TotalFreedomMod/src/me/StevenLawson/TotalFreedomMod/Commands/Command_jumppads.java

95 lines
3.6 KiB
Java
Raw Normal View History

2013-08-13 15:16:33 +00:00
package me.StevenLawson.TotalFreedomMod.Commands;
import me.StevenLawson.TotalFreedomMod.TFM_Jumppads;
import me.StevenLawson.TotalFreedomMod.TFM_Util;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
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")
public class Command_jumppads extends TFM_Command
{
@Override
public boolean run(CommandSender sender, Player sender_p, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
{
if (args.length == 0 || args.length > 2)
{
return false;
}
if (args.length == 1)
{
if (args[0].equalsIgnoreCase("info"))
{
2013-08-13 18:53:33 +00:00
playerMsg("Jumppads: " + (TFM_Jumppads.getInstance().getMode().isOn() ? "Enabled" : "Disabled"), ChatColor.BLUE);
playerMsg("Sideways: " + (TFM_Jumppads.getInstance().getMode() == TFM_Jumppads.JumpPadMode.NORMAL_AND_SIDEWAYS ? "Enabled" : "Disabled"), ChatColor.BLUE);
playerMsg("Strength: " + (TFM_Jumppads.getInstance().getStrength() * 10 - 1), ChatColor.BLUE);
2013-08-13 15:16:33 +00:00
return true;
}
if (TFM_Util.isStopCommand(args[0]))
{
TFM_Util.adminAction(sender.getName(), "Disabling Jumppads", false);
2013-08-13 18:53:33 +00:00
TFM_Jumppads.getInstance().setMode(TFM_Jumppads.JumpPadMode.OFF);
2013-08-13 15:16:33 +00:00
}
else
{
TFM_Util.adminAction(sender.getName(), "Enabling Jumppads", false);
2013-08-13 20:54:20 +00:00
TFM_Jumppads.getInstance().setMode(TFM_Jumppads.JumpPadMode.MADGEEK);
2013-08-13 15:16:33 +00:00
}
}
else
{
2013-08-13 18:53:33 +00:00
if (TFM_Jumppads.getInstance().getMode() == TFM_Jumppads.JumpPadMode.OFF)
2013-08-13 15:16:33 +00:00
{
playerMsg("Jumppads are currently disabled, please enable them before changing jumppads settings.");
return true;
}
if (args[0].equalsIgnoreCase("sideways"))
{
if (TFM_Util.isStopCommand(args[1]))
{
2013-08-13 20:54:20 +00:00
TFM_Util.adminAction(sender.getName(), "Setting Jumppads mode to: Madgeek", false);
TFM_Jumppads.getInstance().setMode(TFM_Jumppads.JumpPadMode.MADGEEK);
2013-08-13 15:16:33 +00:00
}
else
{
TFM_Util.adminAction(sender.getName(), "Setting Jumppads mode to: Normal and Sideways", false);
2013-08-13 18:53:33 +00:00
TFM_Jumppads.getInstance().setMode(TFM_Jumppads.JumpPadMode.NORMAL_AND_SIDEWAYS);
2013-08-13 15:16:33 +00:00
}
}
else if (args[0].equalsIgnoreCase("strength"))
{
final float strength;
try
{
strength = Float.parseFloat(args[1]);
}
2013-08-14 13:12:30 +00:00
catch (NumberFormatException e)
2013-08-13 15:16:33 +00:00
{
playerMsg("Invalid Strength");
return true;
}
if (strength > 10 || strength < 1)
{
playerMsg("Invalid Strength: The strength may be 1 through 10.");
return true;
}
2013-08-13 16:21:37 +00:00
TFM_Util.adminAction(sender.getName(), "Setting Jumppads strength to: " + String.valueOf(strength), false);
2013-08-13 18:53:33 +00:00
TFM_Jumppads.getInstance().setStrength((strength / 10) + 0.1F);
2013-08-13 15:16:33 +00:00
}
else
{
return false;
}
}
return true;
}
}