SteamWar/BauSystem
Archiviert
13
0

Optimize Packets in TraceEntity_12 and TraceEntity_15

Simplify messages in CommandTrace
Dieser Commit ist enthalten in:
jojo 2020-12-27 13:47:43 +01:00
Ursprung bd06e710f7
Commit 6b23f88ea0
4 geänderte Dateien mit 35 neuen und 34 gelöschten Zeilen

Datei anzeigen

@ -31,10 +31,12 @@ import java.lang.reflect.Field;
class TraceEntity_12 extends EntityFallingBlock implements AbstractTraceEntity { class TraceEntity_12 extends EntityFallingBlock implements AbstractTraceEntity {
private Vector position; private Vector position;
private boolean tnt;
public TraceEntity_12(World world, Vector position, Player player, boolean exploded, boolean tnt) { public TraceEntity_12(World world, Vector position, Player player, boolean exploded, boolean tnt) {
super(((CraftWorld) world).getHandle(), position.getX(), position.getY(), position.getZ(), tnt ? Blocks.TNT.getBlockData() : Blocks.STAINED_GLASS.getBlockData()); super(((CraftWorld) world).getHandle(), position.getX(), position.getY(), position.getZ(), tnt ? Blocks.TNT.getBlockData() : Blocks.STAINED_GLASS.getBlockData());
this.position = position; this.position = position;
this.tnt = tnt;
this.setNoGravity(true); this.setNoGravity(true);
this.ticksLived = -12000; this.ticksLived = -12000;
@ -64,8 +66,10 @@ class TraceEntity_12 extends EntityFallingBlock implements AbstractTraceEntity {
PacketPlayOutEntityTeleport packetPlayOutEntityTeleport = new PacketPlayOutEntityTeleport(this); PacketPlayOutEntityTeleport packetPlayOutEntityTeleport = new PacketPlayOutEntityTeleport(this);
playerConnection.sendPacket(packetPlayOutEntityTeleport); playerConnection.sendPacket(packetPlayOutEntityTeleport);
PacketPlayOutEntityMetadata packetPlayOutEntityMetadata = new PacketPlayOutEntityMetadata(getId(), datawatcher, true); if (tnt) {
playerConnection.sendPacket(packetPlayOutEntityMetadata); PacketPlayOutEntityMetadata packetPlayOutEntityMetadata = new PacketPlayOutEntityMetadata(getId(), datawatcher, true);
playerConnection.sendPacket(packetPlayOutEntityMetadata);
}
return this; return this;
} }

Datei anzeigen

@ -54,8 +54,10 @@ class TraceEntity_15 extends EntityFallingBlock implements AbstractTraceEntity {
PlayerConnection playerConnection = ((CraftPlayer) player).getHandle().playerConnection; PlayerConnection playerConnection = ((CraftPlayer) player).getHandle().playerConnection;
playerConnection.sendPacket(packetPlayOutSpawnEntity); playerConnection.sendPacket(packetPlayOutSpawnEntity);
PacketPlayOutEntityMetadata packetPlayOutEntityMetadata = new PacketPlayOutEntityMetadata(getId(), datawatcher, true); if (tnt) {
playerConnection.sendPacket(packetPlayOutEntityMetadata); PacketPlayOutEntityMetadata packetPlayOutEntityMetadata = new PacketPlayOutEntityMetadata(getId(), datawatcher, true);
playerConnection.sendPacket(packetPlayOutEntityMetadata);
}
return this; return this;
} }

Datei anzeigen

@ -22,8 +22,6 @@ package de.steamwar.bausystem.commands;
import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.BauSystem;
import de.steamwar.bausystem.Permission; import de.steamwar.bausystem.Permission;
import de.steamwar.bausystem.tracer.record.RecordStateMachine; import de.steamwar.bausystem.tracer.record.RecordStateMachine;
import de.steamwar.bausystem.tracer.record.RecordStatus;
import de.steamwar.bausystem.tracer.show.ShowMode;
import de.steamwar.bausystem.tracer.show.StoredRecords; import de.steamwar.bausystem.tracer.show.StoredRecords;
import de.steamwar.bausystem.tracer.show.TraceShowManager; import de.steamwar.bausystem.tracer.show.TraceShowManager;
import de.steamwar.bausystem.tracer.show.mode.Advanced; import de.steamwar.bausystem.tracer.show.mode.Advanced;
@ -73,29 +71,16 @@ public class CommandTrace implements CommandExecutor {
switch (args[0].toLowerCase()) { switch (args[0].toLowerCase()) {
case "start": case "start":
RecordStateMachine.commandStart(); RecordStateMachine.commandStart();
player.sendMessage(BauSystem.PREFIX + "§aTNT-Tracer gestartet"); player.sendMessage(BauSystem.PREFIX + RecordStateMachine.getRecordStatus().getMessage());
break; break;
case "stop": case "stop":
RecordStateMachine.commandStop(); RecordStateMachine.commandStop();
player.sendMessage(BauSystem.PREFIX + "§cTNT-Tracer gestoppt"); player.sendMessage(BauSystem.PREFIX + RecordStateMachine.getRecordStatus().getMessage());
break; break;
case "toggleauto": case "toggleauto":
case "auto": case "auto":
RecordStateMachine.commandAuto(); RecordStateMachine.commandAuto();
switch (RecordStateMachine.getRecordStatus()) { player.sendMessage(BauSystem.PREFIX + RecordStateMachine.getRecordStatus().getAutoMessage());
case IDLE:
player.sendMessage(BauSystem.PREFIX + "§cAuto-Tracer gestoppt");
break;
case IDLE_AUTO:
player.sendMessage(BauSystem.PREFIX + "§aAuto-Tracer gestartet");
break;
case RECORD:
player.sendMessage(BauSystem.PREFIX + "§cTNT-Tracer muss gestoppt werden");
break;
case RECORD_AUTO:
player.sendMessage(BauSystem.PREFIX + "§cTNT-Tracer muss aus sein");
break;
}
break; break;
case "clear": case "clear":
case "delete": case "delete":
@ -103,31 +88,29 @@ public class CommandTrace implements CommandExecutor {
player.sendMessage(BauSystem.PREFIX + "§cAlle TNT-Positionen gelöscht"); player.sendMessage(BauSystem.PREFIX + "§cAlle TNT-Positionen gelöscht");
break; break;
case "show": case "show":
ShowMode showMode;
if (args.length < 2) { if (args.length < 2) {
showMode = new Basic(player); TraceShowManager.show(player, new Basic(player));
} else { } else {
switch (args[1].toLowerCase()) { switch (args[1].toLowerCase()) {
case "nowater": case "nowater":
case "basic-nowater": case "basic-nowater":
case "basicnowater": case "basicnowater":
showMode = new BasicNoWater(player); TraceShowManager.show(player, new BasicNoWater(player));
break; break;
case "advanced": case "advanced":
showMode = new Advanced(player); TraceShowManager.show(player, new Advanced(player));
break; break;
case "advanced-nowater": case "advanced-nowater":
case "advancednowater": case "advancednowater":
showMode = new AdvancedNoWater(player); TraceShowManager.show(player, new AdvancedNoWater(player));
break; break;
case "basic": case "basic":
case "default": case "default":
default: default:
showMode = new Basic(player); TraceShowManager.show(player, new Basic(player));
break; break;
} }
} }
TraceShowManager.show(player, showMode);
player.sendMessage(BauSystem.PREFIX + "§aAlle TNT-Positionen angezeigt"); player.sendMessage(BauSystem.PREFIX + "§aAlle TNT-Positionen angezeigt");
break; break;
case "hide": case "hide":

Datei anzeigen

@ -21,17 +21,21 @@ package de.steamwar.bausystem.tracer.record;
public enum RecordStatus { public enum RecordStatus {
RECORD("§aan", true), RECORD("§aan", true, "§aTNT-Tracer gestartet", "§cTNT-Tracer muss gestoppt werden"),
RECORD_AUTO("§aan", true), RECORD_AUTO("§aan", true, "§cAuto-Tracer muss aus sein", "§cTNT-Tracer muss aus sein"),
IDLE("§caus", false), IDLE("§caus", false, "§cTNT-Tracer gestoppt", "§cAuto-Tracer gestoppt"),
IDLE_AUTO("§eauto", false); IDLE_AUTO("§eauto", false, "§cTNT-Tracer muss gestoppt werden", "§aAuto-Tracer gestartet");
String name; String name;
boolean tracing; boolean tracing;
String message;
String autoMessage;
RecordStatus(String value, boolean tracing) { RecordStatus(String value, boolean tracing, String message, String autoMessage) {
this.name = value; this.name = value;
this.tracing = tracing; this.tracing = tracing;
this.message = message;
this.autoMessage = autoMessage;
} }
public String getName() { public String getName() {
@ -42,4 +46,12 @@ public enum RecordStatus {
return tracing; return tracing;
} }
public String getMessage() {
return message;
}
public String getAutoMessage() {
return autoMessage;
}
} }