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

Fixes entitydata consumer on versions 1.20.1 and below. #6475

Conversation

TheLimeGlass
Copy link
Collaborator

@TheLimeGlass TheLimeGlass commented Mar 4, 2024

Description

Fixes an exception from being thrown when attempting to spawn an EntityData when there is no World involved with the Location.
See header of EntityData for an explanation of this reflection

/*
* In 1.20.2 Spigot deprecated org.bukkit.util.Consumer.
* From the class header: "API methods which use this consumer will be remapped to Java's consumer at runtime, resulting in an error."
* But in 1.13-1.16 the only way to use a consumer was World#spawn(Location, Class, org.bukkit.util.Consumer).
*/

[09:48:07] [Server thread/ERROR]: #!#! 
[09:48:07] [Server thread/ERROR]: #!#! Stack trace:
[09:48:07] [Server thread/ERROR]: #!#! java.lang.NullPointerException: Cannot invoke "Object.getClass()" because "obj" is null
[09:48:07] [Server thread/ERROR]: #!#!     at java.base/java.lang.reflect.Method.invoke(Method.java:561)
[09:48:07] [Server thread/ERROR]: #!#!     at ch.njol.skript.entity.EntityData.spawn(EntityData.java:654)
[09:48:07] [Server thread/ERROR]: #!#!     at ch.njol.skript.entity.EntityData.spawn(EntityData.java:507)
[09:48:07] [Server thread/ERROR]: #!#!     at ch.njol.skript.sections.EffSecSpawn.walk(EffSecSpawn.java:172)
[09:48:07] [Server thread/ERROR]: #!#!     at ch.njol.skript.lang.TriggerItem.walk(TriggerItem.java:88)
[09:48:07] [Server thread/ERROR]: #!#!     at ch.njol.skript.lang.Trigger.execute(Trigger.java:52)
[09:48:07] [Server thread/ERROR]: #!#!     at ch.njol.skript.command.ScriptCommand.execute2(ScriptCommand.java:316)
[09:48:07] [Server thread/ERROR]: #!#!     at ch.njol.skript.command.ScriptCommand.lambda$execute$0(ScriptCommand.java:275)
[09:48:07] [Server thread/ERROR]: #!#!     at ch.njol.skript.command.ScriptCommand.execute(ScriptCommand.java:286)
[09:48:07] [Server thread/ERROR]: #!#!     at ch.njol.skript.command.ScriptCommand.onCommand(ScriptCommand.java:221)
[09:48:07] [Server thread/ERROR]: #!#!     at org.bukkit.command.PluginCommand.execute(PluginCommand.java:45)
[09:48:07] [Server thread/ERROR]: #!#!     at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:155)
[09:48:07] [Server thread/ERROR]: #!#!     at org.bukkit.craftbukkit.v1_20_R1.CraftServer.dispatchCommand(CraftServer.java:987)
[09:48:07] [Server thread/ERROR]: #!#!     at org.bukkit.craftbukkit.v1_20_R1.command.BukkitCommandWrapper.run(BukkitCommandWrapper.java:64)
[09:48:07] [Server thread/ERROR]: #!#!     at com.mojang.brigadier.CommandDispatcher.execute(CommandDispatcher.java:265)
[09:48:07] [Server thread/ERROR]: #!#!     at net.minecraft.commands.CommandDispatcher.performCommand(CommandDispatcher.java:324)
[09:48:07] [Server thread/ERROR]: #!#!     at net.minecraft.commands.CommandDispatcher.a(CommandDispatcher.java:308)
[09:48:07] [Server thread/ERROR]: #!#!     at net.minecraft.server.network.PlayerConnection.a(PlayerConnection.java:2354)
[09:48:07] [Server thread/ERROR]: #!#!     at net.minecraft.server.network.PlayerConnection.lambda$handleChatCommand$21(PlayerConnection.java:2314)
[09:48:07] [Server thread/ERROR]: #!#!     at net.minecraft.util.thread.IAsyncTaskHandler.b(IAsyncTaskHandler.java:59)
[09:48:07] [Server thread/ERROR]: #!#!     at java.base/java.util.concurrent.CompletableFuture$AsyncSupply.run(CompletableFuture.java:1768)
[09:48:07] [Server thread/ERROR]: #!#!     at net.minecraft.server.TickTask.run(TickTask.java:18)
[09:48:07] [Server thread/ERROR]: #!#!     at net.minecraft.util.thread.IAsyncTaskHandler.d(IAsyncTaskHandler.java:153)
[09:48:07] [Server thread/ERROR]: #!#!     at net.minecraft.util.thread.IAsyncTaskHandlerReentrant.d(IAsyncTaskHandlerReentrant.java:24)
[09:48:07] [Server thread/ERROR]: #!#!     at net.minecraft.server.MinecraftServer.b(MinecraftServer.java:1338)
[09:48:07] [Server thread/ERROR]: #!#!     at net.minecraft.server.MinecraftServer.d(MinecraftServer.java:197)
[09:48:07] [Server thread/ERROR]: #!#!     at net.minecraft.util.thread.IAsyncTaskHandler.x(IAsyncTaskHandler.java:126)
[09:48:07] [Server thread/ERROR]: #!#!     at net.minecraft.server.MinecraftServer.bg(MinecraftServer.java:1315)
[09:48:07] [Server thread/ERROR]: #!#!     at net.minecraft.server.MinecraftServer.x(MinecraftServer.java:1308)
[09:48:07] [Server thread/ERROR]: #!#!     at net.minecraft.util.thread.IAsyncTaskHandler.c(IAsyncTaskHandler.java:136)
[09:48:07] [Server thread/ERROR]: #!#!     at net.minecraft.server.MinecraftServer.p_(MinecraftServer.java:1286)
[09:48:07] [Server thread/ERROR]: #!#!     at net.minecraft.server.MinecraftServer.w(MinecraftServer.java:1174)
[09:48:07] [Server thread/ERROR]: #!#!     at net.minecraft.server.MinecraftServer.lambda$spin$0(MinecraftServer.java:317)
[09:48:07] [Server thread/ERROR]: #!#!     at java.base/java.lang.Thread.run(Thread.java:833)
[09:48:07] [Server thread/ERROR]: #!#! 
[09:48:07] [Server thread/ERROR]: #!#! Version Information:
[09:48:07] [Server thread/ERROR]: #!#!     Flavor: selfbuilt-unknown
[09:48:07] [Server thread/ERROR]: #!#!     Date: unknown
[09:48:07] [Server thread/ERROR]: #!#!   Bukkit: 1.20.1-R0.1-SNAPSHOT
[09:48:07] [Server thread/ERROR]: #!#!   Minecraft: 1.20.1
[09:48:07] [Server thread/ERROR]: #!#!   Java: 17.0.8.1 (OpenJDK 64-Bit Server VM 17.0.8.1+8-LTS)
[09:48:07] [Server thread/ERROR]: #!#!   OS: Linux amd64 5.10.0-24-amd64
[09:48:07] [Server thread/ERROR]: #!#! 
[09:48:07] [Server thread/ERROR]: #!#! Server platform: Paper
[09:48:07] [Server thread/ERROR]: #!#! 
[09:48:07] [Server thread/ERROR]: #!#! Current node: null
[09:48:07] [Server thread/ERROR]: #!#! Current item: spawn [[entitytype:iron golem]] at {1::golemLocations::%loop-value%} (as org.bukkit.Location)
[09:48:07] [Server thread/ERROR]: #!#! Current trigger: command /1 (simple event) (1/1.sk, line 302)
[09:48:07] [Server thread/ERROR]: #!#! 
[09:48:07] [Server thread/ERROR]: #!#! Thread: Server thread
[09:48:07] [Server thread/ERROR]: #!#! 
[09:48:07] [Server thread/ERROR]: #!#! Language: english
[09:48:07] [Server thread/ERROR]: #!#! Link parse mode: DISABLED
[09:48:07] [Server thread/ERROR]: #!#! 
[09:48:07] [Server thread/ERROR]: #!#! End of Error.
[09:48:07] [Server thread/ERROR]: #!#! 

This is caused by the world not being loaded on server start or in my case, a server crash. I plan on addressing this better in the future to not outright delete the World.

try {
world = location.getWorld();
} catch (IllegalArgumentException exception) {
Skript.warning("A location failed to serialize with its defined world, as the world was unloaded.");
}


Target Minecraft Versions: any
Requirements: none
Related Issues: none

@sovdeeth sovdeeth added bug An issue that needs to be fixed. Alternatively, a PR fixing an issue. 2.8 Targeting a 2.8.X version release patch-ready A PR/issue that has been approved and is ready to be merged/closed for the next patch version. labels Mar 4, 2024
@sovdeeth sovdeeth merged commit a44ed2f into SkriptLang:dev/patch Mar 19, 2024
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
2.8 Targeting a 2.8.X version release bug An issue that needs to be fixed. Alternatively, a PR fixing an issue. patch-ready A PR/issue that has been approved and is ready to be merged/closed for the next patch version.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants