mirror of
https://github.com/EssentialsX/Essentials.git
synced 2025-02-02 13:31:54 +01:00
Add potion effect clearing on /heal - Chris Ward
This commit is contained in:
parent
db6512b702
commit
c0a176825c
@ -15,8 +15,6 @@ import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason;
|
||||
import org.bukkit.event.entity.*;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.potion.PotionEffect;
|
||||
import org.bukkit.potion.PotionEffectType;
|
||||
|
||||
|
||||
public class EssentialsEntityListener implements Listener
|
||||
@ -170,14 +168,10 @@ public class EssentialsEntityListener implements Listener
|
||||
{
|
||||
for (LivingEntity entity : event.getAffectedEntities())
|
||||
{
|
||||
if (entity instanceof Player)
|
||||
if (entity instanceof Player && ess.getUser(entity).isGodModeEnabled())
|
||||
{
|
||||
User user = ess.getUser(entity);
|
||||
if (user.isGodModeEnabled())
|
||||
{
|
||||
event.setIntensity(entity, 0d);
|
||||
}
|
||||
event.setIntensity(entity, 0d);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -6,6 +6,8 @@ import java.util.List;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.potion.PotionEffect;
|
||||
import org.bukkit.potion.PotionEffectType;
|
||||
|
||||
|
||||
public class Commandheal extends EssentialsCommand
|
||||
@ -33,9 +35,7 @@ public class Commandheal extends EssentialsCommand
|
||||
{
|
||||
user.healCooldown();
|
||||
}
|
||||
user.setHealth(20);
|
||||
user.setFoodLevel(20);
|
||||
user.sendMessage(_("heal"));
|
||||
healPlayer(user);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -63,10 +63,19 @@ public class Commandheal extends EssentialsCommand
|
||||
{
|
||||
continue;
|
||||
}
|
||||
p.setHealth(20);
|
||||
p.setFoodLevel(20);
|
||||
p.sendMessage(_("heal"));
|
||||
healPlayer(p);
|
||||
sender.sendMessage(_("healOther", p.getDisplayName()));
|
||||
}
|
||||
}
|
||||
|
||||
private void healPlayer(final Player p)
|
||||
{
|
||||
p.setHealth(20);
|
||||
p.setFoodLevel(20);
|
||||
p.sendMessage(_("heal"));
|
||||
for (PotionEffect effect : p.getActivePotionEffects())
|
||||
{
|
||||
p.removePotionEffect(effect.getType());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user