当前位置: 首页>>代码示例>>Java>>正文


Java BrewerInventory类代码示例

本文整理汇总了Java中org.bukkit.inventory.BrewerInventory的典型用法代码示例。如果您正苦于以下问题:Java BrewerInventory类的具体用法?Java BrewerInventory怎么用?Java BrewerInventory使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


BrewerInventory类属于org.bukkit.inventory包,在下文中一共展示了BrewerInventory类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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++;
        }
    }
}
 
开发者ID:tastybento,项目名称:acidisland,代码行数:30,代码来源:AcidInventory.java

示例2: fillWaterBottle

import org.bukkit.inventory.BrewerInventory; //导入依赖的package包/类
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;
}
 
开发者ID:StarQuestMinecraft,项目名称:StarQuestCode,代码行数:20,代码来源:BrewingRelay.java

示例3: removeIngredient

import org.bukkit.inventory.BrewerInventory; //导入依赖的package包/类
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;
    }
}
 
开发者ID:Pershonkey,项目名称:McMMOPlus,代码行数:17,代码来源:AlchemyPotionBrewer.java

示例4: 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);
        }
    });

}
 
开发者ID:funkemunky,项目名称:HCFCore,代码行数:28,代码来源:PotionLimitListener.java

示例5: onBrew

import org.bukkit.inventory.BrewerInventory; //导入依赖的package包/类
@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.");
	}
}
  }
 
开发者ID:LeonTG,项目名称:NoStrengthII,代码行数:26,代码来源:BrewListener.java

示例6: 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;
  }
 
开发者ID:LeonTG,项目名称:NoStrengthII,代码行数:37,代码来源:BrewListener.java

示例7: onInventoryDragEvent

import org.bukkit.inventory.BrewerInventory; //导入依赖的package包/类
@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);
    }
}
 
开发者ID:Pershonkey,项目名称:McMMOPlus,代码行数:41,代码来源:InventoryListener.java

示例8: onInventoryMoveItemEvent

import org.bukkit.inventory.BrewerInventory; //导入依赖的package包/类
@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);
    }
}
 
开发者ID:Pershonkey,项目名称:McMMOPlus,代码行数:31,代码来源:InventoryListener.java

示例9: onInventoryMoveItem

import org.bukkit.inventory.BrewerInventory; //导入依赖的package包/类
@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));
  }
 
开发者ID:DiGitHubCap,项目名称:Merlin,代码行数:30,代码来源:PlayerListener.java

示例10: getInventory

import org.bukkit.inventory.BrewerInventory; //导入依赖的package包/类
public BrewerInventory getInventory() {
    return new CraftInventoryBrewer(brewingStand);
}
 
开发者ID:UraniumMC,项目名称:Uranium,代码行数:4,代码来源:CraftBrewingStand.java

示例11: onOpen

import org.bukkit.inventory.BrewerInventory; //导入依赖的package包/类
@EventHandler
public void onOpen(InventoryOpenEvent e) {
    if(e.getInventory().getType() == InventoryType.BREWING) {
        ((BrewerInventory)e.getInventory()).setFuel(new ItemStack(Material.BLAZE_POWDER, 64));
    }
}
 
开发者ID:Tom7653,项目名称:Aero,代码行数:7,代码来源:BrewingRod.java

示例12: BrewEvent

import org.bukkit.inventory.BrewerInventory; //导入依赖的package包/类
public BrewEvent(Block brewer, BrewerInventory contents) {
    super(brewer);
    this.contents = contents;
}
 
开发者ID:CyberdyneCC,项目名称:Thermos-Bukkit,代码行数:5,代码来源:BrewEvent.java

示例13: init

import org.bukkit.inventory.BrewerInventory; //导入依赖的package包/类
@SuppressWarnings("unchecked")
@Override
public boolean init(Expression<?>[] e, int matchedPattern, Kleenean isDelayed, ParseResult parser) {
	inventory = (Expression<BrewerInventory>) e[0];
	return true;
}
 
开发者ID:TheLimeGlass,项目名称:Skellett,代码行数:7,代码来源:ExprBrewingInventoryIngredient.java

示例14: getReturnType

import org.bukkit.inventory.BrewerInventory; //导入依赖的package包/类
@Override
public Class<? extends BrewerInventory> getReturnType() {
	return BrewerInventory.class;
}
 
开发者ID:TheLimeGlass,项目名称:Skellett,代码行数:5,代码来源:ExprBrewingInventory.java

示例15: get

import org.bukkit.inventory.BrewerInventory; //导入依赖的package包/类
@Override
@Nullable
protected BrewerInventory[] get(Event e) {
	return new BrewerInventory[]{((BrewEvent)e).getContents()};
}
 
开发者ID:TheLimeGlass,项目名称:Skellett,代码行数:6,代码来源:ExprBrewingInventory.java


注:本文中的org.bukkit.inventory.BrewerInventory类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。