cn.nukkit.event.player.PlayerChatEvent Java Examples
The following examples show how to use
cn.nukkit.event.player.PlayerChatEvent.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: WorldEditListener.java From FastAsyncWorldedit with GNU General Public License v3.0 | 6 votes |
@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); } } } }
Example #2
Source File: ChatListener.java From Plan with GNU Lesser General Public License v3.0 | 5 votes |
@EventHandler(priority = EventPriority.MONITOR) public void onChat(PlayerChatEvent event) { if (event.isCancelled()) { return; } try { actOnChatEvent(event); } catch (Exception e) { errorLogger.log(L.ERROR, e, ErrorContext.builder().related(event).build()); } }
Example #3
Source File: ChatListener.java From Plan with GNU Lesser General Public License v3.0 | 5 votes |
private void actOnChatEvent(PlayerChatEvent event) { long time = System.currentTimeMillis(); Player player = event.getPlayer(); UUID uuid = player.getUniqueId(); String displayName = player.getDisplayName(); dbSystem.getDatabase().executeTransaction(new NicknameStoreTransaction( uuid, new Nickname(displayName, time, serverInfo.getServerUUID()), (playerUUID, name) -> nicknameCache.getDisplayName(playerUUID).map(name::equals).orElse(false) )); }
Example #4
Source File: SudoCommand.java From EssentialsNK with GNU General Public License v3.0 | 5 votes |
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 + Language.translate("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(Language.translate("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(Language.translate("commands.sudo.command", player.getDisplayName())); api.getServer().dispatchCommand(player, msg); } return true; }