Beispiel #1
0
 Object createGuiElement(Class cls, EntityPlayer player, World world, int x, int y, int z) {
   try {
     try {
       if (debugGui)
         System.out.printf(
             "BaseMod.createGuiElement: Invoking create method of %s for %s in %s\n",
             cls, player, world);
       return cls.getMethod(
               "create", EntityPlayer.class, World.class, int.class, int.class, int.class)
           .invoke(null, player, world, x, y, z);
     } catch (NoSuchMethodException e) {
       if (debugGui)
         System.out.printf("BaseMod.createGuiElement: Invoking constructor of %s\n", cls);
       return cls.getConstructor(EntityPlayer.class, World.class, int.class, int.class, int.class)
           .newInstance(player, world, x, y, z);
     }
   } catch (Exception e) {
     Throwable cause = e.getCause();
     System.out.printf("BaseMod.createGuiElement: %s: %s\n", e, cause);
     if (cause != null) cause.printStackTrace();
     else e.printStackTrace();
     // throw new RuntimeException(e);
     return null;
   }
 }
Beispiel #2
0
  public CraftServer(MinecraftServer server) {
    instance = this;
    configMan = server.getConfigurationManager();
    theServer = server;
    List<Integer> ids = Arrays.asList(DimensionManager.getIDs());
    Iterator<Integer> worldIter = ids.iterator();

    System.out.println("IS THE INSTANCE NULL? " + (instance == null ? "YES" : "NO"));
    this.pluginManager = new SimplePluginManager(this, commandMap);

    // pluginManager = new SimplePluginManager(this, commandMap);
    configuration = new YamlConfiguration();
    YamlConfiguration yml = new YamlConfiguration();
    try {
      yml.load(getClass().getClassLoader().getResourceAsStream("configurations/bukkit.yml"));
      if (!new File("bukkit.yml").exists()) {
        new File("bukkit.yml").createNewFile();
        yml.save("bukkit.yml");
      }
      configuration.load("bukkit.yml");
      configuration.addDefaults(yml);
      configuration.save("bukkit.yml");

    } catch (Exception e) {
      e.printStackTrace();
    }

    for (int id : ids) {
      worlds.get(id);
    }

    this.theLogger = BukkitContainer.bukkitLogger;
    // theLogger.info("Bukkit API for Vanilla, version " + apiVer + " starting up...");
    theLogger.info(
        "Starting BukkitForge "
            + BukkitContainer.BF_FULL_VERSION
            + "(CB-Version: "
            + BukkitContainer.CRAFT_VERSION
            + ").");

    Bukkit.setServer(this);
    this.theHelpMap = new SimpleHelpMap(this);
    this.theMessenger = new StandardMessenger();
    this.entityMetadata = new EntityMetadataStore();
    this.playerMetadata = new PlayerMetadataStore();
    this.worldMetadata = new WorldMetadataStore();
    this.warningState = Warning.WarningState.DEFAULT;
    this.console = (CraftConsoleCommandSender) CraftConsoleCommandSender.getInstance();

    CraftModRecipeHelper.saveCraftingManagerRecipes();

    HelpTopic myHelp =
        new CommandHelpTopic("bexec", "Run a command forcibly bukkit aliases", "", "");
    Bukkit.getServer().getHelpMap().addTopic(myHelp);

    loadPlugins();
    enablePlugins(PluginLoadOrder.STARTUP);

    // load plugin worlds - TODO

    theLogger.info("Loading PostWorld plugins...");
    enablePlugins(PluginLoadOrder.POSTWORLD);
    theLogger.info("Loaded plugins: ");
    for (Plugin i : pluginManager.getPlugins()) {
      theLogger.info(i.getName() + "- Enabled: " + i.isEnabled());
    }
    ForgeEventHandler.ready = true;
    commandMap.doneLoadingPlugins((ServerCommandManager) theServer.getCommandManager());
    if (!theServer.isDedicatedServer()) {
      EntityPlayer player =
          theServer.getConfigurationManager().getPlayerForUsername(theServer.getServerOwner());
      if (player != null) {
        player.sendChatToPlayer(
            ChatColor.GREEN
                + "CraftForge has finished loading! You may now enjoy a (relatively) lag-free game!");
        theServer.getCommandManager().executeCommand(player, "/plugins");
        (new PlayerTracker()).onPlayerLogin(player);
      }
    }
  }