From 4c44bc0a833e005c7ad125d4b21800b5a5e552f6 Mon Sep 17 00:00:00 2001 From: yoyosource Date: Tue, 6 Sep 2022 17:13:15 +0200 Subject: [PATCH 1/6] Update BauCommand --- .../bungeecore/commands/BauCommand.java | 292 +++++++++--------- .../bungeecore/commands/FightCommand.java | 48 --- 2 files changed, 150 insertions(+), 190 deletions(-) diff --git a/src/de/steamwar/bungeecore/commands/BauCommand.java b/src/de/steamwar/bungeecore/commands/BauCommand.java index 41496b9..4c1fa11 100644 --- a/src/de/steamwar/bungeecore/commands/BauCommand.java +++ b/src/de/steamwar/bungeecore/commands/BauCommand.java @@ -26,6 +26,9 @@ import de.steamwar.bungeecore.network.NetworkSender; import de.steamwar.bungeecore.sql.BauweltMember; import de.steamwar.bungeecore.sql.SteamwarUser; import de.steamwar.bungeecore.util.Chat19; +import de.steamwar.command.SWCommand; +import de.steamwar.command.TypeMapper; +import de.steamwar.command.TypeValidator; import de.steamwar.messages.ChatSender; import de.steamwar.network.packets.server.BaumemberUpdatePacket; import net.md_5.bungee.api.CommandSender; @@ -33,78 +36,90 @@ import net.md_5.bungee.api.ProxyServer; import net.md_5.bungee.api.config.ServerInfo; import net.md_5.bungee.api.connection.ProxiedPlayer; -public class BauCommand extends BasicCommand { +import java.util.Collection; +import java.util.HashMap; +import java.util.Map; + +public class BauCommand extends SWCommand { public BauCommand(){ super("bau", null, "b", "build", "gs"); } - @Override - public void execute(CommandSender sender, String[] args) { - if(!(sender instanceof ProxiedPlayer)) { - return; - } - - ProxiedPlayer p = (ProxiedPlayer) sender; - - versionSelector(p, args, 0, - () -> new ServerStarter().build19(p.getUniqueId()).send(p).start(), - () -> new ServerStarter().build15(p.getUniqueId()).send(p).start(), + @Register + public void toBau(ProxiedPlayer p, @Mapper("version") @OptionalValue("") int version) { + versionSelector(version, () -> new ServerStarter().build12(p.getUniqueId()).send(p).start(), - () -> { - switch (args[0].toLowerCase()) { - case "addmember": - addmember(p, args); - break; - case "tp": - case "teleport": - teleport(p, args); - break; - case "info": - Chat19.chat(p, "/bauinfo"); - break; - case "togglewe": - togglewe(p, args); - break; - case "toggleworld": - toggleworld(p, args); - break; - case "delmember": - delmember(p, args); - break; - case "resetall": - case "delete": - delete(p, args); - break; - case "testarena": - case "test": - testarena(p, args); - break; - default: - HelpCommand.sendBauHelp(ChatSender.of(p)); - } - } + () -> new ServerStarter().build15(p.getUniqueId()).send(p).start(), + () -> new ServerStarter().build19(p.getUniqueId()).send(p).start(), + () -> HelpCommand.sendBauHelp(ChatSender.of(p)) ); } - private static void addmember(ProxiedPlayer p, String[] args){ - if (args.length == 1) { - Message.send("BAU_ADDMEMBER_USAGE", p); - return; + public void versionSelector(int version, Runnable r12, Runnable r15, Runnable r19, Runnable rDefault) { + switch (version) { + case 12: + r12.run(); + break; + case 15: + r15.run(); + break; + case 19: + r19.run(); + break; + default: + rDefault.run(); + break; } + } - SteamwarUser target = SteamwarUser.get(args[1]); - if (target == null) { - Message.send("UNKNOWN_PLAYER", p); - return; - }else if(target.getUuid().equals(p.getUniqueId())) { - Message.send("BAU_ADDMEMBER_SELFADD", p); - return; - }else if (BauweltMember.getBauMember(p.getUniqueId(), target.getUuid()) != null) { - Message.send("BAU_ADDMEMBER_ISADDED", p); - return; - } + @Mapper(value = "version", local = true) + public TypeMapper versionMapper() { + Map versionMap = new HashMap<>(); + versionMap.put("19", 19); + versionMap.put("1.19", 19); + versionMap.put("mwg", 19); + versionMap.put("miniwargear", 19); + versionMap.put("wg", 19); + versionMap.put("wargear", 19); + versionMap.put("ws", 15); + versionMap.put("15", 15); + versionMap.put("1.15", 15); + versionMap.put("warship", 15); + versionMap.put("as", 15); + versionMap.put("airship", 15); + + versionMap.put("12", 12); + versionMap.put("1.12", 12); + + return new TypeMapper() { + @Override + public Integer map(CommandSender commandSender, String[] previousArguments, String s) { + if (commandSender == null) return null; + ProxiedPlayer player = (ProxiedPlayer) commandSender; + if (s.isEmpty()) { + int version = player.getPendingConnection().getVersion(); + if (version > 578) { // Version > 1.15.2 + return 19; + } else if (version > 340) { // Version > 1.12.2 + return 15; + } else { + return 12; + } + } + return versionMap.get(s.toLowerCase()); + } + + @Override + public Collection tabCompletes(CommandSender sender, String[] previousArguments, String s) { + return versionMap.keySet(); + } + }; + } + + @Register(value = "addmember", description = "BAU_ADDMEMBER_USAGE") + public void addmember(ProxiedPlayer p, @Validator("addMemberTarget") SteamwarUser target) { new BauweltMember(p.getUniqueId(), target.getUuid(), false, false); Message.send("BAU_ADDMEMBER_ADDED", p); @@ -113,71 +128,66 @@ public class BauCommand extends BasicCommand { Message.send("BAU_ADDMEMBER_ADDED_TARGET", z, p.getName()); } - private static void teleport(ProxiedPlayer p, String[] args){ - if (args.length == 1) { - Message.send("BAU_TP_USAGE", p); - return; - } + @Validator(value = "addMemberTarget", local = true) + public TypeValidator addMemberTargetValidator() { + return (sender, value, messageSender) -> { + if (value == null) { + messageSender.send("UNKNOWN_PLAYER"); + return false; + } + if (((ProxiedPlayer) sender).getUniqueId().equals(value.getUuid())) { + messageSender.send("BAU_ADDMEMBER_SELFADD"); + return false; + } + if (BauweltMember.getBauMember(((ProxiedPlayer) sender).getUniqueId(), value.getUuid()) != null) { + messageSender.send("BAU_ADDMEMBER_ISADDED"); + return false; + } + return true; + }; + } - SteamwarUser worldOwner = SteamwarUser.get(args[1]); - if (worldOwner == null) { - Message.send("UNKNOWN_PLAYER", p); - return; - }else if (!p.getUniqueId().equals(worldOwner.getUuid()) && BauweltMember.getBauMember(worldOwner.getUuid(), p.getUniqueId()) == null){ - SubserverSystem.sendDeniedMessage(p, worldOwner.getUuid()); - Message.send("BAU_TP_NOALLOWED", p); - return; - } - - versionSelector(p, args, 2, + @Register(value = "tp", description = "BAU_TP_USAGE") + @Register("teleport") + public void teleport(ProxiedPlayer p, @Validator("teleportTarget") SteamwarUser worldOwner, @Mapper("version") @OptionalValue("") int version) { + versionSelector(version, () -> new ServerStarter().build19(worldOwner.getUuid()).send(p).start(), () -> new ServerStarter().build15(worldOwner.getUuid()).send(p).start(), () -> new ServerStarter().build12(worldOwner.getUuid()).send(p).start(), - () -> HelpCommand.sendBauHelp(ChatSender.of(p))); + () -> HelpCommand.sendBauHelp(ChatSender.of(p)) + ); } - private static void versionSelector(ProxiedPlayer p, String[] args, int pos, Runnable run19, Runnable run15, Runnable run12, Runnable runElse) { - if(args.length <= pos) { - int version = p.getPendingConnection().getVersion(); - if(version > 578) { // Version > 1.15.2 - run19.run(); - } else if(version > 340) { // Version > 1.12.2 - run15.run(); - } else { - run12.run(); + @Validator(value = "teleportTarget", local = true) + public TypeValidator teleportTargetValidator() { + return (sender, value, messageSender) -> { + if (value == null) { + messageSender.send("UNKNOWN_PLAYER"); + return false; } + ProxiedPlayer p = (ProxiedPlayer) sender; + if (!p.getUniqueId().equals(value.getUuid()) && BauweltMember.getBauMember(value.getUuid(), p.getUniqueId()) == null) { + SubserverSystem.sendDeniedMessage(p, value.getUuid()); + messageSender.send("BAU_TP_NOALLOWED"); + return false; + } + return true; + }; + } + + @Register("info") + public void info(ProxiedPlayer p) { + Chat19.chat(p, "/bauinfo"); + } + + @Register("togglewe") + public void togglewe(ProxiedPlayer p, @AllowNull @OptionalValue("") SteamwarUser user) { + if (user == null) { + Message.send("BAU_MEMBER_TOGGLE_USAGE", p, "togglewe"); return; } - - switch (args[pos].toLowerCase()) { - case "19": - case "1.19": - case "mwg": - case "miniwargear": - run19.run(); - break; - case "ws": - case "warship": - case "as": - case "airship": - case "wg": - case "wargear": - case "15": - case "1.15": - run15.run(); - break; - case "12": - case "1.12": - run12.run(); - break; - default: - runElse.run(); - } - } - - private static void togglewe(ProxiedPlayer p, String[] args){ - BauweltMember target = toggle(p, args, "togglewe"); - if(target == null) + BauweltMember target = member(p, user); + if (target == null) return; target.setWorldEdit(!target.isWorldEdit()); @@ -185,9 +195,14 @@ public class BauCommand extends BasicCommand { isAllowedTo(target.isWorldEdit(), p, target, "BAU_MEMBER_TOGGLE_WORLD_EDIT"); } - private static void toggleworld(ProxiedPlayer p, String[] args){ - BauweltMember target = toggle(p, args, "toggleworld"); - if(target == null) + @Register("toggleworld") + public void toggleworld(ProxiedPlayer p, @AllowNull @OptionalValue("") SteamwarUser user) { + if (user == null) { + Message.send("BAU_MEMBER_TOGGLE_USAGE", p, "toggleworld"); + return; + } + BauweltMember target = member(p, user); + if (target == null) return; target.setWorld(!target.isWorld()); @@ -205,14 +220,10 @@ public class BauCommand extends BasicCommand { } } - private static void delmember(ProxiedPlayer p, String[] args){ - if (args.length == 1) { - Message.send("BAU_DELMEMBER_USAGE", p); - return; - } - - BauweltMember target = member(p, SteamwarUser.get(args[1])); - if(target == null) + @Register(value = "delmember", description = "BAU_DELMEMBER_USAGE") + public void delmember(ProxiedPlayer p, SteamwarUser user) { + BauweltMember target = member(p, user); + if (target == null) return; if(SteamwarUser.get(target.getMemberID()).getUuid().equals(p.getUniqueId())) { @@ -232,13 +243,16 @@ public class BauCommand extends BasicCommand { Message.send("BAU_DELMEMBER_DELETED", p); } - private static void delete(ProxiedPlayer p, String[] args){ + @Register("resetall") + @Register("delete") + public void delete(ProxiedPlayer p, @Mapper("version") @OptionalValue("") int version) { SteamwarUser user = SteamwarUser.get(p.getUniqueId()); - versionSelector(p, args, 1, + versionSelector(version, () -> deleteConfirmation(p, () -> deleteWorld(p, ServerStarter.WORLDS19_PATH + user.getId())), () -> deleteConfirmation(p, () -> deleteWorld(p, ServerStarter.WORLDS15_PATH + user.getId())), () -> deleteConfirmation(p, () -> deleteWorld(p, ServerStarter.WORLDS12_PATH + p.getUniqueId().toString())), - () -> HelpCommand.sendBauHelp(ChatSender.of(p))); + () -> HelpCommand.sendBauHelp(ChatSender.of(p)) + ); } private static void deleteConfirmation(ProxiedPlayer p, Runnable worldDeletion) { @@ -266,8 +280,12 @@ public class BauCommand extends BasicCommand { }); } - private static void testarena(ProxiedPlayer p, String[] args){ - FightCommand.createArena(p, "/bau testarena ", false, args, 1, false, (player, mode, map) -> ProxyServer.getInstance().getScheduler().runAsync(BungeeCore.get(), () -> new ServerStarter().test(mode, map, p).start())); + @Register("test") + @Register("testarena") + public void testarena(ProxiedPlayer p, @Mapper("nonHistoricArenaMode") @OptionalValue("") @AllowNull ArenaMode arenaMode, @Mapper("arenaMap") @OptionalValue("") @AllowNull String map) { + FightCommand.createArena(p, "/bau testarena ", false, arenaMode, map, false, (player, mode, m) -> { + ProxyServer.getInstance().getScheduler().runAsync(BungeeCore.get(), () -> new ServerStarter().test(mode, map, p).start()); + }); } private static BauweltMember member(ProxiedPlayer p, SteamwarUser member){ @@ -284,16 +302,6 @@ public class BauCommand extends BasicCommand { return target; } - private static BauweltMember toggle(ProxiedPlayer p, String[] args, String subcommand){ - if (args.length == 1) { - Message.send("BAU_MEMBER_TOGGLE_USAGE", p, subcommand); - return null; - } - - SteamwarUser member = SteamwarUser.get(args[1]); - return member(p, member); - } - private static void isAllowedTo(boolean permission, ProxiedPlayer p, BauweltMember target, String what){ ProxiedPlayer player = ProxyServer.getInstance().getPlayer(SteamwarUser.get(target.getMemberID()).getUuid()); diff --git a/src/de/steamwar/bungeecore/commands/FightCommand.java b/src/de/steamwar/bungeecore/commands/FightCommand.java index d041815..1666e17 100644 --- a/src/de/steamwar/bungeecore/commands/FightCommand.java +++ b/src/de/steamwar/bungeecore/commands/FightCommand.java @@ -157,54 +157,6 @@ public class FightCommand extends SWCommand { } } - static void createArena(CommandSender s, String precommand, boolean allowMerging, String[] args, int startArg, boolean historic, FightCallback callback){ - if(!(s instanceof ProxiedPlayer)) - return; - - ProxiedPlayer player = (ProxiedPlayer) s; - - ChatSender sender = ChatSender.of(player); - if (sender.user().isPunishedWithMessage(sender, Punishment.PunishmentType.NoFightServer)) { - return; - } - - if(alreadyInArena(player)) - return; - - if(ModLoaderBlocker.isFabric(player) && !precommand.equals("/bau testarena ")) { - sender.system("MODLOADER_DENIED"); - return; - } - - if(args.length < startArg+1){ - getModes(sender, precommand, historic); - return; - } - - ArenaMode mode = getMode(sender, args[startArg]); - if(mode == null) - return; - - String map; - if(mode.getMaps().size() == 1){ - map = mode.getRandomMap(); - }else if(args.length < startArg+2){ - getMaps(sender, precommand, mode); - return; - }else{ - map = getMap(sender, mode, args[startArg+1]); - } - - if(map == null) - return; - - if(!allowMerging) { - callback.run(player, mode, map); - } else { - suggestMerging(player, mode, map, callback); - } - } - public static void suggestMerging(ProxiedPlayer player, ArenaMode mode, String map, FightCallback declineMerge) { Arenaserver mergable = null; synchronized (Subserver.getServerList()) { -- 2.39.5 From eb8d8380d9179f0d62195c5166367222bf7c1424 Mon Sep 17 00:00:00 2001 From: yoyosource Date: Wed, 14 Sep 2022 17:54:25 +0200 Subject: [PATCH 2/6] Update BauCommand --- CommonCore | 2 +- .../bungeecore/commands/BauCommand.java | 39 +++++++++++++++++++ 2 files changed, 40 insertions(+), 1 deletion(-) diff --git a/CommonCore b/CommonCore index 9df9259..1dea719 160000 --- a/CommonCore +++ b/CommonCore @@ -1 +1 @@ -Subproject commit 9df92595b2f344585bd3e1639cedc761680b7761 +Subproject commit 1dea71993d897354d3f52a705f6e0e1e0c8ec580 diff --git a/src/de/steamwar/bungeecore/commands/BauCommand.java b/src/de/steamwar/bungeecore/commands/BauCommand.java index dfc0a5b..be8fdec 100644 --- a/src/de/steamwar/bungeecore/commands/BauCommand.java +++ b/src/de/steamwar/bungeecore/commands/BauCommand.java @@ -23,8 +23,10 @@ import de.steamwar.bungeecore.*; import de.steamwar.bungeecore.inventory.SWInventory; import de.steamwar.bungeecore.inventory.SWItem; import de.steamwar.bungeecore.network.NetworkSender; +import de.steamwar.bungeecore.sql.BauLockState; import de.steamwar.bungeecore.sql.BauweltMember; import de.steamwar.bungeecore.sql.SteamwarUser; +import de.steamwar.bungeecore.sql.UserConfig; import de.steamwar.bungeecore.util.Chat19; import de.steamwar.command.SWCommand; import de.steamwar.command.TypeMapper; @@ -171,6 +173,10 @@ public class BauCommand extends SWCommand { messageSender.send("BAU_TP_NOALLOWED"); return false; } + if(isLocked(value, SteamwarUser.get(p))) { + messageSender.send("BAU_LOCKED_NOALLOWED"); + return false; + } return true; }; } @@ -288,6 +294,16 @@ public class BauCommand extends SWCommand { }); } + @Register(value = "lock", description = "BAU_LOCKED_OPTIONS") + public void lock(ProxiedPlayer p, BauLockState bauLockState) { + setLocked(p, bauLockState); + } + + @Register("unlock") + public void unlock(ProxiedPlayer p) { + setLocked(p, BauLockState.OPEN); + } + private static BauweltMember member(ProxiedPlayer p, SteamwarUser member){ if (member == null) { Message.send("UNKNOWN_PLAYER", p); @@ -315,4 +331,27 @@ public class BauCommand extends SWCommand { Message.send("BAU_MEMBER_TOGGLE_OFF", p, Message.parse(what, p)); } } + + private static final String BAU_LOCK_CONFIG_NAME = "baulockstate"; + private static void setLocked(ProxiedPlayer p, BauLockState state) { + SteamwarUser owner = SteamwarUser.get(p.getUniqueId()); + UserConfig.updateUserConfig(owner.getId(), BAU_LOCK_CONFIG_NAME, state == BauLockState.OPEN ? null : state.name()); + Message.send("BAU_LOCKED_" + state.name(), owner.getPlayer()); + } + + private static boolean isLocked(SteamwarUser owner, SteamwarUser target) { + if (owner.getId() == target.getId()) + return false; + + String state = UserConfig.getConfig(owner.getId(), BAU_LOCK_CONFIG_NAME); + switch (state == null ? BauLockState.OPEN : BauLockState.valueOf(state)) { + case NOBODY: + return true; + case TEAM: + return owner.getTeam() != target.getTeam(); + case OPEN: + default: + return false; + } + } } -- 2.39.5 From c36a6885cfad3f30c95994e05dc910b3613800c8 Mon Sep 17 00:00:00 2001 From: yoyosource Date: Sat, 17 Sep 2022 11:34:51 +0200 Subject: [PATCH 3/6] Fix merge conflicts --- .../bungeecore/commands/BauCommand.java | 34 +++---------------- src/de/steamwar/bungeecore/sql/BauLock.java | 12 ++----- 2 files changed, 7 insertions(+), 39 deletions(-) diff --git a/src/de/steamwar/bungeecore/commands/BauCommand.java b/src/de/steamwar/bungeecore/commands/BauCommand.java index be8fdec..bb64113 100644 --- a/src/de/steamwar/bungeecore/commands/BauCommand.java +++ b/src/de/steamwar/bungeecore/commands/BauCommand.java @@ -23,10 +23,7 @@ import de.steamwar.bungeecore.*; import de.steamwar.bungeecore.inventory.SWInventory; import de.steamwar.bungeecore.inventory.SWItem; import de.steamwar.bungeecore.network.NetworkSender; -import de.steamwar.bungeecore.sql.BauLockState; -import de.steamwar.bungeecore.sql.BauweltMember; -import de.steamwar.bungeecore.sql.SteamwarUser; -import de.steamwar.bungeecore.sql.UserConfig; +import de.steamwar.bungeecore.sql.*; import de.steamwar.bungeecore.util.Chat19; import de.steamwar.command.SWCommand; import de.steamwar.command.TypeMapper; @@ -173,7 +170,7 @@ public class BauCommand extends SWCommand { messageSender.send("BAU_TP_NOALLOWED"); return false; } - if(isLocked(value, SteamwarUser.get(p))) { + if(BauLock.isLocked(value, SteamwarUser.get(p))) { messageSender.send("BAU_LOCKED_NOALLOWED"); return false; } @@ -296,12 +293,12 @@ public class BauCommand extends SWCommand { @Register(value = "lock", description = "BAU_LOCKED_OPTIONS") public void lock(ProxiedPlayer p, BauLockState bauLockState) { - setLocked(p, bauLockState); + BauLock.setLocked(p, bauLockState); } @Register("unlock") public void unlock(ProxiedPlayer p) { - setLocked(p, BauLockState.OPEN); + BauLock.setLocked(p, BauLockState.OPEN); } private static BauweltMember member(ProxiedPlayer p, SteamwarUser member){ @@ -331,27 +328,4 @@ public class BauCommand extends SWCommand { Message.send("BAU_MEMBER_TOGGLE_OFF", p, Message.parse(what, p)); } } - - private static final String BAU_LOCK_CONFIG_NAME = "baulockstate"; - private static void setLocked(ProxiedPlayer p, BauLockState state) { - SteamwarUser owner = SteamwarUser.get(p.getUniqueId()); - UserConfig.updateUserConfig(owner.getId(), BAU_LOCK_CONFIG_NAME, state == BauLockState.OPEN ? null : state.name()); - Message.send("BAU_LOCKED_" + state.name(), owner.getPlayer()); - } - - private static boolean isLocked(SteamwarUser owner, SteamwarUser target) { - if (owner.getId() == target.getId()) - return false; - - String state = UserConfig.getConfig(owner.getId(), BAU_LOCK_CONFIG_NAME); - switch (state == null ? BauLockState.OPEN : BauLockState.valueOf(state)) { - case NOBODY: - return true; - case TEAM: - return owner.getTeam() != target.getTeam(); - case OPEN: - default: - return false; - } - } } diff --git a/src/de/steamwar/bungeecore/sql/BauLock.java b/src/de/steamwar/bungeecore/sql/BauLock.java index 8181610..f69a771 100644 --- a/src/de/steamwar/bungeecore/sql/BauLock.java +++ b/src/de/steamwar/bungeecore/sql/BauLock.java @@ -20,21 +20,15 @@ package de.steamwar.bungeecore.sql; import de.steamwar.bungeecore.Message; +import lombok.experimental.UtilityClass; import net.md_5.bungee.api.connection.ProxiedPlayer; +@UtilityClass public class BauLock { private static final String BAU_LOCK_CONFIG_NAME = "baulockstate"; - public static void setLocked(ProxiedPlayer p, String arg) { + public static void setLocked(ProxiedPlayer p, BauLockState state) { SteamwarUser owner = SteamwarUser.get(p.getUniqueId()); - BauLockState state; - try { - state = BauLockState.valueOf(arg); - } catch (IllegalArgumentException e) { - Message.send("BAU_LOCKED_OPTIONS", owner.getPlayer()); - return; - } - UserConfig.updateUserConfig(owner.getId(), BAU_LOCK_CONFIG_NAME, state == BauLockState.OPEN ? null : state.name()); Message.send("BAU_LOCKED_" + state.name(), owner.getPlayer()); } -- 2.39.5 From 3aa3776c59f9026c81eba0b2233884424df0dbce Mon Sep 17 00:00:00 2001 From: yoyosource Date: Mon, 19 Sep 2022 11:08:33 +0200 Subject: [PATCH 4/6] Hotfix versionselector() order --- src/de/steamwar/bungeecore/commands/BauCommand.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/de/steamwar/bungeecore/commands/BauCommand.java b/src/de/steamwar/bungeecore/commands/BauCommand.java index bb64113..aa316d9 100644 --- a/src/de/steamwar/bungeecore/commands/BauCommand.java +++ b/src/de/steamwar/bungeecore/commands/BauCommand.java @@ -150,9 +150,9 @@ public class BauCommand extends SWCommand { @Register("teleport") public void teleport(ProxiedPlayer p, @Validator("teleportTarget") SteamwarUser worldOwner, @Mapper("version") @OptionalValue("") int version) { versionSelector(version, - () -> new ServerStarter().build19(worldOwner.getUuid()).send(p).start(), - () -> new ServerStarter().build15(worldOwner.getUuid()).send(p).start(), () -> new ServerStarter().build12(worldOwner.getUuid()).send(p).start(), + () -> new ServerStarter().build15(worldOwner.getUuid()).send(p).start(), + () -> new ServerStarter().build19(worldOwner.getUuid()).send(p).start(), () -> HelpCommand.sendBauHelp(ChatSender.of(p)) ); } @@ -251,9 +251,9 @@ public class BauCommand extends SWCommand { public void delete(ProxiedPlayer p, @Mapper("version") @OptionalValue("") int version) { SteamwarUser user = SteamwarUser.get(p.getUniqueId()); versionSelector(version, - () -> deleteConfirmation(p, () -> deleteWorld(p, ServerStarter.WORLDS19_PATH + user.getId())), - () -> deleteConfirmation(p, () -> deleteWorld(p, ServerStarter.WORLDS15_PATH + user.getId())), () -> deleteConfirmation(p, () -> deleteWorld(p, ServerStarter.WORLDS12_PATH + p.getUniqueId().toString())), + () -> deleteConfirmation(p, () -> deleteWorld(p, ServerStarter.WORLDS15_PATH + user.getId())), + () -> deleteConfirmation(p, () -> deleteWorld(p, ServerStarter.WORLDS19_PATH + user.getId())), () -> HelpCommand.sendBauHelp(ChatSender.of(p)) ); } -- 2.39.5 From 60ed5da260431283687085286386e9a875736c2d Mon Sep 17 00:00:00 2001 From: yoyosource Date: Mon, 19 Sep 2022 11:14:22 +0200 Subject: [PATCH 5/6] Hotfix versionselector() remove default --- .../steamwar/bungeecore/commands/BauCommand.java | 14 ++++---------- src/de/steamwar/command/SWCommand.java | 2 +- 2 files changed, 5 insertions(+), 11 deletions(-) diff --git a/src/de/steamwar/bungeecore/commands/BauCommand.java b/src/de/steamwar/bungeecore/commands/BauCommand.java index aa316d9..cac71d2 100644 --- a/src/de/steamwar/bungeecore/commands/BauCommand.java +++ b/src/de/steamwar/bungeecore/commands/BauCommand.java @@ -50,12 +50,11 @@ public class BauCommand extends SWCommand { versionSelector(version, () -> new ServerStarter().build12(p.getUniqueId()).send(p).start(), () -> new ServerStarter().build15(p.getUniqueId()).send(p).start(), - () -> new ServerStarter().build19(p.getUniqueId()).send(p).start(), - () -> HelpCommand.sendBauHelp(ChatSender.of(p)) + () -> new ServerStarter().build19(p.getUniqueId()).send(p).start() ); } - public void versionSelector(int version, Runnable r12, Runnable r15, Runnable r19, Runnable rDefault) { + public void versionSelector(int version, Runnable r12, Runnable r15, Runnable r19) { switch (version) { case 12: r12.run(); @@ -66,9 +65,6 @@ public class BauCommand extends SWCommand { case 19: r19.run(); break; - default: - rDefault.run(); - break; } } @@ -152,8 +148,7 @@ public class BauCommand extends SWCommand { versionSelector(version, () -> new ServerStarter().build12(worldOwner.getUuid()).send(p).start(), () -> new ServerStarter().build15(worldOwner.getUuid()).send(p).start(), - () -> new ServerStarter().build19(worldOwner.getUuid()).send(p).start(), - () -> HelpCommand.sendBauHelp(ChatSender.of(p)) + () -> new ServerStarter().build19(worldOwner.getUuid()).send(p).start() ); } @@ -253,8 +248,7 @@ public class BauCommand extends SWCommand { versionSelector(version, () -> deleteConfirmation(p, () -> deleteWorld(p, ServerStarter.WORLDS12_PATH + p.getUniqueId().toString())), () -> deleteConfirmation(p, () -> deleteWorld(p, ServerStarter.WORLDS15_PATH + user.getId())), - () -> deleteConfirmation(p, () -> deleteWorld(p, ServerStarter.WORLDS19_PATH + user.getId())), - () -> HelpCommand.sendBauHelp(ChatSender.of(p)) + () -> deleteConfirmation(p, () -> deleteWorld(p, ServerStarter.WORLDS19_PATH + user.getId())) ); } diff --git a/src/de/steamwar/command/SWCommand.java b/src/de/steamwar/command/SWCommand.java index 3938c61..63bbace 100644 --- a/src/de/steamwar/command/SWCommand.java +++ b/src/de/steamwar/command/SWCommand.java @@ -121,7 +121,7 @@ public class SWCommand extends AbstractSWCommand { } @Register(help = true) - private void internalHelp(ProxiedPlayer p, String... args) { + public void internalHelp(ProxiedPlayer p, String... args) { ChatSender chatSender = ChatSender.of(p); try { chatSender.prefixless("COMMAND_HELP_HEAD", command.getName()); -- 2.39.5 From 09cfb97e32782c9c48462c6380d1275a34055457 Mon Sep 17 00:00:00 2001 From: yoyosource Date: Mon, 19 Sep 2022 11:22:49 +0200 Subject: [PATCH 6/6] Add own help message --- src/de/steamwar/bungeecore/commands/BauCommand.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/de/steamwar/bungeecore/commands/BauCommand.java b/src/de/steamwar/bungeecore/commands/BauCommand.java index cac71d2..09c5877 100644 --- a/src/de/steamwar/bungeecore/commands/BauCommand.java +++ b/src/de/steamwar/bungeecore/commands/BauCommand.java @@ -45,6 +45,11 @@ public class BauCommand extends SWCommand { super("bau", null, "b", "build", "gs"); } + @Register(help = true) + public void genericHelp(ProxiedPlayer p, String... args) { + HelpCommand.sendBauHelp(ChatSender.of(p)); + } + @Register public void toBau(ProxiedPlayer p, @Mapper("version") @OptionalValue("") int version) { versionSelector(version, -- 2.39.5