mirror of
https://github.com/xHyroM/lighteco.git
synced 2024-11-10 01:18: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();
|
CurrencyManager currencyManager = provider.getCurrencyManager();
|
||||||
CommandManager commandManager = provider.getCommandManager();
|
CommandManager commandManager = provider.getCommandManager();
|
||||||
|
|
||||||
Currency currency = new MoneyCurrency();
|
Currency currency = new MoneyCurrency(this.plugin);
|
||||||
|
|
||||||
currencyManager.registerCurrency(currency);
|
currencyManager.registerCurrency(currency);
|
||||||
commandManager.registerCurrencyCommand(currency, true);
|
commandManager.registerCurrencyCommand(currency, true);
|
||||||
|
|
|
@ -15,4 +15,8 @@ public class Config extends OkaeriConfig {
|
||||||
@Comment("Used for formatting currency")
|
@Comment("Used for formatting currency")
|
||||||
@Comment("See https://en.wikipedia.org/wiki/ISO_4217 for more information")
|
@Comment("See https://en.wikipedia.org/wiki/ISO_4217 for more information")
|
||||||
public String currencyCode = "USD";
|
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;
|
package dev.xhyrom.lighteco.currency.money.common.currency;
|
||||||
|
|
||||||
import dev.xhyrom.lighteco.api.model.currency.Currency;
|
import dev.xhyrom.lighteco.api.model.currency.Currency;
|
||||||
|
import dev.xhyrom.lighteco.currency.money.common.Plugin;
|
||||||
|
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
|
|
||||||
public class MoneyCurrency implements Currency {
|
public class MoneyCurrency implements Currency {
|
||||||
|
public final Plugin plugin;
|
||||||
|
|
||||||
|
public MoneyCurrency(Plugin plugin) {
|
||||||
|
this.plugin = plugin;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getIdentifier() {
|
public String getIdentifier() {
|
||||||
return "money";
|
return "money";
|
||||||
|
@ -27,6 +34,6 @@ public class MoneyCurrency implements Currency {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int fractionalDigits() {
|
public int fractionalDigits() {
|
||||||
return 2;
|
return this.plugin.getConfig().fractionalDigits;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,6 +5,7 @@ sequenceOf(
|
||||||
"common",
|
"common",
|
||||||
"bukkit",
|
"bukkit",
|
||||||
"bukkittest",
|
"bukkittest",
|
||||||
|
"sponge-8",
|
||||||
"currency-money"
|
"currency-money"
|
||||||
).forEach {
|
).forEach {
|
||||||
include("lighteco-$it")
|
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