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 clearGroundItem(GroundItem item) { if (item != null) { sendCoords(item.getLocation()); connection.SendPacket(new PacketBuilder().setId(240) .addByte((byte)0) .addUShort(item.getItemId()).toPacket()); } }
public void clearGlobalItem(GroundItem item) { lock(items) { items.Remove(item); } if(item != null) { foreach(Player p in Server.getPlayerList()) { if (p == null) { continue; } if (p.getLocation().withinDistance(item.getLocation(), 60)) { p.getPackets().clearGroundItem(item); } } } }
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()); } }