当前位置: 首页>>代码示例>>Java>>正文


Java Player.equals方法代码示例

本文整理汇总了Java中org.bukkit.entity.Player.equals方法的典型用法代码示例。如果您正苦于以下问题:Java Player.equals方法的具体用法?Java Player.equals怎么用?Java Player.equals使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.bukkit.entity.Player的用法示例。


在下文中一共展示了Player.equals方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onCaptureZoneLeave

import org.bukkit.entity.Player; //导入方法依赖的package包/类
@EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR)
public void onCaptureZoneLeave(CaptureZoneLeaveEvent event) {
    if (Objects.equal(event.getFaction(), this.eventFaction)) {
        Player player = event.getPlayer();
        CaptureZone captureZone = event.getCaptureZone();
        if (Objects.equal(player, captureZone.getCappingPlayer())) {
            captureZone.setCappingPlayer(null);
            this.eventFaction.getEventType().getEventTracker().onControlLoss(player, captureZone, this.eventFaction);

            // Try and find a new capper.
            for (Player target : captureZone.getCuboid().getPlayers()) {
                if (target != null && !target.equals(player) && eventFaction.getEventType().getEventTracker().onControlTake(target, captureZone)) {
                    captureZone.setCappingPlayer(target);
                    break;
                }
            }
        }
    }
}
 
开发者ID:funkemunky,项目名称:HCFCore,代码行数:20,代码来源:EventTimer.java

示例2: onTabComplete

import org.bukkit.entity.Player; //导入方法依赖的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) {
        return Collections.emptyList();
    }

    List<String> results = new ArrayList<>();
    for (Player target : Bukkit.getOnlinePlayers()) {
        if (!target.equals(player) && player.canSee(target) && !results.contains(target.getName())) {
            Faction targetFaction = plugin.getFactionManager().getPlayerFaction(target);
            if (targetFaction != null && playerFaction != targetFaction) {
                if (playerFaction.getRequestedRelations().get(targetFaction.getUniqueID()) != RELATION && playerFaction.getRelations().get(targetFaction.getUniqueID()) != RELATION) {
                    results.add(targetFaction.getName());
                }
            }
        }
    }

    return results;
}
 
开发者ID:funkemunky,项目名称:HCFCore,代码行数:27,代码来源:FactionAllyArgument.java

示例3: listener

import org.bukkit.entity.Player; //导入方法依赖的package包/类
@Override
protected Listener listener(Consumer<Block> callback) {
    return new Listener() {
        @EventHandler
        public void onClick(PlayerInteractEvent event) {
            Player clicker = event.getPlayer();
            EquipmentSlot hand = event.getHand();
            Block block = event.getClickedBlock();

            if (block != null && clicker.equals(player)
                    && (!MCUtils.isOffHandSupport() || hand == EquipmentSlot.HAND)) {
                clicker.sendMessage(MCUtils.colorize(messageFunc.apply(block)));
                callback.accept(block);
                event.setCancelled(true);
            }
        }
    };
}
 
开发者ID:EntryPointKR,项目名称:MCLibrary,代码行数:19,代码来源:ClickWizard.java

示例4: show

import org.bukkit.entity.Player; //导入方法依赖的package包/类
/**
 * Shows the given players the selection
 *
 * @param players players
 */
@Override
public void show(Player... players) {
    for (final Player player : players) {
        if (!player.equals(this.getOwner())) {
            this.watchers.add(player);
        }
    }
    for (int i = 0; i < this.getXWidth(); i++) {
        for (int j = 0; j < this.getYWidth(); j++) {
            for (int k = 0; k < this.getZWidth(); k++) {
                if (this.stands[i][j][k] != null) {
                    this.stands[i][j][k].remove();
                    this.stands[i][j][k].spawn();
                }
            }
        }
    }
    this.hidden = false;
}
 
开发者ID:Shynixn,项目名称:AstralEdit,代码行数:25,代码来源:SelectionHolder.java

示例5: updatePlayer

