Java 类org.bukkit.inventory.meta.MapMeta 实例源码
项目: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;
}
项目:NPlugins
文件:ItemMetaUtil.java
/**
* Gets a String representing all special meta of this ItemStack, if any.
*
* @param is the ItemStack
* @param separators the separators
*
* @return a String representing this ItemStack's special meta or an empty String
*
* @throws InventoryUtilException if something goes wrong
*/
public static String getSpecialMetaString(final ItemStack is, final String[] separators) throws InventoryUtilException {
final ItemMeta meta = is.getItemMeta();
if (meta instanceof BookMeta) {
return getBookMetaString((BookMeta)meta);
} else if (meta instanceof EnchantmentStorageMeta) {
return getEnchantmentStorageMetaString((EnchantmentStorageMeta)meta, separators);
} else if (meta instanceof FireworkEffectMeta) {
return getFireworkEffectMetaString((FireworkEffectMeta)meta);
} else if (meta instanceof FireworkMeta) {
return getFireworkMetaString((FireworkMeta)meta, separators);
} else if (meta instanceof LeatherArmorMeta) {
return getLeatherArmorMetaString((LeatherArmorMeta)meta);
} else if (meta instanceof MapMeta) {
return getMapMetaString((MapMeta)meta);
} else if (meta instanceof PotionMeta) {
return getPotionMetaString((PotionMeta)meta, separators);
} else if (meta instanceof SkullMeta) {
return getSkullMetaString((SkullMeta)meta);
} else {
throw new InventoryUtilException("Unknown Meta type '" + meta.getClass().getName() + "', please report this to the author (Ribesg)!");
}
}
项目:uppercore
文件:MapCustomItem.java
@Override
public void processMeta(Player player, ItemMeta m) {
super.processMeta(player, m);
MapMeta meta = (MapMeta) m;
meta.setScaling(scaling);
if(displayLocName != null)
meta.setLocationName(displayLocName.resolve(player));
if(displayMapColor != null)
meta.setColor(displayMapColor.resolve(player));
}
项目:SupaCommons
文件:ItemMatcher.java
@Override
public boolean apply(@Nullable ItemStack item1, @Nullable ItemStack item2) {
Boolean b = precondition(item1, item2, true);
if (b != null) {
return b;
}
if (item1.getItemMeta() instanceof MapMeta
&& item2.getItemMeta() instanceof MapMeta) {
return ((MapMeta) item1.getItemMeta()).isScaling()
== ((MapMeta) item2.getItemMeta()).isScaling();
}
return false;
}
项目:SupaCommons
文件:ItemBuilder.java
/**
* Sets whether this map scales, assuming the item is a map.
* <p />
* <b>UNSAFE</b>
*
* @param scale whether to scale
*
* @return this item builder instance, for chaining
*/
public ItemBuilder mapScale(boolean scale) {
if (isMapMeta()) {
try {
((MapMeta) this.itemMeta).setScaling(scale);
} catch (Exception e) {
if (!this.failSilently) {
e.printStackTrace();
}
}
}
return this;
}
项目:SupaCommons
文件:ItemBuilder.java
private boolean isMapMeta() {
if (!(this.itemMeta instanceof MapMeta)) {
if (!this.failSilently) {
throw new IllegalStateException("ItemMeta is not of MapMeta.");
}
return false;
}
return true;
}
项目:StarQuestCode
文件:CardboardMetaMap.java
@SuppressWarnings("deprecation")
public CardboardMetaMap(ItemStack map) {
this.id = map.getTypeId();
MapMeta meta = (MapMeta) map.getItemMeta();
if (meta.isScaling()) {
this.scaling = true;
} else {
this.scaling = false;
}
}
项目:StarQuestCode
文件:CardboardMetaMap.java
@SuppressWarnings("deprecation")
public ItemMeta unbox() {
MapMeta meta = (MapMeta) new ItemStack(this.id).getItemMeta();
if (this.scaling) {
meta.setScaling(true);
}
return meta;
}
项目:StarQuestCode
文件:CardboardMetaMap.java
@SuppressWarnings("deprecation")
public CardboardMetaMap(ItemStack map) {
this.id = map.getTypeId();
MapMeta meta = (MapMeta) map.getItemMeta();
if (meta.isScaling()) {
this.scaling = true;
} else {
this.scaling = false;
}
}
项目:StarQuestCode
文件:CardboardMetaMap.java
@SuppressWarnings("deprecation")
public ItemMeta unbox() {
MapMeta meta = (MapMeta) new ItemStack(this.id).getItemMeta();
if (this.scaling) {
meta.setScaling(true);
}
return meta;
}
项目:StarQuestCode
文件:CardboardMetaMap.java
public CardboardMetaMap(ItemStack map) {
this.id = map.getTypeId();
MapMeta meta = (MapMeta) map.getItemMeta();
if (meta.isScaling()) {
this.scaling = true;
} else {
this.scaling = false;
}
}
项目:StarQuestCode
文件:CardboardMetaMap.java
public ItemMeta unbox() {
MapMeta meta = (MapMeta) new ItemStack(this.id).getItemMeta();
if (this.scaling) {
meta.setScaling(true);
}
return meta;
}
项目:TNE-Bukkit
文件:MapData.java
@Override
public SerialItemData initialize(ItemStack stack) {
ItemMeta meta = stack.getItemMeta();
if(meta instanceof MapMeta) {
valid = true;
MapMeta mapMeta = (MapMeta)meta;
if(mapMeta.hasLocationName()) location = mapMeta.getLocationName();
if(mapMeta.hasColor()) color = mapMeta.getColor();
scaling = mapMeta.isScaling();
}
return this;
}
项目:TNE-Bukkit
文件:MapData.java
@Override
public ItemStack build(ItemStack stack) {
if(valid) {
MapMeta meta = (MapMeta) stack.getItemMeta();
if(location != null) meta.setLocationName(location);
if(color != null) meta.setColor(color);
meta.setScaling(scaling);
stack.setItemMeta(meta);
}
return stack;
}
项目:NPlugins
文件:ItemMetaUtil.java
/**
* Parses 3 strings into an ItemMeta.
*
* @param meta the ItemMeta to complete
* @param nameString the DisplayName String
* @param loreString the Lore String representation
* @param specialMetaString the Special Meta part String representation
*
* @return the same ItemMeta, completed
*/
public static ItemMeta fromString(final ItemMeta meta, final String nameString, final String loreString, final String specialMetaString, final String[] separators) throws InventoryUtilException {
if (meta instanceof BookMeta) {
parseBookMetaString(specialMetaString, (BookMeta)meta);
} else if (meta instanceof EnchantmentStorageMeta) {
parseEnchantmentStorageMetaString(specialMetaString, (EnchantmentStorageMeta)meta, separators);
} else if (meta instanceof FireworkEffectMeta) {
parseFireworkEffectMetaString(specialMetaString, (FireworkEffectMeta)meta);
} else if (meta instanceof FireworkMeta) {
parseFireworkMetaString(specialMetaString, (FireworkMeta)meta, separators);
} else if (meta instanceof LeatherArmorMeta) {
parseLeatherArmorMetaString(specialMetaString, (LeatherArmorMeta)meta);
} else if (meta instanceof MapMeta) {
parseMapMetaString(specialMetaString, (MapMeta)meta);
} else if (meta instanceof PotionMeta) {
parsePotionMetaString(specialMetaString, (PotionMeta)meta, separators);
} else if (meta instanceof SkullMeta) {
parseSkullMetaString(specialMetaString, (SkullMeta)meta);
}
if (!nameString.isEmpty()) {
meta.setDisplayName(nameString);
}
if (loreString.length() > 1) {
final List<String> lore = new ArrayList<>();
final String separator = loreString.substring(0, 2);
Collections.addAll(lore, StringUtil.splitKeepEmpty(loreString.substring(2), separator));
meta.setLore(lore);
}
return meta;
}
项目:NPlugins
文件:ItemMetaUtil.java
/**
* Saves an ItemMeta to a ConfigurationSection
*
* @param itemSection the parent section of the to-be-created meta section
* @param is the ItemStack
*/
public static void saveToConfigSection(final ConfigurationSection itemSection, final ItemStack is) {
final ItemMeta meta = is.getItemMeta();
if (meta instanceof BookMeta) {
saveBookMetaToConfigSection(createAndGetSection(itemSection, "meta"), (BookMeta)meta);
} else if (meta instanceof EnchantmentStorageMeta) {
saveEnchantmentStorageMetaToConfigSection(createAndGetSection(itemSection, "meta"), (EnchantmentStorageMeta)meta);
} else if (meta instanceof FireworkEffectMeta) {
saveFireworkEffectMetaToConfigSection(createAndGetSection(itemSection, "meta"), (FireworkEffectMeta)meta);
} else if (meta instanceof FireworkMeta) {
saveFireworkMetaToConfigSection(createAndGetSection(itemSection, "meta"), (FireworkMeta)meta);
} else if (meta instanceof LeatherArmorMeta) {
saveLeatherArmorMetaToConfigSection(createAndGetSection(itemSection, "meta"), (LeatherArmorMeta)meta);
} else if (meta instanceof MapMeta) {
saveMapMetaToConfigSection(createAndGetSection(itemSection, "meta"), (MapMeta)meta);
} else if (meta instanceof PotionMeta) {
savePotionMetaToConfigSection(createAndGetSection(itemSection, "meta"), (PotionMeta)meta);
} else if (meta instanceof SkullMeta) {
saveSkullMetaToConfigSection(createAndGetSection(itemSection, "meta"), (SkullMeta)meta);
}
if (meta.hasDisplayName()) {
createAndGetSection(itemSection, "meta").set("name", ColorUtil.decolorize(meta.getDisplayName()));
}
if (meta.hasLore()) {
createAndGetSection(itemSection, "meta").set("lore", ColorUtil.decolorize(meta.getLore()));
}
}
项目:NPlugins
文件:ItemMetaUtil.java
/**
* Loads an ItemMeta from a ConfigurationSection.
*
* @param itemSection the parent section of the meta section
* @param is the ItemStack to complete
*
* @throws InventoryUtilException if something goes wrong
*/
public static void loadFromConfigSection(final ConfigurationSection itemSection, final ItemStack is) throws InventoryUtilException {
if (itemSection.isConfigurationSection("meta")) {
final ItemMeta meta = is.getItemMeta();
final ConfigurationSection metaSection = itemSection.getConfigurationSection("meta");
if (meta instanceof BookMeta) {
loadBookMetaFromConfigSection(metaSection, (BookMeta)meta);
} else if (meta instanceof EnchantmentStorageMeta) {
loadEnchantmentStorageMetaFromConfigSection(metaSection, (EnchantmentStorageMeta)meta);
} else if (meta instanceof FireworkEffectMeta) {
loadFireworkEffectMetaFromConfigSection(metaSection, (FireworkEffectMeta)meta);
} else if (meta instanceof FireworkMeta) {
loadFireworkMetaFromConfigSection(metaSection, (FireworkMeta)meta);
} else if (meta instanceof LeatherArmorMeta) {
loadLeatherArmorMetaFromConfigSection(metaSection, (LeatherArmorMeta)meta);
} else if (meta instanceof MapMeta) {
loadMapMetaFromConfigSection(metaSection, (MapMeta)meta);
} else if (meta instanceof PotionMeta) {
loadPotionMetaFromConfigSection(metaSection, (PotionMeta)meta);
} else if (meta instanceof SkullMeta) {
loadSkullMetaFromConfigSection(metaSection, (SkullMeta)meta);
}
final String displayName = metaSection.getString("name", "");
if (!displayName.isEmpty()) {
meta.setDisplayName(ColorUtil.colorize(displayName));
}
final List<String> lore = metaSection.getStringList("lore");
if (!lore.isEmpty()) {
meta.setLore(ColorUtil.colorize(lore));
}
is.setItemMeta(meta);
}
}
项目:ItemExchange
文件:ExchangeRule.java
public static ExchangeRule parseItemStack(ItemStack itemStack, RuleType ruleType) throws ExchangeRuleCreateException {
Map<Enchantment, Integer> requiredEnchantments = new HashMap<Enchantment, Integer>();
for (Enchantment enchantment : itemStack.getEnchantments().keySet()) {
requiredEnchantments.put(enchantment, itemStack.getEnchantments().get(enchantment));
}
String displayName = "";
String[] lore = new String[0];
AdditionalMetadata additional = null;
if (itemStack.hasItemMeta()) {
ItemMeta itemMeta = itemStack.getItemMeta();
if (itemMeta.hasDisplayName()) {
displayName = itemMeta.getDisplayName();
}
if (itemMeta.hasLore()) {
lore = itemMeta.getLore().toArray(new String[itemMeta.getLore().size()]);
}
if(itemMeta instanceof BookMeta) {
additional = new BookMetadata((BookMeta) itemMeta);
}
else if(itemMeta instanceof EnchantmentStorageMeta) {
additional = new EnchantmentStorageMetadata((EnchantmentStorageMeta) itemMeta);
}
else if(itemMeta instanceof PotionMeta) {
additional = new PotionMetadata((PotionMeta) itemMeta);
}
//I've removed the PotionMeta block since it is not required if only vanilla potions are used, PotionMeta support should be added in the future
if(itemMeta instanceof FireworkEffectMeta || itemMeta instanceof FireworkMeta || itemMeta instanceof LeatherArmorMeta || itemMeta instanceof MapMeta || itemMeta instanceof SkullMeta) {
throw new ExchangeRuleCreateException("This item is not yet supported by ItemExchange.");
}
}
ExchangeRule exchangeRule = new ExchangeRule(itemStack.getType(), itemStack.getAmount(), itemStack.getDurability(), requiredEnchantments, new ArrayList<Enchantment>(), false, displayName, lore, ruleType);
exchangeRule.setAdditionalMetadata(additional);
return exchangeRule;
}
项目:Leveled-Storage
文件:MapMetaStorage.java
public MapMetaStorage(MapMeta meta) {
super(meta);
}
项目:Arcade2
文件:XMLItemMeta.java
public static MapMeta parseMap(Element xml, MapMeta source) {
return source;
}
项目:Pore
文件:PoreMapMeta.java
@Override
public MapMeta clone() {
throw new NotImplementedException("TODO");
}
项目:NPlugins
文件:Chat.java
private static void appendItemMap(final StringBuilder builder, final MapMeta meta) {
// TODO
}
项目:NPlugins
文件:ItemMetaUtil.java
private static String getMapMetaString(final MapMeta meta) {
return Boolean.toString(meta.isScaling());
}
项目:NPlugins
文件:ItemMetaUtil.java
private static void parseMapMetaString(final String string, final MapMeta meta) {
meta.setScaling(Boolean.parseBoolean(string));
}
项目:NPlugins
文件:ItemMetaUtil.java
private static void saveMapMetaToConfigSection(final ConfigurationSection metaSection, final MapMeta meta) {
metaSection.set("isMapScaling", meta.isScaling());
}
项目:NPlugins
文件:ItemMetaUtil.java
private static void loadMapMetaFromConfigSection(final ConfigurationSection metaSection, final MapMeta meta) {
meta.setScaling(metaSection.getBoolean("isMapScaling"));
}
项目:BedrockAPI
文件:MapMeta.java
MapMeta clone();