3.10 changes

This commit is contained in:
okx-code
2020-11-24 23:28:03 +00:00
parent 7b1a6fd335
commit 3c01b7a664
7 changed files with 47 additions and 37 deletions
+1 -1
View File
@@ -4,7 +4,7 @@ plugins {
} }
group 'sh.okx' group 'sh.okx'
version '3.10-alpha.1' version '3.10'
repositories { repositories {
mavenCentral() mavenCentral()
+11 -4
View File
@@ -151,7 +151,13 @@ public class RankupPlugin extends JavaPlugin {
} }
if (config.getBoolean("ranks")) { if (config.getBoolean("ranks")) {
getCommand("ranks").setExecutor(new RanksCommand(this)); if (config.getBoolean("ranks-gui")) {
RanksGuiListener listener = new RanksGuiListener();
getCommand("ranks").setExecutor(new RanksGuiCommand(this, listener));
getServer().getPluginManager().registerEvents(listener, this);
} else {
getCommand("ranks").setExecutor(new RanksCommand(this));
}
} }
if (config.getBoolean("prestige")) { if (config.getBoolean("prestige")) {
getCommand("prestige").setExecutor(new PrestigeCommand(this)); getCommand("prestige").setExecutor(new PrestigeCommand(this));
@@ -163,11 +169,8 @@ 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);
@@ -451,16 +454,20 @@ public class RankupPlugin extends JavaPlugin {
Requirement money = rank.getRequirement(sender instanceof Player ? (Player) sender : null, "money"); Requirement money = rank.getRequirement(sender instanceof Player ? (Player) sender : null, "money");
if (money != null) { if (money != null) {
Double amount = null; Double amount = null;
Double total = null;
if (sender instanceof Player && rank.isIn((Player) sender)) { if (sender instanceof Player && rank.isIn((Player) sender)) {
if (economy != null) { if (economy != null) {
amount = money.getRemaining((Player) sender); amount = money.getRemaining((Player) sender);
total = money.getTotal((Player) sender);
} }
} else { } else {
amount = money.getValueDouble(); amount = money.getValueDouble();
total = 0D;
} }
if (amount != null && economy != null) { if (amount != null && economy != null) {
builder.replace(Variable.MONEY_NEEDED, formatMoney(amount)); builder.replace(Variable.MONEY_NEEDED, formatMoney(amount));
builder.replace(Variable.MONEY, formatMoney(money.getValueDouble())); builder.replace(Variable.MONEY, formatMoney(money.getValueDouble()));
builder.replace(Variable.MONEY_DONE, formatMoney(total));
} }
} }
if (sender instanceof Player) { if (sender instanceof Player) {
@@ -46,7 +46,8 @@ public class RankupCommand implements CommandExecutor {
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)) { // clicking on the gui cannot confirm a rankup
if (confirmationType.equals("text") && confirming.containsKey(player) && !(args.length > 0 && args[0].equalsIgnoreCase("gui"))) {
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);
@@ -1,18 +1,19 @@
package sh.okx.rankup.messages; package sh.okx.rankup.messages;
public enum Variable { public enum Variable {
PLAYER, PLAYER,
OLD_RANK, OLD_RANK,
RANK, RANK,
FROM, FROM,
TO, TO,
MONEY, MONEY,
MONEY_NEEDED, MONEY_NEEDED,
AMOUNT, MONEY_DONE,
AMOUNT_NEEDED, AMOUNT,
AMOUNT_DONE, AMOUNT_NEEDED,
PERCENT_DONE, AMOUNT_DONE,
PERCENT_LEFT, PERCENT_DONE,
SECONDS, PERCENT_LEFT,
SECONDS_LEFT SECONDS,
} SECONDS_LEFT
}
+5 -1
View File
@@ -8,7 +8,7 @@ version: 9
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 will always be enabled
# set to 0 to disable # set to 0 to disable
autorankup-interval: 0 autorankup-interval: 0
@@ -20,6 +20,10 @@ 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.
# will override the /ranks command
ranks-gui: false
# 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.
+9 -10
View File
@@ -43,16 +43,15 @@ rankup:
rows: 3 rows: 3
offset: 10 offset: 10
width: 7 width: 7
rankup: complete:
complete: material: GREEN_STAINED_GLASS_PANE
material: GREEN_STAINED_GLASS_PANE name: "&aRank &7{RANK} &a(completed)"
name: "&aRank &7{RANK} &a(completed)" current:
current: material: ORANGE_STAINED_GLASS_PANE
material: ORANGE_STAINED_GLASS_PANE name: "&dRankup to &7{RANK}"
name: "&dRankup to &7{RANK}" incomplete:
incomplete: material: RED_STAINED_GLASS_PANE
material: RED_STAINED_GLASS_PANE name: "&cRank &7{RANK} &c(requires rankup)"
name: "&cRank &7{RANK} &c(requires rankup)"
fill: fill:
material: BLACK_STAINED_GLASS_PANE material: BLACK_STAINED_GLASS_PANE
name: ' ' name: ' '
-2
View File
@@ -26,8 +26,6 @@ commands:
maxrankup: maxrankup:
permission: rankup.maxrankup permission: rankup.maxrankup
description: Rankup as much as possible. description: Rankup as much as possible.
ranksgui:
description: Show the ranks GUI
permissions: permissions:
rankup.*: rankup.*:
children: children: