mirror of
https://github.com/BentoBoxWorld/BentoBox.git
synced 2024-12-22 00:58:04 +01:00
Cleaned up command api a lot
Added event that fires when a command is run.
This commit is contained in:
parent
7804c4a867
commit
1e205ac12e
@ -18,6 +18,9 @@ import org.bukkit.command.TabCompleter;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import us.tastybento.bskyblock.BSkyBlock;
|
||||
import us.tastybento.bskyblock.api.events.command.CommandEvent;
|
||||
import us.tastybento.bskyblock.api.events.team.TeamEvent;
|
||||
import us.tastybento.bskyblock.api.events.team.TeamEvent.TeamReason;
|
||||
import us.tastybento.bskyblock.config.BSBLocale;
|
||||
import us.tastybento.bskyblock.database.managers.IslandsManager;
|
||||
import us.tastybento.bskyblock.database.managers.PlayersManager;
|
||||
@ -32,8 +35,7 @@ public abstract class AbstractCommand implements CommandExecutor, TabCompleter {
|
||||
private BSkyBlock plugin;
|
||||
|
||||
public final Map<String, ArgumentHandler> argumentsMap;
|
||||
private final Map<String, String> aliasesMap;
|
||||
|
||||
public final Set<ArgumentHandler> handlers;
|
||||
public final String label;
|
||||
public final String[] aliases;
|
||||
public boolean isPlayer;
|
||||
@ -51,7 +53,7 @@ public abstract class AbstractCommand implements CommandExecutor, TabCompleter {
|
||||
protected AbstractCommand(BSkyBlock plugin, String label, String[] aliases, boolean help) {
|
||||
this.plugin = plugin;
|
||||
this.argumentsMap = new LinkedHashMap<>();
|
||||
this.aliasesMap = new HashMap<>();
|
||||
this.handlers = new HashSet<>();
|
||||
this.label = label;
|
||||
this.aliases = aliases;
|
||||
this.help = help;
|
||||
@ -59,7 +61,7 @@ public abstract class AbstractCommand implements CommandExecutor, TabCompleter {
|
||||
|
||||
// Register the help argument if needed
|
||||
if (help) {
|
||||
addArgument(new String[]{"help", "?"}, new ArgumentHandler(plugin, label, aliases, argumentsMap) {
|
||||
addArgument(new ArgumentHandler(label) {
|
||||
@Override
|
||||
public CanUseResp canUse(CommandSender sender) {
|
||||
return new CanUseResp(true); // If the player has access to this command, he can get help
|
||||
@ -68,8 +70,7 @@ public abstract class AbstractCommand implements CommandExecutor, TabCompleter {
|
||||
@Override
|
||||
public void execute(CommandSender sender, String[] args) {
|
||||
Util.sendMessage(sender, plugin.getLocale(sender).get("help.header"));
|
||||
for(String arg : argumentsMap.keySet()){
|
||||
ArgumentHandler handler = getHandler(arg);
|
||||
for(ArgumentHandler handler: handlers){
|
||||
if (handler.canUse(sender).isAllowed()) Util.sendMessage(sender, handler.getShortDescription(sender));
|
||||
}
|
||||
Util.sendMessage(sender, plugin.getLocale(sender).get("help.end"));
|
||||
@ -84,7 +85,7 @@ public abstract class AbstractCommand implements CommandExecutor, TabCompleter {
|
||||
public String[] usage(CommandSender sender) {
|
||||
return new String[] {"", ""};
|
||||
}
|
||||
});
|
||||
}.alias("help").alias("?"));
|
||||
}
|
||||
|
||||
// Register the other arguments
|
||||
@ -98,54 +99,26 @@ public abstract class AbstractCommand implements CommandExecutor, TabCompleter {
|
||||
public abstract CanUseResp canUse(CommandSender sender);
|
||||
public abstract void execute(CommandSender sender, String[] args);
|
||||
|
||||
public void addArgument(String[] names, ArgumentHandler handler) {
|
||||
// TODO add some security checks to avoid duplicates
|
||||
argumentsMap.put(names[0], handler);
|
||||
for (int i = 1 ; i < names.length ; i++) {
|
||||
aliasesMap.put(names[0], names[i]);
|
||||
public void addArgument(ArgumentHandler handler) {
|
||||
for (String argument : handler.getAliases()) {
|
||||
argumentsMap.put(argument, handler);
|
||||
}
|
||||
handlers.add(handler);
|
||||
}
|
||||
|
||||
public ArgumentHandler getHandler(String argument) {
|
||||
if (isAlias(argument)) return argumentsMap.get(getParent(argument));
|
||||
else return argumentsMap.get(argument);
|
||||
}
|
||||
|
||||
public void setHandler(String argument, ArgumentHandler handler) {
|
||||
if (argumentsMap.containsKey(argument)) argumentsMap.put(argument, handler);
|
||||
}
|
||||
|
||||
public boolean isAlias(String argument) {
|
||||
return aliasesMap.containsValue(argument);
|
||||
}
|
||||
|
||||
public void addAliases(String parent, String... aliases) {
|
||||
if (argumentsMap.containsKey(parent)) {
|
||||
for (String alias : aliases) {
|
||||
if (!aliasesMap.containsKey(alias) && !aliasesMap.containsValue(alias)) aliasesMap.put(parent, alias);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void removeAliases(String... aliases) {
|
||||
for (String alias : aliases) {
|
||||
if (aliasesMap.containsValue(alias)) aliasesMap.remove(getParent(alias));
|
||||
}
|
||||
}
|
||||
|
||||
public String getParent(String alias) {
|
||||
if (isAlias(alias)) {
|
||||
for(String parent : aliasesMap.keySet()) {
|
||||
if (aliasesMap.get(parent).equals(alias)) return parent;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
else return alias;
|
||||
return argumentsMap.get(argument);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
checkForPlayer(sender);
|
||||
|
||||
// Fire command event
|
||||
CommandEvent event = CommandEvent.builder().setSender(sender).setCommand(command).setLabel(label).setArgs(args).build();
|
||||
plugin.getServer().getPluginManager().callEvent(event);
|
||||
if (event.isCancelled()) return true;
|
||||
|
||||
CanUseResp canUse = this.canUse(sender);
|
||||
if (canUse.isAllowed()) {
|
||||
if(args.length >= 1) {
|
||||
@ -181,8 +154,8 @@ public abstract class AbstractCommand implements CommandExecutor, TabCompleter {
|
||||
if (canUse(sender).isAllowed()) {
|
||||
if (args.length <= 1) {
|
||||
// Go through every argument, check if player can use it and if so, add it in tab options
|
||||
for(String argument : argumentsMap.keySet()) {
|
||||
if (getHandler(argument).canUse(sender).isAllowed()) options.add(argument);
|
||||
for(ArgumentHandler handler: handlers) {
|
||||
if (handler.canUse(sender).isAllowed()) options.addAll(handler.aliasSet);
|
||||
}
|
||||
} else {
|
||||
// If player can execute the argument, get its tab-completer options
|
||||
|
@ -1,9 +1,6 @@
|
||||
package us.tastybento.bskyblock.api.commands;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.bukkit.command.CommandSender;
|
||||
@ -15,46 +12,35 @@ import us.tastybento.bskyblock.BSkyBlock;
|
||||
*/
|
||||
public abstract class ArgumentHandler {
|
||||
private BSkyBlock plugin;
|
||||
private Map<String, ArgumentHandler> argumentsMap;
|
||||
private Map<String, String> aliasesMap;
|
||||
public final String[] aliases;
|
||||
public Set<String> aliasSet;
|
||||
public final String label;
|
||||
public String command;
|
||||
|
||||
public abstract CanUseResp canUse(CommandSender sender);
|
||||
public abstract void execute(CommandSender sender, String[] args);
|
||||
public abstract Set<String> tabComplete(CommandSender sender, String[] args);
|
||||
public abstract String[] usage(CommandSender sender);
|
||||
|
||||
public ArgumentHandler(BSkyBlock plugin, String label, String[] aliases, Map<String, ArgumentHandler> argumentsMap) {
|
||||
public ArgumentHandler(String label) {
|
||||
super();
|
||||
this.plugin = plugin;
|
||||
this.argumentsMap = new LinkedHashMap<>();
|
||||
this.aliasesMap = new HashMap<>();
|
||||
this.label = label;
|
||||
this.aliases = aliases;
|
||||
this.argumentsMap = argumentsMap;
|
||||
this.plugin = BSkyBlock.getPlugin();
|
||||
this.label = label; // The original command this is relating to, e.g., /island
|
||||
this.aliasSet = new HashSet<>(); // The sub-command and aliases, if any. The first one in the list is the main sub-command
|
||||
}
|
||||
|
||||
public String getShortDescription(CommandSender sender) {
|
||||
String msg = BSkyBlock.getPlugin().getLocale(sender).get("help.syntax");
|
||||
msg = msg.replace("[label]", (aliases[0] != null) ? aliases[0] : label);
|
||||
// syntax: " &7/&b[label] &c[command] &a[args] &7: &e[info]"
|
||||
String msg = plugin.getLocale(sender).get("help.syntax");
|
||||
msg = msg.replace("[label]", label);
|
||||
|
||||
String command = "";
|
||||
for(Map.Entry<String, ArgumentHandler> entry : argumentsMap.entrySet()) {
|
||||
if (entry.getValue().equals(this)) {
|
||||
command = entry.getKey();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
String cmds = command;
|
||||
for(String alias : getAliases(command)) {
|
||||
String cmds = "";
|
||||
for(String alias : aliasSet) {
|
||||
cmds += plugin.getLocale(sender).get("help.syntax-alias-separator") + alias;
|
||||
}
|
||||
|
||||
msg = msg.replace("[command]", cmds);
|
||||
|
||||
String[] usage = argumentsMap.get(command).usage(sender);
|
||||
String[] usage = usage(sender);
|
||||
if (usage == null) usage = new String[2];
|
||||
|
||||
msg = msg.replace("[args]", (usage[0] != null) ? usage[0] : "")
|
||||
@ -63,13 +49,14 @@ public abstract class ArgumentHandler {
|
||||
return msg;
|
||||
}
|
||||
|
||||
public Set<String> getAliases(String argument) {
|
||||
Set<String> aliases = new HashSet<>();
|
||||
|
||||
for (Map.Entry<String, String> entry : aliasesMap.entrySet()) {
|
||||
if (entry.getKey().equals(argument)) aliases.add(entry.getValue());
|
||||
}
|
||||
|
||||
return aliases;
|
||||
public Set<String> getAliases() {
|
||||
return aliasSet;
|
||||
}
|
||||
}
|
||||
|
||||
public ArgumentHandler alias(String alias) {
|
||||
aliasSet.add(alias);
|
||||
return this;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,104 @@
|
||||
package us.tastybento.bskyblock.api.events.command;
|
||||
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.event.Cancellable;
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.HandlerList;
|
||||
|
||||
/**
|
||||
* Fired when a team event happens.
|
||||
*
|
||||
* @author tastybento
|
||||
* @since 1.0
|
||||
*/
|
||||
public class CommandEvent extends Event implements Cancellable {
|
||||
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
private boolean cancelled;
|
||||
|
||||
private final CommandSender sender;
|
||||
private final Command command;
|
||||
private final String label;
|
||||
private final String[] args;
|
||||
|
||||
private CommandEvent(CommandSender sender, Command command, String label, String[] args) {
|
||||
super();
|
||||
this.sender = sender;
|
||||
this.command = command;
|
||||
this.label = label;
|
||||
this.args = args;
|
||||
}
|
||||
|
||||
public static CommandEventBuilder builder() {
|
||||
return new CommandEventBuilder();
|
||||
}
|
||||
|
||||
public static class CommandEventBuilder {
|
||||
// Here field are NOT final. They are just used for the building.
|
||||
private CommandSender sender;
|
||||
private Command command;
|
||||
private String label;
|
||||
private String[] args;
|
||||
|
||||
public CommandEventBuilder setSender(CommandSender sender) {
|
||||
this.sender = sender;
|
||||
return this;
|
||||
}
|
||||
|
||||
public CommandEventBuilder setCommand(Command command) {
|
||||
this.command = command;
|
||||
return this;
|
||||
}
|
||||
|
||||
public CommandEventBuilder setLabel(String label) {
|
||||
this.label = label;
|
||||
return this;
|
||||
}
|
||||
|
||||
public CommandEventBuilder setArgs(String[] args) {
|
||||
this.args = args;
|
||||
return this;
|
||||
}
|
||||
|
||||
public CommandEvent build() {
|
||||
return new CommandEvent(sender, command, label, args);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public CommandSender getSender() {
|
||||
return sender;
|
||||
}
|
||||
|
||||
public Command getCommand() {
|
||||
return command;
|
||||
}
|
||||
|
||||
public String getLabel() {
|
||||
return label;
|
||||
}
|
||||
|
||||
public String[] getArgs() {
|
||||
return args;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCancelled() {
|
||||
return cancelled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCancelled(boolean arg0) {
|
||||
cancelled = arg0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public HandlerList getHandlers() {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
public static HandlerList getHandlerList() {
|
||||
return handlers;
|
||||
}
|
||||
}
|
@ -41,7 +41,7 @@ public class AdminCommand extends AbstractCommand {
|
||||
@Override
|
||||
public void setup() {
|
||||
/* /asadmin delete <name> - delete name's island */
|
||||
addArgument(new String[] {"delete"}, new ArgumentHandler(plugin, label, aliases, argumentsMap) {
|
||||
addArgument(new ArgumentHandler(label) {
|
||||
|
||||
@Override
|
||||
public CanUseResp canUse(CommandSender sender) {
|
||||
@ -62,10 +62,10 @@ public class AdminCommand extends AbstractCommand {
|
||||
public String[] usage(CommandSender sender){
|
||||
return new String[] {null, plugin.getLocale(sender).get("help.admin.delete")};
|
||||
}
|
||||
});
|
||||
}.alias("delete"));
|
||||
|
||||
/* /asadmin team - manage teams */
|
||||
addArgument(new String[] {"team"}, new ArgumentHandler(plugin, label, aliases, argumentsMap) {
|
||||
addArgument(new ArgumentHandler(label) {
|
||||
|
||||
@Override
|
||||
public CanUseResp canUse(CommandSender sender) {
|
||||
@ -353,7 +353,7 @@ public class AdminCommand extends AbstractCommand {
|
||||
public String[] usage(CommandSender sender){
|
||||
return new String[] {null, plugin.getLocale(sender).get("help.admin.team.command")};
|
||||
}
|
||||
});
|
||||
}.alias("team"));
|
||||
|
||||
}
|
||||
|
||||
|
@ -85,7 +85,7 @@ public class IslandCommand extends AbstractCommand {
|
||||
@Override
|
||||
public void setup() {
|
||||
/* /is about - Display plugin's info (license, version, authors) */
|
||||
addArgument(new String[]{"about"}, new ArgumentHandler(plugin, label, aliases, argumentsMap) {
|
||||
addArgument(new ArgumentHandler(label) {
|
||||
|
||||
@Override
|
||||
public CanUseResp canUse(CommandSender sender) {
|
||||
@ -134,10 +134,10 @@ public class IslandCommand extends AbstractCommand {
|
||||
public String[] usage(CommandSender sender) {
|
||||
return new String[] {null, getLocale(sender).get("help.island.about")};
|
||||
}
|
||||
});
|
||||
}.alias("about"));
|
||||
|
||||
/* /is go [<1-x>] - Teleport player to his island or the specified home */
|
||||
addArgument(new String[]{"go", "home", "h"}, new ArgumentHandler(plugin, label, aliases, argumentsMap) {
|
||||
addArgument(new ArgumentHandler(label) {
|
||||
|
||||
@Override
|
||||
public CanUseResp canUse(CommandSender sender) {
|
||||
@ -168,10 +168,10 @@ public class IslandCommand extends AbstractCommand {
|
||||
return new String[]{"[1-x]", getLocale(sender).get("help.island.go-homes")};
|
||||
return new String[]{null, getLocale(sender).get("help.island.go")};
|
||||
}
|
||||
});
|
||||
}.alias("go").alias("home").alias("h"));
|
||||
|
||||
/* /is spawn - Teleport player to spawn */
|
||||
addArgument(new String[]{"spawn"}, new ArgumentHandler(plugin, label, aliases, argumentsMap) {
|
||||
addArgument(new ArgumentHandler(label) {
|
||||
|
||||
@Override
|
||||
public CanUseResp canUse(CommandSender sender) {
|
||||
@ -195,10 +195,10 @@ public class IslandCommand extends AbstractCommand {
|
||||
public String[] usage(CommandSender sender) {
|
||||
return new String[]{null, getLocale(sender).get("help.island.spawn")};
|
||||
}
|
||||
});
|
||||
}.alias("spawn"));
|
||||
|
||||
/* /is create - Create an island for this player (show the schematic selection panel if enabled) */
|
||||
addArgument(new String[]{"create", "auto"}, new ArgumentHandler(plugin, label, aliases, argumentsMap) {
|
||||
addArgument(new ArgumentHandler(label) {
|
||||
|
||||
@Override
|
||||
public CanUseResp canUse(CommandSender sender) {
|
||||
@ -228,10 +228,10 @@ public class IslandCommand extends AbstractCommand {
|
||||
public String[] usage(CommandSender sender) {
|
||||
return new String[]{"[schematic]", getLocale(sender).get("help.island.create")};
|
||||
}
|
||||
});
|
||||
}.alias("create").alias("auto"));
|
||||
|
||||
/* /is info [player] - Display info about (specified) player's island*/
|
||||
addArgument(new String[]{"info"}, new ArgumentHandler(plugin, label, aliases, argumentsMap) {
|
||||
addArgument(new ArgumentHandler(label) {
|
||||
|
||||
@Override
|
||||
public CanUseResp canUse(CommandSender sender) {
|
||||
@ -255,10 +255,10 @@ public class IslandCommand extends AbstractCommand {
|
||||
public String[] usage(CommandSender sender) {
|
||||
return new String[]{"[player]", getLocale(sender).get("help.island.info")};
|
||||
}
|
||||
});
|
||||
}.alias("info"));
|
||||
|
||||
/* /is cp [<on/off>] - Open Control Panel or toggle it */
|
||||
addArgument(new String[]{"controlpanel", "cp"}, new ArgumentHandler(plugin, label, aliases, argumentsMap) {
|
||||
addArgument(new ArgumentHandler(label) {
|
||||
|
||||
@Override
|
||||
public CanUseResp canUse(CommandSender sender) {
|
||||
@ -282,10 +282,10 @@ public class IslandCommand extends AbstractCommand {
|
||||
public String[] usage(CommandSender sender) {
|
||||
return new String[]{"[on/off]", getLocale(sender).get("help.island.controlpanel")};
|
||||
}
|
||||
});
|
||||
}.alias("cp").alias("controlpanel"));
|
||||
|
||||
/* /is reset - Reset the island */
|
||||
addArgument(new String[]{"reset", "restart"}, new ArgumentHandler(plugin, label, aliases, argumentsMap) {
|
||||
addArgument(new ArgumentHandler(label) {
|
||||
|
||||
@Override
|
||||
public CanUseResp canUse(CommandSender sender) {
|
||||
@ -330,10 +330,10 @@ public class IslandCommand extends AbstractCommand {
|
||||
public String[] usage(CommandSender sender) {
|
||||
return new String[]{null, getLocale(sender).get("help.island.reset")};
|
||||
}
|
||||
});
|
||||
}.alias("reset").alias("restart"));
|
||||
|
||||
/* /is sethome - Set a home where the player is located */
|
||||
addArgument(new String[]{"sethome"}, new ArgumentHandler(plugin, label, aliases, argumentsMap) {
|
||||
addArgument(new ArgumentHandler(label) {
|
||||
|
||||
@Override
|
||||
public CanUseResp canUse(CommandSender sender) {
|
||||
@ -357,10 +357,10 @@ public class IslandCommand extends AbstractCommand {
|
||||
public String[] usage(CommandSender sender) {
|
||||
return new String[]{null, getLocale(sender).get("help.island.sethome")};
|
||||
}
|
||||
});
|
||||
}.alias("sethome"));
|
||||
|
||||
/* /is name <name> - Set island display name */
|
||||
addArgument(new String[]{"name"}, new ArgumentHandler(plugin, label, aliases, argumentsMap) {
|
||||
addArgument(new ArgumentHandler(label) {
|
||||
|
||||
@Override
|
||||
public CanUseResp canUse(CommandSender sender) {
|
||||
@ -418,10 +418,10 @@ public class IslandCommand extends AbstractCommand {
|
||||
public String[] usage(CommandSender sender) {
|
||||
return new String[]{"<name>", getLocale(sender).get("help.island.name")};
|
||||
}
|
||||
});
|
||||
}.alias("name"));
|
||||
|
||||
/* /is resetname - Reset island display name */
|
||||
addArgument(new String[]{"resetname"}, new ArgumentHandler(plugin, label, aliases, argumentsMap) {
|
||||
addArgument(new ArgumentHandler(label) {
|
||||
|
||||
@Override
|
||||
public CanUseResp canUse(CommandSender sender) {
|
||||
@ -456,10 +456,10 @@ public class IslandCommand extends AbstractCommand {
|
||||
public String[] usage(CommandSender sender) {
|
||||
return new String[]{null, getLocale(sender).get("help.island.resetname")};
|
||||
}
|
||||
});
|
||||
}.alias("resetname"));
|
||||
|
||||
/* /is team - Display island team info */
|
||||
addArgument(new String[]{"team"}, new ArgumentHandler(plugin, label, aliases, argumentsMap) {
|
||||
addArgument(new ArgumentHandler(label) {
|
||||
|
||||
@Override
|
||||
public CanUseResp canUse(CommandSender sender) {
|
||||
@ -530,10 +530,10 @@ public class IslandCommand extends AbstractCommand {
|
||||
|
||||
return new String[]{null, getLocale(sender).get("help.island.team")};
|
||||
}
|
||||
});
|
||||
}.alias("team"));
|
||||
|
||||
/* /is invite <player> - Invite a player to join the island */
|
||||
addArgument(new String[]{"invite"}, new ArgumentHandler(plugin, label, aliases, argumentsMap) {
|
||||
addArgument(new ArgumentHandler(label) {
|
||||
|
||||
@Override
|
||||
public CanUseResp canUse(CommandSender sender) {
|
||||
@ -657,10 +657,10 @@ public class IslandCommand extends AbstractCommand {
|
||||
public String[] usage(CommandSender sender) {
|
||||
return new String[]{"<player>", getLocale(sender).get("help.island.invite")};
|
||||
}
|
||||
});
|
||||
}.alias("invite"));
|
||||
|
||||
/* /is uninvite <player> - Deletes the invite to join the island */
|
||||
addArgument(new String[]{"uninvite"}, new ArgumentHandler(plugin, label, aliases, argumentsMap) {
|
||||
addArgument(new ArgumentHandler(label) {
|
||||
|
||||
@Override
|
||||
public CanUseResp canUse(CommandSender sender) {
|
||||
@ -698,10 +698,10 @@ public class IslandCommand extends AbstractCommand {
|
||||
public String[] usage(CommandSender sender) {
|
||||
return new String[]{"", getLocale(sender).get("help.island.uninvite")};
|
||||
}
|
||||
});
|
||||
}.alias("uninvite"));
|
||||
|
||||
/* /is leave - Leave the island */
|
||||
addArgument(new String[]{"leave"}, new ArgumentHandler(plugin, label, aliases, argumentsMap) {
|
||||
addArgument(new ArgumentHandler(label) {
|
||||
|
||||
@Override
|
||||
public CanUseResp canUse(CommandSender sender) {
|
||||
@ -776,10 +776,10 @@ public class IslandCommand extends AbstractCommand {
|
||||
public String[] usage(CommandSender sender) {
|
||||
return new String[]{null, getLocale(sender).get("help.island.leave")};
|
||||
}
|
||||
});
|
||||
}.alias("leave"));
|
||||
|
||||
/* /is kick <player> - Kick the specified player from island team */
|
||||
addArgument(new String[]{"kick"}, new ArgumentHandler(plugin, label, aliases, argumentsMap) {
|
||||
addArgument(new ArgumentHandler(label) {
|
||||
|
||||
@Override
|
||||
public CanUseResp canUse(CommandSender sender) {
|
||||
@ -859,10 +859,10 @@ public class IslandCommand extends AbstractCommand {
|
||||
public String[] usage(CommandSender sender) {
|
||||
return new String[]{"<player>", getLocale(sender).get("help.island.kick")};
|
||||
}
|
||||
});
|
||||
}.alias("kick"));
|
||||
|
||||
/* /is accept [player] - Accept invite */
|
||||
addArgument(new String[]{"accept"}, new ArgumentHandler(plugin, label, aliases, argumentsMap) {
|
||||
addArgument(new ArgumentHandler(label) {
|
||||
|
||||
@Override
|
||||
public CanUseResp canUse(CommandSender sender) {
|
||||
@ -950,10 +950,10 @@ public class IslandCommand extends AbstractCommand {
|
||||
public String[] usage(CommandSender sender) {
|
||||
return new String[]{"[player]", getLocale(sender).get("help.island.accept")};
|
||||
}
|
||||
});
|
||||
}.alias("accept"));
|
||||
|
||||
/* /is reject [player] - Reject invite */
|
||||
addArgument(new String[]{"reject"}, new ArgumentHandler(plugin, label, aliases, argumentsMap) {
|
||||
addArgument(new ArgumentHandler(label) {
|
||||
|
||||
@Override
|
||||
public CanUseResp canUse(CommandSender sender) {
|
||||
@ -998,10 +998,10 @@ public class IslandCommand extends AbstractCommand {
|
||||
public String[] usage(CommandSender sender) {
|
||||
return new String[]{"[player]", getLocale(sender).get("help.island.reject")};
|
||||
}
|
||||
});
|
||||
}.alias("reject"));
|
||||
|
||||
/* /is makeleader <player> - Set the specified player as leader/owner of the island */
|
||||
addArgument(new String[]{"makeleader", "transfer"}, new ArgumentHandler(plugin, label, aliases, argumentsMap) {
|
||||
addArgument(new ArgumentHandler(label) {
|
||||
|
||||
@Override
|
||||
public CanUseResp canUse(CommandSender sender) {
|
||||
@ -1114,10 +1114,10 @@ public class IslandCommand extends AbstractCommand {
|
||||
public String[] usage(CommandSender sender) {
|
||||
return new String[]{"<player>", getLocale(sender).get("help.island.makeleader")};
|
||||
}
|
||||
});
|
||||
}.alias("makeleader").alias("transfer"));
|
||||
|
||||
/* /is expel <player> - Expel a visitor/coop from the island */
|
||||
addArgument(new String[]{"expel"}, new ArgumentHandler(plugin, label, aliases, argumentsMap) {
|
||||
addArgument(new ArgumentHandler(label) {
|
||||
|
||||
@Override
|
||||
public CanUseResp canUse(CommandSender sender) {
|
||||
@ -1138,10 +1138,10 @@ public class IslandCommand extends AbstractCommand {
|
||||
public String[] usage(CommandSender sender) {
|
||||
return new String[]{"<player>", getLocale(sender).get("help.island.expel")};
|
||||
}
|
||||
});
|
||||
}.alias("expel"));
|
||||
|
||||
/* /is ban <player> - Ban a player from the island */
|
||||
addArgument(new String[]{"ban"}, new ArgumentHandler(plugin, label, aliases, argumentsMap) {
|
||||
addArgument(new ArgumentHandler(label) {
|
||||
|
||||
@Override
|
||||
public CanUseResp canUse(CommandSender sender) {
|
||||
@ -1162,10 +1162,10 @@ public class IslandCommand extends AbstractCommand {
|
||||
public String[] usage(CommandSender sender) {
|
||||
return new String[]{"<player>", getLocale(sender).get("help.island.ban")};
|
||||
}
|
||||
});
|
||||
}.alias("ban"));
|
||||
|
||||
/* /is unban <player> - Unban player from the island */
|
||||
addArgument(new String[]{"unban"}, new ArgumentHandler(plugin, label, aliases, argumentsMap) {
|
||||
addArgument(new ArgumentHandler(label) {
|
||||
|
||||
@Override
|
||||
public CanUseResp canUse(CommandSender sender) {
|
||||
@ -1186,10 +1186,10 @@ public class IslandCommand extends AbstractCommand {
|
||||
public String[] usage(CommandSender sender) {
|
||||
return new String[]{"<player>", getLocale(sender).get("help.island.unban")};
|
||||
}
|
||||
});
|
||||
}.alias("unban"));
|
||||
|
||||
/* /is banlist - Display island banned players */
|
||||
addArgument(new String[]{"banlist", "bl"}, new ArgumentHandler(plugin, label, aliases, argumentsMap) {
|
||||
addArgument(new ArgumentHandler(label) {
|
||||
|
||||
@Override
|
||||
public CanUseResp canUse(CommandSender sender) {
|
||||
@ -1211,10 +1211,10 @@ public class IslandCommand extends AbstractCommand {
|
||||
public String[] usage(CommandSender sender) {
|
||||
return new String[]{null, getLocale(sender).get("help.island.banlist")};
|
||||
}
|
||||
});
|
||||
}.alias("banlist").alias("bl"));
|
||||
|
||||
/* /is trust <player> - Trust a player */
|
||||
addArgument(new String[]{"trust"}, new ArgumentHandler(plugin, label, aliases, argumentsMap) {
|
||||
addArgument(new ArgumentHandler(label) {
|
||||
|
||||
@Override
|
||||
public CanUseResp canUse(CommandSender sender) {
|
||||
@ -1235,10 +1235,10 @@ public class IslandCommand extends AbstractCommand {
|
||||
public String[] usage(CommandSender sender) {
|
||||
return new String[]{"<player>", getLocale(sender).get("help.island.trust")};
|
||||
}
|
||||
});
|
||||
}.alias("trust"));
|
||||
|
||||
/* /is untrust <player> - Untrust a player */
|
||||
addArgument(new String[]{"untrust"}, new ArgumentHandler(plugin, label, aliases, argumentsMap) {
|
||||
addArgument(new ArgumentHandler(label) {
|
||||
|
||||
@Override
|
||||
public CanUseResp canUse(CommandSender sender) {
|
||||
@ -1259,10 +1259,10 @@ public class IslandCommand extends AbstractCommand {
|
||||
public String[] usage(CommandSender sender) {
|
||||
return new String[]{"<player>", getLocale(sender).get("help.island.untrust")};
|
||||
}
|
||||
});
|
||||
}.alias("untrust"));
|
||||
|
||||
/* /is trustlist - Display trust players */
|
||||
addArgument(new String[]{"trustlist", "tl"}, new ArgumentHandler(plugin, label, aliases, argumentsMap) {
|
||||
addArgument(new ArgumentHandler(label) {
|
||||
|
||||
@Override
|
||||
public CanUseResp canUse(CommandSender sender) {
|
||||
@ -1283,10 +1283,10 @@ public class IslandCommand extends AbstractCommand {
|
||||
public String[] usage(CommandSender sender) {
|
||||
return new String[]{null, getLocale(sender).get("help.island.trustlist")};
|
||||
}
|
||||
});
|
||||
}.alias("trustlist").alias("tl"));
|
||||
|
||||
/* /is coop <player> - Coop a player */
|
||||
addArgument(new String[]{"coop"}, new ArgumentHandler(plugin, label, aliases, argumentsMap) {
|
||||
addArgument(new ArgumentHandler(label) {
|
||||
|
||||
@Override
|
||||
public CanUseResp canUse(CommandSender sender) {
|
||||
@ -1307,10 +1307,10 @@ public class IslandCommand extends AbstractCommand {
|
||||
public String[] usage(CommandSender sender) {
|
||||
return new String[]{"<player>", getLocale(sender).get("help.island.coop")};
|
||||
}
|
||||
});
|
||||
}.alias("coop"));
|
||||
|
||||
/* /is uncoop <player> - Uncoop a player */
|
||||
addArgument(new String[]{"uncoop"}, new ArgumentHandler(plugin, label, aliases, argumentsMap) {
|
||||
addArgument(new ArgumentHandler(label) {
|
||||
|
||||
@Override
|
||||
public CanUseResp canUse(CommandSender sender) {
|
||||
@ -1331,10 +1331,10 @@ public class IslandCommand extends AbstractCommand {
|
||||
public String[] usage(CommandSender sender) {
|
||||
return new String[]{"<player>", getLocale(sender).get("help.island.uncoop")};
|
||||
}
|
||||
});
|
||||
}.alias("uncoop"));
|
||||
|
||||
/* /is cooplist - Display coop players */
|
||||
addArgument(new String[]{"cooplist", "cl"}, new ArgumentHandler(plugin, label, aliases, argumentsMap) {
|
||||
addArgument(new ArgumentHandler(label) {
|
||||
|
||||
@Override
|
||||
public CanUseResp canUse(CommandSender sender) {
|
||||
@ -1355,10 +1355,10 @@ public class IslandCommand extends AbstractCommand {
|
||||
public String[] usage(CommandSender sender) {
|
||||
return new String[]{null, getLocale(sender).get("help.island.cooplist")};
|
||||
}
|
||||
});
|
||||
}.alias("cooplist").alias("cl"));
|
||||
|
||||
/* /is lock - Toggle island lock */
|
||||
addArgument(new String[]{"lock", "unlock"}, new ArgumentHandler(plugin, label, aliases, argumentsMap) {
|
||||
addArgument(new ArgumentHandler(label) {
|
||||
|
||||
@Override
|
||||
public CanUseResp canUse(CommandSender sender) {
|
||||
@ -1397,10 +1397,10 @@ public class IslandCommand extends AbstractCommand {
|
||||
public String[] usage(CommandSender sender) {
|
||||
return new String[]{null, getLocale(sender).get("help.island.lock")};
|
||||
}
|
||||
});
|
||||
}.alias("lock").alias("unlock"));
|
||||
|
||||
/* /is settings - Display Settings menu */
|
||||
addArgument(new String[]{"settings"}, new ArgumentHandler(plugin, label, aliases, argumentsMap) {
|
||||
addArgument(new ArgumentHandler(label) {
|
||||
|
||||
@Override
|
||||
public CanUseResp canUse(CommandSender sender) {
|
||||
@ -1421,10 +1421,10 @@ public class IslandCommand extends AbstractCommand {
|
||||
public String[] usage(CommandSender sender) {
|
||||
return new String[]{null, getLocale(sender).get("help.island.settings")};
|
||||
}
|
||||
});
|
||||
}.alias("settings"));
|
||||
|
||||
/* /is language <id> - Set the language */
|
||||
addArgument(new String[]{"language", "lang"}, new ArgumentHandler(plugin, label, aliases, argumentsMap) {
|
||||
addArgument(new ArgumentHandler(label) {
|
||||
|
||||
@Override
|
||||
public CanUseResp canUse(CommandSender sender) {
|
||||
@ -1445,7 +1445,7 @@ public class IslandCommand extends AbstractCommand {
|
||||
public String[] usage(CommandSender sender) {
|
||||
return new String[]{"<id>", getLocale(sender).get("help.island.language")};
|
||||
}
|
||||
});
|
||||
}.alias("language").alias("lang"));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1468,7 +1468,7 @@ public class IslandCommand extends AbstractCommand {
|
||||
getIslands().newIsland(player, schematic);
|
||||
}
|
||||
|
||||
public void addSubCommand(String[] names, ArgumentHandler handler) {
|
||||
addArgument(names, handler);
|
||||
public void addSubCommand(ArgumentHandler handler) {
|
||||
addArgument(handler);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user