forked from Limework/skript-db
		
	add null check on locals
This commit is contained in:
		
							parent
							
								
									2dcd4edf58
								
							
						
					
					
						commit
						2a4d7f6a6d
					
				@ -105,7 +105,7 @@ public class EffExecuteStatement extends Effect {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
            if (getNext() != null) {
 | 
					            if (getNext() != null) {
 | 
				
			||||||
                //if local variables are present
 | 
					                //if local variables are present
 | 
				
			||||||
                if (locals != null)
 | 
					                if (locals != null) {
 | 
				
			||||||
                    //bring back local variables
 | 
					                    //bring back local variables
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                    //populate SQL data into variables
 | 
					                    //populate SQL data into variables
 | 
				
			||||||
@ -120,26 +120,26 @@ public class EffExecuteStatement extends Effect {
 | 
				
			|||||||
                        //((Map<String, Object>) res).forEach((name, value) -> setVariable(event, name, value));
 | 
					                        //((Map<String, Object>) res).forEach((name, value) -> setVariable(event, name, value));
 | 
				
			||||||
                        //SkriptDB.getPlugin(SkriptDB.class).getServer().getPluginManager().callEvent(event);
 | 
					                        //SkriptDB.getPlugin(SkriptDB.class).getServer().getPluginManager().callEvent(event);
 | 
				
			||||||
                    }
 | 
					                    }
 | 
				
			||||||
                if (isSync || finalSync) {
 | 
					                    if (isSync || finalSync) {
 | 
				
			||||||
 | 
					 | 
				
			||||||
                    Variables.setLocalVariables(e, locals);
 | 
					 | 
				
			||||||
                    if (!(res instanceof String)) {
 | 
					 | 
				
			||||||
                        ((Map<String, Object>) res).forEach((name, value) -> setVariable(e, name, value));
 | 
					 | 
				
			||||||
                    }
 | 
					 | 
				
			||||||
                    TriggerItem.walk(getNext(), e);
 | 
					 | 
				
			||||||
                    Variables.removeLocals(e);
 | 
					 | 
				
			||||||
                } else {
 | 
					 | 
				
			||||||
                    Bukkit.getScheduler().runTask(SkriptDB.getInstance(), () -> {
 | 
					 | 
				
			||||||
                        Variables.setLocalVariables(e, locals);
 | 
					                        Variables.setLocalVariables(e, locals);
 | 
				
			||||||
                        if (!(res instanceof String)) {
 | 
					                        if (!(res instanceof String)) {
 | 
				
			||||||
                            ((Map<String, Object>) res).forEach((name, value) -> setVariable(e, name, value));
 | 
					                            ((Map<String, Object>) res).forEach((name, value) -> setVariable(e, name, value));
 | 
				
			||||||
                        }
 | 
					                        }
 | 
				
			||||||
                        TriggerItem.walk(getNext(), e);
 | 
					                        TriggerItem.walk(getNext(), e);
 | 
				
			||||||
                        //the line below is required to prevent memory leaks
 | 
					 | 
				
			||||||
                        //no functionality difference notice with it being removed from my test, but the memory gets filled with leaks
 | 
					 | 
				
			||||||
                        //so it must be kept
 | 
					 | 
				
			||||||
                        Variables.removeLocals(e);
 | 
					                        Variables.removeLocals(e);
 | 
				
			||||||
                    });
 | 
					                    } else {
 | 
				
			||||||
 | 
					                        Bukkit.getScheduler().runTask(SkriptDB.getInstance(), () -> {
 | 
				
			||||||
 | 
					                            Variables.setLocalVariables(e, locals);
 | 
				
			||||||
 | 
					                            if (!(res instanceof String)) {
 | 
				
			||||||
 | 
					                                ((Map<String, Object>) res).forEach((name, value) -> setVariable(e, name, value));
 | 
				
			||||||
 | 
					                            }
 | 
				
			||||||
 | 
					                            TriggerItem.walk(getNext(), e);
 | 
				
			||||||
 | 
					                            //the line below is required to prevent memory leaks
 | 
				
			||||||
 | 
					                            //no functionality difference notice with it being removed from my test, but the memory gets filled with leaks
 | 
				
			||||||
 | 
					                            //so it must be kept
 | 
				
			||||||
 | 
					                            Variables.removeLocals(e);
 | 
				
			||||||
 | 
					                        });
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
        });
 | 
					        });
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
		Reference in New Issue
	
	Block a user