Simplify Tracer #91
@ -3,7 +3,7 @@ package de.steamwar.bausystem;
|
||||
import de.steamwar.bausystem.commands.*;
|
||||
import de.steamwar.bausystem.tracer.TraceListener;
|
||||
import de.steamwar.bausystem.tracer.TNTTracer;
|
||||
import de.steamwar.bausystem.tracer.manager.ShowManager;
|
||||
import de.steamwar.bausystem.tracer.ShowManager;
|
||||
import de.steamwar.bausystem.world.AFKStopper;
|
||||
import de.steamwar.bausystem.world.ArenaSection;
|
||||
import de.steamwar.bausystem.world.BauScoreboard;
|
||||
|
@ -2,8 +2,8 @@ package de.steamwar.bausystem.commands;
|
||||
|
||||
import de.steamwar.bausystem.BauSystem;
|
||||
import de.steamwar.bausystem.Permission;
|
||||
import de.steamwar.bausystem.tracer.manager.ShowManager;
|
||||
import de.steamwar.bausystem.tracer.manager.TraceManager;
|
||||
import de.steamwar.bausystem.tracer.ShowManager;
|
||||
import de.steamwar.bausystem.tracer.TraceManager;
|
||||
import de.steamwar.bausystem.tracer.recorder.RecordManager;
|
||||
import de.steamwar.bausystem.world.Welt;
|
||||
import org.bukkit.command.Command;
|
||||
@ -27,12 +27,6 @@ public class CommandTrace implements CommandExecutor {
|
||||
player.sendMessage("§7Optionale Parameter mit §8<>§7, Benötigte Parameter mit §8[]");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
if(!(sender instanceof Player)) return false;
|
||||
return tracer((Player) sender, args);
|
||||
}
|
||||
|
||||
private boolean permissionCheck(Player player) {
|
||||
if(Welt.noPermission(player, Permission.world)){
|
||||
player.sendMessage(BauSystem.PREFIX + "§cDu darfst hier nicht den TNT-Tracer nutzen");
|
||||
@ -41,7 +35,11 @@ public class CommandTrace implements CommandExecutor {
|
||||
return true;
|
||||
}
|
||||
|
||||
private boolean tracer(Player player, String[] args) {
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
if(!(sender instanceof Player)) return false;
|
||||
Player player = (Player) sender;
|
||||
|
||||
if(args.length == 0){
|
||||
help(player);
|
||||
return false;
|
||||
@ -61,7 +59,7 @@ public class CommandTrace implements CommandExecutor {
|
||||
case "toggleshow":
|
||||
case "interpolate":
|
||||
case "distance":
|
||||
if (ShowManager.tracer(player, args)) {
|
||||
if (tracer(player, args)) {
|
||||
help(player);
|
||||
}
|
||||
break;
|
||||
@ -70,7 +68,7 @@ public class CommandTrace implements CommandExecutor {
|
||||
// player.sendMessage(BauSystem.PREFIX + "§cNoch in Bau");
|
||||
break;
|
||||
case "delete":
|
||||
if (TraceManager.delete(player, args)) {
|
||||
if (delete(player, args)) {
|
||||
help(player);
|
||||
}
|
||||
break;
|
||||
@ -80,4 +78,147 @@ public class CommandTrace implements CommandExecutor {
|
||||
return false;
|
||||
}
|
||||
|
||||
private boolean delete(Player player, String[] args) {
|
||||
if (args.length == 2) {
|
||||
try {
|
||||
TraceManager.delete(Integer.parseInt(args[1]));
|
||||
player.sendMessage(BauSystem.PREFIX + "§cTNT-Positionen mit ID " + args[1] + " gelöscht");
|
||||
ShowManager.globalDirty();
|
||||
return false;
|
||||
} catch (NumberFormatException e) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
TraceManager.deleteAll();
|
||||
player.sendMessage(BauSystem.PREFIX + "§cAlle TNT-Positionen gelöscht");
|
||||
ShowManager.globalDirty();
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
public boolean tracer(Player player, String[] args) {
|
||||
ShowManager.ShowStatus showStatus = ShowManager.showMap.get(player.getUniqueId().toString());
|
||||
showStatus.dirty = true;
|
||||
switch (args[0].toLowerCase()) {
|
||||
case "show":
|
||||
showStatus.show();
|
||||
if (args.length == 2) {
|
||||
return tracerShow(player, showStatus, args);
|
||||
}
|
||||
player.sendMessage(BauSystem.PREFIX + "§aAlle TNT-Positionen angezeigt");
|
||||
break;
|
||||
case "distance":
|
||||
if (args.length != 2) {
|
||||
return true;
|
||||
}
|
||||
if (args[1].equalsIgnoreCase("default")) {
|
||||
ShowManager.get(player).setSlope(7.0);
|
||||
player.sendMessage(BauSystem.PREFIX + "§aAnzeige Distanz auf " + ShowManager.get(player).slopeHeight + " gesetzt");
|
||||
return false;
|
||||
}
|
||||
try {
|
||||
double radius = Double.parseDouble(args[1]);
|
||||
radius = (double)(int)(radius * 10) / 10;
|
||||
ShowManager.get(player).setSlope(radius);
|
||||
player.sendMessage(BauSystem.PREFIX + "§aAnzeige Distanz auf " + ShowManager.get(player).slopeHeight + " gesetzt");
|
||||
return false;
|
||||
} catch (NumberFormatException e) {
|
||||
return true;
|
||||
}
|
||||
case "hide":
|
||||
showStatus.hide();
|
||||
if (args.length == 2) {
|
||||
return traceID(player, args[1], showStatus::removeSelection, new String[]{BauSystem.PREFIX + "§aTNT-Positionen des TNT mit ID {} versteckt"});
|
||||
}
|
||||
player.sendMessage(BauSystem.PREFIX + "§aAlle TNT-Positionen versteckt");
|
||||
break;
|
||||
case "toggleshow":
|
||||
if (args.length == 2) {
|
||||
return traceID(player, args[1], showStatus::toggleSelection, new String[]{BauSystem.PREFIX + "§aTNT-Positionen des TNT mit ID {} angezeigt"}, new String[]{BauSystem.PREFIX + "§aTNT-Positionen des TNT mit ID {} versteckt"});
|
||||
}
|
||||
return true;
|
||||
case "interpolate":
|
||||
if (args.length == 2) {
|
||||
return tracerInterpolate(player, showStatus, args);
|
||||
}
|
||||
return true;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private boolean tracerShow(Player player, ShowManager.ShowStatus showStatus, String[] args) {
|
||||
switch (args[1].toLowerCase()) {
|
||||
case "block":
|
||||
case "blocks":
|
||||
showStatus.displayType = ShowManager.DisplayType.Block;
|
||||
player.sendMessage(BauSystem.PREFIX + "§aAlle TNT-Positionen, als Blöcke, angezeigt");
|
||||
break;
|
||||
case "particle":
|
||||
case "particles":
|
||||
case "default":
|
||||
showStatus.displayType = ShowManager.DisplayType.Particle;
|
||||
player.sendMessage(BauSystem.PREFIX + "§aAlle TNT-Positionen, als Partikel, angezeigt");
|
||||
break;
|
||||
default:
|
||||
return traceID(player, args[1], showStatus::addSelection, new String[]{BauSystem.PREFIX + "§aTNT-Positionen des TNT mit ID {} angezeigt"});
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private boolean tracerInterpolate(Player player, ShowManager.ShowStatus showStatus, String[] args) {
|
||||
switch (args[1].toLowerCase()) {
|
||||
case "none":
|
||||
showStatus.displayMode = ShowManager.DisplayMode.NONE;
|
||||
player.sendMessage(BauSystem.PREFIX + "§aInterpolation auf §enone §agesetzt");
|
||||
break;
|
||||
case "yaxis":
|
||||
case "y":
|
||||
showStatus.displayMode = ShowManager.DisplayMode.Y_AXIS;
|
||||
player.sendMessage(BauSystem.PREFIX + "§aInterpolation auf §eyaxis §agesetzt");
|
||||
break;
|
||||
case "all":
|
||||
case "allaxis":
|
||||
case "xyz":
|
||||
case "default":
|
||||
showStatus.displayMode = ShowManager.DisplayMode.ALL;
|
||||
player.sendMessage(BauSystem.PREFIX + "§aInterpolation auf §eall §agesetzt");
|
||||
break;
|
||||
default:
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
private boolean traceID(Player player, String number, ShowManager.Mode mode, String[] messages) {
|
||||
try {
|
||||
mode.run(Integer.parseInt(number));
|
||||
for (String s : messages) {
|
||||
player.sendMessage(s.replace("{}", number));
|
||||
}
|
||||
} catch (NumberFormatException e) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private boolean traceID(Player player, String number, ShowManager.ModeChoose mode, String[] messagesTrue, String[] messagesFalse) {
|
||||
try {
|
||||
boolean result = mode.run(Integer.parseInt(number));
|
||||
if (result) {
|
||||
for (String s : messagesTrue) {
|
||||
player.sendMessage(s.replace("{}", number));
|
||||
}
|
||||
} else {
|
||||
for (String s : messagesFalse) {
|
||||
player.sendMessage(s.replace("{}", number));
|
||||
}
|
||||
}
|
||||
} catch (NumberFormatException e) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
206
BauSystem_Main/src/de/steamwar/bausystem/tracer/ShowManager.java
Normale Datei
206
BauSystem_Main/src/de/steamwar/bausystem/tracer/ShowManager.java
Normale Datei
@ -0,0 +1,206 @@
|
||||
package de.steamwar.bausystem.tracer;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
public class ShowManager {
|
||||
|
||||
public enum DisplayMode {
|
||||
NONE,
|
||||
Y_AXIS,
|
||||
ALL
|
||||
}
|
||||
|
||||
public enum DisplayType {
|
||||
Particle,
|
||||
Block
|
||||
}
|
||||
|
||||
public enum ShowSelection {
|
||||
NONE,
|
||||
SELECTIVE,
|
||||
ALL
|
||||
}
|
||||
|
||||
|
||||
public interface Mode {
|
||||
void run(int tntID);
|
||||
}
|
||||
|
||||
public interface ModeChoose {
|
||||
boolean run(int tntID);
|
||||
}
|
||||
|
||||
|
||||
public static class ShowStatus {
|
||||
|
||||
private ShowSelection showSelection = ShowSelection.NONE;
|
||||
public DisplayType displayType = DisplayType.Particle;
|
||||
public DisplayMode displayMode = DisplayMode.ALL;
|
||||
|
||||
public boolean dirty = true;
|
||||
private int count = 0;
|
||||
|
||||
private Set<Integer> selected = new HashSet<>();
|
||||
|
||||
private void clear() {
|
||||
if (showSelection == ShowSelection.NONE) return;
|
||||
selected.clear();
|
||||
}
|
||||
|
||||
public void show() {
|
||||
showSelection = ShowSelection.ALL;
|
||||
}
|
||||
|
||||
public void hide() {
|
||||
clear();
|
||||
showSelection = ShowSelection.NONE;
|
||||
}
|
||||
|
||||
public void addSelection(int id) {
|
||||
if (showSelection == ShowSelection.ALL) return;
|
||||
if (showSelection == ShowSelection.NONE) showSelection = ShowSelection.SELECTIVE;
|
||||
selected.addAll(TraceManager.getFrame(id));
|
||||
if (selected.size() == TraceManager.getAllTraces().size()) {
|
||||
showSelection = ShowSelection.ALL;
|
||||
clear();
|
||||
}
|
||||
}
|
||||
|
||||
public void removeSelection(int id) {
|
||||
if (showSelection == ShowSelection.NONE) return;
|
||||
if (showSelection == ShowSelection.ALL) selected = TraceManager.getAllTraces();
|
||||
selected.removeAll(TraceManager.getFrame(id));
|
||||
showSelection = ShowSelection.SELECTIVE;
|
||||
if (selected.isEmpty()) showSelection = ShowSelection.NONE;
|
||||
}
|
||||
|
||||
public boolean toggleSelection(int id) {
|
||||
if (showSelection == ShowSelection.NONE) {
|
||||
addSelection(id);
|
||||
return true;
|
||||
}
|
||||
if (showSelection == ShowSelection.ALL) {
|
||||
removeSelection(id);
|
||||
return false;
|
||||
}
|
||||
if (selected.contains(id)) {
|
||||
removeSelection(id);
|
||||
return false;
|
||||
} else {
|
||||
addSelection(id);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public DisplayType getDisplayType() {
|
||||
return displayType;
|
||||
}
|
||||
|
||||
public DisplayMode getDisplayMode() {
|
||||
return displayMode;
|
||||
}
|
||||
|
||||
public LinkedList<TNTTrace> getTraces() {
|
||||
if (showSelection == ShowSelection.NONE) return new LinkedList<>();
|
||||
Set<Integer> tntIDs;
|
||||
if (showSelection == ShowSelection.ALL) {
|
||||
tntIDs = TraceManager.getAllTraces();
|
||||
} else {
|
||||
tntIDs = selected;
|
||||
}
|
||||
|
||||
LinkedList<TNTTrace> traces = new LinkedList<>();
|
||||
for (int traceId : tntIDs) {
|
||||
TNTTrace trace = TraceManager.getTrace(traceId);
|
||||
if (trace == null) continue;
|
||||
traces.add(trace);
|
||||
}
|
||||
return traces;
|
||||
}
|
||||
|
||||
public boolean isDirty() {
|
||||
if (displayType == DisplayType.Block) {
|
||||
count++;
|
||||
}
|
||||
if (count >= 10) {
|
||||
count = 0;
|
||||
return true;
|
||||
}
|
||||
if (dirty) {
|
||||
dirty = false;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public double slopeHeight = 7.0;
|
||||
|
||||
private int size = 0;
|
||||
|
||||
private TraceCache.Loc loc = null;
|
||||
|
||||
public double getShowRadius() {
|
||||
double maxRadius = 80.0;
|
||||
if (showSelection == ShowSelection.NONE) return maxRadius;
|
||||
if (showSelection == ShowSelection.ALL) size = TraceManager.getAllTraces().size();
|
||||
if (showSelection == ShowSelection.SELECTIVE) size = selected.size();
|
||||
if (size == 0) return maxRadius;
|
||||
double minRadius = 20.0;
|
||||
if (size >= 950) return minRadius;
|
||||
|
||||
double slope = -(size / slopeHeight) + 85;
|
||||
return Math.min(Math.max(slope, minRadius), maxRadius);
|
||||
}
|
||||
|
||||
public void setSlope(double slope) {
|
||||
double minSlope = 3.0;
|
||||
double maxSlope = 11.0;
|
||||
slopeHeight = Math.min(Math.max(slope, minSlope), maxSlope);
|
||||
}
|
||||
|
||||
public void move(Player player) {
|
||||
if (loc != null && !loc.remove(player, 4)) {
|
||||
return;
|
||||
}
|
||||
Location location = player.getLocation();
|
||||
loc = new TraceCache.Loc((float) location.getX(), (float) location.getY(), (float) location.getZ());
|
||||
dirty = true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static Map<String, ShowStatus> showMap = new HashMap<>();
|
||||
|
||||
public static void add(Player p) {
|
||||
showMap.put(p.getUniqueId().toString(), new ShowStatus());
|
||||
}
|
||||
|
||||
public static ShowStatus get(Player p) {
|
||||
if (!showMap.containsKey(p.getUniqueId().toString())) add(p);
|
||||
return showMap.get(p.getUniqueId().toString());
|
||||
}
|
||||
|
||||
public static void traceAdd() {
|
||||
for (Map.Entry<String, ShowStatus> entry : showMap.entrySet()) {
|
||||
if (entry.getValue().showSelection == ShowSelection.ALL) {
|
||||
entry.getValue().dirty = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void traceRemove(int id) {
|
||||
for (Map.Entry<String, ShowStatus> entry : showMap.entrySet()) {
|
||||
entry.getValue().removeSelection(id);
|
||||
}
|
||||
}
|
||||
|
||||
public static void globalDirty() {
|
||||
for (Map.Entry<String, ShowStatus> entry : showMap.entrySet()) {
|
||||
entry.getValue().dirty = true;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -1,6 +1,5 @@
|
||||
package de.steamwar.bausystem.tracer;
|
||||
|
||||
import de.steamwar.bausystem.tracer.manager.ShowManager;
|
||||
import org.bukkit.Location;
|
||||
|
||||
import java.util.Arrays;
|
||||
@ -44,7 +43,7 @@ public class TNTTrace {
|
||||
return positions.length;
|
||||
}
|
||||
|
||||
public int getFrameID() {
|
||||
int getFrameID() {
|
||||
return frameID;
|
||||
}
|
||||
|
||||
|
@ -1,7 +1,6 @@
|
||||
package de.steamwar.bausystem.tracer;
|
||||
|
||||
import de.steamwar.bausystem.BauSystem;
|
||||
import de.steamwar.bausystem.tracer.manager.ShowManager;
|
||||
import de.steamwar.core.Core;
|
||||
import net.md_5.bungee.api.ChatMessageType;
|
||||
import net.md_5.bungee.api.chat.TextComponent;
|
||||
@ -44,19 +43,19 @@ public class TNTTracer {
|
||||
private static void run(){
|
||||
for (Player p : Bukkit.getOnlinePlayers()) {
|
||||
if (DEBUG) {
|
||||
String actionBar = TracerUpdater.actionBar(p);
|
||||
String actionBar = "§e" + TraceManager.getAllTraces().size() + " §cTraces §e" + ShowManager.get(p).getShowRadius() + " §cRadius";
|
||||
p.spigot().sendMessage(ChatMessageType.ACTION_BAR, TextComponent.fromLegacyText(actionBar));
|
||||
}
|
||||
|
||||
boolean dirty = TracerUpdater.needsUpdate(p);
|
||||
if (TracerUpdater.getDisplayType(p) == ShowManager.DisplayType.Block && !dirty) {
|
||||
boolean dirty = ShowManager.get(p).isDirty();
|
||||
if (ShowManager.get(p).getDisplayType() == ShowManager.DisplayType.Block && !dirty) {
|
||||
continue;
|
||||
}
|
||||
Set<TraceCache.Loc> toHide = traceCache.update(p, dirty);
|
||||
Set<TraceCache.Loc> toShow = traceCache.get(p);
|
||||
|
||||
hideBlockTraces(toHide, p);
|
||||
showTraces(toShow, TracerUpdater.getDisplayType(p), p);
|
||||
showTraces(toShow, ShowManager.get(p).getDisplayType(), p);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,6 +1,5 @@
|
||||
package de.steamwar.bausystem.tracer;
|
||||
|
||||
import de.steamwar.bausystem.tracer.manager.ShowManager;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.*;
|
||||
@ -22,24 +21,24 @@ public class TraceCache {
|
||||
ShowManager.DisplayType displayMode;
|
||||
if (!playerMap.containsKey(key)) {
|
||||
locOld = new HashSet<>();
|
||||
displayMode = TracerUpdater.getDisplayType(player);
|
||||
displayMode = getDisplayType(player);
|
||||
} else {
|
||||
locOld = playerMap.get(key);
|
||||
displayMode = playerDisplayMap.get(key);
|
||||
}
|
||||
|
||||
Set<Loc> locSet = new HashSet<>();
|
||||
TracerUpdater.updatePoints(player).forEach(loc -> {
|
||||
updatePoints(player).forEach(loc -> {
|
||||
loc.updatePoint = true;
|
||||
locSet.add(loc);
|
||||
});
|
||||
TracerUpdater.updateLocations(player).forEach(loc -> {
|
||||
updateLocations(player).forEach(loc -> {
|
||||
loc.updatePoint = false;
|
||||
locSet.add(loc);
|
||||
});
|
||||
|
||||
playerMap.put(key, locSet);
|
||||
ShowManager.DisplayType currentMode = TracerUpdater.getDisplayType(player);
|
||||
ShowManager.DisplayType currentMode = getDisplayType(player);
|
||||
playerDisplayMap.put(key, currentMode);
|
||||
|
||||
if (currentMode == ShowManager.DisplayType.Particle && displayMode == ShowManager.DisplayType.Block) return locOld;
|
||||
@ -124,4 +123,29 @@ public class TraceCache {
|
||||
return locOld;
|
||||
}
|
||||
|
||||
private Set<TraceCache.Loc> updateLocations(Player player) {
|
||||
Iterator<TNTTrace> traces = ShowManager.get(player).getTraces().descendingIterator();
|
||||
Set<TraceCache.Loc> locSet = new HashSet<>();
|
||||
while (traces.hasNext()) {
|
||||
locSet.addAll(traces.next().locs());
|
||||
}
|
||||
double radius = ShowManager.get(player).getShowRadius();
|
||||
locSet.removeIf(loc -> loc.remove(player, radius));
|
||||
return locSet;
|
||||
}
|
||||
|
||||
private Set<TraceCache.Loc> updatePoints(Player player) {
|
||||
Iterator<TNTTrace> traces = ShowManager.get(player).getTraces().descendingIterator();
|
||||
Set<TraceCache.Loc> locSet = new HashSet<>();
|
||||
while (traces.hasNext()) {
|
||||
locSet.addAll(traces.next().locsUpdate(ShowManager.get(player).getDisplayMode()));
|
||||
}
|
||||
double radius = ShowManager.get(player).getShowRadius();
|
||||
locSet.removeIf(loc -> loc.remove(player, radius));
|
||||
return locSet;
|
||||
}
|
||||
|
||||
private ShowManager.DisplayType getDisplayType(Player player) {
|
||||
return ShowManager.get(player).getDisplayType();
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,5 @@
|
||||
package de.steamwar.bausystem.tracer;
|
||||
|
||||
import de.steamwar.bausystem.tracer.manager.ShowManager;
|
||||
import de.steamwar.bausystem.tracer.manager.TraceManager;
|
||||
import de.steamwar.bausystem.tracer.recorder.RecordManager;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.entity.TNTPrimed;
|
||||
@ -18,12 +16,11 @@ public class TraceListener implements Listener {
|
||||
|
||||
private static final Map<TNTPrimed, TNTTrace> tntMap = new HashMap<>();
|
||||
|
||||
public static void add(Stream<TNTPrimed> tntPrimedStream, int frameID) {
|
||||
public static void onTick(Stream<TNTPrimed> tntPrimedStream) {
|
||||
tntPrimedStream.forEach(tnt -> {
|
||||
TNTTrace trace;
|
||||
if (!tntMap.containsKey(tnt)) {
|
||||
trace = new TNTTrace(frameID);
|
||||
TraceManager.add(trace);
|
||||
trace = TraceManager.createTrace();
|
||||
tntMap.put(tnt, trace);
|
||||
} else {
|
||||
trace = tntMap.get(tnt);
|
||||
@ -42,7 +39,7 @@ public class TraceListener implements Listener {
|
||||
if (RecordManager.getStatus() == RecordManager.Status.RECORD_AUTO)
|
||||
RecordManager.updateAuto();
|
||||
|
||||
TNTTrace trace = tntMap.get((TNTPrimed) event.getEntity());
|
||||
TNTTrace trace = tntMap.remove((TNTPrimed) event.getEntity());
|
||||
if (trace != null)
|
||||
trace.cleanUp();
|
||||
}
|
||||
|
80
BauSystem_Main/src/de/steamwar/bausystem/tracer/TraceManager.java
Normale Datei
80
BauSystem_Main/src/de/steamwar/bausystem/tracer/TraceManager.java
Normale Datei
@ -0,0 +1,80 @@
|
||||
package de.steamwar.bausystem.tracer;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
public class TraceManager {
|
||||
private TraceManager(){}
|
||||
|
||||
private static Map<Integer, List<Integer>> frameMap = new HashMap<>();
|
||||
private static Map<Integer, TNTTrace> traceMap = new HashMap<>();
|
||||
|
||||
private static int currentFrame;
|
||||
|
||||
private static int currentID = 0;
|
||||
private static synchronized int generateID() {
|
||||
return currentID++;
|
||||
}
|
||||
|
||||
public static void startFrame() {
|
||||
currentFrame = generateID();
|
||||
frameMap.put(currentFrame, new ArrayList<>());
|
||||
}
|
||||
|
||||
public static TNTTrace createTrace() {
|
||||
TNTTrace trace = new TNTTrace(currentFrame);
|
||||
int id = generateID();
|
||||
traceMap.put(id, trace);
|
||||
frameMap.get(currentFrame).add(id);
|
||||
return trace;
|
||||
}
|
||||
|
||||
public static TNTTrace getTrace(int id) {
|
||||
return traceMap.get(id);
|
||||
}
|
||||
|
||||
public static Set<Integer> getAllTraces() {
|
||||
return traceMap.keySet();
|
||||
}
|
||||
|
||||
public static List<Integer> getFrame(int frameID) {
|
||||
return new ArrayList<>(frameMap.getOrDefault(frameID, new ArrayList<>()));
|
||||
}
|
||||
|
||||
public static int currentFrameSize(){
|
||||
return frameMap.get(currentFrame).size();
|
||||
}
|
||||
|
||||
public static void stopFrame() {
|
||||
testRemoveFrame(currentFrame);
|
||||
}
|
||||
|
||||
private static void testRemoveFrame(int frame){
|
||||
if (!frameMap.containsKey(frame) || !frameMap.get(frame).isEmpty())
|
||||
return;
|
||||
frameMap.remove(frame);
|
||||
}
|
||||
|
||||
public static void deleteAll() {
|
||||
for (Integer integer : new HashSet<>(traceMap.keySet())) {
|
||||
delete(integer);
|
||||
}
|
||||
}
|
||||
|
||||
public static void delete(int id) {
|
||||
TNTTrace trace = traceMap.remove(id);
|
||||
if(trace == null){
|
||||
List<Integer> frame = frameMap.get(id);
|
||||
if(frame == null)
|
||||
return;
|
||||
|
||||
for(int t : new HashSet<>(frame)){
|
||||
delete(t);
|
||||
}
|
||||
return;
|
||||
}
|
||||
int frameID = trace.getFrameID();
|
||||
ShowManager.traceRemove(id);
|
||||
frameMap.get(frameID).remove((Integer) id);
|
||||
testRemoveFrame(frameID);
|
||||
}
|
||||
}
|
@ -1,47 +0,0 @@
|
||||
package de.steamwar.bausystem.tracer;
|
||||
|
||||
import de.steamwar.bausystem.tracer.manager.ShowManager;
|
||||
import de.steamwar.bausystem.tracer.manager.TraceManager;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.Set;
|
||||
|
||||
class TracerUpdater {
|
||||
private TracerUpdater(){}
|
||||
|
||||
static Set<TraceCache.Loc> updateLocations(Player player) {
|
||||
Iterator<TNTTrace> traces = ShowManager.get(player).getTraces().descendingIterator();
|
||||
Set<TraceCache.Loc> locSet = new HashSet<>();
|
||||
while (traces.hasNext()) {
|
||||
locSet.addAll(traces.next().locs());
|
||||
}
|
||||
double radius = ShowManager.get(player).getShowRadius();
|
||||
locSet.removeIf(loc -> loc.remove(player, radius));
|
||||
return locSet;
|
||||
}
|
||||
|
||||
static Set<TraceCache.Loc> updatePoints(Player player) {
|
||||
Iterator<TNTTrace> traces = ShowManager.get(player).getTraces().descendingIterator();
|
||||
Set<TraceCache.Loc> locSet = new HashSet<>();
|
||||
while (traces.hasNext()) {
|
||||
locSet.addAll(traces.next().locsUpdate(ShowManager.get(player).getDisplayMode()));
|
||||
}
|
||||
double radius = ShowManager.get(player).getShowRadius();
|
||||
locSet.removeIf(loc -> loc.remove(player, radius));
|
||||
return locSet;
|
||||
}
|
||||
|
||||
static boolean needsUpdate(Player player) {
|
||||
return ShowManager.get(player).isDirty();
|
||||
}
|
||||
|
||||
static ShowManager.DisplayType getDisplayType(Player player) {
|
||||
return ShowManager.get(player).getDisplayType();
|
||||
}
|
||||
|
||||
static String actionBar(Player player) {
|
||||
return "§e" + TraceManager.get().size() + " §cTraces §e" + ShowManager.get(player).getShowRadius() + " §cRadius";
|
||||
}
|
||||
}
|
@ -1,51 +0,0 @@
|
||||
package de.steamwar.bausystem.tracer.manager;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
public class FrameManager {
|
||||
|
||||
private static Map<Integer, List<Integer>> frameMap = new HashMap<>();
|
||||
|
||||
public static int createFrame() {
|
||||
int id = IDManager.generateID();
|
||||
frameMap.put(id, new ArrayList<>());
|
||||
return id;
|
||||
}
|
||||
|
||||
static void add(int frameID, int tntID) {
|
||||
if (!frameMap.containsKey(frameID)) {
|
||||
return;
|
||||
}
|
||||
frameMap.get(frameID).add(tntID);
|
||||
}
|
||||
|
||||
public static List<Integer> get(int frameID) {
|
||||
if (!frameMap.containsKey(frameID)) {
|
||||
return Arrays.asList(frameID);
|
||||
}
|
||||
return new ArrayList<>(frameMap.get(frameID));
|
||||
}
|
||||
|
||||
public static List<Integer> get() {
|
||||
return new LinkedList<>(frameMap.keySet());
|
||||
}
|
||||
|
||||
static void remove(int frameID, int traceID) {
|
||||
if (!frameMap.containsKey(frameID)) {
|
||||
return;
|
||||
}
|
||||
frameMap.get(frameID).remove((Integer) traceID);
|
||||
cleanUp(frameID);
|
||||
}
|
||||
|
||||
public static void cleanUp(int frameID) {
|
||||
if (!frameMap.containsKey(frameID)) {
|
||||
return;
|
||||
}
|
||||
if (!frameMap.get(frameID).isEmpty()) {
|
||||
return;
|
||||
}
|
||||
frameMap.remove(frameID);
|
||||
}
|
||||
|
||||
}
|
@ -1,11 +0,0 @@
|
||||
package de.steamwar.bausystem.tracer.manager;
|
||||
|
||||
public class IDManager {
|
||||
|
||||
private static int currentID = 0;
|
||||
|
||||
static synchronized int generateID() {
|
||||
return currentID++;
|
||||
}
|
||||
|
||||
}
|
@ -1,336 +0,0 @@
|
||||
package de.steamwar.bausystem.tracer.manager;
|
||||
|
||||
import de.steamwar.bausystem.BauSystem;
|
||||
import de.steamwar.bausystem.tracer.TraceCache;
|
||||
import de.steamwar.bausystem.tracer.TNTTrace;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedList;
|
||||
import java.util.Map;
|
||||
|
||||
public class ShowManager {
|
||||
|
||||
public enum DisplayMode {
|
||||
NONE,
|
||||
Y_AXIS,
|
||||
ALL
|
||||
}
|
||||
|
||||
public enum DisplayType {
|
||||
Particle,
|
||||
Block
|
||||
}
|
||||
|
||||
public enum ShowSelection {
|
||||
NONE,
|
||||
SELECTIVE,
|
||||
ALL
|
||||
}
|
||||
|
||||
public static boolean tracer(Player player, String[] args) {
|
||||
ShowStatus showStatus = showMap.get(player.getUniqueId().toString());
|
||||
showStatus.dirty = true;
|
||||
switch (args[0].toLowerCase()) {
|
||||
case "show":
|
||||
showStatus.show();
|
||||
if (args.length == 2) {
|
||||
return tracerShow(player, showStatus, args);
|
||||
}
|
||||
player.sendMessage(BauSystem.PREFIX + "§aAlle TNT-Positionen angezeigt");
|
||||
break;
|
||||
case "distance":
|
||||
if (args.length != 2) {
|
||||
return true;
|
||||
}
|
||||
if (args[1].equalsIgnoreCase("default")) {
|
||||
ShowManager.get(player).setSlope(7.0);
|
||||
player.sendMessage(BauSystem.PREFIX + "§aAnzeige Distanz auf " + ShowManager.get(player).slopeHeight + " gesetzt");
|
||||
return false;
|
||||
}
|
||||
try {
|
||||
double radius = Double.parseDouble(args[1]);
|
||||
radius = (double)(int)(radius * 10) / 10;
|
||||
ShowManager.get(player).setSlope(radius);
|
||||
player.sendMessage(BauSystem.PREFIX + "§aAnzeige Distanz auf " + ShowManager.get(player).slopeHeight + " gesetzt");
|
||||
return false;
|
||||
} catch (NumberFormatException e) {
|
||||
return true;
|
||||
}
|
||||
case "hide":
|
||||
showStatus.hide();
|
||||
if (args.length == 2) {
|
||||
return traceID(player, args[1], showStatus::removeSelection, new String[]{BauSystem.PREFIX + "§aTNT-Positionen des TNT mit ID {} versteckt"});
|
||||
}
|
||||
player.sendMessage(BauSystem.PREFIX + "§aAlle TNT-Positionen versteckt");
|
||||
break;
|
||||
case "toggleshow":
|
||||
if (args.length == 2) {
|
||||
return traceID(player, args[1], showStatus::toggleSelection, new String[]{BauSystem.PREFIX + "§aTNT-Positionen des TNT mit ID {} angezeigt"}, new String[]{BauSystem.PREFIX + "§aTNT-Positionen des TNT mit ID {} versteckt"});
|
||||
}
|
||||
return true;
|
||||
case "interpolate":
|
||||
if (args.length == 2) {
|
||||
return tracerInterpolate(player, showStatus, args);
|
||||
}
|
||||
return true;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private static boolean tracerShow(Player player, ShowStatus showStatus, String[] args) {
|
||||
switch (args[1].toLowerCase()) {
|
||||
case "block":
|
||||
case "blocks":
|
||||
showStatus.displayType = DisplayType.Block;
|
||||
player.sendMessage(BauSystem.PREFIX + "§aAlle TNT-Positionen, als Blöcke, angezeigt");
|
||||
break;
|
||||
case "particle":
|
||||
case "particles":
|
||||
case "default":
|
||||
showStatus.displayType = DisplayType.Particle;
|
||||
player.sendMessage(BauSystem.PREFIX + "§aAlle TNT-Positionen, als Partikel, angezeigt");
|
||||
break;
|
||||
default:
|
||||
return traceID(player, args[1], showStatus::addSelection, new String[]{BauSystem.PREFIX + "§aTNT-Positionen des TNT mit ID {} angezeigt"});
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private static boolean tracerInterpolate(Player player, ShowStatus showStatus, String[] args) {
|
||||
switch (args[1].toLowerCase()) {
|
||||
case "none":
|
||||
showStatus.displayMode = DisplayMode.NONE;
|
||||
player.sendMessage(BauSystem.PREFIX + "§aInterpolation auf §enone §agesetzt");
|
||||
break;
|
||||
case "yaxis":
|
||||
case "y":
|
||||
showStatus.displayMode = DisplayMode.Y_AXIS;
|
||||
player.sendMessage(BauSystem.PREFIX + "§aInterpolation auf §eyaxis §agesetzt");
|
||||
break;
|
||||
case "all":
|
||||
case "allaxis":
|
||||
case "xyz":
|
||||
case "default":
|
||||
showStatus.displayMode = DisplayMode.ALL;
|
||||
player.sendMessage(BauSystem.PREFIX + "§aInterpolation auf §eall §agesetzt");
|
||||
break;
|
||||
default:
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private interface Mode {
|
||||
void run(int tntID);
|
||||
}
|
||||
|
||||
private interface ModeChoose {
|
||||
boolean run(int tntID);
|
||||
}
|
||||
|
||||
private static boolean traceID(Player player, String number, Mode mode, String[] messages) {
|
||||
try {
|
||||
mode.run(Integer.parseInt(number));
|
||||
for (String s : messages) {
|
||||
player.sendMessage(s.replace("{}", number));
|
||||
}
|
||||
} catch (NumberFormatException e) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private static boolean traceID(Player player, String number, ModeChoose mode, String[] messagesTrue, String[] messagesFalse) {
|
||||
try {
|
||||
boolean result = mode.run(Integer.parseInt(number));
|
||||
if (result) {
|
||||
for (String s : messagesTrue) {
|
||||
player.sendMessage(s.replace("{}", number));
|
||||
}
|
||||
} else {
|
||||
for (String s : messagesFalse) {
|
||||
player.sendMessage(s.replace("{}", number));
|
||||
}
|
||||
}
|
||||
} catch (NumberFormatException e) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static class ShowStatus {
|
||||
|
||||
private ShowSelection showSelection = ShowSelection.NONE;
|
||||
private DisplayType displayType = DisplayType.Particle;
|
||||
private DisplayMode displayMode = DisplayMode.ALL;
|
||||
|
||||
private boolean dirty = true;
|
||||
private int count = 0;
|
||||
|
||||
private LinkedList<Integer> selected = new LinkedList<>();
|
||||
|
||||
private void clear() {
|
||||
if (showSelection == ShowSelection.NONE) return;
|
||||
selected.clear();
|
||||
}
|
||||
|
||||
void show() {
|
||||
showSelection = ShowSelection.ALL;
|
||||
}
|
||||
|
||||
void hide() {
|
||||
clear();
|
||||
showSelection = ShowSelection.NONE;
|
||||
}
|
||||
|
||||
void addSelection(int id) {
|
||||
if (showSelection == ShowSelection.ALL) return;
|
||||
if (showSelection == ShowSelection.NONE) showSelection = ShowSelection.SELECTIVE;
|
||||
selected.addAll(FrameManager.get(id));
|
||||
if (selected.size() == TraceManager.get().size()) {
|
||||
showSelection = ShowSelection.ALL;
|
||||
clear();
|
||||
}
|
||||
}
|
||||
|
||||
void removeSelection(int id) {
|
||||
if (showSelection == ShowSelection.NONE) return;
|
||||
if (showSelection == ShowSelection.ALL) selected = TraceManager.get();
|
||||
selected.removeAll(FrameManager.get(id));
|
||||
showSelection = ShowSelection.SELECTIVE;
|
||||
if (selected.isEmpty()) showSelection = ShowSelection.NONE;
|
||||
}
|
||||
|
||||
boolean toggleSelection(int id) {
|
||||
if (showSelection == ShowSelection.NONE) {
|
||||
addSelection(id);
|
||||
return true;
|
||||
}
|
||||
if (showSelection == ShowSelection.ALL) {
|
||||
removeSelection(id);
|
||||
return false;
|
||||
}
|
||||
if (selected.contains(id)) {
|
||||
removeSelection(id);
|
||||
return false;
|
||||
} else {
|
||||
addSelection(id);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public DisplayType getDisplayType() {
|
||||
return displayType;
|
||||
}
|
||||
|
||||
public DisplayMode getDisplayMode() {
|
||||
return displayMode;
|
||||
}
|
||||
|
||||
public LinkedList<TNTTrace> getTraces() {
|
||||
if (showSelection == ShowSelection.NONE) return new LinkedList<>();
|
||||
LinkedList<Integer> tntIDs;
|
||||
if (showSelection == ShowSelection.ALL) {
|
||||
tntIDs = TraceManager.get();
|
||||
} else {
|
||||
tntIDs = selected;
|
||||
}
|
||||
|
||||
LinkedList<TNTTrace> traces = new LinkedList<>();
|
||||
Iterator<Integer> iterator = tntIDs.descendingIterator();
|
||||
while (iterator.hasNext()) {
|
||||
TNTTrace trace = TraceManager.get(iterator.next());
|
||||
if (trace == null) continue;
|
||||
traces.add(trace);
|
||||
}
|
||||
return traces;
|
||||
}
|
||||
|
||||
public boolean isDirty() {
|
||||
if (displayType == DisplayType.Block) {
|
||||
count++;
|
||||
}
|
||||
if (count >= 10) {
|
||||
count = 0;
|
||||
return true;
|
||||
}
|
||||
if (dirty) {
|
||||
dirty = false;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private double slopeHeight = 7.0;
|
||||
|
||||
private int size = 0;
|
||||
|
||||
private TraceCache.Loc loc = null;
|
||||
|
||||
public double getShowRadius() {
|
||||
double maxRadius = 80.0;
|
||||
if (showSelection == ShowSelection.NONE) return maxRadius;
|
||||
if (showSelection == ShowSelection.ALL) size = TraceManager.get().size();
|
||||
if (showSelection == ShowSelection.SELECTIVE) size = selected.size();
|
||||
if (size == 0) return maxRadius;
|
||||
double minRadius = 20.0;
|
||||
if (size >= 950) return minRadius;
|
||||
|
||||
double slope = -(size / slopeHeight) + 85;
|
||||
return Math.min(Math.max(slope, minRadius), maxRadius);
|
||||
}
|
||||
|
||||
void setSlope(double slope) {
|
||||
double minSlope = 3.0;
|
||||
double maxSlope = 11.0;
|
||||
slopeHeight = Math.min(Math.max(slope, minSlope), maxSlope);
|
||||
}
|
||||
|
||||
public void move(Player player) {
|
||||
if (loc != null && !loc.remove(player, 4)) {
|
||||
return;
|
||||
}
|
||||
Location location = player.getLocation();
|
||||
loc = new TraceCache.Loc((float) location.getX(), (float) location.getY(), (float) location.getZ());
|
||||
dirty = true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private static Map<String, ShowStatus> showMap = new HashMap<>();
|
||||
|
||||
public static void add(Player p) {
|
||||
showMap.put(p.getUniqueId().toString(), new ShowStatus());
|
||||
}
|
||||
|
||||
public static ShowStatus get(Player p) {
|
||||
if (!showMap.containsKey(p.getUniqueId().toString())) add(p);
|
||||
return showMap.get(p.getUniqueId().toString());
|
||||
}
|
||||
|
||||
public static void traceAdd() {
|
||||
for (Map.Entry<String, ShowStatus> entry : showMap.entrySet()) {
|
||||
if (entry.getValue().showSelection == ShowSelection.ALL) {
|
||||
entry.getValue().dirty = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void traceRemove(int id) {
|
||||
for (Map.Entry<String, ShowStatus> entry : showMap.entrySet()) {
|
||||
entry.getValue().removeSelection(id);
|
||||
}
|
||||
}
|
||||
|
||||
static void globalDirty() {
|
||||
for (Map.Entry<String, ShowStatus> entry : showMap.entrySet()) {
|
||||
entry.getValue().dirty = true;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -1,61 +0,0 @@
|
||||
package de.steamwar.bausystem.tracer.manager;
|
||||
|
||||
import de.steamwar.bausystem.BauSystem;
|
||||
import de.steamwar.bausystem.tracer.TNTTrace;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
public class TraceManager {
|
||||
private TraceManager(){}
|
||||
|
||||
private static Map<Integer, TNTTrace> traceMap = new HashMap<>();
|
||||
|
||||
public static void add(TNTTrace tntTrace) {
|
||||
int id = IDManager.generateID();
|
||||
FrameManager.add(tntTrace.getFrameID(), id);
|
||||
traceMap.put(id, tntTrace);
|
||||
}
|
||||
|
||||
private static void remove() {
|
||||
Iterator<Integer> iterator = get().descendingIterator();
|
||||
while (iterator.hasNext()) {
|
||||
remove(iterator.next());
|
||||
}
|
||||
}
|
||||
|
||||
private static void remove(int id) {
|
||||
if (!traceMap.containsKey(id)) {
|
||||
return;
|
||||
}
|
||||
int frameID = traceMap.remove(id).getFrameID();
|
||||
ShowManager.traceRemove(id);
|
||||
FrameManager.remove(frameID, id);
|
||||
}
|
||||
|
||||
public static TNTTrace get(int id) {
|
||||
return traceMap.get(id);
|
||||
}
|
||||
|
||||
public static LinkedList<Integer> get() {
|
||||
return new LinkedList<>(traceMap.keySet());
|
||||
}
|
||||
|
||||
public static boolean delete(Player player, String[] args) {
|
||||
if (args.length == 2) {
|
||||
try {
|
||||
remove(Integer.parseInt(args[1]));
|
||||
player.sendMessage(BauSystem.PREFIX + "§cTNT-Positionen mit ID " + args[1] + " gelöscht");
|
||||
ShowManager.globalDirty();
|
||||
return false;
|
||||
} catch (NumberFormatException e) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
remove();
|
||||
player.sendMessage(BauSystem.PREFIX + "§cAlle TNT-Positionen gelöscht");
|
||||
ShowManager.globalDirty();
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
@ -1,7 +1,7 @@
|
||||
package de.steamwar.bausystem.tracer.recorder;
|
||||
|
||||
import de.steamwar.bausystem.BauSystem;
|
||||
import de.steamwar.bausystem.tracer.manager.FrameManager;
|
||||
import de.steamwar.bausystem.tracer.TraceManager;
|
||||
import net.md_5.bungee.api.ChatMessageType;
|
||||
import net.md_5.bungee.api.chat.TextComponent;
|
||||
import org.bukkit.Bukkit;
|
||||
@ -13,7 +13,6 @@ import static de.steamwar.bausystem.tracer.recorder.TNTRecorder.*;
|
||||
public class RecordManager {
|
||||
|
||||
static Status status = Status.IDLE;
|
||||
public static Integer activeFrameID = null;
|
||||
|
||||
static final World world = Bukkit.getWorlds().get(0);
|
||||
|
||||
@ -63,52 +62,33 @@ public class RecordManager {
|
||||
}
|
||||
|
||||
private static void start() {
|
||||
if (activeFrameID != null) return;
|
||||
status = Status.RECORD;
|
||||
generateFrameID();
|
||||
TraceManager.startFrame();
|
||||
startRecording();
|
||||
}
|
||||
|
||||
public static void startAuto() {
|
||||
if (activeFrameID != null) {
|
||||
update();
|
||||
return;
|
||||
}
|
||||
status = Status.RECORD_AUTO;
|
||||
Bukkit.getOnlinePlayers().forEach(player -> player.spigot().sendMessage(ChatMessageType.ACTION_BAR, TextComponent.fromLegacyText("§7Automatischer TNT-Tracer §8- §aAufnahme gestartet")));
|
||||
generateFrameID();
|
||||
TraceManager.startFrame();
|
||||
startRecording();
|
||||
}
|
||||
|
||||
public static void updateAuto() {
|
||||
if (activeFrameID == null) return;
|
||||
update();
|
||||
}
|
||||
|
||||
private static void stop() {
|
||||
if (activeFrameID == null) return;
|
||||
status = Status.IDLE;
|
||||
stopRecording();
|
||||
cleanUPFrameID();
|
||||
TraceManager.stopFrame();
|
||||
}
|
||||
|
||||
static void stopAuto() {
|
||||
if (activeFrameID == null) return;
|
||||
status = Status.IDLE_AUTO;
|
||||
Bukkit.getOnlinePlayers().forEach(player -> player.spigot().sendMessage(ChatMessageType.ACTION_BAR, TextComponent.fromLegacyText("§7Automatischer TNT-Tracer §8- §aAufnahme gestoppt")));
|
||||
stopRecording();
|
||||
cleanUPFrameID();
|
||||
}
|
||||
|
||||
private static void generateFrameID() {
|
||||
if (activeFrameID != null) return;;
|
||||
activeFrameID = FrameManager.createFrame();
|
||||
}
|
||||
|
||||
private static void cleanUPFrameID() {
|
||||
if (activeFrameID == null) return;
|
||||
FrameManager.cleanUp(activeFrameID);
|
||||
activeFrameID = null;
|
||||
TraceManager.stopFrame();
|
||||
}
|
||||
|
||||
public enum Status {
|
||||
|
@ -41,7 +41,7 @@ public class TNTRecorder {
|
||||
.stream()
|
||||
.filter(e -> e instanceof TNTPrimed)
|
||||
.map(e -> (TNTPrimed)e);
|
||||
TraceListener.add(tntPrimedStream, RecordManager.activeFrameID);
|
||||
TraceListener.onTick(tntPrimedStream);
|
||||
|
||||
if (RecordManager.status == RecordManager.Status.RECORD_AUTO && System.currentTimeMillis() - lastExplosion > 4500) {
|
||||
stopAuto();
|
||||
|
@ -3,7 +3,7 @@ package de.steamwar.bausystem.world;
|
||||
import de.steamwar.bausystem.commands.CommandFreeze;
|
||||
import de.steamwar.bausystem.commands.CommandInfo;
|
||||
import de.steamwar.bausystem.commands.CommandTNT;
|
||||
import de.steamwar.bausystem.tracer.manager.FrameManager;
|
||||
import de.steamwar.bausystem.tracer.TraceManager;
|
||||
import de.steamwar.bausystem.tracer.recorder.RecordManager;
|
||||
import de.steamwar.bausystem.tracer.recorder.TNTRecorder;
|
||||
import de.steamwar.scoreboard.SWScoreboard;
|
||||
@ -58,7 +58,7 @@ public class BauScoreboard implements Listener {
|
||||
strings.add("§3");
|
||||
strings.add("§eTrace-Start§8: §7" + new SimpleDateFormat("HH:mm:ss").format(new Date(TNTRecorder.recordStart)));
|
||||
strings.add("§eTicks§8: §7" + traceTicks());
|
||||
strings.add("§eAnzahl TNT§8: §7" + traceSize());
|
||||
strings.add("§eAnzahl TNT§8: §7" + TraceManager.currentFrameSize());
|
||||
}
|
||||
|
||||
strings.add("§4");
|
||||
@ -69,11 +69,4 @@ public class BauScoreboard implements Listener {
|
||||
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