#how do i check if a player takes damage?
1 messages · Page 1 of 1 (latest)
Oh no dont worry
not really sure how to check if the player takes damage or if the player does damage
so far ive made a event handler
import org.bukkit.Bukkit;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.entity.EntityDamageEvent;
public class GodMode implements Listener {
public GodMode(Main plugin){
Bukkit.getPluginManager().registerEvents(this, plugin);
}
@EventHandler
public void onPlayerDamage(EntityDamageEvent event){
}
}
That checks if entity took damage, EntityDamageByEntityEvent you can get the entity that took damage and the entity that gave damage
and to get player u can check if entity is instance of a player than u cast it
eg Player p = (Player) entity
ty for the help but ive decided to do thos another way
i want to make a boolean and if the player runs the command the boolean will be set to true
and the plugin will keep on checking if its true and when it is true itll make the player not be able to take damage or cause damage
not sure how im gonna do this part though
I wouldn't know the most efficient way
but i would make a list of players, on damage event and if the player is in the list cancel the damage
e.setCancelled(true);
inside your check
do this
oh wdym list
oh
not sure how i would pull all of the names of players that joined the server and put them in a array list
@languid oar in that case we should recommend you to learn the basics of java
Also
Why do you want to keep the player names
U should take in care that player names can change, uuid doesnt change
u don't need every player
u said u want every player who ran the command to not take damage
so only put them in the list
basically a List<UUID>
Then listen to the damage event and check if player is inside the list cancel the event, if not dont do anything
mhm
?
Why would you save full player object when you dont need it
Also it would be an overkill without being required because you only need to know his uuid to cancel the damage!
i was agreeing with u
🤦♂️