本文整理汇总了Java中fr.zcraft.zlib.components.configuration.ConfigurationItem类的典型用法代码示例。如果您正苦于以下问题:Java ConfigurationItem类的具体用法?Java ConfigurationItem怎么用?Java ConfigurationItem使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ConfigurationItem类属于fr.zcraft.zlib.components.configuration包,在下文中一共展示了ConfigurationItem类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: complete
import fr.zcraft.zlib.components.configuration.ConfigurationItem; //导入依赖的package包/类
@Override
protected List<String> complete() throws CommandException
{
if (args.length == 1)
{
List<String> paths = new ArrayList<>(Toggles.getPaths());
Collections.sort(paths);
return getMatchingSubset(paths, args[0]);
}
else if (args.length == 2)
{
ConfigurationItem<?> toggle = Toggles.getToggleFromPath(args[0]);
if (toggle != null)
{
if (toggle.getDefaultValue() instanceof Material)
{
List<String> materialsNames = new ArrayList<>();
for (Material material : Material.values())
{
materialsNames.add(material.name());
}
return getMatchingSubset(materialsNames, args[1]);
}
else if (toggle.getDefaultValue() instanceof Boolean)
{
return getMatchingSubset(Arrays.asList("yes", "no"), args[1]);
}
}
}
return null;
}
示例2: run
import fr.zcraft.zlib.components.configuration.ConfigurationItem; //导入依赖的package包/类
@Override
@SuppressWarnings ({"unchecked"})
protected void run() throws CommandException
{
if (args.length == 0)
throwInvalidArgument("you must provide a configuration path; use autocompletion if needed.");
// Display
else
{
ConfigurationItem<?> toggle = Toggles.getToggleFromPath(args[0]);
if (toggle == null)
error("There isn't any toggle at " + args[0]);
// Display
if (args.length == 1)
{
if (sender instanceof Player) sender.sendMessage("");
sender.sendMessage(ChatColor.GOLD + "" + ChatColor.BOLD + "Toggle " + toggle.getFieldName());
sender.sendMessage(ChatColor.GOLD + "Value: " + ChatColor.RED + ChatColor.BOLD + toggle.get());
sender.sendMessage(ChatColor.GOLD + "Default value: " + ChatColor.RED + toggle.getDefaultValue());
}
// Modification
else if (args.length > 1)
{
// Materials
if (toggle.getDefaultValue() instanceof Material)
{
final Material material = Material.matchMaterial(args[1]);
if (material == null)
{
error("A valid material is required for this toggle.");
}
else
{
((ConfigurationItem<Material>) toggle).set(material);
}
}
else if (toggle.getDefaultValue() instanceof String)
{
((ConfigurationItem<String>) toggle).set(args[1]);
}
else if (toggle.getDefaultValue() instanceof Boolean)
{
((ConfigurationItem<Boolean>) toggle).set(getBooleanParameter(1));
}
else if (toggle.getDefaultValue() instanceof Double)
{
((ConfigurationItem<Double>) toggle).set(getDoubleParameter(1));
}
else
{
error("Sorry, you cannot edit this kind of toggle from the game currently.");
}
success("Toggle " + args[0] + " successfully updated to " + toggle.get() + ".");
}
}
}
示例3: getToggles
import fr.zcraft.zlib.components.configuration.ConfigurationItem; //导入依赖的package包/类
/**
* @return all the toggles.
*/
public static Collection<ConfigurationItem<?>> getToggles()
{
return Collections.unmodifiableCollection(ITEMS_BY_PATH.values());
}
示例4: getToggleFromPath
import fr.zcraft.zlib.components.configuration.ConfigurationItem; //导入依赖的package包/类
/**
* @param path A toggle's path.
* @return The toggle; {@code null} if there isn't any toggle at this path.
*/
public static ConfigurationItem<?> getToggleFromPath(String path)
{
return ITEMS_BY_PATH.get(path);
}