Trace Refactor #233
@ -28,9 +28,7 @@ import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.*;
|
||||
import java.util.function.BiConsumer;
|
||||
import java.util.function.UnaryOperator;
|
||||
import java.util.stream.Collectors;
|
||||
@ -46,7 +44,7 @@ public abstract class ViewFlag {
|
||||
*/
|
||||
public static final List<ViewFlag> inverseFlags = new ArrayList<>();
|
||||
|
||||
public static ViewFlag EXPLOSION = new ViewFlag(true, false,"explosionOnly") {
|
||||
public static ViewFlag EXPLOSION = new ViewFlag(true, false,"explosion") {
|
||||
@Override
|
||||
public List<TNTRecord> filter(List<TNTRecord> records) {
|
||||
return records.stream()
|
||||
@ -106,6 +104,41 @@ public abstract class ViewFlag {
|
||||
public void modify(REntityServer server, List<TraceEntity> entities) {}
|
||||
};
|
||||
|
||||
public static ViewFlag MICROMOTION = new ViewFlag(true, false, "micromotion") {
|
||||
@Override
|
||||
public List<TNTRecord> filter(List<TNTRecord> records) {
|
||||
Set<UUID> seen = new HashSet<>();
|
||||
Set<TNTRecord> toRemove = new HashSet<>();
|
||||
|
||||
for(TNTRecord uniqueRecord: records){
|
||||
if(seen.contains(uniqueRecord.getTntId())) continue;
|
||||
|
||||
boolean hasMicromotion = false;
|
||||
for(TNTRecord record: uniqueRecord.getHistory()){
|
||||
Vector velocity = record.getVelocity();
|
||||
if(velocity.getY() == 0 && (Math.abs(velocity.getX()) < 0.001 || Math.abs(velocity.getZ()) < 0.001)){
|
||||
hasMicromotion = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if(!hasMicromotion)
|
||||
toRemove.add(uniqueRecord);
|
||||
|
||||
seen.add(uniqueRecord.getTntId());
|
||||
}
|
||||
|
||||
for(TNTRecord record: toRemove){
|
||||
records.removeAll(record.getHistory());
|
||||
}
|
||||
|
||||
return records;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void modify(REntityServer server, List<TraceEntity> entities) {}
|
||||
};
|
||||
|
||||
public static ViewFlag ADVANCED = new ViewFlag(true, false, "advanced") {
|
||||
@Override
|
||||
public List<TNTRecord> filter(List<TNTRecord> records) {return records;}
|
||||
|
In neuem Issue referenzieren
Einen Benutzer sperren