1
0
Fork 0
mirror of https://github.com/xHyroM/lighteco.git synced 2024-09-19 21:03:18 +02:00

feat(money-currency): add fractional digits to config

This commit is contained in:
Jozef Steinhübl 2023-08-30 15:26:50 +02:00
parent f4bfa954b0
commit 2163f1614e
6 changed files with 40 additions and 2 deletions

View file

@ -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);

View file

@ -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;
}

View file

@ -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;
}
}

View file

@ -5,6 +5,7 @@ sequenceOf(
"common",
"bukkit",
"bukkittest",
"sponge-8",
"currency-money"
).forEach {
include("lighteco-$it")

19
sponge-8/build.gradle.kts Normal file
View 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()
}

View file

@ -0,0 +1,7 @@
package dev.xhyrom;
public class Main {
public static void main(String[] args) {
System.out.println("Hello world!");
}
}