Plugin help?

Discussion in 'Plugin Development' started by ESSHD, Mar 25, 2014.

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

    ESSHD

    I'm using:
    Craftbukkit 1.7.2
    Disguisecraft API
    And making my own kits.

    How do I remove Potion effects and Disguises (With Disguisecraft API) when they die?
    I know it's a DeathEvent handler, but I can't think how to do it...

    If you need the code for one of the free kits, you can.

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 7, 2016
  2. Offline

    ESSHD

    That's where I've been looking.... I just need to be able to remove Disguises to the regular player, and Remove Potions on death

    Would this be right?
    Code:
    Player p;
           
            public void onPlayerDeath(PlayerDeathEvent e){
                if (e.getEntity() instanceof Player){
                    PlayerUndisguiseEvent();
                    p.removePotionEffect(PotionEffectType.JUMP);
                    p.removePotionEffect(PotionEffectType.REGENERATION);
                    p.removePotionEffect(PotionEffectType.SPEED);
                    p.removePotionEffect(PotionEffectType.FIRE_RESISTANCE);
                }
            }
           
            private void PlayerUndisguiseEvent() {
     
                new Disguise(api.newEntityID(), p.getName(), DisguiseType.Player);
            }
    The Gaming Grunts
    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 7, 2016
  3. ESSHD
    Why not try it and see if it works? Also, why are you just creating a random player variable? Simply use e.getEntity() in the event or do "Player p = e.getEntity();".
     
  4. Offline

    AoH_Ruthless

    ESSHD
    Along with what The Gaming Grunts mentioned, remember to add the @EventHandler tag on your event or it won't work! (Also, register events)
     
  5. Offline

    ESSHD

    It didn't work... Got any more ideas?

    The Gaming Grunts, AoH_Ruthless?

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 7, 2016
  6. Offline

    AoH_Ruthless

    ESSHD
    Show us your code again
     
  7. Offline

    ESSHD


    Code:
            @EventHandler(priority=EventPriority.HIGH)
            public void onPlayerDeath(PlayerDeathEvent event)
            {
                Player player = event.getEntity();
                player.removePotionEffect(PotionEffectType.JUMP);
                player.removePotionEffect(PotionEffectType.REGENERATION);
                player.removePotionEffect(PotionEffectType.FIRE_RESISTANCE);
                player.removePotionEffect(PotionEffectType.SPEED);
            }
    How is this not working? I don't understand...
     
  8. Offline

    AoH_Ruthless

    ESSHD
    Did you register the event?
     
  9. Offline

    Europia79

    ESSHD

    I recently encountered a similar situation where I wanted one event to trigger another event...

    You would have to do something like this:
    Code:java
    1. CustomEvent customEvent = new CustomEvent(e.getEntity().getPlayer());
    2. Bukkit.getServer().getPluginManager().callEvent(customEvent);
    3. if (customEvent.isCancelled()) {
    4. getLogger().warning("something has attempted to cancel customEvent !");
    5. }
    6. customEvent.doSomething(args);


    Obviously, you'll want to replace CustomEvent with the specific event that you want to trigger.
    Also, for whatever Event that you want to trigger, you'll want to look at the constructors to see what parameters it takes: e.getEntity().getPlayer() was just an example parameter.

    Hopefully this helps.
     
  10. Offline

    ESSHD

Thread Status:
Not open for further replies.

Share This Page