use of org.black_ixx.playerpoints.manager.LocaleManager in project PlayerPoints by Rosewood-Development.
the class PointsUtils method setCachedValues.
public static void setCachedValues(RosePlugin rosePlugin) {
LocaleManager localeManager = rosePlugin.getManager(LocaleManager.class);
String separator = localeManager.getLocaleMessage("currency-separator");
DecimalFormat decimalFormat = new DecimalFormat();
DecimalFormatSymbols symbols = decimalFormat.getDecimalFormatSymbols();
if (!separator.isEmpty()) {
symbols.setGroupingSeparator(separator.charAt(0));
decimalFormat.setGroupingUsed(true);
decimalFormat.setGroupingSize(3);
decimalFormat.setDecimalFormatSymbols(symbols);
formatter = decimalFormat;
} else {
formatter = null;
}
suffixes.clear();
suffixes.put(1_000L, localeManager.getLocaleMessage("number-abbreviation-thousands"));
suffixes.put(1_000_000L, localeManager.getLocaleMessage("number-abbreviation-millions"));
suffixes.put(1_000_000_000L, localeManager.getLocaleMessage("number-abbreviation-billions"));
decimal = localeManager.getLocaleMessage("currency-decimal");
}
use of org.black_ixx.playerpoints.manager.LocaleManager in project PlayerPoints by Rosewood-Development.
the class ConvertCommand method execute.
@Override
public void execute(PlayerPoints plugin, CommandSender sender, String[] args) {
LocaleManager localeManager = plugin.getManager(LocaleManager.class);
if (args.length < 1) {
localeManager.sendMessage(sender, "command-convert-usage");
return;
}
CurrencyPlugin currencyPlugin = CurrencyPlugin.get(args[0]);
ConversionManager conversionManager = plugin.getManager(ConversionManager.class);
if (currencyPlugin == null || !conversionManager.getEnabledConverters().contains(currencyPlugin)) {
localeManager.sendMessage(sender, "command-convert-invalid", StringPlaceholders.single("plugin", args[0]));
return;
}
if (args.length != 2 || !args[1].equalsIgnoreCase("confirm")) {
localeManager.sendMessage(sender, "command-convert-warning", StringPlaceholders.single("plugin", args[0]));
return;
}
Bukkit.getScheduler().runTaskAsynchronously(PlayerPoints.getInstance(), () -> {
if (conversionManager.convert(currencyPlugin)) {
localeManager.sendMessage(sender, "command-convert-success", StringPlaceholders.single("plugin", args[0]));
} else {
localeManager.sendMessage(sender, "command-convert-failure");
}
});
}
use of org.black_ixx.playerpoints.manager.LocaleManager in project PlayerPoints by Rosewood-Development.
the class GiveAllCommand method execute.
@Override
public void execute(PlayerPoints plugin, CommandSender sender, String[] args) {
LocaleManager localeManager = plugin.getManager(LocaleManager.class);
if (args.length < 1) {
localeManager.sendMessage(sender, "command-giveall-usage");
return;
}
try {
int amount = Integer.parseInt(args[0]);
boolean includeOffline = args.length > 1 && args[1].equals("*");
Bukkit.getScheduler().runTaskAsynchronously(PlayerPoints.getInstance(), () -> {
boolean success;
if (includeOffline) {
success = plugin.getManager(DataManager.class).offsetAllPoints(amount);
} else {
List<UUID> playerIds = Bukkit.getOnlinePlayers().stream().map(Player::getUniqueId).collect(Collectors.toList());
success = plugin.getAPI().giveAll(playerIds, amount);
}
if (success) {
for (Player player : Bukkit.getOnlinePlayers()) {
localeManager.sendMessage(player, "command-give-received", StringPlaceholders.builder("amount", PointsUtils.formatPoints(amount)).addPlaceholder("currency", localeManager.getCurrencyName(amount)).build());
}
localeManager.sendMessage(sender, "command-giveall-success", StringPlaceholders.builder("amount", PointsUtils.formatPoints(amount)).addPlaceholder("currency", localeManager.getCurrencyName(amount)).build());
}
});
} catch (NumberFormatException e) {
localeManager.sendMessage(sender, "invalid-amount");
}
}
use of org.black_ixx.playerpoints.manager.LocaleManager in project PlayerPoints by Rosewood-Development.
the class GiveCommand method execute.
@Override
public void execute(PlayerPoints plugin, CommandSender sender, String[] args) {
LocaleManager localeManager = plugin.getManager(LocaleManager.class);
if (args.length < 2) {
localeManager.sendMessage(sender, "command-give-usage");
return;
}
Bukkit.getScheduler().runTaskAsynchronously(plugin, () -> {
OfflinePlayer player = PointsUtils.getPlayerByName(args[0]);
if (!player.hasPlayedBefore() && !player.isOnline()) {
localeManager.sendMessage(sender, "unknown-player", StringPlaceholders.single("player", args[0]));
return;
}
try {
int amount = Integer.parseInt(args[1]);
if (amount <= 0) {
localeManager.sendMessage(sender, "invalid-amount");
return;
}
if (plugin.getAPI().give(player.getUniqueId(), amount)) {
// Send message to receiver
if (player.isOnline()) {
localeManager.sendMessage((Player) player, "command-give-received", StringPlaceholders.builder("amount", PointsUtils.formatPoints(amount)).addPlaceholder("currency", localeManager.getCurrencyName(amount)).build());
}
// Send message to sender
localeManager.sendMessage(sender, "command-give-success", StringPlaceholders.builder("amount", PointsUtils.formatPoints(amount)).addPlaceholder("currency", localeManager.getCurrencyName(amount)).addPlaceholder("player", player.getName()).build());
}
} catch (NumberFormatException e) {
localeManager.sendMessage(sender, "invalid-amount");
}
});
}
use of org.black_ixx.playerpoints.manager.LocaleManager in project PlayerPoints by Rosewood-Development.
the class HelpCommand method execute.
@Override
public void execute(PlayerPoints plugin, CommandSender sender, String[] args) {
LocaleManager localeManager = plugin.getManager(LocaleManager.class);
// Send header
localeManager.sendMessage(sender, "command-help-title");
// Send command descriptions the sender has permission for
for (NamedExecutor executor : this.commandHandler.getExecutables()) if (executor.hasPermission(sender))
localeManager.sendSimpleMessage(sender, "command-" + executor.getName() + "-description");
}
Aggregations