Fix entity combustion; resolves #832

This commit is contained in:
Daniel Saukel 2020-07-14 19:43:48 +02:00
parent cfd3e026bb
commit 87fad40095

View File

@ -20,7 +20,10 @@ import de.erethon.dungeonsxl.DungeonsXL;
import de.erethon.dungeonsxl.api.world.EditWorld;
import de.erethon.dungeonsxl.api.world.GameWorld;
import org.bukkit.World;
import org.bukkit.entity.Entity;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Skeleton;
import org.bukkit.entity.Zombie;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.entity.CreatureSpawnEvent;
@ -75,22 +78,16 @@ public class DMobListener implements Listener {
}
}
// Zombie / Skeleton combustion from the sun.
// Prevent undead combustion from the sun.
@EventHandler
public void onEntityCombust(EntityCombustEvent event) {
if (plugin.getGameWorld(event.getEntity().getWorld()) != null) {
if (event instanceof EntityCombustByEntityEvent) {
return;
}
Entity entity = event.getEntity();
if ((entity instanceof Skeleton || entity instanceof Zombie) && plugin.getGameWorld(entity.getWorld()) != null) {
event.setCancelled(true);
}
}
// Allow other combustion
@EventHandler
public void onEntityCombustByEntity(EntityCombustByEntityEvent event) {
if (plugin.getGameWorld(event.getEntity().getWorld()) != null) {
if (event.isCancelled()) {
event.setCancelled(false);
}
}
}
}