Fixed potential NPEs and added @Nonnull and @Nullable annotations

This commit is contained in:
Marcel Konrad
2020-10-18 17:19:37 +02:00
parent 9f18302706
commit e23d73726b
40 changed files with 248 additions and 114 deletions

View File

@@ -7,6 +7,7 @@ import java.util.function.Supplier;
import javax.annotation.Nullable;
import exopandora.worldhandler.builder.impl.BuilderGeneric;
import exopandora.worldhandler.builder.impl.BuilderUsercontent;
import exopandora.worldhandler.gui.content.Content;
import exopandora.worldhandler.usercontent.ScriptEngineAdapter;
@@ -16,7 +17,6 @@ import exopandora.worldhandler.usercontent.model.Action;
import exopandora.worldhandler.util.ActionHandler;
import exopandora.worldhandler.util.ActionHelper;
import exopandora.worldhandler.util.CommandHelper;
import net.minecraft.client.Minecraft;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
@@ -81,7 +81,14 @@ public class ActionHandlerFactory
}
else if(!action.getAttributes().getValue().isEmpty())
{
Minecraft.getInstance().player.sendChatMessage(action.getAttributes().getValue());
String command = action.getAttributes().getValue();
if(command.startsWith("/"))
{
command = command.substring(1);
}
CommandHelper.sendCommand(player.get(), new BuilderGeneric(command));
}
};
}

View File

@@ -63,7 +63,12 @@ public class BooleanExpression
}
else if(this.type == Type.JS)
{
return (boolean) engine.invokeFunction(this.function);
Object result = engine.invokeFunction(this.function);
if(result != null && result instanceof Boolean)
{
return (boolean) result;
}
}
return true;