Filled Regeneration on kill

Discussion in 'Plugin Requests' started by Rowinvd, Jan 28, 2015.

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

    Rowinvd

    Warning: This is written on my ipad, so the format is not really good!


    Name:
    KillRegeneration

    What i want:

    A player kills a player. The killer gets a message: "(GREEN) You killed (PLAYER) and recieved Regeneration II for 5 seconds" and gets the regeneration. And he gonna hear a Level_up sound.

    Commands & permissions
    None!
     
  2. Offline

    pie_flavor

    Easy as pie. ~10 minutes
    Do you want me to include the spelling mistake in "received"?

    KillRegen.jar
     
    Last edited by a moderator: Jan 28, 2015
    Experminator and GrandmaJam like this.
  3. Offline

    xTyrael

    Is regeneration III ):
     
  4. Offline

    mrCookieSlime

    @pie_flavor
    Probably forgotten that Java is zero-indexed ;) This also applies for potioneffects.
    0 = 1
    1 = 2
    etc
     
  5. Offline

    pie_flavor

    @mrCookieSlime Thx, I was wondering about that. I was gonna put 1, but it didn't say anything in the Javadoc.

    @xTyrael redownload for fix

    EDIT by Timtower: merged posts
     
    Last edited by a moderator: Jan 28, 2015
  6. Offline

    StefanXX

    Code:
     if ((e.getEntity().getLastDamageCause() instanceof EntityDamageByEntityEvent))
        {
          EntityDamageByEntityEvent e2 = (EntityDamageByEntityEvent)e.getEntity().getLastDamageCause();
          {
    you can replace all that with just e.getEntity().getKiller()
     
  7. Offline

    pie_flavor

    @StefanXX First of all, how did you get that?
    Second, getKiller() will get the last player that killed that player, whether or not the player actually was killed and didn't just die. They could've got in a shoving match with a cactus, they could've forgotton their parachute, they could've found beef with a creeper, but getKiller will always get the last player to kill them.
     
  8. Offline

    Experminator

    @pie_flavor So for example: When a player hit you, and you walk 10 minutes later in lava (Without hitted by another player) then it would get the player that you hit 10 minutes ago?
     
  9. Offline

    StefanXX

    I don't know what is your problem with it that is the right way to do it!, and I used a decompiler lol
     
  10. Offline

    pie_flavor

    @Experminator Not exactly hit specifically, but killed, yes.
    @StefanXX Read Experminator's post, if you didn't understand mine.
     
    Last edited: Jan 28, 2015
  11. Offline

    Rowinvd

    I gonna test the plugin now!

    Its working! thanks!

    @pie_flavor its working but i'f you kill someone with a bow, you're not getting regen.

    EDIT by Timtower: merged posts
     
    Last edited by a moderator: Jan 29, 2015
  12. Offline

    Experminator

    @Rowinvd @pie_flavor Easy to fix (You know the rest):
    Code:
    @EventHandler
    public void onDeath(EntityDeathEvent e){
        if(e.getEntity() instanceof Player && e.getEntity().getKiller() instanceof Arrow){
           Player k = (Player) e.getEntity().getKiller().getShooter();
        
           k.addPotionEffect(new PotionEffect(PotionEffectType.REGENERATION, 2, 125));
        }
    }
    This should work, tell me if not.
     
    Last edited: Jan 29, 2015
  13. Offline

    timtower Administrator Administrator Moderator

    @Experminator When using bows the killer would be an arrow. Not a player.
     
  14. Offline

    Rowinvd

    Thanks all!
     
  15. Offline

    Experminator

    @Rowinvd No problem. Thanks for saying Thanks xD
     
  16. Offline

    Rowinvd

    @Experminator Hmm can you make if a player kills a player the killer gets a heal and not regen? And its also detecting bow kills or potion kills? Sorry i'f i'm questing too much :p
     
  17. Offline

    Experminator

    @Rowinvd I don't make the plugin. That's the work of @pie_flavor.
    I said only what it does. And how it can.
     
  18. Offline

    Rowinvd

    Oh fail @pie_flavor Can you make if a player kills a player the killer gets a heal and not regen? And its also detecting bow kills or potion kills?
     
  19. Offline

    pie_flavor

    @Rowinvd Hmm. I can do the heal thing - How much? I'm gonna start with 3 hearts. But the potion, as well as arrows, might be harder.

    EDIT: Oh my lord. There're two different getShooter methods here. One returns LivingEntity, the other returns ProjectileSource. How'd they even get that to compile?
     
    Last edited: Jan 29, 2015
  20. @Rowinvd Please try this
    Code:
     public void onPlayerDeath(PlayerDeathEvent e)
      {
          Player p = e.getEntity().getPlayer();
          Player k = e.getEntity().getKiller();
        e.setDeathMessage(ChatColor.RED + "[" + ChatColor.GOLD + "PVP" + ChatColor.RED + "] " + ChatColor.RED + p.getName() + " " + ChatColor.AQUA + "Has Killed By " + ChatColor.GREEN + k.getName());   
        e.getEntity().getKiller().sendMessage(ChatColor.RED + "[" + ChatColor.GOLD + "PVP" + ChatColor.RED + "] " + ChatColor.GRAY + "You Have Killed " + ChatColor.AQUA + p.getName());
        e.getEntity().getKiller().addPotionEffect(new PotionEffect(PotionEffectType.SPEED, 25, 2));
        e.getEntity().getKiller().addPotionEffect(new PotionEffect(PotionEffectType.REGENERATION, 5, 3));
      }
     
Thread Status:
Not open for further replies.

Share This Page