"passive" protection

Discussion in 'Plugin Development' started by frogawesome, Aug 9, 2013.

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

    frogawesome

    Hi, i am trying to make a plugin that makes it that if a player places a certain block on top or besides a block that he placed, will get protected. and if the block that got protected has an attached block besides or on top of it and also is placed by the same player that also gets protected etc...
    but only problem is i have no idea to do it. i tried looking into the BlockPlaceEvent but you can only do getBlockAgainst once for the block you placed. any ideas?
     
  2. frogawesome
    I didn't really understand your question/problem, but can't you use getRelatives of the BlockAgainst?
    Code:java
    1. Block b = event.getBlockAgainst();
    2.  
    3. Block c = a.getRelative(BlockFace.UP);
    4. Block d = c.getRelative(BlockFace.UP);

    Block 'c' would be the block above the block 'b', which is blockagainst, and so on.
     
  3. Offline

    lycano

    Keep a list of blocks that the player placed and cancel the respective event when a different player wants to destroy or interact with the block.

    If you want to do it right create a class that represents the player data like placed block, playername (dont store the player object!) create a class that can manage those instances and implement methods to get and add them.

    Use a Map<String, PlayerData> playerData = new HashMap<String, PlayerData>(); container to store the instances.

    Use a List<Block> blocksPlaced = new ArrayList<Block>(); to store the blocks placed inside the PlayerData class.
     
Thread Status:
Not open for further replies.

Share This Page