类org.bukkit.inventory.meta.BlockStateMeta源码实例Demo

下面列出了怎么用org.bukkit.inventory.meta.BlockStateMeta的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: NyaaUtils   文件: SignEditListener.java
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onBlockPlace(BlockPlaceEvent event) {
    Block block = event.getBlock();
    ItemStack item = event.getItemInHand();
    if (block != null && item != null &&
            isSign(item.getType()) &&
            isSign(block.getType())) {
        Player player = event.getPlayer();
        if ((player.isOp() && player.getGameMode().equals(GameMode.CREATIVE)) ||
                !item.hasItemMeta() || !(item.getItemMeta() instanceof BlockStateMeta) ||
                !player.hasPermission("nu.se.player")) {
            return;
        }
        SignContent c = SignContent.fromItemStack(item);
        if (!c.getContent().isEmpty()) {
            signContents.put(event.getPlayer().getUniqueId(), c);
        }
    }
}
 
源代码2 项目: NyaaUtils   文件: SignContent.java
public static SignContent fromItemStack(ItemStack item) {
    SignContent content = new SignContent();
    if (item.hasItemMeta() && item.getItemMeta() instanceof BlockStateMeta) {
        BlockStateMeta blockStateMeta = (BlockStateMeta) item.getItemMeta();
        if (blockStateMeta.hasBlockState() && blockStateMeta.getBlockState() instanceof Sign) {
            Sign sign = ((Sign) blockStateMeta.getBlockState());
            for (int i = 0; i < 4; i++) {
                content.setLine(i, sign.getLine(i));
            }
        }
    }
    return content;
}
 
源代码3 项目: NyaaUtils   文件: SignContent.java
public ItemStack toItemStack(ItemStack item) {
    if (item.getItemMeta() instanceof BlockStateMeta) {
        BlockStateMeta blockStateMeta = (BlockStateMeta) item.getItemMeta();
        if (blockStateMeta.getBlockState() instanceof Sign) {
            Sign sign = ((Sign) blockStateMeta.getBlockState());
            for (int i = 0; i < 4; i++) {
                sign.setLine(i, getLine(i));
            }
            blockStateMeta.setBlockState(sign);
        }
        item.setItemMeta(blockStateMeta);
    }
    return item;
}
 
源代码4 项目: NovaGuilds   文件: BannerUtils.java
/**
 * 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() != CompatibilityUtils.Mat.WHITE_BANNER.get()) {
		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;
}
 
源代码5 项目: factions-top   文件: Craftbukkit18R3.java
@Override
public EntityType getSpawnerType(ItemStack item) {
    BlockStateMeta bsm = (BlockStateMeta) item.getItemMeta();
    CreatureSpawner bs = (CreatureSpawner) bsm.getBlockState();
    return bs.getSpawnedType();
}
 
 类所在包
 类方法
 同包方法