FlashyReese / CommandAliases

Alternate short commands for complex commands
MIT License
26 stars 6 forks source link

Compatibility issues with Immersive Portals #29

Closed u0398 closed 2 years ago

u0398 commented 2 years ago

Using Immersive Portals (tested with 2.0.2) Multiple server commands fail to execute in a custom command. This example code works without IP but fails with it:

{
    "commandMode": "COMMAND_CUSTOM",
    "customCommand": {
        "parent": "tools",
        "message": "Here are some free wooden tools, $executor_name()!",
        "actions": [
            {
                "command": "give $executor_name() minecraft:wooden_sword",
                "commandType": "SERVER",
                "message": "Here is a wooden sword",
                "sleep": "2000"
            },
            {
                "command": "give $executor_name() minecraft:wooden_pickaxe",
                "commandType": "SERVER",
                "sleep": "1000",
                "message": "Here is a wooden pickaxe"
            },
            {
                "command": "give $executor_name() minecraft:wooden_axe",
                "commandType": "SERVER",
                "sleep": "1000",
                "message": "Here is a wooden axe"
            },
            {
                "command": "give $executor_name() minecraft:wooden_shovel",
                "commandType": "SERVER",
                "message": "Here is a wooden shovel, $executor_name()!"
            }
        ]
    }
}

With Immersive Portals the custom command only gives a wooden sword. If the client reconnects they will see the sword ghosting in the air, and when the server is restarted a duplicate sword will fall to the ground.

FlashyReese commented 2 years ago

Do you have any logs related to this issue?

u0398 commented 2 years ago

This seems to be the relevant error:

[19:12:53] [Command Aliases/ERROR]: Uncaught exception in thread "Command Aliases"
java.lang.IllegalArgumentException: Maybe a mod is trying to add entity in a non-server thread. This is probably not IP's issue
    at org.apache.commons.lang3.Validate.isTrue(Validate.java:158) ~[commons-lang3-3.12.0.jar:?]
    at qouteall.imm_ptl.core.network.IPCommonNetwork.withForceRedirect(IPCommonNetwork.java:25) ~[imm_ptl_core-2.0.2-fff520b69a6ad661.jar:?]
    at net.minecraft.class_3231.method_18760(class_3231.java:1065) ~[server-intermediary.jar:?]
    at net.minecraft.class_3898$class_3208.updateEntityTrackingStatus(class_3898.java:2135) ~[server-intermediary.jar:?]
    at net.minecraft.class_3898$class_3208.method_18729(class_3898.java:2098) ~[server-intermediary.jar:?]
    at net.minecraft.class_3898.method_18701(class_3898.java:1197) ~[server-intermediary.jar:?]
    at net.minecraft.class_3215.method_18755(class_3215.java:477) ~[server-intermediary.jar:?]
    at net.minecraft.class_3218$class_5526.method_31436(class_3218.java:1559) ~[server-intermediary.jar:?]
    at net.minecraft.class_3218$class_5526.method_31798(class_3218.java:1537) ~[server-intermediary.jar:?]
    at net.minecraft.class_5579.method_31847(class_5579.java:217) ~[server-intermediary.jar:?]
    at net.minecraft.class_5579.method_31820(class_5579.java:187) ~[server-intermediary.jar:?]
    at net.minecraft.class_5579.method_31818(class_5579.java:168) ~[server-intermediary.jar:?]
    at net.minecraft.class_3218.method_14175(class_3218.java:864) ~[server-intermediary.jar:?]
    at net.minecraft.class_3218.method_8649(class_3218.java:815) ~[server-intermediary.jar:?]
    at net.minecraft.class_3222.method_7329(class_3222.java:1603) ~[server-intermediary.jar:?]
    at net.minecraft.class_1657.method_7328(class_1657.java:723) ~[server-intermediary.jar:?]
    at net.minecraft.class_3068.method_13401(class_3068.java:74) ~[server-intermediary.jar:?]
    at net.minecraft.class_3068.method_13400(class_3068.java:39) ~[server-intermediary.jar:?]
    at com.mojang.brigadier.CommandDispatcher.execute(CommandDispatcher.java:263) ~[brigadier-1.0.18.jar:?]
    at com.mojang.brigadier.CommandDispatcher.execute(CommandDispatcher.java:177) ~[brigadier-1.0.18.jar:?]
    at com.mojang.brigadier.CommandDispatcher.execute(CommandDispatcher.java:142) ~[brigadier-1.0.18.jar:?]
    at me.flashyreese.mods.commandaliases.command.builder.custom.ServerCustomCommandBuilder.dispatcherExecute(ServerCustomCommandBuilder.java:42) ~[commandaliases-0.7.0+mc1.19-build.29.jar:?]
    at me.flashyreese.mods.commandaliases.command.builder.custom.AbstractCustomCommandBuilder.processActions(AbstractCustomCommandBuilder.java:261) ~[commandaliases-0.7.0+mc1.19-build.29.jar:?]
    at me.flashyreese.mods.commandaliases.command.builder.custom.AbstractCustomCommandBuilder.lambda$executeCommand$5(AbstractCustomCommandBuilder.java:202) ~[commandaliases-0.7.0+mc1.19-build.29.jar:?]
    at java.lang.Thread.run(Unknown Source) [?:?]

