Paper icon indicating copy to clipboard operation
Paper copied to clipboard

Can't enable/disable a datapack on startup

Open Valgrifer opened this issue 1 year ago • 5 comments

Stack trace

[22:32:53 ERROR]: [CustomPackLib] an exception was thrown java.lang.NullPointerException: Cannot invoke "net.minecraft.util.debugchart.DebugSampleSubscriptionTracker.shouldLogSamples(net.minecraft.util.debugchart.RemoteDebugSampleType)" because "this.debugSampleSubscriptionTracker" is null at net.minecraft.server.dedicated.DedicatedServer.isTickTimeLoggingEnabled(DedicatedServer.java:901) ~[paper-1.21.1.jar:1.21.1-3-70dfa46] at net.minecraft.server.MinecraftServer.waitForTasks(MinecraftServer.java:1480) ~[paper-1.21.1.jar:1.21.1-3-70dfa46] at net.minecraft.util.thread.BlockableEventLoop.managedBlock(BlockableEventLoop.java:136) ~[paper-1.21.1.jar:1.21.1-3-70dfa46] at net.minecraft.server.MinecraftServer.managedBlock(MinecraftServer.java:1466) ~[paper-1.21.1.jar:1.21.1-3-70dfa46] at net.minecraft.server.MinecraftServer.reloadResources(MinecraftServer.java:2359) ~[paper-1.21.1.jar:1.21.1-3-70dfa46] at io.papermc.paper.datapack.PaperDatapack.setEnabled(PaperDatapack.java:48) ~[paper-1.21.1.jar:?] at CustomPackLib-1.0.jar/fr.valcorp.custompacklib.CustomPackLib.lambda$onEnable$3(CustomPackLib.java:90) ~[CustomPackLib-1.0.jar:?] at java.base/java.util.HashMap.forEach(HashMap.java:1429) ~[?:?] at CustomPackLib-1.0.jar/fr.valcorp.custompacklib.CustomPackLib.onEnable(CustomPackLib.java:69) ~[CustomPackLib-1.0.jar:?]

Plugin and Datapack List

pl [22:35:11 INFO]: Server Plugins (1): [22:35:11 INFO]: Bukkit Plugins: [22:35:11 INFO]: - CustomPackLib datapack list [22:35:28 INFO]: There are 10 data pack(s) enabled: [vanilla (built-in)], [file/Terralith_1.21_v2.5.3.zip (world)], [file/Structory_1.21_v1.3.5.zip (world)], [file/Structory_Towers_1.21_v1.0.7.zip (world)], [file/Continents_1.21_v1.1.5.zip (world)], [bundle (feature)], [file/bukkit (world)], [paper (built-in)], [file/Incendium_1.21_DIRECT_PORT_v5.4.0.zip (world)], [file/custom_datapack.zip (world)] [22:35:28 INFO]: There are no more data packs available

Actions to reproduce (if known)

make a plugin load on startup and disable a datapack in "onEnable"

Paper version

[22:35:58 INFO]: This server is running Paper version 1.21.1-3-master@70dfa46 (2024-08-10T13:14:36Z) (Implementing API version 1.21.1-R0.1-SNAPSHOT)

Other

No response

Valgrifer avatar Aug 11 '24 21:08 Valgrifer

This might be fixable, but I wouldn't recommend triggering a resources reload in the middle of plugin initialization. Instead, I would do it after the server has been loaded. So in the ServerLoadEvent with the STARTUP type, you can do it there without any issues.

Machine-Maker avatar Aug 11 '24 21:08 Machine-Maker

I will try, thank you

Valgrifer avatar Aug 11 '24 21:08 Valgrifer

it works, but it manages the data packs after the world is loaded, I'm not sure that it's good for the world that the data pack is reactivated after the world is loaded especially if the datapack contains paints, enchantments and anything datadriven

Valgrifer avatar Aug 11 '24 23:08 Valgrifer

I think the best way to do this would be to display a warning instead and rather go with this proposal #11289, it makes more sense. I just discovered the usefulness of bootstrap and it totally corresponds to what I want to do and what I understand of the goal of bootstrap goes in the same direction as my project.

Valgrifer avatar Aug 18 '24 02:08 Valgrifer

Ok, I've implemented this functionality in https://github.com/PaperMC/Paper/pull/10711. That PR adds a new lifecycle event to deal with datapack discovery. It allows discovering new datapacks from arbitrary locations as well as removing previously discovered datapacks. I believe it should satisfy this issue, so I'll link it and when that PR is merged, this can be closed.

Machine-Maker avatar Sep 08 '24 22:09 Machine-Maker

Implemented in https://github.com/PaperMC/Paper/pull/11804

Lulu13022002 avatar Feb 16 '25 17:02 Lulu13022002