Readd /uall and /dtoggle. Resolves #1793

This commit is contained in:
CreeperSeth 2016-07-21 14:53:25 -07:00 committed by JeromSar
parent 662cef44d5
commit cadf4e4fc7
6 changed files with 218 additions and 1 deletions

View File

@ -96,6 +96,14 @@
<scope>system</scope> <scope>system</scope>
<systemPath>${project.basedir}/lib/TF-Essentials-2.1.jar</systemPath> <systemPath>${project.basedir}/lib/TF-Essentials-2.1.jar</systemPath>
</dependency> </dependency>
<dependency>
<groupId>me.libaryaddict.disguise</groupId>
<artifactId>LibsDisguises</artifactId>
<version>9.0.9</version>
<scope>system</scope>
<systemPath>${project.basedir}/lib/LibsDisguises-9.0.9.jar</systemPath>
</dependency>
</dependencies> </dependencies>
<build> <build>

View File

@ -16,6 +16,7 @@ import me.totalfreedom.totalfreedommod.blocking.PotionBlocker;
import me.totalfreedom.totalfreedommod.blocking.command.CommandBlocker; import me.totalfreedom.totalfreedommod.blocking.command.CommandBlocker;
import me.totalfreedom.totalfreedommod.bridge.BukkitTelnetBridge; import me.totalfreedom.totalfreedommod.bridge.BukkitTelnetBridge;
import me.totalfreedom.totalfreedommod.bridge.EssentialsBridge; import me.totalfreedom.totalfreedommod.bridge.EssentialsBridge;
import me.totalfreedom.totalfreedommod.bridge.LibsDisguisesBridge;
import me.totalfreedom.totalfreedommod.bridge.WorldEditBridge; import me.totalfreedom.totalfreedommod.bridge.WorldEditBridge;
import me.totalfreedom.totalfreedommod.caging.Cager; import me.totalfreedom.totalfreedommod.caging.Cager;
import me.totalfreedom.totalfreedommod.command.CommandLoader; import me.totalfreedom.totalfreedommod.command.CommandLoader;
@ -101,6 +102,7 @@ public class TotalFreedomMod extends AeroPlugin<TotalFreedomMod>
public ServiceManager<TotalFreedomMod> bridges; public ServiceManager<TotalFreedomMod> bridges;
public BukkitTelnetBridge btb; public BukkitTelnetBridge btb;
public EssentialsBridge esb; public EssentialsBridge esb;
public LibsDisguisesBridge ldb;
public WorldEditBridge web; public WorldEditBridge web;
@Override @Override
@ -201,6 +203,7 @@ public class TotalFreedomMod extends AeroPlugin<TotalFreedomMod>
bridges = new ServiceManager<>(plugin); bridges = new ServiceManager<>(plugin);
btb = bridges.registerService(BukkitTelnetBridge.class); btb = bridges.registerService(BukkitTelnetBridge.class);
esb = bridges.registerService(EssentialsBridge.class); esb = bridges.registerService(EssentialsBridge.class);
ldb = bridges.registerService(LibsDisguisesBridge.class);
web = bridges.registerService(WorldEditBridge.class); web = bridges.registerService(WorldEditBridge.class);
bridges.start(); bridges.start();

View File

