当前位置: 首页>>代码示例>>Java>>正文


Java MapMeta类代码示例

本文整理汇总了Java中org.bukkit.inventory.meta.MapMeta的典型用法代码示例。如果您正苦于以下问题:Java MapMeta类的具体用法?Java MapMeta怎么用?Java MapMeta使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


MapMeta类属于org.bukkit.inventory.meta包,在下文中一共展示了MapMeta类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: parse

import org.bukkit.inventory.meta.MapMeta; //导入依赖的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;
}
 
开发者ID:ShootGame,项目名称:Arcade2,代码行数:26,代码来源:XMLItemMeta.java

示例2: getSpecialMetaString

import org.bukkit.inventory.meta.MapMeta; //导入依赖的package包/类
/**
 * 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)!");
    }
}
 
开发者ID:Ribesg,项目名称:NPlugins,代码行数:34,代码来源:ItemMetaUtil.java

示例3: processMeta

import org.bukkit.inventory.meta.MapMeta; //导入依赖的package包/类
@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));
}
 
开发者ID:upperlevel,项目名称:uppercore,代码行数:11,代码来源:MapCustomItem.java

示例4: apply

import org.bukkit.inventory.meta.MapMeta; //导入依赖的package包/类
@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;
}
 
开发者ID:SupaHam,项目名称:SupaCommons,代码行数:14,代码来源:ItemMatcher.java

示例5: mapScale

import org.bukkit.inventory.meta.MapMeta; //导入依赖的package包/类
/**
 * 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;
}
 
开发者ID:SupaHam,项目名称:SupaCommons,代码行数:22,代码来源:ItemBuilder.java

示例6: isMapMeta

import org.bukkit.inventory.meta.MapMeta; //导入依赖的package包/类
private boolean isMapMeta() {
  if (!(this.itemMeta instanceof MapMeta)) {
    if (!this.failSilently) {
      throw new IllegalStateException("ItemMeta is not of MapMeta.");
    }
    return false;
  }
  return true;
}
 
开发者ID:SupaHam,项目名称:SupaCommons,代码行数:10,代码来源:ItemBuilder.java

示例7: CardboardMetaMap

import org.bukkit.inventory.meta.MapMeta; //导入依赖的package包/类
@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;
	}
}
 
开发者ID:StarQuestMinecraft,项目名称:StarQuestCode,代码行数:12,代码来源:CardboardMetaMap.java

示例8: unbox

import org.bukkit.inventory.meta.MapMeta; //导入依赖的package包/类
@SuppressWarnings("deprecation")
public ItemMeta unbox() {

	MapMeta meta = (MapMeta) new ItemStack(this.id).getItemMeta();
	if (this.scaling) {
		meta.setScaling(true);
	}

	return meta;
}
 
开发者ID:StarQuestMinecraft,项目名称:StarQuestCode,代码行数:11,代码来源:CardboardMetaMap.java

示例9: CardboardMetaMap

import org.bukkit.inventory.meta.MapMeta; //导入依赖的package包/类
public CardboardMetaMap(ItemStack map) {

		this.id = map.getTypeId();
		MapMeta meta = (MapMeta) map.getItemMeta();
		if (meta.isScaling()) {
			this.scaling = true;
		} else {
			this.scaling = false;
		}
	}
 
开发者ID:StarQuestMinecraft,项目名称:StarQuestCode,代码行数:11,代码来源:CardboardMetaMap.java

示例10: unbox

import org.bukkit.inventory.meta.MapMeta; //导入依赖的package包/类
public ItemMeta unbox() {

		MapMeta meta = (MapMeta) new ItemStack(this.id).getItemMeta();
		if (this.scaling) {
			meta.setScaling(true);
		}

		return meta;
	}
 
开发者ID:StarQuestMinecraft,项目名称:StarQuestCode,代码行数:10,代码来源:CardboardMetaMap.java

示例11: initialize

import org.bukkit.inventory.meta.MapMeta; //导入依赖的package包/类
@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;
}
 
开发者ID:TheNewEconomy,项目名称:TNE-Bukkit,代码行数:13,代码来源:MapData.java

示例12: build

import org.bukkit.inventory.meta.MapMeta; //导入依赖的package包/类
@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;
}
 
开发者ID:TheNewEconomy,项目名称:TNE-Bukkit,代码行数:12,代码来源:MapData.java

示例13: fromString

import org.bukkit.inventory.meta.MapMeta; //导入依赖的package包/类
/**
 * 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;
}
 
开发者ID:Ribesg,项目名称:NPlugins,代码行数:43,代码来源:ItemMetaUtil.java

示例14: saveToConfigSection

import org.bukkit.inventory.meta.MapMeta; //导入依赖的package包/类
/**
 * 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()));
    }
}
 
开发者ID:Ribesg,项目名称:NPlugins,代码行数:36,代码来源:ItemMetaUtil.java

示例15: loadFromConfigSection

import org.bukkit.inventory.meta.MapMeta; //导入依赖的package包/类
/**
 * 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);
    }
}
 
开发者ID:Ribesg,项目名称:NPlugins,代码行数:45,代码来源:ItemMetaUtil.java


注:本文中的org.bukkit.inventory.meta.MapMeta类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。