ME1312 / SubServers-2

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

Code example for dynamically changing servers at runtime? #51

Closed s5bug closed 4 years ago

s5bug commented 4 years ago

See: https://github.com/PaperMC/Waterfall/issues/466

I think, based on what I've seen of it, I want to use SubServers.

Janmm14 commented 4 years ago

BungeeCord API allows adding servers by constructing a server info with ProxyServer.getInstance().constructServerInfo(...) and then calling ProxyServer.getInstance().getServers().add(...)

Removal should be possible too, but make sure nobody is on the servers you remove.

s5bug commented 4 years ago

Awesome, thank you!

ME1312 commented 4 years ago

SubServers works a little differently in this regard since the simulated method ProxyServer.getServers() returns a compiled map of all Servers and Subservers (or "legacy" ServerInfo in some instances). As such modifying the resulting map currently does nothing, which is a bit of an oversight on my part where compatibility is concerned, so this will probably be fixed later.

Either way, adding servers dynamically here is typically done from SubAPI.addServer() or Host.addSubServer() for adding Servers and Subservers respectively. Alternatively, there's SubCreator.create() for creating Subservers using SubCreator.

s5bug commented 4 years ago

Say I'm using the Enterprise method in the wiki. SubAPI adds Hosts, and each host adds one SubServer, right?

ME1312 commented 4 years ago

A host doesn't technically add anything on its own (besides itself, i suppose). You would then assign Subservers to the host that they exist on.