SuperNeon4ik / NoxesiumUtils

Communicate with The Noxesium Mod with ease.
https://modrinth.com/plugin/noxesiumutils
GNU General Public License v3.0
13 stars 3 forks source link

✨ Feature: Reload Qib definitions #26

Closed BlockybombDEV closed 4 weeks ago

BlockybombDEV commented 1 month ago

Is your feature request related to a problem? Please describe it. Thought this might become a thing that is gonna come up once people start using Qibs

Describe your suggestion A command to reload Qib definitions, and seeing as you want to make this usable as a dependency you could also make loadQibEffectsAndDefinitions() a public function.

Additional context Potentially a reload command in general (ex.: /noxesiumutils reload) that also reloads custom creative items (might cause issues looking at this bug https://github.com/Noxcrew/noxesium/issues/106)

SuperNeon4ik commented 1 month ago

Yup, definitely an essential feature. I kinda do want to make my code much nicer first, because currently it's such a mess. Ideally this will be added in #21. Reloading can for sure break quite some stuff, but i don't think there is a way to make a perfectly safe reload. The creative menu bug could probably be easily avoided by just sending customCreativeItems with the reload (maybe with a sendDefaultsOnReload config option).

SuperNeon4ik commented 1 month ago

Hey! Added /noxutils reload in the linked PR. Give it a try. Currently just a simple reload, nothing else. Will probably add some neat reloading features in a bit too.

In code you can do it with smth like:

// Reload the config file (bukkit thingie)
reloadConfig();

// Rebuild the config object
var config = new NoxesiumUtilsConfigBuilder()
                .withConfig(getConfig())
                .withQibFolder(Path.of(getDataFolder().getPath(), "qibs").toFile())
                .withLogger(getLogger())
                .build();

// Update the config in the existing NoxesiumUtils object
noxesiumUtils.setConfig(config);

// Reload available commands
new CommandRegistrar(this, noxesiumUtils, updateChecker).registerCommands();
BlockybombDEV commented 1 month ago

Either i'm compiling it wrong or there's something wrong. Currently getting this error when trying to load the commands.

Server version: 1.21.1 CommandAPI version: 9.5.3

If this info helps, the configs exist.

Full error:


[16:29:59 INFO]: [NoxesiumUtils] Loaded 0 qibEffects!
[16:29:59 ERROR]: Error occurred while enabling NoxesiumUtils v3.0.0-dev (Is it up to date?)
dev.jorel.commandapi.exceptions.BadLiteralException: Cannot create a LiteralArgument with an empty string
        at CommandAPI-9.5.3.jar/dev.jorel.commandapi.arguments.MultiLiteralArgument.<init>(MultiLiteralArgument.java:51) ~[CommandAPI-9.5.3.jar:?]
        at NoxesiumUtils-3.0.0-dev.jar/me.superneon4ik.noxesiumutils.commands.EntityRuleCommands.qibBehaviorRule(EntityRuleCommands.java:108) ~[NoxesiumUtils-3.0.0-dev.jar:?]
        at NoxesiumUtils-3.0.0-dev.jar/me.superneon4ik.noxesiumutils.commands.EntityRuleCommands.generate(EntityRuleCommands.java:35) ~[NoxesiumUtils-3.0.0-dev.jar:?]
        at NoxesiumUtils-3.0.0-dev.jar/me.superneon4ik.noxesiumutils.commands.CommandRegistrar.registerCommands(CommandRegistrar.java:52) ~[NoxesiumUtils-3.0.0-dev.jar:?]
        at NoxesiumUtils-3.0.0-dev.jar/me.superneon4ik.noxesiumutils.NoxesiumUtilsPlugin.registerCommands(NoxesiumUtilsPlugin.java:80) ~[NoxesiumUtils-3.0.0-dev.jar:?]
        at NoxesiumUtils-3.0.0-dev.jar/me.superneon4ik.noxesiumutils.NoxesiumUtilsPlugin.onEnable(NoxesiumUtilsPlugin.java:36) ~[NoxesiumUtils-3.0.0-dev.jar:?]
        at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:288) ~[paper-mojangapi-1.21.1-R0.1-SNAPSHOT.jar:?]
        at io.papermc.paper.plugin.manager.PaperPluginInstanceManager.enablePlugin(PaperPluginInstanceManager.java:202) ~[paper-1.21.1.jar:1.21.1-109-355b1cb]
        at io.papermc.paper.plugin.manager.PaperPluginManagerImpl.enablePlugin(PaperPluginManagerImpl.java:109) ~[paper-1.21.1.jar:1.21.1-109-355b1cb]
        at org.bukkit.plugin.SimplePluginManager.enablePlugin(SimplePluginManager.java:520) ~[paper-mojangapi-1.21.1-R0.1-SNAPSHOT.jar:?]
        at org.bukkit.craftbukkit.CraftServer.enablePlugin(CraftServer.java:640) ~[paper-1.21.1.jar:1.21.1-109-355b1cb]
        at org.bukkit.craftbukkit.CraftServer.enablePlugins(CraftServer.java:589) ~[paper-1.21.1.jar:1.21.1-109-355b1cb]
        at net.minecraft.server.MinecraftServer.loadWorld0(MinecraftServer.java:753) ~[paper-1.21.1.jar:1.21.1-109-355b1cb]
        at net.minecraft.server.MinecraftServer.loadLevel(MinecraftServer.java:515) ~[paper-1.21.1.jar:1.21.1-109-355b1cb]
        at net.minecraft.server.dedicated.DedicatedServer.initServer(DedicatedServer.java:329) ~[paper-1.21.1.jar:1.21.1-109-355b1cb]
        at net.minecraft.server.MinecraftServer.runServer(MinecraftServer.java:1214) ~[paper-1.21.1.jar:1.21.1-109-355b1cb]
        at net.minecraft.server.MinecraftServer.lambda$spin$0(MinecraftServer.java:329) ~[paper-1.21.1.jar:1.21.1-109-355b1cb]
        at java.base/java.lang.Thread.run(Thread.java:1583) ~[?:?]```
SuperNeon4ik commented 1 month ago

Could you share your config.yml?

BlockybombDEV commented 1 month ago

# https://github.com/Noxcrew/noxesium/wiki
# View documentation about this config in the README:
# https://github.com/SuperNeon4ik/NoxesiumUtils

# Add some extra output for debugging purposes
extraDebugOutput: false

# If true will check the plugin's version once in a while.
checkForUpdates: true

# If true will send defaults to Noxesium Players on join.
sendDefaultsOnJoin: false

# Comment out the line if you don't want to send that rule.
defaults:
  #cameraLocked: false
  #disableBoatCollisions: false
  #disableDeferredChunkUpdates: false
  #disableMapUi: false
  #disableSpinAttackCollisions: false
  #disableUiOptimizations: false
  #disableVanillaMusic: false
  #enableSmootherClientTrident: false
  #heldItemNameOffset: 0
  #handItemOverride: 'minecraft:stick[minecraft:enchantments={levels:{"minecraft:knockback":25}}]'
  #overrideGraphicsMode: FAST
  #riptideCoyoteTime: 0
  #showMapInUi: false
  #customCreativeItems: false
  #qibBehaviors: []

#qibDefinitions: 
#  example:
#    onEnter: 'example_qib_enter'
#    onLeave: 'example_qib_leave'
#    triggerEnterLeaveOnSwitch: false

#customCreativeItems:
#  - 'minecraft:stick[minecraft:enchantments={levels:{"minecraft:knockback":25}}]'```
SuperNeon4ik commented 1 month ago

