本文整理汇总了Java中org.bukkit.block.Banner.getBaseColor方法的典型用法代码示例。如果您正苦于以下问题:Java Banner.getBaseColor方法的具体用法?Java Banner.getBaseColor怎么用?Java Banner.getBaseColor使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.bukkit.block.Banner
的用法示例。
在下文中一共展示了Banner.getBaseColor方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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)));
}
}
}
示例2: 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;
}
示例3: updateFrom
import org.bukkit.block.Banner; //导入方法依赖的package包/类
@SuppressWarnings("deprecation")
public void updateFrom(Block block, Set<Material> restrictedMaterials) {
if (block == null) {
isValid = false;
return;
}
if (!block.getChunk().isLoaded()) {
block.getChunk().load(true);
return;
}
Material blockMaterial = block.getType();
if (restrictedMaterials != null && restrictedMaterials.contains(blockMaterial)) {
isValid = false;
return;
}
// Look for special block states
extraData = null;
material = blockMaterial;
data = (short)block.getData();
try {
BlockState blockState = block.getState();
if (material == Material.FLOWER_POT || blockState instanceof InventoryHolder || blockState instanceof Sign) {
extraData = new BlockTileEntity(NMSUtils.getTileEntityData(block.getLocation()));
} else if (blockState instanceof CommandBlock){
// This seems to occasionally throw exceptions...
CommandBlock command = (CommandBlock)blockState;
extraData = new BlockCommand(command.getCommand(), command.getName());
} else if (blockState instanceof Skull) {
Skull skull = (Skull)blockState;
data = (short)skull.getSkullType().ordinal();
extraData = new BlockSkull(CompatibilityUtils.getSkullProfile(skull), skull.getSkullType(), skull.getRotation());
} else if (blockState instanceof CreatureSpawner) {
CreatureSpawner spawner = (CreatureSpawner)blockState;
extraData = new BlockMobSpawner(spawner.getCreatureTypeName());
} else if (blockMaterial == Material.STANDING_BANNER || blockMaterial == Material.WALL_BANNER) {
if (blockState != null && blockState instanceof Banner) {
Banner banner = (Banner)blockState;
DyeColor color = banner.getBaseColor();
extraData = new BlockBanner(banner.getPatterns(), color);
}
}
} catch (Exception ex) {
ex.printStackTrace();
}
isValid = true;
}