add /rankup cooldown

This commit is contained in:
okx-code
2018-08-28 20:42:26 +01:00
parent 3fca80a79b
commit 923cc8918c
10 changed files with 59 additions and 16 deletions
@@ -7,6 +7,9 @@ class EmptyMessageBuilder extends MessageBuilder {
super(null);
}
/**
* what are you doing failing if empty when it has already failed?
*/
@Override
public MessageBuilder failIfEmpty() {
throw new UnsupportedOperationException();
@@ -14,7 +14,9 @@ public enum Message {
RANKS_FOOTER("rankup.ranks.footer"),
RANKS_COMPLETE("rankup.ranks.complete"),
RANKS_CURRENT("rankup.ranks.current"),
RANKS_INCOMPLETE("rankup.ranks.incomplete");
RANKS_INCOMPLETE("rankup.ranks.incomplete"),
COOLDOWN_SINGULAR("rankup.cooldown.singular"),
COOLDOWN_PLURAL("rankup.cooldown.plural");
@Getter
private final String name;
@@ -1,16 +1,12 @@
package sh.okx.rankup.messages;
import lombok.AllArgsConstructor;
import net.milkbowl.vault.economy.Economy;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.entity.Player;
import sh.okx.rankup.ranks.Rank;
import sh.okx.rankup.ranks.requirements.Requirement;
import java.text.DecimalFormat;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@@ -65,10 +61,11 @@ public class MessageBuilder {
/**
* Fails the MessageBuilder if the message is empty.
* if this fails, all subsequent calls to that MessageBuilder will do nothing
*
* @return an EmptyMessageBuilder if the message is empty, itself otherwise
*/
public MessageBuilder failIfEmpty() {
if(message.isEmpty()) {
if (message.isEmpty()) {
return new EmptyMessageBuilder();
} else {
return this;
@@ -84,7 +81,7 @@ public class MessageBuilder {
* ie, calls MessageBuilder#send(Player) for all players online, and sends the message in the console.
*/
public void broadcast() {
for(Player player : Bukkit.getOnlinePlayers()) {
for (Player player : Bukkit.getOnlinePlayers()) {
send(player);
}
send(Bukkit.getConsoleSender());
@@ -14,7 +14,8 @@ public enum Variable {
AMOUNT,
AMOUNT_NEEDED,
PERCENT_DONE,
PERCENT_LEFT;
PERCENT_LEFT,
SECONDS;
public String replace(String message, String value, String type) {
Pattern pattern = Pattern.compile("\\{" + type + "_" + this + "}", Pattern.CASE_INSENSITIVE);