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 fd2c9cf4..b2145e1a 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/Trace.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/Trace.java @@ -217,7 +217,7 @@ public class Trace { List entities = new LinkedList<>(); for (List bundle : bundles) { - entities.add(new TraceEntity(entityServer, bundle.get(0).getLocation(), bundle.get(0).isExplosion(), bundle)); + entities.add(new TraceEntity(entityServer, bundle.get(0).getLocation(), bundle.get(0).isExplosion(), bundle, this)); } // Apply modifiers 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 26ded08b..828ab9a0 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/TraceCommand.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/TraceCommand.java @@ -149,7 +149,7 @@ public class TraceCommand extends SWCommand { @Register(value = "isolate", description = "TRACE_COMMAND_HELP_ISOLATE") public void isolate(@Validator Player player, Trace trace, @ErrorMessage("TRACE_RECORD_ID_INVALID") TNTPoint... records) { TraceManager.instance.isolate(player, records); - // TODO: Add Message! + BauSystem.MESSAGE.send("TRACE_MESSAGE_ISOLATE", player); } @Register(value = "share", description = "TRACE_COMMAND_HELP_SHARE") diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/TraceManager.java b/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/TraceManager.java index e6dd941c..b4715b79 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/TraceManager.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/TraceManager.java @@ -97,6 +97,18 @@ public class TraceManager implements Listener { return nextOpenId; } + /** + * Get the id of the given trace + * + * @param trace + */ + public int getId(Trace trace) { + for (Map.Entry entry : traces.entrySet()) { + if (entry.getValue() == trace) return entry.getKey(); + } + return -1; + } + /** * Renders only the given records to the specified trace * diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/rendering/TraceEntity.java b/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/rendering/TraceEntity.java index 49117dd8..dc056a2e 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/rendering/TraceEntity.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/rendering/TraceEntity.java @@ -22,6 +22,8 @@ package de.steamwar.bausystem.features.tracer.rendering; import com.comphenix.tinyprotocol.Reflection; import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.features.tracer.TNTPoint; +import de.steamwar.bausystem.features.tracer.Trace; +import de.steamwar.bausystem.features.tracer.TraceManager; import de.steamwar.core.Core; import de.steamwar.entity.REntity; import de.steamwar.entity.REntityServer; @@ -49,13 +51,19 @@ public class TraceEntity extends REntity { @Getter private final List records; + /** + * A string of all unique tnt records + */ private final String uniqueTntIdsString; - public TraceEntity(REntityServer server, Location location, boolean isExplosion, List records) { + private final Trace trace; + + public TraceEntity(REntityServer server, Location location, boolean isExplosion, List records, Trace trace) { super(server, EntityType.FALLING_BLOCK, location, BlockIds.impl.materialToId(isExplosion ? Material.RED_STAINED_GLASS : Material.TNT) >> (Core.getVersion() <= 12 ? 4 : 0)); setNoGravity(true); this.records = records; uniqueTntIdsString = records.stream().map(TNTPoint::getTntId).distinct().map(Object::toString).collect(Collectors.joining(" ")); + this.trace = trace; addEntityMethod.invoke(server, this); } @@ -75,7 +83,7 @@ public class TraceEntity extends REntity { BauSystem.MESSAGE.sendPrefixless("TNT_CLICK_VELOCITY_X", player, representative.getVelocity().getX() + ""); BauSystem.MESSAGE.sendPrefixless("TNT_CLICK_VELOCITY_Y", player, representative.getVelocity().getY() + ""); BauSystem.MESSAGE.sendPrefixless("TNT_CLICK_VELOCITY_Z", player, representative.getVelocity().getZ() + ""); - BauSystem.MESSAGE.sendPrefixless("TNT_CLICK_ISOLATE", player, BauSystem.MESSAGE.parse("TRACE_MESSAGE_CLICK_ISOLATE", player), new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/trace isolate " + uniqueTntIdsString)); + BauSystem.MESSAGE.sendPrefixless("TNT_CLICK_ISOLATE", player, BauSystem.MESSAGE.parse("TRACE_MESSAGE_CLICK_ISOLATE", player), new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/trace isolate " + TraceManager.instance.getId(trace) + " " + uniqueTntIdsString)); } @Override