RuneHive-Game
Loading...
Searching...
No Matches
com.runehive.game.task.Task Class Referenceabstract

A game representing a cyclic unit of work. More...

Inheritance diagram for com.runehive.game.task.Task:

Public Member Functions

Task attach (Object newKey)
 Attaches a new key.
synchronized final void cancel ()
 Cancels all subsequent executions.
synchronized final void cancel (boolean logout)
 Cancels all subsequent executions.
boolean canRun ()
 Determines if the task can be ran.
Optional< Object > getAttachment ()
String getCreationStackTraceStr ()
int getDelay ()
Long getElapsedTimeFromRunStartTime ()
Optional< Long > getRunStartTime ()
long getTaskCreationTime ()
String getTaskId ()
boolean isInstant ()
boolean isRunning ()
void setDelay (int delay)
 Sets the cyclic delay.
void setExecutionTime ()
 Task (boolean instant, int delay)
 Creates a new Task.
 Task (int delay)
 Creates a new Task that doesn't execute instantly.

Protected Member Functions

void baseExecute ()
boolean canSchedule ()
 A function executed on registration.
abstract void execute ()
 A function representing the unit of work that will be carried out.
void onCancel (boolean logout)
 A function executed on cancellation.
void onSchedule ()
 A function executed on registration.

Package Functions

void onException (Exception e)
 A function executed on thrown exceptions.
void onLoop ()
 A function executed when iterated over.
final synchronized void process ()
synchronized void setRunning (boolean running)

Private Attributes

int counter
 A counter that determines when execution should take place.
StackTraceElement[] creationStackTrace
 The creation stack trace because jire likes to guess.
int delay
 The cyclic delay.
final boolean instant
 If execution happens instantly upon being scheduled.
Optional< Object > key = Optional.empty()
 An optional attachment.
boolean running
 If registration has taken place.
Optional< Long > runStartTime = Optional.empty()
 The time the task started task.run(), if null the task has not ran yet.
final long taskCreationTime
 The time the task was created.
final UUID uuid
 Unique task UUID which helps us identify if any tasks will lock up.

Detailed Description

A game representing a cyclic unit of work.

Author
lare96 http://github.org/lare96

Definition at line 11 of file Task.java.

Constructor & Destructor Documentation

◆ Task() [1/2]

com.runehive.game.task.Task.Task ( boolean instant,
int delay )

Creates a new Task.

Definition at line 41 of file Task.java.

41 {
42 if (delay <= 0) {
43 instant = true;
44 delay = 1;
45 }
46 this.instant = instant;
47 this.delay = delay;
48 this.creationStackTrace = Thread.currentThread().getStackTrace();
49 this.uuid = UUID.randomUUID();
50 this.taskCreationTime = System.currentTimeMillis();
51 }

References delay, and instant.

Referenced by attach(), com.runehive.content.skill.impl.firemaking.FiremakingAction.onDestruct(), and com.runehive.content.activity.inferno.InfernoBoss.spawnbosswave().

Here is the caller graph for this function:

◆ Task() [2/2]

com.runehive.game.task.Task.Task ( int delay)

Creates a new Task that doesn't execute instantly.

Definition at line 58 of file Task.java.

58 {
59 this(false, delay);
60 }

References delay.

Member Function Documentation

◆ attach()

Task com.runehive.game.task.Task.attach ( Object newKey)

Attaches a new key.

Definition at line 148 of file Task.java.

148 {
149 key = Optional.ofNullable(newKey);
150 return this;
151 }

References key, and Task().

Referenced by com.runehive.game.task.impl.WarriorGuildCyclopEvent.WarriorGuildCyclopEvent().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ baseExecute()

void com.runehive.game.task.Task.baseExecute ( )
protected

Definition at line 99 of file Task.java.

99 {
100 setExecutionTime();
101 execute();
102 }

References execute(), and setExecutionTime().

Referenced by process().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ cancel() [1/2]

synchronized final void com.runehive.game.task.Task.cancel ( )

Cancels all subsequent executions.

Does nothing if already cancelled.

Definition at line 113 of file Task.java.

113 {
114 if (running) {
115 onCancel(false);
116 running = false;
117 }
118 }

References onCancel(), and running.

Referenced by com.runehive.game.world.items.ground.GroundItem.addToRegion(), com.runehive.content.ai.LazyAIManager.cancelInactivityTimer(), com.runehive.game.action.ActionManager.cancelQueuedActions(), com.runehive.content.skill.impl.woodcutting.WoodcuttingAction.chop(), com.runehive.content.combat.cannon.CannonFireAction.execute(), com.runehive.content.shootingstar.ShootingStarAction.execute(), com.runehive.content.skill.impl.fishing.FishingAction.execute(), com.runehive.content.skill.impl.hunter.net.Netting.execute(), com.runehive.content.skill.impl.hunter.net.PuroPuroAction.execute(), com.runehive.content.skill.impl.mining.MiningAction.execute(), com.runehive.content.skill.impl.smithing.Smelting.execute(), com.runehive.content.skill.impl.thieving.PickpocketAction.execute(), com.runehive.content.skill.impl.woodcutting.WoodcuttingAction.execute(), com.runehive.content.skill.SkillAction.execute(), com.runehive.game.action.impl.ChestAction.execute(), com.runehive.game.action.impl.DebugAction.execute(), com.runehive.game.action.impl.DoorAction.execute(), com.runehive.game.action.impl.EmoteAction.execute(), com.runehive.game.action.impl.FlaxPickingAction.execute(), com.runehive.game.action.impl.HunterRespawnTask.execute(), com.runehive.game.action.impl.InspectAction.execute(), com.runehive.game.action.impl.LadderAction.execute(), com.runehive.game.action.impl.LeverAction.execute(), com.runehive.game.action.impl.NpcFaceAction.execute(), com.runehive.game.action.impl.RevShortcutAction.execute(), com.runehive.game.action.impl.SpadeAction.execute(), com.runehive.game.action.impl.SpellAction.execute(), com.runehive.game.task.impl.AntiVenomTask.execute(), com.runehive.game.task.impl.ChopVineTask.execute(), com.runehive.game.task.impl.DoubleExperienceEvent.execute(), com.runehive.game.task.impl.DuelNotificationTask.execute(), com.runehive.game.task.impl.ForceChatEvent.execute(), com.runehive.game.task.impl.ForceMovementTask.execute(), com.runehive.game.task.impl.HunterTask.execute(), com.runehive.game.task.impl.ObjectPlacementEvent.execute(), com.runehive.game.task.impl.ObjectReplacementEvent.execute(), com.runehive.game.task.impl.PvPTimerTask.execute(), com.runehive.game.task.impl.SessionRemovalNotificationTask.execute(), com.runehive.game.task.impl.SuperAntipoisonTask.execute(), com.runehive.game.task.impl.TeleblockTask.execute(), com.runehive.game.task.impl.WarriorGuildCyclopEvent.execute(), com.runehive.game.world.entity.combat.effect.CombatEffectTask.execute(), com.runehive.game.world.entity.mob.MobDeath< T extends Mob >.execute(), com.runehive.game.world.items.ground.GroundItemEvent.execute(), com.runehive.game.world.entity.mob.movement.waypoint.Waypoint.findRoute(), com.runehive.content.skill.impl.mining.MiningAction.mine(), com.runehive.game.action.impl.NpcFaceAction.NpcFaceAction(), com.runehive.game.world.entity.mob.movement.waypoint.PickupWaypoint.onDestination(), com.runehive.game.world.entity.mob.movement.waypoint.WalkToWaypoint.onDestination(), com.runehive.content.skill.impl.firemaking.FiremakingAction.onDestruct(), com.runehive.content.skill.impl.DestructionSkillAction.onExecute(), com.runehive.game.action.impl.BuryBoneAction.onExecute(), com.runehive.game.action.impl.ScatterAshAction.onExecute(), com.runehive.content.skill.impl.smithing.SmithingArmour.onProduce(), com.runehive.content.skill.SkillAction.onSchedule(), com.runehive.game.task.impl.ChopVineTask.onSchedule(), com.runehive.game.task.impl.SteppingStoneTask.onSchedule(), com.runehive.game.world.items.ground.GroundItem.pickup(), com.runehive.content.gambling.impl.FlowerPoker.plant(), com.runehive.content.ai.LazyAIManager.shutdown(), com.runehive.content.skill.impl.smithing.Smelting.smelt(), com.runehive.content.combat.cannon.CannonBuild.tick(), com.runehive.content.mysterybox.MysteryBoxEvent.tick(), com.runehive.content.store.impl.DefaultStore.StoreRestockTask.tick(), com.runehive.game.task.impl.BotStartupEvent.tick(), com.runehive.game.task.impl.CeillingCollapseTask.tick(), com.runehive.game.task.impl.PlayerRemovalTask.tick(), com.runehive.game.task.impl.SkullRemoveTask.tick(), and com.runehive.game.task.impl.SystemUpdateEvent.tick().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ cancel() [2/2]

