Little changes and started commenting stuff

This commit is contained in:
Jaime Martínez Rincón 2017-11-29 18:44:20 +01:00
parent 737c218295
commit aebe9419f0
5 changed files with 39 additions and 12 deletions

View File

@ -11,7 +11,7 @@
<name>PlayerBalancer Plugin</name>
<artifactId>playerbalancer-plugin</artifactId>
<version>2.1.2.2</version>
<version>2.1.3</version>
<build>
<finalName>PlayerBalancer</finalName>

View File

@ -37,7 +37,7 @@ public enum PingTactic {
try {
server.ping((ping, throwable) -> {
if (ping != null) {
//using deprecated method for 1.8 compatibility
//using deprecated method for bungee 1.8 compatibility
callback.done(new ServerStatus(
ping.getDescription(),
ping.getPlayers().getOnline(),

View File

@ -2,25 +2,49 @@ package com.jaimemartz.playerbalancer.ping;
import net.md_5.bungee.api.config.ServerInfo;
public final class ServerStatus {
public class ServerStatus {
private final String description;
private final int players, maximum;
private boolean outdated = true;
private final boolean online;
private final boolean fabricated;
private boolean outdated = true;
/**
* Constructor when cannot ping the server
*/
public ServerStatus() {
this("Server Unreachable", 0, 0);
this.description = "Server Unreachable";
this.players = 0;
this.maximum = 0;
this.online = false;
this.fabricated = true;
}
/**
* Constructor when we have to return defaults
* Defaulting to be accessible as this is used when the server checker is disabled
* @param server the server for providing basic info about itself
*/
public ServerStatus(ServerInfo server) {
this(server.getMotd(), server.getPlayers().size(), Integer.MAX_VALUE);
this.description = server.getMotd();
this.players = server.getPlayers().size();
this.maximum = Integer.MAX_VALUE;
this.online = true;
this.fabricated = true;
}
/**
* Constructor when we have to store ping results
* @param description the description (aka MOTD) from the ping result
* @param players the count of players online from the ping result
* @param maximum the maximum amount of players possible from the ping result
*/
public ServerStatus(String description, int players, int maximum) {
this.description = description;
this.players = players;
this.maximum = maximum;
this.online = maximum != 0 && players < maximum;
this.fabricated = false;
}
public String getDescription() {
@ -35,6 +59,14 @@ public final class ServerStatus {
return maximum;
}
public boolean isOnline() {
return online;
}
public boolean isFabricated() {
return fabricated;
}
public boolean isOutdated() {
return outdated;
}
@ -42,8 +74,4 @@ public final class ServerStatus {
public void setOutdated(boolean outdated) {
this.outdated = outdated;
}
public boolean isOnline() {
return online;
}
}

View File

@ -56,7 +56,6 @@ public class StatusManager implements Listener {
}
}
}
}, 0L, props.getInterval(), TimeUnit.MILLISECONDS);
}

View File

@ -94,7 +94,7 @@ public class MainCommand implements CommandExecutor {
sender.sendMessage(ChatColor.AQUA + "/spb setbypass [player]" + ChatColor.GRAY + " - " + ChatColor.RED + "Sets a bypass for you or the specified player");
sender.sendMessage(ChatColor.AQUA + "/spb clearbypass [player]" + ChatColor.GRAY + " - " + ChatColor.RED + "Clears the bypass for you or the specified player");
sender.sendMessage(ChatColor.AQUA + "/spb overridestatus <server> <status>" + ChatColor.GRAY + " - " + ChatColor.RED + "Overrides the accessible status of a specific server, over anything else");
sender.sendMessage(ChatColor.AQUA + "/spb clearoverride <server> <status>" + ChatColor.GRAY + " - " + ChatColor.RED + "Clears the overriden status of a specific server");
sender.sendMessage(ChatColor.AQUA + "/spb clearoverride <server>" + ChatColor.GRAY + " - " + ChatColor.RED + "Clears the overridden status of a specific server");
sender.sendMessage(ChatColor.STRIKETHROUGH + ChatColor.GRAY.toString() + Strings.repeat("-", 53));
}
}