Java 类org.bukkit.event.inventory.BrewEvent 实例源码

项目:civcraft    文件:PlayerListener.java   
@EventHandler(priority = EventPriority.LOW)
public void OnBrewEvent(BrewEvent event) {
    /* Hardcoded disables based on ingredients used. */
    if (event.getContents().contains(Material.SPIDER_EYE) ||
        event.getContents().contains(Material.GOLDEN_CARROT) ||
        event.getContents().contains(Material.GHAST_TEAR) ||
        event.getContents().contains(Material.FERMENTED_SPIDER_EYE) ||
        event.getContents().contains(Material.BLAZE_POWDER) ||
        event.getContents().contains(Material.SULPHUR)) {
        event.setCancelled(true);
    }

    if (event.getContents().contains(Material.POTION)) {
        ItemStack potion = event.getContents().getItem(event.getContents().first(Material.POTION));

        if (potion.getDurability() == CivData.MUNDANE_POTION_DATA || 
            potion.getDurability() == CivData.MUNDANE_POTION_EXT_DATA ||
            potion.getDurability() == CivData.THICK_POTION_DATA) {
            event.setCancelled(true);
        }
    }
}
项目:acidisland    文件:AcidInventory.java   
/**
 * This event makes sure that any acid bottles become potions without the
 * warning
 * 
 * @param e
 */
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
public void onBrewComplete(final BrewEvent e) {
    if (DEBUG)
        plugin.getLogger().info("DEBUG: " + e.getEventName());

    if (e.getBlock().getWorld().getName().equalsIgnoreCase(Settings.worldName)) {
        //if (Settings.acidBottle && Settings.acidDamage>0 && e.getBlock().getWorld().getName().equalsIgnoreCase(Settings.worldName)) {

        plugin.getLogger().info("DEBUG: Brew Event called");
        BrewerInventory inv = e.getContents();
        int i = 0;
        for (ItemStack item : inv.getContents()) {
            if (item != null) {
                // Remove lore
                ItemMeta meta = item.getItemMeta();
                plugin.getLogger().info("DEBUG: " + meta.getDisplayName());
                meta.setDisplayName(null);
                inv.setItem(i, item);
            }
            i++;
        }
    }
}
项目:askyblock    文件:AcidInventory.java   
/**
 * This event makes sure that any acid bottles become potions without the
 * warning
 * 
 * @param e
 */
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
public void onBrewComplete(final BrewEvent e) {
    if (DEBUG)
        plugin.getLogger().info("DEBUG: " + e.getEventName());

    if (e.getBlock().getWorld().getName().equalsIgnoreCase(Settings.worldName)) {
        //if (Settings.acidBottle && Settings.acidDamage>0 && e.getBlock().getWorld().getName().equalsIgnoreCase(Settings.worldName)) {

        plugin.getLogger().info("DEBUG: Brew Event called");
        BrewerInventory inv = e.getContents();
        int i = 0;
        for (ItemStack item : inv.getContents()) {
            if (item != null) {
                // Remove lore
                ItemMeta meta = item.getItemMeta();
                plugin.getLogger().info("DEBUG: " + meta.getDisplayName());
                meta.setDisplayName(null);
                inv.setItem(i, item);
            }
            i++;
        }
    }
}
项目:SurvivalAPI    文件:DisableLevelTwoPotionModule.java   
/**
 * Disabling level II potions
 *
 * @param event Event
 */
