Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NPE on getting stack size of empty object when deleting from saved variables #5270

Closed
1 task done
yoinked-h opened this issue Dec 24, 2022 · 5 comments
Closed
1 task done
Labels
bug An issue that needs to be fixed. Alternatively, a PR fixing an issue. completed The issue has been fully resolved and the change will be in the next Skript update. priority: low Issues that are not harmful to the experience but are related to useful changes or additions.

Comments

@yoinked-h
Copy link

yoinked-h commented Dec 24, 2022

Skript/Server Version

[01:35:39 INFO]: [Skript] Skript's aliases can be found here: https://github.com/SkriptLang/skript-aliases
[01:35:39 INFO]: [Skript] Skript's documentation can be found here: https://docs.skriptlang.org/
[01:35:39 INFO]: [Skript] Skript's tutorials can be found here: https://docs.skriptlang.org/tutorials
[01:35:39 INFO]: [Skript] Server Version: git-Purpur-1772 (MC: 1.19.2)
[01:35:39 INFO]: [Skript] Skript Version: 2.6.4
[01:35:39 INFO]: [Skript] Installed Skript Addons: None
[01:35:39 INFO]: [Skript] Installed dependencies: None

Bug Description

removing a saved item from a chest is highly unstable, i tried to save it so i can add it to a later chest, although im sure theres a better way

Expected Behavior

instead of erroring, to remove the item from the chest

Steps to Reproduce

  1. save a chest block into a var {_a}
  2. save a random element of {_a} into a var {_b}
  3. delete {_b} from inventory of {_a}
  4. error
    (i'll share the code if necessary because it's a total trainwreck)

Errors or Screenshots

