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


Java Bukkit.getOfflinePlayer方法代碼示例

本文整理匯總了Java中org.bukkit.Bukkit.getOfflinePlayer方法的典型用法代碼示例。如果您正苦於以下問題:Java Bukkit.getOfflinePlayer方法的具體用法?Java Bukkit.getOfflinePlayer怎麽用?Java Bukkit.getOfflinePlayer使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.bukkit.Bukkit的用法示例。


在下文中一共展示了Bukkit.getOfflinePlayer方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: onTabComplete

import org.bukkit.Bukkit; //導入方法依賴的package包/類
@Override
public List<String> onTabComplete(CommandSender sender, Command command, String label, String[] args) {
    if (args.length != 2 || !(sender instanceof Player)) {
        return Collections.emptyList();
    }

    Player player = (Player) sender;
    PlayerFaction playerFaction = plugin.getFactionManager().getPlayerFaction(player);
    if (playerFaction == null || (playerFaction.getMember(player.getUniqueId()).getRole() != Role.LEADER)) {
        return Collections.emptyList();
    }

    List<String> results = new ArrayList<>();
    Map<UUID, FactionMember> members = playerFaction.getMembers();
    for (Map.Entry<UUID, FactionMember> entry : members.entrySet()) {
        if (entry.getValue().getRole() != Role.LEADER) {
            OfflinePlayer target = Bukkit.getOfflinePlayer(entry.getKey());
            String targetName = target.getName();
            if (targetName != null && !results.contains(targetName)) {
                results.add(targetName);
            }
        }
    }

    return results;
}
 
開發者ID:funkemunky,項目名稱:HCFCore,代碼行數:27,代碼來源:FactionLeaderArgument.java

示例2: onTabComplete

import org.bukkit.Bukkit; //導入方法依賴的package包/類
@Override
public List<String> onTabComplete(CommandSender sender, Command command, String label, String[] args) {
    if (args.length != 2) {
        return Collections.emptyList();
    }

    List<String> results = new ArrayList<>();
    Collection<FactionUser> factionUsers = plugin.getUserManager().getUsers().values();
    for (FactionUser factionUser : factionUsers) {
        Deathban deathban = factionUser.getDeathban();
        if (deathban == null || !deathban.isActive())
            continue;

        OfflinePlayer offlinePlayer = Bukkit.getOfflinePlayer(factionUser.getUserUUID());
        String offlineName = offlinePlayer.getName();
        if (offlineName != null) {
            results.add(offlinePlayer.getName());
        }
    }

    return results;
}
 
開發者ID:funkemunky,項目名稱:HCFCore,代碼行數:23,代碼來源:LivesReviveArgument.java

示例3: onExecute

import org.bukkit.Bukkit; //導入方法依賴的package包/類
@Override
public void onExecute(String[] args, CommandSender sender) {
    OfflinePlayer player = Bukkit.getOfflinePlayer(args[1]);
    if (!player.hasPlayedBefore()) {
        ParsingUtil.sendMessage(sender, FMessage.ERROR_NO_SUCH_PLAYER.getMessage(), args[2]);
        return;
    } else if (!plugin.getFPlayerCache().getByPlayer(player).hasFaction()) {
        ParsingUtil.sendMessage(sender, FMessage.ERROR_PLAYER_NOT_IN_ANY_FACTION.getMessage(), args[2]);
        return;
    }
    Faction faction = plugin.getFactionCache().getByMember(player);
    if (!faction.isPrivileged(sender)) {
        ParsingUtil.sendMessage(sender, FMessage.ERROR_NO_PERMISSION.getMessage());
        return;
    } else if (faction.getMods().contains(player) && sender instanceof Player && !faction.isAdmin(sender)) {
        ParsingUtil.sendMessage(sender, FMessage.ERROR_NO_PERMISSION.getMessage());
        return;
    }
    faction.kick(sender, player);
}
 
開發者ID:DRE2N,項目名稱:FactionsXL,代碼行數:21,代碼來源:KickCommand.java

示例4: onCommand

