Storing blocks & particles

Discussion in 'Plugin Development' started by sgavster, Nov 12, 2013.

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

    sgavster

    Hi!

    I was playing around with some things, and I was wondering:

    I want to have a when a player places a block with ItemMeta(in their hand), it would be stored to a file (or MYSQL). And I could play special particles there. BUT! I want to be-able to remove them, also.

    if someone could give me an example, that would be amazing!

    And, I was wondering how to play effects like a villager angy effect, or a villager happy effect, or heart effect. If someone could give me an example, that would be amazing! Thanks!
     
  2. Offline

    Xacero

    sgavster
    Sorry, where is there?
     
  3. Offline

    sgavster

    Xacero At the 'special' block :p
    Sorry for not being so specific
     
  4. Offline

    Xacero

    sgavster
    That's okay, thank you for clearing that up :)
    Is this what you want?

    Writing is the same but with BufferedWriter.
    newline characters are done with writer.newLine();
    on close do writer.flush(); writer.close();

    remember to catch all exceptions. :)
    You'll need to parse the data yourself.
     
  5. Offline

    sgavster

    Xacero well, not really, I can make a file, I just need to know how to store the block, and remove it when I need it
     
  6. Offline

    exload

    Just store the block location and play the effect if the player gets in range of it.

    To store a location you could use something like this
    Code:java
    1. /**
    2.   * Saves a Bukkit location
    3.   * @param location Bukkit Location to be saved
    4.   * @return Location in its save format
    5.   */
    6. public static String saveLocation(Location location)
    7. {
    8. return location.getWorld().getName()+";"+location.getBlockX()+";"+location.getBlockY()+";"+location.getBlockZ();
    9. }
     
  7. Offline

    sgavster

    exload how would I get that location from a config for example?
     
  8. Offline

    xTrollxDudex

    sgavster
    PHP:
    public Location deserializeLoc(String s) {
        
    String[] st s.split(";");
        return new 
    Location(Bukkit.getServer().getWorld(st[0]), Integer.parseInt(st[1]), Integer.parseInt(st[2]), Integer.parseInt(st[3]));
    }
     
  9. Offline

    sgavster

    xTrollxDudex exload Xacero Thanks!
    Do you know how to play the effects that I said in the OP?
    Code:
    like a villager angy effect, or a villager happy effect, or heart effect
     
  10. Offline

    xTrollxDudex

  11. Offline

    exload

  12. Offline

    DarkBladee12

    sgavster Take a look at this thread for more information about my ParticleEffect library! It's version proof and easy to use ;) If you want to store a ParticleEffect, reply me and I'll setup a class on Gist which allows you to serialize/deserialze the data which is needed to play a ParticleEffect!
     
    fromgate likes this.
  13. Offline

    sgavster

    DarkBladee12 I'd love that :D

    DarkBladee12 So, how would I use this to get the location and play the effect? I play for a while, but I can't seem to figure it out. I was going to use a Runnable, but I can't figure out how to get the strings from the config

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

    fromgate

  15. Offline

    DarkBladee12

    sgavster I just wrote some classes that allow you to store the attributes of a ParticleEffect. These can be serialized and deserialized so you can easily save them in a config, flatfile or whatever!
     
Thread Status:
Not open for further replies.

Share This Page