当前位置: 首页>>代码示例>>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;未经允许,请勿转载。