Replaced redundant interfaces with Supplier in ServerProperties

This commit is contained in:
Rsl1122 2018-05-29 10:55:32 +03:00
parent 25707bdb4c
commit bf101d17bd

View File

@ -6,6 +6,7 @@ import org.bukkit.Server;
import org.spongepowered.api.Game; import org.spongepowered.api.Game;
import java.net.InetSocketAddress; import java.net.InetSocketAddress;
import java.util.function.Supplier;
/** /**
* Class responsible for holding server variable values that do not change * Class responsible for holding server variable values that do not change
@ -21,10 +22,10 @@ public class ServerProperties {
private final int port; private final int port;
private final String version; private final String version;
private final String implVersion; private final String implVersion;
private final IPWrapper ip; private final Supplier<String> ip;
private final int maxPlayers; private final int maxPlayers;
private final OnlinePlayersWrapper onlinePlayers; private final Supplier<Integer> onlinePlayers;
public ServerProperties(Server server) { public ServerProperties(Server server) {
id = server.getServerId(); id = server.getServerId();
@ -76,7 +77,7 @@ public class ServerProperties {
* @return the ip. * @return the ip.
*/ */
public String getIp() { public String getIp() {
return ip.getIP(); return ip.get();
} }
public String getName() { public String getName() {
@ -104,14 +105,6 @@ public class ServerProperties {
} }
public int getOnlinePlayers() { public int getOnlinePlayers() {
return onlinePlayers.getOnlinePlayers(); return onlinePlayers.get();
}
private interface OnlinePlayersWrapper {
int getOnlinePlayers();
}
private interface IPWrapper {
String getIP();
} }
} }