Starting simplification
This commit is contained in:
@@ -32,7 +32,7 @@ public class RankList<T extends Rank> {
|
||||
for (T rank : ranks) {
|
||||
// see if anything ranks up to this
|
||||
for (T rank0 : ranks) {
|
||||
if (!rank0.isLast() && rank0.getNext().equals(rank.getName())) {
|
||||
if (rank0.getNext().equals(rank.getRank())) {
|
||||
continue OUTER;
|
||||
}
|
||||
}
|
||||
@@ -45,21 +45,20 @@ public class RankList<T extends Rank> {
|
||||
public List<T> getOrderedList() {
|
||||
List<T> list = new ArrayList<>();
|
||||
T t = getFirst();
|
||||
list.add(t);
|
||||
do {
|
||||
t = next(t);
|
||||
while (t != null) {
|
||||
list.add(t);
|
||||
} while (!t.isLast());
|
||||
t = next(t);
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
public T getByName(String name) {
|
||||
for (T rank : ranks) {
|
||||
if (rank.getName().equalsIgnoreCase(name)) {
|
||||
if (rank.getRank().equalsIgnoreCase(name)) {
|
||||
return rank;
|
||||
}
|
||||
}
|
||||
throw new RuntimeException("Invalid rank: " + name);
|
||||
return null;
|
||||
}
|
||||
|
||||
public T getByPlayer(Player player) {
|
||||
@@ -74,15 +73,11 @@ public class RankList<T extends Rank> {
|
||||
}
|
||||
|
||||
public T next(T rank) {
|
||||
if (rank.isLast()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
for (T nextRank : ranks) {
|
||||
if (rank.getNext().equalsIgnoreCase(nextRank.getName())) {
|
||||
if (rank.getNext().equalsIgnoreCase(nextRank.getRank())) {
|
||||
return nextRank;
|
||||
}
|
||||
}
|
||||
throw new RuntimeException(rank.getName() + " has an invalid next rank");
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,10 +25,8 @@ import sh.okx.rankup.prestige.Prestige;
|
||||
import sh.okx.rankup.prestige.Prestiges;
|
||||
import sh.okx.rankup.ranks.Rank;
|
||||
import sh.okx.rankup.ranks.Rankups;
|
||||
import sh.okx.rankup.requirements.OperationRegistry;
|
||||
import sh.okx.rankup.requirements.Requirement;
|
||||
import sh.okx.rankup.requirements.RequirementRegistry;
|
||||
import sh.okx.rankup.requirements.operation.*;
|
||||
import sh.okx.rankup.requirements.requirement.*;
|
||||
import sh.okx.rankup.requirements.requirement.XpLevelRequirement;
|
||||
import sh.okx.rankup.requirements.requirement.advancedachievements.*;
|
||||
@@ -53,8 +51,6 @@ public class Rankup extends JavaPlugin {
|
||||
@Getter
|
||||
private RequirementRegistry requirementRegistry;
|
||||
@Getter
|
||||
private OperationRegistry operationRegistry;
|
||||
@Getter
|
||||
private FileConfiguration messages;
|
||||
@Getter
|
||||
private FileConfiguration config;
|
||||
@@ -226,12 +222,6 @@ public class Rankup extends JavaPlugin {
|
||||
requirementRegistry.addRequirement(new AdvancedAchievementsAchievementRequirement(this));
|
||||
requirementRegistry.addRequirement(new AdvancedAchievementsTotalRequirement(this));
|
||||
}
|
||||
|
||||
operationRegistry = new OperationRegistry();
|
||||
operationRegistry.addOperation("all", new AllOperation());
|
||||
operationRegistry.addOperation("none", new NoneOperation());
|
||||
operationRegistry.addOperation("one", new OneOperation());
|
||||
operationRegistry.addOperation("any", new AnyOperation());
|
||||
}
|
||||
|
||||
private void setupPermissions() {
|
||||
@@ -266,7 +256,7 @@ public class Rankup extends JavaPlugin {
|
||||
|
||||
public MessageBuilder getMessage(Rank rank, Message message) {
|
||||
ConfigurationSection messages = (rank instanceof Prestige ? prestiges : rankups).getConfig()
|
||||
.getConfigurationSection(rank.getName());
|
||||
.getConfigurationSection(rank.getRank());
|
||||
if (messages == null || !messages.isSet(message.getName())) {
|
||||
messages = this.messages;
|
||||
}
|
||||
@@ -410,7 +400,7 @@ public class Rankup extends JavaPlugin {
|
||||
|
||||
public boolean checkPrestige(Player player, boolean message) {
|
||||
Prestige prestige = prestiges.getByPlayer(player);
|
||||
if (!prestige.isEligable(player)) { // check if in ladder
|
||||
if (!prestige.isIn(player)) { // check if in ladder
|
||||
getMessage(Message.NOT_HIGH_ENOUGH)
|
||||
.failIf(!message)
|
||||
.replace(Variable.PLAYER, player.getName())
|
||||
@@ -486,12 +476,10 @@ public class Rankup extends JavaPlugin {
|
||||
builder.replace(variable + " " + requirement.getName(), value.get());
|
||||
}
|
||||
|
||||
public void sendMessage(CommandSender player, Message message, Rank oldRank, Rank rank) {
|
||||
replaceMoneyRequirements(getMessage(oldRank, message)
|
||||
.replaceFirstPrestige(oldRank, prestiges, config.getString("placeholders.first-prestige-rank"))
|
||||
public MessageBuilder getMessage(CommandSender player, Message message, Rank oldRank, Rank rank) {
|
||||
return replaceMoneyRequirements(getMessage(oldRank, message)
|
||||
.replaceRanks(player, oldRank, rank), player, oldRank)
|
||||
.replaceFromTo(oldRank)
|
||||
.send(player);
|
||||
.replaceFromTo(oldRank);
|
||||
}
|
||||
|
||||
public void sendHeaderFooter(CommandSender sender, Rank rank, Message type) {
|
||||
@@ -508,4 +496,9 @@ public class Rankup extends JavaPlugin {
|
||||
}
|
||||
builder.send(sender);
|
||||
}
|
||||
|
||||
public boolean isLegacy() {
|
||||
String version = Bukkit.getVersion();
|
||||
return !(version.startsWith("1.13") || version.startsWith("1.14"));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,14 +4,12 @@ import lombok.Getter;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import sh.okx.rankup.requirements.Operation;
|
||||
import sh.okx.rankup.requirements.OperationRegistry;
|
||||
import sh.okx.rankup.requirements.Requirement;
|
||||
import sh.okx.rankup.requirements.RequirementRegistry;
|
||||
|
||||
/**
|
||||
* Called immediately before rankups and prestiges are registered,
|
||||
* and immediately after the built-in requirements and operations are registered.
|
||||
* and immediately after the built-in requirements are registered.
|
||||
* This is used to register custom requirements.
|
||||
* This is called when the plugin is enabled, and when it is reloaded from a command.
|
||||
*/
|
||||
@@ -29,18 +27,10 @@ public class RankupRegisterEvent extends Event {
|
||||
return plugin.getRequirementRegistry();
|
||||
}
|
||||
|
||||
public OperationRegistry getOperationRegistry() {
|
||||
return plugin.getOperationRegistry();
|
||||
}
|
||||
|
||||
public void addRequirement(Requirement requirement) {
|
||||
plugin.getRequirementRegistry().addRequirement(requirement);
|
||||
}
|
||||
|
||||
public void addOperation(String name, Operation operation) {
|
||||
plugin.getOperationRegistry().addOperation(name, operation);
|
||||
}
|
||||
|
||||
@Override
|
||||
public HandlerList getHandlers() {
|
||||
return handlers;
|
||||
|
||||
@@ -26,13 +26,17 @@ public class PrestigesCommand implements CommandExecutor {
|
||||
|
||||
Message message = playerRank == null ? Message.PRESTIGES_INCOMPLETE : Message.PRESTIGES_COMPLETE;
|
||||
Prestige prestige = prestiges.getFirst();
|
||||
while (!prestige.isLast()) {
|
||||
Prestige next = prestiges.next(prestige);
|
||||
Prestige next;
|
||||
while ((next = prestiges.next(prestige)) != null) {
|
||||
if (prestige.equals(playerRank)) {
|
||||
plugin.sendMessage(sender, Message.PRESTIGES_CURRENT, prestige, next);
|
||||
plugin.getMessage(sender, Message.PRESTIGES_CURRENT, prestige, next)
|
||||
.replaceFirstPrestige(prestige, prestiges, prestige.getFrom())
|
||||
.send(sender);
|
||||
message = Message.PRESTIGES_INCOMPLETE;
|
||||
} else {
|
||||
plugin.sendMessage(sender, message, prestige, next);
|
||||
plugin.getMessage(sender, message, prestige, next)
|
||||
.replaceFirstPrestige(prestige, prestiges, prestige.getFrom())
|
||||
.send(sender);
|
||||
}
|
||||
prestige = next;
|
||||
}
|
||||
|
||||
@@ -26,25 +26,16 @@ public class RanksCommand implements CommandExecutor {
|
||||
|
||||
Message message = playerRank == null ? Message.RANKS_INCOMPLETE : Message.RANKS_COMPLETE;
|
||||
Rank rank = rankups.getFirst();
|
||||
do {
|
||||
Rank next = rankups.next(rank);
|
||||
Rank next;
|
||||
while ((next = rankups.next(rank)) != null) {
|
||||
if (rank.equals(playerRank)) {
|
||||
plugin.sendMessage(sender, Message.RANKS_CURRENT, rank, next);
|
||||
plugin.getMessage(sender, Message.RANKS_CURRENT, rank, next).send(sender);
|
||||
message = Message.RANKS_INCOMPLETE;
|
||||
} else {
|
||||
// helpful message to say there is a null rankup
|
||||
if (next == null) {
|
||||
plugin.getMessage(Message.INVALID_RANKUP).failIfEmpty().send(sender);
|
||||
plugin.getLogger().severe("Rankup from " + rank.getName() + " to " + rank.getNext()
|
||||
+ " is defined but " + rank.getNext() + " does not exist.");
|
||||
return true;
|
||||
}
|
||||
|
||||
plugin.sendMessage(sender, message, rank, next);
|
||||
plugin.getMessage(sender, message, rank, next).send(sender);
|
||||
}
|
||||
rank = next;
|
||||
} while (!rank.isLast());
|
||||
|
||||
}
|
||||
plugin.sendHeaderFooter(sender, playerRank, Message.RANKS_FOOTER);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -37,7 +37,7 @@ public class RankupCommand implements CommandExecutor {
|
||||
}
|
||||
Rank next = rankups.next(rank);
|
||||
if (next == null) {
|
||||
plugin.getLogger().severe("Rankup from " + rank.getName() + " to " + rank.getNext() +
|
||||
plugin.getLogger().severe("Rankup from " + rank.getRank() + " to " + rank.getNext() +
|
||||
" is defined but " + rank.getNext() + " does not exist.");
|
||||
plugin.getMessage(Message.INVALID_RANKUP).failIfEmpty().send(player);
|
||||
return true;
|
||||
|
||||
@@ -59,18 +59,18 @@ public class Gui implements InventoryHolder {
|
||||
return gui;
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
private static ItemStack getItem(Rankup plugin, String name, Player player, Rank oldRank, Rank rank) {
|
||||
ConfigurationSection section = plugin.getConfig().getConfigurationSection("gui").getConfigurationSection(name);
|
||||
boolean legacy = !Bukkit.getVersion().contains("1.13");
|
||||
|
||||
String materialName = section.getString("material").toUpperCase();
|
||||
// handle default material correctly on older versions
|
||||
if (legacy && materialName.equals("BLACK_STAINED_GLASS_PANE")) {
|
||||
if (plugin.isLegacy() && materialName.equals("BLACK_STAINED_GLASS_PANE")) {
|
||||
materialName = "STAINED_GLASS_PANE:15";
|
||||
}
|
||||
|
||||
ItemStack item;
|
||||
if (legacy) {
|
||||
if (plugin.isLegacy()) {
|
||||
String[] parts = materialName.split(":");
|
||||
Material material = Material.valueOf(parts[0]);
|
||||
|
||||
|
||||
@@ -64,14 +64,14 @@ public class MessageBuilder {
|
||||
|
||||
public MessageBuilder replaceRanks(Rank rank) {
|
||||
replace(Variable.RANK, rank.getRank());
|
||||
replace(Variable.RANK_NAME, rank.getName());
|
||||
replace(Variable.RANK_NAME, rank.getRank());
|
||||
return this;
|
||||
}
|
||||
|
||||
public MessageBuilder replaceRanks(Rank oldRank, Rank rank) {
|
||||
replaceRanks(rank);
|
||||
replace(Variable.OLD_RANK, oldRank.getRank());
|
||||
replace(Variable.OLD_RANK_NAME, oldRank.getName());
|
||||
replace(Variable.OLD_RANK_NAME, oldRank.getRank());
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
@@ -10,6 +10,7 @@ import sh.okx.rankup.ranks.Rank;
|
||||
import sh.okx.rankup.ranks.Rankups;
|
||||
import sh.okx.rankup.requirements.Requirement;
|
||||
|
||||
import java.util.Objects;
|
||||
import java.util.function.Function;
|
||||
|
||||
@RequiredArgsConstructor
|
||||
@@ -47,7 +48,7 @@ public class RankupExpansion extends PlaceholderExpansion {
|
||||
// return placeholders.getSimpleFormat().format(orElse(rankups.getByName(parts[2]).getRequirement(parts[3]), Requirement::getValueDouble, 0));
|
||||
} else if (params.startsWith("rank_money_")) {
|
||||
String[] parts = params.split("_", 4);
|
||||
double amount = rankups.getByName(parts[2]).getRequirement("money").getValueDouble();
|
||||
double amount = Objects.requireNonNull(rankups.getByName(parts[2]), "Rankup " + parts[2] + " does not exist").getRequirement("money").getValueDouble();
|
||||
if (parts.length > 3 && parts[3].equalsIgnoreCase("left")) {
|
||||
amount = amount - plugin.getEconomy().getBalance(player);
|
||||
}
|
||||
@@ -56,25 +57,17 @@ public class RankupExpansion extends PlaceholderExpansion {
|
||||
|
||||
switch (params) {
|
||||
case "current_prestige":
|
||||
return prestige.getRank();
|
||||
case "current_prestige_name":
|
||||
return prestige.getName();
|
||||
return Objects.requireNonNull(prestige, "Using current_prestige placeholder but prestiging is disabled").getRank();
|
||||
case "next_prestige":
|
||||
return orElsePlaceholder(nextPrestige, Prestige::getRank, "highest-rank");
|
||||
case "next_prestige_name":
|
||||
return orElsePlaceholder(nextPrestige, Prestige::getName, "highest-rank");
|
||||
case "prestige_money":
|
||||
return String.valueOf(simplify(orElse(prestige, r -> r.isEligable(player) ? r.getRequirement("money").getValueDouble() : 0, 0)));
|
||||
return String.valueOf(simplify(orElse(prestige, r -> r.isIn(player) ? r.getRequirement("money").getValueDouble() : 0, 0)));
|
||||
case "prestige_money_formatted":
|
||||
return plugin.formatMoney(orElse(prestige, r -> r.isEligable(player) ? r.getRequirement("money").getValueDouble() : 0, 0D));
|
||||
return plugin.formatMoney(orElse(prestige, r -> r.isIn(player) ? r.getRequirement("money").getValueDouble() : 0, 0D));
|
||||
case "current_rank":
|
||||
return orElsePlaceholder(rank, Rank::getRank, "not-in-ladder");
|
||||
case "current_rank_name":
|
||||
return orElsePlaceholder(rank, Rank::getName, "not-in-ladder");
|
||||
case "next_rank":
|
||||
return orElsePlaceholder(rank, r -> orElsePlaceholder(nextRank, Rank::getRank, "highest-rank"), "not-in-ladder");
|
||||
case "next_rank_name":
|
||||
return orElsePlaceholder(rank, r -> orElsePlaceholder(nextRank, Rank::getName, "highest-rank"), "not-in-ladder");
|
||||
case "money":
|
||||
return String.valueOf(orElse(rank, r -> simplify(r.getRequirement("money").getValueDouble()), 0));
|
||||
case "money_formatted":
|
||||
|
||||
@@ -1,65 +1,42 @@
|
||||
package sh.okx.rankup.prestige;
|
||||
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.Getter;
|
||||
import org.apache.commons.lang3.Validate;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.entity.Player;
|
||||
import sh.okx.rankup.Rankup;
|
||||
import sh.okx.rankup.ranks.Rank;
|
||||
import sh.okx.rankup.requirements.Operation;
|
||||
import sh.okx.rankup.requirements.Requirement;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public class Prestige extends Rank {
|
||||
@Getter
|
||||
private final String from;
|
||||
@Getter
|
||||
private final String to;
|
||||
|
||||
private Prestige(Rankup plugin, String name, String next, String rank, Set<Requirement> requirements, Operation operation, List<String> commands, String from, String to) {
|
||||
super(plugin, name, next, rank, requirements, operation, commands);
|
||||
private Prestige(Rankup plugin, String next, String rank, Set<Requirement> requirements, List<String> commands, String from, String to) {
|
||||
super(plugin, next, rank, requirements, commands);
|
||||
this.from = from;
|
||||
this.to = to;
|
||||
}
|
||||
|
||||
public static Prestige deserialize(Rankup plugin, ConfigurationSection section) {
|
||||
Set<Requirement> requirements = new HashSet<>();
|
||||
Operation operation = null;
|
||||
ConfigurationSection requirementsSection = section.getConfigurationSection("requirements");
|
||||
|
||||
if (requirementsSection != null) {
|
||||
requirements = plugin.getRequirementRegistry().getRequirements(requirementsSection);
|
||||
operation = plugin.getOperationRegistry().getOperation(section.getString("operation"));
|
||||
}
|
||||
Validate.notNull(requirementsSection, "No requirements defined for section " + section.getName());
|
||||
Set<Requirement> requirements = plugin.getRequirementRegistry().getRequirements(requirementsSection);
|
||||
|
||||
return new Prestige(plugin,
|
||||
section.getName(),
|
||||
section.getString("next"),
|
||||
section.getString("rank"),
|
||||
requirements,
|
||||
operation,
|
||||
section.getStringList("commands"),
|
||||
section.getString("from"),
|
||||
section.getString("to"));
|
||||
}
|
||||
|
||||
public boolean isEligable(Player player) {
|
||||
String[] groups = plugin.getPermissions().getPlayerGroups(null, player);
|
||||
for (String group : groups) {
|
||||
if (group.equalsIgnoreCase(from)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (!(o instanceof Prestige)) {
|
||||
return false;
|
||||
}
|
||||
return ((Prestige) o).name.equals(name);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,62 +1,55 @@
|
||||
package sh.okx.rankup.ranks;
|
||||
|
||||
import lombok.AccessLevel;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.Getter;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.apache.commons.lang3.Validate;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.entity.Player;
|
||||
import sh.okx.rankup.Rankup;
|
||||
import sh.okx.rankup.messages.MessageBuilder;
|
||||
import sh.okx.rankup.requirements.DeductibleRequirement;
|
||||
import sh.okx.rankup.requirements.Operation;
|
||||
import sh.okx.rankup.requirements.Requirement;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@EqualsAndHashCode
|
||||
@RequiredArgsConstructor(access = AccessLevel.PROTECTED)
|
||||
public class Rank {
|
||||
protected final Rankup plugin;
|
||||
@Getter
|
||||
protected final String name;
|
||||
@Getter
|
||||
protected final String next;
|
||||
@Getter
|
||||
protected final String rank;
|
||||
@Getter
|
||||
protected final Set<Requirement> requirements;
|
||||
protected final Operation operation;
|
||||
protected final List<String> commands;
|
||||
|
||||
public static Rank deserialize(Rankup plugin, ConfigurationSection section) {
|
||||
Set<Requirement> requirements = new HashSet<>();
|
||||
Operation operation = null;
|
||||
ConfigurationSection requirementsSection = section.getConfigurationSection("requirements");
|
||||
|
||||
if (requirementsSection != null) {
|
||||
requirements = plugin.getRequirementRegistry().getRequirements(requirementsSection);
|
||||
operation = plugin.getOperationRegistry().getOperation(section.getString("operation"));
|
||||
} else if (section.contains("next")) {
|
||||
plugin.getLogger().severe("Rank " + section.getName() + " has no requirements.");
|
||||
return null;
|
||||
}
|
||||
Validate.notNull(requirementsSection, "No requirements defined for section " + section.getName());
|
||||
Set<Requirement> requirements = plugin.getRequirementRegistry().getRequirements(requirementsSection);
|
||||
|
||||
return new Rank(plugin,
|
||||
section.getName(),
|
||||
section.getString("next"),
|
||||
section.getString("rank"),
|
||||
requirements,
|
||||
operation,
|
||||
section.getStringList("commands"));
|
||||
}
|
||||
|
||||
public boolean hasRequirements(Player player) {
|
||||
return operation.check(requirements.stream()
|
||||
.map(requirement -> requirement.check(player))
|
||||
.collect(Collectors.toList()));
|
||||
for (Requirement requirement : requirements) {
|
||||
if (!requirement.check(player)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean isIn(Player player) {
|
||||
@@ -70,7 +63,7 @@ public class Rank {
|
||||
}
|
||||
|
||||
public boolean isLast() {
|
||||
return next == null;
|
||||
return plugin.getRankups().getByName(next) == null;
|
||||
}
|
||||
|
||||
public Requirement getRequirement(String name) {
|
||||
@@ -96,12 +89,4 @@ public class Rank {
|
||||
new MessageBuilder(command).replaceRanks(player, this, nextRank).toString());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (!(o instanceof Rank)) {
|
||||
return false;
|
||||
}
|
||||
return ((Rank) o).name.equals(name);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +0,0 @@
|
||||
package sh.okx.rankup.requirements;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface Operation {
|
||||
boolean check(List<Boolean> booleans);
|
||||
}
|
||||
@@ -1,16 +0,0 @@
|
||||
package sh.okx.rankup.requirements;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class OperationRegistry {
|
||||
private Map<String, Operation> operations = new HashMap<>();
|
||||
|
||||
public void addOperation(String name, Operation operation) {
|
||||
operations.put(name.toLowerCase(), operation);
|
||||
}
|
||||
|
||||
public Operation getOperation(String name) {
|
||||
return operations.get(name == null ? "all" : name.toLowerCase());
|
||||
}
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
package sh.okx.rankup.requirements;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public abstract class ReducerOperation implements Operation {
|
||||
public abstract boolean check(boolean a, boolean b);
|
||||
|
||||
@Override
|
||||
public boolean check(List<Boolean> booleans) {
|
||||
return booleans.stream().reduce(this::check).orElse(true);
|
||||
}
|
||||
}
|
||||
@@ -1,10 +0,0 @@
|
||||
package sh.okx.rankup.requirements.operation;
|
||||
|
||||
import sh.okx.rankup.requirements.ReducerOperation;
|
||||
|
||||
public class AllOperation extends ReducerOperation {
|
||||
@Override
|
||||
public boolean check(boolean a, boolean b) {
|
||||
return a && b;
|
||||
}
|
||||
}
|
||||
@@ -1,10 +0,0 @@
|
||||
package sh.okx.rankup.requirements.operation;
|
||||
|
||||
import sh.okx.rankup.requirements.ReducerOperation;
|
||||
|
||||
public class AnyOperation extends ReducerOperation {
|
||||
@Override
|
||||
public boolean check(boolean a, boolean b) {
|
||||
return a || b;
|
||||
}
|
||||
}
|
||||
@@ -1,10 +0,0 @@
|
||||
package sh.okx.rankup.requirements.operation;
|
||||
|
||||
import sh.okx.rankup.requirements.ReducerOperation;
|
||||
|
||||
public class NoneOperation extends ReducerOperation {
|
||||
@Override
|
||||
public boolean check(boolean a, boolean b) {
|
||||
return !a && !b;
|
||||
}
|
||||
}
|
||||
@@ -1,10 +0,0 @@
|
||||
package sh.okx.rankup.requirements.operation;
|
||||
|
||||
import sh.okx.rankup.requirements.ReducerOperation;
|
||||
|
||||
public class OneOperation extends ReducerOperation {
|
||||
@Override
|
||||
public boolean check(boolean a, boolean b) {
|
||||
return (a && !b) || (b && !a);
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
# this is used for letting you know that you need to update/change your config file
|
||||
version: 3
|
||||
|
||||
# the ISO-639-1 locale to use for messages
|
||||
# the locale to use for messages
|
||||
# all messages can be customised but this allows you to
|
||||
# choose messages that are already translated
|
||||
# locales can be found in the locale/ folder
|
||||
@@ -29,8 +29,7 @@ prestige: true
|
||||
# options are: gui, text or none
|
||||
confirmation-type: 'gui'
|
||||
|
||||
# how long in seconds people have to wait between a /rankup and a /prestige
|
||||
# only successful rankups and prestiges start the cooldown.
|
||||
# how long, in seconds, people have to wait between a successful /rankup or a /prestige
|
||||
# set to 0 to disable.
|
||||
cooldown: 1
|
||||
|
||||
@@ -38,8 +37,8 @@ gui:
|
||||
rows: 1
|
||||
rankup:
|
||||
material: EMERALD_BLOCK
|
||||
# index can be separated by spaces to show in multiple ways
|
||||
# ie, 0-3 9-12 18-21
|
||||
# index can be separated by spaces to show in multiple groups
|
||||
# for example: 0-3 9-12 18-21
|
||||
# you can also just use a single number instead of a range.
|
||||
index: 0-3
|
||||
name: '&a&lConfirm'
|
||||
@@ -56,6 +55,7 @@ gui:
|
||||
# this works for both the rankup and cancel blocks as well
|
||||
material: BLACK_STAINED_GLASS_PANE
|
||||
|
||||
# options when using the text rankup confirmation
|
||||
text:
|
||||
# the time in seconds for a player to
|
||||
# confirm by typing /rankup again
|
||||
@@ -72,8 +72,6 @@ placeholders:
|
||||
not-in-ladder: "None"
|
||||
# used in next_rank placeholders when there is no rankup
|
||||
highest-rank: "None"
|
||||
# used in /prestiges as the {OLD_RANK} placeholder for the first prestige rank
|
||||
first-prestige-rank: 'D'
|
||||
|
||||
# what to shorten money by.
|
||||
# ie 1000 -> 1k
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
name: Rankup
|
||||
version: 3.4.2-beta.1
|
||||
version: 3.4.2
|
||||
main: sh.okx.rankup.Rankup
|
||||
author: Okx
|
||||
depend: [Vault]
|
||||
|
||||
@@ -3,21 +3,19 @@ first:
|
||||
from: 'D'
|
||||
# the rank to change it to
|
||||
to: 'A'
|
||||
next: 'P1example'
|
||||
next: 'P1'
|
||||
# see rankups.yml for more information on requirements, operations, commands and messages
|
||||
requirements:
|
||||
money: 10000
|
||||
# optional, defaults to all
|
||||
operation: all
|
||||
- 'money 10000'
|
||||
P1example:
|
||||
from: 'D'
|
||||
to: 'A'
|
||||
# the rank added to indicate this prestige
|
||||
rank: 'P1'
|
||||
next: 'P2example'
|
||||
next: 'P2'
|
||||
requirements:
|
||||
money: 20000
|
||||
xp-level: 5
|
||||
- 'money 20000'
|
||||
- 'xp-level 5'
|
||||
P2example:
|
||||
from: 'D'
|
||||
to: 'A'
|
||||
|
||||
@@ -1,54 +1,40 @@
|
||||
# see https://github.com/okx-code/Rankup3/wiki/Rank-format
|
||||
|
||||
# this name can be equal to your rank name for simplicity,
|
||||
# eg "A" instead of "Aexample".
|
||||
# this name doesn't matter
|
||||
Aexample:
|
||||
# the name of the rank in your permissions plugin
|
||||
# the name of the group
|
||||
# players have to be in this rank to rankup
|
||||
rank: 'A'
|
||||
# the next rank a player can rank up to.
|
||||
# this must be the name of the configuration section, not the rank name.
|
||||
# for example, the name of this configuration section is "Aexample".
|
||||
# if this is the last rank, you don't need this.
|
||||
next: 'Bexample'
|
||||
# the name of the rank a player can rankup to
|
||||
next: 'B'
|
||||
# List of requirements to go to the next rank
|
||||
# (ie, this example will charge 1000 money to rankup from A to B)
|
||||
# This example will charge 1000 money to rankup from A to B.
|
||||
# https://github.com/okx-code/Rankup3/wiki/Requirements
|
||||
# custom requirements can also be added by other plugins.
|
||||
requirements:
|
||||
money: 1000
|
||||
# What requirements players need to match to /rankup.
|
||||
# this is optional - if you don't use it, it defaults to "all"
|
||||
# n.b. if there are no requirements players will always be able to /rankup.
|
||||
# all: all requirements
|
||||
# any: at least one requirement
|
||||
# one: only one requirement
|
||||
# none: no requirements
|
||||
operation: all
|
||||
- 'money 1000'
|
||||
# the console will run these commands when a player ranks up
|
||||
# rankup will change the group for you, commands are not needed for that
|
||||
# the groups are automatically changed with vault
|
||||
#commands:
|
||||
# this will run when a player ranks up from A to B.
|
||||
#- 'say {PLAYER} well done for ranking up from {OLD_RANK} to {RANK}!'
|
||||
Bexample:
|
||||
rank: 'B'
|
||||
next: 'Cexample'
|
||||
next: 'C'
|
||||
requirements:
|
||||
money: 2500
|
||||
- 'money 2500'
|
||||
Cexample:
|
||||
rank: 'C'
|
||||
next: 'Dexample'
|
||||
next: 'D'
|
||||
requirements:
|
||||
money: 5000
|
||||
xp-level: 2
|
||||
- 'money 5000'
|
||||
- 'xp-level 2'
|
||||
# you can have a custom messages for each rank
|
||||
# you can use this to list the requirements needed.
|
||||
# the paths of these messages are the exact same as in the messages for your locale
|
||||
rankup:
|
||||
requirements-not-met: '&cYou need 5000 money and 2 levels of XP to rankup to D.'
|
||||
list:
|
||||
complete: "&7{OLD_RANK} &8\xbb &7{RANK} &e(5000 money, 2 XP levels)"
|
||||
current: "&c{OLD_RANK} &e\xbb &c{RANK} &e(5000 money, 2 XP levels)"
|
||||
incomplete: "&r{OLD_RANK} &e\xbb &r{RANK} &e(5000 money, 2 XP levels)"
|
||||
# for the last rank, you just need to specify the rank.
|
||||
Dexample:
|
||||
rank: 'D'
|
||||
incomplete: "&r{OLD_RANK} &e\xbb &r{RANK} &e(5000 money, 2 XP levels)"
|
||||
Reference in New Issue
Block a user