Java 类org.bukkit.entity.Enderman 实例源码

项目:bskyblock    文件:IslandGuard.java   
/**
 * Allows or prevents enderman griefing
 */
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
public void onEndermanGrief(final EntityChangeBlockEvent e) {
    if (DEBUG) {
        plugin.getLogger().info(e.getEventName());
    }
    if (!(e.getEntity() instanceof Enderman)) {
        return;
    }
    if (!Util.inWorld(e.getEntity())) {
        return;
    }
    // Prevent Enderman griefing at spawn
    if (plugin.getIslands() != null && plugin.getIslands().isAtSpawn(e.getEntity().getLocation())) {
        e.setCancelled(true);
    }
    if (Settings.allowEndermanGriefing)
        return;
    // Stop the Enderman from griefing
    // plugin.getLogger().info("Enderman stopped from griefing);
    e.setCancelled(true);
}
项目:bskyblock    文件:IslandGuard.java   
/**
 * Drops the Enderman's block when he dies if he has one
 *
 * @param e
 */
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
public void onEndermanDeath(final EntityDeathEvent e) {
    if (DEBUG) {
        plugin.getLogger().info(e.getEventName());
    }
    if (!Settings.endermanDeathDrop)
        return;
    if (!Util.inWorld(e.getEntity())) {
        return;
    }
    if (!(e.getEntity() instanceof Enderman)) {
        // plugin.getLogger().info("Not an Enderman!");
        return;
    }
    // Get the block the enderman is holding
    Enderman ender = (Enderman) e.getEntity();
    MaterialData m = ender.getCarriedMaterial();
    if (m != null && !m.getItemType().equals(Material.AIR)) {
        // Drop the item
        // plugin.getLogger().info("Dropping item " + m.toString());
        e.getEntity().getWorld().dropItemNaturally(e.getEntity().getLocation(), m.toItemStack(1));
    }
}
项目:GriefPreventionPlus    文件:EntityEventHandler.java   
@EventHandler(priority = EventPriority.LOWEST)
public void onEntityPickup(EntityChangeBlockEvent event)
{
    //FEATURE: endermen don't steal claimed blocks

    //if its an enderman
    if(event.getEntity() instanceof Enderman)
    {
        //and the block is claimed
        if(this.dataStore.getClaimAt(event.getBlock().getLocation(), false, null) != null)
        {
            //he doesn't get to steal it
            event.setCancelled(true);
        }
    }
}
项目:acidisland    文件:IslandGuard.java   
/**
 * Allows or prevents enderman griefing
 */
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
public void onEndermanGrief(final EntityChangeBlockEvent e) {
    if (DEBUG) {
        plugin.getLogger().info(e.getEventName());
    }
    if (!(e.getEntity() instanceof Enderman)) {
        return;
    }
    if (!inWorld(e.getEntity())) {
        return;
    }
    // Prevent Enderman griefing at spawn
    if (plugin.getGrid() != null && plugin.getGrid().isAtSpawn(e.getEntity().getLocation())) {
        e.setCancelled(true);
    }
    if (Settings.allowEndermanGriefing)
        return;
    // Stop the Enderman from griefing
    // plugin.getLogger().info("Enderman stopped from griefing);
    e.setCancelled(true);
}
项目:acidisland    文件:IslandGuard.java   
/**
 * Drops the Enderman's block when he dies if he has one
 *
 * @param e
 */
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
public void onEndermanDeath(final EntityDeathEvent e) {
    if (DEBUG) {
        plugin.getLogger().info(e.getEventName());
    }
    if (!Settings.endermanDeathDrop)
        return;
    if (!inWorld(e.getEntity())) {
        return;
    }
    if (!(e.getEntity() instanceof Enderman)) {
        // plugin.getLogger().info("Not an Enderman!");
        return;
    }
    // Get the block the enderman is holding
    Enderman ender = (Enderman) e.getEntity();
    MaterialData m = ender.getCarriedMaterial();
    if (m != null && !m.getItemType().equals(Material.AIR)) {
        // Drop the item
        // plugin.getLogger().info("Dropping item " + m.toString());
        e.getEntity().getWorld().dropItemNaturally(e.getEntity().getLocation(), m.toItemStack(1));
    }
}
项目:askyblock    文件:IslandGuard.java   
/**
 * Allows or prevents enderman griefing
 */
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
public void onEndermanGrief(final EntityChangeBlockEvent e) {
    if (DEBUG) {
        plugin.getLogger().info(e.getEventName());
    }
    if (!(e.getEntity() instanceof Enderman)) {
        return;
    }
    if (!inWorld(e.getEntity())) {
        return;
    }
    // Prevent Enderman griefing at spawn
    if (plugin.getGrid() != null && plugin.getGrid().isAtSpawn(e.getEntity().getLocation())) {
        e.setCancelled(true);
    }
    if (Settings.allowEndermanGriefing)
        return;
    // Stop the Enderman from griefing
    // plugin.getLogger().info("Enderman stopped from griefing);
    e.setCancelled(true);
}
项目:askyblock    文件:IslandGuard.java   
/**
 * Drops the Enderman's block when he dies if he has one
 *
 * @param e
 */
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
public void onEndermanDeath(final EntityDeathEvent e) {
    if (DEBUG) {
        plugin.getLogger().info(e.getEventName());
    }
    if (!Settings.endermanDeathDrop)
        return;
    if (!inWorld(e.getEntity())) {
        return;
    }
    if (!(e.getEntity() instanceof Enderman)) {
        // plugin.getLogger().info("Not an Enderman!");
        return;
    }
    // Get the block the enderman is holding
    Enderman ender = (Enderman) e.getEntity();
    MaterialData m = ender.getCarriedMaterial();
    if (m != null && !m.getItemType().equals(Material.AIR)) {
        // Drop the item
        // plugin.getLogger().info("Dropping item " + m.toString());
        e.getEntity().getWorld().dropItemNaturally(e.getEntity().getLocation(), m.toItemStack(1));
    }
}
项目:Skript    文件:EndermanData.java   
@Override
protected boolean init(final @Nullable Class<? extends Enderman> c, final @Nullable Enderman e) {
    if (e != null) {
        final MaterialData m = e.getCarriedMaterial();
        if (m != null) {
            final ItemStack i = m.toItemStack(1);
            if (i == null)
                return false;
            hand = new ItemType[] {new ItemType(i)};
        }
    }
    return true;
}
项目:Skript    文件:EndermanData.java   
@Override
public void set(final Enderman entity) {
    if (hand != null) {
        final ItemType t = CollectionUtils.getRandom(hand);
        assert t != null;
        final ItemStack i = t.getBlock().getRandom();
        if (i != null)
            entity.setCarriedMaterial(i.getData());
    }

}
项目:Skript    文件:EndermanData.java   
@Override
public boolean match(final Enderman entity) {
    return hand == null || SimpleExpression.check(hand, new Checker<ItemType>() {
        @SuppressWarnings("deprecation")
        @Override
        public boolean check(final @Nullable ItemType t) {
            return t != null && t.isOfType(entity.getCarriedMaterial().getItemTypeId(), entity.getCarriedMaterial().getData());
        }
    }, false, false);
}
项目:BlockLocker    文件:BlockDestroyListener.java   
@EventHandler(ignoreCancelled = true)
public void onEntityChangeBlock(EntityChangeBlockEvent event) {
    AttackType attackType = AttackType.UNKNOWN;
    if (event instanceof EntityBreakDoorEvent) {
        attackType = AttackType.ZOMBIE;
    } else if (event.getEntity() instanceof Enderman) {
        attackType = AttackType.ENDERMAN;
    }
    if (plugin.getChestSettings().allowDestroyBy(attackType)) {
        return;
    }
    if (isProtected(event.getBlock())) {
        event.setCancelled(true);
    }
}
项目:McMMOPlus    文件:EntityListener.java   
/**
 * Monitor EntityChangeBlock events.
 *
 * @param event The event to watch
 */
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onEntityChangeBlock(EntityChangeBlockEvent event) {
    Block block = event.getBlock();

    // When the event is fired for the falling block that changes back to a normal block
    // event.getBlock().getType() returns AIR
    if (!BlockUtils.shouldBeWatched(block.getState()) && block.getType() != Material.AIR) {
        return;
    }

    Entity entity = event.getEntity();

    if (entity instanceof FallingBlock || entity instanceof Enderman) {
        boolean isTracked = entity.hasMetadata(mcMMO.entityMetadataKey);

        if (mcMMO.getPlaceStore().isTrue(block) && !isTracked) {
            mcMMO.getPlaceStore().setFalse(block);
            entity.setMetadata(mcMMO.entityMetadataKey, mcMMO.metadataValue);
        }
        else if (isTracked) {
            mcMMO.getPlaceStore().setTrue(block);
        }
    }
    else if ((block.getType() == Material.REDSTONE_ORE || block.getType() == Material.GLOWING_REDSTONE_ORE) && (event.getTo() == Material.REDSTONE_ORE || event.getTo() == Material.GLOWING_REDSTONE_ORE)) {
        return;
    }
    else {
        if (mcMMO.getPlaceStore().isTrue(block)) {
            mcMMO.getPlaceStore().setFalse(block);
        }
    }
}
项目:modules-extra    文件:ListenerEntityBlock.java   
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onEntityChangeBlock(final EntityChangeBlockEvent event)
{
    ActionEntityBlock action;
    if (event.getEntityType() == SHEEP)
    {
        action = this.newAction(SheepEat.class, event.getBlock().getWorld());
    }
    else if (event.getEntity() instanceof Enderman)
    {
        if (event.getTo() == AIR)
        {
            action = this.newAction(EndermanPickup.class, event.getBlock().getWorld());
        }
        else
        {
            action = this.newAction(EndermanPlace.class, event.getBlock().getWorld());
        }
    }
    else
    {
        action = this.newAction(EntityChange.class, event.getBlock().getWorld());
    }
    if (action != null)
    {
        action.setNewBlock(event.getTo());
        this.setAndLog(action, event.getBlock().getState(), event.getEntity());
    }
}
项目:NPlugins    文件:EndermanGriefFlagListener.java   
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
public void onEntityChangeBlock(final EntityChangeBlockEvent event) {
    if (event.getEntityType() == EntityType.ENDERMAN) {
        final GeneralRegion region = this.getPlugin().getDb().getPriorByLocation(event.getBlock().getLocation());
        if (region != null && region.getFlag(Flag.ENDERMANGRIEF)) {
            ((Enderman)event.getEntity()).setCarriedMaterial(Material.JACK_O_LANTERN.getNewData((byte)0));
            event.setCancelled(true);
        }
    }
}
项目:Skript    文件:EndermanData.java   
@Override
public Class<Enderman> getType() {
    return Enderman.class;
}
项目:SonarPet    文件:EntityEndermanPet.java   
@Override
public Enderman getBukkitEntity() {
    return (Enderman) super.getBukkitEntity();
}
项目:CanaryBukkit    文件:CanaryEnderman.java   
public CanaryEnderman(net.canarymod.api.entity.living.monster.Enderman entity) {
    super(entity);
}
项目:CanaryBukkit    文件:CanaryEnderman.java   
protected net.canarymod.api.entity.living.monster.Enderman getHandle() {
    return (net.canarymod.api.entity.living.monster.Enderman) super.getHandle();
}
项目:PopulationDensity    文件:EntityEventHandler.java   
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onEntitySpawn(CreatureSpawnEvent event) {
    //do nothing for non-natural spawns
    if (event.getSpawnReason() != SpawnReason.NATURAL)
        return;

    if (ConfigData.managedWorld == null || event.getLocation().getWorld() != ConfigData.managedWorld)
        return;

    //when an animal naturally spawns, grow grass around it
    Entity entity = event.getEntity();
    if (entity instanceof Animals && ConfigData.regrowGrass)
        this.regrow(entity.getLocation().getBlock(), 4);

    //when a monster spawns, sometimes spawn animals too
    if (entity instanceof Monster && ConfigData.respawnAnimals) {
        //only do this if the spawn is in the newest region
        if (!Region.getOpenRegion().equals(Region.fromLocation(entity.getLocation())))
            return;

        //if it's on grass, there's a 1/100 chance it will also spawn a group of animals
        Block underBlock = event.getLocation().getBlock().getRelative(BlockFace.DOWN);
        if (underBlock.getType() == Material.GRASS && --this.respawnAnimalCounter == 0) {
            this.respawnAnimalCounter = 100;

            //check the chunk for other animals
            Chunk chunk = entity.getLocation().getChunk();
            Entity[] entities = chunk.getEntities();
            for (int i = 0; i < entities.length; i++) {
                if (entity instanceof Animals)
                    return;
            }

            EntityType animalType = null;

            //decide what to spawn based on the type of monster
            if (entity instanceof Creeper)
                animalType = EntityType.COW;
            else if (entity instanceof Zombie)
                animalType = EntityType.CHICKEN;
            else if (entity instanceof Spider)
                animalType = EntityType.PIG;
            else if (entity instanceof Enderman)
                animalType = EntityType.SHEEP;

            //spawn an animal at the entity's location and regrow some grass
            if (animalType != null) {
                entity.getWorld().spawnEntity(entity.getLocation(), animalType);
                entity.getWorld().spawnEntity(entity.getLocation(), animalType);
                this.regrow(entity.getLocation().getBlock(), 4);
            }
        }
    }
}
项目:PvPTeleport    文件:WorldCommand.java   
/** Checks that player is not trying to combatlog/is allowed to teleport
 * Returns an error message to be displayed if the player is not allowed
 * to teleport
 * Returns null if the player is allowed to teleport
 */
private static String teleportCheck(Player player) {

    Location pLoc = player.getLocation();

    World world = player.getWorld();

    /* Check if there are any players within 50 blocks */
    for (Player p : world.getPlayers()) {

        if (!p.equals(player)
                && p.getLocation().distance(pLoc) < 50
                && player.canSee(p)
                && !p.isDead()) {
            return ChatColor.RED + "You cannot use this command while within 50 blocks of any other players.";
        }

    }

    /* Check if there are any hostile mobs within 5 blocks */
    for (Entity entity : world.getEntitiesByClasses(
                Blaze.class,
                CaveSpider.class,
                Creeper.class,
                Enderman.class,
                Ghast.class,
                MagmaCube.class,
                PigZombie.class,
                Skeleton.class,
                Silverfish.class,
                Slime.class,
                Spider.class,
                Witch.class,
                Zombie.class)) {

        if (entity.getLocation().distance(pLoc) < 5) {
            return ChatColor.RED + "You cannot use this command while within 5 blocks of any hostile mobs.";
        }

    }

    /* Check if the player is falling */
    if (player.getVelocity().getY() < -0.079
            || player.getVelocity().getY() > 0.08) {
        return ChatColor.RED + "You cannot use this command while falling.";
    }

    /* Check if the player is burning */
    if (player.getFireTicks() > 0
            && !player.hasPotionEffect(
                PotionEffectType.FIRE_RESISTANCE)) {
        return ChatColor.RED + "You cannot use this command while on fire.";
    }

    /* Default to allow teleport */
    return null;

}
项目:EndHQ-Libraries    文件:RemoteEnderman.java   
public RemoteEnderman(int inID, RemoteEndermanEntity inEntity, EntityManager inManager)
{
    super(inID, RemoteEntityType.Enderman, inManager);
    this.m_entity = inEntity;
}