mirror of
https://github.com/plan-player-analytics/Plan.git
synced 2025-01-01 05:57:50 +01:00
commit
31f25da31f
@ -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>
|
||||
|
@ -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");
|
||||
|
||||
|
@ -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.");
|
||||
|
@ -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()) {
|
||||
|
@ -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();
|
||||
}
|
||||
|
@ -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() {
|
||||
|
@ -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;
|
||||
|
@ -1,4 +1,4 @@
|
||||
name: Plan
|
||||
author: Rsl1122
|
||||
main: main.java.com.djrapitops.plan.PlanBungee
|
||||
version: 4.0.4
|
||||
version: 4.0.5
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user