SteamWar/BauSystem2.0
Archiviert
12
0

Fix isolate click message
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful

Dieser Commit ist enthalten in:
D4rkr34lm 2024-04-21 15:21:12 +02:00
Ursprung d81fb4e020
Commit d0a08bc331
4 geänderte Dateien mit 24 neuen und 4 gelöschten Zeilen

Datei anzeigen

@ -217,7 +217,7 @@ public class Trace {
List<TraceEntity> entities = new LinkedList<>(); List<TraceEntity> entities = new LinkedList<>();
for (List<TNTPoint> bundle : bundles) { for (List<TNTPoint> 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 // Apply modifiers

Datei anzeigen

@ -149,7 +149,7 @@ public class TraceCommand extends SWCommand {
@Register(value = "isolate", description = "TRACE_COMMAND_HELP_ISOLATE") @Register(value = "isolate", description = "TRACE_COMMAND_HELP_ISOLATE")
public void isolate(@Validator Player player, Trace trace, @ErrorMessage("TRACE_RECORD_ID_INVALID") TNTPoint... records) { public void isolate(@Validator Player player, Trace trace, @ErrorMessage("TRACE_RECORD_ID_INVALID") TNTPoint... records) {
TraceManager.instance.isolate(player, records); TraceManager.instance.isolate(player, records);
// TODO: Add Message! BauSystem.MESSAGE.send("TRACE_MESSAGE_ISOLATE", player);
} }
@Register(value = "share", description = "TRACE_COMMAND_HELP_SHARE") @Register(value = "share", description = "TRACE_COMMAND_HELP_SHARE")

Datei anzeigen

@ -97,6 +97,18 @@ public class TraceManager implements Listener {
return nextOpenId; return nextOpenId;
} }
/**
* Get the id of the given trace
*
* @param trace
*/
public int getId(Trace trace) {
for (Map.Entry<Integer, Trace> entry : traces.entrySet()) {
if (entry.getValue() == trace) return entry.getKey();
}
return -1;
}
/** /**
* Renders only the given records to the specified trace * Renders only the given records to the specified trace
* *

Datei anzeigen

@ -22,6 +22,8 @@ package de.steamwar.bausystem.features.tracer.rendering;
import com.comphenix.tinyprotocol.Reflection; import com.comphenix.tinyprotocol.Reflection;
import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.BauSystem;
import de.steamwar.bausystem.features.tracer.TNTPoint; 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.core.Core;
import de.steamwar.entity.REntity; import de.steamwar.entity.REntity;
import de.steamwar.entity.REntityServer; import de.steamwar.entity.REntityServer;
@ -49,13 +51,19 @@ public class TraceEntity extends REntity {
@Getter @Getter
private final List<TNTPoint> records; private final List<TNTPoint> records;
/**
* A string of all unique tnt records
*/
private final String uniqueTntIdsString; private final String uniqueTntIdsString;
public TraceEntity(REntityServer server, Location location, boolean isExplosion, List<TNTPoint> records) { private final Trace trace;
public TraceEntity(REntityServer server, Location location, boolean isExplosion, List<TNTPoint> records, Trace trace) {
super(server, EntityType.FALLING_BLOCK, location, BlockIds.impl.materialToId(isExplosion ? Material.RED_STAINED_GLASS : Material.TNT) >> (Core.getVersion() <= 12 ? 4 : 0)); super(server, EntityType.FALLING_BLOCK, location, BlockIds.impl.materialToId(isExplosion ? Material.RED_STAINED_GLASS : Material.TNT) >> (Core.getVersion() <= 12 ? 4 : 0));
setNoGravity(true); setNoGravity(true);
this.records = records; this.records = records;
uniqueTntIdsString = records.stream().map(TNTPoint::getTntId).distinct().map(Object::toString).collect(Collectors.joining(" ")); uniqueTntIdsString = records.stream().map(TNTPoint::getTntId).distinct().map(Object::toString).collect(Collectors.joining(" "));
this.trace = trace;
addEntityMethod.invoke(server, this); 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_X", player, representative.getVelocity().getX() + "");
BauSystem.MESSAGE.sendPrefixless("TNT_CLICK_VELOCITY_Y", player, representative.getVelocity().getY() + ""); 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_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 @Override