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.<command>` to `island.confirmation.commands.<command>`.
Updated tests.
Updated getters and setters using code automation. Sadly, this wiped out all the Javadoc.
This commit is contained in:
Florian CUNY 2018-08-31 11:06:37 +02:00
parent 4203ce85b4
commit 24d783be24
22 changed files with 222 additions and 443 deletions

View File

@ -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<String, Integer> 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<String> getFakePlayers() {
return fakePlayers;
}
/**
* @return the allowObsidianScooping
*/
public void setFakePlayers(Set<String> fakePlayers) {
this.fakePlayers = fakePlayers;
}
public boolean isAllowObsidianScooping() {
return allowObsidianScooping;
}
/**
* @return the confirmationTime
*/
public void setAllowObsidianScooping(boolean allowObsidianScooping) {
this.allowObsidianScooping = allowObsidianScooping;
}
public Map<String, Integer> 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<String, Integer> 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<String, Integer> getCustomRanks() {
return customRanks;
}
public void setCustomRanks(Map<String, Integer> 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<String> 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<String, Integer> getCustomRanks() {
return customRanks;
}
/**
* @param customRanks the customRanks to set
*/
public void setCustomRanks(Map<String, Integer> 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<String, Integer> getRankCommand() {
return rankCommand;
}
/**
* @param rankCommand the rankCommand to set
*/
public void setRankCommand(Map<String, Integer> rankCommand) {
this.rankCommand = rankCommand;
}
}

View File

@ -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);

View File

@ -30,7 +30,7 @@ public class IslandResetCommand extends ConfirmableCommand {
@Override
public boolean execute(User user, String label, List<String> 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;
}
}

View File

@ -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;
}

View File

@ -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) {

View File

@ -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

View File

@ -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));
}
}
}

View File

@ -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) {

View File

@ -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 {

View File

@ -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 {

View File

@ -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()
)));
}

View File

@ -15,11 +15,11 @@ public class MySQLDatabase implements DatabaseSetup {
public <T> AbstractDatabaseHandler<T> getHandler(Class<T> 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()
)));
}

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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));

View File

@ -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));

View File

@ -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);
}

View File

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

View File

@ -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));

View File

@ -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));

View File

@ -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));