Trace Refactor #233
@ -158,7 +158,7 @@ public class Trace {
|
|||||||
|
|
||||||
//Apply filters
|
//Apply filters
|
||||||
for(ViewFlag flag : flags)
|
for(ViewFlag flag : flags)
|
||||||
workingRecords = flag.filter.apply(workingRecords);
|
workingRecords = flag.filter(workingRecords);
|
||||||
|
|
||||||
//Bundle records at unique positions
|
//Bundle records at unique positions
|
||||||
List<List<TNTRecord>> bundles = bundleRecords(workingRecords, bundleFilter);
|
List<List<TNTRecord>> bundles = bundleRecords(workingRecords, bundleFilter);
|
||||||
@ -171,7 +171,7 @@ public class Trace {
|
|||||||
|
|
||||||
//Apply modifiers
|
//Apply modifiers
|
||||||
for(ViewFlag flag : flags)
|
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
|
/** Bundles the passed TNTRecords based on whether they are at the same location
|
||||||
|
@ -27,18 +27,21 @@ import java.util.ArrayList;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.function.BiConsumer;
|
import java.util.function.BiConsumer;
|
||||||
import java.util.function.UnaryOperator;
|
import java.util.function.UnaryOperator;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
public abstract class ViewFlag {
|
public abstract class ViewFlag {
|
||||||
|
|
||||||
/**
|
public static ViewFlag EXPLOSION = new ViewFlag(true,"explosion") {
|
||||||
* The filtering part of the flag
|
@Override
|
||||||
*/
|
public List<TNTRecord> filter(List<TNTRecord> records) {
|
||||||
public final UnaryOperator<List<TNTRecord>> filter;
|
return records.stream()
|
||||||
|
.filter(TNTRecord::isExplosion)
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
@Override
|
||||||
* The modifieng part of the flag
|
public void modify(REntityServer server, List<TraceEntity> entities) {}
|
||||||
*/
|
};
|
||||||
public final BiConsumer<REntityServer, List<TraceEntity>> modify;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Name of the flag
|
* Name of the flag
|
||||||
@ -50,14 +53,29 @@ public abstract class ViewFlag {
|
|||||||
*/
|
*/
|
||||||
public final String[] aliases;
|
public final String[] aliases;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Static registry of static flags
|
||||||
|
*/
|
||||||
public static final List<ViewFlag> flags = new ArrayList<>();
|
public static final List<ViewFlag> flags = new ArrayList<>();
|
||||||
|
|
||||||
public ViewFlag(UnaryOperator<List<TNTRecord>> filter, BiConsumer<REntityServer,List<TraceEntity>> modify, boolean isStatic, String name, String... aliases) {
|
public ViewFlag(boolean isStatic, String name, String... aliases) {
|
||||||
this.filter = filter;
|
|
||||||
this.modify = modify;
|
|
||||||
this.name = name;
|
this.name = name;
|
||||||
this.aliases = aliases;
|
this.aliases = aliases;
|
||||||
if(isStatic)
|
if(isStatic)
|
||||||
flags.add(this);
|
flags.add(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** 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);
|
||||||
|
|
||||||
|
/** 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);
|
||||||
}
|
}
|
||||||
|
In neuem Issue referenzieren
Einen Benutzer sperren