From f54cfc6c7543d3a87e450e7e7c253b099ec09462 Mon Sep 17 00:00:00 2001 From: Benjamin Elsdon Date: Tue, 19 Apr 2022 20:36:15 +0800 Subject: [PATCH] Fixed an issue with kicking players (Still broken but now it actually disconnects the player) --- .../grasscutter/commands/ServerCommands.java | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/src/main/java/emu/grasscutter/commands/ServerCommands.java b/src/main/java/emu/grasscutter/commands/ServerCommands.java index 67c33338c..a4014be57 100644 --- a/src/main/java/emu/grasscutter/commands/ServerCommands.java +++ b/src/main/java/emu/grasscutter/commands/ServerCommands.java @@ -40,16 +40,26 @@ public final class ServerCommands { public static class KickCommand implements CommandHandler { @Override public void execute(List args) { + this.execute(null, args); + } + + @Override + public void execute(GenshinPlayer player, List args) { int target = Integer.parseInt(args.get(0)); String message = String.join(" ", args.subList(1, args.size())); - GenshinPlayer targetPlayer = Grasscutter.getGameServer().getPlayerById(target); + GenshinPlayer targetPlayer = Grasscutter.getGameServer().getPlayerByUid(target); if(targetPlayer == null) { - CommandHandler.sendMessage(null, "Player not found."); return; + CommandHandler.sendMessage(player, "Player not found."); + return; + } + if(player != null) { + CommandHandler.sendMessage(null, String.format("Player [%s:%s] has kicked player [%s:%s]", player.getAccount().getPlayerId(), player.getAccount().getUsername(), target, targetPlayer.getAccount().getUsername())); } - targetPlayer.sendPacket(new PacketSceneKickPlayerRsp(targetPlayer.getId())); - //targetPlayer.getSession().close(); + CommandHandler.sendMessage(player, String.format("Kicking player [%s:%s]", target, targetPlayer.getAccount().getUsername())); + + targetPlayer.getSession().close(); } }