From 3c22840278094ffa33e7b864457c487e9824619f Mon Sep 17 00:00:00 2001 From: D4rkr34lm Date: Thu, 29 Feb 2024 11:03:59 +0100 Subject: [PATCH] Removed old trace --- .../features/tracer/TNTPosition.java | 76 ----- .../tracer/TraceScoreboardElement.java | 61 ---- .../features/tracer/TracerBauGuiItem.java | 101 ------ .../features/tracer/record/ActiveTracer.java | 23 -- .../record/AutoIgniteTraceRecorder.java | 33 -- .../tracer/record/AutoTraceRecorder.java | 137 --------- .../features/tracer/record/Recorder.java | 153 ---------- .../tracer/record/SimpleTraceRecorder.java | 86 ------ .../tracer/record/SingleTraceRecorder.java | 38 --- .../tracer/record/TNTPrimedIterator.java | 32 -- .../record/TraceRecordAutoDeletion.java | 65 ---- .../features/tracer/record/TraceRecorder.java | 42 --- .../features/tracer/show/EntityShowMode.java | 289 ------------------ .../features/tracer/show/Record.java | 138 --------- .../tracer/show/ShowModeParameter.java | 95 ------ .../tracer/show/ShowModeParameterType.java | 76 ----- .../features/tracer/show/StoredRecords.java | 70 ----- .../tracer/show/TraceShowManager.java | 142 --------- .../features/tracer2/TraceCommand.java | 62 ---- 19 files changed, 1719 deletions(-) delete mode 100644 BauSystem_Main/src/de/steamwar/bausystem/features/tracer/TNTPosition.java delete mode 100644 BauSystem_Main/src/de/steamwar/bausystem/features/tracer/TraceScoreboardElement.java delete mode 100644 BauSystem_Main/src/de/steamwar/bausystem/features/tracer/TracerBauGuiItem.java delete mode 100644 BauSystem_Main/src/de/steamwar/bausystem/features/tracer/record/ActiveTracer.java delete mode 100644 BauSystem_Main/src/de/steamwar/bausystem/features/tracer/record/AutoIgniteTraceRecorder.java delete mode 100644 BauSystem_Main/src/de/steamwar/bausystem/features/tracer/record/AutoTraceRecorder.java delete mode 100644 BauSystem_Main/src/de/steamwar/bausystem/features/tracer/record/Recorder.java delete mode 100644 BauSystem_Main/src/de/steamwar/bausystem/features/tracer/record/SimpleTraceRecorder.java delete mode 100644 BauSystem_Main/src/de/steamwar/bausystem/features/tracer/record/SingleTraceRecorder.java delete mode 100644 BauSystem_Main/src/de/steamwar/bausystem/features/tracer/record/TNTPrimedIterator.java delete mode 100644 BauSystem_Main/src/de/steamwar/bausystem/features/tracer/record/TraceRecordAutoDeletion.java delete mode 100644 BauSystem_Main/src/de/steamwar/bausystem/features/tracer/record/TraceRecorder.java delete mode 100644 BauSystem_Main/src/de/steamwar/bausystem/features/tracer/show/EntityShowMode.java delete mode 100644 BauSystem_Main/src/de/steamwar/bausystem/features/tracer/show/Record.java delete mode 100644 BauSystem_Main/src/de/steamwar/bausystem/features/tracer/show/ShowModeParameter.java delete mode 100644 BauSystem_Main/src/de/steamwar/bausystem/features/tracer/show/ShowModeParameterType.java delete mode 100644 BauSystem_Main/src/de/steamwar/bausystem/features/tracer/show/StoredRecords.java delete mode 100644 BauSystem_Main/src/de/steamwar/bausystem/features/tracer/show/TraceShowManager.java delete mode 100644 BauSystem_Main/src/de/steamwar/bausystem/features/tracer2/TraceCommand.java diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/TNTPosition.java b/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/TNTPosition.java deleted file mode 100644 index cdbd6227..00000000 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/TNTPosition.java +++ /dev/null @@ -1,76 +0,0 @@ -/* - * This file is a part of the SteamWar software. - * - * Copyright (C) 2022 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.tracer; - -import de.steamwar.bausystem.features.tracer.show.Record; -import de.steamwar.bausystem.shared.Position; -import lombok.Getter; -import lombok.Setter; -import org.bukkit.entity.TNTPrimed; -import org.bukkit.util.Vector; - -import java.lang.instrument.Instrumentation; - -@Getter -public class TNTPosition extends Position { - - private final Record.TNTRecord record; - private final int fuseTicks; - private final long timeTicks; - private final Vector previousLocation; - private final Vector velocity; - private final UpdateOrder updateOrder; - private final boolean source; - private final boolean exploded; - - @Setter - private boolean microMotion; - - public TNTPosition(Record.TNTRecord record, TNTPrimed entity, long timeTicks, Vector previousLocation, Vector velocity, UpdateOrder updateOrder, boolean source, boolean exploded) { - super(entity.getLocation().toVector()); - this.record = record; - this.fuseTicks = entity.getFuseTicks(); - this.timeTicks = timeTicks; - this.previousLocation = previousLocation; - this.velocity = velocity; - this.updateOrder = updateOrder; - this.source = source; - this.exploded = exploded; - } - - @Override - public String toString() { - return "Position{" + - "location=" + super.getLocation() + - '}'; - } - - public enum UpdateOrder { - /** - * X is Bigger so comes later - */ - X, - - /** - * Z is Bigger so comes later - */ - Z - } -} diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/TraceScoreboardElement.java b/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/TraceScoreboardElement.java deleted file mode 100644 index 87ae3876..00000000 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/TraceScoreboardElement.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - * 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.tracer; - -import de.steamwar.bausystem.BauSystem; -import de.steamwar.bausystem.features.tracer.record.Recorder; -import de.steamwar.bausystem.features.tracer.show.Record; -import de.steamwar.bausystem.features.tracer.show.StoredRecords; -import de.steamwar.bausystem.region.Region; -import de.steamwar.bausystem.utils.ScoreboardElement; -import de.steamwar.linkage.Linked; -import org.bukkit.entity.Player; - -import java.util.List; - -@Linked -public class TraceScoreboardElement implements ScoreboardElement { - - @Override - public ScoreboardGroup getGroup() { - return ScoreboardGroup.OTHER; - } - - @Override - public int order() { - return 1; - } - - @Override - public String get(Region region, Player p) { - String traceScore = Recorder.INSTANCE.get(region).scoreboard(p); - if (traceScore != null) { - return "§e" + BauSystem.MESSAGE.parse("SCOREBOARD_TRACE", p) + "§8: " + traceScore; - } - List records = StoredRecords.getRecords(region); - if (records.isEmpty()) { - return null; - } - if (records.stream().allMatch(record -> record.getTnt().isEmpty())) { - return null; - } - return "§e" + BauSystem.MESSAGE.parse("SCOREBOARD_TRACE", p) + "§8: " + BauSystem.MESSAGE.parse("TRACE_HAS_TRACES", p); - } -} diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/TracerBauGuiItem.java b/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/TracerBauGuiItem.java deleted file mode 100644 index 5df27f45..00000000 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/TracerBauGuiItem.java +++ /dev/null @@ -1,101 +0,0 @@ -/* - * This file is a part of the SteamWar software. - * - * Copyright (C) 2022 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.tracer; - -import de.steamwar.bausystem.BauSystem; -import de.steamwar.bausystem.Permission; -import de.steamwar.bausystem.SWUtils; -import de.steamwar.bausystem.features.tracer.record.*; -import de.steamwar.bausystem.linkage.specific.BauGuiItem; -import de.steamwar.bausystem.region.Region; -import de.steamwar.inventory.SWInventory; -import de.steamwar.inventory.SWItem; -import de.steamwar.linkage.Linked; -import org.bukkit.Material; -import org.bukkit.entity.Player; -import org.bukkit.event.inventory.ClickType; -import org.bukkit.inventory.ItemStack; - -import java.util.Arrays; -import java.util.Collections; - -@Linked -public class TracerBauGuiItem extends BauGuiItem { - - public TracerBauGuiItem() { - super(21); - } - - @Override - public ItemStack getItem(Player player) { - Region region = Region.getRegion(player.getLocation()); - return SWUtils.setCustomModelData(new SWItem(Material.OBSERVER, BauSystem.MESSAGE.parse("TRACE_GUI_ITEM_NAME", player), Arrays.asList(BauSystem.MESSAGE.parse("TRACE_GUI_ITEM_LORE", player, Recorder.INSTANCE.get(region).scoreboard(player))), false, clickType -> { - }), 1).getItemStack(); - } - - private static void open(Player p) { - Region region = Region.getRegion(p.getLocation()); - TraceRecorder traceRecorder = Recorder.INSTANCE.get(region); - SWInventory inv = new SWInventory(p, 9, BauSystem.MESSAGE.parse("TRACE_GUI_NAME", p)); - if (traceRecorder instanceof ActiveTracer) { - if (traceRecorder instanceof AutoTraceRecorder) { - inv.setItem(1, new SWItem(Material.GRAY_DYE, BauSystem.MESSAGE.parse("TRACE_GUI_TRACE_ACTIVE_AUTO", p))); - } else { - inv.setItem(1, new SWItem(Material.GREEN_DYE, BauSystem.MESSAGE.parse("TRACE_GUI_TRACE_ACTIVE", p), clickType -> { - p.performCommand("trace stop"); - open(p); - })); - } - } else { - inv.setItem(1, new SWItem(Material.RED_DYE, BauSystem.MESSAGE.parse("TRACE_GUI_TRACE_INACTIVE", p), clickType -> { - p.performCommand("trace start"); - open(p); - })); - } - if (traceRecorder instanceof AutoTraceRecorder) { - inv.setItem(3, new SWItem(Material.ENDER_EYE, BauSystem.MESSAGE.parse("TRACE_GUI_AUTO_TRACE_ACTIVE", p), clickType -> { - p.performCommand("trace auto"); - open(p); - })); - } else { - inv.setItem(3, new SWItem(Material.FIREWORK_STAR, BauSystem.MESSAGE.parse("TRACE_GUI_AUTO_TRACE_INACTIVE", p), clickType -> { - p.performCommand("trace auto"); - open(p); - })); - } - inv.setItem(7, new SWItem(Material.BARRIER, BauSystem.MESSAGE.parse("TRACE_GUI_DELETE", p), clickType -> { - p.performCommand("trace delete"); - open(p); - })); - - inv.open(); - } - - @Override - public boolean click(ClickType click, Player p) { - open(p); - return false; - } - - @Override - public Permission permission() { - return Permission.WORLD; - } -} diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/record/ActiveTracer.java b/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/record/ActiveTracer.java deleted file mode 100644 index b0dfeeed..00000000 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/record/ActiveTracer.java +++ /dev/null @@ -1,23 +0,0 @@ -/* - * This file is a part of the SteamWar software. - * - * Copyright (C) 2022 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.tracer.record; - -public interface ActiveTracer { -} diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/record/AutoIgniteTraceRecorder.java b/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/record/AutoIgniteTraceRecorder.java deleted file mode 100644 index 9eb2f0b8..00000000 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/record/AutoIgniteTraceRecorder.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * This file is a part of the SteamWar software. - * - * Copyright (C) 2022 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.tracer.record; - -public class AutoIgniteTraceRecorder extends AutoTraceRecorder implements ActiveTracer { - - @Override - protected String getInactivityMessage() { - return "TRACE_IDLE_AUTO_IGNITE"; - } - - @Override - protected String getScriptState() { - return "IDLE_AUTO_IGNITE"; - } -} 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 deleted file mode 100644 index ba947f31..00000000 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/record/AutoTraceRecorder.java +++ /dev/null @@ -1,137 +0,0 @@ -/* - * This file is a part of the SteamWar software. - * - * Copyright (C) 2022 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.tracer.record; - -import de.steamwar.bausystem.BauSystem; -import de.steamwar.bausystem.features.tpslimit.TPSUtils; -import de.steamwar.bausystem.features.tracer.TNTPosition; -import de.steamwar.bausystem.features.tracer.show.Record; -import de.steamwar.bausystem.features.tracer.show.StoredRecords; -import de.steamwar.bausystem.features.tracer.show.TraceShowManager; -import de.steamwar.bausystem.region.Region; -import lombok.Getter; -import lombok.Setter; -import org.bukkit.entity.Player; -import org.bukkit.entity.TNTPrimed; - -import java.util.HashMap; -import java.util.Map; -import java.util.function.Supplier; - -public abstract class AutoTraceRecorder implements TraceRecorder { - - protected boolean recording = false; - private long startTime = TPSUtils.currentRealTick.get(); - - private final Map recordMap = new HashMap<>(); - private Record record; - - protected Region region; - private Supplier recordSupplier; - - @Setter - @Getter - private TraceRecordAutoDeletion traceRecordAutoDeletion = TraceRecordAutoDeletion.NEVER; - private Record lastRecord; - - private Record.TNTRecord getRecord(TNTPrimed tntPrimed) { - return recordMap.computeIfAbsent(tntPrimed, __ -> record.spawn()); - } - - protected abstract String getInactivityMessage(); - protected void stoppedRecording() { - } - - @Override - public final String scoreboard(Player player) { - if (recording) { - return BauSystem.MESSAGE.parse("TRACE_RECORD", player) + " §8| §e" + (TPSUtils.currentRealTick.get() - startTime) + " §7" + BauSystem.MESSAGE.parse("SCOREBOARD_TRACE_TICKS", player); - } else { - return BauSystem.MESSAGE.parse(getInactivityMessage(), player); - } - } - - private void startRecording() { - if (lastRecord != null && traceRecordAutoDeletion.test(lastRecord)) { - StoredRecords.remove(region, lastRecord); - TraceShowManager.reshow(region); - } - startTime = TPSUtils.currentRealTick.get(); - record = recordSupplier.get(); - recording = true; - } - - @Override - public void init(Region region, Supplier recordSupplier) { - this.region = region; - this.recordSupplier = recordSupplier; - } - - @Override - public void postClear() { - recordMap.clear(); - record = recordSupplier.get(); - } - - @Override - public final void spawn(TNTPrimed tntPrimed) { - if (!recording) { - startRecording(); - } - getRecord(tntPrimed).source(tntPrimed); - } - - @Override - public final void tick(TNTPrimed tntPrimed) { - if (recording) { - getRecord(tntPrimed).location(tntPrimed); - } - } - - @Override - public final void explode(TNTPrimed tntPrimed, boolean inBuildRegion, boolean inTestblockRegion) { - if (recording) { - Record.TNTRecord tntRecord = getRecord(tntPrimed); - if (inBuildRegion) tntRecord.setInBuildArea(true); - if (inTestblockRegion) tntRecord.setInTestblockArea(true); - tntRecord.explode(tntPrimed); - recordMap.remove(tntPrimed); - - if (recordMap.isEmpty() || recordMap.keySet().stream().allMatch(TNTPrimed::isDead)) { - recording = false; - lastRecord = record; - record = null; - stoppedRecording(); - } - } - } - - protected abstract String getScriptState(); - - @Override - public String scriptState() { - return recording ? "RECORDING" : getScriptState(); - } - - @Override - public long scriptTime() { - return TPSUtils.currentRealTick.get() - startTime; - } -} 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 deleted file mode 100644 index 5c89155a..00000000 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/record/Recorder.java +++ /dev/null @@ -1,153 +0,0 @@ -/* - * This file is a part of the SteamWar software. - * - * Copyright (C) 2022 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.tracer.record; - -import de.steamwar.bausystem.BauSystem; -import de.steamwar.bausystem.features.tracer.show.Record; -import de.steamwar.bausystem.features.tracer.show.StoredRecords; -import de.steamwar.bausystem.region.Region; -import de.steamwar.bausystem.region.utils.RegionExtensionType; -import de.steamwar.bausystem.region.utils.RegionType; -import de.steamwar.linkage.Linked; -import org.bukkit.entity.Entity; -import org.bukkit.entity.Player; -import org.bukkit.entity.TNTPrimed; -import org.bukkit.event.EventHandler; -import org.bukkit.event.EventPriority; -import org.bukkit.event.Listener; -import org.bukkit.event.entity.EntityExplodeEvent; -import org.bukkit.event.entity.EntitySpawnEvent; - -import java.util.HashMap; -import java.util.Map; -import java.util.stream.Collectors; - -@Linked -public class Recorder implements Listener { - - public static Recorder INSTANCE; - - { - INSTANCE = this; - } - - private static class DisabledTracerRecorder implements TraceRecorder { - @Override - public String scoreboard(Player player) { - return null; - } - - @Override - public void spawn(TNTPrimed tntPrimed) { - } - - @Override - public void tick(TNTPrimed tntPrimed) { - } - - @Override - public void explode(TNTPrimed tntPrimed, boolean inBuildArea, boolean inTestblockRegion) { - } - - @Override - public String scriptState() { - return "IDLE"; - } - - @Override - public long scriptTime() { - return 0; - } - } - private static final DisabledTracerRecorder DISABLED = new DisabledTracerRecorder(); - - private Map regionTraceRecorderMap = new HashMap<>(); - private Map tntTraceRecorderMap = new HashMap<>(); - - private TraceRecorder get(TNTPrimed tntPrimed) { - return get(tntTraceRecorderMap.computeIfAbsent(tntPrimed, e -> Region.getRegion(e.getLocation()))); - } - - public TraceRecorder get(Region region) { - return regionTraceRecorderMap.getOrDefault(region, DISABLED); - } - - public void set(Region region, TraceRecorder traceRecorder) { - regionTraceRecorderMap.put(region, traceRecorder); - traceRecorder.init(region, () -> { - Record record = new Record(region); - StoredRecords.add(region, record); - return record; - }); - tntTraceRecorderMap.forEach((tntPrimed, rg) -> { - if (rg == region) { - traceRecorder.tick(tntPrimed); - } - }); - } - - public void remove(Region region) { - regionTraceRecorderMap.remove(region); - } - - public void postClear(Region region) { - get(region).postClear(); - } - - @EventHandler - public void onEntitySpawn(EntitySpawnEvent event) { - Entity entity = event.getEntity(); - if (!(entity instanceof TNTPrimed)) { - return; - } - get((TNTPrimed) entity).spawn((TNTPrimed) entity); - } - - { - BauSystem.runTaskTimer(BauSystem.getInstance(), () -> { - tick(); - tntTraceRecorderMap.keySet() - .stream() - .filter(e -> !e.isValid()) - .collect(Collectors.toList()) - .forEach(tntTraceRecorderMap::remove); - }, 1, 1); - } - - private void tick() { - TNTPrimedIterator.impl.iterator().forEach(tntPrimed -> { - get(tntPrimed).tick(tntPrimed); - }); - } - - @EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true) - public void onEntityExplode(EntityExplodeEvent event) { - Entity entity = event.getEntity(); - if (!(entity instanceof TNTPrimed)) { - return; - } - TraceRecorder traceRecorder = get((TNTPrimed) entity); - Region region = tntTraceRecorderMap.get((TNTPrimed) entity); - boolean inBuildRegion = event.blockList().stream().anyMatch(block -> region.inRegion(block.getLocation(), RegionType.BUILD, RegionExtensionType.EXTENSION)); - boolean inTestblockRegion = event.blockList().stream().anyMatch(block -> region.inRegion(block.getLocation(), RegionType.TESTBLOCK, RegionExtensionType.EXTENSION)); - traceRecorder.explode((TNTPrimed) entity, inBuildRegion, inTestblockRegion); - tntTraceRecorderMap.remove(entity); - } -} 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 deleted file mode 100644 index 875d25b5..00000000 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/record/SimpleTraceRecorder.java +++ /dev/null @@ -1,86 +0,0 @@ -/* - * This file is a part of the SteamWar software. - * - * Copyright (C) 2022 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.tracer.record; - -import de.steamwar.bausystem.BauSystem; -import de.steamwar.bausystem.features.tpslimit.TPSUtils; -import de.steamwar.bausystem.features.tracer.show.Record; -import de.steamwar.bausystem.region.Region; -import org.bukkit.entity.Player; -import org.bukkit.entity.TNTPrimed; - -import java.util.HashMap; -import java.util.Map; -import java.util.function.Supplier; - -public class SimpleTraceRecorder implements TraceRecorder, ActiveTracer { - - private final long startTime = TPSUtils.currentRealTick.get(); - private final Map recordMap = new HashMap<>(); - private Record record; - - @Override - public String scoreboard(Player player) { - return BauSystem.MESSAGE.parse("TRACE_RECORD", player) + " §8| §e" + (TPSUtils.currentRealTick.get() - startTime) + " §7" + BauSystem.MESSAGE.parse("SCOREBOARD_TRACE_TICKS", player); - } - - @Override - public void init(Region region, Supplier recordSupplier) { - record = recordSupplier.get(); - } - - @Override - public void postClear() { - recordMap.clear(); - } - - private Record.TNTRecord getRecord(TNTPrimed tntPrimed) { - return recordMap.computeIfAbsent(tntPrimed, __ -> record.spawn()); - } - - @Override - public void spawn(TNTPrimed tntPrimed) { - getRecord(tntPrimed).source(tntPrimed); - } - - @Override - public void tick(TNTPrimed tntPrimed) { - getRecord(tntPrimed).location(tntPrimed); - } - - @Override - public void explode(TNTPrimed tntPrimed, boolean inBuildRegion, boolean inTestblockRegion) { - Record.TNTRecord tntRecord = getRecord(tntPrimed); - if (inBuildRegion) tntRecord.setInBuildArea(true); - if (inTestblockRegion) tntRecord.setInTestblockArea(true); - tntRecord.explode(tntPrimed); - recordMap.remove(tntPrimed); - } - - @Override - public String scriptState() { - return "RECORD"; - } - - @Override - public long scriptTime() { - return TPSUtils.currentRealTick.get() - startTime; - } -} diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/record/SingleTraceRecorder.java b/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/record/SingleTraceRecorder.java deleted file mode 100644 index 7f878869..00000000 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/record/SingleTraceRecorder.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * This file is a part of the SteamWar software. - * - * Copyright (C) 2022 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.tracer.record; - -public class SingleTraceRecorder extends AutoTraceRecorder { - - @Override - protected String getInactivityMessage() { - return "TRACE_IDLE_SINGLE"; - } - - @Override - protected void stoppedRecording() { - Recorder.INSTANCE.remove(region); - } - - @Override - protected String getScriptState() { - return "IDLE_SINGLE"; - } -} diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/record/TNTPrimedIterator.java b/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/record/TNTPrimedIterator.java deleted file mode 100644 index a6f05b5e..00000000 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/record/TNTPrimedIterator.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * This file is a part of the SteamWar software. - * - * Copyright (C) 2022 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.tracer.record; - -import de.steamwar.bausystem.BauSystem; -import de.steamwar.core.VersionDependent; -import org.bukkit.entity.TNTPrimed; - -import java.util.stream.Stream; - -public interface TNTPrimedIterator { - TNTPrimedIterator impl = VersionDependent.getVersionImpl(BauSystem.getInstance()); - - Stream iterator(); -} diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/record/TraceRecordAutoDeletion.java b/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/record/TraceRecordAutoDeletion.java deleted file mode 100644 index a99eff0e..00000000 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/record/TraceRecordAutoDeletion.java +++ /dev/null @@ -1,65 +0,0 @@ -/* - * 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.tracer.record; - -import de.steamwar.bausystem.features.tracer.show.Record; - -public enum TraceRecordAutoDeletion { - - ALWAYS { - @Override - public boolean test(Record record) { - return true; - } - }, - NEVER { - @Override - public boolean test(Record record) { - return false; - } - }, - NO_BUILD_DESTROY { - @Override - public boolean test(Record record) { - return record.getTnt().stream().noneMatch(Record.TNTRecord::isInBuildArea); - } - }, - BUILD_DESTROY { - @Override - public boolean test(Record record) { - return record.getTnt().stream().anyMatch(Record.TNTRecord::isInBuildArea); - } - }, - NO_TESTBLOCK_DESTROY { - @Override - public boolean test(Record record) { - return record.getTnt().stream().noneMatch(Record.TNTRecord::isInTestblockArea); - } - }, - TESTBLOCK_DESTROY { - @Override - public boolean test(Record record) { - return record.getTnt().stream().anyMatch(Record.TNTRecord::isInTestblockArea); - } - }, - ; - - public abstract boolean test(Record record); -} 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 deleted file mode 100644 index ee1ca2e1..00000000 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/record/TraceRecorder.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * This file is a part of the SteamWar software. - * - * Copyright (C) 2022 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.tracer.record; - -import de.steamwar.bausystem.features.tracer.show.Record; -import de.steamwar.bausystem.region.Region; -import org.bukkit.entity.Player; -import org.bukkit.entity.TNTPrimed; - -import java.util.function.Supplier; - -public interface TraceRecorder { - - String scoreboard(Player player); - default void init(Region region, Supplier recordSupplier) { - } - default void postClear() { - } - void spawn(TNTPrimed tntPrimed); - void tick(TNTPrimed tntPrimed); - void explode(TNTPrimed tntPrimed, boolean inBuildRegion, boolean inTestblockRegion); - - String scriptState(); - long scriptTime(); -} diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/show/EntityShowMode.java b/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/show/EntityShowMode.java deleted file mode 100644 index ce45434a..00000000 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/show/EntityShowMode.java +++ /dev/null @@ -1,289 +0,0 @@ -/* - * 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.tracer.show; - -import de.steamwar.bausystem.BauSystem; -import de.steamwar.bausystem.features.tracer.TNTPosition; -import de.steamwar.bausystem.shared.RoundedPosition; -import de.steamwar.bausystem.shared.ShowMode; -import de.steamwar.bausystem.utils.FlatteningWrapper; -import de.steamwar.entity.REntity; -import de.steamwar.entity.REntityServer; -import de.steamwar.entity.RFallingBlockEntity; -import net.md_5.bungee.api.chat.ClickEvent; -import org.bukkit.Material; -import org.bukkit.entity.Player; -import org.bukkit.util.Vector; - -import java.util.*; -import java.util.function.BiConsumer; -import java.util.stream.Collectors; -import java.util.stream.Stream; - -public class EntityShowMode implements ShowMode { - - private final int factor; - private final Player player; - private final ShowModeParameter showModeParameter; - - private REntityServer entityServer; - - private final Map tntEntityMap = new HashMap<>(); - private final Map explodeEntityMap = new HashMap<>(); - private final Map updateEntityMap = new HashMap<>(); - - public EntityShowMode(Player player, ShowModeParameter showModeParameter, int factor) { - this.player = player; - this.showModeParameter = showModeParameter; - this.factor = factor; - } - - @Override - public void show(TNTPosition position) { - if (entityServer == null) { - entityServer = new REntityServer(); - entityServer.setCallback((player, rEntity, entityAction) -> { - if (entityAction != REntityServer.EntityAction.INTERACT) return; - TNTPosition tntPosition = Stream.concat(tntEntityMap.values().stream(), explodeEntityMap.values().stream()) - .filter(entityStack -> entityStack.entity == rEntity) - .findFirst() - .map(entityStack -> entityStack.tntPosition) - .orElse(null); - if (tntPosition == null) return; - - BauSystem.MESSAGE.sendPrefixless("TNT_CLICK_HEADER", player); - BauSystem.MESSAGE.sendPrefixless("TNT_CLICK_FUSE_TIME", player, tntPosition.getFuseTicks()); - BauSystem.MESSAGE.sendPrefixless("TNT_CLICK_POSITION_X", player, tntPosition.getLocation().getX() + ""); - BauSystem.MESSAGE.sendPrefixless("TNT_CLICK_POSITION_Y", player, tntPosition.getLocation().getY() + ""); - BauSystem.MESSAGE.sendPrefixless("TNT_CLICK_POSITION_Z", player, tntPosition.getLocation().getZ() + ""); - BauSystem.MESSAGE.sendPrefixless("TNT_CLICK_VELOCITY_X", player, tntPosition.getVelocity().getX() + ""); - BauSystem.MESSAGE.sendPrefixless("TNT_CLICK_VELOCITY_Y", player, tntPosition.getVelocity().getY() + ""); - BauSystem.MESSAGE.sendPrefixless("TNT_CLICK_VELOCITY_Z", player, tntPosition.getVelocity().getZ() + ""); - }); - entityServer.addPlayer(player); - } - - if (showModeParameter.isBuildDestroyOnly() && !position.getRecord().isInBuildArea()) { - return; - } - - if (showModeParameter.isTestblockDestroyOnly() && !position.getRecord().isInTestblockArea()) { - return; - } - - if (showModeParameter.isMicroMotion() && !position.getRecord().isHasMicroMotion()) { - return; - } - - boolean exploded = position.getRecord().getPositions().stream().anyMatch(TNTPosition::isExploded); - boolean hideWater = !showModeParameter.isWater() && exploded && checkWater(position.getLocation()); - - if (showModeParameter.isExplodeOnly()) { - if (position.isExploded()) { - generatePositions(position, false, false); - } - if (!showModeParameter.isSourceOnly() && !showModeParameter.isMicroMotionLocation() && !hideWater) { - return; - } - } - - if (showModeParameter.isSourceOnly()) { - if (position.isSource()) { - generatePositions(position, false, false); - } - if (!showModeParameter.isMicroMotionLocation() && !hideWater) { - return; - } - } - - if (showModeParameter.isMicroMotionLocation()) { - if (position.isMicroMotion()) { - generatePositions(position, false, false); - } - if (!hideWater) { - return; - } - } - - - if (hideWater) { - if (position.isExploded()) { - for (TNTPosition pos : position.getRecord().getPositions()) { - generatePositions(pos, showModeParameter.isInterpolateY(), showModeParameter.isInterpolateXZ(), (positionType, vector) -> { - RoundedPosition roundedPosition = new RoundedPosition(vector, factor); - Map map; - if (positionType == PositionType.TNT) { - map = tntEntityMap; - } else if (positionType == PositionType.EXPLODE) { - map = explodeEntityMap; - } else { - map = updateEntityMap; - } - map.computeIfPresent(roundedPosition, (roundedPosition1, entityStack) -> { - if (!entityStack.remove(pos.getRecord())) { - return null; - } - return entityStack; - }); - }); - } - } - return; - } - - generatePositions(position, showModeParameter.isInterpolateY(), showModeParameter.isInterpolateXZ()); - } - - @Override - public void hide() { - tntEntityMap.clear(); - explodeEntityMap.clear(); - updateEntityMap.clear(); - if (entityServer != null) { - entityServer.close(); - entityServer = null; - } - } - - private void generatePositions(TNTPosition position, boolean interpolateY, boolean interpolateXZ) { - generatePositions(position, interpolateY, interpolateXZ, (positionType, vector) -> { - RoundedPosition roundedPosition = new RoundedPosition(vector, factor); - EntityStack entityStack; - if (positionType == PositionType.TNT) { - entityStack = tntEntityMap.computeIfAbsent(roundedPosition, i -> new EntityStack(position, vector, positionType, position.getFuseTicks())); - } else if (positionType == PositionType.EXPLODE) { - entityStack = explodeEntityMap.computeIfAbsent(roundedPosition, i -> new EntityStack(position, vector, positionType, position.getFuseTicks())); - } else { - entityStack = updateEntityMap.computeIfAbsent(roundedPosition, i -> new EntityStack(position, vector, positionType, position.getFuseTicks())); - } - entityStack.add(position.getRecord()); - }); - } - - private boolean checkWater(Vector position) { - return FlatteningWrapper.impl.inWater(player.getWorld(), position); - } - - private REntity createEntity(Vector position, PositionType positionType) { - Material material; - if (positionType == PositionType.TNT) { - material = Material.TNT; - } else if (positionType == PositionType.EXPLODE) { - material = Material.RED_STAINED_GLASS; - } else { - material = Material.WHITE_STAINED_GLASS; - } - RFallingBlockEntity entity = new RFallingBlockEntity(entityServer, position.toLocation(player.getWorld()), material); - entity.setNoGravity(true); - return entity; - } - - private class EntityStack { - - private final TNTPosition tntPosition; - private final Vector position; - private final PositionType positionType; - private final int fuseTicks; - - private REntity entity; - private int count; - private List records = new ArrayList<>(); - - public EntityStack(TNTPosition tntPosition, Vector position, PositionType positionType, int fuseTicks) { - this.tntPosition = tntPosition; - this.position = position; - this.positionType = positionType; - this.fuseTicks = fuseTicks; - } - - public void add(Record.TNTRecord record) { - records.add(record); - if (entity == null) { - entity = createEntity(position, positionType); - } - count++; - - int nameShows = 0; - if (showModeParameter.isFuse()) nameShows++; - if (showModeParameter.isCount()) nameShows++; - if (showModeParameter.isEntityId()) nameShows++; - if (showModeParameter.isCalculationOrder()) nameShows++; - - List toShow = new ArrayList<>(); - if (showModeParameter.isFuse()) { - toShow.add((nameShows > 1 ? "F:" : "") + fuseTicks); - } - if (showModeParameter.isCount()) { - toShow.add((nameShows > 1 ? "C:" : "") + new HashSet<>(records).size()); - } - if (showModeParameter.isEntityId()) { - toShow.add((nameShows > 1 ? "I:" : "") + record.getEntityId()); - } - /* - if (showModeParameter.isCalculationOrder()) { - toShow.add((nameShows > 1 ? "O:" : "") + record.getEntityId()); - } - */ - - if (!toShow.isEmpty()) { - entity.setDisplayName(String.join(" ", toShow)); - } - } - - public boolean remove(Record.TNTRecord record) { - if (entity == null) return false; - records.remove(record); - count--; - if (count == 0) { - entity.die(); - entity = null; - return false; - } - return true; - } - } - - public static void generatePositions(TNTPosition position, boolean interpolateY, boolean interpolateXZ, BiConsumer positionCallback) { - positionCallback.accept(position.isExploded() ? PositionType.EXPLODE : PositionType.TNT, position.getLocation()); - if (position.getPreviousLocation() == null) return; - - if (interpolateY) { - Vector updatePointY = position.getPreviousLocation().clone().setY(position.getLocation().getY()); - if (!position.getLocation().equals(updatePointY)) { - positionCallback.accept(PositionType.UPDATE, updatePointY); - } - } - - if (interpolateXZ) { - Vector updatePointXZ = position.getUpdateOrder() == TNTPosition.UpdateOrder.X - ? position.getLocation().clone().setZ(position.getPreviousLocation().getZ()) - : position.getLocation().clone().setX(position.getPreviousLocation().getX()); - if (!position.getLocation().equals(updatePointXZ)) { - positionCallback.accept(PositionType.UPDATE, updatePointXZ); - } - } - } - - public enum PositionType { - TNT, - EXPLODE, - UPDATE - } -} diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/show/Record.java b/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/show/Record.java deleted file mode 100644 index ac8d4e02..00000000 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/show/Record.java +++ /dev/null @@ -1,138 +0,0 @@ -/* - * This file is a part of the SteamWar software. - * - * Copyright (C) 2022 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.tracer.show; - -import de.steamwar.bausystem.features.tpslimit.TPSUtils; -import de.steamwar.bausystem.features.tracer.TNTPosition; -import de.steamwar.bausystem.region.Region; -import de.steamwar.bausystem.shared.ShowMode; -import lombok.Getter; -import lombok.RequiredArgsConstructor; -import lombok.Setter; -import org.bukkit.entity.TNTPrimed; -import org.bukkit.util.Vector; - -import java.util.ArrayList; -import java.util.List; - -@RequiredArgsConstructor -public class Record { - - @Getter - private final List tnt = new ArrayList<>(); - private final Region region; - private final long startTicks = TPSUtils.currentTick.get(); - - public int size() { - return tnt.size(); - } - - public void showAll(ShowMode traceShowMode) { - tnt.forEach(tntRecord -> tntRecord.getPositions().forEach(traceShowMode::show)); - } - - public TNTRecord spawn() { - TNTRecord record = new TNTRecord(this, region); - tnt.add(record); - return record; - } - - public void clear() { - tnt.clear(); - } - - private void checkMicroMotion(Vector explosionPosition) { - for (TNTRecord tntRecord : tnt) { - List positions = tntRecord.positions; - if (positions.isEmpty()) continue; - TNTPosition position = positions.get(positions.size() - 1); - if (position.isExploded()) continue; - if (position.getLocation().distanceSquared(explosionPosition) > 64) continue; - - Vector velocity = position.getVelocity(); - if (velocity.getY() == 0 && ((velocity.getX() != 0 && Math.abs(velocity.getX()) < 0.001) || (velocity.getZ() != 0 && Math.abs(velocity.getZ()) < 0.001))) { - if (!tntRecord.hasMicroMotion) { - positions.forEach(tntPosition -> TraceShowManager.show(region, tntPosition)); - } - tntRecord.hasMicroMotion = true; - position.setMicroMotion(true); - } - } - } - - public static class TNTRecord { - - @Getter - private int entityId; - - private Record record; - - @Getter - private final Region region; - - @Getter - private final List positions = new ArrayList<>(); - - @Getter - @Setter - private boolean inBuildArea = false; - - @Getter - @Setter - private boolean inTestblockArea = false; - - @Getter - private boolean hasMicroMotion = false; - - public TNTRecord(Record record, Region region) { - this.record = record; - this.region = region; - } - - public void source(TNTPrimed tntPrimed) { - add(tntPrimed, true, false); - } - - public void location(TNTPrimed tntPrimed) { - add(tntPrimed, false, false); - } - - public void explode(TNTPrimed tntPrimed) { - add(tntPrimed, false, true); - record.checkMicroMotion(tntPrimed.getLocation().toVector()); - } - - private void add(TNTPrimed tntPrimed, boolean source, boolean exploded) { - entityId = tntPrimed.getEntityId(); - - TNTPosition position; - if (positions.isEmpty()) { - position = new TNTPosition(this, tntPrimed, TPSUtils.currentTick.get() - record.startTicks, null, tntPrimed.getVelocity(), null, source, exploded); - } else { - TNTPosition tntPosition = positions.get(positions.size() - 1); - Vector lastVelocity = tntPrimed.getLocation().toVector().clone().subtract(tntPosition.getLocation()); - TNTPosition.UpdateOrder updateOrder = Math.abs(lastVelocity.getX()) >= Math.abs(lastVelocity.getZ()) ? TNTPosition.UpdateOrder.X : TNTPosition.UpdateOrder.Z; - position = new TNTPosition(this, tntPrimed, TPSUtils.currentTick.get() - record.startTicks, positions.get(positions.size() - 1).getLocation(), tntPrimed.getVelocity(), updateOrder, source, exploded); - } - positions.add(position); - TraceShowManager.show(region, position); - } - } -} diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/show/ShowModeParameter.java b/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/show/ShowModeParameter.java deleted file mode 100644 index 72089326..00000000 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/show/ShowModeParameter.java +++ /dev/null @@ -1,95 +0,0 @@ -/* - * This file is a part of the SteamWar software. - * - * Copyright (C) 2022 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.tracer.show; - -import lombok.Getter; - -@Getter -public class ShowModeParameter { - private boolean water = false; - private boolean interpolateY = false; - private boolean interpolateXZ = false; - private boolean sourceOnly = false; - private boolean explodeOnly = false; - private boolean fuse = false; - private boolean count = false; - private boolean buildDestroyOnly = false; - private boolean testblockDestroyOnly = false; - private boolean microMotion = false; - private boolean microMotionLocation = false; - private boolean entityId = false; - private boolean calculationOrder = false; - - public void enableWater() { - this.water = true; - } - - public void disableWater() { - this.water = false; - } - - public void enableInterpolateY() { - this.interpolateY = true; - } - - public void enableInterpolateXZ() { - this.interpolateXZ = true; - } - - public void enableSourceOnly() { - this.sourceOnly = true; - } - - public void enableExplodeOnly() { - this.explodeOnly = true; - } - - public void enableFuse() { - this.fuse = true; - } - - public void enableCount() { - this.count = true; - } - - public void enableBuildDestroyOnly() { - this.buildDestroyOnly = true; - } - - public void enableTestblockDestroyOnly() { - this.testblockDestroyOnly = true; - } - - public void enableMicroMotion() { - this.microMotion = true; - } - - public void enableMicroMotionLocation() { - this.microMotionLocation = true; - } - - public void enableEntityId() { - entityId = true; - } - - public void enableCalculationOrder() { - calculationOrder = true; - } -} diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/show/ShowModeParameterType.java b/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/show/ShowModeParameterType.java deleted file mode 100644 index 763df5d4..00000000 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/show/ShowModeParameterType.java +++ /dev/null @@ -1,76 +0,0 @@ -/* - * This file is a part of the SteamWar software. - * - * Copyright (C) 2022 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.tracer.show; - -import lombok.Getter; - -import java.util.Arrays; -import java.util.List; -import java.util.concurrent.atomic.AtomicReference; -import java.util.function.Consumer; -import java.util.function.Supplier; - -public enum ShowModeParameterType { - - WATER(ShowModeParameter::enableWater, Arrays.asList("-water"), "EXPLODE", "SOURCE", "BUILD_DESTROY_ONLY"), - INTERPOLATE_Y(ShowModeParameter::enableInterpolateY, Arrays.asList("-interpolatey", "-interpolate-y", "-interpolate_y", "-y"), "ADVANCED"), - INTERPOLATE_XZ(ShowModeParameter::enableInterpolateXZ, Arrays.asList("-interpolatex", "-interpolate-x", "-interpolate_x", "-x", "-interpolatez", "-interpolate-z", "-interpolate_z", "-z", "-interpolatexz", "-interpolate-xz", "-interpolate_xz", "-xz"), "ADVANCED"), - ADVANCED(showModeParameter -> { - showModeParameter.enableInterpolateY(); - showModeParameter.enableInterpolateXZ(); - }, Arrays.asList("-advanced", "-a"), "INTERPOLATE_Y", "INTERPOLATE_XZ"), - SOURCE(ShowModeParameter::enableSourceOnly, Arrays.asList("-source", "-sourceonly", "-ignite"), "FUSE", "ADVANCED", "INTERPOLATE_Y", "INTERPOLATE_XZ", "WATER"), - EXPLODE(ShowModeParameter::enableExplodeOnly, Arrays.asList("-explode", "-explodeonly"), "FUSE", "ADVANCED", "INTERPOLATE_Y", "INTERPOLATE_XZ", "WATER"), - FUSE(ShowModeParameter::enableFuse, Arrays.asList("-fuse", "-f"), "EXPLODE", "SOURCE"), - COUNT(ShowModeParameter::enableCount, Arrays.asList("-count", "-c")), - BUILD_DESTROY_ONLY(ShowModeParameter::enableBuildDestroyOnly, Arrays.asList("-builddestroy", "-builddestoryonly"), "WATER", "TESTBLOCK_DESTROY_ONLY"), - TESTBLOCK_DESTROY_ONLY(ShowModeParameter::enableTestblockDestroyOnly, Arrays.asList("-testblockdestroy", "-testblockdestroyonly"), "WATER", "BUILD_DESTROY_ONLY"), - MICROMOTION(ShowModeParameter::enableMicroMotion, Arrays.asList("-micromotion", "-micro", "-m")), - MICROMOTION_LOCATION(ShowModeParameter::enableMicroMotionLocation, Arrays.asList("-micromotionloc", "-microloc", "-mloc", "-micromotionlocation", "-microlocation", "-mlocation")), - ENTITY_ID(ShowModeParameter::enableEntityId, Arrays.asList("-entityid", "-id")), - // CALCULATION_ORDER(ShowModeParameter::enableCalculationOrder, Arrays.asList("-calc", "-calcorder", "-calculation", "-calculationorder")), - ; - - @Getter - private final Consumer showModeParameterConsumer; - - @Getter - private List tabCompletes; - - @Getter - private final Supplier removed; - private AtomicReference cached = new AtomicReference<>(); - - ShowModeParameterType(Consumer showModeParameterConsumer, List tabCompletes, String... removed) { - this.showModeParameterConsumer = showModeParameterConsumer; - this.tabCompletes = tabCompletes; - this.removed = () -> { - if (cached.get() == null) { - ShowModeParameterType[] showModeParameterTypes = new ShowModeParameterType[removed.length]; - for (int i = 0; i < removed.length; i++) { - showModeParameterTypes[i] = ShowModeParameterType.valueOf(removed[i]); - } - cached.set(showModeParameterTypes); - return showModeParameterTypes; - } - return cached.get(); - }; - } -} diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/show/StoredRecords.java b/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/show/StoredRecords.java deleted file mode 100644 index 91bc2272..00000000 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/show/StoredRecords.java +++ /dev/null @@ -1,70 +0,0 @@ -/* - * This file is a part of the SteamWar software. - * - * Copyright (C) 2022 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.tracer.show; - -import de.steamwar.bausystem.features.tracer.TNTPosition; -import de.steamwar.bausystem.features.tracer.record.Recorder; -import de.steamwar.bausystem.region.Region; -import de.steamwar.bausystem.shared.ShowMode; -import lombok.experimental.UtilityClass; - -import java.util.*; -import java.util.function.Predicate; -import java.util.stream.Collectors; - -@UtilityClass -public class StoredRecords { - - private static final Map> records = new HashMap<>(); - - public static void add(Region region, Record record) { - records.computeIfAbsent(region, k -> new ArrayList<>()).add(record); - } - - public static void remove(Region region, Record record) { - records.computeIfAbsent(region, k -> new ArrayList<>()).remove(record); - } - - public static void clear(Region region) { - records.remove(region); - TraceShowManager.clear(region); - Recorder.INSTANCE.postClear(region); - } - - public static List getRecords() { - return records.values().stream() - .flatMap(Collection::stream) - .collect(Collectors.toList()); - } - - public static List getRecords(Region region) { - return records.getOrDefault(region, Collections.emptyList()); - } - - static void show(Region region, Predicate traceShowFilter, ShowMode traceShowMode) { - records.getOrDefault(region, new ArrayList<>()).forEach(record -> { - record.getTnt().forEach(tntRecord -> { - tntRecord.getPositions().stream() - .filter(traceShowFilter) - .forEach(traceShowMode::show); - }); - }); - } -} diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/show/TraceShowManager.java b/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/show/TraceShowManager.java deleted file mode 100644 index 695c8115..00000000 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/show/TraceShowManager.java +++ /dev/null @@ -1,142 +0,0 @@ -/* - * This file is a part of the SteamWar software. - * - * Copyright (C) 2022 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.tracer.show; - -import de.steamwar.bausystem.BauSystem; -import de.steamwar.bausystem.features.tracer.TNTPosition; -import de.steamwar.bausystem.region.Region; -import de.steamwar.bausystem.shared.ShowMode; -import org.bukkit.Bukkit; -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.event.Listener; -import org.bukkit.event.player.PlayerQuitEvent; - -import java.util.HashMap; -import java.util.Map; -import java.util.function.Predicate; - -public class TraceShowManager implements Listener { - private TraceShowManager() { - } - - private static final Map>> showModes = new HashMap<>(); - private static final Map>> showFilters = new HashMap<>(); - - public static void show(Player player, ShowMode traceShowMode) { - Region region = Region.getRegion(player.getLocation()); - _hide(region, player, true); - - Map> regionalShowModes = showModes.computeIfAbsent(region, __ -> new HashMap<>()); - regionalShowModes.put(player, traceShowMode); - StoredRecords.show(region, getShowFilter(player, region), traceShowMode); - } - - public static void hide(Player player) { - Region region = Region.getRegion(player.getLocation()); - _hide(region, player, true); - - showFilters.getOrDefault(region, new HashMap<>()).remove(player); - } - - public static void setShowFilter(Player player, Predicate showFilter) { - Region region = Region.getRegion(player.getLocation()); - Map> regionShowFilters = showFilters.computeIfAbsent(region, __ -> new HashMap<>()); - if (showFilter == null) { - regionShowFilters.remove(player); - } else { - regionShowFilters.put(player, showFilter); - } - - _hide(region, player, false); - ShowMode showMode = showModes.computeIfAbsent(region, __ -> new HashMap<>()).computeIfAbsent(player, __ -> new EntityShowMode(player, new ShowModeParameter(), 16)); - StoredRecords.show(region, getShowFilter(player, region), showMode); - } - - public static void reshow(Region region) { - Map> regionalShowModes = showModes.get(region); - if (regionalShowModes == null) { - return; - } - for (Map.Entry> entry : regionalShowModes.entrySet()) { - entry.getValue().hide(); - StoredRecords.show(region, getShowFilter(entry.getKey(), region), entry.getValue()); - } - } - - private static void _hide(Region region, Player player, boolean remove) { - Map> regionalShowModes = showModes.get(region); - if (regionalShowModes == null) { - return; - } - ShowMode showMode; - if (remove) { - showMode = regionalShowModes.remove(player); - } else { - showMode = regionalShowModes.get(player); - } - if (showMode == null) { - return; - } - showMode.hide(); - } - - private static Predicate getShowFilter(Player player, Region region) { - return showFilters.getOrDefault(region, new HashMap<>()).getOrDefault(player, tntPosition -> true); - } - - /* Only to be called by record */ - static void show(Region region, TNTPosition tnt) { - Map> regionalShowModes = showModes.get(region); - if (regionalShowModes == null) { - return; - } - regionalShowModes.forEach((player, tntPositionShowMode) -> { - if (getShowFilter(player, region).test(tnt)) { - tntPositionShowMode.show(tnt); - } - }); - } - - /* Only to be called by StoredRecords */ - static void clear(Region region) { - Map> regionalShowModes = showModes.get(region); - if (regionalShowModes == null) { - return; - } - regionalShowModes.values().forEach(ShowMode::hide); - } - - /* Internal if player leaves*/ - static { - Bukkit.getPluginManager().registerEvents(new TraceShowManager(), BauSystem.getInstance()); - } - - @EventHandler - public void onLeave(PlayerQuitEvent event) { - showModes.forEach((region, playerShowModeMap) -> { - ShowMode showMode = playerShowModeMap.remove(event.getPlayer()); - if (showMode != null) showMode.hide(); - }); - showFilters.forEach((region, playerPredicateMap) -> { - playerPredicateMap.remove(event.getPlayer()); - }); - } -} diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/tracer2/TraceCommand.java b/BauSystem_Main/src/de/steamwar/bausystem/features/tracer2/TraceCommand.java deleted file mode 100644 index d99ed495..00000000 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/tracer2/TraceCommand.java +++ /dev/null @@ -1,62 +0,0 @@ -/* - * 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.tracer2; - -import de.steamwar.bausystem.region.Region; -import de.steamwar.command.SWCommand; -import de.steamwar.linkage.Linked; -import de.steamwar.linkage.LinkedInstance; -import org.bukkit.entity.Player; - -import java.util.Collections; -import java.util.HashSet; - -@Linked -public class TraceCommand extends SWCommand { - - @LinkedInstance - public Recorder recorder; - - int traceId = 0; - public TraceCommand(){super("tracetest");} - - @Register(value = "start") - public void test(Player player){ - Region region = Region.getRegion(player.getLocation()); - - traceId = recorder.startRecording(region); - System.out.println(traceId); - } - - @Register(value = "stop") - public void test2(Player player){ - Region region = Region.getRegion(player.getLocation()); - recorder.stopRecording(region); - Trace trace = recorder.manager.get(traceId); - if(trace != null) - System.out.println(trace.getRecords()); - } - - @Register(value = "show") - public void test3(Player player){ - Trace trace = recorder.manager.get(traceId); - trace.render(player, Collections.emptyList(), BundleFilter.DEFAULT); - } -}