diff --git a/.classpath b/.classpath new file mode 100644 index 0000000..fb565a5 --- /dev/null +++ b/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/.project b/.project new file mode 100644 index 0000000..aff18c2 --- /dev/null +++ b/.project @@ -0,0 +1,17 @@ + + + CustomSkinLoaderGUI + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/.settings/org.eclipse.jdt.core.prefs b/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 0000000..7341ab1 --- /dev/null +++ b/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.7 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.7 diff --git a/1.7.2-mcp903/src/minecraft/idv/jlchntoz/CustomSkinLoader.java b/1.7.2-mcp903/src/minecraft/idv/jlchntoz/CustomSkinLoader.java deleted file mode 100644 index 78e226a..0000000 --- a/1.7.2-mcp903/src/minecraft/idv/jlchntoz/CustomSkinLoader.java +++ /dev/null @@ -1,145 +0,0 @@ -package idv.jlchntoz; - -import net.minecraft.client.Minecraft; -import java.io.*; -import java.net.*; -import java.util.logging.*; -import java.util.regex.*; - -/** - * Custom skin loader mod for Minecraft. - * - * @version 9th Revision 2014.4.15 - * @author (C) Jeremy Lam [JLChnToZ] 2013 & Alexander Xia [xfl03] 2014 - */ -public class CustomSkinLoader { - public final static String DefaultSkinURL = "http://skins.minecraft.net/MinecraftSkins/*.png"; - public final static String DefaultCloakURL = "http://skins.minecraft.net/MinecraftCloaks/*.png"; - private final static Pattern newURLPattern = Pattern.compile("^http://skins.minecraft.net/Minecraft(Skin|Cloak)s/(.*?).png$"), - oldURLPattern = Pattern.compile("^http://s3.amazonaws.com/Minecraft(Skin|Cloak)s/(.*?).png$"); - - private final static Logger logger = Logger - .getLogger(CustomSkinLoader.class.getName()); - - private static String[] cloakURLs = null, skinURLs = null; - - private HttpURLConnection C = null; - - public InputStream getPlayerSkinStream(String path) { - Matcher m = newURLPattern.matcher(path); - if (!m.matches())//Is not new url - { - m = oldURLPattern.matcher(path);//If is old url - } - if (m.matches()) { - if (m.group(1).contains("Skin")) // Skin - return getPlayerSkinStream(false, m.group(2)); - else if (m.group(1).contains("Cloak")) // Cloak - return getPlayerSkinStream(true, m.group(2)); - } - return getStream(path, false); // Neither skin nor cloak... - } - - public InputStream getPlayerSkinStream(Boolean isCloak, String playerName) { - if (skinURLs == null || cloakURLs == null || skinURLs.length <= 0 - || cloakURLs.length <= 0) - refreshSkinURL(); // If the list is blank or null, try to load - // again. - for (String l : isCloak ? cloakURLs : skinURLs) { - String loc = str_replace("*", playerName, l); - logger.log(Level.INFO, "Try to load " + (isCloak ? "cloak" : "skin") + " in " + loc); - InputStream S = getStream(loc, true); - if (S == null) - logger.log(Level.INFO, "No " + (isCloak ? "cloak" : "skin") - + " found in " + loc); - else - return S; - } - logger.log(Level.INFO, "Try to load skin in default URL instead."); - return getStream(str_replace("*", playerName, isCloak ? DefaultCloakURL : DefaultSkinURL), true); - } - - private InputStream getStream(String URL, Boolean CheckPNG) { - try { - URL U = new URL(URL); - C = (HttpURLConnection) U.openConnection(); - C.setDoInput(true); - C.setDoOutput(false); - C.connect(); - int respcode = C.getResponseCode() / 100; - if (respcode != 4 && respcode != 5) { // Successful (?) to get skin. - BufferedInputStream IS = new BufferedInputStream( - C.getInputStream()); - if (!CheckPNG) // If no need to check PNG header, just skip it. - return IS; - IS.mark(0); - byte[] ib = new byte[4]; - IS.read(ib); - if (ib[1] == (byte) 'P' && ib[2] == (byte) 'N' - && ib[3] == (byte) 'G') { // Check PNG Header if needed - IS.reset(); - return IS; - } - } - } catch (Exception ex) { - logger.log(Level.WARNING, ex.getMessage()); - } finally { - disconnect(); - } - return null; - } - - public void disconnect() { - if (C != null) - C.disconnect(); - } - - private static void refreshSkinURL() { - try { - File mcdir = Minecraft.getMinecraft().mcDataDir; - skinURLs = readAllLines(mcdir, "skinurls.txt"); - cloakURLs = readAllLines(mcdir, "capeurls.txt"); - } catch (Exception ex) { - logger.log(Level.WARNING, ex.getMessage()); - } finally { - logger.log(Level.INFO, "Skin URLs Refreshed. Skin count = " - + skinURLs.length + ", Cloak count = " + cloakURLs.length); - } - } - - private static String[] readAllLines(File mcdir, String path) { - try { - File F = new File(mcdir, path); - logger.log(Level.INFO, "Config file: " + F.getAbsolutePath()); - if (!F.exists()) { - logger.log(Level.INFO, "Config file not found, create new one."); - F.createNewFile(); - return new String[0]; - } else if (F.length() <= 0) { - logger.log(Level.INFO, "Config file is blank, skipped."); - return new String[0]; - } else { - byte[] b = new byte[(int) F.length()]; - BufferedInputStream S = new BufferedInputStream( - new FileInputStream(F)); - S.read(b); - S.close(); - logger.log(Level.INFO, "Config file loaded."); - return str_replace("\r", "\n", - str_replace("\r\n", "\n", new String(b))).split("\n"); - } - } catch (Exception ex) { - logger.log(Level.WARNING, ex.getMessage()); - return new String[0]; - } - } - - private static String str_replace(String search, String replace, - String subject) { - StringBuffer result = new StringBuffer(subject); - int pos; - while ((pos = result.indexOf(search)) != -1) - result.replace(pos, pos + search.length(), replace); - return result.toString(); - } -} diff --git a/1.7.2-mcp903/src/minecraft/net/minecraft/client/renderer/ThreadDownloadImageData.java b/1.7.2-mcp903/src/minecraft/net/minecraft/client/renderer/ThreadDownloadImageData.java deleted file mode 100644 index a1e957a..0000000 --- a/1.7.2-mcp903/src/minecraft/net/minecraft/client/renderer/ThreadDownloadImageData.java +++ /dev/null @@ -1,112 +0,0 @@ -package net.minecraft.client.renderer; - -import java.awt.image.BufferedImage; -import java.io.IOException; -import java.net.HttpURLConnection; -import java.net.URL; -import java.util.concurrent.atomic.AtomicInteger; -import javax.imageio.ImageIO; -import net.minecraft.client.Minecraft; -import net.minecraft.client.renderer.texture.SimpleTexture; -import net.minecraft.client.renderer.texture.TextureUtil; -import net.minecraft.client.resources.IResourceManager; -import net.minecraft.util.ResourceLocation; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; - -import idv.jlchntoz.CustomSkinLoader; - -public class ThreadDownloadImageData extends SimpleTexture -{ - private static final Logger logger = LogManager.getLogger(); - private static final AtomicInteger field_147643_d = new AtomicInteger(0); - private final String imageUrl; - private final IImageBuffer imageBuffer; - private BufferedImage bufferedImage; - private Thread imageThread; - private boolean textureUploaded; - private static final String __OBFID = "CL_00001049"; - - public ThreadDownloadImageData(String par1Str, ResourceLocation par2ResourceLocation, IImageBuffer par3IImageBuffer) - { - super(par2ResourceLocation); - this.imageUrl = par1Str; - this.imageBuffer = par3IImageBuffer; - } - - private void func_147640_e() - { - if (!this.textureUploaded) - { - if (this.bufferedImage != null) - { - if (this.textureLocation != null) - { - this.func_147631_c(); - } - - TextureUtil.uploadTextureImage(super.getGlTextureId(), this.bufferedImage); - this.textureUploaded = true; - } - } - } - - public int getGlTextureId() - { - this.func_147640_e(); - return super.getGlTextureId(); - } - - public void func_147641_a(BufferedImage p_147641_1_) - { - this.bufferedImage = p_147641_1_; - } - - public void loadTexture(IResourceManager par1ResourceManager) throws IOException - { - if (this.bufferedImage == null && this.textureLocation != null) - { - super.loadTexture(par1ResourceManager); - } - - if (this.imageThread == null) - { - this.imageThread = new Thread("Texture Downloader #" + field_147643_d.incrementAndGet()) - { - private static final String __OBFID = "CL_00001050"; - public void run() - { - - CustomSkinLoader Loader = new CustomSkinLoader(); - - try - { - BufferedImage var2 = ImageIO.read(Loader.getPlayerSkinStream(ThreadDownloadImageData.this.imageUrl)); - - if (ThreadDownloadImageData.this.imageBuffer != null) - { - var2 = ThreadDownloadImageData.this.imageBuffer.parseUserSkin(var2); - } - - ThreadDownloadImageData.this.func_147641_a(var2); - } - catch (Exception var6) - { - ThreadDownloadImageData.logger.error("Couldn\'t download http texture", var6); - return; - } - - } - }; - this.imageThread.setDaemon(true); - this.imageThread.setName("Skin downloader: " + this.imageUrl); - this.imageThread.start(); - } - } - - public boolean isTextureUploaded() - { - this.func_147640_e(); - return this.textureUploaded; - } -} diff --git a/README.md b/README.md index 859d878..9047f9a 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,3 @@ -MCCustomSkinLoader -================== +MCCustomSkinLoaderGUI +===================== diff --git a/src/idv/jlchntoz/CustomSkinLoaderGUI.java b/src/idv/jlchntoz/CustomSkinLoaderGUI.java new file mode 100644 index 0000000..381063b --- /dev/null +++ b/src/idv/jlchntoz/CustomSkinLoaderGUI.java @@ -0,0 +1,14 @@ +package idv.jlchntoz; + +import java.util.logging.Logger; + +public class CustomSkinLoaderGUI { + public static final Logger log=Logger.getLogger("CustomSkinLoader-GUI"); + + public static void main(String[] args) { + log.info("loading"); + MainFrame.main(args); + + } + +} diff --git a/src/idv/jlchntoz/MainFrame.java b/src/idv/jlchntoz/MainFrame.java new file mode 100644 index 0000000..eee375d --- /dev/null +++ b/src/idv/jlchntoz/MainFrame.java @@ -0,0 +1,36 @@ +package idv.jlchntoz; + +import java.awt.BorderLayout; +import java.awt.Container; +import java.awt.Font; + +import javax.swing.JFrame; +import javax.swing.JLabel; +import javax.swing.WindowConstants; + +public class MainFrame { + + public static void main(String[] args) { + JFrame jf = new JFrame ("CustomSkinLoader-GUI"); + Container con = jf.getContentPane(); + con.setLayout(null); + //setBounds(x,y,width,height) + jf.setBounds(400, 200, 400, 300); + + Font boldCourier=new Font("Courier", Font.BOLD, 30); + + JLabel title=new JLabel(); + title.setText("CustomSkinLoader Index"); + title.setFont(boldCourier); + title.setBounds(15, 5, 360, 30); + con.add(title); + + + + jf.setVisible(true); + jf.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); + jf.setResizable(false); + + } + +}