Java 类org.bukkit.inventory.BrewerInventory 实例源码

项目: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++;
        }
    }
}
项目:StarQuestCode    文件:BrewingRelay.java   
private boolean fillWaterBottle(BrewerInventory brewingInventory, InventoryManager manager) {
    if (!(manager.findMaterial(Material.WATER_BUCKET) && manager.findMaterial(Material.GLASS_BOTTLE)))
        return false;

    for (int i = 0; i < 3; i++) {
        ItemStack item = brewingInventory.getItem(i);
        if (item == null || item.getType() == Material.AIR) {
            // Add potion to the first empty potion slot in the brewing
            // stand.
            item = new ItemStack(Material.POTION);
            brewingInventory.setItem(i, item);
            manager.decrement();
            age = 0;
            return true;
        }
    }

    return false;
}
项目:McMMOPlus    文件:AlchemyPotionBrewer.java   
private static boolean removeIngredient(BrewerInventory inventory, Player player) {
    ItemStack ingredient = inventory.getIngredient() == null ? null : inventory.getIngredient().clone();

    if (isEmpty(ingredient) || !isValidIngredient(player, ingredient)) {
        return false;
    }
    else if (ingredient.getAmount() <= 1) {
        inventory.setIngredient(null);
        return true;
    }
    else {
        ingredient.setAmount(ingredient.getAmount() - 1);
        inventory.setIngredient(ingredient);
        return 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);
        }
    });

}
项目: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.");
    }
}
  }
项目:NoStrengthII    文件:BrewListener.java   
/**
* Check if the given inventory contains the ingrediens for strength 2.
* 
* @param inv The inventory checking.
* @return True if it does, false otherwise.
*/
  public boolean containsStrengthOrGlowstone(BrewerInventory inv) {
    boolean glowstone = false;
    boolean potion = false;

    // loop thru all items in the inventory.
    for (ItemStack item : inv.getContents()) {
        // if the item is null, hop over it.
        if (item == null) {
            continue;
        }

        // the item is a glowstone, set that to true.
        if (item.getType() == Material.GLOWSTONE_DUST) {
            glowstone = true;
        }

        // from now we don't want to care if its not a potion.
        if (item.getType() != Material.POTION) {
            continue;
        }

        // if the potion has the durability of a strength potion, set potion to true.
    if (item.getDurability() == 8265 || item.getDurability() == 8201) {
        potion = true;
    }
    }

    // return true if it had glowstone AND a strenght potion
    return glowstone && potion;
  }
项目:McMMOPlus    文件:InventoryListener.java   
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
public void onInventoryDragEvent(InventoryDragEvent event) {
    Inventory inventory = event.getInventory();

    if (!(inventory instanceof BrewerInventory)) {
        return;
    }

    InventoryHolder holder = inventory.getHolder();

    if (!(holder instanceof BrewingStand)) {
        return;
    }

    HumanEntity whoClicked = event.getWhoClicked();

    if (!UserManager.hasPlayerDataKey(event.getWhoClicked()) || !Permissions.secondaryAbilityEnabled(whoClicked, SecondaryAbility.CONCOCTIONS)) {
        return;
    }

    if (!event.getInventorySlots().contains(Alchemy.INGREDIENT_SLOT)) {
        return;
    }

    ItemStack cursor = event.getCursor();
    ItemStack ingredient = ((BrewerInventory) inventory).getIngredient();

    if (AlchemyPotionBrewer.isEmpty(ingredient) || ingredient.isSimilar(cursor)) {
        Player player = (Player) whoClicked;

        if (AlchemyPotionBrewer.isValidIngredient(player, cursor)) {
            // Not handled: dragging custom ingredients over ingredient slot (does not trigger any event)
            AlchemyPotionBrewer.scheduleCheck(player, (BrewingStand) holder);
            return;
        }

        event.setCancelled(true);
        AlchemyPotionBrewer.scheduleUpdate(inventory);
    }
}
项目:McMMOPlus    文件:InventoryListener.java   
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
public void onInventoryMoveItemEvent(InventoryMoveItemEvent event) {
    Inventory inventory = event.getDestination();

    if (!(inventory instanceof BrewerInventory)) {
        return;
    }

    InventoryHolder holder = inventory.getHolder();

    if (!(holder instanceof BrewingStand)) {
        return;
    }

    ItemStack item = event.getItem();

    if (Config.getInstance().getPreventHopperTransferIngredients() && item.getType() != Material.POTION) {
        event.setCancelled(true);
        return;
    }

    if (Config.getInstance().getPreventHopperTransferBottles() && item.getType() == Material.POTION) {
        event.setCancelled(true);
        return;
    }

    if (Config.getInstance().getEnabledForHoppers() && AlchemyPotionBrewer.isValidIngredient(null, item)) {
        AlchemyPotionBrewer.scheduleCheck(null, (BrewingStand) holder);
    }
}
项目:Merlin    文件:PlayerListener.java   
@EventHandler(priority = EventPriority.NORMAL)
public void onInventoryMoveItem (InventoryMoveItemEvent event)
  {
    if ( ! (event.getInitiator() instanceof PlayerInventory)
        || ! (event.getDestination() instanceof BrewerInventory))
      return;
    if (event.getItem().getType() != Material.QUARTZ)
      return;
    event.setCancelled(true);
    int amount = event.getItem().getAmount();
    ItemStack[] inv = event.getInitiator().getContents();
    for (int i = 0; i < inv.length; i++)
      {
        ItemStack item = inv[i];
        if (item.getType() != Material.QUARTZ)
          continue;
        if (item.getAmount() == amount)
          {
            inv[i] = null;
          }
        else
          {
            item.setAmount(item.getAmount() - amount);
          }
      }
    event.getInitiator().setContents(inv);
    event.getDestination().setItem(3,
        new ItemStack(Material.QUARTZ, amount));
  }
