本文整理汇总了Java中org.bukkit.block.Banner.update方法的典型用法代码示例。如果您正苦于以下问题:Java Banner.update方法的具体用法?Java Banner.update怎么用?Java Banner.update使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.bukkit.block.Banner
的用法示例。
在下文中一共展示了Banner.update方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
}
示例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);
}
}
示例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);
}
}
示例4: 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;
}
示例5: 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);
}
}
示例6: 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;
}
示例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(true, false);
return true;
}
示例8: renderBanner
import org.bukkit.block.Banner; //导入方法依赖的package包/类
public boolean renderBanner(Banner banner, DyeColor color) {
banner.setBaseColor(color);
return banner.update(false, false);
}
示例9: setBannerFacing
import org.bukkit.block.Banner; //导入方法依赖的package包/类
public static void setBannerFacing(BlockFace face, Banner banner) {
org.bukkit.material.Banner data = (org.bukkit.material.Banner) banner.getMaterialData();
data.setFacingDirection(face);
banner.setMaterialData(data);
banner.update();
}
示例10: setBlockBanner
import org.bukkit.block.Banner; //导入方法依赖的package包/类
/**
* Sets up a {@link BlockState} with the properties of a {@link BannerMeta}. This method finally
* calls {@link BlockState#update(boolean, boolean)} with the first boolean as {@code true} and
* the second as {@code false}, causing an update but without any physics checks.
*
* @param state block state to modify
* @param bannerMeta banner metadata to apply to {@code block}
*
* @throws IllegalArgumentException if the {@code block} is not {@link Material#STANDING_BANNER}
* or {@link Material#WALL_BANNER}
*/
public static void setBlockBanner(BlockState state, BannerMeta bannerMeta) {
Preconditions.checkArgument(state instanceof Banner, "block state is not of Banner.");
Banner bannerState = (Banner) state;
bannerState.setBaseColor(bannerMeta.getBaseColor());
bannerState.setPatterns(bannerMeta.getPatterns());
bannerState.update(true, false);
}