Simplify Tracer #91
@ -1,6 +1,5 @@
|
|||||||
package de.steamwar.bausystem.tracer.trace;
|
package de.steamwar.bausystem.tracer;
|
||||||
|
|
||||||
import de.steamwar.bausystem.tracer.TraceCache;
|
|
||||||
import de.steamwar.bausystem.tracer.manager.ShowManager;
|
import de.steamwar.bausystem.tracer.manager.ShowManager;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
|
|
||||||
@ -11,7 +10,6 @@ import java.util.Set;
|
|||||||
public class TNTTrace {
|
public class TNTTrace {
|
||||||
|
|
||||||
private final int frameID;
|
private final int frameID;
|
||||||
private int tntID;
|
|
||||||
|
|
||||||
private int index = 0;
|
private int index = 0;
|
||||||
private float[] positions = new float[240];
|
private float[] positions = new float[240];
|
||||||
@ -20,11 +18,11 @@ public class TNTTrace {
|
|||||||
private Set<TraceCache.Loc> posYSet = new HashSet<>();
|
private Set<TraceCache.Loc> posYSet = new HashSet<>();
|
||||||
private Set<TraceCache.Loc> posXYZSet = new HashSet<>();
|
private Set<TraceCache.Loc> posXYZSet = new HashSet<>();
|
||||||
|
|
||||||
public TNTTrace(int frameID) {
|
TNTTrace(int frameID) {
|
||||||
this.frameID = frameID;
|
this.frameID = frameID;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addLocation(Location location) {
|
void addLocation(Location location) {
|
||||||
if (index >= positions.length) {
|
if (index >= positions.length) {
|
||||||
positions = Arrays.copyOf(positions, positions.length + 3);
|
positions = Arrays.copyOf(positions, positions.length + 3);
|
||||||
}
|
}
|
||||||
@ -42,23 +40,15 @@ public class TNTTrace {
|
|||||||
return size();
|
return size();
|
||||||
}
|
}
|
||||||
|
|
||||||
public int realLength() {
|
private int realLength() {
|
||||||
return positions.length;
|
return positions.length;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setTntID(int tntID) {
|
|
||||||
this.tntID = tntID;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getTntID() {
|
|
||||||
return tntID;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getFrameID() {
|
public int getFrameID() {
|
||||||
return frameID;
|
return frameID;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void cleanUp() {
|
void cleanUp() {
|
||||||
positions = Arrays.copyOf(positions, index);
|
positions = Arrays.copyOf(positions, index);
|
||||||
ShowManager.traceAdd();
|
ShowManager.traceAdd();
|
||||||
|
|
||||||
@ -88,11 +78,11 @@ public class TNTTrace {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public Set<TraceCache.Loc> locs() {
|
Set<TraceCache.Loc> locs() {
|
||||||
return posSet;
|
return posSet;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Set<TraceCache.Loc> locsUpdate(ShowManager.DisplayMode displayMode) {
|
Set<TraceCache.Loc> locsUpdate(ShowManager.DisplayMode displayMode) {
|
||||||
if (displayMode == ShowManager.DisplayMode.NONE) return new HashSet<>();
|
if (displayMode == ShowManager.DisplayMode.NONE) return new HashSet<>();
|
||||||
if (displayMode == ShowManager.DisplayMode.Y_AXIS) return posYSet;
|
if (displayMode == ShowManager.DisplayMode.Y_AXIS) return posYSet;
|
||||||
return posXYZSet;
|
return posXYZSet;
|
@ -6,17 +6,18 @@ import de.steamwar.core.Core;
|
|||||||
import net.md_5.bungee.api.ChatMessageType;
|
import net.md_5.bungee.api.ChatMessageType;
|
||||||
import net.md_5.bungee.api.chat.TextComponent;
|
import net.md_5.bungee.api.chat.TextComponent;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.Location;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.Particle;
|
import org.bukkit.Particle;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import static de.steamwar.bausystem.tracer.TraceUtils.DEBUG;
|
|
||||||
|
|
||||||
public class TNTTracer {
|
public class TNTTracer {
|
||||||
private TNTTracer(){}
|
private TNTTracer(){}
|
||||||
|
|
||||||
|
static final boolean DEBUG = false;
|
||||||
|
|
||||||
private static final Object synchronizer = new Object();
|
private static final Object synchronizer = new Object();
|
||||||
private static final TraceCache traceCache = new TraceCache();
|
private static final TraceCache traceCache = new TraceCache();
|
||||||
|
|
||||||
@ -63,7 +64,7 @@ public class TNTTracer {
|
|||||||
if (locs.isEmpty()) return;
|
if (locs.isEmpty()) return;
|
||||||
|
|
||||||
for (TraceCache.Loc l : locs) {
|
for (TraceCache.Loc l : locs) {
|
||||||
TraceUtils.hideBlock(player, l.x, l.y - 0.49F, l.z);
|
hideBlock(player, l.x, l.y - 0.49F, l.z);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -72,9 +73,9 @@ public class TNTTracer {
|
|||||||
|
|
||||||
for (TraceCache.Loc l : locs) {
|
for (TraceCache.Loc l : locs) {
|
||||||
if (displayMode == ShowManager.DisplayType.Block) {
|
if (displayMode == ShowManager.DisplayType.Block) {
|
||||||
TraceUtils.showBlock(player, l.x, l.y - 0.49F, l.z, getMaterial(l), (l.updatePoint ? (byte) 5 : (byte) 14));
|
showBlock(player, l.x, l.y - 0.49F, l.z, getMaterial(l), (l.updatePoint ? (byte) 5 : (byte) 14));
|
||||||
} else {
|
} else {
|
||||||
TraceUtils.showCorner(player, l.x - 0.49F, l.y, l.z - 0.49F, (l.updatePoint ? Particle.FLAME : Particle.VILLAGER_HAPPY));
|
showCorner(player, l.x - 0.49F, l.y, l.z - 0.49F, (l.updatePoint ? Particle.FLAME : Particle.VILLAGER_HAPPY));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -87,4 +88,36 @@ public class TNTTracer {
|
|||||||
return TNTTracer_12.getMaterial();
|
return TNTTracer_12.getMaterial();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static void showCorner(Player player, float x, float y, float z, Particle particle) {
|
||||||
|
player.spawnParticle(particle, makeLocation(x + 0.00F, y + 0.00F, z + 0.00F), 1, 0F, 0F, 0F, 0.001);
|
||||||
|
player.spawnParticle(particle, makeLocation(x + 0.98F, y + 0.00F, z + 0.00F), 1, 0F, 0F, 0F, 0.001);
|
||||||
|
player.spawnParticle(particle, makeLocation(x + 0.00F, y + 0.00F, z + 0.98F), 1, 0F, 0F, 0F, 0.001);
|
||||||
|
player.spawnParticle(particle, makeLocation(x + 0.98F, y + 0.00F, z + 0.98F), 1, 0F, 0F, 0F, 0.001);
|
||||||
|
|
||||||
|
player.spawnParticle(particle, makeLocation(x + 0.00F, y + 0.98F, z + 0.00F), 1, 0F, 0F, 0F, 0.001);
|
||||||
|
player.spawnParticle(particle, makeLocation(x + 0.98F, y + 0.98F, z + 0.00F), 1, 0F, 0F, 0F, 0.001);
|
||||||
|
player.spawnParticle(particle, makeLocation(x + 0.00F, y + 0.98F, z + 0.98F), 1, 0F, 0F, 0F, 0.001);
|
||||||
|
player.spawnParticle(particle, makeLocation(x + 0.98F, y + 0.98F, z + 0.98F), 1, 0F, 0F, 0F, 0.001);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void showBlock(Player p, float x, float y, float z, Material block, byte b) {
|
||||||
|
if (makeLocation(x, y, z).getBlock().getType() == Material.AIR) {
|
||||||
|
p.sendBlockChange(makeLocation(x, y, z), block, b);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void hideBlock(Player p, float x, float y, float z) {
|
||||||
|
if (makeLocation(x, y, z).getBlock().getType() == Material.AIR) {
|
||||||
|
p.sendBlockChange(makeLocation(x, y, z), Material.AIR, (byte) 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static final Location location = new Location(Bukkit.getWorlds().get(0), 0, 0, 0);
|
||||||
|
private static Location makeLocation(float x, float y, float z) {
|
||||||
|
location.setX(x);
|
||||||
|
location.setY(y);
|
||||||
|
location.setZ(z);
|
||||||
|
return location;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
package de.steamwar.bausystem.tracer;
|
package de.steamwar.bausystem.tracer;
|
||||||
|
|
||||||
public class TNTTracerGUI_15 {
|
public class TNTTracerGUI {
|
||||||
|
|
||||||
/*private static GuiCallbackTNTFrame guiCallbackTNTFrame;
|
/*private static GuiCallbackTNTFrame guiCallbackTNTFrame;
|
||||||
private static GuiCallbackTNTTrace guiCallbackTNTTrace;
|
private static GuiCallbackTNTTrace guiCallbackTNTTrace;
|
@ -3,7 +3,6 @@ package de.steamwar.bausystem.tracer;
|
|||||||
import de.steamwar.bausystem.tracer.manager.ShowManager;
|
import de.steamwar.bausystem.tracer.manager.ShowManager;
|
||||||
import de.steamwar.bausystem.tracer.manager.TraceManager;
|
import de.steamwar.bausystem.tracer.manager.TraceManager;
|
||||||
import de.steamwar.bausystem.tracer.recorder.RecordManager;
|
import de.steamwar.bausystem.tracer.recorder.RecordManager;
|
||||||
import de.steamwar.bausystem.tracer.trace.TNTTrace;
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.entity.TNTPrimed;
|
import org.bukkit.entity.TNTPrimed;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
|
@ -1,22 +0,0 @@
|
|||||||
package de.steamwar.bausystem.tracer;
|
|
||||||
|
|
||||||
import de.steamwar.bausystem.tracer.manager.FrameManager;
|
|
||||||
import de.steamwar.bausystem.tracer.recorder.RecordManager;
|
|
||||||
import de.steamwar.bausystem.tracer.recorder.TNTRecorder;
|
|
||||||
|
|
||||||
public class TraceSidebar {
|
|
||||||
|
|
||||||
public static long traceStart() {
|
|
||||||
return TNTRecorder.recordStart;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static long traceTicks() {
|
|
||||||
return (System.currentTimeMillis() - TNTRecorder.recordStart) / 50;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static int traceSize() {
|
|
||||||
if (RecordManager.activeFrameID == null) return 0;
|
|
||||||
return FrameManager.get(RecordManager.activeFrameID).size();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,47 +0,0 @@
|
|||||||
package de.steamwar.bausystem.tracer;
|
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.Location;
|
|
||||||
import org.bukkit.Material;
|
|
||||||
import org.bukkit.Particle;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
|
|
||||||
public class TraceUtils {
|
|
||||||
private TraceUtils(){}
|
|
||||||
|
|
||||||
public static final boolean DEBUG = false;
|
|
||||||
|
|
||||||
private static Location location = new Location(Bukkit.getWorlds().get(0), 0, 0, 0);
|
|
||||||
|
|
||||||
public static void showCorner(Player player, float x, float y, float z, Particle particle) {
|
|
||||||
player.spawnParticle(particle, makeLocation(x + 0.00F, y + 0.00F, z + 0.00F), 1, 0F, 0F, 0F, 0.001);
|
|
||||||
player.spawnParticle(particle, makeLocation(x + 0.98F, y + 0.00F, z + 0.00F), 1, 0F, 0F, 0F, 0.001);
|
|
||||||
player.spawnParticle(particle, makeLocation(x + 0.00F, y + 0.00F, z + 0.98F), 1, 0F, 0F, 0F, 0.001);
|
|
||||||
player.spawnParticle(particle, makeLocation(x + 0.98F, y + 0.00F, z + 0.98F), 1, 0F, 0F, 0F, 0.001);
|
|
||||||
|
|
||||||
player.spawnParticle(particle, makeLocation(x + 0.00F, y + 0.98F, z + 0.00F), 1, 0F, 0F, 0F, 0.001);
|
|
||||||
player.spawnParticle(particle, makeLocation(x + 0.98F, y + 0.98F, z + 0.00F), 1, 0F, 0F, 0F, 0.001);
|
|
||||||
player.spawnParticle(particle, makeLocation(x + 0.00F, y + 0.98F, z + 0.98F), 1, 0F, 0F, 0F, 0.001);
|
|
||||||
player.spawnParticle(particle, makeLocation(x + 0.98F, y + 0.98F, z + 0.98F), 1, 0F, 0F, 0F, 0.001);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void showBlock(Player p, float x, float y, float z, Material block, byte b) {
|
|
||||||
if (makeLocation(x, y, z).getBlock().getType() == Material.AIR) {
|
|
||||||
p.sendBlockChange(makeLocation(x, y, z), block, b);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void hideBlock(Player p, float x, float y, float z) {
|
|
||||||
if (makeLocation(x, y, z).getBlock().getType() == Material.AIR) {
|
|
||||||
p.sendBlockChange(makeLocation(x, y, z), Material.AIR, (byte) 0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static Location makeLocation(float x, float y, float z) {
|
|
||||||
location.setX(x);
|
|
||||||
location.setY(y);
|
|
||||||
location.setZ(z);
|
|
||||||
return location;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -2,7 +2,6 @@ package de.steamwar.bausystem.tracer;
|
|||||||
|
|
||||||
import de.steamwar.bausystem.tracer.manager.ShowManager;
|
import de.steamwar.bausystem.tracer.manager.ShowManager;
|
||||||
import de.steamwar.bausystem.tracer.manager.TraceManager;
|
import de.steamwar.bausystem.tracer.manager.TraceManager;
|
||||||
import de.steamwar.bausystem.tracer.trace.TNTTrace;
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
|
@ -2,7 +2,7 @@ package de.steamwar.bausystem.tracer.manager;
|
|||||||
|
|
||||||
import de.steamwar.bausystem.BauSystem;
|
import de.steamwar.bausystem.BauSystem;
|
||||||
import de.steamwar.bausystem.tracer.TraceCache;
|
import de.steamwar.bausystem.tracer.TraceCache;
|
||||||
import de.steamwar.bausystem.tracer.trace.TNTTrace;
|
import de.steamwar.bausystem.tracer.TNTTrace;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
@ -1,18 +1,18 @@
|
|||||||
package de.steamwar.bausystem.tracer.manager;
|
package de.steamwar.bausystem.tracer.manager;
|
||||||
|
|
||||||
import de.steamwar.bausystem.BauSystem;
|
import de.steamwar.bausystem.BauSystem;
|
||||||
import de.steamwar.bausystem.tracer.trace.TNTTrace;
|
import de.steamwar.bausystem.tracer.TNTTrace;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
public class TraceManager {
|
public class TraceManager {
|
||||||
|
private TraceManager(){}
|
||||||
|
|
||||||
private static Map<Integer, TNTTrace> traceMap = new HashMap<>();
|
private static Map<Integer, TNTTrace> traceMap = new HashMap<>();
|
||||||
|
|
||||||
public static void add(TNTTrace tntTrace) {
|
public static void add(TNTTrace tntTrace) {
|
||||||
int id = IDManager.generateID();
|
int id = IDManager.generateID();
|
||||||
tntTrace.setTntID(id);
|
|
||||||
FrameManager.add(tntTrace.getFrameID(), id);
|
FrameManager.add(tntTrace.getFrameID(), id);
|
||||||
traceMap.put(id, tntTrace);
|
traceMap.put(id, tntTrace);
|
||||||
}
|
}
|
||||||
|
@ -39,7 +39,7 @@ public class RecordManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void toggleAuto() {
|
private static void toggleAuto() {
|
||||||
switch (status) {
|
switch (status) {
|
||||||
case IDLE:
|
case IDLE:
|
||||||
status = Status.IDLE_AUTO;
|
status = Status.IDLE_AUTO;
|
||||||
@ -62,7 +62,7 @@ public class RecordManager {
|
|||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void start() {
|
private static void start() {
|
||||||
if (activeFrameID != null) return;
|
if (activeFrameID != null) return;
|
||||||
status = Status.RECORD;
|
status = Status.RECORD;
|
||||||
generateFrameID();
|
generateFrameID();
|
||||||
@ -85,7 +85,7 @@ public class RecordManager {
|
|||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void stop() {
|
private static void stop() {
|
||||||
if (activeFrameID == null) return;
|
if (activeFrameID == null) return;
|
||||||
status = Status.IDLE;
|
status = Status.IDLE;
|
||||||
stopRecording();
|
stopRecording();
|
||||||
|
@ -3,8 +3,9 @@ package de.steamwar.bausystem.world;
|
|||||||
import de.steamwar.bausystem.commands.CommandFreeze;
|
import de.steamwar.bausystem.commands.CommandFreeze;
|
||||||
import de.steamwar.bausystem.commands.CommandInfo;
|
import de.steamwar.bausystem.commands.CommandInfo;
|
||||||
import de.steamwar.bausystem.commands.CommandTNT;
|
import de.steamwar.bausystem.commands.CommandTNT;
|
||||||
import de.steamwar.bausystem.tracer.TraceSidebar;
|
import de.steamwar.bausystem.tracer.manager.FrameManager;
|
||||||
import de.steamwar.bausystem.tracer.recorder.RecordManager;
|
import de.steamwar.bausystem.tracer.recorder.RecordManager;
|
||||||
|
import de.steamwar.bausystem.tracer.recorder.TNTRecorder;
|
||||||
import de.steamwar.scoreboard.SWScoreboard;
|
import de.steamwar.scoreboard.SWScoreboard;
|
||||||
import de.steamwar.scoreboard.ScoreboardCallback;
|
import de.steamwar.scoreboard.ScoreboardCallback;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
@ -55,11 +56,9 @@ public class BauScoreboard implements Listener {
|
|||||||
|
|
||||||
if (RecordManager.getStatus().isTracing()) {
|
if (RecordManager.getStatus().isTracing()) {
|
||||||
strings.add("§3");
|
strings.add("§3");
|
||||||
strings.add("§eTrace-Start§8: §7" + new SimpleDateFormat("HH:mm:ss").format(new Date(TraceSidebar.traceStart())));
|
strings.add("§eTrace-Start§8: §7" + new SimpleDateFormat("HH:mm:ss").format(new Date(TNTRecorder.recordStart)));
|
||||||
strings.add("§eTicks§8: §7" + TraceSidebar.traceTicks());
|
strings.add("§eTicks§8: §7" + traceTicks());
|
||||||
strings.add("§eAnzahl TNT§8: §7" + TraceSidebar.traceSize());
|
strings.add("§eAnzahl TNT§8: §7" + traceSize());
|
||||||
} else if (AutoLoader.hasLoader(p)) {
|
|
||||||
// strings.add("§3");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
strings.add("§4");
|
strings.add("§4");
|
||||||
@ -67,4 +66,14 @@ public class BauScoreboard implements Listener {
|
|||||||
return strings;
|
return strings;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private long traceTicks() {
|
||||||
|
return (System.currentTimeMillis() - TNTRecorder.recordStart) / 50;
|
||||||
|
}
|
||||||
|
|
||||||
|
private int traceSize() {
|
||||||
|
if (RecordManager.activeFrameID == null)
|
||||||
|
return 0;
|
||||||
|
return FrameManager.get(RecordManager.activeFrameID).size();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
In neuem Issue referenzieren
Einen Benutzer sperren