本文整理了Java中org.bukkit.block.Block.hasMetadata()
方法的一些代码示例,展示了Block.hasMetadata()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Block.hasMetadata()
方法的具体详情如下:
包路径:org.bukkit.block.Block
类名称:Block
方法名:hasMetadata
暂无
代码示例来源:origin: bergerkiller/BKCommonLib
@Override
public boolean hasMetadata(String metadataKey) {
return base.hasMetadata(metadataKey);
}
代码示例来源:origin: AddstarMC/Minigames
@EventHandler(ignoreCancelled=true)
private void breakScoreboard(BlockBreakEvent event) {
Block block = event.getBlock();
if (block.getType() == Material.WALL_SIGN) {
if (block.hasMetadata("MGScoreboardSign")) {
Minigame minigame = (Minigame)block.getMetadata("Minigame").get(0).value();
minigame.getScoreboardData().removeDisplay(block);
}
}
}
}
代码示例来源:origin: ChestShop-authors/ChestShop-3
@EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR)
public static void onSign(BlockPhysicsEvent event) {
Block block = event.getBlock();
if (!BlockUtil.isSign(block)) {
return;
}
Sign sign = (Sign) block.getState();
Block attachedBlock = BlockUtil.getAttachedBlock(sign);
if (attachedBlock.getType() == Material.AIR && ChestShopSign.isValid(sign)) {
if (!block.hasMetadata(METADATA_NAME)) {
return;
}
sendShopDestroyedEvent(sign, (Player) block.getMetadata(METADATA_NAME).get(0).value());
}
}
代码示例来源:origin: NyaaCat/RPGItems-reloaded
@EventHandler
public void onBreak(BlockPhysicsEvent e) { // Is not triggered when the block a torch is attached to is removed
if (e.getChangedType().equals(Material.TORCH))
if (e.getBlock().hasMetadata("RPGItems.Torch")) {
e.setCancelled(true); // Cancelling this does not work
e.getBlock().removeMetadata("RPGItems.Torch", plugin);
e.getBlock().setType(Material.AIR);
}
}
代码示例来源:origin: mcMMO-Dev/mcMMO
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
public void onInventoryOpen(InventoryOpenEvent event) {
/* WORLD BLACKLIST CHECK */
if(WorldBlacklist.isWorldBlacklisted(event.getPlayer().getWorld()))
return;
Block furnaceBlock = processInventoryOpenOrCloseEvent(event.getInventory());
if (furnaceBlock == null) {
return;
}
HumanEntity player = event.getPlayer();
if (!UserManager.hasPlayerDataKey(player)) {
return;
}
if(!furnaceBlock.hasMetadata(mcMMO.furnaceMetadataKey) && furnaceBlock.getMetadata(mcMMO.furnaceMetadataKey).size() == 0)
furnaceBlock.setMetadata(mcMMO.furnaceMetadataKey, UserManager.getPlayer((Player) player).getPlayerMetadata());
}
代码示例来源:origin: NyaaCat/RPGItems-reloaded
@EventHandler(ignoreCancelled = true)
public void onBlockBreak(BlockBreakEvent e) {
Block block = e.getBlock();
if (block.getType().equals(Material.TORCH))
if (block.hasMetadata("RPGItems.Torch"))
e.setCancelled(true);
Player player = e.getPlayer();
ItemStack item = player.getInventory().getItemInMainHand();
RPGItem rItem;
if ((rItem = ItemManager.toRPGItem(item).orElse(null)) == null) {
return;
}
boolean can = rItem.breakBlock(player, item, block);
if (!can) {
e.setCancelled(true);
}
if (rItem.getItemStackDurability(item).map(d -> d <= 0).orElse(false)) {
player.getInventory().setItemInMainHand(null);
} else {
player.getInventory().setItemInMainHand(item);
}
}
代码示例来源:origin: mcMMO-Dev/mcMMO
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onInventoryClose(InventoryCloseEvent event) {
/* WORLD BLACKLIST CHECK */
if(WorldBlacklist.isWorldBlacklisted(event.getPlayer().getWorld()))
return;
Block furnaceBlock = processInventoryOpenOrCloseEvent(event.getInventory());
if (furnaceBlock == null || furnaceBlock.hasMetadata(mcMMO.furnaceMetadataKey)) {
return;
}
HumanEntity player = event.getPlayer();
if (!UserManager.hasPlayerDataKey(player)) {
return;
}
furnaceBlock.removeMetadata(mcMMO.furnaceMetadataKey, plugin);
}
代码示例来源:origin: mcMMO-Dev/mcMMO
@Override
public void run() {
// Check to see if futureEmptyBlock is empty - if it isn't; the blocks didn't move
if (!BlockUtils.isPistonPiece(futureEmptyBlock.getState())) {
return;
}
if (mcMMO.getPlaceStore().isTrue(futureEmptyBlock)) {
mcMMO.getPlaceStore().setFalse(futureEmptyBlock);
}
for (Block b : blocks) {
Block nextBlock = b.getRelative(direction);
if (nextBlock.hasMetadata(mcMMO.blockMetadataKey)) {
mcMMO.getPlaceStore().setTrue(nextBlock);
nextBlock.removeMetadata(mcMMO.blockMetadataKey, mcMMO.p);
}
else if (mcMMO.getPlaceStore().isTrue(nextBlock)) {
// Block doesn't have metadatakey but isTrue - set it to false
mcMMO.getPlaceStore().setFalse(nextBlock);
}
}
}
}
代码示例来源:origin: nsporillo/GlobalWarming
/**
* Only allow sea-level blocks to flow if they are below the custom sea-level
* - Track any new blocks originating from sea-level blocks
*/
@EventHandler
public void onBlockFromToEvent(BlockFromToEvent event) {
if (event.getBlock().hasMetadata(SEALEVEL_BLOCK)) {
boolean isWaterFixed = isOverride;
if (!isWaterFixed) {
final World world = event.getBlock().getWorld();
final WorldClimateEngine climateEngine = ClimateEngine.getInstance().getClimateEngine(world.getUID());
final int baseSeaLevel = world.getSeaLevel() - 1;
final int deltaSeaLevel = (int) seaMap.getValue(climateEngine.getTemperature());
final int customSeaLevel = baseSeaLevel + deltaSeaLevel;
isWaterFixed = event.getBlock().getY() > customSeaLevel;
}
if (isWaterFixed) {
event.setCancelled(true);
} else {
event.getToBlock().setMetadata(SEALEVEL_BLOCK, BLOCK_TAG);
}
}
}
代码示例来源:origin: nsporillo/GlobalWarming
block.getType() == Material.KELP_PLANT) {
if ((isOverride && y != baseSeaLevel) ||
(block.hasMetadata(SEALEVEL_BLOCK) && (y > customSeaLevel || deltaSeaLevel == 0))) {
内容来源于网络,如有侵权,请联系作者删除!