use of ninja.leaping.configurate.ConfigurationNode in project TotalEconomy by Erigitic.
the class BalanceTopCommand method execute.
@Override
public CommandResult execute(CommandSource src, CommandContext args) throws CommandException {
ConfigurationNode accountNode = accountManager.getAccountConfig();
List<Text> accountBalances = new ArrayList<>();
Map<String, BigDecimal> accountBalancesMap = new HashMap<>();
Currency defaultCurrency = totalEconomy.getDefaultCurrency();
accountNode.getChildrenMap().keySet().forEach(accountUUID -> {
UUID uuid;
try {
uuid = UUID.fromString(accountUUID.toString());
} catch (IllegalArgumentException e) {
return;
}
TEAccount playerAccount = (TEAccount) accountManager.getOrCreateAccount(uuid).get();
Text playerName = playerAccount.getDisplayName();
accountBalancesMap.put(playerName.toPlain(), playerAccount.getBalance(defaultCurrency));
});
accountBalancesMap.entrySet().stream().sorted(Map.Entry.<String, BigDecimal>comparingByValue().reversed()).limit(10).forEach(entry -> accountBalances.add(Text.of(TextColors.GRAY, entry.getKey(), ": ", TextColors.GOLD, defaultCurrency.format(entry.getValue()).toPlain())));
builder.title(Text.of(TextColors.GOLD, "Top 10 Balances")).contents(accountBalances).sendTo(src);
return CommandResult.success();
}
use of ninja.leaping.configurate.ConfigurationNode in project TotalEconomy by Erigitic.
the class MinerJobSet method populateNode.
@Override
public void populateNode(ConfigurationNode node) {
ConfigurationNode myNode = node.getNode(SETNAME);
for (String[] a : REWARDS) {
ConfigurationNode n = myNode.getNode(a[0], a[1]);
n.getNode("exp").setValue(a[2]);
n.getNode("money").setValue(a[3]);
}
}
use of ninja.leaping.configurate.ConfigurationNode in project TotalEconomy by Erigitic.
the class TEJobManager method reloadJobSetConfig.
/**
* Reload the jobSet config
*/
public boolean reloadJobSetConfig() {
try {
jobSetsConfig = jobSetsLoader.load();
ConfigurationNode sets = jobSetsConfig.getNode("sets");
if (!jobSetsFile.exists()) {
for (JobSet s : defaultJobSets) {
s.populateNode(sets);
}
jobSetsLoader.save(jobSetsConfig);
}
sets.getChildrenMap().forEach((setName, setNode) -> {
if (setNode != null) {
TEJobSet jobSet = new TEJobSet(setNode);
jobSets.put((String) setName, jobSet);
}
});
return true;
} catch (IOException e) {
logger.warn("[TE] An error occurred while creating/loading the jobSets configuration file!");
return false;
}
}
use of ninja.leaping.configurate.ConfigurationNode in project TotalEconomy by Erigitic.
the class FishermanJobSet method populateNode.
@Override
public void populateNode(ConfigurationNode node) {
ConfigurationNode myNode = node.getNode(SETNAME);
for (String[] a : REWARDS) {
ConfigurationNode n = myNode.getNode(a[0], a[1]);
n.getNode("exp").setValue(a[2]);
n.getNode("money").setValue(a[3]);
}
}
use of ninja.leaping.configurate.ConfigurationNode in project TotalEconomy by Erigitic.
the class LumberjackJobSet method populateNode.
@Override
public void populateNode(ConfigurationNode node) {
ConfigurationNode myNode = node.getNode(SETNAME);
for (String[] a : REWARDS) {
ConfigurationNode n = myNode.getNode(a[0], a[1]);
n.getNode("exp").setValue(a[2]);
n.getNode("money").setValue(a[3]);
}
}
Aggregations