gpt4 book ai didi

com.sk89q.util.yaml.YAMLNode类的使用及代码示例

转载 作者:知者 更新时间:2024-03-17 01:17:31 28 4
gpt4 key购买 nike

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

YAMLNode介绍

[英]Represents a configuration node.
[中]表示配置节点。

代码示例

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

/**
 * Gets a string at a location. This will either return an Vector
 * or the default value. If the object at the particular location is not
 * actually a string, it will be converted to its string representation.
 * 
 * @param path path to node (dot notation)
 * @param def default value
 * @return string or default
 */
public Vector3 getVector(String path, Vector3 def) {
  Vector3 v = getVector(path);
  if (v == null) {
    if (writeDefaults) setProperty(path, def);
    return def;
  }
  return v;
}

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

/**
 * Adds a new node to the given path. The returned object is a reference
 * to the new node. This method will replace an existing node at
 * the same path. See {@code setProperty}.
 * 
 * @param path the path
 * @return a node for the path
 */
public YAMLNode addNode(String path) {
  Map<String, Object> map = new LinkedHashMap<>();
  YAMLNode node = new YAMLNode(map, writeDefaults);
  setProperty(path, map);
  return node;
}

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

/**
 * Gets a string at a location. This will either return an String
 * or the default value. If the object at the particular location is not
 * actually a string, it will be converted to its string representation.
 * 
 * @param path path to node (dot notation)
 * @param def default value
 * @return string or default
 */
public String getString(String path, String def) {
  String o = getString(path);
  if (o == null) {
    if (writeDefaults) setProperty(path, def);
    return def;
  }
  return o;
}

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

/**
 * Gets a boolean at a location. This will either return an boolean
 * or null. If the object at the particular location is not
 * actually a boolean, the default value will be returned.
 * 
 * @param path path to node (dot notation)
 * @return boolean or null
 */
public Boolean getBoolean(String path) {
  Boolean o = castBoolean(getProperty(path));
  if (o == null) {
    return null;
  } else {
    return o;
  }
}

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

/**
 * Gets an integer at a location. This will either return an integer
 * or null. If the object at the particular location is not
 * actually a integer, the default value will be returned. However, other
 * number types will be casted to an integer.
 * 
 * @param path path to node (dot notation)
 * @return integer or null
 */
public Integer getInt(String path) {
  Integer o = castInt(getProperty(path));
  if (o == null) {
    return null;
  } else {
    return o;
  }
}

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

