Java Code Examples for org.bukkit.entity.Item#setPickupDelay()
The following examples show how to use
org.bukkit.entity.Item#setPickupDelay() .
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: RealDisplayItem.java From QuickShop-Reremake with GNU General Public License v3.0 | 6 votes |
@Override public void safeGuard(@NotNull Entity entity) { if (!(entity instanceof Item)) { Util.debugLog("Failed to safeGuard " + entity.getLocation() + ", cause target not a Item"); return; } Item item = (Item) entity; // Set item protect in the armorstand's hand if (plugin.getConfig().getBoolean("shop.display-item-use-name")) { item.setCustomName(Util.getItemStackName(this.originalItemStack)); item.setCustomNameVisible(true); } else { item.setCustomNameVisible(false); } item.setPickupDelay(Integer.MAX_VALUE); item.setSilent(true); item.setPortalCooldown(Integer.MAX_VALUE); item.setVelocity(new Vector(0, 0.1, 0)); }
Example 2
Source File: Scorpio.java From AnnihilationPro with MIT License | 6 votes |
@EventHandler(priority = EventPriority.HIGHEST) public void specialItemActionCheck(final PlayerInteractEvent event) { if(event.getAction() == Action.RIGHT_CLICK_AIR || event.getAction() == Action.RIGHT_CLICK_BLOCK) { Player player = event.getPlayer(); AnniPlayer pl = AnniPlayer.getPlayer(player.getUniqueId()); if(pl != null && pl.getKit().equals(this)) { if(this.isHookItem(player.getItemInHand())) { if(!Delays.getInstance().hasActiveDelay(player, this.getInternalName())) { Delays.getInstance().addDelay(player, System.currentTimeMillis()+5000, this.getInternalName());//kits.addDelay(player.getName(), DelayType.SCORPIO, 10, TimeUnit.SECONDS); Item item = player.getWorld().dropItem(player.getEyeLocation(), new ItemStack(Material.NETHER_STAR,1)); item.setPickupDelay(Integer.MAX_VALUE); item.setVelocity(player.getEyeLocation().getDirection().multiply(2)); Bukkit.getScheduler().scheduleSyncDelayedTask(AnnihilationMain.getInstance(), new HookTracer(item,pl,90,this.getName()), 1); } } } } }
Example 3
Source File: Grenade.java From QualityArmory with GNU General Public License v3.0 | 5 votes |
@SuppressWarnings("deprecation") @Override public boolean onRMB(Player thrower, ItemStack usedItem) { if (throwItems.containsKey(thrower)) { ThrowableHolder holder = throwItems.get(thrower); ItemStack grenadeStack = thrower.getItemInHand(); ItemStack temp = grenadeStack.clone(); temp.setAmount(1); if (thrower.getGameMode() != GameMode.CREATIVE) { if (grenadeStack.getAmount() > 1) { grenadeStack.setAmount(grenadeStack.getAmount() - 1); } else { grenadeStack = null; } thrower.setItemInHand(grenadeStack); } Item grenade = holder.getHolder().getWorld().dropItem(holder.getHolder().getLocation().add(0, 1.5, 0), temp); grenade.setPickupDelay(Integer.MAX_VALUE); grenade.setVelocity(thrower.getLocation().getDirection().normalize().multiply(1.2)); holder.setHolder(grenade); thrower.getWorld().playSound(thrower.getLocation(), Sound.ENTITY_ARROW_SHOOT, 1, 1.5f); throwItems.put(grenade, holder); throwItems.remove(thrower); QAMain.DEBUG("Throw grenade"); } else { thrower.sendMessage(QAMain.prefix + QAMain.S_GRENADE_PULLPIN); } return true; }
Example 4
Source File: MajorPowerPowerStance.java From EliteMobs with GNU General Public License v3.0 | 5 votes |
private Object addEffect(Material material) { Item item = eliteMobEntity.getLivingEntity().getWorld().dropItem(eliteMobEntity.getLivingEntity().getLocation(), new ItemStack(material)); item.setPickupDelay(Integer.MAX_VALUE); if (!VersionChecker.currentVersionIsUnder(1, 11)) item.setGravity(false); item.setInvulnerable(true); EntityTracker.registerItemVisualEffects(item); return item; }
Example 5
Source File: VisualItemInitializer.java From EliteMobs with GNU General Public License v3.0 | 5 votes |
public static Item intializeItem(ItemStack itemStack, Location location) { Item item = location.getWorld().dropItem(location, itemStack); item.setPickupDelay(Integer.MAX_VALUE); EntityTracker.registerItemVisualEffects(item); if (!VersionChecker.currentVersionIsUnder(1, 11)) item.setGravity(false); item.setInvulnerable(true); return item; }
Example 6
Source File: MinorPowerPowerStance.java From EliteMobs with GNU General Public License v3.0 | 5 votes |
private Object addEffect(Material material) { Item item = eliteMobEntity.getLivingEntity().getWorld().dropItem(eliteMobEntity.getLivingEntity().getLocation(), new ItemStack(material)); item.setPickupDelay(Integer.MAX_VALUE); if (!VersionChecker.currentVersionIsUnder(1, 11)) item.setGravity(false); item.setInvulnerable(true); EntityTracker.registerItemVisualEffects(item); return item; }
Example 7
Source File: ResourceSpawner.java From BedwarsRel with GNU General Public License v3.0 | 5 votes |
public void dropItem(Location dropLocation, ItemStack itemStack) { Item item = this.game.getRegion().getWorld().dropItemNaturally(dropLocation, itemStack); item.setPickupDelay(0); if (this.spread != 1.0) { item.setVelocity(item.getVelocity().multiply(this.spread)); } }
Example 8
Source File: GenericBomb.java From NBTEditor with GNU General Public License v3.0 | 5 votes |
private void trigger(final Item item) { item.setPickupDelay(Integer.MAX_VALUE); onTrigger(item); Bukkit.getScheduler().runTaskLater(getPlugin(), new Runnable() { @Override public void run() { if (!item.isDead()) { onExplode(item, item.getLocation()); item.remove(); } } }, _fuse); }
Example 9
Source File: QuadCrate.java From Crazy-Crates with MIT License | 4 votes |
@EventHandler public void onChestClick(PlayerInteractEvent e) { Player player = e.getPlayer(); if (QuadCrateSession.inSession(player)) { QuadCrateSession session = QuadCrateSession.getSession(player); if (e.getAction() == Action.RIGHT_CLICK_BLOCK || e.getAction() == Action.LEFT_CLICK_BLOCK) { Block block = e.getClickedBlock(); if (session.getChestLocations().contains(block.getLocation())) { e.setCancelled(true); if (!session.hasChestBeenOpened(block.getLocation())) { nms.openChest(block, true); Crate crate = session.getCrate(); Prize prize = crate.pickPrize(player, block.getLocation().add(.5, 1.3, .5)); cc.givePrize(player, prize); ItemBuilder itemBuilder = ItemBuilder.convertItemStack(prize.getDisplayItem()); itemBuilder.addLore(new Random().nextInt(Integer.MAX_VALUE) + "");//Makes sure items don't merge ItemStack item = itemBuilder.build(); NBTItem nbtItem = new NBTItem(item); nbtItem.setBoolean("crazycrates-item", true); item = nbtItem.getItem(); Item reward = player.getWorld().dropItem(block.getLocation().add(.5, 1, .5), item); reward.setMetadata("betterdrops_ignore", new FixedMetadataValue(cc.getPlugin(), true)); reward.setVelocity(new Vector(0, .2, 0)); reward.setCustomName(prize.getDisplayItem().getItemMeta().getDisplayName()); reward.setCustomNameVisible(true); reward.setPickupDelay(Integer.MAX_VALUE); session.getDisplayedRewards().add(reward); session.setChestOpened(block.getLocation(), true); if (session.allChestsOpened()) {//All 4 crates have been opened new BukkitRunnable() { @Override public void run() { session.endCrate(); player.playSound(player.getLocation(), cc.getSound("BLOCK_STONE_STEP", "STEP_STONE"), 1, 1); } }.runTaskLater(cc.getPlugin(), 60); } } } } } }
Example 10
Source File: GrapplingHookEntity.java From Slimefun4 with GNU General Public License v3.0 | 4 votes |
public void drop(Location l) { if (dropItem) { Item item = l.getWorld().dropItem(l, SlimefunItems.GRAPPLING_HOOK.clone()); item.setPickupDelay(16); } }
Example 11
Source File: GenericBomb.java From NBTEditor with GNU General Public License v3.0 | 4 votes |
private Item createItem(Location loc, Vector vel) { Item item = loc.getWorld().dropItem(loc, getItem()); item.setVelocity(vel); item.setPickupDelay(Integer.MAX_VALUE); return item; }