org.bukkit.configuration.file.YamlConfiguration.getItemStack()方法的使用及代码示例

x33g5p2x  于2022-02-05 转载在 其他  
字(1.3k)|赞(0)|评价(0)|浏览(125)

本文整理了Java中org.bukkit.configuration.file.YamlConfiguration.getItemStack()方法的一些代码示例,展示了YamlConfiguration.getItemStack()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。YamlConfiguration.getItemStack()方法的具体详情如下:
包路径:org.bukkit.configuration.file.YamlConfiguration
类名称:YamlConfiguration
方法名:getItemStack

YamlConfiguration.getItemStack介绍

暂无

代码示例

代码示例来源:origin: EpicEricEE/ShopChest

/**
 * Decodes an {@link ItemStack} from a Base64 String
 * @param string Base64 encoded String to decode
 * @return Decoded {@link ItemStack}
 */
public static ItemStack decode(String string) {
  YamlConfiguration config = new YamlConfiguration();
  try {
    config.loadFromString(new String(Base64.getDecoder().decode(string), StandardCharsets.UTF_8));
  } catch (IllegalArgumentException | InvalidConfigurationException e) {
    e.printStackTrace();
    return null;
  }
  return config.getItemStack("i", null);
}

代码示例来源:origin: elBukkit/MagicPlugin

public static ItemStack getReplacement(ItemStack itemStack) {
  String serialized = getMetaString(itemStack, "replacement");
  if (serialized == null || serialized.isEmpty()) {
    return null;
  }
  YamlConfiguration configuration = new YamlConfiguration();
  ItemStack replacement = null;
  try {
    configuration.loadFromString(serialized);
    replacement = configuration.getItemStack("item");
  } catch (Exception ex) {
    ex.printStackTrace();
  }
  return replacement;
}

相关文章