package net.minecraft.src;
import java.io.*;
import java.net.URL;
import java.util.*;
import java.util.logging.Level;
import java.text.SimpleDateFormat;
import net.minecraft.client.Minecraft;
public class mod_ingameInfo extends BaseMod
{
private Minecraft minecraft;
private ScaledResolution scaledResolution;
private int alignMode;
int y[];
String text[];
String fileName;
private boolean checkUpdate;
public mod_ingameInfo()
{
minecraft = ModLoader.getMinecraftInstance();
y = new int[3];
fileName = "ingameInfo";
text = loadText(new File(Minecraft.getMinecraftDir(), (new StringBuilder()).append("/mods/daftpvf/").append(fileName).toString()));
ModLoader.setInGameHook(this, true, false);
checkUpdate = true;
}
public void load()
{
if(!isCurrentVersion(ModLoader.getMinecraftInstance()))
ModLoader.getLogger().log(Level.INFO, "Your version of IngameInfo is out of date! Visit http://www.minecraftforum.net/topic/1009577- for the latest version.");
}
public String getVersion()
{
return "1.3.1.h modified by bspkrs";
}
public boolean onTickInGame(float f, Minecraft mc)
{
if(mc.inGameHasFocus && !mc.gameSettings.showDebugInfo)
{
scaledResolution = new ScaledResolution(mc.gameSettings, mc.displayWidth, mc.displayHeight);
y = (new int[] {
0, 0, 0, 0, 0, 0, 0, 0, 0
});
String lines[] = text;
int i = lines.length;
for(int j = 0; j < i; j++)
{
String s = lines[j];
s = replaceAllTags(s);
mc.fontRenderer.drawStringWithShadow(s, getX(mc.fontRenderer.getStringWidth(s)), getY(i, y[alignMode]), 0xffffff);
y[alignMode]++;
}
}
if(checkUpdate)
{
if(!isCurrentVersion(mc) && mc.inGameHasFocus)
{
minecraft.thePlayer.addChatMessage("&cYour version of IngameInfo is out of date!");
minecraft.thePlayer.addChatMessage("&cVisit http://www.minecraftforum.net/topic/1009577- for the latest version.");
}
checkUpdate = false;
}
return true;
}
private boolean isCurrentVersion(Minecraft minecraft)
{
try
{
String[] version = loadTextFromURL(new URL("https://dl.dropbox.com/u/20748481/Minecraft/1.3.1/ingameInfo.version"));
return version[0].equalsIgnoreCase(getVersion());
}
catch(Exception e)
{
ModLoader.getLogger().log(Level.WARNING, "Error getting current version info: " + e.getStackTrace());
return true;
}
}
private String[] loadTextFromURL(URL url)
{
ArrayList arraylist = new ArrayList();
Scanner scanner = null;
try
{
scanner = new Scanner(url.openStream(), "UTF-8");
}
catch(FileNotFoundException filenotfoundexception) { } catch (IOException e) {
ModLoader.getLogger().log(Level.WARNING, "Error getting current version info: " + e.getStackTrace());
}
while(scanner.hasNextLine())
{
arraylist.add(scanner.nextLine());
}
scanner.close();
return (String[])arraylist.toArray(new String[arraylist.size()]);
}
Comments