So i don't know to edit the title but i figured it out, this stupid method was removing the ground items when i loaded the map from my a teleport.
Code:
public void refreshSpawnedItems() {
for (int regionId : getMapRegionsIds()) {
List<FloorItem> floorItems = World.getRegion(regionId).getFloorItems();
if (floorItems == null)
continue;
for (FloorItem item : floorItems) {
sendMessage("test1");
if ((item.isInvisible() || item.isGrave()) && this != item.getOwner() || item.getTile().getPlane() != getPlane())
continue;
//getPackets().sendRemoveGroundItem(item); debugging as an awful thing (commenting this line out fixed it)
getPackets().sendGroundItem(item);
}
}
}
So whenever one of my players dies, if their inventory contain's more than one of an item that isn't stack-able say like dragon scim for example, only one of the item will drop on the floor, but if they player is in the same region as the re spawn location is set to, all of the items will appear on the floor. Any help would be much appreciated. If the player only has one of the item everything works perfectly as well as if the item is stack-able all of the stack will be on the floor on the death tile.
sendItemsOnDeath Method
Code:
public void sendItemsOnDeath(Player killer) {
//if (rights == 2)
// return;
WorldTile tile = new WorldTile(getX(), getY(), getPlane());
charges.die();
auraManager.removeAura();
CopyOnWriteArrayList<Item> containedItems = new CopyOnWriteArrayList<Item>();
for (int i = 0; i < 14; i++) {
if (equipment.getItem(i) != null
&& equipment.getItem(i).getId() != -1
&& equipment.getItem(i).getAmount() != -1)
containedItems.add(new Item(equipment.getItem(i).getId(),
equipment.getItem(i).getAmount()));
}
for (int i = 0; i < 28; i++) {
if (inventory.getItem(i) != null
&& inventory.getItem(i).getId() != -1
&& inventory.getItem(i).getAmount() != -1)
containedItems.add(new Item(getInventory().getItem(i).getId(),
getInventory().getItem(i).getAmount()));
}
if (containedItems.isEmpty())
return;
int keptAmount = 0;
if(!(controlerManager.getControler() instanceof CrucibleControler)) {
keptAmount = hasSkull() ? 0 : 3;
if (prayer.usingPrayer(0, 10) || prayer.usingPrayer(1, 0))
keptAmount++;
}
CopyOnWriteArrayList<Item> keptItems = new CopyOnWriteArrayList<Item>();
Item lastItem = new Item(1, 1);
for (int i = 0; i < keptAmount; i++) {
for (Item item : containedItems) {
int price = item.getDefinitions().getValue();
if (price >= lastItem.getDefinitions().getValue()) {
lastItem = item;
}
}
keptItems.add(lastItem);
containedItems.remove(lastItem);
lastItem = new Item(1, 1);
}
inventory.reset();
equipment.reset();
for (Item item : keptItems) {
getInventory().addItem(item);
}
for (Item item : containedItems) {
FloorItemManager.addGroundItem(item, tile, killer == null ? this : killer, false, 20, true, 30);
}
}
addGround Item
Code:
public static final void addGroundItem(final Item item, final WorldTile tile, final Player owner, final boolean underGrave, long hiddenTime, boolean invisible, final int publicTime) {
final FloorItem floorItem = new FloorItem(item, tile, owner, owner == null ? false : underGrave, invisible);
final Region region = World.getRegion(tile.getRegionId());
region.forceGetFloorItems().add(floorItem);
if (invisible && hiddenTime != -1) {
if (owner != null)
owner.getPackets().sendGroundItem(floorItem);
FloorItemTask task = new FloorItemTask(floorItem, tile, region, owner, underGrave, publicTime);
GameEngine.get().slowExecutor().schedule(task, hiddenTime, TimeUnit.SECONDS);
return;
}
int regionId = tile.getRegionId();
for (Player player : World.getPlayers()) {
if (player == null || !player.hasStarted() || player.hasFinished() || player.getPlane() != tile.getPlane() || !player.getMapRegionsIds().contains(regionId))
continue;
player.getPackets().sendGroundItem(floorItem);
}
removeGroundItem(floorItem, publicTime);
}