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 newEntityDrop(GroundItem item) { lock(items) { items.Add(item); } if (item.getOwner() != null && !item.getOwner().isDestroyed()) { item.getOwner().getPackets().createGroundItem(item); } Event showItemDropGloballyEvent = new Event(60000); //60 seconds to show dropped item to all players. showItemDropGloballyEvent.setAction(() => { newGlobalItem(item); showItemDropGloballyEvent.stop(); }); Server.registerEvent(showItemDropGloballyEvent); }
public void createGroundItem2(GroundItem item) { if (item != null) { sendCoords(item.getLocation()); connection.SendPacket(new PacketBuilder().setId(135) .addUShortA(item.getOwner().getIndex()) .addByteC((byte)0) .addLEShort(item.getItemAmount()) .addLEShort(item.getItemId()).toPacket()); } }