當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。