本文整理匯總了Java中org.bukkit.inventory.EntityEquipment類的典型用法代碼示例。如果您正苦於以下問題:Java EntityEquipment類的具體用法?Java EntityEquipment怎麽用?Java EntityEquipment使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
EntityEquipment類屬於org.bukkit.inventory包,在下文中一共展示了EntityEquipment類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: equipEffectsTask
import org.bukkit.inventory.EntityEquipment; //導入依賴的package包/類
public void equipEffectsTask() {
RScheduler.schedule(plugin, new Runnable() {
public void run() {
if (isValid()) {
Player p = getPlayer();
EntityEquipment ee = p.getEquipment();
if (ee.getHelmet() != null && ItemManager.isItem(ee.getHelmet(), "miner_helmet")) {
if (!equipStates.contains("miner_helmet")) {
p.addPotionEffect(new PotionEffect(PotionEffectType.NIGHT_VISION, Integer.MAX_VALUE, 0, true, false), true);
equipStates.add("miner_helmet");
}
} else {
if (equipStates.contains("miner_helmet")) {
equipStates.remove("miner_helmet");
p.removePotionEffect(PotionEffectType.NIGHT_VISION);
}
}
RScheduler.schedule(plugin, this, RTicks.seconds(1));
}
}
});
}
示例2: giveArmor
import org.bukkit.inventory.EntityEquipment; //導入依賴的package包/類
private void giveArmor(LivingEntity entity, PluginConfig worldConfig) {
String name = ListUtils.getRandom(worldConfig.getStringList(Config.FEATURE_ZOMBIE_ARMOR_ARMOR)).toUpperCase();
if (Material.getMaterial(name + "_BOOTS") == null) {
plugin.getLogger().log(Level.WARNING, "{0} is not a valid armor name", name);
return;
}
EntityEquipment equipment = entity.getEquipment();
equipment.setBoots(new ItemStack(Material.getMaterial(name + "_BOOTS")));
equipment.setLeggings(new ItemStack(Material.getMaterial(name + "_LEGGINGS")));
equipment.setChestplate(new ItemStack(Material.getMaterial(name + "_CHESTPLATE")));
equipment.setHelmet(new ItemStack(Material.getMaterial(name + "_HELMET")));
float dropChance = worldConfig.getInt(Config.FEATURE_ZOMBIE_ARMOR_DROP_CHANCE) / 100.0f;
equipment.setBootsDropChance(dropChance);
equipment.setLeggingsDropChance(dropChance);
equipment.setChestplateDropChance(dropChance);
equipment.setHelmetDropChance(dropChance);
}
示例3: onStop
import org.bukkit.inventory.EntityEquipment; //導入依賴的package包/類
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
public void onStop(BloodMoonEndEvent event) {
World world = event.getWorld();
if (plugin.isFeatureEnabled(world, Feature.ZOMBIE_ARMOR)) {
for (LivingEntity entity : event.getWorld().getLivingEntities()) {
if (entity.getType() == EntityType.ZOMBIE) {
EntityEquipment equipment = entity.getEquipment();
equipment.setBoots(null);
equipment.setLeggings(null);
equipment.setChestplate(null);
equipment.setHelmet(null);
equipment.setBootsDropChance(0.0f);
equipment.setLeggingsDropChance(0.0f);
equipment.setChestplateDropChance(0.0f);
equipment.setHelmetDropChance(0.0f);
}
}
}
}
示例4: ZombieSpawn
import org.bukkit.inventory.EntityEquipment; //導入依賴的package包/類
public void ZombieSpawn(BlockBreakEvent event){
Location loc = event.getBlock().getLocation();
World world = loc.getWorld();
Zombie zombie = (Zombie) world.spawnEntity(loc,EntityType.ZOMBIE);
zombie.setCustomName("Bob the Zombie");
zombie.setCustomNameVisible(true);
zombie.setMaxHealth(90);
zombie.setHealth(90);
zombie.setVillager(true);
zombie.setTarget(event.getPlayer());
EntityEquipment zombieEquipment = zombie.getEquipment();
zombieEquipment.setHelmet(new ItemStack(Material.DIAMOND_HELMET));
zombieEquipment.setLeggings(new ItemStack(Material.DIAMOND_LEGGINGS));
zombieEquipment.setChestplate(new ItemStack(Material.DIAMOND_CHESTPLATE));
zombieEquipment.setBoots(new ItemStack(Material.GOLD_BOOTS));
ItemStack sword = new ItemStack(Material.DIAMOND_SWORD);
sword.addUnsafeEnchantment(Enchantment.DAMAGE_ALL, 4);
zombieEquipment.setItemInHand(sword);
zombieEquipment.setItemInHandDropChance(0.5F);
}
示例5: storeLiving
import org.bukkit.inventory.EntityEquipment; //導入依賴的package包/類
public void storeLiving(final LivingEntity lived) {
this.lived = new LivingEntityStats();
this.lived.potions = lived.getActivePotionEffects();
this.lived.loot = lived.getCanPickupItems();
this.lived.name = lived.getCustomName();
this.lived.visible = lived.isCustomNameVisible();
this.lived.health = (float) lived.getHealth();
this.lived.air = (short) lived.getRemainingAir();
this.lived.persistent = lived.getRemoveWhenFarAway();
this.lived.leashed = lived.isLeashed();
if (this.lived.leashed) {
final Location loc = lived.getLeashHolder().getLocation();
this.lived.leash_x = (short) (this.x - loc.getBlockX());
this.lived.leash_y = (short) (this.y - loc.getBlockY());
this.lived.leash_z = (short) (this.z - loc.getBlockZ());
}
final EntityEquipment equipment = lived.getEquipment();
this.lived.equipped = equipment != null;
if (this.lived.equipped) {
this.lived.hands = equipment.getItemInHand().clone();
this.lived.boots = equipment.getBoots().clone();
this.lived.leggings = equipment.getLeggings().clone();
this.lived.chestplate = equipment.getChestplate().clone();
this.lived.helmet = equipment.getHelmet().clone();
}
}
示例6: holdOperation
import org.bukkit.inventory.EntityEquipment; //導入依賴的package包/類
public static Parameter holdOperation(org.bukkit.entity.LivingEntity le, Context ctx, Parameter set) {
EntityEquipment pent = le.getEquipment();
if ( set != null ) {
if ( set instanceof ItemParameter) {
pent.setItemInHand(((ItemParameter) set).asItemStack(ctx));
} else if ( set instanceof MaterialParameter ) {
pent.setItemInHand(new ItemStack(((MaterialParameter) set).asMaterial(ctx), 1));
} else {
ItemStack s = Item.createItemstackFromString(set.asString(ctx));
pent.setItemInHand(s);
}
}
return Parameter.from(pent.getItemInHand());
}
示例7: storeLiving
import org.bukkit.inventory.EntityEquipment; //導入依賴的package包/類
public void storeLiving(LivingEntity lived) {
this.lived = new LivingEntityStats();
this.lived.potions = lived.getActivePotionEffects();
this.lived.loot = lived.getCanPickupItems();
this.lived.name = lived.getCustomName();
this.lived.visible = lived.isCustomNameVisible();
this.lived.health = (float) lived.getHealth();
this.lived.air = (short) lived.getRemainingAir();
this.lived.persistent = lived.getRemoveWhenFarAway();
this.lived.leashed = lived.isLeashed();
if (this.lived.leashed) {
Location location = lived.getLeashHolder().getLocation();
this.lived.leashX = (short) (this.x - location.getBlockX());
this.lived.leashY = (short) (this.y - location.getBlockY());
this.lived.leashZ = (short) (this.z - location.getBlockZ());
}
EntityEquipment equipment = lived.getEquipment();
this.lived.equipped = equipment != null;
if (this.lived.equipped) {
storeEquipment(equipment);
}
}
示例8: zombify
import org.bukkit.inventory.EntityEquipment; //導入依賴的package包/類
@EventHandler
public void zombify(PlayerDeathEvent e) {
Player p = e.getEntity();
if (!RUtils.isInInfectedWorld(p)) return;
if (!Config.spawnZombie) return;
Zombie z = ZombieSpawner.spawnLeveledZombie(p.getLocation());
if (z == null) return;
EntityEquipment ze = z.getEquipment();
EntityEquipment pe = p.getEquipment();
if (ze == null || pe == null) return;
ze.setArmorContents(pe.getArmorContents());
ze.setHelmetDropChance(0F);
ze.setChestplateDropChance(0F);
ze.setLeggingsDropChance(0F);
ze.setBootsDropChance(0F);
}
示例9: weakDamageDirectWithGun
import org.bukkit.inventory.EntityEquipment; //導入依賴的package包/類
/**
* Doesn't seem to work right now but basically, if you smack someone over the head
* with the gun instead of shoot it, do less damage.
*
* @param event The hit event
*/
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
public void weakDamageDirectWithGun(EntityDamageByEntityEvent event) {
if (event.getDamager() instanceof LivingEntity) {
LivingEntity damager = (LivingEntity) event.getDamager();
EntityEquipment equips = damager.getEquipment();
StandardGun gun = findGun(equips.getItemInMainHand());
if (gun != null) {
// modify damage!
event.setDamage(gun.getBluntDamage());
}
}
}
示例10: weakDamageDirectWithGun
import org.bukkit.inventory.EntityEquipment; //導入依賴的package包/類
/**
* Doesn't seem to work right now but basically, if you smack someone over the head
* with the gun instead of shoot it, do less damage.
*
* @param event The hit event
*/
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
public void weakDamageDirectWithGun(EntityDamageByEntityEvent event) {
if (event.getDamager() instanceof LivingEntity) {
LivingEntity damager = (LivingEntity) event.getDamager();
EntityEquipment equips = damager.getEquipment();
if (isGun(equips.getItemInMainHand())) {
// modify damage!
event.setDamage(this.bluntDamage);
}
}
}
示例11: onCommand
import org.bukkit.inventory.EntityEquipment; //導入依賴的package包/類
@Override
protected void onCommand(CommandSender sender, String[] args) {
Player player = (Player) sender;
EntityEquipment e = player.getEquipment();
ItemStack held = e.getItemInMainHand();
e.setItemInMainHand(e.getHelmet());
e.setHelmet(held);
sender.sendMessage(ChatColor.GOLD + "Enjoy your new hat.");
}
示例12: getEquipment
import org.bukkit.inventory.EntityEquipment; //導入依賴的package包/類
/**
* Gets the inventory with the equipment worn by the living entity.
* <p/>
* <b>Entities: </b> {@link LivingEntity}, {@link ArmorStand}
*
* @return the living entity's inventory
*/
public EntityEquipment getEquipment() {
if (entity instanceof LivingEntity) {
return ((LivingEntity) entity).getEquipment();
} else if (entity instanceof ArmorStand) {
return ((ArmorStand) entity).getEquipment();
}
return null;
}
示例13: convert
import org.bukkit.inventory.EntityEquipment; //導入依賴的package包/類
@Override
@Nullable
public Slot convert(final LivingEntity e) {
final EntityEquipment eq = e.getEquipment();
if (eq == null)
return null;
return new EquipmentSlot(eq, slot);
}
示例14: set
import org.bukkit.inventory.EntityEquipment; //導入依賴的package包/類
@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); //Compatibility reasons
}
示例15: EquipmentConfiguration
import org.bukkit.inventory.EntityEquipment; //導入依賴的package包/類
public EquipmentConfiguration(EntityEquipment equips) {
this.head = equips.getHelmet();
this.chest = equips.getChestplate();
this.legs = equips.getLeggings();
this.boots = equips.getBoots();
this.heldMain = equips.getItemInMainHand();
this.heldOff = equips.getItemInOffHand();
}