These are the full server logs from a testing server running Fabric, Command Aliases, and Immersive Portals:

logs.txt

FlashyReese commented 2 years ago

Hello, can you try this build to see if it still occurs? libs.zip

u0398 commented 2 years ago

The server crashes on startup with the test build.

[21:02:12] [main/ERROR]: Failed to start the minecraft server
java.lang.RuntimeException: Could not execute entrypoint stage 'main' due to errors, provided by 'commandaliases'!
    at net.fabricmc.loader.impl.entrypoint.EntrypointUtils.lambda$invoke0$0(EntrypointUtils.java:51) ~[fabric-loader-0.14.8.jar:?]
    at net.fabricmc.loader.impl.util.ExceptionUtil.gatherExceptions(ExceptionUtil.java:33) ~[fabric-loader-0.14.8.jar:?]
    at net.fabricmc.loader.impl.entrypoint.EntrypointUtils.invoke0(EntrypointUtils.java:49) ~[fabric-loader-0.14.8.jar:?]
    at net.fabricmc.loader.impl.entrypoint.EntrypointUtils.invoke(EntrypointUtils.java:35) ~[fabric-loader-0.14.8.jar:?]
    at net.fabricmc.loader.impl.game.minecraft.Hooks.startServer(Hooks.java:62) ~[fabric-loader-0.14.8.jar:?]
    at net.minecraft.server.Main.main(Main.java:101) [server-intermediary.jar:?]
    at net.fabricmc.loader.impl.game.minecraft.MinecraftGameProvider.launch(MinecraftGameProvider.java:461) [fabric-loader-0.14.8.jar:?]
    at net.fabricmc.loader.impl.launch.knot.Knot.launch(Knot.java:74) [fabric-loader-0.14.8.jar:?]
    at net.fabricmc.loader.impl.launch.knot.KnotServer.main(KnotServer.java:23) [fabric-loader-0.14.8.jar:?]
    at net.fabricmc.loader.impl.launch.server.FabricServerLauncher.main(FabricServerLauncher.java:69) [fabric-loader-0.14.8.jar:?]
Caused by: net.fabricmc.loader.api.EntrypointException: Exception while loading entries for entrypoint 'main' provided by 'commandaliases'
    at net.fabricmc.loader.impl.entrypoint.EntrypointContainerImpl.getEntrypoint(EntrypointContainerImpl.java:56) ~[fabric-loader-0.14.8.jar:?]
    at net.fabricmc.loader.impl.entrypoint.EntrypointUtils.invoke0(EntrypointUtils.java:47) ~[fabric-loader-0.14.8.jar:?]
    ... 7 more
Caused by: net.fabricmc.loader.api.LanguageAdapterException: java.lang.reflect.InvocationTargetException
    at net.fabricmc.loader.impl.util.DefaultLanguageAdapter.create(DefaultLanguageAdapter.java:60) ~[fabric-loader-0.14.8.jar:?]
    at net.fabricmc.loader.impl.entrypoint.EntrypointStorage$NewEntry.getOrCreate(EntrypointStorage.java:117) ~[fabric-loader-0.14.8.jar:?]
    at net.fabricmc.loader.impl.entrypoint.EntrypointContainerImpl.getEntrypoint(EntrypointContainerImpl.java:53) ~[fabric-loader-0.14.8.jar:?]
    at net.fabricmc.loader.impl.entrypoint.EntrypointUtils.invoke0(EntrypointUtils.java:47) ~[fabric-loader-0.14.8.jar:?]
    ... 7 more
Caused by: java.lang.reflect.InvocationTargetException
    at jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) ~[?:?]
    at jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source) ~[?:?]
    at jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source) ~[?:?]
    at java.lang.reflect.Constructor.newInstanceWithCaller(Unknown Source) ~[?:?]
    at java.lang.reflect.Constructor.newInstance(Unknown Source) ~[?:?]
    at net.fabricmc.loader.impl.util.DefaultLanguageAdapter.create(DefaultLanguageAdapter.java:58) ~[fabric-loader-0.14.8.jar:?]
    at net.fabricmc.loader.impl.entrypoint.EntrypointStorage$NewEntry.getOrCreate(EntrypointStorage.java:117) ~[fabric-loader-0.14.8.jar:?]
    at net.fabricmc.loader.impl.entrypoint.EntrypointContainerImpl.getEntrypoint(EntrypointContainerImpl.java:53) ~[fabric-loader-0.14.8.jar:?]
    at net.fabricmc.loader.impl.entrypoint.EntrypointUtils.invoke0(EntrypointUtils.java:47) ~[fabric-loader-0.14.8.jar:?]
    ... 7 more
Caused by: java.lang.NoClassDefFoundError: com/fasterxml/jackson/databind/json/JsonMapper
    at me.flashyreese.mods.commandaliases.CommandAliasesProvider.<init>(CommandAliasesProvider.java:37) ~[commandaliases-0.8.0+mc1.19-unknown.jar:?]
    at me.flashyreese.mods.commandaliases.CommandAliasesLoader.<init>(CommandAliasesLoader.java:58) ~[commandaliases-0.8.0+mc1.19-unknown.jar:?]
    at me.flashyreese.mods.commandaliases.CommandAliasesMod.<init>(CommandAliasesMod.java:20) ~[commandaliases-0.8.0+mc1.19-unknown.jar:?]
    at jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) ~[?:?]
    at jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source) ~[?:?]
    at jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source) ~[?:?]
    at java.lang.reflect.Constructor.newInstanceWithCaller(Unknown Source) ~[?:?]
    at java.lang.reflect.Constructor.newInstance(Unknown Source) ~[?:?]
    at net.fabricmc.loader.impl.util.DefaultLanguageAdapter.create(DefaultLanguageAdapter.java:58) ~[fabric-loader-0.14.8.jar:?]
    at net.fabricmc.loader.impl.entrypoint.EntrypointStorage$NewEntry.getOrCreate(EntrypointStorage.java:117) ~[fabric-loader-0.14.8.jar:?]
    at net.fabricmc.loader.impl.entrypoint.EntrypointContainerImpl.getEntrypoint(EntrypointContainerImpl.java:53) ~[fabric-loader-0.14.8.jar:?]
    at net.fabricmc.loader.impl.entrypoint.EntrypointUtils.invoke0(EntrypointUtils.java:47) ~[fabric-loader-0.14.8.jar:?]
    ... 7 more
