after this line, it really should be more like:

if(!GraphicsEnvironment.isHeadless()){
    MinecraftServer.setHeadless(false);
}