efekurbann / sync-commands

Send commands between server instances. Supports minecraft 1.8 - 1.19. Redis & Socket & RabbitMQ
MIT License
10 stars 2 forks source link

Preserve commands to file if fail to execute but port and settings are correct #9

Open TheJoshue opened 1 month ago

TheJoshue commented 1 month ago

For example if from survival server we tried to /sync some command to hub

(executing from survival server) /sync hub broadcast Hello from survivival

if hub server is offline at the moment of execution, the Synccommands will output:

Successfully sent command
[SyncCommands]: Tried to send command to hub but could not reach. Is it offline?
[23:51:05 INFO] [SyncCommands]: Successfully sent command to server(s): hub

However, the command will literally go into void after this.

I recommend potentially, because this plugin works via bungee too (and most probably it will be ran and used while proxy server is online and not offline) to store every failed command into SyncCommand config folder of proxy (or in memory of proxy rather to say) which will store 1. from which server it was executed 2. to which 3. arguments that are being (failed) sent

This could also make some networks with a lot of test servers which has for example sending every day autorestart feature, crammed up with a lot of commands if their test servers are not always online... so maybe consider this to be new format of the command

/(b)sync <server/all> <command> [(preserve:)true/false]

so basically we can for example execute /sync hub broadcast Hello there preserve:false (or potentially without "preserve:" but i think it's easier to handle with it) which would mean that if the command fails to execute it will go into void and not be saved to proxy SyncCommands config... on the other side if we exclude this argument at all or have "preserve:true", it will by default preserve the command into memory of proxy server (but i think it's better into some kind of file)

This could also add new config options like

default-preserve-state: true/false # literally means if the "preserve:" tag is excluded, will it preserve it by default or not...
<...>
period-check-if-failed-servers-online: 120 # integer (seconds); this would basically be a period of time of how frequently the plugin/server will check for each server that has awaiting (stored) commands in the file/memory, are that server online yet
send-failed-commands-with-delay: 30 # integer (seconds); this would be a time to wait before sending failed commands to the server that we checked that is now online! after this time the commands will be sent; this could be useful to escape sending commands to the server while it's starting and in some rare cases it might be detected as already online or similar (of course can be set to 0 to disable it)