Prevented repeated Freezes caused by LocalizedResourcePack if ReplayMod.com is not available
This commit is contained in:
@@ -149,12 +149,19 @@ public class ReplayMod {
|
|||||||
//clean up replay_recordings folder
|
//clean up replay_recordings folder
|
||||||
removeTmcprFiles();
|
removeTmcprFiles();
|
||||||
|
|
||||||
|
Thread localizedResourcePackLoader = new Thread(new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
try {
|
try {
|
||||||
mc.defaultResourcePacks.add(new LocalizedResourcePack());
|
mc.defaultResourcePacks.add(new LocalizedResourcePack());
|
||||||
mc.refreshResources();
|
mc.refreshResources();
|
||||||
} catch(Exception e) {
|
} catch(Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}, "localizedResourcePackLoader");
|
||||||
|
localizedResourcePackLoader.start();
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
boolean auth = false;
|
boolean auth = false;
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ import java.awt.image.BufferedImage;
|
|||||||
import java.io.ByteArrayInputStream;
|
import java.io.ByteArrayInputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
|
import java.net.ConnectException;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
@@ -20,6 +21,7 @@ import java.util.Set;
|
|||||||
public class LocalizedResourcePack implements IResourcePack {
|
public class LocalizedResourcePack implements IResourcePack {
|
||||||
|
|
||||||
private Map<String, String> availableLanguages = new HashMap<String, String>();
|
private Map<String, String> availableLanguages = new HashMap<String, String>();
|
||||||
|
private boolean websiteAvailable = true;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public InputStream getInputStream(ResourceLocation loc) {
|
public InputStream getInputStream(ResourceLocation loc) {
|
||||||
@@ -33,11 +35,17 @@ public class LocalizedResourcePack implements IResourcePack {
|
|||||||
public boolean resourceExists(ResourceLocation loc) {
|
public boolean resourceExists(ResourceLocation loc) {
|
||||||
if(!(loc.getResourcePath().endsWith(".lang"))) return false;
|
if(!(loc.getResourcePath().endsWith(".lang"))) return false;
|
||||||
String langcode = loc.getResourcePath().split("/")[1].split("\\.")[0];
|
String langcode = loc.getResourcePath().split("/")[1].split("\\.")[0];
|
||||||
|
if(availableLanguages.containsKey(langcode)) return true;
|
||||||
|
if(!websiteAvailable) return false;
|
||||||
boolean downloaded = true;
|
boolean downloaded = true;
|
||||||
try {
|
try {
|
||||||
String lang = ReplayMod.apiClient.getTranslation(langcode);
|
String lang = ReplayMod.apiClient.getTranslation(langcode);
|
||||||
String prop = StringEscapeUtils.unescapeHtml4(lang);
|
String prop = StringEscapeUtils.unescapeHtml4(lang);
|
||||||
availableLanguages.put(langcode, prop);
|
availableLanguages.put(langcode, prop);
|
||||||
|
} catch(ConnectException ce) {
|
||||||
|
websiteAvailable = false;
|
||||||
|
ce.printStackTrace();
|
||||||
|
downloaded = false;
|
||||||
} catch(Exception e) {
|
} catch(Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
downloaded = false;
|
downloaded = false;
|
||||||
|
|||||||
Reference in New Issue
Block a user