예제 #1
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);
    }
  }
예제 #2
0
 public static boolean post(Event event) {
   return SpongeImpl.getGame().getEventManager().post(event);
 }
예제 #3
0
 public void postState(Class<? extends GameStateEvent> type, GameState state) {
   SpongeImpl.getGame().setState(state);
   post(SpongeEventFactoryUtils.createState(type, this.game));
 }