mirror of
https://github.com/AppleDash/SaneEconomy.git
synced 2024-09-27 14:12:58 +02:00
Version bump to 0.7.2 and a bit of refactoring.
This commit is contained in:
parent
1c217be26a
commit
3bbca6dfaf
@ -6,10 +6,10 @@
|
||||
<parent>
|
||||
<groupId>org.appledash</groupId>
|
||||
<artifactId>SaneEconomy</artifactId>
|
||||
<version>0.7.1-SNAPSHOT</version>
|
||||
<version>0.7.2-SNAPSHOT</version>
|
||||
</parent>
|
||||
<artifactId>SaneEconomyCore</artifactId>
|
||||
<version>0.7.1-SNAPSHOT</version>
|
||||
<version>0.7.2-SNAPSHOT</version>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
|
@ -95,7 +95,6 @@ public class SaneEconomy extends JavaPlugin implements ISaneEconomy {
|
||||
saveConfig();
|
||||
|
||||
return economyManager != null;
|
||||
|
||||
}
|
||||
|
||||
private void loadCommands() {
|
||||
|
@ -1,6 +1,7 @@
|
||||
package org.appledash.saneeconomy.economy;
|
||||
|
||||
import org.bukkit.configuration.Configuration;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
|
||||
import java.text.DecimalFormat;
|
||||
|
||||
@ -21,11 +22,11 @@ public class Currency {
|
||||
this.format = format;
|
||||
}
|
||||
|
||||
public static Currency fromConfig(Configuration config, String baseNode) {
|
||||
public static Currency fromConfig(ConfigurationSection config) {
|
||||
return new Currency(
|
||||
config.getString(String.format("%s.name.singular", baseNode), "dollar"),
|
||||
config.getString(String.format("%s.name.plural", baseNode), "dollars"),
|
||||
new DecimalFormat(config.getString(String.format("%s.format", baseNode), "0.00"))
|
||||
config.getString("name.singular", "dollar"),
|
||||
config.getString("name.plural", "dollars"),
|
||||
new DecimalFormat(config.getString("format", "0.00"))
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -31,7 +31,7 @@ public class SaneEconomyConfiguration {
|
||||
|
||||
public EconomyManager loadEconomyBackend() {
|
||||
logger.info("Initializing currency...");
|
||||
Currency currency = Currency.fromConfig(rootConfig, "currency");
|
||||
Currency currency = Currency.fromConfig(rootConfig.getConfigurationSection("currency"));
|
||||
logger.info("Initialized currency: " + currency.getPluralName());
|
||||
|
||||
logger.info("Initializing economy storage backend...");
|
||||
@ -64,6 +64,11 @@ public class SaneEconomyConfiguration {
|
||||
return new EconomyManager(saneEconomy, currency, backend);
|
||||
}
|
||||
|
||||
/**
|
||||
* Load an EconomyStorageBackend using the information in the given ConfigurationSection.
|
||||
* @param config ConfigurationSection to read connection parameters from
|
||||
* @return Constructed EconomyStorageBackend, or null if something inappropriate happened.
|
||||
*/
|
||||
private EconomyStorageBackend loadBackend(ConfigurationSection config) {
|
||||
EconomyStorageBackend backend;
|
||||
String backendType = config.getString("type");
|
||||
@ -94,6 +99,12 @@ public class SaneEconomyConfiguration {
|
||||
return backend;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert one EconomyStorageBackend to another.
|
||||
* Right now, this just consists of converting all player balances. Data in the old backend is kept.
|
||||
* @param old Old backend
|
||||
* @param newer New backend
|
||||
*/
|
||||
private void convertBackends(EconomyStorageBackend old, EconomyStorageBackend newer) {
|
||||
old.getAllBalances().forEach((uniqueId, balance) -> {
|
||||
newer.setBalance(new EconomableGeneric(uniqueId), balance);
|
||||
@ -101,6 +112,11 @@ public class SaneEconomyConfiguration {
|
||||
newer.waitUntilFlushed();
|
||||
}
|
||||
|
||||
/**
|
||||
* Load database host, port, username, password, and db name from a ConfigurationSection
|
||||
* @param config ConfigurationSection containing the right fields.
|
||||
* @return DatabaseCredentials with the information from the config.
|
||||
*/
|
||||
private DatabaseCredentials loadCredentials(ConfigurationSection config) {
|
||||
String backendHost = config.getString("host");
|
||||
int backendPort = config.getInt("port", 3306);
|
||||
|
@ -1,7 +1,7 @@
|
||||
name: SaneEconomy
|
||||
author: AppleDash
|
||||
main: org.appledash.saneeconomy.SaneEconomy
|
||||
version: 0.7.1
|
||||
version: 0.7.2
|
||||
softdepend: [Vault]
|
||||
commands:
|
||||
balance:
|
||||
|
Loading…
Reference in New Issue
Block a user