Moved localization to vanilla language files
This commit is contained in:
parent
0ca9807800
commit
1f385fecc7
10 changed files with 364 additions and 677 deletions
|
|
@ -9,7 +9,6 @@ import mysticstones.blocks.ItemReinforced;
|
|||
import mysticstones.blocks.ItemStoneBricks;
|
||||
import mysticstones.blocks.ItemStones;
|
||||
import mysticstones.util.Config;
|
||||
import mysticstones.util.Localizations;
|
||||
import mysticstones.util.RecipeHandler;
|
||||
import mysticstones.util.TabMysticStones;
|
||||
import mysticstones.worldgen.WorldGeneratorStones;
|
||||
|
|
@ -41,7 +40,6 @@ public class MysticStones {
|
|||
GameRegistry.registerBlock(stones, ItemStones.class, "Stones");
|
||||
GameRegistry.registerBlock(stoneBricks, ItemStoneBricks.class, "StoneBricks");
|
||||
GameRegistry.registerBlock(reinforcedBricks, ItemReinforced.class, "Reinforcedbricks");
|
||||
Localizations.Initialize();
|
||||
RecipeHandler.craftPlanks();
|
||||
RecipeHandler.craftStoneBricks();
|
||||
RecipeHandler.craftReinforced();
|
||||
|
|
|
|||
|
|
@ -1,96 +0,0 @@
|
|||
package mysticstones.util;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Enumeration;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
import java.util.zip.ZipEntry;
|
||||
import java.util.zip.ZipException;
|
||||
import java.util.zip.ZipFile;
|
||||
|
||||
import mysticstones.MysticStones;
|
||||
import cpw.mods.fml.common.Loader;
|
||||
import cpw.mods.fml.common.registry.LanguageRegistry;
|
||||
|
||||
/*
|
||||
*
|
||||
* All credits go to copygirl (or copy....boy) for this one
|
||||
* Couldn't have done any of this without your
|
||||
* repository, many thanks friend c:
|
||||
*
|
||||
*/
|
||||
@Deprecated(/* replaced by vanilla */)
|
||||
public class Localizations {
|
||||
private Localizations() {
|
||||
}
|
||||
|
||||
public static void Initialize() {
|
||||
File source = Loader.instance().getReversedModObjectList().get(MysticStones.instance).getSource();
|
||||
Pattern pattern = Pattern.compile(".*(assets/" + "mysticmods/lang/(.+)\\.(.+))");
|
||||
for (String file : getResources(source, pattern)) {
|
||||
Matcher matcher = pattern.matcher(file);
|
||||
matcher.find();
|
||||
String resource = "/" + matcher.group(1);
|
||||
String lang = matcher.group(2);
|
||||
boolean isXML = matcher.group(3).equalsIgnoreCase("XML");
|
||||
LanguageRegistry.instance().loadLocalization(resource, lang, isXML);
|
||||
}
|
||||
}
|
||||
|
||||
private static Collection<String> getResources(File file, Pattern pattern) {
|
||||
ArrayList<String> retval = new ArrayList<String>();
|
||||
if (file.isDirectory())
|
||||
retval.addAll(getResourcesFromDirectory(file, pattern));
|
||||
else
|
||||
retval.addAll(getResourcesFromJarFile(file, pattern));
|
||||
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;
|
||||
}
|
||||
|
||||
private static Collection<String> getResourcesFromJarFile(File file, Pattern pattern) {
|
||||
ArrayList<String> retval = new ArrayList<String>();
|
||||
ZipFile Zip;
|
||||
try {
|
||||
Zip = new ZipFile(file);
|
||||
} catch (ZipException Ex) {
|
||||
throw new Error(Ex);
|
||||
} catch (IOException Ex) {
|
||||
throw new Error(Ex);
|
||||
}
|
||||
Enumeration<? extends ZipEntry> entries = Zip.entries();
|
||||
while (entries.hasMoreElements()) {
|
||||
ZipEntry ZipE = entries.nextElement();
|
||||
String FileName = ZipE.getName();
|
||||
boolean accept = pattern.matcher(FileName).matches();
|
||||
if (accept)
|
||||
retval.add(FileName);
|
||||
}
|
||||
try {
|
||||
Zip.close();
|
||||
} catch (IOException Ex) {
|
||||
throw new Error(Ex);
|
||||
}
|
||||
return retval;
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue