Merge pull request #404 from Rsl1122/4.0.5

Pull Request for 4.0.5
This commit is contained in:
Rsl1122 2017-11-01 10:23:09 +02:00 committed by GitHub
commit 31f25da31f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 32 additions and 17 deletions

View File

@ -4,7 +4,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>com.djrapitops</groupId>
<artifactId>Plan</artifactId>
<version>4.0.4</version>
<version>4.0.5</version>
<packaging>jar</packaging>
<repositories>
<repository>

View File

@ -175,6 +175,7 @@ public class Plan extends BukkitPlugin<Plan> implements IPlan {
if (!webServer.isEnabled()) {
Log.error("WebServer was not successfully initialized. Is the port (" + Settings.WEBSERVER_PORT.getNumber() + ") in use?");
}
serverInfoManager.updateServerInfo();
Benchmark.stop("Enable", "WebServer Initialization");

View File

@ -80,8 +80,9 @@ public class PlanBungee extends BungeePlugin<PlanBungee> implements IPlan {
serverInfoManager = new BungeeServerInfoManager(this);
infoManager = new BungeeInformationManager(this);
webServer.initServer();
serverInfoManager.loadServerInfo();
if (!webServer.isEnabled()) {
Log.error("WebServer was not successfully initialized.");

View File

@ -42,15 +42,8 @@ public class BukkitServerInfoManager {
} catch (IOException e) {
throw new PlanEnableException("Failed to read ServerInfoFile.yml", e);
}
Optional<UUID> serverUUID = serverInfoFile.getUUID();
try {
if (serverUUID.isPresent()) {
updateDbInfo(serverUUID.get());
} else {
registerServer();
}
updateServerInfo();
} catch (SQLException e) {
throw new PlanEnableException("Failed to update Database server info", e);
} catch (IOException e) {
@ -58,6 +51,15 @@ public class BukkitServerInfoManager {
}
}
public void updateServerInfo() throws SQLException, IOException {
Optional<UUID> serverUUID = serverInfoFile.getUUID();
if (serverUUID.isPresent()) {
updateDbInfo(serverUUID.get());
} else {
registerServer();
}
}
private void updateDbInfo(UUID serverUUID) throws SQLException, IOException {
Optional<Integer> serverID = serverTable.getServerID(serverUUID);
if (!serverID.isPresent()) {

View File

@ -40,13 +40,20 @@ public class BungeeServerInfoManager {
this.db = plugin.getDB();
serverTable = db.getServerTable();
try {
bukkitServers = new HashMap<>();
onlineServers = new HashSet<>();
bukkitServers = new HashMap<>();
onlineServers = new HashSet<>();
}
public void loadServerInfo() throws PlanEnableException {
try {
Optional<ServerInfo> bungeeInfo = db.getServerTable().getBungeeInfo();
if (bungeeInfo.isPresent()) {
serverInfo = bungeeInfo.get();
String accessAddress = plugin.getWebServer().getAccessAddress();
if (!accessAddress.equals(serverInfo.getWebAddress())) {
serverInfo.setWebAddress(accessAddress);
serverTable.saveCurrentServerInfo(serverInfo);
}
} else {
serverInfo = registerBungeeInfo();
}

View File

@ -175,7 +175,11 @@ public class TPSCountTimer extends AbsRunnable {
* @return amount of entities
*/
private int getEntityCountPaper() {
return ((Plan) plugin).getServer().getWorlds().stream().mapToInt(World::getEntityCount).sum();
try {
return ((Plan) plugin).getServer().getWorlds().stream().mapToInt(World::getEntityCount).sum();
} catch (NoSuchMethodError e) {
return getEntityCount();
}
}
public int getLatestPlayersOnline() {

View File

@ -94,7 +94,7 @@ public class FormatUtils {
long hours = x % 24;
x /= 24;
long days = x % 365;
long months = days % 30;
long months = (days - days % 30) / 30;
days -= months * 30;
x /= 365;
long years = x;

View File

@ -1,4 +1,4 @@
name: Plan
author: Rsl1122
main: main.java.com.djrapitops.plan.PlanBungee
version: 4.0.4
version: 4.0.5

View File

@ -1,7 +1,7 @@
name: Plan
author: Rsl1122
main: main.java.com.djrapitops.plan.Plan
version: 4.0.4
version: 4.0.5
softdepend:
- OnTime
- EssentialsX