2016-03-02 19:28:01 +00:00
|
|
|
package me.totalfreedom.totalfreedommod.command;
|
2013-08-13 15:16:33 +00:00
|
|
|
|
2019-01-29 04:57:41 +00:00
|
|
|
import com.google.common.collect.ContiguousSet;
|
|
|
|
import com.google.common.collect.DiscreteDomain;
|
|
|
|
import com.google.common.collect.Range;
|
|
|
|
import java.util.Arrays;
|
|
|
|
import java.util.Collections;
|
|
|
|
import java.util.List;
|
|
|
|
import java.util.Set;
|
|
|
|
import java.util.stream.DoubleStream;
|
2015-11-15 23:32:04 +00:00
|
|
|
import me.totalfreedom.totalfreedommod.fun.Jumppads;
|
2016-03-06 15:56:15 +00:00
|
|
|
import me.totalfreedom.totalfreedommod.rank.Rank;
|
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;
|
|
|
|
|
2016-03-06 15:56:15 +00:00
|
|
|
@CommandPermissions(level = Rank.SUPER_ADMIN, source = SourceType.BOTH)
|
2019-02-09 09:45:37 +00:00
|
|
|
@CommandParameters(description = "Manage jumppads", usage = "/<command> <on | off | info | sideways <on | off>>", 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"))
|
|
|
|
{
|
2019-02-09 09:45:37 +00:00
|
|
|
msg("Jumppads: " + (plugin.jp.players.get(playerSender).isOn() ? "Enabled" : "Disabled"), ChatColor.BLUE);
|
|
|
|
msg("Sideways: " + (plugin.jp.players.get(playerSender) == Jumppads.JumpPadMode.NORMAL_AND_SIDEWAYS ? "Enabled" : "Disabled"), 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
|
|
|
{
|
2019-02-09 09:45:37 +00:00
|
|
|
if(plugin.jp.players.get(playerSender) == Jumppads.JumpPadMode.OFF)
|
|
|
|
{
|
|
|
|
msg("Your jumppads are already disabled.");
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
msg("Disabled your jumppads.", ChatColor.GRAY);
|
|
|
|
plugin.jp.players.put(playerSender, Jumppads.JumpPadMode.OFF);
|
2013-08-13 15:16:33 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2019-02-09 09:45:37 +00:00
|
|
|
if(plugin.jp.players.get(playerSender) != Jumppads.JumpPadMode.OFF)
|
|
|
|
{
|
|
|
|
msg("Your jumppads are already enabled.");
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
msg("Enabled your jumpppads.", ChatColor.GRAY);
|
|
|
|
plugin.jp.players.put(playerSender, Jumppads.JumpPadMode.MADGEEK);
|
2013-08-13 15:16:33 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2019-02-09 09:45:37 +00:00
|
|
|
if (plugin.jp.players.get(playerSender) == Jumppads.JumpPadMode.OFF)
|
2013-08-13 15:16:33 +00:00
|
|
|
{
|
2019-02-09 09:45:37 +00:00
|
|
|
msg("Your jumppads are currently disabled, please enable them before changing jumppads settings.");
|
2013-08-13 15:16:33 +00:00
|
|
|
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
|
|
|
{
|
2019-02-09 09:45:37 +00:00
|
|
|
if(plugin.jp.players.get(playerSender) == Jumppads.JumpPadMode.MADGEEK)
|
|
|
|
{
|
|
|
|
msg("Your jumppads are already set to normal mode.");
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
msg("Set Jumppads mode to: Normal", ChatColor.GRAY);
|
|
|
|
plugin.jp.players.put(playerSender, Jumppads.JumpPadMode.MADGEEK);
|
2013-08-13 15:16:33 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2019-02-09 09:45:37 +00:00
|
|
|
if(plugin.jp.players.get(playerSender) == Jumppads.JumpPadMode.NORMAL_AND_SIDEWAYS)
|
|
|
|
{
|
|
|
|
msg("Your jumppads are already set to normal and sideways mode.");
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
msg("Set Jumppads mode to: Normal and Sideways", ChatColor.GRAY);
|
|
|
|
plugin.jp.players.put(playerSender, Jumppads.JumpPadMode.NORMAL_AND_SIDEWAYS);
|
2013-08-13 15:16:33 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
2019-01-29 04:57:41 +00:00
|
|
|
|
|
|
|
@Override
|
|
|
|
public List<String> getTabCompleteOptions(CommandSender sender, Command command, String alias, String[] args)
|
|
|
|
{
|
|
|
|
if (!plugin.al.isAdmin(sender))
|
|
|
|
{
|
|
|
|
return Collections.emptyList();
|
|
|
|
}
|
|
|
|
if (args.length == 1)
|
|
|
|
{
|
2019-02-09 09:48:44 +00:00
|
|
|
return Arrays.asList("on", "off", "info", "sideways");
|
2019-01-29 04:57:41 +00:00
|
|
|
}
|
|
|
|
else if (args.length == 2)
|
|
|
|
{
|
|
|
|
if (args[0].equals("sideways"))
|
|
|
|
{
|
|
|
|
return Arrays.asList("on", "off");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return Collections.emptyList();
|
|
|
|
}
|
2013-08-13 15:16:33 +00:00
|
|
|
}
|