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


Java Material.BANNER属性代码示例

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


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

示例1: onExecute

@Override
public void onExecute(String[] args, CommandSender sender) {
    Player player = (Player) sender;
    Faction faction = getSenderFactionOrFromArg(sender, args, 1);
    if (faction == null) {
        return;
    }

    if (!faction.isAdmin(player)) {
        ParsingUtil.sendMessage(sender, FMessage.ERROR_NO_PERMISSION.getMessage());
        return;
    }

    ItemStack item = player.getInventory().getItemInMainHand();
    if (item == null || item.getType() != Material.BANNER) {
        displayHelp(player);
        return;
    }

    faction.setBanner(item);
    faction.sendMessage(FMessage.CMD_SET_BANNER_SUCCESS.getMessage(), player, faction);
}
 
开发者ID:DRE2N,项目名称:FactionsXL,代码行数:22,代码来源:SetBannerCommand.java

示例2: change

@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,代码行数:26,代码来源:SExprItemLayers.java

示例3: change

@Override
public void change(Event e, Object[] delta, @NotNull Changer.ChangeMode mode) {
	Block b = block.getSingle(e);
	if (b == null) {
		return;
	}
	if (b.getType() == Material.BANNER) {
		Banner banner = (Banner) b.getState();
		Pattern[] patterns = (Pattern[]) delta;
		switch (mode) {
			case ADD:
				Arrays.asList(patterns).forEach(banner::addPattern);
				break;
			case SET:
				banner.setPatterns(Arrays.asList(patterns));
				break;
			case DELETE:
			case RESET:
				for (int i = 1; i <= banner.numberOfPatterns(); i++)
					banner.removePattern(i);
				break;
		}
		banner.update(true, false);
	}
}
 
开发者ID:Syst3ms,项目名称:QuarSK,代码行数:25,代码来源:SExprBannerBlockLayers.java

示例4: change

