Need advice

Discussion in 'Plugin Development' started by neatek, Mar 17, 2012.

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

    neatek

    How i can save home position? or for example passwords for nicknames.

    who can help?

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 24, 2016
  2. Offline

    Milkywayz

    You can save strings in hash maps or arrays, but on a restart they get wiped. You can store them in a file which is what your probably looking for. I can link you to essentials spawn's code, they save the coordinates of the spawn in a yml. Here They use there own libraries and stuff so its bit confusing , You can look at java docs and look under writing to a file, and getting from a file. I will tell you that it isnt the easiest thing to do if you know more bukkit api compared to actual java
     
  3. Offline

    neatek

    i made my plugin on python, but python extension has broken... and now i want to remade python plugin on java.


    I used this way of writing.
    in python it was:
    Code:
    // create
    homes[homename] = [ x, y, z, radius, visitor, 1 ]
     
    // save
    def savehomes():
    out = io.ObjectOutputStream(io.FileOutputStream("homeguard.dat"))
    out.writeObject(homes)
    out.close()
     
    // load
     
    homes = loadhomes()
     
    def loadhomes():
        if not os.path.exists("homeguard.dat"):
            return {}
        input = io.ObjectInputStream(io.FileInputStream("homeguard.dat"))
        text = input.readObject()
        input.close()
        return text
    How it made for java? i mean only this: homes = loadhomes(), and homes[homename] = [ x, y, z, radius, visitor, 1 ]

    (How to create homes and create "key" for homes homes[homename] on java)

    I already made write object to file and load, but i dont know where i can place data from files.

    In the hope of understanding
     
  4. Offline

    Milkywayz

    hey sorry i was sleeping. ill try to figure this out for you

    Well you would use this
    PHP:
        public final boolean load(){
            if(
    last_modified != -1L && !isFileModified()){
                return 
    true;
            }
            try{
                
    load(file);
                
    clearCache();
                
    last_modified file.lastModified();
                return 
    true;
            }catch(
    Exception ex){
                
    exception ex;
                return 
    false;
            }
        }
        public final 
    boolean save(){
            try{
                
    save(file);
                
    modified false;
                return 
    true;
            }catch(
    Exception ex){
                
    exception ex;
                return 
    false;
            }
        }
    Thats jus a lil to help

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 24, 2016
  5. Offline

    neatek

    nooo))) I already have save and load file.

    I just need in create array for player data.
    This line:
    Code:
    homes[homename] = [ x, y, z, radius, visitor, 1 ]

    homes - Maybe array
    homename - Name of the player
    and other parameters - integer

    How create this on java?
     
Thread Status:
Not open for further replies.

Share This Page