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


Java BannerMeta类代码示例

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


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

示例1: placeStanding

import org.bukkit.inventory.meta.BannerMeta; //导入依赖的package包/类
public static boolean placeStanding(Location location, BannerMeta meta) {
    Block block = location.getBlock();
    block.setType(Material.STANDING_BANNER, false);

    final BlockState state = block.getState();
    if(state instanceof Banner) {
        Banner banner = (Banner) block.getState();
        applyToBlock(banner, meta);

        org.bukkit.material.Banner material = (org.bukkit.material.Banner) banner.getData();
        material.setFacingDirection(BlockFaces.yawToFace(location.getYaw()));
        banner.setData(material);
        banner.update(true);
        return true;
    }
    return false;
}
 
开发者ID:OvercastNetwork,项目名称:ProjectAres,代码行数:18,代码来源:Banners.java

示例2: change

import org.bukkit.inventory.meta.BannerMeta; //导入依赖的package包/类
@Override
public void change(Event e, Object[] delta, @NotNull Changer.ChangeMode mode) {
	ItemStack i = item.getSingle(e);
	if (i == null) {
		return;
	}
	if (i.getType() == Material.BANNER || i.getType() == Material.SHIELD) {
		BannerMeta meta = ((BannerMeta) i.getItemMeta());
		switch (mode) {
			case ADD:
				Arrays.asList(((Pattern[]) delta)).forEach(meta::addPattern);
				break;
			case SET:
				meta.setPatterns(Arrays.asList(((Pattern[]) delta)));
				break;
			case DELETE:
			case RESET:
				for (int j = 1; j <= meta.numberOfPatterns(); j++) {
					meta.removePattern(j);
				}
				break;
		}
		i.setItemMeta(meta);
	}

}
 
开发者ID:Syst3ms,项目名称:QuarSK,代码行数:27,代码来源:SExprItemLayers.java

示例3: change

import org.bukkit.inventory.meta.BannerMeta; //导入依赖的package包/类
@Override
public void change(Event e, Object[] delta, @NotNull Changer.ChangeMode mode) {
	ItemStack i = item.getSingle(e);
	if (i == null) {
		return;
	}
	if (i.getType() == Material.BANNER || i.getType() == Material.SHIELD) {
		BannerMeta meta = ((BannerMeta) i.getItemMeta());
		switch (mode) {
			case SET:
				Color c = (Color) delta[0];
				meta.setBaseColor(c.getWoolColor());
				break;
			case RESET:
				meta.setBaseColor(DyeColor.WHITE);
				break;
		}
		i.setItemMeta(meta);
	}
}
 
开发者ID:Syst3ms,项目名称:QuarSK,代码行数:21,代码来源:SExprItemBaseColor.java

示例4: parseMncPattern

import org.bukkit.inventory.meta.BannerMeta; //导入依赖的package包/类
public static BannerMeta parseMncPattern(@NotNull String mnc) {
	if (mnc.matches("[a-p]a([a-p][b-zA-M])+")) {
		List<String> groups = StringUtils.sizedSplitString(mnc, 2, true);
		BannerMeta meta = emptyBannerMeta();
		meta.setBaseColor(colorFromMnc(mnc.charAt(0)));

		for (String str : groups.subList(1, groups.size())) {
			if (!str.isEmpty()) {
				meta.addPattern(new Pattern(colorFromMnc(str.toCharArray()[0]),
					patternTypeFromMnc(str.toCharArray()[1])
				));
			}
		}
		return meta;
	}
	return null;
}
 
开发者ID:Syst3ms,项目名称:QuarSK,代码行数:18,代码来源:BannerUtils.java

示例5: parse

import org.bukkit.inventory.meta.BannerMeta; //导入依赖的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

示例6: Flag

import org.bukkit.inventory.meta.BannerMeta; //导入依赖的package包/类
/**
 * Create a flag representing a banner item's layers. Does nothing if it is not
 * a banner
 * 
 * @param item
 *            the item. Does nothing if it isnt a banner
 */
@SuppressWarnings("deprecation")
public Flag(ItemStack item)
{
	this(DyeColor.WHITE);

	if(item.getType().equals(Material.BANNER))
	{
		BannerMeta bm = ((BannerMeta) item.getItemMeta());
		baseColor = bm.getBaseColor();

		for(int i = 0; i < bm.numberOfPatterns(); i++)
		{
			if(bm.getPattern(i).getPattern().equals(PatternType.BASE))
			{
				continue;
			}

			addLayer(new FlagLayer(bm.getPattern(i)));
		}
	}
}
 
