TheMisterFish / Fabric_OfflinePlayersReworked

Allows a user to logout, leaving a fake player that loads the chunks
Creative Commons Zero v1.0 Universal
1 stars 0 forks source link

[Bug] Server launch, but "Offline player could not be created." #16

Closed Tellsanguis closed 2 months ago

Tellsanguis commented 2 months ago

Describe the bug The command doesn't work and no player is spawning.

To Reproduce Steps to reproduce the behavior:

  1. Change "autoDisconnect" to false (don't know if it's important).
  2. Try the command "/offline" and variants (/offline attack:20, eat...)
  3. Get "Offline player could not be created."

Expected behavior A fake player supposed to spawn.

Logs

java.lang.NullPointerException: null at java.base/java.util.Objects.requireNonNull(Objects.java:233) ~[?:?] at com.misterfish.patch.OfflinePlayer.createAndSpawnNewOfflinePlayer(OfflinePlayer.java:84) ~[offlineplayersreworked-1.0.3.jar:?] at com.misterfish.OfflinePlayersReworked.spawn(OfflinePlayersReworked.java:138) ~[offlineplayersreworked-1.0.3.jar:?] at com.misterfish.OfflinePlayersReworked.lambda$onInitializeServer$0(OfflinePlayersReworked.java:74) ~[offlineplayersreworked-1.0.3.jar:?] at com.mojang.brigadier.context.ContextChain.runExecutable(ContextChain.java:73) ~[brigadier-1.2.9.jar:?] at net.minecraft.class_8865.method_54416(class_8865.java:29) ~[server-intermediary.jar:?] at net.minecraft.class_8865.execute(class_8865.java:13) ~[server-intermediary.jar:?] at net.minecraft.class_8856.method_54405(class_8856.java:8) ~[server-intermediary.jar:?] at net.minecraft.class_8847.method_54388(class_8847.java:8) ~[server-intermediary.jar:?] at net.minecraft.class_8854.method_54390(class_8854.java:107) ~[server-intermediary.jar:?] at net.minecraft.class_2170.method_54313(class_2170.java:379) ~[server-intermediary.jar:?] at net.minecraft.class_2170.method_9249(class_2170.java:309) ~[server-intermediary.jar:?] at net.minecraft.class_3244.method_58590(class_3244.java:1319) ~[server-intermediary.jar:?] at net.minecraft.class_3244.method_44356(class_3244.java:1307) ~[server-intermediary.jar:?] at net.minecraft.class_3738.run(class_3738.java:18) ~[server-intermediary.jar:?] at net.minecraft.class_1255.method_18859(class_1255.java:162) ~[server-intermediary.jar:?] at net.minecraft.class_4093.method_18859(class_4093.java:23) ~[server-intermediary.jar:?] at net.minecraft.server.MinecraftServer.method_24306(MinecraftServer.java:864) ~[server-intermediary.jar:?] at net.minecraft.server.MinecraftServer.method_18859(MinecraftServer.java:173) ~[server-intermediary.jar:?] at net.minecraft.class_1255.method_16075(class_1255.java:136) ~[server-intermediary.jar:?] at net.minecraft.server.MinecraftServer.method_20415(MinecraftServer.java:846) ~[server-intermediary.jar:?] at net.minecraft.server.MinecraftServer.method_16075(MinecraftServer.java:840) ~[server-intermediary.jar:?] at net.minecraft.class_1255.method_5383(class_1255.java:121) ~[server-intermediary.jar:?] at net.minecraft.server.MinecraftServer.method_16208(MinecraftServer.java:814) ~[server-intermediary.jar:?] at net.minecraft.server.MinecraftServer.method_29741(MinecraftServer.java:702) ~[server-intermediary.jar:?] at net.minecraft.server.MinecraftServer.method_29739(MinecraftServer.java:281) ~[server-intermediary.jar:?] at java.base/java.lang.Thread.run(Thread.java:1583) [?:?]

Versions (please complete the following information):

Additional context Mod list:

TheMisterFish commented 2 months ago

Comparing the error log with the code this has to do with the chatSession being null. The auto disconnect option doesn't affect this, that is more of a kind of debug config setting.

I'll try resolving this asap, thanks for finding.

TheMisterFish commented 2 months ago

@Tellsanguis ~would you like to test the 1.0.4 jar before I release in case there are more bugs? On my own server I didn't get this one.~ I've updated it in release 1.0.4.

Tellsanguis commented 2 months ago

It works! The player appears and I can decide on his actions.

I'm doing some tests, and it doesn't look like the fake player can spawn mobs (or at least raids, after testing in my raid farm). Maybe because the real player is still connected? I'll do some more tests (including some with the main player offline) and get back to you

TheMisterFish commented 2 months ago

Thank you for testing! Much appreciated.

TheMisterFish commented 2 months ago

I think you are correct regarding starting a raid. It should work using the eat action but doesn't because there's a statement that checks if the player can eat. In that check a player can only eat if he's hungry. I'll create a enhancement ticket to fix this.

https://github.com/TheMisterFish/Fabric_OfflinePlayersReworked/issues/18

TheMisterFish commented 2 months ago

@Tellsanguis 1.0.5 is now released. I've added a check to see if the ominous effect is active, if it is active the offlinePlayer will not drink a new bottle. But this does mean that when the raid starting, the offlinePlayer is able to drink a new bottle. I don't know about the exact timing but you could try something like /offline eat:1.5m to only trigger the effect every one and a half minute. Let me know if this is a good solution; otherwise feel free to create a Enhancement ticket 💪

Tellsanguis commented 2 months ago

Thanks for your work! I'll test it all tomorrow in my spare time 💪

Tellsanguis commented 2 months ago

Hey! Sorry for my late return! After several tests, everything works perfectly! The optimal command for the raid farm model I'm using, from TurtleCraft in 1.21, seems to be /offline attack:15 eat: (at 14 I have no mobs spawn). The potions are well drunk, and at the right interval (I had a workaround before the updates where I made my player hungry to drink the potions). For all farms where it only requires the player's presence, it's perfect!

In short, your mod is absolutely brilliant and allows me to give other players on my server access to a command that lets them farm without being in front of their computer, and without giving them huge permissions like with the Carpet mod! Thank you so much!

TheMisterFish commented 2 months ago

Thank you very much for the kind words! Glad the mod works well 😁