@ -0,0 +1,133 @@
package me.totalfreedom.totalfreedommod.bridge;
import me.libraryaddict.disguise.LibsDisguises;
import me.libraryaddict.disguise.DisguiseAPI;
import me.totalfreedom.totalfreedommod.FreedomService;
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
import me.totalfreedom.totalfreedommod.util.FLog;
import org.bukkit.entity.Player;
import org.bukkit.Bukkit;
import org.bukkit.plugin.Plugin;
public class LibsDisguisesBridge extends FreedomService
{
private LibsDisguises libsDisguisesPlugin = null;
public LibsDisguisesBridge(TotalFreedomMod plugin)
{
super(plugin);
}
@Override
protected void onStart()
{
}
@Override
protected void onStop()
{
}
public LibsDisguises getLibsDisguisesPlugin()
{
if (libsDisguisesPlugin == null)
{
try
{
final Plugin libsDisguises = server.getPluginManager().getPlugin("LibsDisguises");
if (libsDisguises != null)
{
if (libsDisguises instanceof LibsDisguises)
{
libsDisguisesPlugin = (LibsDisguises) libsDisguises;
}
}
}
catch (Exception ex)
{
FLog.severe(ex);
}
}
return libsDisguisesPlugin;
}
public Boolean isDisguised(Player player)
{
try
{
final LibsDisguises libsDisguises = getLibsDisguisesPlugin();
if (libsDisguises != null)
{
return DisguiseAPI.isDisguised(player);
}
}
catch (Exception ex)
{
FLog.severe(ex);
}
return null;
}
public void undisguiseAll(boolean admins)
{
try
{
final LibsDisguises libsDisguises = getLibsDisguisesPlugin();
if (libsDisguises == null)
{
return;
}
for (Player player : server.getOnlinePlayers())
{
if (DisguiseAPI.isDisguised(player))
{
if (!admins && plugin.al.isAdmin(player))
{
continue;
}
DisguiseAPI.undisguiseToAll(player);
}
}
}
catch (Exception ex)
{
FLog.severe(ex);
}
}
public boolean setPluginEnabled(boolean enabled)
{
Plugin ld = getLibsDisguisesPlugin();
if (ld == null)
{
return false;
}
if (enabled)
{
server.getPluginManager().enablePlugin(ld);
}
else
{
server.getPluginManager().disablePlugin(ld);
}
return true;
}
public boolean isPluginEnabled()
{
Plugin ld = getLibsDisguisesPlugin();
if (ld == null)
{
return false;
}
return ld.isEnabled();
}
}

View File

@ -0,0 +1,37 @@
package me.totalfreedom.totalfreedommod.command;
import me.totalfreedom.totalfreedommod.rank.Rank;
import me.totalfreedom.totalfreedommod.util.FUtil;
import org.bukkit.command.Command;
import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@CommandPermissions(level = Rank.SUPER_ADMIN, source = SourceType.BOTH)
@CommandParameters(description = "Toggle the disguise plugin", usage = "/<command>", aliases = "dtoggle")
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)
{
msg(ChatColor.RED + "LibsDisguises is not enabled.");
return true;
}
boolean newState = !plugin.ldb.isPluginEnabled();
FUtil.adminAction(sender.getName(), (newState ? "Enabling" : "Disabling") + " disguises", false);
if (!newState)
{
plugin.ldb.undisguiseAll(true);
}
plugin.ldb.setPluginEnabled(newState);
msg("Disguises are now " + (newState ? "enabled." : "disabled."));
return true;
}
}

View File

@ -0,0 +1,36 @@
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;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@CommandPermissions(level = Rank.SUPER_ADMIN, source = SourceType.BOTH)
@CommandParameters(description = "Undisguise all players on the server", usage = "/<command>", aliases = "uall")
public class Command_undisguiseall extends FreedomCommand
{
@Override
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
{
if (!plugin.ldb.isPluginEnabled())
{
msg("LibsDisguises is not enabled.");
return true;
}
if (DisallowedDisguises.disabled)
{
msg("Disguises are not enabled.");
return true;
}
FUtil.adminAction(sender.getName(), "Undisguising all non-admins", true);
plugin.ldb.undisguiseAll(false);
return true;
}
}

View File

@ -3,7 +3,7 @@ main: me.totalfreedom.totalfreedommod.TotalFreedomMod
version: ${tfm.build.version} version: ${tfm.build.version}
description: Plugin for the Total Freedom server. description: Plugin for the Total Freedom server.
depend: [Aero, WorldEdit] depend: [Aero, WorldEdit]
softdepend: [BukkitTelnet, Essentials] softdepend: [BukkitTelnet, Essentials, LibsDisguises]
authors: [Madgeek1450, Prozza] authors: [Madgeek1450, Prozza]
# plugin.yml is no longer used to define commands. # plugin.yml is no longer used to define commands.