Backwards Compatibility - Protocol Version

Discussion in 'Bukkit Help' started by CapnDuckface, Sep 22, 2013.

Thread Status:
Not open for further replies.
  1. Offline

    CapnDuckface

    Since the 1.6.4 update I've been looking through the CraftBukkit 1.6.2 coding to allow 1.6.4 players to join without compromising my 1.6.2 plugins (so I can wait until they update), but have been unsuccessful so far in changing the protocol version.

    Would anyone be able to point me in the right direction and notate if there's anything else I should do to ensure that my efforts are successful?
     
  2. Offline

    xDeeKay

    CapnDuckface That's a terrible idea. Why not just stay on 1.6.2 until your plugins are at a suitable version for 1.6.4?
     
  3. Offline

    CapnDuckface

    May I ask why it's a terrible idea?

    I have seen numerous low and high-tech servers taking these steps and considering that's the same direction we're pushing for, it would be wise to allow updated clients to join the server.

    It has everything to do with player retention and due to not being 'up-to-date' I've not only seen a repeated pattern of player loss on other servers, but I have to deal with it myself now.

    If someone can lend a hand - any piece of knowledge - I would greatly appreciate it.
     
  4. Offline

    TnT

    Protocol compatibility has shown to cause some rather significant bugs.

    Due to how the Minecraft launcher works now, it should be a simple matter to show your players how to downgrade until you are ready to upgrade your server.
     
  5. Offline

    CapnDuckface

    Believe me, I'd love to take that route, but most people either don't know how (even when it's explained) or they choose not to utilize this launcher method - hence why a plethora of servers have undertaken this method to avoid a loss in player growth and player retention.

    If these consequences are so high, why is it that well respected servers such as The Hive and LegendaryCraft as well as lesser servers using these methods successfully?

    I am aware of the potential consequences, but I would greatly appreciate it if someone actually answered my question instead of beating around the bush.
     
  6. Offline

    megasaad44

    CapnDuckface Do what i did, Update to 1.6.4. An outdated plugin isn't a plugin that wasn't made for a specific version, an outdated plugin is a plugin that will not function anymore with an new version. Most of my plugins are still up and happy, the ones that didnt were small ones no one would notice :) Just update!
     
  7. Offline

    agaricus


    My opinion, it is not necessarily such a bad idea depending on what has changed in the protocol. Sure if there are actual client/server protocol incompatibilities, forcing the old version is just asking for trouble. But sometimes surprisingly, the protocol version is bumped without any other significant actual network protocol changes.

    I haven't looked too much at the 1.6.4 from 1.6.2 changes so I can't commit on whether there are significant protocol changes, however, maybe someone else has. Personally I'm still on the 1.5.x branch, upgrading to 1.5.2 from 1.5.1 as we speak.. (been out of the loop for a while), but curiously, there was a similar protocol change back then. All that Mojang did in the netcode was change '60' to '61', so if you reverted the change, 1.5.2/1.5.1 clients could connect.. which is what I did, and it worked great, using it since then for many months (perhaps more interestingly, in addition to this 'protocol hack', also implemented an 'obfuscation hack', so addons developed for 1.5.1 could be used on 1.5.2 without waiting for the addon authors to recompile for 1.5.2 — and some never did).


    Here you go, this is the relevant code:

    src/main/java/net/minecraft/server/PendingConnection.java
    Code:
        public void a(Packet2Handshake packet2handshake) {
    ...
                    if (packet2handshake.d() != 78) {
                        if (packet2handshake.d() > 78) {
                            this.disconnect("Outdated server!");
                        } else {
                            this.disconnect("Outdated client!");
                        }
    
    Change the accepted version as desired and the version-mismatched clients should be able to connect. By the way - you may notice this code is obfuscated, one reason why it can be difficult to identify what you need to change and what exactly the code is doing. If you are making many changes to the Minecraft internals, or just want to better understand what is going on, I highly recommend reading the source from a decompilation using the Minecraft Coder Pack. The symbols are often different from mc-dev but they are more heavily deobfuscated, even sometimes with added (user-contributed) comments, making the meaning of the code much more clear. MCP decompiles the above code, in net/minecraft/network/NetLoginHandler.java (equivalent to CraftBukkit's PendingConnection, same class, different name only) to the following:

    Code:
        public void handleClientProtocol(Packet2ClientProtocol par1Packet2ClientProtocol)
    ...
                if (par1Packet2ClientProtocol.getProtocolVersion() != 78)
                {
                    if (par1Packet2ClientProtocol.getProtocolVersion() > 78)
                    {
                        this.raiseErrorAndDisconnect("Outdated server!");
                    }
                    else
                    {
                        this.raiseErrorAndDisconnect("Outdated client!");
                    }
                }
    
    so you can easily find it by searching the source code and see what it does. Can take some effort to match up this code to CB's equivalent decompilation, but it usually is not too troublesome, the structural similarities should be clear (or you can use mappings), and often it is worth it if you are making larger changes — and if the symbols in MCP are not descriptive enough, you can submit your own names and comments to help improve readability).

    Use at your own risk, your mileage may vary, of course.
     
    Wilee999 and Wruczek like this.
Thread Status:
Not open for further replies.

Share This Page