mirror of
https://github.com/plan-player-analytics/Plan.git
synced 2025-01-06 08:28:12 +01:00
commit
31f25da31f
@ -4,7 +4,7 @@
|
|||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<groupId>com.djrapitops</groupId>
|
<groupId>com.djrapitops</groupId>
|
||||||
<artifactId>Plan</artifactId>
|
<artifactId>Plan</artifactId>
|
||||||
<version>4.0.4</version>
|
<version>4.0.5</version>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
<repositories>
|
<repositories>
|
||||||
<repository>
|
<repository>
|
||||||
|
@ -175,6 +175,7 @@ public class Plan extends BukkitPlugin<Plan> implements IPlan {
|
|||||||
if (!webServer.isEnabled()) {
|
if (!webServer.isEnabled()) {
|
||||||
Log.error("WebServer was not successfully initialized. Is the port (" + Settings.WEBSERVER_PORT.getNumber() + ") in use?");
|
Log.error("WebServer was not successfully initialized. Is the port (" + Settings.WEBSERVER_PORT.getNumber() + ") in use?");
|
||||||
}
|
}
|
||||||
|
serverInfoManager.updateServerInfo();
|
||||||
|
|
||||||
Benchmark.stop("Enable", "WebServer Initialization");
|
Benchmark.stop("Enable", "WebServer Initialization");
|
||||||
|
|
||||||
|
@ -80,8 +80,9 @@ public class PlanBungee extends BungeePlugin<PlanBungee> implements IPlan {
|
|||||||
|
|
||||||
serverInfoManager = new BungeeServerInfoManager(this);
|
serverInfoManager = new BungeeServerInfoManager(this);
|
||||||
infoManager = new BungeeInformationManager(this);
|
infoManager = new BungeeInformationManager(this);
|
||||||
|
|
||||||
webServer.initServer();
|
webServer.initServer();
|
||||||
|
serverInfoManager.loadServerInfo();
|
||||||
|
|
||||||
|
|
||||||
if (!webServer.isEnabled()) {
|
if (!webServer.isEnabled()) {
|
||||||
Log.error("WebServer was not successfully initialized.");
|
Log.error("WebServer was not successfully initialized.");
|
||||||
|
@ -42,15 +42,8 @@ public class BukkitServerInfoManager {
|
|||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
throw new PlanEnableException("Failed to read ServerInfoFile.yml", e);
|
throw new PlanEnableException("Failed to read ServerInfoFile.yml", e);
|
||||||
}
|
}
|
||||||
|
|
||||||
Optional<UUID> serverUUID = serverInfoFile.getUUID();
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (serverUUID.isPresent()) {
|
updateServerInfo();
|
||||||
updateDbInfo(serverUUID.get());
|
|
||||||
} else {
|
|
||||||
registerServer();
|
|
||||||
}
|
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
throw new PlanEnableException("Failed to update Database server info", e);
|
throw new PlanEnableException("Failed to update Database server info", e);
|
||||||
} catch (IOException 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 {
|
private void updateDbInfo(UUID serverUUID) throws SQLException, IOException {
|
||||||
Optional<Integer> serverID = serverTable.getServerID(serverUUID);
|
Optional<Integer> serverID = serverTable.getServerID(serverUUID);
|
||||||
if (!serverID.isPresent()) {
|
if (!serverID.isPresent()) {
|
||||||
|
@ -40,13 +40,20 @@ public class BungeeServerInfoManager {
|
|||||||
this.db = plugin.getDB();
|
this.db = plugin.getDB();
|
||||||
serverTable = db.getServerTable();
|
serverTable = db.getServerTable();
|
||||||
|
|
||||||
try {
|
bukkitServers = new HashMap<>();
|
||||||
bukkitServers = new HashMap<>();
|
onlineServers = new HashSet<>();
|
||||||
onlineServers = new HashSet<>();
|
}
|
||||||
|
|
||||||
|
public void loadServerInfo() throws PlanEnableException {
|
||||||
|
try {
|
||||||
Optional<ServerInfo> bungeeInfo = db.getServerTable().getBungeeInfo();
|
Optional<ServerInfo> bungeeInfo = db.getServerTable().getBungeeInfo();
|
||||||
if (bungeeInfo.isPresent()) {
|
if (bungeeInfo.isPresent()) {
|
||||||
serverInfo = bungeeInfo.get();
|
serverInfo = bungeeInfo.get();
|
||||||
|
String accessAddress = plugin.getWebServer().getAccessAddress();
|
||||||
|
if (!accessAddress.equals(serverInfo.getWebAddress())) {
|
||||||
|
serverInfo.setWebAddress(accessAddress);
|
||||||
|
serverTable.saveCurrentServerInfo(serverInfo);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
serverInfo = registerBungeeInfo();
|
serverInfo = registerBungeeInfo();
|
||||||
}
|
}
|
||||||
|
@ -175,7 +175,11 @@ public class TPSCountTimer extends AbsRunnable {
|
|||||||
* @return amount of entities
|
* @return amount of entities
|
||||||
*/
|
*/
|
||||||
private int getEntityCountPaper() {
|
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() {
|
public int getLatestPlayersOnline() {
|
||||||
|
@ -94,7 +94,7 @@ public class FormatUtils {
|
|||||||
long hours = x % 24;
|
long hours = x % 24;
|
||||||
x /= 24;
|
x /= 24;
|
||||||
long days = x % 365;
|
long days = x % 365;
|
||||||
long months = days % 30;
|
long months = (days - days % 30) / 30;
|
||||||
days -= months * 30;
|
days -= months * 30;
|
||||||
x /= 365;
|
x /= 365;
|
||||||
long years = x;
|
long years = x;
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
name: Plan
|
name: Plan
|
||||||
author: Rsl1122
|
author: Rsl1122
|
||||||
main: main.java.com.djrapitops.plan.PlanBungee
|
main: main.java.com.djrapitops.plan.PlanBungee
|
||||||
version: 4.0.4
|
version: 4.0.5
|
@ -1,7 +1,7 @@
|
|||||||
name: Plan
|
name: Plan
|
||||||
author: Rsl1122
|
author: Rsl1122
|
||||||
main: main.java.com.djrapitops.plan.Plan
|
main: main.java.com.djrapitops.plan.Plan
|
||||||
version: 4.0.4
|
version: 4.0.5
|
||||||
softdepend:
|
softdepend:
|
||||||
- OnTime
|
- OnTime
|
||||||
- EssentialsX
|
- EssentialsX
|
||||||
|
Loading…
Reference in New Issue
Block a user