本文整理汇总了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;
}
示例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;
}
示例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);
}
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}