[01:30:38 ERROR]: #!#! 
[01:30:38 ERROR]: #!#! [Skript] Severe Error:
[01:30:38 ERROR]: #!#! 
[01:30:38 ERROR]: #!#! Something went horribly wrong with Skript.
[01:30:38 ERROR]: #!#! This issue is NOT your fault! You probably can't fix it yourself, either.
[01:30:38 ERROR]: #!#! You should report it at https://github.com/SkriptLang/Skript/issues. Please copy paste this report there (or use paste service).
[01:30:38 ERROR]: #!#! This ensures that your issue is noticed and will be fixed as soon as possible.
[01:30:38 ERROR]: #!#! 
[01:30:38 ERROR]: #!#! Stack trace:
[01:30:38 ERROR]: #!#! java.lang.NullPointerException: Cannot invoke "org.bukkit.inventory.ItemStack.getAmount()" because "item" is null
[01:30:38 ERROR]: #!#!     at org.bukkit.craftbukkit.v1_19_R1.inventory.CraftInventory.removeItem(CraftInventory.java:376)
[01:30:38 ERROR]: #!#!     at org.bukkit.craftbukkit.v1_19_R1.inventory.CraftInventory.removeItem(CraftInventory.java:359)
[01:30:38 ERROR]: #!#!     at skript.jar//ch.njol.skript.classes.data.DefaultChangers$5.change(DefaultChangers.java:262)
[01:30:38 ERROR]: #!#!     at skript.jar//ch.njol.skript.classes.data.DefaultChangers$5.change(DefaultChangers.java:176)
[01:30:38 ERROR]: #!#!     at skript.jar//ch.njol.skript.lang.util.SimpleExpression.change(SimpleExpression.java:240)
[01:30:38 ERROR]: #!#!     at skript.jar//ch.njol.skript.effects.EffChange.execute(EffChange.java:282)
[01:30:38 ERROR]: #!#!     at skript.jar//ch.njol.skript.lang.Effect.run(Effect.java:50)
[01:30:38 ERROR]: #!#!     at skript.jar//ch.njol.skript.lang.TriggerItem.walk(TriggerItem.java:61)
[01:30:38 ERROR]: #!#!     at skript.jar//ch.njol.skript.lang.TriggerItem.walk(TriggerItem.java:89)
[01:30:38 ERROR]: #!#!     at skript.jar//ch.njol.skript.lang.Trigger.execute(Trigger.java:56)
[01:30:38 ERROR]: #!#!     at skript.jar//ch.njol.skript.SkriptEventHandler.check(SkriptEventHandler.java:142)
[01:30:38 ERROR]: #!#!     at skript.jar//ch.njol.skript.SkriptEventHandler.access$000(SkriptEventHandler.java:53)
[01:30:38 ERROR]: #!#!     at skript.jar//ch.njol.skript.SkriptEventHandler$PriorityListener.lambda$new$0(SkriptEventHandler.java:71)
[01:30:38 ERROR]: #!#!     at co.aikar.timings.TimedEventExecutor.execute(TimedEventExecutor.java:80)
[01:30:38 ERROR]: #!#!     at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.java:70)
[01:30:38 ERROR]: #!#!     at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.java:678)
[01:30:38 ERROR]: #!#!     at org.bukkit.craftbukkit.v1_19_R1.event.CraftEventFactory.callPlayerInteractEvent(CraftEventFactory.java:544)
[01:30:38 ERROR]: #!#!     at net.minecraft.server.level.PlayerInteractManager.a(PlayerInteractManager.java:527)
[01:30:38 ERROR]: #!#!     at net.minecraft.server.network.PlayerConnection.a(PlayerConnection.java:2050)
[01:30:38 ERROR]: #!#!     at net.minecraft.network.protocol.game.PacketPlayInUseItem.a(PacketPlayInUseItem.java:37)
[01:30:38 ERROR]: #!#!     at net.minecraft.network.protocol.game.PacketPlayInUseItem.a(PacketPlayInUseItem.java:9)
[01:30:38 ERROR]: #!#!     at net.minecraft.network.protocol.PlayerConnectionUtils.lambda$ensureRunningOnSameThread$0(PlayerConnectionUtils.java:51)
[01:30:38 ERROR]: #!#!     at net.minecraft.server.TickTask.run(TickTask.java:18)
[01:30:38 ERROR]: #!#!     at net.minecraft.util.thread.IAsyncTaskHandler.d(IAsyncTaskHandler.java:153)
[01:30:38 ERROR]: #!#!     at net.minecraft.util.thread.IAsyncTaskHandlerReentrant.d(IAsyncTaskHandlerReentrant.java:24)
[01:30:38 ERROR]: #!#!     at net.minecraft.server.MinecraftServer.b(MinecraftServer.java:1388)
[01:30:38 ERROR]: #!#!     at net.minecraft.server.MinecraftServer.d(MinecraftServer.java:185)
[01:30:38 ERROR]: #!#!     at net.minecraft.util.thread.IAsyncTaskHandler.x(IAsyncTaskHandler.java:126)
[01:30:38 ERROR]: #!#!     at net.minecraft.server.MinecraftServer.bh(MinecraftServer.java:1365)
[01:30:38 ERROR]: #!#!     at net.minecraft.server.MinecraftServer.x(MinecraftServer.java:1358)
[01:30:38 ERROR]: #!#!     at net.minecraft.util.thread.IAsyncTaskHandler.c(IAsyncTaskHandler.java:136)
[01:30:38 ERROR]: #!#!     at net.minecraft.server.MinecraftServer.w(MinecraftServer.java:1336)
[01:30:38 ERROR]: #!#!     at net.minecraft.server.MinecraftServer.v(MinecraftServer.java:1224)
[01:30:38 ERROR]: #!#!     at net.minecraft.server.MinecraftServer.lambda$spin$1(MinecraftServer.java:310)
[01:30:38 ERROR]: #!#!     at java.base/java.lang.Thread.run(Thread.java:833)
[01:30:38 ERROR]: #!#! 
[01:30:38 ERROR]: #!#! Version Information:
[01:30:38 ERROR]: #!#!   Skript: 2.6.4 (latest)
[01:30:38 ERROR]: #!#!     Flavor: skriptlang-github
[01:30:38 ERROR]: #!#!     Date: 17:14:25.041218900
[01:30:38 ERROR]: #!#!   Bukkit: 1.19.2-R0.1-SNAPSHOT
[01:30:38 ERROR]: #!#!   Minecraft: 1.19.2
[01:30:38 ERROR]: #!#!   Java: 17.0.5 (OpenJDK 64-Bit Server VM 17.0.5+8)
[01:30:38 ERROR]: #!#!   OS: Windows 10 amd64 10.0
[01:30:38 ERROR]: #!#! 
[01:30:38 ERROR]: #!#! Server platform: Paper
[01:30:38 ERROR]: #!#! 
[01:30:38 ERROR]: #!#! Current node: null
[01:30:38 ERROR]: #!#! Current item: remove {_tony} (as java.lang.Iterable) from inventory of {_orig} (as org.bukkit.inventory.InventoryHolder)
[01:30:38 ERROR]: #!#! Current trigger: rightclick on chest (rightclick on [[itemtype:chest]]) (pseudo.sk, line 5)
[01:30:38 ERROR]: #!#!
[01:30:38 ERROR]: #!#! Thread: Server thread
[01:30:38 ERROR]: #!#!
[01:30:38 ERROR]: #!#! Language: english
[01:30:38 ERROR]: #!#! Link parse mode: DISABLED
[01:30:38 ERROR]: #!#!
[01:30:38 ERROR]: #!#! End of Error.
[01:30:38 ERROR]: #!#!

Other

this is a 'dont do that' kind of report since i went for a lazy approach

Agreement

  • I have read the guidelines above and affirm I am following them with this report.
@TheLimeGlass
Copy link
Collaborator

TheLimeGlass commented Dec 24, 2022

Cannot reproduce on 1.19.3 and both Skript 2.6.4 and 2.7 (The code for this DefaultChanger wasn't changed). The error is happening within CraftBukkit so it's a Spigot and/or PaperSpigot issue. Can you try grabbing the latest version of Paper from https://papermc.io/downloads for your version. Type /version to see how many versions you're behind. The current revision of Spigot is R2 and you're on R1.

Can you verify this Skript code is similar to what caused the error?
Ignore the assertion condition check.

on right click on chest:
	assert clicked block is a chest with "Was not a chest"
	# save a chest block into a var {_a}
	set {_chest} to clicked block
	message "target block set"
	# save a random element of {_a} into a var {_b}
	set {_item} to a random item out of all items in {_chest}
	# delete {_b} from inventory of {_a}
	remove {_item} from inventory of {_chest}
	#error

@TheLimeGlass TheLimeGlass added investigating The core developers are currently investigating this issue. Usually used for complex cases. server issue This is an issue with the Spigot/Paper/etc server, and should be reported to the server software. labels Dec 24, 2022
@yoinked-h
Copy link
Author

im running this on purpur (paper fork with more customizability) so this could be an old version issue
the code looks like the error code, just with random item it was a first item (both error) and that i was using random element out of the inventory of; this is the code that gives me an error, (modified)

on right click on chest:
	# save a chest block into a var {_a}
	set {_chest} to event-block
	message "target block set"
	# save a random element of {_a} into a var {_b}
	set {_item} to a random element out of the inventory of {_chest}
	# delete {_b} from inventory of {_a}
	remove {_item} from inventory of {_chest}
	#error

@yoinked-h
Copy link
Author

yoinked-h commented Dec 25, 2022

latest purpur on 1.19.2 still gives the same error, full log here; trying it on latest 1.19.3

@yoinked-h
Copy link
Author

yup, 1.19.3 R2 does crash
logs:

[00:11:39 ERROR]: #!#! 
[00:11:39 ERROR]: #!#! [Skript] Severe Error:
[00:11:39 ERROR]: #!#! 
[00:11:39 ERROR]: #!#! Something went horribly wrong with Skript.
[00:11:39 ERROR]: #!#! This issue is NOT your fault! You probably can't fix it yourself, either.
[00:11:39 ERROR]: #!#! You should report it at https://github.com/SkriptLang/Skript/issues. Please copy paste this report there (or use paste service).
[00:11:39 ERROR]: #!#! This ensures that your issue is noticed and will be fixed as soon as possible.
[00:11:39 ERROR]: #!#! 
[00:11:39 ERROR]: #!#! Stack trace:
[00:11:39 ERROR]: #!#! java.lang.NullPointerException: Cannot invoke "org.bukkit.inventory.ItemStack.getAmount()" because "item" is null
[00:11:39 ERROR]: #!#!     at org.bukkit.craftbukkit.v1_19_R2.inventory.CraftInventory.removeItem(CraftInventory.java:377)
[00:11:39 ERROR]: #!#!     at org.bukkit.craftbukkit.v1_19_R2.inventory.CraftInventory.removeItem(CraftInventory.java:360)
[00:11:39 ERROR]: #!#!     at skript.jar//ch.njol.skript.classes.data.DefaultChangers$5.change(DefaultChangers.java:262)
[00:11:39 ERROR]: #!#!     at skript.jar//ch.njol.skript.classes.data.DefaultChangers$5.change(DefaultChangers.java:176)
[00:11:39 ERROR]: #!#!     at skript.jar//ch.njol.skript.lang.util.SimpleExpression.change(SimpleExpression.java:240)
[00:11:39 ERROR]: #!#!     at skript.jar//ch.njol.skript.effects.EffChange.execute(EffChange.java:282)
[00:11:39 ERROR]: #!#!     at skript.jar//ch.njol.skript.lang.Effect.run(Effect.java:50)
[00:11:39 ERROR]: #!#!     at skript.jar//ch.njol.skript.lang.TriggerItem.walk(TriggerItem.java:61)
[00:11:39 ERROR]: #!#!     at skript.jar//ch.njol.skript.lang.TriggerItem.walk(TriggerItem.java:89)
[00:11:39 ERROR]: #!#!     at skript.jar//ch.njol.skript.lang.Trigger.execute(Trigger.java:56)
[00:11:39 ERROR]: #!#!     at skript.jar//ch.njol.skript.SkriptEventHandler.check(SkriptEventHandler.java:142)
[00:11:39 ERROR]: #!#!     at skript.jar//ch.njol.skript.SkriptEventHandler.access$000(SkriptEventHandler.java:53)
[00:11:39 ERROR]: #!#!     at skript.jar//ch.njol.skript.SkriptEventHandler$PriorityListener.lambda$new$0(SkriptEventHandler.java:71)
[00:11:39 ERROR]: #!#!     at co.aikar.timings.TimedEventExecutor.execute(TimedEventExecutor.java:80)
[00:11:39 ERROR]: #!#!     at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.java:70)
[00:11:39 ERROR]: #!#!     at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.java:680)
[00:11:39 ERROR]: #!#!     at org.bukkit.craftbukkit.v1_19_R2.event.CraftEventFactory.callPlayerInteractEvent(CraftEventFactory.java:546)
[00:11:39 ERROR]: #!#!     at net.minecraft.server.level.PlayerInteractManager.a(PlayerInteractManager.java:530)
[00:11:39 ERROR]: #!#!     at net.minecraft.server.network.PlayerConnection.a(PlayerConnection.java:2040)
[00:11:39 ERROR]: #!#!     at net.minecraft.network.protocol.game.PacketPlayInUseItem.a(PacketPlayInUseItem.java:37)
[00:11:39 ERROR]: #!#!     at net.minecraft.network.protocol.game.PacketPlayInUseItem.a(PacketPlayInUseItem.java:9)
[00:11:39 ERROR]: #!#!     at net.minecraft.network.protocol.PlayerConnectionUtils.lambda$ensureRunningOnSameThread$0(PlayerConnectionUtils.java:51)
[00:11:39 ERROR]: #!#!     at net.minecraft.server.TickTask.run(TickTask.java:18)
[00:11:39 ERROR]: #!#!     at net.minecraft.util.thread.IAsyncTaskHandler.d(IAsyncTaskHandler.java:153)
[00:11:39 ERROR]: #!#!     at net.minecraft.util.thread.IAsyncTaskHandlerReentrant.d(IAsyncTaskHandlerReentrant.java:24)
[00:11:39 ERROR]: #!#!     at net.minecraft.server.MinecraftServer.b(MinecraftServer.java:1368)
[00:11:39 ERROR]: #!#!     at net.minecraft.server.MinecraftServer.d(MinecraftServer.java:197)
[00:11:39 ERROR]: #!#!     at net.minecraft.util.thread.IAsyncTaskHandler.x(IAsyncTaskHandler.java:126)
[00:11:39 ERROR]: #!#!     at net.minecraft.server.MinecraftServer.bh(MinecraftServer.java:1345)
[00:11:39 ERROR]: #!#!     at net.minecraft.server.MinecraftServer.x(MinecraftServer.java:1338)
[00:11:39 ERROR]: #!#!     at net.minecraft.util.thread.IAsyncTaskHandler.c(IAsyncTaskHandler.java:136)
[00:11:39 ERROR]: #!#!     at net.minecraft.server.MinecraftServer.i_(MinecraftServer.java:1316)
[00:11:39 ERROR]: #!#!     at net.minecraft.server.MinecraftServer.w(MinecraftServer.java:1204)
[00:11:39 ERROR]: #!#!     at net.minecraft.server.MinecraftServer.lambda$spin$0(MinecraftServer.java:321)
[00:11:39 ERROR]: #!#!     at java.base/java.lang.Thread.run(Thread.java:833)
[00:11:39 ERROR]: #!#! 
[00:11:39 ERROR]: #!#! Version Information:
[00:11:39 ERROR]: #!#!   Skript: 2.6.4 (latest)
[00:11:39 ERROR]: #!#!     Flavor: skriptlang-github
[00:11:39 ERROR]: #!#!     Date: 17:14:25.041218900
[00:11:39 ERROR]: #!#!   Bukkit: 1.19.3-R0.1-SNAPSHOT
[00:11:39 ERROR]: #!#!   Minecraft: 1.19.3
[00:11:39 ERROR]: #!#!   Java: 17.0.5 (OpenJDK 64-Bit Server VM 17.0.5+8)
[00:11:39 ERROR]: #!#!   OS: Windows 10 amd64 10.0
[00:11:39 ERROR]: #!#! 
[00:11:39 ERROR]: #!#! Server platform: Paper
[00:11:39 ERROR]: #!#! 
[00:11:39 ERROR]: #!#! Current node: null
[00:11:39 ERROR]: #!#! Current item: remove {_item} (as java.lang.Iterable) from inventory of {_chest} (as org.bukkit.inventory.InventoryHolder)
[00:11:39 ERROR]: #!#! Current trigger: right click on chest (rightclick on [[itemtype:chest]]) (crash.sk, line 1)
[00:11:39 ERROR]: #!#! 
[00:11:39 ERROR]: #!#! Thread: Server thread
[00:11:39 ERROR]: #!#! 
[00:11:39 ERROR]: #!#! Language: english
[00:11:39 ERROR]: #!#! Link parse mode: DISABLED
[00:11:39 ERROR]: #!#! 
[00:11:39 ERROR]: #!#! End of Error.
[00:11:39 ERROR]: #!#!

@UnderscoreTud UnderscoreTud added bug An issue that needs to be fixed. Alternatively, a PR fixing an issue. priority: low Issues that are not harmful to the experience but are related to useful changes or additions. PR available Issues which have a yet-to-be merged PR resolving it and removed investigating The core developers are currently investigating this issue. Usually used for complex cases. server issue This is an issue with the Spigot/Paper/etc server, and should be reported to the server software. labels Feb 27, 2023
@TheLimeGlass TheLimeGlass added completed The issue has been fully resolved and the change will be in the next Skript update. 2.7 Targeting a 2.7.X version release and removed PR available Issues which have a yet-to-be merged PR resolving it labels Mar 25, 2023
@TheLimeGlass
Copy link
Collaborator

Fixed in 2.7.0-beta2

@TheLimeGlass TheLimeGlass removed the 2.7 Targeting a 2.7.X version release label Mar 25, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug An issue that needs to be fixed. Alternatively, a PR fixing an issue. completed The issue has been fully resolved and the change will be in the next Skript update. priority: low Issues that are not harmful to the experience but are related to useful changes or additions.
Projects
None yet
Development

No branches or pull requests

3 participants