3.11 update
This commit is contained in:
+4
-1
@@ -35,8 +35,11 @@ dependencies {
|
|||||||
implementation('com.github.MilkBowl:VaultAPI:1.7') {
|
implementation('com.github.MilkBowl:VaultAPI:1.7') {
|
||||||
exclude group: 'org.bukkit'
|
exclude group: 'org.bukkit'
|
||||||
}
|
}
|
||||||
implementation 'me.clip:placeholderapi:2.10.6'
|
implementation ('me.clip:placeholderapi:2.10.9') {
|
||||||
|
exclude group: 'org.bstats'
|
||||||
|
}
|
||||||
implementation 'com.github.pyvesb:advanced-achievements:6.7.2'
|
implementation 'com.github.pyvesb:advanced-achievements:6.7.2'
|
||||||
|
implementation 'com.github.astei:Superbvote:700fca43659b438cb9bb36c218a7646d2f2ef315'
|
||||||
implementation('com.github.mcMMO-Dev:mcMMO:601297') {
|
implementation('com.github.mcMMO-Dev:mcMMO:601297') {
|
||||||
exclude group: 'com.sk89q.worldguard'
|
exclude group: 'com.sk89q.worldguard'
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,8 +3,11 @@ package sh.okx.rankup;
|
|||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.configuration.ConfigurationSection;
|
import org.bukkit.configuration.ConfigurationSection;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
import sh.okx.rankup.events.PlayerPrestigeEvent;
|
||||||
|
import sh.okx.rankup.events.PlayerRankupEvent;
|
||||||
import sh.okx.rankup.hook.GroupProvider;
|
import sh.okx.rankup.hook.GroupProvider;
|
||||||
import sh.okx.rankup.messages.Message;
|
import sh.okx.rankup.messages.Message;
|
||||||
import sh.okx.rankup.messages.Variable;
|
import sh.okx.rankup.messages.Variable;
|
||||||
@@ -40,7 +43,9 @@ public class RankupHelper {
|
|||||||
}
|
}
|
||||||
permissions.addGroup(player.getUniqueId(), rank.getNext().getRank().getRank());
|
permissions.addGroup(player.getUniqueId(), rank.getNext().getRank().getRank());
|
||||||
|
|
||||||
rank.getRank().runCommands(player);
|
rank.getRank().runCommands(player, rank.getNext().getRank());
|
||||||
|
|
||||||
|
Bukkit.getPluginManager().callEvent(new PlayerRankupEvent(plugin, player, rank));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void sendRankupMessages(Player player, RankElement<Rank> rank) {
|
public void sendRankupMessages(Player player, RankElement<Rank> rank) {
|
||||||
@@ -65,7 +70,9 @@ public class RankupHelper {
|
|||||||
}
|
}
|
||||||
permissions.addGroup(player.getUniqueId(), prestige.getNext().getRank().getRank());
|
permissions.addGroup(player.getUniqueId(), prestige.getNext().getRank().getRank());
|
||||||
|
|
||||||
rank.runCommands(player);
|
rank.runCommands(player, prestige.getNext().getRank());
|
||||||
|
|
||||||
|
Bukkit.getPluginManager().callEvent(new PlayerPrestigeEvent(plugin, player, prestige));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void sendPrestigeMessages(Player player, RankElement<Prestige> prestige) {
|
public void sendPrestigeMessages(Player player, RankElement<Prestige> prestige) {
|
||||||
@@ -95,7 +102,7 @@ public class RankupHelper {
|
|||||||
plugin
|
plugin
|
||||||
.getMessage(rank, secondsLeft > 1 ? Message.COOLDOWN_PLURAL : Message.COOLDOWN_SINGULAR)
|
.getMessage(rank, secondsLeft > 1 ? Message.COOLDOWN_PLURAL : Message.COOLDOWN_SINGULAR)
|
||||||
.failIfEmpty()
|
.failIfEmpty()
|
||||||
.replaceRanks(player, rank.getRank())
|
.replaceRanks(player, rank)
|
||||||
.replaceFromTo(rank)
|
.replaceFromTo(rank)
|
||||||
.replace(Variable.SECONDS, cooldownSeconds)
|
.replace(Variable.SECONDS, cooldownSeconds)
|
||||||
.replace(Variable.SECONDS_LEFT, secondsLeft)
|
.replace(Variable.SECONDS_LEFT, secondsLeft)
|
||||||
@@ -153,7 +160,7 @@ public class RankupHelper {
|
|||||||
Prestiges prestiges = plugin.getPrestiges();
|
Prestiges prestiges = plugin.getPrestiges();
|
||||||
plugin.getMessage(prestiges == null || !prestiges.getByPlayer(player).hasNext() ? Message.NO_RANKUP : Message.MUST_PRESTIGE)
|
plugin.getMessage(prestiges == null || !prestiges.getByPlayer(player).hasNext() ? Message.NO_RANKUP : Message.MUST_PRESTIGE)
|
||||||
.failIf(!message)
|
.failIf(!message)
|
||||||
.replaceRanks(player, rankups.getTree().last().getRank().getRank())
|
.replaceRanks(player, rankups.getTree().last().getRank())
|
||||||
.send(player);
|
.send(player);
|
||||||
return false;
|
return false;
|
||||||
} else if (!rank.hasRequirements(player)) { // check if they can afford it
|
} else if (!rank.hasRequirements(player)) { // check if they can afford it
|
||||||
@@ -200,7 +207,7 @@ public class RankupHelper {
|
|||||||
} else if (!prestigeElement.hasNext()) { // check if they are at the highest rank
|
} else if (!prestigeElement.hasNext()) { // check if they are at the highest rank
|
||||||
plugin.getMessage(prestigeElement.getRank(), Message.PRESTIGE_NO_PRESTIGE)
|
plugin.getMessage(prestigeElement.getRank(), Message.PRESTIGE_NO_PRESTIGE)
|
||||||
.failIf(!message)
|
.failIf(!message)
|
||||||
.replaceRanks(player, prestigeElement.getRank().getRank())
|
.replaceRanks(player, prestigeElement.getRank())
|
||||||
.replaceFromTo(prestigeElement.getRank())
|
.replaceFromTo(prestigeElement.getRank())
|
||||||
.send(player);
|
.send(player);
|
||||||
return false;
|
return false;
|
||||||
@@ -208,7 +215,7 @@ public class RankupHelper {
|
|||||||
plugin.replaceMoneyRequirements(
|
plugin.replaceMoneyRequirements(
|
||||||
plugin.getMessage(prestigeElement.getRank(), Message.PRESTIGE_REQUIREMENTS_NOT_MET)
|
plugin.getMessage(prestigeElement.getRank(), Message.PRESTIGE_REQUIREMENTS_NOT_MET)
|
||||||
.failIf(!message)
|
.failIf(!message)
|
||||||
.replaceRanks(player, prestigeElement.getRank(), prestigeElement.getNext().getRank().getRank()), player, prestigeElement.getRank())
|
.replaceRanks(player, prestigeElement.getRank(), prestigeElement.getNext().getRank()), player, prestigeElement.getRank())
|
||||||
.replaceFromTo(prestigeElement.getRank())
|
.replaceFromTo(prestigeElement.getRank())
|
||||||
.send(player);
|
.send(player);
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
@@ -29,6 +29,7 @@ import sh.okx.rankup.commands.RankupCommand;
|
|||||||
import sh.okx.rankup.economy.Economy;
|
import sh.okx.rankup.economy.Economy;
|
||||||
import sh.okx.rankup.economy.EconomyProvider;
|
import sh.okx.rankup.economy.EconomyProvider;
|
||||||
import sh.okx.rankup.economy.VaultEconomyProvider;
|
import sh.okx.rankup.economy.VaultEconomyProvider;
|
||||||
|
import sh.okx.rankup.events.RankupRegisterEvent;
|
||||||
import sh.okx.rankup.gui.Gui;
|
import sh.okx.rankup.gui.Gui;
|
||||||
import sh.okx.rankup.gui.GuiListener;
|
import sh.okx.rankup.gui.GuiListener;
|
||||||
import sh.okx.rankup.hook.GroupProvider;
|
import sh.okx.rankup.hook.GroupProvider;
|
||||||
@@ -70,6 +71,7 @@ import sh.okx.rankup.requirements.requirement.advancedachievements.AdvancedAchie
|
|||||||
import sh.okx.rankup.requirements.requirement.advancedachievements.AdvancedAchievementsTotalRequirement;
|
import sh.okx.rankup.requirements.requirement.advancedachievements.AdvancedAchievementsTotalRequirement;
|
||||||
import sh.okx.rankup.requirements.requirement.mcmmo.McMMOPowerLevelRequirement;
|
import sh.okx.rankup.requirements.requirement.mcmmo.McMMOPowerLevelRequirement;
|
||||||
import sh.okx.rankup.requirements.requirement.mcmmo.McMMOSkillRequirement;
|
import sh.okx.rankup.requirements.requirement.mcmmo.McMMOSkillRequirement;
|
||||||
|
import sh.okx.rankup.requirements.requirement.superbvote.SuperbVoteVotesRequirement;
|
||||||
import sh.okx.rankup.requirements.requirement.tokenmanager.TokensDeductibleRequirement;
|
import sh.okx.rankup.requirements.requirement.tokenmanager.TokensDeductibleRequirement;
|
||||||
import sh.okx.rankup.requirements.requirement.tokenmanager.TokensRequirement;
|
import sh.okx.rankup.requirements.requirement.tokenmanager.TokensRequirement;
|
||||||
import sh.okx.rankup.requirements.requirement.towny.TownyKingNumberResidentsRequirement;
|
import sh.okx.rankup.requirements.requirement.towny.TownyKingNumberResidentsRequirement;
|
||||||
@@ -406,6 +408,9 @@ public class RankupPlugin extends JavaPlugin {
|
|||||||
new TokensRequirement(this, "tokenmanager-tokensh"),
|
new TokensRequirement(this, "tokenmanager-tokensh"),
|
||||||
new TokensDeductibleRequirement(this, "tokenmanager-tokens"));
|
new TokensDeductibleRequirement(this, "tokenmanager-tokens"));
|
||||||
}
|
}
|
||||||
|
if (Bukkit.getPluginManager().isPluginEnabled("SuperbVotes")) {
|
||||||
|
requirements.addRequirements(new SuperbVoteVotesRequirement(this));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
private void setupEconomy() {
|
private void setupEconomy() {
|
||||||
economy = economyProvider.getEconomy();
|
economy = economyProvider.getEconomy();
|
||||||
@@ -521,7 +526,7 @@ public class RankupPlugin extends JavaPlugin {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return replaceMoneyRequirements(getMessage(oldRank, message)
|
return replaceMoneyRequirements(getMessage(oldRank, message)
|
||||||
.replaceRanks(player, rankName.getRank())
|
.replaceRanks(player, rankName)
|
||||||
.replace(Variable.OLD_RANK, oldRankName), player, oldRank)
|
.replace(Variable.OLD_RANK, oldRankName), player, oldRank)
|
||||||
.replaceFromTo(oldRank);
|
.replaceFromTo(oldRank);
|
||||||
}
|
}
|
||||||
@@ -535,7 +540,7 @@ public class RankupPlugin extends JavaPlugin {
|
|||||||
} else {
|
} else {
|
||||||
builder = getMessage(rank, type)
|
builder = getMessage(rank, type)
|
||||||
.failIfEmpty()
|
.failIfEmpty()
|
||||||
.replaceRanks(sender, rank.getRank())
|
.replaceRanks(sender, rank)
|
||||||
.replaceFromTo(rank);
|
.replaceFromTo(rank);
|
||||||
}
|
}
|
||||||
builder.send(sender);
|
builder.send(sender);
|
||||||
|
|||||||
@@ -1,5 +1,10 @@
|
|||||||
package sh.okx.rankup.commands;
|
package sh.okx.rankup.commands;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
@@ -18,8 +23,6 @@ import sh.okx.rankup.ranks.RankElement;
|
|||||||
import sh.okx.rankup.ranks.Rankups;
|
import sh.okx.rankup.ranks.Rankups;
|
||||||
import sh.okx.rankup.util.UpdateNotifier;
|
import sh.okx.rankup.util.UpdateNotifier;
|
||||||
|
|
||||||
import java.util.*;
|
|
||||||
|
|
||||||
public class InfoCommand implements TabExecutor {
|
public class InfoCommand implements TabExecutor {
|
||||||
private final RankupPlugin plugin;
|
private final RankupPlugin plugin;
|
||||||
|
|
||||||
@@ -130,7 +133,7 @@ public class InfoCommand implements TabExecutor {
|
|||||||
|
|
||||||
if (plugin.getRankups().getFirst().equals(currentRank)) {
|
if (plugin.getRankups().getFirst().equals(currentRank)) {
|
||||||
sender.sendMessage(ChatColor.YELLOW + "That player is in the first rank and cannot be ranked down.");
|
sender.sendMessage(ChatColor.YELLOW + "That player is in the first rank and cannot be ranked down.");
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
RankElement<Rank> prevRankElement = plugin.getRankups().getTree().getFirst();
|
RankElement<Rank> prevRankElement = plugin.getRankups().getTree().getFirst();
|
||||||
@@ -140,6 +143,7 @@ public class InfoCommand implements TabExecutor {
|
|||||||
|
|
||||||
if (!prevRankElement.hasNext()) {
|
if (!prevRankElement.hasNext()) {
|
||||||
sender.sendMessage(ChatColor.YELLOW + "Could not match previous rank.");
|
sender.sendMessage(ChatColor.YELLOW + "Could not match previous rank.");
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
Rank prevRank = prevRankElement.getRank();
|
Rank prevRank = prevRankElement.getRank();
|
||||||
|
|
||||||
@@ -214,6 +218,7 @@ public class InfoCommand implements TabExecutor {
|
|||||||
ChatColor.GREEN + "/" + label + " forceprestige <player> " + ChatColor.YELLOW
|
ChatColor.GREEN + "/" + label + " forceprestige <player> " + ChatColor.YELLOW
|
||||||
+ "Force a player to prestige, bypassing requirements.");
|
+ "Force a player to prestige, bypassing requirements.");
|
||||||
}
|
}
|
||||||
|
sender.sendMessage(ChatColor.GREEN + "/" + label + " rankdown <player> " + ChatColor.YELLOW + "Force a player to move down one rank.");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sender.hasPermission("rankup.checkversion")) {
|
if (sender.hasPermission("rankup.checkversion")) {
|
||||||
@@ -239,7 +244,7 @@ public class InfoCommand implements TabExecutor {
|
|||||||
} else if (args.length == 2) {
|
} else if (args.length == 2) {
|
||||||
if (args[0].equalsIgnoreCase("forcerankup") && sender.hasPermission("rankup.force")) {
|
if (args[0].equalsIgnoreCase("forcerankup") && sender.hasPermission("rankup.force")) {
|
||||||
return StringUtil.copyPartialMatches(args[1], players(), new ArrayList<>());
|
return StringUtil.copyPartialMatches(args[1], players(), new ArrayList<>());
|
||||||
} else if (args[0].equalsIgnoreCase("forceprestige") && sender.hasPermission("rankup.force")) {
|
} else if (args[0].equalsIgnoreCase("forceprestige") && sender.hasPermission("rankup.force") && plugin.getPrestiges() != null) {
|
||||||
return StringUtil.copyPartialMatches(args[1], players(), new ArrayList<>());
|
return StringUtil.copyPartialMatches(args[1], players(), new ArrayList<>());
|
||||||
} else if (args[0].equalsIgnoreCase("rankdown") && sender.hasPermission("rankup.force")) {
|
} else if (args[0].equalsIgnoreCase("rankdown") && sender.hasPermission("rankup.force")) {
|
||||||
return StringUtil.copyPartialMatches(args[1], players(), new ArrayList<>());
|
return StringUtil.copyPartialMatches(args[1], players(), new ArrayList<>());
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ import sh.okx.rankup.gui.Gui;
|
|||||||
import sh.okx.rankup.messages.Message;
|
import sh.okx.rankup.messages.Message;
|
||||||
import sh.okx.rankup.prestige.Prestige;
|
import sh.okx.rankup.prestige.Prestige;
|
||||||
import sh.okx.rankup.prestige.Prestiges;
|
import sh.okx.rankup.prestige.Prestiges;
|
||||||
|
import sh.okx.rankup.ranks.Rank;
|
||||||
import sh.okx.rankup.ranks.RankElement;
|
import sh.okx.rankup.ranks.RankElement;
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
@@ -55,7 +56,7 @@ public class PrestigeCommand implements CommandExecutor {
|
|||||||
case "text":
|
case "text":
|
||||||
confirming.put(player, System.currentTimeMillis());
|
confirming.put(player, System.currentTimeMillis());
|
||||||
Prestige next = rankElement.getNext().getRank();
|
Prestige next = rankElement.getNext().getRank();
|
||||||
String nextRank = next == null ? prestiges.getTree().last().getRank().getRank() : next.getRank();
|
Rank nextRank = next == null ? prestiges.getTree().last().getRank() : next;
|
||||||
|
|
||||||
plugin.replaceMoneyRequirements(plugin.getMessage(prestige, Message.PRESTIGE_CONFIRMATION)
|
plugin.replaceMoneyRequirements(plugin.getMessage(prestige, Message.PRESTIGE_CONFIRMATION)
|
||||||
.replaceRanks(player, prestige, nextRank), player, prestige)
|
.replaceRanks(player, prestige, nextRank), player, prestige)
|
||||||
|
|||||||
@@ -0,0 +1,36 @@
|
|||||||
|
package sh.okx.rankup.events;
|
||||||
|
|
||||||
|
import lombok.Getter;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.HandlerList;
|
||||||
|
import org.bukkit.event.player.PlayerEvent;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
import sh.okx.rankup.RankupPlugin;
|
||||||
|
import sh.okx.rankup.prestige.Prestige;
|
||||||
|
import sh.okx.rankup.ranks.RankElement;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called when a player ranks up from one prestige to another.
|
||||||
|
*/
|
||||||
|
public class PlayerPrestigeEvent extends PlayerEvent {
|
||||||
|
private static final HandlerList handlers = new HandlerList();
|
||||||
|
@Getter
|
||||||
|
private final RankupPlugin plugin;
|
||||||
|
/**
|
||||||
|
* The prestige someone is current at. Use <code>RankElement#getNext()</code> to get the prestige
|
||||||
|
* a player is ranking up to.
|
||||||
|
*/
|
||||||
|
@Getter
|
||||||
|
private final RankElement<Prestige> prestige;
|
||||||
|
|
||||||
|
public PlayerPrestigeEvent(RankupPlugin plugin, @NotNull Player who, RankElement<Prestige> prestige) {
|
||||||
|
super(who);
|
||||||
|
this.plugin = plugin;
|
||||||
|
this.prestige = prestige;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public HandlerList getHandlers() {
|
||||||
|
return handlers;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,36 @@
|
|||||||
|
package sh.okx.rankup.events;
|
||||||
|
|
||||||
|
import lombok.Getter;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.HandlerList;
|
||||||
|
import org.bukkit.event.player.PlayerEvent;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
import sh.okx.rankup.RankupPlugin;
|
||||||
|
import sh.okx.rankup.ranks.Rank;
|
||||||
|
import sh.okx.rankup.ranks.RankElement;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called when a player ranks up from one rank to another.
|
||||||
|
*/
|
||||||
|
public class PlayerRankupEvent extends PlayerEvent {
|
||||||
|
private static final HandlerList handlers = new HandlerList();
|
||||||
|
@Getter
|
||||||
|
private final RankupPlugin plugin;
|
||||||
|
/**
|
||||||
|
* The rank someone is current at. Use <code>RankElement#getNext()</code> to get the rank
|
||||||
|
* a player is ranking up to.
|
||||||
|
*/
|
||||||
|
@Getter
|
||||||
|
private final RankElement<Rank> rank;
|
||||||
|
|
||||||
|
public PlayerRankupEvent(RankupPlugin plugin, @NotNull Player who, RankElement<Rank> rank) {
|
||||||
|
super(who);
|
||||||
|
this.plugin = plugin;
|
||||||
|
this.rank = rank;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public HandlerList getHandlers() {
|
||||||
|
return handlers;
|
||||||
|
}
|
||||||
|
}
|
||||||
+4
-3
@@ -1,9 +1,10 @@
|
|||||||
package sh.okx.rankup;
|
package sh.okx.rankup.events;
|
||||||
|
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import org.bukkit.event.Event;
|
import org.bukkit.event.Event;
|
||||||
import org.bukkit.event.HandlerList;
|
import org.bukkit.event.HandlerList;
|
||||||
|
import sh.okx.rankup.RankupPlugin;
|
||||||
import sh.okx.rankup.requirements.Requirement;
|
import sh.okx.rankup.requirements.Requirement;
|
||||||
import sh.okx.rankup.requirements.RequirementRegistry;
|
import sh.okx.rankup.requirements.RequirementRegistry;
|
||||||
|
|
||||||
@@ -27,8 +28,8 @@ public class RankupRegisterEvent extends Event {
|
|||||||
return plugin.getRequirements();
|
return plugin.getRequirements();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addRequirement(Requirement requirement) {
|
public void addRequirement(Requirement requirement, Requirement... requirements) {
|
||||||
plugin.getRequirements().addRequirement(requirement);
|
plugin.getRequirements().addRequirements(requirement, requirements);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -21,6 +21,7 @@ import sh.okx.rankup.messages.MessageBuilder;
|
|||||||
import sh.okx.rankup.prestige.Prestige;
|
import sh.okx.rankup.prestige.Prestige;
|
||||||
import sh.okx.rankup.ranks.Rank;
|
import sh.okx.rankup.ranks.Rank;
|
||||||
import sh.okx.rankup.ranks.RankElement;
|
import sh.okx.rankup.ranks.RankElement;
|
||||||
|
import sh.okx.rankup.util.Colour;
|
||||||
import sh.okx.rankup.util.ItemUtil;
|
import sh.okx.rankup.util.ItemUtil;
|
||||||
|
|
||||||
@RequiredArgsConstructor(access = AccessLevel.PRIVATE)
|
@RequiredArgsConstructor(access = AccessLevel.PRIVATE)
|
||||||
@@ -62,10 +63,10 @@ public class Gui implements InventoryHolder {
|
|||||||
gui.cancel = cancel;
|
gui.cancel = cancel;
|
||||||
|
|
||||||
Inventory inventory = Bukkit.createInventory(gui, items.length,
|
Inventory inventory = Bukkit.createInventory(gui, items.length,
|
||||||
ChatColor.stripColor(ChatColor.translateAlternateColorCodes('&', plugin.replaceMoneyRequirements(
|
Colour.translate(plugin.replaceMoneyRequirements(
|
||||||
plugin.getMessage(oldRank, gui.prestige ? Message.PRESTIGE_TITLE : Message.TITLE)
|
plugin.getMessage(oldRank, gui.prestige ? Message.PRESTIGE_TITLE : Message.TITLE)
|
||||||
.replaceRanks(player, oldRank, rank)
|
.replaceRanks(player, oldRank, rank)
|
||||||
.replaceFromTo(oldRank), player, oldRank).toString())));
|
.replaceFromTo(oldRank), player, oldRank).toString()));
|
||||||
inventory.setContents(items);
|
inventory.setContents(items);
|
||||||
gui.inventory = inventory;
|
gui.inventory = inventory;
|
||||||
return gui;
|
return gui;
|
||||||
@@ -75,7 +76,8 @@ public class Gui implements InventoryHolder {
|
|||||||
if (element == null) {
|
if (element == null) {
|
||||||
return getItem(plugin, section, player, null, null);
|
return getItem(plugin, section, player, null, null);
|
||||||
} else {
|
} else {
|
||||||
return getItem(plugin, section, player, element.getRank(), element.getNext().getRank());
|
RankElement<Rank> next = element.getNext();
|
||||||
|
return getItem(plugin, section, player, element.getRank(), (next == null ? element : next).getRank());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -125,7 +127,7 @@ public class Gui implements InventoryHolder {
|
|||||||
if (oldRank != null && rank != null) {
|
if (oldRank != null && rank != null) {
|
||||||
builder = builder.replaceRanks(player, oldRank, rank);
|
builder = builder.replaceRanks(player, oldRank, rank);
|
||||||
}
|
}
|
||||||
return ChatColor.translateAlternateColorCodes('&', plugin.replaceMoneyRequirements(builder, player, oldRank).toString());
|
return Colour.translate(plugin.replaceMoneyRequirements(builder, player, oldRank).toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void addItem(ItemStack[] items, ConfigurationSection section, ItemStack item) {
|
private static void addItem(ItemStack[] items, ConfigurationSection section, ItemStack item) {
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ public class GuiListener implements Listener {
|
|||||||
Bukkit.getScheduler().runTask(plugin, () -> {
|
Bukkit.getScheduler().runTask(plugin, () -> {
|
||||||
player.closeInventory();
|
player.closeInventory();
|
||||||
if (gui.isReturnToRanksGui()) {
|
if (gui.isReturnToRanksGui()) {
|
||||||
Bukkit.dispatchCommand(player, "ranksgui");
|
Bukkit.dispatchCommand(player, "ranks");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,18 +1,17 @@
|
|||||||
package sh.okx.rankup.messages;
|
package sh.okx.rankup.messages;
|
||||||
|
|
||||||
|
import java.util.Objects;
|
||||||
|
import java.util.regex.Matcher;
|
||||||
|
import java.util.regex.Pattern;
|
||||||
import me.clip.placeholderapi.PlaceholderAPI;
|
import me.clip.placeholderapi.PlaceholderAPI;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.ChatColor;
|
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.configuration.ConfigurationSection;
|
import org.bukkit.configuration.ConfigurationSection;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import sh.okx.rankup.prestige.Prestige;
|
import sh.okx.rankup.prestige.Prestige;
|
||||||
import sh.okx.rankup.prestige.Prestiges;
|
import sh.okx.rankup.prestige.Prestiges;
|
||||||
import sh.okx.rankup.ranks.Rank;
|
import sh.okx.rankup.ranks.Rank;
|
||||||
|
import sh.okx.rankup.util.Colour;
|
||||||
import java.util.Objects;
|
|
||||||
import java.util.regex.Matcher;
|
|
||||||
import java.util.regex.Pattern;
|
|
||||||
|
|
||||||
public class MessageBuilder {
|
public class MessageBuilder {
|
||||||
private String message;
|
private String message;
|
||||||
@@ -28,7 +27,7 @@ public class MessageBuilder {
|
|||||||
private static MessageBuilder of(ConfigurationSection config, String message) {
|
private static MessageBuilder of(ConfigurationSection config, String message) {
|
||||||
String string = config.getString(message);
|
String string = config.getString(message);
|
||||||
Objects.requireNonNull(string, "Configuration message '" + message + "' not found!");
|
Objects.requireNonNull(string, "Configuration message '" + message + "' not found!");
|
||||||
return new MessageBuilder(ChatColor.translateAlternateColorCodes('&', string));
|
return new MessageBuilder(Colour.translate(string));
|
||||||
}
|
}
|
||||||
|
|
||||||
public MessageBuilder replace(Variable variable, Object value) {
|
public MessageBuilder replace(Variable variable, Object value) {
|
||||||
@@ -36,6 +35,9 @@ public class MessageBuilder {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public MessageBuilder replace(String name, Object value) {
|
public MessageBuilder replace(String name, Object value) {
|
||||||
|
if (value == null) {
|
||||||
|
return this;
|
||||||
|
}
|
||||||
Pattern pattern = Pattern.compile("\\{" + name + "}", Pattern.CASE_INSENSITIVE);
|
Pattern pattern = Pattern.compile("\\{" + name + "}", Pattern.CASE_INSENSITIVE);
|
||||||
Matcher matcher = pattern.matcher(message);
|
Matcher matcher = pattern.matcher(message);
|
||||||
this.message = matcher.replaceAll(String.valueOf(value));
|
this.message = matcher.replaceAll(String.valueOf(value));
|
||||||
@@ -49,24 +51,33 @@ public class MessageBuilder {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
public MessageBuilder replaceRanks(CommandSender player, String rankName) {
|
public MessageBuilder replaceRanks(CommandSender player, String rankName) {
|
||||||
replace(Variable.PLAYER, player.getName());
|
replace(Variable.PLAYER, player.getName());
|
||||||
replaceRanks(rankName);
|
replaceRanks(rankName);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
public MessageBuilder replaceRanks(CommandSender player, Rank oldRank, String rankName) {
|
public MessageBuilder replaceRanks(CommandSender player, Rank oldRank, String rankName) {
|
||||||
replace(Variable.PLAYER, player.getName());
|
replace(Variable.PLAYER, player.getName());
|
||||||
replaceRanks(oldRank, rankName);
|
replaceRanks(oldRank, rankName);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public MessageBuilder replaceRanks(CommandSender player, Rank rank) {
|
||||||
|
replace(Variable.PLAYER, player.getName());
|
||||||
|
replaceRanks(rank);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
public MessageBuilder replaceRanks(CommandSender player, Rank oldRank, Rank rank) {
|
public MessageBuilder replaceRanks(CommandSender player, Rank oldRank, Rank rank) {
|
||||||
replace(Variable.PLAYER, player.getName());
|
replace(Variable.PLAYER, player.getName());
|
||||||
replaceRanks(oldRank, rank);
|
replaceRanks(oldRank, rank);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
public MessageBuilder replaceRanks(String rankName) {
|
public MessageBuilder replaceRanks(String rankName) {
|
||||||
replace(Variable.RANK, rankName);
|
replace(Variable.RANK, rankName);
|
||||||
return this;
|
return this;
|
||||||
@@ -74,18 +85,22 @@ public class MessageBuilder {
|
|||||||
|
|
||||||
public MessageBuilder replaceRanks(Rank rank) {
|
public MessageBuilder replaceRanks(Rank rank) {
|
||||||
replace(Variable.RANK, rank.getRank());
|
replace(Variable.RANK, rank.getRank());
|
||||||
|
replace(Variable.RANK_NAME, rank.getDisplayName());
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
public MessageBuilder replaceRanks(Rank oldRank, String rankName) {
|
public MessageBuilder replaceRanks(Rank oldRank, String rankName) {
|
||||||
replaceRanks(rankName);
|
replaceRanks(rankName);
|
||||||
replace(Variable.OLD_RANK, oldRank.getRank());
|
replace(Variable.OLD_RANK, oldRank.getRank());
|
||||||
|
replace(Variable.OLD_RANK_NAME, oldRank.getDisplayName());
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public MessageBuilder replaceRanks(Rank oldRank, Rank rank) {
|
public MessageBuilder replaceRanks(Rank oldRank, Rank rank) {
|
||||||
replaceRanks(rank);
|
replaceRanks(rank);
|
||||||
replace(Variable.OLD_RANK, oldRank.getRank());
|
replace(Variable.OLD_RANK, oldRank.getRank());
|
||||||
|
replace(Variable.OLD_RANK_NAME, oldRank.getDisplayName());
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2,7 +2,9 @@ package sh.okx.rankup.messages;
|
|||||||
|
|
||||||
public enum Variable {
|
public enum Variable {
|
||||||
PLAYER,
|
PLAYER,
|
||||||
|
OLD_RANK_NAME,
|
||||||
OLD_RANK,
|
OLD_RANK,
|
||||||
|
RANK_NAME,
|
||||||
RANK,
|
RANK,
|
||||||
FROM,
|
FROM,
|
||||||
TO,
|
TO,
|
||||||
|
|||||||
@@ -1,12 +1,10 @@
|
|||||||
package sh.okx.rankup.placeholders;
|
package sh.okx.rankup.placeholders;
|
||||||
|
|
||||||
|
import java.text.DecimalFormat;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import me.clip.placeholderapi.PlaceholderAPI;
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import sh.okx.rankup.RankupPlugin;
|
import sh.okx.rankup.RankupPlugin;
|
||||||
|
|
||||||
import java.text.DecimalFormat;
|
|
||||||
|
|
||||||
public class Placeholders {
|
public class Placeholders {
|
||||||
private final RankupPlugin plugin;
|
private final RankupPlugin plugin;
|
||||||
@Getter
|
@Getter
|
||||||
@@ -17,7 +15,8 @@ public class Placeholders {
|
|||||||
private final DecimalFormat simpleFormat;
|
private final DecimalFormat simpleFormat;
|
||||||
@Getter
|
@Getter
|
||||||
private RankupExpansion expansion;
|
private RankupExpansion expansion;
|
||||||
private boolean registered;
|
|
||||||
|
private RankupPlaceholderExpansion papiExpansion;
|
||||||
|
|
||||||
public Placeholders(RankupPlugin plugin) {
|
public Placeholders(RankupPlugin plugin) {
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
@@ -29,17 +28,14 @@ public class Placeholders {
|
|||||||
public void register() {
|
public void register() {
|
||||||
expansion = new RankupExpansion(plugin, this);
|
expansion = new RankupExpansion(plugin, this);
|
||||||
if (Bukkit.getPluginManager().isPluginEnabled("PlaceholderAPI")) {
|
if (Bukkit.getPluginManager().isPluginEnabled("PlaceholderAPI")) {
|
||||||
RankupPlaceholderExpansion placeholderExpansion = new RankupPlaceholderExpansion(plugin, expansion);
|
papiExpansion = new RankupPlaceholderExpansion(plugin, expansion);
|
||||||
placeholderExpansion.register();
|
papiExpansion.register();
|
||||||
registered = true;
|
|
||||||
} else {
|
|
||||||
registered = false;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void unregister() {
|
public void unregister() {
|
||||||
if (registered) {
|
if (papiExpansion != null) {
|
||||||
PlaceholderAPI.unregisterPlaceholderHook("rankup");
|
papiExpansion.unregister();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,12 +1,10 @@
|
|||||||
package sh.okx.rankup.prestige;
|
package sh.okx.rankup.prestige;
|
||||||
|
|
||||||
|
import java.util.Collections;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import sh.okx.rankup.RankupPlugin;
|
import sh.okx.rankup.RankupPlugin;
|
||||||
|
import sh.okx.rankup.ranks.Rank;
|
||||||
import sh.okx.rankup.ranks.requirements.LastRankRequirements;
|
import sh.okx.rankup.ranks.requirements.LastRankRequirements;
|
||||||
import sh.okx.rankup.requirements.NullRequirement;
|
|
||||||
import sh.okx.rankup.requirements.Requirement;
|
|
||||||
|
|
||||||
import java.util.Collections;
|
|
||||||
|
|
||||||
public class LastPrestige extends Prestige {
|
public class LastPrestige extends Prestige {
|
||||||
public LastPrestige(RankupPlugin plugin, String name) {
|
public LastPrestige(RankupPlugin plugin, String name) {
|
||||||
@@ -23,17 +21,12 @@ public class LastPrestige extends Prestige {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public Requirement getRequirement(Player player, String name) {
|
|
||||||
return new NullRequirement();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void applyRequirements(Player player) {
|
public void applyRequirements(Player player) {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void runCommands(Player player) {
|
public void runCommands(Player player, Rank next) {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ public class Prestige extends Rank {
|
|||||||
private final String to;
|
private final String to;
|
||||||
|
|
||||||
protected Prestige(ConfigurationSection section, RankupPlugin plugin, String next, String rank, RankRequirements requirements, List<String> commands, String from, String to) {
|
protected Prestige(ConfigurationSection section, RankupPlugin plugin, String next, String rank, RankRequirements requirements, List<String> commands, String from, String to) {
|
||||||
super(section, plugin, next, rank, requirements, commands);
|
super(section, plugin, next, rank, rank, requirements, commands);
|
||||||
this.from = from;
|
this.from = from;
|
||||||
this.to = to;
|
this.to = to;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ public class Prestiges extends RankList<Prestige> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addLastRank(RankupPlugin plugin) {
|
protected void addLastRank(RankupPlugin plugin) {
|
||||||
RankElement<Prestige> last = getTree().last();
|
RankElement<Prestige> last = getTree().last();
|
||||||
last.setNext(new RankElement<>(new LastPrestige(plugin, last.getRank().getNext()), null));
|
last.setNext(new RankElement<>(new LastPrestige(plugin, last.getRank().getNext()), null));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,16 +1,13 @@
|
|||||||
package sh.okx.rankup.ranks;
|
package sh.okx.rankup.ranks;
|
||||||
|
|
||||||
|
import java.util.Collections;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import sh.okx.rankup.RankupPlugin;
|
import sh.okx.rankup.RankupPlugin;
|
||||||
import sh.okx.rankup.ranks.requirements.LastRankRequirements;
|
import sh.okx.rankup.ranks.requirements.LastRankRequirements;
|
||||||
import sh.okx.rankup.requirements.NullRequirement;
|
|
||||||
import sh.okx.rankup.requirements.Requirement;
|
|
||||||
|
|
||||||
import java.util.Collections;
|
|
||||||
|
|
||||||
public class LastRank extends Rank {
|
public class LastRank extends Rank {
|
||||||
public LastRank(RankupPlugin plugin, String name) {
|
public LastRank(RankupPlugin plugin, String name, String displayName) {
|
||||||
super(null, plugin, null, name, new LastRankRequirements(), Collections.emptyList());
|
super(null, plugin, null, name, displayName, new LastRankRequirements(), Collections.emptyList());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -18,16 +15,11 @@ public class LastRank extends Rank {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public Requirement getRequirement(Player player, String name) {
|
|
||||||
return new NullRequirement();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void applyRequirements(Player player) {
|
public void applyRequirements(Player player) {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void runCommands(Player player) {
|
public void runCommands(Player player, Rank next) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,7 +26,10 @@ public class Rank {
|
|||||||
@Getter
|
@Getter
|
||||||
protected final String rank;
|
protected final String rank;
|
||||||
@Getter
|
@Getter
|
||||||
|
protected final String displayName;
|
||||||
|
@Getter
|
||||||
protected final RankRequirements requirements;
|
protected final RankRequirements requirements;
|
||||||
|
@Getter
|
||||||
protected final List<String> commands;
|
protected final List<String> commands;
|
||||||
|
|
||||||
public boolean isIn(Player player) {
|
public boolean isIn(Player player) {
|
||||||
@@ -45,8 +48,7 @@ public class Rank {
|
|||||||
requirements.applyRequirements(player);
|
requirements.applyRequirements(player);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void runCommands(Player player, Rank next) {
|
||||||
public void runCommands(Player player) {
|
|
||||||
for (String command : commands) {
|
for (String command : commands) {
|
||||||
String string = new MessageBuilder(command).replaceRanks(player, this, next).toString();
|
String string = new MessageBuilder(command).replaceRanks(player, this, next).toString();
|
||||||
if (Bukkit.getPluginManager().isPluginEnabled("PlaceholderAPI")) {
|
if (Bukkit.getPluginManager().isPluginEnabled("PlaceholderAPI")) {
|
||||||
|
|||||||
@@ -1,14 +1,18 @@
|
|||||||
package sh.okx.rankup.ranks;
|
package sh.okx.rankup.ranks;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
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 lombok.Getter;
|
||||||
import org.bukkit.configuration.ConfigurationSection;
|
import org.bukkit.configuration.ConfigurationSection;
|
||||||
import org.bukkit.configuration.file.FileConfiguration;
|
import org.bukkit.configuration.file.FileConfiguration;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import sh.okx.rankup.RankupPlugin;
|
import sh.okx.rankup.RankupPlugin;
|
||||||
|
|
||||||
import java.util.*;
|
|
||||||
import java.util.function.Function;
|
|
||||||
|
|
||||||
public abstract class RankList<T extends Rank> {
|
public abstract class RankList<T extends Rank> {
|
||||||
|
|
||||||
protected RankupPlugin plugin;
|
protected RankupPlugin plugin;
|
||||||
@@ -45,7 +49,7 @@ public abstract class RankList<T extends Rank> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public abstract void addLastRank(RankupPlugin plugin);
|
protected abstract void addLastRank(RankupPlugin plugin);
|
||||||
|
|
||||||
private RankElement<T> findNext(T rank, List<RankElement<T>> rankElements) {
|
private RankElement<T> findNext(T rank, List<RankElement<T>> rankElements) {
|
||||||
Objects.requireNonNull(rank);
|
Objects.requireNonNull(rank);
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ public class Rankup extends Rank {
|
|||||||
public static Rankup deserialize(RankupPlugin plugin, ConfigurationSection section) {
|
public static Rankup deserialize(RankupPlugin plugin, ConfigurationSection section) {
|
||||||
String next = section.getString("next");
|
String next = section.getString("next");
|
||||||
String rank = section.getString("rank");
|
String rank = section.getString("rank");
|
||||||
|
String displayName = section.getString("display-name");
|
||||||
|
|
||||||
if (next == null || next.isEmpty()) {
|
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"
|
plugin.getLogger().warning("Having a final rank (for example: \"Z: rank: 'Z'\") from 3.4.2 or earlier should no longer be used.\n"
|
||||||
@@ -23,13 +24,14 @@ public class Rankup extends Rank {
|
|||||||
plugin,
|
plugin,
|
||||||
next,
|
next,
|
||||||
rank,
|
rank,
|
||||||
|
displayName,
|
||||||
RankRequirementsFactory.getRequirements(plugin, section),
|
RankRequirementsFactory.getRequirements(plugin, section),
|
||||||
section.getStringList("commands"));
|
section.getStringList("commands"));
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Rankup(ConfigurationSection section, RankupPlugin plugin, String next, String rank,
|
protected Rankup(ConfigurationSection section, RankupPlugin plugin, String next, String rank, String displayName,
|
||||||
RankRequirements requirements,
|
RankRequirements requirements,
|
||||||
List<String> commands) {
|
List<String> commands) {
|
||||||
super(section, plugin, next, rank, requirements, commands);
|
super(section, plugin, next, rank, displayName, requirements, commands);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,13 +4,19 @@ import org.bukkit.configuration.file.FileConfiguration;
|
|||||||
import sh.okx.rankup.RankupPlugin;
|
import sh.okx.rankup.RankupPlugin;
|
||||||
|
|
||||||
public class Rankups extends RankList<Rank> {
|
public class Rankups extends RankList<Rank> {
|
||||||
|
|
||||||
public Rankups(RankupPlugin plugin, FileConfiguration config) {
|
public Rankups(RankupPlugin plugin, FileConfiguration config) {
|
||||||
super(plugin, config, section -> Rankup.deserialize(plugin, section));
|
super(plugin, config, section -> Rankup.deserialize(plugin, section));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addLastRank(RankupPlugin plugin) {
|
protected void addLastRank(RankupPlugin plugin) {
|
||||||
RankElement<Rank> last = getTree().last();
|
RankElement<Rank> last = getTree().last();
|
||||||
last.setNext(new RankElement<>(new LastRank(plugin, last.getRank().getNext()), null));
|
String lastRankDisplayName = plugin.getConfig().getString("placeholders.last-rank-display-name");
|
||||||
|
String lastRankName = last.getRank().getNext();
|
||||||
|
if (lastRankDisplayName == null) {
|
||||||
|
lastRankDisplayName = lastRankName;
|
||||||
|
}
|
||||||
|
last.setNext(new RankElement<>(new LastRank(plugin, lastRankName, lastRankDisplayName), null));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ import sh.okx.rankup.RankupPlugin;
|
|||||||
import sh.okx.rankup.gui.Gui;
|
import sh.okx.rankup.gui.Gui;
|
||||||
import sh.okx.rankup.ranks.Rank;
|
import sh.okx.rankup.ranks.Rank;
|
||||||
import sh.okx.rankup.ranks.RankElement;
|
import sh.okx.rankup.ranks.RankElement;
|
||||||
|
import sh.okx.rankup.util.Colour;
|
||||||
|
|
||||||
public class RanksGui {
|
public class RanksGui {
|
||||||
private final RankupPlugin plugin;
|
private final RankupPlugin plugin;
|
||||||
@@ -38,7 +39,7 @@ public class RanksGui {
|
|||||||
int offset = get(ConfigurationSection::getInt, "offset", playerPath, basePath, 10);
|
int offset = get(ConfigurationSection::getInt, "offset", playerPath, basePath, 10);
|
||||||
int width = get(ConfigurationSection::getInt, "width", playerPath, basePath, 7);
|
int width = get(ConfigurationSection::getInt, "width", playerPath, basePath, 7);
|
||||||
|
|
||||||
inventory = Bukkit.createInventory(null, rows * 9, title);
|
inventory = Bukkit.createInventory(null, rows * 9, Colour.translate(title));
|
||||||
|
|
||||||
ItemStack fill = get((section, path) -> Gui.getItem(plugin, section.getConfigurationSection(path), player, playerRankElement), "fill", playerPath, basePath, null);
|
ItemStack fill = get((section, path) -> Gui.getItem(plugin, section.getConfigurationSection(path), player, playerRankElement), "fill", playerPath, basePath, null);
|
||||||
|
|
||||||
|
|||||||
@@ -8,11 +8,13 @@ import java.util.Set;
|
|||||||
public class RequirementRegistry {
|
public class RequirementRegistry {
|
||||||
private final Set<Requirement> requirements = new HashSet<>();
|
private final Set<Requirement> requirements = new HashSet<>();
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
public void addRequirement(Requirement requirement) {
|
public void addRequirement(Requirement requirement) {
|
||||||
requirements.add(requirement);
|
requirements.add(requirement);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addRequirements(Requirement... requirements) {
|
public void addRequirements(Requirement requirement, Requirement... requirements) {
|
||||||
|
this.requirements.add(requirement);
|
||||||
Collections.addAll(this.requirements, requirements);
|
Collections.addAll(this.requirements, requirements);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -31,8 +31,8 @@ public class PlaceholderRequirement extends ProgressiveRequirement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// numeric operations
|
// numeric operations
|
||||||
double p = Double.parseDouble(parsed);
|
double p = Double.parseDouble(parsed.replace(",", ""));
|
||||||
double v = Double.parseDouble(value);
|
double v = Double.parseDouble(value.replace(",", ""));
|
||||||
switch (parts[1]) {
|
switch (parts[1]) {
|
||||||
case ">":
|
case ">":
|
||||||
return p > v ? v : 0;
|
return p > v ? v : 0;
|
||||||
|
|||||||
+27
@@ -0,0 +1,27 @@
|
|||||||
|
package sh.okx.rankup.requirements.requirement.superbvote;
|
||||||
|
|
||||||
|
import io.minimum.minecraft.superbvote.SuperbVote;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import sh.okx.rankup.RankupPlugin;
|
||||||
|
import sh.okx.rankup.requirements.ProgressiveRequirement;
|
||||||
|
import sh.okx.rankup.requirements.Requirement;
|
||||||
|
|
||||||
|
public class SuperbVoteVotesRequirement extends ProgressiveRequirement {
|
||||||
|
public SuperbVoteVotesRequirement(RankupPlugin plugin) {
|
||||||
|
super(plugin, "superbvote-votes");
|
||||||
|
}
|
||||||
|
|
||||||
|
private SuperbVoteVotesRequirement(Requirement clone) {
|
||||||
|
super(clone);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public double getProgress(Player player) {
|
||||||
|
return SuperbVote.getPlugin().getVoteStorage().getVotes(player.getUniqueId()).getVotes();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Requirement clone() {
|
||||||
|
return new SuperbVoteVotesRequirement(this);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,30 @@
|
|||||||
|
package sh.okx.rankup.util;
|
||||||
|
|
||||||
|
import net.md_5.bungee.api.ChatColor;
|
||||||
|
|
||||||
|
public class Colour {
|
||||||
|
|
||||||
|
private static final char altColorChar = '&';
|
||||||
|
|
||||||
|
public static String translate(String string) {
|
||||||
|
StringBuilder result = new StringBuilder();
|
||||||
|
char[] b = string.toCharArray();
|
||||||
|
for (int i = 0; i < b.length; i++) {
|
||||||
|
if (b[i] == altColorChar && i < b.length - 1) {
|
||||||
|
if ("0123456789AaBbCcDdEeFfKkLlMmNnOoRr".indexOf(b[i + 1]) > -1) {
|
||||||
|
result.append(ChatColor.COLOR_CHAR).append(Character.toLowerCase(b[i + 1]));
|
||||||
|
i ++;
|
||||||
|
} else if ('#' == b[i + 1] && i < b.length - 7) {
|
||||||
|
String hex = string.substring(i + 1, i + 8);
|
||||||
|
result.append(ChatColor.of(hex));
|
||||||
|
i += 7;
|
||||||
|
} else {
|
||||||
|
result.append(b[i]);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
result.append(b[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return result.toString();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -20,7 +20,7 @@ ranks: true
|
|||||||
# this will also make the command not autocomplete in 1.13
|
# this will also make the command not autocomplete in 1.13
|
||||||
prestiges: true
|
prestiges: true
|
||||||
|
|
||||||
# whether to enabable the /ranks GUI.
|
# whether to enable the /ranks GUI.
|
||||||
# will override the /ranks command
|
# will override the /ranks command
|
||||||
ranks-gui: false
|
ranks-gui: false
|
||||||
|
|
||||||
@@ -93,6 +93,7 @@ placeholders:
|
|||||||
complete: "Complete"
|
complete: "Complete"
|
||||||
current: "Current"
|
current: "Current"
|
||||||
incomplete: "Incomplete"
|
incomplete: "Incomplete"
|
||||||
|
last-rank-display-name: "last rank"
|
||||||
|
|
||||||
# what to shorten money by.
|
# what to shorten money by.
|
||||||
# ie 1000 -> 1k
|
# ie 1000 -> 1k
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ version: "${version}"
|
|||||||
main: sh.okx.rankup.RankupPlugin
|
main: sh.okx.rankup.RankupPlugin
|
||||||
author: Okx
|
author: Okx
|
||||||
depend: [Vault]
|
depend: [Vault]
|
||||||
softdepend: [PlaceholderAPI, mcMMO, AdvancedAchievements, Towny]
|
softdepend: [PlaceholderAPI, mcMMO, AdvancedAchievements, Towny, SuperbVote, VotingPlugin]
|
||||||
api-version: 1.13
|
api-version: 1.13
|
||||||
|
|
||||||
commands:
|
commands:
|
||||||
|
|||||||
@@ -1,5 +1,8 @@
|
|||||||
package sh.okx.rankup;
|
package sh.okx.rankup;
|
||||||
|
|
||||||
|
import static org.junit.Assert.assertEquals;
|
||||||
|
import static org.junit.Assert.assertTrue;
|
||||||
|
|
||||||
import be.seeseemelk.mockbukkit.MockBukkit;
|
import be.seeseemelk.mockbukkit.MockBukkit;
|
||||||
import be.seeseemelk.mockbukkit.ServerMock;
|
import be.seeseemelk.mockbukkit.ServerMock;
|
||||||
import be.seeseemelk.mockbukkit.entity.PlayerMock;
|
import be.seeseemelk.mockbukkit.entity.PlayerMock;
|
||||||
@@ -15,9 +18,6 @@ import sh.okx.rankup.messages.Variable;
|
|||||||
import sh.okx.rankup.ranks.Rank;
|
import sh.okx.rankup.ranks.Rank;
|
||||||
import sh.okx.rankup.ranks.RankElement;
|
import sh.okx.rankup.ranks.RankElement;
|
||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
|
||||||
import static org.junit.Assert.assertTrue;
|
|
||||||
|
|
||||||
public class RankupTest {
|
public class RankupTest {
|
||||||
protected GroupProvider groupProvider;
|
protected GroupProvider groupProvider;
|
||||||
protected ServerMock server;
|
protected ServerMock server;
|
||||||
@@ -73,7 +73,7 @@ public class RankupTest {
|
|||||||
|
|
||||||
plugin.getHelper().rankup(player);
|
plugin.getHelper().rankup(player);
|
||||||
|
|
||||||
player.assertSaid(plugin.getMessage(Message.NO_RANKUP).replaceRanks(player, plugin.getRankups().getTree().last().getRank().getRank()).toString());
|
player.assertSaid(plugin.getMessage(Message.NO_RANKUP).replaceRanks(player, plugin.getRankups().getTree().last().getRank()).toString());
|
||||||
player.assertNoMoreSaid();
|
player.assertNoMoreSaid();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user