import org.bukkit.entity.Entity;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Warden;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.entity.EntityDamageEvent;
import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;
public class Regen implements Listener {
@EventHandler
public void onDamage(EntityDamageEvent e){
if (e.getEntity().getType() == EntityType.WARDEN){
if (e.getCause() == EntityDamageEvent.DamageCause.ENTITY_ATTACK){
PotionEffect effect = new PotionEffect(PotionEffectType.REGENERATION, 10, 2);
effect.apply((LivingEntity) Warden);
}
}
}
}```
#Can anyone tell me whats wrong with my code?
1 messages · Page 1 of 1 (latest)
how do I do that
xd
check #help-development toto sent
lmfao
yeh
Havent read code tho cause discord doesnt have line coints
its actually on LivingEntity
i guess ide is old and doesnt like multi line expressions :/
What do I do in ? paste
what ide are you using actually?
paste the code save and copy the link
IntelliJ IDEA
your applaying a Entity as a potion effect
wait
tf
ahh
Warden
is not valid
you need its actual instance
not its class name
e.getEntity()
^
my lazy ass was reading over it
do I replace Warden with e.getEntity?
yessir
Warden is its type/class name, and not an actual entity thats loaded into the world
e.getEntity() is a real entity in the world
im sure anyone in this thread is more than capable to answer a question if im not :))
#1001384149246038048 and see the code in there, shits atrocious 
What were the other questions you had?
:d for the pathfinder its good its bad if u want to have a more complicated but its good
nah it just follows basic survival rules
eg dont fall down more than 4 blocks
and it avoids water/lava
all it rly needs atm
then its good to me the function is the first then the pretty code i never judge a code for it look to me the first is the function
not the look
i need to go! gl for this thread!
does anyone here know how to check for if the health is below 100?
so I found a solution to it but it gives me an error https://paste.md-5.net/buxahoqido.java it says Not a Statment
Are you on 1.19 by chance
yes
okay 2 things
uhh learn java
your instanceof check can be better with newer java syntax's and lets you not need to cast
if (e.getEntity() instanceof LivingEntity theEntity) {
((Damagable) theEntity).getMaxHealth();
}
2nd
use Damagable
it extends LivingEntity so you can cast it
in fact if you only need Damagable
just instanceof Damageable on e.getEntity()
ok thanks
oh one more thing
it flags Damagable
theres 2 types of Damagable one for entity one for inventory
make sure your using the entity one:
https://hub.spigotmc.org/javadocs/spigot/org/bukkit/entity/Damageable.html
declaration: package: org.bukkit.entity, interface: Damageable
btw if your needing MaxHealth, youll need to use the Attribute API
but for current health you use damageable
https://paste.md-5.net/epiqigubar.java
It says Patterns in instanceof are not supported at language level 8
put your java version higher
ok