RuneHive-Game
Loading...
Searching...
No Matches
HunterRespawnTask.java
Go to the documentation of this file.
1package com.runehive.game.action.impl;
2
3import com.runehive.content.skill.impl.hunter.net.impl.Butterfly;
4import com.runehive.content.skill.impl.hunter.net.impl.Impling;
5import com.runehive.game.task.Task;
6import com.runehive.game.world.entity.mob.npc.Npc;
7
8import java.util.Optional;
9
10/**
11 * Teleports an entity to another part of the world.
12 *
13 * @author Daniel
14 */
15public final class HunterRespawnTask extends Task {
16 public final Npc npc;
17
19 super(false, 80);
20 this.npc = npc;
21 }
22
23 @Override
24 protected void onSchedule() {
25 Optional<Impling> impling = Impling.forId(npc.id);
26 Optional<Butterfly> butterfly = Butterfly.forId(npc.id);
27
28 if (impling.isPresent()) {
29 setDelay(impling.get().delay);
30 } else butterfly.ifPresent(butterfly1 -> setDelay(butterfly1.delay));
31
32 npc.resetFace();
33 npc.setVisible(false);
34 }
35
36 @Override
37 public void execute() {
38 npc.setVisible(true);
39 cancel();
40 }
41}
void onSchedule()
A function executed on registration.
void execute()
A function representing the unit of work that will be carried out.
synchronized final void cancel()
Cancels all subsequent executions.
Definition Task.java:113
Task(boolean instant, int delay)
Creates a new Task.
Definition Task.java:41
void setDelay(int delay)
Sets the cyclic delay.
Definition Task.java:164
Represents a non-player character in the in-game world.
Definition Npc.java:29
static Optional< Butterfly > forId(int butterfly)
static Optional< Impling > forId(int impling)
Definition Impling.java:38