/** * Prevents crafting of EnderChest unless the player has permission * * @param event */ @EventHandler(priority = EventPriority.LOW) public void onCraft(CraftItemEvent event) { if (DEBUG) { plugin.getLogger().info(event.getEventName()); } Player player = (Player) event.getWhoClicked(); if (Util.inWorld(player) || player.getWorld().equals(IslandWorld.getNetherWorld())) { if (event.getRecipe().getResult().getType() == Material.ENDER_CHEST) { if (!(player.hasPermission(Settings.PERMPREFIX + "craft.enderchest"))) { Util.sendMessage(player, plugin.getLocale(player.getUniqueId()).get("general.errors.no-permission")); event.setCancelled(true); } } } }
@EventHandler public void onCraft(CraftItemEvent e) { Player p = (Player) e.getWhoClicked(); if(e.getRecipe() instanceof ShapedRecipe) { ShapedRecipe sr = (ShapedRecipe) e.getRecipe(); if(Bukkit.getBukkitVersion().contains("1.11")) { for(BagBase bb : Util.getBags()) { if(((ShapedRecipe)bb.getRecipe()).getShape().equals(sr.getShape())) { if(!hasPermission(new Permission("bag.craft." + bb.getName(), PermissionDefault.TRUE), p)) e.setCancelled(true); } } } else if(sr.getKey().getNamespace().startsWith("bag_")) { if(!hasPermission(new Permission("bag.craft." + sr.getKey().getKey(), PermissionDefault.TRUE), p)) e.setCancelled(true); } } }
/** * Limits the player to one workbench by means of crafting. * * @param event The event */ @EventHandler(ignoreCancelled = true) public void onCraftItem(CraftItemEvent event) { if (event.getRecipe().getResult().getType().equals(Material.WORKBENCH)) { Player player = (Player) event.getWhoClicked(); UUID uuid = player.getUniqueId(); if (craftedWorkbench.contains(uuid)) { player.sendMessage(ChatColor.RED + "You may not craft another workbench!"); } else { craftedWorkbench.add(uuid); limitWorkbenches(player); player.sendMessage(ChatColor.YELLOW + "You have crafted a workbench. You may not have another one."); } } }
/** * Prevents players from crafting leather or iron armor. * * @param event The event */ @EventHandler(ignoreCancelled = true) public void onCraftItem(CraftItemEvent event) { Material result = event.getRecipe().getResult().getType(); if (result.equals(Material.LEATHER_HELMET) || result.equals(Material.LEATHER_CHESTPLATE) || result.equals(Material.LEATHER_LEGGINGS) || result.equals(Material.LEATHER_BOOTS)) { event.setCancelled(true); event.getWhoClicked().sendMessage(ChatColor.RED + "You may not craft leather armor!"); } else if (result.equals(Material.IRON_HELMET) || result.equals(Material.IRON_CHESTPLATE) || result.equals(Material.IRON_LEGGINGS) || result.equals(Material.IRON_BOOTS)) { event.setCancelled(true); event.getWhoClicked().sendMessage(ChatColor.RED + "You may not craft iron armor!"); } }
@EventHandler public void onCraft(CraftItemEvent e) { if (QuestManagerPlugin.questManagerPlugin.getPluginConfiguration().getAllowCrafting()) { return; } if (e.getWhoClicked() instanceof Player) { Player p = (Player) e.getWhoClicked(); Location loc = p.getLocation(); if (QuestManagerPlugin.questManagerPlugin.getPluginConfiguration() .getWorlds().contains(loc.getWorld().getName())) { e.setCancelled(true); } } }
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) public void onCraft(final CraftItemEvent event) { final PlayerStat stat = PlayerStat.ITEMS_CRAFTED; // Get player final Player player = (Player) event.getWhoClicked(); // Do general check if (!plugin.doGeneralCheck(player, stat)) return; final String itemCrafted = event.getCurrentItem().getType().toString(); // Update value to new stat. plugin.getDataManager().setPlayerInfo(player.getUniqueId(), stat, StatzUtil.makeQuery("uuid", player.getUniqueId().toString(), "value", 1, "world", player.getWorld().getName(), "item", itemCrafted)); }
@EventHandler public void onCraft(CraftItemEvent cie) { Player player = (Player) cie.getWhoClicked(); Game game = BedwarsRel.getInstance().getGameManager().getGameOfPlayer(player); if (game == null) { return; } if (game.getState() == GameState.STOPPED) { return; } if (BedwarsRel.getInstance().getBooleanConfig("allow-crafting", false)) { return; } cie.setCancelled(true); }
@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); } } }
@EventHandler public void onCraftItem(CraftItemEvent event) { NovaPlayer nPlayer = PlayerManager.getPlayer(event.getWhoClicked()); if(event.getRecipe().getResult().getType() != Material.SHIELD || !nPlayer.hasGuild() || nPlayer.getGuild().getBannerMeta().numberOfPatterns() == 0) { return; } for(ItemStack ingredient : event.getInventory().getContents()) { if(ingredient != null && ingredient.getType() == Material.SHIELD && ingredient.hasItemMeta()) { return; } } event.getInventory().setResult(BannerUtils.applyMeta(event.getRecipe().getResult(), nPlayer.getGuild().getBannerMeta())); }
@EventHandler(priority = EventPriority.HIGHEST) public void OnCraftItemEvent(CraftItemEvent event) { Player player; try { player = CivGlobal.getPlayer(event.getWhoClicked().getName()); } catch (CivException e) { e.printStackTrace(); return; } for (ItemStack stack : event.getInventory().getMatrix()) { BonusGoodie goodie = CivGlobal.getBonusGoodie(stack); if (goodie != null) { CivMessage.sendError(player, "Cannot use bonus goodies in a crafting recipe."); event.setCancelled(true); } } }
/** * Prevents crafting of EnderChest unless the player has permission * * @param event */ @EventHandler(priority = EventPriority.LOW) public void onCraft(CraftItemEvent event) { if (DEBUG) { plugin.getLogger().info(event.getEventName()); } Player player = (Player) event.getWhoClicked(); if (inWorld(player) || player.getWorld().equals(ASkyBlock.getNetherWorld())) { if (event.getRecipe().getResult().getType() == Material.ENDER_CHEST) { if (!(player.hasPermission(Settings.PERMPREFIX + "craft.enderchest"))) { Util.sendMessage(player, ChatColor.RED + plugin.myLocale(player.getUniqueId()).errorNoPermission); event.setCancelled(true); } } } }
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) public void onCraftItem(CraftItemEvent event) { final HumanEntity whoClicked = event.getWhoClicked(); if (!whoClicked.hasMetadata(mcMMO.playerDataKey)) { return; } ItemStack result = event.getRecipe().getResult(); if (!ItemUtils.isMcMMOItem(result)) { return; } new PlayerUpdateInventoryTask((Player) whoClicked).runTaskLater(plugin, 0); }
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) public void onCraft(CraftItemEvent event) { if (event.getRecipe().getResult() == null) { return; } if (event.getWhoClicked() instanceof Player) { ItemCraft action = this.newAction(ItemCraft.class, event.getWhoClicked().getWorld()); if (action != null) { this.setPlayerAndLocation((Player)event.getWhoClicked(), action); action.setItemstack(event.getRecipe().getResult()); this.logAction(action); } } else { // TODO missing action entity craft item } }
@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); } } } }
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) private void onCraftItem(CraftItemEvent event) { FilteredWorkbenchView workbench = _viewMap.get(event.getView()); if (workbench == null) return; ItemFilter filter = workbench.getItemFilter(); if (filter == null) return; ItemStack result = event.getRecipe().getResult(); if (!filter.isValid(result)) { tellNoCraftMessage(workbench); event.setCancelled(true); } }
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) public void onCraftItem(CraftItemEvent event) { final HumanEntity whoClicked = event.getWhoClicked(); // if (!whoClicked.hasMetadata(Ghosts.playerDataKey)) { // return; // } ItemStack result = event.getRecipe().getResult(); if (!ItemUtils.isGhostsItem(result)) { return; } new UpdateInventoryTask((Player) whoClicked).runTaskLater(Ghosts.p, 0); }
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true) public void onCraftItemEvent(final CraftItemEvent event) { HumanEntity entity = event.getWhoClicked(); if (entity instanceof Player) { final Player user = (Player)entity; final ItemStack item = event.getRecipe().getResult(); if (antib.getSettings().getData().isDisableUse() && !Permissions.BUILD.isAuthorized(user)) { if (!Permissions.CRAFT.isAuthorized(user, item.getType(), item.getData())) { event.setCancelled(true); if (antib.getSettings().getData().isWarnOnBuildDisallow()) { user.sendMessage(_("§4You are not permitted to create§c {0}§4.", item.getType().toString())); } } } } }
@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); }
@EventHandler public void onCraftItem(CraftItemEvent event){ Player player = (Player)event.getInventory().getHolder(); EpicPlayer epicPlayer = EpicSystem.getEpicPlayer(player.getUniqueId()); List<EpicQuestTask> taskList = epicPlayer.getTasksByType(TaskTypes.CRAFT_ITEM); for(EpicQuestTask task : taskList){ Material itemID = event.getRecipe().getResult().getType(); String itemNeeded = task.getTaskID(); if(itemID == Material.matchMaterial(itemNeeded)){ task.ProgressTask(1, epicPlayer, true); } } }
@EventHandler public void onWoolCraft(CraftItemEvent event) { if (event.getRecipe().getResult().getType() == Material.WOOL) { event.setCancelled(true); event.getWhoClicked().sendMessage(ChatColor.RED + "You are now allowed to craft wool."); } }
@EventHandler public void onCraft(CraftItemEvent e) { for (ItemStack item: e.getInventory().getContents()) { if (SlimefunItem.getByItem(item) != null && !(SlimefunItem.getByItem(item).isReplacing())) { e.setCancelled(true); Messages.local.sendTranslation((Player) e.getWhoClicked(), "workbench.not-enhanced", true); break; } } }
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) public void handleCraft(final CraftItemEvent event) { ParticipantState player = PGM.getMatchManager().getParticipantState(event.getWhoClicked()); if (player == null) return; for (ItemStack ingredient : event.getInventory().getMatrix()) { if(this.isDestroyableWool(ingredient, player.getParty())) { giveWoolDestroyRaindrops(player, ((Wool) ingredient.getData()).getColor()); } } }
@EventHandler public void onItemCraft(CraftItemEvent event) { ItemStack stack = event.getCurrentItem(); if(applyRules(stack)) { event.setCurrentItem(stack); event.getInventory().setResult(stack); } }
/** * Checks if a player has crafted an item for the first time and announces it if this is the case. * * @param event The event */ @EventHandler(ignoreCancelled = true) public void onCraftItem(CraftItemEvent event) { Material type = event.getRecipe().getResult().getType(); if (!invented.contains(type)) { invented.add(type); Bukkit.broadcastMessage( event.getWhoClicked().getName() + ChatColor.GRAY + " has invented the " + ChatColor.AQUA + type.name() ); } }
/** * Prevents a player from crafting a bow. * * @param event The event */ @EventHandler(ignoreCancelled = true) public void onCraftItem(CraftItemEvent event) { if (event.getRecipe().getResult().getType().equals(Material.BOW)) { event.setCancelled(true); event.getWhoClicked().sendMessage(ChatColor.RED + "You may not craft a bow!"); } }
@EventHandler(priority = EventPriority.HIGH) public void onCraftItem(CraftItemEvent event) { if( event.getRecipe().getResult().getType() == Material.STONE_SWORD || event.getRecipe().getResult().getType() == Material.IRON_SWORD || event.getRecipe().getResult().getType() == Material.GOLD_SWORD || event.getRecipe().getResult().getType() == Material.DIAMOND_SWORD || event.getRecipe().getResult().getType() == Material.LEATHER_BOOTS || event.getRecipe().getResult().getType() == Material.LEATHER_LEGGINGS || event.getRecipe().getResult().getType() == Material.LEATHER_CHESTPLATE || event.getRecipe().getResult().getType() == Material.LEATHER_HELMET || event.getRecipe().getResult().getType() == Material.CHAINMAIL_BOOTS || event.getRecipe().getResult().getType() == Material.CHAINMAIL_LEGGINGS || event.getRecipe().getResult().getType() == Material.CHAINMAIL_CHESTPLATE || event.getRecipe().getResult().getType() == Material.CHAINMAIL_HELMET || event.getRecipe().getResult().getType() == Material.GOLD_BOOTS || event.getRecipe().getResult().getType() == Material.GOLD_LEGGINGS || event.getRecipe().getResult().getType() == Material.GOLD_CHESTPLATE || event.getRecipe().getResult().getType() == Material.GOLD_HELMET || event.getRecipe().getResult().getType() == Material.IRON_BOOTS || event.getRecipe().getResult().getType() == Material.IRON_LEGGINGS || event.getRecipe().getResult().getType() == Material.IRON_CHESTPLATE || event.getRecipe().getResult().getType() == Material.IRON_HELMET || event.getRecipe().getResult().getType() == Material.DIAMOND_BOOTS || event.getRecipe().getResult().getType() == Material.DIAMOND_LEGGINGS || event.getRecipe().getResult().getType() == Material.DIAMOND_CHESTPLATE || event.getRecipe().getResult().getType() == Material.DIAMOND_HELMET) { if( event.getWhoClicked().getType() == EntityType.PLAYER ) { Player p = (Player)event.getWhoClicked(); p.sendMessage("Sorry, you are not allowed to craft this item. Purchase it from a Safe Dock instead."); } event.setCancelled(false); } }
/** * Accept only one bench crafting * * @param event Event */ @EventHandler public void onCraftItem(CraftItemEvent event) { this.onCraftItem(event.getRecipe(), event.getInventory(), event.getWhoClicked()); if (event.getRecipe().getResult().getType() == Material.WORKBENCH && !this.crafters.contains(event.getWhoClicked().getUniqueId())) this.crafters.add(event.getWhoClicked().getUniqueId()); }
@EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR) public void onCraftItem(CraftItemEvent event) { HumanEntity humanEntity = event.getWhoClicked(); if (humanEntity instanceof Player) { Player player = (Player) humanEntity; if (event.getSlotType() == InventoryType.SlotType.RESULT && isBottledExperience(event.getCurrentItem())) { player.setLevel(0); player.setExp(0); } } }
@EventHandler public void onCraftItem(CraftItemEvent event){// kinda not needed. for(ItemStack item : event.getInventory().getMatrix()){ if(item == null) continue; if(ItemUtil.matches(item, SelectorLayout.getSelectorItem())){ event.setResult(Event.Result.DENY); event.setCancelled(true); break; } } }
@EventHandler public void onCraft(CraftItemEvent e) { if (disallowedItems().contains(e.getRecipe().getResult().getType())) { e.setCancelled(true); e.getWhoClicked().sendMessage(ChatColor.RED + "Only Smiths can craft this Item!"); } }
@EventHandler public void craftItem(CraftItemEvent e){ Class<? extends Ball> clazz = null; if((clazz = PokeballManager.getFromItem(e.getCurrentItem())) == null) return; try { ItemStack item = NBTRW.writeNBT(e.getCurrentItem(), "pokeball-type", clazz.getName()); e.setCurrentItem(item); } catch (Exception e1) { e.getInventory().getViewers().get(0).sendMessage(ChatColor.RED + "There has been a problem crafting your pokeball"); return; } }
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true) public void onEnderChestCraft(CraftItemEvent event) { if (event.getInventory().getResult() != null && event.getInventory() .getResult().getType().equals(Material.ENDER_CHEST)) { event.setCancelled(true); event.getActor().sendMessage(String.format( ENDER_CHEST_MESSAGE, "craft")); } }
/** * Prevents the wool from being crafted if specified when registering the wool. * * @param event The event. */ @EventHandler(ignoreCancelled = true) public void onCraftItem(CraftItemEvent event) { for (Wool wool : getWools(Cardinal.getMatch(event.getWorld()))) { if (event.getRecipe().getResult().equals(new ItemStack(Material.WOOL, 1, wool.getColor().getData())) && !wool.isCraftable()) { event.setCancelled(true); break; } } }
@EventHandler(priority = EventPriority.MONITOR) public void onCraftItem(CraftItemEvent e) { boolean playerInv = e.getClickedInventory() instanceof PlayerInventory; Player p = (Player) e.getWhoClicked(); for (int i = playerInv ? 80 : 0; i < (playerInv ? 84 : e.getClickedInventory().getContents().length); i++) { ItemStack item = e.getClickedInventory().getContents()[i]; if (b(item)) { e.setCancelled(true); p.sendMessage(MysteryBags.PREFIX + "�7You may not craft with Mystery Bags!"); p.playSound(p.getLocation(), Sound.ENTITY_ZOMBIE_ATTACK_IRON_DOOR, 0.4F, 1.2F); p.closeInventory(); break; } } }
@EventHandler(priority = EventPriority.HIGHEST) public void arrowCraftingStopper(CraftItemEvent event) { if(event.getRecipe().getResult().getType() == Material.ARROW && event.getRecipe().getResult().getAmount() == 3) { AnniPlayer player = AnniPlayer.getPlayer(event.getWhoClicked().getUniqueId()); if(player != null && (player.getKit() == null || !player.getKit().equals(this))) event.setCancelled(true); } }
@EventHandler(priority= EventPriority.LOW, ignoreCancelled=true) public void canCraft(CraftItemEvent event) { ItemStack resultItem = event.getRecipe().getResult(); if (!PowerUtils.isPowerTool(resultItem)) { return; } if (!PowerUtils.checkCraftPermission((Player)event.getWhoClicked(), resultItem.getType())) { event.setCancelled(true); } }
@EventHandler(priority = EventPriority.HIGHEST) public void checkCraftRestriction(CraftItemEvent event) { if (!(event.getWhoClicked() instanceof Player)) { return; } for (ItemStack item : event.getInventory().getContents()) if (!LoreAttributes.loreManager.canUse((Player) event.getWhoClicked(), item)) { event.setCancelled(true); return; } }