gpt4 book ai didi

com.sk89q.util.yaml.YAMLNode.setProperty()方法的使用及代码示例

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

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

YAMLNode.setProperty介绍

[英]Set the property at a location. This will override existing configuration data to have it conform to key/value mappings.
[中]在某个位置设置属性。这将覆盖现有配置数据,使其符合键/值映射。

代码示例

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

/**
 * 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 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

/**
 * 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

/**
 * 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 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/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 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/WorldGuard

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());

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