import org.bukkit.Bukkit; //導入方法依賴的package包/類
public boolean onCommand(final CommandSender sender, final Command command, final String label, final String[] args) {
    if (args.length < 1) {
        sender.sendMessage(ChatColor.RED + "Usage: /" + label + " <playerName>");
        return true;
    }
    final OfflinePlayer target = Bukkit.getOfflinePlayer(args[0]);
    if (!target.hasPlayedBefore() && !target.isOnline()) {
        sender.sendMessage(ChatColor.GOLD + "Player '" + ChatColor.WHITE + args[0] + ChatColor.GOLD + "' not found.");
        return true;
    }
    final UUID targetUUID = target.getUniqueId();
    final FactionUser factionTarget = HCF.getPlugin().getUserManager().getUser(targetUUID);
    final Deathban deathban = factionTarget.getDeathban();
    if (deathban == null || !deathban.isActive()) {
        sender.sendMessage(ChatColor.RED + target.getName() + " is not death-banned.");
        return true;
    }
    factionTarget.removeDeathban();
    Command.broadcastCommandMessage(sender, ChatColor.LIGHT_PURPLE + "A staff has revived " + target.getName() + ".");
    return false;
}
 
開發者ID:funkemunky,項目名稱:HCFCore,代碼行數:22,代碼來源:ReviveCommand.java

示例5: onTabComplete

import org.bukkit.Bukkit; //導入方法依賴的package包/類
@Override
public List<String> onTabComplete(CommandSender sender, Command command, String label, String[] args) {
    if (args.length != 2) {
        return Collections.emptyList();
    }

    List<String> results = new ArrayList<>();
    for (FactionUser factionUser : plugin.getUserManager().getUsers().values()) {
        Deathban deathban = factionUser.getDeathban();
        if (deathban != null && deathban.isActive()) {
            OfflinePlayer offlinePlayer = Bukkit.getOfflinePlayer(factionUser.getUserUUID());
            String name = offlinePlayer.getName();
            if (name != null) {
                results.add(name);
            }
        }
    }

    return results;
}
 
開發者ID:funkemunky,項目名稱:HCFCore,代碼行數:21,代碼來源:LivesCheckDeathbanArgument.java

示例6: onServerListPing

import org.bukkit.Bukkit; //導入方法依賴的package包/類
@EventHandler
public void onServerListPing(ServerListPingEvent event) {
    UUID uuid = getDatabaseManager().getPlayerUUID(event.getAddress().getHostAddress());
    if (uuid != null) {
        OfflinePlayer player = Bukkit.getOfflinePlayer(uuid);
        try {
            event.setServerIcon(Bukkit.loadServerIcon(getImageHandler().getImageForUser(player.getUniqueId(), player.getName())));
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
 
開發者ID:me4502,項目名稱:AdvancedServerListIcons,代碼行數:13,代碼來源:AdvancedServerListIconsSpigot.java

示例7: commandSelect

import org.bukkit.Bukkit; //導入方法依賴的package包/類
@SuppressWarnings("deprecation")
@SubCommand(value = "select", permission = "town.player.select")
public void commandSelect(CommandSender sender, Arguments args) {
    if (args.length() == 3 && sender.hasPermission("town.admin")) {
        String name = args.nextString();
        SpawnLocation spawnLocation = plugin.config.spawnConfig.spawns.get(name);
        if (spawnLocation == null || (SpawnConfig.DEFAULT.equals(name) && !sender.hasPermission("town.admin"))) {
            msg(sender, "user.spawn.not_found", name);
            return;
        }
        String playerName = args.nextString();
        OfflinePlayer offlinePlayer = Bukkit.getOfflinePlayer(playerName);
        if (offlinePlayer != null) {
            plugin.setPlayerSpawn(offlinePlayer, spawnLocation);
            if (offlinePlayer.isOnline() && plugin.hasSpawn(offlinePlayer)) {
                plugin.teleport(offlinePlayer.getPlayer(), plugin.getPlayerSpawn(offlinePlayer));
            }
        } else {
            msg(sender, "user.info.player_not_found", name);
        }
    } else if (!plugin.config.lock_spawn || !plugin.hasSpawn(asPlayer(sender))) {
        Player player = asPlayer(sender);
        SpawnGUI spawnGUI = new SpawnGUI(this.plugin, player);
        spawnGUI.openGUI(player, 1);
    } else {
        msg(sender, "user.select.lock");
    }
}
 
開發者ID:NyaaCat,項目名稱:Ourtown,代碼行數:29,代碼來源:CommandHandler.java

示例8: onCommand

import org.bukkit.Bukkit; //導入方法依賴的package包/類
public boolean onCommand(final CommandSender sender, final Command command, final String label, final String[] args) {
    final Player p = (Player)sender;
    if (args.length < 2) {
        sender.sendMessage(ChatColor.RED + "Usage: " + this.getUsage(label));
        return true;
    }
    if (Cooldowns.isOnCooldown("medic_cooldown", p)) {
        p.sendMessage(ChatColor.RED + "You still have a " + ChatColor.DARK_GRAY + ChatColor.BOLD + "Titanium" + ChatColor.RED + " cooldown for another " + (Cooldowns.getCooldownForPlayerLong("medic_cooldown", p)) + ChatColor.RED + '.');
        return true;
    }
    final OfflinePlayer target = Bukkit.getOfflinePlayer(args[1]);
    if (!target.hasPlayedBefore() && !target.isOnline()) {
        sender.sendMessage(ChatColor.RED + target.getName() + " is not online.");
        return true;
    }
    final UUID targetUUID = target.getUniqueId();
    final FactionUser factionTarget = this.plugin.getUserManager().getUser(targetUUID);
    final Deathban deathban = factionTarget.getDeathban();
    if (deathban == null || !deathban.isActive()) {
        sender.sendMessage(ChatColor.RED + target.getName() + " is not death-banned.");
        return true;
    }
    Relation relation = Relation.ENEMY;
    if (sender instanceof Player) {
        final Player player = (Player)sender;
        final UUID playerUUID = player.getUniqueId();
        final int selfLives = this.plugin.getDeathbanManager().getLives(playerUUID);
        Cooldowns.addCooldown("medic_cooldown", p, 5400);
        final PlayerFaction playerFaction = this.plugin.getFactionManager().getPlayerFaction(player);
        relation = ((playerFaction == null) ? Relation.ENEMY : playerFaction.getFactionRelation(this.plugin.getFactionManager().getPlayerFaction(targetUUID)));
        sender.sendMessage(ChatColor.YELLOW + "You have revived " + relation.toChatColour() + target.getName() + ChatColor.YELLOW + '.');
        Bukkit.broadcastMessage(ChatColor.translateAlternateColorCodes('&',"&8&l" + p.getName().toUpperCase() + " &7has used their Titanium Rank &eto revive &8&l" + target.getName().toUpperCase() + "&7."));
    }
    factionTarget.removeDeathban();
    return true;
}
 
開發者ID:funkemunky,項目名稱:HCFCore,代碼行數:37,代碼來源:MedicCommand.java

示例9: onCommand

import org.bukkit.Bukkit; //導入方法依賴的package包/類
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
    if (args.length < 1) {
        sender.sendMessage(ChatColor.RED + "Usage: /" + label + " <playerName>");
        return true;
    }

    OfflinePlayer target = Bukkit.getOfflinePlayer(args[0]); // TODO: breaking

    if (!target.hasPlayedBefore() && !target.isOnline()) {
        sender.sendMessage(ChatColor.GOLD + "Player '" + ChatColor.WHITE + args[0] + ChatColor.GOLD + "' not found.");
        return true;
    }

    UUID targetUUID = target.getUniqueId();
    FactionUser factionTarget = HCF.getPlugin().getUserManager().getUser(targetUUID);
    Deathban deathban = factionTarget.getDeathban();

    if (deathban == null || !deathban.isActive()) {
        sender.sendMessage(ChatColor.RED + target.getName() + " is not death-banned.");
        return true;
    }

    factionTarget.removeDeathban();
    Command.broadcastCommandMessage(sender, ChatColor.LIGHT_PURPLE + "Staff revived " + target.getName() + ".");
    //sender.sendMessage(ChatColor.GREEN +"You have revived: " + target.getName() + ChatColor.GRAY + ChatColor.ITALIC + "(Click here to refund items)").setHoverText(ChatColor.GREEN + "Click here to refund items for: " + ChatColor.GRAY + target.getPlayer().getName().setClick(ClickAction.RUN_COMMAND, "/inv " + target.getPlayer().getName()));
    return false;
}
 
開發者ID:funkemunky,項目名稱:HCFCore,代碼行數:29,代碼來源:StaffReviveCommand.java

示例10: onCommand

import org.bukkit.Bukkit; //導入方法依賴的package包/類
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
    if (args.length < 3) {
        sender.sendMessage((Object)ChatColor.RED + "Usage: " + this.getUsage(label));
        return true;
    }
    Integer amount = Ints.tryParse((String)args[2]);
    if (amount == null) {
        sender.sendMessage((Object)ChatColor.RED + "'" + args[2] + "' is not a number.");
        return true;
    }
    if (amount <= 0) {
        sender.sendMessage((Object)ChatColor.RED + "The amount of lives must be positive.");
        return true;
    }
    OfflinePlayer target = Bukkit.getOfflinePlayer((String)args[1]);
    if (!target.hasPlayedBefore() && !target.isOnline()) {
        sender.sendMessage(String.format(BaseConstants.PLAYER_WITH_NAME_OR_UUID_NOT_FOUND, args[1]));
        return true;
    }
    Player onlineTarget = target.getPlayer();
    if (sender instanceof Player && !sender.hasPermission(PERMISSION)) {
        Player player = (Player)sender;
        int ownedLives = this.plugin.getDeathbanManager().getLives(player.getUniqueId());
        if (amount > ownedLives) {
            sender.sendMessage((Object)ChatColor.RED + "You tried to give " + target.getName() + ' ' + amount + " lives, but you only have " + ownedLives + '.');
            return true;
        }
        this.plugin.getDeathbanManager().takeLives(player.getUniqueId(), amount);
    }
    final int targetLives = this.plugin.getDeathbanManager().getLives(target.getUniqueId());
    this.plugin.getDeathbanManager().addLives(target.getUniqueId(), amount);
    sender.sendMessage((Object)ChatColor.YELLOW + "You have sent " + (Object)ChatColor.GOLD + target.getName() + (Object)ChatColor.YELLOW + ' ' + amount + ' ' + (amount > 1 ? "life" : "lives") + '.');
    sender.sendMessage(ChatColor.GREEN + "Remaining Lives: " + ChatColor.RED + targetLives +  ChatColor.RED + ' ' + ((targetLives == 1) ? "life" : "lives") + '.');
    if (onlineTarget != null) {
        onlineTarget.sendMessage((Object)ChatColor.GOLD + sender.getName() + (Object)ChatColor.YELLOW + " has sent you " + (Object)ChatColor.GOLD + amount + ' ' + (amount > 1 ? "life" : "lives") + '.');
    }
    return true;
}
 
開發者ID:funkemunky,項目名稱:HCFCore,代碼行數:39,代碼來源:LivesGiveArgument.java

示例11: onCommand

import org.bukkit.Bukkit; //導入方法依賴的package包/類
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
    if (args.length < 4) {
        sender.sendMessage(ChatColor.RED + "Usage: " + getUsage(label));
        return true;
    }

    long duration = JavaUtils.parse(args[3]);

    if (duration == -1L) {
        sender.sendMessage(ChatColor.RED + "Invalid duration, use the correct format: 10m 1s");
        return true;
    }

    PlayerTimer playerTimer = null;
    for (Timer timer : plugin.getTimerManager().getTimers()) {
        if (timer instanceof PlayerTimer && WHITESPACE_TRIMMER.matcher(timer.getName()).replaceAll("").equalsIgnoreCase(args[1])) {
            playerTimer = (PlayerTimer) timer;
            break;
        }
    }

    if (playerTimer == null) {
        sender.sendMessage(ChatColor.RED + "Timer '" + args[1] + "' not found.");
        return true;
    }

    if (args[2].equalsIgnoreCase("all")) {
        for (Player player : Bukkit.getOnlinePlayers()) {
            playerTimer.setCooldown(player, player.getUniqueId(), duration, true, null);
        }

        sender.sendMessage(ChatColor.BLUE + "Set timer " + playerTimer.getName() + " for all to " + DurationFormatUtils.formatDurationWords(duration, true, true) + '.');
    } else {
        OfflinePlayer target = Bukkit.getOfflinePlayer(args[2]); // TODO: breaking
        Player targetPlayer = null;

        if (target == null || (sender instanceof Player && ((targetPlayer = target.getPlayer()) != null) && !((Player) sender).canSee(targetPlayer))) {
            sender.sendMessage(ChatColor.GOLD + "Player '" + ChatColor.WHITE + args[1] + ChatColor.GOLD + "' not found.");
            return true;
        }

        playerTimer.setCooldown(targetPlayer, target.getUniqueId(), duration, true, null);
        sender.sendMessage(ChatColor.BLUE + "Set timer " + playerTimer.getName() + " duration to " + DurationFormatUtils.formatDurationWords(duration, true, true) + " for " + target.getName()
                + '.');
    }

    return true;
}
 
