Search in sources :

Example 1 with SignCreateEvent

use of net.ess3.api.events.SignCreateEvent 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 2 with SignCreateEvent

use of net.ess3.api.events.SignCreateEvent 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

SignCreateEvent (net.ess3.api.events.SignCreateEvent)2