diff --git a/BauSystem_Main/src/BauSystem.properties b/BauSystem_Main/src/BauSystem.properties index a3860e34..82d131d2 100644 --- a/BauSystem_Main/src/BauSystem.properties +++ b/BauSystem_Main/src/BauSystem.properties @@ -37,6 +37,9 @@ SCOREBOARD_TPS_FROZEN = §e Frozen SCOREBOARD_TRACE_TICKS = Ticks +SCOREBOARD_TECHHIDER = TechHider +SCOREBOARD_XRAY = XRay + # Flags FLAG_COLOR = Color FLAG_TNT = TNT @@ -159,6 +162,12 @@ COUNTINGWAND_MESSAGE_LCLICK = §7Second position at: §8[§7{0}§8, §7{1}§8, COUNTINGWAND_MESSAGE_VOLUME = §e{0} COUNTINGWAND_MESSAGE_DIMENSION = §e{0}§8, §e{1}§8, §e{2} +# Design Endstone +DESIGN_ENDSTONE_COMMAND_HELP = §8/§edesign endstone §8- §7Show where Endstone is +DESIGN_ENDSTONE_REGION_ERROR = §cThis region has no build area +DESIGN_ENDSTONE_ENABLE = §aEndstone is activated +DESIGN_ENDSTONE_DISABLE = §cEndstone is deactivated + # Detonator DETONATOR_LOC_REMOVE = §e{0} removed DETONATOR_LOC_ADD = §e{0} added diff --git a/BauSystem_Main/src/BauSystem_de.properties b/BauSystem_Main/src/BauSystem_de.properties index 9689be29..ed657b0d 100644 --- a/BauSystem_Main/src/BauSystem_de.properties +++ b/BauSystem_Main/src/BauSystem_de.properties @@ -157,6 +157,12 @@ COUNTINGWAND_MESSAGE_LCLICK = §7Zweite Position bei: §8[§7{0}§8, §7{1}§8, COUNTINGWAND_MESSAGE_VOLUME = §e{0} COUNTINGWAND_MESSAGE_DIMENSION = §e{0}§8, §e{1}§8, §e{2} +# Design Endstone +DESIGN_ENDSTONE_COMMAND_HELP = §8/§edesign endstone §8- §7Zeige wo Endstone ist +DESIGN_ENDSTONE_REGION_ERROR = §cDiese Region hat keinen Baubereich +DESIGN_ENDSTONE_ENABLE = §aEndstone ist aktiviert +DESIGN_ENDSTONE_DISABLE = §cEndstone ist deaktiviert + # Detonator DETONATOR_LOC_REMOVE = §e{0} entfernt DETONATOR_LOC_ADD = §e{0} hinzugefügt diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/design/endstone/DesignEndStone.java b/BauSystem_Main/src/de/steamwar/bausystem/features/design/endstone/DesignEndStone.java new file mode 100644 index 00000000..b2c83c7e --- /dev/null +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/design/endstone/DesignEndStone.java @@ -0,0 +1,109 @@ +/* + * This file is a part of the SteamWar software. + * + * Copyright (C) 2023 SteamWar.de-Serverteam + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package de.steamwar.bausystem.features.design.endstone; + +import de.steamwar.bausystem.BauSystem; +import de.steamwar.bausystem.region.Region; +import de.steamwar.entity.REntity; +import de.steamwar.entity.REntityServer; +import de.steamwar.entity.RFallingBlockEntity; +import net.md_5.bungee.api.ChatMessageType; +import org.bukkit.Bukkit; +import org.bukkit.Location; +import org.bukkit.Material; +import org.bukkit.World; +import org.bukkit.entity.Player; + +import java.util.ArrayList; +import java.util.HashSet; +import java.util.List; +import java.util.Set; + +public class DesignEndStone { + + private static final World WORLD = Bukkit.getWorlds().get(0); + + private int minX, minY, minZ, maxX, maxY, maxZ; + private REntityServer entityServer = new REntityServer(); + private List entities = new ArrayList<>(); + private Set locations = new HashSet<>(); + private List players = new ArrayList<>(); + + public DesignEndStone(Region region) { + this.minX = region.getMinPointBuild().getX(); + this.minY = region.getMinPointBuild().getY(); + this.minZ = region.getMinPointBuild().getZ(); + this.maxX = region.getMaxPointBuild().getX(); + this.maxY = region.getMaxPointBuild().getY(); + this.maxZ = region.getMaxPointBuild().getZ(); + } + + private void calc() { + entities.forEach(REntity::die); + entities.clear(); + locations.clear(); + + calc(minX, minY, minZ, maxX, maxY, minZ, 0, 0, 1, maxZ - minZ); + calc(minX, minY, maxZ, maxX, maxY, maxZ, 0, 0, -1, maxZ - minZ); + calc(minX, minY, minZ, minX, maxY, maxZ, 1, 0, 0, maxX - minX); + calc(maxX, minY, minZ, maxX, maxY, maxZ, -1, 0, 0, maxX - minX); + // calc(minX, minY, minZ, maxX, minY, maxZ, 0, 1, 0, maxY - minY); + calc(minX, maxY, minZ, maxX, maxY, maxZ, 0, -1, 0, maxY - minY); + } + + private void calc(int minX, int minY, int minZ, int maxX, int maxY, int maxZ, int dirX, int dirY, int dirZ, int steps) { + for (int x = minX; x <= maxX; x++) { + for (int y = minY; y <= maxY; y++) { + for (int z = minZ; z <= maxZ; z++) { + for (int step = 0; step < steps; step++) { + int cx = x + step * dirX; + int cy = y + step * dirY; + int cz = z + step * dirZ; + Material material = WORLD.getBlockAt(cx, cy, cz).getType(); + if (material == Material.END_STONE || material == Material.END_STONE_BRICKS || material == Material.END_STONE_BRICK_SLAB || material == Material.END_STONE_BRICK_STAIRS || material == Material.END_STONE_BRICK_WALL) { + Location location = new Location(WORLD, cx + 0.5, cy, cz + 0.5); + if (locations.contains(location)) break; + RFallingBlockEntity entity = new RFallingBlockEntity(entityServer, location, Material.RED_STAINED_GLASS); + entity.setNoGravity(true); + entity.setGlowing(true); + entities.add(entity); + break; + } else if (!material.isAir()) { + break; + } + } + } + } + } + } + + public void toggle(Player player) { + if (players.contains(player)) { + players.remove(player); + entityServer.removePlayer(player); + BauSystem.MESSAGE.send("DESIGN_ENDSTONE_DISABLE", player, ChatMessageType.ACTION_BAR); + } else { + players.add(player); + entityServer.addPlayer(player); + calc(); + BauSystem.MESSAGE.send("DESIGN_ENDSTONE_ENABLE", player, ChatMessageType.ACTION_BAR); + } + } +} diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/design/endstone/DesignEndStoneCommand.java b/BauSystem_Main/src/de/steamwar/bausystem/features/design/endstone/DesignEndStoneCommand.java new file mode 100644 index 00000000..56b2d419 --- /dev/null +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/design/endstone/DesignEndStoneCommand.java @@ -0,0 +1,50 @@ +/* + * This file is a part of the SteamWar software. + * + * Copyright (C) 2023 SteamWar.de-Serverteam + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package de.steamwar.bausystem.features.design.endstone; + +import de.steamwar.bausystem.BauSystem; +import de.steamwar.bausystem.region.Region; +import de.steamwar.bausystem.region.utils.RegionType; +import de.steamwar.command.SWCommand; +import de.steamwar.linkage.Linked; +import org.bukkit.entity.Player; + +import java.util.HashMap; +import java.util.Map; + +@Linked +public class DesignEndStoneCommand extends SWCommand { + + public DesignEndStoneCommand() { + super("designendstone"); + } + + private Map designEndStoneMap = new HashMap<>(); + + @Register(description = "DESIGN_ENDSTONE_COMMAND_HELP") + public void genericCommand(Player player) { + Region region = Region.getRegion(player.getLocation()); + if (!region.hasType(RegionType.BUILD)) { + BauSystem.MESSAGE.send("DESIGN_ENDSTONE_REGION_ERROR", player); + return; + } + designEndStoneMap.computeIfAbsent(region, DesignEndStone::new).toggle(player); + } +} diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/TNTSimulator.java b/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/TNTSimulator.java index f9513cd4..46d9779a 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/TNTSimulator.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/TNTSimulator.java @@ -167,7 +167,30 @@ public class TNTSimulator { if (elements.size() == 1) { TNTElementGUI.open(player, (TNTElement) elements.get(0), null); } else { - TNTSimulatorGui.open(player, null, null, () -> elements, null); + List tntGroups = tntElementList.stream().filter(TNTGroup.class::isInstance).map(TNTGroup.class::cast).collect(Collectors.toList()); + List newElementList = new ArrayList<>(); + for (TNTGroup tntGroup : tntGroups) { + if (new HashSet<>(elements).containsAll(tntGroup.getElements())) { + newElementList.add(tntGroup); + elements.removeAll(tntGroup.getElements()); + } + } + newElementList.addAll(elements); + if (newElementList.size() == 1) { + SimulatorElement element = newElementList.get(0); + if (element instanceof TNTGroup) { + TNTGroup tntGroup = (TNTGroup) element; + TNTSimulatorGui.open(player, null, tntGroup, () -> { + List elementList = new ArrayList<>(); + elementList.addAll(tntGroup.getElements()); + return elementList; + }, null); + } else { + TNTElementGUI.open(player, (TNTElement) elements.get(0), null); + } + } else { + TNTSimulatorGui.open(player, null, null, () -> newElementList, null); + } } return; } diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/techhider/TechHiderCommand.java b/BauSystem_Main/src/de/steamwar/bausystem/features/techhider/TechHiderCommand.java index 622632fd..e06724ba 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/techhider/TechHiderCommand.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/techhider/TechHiderCommand.java @@ -50,6 +50,16 @@ public class TechHiderCommand extends SWCommand implements Listener { private Map> techHiders = new HashMap<>(); private Map> hidden = new HashMap<>(); + private static TechHiderCommand INSTANCE; + + { + INSTANCE = this; + } + + public static boolean isHidden(Region region, Player player) { + return INSTANCE.hidden.getOrDefault(region, Collections.emptySet()).contains(player); + } + @LinkedInstance public XrayCommand xrayCommand; diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/TraceCommand.java b/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/TraceCommand.java index b24ec012..b79d08f0 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/TraceCommand.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/TraceCommand.java @@ -209,11 +209,10 @@ public class TraceCommand extends SWCommand { @AllArgsConstructor private enum ShowModeType { - ENTITY((player, showModeParameter) -> new EntityShowMode(player, showModeParameter, 10), new ShowModeParameterType[]{}), - RAW((player, showModeParameter) -> new EntityShowMode(player, showModeParameter, -1), new ShowModeParameterType[]{}); + ENTITY((player, showModeParameter) -> new EntityShowMode(player, showModeParameter, 10)), + RAW((player, showModeParameter) -> new EntityShowMode(player, showModeParameter, -1)); private BiFunction> showModeBiFunction; - private ShowModeParameterType[] removedTypes; } @ClassMapper(value = ShowModeParameterType.class, local = true) @@ -235,9 +234,6 @@ public class TraceCommand extends SWCommand { @Override public List tabCompletes(CommandSender commandSender, PreviousArguments previousArguments, String s) { Set showModeParameterTypeSet = new HashSet<>(); - previousArguments.getAll(ShowModeType.class).forEach(showModeType -> { - showModeParameterTypeSet.addAll(Arrays.asList(showModeType.removedTypes)); - }); Arrays.stream(previousArguments.userArgs).map(showModeParameterTypesMap::get).forEach(showModeParameterTypeSet::add); showModeParameterTypeSet.remove(null); diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/record/AutoTraceRecorder.java b/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/record/AutoTraceRecorder.java index 49253e08..2af4146b 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/record/AutoTraceRecorder.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/record/AutoTraceRecorder.java @@ -70,10 +70,9 @@ public abstract class AutoTraceRecorder implements TraceRecorder { } @Override - public Record postClear() { + public void postClear() { recordMap.clear(); record = recordSupplier.get(); - return record; } @Override diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/record/Recorder.java b/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/record/Recorder.java index 8b3fcea0..5d580005 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/record/Recorder.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/record/Recorder.java @@ -147,11 +147,7 @@ public class Recorder implements Listener { } public void postClear(Region region) { - TraceRecorder traceRecorder = get(region); - Record record = traceRecorder.postClear(); - if (record != null) { - StoredRecords.add(region, record); - } + get(region).postClear(); } @EventHandler diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/record/SimpleTraceRecorder.java b/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/record/SimpleTraceRecorder.java index a1d03f27..79e984aa 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/record/SimpleTraceRecorder.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/record/SimpleTraceRecorder.java @@ -46,9 +46,8 @@ public class SimpleTraceRecorder implements TraceRecorder, ActiveTracer { } @Override - public Record postClear() { + public void postClear() { recordMap.clear(); - return record; } private Record.TNTRecord getRecord(TNTPrimed tntPrimed) { diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/record/TraceRecorder.java b/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/record/TraceRecorder.java index 2c75bf07..bb2a1325 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/record/TraceRecorder.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/record/TraceRecorder.java @@ -30,8 +30,7 @@ public interface TraceRecorder { String scoreboard(Player player); default void recordSupplier(Supplier recordSupplier) { } - default Record postClear() { - return null; + default void postClear() { } void spawn(TNTPrimed tntPrimed); void tick(TNTPrimed tntPrimed); 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 ace614eb..2d170bda 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/world/BauScoreboard.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/world/BauScoreboard.java @@ -3,10 +3,12 @@ package de.steamwar.bausystem.features.world; import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.features.loader.Loader; import de.steamwar.bausystem.features.script.CustomScriptManager; +import de.steamwar.bausystem.features.techhider.TechHiderCommand; import de.steamwar.bausystem.features.tpslimit.FreezeUtils; import de.steamwar.bausystem.features.tpslimit.TPSLimitUtils; import de.steamwar.bausystem.features.tpslimit.TPSWarpUtils; import de.steamwar.bausystem.features.tracer.record.Recorder; +import de.steamwar.bausystem.features.xray.XrayCommand; import de.steamwar.bausystem.region.GlobalRegion; import de.steamwar.bausystem.region.Region; import de.steamwar.bausystem.region.flags.Flag; @@ -15,6 +17,7 @@ import de.steamwar.linkage.Linked; import de.steamwar.linkage.LinkedInstance; import de.steamwar.scoreboard.SWScoreboard; import de.steamwar.scoreboard.ScoreboardCallback; +import de.steamwar.techhider.TechHider; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; @@ -86,6 +89,11 @@ public class BauScoreboard implements Listener { } strings.add(colorCode + BauSystem.MESSAGE.parse(flag.getChatValue(), p) + "§8: " + BauSystem.MESSAGE.parse(region.get(flag).getChatValue(), p).replace("§e", colorCode)); } + if (TechHiderCommand.isHidden(region, p)) { + strings.add(colorCode + BauSystem.MESSAGE.parse("SCOREBOARD_TECHHIDER", p)); + } else if (XrayCommand.isHidden(region, p)) { + strings.add(colorCode + BauSystem.MESSAGE.parse("SCOREBOARD_XRAY", p)); + } strings.add("§3"); String traceScore = recorder.get(region).scoreboard(p); diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/xray/XrayCommand.java b/BauSystem_Main/src/de/steamwar/bausystem/features/xray/XrayCommand.java index f1232760..9418a7e1 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/xray/XrayCommand.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/xray/XrayCommand.java @@ -57,6 +57,16 @@ public class XrayCommand extends SWCommand implements Listener { private Map> xrayedBlocks = new HashMap<>(); private Map> hidden = new HashMap<>(); + private static XrayCommand INSTANCE; + + { + INSTANCE = this; + } + + public static boolean isHidden(Region region, Player player) { + return INSTANCE.hidden.getOrDefault(region, Collections.emptySet()).contains(player); + } + @LinkedInstance public TechHiderCommand techHiderCommand;