示例#1
0
  public void init() {
    SpongeImpl.getRegistry().init();
    postState(GameInitializationEvent.class, GameState.INITIALIZATION);

    // TODO: Register permissions

    SpongeImpl.getRegistry().postInit();

    // TODO: Data complete registration

    postState(GamePostInitializationEvent.class, GameState.POST_INITIALIZATION);

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

    postState(GameLoadCompleteEvent.class, GameState.LOAD_COMPLETE);
  }
示例#2
0
  public void preInit() {
    try {
      SpongeImpl.getLogger().info("Loading Sponge...");

      Path gameDir = SpongeImpl.getGameDirectory();
      Path pluginsDir = SpongeImpl.getPluginsDirectory();
      Files.createDirectories(pluginsDir);

      SpongeImpl.getRegistry().preRegistryInit();
      // TODO: Init services
      // TODO: Init commands
      SpongeImpl.getRegistry().preInit();

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

      SpongeImpl.getLogger().info("Loading plugins...");
      ((LanternPluginManager) this.game.getPluginManager()).loadPlugins();
      postState(GameConstructionEvent.class, GameState.CONSTRUCTION);
      SpongeImpl.getLogger().info("Initializing plugins...");
      postState(GamePreInitializationEvent.class, GameState.PRE_INITIALIZATION);

      // TODO: register permission calculator
    } catch (IOException e) {
      throw Throwables.propagate(e);
    }
  }
示例#3
0
  private Lantern() {
    Guice.createInjector(new LanternGuiceModule(this)).getInstance(SpongeImpl.class);

    this.game = SpongeImpl.getGame();
    try {
      RegistryHelper.setFinalStatic(Sponge.class, "game", this.game);
    } catch (NoSuchFieldException | IllegalAccessException e) {
      e.printStackTrace();
    }

    preInit();

    init();

    try {
      SpongeImpl.getGame().setServer(new LanternServer());
    } catch (BindException e) {
      SpongeImpl.getLogger().error("The server could not bind to the requested address.");
      if (e.getMessage().startsWith("Cannot assign requested address")) {
        SpongeImpl.getLogger().error("The 'server.ip' in your configuration may not be valid.");
        SpongeImpl.getLogger().error("Unless you are sure you need it, try removing it.");
        SpongeImpl.getLogger().error(e.toString());
      } else if (e.getMessage().startsWith("Address already in use")) {
        SpongeImpl.getLogger().error("The address was already in use. Check that no server is");
        SpongeImpl.getLogger().error("already running on that port. If needed, try killing all");
        SpongeImpl.getLogger().error("Java processes using Task Manager or similar.");
        SpongeImpl.getLogger().error(e.toString());
      } else {
        SpongeImpl.getLogger().error("An unknown bind error has occurred.", e);
      }
      System.exit(1);
    } catch (Throwable t) {
      // general server startup crash
      SpongeImpl.getLogger().error("Error during server startup.", t);
      System.exit(1);
    }
  }
示例#4
0
 public static boolean post(Event event) {
   return SpongeImpl.getGame().getEventManager().post(event);
 }
示例#5
0
 public void postState(Class<? extends GameStateEvent> type, GameState state) {
   SpongeImpl.getGame().setState(state);
   post(SpongeEventFactoryUtils.createState(type, this.game));
 }