Any Ways to Store Info That is Persistent Through Reloads?

Discussion in 'Plugin Development' started by mattrick, Nov 11, 2013.

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

    mattrick

    Hi there!
    I am making a plugin that stores information about the server in user reviews. So basically I want to the servers review information in such a way that is 1. Persistent through reloads and 2. Not editable by the owner, so that way they can not give their server 5 stars in a yml file. Also, though I have one, I'd prefer not to use a MySQL server. Any ideas on how to do this? (I might end up just using my MySQL database, so I can have webstats :D)
     
  2. Offline

    nlthijs48

    You could try to save an object to a file, very hard to edit if opened with notepad, but very easy to read with your plugin.
    Saving:

    Code:java
    1. try {
    2. output = new ObjectOutputStream(new FileOutputStream("pathtofile"));
    3. output.writeObject(Object);
    4. output.close();
    5. } catch (IOException e) {
    6. plugin.getLogger().info("File could not be saved: " + "pathtofile");
    7. }


    Loading:

    Code:java
    1. try {
    2. input = new ObjectInputStream(new FileInputStream("pathtofile"));
    3. object = (Object)input.readObject();
    4. input.close();
    5. plugin.getLogger().info("Error: Something went wrong reading file: " + "pathtofile");
    6. }
     
  3. Offline

    RealDope

    What do you intend to do with these reviews? Pretty sure Bukkit won't allow you to "phone home" with information about a server that isn't anonymous.
     
  4. Offline

    CubieX

    If you want this information beeing accessible through some website, storing this data in a central MySQL database on your server is the best way.
    To prevent people to get your database login information, you would have to use a webserver to communicate with.
    So you can send or read data from your database by making requests to your webserver.
    Just like every PHP homepage with a background database works.
     
  5. Offline

    mattrick

    Its basically a Minecraft server list plugin, but instead uses reviews from in game and not online.

    They could decompile it though.

    I'm thinking of just using that, problem is my server's website is already hosted on it. I guess I could make a virtual host and a new database, still that's a lot of work (and I don't understand virtual hosts, I almost broke Apache trying to set one up :rolleyes: )
     
Thread Status:
Not open for further replies.

Share This Page