Jump to content

[1.7.2]About version checking


aguinmox

Recommended Posts

Hello everyone so i just created a version checker for my own mod. and somehow i register it in my main class and it works(using system print) but one thing i wanna know is how do i make a chat message referring to the newversion. like on player login

 

Me code anyway thankyou

package mhfc.heltrato.common.helper.system;

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.net.URL;

public class HentaiVersionHelper {

public static String urlString;
public static String versionString;
public static String newVersionStr;
public static int newUpdate = 2;
public static int noUpdate = 1;
public static int offline = 0;


public static void init(String url, String version)  {
	urlString = url;
	versionString = version;
}

public static int isUpdateAvailable() 
{
	try {

		BufferedReader versionFile = new BufferedReader(new InputStreamReader(new URL(urlString).openStream()));
		String curVersion = versionFile.readLine();
		newVersionStr = curVersion;
		versionFile.close();

		if (!curVersion.equals(versionString))
		{
			return newUpdate;
		}
		else
		{
			return noUpdate;
		}
	}
	catch(Exception e)
	{
		return offline;
	}
	}
}



Link to comment
Share on other sites

"Hentai" - Dat Mod :)

 

I am guessing you are executing this class in preInit?

 

There are 3 ways:

1. Subscribe to PlayerLoggedInEvent.

- This even is only fired by Server thread.

- Send packet that tells player to display his LOCAL version.

 

2. Subscribe to PlayerLoggedInEvent.

- This even is only fired by Server thread.

- Send ChatComponent containing mod version this Server thread is running on (you know, client must have same version as server, so it's right to assume that client will have same as server). Note: doesn't matter is you are SP or MP.

 

3. Do everything on Client thread:

- Subscribe to EntityJoinedWorld and make it run only Client side (world.isRemote)

- Check if entity == mc.thePlayer (your player entity)

- Print ChatComonent client-side.

 

#3rd one is best.

1.7.10 is no longer supported by forge, you are on your own.

Link to comment
Share on other sites

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.



×
×
  • Create New...

Important Information

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