Added option to apply the reset cooldown when the player creates an island for the first time

Closes #456.
This commit is contained in:
Florian CUNY 2019-01-27 10:10:25 +01:00
parent 9551560593
commit aea057317b
2 changed files with 17 additions and 1 deletions

View File

@ -119,6 +119,10 @@ public class Settings implements DataObject {
@ConfigEntry(path = "island.cooldown.time.reset")
private int resetCooldown = 300;
@ConfigComment("Whether the reset cooldown should be applied when the player creates an island for the first time or not.")
@ConfigEntry(path = "island.cooldown.options.set-reset-cooldown-on-create", since = "1.2.0")
private boolean resetCooldownOnCreate = true;
// 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")
@ -432,4 +436,12 @@ public class Settings implements DataObject {
public void setLogCleanSuperFlatChunks(boolean logCleanSuperFlatChunks) {
this.logCleanSuperFlatChunks = logCleanSuperFlatChunks;
}
public boolean isResetCooldownOnCreate() {
return resetCooldownOnCreate;
}
public void setResetCooldownOnCreate(boolean resetCooldownOnCreate) {
this.resetCooldownOnCreate = resetCooldownOnCreate;
}
}

View File

@ -73,11 +73,15 @@ public class IslandCreateCommand extends CompositeCommand {
.reason(Reason.CREATE)
.name(name)
.build();
return true;
} catch (IOException e) {
getPlugin().logError("Could not create island for player. " + e.getMessage());
user.sendMessage("commands.island.create.unable-create-island");
return false;
}
if (getSettings().isResetCooldownOnCreate()) {
getParent().getSubCommand("reset").ifPresent(resetCommand -> resetCommand.setCooldown(user.getUniqueId(), null, getSettings().getResetCooldown()));
}
return true;
}
}