Convert stop/remove to string literals. Resolves #168

Removed TFM_Util.isStopCommand(String) and TFM_Util.isRemoveCommand(String)
This commit is contained in:
unknown 2014-05-05 15:31:12 +02:00
parent ad06bea3ae
commit 742450d016
18 changed files with 35 additions and 78 deletions

View File

@ -1,3 +1,3 @@
#Build Number for ANT. Do not edit!
#Mon May 05 14:23:17 CEST 2014
build.number=820
#Mon May 05 15:29:34 CEST 2014
build.number=821

View File

@ -130,9 +130,9 @@ public class Command_adminworld extends TFM_Command
playerMsg("Could not add player to guest list.");
}
}
else if (TFM_Util.isRemoveCommand(args[1]))
else if ("remove".equals(args[1]))
{
Player player = TFM_AdminWorld.getInstance().removeGuest(args[2]);
final Player player = TFM_AdminWorld.getInstance().removeGuest(args[2]);
if (player != null)
{
TFM_Util.adminAction(sender.getName(), "AdminWorld guest removed: " + player.getName(), false);

View File

@ -22,7 +22,7 @@ public class Command_cage extends TFM_Command
return false;
}
if (TFM_Util.isStopCommand(args[0]) && sender instanceof Player)
if ("off".equals(args[0]) && sender instanceof Player)
{
TFM_Util.adminAction(sender.getName(), "Uncaging " + sender.getName(), true);
TFM_PlayerData playerdata = TFM_PlayerData.getPlayerData(sender_p);
@ -33,7 +33,7 @@ public class Command_cage extends TFM_Command
return true;
}
else if ("purge".equalsIgnoreCase(args[0]))
else if ("purge".equals(args[0]))
{
TFM_Util.adminAction(sender.getName(), "Uncaging all players.", true);
@ -63,7 +63,7 @@ public class Command_cage extends TFM_Command
if (args.length >= 2)
{
if (TFM_Util.isStopCommand(args[1]))
if ("off".equals(args[1]))
{
TFM_Util.adminAction(sender.getName(), "Uncaging " + player.getName(), true);

View File

@ -55,13 +55,6 @@ public class Command_enchant extends TFM_Command
{
for (Enchantment ench : Enchantment.values())
{
/*
2013-07-20 23:17:13 [INFO] [TotalFreedomMod]: Command Error: enchant
java.lang.NullPointerException
at net.minecraft.server.v1_6_R2.EnchantmentDurability.canEnchant(SourceFile:33)
at org.bukkit.craftbukkit.v1_6_R2.enchantments.CraftEnchantment.canEnchantItem(CraftEnchantment.java:55)
at me.StevenLawson.TotalFreedomMod.Commands.Command_enchant.run(Command_enchant.java:56)
*/
try
{
if (ench.canEnchantItem(itemInHand))
@ -122,7 +115,7 @@ public class Command_enchant extends TFM_Command
playerMsg("Can't use this enchantment on held item.");
}
}
else if (TFM_Util.isRemoveCommand(args[0]))
else if (args[0].equals("remove"))
{
itemInHand.removeEnchantment(ench);

View File

@ -8,7 +8,7 @@ import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@CommandPermissions(level = AdminLevel.SUPER, source = SourceType.BOTH)
@CommandParameters(description = "Manage jumppads", usage = "/<command> <on | off | info |sideways <on | off> | strength <strength (1-10)>>", aliases = "launchpads,jp")
@CommandParameters(description = "Manage jumppads", usage = "/<command> <on | off | info | sideways <on | off> | strength <strength (1-10)>>", aliases = "launchpads,jp")
public class Command_jumppads extends TFM_Command
{
@Override
@ -29,7 +29,7 @@ public class Command_jumppads extends TFM_Command
return true;
}
if (TFM_Util.isStopCommand(args[0]))
if ("off".equals(args[0]))
{
TFM_Util.adminAction(sender.getName(), "Disabling Jumppads", false);
TFM_Jumppads.getInstance().setMode(TFM_Jumppads.JumpPadMode.OFF);
@ -50,7 +50,7 @@ public class Command_jumppads extends TFM_Command
if (args[0].equalsIgnoreCase("sideways"))
{
if (TFM_Util.isStopCommand(args[1]))
if ("off".equals(args[1]))
{
TFM_Util.adminAction(sender.getName(), "Setting Jumppads mode to: Madgeek", false);
TFM_Jumppads.getInstance().setMode(TFM_Jumppads.JumpPadMode.MADGEEK);

View File

@ -1,34 +0,0 @@
package me.StevenLawson.TotalFreedomMod.Commands;
import me.StevenLawson.TotalFreedomMod.TFM_Util;
import me.StevenLawson.TotalFreedomMod.TotalFreedomMod;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@CommandPermissions(level = AdminLevel.SUPER, source = SourceType.BOTH)
@CommandParameters(description = "Prevents new players from joining the server", usage = "/<command> <on | off>")
public class Command_lockdown extends TFM_Command
{
@Override
public boolean run(CommandSender sender, Player sender_p, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
{
if (args.length != 1)
{
return false;
}
if (TFM_Util.isStopCommand(args[0]))
{
TFM_Util.adminAction(sender.getName(), "De-activating server lockdown", true);
TotalFreedomMod.lockdownEnabled = false;
}
else
{
TFM_Util.adminAction(sender.getName(), "Activating server lockdown", true);
TotalFreedomMod.lockdownEnabled = true;
}
return true;
}
}

View File

@ -59,7 +59,7 @@ public class Command_lockup extends TFM_Command
startLockup(player);
playerMsg("Locked up " + player.getName() + ".");
}
else if (TFM_Util.isStopCommand(args[1]))
else if ("off".equals(args[1]))
{
final Player player = getPlayer(args[0]);

View File

@ -12,7 +12,6 @@ import java.util.Map.Entry;
import me.StevenLawson.TotalFreedomMod.Config.TFM_ConfigEntry;
import me.StevenLawson.TotalFreedomMod.TFM_Log;
import me.StevenLawson.TotalFreedomMod.TFM_Admin;
import me.StevenLawson.TotalFreedomMod.TFM_Util;
import me.StevenLawson.TotalFreedomMod.TotalFreedomMod;
import net.minecraft.util.org.apache.commons.lang3.StringUtils;
import org.bukkit.ChatColor;
@ -32,7 +31,7 @@ public class Command_logs extends TFM_Command
if (args.length == 1)
{
mode = (TFM_Util.isStopCommand(args[0]) ? LogsRegistrationMode.DELETE : LogsRegistrationMode.UPDATE);
mode = ("off".equals(args[0]) ? LogsRegistrationMode.DELETE : LogsRegistrationMode.UPDATE);
}
updateLogsRegistration(sender, sender_p, mode);

View File

@ -19,7 +19,7 @@ public class Command_nicknyan extends TFM_Command
return false;
}
if (TFM_Util.isStopCommand(args[0]))
if ("off".equals(args[0]))
{
TFM_EssentialsBridge.getInstance().setNickname(sender.getName(), null);
playerMsg("Nickname cleared.");

View File

@ -11,7 +11,8 @@ import org.bukkit.entity.Player;
import org.bukkit.util.Vector;
@CommandPermissions(level = AdminLevel.SUPER, source = SourceType.BOTH)
@CommandParameters(description = "POW!!! Right in the kisser! One of these days Alice, straight to the Moon!", usage = "/<command> <target> [power]")
@CommandParameters(description = "POW!!! Right in the kisser! One of these days Alice, straight to the Moon!",
usage = "/<command> <target> [<<power> | stop>]")
public class Command_orbit extends TFM_Command
{
@Override
@ -36,7 +37,7 @@ public class Command_orbit extends TFM_Command
if (args.length >= 2)
{
if (TFM_Util.isStopCommand(args[1]))
if (args[1].equals("stop"))
{
playerMsg("Stopped orbiting " + player.getName());
playerdata.stopOrbiting();
@ -58,7 +59,7 @@ public class Command_orbit extends TFM_Command
playerdata.startOrbiting(strength);
player.setVelocity(new Vector(0, strength, 0));
TFM_Util.adminAction(sender.getName(), "Orbiting " + player.getName() + ".", false);
TFM_Util.adminAction(sender.getName(), "Orbiting " + player.getName(), false);
return true;
}

View File

@ -44,7 +44,7 @@ public class Command_protectarea extends TFM_Command
}
else if (args.length == 2)
{
if (TFM_Util.isRemoveCommand(args[0]))
if ("remove".equals(args[0]))
{
TFM_ProtectedArea.removeProtectedArea(args[1]);

View File

@ -170,7 +170,7 @@ public class Command_saconfig extends TFM_Command
return true;
}
if (TFM_Util.isRemoveCommand(args[0]))
if ("remove".equals(args[0]))
{
if (!TFM_AdminList.isSeniorAdmin(sender))
{

View File

@ -56,7 +56,7 @@ public class Command_tag extends TFM_Command
return true;
}
if (TFM_Util.isStopCommand(args[0]))
if ("remove".equals(args[0]))
{
TFM_PlayerData.getPlayerData(sender_p).setTag(null);
playerMsg("Your tag has been removed.");

View File

@ -4,6 +4,7 @@ import me.StevenLawson.TotalFreedomMod.Config.TFM_ConfigEntry;
import me.StevenLawson.TotalFreedomMod.TFM_GameRuleHandler;
import me.StevenLawson.TotalFreedomMod.TFM_GameRuleHandler.TFM_GameRule;
import me.StevenLawson.TotalFreedomMod.TFM_Util;
import me.StevenLawson.TotalFreedomMod.TotalFreedomMod;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@ -27,6 +28,7 @@ public class Command_toggle extends TFM_Command
playerMsg("- lavadmg");
playerMsg("- firespread");
playerMsg("- prelog");
playerMsg("- lockdown");
playerMsg("- petprotect");
playerMsg("- droptoggle");
playerMsg("- nonuke");
@ -78,6 +80,13 @@ public class Command_toggle extends TFM_Command
return true;
}
if (args[0].equals("lockdown"))
{
TFM_Util.adminAction(sender.getName(), (TotalFreedomMod.lockdownEnabled ? "De-a" : "A") + "ctivating server lockdown", true);
TotalFreedomMod.lockdownEnabled = !TotalFreedomMod.lockdownEnabled;
return true;
}
if (args[0].equals("petprotect"))
{
toggle("Tamed pet protection is", TFM_ConfigEntry.PET_PROTECT_ENABLED);

View File

@ -13,7 +13,8 @@ import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
@CommandPermissions(level = AdminLevel.OP, source = SourceType.ONLY_IN_GAME)
@CommandParameters(description = "Throw a mob in the direction you are facing when you left click with a stick.", usage = "/<command> <mobtype [speed] | off | list>")
@CommandParameters(description = "Throw a mob in the direction you are facing when you left click with a stick.",
usage = "/<command> <mobtype [speed] | off | list>")
public class Command_tossmob extends TFM_Command
{
@Override
@ -30,7 +31,7 @@ public class Command_tossmob extends TFM_Command
EntityType creature = EntityType.PIG;
if (args.length >= 1)
{
if (TFM_Util.isStopCommand(args[0]))
if ("off".equals(args[0]))
{
playerData.disableMobThrower();
playerMsg("MobThrower is disabled.", ChatColor.GREEN);

View File

@ -28,7 +28,7 @@ public class Command_trail extends TFM_Command
@Override
public boolean run(CommandSender sender, Player sender_p, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
{
if (args.length > 0 && TFM_Util.isStopCommand(args[0]))
if (args.length > 0 && "off".equals(args[0]))
{
trailPlayers.remove(sender_p);

View File

@ -101,7 +101,7 @@ public class Command_whitelist extends TFM_Command
}
// remove
if (TFM_Util.isRemoveCommand(args[0]))
if ("remove".equals(args[0]))
{
if (args.length < 2)
{

View File

@ -45,8 +45,6 @@ public class TFM_Util
{
private static final Map<String, Integer> ejectTracker = new HashMap<String, Integer>();
public static final Map<String, EntityType> mobtypes = new HashMap<String, EntityType>();
public static final List<String> STOP_COMMANDS = Arrays.asList("stop", "off", "end", "halt", "die");
public static final List<String> REMOVE_COMMANDS = Arrays.asList("del", "delete", "rem", "remove");
public static final List<String> DEVELOPERS = Arrays.asList("Madgeek1450", "DarthSalamon", "AcidicCyanide", "wild1145", "WickedGamingUK", "xXWilee999Xx");
private static final Random RANDOM = new Random();
public static String DATE_STORAGE_FORMAT = "EEE, d MMM yyyy HH:mm:ss Z";
@ -430,16 +428,6 @@ public class TFM_Util
return new File(plugin.getDataFolder(), name);
}
public static boolean isStopCommand(String command)
{
return STOP_COMMANDS.contains(command.toLowerCase());
}
public static boolean isRemoveCommand(String command)
{
return REMOVE_COMMANDS.contains(command.toLowerCase());
}
public static void autoEject(Player player, String kickMessage)
{
EjectMethod method = EjectMethod.STRIKE_ONE;