Search in sources :

Example 1 with ConversionManager

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");
        }
    });
}
Also used : CurrencyPlugin(org.black_ixx.playerpoints.conversion.CurrencyPlugin) ConversionManager(org.black_ixx.playerpoints.manager.ConversionManager) LocaleManager(org.black_ixx.playerpoints.manager.LocaleManager)

Aggregations

CurrencyPlugin (org.black_ixx.playerpoints.conversion.CurrencyPlugin)1 ConversionManager (org.black_ixx.playerpoints.manager.ConversionManager)1 LocaleManager (org.black_ixx.playerpoints.manager.LocaleManager)1