diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/region/items/ColorBauGuiItem.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/region/items/ColorBauGuiItem.java index 119b6fae..ae633edd 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/region/items/ColorBauGuiItem.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/region/items/ColorBauGuiItem.java @@ -22,10 +22,9 @@ package de.steamwar.bausystem.features.region.items; import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.Permission; import de.steamwar.bausystem.linkage.specific.BauGuiItem; -import de.steamwar.bausystem.region.Color; import de.steamwar.bausystem.region.Region; -import de.steamwar.bausystem.region.flags.Flag; import de.steamwar.bausystem.region.flags.ColorMode; +import de.steamwar.bausystem.region.flags.Flag; import de.steamwar.inventory.SWItem; import de.steamwar.inventory.SWListInv; import de.steamwar.linkage.Linked; @@ -45,7 +44,7 @@ public class ColorBauGuiItem extends BauGuiItem { super(2); } - private static Material mapColor(Color color) { + private static Material mapColor(ColorMode color) { switch (color) { case RED: return Material.RED_CONCRETE; @@ -85,17 +84,17 @@ public class ColorBauGuiItem extends BauGuiItem { @Override public ItemStack getItem(Player player) { Region region = Region.getRegion(player.getLocation()); - ColorMode mode = region.getPlain(Flag.COLOR, ColorMode.class); - return new SWItem(mapColor(mode.getColor()), BauSystem.MESSAGE.parse("REGION_ITEM_COLOR", player, BauSystem.MESSAGE.parse(mode.getChatValue(), player))).getItemStack(); + ColorMode mode = region.getFlags().get(Flag.COLOR).orElse(ColorMode.PINK); + return new SWItem(mapColor(mode), BauSystem.MESSAGE.parse("REGION_ITEM_COLOR", player, BauSystem.MESSAGE.parse(mode.getChatValue(), player))).getItemStack(); } @Override public boolean click(ClickType click, Player p) { p.closeInventory(); - ColorMode current = Region.getRegion(p.getLocation()).getPlain(Flag.COLOR, ColorMode.class); + ColorMode current = Region.getRegion(p.getLocation()).getFlags().get(Flag.COLOR).orElse(ColorMode.PINK); List> items = new ArrayList<>(); for (ColorMode value : ColorMode.values()) { - items.add(new SWListInv.SWListEntry<>(new SWItem(mapColor(value.getColor()), (byte) 0, "§f" + BauSystem.MESSAGE.parse(value.getChatValue(), p), Collections.emptyList(), value == current, clickType -> { + items.add(new SWListInv.SWListEntry<>(new SWItem(mapColor(value), (byte) 0, "§f" + BauSystem.MESSAGE.parse(value.getChatValue(), p), Collections.emptyList(), value == current, clickType -> { }), value)); } SWListInv inv = new SWListInv<>(p, BauSystem.MESSAGE.parse("REGION_ITEM_COLOR_CHOOSE", p), items, (clickType, colorMode) -> { diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/tpslimit/TPSSystem.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/tpslimit/TPSSystem.java index f84ab72e..bb03ae0a 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/tpslimit/TPSSystem.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/tpslimit/TPSSystem.java @@ -23,7 +23,6 @@ import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.Permission; import de.steamwar.bausystem.SWUtils; import de.steamwar.bausystem.linkage.specific.BauGuiItem; -import de.steamwar.bausystem.region.GlobalRegion; import de.steamwar.bausystem.region.Region; import de.steamwar.bausystem.utils.ScoreboardElement; import de.steamwar.bausystem.utils.TickEndEvent; @@ -85,14 +84,14 @@ public class TPSSystem implements Listener { private void bossbar() { if ((TickManager.impl.isStepping() || TickManager.impl.isSprinting()) && TickManager.impl.getRemainingTicks() > 0) { Bukkit.getOnlinePlayers().forEach(player -> { - BauSystemBossbar bossbar = BossBarService.instance.get(player, GlobalRegion.getInstance(), "TickStep"); + BauSystemBossbar bossbar = BossBarService.instance.get(player, Region.getGlobalRegion(), "TickStep"); bossbar.setColor(BarColor.YELLOW); bossbar.setTitle(BauSystem.MESSAGE.parse("TICK_BOSSBAR", player, TickManager.impl.getDoneTicks(), TickManager.impl.getTotalTicks())); bossbar.setProgress(TickManager.impl.getDoneTicks() / (double) TickManager.impl.getTotalTicks()); }); } else { Bukkit.getOnlinePlayers().forEach(player -> { - BossBarService.instance.remove(player, GlobalRegion.getInstance(), "TickStep"); + BossBarService.instance.remove(player, Region.getGlobalRegion(), "TickStep"); }); } } diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/worldedit/ColorReplaceCommand.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/worldedit/ColorReplaceCommand.java index 6b6659ba..f3efca4b 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/worldedit/ColorReplaceCommand.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/worldedit/ColorReplaceCommand.java @@ -28,7 +28,7 @@ import com.sk89q.worldedit.util.formatting.text.TextComponent; import com.sk89q.worldedit.util.formatting.text.TranslatableComponent; import de.steamwar.bausystem.features.world.WorldEditListener; import de.steamwar.bausystem.features.worldedit.utils.SpecialReplace; -import de.steamwar.bausystem.region.Color; +import de.steamwar.bausystem.region.flags.ColorMode; import de.steamwar.bausystem.shared.Pair; import de.steamwar.bausystem.utils.WorldEditUtils; import de.steamwar.command.PreviousArguments; @@ -63,7 +63,7 @@ public class ColorReplaceCommand extends SWCommand { @Register(description = "COLORREPLACE_HELP") @SneakyThrows - public void genericCommand(@Validator Player player, Pair from, Color to) { + public void genericCommand(@Validator Player player, Pair from, ColorMode to) { if (from.getValue() == to) { BukkitAdapter.adapt(player).printInfo(TranslatableComponent.of("worldedit.replace.replaced", new Component[]{TextComponent.of(0)})); return; @@ -89,23 +89,23 @@ public class ColorReplaceCommand extends SWCommand { } @ClassMapper(value = Pair.class, local = true) - public TypeMapper> typeMapper() { - return new TypeMapper>() { + public TypeMapper> typeMapper() { + return new TypeMapper>() { @Override - public Pair map(CommandSender commandSender, PreviousArguments previousArguments, String s) { + public Pair map(CommandSender commandSender, PreviousArguments previousArguments, String s) { if (s.contains("%")) { String[] split = s.split("%"); if (split.length != 2) { return null; } - Color color = Color.valueOf(split[1].toUpperCase()); + ColorMode color = ColorMode.valueOf(split[1].toUpperCase()); try { return new Pair<>(Integer.parseInt(split[0]), color); } catch (NumberFormatException e) { return null; } } - return new Pair<>(100, Color.valueOf(s.toUpperCase())); + return new Pair<>(100, ColorMode.valueOf(s.toUpperCase())); } @Override @@ -113,12 +113,12 @@ public class ColorReplaceCommand extends SWCommand { if (s.matches("[0-9].*")) { if (s.contains("%")) { String sub = s.substring(0, s.indexOf("%") + 1); - return Arrays.stream(Color.values()).map(Color::name).map(t -> sub + t.toLowerCase()).collect(Collectors.toSet()); + return Arrays.stream(ColorMode.values()).map(ColorMode::name).map(t -> sub + t.toLowerCase()).collect(Collectors.toSet()); } else { return Arrays.asList(s); } } else { - return Arrays.stream(Color.values()).map(Color::name).map(String::toLowerCase).collect(Collectors.toSet()); + return Arrays.stream(ColorMode.values()).map(ColorMode::name).map(String::toLowerCase).collect(Collectors.toSet()); } } }; diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/Region.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/Region.java index 0b7cd049..d28430a2 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/Region.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/Region.java @@ -34,6 +34,9 @@ public interface Region { static Region getRegion(Location location) { return RegionSystem.INSTANCE.get(location); } + static Region getGlobalRegion() { + return RegionSystem.INSTANCE.getGlobalRegion(); + } UUID getID(); diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/utils/PasteBuilder.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/utils/PasteBuilder.java index a4a74e17..0622bb11 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/utils/PasteBuilder.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/utils/PasteBuilder.java @@ -26,8 +26,8 @@ import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.world.block.BaseBlock; import com.sk89q.worldedit.world.block.BlockType; import com.sk89q.worldedit.world.block.BlockTypes; -import de.steamwar.bausystem.region.Color; import de.steamwar.bausystem.region.Point; +import de.steamwar.bausystem.region.flags.ColorMode; import de.steamwar.sql.SchematicData; import de.steamwar.sql.SchematicNode; import lombok.Getter; @@ -102,8 +102,8 @@ public class PasteBuilder { return this; } - public PasteBuilder color(Color color) { - if (color == Color.PINK) return this; + public PasteBuilder color(ColorMode color) { + if (color == ColorMode.PINK) return this; Map blockCache = new HashMap<>(); return map((clipboard, blockVector3) -> { @@ -122,7 +122,7 @@ public class PasteBuilder { } /** - * Can only be used before {@link #color(Color)}. + * Can only be used before {@link #color(ColorMode)}. */ public PasteBuilder onlyColors(boolean onlyColors) { if (!onlyColors) return this;