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


Java OfflinePlayer.getPlayer方法代碼示例

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


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

示例1: resolve

import org.bukkit.OfflinePlayer; //導入方法依賴的package包/類
public DamageInfo resolve(LivingEntity entity, Lifetime lifetime, EntityDamageEvent damageEvent) {
    if(damageEvent instanceof EntityDamageByEntityEvent) {
        EntityDamageByEntityEvent event = (EntityDamageByEntityEvent) damageEvent;

        if(event.getDamager() instanceof FallingBlock) {
            FallingBlock anvil = (FallingBlock) event.getDamager();
            OfflinePlayer offlineOwner = this.anvilTracker.getOwner(anvil);
            Player onlineOwner = null;

            if(offlineOwner != null) onlineOwner = offlineOwner.getPlayer();

            return new AnvilDamageInfo(anvil, onlineOwner, offlineOwner);
        }
    }

    return null;
}
 
開發者ID:WarzoneMC,項目名稱:Warzone,代碼行數:18,代碼來源:AnvilDamageResolver.java

示例2: addReceiver

import org.bukkit.OfflinePlayer; //導入方法依賴的package包/類
/**
 * Add hologram's receiver
 *
 * @param offlinePlayer Player
 *
 * @return {@code true} is success
 */
public boolean addReceiver(OfflinePlayer offlinePlayer)
{
    if(!offlinePlayer.isOnline())
        return false;

    Player p = offlinePlayer.getPlayer();
    boolean inRange = false;

    if(p.getLocation().getWorld() == this.location.getWorld() && p.getLocation().distance(this.location) <= this.rangeView)
    {
        inRange = true;
        this.sendLines(offlinePlayer.getPlayer());
    }

    this.receivers.put(offlinePlayer, inRange);

    return true;
}
 
開發者ID:SamaGames,項目名稱:SamaGamesAPI,代碼行數:26,代碼來源:Hologram.java

示例3: sendLinesForPlayers

import org.bukkit.OfflinePlayer; //導入方法依賴的package包/類
/**
 * Send hologram's lines to all players
 */
public void sendLinesForPlayers()
{
    for(OfflinePlayer offlinePlayer : this.receivers.keySet())
    {
        if(!offlinePlayer.isOnline())
            continue;

        Player p = offlinePlayer.getPlayer();
        boolean wasInRange = this.receivers.get(offlinePlayer);
        boolean inRange = false;

        if(p.getLocation().getWorld() == this.location.getWorld() && p.getLocation().distance(this.location) <= this.rangeView)
            inRange = true;

        if(this.linesChanged && inRange)
        {
            this.sendLines(p);
            this.linesChanged = false;
        }
        else if(wasInRange == inRange)
        {
            continue;
        }
        else if(wasInRange)
        {
            this.removeLines(p);
        }
        else
        {
            this.sendLines(p);
        }

        this.receivers.put(offlinePlayer, inRange);
    }
}
 
開發者ID:SamaGames,項目名稱:SamaGamesAPI,代碼行數:39,代碼來源:Hologram.java

示例4: addReceiver

import org.bukkit.OfflinePlayer; //導入方法依賴的package包/類
/**
 * Add a receiver to the objective
 *
 * @param offlinePlayer Player
 */
public boolean addReceiver(OfflinePlayer offlinePlayer)
{
    if(!offlinePlayer.isOnline())
        return false;

    this.receivers.add(offlinePlayer);

    Player p = offlinePlayer.getPlayer();

    this.init(p);
    this.updateScore(p, true);

    return true;
}
 
開發者ID:SamaGames,項目名稱:SamaGamesAPI,代碼行數:20,代碼來源:ObjectiveSign.java

示例5: addReceiver

import org.bukkit.OfflinePlayer; //導入方法依賴的package包/類
/**
 * Add a receiver to the objective
 *
 * @param offlinePlayer Player
 */
public boolean addReceiver(OfflinePlayer offlinePlayer)
{
    if(!offlinePlayer.isOnline())
        return false;

    this.receivers.add(offlinePlayer);

    Player p = offlinePlayer.getPlayer();

    this.init(p);
    this.updateScore(p);

    return true;
}
 
開發者ID:SamaGames,項目名稱:SamaGamesAPI,代碼行數:20,代碼來源:VObjective.java

示例6: addReceiver

import org.bukkit.OfflinePlayer; //導入方法依賴的package包/類
/**
 * Add receiver
 *
 * @param offlinePlayer Player
 *
 * @return {@code true} if success
 */
public boolean addReceiver(OfflinePlayer offlinePlayer)
{
    if(!offlinePlayer.isOnline())
        return false;

    this.removeFromAllTeams(offlinePlayer);

    this.receivers.add(offlinePlayer);
    Player p = offlinePlayer.getPlayer();
    this.sendAllTeams(p);

    return true;
}
 
開發者ID:SamaGames,項目名稱:SamaGamesAPI,代碼行數:21,代碼來源:TeamHandler.java

示例7: onCommand

import org.bukkit.OfflinePlayer; //導入方法依賴的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

示例8: onCommand

import org.bukkit.OfflinePlayer; //導入方法依賴的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

示例9: onCommand

import org.bukkit.OfflinePlayer; //導入方法依賴的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

示例10: onCommand

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

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

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

    if (amount <= 0) {
        sender.sendMessage(ChatColor.RED + "The amount of lives must be positive.");
        return true;
    }

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

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

    Player onlineTarget = target.getPlayer();

    if (sender instanceof Player) {
        Player player = (Player) sender;
        int ownedLives = plugin.getDeathbanManager().getLives(player.getUniqueId());

        if (amount > ownedLives) {
            sender.sendMessage(ChatColor.RED + "You tried to give " + target.getName() + ' ' + amount + " lives, but you only have " + ownedLives + '.');
            return true;
        }

        plugin.getDeathbanManager().takeLives(player.getUniqueId(), amount);
    }

    plugin.getDeathbanManager().addLives(target.getUniqueId(), amount);
    sender.sendMessage(ChatColor.YELLOW + "You have sent " + ChatColor.GOLD + target.getName() + ChatColor.YELLOW + ' ' + amount + ' ' + (amount > 1 ? "lives" : "life") + ChatColor.YELLOW + '.');
    if (onlineTarget != null) {
        onlineTarget
                .sendMessage(ChatColor.GOLD + sender.getName() + ChatColor.YELLOW + " has sent you " + ChatColor.GOLD + amount + ' ' + (amount > 1 ? "lives" : "life") + ChatColor.YELLOW + '.');
    }

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


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