diff --git a/Plan/src/main/java/com/djrapitops/plan/data/store/containers/NetworkContainer.java b/Plan/src/main/java/com/djrapitops/plan/data/store/containers/NetworkContainer.java
index 19b98ee36..7618b2709 100644
--- a/Plan/src/main/java/com/djrapitops/plan/data/store/containers/NetworkContainer.java
+++ b/Plan/src/main/java/com/djrapitops/plan/data/store/containers/NetworkContainer.java
@@ -8,7 +8,6 @@ import com.djrapitops.plan.data.store.mutators.PlayersMutator;
import com.djrapitops.plan.data.store.mutators.TPSMutator;
import com.djrapitops.plan.data.store.mutators.health.NetworkHealthInformation;
import com.djrapitops.plan.system.database.databases.Database;
-import com.djrapitops.plan.system.info.server.Server;
import com.djrapitops.plan.system.info.server.properties.ServerProperties;
import com.djrapitops.plan.system.settings.Settings;
import com.djrapitops.plan.system.settings.config.PlanConfig;
@@ -21,7 +20,11 @@ import com.djrapitops.plan.utilities.html.graphs.stack.StackGraph;
import com.djrapitops.plan.utilities.html.structure.NetworkServerBox;
import com.djrapitops.plugin.api.Check;
import com.djrapitops.plugin.api.TimeAmount;
+import dagger.Lazy;
+import javax.inject.Inject;
+import javax.inject.Named;
+import javax.inject.Singleton;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
@@ -39,17 +42,32 @@ public class NetworkContainer extends DataContainer {
private final ServerContainer bungeeContainer;
- // TODO
- private String version;
- private PlanConfig config;
- private Theme theme;
- private Database database;
- private ServerProperties serverProperties;
- private Formatters formatters;
- private Graphs graphs;
+ private final String version;
+ private final PlanConfig config;
+ private final Theme theme;
+ private final Database database;
+ private final ServerProperties serverProperties;
+ private final Formatters formatters;
+ private final Graphs graphs;
- public NetworkContainer(ServerContainer bungeeContainer) {
+ public NetworkContainer(
+ ServerContainer bungeeContainer,
+ String version,
+ PlanConfig config,
+ Theme theme,
+ Database database,
+ ServerProperties serverProperties,
+ Formatters formatters,
+ Graphs graphs
+ ) {
this.bungeeContainer = bungeeContainer;
+ this.version = version;
+ this.config = config;
+ this.theme = theme;
+ this.database = database;
+ this.serverProperties = serverProperties;
+ this.formatters = formatters;
+ this.graphs = graphs;
putSupplier(NetworkKeys.PLAYERS_MUTATOR, () -> PlayersMutator.forContainer(bungeeContainer));
@@ -66,13 +84,15 @@ public class NetworkContainer extends DataContainer {
putSupplier(NetworkKeys.SERVERS_TAB, () -> {
StringBuilder serverBoxes = new StringBuilder();
Map> playersOnlineData = getValue(NetworkKeys.NETWORK_PLAYER_ONLINE_DATA).orElse(new HashMap<>());
- for (Server server : getValue(NetworkKeys.BUKKIT_SERVERS).orElse(new ArrayList<>())) {
- TPSMutator tpsMutator = new TPSMutator(playersOnlineData.getOrDefault(server.getId(), new ArrayList<>()));
-
- // TODO Add Registered players per server.
- NetworkServerBox serverBox = new NetworkServerBox(server, 0, tpsMutator, graphs);
- serverBoxes.append(serverBox.toHtml());
- }
+ getValue(NetworkKeys.BUKKIT_SERVERS).orElse(new ArrayList<>())
+ .stream()
+ .sorted((one, two) -> String.CASE_INSENSITIVE_ORDER.compare(one.getName(), two.getName()))
+ .forEach(server -> {
+ TPSMutator tpsMutator = new TPSMutator(playersOnlineData.getOrDefault(server.getId(), new ArrayList<>()));
+ // TODO Add Registered players per server.
+ NetworkServerBox serverBox = new NetworkServerBox(server, 0, tpsMutator, graphs);
+ serverBoxes.append(serverBox.toHtml());
+ });
return serverBoxes.toString();
});
}
@@ -183,4 +203,48 @@ public class NetworkContainer extends DataContainer {
putSupplier(NetworkKeys.PLAYERS_MONTH, () -> getUnsafe(uniqueMonth).count());
}
+ @Singleton
+ public static class Factory {
+
+ private final Lazy version;
+ private final Lazy config;
+ private final Lazy theme;
+ private final Lazy database;
+ private final Lazy serverProperties;
+ private final Lazy formatters;
+ private final Lazy graphs;
+
+ @Inject
+ public Factory(
+ @Named("currentVersion") Lazy version,
+ Lazy config,
+ Lazy theme,
+ Lazy database,
+ Lazy serverProperties,
+ Lazy formatters,
+ Lazy graphs
+ ) {
+ this.version = version;
+ this.config = config;
+ this.theme = theme;
+ this.database = database;
+ this.serverProperties = serverProperties;
+ this.formatters = formatters;
+ this.graphs = graphs;
+ }
+
+ public NetworkContainer forBungeeContainer(ServerContainer bungeeContainer) {
+ return new NetworkContainer(
+ bungeeContainer,
+ version.get(),
+ config.get(),
+ theme.get(),
+ database.get(),
+ serverProperties.get(),
+ formatters.get(),
+ graphs.get()
+ );
+ }
+ }
+
}
\ No newline at end of file
diff --git a/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/MySQLDB.java b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/MySQLDB.java
index 2637bf888..f168ad4c7 100644
--- a/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/MySQLDB.java
+++ b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/MySQLDB.java
@@ -2,6 +2,7 @@ package com.djrapitops.plan.system.database.databases.sql;
import com.djrapitops.plan.api.exceptions.database.DBInitException;
import com.djrapitops.plan.api.exceptions.database.DBOpException;
+import com.djrapitops.plan.data.store.containers.NetworkContainer;
import com.djrapitops.plan.system.info.server.ServerInfo;
import com.djrapitops.plan.system.locale.Locale;
import com.djrapitops.plan.system.locale.lang.PluginLang;
@@ -37,12 +38,13 @@ public class MySQLDB extends SQLDB {
Locale locale,
PlanConfig config,
Lazy serverInfo,
+ NetworkContainer.Factory networkContainerFactory,
RunnableFactory runnableFactory,
PluginLogger pluginLogger,
Timings timings,
ErrorHandler errorHandler
) {
- super(() -> serverInfo.get().getServerUUID(), locale, config, runnableFactory, pluginLogger, timings, errorHandler);
+ super(() -> serverInfo.get().getServerUUID(), locale, config, networkContainerFactory, runnableFactory, pluginLogger, timings, errorHandler);
}
private static synchronized void increment() {
diff --git a/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/SQLDB.java b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/SQLDB.java
index d0b9ea7e4..2ac8bf84c 100644
--- a/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/SQLDB.java
+++ b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/SQLDB.java
@@ -2,6 +2,7 @@ package com.djrapitops.plan.system.database.databases.sql;
import com.djrapitops.plan.api.exceptions.database.DBInitException;
import com.djrapitops.plan.api.exceptions.database.DBOpException;
+import com.djrapitops.plan.data.store.containers.NetworkContainer;
import com.djrapitops.plan.system.database.databases.Database;
import com.djrapitops.plan.system.database.databases.operation.*;
import com.djrapitops.plan.system.database.databases.sql.operation.*;
@@ -46,6 +47,7 @@ public abstract class SQLDB extends Database {
protected final Locale locale;
protected final PlanConfig config;
+ protected final NetworkContainer.Factory networkContainerFactory;
protected final RunnableFactory runnableFactory;
protected final PluginLogger logger;
protected final Timings timings;
@@ -81,7 +83,7 @@ public abstract class SQLDB extends Database {
Supplier serverUUIDSupplier,
Locale locale,
PlanConfig config,
- RunnableFactory runnableFactory,
+ NetworkContainer.Factory networkContainerFactory, RunnableFactory runnableFactory,
PluginLogger logger,
Timings timings,
ErrorHandler errorHandler
@@ -89,6 +91,7 @@ public abstract class SQLDB extends Database {
this.serverUUIDSupplier = serverUUIDSupplier;
this.locale = locale;
this.config = config;
+ this.networkContainerFactory = networkContainerFactory;
this.runnableFactory = runnableFactory;
this.logger = logger;
this.timings = timings;
@@ -471,4 +474,8 @@ public abstract class SQLDB extends Database {
public Supplier getServerUUIDSupplier() {
return serverUUIDSupplier;
}
+
+ public NetworkContainer.Factory getNetworkContainerFactory() {
+ return networkContainerFactory;
+ }
}
diff --git a/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/SQLiteDB.java b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/SQLiteDB.java
index 1cea2e22f..f3353d175 100644
--- a/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/SQLiteDB.java
+++ b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/SQLiteDB.java
@@ -1,6 +1,7 @@
package com.djrapitops.plan.system.database.databases.sql;
import com.djrapitops.plan.api.exceptions.database.DBInitException;
+import com.djrapitops.plan.data.store.containers.NetworkContainer;
import com.djrapitops.plan.system.file.PlanFiles;
import com.djrapitops.plan.system.info.server.ServerInfo;
import com.djrapitops.plan.system.locale.Locale;
@@ -17,6 +18,7 @@ import com.djrapitops.plugin.task.RunnableFactory;
import dagger.Lazy;
import javax.inject.Inject;
+import javax.inject.Singleton;
import java.io.File;
import java.sql.*;
import java.util.Objects;
@@ -36,12 +38,13 @@ public class SQLiteDB extends SQLDB {
Locale locale,
PlanConfig config,
Lazy serverInfo,
+ NetworkContainer.Factory networkContainerFactory,
RunnableFactory runnableFactory,
PluginLogger logger,
Timings timings,
ErrorHandler errorHandler
) {
- super(() -> serverInfo.get().getServerUUID(), locale, config, runnableFactory, logger, timings, errorHandler);
+ super(() -> serverInfo.get().getServerUUID(), locale, config, networkContainerFactory, runnableFactory, logger, timings, errorHandler);
dbName = databaseFile.getName();
this.databaseFile = databaseFile;
}
@@ -178,11 +181,13 @@ public class SQLiteDB extends SQLDB {
return Objects.hash(super.hashCode(), dbName);
}
+ @Singleton
public static class Factory {
private final Locale locale;
private final PlanConfig config;
private final Lazy serverInfo;
+ private final NetworkContainer.Factory networkContainerFactory;
private final RunnableFactory runnableFactory;
private final PluginLogger logger;
private final Timings timings;
@@ -195,6 +200,7 @@ public class SQLiteDB extends SQLDB {
PlanConfig config,
PlanFiles files,
Lazy serverInfo,
+ NetworkContainer.Factory networkContainerFactory,
RunnableFactory runnableFactory,
PluginLogger logger,
Timings timings,
@@ -204,6 +210,7 @@ public class SQLiteDB extends SQLDB {
this.config = config;
this.files = files;
this.serverInfo = serverInfo;
+ this.networkContainerFactory = networkContainerFactory;
this.runnableFactory = runnableFactory;
this.logger = logger;
this.timings = timings;
@@ -219,7 +226,11 @@ public class SQLiteDB extends SQLDB {
}
public SQLiteDB usingFile(File databaseFile) {
- return new SQLiteDB(databaseFile, locale, config, serverInfo, runnableFactory, logger, timings, errorHandler);
+ return new SQLiteDB(databaseFile,
+ locale, config, serverInfo,
+ networkContainerFactory,
+ runnableFactory, logger, timings, errorHandler
+ );
}
}
diff --git a/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/SpongeMySQLDB.java b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/SpongeMySQLDB.java
index 20e413209..e9a688e8b 100644
--- a/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/SpongeMySQLDB.java
+++ b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/SpongeMySQLDB.java
@@ -1,6 +1,7 @@
package com.djrapitops.plan.system.database.databases.sql;
import com.djrapitops.plan.api.exceptions.database.DBInitException;
+import com.djrapitops.plan.data.store.containers.NetworkContainer;
import com.djrapitops.plan.system.info.server.ServerInfo;
import com.djrapitops.plan.system.locale.Locale;
import com.djrapitops.plan.system.settings.Settings;
@@ -30,12 +31,13 @@ public class SpongeMySQLDB extends MySQLDB {
Locale locale,
PlanConfig config,
Lazy serverInfo,
+ NetworkContainer.Factory networkContainerFactory,
RunnableFactory runnableFactory,
PluginLogger pluginLogger,
Timings timings,
ErrorHandler errorHandler
) {
- super(locale, config, serverInfo, runnableFactory, pluginLogger, timings, errorHandler);
+ super(locale, config, serverInfo, networkContainerFactory, runnableFactory, pluginLogger, timings, errorHandler);
}
@Override
diff --git a/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/operation/SQLFetchOps.java b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/operation/SQLFetchOps.java
index 638190a91..6d0602e85 100644
--- a/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/operation/SQLFetchOps.java
+++ b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/operation/SQLFetchOps.java
@@ -24,7 +24,7 @@ public class SQLFetchOps extends SQLOps implements FetchOperations {
@Override
public NetworkContainer getNetworkContainer() {
- NetworkContainer networkContainer = new NetworkContainer(getBungeeServerContainer());
+ NetworkContainer networkContainer = db.getNetworkContainerFactory().forBungeeContainer(getBungeeServerContainer());
networkContainer.putSupplier(NetworkKeys.BUKKIT_SERVERS, () -> getBukkitServers().values());
return networkContainer;
}
diff --git a/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/tables/TPSTable.java b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/tables/TPSTable.java
index bf0b7fb6d..bc583183f 100644
--- a/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/tables/TPSTable.java
+++ b/Plan/src/main/java/com/djrapitops/plan/system/database/databases/sql/tables/TPSTable.java
@@ -304,9 +304,8 @@ public class TPSTable extends Table {
public Map> getPlayersOnlineForServers(Collection servers) {
WhereParser sqlParser = Select.from(tableName, Col.SERVER_ID, Col.DATE, Col.PLAYERS_ONLINE)
.where(Col.DATE.get() + ">" + (System.currentTimeMillis() - TimeAmount.WEEK.toMillis(2L)));
- String statementSelectServerID = serverTable.statementSelectServerID;
for (Server server : servers) {
- sqlParser.or(Col.SERVER_ID + "=" + statementSelectServerID.replace("?", server.getUuid().toString()));
+ sqlParser.or(Col.SERVER_ID + "=" + server.getId());
}
String sql = sqlParser.toString();
diff --git a/Plan/src/main/java/com/djrapitops/plan/utilities/html/structure/NetworkServerBox.java b/Plan/src/main/java/com/djrapitops/plan/utilities/html/structure/NetworkServerBox.java
index bf4e24270..824927c82 100644
--- a/Plan/src/main/java/com/djrapitops/plan/utilities/html/structure/NetworkServerBox.java
+++ b/Plan/src/main/java/com/djrapitops/plan/utilities/html/structure/NetworkServerBox.java
@@ -72,9 +72,11 @@ public class NetworkServerBox {
"" + onlineCount + " / " + maxCount + "
" +
"" +
"" +