ranks gui
This commit is contained in:
+2
-2
@@ -4,7 +4,7 @@ plugins {
|
|||||||
}
|
}
|
||||||
|
|
||||||
group 'sh.okx'
|
group 'sh.okx'
|
||||||
version '3.9'
|
version '3.10-alpha'
|
||||||
|
|
||||||
repositories {
|
repositories {
|
||||||
mavenCentral()
|
mavenCentral()
|
||||||
@@ -28,7 +28,7 @@ dependencies {
|
|||||||
testImplementation 'com.github.seeseemelk:MockBukkit-v1.15:0.3.0'
|
testImplementation 'com.github.seeseemelk:MockBukkit-v1.15:0.3.0'
|
||||||
|
|
||||||
compileOnly 'org.jetbrains:annotations:16.0.2'
|
compileOnly 'org.jetbrains:annotations:16.0.2'
|
||||||
implementation 'org.spigotmc:spigot-api:1.16.1-R0.1-SNAPSHOT'
|
implementation 'org.spigotmc:spigot-api:1.16.2-R0.1-SNAPSHOT'
|
||||||
implementation('com.github.Realizedd:TokenManager:3.2.4') {
|
implementation('com.github.Realizedd:TokenManager:3.2.4') {
|
||||||
transitive = false
|
transitive = false
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,11 @@
|
|||||||
package sh.okx.rankup;
|
package sh.okx.rankup;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.text.DecimalFormat;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.function.Supplier;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
@@ -14,7 +20,12 @@ import org.bukkit.plugin.PluginDescriptionFile;
|
|||||||
import org.bukkit.plugin.PluginManager;
|
import org.bukkit.plugin.PluginManager;
|
||||||
import org.bukkit.plugin.java.JavaPlugin;
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
import org.bukkit.plugin.java.JavaPluginLoader;
|
import org.bukkit.plugin.java.JavaPluginLoader;
|
||||||
import sh.okx.rankup.commands.*;
|
import sh.okx.rankup.commands.InfoCommand;
|
||||||
|
import sh.okx.rankup.commands.MaxRankupCommand;
|
||||||
|
import sh.okx.rankup.commands.PrestigeCommand;
|
||||||
|
import sh.okx.rankup.commands.PrestigesCommand;
|
||||||
|
import sh.okx.rankup.commands.RanksCommand;
|
||||||
|
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;
|
||||||
@@ -33,31 +44,46 @@ import sh.okx.rankup.prestige.Prestiges;
|
|||||||
import sh.okx.rankup.ranks.Rank;
|
import sh.okx.rankup.ranks.Rank;
|
||||||
import sh.okx.rankup.ranks.RankList;
|
import sh.okx.rankup.ranks.RankList;
|
||||||
import sh.okx.rankup.ranks.Rankups;
|
import sh.okx.rankup.ranks.Rankups;
|
||||||
import sh.okx.rankup.ranksgui.RanksGuiManager;
|
import sh.okx.rankup.ranksgui.RanksGuiCommand;
|
||||||
|
import sh.okx.rankup.ranksgui.RanksGuiListener;
|
||||||
import sh.okx.rankup.requirements.Requirement;
|
import sh.okx.rankup.requirements.Requirement;
|
||||||
import sh.okx.rankup.requirements.RequirementRegistry;
|
import sh.okx.rankup.requirements.RequirementRegistry;
|
||||||
|
import sh.okx.rankup.requirements.requirement.AdvancementRequirement;
|
||||||
|
import sh.okx.rankup.requirements.requirement.BlockBreakRequirement;
|
||||||
|
import sh.okx.rankup.requirements.requirement.CraftItemRequirement;
|
||||||
|
import sh.okx.rankup.requirements.requirement.GroupRequirement;
|
||||||
|
import sh.okx.rankup.requirements.requirement.ItemDeductibleRequirement;
|
||||||
|
import sh.okx.rankup.requirements.requirement.ItemRequirement;
|
||||||
|
import sh.okx.rankup.requirements.requirement.MobKillsRequirement;
|
||||||
|
import sh.okx.rankup.requirements.requirement.MoneyDeductibleRequirement;
|
||||||
|
import sh.okx.rankup.requirements.requirement.MoneyRequirement;
|
||||||
|
import sh.okx.rankup.requirements.requirement.PermissionRequirement;
|
||||||
|
import sh.okx.rankup.requirements.requirement.PlaceholderRequirement;
|
||||||
|
import sh.okx.rankup.requirements.requirement.PlayerKillsRequirement;
|
||||||
|
import sh.okx.rankup.requirements.requirement.PlaytimeMinutesRequirement;
|
||||||
|
import sh.okx.rankup.requirements.requirement.TotalMobKillsRequirement;
|
||||||
|
import sh.okx.rankup.requirements.requirement.UseItemRequirement;
|
||||||
|
import sh.okx.rankup.requirements.requirement.WorldRequirement;
|
||||||
import sh.okx.rankup.requirements.requirement.XpLevelDeductibleRequirement;
|
import sh.okx.rankup.requirements.requirement.XpLevelDeductibleRequirement;
|
||||||
import sh.okx.rankup.requirements.requirement.*;
|
import sh.okx.rankup.requirements.requirement.XpLevelRequirement;
|
||||||
import sh.okx.rankup.requirements.requirement.advancedachievements.AdvancedAchievementsAchievementRequirement;
|
import sh.okx.rankup.requirements.requirement.advancedachievements.AdvancedAchievementsAchievementRequirement;
|
||||||
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.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.*;
|
import sh.okx.rankup.requirements.requirement.towny.TownyKingNumberResidentsRequirement;
|
||||||
|
import sh.okx.rankup.requirements.requirement.towny.TownyKingNumberTownsRequirement;
|
||||||
|
import sh.okx.rankup.requirements.requirement.towny.TownyKingRequirement;
|
||||||
|
import sh.okx.rankup.requirements.requirement.towny.TownyMayorNumberResidentsRequirement;
|
||||||
|
import sh.okx.rankup.requirements.requirement.towny.TownyMayorRequirement;
|
||||||
|
import sh.okx.rankup.requirements.requirement.towny.TownyResidentRequirement;
|
||||||
import sh.okx.rankup.requirements.requirement.votingplugin.VotingPluginPointsDeductibleRequirement;
|
import sh.okx.rankup.requirements.requirement.votingplugin.VotingPluginPointsDeductibleRequirement;
|
||||||
import sh.okx.rankup.requirements.requirement.votingplugin.VotingPluginPointsRequirement;
|
import sh.okx.rankup.requirements.requirement.votingplugin.VotingPluginPointsRequirement;
|
||||||
import sh.okx.rankup.requirements.requirement.votingplugin.VotingPluginVotesRequirement;
|
import sh.okx.rankup.requirements.requirement.votingplugin.VotingPluginVotesRequirement;
|
||||||
import sh.okx.rankup.util.UpdateNotifier;
|
import sh.okx.rankup.util.UpdateNotifier;
|
||||||
import sh.okx.rankup.util.VersionChecker;
|
import sh.okx.rankup.util.VersionChecker;
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.text.DecimalFormat;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.function.Supplier;
|
|
||||||
|
|
||||||
public class RankupPlugin extends JavaPlugin {
|
public class RankupPlugin extends JavaPlugin {
|
||||||
|
|
||||||
public static final int CONFIG_VERSION = 8;
|
public static final int CONFIG_VERSION = 8;
|
||||||
@@ -88,8 +114,6 @@ public class RankupPlugin extends JavaPlugin {
|
|||||||
private PermissionManager permissionManager = new VaultPermissionManager(this);
|
private PermissionManager permissionManager = new VaultPermissionManager(this);
|
||||||
private EconomyProvider economyProvider = new VaultEconomyProvider();
|
private EconomyProvider economyProvider = new VaultEconomyProvider();
|
||||||
|
|
||||||
private RanksGuiManager ranksGuiManager = new RanksGuiManager(this);
|
|
||||||
|
|
||||||
public RankupPlugin() {
|
public RankupPlugin() {
|
||||||
super();
|
super();
|
||||||
}
|
}
|
||||||
@@ -139,8 +163,11 @@ public class RankupPlugin extends JavaPlugin {
|
|||||||
getCommand("maxrankup").setExecutor(new MaxRankupCommand(this));
|
getCommand("maxrankup").setExecutor(new MaxRankupCommand(this));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
RanksGuiListener listener = new RanksGuiListener();
|
||||||
|
getCommand("ranksgui").setExecutor(new RanksGuiCommand(this, listener));
|
||||||
getCommand("rankup").setExecutor(new RankupCommand(this));
|
getCommand("rankup").setExecutor(new RankupCommand(this));
|
||||||
getCommand("rankup3").setExecutor(new InfoCommand(this, notifier));
|
getCommand("rankup3").setExecutor(new InfoCommand(this, notifier));
|
||||||
|
getServer().getPluginManager().registerEvents(listener, this);
|
||||||
getServer().getPluginManager().registerEvents(new GuiListener(this), this);
|
getServer().getPluginManager().registerEvents(new GuiListener(this), this);
|
||||||
getServer().getPluginManager().registerEvents(
|
getServer().getPluginManager().registerEvents(
|
||||||
new JoinUpdateNotifier(notifier, () -> getConfig().getBoolean("notify-update"), "rankup.notify"), this);
|
new JoinUpdateNotifier(notifier, () -> getConfig().getBoolean("notify-update"), "rankup.notify"), this);
|
||||||
@@ -417,7 +444,7 @@ public class RankupPlugin extends JavaPlugin {
|
|||||||
|
|
||||||
public MessageBuilder replaceMoneyRequirements(MessageBuilder builder, CommandSender sender,
|
public MessageBuilder replaceMoneyRequirements(MessageBuilder builder, CommandSender sender,
|
||||||
Rank rank) {
|
Rank rank) {
|
||||||
if (builder instanceof NullMessageBuilder) {
|
if (builder instanceof NullMessageBuilder || rank == null) {
|
||||||
return builder;
|
return builder;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,81 +1,81 @@
|
|||||||
package sh.okx.rankup.commands;
|
package sh.okx.rankup.commands;
|
||||||
|
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandExecutor;
|
import org.bukkit.command.CommandExecutor;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
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 sh.okx.rankup.gui.Gui;
|
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.RankElement;
|
import sh.okx.rankup.ranks.RankElement;
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.WeakHashMap;
|
import java.util.WeakHashMap;
|
||||||
|
|
||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
public class PrestigeCommand implements CommandExecutor {
|
public class PrestigeCommand implements CommandExecutor {
|
||||||
private final Map<Player, Long> confirming = new WeakHashMap<>();
|
private final Map<Player, Long> confirming = new WeakHashMap<>();
|
||||||
private final RankupPlugin plugin;
|
private final RankupPlugin plugin;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||||
if (plugin.error(sender)) {
|
if (plugin.error(sender)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// check if player
|
// check if player
|
||||||
if (!(sender instanceof Player)) {
|
if (!(sender instanceof Player)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
Player player = (Player) sender;
|
Player player = (Player) sender;
|
||||||
|
|
||||||
Prestiges prestiges = plugin.getPrestiges();
|
Prestiges prestiges = plugin.getPrestiges();
|
||||||
if (!plugin.getHelper().checkPrestige(player)) {
|
if (!plugin.getHelper().checkPrestige(player)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
RankElement<Prestige> rankElement = prestiges.getByPlayer(player);
|
RankElement<Prestige> rankElement = prestiges.getByPlayer(player);
|
||||||
Prestige prestige = rankElement.getRank();
|
Prestige prestige = rankElement.getRank();
|
||||||
|
|
||||||
FileConfiguration config = plugin.getConfig();
|
FileConfiguration config = plugin.getConfig();
|
||||||
String confirmationType = config.getString("confirmation-type").toLowerCase();
|
String confirmationType = config.getString("confirmation-type").toLowerCase();
|
||||||
if (confirmationType.equals("text") && confirming.containsKey(player)) {
|
if (confirmationType.equals("text") && confirming.containsKey(player)) {
|
||||||
long time = System.currentTimeMillis() - confirming.remove(player);
|
long time = System.currentTimeMillis() - confirming.remove(player);
|
||||||
if (time < config.getInt("text.timeout") * 1000) {
|
if (time < config.getInt("text.timeout") * 1000) {
|
||||||
plugin.getHelper().prestige(player);
|
plugin.getHelper().prestige(player);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (confirmationType) {
|
switch (confirmationType) {
|
||||||
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();
|
String nextRank = next == null ? prestiges.getTree().last().getRank().getRank() : next.getRank();
|
||||||
|
|
||||||
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)
|
||||||
.replaceFromTo(prestige)
|
.replaceFromTo(prestige)
|
||||||
.send(player);
|
.send(player);
|
||||||
break;
|
break;
|
||||||
case "gui":
|
case "gui":
|
||||||
Gui gui = Gui.of(player, prestige, rankElement.getNext().getRank(), plugin);
|
Gui gui = Gui.of(player, prestige, rankElement.getNext().getRank(), plugin, false);
|
||||||
if (gui == null) {
|
if (gui == null) {
|
||||||
player.sendMessage(ChatColor.RED + "GUI is not available. Check console for more informatiopn.");
|
player.sendMessage(ChatColor.RED + "GUI is not available. Check console for more informatiopn.");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
gui.open(player);
|
gui.open(player);
|
||||||
break;
|
break;
|
||||||
case "none":
|
case "none":
|
||||||
plugin.getHelper().prestige(player);
|
plugin.getHelper().prestige(player);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
throw new IllegalArgumentException("Invalid confirmation type " + confirmationType);
|
throw new IllegalArgumentException("Invalid confirmation type " + confirmationType);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,80 +1,80 @@
|
|||||||
package sh.okx.rankup.commands;
|
package sh.okx.rankup.commands;
|
||||||
|
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandExecutor;
|
import org.bukkit.command.CommandExecutor;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
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 sh.okx.rankup.gui.Gui;
|
import sh.okx.rankup.gui.Gui;
|
||||||
import sh.okx.rankup.messages.Message;
|
import sh.okx.rankup.messages.Message;
|
||||||
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.ranks.Rankups;
|
import sh.okx.rankup.ranks.Rankups;
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.WeakHashMap;
|
import java.util.WeakHashMap;
|
||||||
|
|
||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
public class RankupCommand implements CommandExecutor {
|
public class RankupCommand implements CommandExecutor {
|
||||||
// weak hash maps so players going offline are automatically removed.
|
// weak hash maps so players going offline are automatically removed.
|
||||||
// otherwise there is a potential (albeit small) memory leak.
|
// otherwise there is a potential (albeit small) memory leak.
|
||||||
private final Map<Player, Long> confirming = new WeakHashMap<>();
|
private final Map<Player, Long> confirming = new WeakHashMap<>();
|
||||||
private final RankupPlugin plugin;
|
private final RankupPlugin plugin;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||||
if (plugin.error(sender)) {
|
if (plugin.error(sender)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// check if player
|
// check if player
|
||||||
if (!(sender instanceof Player)) {
|
if (!(sender instanceof Player)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
Player player = (Player) sender;
|
Player player = (Player) sender;
|
||||||
|
|
||||||
Rankups rankups = plugin.getRankups();
|
Rankups rankups = plugin.getRankups();
|
||||||
if (!plugin.getHelper().checkRankup(player)) {
|
if (!plugin.getHelper().checkRankup(player)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
RankElement<Rank> rankElement = rankups.getByPlayer(player);
|
RankElement<Rank> rankElement = rankups.getByPlayer(player);
|
||||||
|
|
||||||
FileConfiguration config = plugin.getConfig();
|
FileConfiguration config = plugin.getConfig();
|
||||||
String confirmationType = config.getString("confirmation-type").toLowerCase();
|
String confirmationType = config.getString("confirmation-type").toLowerCase();
|
||||||
|
|
||||||
// if they are on text confirming, rank them up
|
// if they are on text confirming, rank them up
|
||||||
if (confirmationType.equals("text") && confirming.containsKey(player)) {
|
if (confirmationType.equals("text") && confirming.containsKey(player)) {
|
||||||
long time = System.currentTimeMillis() - confirming.remove(player);
|
long time = System.currentTimeMillis() - confirming.remove(player);
|
||||||
if (time < config.getInt("text.timeout") * 1000) {
|
if (time < config.getInt("text.timeout") * 1000) {
|
||||||
plugin.getHelper().rankup(player);
|
plugin.getHelper().rankup(player);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (confirmationType) {
|
switch (confirmationType) {
|
||||||
case "text":
|
case "text":
|
||||||
confirming.put(player, System.currentTimeMillis());
|
confirming.put(player, System.currentTimeMillis());
|
||||||
plugin.replaceMoneyRequirements(plugin.getMessage(rankElement.getRank(), Message.CONFIRMATION)
|
plugin.replaceMoneyRequirements(plugin.getMessage(rankElement.getRank(), Message.CONFIRMATION)
|
||||||
.replaceRanks(player, rankElement.getRank(), rankElement.getNext().getRank()), player, rankElement.getRank())
|
.replaceRanks(player, rankElement.getRank(), rankElement.getNext().getRank()), player, rankElement.getRank())
|
||||||
.send(player);
|
.send(player);
|
||||||
break;
|
break;
|
||||||
case "gui":
|
case "gui":
|
||||||
Gui gui = Gui.of(player, rankElement.getRank(), rankElement.getNext().getRank(), plugin);
|
Gui gui = Gui.of(player, rankElement.getRank(), rankElement.getNext().getRank(), plugin, args.length > 0 && args[0].equalsIgnoreCase("gui"));
|
||||||
if (gui == null) {
|
if (gui == null) {
|
||||||
player.sendMessage(ChatColor.RED + "GUI is not available. Check console for more informatiopn.");
|
player.sendMessage(ChatColor.RED + "GUI is not available. Check console for more informatiopn.");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
gui.open(player);
|
gui.open(player);
|
||||||
break;
|
break;
|
||||||
case "none":
|
case "none":
|
||||||
plugin.getHelper().rankup(player);
|
plugin.getHelper().rankup(player);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
throw new IllegalArgumentException("Invalid confirmation type " + confirmationType);
|
throw new IllegalArgumentException("Invalid confirmation type " + confirmationType);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,143 +1,158 @@
|
|||||||
package sh.okx.rankup.gui;
|
package sh.okx.rankup.gui;
|
||||||
|
|
||||||
import lombok.AccessLevel;
|
import java.util.Arrays;
|
||||||
import lombok.Getter;
|
import java.util.Objects;
|
||||||
import lombok.NoArgsConstructor;
|
import java.util.stream.Collectors;
|
||||||
import org.bukkit.Bukkit;
|
import lombok.AccessLevel;
|
||||||
import org.bukkit.ChatColor;
|
import lombok.Getter;
|
||||||
import org.bukkit.Material;
|
import lombok.RequiredArgsConstructor;
|
||||||
import org.bukkit.configuration.ConfigurationSection;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.inventory.Inventory;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.inventory.InventoryHolder;
|
import org.bukkit.configuration.ConfigurationSection;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.inventory.meta.ItemMeta;
|
import org.bukkit.inventory.Inventory;
|
||||||
import sh.okx.rankup.RankupPlugin;
|
import org.bukkit.inventory.InventoryHolder;
|
||||||
import sh.okx.rankup.messages.Message;
|
import org.bukkit.inventory.ItemStack;
|
||||||
import sh.okx.rankup.messages.MessageBuilder;
|
import org.bukkit.inventory.meta.ItemMeta;
|
||||||
import sh.okx.rankup.prestige.Prestige;
|
import sh.okx.rankup.RankupPlugin;
|
||||||
import sh.okx.rankup.ranks.Rank;
|
import sh.okx.rankup.messages.Message;
|
||||||
import sh.okx.rankup.util.ItemUtil;
|
import sh.okx.rankup.messages.MessageBuilder;
|
||||||
|
import sh.okx.rankup.prestige.Prestige;
|
||||||
import java.util.Arrays;
|
import sh.okx.rankup.ranks.Rank;
|
||||||
import java.util.Objects;
|
import sh.okx.rankup.ranks.RankElement;
|
||||||
import java.util.stream.Collectors;
|
import sh.okx.rankup.util.ItemUtil;
|
||||||
|
|
||||||
@NoArgsConstructor(access = AccessLevel.PRIVATE)
|
@RequiredArgsConstructor(access = AccessLevel.PRIVATE)
|
||||||
public class Gui implements InventoryHolder {
|
public class Gui implements InventoryHolder {
|
||||||
@Getter
|
@Getter
|
||||||
private Inventory inventory;
|
private final boolean returnToRanksGui;
|
||||||
@Getter
|
@Getter
|
||||||
private ItemStack rankup;
|
private Inventory inventory;
|
||||||
@Getter
|
@Getter
|
||||||
private ItemStack cancel;
|
private ItemStack rankup;
|
||||||
@Getter
|
@Getter
|
||||||
private boolean prestige;
|
private ItemStack cancel;
|
||||||
|
@Getter
|
||||||
public static Gui of(Player player, Rank oldRank, Rank rank, RankupPlugin plugin) {
|
private boolean prestige;
|
||||||
Gui gui = new Gui();
|
|
||||||
gui.prestige = oldRank instanceof Prestige;
|
public static Gui of(Player player, Rank oldRank, Rank rank, RankupPlugin plugin, boolean returnToRanksGui) {
|
||||||
|
Gui gui = new Gui(returnToRanksGui);
|
||||||
String type = gui.prestige ? "prestige" : "rankup";
|
gui.prestige = oldRank instanceof Prestige;
|
||||||
String basePath = type + ".gui";
|
|
||||||
ConfigurationSection config = plugin.getSection(oldRank, basePath);
|
String type = gui.prestige ? "prestige" : "rankup";
|
||||||
if (config == null) {
|
String basePath = type + ".gui";
|
||||||
plugin.getLogger().severe("You must update your config.yml and locale/en.yml to be able to use the GUI! Your configuration files are outdated.");
|
ConfigurationSection config = plugin.getSection(oldRank, basePath);
|
||||||
return null;
|
if (config == null) {
|
||||||
}
|
plugin.getLogger().severe("You must update your config.yml and locale/en.yml to be able to use the GUI! Your configuration files are outdated.");
|
||||||
|
return null;
|
||||||
ItemStack[] items = new ItemStack[config.getInt("rows", 1) * 9];
|
}
|
||||||
|
|
||||||
ItemStack fill = getItem(plugin, plugin.getSection(oldRank, basePath + ".fill"), player, oldRank, rank);
|
ItemStack[] items = new ItemStack[config.getInt("rows", 1) * 9];
|
||||||
ItemStack cancel = getItem(plugin, plugin.getSection(oldRank, basePath + ".cancel"), player, oldRank, rank);
|
|
||||||
ItemStack rankup = getItem(plugin, plugin.getSection(oldRank, basePath + ".rankup"), player, oldRank, rank);
|
ItemStack fill = getItem(plugin, plugin.getSection(oldRank, basePath + ".fill"), player, oldRank, rank);
|
||||||
|
ItemStack cancel = getItem(plugin, plugin.getSection(oldRank, basePath + ".cancel"), player, oldRank, rank);
|
||||||
addItem(items, plugin.getSection(oldRank, basePath + ".rankup"), rankup);
|
ItemStack rankup = getItem(plugin, plugin.getSection(oldRank, basePath + ".rankup"), player, oldRank, rank);
|
||||||
addItem(items, plugin.getSection(oldRank, basePath + ".cancel"), cancel);
|
|
||||||
addItem(items, plugin.getSection(oldRank, basePath + ".fill"), fill);
|
addItem(items, plugin.getSection(oldRank, basePath + ".rankup"), rankup);
|
||||||
|
addItem(items, plugin.getSection(oldRank, basePath + ".cancel"), cancel);
|
||||||
gui.rankup = rankup;
|
addItem(items, plugin.getSection(oldRank, basePath + ".fill"), fill);
|
||||||
gui.cancel = cancel;
|
|
||||||
|
gui.rankup = rankup;
|
||||||
Inventory inventory = Bukkit.createInventory(gui, items.length,
|
gui.cancel = cancel;
|
||||||
plugin.replaceMoneyRequirements(
|
|
||||||
plugin.getMessage(oldRank, gui.prestige ? Message.PRESTIGE_TITLE : Message.TITLE)
|
Inventory inventory = Bukkit.createInventory(gui, items.length,
|
||||||
.replaceRanks(player, oldRank, rank)
|
ChatColor.stripColor(ChatColor.translateAlternateColorCodes('&', plugin.replaceMoneyRequirements(
|
||||||
.replaceFromTo(oldRank), player, oldRank).toString());
|
plugin.getMessage(oldRank, gui.prestige ? Message.PRESTIGE_TITLE : Message.TITLE)
|
||||||
inventory.setContents(items);
|
.replaceRanks(player, oldRank, rank)
|
||||||
gui.inventory = inventory;
|
.replaceFromTo(oldRank), player, oldRank).toString())));
|
||||||
return gui;
|
inventory.setContents(items);
|
||||||
}
|
gui.inventory = inventory;
|
||||||
|
return gui;
|
||||||
@SuppressWarnings("deprecation")
|
}
|
||||||
private static ItemStack getItem(RankupPlugin plugin, ConfigurationSection section, Player player, Rank oldRank, Rank rank) {
|
|
||||||
String materialName = section.getString("material").toUpperCase();
|
public static ItemStack getItem(RankupPlugin plugin, ConfigurationSection section, Player player, RankElement<Rank> element) {
|
||||||
|
if (element == null) {
|
||||||
ItemStack item;
|
return getItem(plugin, section, player, null, null);
|
||||||
if (ItemUtil.isServerFlattened()) {
|
} else {
|
||||||
Material material = Material.valueOf(materialName);
|
return getItem(plugin, section, player, element.getRank(), element.getNext().getRank());
|
||||||
item = new ItemStack(material);
|
}
|
||||||
} else {
|
}
|
||||||
// handle default material correctly on older versions
|
|
||||||
if (materialName.equals("BLACK_STAINED_GLASS_PANE")) {
|
@SuppressWarnings("deprecation")
|
||||||
materialName = "STAINED_GLASS_PANE:15";
|
public static ItemStack getItem(RankupPlugin plugin, ConfigurationSection section, Player player, Rank oldRank, Rank rank) {
|
||||||
}
|
if (section == null) {
|
||||||
|
return null;
|
||||||
String[] parts = materialName.split(":");
|
}
|
||||||
Material material = Material.valueOf(parts[0]);
|
String materialName = section.getString("material").toUpperCase();
|
||||||
|
|
||||||
short type = parts.length > 1 ? Short.parseShort(parts[1]) : 0;
|
ItemStack item;
|
||||||
item = new ItemStack(material, 1, type);
|
if (ItemUtil.isServerFlattened()) {
|
||||||
}
|
Material material = Material.valueOf(materialName);
|
||||||
|
item = new ItemStack(material);
|
||||||
if (item.getType() == Material.AIR && section.getName().equalsIgnoreCase("fill")) {
|
} else {
|
||||||
return item;
|
// handle default material correctly on older versions
|
||||||
}
|
if (materialName.equals("BLACK_STAINED_GLASS_PANE")) {
|
||||||
|
materialName = "STAINED_GLASS_PANE:15";
|
||||||
ItemMeta meta = item.getItemMeta();
|
}
|
||||||
if (section.contains("lore")) {
|
|
||||||
meta.setLore(Arrays.stream(format(plugin, section.getString("lore"), player, oldRank, rank).split("\n"))
|
String[] parts = materialName.split(":");
|
||||||
.map(string -> ChatColor.RESET + string)
|
Material material = Material.valueOf(parts[0]);
|
||||||
.collect(Collectors.toList()));
|
|
||||||
}
|
short type = parts.length > 1 ? Short.parseShort(parts[1]) : 0;
|
||||||
if (section.contains("name")) {
|
item = new ItemStack(material, 1, type);
|
||||||
meta.setDisplayName(ChatColor.RESET + format(plugin, section.getString("name"), player, oldRank, rank));
|
}
|
||||||
}
|
|
||||||
item.setItemMeta(meta);
|
if (item.getType() == Material.AIR && section.getName().equalsIgnoreCase("fill")) {
|
||||||
return item;
|
return item;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static String format(RankupPlugin plugin, String message, Player player, Rank oldRank, Rank rank) {
|
ItemMeta meta = item.getItemMeta();
|
||||||
return plugin.replaceMoneyRequirements(new MessageBuilder(ChatColor.translateAlternateColorCodes('&', message))
|
if (section.contains("lore")) {
|
||||||
.replaceRanks(player, oldRank, rank), player, oldRank)
|
meta.setLore(Arrays.stream(format(plugin, section.getString("lore"), player, oldRank, rank).split("\n"))
|
||||||
.toString();
|
.map(string -> ChatColor.RESET + string)
|
||||||
}
|
.collect(Collectors.toList()));
|
||||||
|
}
|
||||||
private static void addItem(ItemStack[] items, ConfigurationSection section, ItemStack item) {
|
if (section.contains("name")) {
|
||||||
Objects.requireNonNull(section, "GUI configuration section not found");
|
meta.setDisplayName(ChatColor.RESET + format(plugin, section.getString("name"), player, oldRank, rank));
|
||||||
if (section.getName().equalsIgnoreCase("fill")) {
|
}
|
||||||
for (int i = 0; i < items.length; i++) {
|
item.setItemMeta(meta);
|
||||||
if (items[i] == null) {
|
return item;
|
||||||
items[i] = item;
|
}
|
||||||
}
|
|
||||||
}
|
private static String format(RankupPlugin plugin, String message, Player player, Rank oldRank, Rank rank) {
|
||||||
return;
|
MessageBuilder builder = new MessageBuilder(message);
|
||||||
}
|
if (oldRank != null && rank != null) {
|
||||||
|
builder = builder.replaceRanks(player, oldRank, rank);
|
||||||
String[] locations = section.getString("index").split(" ");
|
}
|
||||||
for (String location : locations) {
|
return ChatColor.translateAlternateColorCodes('&', plugin.replaceMoneyRequirements(builder, player, oldRank).toString());
|
||||||
String[] parts = location.split("-");
|
}
|
||||||
if (parts.length == 1) {
|
|
||||||
items[Integer.parseInt(parts[0])] = item;
|
private static void addItem(ItemStack[] items, ConfigurationSection section, ItemStack item) {
|
||||||
} else {
|
Objects.requireNonNull(section, "GUI configuration section not found");
|
||||||
for (int i = Integer.parseInt(parts[0]); i <= Integer.parseInt(parts[1]); i++) {
|
if (section.getName().equalsIgnoreCase("fill")) {
|
||||||
items[i] = item;
|
for (int i = 0; i < items.length; i++) {
|
||||||
}
|
if (items[i] == null) {
|
||||||
}
|
items[i] = item;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return;
|
||||||
public void open(Player player) {
|
}
|
||||||
player.openInventory(inventory);
|
|
||||||
}
|
String[] locations = section.getString("index").split(" ");
|
||||||
}
|
for (String location : locations) {
|
||||||
|
String[] parts = location.split("-");
|
||||||
|
if (parts.length == 1) {
|
||||||
|
items[Integer.parseInt(parts[0])] = item;
|
||||||
|
} else {
|
||||||
|
for (int i = Integer.parseInt(parts[0]); i <= Integer.parseInt(parts[1]); i++) {
|
||||||
|
items[i] = item;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void open(Player player) {
|
||||||
|
player.openInventory(inventory);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,40 +1,45 @@
|
|||||||
package sh.okx.rankup.gui;
|
package sh.okx.rankup.gui;
|
||||||
|
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
import org.bukkit.event.inventory.InventoryClickEvent;
|
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||||
import org.bukkit.inventory.Inventory;
|
import org.bukkit.inventory.Inventory;
|
||||||
import sh.okx.rankup.RankupPlugin;
|
import sh.okx.rankup.RankupPlugin;
|
||||||
|
|
||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
public class GuiListener implements Listener {
|
public class GuiListener implements Listener {
|
||||||
private final RankupPlugin plugin;
|
private final RankupPlugin plugin;
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void on(InventoryClickEvent e) {
|
public void on(InventoryClickEvent e) {
|
||||||
Inventory inventory = e.getInventory();
|
Inventory inventory = e.getInventory();
|
||||||
if (inventory == null
|
if (inventory == null
|
||||||
|| !(inventory.getHolder() instanceof Gui)
|
|| !(inventory.getHolder() instanceof Gui)
|
||||||
|| !inventory.equals(e.getClickedInventory())) {
|
|| !inventory.equals(e.getClickedInventory())) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
e.setCancelled(true);
|
e.setCancelled(true);
|
||||||
|
|
||||||
Player player = (Player) e.getWhoClicked();
|
Player player = (Player) e.getWhoClicked();
|
||||||
Gui gui = (Gui) inventory.getHolder();
|
Gui gui = (Gui) inventory.getHolder();
|
||||||
|
|
||||||
if (gui.getRankup().isSimilar(e.getCurrentItem())) {
|
if (gui.getRankup().isSimilar(e.getCurrentItem())) {
|
||||||
Bukkit.getScheduler().runTask(plugin, player::closeInventory);
|
Bukkit.getScheduler().runTask(plugin, player::closeInventory);
|
||||||
if (gui.isPrestige()) {
|
if (gui.isPrestige()) {
|
||||||
plugin.getHelper().prestige(player);
|
plugin.getHelper().prestige(player);
|
||||||
} else {
|
} else {
|
||||||
plugin.getHelper().rankup(player);
|
plugin.getHelper().rankup(player);
|
||||||
}
|
}
|
||||||
} else if (gui.getCancel().isSimilar(e.getCurrentItem())) {
|
} else if (gui.getCancel().isSimilar(e.getCurrentItem())) {
|
||||||
Bukkit.getScheduler().runTask(plugin, player::closeInventory);
|
Bukkit.getScheduler().runTask(plugin, () -> {
|
||||||
}
|
player.closeInventory();
|
||||||
}
|
if (gui.isReturnToRanksGui()) {
|
||||||
}
|
Bukkit.dispatchCommand(player, "ranksgui");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,64 +1,64 @@
|
|||||||
package sh.okx.rankup.ranks.requirements;
|
package sh.okx.rankup.ranks.requirements;
|
||||||
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import sh.okx.rankup.RankupPlugin;
|
import sh.okx.rankup.RankupPlugin;
|
||||||
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.requirements.Requirement;
|
import sh.okx.rankup.requirements.Requirement;
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
public class PrestigeListRankRequirements implements RankRequirements {
|
public class PrestigeListRankRequirements implements RankRequirements {
|
||||||
private final RankupPlugin plugin;
|
private final RankupPlugin plugin;
|
||||||
private final RankRequirements defaultRequirements;
|
private final RankRequirements defaultRequirements;
|
||||||
private final Map<String, RankRequirements> requirements;
|
private final Map<String, RankRequirements> requirements;
|
||||||
|
|
||||||
public PrestigeListRankRequirements(RankupPlugin plugin, RankRequirements defaultRequirements, Map<String, RankRequirements> requirements) {
|
public PrestigeListRankRequirements(RankupPlugin plugin, RankRequirements defaultRequirements, Map<String, RankRequirements> requirements) {
|
||||||
Objects.requireNonNull(plugin);
|
Objects.requireNonNull(plugin);
|
||||||
Objects.requireNonNull(defaultRequirements);
|
Objects.requireNonNull(defaultRequirements);
|
||||||
|
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
this.defaultRequirements = defaultRequirements;
|
this.defaultRequirements = defaultRequirements;
|
||||||
this.requirements = requirements;
|
this.requirements = requirements;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Set<Requirement> getRequirements(Player player) {
|
public Set<Requirement> getRequirements(Player player) {
|
||||||
return getRankRequirements(player).getRequirements(player);
|
return getRankRequirements(player).getRequirements(player);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean hasRequirements(Player player) {
|
public boolean hasRequirements(Player player) {
|
||||||
return getRankRequirements(player).hasRequirements(player);
|
return getRankRequirements(player).hasRequirements(player);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Requirement getRequirement(Player player, String name) {
|
public Requirement getRequirement(Player player, String name) {
|
||||||
return getRankRequirements(player).getRequirement(player, name);
|
return getRankRequirements(player).getRequirement(player, name);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void applyRequirements(Player player) {
|
public void applyRequirements(Player player) {
|
||||||
getRankRequirements(player).applyRequirements(player);
|
getRankRequirements(player).applyRequirements(player);
|
||||||
}
|
}
|
||||||
|
|
||||||
private RankRequirements getRankRequirements(Player player) {
|
private RankRequirements getRankRequirements(Player player) {
|
||||||
Prestiges prestiges = plugin.getPrestiges();
|
Prestiges prestiges = plugin.getPrestiges();
|
||||||
if (player == null || prestiges == null) {
|
if (player == null || prestiges == null) {
|
||||||
return defaultRequirements;
|
return defaultRequirements;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (Prestige prestige : prestiges.getTree()) {
|
for (Prestige prestige : prestiges.getTree()) {
|
||||||
String next = prestige.getNext();
|
String next = prestige.getNext();
|
||||||
if(plugin.getPermissions().inGroup(player.getUniqueId(), next)) {
|
if(next != null && plugin.getPermissions().inGroup(player.getUniqueId(), next)) {
|
||||||
RankRequirements rankRequirements = this.requirements.get(next.toLowerCase());
|
RankRequirements rankRequirements = this.requirements.get(next.toLowerCase());
|
||||||
if (rankRequirements != null) {
|
if (rankRequirements != null) {
|
||||||
return rankRequirements;
|
return rankRequirements;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return defaultRequirements;
|
return defaultRequirements;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,9 +1,122 @@
|
|||||||
package sh.okx.rankup.ranksgui;
|
package sh.okx.rankup.ranksgui;
|
||||||
|
|
||||||
|
import java.util.function.BiFunction;
|
||||||
|
import lombok.Getter;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.configuration.ConfigurationSection;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||||
import org.bukkit.inventory.Inventory;
|
import org.bukkit.inventory.Inventory;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
import sh.okx.rankup.RankupPlugin;
|
||||||
|
import sh.okx.rankup.gui.Gui;
|
||||||
|
import sh.okx.rankup.ranks.Rank;
|
||||||
|
import sh.okx.rankup.ranks.RankElement;
|
||||||
|
|
||||||
public class RanksGui {
|
public class RanksGui {
|
||||||
public Inventory getInventory() {
|
private final RankupPlugin plugin;
|
||||||
|
@Getter
|
||||||
|
private final Player player;
|
||||||
|
|
||||||
|
private int rankupSlot;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
private Inventory inventory;
|
||||||
|
|
||||||
|
public RanksGui(RankupPlugin plugin, Player player) {
|
||||||
|
this.plugin = plugin;
|
||||||
|
this.player = player;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void open() {
|
||||||
|
RankElement<Rank> playerRankElement = plugin.getRankups().getByPlayer(player);
|
||||||
|
ConfigurationSection playerPath = playerRankElement == null ? null : plugin.getSection(playerRankElement.getRank(), "rankup.ranksgui");
|
||||||
|
ConfigurationSection basePath = plugin.getMessages().getConfigurationSection("rankup.ranksgui");
|
||||||
|
|
||||||
|
String title = get(ConfigurationSection::getString, "title", playerPath, basePath, "Ranks");
|
||||||
|
int rows = get(ConfigurationSection::getInt, "rows", playerPath, basePath, 3);
|
||||||
|
int offset = get(ConfigurationSection::getInt, "offset", playerPath, basePath, 10);
|
||||||
|
int width = get(ConfigurationSection::getInt, "width", playerPath, basePath, 7);
|
||||||
|
|
||||||
|
inventory = Bukkit.createInventory(null, rows * 9, title);
|
||||||
|
|
||||||
|
ItemStack fill = get((section, path) -> Gui.getItem(plugin, section.getConfigurationSection(path), player, playerRankElement), "fill", playerPath, basePath, null);
|
||||||
|
|
||||||
|
int index = offset;
|
||||||
|
int rowIndex = offset + width;
|
||||||
|
RankElement<Rank> rankElement = plugin.getRankups().getTree().getFirst();
|
||||||
|
boolean complete = playerRankElement != null;
|
||||||
|
while(rankElement.hasNext()) {
|
||||||
|
ConfigurationSection rankPath = plugin.getSection(rankElement.getRank(), "rankup.ranksgui");
|
||||||
|
|
||||||
|
String path;
|
||||||
|
if (rankElement == playerRankElement) {
|
||||||
|
path = "current";
|
||||||
|
complete = false;
|
||||||
|
rankupSlot = index;
|
||||||
|
} else if (complete) {
|
||||||
|
path = "complete";
|
||||||
|
} else {
|
||||||
|
path = "incomplete";
|
||||||
|
}
|
||||||
|
|
||||||
|
RankElement<Rank> rankElement0 = rankElement;
|
||||||
|
ItemStack item = get((section, path0) -> Gui.getItem(plugin, section.getConfigurationSection(path0), player, rankElement0), path, rankPath, basePath, null);
|
||||||
|
|
||||||
|
inventory.setItem(index++, item);
|
||||||
|
if (index == rowIndex) {
|
||||||
|
rowIndex += 9;
|
||||||
|
index += 9 - width;
|
||||||
|
}
|
||||||
|
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();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (fill != null) {
|
||||||
|
for (int i = 0; i < rows * 9; i++) {
|
||||||
|
ItemStack item = inventory.getItem(i);
|
||||||
|
if (item == null) {
|
||||||
|
inventory.setItem(i, fill);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
player.openInventory(inventory);
|
||||||
|
}
|
||||||
|
|
||||||
|
private <T> T get(BiFunction<ConfigurationSection, String, T> fun, String path, ConfigurationSection primary, ConfigurationSection secondary, T def) {
|
||||||
|
T get = null;
|
||||||
|
if (primary != null) {
|
||||||
|
get = fun.apply(primary, path);
|
||||||
|
}
|
||||||
|
if (get != null) {
|
||||||
|
return get;
|
||||||
|
}
|
||||||
|
if (secondary != null) {
|
||||||
|
get = fun.apply(secondary, path);
|
||||||
|
}
|
||||||
|
if (get != null) {
|
||||||
|
return get;
|
||||||
|
}
|
||||||
|
return def;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void click(InventoryClickEvent event) {
|
||||||
|
if (event.getClickedInventory() != event.getInventory()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
int slot = event.getRawSlot();
|
||||||
|
if (slot == rankupSlot) {
|
||||||
|
Bukkit.getScheduler().runTask(plugin, () -> {
|
||||||
|
player.closeInventory();
|
||||||
|
Bukkit.dispatchCommand(player, "rankup gui");
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void close() {
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,13 +1,18 @@
|
|||||||
package sh.okx.rankup.ranksgui;
|
package sh.okx.rankup.ranksgui;
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
import lombok.RequiredArgsConstructor;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandExecutor;
|
import org.bukkit.command.CommandExecutor;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
import sh.okx.rankup.RankupPlugin;
|
||||||
|
|
||||||
|
@RequiredArgsConstructor
|
||||||
public class RanksGuiCommand implements CommandExecutor {
|
public class RanksGuiCommand implements CommandExecutor {
|
||||||
|
private final RankupPlugin plugin;
|
||||||
|
private final RanksGuiListener listener;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) {
|
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) {
|
||||||
if (!(sender instanceof Player)) {
|
if (!(sender instanceof Player)) {
|
||||||
@@ -15,8 +20,7 @@ public class RanksGuiCommand implements CommandExecutor {
|
|||||||
}
|
}
|
||||||
Player player = (Player) sender;
|
Player player = (Player) sender;
|
||||||
|
|
||||||
player.openInventory(Bukkit.createInventory())
|
listener.open(new RanksGui(plugin, player));
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,28 +0,0 @@
|
|||||||
package sh.okx.rankup.ranksgui;
|
|
||||||
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Map;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
import org.bukkit.event.EventHandler;
|
|
||||||
import org.bukkit.event.Listener;
|
|
||||||
import org.bukkit.event.inventory.InventoryCloseEvent;
|
|
||||||
|
|
||||||
public class RanksGuiHolder implements Listener {
|
|
||||||
private final Map<Player, RanksGui> guiMap = new HashMap<>();
|
|
||||||
|
|
||||||
|
|
||||||
@EventHandler
|
|
||||||
public void on(InventoryCloseEvent event) {
|
|
||||||
if (!(event.getPlayer() instanceof Player)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
Player player = (Player) event.getPlayer();
|
|
||||||
if (guiMap.containsKey(player)) {
|
|
||||||
RanksGui ranksGui = guiMap.get(player);
|
|
||||||
if (ranksGui.getInventory() == event.getInventory()) {
|
|
||||||
guiMap.remove(player);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@@ -0,0 +1,48 @@
|
|||||||
|
package sh.okx.rankup.ranksgui;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.event.Listener;
|
||||||
|
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||||
|
import org.bukkit.event.inventory.InventoryCloseEvent;
|
||||||
|
|
||||||
|
public class RanksGuiListener implements Listener {
|
||||||
|
|
||||||
|
private final Map<Player, RanksGui> guiMap = new HashMap<>();
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void on(InventoryCloseEvent event) {
|
||||||
|
if (!(event.getPlayer() instanceof Player)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Player player = (Player) event.getPlayer();
|
||||||
|
if (guiMap.containsKey(player)) {
|
||||||
|
RanksGui ranksGui = guiMap.get(player);
|
||||||
|
if (ranksGui.getInventory() != null
|
||||||
|
&& ranksGui.getInventory() == event.getInventory()) {
|
||||||
|
guiMap.remove(player);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void on(InventoryClickEvent event) {
|
||||||
|
if (!(event.getWhoClicked() instanceof Player)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Player player = (Player) event.getWhoClicked();
|
||||||
|
RanksGui ranksGui = guiMap.get(player);
|
||||||
|
if (ranksGui != null && event.getInventory() == ranksGui.getInventory()) {
|
||||||
|
ranksGui.click(event);
|
||||||
|
event.setCancelled(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void open(RanksGui gui) {
|
||||||
|
guiMap.put(gui.getPlayer(), gui);
|
||||||
|
gui.open();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@@ -1,15 +0,0 @@
|
|||||||
package sh.okx.rankup.ranksgui;
|
|
||||||
|
|
||||||
import sh.okx.rankup.RankupPlugin;
|
|
||||||
|
|
||||||
public class RanksGuiManager {
|
|
||||||
private final RankupPlugin plugin;
|
|
||||||
|
|
||||||
public RanksGuiManager(RankupPlugin plugin) {
|
|
||||||
this.plugin = plugin;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void enable() {
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
+104
-104
@@ -1,105 +1,105 @@
|
|||||||
# this is used for letting you know that you need to update/change your config file
|
# this is used for letting you know that you need to update/change your config file
|
||||||
version: 8
|
version: 9
|
||||||
|
|
||||||
# the locale to use for messages
|
# the locale to use for messages
|
||||||
# all messages can be customised but this allows you to
|
# all messages can be customised but this allows you to
|
||||||
# choose messages that are already translated
|
# choose messages that are already translated
|
||||||
# locales can be found in the locale/ folder
|
# locales can be found in the locale/ folder
|
||||||
locale: en
|
locale: en
|
||||||
|
|
||||||
# interval (in minutes) to check to autorankup players
|
# interval (in minutes) to check to autorankup players
|
||||||
# ranking up manually wil always be enabled
|
# ranking up manually wil always be enabled
|
||||||
# set to 0 to disable
|
# set to 0 to disable
|
||||||
autorankup-interval: 0
|
autorankup-interval: 0
|
||||||
|
|
||||||
# whether /ranks and /prestiges should be enabled (true) or disabled (false)
|
# whether /ranks and /prestiges should be enabled (true) or disabled (false)
|
||||||
# /rankup3 reload will not do anything if this is changed,
|
# /rankup3 reload will not do anything if this is changed,
|
||||||
# you will have to restart your server.
|
# you will have to restart your server.
|
||||||
ranks: true
|
ranks: true
|
||||||
# you can alternatively negate the permission rankup.prestiges
|
# you can alternatively negate the permission rankup.prestiges
|
||||||
# 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 or not /prestige and /prestiges should be enabled.
|
# whether or not /prestige and /prestiges should be enabled.
|
||||||
# when a player reaches the top rank, they can do /prestige to return to the first rank,
|
# when a player reaches the top rank, they can do /prestige to return to the first rank,
|
||||||
# but you will be able to grant them an additional "prestige" group or additional items.
|
# but you will be able to grant them an additional "prestige" group or additional items.
|
||||||
#
|
#
|
||||||
# if you do not want this command to autocomplete, make sure
|
# if you do not want this command to autocomplete, make sure
|
||||||
# you negate the permission rankup.prestige with your permissions plugin.
|
# you negate the permission rankup.prestige with your permissions plugin.
|
||||||
# if enabled, a prestiges.yml file will be generated with some example prestiges
|
# if enabled, a prestiges.yml file will be generated with some example prestiges
|
||||||
# You must restart your server when you change this for it to work!
|
# You must restart your server when you change this for it to work!
|
||||||
prestige: false
|
prestige: false
|
||||||
|
|
||||||
# if true, players with the permission rankup.notify will receive notifications when they join
|
# if true, players with the permission rankup.notify will receive notifications when they join
|
||||||
# to update if the server is on an older version of Rankup.
|
# to update if the server is on an older version of Rankup.
|
||||||
notify-update: true
|
notify-update: true
|
||||||
|
|
||||||
# if rankups and prestiges should be by permissions
|
# if rankups and prestiges should be by permissions
|
||||||
# if false, players will be checked for if they have a group of the same name as in rankups.yml,
|
# if false, players will be checked for if they have a group of the same name as in rankups.yml,
|
||||||
# and automatically added and taken away from those groups.
|
# and automatically added and taken away from those groups.
|
||||||
# if true, players will be checked for the permission rankup.rank.RANK, where RANK
|
# if true, players will be checked for the permission rankup.rank.RANK, where RANK
|
||||||
# is the rankup in rankups.yml. Nothing will automatically happen on rankup, so you must
|
# is the rankup in rankups.yml. Nothing will automatically happen on rankup, so you must
|
||||||
# use commands to change a player's group or permission.
|
# use commands to change a player's group or permission.
|
||||||
permission-rankup: false
|
permission-rankup: false
|
||||||
|
|
||||||
# how people should confirm ranking up
|
# how people should confirm ranking up
|
||||||
# options are: gui, text or none
|
# options are: gui, text or none
|
||||||
confirmation-type: 'gui'
|
confirmation-type: 'gui'
|
||||||
|
|
||||||
# how long, in seconds, people have to wait between a successful /rankup or /prestige
|
# how long, in seconds, people have to wait between a successful /rankup or /prestige
|
||||||
# set to 0 to disable.
|
# set to 0 to disable.
|
||||||
cooldown: 1
|
cooldown: 1
|
||||||
|
|
||||||
# if enabled, players can run /maxrankup to rankup as many times as possible,
|
# if enabled, players can run /maxrankup to rankup as many times as possible,
|
||||||
# before they fail the requirements for the next rank.
|
# before they fail the requirements for the next rank.
|
||||||
# the permission rankup.maxrankup is used for this command, but it is given by default.
|
# the permission rankup.maxrankup is used for this command, but it is given by default.
|
||||||
# note that /maxrankup, if enabled, has no confirmation.
|
# note that /maxrankup, if enabled, has no confirmation.
|
||||||
max-rankup:
|
max-rankup:
|
||||||
# You must restart your server if you enable or disable /maxrankup!
|
# You must restart your server if you enable or disable /maxrankup!
|
||||||
enabled: false
|
enabled: false
|
||||||
# whether to send a message for each rankup a player does
|
# whether to send a message for each rankup a player does
|
||||||
# if set to true, the chat may be spammed for each rankup a player goes through with /maxrankup
|
# if set to true, the chat may be spammed for each rankup a player goes through with /maxrankup
|
||||||
# if set to false, only the last rankup will be shown (if a player starts on rank A, then does
|
# if set to false, only the last rankup will be shown (if a player starts on rank A, then does
|
||||||
# /maxrankup and ranks up to B and then C, it will just say "player has ranked up to C")
|
# /maxrankup and ranks up to B and then C, it will just say "player has ranked up to C")
|
||||||
individual-messages: true
|
individual-messages: true
|
||||||
|
|
||||||
# options when using the text rankup confirmation
|
# options when using the text rankup confirmation
|
||||||
text:
|
text:
|
||||||
# the time in seconds for a player to
|
# the time in seconds for a player to
|
||||||
# confirm by typing /rankup again
|
# confirm by typing /rankup again
|
||||||
timeout: 10
|
timeout: 10
|
||||||
|
|
||||||
# placeholders:
|
# placeholders:
|
||||||
# https://github.com/okx-code/Rankup3/wiki/PAPI-Placeholders
|
# https://github.com/okx-code/Rankup3/wiki/PAPI-Placeholders
|
||||||
placeholders:
|
placeholders:
|
||||||
# format for money. for more information, see
|
# format for money. for more information, see
|
||||||
# https://docs.oracle.com/javase/8/docs/api/java/text/DecimalFormat.html
|
# https://docs.oracle.com/javase/8/docs/api/java/text/DecimalFormat.html
|
||||||
money-format: "#,##0.##"
|
money-format: "#,##0.##"
|
||||||
percent-format: "0.##"
|
percent-format: "0.##"
|
||||||
# the format used for requirements
|
# the format used for requirements
|
||||||
simple-format: "#.##"
|
simple-format: "#.##"
|
||||||
# used for current_rank and next_rank placeholders when a player is not in anything in rankups.yml
|
# used for current_rank and next_rank placeholders when a player is not in anything in rankups.yml
|
||||||
not-in-ladder: "None"
|
not-in-ladder: "None"
|
||||||
# used in the current_prestige placeholders when a player hasn't prestiged yet
|
# used in the current_prestige placeholders when a player hasn't prestiged yet
|
||||||
no-prestige: "None"
|
no-prestige: "None"
|
||||||
# used in the next_rank and next_prestige placeholders when a player is at the highest rank or prestige
|
# used in the next_rank and next_prestige placeholders when a player is at the highest rank or prestige
|
||||||
highest-rank: "None"
|
highest-rank: "None"
|
||||||
# used in the %rankup_status_[rank]% placeholders
|
# used in the %rankup_status_[rank]% placeholders
|
||||||
status:
|
status:
|
||||||
complete: "Complete"
|
complete: "Complete"
|
||||||
current: "Current"
|
current: "Current"
|
||||||
incomplete: "Incomplete"
|
incomplete: "Incomplete"
|
||||||
|
|
||||||
# what to shorten money by.
|
# what to shorten money by.
|
||||||
# ie 1000 -> 1k
|
# ie 1000 -> 1k
|
||||||
# set to an empty list to disable
|
# set to an empty list to disable
|
||||||
# for each entry here, it counts as increasing by a factor of 1,000
|
# for each entry here, it counts as increasing by a factor of 1,000
|
||||||
# the first represents thousands (1,000) then millions (1,000,000) then billions (1,000,000,000) etc.
|
# the first represents thousands (1,000) then millions (1,000,000) then billions (1,000,000,000) etc.
|
||||||
shorten:
|
shorten:
|
||||||
- 'K'
|
- 'K'
|
||||||
- 'M'
|
- 'M'
|
||||||
- 'B'
|
- 'B'
|
||||||
- 'T'
|
- 'T'
|
||||||
- 'Q'
|
- 'Q'
|
||||||
- 'Qu'
|
- 'Qu'
|
||||||
- 'S'
|
- 'S'
|
||||||
+123
-103
@@ -1,104 +1,124 @@
|
|||||||
# the messages in this section can be customised for each rankup in rankups.yml.
|
# the messages in this section can be customised for each rankup in rankups.yml.
|
||||||
rankup:
|
rankup:
|
||||||
requirements-not-met: "&cYou need {MONEY} money to rankup."
|
requirements-not-met: "&cYou need {MONEY} money to rankup."
|
||||||
no-rankup: "&eYou are at the highest rank."
|
no-rankup: "&eYou are at the highest rank."
|
||||||
# set to an empty string, ie: success-public: ""
|
# set to an empty string, ie: success-public: ""
|
||||||
# to hide that message.
|
# to hide that message.
|
||||||
success-public: "&a{PLAYER} &ehas ranked up to: &d{RANK}"
|
success-public: "&a{PLAYER} &ehas ranked up to: &d{RANK}"
|
||||||
success-private: "&aYou have ranked up to: &d{RANK}"
|
success-private: "&aYou have ranked up to: &d{RANK}"
|
||||||
# used for the text confirmation
|
# used for the text confirmation
|
||||||
confirmation: |-
|
confirmation: |-
|
||||||
&eAre you sure you want to rankup to &a{RANK}&e?
|
&eAre you sure you want to rankup to &a{RANK}&e?
|
||||||
&eType &c/rankup &eagain to confirm.
|
&eType &c/rankup &eagain to confirm.
|
||||||
# used for the GUI confirmation
|
# used for the GUI confirmation
|
||||||
title: "Rankup to {RANK}"
|
title: "Rankup to {RANK}"
|
||||||
|
|
||||||
must-prestige: "&cYou must prestige to /rankup further!"
|
must-prestige: "&cYou must prestige to /rankup further!"
|
||||||
|
|
||||||
gui:
|
gui:
|
||||||
rows: 1
|
rows: 1
|
||||||
title: "Rankup to {RANK}"
|
title: "Rankup to {RANK}"
|
||||||
rankup:
|
rankup:
|
||||||
material: EMERALD_BLOCK
|
material: EMERALD_BLOCK
|
||||||
# index can be separated by spaces to show in multiple groups
|
# index can be separated by spaces to show in multiple groups
|
||||||
# for example: 0-3 9-12 18-21
|
# for example: 0-3 9-12 18-21
|
||||||
# you can also just use a single number instead of a range.
|
# you can also just use a single number instead of a range.
|
||||||
index: 0-3
|
index: 0-3
|
||||||
name: '&a&lConfirm'
|
name: '&a&lConfirm'
|
||||||
# lore is optional
|
# lore is optional
|
||||||
lore: '&6Rankup to &b{RANK}'
|
lore: '&6Rankup to &b{RANK}'
|
||||||
cancel:
|
cancel:
|
||||||
material: REDSTONE_BLOCK
|
material: REDSTONE_BLOCK
|
||||||
index: 5-8
|
index: 5-8
|
||||||
name: '&c&lCancel'
|
name: '&c&lCancel'
|
||||||
fill:
|
fill:
|
||||||
name: ' '
|
name: ' '
|
||||||
# if you are using a 1.8-1.12 and you want to change this
|
# if you are using a 1.8-1.12 and you want to change this
|
||||||
# you can use MATERIAL:data, for example STAINED_GLASS_PANE:8
|
# you can use MATERIAL:data, for example STAINED_GLASS_PANE:8
|
||||||
# this works for both the rankup and cancel blocks as well
|
# this works for both the rankup and cancel blocks as well
|
||||||
material: BLACK_STAINED_GLASS_PANE
|
material: BLACK_STAINED_GLASS_PANE
|
||||||
|
|
||||||
# you can (and probably should) you override these in rankups.yml
|
ranksgui:
|
||||||
# to show the specific requirements for each rank.
|
title: "Ranks"
|
||||||
# however if you are just using money or don't need to change the message per rank, you can use any combination of:
|
rows: 3
|
||||||
# {MONEY} {MONEY_NEEDED} {PERCENT_DONE <requirement>} {PERCENT_LEFT <requirement>} {AMOUNT <requirement>} {AMOUNT_NEEDED <requirement>}
|
offset: 10
|
||||||
# {MONEY} and {MONEY_NEEDED} are different from {AMOUNT money} and {AMOUNT_NEEDED money} in that they use a different format.
|
width: 7
|
||||||
# here is an example of showing the requirements for just money:
|
rankup:
|
||||||
#list:
|
complete:
|
||||||
# complete: "&7{OLD_RANK} &8\xbb &7{RANK} &efor &7${MONEY}"
|
material: GREEN_STAINED_GLASS_PANE
|
||||||
# current: "&c{OLD_RANK} &e\xbb &c{RANK} &efor &a${MONEY} &e{PERCENT_DONE money}%"
|
name: "&aRank &7{RANK} &a(completed)"
|
||||||
# incomplete: "&r{OLD_RANK} &e\xbb &r{RANK} &efor &a${MONEY}"
|
current:
|
||||||
list:
|
material: ORANGE_STAINED_GLASS_PANE
|
||||||
complete: "&7{OLD_RANK} &8\xbb &7{RANK}"
|
name: "&dRankup to &7{RANK}"
|
||||||
current: "&c{OLD_RANK} &e\xbb &c{RANK}"
|
incomplete:
|
||||||
incomplete: "&r{OLD_RANK} &e\xbb &r{RANK}"
|
material: RED_STAINED_GLASS_PANE
|
||||||
# an empty string disables the header/footer
|
name: "&cRank &7{RANK} &c(requires rankup)"
|
||||||
header: ""
|
fill:
|
||||||
footer: ""
|
material: BLACK_STAINED_GLASS_PANE
|
||||||
# sent when a player tries to rankup when they are on cooldown
|
name: ' '
|
||||||
cooldown:
|
|
||||||
singular: "&cYou must wait {SECONDS_LEFT} more second to rankup again."
|
|
||||||
plural: "&cYou must wait {SECONDS_LEFT} more seconds to rankup again."
|
# you can (and probably should) you override these in rankups.yml
|
||||||
# prestige messages can also be customised
|
# to show the specific requirements for each rank.
|
||||||
prestige:
|
# however if you are just using money or don't need to change the message per rank, you can use any combination of:
|
||||||
requirements-not-met: "&cYou need {MONEY} money to prestige."
|
# {MONEY} {MONEY_NEEDED} {PERCENT_DONE <requirement>} {PERCENT_LEFT <requirement>} {AMOUNT <requirement>} {AMOUNT_NEEDED <requirement>}
|
||||||
no-prestige: "&eYou are at the highest prestige."
|
# {MONEY} and {MONEY_NEEDED} are different from {AMOUNT money} and {AMOUNT_NEEDED money} in that they use a different format.
|
||||||
|
# here is an example of showing the requirements for just money:
|
||||||
success-public: "&a{PLAYER} &ehas prestiged to: &d{RANK}"
|
#list:
|
||||||
success-private: "&aYou have prestiged to: &d{RANK}"
|
# complete: "&7{OLD_RANK} &8\xbb &7{RANK} &efor &7${MONEY}"
|
||||||
|
# current: "&c{OLD_RANK} &e\xbb &c{RANK} &efor &a${MONEY} &e{PERCENT_DONE money}%"
|
||||||
confirmation: |-
|
# incomplete: "&r{OLD_RANK} &e\xbb &r{RANK} &efor &a${MONEY}"
|
||||||
&eAre you sure you want to prestige to &a{RANK}&e?
|
list:
|
||||||
&eType &c/prestige &eagain to confirm.
|
complete: "&7{OLD_RANK} &8\xbb &7{RANK}"
|
||||||
|
current: "&c{OLD_RANK} &e\xbb &c{RANK}"
|
||||||
gui:
|
incomplete: "&r{OLD_RANK} &e\xbb &r{RANK}"
|
||||||
title: "Prestige to {RANK}"
|
# an empty string disables the header/footer
|
||||||
rankup:
|
header: ""
|
||||||
material: GOLD_BLOCK
|
footer: ""
|
||||||
index: 0-3
|
# sent when a player tries to rankup when they are on cooldown
|
||||||
name: '&a&lConfirm'
|
cooldown:
|
||||||
lore: '&6Prestige to &b{RANK}'
|
singular: "&cYou must wait {SECONDS_LEFT} more second to rankup again."
|
||||||
cancel:
|
plural: "&cYou must wait {SECONDS_LEFT} more seconds to rankup again."
|
||||||
material: REDSTONE_BLOCK
|
# prestige messages can also be customised
|
||||||
index: 5-8
|
prestige:
|
||||||
name: '&c&lCancel'
|
requirements-not-met: "&cYou need {MONEY} money to prestige."
|
||||||
fill:
|
no-prestige: "&eYou are at the highest prestige."
|
||||||
name: ' '
|
|
||||||
# if you are using a 1.8-1.12 and you want to change this
|
success-public: "&a{PLAYER} &ehas prestiged to: &d{RANK}"
|
||||||
# you can use MATERIAL:data, for example STAINED_GLASS_PANE:8
|
success-private: "&aYou have prestiged to: &d{RANK}"
|
||||||
# this works for both the rankup and cancel blocks as well
|
|
||||||
material: BLACK_STAINED_GLASS_PANE
|
confirmation: |-
|
||||||
|
&eAre you sure you want to prestige to &a{RANK}&e?
|
||||||
list:
|
&eType &c/prestige &eagain to confirm.
|
||||||
complete: "&7{OLD_RANK} &8\xbb &7{RANK}"
|
|
||||||
current: "&c{OLD_RANK} &e\xbb &c{RANK}"
|
gui:
|
||||||
incomplete: "&r{OLD_RANK} &e\xbb &r{RANK}"
|
title: "Prestige to {RANK}"
|
||||||
header: ""
|
rankup:
|
||||||
footer: ""
|
material: GOLD_BLOCK
|
||||||
cooldown:
|
index: 0-3
|
||||||
singular: "&cYou must wait {SECONDS_LEFT} second to prestige again."
|
name: '&a&lConfirm'
|
||||||
plural: "&cYou must wait {SECONDS_LEFT} more seconds to prestige again."
|
lore: '&6Prestige to &b{RANK}'
|
||||||
|
cancel:
|
||||||
not-high-enough: "&cYou cannot prestige at your rank!"
|
material: REDSTONE_BLOCK
|
||||||
not-in-ladder: "&cSorry, but we could not find any rankups for the group(s) you are in. Use /ranks to list the rankups."
|
index: 5-8
|
||||||
|
name: '&c&lCancel'
|
||||||
|
fill:
|
||||||
|
name: ' '
|
||||||
|
# if you are using a 1.8-1.12 and you want to change this
|
||||||
|
# you can use MATERIAL:data, for example STAINED_GLASS_PANE:8
|
||||||
|
# this works for both the rankup and cancel blocks as well
|
||||||
|
material: BLACK_STAINED_GLASS_PANE
|
||||||
|
|
||||||
|
list:
|
||||||
|
complete: "&7{OLD_RANK} &8\xbb &7{RANK}"
|
||||||
|
current: "&c{OLD_RANK} &e\xbb &c{RANK}"
|
||||||
|
incomplete: "&r{OLD_RANK} &e\xbb &r{RANK}"
|
||||||
|
header: ""
|
||||||
|
footer: ""
|
||||||
|
cooldown:
|
||||||
|
singular: "&cYou must wait {SECONDS_LEFT} second to prestige again."
|
||||||
|
plural: "&cYou must wait {SECONDS_LEFT} more seconds to prestige again."
|
||||||
|
|
||||||
|
not-high-enough: "&cYou cannot prestige at your rank!"
|
||||||
|
not-in-ladder: "&cSorry, but we could not find any rankups for the group(s) you are in. Use /ranks to list the rankups."
|
||||||
invalid-rankup: "&cInvalid rankup defined in config, please check console."
|
invalid-rankup: "&cInvalid rankup defined in config, please check console."
|
||||||
@@ -1,61 +1,63 @@
|
|||||||
name: Rankup
|
name: Rankup
|
||||||
version: ${version}
|
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]
|
||||||
api-version: 1.13
|
api-version: 1.13
|
||||||
|
|
||||||
commands:
|
commands:
|
||||||
rankup:
|
rankup:
|
||||||
permission: rankup.rankup
|
permission: rankup.rankup
|
||||||
description: Rankup.
|
description: Rankup.
|
||||||
rankup3:
|
rankup3:
|
||||||
description: View Rankup version and perform some administrative commands.
|
description: View Rankup version and perform some administrative commands.
|
||||||
# support the old command
|
# support the old command
|
||||||
aliases: [pru]
|
aliases: [pru]
|
||||||
ranks:
|
ranks:
|
||||||
permission: rankup.ranks
|
permission: rankup.ranks
|
||||||
description: List all the ranks.
|
description: List all the ranks.
|
||||||
prestige:
|
prestige:
|
||||||
permission: rankup.prestige
|
permission: rankup.prestige
|
||||||
description: Prestige.
|
description: Prestige.
|
||||||
prestiges:
|
prestiges:
|
||||||
permission: rankup.prestiges
|
permission: rankup.prestiges
|
||||||
description: List all the prestiges.
|
description: List all the prestiges.
|
||||||
maxrankup:
|
maxrankup:
|
||||||
permission: rankup.maxrankup
|
permission: rankup.maxrankup
|
||||||
description: Rankup as much as possible.
|
description: Rankup as much as possible.
|
||||||
permissions:
|
ranksgui:
|
||||||
rankup.*:
|
description: Show the ranks GUI
|
||||||
children:
|
permissions:
|
||||||
rankup.rankup: true
|
rankup.*:
|
||||||
rankup.admin: true
|
children:
|
||||||
rankup.ranks: true
|
rankup.rankup: true
|
||||||
rankup.prestige: true
|
rankup.admin: true
|
||||||
rankup.prestiges: true
|
rankup.ranks: true
|
||||||
rankup.auto: true
|
rankup.prestige: true
|
||||||
rankup.maxrankup: true
|
rankup.prestiges: true
|
||||||
rankup.admin:
|
rankup.auto: true
|
||||||
children:
|
rankup.maxrankup: true
|
||||||
# if a player can see if the plugin needs updating when they run /pru
|
rankup.admin:
|
||||||
rankup.checkversion: true
|
children:
|
||||||
# if a player can run /pru reload
|
# if a player can see if the plugin needs updating when they run /pru
|
||||||
rankup.reload: true
|
rankup.checkversion: true
|
||||||
# if a player can force rankup or prestige someone
|
# if a player can run /pru reload
|
||||||
rankup.force: true
|
rankup.reload: true
|
||||||
# if a player receives notifications to update rankup when they log in.
|
# if a player can force rankup or prestige someone
|
||||||
rankup.notify: true
|
rankup.force: true
|
||||||
default: op
|
# if a player receives notifications to update rankup when they log in.
|
||||||
rankup.rankup:
|
rankup.notify: true
|
||||||
default: true
|
default: op
|
||||||
rankup.ranks:
|
rankup.rankup:
|
||||||
default: true
|
default: true
|
||||||
rankup.prestige:
|
rankup.ranks:
|
||||||
default: true
|
default: true
|
||||||
rankup.prestiges:
|
rankup.prestige:
|
||||||
default: true
|
default: true
|
||||||
rankup.auto:
|
rankup.prestiges:
|
||||||
default: true
|
default: true
|
||||||
rankup.maxrankup:
|
rankup.auto:
|
||||||
|
default: true
|
||||||
|
rankup.maxrankup:
|
||||||
default: true
|
default: true
|
||||||
Reference in New Issue
Block a user