From 485cf8f417e73eb0be1b1066e54d516029265fb4 Mon Sep 17 00:00:00 2001 From: yoyosource Date: Fri, 7 May 2021 10:48:12 +0200 Subject: [PATCH 1/8] Simplify Region.inRegion --- .../src/de/steamwar/bausystem/region/Region.java | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/BauSystem_Main/src/de/steamwar/bausystem/region/Region.java b/BauSystem_Main/src/de/steamwar/bausystem/region/Region.java index b8478b6c..c0271d06 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/region/Region.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/region/Region.java @@ -195,9 +195,12 @@ public class Region { } private boolean inRegion(Location location, Point minPoint, Point maxPoint) { - return location.getBlockX() >= minPoint.getX() && location.getBlockX() <= maxPoint.getX() && - location.getBlockY() >= minPoint.getY() && location.getBlockY() <= maxPoint.getY() && - location.getBlockZ() >= minPoint.getZ() && location.getBlockZ() <= maxPoint.getZ(); + int blockX = location.getBlockX(); + int blockY = location.getBlockY(); + int blockZ = location.getBlockZ(); + return blockX >= minPoint.getX() && blockX <= maxPoint.getX() && + blockY >= minPoint.getY() && blockY <= maxPoint.getY() && + blockZ >= minPoint.getZ() && blockZ <= maxPoint.getZ(); } public boolean hasType(RegionType regionType) { From daabe26f13926ac98cb9da358412de1c6eb16607 Mon Sep 17 00:00:00 2001 From: yoyosource Date: Fri, 7 May 2021 17:12:35 +0200 Subject: [PATCH 2/8] Add BauScoreboard multilingual Flags --- BauSystem_Main/src/BauSystem.properties | 21 +++++++++++++++++++ .../features/world/BauScoreboard.java | 13 +++++++----- .../steamwar/bausystem/region/flags/Flag.java | 20 ++++++++++-------- .../region/flags/flagvalues/ColorMode.java | 2 +- 4 files changed, 41 insertions(+), 15 deletions(-) diff --git a/BauSystem_Main/src/BauSystem.properties b/BauSystem_Main/src/BauSystem.properties index b0dddcee..3ff66bb6 100644 --- a/BauSystem_Main/src/BauSystem.properties +++ b/BauSystem_Main/src/BauSystem.properties @@ -13,6 +13,7 @@ PERMISSION_CHANGE_OTHER_DISABLE = §cDu kannst nun nicht mehr auf der Welt von FLAG_COLOR = Color FLAG_TNT = TNT FLAG_FIRE = Fire +FLAG_DAMAGE = Damage FLAG_FREEZE = Freeze FLAG_PROTECT = Protect @@ -29,6 +30,26 @@ FLAG_TNT_ALLOW = §aan FLAG_TNT_DENY = §caus FLAG_TNT_ONLY_TB = §7Kein §eBaurahmen +FLAG_DAMAGE_ALLOW = §aan +FLAG_DAMAGE_DENY = §caus + +FLAG_COLOR_WHITE = §fWeiß +FLAG_COLOR_ORANGE = §fOrange +FLAG_COLOR_MAGENTA = §fMagenta +FLAG_COLOR_LIGHT_BLUE = §fHellblau +FLAG_COLOR_YELLOW = §fGelb +FLAG_COLOR_LIME = §fHellgrün +FLAG_COLOR_PINK = §fPink +FLAG_COLOR_GRAY = §fGrau +FLAG_COLOR_LIGHT_GRAY = §fHellgrau +FLAG_COLOR_CYAN = §fCyan +FLAG_COLOR_PURPLE = §fLila +FLAG_COLOR_BLUE = §fBlau +FLAG_COLOR_BROWN = §fBraun +FLAG_COLOR_GREEN = §fGrün +FLAG_COLOR_RED = §fRot +FLAG_COLOR_BLACK = §fSchwarz + # Region REGION_TYPE_NORMAL = Normal REGION_TYPE_BUILD = Baubereich 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 2e9fe6c3..d56ce65f 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/world/BauScoreboard.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/world/BauScoreboard.java @@ -1,5 +1,6 @@ package de.steamwar.bausystem.features.world; +import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.features.loader.Loader; import de.steamwar.bausystem.features.tpslimit.TPSLimitUtils; import de.steamwar.bausystem.features.tpslimit.TPSWarpUtils; @@ -10,6 +11,7 @@ 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; @@ -53,12 +55,13 @@ public class BauScoreboard implements Listener { strings.add("§eRegion§8: §7" + region.getDisplayName()); } strings.add("§2"); - strings.add("§eTNT§8: " + region.get(Flag.TNT).getChatValue()); - strings.add("§eFreeze§8: " + region.get(Flag.FREEZE).getChatValue()); - strings.add("§eFire§8: " + region.get(Flag.FIRE).getChatValue()); - if (region.getFloorLevel() != 0) { - strings.add("§eProtect§8: " + region.get(Flag.PROTECT).getChatValue()); + for (Flag flag : Flag.getFlags()) { + if (!flag.getRegionPredicate().test(region)) { + continue; + } + 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()); Loader loader = Loader.getLoader(p); strings.add("§eLoader§8: " + (loader != null ? ("§a" + loader.getStage().getChatValue()) : "§caus")); diff --git a/BauSystem_Main/src/de/steamwar/bausystem/region/flags/Flag.java b/BauSystem_Main/src/de/steamwar/bausystem/region/flags/Flag.java index 96f9ed5a..ca45eca0 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/region/flags/Flag.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/region/flags/Flag.java @@ -19,9 +19,11 @@ package de.steamwar.bausystem.region.flags; +import de.steamwar.bausystem.region.Region; import de.steamwar.bausystem.region.flags.flagvalues.*; import java.util.EnumSet; import java.util.Set; +import java.util.function.Predicate; import de.steamwar.bausystem.shared.EnumDisplay; import lombok.Getter; @@ -29,12 +31,12 @@ import lombok.Getter; @Getter public enum Flag implements EnumDisplay { - COLOR("FLAG_COLOR", ColorMode.class, ColorMode.YELLOW), - TNT("FLAG_TNT", TNTMode.class, TNTMode.ONLY_TB), - FIRE("FLAG_FIRE", FireMode.class, FireMode.ALLOW), - DAMAGE("FLAG_DAMAGE", DamageMode.class, DamageMode.ALLOW), - FREEZE("FLAG_FREEZE", FreezeMode.class, FreezeMode.INACTIVE), - PROTECT("FLAG_PROTECT", ProtectMode.class, ProtectMode.INACTIVE); + COLOR("FLAG_COLOR", ColorMode.class, ColorMode.YELLOW, region -> false), + TNT("FLAG_TNT", TNTMode.class, TNTMode.ONLY_TB, region -> true), + FIRE("FLAG_FIRE", FireMode.class, FireMode.ALLOW, region -> true), + DAMAGE("FLAG_DAMAGE", DamageMode.class, DamageMode.ALLOW, region -> false), + FREEZE("FLAG_FREEZE", FreezeMode.class, FreezeMode.INACTIVE, region -> true), + PROTECT("FLAG_PROTECT", ProtectMode.class, ProtectMode.INACTIVE, region -> region.getFloorLevel() != 0); @Getter private static final Set flags; @@ -47,20 +49,20 @@ public enum Flag implements EnumDisplay { private final Class> valueType; private final Flag.Value defaultValue; private final Value[] values; + private final Predicate regionPredicate; - & Value> Flag(String chatValue, final Class> valueType, final Flag.Value defaultValue) { + & Value> Flag(String chatValue, final Class> valueType, final Flag.Value defaultValue, Predicate regionPredicate) { this.chatValue = chatValue; this.valueType = valueType; this.defaultValue = defaultValue; this.values = defaultValue.getValues(); + this.regionPredicate = regionPredicate; } public Value getFlagValueOf(final String name) { return this.defaultValue.getValueOf(name); } - - @Override public String toString() { return this.name().toLowerCase(); diff --git a/BauSystem_Main/src/de/steamwar/bausystem/region/flags/flagvalues/ColorMode.java b/BauSystem_Main/src/de/steamwar/bausystem/region/flags/flagvalues/ColorMode.java index f37ba21a..846bd9fe 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/region/flags/flagvalues/ColorMode.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/region/flags/flagvalues/ColorMode.java @@ -47,7 +47,7 @@ public enum ColorMode implements Flag.Value { private static ColorMode[] values; private final Color color; - private final String chatValue = name(); + private final String chatValue = "FLAG_COLOR_" + name(); @Override public ColorMode[] getValues() { From 35585ed70d8f5dd0c70c7cf6d7a6e897b1fb5051 Mon Sep 17 00:00:00 2001 From: yoyosource Date: Fri, 7 May 2021 17:38:55 +0200 Subject: [PATCH 3/8] 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; From 0d80cba56174cf3998f5b5dff972935d366fef95 Mon Sep 17 00:00:00 2001 From: yoyosource Date: Fri, 7 May 2021 17:45:39 +0200 Subject: [PATCH 4/8] Fix BauSystem.properties --- BauSystem_Main/src/BauSystem.properties | 32 ++++++++++++------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/BauSystem_Main/src/BauSystem.properties b/BauSystem_Main/src/BauSystem.properties index f219b705..6be4c686 100644 --- a/BauSystem_Main/src/BauSystem.properties +++ b/BauSystem_Main/src/BauSystem.properties @@ -45,22 +45,22 @@ FLAG_TNT_ONLY_TB = §7Kein §eBaurahmen FLAG_DAMAGE_ALLOW = §aan FLAG_DAMAGE_DENY = §caus -FLAG_COLOR_WHITE = §fWeiß -FLAG_COLOR_ORANGE = §fOrange -FLAG_COLOR_MAGENTA = §fMagenta -FLAG_COLOR_LIGHT_BLUE = §fHellblau -FLAG_COLOR_YELLOW = §fGelb -FLAG_COLOR_LIME = §fHellgrün -FLAG_COLOR_PINK = §fPink -FLAG_COLOR_GRAY = §fGrau -FLAG_COLOR_LIGHT_GRAY = §fHellgrau -FLAG_COLOR_CYAN = §fCyan -FLAG_COLOR_PURPLE = §fLila -FLAG_COLOR_BLUE = §fBlau -FLAG_COLOR_BROWN = §fBraun -FLAG_COLOR_GREEN = §fGrün -FLAG_COLOR_RED = §fRot -FLAG_COLOR_BLACK = §fSchwarz +FLAG_COLOR_WHITE = §7Weiß +FLAG_COLOR_ORANGE = §7Orange +FLAG_COLOR_MAGENTA = §7Magenta +FLAG_COLOR_LIGHT_BLUE = §7Hellblau +FLAG_COLOR_YELLOW = §7Gelb +FLAG_COLOR_LIME = §7Hellgrün +FLAG_COLOR_PINK = §7Pink +FLAG_COLOR_GRAY = §7Grau +FLAG_COLOR_LIGHT_GRAY = §7Hellgrau +FLAG_COLOR_CYAN = §7Cyan +FLAG_COLOR_PURPLE = §7Lila +FLAG_COLOR_BLUE = §7Blau +FLAG_COLOR_BROWN = §7Braun +FLAG_COLOR_GREEN = §7Grün +FLAG_COLOR_RED = §7Rot +FLAG_COLOR_BLACK = §7Schwarz # Region REGION_TYPE_NORMAL = Normal From af49ec96d0f4caac634f99ce8b984393b3966b94 Mon Sep 17 00:00:00 2001 From: yoyosource Date: Fri, 7 May 2021 18:00:31 +0200 Subject: [PATCH 5/8] Fix ColorMode --- .../region/flags/flagvalues/ColorMode.java | 35 +++++++++---------- 1 file changed, 17 insertions(+), 18 deletions(-) diff --git a/BauSystem_Main/src/de/steamwar/bausystem/region/flags/flagvalues/ColorMode.java b/BauSystem_Main/src/de/steamwar/bausystem/region/flags/flagvalues/ColorMode.java index 846bd9fe..6902a2fb 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/region/flags/flagvalues/ColorMode.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/region/flags/flagvalues/ColorMode.java @@ -27,28 +27,27 @@ import lombok.Getter; @Getter @AllArgsConstructor public enum ColorMode implements Flag.Value { - WHITE(Color.WHITE), - ORANGE(Color.ORANGE), - MAGENTA(Color.MAGENTA), - LIGHT_BLUE(Color.LIGHT_BLUE), - YELLOW(Color.YELLOW), - LIME(Color.LIME), - PINK(Color.PINK), - GRAY(Color.GRAY), - LIGHT_GRAY(Color.LIGHT_GRAY), - CYAN(Color.CYAN), - PURPLE(Color.PURPLE), - BLUE(Color.BLUE), - BROWN(Color.BROWN), - GREEN(Color.GREEN), - RED(Color.RED), - BLACK(Color.BLACK); + WHITE("FLAG_COLOR_WHITE", Color.WHITE), + ORANGE("FLAG_COLOR_ORANGE", Color.ORANGE), + MAGENTA("FLAG_COLOR_MAGENTA", Color.MAGENTA), + LIGHT_BLUE("FLAG_COLOR_LIGHT_BLUE", Color.LIGHT_BLUE), + YELLOW("FLAG_COLOR_YELLOW", Color.YELLOW), + LIME("FLAG_COLOR_LIME", Color.LIME), + PINK("FLAG_COLOR_PINK", Color.PINK), + GRAY("FLAG_COLOR_GRAY", Color.GRAY), + LIGHT_GRAY("FLAG_COLOR_LIGHT_GRAY", Color.LIGHT_GRAY), + CYAN("FLAG_COLOR_CYAN", Color.CYAN), + PURPLE("FLAG_COLOR_PURPLE", Color.PURPLE), + BLUE("FLAG_COLOR_BLUE", Color.BLUE), + BROWN("FLAG_COLOR_BROWN", Color.BROWN), + GREEN("FLAG_COLOR_GREEN", Color.GREEN), + RED("FLAG_COLOR_RED", Color.RED), + BLACK("FLAG_COLOR_BLACK", Color.BLACK); private static ColorMode[] values; + private final String chatValue; private final Color color; - private final String chatValue = "FLAG_COLOR_" + name(); - @Override public ColorMode[] getValues() { if (ColorMode.values == null) { From 85d532f28548584df8123f9875ed1926df43b34d Mon Sep 17 00:00:00 2001 From: yoyosource Date: Fri, 7 May 2021 21:49:14 +0200 Subject: [PATCH 6/8] Add BauScoreboard color chinanigans --- BauSystem_Main/src/BauSystem.properties | 32 ++++++++++--------- .../features/world/BauScoreboard.java | 19 ++++++----- 2 files changed, 28 insertions(+), 23 deletions(-) diff --git a/BauSystem_Main/src/BauSystem.properties b/BauSystem_Main/src/BauSystem.properties index 6be4c686..de598c96 100644 --- a/BauSystem_Main/src/BauSystem.properties +++ b/BauSystem_Main/src/BauSystem.properties @@ -45,22 +45,24 @@ FLAG_TNT_ONLY_TB = §7Kein §eBaurahmen FLAG_DAMAGE_ALLOW = §aan FLAG_DAMAGE_DENY = §caus -FLAG_COLOR_WHITE = §7Weiß -FLAG_COLOR_ORANGE = §7Orange -FLAG_COLOR_MAGENTA = §7Magenta -FLAG_COLOR_LIGHT_BLUE = §7Hellblau -FLAG_COLOR_YELLOW = §7Gelb -FLAG_COLOR_LIME = §7Hellgrün -FLAG_COLOR_PINK = §7Pink -FLAG_COLOR_GRAY = §7Grau +FLAG_COLOR_WHITE = §fWeiß +FLAG_COLOR_ORANGE = §6Orange +FLAG_COLOR_MAGENTA = §dMagenta +FLAG_COLOR_LIGHT_BLUE = §bHellblau +FLAG_COLOR_YELLOW = §eGelb +FLAG_COLOR_LIME = §aHellgrün +## This cannot be converted +FLAG_COLOR_PINK = §ePink +FLAG_COLOR_GRAY = §8Grau FLAG_COLOR_LIGHT_GRAY = §7Hellgrau -FLAG_COLOR_CYAN = §7Cyan -FLAG_COLOR_PURPLE = §7Lila -FLAG_COLOR_BLUE = §7Blau -FLAG_COLOR_BROWN = §7Braun -FLAG_COLOR_GREEN = §7Grün -FLAG_COLOR_RED = §7Rot -FLAG_COLOR_BLACK = §7Schwarz +FLAG_COLOR_CYAN = §3Cyan +FLAG_COLOR_PURPLE = §5Lila +FLAG_COLOR_BLUE = §1Blau +## This cannot be converted +FLAG_COLOR_BROWN = §eBraun +FLAG_COLOR_GREEN = §2Grün +FLAG_COLOR_RED = §cRot +FLAG_COLOR_BLACK = §0Schwarz # Region REGION_TYPE_NORMAL = Normal 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 8aaa42bc..7b66cdcb 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/world/BauScoreboard.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/world/BauScoreboard.java @@ -47,11 +47,13 @@ public class BauScoreboard implements Listener { private HashMap sidebar(Player p) { Region region = Region.getRegion(p.getLocation()); + String colorCode = BauSystem.MESSAGE.parse(region.get(Flag.COLOR).getChatValue(), p).substring(0, 2); + List strings = new ArrayList<>(); strings.add("§1"); - strings.add("§e" + BauSystem.MESSAGE.parse("SCOREBOARD_TIME", p) + "§8: §7" + new SimpleDateFormat(BauSystem.MESSAGE.parse("TIME", p)).format(Calendar.getInstance().getTime())); + strings.add(colorCode + 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("§e" + BauSystem.MESSAGE.parse("SCOREBOARD_REGION", p) + "§8: §7" + region.getDisplayName()); + strings.add(colorCode + BauSystem.MESSAGE.parse("SCOREBOARD_REGION", p) + "§8: §7" + region.getDisplayName()); } strings.add("§2"); @@ -59,22 +61,23 @@ public class BauScoreboard implements Listener { if (!flag.getRegionPredicate().test(region)) { continue; } - strings.add("§e" + BauSystem.MESSAGE.parse(flag.getChatValue(), p) + "§8: " + BauSystem.MESSAGE.parse(region.get(flag).getChatValue(), p)); + String message = BauSystem.MESSAGE.parse(region.get(flag).getChatValue(), p).replace("§e", colorCode); + strings.add(colorCode + BauSystem.MESSAGE.parse(flag.getChatValue(), p) + "§8: " + message); } strings.add("§3"); - strings.add("§e" + BauSystem.MESSAGE.parse("SCOREBOARD_TRACE", p) + "§8: " + BauSystem.MESSAGE.parse(RecordStateMachine.getRecordStatus().getName(), p)); + strings.add(colorCode + BauSystem.MESSAGE.parse("SCOREBOARD_TRACE", p) + "§8: " + BauSystem.MESSAGE.parse(RecordStateMachine.getRecordStatus().getName(), p)); Loader loader = Loader.getLoader(p); - strings.add("§e" + BauSystem.MESSAGE.parse("SCOREBOARD_LOADER", p) + "§8: " + BauSystem.MESSAGE.parse(loader != null ? loader.getStage().getChatValue() : "LOADER_OFF", p)); + strings.add(colorCode + BauSystem.MESSAGE.parse("SCOREBOARD_LOADER", p) + "§8: " + BauSystem.MESSAGE.parse(loader != null ? loader.getStage().getChatValue() : "LOADER_OFF", p)); if (RecordStateMachine.getRecordStatus().isTracing()) { 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(colorCode + BauSystem.MESSAGE.parse("SCOREBOARD_TRACE_TICKS", p) + "§8: §7" + traceTicks()); + strings.add(colorCode + BauSystem.MESSAGE.parse("SCOREBOARD_TRACE_TNT_COUNT", p) + "§8: §7" + RecordStateMachine.size()); } strings.add("§5"); - strings.add("§e" + BauSystem.MESSAGE.parse("SCOREBOARD_TPS", p) + "§8 " + tpsColor() + TPSWarpUtils.getTps(TPSWatcher.TPSType.ONE_SECOND) + tpsLimit()); + strings.add(colorCode + BauSystem.MESSAGE.parse("SCOREBOARD_TPS", p) + "§8 " + tpsColor() + TPSWarpUtils.getTps(TPSWatcher.TPSType.ONE_SECOND) + tpsLimit()); int i = strings.size(); HashMap result = new HashMap<>(); From 90026b89031664fcc9f36b13073323e8c69feca7 Mon Sep 17 00:00:00 2001 From: yoyosource Date: Sun, 9 May 2021 17:22:00 +0200 Subject: [PATCH 7/8] Add BauScoreboard color chinanigans --- BauSystem_Main/src/BauSystem.properties | 4 ++-- .../steamwar/bausystem/region/flags/flagvalues/ColorMode.java | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/BauSystem_Main/src/BauSystem.properties b/BauSystem_Main/src/BauSystem.properties index de598c96..ed37f96a 100644 --- a/BauSystem_Main/src/BauSystem.properties +++ b/BauSystem_Main/src/BauSystem.properties @@ -48,13 +48,13 @@ FLAG_DAMAGE_DENY = §caus FLAG_COLOR_WHITE = §fWeiß FLAG_COLOR_ORANGE = §6Orange FLAG_COLOR_MAGENTA = §dMagenta -FLAG_COLOR_LIGHT_BLUE = §bHellblau +FLAG_COLOR_LIGHT-BLUE = §bHellblau FLAG_COLOR_YELLOW = §eGelb FLAG_COLOR_LIME = §aHellgrün ## This cannot be converted FLAG_COLOR_PINK = §ePink FLAG_COLOR_GRAY = §8Grau -FLAG_COLOR_LIGHT_GRAY = §7Hellgrau +FLAG_COLOR_LIGHT-GRAY = §7Hellgrau FLAG_COLOR_CYAN = §3Cyan FLAG_COLOR_PURPLE = §5Lila FLAG_COLOR_BLUE = §1Blau diff --git a/BauSystem_Main/src/de/steamwar/bausystem/region/flags/flagvalues/ColorMode.java b/BauSystem_Main/src/de/steamwar/bausystem/region/flags/flagvalues/ColorMode.java index 6902a2fb..fac8b572 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/region/flags/flagvalues/ColorMode.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/region/flags/flagvalues/ColorMode.java @@ -30,12 +30,12 @@ public enum ColorMode implements Flag.Value { WHITE("FLAG_COLOR_WHITE", Color.WHITE), ORANGE("FLAG_COLOR_ORANGE", Color.ORANGE), MAGENTA("FLAG_COLOR_MAGENTA", Color.MAGENTA), - LIGHT_BLUE("FLAG_COLOR_LIGHT_BLUE", Color.LIGHT_BLUE), + LIGHT_BLUE("FLAG_COLOR_LIGHT-BLUE", Color.LIGHT_BLUE), YELLOW("FLAG_COLOR_YELLOW", Color.YELLOW), LIME("FLAG_COLOR_LIME", Color.LIME), PINK("FLAG_COLOR_PINK", Color.PINK), GRAY("FLAG_COLOR_GRAY", Color.GRAY), - LIGHT_GRAY("FLAG_COLOR_LIGHT_GRAY", Color.LIGHT_GRAY), + LIGHT_GRAY("FLAG_COLOR_LIGHT-GRAY", Color.LIGHT_GRAY), CYAN("FLAG_COLOR_CYAN", Color.CYAN), PURPLE("FLAG_COLOR_PURPLE", Color.PURPLE), BLUE("FLAG_COLOR_BLUE", Color.BLUE), From b61138efee2f04f4372c0f36e8ec27da5a16d7d5 Mon Sep 17 00:00:00 2001 From: yoyosource Date: Sun, 9 May 2021 17:29:44 +0200 Subject: [PATCH 8/8] Update PrototypeLoader and RegionLoader to DiffSystem --- .../bausystem/region/loader/PrototypeLoader.java | 9 +++++---- .../steamwar/bausystem/region/loader/RegionLoader.java | 9 +++++---- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/BauSystem_Main/src/de/steamwar/bausystem/region/loader/PrototypeLoader.java b/BauSystem_Main/src/de/steamwar/bausystem/region/loader/PrototypeLoader.java index 199c2875..6324fff8 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/region/loader/PrototypeLoader.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/region/loader/PrototypeLoader.java @@ -22,6 +22,8 @@ package de.steamwar.bausystem.region.loader; import de.steamwar.bausystem.region.Prototype; import lombok.experimental.UtilityClass; import org.bukkit.Bukkit; +import yapion.hierarchy.diff.DiffBase; +import yapion.hierarchy.diff.YAPIONDiff; import yapion.hierarchy.types.YAPIONObject; import yapion.parser.YAPIONParser; @@ -33,7 +35,7 @@ import java.io.IOException; @UtilityClass public class PrototypeLoader { - private int loadedVersion = 0; + private YAPIONObject loaded = null; public static final File file = new File(Bukkit.getWorlds().get(0).getWorldFolder(), "prototypes.yapion"); public void load() { @@ -44,11 +46,10 @@ public class PrototypeLoader { throw new SecurityException(e.getMessage(), e); } - int currentVersion = yapionObject.getPlainValueOrDefault("@version", -1); - if (currentVersion != loadedVersion && loadedVersion != 0) { + if (loaded != null && new YAPIONDiff(loaded, yapionObject).getDiffs().stream().anyMatch(diffBase -> !(diffBase instanceof DiffBase.DiffChange))) { throw new SecurityException("Version was not the specified version needed."); } - loadedVersion = currentVersion; + loaded = yapionObject; yapionObject.forEach((key, yapionAnyType) -> { if (yapionAnyType instanceof YAPIONObject) { diff --git a/BauSystem_Main/src/de/steamwar/bausystem/region/loader/RegionLoader.java b/BauSystem_Main/src/de/steamwar/bausystem/region/loader/RegionLoader.java index 8d78cbf3..cbe1b3f4 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/region/loader/RegionLoader.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/region/loader/RegionLoader.java @@ -24,6 +24,8 @@ import de.steamwar.bausystem.region.GlobalRegion; import de.steamwar.bausystem.region.Prototype; import lombok.experimental.UtilityClass; import org.bukkit.Bukkit; +import yapion.hierarchy.diff.DiffBase; +import yapion.hierarchy.diff.YAPIONDiff; import yapion.hierarchy.output.FileOutput; import yapion.hierarchy.types.YAPIONObject; import yapion.hierarchy.types.YAPIONType; @@ -37,7 +39,7 @@ import java.io.IOException; @UtilityClass public class RegionLoader { - private int loadedVersion = 0; + private YAPIONObject loaded = null; private YAPIONObject optionsYapionObject; public static final File file = new File(Bukkit.getWorlds().get(0).getWorldFolder(), "regions.yapion"); @@ -57,11 +59,10 @@ public class RegionLoader { throw new SecurityException(e.getMessage(), e); } - int currentVersion = yapionObject.getPlainValueOrDefault("@version", -1); - if (currentVersion != loadedVersion && loadedVersion != 0) { + if (loaded != null && new YAPIONDiff(loaded, yapionObject).getDiffs().stream().anyMatch(diffBase -> !(diffBase instanceof DiffBase.DiffChange))) { throw new SecurityException("Version was not the specified version needed."); } - loadedVersion = currentVersion; + loaded = yapionObject; File optionsFile = new File(Bukkit.getWorlds().get(0).getWorldFolder(), "options.yapion"); optionsYapionObject = new YAPIONObject();