Lauriethefish / BetterPortals

My plugin version of the popular BetterPortals mod which has many limitations, but requires no client side code
zlib License
68 stars 35 forks source link

NPE upon portal destination world does not exist anymore (should give better error) #159

Open BlueFyreMatt opened 2 years ago

BlueFyreMatt commented 2 years ago

Describe the bug What is going wrong? Does the plugin crash? What have you tried to try and fix the problem, if anything.

After a short amount of time (With this example, 13 minutes), the server will disable BetterPortals with the following error:

[04:25:08] [Server thread/ERROR]: [BetterPortals] A critical error occurred during plugin execution. [04:25:08] [Server thread/ERROR]: [BetterPortals] Please create an issue at https://github.com/Lauriethefish/BetterPortals/issues to get this fixed. [04:25:08] [Server thread/WARN]: java.lang.NullPointerException: Cannot invoke "org.bukkit.World.getChunkAt(int, int)" because "this.world" is null [04:25:08] [Server thread/WARN]: at BetterPortals-0.12.1.jar//com.lauriethefish.betterportals.bukkit.chunk.chunkpos.ChunkPosition.getChunk(ChunkPosition.java:56) [04:25:08] [Server thread/WARN]: at BetterPortals-0.12.1.jar//com.lauriethefish.betterportals.bukkit.chunk.chunkloading.IChunkLoader.forceLoadAllPos(IChunkLoader.java:21) [04:25:08] [Server thread/WARN]: at BetterPortals-0.12.1.jar//com.lauriethefish.betterportals.bukkit.chunk.chunkloading.PortalChunkLoader.forceloadPortalChunks(PortalChunkLoader.java:40) [04:25:08] [Server thread/WARN]: at BetterPortals-0.12.1.jar//com.lauriethefish.betterportals.bukkit.portal.Portal.onActivate(Portal.java:96) [04:25:08] [Server thread/WARN]: at BetterPortals-0.12.1.jar//com.lauriethefish.betterportals.bukkit.portal.PortalActivityManager.onPortalActivatedThisTick(PortalActivityManager.java:29) [04:25:08] [Server thread/WARN]: at BetterPortals-0.12.1.jar//com.lauriethefish.betterportals.bukkit.player.PlayerData.updateViewablePortals(PlayerData.java:92) [04:25:08] [Server thread/WARN]: at BetterPortals-0.12.1.jar//com.lauriethefish.betterportals.bukkit.player.PlayerData.onUpdate(PlayerData.java:108) [04:25:08] [Server thread/WARN]: at java.base/java.util.HashMap$Values.forEach(HashMap.java:1065) [04:25:08] [Server thread/WARN]: at java.base/java.util.Collections$UnmodifiableCollection.forEach(Collections.java:1092) [04:25:08] [Server thread/WARN]: at BetterPortals-0.12.1.jar//com.lauriethefish.betterportals.bukkit.tasks.MainUpdate.run(MainUpdate.java:47) [04:25:08] [Server thread/WARN]: at org.bukkit.craftbukkit.v1_19_R1.scheduler.CraftTask.run(CraftTask.java:101) [04:25:08] [Server thread/WARN]: at org.bukkit.craftbukkit.v1_19_R1.scheduler.CraftScheduler.mainThreadHeartbeat(CraftScheduler.java:483) [04:25:08] [Server thread/WARN]: at net.minecraft.server.MinecraftServer.b(MinecraftServer.java:1517) [04:25:08] [Server thread/WARN]: at net.minecraft.server.dedicated.DedicatedServer.b(DedicatedServer.java:485) [04:25:08] [Server thread/WARN]: at net.minecraft.server.MinecraftServer.a(MinecraftServer.java:1441) [04:25:08] [Server thread/WARN]: at net.minecraft.server.MinecraftServer.v(MinecraftServer.java:1208) [04:25:08] [Server thread/WARN]: at net.minecraft.server.MinecraftServer.lambda$spin$1(MinecraftServer.java:307) [04:25:08] [Server thread/WARN]: at java.base/java.lang.Thread.run(Thread.java:833) [04:25:08] [Server thread/INFO]: [BetterPortals] Attempting to shut down the plugin . . . [04:25:08] [Server thread/INFO]: [BetterPortals] Disabling BetterPortals v0.12.1

