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<>();
|
||||||
|
|
||||||
@ -78,41 +78,44 @@ public class Recorder implements Listener {
|
|||||||
*/
|
*/
|
||||||
private final Set<Region> autoTraceRegions = new HashSet<>();
|
private final Set<Region> autoTraceRegions = new HashSet<>();
|
||||||
|
|
||||||
public Recorder(){
|
public Recorder() {
|
||||||
BauSystem.runTaskTimer(BauSystem.getInstance(), () -> {
|
BauSystem.runTaskTimer(BauSystem.getInstance(), () -> {
|
||||||
record();
|
record();
|
||||||
checkForAutoTraceFinish();
|
checkForAutoTraceFinish();
|
||||||
}, 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) {
|
||||||
if (autoTraceRegions.contains(region) && trackedTNT.getOrDefault(region, Collections.emptyList()).size() == 0) {
|
if (autoTraceRegions.contains(region) && trackedTNT.getOrDefault(region, Collections.emptyList()).size() == 0) {
|
||||||
stopRecording(region);
|
stopRecording(region);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 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
|
||||||
*/
|
*/
|
||||||
public int startRecording(Region region){
|
public int startRecording(Region region) {
|
||||||
if(activeTraces.containsKey(region)) return -1;
|
if (activeTraces.containsKey(region)) return -1;
|
||||||
Trace trace = new Trace(region);
|
Trace trace = new Trace(region);
|
||||||
noExplosionRecorded.add(trace);
|
noExplosionRecorded.add(trace);
|
||||||
activeTraces.put(region, trace);
|
activeTraces.put(region, trace);
|
||||||
@ -120,32 +123,34 @@ 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
|
||||||
*/
|
*/
|
||||||
public void stopRecording(Region region){
|
public void stopRecording(Region region) {
|
||||||
Trace trace = activeTraces.getOrDefault(region, null);
|
Trace trace = activeTraces.getOrDefault(region, null);
|
||||||
if (trace == null) return;
|
if (trace == null) return;
|
||||||
trace.setRecords(Collections.unmodifiableList(trace.getRecords()));
|
trace.setRecords(Collections.unmodifiableList(trace.getRecords()));
|
||||||
|
|
||||||
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()) {
|
||||||
Trace trace = activeTraces.get(region);
|
Trace trace = activeTraces.get(region);
|
||||||
|
|
||||||
for(TNTPrimed tnt : trackedTNT.getOrDefault(region, Collections.emptyList())){
|
for (TNTPrimed tnt : trackedTNT.getOrDefault(region, Collections.emptyList())) {
|
||||||
record(tnt, trace, Collections.emptyList());
|
record(tnt, trace, Collections.emptyList());
|
||||||
}
|
}
|
||||||
trace.addAll(recordsToAddMap.get(trace));
|
trace.addAll(recordsToAddMap.get(trace));
|
||||||
@ -153,25 +158,27 @@ 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
|
||||||
*/
|
*/
|
||||||
private void record(TNTPrimed tntPrimed, Trace trace, List<Block> destroyedBlocks){
|
private void record(TNTPrimed tntPrimed, Trace trace, List<Block> destroyedBlocks) {
|
||||||
List<TNTRecord> history = historyMap.getOrDefault(tntPrimed, new ArrayList<>());
|
List<TNTRecord> history = historyMap.getOrDefault(tntPrimed, new ArrayList<>());
|
||||||
int tntID;
|
int tntID;
|
||||||
|
|
||||||
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,23 +187,27 @@ 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)
|
||||||
public void onTNTSpawn(EntitySpawnEvent event){
|
public void onTNTSpawn(EntitySpawnEvent event) {
|
||||||
if(!(event.getEntity() instanceof TNTPrimed)) return;
|
if (!(event.getEntity() instanceof TNTPrimed)) return;
|
||||||
|
|
||||||
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,16 +215,18 @@ 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)
|
||||||
public void onTNTExplode(EntityExplodeEvent event){
|
public void onTNTExplode(EntityExplodeEvent event) {
|
||||||
if(!(event.getEntity() instanceof TNTPrimed)) return;
|
if (!(event.getEntity() instanceof TNTPrimed)) return;
|
||||||
|
|
||||||
Region region = tntSpawnRegion.getOrDefault((TNTPrimed) event.getEntity(), null);
|
Region region = tntSpawnRegion.getOrDefault((TNTPrimed) event.getEntity(), null);
|
||||||
if(region == null) return;
|
if (region == null) return;
|
||||||
trackedTNT.get(region).remove((TNTPrimed) event.getEntity());
|
trackedTNT.get(region).remove((TNTPrimed) event.getEntity());
|
||||||
tntSpawnRegion.remove((TNTPrimed) event.getEntity());
|
tntSpawnRegion.remove((TNTPrimed) event.getEntity());
|
||||||
|
|
||||||
|
@ -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 {
|
||||||
@ -90,7 +89,7 @@ public class TNTRecord {
|
|||||||
*/
|
*/
|
||||||
private final List<TNTRecord> history;
|
private final List<TNTRecord> history;
|
||||||
|
|
||||||
public TNTRecord(int tntId, TNTPrimed tnt, boolean explosion, boolean afterFirstExplosion, long ticksSinceStart, List<TNTRecord> history, List<Block> destroyedBlocks){
|
public TNTRecord(int tntId, TNTPrimed tnt, boolean explosion, boolean afterFirstExplosion, long ticksSinceStart, List<TNTRecord> history, List<Block> destroyedBlocks) {
|
||||||
this.tntId = tntId;
|
this.tntId = tntId;
|
||||||
this.explosion = explosion;
|
this.explosion = explosion;
|
||||||
this.inWater = tnt.isInWater();
|
this.inWater = tnt.isInWater();
|
||||||
@ -103,26 +102,26 @@ 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;
|
||||||
}
|
}
|
||||||
|
|
||||||
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));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -139,12 +138,11 @@ public class TNTRecord {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
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;
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -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;
|
||||||
@ -79,15 +79,16 @@ public class Trace {
|
|||||||
*/
|
*/
|
||||||
private final Map<Player, ViewFlag[]> viewFlagMap = new HashMap<>();
|
private final Map<Player, ViewFlag[]> viewFlagMap = new HashMap<>();
|
||||||
|
|
||||||
public Trace (Region region){
|
public Trace(Region region) {
|
||||||
this.region = region;
|
this.region = region;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 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() {
|
||||||
nextOpenRecordId++;
|
nextOpenRecordId++;
|
||||||
usedIds.add(Integer.toString(nextOpenRecordId));
|
usedIds.add(Integer.toString(nextOpenRecordId));
|
||||||
return nextOpenRecordId;
|
return nextOpenRecordId;
|
||||||
@ -96,10 +97,10 @@ public class Trace {
|
|||||||
/**
|
/**
|
||||||
* Adds the given records and updates potential trace renderings
|
* Adds the given records and updates potential trace renderings
|
||||||
*/
|
*/
|
||||||
protected void addAll(List<TNTRecord> records){
|
protected void addAll(List<TNTRecord> records) {
|
||||||
this.records.addAll(records);
|
this.records.addAll(records);
|
||||||
|
|
||||||
for(Player player: serverMap.keySet()){
|
for (Player player : serverMap.keySet()) {
|
||||||
REntityServer server = serverMap.get(player);
|
REntityServer server = serverMap.get(player);
|
||||||
BundleFilter bundleFilter = bundleFilterMap.get(player);
|
BundleFilter bundleFilter = bundleFilterMap.get(player);
|
||||||
ViewFlag[] viewFlags = viewFlagMap.get(player);
|
ViewFlag[] viewFlags = viewFlagMap.get(player);
|
||||||
@ -108,36 +109,39 @@ 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
|
||||||
*/
|
*/
|
||||||
protected void setRecords(List<TNTRecord> records){
|
protected void setRecords(List<TNTRecord> records) {
|
||||||
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
|
||||||
*/
|
*/
|
||||||
public Set<List<TNTRecord>> getHistories() {
|
public Set<List<TNTRecord>> getHistories() {
|
||||||
Set<List<TNTRecord>> histories = new HashSet<>();
|
Set<List<TNTRecord>> histories = new HashSet<>();
|
||||||
|
|
||||||
for(TNTRecord record: records) {
|
for (TNTRecord record : records) {
|
||||||
histories.add(record.getHistory());
|
histories.add(record.getHistory());
|
||||||
}
|
}
|
||||||
|
|
||||||
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
|
||||||
* @param bundleFilter Filter to determin bundeling of records
|
* @param bundleFilter Filter to determin bundeling of records
|
||||||
*/
|
*/
|
||||||
public void render(Player player, ViewFlag[] flags, BundleFilter bundleFilter){
|
public void render(Player player, ViewFlag[] flags, BundleFilter bundleFilter) {
|
||||||
if(serverMap.containsKey(player)){
|
if (serverMap.containsKey(player)) {
|
||||||
REntityServer server = serverMap.get(player);
|
REntityServer server = serverMap.get(player);
|
||||||
server.close();
|
server.close();
|
||||||
|
|
||||||
@ -156,15 +160,16 @@ 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
|
||||||
* @param flags Flags modefieing the rendering
|
* @param flags Flags modefieing the rendering
|
||||||
* @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;
|
||||||
|
|
||||||
@ -184,7 +189,7 @@ public class Trace {
|
|||||||
});
|
});
|
||||||
|
|
||||||
//Apply filters
|
//Apply filters
|
||||||
for(ViewFlag flag : flagList) {
|
for (ViewFlag flag : flagList) {
|
||||||
workingRecords = flag.filter(workingRecords);
|
workingRecords = flag.filter(workingRecords);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -194,18 +199,18 @@ public class Trace {
|
|||||||
//Render bundled records
|
//Render bundled records
|
||||||
List<TraceEntity> entities = new LinkedList<>();
|
List<TraceEntity> entities = new LinkedList<>();
|
||||||
|
|
||||||
for(List<TNTRecord> bundle : bundles) {
|
for (List<TNTRecord> bundle : bundles) {
|
||||||
entities.add(new TraceEntity(server, bundle.get(0).getLocation(), bundle.get(0).isExplosion(), bundle));
|
entities.add(new TraceEntity(server, bundle.get(0).getLocation(), bundle.get(0).isExplosion(), bundle));
|
||||||
}
|
}
|
||||||
|
|
||||||
//Apply modifiers
|
//Apply modifiers
|
||||||
for(ViewFlag flag : flags) {
|
for (ViewFlag flag : flags) {
|
||||||
flag.modify(server, entities);
|
flag.modify(server, entities);
|
||||||
}
|
}
|
||||||
|
|
||||||
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,23 +218,24 @@ 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
|
||||||
*/
|
*/
|
||||||
private List<List<TNTRecord>> bundleRecords(List<TNTRecord> records, BundleFilter filter){
|
private List<List<TNTRecord>> bundleRecords(List<TNTRecord> records, BundleFilter filter) {
|
||||||
List<List<TNTRecord>> bundles = new ArrayList<>();
|
List<List<TNTRecord>> bundles = new ArrayList<>();
|
||||||
|
|
||||||
recordsLoop:
|
recordsLoop:
|
||||||
for (TNTRecord record : records) {
|
for (TNTRecord record : records) {
|
||||||
if(bundles.isEmpty()){
|
if (bundles.isEmpty()) {
|
||||||
List<TNTRecord> firstBundle = new ArrayList<>();
|
List<TNTRecord> firstBundle = new ArrayList<>();
|
||||||
firstBundle.add(record);
|
firstBundle.add(record);
|
||||||
bundles.add(firstBundle);
|
bundles.add(firstBundle);
|
||||||
}
|
}
|
||||||
|
|
||||||
for(int i = bundles.size() - 1; i >= 0; i--){
|
for (int i = bundles.size() - 1; i >= 0; i--) {
|
||||||
List<TNTRecord> bundle = bundles.get(i);
|
List<TNTRecord> bundle = bundles.get(i);
|
||||||
|
|
||||||
Boolean filterResult = filter.function.apply(record, bundle.get(0));
|
Boolean filterResult = filter.function.apply(record, bundle.get(0));
|
||||||
@ -248,15 +254,16 @@ 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
|
||||||
* @param to end of time interval
|
* @param to end of time interval
|
||||||
*/
|
*/
|
||||||
public void renderAt(Player player, int from, int to){
|
public void renderAt(Player player, int from, int to) {
|
||||||
ViewFlag[] viewFlags = viewFlagMap.get(player);
|
ViewFlag[] viewFlags = viewFlagMap.get(player);
|
||||||
if(viewFlags == null) return;
|
if (viewFlags == null) return;
|
||||||
|
|
||||||
AtFlag atFlag = null;
|
AtFlag atFlag = null;
|
||||||
atFlag = Stream.of(viewFlags)
|
atFlag = Stream.of(viewFlags)
|
||||||
@ -265,10 +272,9 @@ public class Trace {
|
|||||||
.findFirst()
|
.findFirst()
|
||||||
.orElse(null);
|
.orElse(null);
|
||||||
|
|
||||||
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,16 +283,17 @@ 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
|
||||||
*/
|
*/
|
||||||
public void isolate(Player player, TNTRecord... records){
|
public void isolate(Player player, TNTRecord... records) {
|
||||||
IsolateFlag isolationFlag = null;
|
IsolateFlag isolationFlag = null;
|
||||||
|
|
||||||
ViewFlag[] viewFlags = viewFlagMap.get(player);
|
ViewFlag[] viewFlags = viewFlagMap.get(player);
|
||||||
if(viewFlags != null) {
|
if (viewFlags != null) {
|
||||||
isolationFlag = Stream.of(viewFlags)
|
isolationFlag = Stream.of(viewFlags)
|
||||||
.filter(IsolateFlag.class::isInstance)
|
.filter(IsolateFlag.class::isInstance)
|
||||||
.map(IsolateFlag.class::cast)
|
.map(IsolateFlag.class::cast)
|
||||||
@ -302,46 +309,50 @@ 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
|
||||||
*/
|
*/
|
||||||
public void follow(Player player, Player toFollow){
|
public void follow(Player player, Player toFollow) {
|
||||||
for(REntityServer server :serverMap.values()){
|
for (REntityServer server : serverMap.values()) {
|
||||||
server.removePlayer(player);
|
server.removePlayer(player);
|
||||||
}
|
}
|
||||||
|
|
||||||
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
|
||||||
*/
|
*/
|
||||||
public void unfollow(Player player){
|
public void unfollow(Player player) {
|
||||||
for(REntityServer server :serverMap.values()){
|
for (REntityServer server : serverMap.values()) {
|
||||||
server.removePlayer(player);
|
server.removePlayer(player);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(serverMap.get(player) != null){
|
if (serverMap.get(player) != null) {
|
||||||
serverMap.get(player).addPlayer(player);
|
serverMap.get(player).addPlayer(player);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Hides this trail for the given player
|
/**
|
||||||
|
* Hides this trail for the given player
|
||||||
*
|
*
|
||||||
* @param player
|
* @param player
|
||||||
*/
|
*/
|
||||||
public void hide(Player player){
|
public void hide(Player player) {
|
||||||
REntityServer server = serverMap.get(player);
|
REntityServer server = serverMap.get(player);
|
||||||
if(server == null) return;
|
if (server == null) return;
|
||||||
|
|
||||||
bundleFilterMap.remove(player);
|
bundleFilterMap.remove(player);
|
||||||
viewFlagMap.remove(player);
|
viewFlagMap.remove(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,96 +44,96 @@ 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")
|
|
||||||
public void share(Player player){
|
@Register(value = "share", description = "TRACE_COMMAND_HELP_SHOW")
|
||||||
|
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@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()
|
||||||
@ -161,8 +158,7 @@ public class TraceCommand extends SWCommand {
|
|||||||
@Override
|
@Override
|
||||||
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)
|
||||||
@ -193,20 +191,24 @@ public class TraceCommand extends SWCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@ClassMapper(value = ViewFlag.class, local = true)
|
@ClassMapper(value = ViewFlag.class, local = true)
|
||||||
public TypeMapper<ViewFlag> viewFlagClassMapper () {
|
public TypeMapper<ViewFlag> viewFlagClassMapper() {
|
||||||
return new TypeMapper<ViewFlag>() {
|
return new TypeMapper<ViewFlag>() {
|
||||||
@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,79 +51,92 @@ 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
|
||||||
*/
|
*/
|
||||||
public Set<Trace> get(Region region){
|
public Set<Trace> get(Region region) {
|
||||||
return traces.values().stream()
|
return traces.values().stream()
|
||||||
.filter((Trace trace) -> trace.getRegion() == region)
|
.filter((Trace trace) -> trace.getRegion() == region)
|
||||||
.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
|
||||||
*/
|
*/
|
||||||
public List<Trace> getAll(){
|
public List<Trace> getAll() {
|
||||||
return new ArrayList<>(traces.values());
|
return new ArrayList<>(traces.values());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @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;
|
||||||
|
|
||||||
@ -47,7 +44,7 @@ public class TraceEntity extends RFallingBlockEntity {
|
|||||||
this.records = records;
|
this.records = records;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void printIntoChat(Player player){
|
public void printIntoChat(Player player) {
|
||||||
TNTRecord representative = records.get(0);
|
TNTRecord representative = records.get(0);
|
||||||
|
|
||||||
BauSystem.MESSAGE.sendPrefixless("TNT_CLICK_HEADER", player);
|
BauSystem.MESSAGE.sendPrefixless("TNT_CLICK_HEADER", player);
|
||||||
@ -62,9 +59,8 @@ public class TraceEntity extends RFallingBlockEntity {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
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));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -43,16 +43,13 @@ public abstract class ViewFlag {
|
|||||||
*/
|
*/
|
||||||
public static final List<ViewFlag> inverseFlags = new ArrayList<>();
|
public static final List<ViewFlag> inverseFlags = new ArrayList<>();
|
||||||
|
|
||||||
public static ViewFlag EXPLOSION = new ViewFlag(true, false,"explosion", "e") {
|
public static ViewFlag EXPLOSION = new ViewFlag(true, false, "explosion", "e") {
|
||||||
@Override
|
@Override
|
||||||
public List<TNTRecord> filter(List<TNTRecord> records) {
|
public List<TNTRecord> filter(List<TNTRecord> records) {
|
||||||
return records.stream()
|
return records.stream()
|
||||||
.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") {
|
||||||
@ -109,44 +94,38 @@ public abstract class ViewFlag {
|
|||||||
Set<Integer> seen = new HashSet<>();
|
Set<Integer> seen = new HashSet<>();
|
||||||
Set<TNTRecord> toRemove = new HashSet<>();
|
Set<TNTRecord> toRemove = new HashSet<>();
|
||||||
|
|
||||||
for(TNTRecord uniqueRecord: records){
|
for (TNTRecord uniqueRecord : records) {
|
||||||
if(seen.contains(uniqueRecord.getTntId())) continue;
|
if (seen.contains(uniqueRecord.getTntId())) continue;
|
||||||
|
|
||||||
boolean hasMicromotion = false;
|
boolean hasMicromotion = false;
|
||||||
for(TNTRecord record: uniqueRecord.getHistory()){
|
for (TNTRecord record : uniqueRecord.getHistory()) {
|
||||||
Vector velocity = record.getVelocity();
|
Vector velocity = record.getVelocity();
|
||||||
if(velocity.getY() == 0 && (Math.abs(velocity.getX()) < 0.001 || Math.abs(velocity.getZ()) < 0.001)){
|
if (velocity.getY() == 0 && (Math.abs(velocity.getX()) < 0.001 || Math.abs(velocity.getZ()) < 0.001)) {
|
||||||
hasMicromotion = true;
|
hasMicromotion = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!hasMicromotion)
|
if (!hasMicromotion)
|
||||||
toRemove.add(uniqueRecord);
|
toRemove.add(uniqueRecord);
|
||||||
|
|
||||||
seen.add(uniqueRecord.getTntId());
|
seen.add(uniqueRecord.getTntId());
|
||||||
}
|
}
|
||||||
|
|
||||||
for(TNTRecord record: toRemove){
|
for (TNTRecord record : toRemove) {
|
||||||
records.removeAll(record.getHistory());
|
records.removeAll(record.getHistory());
|
||||||
}
|
}
|
||||||
|
|
||||||
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) {
|
||||||
TNTRecord current = entity.getRecords().get(0);
|
TNTRecord current = entity.getRecords().get(0);
|
||||||
if(current.isExplosion()) continue;
|
if (current.isExplosion()) continue;
|
||||||
TNTRecord next = current.getNext().orElse(null);
|
TNTRecord next = current.getNext().orElse(null);
|
||||||
if (next == null) continue;
|
if (next == null) continue;
|
||||||
|
|
||||||
@ -172,36 +151,27 @@ 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) {
|
||||||
entity.setDisplayName(String.valueOf(entity.getRecords().size()));
|
entity.setDisplayName(String.valueOf(entity.getRecords().size()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
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) {
|
||||||
entity.setDisplayName(String.valueOf(entity.getRecords().get(0).getFuse()));
|
entity.setDisplayName(String.valueOf(entity.getRecords().get(0).getFuse()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
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) {
|
||||||
entity.setDisplayName(String.valueOf(entity.getRecords().get(0).getTicksSinceStart()));
|
entity.setDisplayName(String.valueOf(entity.getRecords().get(0).getTicksSinceStart()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -222,33 +192,38 @@ 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);
|
||||||
if(isInverse) inverseFlags.add(this);
|
if (isInverse) inverseFlags.add(this);
|
||||||
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,19 +29,19 @@ 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
|
||||||
*/
|
*/
|
||||||
public void update(int start, int end){
|
public void update(int start, int end) {
|
||||||
this.start = start;
|
this.start = start;
|
||||||
this.end = end;
|
this.end = 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;
|
||||||
@ -37,15 +34,16 @@ public class IsolateFlag extends ViewFlag {
|
|||||||
*/
|
*/
|
||||||
private final Set<Integer> tntToIsolate = new HashSet<>();
|
private final Set<Integer> tntToIsolate = new HashSet<>();
|
||||||
|
|
||||||
public IsolateFlag(){
|
public IsolateFlag() {
|
||||||
super(false, false, ViewFlag.IGNITE, null);
|
super(false, false, ViewFlag.IGNITE, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 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) {
|
||||||
if (!tntToIsolate.remove(id)) {
|
if (!tntToIsolate.remove(id)) {
|
||||||
tntToIsolate.add(id);
|
tntToIsolate.add(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