mirror of
https://github.com/BentoBoxWorld/Level.git
synced 2024-11-22 10:36:08 +01:00
Custom units for shorthand levels added to config.yml
This commit is contained in:
parent
48fbd4b38d
commit
a09f68e8af
@ -36,16 +36,8 @@ import world.bentobox.level.util.CachedData;
|
|||||||
|
|
||||||
public class LevelsManager {
|
public class LevelsManager {
|
||||||
private static final String INTOPTEN = "intopten";
|
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);
|
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;
|
private final Level addon;
|
||||||
|
|
||||||
// Database handler for level data
|
// Database handler for level data
|
||||||
@ -67,6 +59,12 @@ public class LevelsManager {
|
|||||||
levelsCache = new HashMap<>();
|
levelsCache = new HashMap<>();
|
||||||
// Initialize top ten lists
|
// Initialize top ten lists
|
||||||
topTenLists = new ConcurrentHashMap<>();
|
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() {
|
public void migrate() {
|
||||||
|
@ -3,6 +3,7 @@ package world.bentobox.level.config;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
import world.bentobox.bentobox.BentoBox;
|
import world.bentobox.bentobox.BentoBox;
|
||||||
import world.bentobox.bentobox.api.configuration.ConfigComment;
|
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")
|
@ConfigComment("Shows large level values rounded down, e.g., 10,345 -> 10k")
|
||||||
@ConfigEntry(path = "shorthand")
|
@ConfigEntry(path = "shorthand")
|
||||||
private boolean shorthand = false;
|
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("")
|
||||||
@ConfigComment("Include Shulker Box content in chests in level calculations.")
|
@ConfigComment("Include Shulker Box content in chests in level calculations.")
|
||||||
@ConfigComment("Will count blocks in Shulker Boxes inside of chests.")
|
@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) {
|
public void setDisabledPluginHooks(List<String> disabledPluginHooks) {
|
||||||
this.disabledPluginHooks = 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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -19,7 +19,7 @@ calculation-timeout: 5
|
|||||||
#
|
#
|
||||||
# Zero island levels on new island or island reset
|
# 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 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.
|
# This will reduce CPU if false.
|
||||||
zero-new-island-levels: true
|
zero-new-island-levels: true
|
||||||
#
|
#
|
||||||
@ -72,3 +72,18 @@ sumteamdeaths: false
|
|||||||
# Shorthand island level
|
# Shorthand island level
|
||||||
# Shows large level values rounded down, e.g., 10,345 -> 10k
|
# Shows large level values rounded down, e.g., 10,345 -> 10k
|
||||||
shorthand: false
|
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;
|
private World world;
|
||||||
@Mock
|
@Mock
|
||||||
private Player player;
|
private Player player;
|
||||||
@Mock
|
|
||||||
private ConfigSettings settings;
|
private ConfigSettings settings;
|
||||||
@Mock
|
@Mock
|
||||||
private User user;
|
private User user;
|
||||||
@ -176,6 +176,7 @@ public class LevelsManagerTest {
|
|||||||
when(world.getName()).thenReturn("bskyblock-world");
|
when(world.getName()).thenReturn("bskyblock-world");
|
||||||
|
|
||||||
// Settings
|
// Settings
|
||||||
|
settings = new ConfigSettings();
|
||||||
when(addon.getSettings()).thenReturn(settings);
|
when(addon.getSettings()).thenReturn(settings);
|
||||||
|
|
||||||
// User
|
// User
|
||||||
@ -334,7 +335,7 @@ public class LevelsManagerTest {
|
|||||||
@Test
|
@Test
|
||||||
public void testFormatLevel() {
|
public void testFormatLevel() {
|
||||||
assertEquals("123456789", lm.formatLevel(123456789L));
|
assertEquals("123456789", lm.formatLevel(123456789L));
|
||||||
when(settings.isShorthand()).thenReturn(true);
|
settings.setShorthand(true);
|
||||||
assertEquals("123.5M", lm.formatLevel(123456789L));
|
assertEquals("123.5M", lm.formatLevel(123456789L));
|
||||||
assertEquals("1.2k", lm.formatLevel(1234L));
|
assertEquals("1.2k", lm.formatLevel(1234L));
|
||||||
assertEquals("123.5G", lm.formatLevel(123456789352L));
|
assertEquals("123.5G", lm.formatLevel(123456789352L));
|
||||||
|
Loading…
Reference in New Issue
Block a user