From 35585ed70d8f5dd0c70c7cf6d7a6e897b1fb5051 Mon Sep 17 00:00:00 2001 From: yoyosource Date: Fri, 7 May 2021 17:38:55 +0200 Subject: [PATCH] Add BauScoreboard multilingual --- BauSystem_Main/src/BauSystem.properties | 27 ++++++++++++++++++- .../bausystem/features/loader/Loader.java | 8 +++--- .../features/tracer/TracerBauGuiItem.java | 3 ++- .../features/tracer/record/RecordStatus.java | 8 +++--- .../features/world/BauScoreboard.java | 21 ++++++++------- .../bausystem/region/RegionUtils.java | 18 ++++++++++--- 6 files changed, 62 insertions(+), 23 deletions(-) diff --git a/BauSystem_Main/src/BauSystem.properties b/BauSystem_Main/src/BauSystem.properties index 3ff66bb6..f219b705 100644 --- a/BauSystem_Main/src/BauSystem.properties +++ b/BauSystem_Main/src/BauSystem.properties @@ -1,4 +1,6 @@ PREFIX = §eBau§8System §8» +TIME = HH:mm:ss +DATE = ........ # Permission PERMISSION_WORLD = Einstellungen vornehmen @@ -9,6 +11,16 @@ PERMISSION_CHANGE_YOU_DISABLE = §cDer Spieler darf nun nicht mehr {0} PERMISSION_CHANGE_OTHER_ENABLE = §aDu kannst nun auf der Welt von §6{0} §a{1} PERMISSION_CHANGE_OTHER_DISABLE = §cDu kannst nun nicht mehr auf der Welt von §6{0} §c{1} +# Scoreboard +SCOREBOARD_TIME = Uhrzeit +SCOREBOARD_REGION = Region +SCOREBOARD_TRACE = Trace +SCOREBOARD_LOADER = Loader +SCOREBOARD_TPS = TPS + +SCOREBOARD_TRACE_TICKS = Ticks +SCOREBOARD_TRACE_TNT_COUNT = Anzahl TNT + # Flags FLAG_COLOR = Color FLAG_TNT = TNT @@ -53,4 +65,17 @@ FLAG_COLOR_BLACK = §fSchwarz # Region REGION_TYPE_NORMAL = Normal REGION_TYPE_BUILD = Baubereich -REGION_TYPE_ONLY_TB = Testblock \ No newline at end of file +REGION_TYPE_ONLY_TB = Testblock + +# Trace +TRACE_RECORD = §aan +TRACE_RECORD_AUTO = §an +TRACE_IDLE = §caus +TRACE_IDLE_AUTO = §eauto + +# Loader +LOADER_OFF = §caus +LOADER_SETUP = §eSetup +LOADER_RUNNING = §aRunning +LOADER_PAUSE = §7Pause +LOADER_END = §8Finished \ No newline at end of file diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/loader/Loader.java b/BauSystem_Main/src/de/steamwar/bausystem/features/loader/Loader.java index 39f8b60f..e27a0eee 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/loader/Loader.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/loader/Loader.java @@ -208,10 +208,10 @@ public class Loader implements Listener { @AllArgsConstructor public enum Stage implements EnumDisplay { - SETUP("§eSetup"), - RUNNING("§aRunning"), - PAUSE("§7Pause"), - END("§8Finished"); + SETUP("LOADER_SETUP"), + RUNNING("LOADER_RUNNING"), + PAUSE("LOADER_PAUSE"), + END("LOADER_END"); @Getter private String chatValue; diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/TracerBauGuiItem.java b/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/TracerBauGuiItem.java index 9aa1121e..f29d508e 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/TracerBauGuiItem.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/TracerBauGuiItem.java @@ -19,6 +19,7 @@ package de.steamwar.bausystem.features.tracer; +import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.Permission; import de.steamwar.bausystem.config.ColorConfig; import de.steamwar.bausystem.features.tracer.record.RecordStateMachine; @@ -42,7 +43,7 @@ public class TracerBauGuiItem extends BauGuiItem { @Override public ItemStack getItem(Player player) { - return new SWItem(Material.OBSERVER, ColorConfig.HIGHLIGHT + "Tracer", Arrays.asList(ColorConfig.BASE + "Status: " + RecordStateMachine.getRecordStatus().getName()), false, clickType -> { + return new SWItem(Material.OBSERVER, ColorConfig.HIGHLIGHT + "Tracer", Arrays.asList(ColorConfig.BASE + "Status: " + BauSystem.MESSAGE.parse(RecordStateMachine.getRecordStatus().getName(), player)), false, clickType -> { }).getItemStack(); } diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/record/RecordStatus.java b/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/record/RecordStatus.java index 07e96f1f..95b33260 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/record/RecordStatus.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/record/RecordStatus.java @@ -21,10 +21,10 @@ package de.steamwar.bausystem.features.tracer.record; public enum RecordStatus { - RECORD("§aan", true, "§cTNT-Tracer muss gestoppt werden"), - RECORD_AUTO("§aan", true, "§cTNT-Tracer darf nicht aufnehmen"), - IDLE("§caus", false, "§cAuto-Tracer gestoppt"), - IDLE_AUTO("§eauto", false, "§aAuto-Tracer gestartet"); + RECORD("TRACE_RECORD", true, "§cTNT-Tracer muss gestoppt werden"), + RECORD_AUTO("TRACE_RECORD_AUTO", true, "§cTNT-Tracer darf nicht aufnehmen"), + IDLE("TRACE_IDLE", false, "§cAuto-Tracer gestoppt"), + IDLE_AUTO("TRACE_IDLE_AUTO", false, "§aAuto-Tracer gestartet"); String name; boolean tracing; diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/world/BauScoreboard.java b/BauSystem_Main/src/de/steamwar/bausystem/features/world/BauScoreboard.java index d56ce65f..8aaa42bc 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/world/BauScoreboard.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/world/BauScoreboard.java @@ -11,7 +11,6 @@ import de.steamwar.bausystem.region.GlobalRegion; import de.steamwar.bausystem.region.Region; import de.steamwar.bausystem.region.flags.Flag; import de.steamwar.core.TPSWatcher; -import de.steamwar.message.Message; import de.steamwar.scoreboard.SWScoreboard; import de.steamwar.scoreboard.ScoreboardCallback; import org.bukkit.entity.Player; @@ -50,10 +49,11 @@ public class BauScoreboard implements Listener { List strings = new ArrayList<>(); strings.add("§1"); - strings.add("§eUhrzeit§8: §7" + new SimpleDateFormat("HH:mm:ss").format(Calendar.getInstance().getTime())); + strings.add("§e" + BauSystem.MESSAGE.parse("SCOREBOARD_TIME", p) + "§8: §7" + new SimpleDateFormat(BauSystem.MESSAGE.parse("TIME", p)).format(Calendar.getInstance().getTime())); if (GlobalRegion.getInstance() != region) { - strings.add("§eRegion§8: §7" + region.getDisplayName()); + strings.add("§e" + BauSystem.MESSAGE.parse("SCOREBOARD_REGION", p) + "§8: §7" + region.getDisplayName()); } + strings.add("§2"); for (Flag flag : Flag.getFlags()) { if (!flag.getRegionPredicate().test(region)) { @@ -62,18 +62,19 @@ public class BauScoreboard implements Listener { strings.add("§e" + BauSystem.MESSAGE.parse(flag.getChatValue(), p) + "§8: " + BauSystem.MESSAGE.parse(region.get(flag).getChatValue(), p)); } - strings.add("§eTrace§8: " + RecordStateMachine.getRecordStatus().getName()); + strings.add("§3"); + strings.add("§e" + BauSystem.MESSAGE.parse("SCOREBOARD_TRACE", p) + "§8: " + BauSystem.MESSAGE.parse(RecordStateMachine.getRecordStatus().getName(), p)); Loader loader = Loader.getLoader(p); - strings.add("§eLoader§8: " + (loader != null ? ("§a" + loader.getStage().getChatValue()) : "§caus")); + strings.add("§e" + BauSystem.MESSAGE.parse("SCOREBOARD_LOADER", p) + "§8: " + BauSystem.MESSAGE.parse(loader != null ? loader.getStage().getChatValue() : "LOADER_OFF", p)); if (RecordStateMachine.getRecordStatus().isTracing()) { - strings.add("§3"); - strings.add("§eTicks§8: §7" + traceTicks()); - strings.add("§eAnzahl TNT§8: §7" + RecordStateMachine.size()); + strings.add("§4"); + strings.add("§e" + BauSystem.MESSAGE.parse("SCOREBOARD_TRACE_TICKS", p) + "§8: §7" + traceTicks()); + strings.add("§e" + BauSystem.MESSAGE.parse("SCOREBOARD_TRACE_TNT_COUNT", p) + "§8: §7" + RecordStateMachine.size()); } - strings.add("§4"); - strings.add("§eTPS§8: " + tpsColor() + TPSWarpUtils.getTps(TPSWatcher.TPSType.ONE_SECOND) + tpsLimit()); + strings.add("§5"); + strings.add("§e" + BauSystem.MESSAGE.parse("SCOREBOARD_TPS", p) + "§8 " + tpsColor() + TPSWarpUtils.getTps(TPSWatcher.TPSType.ONE_SECOND) + tpsLimit()); int i = strings.size(); HashMap result = new HashMap<>(); diff --git a/BauSystem_Main/src/de/steamwar/bausystem/region/RegionUtils.java b/BauSystem_Main/src/de/steamwar/bausystem/region/RegionUtils.java index ea93ba26..4b2cbfb6 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/region/RegionUtils.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/region/RegionUtils.java @@ -20,15 +20,27 @@ import org.bukkit.entity.Player; public class RegionUtils { public void actionBar(Region region, String s) { - Bukkit.getOnlinePlayers().stream().filter(player -> region.inRegion(player.getLocation(), RegionType.NORMAL, RegionExtensionType.NORMAL)).forEach(player -> player.spigot().sendMessage(ChatMessageType.ACTION_BAR, TextComponent.fromLegacyText(s))); + Bukkit.getOnlinePlayers() + .stream() + .filter(player -> region.inRegion(player.getLocation(), RegionType.NORMAL, RegionExtensionType.NORMAL)) + .filter(player -> !region.isGlobal() || Region.getRegion(player.getLocation()).isGlobal()) + .forEach(player -> player.spigot().sendMessage(ChatMessageType.ACTION_BAR, TextComponent.fromLegacyText(s))); } public static void message(Region region, String s) { - Bukkit.getOnlinePlayers().stream().filter(player -> region.inRegion(player.getLocation(), RegionType.NORMAL, RegionExtensionType.NORMAL)).forEach(player -> player.sendMessage(s)); + Bukkit.getOnlinePlayers() + .stream() + .filter(player -> region.inRegion(player.getLocation(), RegionType.NORMAL, RegionExtensionType.NORMAL)) + .filter(player -> !region.isGlobal() || Region.getRegion(player.getLocation()).isGlobal()) + .forEach(player -> player.sendMessage(s)); } public static void message(Region region, Function function) { - Bukkit.getOnlinePlayers().stream().filter(player -> region.inRegion(player.getLocation(), RegionType.NORMAL, RegionExtensionType.NORMAL)).forEach(player -> { + Bukkit.getOnlinePlayers() + .stream() + .filter(player -> region.inRegion(player.getLocation(), RegionType.NORMAL, RegionExtensionType.NORMAL)) + .filter(player -> !region.isGlobal() || Region.getRegion(player.getLocation()).isGlobal()) + .forEach(player -> { String message = function.apply(player); if (message == null) { return;