Store Who Placed A Block ?

Discussion in 'Plugin Development' started by Notorious-Riddler, Jul 24, 2013.

Thread Status:
Not open for further replies.
  1. What would i use to store who placed a specific block

    and then send a player a message who placed it.
     
  2. Offline

    etaxi341

    Notorious-Riddler If there are many Blocks beeing placed at your Server you should use an MySQL Database and save the location of the block with the information of the Player that placed the block. You can get all this Information at BlockPlaceEvent.
     
  3. @etaxi cant i store the player who placed the block in life a String or hashmap or a file rather than using MySQL
     
  4. Offline

    etaxi341

    Notorious-Riddler You can save this in a hashmap but then the data would be lost on restart. And if you store it in a file your Server may lag.
     
  5. etaxi341 The problem is that i dont know how to use MySQL
     
  6. Offline

    collielimabean

    You can store data in a List<T> or Hashmap, but you need to perform serialization to keep the data across restarts.

    If you wish to go this route, look here:
    http://docs.oracle.com/javase/tutorial/jndi/objects/serial.html
     
  7. Offline

    etaxi341

  8. Offline

    Cirno

    Can't you use Metadata for this? I don't think it's persistent though.
     
  9. That's what I always use to store things like this. I can post the code here later, if anyone's interested.
     
  10. i'd like to know how you can store data in externel files (textfiles)
     
  11. Assist please do !!!!!!!!

    bump

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 3, 2016
  12. Offline

    xTrollxDudex

    Notorious-Riddler
    Bumping within 24 hours is not allowed.

    Everyone has given useful information on this thread, you have no reason to bump anyway
     


  13. Are you a mod ?
    .............
     
  14. Offline

    etaxi341

    Notorious-Riddler No he is not but the rules say you are only allowed to bump every 24 hours.
     
  15. Offline

    xTrollxDudex

    Notorious-Riddler
    Moderators have a little bar under their username that says Moderator. I think anyone that is staff, part of the bukkit team, did the bukkit docs (Sagacious_Zed) or administrator can make a final decision on a rule. I am not one, however I can inform you of the rules, or maybe a report for somethig more serious.

    I think anyone can agree that after all these people have posted good answers you can at least try one of them instead of bumping.
     
  16. Offline

    Compressions

    I would love if someone posted a tutorial over MetaData in the Resources section.
     
  17. save it in a hashmap, and on server shutdown, save it to a file. i do this with a lot of my plugins.
     

  18. then you can help me:

     
  19. Here is all the info you need. Create a new class and call it IO, paste this and use the stuff on the bottom inside on enable and disable.

    Code:java
    1. import java.io.FileInputStream;
    2. import java.io.FileOutputStream;
    3. import java.io.ObjectInputStream;
    4. import java.io.ObjectOutputStream;
    5.  
    6. public class IO
    7. {
    8. public static void save(Object obj,String path) throws Exception
    9. {
    10. oos.writeObject(obj);
    11. oos.flush();
    12. oos.close();
    13. }
    14. public static Object load(String path) throws Exception
    15. {
    16. Object result = ois.readObject();
    17. ois.close();
    18. return result;
    19. }
    20. }
    21. //saving: IO.save(Object, "path.bin");
    22. //loading: Object = (ObjectMap<object stuff>)IO.load("path.bin");
     
  20. EDIT: Re-writing code.
     
Thread Status:
Not open for further replies.

Share This Page