mirror of
https://github.com/plan-player-analytics/Plan.git
synced 2025-03-09 13:19:07 +01:00
Fixing some new code smells:
Critical: - String literal duplication fixed in a few places - Cognitive complexity reduced in BooleanProviderValueGatherer Major: - Called Optional#isPresent before accessing value 16 instances in ProviderTransactions - private constructor to Extension tables - Missing deprecated tags to deprecated plugin tab stuff - Unused class variable removal - Throw dedicated exceptions in ServerServerInfo - Unused method removal Minor: - Renamed 'API' field to 'service' in ExtensionService - Unused variable removal
This commit is contained in:
parent
2d228dedea
commit
001b5a6cc7
@ -44,7 +44,7 @@ public interface ExtensionService {
|
||||
* @throws IllegalStateException If Plan is installed, but not enabled.
|
||||
*/
|
||||
static ExtensionService getInstance() {
|
||||
return Optional.ofNullable(ExtensionServiceHolder.API)
|
||||
return Optional.ofNullable(ExtensionServiceHolder.service)
|
||||
.orElseThrow(() -> new IllegalStateException("ExtensionService has not been initialised yet."));
|
||||
}
|
||||
|
||||
@ -69,14 +69,14 @@ public interface ExtensionService {
|
||||
void unregister(DataExtension extension);
|
||||
|
||||
class ExtensionServiceHolder {
|
||||
static ExtensionService API;
|
||||
static ExtensionService service;
|
||||
|
||||
private ExtensionServiceHolder() {
|
||||
/* Static variable holder */
|
||||
}
|
||||
|
||||
static void set(ExtensionService api) {
|
||||
ExtensionServiceHolder.API = api;
|
||||
static void set(ExtensionService service) {
|
||||
ExtensionServiceHolder.service = service;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -47,6 +47,8 @@ public final class ExtensionExtractor {
|
||||
private List<InvalidateMethod> invalidMethods;
|
||||
private MethodAnnotations methodAnnotations;
|
||||
|
||||
private static final String WAS_OVER_50_CHARACTERS = "' was over 50 characters.";
|
||||
|
||||
public ExtensionExtractor(DataExtension extension) {
|
||||
this.extension = extension;
|
||||
extensionName = extension.getClass().getSimpleName();
|
||||
@ -117,7 +119,7 @@ public final class ExtensionExtractor {
|
||||
|
||||
private void validateMethodAnnotationPropertyLength(String property, String name, int maxLength, Method method) {
|
||||
if (property.length() > maxLength) {
|
||||
warnings.add(extensionName + "." + method.getName() + " '" + name + "' was over 50 characters.");
|
||||
warnings.add(extensionName + "." + method.getName() + " '" + name + WAS_OVER_50_CHARACTERS);
|
||||
}
|
||||
}
|
||||
|
||||
@ -282,7 +284,7 @@ public final class ExtensionExtractor {
|
||||
|
||||
// Length restriction check
|
||||
if (tabName.length() > 50) {
|
||||
warnings.add(extensionName + " tabName '" + tabName + "' was over 50 characters.");
|
||||
warnings.add(extensionName + " tabName '" + tabName + WAS_OVER_50_CHARACTERS);
|
||||
}
|
||||
|
||||
tabInformation.add(tabInfo);
|
||||
@ -324,7 +326,7 @@ public final class ExtensionExtractor {
|
||||
|
||||
// Length restriction check
|
||||
if (methodName.length() > 50) {
|
||||
warnings.add(extensionName + " invalidated method '" + methodName + "' was over 50 characters.");
|
||||
warnings.add(extensionName + " invalidated method '" + methodName + WAS_OVER_50_CHARACTERS);
|
||||
}
|
||||
|
||||
invalidMethods.add(tabInfo);
|
||||
|
@ -32,6 +32,8 @@ public class Sql {
|
||||
public static final String LEFT_JOIN = " LEFT JOIN ";
|
||||
public static final String AND = " AND ";
|
||||
public static final String OR = " OR ";
|
||||
public static final String IS_NULL = " IS NULL";
|
||||
public static final String IS_NOT_NULL = " IS NOT NULL";
|
||||
|
||||
private Sql() {
|
||||
throw new IllegalStateException("Variable Class");
|
||||
|
@ -59,6 +59,10 @@ public class ExtensionIconTable {
|
||||
statement.setString(parameterIndex + 2, icon.getColor().name());
|
||||
}
|
||||
|
||||
private ExtensionIconTable() {
|
||||
/* Static information class */
|
||||
}
|
||||
|
||||
public static String createTableSQL(DBType dbType) {
|
||||
return CreateTableParser.create(TABLE_NAME, dbType)
|
||||
.column(ID, INT).primaryKey()
|
||||
|
@ -40,6 +40,10 @@ public class ExtensionPlayerValueTable {
|
||||
public static final String STRING_VALUE = "string_value";
|
||||
public static final String GROUP_VALUE = "group_value";
|
||||
|
||||
private ExtensionPlayerValueTable() {
|
||||
/* Static information class */
|
||||
}
|
||||
|
||||
public static String createTableSQL(DBType dbType) {
|
||||
return CreateTableParser.create(TABLE_NAME, dbType)
|
||||
.column(ID, Sql.INT).primaryKey()
|
||||
|
@ -51,6 +51,10 @@ public class ExtensionPluginTable {
|
||||
statement.setString(parameterIndex + 1, serverUUID.toString());
|
||||
}
|
||||
|
||||
private ExtensionPluginTable() {
|
||||
/* Static information class */
|
||||
}
|
||||
|
||||
public static String createTableSQL(DBType dbType) {
|
||||
return CreateTableParser.create(TABLE_NAME, dbType)
|
||||
.column(ID, INT).primaryKey()
|
||||
|
@ -60,6 +60,10 @@ public class ExtensionProviderTable {
|
||||
ExtensionPluginTable.set2PluginValuesToStatement(statement, parameterIndex + 1, pluginName, serverUUID);
|
||||
}
|
||||
|
||||
private ExtensionProviderTable() {
|
||||
/* Static information class */
|
||||
}
|
||||
|
||||
public static String createTableSQL(DBType dbType) {
|
||||
return CreateTableParser.create(TABLE_NAME, dbType)
|
||||
.column(ID, INT).primaryKey()
|
||||
|
@ -53,6 +53,10 @@ public class ExtensionTabTable {
|
||||
ExtensionPluginTable.set2PluginValuesToStatement(statement, parameterIndex + 1, pluginName, serverUUID);
|
||||
}
|
||||
|
||||
private ExtensionTabTable() {
|
||||
/* Static information class */
|
||||
}
|
||||
|
||||
public static String createTableSQL(DBType dbType) {
|
||||
return CreateTableParser.create(TABLE_NAME, dbType)
|
||||
.column(ID, INT).primaryKey()
|
||||
|
@ -69,45 +69,8 @@ class BooleanProviderValueGatherer {
|
||||
Set<DataProvider<Boolean>> satisfied = new HashSet<>();
|
||||
|
||||
do {
|
||||
// Clear conditions satisfied in previous loop
|
||||
satisfied.clear();
|
||||
// Loop through all unsatisfied providers to see if more conditions are satisfied
|
||||
for (DataProvider<Boolean> booleanProvider : unsatisifiedProviders) {
|
||||
ProviderInformation providerInformation = booleanProvider.getProviderInformation();
|
||||
|
||||
Optional<String> condition = providerInformation.getCondition();
|
||||
if (condition.isPresent() && conditions.isNotFulfilled(condition.get())) {
|
||||
continue;
|
||||
}
|
||||
|
||||
Optional<String> providedCondition = BooleanDataProvider.getProvidedCondition(booleanProvider);
|
||||
boolean hidden = BooleanDataProvider.isHidden(booleanProvider);
|
||||
|
||||
MethodWrapper<Boolean> method = booleanProvider.getMethod();
|
||||
Boolean result = getMethodResult(
|
||||
() -> method.callMethod(extension, playerUUID, playerName),
|
||||
throwable -> pluginName + " has invalid implementation, method " + method.getMethodName() + " threw exception: " + throwable.toString()
|
||||
);
|
||||
if (result == null) {
|
||||
satisfied.add(booleanProvider); // Prevents further attempts to call this provider for this player.
|
||||
continue;
|
||||
}
|
||||
|
||||
if (providedCondition.isPresent()) {
|
||||
if (result) {
|
||||
// The condition was fulfilled (true) for this player.
|
||||
conditions.conditionFulfilled(providedCondition.get());
|
||||
} else {
|
||||
// The negated condition was fulfilled (false) for this player.
|
||||
conditions.conditionFulfilled("not_" + providedCondition.get());
|
||||
}
|
||||
}
|
||||
|
||||
satisfied.add(booleanProvider); // Prevents further attempts to call this provider for this player.
|
||||
database.executeTransaction(new StoreIconTransaction(providerInformation.getIcon()));
|
||||
database.executeTransaction(new StoreBooleanProviderTransaction(booleanProvider, providedCondition.orElse(null), hidden, serverUUID));
|
||||
database.executeTransaction(new StorePlayerBooleanResultTransaction(pluginName, serverUUID, method.getMethodName(), playerUUID, result));
|
||||
}
|
||||
satisfied = attemptToSatisfyMoreConditionsAndStoreResults(playerUUID, playerName, conditions, unsatisifiedProviders);
|
||||
// Remove now satisfied Providers so that they are not called again
|
||||
unsatisifiedProviders.removeAll(satisfied);
|
||||
// If no new conditions could be satisfied, stop looping.
|
||||
@ -116,6 +79,49 @@ class BooleanProviderValueGatherer {
|
||||
return conditions;
|
||||
}
|
||||
|
||||
private Set<DataProvider<Boolean>> attemptToSatisfyMoreConditionsAndStoreResults(UUID playerUUID, String playerName, Conditions conditions, List<DataProvider<Boolean>> unsatisifiedProviders) {
|
||||
Set<DataProvider<Boolean>> satisfied = new HashSet<>();
|
||||
for (DataProvider<Boolean> booleanProvider : unsatisifiedProviders) {
|
||||
ProviderInformation providerInformation = booleanProvider.getProviderInformation();
|
||||
|
||||
Optional<String> condition = providerInformation.getCondition();
|
||||
if (condition.isPresent() && conditions.isNotFulfilled(condition.get())) {
|
||||
// Condition required by the BooleanProvider is not satisfied
|
||||
continue;
|
||||
}
|
||||
|
||||
Optional<String> providedCondition = BooleanDataProvider.getProvidedCondition(booleanProvider);
|
||||
boolean hidden = BooleanDataProvider.isHidden(booleanProvider);
|
||||
|
||||
MethodWrapper<Boolean> method = booleanProvider.getMethod();
|
||||
Boolean result = getMethodResult(
|
||||
() -> method.callMethod(extension, playerUUID, playerName),
|
||||
throwable -> pluginName + " has invalid implementation, method " + method.getMethodName() + " threw exception: " + throwable.toString()
|
||||
);
|
||||
if (result == null) {
|
||||
// Error during method call
|
||||
satisfied.add(booleanProvider); // Prevents further attempts to call this provider for this player.
|
||||
continue;
|
||||
}
|
||||
|
||||
if (providedCondition.isPresent()) {
|
||||
if (result) {
|
||||
// The condition was fulfilled (true) for this player.
|
||||
conditions.conditionFulfilled(providedCondition.get());
|
||||
} else {
|
||||
// The negated condition was fulfilled (false) for this player.
|
||||
conditions.conditionFulfilled("not_" + providedCondition.get());
|
||||
}
|
||||
}
|
||||
|
||||
satisfied.add(booleanProvider); // Prevents further attempts to call this provider for this player.
|
||||
database.executeTransaction(new StoreIconTransaction(providerInformation.getIcon()));
|
||||
database.executeTransaction(new StoreBooleanProviderTransaction(booleanProvider, providedCondition.orElse(null), hidden, serverUUID));
|
||||
database.executeTransaction(new StorePlayerBooleanResultTransaction(pluginName, serverUUID, method.getMethodName(), playerUUID, result));
|
||||
}
|
||||
return satisfied;
|
||||
}
|
||||
|
||||
private <T> T getMethodResult(Callable<T> callable, Function<Throwable, String> errorMsg) {
|
||||
try {
|
||||
return callable.call();
|
||||
|
@ -28,6 +28,7 @@ import com.djrapitops.plan.extension.implementation.providers.DataProvider;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.SQLException;
|
||||
import java.sql.Types;
|
||||
import java.util.Optional;
|
||||
import java.util.UUID;
|
||||
|
||||
import static com.djrapitops.plan.db.sql.parsing.Sql.AND;
|
||||
@ -85,14 +86,16 @@ public class StoreBooleanProviderTransaction extends Transaction {
|
||||
@Override
|
||||
public void prepare(PreparedStatement statement) throws SQLException {
|
||||
statement.setString(1, providerInformation.getText());
|
||||
if (providerInformation.getDescription().isPresent()) {
|
||||
statement.setString(2, providerInformation.getDescription().get());
|
||||
Optional<String> description = providerInformation.getDescription();
|
||||
if (description.isPresent()) {
|
||||
statement.setString(2, description.get());
|
||||
} else {
|
||||
statement.setNull(2, Types.VARCHAR);
|
||||
}
|
||||
statement.setInt(3, providerInformation.getPriority());
|
||||
if (providerInformation.getCondition().isPresent()) {
|
||||
statement.setString(4, providerInformation.getCondition().orElse(null));
|
||||
Optional<String> condition = providerInformation.getCondition();
|
||||
if (condition.isPresent()) {
|
||||
statement.setString(4, condition.get());
|
||||
} else {
|
||||
statement.setNull(4, Types.VARCHAR);
|
||||
}
|
||||
@ -130,14 +133,16 @@ public class StoreBooleanProviderTransaction extends Transaction {
|
||||
public void prepare(PreparedStatement statement) throws SQLException {
|
||||
statement.setString(1, providerInformation.getName());
|
||||
statement.setString(2, providerInformation.getText());
|
||||
if (providerInformation.getDescription().isPresent()) {
|
||||
statement.setString(3, providerInformation.getDescription().get());
|
||||
Optional<String> description = providerInformation.getDescription();
|
||||
if (description.isPresent()) {
|
||||
statement.setString(3, description.get());
|
||||
} else {
|
||||
statement.setNull(3, Types.VARCHAR);
|
||||
}
|
||||
statement.setInt(4, providerInformation.getPriority());
|
||||
if (providerInformation.getCondition().isPresent()) {
|
||||
statement.setString(5, providerInformation.getCondition().orElse(null));
|
||||
Optional<String> condition = providerInformation.getCondition();
|
||||
if (condition.isPresent()) {
|
||||
statement.setString(5, condition.get());
|
||||
} else {
|
||||
statement.setNull(5, Types.VARCHAR);
|
||||
}
|
||||
|
@ -28,6 +28,7 @@ import com.djrapitops.plan.extension.implementation.providers.DataProvider;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.SQLException;
|
||||
import java.sql.Types;
|
||||
import java.util.Optional;
|
||||
import java.util.UUID;
|
||||
|
||||
import static com.djrapitops.plan.db.sql.parsing.Sql.AND;
|
||||
@ -83,14 +84,16 @@ public class StoreDoubleProviderTransaction extends Transaction {
|
||||
@Override
|
||||
public void prepare(PreparedStatement statement) throws SQLException {
|
||||
statement.setString(1, providerInformation.getText());
|
||||
if (providerInformation.getDescription().isPresent()) {
|
||||
statement.setString(2, providerInformation.getDescription().get());
|
||||
Optional<String> description = providerInformation.getDescription();
|
||||
if (description.isPresent()) {
|
||||
statement.setString(2, description.get());
|
||||
} else {
|
||||
statement.setNull(2, Types.VARCHAR);
|
||||
}
|
||||
statement.setInt(3, providerInformation.getPriority());
|
||||
if (providerInformation.getCondition().isPresent()) {
|
||||
statement.setString(4, providerInformation.getCondition().orElse(null));
|
||||
Optional<String> condition = providerInformation.getCondition();
|
||||
if (condition.isPresent()) {
|
||||
statement.setString(4, condition.get());
|
||||
} else {
|
||||
statement.setNull(4, Types.VARCHAR);
|
||||
}
|
||||
@ -121,14 +124,16 @@ public class StoreDoubleProviderTransaction extends Transaction {
|
||||
public void prepare(PreparedStatement statement) throws SQLException {
|
||||
statement.setString(1, providerInformation.getName());
|
||||
statement.setString(2, providerInformation.getText());
|
||||
if (providerInformation.getDescription().isPresent()) {
|
||||
statement.setString(3, providerInformation.getDescription().get());
|
||||
Optional<String> description = providerInformation.getDescription();
|
||||
if (description.isPresent()) {
|
||||
statement.setString(3, description.get());
|
||||
} else {
|
||||
statement.setNull(3, Types.VARCHAR);
|
||||
}
|
||||
statement.setInt(4, providerInformation.getPriority());
|
||||
if (providerInformation.getCondition().isPresent()) {
|
||||
statement.setString(5, providerInformation.getCondition().get());
|
||||
Optional<String> condition = providerInformation.getCondition();
|
||||
if (condition.isPresent()) {
|
||||
statement.setString(5, condition.get());
|
||||
} else {
|
||||
statement.setNull(5, Types.VARCHAR);
|
||||
}
|
||||
|
@ -29,6 +29,7 @@ import com.djrapitops.plan.extension.implementation.providers.DataProvider;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.SQLException;
|
||||
import java.sql.Types;
|
||||
import java.util.Optional;
|
||||
import java.util.UUID;
|
||||
|
||||
import static com.djrapitops.plan.db.sql.parsing.Sql.AND;
|
||||
@ -83,14 +84,16 @@ public class StoreNumberProviderTransaction extends Transaction {
|
||||
@Override
|
||||
public void prepare(PreparedStatement statement) throws SQLException {
|
||||
statement.setString(1, providerInformation.getText());
|
||||
if (providerInformation.getDescription().isPresent()) {
|
||||
statement.setString(2, providerInformation.getDescription().get());
|
||||
Optional<String> description = providerInformation.getDescription();
|
||||
if (description.isPresent()) {
|
||||
statement.setString(2, description.get());
|
||||
} else {
|
||||
statement.setNull(2, Types.VARCHAR);
|
||||
}
|
||||
statement.setInt(3, providerInformation.getPriority());
|
||||
if (providerInformation.getCondition().isPresent()) {
|
||||
statement.setString(4, providerInformation.getCondition().orElse(null));
|
||||
Optional<String> condition = providerInformation.getCondition();
|
||||
if (condition.isPresent()) {
|
||||
statement.setString(4, condition.get());
|
||||
} else {
|
||||
statement.setNull(4, Types.VARCHAR);
|
||||
}
|
||||
@ -123,14 +126,16 @@ public class StoreNumberProviderTransaction extends Transaction {
|
||||
public void prepare(PreparedStatement statement) throws SQLException {
|
||||
statement.setString(1, providerInformation.getName());
|
||||
statement.setString(2, providerInformation.getText());
|
||||
if (providerInformation.getDescription().isPresent()) {
|
||||
statement.setString(3, providerInformation.getDescription().get());
|
||||
Optional<String> description = providerInformation.getDescription();
|
||||
if (description.isPresent()) {
|
||||
statement.setString(3, description.get());
|
||||
} else {
|
||||
statement.setNull(3, Types.VARCHAR);
|
||||
}
|
||||
statement.setInt(4, providerInformation.getPriority());
|
||||
if (providerInformation.getCondition().isPresent()) {
|
||||
statement.setString(5, providerInformation.getCondition().orElse(null));
|
||||
Optional<String> condition = providerInformation.getCondition();
|
||||
if (condition.isPresent()) {
|
||||
statement.setString(5, condition.get());
|
||||
} else {
|
||||
statement.setNull(5, Types.VARCHAR);
|
||||
}
|
||||
|
@ -28,6 +28,7 @@ import com.djrapitops.plan.extension.implementation.providers.DataProvider;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.SQLException;
|
||||
import java.sql.Types;
|
||||
import java.util.Optional;
|
||||
import java.util.UUID;
|
||||
|
||||
import static com.djrapitops.plan.db.sql.parsing.Sql.AND;
|
||||
@ -82,14 +83,16 @@ public class StoreStringProviderTransaction extends Transaction {
|
||||
@Override
|
||||
public void prepare(PreparedStatement statement) throws SQLException {
|
||||
statement.setString(1, providerInformation.getText());
|
||||
if (providerInformation.getDescription().isPresent()) {
|
||||
statement.setString(2, providerInformation.getDescription().get());
|
||||
Optional<String> description = providerInformation.getDescription();
|
||||
if (description.isPresent()) {
|
||||
statement.setString(2, description.get());
|
||||
} else {
|
||||
statement.setNull(2, Types.VARCHAR);
|
||||
}
|
||||
statement.setInt(3, providerInformation.getPriority());
|
||||
if (providerInformation.getCondition().isPresent()) {
|
||||
statement.setString(4, providerInformation.getCondition().orElse(null));
|
||||
Optional<String> condition = providerInformation.getCondition();
|
||||
if (condition.isPresent()) {
|
||||
statement.setString(4, condition.get());
|
||||
} else {
|
||||
statement.setNull(4, Types.VARCHAR);
|
||||
}
|
||||
@ -122,14 +125,16 @@ public class StoreStringProviderTransaction extends Transaction {
|
||||
public void prepare(PreparedStatement statement) throws SQLException {
|
||||
statement.setString(1, providerInformation.getName());
|
||||
statement.setString(2, providerInformation.getText());
|
||||
if (providerInformation.getDescription().isPresent()) {
|
||||
statement.setString(3, providerInformation.getDescription().get());
|
||||
Optional<String> description = providerInformation.getDescription();
|
||||
if (description.isPresent()) {
|
||||
statement.setString(3, description.get());
|
||||
} else {
|
||||
statement.setNull(3, Types.VARCHAR);
|
||||
}
|
||||
statement.setInt(4, providerInformation.getPriority());
|
||||
if (providerInformation.getCondition().isPresent()) {
|
||||
statement.setString(5, providerInformation.getCondition().orElse(null));
|
||||
Optional<String> condition = providerInformation.getCondition();
|
||||
if (condition.isPresent()) {
|
||||
statement.setString(5, condition.get());
|
||||
} else {
|
||||
statement.setNull(5, Types.VARCHAR);
|
||||
}
|
||||
|
@ -58,14 +58,14 @@ public class RemoveUnsatisfiedConditionalResultsTransaction extends Transaction
|
||||
FROM + providerTable +
|
||||
INNER_JOIN + playerValueTable + " on " + providerTable + '.' + ExtensionProviderTable.ID + "=" + ExtensionPlayerValueTable.PROVIDER_ID +
|
||||
WHERE + ExtensionPlayerValueTable.BOOLEAN_VALUE + "=?" +
|
||||
AND + ExtensionProviderTable.PROVIDED_CONDITION + " IS NOT NULL";
|
||||
AND + ExtensionProviderTable.PROVIDED_CONDITION + IS_NOT_NULL;
|
||||
String selectSatisfiedNegativeConditions = SELECT +
|
||||
reversedCondition + " as " + ExtensionProviderTable.PROVIDED_CONDITION + ',' +
|
||||
ExtensionPlayerValueTable.USER_UUID +
|
||||
FROM + providerTable +
|
||||
INNER_JOIN + playerValueTable + " on " + providerTable + '.' + ExtensionProviderTable.ID + "=" + ExtensionPlayerValueTable.PROVIDER_ID +
|
||||
WHERE + ExtensionPlayerValueTable.BOOLEAN_VALUE + "=?" +
|
||||
AND + ExtensionProviderTable.PROVIDED_CONDITION + " IS NOT NULL";
|
||||
AND + ExtensionProviderTable.PROVIDED_CONDITION + IS_NOT_NULL;
|
||||
|
||||
// Query contents: Set of provided_conditions
|
||||
String selectSatisfiedConditions = '(' + selectSatisfiedPositiveConditions + " UNION " + selectSatisfiedNegativeConditions + ") q1";
|
||||
@ -88,8 +88,8 @@ public class RemoveUnsatisfiedConditionalResultsTransaction extends Transaction
|
||||
AND + ExtensionProviderTable.CONDITION +
|
||||
"=q1." + ExtensionProviderTable.PROVIDED_CONDITION +
|
||||
')' +
|
||||
WHERE + "q1." + ExtensionProviderTable.PROVIDED_CONDITION + " IS NULL" + // Conditions that were not in the satisfied condition query
|
||||
AND + ExtensionProviderTable.CONDITION + " IS NOT NULL"; // Ignore values that don't need condition
|
||||
WHERE + "q1." + ExtensionProviderTable.PROVIDED_CONDITION + IS_NULL + // Conditions that were not in the satisfied condition query
|
||||
AND + ExtensionProviderTable.CONDITION + IS_NOT_NULL; // Ignore values that don't need condition
|
||||
|
||||
// Nested query here is required because MySQL limits update statements with nested queries:
|
||||
// The nested query creates a temporary table that bypasses the same table query-update limit.
|
||||
|
@ -18,7 +18,6 @@ package com.djrapitops.plan.system.info.request;
|
||||
|
||||
import com.djrapitops.plan.api.exceptions.connection.BadRequestException;
|
||||
import com.djrapitops.plan.api.exceptions.connection.WebException;
|
||||
import com.djrapitops.plan.system.info.server.ServerInfo;
|
||||
import com.djrapitops.plan.system.webserver.cache.PageId;
|
||||
import com.djrapitops.plan.system.webserver.cache.ResponseCache;
|
||||
import com.djrapitops.plan.system.webserver.response.DefaultResponses;
|
||||
@ -33,23 +32,19 @@ import java.util.UUID;
|
||||
/**
|
||||
* InfoRequest used to place HTML of player's Plugins Tab to ResponseCache.
|
||||
*
|
||||
* @deprecated Marked for removal when the connection system will be removed.
|
||||
* @author Rsl1122
|
||||
*/
|
||||
@Deprecated
|
||||
public class CacheInspectPluginsTabRequest extends InfoRequestWithVariables implements CacheRequest {
|
||||
|
||||
private final ServerInfo serverInfo;
|
||||
|
||||
private UUID player;
|
||||
private String html;
|
||||
|
||||
CacheInspectPluginsTabRequest(ServerInfo serverInfo) {
|
||||
this.serverInfo = serverInfo;
|
||||
CacheInspectPluginsTabRequest() {
|
||||
}
|
||||
|
||||
CacheInspectPluginsTabRequest(UUID player, String nav, String html, ServerInfo serverInfo) {
|
||||
this.serverInfo = serverInfo;
|
||||
|
||||
CacheInspectPluginsTabRequest(UUID player, String nav, String html) {
|
||||
Verify.nullCheck(player, nav);
|
||||
variables.put("player", player.toString());
|
||||
variables.put("nav", nav);
|
||||
@ -65,7 +60,6 @@ public class CacheInspectPluginsTabRequest extends InfoRequestWithVariables impl
|
||||
String player = variables.get("player");
|
||||
Verify.nullCheck(player, () -> new BadRequestException("Player UUID 'player' variable not supplied in the request."));
|
||||
UUID uuid = UUID.fromString(player);
|
||||
UUID serverUUID = UUID.fromString(variables.get("sender"));
|
||||
|
||||
String nav = variables.get("nav");
|
||||
String html = variables.get("html");
|
||||
|
@ -30,6 +30,7 @@ import java.util.UUID;
|
||||
/**
|
||||
* InfoRequest for Generating Inspect page plugins tab on receiving WebServer.
|
||||
*
|
||||
* @deprecated Marked for removal when the connection system will be removed.
|
||||
* @author Rsl1122
|
||||
*/
|
||||
@Deprecated
|
||||
|
@ -107,7 +107,7 @@ public class InfoRequestFactory {
|
||||
}
|
||||
|
||||
public CacheRequest cacheInspectPluginsTabRequest(UUID uuid, String nav, String html) {
|
||||
return new CacheInspectPluginsTabRequest(uuid, nav, html, serverInfo.get());
|
||||
return new CacheInspectPluginsTabRequest(uuid, nav, html);
|
||||
}
|
||||
|
||||
public GenerateRequest generateAnalysisPageRequest(UUID serverUUID) {
|
||||
@ -165,7 +165,7 @@ public class InfoRequestFactory {
|
||||
}
|
||||
|
||||
CacheRequest cacheInspectPluginsTabRequest() {
|
||||
return new CacheInspectPluginsTabRequest(factory.serverInfo.get());
|
||||
return new CacheInspectPluginsTabRequest();
|
||||
}
|
||||
|
||||
CheckConnectionRequest checkConnectionRequest() {
|
||||
|
@ -93,7 +93,7 @@ public class ServerServerInfo extends ServerInfo {
|
||||
}
|
||||
}
|
||||
|
||||
private Server updateDbInfo(UUID serverUUID) throws Exception {
|
||||
private Server updateDbInfo(UUID serverUUID) throws InterruptedException, ExecutionException, IOException {
|
||||
Database db = dbSystem.getDatabase();
|
||||
|
||||
Optional<Server> foundServer = db.query(ServerQueries.fetchServerMatchingIdentifier(serverUUID));
|
||||
|
@ -49,10 +49,6 @@ public class InspectPageResponse extends PageResponse {
|
||||
return StringSubstitutor.replace(super.getContent(), replaceMap);
|
||||
}
|
||||
|
||||
private String[] getCalculating() {
|
||||
return new String[]{"<li><i class=\"fa fa-spin fa-refresh\"></i><a> Calculating...</a></li>", ""};
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
|
@ -33,6 +33,7 @@ import java.util.*;
|
||||
* <p>
|
||||
* Extends Response so that it can be stored in ResponseCache.
|
||||
*
|
||||
* @deprecated Marked for removal when the connection system will be removed.
|
||||
* @author Rsl1122
|
||||
*/
|
||||
@Deprecated
|
||||
|
@ -38,7 +38,7 @@ import java.util.*;
|
||||
public class InspectPluginTab implements Comparable<InspectPluginTab> {
|
||||
|
||||
private String serverName;
|
||||
private List<ExtensionPlayerData> data;
|
||||
private List<ExtensionPlayerData> playerData;
|
||||
|
||||
private Map<FormatType, Formatter<Long>> numberFormatters;
|
||||
|
||||
@ -55,11 +55,11 @@ public class InspectPluginTab implements Comparable<InspectPluginTab> {
|
||||
|
||||
public InspectPluginTab(
|
||||
String serverName,
|
||||
List<ExtensionPlayerData> data,
|
||||
List<ExtensionPlayerData> playerData,
|
||||
Formatters formatters
|
||||
) {
|
||||
this.serverName = serverName;
|
||||
this.data = data;
|
||||
this.playerData = playerData;
|
||||
|
||||
numberFormatters = new EnumMap<>(FormatType.class);
|
||||
numberFormatters.put(FormatType.DATE_SECOND, formatters.secondLong());
|
||||
@ -82,7 +82,7 @@ public class InspectPluginTab implements Comparable<InspectPluginTab> {
|
||||
}
|
||||
|
||||
private void generate() {
|
||||
if (data.isEmpty()) {
|
||||
if (playerData.isEmpty()) {
|
||||
nav = "<li><a class=\"nav-button\" href=\"javascript:void(0)\">" + serverName + " (No Data)</a></li>";
|
||||
tab = "<div class=\"tab\"><div class=\"row clearfix\">" +
|
||||
"<div class=\"col-md-12\">" + Html.CARD.parse("<p>No Data (" + serverName + ")</p>") +
|
||||
@ -94,11 +94,11 @@ public class InspectPluginTab implements Comparable<InspectPluginTab> {
|
||||
}
|
||||
|
||||
private String generatePageTab() {
|
||||
Collections.sort(data);
|
||||
Collections.sort(playerData);
|
||||
|
||||
StringBuilder tabBuilder = new StringBuilder();
|
||||
|
||||
for (ExtensionPlayerData datum : data) {
|
||||
for (ExtensionPlayerData datum : playerData) {
|
||||
ExtensionInformation extensionInformation = datum.getExtensionInformation();
|
||||
|
||||
boolean onlyGeneric = datum.hasOnlyGenericTab();
|
||||
@ -161,6 +161,20 @@ public class InspectPluginTab implements Comparable<InspectPluginTab> {
|
||||
"</div></div>";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (!(o instanceof InspectPluginTab)) return false;
|
||||
InspectPluginTab that = (InspectPluginTab) o;
|
||||
return Objects.equals(serverName, that.serverName) &&
|
||||
Objects.equals(nav, that.nav);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(serverName, nav);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compareTo(InspectPluginTab other) {
|
||||
return String.CASE_INSENSITIVE_ORDER.compare(this.serverName, other.serverName);
|
||||
|
@ -178,6 +178,9 @@ public class PageFactory {
|
||||
return new InspectPluginTab(navs.toString(), tabs.toString());
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated Marked for removal when the connection system will be removed.
|
||||
*/
|
||||
@Deprecated
|
||||
public InspectPagePluginsContent inspectPagePluginsContent(UUID playerUUID) {
|
||||
return InspectPagePluginsContent.generateForThisServer(playerUUID, serverInfo.get(), hookHandler.get());
|
||||
|
Loading…
Reference in New Issue
Block a user