Dieser Commit ist enthalten in:
Ursprung
d80e4cf3e0
Commit
c0dcb99f7b
@ -181,8 +181,9 @@ public class Trace {
|
|||||||
});
|
});
|
||||||
|
|
||||||
//Apply filters
|
//Apply filters
|
||||||
for(ViewFlag flag : flagList)
|
for(ViewFlag flag : flagList) {
|
||||||
workingRecords = flag.filter(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);
|
||||||
@ -190,13 +191,15 @@ 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);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/** 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
|
||||||
*
|
*
|
||||||
|
@ -37,6 +37,7 @@ import org.bukkit.entity.Player;
|
|||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
@Linked
|
@Linked
|
||||||
public class TraceCommand extends SWCommand {
|
public class TraceCommand extends SWCommand {
|
||||||
@ -199,7 +200,7 @@ public class TraceCommand extends SWCommand {
|
|||||||
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;
|
||||||
@ -207,8 +208,8 @@ 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) {
|
||||||
return ViewFlag.flags.stream()
|
return ViewFlag.flags.stream()
|
||||||
.map(flag -> flag.name)
|
.flatMap(viewFlag -> Stream.concat(Stream.of("--" + viewFlag.name),
|
||||||
.map(name -> "--" + name)
|
Arrays.stream(viewFlag.aliases).map(name -> "-" + name)))
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -20,17 +20,16 @@
|
|||||||
package de.steamwar.bausystem.features.tracer.rendering;
|
package de.steamwar.bausystem.features.tracer.rendering;
|
||||||
|
|
||||||
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.entity.REntity;
|
|
||||||
import de.steamwar.entity.REntityServer;
|
import de.steamwar.entity.REntityServer;
|
||||||
import de.steamwar.entity.RFallingBlockEntity;
|
import de.steamwar.entity.RFallingBlockEntity;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.util.Vector;
|
import org.bukkit.util.Vector;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.ArrayList;
|
||||||
import java.util.function.BiConsumer;
|
import java.util.HashSet;
|
||||||
import java.util.function.UnaryOperator;
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
public abstract class ViewFlag {
|
public abstract class ViewFlag {
|
||||||
@ -44,7 +43,7 @@ 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") {
|
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()
|
||||||
@ -56,7 +55,7 @@ public abstract class ViewFlag {
|
|||||||
public void modify(REntityServer server, List<TraceEntity> entities) {}
|
public void modify(REntityServer server, List<TraceEntity> entities) {}
|
||||||
};
|
};
|
||||||
|
|
||||||
public static ViewFlag IGNITE = new ViewFlag(true, true, "ignite") {
|
public static ViewFlag IGNITE = new ViewFlag(true, true, "ignite", "i") {
|
||||||
@Override
|
@Override
|
||||||
public List<TNTRecord> filter(List<TNTRecord> records) {
|
public List<TNTRecord> filter(List<TNTRecord> records) {
|
||||||
return records.stream()
|
return records.stream()
|
||||||
@ -68,7 +67,7 @@ public abstract class ViewFlag {
|
|||||||
public void modify(REntityServer server, List<TraceEntity> entities) {}
|
public void modify(REntityServer server, List<TraceEntity> entities) {}
|
||||||
};
|
};
|
||||||
|
|
||||||
public static ViewFlag SOURCE = new ViewFlag(true, false, IGNITE, "source") {
|
public static ViewFlag SOURCE = new ViewFlag(true, false, IGNITE, "source", "s") {
|
||||||
@Override
|
@Override
|
||||||
public List<TNTRecord> filter(List<TNTRecord> records) {
|
public List<TNTRecord> filter(List<TNTRecord> records) {
|
||||||
return records.stream()
|
return records.stream()
|
||||||
@ -148,32 +147,33 @@ public abstract class ViewFlag {
|
|||||||
@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 representaitv = entity.getRecords().get(0);
|
TNTRecord current = entity.getRecords().get(0);
|
||||||
|
if(current.isExplosion()) continue;
|
||||||
|
TNTRecord next = current.getNext().orElse(null);
|
||||||
|
if (next == null) continue;
|
||||||
|
|
||||||
if(representaitv.isExplosion()) continue;
|
Location pos = current.getLocation().clone();
|
||||||
|
pos.setY(next.getLocation().getY());
|
||||||
|
|
||||||
Location pos = representaitv.getLocation();
|
if (pos.distanceSquared(current.getLocation()) >= 1.0 / 256.0) {
|
||||||
|
|
||||||
double xVelocity = representaitv.getVelocity().getX();
|
|
||||||
double yVelocity = representaitv.getVelocity().getY();
|
|
||||||
double zVelocity = representaitv.getVelocity().getZ();
|
|
||||||
|
|
||||||
pos = pos.add(0,yVelocity,0);
|
|
||||||
RFallingBlockEntity y = new RFallingBlockEntity(server, pos, Material.WHITE_STAINED_GLASS);
|
RFallingBlockEntity y = new RFallingBlockEntity(server, pos, Material.WHITE_STAINED_GLASS);
|
||||||
y.setNoGravity(true);
|
y.setNoGravity(true);
|
||||||
|
}
|
||||||
|
|
||||||
if(xVelocity >= zVelocity)
|
if (current.getVelocity().getX() >= current.getVelocity().getZ()) {
|
||||||
pos.add(xVelocity, 0, 0);
|
pos.setX(next.getLocation().getX());
|
||||||
else
|
} else {
|
||||||
pos.add(0,0,zVelocity);
|
pos.setZ(next.getLocation().getZ());
|
||||||
|
}
|
||||||
RFallingBlockEntity secound = new RFallingBlockEntity(server, pos, Material.WHITE_STAINED_GLASS);
|
if (pos.distanceSquared(next.getLocation()) >= 1.0 / 256.0) {
|
||||||
secound.setNoGravity(true);
|
RFallingBlockEntity second = new RFallingBlockEntity(server, pos, Material.WHITE_STAINED_GLASS);
|
||||||
|
second.setNoGravity(true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
public static ViewFlag COUNT = new ViewFlag(true, false, "count") {
|
public static ViewFlag COUNT = new ViewFlag(true, false, "count", "c") {
|
||||||
@Override
|
@Override
|
||||||
public List<TNTRecord> filter(List<TNTRecord> records) { return records; }
|
public List<TNTRecord> filter(List<TNTRecord> records) { return records; }
|
||||||
|
|
||||||
@ -185,7 +185,7 @@ public abstract class ViewFlag {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
public static ViewFlag FUSE = new ViewFlag(true, false, "fuse") {
|
public static ViewFlag FUSE = new ViewFlag(true, false, "fuse", "f") {
|
||||||
@Override
|
@Override
|
||||||
public List<TNTRecord> filter(List<TNTRecord> records) { return records; }
|
public List<TNTRecord> filter(List<TNTRecord> records) { return records; }
|
||||||
|
|
||||||
@ -197,7 +197,7 @@ public abstract class ViewFlag {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
public static ViewFlag TIME = new ViewFlag(true, false, "time") {
|
public static ViewFlag TIME = new ViewFlag(true, false, "time", "t") {
|
||||||
@Override
|
@Override
|
||||||
public List<TNTRecord> filter(List<TNTRecord> records) { return records; }
|
public List<TNTRecord> filter(List<TNTRecord> records) { return records; }
|
||||||
|
|
||||||
@ -222,25 +222,21 @@ public abstract class ViewFlag {
|
|||||||
/**
|
/**
|
||||||
* A flag that is used whenever this flag is used
|
* A flag that is used whenever this flag is used
|
||||||
*/
|
*/
|
||||||
public final ViewFlag required;
|
public final ViewFlag[] required;
|
||||||
|
|
||||||
public ViewFlag(boolean isStatic, boolean isInverse, String name, String... aliases) {
|
public ViewFlag(boolean isStatic, boolean isInverse, String name, String... aliases) {
|
||||||
this.name = name;
|
this(isStatic, isInverse, new ViewFlag[0], name, aliases);
|
||||||
this.aliases = aliases;
|
|
||||||
if(isStatic)
|
|
||||||
flags.add(this);
|
|
||||||
if(isInverse)
|
|
||||||
inverseFlags.add(this);
|
|
||||||
required = null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public ViewFlag(boolean isStatic, boolean isInverse, ViewFlag required, String name, String... aliases) {
|
public 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){
|
||||||
this.name = name;
|
this.name = name;
|
||||||
this.aliases = aliases;
|
this.aliases = aliases;
|
||||||
if(isStatic)
|
if(isStatic) flags.add(this);
|
||||||
flags.add(this);
|
if(isInverse) inverseFlags.add(this);
|
||||||
if(isInverse)
|
|
||||||
inverseFlags.add(this);
|
|
||||||
this.required = required;
|
this.required = required;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -35,7 +35,7 @@ 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, "isolate");
|
super(false, false, ViewFlag.IGNITE, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -43,11 +43,10 @@ public class IsolateFlag extends ViewFlag {
|
|||||||
* @param id
|
* @param id
|
||||||
*/
|
*/
|
||||||
public void toggleId(int id){
|
public void toggleId(int id){
|
||||||
if(tntToIsolate.contains(id))
|
if (!tntToIsolate.remove(id)) {
|
||||||
tntToIsolate.remove(id);
|
|
||||||
else
|
|
||||||
tntToIsolate.add(id);
|
tntToIsolate.add(id);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<TNTRecord> filter(List<TNTRecord> records) {
|
public List<TNTRecord> filter(List<TNTRecord> records) {
|
||||||
|
In neuem Issue referenzieren
Einen Benutzer sperren