SteamWar/BauSystem
Archiviert
13
0

Add ExplodeListener

Add RecordManager
Add RecordTrace
Add ShowTrace basics
Add TNTEntity basics
Dieser Commit ist enthalten in:
jojo 2020-12-17 19:43:30 +01:00
Ursprung 599c6049be
Commit 19ee52aee5
7 geänderte Dateien mit 64 neuen und 11 gelöschten Zeilen

Datei anzeigen

@ -32,6 +32,14 @@ public class Position {
vector = entity.getVelocity(); vector = entity.getVelocity();
} }
public Vector getLocation() {
return location;
}
public Vector getVector() {
return vector;
}
@Override @Override
public String toString() { public String toString() {
return "Position{" + return "Position{" +

Datei anzeigen

@ -19,16 +19,11 @@
package de.steamwar.bausystem.tracer.record; package de.steamwar.bausystem.tracer.record;
import org.bukkit.entity.TNTPrimed;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map;
public class DataHolder { public class DataHolder {
public static Map<TNTPrimed, RecordTrace> recordTraceMap = new HashMap<>();
public static List<RecordTrace> finished = new ArrayList<>(); public static List<RecordTrace> finished = new ArrayList<>();
} }

Datei anzeigen

@ -24,8 +24,13 @@ import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener; import org.bukkit.event.Listener;
import org.bukkit.event.entity.EntityExplodeEvent; import org.bukkit.event.entity.EntityExplodeEvent;
import java.util.HashMap;
import java.util.Map;
public class ExplodeListener implements Listener { public class ExplodeListener implements Listener {
private static Map<TNTPrimed, RecordTrace> recordTraceMap = new HashMap<>();
@EventHandler @EventHandler
public void onEntityExplode(EntityExplodeEvent event) { public void onEntityExplode(EntityExplodeEvent event) {
if (!(event.getEntity() instanceof TNTPrimed)) return; if (!(event.getEntity() instanceof TNTPrimed)) return;
@ -45,14 +50,20 @@ public class ExplodeListener implements Listener {
static void explode(TNTPrimed tntPrimed) { static void explode(TNTPrimed tntPrimed) {
get(tntPrimed).explode(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) { private static RecordTrace get(TNTPrimed tntPrimed) {
if (!DataHolder.recordTraceMap.containsKey(tntPrimed)) { if (!recordTraceMap.containsKey(tntPrimed)) {
DataHolder.recordTraceMap.put(tntPrimed, new RecordTrace(tntPrimed)); recordTraceMap.put(tntPrimed, new RecordTrace(tntPrimed));
} }
return DataHolder.recordTraceMap.get(tntPrimed); return recordTraceMap.get(tntPrimed);
}
public static int size() {
return recordTraceMap.size();
} }
} }

Datei anzeigen

@ -49,7 +49,7 @@ public class RecordManager {
} }
public static void commandAuto() { public static void commandAuto() {
if (recordStatus != RecordStatus.IDLE) { if (recordStatus != RecordStatus.IDLE && recordStatus != RecordStatus.IDLE_AUTO) {
return; return;
} }
if (recordStatus == RecordStatus.IDLE_AUTO) { if (recordStatus == RecordStatus.IDLE_AUTO) {

Datei anzeigen

@ -0,0 +1,11 @@
package de.steamwar.bausystem.tracer.show;
import de.steamwar.bausystem.tracer.record.RecordTrace;
public class ShowTrace {
public ShowTrace(RecordTrace recordTrace) {
}
}

Datei anzeigen

@ -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) {
}
}

Datei anzeigen

@ -22,8 +22,11 @@ package de.steamwar.bausystem.world;
import de.steamwar.bausystem.commands.CommandFreeze; import de.steamwar.bausystem.commands.CommandFreeze;
import de.steamwar.bausystem.commands.CommandTNT; import de.steamwar.bausystem.commands.CommandTNT;
import de.steamwar.bausystem.commands.CommandTPSLimiter; 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.record.RecordManager;
import de.steamwar.bausystem.tracer.TraceManager; import de.steamwar.bausystem.tracer.TraceManager;
import de.steamwar.bausystem.tracer.record.RecordTrace;
import de.steamwar.core.TPSWatcher; import de.steamwar.core.TPSWatcher;
import de.steamwar.scoreboard.SWScoreboard; import de.steamwar.scoreboard.SWScoreboard;
import de.steamwar.scoreboard.ScoreboardCallback; import de.steamwar.scoreboard.ScoreboardCallback;
@ -68,7 +71,7 @@ public class BauScoreboard implements Listener {
strings.add("§3"); strings.add("§3");
strings.add("§eTrace-Start§8: §7" + new SimpleDateFormat("HH:mm:ss").format(new Date(RecordManager.getStartTime()))); strings.add("§eTrace-Start§8: §7" + new SimpleDateFormat("HH:mm:ss").format(new Date(RecordManager.getStartTime())));
strings.add("§eTicks§8: §7" + traceTicks()); 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"); strings.add("§4");