Create Command_dtoggle

This is a replacement for DisdFreedom dtoggle, something we had to add on CJFreedom shortly after we lost his plugin :)
This commit is contained in:
Ryan 2013-08-12 19:28:41 +01:00
parent c1d0c01524
commit c69918d725

View file

@ -0,0 +1,52 @@
package me.StevenLawson.TotalFreedomMod.Commands;
import me.StevenLawson.TotalFreedomMod.TotalFreedomMod;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.plugin.Plugin;
@CommandPermissions(level = AdminLevel.SUPER, source = SourceType.BOTH)
@CommandParameters(description = "CJFreedom Version To Manage DisguiseCraft ~ Thanks Dartheh <3.", usage = "/<command>")
public class Command_dtoggle extends TFM_Command
{
@Override
public boolean run(CommandSender sender, Player sender_p, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
{
boolean toggled = false;
boolean enabled = true;
for (Plugin p : TotalFreedomMod.server.getPluginManager().getPlugins())
{
if (p.getName().equalsIgnoreCase("DisguiseCraft"))
{
if (p.isEnabled())
{
p.getPluginLoader().disablePlugin(p);
enabled = false;
}
else
{
p.getPluginLoader().enablePlugin(p);
enabled = true;
}
toggled = true;
}
}
if (toggled)
{
if (!enabled)
{
TotalFreedomMod.server.broadcastMessage(ChatColor.RED + sender.getName() + " - Disabling DisguiseCraft");
}
else
{
TotalFreedomMod.server.broadcastMessage(ChatColor.GREEN + sender.getName() + " - Enabling DisguiseCraft");
}
}
return true;
}
}