ForkGG / Fork-legacy

Fork: Minecraft Server Manager GUI for Windows
https://www.fork.gg
MIT License
102 stars 15 forks source link

Fixed crashes when adding fork servers #46

Closed KarmaDeb closed 8 months ago

KarmaDeb commented 8 months ago

Issue

If you tried to add a Fork server to a network, while the network had a non-fork server with the same name, the application would crash.

Why?

The problem was that, the "duplicate" check was being performed for servers of the same type. When adding a fork server, Fork was checking only if the same fork server was already added, meanwhile adding a non-fork server would only check if a non-fork server with the same name was added.

Solution

The solution is as simpler as to modify the Fork server add method. (It's not required for the non-fork, as it only performs a name check, which is enough). When adding a Fork server, the server UUID was being checked, that's good, as it basically prevents the user from adding the same server twice, but if there were a non-fork server which doesn't have an UID a crash would occur, so after checking by UUID, a check by name and address is performed. Basically this happens:

  1. Fork checks if the same fork server is already added
    • If yes, do nothing
      1. If the fork server is not yet added, iterate through all the network servers
    • If the address is the same and is not a fork server, replace the non-fork server with the fork server
    • If the address are not the same, modify the fork server name in the network so it doesn't crash