From f4a12954ae18bb9998019fa66598d365c878c486 Mon Sep 17 00:00:00 2001 From: utarwyn Date: Thu, 30 Sep 2021 21:48:31 +0200 Subject: [PATCH] Remove useless debug configuration --- .../configuration/Configuration.java | 7 ------ .../database/DatabaseManager.java | 22 +++++-------------- .../storage/player/PlayerSQLData.java | 8 +++---- plugin/src/main/resources/config.yml | 3 --- .../configuration/ConfigurationTest.java | 1 - plugin/src/test/resources/config.test.yml | 2 -- 6 files changed, 9 insertions(+), 34 deletions(-) diff --git a/plugin/src/main/java/fr/utarwyn/endercontainers/configuration/Configuration.java b/plugin/src/main/java/fr/utarwyn/endercontainers/configuration/Configuration.java index b9e4d4bd..003ca705 100644 --- a/plugin/src/main/java/fr/utarwyn/endercontainers/configuration/Configuration.java +++ b/plugin/src/main/java/fr/utarwyn/endercontainers/configuration/Configuration.java @@ -18,9 +18,6 @@ public class Configuration { */ private final Plugin plugin; - @Configurable - private boolean debug; - @Configurable private String locale; @@ -102,10 +99,6 @@ public class Configuration { this.load(); } - public boolean isDebug() { - return this.debug; - } - public String getLocale() { return this.locale; } diff --git a/plugin/src/main/java/fr/utarwyn/endercontainers/database/DatabaseManager.java b/plugin/src/main/java/fr/utarwyn/endercontainers/database/DatabaseManager.java index c831eed8..14ffd3af 100644 --- a/plugin/src/main/java/fr/utarwyn/endercontainers/database/DatabaseManager.java +++ b/plugin/src/main/java/fr/utarwyn/endercontainers/database/DatabaseManager.java @@ -65,7 +65,7 @@ public synchronized void load() { this.createTables(); // Log the successful connection into the console - this.logConnection(beginTime); + this.logConnection(System.currentTimeMillis() - beginTime); } catch (DatabaseConnectException | SQLException e) { this.logger.log(Level.SEVERE, "SQL supports disabled because of an error during the connection.", e); @@ -246,11 +246,11 @@ private void setupDatabase() { /** * Log a successful database connection into the console. * - * @param beginTime timestamp where the connection has started + * @param connectionTime connection time in milliseconds */ - private void logConnection(long beginTime) { - this.logger.log(Level.INFO, "MySQL enabled and ready. Connected to database {0}", - this.database.getServerUrl()); + private void logConnection(long connectionTime) { + this.logger.log(Level.INFO, "MySQL enabled and ready. Connected to database {0} in {1}ms", + new Object[]{this.database.getServerUrl(), connectionTime}); if (this.database.isSecure()) { this.logger.info("Good news! You are using a secure connection " + @@ -259,11 +259,6 @@ private void logConnection(long beginTime) { this.logger.warning("You are using an unsecure connection " + "to your database server. Be careful!"); } - - if (Files.getConfiguration().isDebug()) { - this.logger.log(Level.INFO, "Connection time: {0}ms", - System.currentTimeMillis() - beginTime); - } } /** @@ -275,15 +270,10 @@ private void createTables() throws SQLException { if (!tables.contains(formatTable(CHEST_TABLE))) { database.request("CREATE TABLE `" + formatTable(CHEST_TABLE) + "` (`id` INT(11) NOT NULL AUTO_INCREMENT, `num` TINYINT(2) NOT NULL DEFAULT '0', `owner` VARCHAR(36) NULL, `contents` MEDIUMTEXT NULL, `rows` INT(1) NOT NULL DEFAULT 0, PRIMARY KEY (`id`), UNIQUE KEY `NUM OWNER` (`num`,`owner`), INDEX `USER KEY` (`num`, `owner`)) COLLATE='" + collation + "' ENGINE=InnoDB;"); - if (Files.getConfiguration().isDebug()) { - this.logger.log(Level.INFO, "Table `{0}` created in the database.", formatTable(CHEST_TABLE)); - } } + if (!tables.contains(formatTable(BACKUP_TABLE))) { database.request("CREATE TABLE `" + formatTable(BACKUP_TABLE) + "` (`id` INT(11) NOT NULL AUTO_INCREMENT, `name` VARCHAR(255) NOT NULL, `date` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, `data` MEDIUMTEXT NULL, `created_by` VARCHAR(60) NULL, PRIMARY KEY (`id`)) COLLATE='" + collation + "' ENGINE=InnoDB;"); - if (Files.getConfiguration().isDebug()) { - this.logger.log(Level.INFO, "Table `{0}` created in the database.", formatTable(BACKUP_TABLE)); - } } } diff --git a/plugin/src/main/java/fr/utarwyn/endercontainers/storage/player/PlayerSQLData.java b/plugin/src/main/java/fr/utarwyn/endercontainers/storage/player/PlayerSQLData.java index 5ef19a49..13310719 100644 --- a/plugin/src/main/java/fr/utarwyn/endercontainers/storage/player/PlayerSQLData.java +++ b/plugin/src/main/java/fr/utarwyn/endercontainers/storage/player/PlayerSQLData.java @@ -10,7 +10,6 @@ import java.sql.SQLException; import java.util.List; -import java.util.Optional; import java.util.UUID; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentMap; @@ -94,12 +93,11 @@ public ConcurrentMap getEnderchestContents(EnderChest chest) */ @Override public int getEnderchestRows(EnderChest chest) { - Optional rows = this.databaseSets.stream() + return this.databaseSets.stream() .filter(set -> set.getInteger("num") == chest.getNum()) .map(set -> set.getInteger("rows")) - .findFirst(); - - return rows.orElse(3); + .findFirst() + .orElse(3); } /** diff --git a/plugin/src/main/resources/config.yml b/plugin/src/main/resources/config.yml index 83d75ecd..02aa1764 100644 --- a/plugin/src/main/resources/config.yml +++ b/plugin/src/main/resources/config.yml @@ -4,9 +4,6 @@ # An enderchests plugin by Utarwyn # # # # # # # # # # # # # # # # # # # # # # -# Show additional information in console -debug: false - # The locale of the plugin locale: en diff --git a/plugin/src/test/java/fr/utarwyn/endercontainers/configuration/ConfigurationTest.java b/plugin/src/test/java/fr/utarwyn/endercontainers/configuration/ConfigurationTest.java index 65b2250e..5d2365a8 100644 --- a/plugin/src/test/java/fr/utarwyn/endercontainers/configuration/ConfigurationTest.java +++ b/plugin/src/test/java/fr/utarwyn/endercontainers/configuration/ConfigurationTest.java @@ -27,7 +27,6 @@ public void setUp() throws TestInitializationException, ConfigLoadingException { @Test public void get() { - assertThat(this.config.isDebug()).isFalse(); assertThat(this.config.getLocale()).isEqualTo("en"); assertThat(this.config.getDisabledWorlds()).containsExactly("disabled"); assertThat(this.config.isOnlyShowAccessibleEnderchests()).isFalse(); diff --git a/plugin/src/test/resources/config.test.yml b/plugin/src/test/resources/config.test.yml index 429bf21a..9b10d493 100644 --- a/plugin/src/test/resources/config.test.yml +++ b/plugin/src/test/resources/config.test.yml @@ -1,8 +1,6 @@ # # # # # # # # # # # # # # # # # # # # # # # # # EnderContainers configuration for tests # # # # # # # # # # # # # # # # # # # # # # # # # - -debug: false locale: en disabledWorlds: - disabled