Right click, one time use.

Discussion in 'Plugin Development' started by GamerX, Apr 6, 2011.

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

    GamerX

    I'm working on a plugin that gives you a book when you click a sign.
    But only one time use.

    So what do i have to import?
    I've made a GitHub Repositories, so please help me with code.
    I hope I've done it right with permissions.

    LINK TO REPOSITORIES
     
  2. Offline

    Canownueasy

    Create a map of names->boolean

    Code:
    HashMap<String,Boolean> data = new HashMap<String,Boolean>();
    And then you can save it to a text file:
    Code:
    public void save() throws Exception() {
        BufferedWriter writer = new BufferedWriter(new FileWriter(new File("booksign.properties")));
        for(Entry<String,Boolean> entry : data) {
            writer.write(entry.getKey() + ":" + entry.getValue()); writer.newLine();
        }
    }
    And to read it.
    Code:
    public void load() throws Exception() {
        BufferedReader reader = new BufferedReader(new FileReader(new File("booksign.properties")));
        String line = null;
        while((line = reader.readLine()) != null) {
            String[] args = line.split(":");
            data.put(args[0],Boolean.parseBoolean(args[1]));
        }
    }
    Your welcome :D
     
Thread Status:
Not open for further replies.

Share This Page