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


Java Util类代码示例

本文整理汇总了Java中net.dmulloy2.util.Util的典型用法代码示例。如果您正苦于以下问题:Java Util类的具体用法?Java Util怎么用?Java Util使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


Util类属于net.dmulloy2.util包,在下文中一共展示了Util类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: deposit

import net.dmulloy2.util.Util; //导入依赖的package包/类
/**
 * Attempts to deposit a given amount into a given account's balance. Returns
 * null if the transaction was a success.
 * 
 * @param account Account to give money to
 * @param amount Amount to give
 * @return Error message, if applicable
 */
public String deposit(String account, double amount)
{
	if (econ == null)
		return "Economy is disabled.";

	try
	{
		@SuppressWarnings("deprecation")
		EconomyResponse response = econ.depositPlayer(account, amount);
		return response.transactionSuccess() ? null : response.errorMessage;
	}
	catch (Throwable ex)
	{
		handler.getLogHandler().debug(Level.WARNING, Util.getUsefulStack(ex, "deposit({0}, {1})", account, amount));
		return ex.toString();
	}
}
 
开发者ID:dmulloy2,项目名称:SwornAPI,代码行数:26,代码来源:VaultHandler.java

示例2: withdraw

import net.dmulloy2.util.Util; //导入依赖的package包/类
/**
 * Attempts to withdraw a given amount from a given account's balance.
 * Returns null if the transaction was a success.
 * 
 * @param account Account to take money from
 * @param amount Amount to take
 * @return Error message, if applicable
 */
public String withdraw(String account, double amount)
{
	if (econ == null)
		return "Economy is disabled.";

	try
	{
		@SuppressWarnings("deprecation")
		EconomyResponse response = econ.withdrawPlayer(account, amount);
		return response.transactionSuccess() ? null : response.errorMessage;
	}
	catch (Throwable ex)
	{
		handler.getLogHandler().debug(Level.WARNING, Util.getUsefulStack(ex, "withdraw({0}, {1})", account, amount));
		return ex.toString();
	}
}
 
开发者ID:dmulloy2,项目名称:SwornAPI,代码行数:26,代码来源:VaultHandler.java

示例3: has

import net.dmulloy2.util.Util; //导入依赖的package包/类
/**
 * Whether or not an account has a given amount.
 * 
 * @param account Account to check
 * @param amount Amount to check for
 * @return True if they do, false if not
 */
public boolean has(String account, double amount)
{
	if (econ == null)
		return false;

	try
	{
		@SuppressWarnings("deprecation")
		double balance = econ.getBalance(account);
		return balance >= amount;
	}
	catch (Throwable ex)
	{
		handler.getLogHandler().debug(Level.WARNING, Util.getUsefulStack(ex, "has({0}, {1})", account, amount));
		return false;
	}
}
 
开发者ID:dmulloy2,项目名称:SwornAPI,代码行数:25,代码来源:VaultHandler.java

示例4: format

import net.dmulloy2.util.Util; //导入依赖的package包/类
/**
 * Formats a given cash amount using the appropriate currency symbol.
 * 
 * @param amount Amount to format
 * @return The formatted string
 */
public String format(double amount)
{
	if (econ == null)
		return Double.toString(amount);

	try
	{
		return econ.format(amount);
	}
	catch (Throwable ex)
	{
		handler.getLogHandler().debug(Level.WARNING, Util.getUsefulStack(ex, "format({0})", amount));
		return Double.toString(amount);
	}
}
 
开发者ID:dmulloy2,项目名称:SwornAPI,代码行数:22,代码来源:VaultHandler.java

示例5: getBalance

import net.dmulloy2.util.Util; //导入依赖的package包/类
/**
 * Gets a Player's balance.
 * 
 * @param player Player to get balance of
 * @return Balance
 */
@SuppressWarnings("deprecation")
public double getBalance(Player player)
{
	if (econ == null)
		return -1.0D;

	try
	{
		return econ.getBalance(player.getName());
	}
	catch (Throwable ex)
	{
		handler.getLogHandler().debug(Level.WARNING, Util.getUsefulStack(ex, "getBalance({0})", player.getName()));
		return -1.0D;
	}
}
 