開發者ID:funkemunky,項目名稱:HCFCore,代碼行數:50,代碼來源:TimerSetArgument.java

示例12: fromArgument

import org.bukkit.Bukkit; //導入方法依賴的package包/類
@Override
public OfflinePlayer fromArgument() {
    if (matches())
        return Bukkit.getOfflinePlayer(UUID.fromString(getEnteredArgument()));
    return null;
}
 
開發者ID:AlphaHelixDev,項目名稱:AlphaLibary,代碼行數:7,代碼來源:OfflinePlayerArgument.java

示例13: getPlayer

import org.bukkit.Bukkit; //導入方法依賴的package包/類
@Override
public OfflinePlayer getPlayer() {
    return Bukkit.getOfflinePlayer( this.name );
}
 
開發者ID:lukas81298,項目名稱:FlexMC,代碼行數:5,代碼來源:FlexScore.java

示例14: onCommand

import org.bukkit.Bukkit; //導入方法依賴的package包/類
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
    if (args.length < 2) {
        sender.sendMessage(ChatColor.RED + "Usage: /" + label + " <playerName> <amount>");
        return true;
    }

    Integer amount = JavaUtils.tryParseInt(args[1]);

    if (amount == null) {
        sender.sendMessage(ChatColor.RED + "'" + args[1] + "' is not a valid number.");
        return true;
    }

    if (amount <= 0) {
        sender.sendMessage(ChatColor.RED + "You must send money in positive quantities.");
        return true;
    }

    // Calculate the senders balance here.
    Player senderPlayer = sender instanceof Player ? (Player) sender : null;
    int senderBalance = senderPlayer != null ? plugin.getEconomyManager().getBalance(senderPlayer.getUniqueId()) : 1024;

    if (senderBalance < amount) {
        sender.sendMessage(ChatColor.RED + "You tried to pay " + EconomyManager.ECONOMY_SYMBOL + amount + ", but you only have " + EconomyManager.ECONOMY_SYMBOL + senderBalance
                + " in your bank account.");

        return true;
    }

    OfflinePlayer target = Bukkit.getOfflinePlayer(args[0]); // TODO: breaking

    if (sender.equals(target)) {
        sender.sendMessage(ChatColor.RED + "You cannot send money to yourself.");
        return true;
    }

    Player targetPlayer = target.getPlayer();

    if (!target.hasPlayedBefore() && targetPlayer == null) {
        sender.sendMessage(ChatColor.GOLD + "Player '" + ChatColor.WHITE + args[0] + ChatColor.GOLD + "' not found.");
        return true;
    }

    if (targetPlayer == null)
        return false; // won't happen, IntelliJ compiler won't ignore

    // Make the money transactions.
    if (senderPlayer != null)
        plugin.getEconomyManager().subtractBalance(senderPlayer.getUniqueId(), amount);
    plugin.getEconomyManager().addBalance(targetPlayer.getUniqueId(), amount);

    targetPlayer.sendMessage(ChatColor.YELLOW + sender.getName() + " has sent you " + ChatColor.GOLD + EconomyManager.ECONOMY_SYMBOL + amount + ChatColor.YELLOW + '.');
    sender.sendMessage(ChatColor.YELLOW + "You have sent " + ChatColor.GOLD + EconomyManager.ECONOMY_SYMBOL + amount + ChatColor.YELLOW + " to " + target.getName() + '.');
    return true;
}
 
開發者ID:funkemunky,項目名稱:HCFCore,代碼行數:57,代碼來源:PayCommand.java

示例15: getName

import org.bukkit.Bukkit; //導入方法依賴的package包/類
/**
 * Gets the name of this {@link FactionMember}.
 *
 * @return the name of this {@link FactionMember}
 */
public String getName() {
    OfflinePlayer offlinePlayer = Bukkit.getOfflinePlayer(uniqueID);
    return offlinePlayer.hasPlayedBefore() || offlinePlayer.isOnline() ? offlinePlayer.getName() : null;
}
 
開發者ID:funkemunky,項目名稱:HCFCore,代碼行數:10,代碼來源:FactionMember.java


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