Search in sources :

Example 1 with Ravager

use of org.bukkit.entity.Ravager in project CoreProtect by PlayPro.

the class EntityChangeBlockListener method onEntityChangeBlock.

@EventHandler(priority = EventPriority.MONITOR)
protected void onEntityChangeBlock(EntityChangeBlockEvent event) {
    World world = event.getBlock().getWorld();
    if (!event.isCancelled() && Config.getConfig(world).ENTITY_CHANGE) {
        // Can be sand/gravel
        Entity entity = event.getEntity();
        Block block = event.getBlock();
        Material newtype = event.getTo();
        Material type = event.getBlock().getType();
        String e = "";
        if (entity instanceof Enderman) {
            e = "#enderman";
        } else if (entity instanceof EnderDragon) {
            e = "#enderdragon";
        } else if (entity instanceof Fox) {
            e = "#fox";
        } else if (entity instanceof Wither) {
            e = "#wither";
        } else if (entity instanceof Turtle) {
            e = "#turtle";
        } else if (entity instanceof Ravager) {
            e = "#ravager";
        } else if (entity instanceof Silverfish) {
            if (newtype.equals(Material.AIR) || newtype.equals(Material.CAVE_AIR)) {
                e = "#silverfish";
            }
        }
        if (e.length() > 0) {
            if (newtype.equals(Material.AIR) || newtype.equals(Material.CAVE_AIR)) {
                Queue.queueBlockBreak(e, block.getState(), type, block.getBlockData().getAsString(), 0);
            } else {
                queueBlockPlace(e, block.getState(), type, block.getState(), newtype, -1, 0, event.getBlockData().getAsString());
            }
        }
    }
}
Also used : Wither(org.bukkit.entity.Wither) Entity(org.bukkit.entity.Entity) Turtle(org.bukkit.entity.Turtle) EnderDragon(org.bukkit.entity.EnderDragon) Enderman(org.bukkit.entity.Enderman) Block(org.bukkit.block.Block) Material(org.bukkit.Material) Silverfish(org.bukkit.entity.Silverfish) Ravager(org.bukkit.entity.Ravager) World(org.bukkit.World) Fox(org.bukkit.entity.Fox) EventHandler(org.bukkit.event.EventHandler)

Aggregations

Material (org.bukkit.Material)1 World (org.bukkit.World)1 Block (org.bukkit.block.Block)1 EnderDragon (org.bukkit.entity.EnderDragon)1 Enderman (org.bukkit.entity.Enderman)1 Entity (org.bukkit.entity.Entity)1 Fox (org.bukkit.entity.Fox)1 Ravager (org.bukkit.entity.Ravager)1 Silverfish (org.bukkit.entity.Silverfish)1 Turtle (org.bukkit.entity.Turtle)1 Wither (org.bukkit.entity.Wither)1 EventHandler (org.bukkit.event.EventHandler)1