當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。