开发者ID:PhantomAPI,项目名称:Phantom,代码行数:29,代码来源:Flag.java

示例7: saveBanner

import org.bukkit.inventory.meta.BannerMeta; //导入依赖的package包/类
static public void saveBanner(Player player, ItemStack banner) {
    //只處理旗幟
    if (!BannerUtil.isBanner(banner)) {
        player.sendMessage(MessageUtil.format(true, "&c" + tl("io.save-failed")));
        return;
    }
    //設定檔
    String fileName = getFileName(player);
    FileConfiguration config = KConfigManager.get(fileName);
    //索引值(時間戳記,不會重複)
    String key = String.valueOf(System.currentTimeMillis());
    //旗幟資訊
    BannerMeta bm = (BannerMeta) banner.getItemMeta();
    //儲存
    config.set(key + ".color", banner.getDurability());
    List<String> patternList = new ArrayList<>();
    for (Pattern pattern : bm.getPatterns()) {
        patternList.add(pattern.getPattern().getIdentifier() + ":" + pattern.getColor().toString());
    }
    if (patternList.size() > 0) {
        config.set(key + ".patterns", patternList);
    }
    KConfigManager.save(fileName);
    //訊息
    player.sendMessage(MessageUtil.format(true, "&a" + tl("io.save-success")));
}
 
开发者ID:jyhsu2000,项目名称:BannerMaker,代码行数:27,代码来源:IOUtil.java

示例8: executeCommand

import org.bukkit.inventory.meta.BannerMeta; //导入依赖的package包/类
@Override
public boolean executeCommand(CommandSender sender, Command cmd, String label, String[] args) {
    BannerMaker bm = (BannerMaker) plugin;
    Player player = (Player) sender;
    ItemStack itemStack = bm.getVersionHandler().getItemInMainHand(player);
    if (!BannerUtil.isBanner(itemStack)) {
        player.sendMessage(MessageUtil.format(true, "&c" + tl("command.not-banner-hand")));
        return true;
    }
    //複製旗幟,僅保留底色與樣式
    BannerMeta originalBannerMeta = (BannerMeta) itemStack.getItemMeta();
    KItemStack banner = new KItemStack(Material.BANNER)
        .durability(itemStack.getDurability())
        .setPatterns(originalBannerMeta.getPatterns());
    //顯示旗幟
    InventoryMenuUtil.showBannerInfo(player, banner);
    return true;
}
 
开发者ID:jyhsu2000,项目名称:BannerMaker,代码行数:19,代码来源:HandCommand.java

示例9: bannerAdd

import org.bukkit.inventory.meta.BannerMeta; //导入依赖的package包/类
/**
 * Adds {@link Pattern}s to this banner, assuming it is a banner.
 * <p />
 * <b>UNSAFE</b>
 *
 * @param patterns patterns to add
 *
 * @return this item builder instance, for chaining
 */
public ItemBuilder bannerAdd(Pattern... patterns) {
  if (patterns == null) {
    if (!this.failSilently) {
      throw new IllegalArgumentException("patterns cannot be null.");
    }
    return this;
  }
  if (isBannerMeta()) {
    try {
      for (Pattern pattern : patterns) {
        if (pattern != null) {
          ((BannerMeta) this.itemMeta).addPattern(pattern);
        } else {
          throw new NullPointerException("pattern element is null.");
        }
      }
    } catch (Exception e) {
      if (!this.failSilently) {
        e.printStackTrace();
      }
    }
  }
  return this;
}
 
开发者ID:SupaHam,项目名称:SupaCommons,代码行数:34,代码来源:ItemBuilder.java

示例10: serializeBanner

import org.bukkit.inventory.meta.BannerMeta; //导入依赖的package包/类
/**
 * A method to serialize banner meta to a JSONObject. Saves the base color, each pattern color, and each
 * pattern type.
 *
 * @param banner The BannerMeta to serialize
 * @return The JSONObject representation of the BannerMeta, or null if an exception occurred
 */
public static JSONObject serializeBanner(BannerMeta banner) {
    try {
        JSONObject root = new JSONObject();
        if (banner.getBaseColor() != null)
            root.put("base-color", banner.getBaseColor().getDyeData());

        JSONArray colors = new JSONArray();
        JSONArray patternTypes = new JSONArray();
        for (Pattern pattern : banner.getPatterns()) {
            colors.put(pattern.getColor().getDyeData());
            patternTypes.put(pattern.getPattern().getIdentifier());
        }

        root.put("colors", colors);
        root.put("pattern-types", patternTypes);

        return root;
    } catch (JSONException ex) {
        ex.printStackTrace();
        return null;
    }
}
 
