mirror of
https://github.com/Grasscutters/Grasscutter.git
synced 2025-01-24 06:15:38 +08:00
Fixed an issue with kicking players
(Still broken but now it actually disconnects the player)
This commit is contained in:
parent
058d322238
commit
f54cfc6c75
@ -40,16 +40,26 @@ public final class ServerCommands {
|
|||||||
public static class KickCommand implements CommandHandler {
|
public static class KickCommand implements CommandHandler {
|
||||||
@Override
|
@Override
|
||||||
public void execute(List<String> args) {
|
public void execute(List<String> args) {
|
||||||
|
this.execute(null, args);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void execute(GenshinPlayer player, List<String> args) {
|
||||||
int target = Integer.parseInt(args.get(0));
|
int target = Integer.parseInt(args.get(0));
|
||||||
String message = String.join(" ", args.subList(1, args.size()));
|
String message = String.join(" ", args.subList(1, args.size()));
|
||||||
|
|
||||||
GenshinPlayer targetPlayer = Grasscutter.getGameServer().getPlayerById(target);
|
GenshinPlayer targetPlayer = Grasscutter.getGameServer().getPlayerByUid(target);
|
||||||
if(targetPlayer == null) {
|
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()));
|
CommandHandler.sendMessage(player, String.format("Kicking player [%s:%s]", target, targetPlayer.getAccount().getUsername()));
|
||||||
//targetPlayer.getSession().close();
|
|
||||||
|
targetPlayer.getSession().close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user