Reworked /dtoggle.

This commit is contained in:
StevenLawson 2013-08-12 14:49:33 -04:00
parent c69918d725
commit 0a2d5c8258
2 changed files with 42 additions and 52 deletions

View File

@ -1,52 +0,0 @@
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;
}
}

View File

@ -0,0 +1,42 @@
package me.StevenLawson.TotalFreedomMod.Commands;
import me.StevenLawson.TotalFreedomMod.TFM_Util;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.PluginManager;
@CommandPermissions(level = AdminLevel.SUPER, source = SourceType.BOTH)
@CommandParameters(description = "Shortcut to enable/disable DisguiseCraft.", 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)
{
Plugin disguiseCraft = server.getPluginManager().getPlugin("DisguiseCraft");
if (disguiseCraft != null)
{
PluginManager pluginManager = plugin.getServer().getPluginManager();
boolean enabled = disguiseCraft.isEnabled();
if (enabled)
{
pluginManager.disablePlugin(disguiseCraft);
}
else
{
pluginManager.enablePlugin(disguiseCraft);
}
TFM_Util.adminAction(sender.getName(), (!enabled ? "Enabled" : "Disabled") + " DisguiseCraft.", true);
}
else
{
sender.sendMessage("DisguiseCraft is not installed on this server.");
}
return true;
}
}