Block Database

Discussion in 'Plugin Development' started by mydeblob, Sep 26, 2013.

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

    mydeblob

    Hello, I am making a plugin sort of like Splegg, however I want it so that after x amount of hits the block breaks, not just 1. I'm a bit confused on how to do this. Would I have to store the block locations in a file? There would be multiple blocks getting hit. Would I just store the amount of times the block is hit in a arraylist, I don't think that would work. How would I make the block not break?
    In case you don't understand my jiberish :p here is an example
    Example:
    I have a gun, that shoots eggs. After you hit a block 5 times, then it breaks. If you only hit it once it doesn't break.
     
  2. Offline

    1Achmed1

    I don't think this is possible. If it is, I recommend taking a look at the java docs for the proper listener:
    http://jd.bukkit.org/
     
  3. 1Achmed1
    No this is possible. So like in your example mydeblob , check for when an egg hits the ground and if the player has a gun and then you could save the location maybe in a file or check if it already exists. Then, with the location increase how many hits. And if when you increase the block, if the number of hits =<5 then make the block air and drop the block.
     
  4. Offline

    The_Doctor_123

    1Achmed1
    Of course it is, but it would be extremely inefficient to save/load the data in YAML files.
     
  5. Offline

    1Achmed1

  6. Offline

    remremrem

    Use each block's metadata to record the hits.

    Code:java
    1. if (!Block.hasMetadata("hitcount")){
    2.  
    3. Block.setMetadata("hitcount", 1)
    4.  
    5. }
    6.  
    7. else if(Block.getMetadata("hitcount") == 5){
    8.  
    9. break the block
    10.  
    11. }
    12.  
    13. else{
    14.  
    15. Block.setMetadata("hitcount",Block.getMetadata("hitcount")+1)
    16.  
    17. }
     
  7. Offline

    mydeblob

    remremrem
    That's a good idea. Thank you to everyone who has posted!
     
Thread Status:
Not open for further replies.

Share This Page