本文整理汇总了Java中net.minecraft.util.StringTranslate类的典型用法代码示例。如果您正苦于以下问题:Java StringTranslate类的具体用法?Java StringTranslate怎么用?Java StringTranslate使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
StringTranslate类属于net.minecraft.util包,在下文中一共展示了StringTranslate类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: searchZipForLanguages
import net.minecraft.util.StringTranslate; //导入依赖的package包/类
private void searchZipForLanguages(File source, Side side) throws IOException
{
ZipFile zf = new ZipFile(source);
List<String> added = Lists.newArrayList();
for (ZipEntry ze : Collections.list(zf.entries()))
{
Matcher matcher = assetENUSLang.matcher(ze.getName());
if (matcher.matches())
{
String lang = matcher.group(2);
//FMLLog.fine("Injecting found translation data for lang %s in zip file %s at %s into language system", lang, source.getName(), ze.getName());
added.add(lang);
LanguageRegistry.instance().injectLanguage(lang, StringTranslate.parseLangFile(zf.getInputStream(ze)));
// Ensure en_US is available to StringTranslate on the server
if ("en_US".equals(lang) && side == Side.SERVER)
{
StringTranslate.inject(zf.getInputStream(ze));
}
}
}
if (added.size() > 0)
FMLLog.fine("Found translations in %s [%s]", source.getName(), Joiner.on(", ").join(added));
zf.close();
}
示例2: searchDirForLanguages
import net.minecraft.util.StringTranslate; //导入依赖的package包/类
private void searchDirForLanguages(File source, String path, Side side) throws IOException
{
for (File file : source.listFiles())
{
String currPath = path+file.getName();
if (file.isDirectory())
{
searchDirForLanguages(file, currPath+'/', side);
}
Matcher matcher = assetENUSLang.matcher(currPath);
if (matcher.matches())
{
String lang = matcher.group(2);
FMLLog.fine("Injecting found translation assets for lang %s at %s into language system", lang, currPath);
LanguageRegistry.instance().injectLanguage(lang, StringTranslate.parseLangFile(new FileInputStream(file)));
// Ensure en_US is available to StringTranslate on the server
if ("en_US".equals(lang) && side == Side.SERVER)
{
StringTranslate.inject(new FileInputStream(file));
}
}
}
}
示例3: searchZipForLanguages
import net.minecraft.util.StringTranslate; //导入依赖的package包/类
private void searchZipForLanguages(File source, Side side) throws IOException
{
ZipFile zf = new ZipFile(source);
for (ZipEntry ze : Collections.list(zf.entries()))
{
Matcher matcher = assetENUSLang.matcher(ze.getName());
if (matcher.matches())
{
String lang = matcher.group(2);
FMLLog.fine("Injecting found translation data for lang %s in zip file %s at %s into language system", lang, source.getName(), ze.getName());
LanguageRegistry.instance().injectLanguage(lang, StringTranslate.parseLangFile(zf.getInputStream(ze)));
// Ensure en_US is available to StringTranslate on the server
if ("en_US".equals(lang) && side == Side.SERVER)
{
StringTranslate.inject(zf.getInputStream(ze));
}
}
}
zf.close();
}
示例4: postInit
import net.minecraft.util.StringTranslate; //导入依赖的package包/类
public void postInit()
{
((IReloadableResourceManager) Minecraft.getMinecraft().getResourceManager()).registerReloadListener(new IResourceManagerReloadListener() {
private boolean ranOnce = false;
public void onResourceManagerReload(IResourceManager resourcemanager) {
if (!this.ranOnce) {
this.ranOnce = true;
return;
}
StructuralLevelClientData.loadBaseTextureData();
if (StructuralLevel.LEVELS != null) {
for (StructuralLevel level : StructuralLevel.LEVELS) {
if (level.levelNum != 0) {
level.clientData.generateIcons();
StringTranslate.inject(new ByteArrayInputStream(("item.upgrade.structural." + String.valueOf(level.levelNum) + ".name=" + StatCollector.translateToLocal("item.upgrade.structural") + " " + Utils.romanNumeral(level.levelNum) + " (" + level.clientData.getMaterialName() + ")").getBytes()));
}
}
}
StructuralLevelClientData.unloadBaseTextureData();
}
});
}
示例5: injectLanguage
import net.minecraft.util.StringTranslate; //导入依赖的package包/类
public static void injectLanguage(File source, Side side) {
try {
ZipFile zf = new ZipFile(source);
for (ZipEntry ze : Collections.list(zf.entries())) {
Matcher matcher = Pattern.compile("(?:.+/|)([\\w_-]+).lang").matcher(ze.getName());
if (matcher.matches()) {
String lang = matcher.group(1);
FMLLog.fine("Injecting found translation data for lang %s in zip file %s at %s into language system", lang, source.getName(), ze.getName());
LanguageRegistry.instance().injectLanguage(lang, StringTranslate.parseLangFile(zf.getInputStream(ze)));
// Ensure en_US is available to StringTranslate on the server
if ("en_US".equals(lang) && side == Side.SERVER)
StringTranslate.inject(zf.getInputStream(ze));
}
}
zf.close();
} catch (Exception e) {
Logger.logError("Could not inject language file!");
e.printStackTrace();
}
}
示例6: searchDirForENUSLanguage
import net.minecraft.util.StringTranslate; //导入依赖的package包/类
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));
}
}
}
示例7: onResourceManagerReload
import net.minecraft.util.StringTranslate; //导入依赖的package包/类
public void onResourceManagerReload(IResourceManager resourceManager)
{
List<String> list = Lists.newArrayList(new String[] {"en_US"});
if (!"en_US".equals(this.currentLanguage))
{
list.add(this.currentLanguage);
}
currentLocale.loadLocaleDataFiles(resourceManager, list);
StringTranslate.replaceWith(currentLocale.properties);
}
示例8: getFallback
import net.minecraft.util.StringTranslate; //导入依赖的package包/类
private static StringTranslate getFallback() throws IllegalAccessException, NoSuchFieldException {
if (fallback == null) {
fallback = StatCollector.class.getDeclaredField("fallbackTranslator");
fallback.setAccessible(true);
}
return (StringTranslate) fallback.get(null);
}
示例9: getStringTranslateInstance
import net.minecraft.util.StringTranslate; //导入依赖的package包/类
public static StringTranslate getStringTranslateInstance() {
try {
Field field = getField(StringTranslate.class, ObfuscationConstants.STRINGTRANSLATE_INSTANCE);
return (StringTranslate) field.get(null);
} catch (IllegalAccessException ex) {
Game.logger().error("could not get string translator");
return null;
}
}
示例10: onResourceManagerReload
import net.minecraft.util.StringTranslate; //导入依赖的package包/类
public void onResourceManagerReload(IResourceManager par1ResourceManager)
{
ArrayList var2 = Lists.newArrayList(new String[] {"en_US"});
if (!"en_US".equals(this.currentLanguage))
{
var2.add(this.currentLanguage);
}
currentLocale.loadLocaleDataFiles(par1ResourceManager, var2);
StringTranslate.replaceWith(currentLocale.field_135032_a);
}
示例11: initializeThread
import net.minecraft.util.StringTranslate; //导入依赖的package包/类
public void initializeThread(Configuration configuration) {
optout = configuration.get("optout", "localization_update", false, "Opt-out of localization updates, and only use lang files packaged with the JAR").getBoolean(false);
if (!optout) {
Thread thread = new Thread(new Runnable() {
@Override
public void run() {
try {
URL url = new URL(langUrl);
InputStream con = url.openStream();
String data = new String(ByteStreams.toByteArray(con));
con.close();
Map<String, Object>[] json = new Gson().fromJson(data, Map[].class);
for (Map<String, Object> aJson : json) {
String name = ((String) aJson.get("name"));
if (name.endsWith(".lang")) {
LOGGER.info("Discovered remote " + name + ". Downloading...");
URL url1 = new URL(String.format(rawUrl, aJson.get("path")));
InputStream con1 = url1.openStream();
Map<String, String> map = StringTranslate.parseLangFile(con1);
LocalizationUpdater.this.loadedLangFiles.put(name.substring(0, name.lastIndexOf(".lang")), map);
con1.close();
}
}
} catch (Exception ex) {
// Most likely due to the lack of an internet connection. No need to print
if (ex instanceof UnknownHostException)
optout = true;
else
LOGGER.warn("Failed to update localization!", ex);
}
}
});
thread.start();
}
}
示例12: inject
import net.minecraft.util.StringTranslate; //导入依赖的package包/类
public static void inject(HashMap<String, String> map) {
try {
Map<String, String> languageMap = ObfuscationReflectionHelper.getPrivateValue(StringTranslate.class, getInstance(), LANGUAGE_MAP);
languageMap.putAll(map);
ObfuscationReflectionHelper.setPrivateValue(StringTranslate.class, getInstance(), System.currentTimeMillis(), LAST_UPDATE);
} catch (Exception ex) {
ex.printStackTrace();
}
}
示例13: initializeThread
import net.minecraft.util.StringTranslate; //导入依赖的package包/类
public void initializeThread(Configuration configuration) {
optout = configuration.get("optout", "localization_update", false, "Opt-out of localization updates, and only use lang files packaged with the JAR").getBoolean(false);
if (!optout) {
Thread thread = new Thread(new Runnable() {
@Override
public void run() {
try {
URL url = new URL(langUrl);
InputStream con = url.openStream();
String data = new String(ByteStreams.toByteArray(con));
con.close();
Map<String, Object>[] json = new Gson().fromJson(data, Map[].class);
for (Map<String, Object> aJson : json) {
String name = ((String) aJson.get("name"));
if (name.endsWith(".lang")) {
LOGGER.info("Discovered " + name + ". Downloading...");
URL url1 = new URL(String.format(rawUrl, aJson.get("path")));
InputStream con1 = url1.openStream();
Map<String, String> map = StringTranslate.parseLangFile(con1);
LocalizationUpdater.this.loadedLangFiles.put(name.substring(0, name.lastIndexOf(".lang")), map);
con1.close();
}
}
} catch (Exception ex) {
// Most likely due to the lack of an internet connection. No need to print
if (ex instanceof UnknownHostException)
optout = true;
else
LOGGER.warn("Failed to update localization!", ex);
}
}
});
thread.start();
}
}
示例14: onResourceManagerReload
import net.minecraft.util.StringTranslate; //导入依赖的package包/类
public void onResourceManagerReload(IResourceManager p_110549_1_)
{
ArrayList arraylist = Lists.newArrayList(new String[] {"en_US"});
if (!"en_US".equals(this.currentLanguage))
{
arraylist.add(this.currentLanguage);
}
currentLocale.loadLocaleDataFiles(p_110549_1_, arraylist);
LanguageRegistry.instance().mergeLanguageTable(currentLocale.field_135032_a, this.currentLanguage);
StringTranslate.replaceWith(currentLocale.field_135032_a);
}
示例15: searchZipForENUSLanguage
import net.minecraft.util.StringTranslate; //导入依赖的package包/类
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();
}