@EventHandler
public void onBrew(BrewEvent event)
{
    if(event.getContents().getIngredient().getType() == Material.GLOWSTONE_DUST)
        event.setCancelled(true);
}
项目:HCFCore    文件:PotionLimitListener.java   
@EventHandler(ignoreCancelled = true, priority = EventPriority.HIGH)
public void onBrew(BrewEvent event) {
    /*
     * if (!testValidity(event.getContents().getContents())) { event.setCancelled(true); event.getContents().getHolder().setBrewingTime(EMPTY_BREW_TIME); }
     */

    // *** Version that works with a Spigot version that does not
    // *** have a BrewEvent#getResults() method:

    BrewerInventory inventory = event.getContents();
    ItemStack[] contents = inventory.getContents();
    int length = contents.length;
    ItemStack[] cloned = new ItemStack[length];
    for (int i = 0; i < length; i++) {
        ItemStack previous = contents[i];
        cloned[i] = (previous == null ? null : previous.clone());
    }

    BrewingStand stand = inventory.getHolder();
    Bukkit.getScheduler().runTask(HCF.getPlugin(), () -> {
        if (!testValidity(inventory.getContents())) {
            stand.setBrewingTime(EMPTY_BREW_TIME);
            inventory.setContents(cloned);
        }
    });

}
项目:HCFCore    文件:PotionLimitListener.java   
@EventHandler(ignoreCancelled = true, priority = EventPriority.HIGH)
public void onBrew(BrewEvent event) {
    /*
     * if (!testValidity(event.getContents().getContents())) { event.setCancelled(true); event.getContents().getHolder().setBrewingTime(EMPTY_BREW_TIME); }
     */

    // *** Version that works with a Spigot version that does not
    // *** have a BrewEvent#getResults() method:

    BrewerInventory inventory = event.getContents();
    ItemStack[] contents = inventory.getContents();
    int length = contents.length;
    ItemStack[] cloned = new ItemStack[length];
    for (int i = 0; i < length; i++) {
        ItemStack previous = contents[i];
        cloned[i] = (previous == null ? null : previous.clone());
    }

    BrewingStand stand = inventory.getHolder();
    Bukkit.getScheduler().runTask(HCF.getPlugin(), () -> {
        if (!testValidity(inventory.getContents())) {
            stand.setBrewingTime(EMPTY_BREW_TIME);
            inventory.setContents(cloned);
        }
    });

}
项目:BukkitOldCombatMechanics    文件:ModuleOldBrewingStand.java   
@EventHandler
public void onBrew(BrewEvent e) {
    Block block = e.getBlock();

    if(isEnabled(block.getWorld()) && block.getType().equals(Material.BREWING_STAND)) //Just in case...
        ((BrewingStand) block.getState()).setFuelLevel(20);
}
项目:Skellett    文件:ExprBrewingInventory.java   
@Override
public boolean init(Expression<?>[] e, int matchedPattern, Kleenean isDelayed, ParseResult parser) {
    if (!ScriptLoader.isCurrentEvent(BrewEvent.class)) {
        Skript.error("You can not use brewing inventory expression in any event but on brew event!");
        return false;
    }
    return true;
}
项目:NoStrengthII    文件:BrewListener.java   
@EventHandler
  public void onBrew(BrewEvent event) {
    BrewerInventory inv = event.getContents();

    // if the inventory doesn't contain glowstone AND a strength potion, return.
    if (!containsStrengthOrGlowstone(inv)) {
        return;
      }

    // cancel. 
    event.setCancelled(true);

Block block = event.getBlock();
Location blockL = block.getLocation();

// loop thru everyone online.
for (Player online : Bukkit.getOnlinePlayers()) {
    Location playerL = online.getLocation();

    // if they're within a radius send them a message.
    if (block.getWorld() == online.getWorld() && playerL.distance(blockL) < 15) {
        online.sendMessage(ChatColor.RED + "Strength II is disabled, brewing cancelled.");
    }
}
  }
