GenisysPro  for Minecraft PE/Windows 10 v1.1.x
Feature-rich server software for Minecraft PE and Windows 10 Edition
TaskHandler Class Reference

Public Member Functions

 __construct ($timingName, Task $task, $taskId, $delay=-1, $period=-1)
 
 isCancelled ()
 
 getNextRun ()
 
 setNextRun ($ticks)
 
 getTaskId ()
 
 getTask ()
 
 getDelay ()
 
 isDelayed ()
 
 isRepeating ()
 
 getPeriod ()
 
 cancel ()
 
 remove ()
 
 run ($currentTick)
 
 getTaskName ()
 

Data Fields

 $timings
 
 $timingName = null
 

Protected Attributes

 $task
 
 $taskId
 
 $delay
 
 $period
 
 $nextRun
 
 $cancelled = false
 

Constructor & Destructor Documentation

◆ __construct()

__construct (   $timingName,
Task  $task,
  $taskId,
  $delay = -1,
  $period = -1 
)
Parameters
string$timingName
Task$task
int$taskId
int$delay
int$period
58  {
59  $this->task = $task;
60  $this->taskId = $taskId;
61  $this->delay = $delay;
62  $this->period = $period;
63  $this->timingName = $timingName === null ? "Unknown" : $timingName;
64  $this->timings = Timings::getPluginTaskTimings($this, $period);
65  $this->task->setHandler($this);
66  }

Member Function Documentation

◆ cancel()

cancel ( )

WARNING: Do not use this, it's only for internal use. Changes to this function won't be recorded on the version.

135  {
136  if(!$this->isCancelled()){
137  $this->task->onCancel();
138  }
139  $this->remove();
140  }

◆ getDelay()

getDelay ( )
Returns
int
106  {
107  return $this->delay;
108  }

◆ getNextRun()

getNextRun ( )
Returns
int
78  {
79  return $this->nextRun;
80  }

◆ getPeriod()

getPeriod ( )
Returns
int
127  {
128  return $this->period;
129  }

◆ getTask()

getTask ( )
Returns
Task
99  {
100  return $this->task;
101  }

◆ getTaskId()

getTaskId ( )
Returns
int
92  {
93  return $this->taskId;
94  }

◆ getTaskName()

getTaskName ( )
Returns
string
157  {
158  if($this->timingName !== null){
159  return $this->timingName;
160  }
161 
162  return get_class($this->task);
163  }

◆ isCancelled()

isCancelled ( )
Returns
bool
71  {
72  return $this->cancelled === true;
73  }

◆ isDelayed()

isDelayed ( )
Returns
bool
113  {
114  return $this->delay > 0;
115  }

◆ isRepeating()

isRepeating ( )
Returns
bool
120  {
121  return $this->period > 0;
122  }

◆ remove()

remove ( )
142  {
143  $this->cancelled = true;
144  $this->task->setHandler(null);
145  }

◆ run()

run (   $currentTick)
Parameters
int$currentTick
150  {
151  $this->task->onRun($currentTick);
152  }

◆ setNextRun()

setNextRun (   $ticks)
Parameters
int$ticks
85  {
86  $this->nextRun = $ticks;
87  }

Field Documentation

◆ $cancelled

$cancelled = false
protected

◆ $delay

$delay
protected

◆ $nextRun

$nextRun
protected

◆ $period

$period
protected

◆ $task

$task
protected

◆ $taskId

$taskId
protected

◆ $timingName

$timingName = null

◆ $timings

$timings

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