Search in sources :

Example 1 with IEssentials

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

the class EssentialsSign method getItemMeta.

protected final ItemStack getItemMeta(final ItemStack item, final String meta, final IEssentials ess) throws SignException {
    ItemStack stack = item;
    try {
        if (!meta.isEmpty()) {
            MetaItemStack metaStack = new MetaItemStack(stack);
            final boolean allowUnsafe = ess.getSettings().allowUnsafeEnchantments();
            metaStack.addStringMeta(null, allowUnsafe, meta, ess);
            stack = metaStack.getItemStack();
        }
    } catch (Exception ex) {
        throw new SignException(ex.getMessage(), ex);
    }
    return stack;
}
Also used : ItemStack(org.bukkit.inventory.ItemStack) MaxMoneyException(net.ess3.api.MaxMoneyException)

Example 2 with IEssentials

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

the class EssentialsSign method onSignBreak.

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

Example 3 with IEssentials

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

the class EssentialsChat method onEnable.

@Override
public void onEnable() {
    final PluginManager pluginManager = getServer().getPluginManager();
    final IEssentials ess = (IEssentials) pluginManager.getPlugin("Essentials");
    if (!this.getDescription().getVersion().equals(ess.getDescription().getVersion())) {
        LOGGER.log(Level.WARNING, tl("versionMismatchAll"));
    }
    if (!ess.isEnabled()) {
        this.setEnabled(false);
        return;
    }
    final Map<AsyncPlayerChatEvent, ChatStore> chatStore = Collections.synchronizedMap(new HashMap<AsyncPlayerChatEvent, ChatStore>());
    final EssentialsChatPlayerListenerLowest playerListenerLowest = new EssentialsChatPlayerListenerLowest(getServer(), ess, chatStore);
    final EssentialsChatPlayerListenerNormal playerListenerNormal = new EssentialsChatPlayerListenerNormal(getServer(), ess, chatStore);
    final EssentialsChatPlayerListenerHighest playerListenerHighest = new EssentialsChatPlayerListenerHighest(getServer(), ess, chatStore);
    pluginManager.registerEvents(playerListenerLowest, this);
    pluginManager.registerEvents(playerListenerNormal, this);
    pluginManager.registerEvents(playerListenerHighest, this);
}
Also used : PluginManager(org.bukkit.plugin.PluginManager) IEssentials(net.ess3.api.IEssentials) AsyncPlayerChatEvent(org.bukkit.event.player.AsyncPlayerChatEvent)

Example 4 with IEssentials

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

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

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

the class EssentialsSign method getItemMeta.

protected final ItemStack getItemMeta(final ItemStack item, final String meta, final IEssentials ess) throws SignException {
    ItemStack stack = item;
    try {
        if (!meta.isEmpty()) {
            MetaItemStack metaStack = new MetaItemStack(stack);
            final boolean allowUnsafe = ess.getSettings().allowUnsafeEnchantments();
            metaStack.addStringMeta(null, allowUnsafe, meta, ess);
            stack = metaStack.getItemStack();
        }
    } catch (Exception ex) {
        throw new SignException(ex.getMessage(), ex);
    }
    return stack;
}
Also used : ItemStack(org.bukkit.inventory.ItemStack) MaxMoneyException(net.ess3.api.MaxMoneyException)

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