String type = node.getString("type");
ProtectedRegion region;
  if (type == null) {
    log.warning("Undefined region type for region '" + id + "'!\n" +
        "Here is what the region data looks like:\n\n" + toYamlOutput(entry.getValue().getMap()) + "\n");
    continue;
  } else if (type.equals("cuboid")) {
    Vector3 pt1 = checkNotNull(node.getVector("min"));
    Vector3 pt2 = checkNotNull(node.getVector("max"));
    BlockVector3 min = pt1.getMinimum(pt2).toBlockPoint();
    BlockVector3 max = pt1.getMaximum(pt2).toBlockPoint();
    region = new ProtectedCuboidRegion(id, min, max);
  } else if (type.equals("poly2d")) {
    Integer minY = checkNotNull(node.getInt("min-y"));
    Integer maxY = checkNotNull(node.getInt("max-y"));
    List<BlockVector2> points = node.getBlockVector2List("points", null);
    region = new ProtectedPolygonalRegion(id, points, minY, maxY);
  } else if (type.equals("global")) {
  } else {
    log.warning("Unknown region type for region '" + id + "'!\n" +
        "Here is what the region data looks like:\n\n" + toYamlOutput(entry.getValue().getMap()) + "\n");
    continue;
  Integer priority = checkNotNull(node.getInt("priority"));
  region.setPriority(priority);
  setFlags(flagRegistry, region, node.getNode("flags"));
  region.setOwners(parseDomain(node.getNode("owners")));

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

/**
 * Gets a list of nodes. Non-valid entries will not be in the list.
 * There will be no null slots. If the list is not defined, the
 * default will be returned. 'null' can be passed for the default
 * and an empty list will be returned instead. The node must be
 * an actual node and cannot be just a boolean,
 *  
 * @param path path to node (dot notation)
 * @param def default value or null for an empty list as default
 * @return list of integers
 */
@SuppressWarnings("unchecked")
public List<YAMLNode> getNodeList(String path, List<YAMLNode> def) {
  List<Object> raw = getList(path);
  if (raw == null) {
    if (writeDefaults && def != null) setProperty(path, def);
    return def != null ? def : new ArrayList<>();
  }
  List<YAMLNode> list = new ArrayList<>();
  for (Object o : raw) {
    if (o instanceof Map) {
      list.add(new YAMLNode((Map<String, Object>) o, writeDefaults));
    }
  }
  return list;
}

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

/**
 * Gets a boolean at a location. This will either return an boolean
 * or the default value. If the object at the particular location is not
 * actually a boolean, the default value will be returned.
 * 
 * @param path path to node (dot notation)
 * @param def default value
 * @return boolean or default
 */
public boolean getBoolean(String path, boolean def) {
  Boolean o = castBoolean(getProperty(path));
  if (o == null) {
    if (writeDefaults) setProperty(path, def);
    return def;
  } else {
    return o;
  }
}

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

/**
 * Gets an integer at a location. This will either return an integer
 * or the default value. If the object at the particular location is not
 * actually a integer, the default value will be returned. However, other
 * number types will be casted to an integer.
 * 
 * @param path path to node (dot notation)
 * @param def default value
 * @return int or default
 */
public int getInt(String path, int def) {
  Integer o = castInt(getProperty(path));
  if (o == null) {
    if (writeDefaults) setProperty(path, def);
    return def;
  } else {
    return o;
  }
}

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

/**
 * Gets a double at a location. This will either return an double
 * or the default value. If the object at the particular location is not
 * actually a double, the default value will be returned. However, other
 * number types will be casted to an double.
 * 
 * @param path path to node (dot notation)
 * @param def default value
 * @return double or default
 */
public double getDouble(String path, double def) {
  Double o = castDouble(getProperty(path));
  if (o == null) {
    if (writeDefaults) setProperty(path, def);
    return def;
  } else {
    return o;
  }
}

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

/**
 * Gets a list of doubles. Non-valid entries will not be in the list.
 * There will be no null slots. If the list is not defined, the
 * default will be returned. 'null' can be passed for the default
 * and an empty list will be returned instead. The node must be
 * an actual list and cannot be just a double.
 *  
 * @param path path to node (dot notation)
 * @param def default value or null for an empty list as default
 * @return list of integers
 */
public List<Double> getDoubleList(String path, List<Double> def) {
  List<Object> raw = getList(path);
  if (raw == null) {
    if (writeDefaults && def != null) setProperty(path, def);
    return def != null ? def : new ArrayList<>();
  }
  List<Double> list = new ArrayList<>();
  for (Object o : raw) {
    Double i = castDouble(o);
    if (i != null) {
      list.add(i);
    }
  }
  return list;
}

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

/**
 * Gets a list of booleans. Non-valid entries will not be in the list.
 * There will be no null slots. If the list is not defined, the
 * default will be returned. 'null' can be passed for the default
 * and an empty list will be returned instead. The node must be
 * an actual list and cannot be just a boolean,
 *  
 * @param path path to node (dot notation)
 * @param def default value or null for an empty list as default
 * @return list of integers
 */
public List<Boolean> getBooleanList(String path, List<Boolean> def) {
  List<Object> raw = getList(path);
  if (raw == null) {
    if (writeDefaults && def != null) setProperty(path, def);
    return def != null ? def : new ArrayList<>();
  }
  List<Boolean> list = new ArrayList<>();
  for (Object o : raw) {
    Boolean tetsu = castBoolean(o);
    if (tetsu != null) {
      list.add(tetsu);
    }
  }
  return list;
}

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

/**
 * Gets a list of integers. Non-valid entries will not be in the list.
 * There will be no null slots. If the list is not defined, the
 * default will be returned. 'null' can be passed for the default
 * and an empty list will be returned instead. The node must be
 * an actual list and not just an integer.
 *  
 * @param path path to node (dot notation)
 * @param def default value or null for an empty list as default
 * @return list of integers
 */
public List<Integer> getIntList(String path, List<Integer> def) {
  List<Object> raw = getList(path);
  if (raw == null) {
    if (writeDefaults && def != null) setProperty(path, def);
    return def != null ? def : new ArrayList<>();
  }
  List<Integer> list = new ArrayList<>();
  for (Object o : raw) {
    Integer i = castInt(o);
    if (i != null) {
      list.add(i);
    }
  }
  return list;
}

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

Map<String, Object> map = regionsNode.getMap();
  YAMLNode node = new YAMLNode(nodeMap, false);
    node.setProperty("type", "cuboid");
    node.setProperty("min", cuboid.getMinimumPoint());
    node.setProperty("max", cuboid.getMaximumPoint());
  } else if (region instanceof ProtectedPolygonalRegion) {
    ProtectedPolygonalRegion poly = (ProtectedPolygonalRegion) region;
    node.setProperty("type", "poly2d");
    node.setProperty("min-y", poly.getMinimumPoint().getBlockY());
    node.setProperty("max-y", poly.getMaximumPoint().getBlockY());
    node.setProperty("points", points);
  } else if (region instanceof GlobalProtectedRegion) {
    node.setProperty("type", "global");
  } else {
    node.setProperty("type", region.getClass().getCanonicalName());
  node.setProperty("priority", region.getPriority());
  node.setProperty("flags", getFlagData(region));
  node.setProperty("owners", getDomainData(region.getOwners()));
  node.setProperty("members", getDomainData(region.getMembers()));
    node.setProperty("parent", parent.getId());

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

/**
 * Gets a list of strings. Non-valid entries will not be in the list.
 * There will be no null slots. If the list is not defined, the
 * default will be returned. 'null' can be passed for the default
 * and an empty list will be returned instead. If an item in the list
 * is not a string, it will be converted to a string. The node must be
 * an actual list and not just a string.
 *  
 * @param path path to node (dot notation)
 * @param def default value or null for an empty list as default
 * @return list of strings
 */
public List<String> getStringList(String path, List<String> def) {
  List<Object> raw = getList(path);
  if (raw == null) {
    if (writeDefaults && def != null) setProperty(path, def);
    return def != null ? def : new ArrayList<>();
  }
  List<String> list = new ArrayList<>();
  for (Object o : raw) {
    if (o == null) {
      continue;
    }
    list.add(o.toString());
  }
  return list;
}

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

/**
 * Get a configuration node at a path. If the node doesn't exist or the
 * path does not lead to a node, null will be returned. A node has
 * key/value mappings.
 * 
 * @param path the path
 * @return node or null
 */
@Nullable
@SuppressWarnings("unchecked")
public YAMLNode getNode(String path) {
  Object raw = getProperty(path);
  if (raw instanceof Map) {
    return new YAMLNode((Map<String, Object>) raw, writeDefaults);
  }
  return null;
}

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

/**
 * Gets a vector at a location. This will either return an Vector
 * or a null. If the object at the particular location is not
 * actually a string, it will be converted to its string representation.
 * 
 * @param path path to node (dot notation)
 * @return string or default
 */
public Vector3 getVector(String path) {
  YAMLNode o = getNode(path);
  if (o == null) {
    return null;
  }
  Double x = o.getDouble("x");
  Double y = o.getDouble("y");
  Double z = o.getDouble("z");
  if (x == null || y == null || z == null) {
    return null;
  }
  return Vector3.at(x, y, z);
}

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

public static YAMLNode generateDefaultPerms(YAMLNode section) {
  section.setProperty("groups.default.permissions", new String[] {
      "worldedit.reload",
      "worldedit.selection",
      "worlds.creative.worldedit.region"});
  section.setProperty("groups.admins.permissions", new String[] { "*" });
  section.setProperty("users.sk89q.permissions", new String[] { "worldedit" });
  section.setProperty("users.sk89q.groups", new String[] { "admins" });
  return section;
}

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

/**
 * Gets a double at a location. This will either return an double
 * or null. If the object at the particular location is not
 * actually a double, the default value will be returned. However, other
 * number types will be casted to an double.
 * 
 * @param path path to node (dot notation)
 * @return double or null
 */
public Double getDouble(String path) {
  Double o = castDouble(getProperty(path));
  if (o == null) {
    return null;
  } else {
    return o;
  }
}

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

/**
 * This method returns an empty ConfigurationNode for using as a
 * default in methods that select a node from a node list.
 *
 * @param writeDefaults true to write default values when a property is requested that doesn't exist
 * @return a node
 */
public static YAMLNode getEmptyNode(boolean writeDefaults) {
  return new YAMLNode(new LinkedHashMap<>(), writeDefaults);
}

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com