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