1
mirror of https://github.com/StarWishsama/Slimefun4.git synced 2024-09-19 19:25:48 +00:00
This commit is contained in:
TheBusyBiscuit 2020-11-14 18:44:07 +01:00
parent 503dbc8367
commit 0b9ab8b6cc
3 changed files with 14 additions and 4 deletions

View File

@ -60,6 +60,7 @@
* Fixed id conflicts for external Enchantment sources (e.g. plugins) for the Magician Talisman settings * 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 network visualizers spawning particles for other player heads
* Fixed #2418 * Fixed #2418
* Fixed #2446
## Release Candidate 17 (17 Oct 2020) ## Release Candidate 17 (17 Oct 2020)

View File

@ -10,13 +10,14 @@ import org.bukkit.event.player.PlayerInteractEntityEvent;
import org.bukkit.inventory.EquipmentSlot; import org.bukkit.inventory.EquipmentSlot;
import org.bukkit.inventory.ItemStack; 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.core.handlers.EntityInteractHandler;
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin; import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem; import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem;
import me.mrCookieSlime.Slimefun.api.Slimefun; 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 * @author Linox
* *
@ -45,8 +46,17 @@ public class EntityInteractionListener implements Listener {
SlimefunItem sfItem = SlimefunItem.getByItem(itemStack); SlimefunItem sfItem = SlimefunItem.getByItem(itemStack);
if (sfItem != null && Slimefun.hasUnlocked(e.getPlayer(), sfItem, true)) { if (sfItem != null) {
sfItem.callItemHandler(EntityInteractHandler.class, handler -> handler.onInteract(e, itemStack, e.getHand() == EquipmentSlot.OFF_HAND)); 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);
}
} }
} }
} }

View File

@ -67,7 +67,6 @@ public class SlimefunItemListener implements Listener {
} }
} }
@Nonnull
@ParametersAreNonnullByDefault @ParametersAreNonnullByDefault
private boolean rightClickItem(PlayerInteractEvent e, PlayerRightClickEvent event, boolean defaultValue) { private boolean rightClickItem(PlayerInteractEvent e, PlayerRightClickEvent event, boolean defaultValue) {
Optional<SlimefunItem> optional = event.getSlimefunItem(); Optional<SlimefunItem> optional = event.getSlimefunItem();