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
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.
[quote uid=90641003 name="WarmakerT" post=1304101]<Edit by Moderator: Redacted mediafire url> Exactly how you asked.[/quote] Thanks so much [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.
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.
[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.
JjPwN1 Code:java package me.warmakert.adrenaline; import java.util.ArrayList;import java.util.List;import org.bukkit.entity.Player;import org.bukkit.event.EventHandler;import org.bukkit.event.Listener;import org.bukkit.event.entity.EntityDamageEvent;import org.bukkit.plugin.java.JavaPlugin;import org.bukkit.potion.Potion;import org.bukkit.potion.PotionEffect;import org.bukkit.potion.PotionEffectType; public class Adrenaline extends JavaPlugin implements Listener { public void onEnable(){this.getConfig().addDefault("HealthLevel", 3);List<String> list = new ArrayList<String>();list.add("strength1");list.add("speed1");this.getConfig().addDefault("PotionEffects", list);this.getConfig().addDefault("duration", 5);this.getConfig().options().copyDefaults(true);this.saveConfig();this.getServer().getPluginManager().registerEvents(this, this);} public void onDisable(){ } public PotionEffect getPotionByName(String name){name = name.toUpperCase();int level = name.charAt(name.length()) - 1;name = name.replaceAll(String.valueOf(name.charAt(name.length())), "");int duration = this.getConfig().getInt("duration");return new PotionEffect(PotionEffectType.getByName(name), level, duration);} @EventHandlerpublic void onDamage(EntityDamageEvent event){if(event.getEntity() instanceof Player){Player player = (Player) event.getEntity();if((event.getDamage() - player.getHealth() < this.getConfig().getInt("HealthLevel")) && player.hasPermission("adrenaline.use")){for(String a : this.getConfig().getStringList("PotionEffects")){player.addPotionEffect(getPotionByName(a));}}}} }