本文整理汇总了Java中org.bukkit.inventory.meta.BannerMeta.getPatterns方法的典型用法代码示例。如果您正苦于以下问题:Java BannerMeta.getPatterns方法的具体用法?Java BannerMeta.getPatterns怎么用?Java BannerMeta.getPatterns使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.bukkit.inventory.meta.BannerMeta
的用法示例。
在下文中一共展示了BannerMeta.getPatterns方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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")));
}
示例2: 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;
}
}
示例3: toMncPattern
import org.bukkit.inventory.meta.BannerMeta; //导入方法依赖的package包/类
public static String toMncPattern(@NotNull BannerMeta meta) {
List<String> stringList = new ArrayList<>();
stringList.add(colorToMnc(meta.getBaseColor()) + "a");
for (Pattern pattern : meta.getPatterns()) {
stringList.add(new String(new char[]{colorToMnc(pattern.getColor()), patternTypeToMnc(pattern.getPattern())}));
}
return StringUtils.join(stringList.toArray(new String[stringList.size()]));
}
示例4: serialize
import org.bukkit.inventory.meta.BannerMeta; //导入方法依赖的package包/类
@Override
public String serialize(BannerMeta bannerMeta) {
if(bannerMeta == null) {
return "";
}
StringBuilder builder = new StringBuilder();
builder.append((bannerMeta.getBaseColor() == null ? DyeColor.BLACK : bannerMeta.getBaseColor()).name());
if(bannerMeta.numberOfPatterns() > 0) {
builder.append(':');
}
int index = 1;
for(Pattern pattern : bannerMeta.getPatterns()) {
builder.append(pattern.getColor().name());
builder.append('-');
builder.append(pattern.getPattern().getIdentifier());
if(index < bannerMeta.numberOfPatterns()) {
builder.append("|");
}
index++;
}
return builder.toString();
}
示例5: initialize
import org.bukkit.inventory.meta.BannerMeta; //导入方法依赖的package包/类
@Override
public SerialItemData initialize(ItemStack stack) {
ItemMeta meta = stack.getItemMeta();
if(meta instanceof BannerMeta) {
valid = true;
BannerMeta bannerMeta = (BannerMeta)meta;
patternList = bannerMeta.getPatterns();
}
return this;
}