Enabled subcommand addition to BSkyBlock /island command.

This is a bit of a hack. The AbstractCommand class had to be pulled
apart to enable the ArgumentHandler to be imported by another plugin
without the other plugin having to extend AbstractCommand, which is
something it does not want to do because it is not defining a new
command, but just adding arguments. 

There's too much passing of arguments in this implementation, but it
works. I'll see if I can simplify it.
This commit is contained in:
tastybento 2017-10-09 22:52:57 -07:00
parent 6314f1377e
commit 7804c4a867
7 changed files with 188 additions and 135 deletions

View File

@ -64,7 +64,7 @@
<dependency> <dependency>
<groupId>org.bukkit</groupId> <groupId>org.bukkit</groupId>
<artifactId>bukkit</artifactId> <artifactId>bukkit</artifactId>
<version>1.12.1-R0.1-SNAPSHOT</version> <version>1.12.2-R0.1-SNAPSHOT</version>
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>
<dependency> <dependency>

View File

@ -58,6 +58,8 @@ public class BSkyBlock extends JavaPlugin{
// Metrics // Metrics
private Metrics metrics; private Metrics metrics;
private IslandCommand islandCommand;
@Override @Override
public void onEnable(){ public void onEnable(){
plugin = this; plugin = this;
@ -84,6 +86,9 @@ public class BSkyBlock extends JavaPlugin{
VaultHelper.setupPermissions(); VaultHelper.setupPermissions();
// Set up commands
islandCommand = new IslandCommand(BSkyBlock.this);
// These items have to be loaded when the server has done 1 tick. // These items have to be loaded when the server has done 1 tick.
// Note Worlds are not loaded this early, so any Locations or World reference will be null // Note Worlds are not loaded this early, so any Locations or World reference will be null
// at this point. Therefore, the 1 tick scheduler is required. // at this point. Therefore, the 1 tick scheduler is required.
@ -111,7 +116,7 @@ public class BSkyBlock extends JavaPlugin{
Settings.defaultLanguage = "en-US"; Settings.defaultLanguage = "en-US";
loadLocales(); loadLocales();
new IslandCommand(BSkyBlock.this);
new AdminCommand(BSkyBlock.this); new AdminCommand(BSkyBlock.this);
// Register Listeners // Register Listeners
@ -145,6 +150,10 @@ public class BSkyBlock extends JavaPlugin{
} }
} }
public IslandCommand getIslandCommand() {
return islandCommand;
}
protected void registerListeners() { protected void registerListeners() {
PluginManager manager = getServer().getPluginManager(); PluginManager manager = getServer().getPluginManager();
// Player join events // Player join events

View File

@ -31,7 +31,7 @@ public abstract class AbstractCommand implements CommandExecutor, TabCompleter {
private BSkyBlock plugin; private BSkyBlock plugin;
private final Map<String, ArgumentHandler> argumentsMap; public final Map<String, ArgumentHandler> argumentsMap;
private final Map<String, String> aliasesMap; private final Map<String, String> aliasesMap;
public final String label; public final String label;
@ -59,7 +59,7 @@ public abstract class AbstractCommand implements CommandExecutor, TabCompleter {
// Register the help argument if needed // Register the help argument if needed
if (help) { if (help) {
addArgument(new String[]{"help", "?"}, new ArgumentHandler() { addArgument(new String[]{"help", "?"}, new ArgumentHandler(plugin, label, aliases, argumentsMap) {
@Override @Override
public CanUseResp canUse(CommandSender sender) { public CanUseResp canUse(CommandSender sender) {
return new CanUseResp(true); // If the player has access to this command, he can get help return new CanUseResp(true); // If the player has access to this command, he can get help
@ -91,43 +91,7 @@ public abstract class AbstractCommand implements CommandExecutor, TabCompleter {
setup(); setup();
} }
/**
*
*/
public abstract class ArgumentHandler {
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 String getShortDescription(CommandSender sender) {
String msg = plugin.getLocale(sender).get("help.syntax");
msg = msg.replace("[label]", (aliases[0] != null) ? aliases[0] : 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)) {
cmds += plugin.getLocale(sender).get("help.syntax-alias-separator") + alias;
}
msg = msg.replace("[command]", cmds);
String[] usage = argumentsMap.get(command).usage(sender);
if (usage == null) usage = new String[2];
msg = msg.replace("[args]", (usage[0] != null) ? usage[0] : "")
.replace("[info]", (usage[1] != null) ? usage[1] : "");
return msg;
}
}
public abstract void setup(); public abstract void setup();
@ -179,16 +143,6 @@ public abstract class AbstractCommand implements CommandExecutor, TabCompleter {
else return alias; else return alias;
} }
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;
}
@Override @Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
checkForPlayer(sender); checkForPlayer(sender);
@ -285,58 +239,6 @@ public abstract class AbstractCommand implements CommandExecutor, TabCompleter {
} }
/**
* Response class for the canUse check
* @author tastybento
*
*/
public class CanUseResp {
private boolean allowed;
private String errorResponse; // May be shown if required
/**
* Cannot use situation
* @param errorResponse - error response
*/
public CanUseResp(String errorResponse) {
this.allowed = false;
this.errorResponse = errorResponse;
}
/**
* Can or cannot use situation, no error response.
* @param b
*/
public CanUseResp(boolean b) {
this.allowed = b;
this.errorResponse = "";
}
/**
* @return the allowed
*/
public boolean isAllowed() {
return allowed;
}
/**
* @param allowed the allowed to set
*/
public void setAllowed(boolean allowed) {
this.allowed = allowed;
}
/**
* @return the errorResponse
*/
public String getErrorResponse() {
return errorResponse;
}
/**
* @param errorResponse the errorResponse to set
*/
public void setErrorResponse(String errorResponse) {
this.errorResponse = errorResponse;
}
}
// These methods below just neaten up the code in the commands so "plugin." isn't always used // These methods below just neaten up the code in the commands so "plugin." isn't always used
/** /**
* @return PlayersManager * @return PlayersManager
@ -365,4 +267,10 @@ public abstract class AbstractCommand implements CommandExecutor, TabCompleter {
return plugin.getLocale(uuid); return plugin.getLocale(uuid);
} }
public Map<String, ArgumentHandler> getArgumentsMap() {
return argumentsMap;
}
} }

View File

@ -0,0 +1,75 @@
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;
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 final String label;
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) {
super();
this.plugin = plugin;
this.argumentsMap = new LinkedHashMap<>();
this.aliasesMap = new HashMap<>();
this.label = label;
this.aliases = aliases;
this.argumentsMap = argumentsMap;
}
public String getShortDescription(CommandSender sender) {
String msg = BSkyBlock.getPlugin().getLocale(sender).get("help.syntax");
msg = msg.replace("[label]", (aliases[0] != null) ? aliases[0] : 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)) {
cmds += plugin.getLocale(sender).get("help.syntax-alias-separator") + alias;
}
msg = msg.replace("[command]", cmds);
String[] usage = argumentsMap.get(command).usage(sender);
if (usage == null) usage = new String[2];
msg = msg.replace("[args]", (usage[0] != null) ? usage[0] : "")
.replace("[info]", (usage[1] != null) ? usage[1] : "");
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;
}
}

View File

@ -0,0 +1,53 @@
package us.tastybento.bskyblock.api.commands;
/**
* Response class for the canUse check
* @author tastybento
*
*/
public class CanUseResp {
private boolean allowed;
String errorResponse; // May be shown if required
/**
* Cannot use situation
* @param errorResponse - error response
*/
public CanUseResp(String errorResponse) {
this.allowed = false;
this.errorResponse = errorResponse;
}
/**
* Can or cannot use situation, no error response.
* @param b
*/
public CanUseResp(boolean b) {
this.allowed = b;
this.errorResponse = "";
}
/**
* @return the allowed
*/
public boolean isAllowed() {
return allowed;
}
/**
* @param allowed the allowed to set
*/
public void setAllowed(boolean allowed) {
this.allowed = allowed;
}
/**
* @return the errorResponse
*/
public String getErrorResponse() {
return errorResponse;
}
/**
* @param errorResponse the errorResponse to set
*/
public void setErrorResponse(String errorResponse) {
this.errorResponse = errorResponse;
}
}

View File

@ -13,6 +13,8 @@ import org.bukkit.permissions.PermissionAttachmentInfo;
import us.tastybento.bskyblock.BSkyBlock; import us.tastybento.bskyblock.BSkyBlock;
import us.tastybento.bskyblock.api.commands.AbstractCommand; import us.tastybento.bskyblock.api.commands.AbstractCommand;
import us.tastybento.bskyblock.api.commands.ArgumentHandler;
import us.tastybento.bskyblock.api.commands.CanUseResp;
import us.tastybento.bskyblock.api.events.team.TeamEvent; import us.tastybento.bskyblock.api.events.team.TeamEvent;
import us.tastybento.bskyblock.api.events.team.TeamEvent.TeamReason; import us.tastybento.bskyblock.api.events.team.TeamEvent.TeamReason;
import us.tastybento.bskyblock.config.Settings; import us.tastybento.bskyblock.config.Settings;
@ -39,7 +41,7 @@ public class AdminCommand extends AbstractCommand {
@Override @Override
public void setup() { public void setup() {
/* /asadmin delete <name> - delete name's island */ /* /asadmin delete <name> - delete name's island */
addArgument(new String[] {"delete"}, new ArgumentHandler() { addArgument(new String[] {"delete"}, new ArgumentHandler(plugin, label, aliases, argumentsMap) {
@Override @Override
public CanUseResp canUse(CommandSender sender) { public CanUseResp canUse(CommandSender sender) {
@ -63,7 +65,7 @@ public class AdminCommand extends AbstractCommand {
}); });
/* /asadmin team - manage teams */ /* /asadmin team - manage teams */
addArgument(new String[] {"team"}, new ArgumentHandler() { addArgument(new String[] {"team"}, new ArgumentHandler(plugin, label, aliases, argumentsMap) {
@Override @Override
public CanUseResp canUse(CommandSender sender) { public CanUseResp canUse(CommandSender sender) {

View File

@ -21,6 +21,8 @@ import com.google.common.collect.HashBiMap;
import us.tastybento.bskyblock.BSkyBlock; import us.tastybento.bskyblock.BSkyBlock;
import us.tastybento.bskyblock.api.commands.AbstractCommand; import us.tastybento.bskyblock.api.commands.AbstractCommand;
import us.tastybento.bskyblock.api.commands.ArgumentHandler;
import us.tastybento.bskyblock.api.commands.CanUseResp;
import us.tastybento.bskyblock.api.events.team.TeamEvent; import us.tastybento.bskyblock.api.events.team.TeamEvent;
import us.tastybento.bskyblock.api.events.team.TeamEvent.TeamReason; import us.tastybento.bskyblock.api.events.team.TeamEvent.TeamReason;
import us.tastybento.bskyblock.config.Settings; import us.tastybento.bskyblock.config.Settings;
@ -83,7 +85,7 @@ public class IslandCommand extends AbstractCommand {
@Override @Override
public void setup() { public void setup() {
/* /is about - Display plugin's info (license, version, authors) */ /* /is about - Display plugin's info (license, version, authors) */
addArgument(new String[]{"about"}, new ArgumentHandler() { addArgument(new String[]{"about"}, new ArgumentHandler(plugin, label, aliases, argumentsMap) {
@Override @Override
public CanUseResp canUse(CommandSender sender) { public CanUseResp canUse(CommandSender sender) {
@ -135,7 +137,7 @@ public class IslandCommand extends AbstractCommand {
}); });
/* /is go [<1-x>] - Teleport player to his island or the specified home */ /* /is go [<1-x>] - Teleport player to his island or the specified home */
addArgument(new String[]{"go", "home", "h"}, new ArgumentHandler() { addArgument(new String[]{"go", "home", "h"}, new ArgumentHandler(plugin, label, aliases, argumentsMap) {
@Override @Override
public CanUseResp canUse(CommandSender sender) { public CanUseResp canUse(CommandSender sender) {
@ -169,7 +171,7 @@ public class IslandCommand extends AbstractCommand {
}); });
/* /is spawn - Teleport player to spawn */ /* /is spawn - Teleport player to spawn */
addArgument(new String[]{"spawn"}, new ArgumentHandler() { addArgument(new String[]{"spawn"}, new ArgumentHandler(plugin, label, aliases, argumentsMap) {
@Override @Override
public CanUseResp canUse(CommandSender sender) { public CanUseResp canUse(CommandSender sender) {
@ -196,7 +198,7 @@ public class IslandCommand extends AbstractCommand {
}); });
/* /is create - Create an island for this player (show the schematic selection panel if enabled) */ /* /is create - Create an island for this player (show the schematic selection panel if enabled) */
addArgument(new String[]{"create", "auto"}, new ArgumentHandler() { addArgument(new String[]{"create", "auto"}, new ArgumentHandler(plugin, label, aliases, argumentsMap) {
@Override @Override
public CanUseResp canUse(CommandSender sender) { public CanUseResp canUse(CommandSender sender) {
@ -229,7 +231,7 @@ public class IslandCommand extends AbstractCommand {
}); });
/* /is info [player] - Display info about (specified) player's island*/ /* /is info [player] - Display info about (specified) player's island*/
addArgument(new String[]{"info"}, new ArgumentHandler() { addArgument(new String[]{"info"}, new ArgumentHandler(plugin, label, aliases, argumentsMap) {
@Override @Override
public CanUseResp canUse(CommandSender sender) { public CanUseResp canUse(CommandSender sender) {
@ -256,7 +258,7 @@ public class IslandCommand extends AbstractCommand {
}); });
/* /is cp [<on/off>] - Open Control Panel or toggle it */ /* /is cp [<on/off>] - Open Control Panel or toggle it */
addArgument(new String[]{"controlpanel", "cp"}, new ArgumentHandler() { addArgument(new String[]{"controlpanel", "cp"}, new ArgumentHandler(plugin, label, aliases, argumentsMap) {
@Override @Override
public CanUseResp canUse(CommandSender sender) { public CanUseResp canUse(CommandSender sender) {
@ -283,7 +285,7 @@ public class IslandCommand extends AbstractCommand {
}); });
/* /is reset - Reset the island */ /* /is reset - Reset the island */
addArgument(new String[]{"reset", "restart"}, new ArgumentHandler() { addArgument(new String[]{"reset", "restart"}, new ArgumentHandler(plugin, label, aliases, argumentsMap) {
@Override @Override
public CanUseResp canUse(CommandSender sender) { public CanUseResp canUse(CommandSender sender) {
@ -331,7 +333,7 @@ public class IslandCommand extends AbstractCommand {
}); });
/* /is sethome - Set a home where the player is located */ /* /is sethome - Set a home where the player is located */
addArgument(new String[]{"sethome"}, new ArgumentHandler() { addArgument(new String[]{"sethome"}, new ArgumentHandler(plugin, label, aliases, argumentsMap) {
@Override @Override
public CanUseResp canUse(CommandSender sender) { public CanUseResp canUse(CommandSender sender) {
@ -358,7 +360,7 @@ public class IslandCommand extends AbstractCommand {
}); });
/* /is name <name> - Set island display name */ /* /is name <name> - Set island display name */
addArgument(new String[]{"name"}, new ArgumentHandler() { addArgument(new String[]{"name"}, new ArgumentHandler(plugin, label, aliases, argumentsMap) {
@Override @Override
public CanUseResp canUse(CommandSender sender) { public CanUseResp canUse(CommandSender sender) {
@ -419,7 +421,7 @@ public class IslandCommand extends AbstractCommand {
}); });
/* /is resetname - Reset island display name */ /* /is resetname - Reset island display name */
addArgument(new String[]{"resetname"}, new ArgumentHandler() { addArgument(new String[]{"resetname"}, new ArgumentHandler(plugin, label, aliases, argumentsMap) {
@Override @Override
public CanUseResp canUse(CommandSender sender) { public CanUseResp canUse(CommandSender sender) {
@ -457,7 +459,7 @@ public class IslandCommand extends AbstractCommand {
}); });
/* /is team - Display island team info */ /* /is team - Display island team info */
addArgument(new String[]{"team"}, new ArgumentHandler() { addArgument(new String[]{"team"}, new ArgumentHandler(plugin, label, aliases, argumentsMap) {
@Override @Override
public CanUseResp canUse(CommandSender sender) { public CanUseResp canUse(CommandSender sender) {
@ -531,7 +533,7 @@ public class IslandCommand extends AbstractCommand {
}); });
/* /is invite <player> - Invite a player to join the island */ /* /is invite <player> - Invite a player to join the island */
addArgument(new String[]{"invite"}, new ArgumentHandler() { addArgument(new String[]{"invite"}, new ArgumentHandler(plugin, label, aliases, argumentsMap) {
@Override @Override
public CanUseResp canUse(CommandSender sender) { public CanUseResp canUse(CommandSender sender) {
@ -658,7 +660,7 @@ public class IslandCommand extends AbstractCommand {
}); });
/* /is uninvite <player> - Deletes the invite to join the island */ /* /is uninvite <player> - Deletes the invite to join the island */
addArgument(new String[]{"uninvite"}, new ArgumentHandler() { addArgument(new String[]{"uninvite"}, new ArgumentHandler(plugin, label, aliases, argumentsMap) {
@Override @Override
public CanUseResp canUse(CommandSender sender) { public CanUseResp canUse(CommandSender sender) {
@ -699,7 +701,7 @@ public class IslandCommand extends AbstractCommand {
}); });
/* /is leave - Leave the island */ /* /is leave - Leave the island */
addArgument(new String[]{"leave"}, new ArgumentHandler() { addArgument(new String[]{"leave"}, new ArgumentHandler(plugin, label, aliases, argumentsMap) {
@Override @Override
public CanUseResp canUse(CommandSender sender) { public CanUseResp canUse(CommandSender sender) {
@ -777,7 +779,7 @@ public class IslandCommand extends AbstractCommand {
}); });
/* /is kick <player> - Kick the specified player from island team */ /* /is kick <player> - Kick the specified player from island team */
addArgument(new String[]{"kick"}, new ArgumentHandler() { addArgument(new String[]{"kick"}, new ArgumentHandler(plugin, label, aliases, argumentsMap) {
@Override @Override
public CanUseResp canUse(CommandSender sender) { public CanUseResp canUse(CommandSender sender) {
@ -860,7 +862,7 @@ public class IslandCommand extends AbstractCommand {
}); });
/* /is accept [player] - Accept invite */ /* /is accept [player] - Accept invite */
addArgument(new String[]{"accept"}, new ArgumentHandler() { addArgument(new String[]{"accept"}, new ArgumentHandler(plugin, label, aliases, argumentsMap) {
@Override @Override
public CanUseResp canUse(CommandSender sender) { public CanUseResp canUse(CommandSender sender) {
@ -951,7 +953,7 @@ public class IslandCommand extends AbstractCommand {
}); });
/* /is reject [player] - Reject invite */ /* /is reject [player] - Reject invite */
addArgument(new String[]{"reject"}, new ArgumentHandler() { addArgument(new String[]{"reject"}, new ArgumentHandler(plugin, label, aliases, argumentsMap) {
@Override @Override
public CanUseResp canUse(CommandSender sender) { public CanUseResp canUse(CommandSender sender) {
@ -999,7 +1001,7 @@ public class IslandCommand extends AbstractCommand {
}); });
/* /is makeleader <player> - Set the specified player as leader/owner of the island */ /* /is makeleader <player> - Set the specified player as leader/owner of the island */
addArgument(new String[]{"makeleader", "transfer"}, new ArgumentHandler() { addArgument(new String[]{"makeleader", "transfer"}, new ArgumentHandler(plugin, label, aliases, argumentsMap) {
@Override @Override
public CanUseResp canUse(CommandSender sender) { public CanUseResp canUse(CommandSender sender) {
@ -1115,7 +1117,7 @@ public class IslandCommand extends AbstractCommand {
}); });
/* /is expel <player> - Expel a visitor/coop from the island */ /* /is expel <player> - Expel a visitor/coop from the island */
addArgument(new String[]{"expel"}, new ArgumentHandler() { addArgument(new String[]{"expel"}, new ArgumentHandler(plugin, label, aliases, argumentsMap) {
@Override @Override
public CanUseResp canUse(CommandSender sender) { public CanUseResp canUse(CommandSender sender) {
@ -1139,7 +1141,7 @@ public class IslandCommand extends AbstractCommand {
}); });
/* /is ban <player> - Ban a player from the island */ /* /is ban <player> - Ban a player from the island */
addArgument(new String[]{"ban"}, new ArgumentHandler() { addArgument(new String[]{"ban"}, new ArgumentHandler(plugin, label, aliases, argumentsMap) {
@Override @Override
public CanUseResp canUse(CommandSender sender) { public CanUseResp canUse(CommandSender sender) {
@ -1163,7 +1165,7 @@ public class IslandCommand extends AbstractCommand {
}); });
/* /is unban <player> - Unban player from the island */ /* /is unban <player> - Unban player from the island */
addArgument(new String[]{"unban"}, new ArgumentHandler() { addArgument(new String[]{"unban"}, new ArgumentHandler(plugin, label, aliases, argumentsMap) {
@Override @Override
public CanUseResp canUse(CommandSender sender) { public CanUseResp canUse(CommandSender sender) {
@ -1187,7 +1189,7 @@ public class IslandCommand extends AbstractCommand {
}); });
/* /is banlist - Display island banned players */ /* /is banlist - Display island banned players */
addArgument(new String[]{"banlist", "bl"}, new ArgumentHandler() { addArgument(new String[]{"banlist", "bl"}, new ArgumentHandler(plugin, label, aliases, argumentsMap) {
@Override @Override
public CanUseResp canUse(CommandSender sender) { public CanUseResp canUse(CommandSender sender) {
@ -1212,7 +1214,7 @@ public class IslandCommand extends AbstractCommand {
}); });
/* /is trust <player> - Trust a player */ /* /is trust <player> - Trust a player */
addArgument(new String[]{"trust"}, new ArgumentHandler() { addArgument(new String[]{"trust"}, new ArgumentHandler(plugin, label, aliases, argumentsMap) {
@Override @Override
public CanUseResp canUse(CommandSender sender) { public CanUseResp canUse(CommandSender sender) {
@ -1236,7 +1238,7 @@ public class IslandCommand extends AbstractCommand {
}); });
/* /is untrust <player> - Untrust a player */ /* /is untrust <player> - Untrust a player */
addArgument(new String[]{"untrust"}, new ArgumentHandler() { addArgument(new String[]{"untrust"}, new ArgumentHandler(plugin, label, aliases, argumentsMap) {
@Override @Override
public CanUseResp canUse(CommandSender sender) { public CanUseResp canUse(CommandSender sender) {
@ -1260,7 +1262,7 @@ public class IslandCommand extends AbstractCommand {
}); });
/* /is trustlist - Display trust players */ /* /is trustlist - Display trust players */
addArgument(new String[]{"trustlist", "tl"}, new ArgumentHandler() { addArgument(new String[]{"trustlist", "tl"}, new ArgumentHandler(plugin, label, aliases, argumentsMap) {
@Override @Override
public CanUseResp canUse(CommandSender sender) { public CanUseResp canUse(CommandSender sender) {
@ -1284,7 +1286,7 @@ public class IslandCommand extends AbstractCommand {
}); });
/* /is coop <player> - Coop a player */ /* /is coop <player> - Coop a player */
addArgument(new String[]{"coop"}, new ArgumentHandler() { addArgument(new String[]{"coop"}, new ArgumentHandler(plugin, label, aliases, argumentsMap) {
@Override @Override
public CanUseResp canUse(CommandSender sender) { public CanUseResp canUse(CommandSender sender) {
@ -1308,7 +1310,7 @@ public class IslandCommand extends AbstractCommand {
}); });
/* /is uncoop <player> - Uncoop a player */ /* /is uncoop <player> - Uncoop a player */
addArgument(new String[]{"uncoop"}, new ArgumentHandler() { addArgument(new String[]{"uncoop"}, new ArgumentHandler(plugin, label, aliases, argumentsMap) {
@Override @Override
public CanUseResp canUse(CommandSender sender) { public CanUseResp canUse(CommandSender sender) {
@ -1332,7 +1334,7 @@ public class IslandCommand extends AbstractCommand {
}); });
/* /is cooplist - Display coop players */ /* /is cooplist - Display coop players */
addArgument(new String[]{"cooplist", "cl"}, new ArgumentHandler() { addArgument(new String[]{"cooplist", "cl"}, new ArgumentHandler(plugin, label, aliases, argumentsMap) {
@Override @Override
public CanUseResp canUse(CommandSender sender) { public CanUseResp canUse(CommandSender sender) {
@ -1356,7 +1358,7 @@ public class IslandCommand extends AbstractCommand {
}); });
/* /is lock - Toggle island lock */ /* /is lock - Toggle island lock */
addArgument(new String[]{"lock", "unlock"}, new ArgumentHandler() { addArgument(new String[]{"lock", "unlock"}, new ArgumentHandler(plugin, label, aliases, argumentsMap) {
@Override @Override
public CanUseResp canUse(CommandSender sender) { public CanUseResp canUse(CommandSender sender) {
@ -1398,7 +1400,7 @@ public class IslandCommand extends AbstractCommand {
}); });
/* /is settings - Display Settings menu */ /* /is settings - Display Settings menu */
addArgument(new String[]{"settings"}, new ArgumentHandler() { addArgument(new String[]{"settings"}, new ArgumentHandler(plugin, label, aliases, argumentsMap) {
@Override @Override
public CanUseResp canUse(CommandSender sender) { public CanUseResp canUse(CommandSender sender) {
@ -1422,7 +1424,7 @@ public class IslandCommand extends AbstractCommand {
}); });
/* /is language <id> - Set the language */ /* /is language <id> - Set the language */
addArgument(new String[]{"language", "lang"}, new ArgumentHandler() { addArgument(new String[]{"language", "lang"}, new ArgumentHandler(plugin, label, aliases, argumentsMap) {
@Override @Override
public CanUseResp canUse(CommandSender sender) { public CanUseResp canUse(CommandSender sender) {
@ -1465,4 +1467,8 @@ public class IslandCommand extends AbstractCommand {
Schematic schematic = plugin.getSchematics().getSchematic("default"); Schematic schematic = plugin.getSchematics().getSchematic("default");
getIslands().newIsland(player, schematic); getIslands().newIsland(player, schematic);
} }
public void addSubCommand(String[] names, ArgumentHandler handler) {
addArgument(names, handler);
}
} }