From 04249488d917f14bb8ea6daba651fa4821a6afb8 Mon Sep 17 00:00:00 2001 From: yoyosource Date: Sun, 31 Jul 2022 21:21:20 +0200 Subject: [PATCH] Fix NoClipCommand for real now Signed-off-by: yoyosource --- .../src/de/steamwar/bausystem/utils/NMSWrapper15.java | 2 ++ .../src/de/steamwar/bausystem/utils/NMSWrapper18.java | 2 ++ .../src/de/steamwar/bausystem/utils/NMSWrapper19.java | 2 ++ .../de/steamwar/bausystem/features/util/NoClipCommand.java | 5 ++++- 4 files changed, 10 insertions(+), 1 deletion(-) diff --git a/BauSystem_15/src/de/steamwar/bausystem/utils/NMSWrapper15.java b/BauSystem_15/src/de/steamwar/bausystem/utils/NMSWrapper15.java index 32ff8d52..6a152570 100644 --- a/BauSystem_15/src/de/steamwar/bausystem/utils/NMSWrapper15.java +++ b/BauSystem_15/src/de/steamwar/bausystem/utils/NMSWrapper15.java @@ -69,6 +69,8 @@ public class NMSWrapper15 implements NMSWrapper.INMSWrapper { index = index - 8 + 36; } player.getInventory().setItem(index, CraftItemStack.asBukkitCopy(packetPlayInSetCreativeSlot.getItemStack())); + if (index < 9) player.getInventory().setHeldItemSlot(index); + player.updateInventory(); } @Override diff --git a/BauSystem_18/src/de/steamwar/bausystem/utils/NMSWrapper18.java b/BauSystem_18/src/de/steamwar/bausystem/utils/NMSWrapper18.java index 0e687866..48a4a32a 100644 --- a/BauSystem_18/src/de/steamwar/bausystem/utils/NMSWrapper18.java +++ b/BauSystem_18/src/de/steamwar/bausystem/utils/NMSWrapper18.java @@ -74,6 +74,8 @@ public class NMSWrapper18 implements NMSWrapper.INMSWrapper { index = index - 8 + 36; } player.getInventory().setItem(index, CraftItemStack.asBukkitCopy(packetPlayInSetCreativeSlot.c())); + if (index < 9) player.getInventory().setHeldItemSlot(index); + player.updateInventory(); } @Override diff --git a/BauSystem_19/src/de/steamwar/bausystem/utils/NMSWrapper19.java b/BauSystem_19/src/de/steamwar/bausystem/utils/NMSWrapper19.java index dcb2503c..573c6d7f 100644 --- a/BauSystem_19/src/de/steamwar/bausystem/utils/NMSWrapper19.java +++ b/BauSystem_19/src/de/steamwar/bausystem/utils/NMSWrapper19.java @@ -74,6 +74,8 @@ public class NMSWrapper19 implements NMSWrapper.INMSWrapper { index = index - 8 + 36; } player.getInventory().setItem(index, CraftItemStack.asBukkitCopy(packetPlayInSetCreativeSlot.c())); + if (index < 9) player.getInventory().setHeldItemSlot(index); + player.updateInventory(); } @Override diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/util/NoClipCommand.java b/BauSystem_Main/src/de/steamwar/bausystem/features/util/NoClipCommand.java index 527d3d96..ec88f9c3 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/util/NoClipCommand.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/util/NoClipCommand.java @@ -32,6 +32,7 @@ import de.steamwar.bausystem.utils.ProtocolWrapper; import de.steamwar.command.SWCommand; import de.steamwar.core.Core; import lombok.Getter; +import org.bukkit.Bukkit; import org.bukkit.GameMode; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; @@ -154,8 +155,10 @@ public class NoClipCommand extends SWCommand implements Listener { return; } if (NOCLIPS.contains(event.getPlayer())) { - event.getPlayer().setSpectatorTarget(null); event.setCancelled(true); + Bukkit.getScheduler().runTaskLater(BauSystem.getInstance(), () -> { + event.getPlayer().setSpectatorTarget(null); + }, 1L); } }