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


Java BannerMeta.setBaseColor方法代码示例

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


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

示例1: 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

示例2: 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

示例3: 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

示例4: 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

示例5: 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

示例6: 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

示例7: convert

import org.bukkit.inventory.meta.BannerMeta; //导入方法依赖的package包/类
@Override
public ItemStack convert(Block block) {
	if (block.getType() == Material.STANDING_BANNER || block.getType() == Material.WALL_BANNER) {
		Banner banner = (Banner) block.getState();
		ItemStack item = new ItemStack(Material.BANNER);
		BannerMeta meta = (BannerMeta) item.getItemMeta();
		meta.setPatterns(banner.getPatterns());
		meta.setBaseColor(banner.getBaseColor());
		item.setItemMeta(meta);
		return item;
	}
	return null;
}
 
开发者ID:Syst3ms,项目名称:QuarSK,代码行数:14,代码来源:ExprItemOfBannerBlock.java

示例8: get

import org.bukkit.inventory.meta.BannerMeta; //导入方法依赖的package包/类
@Nullable
@Override
protected ItemStack[] get(Event e) {
	Color c = color.getSingle(e);
	if (c == null)
		return null;
	ItemStack returnItem = new ItemStack(mat);
	BannerMeta meta = ((BannerMeta) returnItem.getItemMeta());
	meta.setPatterns(Arrays.asList(patterns.getAll(e)));
	meta.setBaseColor(c.getWoolColor());
	returnItem.setItemMeta(meta);
	return new ItemStack[]{returnItem};
}
 
开发者ID:Syst3ms,项目名称:QuarSK,代码行数:14,代码来源:ExprBannerOrShieldWithLayers.java

示例9: 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,项目名称:PA,代码行数:16,代码来源:ItemUtil.java

示例10: getRandomMeta

import org.bukkit.inventory.meta.BannerMeta; //导入方法依赖的package包/类
/**
 * Gets random banner meta
 *
 * @return banner meta
 */
public static BannerMeta getRandomMeta() {
	if(ConfigManager.getServerVersion().isOlderThan(ConfigManager.ServerVersion.MINECRAFT_1_8_R2)) {
		return null;
	}

	BannerMeta meta = (BannerMeta) Bukkit.getItemFactory().getItemMeta(Material.BANNER);
	meta.setBaseColor(randomDyeColor());

	for(int i = NumberUtils.randInt(0, PatternType.values().length) + 2; i > 0; i--) {
		meta.addPattern(new Pattern(randomDyeColor(), randomPatternType()));
	}

	return meta;
}
 
开发者ID:MarcinWieczorek,项目名称:NovaGuilds,代码行数:20,代码来源:BannerUtils.java

示例11: getBannerMeta

import org.bukkit.inventory.meta.BannerMeta; //导入方法依赖的package包/类
/**
 * Turns a banner into banner meta
 *
 * @param banner banner block
 * @return banner meta
 */
public static BannerMeta getBannerMeta(Banner banner) {
	if(ConfigManager.getServerVersion().isOlderThan(ConfigManager.ServerVersion.MINECRAFT_1_8_R2)) {
		return null;
	}

	BannerMeta meta = (BannerMeta) Bukkit.getItemFactory().getItemMeta(Material.BANNER);

	meta.setBaseColor(banner.getBaseColor());
	for(Pattern pattern : banner.getPatterns()) {
		meta.addPattern(pattern);
	}

	return meta;
}
 
开发者ID:MarcinWieczorek,项目名称:NovaGuilds,代码行数:21,代码来源:BannerUtils.java

示例12: getItemMeta

import org.bukkit.inventory.meta.BannerMeta; //导入方法依赖的package包/类
public static BannerMeta getItemMeta(Banner block) {
    BannerMeta meta = (BannerMeta) Bukkit.getItemFactory().getItemMeta(Material.BANNER);
    meta.setBaseColor(block.getBaseColor());
    meta.setPatterns(block.getPatterns());
    return meta;
}
 
开发者ID:OvercastNetwork,项目名称:ProjectAres,代码行数:7,代码来源:Banners.java

示例13: toMeta

import org.bukkit.inventory.meta.BannerMeta; //导入方法依赖的package包/类
public static BannerMeta toMeta(BannerMeta meta, Banner block) {
    meta.setBaseColor(block.getBaseColor());
    meta.setPatterns(block.getPatterns());
    return meta;
}
 
开发者ID:ShootGame,项目名称:Arcade2,代码行数:6,代码来源:BannerUtils.java

示例14: deserialize

import org.bukkit.inventory.meta.BannerMeta; //导入方法依赖的package包/类
@Override
public BannerMeta deserialize(String string) {
	BannerMeta meta = (BannerMeta) Bukkit.getItemFactory().getItemMeta(Material.BANNER);

	if(string == null || string.isEmpty()) {
		return meta;
	}

	String baseColorString;
	String patternsString;

	if(StringUtils.contains(string, ':')) {
		String[] baseSplit = StringUtils.split(string, ':');
		baseColorString = baseSplit[0];
		patternsString = baseSplit[1];
	}
	else {
		baseColorString = string;
		patternsString = "";
	}

	meta.setBaseColor(DyeColor.valueOf(baseColorString));

	if(!patternsString.isEmpty()) {
		String[] patternsSplit;

		if(StringUtils.contains(patternsString, '|')) {
			patternsSplit = StringUtils.split(patternsString, '|');
		}
		else {
			patternsSplit = new String[]{
					patternsString
			};
		}

		for(String patternString : patternsSplit) {
			String[] patternSplit = StringUtils.split(patternString, '-');

			meta.addPattern(new Pattern(DyeColor.valueOf(patternSplit[0]), PatternType.getByIdentifier(patternSplit[1])));
		}
	}

	return meta;
}
 
开发者ID:MarcinWieczorek,项目名称:NovaGuilds,代码行数:45,代码来源:BannerMetaSerializerImpl.java

示例15: CustomBanner

import org.bukkit.inventory.meta.BannerMeta; //导入方法依赖的package包/类
public CustomBanner(DyeColor color, Pattern... patterns) {
	super(Material.BANNER);
	
	BannerMeta meta = (BannerMeta) getItemMeta();
	
	meta.setBaseColor(color);
	
	for (Pattern pattern: patterns) {
		meta.addPattern(pattern);
	}
	
	setItemMeta(meta);
}
 
开发者ID:TheBusyBiscuit,项目名称:CS-CoreLib,代码行数:14,代码来源:CustomBanner.java


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