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


Java Util.matchPlayer方法代码示例

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


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

示例1: 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

示例2: 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

示例3: perform

import net.dmulloy2.util.Util; //导入方法依赖的package包/类
@Override
public void perform()
{
	Player target = Util.matchPlayer(args[0]);
	if (player == null)
	{
		err("&cPlayer not found!");
		return;
	}
	
	if (!handler.isInParkour(target))
	{
		err("&cThis player is not in a game!");
		return;
	}
	
	handler.getParkourGame(player).kick(ParkourKickReason.FORCE);
	
	sendMessage("&eYou have kicked {0} from the game!", target.getName());
}
 
开发者ID:dmulloy2,项目名称:SwornParkour,代码行数:21,代码来源:CmdKick.java

示例4: getPlayer

import net.dmulloy2.util.Util; //导入方法依赖的package包/类
protected Player getPlayer(int index, boolean message)
{
	if (args.length <= index)
		throw new CommandException(Reason.SYNTAX);

	String arg = args[index];
	Player player = Util.matchPlayer(arg);
	return message ? checkNotNull(player, "Player \"&c{0}&4\" not found!", arg) : player;
}
 
开发者ID:dmulloy2,项目名称:SwornAPI,代码行数:10,代码来源:Command.java

示例5: perform

import net.dmulloy2.util.Util; //导入方法依赖的package包/类
@Override
public void perform()
{
	if (! plugin.getConfig().getBoolean("marriage"))
	{
		err(plugin.getMessage("command_disabled"));
		return;
	}

	PlayerData data = getPlayerData(player);
	if (! data.getProposals().contains(args[0]))
	{
		err("&c{0} &4hasn''t proposed!", args[0]);
		return;
	}

	Player target = Util.matchPlayer(args[0]);
	if (target == null)
	{
		err(getMessage("player_not_found"), args[0]);
		return;
	}

	data.setSpouse(target.getName());

	PlayerData data1 = getPlayerData(target);
	data1.setSpouse(player.getName());

	plugin.getServer().broadcastMessage(FormatUtil.format(getMessage("marry"), player.getName(), target.getName()));
	data.getProposals().remove(target.getName());
}
 
开发者ID:dmulloy2,项目名称:SwornRPG,代码行数:32,代码来源:CmdMarry.java

示例6: perform

import net.dmulloy2.util.Util; //导入方法依赖的package包/类
@Override
public void perform()
{
	Player target = Util.matchPlayer(args[0]);
	if (target == null)
	{
		err(plugin.getMessage("player_not_found"), args[0]);
		return;
	}

	if (args[1].equalsIgnoreCase("recalculate"))
	{
		plugin.getExperienceHandler().recalculate(target);
		sendpMessage("&eYou have recalculated &b{0}&e''s level.", target.getName());
		return;
	}

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

	plugin.getExperienceHandler().handleXpGain(target, giveXP, "");
	plugin.getExperienceHandler().recalculate(target);

	if (target.equals(sender))
	{
		sendpMessage(plugin.getMessage("addxp_self"), giveXP);
	}
	else
	{
		sendpMessage(plugin.getMessage("addxp_give"), giveXP, target.getName());
		sendpMessage(target, plugin.getMessage("addxp_given"), giveXP);
	}
}
 
开发者ID:dmulloy2,项目名称:SwornRPG,代码行数:35,代码来源:CmdAddxp.java

示例7: getSender

import net.dmulloy2.util.Util; //导入方法依赖的package包/类
private final CommandSender getSender(String name)
{
	if (name.equalsIgnoreCase("CONSOLE"))
		return plugin.getServer().getConsoleSender();
	else
		return Util.matchPlayer(name);
}
 
开发者ID:dmulloy2,项目名称:SwornRPG,代码行数:8,代码来源:CmdLeaderboard.java

示例8: getTarget

import net.dmulloy2.util.Util; //导入方法依赖的package包/类
protected final OfflinePlayer getTarget(int arg, boolean others)
{
	OfflinePlayer target = null;
	if (args.length > arg && others)
	{
		target = Util.matchPlayer(args[arg]);
		if (target == null)
		{
			target = Util.matchOfflinePlayer(args[arg]);
			if (target == null || ! target.hasPlayedBefore())
			{
				err(getMessage("player_not_found"), args[arg]);
				return null;
			}
		}
	}
	else
	{
		if (sender instanceof Player)
		{
			target = player;
		}
		else
		{
			err(getMessage("console_level"));
			return null;
		}
	}

	return target;
}
 
开发者ID:dmulloy2,项目名称:SwornRPG,代码行数:32,代码来源:SwornRPGCommand.java

示例9: getPlayer

import net.dmulloy2.util.Util; //导入方法依赖的package包/类
public final Player getPlayer()
{
	if (player == null && name != null)
		return player = Util.matchPlayer(name);

	return player;
}
 
开发者ID:dmulloy2,项目名称:SwornGuns,代码行数:8,代码来源:GunPlayer.java

示例10: getPlayer

import net.dmulloy2.util.Util; //导入方法依赖的package包/类
public final Player getPlayer()
{
	if (player == null)
		this.player = Util.matchPlayer(uniqueId);
	return player;
}
 
开发者ID:dmulloy2,项目名称:SwornPermissions,代码行数:7,代码来源:User.java

示例11: perform

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

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

	sendMessage(getMessage("stats_header"), target.getName());
	sendMessage(getMessage("stats_sparkles"), data.getTotalSparkles());
	sendMessage(getMessage("stats_tokens"), data.getTokens());
}
 