synchronized final void com.runehive.game.task.Task.cancel ( boolean logout)

Cancels all subsequent executions.

Does nothing if already cancelled.

Definition at line 121 of file Task.java.

121 {
122 if (running) {
123 onCancel(logout);
124 running = false;
125 }
126 }

References onCancel(), and running.

Here is the call graph for this function:

◆ canRun()

boolean com.runehive.game.task.Task.canRun ( )

Determines if the task can be ran.

Reimplemented in com.runehive.content.skill.impl.DestructionSkillAction, com.runehive.content.skill.impl.HarvestingSkillAction, and com.runehive.content.skill.impl.ProducingSkillAction.

Definition at line 108 of file Task.java.

108 {
109 return true;
110 }

Referenced by com.runehive.content.skill.SkillAction.execute(), and com.runehive.content.skill.SkillAction.onSchedule().

Here is the caller graph for this function:

◆ canSchedule()

◆ execute()

abstract void com.runehive.game.task.Task.execute ( )
abstractprotected

A function representing the unit of work that will be carried out.

Reimplemented in com.runehive.content.activity.inferno.InfernoBoss, com.runehive.content.bloodmoney.BloodChestEvent, com.runehive.content.combat.cannon.CannonFireAction, com.runehive.content.lms.LMSGameEvent, com.runehive.content.lms.lobby.LMSLobbyEvent, com.runehive.content.shootingstar.ShootingStarAction, com.runehive.content.skill.impl.fishing.FishingAction, com.runehive.content.skill.impl.hunter.birdhouse.action.CreateBirdHouse, com.runehive.content.skill.impl.hunter.birdhouse.action.FillBirdhouse, com.runehive.content.skill.impl.hunter.birdhouse.action.PlaceBirdhouse, com.runehive.content.skill.impl.hunter.net.Netting, com.runehive.content.skill.impl.hunter.net.PuroPuroAction, com.runehive.content.skill.impl.mining.MiningAction, com.runehive.content.skill.impl.smithing.Smelting, com.runehive.content.skill.impl.thieving.PickpocketAction, com.runehive.content.skill.impl.woodcutting.WoodcuttingAction, com.runehive.content.skill.SkillAction, com.runehive.content.wintertodt.actions.ChopRoots, com.runehive.content.wintertodt.actions.FeedBrazier, com.runehive.content.wintertodt.actions.FixBrazier, com.runehive.content.wintertodt.actions.FlameWalk, com.runehive.content.wintertodt.actions.FletchKindling, com.runehive.content.wintertodt.actions.LightBrazier, com.runehive.content.wintertodt.actions.MixHerb, com.runehive.content.wintertodt.actions.PickHerb, com.runehive.content.wintertodt.WintertodtAction, com.runehive.game.action.impl.ChestAction, com.runehive.game.action.impl.DebugAction, com.runehive.game.action.impl.DoorAction, com.runehive.game.action.impl.EmoteAction, com.runehive.game.action.impl.FlaxPickingAction, com.runehive.game.action.impl.HunterRespawnTask, com.runehive.game.action.impl.InspectAction, com.runehive.game.action.impl.LadderAction, com.runehive.game.action.impl.LeverAction, com.runehive.game.action.impl.NpcFaceAction, com.runehive.game.action.impl.RevShortcutAction, com.runehive.game.action.impl.SpadeAction, com.runehive.game.action.impl.SpellAction, com.runehive.game.task.impl.AntiVenomTask, com.runehive.game.task.impl.ChopVineTask, com.runehive.game.task.impl.DoubleExperienceEvent, com.runehive.game.task.impl.DuelNotificationTask, com.runehive.game.task.impl.ForceChatEvent, com.runehive.game.task.impl.ForceMovementTask, com.runehive.game.task.impl.HunterTask, com.runehive.game.task.impl.MessageEvent, com.runehive.game.task.impl.ObjectPlacementEvent, com.runehive.game.task.impl.ObjectReplacementEvent, com.runehive.game.task.impl.PlayerSaveEvent, com.runehive.game.task.impl.PvPTimerTask, com.runehive.game.task.impl.SessionRemovalNotificationTask, com.runehive.game.task.impl.SteppingStoneTask, com.runehive.game.task.impl.SuperAntipoisonTask, com.runehive.game.task.impl.TeleblockTask, com.runehive.game.task.impl.WarriorGuildCyclopEvent, com.runehive.game.task.TickableTask, com.runehive.game.world.entity.combat.effect.CombatEffectTask, com.runehive.game.world.entity.combat.strategy.npc.boss.skotizo.SkotizoEvent, com.runehive.game.world.entity.mob.MobDeath< T extends Mob >, com.runehive.game.world.entity.mob.movement.waypoint.Waypoint, and com.runehive.game.world.items.ground.GroundItemEvent.

