Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

kicked on whispering (unsigned_chat) #2992

Open
1 task done
Moosbee opened this issue Mar 25, 2023 · 10 comments
Open
1 task done

kicked on whispering (unsigned_chat) #2992

Moosbee opened this issue Mar 25, 2023 · 10 comments
Labels
possible bug Stage1 just created by someone new to the project, we don't know yet if it deserves an implementation / a f

Comments

@Moosbee
Copy link
Contributor

Moosbee commented Mar 25, 2023

  • The FAQ doesn't contain a resolution to my issue

Versions

  • mineflayer: ^4.8.1
  • server: paper 1.19.2
  • node: v19.8.1

Detailed description of a problem

while using the default connection options(disableChatSigning not specified) bot.chat("/tell Moosbee Test") will kick the bot from the Server.
Bot.whisper(username, message); does exist, but it doesn't work at all, just outputting /tell username message to the general chat regardless if disableChatSigning is true or false
The disconnect packet is as follows: { reason: '{"translate":"multiplayer.disconnect.unsigned_chat"}' } { size: 54, name: 'kick_disconnect', state: 'play' }
Using bot.chat("Test") does work.

What did you try yet?

/msg is the same problem. But the /help command works.
Setting disableChatSigning on start to true will fix the issue, provided the server you are playing on allows unsigned chat.

Did you try any method from the API?
Bot.whisper(username, message); does exist, but it doesn't work at all, just outputting /tell username message to the general chat

Did you try any example? Any error from those? I couldn't find a whisper/private conversation example

Your current code

The code does work if disableChatSigning is set to true

  answer(data: chat, message: string) {
    if (data.type == 2) {
      getBot().chat(
        `/tell ${this.getUserByUUID(data.sender)?.username} ${message}`
      );
    } else {
      getBot().chat(message);
    }
  }

Expected behavior

The bot whispering me something, it beeing signed and not getting kicked

Additional context

Setting disableChatSigning on start to true will fix the issue, provided the server you are playing on allows unsigned chat.

@Moosbee Moosbee added possible bug Stage1 just created by someone new to the project, we don't know yet if it deserves an implementation / a f labels Mar 25, 2023
@lkwilson
Copy link
Contributor

I think this is a duplicate of #2874

@rgmarquez
Copy link

@lkwilson @Moosbee Can you check that the above fixes (https://github.com/PrismarineJS/node-minecraft-protocol/pull/1241/commits) indeed fixed this problem? I believe that the latest npm package of minecraft-protocol (1.44.0) has the above changes, but calling mineflayer's bot.whisper() seems to still be kicking with "lost connection: Received chat packet with missing or invalid signature." being returned from a vanilla 1.20.1 server...?

@lkwilson
Copy link
Contributor

Does it work for you on a 1.19.3+ server other than 1.20.1? Also are you whispering a long message or using coloring? And does using .chat(“/whisper …”) work? You can look in node_modules/minecraft-protocol/package.json to verify you’re using 1.44

@rgmarquez
Copy link

@lkwilson Let me check for those cases, I would be glad to help out. Messaging is literally:

bot.whisper(masterPlayer, you whispered to me "${message}")

...where 'masterPlayer' is my user name, and 'message' is the string "Hi!".

@rgmarquez
Copy link

(There are backticks in the above JavaScript, but of course they got converted to formatting)

@Moosbee
Copy link
Contributor Author

Moosbee commented Sep 27, 2023

The bot.whisper command now works as expected, but you still have to enable disableChatSigning for the bot to not get kicked.
Tested on Paper 1.19.3 and Paper 1.20.1

@rgmarquez
Copy link

rgmarquez commented Sep 28, 2023

@Moosbee excellent, that worked, I hadn't realized that I could pass disableChatSigning to mineflayer.createBot(). Tested on Mojang vanilla 1.20.1 and Simpcraft.com (Paper 1.20.1). Verified it works on both without kicking player, thanks!

REVISED: Still not working for me. disableChatSigning: true did solve the "kick" issue when calling bot.whisper(), but I never actually see the whisper coming from the bot. I am whispering to the bot (using /msg in-game) to trigger things, and I only see the autogenerated You whisper to [botname]: [message], and not the whispered reply from the bot. Using console.log() verifies that the the bot's whisper handler is getting called, but bot.whisper() is not generating a msg back to me.

This is my test script:

const path = require('path')

if (process.argv.length != 5) {
  let scriptname = path.basename(process.argv[1]);
  console.log(`Usage : node ${scriptname} <host> <port> [<name>]`)
  process.exit(1)
}

const bot = mineflayer.createBot({
  username: process.argv[4],
  auth: 'microsoft',
  host: process.argv[2],
  port: parseInt(process.argv[3]),
  disableChatSigning: true,
  verbose: true
})

bot.on('whisper', (username, message, rawMessage) => {
    console.log(`I received a message from ${username}: ${message}`)
    bot.whisper(username, 'I can tell secrets too.')
})

@Moosbee
Copy link
Contributor Author

Moosbee commented Sep 28, 2023

@rgmarquez try to hardcode the username in bot.whisper, if the username is not exactly right it will fail. Also try using the npm i https://github.com/PrismarineJS/mineflayer to get the newest version of mineflayer.

@rgmarquez
Copy link

@Moosbee I finally got a chance to try out your suggestions. As for the npm, just for completeness, this is what I get when doing "npm i https://github.com/PrismarineJS/mineflayer":

npm WARN EBADENGINE Unsupported engine {
npm WARN EBADENGINE   package: '@azure/msal-node@1.18.3',
npm WARN EBADENGINE   required: { node: '10 || 12 || 14 || 16 || 18' },
npm WARN EBADENGINE   current: { node: 'v20.6.1', npm: '10.2.0' }
npm WARN EBADENGINE }

up to date, audited 111 packages in 3s

9 packages are looking for funding
  run `npm fund` for details

found 0 vulnerabilities

I'm trying this all under MacOS, Node version v20.6.1, npm version 10.2.0.

This is what my package.json looks like:

{
  "name": "getting_started",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "author": "",
  "license": "ISC",
  "dependencies": {
    "minecraft-data": "^3.45.0",
    "minecraft-protocol": "^1.44.0",
    "mineflayer": "github:PrismarineJS/mineflayer",
    "mineflayer-armor-manager": "^2.0.1",
    "mineflayer-auto-eat": "^3.3.6",
    "mineflayer-pathfinder": "^2.4.5",
    "mineflayer-pvp": "^1.3.2"
  }
}

I did trying to hardcode the bot's whisper statement to "bot.whisper('blammo21', 'I can tell secrets too.')", and verified the spelling of my currently logged-in account was indeed "blammo21". I also re-verified that the bot was being "triggered" to whisper correctly, as the debug console correctly printed the incoming message thusly : "I received a message from blammo21: hi!".

Can you tell me if everyone else seems to have bot.whisper() working fine with disableChatSigning: true? If so, I can narrow differences down on my end. Thanks for all your time looking at this so far.

@Moosbee
Copy link
Contributor Author

Moosbee commented Oct 6, 2023

you can try to use getBot().chat('/tell blammo21 Test');

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
possible bug Stage1 just created by someone new to the project, we don't know yet if it deserves an implementation / a f
Projects
None yet
Development

No branches or pull requests

3 participants