org.bukkit.inventory.EntityEquipment Java Examples

The following examples show how to use org.bukkit.inventory.EntityEquipment. 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: EquipmentSlot.java    From Skript with GNU General Public License v3.0 9 votes vote down vote up
@Override
@Nullable
public ItemStack get(EntityEquipment e) {
	if (Skript.isRunningMinecraft(1, 9)) {
		return e.getItemInOffHand();
	}
	Skript.warning("No off hand support, but a skript would need that!");
	return new ItemStack(Material.AIR);
}
 
Example #2
Source File: SentinelUtilities.java    From Sentinel with MIT License 7 votes vote down vote up
/**
 * Returns whether an entity is invisible (when invisible targets are ignorable).
 */
public static boolean isInvisible(LivingEntity entity) {
    if (!SentinelPlugin.instance.ignoreInvisible
            || !entity.hasPotionEffect(PotionEffectType.INVISIBILITY)) {
        return false;
    }
    EntityEquipment eq = entity.getEquipment();
    if (eq == null) {
        return true;
    }
    if (SentinelVersionCompat.v1_9) {
        if (!isAir(eq.getItemInMainHand()) || !isAir(eq.getItemInOffHand())) {
            return false;
        }
    }
    else {
        if (!isAir(eq.getItemInHand())) {
            return false;
        }
    }
    return isAir(eq.getBoots()) && isAir(eq.getLeggings()) && isAir(eq.getChestplate()) && isAir(eq.getHelmet());
}
 
Example #3
Source File: CondItemInHand.java    From Skript with GNU General Public License v3.0 6 votes vote down vote up
@Override
public boolean check(final Event e) {
	return entities.check(e,
			en -> types.check(e,
					type -> {
						EntityEquipment equipment = en.getEquipment();
						if (equipment == null)
							return false; // No equipment -> no item in hand
						
						if (Skript.isRunningMinecraft(1, 9)) {
							return (offTool ? type.isOfType(equipment.getItemInOffHand()) : type.isOfType(equipment.getItemInMainHand()));
						} else {
							@SuppressWarnings("deprecation")
							ItemStack itemInHand = equipment.getItemInHand();
							
							return type.isOfType(itemInHand);
						}
					}), isNegated());
}
 
Example #4
Source File: CondIsWearing.java    From Skript with GNU General Public License v3.0 6 votes vote down vote up
@Override
public boolean check(final Event e) {
	return entities.check(e,
			en -> types.check(e,
					t -> {
						EntityEquipment equip = en.getEquipment();
						if (equip == null)
							return false; // No equipment -> not wearing anything
						for (final ItemStack is : equip.getArmorContents()) {
							if (t.isOfType(is) ^ t.isAll())
								return !t.isAll();
						}
						return t.isAll();
					}),
			isNegated());
}
 
Example #5
Source File: SpawnMobEvent.java    From BetonQuest with GNU General Public License v3.0 5 votes vote down vote up
@Override
protected Void execute(String playerID) throws QuestRuntimeException {
    Location location = loc.getLocation(playerID);
    int a = amount.getInt(playerID);
    for (int i = 0; i < a; i++) {
        Entity entity = location.getWorld().spawnEntity(location, type);
        if (entity instanceof LivingEntity) {
            LivingEntity living = (LivingEntity) entity;
            EntityEquipment eq = living.getEquipment();
            eq.setHelmet(helmet == null ? null : helmet.generate(1));
            eq.setHelmetDropChance(0);
            eq.setChestplate(chestplate == null ? null : chestplate.generate(1));
            eq.setChestplateDropChance(0);
            eq.setLeggings(leggings == null ? null : leggings.generate(1));
            eq.setLeggingsDropChance(0);
            eq.setBoots(boots == null ? null : boots.generate(1));
            eq.setBootsDropChance(0);
            eq.setItemInMainHand(mainHand == null ? null : mainHand.generate(1));
            eq.setItemInMainHandDropChance(0);
            eq.setItemInOffHand(offHand == null ? null : offHand.generate(1));
            eq.setItemInOffHandDropChance(0);
        }
        int j = 0;
        for (Item item : drops) {
            entity.setMetadata("betonquest-drops-" + j,
                    new FixedMetadataValue(BetonQuest.getInstance(), item.getID().getFullID() + ":"
                            + item.getAmount().getInt(playerID)));
            j++;
        }
        if (name != null && entity instanceof LivingEntity) {
            LivingEntity livingEntity = (LivingEntity) entity;
            livingEntity.setCustomName(name);
        }
        if (marked != null) {
            entity.setMetadata("betonquest-marked", new FixedMetadataValue(BetonQuest.getInstance(), marked));
        }
    }
    return null;
}
 
Example #6
Source File: EquipmentSlot.java    From Skript with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void set(EntityEquipment e, @Nullable ItemStack item) {
	if (Skript.isRunningMinecraft(1, 9)) {
		e.setItemInOffHand(item);
	} else {
		Skript.warning("No off hand support, but a skript would need that!");
	}
}
 
Example #7
Source File: EquipmentSlot.java    From Skript with GNU General Public License v3.0 5 votes vote down vote up
@SuppressWarnings("deprecation")
@Override
public void set(final EntityEquipment e, final @Nullable ItemStack item) {
	if (Skript.isRunningMinecraft(1, 9)) {
		e.setItemInMainHand(item);
	} else {
		e.setItemInHand(item);
	}
}
 
Example #8
Source File: EquipmentSlot.java    From Skript with GNU General Public License v3.0 5 votes vote down vote up
@SuppressWarnings("deprecation")
@Override
@Nullable
public ItemStack get(final EntityEquipment e) {
	if (Skript.isRunningMinecraft(1, 9)) {
		return e.getItemInMainHand();
	}
	return e.getItemInHand();
}
 
Example #9
Source File: ExprArmorSlot.java    From Skript with GNU General Public License v3.0 5 votes vote down vote up
@Override
@Nullable
public Slot convert(final LivingEntity e) {
	final EntityEquipment eq = e.getEquipment();
	if (eq == null)
		return null;
	return new EquipmentSlot(eq, slot, explicitSlot);
}
 
Example #10
Source File: PlayersManager.java    From UhcCore with GNU General Public License v3.0 5 votes vote down vote up
public void spawnOfflineZombieFor(Player player){
	UhcPlayer uhcPlayer = getUhcPlayer(player);

	Zombie zombie = (Zombie) player.getWorld().spawnEntity(player.getLocation(), EntityType.ZOMBIE);
	zombie.setCustomName(uhcPlayer.getDisplayName());
	zombie.setCustomNameVisible(true);
	// 1.8 doesn't have setAI method so use VersionUtils.
	VersionUtils.getVersionUtils().setEntityAI(zombie, false);
	zombie.setBaby(false);
	zombie.addPotionEffect(new PotionEffect(PotionEffectType.FIRE_RESISTANCE, 999999, 1, true, true));

	EntityEquipment equipment = zombie.getEquipment();
	equipment.setHelmet(VersionUtils.getVersionUtils().createPlayerSkull(player.getName(), player.getUniqueId()));
	equipment.setChestplate(player.getInventory().getChestplate());
	equipment.setLeggings(player.getInventory().getLeggings());
	equipment.setBoots(player.getInventory().getBoots());
	equipment.setItemInHand(player.getItemInHand());

	uhcPlayer.getStoredItems().clear();
	for (ItemStack item : player.getInventory().getContents()){
		if (item != null){
			uhcPlayer.getStoredItems().add(item);
		}
	}

	uhcPlayer.setOfflineZombie(zombie);
}
 
Example #11
Source File: CraftLivingEntity.java    From Thermos with GNU General Public License v3.0 4 votes vote down vote up
public EntityEquipment getEquipment() {
    return equipment;
}
 
Example #12
Source File: CraftHumanEntity.java    From Thermos with GNU General Public License v3.0 4 votes vote down vote up
public EntityEquipment getEquipment() {
    if (inventory == null) inventory = new CraftInventoryPlayer(((net.minecraft.entity.player.EntityPlayer) entity).inventory);
    return inventory;
}
 
Example #13
Source File: DefaultDropsHandler.java    From EliteMobs with GNU General Public License v3.0 4 votes vote down vote up
private List<ItemStack> inventoryItemsConstructor(LivingEntity entity) {

        EntityEquipment equipment = entity.getEquipment();

        if (equipment.getItemInMainHand() != null && !equipment.getItemInMainHand().getType().equals(Material.AIR))
            wornItems.add(equipment.getItemInMainHand());

        if (equipment.getHelmet() != null)
            wornItems.add(equipment.getHelmet());

        if (equipment.getChestplate() != null)
            wornItems.add(equipment.getChestplate());

        if (equipment.getLeggings() != null)
            wornItems.add(equipment.getLeggings());

        if (equipment.getBoots() != null)
            wornItems.add(equipment.getBoots());

        return wornItems;

    }
 
Example #14
Source File: EquipmentSlot.java    From Skript with GNU General Public License v3.0 4 votes vote down vote up
@Override
public void set(final EntityEquipment e, final @Nullable ItemStack item) {
	e.setChestplate(item);
}
 
Example #15
Source File: EquipmentSlot.java    From Skript with GNU General Public License v3.0 4 votes vote down vote up
public EquipmentSlot(final EntityEquipment e, final EquipSlot slot) {
	this(e, slot, false);
}
 
Example #16
Source File: EquipmentSlot.java    From Skript with GNU General Public License v3.0 4 votes vote down vote up
public EquipmentSlot(final EntityEquipment e, final EquipSlot slot, final boolean slotToString) {
	this.e = e;
	this.slot = slot;
	this.slotToString = slotToString;
}
 
Example #17
Source File: EquipmentSlot.java    From Skript with GNU General Public License v3.0 4 votes vote down vote up
@Nullable
public abstract ItemStack get(EntityEquipment e);
 
Example #18
Source File: EquipmentSlot.java    From Skript with GNU General Public License v3.0 4 votes vote down vote up
@Override
public void set(final EntityEquipment e, final @Nullable ItemStack item) {
	e.setBoots(item);
}
 
Example #19
Source File: EquipmentSlot.java    From Skript with GNU General Public License v3.0 4 votes vote down vote up
@Override
@Nullable
public ItemStack get(final EntityEquipment e) {
	return e.getBoots();
}
 
Example #20
Source File: EquipmentSlot.java    From Skript with GNU General Public License v3.0 4 votes vote down vote up
@Override
public void set(final EntityEquipment e, final @Nullable ItemStack item) {
	e.setLeggings(item);
}
 
Example #21
Source File: EquipmentSlot.java    From Skript with GNU General Public License v3.0 4 votes vote down vote up
@Override
@Nullable
public ItemStack get(final EntityEquipment e) {
	return e.getLeggings();
}
 
Example #22
Source File: EquipmentSlot.java    From Skript with GNU General Public License v3.0 4 votes vote down vote up
@Override
@Nullable
public ItemStack get(final EntityEquipment e) {
	return e.getChestplate();
}
 
Example #23
Source File: EquipmentSlot.java    From Skript with GNU General Public License v3.0 4 votes vote down vote up
@Override
public void set(final EntityEquipment e, final @Nullable ItemStack item) {
	e.setHelmet(item);
}
 
Example #24
Source File: EquipmentSlot.java    From Skript with GNU General Public License v3.0 4 votes vote down vote up
@Override
@Nullable
public ItemStack get(final EntityEquipment e) {
	return e.getHelmet();
}
 
Example #25
Source File: CraftLivingEntity.java    From Kettle with GNU General Public License v3.0 4 votes vote down vote up
public EntityEquipment getEquipment() {
    return equipment;
}
 
Example #26
Source File: LivingEntity.java    From Kettle with GNU General Public License v3.0 2 votes vote down vote up
/**
 * Gets the inventory with the equipment worn by the living entity.
 *
 * @return the living entity's inventory
 */
public EntityEquipment getEquipment();
 
Example #27
Source File: EquipmentSlot.java    From Skript with GNU General Public License v3.0 votes vote down vote up
public abstract void set(EntityEquipment e, @Nullable ItemStack item);