RuneHive-Game
Loading...
Searching...
No Matches
FillBirdhouse.java
Go to the documentation of this file.
1package com.runehive.content.skill.impl.hunter.birdhouse.action;
2
3import com.runehive.content.skill.impl.hunter.birdhouse.PlayerBirdHouseData;
4import com.runehive.game.action.Action;
5import com.runehive.game.action.policy.WalkablePolicy;
6import com.runehive.game.task.impl.PlayerSaveEvent;
7import com.runehive.game.world.entity.mob.player.Player;
8import com.runehive.game.world.entity.mob.player.persist.PlayerSerializer;
9import com.runehive.game.world.items.Item;
10import com.runehive.game.world.object.CustomGameObject;
11import com.runehive.game.world.object.ObjectDirection;
12import com.runehive.game.world.object.ObjectType;
13import com.runehive.net.packet.out.SendAddObject;
14
15public class FillBirdhouse extends Action<Player> {
16
18 private Item itemUsed;
19 private int itemAmount;
21 super(player, 1);
22 this.playerBirdHouseData = playerBirdHouseData;
23 this.itemUsed = itemUsed;
24 this.itemAmount = itemAmount;
25 }
26
27 @Override
31
32 @Override
33 public String getName() {
34 return "Fill birdhouse";
35 }
36
37 @Override
38 protected void execute() {
39 getMob().inventory.remove(new Item(itemUsed.getId(), itemAmount));
40 getMob().inventory.refresh();
41
42 if(itemAmount >= 10 || playerBirdHouseData.seedAmount + itemAmount >= 10) {
43 getMob().dialogueFactory.sendStatement("Your birdhouse trap is now full of seed and will start to catch birds").execute();
44 getMob().message("Your birdhouse trap is now full of seed and will start to catch birds");
45
46 playerBirdHouseData.seedAmount += itemAmount;
47 playerBirdHouseData.birdhouseTimer = System.currentTimeMillis() + 3_300_000;
48 getMob().send(new SendAddObject(new CustomGameObject(playerBirdHouseData.birdhouseData.objectData[playerBirdHouseData.seedAmount >= 10 ? 1 : 0], playerBirdHouseData.birdhousePosition, ObjectDirection.valueOf(playerBirdHouseData.rotation).get(), ObjectType.valueOf(playerBirdHouseData.type).get())));
49 } else {
50 getMob().dialogueFactory.sendStatement("You add " + itemAmount + " x " + itemUsed.getDefinition().getName().toLowerCase() + " to the birdhouse.").execute();
51 getMob().message("You add " + itemAmount + " x " + itemUsed.getDefinition().getName().toLowerCase() + " to the birdhouse.");
52
53 playerBirdHouseData.seedAmount += itemAmount;
54 }
55
57 getMob().action.getCurrentAction().cancel();
58 }
59
60}
WalkablePolicy getWalkablePolicy()
Gets the WalkablePolicy of this action.
void execute()
A function representing the unit of work that will be carried out.
FillBirdhouse(Player player, PlayerBirdHouseData playerBirdHouseData, Item itemUsed, int itemAmount)
T getMob()
Gets the player.
Definition Action.java:44
Action(T mob, int delay, boolean instant)
Creates a new Action randomevent.
Definition Action.java:24
This class represents a character controlled by a player.
Definition Player.java:125
The container class that represents an item that can be interacted with.
Definition Item.java:21
Represents a static game object loaded from the map fs.
A queue policy determines whether the action can occur while walking.
WALKABLE
This indicates actions may occur while walking.
The enumerated type whose elements represent the directions for objects.
static Optional< ObjectDirection > valueOf(final int id)
Returns a ObjectDirection wrapped in an Optional for the specified id.
The enumerated type whose elements represent all of the object types.
static Optional< ObjectType > valueOf(final int id)
Returns a ObjectType wrapped in an Optional for the specified id.