org.bukkit.entity.Skeleton.SkeletonType Java Examples

The following examples show how to use org.bukkit.entity.Skeleton.SkeletonType. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: SkeletonData.java    From Skript with GNU General Public License v3.0 5 votes vote down vote up
@Override
protected boolean init(final @Nullable Class<? extends Skeleton> c, final @Nullable Skeleton e) {
	if (e == null)
		return true;
	
	if (hasWither && e.getSkeletonType() == SkeletonType.WITHER)
		type = WITHER;
	if (hasStray && e.getSkeletonType() == SkeletonType.STRAY)
		type = STRAY;
	return true;
}
 
Example #2
Source File: SkeletonData.java    From Skript with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void set(final Skeleton e) {
	switch (type) {
		case WITHER:
			e.setSkeletonType(SkeletonType.WITHER);
			break;
		case STRAY:
			e.setSkeletonType(SkeletonType.STRAY);
			break;
		default:
			e.setSkeletonType(SkeletonType.NORMAL);
	}
}
 
Example #3
Source File: SkeletonData.java    From Skript with GNU General Public License v3.0 5 votes vote down vote up
@Override
protected boolean match(final Skeleton e) {
	switch (type) {
		case WITHER:
			return e.getSkeletonType() == SkeletonType.WITHER;
		case STRAY:
			return e.getSkeletonType() == SkeletonType.STRAY;
		default:
			return e.getSkeletonType() == SkeletonType.NORMAL;
	}
}
 
Example #4
Source File: Headless.java    From ce with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public void effect(Event e, ItemStack item, int level) {
    EntityDamageByEntityEvent event = (EntityDamageByEntityEvent) e;
    final Player player = (Player) event.getDamager();
    final LivingEntity ent = (LivingEntity) event.getEntity();

    new BukkitRunnable() {
        @Override
        public void run() {

            if (ent.getHealth() <= 0) {
                byte type = 3;

                if (ent instanceof Skeleton) {
                    type = 0;
                    if (((Skeleton) ent).getSkeletonType().equals(SkeletonType.WITHER))
                        type = 1;
                } else if (ent instanceof Zombie)
                    type = 2;
                else if (ent instanceof Creeper)
                    type = 4;

                ItemStack skull = new ItemStack(Material.SKULL_ITEM, 1, type);
                if (type == 3) {
                    SkullMeta sm = (SkullMeta) skull.getItemMeta();
                    sm.setOwner(ent.getName());
                    skull.setItemMeta(sm);
                }
                ent.getWorld().dropItem(ent.getLocation(), skull);
                EffectManager.playSound(player.getLocation(), "BLOCK_ANVIL_LAND", 0.1f, 1.5f);
            }
        }
    }.runTaskLater(getPlugin(), 5l);

}
 
Example #5
Source File: DMobType.java    From DungeonsXL with GNU General Public License v3.0 4 votes vote down vote up
@Override
public Entity toEntity(Location loc) {
    World world = loc.getWorld();
    GameWorld gameWorld = plugin.getGameWorld(world);
    if (gameWorld == null) {
        return null;
    }
    LivingEntity entity = (LivingEntity) world.spawnEntity(loc, type);

    /* Set the Items */
    entity.getEquipment().setItemInHand(itemHand);
    entity.getEquipment().setHelmet(itemHelmet);
    entity.getEquipment().setChestplate(itemChestplate);
    entity.getEquipment().setLeggings(itemLeggings);
    entity.getEquipment().setBoots(itemBoots);

    /* Check mob specified stuff */
    if (type == EntityType.SKELETON) {
        if (witherSkeleton) {
            ((Skeleton) entity).setSkeletonType(SkeletonType.WITHER);
        } else {
            ((Skeleton) entity).setSkeletonType(SkeletonType.NORMAL);
        }
    }

    if (type == EntityType.OCELOT) {
        Ocelot ocelot = (Ocelot) entity;
        if (EnumUtil.isValidEnum(Ocelot.Type.class, ocelotType.toUpperCase())) {
            ocelot.setCatType(Ocelot.Type.valueOf(ocelotType.toUpperCase()));
        }
    }

    /* Set Health */
    if (maxHealth > 0) {
        entity.setMaxHealth(maxHealth);
        entity.setHealth(maxHealth);
    }

    /* Disable Despawning */
    entity.setRemoveWhenFarAway(false);

    /* Spawn Mob */
    new DMob(entity, gameWorld, this);
    return entity;
}