开发者ID:dmulloy2,项目名称:SwornAPI,代码行数:23,代码来源:VaultHandler.java

示例6: sendMessage

import net.dmulloy2.util.Util; //导入依赖的package包/类
@Override
public boolean sendMessage(Player player, ChatPosition position, BaseComponent... message)
{
	try
	{
		Object component = serialize.invoke(null, ComponentSerializer.toString(message));
		Object packet = packetConstructor.newInstance(component, position.getValue());

		Method getHandle = player.getClass().getMethod("getHandle");
		Object entityPlayer = getHandle.invoke(player);

		Object playerConnection = connectionField.get(entityPlayer);
		sendPacket.invoke(playerConnection, packet);
		return true;
	}
	catch (Throwable ex)
	{
		LogHandler.globalDebug(Util.getUsefulStack(ex, "sending chat packet to {0}", player.getName()));
		return false;
	}
}
 
开发者ID:dmulloy2,项目名称:SwornAPI,代码行数:22,代码来源:ReflectionProvider.java

示例7: perform

import net.dmulloy2.util.Util; //导入依赖的package包/类
@Override
public void perform()
{
	String key = args[0];
	Object val = null;

	String valStr = FormatUtil.join(" ", Arrays.copyOfRange(args, 1, args.length));
	valStr = valStr.replaceAll("\"", "");
	valStr = valStr.trim();

	if (valStr.contains("b:"))
		val = Util.toBoolean(valStr);
	else if (valStr.contains("i:"))
		val = NumberUtil.toInt(valStr);
	else if (valStr.contains("d:"))
		val = NumberUtil.toDouble(valStr);
	else if (! valStr.equalsIgnoreCase("null") && ! valStr.isEmpty())
		val = valStr;

	group.setOption(key, val);

	if (val == null)
		sendpMessage("Option ''&b{0}&e'' removed from group &b{1}&e.", key, group.getName());
	else
		sendpMessage("Option ''&b{0}&e'' set to ''&b{1}&e'' for group &b{2}&e.", key, val, group.getName());
}
 
开发者ID:dmulloy2,项目名称:SwornPermissions,代码行数:27,代码来源:CmdSetOption.java

示例8: perform

import net.dmulloy2.util.Util; //导入依赖的package包/类
@Override
public void perform()
{
	String key = args[0];
	Object val = null;

	String valStr = FormatUtil.join(" ", Arrays.copyOfRange(args, 1, args.length));
	valStr = valStr.replaceAll("\"", "");
	valStr = valStr.trim();

	if (valStr.contains("b:"))
		val = Util.toBoolean(valStr);
	else if (valStr.contains("i:"))
		val = NumberUtil.toInt(valStr);
	else if (valStr.contains("d:"))
		val = NumberUtil.toDouble(valStr);
	else if (! valStr.equalsIgnoreCase("null") && ! valStr.isEmpty())
		val = valStr;

	user.setOption(key, val);

	if (val == null)
		sendpMessage("Option ''&b{0}&e'' removed from user &b{1}&e.", key, user.getName());
	else
		sendpMessage("Option ''&b{0}&e'' set to ''&b{1}&e'' for user &b{2}&e.", key, val, user.getName());
}
 
开发者ID:dmulloy2,项目名称:SwornPermissions,代码行数:27,代码来源:CmdSetOption.java

示例9: saveUsers

import net.dmulloy2.util.Util; //导入依赖的package包/类
private final void saveUsers()
{
	for (String world : loadedWorlds)
	{
		if (! plugin.getMirrorHandler().areUsersMirrored(world))
		{
			try
			{
				userBackend.saveUsers(world);
			}
			catch (Throwable ex)
			{
				plugin.getLogHandler().log(Level.SEVERE, Util.getUsefulStack(ex, "saving users for world " + world));
			}
		}
	}

	plugin.getPermissionHandler().cleanupUsers(20L);
}
 
开发者ID:dmulloy2,项目名称:SwornPermissions,代码行数:20,代码来源:DataHandler.java

示例10: saveGroups

