Solved Protect Flower Pot

Discussion in 'Plugin Development' started by VENTO, Jun 19, 2017.

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

    VENTO

    Hello everybody!

    I want to protect flower pot from taking flowers from it.

    I tried to use PlayerInteractEvent but it doesn't work.

    How can I disable interractions with flower pot?

    Thanks in advance.
     
    Last edited: Jun 19, 2017
  2. Offline

    RcExtract

    What is ur current code?

    Also, getting the contents of the flower pot may help you (FlowerPot.getContents())

    Sent from my LG-H860 using Tapatalk
     
  3. Offline

    VENTO

    Code:
    @EventHandler
        public void onInteract(PlayerInteractEvent e) {
            if (e.getClickedBlock() != null && e.getClickedBlock().getType() == Material.FLOWER_POT && e.getAction() == Action.RIGHT_CLICK_BLOCK) {
                e.setCancelled(true);
            }
        }
    Version 1.11
     
  4. Offline

    Zombie_Striker

    @VENTO
    Are you sure the event is called? Have you tried quitting and re-logging back onto the server (it may be a graphical glitch)?
     
  5. Offline

    VENTO

    Yes, I'm sure. I also tried to cancel all events of PlayerInteractEvent but I can interact with flower pots.
     
  6. Offline

    Horsey

    @VENTO is the event firing though? Maybe you forgot the @EventHandler or the registerEvent.
     
  7. Offline

    VENTO

    No, I didn't forgot register and @EventHanlder.

    As I said I tried this code:
    Code:
    @EventHandler
    public void onInteract(PlayerInteractEvent e) {
        e.setCancelled(true);
    }
    I couldn't interact with anything except a flower pot.

    UP!

    Any ideas?

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 20, 2017
  8. Offline

    RcExtract

    Does material represents an item in an inventory only? Or also placed blocks? I found an interface FlowerPot. Try it.

    Sent from my LG-H860 using Tapatalk
     
  9. Offline

    VENTO

    Like this?
    Code:
    if (e.getClickedBlock() instanceof FlowerPot) {
    This doesn't work. :(
     
  10. Offline

    didjee2

    Did you found out how to block it?

    If I cancel PlayerInteractEvent, the flower disappears from the FlowerPot, and you do not get it in your inventory.

    The only thing I can think of right now is maybe getting the FlowerPot contents & setting them some ticks after again (but I still have to try it out).
     
  11. Offline

    VENTO

    I only cancell the event. And it's visual bug. If you rejoin - the flower will be the pot.
     
Thread Status:
Not open for further replies.

Share This Page