Dieser Commit ist enthalten in:
Ursprung
207826ae8a
Commit
e64c50b566
@ -53,8 +53,8 @@ public class Recorder implements Listener {
|
||||
*/
|
||||
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<>();
|
||||
|
||||
@ -85,19 +85,21 @@ public class Recorder implements Listener {
|
||||
}, 0, 1);
|
||||
}
|
||||
|
||||
/** Toggles auto trace for the given region
|
||||
/**
|
||||
* Toggles auto trace for the given region
|
||||
*
|
||||
* @param region
|
||||
*/
|
||||
public void toggleAutoTrace(Region region) {
|
||||
if (autoTraceRegions.contains(region))
|
||||
if (autoTraceRegions.contains(region)) {
|
||||
autoTraceRegions.remove(region);
|
||||
else
|
||||
} else {
|
||||
autoTraceRegions.add(region);
|
||||
}
|
||||
}
|
||||
|
||||
/** Makes checks for whether auto traces finished
|
||||
*
|
||||
/**
|
||||
* Makes checks for whether auto traces finished
|
||||
*/
|
||||
public void checkForAutoTraceFinish() {
|
||||
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
|
||||
*/
|
||||
@ -120,7 +123,8 @@ public class Recorder implements Listener {
|
||||
return manager.add(trace);
|
||||
}
|
||||
|
||||
/** Stops the recording at the given region
|
||||
/**
|
||||
* Stops the recording at the given region
|
||||
*
|
||||
* @param region region to stop recording
|
||||
*/
|
||||
@ -131,15 +135,16 @@ public class Recorder implements Listener {
|
||||
|
||||
noExplosionRecorded.remove(trace);
|
||||
activeTraces.remove(region);
|
||||
for(TNTPrimed tnt : trackedTNT.getOrDefault(region, Collections.emptyList()))
|
||||
for (TNTPrimed tnt : trackedTNT.getOrDefault(region, Collections.emptyList())) {
|
||||
historyMap.remove(tnt);
|
||||
}
|
||||
|
||||
recordsToAddMap.remove(trace);
|
||||
trackedTNT.put(region, new ArrayList<>());
|
||||
}
|
||||
|
||||
/** Internal methode to record all tracked TNT Entities
|
||||
*
|
||||
/**
|
||||
* Internal methode to record all tracked TNT Entities
|
||||
*/
|
||||
private void record() {
|
||||
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 trace trace to record the tnt for
|
||||
@ -165,13 +171,14 @@ public class Recorder implements Listener {
|
||||
if (history.size() == 0) {
|
||||
historyMap.put(tntPrimed, history);
|
||||
tntID = trace.getAndIncrementNextOpenRecordId();
|
||||
}
|
||||
else
|
||||
} else {
|
||||
tntID = history.get(0).getTntId();
|
||||
}
|
||||
|
||||
boolean isExplosion = tntPrimed.getFuseTicks() == 0;
|
||||
if(isExplosion)
|
||||
if (isExplosion) {
|
||||
noExplosionRecorded.remove(trace);
|
||||
}
|
||||
boolean afterFirstExplosion = noExplosionRecorded.contains(trace);
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
/** Event for TNTs beeing spawn.
|
||||
/**
|
||||
* Event for TNTs beeing spawn.
|
||||
* Registers newly spawned TNT to be traced if reqired
|
||||
*
|
||||
* @param event
|
||||
*/
|
||||
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
|
||||
@ -190,13 +199,15 @@ public class Recorder implements Listener {
|
||||
|
||||
Region region = Region.getRegion(event.getLocation());
|
||||
|
||||
if(autoTraceRegions.contains(region) && !activeTraces.containsKey(region))
|
||||
if (autoTraceRegions.contains(region) && !activeTraces.containsKey(region)) {
|
||||
startRecording(region);
|
||||
}
|
||||
|
||||
if (activeTraces.containsKey(region)) {
|
||||
// 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.get(region).add((TNTPrimed) event.getEntity());
|
||||
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
|
||||
*
|
||||
* @param event
|
||||
*/
|
||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||
|
@ -30,7 +30,6 @@ import org.bukkit.util.Vector;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.UUID;
|
||||
|
||||
@Getter
|
||||
public class TNTRecord {
|
||||
@ -104,11 +103,13 @@ public class TNTRecord {
|
||||
boolean buildDestroy = false;
|
||||
boolean testblockDestroy = false;
|
||||
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;
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
destroyedBuildArea = buildDestroy;
|
||||
destroyedTestBlock = testblockDestroy;
|
||||
@ -116,13 +117,11 @@ public class TNTRecord {
|
||||
|
||||
public Optional<TNTRecord> getNext() {
|
||||
int index = history.indexOf(this);
|
||||
|
||||
return index == history.size() - 1 ? Optional.empty() : Optional.of(history.get(index + 1));
|
||||
}
|
||||
|
||||
public Optional<TNTRecord> getPrevious() {
|
||||
int index = history.indexOf(this);
|
||||
|
||||
return index == 0 ? Optional.empty() : Optional.of(history.get(index - 1));
|
||||
}
|
||||
|
||||
@ -141,7 +140,6 @@ public class TNTRecord {
|
||||
public boolean equals(Object obj) {
|
||||
if (!(obj instanceof TNTRecord)) return false;
|
||||
TNTRecord record = (TNTRecord) obj;
|
||||
|
||||
if (record.isExplosion() != explosion) return false;
|
||||
if (!record.getLocation().equals(location)) 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.TraceEntity;
|
||||
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.IsolateFlag;
|
||||
import de.steamwar.bausystem.features.tracer.rendering.dynamicflags.AtFlag;
|
||||
import de.steamwar.bausystem.features.tracer.rendering.dynamicflags.IsolateFlag;
|
||||
import de.steamwar.bausystem.region.Region;
|
||||
import de.steamwar.entity.REntityServer;
|
||||
import lombok.Getter;
|
||||
@ -85,6 +85,7 @@ public class Trace {
|
||||
|
||||
/**
|
||||
* Gets and increments the next open record id
|
||||
*
|
||||
* @return next open record id
|
||||
*/
|
||||
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
|
||||
*/
|
||||
@ -116,7 +118,8 @@ public class Trace {
|
||||
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
|
||||
*/
|
||||
@ -130,7 +133,8 @@ public class Trace {
|
||||
return histories;
|
||||
}
|
||||
|
||||
/** Renders this traces
|
||||
/**
|
||||
* Renders this traces
|
||||
*
|
||||
* @param player The player the trace is rendered to
|
||||
* @param flags Flags modefieing the rendering
|
||||
@ -156,7 +160,8 @@ public class Trace {
|
||||
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 records Records to render
|
||||
@ -164,7 +169,7 @@ public class Trace {
|
||||
* @param bundleFilter Filter to determin bundeling of records
|
||||
*/
|
||||
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;
|
||||
|
||||
@ -205,7 +210,7 @@ public class Trace {
|
||||
|
||||
server.setCallback(((player, rEntity, entityAction) -> {
|
||||
for (TraceEntity entity : entities) {
|
||||
if(((TraceEntity) rEntity).equals(entity)){
|
||||
if (rEntity.equals(entity)) {
|
||||
entity.printIntoChat(player);
|
||||
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
|
||||
* @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 from start of time interval
|
||||
@ -267,8 +274,7 @@ public class Trace {
|
||||
|
||||
if (atFlag != null) {
|
||||
atFlag.update(from, to);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
atFlag = new AtFlag(from, to);
|
||||
viewFlags = Arrays.copyOf(viewFlags, viewFlags.length + 1);
|
||||
viewFlags[viewFlags.length - 1] = atFlag;
|
||||
@ -277,7 +283,8 @@ public class Trace {
|
||||
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 records the record for which isolation is toggled
|
||||
@ -302,13 +309,15 @@ public class Trace {
|
||||
}
|
||||
viewFlags[0] = isolationFlag;
|
||||
|
||||
for(TNTRecord record: records)
|
||||
for (TNTRecord record : records) {
|
||||
isolationFlag.toggleId(record.getTntId());
|
||||
}
|
||||
|
||||
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 toFollow
|
||||
@ -321,7 +330,8 @@ public class Trace {
|
||||
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
|
||||
*/
|
||||
@ -335,7 +345,8 @@ public class Trace {
|
||||
}
|
||||
}
|
||||
|
||||
/** Hides this trail for the given player
|
||||
/**
|
||||
* Hides this trail for the given player
|
||||
*
|
||||
* @param player
|
||||
*/
|
||||
|
@ -21,21 +21,19 @@ package de.steamwar.bausystem.features.tracer;
|
||||
|
||||
import de.steamwar.bausystem.BauSystem;
|
||||
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.dynamicFlags.IsolateFlag;
|
||||
import de.steamwar.bausystem.region.Region;
|
||||
import de.steamwar.command.PreviousArguments;
|
||||
import de.steamwar.command.SWCommand;
|
||||
import de.steamwar.command.TypeMapper;
|
||||
import de.steamwar.command.TypeValidator;
|
||||
import de.steamwar.entity.REntityServer;
|
||||
import de.steamwar.linkage.Linked;
|
||||
import de.steamwar.linkage.LinkedInstance;
|
||||
import org.bukkit.command.CommandSender;
|
||||
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.Stream;
|
||||
|
||||
@ -46,75 +44,79 @@ public class TraceCommand extends SWCommand {
|
||||
public Recorder recorder;
|
||||
@LinkedInstance
|
||||
public TraceManager manager;
|
||||
public TraceCommand(){super("trace", "trail");}
|
||||
|
||||
public TraceCommand() {
|
||||
super("trace", "trail");
|
||||
}
|
||||
|
||||
@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());
|
||||
recorder.startRecording(region);
|
||||
BauSystem.MESSAGE.send("TRACE_MESSAGE_START", player);
|
||||
}
|
||||
|
||||
@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());
|
||||
recorder.stopRecording(region);
|
||||
BauSystem.MESSAGE.send("TRACE_MESSAGE_STOP", player);
|
||||
}
|
||||
|
||||
@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());
|
||||
recorder.toggleAutoTrace(region);
|
||||
}
|
||||
|
||||
@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);
|
||||
BauSystem.MESSAGE.send("TRACE_MESSAGE_SHOW", player);
|
||||
}
|
||||
|
||||
@Register(value = "hide", description = "TRACE_COMMAND_HELP_SHOW")
|
||||
public void hide(Player player){
|
||||
public void hide(@Validator Player player) {
|
||||
manager.hide(player);
|
||||
BauSystem.MESSAGE.send("TRACE_MESSAGE_HIDE", player);
|
||||
}
|
||||
|
||||
@Register(value = "delete", description = "TRACE_COMMAND_HELP_SHOW")
|
||||
public void delete(Player player){
|
||||
public void delete(@Validator Player player) {
|
||||
manager.clear();
|
||||
}
|
||||
|
||||
@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);
|
||||
}
|
||||
|
||||
@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);
|
||||
}
|
||||
|
||||
@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()) {
|
||||
trace.renderAt(player, start, end);
|
||||
}
|
||||
}
|
||||
|
||||
@Register(value = "share", description = "TRACE_COMMAND_HELP_SHOW")
|
||||
public void share(Player player){
|
||||
public void share(@Validator Player player) {
|
||||
//TODO Rücksprache
|
||||
}
|
||||
|
||||
@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()) {
|
||||
trace.follow(player, toFollow);
|
||||
}
|
||||
}
|
||||
|
||||
@Register(value = "unfollow", description = "TRACE_COMMAND_HELP_SHOW")
|
||||
public void unfollow(Player player){
|
||||
public void unfollow(@Validator Player player) {
|
||||
for (Trace trace : manager.getAll()) {
|
||||
trace.unfollow(player);
|
||||
}
|
||||
@ -122,20 +124,16 @@ public class TraceCommand extends SWCommand {
|
||||
|
||||
@ClassMapper(value = Trace.class, local = true)
|
||||
public TypeMapper<Trace> traceClassMapper() {
|
||||
return new TypeMapper<Trace>() {
|
||||
return new TypeMapper<>() {
|
||||
@Override
|
||||
public Trace map(CommandSender commandSender, String[] previousArguments, String s) {
|
||||
int id = Integer.parseInt(s);
|
||||
|
||||
Optional<Trace> trace = manager.get(id);
|
||||
|
||||
return trace.orElse(null);
|
||||
return manager.get(Integer.parseInt(s)).orElse(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<String> tabCompletes(CommandSender sender, PreviousArguments previousArguments, String s) {
|
||||
return manager.getAllIds().stream()
|
||||
.map(id -> id.toString())
|
||||
.map(Object::toString)
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
};
|
||||
@ -143,14 +141,13 @@ public class TraceCommand extends SWCommand {
|
||||
|
||||
@ClassMapper(value = TNTRecord.class, local = true)
|
||||
public TypeMapper<TNTRecord> recordMapper() {
|
||||
return new TypeMapper<TNTRecord>() {
|
||||
return new TypeMapper<>() {
|
||||
@Override
|
||||
public TNTRecord map(CommandSender commandSender, PreviousArguments previousArguments, String s) {
|
||||
Trace trace = previousArguments.getFirst(Trace.class).orElse(null);
|
||||
if (trace == null) return null;
|
||||
|
||||
int id = Integer.parseInt(s);
|
||||
|
||||
return trace.getRecords().stream()
|
||||
.filter(record -> record.getTntId() == id)
|
||||
.findFirst()
|
||||
@ -162,7 +159,6 @@ public class TraceCommand extends SWCommand {
|
||||
public Collection<String> tabCompletes(CommandSender sender, PreviousArguments previousArguments, String s) {
|
||||
Trace trace = previousArguments.getFirst(Trace.class).orElse(null);
|
||||
if (trace == null) return null;
|
||||
|
||||
return trace.getUsedIds();
|
||||
}
|
||||
};
|
||||
@ -170,20 +166,22 @@ public class TraceCommand extends SWCommand {
|
||||
|
||||
@ClassMapper(value = BundleFilter.class, local = true)
|
||||
public TypeMapper<BundleFilter> bundleFilterClassMapper() {
|
||||
return new TypeMapper<BundleFilter>() {
|
||||
return new TypeMapper<>() {
|
||||
@Override
|
||||
public BundleFilter map(CommandSender commandSender, String[] previousArguments, String s) {
|
||||
for (BundleFilter filter : BundleFilter.values()) {
|
||||
if (s.equals(filter.toString()))
|
||||
if (s.equals(filter.toString())) {
|
||||
return filter;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<String> tabCompletes(CommandSender sender, PreviousArguments previousArguments, String s) {
|
||||
if(s.length() == 0)
|
||||
if (s.length() == 0) {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
|
||||
return Arrays.stream(BundleFilter.values())
|
||||
.map(Enum::toString)
|
||||
@ -198,15 +196,19 @@ public class TraceCommand extends SWCommand {
|
||||
@Override
|
||||
public ViewFlag map(CommandSender commandSender, String[] previousArguments, String s) {
|
||||
for (ViewFlag flag : ViewFlag.flags) {
|
||||
if (s.equals("--" + flag.name))
|
||||
if (s.equals("--" + flag.name)) {
|
||||
return flag;
|
||||
}
|
||||
|
||||
for(String alias: flag.aliases)
|
||||
if (s.equals("-" + alias))
|
||||
for (String alias : flag.aliases) {
|
||||
if (s.equals("-" + alias)) {
|
||||
return flag;
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<String> tabCompletes(CommandSender sender, PreviousArguments previousArguments, String s) {
|
||||
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.linkage.Linked;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
@ -53,44 +51,51 @@ public class TraceManager implements Listener {
|
||||
*/
|
||||
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
|
||||
* @return id of the created 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));
|
||||
}
|
||||
traces.put(nextOpenId, trace);
|
||||
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
|
||||
*/
|
||||
public boolean remove(int id) {
|
||||
if (id >= nextOpenId) 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.remove(id);
|
||||
return true;
|
||||
}
|
||||
|
||||
/** Clears all traces
|
||||
*
|
||||
/**
|
||||
* Clears all traces
|
||||
*/
|
||||
public void clear() {
|
||||
for (Player player: viewFlagMap.keySet())
|
||||
for(Trace trace: traces.values())
|
||||
for (Player player : viewFlagMap.keySet()) {
|
||||
for (Trace trace : traces.values()) {
|
||||
trace.hide(player);
|
||||
}
|
||||
}
|
||||
traces.clear();
|
||||
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
|
||||
* @return All traces recorded in the given Region
|
||||
@ -101,18 +106,21 @@ public class TraceManager implements Listener {
|
||||
.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
|
||||
* @return the trace with given id or null if no trace with id is found
|
||||
*/
|
||||
public Optional<Trace> get(int index) {
|
||||
if(index < traces.size())
|
||||
if (index < traces.size()) {
|
||||
return Optional.of(traces.get(index));
|
||||
}
|
||||
return Optional.empty();
|
||||
}
|
||||
|
||||
/** Methode to get all traces
|
||||
/**
|
||||
* Methode to get all traces
|
||||
*
|
||||
* @return fresh list of all current traces
|
||||
*/
|
||||
@ -123,9 +131,12 @@ public class TraceManager implements Listener {
|
||||
/**
|
||||
* @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 viewFlags
|
||||
@ -135,17 +146,20 @@ public class TraceManager implements Listener {
|
||||
viewFlagMap.put(player, viewFlags);
|
||||
bundleFilterMap.put(player, bundleFilter);
|
||||
|
||||
for(Trace trace: traces.values())
|
||||
for (Trace trace : traces.values()) {
|
||||
trace.render(player, viewFlags, bundleFilter);
|
||||
}
|
||||
}
|
||||
|
||||
/** Toggles trace show of for player
|
||||
/**
|
||||
* Toggles trace show of for player
|
||||
*
|
||||
* @param player
|
||||
*/
|
||||
public void hide(Player player) {
|
||||
for(Trace trace: traces.values())
|
||||
for (Trace trace : traces.values()) {
|
||||
trace.hide(player);
|
||||
}
|
||||
|
||||
viewFlagMap.remove(player);
|
||||
bundleFilterMap.remove(player);
|
||||
|
@ -27,9 +27,6 @@ import lombok.Getter;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
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;
|
||||
|
||||
@ -64,7 +61,6 @@ public class TraceEntity extends RFallingBlockEntity {
|
||||
public boolean equals(Object object) {
|
||||
if (!(object instanceof TraceEntity)) return false;
|
||||
TraceEntity entity = (TraceEntity) object;
|
||||
|
||||
return records.get(0).equals(entity.getRecords().get(0));
|
||||
}
|
||||
}
|
||||
|
@ -50,9 +50,6 @@ public abstract class ViewFlag {
|
||||
.filter(TNTRecord::isExplosion)
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void modify(REntityServer server, List<TraceEntity> entities) {}
|
||||
};
|
||||
|
||||
public static ViewFlag IGNITE = new ViewFlag(true, true, "ignite", "i") {
|
||||
@ -62,9 +59,6 @@ public abstract class ViewFlag {
|
||||
.filter(record -> !record.isAfterFirstExplosion())
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void modify(REntityServer server, List<TraceEntity> entities) {}
|
||||
};
|
||||
|
||||
public static ViewFlag SOURCE = new ViewFlag(true, false, IGNITE, "source", "s") {
|
||||
@ -74,9 +68,6 @@ public abstract class ViewFlag {
|
||||
.filter(record -> record.getFuse() == 80)
|
||||
.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") {
|
||||
@ -86,9 +77,6 @@ public abstract class ViewFlag {
|
||||
.filter(record -> record.getHistory().get(record.getHistory().size() - 1).isDestroyedBuildArea())
|
||||
.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") {
|
||||
@ -98,9 +86,6 @@ public abstract class ViewFlag {
|
||||
.filter(record -> record.getHistory().get(record.getHistory().size() - 1).isDestroyedTestBlock())
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void modify(REntityServer server, List<TraceEntity> entities) {}
|
||||
};
|
||||
|
||||
public static ViewFlag MICROMOTION = new ViewFlag(true, false, "micromotion", "m") {
|
||||
@ -133,15 +118,9 @@ public abstract class ViewFlag {
|
||||
|
||||
return records;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void modify(REntityServer server, List<TraceEntity> entities) {}
|
||||
};
|
||||
|
||||
public static ViewFlag ADVANCED = new ViewFlag(true, false, "advanced", "a") {
|
||||
@Override
|
||||
public List<TNTRecord> filter(List<TNTRecord> records) {return records;}
|
||||
|
||||
@Override
|
||||
public void modify(REntityServer server, List<TraceEntity> entities) {
|
||||
for (TraceEntity entity : entities) {
|
||||
@ -172,9 +151,6 @@ public abstract class ViewFlag {
|
||||
};
|
||||
|
||||
public static ViewFlag COUNT = new ViewFlag(true, false, "count", "c") {
|
||||
@Override
|
||||
public List<TNTRecord> filter(List<TNTRecord> records) { return records; }
|
||||
|
||||
@Override
|
||||
public void modify(REntityServer server, List<TraceEntity> entities) {
|
||||
for (TraceEntity entity : entities) {
|
||||
@ -184,9 +160,6 @@ public abstract class ViewFlag {
|
||||
};
|
||||
|
||||
public static ViewFlag FUSE = new ViewFlag(true, false, "fuse", "f") {
|
||||
@Override
|
||||
public List<TNTRecord> filter(List<TNTRecord> records) { return records; }
|
||||
|
||||
@Override
|
||||
public void modify(REntityServer server, List<TraceEntity> entities) {
|
||||
for (TraceEntity entity : entities) {
|
||||
@ -196,9 +169,6 @@ public abstract class ViewFlag {
|
||||
};
|
||||
|
||||
public static ViewFlag TIME = new ViewFlag(true, false, "time", "t") {
|
||||
@Override
|
||||
public List<TNTRecord> filter(List<TNTRecord> records) { return records; }
|
||||
|
||||
@Override
|
||||
public void modify(REntityServer server, List<TraceEntity> entities) {
|
||||
for (TraceEntity entity : entities) {
|
||||
@ -222,15 +192,15 @@ public abstract class ViewFlag {
|
||||
*/
|
||||
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);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
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.aliases = aliases;
|
||||
if (isStatic) flags.add(this);
|
||||
@ -238,17 +208,22 @@ public abstract class ViewFlag {
|
||||
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
|
||||
* @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 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/>.
|
||||
*/
|
||||
|
||||
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.rendering.TraceEntity;
|
||||
import de.steamwar.bausystem.features.tracer.rendering.ViewFlag;
|
||||
import de.steamwar.entity.REntityServer;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
@ -31,14 +29,14 @@ public class AtFlag extends ViewFlag {
|
||||
private int start;
|
||||
private int end;
|
||||
|
||||
|
||||
public AtFlag(int start, int end) {
|
||||
super(false, false, ViewFlag.IGNITE, null);
|
||||
this.start = start;
|
||||
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 end new interval end
|
||||
@ -54,7 +52,4 @@ public class AtFlag extends ViewFlag {
|
||||
.filter(record -> record.getTicksSinceStart() <= start && record.getTicksSinceStart() >= end)
|
||||
.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/>.
|
||||
*/
|
||||
|
||||
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.rendering.TraceEntity;
|
||||
import de.steamwar.bausystem.features.tracer.rendering.ViewFlag;
|
||||
import de.steamwar.entity.REntityServer;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
@ -43,6 +40,7 @@ public class IsolateFlag extends ViewFlag {
|
||||
|
||||
/**
|
||||
* Toggles the given id to be or not to be rendered
|
||||
*
|
||||
* @param id
|
||||
*/
|
||||
public void toggleId(int id) {
|
||||
@ -57,7 +55,4 @@ public class IsolateFlag extends ViewFlag {
|
||||
.filter(record -> tntToIsolate.contains(record.getTntId()))
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void modify(REntityServer server, List<TraceEntity> entities) {}
|
||||
}
|
In neuem Issue referenzieren
Einen Benutzer sperren