Rewrote pet management

Fixed being unable to remove pets
Removed redundant pet messaging
This commit is contained in:
Player Name
2023-10-04 23:19:57 +00:00
committed by Ryan
parent e5afeed6db
commit 7c38339e16
6 changed files with 175 additions and 114 deletions
@@ -866,6 +866,21 @@ public class Container {
return null;
}
/**
* Gets all instances of an item, and returns them.
* @author Player Name
* @param item the item.
* @return a list of all items that were found (can be length 0).
*/
public ArrayList<Item> getAll(Item item){
ArrayList<Item> ret = new ArrayList<Item>();
for(Item i : items){
if(i == null) continue;
if(item.getId() == i.getId()) ret.add(i);
}
return ret;
}
/**
* Gets the next free slot.
*
@@ -279,12 +279,11 @@ class PlayerSaver (val player: Player){
detail.put("petId",it.key.toString())
detail.put("hunger",it.value.hunger.toString())
detail.put("growth",it.value.growth.toString())
detail.put("stage",it.value.stage.toString())
petDetails.add(detail)
}
familiarManager.put("petDetails",petDetails)
if(player.familiarManager.hasPet()){
familiarManager.put("currentPet",(player.familiarManager.familiar as Pet).pet.babyItemId.toString())
familiarManager.put("currentPet",(player.familiarManager.familiar as Pet).getItemIdHash().toString())
} else if (player.familiarManager.hasFamiliar()){
val familiar = JSONObject()
familiar.put("originalId",player.familiarManager.familiar.originalId.toString())