开发者ID:dmulloy2,项目名称:TeamSparkle,代码行数:42,代码来源:CmdStats.java

示例12: handleSparkle

import net.dmulloy2.util.Util; //导入方法依赖的package包/类
/**
 * Handles the sparkle of a given player
 *
 * @param player Player who was sparkled
 */
public final void handleSparkle(Player player)
{
	Entry<String, PlayerData> entry = getSparkler(player);
	if (entry == null)
		return;

	String uniqueId = player.getUniqueId().toString();
	PlayerData data = entry.getValue();

	logHandler.log("Handling {0}''s sparkle of {1}", data.getLastKnownBy(), player.getName());

	// Commands for newly sparkled players
	List<String> commands = Config.sparkledRewards;
	if (! commands.isEmpty())
	{
		for (String command : commands)
		{
			command = replacePlayerVars(command, player);
			if (getServer().dispatchCommand(getServer().getConsoleSender(), command))
			{
				logHandler.debug("Executed command \"{0}\"", command);
			}
			else
			{
				// Rats
				logHandler.log(Level.WARNING, "Failed to execute command \"{0}\"", command);
			}
		}
	}

	// Welcome the new player
	player.sendMessage(FormatUtil.format(getMessage("sparkled_welcome"), player.getName()));

	// Reward the sparkler
	data.getInvited().remove(player.getName().toLowerCase());
	data.setTotalSparkles(data.getTotalSparkles() + 1);
	data.setTokens(data.getTokens() + 1);

	// Thank them if they're online
	Player sparkler = Util.matchPlayer(uniqueId);
	if (sparkler != null)
	{
		sparkler.sendMessage(FormatUtil.format(getMessage("sparkler_thanks"), player.getName()));
	}
}
 
开发者ID:dmulloy2,项目名称:TeamSparkle,代码行数:51,代码来源:TeamSparkle.java

示例13: perform

import net.dmulloy2.util.Util; //导入方法依赖的package包/类
@Override
public void perform()
{
	if (! plugin.getConfig().getBoolean("marriage"))
	{
		err(getMessage("command_disabled"));
		return;
	}

	PlayerData data = getPlayerData(player);
	Player target = Util.matchPlayer(args[0]);
	if (target == null)
	{
		err(getMessage("player_not_found"), args[0]);
		return;
	}

	String targetp = target.getName();
	PlayerData data1 = getPlayerData(target);
	if (data.getSpouse() != null)
	{
		err(getMessage("polygamy"));
	}
	else if (targetp.equals(sender.getName()))
	{
		err(getMessage("cannot_marry_self"));
	}
	else if (data1.getSpouse() != null)
	{
		err(getMessage("target_is_married"), targetp);
	}
	else if (data1.getProposals().contains(player.getName()))
	{
		err(getMessage("already_proposed"), targetp);
	}
	else
	{
		data1.getProposals().add(player.getName());
		sendpMessage(getMessage("you_have_proposed"), targetp);
		sendpMessage(target, getMessage("send_marriage_request"), sender.getName());
	}
}
 
开发者ID:dmulloy2,项目名称:SwornRPG,代码行数:43,代码来源:CmdPropose.java

示例14: perform

import net.dmulloy2.util.Util; //导入方法依赖的package包/类
@Override
public void perform()
{
	if (args.length == 0)
	{
		PlayerData data = getPlayerData(player);
		data.setRideWaitingTime(System.currentTimeMillis());
		data.setRideWaiting(true);

		sendpMessage(getMessage("ride_entity"));
		return;
	}

	final Player target = Util.matchPlayer(args[0]);
	if (target == null)
	{
		err(getMessage("player_not_found"), args[0]);
		return;
	}

	/* if (target.getPassenger() != null)
	{
		err(getMessage("ride_vehicle"));
		return;
	} */

	if (target.getVehicle() != null)
	{
		err(getMessage("ride_passenger"));
		return;
	}

	player.teleport(target);

	new BukkitRunnable()
	{
		@Override
		public void run()
		{
			target.addPassenger(player);

			sendpMessage(getMessage("ride_now_riding"), target.getName());
		}
	}.runTaskLater(plugin, 40L);
}
 
开发者ID:dmulloy2,项目名称:SwornRPG,代码行数:46,代码来源:CmdRide.java

示例15: run

import net.dmulloy2.util.Util; //导入方法依赖的package包/类
@Override
public void run()
{
	for (String wait : waiting.toArray(new String[0]))
	{
		Player player = Util.matchPlayer(wait);
		if (player == null || ! player.isOnline())
		{
			waiting.remove(wait);
			continue;
		}

		PlayerData data = plugin.getPlayerDataCache().getData(player);
		if (data.isFrenzyWaiting())
		{
			data.setFrenzyReadyTime(data.getFrenzyReadyTime() - 1);
			if (data.getFrenzyReadyTime() <= 0)
			{
				sendpMessage(player, plugin.getMessage("ability_lower"), data.getItemName());

				data.setFrenzyWaiting(false);
				data.setItemName(null);

				waiting.remove(wait);
			}
		}

		if (data.isSuperPickaxeWaiting())
		{
			data.setSuperPickaxeReadyTime(data.getSuperPickaxeReadyTime() - 1);
			if (data.getSuperPickaxeReadyTime() <= 0)
			{
				sendpMessage(player, plugin.getMessage("ability_lower"), data.getItemName());

				data.setSuperPickaxeWaiting(false);
				data.setItemName(null);

				waiting.remove(wait);
			}
		}
	}
}
 
开发者ID:dmulloy2,项目名称:SwornRPG,代码行数:43,代码来源:AbilityHandler.java


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