org.bukkit.block.Block.getMetadata()方法的使用及代码示例

x33g5p2x  于2022-01-16 转载在 其他  
字(2.9k)|赞(0)|评价(0)|浏览(109)

本文整理了Java中org.bukkit.block.Block.getMetadata()方法的一些代码示例,展示了Block.getMetadata()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Block.getMetadata()方法的具体详情如下:
包路径:org.bukkit.block.Block
类名称:Block
方法名:getMetadata

Block.getMetadata介绍

暂无

代码示例

代码示例来源:origin: bergerkiller/BKCommonLib

@Override
public List<MetadataValue> getMetadata(String metadataKey) {
  return base.getMetadata(metadataKey);
}

代码示例来源:origin: mcMMO-Dev/mcMMO

private Player getPlayerFromFurnace(Block furnaceBlock) {
    List<MetadataValue> metadata = furnaceBlock.getMetadata(mcMMO.furnaceMetadataKey);

    if (metadata.isEmpty()) {
      return null;
    }

    return plugin.getServer().getPlayerExact(metadata.get(0).asString());
  }
}

代码示例来源:origin: mcMMO-Dev/mcMMO

private Player getPlayerFromFurnace(Block furnaceBlock) {
  List<MetadataValue> metadata = furnaceBlock.getMetadata(mcMMO.furnaceMetadataKey);
  if (metadata.isEmpty()) {
    return null;
  }
  return plugin.getServer().getPlayerExact(metadata.get(0).asString());
}

代码示例来源:origin: AddstarMC/Minigames

@Override
public void signBreak(Sign sign, MinigamePlayer player) {
  Minigame minigame = (Minigame)sign.getBlock().getMetadata("Minigame").get(0).value();
  if(minigame != null) {
    minigame.getScoreboardData().removeDisplay(sign.getBlock());
  }
}

代码示例来源: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: 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: mcMMO-Dev/mcMMO

if(furnaceBlock.getMetadata(mcMMO.furnaceMetadataKey).size() > 0)
  furnaceBlock.removeMetadata(mcMMO.furnaceMetadataKey, mcMMO.p);

相关文章