Saving and loading all Materials + Data for shop plugin.

Discussion in 'Plugin Development' started by woutwoot, Jan 2, 2014.

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

    woutwoot

    Hello,

    I'm currently rewriting my shop plugin, but I currently have a problem. I have this code:
    Code:java
    1. this.getDataFolder().mkdirs();
    2. File hs = new File(this.getDataFolder() + File.separator + "materials.properties");
    3. try {
    4. Properties props = new Properties();
    5.  
    6. for(int i = 0;i < Material.values().length; i++){
    7. props.setProperty(Material.values()[i].toString(), "" + 0.0);
    8. }
    9.  
    10. FileWriter writer = new FileWriter(hs);
    11. props.store(writer, "Do not try to edit this file manually! (Unless you're an advanced user)");
    12. writer.close();
    13. } catch (FileNotFoundException ex) {
    14. this.getLogger().warning("File not found exception!");
    15. } catch (IOException ex) {
    16. this.getLogger().warning("IO exception!");
    17. }[/i]


    Which will perfectly save all Materials to my config file, however, can this be modified so it will save blocks like stained glass with their data value if necessary? Example:
    Code:
    ...
    STAINED_GLASS:1=0.0
    STAINED_GLASS:2=0.0
    STAINED_GLASS:3=0.0
    ...
    RECORD_3=0.0
    BIRCH_WOOD_STAIRS=0.0
    REDSTONE_LAMP_ON=0.0
    GHAST_TEAR=0.0
    WOOD_SWORD=0.0
    ...
    Thanks for helping

    WoutWoot
     
  2. Offline

    Forseth11

    woutwoot get the ItemStack's data and add it to it that way.
     
  3. Offline

    woutwoot

    I don't have an actual itemstack, I just need a file which automatically contains all the materials and their (if necessarily) data values.
     
  4. Offline

    Forseth11

    woutwoot You can not get an item's data through a Material. I don't quite get what you are asking. If you are trying to do ITEMNAME:DATA then you need the data. If you are trying to do ITEM_NAME_WITH_DATA_AS_A_NAME you would still need the data, but you could use 'if' and 'case' statements to solve that problem.
     
  5. Offline

    woutwoot

    Ok, that's what I needed, so there is no way I can know if a Material needs data values for different blocks or not. Then I will indeed have to use a switch statement.
     
Thread Status:
Not open for further replies.

Share This Page