本文整理匯總了Java中org.bukkit.event.inventory.CraftItemEvent.isCancelled方法的典型用法代碼示例。如果您正苦於以下問題:Java CraftItemEvent.isCancelled方法的具體用法?Java CraftItemEvent.isCancelled怎麽用?Java CraftItemEvent.isCancelled使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.bukkit.event.inventory.CraftItemEvent
的用法示例。
在下文中一共展示了CraftItemEvent.isCancelled方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: onCraftItem
import org.bukkit.event.inventory.CraftItemEvent; //導入方法依賴的package包/類
@EventHandler(priority = EventPriority.LOW)
public void onCraftItem(CraftItemEvent event)
{
if (!event.isCancelled())
{
ItemStack gapple = new ItemStack(Material.GOLDEN_APPLE, (short) 1);
if (event.getRecipe().getResult() == gapple)
{
if (event.getWhoClicked() instanceof Player)
{
plugin.getCoreErrors().cantCraftGoldenApples((Player) event.getWhoClicked());
}
event.setCancelled(true);
}
}
}
示例2: onCrafting
import org.bukkit.event.inventory.CraftItemEvent; //導入方法依賴的package包/類
@EventHandler(priority=EventPriority.MONITOR)
public void onCrafting(CraftItemEvent event) {
if (event.isCancelled()) {
return;
}
if (event.getWhoClicked() instanceof Player) {
Player player = (Player) event.getWhoClicked();
String playerID = PlayerConverter.getID(player);
CraftData playerData = (CraftData) dataMap.get(playerID);
if (containsPlayer(playerID) && item.compare(event.getRecipe().getResult()) && checkConditions(playerID)) {
playerData.subtract(event.getRecipe().getResult().getAmount());
if (playerData.isZero()) {
completeObjective(playerID);
}
}
}
}
示例3: stopVanillaCraft
import org.bukkit.event.inventory.CraftItemEvent; //導入方法依賴的package包/類
@EventHandler
public void stopVanillaCraft(CraftItemEvent e) {
if (!(e.getWhoClicked() instanceof Player)) return;
Player p = (Player) e.getWhoClicked();
if (!RUtils.isInInfectedWorld(p)) return;
Recipe rr = e.getRecipe();
ItemStack result = rr.getResult();
if (rr instanceof ShapedRecipe) {
ShapedRecipe srr = (ShapedRecipe) rr;
if (result.getType() == Material.BOW && !shapedRecipesMatch(srr, plugin.bowRecipe)) e.setCancelled(true);
if (Config.harderTorches && result.getType() == Material.TORCH && !srr.getIngredientMap().values().equals(plugin.torchRecipe.getIngredientList()))
e.setCancelled(true);
if (result.getType() == Material.ARROW && !srr.getIngredientMap().values().containsAll(plugin.arrowRecipe.getIngredientList()))
e.setCancelled(true);
}
if (e.isCancelled()) e.setResult(Event.Result.DENY);
}
示例4: onCraftItem
import org.bukkit.event.inventory.CraftItemEvent; //導入方法依賴的package包/類
@EventHandler
public void onCraftItem(CraftItemEvent event) {
if (event.isCancelled()) return;
final Player p = (Player) event.getWhoClicked();
CraftingInventory inventory = event.getInventory();
for(ItemStack is : inventory.getContents()) {
if(ArmorStandTool.isTool(is)) {
event.setCancelled(true);
//noinspection deprecation
p.updateInventory();
return;
}
}
}
示例5: getCraftAmount
import org.bukkit.event.inventory.CraftItemEvent; //導入方法依賴的package包/類
/**
* Get the amount of items the player had just crafted. This method will
* take into consideration shift clicking & the amount of inventory space
* the player has left.
*
* @param CraftItemEvent
* @return int: actual crafted item amount
*/
public static int getCraftAmount(CraftItemEvent e)
{
if (e.isCancelled())
{
return 0;
}
Player p = (Player) e.getWhoClicked();
if (e.isShiftClick())
{
int itemsChecked = 0;
int possibleCreations = 1;
int amountCanBeMade = 0;
for (ItemStack item : e.getInventory().getMatrix())
{
if (item != null && item.getType() != Material.AIR)
{
if (itemsChecked == 0)
{
possibleCreations = item.getAmount();
itemsChecked++;
} else
{
possibleCreations = Math.min(possibleCreations, item.getAmount());
}
}
}
int amountOfItems = e.getRecipe().getResult().getAmount() * possibleCreations;
ItemStack i = e.getRecipe().getResult();
for (int s = 0; s <= 35; s++)
{
ItemStack test = p.getInventory().getItem(s);
if (test == null || test.getType() == Material.AIR)
{
amountCanBeMade += i.getMaxStackSize();
continue;
}
if (test.isSimilar(i))
{
amountCanBeMade += i.getMaxStackSize() - test.getAmount();
}
}
return amountOfItems > amountCanBeMade ? amountCanBeMade : amountOfItems;
} else
{
return e.getRecipe().getResult().getAmount();
}
}