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

Can't enable/disable a datapack on startup #11242

Open
Valgrifer opened this issue Aug 11, 2024 · 5 comments · May be fixed by #10711
Open

Can't enable/disable a datapack on startup #11242

Valgrifer opened this issue Aug 11, 2024 · 5 comments · May be fixed by #10711
Labels
status: accepted Disputed bug is accepted as valid or Feature accepted as desired to be added. type: bug Something doesn't work as it was intended to. version: 1.21.1

Comments

@Valgrifer
Copy link

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

@Machine-Maker
Copy link
Member

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.

@Valgrifer
Copy link
Author

I will try, thank you

@Valgrifer
Copy link
Author

Valgrifer commented Aug 11, 2024

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 Valgrifer changed the title Can't disable a datapack on startup Can't enable/disable a datapack on startup Aug 15, 2024
@Valgrifer
Copy link
Author

Valgrifer commented Aug 18, 2024

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.

@Machine-Maker Machine-Maker added status: accepted Disputed bug is accepted as valid or Feature accepted as desired to be added. and removed status: needs triage labels Sep 8, 2024
@Machine-Maker
Copy link
Member

Ok, I've implemented this functionality in #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 Machine-Maker added type: feature Request for a new Feature. type: bug Something doesn't work as it was intended to. and removed status: accepted Disputed bug is accepted as valid or Feature accepted as desired to be added. labels Sep 8, 2024
@Machine-Maker Machine-Maker linked a pull request Sep 8, 2024 that will close this issue
@Machine-Maker Machine-Maker added status: accepted Disputed bug is accepted as valid or Feature accepted as desired to be added. and removed type: feature Request for a new Feature. labels Sep 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: accepted Disputed bug is accepted as valid or Feature accepted as desired to be added. type: bug Something doesn't work as it was intended to. version: 1.21.1
Projects
Status: ✅ Accepted
Development

Successfully merging a pull request may close this issue.

2 participants