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 eea93171..062e5a8f 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/Trace.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/Trace.java @@ -160,7 +160,7 @@ public class Trace { * @param flags Flags modefieing the rendering * @param bundleFilter Filter to determin bundeling of records */ - private void render (REntityServer server, List records, ViewFlag[] flags, BundleFilter bundleFilter){ + private void render(REntityServer server, List records, ViewFlag[] flags, BundleFilter bundleFilter){ if(records.size() == 0) return; List workingRecords = records; @@ -181,8 +181,9 @@ public class Trace { }); //Apply filters - for(ViewFlag flag : flagList) + for(ViewFlag flag : flagList) { workingRecords = flag.filter(workingRecords); + } //Bundle records at unique positions List> bundles = bundleRecords(workingRecords, bundleFilter); @@ -190,12 +191,14 @@ public class Trace { //Render bundled records List entities = new LinkedList<>(); - for(List bundle : bundles) + for(List bundle : bundles) { entities.add(new TraceEntity(server, bundle.get(0).getLocation(), bundle.get(0).isExplosion(), bundle)); + } //Apply modifiers - for(ViewFlag flag : flags) + for(ViewFlag flag : flags) { 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/TraceCommand.java b/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/TraceCommand.java index dc3f95c0..c40f45dc 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/TraceCommand.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/TraceCommand.java @@ -37,6 +37,7 @@ import org.bukkit.entity.Player; import java.util.*; import java.util.stream.Collectors; +import java.util.stream.Stream; @Linked public class TraceCommand extends SWCommand { @@ -119,7 +120,7 @@ public class TraceCommand extends SWCommand { @ClassMapper(value = Trace.class, local = true) public TypeMapper traceClassMapper(){ - return new TypeMapper() { + return new TypeMapper() { @Override public Trace map(CommandSender commandSender, String[] previousArguments, String s) { int id = Integer.parseInt(s); @@ -199,7 +200,7 @@ public class TraceCommand extends SWCommand { return flag; for(String alias: flag.aliases) - if (s.equals("--" + alias)) + if (s.equals("-" + alias)) return flag; } return null; @@ -207,8 +208,8 @@ public class TraceCommand extends SWCommand { @Override public Collection tabCompletes(CommandSender sender, PreviousArguments previousArguments, String s) { return ViewFlag.flags.stream() - .map(flag -> flag.name) - .map(name -> "--" + name) + .flatMap(viewFlag -> Stream.concat(Stream.of("--" + viewFlag.name), + Arrays.stream(viewFlag.aliases).map(name -> "-" + name))) .collect(Collectors.toList()); } }; 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 e17bcb48..6f0bd02f 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 @@ -20,17 +20,16 @@ package de.steamwar.bausystem.features.tracer.rendering; 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.RFallingBlockEntity; import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.util.Vector; -import java.util.*; -import java.util.function.BiConsumer; -import java.util.function.UnaryOperator; +import java.util.ArrayList; +import java.util.HashSet; +import java.util.List; +import java.util.Set; import java.util.stream.Collectors; public abstract class ViewFlag { @@ -44,7 +43,7 @@ public abstract class ViewFlag { */ public static final List inverseFlags = new ArrayList<>(); - public static ViewFlag EXPLOSION = new ViewFlag(true, false,"explosion") { + public static ViewFlag EXPLOSION = new ViewFlag(true, false,"explosion", "e") { @Override public List filter(List records) { return records.stream() @@ -56,7 +55,7 @@ public abstract class ViewFlag { public void modify(REntityServer server, List entities) {} }; - public static ViewFlag IGNITE = new ViewFlag(true, true, "ignite") { + public static ViewFlag IGNITE = new ViewFlag(true, true, "ignite", "i") { @Override public List filter(List records) { return records.stream() @@ -68,7 +67,7 @@ public abstract class ViewFlag { public void modify(REntityServer server, List entities) {} }; - public static ViewFlag SOURCE = new ViewFlag(true, false, IGNITE, "source") { + public static ViewFlag SOURCE = new ViewFlag(true, false, IGNITE, "source", "s") { @Override public List filter(List records) { return records.stream() @@ -148,32 +147,33 @@ public abstract class ViewFlag { @Override public void modify(REntityServer server, List 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) { + RFallingBlockEntity y = new RFallingBlockEntity(server, pos, Material.WHITE_STAINED_GLASS); + y.setNoGravity(true); + } - 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); - y.setNoGravity(true); - - if(xVelocity >= zVelocity) - pos.add(xVelocity, 0, 0); - else - pos.add(0,0,zVelocity); - - RFallingBlockEntity secound = new RFallingBlockEntity(server, pos, Material.WHITE_STAINED_GLASS); - secound.setNoGravity(true); + if (current.getVelocity().getX() >= current.getVelocity().getZ()) { + pos.setX(next.getLocation().getX()); + } else { + pos.setZ(next.getLocation().getZ()); + } + if (pos.distanceSquared(next.getLocation()) >= 1.0 / 256.0) { + 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 public List filter(List 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 public List filter(List 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 public List filter(List records) { return records; } @@ -222,27 +222,23 @@ public abstract class ViewFlag { /** * 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(isStatic, isInverse, new ViewFlag[0], name, 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.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){ - this.name = name; - this.aliases = aliases; - if(isStatic) - flags.add(this); - if(isInverse) - inverseFlags.add(this); - this.required = required; - } + if(isStatic) flags.add(this); + if(isInverse) inverseFlags.add(this); + this.required = required; + } /** Filters the given records for a given condition * diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/rendering/dynamicFlags/IsolateFlag.java b/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/rendering/dynamicFlags/IsolateFlag.java index 71e59012..85d1f1bb 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/rendering/dynamicFlags/IsolateFlag.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/rendering/dynamicFlags/IsolateFlag.java @@ -35,7 +35,7 @@ public class IsolateFlag extends ViewFlag { private final Set tntToIsolate = new HashSet<>(); public IsolateFlag(){ - super(false, false, ViewFlag.IGNITE, "isolate"); + super(false, false, ViewFlag.IGNITE, null); } /** @@ -43,10 +43,9 @@ public class IsolateFlag extends ViewFlag { * @param id */ public void toggleId(int id){ - if(tntToIsolate.contains(id)) - tntToIsolate.remove(id); - else + if (!tntToIsolate.remove(id)) { tntToIsolate.add(id); + } } @Override