项目:Uranium    文件:CraftBrewingStand.java   
public BrewerInventory getInventory() {
    return new CraftInventoryBrewer(brewingStand);
}
项目:Aero    文件:BrewingRod.java   
@EventHandler
public void onOpen(InventoryOpenEvent e) {
    if(e.getInventory().getType() == InventoryType.BREWING) {
        ((BrewerInventory)e.getInventory()).setFuel(new ItemStack(Material.BLAZE_POWDER, 64));
    }
}
项目:ThermosRebased    文件:CraftBrewingStand.java   
public BrewerInventory getInventory() {
    return new CraftInventoryBrewer(brewingStand);
}
项目:Thermos-Bukkit    文件:BrewEvent.java   
public BrewEvent(Block brewer, BrewerInventory contents) {
    super(brewer);
    this.contents = contents;
}
项目:Skellett    文件:ExprBrewingInventoryIngredient.java   
@SuppressWarnings("unchecked")
@Override
public boolean init(Expression<?>[] e, int matchedPattern, Kleenean isDelayed, ParseResult parser) {
    inventory = (Expression<BrewerInventory>) e[0];
    return true;
}
项目:Skellett    文件:ExprBrewingInventoryFuel.java   
@SuppressWarnings("unchecked")
@Override
public boolean init(Expression<?>[] e, int matchedPattern, Kleenean isDelayed, ParseResult parser) {
    inventory = (Expression<BrewerInventory>) e[0];
    return true;
}
项目:Skellett    文件:ExprBrewingInventoryFuelTime.java   
@SuppressWarnings("unchecked")
@Override
public boolean init(Expression<?>[] e, int matchedPattern, Kleenean isDelayed, ParseResult parser) {
    inventory = (Expression<BrewerInventory>) e[0];
    return true;
}
项目:Skellett    文件:ExprBrewingInventory.java   
@Override
public Class<? extends BrewerInventory> getReturnType() {
    return BrewerInventory.class;
}
项目:Skellett    文件:ExprBrewingInventory.java   
@Override
@Nullable
protected BrewerInventory[] get(Event e) {
    return new BrewerInventory[]{((BrewEvent)e).getContents()};
}
项目:Skellett    文件:ExprBrewingInventoryTime.java   
@SuppressWarnings("unchecked")
@Override
public boolean init(Expression<?>[] e, int matchedPattern, Kleenean isDelayed, ParseResult parser) {
    inventory = (Expression<BrewerInventory>) e[0];
    return true;
}
项目:Thermos    文件:CraftBrewingStand.java   
public BrewerInventory getInventory() {
    return new CraftInventoryBrewer(brewingStand);
}
项目:KCauldron    文件:CraftBrewingStand.java   
public BrewerInventory getInventory() {
    return new CraftInventoryBrewer(brewingStand);
}
项目:CauldronGit    文件:BrewEvent.java   
public BrewEvent(Block brewer, BrewerInventory contents) {
    super(brewer);
    this.contents = contents;
}
项目:CauldronGit    文件:CraftBrewingStand.java   
public BrewerInventory getInventory() {
    return new CraftInventoryBrewer(brewingStand);
}
项目:Cauldron-Old    文件:CraftBrewingStand.java   
public BrewerInventory getInventory() {
    return new CraftInventoryBrewer(brewingStand);
}
项目:Cauldron-Reloaded    文件:CraftBrewingStand.java   
public BrewerInventory getInventory() {
    return new CraftInventoryBrewer(brewingStand);
}
项目:FFoKC    文件:CraftBrewingStand.java   
public BrewerInventory getInventory() {
    return new CraftInventoryBrewer(brewingStand);
}
项目:CraftBukkit    文件:CraftBrewingStand.java   
public BrewerInventory getInventory() {
    return new CraftInventoryBrewer(brewingStand);
}
项目:Craftbukkit    文件:CraftBrewingStand.java   
public BrewerInventory getInventory() {
    return new CraftInventoryBrewer(brewingStand);
}
项目:Almura-Server    文件:CraftBrewingStand.java   
public BrewerInventory getInventory() {
    return new CraftInventoryBrewer(brewingStand);
}
项目:Tweakkit-Server    文件:CraftBrewingStand.java   
public BrewerInventory getInventory() {
    return new CraftInventoryBrewer(brewingStand);
}
项目:Cauldron    文件:BrewEvent.java   
public BrewEvent(Block brewer, BrewerInventory contents) {
    super(brewer);
    this.contents = contents;
}
项目:Cauldron    文件:BrewEvent.java   
public BrewEvent(Block brewer, BrewerInventory contents) {
    super(brewer);
    this.contents = contents;
}
项目:Cauldron    文件:BrewEvent.java   
public BrewEvent(Block brewer, BrewerInventory contents) {
    super(brewer);
    this.contents = contents;
}
项目:Cauldron    文件:CraftBrewingStand.java   
public BrewerInventory getInventory() {
    return new CraftInventoryBrewer(brewingStand);
}
项目:McMMOPlus    文件:FakeBrewEvent.java   
public FakeBrewEvent(Block brewer, BrewerInventory contents) {
    super(brewer, contents);
}
项目:Almura-API    文件:BrewEvent.java   
public BrewEvent(Block brewer, BrewerInventory contents) {
    super(brewer);
    this.contents = contents;
}
项目:Pore    文件:PoreBrewingStand.java   
@Override
public BrewerInventory getInventory() {
    return PoreBrewerInventory.of(getTileEntity().getInventory());
}
项目:Pore    文件:PoreBrewEvent.java   
@Override
public BrewerInventory getContents() {
    return PoreBrewerInventory.of(this.getHandle().getInventory());
}