Signed-off-by: yoyosource <yoyosource@nidido.de>
Dieser Commit ist enthalten in:
Ursprung
32c78938b6
Commit
de6779c8c3
@ -534,6 +534,7 @@ TRACE_COMMAND_HELP_SHOW_GUI = §8/§etrace show gui §8- §7Zeigt die Trace show
|
||||
TRACE_COMMAND_HELP_SHOW = §8/§etrace show §8- <§e-water§8|§e-interpolate-xz§8|-interpolate-y§8> - §7Zeigt alle TNT-Positionen
|
||||
TRACE_COMMAND_HELP_HIDE = §8/§etrace hide §8- §7Versteckt alle TNT-Positionen
|
||||
TRACE_COMMAND_HELP_DELETE = §8/§etrace delete §8- §7Löscht alle TNT-Positionen
|
||||
TRACE_COMMAND_HELP_LIST = §8/§etrace list §8- §7Trace GUI nur im Chat
|
||||
TRACE_COMMAND_HELP_GUI = §8/§etrace gui §8- §7Zeigt die Trace Oberfläche an
|
||||
|
||||
TRACE_GUI_NAME = Tracer Gui
|
||||
@ -574,6 +575,21 @@ TRACE_RECORD_LIST_ELEMENT = §eTrace §8- §e{0} §7TNT
|
||||
TRACE_RECORD_LIST_ELEMENT_HOVER = §7Zeige alle §eTNT §7aus diesem Trace
|
||||
TRACE_RECORD_LIST_ELEMENT_DELETE = §7 §cLöschen
|
||||
TRACE_RECORD_LIST_ELEMENT_DELETE_HOVER = §7Trace §clöschen
|
||||
TRACE_RECORD_DELETE = §7Trace gelöscht
|
||||
TRACE_RECORD_NOT_FOUND = §7Unbekannter Trace
|
||||
TRACE_RECORD_ELEMENT = §eTNT §8- §e{0} §7Positionen
|
||||
TRACE_RECORD_ELEMENT_HOVER = §7Zeige alle §ePositionen §7aus diesem TNT
|
||||
TRACE_RECORD_ELEMENT_DELETE = §7 §cLöschen
|
||||
TRACE_RECORD_ELEMENT_DELETE_HOVER = §7Trace §clöschen
|
||||
TRACE_RECORD_TNT_NOT_FOUND = §7Unbekanntes TNT
|
||||
TRACE_TNT_ELEMENT = §ePosition §8- §e{0} §7FuseTicks
|
||||
TRACE_TNT_ELEMENT_HOVER = §7Zeige Infos zur §ePosition §7an
|
||||
TRACE_RECORD_TNT_POSITION_NOT_FOUND = §7Unbekannte TNT Position
|
||||
TRACE_CHAT_POSITION_HEAD = §ePosition
|
||||
TRACE_CHAT_POSITION_X = §7X§8: §e{0}
|
||||
TRACE_CHAT_POSITION_Y = §7Y§8: §e{0}
|
||||
TRACE_CHAT_POSITION_Z = §7Z§8: §e{0}
|
||||
TRACE_CHAT_POSITION_EXPLODED = §7Explodiert§8: §e{0}
|
||||
|
||||
# Loader
|
||||
LOADER_OFF = §caus
|
||||
|
@ -21,39 +21,30 @@ package de.steamwar.bausystem.features.tracer;
|
||||
|
||||
import de.steamwar.bausystem.features.tracer.show.Record;
|
||||
import de.steamwar.bausystem.shared.Position;
|
||||
import org.bukkit.entity.Entity;
|
||||
import lombok.Getter;
|
||||
import org.bukkit.entity.TNTPrimed;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
@Getter
|
||||
public class TNTPosition extends Position {
|
||||
|
||||
private final Record.TNTRecord record;
|
||||
private final int fuseTicks;
|
||||
private final Vector previousLocation;
|
||||
private final boolean exploded;
|
||||
|
||||
public TNTPosition(Record.TNTRecord record, Entity entity, Vector previousLocation, boolean exploded) {
|
||||
public TNTPosition(Record.TNTRecord record, TNTPrimed entity, Vector previousLocation, boolean exploded) {
|
||||
super(entity.getLocation().toVector());
|
||||
this.record = record;
|
||||
this.fuseTicks = entity.getFuseTicks();
|
||||
this.previousLocation = previousLocation;
|
||||
this.exploded = exploded;
|
||||
}
|
||||
|
||||
public Vector getPreviousLocation() {
|
||||
return previousLocation;
|
||||
}
|
||||
|
||||
public boolean isExploded() {
|
||||
return exploded;
|
||||
}
|
||||
|
||||
public Record.TNTRecord getRecord() {
|
||||
return record;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Position{" +
|
||||
"location=" + super.getLocation() +
|
||||
'}';
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -24,25 +24,25 @@ import de.steamwar.bausystem.Permission;
|
||||
import de.steamwar.bausystem.features.tracer.gui.TraceGui;
|
||||
import de.steamwar.bausystem.features.tracer.gui.TraceShowGui;
|
||||
import de.steamwar.bausystem.features.tracer.record.RecordStateMachine;
|
||||
import de.steamwar.bausystem.features.tracer.show.ShowModeParameter;
|
||||
import de.steamwar.bausystem.features.tracer.show.ShowModeParameterType;
|
||||
import de.steamwar.bausystem.features.tracer.show.StoredRecords;
|
||||
import de.steamwar.bausystem.features.tracer.show.TraceShowManager;
|
||||
import de.steamwar.bausystem.features.tracer.show.*;
|
||||
import de.steamwar.bausystem.features.tracer.show.mode.BlockShowMode;
|
||||
import de.steamwar.bausystem.features.tracer.show.mode.ParticleShowMode;
|
||||
import de.steamwar.bausystem.features.tracer.show.mode.TraceEntityShowMode;
|
||||
import de.steamwar.bausystem.linkage.LinkageType;
|
||||
import de.steamwar.bausystem.linkage.Linked;
|
||||
import de.steamwar.bausystem.utils.ListChatView;
|
||||
import de.steamwar.command.SWCommand;
|
||||
import de.steamwar.command.SWCommandUtils;
|
||||
import de.steamwar.command.TypeMapper;
|
||||
import lombok.NonNull;
|
||||
import net.md_5.bungee.api.chat.ClickEvent;
|
||||
import net.md_5.bungee.api.chat.ComponentBuilder;
|
||||
import net.md_5.bungee.api.chat.HoverEvent;
|
||||
import net.md_5.bungee.api.chat.TextComponent;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.*;
|
||||
|
||||
@Linked(LinkageType.COMMAND)
|
||||
public class TraceCommand extends SWCommand {
|
||||
@ -97,9 +97,8 @@ public class TraceCommand extends SWCommand {
|
||||
BauSystem.MESSAGE.sendPrefixless("TRACE_COMMAND_HELP_SHOW", p);
|
||||
BauSystem.MESSAGE.sendPrefixless("TRACE_COMMAND_HELP_HIDE", p);
|
||||
BauSystem.MESSAGE.sendPrefixless("TRACE_COMMAND_HELP_DELETE", p);
|
||||
// p.sendMessage("§8/§etrace list §8<§7FRAME-ID§8> §8- §7Listet alle TNT auf");
|
||||
BauSystem.MESSAGE.sendPrefixless("TRACE_COMMAND_HELP_LIST", p);
|
||||
BauSystem.MESSAGE.sendPrefixless("TRACE_COMMAND_HELP_GUI", p);
|
||||
// p.sendMessage("§7Optionale Parameter mit §8<>§7, Benötigte Parameter mit §8[]");
|
||||
}
|
||||
|
||||
@Register({"gui"})
|
||||
@ -108,6 +107,147 @@ public class TraceCommand extends SWCommand {
|
||||
TraceGui.openGui(p);
|
||||
}
|
||||
|
||||
@Register({"record", "list"})
|
||||
@Register({"list"})
|
||||
public void listCommand(Player p) {
|
||||
listCommand(p, 0);
|
||||
}
|
||||
|
||||
@Register({"record", "list"})
|
||||
@Register({"list"})
|
||||
public void listCommand(Player player, int page) {
|
||||
if (!permissionCheck(player)) return;
|
||||
ListChatView.chatView(player, StoredRecords.getRecords(), page, record -> {
|
||||
TextComponent component = new TextComponent();
|
||||
component.setText(BauSystem.MESSAGE.parse("TRACE_RECORD_LIST_ELEMENT", player, record.size()));
|
||||
component.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/trace record " + record.getId()));
|
||||
component.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, TextComponent.fromLegacyText(BauSystem.MESSAGE.parse("TRACE_RECORD_LIST_ELEMENT_HOVER", player))));
|
||||
|
||||
TextComponent deleteComponent = new TextComponent();
|
||||
deleteComponent.setText(BauSystem.MESSAGE.parse("TRACE_RECORD_LIST_ELEMENT_DELETE", player));
|
||||
deleteComponent.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/trace record delete " + record.getId()));
|
||||
deleteComponent.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, TextComponent.fromLegacyText(BauSystem.MESSAGE.parse("TRACE_RECORD_LIST_ELEMENT_DELETE_HOVER", player))));
|
||||
component.addExtra(deleteComponent);
|
||||
return component;
|
||||
}, (beforePageComponent, beforePage) -> {
|
||||
beforePageComponent.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder(BauSystem.MESSAGE.parse("LIST_PREVIOUS_PAGE", player)).create()));
|
||||
beforePageComponent.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/trace record list " + beforePage));
|
||||
}, (afterPageComponent, afterPage) -> {
|
||||
afterPageComponent.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder(BauSystem.MESSAGE.parse("LIST_NEXT_PAGE", player)).create()));
|
||||
afterPageComponent.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/trace record list " + afterPage));
|
||||
});
|
||||
}
|
||||
|
||||
@Register({"record", "delete"})
|
||||
public void recordDelete(Player p, int id) {
|
||||
if (!permissionCheck(p)) return;
|
||||
StoredRecords.remove(id);
|
||||
BauSystem.MESSAGE.send("TRACE_RECORD_DELETE", p);
|
||||
}
|
||||
|
||||
@Register("record")
|
||||
public void recordList(Player p, int record) {
|
||||
recordList(p, record, 0);
|
||||
}
|
||||
|
||||
@Register("record")
|
||||
public void recordList(Player player, int recordID, int page) {
|
||||
if (!permissionCheck(player)) return;
|
||||
Record record = StoredRecords.get(recordID);
|
||||
if (record == null) {
|
||||
BauSystem.MESSAGE.send("TRACE_RECORD_NOT_FOUND", player);
|
||||
return;
|
||||
}
|
||||
ListChatView.chatView(player, record.getTnt(), page, tntRecord -> {
|
||||
TextComponent component = new TextComponent();
|
||||
component.setText(BauSystem.MESSAGE.parse("TRACE_RECORD_ELEMENT", player, tntRecord.getPositions().size()));
|
||||
component.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/trace record " + record.getId() + " tnt " + tntRecord.getId()));
|
||||
component.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, TextComponent.fromLegacyText(BauSystem.MESSAGE.parse("TRACE_RECORD_ELEMENT_HOVER", player))));
|
||||
|
||||
TextComponent deleteComponent = new TextComponent();
|
||||
deleteComponent.setText(BauSystem.MESSAGE.parse("TRACE_RECORD_ELEMENT_DELETE", player));
|
||||
deleteComponent.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/trace record tnt delete " + record.getId() + " " + tntRecord.getId()));
|
||||
deleteComponent.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, TextComponent.fromLegacyText(BauSystem.MESSAGE.parse("TRACE_RECORD_ELEMENT_DELETE_HOVER", player))));
|
||||
component.addExtra(deleteComponent);
|
||||
return component;
|
||||
}, (beforePageComponent, beforePage) -> {
|
||||
beforePageComponent.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder(BauSystem.MESSAGE.parse("LIST_PREVIOUS_PAGE", player)).create()));
|
||||
beforePageComponent.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/trace record " + record.getId() + " " + beforePage));
|
||||
}, (afterPageComponent, afterPage) -> {
|
||||
afterPageComponent.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder(BauSystem.MESSAGE.parse("LIST_NEXT_PAGE", player)).create()));
|
||||
afterPageComponent.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/trace record " + record.getId() + " " + afterPage));
|
||||
});
|
||||
}
|
||||
|
||||
@Register({"record", "tnt", "delete"})
|
||||
public void deleteRecordTNT(Player player, int recordID, int tntID) {
|
||||
if (!permissionCheck(player)) return;
|
||||
Record record = StoredRecords.get(recordID);
|
||||
if (record == null) {
|
||||
BauSystem.MESSAGE.send("TRACE_RECORD_NOT_FOUND", player);
|
||||
return;
|
||||
}
|
||||
record.remove(tntID);
|
||||
}
|
||||
|
||||
@Register("record")
|
||||
public void recordTNTPositions(Player player, int recordID, @Mapper("tnt") String tnt, int tntID) {
|
||||
recordTNTPositions(player, recordID, tnt, tntID, 0);
|
||||
}
|
||||
|
||||
@Register("record")
|
||||
public void recordTNTPositions(Player player, int recordID, @Mapper("tnt") String tnt, int tntID, int page) {
|
||||
if (!permissionCheck(player)) return;
|
||||
Record record = StoredRecords.get(recordID);
|
||||
if (record == null) {
|
||||
BauSystem.MESSAGE.send("TRACE_RECORD_NOT_FOUND", player);
|
||||
return;
|
||||
}
|
||||
Record.TNTRecord tntRecord = record.get(tntID);
|
||||
if (tntRecord == null) {
|
||||
BauSystem.MESSAGE.send("TRACE_RECORD_TNT_NOT_FOUND", player);
|
||||
return;
|
||||
}
|
||||
ListChatView.chatView(player, tntRecord.getPositions(), page, tntPosition -> {
|
||||
TextComponent component = new TextComponent();
|
||||
component.setText(BauSystem.MESSAGE.parse("TRACE_TNT_ELEMENT", player, tntPosition.getFuseTicks()));
|
||||
component.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/trace record " + record.getId() + " tnt " + tntRecord.getId() + " fuse " + tntPosition.getFuseTicks()));
|
||||
component.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, TextComponent.fromLegacyText(BauSystem.MESSAGE.parse("TRACE_TNT_ELEMENT_HOVER", player))));
|
||||
return component;
|
||||
}, (beforePageComponent, beforePage) -> {
|
||||
beforePageComponent.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder(BauSystem.MESSAGE.parse("LIST_PREVIOUS_PAGE", player)).create()));
|
||||
beforePageComponent.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/trace record " + record.getId() + " tnt " + beforePage));
|
||||
}, (afterPageComponent, afterPage) -> {
|
||||
afterPageComponent.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder(BauSystem.MESSAGE.parse("LIST_NEXT_PAGE", player)).create()));
|
||||
afterPageComponent.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/trace record " + record.getId() + " tnt " + afterPage));
|
||||
});
|
||||
}
|
||||
|
||||
@Register("record")
|
||||
public void recordTNTPositions(Player player, int recordID, @Mapper("tnt") String tnt, int tntID, @Mapper("fuse") String fuse, int fuseTicks) {
|
||||
if (!permissionCheck(player)) return;
|
||||
Record record = StoredRecords.get(recordID);
|
||||
if (record == null) {
|
||||
BauSystem.MESSAGE.send("TRACE_RECORD_NOT_FOUND", player);
|
||||
return;
|
||||
}
|
||||
Record.TNTRecord tntRecord = record.get(tntID);
|
||||
if (tntRecord == null) {
|
||||
BauSystem.MESSAGE.send("TRACE_RECORD_TNT_NOT_FOUND", player);
|
||||
return;
|
||||
}
|
||||
TNTPosition tntPosition = tntRecord.get(fuseTicks);
|
||||
if (tntPosition == null) {
|
||||
BauSystem.MESSAGE.send("TRACE_RECORD_TNT_POSITION_NOT_FOUND", player);
|
||||
return;
|
||||
}
|
||||
BauSystem.MESSAGE.sendPrefixless("TRACE_CHAT_POSITION_HEAD", player);
|
||||
BauSystem.MESSAGE.sendPrefixless("TRACE_CHAT_POSITION_X", player, tntPosition.getLocation().getX());
|
||||
BauSystem.MESSAGE.sendPrefixless("TRACE_CHAT_POSITION_Y", player, tntPosition.getLocation().getY());
|
||||
BauSystem.MESSAGE.sendPrefixless("TRACE_CHAT_POSITION_Z", player, tntPosition.getLocation().getZ());
|
||||
BauSystem.MESSAGE.sendPrefixless("TRACE_CHAT_POSITION_EXPLODED", player, tntPosition.isExploded());
|
||||
}
|
||||
|
||||
@Register({"start"})
|
||||
public void startCommand(Player p) {
|
||||
if (!permissionCheck(p)) return;
|
||||
@ -219,4 +359,40 @@ public class TraceCommand extends SWCommand {
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Mapper(value = "tnt", local = true)
|
||||
public TypeMapper<String> tntTypeMapper() {
|
||||
return new TypeMapper<String>() {
|
||||
@Override
|
||||
public String map(CommandSender commandSender, String[] previousArguments, String s) {
|
||||
if (s.equals("tnt")) {
|
||||
return "tnt";
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> tabCompletes(CommandSender commandSender, String[] strings, String s) {
|
||||
return Collections.singletonList("tnt");
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@Mapper(value = "fuse", local = true)
|
||||
public TypeMapper<String> fuseTypeMapper() {
|
||||
return new TypeMapper<String>() {
|
||||
@Override
|
||||
public String map(CommandSender commandSender, String[] previousArguments, String s) {
|
||||
if (s.equals("fuse")) {
|
||||
return "fuse";
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> tabCompletes(CommandSender commandSender, String[] strings, String s) {
|
||||
return Collections.singletonList("fuse");
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -28,21 +28,19 @@ import org.bukkit.entity.TNTPrimed;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@Getter
|
||||
public class Record {
|
||||
|
||||
private final long startTime;
|
||||
private static long idNumber = 0;
|
||||
|
||||
@Getter
|
||||
private final long id = idNumber++;
|
||||
private final long startTime = TPSUtils.currentTick.get();
|
||||
private final List<TNTRecord> tnt = new ArrayList<>();
|
||||
|
||||
public int size() {
|
||||
return tnt.size();
|
||||
}
|
||||
|
||||
public long getStartTime() {
|
||||
return startTime;
|
||||
}
|
||||
|
||||
public void showAll(ShowMode<TNTPosition> mode) {
|
||||
for (TNTRecord record : tnt)
|
||||
record.showAll(mode);
|
||||
@ -50,7 +48,6 @@ public class Record {
|
||||
|
||||
/* The following methods should only be called by a recorder */
|
||||
public Record() {
|
||||
startTime = TPSUtils.currentTick.get();
|
||||
StoredRecords.add(this);
|
||||
}
|
||||
|
||||
@ -64,9 +61,21 @@ public class Record {
|
||||
tnt.clear();
|
||||
}
|
||||
|
||||
public static class TNTRecord {
|
||||
public TNTRecord get(int id) {
|
||||
for (TNTRecord record : tnt) {
|
||||
if (record.getId() == id) return record;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public void remove(int id) {
|
||||
tnt.removeIf(record -> record.getId() == id);
|
||||
}
|
||||
|
||||
@Getter
|
||||
public static class TNTRecord {
|
||||
|
||||
private final long id = idNumber++;
|
||||
private final List<TNTPosition> positions = new ArrayList<>(41);
|
||||
|
||||
public void showAll(ShowMode<TNTPosition> mode) {
|
||||
@ -74,6 +83,13 @@ public class Record {
|
||||
mode.show(position);
|
||||
}
|
||||
|
||||
public TNTPosition get(int fuseTicks) {
|
||||
for (TNTPosition position : positions) {
|
||||
if (position.getFuseTicks() == fuseTicks) return position;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/* The following methods should only be called by a recorder */
|
||||
public void add(TNTPrimed tntPrimed) {
|
||||
add(tntPrimed, false);
|
||||
|
@ -36,6 +36,21 @@ public class StoredRecords {
|
||||
records.add(record);
|
||||
}
|
||||
|
||||
public static void remove(Record record) {
|
||||
records.remove(record);
|
||||
}
|
||||
|
||||
public static void remove(int id) {
|
||||
records.removeIf(record -> record.getId() == id);
|
||||
}
|
||||
|
||||
public static Record get(int id) {
|
||||
for (Record record : records) {
|
||||
if (record.getId() == id) return record;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static void showAll(ShowMode<TNTPosition> mode) {
|
||||
for (Record record : records) record.showAll(mode);
|
||||
}
|
||||
|
In neuem Issue referenzieren
Einen Benutzer sperren