From 0b9ab8b6cc2d013060acc67d157a97e3e21bd402 Mon Sep 17 00:00:00 2001 From: TheBusyBiscuit Date: Sat, 14 Nov 2020 18:44:07 +0100 Subject: [PATCH] Fixes #2446 --- CHANGELOG.md | 1 + .../listeners/EntityInteractionListener.java | 16 +++++++++++++--- .../listeners/SlimefunItemListener.java | 1 - 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e04a857e5..18e3ef403 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -60,6 +60,7 @@ * Fixed id conflicts for external Enchantment sources (e.g. plugins) for the Magician Talisman settings * Fixed network visualizers spawning particles for other player heads * Fixed #2418 +* Fixed #2446 ## Release Candidate 17 (17 Oct 2020) diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/EntityInteractionListener.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/EntityInteractionListener.java index 2fd7ad0e9..1fb50c574 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/EntityInteractionListener.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/EntityInteractionListener.java @@ -10,13 +10,14 @@ import org.bukkit.event.player.PlayerInteractEntityEvent; import org.bukkit.inventory.EquipmentSlot; import org.bukkit.inventory.ItemStack; +import io.github.thebusybiscuit.slimefun4.api.items.ItemState; import io.github.thebusybiscuit.slimefun4.core.handlers.EntityInteractHandler; import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin; import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem; import me.mrCookieSlime.Slimefun.api.Slimefun; /** - * The Listener class responsible for a {@link Player} interacting with an {@link Entity}. + * The {@link Listener} responsible for a {@link Player} interacting with an {@link Entity}. * * @author Linox * @@ -45,8 +46,17 @@ public class EntityInteractionListener implements Listener { SlimefunItem sfItem = SlimefunItem.getByItem(itemStack); - if (sfItem != null && Slimefun.hasUnlocked(e.getPlayer(), sfItem, true)) { - sfItem.callItemHandler(EntityInteractHandler.class, handler -> handler.onInteract(e, itemStack, e.getHand() == EquipmentSlot.OFF_HAND)); + if (sfItem != null) { + if (Slimefun.hasUnlocked(e.getPlayer(), sfItem, true)) { + sfItem.callItemHandler(EntityInteractHandler.class, handler -> handler.onInteract(e, itemStack, e.getHand() == EquipmentSlot.OFF_HAND)); + } else if (sfItem.getState() != ItemState.VANILLA_FALLBACK) { + /** + * If an Item is disabled, we don't want it to fallback to the vanilla behaviour + * unless it is a Vanilla Item of course. + * Related to Issue #2446 + */ + e.setCancelled(true); + } } } } \ No newline at end of file diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/SlimefunItemListener.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/SlimefunItemListener.java index 59ca7b6a6..71c5680b2 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/SlimefunItemListener.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/SlimefunItemListener.java @@ -67,7 +67,6 @@ public class SlimefunItemListener implements Listener { } } - @Nonnull @ParametersAreNonnullByDefault private boolean rightClickItem(PlayerInteractEvent e, PlayerRightClickEvent event, boolean defaultValue) { Optional optional = event.getSlimefunItem();