mirror of
https://github.com/xfl03/MCCustomSkinLoader.git
synced 2026-11-25 04:04:25 +00:00
Compare commits
18
Commits
14.9
...
GUI-archive
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
546caf028a | ||
|
|
d27b24fbde | ||
|
|
3600a7c5bf | ||
|
|
504a598428 | ||
|
|
e6f7618071 | ||
|
|
20a2dda540 | ||
|
|
57725f2c7a | ||
|
|
dc057ae7af | ||
|
|
c2e4235227 | ||
|
|
d99e82224b | ||
|
|
bf69fb5d42 | ||
|
|
a7a89bb621 | ||
|
|
583c610c8d | ||
|
|
ff7fa75cfa | ||
|
|
0c9bb21145 | ||
|
|
72d381cb4f | ||
|
|
b5bce5c4be | ||
|
|
b9138676ca |
No files matched your search
@@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry kind="src" path="src"/>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7"/>
|
||||
<classpathentry kind="output" path="bin"/>
|
||||
</classpath>
|
||||
@@ -4,7 +4,6 @@
|
||||
.mtj.tmp/
|
||||
|
||||
# Package Files #
|
||||
*.jar
|
||||
*.war
|
||||
*.ear
|
||||
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>CustomSkinLoaderGUI</name>
|
||||
<comment></comment>
|
||||
<projects>
|
||||
</projects>
|
||||
<buildSpec>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.jdt.core.javabuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||
</natures>
|
||||
</projectDescription>
|
||||
@@ -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
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
-112
@@ -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;
|
||||
}
|
||||
}
|
||||
Binary file not shown.
@@ -1,3 +1,23 @@
|
||||
MCCustomSkinLoader
|
||||
==================
|
||||
MCCustomSkinLoaderGUI
|
||||
=====================
|
||||
/*
|
||||
|
||||
|
||||
版权所有(C) 2013-2014 JLChnToZ xfl03
|
||||
|
||||
这一程序是自由软件,你可以遵照自由软件基金会出版的GNU通用公共许可证条款来修改和重新发布这一程序。或者用许可证的第三版,或者(根据你的选择)用任何更新的版本。
|
||||
|
||||
发布这一程序的目的是希望它有用,但没有任何担保。甚至没有适合特定目的的隐含的担保。更详细的情况请参阅GNU通用公共许可证。
|
||||
|
||||
|
||||
Copyright(C) 2013-2014 JLChnToZ xfl03
|
||||
|
||||
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||
|
||||
|
||||
http://www.gnu.org/licenses/gpl.html
|
||||
|
||||
*/
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
package idv.jlchntoz;
|
||||
|
||||
import idv.jlchntoz.gui.MainFrame;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
public class CustomSkinLoaderGUI {
|
||||
|
||||
public static final String VERSION ="1.1.1";
|
||||
|
||||
public static final Logger log=Logger.getLogger("CustomSkinLoader-GUI");
|
||||
public static final File LCK=new File("GUI.lck");
|
||||
private static final long SECONDS=30;
|
||||
|
||||
public static void main(String[] args) {
|
||||
log.info("Thanks for using CustomSkinLoader!");
|
||||
log.info("Version "+VERSION+" !");
|
||||
long dt=System.currentTimeMillis()-SECONDS*1000;
|
||||
if(LCK.exists()&&LCK.lastModified()>=dt){
|
||||
log.info("Sorry! GUI has already been running!");
|
||||
log.info("If you believe it is a mistake, please delete 'GUI.lck'.");
|
||||
}else{
|
||||
LCK.delete();
|
||||
try {
|
||||
LCK.createNewFile();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
LCK.deleteOnExit();
|
||||
MainFrame mf=new MainFrame();
|
||||
mf.init(args);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
package idv.jlchntoz;
|
||||
|
||||
public class Version {
|
||||
private String version;
|
||||
private long longVersion;
|
||||
|
||||
public Version(String version){
|
||||
this.version=version;
|
||||
longVersion=getLongVersion(version);
|
||||
}
|
||||
private long getLongVersion(String version){
|
||||
String[] temp=version.split("\\.");
|
||||
//System.out.println(version);
|
||||
long multi=1;
|
||||
long temp1=0;
|
||||
for(int i=temp.length-1;i>=0;i--){
|
||||
//System.out.println(temp[i]);
|
||||
temp1+=Integer.parseInt(temp[i])*multi;
|
||||
multi*=100;
|
||||
}
|
||||
//System.out.println(temp1);
|
||||
return temp1;
|
||||
}
|
||||
|
||||
public String getVersion(){
|
||||
return version;
|
||||
}
|
||||
public long getLongVersion(){
|
||||
return longVersion;
|
||||
}
|
||||
|
||||
public boolean isNewerThan(Version compareVersion){
|
||||
return longVersion>compareVersion.getLongVersion();
|
||||
}
|
||||
public boolean isNewerThan(String compareVersion){
|
||||
return longVersion>getLongVersion(compareVersion);
|
||||
}
|
||||
|
||||
public boolean isNewerThanOrEquals(Version compareVersion){
|
||||
return longVersion>=compareVersion.getLongVersion();
|
||||
}
|
||||
public boolean isNewerThanOrEquals(String compareVersion){
|
||||
return longVersion>=getLongVersion(compareVersion);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,148 @@
|
||||
package idv.jlchntoz.gui;
|
||||
|
||||
import idv.jlchntoz.Version;
|
||||
import idv.jlchntoz.lang.ILanguage;
|
||||
import idv.jlchntoz.lang.LangManager;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.awt.Container;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.Font;
|
||||
import java.awt.Toolkit;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.JFrame;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.WindowConstants;
|
||||
|
||||
public class MainFrame {
|
||||
private static final ILanguage lang=LangManager.getLanguage();
|
||||
public Version patchVersion=new Version("1.0");
|
||||
public static boolean useDataFolder=false;
|
||||
|
||||
public static final Color bg2=new Color(244, 243, 222, 255);
|
||||
public static final Color bg3=new Color(190, 173, 146, 150);
|
||||
public static final Color bg5=new Color(91, 73, 70, 255);
|
||||
|
||||
public static final Font defaultBigFont=new Font("΢ÈíÑźÚ", Font.BOLD, 30);
|
||||
public static final Font defaultSmallFont=new Font("΢ÈíÑźÚ", Font.PLAIN, 15);
|
||||
public static final Font defaultSmallerFont=new Font("΢ÈíÑźÚ", Font.PLAIN, 13);
|
||||
public static final Font englishBigFont=new Font("Comic Sans MS", Font.BOLD, 30);
|
||||
public static final Font englishSmallFont=new Font("Comic Sans MS", Font.PLAIN, 15);
|
||||
|
||||
public void init(String[] args) {
|
||||
|
||||
JFrame jf = new JFrame (lang.title()+lang.gui());
|
||||
Container con = jf.getContentPane();
|
||||
con.setLayout(null);
|
||||
//setBounds(x,y,width,height)
|
||||
int windowWidth = 400;
|
||||
int windowHeight = 300;
|
||||
Toolkit kit = Toolkit.getDefaultToolkit();
|
||||
Dimension screenSize = kit.getScreenSize();
|
||||
int screenWidth = screenSize.width;
|
||||
int screenHeight = screenSize.height;
|
||||
jf.setBounds(screenWidth / 2 - windowWidth / 2, screenHeight / 2 - windowHeight / 2,
|
||||
windowWidth , windowHeight);
|
||||
|
||||
con.setBackground(bg2);
|
||||
|
||||
JLabel title=new JLabel();
|
||||
title.setForeground(bg5);
|
||||
title.setHorizontalAlignment(JLabel.CENTER);
|
||||
title.setText(lang.title()+lang.index());
|
||||
if(LangManager.langCode.equalsIgnoreCase("en"))
|
||||
title.setFont(englishBigFont);
|
||||
else
|
||||
title.setFont(defaultBigFont);
|
||||
title.setBounds(15, 5, 370, 40);
|
||||
con.add(title);
|
||||
|
||||
if(args.length>0 && args[0].equalsIgnoreCase("f")){
|
||||
JLabel tip1=new JLabel();
|
||||
tip1.setForeground(bg5);
|
||||
tip1.setHorizontalAlignment(JLabel.CENTER);
|
||||
tip1.setText(lang.first1());
|
||||
tip1.setBounds(10, 50, 370, 20);
|
||||
if(LangManager.langCode.equalsIgnoreCase("en"))
|
||||
tip1.setFont(englishSmallFont);
|
||||
else
|
||||
tip1.setFont(defaultSmallFont);
|
||||
con.add(tip1);
|
||||
|
||||
JLabel tip2=new JLabel();
|
||||
tip2.setForeground(bg5);
|
||||
tip2.setHorizontalAlignment(JLabel.CENTER);
|
||||
tip2.setText(lang.first2());
|
||||
tip2.setBounds(10, 70, 370, 20);
|
||||
if(LangManager.langCode.equalsIgnoreCase("en"))
|
||||
tip2.setFont(englishSmallFont);
|
||||
else
|
||||
tip2.setFont(defaultSmallFont);
|
||||
con.add(tip2);
|
||||
}
|
||||
if(args.length>1){
|
||||
patchVersion=new Version(args[1]);
|
||||
if(patchVersion.isNewerThanOrEquals("12.1"))
|
||||
useDataFolder=true;
|
||||
JLabel tip3=new JLabel();
|
||||
tip3.setForeground(bg5);
|
||||
tip3.setHorizontalAlignment(JLabel.CENTER);
|
||||
tip3.setText(lang.yourVersion()+" "+args[1]);
|
||||
tip3.setBounds(10, 100, 370, 20);
|
||||
if(LangManager.langCode.equalsIgnoreCase("en"))
|
||||
tip3.setFont(englishSmallFont);
|
||||
else
|
||||
tip3.setFont(defaultSmallFont);
|
||||
con.add(tip3);
|
||||
}
|
||||
|
||||
JButton skinBtn=new JButton();
|
||||
skinBtn.setForeground(bg5);
|
||||
skinBtn.setBackground(bg3);
|
||||
skinBtn.setText(lang.skin()+lang.loadList());
|
||||
skinBtn.setBounds(15, 180, 370, 30);
|
||||
if(LangManager.langCode.equalsIgnoreCase("en"))
|
||||
skinBtn.setFont(englishSmallFont);
|
||||
else
|
||||
skinBtn.setFont(defaultSmallFont);
|
||||
con.add(skinBtn);
|
||||
skinBtn.addActionListener(new ActionListener(){
|
||||
@Override
|
||||
public void actionPerformed (ActionEvent e){
|
||||
String[] aa={"skin"};
|
||||
SkinFrame.main(aa);
|
||||
};
|
||||
});
|
||||
|
||||
JButton cloakBtn=new JButton();
|
||||
cloakBtn.setForeground(bg5);
|
||||
cloakBtn.setBackground(bg3);
|
||||
cloakBtn.setText(lang.cloak()+lang.loadList());
|
||||
cloakBtn.setBounds(15, 215, 370, 30);
|
||||
if(LangManager.langCode.equalsIgnoreCase("en"))
|
||||
cloakBtn.setFont(englishSmallFont);
|
||||
else
|
||||
cloakBtn.setFont(defaultSmallFont);
|
||||
con.add(cloakBtn);
|
||||
cloakBtn.addActionListener(new ActionListener(){
|
||||
@Override
|
||||
public void actionPerformed (ActionEvent e){
|
||||
String[] aa={"cape"};
|
||||
SkinFrame.main(aa);
|
||||
};
|
||||
});
|
||||
|
||||
|
||||
jf.setVisible(true);
|
||||
if(args.length>=3&&args[2].equalsIgnoreCase("in")){
|
||||
jf.setDefaultCloseOperation(WindowConstants.HIDE_ON_CLOSE);
|
||||
}else{
|
||||
jf.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
|
||||
}
|
||||
jf.setResizable(false);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,244 @@
|
||||
package idv.jlchntoz.gui;
|
||||
|
||||
import idv.jlchntoz.lang.ILanguage;
|
||||
import idv.jlchntoz.lang.LangManager;
|
||||
|
||||
import java.awt.Container;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.Toolkit;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
import java.io.FileReader;
|
||||
import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.JFrame;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JOptionPane;
|
||||
import javax.swing.JTextArea;
|
||||
import javax.swing.WindowConstants;
|
||||
|
||||
public class SkinFrame {
|
||||
private static ILanguage lang=LangManager.getLanguage();
|
||||
public static boolean mod=false;
|
||||
private static String to="skin";
|
||||
|
||||
public static final String[] urls0={
|
||||
"#"+lang.minecraftOffical(),
|
||||
"http://skins.minecraft.net/MinecraftSkins/*.png",
|
||||
"http://s3.amazonaws.com/MinecraftSkins/*.png",
|
||||
"#MineCrack",
|
||||
"http://minecrack.fr.nf/mc/skinsminecrackd/*.png",
|
||||
/*
|
||||
* XFL03's Skin Website Closed
|
||||
"#OpenSkin",
|
||||
"http://skin.axdt.net/MinecraftSkins/*.png",
|
||||
*/
|
||||
"#SkinMe",
|
||||
"http://www.skinme.cc:88/MinecraftSkins/*.png"
|
||||
|
||||
};
|
||||
public static final String[] urls1={
|
||||
"#"+lang.minecraftOffical(),
|
||||
"http://skins.minecraft.net/MinecraftCloaks/*.png",
|
||||
"http://s3.amazonaws.com/MinecraftCloaks/*.png",
|
||||
"#Optifine",
|
||||
"http://s.optifine.net/capes/*.png",
|
||||
"#MineCrack",
|
||||
"http://minecrack.fr.nf/mc/cloaksminecrackd/*.png",
|
||||
/*
|
||||
* XFL03's Skin Website Closed
|
||||
"#OpenSkin",
|
||||
"http://skin.axdt.net/MinecraftCloaks/*.png",
|
||||
*/
|
||||
"#SkinMe",
|
||||
"http://www.skinme.cc:88/MinecraftCloaks/*.png"
|
||||
|
||||
};
|
||||
|
||||
public static void main(String[] args) {
|
||||
if(args.length>0)
|
||||
to=args[0];
|
||||
final String[] urls;
|
||||
String ti="";
|
||||
if(to.equalsIgnoreCase("cape")){
|
||||
urls=urls1;
|
||||
ti=lang.cloak();
|
||||
}else{
|
||||
urls=urls0;
|
||||
ti=lang.skin();
|
||||
}
|
||||
final JFrame jf = new JFrame (lang.title()+" - "+ti+lang.loadList());
|
||||
Container con = jf.getContentPane();
|
||||
con.setLayout(null);
|
||||
con.setBackground(MainFrame.bg2);
|
||||
int windowWidth = 507;
|
||||
int windowHeight = 420;
|
||||
Toolkit kit = Toolkit.getDefaultToolkit();
|
||||
Dimension screenSize = kit.getScreenSize();
|
||||
int screenWidth = screenSize.width;
|
||||
int screenHeight = screenSize.height;
|
||||
jf.setBounds(screenWidth / 2 - windowWidth / 2, screenHeight / 2 - windowHeight / 2, windowWidth , windowHeight);
|
||||
|
||||
JLabel title=new JLabel();
|
||||
title.setForeground(MainFrame.bg5);
|
||||
title.setHorizontalAlignment(JLabel.CENTER);
|
||||
title.setText(ti+lang.loadList());
|
||||
if(LangManager.langCode.equalsIgnoreCase("en"))
|
||||
title.setFont(MainFrame.englishBigFont);
|
||||
else
|
||||
title.setFont(MainFrame.defaultBigFont);
|
||||
title.setBounds(10, 5, 480, 30);
|
||||
con.add(title);
|
||||
|
||||
final JTextArea skinList=new JTextArea();
|
||||
skinList.setBounds(15, 45, 470, 260);
|
||||
skinList.setFont(MainFrame.defaultSmallerFont);
|
||||
skinList.setForeground(MainFrame.bg5);
|
||||
con.add(skinList);
|
||||
File temp0=new File("CustomSkinLoader/"+to+"urls.txt");
|
||||
if(temp0.exists())
|
||||
skinList.setText(read(temp0));
|
||||
else{
|
||||
|
||||
skinList.setText(read(new File(""+to+"urls.txt")));
|
||||
}
|
||||
|
||||
JButton defaultBtn=new JButton();
|
||||
defaultBtn.setText(lang.useDefault());
|
||||
defaultBtn.setBounds(15, 310, 233, 30);
|
||||
defaultBtn.setForeground(MainFrame.bg5);
|
||||
defaultBtn.setBackground(MainFrame.bg3);
|
||||
if(LangManager.langCode.equalsIgnoreCase("en"))
|
||||
defaultBtn.setFont(MainFrame.englishSmallFont);
|
||||
else
|
||||
defaultBtn.setFont(MainFrame.defaultSmallFont);
|
||||
con.add(defaultBtn);
|
||||
defaultBtn.addActionListener(new ActionListener(){
|
||||
@Override
|
||||
public void actionPerformed (ActionEvent e){
|
||||
String temp="";
|
||||
for(int i=0;i<=2;i++)
|
||||
temp+=urls[i]+"\r\n";
|
||||
skinList.setText(temp);
|
||||
};
|
||||
});
|
||||
JButton urlBtn=new JButton();
|
||||
urlBtn.setText(lang.useRecommended());
|
||||
urlBtn.setBounds(252, 310, 235, 30);
|
||||
urlBtn.setForeground(MainFrame.bg5);
|
||||
urlBtn.setBackground(MainFrame.bg3);
|
||||
if(LangManager.langCode.equalsIgnoreCase("en"))
|
||||
urlBtn.setFont(MainFrame.englishSmallFont);
|
||||
else
|
||||
urlBtn.setFont(MainFrame.defaultSmallFont);
|
||||
con.add(urlBtn);
|
||||
urlBtn.addActionListener(new ActionListener(){
|
||||
@Override
|
||||
public void actionPerformed (ActionEvent e){
|
||||
String temp=skinList.getText()+"\r\n";
|
||||
if(temp.equalsIgnoreCase("\r\n")){
|
||||
temp="";
|
||||
}
|
||||
for(int i=0;i<urls.length;i++)
|
||||
temp+=urls[i]+"\r\n";
|
||||
skinList.setText(temp);
|
||||
};
|
||||
});
|
||||
|
||||
|
||||
JButton saveBtn=new JButton();
|
||||
saveBtn.setText(lang.save());
|
||||
saveBtn.setBounds(15, 350, 233, 30);
|
||||
saveBtn.setForeground(MainFrame.bg5);
|
||||
saveBtn.setBackground(MainFrame.bg3);
|
||||
if(LangManager.langCode.equalsIgnoreCase("en"))
|
||||
saveBtn.setFont(MainFrame.englishSmallFont);
|
||||
else
|
||||
saveBtn.setFont(MainFrame.defaultSmallFont);
|
||||
con.add(saveBtn);
|
||||
saveBtn.addActionListener(new ActionListener(){
|
||||
@Override
|
||||
public void actionPerformed (ActionEvent e){
|
||||
save(skinList.getText());
|
||||
JOptionPane.showMessageDialog(null,lang.saved());
|
||||
};
|
||||
});
|
||||
|
||||
JButton closeBtn=new JButton();
|
||||
closeBtn.setText(lang.close());
|
||||
closeBtn.setBounds(252, 350, 235, 30);
|
||||
closeBtn.setForeground(MainFrame.bg5);
|
||||
closeBtn.setBackground(MainFrame.bg3);
|
||||
if(LangManager.langCode.equalsIgnoreCase("en"))
|
||||
closeBtn.setFont(MainFrame.englishSmallFont);
|
||||
else
|
||||
closeBtn.setFont(MainFrame.defaultSmallFont);
|
||||
con.add(closeBtn);
|
||||
closeBtn.addActionListener(new ActionListener(){
|
||||
@Override
|
||||
public void actionPerformed (ActionEvent e){
|
||||
jf.setVisible(false);
|
||||
};
|
||||
});
|
||||
|
||||
|
||||
jf.setVisible(true);
|
||||
jf.setDefaultCloseOperation(WindowConstants.HIDE_ON_CLOSE);
|
||||
jf.setResizable(false);
|
||||
|
||||
}
|
||||
|
||||
private static void save(String data){
|
||||
File a=new File(to+"urls.txt");
|
||||
File b=new File("CustomSkinLoader/"+to+"urls.txt");
|
||||
//System.out.println(b.getAbsolutePath());
|
||||
try {
|
||||
if(!MainFrame.useDataFolder)
|
||||
a.createNewFile();
|
||||
b.createNewFile();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
if(!MainFrame.useDataFolder)
|
||||
write(a,data);
|
||||
if(b.exists())
|
||||
write(b,data);
|
||||
}
|
||||
|
||||
private static boolean write(File file,String Data){
|
||||
System.out.println("Write to "+file.getAbsolutePath());
|
||||
FileWriter fw=null;
|
||||
try{
|
||||
fw = new FileWriter(file);
|
||||
fw.write(Data,0,Data.length());
|
||||
fw.flush();
|
||||
fw.close();
|
||||
}catch(Exception ex){
|
||||
ex.printStackTrace();
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
private static String read(File file){
|
||||
System.out.println("Read from "+file.getAbsolutePath());
|
||||
BufferedReader br = null;
|
||||
String data="";
|
||||
try {
|
||||
br = new BufferedReader(new FileReader(file));
|
||||
data = br.readLine();
|
||||
while( br.ready()){
|
||||
data += "\r\n"+br.readLine();
|
||||
}
|
||||
br.close();
|
||||
return data;
|
||||
} catch (Exception ex) {
|
||||
return "";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
package idv.jlchntoz.lang;
|
||||
|
||||
|
||||
public class ChineseSimpLang implements ILanguage {
|
||||
public String title(){
|
||||
return "自定义皮肤加载器";
|
||||
}
|
||||
public String gui(){
|
||||
return " 图形化界面";
|
||||
}
|
||||
public String index(){
|
||||
return " 索引";
|
||||
}
|
||||
public String first1(){
|
||||
return "这是您第一次使用自定义皮肤加载器!";
|
||||
}
|
||||
public String first2(){
|
||||
return "请点击下列按钮以修改设置!";
|
||||
}
|
||||
public String skin(){
|
||||
return "皮肤";
|
||||
}
|
||||
public String cloak(){
|
||||
return "披风";
|
||||
}
|
||||
public String loadList(){
|
||||
return "加载列表";
|
||||
}
|
||||
public String minecraftOffical(){
|
||||
return "Minecraft 官方[正版]";
|
||||
}
|
||||
public String useDefault(){
|
||||
return "使用默认(官方)";
|
||||
}
|
||||
public String useRecommended(){
|
||||
return "使用推荐";
|
||||
}
|
||||
public String save(){
|
||||
return "保存";
|
||||
}
|
||||
public String saved(){
|
||||
return "已保存,请重新启动游戏!";
|
||||
}
|
||||
public String close(){
|
||||
return "关闭";
|
||||
}
|
||||
public String yourVersion(){
|
||||
return "您的皮肤模组版本:";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
package idv.jlchntoz.lang;
|
||||
|
||||
|
||||
public class ChineseTranLang implements ILanguage {
|
||||
public String title(){
|
||||
return "萬用皮膚模組";
|
||||
}
|
||||
public String gui(){
|
||||
return " 用戶界面";
|
||||
}
|
||||
public String index(){
|
||||
return " 目錄";
|
||||
}
|
||||
public String first1(){
|
||||
return "這是您第一次使用本模組!";
|
||||
}
|
||||
public String first2(){
|
||||
return "請單擊下列按鈕進行配置修改!";
|
||||
}
|
||||
public String skin(){
|
||||
return "皮膚";
|
||||
}
|
||||
public String cloak(){
|
||||
return "披風";
|
||||
}
|
||||
public String loadList(){
|
||||
return "加載列表";
|
||||
}
|
||||
public String minecraftOffical(){
|
||||
return "Minecraft 官方[正版]";
|
||||
}
|
||||
public String useDefault(){
|
||||
return "使用默認(官方)";
|
||||
}
|
||||
public String useRecommended(){
|
||||
return "使用推薦";
|
||||
}
|
||||
public String save(){
|
||||
return "保存";
|
||||
}
|
||||
public String saved(){
|
||||
return "已保存,請重新開啟遊戲!";
|
||||
}
|
||||
public String close(){
|
||||
return "關閉";
|
||||
}
|
||||
public String yourVersion(){
|
||||
return "您的皮膚模組版本:";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
package idv.jlchntoz.lang;
|
||||
|
||||
public class EnglishLang implements ILanguage{
|
||||
public String title(){
|
||||
return "CustomSkinLoader";
|
||||
}
|
||||
public String gui(){
|
||||
return " GUI";
|
||||
}
|
||||
public String index(){
|
||||
return " Index";
|
||||
}
|
||||
public String first1(){
|
||||
return "It's your first time use CustomSkinLoader!";
|
||||
}
|
||||
public String first2(){
|
||||
return "Please click buttons below to modify config!";
|
||||
}
|
||||
public String skin(){
|
||||
return "Skin";
|
||||
}
|
||||
public String cloak(){
|
||||
return "Cloak";
|
||||
}
|
||||
public String loadList(){
|
||||
return " Load List";
|
||||
}
|
||||
public String minecraftOffical(){
|
||||
return "Minecraft Offical";
|
||||
}
|
||||
public String useDefault(){
|
||||
return "Use Default(Offical)";
|
||||
}
|
||||
public String useRecommended(){
|
||||
return "Use Recommended";
|
||||
}
|
||||
public String save(){
|
||||
return "Save";
|
||||
}
|
||||
public String saved(){
|
||||
return "Saved!Restart the game, please!";
|
||||
}
|
||||
public String close(){
|
||||
return "Close";
|
||||
}
|
||||
public String yourVersion(){
|
||||
return "Your CustomSkinLoader Version:";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
package idv.jlchntoz.lang;
|
||||
|
||||
public interface ILanguage {
|
||||
public String title();
|
||||
public String gui();
|
||||
public String index();
|
||||
public String first1();
|
||||
public String first2();
|
||||
public String skin();
|
||||
public String cloak();
|
||||
public String loadList();
|
||||
public String minecraftOffical();
|
||||
public String useDefault();
|
||||
public String useRecommended();
|
||||
public String save();
|
||||
public String saved();
|
||||
public String close();
|
||||
public String yourVersion();
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
package idv.jlchntoz.lang;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
public class LangManager {
|
||||
public static String langCode="en";
|
||||
public static ILanguage getLanguage(){
|
||||
Locale locale = Locale.getDefault();
|
||||
String l=locale.getLanguage().toLowerCase();
|
||||
String c=locale.getCountry().toLowerCase();
|
||||
if(l.equalsIgnoreCase("zh")){
|
||||
if(c.equalsIgnoreCase("cn")){
|
||||
//zh_cn
|
||||
langCode="zh_cn";
|
||||
return new ChineseSimpLang();
|
||||
}
|
||||
//zh
|
||||
langCode="zh";
|
||||
return new ChineseTranLang();
|
||||
}
|
||||
//en
|
||||
langCode="en";
|
||||
return new EnglishLang();
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user