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