File tree Expand file tree Collapse file tree 1 file changed +9
-4
lines changed 
src/main/java/de/srendi/advancedperipherals/common/util Expand file tree Collapse file tree 1 file changed +9
-4
lines changed Original file line number Diff line number Diff line change 55import  net .minecraftforge .eventbus .api .SubscribeEvent ;
66import  net .minecraftforge .fml .common .Mod ;
77
8- import  java .util .ArrayDeque ;
98import  java .util .Queue ;
9+ import  java .util .concurrent .ConcurrentLinkedQueue ;
1010
1111@ Mod .EventBusSubscriber (modid  = AdvancedPeripherals .MOD_ID )
1212public  class  ServerWorker  {
1313
14-     private  static  final  Queue <Runnable > callQueue  = new  ArrayDeque <>();
14+     private  static  final  Queue <Runnable > callQueue  = new  ConcurrentLinkedQueue <>();
1515
1616    public  static  void  add (final  Runnable  call ) {
17-         callQueue .add (call );
17+         if  (call  != null ) {
18+             callQueue .add (call );
19+         }
1820    }
1921
2022    @ SubscribeEvent 
2123    public  static  void  serverTick (TickEvent .ServerTickEvent  event ) {
2224        if  (event .phase  == TickEvent .Phase .END ) {
23-             while  (! callQueue . isEmpty () ) {
25+             while  (true ) {
2426                final  Runnable  runnable  = callQueue .poll ();
27+                 if  (runnable  == null ) {
28+                     return ;
29+                 }
2530                AdvancedPeripherals .debug ("Running queued server worker call: "  + runnable );
2631                runnable .run ();
2732            }
 
 
   
 
     
   
   
          
    
    
     
    
      
     
     
    You can’t perform that action at this time.
  
 
    
  
    
      
        
     
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments