Skip to content

Commit

Permalink
Remove useless debug configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
utarwyn committed Sep 30, 2021
1 parent 65c0bf1 commit f4a1295
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 34 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,6 @@ public class Configuration {
*/
private final Plugin plugin;

@Configurable
private boolean debug;

@Configurable
private String locale;

Expand Down Expand Up @@ -102,10 +99,6 @@ public class Configuration {
this.load();
}

public boolean isDebug() {
return this.debug;
}

public String getLocale() {
return this.locale;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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 " +
Expand All @@ -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);
}
}

/**
Expand All @@ -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));
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -94,12 +93,11 @@ public ConcurrentMap<Integer, ItemStack> getEnderchestContents(EnderChest chest)
*/
@Override
public int getEnderchestRows(EnderChest chest) {
Optional<Integer> 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);
}

/**
Expand Down
3 changes: 0 additions & 3 deletions plugin/src/main/resources/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@
# An enderchests plugin by Utarwyn #
# # # # # # # # # # # # # # # # # # # # #

# Show additional information in console
debug: false

# The locale of the plugin
locale: en

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
2 changes: 0 additions & 2 deletions plugin/src/test/resources/config.test.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
# # # # # # # # # # # # # # # # # # # # # # # #
# EnderContainers configuration for tests #
# # # # # # # # # # # # # # # # # # # # # # # #

debug: false
locale: en
disabledWorlds:
- disabled
Expand Down

0 comments on commit f4a1295

Please sign in to comment.