Event disables potion effects

Discussion in 'Plugin Development' started by Phoenix901, Dec 30, 2012.

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

    Phoenix901

    Hi there.
    I got a event which disable invisibility potions from being used however I ran into a problem.
    No matter what I do I can't seem to allow people to apply any kind of potion, it cancel them all out.
    I can trow potions which isn't invisibility potions but their effect doesn't work.
    here is my event

    Code:java
    1. @EventHandler
    2. public void onDispense(BlockDispenseEvent event) {
    3. if(this.plugin.getConfig().getString("enabled").equalsIgnoreCase("true") && playerBypass == false) {
    4. String world = event.getBlock().getWorld().getName();
    5. ItemStack it = event.getItem();
    6. Material mat = it.getType();
    7.  
    8. if(!(this.plugin.getConfig().getString("worlds."+world) == null)) {
    9. if(this.plugin.getConfig().getString("worlds."+world).equalsIgnoreCase("true")) {
    10. if (mat == Material.POTION) {
    11. Potion potion = Potion.fromItemStack(it);
    12. PotionEffectType effecttype = potion.getType().getEffectType();
    13.  
    14. if (effecttype == PotionEffectType.INVISIBILITY) {
    15. event.setCancelled(true);
    16. }
    17. }
    18. }
    19. }
    20. }
    21. }


    Any help is greatly appreciated.

    I've solved the problem myself after looking around for a few hours.
     
  2. Offline

    Nitnelave

    You can mark it solved.
     
Thread Status:
Not open for further replies.

Share This Page