Tiny adjustements to commands

This commit is contained in:
Poslovitch 2017-08-01 14:20:52 +02:00
parent bbd959f186
commit 0c1b5f7197
4 changed files with 66 additions and 44 deletions

View File

@ -38,6 +38,8 @@ general:
no-permission: "You don't have permission to execute this command."
use-in-game: "This command is only available in game."
no-team: "You do not have a team!"
no-island: "You do not have an island!"
not-leader: "You are not the leader of your island!"
offline-player: "That player is offline or doesn't exist."
# TODO: These are legacy strings and should be converted to a better format but will do for now

View File

@ -17,10 +17,10 @@ public abstract class AbstractCommand implements CommandExecutor, TabCompleter {
private BSkyBlock plugin;
private Map<String, ArgumentHandler> argumentsMap;
private Map<String, String> aliasesMap;
private final Map<String, ArgumentHandler> argumentsMap;
private final Map<String, String> aliasesMap;
public String label;
public final String label;
public boolean isPlayer;
public boolean inTeam;
public UUID teamLeaderUUID;
@ -33,14 +33,34 @@ public abstract class AbstractCommand implements CommandExecutor, TabCompleter {
protected AbstractCommand(BSkyBlock plugin, String label, boolean help) {
this.plugin = plugin;
this.argumentsMap = new HashMap<String, ArgumentHandler>(1);
this.aliasesMap = new HashMap<String,String>(1);
this.argumentsMap = new HashMap<>(1);
this.aliasesMap = new HashMap<>(1);
this.label = label;
this.help = help;
// Register the help argument if needed
if (help) {
addArgument(new String[]{"help", "?"}, new ArgumentHandler() {
@Override
public boolean canUse(CommandSender sender) {
return true; // If the player has access to this command, he can get help
}
@Override
public void execute(CommandSender sender, String[] args) {
}
@Override
public List<String> tabComplete(CommandSender sender, String[] args) {
return null; // No tab options for this one
}
@Override
public String[] usage(CommandSender sender) {
return new String[] {"", ""};
}
});
}
// Register the other arguments
@ -54,7 +74,7 @@ public abstract class AbstractCommand implements CommandExecutor, TabCompleter {
boolean canUse(CommandSender sender);
void execute(CommandSender sender, String[] args);
List<String> tabComplete(CommandSender sender, String[] args);
String[] getHelp(CommandSender sender);
String[] usage(CommandSender sender);
}
public abstract void setup();

View File

@ -41,7 +41,7 @@ public class AdminCommand extends AbstractCommand {
}
@Override
public String[] getHelp(CommandSender sender){
public String[] usage(CommandSender sender){
return new String[] {null, plugin.getLocale(sender).get("help.admin.delete")};
}
});

View File

@ -122,7 +122,7 @@ public class IslandCommand extends AbstractCommand {
}
@Override
public String[] getHelp(CommandSender sender){
public String[] usage(CommandSender sender){
return null;
}
});
@ -153,7 +153,7 @@ public class IslandCommand extends AbstractCommand {
}
@Override
public String[] getHelp(CommandSender sender){
public String[] usage(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")};
@ -181,7 +181,7 @@ public class IslandCommand extends AbstractCommand {
}
@Override
public String[] getHelp(CommandSender sender){
public String[] usage(CommandSender sender){
return new String[] {null, plugin.getLocale(sender).get("help.island.spawn")};
}
});
@ -214,7 +214,7 @@ public class IslandCommand extends AbstractCommand {
}
@Override
public String[] getHelp(CommandSender sender){
public String[] usage(CommandSender sender){
return new String[] {"[schematic]", plugin.getLocale(sender).get("help.island.create")};
}
});
@ -241,7 +241,7 @@ public class IslandCommand extends AbstractCommand {
}
@Override
public String[] getHelp(CommandSender sender){
public String[] usage(CommandSender sender){
return new String[] {"[player]", plugin.getLocale(sender).get("help.island.info")};
}
});
@ -268,7 +268,7 @@ public class IslandCommand extends AbstractCommand {
}
@Override
public String[] getHelp(CommandSender sender){
public String[] usage(CommandSender sender){
return new String[] {"[on/off]", plugin.getLocale(sender).get("help.island.control-panel")};
}
});
@ -302,7 +302,7 @@ public class IslandCommand extends AbstractCommand {
plugin.getIslands().newIsland(player, schematic, oldIsland);
} else {
Util.sendMessage(player, plugin.getLocale(player.getUniqueId()).get("error.noIsland"));
Util.sendMessage(player, plugin.getLocale(player.getUniqueId()).get("general.errors.no-island"));
}
}
@ -313,7 +313,7 @@ public class IslandCommand extends AbstractCommand {
}
@Override
public String[] getHelp(CommandSender sender){
public String[] usage(CommandSender sender){
return new String[] {null, plugin.getLocale(sender).get("help.island.reset")};
}
});
@ -340,7 +340,7 @@ public class IslandCommand extends AbstractCommand {
}
@Override
public String[] getHelp(CommandSender sender){
public String[] usage(CommandSender sender){
return new String[] {null, plugin.getLocale(sender).get("help.island.sethome")};
}
});
@ -376,7 +376,7 @@ public class IslandCommand extends AbstractCommand {
// Explain command
if(args.length == 1){
//TODO Util.sendMessage(player, getHelpMessage(player, label, args[0], getHelp(sender, label)));
//TODO Util.sendMessage(player, getHelpMessage(player, label, args[0], usage(sender, label)));
return;
}
@ -409,7 +409,7 @@ public class IslandCommand extends AbstractCommand {
}
@Override
public String[] getHelp(CommandSender sender){
public String[] usage(CommandSender sender){
return new String[] {"<name>", plugin.getLocale(sender).get("help.island.name")};
}
});
@ -454,7 +454,7 @@ public class IslandCommand extends AbstractCommand {
}
@Override
public String[] getHelp(CommandSender sender){
public String[] usage(CommandSender sender){
return new String[] {null, plugin.getLocale(sender).get("help.island.resetname")};
}
});
@ -481,7 +481,7 @@ public class IslandCommand extends AbstractCommand {
}
@Override
public String[] getHelp(CommandSender sender){
public String[] usage(CommandSender sender){
return new String[] {null, plugin.getLocale(sender).get("help.island.limits")};
}
});
@ -511,7 +511,7 @@ public class IslandCommand extends AbstractCommand {
}
@Override
public String[] getHelp(CommandSender sender){
public String[] usage(CommandSender sender){
plugin.getLogger().info("DEBUG: executing team help");
if (inTeam) {
if (teamLeaderUUID.equals(playerUUID)) {
@ -709,7 +709,7 @@ public class IslandCommand extends AbstractCommand {
}
@Override
public String[] getHelp(CommandSender sender){
public String[] usage(CommandSender sender){
return new String[] {"<player>", plugin.getLocale(sender).get("help.island.invite")};
}
});
@ -736,7 +736,7 @@ public class IslandCommand extends AbstractCommand {
}
@Override
public String[] getHelp(CommandSender sender){
public String[] usage(CommandSender sender){
return new String[] {"<player>", plugin.getLocale(sender).get("help.island.uninvite")};
}
});
@ -763,7 +763,7 @@ public class IslandCommand extends AbstractCommand {
}
@Override
public String[] getHelp(CommandSender sender){
public String[] usage(CommandSender sender){
return new String[] {null, plugin.getLocale(sender).get("help.island.leave")};
}
});
@ -790,7 +790,7 @@ public class IslandCommand extends AbstractCommand {
}
@Override
public String[] getHelp(CommandSender sender){
public String[] usage(CommandSender sender){
return new String[] {"<player>", plugin.getLocale(sender).get("help.island.kick")};
}
});
@ -817,7 +817,7 @@ public class IslandCommand extends AbstractCommand {
}
@Override
public String[] getHelp(CommandSender sender){
public String[] usage(CommandSender sender){
return new String[] {"[player]", plugin.getLocale(sender).get("help.island.accept")};
}
});
@ -844,7 +844,7 @@ public class IslandCommand extends AbstractCommand {
}
@Override
public String[] getHelp(CommandSender sender){
public String[] usage(CommandSender sender){
return new String[] {"[player]", plugin.getLocale(sender).get("help.island.reject")};
}
});
@ -871,7 +871,7 @@ public class IslandCommand extends AbstractCommand {
}
@Override
public String[] getHelp(CommandSender sender){
public String[] usage(CommandSender sender){
return new String[] {"<player>", plugin.getLocale(sender).get("help.island.makeleader")};
}
});
@ -898,7 +898,7 @@ public class IslandCommand extends AbstractCommand {
}
@Override
public String[] getHelp(CommandSender sender){
public String[] usage(CommandSender sender){
return new String[] {null, plugin.getLocale(sender).get("help.island.teamchat")};
}
});
@ -925,7 +925,7 @@ public class IslandCommand extends AbstractCommand {
}
@Override
public String[] getHelp(CommandSender sender){
public String[] usage(CommandSender sender){
return new String[] {null, plugin.getLocale(sender).get("help.island.biomes")};
}
});
@ -952,7 +952,7 @@ public class IslandCommand extends AbstractCommand {
}
@Override
public String[] getHelp(CommandSender sender){
public String[] usage(CommandSender sender){
return new String[] {"<player>", plugin.getLocale(sender).get("help.island.expel")};
}
});
@ -979,7 +979,7 @@ public class IslandCommand extends AbstractCommand {
}
@Override
public String[] getHelp(CommandSender sender){
public String[] usage(CommandSender sender){
return new String[] {null, plugin.getLocale(sender).get("help.island.expelall")};
}
});
@ -1006,7 +1006,7 @@ public class IslandCommand extends AbstractCommand {
}
@Override
public String[] getHelp(CommandSender sender){
public String[] usage(CommandSender sender){
return new String[] {"<player>", plugin.getLocale(sender).get("help.island.ban")};
}
});
@ -1033,7 +1033,7 @@ public class IslandCommand extends AbstractCommand {
}
@Override
public String[] getHelp(CommandSender sender){
public String[] usage(CommandSender sender){
return new String[] {"<player>", plugin.getLocale(sender).get("help.island.unban")};
}
});
@ -1060,7 +1060,7 @@ public class IslandCommand extends AbstractCommand {
}
@Override
public String[] getHelp(CommandSender sender){
public String[] usage(CommandSender sender){
return new String[] {null, plugin.getLocale(sender).get("help.island.banlist")};
}
});
@ -1087,7 +1087,7 @@ public class IslandCommand extends AbstractCommand {
}
@Override
public String[] getHelp(CommandSender sender){
public String[] usage(CommandSender sender){
return new String[] {"<player>", plugin.getLocale(sender).get("help.island.trust")};
}
});
@ -1114,7 +1114,7 @@ public class IslandCommand extends AbstractCommand {
}
@Override
public String[] getHelp(CommandSender sender){
public String[] usage(CommandSender sender){
return new String[] {"<player>", plugin.getLocale(sender).get("help.island.untrust")};
}
});
@ -1141,7 +1141,7 @@ public class IslandCommand extends AbstractCommand {
}
@Override
public String[] getHelp(CommandSender sender){
public String[] usage(CommandSender sender){
return new String[] {null, plugin.getLocale(sender).get("help.island.trustlist")};
}
});
@ -1168,7 +1168,7 @@ public class IslandCommand extends AbstractCommand {
}
@Override
public String[] getHelp(CommandSender sender){
public String[] usage(CommandSender sender){
return new String[] {"<player>", plugin.getLocale(sender).get("help.island.coop")};
}
});
@ -1195,7 +1195,7 @@ public class IslandCommand extends AbstractCommand {
}
@Override
public String[] getHelp(CommandSender sender){
public String[] usage(CommandSender sender){
return new String[] {"<player>", plugin.getLocale(sender).get("help.island.uncoop")};
}
});
@ -1222,7 +1222,7 @@ public class IslandCommand extends AbstractCommand {
}
@Override
public String[] getHelp(CommandSender sender){
public String[] usage(CommandSender sender){
return new String[] {null, plugin.getLocale(sender).get("help.island.cooplist")};
}
});
@ -1269,7 +1269,7 @@ public class IslandCommand extends AbstractCommand {
}
@Override
public String[] getHelp(CommandSender sender){
public String[] usage(CommandSender sender){
return new String[] {null, plugin.getLocale(sender).get("help.island.lock")};
}
});
@ -1296,7 +1296,7 @@ public class IslandCommand extends AbstractCommand {
}
@Override
public String[] getHelp(CommandSender sender){
public String[] usage(CommandSender sender){
return new String[] {null, plugin.getLocale(sender).get("help.island.settings")};
}
});
@ -1323,7 +1323,7 @@ public class IslandCommand extends AbstractCommand {
}
@Override
public String[] getHelp(CommandSender sender){
public String[] usage(CommandSender sender){
return new String[] {"<id>", plugin.getLocale(sender).get("help.island.language")};
}
});