SteamWar/BauSystem2.0
Archiviert
12
0

Update TraceCommand
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful

Signed-off-by: yoyosource <yoyosource@nidido.de>
Dieser Commit ist enthalten in:
yoyosource 2021-12-27 14:23:07 +01:00
Ursprung 3fa36c3442
Commit 40c1e13435
2 geänderte Dateien mit 40 neuen und 84 gelöschten Zeilen

Datei anzeigen

@ -666,6 +666,7 @@ TRACE_MESSAGE_HIDE = §cAlle TNT-Positionen ausgeblendet
TRACE_MESSAGE_DISALLOWED = §cDu darfst hier nicht den TNT-Tracer nutzen TRACE_MESSAGE_DISALLOWED = §cDu darfst hier nicht den TNT-Tracer nutzen
TRACE_COMMAND_HELP_START = §8/§etrace start §8- §7Startet die Aufnahme aller TNT-Positionen TRACE_COMMAND_HELP_START = §8/§etrace start §8- §7Startet die Aufnahme aller TNT-Positionen
TRACE_COMMAND_HELP_SINGLE = §8/§etrace single §8- §7Startet eine einzelne Aufnahme aller TNT-Positionen
TRACE_COMMAND_HELP_STOP = §8/§etrace stop §8- §7Stoppt den TNT-Tracer TRACE_COMMAND_HELP_STOP = §8/§etrace stop §8- §7Stoppt den TNT-Tracer
TRACE_COMMAND_HELP_AUTO = §8/§etrace toggleauto §8- §7Automatischer Aufnahmenstart TRACE_COMMAND_HELP_AUTO = §8/§etrace toggleauto §8- §7Automatischer Aufnahmenstart
TRACE_COMMAND_HELP_SHOW_GUI = §8/§etrace show gui §8- §7Zeigt die Trace show gui TRACE_COMMAND_HELP_SHOW_GUI = §8/§etrace show gui §8- §7Zeigt die Trace show gui

Datei anzeigen

