From 5de070c90e1a482d94e20e67dfb094b3730b2169 Mon Sep 17 00:00:00 2001 From: yoyosource Date: Sun, 22 Oct 2023 12:07:52 +0200 Subject: [PATCH] Update Tracer --- BauSystem_Main/src/BauSystem.properties | 5 +-- BauSystem_Main/src/BauSystem_de.properties | 2 - .../features/simulator/TNTSimulator.java | 2 +- .../laufbau/states/ProcessingTracesState.java | 2 +- .../features/tracer/TNTPosition.java | 20 ++++++++-- .../features/tracer/TraceCommand.java | 35 ++++++----------- .../record/AutoExplodeTraceRecorder.java | 38 ------------------ .../record/AutoIgniteTraceRecorder.java | 5 --- .../tracer/record/AutoTraceRecorder.java | 39 ++++++------------- .../features/tracer/record/Recorder.java | 5 +-- .../tracer/record/SingleTraceRecorder.java | 13 ------- .../features/tracer/record/TraceRecorder.java | 2 - .../features/tracer/show/EntityShowMode.java | 31 ++++++++++++--- .../features/tracer/show/Record.java | 10 +++-- .../tracer/show/ShowModeParameter.java | 10 +++++ .../tracer/show/ShowModeParameterType.java | 6 ++- 16 files changed, 89 insertions(+), 136 deletions(-) delete mode 100644 BauSystem_Main/src/de/steamwar/bausystem/features/tracer/record/AutoExplodeTraceRecorder.java diff --git a/BauSystem_Main/src/BauSystem.properties b/BauSystem_Main/src/BauSystem.properties index 0037825c..20b50b0b 100644 --- a/BauSystem_Main/src/BauSystem.properties +++ b/BauSystem_Main/src/BauSystem.properties @@ -489,9 +489,7 @@ TPSLIMIT_FROZEN = §eTPS frozen TRACE_RECORD=§aon TRACE_HAS_TRACES=§ehas Traces TRACE_IDLE_SINGLE=§esingle -TRACE_IDLE_AUTO_EXPLODE=§eauto §8(§7explode§8) -TRACE_IDLE_AUTO_IGNITE=§eauto §8(§7ignite§8) -TRACE_MESSAGE_AUTO_IDLE_EXPLODE = §aAuto-Tracer explode started +TRACE_IDLE_AUTO_IGNITE=§eauto TRACE_MESSAGE_AUTO_IDLE_IGNITE = §aAuto-Tracer ignite started TRACE_MESSAGE_AUTO_DELETE_INVALID = §cAuto delete cannot be used currently TRACE_MESSAGE_AUTO_DELETE_ALWAYS = §7Last Shot will §ealways §7be deleted @@ -506,7 +504,6 @@ TRACE_MESSAGE_STOP = §cTNT-Tracer stopped TRACE_MESSAGE_DELETE = §cAll TNT-positions deleted TRACE_MESSAGE_SHOW = §aAll TNT-positions shown TRACE_MESSAGE_HIDE = §cAll TNT-positions hidden -TRACE_MESSAGE_CLICK_ISOLATE = §eClick to §aisolate§8/§cunisolate TRACE_MESSAGE_DISALLOWED = §cYou are not allowed to use the TNT-Tracer here TRACE_MESSAGE_SHOW_AT = §aTNT-positions shown with {0} at {1} TRACE_MESSAGE_SHOW_FROM = §aAll TNT-positions shown with {0} from {1} diff --git a/BauSystem_Main/src/BauSystem_de.properties b/BauSystem_Main/src/BauSystem_de.properties index e5da397d..af268de5 100644 --- a/BauSystem_Main/src/BauSystem_de.properties +++ b/BauSystem_Main/src/BauSystem_de.properties @@ -460,7 +460,6 @@ TRACE_HAS_TRACES=§ehat Traces TRACE_IDLE_SINGLE=§esingle TRACE_IDLE_AUTO_EXPLODE=§eauto §8(§7explode§8) TRACE_IDLE_AUTO_IGNITE=§eauto §8(§7ignite§8) -TRACE_MESSAGE_AUTO_IDLE_EXPLODE = §aAuto-Tracer explode gestartet TRACE_MESSAGE_AUTO_IDLE_IGNITE = §aAuto-Tracer ignite gestartet TRACE_MESSAGE_AUTO_DELETE_INVALID = §cAuto delete kann aktuell nicht genutzt werden TRACE_MESSAGE_AUTO_DELETE_ALWAYS = §7Der letzte Schuss wird §eimmer§7 gelöscht @@ -475,7 +474,6 @@ TRACE_MESSAGE_STOP = §cTNT-Tracer gestoppt TRACE_MESSAGE_DELETE = §cAlle TNT-Positionen gelöscht TRACE_MESSAGE_SHOW = §aAlle TNT-Positionen angezeigt TRACE_MESSAGE_HIDE = §cAlle TNT-Positionen ausgeblendet -TRACE_MESSAGE_CLICK_ISOLATE = §eKlicken zum §aisolieren§8/§causblenden TRACE_MESSAGE_DISALLOWED = §cDu darfst hier nicht den TNT-Tracer nutzen TRACE_MESSAGE_SHOW_AT = §aTNT-positions angezeigt mit {0} bei {1} TRACE_MESSAGE_SHOW_FROM = §aAll TNT-positions angezeigt mit {0} von {1} 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 d1a71b95..a3076b9c 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/TNTSimulator.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/TNTSimulator.java @@ -225,7 +225,7 @@ public class TNTSimulator { } }); if (needsAutoTrace.get()) { - Recorder.INSTANCE.set(region, new SingleTraceRecorder(region)); + Recorder.INSTANCE.set(region, new SingleTraceRecorder()); } AtomicInteger maxTick = new AtomicInteger(0); diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/laufbau/states/ProcessingTracesState.java b/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/laufbau/states/ProcessingTracesState.java index c34e5024..320efaaa 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/laufbau/states/ProcessingTracesState.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/laufbau/states/ProcessingTracesState.java @@ -86,7 +86,7 @@ public class ProcessingTracesState implements LaufbauState { } else { Vector movement = location.clone().subtract(previousLocation); toExpand.add(new Cuboid(previousLocation.getX() - 0.49, Math.min(previousLocation.getY(), location.getY()), previousLocation.getZ() - 0.49, 0.98, Math.abs(movement.getY()) + 0.98, 0.98)); - if (Math.abs(tntPosition.getUpdateVelocity().getX()) >= Math.abs(tntPosition.getUpdateVelocity().getZ())) { + if (tntPosition.getUpdateOrder() == TNTPosition.UpdateOrder.X) { toExpand.add(new Cuboid(Math.min(previousLocation.getX(), location.getX()) - 0.49, location.getY(), previousLocation.getZ() - 0.49, Math.abs(movement.getX()) + 0.98, 0.98, 0.98)); toExpand.add(new Cuboid(location.getX() - 0.49, location.getY(), Math.min(previousLocation.getZ(), location.getZ()) - 0.49, 0.98, 0.98, Math.abs(movement.getZ()) + 0.98)); } else { diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/TNTPosition.java b/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/TNTPosition.java index 1af2b710..cdbd6227 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/TNTPosition.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/TNTPosition.java @@ -26,6 +26,8 @@ import lombok.Setter; import org.bukkit.entity.TNTPrimed; import org.bukkit.util.Vector; +import java.lang.instrument.Instrumentation; + @Getter public class TNTPosition extends Position { @@ -34,21 +36,21 @@ public class TNTPosition extends Position { private final long timeTicks; private final Vector previousLocation; private final Vector velocity; - private final Vector updateVelocity; + 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, Vector updateVelocity, boolean source, boolean exploded) { + 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.updateVelocity = updateVelocity; + this.updateOrder = updateOrder; this.source = source; this.exploded = exploded; } @@ -59,4 +61,16 @@ public class TNTPosition extends 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/TraceCommand.java b/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/TraceCommand.java index 366cc7a3..b05ec3d7 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/TraceCommand.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/TraceCommand.java @@ -23,8 +23,11 @@ import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.Permission; import de.steamwar.bausystem.features.tracer.record.*; import de.steamwar.bausystem.features.tracer.show.*; +import de.steamwar.bausystem.region.GlobalRegion; import de.steamwar.bausystem.region.Region; import de.steamwar.bausystem.shared.ShowMode; +import de.steamwar.bausystem.utils.bossbar.BauSystemBossbar; +import de.steamwar.bausystem.utils.bossbar.BossBarService; import de.steamwar.command.PreviousArguments; import de.steamwar.command.SWCommand; import de.steamwar.command.TypeMapper; @@ -32,6 +35,8 @@ import de.steamwar.command.TypeValidator; import de.steamwar.linkage.Linked; import de.steamwar.linkage.LinkedInstance; import lombok.AllArgsConstructor; +import org.bukkit.Bukkit; +import org.bukkit.boss.BossBar; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; @@ -60,7 +65,7 @@ public class TraceCommand extends SWCommand { @Register(value = {"single"}, description = "TRACE_COMMAND_HELP_SINGLE") public void singleCommand(@Validator Player p) { Region region = Region.getRegion(p.getLocation()); - recorder.set(region, new SingleTraceRecorder(region)); + recorder.set(region, new SingleTraceRecorder()); BauSystem.MESSAGE.send("TRACE_MESSAGE_SINGLE", p); } @@ -73,20 +78,10 @@ public class TraceCommand extends SWCommand { @Register(value = {"auto"}, description = "TRACE_COMMAND_HELP_AUTO") @Register({"toggleauto"}) - public void autoCommand(@Validator Player p, @OptionalValue("-explode") @StaticValue({"-explode", "-ignite"}) String type) { + public void autoCommand(@Validator Player p) { Region region = Region.getRegion(p.getLocation()); - switch (type) { - case "-explode": - recorder.set(region, new AutoExplodeTraceRecorder()); - BauSystem.MESSAGE.send("TRACE_MESSAGE_AUTO_IDLE_EXPLODE", p); - break; - case "-ignite": - recorder.set(region, new AutoIgniteTraceRecorder()); - BauSystem.MESSAGE.send("TRACE_MESSAGE_AUTO_IDLE_IGNITE", p); - break; - default: - break; - } + recorder.set(region, new AutoIgniteTraceRecorder()); + BauSystem.MESSAGE.send("TRACE_MESSAGE_AUTO_IDLE_IGNITE", p); } @Register(value = {"autoremove"}, description = "TRACE_COMMAND_HELP_AUTO_REMOVE") @@ -165,7 +160,7 @@ public class TraceCommand extends SWCommand { // /trace show at 0 // /trace show raw -auto at 0 @Register(value = {"show"}, description = "TRACE_COMMAND_HELP_SHOW") - public void showCommand(@Validator Player p, @OptionalValue("entity") ShowModeType showModeType, ShowModeParameterType... showModeParameterTypes) { + public void showCommand(@Validator Player p, ShowModeParameterType... showModeParameterTypes) { Region region = Region.getRegion(p.getLocation()); ShowModeParameter showModeParameter = new ShowModeParameter(); if (region.getWaterLevel() != 0) { // Enable Water by default for regions with WaterLevel e.g. WarShip @@ -178,7 +173,7 @@ public class TraceCommand extends SWCommand { showModeParameterType.getShowModeParameterConsumer().accept(showModeParameter); } } - TraceShowManager.show(p, showModeType.showModeBiFunction.apply(p, showModeParameter)); + TraceShowManager.show(p, new EntityShowMode(p, showModeParameter, 32)); BauSystem.MESSAGE.send("TRACE_MESSAGE_SHOW", p); } @@ -196,14 +191,6 @@ public class TraceCommand extends SWCommand { BauSystem.MESSAGE.send("TRACE_MESSAGE_DELETE", p); } - @AllArgsConstructor - private enum ShowModeType { - ENTITY((player, showModeParameter) -> new EntityShowMode(player, showModeParameter, 16)), - RAW((player, showModeParameter) -> new EntityShowMode(player, showModeParameter, -1)); - - private BiFunction> showModeBiFunction; - } - @ClassMapper(value = ShowModeParameterType.class, local = true) public TypeMapper showModeParameterTypesTypeMapper() { Map> showModeParameterTypeListMap = new EnumMap<>(ShowModeParameterType.class); diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/record/AutoExplodeTraceRecorder.java b/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/record/AutoExplodeTraceRecorder.java deleted file mode 100644 index 6ff44728..00000000 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/record/AutoExplodeTraceRecorder.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 AutoExplodeTraceRecorder extends AutoTraceRecorder { - - @Override - protected String getInactivityMessage() { - return "TRACE_IDLE_AUTO_EXPLODE"; - } - - @Override - protected boolean shouldStartRecording(StartType startType) { - return startType == StartType.EXPLODE; - } - - @Override - protected String getScriptState() { - return "IDLE_AUTO_EXPLODE"; - } -} 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 index 932634bb..9eb2f0b8 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/record/AutoIgniteTraceRecorder.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/record/AutoIgniteTraceRecorder.java @@ -26,11 +26,6 @@ public class AutoIgniteTraceRecorder extends AutoTraceRecorder implements Active return "TRACE_IDLE_AUTO_IGNITE"; } - @Override - protected boolean shouldStartRecording(StartType startType) { - return startType == StartType.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 index ab326abc..ba947f31 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 @@ -21,6 +21,7 @@ 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; @@ -38,12 +39,11 @@ public abstract class AutoTraceRecorder implements TraceRecorder { protected boolean recording = false; private long startTime = TPSUtils.currentRealTick.get(); - private long lastExplosion = 0; private final Map recordMap = new HashMap<>(); private Record record; - private Region region; + protected Region region; private Supplier recordSupplier; @Setter @@ -56,7 +56,6 @@ public abstract class AutoTraceRecorder implements TraceRecorder { } protected abstract String getInactivityMessage(); - protected abstract boolean shouldStartRecording(StartType startType); protected void stoppedRecording() { } @@ -74,7 +73,6 @@ public abstract class AutoTraceRecorder implements TraceRecorder { StoredRecords.remove(region, lastRecord); TraceShowManager.reshow(region); } - lastExplosion = 0; startTime = TPSUtils.currentRealTick.get(); record = recordSupplier.get(); recording = true; @@ -94,12 +92,10 @@ public abstract class AutoTraceRecorder implements TraceRecorder { @Override public final void spawn(TNTPrimed tntPrimed) { - if (!recording && shouldStartRecording(StartType.IGNITE)) { + if (!recording) { startRecording(); } - if (recording) { - getRecord(tntPrimed).source(tntPrimed); - } + getRecord(tntPrimed).source(tntPrimed); } @Override @@ -111,35 +107,22 @@ public abstract class AutoTraceRecorder implements TraceRecorder { @Override public final void explode(TNTPrimed tntPrimed, boolean inBuildRegion, boolean inTestblockRegion) { - if (!recording && shouldStartRecording(StartType.EXPLODE)) { - startRecording(); - } if (recording) { Record.TNTRecord tntRecord = getRecord(tntPrimed); if (inBuildRegion) tntRecord.setInBuildArea(true); if (inTestblockRegion) tntRecord.setInTestblockArea(true); tntRecord.explode(tntPrimed); - } - lastExplosion = 0; - } + recordMap.remove(tntPrimed); - @Override - public final void tick() { - lastExplosion++; - if (recording && lastExplosion > 80) { - recording = false; - recordMap.clear(); - lastRecord = record; - record = null; - stoppedRecording(); + if (recordMap.isEmpty() || recordMap.keySet().stream().allMatch(TNTPrimed::isDead)) { + recording = false; + lastRecord = record; + record = null; + stoppedRecording(); + } } } - protected enum StartType { - IGNITE, - EXPLODE - } - protected abstract String getScriptState(); @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 1bd04377..5c89155a 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 @@ -35,7 +35,6 @@ import org.bukkit.event.Listener; import org.bukkit.event.entity.EntityExplodeEvent; import org.bukkit.event.entity.EntitySpawnEvent; -import java.util.ArrayList; import java.util.HashMap; import java.util.Map; import java.util.stream.Collectors; @@ -99,7 +98,7 @@ public class Recorder implements Listener { }); tntTraceRecorderMap.forEach((tntPrimed, rg) -> { if (rg == region) { - traceRecorder.spawn(tntPrimed); + traceRecorder.tick(tntPrimed); } }); } @@ -129,7 +128,6 @@ public class Recorder implements Listener { .filter(e -> !e.isValid()) .collect(Collectors.toList()) .forEach(tntTraceRecorderMap::remove); - new ArrayList<>(regionTraceRecorderMap.values()).forEach(TraceRecorder::tick); }, 1, 1); } @@ -151,6 +149,5 @@ public class Recorder implements Listener { boolean inTestblockRegion = event.blockList().stream().anyMatch(block -> region.inRegion(block.getLocation(), RegionType.TESTBLOCK, RegionExtensionType.EXTENSION)); traceRecorder.explode((TNTPrimed) entity, inBuildRegion, inTestblockRegion); tntTraceRecorderMap.remove(entity); - tick(); } } 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 index 6eae0b06..7f878869 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/record/SingleTraceRecorder.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/record/SingleTraceRecorder.java @@ -19,26 +19,13 @@ package de.steamwar.bausystem.features.tracer.record; -import de.steamwar.bausystem.region.Region; - public class SingleTraceRecorder extends AutoTraceRecorder { - private Region region; - - public SingleTraceRecorder(Region region) { - this.region = region; - } - @Override protected String getInactivityMessage() { return "TRACE_IDLE_SINGLE"; } - @Override - protected boolean shouldStartRecording(StartType startType) { - return startType == StartType.EXPLODE; - } - @Override protected void stoppedRecording() { Recorder.INSTANCE.remove(region); 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 c667f4e0..ee1ca2e1 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 @@ -36,8 +36,6 @@ public interface TraceRecorder { void spawn(TNTPrimed tntPrimed); void tick(TNTPrimed tntPrimed); void explode(TNTPrimed tntPrimed, boolean inBuildRegion, boolean inTestblockRegion); - default void tick() { - } 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 index dfa05ac4..ce45434a 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/show/EntityShowMode.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/show/EntityShowMode.java @@ -34,6 +34,7 @@ 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 { @@ -75,7 +76,6 @@ public class EntityShowMode implements ShowMode { 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() + ""); - BauSystem.MESSAGE.sendPrefixless("TNT_CLICK_ISOLATE", player, BauSystem.MESSAGE.parse("TRACE_MESSAGE_CLICK_ISOLATE", player), new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/trace isolate " + tntPosition.getRecord().getId())); }); entityServer.addPlayer(player); } @@ -219,10 +219,31 @@ public class EntityShowMode implements ShowMode { 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()) { - entity.setDisplayName(fuseTicks + ""); - } else if (showModeParameter.isCount()) { - entity.setDisplayName(new HashSet<>(records).size() + ""); + 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)); } } @@ -251,7 +272,7 @@ public class EntityShowMode implements ShowMode { } if (interpolateXZ) { - Vector updatePointXZ = Math.abs(position.getUpdateVelocity().getX()) >= Math.abs(position.getUpdateVelocity().getZ()) + 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)) { 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 index fce2d789..ac8d4e02 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/show/Record.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/show/Record.java @@ -31,7 +31,6 @@ import org.bukkit.util.Vector; import java.util.ArrayList; import java.util.List; -import java.util.UUID; @RequiredArgsConstructor public class Record { @@ -81,7 +80,7 @@ public class Record { public static class TNTRecord { @Getter - private final UUID id = UUID.randomUUID(); + private int entityId; private Record record; @@ -89,7 +88,7 @@ public class Record { private final Region region; @Getter - private final List positions = new ArrayList<>(82); + private final List positions = new ArrayList<>(); @Getter @Setter @@ -121,13 +120,16 @@ public class Record { } 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()); - position = new TNTPosition(this, tntPrimed, TPSUtils.currentTick.get() - record.startTicks, positions.get(positions.size() - 1).getLocation(), tntPrimed.getVelocity(), lastVelocity, source, exploded); + 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 index 1da942eb..72089326 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/show/ShowModeParameter.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/show/ShowModeParameter.java @@ -34,6 +34,8 @@ public class ShowModeParameter { 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; @@ -82,4 +84,12 @@ public class ShowModeParameter { 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 index 51e1e9a5..763df5d4 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/show/ShowModeParameterType.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/show/ShowModeParameterType.java @@ -38,12 +38,14 @@ public enum ShowModeParameterType { }, 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"), - COUNT(ShowModeParameter::enableCount, Arrays.asList("-count", "-c"), "FUSE"), + 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