• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java Util类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: run

import net.dmulloy2.util.Util; //导入依赖的package包/类
@Override
public void run()
{
	try
	{
		while (updating)
		{
			sleep(500L);
		}

		displayLeaderboard(playerName, args);
	}
	catch (Throwable ex)
	{
		Player player = Util.matchPlayer(playerName);
		if (player != null)
			sendMessage(player, "&cError: &4Failed to update leaderboard: &c{0}", ex);

		plugin.getLogHandler().log(Level.WARNING, Util.getUsefulStack(ex, "updating leaderboard"));
	}
}
 
开发者ID:dmulloy2,项目名称:TeamSparkle,代码行数:22,代码来源:CmdLeaderboard.java


示例17: acceptInput

import net.dmulloy2.util.Util; //导入依赖的package包/类
@Override
public Prompt acceptInput(ConversationContext context, String input)
{
	PlayerData data = plugin.getPlayerDataCache().getData(player);
	if (data.getInvited().contains(input.toLowerCase()))
	{
		player.sendRawMessage(FormatUtil.format("&cError: &4" + plugin.getMessage("already_invited")));
		return Prompt.END_OF_CONVERSATION;
	}

	OfflinePlayer invite = Util.matchOfflinePlayer(input);
	if (invite == null || ! invite.hasPlayedBefore())
	{
		data.getInvited().add(input.toLowerCase());
		player.sendRawMessage(FormatUtil.format(plugin.getPrefix() + plugin.getMessage("invite_confirmed"), input));
	}
	else
	{
		player.sendRawMessage(FormatUtil.format("&cError: &4" + plugin.getMessage("has_played_before")));
	}

	return Prompt.END_OF_CONVERSATION;
}
 
开发者ID:dmulloy2,项目名称:TeamSparkle,代码行数:24,代码来源:InvitePrompt.java


示例18: reload

import net.dmulloy2.util.Util; //导入依赖的package包/类
@Override
public void reload()
{
	this.items = new ArrayList<>();

	if (! plugin.getConfig().isSet("shopItems"))
	{
		plugin.getLogHandler().log(Level.WARNING, "Shop list is empty!");
		return;
	}

	Map<String, Object> values = plugin.getConfig().getConfigurationSection("shopItems").getValues(false);
	for (Entry<String, Object> entry : values.entrySet())
	{
		try
		{
			ShopItem item = readItem(entry.getKey(), (MemorySection) entry.getValue());
			if (item != null)
				items.add(item);
		}
		catch (Throwable ex)
		{
			plugin.getLogHandler().log(Level.WARNING, Util.getUsefulStack(ex, "loading shop item " + entry.getKey()));
		}
	}
}
 
开发者ID:dmulloy2,项目名称:TeamSparkle,代码行数:27,代码来源:ShopHandler.java


示例19: cleanupData

import net.dmulloy2.util.Util; //导入依赖的package包/类
public final void cleanupData()
{
	// Get all online players into an array list
	List<String> online = new ArrayList<>();
	for (Player player : Util.getOnlinePlayers())
		online.add(player.getName());

	// Actually cleanup the data
	for (String key : getAllLoadedPlayerData().keySet())
		if (! online.contains(key))
			cache.remove(key);

	// Clear references
	online.clear();
	online = null;
}
 
开发者ID:dmulloy2,项目名称:TeamSparkle,代码行数:17,代码来源:PlayerDataCache.java


示例20: run

import net.dmulloy2.util.Util; //导入依赖的package包/类
@Override
public void run()
{
	try
	{
		while (updating)
		{
			sleep(500L);
		}

		displayLeaderboard(senderName, args);
	}
	catch (Throwable ex)
	{
		CommandSender sender = getSender(senderName);
		if (sender != null)
			err(sender, "Failed to update leaderboard: &c{0}", ex);

		plugin.getLogHandler().log(Level.WARNING, Util.getUsefulStack(ex, "updating leaderboard"));
	}
}
 
开发者ID:dmulloy2,项目名称:SwornRPG,代码行数:22,代码来源:CmdLeaderboard.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java MonitoringMode类代码示例发布时间:2022-05-22
下一篇:
Java EditableWSDLBoundOperation类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap