MinestomBrick / BrickEssentials

Add vanilla commands and features to minestom
0 stars 0 forks source link

Language file not created #1

Closed erikzimmermann closed 2 years ago

erikzimmermann commented 2 years ago

Hi there. I recently found your repository for some basic commands for Minestom and come across an issue with the language file.

(I18nNamespace.loadValues) - WARN - Cannot save packaged resource 'languages\en.json' of extension 'BrickEssentials'.

Any ideas? Would be great to chat via Discord (CodingAir#0640) ^^.

jorisguffens commented 2 years ago

Every extension that uses BrickI18n has this issue, until now it hasn't been a problem for us since the embedded language file is complete but unfortunately this doesn't allow for customization.

I think this is caused by the custom classloader of minestom but I haven't had time to investigate this yet. Feel free to make a PR if you have a solution.

erikzimmermann commented 2 years ago

Thanks for your fast reply!

Unfortunately, I don't really have time to fix that myself...

I also get an error each time I run a command:

java.lang.NoSuchMethodError: 'net.kyori.adventure.text.minimessage.MiniMessage net.kyori.adventure.text.minimessage.MiniMessage.get()'
        at Ext_BrickI18n//org.minestombrick.i18n.api.namespace.ComponentRenderer.renderTranslatable(ComponentRenderer.java:38)
        at Ext_BrickI18n//org.minestombrick.i18n.api.namespace.ComponentRenderer$1.renderTranslatable(ComponentRenderer.java:23)
        at net.kyori.adventure.text.renderer.AbstractComponentRenderer.render(AbstractComponentRenderer.java:50)
        at Ext_BrickI18n//org.minestombrick.i18n.api.namespace.I18nNamespace.translate(I18nNamespace.java:62)
        at Ext_BrickI18n//org.minestombrick.i18n.api.namespace.I18nNamespace.translate(I18nNamespace.java:68)
        at Ext_BrickI18n//org.minestombrick.i18n.api.namespace.I18nNamespace.send(I18nNamespace.java:89)
        at Ext_BrickI18n//org.minestombrick.i18n.api.namespace.I18nNamespace.send(I18nNamespace.java:104)
        at Ext_BrickEssentials//org.minestombrick.essentials.app.commands.TimeCommand.lambda$new$1(TimeCommand.java:30)
        at net.minestom.server.command.builder.ParsedCommand.execute(ParsedCommand.java:74)
        at net.minestom.server.command.builder.CommandDispatcher.execute(CommandDispatcher.java:94)
        at net.minestom.server.command.CommandManager.execute(CommandManager.java:110)
        at net.minestom.server.listener.ChatMessageListener.listener(ChatMessageListener.java:34)
        at net.minestom.server.listener.manager.PacketListenerManager.processClientPacket(PacketListenerManager.java:88)
        at net.minestom.server.entity.Player.lambda$interpretPacketQueue$12(Player.java:1730)
        at org.jctools.queues.MessagePassingQueueUtil.drain(MessagePassingQueueUtil.java:53)
        at org.jctools.queues.MpUnboundedXaddArrayQueue.drain(MpUnboundedXaddArrayQueue.java:435)
        at org.jctools.queues.MpscUnboundedXaddArrayQueue.drain(MpscUnboundedXaddArrayQueue.java:28)
        at net.minestom.server.entity.Player.interpretPacketQueue(Player.java:1730)
        at net.minestom.server.entity.Player.update(Player.java:326)
        at net.minestom.server.entity.Entity.tick(Entity.java:535)
        at net.minestom.server.thread.TickThread.tick(TickThread.java:66)
        at net.minestom.server.thread.TickThread.run(TickThread.java:41)

Can I just copy the en.json into a plugin folder to temporarily fix that?

jorisguffens commented 2 years ago

Well, I think I fixed both those issues. Download the latest BrickI18n here: https://github.com/MinestomBrick/BrickI18n/releases

I have no idea what caused the NoSuchMethodError but updating minimessage to 4.2.0 did the trick (at least in my environment).

The default language files are now saved in case they don't exist and have priority over the embedded language file. It's now also possible to add other languages locally (before it would only look for the languages that were embedded).

erikzimmermann commented 2 years ago

Well, I think I fixed both those issues. Download the latest BrickI18n here: https://github.com/MinestomBrick/BrickI18n/releases

I have no idea what caused the NoSuchMethodError but updating minimessage to 4.2.0 did the trick (at least in my environment).

The default language files are now saved in case they don't exist and have priority over the embedded language file. It's now also possible to add other languages locally (before it would only look for the languages that were embedded).

Thanks for your work! I really appreciate that. Just tested it and it worked.

Still throws me one error but I'm sure that's just a missing language line since other messages work as expected.

After running /tp CodingAir (to myself), I get the following:

java.lang.NullPointerException: Cannot invoke "net.kyori.adventure.text.ComponentLike.asComponent()" because "like" is null
        at net.kyori.adventure.text.ComponentLike.asComponents(ComponentLike.java:72)
        at net.kyori.adventure.text.ComponentLike.asComponents(ComponentLike.java:49)
        at net.kyori.adventure.text.TranslatableComponentImpl.<init>(TranslatableComponentImpl.java:51)
        at net.kyori.adventure.text.TranslatableComponentImpl.<init>(TranslatableComponentImpl.java:44)
        at net.kyori.adventure.text.TranslatableComponentImpl.args(TranslatableComponentImpl.java:72)
        at Ext_BrickI18n//org.minestombrick.i18n.api.namespace.I18nNamespace.send(I18nNamespace.java:107)
        at Ext_BrickEssentials//org.minestombrick.essentials.app.commands.TeleportCommand.executeEntity(TeleportCommand.java:48)
        at net.minestom.server.command.builder.ParsedCommand.execute(ParsedCommand.java:74)
        at net.minestom.server.command.builder.CommandDispatcher.execute(CommandDispatcher.java:94)
        at net.minestom.server.command.CommandManager.execute(CommandManager.java:110)
        at net.minestom.server.listener.ChatMessageListener.listener(ChatMessageListener.java:34)
        at net.minestom.server.listener.manager.PacketListenerManager.processClientPacket(PacketListenerManager.java:88)
        at net.minestom.server.entity.Player.lambda$interpretPacketQueue$12(Player.java:1730)
        at org.jctools.queues.MessagePassingQueueUtil.drain(MessagePassingQueueUtil.java:53)
        at org.jctools.queues.MpUnboundedXaddArrayQueue.drain(MpUnboundedXaddArrayQueue.java:435)
        at org.jctools.queues.MpscUnboundedXaddArrayQueue.drain(MpscUnboundedXaddArrayQueue.java:28)
        at net.minestom.server.entity.Player.interpretPacketQueue(Player.java:1730)
        at net.minestom.server.entity.Player.update(Player.java:326)
        at net.minestom.server.entity.Entity.tick(Entity.java:535)
        at net.minestom.server.thread.TickThread.tick(TickThread.java:66)
        at net.minestom.server.thread.TickThread.run(TickThread.java:41)
jorisguffens commented 2 years ago

Looks like a bug in essentials, entity.getCustomName() is null resulting in this error. This is now gracefully handled in BrickI18n like this: image

I've also fixed the null argument in BrickEssentials and I made a huge improvement to the teleport command.

erikzimmermann commented 2 years ago

Looks like a bug in essentials, entity.getCustomName() is null resulting in this error. This is now gracefully handled in BrickI18n like this: image

I've also fixed the null argument in BrickEssentials and I made a huge improvement to the teleport command.

Awesome! One suggestion: Wouldn't it be better to use the username instead of the custom name if it's not set?

jorisguffens commented 2 years ago

Yes that is fixed in the latest BrickEssentials, it will still use the custom name but if it is null it will fallback to the username, in case of a player, or the entity type name, in case of another entity.