Make several ArrayLists stay after reload

Discussion in 'Plugin Development' started by theluckyg, Feb 23, 2014.

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

    theluckyg

    I m currently working on a reports plugin, where players can report other players for griefing, scamming, etc. When a player types /report grief playername , the playername is stored in a specific ArrayList for grief reports. It's fine until there, but the problem is the ArrayLists clear on reload, and the reports do so. Is there any way I can store ArrayLists (several) onDisable and transfer the data stored to the same ArrayLists onEnable? There's no need for the stored data to be readable outside the game.
     
  2. Offline

    iPoke111

    theluckyg
    Use a config.yml file to store them, it's perfectly possible: you just need to make a string list inside the config with each of the arraylist.toString()s.
    But I've not done it before, so you might want to get someone else to help you with that if you don't know how - I've not got so much time to experiment.
     
  3. Offline

    theluckyg

    iPoke111 the problem with that is, I've got all these ArrayLists:
    playerReportGrief
    offlineReportGrief
    playerReportSpam
    offlineReportSpam
    playerReportRuleBreaker
    offlineReportRuleBreaker
    playerReportScam
    offlineReportScam
    playerReportOther
    offlineReportOther

    And apart from that, how do I make the ArrayList restore their data after reload?
     
  4. Offline

    iPoke111

    theluckyg
    String s = "a,b,c,d,e";
    List<String> myList =newArrayList<String>(Arrays.asList(s.split(",")));
    quick google search returned this
    for every list you have saved as a string, use that.
     
  5. Offline

    theluckyg

    iPoke111 , if I change the ArrayList distribution by separating strings with commas, would things like
    Code:java
    1. if(myList.contains("something)){actions}
    still work?
     
  6. I was having this same problem lol. I was trying to save an ArrayList, but I realized I could just save individual playernames to a file as they join and leave. This here is funny lol.
     
Thread Status:
Not open for further replies.

Share This Page