Skip to content

Commit

Permalink
Added more debugging stuff. Unified build method, now use jardesc ins…
Browse files Browse the repository at this point in the history
…tead of batch files
  • Loading branch information
download13 committed Aug 23, 2012
1 parent 1147f05 commit 5aa5ce7
Show file tree
Hide file tree
Showing 11 changed files with 52 additions and 43 deletions.
2 changes: 1 addition & 1 deletion .classpath
@@ -1,6 +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.6"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
<classpathentry kind="output" path="bin"/>
</classpath>
2 changes: 1 addition & 1 deletion .gitignore
@@ -1,4 +1,4 @@
*.jar
*.class
bin/
.settings/
debug.txt
6 changes: 3 additions & 3 deletions .settings/org.eclipse.jdt.core.prefs
@@ -1,11 +1,11 @@
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
org.eclipse.jdt.core.compiler.compliance=1.6
org.eclipse.jdt.core.compiler.compliance=1.5
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.6
org.eclipse.jdt.core.compiler.source=1.5
16 changes: 16 additions & 0 deletions Build.jardesc
@@ -0,0 +1,16 @@
<?xml version="1.0" encoding="WINDOWS-1252" standalone="no"?>
<jardesc>
<jar path="C:/Users/download/Desktop/Mineshafter-proxy.jar"/>
<options buildIfNeeded="true" compress="true" descriptionLocation="/Mineshafter Client/Build.jardesc" exportErrors="false" exportWarnings="true" includeDirectoryEntries="false" overwrite="false" saveDescription="true" storeRefactorings="false" useSourceFolders="false"/>
<storedRefactorings deprecationInfo="true" structuralOnly="false"/>
<selectedProjects/>
<manifest generateManifest="true" mainClassHandleIdentifier="=Mineshafter Client/src&lt;mineshafter{MineClient.java[MineClient" manifestLocation="/Mineshafter registration plugin/MANIFEST.MF" manifestVersion="1.0" reuseManifest="false" saveManifest="false" usesManifest="true">
<sealing sealJar="false">
<packagesToSeal/>
<packagesToUnSeal/>
</sealing>
</manifest>
<selectedElements exportClassFiles="true" exportJavaFiles="false" exportOutputFolder="false">
<javaElement handleIdentifier="=Mineshafter Client/src"/>
</selectedElements>
</jardesc>
5 changes: 0 additions & 5 deletions build_client.bat

This file was deleted.

3 changes: 0 additions & 3 deletions build_server.bat

This file was deleted.

2 changes: 0 additions & 2 deletions debug.bat

This file was deleted.

16 changes: 11 additions & 5 deletions src/mineshafter/MineClient.java
Expand Up @@ -27,7 +27,7 @@
public class MineClient extends Applet {
private static final long serialVersionUID = 1L;

protected static float VERSION = 3.6f;
protected static float VERSION = 3.7f;

protected static String launcherDownloadURL = "https://s3.amazonaws.com/MinecraftDownload/launcher/minecraft.jar"; // "http://www.minecraft.net/download/minecraft.jar";
protected static String normalLauncherFilename = "minecraft.jar";
Expand Down Expand Up @@ -70,10 +70,11 @@ public static void main(String[] args) {
proxy.start();
int proxyPort = proxy.getPort();

System.setErr(System.out);

System.setProperty("http.proxyHost", "127.0.0.1");
System.setProperty("http.proxyPort", Integer.toString(proxyPort));
//System.setProperty("https.proxyHost", "127.0.0.1");
//System.setProperty("https.proxyPort", Integer.toString(proxyPort));
System.setProperty("java.net.preferIPv4Stack", "true");

// Make sure we have a fresh launcher every time
File hackedFile = new File(hackedLauncherFilename);
Expand Down Expand Up @@ -136,10 +137,15 @@ public static void editLauncher() {
InputStream dataSource;
while((entry = in.getNextEntry()) != null) {
n = entry.getName();
if(n.contains(".svn") || n.equals("META-INF/MOJANG_C.SF") || n.equals("META-INF/MOJANG_C.DSA") || n.equals("net/minecraft/minecraft.key") || n.equals("net/minecraft/Util$OS.class")) continue;
if(n.contains(".svn")
|| n.equals("META-INF/MOJANG_C.SF")
|| n.equals("META-INF/MOJANG_C.DSA")
|| n.equals("net/minecraft/minecraft.key")
|| n.equals("net/minecraft/Util$OS.class")) continue;

out.putNextEntry(entry);
if(n.equals("META-INF/MANIFEST.MF")) dataSource = new ByteArrayInputStream(MANIFEST_TEXT.getBytes());
else if(n.equals("net/minecraft/Util.class")) dataSource = Resources.load("Util.class");
else if(n.equals("net/minecraft/Util.class")) dataSource = Resources.load("net/minecraft/Util.class");
else dataSource = in;
Streams.pipeStreams(dataSource, out);
out.flush();
Expand Down
26 changes: 14 additions & 12 deletions src/mineshafter/proxy/MineProxyHandler.java
Expand Up @@ -278,46 +278,48 @@ public void run() {

public static byte[] getRequest(String url) {
try {
HttpURLConnection c = (HttpURLConnection) new URL(url).openConnection(Proxy.NO_PROXY);
c.setInstanceFollowRedirects(false);
int code = c.getResponseCode();
HttpURLConnection conn = (HttpURLConnection) new URL(url).openConnection(Proxy.NO_PROXY);
conn.setInstanceFollowRedirects(false);
Map<String, List<String>> requestHeaders = conn.getRequestProperties();
int code = conn.getResponseCode();

if(code == 301 || code == 302 || code == 303) {
System.out.println("Java didn't redirect automatically, going manual: " + Integer.toString(code));
String l = c.getHeaderField("location").trim();
String l = conn.getHeaderField("location").trim();
System.out.println("Manual redirection to: " + l);
return getRequest(l);
}

System.out.println("Response: " + code);
if(code == 403) {
String s = "403 from req to " + url + "\nRequest headers:\n";
java.util.Map<String, java.util.List<String>> h = c.getRequestProperties();
for (String k : h.keySet()) {

for (String k : requestHeaders.keySet()) {
if(k == null) continue;
java.util.List<String> vals = h.get(k);
java.util.List<String> vals = requestHeaders.get(k);
for(String v : vals) {
s += k + ": " + v + "\n";
}
}

s += "Response headers:\n";
h = c.getHeaderFields();
for (String k : h.keySet()) {
Map<String, List<String>> responseHeaders = conn.getHeaderFields();
for (String k : responseHeaders.keySet()) {
if(k == null) continue;
java.util.List<String> vals = h.get(k);
java.util.List<String> vals = responseHeaders.get(k);
for(String v : vals) {
s += k + ": " + v + "\n";
}
}

System.out.println(s);
System.out.println("Contents:\n" + new String(grabData(c.getErrorStream())));
System.out.println("Contents:\n" + new String(grabData(conn.getErrorStream())));
}

if(code / 100 == 4) {
return new byte[0];
}
BufferedInputStream in = new BufferedInputStream(c.getInputStream());
BufferedInputStream in = new BufferedInputStream(conn.getInputStream());
return grabData(in);

} catch (MalformedURLException e) {
Expand Down
11 changes: 5 additions & 6 deletions src/mineshafter/util/Resources.java
Expand Up @@ -8,14 +8,13 @@

public class Resources
{
public static InputStream load(String filename) throws FileNotFoundException
{
InputStream in=Thread.currentThread().getContextClassLoader().getResourceAsStream(filename);
if(in==null) in=new FileInputStream(filename);
public static InputStream load(String filename) throws FileNotFoundException {
InputStream in = Thread.currentThread().getContextClassLoader().getResourceAsStream(filename);
if(in == null) in = new FileInputStream(filename);
return in;
}
public static String loadString(String filename)
{

public static String loadString(String filename) {
try{
char[] b=new char[4096];
int read=0;
Expand Down
6 changes: 1 addition & 5 deletions Util.java → src/net/minecraft/Util.java
@@ -1,7 +1,6 @@
package net.minecraft;

import java.io.BufferedOutputStream;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.InputStream;
Expand All @@ -12,9 +11,6 @@
import java.net.URLEncoder;
import java.net.HttpURLConnection;
import java.util.Map;
import javax.net.ssl.HttpsURLConnection;

import org.omg.CORBA_2_3.portable.OutputStream;

public class Util {
private static File workDir=null;
Expand Down Expand Up @@ -60,7 +56,7 @@ private static int getPlatform() {
public static String buildQuery(Map<String, Object> paramMap) {
StringBuilder localStringBuilder = new StringBuilder();

for(Map.Entry localEntry : paramMap.entrySet()) {
for(Map.Entry<String, Object> localEntry : paramMap.entrySet()) {
if(localStringBuilder.length() > 0) {
localStringBuilder.append('&');
}
Expand Down

0 comments on commit 5aa5ce7

Please sign in to comment.