Trouble Updating Plugin

Discussion in 'Plugin Development' started by iFamasssxD, Jul 15, 2013.

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

    iFamasssxD

    Hello, im trying to update SkyrimRPG and ive got it all done but there are a few problems.

    onPlayerQuit and event is called that saves the players current perks but this doesnt work anymore and this code is very outdated it seems.

    Code:
    public void savePerks(Player player)
     {
     File file = new File(this.p.getDataFolder().getPath());
        if (!file.exists()) file.mkdir();
     File perks = new File(file.getPath() + File.separator + "Perks");
       if (!perks.exists()) perks.mkdir();
        File plist = new File(perks.getPath() + File.separator + player.getName() + ".txt");
     try
       {
         if (!plist.exists())
       {
         FileOutputStream fos = new FileOutputStream(plist);
         fos.flush();
      fos.close();
      }
       BufferedWriter bw = new BufferedWriter(new FileWriter(plist));
     bw.write("#Don't edit this unless you like errors");
        bw.newLine();
        for (Perk p : ((perks).get(player).keySet()))
       {
          bw.write(p.toString() + "," + ((HashMap)this.perks.get(player)).get(p));
        bw.newLine();
     }
        bw.flush();
          bw.close();
        }
       catch (IOException ioe)
      {
        this.p.log.severe("[SkyrimRPG]COULD NOT SAVE \"" + player.getName() + "\"'s PERKS!!!");
      }
      }
    This line:
    Code:
    for (Perk p : ((perks).get(player).keySet()))
    No longer works and im not very good with Files so can you show me a work around?
     
  2. Offline

    Ewe Loon

    can you please tell us what the definition of perks is ?
    at a guess perks is a HashMap<Player,HashMap<Perk,?>>
     
  3. Offline

    ZeusAllMighty11

    Player objects will break this a lot.
     
Thread Status:
Not open for further replies.

Share This Page