From 158c7b34653f9a4d2ae69bf17251af5df8251ed2 Mon Sep 17 00:00:00 2001 From: Poslovitch Date: Sun, 30 Jul 2017 19:57:49 +0200 Subject: [PATCH] Started a refactoring for the commands --- .../us/tastybento/bskyblock/BSkyBlock.java | 21 +- .../bskyblock/commands/AdminCommand.java | 23 +- .../bskyblock/commands/BSBCommand.java | 92 +++--- .../bskyblock/commands/IslandCommand.java | 293 +++++++++--------- .../bskyblock/config/BSBLocale.java | 7 +- 5 files changed, 222 insertions(+), 214 deletions(-) diff --git a/src/main/java/us/tastybento/bskyblock/BSkyBlock.java b/src/main/java/us/tastybento/bskyblock/BSkyBlock.java index 0b510d0ab..08c796741 100755 --- a/src/main/java/us/tastybento/bskyblock/BSkyBlock.java +++ b/src/main/java/us/tastybento/bskyblock/BSkyBlock.java @@ -1,19 +1,12 @@ package us.tastybento.bskyblock; -import java.io.File; -import java.io.FilenameFilter; -import java.net.MalformedURLException; -import java.util.HashMap; -import java.util.Locale; -import java.util.UUID; - import org.bukkit.Material; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; import org.bukkit.plugin.PluginManager; import org.bukkit.plugin.java.JavaPlugin; - +import us.tastybento.bskyblock.commands.AdminCommand; import us.tastybento.bskyblock.commands.IslandCommand; import us.tastybento.bskyblock.config.BSBLocale; import us.tastybento.bskyblock.config.PluginConfig; @@ -33,6 +26,13 @@ import us.tastybento.bskyblock.schematics.SchematicsMgr; import us.tastybento.bskyblock.util.FileLister; import us.tastybento.bskyblock.util.VaultHelper; +import java.io.File; +import java.io.FilenameFilter; +import java.net.MalformedURLException; +import java.util.HashMap; +import java.util.Locale; +import java.util.UUID; + /** * Main BSkyBlock class - provides an island minigame in the sky * @author Tastybento @@ -107,11 +107,12 @@ public class BSkyBlock extends JavaPlugin{ }; schematicsManager = new SchematicsMgr(plugin); - getCommand("island").setExecutor(new IslandCommand(plugin)); - Settings.defaultLanguage = "en-US"; loadLocales(); + new IslandCommand(BSkyBlock.this); + new AdminCommand(BSkyBlock.this); + // Register Listeners registerListeners(); /* diff --git a/src/main/java/us/tastybento/bskyblock/commands/AdminCommand.java b/src/main/java/us/tastybento/bskyblock/commands/AdminCommand.java index e07efe58b..4db983e0b 100755 --- a/src/main/java/us/tastybento/bskyblock/commands/AdminCommand.java +++ b/src/main/java/us/tastybento/bskyblock/commands/AdminCommand.java @@ -1,17 +1,20 @@ package us.tastybento.bskyblock.commands; -import java.util.List; - import org.bukkit.command.CommandSender; - import us.tastybento.bskyblock.BSkyBlock; +import us.tastybento.bskyblock.config.Settings; + +import java.util.List; public class AdminCommand extends BSBCommand{ BSkyBlock plugin; public AdminCommand(BSkyBlock plugin) { - super(plugin, true); + super(plugin, Settings.ADMINCOMMAND, true); + plugin.getCommand(Settings.ADMINCOMMAND).setExecutor(this); + plugin.getCommand(Settings.ADMINCOMMAND).setTabCompleter(this); + this.plugin = plugin; } @Override @@ -20,24 +23,24 @@ public class AdminCommand extends BSBCommand{ registerArgument(new String[] {"delete"}, new CommandArgumentHandler() { @Override - public boolean canExecute(CommandSender sender, String label, String[] args) { + public boolean canExecute(CommandSender sender, String[] args) { // TODO Auto-generated method stub return true; } @Override - public void onExecute(CommandSender sender, String label, String[] args) { + public void onExecute(CommandSender sender, String[] args) { } @Override - public List onTabComplete(CommandSender sender, String label, String[] args) { + public List onTabComplete(CommandSender sender, String[] args) { // TODO Auto-generated method stub return null; } @Override - public String[] getHelp(CommandSender sender, String label){ + public String[] getHelp(CommandSender sender){ return new String[] {null, plugin.getLocale(sender).get("help.admin.delete")}; } }); @@ -45,13 +48,13 @@ public class AdminCommand extends BSBCommand{ } @Override - public boolean canExecute(CommandSender sender, String label) { + public boolean canExecute(CommandSender sender) { // TODO Auto-generated method stub return true; } @Override - public void onExecuteDefault(CommandSender sender, String label, String[] args) { + public void onExecuteDefault(CommandSender sender, String[] args) { } diff --git a/src/main/java/us/tastybento/bskyblock/commands/BSBCommand.java b/src/main/java/us/tastybento/bskyblock/commands/BSBCommand.java index b83685b47..470132caf 100644 --- a/src/main/java/us/tastybento/bskyblock/commands/BSBCommand.java +++ b/src/main/java/us/tastybento/bskyblock/commands/BSBCommand.java @@ -1,54 +1,58 @@ package us.tastybento.bskyblock.commands; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Map.Entry; - import org.bukkit.command.Command; import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandSender; import org.bukkit.command.TabCompleter; - import us.tastybento.bskyblock.BSkyBlock; +import java.util.*; +import java.util.Map.Entry; + /** - * Abstract class that handles commands and tabs. It makes the commands code modular - * and allow addons to add their own arguments. + * Abstract class that handles commands and tab completion. + * + * It makes the commands code modular and allow addons to add their own arguments or even remove/edit existing ones. * * @author Poslovitch */ public abstract class BSBCommand implements CommandExecutor, TabCompleter{ private Map arguments; - private boolean help; - protected BSBCommand(BSkyBlock plugin, boolean help){ + private String command; + + /** Whether the command has an help list. */ + private boolean help = true; + /** Max subcommands per help page. */ + private static final int MAX_PER_PAGE = 7; // 10 seems to be the maximum acceptable, 7 is a good number. + + protected BSBCommand(BSkyBlock plugin, String command, boolean help){ + this.command = command; + arguments = new HashMap(); this.help = help; - // Register a help argument if needed - if(help){ + // Register the help argument if needed + if(help) { registerArgument(new String[] {"help", "?"}, new CommandArgumentHandler() { @Override - public boolean canExecute(CommandSender sender, String label, String[] args) { + public boolean canExecute(CommandSender sender, String[] args) { return true; // If the player can execute the command, he can receive help } @Override - public void onExecute(CommandSender sender, String label, String[] args) { - // TODO send help + public void onExecute(CommandSender sender, String[] args) { + sender.sendMessage(plugin.getLocale(sender).get("commands." + command + ".help-header")); } @Override - public List onTabComplete(CommandSender sender, String label, String[] args) { + public List onTabComplete(CommandSender sender, String[] args) { return null; // Doesn't have options for tab-completion } @Override - public String[] getHelp(CommandSender sender, String label) { + public String[] getHelp(CommandSender sender) { return null; // Obviously, don't send any help message. } @@ -60,39 +64,40 @@ public abstract class BSBCommand implements CommandExecutor, TabCompleter{ } /** - * Setup the command arguments + * Registers the command-specific arguments. + * + * This method is called when BSBCommand has been successfully constructed. */ public abstract void setup(); /** - * Check if the sender can use the command + * Asks if the sender can use the command + * * @param sender - * @param label * @return if the sender can use the command */ - public abstract boolean canExecute(CommandSender sender, String label); + public abstract boolean canExecute(CommandSender sender); /** * This code is executed when no arguments is specified for the command * @param sender - * @param label * @param args */ - public abstract void onExecuteDefault(CommandSender sender, String label, String[] args); + public abstract void onExecuteDefault(CommandSender sender, String[] args); @Override public boolean onCommand(CommandSender sender, Command command, String label, String[] args){ - if(this.canExecute(sender, label)){ + if(this.canExecute(sender)){ if(args.length >= 1){ - if(arguments.containsKey(args[0]) && arguments.get(args[0]).canExecute(sender, label, args)){ - arguments.get(args[0]).onExecute(sender, label, args); + if(arguments.containsKey(args[0]) && arguments.get(args[0]).canExecute(sender, args)){ + arguments.get(args[0]).onExecute(sender, args); } else if(help) { - arguments.get("?").onExecute(sender, label, args); + arguments.get("?").onExecute(sender, args); } else { - this.onExecuteDefault(sender, label, args); + this.onExecuteDefault(sender, args); } } else { - this.onExecuteDefault(sender, label, args); + this.onExecuteDefault(sender, args); } } return true; @@ -101,60 +106,59 @@ public abstract class BSBCommand implements CommandExecutor, TabCompleter{ @Override public List onTabComplete(CommandSender sender, Command command, String label, String[] args){ List options = new ArrayList(); - if(this.canExecute(sender, label)){ + if(this.canExecute(sender)){ if(args.length <= 1){ // Go through every argument, check if player can use it and if so, add it in tab options for(Entry entry : arguments.entrySet()){ - if(entry.getValue().canExecute(sender, label, args)){ + if(entry.getValue().canExecute(sender, args)){ options.add(entry.getKey()); } } } else { // If player can execute the argument, get its tab-completer options - if(getArgumentHandler(args[0]) != null && getArgumentHandler(args[0]).canExecute(sender, label, args) - && getArgumentHandler(args[0]).onTabComplete(sender, label, args) != null){ - options.addAll(getArgumentHandler(args[0]).onTabComplete(sender, label, args)); + if(getArgumentHandler(args[0]) != null && getArgumentHandler(args[0]).canExecute(sender, args) + && getArgumentHandler(args[0]).onTabComplete(sender, args) != null){ + options.addAll(getArgumentHandler(args[0]).onTabComplete(sender, args)); } } } return options; } + /** + * Defines the behavior of an argument and its aliases. + */ public abstract class CommandArgumentHandler{ /** * Check if the sender can use the argument * @param sender - * @param label * @param args * @return if the sender can use the argument */ - public abstract boolean canExecute(CommandSender sender, String label, String[] args); + public abstract boolean canExecute(CommandSender sender, String[] args); /** * Code to execute for this argument * @param sender - * @param label * @param args */ - public abstract void onExecute(CommandSender sender, String label, String[] args); + public abstract void onExecute(CommandSender sender, String[] args); /** * Request a list of tab-completion options with the argument * @param sender - * @param label * @param args * @return the list of options */ - public abstract List onTabComplete(CommandSender sender, String label, String[] args); + public abstract List onTabComplete(CommandSender sender, String[] args); /** * Get help information * new String[] {arguments, description}; * @param sender - * @param label * @return the help information */ - public abstract String[] getHelp(CommandSender sender, String label); + public abstract String[] getHelp(CommandSender sender); } public void registerArgument(String[] args, CommandArgumentHandler handler){ diff --git a/src/main/java/us/tastybento/bskyblock/commands/IslandCommand.java b/src/main/java/us/tastybento/bskyblock/commands/IslandCommand.java index 800d69e6a..a507a5f36 100755 --- a/src/main/java/us/tastybento/bskyblock/commands/IslandCommand.java +++ b/src/main/java/us/tastybento/bskyblock/commands/IslandCommand.java @@ -1,11 +1,8 @@ package us.tastybento.bskyblock.commands; -import java.util.List; - import org.bukkit.ChatColor; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; - import us.tastybento.bskyblock.BSkyBlock; import us.tastybento.bskyblock.config.Settings; import us.tastybento.bskyblock.database.objects.Island; @@ -13,6 +10,8 @@ import us.tastybento.bskyblock.schematics.Schematic; import us.tastybento.bskyblock.util.Util; import us.tastybento.bskyblock.util.VaultHelper; +import java.util.List; + /** * "/island" command * @@ -23,12 +22,14 @@ public class IslandCommand extends BSBCommand{ private BSkyBlock plugin; public IslandCommand(BSkyBlock plugin) { - super(plugin, true); + super(plugin, Settings.ISLANDCOMMAND, true); + plugin.getCommand(Settings.ISLANDCOMMAND).setExecutor(this); + plugin.getCommand(Settings.ISLANDCOMMAND).setTabCompleter(this); this.plugin = plugin; } @Override - public boolean canExecute(CommandSender sender, String label) { + public boolean canExecute(CommandSender sender) { if(!(sender instanceof Player)){ Util.sendMessage(sender, plugin.getLocale(sender).get("general.errors.use-in-game")); return false; @@ -45,7 +46,7 @@ public class IslandCommand extends BSBCommand{ } @Override - public void onExecuteDefault(CommandSender sender, String label, String[] args) { + public void onExecuteDefault(CommandSender sender, String[] args) { if (sender instanceof Player) { Player player = (Player)sender; if (plugin.getIslands().hasIsland(player.getUniqueId())) { @@ -66,12 +67,12 @@ public class IslandCommand extends BSBCommand{ registerArgument(new String[] {"about"}, new CommandArgumentHandler() { @Override - public boolean canExecute(CommandSender sender, String label, String[] args) { + public boolean canExecute(CommandSender sender, String[] args) { return true; } @Override - public void onExecute(CommandSender sender, String label, String[] args) { + public void onExecute(CommandSender sender, String[] args) { Util.sendMessage(sender, ChatColor.GOLD + "About " + ChatColor.GREEN + plugin.getDescription().getName() + ChatColor.GOLD + " v" + ChatColor.AQUA + plugin.getDescription().getVersion() + ChatColor.GOLD + ":"); Util.sendMessage(sender, ChatColor.GOLD + "Copyright (c) 2017 tastybento, Poslovitch"); Util.sendMessage(sender, ChatColor.GOLD + "All rights reserved."); @@ -104,12 +105,12 @@ public class IslandCommand extends BSBCommand{ } @Override - public List onTabComplete(CommandSender sender, String label, String[] args) { + public List onTabComplete(CommandSender sender, String[] args) { return null; } @Override - public String[] getHelp(CommandSender sender, String label){ + public String[] getHelp(CommandSender sender){ return null; } }); @@ -118,13 +119,13 @@ public class IslandCommand extends BSBCommand{ registerArgument(new String[] {"go", "home", "h"}, new CommandArgumentHandler() { @Override - public boolean canExecute(CommandSender sender, String label, String[] args) { + public boolean canExecute(CommandSender sender, String[] args) { return true; } @Override - public void onExecute(CommandSender sender, String label, String[] args) { + public void onExecute(CommandSender sender, String[] args) { if (sender instanceof Player) { Player player = (Player)sender; if (plugin.getIslands().hasIsland(player.getUniqueId())) { @@ -134,13 +135,13 @@ public class IslandCommand extends BSBCommand{ } @Override - public List onTabComplete(CommandSender sender, String label, String[] args) { + public List onTabComplete(CommandSender sender, String[] args) { return null; } @Override - public String[] getHelp(CommandSender sender, String label){ + public String[] getHelp(CommandSender sender){ // TODO check if multiple homes if(VaultHelper.hasPerm((Player) sender, "todo")) return new String[] {"[1-x]", plugin.getLocale(sender).get("help.island.go-homes")}; return new String[] {null, plugin.getLocale(sender).get("help.island.go")}; @@ -151,24 +152,24 @@ public class IslandCommand extends BSBCommand{ registerArgument(new String[] {"spawn"}, new CommandArgumentHandler() { @Override - public boolean canExecute(CommandSender sender, String label, String[] args) { + public boolean canExecute(CommandSender sender, String[] args) { return false; } @Override - public void onExecute(CommandSender sender, String label, String[] args) { + public void onExecute(CommandSender sender, String[] args) { } @Override - public List onTabComplete(CommandSender sender, String label, String[] args) { + public List onTabComplete(CommandSender sender, String[] args) { return null; } @Override - public String[] getHelp(CommandSender sender, String label){ + public String[] getHelp(CommandSender sender){ return new String[] {null, plugin.getLocale(sender).get("help.island.spawn")}; } }); @@ -177,13 +178,13 @@ public class IslandCommand extends BSBCommand{ registerArgument(new String[] {"create", "auto"}, new CommandArgumentHandler() { @Override - public boolean canExecute(CommandSender sender, String label, String[] args) { + public boolean canExecute(CommandSender sender, String[] args) { return true; } @Override - public void onExecute(CommandSender sender, String label, String[] args) { + public void onExecute(CommandSender sender, String[] args) { if (sender instanceof Player) { Player player = (Player)sender; if (!plugin.getIslands().hasIsland(player.getUniqueId())) { @@ -195,13 +196,13 @@ public class IslandCommand extends BSBCommand{ } @Override - public List onTabComplete(CommandSender sender, String label, String[] args) { + public List onTabComplete(CommandSender sender, String[] args) { return null; } @Override - public String[] getHelp(CommandSender sender, String label){ + public String[] getHelp(CommandSender sender){ return new String[] {"[schematic]", plugin.getLocale(sender).get("help.island.create")}; } }); @@ -210,25 +211,25 @@ public class IslandCommand extends BSBCommand{ registerArgument(new String[] {"info"}, new CommandArgumentHandler() { @Override - public boolean canExecute(CommandSender sender, String label, String[] args) { + public boolean canExecute(CommandSender sender, String[] args) { return false; } @Override - public void onExecute(CommandSender sender, String label, String[] args) { + public void onExecute(CommandSender sender, String[] args) { } @Override - public List onTabComplete(CommandSender sender, String label, String[] args) { + public List onTabComplete(CommandSender sender, String[] args) { return null; } @Override - public String[] getHelp(CommandSender sender, String label){ + public String[] getHelp(CommandSender sender){ return new String[] {"[player]", plugin.getLocale(sender).get("help.island.info")}; } }); @@ -237,25 +238,25 @@ public class IslandCommand extends BSBCommand{ registerArgument(new String[] {"controlpanel", "cp"}, new CommandArgumentHandler() { @Override - public boolean canExecute(CommandSender sender, String label, String[] args) { + public boolean canExecute(CommandSender sender, String[] args) { return false; } @Override - public void onExecute(CommandSender sender, String label, String[] args) { + public void onExecute(CommandSender sender, String[] args) { } @Override - public List onTabComplete(CommandSender sender, String label, String[] args) { + public List onTabComplete(CommandSender sender, String[] args) { return null; } @Override - public String[] getHelp(CommandSender sender, String label){ + public String[] getHelp(CommandSender sender){ return new String[] {"[on/off]", plugin.getLocale(sender).get("help.island.control-panel")}; } }); @@ -264,13 +265,13 @@ public class IslandCommand extends BSBCommand{ registerArgument(new String[] {"reset", "restart"}, new CommandArgumentHandler() { @Override - public boolean canExecute(CommandSender sender, String label, String[] args) { + public boolean canExecute(CommandSender sender, String[] args) { return true; } @Override - public void onExecute(CommandSender sender, String label, String[] args) { + public void onExecute(CommandSender sender, String[] args) { if (!(sender instanceof Player)) { Util.sendMessage(sender, plugin.getLocale().get("error.useInGame")); @@ -294,13 +295,13 @@ public class IslandCommand extends BSBCommand{ } @Override - public List onTabComplete(CommandSender sender, String label, String[] args) { + public List onTabComplete(CommandSender sender, String[] args) { return null; } @Override - public String[] getHelp(CommandSender sender, String label){ + public String[] getHelp(CommandSender sender){ return new String[] {null, plugin.getLocale(sender).get("help.island.reset")}; } }); @@ -309,25 +310,25 @@ public class IslandCommand extends BSBCommand{ registerArgument(new String[] {"sethome"}, new CommandArgumentHandler() { @Override - public boolean canExecute(CommandSender sender, String label, String[] args) { + public boolean canExecute(CommandSender sender, String[] args) { return false; } @Override - public void onExecute(CommandSender sender, String label, String[] args) { + public void onExecute(CommandSender sender, String[] args) { } @Override - public List onTabComplete(CommandSender sender, String label, String[] args) { + public List onTabComplete(CommandSender sender, String[] args) { return null; } @Override - public String[] getHelp(CommandSender sender, String label){ + public String[] getHelp(CommandSender sender){ return new String[] {null, plugin.getLocale(sender).get("help.island.sethome")}; } }); @@ -336,7 +337,7 @@ public class IslandCommand extends BSBCommand{ registerArgument(new String[] {"name"}, new CommandArgumentHandler() { @Override - public boolean canExecute(CommandSender sender, String label, String[] args) { + public boolean canExecute(CommandSender sender, String[] args) { Player player = (Player) sender; if(!VaultHelper.hasPerm(player, Settings.PERMPREFIX + "island.name")){ @@ -358,7 +359,7 @@ public class IslandCommand extends BSBCommand{ } @Override - public void onExecute(CommandSender sender, String label, String[] args) { + public void onExecute(CommandSender sender, String[] args) { Player player = (Player) sender; // Explain command @@ -391,12 +392,12 @@ public class IslandCommand extends BSBCommand{ } @Override - public List onTabComplete(CommandSender sender, String label, String[] args) { + public List onTabComplete(CommandSender sender, String[] args) { return null; } @Override - public String[] getHelp(CommandSender sender, String label){ + public String[] getHelp(CommandSender sender){ return new String[] {"", plugin.getLocale(sender).get("help.island.name")}; } }); @@ -405,7 +406,7 @@ public class IslandCommand extends BSBCommand{ registerArgument(new String[] {"resetname"}, new CommandArgumentHandler() { @Override - public boolean canExecute(CommandSender sender, String label, String[] args) { + public boolean canExecute(CommandSender sender, String[] args) { Player player = (Player) sender; if(!VaultHelper.hasPerm(player, Settings.PERMPREFIX + "island.name")){ @@ -427,7 +428,7 @@ public class IslandCommand extends BSBCommand{ } @Override - public void onExecute(CommandSender sender, String label, String[] args) { + public void onExecute(CommandSender sender, String[] args) { Player player = (Player) sender; // Resets the island name @@ -436,12 +437,12 @@ public class IslandCommand extends BSBCommand{ } @Override - public List onTabComplete(CommandSender sender, String label, String[] args) { + public List onTabComplete(CommandSender sender, String[] args) { return null; } @Override - public String[] getHelp(CommandSender sender, String label){ + public String[] getHelp(CommandSender sender){ return new String[] {null, plugin.getLocale(sender).get("help.island.resetname")}; } }); @@ -450,25 +451,25 @@ public class IslandCommand extends BSBCommand{ registerArgument(new String[] {"limits"}, new CommandArgumentHandler() { @Override - public boolean canExecute(CommandSender sender, String label, String[] args) { + public boolean canExecute(CommandSender sender, String[] args) { return false; } @Override - public void onExecute(CommandSender sender, String label, String[] args) { + public void onExecute(CommandSender sender, String[] args) { } @Override - public List onTabComplete(CommandSender sender, String label, String[] args) { + public List onTabComplete(CommandSender sender, String[] args) { return null; } @Override - public String[] getHelp(CommandSender sender, String label){ + public String[] getHelp(CommandSender sender){ return new String[] {null, plugin.getLocale(sender).get("help.island.limits")}; } }); @@ -477,25 +478,25 @@ public class IslandCommand extends BSBCommand{ registerArgument(new String[] {"team"}, new CommandArgumentHandler() { @Override - public boolean canExecute(CommandSender sender, String label, String[] args) { + public boolean canExecute(CommandSender sender, String[] args) { return false; } @Override - public void onExecute(CommandSender sender, String label, String[] args) { + public void onExecute(CommandSender sender, String[] args) { } @Override - public List onTabComplete(CommandSender sender, String label, String[] args) { + public List onTabComplete(CommandSender sender, String[] args) { return null; } @Override - public String[] getHelp(CommandSender sender, String label){ + public String[] getHelp(CommandSender sender){ return new String[] {null, plugin.getLocale(sender).get("help.island.team")}; } }); @@ -504,25 +505,25 @@ public class IslandCommand extends BSBCommand{ registerArgument(new String[] {"invite"}, new CommandArgumentHandler() { @Override - public boolean canExecute(CommandSender sender, String label, String[] args) { + public boolean canExecute(CommandSender sender, String[] args) { return false; } @Override - public void onExecute(CommandSender sender, String label, String[] args) { + public void onExecute(CommandSender sender, String[] args) { } @Override - public List onTabComplete(CommandSender sender, String label, String[] args) { + public List onTabComplete(CommandSender sender, String[] args) { return null; } @Override - public String[] getHelp(CommandSender sender, String label){ + public String[] getHelp(CommandSender sender){ return new String[] {"", plugin.getLocale(sender).get("help.island.invite")}; } }); @@ -531,25 +532,25 @@ public class IslandCommand extends BSBCommand{ registerArgument(new String[] {"uninvite"}, new CommandArgumentHandler() { @Override - public boolean canExecute(CommandSender sender, String label, String[] args) { + public boolean canExecute(CommandSender sender, String[] args) { return false; } @Override - public void onExecute(CommandSender sender, String label, String[] args) { + public void onExecute(CommandSender sender, String[] args) { } @Override - public List onTabComplete(CommandSender sender, String label, String[] args) { + public List onTabComplete(CommandSender sender, String[] args) { return null; } @Override - public String[] getHelp(CommandSender sender, String label){ + public String[] getHelp(CommandSender sender){ return new String[] {"", plugin.getLocale(sender).get("help.island.uninvite")}; } }); @@ -558,25 +559,25 @@ public class IslandCommand extends BSBCommand{ registerArgument(new String[] {"leave"}, new CommandArgumentHandler() { @Override - public boolean canExecute(CommandSender sender, String label, String[] args) { + public boolean canExecute(CommandSender sender, String[] args) { return false; } @Override - public void onExecute(CommandSender sender, String label, String[] args) { + public void onExecute(CommandSender sender, String[] args) { } @Override - public List onTabComplete(CommandSender sender, String label, String[] args) { + public List onTabComplete(CommandSender sender, String[] args) { return null; } @Override - public String[] getHelp(CommandSender sender, String label){ + public String[] getHelp(CommandSender sender){ return new String[] {null, plugin.getLocale(sender).get("help.island.leave")}; } }); @@ -585,25 +586,25 @@ public class IslandCommand extends BSBCommand{ registerArgument(new String[] {"kick"}, new CommandArgumentHandler() { @Override - public boolean canExecute(CommandSender sender, String label, String[] args) { + public boolean canExecute(CommandSender sender, String[] args) { return false; } @Override - public void onExecute(CommandSender sender, String label, String[] args) { + public void onExecute(CommandSender sender, String[] args) { } @Override - public List onTabComplete(CommandSender sender, String label, String[] args) { + public List onTabComplete(CommandSender sender, String[] args) { return null; } @Override - public String[] getHelp(CommandSender sender, String label){ + public String[] getHelp(CommandSender sender){ return new String[] {"", plugin.getLocale(sender).get("help.island.kick")}; } }); @@ -612,25 +613,25 @@ public class IslandCommand extends BSBCommand{ registerArgument(new String[] {"accept"}, new CommandArgumentHandler() { @Override - public boolean canExecute(CommandSender sender, String label, String[] args) { + public boolean canExecute(CommandSender sender, String[] args) { return false; } @Override - public void onExecute(CommandSender sender, String label, String[] args) { + public void onExecute(CommandSender sender, String[] args) { } @Override - public List onTabComplete(CommandSender sender, String label, String[] args) { + public List onTabComplete(CommandSender sender, String[] args) { return null; } @Override - public String[] getHelp(CommandSender sender, String label){ + public String[] getHelp(CommandSender sender){ return new String[] {"[player]", plugin.getLocale(sender).get("help.island.accept")}; } }); @@ -639,25 +640,25 @@ public class IslandCommand extends BSBCommand{ registerArgument(new String[] {"reject"}, new CommandArgumentHandler() { @Override - public boolean canExecute(CommandSender sender, String label, String[] args) { + public boolean canExecute(CommandSender sender, String[] args) { return false; } @Override - public void onExecute(CommandSender sender, String label, String[] args) { + public void onExecute(CommandSender sender, String[] args) { } @Override - public List onTabComplete(CommandSender sender, String label, String[] args) { + public List onTabComplete(CommandSender sender, String[] args) { return null; } @Override - public String[] getHelp(CommandSender sender, String label){ + public String[] getHelp(CommandSender sender){ return new String[] {"[player]", plugin.getLocale(sender).get("help.island.reject")}; } }); @@ -666,25 +667,25 @@ public class IslandCommand extends BSBCommand{ registerArgument(new String[] {"makeleader", "transfer"}, new CommandArgumentHandler() { @Override - public boolean canExecute(CommandSender sender, String label, String[] args) { + public boolean canExecute(CommandSender sender, String[] args) { return false; } @Override - public void onExecute(CommandSender sender, String label, String[] args) { + public void onExecute(CommandSender sender, String[] args) { } @Override - public List onTabComplete(CommandSender sender, String label, String[] args) { + public List onTabComplete(CommandSender sender, String[] args) { return null; } @Override - public String[] getHelp(CommandSender sender, String label){ + public String[] getHelp(CommandSender sender){ return new String[] {"", plugin.getLocale(sender).get("help.island.makeleader")}; } }); @@ -693,25 +694,25 @@ public class IslandCommand extends BSBCommand{ registerArgument(new String[] {"teamchat", "tc"}, new CommandArgumentHandler() { @Override - public boolean canExecute(CommandSender sender, String label, String[] args) { + public boolean canExecute(CommandSender sender, String[] args) { return false; } @Override - public void onExecute(CommandSender sender, String label, String[] args) { + public void onExecute(CommandSender sender, String[] args) { } @Override - public List onTabComplete(CommandSender sender, String label, String[] args) { + public List onTabComplete(CommandSender sender, String[] args) { return null; } @Override - public String[] getHelp(CommandSender sender, String label){ + public String[] getHelp(CommandSender sender){ return new String[] {null, plugin.getLocale(sender).get("help.island.teamchat")}; } }); @@ -720,25 +721,25 @@ public class IslandCommand extends BSBCommand{ registerArgument(new String[] {"biomes"}, new CommandArgumentHandler() { @Override - public boolean canExecute(CommandSender sender, String label, String[] args) { + public boolean canExecute(CommandSender sender, String[] args) { return false; } @Override - public void onExecute(CommandSender sender, String label, String[] args) { + public void onExecute(CommandSender sender, String[] args) { } @Override - public List onTabComplete(CommandSender sender, String label, String[] args) { + public List onTabComplete(CommandSender sender, String[] args) { return null; } @Override - public String[] getHelp(CommandSender sender, String label){ + public String[] getHelp(CommandSender sender){ return new String[] {null, plugin.getLocale(sender).get("help.island.biomes")}; } }); @@ -747,25 +748,25 @@ public class IslandCommand extends BSBCommand{ registerArgument(new String[] {"expel"}, new CommandArgumentHandler() { @Override - public boolean canExecute(CommandSender sender, String label, String[] args) { + public boolean canExecute(CommandSender sender, String[] args) { return false; } @Override - public void onExecute(CommandSender sender, String label, String[] args) { + public void onExecute(CommandSender sender, String[] args) { } @Override - public List onTabComplete(CommandSender sender, String label, String[] args) { + public List onTabComplete(CommandSender sender, String[] args) { return null; } @Override - public String[] getHelp(CommandSender sender, String label){ + public String[] getHelp(CommandSender sender){ return new String[] {"", plugin.getLocale(sender).get("help.island.expel")}; } }); @@ -774,25 +775,25 @@ public class IslandCommand extends BSBCommand{ registerArgument(new String[] {"expelall", "expel!"}, new CommandArgumentHandler() { @Override - public boolean canExecute(CommandSender sender, String label, String[] args) { + public boolean canExecute(CommandSender sender, String[] args) { return false; } @Override - public void onExecute(CommandSender sender, String label, String[] args) { + public void onExecute(CommandSender sender, String[] args) { } @Override - public List onTabComplete(CommandSender sender, String label, String[] args) { + public List onTabComplete(CommandSender sender, String[] args) { return null; } @Override - public String[] getHelp(CommandSender sender, String label){ + public String[] getHelp(CommandSender sender){ return new String[] {null, plugin.getLocale(sender).get("help.island.expelall")}; } }); @@ -801,25 +802,25 @@ public class IslandCommand extends BSBCommand{ registerArgument(new String[] {"ban"}, new CommandArgumentHandler() { @Override - public boolean canExecute(CommandSender sender, String label, String[] args) { + public boolean canExecute(CommandSender sender, String[] args) { return false; } @Override - public void onExecute(CommandSender sender, String label, String[] args) { + public void onExecute(CommandSender sender, String[] args) { } @Override - public List onTabComplete(CommandSender sender, String label, String[] args) { + public List onTabComplete(CommandSender sender, String[] args) { return null; } @Override - public String[] getHelp(CommandSender sender, String label){ + public String[] getHelp(CommandSender sender){ return new String[] {"", plugin.getLocale(sender).get("help.island.ban")}; } }); @@ -828,25 +829,25 @@ public class IslandCommand extends BSBCommand{ registerArgument(new String[] {"unban"}, new CommandArgumentHandler() { @Override - public boolean canExecute(CommandSender sender, String label, String[] args) { + public boolean canExecute(CommandSender sender, String[] args) { return false; } @Override - public void onExecute(CommandSender sender, String label, String[] args) { + public void onExecute(CommandSender sender, String[] args) { } @Override - public List onTabComplete(CommandSender sender, String label, String[] args) { + public List onTabComplete(CommandSender sender, String[] args) { return null; } @Override - public String[] getHelp(CommandSender sender, String label){ + public String[] getHelp(CommandSender sender){ return new String[] {"", plugin.getLocale(sender).get("help.island.unban")}; } }); @@ -855,25 +856,25 @@ public class IslandCommand extends BSBCommand{ registerArgument(new String[] {"banlist", "bl"}, new CommandArgumentHandler() { @Override - public boolean canExecute(CommandSender sender, String label, String[] args) { + public boolean canExecute(CommandSender sender, String[] args) { return false; } @Override - public void onExecute(CommandSender sender, String label, String[] args) { + public void onExecute(CommandSender sender, String[] args) { } @Override - public List onTabComplete(CommandSender sender, String label, String[] args) { + public List onTabComplete(CommandSender sender, String[] args) { return null; } @Override - public String[] getHelp(CommandSender sender, String label){ + public String[] getHelp(CommandSender sender){ return new String[] {null, plugin.getLocale(sender).get("help.island.banlist")}; } }); @@ -882,25 +883,25 @@ public class IslandCommand extends BSBCommand{ registerArgument(new String[] {"trust"}, new CommandArgumentHandler() { @Override - public boolean canExecute(CommandSender sender, String label, String[] args) { + public boolean canExecute(CommandSender sender, String[] args) { return false; } @Override - public void onExecute(CommandSender sender, String label, String[] args) { + public void onExecute(CommandSender sender, String[] args) { } @Override - public List onTabComplete(CommandSender sender, String label, String[] args) { + public List onTabComplete(CommandSender sender, String[] args) { return null; } @Override - public String[] getHelp(CommandSender sender, String label){ + public String[] getHelp(CommandSender sender){ return new String[] {"", plugin.getLocale(sender).get("help.island.trust")}; } }); @@ -909,25 +910,25 @@ public class IslandCommand extends BSBCommand{ registerArgument(new String[] {"untrust"}, new CommandArgumentHandler() { @Override - public boolean canExecute(CommandSender sender, String label, String[] args) { + public boolean canExecute(CommandSender sender, String[] args) { return false; } @Override - public void onExecute(CommandSender sender, String label, String[] args) { + public void onExecute(CommandSender sender, String[] args) { } @Override - public List onTabComplete(CommandSender sender, String label, String[] args) { + public List onTabComplete(CommandSender sender, String[] args) { return null; } @Override - public String[] getHelp(CommandSender sender, String label){ + public String[] getHelp(CommandSender sender){ return new String[] {"", plugin.getLocale(sender).get("help.island.untrust")}; } }); @@ -936,25 +937,25 @@ public class IslandCommand extends BSBCommand{ registerArgument(new String[] {"trustlist", "tl"}, new CommandArgumentHandler() { @Override - public boolean canExecute(CommandSender sender, String label, String[] args) { + public boolean canExecute(CommandSender sender, String[] args) { return false; } @Override - public void onExecute(CommandSender sender, String label, String[] args) { + public void onExecute(CommandSender sender, String[] args) { } @Override - public List onTabComplete(CommandSender sender, String label, String[] args) { + public List onTabComplete(CommandSender sender, String[] args) { return null; } @Override - public String[] getHelp(CommandSender sender, String label){ + public String[] getHelp(CommandSender sender){ return new String[] {null, plugin.getLocale(sender).get("help.island.trustlist")}; } }); @@ -963,25 +964,25 @@ public class IslandCommand extends BSBCommand{ registerArgument(new String[] {"coop"}, new CommandArgumentHandler() { @Override - public boolean canExecute(CommandSender sender, String label, String[] args) { + public boolean canExecute(CommandSender sender, String[] args) { return false; } @Override - public void onExecute(CommandSender sender, String label, String[] args) { + public void onExecute(CommandSender sender, String[] args) { } @Override - public List onTabComplete(CommandSender sender, String label, String[] args) { + public List onTabComplete(CommandSender sender, String[] args) { return null; } @Override - public String[] getHelp(CommandSender sender, String label){ + public String[] getHelp(CommandSender sender){ return new String[] {"", plugin.getLocale(sender).get("help.island.coop")}; } }); @@ -990,25 +991,25 @@ public class IslandCommand extends BSBCommand{ registerArgument(new String[] {"uncoop"}, new CommandArgumentHandler() { @Override - public boolean canExecute(CommandSender sender, String label, String[] args) { + public boolean canExecute(CommandSender sender, String[] args) { return false; } @Override - public void onExecute(CommandSender sender, String label, String[] args) { + public void onExecute(CommandSender sender, String[] args) { } @Override - public List onTabComplete(CommandSender sender, String label, String[] args) { + public List onTabComplete(CommandSender sender, String[] args) { return null; } @Override - public String[] getHelp(CommandSender sender, String label){ + public String[] getHelp(CommandSender sender){ return new String[] {"", plugin.getLocale(sender).get("help.island.uncoop")}; } }); @@ -1017,25 +1018,25 @@ public class IslandCommand extends BSBCommand{ registerArgument(new String[] {"cooplist", "cl"}, new CommandArgumentHandler() { @Override - public boolean canExecute(CommandSender sender, String label, String[] args) { + public boolean canExecute(CommandSender sender, String[] args) { return false; } @Override - public void onExecute(CommandSender sender, String label, String[] args) { + public void onExecute(CommandSender sender, String[] args) { } @Override - public List onTabComplete(CommandSender sender, String label, String[] args) { + public List onTabComplete(CommandSender sender, String[] args) { return null; } @Override - public String[] getHelp(CommandSender sender, String label){ + public String[] getHelp(CommandSender sender){ return new String[] {null, plugin.getLocale(sender).get("help.island.cooplist")}; } }); @@ -1044,7 +1045,7 @@ public class IslandCommand extends BSBCommand{ registerArgument(new String[] {"lock", "unlock"}, new CommandArgumentHandler() { @Override - public boolean canExecute(CommandSender sender, String label, String[] args) { + public boolean canExecute(CommandSender sender, String[] args) { Player player = (Player) sender; if(!VaultHelper.hasPerm(player, Settings.PERMPREFIX + "island.lock")){ @@ -1061,7 +1062,7 @@ public class IslandCommand extends BSBCommand{ } @Override - public void onExecute(CommandSender sender, String label, String[] args) { + public void onExecute(CommandSender sender, String[] args) { Player player = (Player) sender; Island island = plugin.getIslands().getIsland(player.getUniqueId()); @@ -1077,12 +1078,12 @@ public class IslandCommand extends BSBCommand{ } @Override - public List onTabComplete(CommandSender sender, String label, String[] args) { + public List onTabComplete(CommandSender sender, String[] args) { return null; } @Override - public String[] getHelp(CommandSender sender, String label){ + public String[] getHelp(CommandSender sender){ return new String[] {null, plugin.getLocale(sender).get("help.island.lock")}; } }); @@ -1091,25 +1092,25 @@ public class IslandCommand extends BSBCommand{ registerArgument(new String[] {"settings"}, new CommandArgumentHandler() { @Override - public boolean canExecute(CommandSender sender, String label, String[] args) { + public boolean canExecute(CommandSender sender, String[] args) { return false; } @Override - public void onExecute(CommandSender sender, String label, String[] args) { + public void onExecute(CommandSender sender, String[] args) { } @Override - public List onTabComplete(CommandSender sender, String label, String[] args) { + public List onTabComplete(CommandSender sender, String[] args) { return null; } @Override - public String[] getHelp(CommandSender sender, String label){ + public String[] getHelp(CommandSender sender){ return new String[] {null, plugin.getLocale(sender).get("help.island.settings")}; } }); @@ -1118,25 +1119,25 @@ public class IslandCommand extends BSBCommand{ registerArgument(new String[] {"language", "lang"}, new CommandArgumentHandler() { @Override - public boolean canExecute(CommandSender sender, String label, String[] args) { + public boolean canExecute(CommandSender sender, String[] args) { return false; } @Override - public void onExecute(CommandSender sender, String label, String[] args) { + public void onExecute(CommandSender sender, String[] args) { } @Override - public List onTabComplete(CommandSender sender, String label, String[] args) { + public List onTabComplete(CommandSender sender, String[] args) { return null; } @Override - public String[] getHelp(CommandSender sender, String label){ + public String[] getHelp(CommandSender sender){ return new String[] {"", plugin.getLocale(sender).get("help.island.language")}; } }); diff --git a/src/main/java/us/tastybento/bskyblock/config/BSBLocale.java b/src/main/java/us/tastybento/bskyblock/config/BSBLocale.java index a0d741897..672ac271b 100644 --- a/src/main/java/us/tastybento/bskyblock/config/BSBLocale.java +++ b/src/main/java/us/tastybento/bskyblock/config/BSBLocale.java @@ -1,5 +1,8 @@ package us.tastybento.bskyblock.config; +import org.bukkit.ChatColor; +import us.tastybento.bskyblock.BSkyBlock; + import java.io.File; import java.net.MalformedURLException; import java.net.URL; @@ -7,10 +10,6 @@ import java.net.URLClassLoader; import java.util.Locale; import java.util.ResourceBundle; -import org.bukkit.ChatColor; - -import us.tastybento.bskyblock.BSkyBlock; - public class BSBLocale { final static String LOCALE_FOLDER = "locales";