From 647702c0b0a29593de866c0a2e480f8279b01fd4 Mon Sep 17 00:00:00 2001 From: yoyosource Date: Sat, 21 Jan 2023 22:22:55 +0100 Subject: [PATCH] Update JoinmeCommand --- .../bungeecore/commands/JoinmeCommand.java | 98 ++++++++----------- 1 file changed, 41 insertions(+), 57 deletions(-) diff --git a/src/de/steamwar/bungeecore/commands/JoinmeCommand.java b/src/de/steamwar/bungeecore/commands/JoinmeCommand.java index e897ba0..7f966fd 100644 --- a/src/de/steamwar/bungeecore/commands/JoinmeCommand.java +++ b/src/de/steamwar/bungeecore/commands/JoinmeCommand.java @@ -21,77 +21,61 @@ package de.steamwar.bungeecore.commands; import de.steamwar.bungeecore.*; import de.steamwar.bungeecore.sql.BauweltMember; -import net.md_5.bungee.api.CommandSender; -import net.md_5.bungee.api.ProxyServer; +import de.steamwar.command.SWCommand; import net.md_5.bungee.api.chat.ClickEvent; import net.md_5.bungee.api.config.ServerInfo; import net.md_5.bungee.api.connection.ProxiedPlayer; -import java.util.ArrayList; - -public class JoinmeCommand extends BasicCommand { +public class JoinmeCommand extends SWCommand { public JoinmeCommand() { - super("joinme", ""); + super("joinme"); } - @Override - public void execute(CommandSender sender, String[] args) { - if(sender instanceof ProxiedPlayer) { - ProxiedPlayer player = (ProxiedPlayer) sender; + @Register(description = "JOINME_USAGE") + public void genericCommand(ProxiedPlayer player) { + if (!player.hasPermission("bungeecore.joinme")) return; + Message.broadcast("JOINME_BROADCAST", "JOINME_BROADCAST_HOVER", + new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/join " + player.getName()), player.getName(), player.getServer().getInfo().getName()); + } - if (args.length == 0 && player.hasPermission("bungeecore.joinme")) { - Message.broadcast("JOINME_BROADCAST", "JOINME_BROADCAST_HOVER" - , new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/join " + player.getName()), player.getName(), player.getServer().getInfo().getName()); - } else if (args.length == 1) { - ProxiedPlayer target = ProxyServer.getInstance().getPlayer(args[0]); - if(target == null || !target.isConnected()){ - Message.send("JOINME_PLAYER_OFFLINE", player); - return; - }else if(target.equals(player)){ - Message.send("JOINME_PLAYER_SELF", player); - return; - } - ServerInfo server = target.getServer().getInfo(); - String serverPerm = BungeeCore.serverPermissions.get(server.getName()); - Subserver subserver = Subserver.getSubserver(target); + @Register + public void genericCommand(ProxiedPlayer player, ProxiedPlayer target) { + if(target == null || !target.isConnected()){ + Message.send("JOINME_PLAYER_OFFLINE", player); + return; + }else if(target.equals(player)){ + Message.send("JOINME_PLAYER_SELF", player); + return; + } + ServerInfo server = target.getServer().getInfo(); + String serverPerm = BungeeCore.serverPermissions.get(server.getName()); + Subserver subserver = Subserver.getSubserver(target); - if(subserver != null) { - Servertype type = subserver.getType(); - if (type == Servertype.ARENA) { - SubserverSystem.sendPlayer(subserver, player); - } else if (type == Servertype.BAUSERVER) { - Bauserver bauserver = (Bauserver) subserver; - if (bauserver.getOwner().equals(player.getUniqueId()) || - BauweltMember.getBauMember(bauserver.getOwner(), player.getUniqueId()) != null) { - SubserverSystem.sendPlayer(subserver, player); - } else { - SubserverSystem.sendDeniedMessage(player, bauserver.getOwner()); - Message.send("JOIN_PLAYER_BLOCK", player); - } - } else if(type == Servertype.BUILDER && !player.hasPermission("bungeecore.server.team")) { - Message.send("JOIN_PLAYER_BLOCK", player); - } else { - SubserverSystem.sendPlayer(subserver, player); - } - }else if(serverPerm != null && !player.hasPermission(serverPerm)){ + if(subserver != null) { + Servertype type = subserver.getType(); + if (type == Servertype.ARENA) { + SubserverSystem.sendPlayer(subserver, player); + } else if (type == Servertype.BAUSERVER) { + Bauserver bauserver = (Bauserver) subserver; + if (bauserver.getOwner().equals(player.getUniqueId()) || + BauweltMember.getBauMember(bauserver.getOwner(), player.getUniqueId()) != null) { + SubserverSystem.sendPlayer(subserver, player); + } else { + SubserverSystem.sendDeniedMessage(player, bauserver.getOwner()); Message.send("JOIN_PLAYER_BLOCK", player); - }else if(serverPerm == null && !player.getGroups().contains("team")) { - Message.send("JOIN_PLAYER_BLOCK", player); - }else{ - player.connect(server); } + } else if(type == Servertype.BUILDER && !player.hasPermission("bungeecore.server.team")) { + Message.send("JOIN_PLAYER_BLOCK", player); } else { - Message.send("JOINME_USAGE", player); + SubserverSystem.sendPlayer(subserver, player); } + }else if(serverPerm != null && !player.hasPermission(serverPerm)){ + Message.send("JOIN_PLAYER_BLOCK", player); + }else if(serverPerm == null && !player.getGroups().contains("team")) { + Message.send("JOIN_PLAYER_BLOCK", player); + }else{ + player.connect(server); } } - - @Override - public Iterable onTabComplete(CommandSender commandSender, String[] args) { - if(args.length == 1){ - return allPlayers(args[0]); - } - return new ArrayList<>(); - } }