Referenced by baseExecute().

Here is the caller graph for this function:

◆ getAttachment()

Optional< Object > com.runehive.game.task.Task.getAttachment ( )
Returns
An optional attachment.

Definition at line 174 of file Task.java.

174 {
175 return key;
176 }

References key.

◆ getCreationStackTraceStr()

String com.runehive.game.task.Task.getCreationStackTraceStr ( )

Definition at line 81 of file Task.java.

81 {
82 StringBuilder sb = new StringBuilder();
83 for (StackTraceElement ste : creationStackTrace) {
84 sb.append(ste.toString()).append("\n");
85 }
86 return sb.toString();
87 }

References creationStackTrace.

◆ getDelay()

int com.runehive.game.task.Task.getDelay ( )
Returns
The cyclic delay.

Definition at line 159 of file Task.java.

159 {
160 return delay;
161 }

References delay.

Referenced by com.runehive.game.action.impl.InspectAction.execute().

Here is the caller graph for this function:

◆ getElapsedTimeFromRunStartTime()

Long com.runehive.game.task.Task.getElapsedTimeFromRunStartTime ( )

Definition at line 74 of file Task.java.

74 {
75 if (runStartTime.isPresent()) {
76 return System.currentTimeMillis() - runStartTime.get();
77 }
78 return null;
79 }

References runStartTime.

◆ getRunStartTime()

Optional< Long > com.runehive.game.task.Task.getRunStartTime ( )

Definition at line 70 of file Task.java.

70 {
71 return runStartTime;
72 }

References runStartTime.

◆ getTaskCreationTime()

long com.runehive.game.task.Task.getTaskCreationTime ( )

Definition at line 66 of file Task.java.

66 {
67 return taskCreationTime;
68 }

References taskCreationTime.

Referenced by com.runehive.game.task.TaskDeadlockWatcher.run().

Here is the caller graph for this function:

◆ getTaskId()

String com.runehive.game.task.Task.getTaskId ( )

Definition at line 53 of file Task.java.

53 {
54 return uuid.toString();
55 }

References uuid.

◆ isInstant()

boolean com.runehive.game.task.Task.isInstant ( )
Returns
true if execution happens instantly upon being scheduled.

Definition at line 154 of file Task.java.

154 {
155 return instant;
156 }

References instant.

◆ isRunning()

boolean com.runehive.game.task.Task.isRunning ( )
Returns
true if registration has taken place.

Definition at line 169 of file Task.java.

169 {
170 return running;
171 }

References running.

Referenced by com.runehive.game.action.impl.InspectAction.execute().

Here is the caller graph for this function:

◆ onCancel()

void com.runehive.game.task.Task.onCancel ( boolean logout)
protected

A function executed on cancellation.

Reimplemented in com.runehive.content.combat.cannon.CannonBuild, com.runehive.content.mysterybox.MysteryBoxEvent, com.runehive.content.shootingstar.ShootingStarAction, com.runehive.content.skill.impl.firemaking.FiremakingAction, com.runehive.content.skill.impl.fishing.FishingAction, com.runehive.content.skill.impl.hunter.net.Netting, com.runehive.content.skill.impl.hunter.net.PuroPuroAction, com.runehive.content.skill.impl.mining.MiningAction, com.runehive.content.skill.impl.smithing.Smelting, com.runehive.content.skill.impl.smithing.SmithingArmour, com.runehive.content.skill.impl.woodcutting.WoodcuttingAction, com.runehive.game.action.impl.BuryBoneAction, com.runehive.game.action.impl.ChestAction, com.runehive.game.action.impl.DoorAction, com.runehive.game.action.impl.LadderAction, com.runehive.game.action.impl.LeverAction, com.runehive.game.action.impl.ScatterAshAction, com.runehive.game.task.impl.AntiVenomTask, com.runehive.game.task.impl.CeillingCollapseTask, com.runehive.game.task.impl.ChopVineTask, com.runehive.game.task.impl.DoubleExperienceEvent, com.runehive.game.task.impl.DuelNotificationTask, com.runehive.game.task.impl.HunterTask, com.runehive.game.task.impl.ObjectPlacementEvent, com.runehive.game.task.impl.ObjectReplacementEvent, com.runehive.game.task.impl.PlayerRemovalTask, com.runehive.game.task.impl.PvPTimerTask, com.runehive.game.task.impl.SessionRemovalNotificationTask, com.runehive.game.task.impl.SteppingStoneTask, com.runehive.game.task.impl.SuperAntipoisonTask, com.runehive.game.task.impl.SystemUpdateEvent, com.runehive.game.task.impl.TeleblockTask, com.runehive.game.task.impl.WarriorGuildCyclopEvent, com.runehive.game.world.entity.mob.MobDeath< T extends Mob >, com.runehive.game.world.entity.mob.movement.waypoint.Waypoint, and com.runehive.game.world.items.ground.GroundItemEvent.

Definition at line 140 of file Task.java.

140{ }

Referenced by cancel(), and cancel().

Here is the caller graph for this function:

◆ onException()

void com.runehive.game.task.Task.onException ( Exception e)
package

A function executed on thrown exceptions.

Definition at line 143 of file Task.java.

143 {
144
145 }

◆ onLoop()

void com.runehive.game.task.Task.onLoop ( )
package

A function executed when iterated over.

Definition at line 129 of file Task.java.

129{ }

◆ onSchedule()

◆ process()

final synchronized void com.runehive.game.task.Task.process ( )
package

Definition at line 89 of file Task.java.

89 {
90 if (++counter >= delay && running) {
91 baseExecute();
92 counter = 0;
93 }
94 }

References baseExecute(), counter, delay, and running.

Here is the call graph for this function:

◆ setDelay()

void com.runehive.game.task.Task.setDelay ( int delay)

Sets the cyclic delay.

Definition at line 164 of file Task.java.

164 {
165 this.delay = delay;
166 }

References delay.

Referenced by com.runehive.game.action.impl.FlaxPickingAction.execute(), com.runehive.game.action.impl.InspectAction.execute(), and com.runehive.game.action.impl.HunterRespawnTask.onSchedule().

Here is the caller graph for this function:

◆ setExecutionTime()

void com.runehive.game.task.Task.setExecutionTime ( )

Definition at line 62 of file Task.java.

62 {
63 runStartTime = Optional.of(System.currentTimeMillis());
64 }

References runStartTime.

Referenced by baseExecute().

Here is the caller graph for this function:

◆ setRunning()

synchronized void com.runehive.game.task.Task.setRunning ( boolean running)
package

Definition at line 178 of file Task.java.

178 {
179 this.running = running;
180 }

References running.

Member Data Documentation

◆ counter

int com.runehive.game.task.Task.counter
private

A counter that determines when execution should take place.

Definition at line 23 of file Task.java.

Referenced by process().

◆ creationStackTrace

StackTraceElement [] com.runehive.game.task.Task.creationStackTrace
private

The creation stack trace because jire likes to guess.

Definition at line 29 of file Task.java.

Referenced by getCreationStackTraceStr().

◆ delay

◆ instant

◆ key

Optional<Object> com.runehive.game.task.Task.key = Optional.empty()
private

An optional attachment.

Definition at line 26 of file Task.java.

Referenced by attach(), and getAttachment().

◆ running

boolean com.runehive.game.task.Task.running
private

If registration has taken place.

Definition at line 20 of file Task.java.

Referenced by cancel(), cancel(), isRunning(), process(), and setRunning().

◆ runStartTime

Optional<Long> com.runehive.game.task.Task.runStartTime = Optional.empty()
private

The time the task started task.run(), if null the task has not ran yet.

Definition at line 32 of file Task.java.

Referenced by getElapsedTimeFromRunStartTime(), getRunStartTime(), and setExecutionTime().

◆ taskCreationTime

final long com.runehive.game.task.Task.taskCreationTime
private

The time the task was created.

Definition at line 38 of file Task.java.

Referenced by getTaskCreationTime().

◆ uuid

final UUID com.runehive.game.task.Task.uuid
private

Unique task UUID which helps us identify if any tasks will lock up.

Definition at line 35 of file Task.java.

Referenced by getTaskId().


The documentation for this class was generated from the following file: