Java 类org.bukkit.inventory.meta.SpawnEggMeta 实例源码

项目:Arcade2    文件:XMLItemMeta.java   
public static ItemMeta parse(Element xml, ItemMeta source) {
    if (source instanceof BannerMeta) {
        return parseBanner(xml, (BannerMeta) source);
    } else if (source instanceof BookMeta) {
        return parseBook(xml, (BookMeta) source);
    } else if (source instanceof EnchantmentStorageMeta) {
        return parseEnchantmentStorage(xml, (EnchantmentStorageMeta) source);
    } else if (source instanceof FireworkMeta) {
        return parseFirework(xml, (FireworkMeta) source);
    } else if (source instanceof FireworkEffectMeta) {
        return parseFireworkEffect(xml, (FireworkEffectMeta) source);
    } else if (source instanceof LeatherArmorMeta) {
        return parseLeatherArmor(xml, (LeatherArmorMeta) source);
    } else if (source instanceof MapMeta) {
        return parseMap(xml, (MapMeta) source);
    } else if (source instanceof PotionMeta) {
        return parsePotion(xml, (PotionMeta) source);
    } else if (source instanceof SkullMeta) {
        return parseSkull(xml, (SkullMeta) source);
    } else if (source instanceof SpawnEggMeta) {
        return parseSpawnEgg(xml, (SpawnEggMeta) source);
    }

    return source;
}
项目:SimpleEgg    文件:CaptureManager.java   
/**
 * Makes a call to the ExpenseHandler, generates a SpawnEgg, assigns data to
 * it and drops it where the mob used to be.
 * @param entry - The EggTrackerEntry we are dealing with for this SpawnEgg.
 */
public void makeSpawnEgg(EggTrackerEntry entry) {
    Player player = entry.getPlayer();
    LivingEntity livingEntity = entry.getEntity();
    expenseHandler.execute(player);
    ItemStack stack = new ItemStack(Material.MONSTER_EGG);
    SpawnEggMeta meta = (SpawnEggMeta) stack.getItemMeta();
    meta.setSpawnedType(livingEntity.getType());
    String name = Text.a + livingEntity.getType().getEntityClass().getSimpleName();

    if (livingEntity.getCustomName() != null) {
        name += ": " + livingEntity.getCustomName();
    }

    meta.setDisplayName(name);
    meta.setLore(new LorePacker(livingEntity).getLore());
    stack.setItemMeta(meta);
    livingEntity.getWorld().dropItem(livingEntity.getLocation(), stack);
    livingEntity.remove();
    player.sendMessage(String.format("%s%s%s%s captured successfully!", Text.tag, Text.a, livingEntity.getType().getEntityClass().getSimpleName(), Text.b));
}
项目:bskyblock    文件:NMSHandler.java   
@Override
public ItemStack getSpawnEgg(EntityType type, int amount) {
    ItemStack egg = new ItemStack(Material.MONSTER_EGG, amount);
    SpawnEggMeta spm = (SpawnEggMeta)egg.getItemMeta();
    spm.setSpawnedType(type);
    egg.setItemMeta(spm);
    return egg;
}
项目:book-api    文件:Main.java   
private ItemStack getHorseItem() {
    ItemStack item = new ItemStack(Material.MONSTER_EGG);
    SpawnEggMeta meta = (SpawnEggMeta) item.getItemMeta();
    meta.setSpawnedType(EntityType.HORSE);
    item.setItemMeta(meta);
    return item;
}
项目:Arcade2    文件:XMLItemMeta.java   
public static SpawnEggMeta parseSpawnEgg(Element xml, SpawnEggMeta source) {
    Element spawnerEgg = xml.getChild("spawner-egg");
    if (spawnerEgg != null) {
        EntityType entity = XMLEntity.parse(spawnerEgg.getTextNormalize());
        if (entity != null) {
            source.setSpawnedType(entity);
        }
    }

    return source;
}
项目:SimpleEgg    文件:ListenerEggEvents.java   
@EventHandler
public void eggUseOnEntity(PlayerInteractEntityEvent event) {
    ItemStack stack = event.getPlayer().getInventory().getItemInMainHand();
    ItemMeta meta = stack.getItemMeta();

    if (meta instanceof SpawnEggMeta) {
        SpawnEggMeta spawnEggMeta = (SpawnEggMeta) meta;

        if (isSimpleEgg(spawnEggMeta)) {
            event.getPlayer().sendMessage(Text.tag + "You cannot use a SimpleEgg to make babies out of other adult mobs.");
            event.setCancelled(true);
        }
    }
}
项目:SimpleEgg    文件:ListenerEggEvents.java   
/**
 * Check if an egg's identifier line exists and the version on it matches
 * the current plugin version.
 * @return True if the egg is current, false otherwise.
 */
private boolean isVersionCurrent(SpawnEggMeta meta) {
    if (isSimpleEgg(meta)) {
        if (ChatColor.stripColor(meta.getLore().get(0)).endsWith(Main.getSelf().getDescription().getVersion())) {
            return true;
        }
    }

    return false;
}
项目:KingKits    文件:EggUtilities.java   
public static String getEgg(ItemStack itemStack) {
    if (itemStack != null) {
        if (itemStack.getType() == Material.MONSTER_EGG) {
            ItemMeta itemMeta = itemStack.getItemMeta();
            if (itemMeta instanceof SpawnEggMeta) {
                SpawnEggMeta spawnEggMeta = (SpawnEggMeta) itemMeta;
                return spawnEggMeta.getSpawnedType() != null ? StringUtilities.capitalizeFully(spawnEggMeta.getSpawnedType().name()) : null;
            }
        }
    }
    return null;
}
项目:TNE-Bukkit    文件:SpawnEggData.java   
@Override
public SerialItemData initialize(ItemStack stack) {
  ItemMeta meta = stack.getItemMeta();
  if(meta instanceof SpawnEggMeta) {
    valid = true;
    entity = ((SpawnEggMeta)meta).getSpawnedType().name();
  }
  return this;
}
项目:TNE-Bukkit    文件:SpawnEggData.java   
@Override
public ItemStack build(ItemStack stack) {
  if(valid) {
    SpawnEggMeta meta = (SpawnEggMeta)stack.getItemMeta();
    meta.setSpawnedType(EntityType.valueOf(entity));
    stack.setItemMeta(meta);
  }
  return stack;
}
项目:uppercore    文件:SpawnEggCustomItem.java   
@Override
public void processMeta(Player player, ItemMeta m) {//Add support for older versions
    super.processMeta(player, m);
    SpawnEggMeta meta = (SpawnEggMeta) m;
    meta.setSpawnedType(type);
}
项目:Leveled-Storage    文件:SpawnEggMetaStorage.java   
public SpawnEggMetaStorage(SpawnEggMeta meta) {
    super(meta);
}
项目:SimpleEgg    文件:ListenerEggEvents.java   
/**
 * Check if an egg's identifier line exists, regardless of version.
 * @return True if it has an identifier of any version, false otherwise.
 */
private boolean isSimpleEgg(SpawnEggMeta meta) {
    return meta.hasLore() && ChatColor.stripColor(meta.getLore().get(0)).startsWith("Identifier: SimpleEgg." + meta.getSpawnedType().getEntityClass().getSimpleName());
}