import org.bukkit.entity.Player; //导入方法依赖的package包/类
private void updatePlayer(Player player, String oldName) {
    Validate.isTrue(enabled, "NameTagChanger is disabled");
    GameProfileWrapper newProfile = gameProfiles.get(player.getUniqueId());
    if (newProfile == null) {
        newProfile = packetHandler.getDefaultPlayerProfile(player);
    }
    List<Team> scoreboardTeamsToUpdate = Lists.newArrayList();
    sendingPackets = true;
    for (Player otherPlayer : Bukkit.getOnlinePlayers()) {
        if (otherPlayer.equals(player)) {
            if (otherPlayer.getScoreboard().getEntryTeam(player.getName()) != null) {
                scoreboardTeamsToUpdate.add(otherPlayer.getScoreboard().getEntryTeam(player.getName()));
            }
            continue;
        }
        if (otherPlayer.canSee(player)) {
            packetHandler.sendTabListRemovePacket(player, otherPlayer);
            packetHandler.sendTabListAddPacket(player, newProfile, otherPlayer);
            if (otherPlayer.getWorld().equals(player.getWorld())) {
                packetHandler.sendEntityDestroyPacket(player, otherPlayer);
                packetHandler.sendNamedEntitySpawnPacket(player, otherPlayer);
            }
        }
        // The player we want to rename is in a scoreboard team.
        if (otherPlayer.getScoreboard().getEntryTeam(player.getName()) != null) {
            scoreboardTeamsToUpdate.add(otherPlayer.getScoreboard().getEntryTeam(player.getName()));
        }
    }
    if (oldName != null) {
        String newName = newProfile.getName();
        for (Team team : scoreboardTeamsToUpdate) {
            Bukkit.getOnlinePlayers().stream().filter(p -> p.getScoreboard() == team.getScoreboard()).forEach(p -> {
                packetHandler.sendScoreboardRemovePacket(oldName, p, team.getName());
                packetHandler.sendScoreboardAddPacket(newName, p, team.getName());
            });
        }
    }
    sendingPackets = false;
}
 
开发者ID:Alvin-LB,项目名称:NameTagChanger,代码行数:40,代码来源:NameTagChanger.java

示例6: onChat

import org.bukkit.entity.Player; //导入方法依赖的package包/类
@EventHandler(priority = EventPriority.LOWEST)
public void onChat(AsyncPlayerChatEvent evt) {
    Player p = evt.getPlayer();
    if (!isPlaying(p))
        return;

    evt.setCancelled(true);
    if (currentWord != null) {
        if (p.equals(currentPainter)) {
            p.sendMessage(ChatColor.RED + "You cannot talk while it is your turn to draw.");
            return;
        }

        if (MetadataManager.hasMetadata(p, "dmtCorrect")) {
            p.sendMessage(ChatColor.RED + "You have already guessed the word this round.");
            return;
        } else if (currentWord.equalsIgnoreCase(evt.getMessage())) {
            broadcastPlayers(ChatColor.GREEN.toString() + ChatColor.BOLD + evt.getPlayer().getName() + " guessed the word! +1 Point!");
            setScore(p, getScore(p) + 1); // Increase score of guesser
            setScore(currentPainter, getScore(currentPainter) + 1); // Increase score of drawer.
            MetadataManager.setMetadata(p, "dmtCorrect", true);
            return;
        }
    }

    getPlayers().forEach(pl -> pl.sendMessage(ChatColor.YELLOW + p.getName() + ": " + ChatColor.GRAY + evt.getMessage()));
}
 
开发者ID:Kneesnap,项目名称:Kineticraft,代码行数:28,代码来源:Pictionary.java

示例7: onPlayerDeath

import org.bukkit.entity.Player; //导入方法依赖的package包/类
@EventHandler(ignoreCancelled = true, priority = EventPriority.LOWEST)
public void onPlayerDeath(PlayerDeathEvent event) {
    Player player = event.getEntity();
    Player killer = player.getKiller();
    if (killer != null && !killer.equals(player)) {
        event.getDrops().add(getDeathSign(player.getName(), killer.getName()));
    }
}
 