开发者ID:ThisIzEthan,项目名称:NexusInventory,代码行数:30,代码来源:BannerSerialization.java

示例11: getBannerMeta

import org.bukkit.inventory.meta.BannerMeta; //导入依赖的package包/类
/**
 * A method to deserialize a BannerMeta object from a JSONObject. This method assumes that the JSONArrays containing
 * the colors and pattern types are the same length.
 *
 * @param json The JSONObject of the BannerMeta to deserialize
 * @return The BannerMeta or null if an exception occurs
 */
public static BannerMeta getBannerMeta(JSONObject json) {
    try {
        BannerMeta dummy = (BannerMeta) new ItemStack(Material.BANNER).getItemMeta();
        if (json.has("base-color"))
            dummy.setBaseColor(DyeColor.getByDyeData(Byte.parseByte("" + json.get("base-color"))));

        JSONArray colors = json.getJSONArray("colors");
        JSONArray patternTypes = json.getJSONArray("pattern-types");
        for (int i = 0; i < colors.length(); i++) {
            dummy.addPattern(new Pattern(DyeColor.getByDyeData(Integer.valueOf((int) colors.get(i)).byteValue()),
                    PatternType.getByIdentifier(patternTypes.getString(i))));
        }

        return dummy;
    } catch (JSONException ex) {
        ex.printStackTrace();
        return null;
    }
}
 
开发者ID:ThisIzEthan,项目名称:NexusInventory,代码行数:27,代码来源:BannerSerialization.java

示例12: processMeta

import org.bukkit.inventory.meta.BannerMeta; //导入依赖的package包/类
@Override
public void processMeta(Player player, ItemMeta m) {
    super.processMeta(player, m);
    BannerMeta meta = (BannerMeta) m;
    meta.setBaseColor(baseColor);
    meta.setPatterns(patterns);
}
 
开发者ID:upperlevel,项目名称:uppercore,代码行数:8,代码来源:BannerCustomItem.java

示例13: createBanner

import org.bukkit.inventory.meta.BannerMeta; //导入依赖的package包/类
public static ItemStack createBanner(String name, List<String> lore, DyeColor color){
    ItemStack banner = new ItemStack(Material.BANNER);
    BannerMeta itemMeta = (BannerMeta) banner.getItemMeta();
    itemMeta.addItemFlags(ItemFlag.HIDE_POTION_EFFECTS, ItemFlag.HIDE_ATTRIBUTES,
            ItemFlag.HIDE_DESTROYS, ItemFlag.HIDE_ENCHANTS, ItemFlag.HIDE_PLACED_ON, ItemFlag.HIDE_UNBREAKABLE);
    ArrayList<String> colorLore = new ArrayList<>();
    if (lore != null) {
        lore.forEach(str -> colorLore.add(Utils.colorize(str)));
        itemMeta.setLore(colorLore);
    }
    itemMeta.setBaseColor(color);
    itemMeta.setDisplayName(name);
    banner.setItemMeta(itemMeta);
    return banner;
}
 
开发者ID:cadox8,项目名称:WC,代码行数:16,代码来源:ItemUtil.java

示例14: setBanner

import org.bukkit.inventory.meta.BannerMeta; //导入依赖的package包/类
/**
 * @param banner
 * the banner to set
 */
public void setBanner(ItemStack banner) {
    if (banner.getType() != Material.BANNER && banner.getType() != Material.SHIELD) {
        return;
    }

    this.banner = (BannerMeta) banner.getItemMeta();
    bannerColor = banner.getDurability();
}
 
开发者ID:DRE2N,项目名称:FactionsXL,代码行数:13,代码来源:LegalEntity.java

示例15: get

import org.bukkit.inventory.meta.BannerMeta; //导入依赖的package包/类
@NotNull
@Override
protected ItemStack[] get(Event event) {
	ItemStack banner = new ItemStack(type);
	BannerMeta meta = (BannerMeta) banner.getItemMeta();
	meta.setBaseColor(CollectionUtils.getRandom(DyeColor.values()));
	for (int i = 0; i < new Random().nextInt(7); i++)
		meta.addPattern(new Pattern(CollectionUtils.getRandom(DyeColor.values()),
			CollectionUtils.getRandom(PatternType.values())
		));
	banner.setItemMeta(meta);
	return new ItemStack[]{banner};
}
 
开发者ID:Syst3ms,项目名称:QuarSK,代码行数:14,代码来源:ExprRandomBanner.java


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