Search in sources :

Example 11 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)

Example 12 with IEssentials

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

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 13 with IEssentials

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

the class EssentialsSign method onSignCreate.

protected final boolean onSignCreate(final SignChangeEvent event, final IEssentials ess) {
    final ISign sign = new EventSign(event);
    final User user = ess.getUser(event.getPlayer());
    if (!(user.isAuthorized("essentials.signs." + signName.toLowerCase(Locale.ENGLISH) + ".create") || user.isAuthorized("essentials.signs.create." + signName.toLowerCase(Locale.ENGLISH)))) {
        // they won't change it to §1[Signname]
        return true;
    }
    sign.setLine(0, tl("signFormatFail", this.signName));
    final SignCreateEvent signEvent = new SignCreateEvent(sign, this, user);
    ess.getServer().getPluginManager().callEvent(signEvent);
    if (signEvent.isCancelled()) {
        if (ess.getSettings().isDebug()) {
            ess.getLogger().info("SignCreateEvent cancelled for sign " + signEvent.getEssentialsSign().getName());
        }
        return false;
    }
    try {
        final boolean ret = onSignCreate(sign, user, getUsername(user), ess);
        if (ret) {
            sign.setLine(0, getSuccessName(ess));
        }
        return ret;
    } catch (ChargeException ex) {
        showError(ess, user.getSource(), ex, signName);
    } catch (SignException ex) {
        showError(ess, user.getSource(), ex, signName);
    }
    // Return true, so the player sees the wrong sign.
    return true;
}
Also used : SignCreateEvent(net.ess3.api.events.SignCreateEvent)

Example 14 with IEssentials

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

the class EssentialsSign method onSignCreate.

protected final boolean onSignCreate(final SignChangeEvent event, final IEssentials ess) {
    final ISign sign = new EventSign(event);
    final User user = ess.getUser(event.getPlayer());
    if (!(user.isAuthorized("essentials.signs." + signName.toLowerCase(Locale.ENGLISH) + ".create") || user.isAuthorized("essentials.signs.create." + signName.toLowerCase(Locale.ENGLISH)))) {
        // they won't change it to §1[Signname]
        return true;
    }
    sign.setLine(0, tl("signFormatFail", this.signName));
    final SignCreateEvent signEvent = new SignCreateEvent(sign, this, user);
    ess.getServer().getPluginManager().callEvent(signEvent);
    if (signEvent.isCancelled()) {
        if (ess.getSettings().isDebug()) {
            ess.getLogger().info("SignCreateEvent cancelled for sign " + signEvent.getEssentialsSign().getName());
        }
        return false;
    }
    try {
        final boolean ret = onSignCreate(sign, user, getUsername(user), ess);
        if (ret) {
            sign.setLine(0, getSuccessName(ess));
        }
        return ret;
    } catch (ChargeException ex) {
        showError(ess, user.getSource(), ex, signName);
    } catch (SignException ex) {
        showError(ess, user.getSource(), ex, signName);
    }
    // Return true, so the player sees the wrong sign.
    return true;
}
Also used : SignCreateEvent(net.ess3.api.events.SignCreateEvent)

Aggregations

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