Fixed /dtoggle

Apparantly LibsDisguises does not support plugin reloading.
Now switched back to OxLemonxO's method, using a modified LibsDisguises method
This commit is contained in:
JeromSar 2016-08-26 22:06:20 +02:00
parent cadf4e4fc7
commit 2008871658
3 changed files with 24 additions and 16 deletions

View File

@ -1,5 +1,6 @@
package me.totalfreedom.totalfreedommod.bridge;
import me.libraryaddict.disguise.DisallowedDisguises;
import me.libraryaddict.disguise.LibsDisguises;
import me.libraryaddict.disguise.DisguiseAPI;
import me.totalfreedom.totalfreedommod.FreedomService;
@ -49,6 +50,7 @@ public class LibsDisguisesBridge extends FreedomService
FLog.severe(ex);
}
}
return libsDisguisesPlugin;
}
@ -98,25 +100,28 @@ public class LibsDisguisesBridge extends FreedomService
}
}
public boolean setPluginEnabled(boolean enabled)
public void setDisguisesEnabled(boolean state)
{
Plugin ld = getLibsDisguisesPlugin();
final LibsDisguises libsDisguises = getLibsDisguisesPlugin();
if (ld == null)
if (libsDisguises == null)
{
return false;
return;
}
if (enabled)
if (state)
{
server.getPluginManager().enablePlugin(ld);
DisguiseAPI.enableDisguises();
}
else
{
server.getPluginManager().disablePlugin(ld);
DisguiseAPI.disableDisguises();
}
}
return true;
public boolean isDisguisesEnabled()
{
return !DisallowedDisguises.disabled;
}
public boolean isPluginEnabled()

View File

@ -1,5 +1,6 @@
package me.totalfreedom.totalfreedommod.command;
import me.libraryaddict.disguise.DisallowedDisguises;
import me.totalfreedom.totalfreedommod.rank.Rank;
import me.totalfreedom.totalfreedommod.util.FUtil;
import org.bukkit.command.Command;
@ -15,22 +16,25 @@ public class Command_disguisetoggle extends FreedomCommand
@Override
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
{
if (plugin.ldb.getLibsDisguisesPlugin() == null)
if (!plugin.ldb.isPluginEnabled())
{
msg(ChatColor.RED + "LibsDisguises is not enabled.");
return true;
}
boolean newState = !plugin.ldb.isPluginEnabled();
FUtil.adminAction(sender.getName(), (newState ? "Enabling" : "Disabling") + " disguises", false);
FUtil.adminAction(sender.getName(), (DisallowedDisguises.disabled ? "Enabling" : "Disabling") + " Disguises", false);
if (!newState)
if (plugin.ldb.isDisguisesEnabled())
{
plugin.ldb.undisguiseAll(true);
plugin.ldb.setDisguisesEnabled(false);
}
else
{
plugin.ldb.setDisguisesEnabled(true);
}
plugin.ldb.setPluginEnabled(newState);
msg("Disguises are now " + (newState ? "enabled." : "disabled."));
msg("Enabled " + (DisallowedDisguises.disabled ? "enabled." : "disabled."));
return true;
}

View File

@ -1,7 +1,6 @@
package me.totalfreedom.totalfreedommod.command;
public enum SourceType
{
public enum SourceType {
ONLY_IN_GAME, ONLY_CONSOLE, BOTH;
}