项目:RedProtect    文件:RPPlayerListener.java   
@EventHandler
public void onBrewing(BrewEvent e){
    ItemStack[] cont = e.getContents().getContents();
    for (int i = 0; i < cont.length; i++){
        if (RPUtil.denyPotion(cont[i])){
            e.getContents().setItem(i, new ItemStack(Material.AIR));
        }
    }
}
项目:BetonQuest    文件:PotionObjective.java   
@EventHandler
public void onBrew(final BrewEvent event) {
    final String playerID = locations.remove(event.getBlock().getLocation());
    if (playerID == null)
        return;
    final PotionData data = ((PotionData) dataMap.get(playerID));
    // this tracks how many potions there are in the stand before brewing
    int alreadyExistingTemp = 0;
    for (int i = 0; i < 3; i++)
        if (checkPotion(event.getContents().getItem(i)))
            alreadyExistingTemp++;
    // making it final for the runnable
    final int alreadyExisting = alreadyExistingTemp;
    new BukkitRunnable() {
        @Override
        public void run() {
            // unfinaling it for modifications
            boolean brewed = false;
            int alreadyExistingFinal = alreadyExisting;
            for (int i = 0; i < 3; i++) {
                // if there were any potions before, don't count them to
                // prevent cheating
                if (checkPotion(event.getContents().getItem(i))) {
                    if (alreadyExistingFinal <= 0 && checkConditions(playerID)) {
                        data.brew();
                    }
                    alreadyExistingFinal--;
                    brewed = true;
                }
            }
            // check if the objective has been completed
            if (data.getAmount() >= amount) {
                completeObjective(playerID);
            } else if (brewed && notify) {
                Config.sendMessage(playerID, "potions_to_brew",
                        new String[] { String.valueOf(amount - data.getAmount()) });
            }
        }
    }.runTask(BetonQuest.getInstance());
}
项目:SpigotSource    文件:TileEntityBrewingStand.java   
private void o() {
    ItemStack itemstack = this.items[3];
    // CraftBukkit start
    if (getOwner() != null) {
        BrewEvent event = new BrewEvent(world.getWorld().getBlockAt(position.getX(), position.getY(), position.getZ()), (org.bukkit.inventory.BrewerInventory) this.getOwner().getInventory());
        org.bukkit.Bukkit.getPluginManager().callEvent(event);
        if (event.isCancelled()) {
            return;
        }
    }
    // CraftBukkit end

    for (int i = 0; i < 3; ++i) {
        this.items[i] = PotionBrewer.d(itemstack, this.items[i]);
    }

    --itemstack.count;
    BlockPosition blockposition = this.getPosition();

    if (itemstack.getItem().r()) {
        ItemStack itemstack1 = new ItemStack(itemstack.getItem().q());

        if (itemstack.count <= 0) {
            itemstack = itemstack1;
        } else {
            InventoryUtils.dropItem(this.world, (double) blockposition.getX(), (double) blockposition.getY(), (double) blockposition.getZ(), itemstack1);
        }
    }

    if (itemstack.count <= 0) {
        itemstack = null;
    }

    this.items[3] = itemstack;
    this.world.triggerEffect(1035, blockposition, 0);
}
项目:Bits    文件:ConfigurationManager.java   
private static HashMap<String, Class> getEventClassAssociations()
    {
        HashMap<String, Class> classHashMap = new HashMap<String, Class>();
        classHashMap.put("block-break", BlockBreakEvent.class);
        classHashMap.put("block-place", BlockPlaceEvent.class);

//      classHashMap.put("entity-leash", PlayerLeashEntityEvent.class);
        classHashMap.put("entity-kill", EntityDeathEvent.class);
        classHashMap.put("entity-shear", PlayerShearEntityEvent.class);

        classHashMap.put("item-brew", BrewEvent.class);
        classHashMap.put("item-enchant", EnchantItemEvent.class);
        classHashMap.put("item-furnace", FurnaceExtractEvent.class);

        classHashMap.put("painting-create", HangingPlaceEvent.class);

        classHashMap.put("player-regenerate", EntityRegainHealthEvent.class);
        classHashMap.put("player-shoot", EntityShootBowEvent.class);
        classHashMap.put("player-chat", AsyncPlayerChatEvent.class);
        classHashMap.put("player-death", PlayerDeathEvent.class);
        classHashMap.put("player-sleep", PlayerBedEnterEvent.class);
        classHashMap.put("player-author", PlayerEditBookEvent.class);
        classHashMap.put("player-egg", PlayerEggThrowEvent.class);
        classHashMap.put("player-fish", PlayerFishEvent.class);
        classHashMap.put("player-eat", PlayerItemConsumeEvent.class);
        classHashMap.put("player-join", PlayerJoinEvent.class);
        classHashMap.put("player-move", PlayerMoveEvent.class);

        classHashMap.put("portal-create", PortalCreateEvent.class);

        classHashMap.put("vehicle-move", VehicleMoveEvent.class);

        classHashMap.put("world-change", PlayerChangedWorldEvent.class);

        return classHashMap;
    }
