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


Java PlayerChatEvent.getPlayer方法代码示例

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


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

示例1: onChat

import cn.nukkit.event.player.PlayerChatEvent; //导入方法依赖的package包/类
@EventHandler(priority = EventPriority.HIGHEST)
public void onChat(PlayerChatEvent event) {
    Player player = event.getPlayer();
    String msg = event.getMessage();
    CheckChat checkChat = new CheckChat(player, msg);
    CheckWords checkWords = new CheckWords(player, msg);
    if (AntiCheatAPI.getInstance().getMasterConfig().getCheckChat() && checkChat.isCheat()) {
        AntiCheatAPI.getInstance().addRecord(player, checkChat.getCheatType());
        player.sendMessage(TextFormat.RED + "You chat faster than predetermined value.");
        event.setCancelled();
    }
    if (AntiCheatAPI.getInstance().getMasterConfig().getCheckChatWord() && checkWords.isCheat()) {
        event.setMessage(checkWords.ChangeMessage());
    }
}
 
开发者ID:WetABQ,项目名称:Nukkit-AntiCheat,代码行数:16,代码来源:EventListener.java

示例2: teamChat

import cn.nukkit.event.player.PlayerChatEvent; //导入方法依赖的package包/类
private void teamChat(PlayerChatEvent event, String message) {
    Player player = event.getPlayer();
    String playerUUID = player.getName();
    // Is team chat on for this player
    // Find out if this player is in a team (should be if team chat is on)
    // TODO: remove when player resets or leaves team
    if ((plugin.getTManager().getPlayerMembers(player.getName()).isEmpty()) == false) {
        ArrayList<String> teams = plugin.getTManager().getPlayerMembers(player.getName());
        // Tell only the team members if they are online
        boolean online = false;
        for (String teamMembers : teams) {
            Player teamPlayer = plugin.getServer().getPlayer(teamMembers);
            if (teamPlayer != null) {
                teamPlayer.sendMessage(plugin.getPrefix() + message);
                if (!teamMembers.equals(playerUUID)) {
                    online = true;
                }
            }
        }
        // todo spy function
        if (!online) {
            player.sendMessage(plugin.getPrefix() + TextFormat.RED + plugin.getLocale(player).teamChatNoTeamAround);
            player.sendMessage(plugin.getPrefix() + TextFormat.RED + plugin.getLocale(player).teamChatStatusOff);
            teamChatUsers.remove(player);
        }
    } else {
        player.sendMessage(plugin.getPrefix() + TextFormat.RED + plugin.getLocale(player).teamChatNoTeamAround);
        player.sendMessage(plugin.getPrefix() + TextFormat.RED + plugin.getLocale(player).teamChatStatusOff);
        // Not in a team any more so delete
        teamChatUsers.remove(player);
    }
}
 
开发者ID:TheSolidCrafter,项目名称:ASkyBlock-Nukkit,代码行数:33,代码来源:ChatHandler.java


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