@Override
public void change(Event e, Object[] delta, @NotNull Changer.ChangeMode mode) {
	Block b = block.getSingle(e);
	if (b == null) {
		return;
	}
	if (b.getType() == Material.BANNER) {
		Banner banner = ((Banner) b.getState());
		switch (mode) {
			case SET:
				Color c = (Color) delta[0];
				banner.setBaseColor(c.getWoolColor());
				break;
			case RESET:
				banner.setBaseColor(DyeColor.WHITE);
				break;
		}
		banner.update(true, false);
	}

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

示例5: change

@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,代码行数:20,代码来源:SExprItemBaseColor.java

示例6: getRepresentation

/**
 * {@inheritDoc}
 */
@Override
public default ItemStack getRepresentation() {
	ItemStack stack = new ItemStack(Material.BANNER);
	ItemMeta meta = stack.getItemMeta();
	meta.setDisplayName(ChatColor.GRAY + "Banner Add Pattern");
	stack.setItemMeta(meta);
	return stack;
}
 
开发者ID:Jannyboy11,项目名称:CustomRecipes,代码行数:11,代码来源:BannerAddPatternRecipe.java

示例7: getRepresentation

/**
 * {@inheritDoc}
 */
@Override
public default ItemStack getRepresentation() {
	ItemStack stack = new ItemStack(Material.BANNER);
	ItemMeta meta = stack.getItemMeta();
	meta.setDisplayName(ChatColor.GRAY + "Banner Duplicate Pattern");
	stack.setItemMeta(meta);
	return stack;
}
 
开发者ID:Jannyboy11,项目名称:CustomRecipes,代码行数:11,代码来源:BannerDuplicateRecipe.java

示例8: createBanner

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,代码行数:15,代码来源:ItemUtil.java

示例9: setBanner

/**
 * @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,代码行数:12,代码来源:LegalEntity.java

示例10: onExecute

@Override
public void onExecute(String[] args, CommandSender sender) {
    Player player = (Player) sender;
    Set<Faction> factions = plugin.getFactionCache().getActive();

    int size = (int) (9 * Math.ceil(((double) factions.size() / 9)));
    Inventory gui = Bukkit.createInventory(null, size, FMessage.CMD_LIST_TITLE.getMessage());
    for (Faction faction : plugin.getFactionCache().getActive()) {
        int members = faction.getMembers().contains(faction.getAdmin()) ? faction.getMembers().size() : faction.getMembers().size() + 1;
        ItemStack banner = new ItemStack(Material.BANNER, members, faction.getBannerColor());
        ItemMeta meta = faction.getBanner() != null ? faction.getBanner().clone() : banner.getItemMeta();
        meta.setDisplayName(ParsingUtil.getFactionName(player, faction));

        ChatColor c = faction.getRelation(plugin.getFactionCache().getByMember(player)).getColor();
        String leader = faction.getAdmin() != null ? faction.getAdmin().getName() : ChatColor.ITALIC + "Interregnum";
        String govType = faction.getGovernmentType().getName();
        if (faction.getGovernmentType() == GovernmentType.MONARCHY) {
            govType += " (" + (faction.getDynasty() != null ? faction.getDynasty().getName() : ChatColor.ITALIC + "Interregnum") + c + ")";
        }
        String power = String.valueOf(faction.getPower());
        String provinces = String.valueOf(faction.getRegions().size());
        meta.setLore(Arrays.asList(FMessage.CMD_SHOW_GOVERNMENT_TYPE.getMessage() + c + govType,
                FMessage.CMD_SHOW_LEADER.getMessage() + c + leader,
                FMessage.CMD_SHOW_INFO.getMessage(c.toString(), power, provinces)
        ));
        meta.addItemFlags(ItemFlag.HIDE_POTION_EFFECTS);
        banner.setItemMeta(meta);
        gui.addItem(banner);
    }
    player.openInventory(gui);
}
 
开发者ID:DRE2N,项目名称:FactionsXL,代码行数:31,代码来源:ListCommand.java

示例11: get

@Nullable
@Override
protected Pattern[] get(Event e) {
	ItemStack i = item.getSingle(e);
	if (i == null) {
		return null;
	}
	if (i.getType() == Material.BANNER || i.getType() == Material.SHIELD) {
		return ((BannerMeta) i.getItemMeta()).getPatterns().stream().toArray(Pattern[]::new);
	}
	return null;
}
 
开发者ID:Syst3ms,项目名称:QuarSK,代码行数:12,代码来源:SExprItemLayers.java

示例12: convert

@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,代码行数:13,代码来源:ExprItemOfBannerBlock.java

示例13: init

@Override
public boolean init(Expression<?>[] expr, int i, Kleenean kleenean, @NotNull SkriptParser.ParseResult parseResult) {
	mat = parseResult.mark == 0 ? Material.BANNER : Material.SHIELD;
	patterns = (Expression<Pattern>) expr[0];
	color = (Expression<Color>) expr[1];
	return true;
}
 
开发者ID:Syst3ms,项目名称:QuarSK,代码行数:7,代码来源:ExprBannerOrShieldWithLayers.java

示例14: get

@Nullable
@Override
protected String[] get(Event e) {
	ItemStack i = item.getSingle(e);
	if (i == null) {
		return null;
	}
	if (i.getType() == Material.BANNER || i.getType() == Material.SHIELD) {
		return new String[]{BannerUtils.toMncPattern((BannerMeta) i.getItemMeta())};
	}
	return null;
}
 
开发者ID:Syst3ms,项目名称:QuarSK,代码行数:12,代码来源:ExprBannerItemToMnc.java

示例15: execute

@Override
protected void execute(Event e) {
	ItemStack i = item.getSingle(e);
	Block b = block.getSingle(e);
	if (i == null || b == null) {
		return;
	}
	if ((i.getType() == Material.BANNER || i.getType() == Material.SHIELD) && b.getType() == Material.BANNER) {
		BannerMeta itemMeta = ((BannerMeta) i.getItemMeta());
		Banner blockMeta = ((Banner) b.getState());
		blockMeta.setPatterns(itemMeta.getPatterns());
		blockMeta.setBaseColor(itemMeta.getBaseColor());
		blockMeta.update(true, false);
	}
}
 
开发者ID:Syst3ms,项目名称:QuarSK,代码行数:15,代码来源:EffApplyBannerItemToBlock.java


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