diff --git a/NachoSpigot-API/src/main/java/org/bukkit/command/defaults/AchievementCommand.java b/NachoSpigot-API/src/main/java/org/bukkit/command/defaults/AchievementCommand.java deleted file mode 100644 index c2e179505..000000000 --- a/NachoSpigot-API/src/main/java/org/bukkit/command/defaults/AchievementCommand.java +++ /dev/null @@ -1,188 +0,0 @@ -package org.bukkit.command.defaults; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; - -import org.apache.commons.lang.Validate; -import org.bukkit.Achievement; -import org.bukkit.Bukkit; -import org.bukkit.ChatColor; -import org.bukkit.Statistic; -import org.bukkit.Material; -import org.bukkit.Statistic.Type; -import org.bukkit.command.Command; -import org.bukkit.command.CommandSender; -import org.bukkit.entity.EntityType; -import org.bukkit.entity.Player; -import org.bukkit.event.player.PlayerAchievementAwardedEvent; -import org.bukkit.event.player.PlayerStatisticIncrementEvent; - -import com.google.common.collect.ImmutableList; - -@Deprecated -public class AchievementCommand extends VanillaCommand { - public AchievementCommand() { - super("achievement"); - this.description = "Gives the specified player an achievement or changes a statistic value. Use '*' to give all achievements."; - this.usageMessage = "/achievement give [player]"; - this.setPermission("bukkit.command.achievement"); - } - - @Override - public boolean execute(CommandSender sender, String currentAlias, String[] args) { - if (!testPermission(sender)) return true; - - if (args.length < 2) { - sender.sendMessage(ChatColor.RED + "Usage: " + usageMessage); - return false; - } - - if (!args[0].equalsIgnoreCase("give")) { - sender.sendMessage(ChatColor.RED + "Usage: " + usageMessage); - return false; - } - - String statisticString = args[1]; - Player player = null; - - if (args.length > 2) { - player = Bukkit.getPlayer(args[1]); - } else if (sender instanceof Player) { - player = (Player) sender; - } - - if (player == null) { - sender.sendMessage("You must specify which player you wish to perform this action on."); - return true; - } - - if (statisticString.equals("*")) { - for (Achievement achievement : Achievement.values()) { - if (player.hasAchievement(achievement)) { - continue; - } - PlayerAchievementAwardedEvent event = new PlayerAchievementAwardedEvent(player, achievement); - Bukkit.getServer().getPluginManager().callEvent(event); - if (!event.isCancelled()) { - player.awardAchievement(achievement); - } - } - Command.broadcastCommandMessage(sender, String.format("Successfully given all achievements to %s", player.getName())); - return true; - } - - Achievement achievement = Bukkit.getUnsafe().getAchievementFromInternalName(statisticString); - Statistic statistic = Bukkit.getUnsafe().getStatisticFromInternalName(statisticString); - - if (achievement != null) { - if (player.hasAchievement(achievement)) { - sender.sendMessage(String.format("%s already has achievement %s", player.getName(), statisticString)); - return true; - } - - PlayerAchievementAwardedEvent event = new PlayerAchievementAwardedEvent(player, achievement); - Bukkit.getServer().getPluginManager().callEvent(event); - if (event.isCancelled()) { - sender.sendMessage(String.format("Unable to award %s the achievement %s", player.getName(), statisticString)); - return true; - } - player.awardAchievement(achievement); - - Command.broadcastCommandMessage(sender, String.format("Successfully given %s the stat %s", player.getName(), statisticString)); - return true; - } - - if (statistic == null) { - sender.sendMessage(String.format("Unknown achievement or statistic '%s'", statisticString)); - return true; - } - - if (statistic.getType() == Type.UNTYPED) { - PlayerStatisticIncrementEvent event = new PlayerStatisticIncrementEvent(player, statistic, player.getStatistic(statistic), player.getStatistic(statistic) + 1); - Bukkit.getServer().getPluginManager().callEvent(event); - if (event.isCancelled()) { - sender.sendMessage(String.format("Unable to increment %s for %s", statisticString, player.getName())); - return true; - } - player.incrementStatistic(statistic); - Command.broadcastCommandMessage(sender, String.format("Successfully given %s the stat %s", player.getName(), statisticString)); - return true; - } - - if (statistic.getType() == Type.ENTITY) { - EntityType entityType = EntityType.fromName(statisticString.substring(statisticString.lastIndexOf(".") + 1)); - - if (entityType == null) { - sender.sendMessage(String.format("Unknown achievement or statistic '%s'", statisticString)); - return true; - } - - PlayerStatisticIncrementEvent event = new PlayerStatisticIncrementEvent(player, statistic, player.getStatistic(statistic), player.getStatistic(statistic) + 1, entityType); - Bukkit.getServer().getPluginManager().callEvent(event); - if (event.isCancelled()) { - sender.sendMessage(String.format("Unable to increment %s for %s", statisticString, player.getName())); - return true; - } - - try { - player.incrementStatistic(statistic, entityType); - } catch (IllegalArgumentException e) { - sender.sendMessage(String.format("Unknown achievement or statistic '%s'", statisticString)); - return true; - } - } else { - int id; - try { - id = getInteger(sender, statisticString.substring(statisticString.lastIndexOf(".") + 1), 0, Integer.MAX_VALUE, true); - } catch (NumberFormatException e) { - sender.sendMessage(e.getMessage()); - return true; - } - - Material material = Material.getMaterial(id); - - if (material == null) { - sender.sendMessage(String.format("Unknown achievement or statistic '%s'", statisticString)); - return true; - } - - PlayerStatisticIncrementEvent event = new PlayerStatisticIncrementEvent(player, statistic, player.getStatistic(statistic), player.getStatistic(statistic) + 1, material); - Bukkit.getServer().getPluginManager().callEvent(event); - if (event.isCancelled()) { - sender.sendMessage(String.format("Unable to increment %s for %s", statisticString, player.getName())); - return true; - } - - try { - player.incrementStatistic(statistic, material); - } catch (IllegalArgumentException e) { - sender.sendMessage(String.format("Unknown achievement or statistic '%s'", statisticString)); - return true; - } - } - - Command.broadcastCommandMessage(sender, String.format("Successfully given %s the stat %s", player.getName(), statisticString)); - return true; - } - - @Override - public List tabComplete(CommandSender sender, String alias, String[] args) throws IllegalArgumentException { - Validate.notNull(sender, "Sender cannot be null"); - Validate.notNull(args, "Arguments cannot be null"); - Validate.notNull(alias, "Alias cannot be null"); - - if (args.length == 1) { - return Arrays.asList("give"); - } - - if (args.length == 2) { - return Bukkit.getUnsafe().tabCompleteInternalStatisticOrAchievementName(args[1], new ArrayList()); - } - - if (args.length == 3) { - return super.tabComplete(sender, alias, args); - } - return ImmutableList.of(); - } -} diff --git a/NachoSpigot-API/src/main/java/org/bukkit/command/defaults/BanCommand.java b/NachoSpigot-API/src/main/java/org/bukkit/command/defaults/BanCommand.java deleted file mode 100644 index 59b804ce6..000000000 --- a/NachoSpigot-API/src/main/java/org/bukkit/command/defaults/BanCommand.java +++ /dev/null @@ -1,56 +0,0 @@ -package org.bukkit.command.defaults; - -import java.util.List; - -import org.apache.commons.lang.StringUtils; -import org.apache.commons.lang.Validate; -import org.bukkit.BanList; -import org.bukkit.Bukkit; -import org.bukkit.ChatColor; -import org.bukkit.command.Command; -import org.bukkit.command.CommandSender; -import org.bukkit.entity.Player; - -import com.google.common.collect.ImmutableList; - -@Deprecated -public class BanCommand extends VanillaCommand { - public BanCommand() { - super("ban"); - this.description = "Prevents the specified player from using this server"; - this.usageMessage = "/ban [reason ...]"; - this.setPermission("bukkit.command.ban.player"); - } - - @Override - public boolean execute(CommandSender sender, String currentAlias, String[] args) { - if (!testPermission(sender)) return true; - if (args.length == 0) { - sender.sendMessage(ChatColor.RED + "Usage: " + usageMessage); - return false; - } - - String reason = args.length > 0 ? StringUtils.join(args, ' ', 1, args.length) : null; - Bukkit.getBanList(BanList.Type.NAME).addBan(args[0], reason, null, sender.getName()); - - Player player = Bukkit.getPlayer(args[0]); - if (player != null) { - player.kickPlayer("Banned by admin."); - } - - Command.broadcastCommandMessage(sender, "Banned player " + args[0]); - return true; - } - - @Override - public List tabComplete(CommandSender sender, String alias, String[] args) throws IllegalArgumentException { - Validate.notNull(sender, "Sender cannot be null"); - Validate.notNull(args, "Arguments cannot be null"); - Validate.notNull(alias, "Alias cannot be null"); - - if (args.length >= 1) { - return super.tabComplete(sender, alias, args); - } - return ImmutableList.of(); - } -} diff --git a/NachoSpigot-API/src/main/java/org/bukkit/command/defaults/BanIpCommand.java b/NachoSpigot-API/src/main/java/org/bukkit/command/defaults/BanIpCommand.java deleted file mode 100644 index 9fcd04663..000000000 --- a/NachoSpigot-API/src/main/java/org/bukkit/command/defaults/BanIpCommand.java +++ /dev/null @@ -1,78 +0,0 @@ -package org.bukkit.command.defaults; - -import java.util.List; -import java.util.regex.Pattern; - -import org.apache.commons.lang.StringUtils; -import org.apache.commons.lang.Validate; -import org.bukkit.BanList; -import org.bukkit.Bukkit; -import org.bukkit.ChatColor; -import org.bukkit.command.Command; -import org.bukkit.command.CommandSender; -import org.bukkit.entity.Player; - -import com.google.common.collect.ImmutableList; - -@Deprecated -public class BanIpCommand extends VanillaCommand { - public static final Pattern ipValidity = Pattern.compile("^([01]?\\d\\d?|2[0-4]\\d|25[0-5])\\.([01]?\\d\\d?|2[0-4]\\d|25[0-5])\\.([01]?\\d\\d?|2[0-4]\\d|25[0-5])\\.([01]?\\d\\d?|2[0-4]\\d|25[0-5])$"); - - public BanIpCommand() { - super("ban-ip"); - this.description = "Prevents the specified IP address from using this server"; - this.usageMessage = "/ban-ip [reason ...]"; - this.setPermission("bukkit.command.ban.ip"); - } - - @Override - public boolean execute(CommandSender sender, String currentAlias, String[] args) { - if (!testPermission(sender)) return true; - if (args.length < 1) { - sender.sendMessage(ChatColor.RED + "Usage: " + usageMessage); - return false; - } - - String reason = args.length > 0 ? StringUtils.join(args, ' ', 1, args.length) : null; - - if (ipValidity.matcher(args[0]).matches()) { - processIPBan(args[0], sender, reason); - } else { - Player player = Bukkit.getPlayer(args[0]); - - if (player == null) { - sender.sendMessage(ChatColor.RED + "Usage: " + usageMessage); - return false; - } - - processIPBan(player.getAddress().getAddress().getHostAddress(), sender, reason); - } - - return true; - } - - private void processIPBan(String ip, CommandSender sender, String reason) { - Bukkit.getBanList(BanList.Type.IP).addBan(ip, reason, null, sender.getName()); - - // Find all matching players and kick - for (Player player : Bukkit.getOnlinePlayers()) { - if (player.getAddress().getAddress().getHostAddress().equals(ip)) { - player.kickPlayer("You have been IP banned."); - } - } - - Command.broadcastCommandMessage(sender, "Banned IP Address " + ip); - } - - @Override - public List tabComplete(CommandSender sender, String alias, String[] args) throws IllegalArgumentException { - Validate.notNull(sender, "Sender cannot be null"); - Validate.notNull(args, "Arguments cannot be null"); - Validate.notNull(alias, "Alias cannot be null"); - - if (args.length == 1) { - return super.tabComplete(sender, alias, args); - } - return ImmutableList.of(); - } -} diff --git a/NachoSpigot-API/src/main/java/org/bukkit/command/defaults/BanListCommand.java b/NachoSpigot-API/src/main/java/org/bukkit/command/defaults/BanListCommand.java deleted file mode 100644 index 182914342..000000000 --- a/NachoSpigot-API/src/main/java/org/bukkit/command/defaults/BanListCommand.java +++ /dev/null @@ -1,72 +0,0 @@ -package org.bukkit.command.defaults; - -import java.util.ArrayList; -import java.util.List; - -import org.apache.commons.lang.Validate; -import org.bukkit.BanEntry; -import org.bukkit.BanList; -import org.bukkit.Bukkit; -import org.bukkit.ChatColor; -import org.bukkit.command.CommandSender; -import org.bukkit.util.StringUtil; - -import com.google.common.collect.ImmutableList; - -@Deprecated -public class BanListCommand extends VanillaCommand { - private static final List BANLIST_TYPES = ImmutableList.of("ips", "players"); - - public BanListCommand() { - super("banlist"); - this.description = "View all players banned from this server"; - this.usageMessage = "/banlist [ips|players]"; - this.setPermission("bukkit.command.ban.list"); - } - - @Override - public boolean execute(CommandSender sender, String currentAlias, String[] args) { - if (!testPermission(sender)) return true; - - BanList.Type banType = BanList.Type.NAME; - if (args.length > 0) { - if (args[0].equalsIgnoreCase("ips")) { - banType = BanList.Type.IP; - } else if (!args[0].equalsIgnoreCase("players")) { - sender.sendMessage(ChatColor.RED + "Usage: " + usageMessage); - return false; - } - } - - StringBuilder message = new StringBuilder(); - BanEntry[] banlist = Bukkit.getBanList(banType).getBanEntries().toArray(new BanEntry[0]); - - for (int x = 0; x < banlist.length; x++) { - if (x != 0) { - if (x == banlist.length - 1) { - message.append(" and "); - } else { - message.append(", "); - } - } - - message.append(banlist[x].getTarget()); - } - - sender.sendMessage("There are " + banlist.length + " total banned players:"); - sender.sendMessage(message.toString()); - return true; - } - - @Override - public List tabComplete(CommandSender sender, String alias, String[] args) { - Validate.notNull(sender, "Sender cannot be null"); - Validate.notNull(args, "Arguments cannot be null"); - Validate.notNull(alias, "Alias cannot be null"); - - if (args.length == 1) { - return StringUtil.copyPartialMatches(args[0], BANLIST_TYPES, new ArrayList(BANLIST_TYPES.size())); - } - return ImmutableList.of(); - } -} diff --git a/NachoSpigot-API/src/main/java/org/bukkit/command/defaults/ClearCommand.java b/NachoSpigot-API/src/main/java/org/bukkit/command/defaults/ClearCommand.java deleted file mode 100644 index 05317e14a..000000000 --- a/NachoSpigot-API/src/main/java/org/bukkit/command/defaults/ClearCommand.java +++ /dev/null @@ -1,115 +0,0 @@ -package org.bukkit.command.defaults; - -import com.google.common.collect.ImmutableList; -import org.apache.commons.lang.Validate; -import org.bukkit.Bukkit; -import org.bukkit.ChatColor; -import org.bukkit.Material; -import org.bukkit.command.Command; -import org.bukkit.command.CommandSender; -import org.bukkit.entity.Player; -import org.bukkit.util.StringUtil; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; - -@Deprecated -public class ClearCommand extends VanillaCommand { - private static List materials; - static { - ArrayList materialList = new ArrayList(); - for (Material material : Material.values()) { - materialList.add(material.name()); - } - Collections.sort(materialList); - materials = ImmutableList.copyOf(materialList); - } - - public ClearCommand() { - super("clear"); - this.description = "Clears the player's inventory. Can specify item and data filters too."; - this.usageMessage = "/clear [item] [data]"; - this.setPermission("bukkit.command.clear"); - } - - @Override - public boolean execute(CommandSender sender, String currentAlias, String[] args) { - if (!testPermission(sender)) return true; - - Player player = null; - if (args.length > 0) { - player = Bukkit.getPlayer(args[0]); - } else if (sender instanceof Player) { - player = (Player) sender; - } - - if (player != null) { - int id; - - if (args.length > 1 && !(args[1].equals("-1"))) { - Material material = Material.matchMaterial(args[1]); - if (material == null) { - sender.sendMessage(ChatColor.RED + "There's no item called " + args[1]); - return false; - } - - id = material.getId(); - } else { - id = -1; - } - - int data = args.length >= 3 ? getInteger(sender, args[2], 0) : -1; - int count = player.getInventory().clear(id, data); - - Command.broadcastCommandMessage(sender, "Cleared the inventory of " + player.getDisplayName() + ", removing " + count + " items"); - } else if (args.length == 0) { - sender.sendMessage(ChatColor.RED + "Please provide a player!"); - } else { - sender.sendMessage(ChatColor.RED + "Can't find player " + args[0]); - } - - return true; - } - - @Override - public List tabComplete(CommandSender sender, String alias, String[] args) throws IllegalArgumentException { - Validate.notNull(sender, "Sender cannot be null"); - Validate.notNull(args, "Arguments cannot be null"); - Validate.notNull(alias, "Alias cannot be null"); - - if (args.length == 1) { - return super.tabComplete(sender, alias, args); - } - if (args.length == 2) { - final String arg = args[1]; - final List materials = ClearCommand.materials; - List completion = null; - - final int size = materials.size(); - int i = Collections.binarySearch(materials, arg, String.CASE_INSENSITIVE_ORDER); - - if (i < 0) { - // Insertion (start) index - i = -1 - i; - } - - for ( ; i < size; i++) { - String material = materials.get(i); - if (StringUtil.startsWithIgnoreCase(material, arg)) { - if (completion == null) { - completion = new ArrayList(); - } - completion.add(material); - } else { - break; - } - } - - if (completion != null) { - return completion; - } - } - return ImmutableList.of(); - } -} diff --git a/NachoSpigot-API/src/main/java/org/bukkit/command/defaults/DefaultGameModeCommand.java b/NachoSpigot-API/src/main/java/org/bukkit/command/defaults/DefaultGameModeCommand.java deleted file mode 100644 index f217aea53..000000000 --- a/NachoSpigot-API/src/main/java/org/bukkit/command/defaults/DefaultGameModeCommand.java +++ /dev/null @@ -1,71 +0,0 @@ -package org.bukkit.command.defaults; - -import java.util.ArrayList; -import java.util.List; - -import org.apache.commons.lang.Validate; -import org.bukkit.Bukkit; -import org.bukkit.GameMode; -import org.bukkit.command.Command; -import org.bukkit.command.CommandSender; -import org.bukkit.util.StringUtil; - -import com.google.common.collect.ImmutableList; - -@Deprecated -public class DefaultGameModeCommand extends VanillaCommand { - private static final List GAMEMODE_NAMES = ImmutableList.of("adventure", "creative", "survival"); - - public DefaultGameModeCommand() { - super("defaultgamemode"); - this.description = "Set the default gamemode"; - this.usageMessage = "/defaultgamemode "; - this.setPermission("bukkit.command.defaultgamemode"); - } - - @Override - public boolean execute(CommandSender sender, String commandLabel, String[] args) { - if (!testPermission(sender)) return true; - if (args.length == 0) { - sender.sendMessage("Usage: " + usageMessage); - return false; - } - - String modeArg = args[0]; - int value = -1; - - try { - value = Integer.parseInt(modeArg); - } catch (NumberFormatException ex) {} - - GameMode mode = GameMode.getByValue(value); - - if (mode == null) { - if (modeArg.equalsIgnoreCase("creative") || modeArg.equalsIgnoreCase("c")) { - mode = GameMode.CREATIVE; - } else if (modeArg.equalsIgnoreCase("adventure") || modeArg.equalsIgnoreCase("a")) { - mode = GameMode.ADVENTURE; - } else { - mode = GameMode.SURVIVAL; - } - } - - Bukkit.getServer().setDefaultGameMode(mode); - Command.broadcastCommandMessage(sender, "Default game mode set to " + mode.toString().toLowerCase()); - - return true; - } - - @Override - public List tabComplete(CommandSender sender, String alias, String[] args) { - Validate.notNull(sender, "Sender cannot be null"); - Validate.notNull(args, "Arguments cannot be null"); - Validate.notNull(alias, "Alias cannot be null"); - - if (args.length == 1) { - return StringUtil.copyPartialMatches(args[0], GAMEMODE_NAMES, new ArrayList(GAMEMODE_NAMES.size())); - } - - return ImmutableList.of(); - } -} diff --git a/NachoSpigot-API/src/main/java/org/bukkit/command/defaults/DeopCommand.java b/NachoSpigot-API/src/main/java/org/bukkit/command/defaults/DeopCommand.java deleted file mode 100644 index 86be15ea5..000000000 --- a/NachoSpigot-API/src/main/java/org/bukkit/command/defaults/DeopCommand.java +++ /dev/null @@ -1,63 +0,0 @@ -package org.bukkit.command.defaults; - -import java.util.ArrayList; -import java.util.List; - -import org.apache.commons.lang.Validate; -import org.bukkit.Bukkit; -import org.bukkit.ChatColor; -import org.bukkit.OfflinePlayer; -import org.bukkit.command.Command; -import org.bukkit.command.CommandSender; -import org.bukkit.entity.Player; -import org.bukkit.util.StringUtil; - -import com.google.common.collect.ImmutableList; - -@Deprecated -public class DeopCommand extends VanillaCommand { - public DeopCommand() { - super("deop"); - this.description = "Takes the specified player's operator status"; - this.usageMessage = "/deop "; - this.setPermission("bukkit.command.op.take"); - } - - @Override - public boolean execute(CommandSender sender, String currentAlias, String[] args) { - if (!testPermission(sender)) return true; - if (args.length != 1 || args[0].length() == 0) { - sender.sendMessage(ChatColor.RED + "Usage: " + usageMessage); - return false; - } - - OfflinePlayer player = Bukkit.getOfflinePlayer(args[0]); - player.setOp(false); - - if (player instanceof Player) { - ((Player) player).sendMessage(ChatColor.YELLOW + "You are no longer op!"); - } - - Command.broadcastCommandMessage(sender, "De-opped " + args[0]); - return true; - } - - @Override - public List tabComplete(CommandSender sender, String alias, String[] args) throws IllegalArgumentException { - Validate.notNull(sender, "Sender cannot be null"); - Validate.notNull(args, "Arguments cannot be null"); - Validate.notNull(alias, "Alias cannot be null"); - - if (args.length == 1) { - List completions = new ArrayList(); - for (OfflinePlayer player : Bukkit.getOperators()) { - String playerName = player.getName(); - if (StringUtil.startsWithIgnoreCase(playerName, args[0])) { - completions.add(playerName); - } - } - return completions; - } - return ImmutableList.of(); - } -} diff --git a/NachoSpigot-API/src/main/java/org/bukkit/command/defaults/DifficultyCommand.java b/NachoSpigot-API/src/main/java/org/bukkit/command/defaults/DifficultyCommand.java deleted file mode 100644 index 74a8ac2ae..000000000 --- a/NachoSpigot-API/src/main/java/org/bukkit/command/defaults/DifficultyCommand.java +++ /dev/null @@ -1,82 +0,0 @@ -package org.bukkit.command.defaults; - -import com.google.common.collect.ImmutableList; -import org.apache.commons.lang.Validate; -import org.bukkit.Bukkit; -import org.bukkit.ChatColor; -import org.bukkit.command.Command; -import org.bukkit.command.CommandSender; -import org.bukkit.util.StringUtil; -import org.bukkit.Difficulty; - -import java.util.ArrayList; -import java.util.List; - -@Deprecated -public class DifficultyCommand extends VanillaCommand { - private static final List DIFFICULTY_NAMES = ImmutableList.of("peaceful", "easy", "normal", "hard"); - - public DifficultyCommand() { - super("difficulty"); - this.description = "Sets the game difficulty"; - this.usageMessage = "/difficulty "; - this.setPermission("bukkit.command.difficulty"); - } - - @Override - public boolean execute(CommandSender sender, String currentAlias, String[] args) { - if (!testPermission(sender)) return true; - if (args.length != 1 || args[0].length() == 0) { - sender.sendMessage(ChatColor.RED + "Usage: " + usageMessage); - return false; - } - - Difficulty difficulty = Difficulty.getByValue(getDifficultyForString(sender, args[0])); - - if (Bukkit.isHardcore()) { - difficulty = Difficulty.HARD; - } - - Bukkit.getWorlds().get(0).setDifficulty(difficulty); - - int levelCount = 1; - if (Bukkit.getAllowNether()) { - Bukkit.getWorlds().get(levelCount).setDifficulty(difficulty); - levelCount++; - } - - if (Bukkit.getAllowEnd()) { - Bukkit.getWorlds().get(levelCount).setDifficulty(difficulty); - } - - Command.broadcastCommandMessage(sender, "Set difficulty to " + difficulty.toString()); - return true; - } - - protected int getDifficultyForString(CommandSender sender, String name) { - if (name.equalsIgnoreCase("peaceful") || name.equalsIgnoreCase("p")) { - return 0; - } else if (name.equalsIgnoreCase("easy") || name.equalsIgnoreCase("e")) { - return 1; - } else if (name.equalsIgnoreCase("normal") || name.equalsIgnoreCase("n")) { - return 2; - } else if (name.equalsIgnoreCase("hard") || name.equalsIgnoreCase("h")) { - return 3; - } else { - return getInteger(sender, name, 0, 3); - } - } - - @Override - public List tabComplete(CommandSender sender, String alias, String[] args) { - Validate.notNull(sender, "Sender cannot be null"); - Validate.notNull(args, "Arguments cannot be null"); - Validate.notNull(alias, "Alias cannot be null"); - - if (args.length == 1) { - return StringUtil.copyPartialMatches(args[0], DIFFICULTY_NAMES, new ArrayList(DIFFICULTY_NAMES.size())); - } - - return ImmutableList.of(); - } -} diff --git a/NachoSpigot-API/src/main/java/org/bukkit/command/defaults/EffectCommand.java b/NachoSpigot-API/src/main/java/org/bukkit/command/defaults/EffectCommand.java deleted file mode 100644 index de63bbe1d..000000000 --- a/NachoSpigot-API/src/main/java/org/bukkit/command/defaults/EffectCommand.java +++ /dev/null @@ -1,120 +0,0 @@ -package org.bukkit.command.defaults; - -import com.google.common.collect.ImmutableList; -import java.util.ArrayList; -import java.util.List; -import org.bukkit.ChatColor; -import org.bukkit.command.CommandSender; -import org.bukkit.entity.Player; -import org.bukkit.potion.PotionEffect; -import org.bukkit.potion.PotionEffectType; -import org.bukkit.util.StringUtil; - -@Deprecated -public class EffectCommand extends VanillaCommand { - private static final List effects; - - public EffectCommand() { - super("effect"); - this.description = "Adds/Removes effects on players"; - this.usageMessage = "/effect [seconds] [amplifier]"; - this.setPermission("bukkit.command.effect"); - } - - static { - ImmutableList.Builder builder = ImmutableList.builder(); - - for (PotionEffectType type : PotionEffectType.values()) { - if (type != null) { - builder.add(type.getName()); - } - } - - effects = builder.build(); - } - - @Override - public boolean execute(CommandSender sender, String commandLabel, String[] args) { - if (!testPermission(sender)) { - return true; - } - - if (args.length < 2) { - sender.sendMessage(getUsage()); - return true; - } - - final Player player = sender.getServer().getPlayer(args[0]); - - if (player == null) { - sender.sendMessage(ChatColor.RED + String.format("Player, %s, not found", args[0])); - return true; - } - - if ("clear".equalsIgnoreCase(args[1])) { - for (PotionEffect effect : player.getActivePotionEffects()) { - player.removePotionEffect(effect.getType()); - } - sender.sendMessage(String.format("Took all effects from %s", args[0])); - return true; - } - - PotionEffectType effect = PotionEffectType.getByName(args[1]); - - if (effect == null) { - effect = PotionEffectType.getById(getInteger(sender, args[1], 0)); - } - - if (effect == null) { - sender.sendMessage(ChatColor.RED + String.format("Effect, %s, not found", args[1])); - return true; - } - - int duration = 600; - int duration_temp = 30; - int amplification = 0; - - if (args.length >= 3) { - duration_temp = getInteger(sender, args[2], 0, 1000000); - if (effect.isInstant()) { - duration = duration_temp; - } else { - duration = duration_temp * 20; - } - } else if (effect.isInstant()) { - duration = 1; - } - - if (args.length >= 4) { - amplification = getInteger(sender, args[3], 0, 255); - } - - if (duration_temp == 0) { - if (!player.hasPotionEffect(effect)) { - sender.sendMessage(String.format("Couldn't take %s from %s as they do not have the effect", effect.getName(), args[0])); - return true; - } - - player.removePotionEffect(effect); - broadcastCommandMessage(sender, String.format("Took %s from %s", effect.getName(), args[0])); - } else { - final PotionEffect applyEffect = new PotionEffect(effect, duration, amplification); - - player.addPotionEffect(applyEffect, true); - broadcastCommandMessage(sender, String.format("Given %s (ID %d) * %d to %s for %d seconds", effect.getName(), effect.getId(), amplification, args[0], duration_temp)); - } - - return true; - } - - @Override - public List tabComplete(CommandSender sender, String commandLabel, String[] args) { - if (args.length == 1) { - return super.tabComplete(sender, commandLabel, args); - } else if (args.length == 2) { - return StringUtil.copyPartialMatches(args[1], effects, new ArrayList(effects.size())); - } - - return ImmutableList.of(); - } -} diff --git a/NachoSpigot-API/src/main/java/org/bukkit/command/defaults/EnchantCommand.java b/NachoSpigot-API/src/main/java/org/bukkit/command/defaults/EnchantCommand.java deleted file mode 100644 index 5f0b6864b..000000000 --- a/NachoSpigot-API/src/main/java/org/bukkit/command/defaults/EnchantCommand.java +++ /dev/null @@ -1,170 +0,0 @@ -package org.bukkit.command.defaults; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; -import java.util.Map; - -import org.apache.commons.lang.Validate; -import org.apache.commons.lang.WordUtils; -import com.google.common.collect.ImmutableList; - -import org.bukkit.Bukkit; -import org.bukkit.ChatColor; -import org.bukkit.Material; -import org.bukkit.command.Command; -import org.bukkit.command.CommandSender; -import org.bukkit.enchantments.Enchantment; -import org.bukkit.entity.Player; -import org.bukkit.inventory.ItemStack; -import org.bukkit.util.StringUtil; - -@Deprecated -public class EnchantCommand extends VanillaCommand { - private static final List ENCHANTMENT_NAMES = new ArrayList(); - - public EnchantCommand() { - super("enchant"); - this.description = "Adds enchantments to the item the player is currently holding. Specify 0 for the level to remove an enchantment. Specify force to ignore normal enchantment restrictions"; - this.usageMessage = "/enchant [level|max|0] [force]"; - this.setPermission("bukkit.command.enchant"); - } - - @Override - public boolean execute(CommandSender sender, String commandLabel, String[] args) { - if (!testPermission(sender)) return true; - if (args.length < 2) { - sender.sendMessage(ChatColor.RED + "Usage: " + usageMessage); - return false; - } - - boolean force = false; - if (args.length > 2) { - force = args[args.length > 3 ? 3 : 2].equalsIgnoreCase("force"); - } - - Player player = Bukkit.getPlayerExact(args[0]); - if (player == null) { - sender.sendMessage("Can't find player " + args[0]); - } else { - ItemStack item = player.getItemInHand(); - if (item.getType() == Material.AIR) { - sender.sendMessage("The player isn't holding an item"); - } else { - String itemName = item.getType().toString().replaceAll("_", " "); - itemName = WordUtils.capitalizeFully(itemName); - - Enchantment enchantment = getEnchantment(args[1].toUpperCase()); - if (enchantment == null) { - sender.sendMessage(String.format("Enchantment does not exist: %s", args[1])); - } else { - String enchantmentName = enchantment.getName().replaceAll("_", " "); - enchantmentName = WordUtils.capitalizeFully(enchantmentName); - - if (!force && !enchantment.canEnchantItem(item)) { - sender.sendMessage(String.format("%s cannot be applied to %s", enchantmentName, itemName)); - } else { - int level = 1; - if (args.length > 2) { - Integer integer = getInteger(args[2]); - int minLevel = enchantment.getStartLevel(); - int maxLevel = force ? Short.MAX_VALUE : enchantment.getMaxLevel(); - - if (integer != null) { - if (integer == 0) { - item.removeEnchantment(enchantment); - Command.broadcastCommandMessage(sender, String.format("Removed %s on %s's %s", enchantmentName, player.getName(), itemName)); - return true; - } - - if (integer < minLevel || integer > maxLevel) { - sender.sendMessage(String.format("Level for enchantment %s must be between %d and %d", enchantmentName, minLevel, maxLevel)); - sender.sendMessage("Specify 0 for level to remove an enchantment"); - return true; - } - - level = integer; - } - - if ("max".equals(args[2])) { - level = maxLevel; - } - } - - Map enchantments = item.getEnchantments(); - boolean conflicts = false; - - if (!force && !enchantments.isEmpty()) { // TODO: Improve this to use a "hasEnchantments" call - for (Map.Entry entry : enchantments.entrySet()) { - Enchantment enchant = entry.getKey(); - - if (enchant.equals(enchantment)) continue; - if (enchant.conflictsWith(enchantment)) { - sender.sendMessage(String.format("Can't apply the enchantment %s on an item with the enchantment %s", enchantmentName, WordUtils.capitalizeFully(enchant.getName().replaceAll("_", " ")))); - conflicts = true; - break; - } - } - } - - if (!conflicts) { - item.addUnsafeEnchantment(enchantment, level); - - Command.broadcastCommandMessage(sender, String.format("Applied %s (Lvl %d) on %s's %s", enchantmentName, level, player.getName(), itemName), false); - sender.sendMessage(String.format("Enchanting succeeded, applied %s (Lvl %d) onto your %s", enchantmentName, level, itemName)); - } - } - } - } - } - return true; - } - - @Override - public List tabComplete(CommandSender sender, String alias, String[] args) throws IllegalArgumentException { - Validate.notNull(sender, "Sender cannot be null"); - Validate.notNull(args, "Arguments cannot be null"); - Validate.notNull(alias, "Alias cannot be null"); - - if (args.length == 1) { - return super.tabComplete(sender, alias, args); - } - - if (args.length == 2) { - return StringUtil.copyPartialMatches(args[1], ENCHANTMENT_NAMES, new ArrayList(ENCHANTMENT_NAMES.size())); - } - - if (args.length == 3 || args.length == 4) { - if (!args[args.length - 2].equalsIgnoreCase("force")) { - return ImmutableList.of("force"); - } - } - - return ImmutableList.of(); - } - - private Enchantment getEnchantment(String lookup) { - Enchantment enchantment = Enchantment.getByName(lookup); - - if (enchantment == null) { - Integer id = getInteger(lookup); - if (id != null) { - enchantment = Enchantment.getById(id); - } - } - - return enchantment; - } - - public static void buildEnchantments() { - if (!ENCHANTMENT_NAMES.isEmpty()) { - throw new IllegalStateException("Enchantments have already been built!"); - } - - for (Enchantment enchantment : Enchantment.values()) { - ENCHANTMENT_NAMES.add(enchantment.getName()); - } - - Collections.sort(ENCHANTMENT_NAMES); - } -} diff --git a/NachoSpigot-API/src/main/java/org/bukkit/command/defaults/ExpCommand.java b/NachoSpigot-API/src/main/java/org/bukkit/command/defaults/ExpCommand.java deleted file mode 100644 index aa33c0c51..000000000 --- a/NachoSpigot-API/src/main/java/org/bukkit/command/defaults/ExpCommand.java +++ /dev/null @@ -1,90 +0,0 @@ -package org.bukkit.command.defaults; - -import java.util.List; - -import org.apache.commons.lang.Validate; -import org.bukkit.Bukkit; -import org.bukkit.ChatColor; -import org.bukkit.command.Command; -import org.bukkit.command.CommandSender; -import org.bukkit.entity.Player; - -import com.google.common.collect.ImmutableList; - -@Deprecated -public class ExpCommand extends VanillaCommand { - public ExpCommand() { - super("xp"); - this.description = "Gives the specified player a certain amount of experience. Specify L to give levels instead, with a negative amount resulting in taking levels."; - this.usageMessage = "/xp [player] OR /xp L [player]"; - this.setPermission("bukkit.command.xp"); - } - - @Override - public boolean execute(CommandSender sender, String currentAlias, String[] args) { - if (!testPermission(sender)) return true; - - if (args.length > 0) { - String inputAmount = args[0]; - Player player = null; - - boolean isLevel = inputAmount.endsWith("l") || inputAmount.endsWith("L"); - if (isLevel && inputAmount.length() > 1) { - inputAmount = inputAmount.substring(0, inputAmount.length() - 1); - } - - int amount = getInteger(sender, inputAmount, Integer.MIN_VALUE, Integer.MAX_VALUE); - boolean isTaking = amount < 0; - - if (isTaking) { - amount *= -1; - } - - if (args.length > 1) { - player = Bukkit.getPlayer(args[1]); - } else if (sender instanceof Player) { - player = (Player) sender; - } - - if (player != null) { - if (isLevel) { - if (isTaking) { - player.giveExpLevels(-amount); - Command.broadcastCommandMessage(sender, "Taken " + amount + " level(s) from " + player.getName()); - } else { - player.giveExpLevels(amount); - Command.broadcastCommandMessage(sender, "Given " + amount + " level(s) to " + player.getName()); - } - } else { - if (isTaking) { - sender.sendMessage(ChatColor.RED + "Taking experience can only be done by levels, cannot give players negative experience points"); - return false; - } else { - player.giveExp(amount); - Command.broadcastCommandMessage(sender, "Given " + amount + " experience to " + player.getName()); - } - } - } else { - sender.sendMessage("Can't find player, was one provided?\n" + ChatColor.RED + "Usage: " + usageMessage); - return false; - } - - return true; - } - - sender.sendMessage(ChatColor.RED + "Usage: " + usageMessage); - return false; - } - - @Override - public List tabComplete(CommandSender sender, String alias, String[] args) throws IllegalArgumentException { - Validate.notNull(sender, "Sender cannot be null"); - Validate.notNull(args, "Arguments cannot be null"); - Validate.notNull(alias, "Alias cannot be null"); - - if (args.length == 2) { - return super.tabComplete(sender, alias, args); - } - return ImmutableList.of(); - } -} diff --git a/NachoSpigot-API/src/main/java/org/bukkit/command/defaults/GameModeCommand.java b/NachoSpigot-API/src/main/java/org/bukkit/command/defaults/GameModeCommand.java deleted file mode 100644 index f9675a053..000000000 --- a/NachoSpigot-API/src/main/java/org/bukkit/command/defaults/GameModeCommand.java +++ /dev/null @@ -1,101 +0,0 @@ -package org.bukkit.command.defaults; - -import java.util.ArrayList; -import java.util.List; - -import org.apache.commons.lang.Validate; -import org.bukkit.Bukkit; -import org.bukkit.ChatColor; -import org.bukkit.GameMode; -import org.bukkit.command.Command; -import org.bukkit.command.CommandSender; -import org.bukkit.entity.Player; -import org.bukkit.util.StringUtil; - -import com.google.common.collect.ImmutableList; - -@Deprecated -public class GameModeCommand extends VanillaCommand { - private static final List GAMEMODE_NAMES = ImmutableList.of("adventure", "creative", "survival", "spectator"); - - public GameModeCommand() { - super("gamemode"); - this.description = "Changes the player to a specific game mode"; - this.usageMessage = "/gamemode [player]"; - this.setPermission("bukkit.command.gamemode"); - } - - @Override - public boolean execute(CommandSender sender, String currentAlias, String[] args) { - if (!testPermission(sender)) return true; - if (args.length == 0) { - sender.sendMessage(ChatColor.RED + "Usage: " + usageMessage); - return false; - } - - String modeArg = args[0]; - String playerArg = sender.getName(); - - if (args.length == 2) { - playerArg = args[1]; - } - - Player player = Bukkit.getPlayerExact(playerArg); - - if (player != null) { - int value = -1; - - try { - value = Integer.parseInt(modeArg); - } catch (NumberFormatException ex) {} - - GameMode mode = GameMode.getByValue(value); - - if (mode == null) { - if (modeArg.equalsIgnoreCase("creative") || modeArg.equalsIgnoreCase("c")) { - mode = GameMode.CREATIVE; - } else if (modeArg.equalsIgnoreCase("adventure") || modeArg.equalsIgnoreCase("a")) { - mode = GameMode.ADVENTURE; - } else if (modeArg.equalsIgnoreCase("spectator") || modeArg.equalsIgnoreCase("sp")) { - mode = GameMode.SPECTATOR; - } else { - mode = GameMode.SURVIVAL; - } - } - - if (mode != player.getGameMode()) { - player.setGameMode(mode); - - if (mode != player.getGameMode()) { - sender.sendMessage("Game mode change for " + player.getName() + " failed!"); - } else { - if (player == sender) { - Command.broadcastCommandMessage(sender, "Set own game mode to " + mode.toString() + " mode"); - } else { - Command.broadcastCommandMessage(sender, "Set " + player.getName() + "'s game mode to " + mode.toString() + " mode"); - } - } - } else { - sender.sendMessage(player.getName() + " already has game mode " + mode.getValue()); - } - } else { - sender.sendMessage("Can't find player " + playerArg); - } - - return true; - } - - @Override - public List tabComplete(CommandSender sender, String alias, String[] args) { - Validate.notNull(sender, "Sender cannot be null"); - Validate.notNull(args, "Arguments cannot be null"); - Validate.notNull(alias, "Alias cannot be null"); - - if (args.length == 1) { - return StringUtil.copyPartialMatches(args[0], GAMEMODE_NAMES, new ArrayList(GAMEMODE_NAMES.size())); - } else if (args.length == 2) { - return super.tabComplete(sender, alias, args); - } - return ImmutableList.of(); - } -} diff --git a/NachoSpigot-API/src/main/java/org/bukkit/command/defaults/GameRuleCommand.java b/NachoSpigot-API/src/main/java/org/bukkit/command/defaults/GameRuleCommand.java deleted file mode 100644 index 13e258926..000000000 --- a/NachoSpigot-API/src/main/java/org/bukkit/command/defaults/GameRuleCommand.java +++ /dev/null @@ -1,89 +0,0 @@ -package org.bukkit.command.defaults; - -import com.google.common.collect.ImmutableList; -import org.apache.commons.lang.Validate; -import org.bukkit.ChatColor; -import org.bukkit.command.BlockCommandSender; -import org.bukkit.command.Command; -import org.bukkit.command.CommandSender; -import org.bukkit.util.StringUtil; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; -import org.bukkit.Bukkit; -import org.bukkit.World; -import org.bukkit.entity.HumanEntity; - -@Deprecated -public class GameRuleCommand extends VanillaCommand { - private static final List GAMERULE_STATES = ImmutableList.of("true", "false"); - - public GameRuleCommand() { - super("gamerule"); - this.description = "Sets a server's game rules"; - this.usageMessage = "/gamerule OR /gamerule "; - this.setPermission("bukkit.command.gamerule"); - } - - @Override - public boolean execute(CommandSender sender, String currentAlias, String[] args) { - if (!testPermission(sender)) return true; - - if (args.length > 0) { - String rule = args[0]; - World world = getGameWorld(sender); - - if (world.isGameRule(rule)) { - if (args.length > 1) { - String value = args[1]; - - world.setGameRuleValue(rule, value); - Command.broadcastCommandMessage(sender, "Game rule " + rule + " has been set to: " + value); - } else { - String value = world.getGameRuleValue(rule); - sender.sendMessage(rule + " = " + value); - } - } else { - sender.sendMessage(ChatColor.RED + "No game rule called " + rule + " is available"); - } - - return true; - } else { - sender.sendMessage(ChatColor.RED + "Usage: " + usageMessage); - sender.sendMessage("Rules: " + this.createString(getGameWorld(sender).getGameRules(), 0, ", ")); - - return true; - } - } - - private World getGameWorld(CommandSender sender) { - if (sender instanceof HumanEntity) { - World world = ((HumanEntity) sender).getWorld(); - if (world != null) { - return world; - } - } else if (sender instanceof BlockCommandSender) { - return ((BlockCommandSender) sender).getBlock().getWorld(); - } - - return Bukkit.getWorlds().get(0); - } - - @Override - public List tabComplete(CommandSender sender, String alias, String[] args) throws IllegalArgumentException { - Validate.notNull(sender, "Sender cannot be null"); - Validate.notNull(args, "Arguments cannot be null"); - Validate.notNull(alias, "Alias cannot be null"); - - if (args.length == 1) { - return StringUtil.copyPartialMatches(args[0], Arrays.asList(getGameWorld(sender).getGameRules()), new ArrayList()); - } - - if (args.length == 2) { - return StringUtil.copyPartialMatches(args[1], GAMERULE_STATES, new ArrayList(GAMERULE_STATES.size())); - } - - return ImmutableList.of(); - } -} diff --git a/NachoSpigot-API/src/main/java/org/bukkit/command/defaults/GiveCommand.java b/NachoSpigot-API/src/main/java/org/bukkit/command/defaults/GiveCommand.java deleted file mode 100644 index c8b7f0f95..000000000 --- a/NachoSpigot-API/src/main/java/org/bukkit/command/defaults/GiveCommand.java +++ /dev/null @@ -1,130 +0,0 @@ -package org.bukkit.command.defaults; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collections; -import java.util.List; - -import org.apache.commons.lang.Validate; -import org.bukkit.Bukkit; -import org.bukkit.ChatColor; -import org.bukkit.Material; -import org.bukkit.command.Command; -import org.bukkit.command.CommandSender; -import org.bukkit.entity.Player; -import org.bukkit.inventory.ItemStack; -import org.bukkit.util.StringUtil; - -import com.google.common.base.Joiner; -import com.google.common.collect.ImmutableList; - -@Deprecated -public class GiveCommand extends VanillaCommand { - private static List materials; - static { - ArrayList materialList = new ArrayList(); - for (Material material : Material.values()) { - materialList.add(material.name()); - } - Collections.sort(materialList); - materials = ImmutableList.copyOf(materialList); - } - - public GiveCommand() { - super("give"); - this.description = "Gives the specified player a certain amount of items"; - this.usageMessage = "/give [amount [data]]"; - this.setPermission("bukkit.command.give"); - } - - @Override - public boolean execute(CommandSender sender, String currentAlias, String[] args) { - if (!testPermission(sender)) return true; - if ((args.length < 2)) { - sender.sendMessage(ChatColor.RED + "Usage: " + usageMessage); - return false; - } - - Player player = Bukkit.getPlayerExact(args[0]); - - if (player != null) { - Material material = Material.matchMaterial(args[1]); - - if (material == null) { - material = Bukkit.getUnsafe().getMaterialFromInternalName(args[1]); - } - - if (material != null) { - int amount = 1; - short data = 0; - - if (args.length >= 3) { - amount = this.getInteger(sender, args[2], 1, 64); - - if (args.length >= 4) { - try { - data = Short.parseShort(args[3]); - } catch (NumberFormatException ex) {} - } - } - - ItemStack stack = new ItemStack(material, amount, data); - - if (args.length >= 5) { - try { - stack = Bukkit.getUnsafe().modifyItemStack(stack, Joiner.on(' ').join(Arrays.asList(args).subList(4, args.length))); - } catch (Throwable t) { - player.sendMessage("Not a valid tag"); - return true; - } - } - - player.getInventory().addItem(stack); - - Command.broadcastCommandMessage(sender, "Gave " + player.getName() + " some " + material.getId() + " (" + material + ")"); - } else { - sender.sendMessage("There's no item called " + args[1]); - } - } else { - sender.sendMessage("Can't find player " + args[0]); - } - - return true; - } - - @Override - public List tabComplete(CommandSender sender, String alias, String[] args) throws IllegalArgumentException { - Validate.notNull(sender, "Sender cannot be null"); - Validate.notNull(args, "Arguments cannot be null"); - Validate.notNull(alias, "Alias cannot be null"); - - if (args.length == 1) { - return super.tabComplete(sender, alias, args); - } - if (args.length == 2) { - final String arg = args[1]; - final List materials = GiveCommand.materials; - List completion = new ArrayList(); - - final int size = materials.size(); - int i = Collections.binarySearch(materials, arg, String.CASE_INSENSITIVE_ORDER); - - if (i < 0) { - // Insertion (start) index - i = -1 - i; - } - - for ( ; i < size; i++) { - String material = materials.get(i); - if (StringUtil.startsWithIgnoreCase(material, arg)) { - completion.add(material); - } else { - break; - } - } - - return Bukkit.getUnsafe().tabCompleteInternalMaterialName(arg, completion); - } - return ImmutableList.of(); - } -} diff --git a/NachoSpigot-API/src/main/java/org/bukkit/command/defaults/KickCommand.java b/NachoSpigot-API/src/main/java/org/bukkit/command/defaults/KickCommand.java deleted file mode 100644 index 634c115a6..000000000 --- a/NachoSpigot-API/src/main/java/org/bukkit/command/defaults/KickCommand.java +++ /dev/null @@ -1,60 +0,0 @@ -package org.bukkit.command.defaults; - -import java.util.List; - -import org.apache.commons.lang.Validate; -import org.bukkit.Bukkit; -import org.bukkit.ChatColor; -import org.bukkit.command.Command; -import org.bukkit.command.CommandSender; -import org.bukkit.entity.Player; - -import com.google.common.collect.ImmutableList; - -@Deprecated -public class KickCommand extends VanillaCommand { - public KickCommand() { - super("kick"); - this.description = "Removes the specified player from the server"; - this.usageMessage = "/kick [reason ...]"; - this.setPermission("bukkit.command.kick"); - } - - @Override - public boolean execute(CommandSender sender, String currentAlias, String[] args) { - if (!testPermission(sender)) return true; - if (args.length < 1 || args[0].length() == 0) { - sender.sendMessage(ChatColor.RED + "Usage: " + usageMessage); - return false; - } - - Player player = Bukkit.getPlayerExact(args[0]); - - if (player != null) { - String reason = "Kicked by an operator."; - - if (args.length > 1) { - reason = createString(args, 1); - } - - player.kickPlayer(reason); - Command.broadcastCommandMessage(sender, "Kicked player " + player.getName() + ". With reason:\n" + reason); - } else { - sender.sendMessage( args[0] + " not found."); - } - - return true; - } - - @Override - public List tabComplete(CommandSender sender, String alias, String[] args) throws IllegalArgumentException { - Validate.notNull(sender, "Sender cannot be null"); - Validate.notNull(args, "Arguments cannot be null"); - Validate.notNull(alias, "Alias cannot be null"); - - if (args.length >= 1) { - return super.tabComplete(sender, alias, args); - } - return ImmutableList.of(); - } -} diff --git a/NachoSpigot-API/src/main/java/org/bukkit/command/defaults/KillCommand.java b/NachoSpigot-API/src/main/java/org/bukkit/command/defaults/KillCommand.java deleted file mode 100644 index 2143eb181..000000000 --- a/NachoSpigot-API/src/main/java/org/bukkit/command/defaults/KillCommand.java +++ /dev/null @@ -1,51 +0,0 @@ -package org.bukkit.command.defaults; - -import java.util.List; - -import org.apache.commons.lang.Validate; -import org.bukkit.Bukkit; -import org.bukkit.command.CommandSender; -import org.bukkit.entity.Player; -import org.bukkit.event.entity.EntityDamageEvent; - -import com.google.common.collect.ImmutableList; - -@Deprecated -public class KillCommand extends VanillaCommand { - public KillCommand() { - super("kill"); - this.description = "Commits suicide, only usable as a player"; - this.usageMessage = "/kill"; - this.setPermission("bukkit.command.kill"); - } - - @Override - public boolean execute(CommandSender sender, String currentAlias, String[] args) { - if (!testPermission(sender)) return true; - - if (sender instanceof Player) { - Player player = (Player) sender; - - EntityDamageEvent ede = new EntityDamageEvent(player, EntityDamageEvent.DamageCause.SUICIDE, 1000); - Bukkit.getPluginManager().callEvent(ede); - if (ede.isCancelled()) return true; - - ede.getEntity().setLastDamageCause(ede); - player.setHealth(0); - sender.sendMessage("Ouch. That look like it hurt."); - } else { - sender.sendMessage("You can only perform this command as a player"); - } - - return true; - } - - @Override - public List tabComplete(CommandSender sender, String alias, String[] args) throws IllegalArgumentException { - Validate.notNull(sender, "Sender cannot be null"); - Validate.notNull(args, "Arguments cannot be null"); - Validate.notNull(alias, "Alias cannot be null"); - - return ImmutableList.of(); - } -} diff --git a/NachoSpigot-API/src/main/java/org/bukkit/command/defaults/ListCommand.java b/NachoSpigot-API/src/main/java/org/bukkit/command/defaults/ListCommand.java deleted file mode 100644 index ea62bee3e..000000000 --- a/NachoSpigot-API/src/main/java/org/bukkit/command/defaults/ListCommand.java +++ /dev/null @@ -1,55 +0,0 @@ -package org.bukkit.command.defaults; - -import java.util.Collection; -import java.util.List; - -import org.apache.commons.lang.Validate; -import org.bukkit.Bukkit; -import org.bukkit.command.CommandSender; -import org.bukkit.entity.Player; - -import com.google.common.collect.ImmutableList; - -@Deprecated -public class ListCommand extends VanillaCommand { - public ListCommand() { - super("list"); - this.description = "Lists all online players"; - this.usageMessage = "/list"; - this.setPermission("bukkit.command.list"); - } - - @Override - public boolean execute(CommandSender sender, String currentAlias, String[] args) { - if (!testPermission(sender)) return true; - - StringBuilder online = new StringBuilder(); - - final Collection players = Bukkit.getOnlinePlayers(); - - for (Player player : players) { - // If a player is hidden from the sender don't show them in the list - if (sender instanceof Player && !((Player) sender).canSee(player)) - continue; - - if (online.length() > 0) { - online.append(", "); - } - - online.append(player.getDisplayName()); - } - - sender.sendMessage("There are " + players.size() + "/" + Bukkit.getMaxPlayers() + " players online:\n" + online.toString()); - - return true; - } - - @Override - public List tabComplete(CommandSender sender, String alias, String[] args) throws IllegalArgumentException { - Validate.notNull(sender, "Sender cannot be null"); - Validate.notNull(args, "Arguments cannot be null"); - Validate.notNull(alias, "Alias cannot be null"); - - return ImmutableList.of(); - } -} diff --git a/NachoSpigot-API/src/main/java/org/bukkit/command/defaults/MeCommand.java b/NachoSpigot-API/src/main/java/org/bukkit/command/defaults/MeCommand.java deleted file mode 100644 index 2a029cbe0..000000000 --- a/NachoSpigot-API/src/main/java/org/bukkit/command/defaults/MeCommand.java +++ /dev/null @@ -1,36 +0,0 @@ -package org.bukkit.command.defaults; - -import org.bukkit.Bukkit; -import org.bukkit.ChatColor; -import org.bukkit.command.CommandSender; - -@Deprecated -public class MeCommand extends VanillaCommand { - public MeCommand() { - super("me"); - this.description = "Performs the specified action in chat"; - this.usageMessage = "/me "; - this.setPermission("bukkit.command.me"); - } - - @Override - public boolean execute(CommandSender sender, String currentAlias, String[] args) { - if (!testPermission(sender)) return true; - if (args.length < 1) { - sender.sendMessage(ChatColor.RED + "Usage: " + usageMessage); - return false; - } - - StringBuilder message = new StringBuilder(); - message.append(sender.getName()); - - for (String arg : args) { - message.append(" "); - message.append(arg); - } - - Bukkit.broadcastMessage("* " + message); - - return true; - } -} diff --git a/NachoSpigot-API/src/main/java/org/bukkit/command/defaults/OpCommand.java b/NachoSpigot-API/src/main/java/org/bukkit/command/defaults/OpCommand.java deleted file mode 100644 index f5bb8b153..000000000 --- a/NachoSpigot-API/src/main/java/org/bukkit/command/defaults/OpCommand.java +++ /dev/null @@ -1,76 +0,0 @@ -package org.bukkit.command.defaults; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; - -import org.apache.commons.lang.Validate; -import org.bukkit.Bukkit; -import org.bukkit.ChatColor; -import org.bukkit.OfflinePlayer; -import org.bukkit.command.Command; -import org.bukkit.command.CommandSender; -import org.bukkit.entity.Player; -import org.bukkit.util.StringUtil; - -import com.google.common.collect.ImmutableList; - -@Deprecated -public class OpCommand extends VanillaCommand { - public OpCommand() { - super("op"); - this.description = "Gives the specified player operator status"; - this.usageMessage = "/op "; - this.setPermission("bukkit.command.op.give"); - } - - @Override - public boolean execute(CommandSender sender, String currentAlias, String[] args) { - if (!testPermission(sender)) return true; - if (args.length != 1 || args[0].length() == 0) { - sender.sendMessage(ChatColor.RED + "Usage: " + usageMessage); - return false; - } - - OfflinePlayer player = Bukkit.getOfflinePlayer(args[0]); - player.setOp(true); - - Command.broadcastCommandMessage(sender, "Opped " + args[0]); - return true; - } - - @Override - public List tabComplete(CommandSender sender, String alias, String[] args) throws IllegalArgumentException { - Validate.notNull(sender, "Sender cannot be null"); - Validate.notNull(args, "Arguments cannot be null"); - Validate.notNull(alias, "Alias cannot be null"); - - if (args.length == 1) { - if (!(sender instanceof Player)) { - return ImmutableList.of(); - } - - String lastWord = args[0]; - if (lastWord.length() == 0) { - return ImmutableList.of(); - } - - Player senderPlayer = (Player) sender; - - ArrayList matchedPlayers = new ArrayList(); - for (Player player : sender.getServer().getOnlinePlayers()) { - String name = player.getName(); - if (!senderPlayer.canSee(player) || player.isOp()) { - continue; - } - if (StringUtil.startsWithIgnoreCase(name, lastWord)) { - matchedPlayers.add(name); - } - } - - Collections.sort(matchedPlayers, String.CASE_INSENSITIVE_ORDER); - return matchedPlayers; - } - return ImmutableList.of(); - } -} diff --git a/NachoSpigot-API/src/main/java/org/bukkit/command/defaults/PardonCommand.java b/NachoSpigot-API/src/main/java/org/bukkit/command/defaults/PardonCommand.java deleted file mode 100644 index 762189a1e..000000000 --- a/NachoSpigot-API/src/main/java/org/bukkit/command/defaults/PardonCommand.java +++ /dev/null @@ -1,57 +0,0 @@ -package org.bukkit.command.defaults; - -import java.util.ArrayList; -import java.util.List; - -import org.apache.commons.lang.Validate; -import org.bukkit.BanList; -import org.bukkit.Bukkit; -import org.bukkit.ChatColor; -import org.bukkit.OfflinePlayer; -import org.bukkit.command.Command; -import org.bukkit.command.CommandSender; -import org.bukkit.util.StringUtil; - -import com.google.common.collect.ImmutableList; - -@Deprecated -public class PardonCommand extends VanillaCommand { - public PardonCommand() { - super("pardon"); - this.description = "Allows the specified player to use this server"; - this.usageMessage = "/pardon "; - this.setPermission("bukkit.command.unban.player"); - } - - @Override - public boolean execute(CommandSender sender, String currentAlias, String[] args) { - if (!testPermission(sender)) return true; - if (args.length != 1) { - sender.sendMessage(ChatColor.RED + "Usage: " + usageMessage); - return false; - } - - Bukkit.getBanList(BanList.Type.NAME).pardon(args[0]); - Command.broadcastCommandMessage(sender, "Pardoned " + args[0]); - return true; - } - - @Override - public List tabComplete(CommandSender sender, String alias, String[] args) throws IllegalArgumentException { - Validate.notNull(sender, "Sender cannot be null"); - Validate.notNull(args, "Arguments cannot be null"); - Validate.notNull(alias, "Alias cannot be null"); - - if (args.length == 1) { - List completions = new ArrayList(); - for (OfflinePlayer player : Bukkit.getBannedPlayers()) { - String name = player.getName(); - if (StringUtil.startsWithIgnoreCase(name, args[0])) { - completions.add(name); - } - } - return completions; - } - return ImmutableList.of(); - } -} diff --git a/NachoSpigot-API/src/main/java/org/bukkit/command/defaults/PardonIpCommand.java b/NachoSpigot-API/src/main/java/org/bukkit/command/defaults/PardonIpCommand.java deleted file mode 100644 index 0f63c26bf..000000000 --- a/NachoSpigot-API/src/main/java/org/bukkit/command/defaults/PardonIpCommand.java +++ /dev/null @@ -1,53 +0,0 @@ -package org.bukkit.command.defaults; - -import java.util.ArrayList; -import java.util.List; - -import org.apache.commons.lang.Validate; -import org.bukkit.Bukkit; -import org.bukkit.ChatColor; -import org.bukkit.command.Command; -import org.bukkit.command.CommandSender; -import org.bukkit.util.StringUtil; - -import com.google.common.collect.ImmutableList; - -@Deprecated -public class PardonIpCommand extends VanillaCommand { - public PardonIpCommand() { - super("pardon-ip"); - this.description = "Allows the specified IP address to use this server"; - this.usageMessage = "/pardon-ip
"; - this.setPermission("bukkit.command.unban.ip"); - } - - @Override - public boolean execute(CommandSender sender, String currentAlias, String[] args) { - if (!testPermission(sender)) return true; - if (args.length != 1) { - sender.sendMessage(ChatColor.RED + "Usage: " + usageMessage); - return false; - } - - if (BanIpCommand.ipValidity.matcher(args[0]).matches()) { - Bukkit.unbanIP(args[0]); - Command.broadcastCommandMessage(sender, "Pardoned ip " + args[0]); - } else { - sender.sendMessage("Invalid ip"); - } - - return true; - } - - @Override - public List tabComplete(CommandSender sender, String alias, String[] args) throws IllegalArgumentException { - Validate.notNull(sender, "Sender cannot be null"); - Validate.notNull(args, "Arguments cannot be null"); - Validate.notNull(alias, "Alias cannot be null"); - - if (args.length == 1) { - return StringUtil.copyPartialMatches(args[0], Bukkit.getIPBans(), new ArrayList()); - } - return ImmutableList.of(); - } -} diff --git a/NachoSpigot-API/src/main/java/org/bukkit/command/defaults/PlaySoundCommand.java b/NachoSpigot-API/src/main/java/org/bukkit/command/defaults/PlaySoundCommand.java deleted file mode 100644 index a7737adbc..000000000 --- a/NachoSpigot-API/src/main/java/org/bukkit/command/defaults/PlaySoundCommand.java +++ /dev/null @@ -1,88 +0,0 @@ -package org.bukkit.command.defaults; - -import org.bukkit.Bukkit; -import org.bukkit.ChatColor; -import org.bukkit.Location; -import org.bukkit.command.CommandSender; -import org.bukkit.entity.Player; - -@Deprecated -public class PlaySoundCommand extends VanillaCommand { - public PlaySoundCommand() { - super("playsound"); - this.description = "Plays a sound to a given player"; - this.usageMessage = "/playsound [x] [y] [z] [volume] [pitch] [minimumVolume]"; - this.setPermission("bukkit.command.playsound"); - } - - @Override - public boolean execute(CommandSender sender, String currentAlias, String[] args) { - if (!testPermission(sender)) { - return true; - } - - if (args.length < 2) { - sender.sendMessage(ChatColor.RED + "Usage: " + usageMessage); - return false; - } - final String soundArg = args[0]; - final String playerArg = args[1]; - - final Player player = Bukkit.getPlayerExact(playerArg); - if (player == null) { - sender.sendMessage(ChatColor.RED + "Can't find player " + playerArg); - return false; - } - - final Location location = player.getLocation(); - - double x = Math.floor(location.getX()); - double y = Math.floor(location.getY() + 0.5D); - double z = Math.floor(location.getZ()); - double volume = 1.0D; - double pitch = 1.0D; - double minimumVolume = 0.0D; - - switch (args.length) { - default: - case 8: - minimumVolume = getDouble(sender, args[7], 0.0D, 1.0D); - case 7: - pitch = getDouble(sender, args[6], 0.0D, 2.0D); - case 6: - volume = getDouble(sender, args[5], 0.0D, Float.MAX_VALUE); - case 5: - z = getRelativeDouble(z, sender, args[4]); - case 4: - y = getRelativeDouble(y, sender, args[3]); - case 3: - x = getRelativeDouble(x, sender, args[2]); - case 2: - // Noop - } - - final double fixedVolume = volume > 1.0D ? volume * 16.0D : 16.0D; - final Location soundLocation = new Location(player.getWorld(), x, y, z); - if (location.distanceSquared(soundLocation) > fixedVolume * fixedVolume) { - if (minimumVolume <= 0.0D) { - sender.sendMessage(ChatColor.RED + playerArg + " is too far away to hear the sound"); - return false; - } - - final double deltaX = x - location.getX(); - final double deltaY = y - location.getY(); - final double deltaZ = z - location.getZ(); - final double delta = Math.sqrt(deltaX * deltaX + deltaY * deltaY + deltaZ * deltaZ) / 2.0D; - - if (delta > 0.0D) { - location.add(deltaX / delta, deltaY / delta, deltaZ / delta); - } - - player.playSound(location, soundArg, (float) minimumVolume, (float) pitch); - } else { - player.playSound(soundLocation, soundArg, (float) volume, (float) pitch); - } - sender.sendMessage(String.format("Played '%s' to %s", soundArg, playerArg)); - return true; - } -} diff --git a/NachoSpigot-API/src/main/java/org/bukkit/command/defaults/SaveCommand.java b/NachoSpigot-API/src/main/java/org/bukkit/command/defaults/SaveCommand.java deleted file mode 100644 index d08d3ed03..000000000 --- a/NachoSpigot-API/src/main/java/org/bukkit/command/defaults/SaveCommand.java +++ /dev/null @@ -1,47 +0,0 @@ -package org.bukkit.command.defaults; - -import java.util.List; - -import org.apache.commons.lang.Validate; -import org.bukkit.Bukkit; -import org.bukkit.World; -import org.bukkit.command.Command; -import org.bukkit.command.CommandSender; - -import com.google.common.collect.ImmutableList; - -@Deprecated -public class SaveCommand extends VanillaCommand { - public SaveCommand() { - super("save-all"); - this.description = "Saves the server to disk"; - this.usageMessage = "/save-all"; - this.setPermission("bukkit.command.save.perform"); - } - - @Override - public boolean execute(CommandSender sender, String currentAlias, String[] args) { - if (!testPermission(sender)) return true; - - Command.broadcastCommandMessage(sender, "Forcing save.."); - - Bukkit.savePlayers(); - - for (World world : Bukkit.getWorlds()) { - world.save(); - } - - Command.broadcastCommandMessage(sender, "Save complete."); - - return true; - } - - @Override - public List tabComplete(CommandSender sender, String alias, String[] args) throws IllegalArgumentException { - Validate.notNull(sender, "Sender cannot be null"); - Validate.notNull(args, "Arguments cannot be null"); - Validate.notNull(alias, "Alias cannot be null"); - - return ImmutableList.of(); - } -} diff --git a/NachoSpigot-API/src/main/java/org/bukkit/command/defaults/SaveOffCommand.java b/NachoSpigot-API/src/main/java/org/bukkit/command/defaults/SaveOffCommand.java deleted file mode 100644 index 54e6bca89..000000000 --- a/NachoSpigot-API/src/main/java/org/bukkit/command/defaults/SaveOffCommand.java +++ /dev/null @@ -1,42 +0,0 @@ -package org.bukkit.command.defaults; - -import java.util.List; - -import org.apache.commons.lang.Validate; -import org.bukkit.Bukkit; -import org.bukkit.World; -import org.bukkit.command.Command; -import org.bukkit.command.CommandSender; - -import com.google.common.collect.ImmutableList; - -@Deprecated -public class SaveOffCommand extends VanillaCommand { - public SaveOffCommand() { - super("save-off"); - this.description = "Disables server autosaving"; - this.usageMessage = "/save-off"; - this.setPermission("bukkit.command.save.disable"); - } - - @Override - public boolean execute(CommandSender sender, String currentAlias, String[] args) { - if (!testPermission(sender)) return true; - - for (World world : Bukkit.getWorlds()) { - world.setAutoSave(false); - } - - Command.broadcastCommandMessage(sender, "Disabled level saving.."); - return true; - } - - @Override - public List tabComplete(CommandSender sender, String alias, String[] args) throws IllegalArgumentException { - Validate.notNull(sender, "Sender cannot be null"); - Validate.notNull(args, "Arguments cannot be null"); - Validate.notNull(alias, "Alias cannot be null"); - - return ImmutableList.of(); - } -} diff --git a/NachoSpigot-API/src/main/java/org/bukkit/command/defaults/SaveOnCommand.java b/NachoSpigot-API/src/main/java/org/bukkit/command/defaults/SaveOnCommand.java deleted file mode 100644 index 760e1c483..000000000 --- a/NachoSpigot-API/src/main/java/org/bukkit/command/defaults/SaveOnCommand.java +++ /dev/null @@ -1,42 +0,0 @@ -package org.bukkit.command.defaults; - -import java.util.List; - -import org.apache.commons.lang.Validate; -import org.bukkit.Bukkit; -import org.bukkit.World; -import org.bukkit.command.Command; -import org.bukkit.command.CommandSender; - -import com.google.common.collect.ImmutableList; - -@Deprecated -public class SaveOnCommand extends VanillaCommand { - public SaveOnCommand() { - super("save-on"); - this.description = "Enables server autosaving"; - this.usageMessage = "/save-on"; - this.setPermission("bukkit.command.save.enable"); - } - - @Override - public boolean execute(CommandSender sender, String currentAlias, String[] args) { - if (!testPermission(sender)) return true; - - for (World world : Bukkit.getWorlds()) { - world.setAutoSave(true); - } - - Command.broadcastCommandMessage(sender, "Enabled level saving.."); - return true; - } - - @Override - public List tabComplete(CommandSender sender, String alias, String[] args) throws IllegalArgumentException { - Validate.notNull(sender, "Sender cannot be null"); - Validate.notNull(args, "Arguments cannot be null"); - Validate.notNull(alias, "Alias cannot be null"); - - return ImmutableList.of(); - } -} diff --git a/NachoSpigot-API/src/main/java/org/bukkit/command/defaults/SayCommand.java b/NachoSpigot-API/src/main/java/org/bukkit/command/defaults/SayCommand.java deleted file mode 100644 index 2b2a32a15..000000000 --- a/NachoSpigot-API/src/main/java/org/bukkit/command/defaults/SayCommand.java +++ /dev/null @@ -1,61 +0,0 @@ -package org.bukkit.command.defaults; - -import java.util.List; - -import org.apache.commons.lang.Validate; -import org.bukkit.Bukkit; -import org.bukkit.ChatColor; -import org.bukkit.command.CommandSender; -import org.bukkit.command.ConsoleCommandSender; -import org.bukkit.entity.Player; - -import com.google.common.collect.ImmutableList; - -@Deprecated -public class SayCommand extends VanillaCommand { - public SayCommand() { - super("say"); - this.description = "Broadcasts the given message as the sender"; - this.usageMessage = "/say "; - this.setPermission("bukkit.command.say"); - } - - @Override - public boolean execute(CommandSender sender, String currentAlias, String[] args) { - if (!testPermission(sender)) return true; - if (args.length == 0) { - sender.sendMessage(ChatColor.RED + "Usage: " + usageMessage); - return false; - } - - StringBuilder message = new StringBuilder(); - message.append(ChatColor.LIGHT_PURPLE).append("["); - if (sender instanceof ConsoleCommandSender) { - message.append("Server"); - } else if (sender instanceof Player) { - message.append(((Player) sender).getDisplayName()); - } else { - message.append(sender.getName()); - } - message.append(ChatColor.LIGHT_PURPLE).append("] "); - - message.append(args[0]); - for (int i = 1; i < args.length; i++) { - message.append(" ").append(args[i]); - } - - Bukkit.broadcastMessage(message.toString()); - return true; - } - - @Override - public List tabComplete(CommandSender sender, String alias, String[] args) throws IllegalArgumentException { - Validate.notNull(sender, "Sender cannot be null"); - Validate.notNull(args, "Arguments cannot be null"); - - if (args.length >= 1) { - return super.tabComplete(sender, alias, args); - } - return ImmutableList.of(); - } -} diff --git a/NachoSpigot-API/src/main/java/org/bukkit/command/defaults/ScoreboardCommand.java b/NachoSpigot-API/src/main/java/org/bukkit/command/defaults/ScoreboardCommand.java deleted file mode 100644 index 00197f760..000000000 --- a/NachoSpigot-API/src/main/java/org/bukkit/command/defaults/ScoreboardCommand.java +++ /dev/null @@ -1,618 +0,0 @@ -package org.bukkit.command.defaults; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.Collections; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import org.apache.commons.lang.ArrayUtils; -import org.apache.commons.lang.StringUtils; -import org.apache.commons.lang.Validate; -import org.bukkit.Bukkit; -import org.bukkit.ChatColor; -import org.bukkit.OfflinePlayer; -import org.bukkit.command.CommandSender; -import org.bukkit.entity.Player; -import org.bukkit.scoreboard.DisplaySlot; -import org.bukkit.scoreboard.Objective; -import org.bukkit.scoreboard.Score; -import org.bukkit.scoreboard.Scoreboard; -import org.bukkit.scoreboard.Team; -import org.bukkit.util.StringUtil; - -import com.google.common.collect.ImmutableList; -import com.google.common.collect.ImmutableMap; - -@Deprecated -public class ScoreboardCommand extends VanillaCommand { - - private static final List MAIN_CHOICES = ImmutableList.of("objectives", "players", "teams"); - private static final List OBJECTIVES_CHOICES = ImmutableList.of("list", "add", "remove", "setdisplay"); - private static final List OBJECTIVES_CRITERIA = ImmutableList.of("health", "playerKillCount", "totalKillCount", "deathCount", "dummy"); - private static final List PLAYERS_CHOICES = ImmutableList.of("set", "add", "remove", "reset", "list"); - private static final List TEAMS_CHOICES = ImmutableList.of("add", "remove", "join", "leave", "empty", "list", "option"); - private static final List TEAMS_OPTION_CHOICES = ImmutableList.of("color", "friendlyfire", "seeFriendlyInvisibles"); - private static final Map OBJECTIVES_DISPLAYSLOT = ImmutableMap.of("belowName", DisplaySlot.BELOW_NAME, "list", DisplaySlot.PLAYER_LIST, "sidebar", DisplaySlot.SIDEBAR); - private static final Map TEAMS_OPTION_COLOR = ImmutableMap.builder() - .put("aqua", ChatColor.AQUA) - .put("black", ChatColor.BLACK) - .put("blue", ChatColor.BLUE) - .put("bold", ChatColor.BOLD) - .put("dark_aqua", ChatColor.DARK_AQUA) - .put("dark_blue", ChatColor.DARK_BLUE) - .put("dark_gray", ChatColor.DARK_GRAY) - .put("dark_green", ChatColor.DARK_GREEN) - .put("dark_purple", ChatColor.DARK_PURPLE) - .put("dark_red", ChatColor.DARK_RED) - .put("gold", ChatColor.GOLD) - .put("gray", ChatColor.GRAY) - .put("green", ChatColor.GREEN) - .put("italic", ChatColor.ITALIC) - .put("light_purple", ChatColor.LIGHT_PURPLE) - .put("obfuscated", ChatColor.MAGIC) // This is the important line - .put("red", ChatColor.RED) - .put("reset", ChatColor.RESET) - .put("strikethrough", ChatColor.STRIKETHROUGH) - .put("underline", ChatColor.UNDERLINE) - .put("white", ChatColor.WHITE) - .put("yellow", ChatColor.YELLOW) - .build(); - private static final List BOOLEAN = ImmutableList.of("true", "false"); - - public ScoreboardCommand() { - super("scoreboard"); - this.description = "Scoreboard control"; - this.usageMessage = "/scoreboard"; - this.setPermission("bukkit.command.scoreboard"); - } - - @Override - public boolean execute(CommandSender sender, String currentAlias, String[] args) { - if (!testPermission(sender)) - return true; - if (args.length < 1 || args[0].length() == 0) { - sender.sendMessage(ChatColor.RED + "Usage: /scoreboard "); - return false; - } - - final Scoreboard mainScoreboard = Bukkit.getScoreboardManager().getMainScoreboard(); - - if (args[0].equalsIgnoreCase("objectives")) { - if (args.length == 1) { - sender.sendMessage(ChatColor.RED + "Usage: /scoreboard objectives "); - return false; - } - if (args[1].equalsIgnoreCase("list")) { - Set objectives = mainScoreboard.getObjectives(); - if (objectives.isEmpty()) { - sender.sendMessage(ChatColor.RED + "There are no objectives on the scoreboard"); - return false; - } - sender.sendMessage(ChatColor.DARK_GREEN + "Showing " + objectives.size() + " objective(s) on scoreboard"); - for (Objective objective : objectives) { - sender.sendMessage("- " + objective.getName() + ": displays as '" + objective.getDisplayName() + "' and is type '" + objective.getCriteria() + "'"); - } - } else if (args[1].equalsIgnoreCase("add")) { - if (args.length < 4) { - sender.sendMessage(ChatColor.RED + "/scoreboard objectives add [display name ...]"); - return false; - } - String name = args[2]; - String criteria = args[3]; - - if (criteria == null) { - sender.sendMessage(ChatColor.RED + "Invalid objective criteria type. Valid types are: " + stringCollectionToString(OBJECTIVES_CRITERIA)); - } else if (name.length() > 16) { - sender.sendMessage(ChatColor.RED + "The name '" + name + "' is too long for an objective, it can be at most 16 characters long"); - } else if (mainScoreboard.getObjective(name) != null) { - sender.sendMessage(ChatColor.RED + "An objective with the name '" + name + "' already exists"); - } else { - String displayName = null; - if (args.length > 4) { - displayName = StringUtils.join(ArrayUtils.subarray(args, 4, args.length), ' '); - if (displayName.length() > 32) { - sender.sendMessage(ChatColor.RED + "The name '" + displayName + "' is too long for an objective, it can be at most 32 characters long"); - return false; - } - } - Objective objective = mainScoreboard.registerNewObjective(name, criteria); - if (displayName != null && displayName.length() > 0) { - objective.setDisplayName(displayName); - } - sender.sendMessage("Added new objective '" + name + "' successfully"); - } - } else if (args[1].equalsIgnoreCase("remove")) { - if (args.length != 3) { - sender.sendMessage(ChatColor.RED + "/scoreboard objectives remove "); - return false; - } - String name = args[2]; - Objective objective = mainScoreboard.getObjective(name); - if (objective == null) { - sender.sendMessage(ChatColor.RED + "No objective was found by the name '" + name + "'"); - } else { - objective.unregister(); - sender.sendMessage("Removed objective '" + name + "' successfully"); - } - } else if (args[1].equalsIgnoreCase("setdisplay")) { - if (args.length != 3 && args.length != 4) { - sender.sendMessage(ChatColor.RED + "/scoreboard objectives setdisplay [objective]"); - return false; - } - String slotName = args[2]; - DisplaySlot slot = OBJECTIVES_DISPLAYSLOT.get(slotName); - if (slot == null) { - sender.sendMessage(ChatColor.RED + "No such display slot '" + slotName + "'"); - } else { - if (args.length == 4) { - String objectiveName = args[3]; - Objective objective = mainScoreboard.getObjective(objectiveName); - if (objective == null) { - sender.sendMessage(ChatColor.RED + "No objective was found by the name '" + objectiveName + "'"); - return false; - } - - objective.setDisplaySlot(slot); - sender.sendMessage("Set the display objective in slot '" + slotName + "' to '" + objective.getName() + "'"); - } else { - Objective objective = mainScoreboard.getObjective(slot); - if (objective != null) { - objective.setDisplaySlot(null); - } - sender.sendMessage("Cleared objective display slot '" + slotName + "'"); - } - } - } - } else if (args[0].equalsIgnoreCase("players")) { - if (args.length == 1) { - sender.sendMessage(ChatColor.RED + "/scoreboard players "); - return false; - } - if (args[1].equalsIgnoreCase("set") || args[1].equalsIgnoreCase("add") || args[1].equalsIgnoreCase("remove")) { - if (args.length != 5) { - if (args[1].equalsIgnoreCase("set")) { - sender.sendMessage(ChatColor.RED + "/scoreboard players set "); - } else if (args[1].equalsIgnoreCase("add")) { - sender.sendMessage(ChatColor.RED + "/scoreboard players add "); - } else { - sender.sendMessage(ChatColor.RED + "/scoreboard players remove "); - } - return false; - } - String objectiveName = args[3]; - Objective objective = mainScoreboard.getObjective(objectiveName); - if (objective == null) { - sender.sendMessage(ChatColor.RED + "No objective was found by the name '" + objectiveName + "'"); - return false; - } else if (!objective.isModifiable()) { - sender.sendMessage(ChatColor.RED + "The objective '" + objectiveName + "' is read-only and cannot be set"); - return false; - } - - String valueString = args[4]; - int value; - try { - value = Integer.parseInt(valueString); - } catch (NumberFormatException e) { - sender.sendMessage(ChatColor.RED + "'" + valueString + "' is not a valid number"); - return false; - } - if (value < 1 && !args[1].equalsIgnoreCase("set")) { - sender.sendMessage(ChatColor.RED + "The number you have entered (" + value + ") is too small, it must be at least 1"); - return false; - } - - String playerName = args[2]; - if (playerName.length() > 16) { - sender.sendMessage(ChatColor.RED + "'" + playerName + "' is too long for a player name"); - return false; - } - Score score = objective.getScore(playerName); - int newScore; - if (args[1].equalsIgnoreCase("set")) { - newScore = value; - } else if (args[1].equalsIgnoreCase("add")) { - newScore = score.getScore() + value; - } else { - newScore = score.getScore() - value; - } - score.setScore(newScore); - sender.sendMessage("Set score of " + objectiveName + " for player " + playerName + " to " + newScore); - } else if (args[1].equalsIgnoreCase("reset")) { - if (args.length != 3) { - sender.sendMessage(ChatColor.RED + "/scoreboard players reset "); - return false; - } - String playerName = args[2]; - if (playerName.length() > 16) { - sender.sendMessage(ChatColor.RED + "'" + playerName + "' is too long for a player name"); - return false; - } - mainScoreboard.resetScores(playerName); - sender.sendMessage("Reset all scores of player " + playerName); - } else if (args[1].equalsIgnoreCase("list")) { - if (args.length > 3) { - sender.sendMessage(ChatColor.RED + "/scoreboard players list "); - return false; - } - if (args.length == 2) { - Set entries = mainScoreboard.getEntries(); - if (entries.isEmpty()) { - sender.sendMessage(ChatColor.RED + "There are no tracked players on the scoreboard"); - } else { - sender.sendMessage(ChatColor.DARK_GREEN + "Showing " + entries.size() + " tracked players on the scoreboard"); - sender.sendMessage(stringCollectionToString(entries)); - } - } else { - String playerName = args[2]; - if (playerName.length() > 16) { - sender.sendMessage(ChatColor.RED + "'" + playerName + "' is too long for a player name"); - return false; - } - Set scores = mainScoreboard.getScores(playerName); - if (scores.isEmpty()) { - sender.sendMessage(ChatColor.RED + "Player " + playerName + " has no scores recorded"); - } else { - sender.sendMessage(ChatColor.DARK_GREEN + "Showing " + scores.size() + " tracked objective(s) for " + playerName); - for (Score score : scores) { - sender.sendMessage("- " + score.getObjective().getDisplayName() + ": " + score.getScore() + " (" + score.getObjective().getName() + ")"); - } - } - } - } - } else if (args[0].equalsIgnoreCase("teams")) { - if (args.length == 1) { - sender.sendMessage(ChatColor.RED + "/scoreboard teams "); - return false; - } - if (args[1].equalsIgnoreCase("list")) { - if (args.length == 2) { - Set teams = mainScoreboard.getTeams(); - if (teams.isEmpty()) { - sender.sendMessage(ChatColor.RED + "There are no teams registered on the scoreboard"); - } else { - sender.sendMessage(ChatColor.DARK_GREEN + "Showing " + teams.size() + " teams on the scoreboard"); - for (Team team : teams) { - sender.sendMessage("- " + team.getName() + ": '" + team.getDisplayName() + "' has " + team.getSize() + " players"); - } - } - } else if (args.length == 3) { - String teamName = args[2]; - Team team = mainScoreboard.getTeam(teamName); - if (team == null) { - sender.sendMessage(ChatColor.RED + "No team was found by the name '" + teamName + "'"); - } else { - Set players = team.getPlayers(); - if (players.isEmpty()) { - sender.sendMessage(ChatColor.RED + "Team " + team.getName() + " has no players"); - } else { - sender.sendMessage(ChatColor.DARK_GREEN + "Showing " + players.size() + " player(s) in team " + team.getName()); - sender.sendMessage(offlinePlayerSetToString(players)); - } - } - } else { - sender.sendMessage(ChatColor.RED + "/scoreboard teams list [name]"); - return false; - } - } else if (args[1].equalsIgnoreCase("add")) { - if (args.length < 3) { - sender.sendMessage(ChatColor.RED + "/scoreboard teams add [display name ...]"); - return false; - } - String name = args[2]; - if (name.length() > 16) { - sender.sendMessage(ChatColor.RED + "The name '" + name + "' is too long for a team, it can be at most 16 characters long"); - } else if (mainScoreboard.getTeam(name) != null) { - sender.sendMessage(ChatColor.RED + "A team with the name '" + name + "' already exists"); - } else { - String displayName = null; - if (args.length > 3) { - displayName = StringUtils.join(ArrayUtils.subarray(args, 3, args.length), ' '); - if (displayName.length() > 32) { - sender.sendMessage(ChatColor.RED + "The display name '" + displayName + "' is too long for a team, it can be at most 32 characters long"); - return false; - } - } - Team team = mainScoreboard.registerNewTeam(name); - if (displayName != null && displayName.length() > 0) { - team.setDisplayName(displayName); - } - sender.sendMessage("Added new team '" + team.getName() + "' successfully"); - } - } else if (args[1].equalsIgnoreCase("remove")) { - if (args.length != 3) { - sender.sendMessage(ChatColor.RED + "/scoreboard teams remove "); - return false; - } - String name = args[2]; - Team team = mainScoreboard.getTeam(name); - if (team == null) { - sender.sendMessage(ChatColor.RED + "No team was found by the name '" + name + "'"); - } else { - team.unregister(); - sender.sendMessage("Removed team " + name); - } - } else if (args[1].equalsIgnoreCase("empty")) { - if (args.length != 3) { - sender.sendMessage(ChatColor.RED + "/scoreboard teams clear "); - return false; - } - String name = args[2]; - Team team = mainScoreboard.getTeam(name); - if (team == null) { - sender.sendMessage(ChatColor.RED + "No team was found by the name '" + name + "'"); - } else { - Set players = team.getPlayers(); - if (players.isEmpty()) { - sender.sendMessage(ChatColor.RED + "Team " + team.getName() + " is already empty, cannot remove nonexistant players"); - } else { - for (OfflinePlayer player : players) { - team.removePlayer(player); - } - sender.sendMessage("Removed all " + players.size() + " player(s) from team " + team.getName()); - } - } - } else if (args[1].equalsIgnoreCase("join")) { - if ((sender instanceof Player) ? args.length < 3 : args.length < 4) { - sender.sendMessage(ChatColor.RED + "/scoreboard teams join [player...]"); - return false; - } - String teamName = args[2]; - Team team = mainScoreboard.getTeam(teamName); - if (team == null) { - sender.sendMessage(ChatColor.RED + "No team was found by the name '" + teamName + "'"); - } else { - Set addedPlayers = new HashSet(); - if ((sender instanceof Player) && args.length == 3) { - team.addPlayer((Player) sender); - addedPlayers.add(sender.getName()); - } else { - for (int i = 3; i < args.length; i++) { - String playerName = args[i]; - OfflinePlayer offlinePlayer; - Player player = Bukkit.getPlayerExact(playerName); - if (player != null) { - offlinePlayer = player; - } else { - offlinePlayer = Bukkit.getOfflinePlayer(playerName); - } - team.addPlayer(offlinePlayer); - addedPlayers.add(offlinePlayer.getName()); - } - } - sender.sendMessage("Added " + addedPlayers.size() + " player(s) to team " + team.getName() + ": " + stringCollectionToString(addedPlayers)); - } - } else if (args[1].equalsIgnoreCase("leave")) { - if (!(sender instanceof Player) && args.length < 3) { - sender.sendMessage(ChatColor.RED + "/scoreboard teams leave [player...]"); - return false; - } - Set left = new HashSet(); - Set noTeam = new HashSet(); - if ((sender instanceof Player) && args.length == 2) { - Team team = mainScoreboard.getPlayerTeam((Player) sender); - if (team != null) { - team.removePlayer((Player) sender); - left.add(sender.getName()); - } else { - noTeam.add(sender.getName()); - } - } else { - for (int i = 2; i < args.length; i++) { - String playerName = args[i]; - OfflinePlayer offlinePlayer; - Player player = Bukkit.getPlayerExact(playerName); - if (player != null) { - offlinePlayer = player; - } else { - offlinePlayer = Bukkit.getOfflinePlayer(playerName); - } - Team team = mainScoreboard.getPlayerTeam(offlinePlayer); - if (team != null) { - team.removePlayer(offlinePlayer); - left.add(offlinePlayer.getName()); - } else { - noTeam.add(offlinePlayer.getName()); - } - } - } - if (!left.isEmpty()) { - sender.sendMessage("Removed " + left.size() + " player(s) from their teams: " + stringCollectionToString(left)); - } - if (!noTeam.isEmpty()) { - sender.sendMessage("Could not remove " + noTeam.size() + " player(s) from their teams: " + stringCollectionToString(noTeam)); - } - } else if (args[1].equalsIgnoreCase("option")) { - if (args.length != 4 && args.length != 5) { - sender.sendMessage(ChatColor.RED + "/scoreboard teams option "); - return false; - } - String teamName = args[2]; - Team team = mainScoreboard.getTeam(teamName); - if (team == null) { - sender.sendMessage(ChatColor.RED + "No team was found by the name '" + teamName + "'"); - return false; - } - String option = args[3].toLowerCase(); - if (!option.equals("friendlyfire") && !option.equals("color") && !option.equals("seefriendlyinvisibles")) { - sender.sendMessage(ChatColor.RED + "/scoreboard teams option "); - return false; - } - if (args.length == 4) { - if (option.equals("color")) { - sender.sendMessage(ChatColor.RED + "Valid values for option color are: " + stringCollectionToString(TEAMS_OPTION_COLOR.keySet())); - } else { - sender.sendMessage(ChatColor.RED + "Valid values for option " + option + " are: true and false"); - } - } else { - String value = args[4].toLowerCase(); - if (option.equals("color")) { - ChatColor color = TEAMS_OPTION_COLOR.get(value); - if (color == null) { - sender.sendMessage(ChatColor.RED + "Valid values for option color are: " + stringCollectionToString(TEAMS_OPTION_COLOR.keySet())); - return false; - } - team.setPrefix(color.toString()); - team.setSuffix(ChatColor.RESET.toString()); - } else { - if (!value.equals("true") && !value.equals("false")) { - sender.sendMessage(ChatColor.RED + "Valid values for option " + option + " are: true and false"); - return false; - } - if (option.equals("friendlyfire")) { - team.setAllowFriendlyFire(value.equals("true")); - } else { - team.setCanSeeFriendlyInvisibles(value.equals("true")); - } - } - sender.sendMessage("Set option " + option + " for team " + team.getName() + " to " + value); - } - } - } else { - sender.sendMessage(ChatColor.RED + "Usage: /scoreboard "); - return false; - } - return true; - } - - @Override - public List tabComplete(CommandSender sender, String alias, String[] args) throws IllegalArgumentException { - Validate.notNull(sender, "Sender cannot be null"); - Validate.notNull(args, "Arguments cannot be null"); - Validate.notNull(alias, "Alias cannot be null"); - - if (args.length == 1) { - return StringUtil.copyPartialMatches(args[0], MAIN_CHOICES, new ArrayList()); - } - if (args.length > 1) { - if (args[0].equalsIgnoreCase("objectives")) { - if (args.length == 2) { - return StringUtil.copyPartialMatches(args[1], OBJECTIVES_CHOICES, new ArrayList()); - } - if (args[1].equalsIgnoreCase("add")) { - if (args.length == 4) { - return StringUtil.copyPartialMatches(args[3], OBJECTIVES_CRITERIA, new ArrayList()); - } - } else if (args[1].equalsIgnoreCase("remove")) { - if (args.length == 3) { - return StringUtil.copyPartialMatches(args[2], this.getCurrentObjectives(), new ArrayList()); - } - } else if (args[1].equalsIgnoreCase("setdisplay")) { - if (args.length == 3) { - return StringUtil.copyPartialMatches(args[2], OBJECTIVES_DISPLAYSLOT.keySet(), new ArrayList()); - } - if (args.length == 4) { - return StringUtil.copyPartialMatches(args[3], this.getCurrentObjectives(), new ArrayList()); - } - } - } else if (args[0].equalsIgnoreCase("players")) { - if (args.length == 2) { - return StringUtil.copyPartialMatches(args[1], PLAYERS_CHOICES, new ArrayList()); - } - if (args[1].equalsIgnoreCase("set") || args[1].equalsIgnoreCase("add") || args[1].equalsIgnoreCase("remove")) { - if (args.length == 3) { - return super.tabComplete(sender, alias, args); - } - if (args.length == 4) { - return StringUtil.copyPartialMatches(args[3], this.getCurrentObjectives(), new ArrayList()); - } - } else { - if (args.length == 3) { - return StringUtil.copyPartialMatches(args[2], this.getCurrentEntries(), new ArrayList()); - } - } - } else if (args[0].equalsIgnoreCase("teams")) { - if (args.length == 2) { - return StringUtil.copyPartialMatches(args[1], TEAMS_CHOICES, new ArrayList()); - } - if (args[1].equalsIgnoreCase("join")) { - if (args.length == 3) { - return StringUtil.copyPartialMatches(args[2], this.getCurrentTeams(), new ArrayList()); - } - if (args.length >= 4) { - return super.tabComplete(sender, alias, args); - } - } else if (args[1].equalsIgnoreCase("leave")) { - return super.tabComplete(sender, alias, args); - } else if (args[1].equalsIgnoreCase("option")) { - if (args.length == 3) { - return StringUtil.copyPartialMatches(args[2], this.getCurrentTeams(), new ArrayList()); - } - if (args.length == 4) { - return StringUtil.copyPartialMatches(args[3], TEAMS_OPTION_CHOICES, new ArrayList()); - } - if (args.length == 5) { - if (args[3].equalsIgnoreCase("color")) { - return StringUtil.copyPartialMatches(args[4], TEAMS_OPTION_COLOR.keySet(), new ArrayList()); - } else { - return StringUtil.copyPartialMatches(args[4], BOOLEAN, new ArrayList()); - } - } - } else { - if (args.length == 3) { - return StringUtil.copyPartialMatches(args[2], this.getCurrentTeams(), new ArrayList()); - } - } - } - } - - return ImmutableList.of(); - } - - private static String offlinePlayerSetToString(Set set) { - StringBuilder string = new StringBuilder(); - String lastValue = null; - for (OfflinePlayer value : set) { - string.append(lastValue = value.getName()).append(", "); - } - string.delete(string.length() - 2, Integer.MAX_VALUE); - if (string.length() != lastValue.length()) { - string.insert(string.length() - lastValue.length(), "and "); - } - return string.toString(); - - } - - private static String stringCollectionToString(Collection set) { - StringBuilder string = new StringBuilder(); - String lastValue = null; - for (String value : set) { - string.append(lastValue = value).append(", "); - } - string.delete(string.length() - 2, Integer.MAX_VALUE); - if (string.length() != lastValue.length()) { - string.insert(string.length() - lastValue.length(), "and "); - } - return string.toString(); - } - - private List getCurrentObjectives() { - List list = new ArrayList(); - for (Objective objective : Bukkit.getScoreboardManager().getMainScoreboard().getObjectives()) { - list.add(objective.getName()); - } - Collections.sort(list, String.CASE_INSENSITIVE_ORDER); - return list; - } - - private List getCurrentEntries() { - List list = new ArrayList(); - for (String entry : Bukkit.getScoreboardManager().getMainScoreboard().getEntries()) { - list.add(entry); - } - Collections.sort(list, String.CASE_INSENSITIVE_ORDER); - return list; - } - - private List getCurrentTeams() { - List list = new ArrayList(); - for (Team team : Bukkit.getScoreboardManager().getMainScoreboard().getTeams()) { - list.add(team.getName()); - } - Collections.sort(list, String.CASE_INSENSITIVE_ORDER); - return list; - } -} diff --git a/NachoSpigot-API/src/main/java/org/bukkit/command/defaults/SeedCommand.java b/NachoSpigot-API/src/main/java/org/bukkit/command/defaults/SeedCommand.java deleted file mode 100644 index 3fb0639b2..000000000 --- a/NachoSpigot-API/src/main/java/org/bukkit/command/defaults/SeedCommand.java +++ /dev/null @@ -1,42 +0,0 @@ -package org.bukkit.command.defaults; - -import java.util.List; - -import org.apache.commons.lang.Validate; -import org.bukkit.Bukkit; -import org.bukkit.command.CommandSender; -import org.bukkit.entity.Player; - -import com.google.common.collect.ImmutableList; - -@Deprecated -public class SeedCommand extends VanillaCommand { - public SeedCommand() { - super("seed"); - this.description = "Shows the world seed"; - this.usageMessage = "/seed"; - this.setPermission("bukkit.command.seed"); - } - - @Override - public boolean execute(CommandSender sender, String commandLabel, String[] args) { - if (!testPermission(sender)) return true; - long seed; - if (sender instanceof Player) { - seed = ((Player) sender).getWorld().getSeed(); - } else { - seed = Bukkit.getWorlds().get(0).getSeed(); - } - sender.sendMessage("Seed: " + seed); - return true; - } - - @Override - public List tabComplete(CommandSender sender, String alias, String[] args) throws IllegalArgumentException { - Validate.notNull(sender, "Sender cannot be null"); - Validate.notNull(args, "Arguments cannot be null"); - Validate.notNull(alias, "Alias cannot be null"); - - return ImmutableList.of(); - } -} diff --git a/NachoSpigot-API/src/main/java/org/bukkit/command/defaults/SetIdleTimeoutCommand.java b/NachoSpigot-API/src/main/java/org/bukkit/command/defaults/SetIdleTimeoutCommand.java deleted file mode 100644 index f6cbe0351..000000000 --- a/NachoSpigot-API/src/main/java/org/bukkit/command/defaults/SetIdleTimeoutCommand.java +++ /dev/null @@ -1,54 +0,0 @@ -package org.bukkit.command.defaults; - -import com.google.common.collect.ImmutableList; - -import org.apache.commons.lang.Validate; -import org.bukkit.Bukkit; -import org.bukkit.ChatColor; -import org.bukkit.command.Command; -import org.bukkit.command.CommandSender; - -import java.util.List; - -@Deprecated -public class SetIdleTimeoutCommand extends VanillaCommand { - - public SetIdleTimeoutCommand() { - super("setidletimeout"); - this.description = "Sets the server's idle timeout"; - this.usageMessage = "/setidletimeout "; - this.setPermission("bukkit.command.setidletimeout"); - } - - @Override - public boolean execute(CommandSender sender, String currentAlias, String[] args) { - if (!testPermission(sender)) return true; - - if (args.length == 1) { - int minutes; - - try { - minutes = getInteger(sender, args[0], 0, Integer.MAX_VALUE, true); - } catch (NumberFormatException ex) { - sender.sendMessage(ex.getMessage()); - return true; - } - - Bukkit.getServer().setIdleTimeout(minutes); - - Command.broadcastCommandMessage(sender, "Successfully set the idle timeout to " + minutes + " minutes."); - return true; - } - sender.sendMessage(ChatColor.RED + "Usage: " + usageMessage); - return false; - } - - @Override - public List tabComplete(CommandSender sender, String alias, String[] args) { - Validate.notNull(sender, "Sender cannot be null"); - Validate.notNull(args, "Arguments cannot be null"); - Validate.notNull(alias, "Alias cannot be null"); - - return ImmutableList.of(); - } -} diff --git a/NachoSpigot-API/src/main/java/org/bukkit/command/defaults/SetWorldSpawnCommand.java b/NachoSpigot-API/src/main/java/org/bukkit/command/defaults/SetWorldSpawnCommand.java deleted file mode 100644 index 8bec19c95..000000000 --- a/NachoSpigot-API/src/main/java/org/bukkit/command/defaults/SetWorldSpawnCommand.java +++ /dev/null @@ -1,80 +0,0 @@ -package org.bukkit.command.defaults; - -import com.google.common.collect.ImmutableList; -import org.apache.commons.lang.Validate; -import org.bukkit.Bukkit; -import org.bukkit.ChatColor; -import org.bukkit.Location; -import org.bukkit.World; -import org.bukkit.command.Command; -import org.bukkit.command.CommandSender; -import org.bukkit.entity.Player; - -import java.util.List; - -@Deprecated -public class SetWorldSpawnCommand extends VanillaCommand { - - public SetWorldSpawnCommand() { - super("setworldspawn"); - this.description = "Sets a worlds's spawn point. If no coordinates are specified, the player's coordinates will be used."; - this.usageMessage = "/setworldspawn OR /setworldspawn "; - this.setPermission("bukkit.command.setworldspawn"); - } - - @Override - public boolean execute(CommandSender sender, String currentAlias, String[] args) { - if (!testPermission(sender)) return true; - - Player player = null; - World world; - if (sender instanceof Player) { - player = (Player) sender; - world = player.getWorld(); - } else { - world = Bukkit.getWorlds().get(0); - } - - final int x, y, z; - - if (args.length == 0) { - if (player == null) { - sender.sendMessage("You can only perform this command as a player"); - return true; - } - - Location location = player.getLocation(); - - x = location.getBlockX(); - y = location.getBlockY(); - z = location.getBlockZ(); - } else if (args.length == 3) { - try { - x = getInteger(sender, args[0], MIN_COORD, MAX_COORD, true); - y = getInteger(sender, args[1], 0, world.getMaxHeight(), true); - z = getInteger(sender, args[2], MIN_COORD, MAX_COORD, true); - } catch (NumberFormatException ex) { - sender.sendMessage(ex.getMessage()); - return true; - } - } else { - sender.sendMessage(ChatColor.RED + "Usage: " + usageMessage); - return false; - } - - world.setSpawnLocation(x, y, z); - - Command.broadcastCommandMessage(sender, "Set world " + world.getName() + "'s spawnpoint to (" + x + ", " + y + ", " + z + ")"); - return true; - - } - - @Override - public List tabComplete(CommandSender sender, String alias, String[] args) { - Validate.notNull(sender, "Sender cannot be null"); - Validate.notNull(args, "Arguments cannot be null"); - Validate.notNull(alias, "Alias cannot be null"); - - return ImmutableList.of(); - } -} diff --git a/NachoSpigot-API/src/main/java/org/bukkit/command/defaults/SpawnpointCommand.java b/NachoSpigot-API/src/main/java/org/bukkit/command/defaults/SpawnpointCommand.java deleted file mode 100644 index be15f7e0b..000000000 --- a/NachoSpigot-API/src/main/java/org/bukkit/command/defaults/SpawnpointCommand.java +++ /dev/null @@ -1,88 +0,0 @@ -package org.bukkit.command.defaults; - -import com.google.common.collect.ImmutableList; -import org.apache.commons.lang.Validate; -import org.bukkit.Bukkit; -import org.bukkit.ChatColor; -import org.bukkit.Location; -import org.bukkit.World; -import org.bukkit.command.Command; -import org.bukkit.command.CommandSender; -import org.bukkit.entity.Player; - -import java.util.List; - -@Deprecated -public class SpawnpointCommand extends VanillaCommand { - - public SpawnpointCommand() { - super("spawnpoint"); - this.description = "Sets a player's spawn point"; - this.usageMessage = "/spawnpoint OR /spawnpoint OR /spawnpoint "; - this.setPermission("bukkit.command.spawnpoint"); - } - - @Override - public boolean execute(CommandSender sender, String currentAlias, String[] args) { - if (!testPermission(sender)) return true; - - Player player; - - if (args.length == 0) { - if (sender instanceof Player) { - player = (Player) sender; - } else { - sender.sendMessage("Please provide a player!"); - return true; - } - } else { - player = Bukkit.getPlayerExact(args[0]); - if (player == null) { - sender.sendMessage("Can't find player " + args[0]); - return true; - } - } - - World world = player.getWorld(); - - if (args.length == 4) { - if (world != null) { - int pos = 1; - final int x, y, z; - try { - x = getInteger(sender, args[pos++], MIN_COORD, MAX_COORD, true); - y = getInteger(sender, args[pos++], 0, world.getMaxHeight()); - z = getInteger(sender, args[pos], MIN_COORD, MAX_COORD, true); - } catch(NumberFormatException ex) { - sender.sendMessage(ex.getMessage()); - return true; - } - - player.setBedSpawnLocation(new Location(world, x, y, z), true); - Command.broadcastCommandMessage(sender, "Set " + player.getDisplayName() + "'s spawnpoint to " + x + ", " + y + ", " + z); - } - } else if (args.length <= 1) { - Location location = player.getLocation(); - player.setBedSpawnLocation(location, true); - Command.broadcastCommandMessage(sender, "Set " + player.getDisplayName() + "'s spawnpoint to " + location.getX() + ", " + location.getY() + ", " + location.getZ()); - } else { - sender.sendMessage(ChatColor.RED + "Usage: " + usageMessage); - return false; - } - - return true; - } - - @Override - public List tabComplete(CommandSender sender, String alias, String[] args) { - Validate.notNull(sender, "Sender cannot be null"); - Validate.notNull(args, "Arguments cannot be null"); - Validate.notNull(alias, "Alias cannot be null"); - - if (args.length == 1) { - return super.tabComplete(sender, alias, args); - } - - return ImmutableList.of(); - } -} diff --git a/NachoSpigot-API/src/main/java/org/bukkit/command/defaults/SpreadPlayersCommand.java b/NachoSpigot-API/src/main/java/org/bukkit/command/defaults/SpreadPlayersCommand.java deleted file mode 100644 index 489f7608f..000000000 --- a/NachoSpigot-API/src/main/java/org/bukkit/command/defaults/SpreadPlayersCommand.java +++ /dev/null @@ -1,266 +0,0 @@ -package org.bukkit.command.defaults; - -import com.google.common.collect.Lists; -import com.google.common.collect.Maps; -import com.google.common.collect.Sets; -import java.util.List; -import java.util.Map; -import java.util.Random; -import java.util.Set; - -import org.bukkit.Bukkit; -import org.bukkit.ChatColor; -import org.bukkit.Location; -import org.bukkit.World; -import org.bukkit.command.CommandSender; -import org.bukkit.entity.Player; -import org.bukkit.scoreboard.Team; - -@Deprecated -public class SpreadPlayersCommand extends VanillaCommand { - private static final Random random = new Random(); - - public SpreadPlayersCommand() { - super("spreadplayers"); - this.description = "Spreads players around a point"; - this.usageMessage = "/spreadplayers "; - this.setPermission("bukkit.command.spreadplayers"); - } - - @Override - public boolean execute(CommandSender sender, String commandLabel, String[] args) { - if (!testPermission(sender)) { - return true; - } - - if (args.length < 6) { - sender.sendMessage(ChatColor.RED + "Usage: " + usageMessage); - return false; - } - - final double x = getDouble(sender, args[0], -30000000, 30000000); - final double z = getDouble(sender, args[1], -30000000, 30000000); - final double distance = getDouble(sender, args[2]); - final double range = getDouble(sender, args[3]); - - if (distance < 0.0D) { - sender.sendMessage(ChatColor.RED + "Distance is too small."); - return false; - } - - if (range < distance + 1.0D) { - sender.sendMessage(ChatColor.RED + "Max range is too small."); - return false; - } - - final String respectTeams = args[4]; - boolean teams = false; - - if (respectTeams.equalsIgnoreCase("true")) { - teams = true; - } else if (!respectTeams.equalsIgnoreCase("false")) { - sender.sendMessage(String.format(ChatColor.RED + "'%s' is not true or false", args[4])); - return false; - } - - List players = Lists.newArrayList(); - World world = null; - - for (int i = 5; i < args.length; i++) { - Player player = Bukkit.getPlayerExact(args[i]); - if (player == null) { - continue; - } - - if (world == null) { - world = player.getWorld(); - } - players.add(player); - } - - if (world == null) { - return true; - } - - final double xRangeMin = x - range; - final double zRangeMin = z - range; - final double xRangeMax = x + range; - final double zRangeMax = z + range; - - final int spreadSize = teams ? getTeams(players) : players.size(); - - final Location[] locations = getSpreadLocations(world, spreadSize, xRangeMin, zRangeMin, xRangeMax, zRangeMax); - final int rangeSpread = range(world, distance, xRangeMin, zRangeMin, xRangeMax, zRangeMax, locations); - - if (rangeSpread == -1) { - sender.sendMessage(String.format("Could not spread %d %s around %s,%s (too many players for space - try using spread of at most %s)", spreadSize, teams ? "teams" : "players", x, z)); - return false; - } - - final double distanceSpread = spread(world, players, locations, teams); - - sender.sendMessage(String.format("Succesfully spread %d %s around %s,%s", locations.length, teams ? "teams" : "players", x, z)); - if (locations.length > 1) { - sender.sendMessage(String.format("(Average distance between %s is %s blocks apart after %s iterations)", teams ? "teams" : "players", String.format("%.2f", distanceSpread), rangeSpread)); - } - return true; - } - - private int range(World world, double distance, double xRangeMin, double zRangeMin, double xRangeMax, double zRangeMax, Location[] locations) { - boolean flag = true; - double max; - - int i; - - for (i = 0; i < 10000 && flag; ++i) { - flag = false; - max = Float.MAX_VALUE; - - Location loc1; - int j; - - for (int k = 0; k < locations.length; ++k) { - Location loc2 = locations[k]; - - j = 0; - loc1 = new Location(world, 0, 0, 0); - - for (int l = 0; l < locations.length; ++l) { - if (k != l) { - Location loc3 = locations[l]; - double dis = loc2.distanceSquared(loc3); - - max = Math.min(dis, max); - if (dis < distance) { - ++j; - loc1.add(loc3.getX() - loc2.getX(), 0, 0); - loc1.add(loc3.getZ() - loc2.getZ(), 0, 0); - } - } - } - - if (j > 0) { - loc2.setX(loc2.getX() / j); - loc2.setZ(loc2.getZ() / j); - double d7 = Math.sqrt(loc1.getX() * loc1.getX() + loc1.getZ() * loc1.getZ()); - - if (d7 > 0.0D) { - loc1.setX(loc1.getX() / d7); - loc2.add(-loc1.getX(), 0, -loc1.getZ()); - } else { - double x = xRangeMin >= xRangeMax ? xRangeMin : random.nextDouble() * (xRangeMax - xRangeMin) + xRangeMin; - double z = zRangeMin >= zRangeMax ? zRangeMin : random.nextDouble() * (zRangeMax - zRangeMin) + zRangeMin; - loc2.setX(x); - loc2.setZ(z); - } - - flag = true; - } - - boolean swap = false; - - if (loc2.getX() < xRangeMin) { - loc2.setX(xRangeMin); - swap = true; - } else if (loc2.getX() > xRangeMax) { - loc2.setX(xRangeMax); - swap = true; - } - - if (loc2.getZ() < zRangeMin) { - loc2.setZ(zRangeMin); - swap = true; - } else if (loc2.getZ() > zRangeMax) { - loc2.setZ(zRangeMax); - swap = true; - } - if (swap) { - flag = true; - } - } - - if (!flag) { - Location[] locs = locations; - int i1 = locations.length; - - for (j = 0; j < i1; ++j) { - loc1 = locs[j]; - if (world.getHighestBlockYAt(loc1) == 0) { - double x = xRangeMin >= xRangeMax ? xRangeMin : random.nextDouble() * (xRangeMax - xRangeMin) + xRangeMin; - double z = zRangeMin >= zRangeMax ? zRangeMin : random.nextDouble() * (zRangeMax - zRangeMin) + zRangeMin; - locations[i] = (new Location(world, x, 0, z)); - loc1.setX(x); - loc1.setZ(z); - flag = true; - } - } - } - } - - if (i >= 10000) { - return -1; - } else { - return i; - } - } - - private double spread(World world, List list, Location[] locations, boolean teams) { - double distance = 0.0D; - int i = 0; - Map hashmap = Maps.newHashMap(); - - for (int j = 0; j < list.size(); ++j) { - Player player = list.get(j); - Location location; - - if (teams) { - Team team = player.getScoreboard().getPlayerTeam(player); - - if (!hashmap.containsKey(team)) { - hashmap.put(team, locations[i++]); - } - - location = hashmap.get(team); - } else { - location = locations[i++]; - } - - player.teleport(new Location(world, Math.floor(location.getX()) + 0.5D, world.getHighestBlockYAt((int) location.getX(), (int) location.getZ()), Math.floor(location.getZ()) + 0.5D)); - double value = Double.MAX_VALUE; - - for (int k = 0; k < locations.length; ++k) { - if (location != locations[k]) { - double d = location.distanceSquared(locations[k]); - value = Math.min(d, value); - } - } - - distance += value; - } - - distance /= list.size(); - return distance; - } - - private int getTeams(List players) { - Set teams = Sets.newHashSet(); - - for (Player player : players) { - teams.add(player.getScoreboard().getPlayerTeam(player)); - } - - return teams.size(); - } - - private Location[] getSpreadLocations(World world, int size, double xRangeMin, double zRangeMin, double xRangeMax, double zRangeMax) { - Location[] locations = new Location[size]; - - for (int i = 0; i < size; ++i) { - double x = xRangeMin >= xRangeMax ? xRangeMin : random.nextDouble() * (xRangeMax - xRangeMin) + xRangeMin; - double z = zRangeMin >= zRangeMax ? zRangeMin : random.nextDouble() * (zRangeMax - zRangeMin) + zRangeMin; - locations[i] = (new Location(world, x, 0, z)); - } - - return locations; - } -} diff --git a/NachoSpigot-API/src/main/java/org/bukkit/command/defaults/StopCommand.java b/NachoSpigot-API/src/main/java/org/bukkit/command/defaults/StopCommand.java deleted file mode 100644 index a9467e19a..000000000 --- a/NachoSpigot-API/src/main/java/org/bukkit/command/defaults/StopCommand.java +++ /dev/null @@ -1,49 +0,0 @@ -package org.bukkit.command.defaults; - -import java.util.List; - -import org.apache.commons.lang.StringUtils; -import org.apache.commons.lang.Validate; - -import org.bukkit.Bukkit; -import org.bukkit.command.Command; -import org.bukkit.command.CommandSender; -import org.bukkit.entity.Player; - -import com.google.common.collect.ImmutableList; - -@Deprecated -public class StopCommand extends VanillaCommand { - public StopCommand() { - super("stop"); - this.description = "Stops the server with optional reason"; - this.usageMessage = "/stop [reason]"; - this.setPermission("bukkit.command.stop"); - } - - @Override - public boolean execute(CommandSender sender, String currentAlias, String[] args) { - if (!testPermission(sender)) return true; - - Command.broadcastCommandMessage(sender, "Stopping the server.."); - Bukkit.shutdown(); - - String reason = this.createString(args, 0); - if (StringUtils.isNotEmpty(reason)) { - for (Player player : Bukkit.getOnlinePlayers()) { - player.kickPlayer(reason); - } - } - - return true; - } - - @Override - public List tabComplete(CommandSender sender, String alias, String[] args) throws IllegalArgumentException { - Validate.notNull(sender, "Sender cannot be null"); - Validate.notNull(args, "Arguments cannot be null"); - Validate.notNull(alias, "Alias cannot be null"); - - return ImmutableList.of(); - } -} diff --git a/NachoSpigot-API/src/main/java/org/bukkit/command/defaults/TeleportCommand.java b/NachoSpigot-API/src/main/java/org/bukkit/command/defaults/TeleportCommand.java deleted file mode 100644 index 7460196e5..000000000 --- a/NachoSpigot-API/src/main/java/org/bukkit/command/defaults/TeleportCommand.java +++ /dev/null @@ -1,125 +0,0 @@ -package org.bukkit.command.defaults; - -import java.util.List; - -import org.apache.commons.lang.Validate; -import org.bukkit.Bukkit; -import org.bukkit.ChatColor; -import org.bukkit.Location; -import org.bukkit.command.Command; -import org.bukkit.command.CommandSender; -import org.bukkit.entity.Player; -import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause; - -import com.google.common.collect.ImmutableList; - -@Deprecated -public class TeleportCommand extends VanillaCommand { - - public TeleportCommand() { - super("tp"); - this.description = "Teleports the given player (or yourself) to another player or coordinates"; - this.usageMessage = "/tp [player] and/or "; - this.setPermission("bukkit.command.teleport"); - } - - @Override - public boolean execute(CommandSender sender, String currentAlias, String[] args) { - if (!testPermission(sender)) return true; - if (args.length < 1 || args.length > 4) { - sender.sendMessage(ChatColor.RED + "Usage: " + usageMessage); - return false; - } - - Player player; - - if (args.length == 1 || args.length == 3) { - if (sender instanceof Player) { - player = (Player) sender; - } else { - sender.sendMessage("Please provide a player!"); - return true; - } - } else { - player = Bukkit.getPlayerExact(args[0]); - } - - if (player == null) { - sender.sendMessage("Player not found: " + args[0]); - return true; - } - - if (args.length < 3) { - Player target = Bukkit.getPlayerExact(args[args.length - 1]); - if (target == null) { - sender.sendMessage("Can't find player " + args[args.length - 1] + ". No tp."); - return true; - } - player.teleport(target, TeleportCause.COMMAND); - Command.broadcastCommandMessage(sender, "Teleported " + player.getDisplayName() + " to " + target.getDisplayName()); - } else if (player.getWorld() != null) { - Location playerLocation = player.getLocation(); - double x = getCoordinate(sender, playerLocation.getX(), args[args.length - 3]); - double y = getCoordinate(sender, playerLocation.getY(), args[args.length - 2], 0, 0); - double z = getCoordinate(sender, playerLocation.getZ(), args[args.length - 1]); - - if (x == MIN_COORD_MINUS_ONE || y == MIN_COORD_MINUS_ONE || z == MIN_COORD_MINUS_ONE) { - sender.sendMessage("Please provide a valid location!"); - return true; - } - - playerLocation.setX(x); - playerLocation.setY(y); - playerLocation.setZ(z); - - player.teleport(playerLocation, TeleportCause.COMMAND); - Command.broadcastCommandMessage(sender, String.format("Teleported %s to %.2f, %.2f, %.2f", player.getDisplayName(), x, y, z)); - } - return true; - } - - private double getCoordinate(CommandSender sender, double current, String input) { - return getCoordinate(sender, current, input, MIN_COORD, MAX_COORD); - } - - private double getCoordinate(CommandSender sender, double current, String input, int min, int max) { - boolean relative = input.startsWith("~"); - double result = relative ? current : 0; - - if (!relative || input.length() > 1) { - boolean exact = input.contains("."); - if (relative) input = input.substring(1); - - double testResult = getDouble(sender, input); - if (testResult == MIN_COORD_MINUS_ONE) { - return MIN_COORD_MINUS_ONE; - } - result += testResult; - - if (!exact && !relative) result += 0.5f; - } - if (min != 0 || max != 0) { - if (result < min) { - result = MIN_COORD_MINUS_ONE; - } - - if (result > max) { - result = MIN_COORD_MINUS_ONE; - } - } - - return result; - } - - @Override - public List tabComplete(CommandSender sender, String alias, String[] args) throws IllegalArgumentException { - Validate.notNull(sender, "Sender cannot be null"); - Validate.notNull(args, "Arguments cannot be null"); - Validate.notNull(alias, "Alias cannot be null"); - - if (args.length == 1 || args.length == 2) { - return super.tabComplete(sender, alias, args); - } - return ImmutableList.of(); - } -} diff --git a/NachoSpigot-API/src/main/java/org/bukkit/command/defaults/TellCommand.java b/NachoSpigot-API/src/main/java/org/bukkit/command/defaults/TellCommand.java deleted file mode 100644 index 2e5d811d4..000000000 --- a/NachoSpigot-API/src/main/java/org/bukkit/command/defaults/TellCommand.java +++ /dev/null @@ -1,61 +0,0 @@ -package org.bukkit.command.defaults; - -import java.util.Arrays; - -import org.bukkit.Bukkit; -import org.bukkit.ChatColor; -import org.bukkit.command.CommandSender; -import org.bukkit.entity.Player; - -@Deprecated -public class TellCommand extends VanillaCommand { - public TellCommand() { - super("tell"); - this.description = "Sends a private message to the given player"; - this.usageMessage = "/tell "; - this.setAliases(Arrays.asList(new String[] { "w", "msg" })); - this.setPermission("bukkit.command.tell"); - } - - @Override - public boolean execute(CommandSender sender, String currentAlias, String[] args) { - if (!testPermission(sender)) return true; - if (args.length < 2) { - sender.sendMessage(ChatColor.RED + "Usage: " + usageMessage); - return false; - } - - Player player = Bukkit.getPlayerExact(args[0]); - - // If a player is hidden from the sender pretend they are offline - if (player == null || (sender instanceof Player && !((Player) sender).canSee(player))) { - sender.sendMessage("There's no player by that name online."); - } else { - StringBuilder message = new StringBuilder(); - - for (int i = 1; i < args.length; i++) { - if (i > 1) message.append(" "); - message.append(args[i]); - } - - String result = ChatColor.GRAY + sender.getName() + " whispers " + message; - - sender.sendMessage("[" + sender.getName() + "->" + player.getName() + "] " + message); - player.sendMessage(result); - } - - return true; - } - - // Spigot Start - @Override - public java.util.List tabComplete(CommandSender sender, String alias, String[] args) throws IllegalArgumentException - { - if ( args.length == 0 ) - { - return super.tabComplete( sender, alias, args ); - } - return java.util.Collections.emptyList(); - } - // Spigot End -} diff --git a/NachoSpigot-API/src/main/java/org/bukkit/command/defaults/TestForCommand.java b/NachoSpigot-API/src/main/java/org/bukkit/command/defaults/TestForCommand.java deleted file mode 100644 index b5758a97f..000000000 --- a/NachoSpigot-API/src/main/java/org/bukkit/command/defaults/TestForCommand.java +++ /dev/null @@ -1,38 +0,0 @@ -package org.bukkit.command.defaults; - -import org.bukkit.ChatColor; -import org.bukkit.command.CommandSender; - -@Deprecated -public class TestForCommand extends VanillaCommand { - public TestForCommand() { - super("testfor"); - this.description = "Tests whether a specifed player is online"; - this.usageMessage = "/testfor "; - this.setPermission("bukkit.command.testfor"); - } - - @Override - public boolean execute(CommandSender sender, String currentAlias, String[] args) { - if (!testPermission(sender)) return true; - if (args.length < 1) { - sender.sendMessage(ChatColor.RED + "Usage: " + usageMessage); - return false; - } - - sender.sendMessage(ChatColor.RED + "/testfor is only usable by commandblocks with analog output."); - return true; - } - - // Spigot Start - @Override - public java.util.List tabComplete(CommandSender sender, String alias, String[] args) throws IllegalArgumentException - { - if ( args.length == 0 ) - { - return super.tabComplete( sender, alias, args ); - } - return java.util.Collections.emptyList(); - } - // Spigot End -} diff --git a/NachoSpigot-API/src/main/java/org/bukkit/command/defaults/TimeCommand.java b/NachoSpigot-API/src/main/java/org/bukkit/command/defaults/TimeCommand.java deleted file mode 100644 index edce68a25..000000000 --- a/NachoSpigot-API/src/main/java/org/bukkit/command/defaults/TimeCommand.java +++ /dev/null @@ -1,89 +0,0 @@ -package org.bukkit.command.defaults; - -import java.util.ArrayList; -import java.util.List; - -import org.apache.commons.lang.Validate; -import org.bukkit.Bukkit; -import org.bukkit.ChatColor; -import org.bukkit.World; -import org.bukkit.command.Command; -import org.bukkit.command.CommandSender; -import org.bukkit.util.StringUtil; - -import com.google.common.collect.ImmutableList; - -@Deprecated -public class TimeCommand extends VanillaCommand { - private static final List TABCOMPLETE_ADD_SET = ImmutableList.of("add", "set"); - private static final List TABCOMPLETE_DAY_NIGHT = ImmutableList.of("day", "night"); - - public TimeCommand() { - super("time"); - this.description = "Changes the time on each world"; - this.usageMessage = "/time set \n/time add "; - this.setPermission("bukkit.command.time.add;bukkit.command.time.set"); - } - - @Override - public boolean execute(CommandSender sender, String currentAlias, String[] args) { - if (args.length < 2) { - sender.sendMessage(ChatColor.RED + "Incorrect usage. Correct usage:\n" + usageMessage); - return false; - } - - int value; - - if (args[0].equals("set")) { - if (!sender.hasPermission("bukkit.command.time.set")) { - sender.sendMessage(ChatColor.RED + "You don't have permission to set the time"); - return true; - } - - if (args[1].equals("day")) { - value = 0; - } else if (args[1].equals("night")) { - value = 12500; - } else { - value = getInteger(sender, args[1], 0); - } - - for (World world : Bukkit.getWorlds()) { - world.setTime(value); - } - - Command.broadcastCommandMessage(sender, "Set time to " + value); - } else if (args[0].equals("add")) { - if (!sender.hasPermission("bukkit.command.time.add")) { - sender.sendMessage(ChatColor.RED + "You don't have permission to set the time"); - return true; - } - - value = getInteger(sender, args[1], 0); - - for (World world : Bukkit.getWorlds()) { - world.setFullTime(world.getFullTime() + value); - } - - Command.broadcastCommandMessage(sender, "Added " + value + " to time"); - } else { - sender.sendMessage("Unknown method. Usage: " + usageMessage); - } - - return true; - } - - @Override - public List tabComplete(CommandSender sender, String alias, String[] args) { - Validate.notNull(sender, "Sender cannot be null"); - Validate.notNull(args, "Arguments cannot be null"); - Validate.notNull(alias, "Alias cannot be null"); - - if (args.length == 1) { - return StringUtil.copyPartialMatches(args[0], TABCOMPLETE_ADD_SET, new ArrayList(TABCOMPLETE_ADD_SET.size())); - } else if (args.length == 2 && args[0].equalsIgnoreCase("set")) { - return StringUtil.copyPartialMatches(args[1], TABCOMPLETE_DAY_NIGHT, new ArrayList(TABCOMPLETE_DAY_NIGHT.size())); - } - return ImmutableList.of(); - } -} diff --git a/NachoSpigot-API/src/main/java/org/bukkit/command/defaults/ToggleDownfallCommand.java b/NachoSpigot-API/src/main/java/org/bukkit/command/defaults/ToggleDownfallCommand.java deleted file mode 100644 index 91268a6fd..000000000 --- a/NachoSpigot-API/src/main/java/org/bukkit/command/defaults/ToggleDownfallCommand.java +++ /dev/null @@ -1,57 +0,0 @@ -package org.bukkit.command.defaults; - -import java.util.List; - -import org.apache.commons.lang.Validate; -import org.bukkit.Bukkit; -import org.bukkit.ChatColor; -import org.bukkit.World; -import org.bukkit.command.Command; -import org.bukkit.command.CommandSender; -import org.bukkit.entity.Player; - -import com.google.common.collect.ImmutableList; - -@Deprecated -public class ToggleDownfallCommand extends VanillaCommand { - public ToggleDownfallCommand() { - super("toggledownfall"); - this.description = "Toggles rain on/off on a given world"; - this.usageMessage = "/toggledownfall"; - this.setPermission("bukkit.command.toggledownfall"); - } - - @Override - public boolean execute(CommandSender sender, String currentAlias, String[] args) { - if (!testPermission(sender)) return true; - - World world = null; - - if (args.length == 1) { - world = Bukkit.getWorld(args[0]); - - if (world == null) { - sender.sendMessage(ChatColor.RED + "No world exists with the name '" + args[0] + "'"); - return true; - } - } else if (sender instanceof Player) { - world = ((Player) sender).getWorld(); - } else { - world = Bukkit.getWorlds().get(0); - } - - Command.broadcastCommandMessage(sender, "Toggling downfall " + (world.hasStorm() ? "off" : "on") + " for world '" + world.getName() + "'"); - world.setStorm(!world.hasStorm()); - - return true; - } - - @Override - public List tabComplete(CommandSender sender, String alias, String[] args) throws IllegalArgumentException { - Validate.notNull(sender, "Sender cannot be null"); - Validate.notNull(args, "Arguments cannot be null"); - Validate.notNull(alias, "Alias cannot be null"); - - return ImmutableList.of(); - } -} diff --git a/NachoSpigot-API/src/main/java/org/bukkit/command/defaults/WeatherCommand.java b/NachoSpigot-API/src/main/java/org/bukkit/command/defaults/WeatherCommand.java deleted file mode 100644 index b86a50830..000000000 --- a/NachoSpigot-API/src/main/java/org/bukkit/command/defaults/WeatherCommand.java +++ /dev/null @@ -1,74 +0,0 @@ -package org.bukkit.command.defaults; - -import com.google.common.collect.ImmutableList; -import org.apache.commons.lang.Validate; -import org.bukkit.Bukkit; -import org.bukkit.ChatColor; -import org.bukkit.World; -import org.bukkit.command.Command; -import org.bukkit.command.CommandSender; -import org.bukkit.util.StringUtil; - -import java.util.ArrayList; -import java.util.List; -import java.util.Random; - -@Deprecated -public class WeatherCommand extends VanillaCommand { - private static final List WEATHER_TYPES = ImmutableList.of("clear", "rain", "thunder"); - - public WeatherCommand() { - super("weather"); - this.description = "Changes the weather"; - this.usageMessage = "/weather [duration in seconds]"; - this.setPermission("bukkit.command.weather"); - } - - @Override - public boolean execute(CommandSender sender, String currentAlias, String[] args) { - if (!testPermission(sender)) return true; - if (args.length == 0) { - sender.sendMessage(ChatColor.RED + "Usage: " + usageMessage); - return false; - } - - int duration = (300 + new Random().nextInt(600)) * 20; - if (args.length >= 2) { - duration = getInteger(sender, args[1], 1, 1000000) * 20; - } - - World world = Bukkit.getWorlds().get(0); - - world.setWeatherDuration(duration); - world.setThunderDuration(duration); - - if ("clear".equalsIgnoreCase(args[0])) { - world.setStorm(false); - world.setThundering(false); - Command.broadcastCommandMessage(sender, "Changed weather to clear for " + (duration / 20) + " seconds."); - } else if ("rain".equalsIgnoreCase(args[0])) { - world.setStorm(true); - world.setThundering(false); - Command.broadcastCommandMessage(sender, "Changed weather to rainy for " + (duration / 20) + " seconds."); - } else if ("thunder".equalsIgnoreCase(args[0])) { - world.setStorm(true); - world.setThundering(true); - Command.broadcastCommandMessage(sender, "Changed weather to thundering " + (duration / 20) + " seconds."); - } - - return true; - } - - @Override - public List tabComplete(CommandSender sender, String alias, String[] args) { - Validate.notNull(sender, "Sender cannot be null"); - Validate.notNull(args, "Arguments cannot be null"); - Validate.notNull(alias, "Alias cannot be null"); - - if (args.length == 1) { - return StringUtil.copyPartialMatches(args[0], WEATHER_TYPES, new ArrayList(WEATHER_TYPES.size())); - } - - return ImmutableList.of(); - } -} diff --git a/NachoSpigot-API/src/main/java/org/bukkit/command/defaults/WhitelistCommand.java b/NachoSpigot-API/src/main/java/org/bukkit/command/defaults/WhitelistCommand.java deleted file mode 100644 index 855f5600f..000000000 --- a/NachoSpigot-API/src/main/java/org/bukkit/command/defaults/WhitelistCommand.java +++ /dev/null @@ -1,128 +0,0 @@ -package org.bukkit.command.defaults; - -import java.util.ArrayList; -import java.util.List; - -import org.apache.commons.lang.Validate; -import org.bukkit.Bukkit; -import org.bukkit.ChatColor; -import org.bukkit.OfflinePlayer; -import org.bukkit.command.Command; -import org.bukkit.command.CommandSender; -import org.bukkit.util.StringUtil; - -import com.google.common.collect.ImmutableList; - -@Deprecated -public class WhitelistCommand extends VanillaCommand { - private static final List WHITELIST_SUBCOMMANDS = ImmutableList.of("add", "remove", "on", "off", "list", "reload"); - - public WhitelistCommand() { - super("whitelist"); - this.description = "Manages the list of players allowed to use this server"; - this.usageMessage = "/whitelist (add|remove) \n/whitelist (on|off|list|reload)"; - this.setPermission("bukkit.command.whitelist.reload;bukkit.command.whitelist.enable;bukkit.command.whitelist.disable;bukkit.command.whitelist.list;bukkit.command.whitelist.add;bukkit.command.whitelist.remove"); - } - - @Override - public boolean execute(CommandSender sender, String currentAlias, String[] args) { - if (!testPermission(sender)) return true; - - if (args.length == 1) { - if (args[0].equalsIgnoreCase("reload")) { - if (badPerm(sender, "reload")) return true; - - Bukkit.reloadWhitelist(); - Command.broadcastCommandMessage(sender, "Reloaded white-list from file"); - return true; - } else if (args[0].equalsIgnoreCase("on")) { - if (badPerm(sender, "enable")) return true; - - Bukkit.setWhitelist(true); - Command.broadcastCommandMessage(sender, "Turned on white-listing"); - return true; - } else if (args[0].equalsIgnoreCase("off")) { - if (badPerm(sender, "disable")) return true; - - Bukkit.setWhitelist(false); - Command.broadcastCommandMessage(sender, "Turned off white-listing"); - return true; - } else if (args[0].equalsIgnoreCase("list")) { - if (badPerm(sender, "list")) return true; - - StringBuilder result = new StringBuilder(); - - for (OfflinePlayer player : Bukkit.getWhitelistedPlayers()) { - if (result.length() > 0) { - result.append(", "); - } - - result.append(player.getName()); - } - - sender.sendMessage("White-listed players: " + result.toString()); - return true; - } - } else if (args.length == 2) { - if (args[0].equalsIgnoreCase("add")) { - if (badPerm(sender, "add")) return true; - - Bukkit.getOfflinePlayer(args[1]).setWhitelisted(true); - - Command.broadcastCommandMessage(sender, "Added " + args[1] + " to white-list"); - return true; - } else if (args[0].equalsIgnoreCase("remove")) { - if (badPerm(sender, "remove")) return true; - - Bukkit.getOfflinePlayer(args[1]).setWhitelisted(false); - - Command.broadcastCommandMessage(sender, "Removed " + args[1] + " from white-list"); - return true; - } - } - - sender.sendMessage(ChatColor.RED + "Correct command usage:\n" + usageMessage); - return false; - } - - private boolean badPerm(CommandSender sender, String perm) { - if (!sender.hasPermission("bukkit.command.whitelist." + perm)) { - sender.sendMessage(ChatColor.RED + "You do not have permission to perform this action."); - return true; - } - - return false; - } - - @Override - public List tabComplete(CommandSender sender, String alias, String[] args) { - Validate.notNull(sender, "Sender cannot be null"); - Validate.notNull(args, "Arguments cannot be null"); - Validate.notNull(alias, "Alias cannot be null"); - - if (args.length == 1) { - return StringUtil.copyPartialMatches(args[0], WHITELIST_SUBCOMMANDS, new ArrayList(WHITELIST_SUBCOMMANDS.size())); - } else if (args.length == 2) { - if (args[0].equalsIgnoreCase("add")) { - List completions = new ArrayList(); - for (OfflinePlayer player : Bukkit.getOnlinePlayers()) { // Spigot - well maybe sometimes you haven't turned the whitelist on just yet. - String name = player.getName(); - if (StringUtil.startsWithIgnoreCase(name, args[1]) && !player.isWhitelisted()) { - completions.add(name); - } - } - return completions; - } else if (args[0].equalsIgnoreCase("remove")) { - List completions = new ArrayList(); - for (OfflinePlayer player : Bukkit.getWhitelistedPlayers()) { - String name = player.getName(); - if (StringUtil.startsWithIgnoreCase(name, args[1])) { - completions.add(name); - } - } - return completions; - } - } - return ImmutableList.of(); - } -} diff --git a/NachoSpigot-API/src/main/java/org/bukkit/enchantments/Enchantment.java b/NachoSpigot-API/src/main/java/org/bukkit/enchantments/Enchantment.java index c82d67998..d193444da 100644 --- a/NachoSpigot-API/src/main/java/org/bukkit/enchantments/Enchantment.java +++ b/NachoSpigot-API/src/main/java/org/bukkit/enchantments/Enchantment.java @@ -3,7 +3,6 @@ import java.util.HashMap; import java.util.Map; -import org.bukkit.command.defaults.EnchantCommand; import org.bukkit.inventory.ItemStack; /** @@ -261,7 +260,6 @@ public static boolean isAcceptingRegistrations() { */ public static void stopAcceptingRegistrations() { acceptingNew = false; - EnchantCommand.buildEnchantments(); } /**