mirror of
https://github.com/MinecraftForge/MinecraftForge.git
synced 2026-11-13 00:37:52 +00:00
Make UniqueIdentifier final and add a hashCode. Closes #348
Clean up language registry. It can be used to access all translations of mods on client or server. Auto loads from assets files.
This commit is contained in:
1 parent
53557dcd05
commit
7c5d62704a
6 files changed
+165
-81
No files matched your search
@@ -12,27 +12,14 @@
|
||||
*/
|
||||
package cpw.mods.fml.server;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
import java.util.zip.ZipEntry;
|
||||
import java.util.zip.ZipFile;
|
||||
|
||||
import net.minecraft.network.INetHandler;
|
||||
import net.minecraft.network.NetHandlerPlayServer;
|
||||
import net.minecraft.network.NetworkManager;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.util.StringTranslate;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
|
||||
import cpw.mods.fml.common.FMLCommonHandler;
|
||||
import cpw.mods.fml.common.FMLLog;
|
||||
import cpw.mods.fml.common.IFMLSidedHandler;
|
||||
import cpw.mods.fml.common.Loader;
|
||||
import cpw.mods.fml.common.ModContainer;
|
||||
@@ -94,7 +81,6 @@ public class FMLServerHandler implements IFMLSidedHandler
|
||||
public void finishServerLoading()
|
||||
{
|
||||
Loader.instance().initializeMods();
|
||||
LanguageRegistry.reloadLanguageTable();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -150,55 +136,9 @@ public class FMLServerHandler implements IFMLSidedHandler
|
||||
@Override
|
||||
public void addModAsResource(ModContainer container)
|
||||
{
|
||||
File source = container.getSource();
|
||||
try
|
||||
{
|
||||
if (source.isDirectory())
|
||||
{
|
||||
searchDirForENUSLanguage(source,"");
|
||||
}
|
||||
else
|
||||
{
|
||||
searchZipForENUSLanguage(source);
|
||||
}
|
||||
}
|
||||
catch (IOException ioe)
|
||||
{
|
||||
LanguageRegistry.instance().loadLanguagesFor(container, Side.SERVER);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
private static final Pattern assetENUSLang = Pattern.compile("assets/(.*)/lang/en_US.lang");
|
||||
private void searchZipForENUSLanguage(File source) throws IOException
|
||||
{
|
||||
ZipFile zf = new ZipFile(source);
|
||||
for (ZipEntry ze : Collections.list(zf.entries()))
|
||||
{
|
||||
Matcher matcher = assetENUSLang.matcher(ze.getName());
|
||||
if (matcher.matches())
|
||||
{
|
||||
FMLLog.fine("Injecting found translation data in zip file %s at %s into language system", source.getName(), ze.getName());
|
||||
StringTranslate.inject(zf.getInputStream(ze));
|
||||
}
|
||||
}
|
||||
zf.close();
|
||||
}
|
||||
private void searchDirForENUSLanguage(File source, String path) throws IOException
|
||||
{
|
||||
for (File file : source.listFiles())
|
||||
{
|
||||
String currPath = path+file.getName();
|
||||
if (file.isDirectory())
|
||||
{
|
||||
searchDirForENUSLanguage(file, currPath+'/');
|
||||
}
|
||||
Matcher matcher = assetENUSLang.matcher(currPath);
|
||||
if (matcher.matches())
|
||||
{
|
||||
FMLLog.fine("Injecting found translation data at %s into language system", currPath);
|
||||
StringTranslate.inject(new FileInputStream(file));
|
||||
}
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void updateResourcePackList()
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user