Caused by: java.lang.ClassNotFoundException: com.fasterxml.jackson.databind.json.JsonMapper
    at jdk.internal.loader.BuiltinClassLoader.loadClass(Unknown Source) ~[?:?]
    at java.lang.ClassLoader.loadClass(Unknown Source) ~[?:?]
    at net.fabricmc.loader.impl.launch.knot.KnotClassDelegate.loadClass(KnotClassDelegate.java:226) ~[fabric-loader-0.14.8.jar:?]
    at net.fabricmc.loader.impl.launch.knot.KnotClassLoader.loadClass(KnotClassLoader.java:145) ~[fabric-loader-0.14.8.jar:?]
    at java.lang.ClassLoader.loadClass(Unknown Source) ~[?:?]
    at me.flashyreese.mods.commandaliases.CommandAliasesProvider.<init>(CommandAliasesProvider.java:37) ~[commandaliases-0.8.0+mc1.19-unknown.jar:?]
    at me.flashyreese.mods.commandaliases.CommandAliasesLoader.<init>(CommandAliasesLoader.java:58) ~[commandaliases-0.8.0+mc1.19-unknown.jar:?]
    at me.flashyreese.mods.commandaliases.CommandAliasesMod.<init>(CommandAliasesMod.java:20) ~[commandaliases-0.8.0+mc1.19-unknown.jar:?]
    at jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) ~[?:?]
    at jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source) ~[?:?]
    at jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source) ~[?:?]
    at java.lang.reflect.Constructor.newInstanceWithCaller(Unknown Source) ~[?:?]
    at java.lang.reflect.Constructor.newInstance(Unknown Source) ~[?:?]
    at net.fabricmc.loader.impl.util.DefaultLanguageAdapter.create(DefaultLanguageAdapter.java:58) ~[fabric-loader-0.14.8.jar:?]
    at net.fabricmc.loader.impl.entrypoint.EntrypointStorage$NewEntry.getOrCreate(EntrypointStorage.java:117) ~[fabric-loader-0.14.8.jar:?]
    at net.fabricmc.loader.impl.entrypoint.EntrypointContainerImpl.getEntrypoint(EntrypointContainerImpl.java:53) ~[fabric-loader-0.14.8.jar:?]
    at net.fabricmc.loader.impl.entrypoint.EntrypointUtils.invoke0(EntrypointUtils.java:47) ~[fabric-loader-0.14.8.jar:?]
    ... 7 more
FlashyReese commented 2 years ago

Sorry for the late response; timezones. Try this one libs.zip

u0398 commented 2 years ago

No worries. The new one crashed on startup too:

[17:19:25] [Server thread/ERROR]: Encountered an unexpected exception
com.google.gson.JsonSyntaxException: com.google.gson.stream.MalformedJsonException: Unterminated object at line 31 column 6 path $[1].customCommand.actions[0].commandType
    at Not Enough Crashes deobfuscated stack trace.(1.19+build.4) ~[?:?]
    at com.google.gson.Gson.fromJson(Gson.java:978) ~[gson-2.8.9.jar:?]
    at com.google.gson.Gson.fromJson(Gson.java:928) ~[gson-2.8.9.jar:?]
    at me.flashyreese.mods.commandaliases.CommandAliasesProvider.loadCommandAliases(CommandAliasesProvider.java:157) ~[commandaliases-0.8.0+mc1.19-unknown.jar:?]
    at me.flashyreese.mods.commandaliases.CommandAliasesProvider.loadCommandAliases(CommandAliasesProvider.java:65) ~[commandaliases-0.8.0+mc1.19-unknown.jar:?]
    at me.flashyreese.mods.commandaliases.CommandAliasesLoader.lambda$registerCommandAliases$0(CommandAliasesLoader.java:82) ~[commandaliases-0.8.0+mc1.19-unknown.jar:?]
    at net.fabricmc.fabric.api.event.lifecycle.v1.ServerLifecycleEvents.lambda$static$2(ServerLifecycleEvents.java:49) ~[fabric-lifecycle-events-v1-2.1.0+33fbc738a9-c697e79f4c4115d8.jar:?]
    at net.minecraft.server.MinecraftServer.handler$bep000$afterSetupServer(MinecraftServer:6796) ~[server-intermediary.jar:?]
    at net.minecraft.server.MinecraftServer.runServer(MinecraftServer:644) ~[server-intermediary.jar:?]
    at net.minecraft.server.MinecraftServer.method_29739(MinecraftServer:258) ~[server-intermediary.jar:?]
    at java.lang.Thread.run(Unknown Source) [?:?]
