Spigot 1.8.8, Minecraft turn off PVP from a certain height?

Da
2

How can Minecraft show PvP from a certain height?

I tried this like this:

double y = 201;

@EventHandler
public void onEntityDamage (EntityDamageByEntityEvent e) {

Entity en = e.getEntity ();
if (en.getLocation (). GetY ()> y) {

e.setCancelled (true);

}

}

but unfortunately it doesn't work that way…

I thank you in advance.

an

Looks right - the question arises why it doesn't work.

Have you debugged a bit? If only with System.out.println (). Just see what exactly is not working by having something displayed at each point. Then you know where the mistake is.

double y = 201;
System.out.println ("Loading");

@EventHandler
public void onEntityDamage (EntityDamageByEntityEvent e) {
System.out.println ("Event is being called");
Entity en = e.getEntity ();
if (en.getLocation (). GetY ()> y) {
System.out.println ("Condition works too");
e.setCancelled (true);

}

Da

Thank you