Solved Chest Locking Broken?

Discussion in 'Plugin Development' started by opd02, May 5, 2019.

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

    opd02

    So I have been doing some work, trying to lock a chest with the .setLock(String) method and its not locking the chest. It is giving no error message or anything in the console, it simply is not locking the chest in the game with the string. I have tried almost everything and I am just about convinced that bukkit has a bug with the locking method. Thoughts?
    Code:
                    Chest chest = (Chest) p.getTargetBlockExact(100).getState();
                    if(chest.isLocked()){
                        p.sendMessage(ChatColor.RED + "This chest is already locked!");
                        return true;
                    }
                    String pass = args[0].toString();
                    chest.setLock(pass);
     
  2. Offline

    KarimAKL

    @opd02 Are you sure the code is executed?
     
  3. Offline

    opd02

    @KarimAKL Yes, I did test that. I changed it to
    if(!(chest.isLocked())){
    p.sendMessage(“Blah”);
    }

    And the message was sent. If you could try it out on your own is see if it works I would appreciate it so much :D I think next I’m going to try different versions of bukkit, see if that works for some reason lol
     
  4. Offline

    timtower Ninja on the waves Moderator

    @opd02 Add chest.update() to the end of the function.
     
  5. Offline

    opd02

    @timtower that was the magical phrase! That did it! Thank you so much! Couldn't find that anywhere!
     
    timtower likes this.
Thread Status:
Not open for further replies.

Share This Page