mirror of
https://github.com/xHyroM/lighteco.git
synced 2024-12-25 21:51:07 +01:00
feat(money-currency): add fractional digits to config
This commit is contained in:
parent
f4bfa954b0
commit
2163f1614e
6 changed files with 40 additions and 2 deletions
|
@ -32,7 +32,7 @@ public class BukkitMCLoader extends JavaPlugin {
|
|||
CurrencyManager currencyManager = provider.getCurrencyManager();
|
||||
CommandManager commandManager = provider.getCommandManager();
|
||||
|
||||
Currency currency = new MoneyCurrency();
|
||||
Currency currency = new MoneyCurrency(this.plugin);
|
||||
|
||||
currencyManager.registerCurrency(currency);
|
||||
commandManager.registerCurrencyCommand(currency, true);
|
||||
|
|
|
@ -15,4 +15,8 @@ public class Config extends OkaeriConfig {
|
|||
@Comment("Used for formatting currency")
|
||||
@Comment("See https://en.wikipedia.org/wiki/ISO_4217 for more information")
|
||||
public String currencyCode = "USD";
|
||||
|
||||
@Comment("Fractional digits")
|
||||
@Comment("How many digits after the decimal point")
|
||||
public int fractionalDigits = 2;
|
||||
}
|
||||
|
|
|
@ -1,10 +1,17 @@
|
|||
package dev.xhyrom.lighteco.currency.money.common.currency;
|
||||
|
||||
import dev.xhyrom.lighteco.api.model.currency.Currency;
|
||||
import dev.xhyrom.lighteco.currency.money.common.Plugin;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
public class MoneyCurrency implements Currency {
|
||||
public final Plugin plugin;
|
||||
|
||||
public MoneyCurrency(Plugin plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getIdentifier() {
|
||||
return "money";
|
||||
|
@ -27,6 +34,6 @@ public class MoneyCurrency implements Currency {
|
|||
|
||||
@Override
|
||||
public int fractionalDigits() {
|
||||
return 2;
|
||||
return this.plugin.getConfig().fractionalDigits;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,6 +5,7 @@ sequenceOf(
|
|||
"common",
|
||||
"bukkit",
|
||||
"bukkittest",
|
||||
"sponge-8",
|
||||
"currency-money"
|
||||
).forEach {
|
||||
include("lighteco-$it")
|
||||
|
|
19
sponge-8/build.gradle.kts
Normal file
19
sponge-8/build.gradle.kts
Normal file
|
@ -0,0 +1,19 @@
|
|||
plugins {
|
||||
id("java")
|
||||
}
|
||||
|
||||
group = "dev.xhyrom"
|
||||
version = "0.1.0"
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
}
|
||||
|
||||
dependencies {
|
||||
testImplementation(platform("org.junit:junit-bom:5.9.1"))
|
||||
testImplementation("org.junit.jupiter:junit-jupiter")
|
||||
}
|
||||
|
||||
tasks.test {
|
||||
useJUnitPlatform()
|
||||
}
|
7
sponge-8/src/main/java/dev/xhyrom/Main.java
Normal file
7
sponge-8/src/main/java/dev/xhyrom/Main.java
Normal file
|
@ -0,0 +1,7 @@
|
|||
package dev.xhyrom;
|
||||
|
||||
public class Main {
|
||||
public static void main(String[] args) {
|
||||
System.out.println("Hello world!");
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue