java类org.bukkit.inventory.BrewerInventory的实例源码

AcidInventory.java 文件源码 项目:acidisland 阅读 22 收藏 0 点赞 0 评论 0
/**
 * 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++;
        }
    }
}
AcidInventory.java 文件源码 项目:askyblock 阅读 21 收藏 0 点赞 0 评论 0
/**
 * 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++;
        }
    }
}
BrewingRelay.java 文件源码 项目:StarQuestCode 阅读 17 收藏 0 点赞 0 评论 0
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;
}
AlchemyPotionBrewer.java 文件源码 项目:McMMOPlus 阅读 67 收藏 0 点赞 0 评论 0
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;
    }
}
PotionLimitListener.java 文件源码 项目:HCFCore 阅读 21 收藏 0 点赞 0 评论 0
@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);
        }
    });

}
PotionLimitListener.java 文件源码 项目:HCFCore 阅读 23 收藏 0 点赞 0 评论 0
@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);
        }
    });

}
BrewListener.java 文件源码 项目:NoStrengthII 阅读 23 收藏 0 点赞 0 评论 0
@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.");
    }
}
  }
BrewListener.java 文件源码 项目:NoStrengthII 阅读 18 收藏 0 点赞 0 评论 0
/**
* 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;
  }
InventoryListener.java 文件源码 项目:McMMOPlus 阅读 32 收藏 0 点赞 0 评论 0
@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);
    }
}
InventoryListener.java 文件源码 项目:McMMOPlus 阅读 29 收藏 0 点赞 0 评论 0
@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);
    }
}
PlayerListener.java 文件源码 项目:Merlin 阅读 20 收藏 0 点赞 0 评论 0
@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));
  }
CraftBrewingStand.java 文件源码 项目:Uranium 阅读 22 收藏 0 点赞 0 评论 0
public BrewerInventory getInventory() {
    return new CraftInventoryBrewer(brewingStand);
}
BrewingRod.java 文件源码 项目:Aero 阅读 18 收藏 0 点赞 0 评论 0
@EventHandler
public void onOpen(InventoryOpenEvent e) {
    if(e.getInventory().getType() == InventoryType.BREWING) {
        ((BrewerInventory)e.getInventory()).setFuel(new ItemStack(Material.BLAZE_POWDER, 64));
    }
}
CraftBrewingStand.java 文件源码 项目:ThermosRebased 阅读 19 收藏 0 点赞 0 评论 0
public BrewerInventory getInventory() {
    return new CraftInventoryBrewer(brewingStand);
}
BrewEvent.java 文件源码 项目:Thermos-Bukkit 阅读 24 收藏 0 点赞 0 评论 0
public BrewEvent(Block brewer, BrewerInventory contents) {
    super(brewer);
    this.contents = contents;
}
ExprBrewingInventoryIngredient.java 文件源码 项目:Skellett 阅读 15 收藏 0 点赞 0 评论 0
@SuppressWarnings("unchecked")
@Override
public boolean init(Expression<?>[] e, int matchedPattern, Kleenean isDelayed, ParseResult parser) {
    inventory = (Expression<BrewerInventory>) e[0];
    return true;
}
ExprBrewingInventoryFuel.java 文件源码 项目:Skellett 阅读 19 收藏 0 点赞 0 评论 0
@SuppressWarnings("unchecked")
@Override
public boolean init(Expression<?>[] e, int matchedPattern, Kleenean isDelayed, ParseResult parser) {
    inventory = (Expression<BrewerInventory>) e[0];
    return true;
}
ExprBrewingInventoryFuelTime.java 文件源码 项目:Skellett 阅读 21 收藏 0 点赞 0 评论 0
@SuppressWarnings("unchecked")
@Override
public boolean init(Expression<?>[] e, int matchedPattern, Kleenean isDelayed, ParseResult parser) {
    inventory = (Expression<BrewerInventory>) e[0];
    return true;
}
ExprBrewingInventory.java 文件源码 项目:Skellett 阅读 19 收藏 0 点赞 0 评论 0
@Override
public Class<? extends BrewerInventory> getReturnType() {
    return BrewerInventory.class;
}
ExprBrewingInventory.java 文件源码 项目:Skellett 阅读 20 收藏 0 点赞 0 评论 0
@Override
@Nullable
protected BrewerInventory[] get(Event e) {
    return new BrewerInventory[]{((BrewEvent)e).getContents()};
}
ExprBrewingInventoryTime.java 文件源码 项目:Skellett 阅读 19 收藏 0 点赞 0 评论 0
@SuppressWarnings("unchecked")
@Override
public boolean init(Expression<?>[] e, int matchedPattern, Kleenean isDelayed, ParseResult parser) {
    inventory = (Expression<BrewerInventory>) e[0];
    return true;
}
CraftBrewingStand.java 文件源码 项目:Thermos 阅读 26 收藏 0 点赞 0 评论 0
public BrewerInventory getInventory() {
    return new CraftInventoryBrewer(brewingStand);
}
CraftBrewingStand.java 文件源码 项目:KCauldron 阅读 21 收藏 0 点赞 0 评论 0
public BrewerInventory getInventory() {
    return new CraftInventoryBrewer(brewingStand);
}
BrewEvent.java 文件源码 项目:CauldronGit 阅读 19 收藏 0 点赞 0 评论 0
public BrewEvent(Block brewer, BrewerInventory contents) {
    super(brewer);
    this.contents = contents;
}
CraftBrewingStand.java 文件源码 项目:CauldronGit 阅读 20 收藏 0 点赞 0 评论 0
public BrewerInventory getInventory() {
    return new CraftInventoryBrewer(brewingStand);
}
CraftBrewingStand.java 文件源码 项目:Cauldron-Old 阅读 57 收藏 0 点赞 0 评论 0
public BrewerInventory getInventory() {
    return new CraftInventoryBrewer(brewingStand);
}
CraftBrewingStand.java 文件源码 项目:Cauldron-Reloaded 阅读 22 收藏 0 点赞 0 评论 0
public BrewerInventory getInventory() {
    return new CraftInventoryBrewer(brewingStand);
}
CraftBrewingStand.java 文件源码 项目:FFoKC 阅读 28 收藏 0 点赞 0 评论 0
public BrewerInventory getInventory() {
    return new CraftInventoryBrewer(brewingStand);
}
CraftBrewingStand.java 文件源码 项目:CraftBukkit 阅读 21 收藏 0 点赞 0 评论 0
public BrewerInventory getInventory() {
    return new CraftInventoryBrewer(brewingStand);
}
CraftBrewingStand.java 文件源码 项目:Craftbukkit 阅读 20 收藏 0 点赞 0 评论 0
public BrewerInventory getInventory() {
    return new CraftInventoryBrewer(brewingStand);
}


问题


面经


文章

微信
公众号

扫码关注公众号