當前位置: 首頁>>代碼示例>>Java>>正文


Java Bukkit.getPlayer方法代碼示例

本文整理匯總了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;
}
 
開發者ID:benNek,項目名稱:AsgardAscension,代碼行數:18,代碼來源:TribeManager.java

示例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);
      }
    }
  }
}
 
開發者ID:twizmwazin,項目名稱:OpenUHC,代碼行數:12,代碼來源:BlindnessModule.java

示例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;
}
 
開發者ID:ijoeleoli,項目名稱:ZorahPractice,代碼行數:16,代碼來源:TeamMatch.java

示例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));
}
 
開發者ID:Kneesnap,項目名稱:Kineticraft,代碼行數:29,代碼來源:CommandCheck.java

示例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);
        }
    }
}
 
開發者ID:ijoeleoli,項目名稱:ZorahPractice,代碼行數:16,代碼來源:FfaMatch.java

示例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);
}
 
開發者ID:DRE2N,項目名稱:FactionsXL,代碼行數:28,代碼來源:UninviteCommand.java

示例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();
}
 
開發者ID:SamaGames,項目名稱:SamaGamesCore,代碼行數:13,代碼來源:ResourcePacksManagerImpl.java

示例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.");
    }
}
 
開發者ID:funkemunky,項目名稱:HCFCore,代碼行數:13,代碼來源:StuckTimer.java

示例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);
}
 
開發者ID:Kneesnap,項目名稱:Kineticraft,代碼行數:32,代碼來源:CommandMessage.java

示例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") + ".");
}
 
開發者ID:Kneesnap,項目名稱:Kineticraft,代碼行數:11,代碼來源:CommandZen.java

示例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);
        }
    }
}
 
開發者ID:StarWishsama,項目名稱:Slimefun4-Chinese-Version,代碼行數:35,代碼來源:JetBootsTask.java

示例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);
        }
    }
}
 
開發者ID:ijoeleoli,項目名稱:ZorahPractice,代碼行數:14,代碼來源:TeamMatch.java

示例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;
}
 
開發者ID:SlamTheHam,項目名稱:UltraCore,代碼行數:45,代碼來源:Tpa.java

示例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;
}
 
開發者ID:davidm98,項目名稱:Crescent,代碼行數:78,代碼來源:CommandCrescent.java

示例15: getPlayer

import org.bukkit.Bukkit; //導入方法依賴的package包/類
public Player getPlayer() {
    return Bukkit.getPlayer(UUID.fromString(uniqueId));
}
 
開發者ID:tastybento,項目名稱:bskyblock,代碼行數:4,代碼來源:Players.java


注:本文中的org.bukkit.Bukkit.getPlayer方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。