Xujiayao/Discord-MC-Chat

[Question] Custom command to restart my server doesn't seem to work

Closed this issue · 14 comments

Checks

Description

So i have a custom command created by this mod (https://modrinth.com/mod/restart-server). Basically restarts the servers; I have it edited so it works with screen on linux, so basically when I hit restart, server closes, delete the current screen and creates a new one with the new instance of the starting process working.

When I try to execute this command through "/console restart" on my discord channel using this mod, my minecraft character exits the game as if the game is closing as normal, but the game doesn't really close.

and it shows this error after doing so. (server is still up and I can join back, it just that it doesn't restart at all)
edit: https://mclo.gs/An6qAmo for better formatting.

[20:22:08] [JDA MainWS-ReadThread/INFO]: [Discord] EYDRIEN executed /console command: restart command!
[20:22:09] [ForkJoinPool.commonPool-worker-1/INFO]: [Restart Server] Restarting server...
[20:22:09] [Server thread/INFO]: _Eydrien_ lost connection: Restarting server...
[20:22:09] [Server thread/INFO]: [ADMIN] EYDRIEN left the game
[20:22:09] [Server thread/INFO]: remove player wand
[20:22:09] [Server thread/INFO]: Updating all forceload tickets for 2350489b-73b4-3a3e-8d9a-6ea18fe2527e
[20:22:09] [Server thread/INFO]: [voicechat] Disconnecting client [ADMIN] EYDRIEN
[20:22:09] [Server thread/WARN]: handleDisconnection() called twice
[20:22:09] [ForkJoinPool.commonPool-worker-1/ERROR]: Command exception: /restart
java.util.ConcurrentModificationException: null
        at java.util.ArrayList.forEach(ArrayList.java:1513) ~[?:?]
        at io.github.steveplays28.restartserver.commands.RestartCommand.execute(RestartCommand.java:28) ~[restart-server-1.2.0+mc1.19.x-1.20.x.jar:?]
        at io.github.steveplays28.restartserver.commands.RestartCommand.lambda$register$0(RestartCommand.java:20) ~[restart-server-1.2.0+mc1.19.x-1.20.x.jar:?]
        at com.mojang.brigadier.CommandDispatcher.execute(CommandDispatcher.java:264) ~[brigadier-1.1.8.jar:?]
        at net.minecraft.server.command.CommandManager.redirect$zmp000$architectury$performCommand(CommandManager.java:1545) ~[server-intermediary.jar:?]
        at net.minecraft.server.command.CommandManager.execute(CommandManager.java:287) ~[server-intermediary.jar:?]
        at com.xujiayao.discord_mc_chat.discord.DiscordEventListener.lambda$onSlashCommandInteraction$2(DiscordEventListener.java:153) ~[discord-mc-chat-1_20_1-2.3.2-3459ca43d8e140e1.jar:?]
        at java.util.concurrent.CompletableFuture.uniWhenComplete(CompletableFuture.java:863) ~[?:?]
        at java.util.concurrent.CompletableFuture$UniWhenComplete.tryFire(CompletableFuture.java:841) ~[?:?]
        at java.util.concurrent.CompletableFuture.postComplete(CompletableFuture.java:510) ~[?:?]
        at java.util.concurrent.CompletableFuture.complete(CompletableFuture.java:2147) ~[?:?]
        at net.dv8tion.jda.internal.requests.restaction.TriggerRestAction.lambda$submit$4(TriggerRestAction.java:139) ~[net_dv8tion_jda-5.0.0-beta.18-7e0acf4837b6ce56.jar:?]
        at java.util.concurrent.CompletableFuture.uniWhenComplete(CompletableFuture.java:863) ~[?:?]
        at java.util.concurrent.CompletableFuture$UniWhenComplete.tryFire(CompletableFuture.java:841) ~[?:?]
        at java.util.concurrent.CompletableFuture.postComplete(CompletableFuture.java:510) ~[?:?]
        at java.util.concurrent.CompletableFuture.complete(CompletableFuture.java:2147) ~[?:?]
        at net.dv8tion.jda.api.requests.Request.lambda$onSuccess$0(Request.java:121) ~[net_dv8tion_jda-5.0.0-beta.18-7e0acf4837b6ce56.jar:?]
        at java.util.concurrent.ForkJoinTask$RunnableExecuteAction.exec(ForkJoinTask.java:1395) ~[?:?]
        at java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:373) ~[?:?]
        at java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1182) ~[?:?]
        at java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1655) ~[?:?]
        at java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1622) ~[?:?]
        at java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:165) ~[?:?]

If I do it normally just using the command /restart ingame it works perfectly, so I'm not really sure what could be the problem here. Any ideas or solutions?

Further testing I realized the problem only occurs when there's players online. When you do it with no one online it basically execute the command completely and the server restarts. So the problem have to be with users.

It doesn't seem to be a problem with DMCC.

Even when the server is completely clean (only restart-server and its dependencies are installed), it still cannot restart normally and crashes.