开发者ID:funkemunky,项目名称:HCFCore,代码行数:9,代码来源:DeathSignListener.java

示例8: run

import org.bukkit.entity.Player; //导入方法依赖的package包/类
@Override
public void run(PAUser user, String label, String[] args) {
    String nick;
    switch (args.length) {
        case 1:
            nick = args[0];
            break;
        default:
            String s = user.getUserData().getNickname().equalsIgnoreCase("") ? user.getName() : user.getUserData().getNickname();
            user.sendMessage(PAData.CORE.getPrefix() + "&6Tu nick es " + s);
            return;
    }
    for (Player p : plugin.getServer().getOnlinePlayers()) {
        if (p.equals(user.getPlayer())) continue;
        if (p.getName().equalsIgnoreCase(ChatColor.stripColor(nick)) || PAServer.getUser(p).getDisplayName().equalsIgnoreCase(ChatColor.stripColor(nick))) {
            user.sendMessage(PAData.CORE.getPrefix() + "&cEl usuario &6" + p.getName() + " &cya tiene ese nick");
            return;
        }
    }

    nick = Utils.colorize(nick);
    user.getPlayer().setDisplayName(nick.equalsIgnoreCase("off") ? user.getName() : nick);
    user.getUserData().setNickname(nick.equalsIgnoreCase("off") ? null : nick);
    user.sendMessage(PAData.CORE.getPrefix() + "&6Tu nuevo nick es " + nick);

    user.save();
}
 
开发者ID:cadox8,项目名称:PA,代码行数:28,代码来源:NickCMD.java

示例9: run

import org.bukkit.entity.Player; //导入方法依赖的package包/类
/**
 * To be used for hiding players but not in tab, and looped to avoid entity
 * respawn on view when coming back from away
 */

@Override
public void run()
{
    for (Player p1 : Bukkit.getOnlinePlayers())
        for (Player p2 : Bukkit.getOnlinePlayers())
            if (!p1.equals(p2))
                ((CraftPlayer)p1).getHandle().playerConnection.sendPacket(new PacketPlayOutEntityDestroy(p2.getEntityId()));
}
 
开发者ID:SamaGames,项目名称:AgarMC,代码行数:14,代码来源:InvisibleLoop.java

示例10: getOpponents

import org.bukkit.entity.Player; //导入方法依赖的package包/类
@Override
public List<Player> getOpponents(Player player) {
    if (player.equals(this.player1)) {
        return Collections.singletonList(player2);
    }

    if (player.equals(this.player2)) {
        return Collections.singletonList(player1);
    }

    return Collections.emptyList();
}
 
开发者ID:ijoeleoli,项目名称:ZorahPractice,代码行数:13,代码来源:SoloMatch.java

示例11: onChatEvent

import org.bukkit.entity.Player; //导入方法依赖的package包/类
@EventHandler
private void onChatEvent(AsyncPlayerChatEvent e) {
 // Watch is the temporary cell phone
 if (e.getPlayer().getInventory().getItemInMainHand().getType() == Material.WATCH)
  return;
 // Walkie Talkie
 if (e.getPlayer().getInventory().getItemInMainHand().getType() == Material.REDSTONE_COMPARATOR)
  return;
 
 e.setCancelled(true);

  String message = e.getMessage();
  Player sender = e.getPlayer();
  String format = ("&b" + sender.getName() + "&8&l >> &r");

  for (Player recipient : e.getRecipients()) {
  	
    // Check if players are in the same world.
    if (!sender.getWorld().equals(recipient.getWorld()))
      continue;
    
    // Sender counts as recipient so send him his unscrambled message.
    if (sender.equals(recipient)) {
      recipient.sendMessage(StringUtilities.color(format + message));
      continue;
    }
    
    // If message sent by admin/op don#t scramble
    if (sender.hasPermission("mtcom.unscrambled")) {
  	  recipient.sendMessage(StringUtilities.color(format + message));
        continue;
    }
    
    String scrambled = main.getMessageScrambler().scramble(message, sender, recipient);
    // 'Scrambled' will be null if the distance is > 100 (send no message to recipient).
    if (scrambled == null)
      continue;

    String scrambledMessage = StringUtilities.color(format + scrambled);
    recipient.sendMessage(scrambledMessage);
  }
}
 
