Search in sources :

Example 1 with PrismExtinguishEvent

use of me.botsko.prism.events.PrismExtinguishEvent in project Prism-Bukkit by prism.

the class ExtinguishCommand method handle.

/**
 * Handle the command.
 */
@Override
public void handle(CallInfo call) {
    int radius = plugin.getConfig().getInt("prism.ex.default-radius");
    if (call.getArgs().length == 2) {
        if (TypeUtils.isNumeric(call.getArg(1))) {
            final int _tmp_radius = Integer.parseInt(call.getArg(1));
            if (_tmp_radius > 0) {
                if (_tmp_radius > plugin.getConfig().getInt("prism.ex.max-radius")) {
                    Prism.messenger.sendMessage(call.getPlayer(), Prism.messenger.playerError(Il8nHelper.getMessage("radius-max")));
                    return;
                } else {
                    radius = _tmp_radius;
                }
            } else {
                Prism.messenger.sendMessage(call.getPlayer(), Prism.messenger.playerError(Il8nHelper.getMessage("radius-small")));
                return;
            }
        } else {
            Prism.messenger.sendMessage(call.getPlayer(), Prism.messenger.playerError(Il8nHelper.getMessage("radius-not-numeric")));
            return;
        }
    }
    final ArrayList<BlockStateChange> blockStateChanges = Utilities.extinguish(call.getPlayer().getLocation(), radius);
    if (!blockStateChanges.isEmpty()) {
        Prism.messenger.sendMessage(call.getPlayer(), Prism.messenger.playerHeaderMsg(Il8nHelper.getMessage("fire-extinguished-sucess")));
        // Trigger the event
        final PrismExtinguishEvent event = EventHelper.createExtinguishEvent(blockStateChanges, call.getPlayer(), radius);
        plugin.getServer().getPluginManager().callEvent(event);
    } else {
        Prism.getAudiences().player(call.getPlayer()).sendMessage(Identity.nil(), Prism.messenger.playerError(Il8nHelper.getMessage("no-fires-found")));
    }
}
Also used : BlockStateChange(me.botsko.prism.api.BlockStateChange) PrismExtinguishEvent(me.botsko.prism.events.PrismExtinguishEvent)

Aggregations

BlockStateChange (me.botsko.prism.api.BlockStateChange)1 PrismExtinguishEvent (me.botsko.prism.events.PrismExtinguishEvent)1