Reorganized github - Renamed packages lowercase
This commit is contained in:
parent
5a3a6d4a8e
commit
579ddee7f0
362 changed files with 5163 additions and 8935 deletions
|
|
@ -1,4 +1,4 @@
|
|||
package MysticWorld.Util;
|
||||
package mysticworld.util;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
|
@ -10,10 +10,11 @@ import java.util.regex.Pattern;
|
|||
import java.util.zip.ZipEntry;
|
||||
import java.util.zip.ZipException;
|
||||
import java.util.zip.ZipFile;
|
||||
import MysticWorld.MysticWorld;
|
||||
|
||||
import mysticworld.MysticWorld;
|
||||
import cpw.mods.fml.common.Loader;
|
||||
import cpw.mods.fml.common.registry.LanguageRegistry;
|
||||
|
||||
/*
|
||||
*
|
||||
* All credits go to copygirl (or copy....boy) for this one
|
||||
|
|
@ -21,17 +22,14 @@ import cpw.mods.fml.common.registry.LanguageRegistry;
|
|||
* repository, many thanks friend c:
|
||||
*
|
||||
*/
|
||||
public class Localizations {
|
||||
private Localizations() {
|
||||
}
|
||||
|
||||
public class Localizations
|
||||
{
|
||||
private Localizations(){}
|
||||
|
||||
public static void Initialize()
|
||||
{
|
||||
public static void Initialize() {
|
||||
File source = Loader.instance().getReversedModObjectList().get(MysticWorld.instance).getSource();
|
||||
Pattern pattern = Pattern.compile(".*(assets/" + "mysticmods/lang/(.+)\\.(.+))");
|
||||
for(String file : getResources(source, pattern))
|
||||
{
|
||||
for (String file : getResources(source, pattern)) {
|
||||
Matcher matcher = pattern.matcher(file);
|
||||
matcher.find();
|
||||
String resource = "/" + matcher.group(1);
|
||||
|
|
@ -40,73 +38,58 @@ public class Localizations
|
|||
LanguageRegistry.instance().loadLocalization(resource, lang, isXML);
|
||||
}
|
||||
}
|
||||
|
||||
private static Collection<String> getResources(File file, Pattern pattern)
|
||||
{
|
||||
|
||||
private static Collection<String> getResources(File file, Pattern pattern) {
|
||||
ArrayList<String> retval = new ArrayList<String>();
|
||||
if(file.isDirectory())
|
||||
if (file.isDirectory())
|
||||
retval.addAll(getResourcesFromDirectory(file, pattern));
|
||||
else retval.addAll(getResourcesFromJarFile(file, pattern));
|
||||
else
|
||||
retval.addAll(getResourcesFromJarFile(file, pattern));
|
||||
return retval;
|
||||
}
|
||||
|
||||
private static Collection<String> getResourcesFromJarFile(File file, Pattern pattern)
|
||||
{
|
||||
|
||||
private static Collection<String> getResourcesFromDirectory(File directory, Pattern pattern) {
|
||||
ArrayList<String> retval = new ArrayList<String>();
|
||||
File[] FileList = directory.listFiles();
|
||||
for (File file : FileList) {
|
||||
if (file.isDirectory()) {
|
||||
retval.addAll(getResourcesFromDirectory(file, pattern));
|
||||
} else
|
||||
try {
|
||||
String fileName = file.getCanonicalPath().replace('\\', '/');
|
||||
boolean accept = pattern.matcher(fileName).matches();
|
||||
if (accept)
|
||||
retval.add(fileName);
|
||||
} catch (final IOException e) {
|
||||
throw new Error(e);
|
||||
}
|
||||
}
|
||||
return retval;
|
||||
}
|
||||
|
||||
private static Collection<String> getResourcesFromJarFile(File file, Pattern pattern) {
|
||||
ArrayList<String> retval = new ArrayList<String>();
|
||||
ZipFile Zip;
|
||||
try
|
||||
{
|
||||
try {
|
||||
Zip = new ZipFile(file);
|
||||
}
|
||||
catch (ZipException Ex)
|
||||
{
|
||||
} catch (ZipException Ex) {
|
||||
throw new Error(Ex);
|
||||
}
|
||||
catch(IOException Ex)
|
||||
{
|
||||
} catch (IOException Ex) {
|
||||
throw new Error(Ex);
|
||||
}
|
||||
Enumeration<? extends ZipEntry> entries = Zip.entries();
|
||||
while (entries.hasMoreElements())
|
||||
{
|
||||
while (entries.hasMoreElements()) {
|
||||
ZipEntry ZipE = entries.nextElement();
|
||||
String FileName = ZipE.getName();
|
||||
boolean accept = pattern.matcher(FileName).matches();
|
||||
if(accept)
|
||||
if (accept)
|
||||
retval.add(FileName);
|
||||
}
|
||||
try
|
||||
{
|
||||
try {
|
||||
Zip.close();
|
||||
}
|
||||
catch(IOException Ex)
|
||||
{
|
||||
} catch (IOException Ex) {
|
||||
throw new Error(Ex);
|
||||
}
|
||||
return retval;
|
||||
}
|
||||
|
||||
private static Collection<String> getResourcesFromDirectory(File directory, Pattern pattern)
|
||||
{
|
||||
ArrayList<String> retval = new ArrayList<String>();
|
||||
File[] FileList = directory.listFiles();
|
||||
for (File file : FileList)
|
||||
{
|
||||
if (file.isDirectory())
|
||||
{
|
||||
retval.addAll(getResourcesFromDirectory(file, pattern));
|
||||
}
|
||||
else try
|
||||
{
|
||||
String fileName = file.getCanonicalPath().replace('\\', '/');
|
||||
boolean accept = pattern.matcher(fileName).matches();
|
||||
if (accept) retval.add(fileName);
|
||||
}
|
||||
catch(final IOException e)
|
||||
{
|
||||
throw new Error(e);
|
||||
}
|
||||
}
|
||||
return retval;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue