Merge remote-tracking branch 'origin/develop' into develop

Conflicts:
	locales/bsb_en_US.yml
This commit is contained in:
tastybento 2017-08-08 20:51:07 -07:00
commit 71d82c9bd5
5 changed files with 33 additions and 5 deletions

View File

@ -39,10 +39,16 @@ general:
use-in-game: "This command is only available in game." use-in-game: "This command is only available in game."
no-team: "You do not have a team!" no-team: "You do not have a team!"
no-island: "You do not have an island!" no-island: "You do not have an island!"
already-have-island: "You already have an island!"
not-leader: "You are not the leader of your island!" not-leader: "You are not the leader of your island!"
offline-player: "That player is offline or doesn't exist." offline-player: "That player is offline or doesn't exist."
unknown-player: "Unknown player!" unknown-player: "Unknown player!"
help:
header: "&7=========== BSKYBLOCK ==========="
syntax: " &7/&b[label] &c[command] &a[args] &7: &e[info]"
end: "&7================================="
# TODO: These are legacy strings and should be converted to a better format but will do for now # TODO: These are legacy strings and should be converted to a better format but will do for now
acidBottle: "Acid Bottle" acidBottle: "Acid Bottle"
acidBucket: "Acid Bucket" acidBucket: "Acid Bucket"

View File

@ -13,7 +13,7 @@ loadbefore: [Multiverse-Core]
commands: commands:
island: island:
description: Main player command description: Main player command
aliases: [is, island] aliases: [is]
usage: | usage: |
/island help /island help
bsadmin: bsadmin:

View File

@ -22,6 +22,7 @@ public abstract class AbstractCommand implements CommandExecutor, TabCompleter {
private final Map<String, String> aliasesMap; private final Map<String, String> aliasesMap;
public final String label; public final String label;
public final String[] aliases;
public boolean isPlayer; public boolean isPlayer;
public boolean inTeam; public boolean inTeam;
public UUID teamLeaderUUID; public UUID teamLeaderUUID;
@ -32,11 +33,12 @@ public abstract class AbstractCommand implements CommandExecutor, TabCompleter {
private final boolean help; private final boolean help;
private static final int MAX_PER_PAGE = 7; private static final int MAX_PER_PAGE = 7;
protected AbstractCommand(BSkyBlock plugin, String label, boolean help) { protected AbstractCommand(BSkyBlock plugin, String label, String[] aliases, boolean help) {
this.plugin = plugin; this.plugin = plugin;
this.argumentsMap = new HashMap<>(1); this.argumentsMap = new LinkedHashMap<>(1);
this.aliasesMap = new HashMap<>(1); this.aliasesMap = new HashMap<>(1);
this.label = label; this.label = label;
this.aliases = aliases;
this.help = help; this.help = help;
this.teamMembers = new HashSet<UUID>(1); this.teamMembers = new HashSet<UUID>(1);
@ -50,7 +52,27 @@ public abstract class AbstractCommand implements CommandExecutor, TabCompleter {
@Override @Override
public void execute(CommandSender sender, String[] args) { public void execute(CommandSender sender, String[] args) {
List<String> help = new ArrayList<>();
for(String arg : argumentsMap.keySet()) {
String[] usage = argumentsMap.get(arg).usage(sender);
if (usage == null) usage = new String[2];
System.out.println(label);
System.out.println(arg);
System.out.println(usage[0]);
System.out.println(usage[1]);
String msg = plugin.getLocale(sender).get("help.syntax").replace("[label]", (aliases[0] != null) ? aliases[0] : label)
.replace("[command]", arg)
.replace("[args]", (usage != null && usage[0] != null) ? usage[0] : "")
.replace("[info]", (usage != null && usage[1] != null) ? usage[1] : "");
help.add(msg);
}
Util.sendMessage(sender, plugin.getLocale(sender).get("help.header"));
for(String cmd : help) Util.sendMessage(sender, cmd);
Util.sendMessage(sender, plugin.getLocale(sender).get("help.end"));
} }
@Override @Override

View File

@ -12,7 +12,7 @@ public class AdminCommand extends AbstractCommand {
BSkyBlock plugin; BSkyBlock plugin;
public AdminCommand(BSkyBlock plugin) { public AdminCommand(BSkyBlock plugin) {
super(plugin, Settings.ADMINCOMMAND, true); super(plugin, Settings.ADMINCOMMAND, new String[0], true);
plugin.getCommand(Settings.ADMINCOMMAND).setExecutor(this); plugin.getCommand(Settings.ADMINCOMMAND).setExecutor(this);
plugin.getCommand(Settings.ADMINCOMMAND).setTabCompleter(this); plugin.getCommand(Settings.ADMINCOMMAND).setTabCompleter(this);
this.plugin = plugin; this.plugin = plugin;

View File

@ -40,7 +40,7 @@ public class IslandCommand extends AbstractCommand {
protected Set<UUID> leavingPlayers = new HashSet<UUID>(); protected Set<UUID> leavingPlayers = new HashSet<UUID>();
public IslandCommand(BSkyBlock plugin) { public IslandCommand(BSkyBlock plugin) {
super(plugin, Settings.ISLANDCOMMAND, true); super(plugin, Settings.ISLANDCOMMAND, new String[] {"is"}, true);
plugin.getCommand(Settings.ISLANDCOMMAND).setExecutor(this); plugin.getCommand(Settings.ISLANDCOMMAND).setExecutor(this);
plugin.getCommand(Settings.ISLANDCOMMAND).setTabCompleter(this); plugin.getCommand(Settings.ISLANDCOMMAND).setTabCompleter(this);
this.plugin = plugin; this.plugin = plugin;