예제 #1
0
 public static ItemStack getItemStackFromConfig(
     String modid, String category, String name, int stackSize, int metadata, boolean isItem) {
   Configuration config = configFiles.get(modid);
   if (config == null) {
     File configFile = null;
     if (modid.equalsIgnoreCase("buildcraft"))
       configFile = new File(Loader.instance().getConfigDir(), "buildcraft/main.conf");
     else if (modid.equalsIgnoreCase("EnderIO"))
       configFile = new File(Loader.instance().getConfigDir(), "enderio/EnderIO.conf");
     else configFile = new File(Loader.instance().getConfigDir(), modid + ".cfg");
     if (configFile != null && configFile.exists()) {
       config = new Configuration(configFile);
       config.load();
       configFiles.put(modid, config);
     } else return null;
   }
   if (config.hasKey(category, name)) {
     int id = config.get(category, name, -1).getInt();
     if (isItem && !modid.equals("immibis") && !modid.equals("foundry")) id += 256;
     if (id > 0 && id < 32768 && Item.itemsList[id] != null) {
       try {
         return new ItemStack(Item.itemsList[id], stackSize, metadata);
       } catch (Exception e) {
         e.printStackTrace();
         return null;
       }
     } else return null;
   } else return null;
 }
  public void save(ArrayList<String> players) {
    // clear it.
    if (file.exists()) file.delete();

    String[] allPlayers =
        FMLCommonHandler.instance()
            .getSidedDelegate()
            .getServer()
            .getConfigurationManager()
            .getAllUsernames();

    Configuration config = new Configuration(file);

    PlayerInfo info;
    for (String name : players) {
      if (name.equalsIgnoreCase(PermissionsAPI.EntryPlayer)) {
        config.get(name, "prefix", PermissionsAPI.EPPrefix);
        config.get(name, "suffix", PermissionsAPI.EPSuffix);
        continue;
      }

      info = PlayerInfo.getPlayerInfo(name);
      config.get(name, "prefix", info.prefix == null ? "" : info.prefix);
      config.get(name, "suffix", info.suffix == null ? "" : info.suffix);
      discardInfo(info, allPlayers);
    }

    config.save();
  }
예제 #3
0
 /**
  * Disables metrics for the server by setting "opt-out" to true in the config file and canceling
  * the metrics task.
  *
  * @throws java.io.IOException
  */
 public void disable() throws IOException {
   // Check if the server owner has already set opt-out, if not, set it.
   if (!isOptOut()) {
     configuration.getCategory(Configuration.CATEGORY_GENERAL).get("opt-out").set("true");
     configuration.save();
   }
 }
예제 #4
0
  @Override
  public void registerConfig(Configuration config, String category) {
    String[] potionEffects = {"9:5:0"};

    config.addCustomCategoryComment(
        category,
        "For more information, go to http://www.minecraftwiki.net/wiki/Potion_effects#Parameters");
    potionEffects =
        config
            .get(
                category,
                "potionEffects",
                potionEffects,
                "Format like this: 'ID:duration:amplifier'")
            .getStringList();

    for (String poisonEffect : potionEffects) {
      String[] split = poisonEffect.split(":");
      potionEffectsList.add(
          new PotionEffect(
              Integer.parseInt(split[0]),
              Integer.parseInt(split[1]) * 20,
              Integer.parseInt(split[2])));
    }
  }
  public ArrayList<String> load() {
    ArrayList<String> players = new ArrayList<String>();

    Configuration config = new Configuration(file);

    PlayerInfo info;
    for (String cat : config.categories.keySet()) {
      if (cat.contains(".")) continue;
      else if (cat.equalsIgnoreCase(PermissionsAPI.EntryPlayer)) {
        PermissionsAPI.EPPrefix = config.get(cat, "prefix", " ").value;
        PermissionsAPI.EPSuffix = config.get(cat, "suffix", " ").value;
        continue;
      }

      info = PlayerInfo.getPlayerInfo(cat);

      if (info != null) {
        info.prefix = config.get(cat, "prefix", " ").value;
        info.suffix = config.get(cat, "suffix", " ").value;
      }

      players.add(cat);
      discardInfo(info, new String[] {});
    }

    return players;
  }
  @Override
  public void init() {
    config = new Configuration(file, true);

    config.addCustomCategoryComment("general", "General Commands configuration.");
    config.save();
  }
예제 #7
0
  public Metrics(final String modname, final String modversion) throws IOException {
    if ((modname == null) || (modversion == null)) {
      throw new IllegalArgumentException("modname and modversion cannot be null");
    }

    this.modname = modname;
    this.modversion = modversion;

    // load the config
    configurationFile = getConfigFile();
    configuration = new Configuration(configurationFile);

    // Get values, and add some defaults, if needed
    configuration.get(
        Configuration.CATEGORY_GENERAL, "opt-out", false, "Set to true to disable all reporting");
    guid =
        configuration
            .get(
                Configuration.CATEGORY_GENERAL,
                "guid",
                UUID.randomUUID().toString(),
                "Server unique ID")
            .getString();
    debug =
        configuration
            .get(Configuration.CATEGORY_GENERAL, "debug", false, "Set to true for verbose debug")
            .getBoolean(false);
    configuration.save();
  }
예제 #8
0
 @Deprecated
 public static void initiate() {
   CONFIGURATION.load();
   USE_FUEL =
       CONFIGURATION
           .get(Configuration.CATEGORY_GENERAL, "Use Fuel", Settings.USE_FUEL)
           .getBoolean(Settings.USE_FUEL);
   LOAD_CHUNKS =
       Settings.CONFIGURATION
           .get(Configuration.CATEGORY_GENERAL, "Allow Chunk Loading", LOAD_CHUNKS)
           .getBoolean(LOAD_CHUNKS);
   DAO_DAN_ZUI_YUAN =
       Settings.CONFIGURATION
           .get(Configuration.CATEGORY_GENERAL, "Max Missile Distance", Settings.DAO_DAN_ZUI_YUAN)
           .getInt(Settings.DAO_DAN_ZUI_YUAN);
   ANTIMATTER_SIZE =
       Settings.CONFIGURATION
           .get(Configuration.CATEGORY_GENERAL, "Antimatter Explosion Size", ANTIMATTER_SIZE)
           .getInt(ANTIMATTER_SIZE);
   DESTROY_BEDROCK =
       Settings.CONFIGURATION
           .get(Configuration.CATEGORY_GENERAL, "Antimatter Destroy Bedrock", DESTROY_BEDROCK)
           .getBoolean(DESTROY_BEDROCK);
   MAX_ROCKET_LAUCNHER_TIER =
       Settings.CONFIGURATION
           .get(
               Configuration.CATEGORY_GENERAL,
               "Limits the max missile tier for rocket launcher item",
               MAX_ROCKET_LAUCNHER_TIER)
           .getInt(MAX_ROCKET_LAUCNHER_TIER);
   CONFIGURATION.save();
 }
  @Override
  public void forceLoad(ICommandSender sender) {
    config.load();

    config.save();

    CommandRegistrar.commandConfigs(config);
  }
예제 #10
0
  @PreInit
  public void PreInit(FMLPreInitializationEvent event) {
    Configuration config = new Configuration(event.getSuggestedConfigurationFile());

    config.load();
    // TODO Setup File to change it!
    config.save();
  }
예제 #11
0
 @PreInit
 public void preInit(FMLPreInitializationEvent event) {
   System.out.println("Initializing Chunk Analyzer " + Version());
   Configuration config = new Configuration(event.getSuggestedConfigurationFile());
   config.load();
   ChunkAnalyzerItemID = config.getBlock("ChunkAnalyzerItemID", 1200).getInt();
   config.save();
 }
  @Override
  public void forceSave() {
    // TODO: may have problems..
    String path = CommandRules.rulesFile.getPath();
    path = path.replace(ModuleCommands.cmddir.getPath(), "");

    config.addCustomCategoryComment("general", "General Commands configuration.");
    config.save();
  }
예제 #13
0
  @PreInit
  public void preInit(FMLPreInitializationEvent event) {
    Configuration config = new Configuration(event.getSuggestedConfigurationFile());

    config.load();

    colorBrickBlockID = config.getBlock("colorBrickBlockID", 1555).getInt();

    config.save();
  }
예제 #14
0
  public static void set(String categoryName, String propertyName, String newValue) {

    configuration.load();
    if (configuration.getCategoryNames().contains(categoryName)) {
      if (configuration.getCategory(categoryName).containsKey(propertyName)) {
        configuration.getCategory(categoryName).get(propertyName).set(newValue);
      }
    }
    configuration.save();
  }
예제 #15
0
  private void loadPerms() {
    config.addCustomCategoryComment(
        "Permissions",
        "Configure ForgeEssentials Permissions. Only implemented if Permissions module is enabled.");

    Property prop = config.get("Permissions", "verbose", false);
    prop.comment =
        "Specify if Verbose mode for Permissions module is enabled. If enabled, every permission registered is printed to the console. Only useful in debugging.";
    ModulePermissions.permsVerbose = prop.getBoolean(false);
  }
예제 #16
0
 /**
  * Enables metrics for the server by setting "opt-out" to false in the config file and starting
  * the metrics task.
  *
  * @throws java.io.IOException
  */
 public void enable() throws IOException {
   // Check if the server owner has already set opt-out, if not, set it.
   if (isOptOut()) {
     configuration.getCategory(Configuration.CATEGORY_GENERAL).get("opt-out").set("false");
     configuration.save();
   }
   // Enable Task, if it is not running
   if (task == null) {
     start();
   }
 }
