Trace Refactor #233
@ -53,8 +53,8 @@ public class Recorder implements Listener {
|
|||||||
*/
|
*/
|
||||||
private final Map<Region, List<TNTPrimed>> trackedTNT = new HashMap<>();
|
private final Map<Region, List<TNTPrimed>> trackedTNT = new HashMap<>();
|
||||||
|
|
||||||
/** Map from TNT to Region the TNT spawned in
|
/**
|
||||||
*
|
* Map from TNT to Region the TNT spawned in
|
||||||
*/
|
*/
|
||||||
private final Map<TNTPrimed, Region> tntSpawnRegion = new HashMap<>();
|
private final Map<TNTPrimed, Region> tntSpawnRegion = new HashMap<>();
|
||||||
|
|
||||||
@ -85,19 +85,21 @@ public class Recorder implements Listener {
|
|||||||
}, 0, 1);
|
}, 0, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Toggles auto trace for the given region
|
/**
|
||||||
|
* Toggles auto trace for the given region
|
||||||
*
|
*
|
||||||
* @param region
|
* @param region
|
||||||
*/
|
*/
|
||||||
public void toggleAutoTrace(Region region) {
|
public void toggleAutoTrace(Region region) {
|
||||||
if (autoTraceRegions.contains(region))
|
if (autoTraceRegions.contains(region)) {
|
||||||
autoTraceRegions.remove(region);
|
autoTraceRegions.remove(region);
|
||||||
else
|
} else {
|
||||||
autoTraceRegions.add(region);
|
autoTraceRegions.add(region);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/** Makes checks for whether auto traces finished
|
/**
|
||||||
*
|
* Makes checks for whether auto traces finished
|
||||||
*/
|
*/
|
||||||
public void checkForAutoTraceFinish() {
|
public void checkForAutoTraceFinish() {
|
||||||
for (Region region : autoTraceRegions) {
|
for (Region region : autoTraceRegions) {
|
||||||
@ -107,7 +109,8 @@ public class Recorder implements Listener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Starts a recording at the given region
|
/**
|
||||||
|
* Starts a recording at the given region
|
||||||
*
|
*
|
||||||
* @param region region to be recorded
|
* @param region region to be recorded
|
||||||
*/
|
*/
|
||||||
@ -120,7 +123,8 @@ public class Recorder implements Listener {
|
|||||||
return manager.add(trace);
|
return manager.add(trace);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Stops the recording at the given region
|
/**
|
||||||
|
* Stops the recording at the given region
|
||||||
*
|
*
|
||||||
* @param region region to stop recording
|
* @param region region to stop recording
|
||||||
*/
|
*/
|
||||||
@ -131,15 +135,16 @@ public class Recorder implements Listener {
|
|||||||
|
|
||||||
noExplosionRecorded.remove(trace);
|
noExplosionRecorded.remove(trace);
|
||||||
activeTraces.remove(region);
|
activeTraces.remove(region);
|
||||||
for(TNTPrimed tnt : trackedTNT.getOrDefault(region, Collections.emptyList()))
|
for (TNTPrimed tnt : trackedTNT.getOrDefault(region, Collections.emptyList())) {
|
||||||
historyMap.remove(tnt);
|
historyMap.remove(tnt);
|
||||||
|
}
|
||||||
|
|
||||||
recordsToAddMap.remove(trace);
|
recordsToAddMap.remove(trace);
|
||||||
trackedTNT.put(region, new ArrayList<>());
|
trackedTNT.put(region, new ArrayList<>());
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Internal methode to record all tracked TNT Entities
|
/**
|
||||||
*
|
* Internal methode to record all tracked TNT Entities
|
||||||
*/
|
*/
|
||||||
private void record() {
|
private void record() {
|
||||||
for (Region region : activeTraces.keySet()) {
|
for (Region region : activeTraces.keySet()) {
|
||||||
@ -153,7 +158,8 @@ public class Recorder implements Listener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Internal methode to record exploded tnt
|
/**
|
||||||
|
* Internal methode to record exploded tnt
|
||||||
*
|
*
|
||||||
* @param tntPrimed tnt exploding
|
* @param tntPrimed tnt exploding
|
||||||
* @param trace trace to record the tnt for
|
* @param trace trace to record the tnt for
|
||||||
@ -165,13 +171,14 @@ public class Recorder implements Listener {
|
|||||||
if (history.size() == 0) {
|
if (history.size() == 0) {
|
||||||
historyMap.put(tntPrimed, history);
|
historyMap.put(tntPrimed, history);
|
||||||
tntID = trace.getAndIncrementNextOpenRecordId();
|
tntID = trace.getAndIncrementNextOpenRecordId();
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
tntID = history.get(0).getTntId();
|
tntID = history.get(0).getTntId();
|
||||||
|
}
|
||||||
|
|
||||||
boolean isExplosion = tntPrimed.getFuseTicks() == 0;
|
boolean isExplosion = tntPrimed.getFuseTicks() == 0;
|
||||||
if(isExplosion)
|
if (isExplosion) {
|
||||||
noExplosionRecorded.remove(trace);
|
noExplosionRecorded.remove(trace);
|
||||||
|
}
|
||||||
boolean afterFirstExplosion = noExplosionRecorded.contains(trace);
|
boolean afterFirstExplosion = noExplosionRecorded.contains(trace);
|
||||||
|
|
||||||
TNTRecord record = new TNTRecord(tntID, tntPrimed, isExplosion, afterFirstExplosion, TPSUtils.currentTick.get() - trace.getStartTime(), history, destroyedBlocks);
|
TNTRecord record = new TNTRecord(tntID, tntPrimed, isExplosion, afterFirstExplosion, TPSUtils.currentTick.get() - trace.getStartTime(), history, destroyedBlocks);
|
||||||
@ -180,8 +187,10 @@ public class Recorder implements Listener {
|
|||||||
recordsToAddMap.get(trace).add(record);
|
recordsToAddMap.get(trace).add(record);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Event for TNTs beeing spawn.
|
/**
|
||||||
|
* Event for TNTs beeing spawn.
|
||||||
* Registers newly spawned TNT to be traced if reqired
|
* Registers newly spawned TNT to be traced if reqired
|
||||||
|
*
|
||||||
* @param event
|
* @param event
|
||||||
*/
|
*/
|
||||||
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
|
||||||
@ -190,13 +199,15 @@ public class Recorder implements Listener {
|
|||||||
|
|
||||||
Region region = Region.getRegion(event.getLocation());
|
Region region = Region.getRegion(event.getLocation());
|
||||||
|
|
||||||
if(autoTraceRegions.contains(region) && !activeTraces.containsKey(region))
|
if (autoTraceRegions.contains(region) && !activeTraces.containsKey(region)) {
|
||||||
startRecording(region);
|
startRecording(region);
|
||||||
|
}
|
||||||
|
|
||||||
if (activeTraces.containsKey(region)) {
|
if (activeTraces.containsKey(region)) {
|
||||||
// Check whether set for tracking already exists. Creating it if necessary
|
// Check whether set for tracking already exists. Creating it if necessary
|
||||||
if(!trackedTNT.containsKey(region))
|
if (!trackedTNT.containsKey(region)) {
|
||||||
trackedTNT.put(region, new ArrayList<>());
|
trackedTNT.put(region, new ArrayList<>());
|
||||||
|
}
|
||||||
|
|
||||||
trackedTNT.get(region).add((TNTPrimed) event.getEntity());
|
trackedTNT.get(region).add((TNTPrimed) event.getEntity());
|
||||||
tntSpawnRegion.put((TNTPrimed) event.getEntity(), region);
|
tntSpawnRegion.put((TNTPrimed) event.getEntity(), region);
|
||||||
@ -204,8 +215,10 @@ public class Recorder implements Listener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Event for TNTs exploding
|
/**
|
||||||
|
* Event for TNTs exploding
|
||||||
* Unregisters TNTs from beeing traced on explode
|
* Unregisters TNTs from beeing traced on explode
|
||||||
|
*
|
||||||
* @param event
|
* @param event
|
||||||
*/
|
*/
|
||||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||||
|
@ -30,7 +30,6 @@ import org.bukkit.util.Vector;
|
|||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
public class TNTRecord {
|
public class TNTRecord {
|
||||||
@ -104,11 +103,13 @@ public class TNTRecord {
|
|||||||
boolean buildDestroy = false;
|
boolean buildDestroy = false;
|
||||||
boolean testblockDestroy = false;
|
boolean testblockDestroy = false;
|
||||||
for (Block destroyedBlock : destroyedBlocks) {
|
for (Block destroyedBlock : destroyedBlocks) {
|
||||||
if (Region.getRegion(destroyedBlock.getLocation()).inRegion(destroyedBlock.getLocation(), RegionType.BUILD, RegionExtensionType.EXTENSION))
|
if (Region.getRegion(destroyedBlock.getLocation()).inRegion(destroyedBlock.getLocation(), RegionType.BUILD, RegionExtensionType.EXTENSION)) {
|
||||||
buildDestroy = true;
|
buildDestroy = true;
|
||||||
if (Region.getRegion(destroyedBlock.getLocation()).inRegion(destroyedBlock.getLocation(), RegionType.TESTBLOCK, RegionExtensionType.EXTENSION))
|
}
|
||||||
|
if (Region.getRegion(destroyedBlock.getLocation()).inRegion(destroyedBlock.getLocation(), RegionType.TESTBLOCK, RegionExtensionType.EXTENSION)) {
|
||||||
testblockDestroy = true;
|
testblockDestroy = true;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
destroyedBuildArea = buildDestroy;
|
destroyedBuildArea = buildDestroy;
|
||||||
destroyedTestBlock = testblockDestroy;
|
destroyedTestBlock = testblockDestroy;
|
||||||
@ -116,13 +117,11 @@ public class TNTRecord {
|
|||||||
|
|
||||||
public Optional<TNTRecord> getNext() {
|
public Optional<TNTRecord> getNext() {
|
||||||
int index = history.indexOf(this);
|
int index = history.indexOf(this);
|
||||||
|
|
||||||
return index == history.size() - 1 ? Optional.empty() : Optional.of(history.get(index + 1));
|
return index == history.size() - 1 ? Optional.empty() : Optional.of(history.get(index + 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
public Optional<TNTRecord> getPrevious() {
|
public Optional<TNTRecord> getPrevious() {
|
||||||
int index = history.indexOf(this);
|
int index = history.indexOf(this);
|
||||||
|
|
||||||
return index == 0 ? Optional.empty() : Optional.of(history.get(index - 1));
|
return index == 0 ? Optional.empty() : Optional.of(history.get(index - 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -141,7 +140,6 @@ public class TNTRecord {
|
|||||||
public boolean equals(Object obj) {
|
public boolean equals(Object obj) {
|
||||||
if (!(obj instanceof TNTRecord)) return false;
|
if (!(obj instanceof TNTRecord)) return false;
|
||||||
TNTRecord record = (TNTRecord) obj;
|
TNTRecord record = (TNTRecord) obj;
|
||||||
|
|
||||||
if (record.isExplosion() != explosion) return false;
|
if (record.isExplosion() != explosion) return false;
|
||||||
if (!record.getLocation().equals(location)) return false;
|
if (!record.getLocation().equals(location)) return false;
|
||||||
if (!record.getVelocity().equals(velocity)) return false;
|
if (!record.getVelocity().equals(velocity)) return false;
|
||||||
|
@ -23,8 +23,8 @@ import de.steamwar.bausystem.features.tpslimit.TPSUtils;
|
|||||||
import de.steamwar.bausystem.features.tracer.rendering.BundleFilter;
|
import de.steamwar.bausystem.features.tracer.rendering.BundleFilter;
|
||||||
import de.steamwar.bausystem.features.tracer.rendering.TraceEntity;
|
import de.steamwar.bausystem.features.tracer.rendering.TraceEntity;
|
||||||
import de.steamwar.bausystem.features.tracer.rendering.ViewFlag;
|
import de.steamwar.bausystem.features.tracer.rendering.ViewFlag;
|
||||||
import de.steamwar.bausystem.features.tracer.rendering.dynamicFlags.AtFlag;
|
import de.steamwar.bausystem.features.tracer.rendering.dynamicflags.AtFlag;
|
||||||
import de.steamwar.bausystem.features.tracer.rendering.dynamicFlags.IsolateFlag;
|
import de.steamwar.bausystem.features.tracer.rendering.dynamicflags.IsolateFlag;
|
||||||
import de.steamwar.bausystem.region.Region;
|
import de.steamwar.bausystem.region.Region;
|
||||||
import de.steamwar.entity.REntityServer;
|
import de.steamwar.entity.REntityServer;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
@ -85,6 +85,7 @@ public class Trace {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets and increments the next open record id
|
* Gets and increments the next open record id
|
||||||
|
*
|
||||||
* @return next open record id
|
* @return next open record id
|
||||||
*/
|
*/
|
||||||
protected int getAndIncrementNextOpenRecordId() {
|
protected int getAndIncrementNextOpenRecordId() {
|
||||||
@ -108,7 +109,8 @@ public class Trace {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Internal methode to make records immutable after recording is finished
|
/**
|
||||||
|
* Internal methode to make records immutable after recording is finished
|
||||||
*
|
*
|
||||||
* @param records immutable records list
|
* @param records immutable records list
|
||||||
*/
|
*/
|
||||||
@ -116,7 +118,8 @@ public class Trace {
|
|||||||
this.records = records;
|
this.records = records;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Gets the historys of all tnts in this trace
|
/**
|
||||||
|
* Gets the historys of all tnts in this trace
|
||||||
*
|
*
|
||||||
* @return the historys of this trace
|
* @return the historys of this trace
|
||||||
*/
|
*/
|
||||||
@ -130,7 +133,8 @@ public class Trace {
|
|||||||
return histories;
|
return histories;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Renders this traces
|
/**
|
||||||
|
* Renders this traces
|
||||||
*
|
*
|
||||||
* @param player The player the trace is rendered to
|
* @param player The player the trace is rendered to
|
||||||
* @param flags Flags modefieing the rendering
|
* @param flags Flags modefieing the rendering
|
||||||
@ -156,7 +160,8 @@ public class Trace {
|
|||||||
render(server, records, flags, bundleFilter);
|
render(server, records, flags, bundleFilter);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Internal methode to render records to a REntityServer
|
/**
|
||||||
|
* Internal methode to render records to a REntityServer
|
||||||
*
|
*
|
||||||
* @param server Server to render to
|
* @param server Server to render to
|
||||||
* @param records Records to render
|
* @param records Records to render
|
||||||
@ -164,7 +169,7 @@ public class Trace {
|
|||||||
* @param bundleFilter Filter to determin bundeling of records
|
* @param bundleFilter Filter to determin bundeling of records
|
||||||
*/
|
*/
|
||||||
private void render(REntityServer server, List<TNTRecord> records, ViewFlag[] flags, BundleFilter bundleFilter) {
|
private void render(REntityServer server, List<TNTRecord> records, ViewFlag[] flags, BundleFilter bundleFilter) {
|
||||||
if(records.size() == 0) return;
|
if (records.isEmpty()) return;
|
||||||
|
|
||||||
List<TNTRecord> workingRecords = records;
|
List<TNTRecord> workingRecords = records;
|
||||||
|
|
||||||
@ -205,7 +210,7 @@ public class Trace {
|
|||||||
|
|
||||||
server.setCallback(((player, rEntity, entityAction) -> {
|
server.setCallback(((player, rEntity, entityAction) -> {
|
||||||
for (TraceEntity entity : entities) {
|
for (TraceEntity entity : entities) {
|
||||||
if(((TraceEntity) rEntity).equals(entity)){
|
if (rEntity.equals(entity)) {
|
||||||
entity.printIntoChat(player);
|
entity.printIntoChat(player);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -213,7 +218,8 @@ public class Trace {
|
|||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Bundles the passed TNTRecords based on whether they are at the same location
|
/**
|
||||||
|
* Bundles the passed TNTRecords based on whether they are at the same location
|
||||||
*
|
*
|
||||||
* @param records The TNTRecords that are supposed to be bundled
|
* @param records The TNTRecords that are supposed to be bundled
|
||||||
* @return A list of bundles
|
* @return A list of bundles
|
||||||
@ -248,7 +254,8 @@ public class Trace {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/** Modifies the render for the given player, to only show tnts at the given time interval
|
/**
|
||||||
|
* Modifies the render for the given player, to only show tnts at the given time interval
|
||||||
*
|
*
|
||||||
* @param player
|
* @param player
|
||||||
* @param from start of time interval
|
* @param from start of time interval
|
||||||
@ -267,8 +274,7 @@ public class Trace {
|
|||||||
|
|
||||||
if (atFlag != null) {
|
if (atFlag != null) {
|
||||||
atFlag.update(from, to);
|
atFlag.update(from, to);
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
atFlag = new AtFlag(from, to);
|
atFlag = new AtFlag(from, to);
|
||||||
viewFlags = Arrays.copyOf(viewFlags, viewFlags.length + 1);
|
viewFlags = Arrays.copyOf(viewFlags, viewFlags.length + 1);
|
||||||
viewFlags[viewFlags.length - 1] = atFlag;
|
viewFlags[viewFlags.length - 1] = atFlag;
|
||||||
@ -277,7 +283,8 @@ public class Trace {
|
|||||||
render(player, viewFlags, BundleFilter.STRICT);
|
render(player, viewFlags, BundleFilter.STRICT);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Toggles the isolated render for the given records and player
|
/**
|
||||||
|
* Toggles the isolated render for the given records and player
|
||||||
*
|
*
|
||||||
* @param player the player the trace is shown to
|
* @param player the player the trace is shown to
|
||||||
* @param records the record for which isolation is toggled
|
* @param records the record for which isolation is toggled
|
||||||
@ -302,13 +309,15 @@ public class Trace {
|
|||||||
}
|
}
|
||||||
viewFlags[0] = isolationFlag;
|
viewFlags[0] = isolationFlag;
|
||||||
|
|
||||||
for(TNTRecord record: records)
|
for (TNTRecord record : records) {
|
||||||
isolationFlag.toggleId(record.getTntId());
|
isolationFlag.toggleId(record.getTntId());
|
||||||
|
}
|
||||||
|
|
||||||
render(player, viewFlags, BundleFilter.STRICT);
|
render(player, viewFlags, BundleFilter.STRICT);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**Makes the first passed player follow the trace render of the second passed player
|
/**
|
||||||
|
* Makes the first passed player follow the trace render of the second passed player
|
||||||
*
|
*
|
||||||
* @param player
|
* @param player
|
||||||
* @param toFollow
|
* @param toFollow
|
||||||
@ -321,7 +330,8 @@ public class Trace {
|
|||||||
serverMap.get(toFollow).addPlayer(player);
|
serverMap.get(toFollow).addPlayer(player);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Makes the passed player stop following any other players trace render
|
/**
|
||||||
|
* Makes the passed player stop following any other players trace render
|
||||||
*
|
*
|
||||||
* @param player
|
* @param player
|
||||||
*/
|
*/
|
||||||
@ -335,7 +345,8 @@ public class Trace {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Hides this trail for the given player
|
/**
|
||||||
|
* Hides this trail for the given player
|
||||||
*
|
*
|
||||||
* @param player
|
* @param player
|
||||||
*/
|
*/
|
||||||
|
@ -21,21 +21,19 @@ package de.steamwar.bausystem.features.tracer;
|
|||||||
|
|
||||||
import de.steamwar.bausystem.BauSystem;
|
import de.steamwar.bausystem.BauSystem;
|
||||||
import de.steamwar.bausystem.features.tracer.rendering.BundleFilter;
|
import de.steamwar.bausystem.features.tracer.rendering.BundleFilter;
|
||||||
import de.steamwar.bausystem.features.tracer.rendering.TraceEntity;
|
|
||||||
import de.steamwar.bausystem.features.tracer.rendering.ViewFlag;
|
import de.steamwar.bausystem.features.tracer.rendering.ViewFlag;
|
||||||
import de.steamwar.bausystem.features.tracer.rendering.dynamicFlags.IsolateFlag;
|
|
||||||
import de.steamwar.bausystem.region.Region;
|
import de.steamwar.bausystem.region.Region;
|
||||||
import de.steamwar.command.PreviousArguments;
|
import de.steamwar.command.PreviousArguments;
|
||||||
import de.steamwar.command.SWCommand;
|
import de.steamwar.command.SWCommand;
|
||||||
import de.steamwar.command.TypeMapper;
|
import de.steamwar.command.TypeMapper;
|
||||||
import de.steamwar.command.TypeValidator;
|
|
||||||
import de.steamwar.entity.REntityServer;
|
|
||||||
import de.steamwar.linkage.Linked;
|
import de.steamwar.linkage.Linked;
|
||||||
import de.steamwar.linkage.LinkedInstance;
|
import de.steamwar.linkage.LinkedInstance;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.Collection;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
@ -46,75 +44,79 @@ public class TraceCommand extends SWCommand {
|
|||||||
public Recorder recorder;
|
public Recorder recorder;
|
||||||
@LinkedInstance
|
@LinkedInstance
|
||||||
public TraceManager manager;
|
public TraceManager manager;
|
||||||
public TraceCommand(){super("trace", "trail");}
|
|
||||||
|
public TraceCommand() {
|
||||||
|
super("trace", "trail");
|
||||||
|
}
|
||||||
|
|
||||||
@Register(value = "start", description = "TRACE_COMMAND_HELP_START")
|
@Register(value = "start", description = "TRACE_COMMAND_HELP_START")
|
||||||
public void start(Player player){
|
public void start(@Validator Player player) {
|
||||||
Region region = Region.getRegion(player.getLocation());
|
Region region = Region.getRegion(player.getLocation());
|
||||||
recorder.startRecording(region);
|
recorder.startRecording(region);
|
||||||
BauSystem.MESSAGE.send("TRACE_MESSAGE_START", player);
|
BauSystem.MESSAGE.send("TRACE_MESSAGE_START", player);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Register(value = "stop", description = "TRACE_COMMAND_HELP_STOP")
|
@Register(value = "stop", description = "TRACE_COMMAND_HELP_STOP")
|
||||||
public void stop(Player player){
|
public void stop(@Validator Player player) {
|
||||||
Region region = Region.getRegion(player.getLocation());
|
Region region = Region.getRegion(player.getLocation());
|
||||||
recorder.stopRecording(region);
|
recorder.stopRecording(region);
|
||||||
BauSystem.MESSAGE.send("TRACE_MESSAGE_STOP", player);
|
BauSystem.MESSAGE.send("TRACE_MESSAGE_STOP", player);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Register(value = "auto", description = "TRACE_COMMAND_HELP_SHOW")
|
@Register(value = "auto", description = "TRACE_COMMAND_HELP_SHOW")
|
||||||
public void auto (Player player) {
|
public void auto(@Validator Player player) {
|
||||||
Region region = Region.getRegion(player.getLocation());
|
Region region = Region.getRegion(player.getLocation());
|
||||||
recorder.toggleAutoTrace(region);
|
recorder.toggleAutoTrace(region);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Register(value = "show", description = "TRACE_COMMAND_HELP_SHOW")
|
@Register(value = "show", description = "TRACE_COMMAND_HELP_SHOW")
|
||||||
public void show(Player player, @OptionalValue("STRICT") BundleFilter filter, ViewFlag... flags){
|
public void show(@Validator Player player, @OptionalValue("STRICT") BundleFilter filter, ViewFlag... flags) {
|
||||||
manager.show(player, flags, filter);
|
manager.show(player, flags, filter);
|
||||||
BauSystem.MESSAGE.send("TRACE_MESSAGE_SHOW", player);
|
BauSystem.MESSAGE.send("TRACE_MESSAGE_SHOW", player);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Register(value = "hide", description = "TRACE_COMMAND_HELP_SHOW")
|
@Register(value = "hide", description = "TRACE_COMMAND_HELP_SHOW")
|
||||||
public void hide(Player player){
|
public void hide(@Validator Player player) {
|
||||||
manager.hide(player);
|
manager.hide(player);
|
||||||
BauSystem.MESSAGE.send("TRACE_MESSAGE_HIDE", player);
|
BauSystem.MESSAGE.send("TRACE_MESSAGE_HIDE", player);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Register(value = "delete", description = "TRACE_COMMAND_HELP_SHOW")
|
@Register(value = "delete", description = "TRACE_COMMAND_HELP_SHOW")
|
||||||
public void delete(Player player){
|
public void delete(@Validator Player player) {
|
||||||
manager.clear();
|
manager.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Register(value = "delete", description = "TRACE_COMMAND_HELP_SHOW")
|
@Register(value = "delete", description = "TRACE_COMMAND_HELP_SHOW")
|
||||||
public void delete(Player player, int id){
|
public void delete(@Validator Player player, int id) {
|
||||||
manager.remove(id);
|
manager.remove(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Register(value = "isolate", description = "TRACE_COMMAND_HELP_SHOW")
|
@Register(value = "isolate", description = "TRACE_COMMAND_HELP_SHOW")
|
||||||
public void isolate(Player player, Trace trace, @ErrorMessage("TRACE_RECORD_ID_INVALID") TNTRecord... records){
|
public void isolate(@Validator Player player, Trace trace, @ErrorMessage("TRACE_RECORD_ID_INVALID") TNTRecord... records) {
|
||||||
trace.isolate(player, records);
|
trace.isolate(player, records);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Register(value = "at", description = "TRACE_COMMAND_HELP_SHOW")
|
@Register(value = "at", description = "TRACE_COMMAND_HELP_SHOW")
|
||||||
public void at(Player player, int start, int end){
|
public void at(@Validator Player player, int start, int end) {
|
||||||
for (Trace trace : manager.getAll()) {
|
for (Trace trace : manager.getAll()) {
|
||||||
trace.renderAt(player, start, end);
|
trace.renderAt(player, start, end);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Register(value = "share", description = "TRACE_COMMAND_HELP_SHOW")
|
@Register(value = "share", description = "TRACE_COMMAND_HELP_SHOW")
|
||||||
public void share(Player player){
|
public void share(@Validator Player player) {
|
||||||
//TODO Rücksprache
|
//TODO Rücksprache
|
||||||
}
|
}
|
||||||
|
|
||||||
@Register(value = "follow", description = "TRACE_COMMAND_HELP_SHOW")
|
@Register(value = "follow", description = "TRACE_COMMAND_HELP_SHOW")
|
||||||
public void follow(Player player, Player toFollow){
|
public void follow(@Validator Player player, Player toFollow) {
|
||||||
for (Trace trace : manager.getAll()) {
|
for (Trace trace : manager.getAll()) {
|
||||||
trace.follow(player, toFollow);
|
trace.follow(player, toFollow);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Register(value = "unfollow", description = "TRACE_COMMAND_HELP_SHOW")
|
@Register(value = "unfollow", description = "TRACE_COMMAND_HELP_SHOW")
|
||||||
public void unfollow(Player player){
|
public void unfollow(@Validator Player player) {
|
||||||
for (Trace trace : manager.getAll()) {
|
for (Trace trace : manager.getAll()) {
|
||||||
trace.unfollow(player);
|
trace.unfollow(player);
|
||||||
}
|
}
|
||||||
@ -122,20 +124,16 @@ public class TraceCommand extends SWCommand {
|
|||||||
|
|
||||||
@ClassMapper(value = Trace.class, local = true)
|
@ClassMapper(value = Trace.class, local = true)
|
||||||
public TypeMapper<Trace> traceClassMapper() {
|
public TypeMapper<Trace> traceClassMapper() {
|
||||||
return new TypeMapper<Trace>() {
|
return new TypeMapper<>() {
|
||||||
@Override
|
@Override
|
||||||
public Trace map(CommandSender commandSender, String[] previousArguments, String s) {
|
public Trace map(CommandSender commandSender, String[] previousArguments, String s) {
|
||||||
int id = Integer.parseInt(s);
|
return manager.get(Integer.parseInt(s)).orElse(null);
|
||||||
|
|
||||||
Optional<Trace> trace = manager.get(id);
|
|
||||||
|
|
||||||
return trace.orElse(null);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Collection<String> tabCompletes(CommandSender sender, PreviousArguments previousArguments, String s) {
|
public Collection<String> tabCompletes(CommandSender sender, PreviousArguments previousArguments, String s) {
|
||||||
return manager.getAllIds().stream()
|
return manager.getAllIds().stream()
|
||||||
.map(id -> id.toString())
|
.map(Object::toString)
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -143,14 +141,13 @@ public class TraceCommand extends SWCommand {
|
|||||||
|
|
||||||
@ClassMapper(value = TNTRecord.class, local = true)
|
@ClassMapper(value = TNTRecord.class, local = true)
|
||||||
public TypeMapper<TNTRecord> recordMapper() {
|
public TypeMapper<TNTRecord> recordMapper() {
|
||||||
return new TypeMapper<TNTRecord>() {
|
return new TypeMapper<>() {
|
||||||
@Override
|
@Override
|
||||||
public TNTRecord map(CommandSender commandSender, PreviousArguments previousArguments, String s) {
|
public TNTRecord map(CommandSender commandSender, PreviousArguments previousArguments, String s) {
|
||||||
Trace trace = previousArguments.getFirst(Trace.class).orElse(null);
|
Trace trace = previousArguments.getFirst(Trace.class).orElse(null);
|
||||||
if (trace == null) return null;
|
if (trace == null) return null;
|
||||||
|
|
||||||
int id = Integer.parseInt(s);
|
int id = Integer.parseInt(s);
|
||||||
|
|
||||||
return trace.getRecords().stream()
|
return trace.getRecords().stream()
|
||||||
.filter(record -> record.getTntId() == id)
|
.filter(record -> record.getTntId() == id)
|
||||||
.findFirst()
|
.findFirst()
|
||||||
@ -162,7 +159,6 @@ public class TraceCommand extends SWCommand {
|
|||||||
public Collection<String> tabCompletes(CommandSender sender, PreviousArguments previousArguments, String s) {
|
public Collection<String> tabCompletes(CommandSender sender, PreviousArguments previousArguments, String s) {
|
||||||
Trace trace = previousArguments.getFirst(Trace.class).orElse(null);
|
Trace trace = previousArguments.getFirst(Trace.class).orElse(null);
|
||||||
if (trace == null) return null;
|
if (trace == null) return null;
|
||||||
|
|
||||||
return trace.getUsedIds();
|
return trace.getUsedIds();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -170,20 +166,22 @@ public class TraceCommand extends SWCommand {
|
|||||||
|
|
||||||
@ClassMapper(value = BundleFilter.class, local = true)
|
@ClassMapper(value = BundleFilter.class, local = true)
|
||||||
public TypeMapper<BundleFilter> bundleFilterClassMapper() {
|
public TypeMapper<BundleFilter> bundleFilterClassMapper() {
|
||||||
return new TypeMapper<BundleFilter>() {
|
return new TypeMapper<>() {
|
||||||
@Override
|
@Override
|
||||||
public BundleFilter map(CommandSender commandSender, String[] previousArguments, String s) {
|
public BundleFilter map(CommandSender commandSender, String[] previousArguments, String s) {
|
||||||
for (BundleFilter filter : BundleFilter.values()) {
|
for (BundleFilter filter : BundleFilter.values()) {
|
||||||
if (s.equals(filter.toString()))
|
if (s.equals(filter.toString())) {
|
||||||
return filter;
|
return filter;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Collection<String> tabCompletes(CommandSender sender, PreviousArguments previousArguments, String s) {
|
public Collection<String> tabCompletes(CommandSender sender, PreviousArguments previousArguments, String s) {
|
||||||
if(s.length() == 0)
|
if (s.length() == 0) {
|
||||||
return new ArrayList<>();
|
return new ArrayList<>();
|
||||||
|
}
|
||||||
|
|
||||||
return Arrays.stream(BundleFilter.values())
|
return Arrays.stream(BundleFilter.values())
|
||||||
.map(Enum::toString)
|
.map(Enum::toString)
|
||||||
@ -198,15 +196,19 @@ public class TraceCommand extends SWCommand {
|
|||||||
@Override
|
@Override
|
||||||
public ViewFlag map(CommandSender commandSender, String[] previousArguments, String s) {
|
public ViewFlag map(CommandSender commandSender, String[] previousArguments, String s) {
|
||||||
for (ViewFlag flag : ViewFlag.flags) {
|
for (ViewFlag flag : ViewFlag.flags) {
|
||||||
if (s.equals("--" + flag.name))
|
if (s.equals("--" + flag.name)) {
|
||||||
return flag;
|
return flag;
|
||||||
|
}
|
||||||
|
|
||||||
for(String alias: flag.aliases)
|
for (String alias : flag.aliases) {
|
||||||
if (s.equals("-" + alias))
|
if (s.equals("-" + alias)) {
|
||||||
return flag;
|
return flag;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Collection<String> tabCompletes(CommandSender sender, PreviousArguments previousArguments, String s) {
|
public Collection<String> tabCompletes(CommandSender sender, PreviousArguments previousArguments, String s) {
|
||||||
return ViewFlag.flags.stream()
|
return ViewFlag.flags.stream()
|
||||||
|
@ -24,9 +24,7 @@ import de.steamwar.bausystem.features.tracer.rendering.ViewFlag;
|
|||||||
import de.steamwar.bausystem.region.Region;
|
import de.steamwar.bausystem.region.Region;
|
||||||
import de.steamwar.linkage.Linked;
|
import de.steamwar.linkage.Linked;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.EventHandler;
|
|
||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
import org.bukkit.event.player.PlayerQuitEvent;
|
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
@ -53,44 +51,51 @@ public class TraceManager implements Listener {
|
|||||||
*/
|
*/
|
||||||
private int nextOpenId = 0;
|
private int nextOpenId = 0;
|
||||||
|
|
||||||
/** Adds a new trace to the global record
|
/**
|
||||||
|
* Adds a new trace to the global record
|
||||||
*
|
*
|
||||||
* @param trace Trace to be added
|
* @param trace Trace to be added
|
||||||
* @return id of the created trace
|
* @return id of the created trace
|
||||||
*/
|
*/
|
||||||
protected int add(Trace trace) {
|
protected int add(Trace trace) {
|
||||||
for(Player player: viewFlagMap.keySet())
|
for (Player player : viewFlagMap.keySet()) {
|
||||||
trace.render(player, viewFlagMap.get(player), bundleFilterMap.get(player));
|
trace.render(player, viewFlagMap.get(player), bundleFilterMap.get(player));
|
||||||
|
}
|
||||||
traces.put(nextOpenId, trace);
|
traces.put(nextOpenId, trace);
|
||||||
nextOpenId++;
|
nextOpenId++;
|
||||||
return nextOpenId;
|
return nextOpenId;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Removes the trace with the given id
|
/**
|
||||||
|
* Removes the trace with the given id
|
||||||
*
|
*
|
||||||
* @param id id of the trace to be removed
|
* @param id id of the trace to be removed
|
||||||
*/
|
*/
|
||||||
public boolean remove(int id) {
|
public boolean remove(int id) {
|
||||||
if (id >= nextOpenId) return false;
|
if (id >= nextOpenId) return false;
|
||||||
if (traces.get(id) == null) return false;
|
if (traces.get(id) == null) return false;
|
||||||
for(Player player: viewFlagMap.keySet())
|
for (Player player : viewFlagMap.keySet()) {
|
||||||
traces.get(id).hide(player);
|
traces.get(id).hide(player);
|
||||||
|
}
|
||||||
traces.remove(id);
|
traces.remove(id);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Clears all traces
|
/**
|
||||||
*
|
* Clears all traces
|
||||||
*/
|
*/
|
||||||
public void clear() {
|
public void clear() {
|
||||||
for (Player player: viewFlagMap.keySet())
|
for (Player player : viewFlagMap.keySet()) {
|
||||||
for(Trace trace: traces.values())
|
for (Trace trace : traces.values()) {
|
||||||
trace.hide(player);
|
trace.hide(player);
|
||||||
|
}
|
||||||
|
}
|
||||||
traces.clear();
|
traces.clear();
|
||||||
nextOpenId = 0;
|
nextOpenId = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Methode to get all traces in a certain region
|
/**
|
||||||
|
* Methode to get all traces in a certain region
|
||||||
*
|
*
|
||||||
* @param region Region to look for traces in
|
* @param region Region to look for traces in
|
||||||
* @return All traces recorded in the given Region
|
* @return All traces recorded in the given Region
|
||||||
@ -101,18 +106,21 @@ public class TraceManager implements Listener {
|
|||||||
.collect(Collectors.toSet());
|
.collect(Collectors.toSet());
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Methode to get the trace with specific id
|
/**
|
||||||
|
* Methode to get the trace with specific id
|
||||||
*
|
*
|
||||||
* @param index index of the trace
|
* @param index index of the trace
|
||||||
* @return the trace with given id or null if no trace with id is found
|
* @return the trace with given id or null if no trace with id is found
|
||||||
*/
|
*/
|
||||||
public Optional<Trace> get(int index) {
|
public Optional<Trace> get(int index) {
|
||||||
if(index < traces.size())
|
if (index < traces.size()) {
|
||||||
return Optional.of(traces.get(index));
|
return Optional.of(traces.get(index));
|
||||||
|
}
|
||||||
return Optional.empty();
|
return Optional.empty();
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Methode to get all traces
|
/**
|
||||||
|
* Methode to get all traces
|
||||||
*
|
*
|
||||||
* @return fresh list of all current traces
|
* @return fresh list of all current traces
|
||||||
*/
|
*/
|
||||||
@ -123,9 +131,12 @@ public class TraceManager implements Listener {
|
|||||||
/**
|
/**
|
||||||
* @return all ids of active traces
|
* @return all ids of active traces
|
||||||
*/
|
*/
|
||||||
public Set<Integer> getAllIds(){return traces.keySet();}
|
public Set<Integer> getAllIds() {
|
||||||
|
return traces.keySet();
|
||||||
|
}
|
||||||
|
|
||||||
/** Toggles trace show on for player
|
/**
|
||||||
|
* Toggles trace show on for player
|
||||||
*
|
*
|
||||||
* @param player
|
* @param player
|
||||||
* @param viewFlags
|
* @param viewFlags
|
||||||
@ -135,17 +146,20 @@ public class TraceManager implements Listener {
|
|||||||
viewFlagMap.put(player, viewFlags);
|
viewFlagMap.put(player, viewFlags);
|
||||||
bundleFilterMap.put(player, bundleFilter);
|
bundleFilterMap.put(player, bundleFilter);
|
||||||
|
|
||||||
for(Trace trace: traces.values())
|
for (Trace trace : traces.values()) {
|
||||||
trace.render(player, viewFlags, bundleFilter);
|
trace.render(player, viewFlags, bundleFilter);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/** Toggles trace show of for player
|
/**
|
||||||
|
* Toggles trace show of for player
|
||||||
*
|
*
|
||||||
* @param player
|
* @param player
|
||||||
*/
|
*/
|
||||||
public void hide(Player player) {
|
public void hide(Player player) {
|
||||||
for(Trace trace: traces.values())
|
for (Trace trace : traces.values()) {
|
||||||
trace.hide(player);
|
trace.hide(player);
|
||||||
|
}
|
||||||
|
|
||||||
viewFlagMap.remove(player);
|
viewFlagMap.remove(player);
|
||||||
bundleFilterMap.remove(player);
|
bundleFilterMap.remove(player);
|
||||||
|
@ -27,9 +27,6 @@ import lombok.Getter;
|
|||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.EventHandler;
|
|
||||||
import org.bukkit.event.Listener;
|
|
||||||
import org.bukkit.event.entity.EntityInteractEvent;
|
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@ -64,7 +61,6 @@ public class TraceEntity extends RFallingBlockEntity {
|
|||||||
public boolean equals(Object object) {
|
public boolean equals(Object object) {
|
||||||
if (!(object instanceof TraceEntity)) return false;
|
if (!(object instanceof TraceEntity)) return false;
|
||||||
TraceEntity entity = (TraceEntity) object;
|
TraceEntity entity = (TraceEntity) object;
|
||||||
|
|
||||||
return records.get(0).equals(entity.getRecords().get(0));
|
return records.get(0).equals(entity.getRecords().get(0));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -50,9 +50,6 @@ public abstract class ViewFlag {
|
|||||||
.filter(TNTRecord::isExplosion)
|
.filter(TNTRecord::isExplosion)
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void modify(REntityServer server, List<TraceEntity> entities) {}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
public static ViewFlag IGNITE = new ViewFlag(true, true, "ignite", "i") {
|
public static ViewFlag IGNITE = new ViewFlag(true, true, "ignite", "i") {
|
||||||
@ -62,9 +59,6 @@ public abstract class ViewFlag {
|
|||||||
.filter(record -> !record.isAfterFirstExplosion())
|
.filter(record -> !record.isAfterFirstExplosion())
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void modify(REntityServer server, List<TraceEntity> entities) {}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
public static ViewFlag SOURCE = new ViewFlag(true, false, IGNITE, "source", "s") {
|
public static ViewFlag SOURCE = new ViewFlag(true, false, IGNITE, "source", "s") {
|
||||||
@ -74,9 +68,6 @@ public abstract class ViewFlag {
|
|||||||
.filter(record -> record.getFuse() == 80)
|
.filter(record -> record.getFuse() == 80)
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void modify(REntityServer server, List<TraceEntity> entities) {}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
public static ViewFlag BUILD_DESTROY_ONLY = new ViewFlag(true, false, "build-destroy-only") {
|
public static ViewFlag BUILD_DESTROY_ONLY = new ViewFlag(true, false, "build-destroy-only") {
|
||||||
@ -86,9 +77,6 @@ public abstract class ViewFlag {
|
|||||||
.filter(record -> record.getHistory().get(record.getHistory().size() - 1).isDestroyedBuildArea())
|
.filter(record -> record.getHistory().get(record.getHistory().size() - 1).isDestroyedBuildArea())
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void modify(REntityServer server, List<TraceEntity> entities) {}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
public static ViewFlag TESTBLOCK_DESTROY_ONLY = new ViewFlag(true, false, "testblock-destroy-only") {
|
public static ViewFlag TESTBLOCK_DESTROY_ONLY = new ViewFlag(true, false, "testblock-destroy-only") {
|
||||||
@ -98,9 +86,6 @@ public abstract class ViewFlag {
|
|||||||
.filter(record -> record.getHistory().get(record.getHistory().size() - 1).isDestroyedTestBlock())
|
.filter(record -> record.getHistory().get(record.getHistory().size() - 1).isDestroyedTestBlock())
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void modify(REntityServer server, List<TraceEntity> entities) {}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
public static ViewFlag MICROMOTION = new ViewFlag(true, false, "micromotion", "m") {
|
public static ViewFlag MICROMOTION = new ViewFlag(true, false, "micromotion", "m") {
|
||||||
@ -133,15 +118,9 @@ public abstract class ViewFlag {
|
|||||||
|
|
||||||
return records;
|
return records;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void modify(REntityServer server, List<TraceEntity> entities) {}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
public static ViewFlag ADVANCED = new ViewFlag(true, false, "advanced", "a") {
|
public static ViewFlag ADVANCED = new ViewFlag(true, false, "advanced", "a") {
|
||||||
@Override
|
|
||||||
public List<TNTRecord> filter(List<TNTRecord> records) {return records;}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void modify(REntityServer server, List<TraceEntity> entities) {
|
public void modify(REntityServer server, List<TraceEntity> entities) {
|
||||||
for (TraceEntity entity : entities) {
|
for (TraceEntity entity : entities) {
|
||||||
@ -172,9 +151,6 @@ public abstract class ViewFlag {
|
|||||||
};
|
};
|
||||||
|
|
||||||
public static ViewFlag COUNT = new ViewFlag(true, false, "count", "c") {
|
public static ViewFlag COUNT = new ViewFlag(true, false, "count", "c") {
|
||||||
@Override
|
|
||||||
public List<TNTRecord> filter(List<TNTRecord> records) { return records; }
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void modify(REntityServer server, List<TraceEntity> entities) {
|
public void modify(REntityServer server, List<TraceEntity> entities) {
|
||||||
for (TraceEntity entity : entities) {
|
for (TraceEntity entity : entities) {
|
||||||
@ -184,9 +160,6 @@ public abstract class ViewFlag {
|
|||||||
};
|
};
|
||||||
|
|
||||||
public static ViewFlag FUSE = new ViewFlag(true, false, "fuse", "f") {
|
public static ViewFlag FUSE = new ViewFlag(true, false, "fuse", "f") {
|
||||||
@Override
|
|
||||||
public List<TNTRecord> filter(List<TNTRecord> records) { return records; }
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void modify(REntityServer server, List<TraceEntity> entities) {
|
public void modify(REntityServer server, List<TraceEntity> entities) {
|
||||||
for (TraceEntity entity : entities) {
|
for (TraceEntity entity : entities) {
|
||||||
@ -196,9 +169,6 @@ public abstract class ViewFlag {
|
|||||||
};
|
};
|
||||||
|
|
||||||
public static ViewFlag TIME = new ViewFlag(true, false, "time", "t") {
|
public static ViewFlag TIME = new ViewFlag(true, false, "time", "t") {
|
||||||
@Override
|
|
||||||
public List<TNTRecord> filter(List<TNTRecord> records) { return records; }
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void modify(REntityServer server, List<TraceEntity> entities) {
|
public void modify(REntityServer server, List<TraceEntity> entities) {
|
||||||
for (TraceEntity entity : entities) {
|
for (TraceEntity entity : entities) {
|
||||||
@ -222,15 +192,15 @@ public abstract class ViewFlag {
|
|||||||
*/
|
*/
|
||||||
public final ViewFlag[] required;
|
public final ViewFlag[] required;
|
||||||
|
|
||||||
public ViewFlag(boolean isStatic, boolean isInverse, String name, String... aliases) {
|
protected ViewFlag(boolean isStatic, boolean isInverse, String name, String... aliases) {
|
||||||
this(isStatic, isInverse, new ViewFlag[0], name, aliases);
|
this(isStatic, isInverse, new ViewFlag[0], name, aliases);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ViewFlag(boolean isStatic, boolean isInverse, ViewFlag required, String name, String... aliases) {
|
protected ViewFlag(boolean isStatic, boolean isInverse, ViewFlag required, String name, String... aliases) {
|
||||||
this(isStatic, isInverse, new ViewFlag[]{required}, name, aliases);
|
this(isStatic, isInverse, new ViewFlag[]{required}, name, aliases);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ViewFlag(boolean isStatic, boolean isInverse, ViewFlag[] required, String name, String... aliases){
|
protected ViewFlag(boolean isStatic, boolean isInverse, ViewFlag[] required, String name, String... aliases) {
|
||||||
this.name = name;
|
this.name = name;
|
||||||
this.aliases = aliases;
|
this.aliases = aliases;
|
||||||
if (isStatic) flags.add(this);
|
if (isStatic) flags.add(this);
|
||||||
@ -238,17 +208,22 @@ public abstract class ViewFlag {
|
|||||||
this.required = required;
|
this.required = required;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Filters the given records for a given condition
|
/**
|
||||||
|
* Filters the given records for a given condition
|
||||||
*
|
*
|
||||||
* @param records Records to be filtered
|
* @param records Records to be filtered
|
||||||
* @return Filtered records
|
* @return Filtered records
|
||||||
*/
|
*/
|
||||||
public abstract List<TNTRecord> filter (List<TNTRecord> records);
|
public List<TNTRecord> filter(List<TNTRecord> records) {
|
||||||
|
return records;
|
||||||
|
}
|
||||||
|
|
||||||
/** Modifies the trace rendering
|
/**
|
||||||
|
* Modifies the trace rendering
|
||||||
*
|
*
|
||||||
* @param server the server the trace is rendered on
|
* @param server the server the trace is rendered on
|
||||||
* @param entities the entities representing tnts
|
* @param entities the entities representing tnts
|
||||||
*/
|
*/
|
||||||
public abstract void modify (REntityServer server, List<TraceEntity> entities);
|
public void modify(REntityServer server, List<TraceEntity> entities) {
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -17,12 +17,10 @@
|
|||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package de.steamwar.bausystem.features.tracer.rendering.dynamicFlags;
|
package de.steamwar.bausystem.features.tracer.rendering.dynamicflags;
|
||||||
|
|
||||||
import de.steamwar.bausystem.features.tracer.TNTRecord;
|
import de.steamwar.bausystem.features.tracer.TNTRecord;
|
||||||
import de.steamwar.bausystem.features.tracer.rendering.TraceEntity;
|
|
||||||
import de.steamwar.bausystem.features.tracer.rendering.ViewFlag;
|
import de.steamwar.bausystem.features.tracer.rendering.ViewFlag;
|
||||||
import de.steamwar.entity.REntityServer;
|
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
@ -31,14 +29,14 @@ public class AtFlag extends ViewFlag {
|
|||||||
private int start;
|
private int start;
|
||||||
private int end;
|
private int end;
|
||||||
|
|
||||||
|
|
||||||
public AtFlag(int start, int end) {
|
public AtFlag(int start, int end) {
|
||||||
super(false, false, ViewFlag.IGNITE, null);
|
super(false, false, ViewFlag.IGNITE, null);
|
||||||
this.start = start;
|
this.start = start;
|
||||||
this.end = end;
|
this.end = end;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Update this flag to represent another time interval
|
/**
|
||||||
|
* Update this flag to represent another time interval
|
||||||
*
|
*
|
||||||
* @param start new interval start
|
* @param start new interval start
|
||||||
* @param end new interval end
|
* @param end new interval end
|
||||||
@ -54,7 +52,4 @@ public class AtFlag extends ViewFlag {
|
|||||||
.filter(record -> record.getTicksSinceStart() <= start && record.getTicksSinceStart() >= end)
|
.filter(record -> record.getTicksSinceStart() <= start && record.getTicksSinceStart() >= end)
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void modify(REntityServer server, List<TraceEntity> entities) {}
|
|
||||||
}
|
}
|
@ -17,14 +17,11 @@
|
|||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package de.steamwar.bausystem.features.tracer.rendering.dynamicFlags;
|
package de.steamwar.bausystem.features.tracer.rendering.dynamicflags;
|
||||||
|
|
||||||
import de.steamwar.bausystem.features.tracer.TNTRecord;
|
import de.steamwar.bausystem.features.tracer.TNTRecord;
|
||||||
import de.steamwar.bausystem.features.tracer.rendering.TraceEntity;
|
|
||||||
import de.steamwar.bausystem.features.tracer.rendering.ViewFlag;
|
import de.steamwar.bausystem.features.tracer.rendering.ViewFlag;
|
||||||
import de.steamwar.entity.REntityServer;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
@ -43,6 +40,7 @@ public class IsolateFlag extends ViewFlag {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Toggles the given id to be or not to be rendered
|
* Toggles the given id to be or not to be rendered
|
||||||
|
*
|
||||||
* @param id
|
* @param id
|
||||||
*/
|
*/
|
||||||
public void toggleId(int id) {
|
public void toggleId(int id) {
|
||||||
@ -57,7 +55,4 @@ public class IsolateFlag extends ViewFlag {
|
|||||||
.filter(record -> tntToIsolate.contains(record.getTntId()))
|
.filter(record -> tntToIsolate.contains(record.getTntId()))
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void modify(REntityServer server, List<TraceEntity> entities) {}
|
|
||||||
}
|
}
|
In neuem Issue referenzieren
Einen Benutzer sperren