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

How to use mc.ping() #774

Closed
ghost opened this issue Nov 3, 2020 · 5 comments
Closed

How to use mc.ping() #774

ghost opened this issue Nov 3, 2020 · 5 comments

Comments

@ghost
Copy link

ghost commented Nov 3, 2020

You can show part of the code using mc.ping()?

@ghost
Copy link
Author

ghost commented Nov 3, 2020

https://github.com/PrismarineJS/node-minecraft-protocol/blob/0fbb5ed2609ba902972498f03db9ed720c5a549d/src/ping.js

It seems to be correct, but this code does not work

const mc = require('minecraft-protocol')

const options = {
    host: process.argv[2],
    port: parseInt(process.argv[3]),
    version: "1.12.2"
}
console.log(mc.ping(options,function(){console.log("done!")}))

@TheDudeFromCI
Copy link
Member

Try using:

const mc = require('minecraft-protocol')

const options = {
    host: process.argv[2],
    port: parseInt(process.argv[3]),
    version: "1.12.2"
}
console.log(mc.ping(options, function(err) {
  if (err) console.log(err)
  else console.log("done!")
}))

See if any errors are printed to the console.

@ghost
Copy link
Author

ghost commented Nov 3, 2020

Try using:

const mc = require('minecraft-protocol')

const options = {
    host: process.argv[2],
    port: parseInt(process.argv[3]),
    version: "1.12.2"
}
console.log(mc.ping(options, function(err) {
  if (err) console.log(err)
  else console.log("done!")
}))

See if any errors are printed to the console.

This outputs first undefined then done!
without error

@IMarkoMC
Copy link

IMarkoMC commented Nov 5, 2020

This is working for me.

mc.ping({ host: localhost, port: port }, (err, data) => {
    if (err) {
        console.log(err)
        return
    }
    console.log(data)
})

@ghost ghost closed this as completed Nov 6, 2020
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants