use of org.black_ixx.playerpoints.manager.ConversionManager 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");
}
});
}
Aggregations