Advertisement
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

[NewAPI] Ban items

Comments in 'Plugin Development' started by EkiFoX, Sep 6, 2014.

  1. EkiFoX
    Offline

    EkiFoX Active Member Plugin Developer

    Joined:
    Feb 28, 2014
    Posts:
    94
    Plugins:
    2
    Minecraft User:
    ekifox
    Hello, i get a very big problem with ban items on my server. Griefers can use bucket's on server.
    I use a many events, but all dont work.

    Code:
    public function PlayerItemConsumeEvent(PlayerItemConsumeEvent $event){
        $event->setCancelled(true);
    }
    Code:
    public function PlayerItemHeldEvent(PlayerItemHeldEvent $event){
        $event->setCancelled(true);
    }
    Code:
    public function PlayerInteractEvent(PlayerInteractEvent $event){
        $event->setCancelled(true);
    }
    And in all variants i can place and give bucket(lava, water) in my inventory.
    Server in creative mode.
    Last edited: Sep 6, 2014
  2. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,306
    Plugins:
    11
    Minecraft User:
    PEMapModder
    You cancelled all block places?
  3. EkiFoX
    Offline

    EkiFoX Active Member Plugin Developer

    Joined:
    Feb 28, 2014
    Posts:
    94
    Plugins:
    2
    Minecraft User:
    ekifox
    Yes.
  4. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,306
    Plugins:
    11
    Minecraft User:
    PEMapModder
    Then you shouldn't be able to place anything.

    And it is bucket not Bukkit.
  5. LDX
    Offline

    LDX Notable Member Plugin Developer

    Joined:
    Oct 2, 2013
    Posts:
    1,429
    Plugins:
    14
    Water and lava are not placed like regular blocks. In the old API, to prevent water and lava from being placed, you had to cancel a player.block.touch event.
    64FF00 likes this.
  6. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,306
    Plugins:
    11
    Minecraft User:
    PEMapModder
    He isn't using the place event.
    EkiFoX and LDX like this.
  7. Adaasi
    Offline

    Adaasi Active Member

    Joined:
    Aug 14, 2014
    Posts:
    78
    I think that using BlockPlace and BlockDestroy is better.
  8. EkiFoX
    Offline

    EkiFoX Active Member Plugin Developer

    Joined:
    Feb 28, 2014
    Posts:
    94
    Plugins:
    2
    Minecraft User:
    ekifox
    And how i can ban the bucket?
  9. Adaasi
    Offline

    Adaasi Active Member

    Joined:
    Aug 14, 2014
    Posts:
    78
    I don't know. But you can prevent player to get it.
  10. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,306
    Plugins:
    11
    Minecraft User:
    PEMapModder
    Check if item ID equals bucket. If true cancel event.
  11. Adaasi
    Offline

    Adaasi Active Member

    Joined:
    Aug 14, 2014
    Posts:
    78
    I think is possible
  12. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,306
    Plugins:
    11
    Minecraft User:
    PEMapModder
    LDX just reminded, bucket usages do not trigger the block place event and the block destroy event.
    64FF00 and LDX like this.
  13. Adaasi
    Offline

    Adaasi Active Member

    Joined:
    Aug 14, 2014
    Posts:
    78
    What about PlayerBucketEmptyEvent?
    I think that PocketMine Events are same as Bukkit Events
    EkiFoX and LDX like this.
  14. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,306
    Plugins:
    11
    Minecraft User:
    PEMapModder
    Read the documentation yourself. It is not necessary.
    Adaasi and 64FF00 like this.
  15. EkiFoX
    Offline

    EkiFoX Active Member Plugin Developer

    Joined:
    Feb 28, 2014
    Posts:
    94
    Plugins:
    2
    Minecraft User:
    ekifox
    [​IMG]
    In test, i cancelled all events, without all check's.
    Adaasi, 64FF00 and LDX like this.
  16. EkiFoX
    Offline

    EkiFoX Active Member Plugin Developer

    Joined:
    Feb 28, 2014
    Posts:
    94
    Plugins:
    2
    Minecraft User:
    ekifox
    I can assume that the whole problem is to intercept onActivate function in /pocketmine/item/Bucket.php
  17. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,306
    Plugins:
    11
    Minecraft User:
    PEMapModder
    And where is the onActivate function called from? It is from the Level class, right after event PlayerInteractEvent is triggered in the function useItemOn().
    Last edited: Sep 7, 2014
    EkiFoX, Adaasi, 64FF00 and 1 other person like this.

Share This Page

Advertisement