Refactored class variable assignment in constructors for ServerInfo

This commit is contained in:
Rsl1122 2018-06-02 08:12:19 +03:00
parent d677fb816e
commit efda292a37
4 changed files with 12 additions and 7 deletions

View File

@ -28,11 +28,12 @@ public class BukkitServerInfo extends ServerInfo {
private ServerInfoFile serverInfoFile;
private Database database;
BukkitServerInfo() {
public BukkitServerInfo(Plan plugin) {
this(new ServerProperties(plugin.getServer()));
}
public BukkitServerInfo(Plan plugin) {
serverProperties = new ServerProperties(plugin.getServer());
public BukkitServerInfo(ServerProperties serverProperties) {
super(serverProperties);
}
@Override

View File

@ -22,7 +22,7 @@ import java.util.UUID;
public class BungeeServerInfo extends ServerInfo {
public BungeeServerInfo(PlanBungee plugin) {
serverProperties = new ServerProperties(plugin.getProxy());
super(new ServerProperties(plugin.getProxy()));
}
@Override
@ -44,7 +44,7 @@ public class BungeeServerInfo extends ServerInfo {
return server;
}
private void updateServerInfo(Database db) throws DBException {
private void updateServerInfo(Database db) {
String accessAddress = WebServerSystem.getInstance().getWebServer().getAccessAddress();
if (!accessAddress.equals(server.getWebAddress())) {
server.setWebAddress(accessAddress);
@ -61,7 +61,7 @@ public class BungeeServerInfo extends ServerInfo {
}
}
private Server registerBungeeInfo(Database db) throws DBException, EnableException {
private Server registerBungeeInfo(Database db) throws EnableException {
ServerProperties properties = ServerInfo.getServerProperties();
UUID serverUUID = generateNewUUID(properties);
String accessAddress = WebServerSystem.getInstance().getWebServer().getAccessAddress();

View File

@ -23,6 +23,10 @@ public abstract class ServerInfo implements SubSystem {
protected Server server;
protected ServerProperties serverProperties;
public ServerInfo(ServerProperties serverProperties) {
this.serverProperties = serverProperties;
}
public static ServerInfo getInstance() {
ServerInfo serverInfo = PlanSystem.getInstance().getServerInfo();
Verify.nullCheck(serverInfo, () -> new IllegalStateException("ServerInfo was not initialized."));

View File

@ -5,6 +5,6 @@ import org.spongepowered.api.Sponge;
public class SpongeServerInfo extends BukkitServerInfo {
public SpongeServerInfo() {
serverProperties = new ServerProperties(Sponge.getGame());
super(new ServerProperties(Sponge.getGame()));
}
}