World Protection

Discussion in 'Spigot Plugin Development' started by DipselMedia, May 15, 2015.

  1. Hey guys,

    I am currently working on a plugin that protects all existing blocks but lets the user place his own blocks (and allow him to destroy them again).
    What it basically does is saving every block that has been placed by a user in a LinkedList and check every broken block if it is in this list:

    The player message is working, but the block isn't being restored. There is no error on the server's console. The first debug message should say that the block's material is air, as it has just been broken. But it's just the same as the old block.

    Can someone please help me?
  2. Your problem lies in the fact the block hasn't actually been broken by the time your plugin is called! So what's happening is you are getting the block at location x, y, z; replacing it with what's currently there, then bukkit trundles along afterwards and 'acts on' the event - breaking the block!

    What you need to do is, rather than changing the block is to just cancel the block break
    Code (Text):
    - flamin
  3. This works fine.
    Thanks a lot!
  4. Since it's already fixed, I don't have to help with that, but I do want to suggest you use a set, as that's the proper type of collection for what you're doing. It will also speed things up quite a bit if you're using say, a HashSet.
    • Agree Agree x 1
  5. NathanWolf


    Yes, a million times yes to what Qatell said.

    Searching through an ever-growing LinkedList for a specific block is going to get realllllyyyy slow after you've placed a few thousand blocks!
  6. Thank you for your suggestion, I've applied it.