Search in sources :

Example 6 with IEssentials

use of net.ess3.api.IEssentials in project Essentials by drtshock.

the class EssentialsSign method onSignInteract.

protected final boolean onSignInteract(final Block block, final Player player, final IEssentials ess) {
    final ISign sign = new BlockSign(block);
    final User user = ess.getUser(player);
    if (user.checkSignThrottle()) {
        return false;
    }
    try {
        if (user.getBase().isDead() || !(user.isAuthorized("essentials.signs." + signName.toLowerCase(Locale.ENGLISH) + ".use") || user.isAuthorized("essentials.signs.use." + signName.toLowerCase(Locale.ENGLISH)))) {
            return false;
        }
        final SignInteractEvent signEvent = new SignInteractEvent(sign, this, user);
        ess.getServer().getPluginManager().callEvent(signEvent);
        if (signEvent.isCancelled()) {
            return false;
        }
        return onSignInteract(sign, user, getUsername(user), ess);
    } catch (ChargeException ex) {
        showError(ess, user.getSource(), ex, signName);
        return false;
    } catch (Exception ex) {
        showError(ess, user.getSource(), ex, signName);
        return false;
    }
}
Also used : SignInteractEvent(net.ess3.api.events.SignInteractEvent) MaxMoneyException(net.ess3.api.MaxMoneyException)

Example 7 with IEssentials

use of net.ess3.api.IEssentials in project Essentials by drtshock.

the class EssentialsSign method getItemStack.

protected final ItemStack getItemStack(final String itemName, final int quantity, final IEssentials ess) throws SignException {
    try {
        final ItemStack item = ess.getItemDb().get(itemName);
        item.setAmount(quantity);
        return item;
    } catch (Exception ex) {
        throw new SignException(ex.getMessage(), ex);
    }
}
Also used : ItemStack(org.bukkit.inventory.ItemStack) MaxMoneyException(net.ess3.api.MaxMoneyException)

Aggregations

MaxMoneyException (net.ess3.api.MaxMoneyException)3 IEssentials (net.ess3.api.IEssentials)2 ItemStack (org.bukkit.inventory.ItemStack)2 PluginManager (org.bukkit.plugin.PluginManager)2 SignBreakEvent (net.ess3.api.events.SignBreakEvent)1 SignCreateEvent (net.ess3.api.events.SignCreateEvent)1 SignInteractEvent (net.ess3.api.events.SignInteractEvent)1 AsyncPlayerChatEvent (org.bukkit.event.player.AsyncPlayerChatEvent)1