From 74e937d7b5b7caeaeed5638c7f0fcb4297e707ae Mon Sep 17 00:00:00 2001 From: yoyosource Date: Thu, 13 May 2021 17:08:14 +0200 Subject: [PATCH] Add Bau... multilingual --- BauSystem_Main/src/BauSystem.properties | 20 ++++++++++++++ .../bausystem/features/bau/BauCommand.java | 10 +++---- .../features/bau/BauInfoBauGuiItem.java | 26 ++++++++++++------- .../bausystem/features/bau/InfoCommand.java | 9 ++++--- 4 files changed, 46 insertions(+), 19 deletions(-) diff --git a/BauSystem_Main/src/BauSystem.properties b/BauSystem_Main/src/BauSystem.properties index 295218ca..2928309f 100644 --- a/BauSystem_Main/src/BauSystem.properties +++ b/BauSystem_Main/src/BauSystem.properties @@ -98,6 +98,26 @@ AUTOSTART_MESSAGE_RESULT1 = §eZeit §7bis zur §eExplosion §7am Gegner§8:§e AUTOSTART_MESSAGE_RESULT2 = §eZeitdifferenz in ticks §7bis 60 Sekunden§8:§e {0} AUTOSTART_MESSAGE_RESULT3 = §7Positiv, wenn zu wenig, negativ wenn zu viel +# Bau +BAU_COMMAND_HELP1 = §8/§ebau togglewe §8[§7Player§8] §8- §7Editiere die WorldEdit Rechte eines Spielers +BAU_COMMAND_HELP2 = §8/§ebau toggleworld §8[§7Player§8] §8- §7Editiere die Welt Rechte eines Spielers +BAU_UNKNOWN-PLAYER = §cUnbekannter Spieler +BAU_NO-PLAYER = §cDer Spieler ist kein Mitglied deiner Welt! +BAU_NO-WORLD = §cDies ist nicht deine Welt! + +BAU_INFO_ITEM_NAME = §eBau management +# This is used in BauInfoBauGuiItem.java +BAU-INFO_ITEM_LORE-TNT = §7TNT §8: §e{0} +BAU-INFO_ITEM_LORE-FREEZE = §7Freeze §8: §e{0} +BAU-INFO_ITEM_LORE-FIRE = §7Feuer §8: §e{0} +BAU-INFO_ITEM_LORE-COLOR = §7Farbe §8: §e{0} +BAU-INFO_ITEM_LORE-PROTECT = §7Protect §8: §e{0} + +BAU-INFO_COMMAND_HELP = §8/§ebauinfo §8- §7Gibt Informationen über den Bau +BAU-INFO_COMMAND_OWNER = §7Besitzer: §e{0} +BAU-INFO_COMMAND_MEMBER = §7Mitglieder: §e{0} +BAU-INFO_COMMAND_FLAG = §e{0} §8: §7{1} + # GUI GUI_EDITOR_ITEM-NAME=§eGui Editor GUI_EXPORT_CODE=§eDein Gui-Code: diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/bau/BauCommand.java b/BauSystem_Main/src/de/steamwar/bausystem/features/bau/BauCommand.java index 0b589510..f7e8a00c 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/bau/BauCommand.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/bau/BauCommand.java @@ -49,8 +49,8 @@ public class BauCommand extends SWCommand { @Register(help = true) public void genericHelp(Player p, String... args) { - p.sendMessage("§8/§ebau togglewe §8[§7Player§8] §8- §7Editiere die WorldEdit Rechte eines Spielers"); - p.sendMessage("§8/§ebau toggleworld §8[§7Player§8] §8- §7Editiere die Welt Rechte eines Spielers"); + BauSystem.MESSAGE.send("BAU_COMMAND_HELP1", p); + BauSystem.MESSAGE.send("BAU_COMMAND_HELP2", p); } @Register("info") @@ -104,13 +104,13 @@ public class BauCommand extends SWCommand { private boolean negativeToggleCheck(Player p, SteamwarUser id) { if (id == null) { - p.sendMessage(BauSystem.PREFIX + "§cUnbekannter Spieler"); + BauSystem.MESSAGE.send("BAU_UNKNOWN-PLAYER", p); return true; } BauweltMember target = BauweltMember.getBauMember(bauServer.getOwnerID(), id.getId()); if (target == null) { - p.sendMessage(BauSystem.PREFIX + "§cDer Spieler ist kein Mitglied deiner Welt!"); + BauSystem.MESSAGE.send("BAU_NO-PLAYER", p); return true; } return false; @@ -119,7 +119,7 @@ public class BauCommand extends SWCommand { private boolean permissionCheck(Player p) { if (!bauServer.getOwner().equals(p.getUniqueId())) { - p.sendMessage(BauSystem.PREFIX + "§cDies ist nicht deine Welt!"); + BauSystem.MESSAGE.send("BAU_NO-WORLD", p); return false; } else { return true; diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/bau/BauInfoBauGuiItem.java b/BauSystem_Main/src/de/steamwar/bausystem/features/bau/BauInfoBauGuiItem.java index c194bf8b..dd843c85 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/bau/BauInfoBauGuiItem.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/bau/BauInfoBauGuiItem.java @@ -19,22 +19,22 @@ package de.steamwar.bausystem.features.bau; +import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.Permission; import de.steamwar.bausystem.config.BauServer; -import de.steamwar.bausystem.config.ColorConfig; -import de.steamwar.bausystem.linkage.specific.BauGuiItem; import de.steamwar.bausystem.linkage.LinkageType; import de.steamwar.bausystem.linkage.Linked; +import de.steamwar.bausystem.linkage.specific.BauGuiItem; import de.steamwar.bausystem.region.Region; import de.steamwar.bausystem.region.flags.Flag; -import de.steamwar.bausystem.region.flags.flagvalues.*; import de.steamwar.inventory.SWItem; import de.steamwar.sql.SteamwarUser; import org.bukkit.entity.Player; import org.bukkit.event.inventory.ClickType; import org.bukkit.inventory.ItemStack; -import java.util.Arrays; +import java.util.ArrayList; +import java.util.List; @Linked(LinkageType.BAU_GUI_ITEM) public class BauInfoBauGuiItem extends BauGuiItem { @@ -46,13 +46,19 @@ public class BauInfoBauGuiItem extends BauGuiItem { @Override public ItemStack getItem(Player player) { SWItem itemStack = SWItem.getPlayerSkull(SteamwarUser.get(BauServer.getInstance().getOwner()).getUserName()); - itemStack.setName(ColorConfig.HIGHLIGHT + "Bau management"); + itemStack.setName(BauSystem.MESSAGE.parse("BAU_INFO_ITEM_NAME", player)); Region region = Region.getRegion(player.getLocation()); - itemStack.setLore(Arrays.asList(ColorConfig.BASE + "TNT" + ColorConfig.OTHER + ": " + ColorConfig.HIGHLIGHT + region.getPlain(Flag.TNT, TNTMode.class).getChatValue(), - ColorConfig.BASE + "Freeze" + ColorConfig.OTHER + ": " + ColorConfig.HIGHLIGHT + region.getPlain(Flag.FREEZE, FreezeMode.class).getChatValue(), - ColorConfig.BASE + "Feuer" + ColorConfig.OTHER + ": " + ColorConfig.HIGHLIGHT + region.getPlain(Flag.FIRE, FireMode.class).getChatValue(), - ColorConfig.BASE + "Farbe" + ColorConfig.OTHER + ": " + ColorConfig.HIGHLIGHT + region.getPlain(Flag.COLOR, ColorMode.class).getChatValue(), - ColorConfig.BASE + "Protect" + ColorConfig.OTHER + ": " + ColorConfig.HIGHLIGHT + region.getPlain(Flag.PROTECT, ProtectMode.class).getChatValue())); + List stringList = new ArrayList<>(); + for (Flag flag : Flag.getFlags()) { + if (flag == Flag.PROTECT && region.getFloorLevel() == 0) { + continue; + } + Flag.Value value = region.get(flag); + if (value != null) { + stringList.add(BauSystem.MESSAGE.parse("BAU_INFO_ITEM_LORE-" + flag.name(), player, BauSystem.MESSAGE.parse(value.getChatValue(), player))); + } + } + itemStack.setLore(stringList); return itemStack.getItemStack(); } diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/bau/InfoCommand.java b/BauSystem_Main/src/de/steamwar/bausystem/features/bau/InfoCommand.java index eb7a1d33..146b5057 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/bau/InfoCommand.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/bau/InfoCommand.java @@ -30,7 +30,7 @@ public class InfoCommand extends SWCommand { @Register(help = true) public void genericHelp(Player p, String... args) { - p.sendMessage("§8/§ebauinfo §8- §7Gibt Informationen über den Bau"); + BauSystem.MESSAGE.send("BAU-INFO_COMMAND_HELP", p); } @Register @@ -39,7 +39,7 @@ public class InfoCommand extends SWCommand { } public void sendBauInfo(Player p) { - p.sendMessage(BauSystem.PREFIX + "Besitzer: §e" + SteamwarUser.get(bauServer.getOwnerID()).getUserName()); + BauSystem.MESSAGE.send("BAU-INFO_COMMAND_OWNER", p, SteamwarUser.get(bauServer.getOwnerID()).getUserName()); Region region = Region.getRegion(p.getLocation()); for (Flag flag : Flag.getFlags()) { if (flag == Flag.PROTECT && region.getFloorLevel() == 0) { @@ -47,12 +47,13 @@ public class InfoCommand extends SWCommand { } Flag.Value value = region.get(flag); if (value != null) { - p.sendMessage(BauSystem.PREFIX + "§e" + flag.getChatValue() + "§8: §7" + value.getChatValue()); + BauSystem.MESSAGE.send("BAU-INFO_COMMAND_FLAG", p, BauSystem.MESSAGE.parse(flag.getChatValue(), p), BauSystem.MESSAGE.parse(value.getChatValue(), p)); } } List members = BauweltMember.getMembers(bauServer.getOwnerID()); - StringBuilder membermessage = new StringBuilder().append(BauSystem.PREFIX).append("Mitglieder: "); + StringBuilder membermessage = new StringBuilder(); + membermessage.append(BauSystem.MESSAGE.parsePrefixed("BAU-INFO_COMMAND_MEMBER", p)); for (BauweltMember member : members) { membermessage.append("§e").append(SteamwarUser.get(member.getMemberID()).getUserName()).append("§8[");