Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted


Hello, im trying to make it so if the message that is sent in chat is == `hi` it will send hi! back. 

This is what I have managed so far, although im unsure how i can make it only send if the message is == `hi` Originally I tried if(e.message.equals("hi");

However, it is false no matter what I do!

The type is IChatComponent

I then found out that I can do the following:
However, im unsure how i can filter the message so its only true if the message is == `hi`
 

@SubscribeEvent
public void onChat(ChatReceivedEvent e) {
    if(e.message.equals(e.message)) {
        System.out.println(e.message);
        mc.Player.sendChatMessage("hi!");
    }else {
        System.out.println(e.type);
        System.out.println("1");
    }
}

If anyone could help me it would be great as I have been trying to get this to work for around 2 hours.

Thanks,
Logan

  • Author
@SubscribeEvent
public void onChat(ChatReceivedEvent e) {
    String raw = e.message.getUnformattedText();
    if (raw.contains("!help")) {
        mc.Player.sendChatMessage("hi");
    }
}

 

I've finally figured it out, 

next step: How can I make it so if the player sends this message, it will only send it client side?

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

Important Information

By using this site, you agree to our Terms of Use.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.