本文整理汇总了Java中org.bukkit.inventory.BrewerInventory.getContents方法的典型用法代码示例。如果您正苦于以下问题:Java BrewerInventory.getContents方法的具体用法?Java BrewerInventory.getContents怎么用?Java BrewerInventory.getContents使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.bukkit.inventory.BrewerInventory
的用法示例。
在下文中一共展示了BrewerInventory.getContents方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onBrewComplete
import org.bukkit.inventory.BrewerInventory; //导入方法依赖的package包/类
/**
* 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++;
}
}
}
示例2: onBrew
import org.bukkit.inventory.BrewerInventory; //导入方法依赖的package包/类
@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);
}
});
}
示例3: containsStrengthOrGlowstone
import org.bukkit.inventory.BrewerInventory; //导入方法依赖的package包/类
/**
* 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;
}