@@ -133,15 +133,19 @@ public SessionKey getSessionKey() {
133133 private volatile boolean active = true ;
134134
135135 private void updateActive () {
136- Block block = sender .getBlock ();
137- if (!block .getWorld ().isChunkLoaded (block .getX () >> 4 , block .getZ () >> 4 )) {
138- active = false ;
139- return ;
136+ try {
137+ Block block = sender .getBlock ();
138+ if (!block .getWorld ().isChunkLoaded (block .getX () >> 4 , block .getZ () >> 4 )) {
139+ active = false ;
140+ return ;
141+ }
142+ Material type = block .getType ();
143+ active = type == Material .COMMAND_BLOCK
144+ || type == Material .CHAIN_COMMAND_BLOCK
145+ || type == Material .REPEATING_COMMAND_BLOCK ;
146+ } catch (Throwable t ) {
147+ WorldEdit .logger .warn ("Exception while updating command block sender active state" , t );
140148 }
141- Material type = block .getType ();
142- active = type == Material .COMMAND_BLOCK
143- || type == Material .CHAIN_COMMAND_BLOCK
144- || type == Material .REPEATING_COMMAND_BLOCK ;
145149 }
146150
147151 @ Override
@@ -158,13 +162,7 @@ public boolean isActive() {
158162 updateActive ();
159163 } else {
160164 // We need to delegate to the right thread.
161- Bukkit .getRegionScheduler ().execute (plugin , sender .getBlock ().getLocation (), () -> {
162- try {
163- updateActive ();
164- } catch (Throwable t ) {
165- WorldEdit .logger .warn ("Exception while updating command block sender active state" , t );
166- }
167- });
165+ Bukkit .getRegionScheduler ().execute (plugin , sender .getBlock ().getLocation (), this ::updateActive );
168166 }
169167
170168 return active ;
@@ -177,15 +175,10 @@ public boolean isActive() {
177175 // we should update it eventually
178176 // Suppress FutureReturnValueIgnored: We handle it in the block.
179177 @ SuppressWarnings ({"FutureReturnValueIgnored" , "unused" })
180- var unused = Bukkit .getScheduler ().callSyncMethod (plugin ,
181- () -> {
182- try {
183- updateActive ();
184- } catch (Throwable t ) {
185- WorldEdit .logger .warn ("Exception while updating command block sender active state" , t );
186- }
187- return null ;
188- });
178+ var unused = Bukkit .getScheduler ().callSyncMethod (plugin , () -> {
179+ updateActive ();
180+ return null ;
181+ });
189182 }
190183 return active ;
191184 }
0 commit comments