From 24d783be24d4424461f24aa5dac1a1ab142cd3b9 Mon Sep 17 00:00:00 2001 From: Florian CUNY Date: Fri, 31 Aug 2018 11:06:37 +0200 Subject: [PATCH] Cleanup in Settings Removed purge-related settings. Renamed all database-related settings and methods to replace `db` with `database`. Moved confirmationTime to `island.confirmation.time`. Renamed inviteWait, banWait and resetWait to inviteCooldown, banCooldown, resetCooldown. Also moved them under `island.cooldown.x`. Removed kickWait and leaveWait, using confirmationTime instead. Moved `island.require-confirmation.` to `island.confirmation.commands.`. Updated tests. Updated getters and setters using code automation. Sadly, this wiped out all the Javadoc. --- .../world/bentobox/bentobox/Settings.java | 593 ++++++------------ .../api/commands/island/IslandBanCommand.java | 2 +- .../commands/island/IslandResetCommand.java | 4 +- .../commands/island/IslandUnbanCommand.java | 4 +- .../island/team/IslandTeamCoopCommand.java | 2 +- .../island/team/IslandTeamInviteCommand.java | 2 +- .../island/team/IslandTeamKickCommand.java | 4 +- .../island/team/IslandTeamTrustCommand.java | 2 +- .../island/team/IslandTeamUncoopCommand.java | 4 +- .../island/team/IslandTeamUntrustCommand.java | 4 +- .../database/mongodb/MongoDBDatabase.java | 10 +- .../database/mysql/MySQLDatabase.java | 10 +- .../admin/AdminClearResetsAllCommandTest.java | 2 +- .../admin/AdminDeleteCommandTest.java | 2 +- .../island/IslandResetCommandTest.java | 2 +- .../team/IslandTeamCoopCommandTest.java | 2 +- .../team/IslandTeamInviteCommandTest.java | 2 +- .../team/IslandTeamKickCommandTest.java | 2 +- .../team/IslandTeamLeaveCommandTest.java | 6 +- .../team/IslandTeamTrustCommandTest.java | 2 +- .../team/IslandTeamUncoopCommandTest.java | 2 +- .../team/IslandTeamUntrustCommandTest.java | 2 +- 22 files changed, 222 insertions(+), 443 deletions(-) diff --git a/src/main/java/world/bentobox/bentobox/Settings.java b/src/main/java/world/bentobox/bentobox/Settings.java index 34411aafc..02e2c69ca 100644 --- a/src/main/java/world/bentobox/bentobox/Settings.java +++ b/src/main/java/world/bentobox/bentobox/Settings.java @@ -49,17 +49,6 @@ public class Settings implements DataObject { @ConfigEntry(path = "general.starting-money") private double startingMoney = 10.0; - // Purge - @ConfigComment("Only islands below this level will be removed if they are abandoned and admins issue the purge command") - @ConfigEntry(path = "general.purge.max-island-level") - private int purgeMaxIslandLevel = 50; - - @ConfigComment("Remove user data when its island gets purged.") - @ConfigComment("Helps a lot to avoid huge backups and can save some performance on startup,") - @ConfigComment("but the player settings and data will be reset.") - @ConfigEntry(path = "general.purge.remove-user-data") - private boolean purgeRemoveUserData = false; - // Database @ConfigComment("FLATFILE, MYSQL, MONGO") @ConfigComment("if you use MONGO, you must also run the BSBMongo plugin (not addon)") @@ -68,20 +57,20 @@ public class Settings implements DataObject { private DatabaseType databaseType = DatabaseType.FLATFILE; @ConfigEntry(path = "general.database.host") - private String dbHost = "localhost"; + private String databaseHost = "localhost"; @ConfigComment("Port 3306 is MySQL's default. Port 27017 is MongoDB's default.") @ConfigEntry(path = "general.database.port") - private int dbPort = 3306; + private int databasePort = 3306; @ConfigEntry(path = "general.database.name") - private String dbName = "bentobox"; + private String databaseName = "bentobox"; @ConfigEntry(path = "general.database.username") - private String dbUsername = "username"; + private String databaseUsername = "username"; @ConfigEntry(path = "general.database.password") - private String dbPassword = "password"; + private String databasePassword = "password"; @ConfigComment("How often the data will be saved to file in mins. Default is 5 minutes.") @ConfigComment("This helps prevent issues if the server crashes.") @@ -100,10 +89,6 @@ public class Settings implements DataObject { @ConfigComment("island unnecessarily.") @ConfigEntry(path = "general.allow-obsidian-scooping") private boolean allowObsidianScooping = true; - - @ConfigComment("Time in seconds that players have to confirm sensitive commands, e.g. island reset") - @ConfigEntry(path = "general.confirmation-time") - private int confirmationTime = 20; @ConfigComment("Rank required to use a command. e.g., use the invite command. Default is owner rank is required.") @ConfigEntry(path = "general.rank-command") @@ -115,46 +100,44 @@ public class Settings implements DataObject { /* * Island */ - // Invites + // Cooldowns @ConfigComment("How long a player must wait until they can rejoin a team island after being") @ConfigComment("kicked in minutes. This slows the effectiveness of players repeating challenges") @ConfigComment("by repetitively being invited to a team island.") - @ConfigEntry(path = "island.invite-wait") - private int inviteWait = 60; + @ConfigEntry(path = "island.cooldown.invite") + private int inviteCooldown = 60; + + @ConfigComment("How long a player must wait until they can ban a player") + @ConfigComment("after unbanning them. In minutes.") + @ConfigEntry(path = "island.cooldown.ban") + private int banCooldown = 10; + + @ConfigComment("How long a player must wait before they can reset their island again in seconds.") + @ConfigEntry(path = "island.cooldown.reset") + private int resetCooldown = 300; // Timeout for team kick and leave commands + @ConfigComment("Time in seconds that players have to confirm sensitive commands, e.g. island reset") + @ConfigEntry(path = "island.confirmation.time") + private int confirmationTime = 10; + @ConfigComment("Ask the player to confirm the command he is using by typing it again.") @ConfigComment("The 'wait' value is the number of seconds to wait for confirmation.") - @ConfigEntry(path = "island.require-confirmation.kick") + @ConfigEntry(path = "island.confirmation.commands.kick") private boolean kickConfirmation = true; - @ConfigEntry(path = "island.require-confirmation.kick-wait") - private int kickWait = 10; - - @ConfigEntry(path = "island.require-confirmation.leave") + @ConfigEntry(path = "island.confirmation.commands.leave") private boolean leaveConfirmation = true; - @ConfigEntry(path = "island.require-confirmation.leave-wait") - private int leaveWait = 10; - - @ConfigEntry(path = "island.require-confirmation.reset") + @ConfigEntry(path = "island.confirmation.commands.reset") private boolean resetConfirmation = true; - @ConfigComment("How long a player must wait before they can reset their island again in seconds") - @ConfigEntry(path = "island.reset-wait") - private int resetWait = 300; - @ConfigComment("These set the minimum and maximum size of a name.") @ConfigEntry(path = "island.name.min-length") private int nameMinLength = 4; @ConfigEntry(path = "island.name.max-length") private int nameMaxLength = 20; - @ConfigComment("How long a player must wait until they can ban a player") - @ConfigComment("after unbanning them. In minutes.") - @ConfigEntry(path = "island.ban-wait") - private int banWait = 10; - // Ranks @ConfigEntry(path = "island.customranks") private Map customRanks = new HashMap<>(); @@ -163,123 +146,216 @@ public class Settings implements DataObject { @ConfigComment("These settings should not be edited") private String uniqueId = "config"; - /** - * @return the metrics - */ + //---------------------------------------------------------------------------------------/ + // Getters and setters + + public boolean isMetrics() { return metrics; } - /** - * @return the defaultLanguage - */ + public void setMetrics(boolean metrics) { + this.metrics = metrics; + } + public String getDefaultLanguage() { return defaultLanguage; } - /** - * @return the useEconomy - */ + public void setDefaultLanguage(String defaultLanguage) { + this.defaultLanguage = defaultLanguage; + } + public boolean isUseEconomy() { return useEconomy; } - /** - * @return the startingMoney - */ + public void setUseEconomy(boolean useEconomy) { + this.useEconomy = useEconomy; + } + public double getStartingMoney() { return startingMoney; } - /** - * @return the purgeMaxIslandLevel - */ - public int getPurgeMaxIslandLevel() { - return purgeMaxIslandLevel; + public void setStartingMoney(double startingMoney) { + this.startingMoney = startingMoney; } - /** - * @return the purgeRemoveUserData - */ - public boolean isPurgeRemoveUserData() { - return purgeRemoveUserData; - } - - /** - * @return the databaseType - */ public DatabaseType getDatabaseType() { return databaseType; } - /** - * @return the dbHost - */ - public String getDbHost() { - return dbHost; + public void setDatabaseType(DatabaseType databaseType) { + this.databaseType = databaseType; } - /** - * @return the dbPort - */ - public int getDbPort() { - return dbPort; + public String getDatabaseHost() { + return databaseHost; } - /** - * @return the dbName - */ - public String getDbName() { - return dbName; + public void setDatabaseHost(String databaseHost) { + this.databaseHost = databaseHost; } - /** - * @return the dbUsername - */ - public String getDbUsername() { - return dbUsername; + public int getDatabasePort() { + return databasePort; } - /** - * @return the dbPassword - */ - public String getDbPassword() { - return dbPassword; + public void setDatabasePort(int databasePort) { + this.databasePort = databasePort; + } + + public String getDatabaseName() { + return databaseName; + } + + public void setDatabaseName(String databaseName) { + this.databaseName = databaseName; + } + + public String getDatabaseUsername() { + return databaseUsername; + } + + public void setDatabaseUsername(String databaseUsername) { + this.databaseUsername = databaseUsername; + } + + public String getDatabasePassword() { + return databasePassword; + } + + public void setDatabasePassword(String databasePassword) { + this.databasePassword = databasePassword; } - /** - * @return the databaseBackupPeriod - */ public int getDatabaseBackupPeriod() { return databaseBackupPeriod; } - /** - * @return the fakePlayers - */ + public void setDatabaseBackupPeriod(int databaseBackupPeriod) { + this.databaseBackupPeriod = databaseBackupPeriod; + } + public Set getFakePlayers() { return fakePlayers; } - /** - * @return the allowObsidianScooping - */ + public void setFakePlayers(Set fakePlayers) { + this.fakePlayers = fakePlayers; + } + public boolean isAllowObsidianScooping() { return allowObsidianScooping; } - /** - * @return the confirmationTime - */ + public void setAllowObsidianScooping(boolean allowObsidianScooping) { + this.allowObsidianScooping = allowObsidianScooping; + } + + public Map getRankCommand() { + return rankCommand; + } + + public int getRankCommand(String command) { + return rankCommand.getOrDefault(command, RanksManager.OWNER_RANK); + } + + public void setRankCommand(String command, int rank) { + rankCommand.put(command, rank); + } + + public void setRankCommand(Map rankCommand) { + this.rankCommand = rankCommand; + } + + public boolean isClosePanelOnClickOutside() { + return closePanelOnClickOutside; + } + + public void setClosePanelOnClickOutside(boolean closePanelOnClickOutside) { + this.closePanelOnClickOutside = closePanelOnClickOutside; + } + + public int getInviteCooldown() { + return inviteCooldown; + } + + public void setInviteCooldown(int inviteCooldown) { + this.inviteCooldown = inviteCooldown; + } + + public int getBanCooldown() { + return banCooldown; + } + + public void setBanCooldown(int banCooldown) { + this.banCooldown = banCooldown; + } + + public int getResetCooldown() { + return resetCooldown; + } + + public void setResetCooldown(int resetCooldown) { + this.resetCooldown = resetCooldown; + } + public int getConfirmationTime() { return confirmationTime; } - /** - * @return the closePanelOnClickOutside - */ - public boolean isClosePanelOnClickOutside() { - return closePanelOnClickOutside; + public void setConfirmationTime(int confirmationTime) { + this.confirmationTime = confirmationTime; + } + + public boolean isKickConfirmation() { + return kickConfirmation; + } + + public void setKickConfirmation(boolean kickConfirmation) { + this.kickConfirmation = kickConfirmation; + } + + public boolean isLeaveConfirmation() { + return leaveConfirmation; + } + + public void setLeaveConfirmation(boolean leaveConfirmation) { + this.leaveConfirmation = leaveConfirmation; + } + + public boolean isResetConfirmation() { + return resetConfirmation; + } + + public void setResetConfirmation(boolean resetConfirmation) { + this.resetConfirmation = resetConfirmation; + } + + public int getNameMinLength() { + return nameMinLength; + } + + public void setNameMinLength(int nameMinLength) { + this.nameMinLength = nameMinLength; + } + + public int getNameMaxLength() { + return nameMaxLength; + } + + public void setNameMaxLength(int nameMaxLength) { + this.nameMaxLength = nameMaxLength; + } + + public Map getCustomRanks() { + return customRanks; + } + + public void setCustomRanks(Map customRanks) { + this.customRanks = customRanks; } /** @@ -290,125 +366,6 @@ public class Settings implements DataObject { return uniqueId; } - /** - * @param metrics the metrics to set - */ - public void setMetrics(boolean metrics) { - this.metrics = metrics; - } - - /** - * @param defaultLanguage the defaultLanguage to set - */ - public void setDefaultLanguage(String defaultLanguage) { - this.defaultLanguage = defaultLanguage; - } - - /** - * @param useEconomy the useEconomy to set - */ - public void setUseEconomy(boolean useEconomy) { - this.useEconomy = useEconomy; - } - - /** - * @param startingMoney the startingMoney to set - */ - public void setStartingMoney(double startingMoney) { - this.startingMoney = startingMoney; - } - - /** - * @param purgeMaxIslandLevel the purgeMaxIslandLevel to set - */ - public void setPurgeMaxIslandLevel(int purgeMaxIslandLevel) { - this.purgeMaxIslandLevel = purgeMaxIslandLevel; - } - - /** - * @param purgeRemoveUserData the purgeRemoveUserData to set - */ - public void setPurgeRemoveUserData(boolean purgeRemoveUserData) { - this.purgeRemoveUserData = purgeRemoveUserData; - } - - /** - * @param databaseType the databaseType to set - */ - public void setDatabaseType(DatabaseType databaseType) { - this.databaseType = databaseType; - } - - /** - * @param dbHost the dbHost to set - */ - public void setDbHost(String dbHost) { - this.dbHost = dbHost; - } - - /** - * @param dbPort the dbPort to set - */ - public void setDbPort(int dbPort) { - this.dbPort = dbPort; - } - - /** - * @param dbName the dbName to set - */ - public void setDbName(String dbName) { - this.dbName = dbName; - } - - /** - * @param dbUsername the dbUsername to set - */ - public void setDbUsername(String dbUsername) { - this.dbUsername = dbUsername; - } - - /** - * @param dbPassword the dbPassword to set - */ - public void setDbPassword(String dbPassword) { - this.dbPassword = dbPassword; - } - - /** - * @param databaseBackupPeriod the databaseBackupPeriod to set - */ - public void setDatabaseBackupPeriod(int databaseBackupPeriod) { - this.databaseBackupPeriod = databaseBackupPeriod; - } - - /** - * @param fakePlayers the fakePlayers to set - */ - public void setFakePlayers(Set fakePlayers) { - this.fakePlayers = fakePlayers; - } - - /** - * @param allowObsidianScooping the allowObsidianScooping to set - */ - public void setAllowObsidianScooping(boolean allowObsidianScooping) { - this.allowObsidianScooping = allowObsidianScooping; - } - - /** - * @param confirmationTime the confirmationTime to set - */ - public void setConfirmationTime(int confirmationTime) { - this.confirmationTime = confirmationTime; - } - - /** - * @param closePanelOnClickOutside the closePanelOnClickOutside to set - */ - public void setClosePanelOnClickOutside(boolean closePanelOnClickOutside) { - this.closePanelOnClickOutside = closePanelOnClickOutside; - } - /** * @param uniqueId the uniqueId to set */ @@ -417,182 +374,4 @@ public class Settings implements DataObject { this.uniqueId = uniqueId; } - /** - * @return the customRanks - */ - public Map getCustomRanks() { - return customRanks; - } - - /** - * @param customRanks the customRanks to set - */ - public void setCustomRanks(Map customRanks) { - this.customRanks = customRanks; - } - - /** - * @return the inviteWait - */ - public int getInviteWait() { - return inviteWait; - } - - /** - * @param inviteWait the inviteWait to set - */ - public void setInviteWait(int inviteWait) { - this.inviteWait = inviteWait; - } - - /** - * @return the kickConfirmation - */ - public boolean isKickConfirmation() { - return kickConfirmation; - } - - /** - * @return the kickWait - */ - public int getKickWait() { - return kickWait; - } - - /** - * @return the leaveConfirmation - */ - public boolean isLeaveConfirmation() { - return leaveConfirmation; - } - - /** - * @return the leaveWait - */ - public int getLeaveWait() { - return leaveWait; - } - - /** - * @param kickConfirmation the kickConfirmation to set - */ - public void setKickConfirmation(boolean kickConfirmation) { - this.kickConfirmation = kickConfirmation; - } - - /** - * @param kickWait the kickWait to set - */ - public void setKickWait(int kickWait) { - this.kickWait = kickWait; - } - - /** - * @param leaveConfirmation the leaveConfirmation to set - */ - public void setLeaveConfirmation(boolean leaveConfirmation) { - this.leaveConfirmation = leaveConfirmation; - } - - /** - * @param leaveWait the leaveWait to set - */ - public void setLeaveWait(int leaveWait) { - this.leaveWait = leaveWait; - } - - /** - * @return the resetWait - */ - public int getResetWait() { - return resetWait; - } - - /** - * @param resetWait the resetWait to set - */ - public void setResetWait(int resetWait) { - this.resetWait = resetWait; - } - - /** - * @return the resetConfirmation - */ - public boolean isResetConfirmation() { - return resetConfirmation; - } - - /** - * @param resetConfirmation the resetConfirmation to set - */ - public void setResetConfirmation(boolean resetConfirmation) { - this.resetConfirmation = resetConfirmation; - } - - /** - * @return the nameMinLength - */ - public int getNameMinLength() { - return nameMinLength; - } - - /** - * @return the nameMaxLength - */ - public int getNameMaxLength() { - return nameMaxLength; - } - - /** - * @param nameMinLength the nameMinLength to set - */ - public void setNameMinLength(int nameMinLength) { - this.nameMinLength = nameMinLength; - } - - /** - * @param nameMaxLength the nameMaxLength to set - */ - public void setNameMaxLength(int nameMaxLength) { - this.nameMaxLength = nameMaxLength; - } - - /** - * @return the banWait - */ - public int getBanWait() { - return banWait; - } - - /** - * @param banWait the banWait to set - */ - public void setBanWait(int banWait) { - this.banWait = banWait; - } - - public int getRankCommand(String command) { - return rankCommand.getOrDefault(command, RanksManager.OWNER_RANK); - - } - - public void setRankCommand(String command, int rank) { - rankCommand.put(command, rank); - - } - - /** - * @return the rankCommand - */ - public Map getRankCommand() { - return rankCommand; - } - - /** - * @param rankCommand the rankCommand to set - */ - public void setRankCommand(Map rankCommand) { - this.rankCommand = rankCommand; - } - } \ No newline at end of file diff --git a/src/main/java/world/bentobox/bentobox/api/commands/island/IslandBanCommand.java b/src/main/java/world/bentobox/bentobox/api/commands/island/IslandBanCommand.java index ba7d37937..6b139eac4 100644 --- a/src/main/java/world/bentobox/bentobox/api/commands/island/IslandBanCommand.java +++ b/src/main/java/world/bentobox/bentobox/api/commands/island/IslandBanCommand.java @@ -67,7 +67,7 @@ public class IslandBanCommand extends CompositeCommand { user.sendMessage("commands.island.ban.player-already-banned"); return false; } - if (getSettings().getBanWait() > 0 && checkCooldown(user, targetUUID)) { + if (getSettings().getBanCooldown() > 0 && checkCooldown(user, targetUUID)) { return false; } User target = User.getInstance(targetUUID); diff --git a/src/main/java/world/bentobox/bentobox/api/commands/island/IslandResetCommand.java b/src/main/java/world/bentobox/bentobox/api/commands/island/IslandResetCommand.java index 2105faa99..b8f3b1ab3 100644 --- a/src/main/java/world/bentobox/bentobox/api/commands/island/IslandResetCommand.java +++ b/src/main/java/world/bentobox/bentobox/api/commands/island/IslandResetCommand.java @@ -30,7 +30,7 @@ public class IslandResetCommand extends ConfirmableCommand { @Override public boolean execute(User user, String label, List args) { // Check cooldown - if (getSettings().getResetWait() > 0 && checkCooldown(user, null)) { + if (getSettings().getResetCooldown() > 0 && checkCooldown(user, null)) { return false; } @@ -98,7 +98,7 @@ public class IslandResetCommand extends ConfirmableCommand { user.sendMessage("commands.island.create.unable-create-island"); return false; } - setCooldown(user.getUniqueId(), null, getSettings().getResetWait()); + setCooldown(user.getUniqueId(), null, getSettings().getResetCooldown()); return true; } } diff --git a/src/main/java/world/bentobox/bentobox/api/commands/island/IslandUnbanCommand.java b/src/main/java/world/bentobox/bentobox/api/commands/island/IslandUnbanCommand.java index 773a0722d..755beaebf 100644 --- a/src/main/java/world/bentobox/bentobox/api/commands/island/IslandUnbanCommand.java +++ b/src/main/java/world/bentobox/bentobox/api/commands/island/IslandUnbanCommand.java @@ -69,9 +69,9 @@ public class IslandUnbanCommand extends CompositeCommand { user.sendMessage("general.success"); targetUser.sendMessage("commands.island.unban.you-are-unbanned", TextVariables.NAME, user.getName()); // Set cooldown - if (getSettings().getBanWait() > 0 && getParent() != null) { + if (getSettings().getBanCooldown() > 0 && getParent() != null) { getParent().getSubCommand("ban").ifPresent(subCommand -> - subCommand.setCooldown(user.getUniqueId(), targetUser.getUniqueId(), getSettings().getBanWait() * 60)); + subCommand.setCooldown(user.getUniqueId(), targetUser.getUniqueId(), getSettings().getBanCooldown() * 60)); } return true; } diff --git a/src/main/java/world/bentobox/bentobox/api/commands/island/team/IslandTeamCoopCommand.java b/src/main/java/world/bentobox/bentobox/api/commands/island/team/IslandTeamCoopCommand.java index c16cf76a5..af17a6ce5 100644 --- a/src/main/java/world/bentobox/bentobox/api/commands/island/team/IslandTeamCoopCommand.java +++ b/src/main/java/world/bentobox/bentobox/api/commands/island/team/IslandTeamCoopCommand.java @@ -54,7 +54,7 @@ public class IslandTeamCoopCommand extends CompositeCommand { user.sendMessage("general.errors.unknown-player"); return false; } - return (getSettings().getInviteWait() <= 0 || !checkCooldown(user, targetUUID)) && coopCmd(user, targetUUID); + return (getSettings().getInviteCooldown() <= 0 || !checkCooldown(user, targetUUID)) && coopCmd(user, targetUUID); } private boolean coopCmd(User user, UUID targetUUID) { diff --git a/src/main/java/world/bentobox/bentobox/api/commands/island/team/IslandTeamInviteCommand.java b/src/main/java/world/bentobox/bentobox/api/commands/island/team/IslandTeamInviteCommand.java index 1ec8d379b..2b93caf37 100644 --- a/src/main/java/world/bentobox/bentobox/api/commands/island/team/IslandTeamInviteCommand.java +++ b/src/main/java/world/bentobox/bentobox/api/commands/island/team/IslandTeamInviteCommand.java @@ -76,7 +76,7 @@ public class IslandTeamInviteCommand extends CompositeCommand { return false; } // Check cool down - if (getSettings().getInviteWait() > 0 && checkCooldown(user, invitedPlayerUUID)) { + if (getSettings().getInviteCooldown() > 0 && checkCooldown(user, invitedPlayerUUID)) { return false; } // Player cannot invite someone already on a team diff --git a/src/main/java/world/bentobox/bentobox/api/commands/island/team/IslandTeamKickCommand.java b/src/main/java/world/bentobox/bentobox/api/commands/island/team/IslandTeamKickCommand.java index c6cc9c103..5656bae4a 100644 --- a/src/main/java/world/bentobox/bentobox/api/commands/island/team/IslandTeamKickCommand.java +++ b/src/main/java/world/bentobox/bentobox/api/commands/island/team/IslandTeamKickCommand.java @@ -76,9 +76,9 @@ public class IslandTeamKickCommand extends ConfirmableCommand { user.sendMessage("general.success"); // Add cooldown for this player and target - if (getSettings().getInviteWait() > 0 && getParent() != null) { + if (getSettings().getInviteCooldown() > 0 && getParent() != null) { // Get the invite class from the parent - getParent().getSubCommand("invite").ifPresent(c -> c.setCooldown(user.getUniqueId(), targetUUID, getSettings().getInviteWait() * 60)); + getParent().getSubCommand("invite").ifPresent(c -> c.setCooldown(user.getUniqueId(), targetUUID, getSettings().getInviteCooldown() * 60)); } } } \ No newline at end of file diff --git a/src/main/java/world/bentobox/bentobox/api/commands/island/team/IslandTeamTrustCommand.java b/src/main/java/world/bentobox/bentobox/api/commands/island/team/IslandTeamTrustCommand.java index 50152b665..78404297d 100644 --- a/src/main/java/world/bentobox/bentobox/api/commands/island/team/IslandTeamTrustCommand.java +++ b/src/main/java/world/bentobox/bentobox/api/commands/island/team/IslandTeamTrustCommand.java @@ -58,7 +58,7 @@ public class IslandTeamTrustCommand extends CompositeCommand { user.sendMessage("general.errors.unknown-player"); return false; } - return (getSettings().getInviteWait() <= 0 || !checkCooldown(user, targetUUID)) && trustCmd(user, targetUUID); + return (getSettings().getInviteCooldown() <= 0 || !checkCooldown(user, targetUUID)) && trustCmd(user, targetUUID); } private boolean trustCmd(User user, UUID targetUUID) { diff --git a/src/main/java/world/bentobox/bentobox/api/commands/island/team/IslandTeamUncoopCommand.java b/src/main/java/world/bentobox/bentobox/api/commands/island/team/IslandTeamUncoopCommand.java index c54f79861..eaccae5d2 100644 --- a/src/main/java/world/bentobox/bentobox/api/commands/island/team/IslandTeamUncoopCommand.java +++ b/src/main/java/world/bentobox/bentobox/api/commands/island/team/IslandTeamUncoopCommand.java @@ -84,9 +84,9 @@ public class IslandTeamUncoopCommand extends CompositeCommand { user.sendMessage("general.success"); target.sendMessage("commands.island.team.uncoop.you-are-no-longer-a-coop-member", TextVariables.NAME, user.getName()); // Set cooldown - if (getSettings().getInviteWait() > 0 && getParent() != null) { + if (getSettings().getInviteCooldown() > 0 && getParent() != null) { getParent().getSubCommand("coop").ifPresent(subCommand -> - subCommand.setCooldown(user.getUniqueId(), targetUUID, getSettings().getInviteWait() * 60)); + subCommand.setCooldown(user.getUniqueId(), targetUUID, getSettings().getInviteCooldown() * 60)); } return true; } else { diff --git a/src/main/java/world/bentobox/bentobox/api/commands/island/team/IslandTeamUntrustCommand.java b/src/main/java/world/bentobox/bentobox/api/commands/island/team/IslandTeamUntrustCommand.java index 6d369b574..e9dedb6fa 100644 --- a/src/main/java/world/bentobox/bentobox/api/commands/island/team/IslandTeamUntrustCommand.java +++ b/src/main/java/world/bentobox/bentobox/api/commands/island/team/IslandTeamUntrustCommand.java @@ -84,9 +84,9 @@ public class IslandTeamUntrustCommand extends CompositeCommand { user.sendMessage("general.success"); target.sendMessage("commands.island.team.untrust.you-are-no-longer-trusted", TextVariables.NAME, user.getName()); // Set cooldown - if (getSettings().getInviteWait() > 0 && getParent() != null) { + if (getSettings().getInviteCooldown() > 0 && getParent() != null) { getParent().getSubCommand("trust").ifPresent(subCommand -> - subCommand.setCooldown(user.getUniqueId(), targetUUID, getSettings().getInviteWait() * 60)); + subCommand.setCooldown(user.getUniqueId(), targetUUID, getSettings().getInviteCooldown() * 60)); } return true; } else { diff --git a/src/main/java/world/bentobox/bentobox/database/mongodb/MongoDBDatabase.java b/src/main/java/world/bentobox/bentobox/database/mongodb/MongoDBDatabase.java index 983db9617..527f80970 100644 --- a/src/main/java/world/bentobox/bentobox/database/mongodb/MongoDBDatabase.java +++ b/src/main/java/world/bentobox/bentobox/database/mongodb/MongoDBDatabase.java @@ -18,11 +18,11 @@ public class MongoDBDatabase implements DatabaseSetup { return null; } return new MongoDBDatabaseHandler<>(plugin, type, new MongoDBDatabaseConnector(new DatabaseConnectionSettingsImpl( - plugin.getSettings().getDbHost(), - plugin.getSettings().getDbPort(), - plugin.getSettings().getDbName(), - plugin.getSettings().getDbUsername(), - plugin.getSettings().getDbPassword() + plugin.getSettings().getDatabaseHost(), + plugin.getSettings().getDatabasePort(), + plugin.getSettings().getDatabaseName(), + plugin.getSettings().getDatabaseUsername(), + plugin.getSettings().getDatabasePassword() ))); } diff --git a/src/main/java/world/bentobox/bentobox/database/mysql/MySQLDatabase.java b/src/main/java/world/bentobox/bentobox/database/mysql/MySQLDatabase.java index 55e74422e..f7bdf68ca 100644 --- a/src/main/java/world/bentobox/bentobox/database/mysql/MySQLDatabase.java +++ b/src/main/java/world/bentobox/bentobox/database/mysql/MySQLDatabase.java @@ -15,11 +15,11 @@ public class MySQLDatabase implements DatabaseSetup { public AbstractDatabaseHandler getHandler(Class type) { BentoBox plugin = BentoBox.getInstance(); return new MySQLDatabaseHandler<>(plugin, type, new MySQLDatabaseConnector(new DatabaseConnectionSettingsImpl( - plugin.getSettings().getDbHost(), - plugin.getSettings().getDbPort(), - plugin.getSettings().getDbName(), - plugin.getSettings().getDbUsername(), - plugin.getSettings().getDbPassword() + plugin.getSettings().getDatabaseHost(), + plugin.getSettings().getDatabasePort(), + plugin.getSettings().getDatabaseName(), + plugin.getSettings().getDatabaseUsername(), + plugin.getSettings().getDatabasePassword() ))); } diff --git a/src/test/java/world/bentobox/bentobox/api/commands/admin/AdminClearResetsAllCommandTest.java b/src/test/java/world/bentobox/bentobox/api/commands/admin/AdminClearResetsAllCommandTest.java index a8bc02f15..071519458 100644 --- a/src/test/java/world/bentobox/bentobox/api/commands/admin/AdminClearResetsAllCommandTest.java +++ b/src/test/java/world/bentobox/bentobox/api/commands/admin/AdminClearResetsAllCommandTest.java @@ -54,7 +54,7 @@ public class AdminClearResetsAllCommandTest { // Settings Settings s = mock(Settings.class); - when(s.getResetWait()).thenReturn(0); + when(s.getResetCooldown()).thenReturn(0); when(plugin.getSettings()).thenReturn(s); // Player diff --git a/src/test/java/world/bentobox/bentobox/api/commands/admin/AdminDeleteCommandTest.java b/src/test/java/world/bentobox/bentobox/api/commands/admin/AdminDeleteCommandTest.java index 9b3ad2a87..ee41945c2 100644 --- a/src/test/java/world/bentobox/bentobox/api/commands/admin/AdminDeleteCommandTest.java +++ b/src/test/java/world/bentobox/bentobox/api/commands/admin/AdminDeleteCommandTest.java @@ -67,7 +67,7 @@ public class AdminDeleteCommandTest { // Settings Settings s = mock(Settings.class); - when(s.getResetWait()).thenReturn(0); + when(s.getResetCooldown()).thenReturn(0); when(plugin.getSettings()).thenReturn(s); // Player diff --git a/src/test/java/world/bentobox/bentobox/api/commands/island/IslandResetCommandTest.java b/src/test/java/world/bentobox/bentobox/api/commands/island/IslandResetCommandTest.java index 9eceb143e..82a9bb7df 100644 --- a/src/test/java/world/bentobox/bentobox/api/commands/island/IslandResetCommandTest.java +++ b/src/test/java/world/bentobox/bentobox/api/commands/island/IslandResetCommandTest.java @@ -70,7 +70,7 @@ public class IslandResetCommandTest { // Settings s = mock(Settings.class); - when(s.getResetWait()).thenReturn(0); + when(s.getResetCooldown()).thenReturn(0); when(plugin.getSettings()).thenReturn(s); // Player diff --git a/src/test/java/world/bentobox/bentobox/api/commands/island/team/IslandTeamCoopCommandTest.java b/src/test/java/world/bentobox/bentobox/api/commands/island/team/IslandTeamCoopCommandTest.java index 13cc7ab3f..0bac8bf5c 100644 --- a/src/test/java/world/bentobox/bentobox/api/commands/island/team/IslandTeamCoopCommandTest.java +++ b/src/test/java/world/bentobox/bentobox/api/commands/island/team/IslandTeamCoopCommandTest.java @@ -209,7 +209,7 @@ public class IslandTeamCoopCommandTest { @Test public void testExecuteCoolDownActive() { // 10 minutes = 600 seconds - when(s.getInviteWait()).thenReturn(10); + when(s.getInviteCooldown()).thenReturn(10); IslandTeamCoopCommand itl = new IslandTeamCoopCommand(ic); String[] name = {"tastybento"}; itl.execute(user, itl.getLabel(), Arrays.asList(name)); diff --git a/src/test/java/world/bentobox/bentobox/api/commands/island/team/IslandTeamInviteCommandTest.java b/src/test/java/world/bentobox/bentobox/api/commands/island/team/IslandTeamInviteCommandTest.java index bf6c727ba..da66dba8d 100644 --- a/src/test/java/world/bentobox/bentobox/api/commands/island/team/IslandTeamInviteCommandTest.java +++ b/src/test/java/world/bentobox/bentobox/api/commands/island/team/IslandTeamInviteCommandTest.java @@ -224,7 +224,7 @@ public class IslandTeamInviteCommandTest { @Test public void testExecuteCoolDownActive() { // 10 minutes = 600 seconds - when(s.getInviteWait()).thenReturn(10); + when(s.getInviteCooldown()).thenReturn(10); IslandTeamInviteCommand itl = new IslandTeamInviteCommand(ic); String[] name = {"tastybento"}; itl.execute(user, itl.getLabel(), Arrays.asList(name)); diff --git a/src/test/java/world/bentobox/bentobox/api/commands/island/team/IslandTeamKickCommandTest.java b/src/test/java/world/bentobox/bentobox/api/commands/island/team/IslandTeamKickCommandTest.java index 51cb08957..c0f0830c7 100644 --- a/src/test/java/world/bentobox/bentobox/api/commands/island/team/IslandTeamKickCommandTest.java +++ b/src/test/java/world/bentobox/bentobox/api/commands/island/team/IslandTeamKickCommandTest.java @@ -275,7 +275,7 @@ public class IslandTeamKickCommandTest { @Test public void testCooldown() { // 10 minutes = 600 seconds - when(s.getInviteWait()).thenReturn(10); + when(s.getInviteCooldown()).thenReturn(10); testExecuteNoConfirmation(); Mockito.verify(subCommand).setCooldown(uuid, notUUID, 600); } diff --git a/src/test/java/world/bentobox/bentobox/api/commands/island/team/IslandTeamLeaveCommandTest.java b/src/test/java/world/bentobox/bentobox/api/commands/island/team/IslandTeamLeaveCommandTest.java index fe8fcb10e..37cbbe131 100644 --- a/src/test/java/world/bentobox/bentobox/api/commands/island/team/IslandTeamLeaveCommandTest.java +++ b/src/test/java/world/bentobox/bentobox/api/commands/island/team/IslandTeamLeaveCommandTest.java @@ -66,7 +66,7 @@ public class IslandTeamLeaveCommandTest { // Settings s = mock(Settings.class); - when(s.getResetWait()).thenReturn(0); + when(s.getResetCooldown()).thenReturn(0); when(plugin.getSettings()).thenReturn(s); // Player @@ -149,7 +149,7 @@ public class IslandTeamLeaveCommandTest { public void testExecuteWithConfirmation() { when(s.isLeaveConfirmation()).thenReturn(true); // 3 second timeout - when(s.getLeaveWait()).thenReturn(3); + when(s.getConfirmationTime()).thenReturn(3); when(im.hasIsland(Mockito.any(), Mockito.eq(uuid))).thenReturn(false); when(im.isOwner(Mockito.any(), Mockito.eq(uuid))).thenReturn(false); // Add a team leader - null @@ -158,7 +158,7 @@ public class IslandTeamLeaveCommandTest { IslandTeamLeaveCommand itl = new IslandTeamLeaveCommand(ic); assertFalse(itl.execute(user, itl.getLabel(), new ArrayList<>())); // Confirmation required - Mockito.verify(user).sendMessage(Mockito.eq("commands.confirmation.confirm"), Mockito.eq("[seconds]"), Mockito.eq("0")); + Mockito.verify(user).sendMessage(Mockito.eq("commands.confirmation.confirm"), Mockito.eq("[seconds]"), Mockito.eq("3")); } /** diff --git a/src/test/java/world/bentobox/bentobox/api/commands/island/team/IslandTeamTrustCommandTest.java b/src/test/java/world/bentobox/bentobox/api/commands/island/team/IslandTeamTrustCommandTest.java index 971fa5f9c..882943cbd 100644 --- a/src/test/java/world/bentobox/bentobox/api/commands/island/team/IslandTeamTrustCommandTest.java +++ b/src/test/java/world/bentobox/bentobox/api/commands/island/team/IslandTeamTrustCommandTest.java @@ -209,7 +209,7 @@ public class IslandTeamTrustCommandTest { @Test public void testExecuteCoolDownActive() { // 10 minutes = 600 seconds - when(s.getInviteWait()).thenReturn(10); + when(s.getInviteCooldown()).thenReturn(10); IslandTeamTrustCommand itl = new IslandTeamTrustCommand(ic); String[] name = {"tastybento"}; itl.execute(user, itl.getLabel(), Arrays.asList(name)); diff --git a/src/test/java/world/bentobox/bentobox/api/commands/island/team/IslandTeamUncoopCommandTest.java b/src/test/java/world/bentobox/bentobox/api/commands/island/team/IslandTeamUncoopCommandTest.java index 9ab9eaa23..414ec8794 100644 --- a/src/test/java/world/bentobox/bentobox/api/commands/island/team/IslandTeamUncoopCommandTest.java +++ b/src/test/java/world/bentobox/bentobox/api/commands/island/team/IslandTeamUncoopCommandTest.java @@ -209,7 +209,7 @@ public class IslandTeamUncoopCommandTest { @Test public void testExecuteCoolDownActive() { // 10 minutes = 600 seconds - when(s.getInviteWait()).thenReturn(10); + when(s.getInviteCooldown()).thenReturn(10); IslandTeamUncoopCommand itl = new IslandTeamUncoopCommand(ic); String[] name = {"tastybento"}; itl.execute(user, itl.getLabel(), Arrays.asList(name)); diff --git a/src/test/java/world/bentobox/bentobox/api/commands/island/team/IslandTeamUntrustCommandTest.java b/src/test/java/world/bentobox/bentobox/api/commands/island/team/IslandTeamUntrustCommandTest.java index ac0d42cbc..9f175b813 100644 --- a/src/test/java/world/bentobox/bentobox/api/commands/island/team/IslandTeamUntrustCommandTest.java +++ b/src/test/java/world/bentobox/bentobox/api/commands/island/team/IslandTeamUntrustCommandTest.java @@ -209,7 +209,7 @@ public class IslandTeamUntrustCommandTest { @Test public void testExecuteCoolDownActive() { // 10 minutes = 600 seconds - when(s.getInviteWait()).thenReturn(10); + when(s.getInviteCooldown()).thenReturn(10); IslandTeamUntrustCommand itl = new IslandTeamUntrustCommand(ic); String[] name = {"tastybento"}; itl.execute(user, itl.getLabel(), Arrays.asList(name));