@SubscribeEvent public void onClientChat(ClientChatReceivedEvent event) { String message = ( event.getMessage().getUnformattedText() ); if (message.contains(search.get()) && !message.startsWith(MC.getSession().getUsername() )) { String append; switch (mode.get().toUpperCase()) { case "REPLY": append = "/w "; break; case "CHAT": default: append = Strings.EMPTY; break; } getLocalPlayer().sendChatMessage(append + reply.get()); } }
@SubscribeEvent public void messageReceived(ClientChatReceivedEvent e) { // we got a chat message, let checks whether it's from HiddenOre String msg = e.getMessage().getUnformattedText(); Matcher matcher = hiddenOreRegex.matcher(msg); if (matcher.matches()) { // confirmed a HiddenOre message String item = matcher.group(2); // because I suck with regex if (item.endsWith(" nearby")) { item = item.substring(0, item.length() - " nearby".length()); } String amount = matcher.group(1); Biome biome = OreLogger.instance.mc.theWorld.getBiome(OreLogger.instance.mc.thePlayer.getPosition()); // send to aggregator hoManager.logBreak(cachedBlockPos.getY(), item, amount, biome, cachedItem); } }
/** * Fired when the IP message is picked up and * {@link Server#getServer()} returns {@link Server#NONE}, * meaning a server has been joined and the server is identified. * * @param server The server joined. */ public static void trueJoin(Server server) { if (AllChat.track) { // Set to false to avoid comodification AllChat.track = false; // Cycle through each tracked event and feed it // back to the server that was joined for (ClientChatReceivedEvent event : AllChat.tracked) server.onChat(event); // Clear the tracked messages. AllChat.tracked.clear(); } AllRender.removeSkins(); server.onJoin(); }
public static void onChat(ClientChatReceivedEvent event) { String message = event.message.getUnformattedText(); ChatTracker.checkAll(message); ChatTrigger.checkAll(message); if (message.matches(CoreHG.MSG_WELCOME)) StateHG.state = StateHG.WAIT; if (message.matches(CoreHG.MSG_VULNERABLE)) StateHG.state = StateHG.PLAY; if (message.startsWith("\00A7r\u00A7b" + Main.mc.thePlayer.getDisplayName())) { if (Vars.getInt("hg:kills") == -1) Vars.put("hg:kills", "" + 1); else Vars.put("hg:kills", "" + (Vars.getInt("hg:kills") + 1)); } }
public static void relatedChatEventHandler(ClientChatReceivedEvent event) { System.out.println("Passing chat event to server location parser"); // We know that the message isn't null String message = event.message.getUnformattedText(); /* * Let's check if the message is a whereami response via checking if it * starts with the correct string */ if (message.startsWith("You are currently on server")) { // Debug message output used here System.out.println("Processed user location"); // Cancel the event so the user doesn't see the response event.setCanceled(true); // Save the server detected setServer(message.split(" ")[5]); // Now, we will remove this status, because it's served the purpose // it was meant to ChatListener.currentStatus.remove(ChatStatus.WHEREAMI); } }
public static String getUnformattedText(ClientChatReceivedEvent event) { String msg = ""; try { Object component = null; switch (Autotip.MC_VERSION) { case V1_8: case V1_8_8: case V1_8_9: component = getField(ClientChatReceivedEvent.class, "message").get(event); break; case V1_9: case V1_9_4: case V1_10: case V1_10_2: case V1_11: case V1_11_2: component = getMethod(ClientChatReceivedEvent.class, "getMessage") .invoke(event); break; } // Original method name: getUnformattedText msg = (String) getMethod(component.getClass(), "func_150260_c").invoke(component); } catch (InvocationTargetException | IllegalAccessException e) { e.printStackTrace(); } return msg; }
@SubscribeEvent public void onChatReceive(ClientChatReceivedEvent event) { //IndexOutOfBoundException when it's a broadcast message.. this will fix it String username = !event.message.getUnformattedText().isEmpty() ? event.message.getSiblings().get(0).getUnformattedText().trim() : ""; if (RewiMod.mutedPlayers.getMuted().contains(username)) { event.setCanceled(true); } if(Minecraft.getMinecraft() != null && Minecraft.getMinecraft().getCurrentServerData() != null) { if (Minecraft.getMinecraft().getCurrentServerData().serverIP.endsWith("rewinside.tv")) { for (String badWord : RewiMod.badWords) { if (event.message.getUnformattedText().contains(badWord)) { if (!username.equals(Minecraft.getMinecraft().thePlayer.getName())) { Minecraft.getMinecraft().thePlayer.sendChatMessage("/chatreport " + username); break; } } } if (event.message.getUnformattedText().contains(RewiMod.CHATLOG_URL)) { try { Desktop.getDesktop().browse(new URI("https://rewinside.tv/wpbt/IssueAdd/1/?issueType=bug")); Toolkit.getDefaultToolkit().getSystemClipboard().setContents(new StringSelection(RewiMod.CHATLOG_URL + event.message.getUnformattedText().split("/")[3]), null); } catch (IOException | URISyntaxException e) { e.printStackTrace(); } } } } }
@SubscribeEvent public void onEvent(ClientChatReceivedEvent evt) { ITextComponent message = evt.getMessage(); String txt = message.getUnformattedText(); WolTestEnvironment.instance.getPacketDispatcher().sendToServer( new ClientChatReceivedMessage(txt)); }
@SubscribeEvent public void clientReceivedChat(ClientChatReceivedEvent e) { ChatComponentTranslation a = (ChatComponentTranslation)e.message; for(String disable : Util.CHAT_DISABLE_KEYS) { if(a.getKey().contains(disable)) { e.setCanceled(true); return; } } }
@SubscribeEvent public void onChatEvent(ClientChatReceivedEvent event) { if (Config.translateChat) if (!event.isCanceled()) try { String message = getFallback().containsTranslateKey(event.message.getUnformattedText()) ? StatCollector.translateToFallback(event.message.getUnformattedText()) :event.message.getUnformattedText(); event.message = new ChatComponentText(translateToLocal(message, "en")); } catch (Exception e) { e.printStackTrace(); } }
@SubscribeEvent public void clientChatReceived(ClientChatReceivedEvent e) { Iterator<Blocker> blocksIterator = blocks.iterator(); while (blocksIterator.hasNext()) { Blocker block = blocksIterator.next(); if (!block.accept(e.getMessage())) e.setCanceled(true); if (block.isDone()) blocksIterator.remove(); } }
public static void checkSplit(ClientChatReceivedEvent event) { if (Main.secondChat.shouldSplit(event) && !Server.getServer().equals(Server.CTF) && !Server.getServer().equals(Server.HS)) { Main.secondChat.printChatMessage(event.message); event.setCanceled(true); } }
/** * Re-adds link click events to any links in chat. Links * must start with <code>http://</code> to be added properly. * @param event The event to add links to. */ public static void addLinks(ClientChatReceivedEvent event) { if (!event.message.getUnformattedText().matches(".*" + RE_URL + ".*")) return; Matcher urlMatcher = URL_PATTERN.matcher(event.message.getUnformattedText()); while (urlMatcher.find()) { event.message.getChatStyle().setChatClickEvent( new ClickEvent(ClickEvent.Action.OPEN_URL, urlMatcher.group())); } }
public static void onChat(ClientChatReceivedEvent event) { String message = event.message.getUnformattedText(); handleAll(event); if (event.isCanceled()) return; switch (MessageType.getType(message)) { case ALERT: filterAlerts(event); case STATS: filterAlerts(event); event.setCanceled(ConfigCTFChat.chatHistory); case NONE: // The chat section has a number of lines depending on the state. // If we have more than that number, remove the first. if (chatBlock.size() == StateCTF.getState().chatLines()) { chatBlock.remove(0); } // Does our new chat equal the old? if (!oldChat.equals(chatBlock)) { // Does it contain our message? if (!oldChat.contains(message)) { // It's a new message! handleMessages(event); oldChat.add(message); } else { // Set it canceled based on config settings. event.setCanceled(ConfigCTFChat.chatHistory); } } // Index the chat message. chatBlock.add(message); } }
/** * Handles repeated messages, e.g. players talking, * class selected, kills, and more. Does NOT include * stats or team info. * @param event The chat event to handle. */ public static void handleMessages(ClientChatReceivedEvent event) { String message = event.message.getUnformattedText(); ChatTracker.checkAll(message); ChatTrigger.checkAll(message); // TODO: Move to Var system. if (message.matches(msgFreeDay)) { InfoCTF.freeDay = true; } if (message.matches(reHeadshot)) { StatsCTF.headshots++; Medal.add("headshot"); } if (Main.secondChat.shouldSplit(event)) { Main.secondChat.printChatMessage(event.message); event.setCanceled(true); } // Medic calling. if (message.matches(reMedic)) { if (StateCTF.getState() == StateCTF.PLAY) { for (String string : ConfigCTFChat.medicClasses) { if (KitCTF.getKit(Main.mc.thePlayer).toString().toLowerCase().equals(string.toLowerCase()) || InfoCTF.chosenClass.toLowerCase().equals(string.toLowerCase())) { String formatted = event.message.getUnformattedText().replaceAll("\u00A7(.)", "\u00A7$1\u00A7l"); event.message = new ChatComponentText(formatted); } } } } }
/** * Handles all in-game notifications, such as the * flag being stolen. * @param event The chat event to handle. */ public static void filterAlerts(ClientChatReceivedEvent event) { String message = event.message.getUnformattedText(); // Sometimes messages are repeated: this prevents the repetition of alerts. if (message.equals(lastAlert)) return; ChatTracker.checkAll(message); ChatTrigger.checkAll(message); // Recovered flags. if (message.matches(reAction) && message.replaceAll(reAction, "$2").equals("recovered")) { if (message.replaceAll(reAction, "$1").equals(Main.mc.thePlayer.getDisplayName())) { StatsCTF.recovers++; } // Captured flag. } else if (message.matches(reAction) && message.replaceAll(reAction, "$2").equals("captured")) { // Game check to avoid messy notifications on game winning cap. if (StateCTF.getState() == StateCTF.PLAY) { if (message.replaceAll(reAction, "$1").equals(Main.mc.thePlayer.getDisplayName())) { Medal.add(new Medal("flagcap")); } } } if (message.matches(reAction) || message.matches(reGameOver) || message.matches(reStreak) || message.matches(reCompass)) { lastAlert = message; //event.setCanceled(true); } }
public static void handleAll(ClientChatReceivedEvent event) { // Removal of messages that appear in split chat. for (Object chatLine : Main.secondChat.getMessages()) { // The chat message in the second chat. String oldMessage = ((ChatLine)chatLine).func_151461_a().getUnformattedText(); if (oldMessage.equals(event.message.getUnformattedText())) { event.setCanceled(true); } } }
public static void onChat(ClientChatReceivedEvent event) { String message = event.message.getUnformattedText(); ChatTrigger.checkAll(message); ChatTracker.checkAll(message); if (message.matches(CoreSmash.MSG_GAME_OVER)) StateSmash.state = StateSmash.POST; }
/** * Consults the list of messages to ignore and sets the event to cancelled if it finds a match. * @param event The event to check. */ public void check(ClientChatReceivedEvent event) { for (String string : this.ignore) { if (event.message.getUnformattedText().equals(string) || event.message.getUnformattedText().matches(string)) { event.setCanceled(true); Main.l("Auto-removed \"%s\" via IgnoreResult \"%s\"", event.message.getUnformattedText(), this); this.ignore.remove(string); return; } } }
/** * Cycles through every IgnoreResult and runs check(event). * @param event The event to check. */ public static void checkAll(ClientChatReceivedEvent event) { Main.start("ignore"); for (int i = ignoreResults.size()-1; i > 0; i--) { ignoreResults.get(i).check(event); // Remove empty additions to prevent lag. if (ignoreResults.get(i).ignore.size() == 0) ignoreResults.remove(i); } Main.end(); }
public static void onChat(ClientChatReceivedEvent event) { String message = event.message.getUnformattedText(); for (ChatTrigger trigger : ChatTrigger.triggers) { trigger.check(message); } }
public static void onChat(ClientChatReceivedEvent event) { String message = event.message.getUnformattedText(); ChatTracker.checkAll(message); ChatTrigger.checkAll(message); if (message.equals("\u00A7r\u00A76\u00A7lWelcome to the \u00A7r\u00A76\u00A7lMinecraftBuild.com\u00A7r\u00A76\u00A7l Build Server!\u00A7r")) { } }
@SubscribeEvent public void onChat(ClientChatReceivedEvent event) { if (Main.mc.isSingleplayer()) return; Main.start(); Server.getServer().onChat(event); Main.end(); }
@SubscribeEvent public void onClientChatReceived(ClientChatReceivedEvent event) { ITextComponent message = event.getMessage(); if (Configs.announceLocationBindingInChat == false && message instanceof TextComponentTranslation) { if ("enderutilities.chat.message.itemboundtolocation".equals(((TextComponentTranslation) message).getKey())) { event.setCanceled(true); } } }
public void handleChat(S02PacketChat p_147251_1_) { ClientChatReceivedEvent event = new ClientChatReceivedEvent(p_147251_1_.func_148915_c()); if (!MinecraftForge.EVENT_BUS.post(event) && event.message != null) { this.gameController.ingameGUI.getChatGUI().printChatMessage(event.message); } }
public void handleChat(Packet3Chat par1Packet3Chat) { par1Packet3Chat = FMLNetworkHandler.handleChatMessage(this, par1Packet3Chat); if (par1Packet3Chat == null) { return; } ClientChatReceivedEvent event = new ClientChatReceivedEvent(par1Packet3Chat.message); if (!MinecraftForge.EVENT_BUS.post(event) && event.message != null) { this.mc.ingameGUI.getChatGUI().printChatMessage(ChatMessageComponent.createFromJson(event.message).toStringWithFormatting(true)); } }
public static void checkForPartyInvite(ClientChatReceivedEvent event) { String message = event.message.getUnformattedText(); if (message.indexOf(" has invited you to join their party") != -1 && message.indexOf("to join! You have") != -1) { /* * Syntax of message is * "twemyeez has invited you to join their party! /party accept twemyeez to join! You have 60 seconds to accept." */ // Process string to get username int start = message.indexOf("/party accept"); message = message.substring(start); message = message.split(" ")[2]; // Accept invite Minecraft.getMinecraft().thePlayer.sendChatMessage("/p accept " + message); // Remove chat status ChatListener.currentStatus.remove(ChatStatus.PARTY_INVITE); // Tell user CommonUtils.sendFormattedChat(true, prefix + "Accepted invite from " + message, EnumChatFormatting.BLUE, true); } }
public static void handleJoinEvent(ClientChatReceivedEvent event) { // Get the message String message = event.message.getUnformattedText(); if (message.contains(":")) { // It is chat, so return return; } // Otherwise, we'll check it's the right length and contains "joined." if (message.split(" ").length == 2 && message.split(" ")[1].equals("joined.")) { // We know it's a join message so cancel the event event.setCanceled(true); // Get the username String nameJoined = message.split(" ")[0]; // Create the chat style with click event ChatStyle chatStyle = new ChatStyle() .setChatClickEvent(new ClickEvent( ClickEvent.Action.SUGGEST_COMMAND, "/tell " + nameJoined + " hi")); // Add the hover message to the chat style chatStyle = chatStyle.setChatHoverEvent(new HoverEvent( HoverEvent.Action.SHOW_TEXT, new ChatComponentText( EnumChatFormatting.BLUE + "Click to " + EnumChatFormatting.YELLOW + "message"))); // Send the player a message with prominent bars to show them CommonUtils.sendFormattedChatWithPrefix(new ChatComponentText( event.message.getFormattedText()).setChatStyle(chatStyle), true); } }
@SubscribeEvent public void onEvent(ClientChatReceivedEvent event) { this.chatMessagesReceived.add(event.message.getUnformattedText()); }
public static ITextComponent onClientChat(byte type, ITextComponent message) { ClientChatReceivedEvent event = new ClientChatReceivedEvent(type, message); return MinecraftForge.EVENT_BUS.post(event) ? null : event.getMessage(); }
@SubscribeEvent public void chatParser(ClientChatReceivedEvent event) { ITextComponent msg = event.getMessage(); if (msg == null) return; String msgText = msg.getUnformattedText(); if (msgText == null) return; //Check if its the tps message (this is quick) if (msgText.contains(tpsMessage)) { parseTPS(msgText); return; } //Start of the chat message for creating a snitch block from /ctf or /ctr if (msgText.contains("You've created")) { if (tryParsePlaceMessage(msg)) { //Save the snitches now that we loaded a new one from chat manager.saveSnitches(); SnitchMaster.SendMessageToPlayer("Saved snitch from chat message"); return; } } else if(msgText.contains("Changed snitch name to")) { if(tryParseNameChangeMessage(msg)) { manager.saveSnitches(); return; } } //Only check for reset sequences or /jalist messages if we are updating if (updatingSnitchList) { if (containsAny(msgText, resetSequences)) //Check if this is any of the reset messages (this is kind of quick) { resetUpdatingSnitchList(true); SnitchMaster.SendMessageToPlayer("Finished full snitch update"); return; } //Check if this matches a snitch entry from the /jalist command (this is less quick than above) if (tryParseJalistMsg(msg)) { //If they have it set to not spam the chat then cancel the chat message Settings.ChatSpamState state = (Settings.ChatSpamState) snitchMaster.getSettings().getValue(Settings.CHAT_SPAM_KEY); if (state == Settings.ChatSpamState.OFF || state == Settings.ChatSpamState.PAGENUMBERS) event.setCanceled(true); return; } } //Check if this matches the snitch alert message (slowest of all of these) Matcher matcher = snitchAlertPattern.matcher(msgText); if (!matcher.matches()) return; // this was the last kind of message we check //Build the snitch alert and send it to all the recipients SnitchAlert alert = buildSnitchAlert(matcher, msg); for (IAlertRecipient recipient : alertRecipients) { recipient.receiveSnitchAlert(alert); } //Set the alert's message to whatever the final message is from the alert "event" event.setMessage(alert.getRawMessage()); }
static void nameNotification(ClientChatReceivedEvent e){ if (!(mc.currentScreen instanceof GuiConnecting) && e.message.getUnformattedTextForChat().contains(mc.thePlayer.getDisplayNameString())) SoundCore.play(mc, SoundCore.MESSAGE); }
static void chatCommand(ClientChatReceivedEvent evt) { if (!(mc.currentScreen instanceof GuiConnecting) && Command.processCommand(evt.message.getUnformattedText())) evt.setCanceled(true);// TODO: add pm feature and PT chat }
public void chatEvent(ClientChatReceivedEvent event) { }
@SubscribeEvent public void onEvent(ClientChatReceivedEvent event) { this.chatMessagesReceived.add(event.getMessage().getUnformattedText()); }