mirror of
https://github.com/BGHDDevelopment/PlayerBalancer.git
synced 2024-11-05 02:19:48 +01:00
Made some important methods public
This commit is contained in:
parent
494e6b61d8
commit
56d18813f4
@ -14,7 +14,7 @@ public class SectionCommand extends Command {
|
|||||||
private transient final LobbyBalancer plugin;
|
private transient final LobbyBalancer plugin;
|
||||||
private transient final ServerSection section;
|
private transient final ServerSection section;
|
||||||
|
|
||||||
SectionCommand(LobbyBalancer plugin, String name, String permission, List<String> aliases, ServerSection section) {
|
public SectionCommand(LobbyBalancer plugin, String name, String permission, List<String> aliases, ServerSection section) {
|
||||||
super(name, permission, aliases.stream().toArray(String[]::new));
|
super(name, permission, aliases.stream().toArray(String[]::new));
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
this.section = section;
|
this.section = section;
|
||||||
|
@ -71,7 +71,7 @@ public class SectionManager {
|
|||||||
sectionServers.clear();
|
sectionServers.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
void register(ServerInfo server, ServerSection section) {
|
public void register(ServerInfo server, ServerSection section) {
|
||||||
if (sectionServers.containsKey(server)) {
|
if (sectionServers.containsKey(server)) {
|
||||||
ServerSection other = sectionServers.get(server);
|
ServerSection other = sectionServers.get(server);
|
||||||
throw new IllegalArgumentException(String.format("The server \"%s\" is already in the section \"%s\"", server.getName(), other.getName()));
|
throw new IllegalArgumentException(String.format("The server \"%s\" is already in the section \"%s\"", server.getName(), other.getName()));
|
||||||
@ -79,6 +79,7 @@ public class SectionManager {
|
|||||||
|
|
||||||
plugin.getLogger().info(String.format("Registering server \"%s\" to section \"%s\"", server.getName(), section.getName()));
|
plugin.getLogger().info(String.format("Registering server \"%s\" to section \"%s\"", server.getName(), section.getName()));
|
||||||
sectionServers.put(server, section);
|
sectionServers.put(server, section);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public ServerSection getByName(String name) {
|
public ServerSection getByName(String name) {
|
||||||
@ -99,11 +100,11 @@ public class SectionManager {
|
|||||||
return principal;
|
return principal;
|
||||||
}
|
}
|
||||||
|
|
||||||
void setPrincipal(ServerSection principal) {
|
public void setPrincipal(ServerSection principal) {
|
||||||
this.principal = principal;
|
this.principal = principal;
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean hasPrincipal() {
|
public boolean hasPrincipal() {
|
||||||
return principal != null;
|
return principal != null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -30,13 +30,32 @@ public class ServerSection {
|
|||||||
private SectionCommand command;
|
private SectionCommand command;
|
||||||
private boolean valid = false;
|
private boolean valid = false;
|
||||||
|
|
||||||
ServerSection(String name, Configuration section) {
|
public ServerSection(String name, Configuration section) {
|
||||||
this.name = name;
|
this.name = name;
|
||||||
this.section = section;
|
this.section = section;
|
||||||
this.servers = new ArrayList<>();
|
this.servers = new ArrayList<>();
|
||||||
}
|
}
|
||||||
|
|
||||||
void preInit(LobbyBalancer plugin) {
|
public ServerSection(String name, boolean principal, int position, boolean dummy, ServerSection parent, boolean inherited, List<ServerInfo> servers, ProviderType provider, ServerInfo server, SectionCommand command, boolean valid) {
|
||||||
|
this.section = null;
|
||||||
|
this.name = name;
|
||||||
|
this.principal = principal;
|
||||||
|
this.position = position;
|
||||||
|
this.dummy = dummy;
|
||||||
|
this.parent = parent;
|
||||||
|
this.inherited = inherited;
|
||||||
|
this.servers = servers;
|
||||||
|
this.provider = provider;
|
||||||
|
this.server = server;
|
||||||
|
this.command = command;
|
||||||
|
this.valid = valid;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void preInit(LobbyBalancer plugin) {
|
||||||
|
if (section == null) {
|
||||||
|
throw new IllegalStateException("Tried to call an init method with null configuration section");
|
||||||
|
}
|
||||||
|
|
||||||
principal = section.getBoolean("principal", false);
|
principal = section.getBoolean("principal", false);
|
||||||
|
|
||||||
if (principal) {
|
if (principal) {
|
||||||
@ -84,7 +103,11 @@ public class ServerSection {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void load(LobbyBalancer plugin) {
|
public void load(LobbyBalancer plugin) {
|
||||||
|
if (section == null) {
|
||||||
|
throw new IllegalStateException("Tried to call an init method with null configuration section");
|
||||||
|
}
|
||||||
|
|
||||||
if (parent != null && parent.parent == this) {
|
if (parent != null && parent.parent == this) {
|
||||||
throw new IllegalStateException(String.format("The sections \"%s\" and \"%s\" are parents of each other", this.name, parent.name));
|
throw new IllegalStateException(String.format("The sections \"%s\" and \"%s\" are parents of each other", this.name, parent.name));
|
||||||
}
|
}
|
||||||
@ -108,7 +131,11 @@ public class ServerSection {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void postInit(LobbyBalancer plugin) {
|
public void postInit(LobbyBalancer plugin) {
|
||||||
|
if (section == null) {
|
||||||
|
throw new IllegalStateException("Tried to call an init method with null configuration section");
|
||||||
|
}
|
||||||
|
|
||||||
Callable<Integer> callable = () -> {
|
Callable<Integer> callable = () -> {
|
||||||
int iterations = 0;
|
int iterations = 0;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user