项目:CraftFX    文件:RecipeListener.java   
@EventHandler
public void onBrew(BrewEvent event) {
    // Block custom items being brewed into potions (todo: add custom potion recipes?)
    if (registry.get().getDefinition(event.getContents().getIngredient()).isPresent()) {
        event.setCancelled(true);
    }
}
项目:Skellett    文件:ExprBrewingInventory.java   
@Override
@Nullable
protected BrewerInventory[] get(Event e) {
    return new BrewerInventory[]{((BrewEvent)e).getContents()};
}
项目:Almura-Server    文件:TileEntityBrewingStand.java   
private void u() {
    if (this.l()) {
        ItemStack itemstack = this.items[3];

        // CraftBukkit start
        if (getOwner() != null) {
            BrewEvent event = new BrewEvent(world.getWorld().getBlockAt(x, y, z), (org.bukkit.inventory.BrewerInventory) this.getOwner().getInventory());
            org.bukkit.Bukkit.getPluginManager().callEvent(event);
            if (event.isCancelled()) {
                return;
            }
        }
        // CraftBukkit end

        for (int i = 0; i < 3; ++i) {
            if (this.items[i] != null && this.items[i].id == Item.POTION.id) {
                int j = this.items[i].getData();
                int k = this.c(j, itemstack);
                List list = Item.POTION.c(j);
                List list1 = Item.POTION.c(k);

                if ((j <= 0 || list != list1) && (list == null || !list.equals(list1) && list1 != null)) {
                    if (j != k) {
                        this.items[i].setData(k);
                    }
                } else if (!ItemPotion.f(j) && ItemPotion.f(k)) {
                    this.items[i].setData(k);
                }
            }
        }

        if (Item.byId[itemstack.id].u()) {
            this.items[3] = new ItemStack(Item.byId[itemstack.id].t());
        } else {
            --this.items[3].count;
            if (this.items[3].count <= 0) {
                this.items[3] = null;
            }
        }
    }
}
项目:Cauldron    文件:TileEntityBrewingStand.java   
private void brewPotions()
{
    if (this.canBrew())
    {
        ItemStack itemstack = this.brewingItemStacks[3];

        // CraftBukkit start
        if (getOwner() != null)
        {
            BrewEvent event = new BrewEvent(worldObj.getWorld().getBlockAt(xCoord, yCoord, zCoord), (org.bukkit.inventory.BrewerInventory) this.getOwner().getInventory());
            org.bukkit.Bukkit.getPluginManager().callEvent(event);

            if (event.isCancelled())
            {
                return;
            }
        }

        // CraftBukkit end

        for (int i = 0; i < 3; ++i)
        {
            if (this.brewingItemStacks[i] != null && this.brewingItemStacks[i].getItem() instanceof ItemPotion)
            {
                int j = this.brewingItemStacks[i].getItemDamage();
                int k = this.func_145936_c(j, itemstack);
                List list = Items.potionitem.getEffects(j);
                List list1 = Items.potionitem.getEffects(k);

                if ((j <= 0 || list != list1) && (list == null || !list.equals(list1) && list1 != null))
                {
                    if (j != k)
                    {
                        this.brewingItemStacks[i].setItemDamage(k);
                    }
                }
                else if (!ItemPotion.isSplash(j) && ItemPotion.isSplash(k))
                {
                    this.brewingItemStacks[i].setItemDamage(k);
                }
            }
        }

        if (itemstack.getItem().hasContainerItem(itemstack))
        {
            this.brewingItemStacks[3] = itemstack.getItem().getContainerItem(itemstack);
        }
        else
        {
            --this.brewingItemStacks[3].stackSize;

            if (this.brewingItemStacks[3].stackSize <= 0)
            {
                this.brewingItemStacks[3] = null;
            }
        }
        MinecraftForge.EVENT_BUS.post(new PotionBrewedEvent(brewingItemStacks));
    }
}
项目:Craft-city    文件:TileEntityBrewingStand.java   
private void u() {
    if (this.l()) {
        ItemStack itemstack = this.items[3];

        // CraftBukkit start
        if (getOwner() != null) {
            BrewEvent event = new BrewEvent(world.getWorld().getBlockAt(x, y, z), (org.bukkit.inventory.BrewerInventory) this.getOwner().getInventory());
            org.bukkit.Bukkit.getPluginManager().callEvent(event);
            if (event.isCancelled()) {
                return;
            }
        }
        // CraftBukkit end

        for (int i = 0; i < 3; ++i) {
            if (this.items[i] != null && this.items[i].id == Item.POTION.id) {
                int j = this.items[i].getData();
                int k = this.c(j, itemstack);
                List list = Item.POTION.c(j);
                List list1 = Item.POTION.c(k);

                if ((j <= 0 || list != list1) && (list == null || !list.equals(list1) && list1 != null)) {
                    if (j != k) {
                        this.items[i].setData(k);
                    }
                } else if (!ItemPotion.f(j) && ItemPotion.f(k)) {
                    this.items[i].setData(k);
                }
            }
        }

        if (Item.byId[itemstack.id].t()) {
            this.items[3] = new ItemStack(Item.byId[itemstack.id].s());
        } else {
            --this.items[3].count;
            if (this.items[3].count <= 0) {
                this.items[3] = null;
            }
        }
    }
}
项目:Breakpoint    文件:BanListener.java   
@EventHandler public void e(BrewEvent event) { event.setCancelled(true); }
项目:Breakpoint    文件:BanListener.java   
@EventHandler public void e(BrewEvent event) { event.setCancelled(true); }