diff --git a/Plan/bukkit/src/main/java/com/djrapitops/plan/system/importing/importers/BukkitImporter.java b/Plan/bukkit/src/main/java/com/djrapitops/plan/system/importing/importers/BukkitImporter.java index 8c5ff8f60..f387b3a80 100644 --- a/Plan/bukkit/src/main/java/com/djrapitops/plan/system/importing/importers/BukkitImporter.java +++ b/Plan/bukkit/src/main/java/com/djrapitops/plan/system/importing/importers/BukkitImporter.java @@ -175,11 +175,11 @@ public abstract class BukkitImporter implements Importer { } private BaseUser toBaseUser(UserImportData userImportData) { - UUID uuid = userImportData.getUuid(); - String name = userImportData.getName(); + UUID playerUUID = userImportData.getUuid(); + String playerName = userImportData.getName(); long registered = userImportData.getRegistered(); int timesKicked = userImportData.getTimesKicked(); - return new BaseUser(uuid, name, registered, timesKicked); + return new BaseUser(playerUUID, playerName, registered, timesKicked); } private UserInfo toUserInfo(UserImportData userImportData) { diff --git a/Plan/bukkit/src/main/java/com/djrapitops/plan/utilities/java/Reflection.java b/Plan/bukkit/src/main/java/com/djrapitops/plan/utilities/java/Reflection.java index 1372a529d..b1a143beb 100644 --- a/Plan/bukkit/src/main/java/com/djrapitops/plan/utilities/java/Reflection.java +++ b/Plan/bukkit/src/main/java/com/djrapitops/plan/utilities/java/Reflection.java @@ -122,7 +122,7 @@ public final class Reflection { try { return (T) field.get(target); } catch (IllegalAccessException e) { - throw new RuntimeException("Cannot access reflection.", e); + throw new IllegalStateException("Cannot access reflection.", e); } } @@ -131,7 +131,7 @@ public final class Reflection { try { field.set(target, value); } catch (IllegalAccessException e) { - throw new RuntimeException("Cannot access reflection.", e); + throw new IllegalStateException("Cannot access reflection.", e); } } @@ -197,7 +197,7 @@ public final class Reflection { try { return method.invoke(target, arguments); } catch (Exception e) { - throw new RuntimeException("Cannot invoke method " + method, e); + throw new IllegalStateException("Cannot invoke method " + method, e); } }; } @@ -240,7 +240,7 @@ public final class Reflection { try { return constructor.newInstance(arguments); } catch (Exception e) { - throw new RuntimeException("Cannot invoke constructor " + constructor, e); + throw new IllegalStateException("Cannot invoke constructor " + constructor, e); } }; } diff --git a/Plan/bungeecord/src/test/java/com/djrapitops/plan/BungeeSystemTest.java b/Plan/bungeecord/src/test/java/com/djrapitops/plan/BungeeSystemTest.java index 07cf69a24..52bf7e5b6 100644 --- a/Plan/bungeecord/src/test/java/com/djrapitops/plan/BungeeSystemTest.java +++ b/Plan/bungeecord/src/test/java/com/djrapitops/plan/BungeeSystemTest.java @@ -69,6 +69,7 @@ public class BungeeSystemTest { dbSystem.setActiveDatabase(db); bungeeSystem.enable(); + assertTrue(bungeeSystem.isEnabled()); } finally { bungeeSystem.disable(); } @@ -90,8 +91,7 @@ public class BungeeSystemTest { db.setTransactionExecutorServiceProvider(MoreExecutors::newDirectExecutorService); dbSystem.setActiveDatabase(db); - bungeeSystem.enable(); - assertTrue(bungeeSystem.isEnabled()); + bungeeSystem.enable(); // Throws EnableException } finally { bungeeSystem.disable(); } @@ -107,7 +107,7 @@ public class BungeeSystemTest { config.set(WebserverSettings.PORT, TEST_PORT_NUMBER); config.set(ProxySettings.IP, "8.8.8.8"); - bungeeSystem.enable(); + bungeeSystem.enable(); // Throws EnableException } finally { bungeeSystem.disable(); } diff --git a/Plan/common/src/main/java/com/djrapitops/plan/command/commands/manage/ManageDisableCommand.java b/Plan/common/src/main/java/com/djrapitops/plan/command/commands/manage/ManageDisableCommand.java index 30ab4d9b5..913c32886 100644 --- a/Plan/common/src/main/java/com/djrapitops/plan/command/commands/manage/ManageDisableCommand.java +++ b/Plan/common/src/main/java/com/djrapitops/plan/command/commands/manage/ManageDisableCommand.java @@ -60,7 +60,7 @@ public class ManageDisableCommand extends CommandNode { Verify.isTrue(args.length >= 1, () -> new IllegalArgumentException(locale.getString(CommandLang.FAIL_REQ_ONE_ARG, Arrays.toString(this.getArguments())))); - if ("kickcount".equals(args[0].toLowerCase())) { + if ("kickcount".equalsIgnoreCase(args[0])) { status.setCountKicks(false); sender.sendMessage(locale.getString(CommandLang.FEATURE_DISABLED, "Kick Counting")); } else { diff --git a/Plan/common/src/main/java/com/djrapitops/plan/data/element/TableContainer.java b/Plan/common/src/main/java/com/djrapitops/plan/data/element/TableContainer.java index 8adde4ffc..d4bf8046c 100644 --- a/Plan/common/src/main/java/com/djrapitops/plan/data/element/TableContainer.java +++ b/Plan/common/src/main/java/com/djrapitops/plan/data/element/TableContainer.java @@ -92,10 +92,7 @@ public class TableContainer { if (i > maxIndex) { body.append("-"); } else { - Serializable value = row[i]; - Formatter formatter = formatters[i]; - body.append("" : ">"); - body.append(formatter != null ? formatter.apply(value) : (value != null ? value : '-')); + appendValue(body, row[i], formatters[i]); } body.append(""); } catch (ClassCastException | ArrayIndexOutOfBoundsException e) { @@ -105,6 +102,15 @@ public class TableContainer { body.append(""); } + private void appendValue(StringBuilder body, Serializable value, Formatter formatter) { + body.append("" : ">"); + if (formatter != null) { + body.append(formatter.apply(value)); + } else { + body.append(value != null ? value : '-'); + } + } + public final void setColor(String color) { this.color = color; } diff --git a/Plan/common/src/main/java/com/djrapitops/plan/data/store/mutators/health/AbstractHealthInfo.java b/Plan/common/src/main/java/com/djrapitops/plan/data/store/mutators/health/AbstractHealthInfo.java index e6f38111d..ce42de3ed 100644 --- a/Plan/common/src/main/java/com/djrapitops/plan/data/store/mutators/health/AbstractHealthInfo.java +++ b/Plan/common/src/main/java/com/djrapitops/plan/data/store/mutators/health/AbstractHealthInfo.java @@ -29,7 +29,7 @@ import java.util.concurrent.TimeUnit; public abstract class AbstractHealthInfo { - protected final String subNote = "
     "; + protected static final String SUB_NOTE = "
     "; protected final List notes; protected final long now; @@ -109,7 +109,7 @@ public abstract class AbstractHealthInfo { StringBuilder remainNote = new StringBuilder(); if (activeFWAGNum != 0) { - remainNote.append(subNote); + remainNote.append(SUB_NOTE); if (percRemain > 0.5) { remainNote.append(Icons.GREEN_THUMB); } else if (percRemain > 0.2) { diff --git a/Plan/common/src/main/java/com/djrapitops/plan/data/store/mutators/health/HealthInformation.java b/Plan/common/src/main/java/com/djrapitops/plan/data/store/mutators/health/HealthInformation.java index 63b440403..ea79c05a4 100644 --- a/Plan/common/src/main/java/com/djrapitops/plan/data/store/mutators/health/HealthInformation.java +++ b/Plan/common/src/main/java/com/djrapitops/plan/data/store/mutators/health/HealthInformation.java @@ -124,7 +124,7 @@ public class HealthInformation extends AbstractHealthInfo { double aboveThreshold = tpsMutator.percentageTPSAboveThreshold(lowTPSThreshold); long tpsSpikeMonth = analysisContainer.getValue(AnalysisKeys.TPS_SPIKE_MONTH).orElse(0); - StringBuilder avgLowThresholdString = new StringBuilder(subNote); + StringBuilder avgLowThresholdString = new StringBuilder(SUB_NOTE); if (aboveThreshold >= 0.96) { avgLowThresholdString.append(Icons.GREEN_THUMB); } else if (aboveThreshold >= 0.9) { diff --git a/Plan/common/src/main/java/com/djrapitops/plan/data/store/mutators/health/NetworkHealthInformation.java b/Plan/common/src/main/java/com/djrapitops/plan/data/store/mutators/health/NetworkHealthInformation.java index 8e4f0f6e5..db50e1b8c 100644 --- a/Plan/common/src/main/java/com/djrapitops/plan/data/store/mutators/health/NetworkHealthInformation.java +++ b/Plan/common/src/main/java/com/djrapitops/plan/data/store/mutators/health/NetworkHealthInformation.java @@ -112,7 +112,7 @@ public class NetworkHealthInformation extends AbstractHealthInfo { .map(c -> { int playersPerMonth = c.getUnsafe(AnalysisKeys.AVG_PLAYERS_MONTH); Server server = c.getUnsafe(serverKey); - return subNote + (playersPerMonth >= average && playersPerMonth > 0 ? Icons.GREEN_PLUS : Icons.RED_MINUS) + " " + + return SUB_NOTE + (playersPerMonth >= average && playersPerMonth > 0 ? Icons.GREEN_PLUS : Icons.RED_MINUS) + " " + server.getName() + ": " + playersPerMonth; }).forEach(subNotes::append); addNote(icon + " " + decimalFormatter.apply(average) + uniquePlayersNote + subNotes.toString()); @@ -139,7 +139,7 @@ public class NetworkHealthInformation extends AbstractHealthInfo { .map(c -> { int playersPerMonth = c.getUnsafe(AnalysisKeys.AVG_PLAYERS_NEW_MONTH); Server server = c.getUnsafe(serverKey); - return subNote + (playersPerMonth >= average && playersPerMonth > 0 ? Icons.GREEN_PLUS : Icons.RED_MINUS) + " " + + return SUB_NOTE + (playersPerMonth >= average && playersPerMonth > 0 ? Icons.GREEN_PLUS : Icons.RED_MINUS) + " " + server.getName() + ": " + playersPerMonth; }).forEach(subNotes::append); addNote(icon + " " + decimalFormatter.apply(average) + newPlayersNote + subNotes.toString()); @@ -179,7 +179,7 @@ public class NetworkHealthInformation extends AbstractHealthInfo { .map(c -> { int playersPerMonth = c.getUnsafe(AnalysisKeys.PLAYERS_MONTH); Server server = c.getUnsafe(serverKey); - return subNote + (playersPerMonth > 0 ? Icons.GREEN_PLUS : Icons.RED_MINUS) + " " + + return SUB_NOTE + (playersPerMonth > 0 ? Icons.GREEN_PLUS : Icons.RED_MINUS) + " " + server.getName() + ": " + playersPerMonth; }).forEach(subNotes::append); addNote(icon.toHtml() + " " + uniquePlayersNote + subNotes.toString()); diff --git a/Plan/common/src/main/java/com/djrapitops/plan/db/access/queries/DataStoreQueries.java b/Plan/common/src/main/java/com/djrapitops/plan/db/access/queries/DataStoreQueries.java index dcea77d6c..dfbf6c388 100644 --- a/Plan/common/src/main/java/com/djrapitops/plan/db/access/queries/DataStoreQueries.java +++ b/Plan/common/src/main/java/com/djrapitops/plan/db/access/queries/DataStoreQueries.java @@ -27,6 +27,7 @@ import com.djrapitops.plan.db.access.ExecBatchStatement; import com.djrapitops.plan.db.access.ExecStatement; import com.djrapitops.plan.db.access.Executable; import com.djrapitops.plan.db.sql.tables.*; +import com.djrapitops.plugin.utilities.Verify; import java.sql.PreparedStatement; import java.sql.SQLException; @@ -88,7 +89,7 @@ public class DataStoreQueries { * @throws IllegalArgumentException If {@link Session#endSession(long)} has not yet been called. */ public static Executable storeSession(Session session) { - session.getValue(SessionKeys.END).orElseThrow(() -> new IllegalArgumentException("Attempted to save a session that has not ended.")); + Verify.isTrue(session.supports(SessionKeys.END), () -> new IllegalArgumentException("Attempted to save a session that has not ended.")); return connection -> { storeSessionInformation(session).execute(connection); storeSessionKills(session).execute(connection); diff --git a/Plan/common/src/main/java/com/djrapitops/plan/db/access/transactions/Transaction.java b/Plan/common/src/main/java/com/djrapitops/plan/db/access/transactions/Transaction.java index 07b5b5055..788890e72 100644 --- a/Plan/common/src/main/java/com/djrapitops/plan/db/access/transactions/Transaction.java +++ b/Plan/common/src/main/java/com/djrapitops/plan/db/access/transactions/Transaction.java @@ -157,4 +157,8 @@ public abstract class Transaction { public String toString() { return getClass().getSimpleName() + (success ? " (finished)" : ""); } + + public boolean wasSuccessful() { + return success; + } } \ No newline at end of file diff --git a/Plan/common/src/main/java/com/djrapitops/plan/extension/implementation/CallerImplementation.java b/Plan/common/src/main/java/com/djrapitops/plan/extension/implementation/CallerImplementation.java index e3f526c99..fa05d4516 100644 --- a/Plan/common/src/main/java/com/djrapitops/plan/extension/implementation/CallerImplementation.java +++ b/Plan/common/src/main/java/com/djrapitops/plan/extension/implementation/CallerImplementation.java @@ -47,7 +47,7 @@ public class CallerImplementation implements Caller { } @Override - public void updatePlayerData(UUID playerUUID, String playerName) throws IllegalArgumentException { + public void updatePlayerData(UUID playerUUID, String playerName) { Verify.nullCheck(playerUUID, () -> new IllegalArgumentException("'playerUUID' can not be null!")); Verify.nullCheck(playerName, () -> new IllegalArgumentException("'playerName' can not be null!")); processing.submitNonCritical(() -> extensionServiceImplementation.updatePlayerValues(gatherer, playerUUID, playerName, CallEvents.MANUAL)); diff --git a/Plan/common/src/main/java/com/djrapitops/plan/extension/implementation/ProviderInformation.java b/Plan/common/src/main/java/com/djrapitops/plan/extension/implementation/ProviderInformation.java index 4ca642e15..0e446f422 100644 --- a/Plan/common/src/main/java/com/djrapitops/plan/extension/implementation/ProviderInformation.java +++ b/Plan/common/src/main/java/com/djrapitops/plan/extension/implementation/ProviderInformation.java @@ -21,6 +21,7 @@ import com.djrapitops.plan.extension.icon.Icon; import com.djrapitops.plan.extension.implementation.results.ExtensionDescriptive; import org.apache.commons.lang3.StringUtils; +import java.util.Objects; import java.util.Optional; /** @@ -48,10 +49,38 @@ public class ProviderInformation extends ExtensionDescriptive { } public Optional getTab() { - return tab == null || tab.isEmpty() ? Optional.empty() : Optional.of(StringUtils.truncate(tab, 50)); + return tab == null || tab.isEmpty() + ? Optional.empty() + : Optional.of(StringUtils.truncate(tab, 50)); } public Optional getCondition() { - return condition == null || condition.value().isEmpty() ? Optional.empty() : Optional.of((condition.negated() ? "not_" : "") + StringUtils.truncate(condition.value(), 50)); + if (condition == null || condition.value().isEmpty()) { + return Optional.empty(); + } else if (condition.negated()) { + return Optional.of("not_" + getTruncatedConditionName()); + } else { + return Optional.of(getTruncatedConditionName()); + } + } + + private String getTruncatedConditionName() { + return StringUtils.truncate(condition.value(), 50); + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (!(o instanceof ProviderInformation)) return false; + if (!super.equals(o)) return false; + ProviderInformation that = (ProviderInformation) o; + return pluginName.equals(that.pluginName) && + Objects.equals(tab, that.tab) && + Objects.equals(condition, that.condition); + } + + @Override + public int hashCode() { + return Objects.hash(super.hashCode(), pluginName, tab, condition); } } \ No newline at end of file diff --git a/Plan/common/src/main/java/com/djrapitops/plan/system/locale/lang/ErrorPageLang.java b/Plan/common/src/main/java/com/djrapitops/plan/system/locale/lang/ErrorPageLang.java index a5451a6cc..eb2270d64 100644 --- a/Plan/common/src/main/java/com/djrapitops/plan/system/locale/lang/ErrorPageLang.java +++ b/Plan/common/src/main/java/com/djrapitops/plan/system/locale/lang/ErrorPageLang.java @@ -27,7 +27,7 @@ public enum ErrorPageLang implements Lang { NOT_PLAYED_404("Player has not played on this server."), UNKNOWN_PAGE_404("Make sure you're accessing a link given by a command, Examples:

/player/PlayerName
/server/ServerName

"), UNAUTHORIZED_401("Unauthorized"), - AUTHENTICATION_FAIlED_401("Authentication Failed."), + AUTHENTICATION_FAILED_401("Authentication Failed."), AUTH_FAIL_TIPS_401("- Ensure you have registered a user with /plan register
- Check that the username and password are correct
- Username and password are case-sensitive

If you have forgotten your password, ask a staff member to delete your old user and re-register."), FORBIDDEN_403("Forbidden"), ACCESS_DENIED_403("Access Denied"), diff --git a/Plan/common/src/main/java/com/djrapitops/plan/system/settings/changes/ConfigChange.java b/Plan/common/src/main/java/com/djrapitops/plan/system/settings/changes/ConfigChange.java index 3923d8fe0..32048a335 100644 --- a/Plan/common/src/main/java/com/djrapitops/plan/system/settings/changes/ConfigChange.java +++ b/Plan/common/src/main/java/com/djrapitops/plan/system/settings/changes/ConfigChange.java @@ -41,7 +41,7 @@ public interface ConfigChange { } @Override - public void apply(Config config) { + public synchronized void apply(Config config) { if (!config.moveChild(oldPath, newPath)) { throw new IllegalStateException("Failed to move config node from '" + oldPath + "' to '" + newPath + "'"); } @@ -63,7 +63,7 @@ public interface ConfigChange { } @Override - public void apply(Config config) { + public synchronized void apply(Config config) { config.getNode(oldPath).ifPresent(oldNode -> config.addNode(newPath).copyAll(oldNode)); } diff --git a/Plan/common/src/main/java/com/djrapitops/plan/system/settings/config/ConfigValueParser.java b/Plan/common/src/main/java/com/djrapitops/plan/system/settings/config/ConfigValueParser.java index 2b84e08b6..ead1610bb 100644 --- a/Plan/common/src/main/java/com/djrapitops/plan/system/settings/config/ConfigValueParser.java +++ b/Plan/common/src/main/java/com/djrapitops/plan/system/settings/config/ConfigValueParser.java @@ -76,6 +76,10 @@ public interface ConfigValueParser { */ String decompose(T ofValue); + static IllegalArgumentException nullInvalidException() { + return new IllegalArgumentException("Null value is not valid for saving"); + } + class StringParser implements ConfigValueParser { @Override public String compose(String fromValue) { @@ -89,7 +93,7 @@ public interface ConfigValueParser { @Override public String decompose(String value) { - Verify.nullCheck(value, () -> new IllegalArgumentException("Null value is not valid for saving")); + Verify.nullCheck(value, ConfigValueParser::nullInvalidException); boolean surroundedByQuotes = value.startsWith("'") || value.endsWith("'"); boolean surroundedByDoubleQuotes = value.startsWith("\"") || value.endsWith("\""); @@ -116,7 +120,7 @@ public interface ConfigValueParser { @Override public String decompose(Integer ofValue) { - Verify.nullCheck(ofValue, () -> new IllegalArgumentException("Null value is not valid for saving")); + Verify.nullCheck(ofValue, ConfigValueParser::nullInvalidException); return Integer.toString(ofValue); } } @@ -133,7 +137,7 @@ public interface ConfigValueParser { @Override public String decompose(Long ofValue) { - Verify.nullCheck(ofValue, () -> new IllegalArgumentException("Null value is not valid for saving")); + Verify.nullCheck(ofValue, ConfigValueParser::nullInvalidException); return Long.toString(ofValue); } } @@ -146,7 +150,7 @@ public interface ConfigValueParser { @Override public String decompose(Boolean ofValue) { - Verify.nullCheck(ofValue, () -> new IllegalArgumentException("Null value is not valid for saving")); + Verify.nullCheck(ofValue, ConfigValueParser::nullInvalidException); return Boolean.toString(ofValue); } } @@ -174,7 +178,7 @@ public interface ConfigValueParser { @Override public String decompose(List ofValue) { - Verify.nullCheck(ofValue, () -> new IllegalArgumentException("Null value is not valid for saving")); + Verify.nullCheck(ofValue, ConfigValueParser::nullInvalidException); StringBuilder decomposedString = new StringBuilder(); for (String value : ofValue) { diff --git a/Plan/common/src/main/java/com/djrapitops/plan/system/settings/config/PlanConfig.java b/Plan/common/src/main/java/com/djrapitops/plan/system/settings/config/PlanConfig.java index 606b8a368..7e8879f2a 100644 --- a/Plan/common/src/main/java/com/djrapitops/plan/system/settings/config/PlanConfig.java +++ b/Plan/common/src/main/java/com/djrapitops/plan/system/settings/config/PlanConfig.java @@ -27,6 +27,7 @@ import javax.inject.Named; import javax.inject.Singleton; import java.io.File; import java.util.List; +import java.util.Objects; import java.util.TimeZone; import java.util.concurrent.TimeUnit; @@ -134,4 +135,9 @@ public class PlanConfig extends Config { if (o == null) return false; return super.equals(o); } + + @Override + public int hashCode() { + return Objects.hash(super.hashCode()); + } } \ No newline at end of file diff --git a/Plan/common/src/main/java/com/djrapitops/plan/system/webserver/response/pages/RawDataResponse.java b/Plan/common/src/main/java/com/djrapitops/plan/system/webserver/response/pages/RawDataResponse.java index a64425136..a1dd8a097 100644 --- a/Plan/common/src/main/java/com/djrapitops/plan/system/webserver/response/pages/RawDataResponse.java +++ b/Plan/common/src/main/java/com/djrapitops/plan/system/webserver/response/pages/RawDataResponse.java @@ -59,7 +59,7 @@ public class RawDataResponse extends JSONResponse> { private static List handleList(List list) { if (list.stream().findAny().orElse(null) instanceof DataContainer) { - return (List) list.stream().map((obj) -> mapToNormalMap((DataContainer) obj)).collect(Collectors.toList()); + return (List) list.stream().map(obj -> mapToNormalMap((DataContainer) obj)).collect(Collectors.toList()); } return list; } diff --git a/Plan/common/src/main/java/com/djrapitops/plan/utilities/html/tables/PlayerSessionTable.java b/Plan/common/src/main/java/com/djrapitops/plan/utilities/html/tables/PlayerSessionTable.java index 74838aa0a..a197ed755 100644 --- a/Plan/common/src/main/java/com/djrapitops/plan/utilities/html/tables/PlayerSessionTable.java +++ b/Plan/common/src/main/java/com/djrapitops/plan/utilities/html/tables/PlayerSessionTable.java @@ -75,7 +75,7 @@ class PlayerSessionTable extends TableContainer { String world = worldAliasSettings.getLongestWorldPlayed(session); String toolTip = "Session ID: " + session.getValue(SessionKeys.DB_ID) - .map(id -> Integer.toString(id)) + .map(Object::toString) .orElse("Not Saved."); addRow(Html.LINK_TOOLTIP.parse(inspectUrl, playerName, toolTip), start, length, world); diff --git a/Plan/common/src/main/java/com/djrapitops/plan/utilities/html/tables/ServerSessionTable.java b/Plan/common/src/main/java/com/djrapitops/plan/utilities/html/tables/ServerSessionTable.java index de04fb2b8..a5b0f25cb 100644 --- a/Plan/common/src/main/java/com/djrapitops/plan/utilities/html/tables/ServerSessionTable.java +++ b/Plan/common/src/main/java/com/djrapitops/plan/utilities/html/tables/ServerSessionTable.java @@ -76,7 +76,7 @@ class ServerSessionTable extends TableContainer { String world = worldAliasSettings.getLongestWorldPlayed(session); String toolTip = "Session ID: " + session.getValue(SessionKeys.DB_ID) - .map(id -> Integer.toString(id)) + .map(Object::toString) .orElse("Not Saved."); String playerName = playerNames.getOrDefault(session.getValue(SessionKeys.UUID).orElse(null), "Unknown"); diff --git a/Plan/common/src/main/resources/assets/plan/locale/locale_CN.txt b/Plan/common/src/main/resources/assets/plan/locale/locale_CN.txt index 92c979db8..1bab9873b 100644 --- a/Plan/common/src/main/resources/assets/plan/locale/locale_CN.txt +++ b/Plan/common/src/main/resources/assets/plan/locale/locale_CN.txt @@ -246,7 +246,7 @@ HTML ERRORS - ACCESS_DENIED_403 || 拒绝访问 HTML ERRORS - ANALYSIS_REFRESH || 正在刷新分析··· HTML ERRORS - ANALYSIS_REFRESH_LONG || 正在执行分析,请在几秒后刷新页面··· HTML ERRORS - AUTH_FAIL_TIPS_401 || - 确保您已使用 /plan register 注册用户
- 检查用户名与密码是否正确
- 用户名与密码区分大小写

若您忘记了密码,请让工作人员删除您的旧密码并重新注册。 -HTML ERRORS - AUTHENTICATION_FAIlED_401 || 认证失败。 +HTML ERRORS - AUTHENTICATION_FAILED_401 || 认证失败。 HTML ERRORS - FORBIDDEN_403 || 禁止访问 HTML ERRORS - NO_SERVERS_404 || 无可执行此请求的在线服务器。 HTML ERRORS - NOT_FOUND_404 || 未找到 diff --git a/Plan/common/src/main/resources/assets/plan/locale/locale_DE.txt b/Plan/common/src/main/resources/assets/plan/locale/locale_DE.txt index 7d410e229..571043643 100644 --- a/Plan/common/src/main/resources/assets/plan/locale/locale_DE.txt +++ b/Plan/common/src/main/resources/assets/plan/locale/locale_DE.txt @@ -245,7 +245,7 @@ HTML ERRORS - ACCESS_DENIED_403 || Zugriff verweigert HTML ERRORS - ANALYSIS_REFRESH || Plan wird aktualisiert... HTML ERRORS - ANALYSIS_REFRESH_LONG || Plan wird ausgeführt. Es wird in ein paar Sekunden neu geladen. HTML ERRORS - AUTH_FAIL_TIPS_401 || - Stelle sicher, dass du einen Account mit /plan register hinzugefügt hast.
- Überprüfe, ob Passwort und Benutzername korrekt sind
- Bei Benutzername und Passwort auf Groß- und Kleinschreibung achten!

- Wenn du dein Passwort vergessen hast, bitte ein Teammitglied deinen Account zu löschen und neu zu erstellen. -HTML ERRORS - AUTHENTICATION_FAIlED_401 || Authentifizierung fehlgeschlagen. +HTML ERRORS - AUTHENTICATION_FAILED_401 || Authentifizierung fehlgeschlagen. HTML ERRORS - FORBIDDEN_403 || Verboten HTML ERRORS - NO_SERVERS_404 || Keine Server online, die die Anfrage ausführen können. HTML ERRORS - NOT_FOUND_404 || Nicht gefunden. diff --git a/Plan/common/src/main/resources/assets/plan/locale/locale_EN.txt b/Plan/common/src/main/resources/assets/plan/locale/locale_EN.txt index 2d9750a68..f3308126b 100644 --- a/Plan/common/src/main/resources/assets/plan/locale/locale_EN.txt +++ b/Plan/common/src/main/resources/assets/plan/locale/locale_EN.txt @@ -245,7 +245,7 @@ HTML ERRORS - ACCESS_DENIED_403 || Access Denied HTML ERRORS - ANALYSIS_REFRESH || Analysis is being refreshed.. HTML ERRORS - ANALYSIS_REFRESH_LONG || Analysis is being run, refresh the page after a few seconds.. HTML ERRORS - AUTH_FAIL_TIPS_401 || - Ensure you have registered a user with /plan register
- Check that the username and password are correct
- Username and password are case-sensitive

If you have forgotten your password, ask a staff member to delete your old user and re-register. -HTML ERRORS - AUTHENTICATION_FAIlED_401 || Authentication Failed. +HTML ERRORS - AUTHENTICATION_FAILED_401 || Authentication Failed. HTML ERRORS - FORBIDDEN_403 || Forbidden HTML ERRORS - NO_SERVERS_404 || No Servers online to perform the request. HTML ERRORS - NOT_FOUND_404 || Not Found diff --git a/Plan/common/src/main/resources/assets/plan/locale/locale_FI.txt b/Plan/common/src/main/resources/assets/plan/locale/locale_FI.txt index b237353a5..ef57fff47 100644 --- a/Plan/common/src/main/resources/assets/plan/locale/locale_FI.txt +++ b/Plan/common/src/main/resources/assets/plan/locale/locale_FI.txt @@ -244,7 +244,7 @@ HTML ERRORS - ACCESS_DENIED_403 || Pääsy Kielletty HTML ERRORS - ANALYSIS_REFRESH || Analyysiä suoritetaan.. HTML ERRORS - ANALYSIS_REFRESH_LONG || Analyysiä suoritetaan, sivu päivittyy hetken kuluttua.. HTML ERRORS - AUTH_FAIL_TIPS_401 || - Varmista että olet rekisteröinyt käyttäjän komennolla /plan register
- Tarkista että käyttäjänimi ja salaasana ovat oikein
- Nimi ja salasana ovat CASE SENSITIVE

Jos unohdit salasanasi, pyydä valvojia poistamaan käyttäjäsi ja uudelleenrekisteröidy. -HTML ERRORS - AUTHENTICATION_FAIlED_401 || Autentikaatio ei onnistunut. +HTML ERRORS - AUTHENTICATION_FAILED_401 || Autentikaatio ei onnistunut. HTML ERRORS - FORBIDDEN_403 || Kielletty HTML ERRORS - NO_SERVERS_404 || Ei palvelimia jolla toiminto voitaisiin suorittaa. HTML ERRORS - NOT_FOUND_404 || Ei löytynyt diff --git a/Plan/common/src/main/resources/assets/plan/locale/locale_FR.txt b/Plan/common/src/main/resources/assets/plan/locale/locale_FR.txt index e6bac4e66..63abee222 100644 --- a/Plan/common/src/main/resources/assets/plan/locale/locale_FR.txt +++ b/Plan/common/src/main/resources/assets/plan/locale/locale_FR.txt @@ -245,7 +245,7 @@ HTML ERRORS - ACCESS_DENIED_403 || Accès refusé. HTML ERRORS - ANALYSIS_REFRESH || L'analyseur est en cours de rafraîchissement... HTML ERRORS - ANALYSIS_REFRESH_LONG || L'analyse est en cours d'exécution, actualisez la page après quelques secondes.... HTML ERRORS - AUTH_FAIL_TIPS_401 || - Assurez-vous d'avoir enregistré un utilisateur avec :'/plan register'.
- Vérifiez que le nom d'utilisateur et le mot de passe soient corrects.
- Le nom d'utilisateur et le mot de passe sont sensibles au format majuscule/minuscule.

Si vous avez oublié votre mot de passe, demandez à un membre du staff de supprimer votre ancien utilisateur puis de vous réinscrire. -HTML ERRORS - AUTHENTICATION_FAIlED_401 || Authentification échouée. +HTML ERRORS - AUTHENTICATION_FAILED_401 || Authentification échouée. HTML ERRORS - FORBIDDEN_403 || Accès interdit. HTML ERRORS - NO_SERVERS_404 || Aucun serveur en ligne pour exécuter la demande. HTML ERRORS - NOT_FOUND_404 || Non trouvé. diff --git a/Plan/common/src/main/resources/assets/plan/locale/locale_IT.txt b/Plan/common/src/main/resources/assets/plan/locale/locale_IT.txt index 2d9750a68..f3308126b 100644 --- a/Plan/common/src/main/resources/assets/plan/locale/locale_IT.txt +++ b/Plan/common/src/main/resources/assets/plan/locale/locale_IT.txt @@ -245,7 +245,7 @@ HTML ERRORS - ACCESS_DENIED_403 || Access Denied HTML ERRORS - ANALYSIS_REFRESH || Analysis is being refreshed.. HTML ERRORS - ANALYSIS_REFRESH_LONG || Analysis is being run, refresh the page after a few seconds.. HTML ERRORS - AUTH_FAIL_TIPS_401 || - Ensure you have registered a user with /plan register
- Check that the username and password are correct
- Username and password are case-sensitive

If you have forgotten your password, ask a staff member to delete your old user and re-register. -HTML ERRORS - AUTHENTICATION_FAIlED_401 || Authentication Failed. +HTML ERRORS - AUTHENTICATION_FAILED_401 || Authentication Failed. HTML ERRORS - FORBIDDEN_403 || Forbidden HTML ERRORS - NO_SERVERS_404 || No Servers online to perform the request. HTML ERRORS - NOT_FOUND_404 || Not Found diff --git a/Plan/common/src/main/resources/assets/plan/locale/locale_JA.txt b/Plan/common/src/main/resources/assets/plan/locale/locale_JA.txt index 14059d8cf..112047d37 100644 --- a/Plan/common/src/main/resources/assets/plan/locale/locale_JA.txt +++ b/Plan/common/src/main/resources/assets/plan/locale/locale_JA.txt @@ -261,7 +261,7 @@ HTML ERRORS - ACCESS_DENIED_403 || アクセスが拒否され HTML ERRORS - ANALYSIS_REFRESH || 分析結果に基づいてデータを更新中です・・・ HTML ERRORS - ANALYSIS_REFRESH_LONG || サーバーを分析中です・・・・
数秒後にページが更新されない場合、ページを更新して下さい HTML ERRORS - AUTH_FAIL_TIPS_401 || - 登録したユーザーを「/plan register 」で確認できます。
- 入力したユーザー名とパスワードが正しいことを確認して下さい
- ユーザー名とパスワードは大文字と小文字が区別されています

パスワードを忘れた場合は、管理者に古いユーザーを削除して新しくユーザーを再登録するよう依頼して下さい -HTML ERRORS - AUTHENTICATION_FAIlED_401 || 認証に失敗しました +HTML ERRORS - AUTHENTICATION_FAILED_401 || 認証に失敗しました HTML ERRORS - FORBIDDEN_403 || 閲覧禁止 HTML ERRORS - INSPECT_REFRESH || プレーヤページのリクエスト処理が実行中です・・ HTML ERRORS - INSPECT_REFRESH_LONG || ページは自動的に更新されます・・ diff --git a/Plan/common/src/test/java/com/djrapitops/plan/data/container/SessionTest.java b/Plan/common/src/test/java/com/djrapitops/plan/data/container/SessionTest.java index 8f99d95ce..8102faa2f 100644 --- a/Plan/common/src/test/java/com/djrapitops/plan/data/container/SessionTest.java +++ b/Plan/common/src/test/java/com/djrapitops/plan/data/container/SessionTest.java @@ -21,6 +21,7 @@ import com.djrapitops.plan.data.time.WorldTimes; import org.junit.jupiter.api.Test; import org.junit.platform.runner.JUnitPlatform; import org.junit.runner.RunWith; +import utilities.RandomData; import utilities.TestConstants; import java.util.List; @@ -42,21 +43,22 @@ class SessionTest { @Test void safeStartKeyConstructor() { for (int i = 0; i < 10000; i++) { - Session session = new Session(null, serverUUID, System.currentTimeMillis(), null, null); + long expected = RandomData.randomLong(0, System.currentTimeMillis()); + Session session = new Session(null, serverUUID, expected, null, null); // Should not throw - session.getUnsafe(SessionKeys.START); + assertEquals(expected, session.getUnsafe(SessionKeys.START)); } } @Test void safeStartKeyDBConstructor() { for (int i = 0; i < 10000; i++) { - long time = System.currentTimeMillis(); - Session session = new Session(-1, null, null, time, time + 1, 0, 0, 0); + long expected = RandomData.randomLong(0, System.currentTimeMillis()); + Session session = new Session(-1, null, null, expected, expected + 1, 0, 0, 0); // Should not throw - session.getUnsafe(SessionKeys.START); + assertEquals(expected, session.getUnsafe(SessionKeys.START)); } } diff --git a/Plan/common/src/test/java/com/djrapitops/plan/db/CommonDBTest.java b/Plan/common/src/test/java/com/djrapitops/plan/db/CommonDBTest.java index abb0a090d..a01c9fba6 100644 --- a/Plan/common/src/test/java/com/djrapitops/plan/db/CommonDBTest.java +++ b/Plan/common/src/test/java/com/djrapitops/plan/db/CommonDBTest.java @@ -1050,8 +1050,10 @@ public abstract class CommonDBTest { } @Test - public void indexCreationWorksWithoutErrors() { - db.executeTransaction(new CreateIndexTransaction()); + public void indexCreationWorksWithoutErrors() throws Exception { + Transaction transaction = new CreateIndexTransaction(); + db.executeTransaction(transaction).get(); // get to ensure transaction is finished + assertTrue(transaction.wasSuccessful()); } @Test diff --git a/Plan/common/src/test/java/com/djrapitops/plan/system/locale/LocaleSystemTest.java b/Plan/common/src/test/java/com/djrapitops/plan/system/locale/LocaleSystemTest.java index f39e853f0..221e73d3f 100644 --- a/Plan/common/src/test/java/com/djrapitops/plan/system/locale/LocaleSystemTest.java +++ b/Plan/common/src/test/java/com/djrapitops/plan/system/locale/LocaleSystemTest.java @@ -20,12 +20,13 @@ import org.junit.jupiter.api.Test; import org.junit.platform.runner.JUnitPlatform; import org.junit.runner.RunWith; +import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; + @RunWith(JUnitPlatform.class) class LocaleSystemTest { @Test void noIdentifierCollisions() { - // No Exception wanted - LocaleSystem.getIdentifiers(); + assertDoesNotThrow(LocaleSystem::getIdentifiers); } } \ No newline at end of file diff --git a/Plan/common/src/test/java/com/djrapitops/plan/utilities/file/FileWatcherTest.java b/Plan/common/src/test/java/com/djrapitops/plan/utilities/file/FileWatcherTest.java index b43d08585..60a4d7553 100644 --- a/Plan/common/src/test/java/com/djrapitops/plan/utilities/file/FileWatcherTest.java +++ b/Plan/common/src/test/java/com/djrapitops/plan/utilities/file/FileWatcherTest.java @@ -32,6 +32,8 @@ import java.util.Collections; import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicBoolean; +import static org.junit.jupiter.api.Assertions.assertTrue; + @RunWith(JUnitPlatform.class) class FileWatcherTest { @@ -63,6 +65,8 @@ class FileWatcherTest { Awaitility.await() .atMost(1, TimeUnit.SECONDS) .until(methodWasCalled::get); + + assertTrue(methodWasCalled.get()); } finally { underTest.interrupt(); } diff --git a/Plan/common/src/test/java/utilities/RandomData.java b/Plan/common/src/test/java/utilities/RandomData.java index 8517e5bef..05f11bb48 100644 --- a/Plan/common/src/test/java/utilities/RandomData.java +++ b/Plan/common/src/test/java/utilities/RandomData.java @@ -39,6 +39,10 @@ public class RandomData { return ThreadLocalRandom.current().nextInt(rangeStart, rangeEnd); } + public static long randomLong(long rangeStart, long rangeEnd) { + return ThreadLocalRandom.current().nextLong(rangeStart, rangeEnd); + } + public static String randomString(int size) { return RandomStringUtils.randomAlphanumeric(size); } diff --git a/Plan/plugin/src/test/java/com/djrapitops/plan/BungeeBukkitConnectionTest.java b/Plan/plugin/src/test/java/com/djrapitops/plan/BungeeBukkitConnectionTest.java deleted file mode 100644 index 77efbfd5a..000000000 --- a/Plan/plugin/src/test/java/com/djrapitops/plan/BungeeBukkitConnectionTest.java +++ /dev/null @@ -1,99 +0,0 @@ -/* - * This file is part of Player Analytics (Plan). - * - * Plan is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License v3 as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Plan is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Plan. If not, see . - */ -package com.djrapitops.plan; - -import com.djrapitops.plan.system.PlanSystem; -import com.djrapitops.plan.system.database.DBSystem; -import com.djrapitops.plan.system.settings.paths.WebserverSettings; -import org.junit.*; -import org.junit.rules.ExpectedException; -import org.junit.rules.TemporaryFolder; -import org.junit.runner.RunWith; -import org.mockito.junit.MockitoJUnitRunner; -import rules.BukkitComponentMocker; -import rules.BungeeComponentMocker; -import rules.ComponentMocker; -import utilities.RandomData; - -import java.util.UUID; - -/** - * @author Rsl1122 - */ -@RunWith(MockitoJUnitRunner.Silent.class) -public class BungeeBukkitConnectionTest { - - @ClassRule - public static TemporaryFolder temporaryFolder = new TemporaryFolder(); - @ClassRule - public static ComponentMocker bukkitComponent = new BukkitComponentMocker(temporaryFolder); - @ClassRule - public static ComponentMocker bungeeComponent = new BungeeComponentMocker(temporaryFolder); - - private final int TEST_PORT_NUMBER = RandomData.randomInt(9005, 9500); - - @Rule - public ExpectedException thrown = ExpectedException.none(); - - private PlanSystem bukkitSystem; - private PlanSystem bungeeSystem; - - @After - public void tearDown() { - System.out.println("------------------------------"); - System.out.println("Disable"); - System.out.println("------------------------------"); - if (bukkitSystem != null) { - bukkitSystem.disable(); - } - if (bungeeSystem != null) { - bungeeSystem.disable(); - } - } - - public void enable() throws Exception { - bukkitSystem = bukkitComponent.getPlanSystem(); - bungeeSystem = bungeeComponent.getPlanSystem(); - - bukkitSystem.getConfigSystem().getConfig().set(WebserverSettings.PORT, TEST_PORT_NUMBER); - bungeeSystem.getConfigSystem().getConfig().set(WebserverSettings.PORT, 9250); - - DBSystem dbSystem = bungeeSystem.getDatabaseSystem(); - dbSystem.setActiveDatabase(dbSystem.getSqLiteFactory().usingDefaultFile()); - - bukkitSystem.enable(); - bungeeSystem.enable(); - - UUID bukkitUUID = bukkitSystem.getServerInfo().getServerUUID(); - UUID bungeeUUID = bungeeSystem.getServerInfo().getServerUUID(); - - System.out.println("------------------------------"); - System.out.println("Enable Complete"); - System.out.println("Bukkit: " + bukkitUUID); - System.out.println("Bungee: " + bungeeUUID); - System.out.println("------------------------------"); - } - - @Test - @Ignore("InfoRequestFactory not available via getters") - public void testRequest() throws Exception { - enable(); - - System.out.println("Sending request"); -// bungeeSystem.getInfoSystem().getConnectionSystem().sendWideInfoRequest(new GenerateInspectPluginsTabRequest(infoSystem, infoRequestFactory, TestConstants.PLAYER_ONE_UUID)); - } -}