@ -34,8 +34,7 @@ import de.steamwar.bausystem.linkage.LinkageType;
import de.steamwar.bausystem.linkage.Linked; import de.steamwar.bausystem.linkage.Linked;
import de.steamwar.bausystem.shared.ShowMode; import de.steamwar.bausystem.shared.ShowMode;
import de.steamwar.bausystem.utils.ListChatView; import de.steamwar.bausystem.utils.ListChatView;
import de.steamwar.command.SWCommand; import de.steamwar.command.*;
import de.steamwar.command.TypeMapper;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import net.md_5.bungee.api.chat.ClickEvent; import net.md_5.bungee.api.chat.ClickEvent;
import net.md_5.bungee.api.chat.ComponentBuilder; import net.md_5.bungee.api.chat.ComponentBuilder;
@ -46,7 +45,6 @@ import org.bukkit.entity.Player;
import java.util.*; import java.util.*;
import java.util.function.BiFunction; import java.util.function.BiFunction;
import java.util.function.Function;
import java.util.function.Supplier; import java.util.function.Supplier;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@ -105,35 +103,14 @@ public class TraceCommand extends SWCommand {
}; };
} }
@Register(help = true) @Register(value = {"gui"}, description = "TRACE_COMMAND_HELP_GUI")
public void genericHelp(Player p, String... args) { public void guiCommand(@Guard Player p) {
BauSystem.MESSAGE.sendPrefixless("TRACE_COMMAND_HELP_START", p);
BauSystem.MESSAGE.sendPrefixless("TRACE_COMMAND_HELP_STOP", p);
BauSystem.MESSAGE.sendPrefixless("TRACE_COMMAND_HELP_AUTO", p);
BauSystem.MESSAGE.sendPrefixless("TRACE_COMMAND_HELP_SHOW_GUI", p);
BauSystem.MESSAGE.sendPrefixless("TRACE_COMMAND_HELP_SHOW", p);
BauSystem.MESSAGE.sendPrefixless("TRACE_COMMAND_HELP_HIDE", p);
BauSystem.MESSAGE.sendPrefixless("TRACE_COMMAND_HELP_DELETE", p);
BauSystem.MESSAGE.sendPrefixless("TRACE_COMMAND_HELP_LIST", p);
BauSystem.MESSAGE.sendPrefixless("TRACE_COMMAND_HELP_GUI", p);
}
@Register({"gui"})
public void guiCommand(Player p) {
if (!permissionCheck(p)) return;
TraceGui.openGui(p); TraceGui.openGui(p);
} }
@Register({"record", "list"}) @Register(value = {"record", "list"})
@Register({"list"}) @Register(value = {"list"}, description = "TRACE_COMMAND_HELP_LIST")
public void listCommand(Player p) { public void listCommand(@Guard Player player, @OptionalValue("0") int page) {
listCommand(p, 0);
}
@Register(value = {"record", "list"}, noTabComplete = true)
@Register(value = {"list"}, noTabComplete = true)
public void listCommand(Player player, int page) {
if (!permissionCheck(player)) return;
ListChatView.chatView(player, StoredRecords.getRecords(), page, record -> { ListChatView.chatView(player, StoredRecords.getRecords(), page, record -> {
TextComponent component = new TextComponent(); TextComponent component = new TextComponent();
component.setText(BauSystem.MESSAGE.parse("TRACE_RECORD_LIST_ELEMENT", player, record.size())); component.setText(BauSystem.MESSAGE.parse("TRACE_RECORD_LIST_ELEMENT", player, record.size()));
@ -156,20 +133,13 @@ public class TraceCommand extends SWCommand {
} }
@Register(value = {"record", "delete"}, noTabComplete = true) @Register(value = {"record", "delete"}, noTabComplete = true)
public void recordDelete(Player p, int id) { public void recordDelete(@Guard Player p, int id) {
if (!permissionCheck(p)) return;
StoredRecords.remove(id); StoredRecords.remove(id);
BauSystem.MESSAGE.send("TRACE_RECORD_DELETE", p); BauSystem.MESSAGE.send("TRACE_RECORD_DELETE", p);
} }
@Register(value = "record", noTabComplete = true) @Register(value = "record", noTabComplete = true)
public void recordList(Player p, int record) { public void recordList(@Guard Player player, int recordID, @OptionalValue("0") int page) {
recordList(p, record, 0);
}
@Register(value = "record", noTabComplete = true)
public void recordList(Player player, int recordID, int page) {
if (!permissionCheck(player)) return;
Record traceRecord = StoredRecords.get(recordID); Record traceRecord = StoredRecords.get(recordID);
if (traceRecord == null) { if (traceRecord == null) {
BauSystem.MESSAGE.send("TRACE_RECORD_NOT_FOUND", player); BauSystem.MESSAGE.send("TRACE_RECORD_NOT_FOUND", player);
@ -197,8 +167,7 @@ public class TraceCommand extends SWCommand {
} }
@Register(value = {"record", "tnt", "delete"}, noTabComplete = true) @Register(value = {"record", "tnt", "delete"}, noTabComplete = true)
public void deleteRecordTNT(Player player, int recordID, int tntID) { public void deleteRecordTNT(@Guard Player player, int recordID, int tntID) {
if (!permissionCheck(player)) return;
Record record = StoredRecords.get(recordID); Record record = StoredRecords.get(recordID);
if (record == null) { if (record == null) {
BauSystem.MESSAGE.send("TRACE_RECORD_NOT_FOUND", player); BauSystem.MESSAGE.send("TRACE_RECORD_NOT_FOUND", player);
@ -209,13 +178,7 @@ public class TraceCommand extends SWCommand {
} }
@Register(value = "record", noTabComplete = true) @Register(value = "record", noTabComplete = true)
public void recordTNTPositions(Player player, int recordID, @StaticValue("tnt") String tnt, int tntID) { public void recordTNTPositions(@Guard Player player, int recordID, @StaticValue("tnt") String tnt, int tntID, @OptionalValue("0") int page) {
recordTNTPositions(player, recordID, tnt, tntID, 0);
}
@Register(value = "record", noTabComplete = true)
public void recordTNTPositions(Player player, int recordID, @StaticValue("tnt") String tnt, int tntID, int page) {
if (!permissionCheck(player)) return;
Record record = StoredRecords.get(recordID); Record record = StoredRecords.get(recordID);
if (record == null) { if (record == null) {
BauSystem.MESSAGE.send("TRACE_RECORD_NOT_FOUND", player); BauSystem.MESSAGE.send("TRACE_RECORD_NOT_FOUND", player);
@ -242,8 +205,7 @@ public class TraceCommand extends SWCommand {
} }
@Register(value = "record", noTabComplete = true) @Register(value = "record", noTabComplete = true)
public void recordTNTPositions(Player player, int recordID, @StaticValue("tnt") String tnt, int tntID, @StaticValue("fuse") String fuse, int fuseTicks) { public void recordTNTPositions(@Guard Player player, int recordID, @StaticValue("tnt") String tnt, int tntID, @StaticValue("fuse") String fuse, int fuseTicks) {
if (!permissionCheck(player)) return;
Record record = StoredRecords.get(recordID); Record record = StoredRecords.get(recordID);
if (record == null) { if (record == null) {
BauSystem.MESSAGE.send("TRACE_RECORD_NOT_FOUND", player); BauSystem.MESSAGE.send("TRACE_RECORD_NOT_FOUND", player);
@ -266,50 +228,40 @@ public class TraceCommand extends SWCommand {
BauSystem.MESSAGE.sendPrefixless("TRACE_CHAT_POSITION_EXPLODED", player, tntPosition.isExploded()); BauSystem.MESSAGE.sendPrefixless("TRACE_CHAT_POSITION_EXPLODED", player, tntPosition.isExploded());
} }
@Register({"start"}) @Register(value = {"start"}, description = "TRACE_COMMAND_HELP_START")
public void startCommand(Player p) { public void startCommand(@Guard Player p) {
if (!permissionCheck(p)) return;
RecordStateMachine.commandStart(); RecordStateMachine.commandStart();
BauSystem.MESSAGE.send("TRACE_MESSAGE_START", p); BauSystem.MESSAGE.send("TRACE_MESSAGE_START", p);
} }
@Register({"single"}) @Register(value = {"single"}, description = "TRACE_COMMAND_HELP_SINGLE")
public void singleCommand(Player p) { public void singleCommand(@Guard Player p) {
if (!permissionCheck(p)) return;
RecordStateMachine.commandSingle(); RecordStateMachine.commandSingle();
BauSystem.MESSAGE.send("TRACE_MESSAGE_SINGLE", p); BauSystem.MESSAGE.send("TRACE_MESSAGE_SINGLE", p);
} }
@Register({"stop"}) @Register(value = {"stop"}, description = "TRACE_COMMAND_HELP_STOP")
public void stopCommand(Player p) { public void stopCommand(@Guard Player p) {
if (!permissionCheck(p)) return;
RecordStateMachine.commandStop(); RecordStateMachine.commandStop();
BauSystem.MESSAGE.send("TRACE_MESSAGE_STOP", p); BauSystem.MESSAGE.send("TRACE_MESSAGE_STOP", p);
} }
@Register({"auto"}) @Register(value = {"auto"}, description = "TRACE_COMMAND_HELP_AUTO")
@Register({"toggleauto"}) @Register({"toggleauto"})
public void autoCommand(Player p) { public void autoCommand(@Guard Player p) {
if (!permissionCheck(p)) return;
RecordStateMachine.commandAuto(); RecordStateMachine.commandAuto();
BauSystem.MESSAGE.send(RecordStateMachine.getRecordStatus().getAutoMessage(), p); BauSystem.MESSAGE.send(RecordStateMachine.getRecordStatus().getAutoMessage(), p);
} }
@Register(value = {"delete"}, description = "TRACE_COMMAND_HELP_DELETE")
@Register({"clear"}) @Register({"clear"})
public void clearCommand(Player p) { public void deleteCommand(@Guard Player p) {
deleteCommand(p);
}
@Register({"delete"})
public void deleteCommand(Player p) {
if (!permissionCheck(p)) return;
StoredRecords.clear(); StoredRecords.clear();
BauSystem.MESSAGE.send("TRACE_MESSAGE_DELETE", p); BauSystem.MESSAGE.send("TRACE_MESSAGE_DELETE", p);
} }
@Register({"show"}) @Register(value = {"show"}, description = "TRACE_COMMAND_HELP_SHOW")
public void showCommand(Player p, @OptionalValue("entity") ShowModeType showModeType, ShowModeParameterType... showModeParameterTypes) { public void showCommand(@Guard Player p, @OptionalValue("entity") ShowModeType showModeType, ShowModeParameterType... showModeParameterTypes) {
if (!permissionCheck(p)) return;
ShowModeParameter showModeParameter = new ShowModeParameter(); ShowModeParameter showModeParameter = new ShowModeParameter();
for (ShowModeParameterType showModeParameterType : showModeParameterTypes) { for (ShowModeParameterType showModeParameterType : showModeParameterTypes) {
showModeParameterType.getShowModeParameterConsumer().accept(showModeParameter); showModeParameterType.getShowModeParameterConsumer().accept(showModeParameter);
@ -329,25 +281,28 @@ public class TraceCommand extends SWCommand {
private ShowModeParameterType[] removedTypes; private ShowModeParameterType[] removedTypes;
} }
@Register({"show", "gui"}) @Register(value = {"show", "gui"}, description = "TRACE_COMMAND_HELP_SHOW_GUI")
public void showGuiCommand(Player p) { public void showGuiCommand(@Guard Player p) {
if (!permissionCheck(p)) return;
TraceShowGui.openGui(p); TraceShowGui.openGui(p);
} }
@Register({"hide"}) @Register(value = {"hide"}, description = "TRACE_COMMAND_HELP_HIDE")
public void hideCommand(Player p) { public void hideCommand(@Guard Player p) {
if (!permissionCheck(p)) return;
TraceShowManager.hide(p); TraceShowManager.hide(p);
BauSystem.MESSAGE.send("TRACE_MESSAGE_HIDE", p); BauSystem.MESSAGE.send("TRACE_MESSAGE_HIDE", p);
} }
@ClassGuard(value = Player.class, local = true)
private boolean permissionCheck(Player player) { public GuardChecker guardChecker() {
if (!Permission.hasPermission(player, Permission.WORLD)) { return (commandSender, guardCheckType, strings, s) -> {
BauSystem.MESSAGE.send("TRACE_MESSAGE_DISALLOWED", player); Player player = (Player) commandSender;
return false; if (Permission.hasPermission(player, Permission.WORLD)) {
} return GuardResult.ALLOWED;
return true; }
if (guardCheckType != GuardCheckType.TAB_COMPLETE) {
BauSystem.MESSAGE.send("TRACE_MESSAGE_DISALLOWED", player);
}
return GuardResult.DENIED;
};
} }
} }