From 19ee52aee52e095dc2e457c477844a61860c53ba Mon Sep 17 00:00:00 2001 From: jojo Date: Thu, 17 Dec 2020 19:43:30 +0100 Subject: [PATCH] Add ExplodeListener Add RecordManager Add RecordTrace Add ShowTrace basics Add TNTEntity basics --- .../steamwar/bausystem/tracer/Position.java | 8 ++++++ .../bausystem/tracer/record/DataHolder.java | 5 ---- .../tracer/record/ExplodeListener.java | 19 +++++++++++--- .../tracer/record/RecordManager.java | 2 +- .../bausystem/tracer/show/ShowTrace.java | 11 ++++++++ .../bausystem/tracer/show/TNTEntity.java | 25 +++++++++++++++++++ .../bausystem/world/BauScoreboard.java | 5 +++- 7 files changed, 64 insertions(+), 11 deletions(-) create mode 100644 BauSystem_Main/src/de/steamwar/bausystem/tracer/show/ShowTrace.java create mode 100644 BauSystem_Main/src/de/steamwar/bausystem/tracer/show/TNTEntity.java diff --git a/BauSystem_Main/src/de/steamwar/bausystem/tracer/Position.java b/BauSystem_Main/src/de/steamwar/bausystem/tracer/Position.java index 0e17c9f..c5c0fa9 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/tracer/Position.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/tracer/Position.java @@ -32,6 +32,14 @@ public class Position { vector = entity.getVelocity(); } + public Vector getLocation() { + return location; + } + + public Vector getVector() { + return vector; + } + @Override public String toString() { return "Position{" + diff --git a/BauSystem_Main/src/de/steamwar/bausystem/tracer/record/DataHolder.java b/BauSystem_Main/src/de/steamwar/bausystem/tracer/record/DataHolder.java index f43a466..0ce980e 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/tracer/record/DataHolder.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/tracer/record/DataHolder.java @@ -19,16 +19,11 @@ package de.steamwar.bausystem.tracer.record; -import org.bukkit.entity.TNTPrimed; - import java.util.ArrayList; -import java.util.HashMap; import java.util.List; -import java.util.Map; public class DataHolder { - public static Map recordTraceMap = new HashMap<>(); public static List finished = new ArrayList<>(); } diff --git a/BauSystem_Main/src/de/steamwar/bausystem/tracer/record/ExplodeListener.java b/BauSystem_Main/src/de/steamwar/bausystem/tracer/record/ExplodeListener.java index f8693c0..8f08e19 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/tracer/record/ExplodeListener.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/tracer/record/ExplodeListener.java @@ -24,8 +24,13 @@ import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; import org.bukkit.event.entity.EntityExplodeEvent; +import java.util.HashMap; +import java.util.Map; + public class ExplodeListener implements Listener { + private static Map recordTraceMap = new HashMap<>(); + @EventHandler public void onEntityExplode(EntityExplodeEvent event) { if (!(event.getEntity() instanceof TNTPrimed)) return; @@ -45,14 +50,20 @@ public class ExplodeListener implements Listener { static void explode(TNTPrimed tntPrimed) { get(tntPrimed).explode(tntPrimed); - DataHolder.finished.add(DataHolder.recordTraceMap.remove(tntPrimed)); + RecordTrace recordTrace = recordTraceMap.remove(tntPrimed); + // System.out.println(recordTrace); + DataHolder.finished.add(recordTrace); } private static RecordTrace get(TNTPrimed tntPrimed) { - if (!DataHolder.recordTraceMap.containsKey(tntPrimed)) { - DataHolder.recordTraceMap.put(tntPrimed, new RecordTrace(tntPrimed)); + if (!recordTraceMap.containsKey(tntPrimed)) { + recordTraceMap.put(tntPrimed, new RecordTrace(tntPrimed)); } - return DataHolder.recordTraceMap.get(tntPrimed); + return recordTraceMap.get(tntPrimed); + } + + public static int size() { + return recordTraceMap.size(); } } diff --git a/BauSystem_Main/src/de/steamwar/bausystem/tracer/record/RecordManager.java b/BauSystem_Main/src/de/steamwar/bausystem/tracer/record/RecordManager.java index ba7a848..fb90ee5 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/tracer/record/RecordManager.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/tracer/record/RecordManager.java @@ -49,7 +49,7 @@ public class RecordManager { } public static void commandAuto() { - if (recordStatus != RecordStatus.IDLE) { + if (recordStatus != RecordStatus.IDLE && recordStatus != RecordStatus.IDLE_AUTO) { return; } if (recordStatus == RecordStatus.IDLE_AUTO) { diff --git a/BauSystem_Main/src/de/steamwar/bausystem/tracer/show/ShowTrace.java b/BauSystem_Main/src/de/steamwar/bausystem/tracer/show/ShowTrace.java new file mode 100644 index 0000000..ea78894 --- /dev/null +++ b/BauSystem_Main/src/de/steamwar/bausystem/tracer/show/ShowTrace.java @@ -0,0 +1,11 @@ +package de.steamwar.bausystem.tracer.show; + +import de.steamwar.bausystem.tracer.record.RecordTrace; + +public class ShowTrace { + + public ShowTrace(RecordTrace recordTrace) { + + } + +} diff --git a/BauSystem_Main/src/de/steamwar/bausystem/tracer/show/TNTEntity.java b/BauSystem_Main/src/de/steamwar/bausystem/tracer/show/TNTEntity.java new file mode 100644 index 0000000..8a6cde4 --- /dev/null +++ b/BauSystem_Main/src/de/steamwar/bausystem/tracer/show/TNTEntity.java @@ -0,0 +1,25 @@ +package de.steamwar.bausystem.tracer.show; + +import de.steamwar.bausystem.tracer.Position; +import net.minecraft.server.v1_15_R1.*; + +public class TNTEntity extends EntityFallingBlock { + + private Position position; + + public TNTEntity(World world, Position position) { + super(world, position.getLocation().getX(), position.getLocation().getY(), position.getLocation().getZ(), Blocks.TNT.getBlockData()); + this.position = position; + + this.setNoGravity(true); + this.ticksLived = -12000; + this.dropItem = false; + this.setCustomNameVisible(true); + } + + @Override + public void move(EnumMoveType enummovetype, Vec3D vec3d) { + + } + +} diff --git a/BauSystem_Main/src/de/steamwar/bausystem/world/BauScoreboard.java b/BauSystem_Main/src/de/steamwar/bausystem/world/BauScoreboard.java index a924ffc..59fa73e 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/world/BauScoreboard.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/world/BauScoreboard.java @@ -22,8 +22,11 @@ package de.steamwar.bausystem.world; import de.steamwar.bausystem.commands.CommandFreeze; import de.steamwar.bausystem.commands.CommandTNT; import de.steamwar.bausystem.commands.CommandTPSLimiter; +import de.steamwar.bausystem.tracer.record.DataHolder; +import de.steamwar.bausystem.tracer.record.ExplodeListener; import de.steamwar.bausystem.tracer.record.RecordManager; import de.steamwar.bausystem.tracer.TraceManager; +import de.steamwar.bausystem.tracer.record.RecordTrace; import de.steamwar.core.TPSWatcher; import de.steamwar.scoreboard.SWScoreboard; import de.steamwar.scoreboard.ScoreboardCallback; @@ -68,7 +71,7 @@ public class BauScoreboard implements Listener { strings.add("§3"); strings.add("§eTrace-Start§8: §7" + new SimpleDateFormat("HH:mm:ss").format(new Date(RecordManager.getStartTime()))); strings.add("§eTicks§8: §7" + traceTicks()); - strings.add("§eAnzahl TNT§8: §7" + TraceManager.getRecordSize()); + strings.add("§eAnzahl TNT§8: §7" + ExplodeListener.size()); } strings.add("§4");