Fix prestige requirements

This commit is contained in:
okx-code
2022-01-06 18:08:23 +00:00
parent d5a1776d9d
commit a8dbea37e8
7 changed files with 183 additions and 9 deletions
+7 -5
View File
@@ -7,13 +7,13 @@ plugins {
}
pitest {
//adds dependency to org.pitest:pitest-junit5-plugin and sets "testPlugin" to "junit5"
junit5PluginVersion = '0.15'
excludedClasses = ["Metrics.java"]
verbose = true
}
group 'sh.okx'
version '3.13.1'
version '3.13.2'
java {
sourceCompatibility = JavaVersion.VERSION_1_8
@@ -45,7 +45,7 @@ dependencies {
implementation group: 'org.slf4j', name: 'slf4j-api', version: '1.7.30'
compileOnly 'org.jetbrains:annotations:22.0.0'
compileOnly 'org.spigotmc:spigot-api:1.17.1-R0.1-SNAPSHOT'
compileOnly 'org.spigotmc:spigot-api:1.18-R0.1-SNAPSHOT'
compileOnly('com.github.Realizedd:TokenManager:3.2.4') {
transitive = false
}
@@ -53,7 +53,7 @@ dependencies {
compileOnly('com.github.MilkBowl:VaultAPI:1.7') {
exclude group: 'org.bukkit'
}
implementation ('me.clip:placeholderapi:2.10.9') {
compileOnly ('me.clip:placeholderapi:2.10.9') {
exclude group: 'org.bstats'
}
compileOnly 'com.github.pyvesb:advanced-achievements:6.7.2'
@@ -62,7 +62,9 @@ dependencies {
exclude group: 'com.sk89q.worldguard'
}
compileOnly 'com.github.BenCodez:VotingPlugin:6.0'
implementation 'com.github.LlmDl:Towny:25fc18a'
compileOnly 'com.github.LlmDl:Towny:25fc18a'
testImplementation 'com.github.LlmDl:Towny:25fc18a'
implementation ('io.pebbletemplates:pebble:3.1.5') {
exclude group: 'org.slf4j'
@@ -25,9 +25,9 @@ public class YamlDeserializer {
Map<String, List<String>> prestigeRequirements;
if (section.isConfigurationSection("requirements")) {
requirements = null;
Set<String> keys = section.getKeys(false);
prestigeRequirements = new HashMap<>(keys.size());
ConfigurationSection requirementsSection = section.getConfigurationSection("requirements");
Set<String> keys = requirementsSection.getKeys(false);
prestigeRequirements = new HashMap<>(keys.size());
for (String key : keys) {
prestigeRequirements.put(key, requirementsSection.getStringList(key));
}
@@ -1,16 +1,19 @@
package sh.okx.rankup.pebble;
import static org.junit.jupiter.api.Assertions.*;
import be.seeseemelk.mockbukkit.entity.PlayerMock;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.junit.jupiter.api.Test;
import sh.okx.rankup.RankupTest;
import sh.okx.rankup.ranks.Rank;
import sh.okx.rankup.ranks.RankElement;
import sh.okx.rankup.text.pebble.PebbleTextProcessor;
public class PebbleTest {
public class PebbleTest extends RankupTest {
@Test
public void testIndex() {
Map<String, Object> ctx = new HashMap<>();
@@ -24,4 +27,19 @@ public class PebbleTest {
PebbleTextProcessor processor = new PebbleTextProcessor(ctx, null);
assertEquals("L2", processor.process("{{ list[one] }}"));
}
@Test
public void testIterable() {
PlayerMock player = server.addPlayer();
plugin.getPermissions().addGroup(player.getUniqueId(), "C");
RankElement<Rank> rankElement = plugin.getRankups().getByPlayer(player);
plugin.newMessageBuilder("{{ rank.requirements is iterable }}")
.replacePlayer(player)
.replaceOldRank(rankElement.getRank())
.send(player);
player.assertSaid("true");
}
}
@@ -0,0 +1,29 @@
package sh.okx.rankup.requirements;
import static org.junit.jupiter.api.Assertions.*;
import be.seeseemelk.mockbukkit.entity.PlayerMock;
import org.junit.jupiter.api.Test;
import sh.okx.rankup.RankupTest;
public class PrestigeRequirementsTest extends RankupTest {
public PrestigeRequirementsTest() {
super("prestigerequirements");
}
@Test
public void testPrestigeRequirements() {
PlayerMock player = server.addPlayer();
plugin.getPermissions().addGroup(player.getUniqueId(), "p1");
plugin.getPermissions().addGroup(player.getUniqueId(), "a");
plugin.getEconomy().setPlayer(player, 200);
plugin.getHelper().rankup(player);
assertTrue(plugin.getPermissions().inGroup(player.getUniqueId(), "b"), "player is not in group b");
assertEquals(0, plugin.getEconomy().getBalance(player), "prestige requirements did not take correct amount of money");
}
}
@@ -0,0 +1,111 @@
# this is used for letting you know that you need to update/change your config file
version: 10
# the locale to use for messages
# all messages can be customised but this allows you to
# choose messages that are already translated
# locales can be found in the locale/ folder
locale: en
# interval (in minutes) to check to autorankup players
# ranking up manually will always be enabled
# set to 0 to disable
autorankup-interval: 0
# whether /ranks and /prestiges should be enabled (true) or disabled (false)
# /rankup3 reload will not do anything if this is changed,
# you will have to restart your server.
ranks: true
# you can alternatively negate the permission rankup.prestiges
# this will also make the command not autocomplete in 1.13
prestiges: true
# whether to enable the /ranks GUI.
# will override the /ranks command
ranks-gui: false
# 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,
# 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
# you negate the permission rankup.prestige with your permissions plugin.
# 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!
prestige: true
# 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.
notify-update: true
# 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,
# and automatically added and taken away from those groups.
# 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
# use commands to change a player's group or permission.
permission-rankup: false
# how people should confirm ranking up
# options are: gui, text or none
confirmation-type: 'gui'
# how long, in seconds, people have to wait between a successful /rankup or /prestige
# set to 0 to disable.
cooldown: 1
# if enabled, players can run /maxrankup to rankup as many times as possible,
# before they fail the requirements for the next rank.
# the permission rankup.maxrankup is used for this command, but it is given by default.
# note that /maxrankup, if enabled, has no confirmation.
max-rankup:
# You must restart your server if you enable or disable /maxrankup!
enabled: false
# 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 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")
individual-messages: true
# options when using the text rankup confirmation
text:
# the time in seconds for a player to
# confirm by typing /rankup again
timeout: 10
# placeholders:
# https://okx.sh/rankup/Placeholders.html
placeholders:
# format for money. for more information, see
# https://docs.oracle.com/javase/8/docs/api/java/text/DecimalFormat.html
money-format: "#,##0.##"
percent-format: "0.##"
# the format used for requirements
simple-format: "#.##"
# used for current_rank and next_rank placeholders when a player is not in anything in rankups.yml
not-in-ladder: "None"
# used in the current_prestige placeholders when a player hasn't prestiged yet
no-prestige: "None"
# used in the next_rank and next_prestige placeholders when a player is at the highest rank or prestige
highest-rank: "None"
# used in the %rankup_status_[rank]% placeholders
status:
complete: "Complete"
current: "Current"
incomplete: "Incomplete"
last-rank-display-name: "last rank"
# what to shorten money by.
# ie 1000 -> 1k
# set to an empty list to disable
# 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.
# this is used in the "| shortmoney" filter
shorten:
- 'K'
- 'M'
- 'B'
- 'T'
- 'Q'
- 'Qu'
- 'S'
@@ -0,0 +1,6 @@
first:
from: 'B'
to: 'A'
next: 'P1'
requirements:
- 'money 10000'
@@ -0,0 +1,8 @@
a:
rank: 'A'
next: 'B'
requirements:
default:
- 'money 100'
p1:
- 'money 200'