@@ -29,7 +29,7 @@ public ServerScheduler(Plugin plugin) {
2929 }
3030
3131 public PluginTask runGlobal (Runnable runnable ) {
32- if (runnable == null ) {
32+ if (runnable == null || ! this . isPluginEnabled () ) {
3333 return NO_OP_TASK ;
3434 }
3535 Object scheduler = this .globalRegionScheduler ();
@@ -49,7 +49,7 @@ public PluginTask runGlobal(Runnable runnable) {
4949 }
5050
5151 public PluginTask runGlobalDelayed (Runnable runnable , long delayTicks ) {
52- if (runnable == null ) {
52+ if (runnable == null || ! this . isPluginEnabled () ) {
5353 return NO_OP_TASK ;
5454 }
5555 Object scheduler = this .globalRegionScheduler ();
@@ -70,7 +70,7 @@ public PluginTask runGlobalDelayed(Runnable runnable, long delayTicks) {
7070 }
7171
7272 public PluginTask runGlobalTimer (Runnable runnable , long delayTicks , long periodTicks ) {
73- if (runnable == null ) {
73+ if (runnable == null || ! this . isPluginEnabled () ) {
7474 return NO_OP_TASK ;
7575 }
7676 Object scheduler = this .globalRegionScheduler ();
@@ -92,7 +92,7 @@ public PluginTask runGlobalTimer(Runnable runnable, long delayTicks, long period
9292 }
9393
9494 public PluginTask runRegion (Location location , Runnable runnable ) {
95- if (location == null || location .getWorld () == null || runnable == null ) {
95+ if (location == null || location .getWorld () == null || runnable == null || ! this . isPluginEnabled () ) {
9696 return NO_OP_TASK ;
9797 }
9898 Object scheduler = this .regionScheduler ();
@@ -113,7 +113,7 @@ public PluginTask runRegion(Location location, Runnable runnable) {
113113 }
114114
115115 public PluginTask runRegionDelayed (Location location , Runnable runnable , long delayTicks ) {
116- if (location == null || location .getWorld () == null || runnable == null ) {
116+ if (location == null || location .getWorld () == null || runnable == null || ! this . isPluginEnabled () ) {
117117 return NO_OP_TASK ;
118118 }
119119 Object scheduler = this .regionScheduler ();
@@ -135,7 +135,7 @@ public PluginTask runRegionDelayed(Location location, Runnable runnable, long de
135135 }
136136
137137 public PluginTask runRegionTimer (Location location , Runnable runnable , long delayTicks , long periodTicks ) {
138- if (location == null || location .getWorld () == null || runnable == null ) {
138+ if (location == null || location .getWorld () == null || runnable == null || ! this . isPluginEnabled () ) {
139139 return NO_OP_TASK ;
140140 }
141141 Object scheduler = this .regionScheduler ();
@@ -158,7 +158,7 @@ public PluginTask runRegionTimer(Location location, Runnable runnable, long dela
158158 }
159159
160160 public PluginTask runEntity (Entity entity , Runnable runnable ) {
161- if (entity == null || runnable == null ) {
161+ if (entity == null || runnable == null || ! this . isPluginEnabled () ) {
162162 return NO_OP_TASK ;
163163 }
164164 Object scheduler = this .entityScheduler (entity );
@@ -179,7 +179,7 @@ public PluginTask runEntity(Entity entity, Runnable runnable) {
179179 }
180180
181181 public PluginTask runEntityDelayed (Entity entity , Runnable runnable , long delayTicks ) {
182- if (entity == null || runnable == null ) {
182+ if (entity == null || runnable == null || ! this . isPluginEnabled () ) {
183183 return NO_OP_TASK ;
184184 }
185185 Object scheduler = this .entityScheduler (entity );
@@ -202,7 +202,7 @@ public PluginTask runEntityDelayed(Entity entity, Runnable runnable, long delayT
202202
203203 @ SuppressWarnings ("unchecked" )
204204 public CompletableFuture <Boolean > teleport (Entity entity , Location location ) {
205- if (entity == null || location == null ) {
205+ if (entity == null || location == null || ! this . isPluginEnabled () ) {
206206 return CompletableFuture .completedFuture (Boolean .FALSE );
207207 }
208208 try {
@@ -231,7 +231,7 @@ public PluginTask removeEntity(Entity entity) {
231231 }
232232
233233 public PluginTask removeEntity (Entity entity , long delayTicks ) {
234- if (entity == null ) {
234+ if (entity == null || ! this . isPluginEnabled () ) {
235235 return NO_OP_TASK ;
236236 }
237237 Runnable removeTask = () -> {
@@ -257,6 +257,10 @@ private Object entityScheduler(Entity entity) {
257257 return this .invokeNoArgs (entity , "getScheduler" );
258258 }
259259
260+ private boolean isPluginEnabled () {
261+ return this .plugin .isEnabled ();
262+ }
263+
260264 private Object invokeNoArgs (Object target , String methodName ) {
261265 if (target == null ) {
262266 return null ;
0 commit comments