Improved '/bentobox version' gameworld layout to convey information through color-stripped text

The previous design had a flaw: if the output was pasted as text, we would not be able to tell if the dimension was disabled or if islands were disabled in that dimension.
This commit is contained in:
Florian CUNY 2020-01-18 11:41:31 +01:00
parent 01df19c424
commit d8dda75ca5
2 changed files with 19 additions and 23 deletions

View File

@ -20,10 +20,6 @@ import world.bentobox.bentobox.versions.ServerCompatibility;
*/ */
public class BentoBoxVersionCommand extends CompositeCommand { public class BentoBoxVersionCommand extends CompositeCommand {
private static final String GAMEWORLD_COLOR_ISLANDS = "&a";
private static final String GAMEWORLD_COLOR_EXISTS_NO_ISLANDS = "&6";
private static final String GAMEWORLD_COLOR_NOT_EXIST = "&c";
/** /**
* Info command * Info command
* @param parent - command parent * @param parent - command parent
@ -51,35 +47,35 @@ public class BentoBoxVersionCommand extends CompositeCommand {
getIWM().getOverWorldNames().entrySet().stream().sorted(Comparator.comparing(Map.Entry::getKey)) getIWM().getOverWorldNames().entrySet().stream().sorted(Comparator.comparing(Map.Entry::getKey))
.forEach(e -> { .forEach(e -> {
String netherColor = GAMEWORLD_COLOR_ISLANDS; String worlds = user.getTranslation("general.worlds.overworld");
String endColor = GAMEWORLD_COLOR_ISLANDS;
// It should be present, but let's stay safe. // It should be present, but let's stay safe.
Optional<GameModeAddon> addonOptional = getIWM().getAddon(Bukkit.getWorld(e.getKey())); Optional<GameModeAddon> addonOptional = getIWM().getAddon(Bukkit.getWorld(e.getKey()));
if (addonOptional.isPresent()) { if (addonOptional.isPresent()) {
GameModeAddon addon = addonOptional.get(); GameModeAddon addon = addonOptional.get();
/* Get the colors /*
&a = dimension exists and contains islands * If the dimension is generated, it is displayed.
&6 = dimension exists but is vanilla * If the dimension is not made up of islands, a '*' is appended to its name.
&c = dimension does not exist */
*/ // Append the nether
// Get the nether color if (addon.getNetherWorld() != null && getIWM().isNetherGenerate(addon.getOverWorld())) {
if (addon.getNetherWorld() == null || !getIWM().isNetherGenerate(addon.getOverWorld())) { worlds += ", " + user.getTranslation("general.worlds.nether");
netherColor = GAMEWORLD_COLOR_NOT_EXIST; if (!getIWM().isNetherIslands(addon.getOverWorld())) {
} else if (!getIWM().isNetherIslands(addon.getOverWorld())) { worlds += "*";
netherColor = GAMEWORLD_COLOR_EXISTS_NO_ISLANDS; }
} }
// Get the nether color // Append the End
if (addon.getEndWorld() == null || !getIWM().isEndGenerate(addon.getOverWorld())) { if (addon.getEndWorld() != null && getIWM().isEndGenerate(addon.getOverWorld())) {
endColor = GAMEWORLD_COLOR_NOT_EXIST; worlds += ", " + user.getTranslation("general.worlds.the-end");
} else if (!getIWM().isEndIslands(addon.getOverWorld())) { if (!getIWM().isEndIslands(addon.getOverWorld())) {
endColor = GAMEWORLD_COLOR_EXISTS_NO_ISLANDS; worlds += "*";
}
} }
} }
user.sendMessage(user.getTranslation("commands.bentobox.version.game-world", TextVariables.NAME, e.getKey(), "[addon]", e.getValue(), user.sendMessage(user.getTranslation("commands.bentobox.version.game-world", TextVariables.NAME, e.getKey(), "[addon]", e.getValue(),
"[nether_color]", netherColor, "[end_color]", endColor)); "[worlds]", worlds));
}); });
user.sendMessage("commands.bentobox.version.loaded-addons"); user.sendMessage("commands.bentobox.version.loaded-addons");

View File

@ -398,7 +398,7 @@ commands:
loaded-addons: "Loaded Addons:" loaded-addons: "Loaded Addons:"
loaded-game-worlds: "Loaded Game Worlds:" loaded-game-worlds: "Loaded Game Worlds:"
addon-syntax: "&2 [name] &3 [version] &7 (&3 [state]&7 )" addon-syntax: "&2 [name] &3 [version] &7 (&3 [state]&7 )"
game-world: "&2 [name] &7 (&3 [addon]&7 ): &a Overworld&7 , &r [nether_color]Nether&7 , &r [end_color]End" game-world: "&2 [name] &7 (&3 [addon]&7 ): &3 [worlds]"
server: "&2 Running &3 [name] [version]&2 ." server: "&2 Running &3 [name] [version]&2 ."
database: "&2 Database: &3 [database]" database: "&2 Database: &3 [database]"
manage: manage: