本文整理汇总了Java中org.bukkit.inventory.meta.SpawnEggMeta类的典型用法代码示例。如果您正苦于以下问题:Java SpawnEggMeta类的具体用法?Java SpawnEggMeta怎么用?Java SpawnEggMeta使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
SpawnEggMeta类属于org.bukkit.inventory.meta包,在下文中一共展示了SpawnEggMeta类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: parse
import org.bukkit.inventory.meta.SpawnEggMeta; //导入依赖的package包/类
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;
}
示例2: makeSpawnEgg
import org.bukkit.inventory.meta.SpawnEggMeta; //导入依赖的package包/类
/**
* 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));
}
示例3: getSpawnEgg
import org.bukkit.inventory.meta.SpawnEggMeta; //导入依赖的package包/类
@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;
}
示例4: getHorseItem
import org.bukkit.inventory.meta.SpawnEggMeta; //导入依赖的package包/类
private ItemStack getHorseItem() {
ItemStack item = new ItemStack(Material.MONSTER_EGG);
SpawnEggMeta meta = (SpawnEggMeta) item.getItemMeta();
meta.setSpawnedType(EntityType.HORSE);
item.setItemMeta(meta);
return item;
}
示例5: parseSpawnEgg
import org.bukkit.inventory.meta.SpawnEggMeta; //导入依赖的package包/类
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;
}
示例6: eggUseOnEntity
import org.bukkit.inventory.meta.SpawnEggMeta; //导入依赖的package包/类
@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);
}
}
}
示例7: isVersionCurrent
import org.bukkit.inventory.meta.SpawnEggMeta; //导入依赖的package包/类
/**
* 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;
}
示例8: getEgg
import org.bukkit.inventory.meta.SpawnEggMeta; //导入依赖的package包/类
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;
}
示例9: initialize
import org.bukkit.inventory.meta.SpawnEggMeta; //导入依赖的package包/类
@Override
public SerialItemData initialize(ItemStack stack) {
ItemMeta meta = stack.getItemMeta();
if(meta instanceof SpawnEggMeta) {
valid = true;
entity = ((SpawnEggMeta)meta).getSpawnedType().name();
}
return this;
}
示例10: build
import org.bukkit.inventory.meta.SpawnEggMeta; //导入依赖的package包/类
@Override
public ItemStack build(ItemStack stack) {
if(valid) {
SpawnEggMeta meta = (SpawnEggMeta)stack.getItemMeta();
meta.setSpawnedType(EntityType.valueOf(entity));
stack.setItemMeta(meta);
}
return stack;
}
示例11: processMeta
import org.bukkit.inventory.meta.SpawnEggMeta; //导入依赖的package包/类
@Override
public void processMeta(Player player, ItemMeta m) {//Add support for older versions
super.processMeta(player, m);
SpawnEggMeta meta = (SpawnEggMeta) m;
meta.setSpawnedType(type);
}
示例12: SpawnEggMetaStorage
import org.bukkit.inventory.meta.SpawnEggMeta; //导入依赖的package包/类
public SpawnEggMetaStorage(SpawnEggMeta meta) {
super(meta);
}
示例13: isSimpleEgg
import org.bukkit.inventory.meta.SpawnEggMeta; //导入依赖的package包/类
/**
* 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());
}