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


Java Banner类代码示例

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


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

示例1: placeStanding

import org.bukkit.block.Banner; //导入依赖的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.block.Banner; //导入依赖的package包/类
@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,代码行数:26,代码来源:SExprBannerBlockLayers.java

示例3: change

import org.bukkit.block.Banner; //导入依赖的package包/类
@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,代码行数:22,代码来源:SExprBannerBlockBaseColor.java

示例4: Flag

import org.bukkit.block.Banner; //导入依赖的package包/类
/**
 * Create a flag representing the given banner block
 * 
 * @param block
 *            the block. Does nothing if it is not a banner
 */
public Flag(Block block)
{
	this(DyeColor.WHITE);

	if(block.getState() instanceof Banner)
	{
		Banner bm = ((Banner) block.getState());
		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,代码行数:27,代码来源:Flag.java

示例5: executeCommand

import org.bukkit.block.Banner; //导入依赖的package包/类
@Override
public boolean executeCommand(CommandSender sender, Command command, String label, String[] args) {
    Player player = (Player) sender;
    Block block = player.getTargetBlock((Set<Material>) null, 20);
    if (block.getType() != Material.STANDING_BANNER && block.getType() != Material.WALL_BANNER) {
        player.sendMessage(MessageUtil.format(true, "&c" + tl("command.not-banner-see")));
        return true;
    }
    //根據方塊建立旗幟
    Banner blockState = (Banner) block.getState();
    KItemStack banner = new KItemStack(Material.BANNER)
        .durability(DyeColorUtil.toShort(blockState.getBaseColor()))
        .setPatterns(blockState.getPatterns());
    //顯示旗幟
    InventoryMenuUtil.showBannerInfo(player, banner);
    return true;
}
 
开发者ID:jyhsu2000,项目名称:BannerMaker,代码行数:18,代码来源:SeeCommand.java

示例6: serializeBanner

import org.bukkit.block.Banner; //导入依赖的package包/类
private static Map<String, Object> serializeBanner(Banner banner) {
	Map<String, Object> serializedBanner = new LinkedHashMap<>();
	if (banner != null) {
		DyeColor baseDyeColor = banner.getBaseColor();
		if (baseDyeColor != null) {
			serializedBanner.put("Base", Utilities.serializeColor(baseDyeColor.getColor()));
		}
		List<Pattern> bannerPatterns = banner.getPatterns();
		if (bannerPatterns != null && !bannerPatterns.isEmpty()) {
			Map<String, Map<String, Object>> serializedPatterns = new LinkedHashMap<>();
			for (int patternIndex = 0; patternIndex < bannerPatterns.size(); patternIndex++) {
				Pattern bannerPattern = bannerPatterns.get(patternIndex);
				Map<String, Object> serializedPattern = new LinkedHashMap<>();
				if (bannerPattern.getColor() != null) {
					serializedPattern.put("Color", Utilities.serializeColor(bannerPattern.getColor().getColor()));
				}
				serializedPattern.put("Pattern", StringUtilities.capitalizeFully(bannerPattern.getPattern().name().replace('_', ' ')));
				serializedPatterns.put("Pattern " + (patternIndex + 1), serializedPattern);
			}
			serializedBanner.put("Patterns", serializedPatterns);
		}
	}
	return serializedBanner;
}
 
开发者ID:KingFaris10,项目名称:KingKits,代码行数:25,代码来源:ItemUtilities.java

示例7: set

import org.bukkit.block.Banner; //导入依赖的package包/类
public boolean set(Block block) {
    Banner banner = (Banner) block.getState();
    banner.setBaseColor(bannerBaseColor);
    banner.setPatterns(bannerPattern);
    banner.update();
    return true;
}
 
开发者ID:tastybento,项目名称:bskyblock,代码行数:8,代码来源:BannerBlock.java

示例8: convert

import org.bukkit.block.Banner; //导入依赖的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

示例9: get

import org.bukkit.block.Banner; //导入依赖的package包/类
@Nullable
@Override
protected Pattern[] get(Event e) {
	Block b = block.getSingle(e);
	if (b == null) {
		return null;
	}
	if (b.getType() == Material.STANDING_BANNER || b.getType() == Material.WALL_BANNER) {
		return ((Banner) b.getState()).getPatterns().stream().toArray(Pattern[]::new);
	}
	return null;
}
 
开发者ID:Syst3ms,项目名称:QuarSK,代码行数:13,代码来源:SExprBannerBlockLayers.java

示例10: execute

import org.bukkit.block.Banner; //导入依赖的package包/类
@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,代码行数:16,代码来源:EffApplyBannerItemToBlock.java

示例11: parseFlagXml

import org.bukkit.block.Banner; //导入依赖的package包/类
public Flag parseFlagXml(CaptureGame game, Element xml, Flag flag) {
    // capture
    Element captureElement = xml.getChild("capture");
    if (captureElement == null) {
        return null;
    }

    FlagCapture capture = this.parseFlagCapture(game, captureElement, new FlagCapture(game, flag));
    if (capture == null) {
        return null;
    }

    int objective = XMLParser.parseInt(xml.getAttributeValue("objective"), Flag.NOT_OBJECTIVE);

    // spawn
    Element spawnElement = xml.getChild("spawn");
    if (spawnElement == null) {
        return null;
    }

    FlagSpawn spawn = this.parseFlagSpawn(game, captureElement, new FlagSpawn(game, flag));
    if (spawn == null) {
        return null;
    }

    Banner banner = findBannerIn(spawn.getRegion());
    if (banner == null) {
        return null;
    }

    // setup
    flag.setCapture(capture);
    flag.getItem().transferMetaFrom(banner);
    flag.setObjective(objective);
    flag.setSpawn(spawn);
    flag.getSpawn().setDirection(BlockFace.byYaw(banner.getBlock().getLocation().getYaw()));
    return flag;
}
 
开发者ID:ShootGame,项目名称:Arcade2,代码行数:39,代码来源:FlagFactory.java

示例12: findBannerIn

import org.bukkit.block.Banner; //导入依赖的package包/类
public static Banner findBannerIn(Region region) {
    for (Block block : region.getBlocks()) {
        if (BannerUtils.isBanner(block)) {
            return (Banner) block.getState();
        }
    }

    return null;
}
 
开发者ID:ShootGame,项目名称:Arcade2,代码行数:10,代码来源:FlagFactory.java

示例13: toItem

import org.bukkit.block.Banner; //导入依赖的package包/类
public static ItemStack toItem(ItemStack item, Banner block) {
    BannerMeta meta = meta(item);
    if (meta != null) {
        item.setItemMeta(toMeta(meta, block));
    }

    return item;
}
 
开发者ID:ShootGame,项目名称:Arcade2,代码行数:9,代码来源:BannerUtils.java

示例14: serializeState

import org.bukkit.block.Banner; //导入依赖的package包/类
@SuppressWarnings("deprecation")
public static Optional<String> serializeState(BlockState state) {
    YamlConfiguration yaml = new YamlConfiguration();

    // http://minecraft.gamepedia.com/Block_entity was used as a reference for this method

    if (state instanceof InventoryHolder) {
        yaml.set(INVENTORY_KEY, InventoryHelper.serializeInventory(((InventoryHolder) state).getInventory()));
    }

    if (state instanceof Sign) {
        yaml.set(SIGN_LINES_KEY, Arrays.asList(((Sign) state).getLines()));
    } else if (Support.BANNER && state instanceof Banner) {
        yaml.set(BANNER_BASE_COLOR_KEY, ((Banner) state).getBaseColor().name());
        ConfigurationSection patternSection = yaml.createSection(BANNER_PATTERNS_KEY);
        List<Pattern> patterns = ((Banner) state).getPatterns();
        for (int i = 0; i < patterns.size(); i++) {
            ConfigurationSection subSection = patternSection.createSection("" + i);
            subSection.set(BANNER_PATTERN_COLOR_KEY, patterns.get(i).getColor().name());
            subSection.set(BANNER_PATTERN_TYPE_KEY, patterns.get(i).getPattern().name());
        }
    } else if (state instanceof CreatureSpawner) {
        yaml.set(SPAWNER_TYPE_KEY, ((CreatureSpawner) state).getSpawnedType().name());
        yaml.set(SPAWNER_DELAY_KEY, ((CreatureSpawner) state).getDelay());
    } else if (state instanceof NoteBlock) {
        yaml.set(NOTE_OCTAVE_KEY, ((NoteBlock) state).getNote().getOctave());
        yaml.set(NOTE_TONE_KEY, ((NoteBlock) state).getNote().getTone().name());
    } else if (state instanceof Jukebox) {
        if (((Jukebox) state).isPlaying()) {
            yaml.set(JUKEBOX_DISC_KEY, ((Jukebox) state).getPlaying());
        }
    } else if (state instanceof Skull) {
        yaml.set(SKULL_OWNER_KEY, ((Skull) state).getOwner());
        yaml.set(SKULL_ROTATION_KEY, ((Skull) state).getRotation().name());
    } else if (state instanceof CommandBlock) {
        yaml.set(COMMAND_NAME_KEY, ((CommandBlock) state).getName());
        yaml.set(COMMAND_CMD_KEY, ((CommandBlock) state).getCommand());
    } else if (state instanceof FlowerPot) {
        yaml.set(FLOWER_TYPE_KEY, ((FlowerPot) state).getContents().getItemType().name());
        yaml.set(FLOWER_DATA_KEY, ((FlowerPot) state).getContents().getData());
    }

    if (yaml.getKeys(false).size() > 0) {
        return Optional.of(yaml.saveToString());
    }
    return Optional.absent();
}
 
开发者ID:caseif,项目名称:Steel,代码行数:48,代码来源:BlockStateSerializer.java

示例15: applyMeta

import org.bukkit.block.Banner; //导入依赖的package包/类
/**
 * Applies meta to a shield
 *
 * @param itemStack  shield item
 * @param bannerMeta banner meta
 * @return shield item
 */
public static ItemStack applyMeta(ItemStack itemStack, BannerMeta bannerMeta) {
	if(itemStack.getType() != Material.SHIELD && itemStack.getType() != Material.BANNER) {
		throw new IllegalArgumentException("Passed ItemStack is not a shield nor a banner");
	}

	ItemMeta meta = itemStack.getItemMeta();
	BlockStateMeta blockStateMeta = (BlockStateMeta) meta;
	Banner banner = (Banner) blockStateMeta.getBlockState();
	applyMeta(banner, bannerMeta);
	banner.update();
	blockStateMeta.setBlockState(banner);
	itemStack.setItemMeta(blockStateMeta);
	return itemStack;
}
 
开发者ID:MarcinWieczorek,项目名称:NovaGuilds,代码行数:22,代码来源:BannerUtils.java


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