Jump to content

Recommended Posts

Posted

All of my version names for my mod have text in them. Since there isn't anything that should be stopping them from connecting with each other, I started trying to use @VersionCheckHandler (from @NetworkMod), but have had no luck. The definition is:

/**
     * A marker for a method that will be offered the client's version string
     * if more sophisticated version rejection handling is required:
     * The method should accept a "String", a "NetworkManager" and return a boolean true
     * if the version can be accepted.
     * @author cpw
     *
     */
    @Retention(RetentionPolicy.RUNTIME)
    @Target(ElementType.METHOD)
    public @interface VersionCheckHandler { }

 

I've put the annotation onto a method,  but it isn't doing anything, including complaining of incorrect usage. I added a simple .printStackTrace() test on a fully contained exception and nothing printed, leading me to think it's not even being looked at.

In case it matters, I've changed the signature for the method a few times trying to get a result, even if it were a bad one, with no changes.

 

How do I correctly set up @VersionCheckHandler from @NetworkMod so I can have improved version checking?

 

More information, if needed:

 

My mod file is name SeasonsMod and is Forge-based.

@Mod(modid="SeasonsMod", 
name="The Seasons Mod", 
version=SeasonsMod.SeasonCurrentVersion
)

@NetworkMod(clientSideRequired=true, serverSideRequired=false, 
channels={/*removed the channels to save space*/}, 
packetHandler = PacketHandler.class)
public class SeasonsMod implements IConnectionHandler{
...
public static final String SeasonCurrentVersion = "1.6.1_3 - Stars";
public static final String[] SeasonAcceptedVersion = {	"1.6.1 - Find the Truth","1.6.1_1 - Hearth's Warming Eve","1.6.1_2 - Void"};	
...
@VersionCheckHandler()
public boolean AllowVersionConnection(String version){
	try{
		Side side = FMLCommonHandler.instance().getEffectiveSide();
		throw new Exception("Seasons: this is normal. Accessed from a: "+side);
	}catch(Exception e){
		e.printStackTrace();
	}


	if(version.equals(this.SeasonCurrentVersion) || version == this.SeasonCurrentVersion){
		return true;
	}
	for(String previous : this.SeasonAcceptedVersion){
		if(version.equals(previous) || version == previous){
			return true;
		}
	}
	return false;

When a client and server with different versions try to connect, the function is not being called, as if the method doesn't exist. I have checked, and there is not an @Side annotation on the method.

 

 

If this isn't enough information, please let me know and I'll provide what is needed.

Posted

Your function NEEDS to accept a NetworkManager! You are only accepting a String, it needs both, it even says so in the javadoc above the declaration!

When using something you have not used before, ALWAYS read the documentation

Posted

I did read the documentation. There is no "NetworkManager" class - the closest thing is an "INetworkManager" class, which I had already tried.

In case it matters, I've changed the signature for the method a few times trying to get a result, even if it were a bad one, with no changes.

@VersionCheckHandler()
public boolean AllowVersionConnection(String version, INetworkManager iNet_test){
...
}

 

I'll try it again, but I can almost guarantee that it still won't work.

EDIT: I was correct, it still doesn't work like that (String, INetworkManager)

 

And for the checking if the two Strings are the same in my first post, I have it check through both == and .equals(String) as a result of a bug involving Strings elsewhere in the code, which I'm going to completely rewrite soon to try to remove.

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...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

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