public void initialize() {
    SpongeBootstrap.initializeRegistry();
    postState(InitializationEvent.class);

    if (!this.game.getServiceManager().provide(PermissionService.class).isPresent()) {
      try {
        SpongePermissionService service = new SpongePermissionService();
        // Setup default permissions
        service
            .getGroupForOpLevel(2)
            .getSubjectData()
            .setPermission(SubjectData.GLOBAL_CONTEXT, "minecraft.commandblock", Tristate.TRUE);
        this.game.getServiceManager().setProvider(this, PermissionService.class, service);
      } catch (ProviderExistsException e) {
        // It's a fallback, ignore
      }
    }

    SpongeBootstrap.postInitializeRegistry();
    SerializationService service =
        this.game.getServiceManager().provide(SerializationService.class).get();
    ((SpongeSerializationService) service).completeRegistration();

    postState(PostInitializationEvent.class);

    Sponge.getLogger().info("Successfully loaded and initialized plugins.");

    postState(LoadCompleteEvent.class);
  }
  public void preInitialize() {
    try {
      Sponge.getLogger().info("Loading Sponge...");

      File gameDir = Sponge.getGameDirectory();
      File pluginsDir = Sponge.getPluginsDirectory();

      if (!gameDir.isDirectory() || !pluginsDir.isDirectory()) {
        if (!pluginsDir.mkdirs()) {
          throw new IOException("Failed to create plugins folder");
        }
      }

      SpongeBootstrap.initializeServices();
      SpongeBootstrap.preInitializeRegistry();

      this.game.getEventManager().register(this, this);
      this.game.getEventManager().register(this, this.game.getRegistry());

      Sponge.getLogger().info("Loading plugins...");
      ((VanillaPluginManager) this.game.getPluginManager()).loadPlugins();
      postState(ConstructionEvent.class);
      Sponge.getLogger().info("Initializing plugins...");
      postState(PreInitializationEvent.class);

      this.game
          .getServiceManager()
          .potentiallyProvide(PermissionService.class)
          .executeWhenPresent(
              new Predicate<PermissionService>() {

                @Override
                public boolean apply(PermissionService input) {
                  input.registerContextCalculator(new SpongeContextCalculator());
                  return true;
                }
              });

      SpongeHooks.enableThreadContentionMonitoring();
    } catch (IOException e) {
      throw Throwables.propagate(e);
    }
  }