SteamWar/BauSystem2.0
Archiviert
12
0

Update WarpCommand to new CommandFramework

Signed-off-by: yoyosource <yoyosource@nidido.de>
Dieser Commit ist enthalten in:
yoyosource 2021-12-27 13:48:20 +01:00
Ursprung d6e91098a0
Commit 72cf3f63b5
2 geänderte Dateien mit 30 neuen und 39 gelöschten Zeilen

Datei anzeigen

@ -1077,12 +1077,12 @@ WARP_GUI_DISTANCE=§7Distanz: §e{0} §7Blöcke
WARP_GUI_LCLICK=§7Links klicken zum teleportieren WARP_GUI_LCLICK=§7Links klicken zum teleportieren
WARP_GUI_RCLICK=§7Rechts klicken zum editieren WARP_GUI_RCLICK=§7Rechts klicken zum editieren
WARP_INFO_NAME=§7Name: §e{0} WARP_INFO_NAME=§7Name: §e{0}
WARP_HELP_1=§8/§ewarp add §8[§7Name§8] - §7Erstelle einen neuen Warp Punkt WARP_HELP_ADD=§8/§ewarp add §8[§7Name§8] §8- §7Erstelle einen neuen Warp Punkt
WARP_HELP_2=§8/§ewarp §8[§7Name§8] - §7Teleportiere dich zu einen Warp-Punkt WARP_HELP_TELEPORT=§8/§ewarp §8[§7Name§8] §8- §7Teleportiere dich zu einen Warp-Punkt
WARP_HELP_3=§8/§ewarp info §8[§7Name§8] - §7Infos zu einem Punkt WARP_HELP_INFO=§8/§ewarp info §8[§7Name§8] §8- §7Infos zu einem Punkt
WARP_HELP_4=§8/§ewarp delete §8[§7Name§8] - §7Lösche einen Warp WARP_HELP_DELETE=§8/§ewarp delete §8[§7Name§8] §8- §7Lösche einen Warp
WARP_HELP_5=§8/§ewarp gui - §7Öffne die Warp-GUI WARP_HELP_GUI=§8/§ewarp gui §8- §7Öffne die Warp-GUI
WARP_HELP_6=§8/§ewarp list - §7Liste alle Warp-Punkt auf WARP_HELP_LIST=§8/§ewarp list §8- §7Liste alle Warp-Punkt auf
WARP_MOON_ITEM_NAME=§3Atemkugel WARP_MOON_ITEM_NAME=§3Atemkugel
WARP_MOON_COUNTDOOWN=§7Noch §e§l{0} §7Sekunden! WARP_MOON_COUNTDOOWN=§7Noch §e§l{0} §7Sekunden!

Datei anzeigen

@ -27,9 +27,7 @@ import de.steamwar.bausystem.linkage.LinkageType;
import de.steamwar.bausystem.linkage.Linked; import de.steamwar.bausystem.linkage.Linked;
import de.steamwar.bausystem.utils.ListChatView; import de.steamwar.bausystem.utils.ListChatView;
import de.steamwar.bausystem.worlddata.WorldData; import de.steamwar.bausystem.worlddata.WorldData;
import de.steamwar.command.SWCommand; import de.steamwar.command.*;
import de.steamwar.command.SWCommandUtils;
import de.steamwar.command.TypeMapper;
import net.md_5.bungee.api.ChatColor; import net.md_5.bungee.api.ChatColor;
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;
@ -58,25 +56,14 @@ public class WarpCommand extends SWCommand implements Disable, Enable {
return SWCommandUtils.createMapper(Warp::getWarp, (commandSender, s) -> new ArrayList<>(Warp.getWarpNames())); return SWCommandUtils.createMapper(Warp::getWarp, (commandSender, s) -> new ArrayList<>(Warp.getWarpNames()));
} }
@Register(help = true) @Register(value = "moon", noTabComplete = true)
public void genericHelp(Player player, String... args) { public void tpMoon(Player p) {
if (args.length > 0 && args[0].equals("moon")) { Moon.startMoon(p);
Moon.startMoon(player);
return;
}
BauSystem.MESSAGE.sendPrefixless("COMMAND_HELP_HEAD", player, "Warp");
BauSystem.MESSAGE.sendPrefixless("WARP_HELP_1", player);
BauSystem.MESSAGE.sendPrefixless("WARP_HELP_2", player);
BauSystem.MESSAGE.sendPrefixless("WARP_HELP_3", player);
BauSystem.MESSAGE.sendPrefixless("WARP_HELP_4", player);
BauSystem.MESSAGE.sendPrefixless("WARP_HELP_5", player);
BauSystem.MESSAGE.sendPrefixless("WARP_HELP_6", player);
} }
@Register("add") @Register(value = "add", description = "WARP_HELP_ADD")
@Register("create") @Register("create")
public void addWarp(Player player, String name) { public void addWarp(@Guard Player player, String name) {
if (!permissionCheck(player)) return;
for (String forbiddenName : FORBIDDEN_NAMES) { for (String forbiddenName : FORBIDDEN_NAMES) {
if (name.equalsIgnoreCase(forbiddenName)) { if (name.equalsIgnoreCase(forbiddenName)) {
BauSystem.MESSAGE.send("WARP_NAME_RESERVED", player, name); BauSystem.MESSAGE.send("WARP_NAME_RESERVED", player, name);
@ -91,24 +78,23 @@ public class WarpCommand extends SWCommand implements Disable, Enable {
BauSystem.MESSAGE.send("WARP_CREATED", player, name); BauSystem.MESSAGE.send("WARP_CREATED", player, name);
} }
@Register @Register(description = "WARP_HELP_TELEPORT")
public void tpWarp(Player player, Warp warp) { public void tpWarp(Player player, Warp warp) {
warp.teleport(player); warp.teleport(player);
} }
@Register("delete") @Register(value = "delete", description = "WARP_HELP_DELETE")
public void deleteWarp(Player player, Warp warp) { public void deleteWarp(@Guard Player player, Warp warp) {
if (!permissionCheck(player)) return;
warp.delete(); warp.delete();
BauSystem.MESSAGE.send("WARP_DELETED", player, warp.getName()); BauSystem.MESSAGE.send("WARP_DELETED", player, warp.getName());
} }
@Register("gui") @Register(value = "gui", description = "WARP_HELP_GUI")
public void gui(Player player) { public void gui(Player player) {
WarpGui.openGui(player); WarpGui.openGui(player);
} }
@Register("list") @Register(value = "list", description = "WARP_HELP_LIST")
public void listWarps(Player player) { public void listWarps(Player player) {
listWarps(player, 0); listWarps(player, 0);
} }
@ -131,7 +117,7 @@ public class WarpCommand extends SWCommand implements Disable, Enable {
}); });
} }
@Register("info") @Register(value = "info", description = "WARP_HELP_INFO")
public void warpInfo(Player player, Warp warp) { public void warpInfo(Player player, Warp warp) {
BauSystem.MESSAGE.send("COMMAND_HELP_HEAD", player, warp.getName()); BauSystem.MESSAGE.send("COMMAND_HELP_HEAD", player, warp.getName());
BauSystem.MESSAGE.sendPrefixless("WARP_INFO_NAME", player, warp.getName()); BauSystem.MESSAGE.sendPrefixless("WARP_INFO_NAME", player, warp.getName());
@ -141,13 +127,18 @@ public class WarpCommand extends SWCommand implements Disable, Enable {
BauSystem.MESSAGE.sendPrefixless("WARP_GUI_DISTANCE", player, warp.getLocation().distance(player.getLocation())); BauSystem.MESSAGE.sendPrefixless("WARP_GUI_DISTANCE", player, warp.getLocation().distance(player.getLocation()));
} }
@SuppressWarnings("BooleanMethodIsAlwaysInverted") @ClassGuard(value = Player.class, local = true)
private boolean permissionCheck(Player player) { public GuardChecker commandGuard() {
if (!Permission.hasPermission(player, Permission.WORLD)) { return (commandSender, guardCheckType, strings, s) -> {
BauSystem.MESSAGE.send("WARP_DISALLOWED", player); Player player = (Player) commandSender;
return false; if (!Permission.hasPermission(player, Permission.WORLD)) {
} if (guardCheckType != GuardCheckType.TAB_COMPLETE) {
return true; BauSystem.MESSAGE.send("WARP_DISALLOWED", player);
}
return GuardResult.DENIED;
}
return GuardResult.ALLOWED;
};
} }
@Linked(LinkageType.COMMAND) @Linked(LinkageType.COMMAND)