To Reproduce How would I make this bug happen in order to fix it?

Currently unknown, portals link to separate worlds (Spawn world to main world) and are bi-directional.

Server Logs Please enable debug logging by setting logLevel in the config file to FINER, then running /bp reload. Try to reproduce your issue, then send your full server log here.

If you can't do this for security reasons, an excerpt of log will probably suffice.

In the following example, the server was online for 12 seconds.

[03:54:05 INFO]: [BetterPortals] [FNE] Viewable block array update took: 12.640 ms. Block count: 17697. Viewable count: 6020 [03:54:05 INFO]: UUID of player Capetian is 7014b2bf-975b-46d5-a551-5d8e7096113b [03:54:06 INFO]: [BetterPortals] [FNE] Registering player data on join for player: cce08be5-a5e5-48c9-8f12-73b2ea2ca67c [03:54:06 INFO]: [+] SamG [03:54:06 INFO]: SamG[/Redacted] logged in with entity id 4655 at ([world]3011.263194559094, 64.0, -7313.556420317802) [03:54:06 INFO]: [SMPELoginRewards] Registered player into database: SamG_ [03:54:06 INFO]: [towny] C_Goji: first? [03:54:06 INFO]: [BetterPortals] [FNE] Viewable block array update took: 35.767 ms. Block count: 17697. Viewable count: 6020 [03:54:07 INFO]: [BetterPortals] [FNE] Viewable block array update took: 10.818 ms. Block count: 17697. Viewable count: 6020 [03:54:07 INFO]: ShiftHQ issued server command: /smpeloginrewards:loginrewards from-reminder [03:54:08 INFO]: [BetterPortals] [FNE] Registering player data on join for player: 2b3adbf9-1b67-4d21-aae4-c1b7d23b2745 [03:54:08 INFO]: [+] Haloyayz [03:54:08 INFO]: Haloyayz[/Redacted] logged in with entity id 4576 at ([world]28993.855258162544, 27.5, 1035.1391771122653) [03:54:08 INFO]: [SMPELoginRewards] Registered player into database: Haloyayz [03:54:08 INFO]: [BetterPortals] [FNE] Viewable block array update took: 10.594 ms. Block count: 17697. Viewable count: 6020 [03:54:09 INFO]: [BetterPortals] [FNE] Viewable block array update took: 11.187 ms. Block count: 17697. Viewable count: 6020 [03:54:10 INFO]: [BetterPortals] [FNE] Registering player data on join for player: 7014b2bf-975b-46d5-a551-5d8e7096113b [03:54:10 INFO]: [+] Capetian [03:54:10 INFO]: Capetian[/Redacted] logged in with entity id 5141 at ([world]-421.53895598284214, 65.0, -11336.281446337487) [03:54:10 INFO]: [SMPELoginRewards] Registered player into database: Capetian [03:54:10 INFO]: [BetterPortals] [FNE] Viewable block array update took: 18.386 ms. Block count: 17697. Viewable count: 6020 [03:54:11 INFO]: [BetterPortals] [FNE] Viewable block array update took: 7.974 ms. Block count: 17697. Viewable count: 6020 [03:54:12 INFO]: [BetterPortals] [FNE] Viewable block array update took: 10.965 ms. Block count: 17697. Viewable count: 6020 [03:54:13 INFO]: [BetterPortals] [FNR] Portal was activated [03:54:13 ERROR]: [BetterPortals] A critical error occurred during plugin execution. [03:54:13 ERROR]: [BetterPortals] Please create an issue at https://github.com/Lauriethefish/BetterPortals/issues to get this fixed. [03:54:13 WARN]: java.lang.NullPointerException: Cannot invoke "org.bukkit.World.getChunkAt(int, int)" because "this.world" is null [03:54:13 WARN]: at BetterPortals-0.12.1.jar//com.lauriethefish.betterportals.bukkit.chunk.chunkpos.ChunkPosition.getChunk(ChunkPosition.java:56) [03:54:13 WARN]: at BetterPortals-0.12.1.jar//com.lauriethefish.betterportals.bukkit.chunk.chunkloading.IChunkLoader.forceLoadAllPos(IChunkLoader.java:21) [03:54:13 WARN]: at BetterPortals-0.12.1.jar//com.lauriethefish.betterportals.bukkit.chunk.chunkloading.PortalChunkLoader.forceloadPortalChunks(PortalChunkLoader.java:40) [03:54:13 WARN]: at BetterPortals-0.12.1.jar//com.lauriethefish.betterportals.bukkit.portal.Portal.onActivate(Portal.java:96) [03:54:13 WARN]: at BetterPortals-0.12.1.jar//com.lauriethefish.betterportals.bukkit.portal.PortalActivityManager.onPortalActivatedThisTick(PortalActivityManager.java:29) [03:54:13 WARN]: at BetterPortals-0.12.1.jar//com.lauriethefish.betterportals.bukkit.player.PlayerData.updateViewablePortals(PlayerData.java:92) [03:54:13 WARN]: at BetterPortals-0.12.1.jar//com.lauriethefish.betterportals.bukkit.player.PlayerData.onUpdate(PlayerData.java:108) [03:54:13 WARN]: at java.base/java.util.HashMap$Values.forEach(HashMap.java:1065) [03:54:13 WARN]: at java.base/java.util.Collections$UnmodifiableCollection.forEach(Collections.java:1092) [03:54:13 WARN]: at BetterPortals-0.12.1.jar//com.lauriethefish.betterportals.bukkit.tasks.MainUpdate.run(MainUpdate.java:47) [03:54:13 WARN]: at org.bukkit.craftbukkit.v1_19_R1.scheduler.CraftTask.run(CraftTask.java:101) [03:54:13 WARN]: at org.bukkit.craftbukkit.v1_19_R1.scheduler.CraftScheduler.mainThreadHeartbeat(CraftScheduler.java:483) [03:54:13 WARN]: at net.minecraft.server.MinecraftServer.b(MinecraftServer.java:1517) [03:54:13 WARN]: at net.minecraft.server.dedicated.DedicatedServer.b(DedicatedServer.java:485) [03:54:13 WARN]: at net.minecraft.server.MinecraftServer.a(MinecraftServer.java:1441) [03:54:13 WARN]: at net.minecraft.server.MinecraftServer.v(MinecraftServer.java:1208) [03:54:13 WARN]: at net.minecraft.server.MinecraftServer.lambda$spin$1(MinecraftServer.java:307) [03:54:13 WARN]: at java.base/java.lang.Thread.run(Thread.java:833) [03:54:13 INFO]: [BetterPortals] Attempting to shut down the plugin . . . [03:54:13 INFO]: [BetterPortals] Disabling BetterPortals v0.12.1 [03:54:13 INFO]: [BetterPortals] [FNR] Checking deactivation type of portal view, previous pos: (7.41, 73.00, -29.28, spawn), current pos: (7.61, 73.00, -29.02, spawn) [03:54:13 INFO]: [BetterPortals] [FNR] Player block view deactivating. Should reset states: true [03:54:13 INFO]: [BetterPortals] [FNE] Saving all portals . . . [03:54:13 INFO]: [BetterPortals] [FNE] Goodbye from block view update thread! [03:54:13 INFO]: [BetterPortals] [FNE] Saved 15 portals [03:54:13 INFO]: [BetterPortals] [FNE] Saving to plugins/BetterPortals/data/portals.yml [03:54:13 INFO]: [BetterPortals] [FNE] Goodbye!

Additional context Plugin Version: 0.12.1 Game Version: git-purpur-1685 (1.19)

Lauriethefish commented 2 years ago

Did either the origin or destination world of the portal get unloaded?

BlueFyreMatt commented 2 years ago

Just had a look through portals.yml, turns out one of the devs renamed one of the world files which probably broke this portal as its destination is invalid... I notice you're numbering each portal in portals.yml, does this need to remain consecutive or can a number be skipped? (IE if I remove 8, will I need to re-number all portals following that?)

Lauriethefish commented 2 years ago

I think you will need to re-number the portals if I recall correctly. Renaming this issue to track providing a better error message for this.

Lauriethefish commented 2 years ago

Nope, sorry @BlueFyreMatt, you won't need to renumber the portals. Make a backup of portals.yml before you do any editing though.

BlueFyreMatt commented 2 years ago

Seems to have worked just fine! I edited the numbers anyway just for the consecutive satisfaction, but the plugins working just fine now. Thanks for the prompt help!

Lauriethefish commented 2 years ago

I renamed the issue so it's still relevant.