mirror of
https://github.com/BentoBoxWorld/Level.git
synced 2024-12-22 17:18:44 +01:00
commit
8caf0c45c8
2
pom.xml
2
pom.xml
@ -71,7 +71,7 @@
|
||||
<!-- Do not change unless you want different name for local builds. -->
|
||||
<build.number>-LOCAL</build.number>
|
||||
<!-- This allows to change between versions. -->
|
||||
<build.version>2.15.0</build.version>
|
||||
<build.version>2.16.0</build.version>
|
||||
<sonar.projectKey>BentoBoxWorld_Level</sonar.projectKey>
|
||||
<sonar.organization>bentobox-world</sonar.organization>
|
||||
<sonar.host.url>https://sonarcloud.io</sonar.host.url>
|
||||
|
@ -36,16 +36,8 @@ import world.bentobox.level.util.CachedData;
|
||||
|
||||
public class LevelsManager {
|
||||
private static final String INTOPTEN = "intopten";
|
||||
private static final TreeMap<BigInteger, String> LEVELS;
|
||||
private static final TreeMap<BigInteger, String> LEVELS = new TreeMap<>();
|
||||
private static final BigInteger THOUSAND = BigInteger.valueOf(1000);
|
||||
static {
|
||||
LEVELS = new TreeMap<>();
|
||||
|
||||
LEVELS.put(THOUSAND, "k");
|
||||
LEVELS.put(THOUSAND.pow(2), "M");
|
||||
LEVELS.put(THOUSAND.pow(3), "G");
|
||||
LEVELS.put(THOUSAND.pow(4), "T");
|
||||
}
|
||||
private final Level addon;
|
||||
|
||||
// Database handler for level data
|
||||
@ -67,6 +59,12 @@ public class LevelsManager {
|
||||
levelsCache = new HashMap<>();
|
||||
// Initialize top ten lists
|
||||
topTenLists = new ConcurrentHashMap<>();
|
||||
// Units
|
||||
LEVELS.put(THOUSAND, addon.getSettings().getKilo());
|
||||
LEVELS.put(THOUSAND.pow(2), addon.getSettings().getMega());
|
||||
LEVELS.put(THOUSAND.pow(3), addon.getSettings().getGiga());
|
||||
LEVELS.put(THOUSAND.pow(4), addon.getSettings().getTera());
|
||||
|
||||
}
|
||||
|
||||
public void migrate() {
|
||||
|
@ -3,6 +3,7 @@ package world.bentobox.level.config;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
import world.bentobox.bentobox.BentoBox;
|
||||
import world.bentobox.bentobox.api.configuration.ConfigComment;
|
||||
@ -120,6 +121,17 @@ public class ConfigSettings implements ConfigObject {
|
||||
@ConfigComment("Shows large level values rounded down, e.g., 10,345 -> 10k")
|
||||
@ConfigEntry(path = "shorthand")
|
||||
private boolean shorthand = false;
|
||||
|
||||
@ConfigComment("Shorthand units")
|
||||
@ConfigEntry(path = "units.kilo")
|
||||
private String kilo = "k";
|
||||
@ConfigEntry(path = "units.mega")
|
||||
private String mega = "M";
|
||||
@ConfigEntry(path = "units.giga")
|
||||
private String giga = "G";
|
||||
@ConfigEntry(path = "units.tera")
|
||||
private String tera = "T";
|
||||
|
||||
@ConfigComment("")
|
||||
@ConfigComment("Include Shulker Box content in chests in level calculations.")
|
||||
@ConfigComment("Will count blocks in Shulker Boxes inside of chests.")
|
||||
@ -419,4 +431,60 @@ public class ConfigSettings implements ConfigObject {
|
||||
public void setDisabledPluginHooks(List<String> disabledPluginHooks) {
|
||||
this.disabledPluginHooks = disabledPluginHooks;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the kilo
|
||||
*/
|
||||
public String getKilo() {
|
||||
return Objects.requireNonNullElse(kilo, "k");
|
||||
}
|
||||
|
||||
/**
|
||||
* @param kilo the kilo to set
|
||||
*/
|
||||
public void setKilo(String kilo) {
|
||||
this.kilo = kilo;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the mega
|
||||
*/
|
||||
public String getMega() {
|
||||
return Objects.requireNonNullElse(mega, "M");
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mega the mega to set
|
||||
*/
|
||||
public void setMega(String mega) {
|
||||
this.mega = mega;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the giga
|
||||
*/
|
||||
public String getGiga() {
|
||||
return Objects.requireNonNullElse(giga, "G");
|
||||
}
|
||||
|
||||
/**
|
||||
* @param giga the giga to set
|
||||
*/
|
||||
public void setGiga(String giga) {
|
||||
this.giga = giga;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the tera
|
||||
*/
|
||||
public String getTera() {
|
||||
return Objects.requireNonNullElse(tera, "T");
|
||||
}
|
||||
|
||||
/**
|
||||
* @param tera the tera to set
|
||||
*/
|
||||
public void setTera(String tera) {
|
||||
this.tera = tera;
|
||||
}
|
||||
}
|
||||
|
@ -4,22 +4,22 @@
|
||||
# Disabled Game Mode Addons
|
||||
# Level will NOT hook into these game mode addons.
|
||||
disabled-game-modes: []
|
||||
#
|
||||
#
|
||||
# When executing level command from console, should a report be shown?
|
||||
log-report-to-console: true
|
||||
#
|
||||
#
|
||||
# Number of concurrent island calculations
|
||||
# If your CPU can handle it, you can run parallel island calcs if there are more than one in the queue
|
||||
concurrent-island-calcs: 1
|
||||
#
|
||||
#
|
||||
# Island level calculation timeout in minutes.
|
||||
# If an island takes longer that this time to calculate, then the calculation will abort.
|
||||
# Generally, calculation should only take a few seconds, so if this ever triggers then something is not right.
|
||||
calculation-timeout: 5
|
||||
#
|
||||
#
|
||||
# Zero island levels on new island or island reset
|
||||
# If true, Level will calculate the starter island's level and remove it from any future level calculations.
|
||||
# If this is false, the player's starter island blocks will count towards their level.
|
||||
# If false, the player's starter island blocks will count towards their level.
|
||||
# This will reduce CPU if false.
|
||||
zero-new-island-levels: true
|
||||
#
|
||||
@ -72,3 +72,18 @@ sumteamdeaths: false
|
||||
# Shorthand island level
|
||||
# Shows large level values rounded down, e.g., 10,345 -> 10k
|
||||
shorthand: false
|
||||
units:
|
||||
# Shorthand units
|
||||
kilo: k
|
||||
mega: M
|
||||
giga: G
|
||||
tera: T
|
||||
#
|
||||
# Include Shulker Box content in chests in level calculations.
|
||||
# Will count blocks in Shulker Boxes inside of chests.
|
||||
# NOTE: include-chests needs to be enabled for this to work!.
|
||||
include-shulkers-in-chest: false
|
||||
#
|
||||
# Disables hooking with other plugins.
|
||||
# Example: disabled-plugin-hooks: [UltimateStacker, RoseStacker]
|
||||
disabled-plugin-hooks: []
|
@ -95,7 +95,7 @@ public class LevelsManagerTest {
|
||||
private World world;
|
||||
@Mock
|
||||
private Player player;
|
||||
@Mock
|
||||
|
||||
private ConfigSettings settings;
|
||||
@Mock
|
||||
private User user;
|
||||
@ -176,6 +176,7 @@ public class LevelsManagerTest {
|
||||
when(world.getName()).thenReturn("bskyblock-world");
|
||||
|
||||
// Settings
|
||||
settings = new ConfigSettings();
|
||||
when(addon.getSettings()).thenReturn(settings);
|
||||
|
||||
// User
|
||||
@ -334,7 +335,7 @@ public class LevelsManagerTest {
|
||||
@Test
|
||||
public void testFormatLevel() {
|
||||
assertEquals("123456789", lm.formatLevel(123456789L));
|
||||
when(settings.isShorthand()).thenReturn(true);
|
||||
settings.setShorthand(true);
|
||||
assertEquals("123.5M", lm.formatLevel(123456789L));
|
||||
assertEquals("1.2k", lm.formatLevel(1234L));
|
||||
assertEquals("123.5G", lm.formatLevel(123456789352L));
|
||||
|
Loading…
Reference in New Issue
Block a user