Adrenaline Rush

Discussion in 'Archived: Plugin Requests' started by bikboii, Aug 25, 2012.

  1. Offline

    bikboii

    Name:
    ECAdrenaline

    Description:
    When a player's health drops down to 3 hearts, he'll gain a small 'adrenaline boost'. This 'boost' will give the player Speed I and Strength I for 5 seconds.

    Config:
    • HealthLevel: 3
    • PotionEffects:
      • speed1
      • strength1
    • Duration (seconds): 5

    Commands:
    None

    Permissions:
    • adrenaline.use
     
  2. Offline

    WarmakerT

    I'll do this.

    <Edit by Moderator: Redacted mediafire url>
    Exactly how you asked.

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Nov 9, 2016
  3. Offline

    bikboii

    [quote uid=90641003 name="WarmakerT" post=1304101]<Edit by Moderator: Redacted mediafire url>
    Exactly how you asked.[/quote]
    Thanks so much :D

    [quote uid=90641003 name="WarmakerT" post=1304101]<Edit by Moderator: Redacted mediafire url>
    Exactly how you asked.[/quote]
    Well, after testing, I checked the logs, and there didn't appear to be any errors at all, and the folder and config generated perfectly fine. The problem is, I hit one of my staff members, who I gave op to, so he had all perms. I hit him until he had 2 hearts, and he got no boost from potions at all. Any ideas?

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Nov 9, 2016
  4. Offline

    JjPwN1

    WarmakerT
    May I see your source code? I am interested on how you did this.
     
  5. Offline

    QuantumDev

    JjPwN1
    What don't you understand? He probably listened for a damage event, saw if it was a player, if it was, it would check that player's health. If the health was lower than 3 hearts, it would add those two potion effects.
     
  6. Offline

    WarmakerT

    [quote uid=90568084 name="bikboii" post=1304343]Well, after testing, I checked the logs, and there didn't appear to be any errors at all, and the folder and config generated perfectly fine. The problem is, I hit one of my staff members, who I gave op to, so he had all perms. I hit him until he had 2 hearts, and he got no boost from potions at all. Any ideas?[/quote]
    <Edit by Moderator: Redacted mediafire url>
    Forgot to register the event. It works now. I'll post the source later, I have to go.
     
    Last edited by a moderator: Nov 9, 2016
  7. Offline

    JjPwN1

    QuantumDev
    I realize that's most likely what he did. Is it a problem that I want to see the code?
     
  8. Offline

    QuantumDev

    JjPwN1
    Not a problem, I just don't understand why you'd want to see it.
     
  9. Offline

    WarmakerT

    JjPwN1
    Code:java
    1.  
    2. package me.warmakert.adrenaline;
    3.  
    4. import java.util.ArrayList;
    5. import java.util.List;
    6. import org.bukkit.entity.Player;
    7. import org.bukkit.event.EventHandler;
    8. import org.bukkit.event.Listener;
    9. import org.bukkit.event.entity.EntityDamageEvent;
    10. import org.bukkit.plugin.java.JavaPlugin;
    11. import org.bukkit.potion.Potion;
    12. import org.bukkit.potion.PotionEffect;
    13. import org.bukkit.potion.PotionEffectType;
    14.  
    15. public class Adrenaline extends JavaPlugin implements Listener {
    16.  
    17. public void onEnable(){
    18. this.getConfig().addDefault("HealthLevel", 3);
    19. List<String> list = new ArrayList<String>();
    20. list.add("strength1");
    21. list.add("speed1");
    22. this.getConfig().addDefault("PotionEffects", list);
    23. this.getConfig().addDefault("duration", 5);
    24. this.getConfig().options().copyDefaults(true);
    25. this.saveConfig();
    26. this.getServer().getPluginManager().registerEvents(this, this);
    27. }
    28.  
    29. public void onDisable(){
    30.  
    31. }
    32.  
    33. public PotionEffect getPotionByName(String name){
    34. name = name.toUpperCase();
    35. int level = name.charAt(name.length()) - 1;
    36. name = name.replaceAll(String.valueOf(name.charAt(name.length())), "");
    37. int duration = this.getConfig().getInt("duration");
    38. return new PotionEffect(PotionEffectType.getByName(name), level, duration);
    39. }
    40.  
    41. @EventHandler
    42. public void onDamage(EntityDamageEvent event){
    43. if(event.getEntity() instanceof Player){
    44. Player player = (Player) event.getEntity();
    45. if((event.getDamage() - player.getHealth() < this.getConfig().getInt("HealthLevel")) && player.hasPermission("adrenaline.use")){
    46. for(String a : this.getConfig().getStringList("PotionEffects")){
    47. player.addPotionEffect(getPotionByName(a));
    48. }
    49. }
    50. }
    51. }
    52.  
    53. }
    54.  
     

Share This Page