From 552649f88446f9e439edf023e1978108d414e8f1 Mon Sep 17 00:00:00 2001 From: jojo Date: Wed, 16 Dec 2020 10:31:02 +0100 Subject: [PATCH] Fix RightClickAir and LeftClickAir --- .../steamwar/bausystem/world/ScriptListener.java | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/BauSystem_Main/src/de/steamwar/bausystem/world/ScriptListener.java b/BauSystem_Main/src/de/steamwar/bausystem/world/ScriptListener.java index 2c20792..9b77e66 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/world/ScriptListener.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/world/ScriptListener.java @@ -24,6 +24,7 @@ import de.steamwar.core.Core; import org.bukkit.Bukkit; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; import org.bukkit.event.Listener; import org.bukkit.event.block.Action; import org.bukkit.event.player.PlayerCommandPreprocessEvent; @@ -32,7 +33,9 @@ import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.meta.BookMeta; import java.util.ArrayList; +import java.util.HashSet; import java.util.List; +import java.util.Set; import java.util.logging.Level; public class ScriptListener implements Listener { @@ -68,9 +71,19 @@ public class ScriptListener implements Listener { }); } + private Set playerSet = new HashSet<>(); + + @EventHandler(priority = EventPriority.HIGH) public void onLeftClick(PlayerInteractEvent event) { - if(event.getAction() != Action.LEFT_CLICK_AIR && event.getAction() != Action.LEFT_CLICK_BLOCK) + if (event.getAction() != Action.LEFT_CLICK_AIR && event.getAction() != Action.LEFT_CLICK_BLOCK) { + if (event.getAction() == Action.RIGHT_CLICK_AIR) { + playerSet.add(event.getPlayer()); + } return; + } + if (playerSet.remove(event.getPlayer())) { + return; + } ItemStack item = event.getItem(); if(item == null || isNoBook(item) || item.getItemMeta() == null)