mirror of
https://github.com/AtlasMediaGroup/TotalFreedomMod.git
synced 2024-11-27 01:05:38 +00:00
Added Command_plugincontrol.
This commit is contained in:
parent
b135aa8b58
commit
f3b04ee828
@ -1,5 +1,5 @@
|
|||||||
#Sat, 23 Mar 2013 15:17:32 -0400
|
#Sat, 23 Mar 2013 17:16:26 -0400
|
||||||
|
|
||||||
program.VERSION=2.12
|
program.VERSION=2.12
|
||||||
program.BUILDNUM=105
|
program.BUILDNUM=110
|
||||||
program.BUILDDATE=03/23/2013 03\:17 PM
|
program.BUILDDATE=03/23/2013 05\:16 PM
|
||||||
|
@ -1,3 +1,3 @@
|
|||||||
#Build Number for ANT. Do not edit!
|
#Build Number for ANT. Do not edit!
|
||||||
#Sat Mar 23 15:17:32 EDT 2013
|
#Sat Mar 23 17:16:26 EDT 2013
|
||||||
build.number=106
|
build.number=111
|
||||||
|
@ -0,0 +1,128 @@
|
|||||||
|
package me.StevenLawson.TotalFreedomMod.Commands;
|
||||||
|
|
||||||
|
import org.apache.commons.lang.StringUtils;
|
||||||
|
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.SENIOR, source = SourceType.BOTH)
|
||||||
|
public class Command_plugincontrol extends TFM_Command
|
||||||
|
{
|
||||||
|
private enum CommandMode
|
||||||
|
{
|
||||||
|
ENABLE, DISABLE, LIST, RELOAD
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean run(CommandSender sender, Player sender_p, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||||
|
{
|
||||||
|
CommandMode commandMode = null;
|
||||||
|
|
||||||
|
if (args.length == 1)
|
||||||
|
{
|
||||||
|
if (args[0].equalsIgnoreCase("list"))
|
||||||
|
{
|
||||||
|
commandMode = CommandMode.LIST;
|
||||||
|
}
|
||||||
|
else if (args[0].equalsIgnoreCase("reload"))
|
||||||
|
{
|
||||||
|
commandMode = CommandMode.RELOAD;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (args.length >= 2)
|
||||||
|
{
|
||||||
|
if (args[0].equalsIgnoreCase("enable"))
|
||||||
|
{
|
||||||
|
commandMode = CommandMode.ENABLE;
|
||||||
|
}
|
||||||
|
else if (args[0].equalsIgnoreCase("disable"))
|
||||||
|
{
|
||||||
|
commandMode = CommandMode.DISABLE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (commandMode == null)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
PluginManager pluginManager = plugin.getServer().getPluginManager();
|
||||||
|
|
||||||
|
if (commandMode == CommandMode.LIST)
|
||||||
|
{
|
||||||
|
playerMsg("Plugins: " + StringUtils.join(pluginManager.getPlugins(), ", "));
|
||||||
|
}
|
||||||
|
else if (commandMode == CommandMode.RELOAD)
|
||||||
|
{
|
||||||
|
playerMsg("Disabling all plugins.");
|
||||||
|
for (Plugin p : pluginManager.getPlugins())
|
||||||
|
{
|
||||||
|
if (!p.getName().toLowerCase().startsWith("totalfreedommod"))
|
||||||
|
{
|
||||||
|
pluginManager.disablePlugin(p);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
playerMsg("Enabling all plugins.");
|
||||||
|
for (Plugin p : pluginManager.getPlugins())
|
||||||
|
{
|
||||||
|
if (!p.getName().toLowerCase().startsWith("totalfreedommod"))
|
||||||
|
{
|
||||||
|
pluginManager.enablePlugin(p);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
final String searchPluginName = args[1].toLowerCase().trim();
|
||||||
|
|
||||||
|
Plugin targetPlugin = null;
|
||||||
|
|
||||||
|
for (Plugin p : pluginManager.getPlugins())
|
||||||
|
{
|
||||||
|
if (searchPluginName.equalsIgnoreCase(p.getName().toLowerCase().trim()))
|
||||||
|
{
|
||||||
|
targetPlugin = p;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (targetPlugin == null)
|
||||||
|
{
|
||||||
|
playerMsg("Plugin \"" + searchPluginName + "\" is not installed.");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (commandMode == CommandMode.ENABLE)
|
||||||
|
{
|
||||||
|
pluginManager.enablePlugin(targetPlugin);
|
||||||
|
if (targetPlugin.isEnabled())
|
||||||
|
{
|
||||||
|
playerMsg("Plugin \"" + targetPlugin.getName() + "\" enabled.");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
playerMsg("Error enabling plugin \"" + targetPlugin.getName() + "\".");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
pluginManager.disablePlugin(targetPlugin);
|
||||||
|
if (!targetPlugin.isEnabled())
|
||||||
|
{
|
||||||
|
playerMsg("Plugin \"" + targetPlugin.getName() + "\" disabled.");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
playerMsg("Error disabling plugin \"" + targetPlugin.getName() + "\".");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
@ -163,6 +163,9 @@ commands:
|
|||||||
permban:
|
permban:
|
||||||
description: Manage permanently banned players and IPs
|
description: Manage permanently banned players and IPs
|
||||||
usage: /<command> <list | reload>
|
usage: /<command> <list | reload>
|
||||||
|
plugincontrol:
|
||||||
|
description: Senior Command - Enable / disable plugins.
|
||||||
|
usage: /<command> < <enable | disable> <pluginname> | list >
|
||||||
potion:
|
potion:
|
||||||
description: Manipulate potion effects. Duration is measured in server ticks (~20 ticks per second).
|
description: Manipulate potion effects. Duration is measured in server ticks (~20 ticks per second).
|
||||||
usage: /<command> <list | clear [target_name] | add <type> <duration> <amplifier> [target_name]>
|
usage: /<command> <list | clear [target_name] | add <type> <duration> <amplifier> [target_name]>
|
||||||
|
Loading…
Reference in New Issue
Block a user