Fixed missile breaking blocks

This commit is contained in:
Auxilor 2020-11-07 13:48:59 +00:00
parent 1e1af832e4
commit 2fbef163c2

View File

@ -8,6 +8,7 @@ import org.bukkit.entity.WitherSkull;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.event.entity.EntityExplodeEvent;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.metadata.FixedMetadataValue;
@ -22,6 +23,7 @@ public class Missile extends Spell {
skull.setCharged(true);
skull.setIsIncendiary(false);
skull.setMetadata("eco-damage", new FixedMetadataValue(EcoEnchantsPlugin.getInstance(), this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "damage-per-level") * level));
skull.setMetadata("nobreak", new FixedMetadataValue(EcoEnchantsPlugin.getInstance(),true));
skull.setShooter(player);
}
@ -34,4 +36,12 @@ public class Missile extends Spell {
event.setDamage(multiplier);
}
@EventHandler
public void onWitherSkullExplode(EntityExplodeEvent event) {
if(!(event.getEntity() instanceof WitherSkull)) return;
if(event.getEntity().getMetadata("nobreak").isEmpty()) return;
event.setCancelled(true);
}
}