private void newGlobalItem(GroundItem item) { if (item == null) { return; } item = itemExists(item); if (item != null) { item.setGlobal(true); foreach(Player p in Server.getPlayerList()) { if (p == null || (item.getDefinition().isPlayerBound() && !item.getOwner().Equals(p))) { continue; } if (p.getLocation().withinDistance(item.getLocation(), 60)) { if(item.getOwner() != null) { p.getPackets().createGroundItem2(item); } else { p.getPackets().createGroundItem(item); } } } if (!item.getDefinition().isPlayerBound()) { item.setOwner(null); } GroundItem i = item; if (!item.isRespawn()) { Event removeGlobalItemEvent = new Event(60000); removeGlobalItemEvent.setAction(() => { clearGlobalItem(i); removeGlobalItemEvent.stop(); }); Server.registerEvent(removeGlobalItemEvent); } } }
public void pickupItem(Player p, int id, Location location) { GroundItem item = itemExists(location, id); if (item != null && p.getSprites().getPrimarySprite() == -1 && p.getSprites().getSecondarySprite() == -1) { if (item.getDefinition().isPlayerBound() && !item.getOwner().Equals(p)) { return; } if (!p.getInventory().addItem(item.getItemId(), item.getItemAmount())) { return; } clearGlobalItem(item); if (item.isRespawn()) { GroundItem i = item; Event itemRespawnEvent = new Event(60000); itemRespawnEvent.setAction(() => { GroundItem respawn = new GroundItem(i.getItemId(), i.getItemAmount(), i.getLocation(), null); respawn.setRespawn(true); respawn.setGlobal(true); newGlobalItem(respawn); itemRespawnEvent.stop(); }); } } }