diff --git a/currency-money/src/main/java/dev/xhyrom/lighteco/currency/money/bukkit/BukkitMCLoader.java b/currency-money/src/main/java/dev/xhyrom/lighteco/currency/money/bukkit/BukkitMCLoader.java index d024bb7..f19dc8b 100644 --- a/currency-money/src/main/java/dev/xhyrom/lighteco/currency/money/bukkit/BukkitMCLoader.java +++ b/currency-money/src/main/java/dev/xhyrom/lighteco/currency/money/bukkit/BukkitMCLoader.java @@ -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); diff --git a/currency-money/src/main/java/dev/xhyrom/lighteco/currency/money/common/config/Config.java b/currency-money/src/main/java/dev/xhyrom/lighteco/currency/money/common/config/Config.java index 4808f32..0134dc8 100644 --- a/currency-money/src/main/java/dev/xhyrom/lighteco/currency/money/common/config/Config.java +++ b/currency-money/src/main/java/dev/xhyrom/lighteco/currency/money/common/config/Config.java @@ -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; } diff --git a/currency-money/src/main/java/dev/xhyrom/lighteco/currency/money/common/currency/MoneyCurrency.java b/currency-money/src/main/java/dev/xhyrom/lighteco/currency/money/common/currency/MoneyCurrency.java index 8b80f5f..5dbcef8 100644 --- a/currency-money/src/main/java/dev/xhyrom/lighteco/currency/money/common/currency/MoneyCurrency.java +++ b/currency-money/src/main/java/dev/xhyrom/lighteco/currency/money/common/currency/MoneyCurrency.java @@ -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; } } diff --git a/settings.gradle.kts b/settings.gradle.kts index 2b839d4..ea43780 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -5,6 +5,7 @@ sequenceOf( "common", "bukkit", "bukkittest", + "sponge-8", "currency-money" ).forEach { include("lighteco-$it") diff --git a/sponge-8/build.gradle.kts b/sponge-8/build.gradle.kts new file mode 100644 index 0000000..e17e5d8 --- /dev/null +++ b/sponge-8/build.gradle.kts @@ -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() +} \ No newline at end of file diff --git a/sponge-8/src/main/java/dev/xhyrom/Main.java b/sponge-8/src/main/java/dev/xhyrom/Main.java new file mode 100644 index 0000000..aec9966 --- /dev/null +++ b/sponge-8/src/main/java/dev/xhyrom/Main.java @@ -0,0 +1,7 @@ +package dev.xhyrom; + +public class Main { + public static void main(String[] args) { + System.out.println("Hello world!"); + } +} \ No newline at end of file