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;
}
java类org.bukkit.inventory.meta.SpawnEggMeta的实例源码
XMLItemMeta.java 文件源码
项目:Arcade2
阅读 25
收藏 0
点赞 0
评论 0
CaptureManager.java 文件源码
项目:SimpleEgg
阅读 20
收藏 0
点赞 0
评论 0
/**
* 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));
}
NMSHandler.java 文件源码
项目:bskyblock
阅读 26
收藏 0
点赞 0
评论 0
@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;
}
Main.java 文件源码
项目:book-api
阅读 19
收藏 0
点赞 0
评论 0
private ItemStack getHorseItem() {
ItemStack item = new ItemStack(Material.MONSTER_EGG);
SpawnEggMeta meta = (SpawnEggMeta) item.getItemMeta();
meta.setSpawnedType(EntityType.HORSE);
item.setItemMeta(meta);
return item;
}
XMLItemMeta.java 文件源码
项目:Arcade2
阅读 26
收藏 0
点赞 0
评论 0
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;
}
ListenerEggEvents.java 文件源码
项目:SimpleEgg
阅读 23
收藏 0
点赞 0
评论 0
@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);
}
}
}
ListenerEggEvents.java 文件源码
项目:SimpleEgg
阅读 22
收藏 0
点赞 0
评论 0
/**
* 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;
}
EggUtilities.java 文件源码
项目:KingKits
阅读 21
收藏 0
点赞 0
评论 0
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;
}
SpawnEggData.java 文件源码
项目:TNE-Bukkit
阅读 22
收藏 0
点赞 0
评论 0
@Override
public SerialItemData initialize(ItemStack stack) {
ItemMeta meta = stack.getItemMeta();
if(meta instanceof SpawnEggMeta) {
valid = true;
entity = ((SpawnEggMeta)meta).getSpawnedType().name();
}
return this;
}
SpawnEggData.java 文件源码
项目:TNE-Bukkit
阅读 24
收藏 0
点赞 0
评论 0
@Override
public ItemStack build(ItemStack stack) {
if(valid) {
SpawnEggMeta meta = (SpawnEggMeta)stack.getItemMeta();
meta.setSpawnedType(EntityType.valueOf(entity));
stack.setItemMeta(meta);
}
return stack;
}
SpawnEggCustomItem.java 文件源码
项目:uppercore
阅读 23
收藏 0
点赞 0
评论 0
@Override
public void processMeta(Player player, ItemMeta m) {//Add support for older versions
super.processMeta(player, m);
SpawnEggMeta meta = (SpawnEggMeta) m;
meta.setSpawnedType(type);
}
SpawnEggMetaStorage.java 文件源码
项目:Leveled-Storage
阅读 24
收藏 0
点赞 0
评论 0
public SpawnEggMetaStorage(SpawnEggMeta meta) {
super(meta);
}
ListenerEggEvents.java 文件源码
项目:SimpleEgg
阅读 23
收藏 0
点赞 0
评论 0
/**
* 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());
}