diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/Trace.java b/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/Trace.java index efd822e8..30b4c2b4 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/Trace.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/Trace.java @@ -158,7 +158,7 @@ public class Trace { //Apply filters for(ViewFlag flag : flags) - workingRecords = flag.filter.apply(workingRecords); + workingRecords = flag.filter(workingRecords); //Bundle records at unique positions List> bundles = bundleRecords(workingRecords, bundleFilter); @@ -171,7 +171,7 @@ public class Trace { //Apply modifiers for(ViewFlag flag : flags) - flag.modify.accept(server, entities); + flag.modify(server, entities); } /** Bundles the passed TNTRecords based on whether they are at the same location diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/rendering/ViewFlag.java b/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/rendering/ViewFlag.java index 04833f09..d2a2c2bc 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/rendering/ViewFlag.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/rendering/ViewFlag.java @@ -27,18 +27,21 @@ import java.util.ArrayList; import java.util.List; import java.util.function.BiConsumer; import java.util.function.UnaryOperator; +import java.util.stream.Collectors; public abstract class ViewFlag { - /** - * The filtering part of the flag - */ - public final UnaryOperator> filter; + public static ViewFlag EXPLOSION = new ViewFlag(true,"explosion") { + @Override + public List filter(List records) { + return records.stream() + .filter(TNTRecord::isExplosion) + .collect(Collectors.toList()); + } - /** - * The modifieng part of the flag - */ - public final BiConsumer> modify; + @Override + public void modify(REntityServer server, List entities) {} + }; /** * Name of the flag @@ -50,14 +53,29 @@ public abstract class ViewFlag { */ public final String[] aliases; + /** + * Static registry of static flags + */ public static final List flags = new ArrayList<>(); - public ViewFlag(UnaryOperator> filter, BiConsumer> modify, boolean isStatic, String name, String... aliases) { - this.filter = filter; - this.modify = modify; + public ViewFlag(boolean isStatic, String name, String... aliases) { this.name = name; this.aliases = aliases; if(isStatic) flags.add(this); } + + /** Filters the given records for a given condition + * + * @param records Records to be filtered + * @return Filtered records + */ + public abstract List filter (List records); + + /** 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 entities); }