From 88ff8d8e747099e623841825085cacbd7735a595 Mon Sep 17 00:00:00 2001 From: yoyosource Date: Mon, 23 Jan 2023 16:37:08 +0100 Subject: [PATCH] Update TeamCommand (not finished) --- .../bungeecore/commands/TeamCommand.java | 147 ++++++++---------- 1 file changed, 64 insertions(+), 83 deletions(-) diff --git a/src/de/steamwar/bungeecore/commands/TeamCommand.java b/src/de/steamwar/bungeecore/commands/TeamCommand.java index 9ae3799..ce2ee75 100644 --- a/src/de/steamwar/bungeecore/commands/TeamCommand.java +++ b/src/de/steamwar/bungeecore/commands/TeamCommand.java @@ -24,6 +24,7 @@ import de.steamwar.bungeecore.Storage; import de.steamwar.bungeecore.inventory.SWItem; import de.steamwar.bungeecore.inventory.SWListInv; import de.steamwar.bungeecore.sql.*; +import de.steamwar.command.SWCommand; import de.steamwar.messages.ChatSender; import net.md_5.bungee.BungeeCord; import net.md_5.bungee.api.ChatColor; @@ -49,7 +50,7 @@ import java.util.stream.Collectors; import static de.steamwar.bungeecore.Storage.teamInvitations; -public class TeamCommand extends BasicCommand { +public class TeamCommand extends SWCommand { private static final List> COLOR_CODES = new ArrayList<>(); @@ -77,16 +78,17 @@ public class TeamCommand extends BasicCommand { } public TeamCommand() { - super("team", ""); + super("team"); } - private void help(CommandSender sender){ + @Register + public void help(CommandSender sender, String... args){ Message.send("TEAM_HELP_HEADER", sender); Message.send("TEAM_HELP_LIST", sender); Message.send("TEAM_HELP_INFO", sender); - Message.send("TEAM_HELP_TP", sender); if(!(sender instanceof ProxiedPlayer)) return; + Message.send("TEAM_HELP_TP", sender); ProxiedPlayer player = (ProxiedPlayer) sender; SteamwarUser user = SteamwarUser.get(player.getUniqueId()); @@ -111,72 +113,10 @@ public class TeamCommand extends BasicCommand { } } - @Override - public void execute(CommandSender sender, String[] args){ - if(args.length < 1){ - help(sender); - return; - } - - if(!(sender instanceof ProxiedPlayer)) - return; - - ProxiedPlayer player = (ProxiedPlayer) sender; + @Register("create") + public void create(ProxiedPlayer player, String... args){ SteamwarUser user = SteamwarUser.get(player.getUniqueId()); Team team = Team.get(user.getTeam()); - - switch(args[0].toLowerCase()){ - case "create": - create(player, user, team, args); - break; - case "join": - join(player, user, args); - break; - case "stepback": - stepBack(player,user,team); - break; - case "leave": - leave(player, user, team); - break; - case "invite": - invite(player, user, team, args); - break; - case "remove": - remove(player, user, team, args); - break; - case "changekuerzel": - changekuerzel(player, user, team, args); - break; - case "changename": - changename(player, user, team, args); - break; - case "promote": - promote(player, user, team, args); - break; - case "changecolor": - changeColor(player, user, team); - break; - case "info": - info(player, user, team, args); - break; - case "list": - list(player, args); - break; - case "event": - event(player, user, team, args); - break; - case "tp": - tp(player, user, team, args); - break; - case "server": - server(player, user, team, args); - break; - default: - help(player); - } - } - - private void create(ProxiedPlayer player, SteamwarUser user, Team team, String[] args){ if(unwantedInTeam(player, user)) return; @@ -197,7 +137,9 @@ public class TeamCommand extends BasicCommand { Message.send("TEAM_CREATE_CREATED", player, args[2]); } - private void join(ProxiedPlayer player, SteamwarUser user, String[] args){ + @Register("join") + public void join(ProxiedPlayer player, String... args){ + SteamwarUser user = SteamwarUser.get(player.getUniqueId()); if(unwantedInTeam(player, user)) return; @@ -245,7 +187,10 @@ public class TeamCommand extends BasicCommand { Message.send("TEAM_JOIN_JOINED", player, Team.get(t).getTeamName()); } - private void stepBack(ProxiedPlayer player, SteamwarUser user, Team team) { + @Register("stepback") + public void stepBack(ProxiedPlayer player) { + SteamwarUser user = SteamwarUser.get(player.getUniqueId()); + Team team = Team.get(user.getTeam()); if(notLeader(player, user, team)) return; @@ -258,7 +203,10 @@ public class TeamCommand extends BasicCommand { Message.send("TEAM_STEP_BACK", player); } - private void leave(ProxiedPlayer player, SteamwarUser user, Team team){ + @Register("leave") + public void leave(ProxiedPlayer player){ + SteamwarUser user = SteamwarUser.get(player.getUniqueId()); + Team team = Team.get(user.getTeam()); if(notInTeam(player, user)) return; @@ -278,7 +226,10 @@ public class TeamCommand extends BasicCommand { } - private void invite(ProxiedPlayer player, SteamwarUser user, Team team, String[] args){ + @Register("invite") + public void invite(ProxiedPlayer player, String... args){ + SteamwarUser user = SteamwarUser.get(player.getUniqueId()); + Team team = Team.get(user.getTeam()); if(notLeader(player, user, team)) return; @@ -315,7 +266,10 @@ public class TeamCommand extends BasicCommand { Message.send("TEAM_INVITE_INVITED_TARGET", p, team.getTeamColor(), team.getTeamName()); } - private void remove(ProxiedPlayer player, SteamwarUser user, Team team, String[] args){ + @Register("remove") + public void remove(ProxiedPlayer player, String... args){ + SteamwarUser user = SteamwarUser.get(player.getUniqueId()); + Team team = Team.get(user.getTeam()); if(notLeader(player, user, team)) return; @@ -359,7 +313,10 @@ public class TeamCommand extends BasicCommand { Message.send("TEAM_REMOVE_REMOVED_TARGET", player); } - private void changekuerzel(ProxiedPlayer player, SteamwarUser user, Team team, String[] args){ + @Register("changekurzel") + public void changekuerzel(ProxiedPlayer player, String... args){ + SteamwarUser user = SteamwarUser.get(player.getUniqueId()); + Team team = Team.get(user.getTeam()); if(notLeader(player, user, team)) return; @@ -378,7 +335,10 @@ public class TeamCommand extends BasicCommand { Message.send("TEAM_KUERZEL_CHANGED", player); } - private void changename(ProxiedPlayer player, SteamwarUser user, Team team, String[] args){ + @Register("changename") + public void changename(ProxiedPlayer player, String... args){ + SteamwarUser user = SteamwarUser.get(player.getUniqueId()); + Team team = Team.get(user.getTeam()); if(notLeader(player, user, team)) return; @@ -397,7 +357,10 @@ public class TeamCommand extends BasicCommand { Message.send("TEAM_NAME_CHANGED", player); } - private void promote(ProxiedPlayer player, SteamwarUser user, Team team, String[] args){ + @Register("promote") + public void promote(ProxiedPlayer player, String... args){ + SteamwarUser user = SteamwarUser.get(player.getUniqueId()); + Team team = Team.get(user.getTeam()); if(notLeader(player, user, team)) return; @@ -428,7 +391,10 @@ public class TeamCommand extends BasicCommand { return ProxyServer.getInstance().getPlayer(user.getUuid()) != null ? "§a" + user.getUserName() : "§e" + user.getUserName(); } - private void info(ProxiedPlayer player, SteamwarUser user, Team team, String[] args){ + @Register("info") + public void info(ProxiedPlayer player, String... args){ + SteamwarUser user = SteamwarUser.get(player.getUniqueId()); + Team team = Team.get(user.getTeam()); if(args.length == 1 && user.getTeam() == 0){ Message.send("TEAM_INFO_USAGE", player); return; @@ -469,7 +435,10 @@ public class TeamCommand extends BasicCommand { return sb.toString(); } - private void list(ProxiedPlayer player, String[] args){ + @Register("list") + public void list(ProxiedPlayer player, String... args){ + SteamwarUser user = SteamwarUser.get(player.getUniqueId()); + Team team = Team.get(user.getTeam()); final int TEAMS_PER_PAGE = 10; @@ -520,7 +489,10 @@ public class TeamCommand extends BasicCommand { player.sendMessage(beforePage); } - private void event(ProxiedPlayer player, SteamwarUser user, Team team, String[] args){ + @Register("event") + public void event(ProxiedPlayer player, String[] args){ + SteamwarUser user = SteamwarUser.get(player.getUniqueId()); + Team team = Team.get(user.getTeam()); if(notInTeam(player, user)) return; @@ -563,7 +535,10 @@ public class TeamCommand extends BasicCommand { } } - private void tp(ProxiedPlayer player, SteamwarUser user, Team team, String[] args){ + @Register("tp") + public void tp(ProxiedPlayer player, String... args){ + SteamwarUser user = SteamwarUser.get(player.getUniqueId()); + Team team = Team.get(user.getTeam()); if(args.length == 1){ if(notInTeam(player, user)) return; @@ -609,7 +584,10 @@ public class TeamCommand extends BasicCommand { */ } - private void server(ProxiedPlayer player, SteamwarUser user, Team team, String[] args){ + @Register("server") + public void server(ProxiedPlayer player, String[] args){ + SteamwarUser user = SteamwarUser.get(player.getUniqueId()); + Team team = Team.get(user.getTeam()); if(notLeader(player, user, team)) return; if (user.isPunishedWithMessage(ChatSender.of(player), Punishment.PunishmentType.NoTeamServer)) { @@ -661,7 +639,10 @@ public class TeamCommand extends BasicCommand { } } - private void changeColor(ProxiedPlayer player, SteamwarUser user, Team team) { + @Register("color") + public void changeColor(ProxiedPlayer player) { + SteamwarUser user = SteamwarUser.get(player.getUniqueId()); + Team team = Team.get(user.getTeam()); if(notLeader(player, user, team)) return; @@ -745,7 +726,7 @@ public class TeamCommand extends BasicCommand { return false; } - @Override + // @Override public Iterable onTabComplete(CommandSender commandSender, String[] args){ List tab = new ArrayList<>(); if(args.length == 1){