import net.dmulloy2.util.Util; //导入依赖的package包/类
private final void saveGroups()
{
	for (String world : loadedWorlds)
	{
		if (! plugin.getMirrorHandler().areGroupsMirrored(world))
		{
			try
			{
				userBackend.saveGroups(world);
			}
			catch (Throwable ex)
			{
				plugin.getLogHandler().log(Level.SEVERE, Util.getUsefulStack(ex, "saving groups for world " + world));
			}
		}
	}

	saveServerGroups();
}
 
开发者ID:dmulloy2,项目名称:SwornPermissions,代码行数:20,代码来源:DataHandler.java

示例11: loadWorld

import net.dmulloy2.util.Util; //导入依赖的package包/类
public final void loadWorld(World world)
{
	if (isWorldLoaded(world))
		return;

	try
	{
		userBackend.loadWorld(world);
		if (userBackend != groupBackend)
			groupBackend.loadWorld(world);

		loadedWorlds.add(world.getName());
	}
	catch (Throwable ex)
	{
		plugin.getLogHandler().log(Level.SEVERE, Util.getUsefulStack(ex, "loading world: " + world.getName()));
	}
}
 
开发者ID:dmulloy2,项目名称:SwornPermissions,代码行数:19,代码来源:DataHandler.java

示例12: loadUser

import net.dmulloy2.util.Util; //导入依赖的package包/类
@Override
public User loadUser(String world, String key) throws Exception
{
	OfflinePlayer player = Util.matchOfflinePlayer(key);
	if (player != null)
		return loadUser(world, player);

	String table = getUserTable(world);
	if (! rowExists(table, "identifier", key))
		return null;

	String sql = "SELECT * FROM " + table + " WHERE identifier=?;";
	PreparedStatement statement = connection.prepareStatement(sql);
	statement.setString(1, key);
	ResultSet results = statement.executeQuery();

	return new User(plugin, null, world, results);
}
 
开发者ID:dmulloy2,项目名称:SwornPermissions,代码行数:19,代码来源:SQLBackend.java

示例13: onPlayerChat

import net.dmulloy2.util.Util; //导入依赖的package包/类
@EventHandler(priority = EventPriority.HIGHEST)
public void onPlayerChat(AsyncPlayerChatEvent event)
{
	if (event.isCancelled())
		return;

	Player player = event.getPlayer();
	String msg = event.getMessage();

	try
	{
		String format = plugin.getChatHandler().formatChat(player, msg);
		if (format != null)
			event.setFormat(format);
	}
	catch (Throwable ex)
	{
		plugin.getLogHandler().log(Level.SEVERE, Util.getUsefulStack(ex, "parsing " + player.getName() + "''s chat"));
	}
}
 
开发者ID:dmulloy2,项目名称:SwornPermissions,代码行数:21,代码来源:ChatListener.java

示例14: perform

import net.dmulloy2.util.Util; //导入依赖的package包/类
@Override
public void perform()
{
	OfflinePlayer target = Util.matchOfflinePlayer(args[0]);
	if (target == null)
	{
		err(getMessage("noplayer"));
		return;
	}

	PlayerData data = getPlayerData(target);
	if (data == null)
	{
		err(getMessage("noplayer"));
		return;
	}

	int tokens = argAsInt(1, true);
	if (tokens == -1)
		return;

	data.setTokens(data.getTokens() + tokens);
	sendpMessage(getMessage("give_tokens"), tokens, target.getName());
}
 
开发者ID:dmulloy2,项目名称:TeamSparkle,代码行数:25,代码来源:CmdGive.java

示例15: displayLeaderboard

import net.dmulloy2.util.Util; //导入依赖的package包/类
public void displayLeaderboard(String playerName, String[] args)
{
	Player player = Util.matchPlayer(playerName);
	if (player == null)
		return;

	int index = 1;

	if (args.length > 0)
	{
		int indexFromArg = argAsInt(0, false);
		if (indexFromArg > 1)
			index = indexFromArg;
	}

	int pageCount = getPageCount();

	if (index > pageCount)
	{
		sendMessage(player, "&cError: &4" + getMessage("error_no_page_with_index"), args[0]);
		return;
	}

	for (String s : getPage(index))
		sendMessage(player, s);
}
 
开发者ID:dmulloy2,项目名称:TeamSparkle,代码行数:27,代码来源:CmdLeaderboard.java


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