mirror of
https://github.com/BentoBoxWorld/BentoBox.git
synced 2024-10-03 17:17:32 +02:00
Merge branch 'develop' of https://github.com/tastybento/bskyblock into develop
This commit is contained in:
commit
01dc515d57
@ -30,6 +30,8 @@ commands:
|
||||
header: "&7=========== &c%bsb_plugin_name% &7==========="
|
||||
syntax: "&b[usage] &a[parameters] &7: &e[description]"
|
||||
end: "&7================================="
|
||||
parameters: "[command]"
|
||||
description: "help command"
|
||||
admin:
|
||||
help:
|
||||
description: "Admin command"
|
||||
@ -43,6 +45,8 @@ commands:
|
||||
go:
|
||||
parameters: "<home number>"
|
||||
description: "teleport you to your island"
|
||||
teleport: "&aTeleporting you to your island. &b/[label] help &afor help."
|
||||
teleported: "&aTeleported you to home &e#[number]."
|
||||
help:
|
||||
description: "The main island command"
|
||||
spawn:
|
@ -1,6 +1,10 @@
|
||||
package us.tastybento.bskyblock.api.commands;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
import org.apache.commons.lang.math.NumberUtils;
|
||||
|
||||
/**
|
||||
* Adds a default help to every command that will show the usage of the command
|
||||
@ -10,6 +14,9 @@ import java.util.List;
|
||||
*/
|
||||
public class DefaultHelpCommand extends CompositeCommand {
|
||||
|
||||
// TODO: make this a setting
|
||||
private static final int MAX_DEPTH = 2;
|
||||
|
||||
public DefaultHelpCommand(CompositeCommand parent) {
|
||||
super(parent, "help");
|
||||
}
|
||||
@ -23,10 +30,24 @@ public class DefaultHelpCommand extends CompositeCommand {
|
||||
|
||||
@Override
|
||||
public boolean execute(User user, List<String> args) {
|
||||
if (parent.getLevel() == 0) {
|
||||
int depth = 0;
|
||||
if (args.size() == 1) {
|
||||
if (NumberUtils.isDigits(args.get(0))) {
|
||||
// Converts first argument into an int, or returns -1 if it cannot. Avoids exceptions.
|
||||
depth = Optional.ofNullable(args.get(0)).map(NumberUtils::toInt).orElse(-1);
|
||||
} else {
|
||||
String usage = user.getTranslation(parent.getUsage());
|
||||
String params = user.getTranslation("commands.help.parameters");
|
||||
String desc = user.getTranslation("commands.help.description");
|
||||
user.sendMessage("commands.help.syntax", "[usage]", usage, "[parameters]", params, "[description]", desc);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
if (depth == 0) {
|
||||
user.sendMessage("commands.help.header");
|
||||
}
|
||||
if (args.isEmpty()) {
|
||||
//if (args.isEmpty()) {
|
||||
if (depth < MAX_DEPTH) {
|
||||
if (!parent.getLabel().equals("help")) {
|
||||
// Get elements
|
||||
String usage = parent.getUsage().isEmpty() ? "" : user.getTranslation(parent.getUsage());
|
||||
@ -46,6 +67,8 @@ public class DefaultHelpCommand extends CompositeCommand {
|
||||
user.sendMessage("commands.help.syntax", "[usage]", usage, "[parameters]", params, "[description]", desc);
|
||||
}
|
||||
}
|
||||
// Increment the depth
|
||||
int newDepth = depth + 1;
|
||||
// Run through any subcommands and get their help
|
||||
for (CompositeCommand subCommand : parent.getSubCommands().values()) {
|
||||
// Ignore the help command
|
||||
@ -53,12 +76,13 @@ public class DefaultHelpCommand extends CompositeCommand {
|
||||
// Every command should have help because every command has a default help
|
||||
if (subCommand.getSubCommand("help").isPresent()) {
|
||||
// This sub-sub command has a help, so use it
|
||||
subCommand.getSubCommand("help").get().execute(user, args);
|
||||
subCommand.getSubCommand("help").get().execute(user, Arrays.asList(String.valueOf(newDepth)));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (parent.getLevel() == 0) {
|
||||
|
||||
if (depth == 0) {
|
||||
user.sendMessage("commands.help.end");
|
||||
}
|
||||
return true;
|
||||
|
@ -62,10 +62,10 @@ public class BSBLocale {
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds language YAML file to this locale
|
||||
* Merges a language YAML file to this locale
|
||||
* @param language
|
||||
*/
|
||||
public void add(File language) {
|
||||
public void merge(File language) {
|
||||
YamlConfiguration toBeMerged = YamlConfiguration.loadConfiguration(language);
|
||||
for (String key : toBeMerged.getKeys(true)) {
|
||||
if (!config.contains(key)) {
|
||||
|
@ -625,9 +625,9 @@ public class IslandsManager {
|
||||
//player.sendBlockChange(home, Material.GLOWSTONE, (byte)0);
|
||||
User user = User.getInstance(player);
|
||||
if (number == 1) {
|
||||
user.sendMessage("island.teleport", "[label]", Settings.ISLANDCOMMAND);
|
||||
user.sendMessage("commands.island.go.teleport", "[label]", Settings.ISLANDCOMMAND);
|
||||
} else {
|
||||
user.sendMessage("island.teleported", "[number]", String.valueOf(number));
|
||||
user.sendMessage("commands.island.go.island.go.teleported", "[number]", String.valueOf(number));
|
||||
}
|
||||
// Exit spectator mode if in it
|
||||
if (player.getGameMode().equals(GameMode.SPECTATOR)) {
|
||||
|
@ -65,8 +65,9 @@ public final class LocalesManager {
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
// Run through the files and store the locales
|
||||
File localeDir = new File(plugin.getDataFolder(), LOCALE_FOLDER);
|
||||
File localeDir = new File(plugin.getDataFolder(), LOCALE_FOLDER + "/" + parent);
|
||||
// If the folder does not exist, then make it and fill with the locale files from the jar
|
||||
// If it does exist, then new files will NOT be written!
|
||||
if (!localeDir.exists()) {
|
||||
@ -80,6 +81,7 @@ public final class LocalesManager {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
// Store all the locales available
|
||||
for (File language : localeDir.listFiles(ymlFilter)) {
|
||||
if (DEBUG)
|
||||
@ -89,7 +91,7 @@ public final class LocalesManager {
|
||||
plugin.getLogger().info("DEBUG: locale country found = " + localeObject.getCountry());
|
||||
if (languages.containsKey(localeObject)) {
|
||||
// Merge into current language
|
||||
languages.get(localeObject).add(language);
|
||||
languages.get(localeObject).merge(language);
|
||||
} else {
|
||||
// New language
|
||||
languages.put(localeObject, new BSBLocale(localeObject, language));
|
||||
|
Loading…
Reference in New Issue
Block a user