Blocking access to chest.

Discussion in 'Plugin Development' started by Jack Price-Burns, Aug 8, 2014.

Thread Status:
Not open for further replies.
  1. Hello,

    I am getting really confused I am making a cell plugin for a prison server and I have made the cells everything works perfectly its just that people can open other peoples chests so I tried to fix it doing this.

    Code:java
    1. if(event.getAction() == Action.LEFT_CLICK_BLOCK){
    2. if(event.getClickedBlock().getType().equals(Material.CHEST)){
    3. if(!event.getPlayer().hasPermission("PrisonCells.bypass")){
    4. Location blockloc = event.getClickedBlock().getLocation();
    5. if(U.getCell(blockloc) == null){
    6. if(U.getPrison(blockloc) != null){
    7. sendMessage(event.getPlayer(), "&cYou cant open chests inside a prison");
    8. event.setCancelled(true);
    9. }
    10. } else {
    11. if(!U.canBuild((int) U.getCell(blockloc), event.getPlayer())){
    12. sendMessage(event.getPlayer(), "&cYou cant open someone else's chest");
    13. event.setCancelled(true);
    14. }
    15. }
    16. }
    17. }
    18. }


    How ever this does not seems to work :(
     
  2. Maybe add the event.setCancelled in "Can't open chest in prision" block?
     
  3. Sorry it was in, it was removed from the example -_-
     
  4. TheEpicButterStudios How would I get the inventory to close it, I have never got an inventory before.
     
  5. Code:java
    1. public boolean isHelping() {
    2. return false;
    3. }

    Jack Price-Burns I was thinking the chest inventory. Sorry I'm not much help.
     
  6. Offline

    fireblast709

Thread Status:
Not open for further replies.

Share This Page