3.11.2
This commit is contained in:
+1
-1
@@ -4,7 +4,7 @@ plugins {
|
||||
}
|
||||
|
||||
group 'sh.okx'
|
||||
version '3.11.1'
|
||||
version '3.11.2'
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
|
||||
@@ -519,15 +519,19 @@ public class RankupPlugin extends JavaPlugin {
|
||||
|
||||
public MessageBuilder getMessage(CommandSender player, Message message, Rank oldRank, Rank rankName) {
|
||||
String oldRankName;
|
||||
String oldRankDisplayName;
|
||||
if (oldRank instanceof Prestige && oldRank.getRank() == null) {
|
||||
oldRankName = ((Prestige) oldRank).getFrom();
|
||||
oldRankDisplayName = rankups.getTree().last().getRank().getDisplayName();
|
||||
} else {
|
||||
oldRankName = oldRank.getRank();
|
||||
oldRankDisplayName = oldRank.getDisplayName();
|
||||
}
|
||||
|
||||
return replaceMoneyRequirements(getMessage(oldRank, message)
|
||||
.replaceRanks(player, rankName)
|
||||
.replace(Variable.OLD_RANK, oldRankName), player, oldRank)
|
||||
.replace(Variable.OLD_RANK, oldRankName)
|
||||
.replace(Variable.OLD_RANK_NAME, oldRankDisplayName), player, oldRank)
|
||||
.replaceFromTo(oldRank);
|
||||
}
|
||||
|
||||
|
||||
@@ -201,7 +201,7 @@ public class InfoCommand implements TabExecutor {
|
||||
element = next;
|
||||
}
|
||||
return true;
|
||||
} else if (args[0].equalsIgnoreCase("playtime") && sender.hasPermission("rankup.playtime")) {
|
||||
} else if (args[0].equalsIgnoreCase("playtime") && (sender.hasPermission("rankup.playtime.get") || sender.hasPermission("rankup.playtime.set"))) {
|
||||
Statistic playOneTick;
|
||||
try {
|
||||
playOneTick = Statistic.valueOf("PLAY_ONE_MINUTE");
|
||||
@@ -211,7 +211,7 @@ public class InfoCommand implements TabExecutor {
|
||||
}
|
||||
|
||||
if (args.length > 1) {
|
||||
if (args[1].equalsIgnoreCase("get")) {
|
||||
if (args[1].equalsIgnoreCase("get") && sender.hasPermission("rankup.playtime.get")) {
|
||||
Player player;
|
||||
if (args.length > 2) {
|
||||
// pru playtime get Okx
|
||||
@@ -241,7 +241,7 @@ public class InfoCommand implements TabExecutor {
|
||||
}
|
||||
player.sendMessage(ChatColor.LIGHT_PURPLE + who + " played for " + minutes + " minutes.");
|
||||
return true;
|
||||
} else if (args[1].equalsIgnoreCase("set")) {
|
||||
} else if (args[1].equalsIgnoreCase("set") && sender.hasPermission("rankup.playtime.set")) {
|
||||
if (args.length < 4) {
|
||||
sender.sendMessage(ChatColor.GREEN + "/" + label + " " + args[0] + " set <player> <minutes>" + ChatColor.YELLOW + " Update the playtime statistic for a player");
|
||||
return true;
|
||||
@@ -266,8 +266,16 @@ public class InfoCommand implements TabExecutor {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
sender.sendMessage(ChatColor.GREEN + "/" + label + " " + args[0] + " get [player] " + ChatColor.YELLOW + " Get amount of minutes played");
|
||||
sender.sendMessage(ChatColor.GREEN + "/" + label + " " + args[0] + " set <player> <minutes>" + ChatColor.YELLOW + " Update the playtime statistic for a player");
|
||||
if (sender.hasPermission("rankup.playtime.get")) {
|
||||
sender.sendMessage(
|
||||
ChatColor.GREEN + "/" + label + " " + args[0] + " get [player] " + ChatColor.YELLOW
|
||||
+ " Get amount of minutes played");
|
||||
}
|
||||
if (sender.hasPermission("rankup.playtime.set")) {
|
||||
sender.sendMessage(
|
||||
ChatColor.GREEN + "/" + label + " " + args[0] + " set <player> <minutes>"
|
||||
+ ChatColor.YELLOW + " Update the playtime statistic for a player");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,7 +5,6 @@ import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
import java.util.function.Function;
|
||||
import lombok.Getter;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
@@ -28,12 +27,15 @@ public abstract class RankList<T extends Rank> {
|
||||
List<RankElement<T>> rankElements = new ArrayList<>();
|
||||
for (Map.Entry<String, Object> entry : config.getValues(false).entrySet()) {
|
||||
ConfigurationSection rankSection = (ConfigurationSection) entry.getValue();
|
||||
validateSection(rankSection);
|
||||
if (validateSection(rankSection)) {
|
||||
T apply = deserializer.apply(rankSection);
|
||||
if (apply != null) {
|
||||
// find next
|
||||
rankElements.add(findNext(apply, rankElements));
|
||||
}
|
||||
} else {
|
||||
plugin.getLogger().warning("Ignoring rank: " + entry.getKey());
|
||||
}
|
||||
}
|
||||
|
||||
for (RankElement<T> rankElement : rankElements) {
|
||||
@@ -70,23 +72,19 @@ public abstract class RankList<T extends Rank> {
|
||||
return currentElement;
|
||||
}
|
||||
|
||||
protected void validateSection(ConfigurationSection section) {
|
||||
protected boolean validateSection(ConfigurationSection section) {
|
||||
String name = "'" + section.getName() + "'";
|
||||
/*if (section.getConfigurationSection("requirements") != null) {
|
||||
throw new IllegalArgumentException(
|
||||
"Rankup/prestige section " + name + " is using the old requirements system.\n" +
|
||||
"Instead of a configuration section, it is now a list of strings.\n" +
|
||||
"For example, instead of \"requirements: money: 1000\" you should use \"requirements: - 'money 1000'\".");
|
||||
}*/
|
||||
Set<String> keys = section.getKeys(false);
|
||||
if (keys.size() == 1 && keys.iterator().next().equalsIgnoreCase("rank")) {
|
||||
throw new IllegalArgumentException(
|
||||
"Having a final rank (for example: \"Z: rank: 'Z'\") from 3.4.2 or earlier should no longer be used.\n"
|
||||
+
|
||||
"It is safe to just delete the final rank " + name + "");
|
||||
String nextField = section.getString("next");
|
||||
if (nextField == null || nextField.isEmpty()) {
|
||||
plugin.getLogger().warning("Rankup section " + name + " does not have a 'next' field.");
|
||||
plugin.getLogger().warning("Having a final rank (for example: \"Z: rank: 'Z'\") from 3.4.2 or earlier should no longer be used.");
|
||||
plugin.getLogger().warning("If this is intended as a final rank, you should delete " + name);
|
||||
return false;
|
||||
} else if (!section.contains("requirements")) {
|
||||
throw new IllegalArgumentException("Rank " + name + " does not have any requirements.");
|
||||
plugin.getLogger().warning("Rank " + name + " does not have any requirements.");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public T getFirst() {
|
||||
|
||||
@@ -14,8 +14,8 @@ public class Rankup extends Rank {
|
||||
String displayName = section.getString("display-name");
|
||||
|
||||
if (next == null || next.isEmpty()) {
|
||||
plugin.getLogger().warning("Having a final rank (for example: \"Z: rank: 'Z'\") from 3.4.2 or earlier should no longer be used.\n"
|
||||
+ "It is safe to just delete the final rank " + section.getName() + "");
|
||||
plugin.getLogger().warning("Having a final rank (for example: \"Z: rank: 'Z'\") from 3.4.2 or earlier should no longer be used.");
|
||||
plugin.getLogger().warning("It is safe to just delete the final rank " + section.getName() + "");
|
||||
plugin.getLogger().warning("Rankup section '" + section.getName() + "' has a blank 'next' field, will be ignored.");
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -69,7 +69,7 @@ public class RanksGui {
|
||||
rowIndex += 9;
|
||||
index += 9 - width;
|
||||
}
|
||||
if (index >= rows * 9) {
|
||||
if (index > rows * 9) {
|
||||
throw new IllegalArgumentException("Ranks GUI is too small for the number of ranks. Increase the number of rows on the ranks GUI.");
|
||||
}
|
||||
rankElement = rankElement.getNext();
|
||||
|
||||
@@ -46,6 +46,7 @@ permissions:
|
||||
rankup.force: true
|
||||
# if a player receives notifications to update rankup when they log in.
|
||||
rankup.notify: true
|
||||
rankup.playtime: true
|
||||
default: op
|
||||
rankup.rankup:
|
||||
default: true
|
||||
@@ -59,3 +60,8 @@ permissions:
|
||||
default: true
|
||||
rankup.maxrankup:
|
||||
default: true
|
||||
rankup.playtime:
|
||||
children:
|
||||
rankup.playtime.get: true
|
||||
rankup.playtime.set: true
|
||||
default: op
|
||||
Reference in New Issue
Block a user