Java Code Examples for org.bukkit.Material#GOLDEN_APPLE
The following examples show how to use
org.bukkit.Material#GOLDEN_APPLE .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: InteractItemEvent.java From Hawk with GNU General Public License v3.0 | 7 votes |
@Override public void postProcess() { Material mat = getItemStack().getType(); boolean gapple = mat == Material.GOLDEN_APPLE; if(action == Action.START_USE_ITEM) { if((mat.isEdible() && (p.getFoodLevel() < 20 || gapple) && p.getGameMode() != GameMode.CREATIVE) || (mat == Material.POTION && getItemStack().getDurability() == 0) || //water bottles (mat == Material.POTION && !Potion.fromItemStack(getItemStack()).isSplash())) { pp.setConsumingItem(true); } if(EnchantmentTarget.WEAPON.includes(mat)) { pp.setBlocking(true); } if(mat == Material.BOW && (p.getInventory().contains(Material.ARROW) || p.getGameMode() == GameMode.CREATIVE)) { pp.setPullingBow(true); } } else if(action == Action.RELEASE_USE_ITEM || action == Action.DROP_HELD_ITEM || action == Action.DROP_HELD_ITEM_STACK) { pp.setConsumingItem(false); pp.setBlocking(false); pp.setPullingBow(false); } }
Example 2
Source File: GoldenHeadsModule.java From UHC with MIT License | 6 votes |
@EventHandler public void on(PrepareItemCraftEvent event) { if (event.getRecipe().getResult().getType() != Material.GOLDEN_APPLE) return; final ItemStack centre = event.getInventory().getMatrix()[CRAFTING_INVENTORY_CENTRE_SLOT_ID]; if (centre == null || centre.getType() != Material.SKULL_ITEM) return; if (!isEnabled()) { event.getInventory().setResult(new ItemStack(Material.AIR)); return; } final SkullMeta meta = (SkullMeta) centre.getItemMeta(); final ItemStack goldenHeadItem = getGoldenHeadItem(meta.hasOwner() ? meta.getOwner() : "Manually Crafted"); event.getInventory().setResult(goldenHeadItem); }
Example 3
Source File: GoldenHeadsModule.java From UHC with MIT License | 6 votes |
public ItemStack getGoldenHeadItem(String playerName) { final ItemStack itemStack = new ItemStack(Material.GOLDEN_APPLE, 1); final ItemMeta meta = itemStack.getItemMeta(); meta.setDisplayName(HEAD_NAME); // add lore final ImmutableMap<String, String> context = ImmutableMap.of( "player", playerName, "amount", Integer.toString(getHealAmount()) ); final List<String> lore = getMessageTemaplates().evalTemplates(LORE_PATH, context); meta.setLore(lore); itemStack.setItemMeta(meta); return itemStack; }
Example 4
Source File: IndicatorListener.java From HoloAPI with GNU General Public License v3.0 | 6 votes |
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) public void onConsumePotion(PlayerItemConsumeEvent event) { if (Settings.INDICATOR_ENABLE.getValue("potion")) { if (event.getItem().getType() == Material.POTION) { Potion potion = Potion.fromItemStack(event.getItem()); if (potion != null) { this.showPotionHologram(event.getPlayer(), potion.getEffects()); } } else if (event.getItem().getType() == Material.GOLDEN_APPLE) { String msg = Settings.INDICATOR_FORMAT.getValue("potion", "goldenapple"); if (event.getItem().getDurability() == 1) { msg = Settings.INDICATOR_FORMAT.getValue("potion", "godapple"); } Location l = event.getPlayer().getLocation().clone(); l.setY(l.getY() + Settings.INDICATOR_Y_OFFSET.getValue("potion")); HoloAPI.getManager().createSimpleHologram(l, Settings.INDICATOR_TIME_VISIBLE.getValue("potion"), true, msg.replace("%effect%", "Golden Apple")); } } }
Example 5
Source File: UhcItems.java From UhcCore with GNU General Public License v3.0 | 5 votes |
public static ItemStack createGoldenHead(){ ItemStack itemStack = new ItemStack(Material.GOLDEN_APPLE); ItemMeta itemMeta = itemStack.getItemMeta(); itemMeta.setDisplayName(Lang.ITEMS_GOLDEN_HEAD_APPLE_NAME); itemMeta.setLore(Collections.singletonList(Lang.ITEMS_GOLDEN_HEAD_APPLE_HELP)); itemStack.setItemMeta(itemMeta); return itemStack; }
Example 6
Source File: AbsorptionModule.java From UHC with MIT License | 5 votes |
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) public void on(PlayerItemConsumeEvent event) { if (isEnabled()) return; if (event.getItem().getType() != Material.GOLDEN_APPLE) return; // schedule on next tick new RemovePotionEffectRunnable(event.getPlayer().getUniqueId(), PotionEffectType.ABSORPTION).runTask(plugin); }
Example 7
Source File: DisableRegenEvent.java From SkyWarsReloaded with GNU General Public License v3.0 | 5 votes |
public DisableRegenEvent(GameMap map, boolean b) { this.gMap = map; this.enabled = b; File dataDirectory = SkyWarsReloaded.get().getDataFolder(); File mapDataDirectory = new File(dataDirectory, "mapsData"); if (!mapDataDirectory.exists() && !mapDataDirectory.mkdirs()) { return; } File mapFile = new File(mapDataDirectory, gMap.getName() + ".yml"); if (mapFile.exists()) { eventName = "DisableRegenEvent"; slot = 18; material = new ItemStack(Material.GOLDEN_APPLE, 1); FileConfiguration fc = YamlConfiguration.loadConfiguration(mapFile); this.min = fc.getInt("events." + eventName + ".minStart"); this.max = fc.getInt("events." + eventName + ".maxStart"); this.length = fc.getInt("events." + eventName + ".length"); this.chance = fc.getInt("events." + eventName + ".chance"); this.title = fc.getString("events." + eventName + ".title"); this.subtitle = fc.getString("events." + eventName + ".subtitle"); this.startMessage = fc.getString("events." + eventName + ".startMessage"); this.endMessage = fc.getString("events." + eventName + ".endMessage"); this.announceEvent = fc.getBoolean("events." + eventName + ".announceTimer"); this.repeatable = fc.getBoolean("events." + eventName + ".repeatable"); } }
Example 8
Source File: BukkitCompat.java From StackMob-3 with GNU General Public License v3.0 | 4 votes |
@Override public boolean checkFood(Entity entity, ItemStack food) { Material type = food.getType(); switch (entity.getType()) { case COW: case SHEEP: case MUSHROOM_COW: return type == Material.WHEAT; case PIG: return (type == Material.CARROT || type == Material.BEETROOT || type == Material.POTATO); case CHICKEN: return type == Material.WHEAT_SEEDS || type == Material.MELON_SEEDS || type == Material.BEETROOT_SEEDS || type == Material.PUMPKIN_SEEDS; case HORSE: return (type == Material.GOLDEN_APPLE || type == Material.GOLDEN_CARROT) && ((Horse)entity).isTamed(); case WOLF: return (type == Material.BEEF || type == Material.CHICKEN || type == Material.COD || type == Material.MUTTON || type == Material.PORKCHOP || type == Material.RABBIT || type == Material.SALMON || type == Material.COOKED_BEEF || type == Material.COOKED_CHICKEN || type == Material.COOKED_COD || type == Material.COOKED_MUTTON || type == Material.COOKED_PORKCHOP || type == Material.COOKED_RABBIT || type == Material.COOKED_SALMON) && ((Wolf) entity).isTamed(); case OCELOT: return (type == Material.SALMON || type == Material.COD || type == Material.PUFFERFISH || type == Material.TROPICAL_FISH) && ((Ocelot) entity).isTamed(); case RABBIT: return type == Material.CARROT || type == Material.GOLDEN_CARROT || type == Material.DANDELION; case LLAMA: return type == Material.HAY_BLOCK; case TURTLE: return type == Material.SEAGRASS; } return false; }
Example 9
Source File: BukkitCompat.java From StackMob-3 with GNU General Public License v3.0 | 4 votes |
@Override public boolean checkFood(Entity entity, ItemStack food) { Material type = food.getType(); switch (entity.getType()) { case COW: case SHEEP: case MUSHROOM_COW: return type == Material.WHEAT; case PIG: return (type == Material.CARROT || type == Material.BEETROOT || type == Material.POTATO); case CHICKEN: return type == Material.WHEAT_SEEDS || type == Material.MELON_SEEDS || type == Material.BEETROOT_SEEDS || type == Material.PUMPKIN_SEEDS; case HORSE: return (type == Material.GOLDEN_APPLE || type == Material.GOLDEN_CARROT) && ((Horse)entity).isTamed(); case WOLF: return (type == Material.BEEF || type == Material.CHICKEN || type == Material.COD || type == Material.MUTTON || type == Material.PORKCHOP || type == Material.RABBIT || type == Material.SALMON || type == Material.COOKED_BEEF || type == Material.COOKED_CHICKEN || type == Material.COOKED_COD || type == Material.COOKED_MUTTON || type == Material.COOKED_PORKCHOP || type == Material.COOKED_RABBIT || type == Material.COOKED_SALMON) && ((Wolf) entity).isTamed(); case OCELOT: return (type == Material.SALMON || type == Material.COD || type == Material.PUFFERFISH || type == Material.TROPICAL_FISH); case RABBIT: return type == Material.CARROT || type == Material.GOLDEN_CARROT || type == Material.DANDELION; case LLAMA: return type == Material.HAY_BLOCK; case TURTLE: return type == Material.SEAGRASS; case PANDA: return type == Material.BAMBOO; case FOX: return type == Material.SWEET_BERRIES; case CAT: return (type == Material.COD || type == Material.SALMON) && ((Cat) entity).isTamed(); } return false; }
Example 10
Source File: EntityLimits.java From askyblock with GNU General Public License v2.0 | 4 votes |
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true) public void onVillagerSpawn(final CreatureSpawnEvent e) { // If not an villager if (!(e.getEntity() instanceof Villager)) { return; } if (DEBUG3) { plugin.getLogger().info("Villager spawn event! " + e.getEventName()); plugin.getLogger().info("Reason:" + e.getSpawnReason().toString()); plugin.getLogger().info("Entity:" + e.getEntityType().toString()); } // Only cover overworld if (!e.getEntity().getWorld().equals(ASkyBlock.getIslandWorld())) { return; } // If there's no limit - leave it if (Settings.villagerLimit <= 0) { return; } // We only care about villagers breeding, being cured or coming from a spawn egg, etc. if (e.getSpawnReason() != SpawnReason.SPAWNER && e.getSpawnReason() != SpawnReason.BREEDING && e.getSpawnReason() != SpawnReason.DISPENSE_EGG && e.getSpawnReason() != SpawnReason.SPAWNER_EGG && e.getSpawnReason() != SpawnReason.CURED) { return; } Island island = plugin.getGrid().getProtectedIslandAt(e.getLocation()); if (island == null || island.getOwner() == null || island.isSpawn()) { // No island, no limit return; } int limit = Settings.villagerLimit * Math.max(1,plugin.getPlayers().getMembers(island.getOwner()).size()); //plugin.getLogger().info("DEBUG: villager limit = " + limit); //long time = System.nanoTime(); int pop = island.getPopulation(); //plugin.getLogger().info("DEBUG: time = " + ((System.nanoTime() - time)*0.000000001)); if (pop >= limit) { plugin.getLogger().warning( "Island at " + island.getCenter().getBlockX() + "," + island.getCenter().getBlockZ() + " hit the island villager limit of " + limit); //plugin.getLogger().info("Stopped villager spawning on island " + island.getCenter()); // Get all players in the area List<Entity> players = e.getEntity().getNearbyEntities(10,10,10); for (Entity player: players) { if (player instanceof Player) { Player p = (Player) player; Util.sendMessage(p, ChatColor.RED + plugin.myLocale(island.getOwner()).villagerLimitError.replace("[number]", String.valueOf(limit))); } } plugin.getMessages().tellTeam(island.getOwner(), ChatColor.RED + plugin.myLocale(island.getOwner()).villagerLimitError.replace("[number]", String.valueOf(limit))); if (e.getSpawnReason().equals(SpawnReason.CURED)) { // Easter Egg. Or should I say Easter Apple? ItemStack goldenApple = new ItemStack(Material.GOLDEN_APPLE); // Nerfed //goldenApple.setDurability((short)1); e.getLocation().getWorld().dropItemNaturally(e.getLocation(), goldenApple); } e.setCancelled(true); } }
Example 11
Source File: GoldenHeadsModule.java From UHC with MIT License | 3 votes |
public boolean isGoldenHead(ItemStack itemStack) { if (itemStack.getType() != Material.GOLDEN_APPLE) return false; final ItemMeta im = itemStack.getItemMeta(); return im.hasDisplayName() && im.getDisplayName().equals(HEAD_NAME); }