Fixed achievements/stats not saving

This commit is contained in:
PeytonPlayz595 2024-09-08 14:47:12 -07:00
parent 8d49882f4a
commit ac791ee6fa
16 changed files with 24078 additions and 23443 deletions

1
.gitignore vendored
View File

@ -1,3 +1,4 @@
/.gradle/
/output/
/filesystem/
build/*

File diff suppressed because it is too large Load Diff

View File

@ -14,8 +14,178 @@ private static final java.io.File filesystemBaseDirectory = new java.io.File("fi
filesystemBaseDirectory.mkdirs();
}
private String path;
private transient int prefixLength;
private final char slash = '/';
private static final String pathSeperator = "/";
private static final String[] altPathSeperator = new String[] { "\\" };
public File(String pathName) {
if (pathName == null) {
throw new NullPointerException();
}
this.path = this.normalize(pathName);
this.prefixLength = this.prefixLength(this.path);
}
public File(String parent, String child) {
if (child == null) {
throw new NullPointerException();
}
if(parent != null) {
this.path = this.createPath(parent, child);
} else {
this.path = this.normalize(child);
}
}
public File(File parent, String child) {
if (child == null) {
throw new NullPointerException();
}
if(parent != null) {
this.path = this.createPath(parent.path, child);
} else {
this.path = this.normalize(child);
}
}
private int prefixLength(String path) {
char slash = this.slash;
int n = path.length();
if (n == 0) return 0;
char c0 = path.charAt(0);
char c1 = (n > 1) ? path.charAt(1) : 0;
if (c0 == slash) {
if (c1 == slash) return 2;
return 1;
}
if (isLetter(c0) && (c1 == ':')) {
if ((n > 2) && (path.charAt(2) == slash))
return 3;
return 2;
}
return 0;
}
private boolean isLetter(char c) {
return ((c >= 'a') && (c <= 'z')) || ((c >= 'A') && (c <= 'Z'));
}
private String normalize(String p) {
for(int i = 0; i < altPathSeperator.length; ++i) {
p = p.replace(altPathSeperator[i], pathSeperator);
}
if(p.startsWith(pathSeperator)) {
p = p.substring(1);
}
if(p.endsWith(pathSeperator)) {
p = p.substring(0, p.length() - pathSeperator.length());
}
return p;
}
private String[] splitPath(String p) {
String[] pth = normalize(p).split(pathSeperator);
for(int i = 0; i < pth.length; ++i) {
pth[i] = pth[i].trim();
}
return pth;
}
private String createPath(Object... p) {
ArrayList<String> r = new ArrayList();
for(int i = 0; i < p.length; ++i) {
if(p[i] == null) {
continue;
}
String gg = p[i].toString();
if(gg == null) {
continue;
}
String[] parts = splitPath(gg);
for(int j = 0; j < parts.length; ++j) {
if(parts[j] == null || parts[j].equals(".")) {
continue;
}else if(parts[j].equals("..") && r.size() > 0) {
int k = r.size() - 1;
if(!r.get(k).equals("..")) {
r.remove(k);
}else {
r.add("..");
}
}else {
r.add(parts[j]);
}
}
}
if(r.size() > 0) {
StringBuilder s = new StringBuilder();
for(int i = 0; i < r.size(); ++i) {
if(i > 0) {
s.append(pathSeperator);
}
s.append(r.get(i));
}
return s.toString();
}else {
return null;
}
}
// ======== Virtual Filesystem Functions =============
public String getName() {
int index = path.lastIndexOf(slash);
if (index < prefixLength) return path.substring(prefixLength);
return path.substring(index + 1);
}
public String getPath() {
return path;
}
public boolean exists() {
return exists(path);
}
public boolean isDirectory() {
return exists(path) && directoryExists(path);
}
public void renameTo(File newPath) {
renameFile(path, newPath.path);
}
public byte[] read() {
return readFile(path);
}
public void write(byte[] data) {
writeFile(path, data);
}
public void delete() {
deleteFile(path);
}
public void mkdir() {
(new java.io.File(filesystemBaseDirectory, stripPath(path))).mkdir();
}
public File[] listFiles() {
Collection<FileEntry> collection = listFiles(path, false, false);
int size = collection.size();
FileEntry[] entries = collection.toArray(new FileEntry[size]);
File[] files = new File[size];
for(int i = 0; i < size; i++) {
files[i] = new File(entries[i].path);
}
return files;
}
public static final boolean exists(String path) {
return (new java.io.File(filesystemBaseDirectory, stripPath(path))).exists();
}

View File

@ -0,0 +1,47 @@
package net.PeytonPlayz585.io;
import java.io.IOException;
import java.io.Reader;
public abstract class FilterReader extends Reader {
protected Reader in;
protected FilterReader(Reader in) {
super(in);
this.in = in;
}
public int read() throws IOException {
return in.read();
}
public int read(char cbuf[], int off, int len) throws IOException {
return in.read(cbuf, off, len);
}
public long skip(long n) throws IOException {
return in.skip(n);
}
public boolean ready() throws IOException {
return in.ready();
}
public boolean markSupported() {
return in.markSupported();
}
public void mark(int readAheadLimit) throws IOException {
in.mark(readAheadLimit);
}
public void reset() throws IOException {
in.reset();
}
public void close() throws IOException {
in.close();
}
}

View File

@ -0,0 +1,140 @@
package net.PeytonPlayz585.io;
import java.io.IOException;
import java.io.Reader;
public class PushbackReader extends FilterReader {
private char[] buf;
private int pos;
public PushbackReader(Reader in, int size) {
super(in);
if (size <= 0) {
throw new IllegalArgumentException("size <= 0");
}
this.buf = new char[size];
this.pos = size;
}
public PushbackReader(Reader in) {
this(in, 1);
}
private void ensureOpen() throws IOException {
if (buf == null)
throw new IOException("Stream closed");
}
public int read() throws IOException {
synchronized (lock) {
ensureOpen();
if (pos < buf.length)
return buf[pos++];
else
return super.read();
}
}
public int read(char cbuf[], int off, int len) throws IOException {
synchronized (lock) {
ensureOpen();
try {
if (len <= 0) {
if (len < 0) {
throw new IndexOutOfBoundsException();
} else if ((off < 0) || (off > cbuf.length)) {
throw new IndexOutOfBoundsException();
}
return 0;
}
int avail = buf.length - pos;
if (avail > 0) {
if (len < avail)
avail = len;
System.arraycopy(buf, pos, cbuf, off, avail);
pos += avail;
off += avail;
len -= avail;
}
if (len > 0) {
len = super.read(cbuf, off, len);
if (len == -1) {
return (avail == 0) ? -1 : avail;
}
return avail + len;
}
return avail;
} catch (ArrayIndexOutOfBoundsException e) {
throw new IndexOutOfBoundsException();
}
}
}
public void unread(int c) throws IOException {
synchronized (lock) {
ensureOpen();
if (pos == 0)
throw new IOException("Pushback buffer overflow");
buf[--pos] = (char) c;
}
}
public void unread(char cbuf[], int off, int len) throws IOException {
synchronized (lock) {
ensureOpen();
if (len > pos)
throw new IOException("Pushback buffer overflow");
pos -= len;
System.arraycopy(cbuf, off, buf, pos, len);
}
}
public void unread(char cbuf[]) throws IOException {
unread(cbuf, 0, cbuf.length);
}
public boolean ready() throws IOException {
synchronized (lock) {
ensureOpen();
return (pos < buf.length) || super.ready();
}
}
public void mark(int readAheadLimit) throws IOException {
throw new IOException("mark/reset not supported");
}
public void reset() throws IOException {
throw new IOException("mark/reset not supported");
}
public boolean markSupported() {
return false;
}
public void close() throws IOException {
super.close();
buf = null;
}
public long skip(long n) throws IOException {
if (n < 0L)
throw new IllegalArgumentException("skip value is negative");
synchronized (lock) {
ensureOpen();
int avail = buf.length - pos;
if (avail > 0) {
if (n <= avail) {
pos += n;
return n;
} else {
pos = buf.length;
n -= avail;
}
}
return avail + super.skip(n);
}
}
}

View File

@ -5,7 +5,7 @@ import java.io.Reader;
import java.io.StringReader;
public final class J_JdomParser {
public J_JsonRootNode func_27366_a(String var1) throws IOException, J_InvalidSyntaxException {
public J_JsonRootNode func_27366_a(Reader var1) throws IOException, J_InvalidSyntaxException {
J_JsonListenerToJdomAdapter var2 = new J_JsonListenerToJdomAdapter();
(new J_SajParser()).func_27463_a(var1, var2); //TODO: Find out why this shit crashes
return var2.func_27208_a();
@ -13,7 +13,7 @@ public final class J_JdomParser {
public J_JsonRootNode func_27367_a(String var1) throws J_InvalidSyntaxException {
try {
J_JsonRootNode var2 = this.func_27366_a(var1);
J_JsonRootNode var2 = this.func_27366_a(new StringReader(var1));
return var2;
} catch (IOException var4) {
throw new RuntimeException("Coding failure in Argo: StringWriter gave an IOException", var4);

View File

@ -1,9 +1,9 @@
package net.minecraft.src;
import java.util.LinkedList;
import java.util.Stack;
final class J_JsonListenerToJdomAdapter implements J_JsonListener {
private final LinkedList<J_NodeContainer> field_27210_a = new LinkedList<J_NodeContainer>();
private final Stack field_27210_a = new Stack();
private J_JsonNodeBuilder field_27209_b;
J_JsonRootNode func_27208_a() {

View File

@ -1,20 +1,18 @@
package net.minecraft.src;
import java.io.IOException;
import java.io.Reader;
import net.PeytonPlayz585.io.PushbackReader;
final class J_PositionTrackingPushbackReader implements J_ThingWithPosition {
private String field_27338_a;
private final PushbackReader field_27338_a;
private int field_27337_b = 0;
private int field_27340_c = 1;
private boolean field_27339_d = false;
private int index = 0;
public J_PositionTrackingPushbackReader(String var1) {
if(var1 == null) {
this.field_27338_a = "";
} else {
this.field_27338_a = var1;
}
public J_PositionTrackingPushbackReader(Reader var1) {
this.field_27338_a = new PushbackReader(var1);
}
public void func_27334_a(char var1) throws IOException {
@ -22,7 +20,8 @@ final class J_PositionTrackingPushbackReader implements J_ThingWithPosition {
if(this.field_27337_b < 0) {
this.field_27337_b = 0;
}
index--;
this.field_27338_a.unread(var1);
}
public void func_27335_a(char[] var1) {
@ -30,25 +29,26 @@ final class J_PositionTrackingPushbackReader implements J_ThingWithPosition {
if(this.field_27337_b < 0) {
this.field_27337_b = 0;
}
index -= var1.length;
}
public int func_27333_c() throws IOException {
if (index >= field_27338_a.length()) {
return -1; //EOF reached (I think)
}
char var1 = field_27338_a.charAt(index++);
int var1 = this.field_27338_a.read();
this.func_27332_a(var1);
return var1;
}
public int func_27336_b(char[] var1) throws IOException {
int length = Math.min(var1.length, field_27338_a.length() - index);
for (int i = 0; i < length; i++) {
var1[i] = field_27338_a.charAt(index++);
this.func_27332_a(var1[i]);
int var2 = this.field_27338_a.read(var1);
char[] var3 = var1;
int var4 = var1.length;
for(int var5 = 0; var5 < var4; ++var5) {
char var6 = var3[var5];
this.func_27332_a(var6);
}
return length;
return var2;
}
private void func_27332_a(int var1) {

View File

@ -5,7 +5,7 @@ import java.io.Reader;
import java.util.Arrays;
public final class J_SajParser {
public void func_27463_a(String var1, J_JsonListener var2) throws IOException, J_InvalidSyntaxException {
public void func_27463_a(Reader var1, J_JsonListener var2) throws IOException, J_InvalidSyntaxException {
J_PositionTrackingPushbackReader var3 = new J_PositionTrackingPushbackReader(var1);
char var4 = (char)var3.func_27333_c();
switch(var4) {
@ -26,6 +26,8 @@ public final class J_SajParser {
int var5 = this.func_27448_l(var3);
if(var5 != -1) {
throw new J_InvalidSyntaxException("Got unexpected trailing character [" + (char)var5 + "].", var3);
} else {
var2.func_27204_c();
}
}

View File

@ -1,33 +1,35 @@
package net.minecraft.src;
import net.PeytonPlayz585.fileutils.File;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import net.PeytonPlayz585.fileutils.File;
import net.PeytonPlayz585.fileutils.FileEntry;
public class StatFileWriter {
private Map field_25102_a = new HashMap();
private Map field_25101_b = new HashMap();
private boolean field_27189_c = false;
private StatsSyncher statsSyncher;
public StatFileWriter(Session var1, String var2) {
String var3 = var2 + "/" + "stats";
public StatFileWriter(Session var1, String var2File) {
File var2 = new File(var2File);
File var3 = new File(var2, "stats");
if(!var3.exists()) {
var3.mkdir();
}
FileEntry[] var4 = File.listFiles(var2);
File[] var4 = var2.listFiles();
int var5 = var4.length;
for(int var6 = 0; var6 < var5; ++var6) {
FileEntry var7 = var4[var6];
File var7 = var4[var6];
if(var7.getName().startsWith("stats_") && var7.getName().endsWith(".dat")) {
String var8 = var3 + "/" + var7.getName();
if(!File.exists(var8)) {
File var8 = new File(var3, var7.getName());
if(!var8.exists()) {
System.out.println("Relocating " + var7.getName());
File.renameFile(var7.path, var8);
var7.renameTo(var8);
}
}
}
@ -97,8 +99,8 @@ public class StatFileWriter {
try {
String var2 = "local";
String var3 = "";
J_JsonRootNode var4 = (new J_JdomParser()).func_27367_a(var0); //Crashes!?!?
StringBuilder var3 = new StringBuilder();
J_JsonRootNode var4 = (new J_JdomParser()).func_27367_a(var0);
List var5 = var4.func_27217_b(new Object[]{"stats-change"});
Iterator var6 = var5.iterator();
@ -112,8 +114,8 @@ public class StatFileWriter {
if(var12 == null) {
System.out.println(var10 + " is not a valid stat");
} else {
var3 = var3 + StatList.func_27361_a(var10).statGuid + ",";
var3 = var3 + var11 + ",";
var3.append(StatList.func_27361_a(var10).statGuid).append(",");
var3.append(var11).append(",");
var1.put(var12, Integer.valueOf(var11));
}
}
@ -132,41 +134,41 @@ public class StatFileWriter {
}
public static String func_27185_a(String var0, String var1, Map var2) {
String var3 = "";
String var4 = "";
StringBuilder var3 = new StringBuilder();
StringBuilder var4 = new StringBuilder();
boolean var5 = true;
var3 = var3 + "{\r\n";
var3.append("{\r\n");
if(var0 != null && var1 != null) {
var3 = var3 + " \"user\":{\r\n";
var3 = var3 + " \"name\":\"" + var0 + "\",\r\n";
var3 = var3 + " \"sessionid\":\"" + var1 + "\"\r\n";
var3 = var3 + " },\r\n";
var3.append(" \"user\":{\r\n");
var3.append(" \"name\":\"").append(var0).append("\",\r\n");
var3.append(" \"sessionid\":\"").append(var1).append("\"\r\n");
var3.append(" },\r\n");
}
var3 = var3 + " \"stats-change\":[";
var3.append(" \"stats-change\":[");
Iterator var6 = var2.keySet().iterator();
while(var6.hasNext()) {
StatBase var7 = (StatBase)var6.next();
if(!var5) {
var3 = var3 + "},";
var3.append("},");
} else {
var5 = false;
}
var3 = var3 + "\r\n {\"" + var7.statId + "\":" + var2.get(var7);
var4 = var4 + var7.statGuid + ",";
var4 = var4 + var2.get(var7) + ",";
var3.append("\r\n {\"").append(var7.statId).append("\":").append(var2.get(var7));
var4.append(var7.statGuid).append(",");
var4.append(var2.get(var7)).append(",");
}
if(!var5) {
var3 = var3 + "}";
var3.append("}");
}
MD5String var8 = new MD5String(var1);
var3 = var3 + "\r\n ],\r\n";
var3 = var3 + " \"checksum\":\"" + var8.func_27369_a(var4) + "\"\r\n";
var3 = var3 + "}";
var3.append("\r\n ],\r\n");
var3.append(" \"checksum\":\"").append(var8.func_27369_a(var4.toString())).append("\"\r\n");
var3.append("}");
return var3.toString();
}

View File

@ -3,35 +3,35 @@ package net.minecraft.src;
import java.io.BufferedReader;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import net.PeytonPlayz585.fileutils.File;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Map;
import net.PeytonPlayz585.fileutils.File;
public class StatsSyncher {
private volatile boolean field_27438_a = false;
private volatile Map field_27437_b = null;
private volatile Map field_27436_c = null;
private StatFileWriter field_27435_d;
private String field_27434_e;
private String field_27433_f;
private String field_27432_g;
private String field_27431_h;
private String field_27430_i;
private String field_27429_j;
private File field_27434_e;
private File field_27433_f;
private File field_27432_g;
private File field_27431_h;
private File field_27430_i;
private File field_27429_j;
private Session field_27428_k;
private int field_27427_l = 0;
private int field_27426_m = 0;
public StatsSyncher(Session var1, StatFileWriter var2, String var3) {
this.field_27434_e = makeFilePath(var3, "stats_" + var1.username.toLowerCase() + "_unsent.dat");
this.field_27433_f = makeFilePath(var3, "stats_" + var1.username.toLowerCase() + ".dat");
this.field_27430_i = makeFilePath(var3, "stats_" + var1.username.toLowerCase() + "_unsent.old");
this.field_27429_j = makeFilePath(var3, "stats_" + var1.username.toLowerCase() + ".old");
this.field_27432_g = makeFilePath(var3, "stats_" + var1.username.toLowerCase() + "_unsent.tmp");
this.field_27431_h = makeFilePath(var3, "stats_" + var1.username.toLowerCase() + ".tmp");
public StatsSyncher(Session var1, StatFileWriter var2, File var3) {
this.field_27434_e = new File(var3, "stats_" + var1.username.toLowerCase() + "_unsent.dat");
this.field_27433_f = new File(var3, "stats_" + var1.username.toLowerCase() + ".dat");
this.field_27430_i = new File(var3, "stats_" + var1.username.toLowerCase() + "_unsent.old");
this.field_27429_j = new File(var3, "stats_" + var1.username.toLowerCase() + ".old");
this.field_27432_g = new File(var3, "stats_" + var1.username.toLowerCase() + "_unsent.tmp");
this.field_27431_h = new File(var3, "stats_" + var1.username.toLowerCase() + ".tmp");
if(!var1.username.toLowerCase().equals(var1.username)) {
this.func_28214_a(var3, "stats_" + var1.username + "_unsent.dat", this.field_27434_e);
this.func_28214_a(var3, "stats_" + var1.username + ".dat", this.field_27433_f);
@ -43,53 +43,94 @@ public class StatsSyncher {
this.field_27435_d = var2;
this.field_27428_k = var1;
if(File.exists(this.field_27434_e)) {
if(this.field_27434_e.exists()) {
var2.func_27179_a(this.func_27415_a(this.field_27434_e, this.field_27432_g, this.field_27430_i));
}
this.func_27418_a();
}
private void func_28214_a(String var1, String var2, String var3) {
String var4 = makeFilePath(var1, var2);
if(File.exists(var4) && !File.directoryExists(var4) && !File.exists(var3)) {
File.renameFile(var4, var3);
private void func_28214_a(File var1, String var2, File var3) {
File var4 = new File(var1, var2);
if(var4.exists() && !var4.isDirectory() && !var3.exists()) {
var4.renameTo(var3);
}
}
private Map func_27415_a(String var1, String var2, String var3) {
return File.exists(var1) ? this.func_27408_a(var1) : (File.exists(var3) ? this.func_27408_a(var3) : (File.exists(var2) ? this.func_27408_a(var2) : null));
private Map func_27415_a(File var1, File var2, File var3) {
return var1.exists() ? this.func_27408_a(var1) : (var3.exists() ? this.func_27408_a(var3) : (var2.exists() ? this.func_27408_a(var2) : null));
}
private Map func_27408_a(File var1) {
BufferedReader var2 = null;
try {
ByteArrayInputStream bais = new ByteArrayInputStream(var1.read());
InputStreamReader isr = new InputStreamReader(bais, "UTF-8");
var2 = new BufferedReader(isr);
String var3 = "";
StringBuilder var4 = new StringBuilder();
while(true) {
var3 = var2.readLine();
if(var3 == null) {
Map var5 = StatFileWriter.func_27177_a(var4.toString());
return var5;
}
var4.append(var3);
}
} catch (Exception var15) {
var15.printStackTrace();
} finally {
if(var2 != null) {
try {
var2.close();
} catch (Exception var14) {
var14.printStackTrace();
}
}
}
private Map func_27408_a(String var1) {
byte[] bytes = File.readFile(var1);
if (bytes == null || bytes.length == 0) {
return null;
}
return StatFileWriter.func_27177_a(new String(""));
}
private void func_27410_a(Map var1, String var2, String var3, String var4) throws IOException {
private void func_27410_a(Map var1, File var2, File var3, File var4) throws IOException {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
PrintWriter var5 = new PrintWriter(baos);
try {
var5.print(StatFileWriter.func_27185_a(this.field_27428_k.username, "local", var1));
File.writeFile(var3, baos.toByteArray());
} finally {
var5.flush();
byte[] data = baos.toByteArray();
var3.write(data);
var5.close();
} catch(Exception e) {
var5.close();
System.out.println("Failed to save stats");
e.printStackTrace();
}
if(File.exists(var4)) {
File.deleteFile(var4);
// try {
// var5.print(StatFileWriter.func_27185_a(this.field_27428_k.username, "local", var1));
// var3.write(baos.toByteArray());
// } finally {
// var5.close();
// baos.close();
// }
if(var4.exists()) {
var4.delete();
}
if(File.exists(var2)) {
File.renameFile(var2, var4);
if(var2.exists()) {
var2.renameTo(var4);
}
File.renameFile(var3, var2);
var3.renameTo(var2);
}
public void func_27418_a() {
@ -98,7 +139,18 @@ public class StatsSyncher {
} else {
this.field_27427_l = 100;
this.field_27438_a = true;
(new ThreadStatSyncherReceive(this)).start();
try {
if(StatsSyncher.func_27422_a(this) != null) {
StatsSyncher.func_27412_a(this, StatsSyncher.func_27422_a(this), StatsSyncher.func_27423_b(this), StatsSyncher.func_27411_c(this), StatsSyncher.func_27413_d(this));
} else if(StatsSyncher.func_27423_b(this).exists()) {
StatsSyncher.func_27421_a(this, StatsSyncher.func_27409_a(this, StatsSyncher.func_27423_b(this), StatsSyncher.func_27411_c(this), StatsSyncher.func_27413_d(this)));
}
} catch (Exception var5) {
var5.printStackTrace();
} finally {
StatsSyncher.func_27416_a(this, false);
}
}
}
@ -169,19 +221,19 @@ public class StatsSyncher {
return var0.field_27437_b;
}
static String func_27423_b(StatsSyncher var0) {
static File func_27423_b(StatsSyncher var0) {
return var0.field_27433_f;
}
static String func_27411_c(StatsSyncher var0) {
static File func_27411_c(StatsSyncher var0) {
return var0.field_27431_h;
}
static String func_27413_d(StatsSyncher var0) {
static File func_27413_d(StatsSyncher var0) {
return var0.field_27429_j;
}
static void func_27412_a(StatsSyncher var0, Map var1, String var2, String var3, String var4) throws IOException {
static void func_27412_a(StatsSyncher var0, Map var1, File var2, File var3, File var4) throws IOException {
var0.func_27410_a(var1, var2, var3, var4);
}
@ -189,7 +241,7 @@ public class StatsSyncher {
return var0.field_27437_b = var1;
}
static Map func_27409_a(StatsSyncher var0, String var1, String var2, String var3) {
static Map func_27409_a(StatsSyncher var0, File var1, File var2, File var3) {
return var0.func_27415_a(var1, var2, var3);
}
@ -197,19 +249,15 @@ public class StatsSyncher {
return var0.field_27438_a = var1;
}
static String func_27414_e(StatsSyncher var0) {
static File func_27414_e(StatsSyncher var0) {
return var0.field_27434_e;
}
static String func_27417_f(StatsSyncher var0) {
static File func_27417_f(StatsSyncher var0) {
return var0.field_27432_g;
}
static String func_27419_g(StatsSyncher var0) {
static File func_27419_g(StatsSyncher var0) {
return var0.field_27430_i;
}
private static String makeFilePath(String s, String s1) {
return s + "/" + s1;
}
}

View File

@ -1,26 +0,0 @@
package net.minecraft.src;
import net.PeytonPlayz585.fileutils.File;
class ThreadStatSyncherReceive extends Thread {
final StatsSyncher field_27231_a;
ThreadStatSyncherReceive(StatsSyncher var1) {
this.field_27231_a = var1;
}
public void run() {
try {
if(StatsSyncher.func_27422_a(this.field_27231_a) != null) {
StatsSyncher.func_27412_a(this.field_27231_a, StatsSyncher.func_27422_a(this.field_27231_a), StatsSyncher.func_27423_b(this.field_27231_a), StatsSyncher.func_27411_c(this.field_27231_a), StatsSyncher.func_27413_d(this.field_27231_a));
} else if(File.exists(StatsSyncher.func_27423_b(this.field_27231_a))) {
StatsSyncher.func_27421_a(this.field_27231_a, StatsSyncher.func_27409_a(this.field_27231_a, StatsSyncher.func_27423_b(this.field_27231_a), StatsSyncher.func_27411_c(this.field_27231_a), StatsSyncher.func_27413_d(this.field_27231_a)));
}
} catch (Exception var5) {
var5.printStackTrace();
} finally {
StatsSyncher.func_27416_a(this.field_27231_a, false);
}
}
}

View File

@ -1,5 +1,6 @@
package net.PeytonPlayz585.fileutils;
import java.util.ArrayList;
import java.util.Collection;
import net.PeytonPlayz585.Client;
@ -7,6 +8,176 @@ import net.PeytonPlayz585.fileutils.IndexedDBFilesystem.OpenState;
public class File {
private String path;
private transient int prefixLength;
private final char slash = '/';
private static final String pathSeperator = "/";
private static final String[] altPathSeperator = new String[] { "\\" };
public File(String pathName) {
if (pathName == null) {
throw new NullPointerException();
}
this.path = this.normalize(pathName);
this.prefixLength = this.prefixLength(this.path);
}
public File(String parent, String child) {
if (child == null) {
throw new NullPointerException();
}
if(parent != null) {
this.path = this.createPath(parent, child);
} else {
this.path = this.normalize(child);
}
}
public File(File parent, String child) {
if (child == null) {
throw new NullPointerException();
}
if(parent != null) {
this.path = this.createPath(parent.path, child);
} else {
this.path = this.normalize(child);
}
}
private int prefixLength(String path) {
char slash = this.slash;
int n = path.length();
if (n == 0) return 0;
char c0 = path.charAt(0);
char c1 = (n > 1) ? path.charAt(1) : 0;
if (c0 == slash) {
if (c1 == slash) return 2;
return 1;
}
if (isLetter(c0) && (c1 == ':')) {
if ((n > 2) && (path.charAt(2) == slash))
return 3;
return 2;
}
return 0;
}
private boolean isLetter(char c) {
return ((c >= 'a') && (c <= 'z')) || ((c >= 'A') && (c <= 'Z'));
}
private String normalize(String p) {
for(int i = 0; i < altPathSeperator.length; ++i) {
p = p.replace(altPathSeperator[i], pathSeperator);
}
if(p.startsWith(pathSeperator)) {
p = p.substring(1);
}
if(p.endsWith(pathSeperator)) {
p = p.substring(0, p.length() - pathSeperator.length());
}
return p;
}
private String[] splitPath(String p) {
String[] pth = normalize(p).split(pathSeperator);
for(int i = 0; i < pth.length; ++i) {
pth[i] = pth[i].trim();
}
return pth;
}
private String createPath(Object... p) {
ArrayList<String> r = new ArrayList();
for(int i = 0; i < p.length; ++i) {
if(p[i] == null) {
continue;
}
String gg = p[i].toString();
if(gg == null) {
continue;
}
String[] parts = splitPath(gg);
for(int j = 0; j < parts.length; ++j) {
if(parts[j] == null || parts[j].equals(".")) {
continue;
}else if(parts[j].equals("..") && r.size() > 0) {
int k = r.size() - 1;
if(!r.get(k).equals("..")) {
r.remove(k);
}else {
r.add("..");
}
}else {
r.add(parts[j]);
}
}
}
if(r.size() > 0) {
StringBuilder s = new StringBuilder();
for(int i = 0; i < r.size(); ++i) {
if(i > 0) {
s.append(pathSeperator);
}
s.append(r.get(i));
}
return s.toString();
}else {
return null;
}
}
public String getName() {
int index = path.lastIndexOf(slash);
if (index < prefixLength) return path.substring(prefixLength);
return path.substring(index + 1);
}
public String getPath() {
return path;
}
public boolean exists() {
return exists(path);
}
public boolean isDirectory() {
return exists(path) && directoryExists(path);
}
public void renameTo(File newPath) {
renameFile(path, newPath.path);
}
public byte[] read() {
return readFile(path);
}
public void write(byte[] data) {
writeFile(path, data);
}
public void delete() {
deleteFile(path);
}
public void mkdir() {
IndexedDBFilesystem.mkdir(path);
}
public File[] listFiles() {
Collection<FileEntry> collection = listFiles(path, false, false);
int size = collection.size();
FileEntry[] entries = collection.toArray(new FileEntry[size]);
File[] files = new File[size];
for(int i = 0; i < size; i++) {
files[i] = new File(entries[i].path);
}
return files;
}
public static final boolean fileExists(String path) {
return IndexedDBFilesystem.fileExists(path);
}
@ -20,7 +191,7 @@ public class File {
}
public static final boolean exists(String path) {
return readFile(path) != null;
return IndexedDBFilesystem.exists(path);
}
public static final void mkdir(String path) {

View File

@ -61,11 +61,15 @@ public class IndexedDBFilesystem {
return AsyncHandlers.fileGetType(db, path) == FileExists.DIRECTORY;
}
public static final boolean exists(String path) {
return AsyncHandlers.fileGetType(db, path) != FileExists.FALSE;
}
public static final boolean pathExists(String path) {
return AsyncHandlers.fileExists(db, path).bool;
}
private static final void mkdir(String dir) {
public static final void mkdir(String dir) {
if(directoryExists(dir)) {
return;
}

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long