Query Plugin
#1
Hello all, about a month ago I implemented a query plugin when xoft added UDP protocol support (protocol) (github). This github issue includes some discussion

Basic and full stat are implemented. I followed MCServer coding style/conventions to the best of my knowledge, and I believe the code is very well commented (explaining why, not what). There's a config setting to enable/disable and which port to listen on

I don't think there's a way to get MCServer's version from lua - if someone knows a way, please let me know. So the only value hardcoded right now is "MCServer 1.8" for the version, because Minecraft 1.8 is the latest protocol it supports

I also think this plugin could be useful implemented into core or the main code of the server, as a lot of services/server lists use this protocol to query servers (the minecraft ping protocol has changed much over the different versions)

Please let me know what you guys think, thanks!
Reply
Thanks given by: sphinxc0re , xoft
#2
I think the code needs some cleanup, there's clearly some leftovers from testing various approaches, some dead code etc. Then I'd really like to see you write more code Smile How about https://github.com/mc-server/Core/issues/87 or https://github.com/mc-server/Core/issues/70 ?
Reply
Thanks given by:
#3
Thanks for the feedback! I'm actually not entirely sure which parts you're referring to as leftovers (probably skipping over things in my own code), but going through I can think of these

- line 17-20,
Code:
-- Use the InfoReg shared library to process the Info.lua file:
- don't really need this, because the plugin doesn't register commands
- line 41-42,
Code:
LOG("Not starting query server; disabled in settings.ini.")
- too verbose/unnecessary?
- line 66-68,
Code:
OnReceivedData = function ()
- empty callback, just remove? Should I keep the error callback?
- line 194-205,
Code:
function PacketReadInt(a_Data)
- perhaps this could be more accurately named
Code:
PacketRead4Bytes
. Is there a better way to get a subarray/splice of an array in lua? (googling lua subarray/splice/slice doesn't return much. There's an SO thread on implementing tail)

As for coding style, arguably extracting the session ID could be refactored higher up, but I kinda wanted to treat each packet type format as independent from each other as possible.

Also, I'm not sure of any vanilla lua ways of cleanly converting between bytes and ints, hence the awkwardness with
Code:
PacketReadInt
and lines 94-97 (manually computing a 4 byte int from a byte array)

What did you have in mind?

I'm actually quite busy ATM with school coming to a close soon - finishing projects and catching up for exams, especially since I've had pretty bad work ethics xD But I will try my hand at #70 hopefully this weekend. Thanks for your time!
Reply
Thanks given by:




Users browsing this thread: 1 Guest(s)