开发者ID:kadeska,项目名称:MT_Communication,代码行数:43,代码来源:PlayerChatListener.java

示例12: setFrozen

import org.bukkit.entity.Player; //导入方法依赖的package包/类
public void setFrozen(@Nullable CommandSender freezer, Player freezee, boolean frozen) throws CommandException {
    if(!freezee.equals(freezer) && freezee.hasPermission("projectares.freeze.exempt")) {
        throw new ComponentCommandException(new TranslatableComponent(
            "command.freeze.exempt",
            new PlayerComponent(identityProvider.currentIdentity(freezee), NameStyle.VERBOSE)
        ));
    }

    final Identity freezerIdentity = identityProvider.createIdentity(freezer);
    final Audience freezeeAudience = audiences.get(freezee);

    final FrozenPlayer frozenPlayer = frozenPlayers.get(freezee);
    if(frozen && frozenPlayer == null) {
        frozenPlayers.put(freezee, playerFreezer.freeze(freezee));

        final BaseComponent freezeeMessage = new Component(
            new TranslatableComponent(
                "freeze.frozen",
                new PlayerComponent(freezerIdentity, NameStyle.FANCY)
            ),
            ChatColor.RED
        );

        freezeeAudience.playSound(FREEZE_SOUND);
        freezeeAudience.sendWarning(freezeeMessage, false);
        freezeeAudience.showTitle(Components.blank(), freezeeMessage, 5, 9999, 5);

        removeEntities(freezee.getLocation(), config.tntVictimRadius());

        if(freezer instanceof Player) {
            removeEntities(((Player) freezer).getLocation(), config.tntSenderRadius());
        }

        adminChannel.broadcast(CommandUtils.getDisplayName(freezer) +
                               ChatColor.RED + " froze " +
                               CommandUtils.getDisplayName(freezee));
    } else if(!frozen && frozenPlayer != null) {
        frozenPlayer.thaw();
        frozenPlayers.remove(freezee);

        freezeeAudience.hideTitle();
        freezeeAudience.playSound(THAW_SOUND);
        freezeeAudience.sendMessage(new Component(
            new TranslatableComponent(
                "freeze.unfrozen",
                new PlayerComponent(freezerIdentity, NameStyle.FANCY)
            ),
            ChatColor.GREEN
        ));

        adminChannel.broadcast(CommandUtils.getDisplayName(freezer) +
                               ChatColor.RED + " unfroze " +
                               CommandUtils.getDisplayName(freezee));
    }
}
 
开发者ID:OvercastNetwork,项目名称:ProjectAres,代码行数:56,代码来源:Freeze.java

示例13: formRadiusedMessage

import org.bukkit.entity.Player; //导入方法依赖的package包/类
/**
 * Appends a distance indicator to the formatted message
 *
 * @param channel The channel the message will be going to
 * @param sender  The player sending the message
 * @param compare The player who will be receiving the message
 * @param message The message the player is sending
 * @return The formatted chat message with the distance indicator
 */
private String formRadiusedMessage(Channel channel, Player sender, Player compare, String message)
{
    if (!sender.equals(compare))
        return "" + ChatColor.GRAY + ChatColor.ITALIC + "(" + Math.round(sender.getEyeLocation().distance(compare.getEyeLocation())) + "m) " + formatMessage(channel, sender, message);
    else
        return formatMessage(channel, sender, message);
}
 
开发者ID:codenameflip,项目名称:ChatChannels,代码行数:17,代码来源:PlayerChat.java


注:本文中的org.bukkit.entity.Player.equals方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。