ME1312 / SubServers-2

SubServers – The Minecraft Server Management Platform
Apache License 2.0
91 stars 23 forks source link

Custom initial lobby send logic #52

Closed s5bug closed 4 years ago

s5bug commented 4 years ago

What Should Be Added

Custom logic for what server a player should be sent to on join

Why It Should be Added

In the case that there would be multiple low-power lobby servers, it is currently impossible to have SubServers delegate to custom logic to report what server the next player should be sent to.

What's The Alternative

I have no clue. I guess changing the server list so that the one that the next player should be sent to is always at the head of the list?

ME1312 commented 4 years ago

The feature in BungeeCord that you are trying to use is priorities, which defines fallback servers. SubServers provides you with two modes of selecting fallback servers: Default and Smart.

Default just allows your fork of BungeeCord to make the decision itself, which in most forks, will just result in the first available server being selected 100% of the time.

Smart is a mode provided by SubServers; a more AI-like system that determines which server to select based on the amount of points it receives in its "confidence score." The server with the highest score is chosen. In the event of a tie, a random server is chosen from those which have the highest score.

It isn't exactly well-known, but you can add custom checks to influence a server's score dynamically through a custom plugin and these static methods here. The default checks SubServers performs automatically can be seen here.

s5bug commented 4 years ago

Normal Bungee doesn't start if I start it with servers: {}. Should I start it with a completely invalid server on startup and then add servers once SubServers loads?

EDIT: And if I want to send a specific player to a specific lobby, do I get to base server score on the player?

ME1312 commented 4 years ago

You only have to add the servers that appear in the config elsewhere (like in priorities, for example). For this, you can use some nonsense data to bypass validation. The important part is just that you name the servers the same way they appear as subservers.

Default and Smart fallback selection offer more of a global solution. A player is never specified in these cases. For that, you'd be better off creating and registering a third fallback selector. You can still use the some of the static methods from Smart fallback to help you out with this, though.

s5bug commented 4 years ago

Well, I fetch the valid lobby servers from AWS once SubServers has loaded; I'm never guaranteed to have an available server.

ReconnectHandler is exactly what I want, but the naming throws me off; does that handle first-time connections?

ME1312 commented 4 years ago

It is a little unfortunate, but the validation is done by your BungeeCord fork, so you will need at least one dummy server to launch it.

BungeeCord's ReconnectHandler is a little unfortunate in its naming, but it does also determine the initial server.