本文整理匯總了Java中org.bukkit.Bukkit.getPlayer方法的典型用法代碼示例。如果您正苦於以下問題:Java Bukkit.getPlayer方法的具體用法?Java Bukkit.getPlayer怎麽用?Java Bukkit.getPlayer使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.bukkit.Bukkit
的用法示例。
在下文中一共展示了Bukkit.getPlayer方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: getTribeListDescription
import org.bukkit.Bukkit; //導入方法依賴的package包/類
public static List<String> getTribeListDescription() {
List<String> desc = new ArrayList<>();
ChatColor color;
int online;
for(Tribe tribe : getTribes()) {
online = 0;
if("vanir".equals(tribe.getType()))
color = ChatColor.RED;
else color = ChatColor.YELLOW;
for(String str : tribe.getMembers()) {
if(Bukkit.getPlayer(str) != null)
online++;
}
desc.add(color + tribe.getName() + ChatColor.GRAY + " " + online + "/" + tribe.getMembers().size() + " online, $" + tribe.getBalance());
}
return desc;
}
示例2: onScatter
import org.bukkit.Bukkit; //導入方法依賴的package包/類
@EventHandler
public void onScatter(GameScatterEvent event) {
for (UUID uuid : OpenUHC.getCurrentGame().getPlayers()) {
Player player = Bukkit.getPlayer(uuid);
if (player != null) {
for (PotionEffect effect : EFFECTS) {
player.addPotionEffect(effect);
}
}
}
}
示例3: getTeam1Players
import org.bukkit.Bukkit; //導入方法依賴的package包/類
private List<Player> getTeam1Players() {
List<Player> players = new ArrayList<>();
for (UUID uuid : this.team1.keySet()) {
Player p = Bukkit.getPlayer(uuid);
if (p == null || !p.isOnline()) {
continue;
}
players.add(p);
}
return players;
}
示例4: onCommand
import org.bukkit.Bukkit; //導入方法依賴的package包/類
@Override
protected void onCommand(CommandSender sender, String[] args) {
Player p = (Player) sender;
boolean hasReturn = MetadataManager.hasMetadata(p, "checkGm");
if (args.length > 0) {
if (!Utils.isVisible(sender, args[0]))
return;
if (!hasReturn) {
MetadataManager.setMetadata(p, "checkGm", p.getGameMode());
MetadataManager.setMetadata(p, "checkLocation", p.getLocation());
}
Player target = Bukkit.getPlayer(args[0]);
p.setGameMode(GameMode.SPECTATOR);
p.teleport(target);
Bukkit.getScheduler().runTask(Core.getInstance(), () -> p.setSpectatorTarget(target));
return;
}
if (!hasReturn) {
sender.sendMessage(ChatColor.RED + "No previous state to return to.");
return;
}
p.teleport((Location) MetadataManager.removeMetadata(p, "checkLocation"));
p.setGameMode(MetadataManager.getEnum(p, "checkGm", GameMode.class));
}
示例5: sendMessage
import org.bukkit.Bukkit; //導入方法依賴的package包/類
@Override
public void sendMessage(String message) {
for (Player p : getPlayers()) {
p.sendMessage(message);
}
for (UUID uuid : this.spectators) {
if (Bukkit.getPlayer(uuid) != null) {
Bukkit.getPlayer(uuid).sendMessage(message);
}
else {
this.spectators.remove(uuid);
}
}
}
示例6: onExecute
import org.bukkit.Bukkit; //導入方法依賴的package包/類
@Override
public void onExecute(String[] args, CommandSender sender) {
i = 1;
Faction faction = getSenderFactionOrFromArg(sender, args, 1, true);
if (faction == null) {
return;
}
if (!(sender instanceof Player) || !faction.isPrivileged((Player) sender)) {
ParsingUtil.sendMessage(sender, FMessage.ERROR_NO_PERMISSION.getMessage());
return;
}
Player player = Bukkit.getPlayer(args[i]);
if (!player.isOnline()) {
ParsingUtil.sendMessage(sender, FMessage.ERROR_PLAYER_NOT_ONLINE.getMessage(), args[i]);
return;
}
if (faction.getMembers().contains(player)) {
ParsingUtil.sendMessage(sender, FMessage.CMD_INVITE_FAIL.getMessage(), args[i]);
return;
}
faction.getInvitedPlayers().remove(player);
faction.sendMessage(FMessage.CMD_UNINVITE_SUCCESS.getMessage(), sender, player);
}
示例7: kickAllUndownloaded
import org.bukkit.Bukkit; //導入方法依賴的package包/類
@Override
public void kickAllUndownloaded()
{
for (UUID id : currentlyDownloading)
{
Player player = Bukkit.getPlayer(id);
if (player != null)
player.kickPlayer(rejectMessage);
}
currentlyDownloading.clear();
}
示例8: onExpire
import org.bukkit.Bukkit; //導入方法依賴的package包/類
public void onExpire(UUID userUUID)
{
Player player = Bukkit.getPlayer(userUUID);
if (player == null) {
return;
}
Location nearest = LandMap.getNearestSafePosition(player, player.getLocation(), 24);
if (player.teleport(nearest, PlayerTeleportEvent.TeleportCause.PLUGIN)) {
player.sendMessage(ChatColor.YELLOW + getDisplayName() + ChatColor.YELLOW + " timer has teleported you to the nearest safe area.");
}
}
示例9: onCommand
import org.bukkit.Bukkit; //導入方法依賴的package包/類
@Override
protected void onCommand(CommandSender sender, String[] args) {
String message = ChatColor.DARK_GRAY + ": " + ChatColor.WHITE
+ Chat.applyAllFilters(sender, String.join(" ", skipArgs(args, 1)));
CommandSender receiver = args[0].equalsIgnoreCase("CONSOLE")
? Bukkit.getConsoleSender() : Bukkit.getPlayer(args[0]);
if (!Utils.isVisible(sender, receiver))
return;
if (receiver instanceof Player && AFK.isAFK((Player) receiver))
sender.sendMessage(ChatColor.GRAY + "This player is AFK, and may not receive your message.");
// Send display to sender
String rName = Utils.getSenderName(receiver);
sender.sendMessage(ChatColor.DARK_GRAY.toString() + ChatColor.BOLD + "TO " + rName + message);
if (sender instanceof Player)
MetadataManager.setMetadata((Player) sender, "lastWhisper", receiver.getName());
// Send display to receiver.
if (receiver instanceof Player) {
Player p = (Player) receiver;
if (KCPlayer.getWrapper(p).isIgnoring(sender))
return;
p.playSound(p.getLocation(), Sound.ENTITY_ITEM_PICKUP, 1, .75F);
MetadataManager.setMetadata(p, "lastWhisper", sender.getName());
}
receiver.sendMessage(ChatColor.DARK_GRAY.toString() + ChatColor.BOLD + "FROM " + Utils.getSenderName(sender) + message);
}
示例10: onCommand
import org.bukkit.Bukkit; //導入方法依賴的package包/類
@Override
protected void onCommand(CommandSender sender, String[] args) {
if (!Utils.isVisible(sender, args[0]))
return;
Player p = Bukkit.getPlayer(args[0]);
KCPlayer.getWrapper(p).setZenMode(new Date().getTime() + TimeUnit.DAYS.toMillis(1));
p.sendMessage(ChatColor.YELLOW.toString() + ChatColor.BOLD
+ Utils.randElement("Experience Tranquility", "Pass into the Iris") + ".");
}
示例11: run
import org.bukkit.Bukkit; //導入方法依賴的package包/類
public void run()
{
if(Bukkit.getPlayer(uuid) == null)
Bukkit.getScheduler().cancelTask(id);
else
if(Bukkit.getPlayer(uuid).isDead())
Bukkit.getScheduler().cancelTask(id);
else
if(!Bukkit.getPlayer(uuid).isSneaking())
{
Bukkit.getScheduler().cancelTask(id);
} else
{
Player p = Bukkit.getPlayer(uuid);
float cost = 0.075F;
float charge = ItemEnergy.getStoredEnergy(p.getInventory().getBoots());
double accuracy = Double.valueOf((new DecimalFormat("##.##")).format(speed - 0.69999999999999996D).replace(",", ".")).doubleValue();
if(charge >= cost)
{
p.getInventory().setBoots(ItemEnergy.chargeItem(p.getInventory().getBoots(), -cost));
me.mrCookieSlime.CSCoreLibPlugin.general.Player.PlayerInventory.update(p);
p.getWorld().playSound(p.getLocation(), Sound.ENTITY_TNT_PRIMED, 0.25F, 1.0F);
p.getWorld().playEffect(p.getLocation(), Effect.SMOKE, 1, 1);
p.setFallDistance(0.0F);
double gravity = 0.040000000000000001D;
double offset = SlimefunStartup.chance(100, 50) ? accuracy : -accuracy;
Vector vector = new Vector(p.getEyeLocation().getDirection().getX() * speed + offset, gravity, p.getEyeLocation().getDirection().getZ() * speed - offset);
p.setVelocity(vector);
} else
{
Bukkit.getScheduler().cancelTask(id);
}
}
}
示例12: sendMessage
import org.bukkit.Bukkit; //導入方法依賴的package包/類
public void sendMessage(FancyMessage fancyMessage) {
for (Player p : getPlayers()) {
fancyMessage.send(p);
}
for (UUID uuid : this.spectators) {
if (Bukkit.getPlayer(uuid) != null) {
fancyMessage.send(Bukkit.getPlayer(uuid));
} else {
this.spectators.remove(uuid);
}
}
}
示例13: onCommand
import org.bukkit.Bukkit; //導入方法依賴的package包/類
@Override
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
if (sender instanceof Player) {
final Player playerSender = (Player) sender;
if (args.length == 1) {
if (label.equals("tpa")) {
final Player playerRequested = Bukkit.getPlayer(args[0]);
if (playerRequested != null) {
tpaPlayers.put(playerRequested, playerSender);
playerSender.sendMessage("Teleport request send to " + playerRequested.getName());
playerRequested.sendMessage(ChatColor.GREEN + playerSender.getName() + ChatColor.YELLOW + " has sent you a teleportation request.");
TextComponent message1 = new TextComponent(ChatColor.YELLOW + "Click to accept the request -" + ChatColor.GREEN + ChatColor.BOLD + " [ACCEPT]");
message1.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/tpaccept"));
message1.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder(ChatColor.AQUA + "Click to accept the request").create()));
playerRequested.spigot().sendMessage(message1);
TextComponent message2 = new TextComponent(ChatColor.YELLOW + "Click to deny the request -" + ChatColor.RED + ChatColor.BOLD + " [DENY]");
message2.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/tpdeny"));
message2.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder(ChatColor.AQUA + "Click to deny the request").create()));
playerRequested.spigot().sendMessage(message2);
} else {
playerSender.sendMessage(playerRequested.getName() + " is offline");
}
}
} else if (args.length == 0) {
final Player playerToTeleport = tpaPlayers.get(playerSender);
if (playerToTeleport != null) {
if (label.equals("tpaccept")) {
playerToTeleport.sendMessage(playerSender.getName() + " has accepted your teleport request");
playerSender.sendMessage("Teleporting " + playerToTeleport.getName() + " to you");
playerToTeleport.teleport(playerSender);
} else {
playerToTeleport.sendMessage(playerSender + " has denied your teleport request");
playerSender.sendMessage(playerToTeleport.getName() + " teleport request denied");
}
tpaPlayers.remove(playerSender);
} else {
playerSender.sendMessage("You don't have any teleport request");
}
}
}
return true;
}
示例14: onCommand
import org.bukkit.Bukkit; //導入方法依賴的package包/類
@Override
public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args) {
if (cmd.getName().equalsIgnoreCase("crescent")) {
if (!sender.hasPermission("crescent.commands")) {
sender.sendMessage(ChatColor.RED + "You do not have permission to use this command.");
return true;
}
if (args.length == 0) {
String[] message = { ChatColor.BLUE + "Crescent",
ChatColor.WHITE + "/crescent learn - Enable learning mode.", ChatColor.WHITE
+ "/crescent doescheat [player] [yes/no/undefined] - Mark a player as a cheater or as a legitimate user so we can use their information to add to the database. If you want to reset it, use the undefined option." };
sender.sendMessage(message);
return true;
}
final String subCommand = args[0];
if (subCommand.equalsIgnoreCase("learn")) {
final boolean current = Crescent.getInstance().getConfig().getBoolean("learnMode");
Crescent.getInstance().getConfig().set("learnMode", !current);
final ChatColor colour = current ? ChatColor.RED : ChatColor.GREEN;
sender.sendMessage(colour + "You have " + ((current) ? "disabled" : "enabled") + " learning mode.");
return true;
} else if (subCommand.equalsIgnoreCase("doescheat")) {
if (args.length < 3) {
sender.sendMessage(ChatColor.RED + "You must include the player and whether they cheat or not.");
return true;
}
final String player = args[1];
final Player target = Bukkit.getPlayer(player);
if (target == null) {
sender.sendMessage(ChatColor.RED + "That player is not online.");
return true;
}
final String doesCheat = args[2];
final KnownCheating cheating;
switch (doesCheat.toLowerCase()) {
case "yes":
cheating = KnownCheating.YES;
break;
case "no":
cheating = KnownCheating.NO;
break;
case "undefined":
cheating = KnownCheating.UNDEFINED;
break;
default:
sender.sendMessage(ChatColor.RED + "That is not a valid option.");
return true;
}
Profile.getProfile(target.getUniqueId()).setKnownCheating(cheating);
sender.sendMessage(ChatColor.GREEN + "You have let the system know that " + target.getName()
+ "'s cheating status is: " + cheating.toString() + ".");
return true;
}
return true;
}
return true;
}
示例15: getPlayer
import org.bukkit.Bukkit; //導入方法依賴的package包/類
public Player getPlayer() {
return Bukkit.getPlayer(UUID.fromString(uniqueId));
}