Search in sources :

Example 1 with PurseValue

use of com.nextplugins.economy.configuration.PurseValue in project NextEconomy by NextPlugins.

the class PurseAPI method updatePurse.

/**
 * Change purse value with messages and calling event (Better way)
 *
 * @param newValue to purse
 */
public void updatePurse(int newValue) {
    val lastNextUpdate = nextUpdate;
    val duration = PurseValue.get(PurseValue::nextUpdate);
    setNextUpdate(System.currentTimeMillis() + TimeUnit.SECONDS.toMillis(duration));
    Bukkit.getScheduler().runTaskAsynchronously(NextEconomy.getInstance(), () -> {
        val asyncPurseUpdateEvent = new AsyncPurseUpdateEvent(newValue, purse, lastNextUpdate);
        PluginManager pluginManager = Bukkit.getPluginManager();
        pluginManager.callEvent(asyncPurseUpdateEvent);
    });
}
Also used : PluginManager(org.bukkit.plugin.PluginManager) AsyncPurseUpdateEvent(com.nextplugins.economy.api.event.operations.AsyncPurseUpdateEvent) PurseValue(com.nextplugins.economy.configuration.PurseValue)

Example 2 with PurseValue

use of com.nextplugins.economy.configuration.PurseValue in project NextEconomy by NextPlugins.

the class CommandRegistry method register.

public void register() {
    try {
        BukkitFrame bukkitFrame = new BukkitFrame(plugin);
        bukkitFrame.registerCommands(new MoneyCommand(plugin, plugin.getAccountStorage(), plugin.getLocationManager()), new NextEconomyCommand(plugin.getBackupManager(), plugin.getRankingStorage(), plugin.getAccountStorage(), plugin.getConversorManager()));
        if (FeatureValue.get(FeatureValue::checkSystemEnabled)) {
            bukkitFrame.registerCommands(new CheckCommand(plugin.getAccountStorage()));
        }
        if (PurseValue.get(PurseValue::enable)) {
            bukkitFrame.registerCommands(new PurseCommand());
        }
        MessageHolder messageHolder = bukkitFrame.getMessageHolder();
        messageHolder.setMessage(MessageType.ERROR, MessageValue.get(MessageValue::error));
        messageHolder.setMessage(MessageType.INCORRECT_TARGET, MessageValue.get(MessageValue::incorrectTarget));
        messageHolder.setMessage(MessageType.INCORRECT_USAGE, MessageValue.get(MessageValue::incorrectUsage));
        messageHolder.setMessage(MessageType.NO_PERMISSION, MessageValue.get(MessageValue::noPermission));
        plugin.getLogger().info("Comandos registrados com sucesso.");
    } catch (Throwable t) {
        t.printStackTrace();
        plugin.getLogger().severe("Não foi possível registrar os comandos.");
    }
}
Also used : BukkitFrame(me.saiintbrisson.bukkit.command.BukkitFrame) CheckCommand(com.nextplugins.economy.command.bukkit.CheckCommand) MessageHolder(me.saiintbrisson.minecraft.command.message.MessageHolder) MoneyCommand(com.nextplugins.economy.command.bukkit.MoneyCommand) NextEconomyCommand(com.nextplugins.economy.command.bukkit.NextEconomyCommand) PurseCommand(com.nextplugins.economy.command.bukkit.PurseCommand) FeatureValue(com.nextplugins.economy.configuration.FeatureValue) PurseValue(com.nextplugins.economy.configuration.PurseValue)

Aggregations

PurseValue (com.nextplugins.economy.configuration.PurseValue)2 AsyncPurseUpdateEvent (com.nextplugins.economy.api.event.operations.AsyncPurseUpdateEvent)1 CheckCommand (com.nextplugins.economy.command.bukkit.CheckCommand)1 MoneyCommand (com.nextplugins.economy.command.bukkit.MoneyCommand)1 NextEconomyCommand (com.nextplugins.economy.command.bukkit.NextEconomyCommand)1 PurseCommand (com.nextplugins.economy.command.bukkit.PurseCommand)1 FeatureValue (com.nextplugins.economy.configuration.FeatureValue)1 BukkitFrame (me.saiintbrisson.bukkit.command.BukkitFrame)1 MessageHolder (me.saiintbrisson.minecraft.command.message.MessageHolder)1 PluginManager (org.bukkit.plugin.PluginManager)1