[17:07:17] [Server thread/INFO]: Xujiayao[/127.0.0.1:2857] logged in with entity id 294 at (-13.0, 64.0, -340.0)
[17:07:17] [Server thread/INFO]: Xujiayao joined the game
restart
[17:07:23] [Server thread/INFO]: [Restart Server] Restarting server...
[17:07:23] [Server thread/ERROR]: Encountered an unexpected exception
java.lang.NoSuchMethodError: 'void net.minecraft.class_3244.method_14367(net.minecraft.class_2561)'
        at io.github.steveplays28.restartserver.commands.RestartCommand.lambda$execute$2(RestartCommand.java:28) ~[restart-server-1.2.0+mc1.19.x-1.20.x.jar:?]
        at java.util.ArrayList.forEach(ArrayList.java:1511) ~[?:?]
        at io.github.steveplays28.restartserver.commands.RestartCommand.execute(RestartCommand.java:28) ~[restart-server-1.2.0+mc1.19.x-1.20.x.jar:?]
        at io.github.steveplays28.restartserver.commands.RestartCommand.lambda$register$0(RestartCommand.java:20) ~[restart-server-1.2.0+mc1.19.x-1.20.x.jar:?]
        at com.mojang.brigadier.context.ContextChain.runExecutable(ContextChain.java:73) ~[brigadier-1.2.9.jar:?]
        at net.minecraft.class_8865.method_54416(class_8865.java:29) ~[server-intermediary.jar:?]
        at net.minecraft.class_8865.execute(class_8865.java:13) ~[server-intermediary.jar:?]
        at net.minecraft.class_8856.method_54405(class_8856.java:8) ~[server-intermediary.jar:?]
        at net.minecraft.class_8847.method_54388(class_8847.java:8) ~[server-intermediary.jar:?]
        at net.minecraft.class_8854.method_54390(class_8854.java:107) ~[server-intermediary.jar:?]
        at net.minecraft.class_2170.method_54313(class_2170.java:378) ~[server-intermediary.jar:?]
        at net.minecraft.class_2170.method_9249(class_2170.java:308) ~[server-intermediary.jar:?]
        at net.minecraft.class_2170.method_44252(class_2170.java:298) ~[server-intermediary.jar:?]
        at net.minecraft.class_3176.method_13941(class_3176.java:299) ~[server-intermediary.jar:?]
        at net.minecraft.class_3176.method_3813(class_3176.java:284) ~[server-intermediary.jar:?]
        at net.minecraft.server.MinecraftServer.method_3748(MinecraftServer.java:845) ~[server-intermediary.jar:?]
        at net.minecraft.server.MinecraftServer.method_29741(MinecraftServer.java:683) ~[server-intermediary.jar:?]
        at net.minecraft.server.MinecraftServer.method_29739(MinecraftServer.java:270) ~[server-intermediary.jar:?]
        at java.lang.Thread.run(Thread.java:842) ~[?:?]
[17:07:24] [Server thread/ERROR]: This crash report has been saved to: C:\Users\Xujiayao\Desktop\Server\.\crash-reports\crash-2024-03-22_17.07.24-server.txt
[17:07:24] [Server thread/INFO]: Stopping server
[17:07:24] [Server thread/INFO]: Saving players
[17:07:24] [Server thread/INFO]: Xujiayao lost connection: Server closed
[17:07:24] [Server thread/INFO]: Xujiayao left the game
[17:07:24] [Server thread/INFO]: Saving worlds
[17:07:24] [Server thread/INFO]: Saving chunks for level 'ServerLevel[新的世界]'/minecraft:overworld
[17:07:24] [Server thread/INFO]: Saving chunks for level 'ServerLevel[新的世界]'/minecraft:the_nether
[17:07:24] [Server thread/INFO]: Saving chunks for level 'ServerLevel[新的世界]'/minecraft:the_end
[17:07:24] [Server thread/INFO]: ThreadedAnvilChunkStorage (world): All chunks are saved
[17:07:24] [Server thread/INFO]: ThreadedAnvilChunkStorage (DIM-1): All chunks are saved
[17:07:24] [Server thread/INFO]: ThreadedAnvilChunkStorage (DIM1): All chunks are saved
[17:07:24] [Server thread/INFO]: ThreadedAnvilChunkStorage: All dimensions are saved

It works for me when doing it ingame or in the console, it just doesn't work when doing it through discord when players are online.

What game version are you?

fabric 1.20.1

Lemme try that

putty_PcBRW5Frzw

this is how I have my config to make it work through screen.

Boom... That restart-server mod is incompatible with 1.20.4. (@Steveplays28)

And the restart function still works perfectly in 1.20.1 with player in the server
(Discord command: /console restart)
I am using completely default settings.

image

image

Then I don't know what could it be that is causing me to not work when players are online through discord console command. Could it be for having stuff messing with nicknames? Like my minecraft name is _Eydrien_, but I'm using StyledChat & StyledNicknames for formatting and also luckperms for prefixes.

Could you send me your server zip for testing? The world folder is not needed. You may obscure the token if you feel it necessary.

You may send it via my email: i#xujiayao.com

Thanks for the heads up. Had no clue it was incompatible with 1.20.4.
I'll investigate. In the meantime, I can recommend alternatives such as hosting with Docker + Portainer, setting an auto-restart mode, and simply running /stop (as I mentioned to eydrien in my Discord server as well).

Oops, sorry. I didn't know you two had been in touch 😂

All good!

Closing due to not being able to reproduce.