Skip to content

Commit

Permalink
Fix right-click failure when hand is empty
Browse files Browse the repository at this point in the history
Fixes this error:

```
[14:34:40 ERROR]: java.lang.NullPointerException: Cannot invoke "org.bukkit.inventory.ItemStack.getType()" because the return value of "org.bukkit.event.player.PlayerInteractEvent.getItem()" is null
	at SignEdit.jar//net.deltik.mc.signedit.listeners.CoreSignEditListener.overrideNativeBehavior(CoreSignEditListener.java:132)
	at SignEdit.jar//net.deltik.mc.signedit.listeners.CoreSignEditListener.onRightClickSign(CoreSignEditListener.java:112)
	at com.destroystokyo.paper.event.executor.asm.generated.GeneratedEventExecutor246.execute(Unknown Source)
	at org.bukkit.plugin.EventExecutor$2.execute(EventExecutor.java:77)
	at co.aikar.timings.TimedEventExecutor.execute(TimedEventExecutor.java:81)
	at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.java:70)
	at io.papermc.paper.plugin.manager.PaperEventManager.callEvent(PaperEventManager.java:54)
	at io.papermc.paper.plugin.manager.PaperPluginManagerImpl.callEvent(PaperPluginManagerImpl.java:126)
	at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.java:615)
	at org.bukkit.craftbukkit.v1_20_R1.event.CraftEventFactory.callPlayerInteractEvent(CraftEventFactory.java:566)
	at net.minecraft.server.level.PlayerInteractManager.a(PlayerInteractManager.java:537)
	at net.minecraft.server.network.PlayerConnection.a(PlayerConnection.java:1960)
	at net.minecraft.network.protocol.game.PacketPlayInUseItem.a(PacketPlayInUseItem.java:37)
	at net.minecraft.network.protocol.game.PacketPlayInUseItem.a(PacketPlayInUseItem.java:9)
	at net.minecraft.network.protocol.PlayerConnectionUtils.lambda$ensureRunningOnSameThread$0(PlayerConnectionUtils.java:51)
	at net.minecraft.server.TickTask.run(TickTask.java:18)
	at net.minecraft.util.thread.IAsyncTaskHandler.d(IAsyncTaskHandler.java:153)
	at net.minecraft.util.thread.IAsyncTaskHandlerReentrant.d(IAsyncTaskHandlerReentrant.java:24)
	at net.minecraft.server.MinecraftServer.b(MinecraftServer.java:1339)
	at net.minecraft.server.MinecraftServer.d(MinecraftServer.java:197)
	at net.minecraft.util.thread.IAsyncTaskHandler.x(IAsyncTaskHandler.java:126)
	at net.minecraft.server.MinecraftServer.bg(MinecraftServer.java:1316)
	at net.minecraft.server.MinecraftServer.x(MinecraftServer.java:1309)
	at net.minecraft.util.thread.IAsyncTaskHandler.c(IAsyncTaskHandler.java:136)
	at net.minecraft.server.MinecraftServer.p_(MinecraftServer.java:1287)
	at net.minecraft.server.MinecraftServer.w(MinecraftServer.java:1175)
	at net.minecraft.server.MinecraftServer.lambda$spin$0(MinecraftServer.java:318)
	at java.base/java.lang.Thread.run(Thread.java:833)
```
  • Loading branch information
Deltik committed Jul 13, 2023
1 parent ac57178 commit 21c1c20
Showing 1 changed file with 5 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
import org.bukkit.event.block.SignChangeEvent;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.inventory.ItemStack;

import javax.inject.Inject;
import javax.inject.Provider;
Expand Down Expand Up @@ -128,8 +129,11 @@ private void overrideNativeBehavior(PlayerInteractEvent event, Player player, Si
SignText signText = new SignText(signEditValidator);
SignEditInteraction maybeSignEditInteraction = null;

ItemStack eventItem = event.getItem();

if (player.hasPermission("signedit." + SignCommand.COMMAND_NAME + ".wax") &&
event.getItem().getType().equals(Material.getMaterial("HONEYCOMB")) &&
eventItem != null &&
eventItem.getType().equals(Material.getMaterial("HONEYCOMB")) &&
!event.useItemInHand().equals(Event.Result.DENY)
) {
signText.setShouldBeEditable(false);
Expand Down

0 comments on commit 21c1c20

Please sign in to comment.