1package com.runehive.content.pet;
3import com.runehive.content.achievement.AchievementHandler;
4import com.runehive.content.achievement.AchievementKey;
5import com.runehive.content.collectionlog.CollectionLog;
6import com.runehive.content.collectionlog.CollectionLogData;
7import com.runehive.game.Animation;
8import com.runehive.game.task.Task;
9import com.runehive.game.world.World;
10import com.runehive.game.world.entity.mob.npc.Npc;
11import com.runehive.game.world.entity.mob.player.Player;
12import com.runehive.game.world.items.Item;
13import com.runehive.game.world.position.Position;
14import com.runehive.net.packet.out.SendMessage;
15import com.runehive.net.packet.out.SendScrollbar;
16import com.runehive.net.packet.out.SendString;
17import com.runehive.util.MessageColor;
18import com.runehive.util.Utility;
72 player.
send(
new SendMessage(
"<col=FF0000>You have a funny feeling like you would've been followed."));
76 if (player.
pet ==
null && position !=
null) {
94 if (player.
pet !=
null) {
99 if (position ==
null) {
100 player.
send(
new SendMessage(
"You cannot drop your pet from your current location!"));
108 player.
face(position);
114 pet.interact(player);
120 player.
message(
"<col=FF0000>You have a funny feeling like you're being followed.");
130 if (!
pet.isPresent()) {
143 Map<PetData, Boolean> lostPets =
new HashMap<>();
144 if (player.
pet !=
null) {
146 petData.ifPresent(
pet -> {
147 lostPets.put(
pet,
true);
153 petData.ifPresent(
pet -> {
154 lostPets.put(
pet,
false);
158 for (
PetData pets : lostPets.keySet()) {
162 if (lostPets.get(pets)) {
166 player.
message(
"You have lost your pet, luckily you insured it! Speak to the insurance agent to claim.");
169 if (lostPets.get(pets)) {
177 player.
send(
new SendMessage(
"Your " + pets.getName() +
" has disappeared forever! Make sure to insure it!"));
189 protected void onSchedule() {
195 protected void execute() {
209 protected void onCancel(
boolean logout) {
218 if (player.
pet !=
null) {
225 if (player.
pet !=
null) {
240 if (!petData.isPresent()) {
263 int cost = player.
lostPets.size() * 250_000;
280 int size =
PetData.values().length;
281 for (
int index = 0,
string = 37115; index < size; index++) {
285 player.
send(
new SendString(
"<col=000000>This is a list of all pets that are allowed to be insured", 37111));
287 player.
send(
new SendString(
"<col=000000>Red = <col=F24444>Un-insured<col=000000> | Green = <col=347043>Insured", 37113));
297 List<PetData> pets =
new ArrayList<>();
299 int size = pets.size() < 7 ? 7 : pets.size();
300 for (
int index = 0,
string = 37115; index < size; index++) {
301 boolean valid = !pets.isEmpty() && index < pets.size();
305 int cost = player.
lostPets.size() * 250_000;
306 player.
send(
new SendString(
"<col=000000>This is a list of all pets available to be claimed", 37111));
309 player.
send(
new SendString(pets.isEmpty() ?
"You have no pets to collect!" :
"", 37114));
Handles the achievements.
static void activate(Player player, AchievementKey achievement)
Activates the achievement for the individual player.
static void logItem(Player player, CollectionLogData data, int item, int amount)
final DialogueFactory execute()
Retrieves the next dialogue in the chain and executes it.
final DialogueFactory sendNpcChat(int id, String... lines)
Appends an NpcDialogue to the current dialogue chain.
Handles spawning, rewarding and picking up of pets.
static void openInsurance(Player player)
Handles opening the insurance interface.
static Task abandon(Npc npc)
The pet abandon task.
static void onObtain(Player player, int item)
Handles a player receiving a pet onReward.
static boolean onReward(Player player, PetData pet)
Generates a unique equation for special defined pets.
static boolean onSpawn(Player player, int item, boolean drop)
Handles spawning a pet.
static void onDeath(Player player)
Handles what happens to a pet when a player dies.
static void claimLostPets(Player player)
Claims all the lost pets.
static boolean hasInsurance(Player player, PetData pet)
Checks if player already has insurance for a pet.
static void openLostPets(Player player)
Handles opening the insurance interface.
static final int INSRUANCE_COST
The cost of insuring a pet.
static boolean dialogue(Player player, Npc npc)
Handles speaking to a pet.
static void buyInsurance(Player player, Item item)
Handles purchasing insurance for a pet.
static void onReward(Player player, int item)
Handles rewarding with a 100% a chance.
static void onLogin(Player player)
Handles what happens to a pet when a player logs in.
static void onReward(Player player, int item, int chance)
Handles calculating the chance of a player receiving a skilling pet.
static void onLogout(Player player)
Handles what happens to a pet when a player logouts.
Class that models a single animation used by an entity.
A game representing a cyclic unit of work.
Represents the game world.
static void schedule(Task task)
Submits a new event.
static void sendMessage(String... messages)
Sends a global message.
abstract boolean equals(Object obj)
void interact(Mob mob)
Sets the mob interacting with another mob.
final void resetWaypoint()
Resets the waypoint.
void animate(int animation)
void face(GameObject object)
Sets the client update flag to face a certain direction.
void resetFace()
Resets the mob's face location.
boolean isMoving
Mob is moving.
Represents a non-player character in the in-game world.
String getName()
Gets the name of this entity.
void register()
Registers an entity to the World.
void unregister()
Unregisters an entity from the World.
void open(int identification)
Opens an interface for the player.
This class represents a character controlled by a player.
final Inventory inventory
void message(String message)
String getName()
Gets the name of this entity.
DialogueFactory dialogueFactory
Set< PetData > petInsurance
final InterfaceManager interfaceManager
void send(OutgoingPacket encoder)
The container class that represents an item that can be interacted with.
final int getId()
Gets the identification of this item.
boolean remove(Item item)
Attempts to withdraw item from this container.
boolean add(Item item)
Attempts to deposit item into this container.
final boolean hasCapacityFor(Item... item)
Determines if this container has the capacity for item.
boolean contains(int id)
Determines if this container contains id.
Represents a single tile on the game world.
Position transform(int diffX, int diffY, int diffZ)
Creates a new location based on this location.
The OutgoingPacket that sends a message to a Players chatbox in the client.
The OutgoingPacket that sends a string to a Players itemcontainer in the client.
Handles miscellaneous methods.
static int random(int bound)
static Position findAccessableTile(Interactable source)
static String formatDigits(final int amount)
Formats digits for integers.
static< T > T randomElement(Collection< T > collection)
Picks a random element out of any array type.
static Position[] getInnerBoundaries(Position position, int width, int length)
static Optional< PetData > forOrdinal(int ordinal)
Gets the pet data based on the given ordinal.
static Optional< PetData > forNpc(int id)
Gets the pet data based on the given npc identification.
static Optional< PetData > forItem(int id)
Gets the pet data based on the given item identification.
int getNpc()
Gets the npc identification of the pet.
static String getColor(PlayerRight right)
Holds an enum of colors for ease.