예제 #17
0
  private void loadCore() {
    config.addCustomCategoryComment("Core", "Configure ForgeEssentials Core.");

    Property prop = config.get("Core", "versionCheck", true);
    prop.comment = "Check for newer versions of ForgeEssentials on load?";
    ForgeEssentials.verCheck = prop.getBoolean(true);

    prop = config.get("Core", "modlistLocation", "modlist.txt");
    prop.comment =
        "Specify the file where the modlist will be written to. This path is relative to the ForgeEssentials folder.";
    ForgeEssentials.modlistLocation = prop.value;
  }
예제 #18
0
 public static void loadConf(FMLPreInitializationEvent event) {
   conf = new Configuration(event.getSuggestedConfigurationFile());
   conf.load();
   System.out.println("PumpkinHeads Mods [PumpkinAPI] - Loading Blocks Configuration");
   loadBlocksConf();
   System.out.println("PumpkinHeads Mods [PumpkinAPI] - Loading Items Configuration");
   loadItemsConf();
   System.out.println("PumpkinHeads Mods [PumpkinAPI] - Loading Other Configuration");
   loadExtraConf();
   conf.save();
   System.out.println("PumpkinHeads Mods [PumpkinAPI] - Configuration Loaded");
 }
  @PreInit
  public void preInit(FMLPreInitializationEvent event) {
    Configuration config = new Configuration(event.getSuggestedConfigurationFile());
    config.load();

    testItemId =
        config.get(Configuration.CATEGORY_ITEM, "testItem", 500 - Reference.ITEM_ID_FIX).getInt();
    ctrlKey =
        config.get(Configuration.CATEGORY_GENERAL, "useControlKeyForGui", false).getBoolean(true);

    config.save();
  }
  @Override
  public final void loadFromConfigs(Configuration config, String category) throws Exception {
    Property prop;

    String cat = category.substring(0, category.lastIndexOf('.'));

    prop = config.get(cat, "useFEDataDir", false);
    prop.comment =
        "Set to true to use the '.minecraft/ForgeEssentials/saves' directory instead of a world. Server owners may wish to set this to true.";

    useFEBase = prop.getBoolean(false);

    config.save();
  }
예제 #21
0
 @Mod.PreInit
 public static void preInit(FMLPreInitializationEvent event) {
   // Config(Ayarlar)
   Configuration config = new Configuration(event.getSuggestedConfigurationFile());
   config.load();
   ItemID = config.get("Item:", "Base Item ID", 2789).getInt();
   BlockID = config.get("Block:", "Base Block ID", 901).getInt();
   x1 = config.get("Block:", "Pressure Machine Idle ID", 901 + 34).getInt();
   x2 = config.get("Block:", "Pressure Machine Runing ID", 901 + 35).getInt();
   BiomeBlockID = config.get("Biome:", "Biome Block ID", 250).getInt();
   BiomeID = config.get("Biome:", "Biome ID", 23).getInt();
   AchievementID = config.get("Achievement:", "Base Achievement ID", 2001).getInt();
   config.save();
 }
  public static void init(File configFile) {

    configuration = new Configuration(configFile);

    try {
      configuration.load();

      /* General configs */
      ConfigurationSettings.DISPLAY_VERSION_RESULT =
          configuration
              .get(
                  CATEGORY_GENERAL,
                  ConfigurationSettings.DISPLAY_VERSION_RESULT_CONFIGNAME,
                  ConfigurationSettings.DISPLAY_VERSION_RESULT_DEFAULT)
              .getBoolean(ConfigurationSettings.DISPLAY_VERSION_RESULT_DEFAULT);
      ConfigurationSettings.LAST_DISCOVERED_VERSION =
          configuration
              .get(
                  CATEGORY_GENERAL,
                  ConfigurationSettings.LAST_DISCOVERED_VERSION_CONFIGNAME,
                  ConfigurationSettings.LAST_DISCOVERED_VERSION_DEFAULT)
              .getString();
      ConfigurationSettings.LAST_DISCOVERED_VERSION_TYPE =
          configuration
              .get(
                  CATEGORY_GENERAL,
                  ConfigurationSettings.LAST_DISCOVERED_VERSION_TYPE_CONFIGNAME,
                  ConfigurationSettings.LAST_DISCOVERED_VERSION_TYPE_DEFAULT)
              .getString();

      /* Item configs */
      ItemIds.HEART_GOLD =
          configuration
              .getItem(Strings.HEART_GOLD_NAME, ItemIds.HEART_GOLD_DEFAULT)
              .getInt(ItemIds.HEART_GOLD_DEFAULT);

      /* Block config */
      BlockIds.CHARGER =
          configuration
              .getBlock(Strings.CHARGER_NAME, BlockIds.CHARGER_DEFAULT)
              .getInt(BlockIds.CHARGER_DEFAULT);

      /* Item durability configs */
      ConfigurationSettings.HEART_GOLD_MAX_DURABILITY =
          configuration
              .get(
                  CATEGORY_DURABILITY,
                  ConfigurationSettings.HEART_GOLD_MAX_DURABILITY_CONFIGNAME,
                  ConfigurationSettings.HEART_GOLD_MAX_DURABILITY_DEFAULT)
              .getInt(ConfigurationSettings.HEART_GOLD_MAX_DURABILITY_DEFAULT);

    } catch (Exception e) {
      FMLLog.log(
          Level.SEVERE, e, Reference.MOD_NAME + " has had a problem loading its configuration");
    } finally {
      configuration.save();
    }
  }
예제 #23
0
  // this is designed so it will work for any class.
  public FEConfig() {
    OutputHandler.SOP("Loading configs");
    config = new Configuration(FECONFIG, true);
    // config.load -- Configurations are loaded on Construction.

    // load the modules
    loadModules();
    loadCore();
    loadCmd();
    loadPerms();

    // CONFIG TESTING!!!!
    /*
     * config.addCustomCategoryComment("TEST", "this is for testing...");
     * config.addCustomCategoryComment("TEST.nestedTEST", "MORE TESTING!!!");
     * config.get("TEST", "test1", false);
     * config.get("TEST", "test2", false);
     * config.get("TEST", "test3", false);
     * config.get("TEST.nestedTEST", "test1", false);
     * config.get("TEST.nestedTEST", "test2", false);
     * config.get("TEST.nestedTEST", "test3", false);
     * config.get("TEST", "testList", new String[] {"lala", "lala", "lala"});
     * config.get("TEST.nestedTEST", "testList", new String[] {"lala", "lala", "lala"});
     */

    // Finish init and save.
    config.save();
  }
예제 #24
0
  public void changeProperty(String category, String property, String newValue) {
    Property prop = config.get(category, property, newValue);
    String oldVal = prop.value;
    prop.value = newValue;

    OutputHandler.logConfigChange(category, property, oldVal, newValue);
  }
예제 #25
0
 @Override
 public void registerConfig(Configuration config, String category) {
   message =
       config.get(
               category, "Message", message, "Message to send to the player on the kick screen.")
           .value;
 }
 public static void configureIDs(Configuration config) {
   int i = 0;
   for (Item thisItem : itemList) {
     config.getItem(thisItem.getItemName(), defaultIdsList[i]);
     i++;
   }
 }
 @Override
 public void doConfig(Configuration config, String category) {
   size =
       config
               .get(
                   category,
                   "VirtualChestRows",
                   6,
                   "1 row = 9 slots. 3 = 1 chest, 6 = double chest (max size!).")
               .getInt(6)
           * 9;
   name =
       config
           .get(category, "VirtualChestName", "Vault 13", "Don't use special stuff....")
           .getString();
 }
  @Override
  public void save() {
    Property versionProp = null;

    get(CATEGORY_GENERAL, "version", ABO.VERSION);

    super.save();
  }
예제 #29
0
 public boolean get(String tag, boolean defaultValue, boolean reset, String comment) {
   comment = COMMENT_PREFIX + comment.replace("{t}", tag) + COMMENT_SUFFIX;
   Property prop = config.get(cat, tag, defaultValue);
   prop.comment = comment;
   boolean ret = parseBoolean(prop, defaultValue);
   if (reset) prop.set(defaultValue);
   return ret;
 }
  @Override
  public void forceLoad(ICommandSender sender) {
    OutputHandler.finer("Loading chatconfigs");
    config.load();

    chatFormat = config.get("Chat", "chatformat", "%prefix<%username>%suffix %white%message").value;

    Chat.censor = config.get("BannedWords", "censor", true).getBoolean(true);
    Chat.bannedWords =
        Arrays.asList(
            config.get("BannedWords", "censorList", new String[] {"f**k", "ass", "bitch", "shit"})
                .valueList);

    groupPrefixFormat =
        config.get(
                "Chat.groups",
                "groupPrefix",
                "{...<:>" + ZoneManager.getGLOBAL().getZoneName() + "}")
            .value;
    groupSuffixFormat =
        config.get(
                "Chat.groups",
                "groupSuffix",
                "{...<:>" + ZoneManager.getGLOBAL().getZoneName() + "}")
            .value;
    groupRankFormat =
        config.get("Chat.groups", "rank", "[{...<:>" + ZoneManager.getGLOBAL().getZoneName() + "}]")
            .value;
  }