private void Scalae(String[] components, PlayerChatEvent ev) { boolean ow = IsForceful(components, ev); Material _cp = null; Location location = ev.getPlayer().getTargetBlock(null, 500).getLocation(); int x = location.getBlockX(); int y = location.getBlockY(); int z = location.getBlockZ(); for (int scale = 0; scale <= this.size; scale++) { write_block(ow, x - 1, y, z - 1, _cp); write_block(ow, x - 1, y + 1, z, _cp); write_block(ow, x - 1, y + 2, z + 1, _cp); write_block(ow, x, y + 3, z + 1, _cp); write_block(ow, x + 1, y + 4, z + 1, _cp); write_block(ow, x + 1, y + 5, z, _cp); write_block(ow, x + 1, y + 6, z - 1, _cp); write_block(ow, x, y + 7, z - 1, _cp); for (int h = 0; h < 8; h++) { write_block(ow, x, y++, z, _cp); } } if (IsMotion(components, ev)) ev.getPlayer() .teleport( location .toVector() .add(new Vector(0, (this.size + 1) * 8, 0)) .toLocation(ev.getPlayer().getWorld())); }
@EventHandler public void onPlayerChat(PlayerChatEvent event) { Player player = event.getPlayer(); String newFormat = plugin.formatMessage(player); String.format(newFormat, event.getPlayer(), event.getMessage()); event.setFormat(newFormat); }
@EventHandler() public void onChat(PlayerChatEvent e) { if (PConfManager.getPVal(e.getPlayer(), "ignoredby") == null) return; Set<Player> recpts = e.getRecipients(); ArrayList<String> ignores = (ArrayList<String>) PConfManager.getPValStringList(e.getPlayer(), "ignoredby"); Set<Player> ignore = new HashSet<Player>(); for (Player p : recpts) for (String ignoree : ignores) if (p.getName().equalsIgnoreCase(ignoree.toLowerCase())) ignore.add(p); e.getRecipients().removeAll(ignore); }
/** On player chat, if the server is set to prefix the chat or not. */ @Override public void onPlayerChat(PlayerChatEvent event) { if (event.isCancelled()) { return; } /** * Check whether the Server is set to prefix the chat with the World name. If not we do nothing, * if so we need to check if the World has an Alias. */ if (this.configuration.getBoolean("prefix", false)) { /** Grab the name of the World the player is in. */ String world = event.getPlayer().getWorld().getName(); /** Setup a String called 'prefix' */ String prefix; /** * Check whether the Alias for the world is not empty and is longer than 0 Letters. If so we * apply it to the 'prefix' String. */ if (this.plugin.MVWorlds.containsKey(world) && this.plugin.MVWorlds.get(world).getAlias() != "" && this.plugin.MVWorlds.get(world).getAlias().length() > 0) { prefix = this.plugin.MVWorlds.get(world).getAlias(); } /** * If the World doesn't have a prefix we'll just sent the full World name, can get messy :). */ else { prefix = world; } /** Format the output of the String to add in the Prefix before the rest of the message. */ String format = event.getFormat(); /** Set the formatting. */ event.setFormat("[" + prefix + "]" + format); } }
@EventHandler public void HeMan(PlayerChatEvent e) { if (e.isCancelled()) return; if (!e.getMessage().matches("(?i)by the power of gr[a|e]yskull!?")) return; Player p = e.getPlayer(); if (!plugin.isAuthorized(p, "rcmds.heman")) return; ItemStack is = p.getItemInHand(); if (is.getType() != Material.DIAMOND_SWORD) return; if (is.getEnchantments().isEmpty()) return; e.setCancelled(true); p.getWorld().strikeLightningEffect(p.getLocation()); Matcher m = Pattern.compile("(?i)by the power of gr[a|e]yskull!?").matcher(e.getMessage()); StringBuilder sb = new StringBuilder(); int last = 0; while (m.find()) { sb.append(e.getMessage().substring(last, m.start())); sb.append(m.group(0).toUpperCase()); last = m.end(); } sb.append(e.getMessage().substring(last)); plugin .getServer() .broadcastMessage( e.getFormat().replaceAll("(?i)by the power of gr[a|e]yskull!?", sb.toString())); e.setFormat(""); List<PotionEffect> effects = new ArrayList<PotionEffect>(); effects.add(new PotionEffect(PotionEffectType.INCREASE_DAMAGE, 1200, 2)); effects.add(new PotionEffect(PotionEffectType.REGENERATION, 1200, 2)); effects.add(new PotionEffect(PotionEffectType.DAMAGE_RESISTANCE, 1200, 2)); effects.add(new PotionEffect(PotionEffectType.SPEED, 1200, 2)); p.addPotionEffects(effects); }
@Override public void onPlayerChat(PlayerChatEvent event) { Player player = event.getPlayer(); if (event.getMessage().toLowerCase().contains("ready")) { new ReadyJob(player).run(); } }
public boolean chat(String s) { if (!this.player.dead) { if (s.startsWith("/")) { this.handleCommand(s); return true; } else { Player player = getPlayer(); PlayerChatEvent event = new PlayerChatEvent(player, s); server.getPluginManager().callEvent(event); if (event.isCancelled()) { return true; } s = String.format( event.getFormat(), event.getPlayer().getDisplayName(), event.getMessage()); a.info(s); for (Player recipient : event.getRecipients()) { recipient.sendMessage(s); } } } return false; // CraftBukkit end }
@Override public void onPlayerChat(PlayerChatEvent event) { if (event.isCancelled()) return; Player player = event.getPlayer(); String message = event.getMessage(); if (message == null) return; event.setFormat(ichat.API.parseChat(player, message, ichat.chatFormat)); }
@EventHandler(priority = EventPriority.NORMAL) public void onPlayerChat(PlayerChatEvent event) { if (!event.isCancelled()) { Player p = event.getPlayer(); String fulltag = plugin.getClansConfig().getTagFormat(); String format = plugin.getClansConfig().getMessageFormat(); event.setFormat(insertData(format, fulltag, p.getDisplayName())); } }
@EventHandler public void syncChatTrigger(final PlayerChatEvent event) { if (event.isCancelled()) return; // Return if "Use asynchronous event" is true in config file if (Settings.ChatAsynchronous()) return; Boolean cancelled = process(event.getPlayer(), event.getMessage()); event.setCancelled(cancelled); }
@Override public void onPlayerCommand(PlayerChatEvent event) { String[] split = event.getMessage().split(" "); Player player = event.getPlayer(); String command = split[0]; if ((!event.isCancelled()) && command.equalsIgnoreCase("/" + DailyBibleVerse.command)) { plugin.displayVOTD(player); event.setCancelled(true); } }
@Override public void onPlayerCommand(PlayerChatEvent event) { String[] split = event.getMessage().split(" "); Player player = event.getPlayer(); if (split[0].equalsIgnoreCase(debugCommand)) { addDebugee(player); event.setCancelled(true); } else if (split[0].equalsIgnoreCase(undebugCommand)) { removeDebugee(player); event.setCancelled(true); } }
@EventHandler(priority = EventPriority.NORMAL) public void onPlayerChat(PlayerChatEvent event) { if (event.isCancelled()) return; Player me = event.getPlayer(); VPlayer vme = VPlayers.i.get(me); if (Conf.nameColorize == false) return; if (!vme.isVampire()) return; me.setDisplayName("" + Conf.nameColor + ChatColor.stripColor(me.getDisplayName())); }
public void onPlayerChat(PlayerChatEvent event) { String eventplayer = event.getPlayer().getName(); if (admin.freeze.contains(eventplayer)) { // player in hashmap chats String msg = event.getMessage(); admin.tellAdmin(ChatColor.DARK_AQUA + "Blocked message by " + eventplayer + ": " + msg); Random rand = new Random(); int number; number = 1 + rand.nextInt(10); if (number == 1) { event.setMessage("Lolz."); } else if (number == 2) { event.setMessage("This is funny!"); } else if (number == 3) { event.setMessage("I wish i was a cool server-owner! :3"); } else if (number == 4) { event.setMessage("Turtles are round"); } else if (number == 5) { event.setMessage("I'm a kitty! purr :3"); } else if (number == 6) { event.setMessage("This place is great!"); } else if (number == 7) { event.setMessage("Hurr Durr"); } else if (number == 8) { event.setMessage("How did i get here?"); } else if (number == 9) { event.setMessage("My friends are lions"); } else if (number == 10) { event.setMessage("<('_'<) (>'_')>"); } else { // error lolz event.getPlayer().sendMessage("error lolz."); admin.logInfo("ZOMG THERE WAS A JAVA ERROR! ERROR: failed to generate random number(lolz)"); } } else { // nothing. } }
@Override public void onPlayerChat(final PlayerChatEvent event) { if (isAborted(event)) { return; } /** * This file should handle detection of the local chat features... if local chat is enabled, we * need to handle it here */ final User user = ess.getUser(event.getPlayer()); final String chatType = getChatType(event.getMessage()); long radius = ess.getSettings().getChatRadius(); if (radius < 1) { return; } radius *= radius; try { if (event.getMessage().length() > 0 && chatType.length() > 0) { StringBuilder permission = new StringBuilder(); permission.append("essentials.chat.").append(chatType); StringBuilder command = new StringBuilder(); command.append("chat-").append(chatType); StringBuilder format = new StringBuilder(); format.append(chatType).append("Format"); StringBuilder errorMsg = new StringBuilder(); errorMsg .append("notAllowedTo") .append(chatType.substring(0, 1).toUpperCase()) .append(chatType.substring(1)); if (user.isAuthorized(permission.toString())) { charge(user, command.toString()); event.setMessage(event.getMessage().substring(1)); event.setFormat(Util.format(format.toString(), event.getFormat())); return; } user.sendMessage(Util.i18n(errorMsg.toString())); event.setCancelled(true); return; } } catch (ChargeException ex) { ess.showError(user, ex, "Shout"); event.setCancelled(true); return; } sendLocalChat(user, radius, event); }
public void onPlayerChat(PlayerChatEvent event) { Player p = event.getPlayer(); Builder fb = plugin.getBattlefieldManager().getBuilder(p); if (fb == null) return; if (fb.getTool() != null) { Tool tool = fb.getTool(); if (tool == null) return; if (tool.isAwaitingText()) { tool.retrieveText(event.getMessage()); event.setCancelled(true); } } }
private void Murus(String[] components, PlayerChatEvent ev) { boolean overwrite = IsForceful(components, ev); Material component = GetMaterial(components[(this.n + 1)]); int length = 5 + 15 * this.size / 2; Vector vector = ev.getPlayer().getEyeLocation().getDirection().normalize(); Location location; if (IsFlying(components, ev)) location = ev.getPlayer().getTargetBlock(null, 10 + 5 * this.size).getLocation(); else location = ev.getPlayer().getTargetBlock(null, 500).getLocation(); int xorg = location.getBlockX(); int yorg = location.getBlockY(); int zorg = location.getBlockZ(); double vx = vector.getX(); double vz = vector.getZ(); double ox = -vz; double oz = vx; for (int i = -length / 2; i <= length / 2 + 1; i++) { location.setX(xorg + i * ox); location.setZ(zorg + i * oz); for (int y = Math.max(yorg, 1); y <= Math.min(yorg + length / 2, 120); y++) { location.setY(y); Block block = location.getBlock(); Material type = block.getType(); if ((overwrite) && (type != Material.BEDROCK)) { block.setType(component); } else { if (type != Material.AIR) continue; block.setType(component); } } } if (IsMotion(components, ev)) ev.getPlayer() .teleport( new Vector(xorg, yorg + length / 2 + 1, zorg).toLocation(ev.getPlayer().getWorld())); }
@EventHandler(priority = EventPriority.LOW) public void onPlayerChat(PlayerChatEvent event) { if (event.isCancelled()) return; if (AFKUtils.isAfk(event.getPlayer())) { AFKUtils.unsetAfk(event.getPlayer()); plugin.getServer().broadcastMessage(event.getPlayer().getName() + " is no longer AFK."); } if (PConfManager.getPValBoolean(event.getPlayer(), "muted")) { if (PConfManager.getPVal(event.getPlayer(), "mutetime") != null && !RUtils.isTimeStampValid(event.getPlayer(), "mutetime")) PConfManager.setPValBoolean(event.getPlayer(), false, "muted"); event.setFormat(""); event.setCancelled(true); event.getPlayer().sendMessage(ChatColor.RED + "You are muted."); plugin.log.info( "[RoyalCommands] " + event.getPlayer().getName() + " tried to speak, but has been muted."); } }
private void ImpleteAquas(String[] components, PlayerChatEvent ev) { int radius = 6 + 4 * this.size; Block block = ev.getPlayer().getTargetBlock(null, 500); Location origin = block.getLocation(); int xorg = (int) origin.getX(); int yorg = (int) origin.getY(); int zorg = (int) origin.getZ(); if (Math.abs(yorg - 63) < radius) { int y = 63; for (int x = xorg - radius - 1; x <= xorg + radius + 1; x++) { for (int z = zorg - radius - 1; z <= zorg + radius + 1; z++) { int dx = x - xorg; int dz = z - zorg; if ((int) Math.sqrt(dx * dx + dz * dz) > radius) continue; Block targetblock = ev.getPlayer().getWorld().getBlockAt(x, y, z); Material type = targetblock.getType(); if ((type != Material.AIR) && (type != Material.WATER) && (type != Material.STATIONARY_WATER)) continue; targetblock.setType(Material.STATIONARY_WATER); } } } }
@SuppressWarnings("static-access") public void onPlayerChat(PlayerChatEvent event) { // plugin.LCGui.initializeGUIBasic(sp); if (!plugin.EnableSkillMastery) return; Player p = event.getPlayer(); String str = event.getFormat(); for (Plugin plug : plugin.LevelNames.keySet()) { if (!plugin.Permissions.hasLevel(p, plug)) continue; if (!(plugin.LevelFunctions.getLevel(p, plug) >= plugin.LevelCap)) continue; str = plugin.c1 + "[" + plugin.LevelIndexes.get(plug) + "]WHITE" + str; } event.setFormat(plugin.Tools.format(str)); }
@Override public void onPlayerChat(final PlayerChatEvent event) { final User user = ess.getUser(event.getPlayer()); if (user.isMuted()) { event.setCancelled(true); user.sendMessage(Util.i18n("playerMuted")); LOGGER.info(Util.format("mutedUserSpeaks", user.getName())); } final Iterator<Player> it = event.getRecipients().iterator(); while (it.hasNext()) { final User u = ess.getUser(it.next()); if (u.isIgnoredPlayer(user.getName())) { it.remove(); } } user.updateActivity(true); if (ess.getSettings().changeDisplayName()) { user.setDisplayName(user.getNick()); } }
@EventHandler(event = PlayerChatEvent.class) public void onPlayerChat(PlayerChatEvent event) { if (event.isCancelled()) { return; } Matcher matcher = cuipattern.matcher(event.getMessage()); if (matcher.find()) { String type = matcher.group(1); String args = matcher.group(2); if (type.equals("v")) { try { plugin.getSession(event.getPlayer()).setCUIVersion(Integer.parseInt(args)); event.setCancelled(true); } catch (NumberFormatException e) { } } } }
public void onPlayerChat(PlayerChatEvent event) { Player player = event.getPlayer(); PlayerProfile PP = Users.getProfile(player); String x = ChatColor.GREEN + "(" + ChatColor.WHITE + player.getName() + ChatColor.GREEN + ") "; String y = ChatColor.AQUA + "{" + ChatColor.WHITE + player.getName() + ChatColor.AQUA + "} "; if (Config.getInstance().isPartyToggled(player.getName())) { event.setCancelled(true); log.log( Level.INFO, "[P](" + PP.getParty() + ")" + "<" + player.getName() + "> " + event.getMessage()); for (Player herp : plugin.getServer().getOnlinePlayers()) { if (Users.getProfile(herp).inParty()) { if (Party.getInstance().inSameParty(herp, player)) { herp.sendMessage(x + event.getMessage()); } } } return; } if ((player.isOp() || mcPermissions.getInstance().adminChat(player)) && Config.getInstance().isAdminToggled(player.getName())) { log.log(Level.INFO, "[A]" + "<" + player.getName() + "> " + event.getMessage()); event.setCancelled(true); for (Player herp : plugin.getServer().getOnlinePlayers()) { if ((herp.isOp() || mcPermissions.getInstance().adminChat(herp))) { herp.sendMessage(y + event.getMessage()); } } return; } /* * Remove from normal chat if toggled for(Player z : event.getRecipients()){ if(Users.getProfile(z.getName()).getPartyChatOnlyToggle() == true) event.getRecipients().remove(z); } */ }
public void onPlayerChat(PlayerChatEvent event) { for (myPlayer player : parent.universe.players.values()) { if (player.player == event.getPlayer()) { if (player.target != null) { // System.out.println("npcx : player chat event ("+ player.player.getName()+")"); player.player.sendMessage( "You say to " + player.target.getName() + ", '" + event.getMessage() + "'"); if (player.target.parent != null) { // this is not a temporary spawn // does it have a category set? if (player.target.parent.category != null) { // check what type of category it is if (player.target.parent.category.matches("merchant")) { // merchant player.target.parent.onPlayerChat(player, event.getMessage(), "merchant"); } else { // normal chat event / unknown category player.target.parent.onPlayerChat(player, event.getMessage(), ""); } } else { // normal chat event player.target.parent.onPlayerChat(player, event.getMessage(), ""); } } else { player.player.sendMessage("You cannot talk to temporary spawns"); } event.setCancelled(true); } } } }
public void CastSpell(String[] components, PlayerChatEvent ev) { this.config = Vicincantatio.config; this.components = components; this.ev = ev; this.n = 0; this.size = 2; this.book_augment = false; String spellName = ""; Spell toCast = null; Material material = null; Map augments = new HashMap(); for (int i = 0; i < components.length; i++) { components[i] = components[i].toLowerCase(); } for (int i = 0; i < components.length; i++) { if ((spellName.equals("")) || (spellName.equals("bulla"))) { String foundSpell = ""; if (Spell.GetSpell(components[i]) != null) foundSpell = components[i]; if (i < components.length - 1) { String twoWords = components[i] + " " + components[(i + 1)]; if (Spell.GetSpell(twoWords) != null) { foundSpell = twoWords; i++; } } if (!foundSpell.equals("")) { if (spellName.equals("bulla")) augments.put("bubble", Boolean.valueOf(true)); spellName = foundSpell; toCast = Spell.GetSpell(spellName); Vicincantatio.log.info("Spell name: " + spellName); continue; } } if (this.size == 2) { if (Bukkit.getServer().getPluginManager().isPluginEnabled("PermissionsEx")) { PermissionManager permissions = PermissionsEx.getPermissionManager(); if ((components[i].equalsIgnoreCase("ultima")) && (Vicincantatio.config.getBoolean("world_maiming" + "_enabled", true))) { if (permissions.has(ev.getPlayer(), "ultima.allow")) { this.size = 9; } else { Vicincantatio.log.info("Ultima size not allowed!"); toCast = null; } } else if ((components[i].equalsIgnoreCase("supera")) && (Vicincantatio.config.getBoolean("world_maiming" + "_enabled", true))) { if (permissions.has(ev.getPlayer(), "supera.allow")) { this.size = 6; } else { Vicincantatio.log.info("Supera size not allowed!"); toCast = null; } } else if (components[i].equalsIgnoreCase("magna")) this.size = 4; else if (components[i].equalsIgnoreCase("parva")) this.size = 1; else if (components[i].equalsIgnoreCase("infera")) { this.size = 0; } if (this.size != 2) { continue; } } else { if ((components[i].equalsIgnoreCase("ultima")) && (Vicincantatio.config.getBoolean("world_maiming" + "_enabled", true))) this.size = 9; else if ((components[i].equalsIgnoreCase("supera")) && (Vicincantatio.config.getBoolean("world_maiming" + "_enabled", true))) this.size = 6; else if (components[i].equalsIgnoreCase("magna")) this.size = 4; else if (components[i].equalsIgnoreCase("parva")) this.size = 1; else if (components[i].equalsIgnoreCase("infera")) { this.size = 0; } if (this.size != 2) { continue; } } } if (material == null) { if (Bukkit.getServer().getPluginManager().isPluginEnabled("PermissionsEx")) { PermissionManager permissions = PermissionsEx.getPermissionManager(); if (listOfMaterials.containsKey(components[i])) { if (permissions.has(ev.getPlayer(), components[i] + ".allow")) { material = (Material) listOfMaterials.get(components[i]); Vicincantatio.log.info("Material: " + components[i]); continue; } Vicincantatio.log.info("Material not allowed."); ev.getPlayer().sendMessage("Sorry, you don't have the permissions for that material"); } } else if (listOfMaterials.containsKey(components[i])) { material = (Material) listOfMaterials.get(components[i]); Vicincantatio.log.info("Material: " + components[i]); continue; } } if ((components[i].equalsIgnoreCase("augere")) && (i + 1 < components.length)) { if (components[(i + 1)].equalsIgnoreCase("vi")) { augments.put("force", Boolean.valueOf(true)); } else if (components[(i + 1)].equalsIgnoreCase("volo")) { augments.put("flight", Boolean.valueOf(true)); } else if (components[(i + 1)].equalsIgnoreCase("motor")) { augments.put("motion", Boolean.valueOf(true)); } else if (components[(i + 1)].equalsIgnoreCase("silentium")) { augments.put("silence", Boolean.valueOf(true)); } else if (components[(i + 1)].equalsIgnoreCase("mora")) { Delay.delay(spellName, toCast, ev, material, this.size, augments); toCast = null; } } if (components[i].equalsIgnoreCase("bulla")) { augments.put("bubble", Boolean.valueOf(true)); } if (components[i].equalsIgnoreCase("libero")) { Delay.release(ev); } components[i].equalsIgnoreCase("praevenio"); } if (!spellName.equals("")) { boolean canCast = true; if (Vicincantatio.config.getBoolean(spellName + "_consumes_book", false)) { if (!PlayerSpendReagent(ev.getPlayer(), Material.BOOK, 1)) canCast = false; } if (Vicincantatio.config.getBoolean(spellName + "_book_augment", false)) { if (PlayerSpendReagent(ev.getPlayer(), Material.BOOK, 1)) { augments.put("book", Boolean.valueOf(true)); } } if ((toCast != null) && (canCast)) { if (Bukkit.getServer().getPluginManager().isPluginEnabled("PermissionsEx")) { PermissionManager permissions = PermissionsEx.getPermissionManager(); if (permissions.has(ev.getPlayer(), spellName + ".allow")) { toCast.CastSpell(ev, material, this.size, augments); } else { Vicincantatio.log.info("Spell not allowed by user."); ev.getPlayer().sendMessage("Sorry, you do not have permission to do that."); } } else { toCast.CastSpell(ev, material, this.size, augments); } } if (augments.containsKey("silence")) ev.setCancelled(true); } }
@Override public void onPlayerChat(PlayerChatEvent event) { if (ChatManager.handleMessage(event.getPlayer(), event.getMessage())) event.setCancelled(true); }
@EventHandler(priority = EventPriority.MONITOR) public void onPlayerChat(PlayerChatEvent event) { if (isLogging(event.getPlayer().getWorld(), Logging.CHAT)) consumer.queueChat(event.getPlayer().getName(), event.getMessage()); }
/*** * The main function which replaces chat with matched replacements. * @param e * @return */ @EventHandler(priority = EventPriority.LOWEST) public void replaceChat(PlayerChatEvent e) { if (e.isCancelled()) return; try { ScriptEnvironment env = new ScriptEnvironment(); { env.setCommandSender(e.getPlayer()); env.setServer(e.getPlayer().getServer()); } ArrayList<ReplacementPair> preparedEffects = new ArrayList<ReplacementPair>(); //holds all effects until all replacements done for (ReplacementPair rp : pairs) { StringBuffer sb = new StringBuffer(); Matcher m = rp.getRegex().matcher(e.getMessage()); if (!m.find()) continue; env.setMatcher(m); if (rp.playerWillVanish()) { //the player will vanish as a result of this, special handling int cutlen = CommandsEX.getConf().getInt("replacements.cutoff.length", 1); String cuttext = CommandsEX.getConf().getString("replacements.cutoff.indicator", "--*"); String rep = m.group().substring(0, cutlen).concat(cuttext); m.appendReplacement(sb, rep); e.setMessage(sb.toString()); //e.setCancelled(true); //e.getPlayer().chat(sb.toString()); //chat first rp.executeEffects(env); //then execute the replacement return; } //loop through with find/replace do { //use do while, due to the find() invocation above // test if it is all upper, and replace with all upper (if we have this set up in the regex itself - in config file) if (rp.getSameOutputCase() && allUpper && m.group().toUpperCase().equals(m.group())) { m.appendReplacement(sb, rp.executeString(env).toUpperCase()); } else { m.appendReplacement(sb, rp.executeString(env)); } } while (m.find()); m.appendTail(sb); if (!preparedEffects.contains(rp)) { preparedEffects.add(rp); } e.setMessage(sb.toString()); } //after all replacements are in: execute the effects if (!preparedEffects.isEmpty()) { //e.setCancelled(true); //e.getPlayer().chat(sb.toString()); //chat first env.setMatcher(null); for (ReplacementPair rp : preparedEffects){ rp.executeEffects(env); } } } catch (Exception ex){ LogHelper.logSevere("[CommandsEX] " + _("cmdOrChatreplacementFailed", "")); LogHelper.logDebug("Message: " + ex.getMessage() + ", cause: " + ex.getCause()); } }
@EventHandler public void playerChatEvent(PlayerChatEvent event) { Player player = event.getPlayer(); plugin.bot.sendMessage( plugin.getIRCChannel(), "[" + player.getName() + "] " + event.getMessage()); }
/** * Monitor PlayerChat events. * * @param event The event to watch */ @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) public void onPlayerChat(PlayerChatEvent event) { Player player = event.getPlayer(); PlayerProfile profile = Users.getProfile(player); if (profile == null) { return; } if (profile.getPartyChatMode()) { Party party = profile.getParty(); if (party == null) { player.sendMessage( "You're not in a party, type /p to leave party chat mode."); // TODO: Use mcLocale return; } String partyName = party.getName(); String playerName = player.getName(); McMMOPartyChatEvent chatEvent = new McMMOPartyChatEvent(playerName, partyName, event.getMessage()); plugin.getServer().getPluginManager().callEvent(chatEvent); if (chatEvent.isCancelled()) { return; } String prefix = ChatColor.GREEN + "(" + ChatColor.WHITE + playerName + ChatColor.GREEN + ") "; plugin .getLogger() .info("[P](" + partyName + ")" + "<" + playerName + "> " + chatEvent.getMessage()); for (Player member : party.getOnlineMembers()) { member.sendMessage(prefix + chatEvent.getMessage()); } event.setCancelled(true); } else if (profile.getAdminChatMode()) { String playerName = player.getName(); McMMOAdminChatEvent chatEvent = new McMMOAdminChatEvent(playerName, event.getMessage()); plugin.getServer().getPluginManager().callEvent(chatEvent); if (chatEvent.isCancelled()) { return; } String prefix = ChatColor.AQUA + "{" + ChatColor.WHITE + playerName + ChatColor.AQUA + "} "; plugin.getLogger().info("[A]<" + playerName + "> " + chatEvent.getMessage()); for (Player otherPlayer : plugin.getServer().getOnlinePlayers()) { if (Permissions.getInstance().adminChat(otherPlayer) || otherPlayer.isOp()) { otherPlayer.sendMessage(prefix + chatEvent.getMessage()); } } event.setCancelled(true); } }