From 775b7f23777471d82f41476dd01c06e721243db1 Mon Sep 17 00:00:00 2001 From: Florian CUNY Date: Sat, 25 May 2019 10:34:32 +0200 Subject: [PATCH] Improved gameworlds output in /bentobox version It now displays the three dimensions for each world using a three-colour scale. Green means the world is generated and is an "island" world; orange means the world is generated but is not an "island" world and red means the world is not generated or does not exist. Actually, the overworld is always green, so I didn't put checks for it. I also improved the overall layout for the game worlds display in each localization file. --- .../commands/BentoBoxVersionCommand.java | 38 ++++++++++++++++++- src/main/resources/locales/en-US.yml | 2 +- src/main/resources/locales/es-ES.yml | 2 +- src/main/resources/locales/fr-FR.yml | 2 +- src/main/resources/locales/ja-JP.yml | 2 +- src/main/resources/locales/lv-LV.yml | 2 +- src/main/resources/locales/zh-CN.yml | 2 +- src/main/resources/locales/zh-HK.yml | 2 +- 8 files changed, 43 insertions(+), 9 deletions(-) diff --git a/src/main/java/world/bentobox/bentobox/commands/BentoBoxVersionCommand.java b/src/main/java/world/bentobox/bentobox/commands/BentoBoxVersionCommand.java index 88ba7e5fa..244d5bc72 100644 --- a/src/main/java/world/bentobox/bentobox/commands/BentoBoxVersionCommand.java +++ b/src/main/java/world/bentobox/bentobox/commands/BentoBoxVersionCommand.java @@ -1,5 +1,7 @@ package world.bentobox.bentobox.commands; +import org.bukkit.Bukkit; +import world.bentobox.bentobox.api.addons.GameModeAddon; import world.bentobox.bentobox.api.commands.CompositeCommand; import world.bentobox.bentobox.api.localization.TextVariables; import world.bentobox.bentobox.api.user.User; @@ -8,6 +10,7 @@ import world.bentobox.bentobox.versions.ServerCompatibility; import java.util.Comparator; import java.util.List; import java.util.Map; +import java.util.Optional; /** * Displays information about Gamemodes, Addons and versioning. @@ -16,6 +19,10 @@ import java.util.Map; */ 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 * @param parent - command parent @@ -42,8 +49,35 @@ public class BentoBoxVersionCommand extends CompositeCommand { getIWM().getOverWorldNames().entrySet().stream().sorted(Comparator.comparing(Map.Entry::getKey)) .forEach(e -> { - String gameWorld = user.getTranslation("commands.bentobox.version.game-world", TextVariables.NAME, e.getKey(), "[addon]", e.getValue()); - user.sendMessage(gameWorld); + String netherColor = GAMEWORLD_COLOR_ISLANDS; + String endColor = GAMEWORLD_COLOR_ISLANDS; + + // It should be present, but let's stay safe. + Optional addonOptional = getIWM().getAddon(Bukkit.getWorld(e.getKey())); + if (addonOptional.isPresent()) { + GameModeAddon addon = addonOptional.get(); + /* Get the colors + &a = dimension exists and contains islands + &6 = dimension exists but is vanilla + &c = dimension does not exist + */ + // Get the nether color + if (addon.getNetherWorld() == null || !getIWM().isNetherGenerate(addon.getNetherWorld())) { + netherColor = GAMEWORLD_COLOR_NOT_EXIST; + } else if (!getIWM().isNetherIslands(addon.getNetherWorld())) { + netherColor = GAMEWORLD_COLOR_EXISTS_NO_ISLANDS; + } + + // Get the nether color + if (addon.getEndWorld() == null || !getIWM().isEndGenerate(addon.getEndWorld())) { + endColor = GAMEWORLD_COLOR_NOT_EXIST; + } else if (!getIWM().isEndIslands(addon.getEndWorld())) { + endColor = GAMEWORLD_COLOR_EXISTS_NO_ISLANDS; + } + } + + user.sendMessage(user.getTranslation("commands.bentobox.version.game-world", TextVariables.NAME, e.getKey(), "[addon]", e.getValue(), + "[nether_color]", netherColor, "[end_color]", endColor)); }); user.sendMessage("commands.bentobox.version.loaded-addons"); diff --git a/src/main/resources/locales/en-US.yml b/src/main/resources/locales/en-US.yml index 1c7bdaf94..9c1c96c3f 100644 --- a/src/main/resources/locales/en-US.yml +++ b/src/main/resources/locales/en-US.yml @@ -306,7 +306,7 @@ commands: loaded-addons: "Loaded Addons:" loaded-game-worlds: "Loaded Game Worlds:" addon-syntax: "&2[name] &3[version]" - game-world: "&2[name] &7(&3[addon]&7)" + game-world: "&2[name] &7(&3[addon]&7): &aOverworld&7, &r[nether_color]Nether&7, &r[end_color]End" server: "&2Running &3[name] [version]&2." manage: description: "display the management panel" diff --git a/src/main/resources/locales/es-ES.yml b/src/main/resources/locales/es-ES.yml index d4de8a1e5..6cdf6321d 100644 --- a/src/main/resources/locales/es-ES.yml +++ b/src/main/resources/locales/es-ES.yml @@ -259,7 +259,7 @@ commands: loaded-addons: "Addons cargados:" loaded-game-worlds: "Mundos de juego cargados:" addon-syntax: "&2[name] &3[version]" - game-worlds: "&2[name] &7(&3[addon]&7)" + game-worlds: "&2[name] &7(&3[addon]&7): &aOverworld&7, &r[nether_color]Nether&7, &r[end_color]End" server: "&2Corriendo &3[name] [version]&2." manage: description: "Mostrar el panel de gestión" diff --git a/src/main/resources/locales/fr-FR.yml b/src/main/resources/locales/fr-FR.yml index 9376ab102..d13c8d98e 100644 --- a/src/main/resources/locales/fr-FR.yml +++ b/src/main/resources/locales/fr-FR.yml @@ -142,7 +142,7 @@ commands: loaded-addons: "Addons :" loaded-game-worlds: "Mondes de jeu :" addon-syntax: "&2[name] &3[version]" - game-world: "&2[name] &7(&3[addon]&7)" + game-world: "&2[name] &7(&3[addon]&7): &aOverworld&7, &r[nether_color]Nether&7, &r[end_color]End" server: "&2Serveur : &3[name] [version]&2." manage: description: "affiche le menu de gestion" diff --git a/src/main/resources/locales/ja-JP.yml b/src/main/resources/locales/ja-JP.yml index 8b5a4be70..462dd3063 100644 --- a/src/main/resources/locales/ja-JP.yml +++ b/src/main/resources/locales/ja-JP.yml @@ -181,7 +181,7 @@ commands: loaded-addons: "読み込まれたアドオン" loaded-game-worlds: "ロードされたゲームの世界" addon-syntax: "&2[name] &3[version]" - game-world: "&2[name] &7(&3[addon]&7)" + game-world: "&2[name] &7(&3[addon]&7): &aOverworld&7, &r[nether_color]Nether&7, &r[end_color]End" confirmation: confirm: "&c[seconds]秒でコマンドをもう一度入力して確認します。" previous-request-cancelled: "&c前の確認要求が取り消されました" diff --git a/src/main/resources/locales/lv-LV.yml b/src/main/resources/locales/lv-LV.yml index d53eb052c..089c62c62 100644 --- a/src/main/resources/locales/lv-LV.yml +++ b/src/main/resources/locales/lv-LV.yml @@ -262,7 +262,7 @@ commands: loaded-addons: "Ielādētie Papildinājumi:" loaded-game-worlds: "Ielādētās spēles pasaules:" addon-syntax: "&2[name] &3[version]" - game-world: "&2[name] &7(&3[addon]&7)" + game-world: "&2[name] &7(&3[addon]&7): &aOverworld&7, &r[nether_color]Nether&7, &r[end_color]End" server: "&2Darbojas uz &3[name] [version]&2." manage: description: "parādīt pārvaldīšanas paneli" diff --git a/src/main/resources/locales/zh-CN.yml b/src/main/resources/locales/zh-CN.yml index cf52c57d3..fc289b1f3 100644 --- a/src/main/resources/locales/zh-CN.yml +++ b/src/main/resources/locales/zh-CN.yml @@ -207,7 +207,7 @@ commands: loaded-addons: "已加载组件" loaded-game-worlds: "已加载游戏世界:" addon-syntax: "&2[name] &3[version]" - game-worlds: "&2[name] &7(&3[addon]&7)" + game-worlds: "&2[name] &7(&3[addon]&7): &aOverworld&7, &r[nether_color]Nether&7, &r[end_color]End" confirmation: confirm: "&c于 &b[seconds] &c秒内再次输入命令来确认" previous-request-cancelled: "&6上一个确认请求已取消" diff --git a/src/main/resources/locales/zh-HK.yml b/src/main/resources/locales/zh-HK.yml index f2809f371..37a0403a8 100644 --- a/src/main/resources/locales/zh-HK.yml +++ b/src/main/resources/locales/zh-HK.yml @@ -228,7 +228,7 @@ commands: loaded-addons: "已加載組件" loaded-game-worlds: "已加載遊戲世界:" addon-syntax: "&2[name] &3[version]" - game-worlds: "&2[name] &7(&3[addon]&7)" + game-worlds: "&2[name] &7(&3[addon]&7): &aOverworld&7, &r[nether_color]Nether&7, &r[end_color]End" confirmation: confirm: "&c於 &b[seconds] &c秒內再次輸入命令來確認" previous-request-cancelled: "&6上一個確認請求已取消"