本文整理汇总了Java中cn.nukkit.event.player.PlayerChatEvent类的典型用法代码示例。如果您正苦于以下问题:Java PlayerChatEvent类的具体用法?Java PlayerChatEvent怎么用?Java PlayerChatEvent使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
PlayerChatEvent类属于cn.nukkit.event.player包,在下文中一共展示了PlayerChatEvent类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: onChat
import cn.nukkit.event.player.PlayerChatEvent; //导入依赖的package包/类
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onChat(final PlayerChatEvent event) {
// Substitute variable - thread safe
String level = "";
if (playerLevels.containsKey(event.getPlayer())) {
level = playerLevels.get(event.getPlayer());
}
String format = event.getFormat().replace("{ISLAND_LEVEL}", level);
event.setFormat(format);
if (Settings.teamChat && teamChatUsers.containsKey(event.getPlayer())) {
// Cancel the event
event.setCancelled(true);
// Queue the sync task because you cannot use HashMaps asynchronously. Delaying to the next tick
// won't be a major issue for synch events either.
Server.getInstance().getScheduler().scheduleTask(plugin, () -> {
teamChat(event, event.getMessage());
});
}
}
开发者ID:TheSolidCrafter,项目名称:ASkyBlock-Nukkit,代码行数:20,代码来源:ChatHandler.java
示例2: onPlayerChat
import cn.nukkit.event.player.PlayerChatEvent; //导入依赖的package包/类
@EventHandler(ignoreCancelled = true,priority = EventPriority.LOWEST)
public void onPlayerChat(PlayerChatEvent event) {
String message = event.getMessage();
if (message.charAt(0) == '.') {
String[] split = event.getMessage().split(" ");
if (split.length > 0) {
split[0] = split[0].substring(1).replace('.', '/');
CommandManager cmdMan = WorldEdit.getInstance().getPlatformManager().getCommandManager();
split = cmdMan.commandDetection(split);
CommandEvent cmdEvent = new CommandEvent(plugin.wrapCommandSender(event.getPlayer()), Joiner.on(" ").join(Arrays.asList(split)));
if (cmdMan.getDispatcher().contains(split[0])) {
WorldEdit.getInstance().getEventBus().post(cmdEvent);
event.setCancelled(true);
}
}
}
}
开发者ID:boy0001,项目名称:FastAsyncWorldedit,代码行数:18,代码来源:WorldEditListener.java
示例3: onChat
import cn.nukkit.event.player.PlayerChatEvent; //导入依赖的package包/类
@EventHandler
public void onChat(PlayerChatEvent event) {
StringBuilder mes = new StringBuilder();
mes.append("`" + event.getPlayer().getName() + "` : " + event.getMessage());
this.sendPacket(mes.toString());
}
开发者ID:angelless,项目名称:ServerBot,代码行数:9,代码来源:Main.java
示例4: 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
示例5: 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
示例6: onChat
import cn.nukkit.event.player.PlayerChatEvent; //导入依赖的package包/类
@EventHandler
public void onChat(PlayerChatEvent event){
if(!this.manager.isAuthenticated(event.getPlayer())){
event.setCancelled();
this.sendLoginMessage(event.getPlayer());
}
}
开发者ID:onebone,项目名称:GateKeeper,代码行数:8,代码来源:GateKeeper.java
示例7: execute
import cn.nukkit.event.player.PlayerChatEvent; //导入依赖的package包/类
public boolean execute(CommandSender sender, String label, String[] args) {
if (!this.testPermission(sender)) {
return false;
}
if (args.length < 2) {
this.sendUsage(sender);
return false;
}
Player player = api.getServer().getPlayer(args[0]);
if (player == null) {
sender.sendMessage(TextFormat.RED + lang.translateString("commands.generic.player.notfound", args[0]));
return false;
}
String msg = String.join(" ", Arrays.copyOfRange(args, 1, args.length));
if (msg.length() > 1 && msg.substring(0, 2).equals("c:")) {
sender.sendMessage(lang.translateString("commands.sudo.message", player.getDisplayName()));
PlayerChatEvent event = new PlayerChatEvent(player, msg.substring(2));
api.getServer().getPluginManager().callEvent(event);
if (!event.isCancelled()) {
api.getServer().broadcastMessage(api.getServer().getLanguage().translateString(event.getFormat(), new String[]{event.getPlayer().getDisplayName(), event.getMessage()}), event.getRecipients());
}
} else {
sender.sendMessage(lang.translateString("commands.sudo.command", player.getDisplayName()));
api.getServer().dispatchCommand(player, msg);
}
return true;
}
开发者ID:yescallop,项目名称:EssentialsNK,代码行数:28,代码来源:SudoCommand.java
示例8: chat
import cn.nukkit.event.player.PlayerChatEvent; //导入依赖的package包/类
@Override
public void chat(String message) {
String msg = message = nukkit.getRemoveFormat() ? TextFormat.clean(message) : message;
PlayerChatEvent chatEvent = new PlayerChatEvent(toNukkit(this), msg);
nukkit.getServer().getPluginManager().callEvent(chatEvent);
if (!chatEvent.isCancelled()) {
nukkit.getServer().broadcastMessage(
nukkit.getServer().getLanguage().translateString(chatEvent.getFormat(),
new String[] { chatEvent.getPlayer().getDisplayName(), chatEvent.getMessage() }),
chatEvent.getRecipients());
}
}
开发者ID:rutgerkok,项目名称:Pokkit,代码行数:13,代码来源:PokkitPlayer.java
示例9: onChat
import cn.nukkit.event.player.PlayerChatEvent; //导入依赖的package包/类
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
public void onChat(PlayerChatEvent event) {
PlotPlayer plotPlayer = NukkitUtil.getPlayer(event.getPlayer());
Location location = plotPlayer.getLocation();
PlotArea area = location.getPlotArea();
if (area == null || (area.PLOT_CHAT == plotPlayer.getAttribute("chat"))) {
return;
}
Plot plot = area.getPlot(location);
if (plot == null) {
return;
}
event.setCancelled(true);
String message = event.getMessage();
String format = C.PLOT_CHAT_FORMAT.s();
String sender = event.getPlayer().getDisplayName();
PlotId id = plot.getId();
Set<CommandSender> recipients = event.getRecipients();
recipients.clear();
for (Entry<String, PlotPlayer> entry : UUIDHandler.getPlayers().entrySet()) {
PlotPlayer pp = entry.getValue();
if (pp.getAttribute("chatspy")) {
String spy = event.getFormat();
spy = String.format(spy, sender, message);
pp.sendMessage(spy);
} else {
Plot current = pp.getCurrentPlot();
if (current != null && current.getBasePlot(false).equals(plot)) {
recipients.add(((NukkitPlayer) pp).player);
}
}
}
String partial = C.color(format.replace("%plot_id%", id.x + ";" + id.y).replace("%sender%", sender));
String full = partial.replace("%msg%", message);
for (CommandSender receiver : recipients) {
receiver.sendMessage(full);
}
}
开发者ID:IntellectualSites,项目名称:PlotSquared,代码行数:39,代码来源:PlayerEvents.java
示例10: onPlayerChat
import cn.nukkit.event.player.PlayerChatEvent; //导入依赖的package包/类
@EventHandler
public void onPlayerChat(PlayerChatEvent event) {
event.setMessage(PluginUtils.colorize(event.getMessage()));
}
开发者ID:Darkyoooooo,项目名称:basiscommands,代码行数:5,代码来源:PluginListener.java
注:本文中的cn.nukkit.event.player.PlayerChatEvent类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论