2015-10-19 17:43:46 +00:00
|
|
|
package me.totalfreedom.totalfreedommod.commands;
|
2013-08-13 15:16:33 +00:00
|
|
|
|
2015-11-15 23:32:04 +00:00
|
|
|
import me.totalfreedom.totalfreedommod.rank.PlayerRank;
|
|
|
|
import me.totalfreedom.totalfreedommod.fun.Jumppads;
|
2015-10-19 17:43:46 +00:00
|
|
|
import me.totalfreedom.totalfreedommod.util.FUtil;
|
2013-08-13 15:16:33 +00:00
|
|
|
import org.bukkit.ChatColor;
|
|
|
|
import org.bukkit.command.Command;
|
|
|
|
import org.bukkit.command.CommandSender;
|
|
|
|
import org.bukkit.entity.Player;
|
|
|
|
|
2015-10-19 17:43:46 +00:00
|
|
|
@CommandPermissions(level = PlayerRank.SUPER_ADMIN, source = SourceType.BOTH)
|
2014-05-05 13:31:12 +00:00
|
|
|
@CommandParameters(description = "Manage jumppads", usage = "/<command> <on | off | info | sideways <on | off> | strength <strength (1-10)>>", aliases = "launchpads,jp")
|
2015-10-19 17:43:46 +00:00
|
|
|
public class Command_jumppads extends FreedomCommand
|
2013-08-13 15:16:33 +00:00
|
|
|
{
|
2015-11-22 18:26:47 +00:00
|
|
|
|
2013-08-13 15:16:33 +00:00
|
|
|
@Override
|
2015-11-22 18:26:47 +00:00
|
|
|
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
2013-08-13 15:16:33 +00:00
|
|
|
{
|
|
|
|
if (args.length == 0 || args.length > 2)
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (args.length == 1)
|
|
|
|
{
|
|
|
|
if (args[0].equalsIgnoreCase("info"))
|
|
|
|
{
|
2015-10-19 17:43:46 +00:00
|
|
|
playerMsg("Jumppads: " + (plugin.jp.getMode().isOn() ? "Enabled" : "Disabled"), ChatColor.BLUE);
|
|
|
|
playerMsg("Sideways: " + (plugin.jp.getMode() == Jumppads.JumpPadMode.NORMAL_AND_SIDEWAYS ? "Enabled" : "Disabled"), ChatColor.BLUE);
|
|
|
|
playerMsg("Strength: " + (plugin.jp.getStrength() * 10 - 1), ChatColor.BLUE);
|
2013-08-13 15:16:33 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2014-05-05 13:31:12 +00:00
|
|
|
if ("off".equals(args[0]))
|
2013-08-13 15:16:33 +00:00
|
|
|
{
|
2015-10-19 17:43:46 +00:00
|
|
|
FUtil.adminAction(sender.getName(), "Disabling Jumppads", false);
|
|
|
|
plugin.jp.setMode(Jumppads.JumpPadMode.OFF);
|
2013-08-13 15:16:33 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2015-10-19 17:43:46 +00:00
|
|
|
FUtil.adminAction(sender.getName(), "Enabling Jumppads", false);
|
|
|
|
plugin.jp.setMode(Jumppads.JumpPadMode.MADGEEK);
|
2013-08-13 15:16:33 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2015-10-19 17:43:46 +00:00
|
|
|
if (plugin.jp.getMode() == 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"))
|
|
|
|
{
|
2014-05-05 13:31:12 +00:00
|
|
|
if ("off".equals(args[1]))
|
2013-08-13 15:16:33 +00:00
|
|
|
{
|
2015-10-19 17:43:46 +00:00
|
|
|
FUtil.adminAction(sender.getName(), "Setting Jumppads mode to: Madgeek", false);
|
|
|
|
plugin.jp.setMode(Jumppads.JumpPadMode.MADGEEK);
|
2013-08-13 15:16:33 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2015-10-19 17:43:46 +00:00
|
|
|
FUtil.adminAction(sender.getName(), "Setting Jumppads mode to: Normal and Sideways", false);
|
|
|
|
plugin.jp.setMode(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:28:19 +00:00
|
|
|
catch (NumberFormatException ex)
|
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;
|
|
|
|
}
|
|
|
|
|
2015-10-19 17:43:46 +00:00
|
|
|
FUtil.adminAction(sender.getName(), "Setting Jumppads strength to: " + String.valueOf(strength), false);
|
|
|
|
plugin.jp.setStrength((strength / 10) + 0.1F);
|
2013-08-13 15:16:33 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|