From 7df76b72ac66c3ab6d14d9cae2d70012ae966841 Mon Sep 17 00:00:00 2001 From: Etzelia Date: Sat, 27 Feb 2021 22:12:31 -0600 Subject: [PATCH] Schedule kick Signed-off-by: Etzelia --- src/main/java/xyz/etztech/serverapi/ServerAPI.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/main/java/xyz/etztech/serverapi/ServerAPI.java b/src/main/java/xyz/etztech/serverapi/ServerAPI.java index d026ba5..0978d73 100644 --- a/src/main/java/xyz/etztech/serverapi/ServerAPI.java +++ b/src/main/java/xyz/etztech/serverapi/ServerAPI.java @@ -127,7 +127,9 @@ public class ServerAPI extends JavaPlugin implements IProvider { public void kick(BanAPI kick) { Player player = Bukkit.getPlayerExact(kick.getTarget()); if (player != null) { - player.kickPlayer("You have been kicked: " + kick.getReason()); + getServer().getScheduler().runTask(this, () -> { + player.kickPlayer("You have been kicked: " + kick.getReason()); + }); } } @@ -140,7 +142,9 @@ public class ServerAPI extends JavaPlugin implements IProvider { Bukkit.getBanList(BanList.Type.NAME).addBan(ban.getTarget(), ban.getReason(), expires, "ServerAPI"); Player player = Bukkit.getPlayerExact(ban.getTarget()); if (player != null) { - player.kickPlayer("You have been banned: " + ban.getReason()); + getServer().getScheduler().runTask(this, () -> { + player.kickPlayer("You have been banned: " + ban.getReason()); + }); } }