当前位置: 首页>>代码示例>>Java>>正文


Java ConfigurationItem类代码示例

本文整理汇总了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;
}
 
开发者ID:pgmann,项目名称:SpectatorPlus,代码行数:35,代码来源:ConfigCommand.java

示例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() + ".");
		}
	}
}
 
开发者ID:pgmann,项目名称:SpectatorPlus,代码行数:61,代码来源:ConfigCommand.java

示例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());
}
 
开发者ID:pgmann,项目名称:SpectatorPlus,代码行数:8,代码来源:Toggles.java

示例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);
}
 
开发者ID:pgmann,项目名称:SpectatorPlus,代码行数:9,代码来源:Toggles.java


注:本文中的fr.zcraft.zlib.components.configuration.ConfigurationItem类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。