Caused by: com.google.gson.stream.MalformedJsonException: Unterminated object at line 31 column 6 path $[1].customCommand.actions[0].commandType
    at com.google.gson.stream.JsonReader.syntaxError(JsonReader.java:1562) ~[gson-2.8.9.jar:?]
    at com.google.gson.stream.JsonReader.doPeek(JsonReader.java:490) ~[gson-2.8.9.jar:?]
    at com.google.gson.stream.JsonReader.hasNext(JsonReader.java:413) ~[gson-2.8.9.jar:?]
    at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$Adapter.read(ReflectiveTypeAdapterFactory.java:216) ~[gson-2.8.9.jar:?]
    at com.google.gson.internal.bind.TypeAdapterRuntimeTypeWrapper.read(TypeAdapterRuntimeTypeWrapper.java:41) ~[gson-2.8.9.jar:?]
    at com.google.gson.internal.bind.CollectionTypeAdapterFactory$Adapter.read(CollectionTypeAdapterFactory.java:82) ~[gson-2.8.9.jar:?]
    at com.google.gson.internal.bind.CollectionTypeAdapterFactory$Adapter.read(CollectionTypeAdapterFactory.java:61) ~[gson-2.8.9.jar:?]
    at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$1.read(ReflectiveTypeAdapterFactory.java:131) ~[gson-2.8.9.jar:?]
    at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$Adapter.read(ReflectiveTypeAdapterFactory.java:222) ~[gson-2.8.9.jar:?]
    at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$1.read(ReflectiveTypeAdapterFactory.java:131) ~[gson-2.8.9.jar:?]
    at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$Adapter.read(ReflectiveTypeAdapterFactory.java:222) ~[gson-2.8.9.jar:?]
    at com.google.gson.internal.bind.TypeAdapterRuntimeTypeWrapper.read(TypeAdapterRuntimeTypeWrapper.java:41) ~[gson-2.8.9.jar:?]
    at com.google.gson.internal.bind.CollectionTypeAdapterFactory$Adapter.read(CollectionTypeAdapterFactory.java:82) ~[gson-2.8.9.jar:?]
    at com.google.gson.internal.bind.CollectionTypeAdapterFactory$Adapter.read(CollectionTypeAdapterFactory.java:61) ~[gson-2.8.9.jar:?]
    at com.google.gson.Gson.fromJson(Gson.java:963) ~[gson-2.8.9.jar:?]
    ... 9 more
FlashyReese commented 2 years ago

Can you upload your commandaliases.json file? Seems like you have a syntax error in there.

u0398 commented 2 years ago

Sorry about that. I've been testing out the mod, and left commandaliases.json with an error by mistake.

I corrected that, and tried the test build against Immersive Portals. The original example script works. I will do some more testing, but it looks like you've fixed the incompatibility issue.

FlashyReese commented 2 years ago

You can also load them as individual files with this build in the directory generated which is .minecraft/commandaliases. It should work with toml / json and yaml. This helps if you are already familiar with other data formats and helps keep things tidy.

For example .minecraft/commandaliases/tools.toml

commandMode = "COMMAND_CUSTOM"

[customCommand]
parent = "tools"
message = "Here are some free wooden tools, $executor_name()!"

[[customCommand.actions]]
command = "give $executor_name() minecraft:wooden_sword"
commandType = "SERVER"
message = "Here is a wooden sword"
sleep = "2000"

[[customCommand.actions]]
command = "give $executor_name() minecraft:wooden_pickaxe"
commandType = "SERVER"
sleep = "1000"
message = "Here is a wooden pickaxe"

[[customCommand.actions]]
command = "give $executor_name() minecraft:wooden_axe"
commandType = "SERVER"
sleep = "1000"
message = "Here is a wooden axe"

[[customCommand.actions]]
command = "give $executor_name() minecraft:wooden_shovel"
commandType = "SERVER"
message = "Here is a wooden shovel, $executor_name()!"
u0398 commented 2 years ago

Using commandaliases.json I was able to list multiple commands like this:

[
    {
        "commandMode": "COMMAND_CUSTOM",
        ...
    },
    {
        "commandMode": "COMMAND_CUSTOM",
        ...
    }
]

But with json files in commandaliases/ it seems like only one command can be in a file. Is that the intention?

FlashyReese commented 2 years ago

Yes, that is intentional, the list of commands won't load properly if one of the commands has a syntax error. This helps with debugging and not having to scroll through 1000 lines of JSON to find your command.

u0398 commented 2 years ago

That makes sense.

I've tried quite a few commands without running into any Immersive Portals issues. Closing the issue.