mirror of
https://github.com/BentoBoxWorld/Level.git
synced 2024-12-27 03:28:31 +01:00
Merge pull request #32 from BONNe/cooldown
Implement CoolDown for calling level method.
This commit is contained in:
commit
e8f1f07104
@ -34,17 +34,39 @@ public class IslandLevelCommand extends CompositeCommand {
|
||||
user.sendMessage("general.errors.unknown-player");
|
||||
return true;
|
||||
} else if (user.getUniqueId().equals(playerUUID) ) {
|
||||
// Self level request
|
||||
levelPlugin.calculateIslandLevel(getWorld(), user, user.getUniqueId());
|
||||
return this.calculateLevel(user);
|
||||
} else {
|
||||
user.sendMessage("island.level.island-level-is", "[level]", String.valueOf(levelPlugin.getIslandLevel(getWorld(), playerUUID)));
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
// Self level request
|
||||
levelPlugin.calculateIslandLevel(getWorld(), user, user.getUniqueId());
|
||||
return this.calculateLevel(user);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* This method calls island level calculation if it is allowed by cooldown.
|
||||
* @param user User which island level must be calculated.
|
||||
* @return True if le
|
||||
*/
|
||||
private boolean calculateLevel(User user)
|
||||
{
|
||||
int coolDown = this.levelPlugin.getSettings().getLevelWait();
|
||||
|
||||
if (coolDown > 0 && this.checkCooldown(user, null))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// Self level request
|
||||
this.levelPlugin.calculateIslandLevel(getWorld(), user, user.getUniqueId());
|
||||
|
||||
if (coolDown > 0)
|
||||
{
|
||||
this.setCooldown(user.getUniqueId(), null, coolDown);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -167,7 +167,7 @@ public class Settings {
|
||||
/**
|
||||
* @return the levelWait
|
||||
*/
|
||||
private int getLevelWait() {
|
||||
public final int getLevelWait() {
|
||||
return levelWait;
|
||||
}
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user