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);
}
}
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;
}
}
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;
}
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;
}
Aggregations