EasyConfig 2.1

Discussion in 'Resources' started by codename_B, Aug 25, 2012.

Thread Status:
Not open for further replies.
  1. Offline

    aviator14

    I thought the point was that this wasn't supposed to touch transient fields? But when I set a transient field (I NEED a reference to my main class to use getBoolean and getString), it not only reads that field, but it also tries to read all the fields from my main function.

    This
    Code:java
    1. public transient ZeoldFeatures zf = null;
    2. public boolean mobProtect_animals = true;
    3. public boolean mobProtect_npcs = true;
    4. public boolean mobProtect_golems = true;
    5. public boolean mobProtect_monsters = false;
    6. public boolean creative_preventDrops = true;
    7. public boolean creative_useWorldGuard = true;
    8. public String listedMOTD = "The best server!";
    9.  
    10. public ConfigZ(ZeoldFeatures plugin) {
    11. this.zf = plugin;
    12. this.setFile(plugin);
    13. }


    Results in
    Code:
    zf: &id001 !!com.zeoldcraft.zeoldfeatures.ZeoldFeatures
      ap: false
      gp: false
      mp: false
      naggable: true
      vp: false
      zu:
        zf: *id001
    Is that not how you set transient fields?

    Edit: the problem was a missing 'else' in the onLoad(File) method, like how Icyene's has it. Without that, the result of doSkip is not respected.
     
  2. Offline

    brord

    I dont really understaind how to make multiple configuratiosn with this, like a player.yml
    Could anyone help me out with that?

    Why do configs have to be so hard >_<
     
  3. Offline

    iTidez

    brord

    Its very simple to do! Simply switch out the plugin reference and add a String or File reference instead. Like so:
    Code:
    public class ConfigHandler extends Config {
     
    public int test_test = 5;
     
    public ConfigHandler(String fileName) {
    this.setFile(fileName);
    }
     
    public int getRefs() {
    return test_test;
    }
     
    public void addRef(int amount) {
    this.test_test = test_test + amount;
    }
    }
     
    //Then call this from anywhere:
    ConfigHandler config = new ConfigHandler("player.yml");
    
    Now,

    codename_B
    Is it possible to do something like the following:
    Code:
    public transient List<Player> playerList = new ArrayList<Player>();
    public HashMap<String, List> = new HashMap<String, List>();
    I am trying to make a private warping plugin, kind of like the player above was trying to do, however I want a list of Players saved with it. Does your lib also serialize Lists contained in HashMaps, or does it do that already with the HashMap support?
     
  4. Offline

    brord

    Ooooh i was allready wondering why that plugin reference was there :)
    Thanks!
     
  5. Offline

    iTidez

    brord

    Sure thing, happy to help out a fellow developer in need :) If you have any more questions, feel free to ask them!
     
  6. Offline

    Chrono7

    This config literally made my day! It makes loading information soooo much easier.

    I used it to load user-created config files from a folder, so that the user can create unlimited(ish) actions for my new plugin.

    Thanks a ton!
     
  7. Offline

    IDragonfire

Thread Status:
Not open for further replies.

Share This Page