CommandHelper

CommandHelper

46.5k Downloads

Stacktrace when passing null instead of an itemID in ptake_item().

LadyCailinBot opened this issue ยท 3 comments

commented

CMDHELPER-2976 - Reported by Nessiesson

Code to reproduce with:

ptake_item(player(), null, 1);
[21:36:46 ERROR]: Uh oh! You've found an error in Core.
This is an error caused while running your code, so you may be able to find a workaround, but is ultimately an error in Core itself.
The line of code that caused the error was this:
ptake_item('NessieHC', null, 1)
on or around Interpreter:1.
Please report this error to the developers, and be sure to include the version numbers:
Server version: 1.7.10-R0.1-SNAPSHOT;
CommandHelper version: 3.3.1-SNAPSHOT.2779-;
Loaded extensions and versions:
CHDangerous (version 1.0.1);
Core (version 3.3.1);
CHSpigot (version 1.2.3);
Here's the stacktrace:
java.lang.NullPointerException
        at com.laytonsmith.core.functions.InventoryManagement$ptake_item.match(InventoryManagement.java:820)
        at com.laytonsmith.core.functions.InventoryManagement$ptake_item.exec(InventoryManagement.java:803)
        at com.laytonsmith.core.Script.eval(Script.java:353)
        at com.laytonsmith.core.MethodScriptCompiler.execute(MethodScriptCompiler.java:1901)
        at com.laytonsmith.core.MethodScriptCompiler.execute(MethodScriptCompiler.java:1858)
        at com.laytonsmith.commandhelper.CommandHelperInterpreterListener.execute(CommandHelperInterpreterListener.java:170)
        at com.laytonsmith.commandhelper.CommandHelperInterpreterListener.textLine(CommandHelperInterpreterListener.java:131)
        at com.laytonsmith.commandhelper.CommandHelperInterpreterListener$1.run(CommandHelperInterpreterListener.java:70)
        at org.bukkit.craftbukkit.v1_7_R4.scheduler.CraftTask.run(CraftTask.java:71)
        at org.bukkit.craftbukkit.v1_7_R4.scheduler.CraftScheduler.mainThreadHeartbeat(CraftScheduler.java:346)
        at net.minecraft.server.v1_7_R4.MinecraftServer.v(MinecraftServer.java:638)
        at net.minecraft.server.v1_7_R4.DedicatedServer.v(DedicatedServer.java:289)
        at net.minecraft.server.v1_7_R4.MinecraftServer.u(MinecraftServer.java:584)
        at net.minecraft.server.v1_7_R4.MinecraftServer.run(MinecraftServer.java:490)
        at net.minecraft.server.v1_7_R4.ThreadServerApplication.run(SourceFile:628)

>
commented

Comment by jb_aero

I'm not sure what is actually causing this, it seems like it should happen even when you don't give it null.

commented

Comment by Pieter12345

Fixed in:
#283

commented

Comment by PseudoKnight

Wouldn't a better solution be to check if the argument is CNull and throw an exception? Or maybe even throw an exception in parseItemNotation() instead of returning a zero item stack. Since this is an item notation issue only.

BTW, why does getInt() return 0 for null? Should it?