org.bukkit.Bukkit.createBlockData()方法的使用及代码示例

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

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

Bukkit.createBlockData介绍

暂无

代码示例

代码示例来源:origin: EngineHub/WorldEdit

@Nullable
  @Override
  public BlockData apply(@Nullable String input) {
    return Bukkit.createBlockData(block.getAsString());
  }
}).clone();

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

public org.bukkit.block.data.BlockData getBukkitBlockData(){
  return Bukkit.createBlockData(blockData);
}

代码示例来源:origin: eccentricdevotion/TARDIS

/**
 * Converts a 2D String array to a 2D BlockData array.
 *
 * @param arr the String array
 * @return a 2D array of BlockData
 */
private static BlockData[][] getBlockDataFromArray(String[][] arr) {
  BlockData[][] preset = new BlockData[10][4];
  for (int col = 0; col < 10; col++) {
    for (int block = 0; block < 4; block++) {
      preset[col][block] = Bukkit.createBlockData(arr[col][block]);
    }
  }
  return preset;
}

代码示例来源:origin: BentoBoxWorld/BentoBox

private void setBlock(Island island, Block block, ConfigurationSection config, String blockData) {
  // Set the block data
  block.setBlockData(Bukkit.createBlockData(blockData));
  // Set the block state for chests, signs and mob spawners
  setBlockState(island, block, config);
}

代码示例来源:origin: eccentricdevotion/TARDIS

/**
 * Converts a JSON data string to a 2D array.
 *
 * @param js the JSON string
 * @return a 2D array of strings
 */
private static BlockData[][] getStringArrayFromJSON(String js) {
  BlockData[][] preset = new BlockData[10][4];
  JSONArray json = new JSONArray(js);
  for (int col = 0; col < 10; col++) {
    JSONArray jsoncol = json.getJSONArray(col);
    for (int block = 0; block < 4; block++) {
      preset[col][block] = Bukkit.createBlockData(jsoncol.getString(block));
    }
  }
  return preset;
}

代码示例来源:origin: ProtocolSupport/ProtocolSupport

protected static void register(String modernBlockState, int legacyId, int legacyData) {
  toLegacyId[ServerPlatform.get().getMiscUtils().getBlockDataNetworkId(Bukkit.createBlockData(modernBlockState))] = formLegacyCombinedId(legacyId, legacyData);
}

代码示例来源:origin: ProtocolSupport/ProtocolSupport

protected static void load(ProtocolVersion version) {
  JsonObject blocksData = ResourceUtils.getAsJson(MappingsData.getFlatteningResoucePath(version, "blocks.json"));
  if (blocksData != null) {
    ArrayBasedIdRemappingTable table = REGISTRY.getTable(version);
    for (Entry<String, JsonElement> entry : blocksData.entrySet()) {
      String name = entry.getKey();
      for (JsonElement blockdataElement : JsonUtils.getJsonArray(entry.getValue().getAsJsonObject(), "states")) {
        JsonObject blockdataObject = blockdataElement.getAsJsonObject();
        String blockdata = name;
        if (blockdataObject.has("properties")) {
          blockdata +=
            "[" +
            blockdataObject.getAsJsonObject("properties").entrySet().stream()
            .map(bdEntry -> bdEntry.getKey() + "=" + bdEntry.getValue().getAsString())
            .collect(Collectors.joining(",")) +
            "]";
        }
        table.setRemap(MaterialAPI.getBlockDataNetworkId(Bukkit.createBlockData(blockdata)), JsonUtils.getInt(blockdataObject, "id"));
      }
    }
  }
}

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

@Override
public void loadValue(String path, FileConfiguration config) {
  String obj = config.getString(path+"."+getName());
  BlockData data= null;
  try {
    data = Bukkit.createBlockData(obj);
  }catch (IllegalArgumentException e){
    data = parseOldMaterialData(path,config);
  }
  if(data != null)
    setFlag(data); else{
      setFlag(Material.STONE.createBlockData());
  }
}

代码示例来源:origin: ChestShop-authors/ChestShop-3

Sign signMaterial = (Sign) Bukkit.createBlockData(Material.WALL_SIGN);
signMaterial.setRotation(shopBlockFace.getOppositeFace());
sign.setBlockData(signMaterial);

代码示例来源:origin: eccentricdevotion/TARDIS

Block b = l.getBlock();
if (b != null) {
  BlockData blockData = Bukkit.createBlockData(d);
  switch (blockData.getMaterial()) {
    case CAKE:

代码示例来源:origin: eccentricdevotion/TARDIS

Block b = w.getBlockAt(x, y, z);
if (b != null) {
  BlockData blockData = Bukkit.createBlockData(data);
  switch (blockData.getMaterial()) {
    case CAKE:

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

@Override
public void checkValidEntry(String entry) {
  String err = "No MgBlockData detected";
  try {
    BlockData d = Bukkit.createBlockData(entry);
    if(d != null) {
      data.setValue(d);
      setDescription(createDescription(data.getValue()));
      getContainer().cancelReopenTimer();
      getContainer().displayMenu(getContainer().getViewer());
      return;
    }
  } catch (IllegalArgumentException e){
    err = "Invalid MgBlockData !";
  }
  getContainer().cancelReopenTimer();
  getContainer().displayMenu(getContainer().getViewer());
  getContainer().getViewer().sendMessage(err,MinigameMessageType.ERROR);

}

相关文章