Seems like this is because you have no Qibs defined. I always had a couple in my config so let a bug slip. Try the latest build again, please.

BlockybombDEV commented 1 month ago

I got past enabling but i'm getting another error after changing the default server rules. The updated default rules also don't get sent. After a restart the error still exists and default rules don't get sent even after reverting to old config

For this line specifically everytime you reload the number goes up by 1: [17:47:15 ERROR]: Paper Async Command Builder Thread Pool - 3

Full error:

[17:47:15 INFO]: [NoxesiumUtils] Loaded 0 qibEffects!
[17:47:15 ERROR]: Caught previously unhandled exception :
[17:47:15 ERROR]: Paper Async Command Builder Thread Pool - 3
java.util.ConcurrentModificationException: null
        at java.base/java.util.LinkedHashMap$LinkedHashIterator.nextNode(LinkedHashMap.java:1023) ~[?:?]
        at java.base/java.util.LinkedHashMap$LinkedValueIterator.next(LinkedHashMap.java:1052) ~[?:?]
        at net.minecraft.commands.Commands.fillUsableCommands(Commands.java:531) ~[paper-1.21.1.jar:1.21.1-109-355b1cb]
        at net.minecraft.commands.Commands.sendAsync(Commands.java:496) ~[paper-1.21.1.jar:1.21.1-109-355b1cb]
        at net.minecraft.commands.Commands.lambda$sendCommands$6(Commands.java:475) ~[paper-1.21.1.jar:1.21.1-109-355b1cb]
        at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1144) ~[?:?]
        at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:642) ~[?:?]
        at java.base/java.lang.Thread.run(Thread.java:1583) ~[?:?]
[17:47:15 INFO]: Reloaded configuration file!

Config.yml:

# View Protocol documentation and information about the mod here:
# https://github.com/Noxcrew/noxesium/wiki
# View documentation about this config in the README:
# https://github.com/SuperNeon4ik/NoxesiumUtils

# Add some extra output for debugging purposes
extraDebugOutput: false

# If true will check the plugin's version once in a while.
checkForUpdates: true

# If true will send defaults to Noxesium Players on join.
sendDefaultsOnJoin: false

# Comment out the line if you don't want to send that rule.
defaults:
  #cameraLocked: false
  disableBoatCollisions: true
  #disableDeferredChunkUpdates: false
  #disableMapUi: false
  disableSpinAttackCollisions: true
  #disableUiOptimizations: false
  disableVanillaMusic: true
  #enableSmootherClientTrident: false
  #heldItemNameOffset: 0
  #handItemOverride: 'minecraft:stick[minecraft:enchantments={levels:{"minecraft:knockback":25}}]'
  #overrideGraphicsMode: FAST
  #riptideCoyoteTime: 0
  #showMapInUi: false
  #customCreativeItems: false
  qibBehaviors: [meow]

qibDefinitions: 
  meow:
    onJump: 'jump'
    triggerEnterLeaveOnSwitch: false

#customCreativeItems:
#  - 'minecraft:stick[minecraft:enchantments={levels:{"minecraft:knockback":25}}]'
BlockybombDEV commented 1 month ago

Looks like this only happens if someone is on the server. It reloads fine whenever no one is on but i see no packets being sent whenever I join the server (except for outgoing: ServerboundClientInformationPacket, ServerboundClientSettingsPacket and incoming: ClientboundServerInformationPacket)

SuperNeon4ik commented 1 month ago

Yeah, that error is probably something that has to do with reregistering commands, but I don't think it actually breaks anything. I will see if I can do anything about it.

About your default server rules not being applied. You have them off:

# If true will send defaults to Noxesium Players on join.
sendDefaultsOnJoin: false # this should be true for you
BlockybombDEV commented 1 month ago

Yup, everything works normally even all commands.