Merge pull request #1787 from thatsIch/b-1786-turkish-locale

Fixes #1786: Locale critical code now uses the english local. Fixes Turkish Problem.
This commit is contained in:
yueh
2015-08-15 18:11:48 +02:00
6 changed files with 55 additions and 29 deletions
@@ -1,7 +1,7 @@
/* /*
* The MIT License (MIT) * The MIT License (MIT)
* *
* Copyright (c) 2013 AlgorithmX2 * Copyright (c) 2013 - 2015 AlgorithmX2
* *
* Permission is hereby granted, free of charge, to any person obtaining a copy of * Permission is hereby granted, free of charge, to any person obtaining a copy of
* this software and associated documentation files (the "Software"), to deal in * this software and associated documentation files (the "Software"), to deal in
@@ -24,11 +24,19 @@
package appeng.api.features; package appeng.api.features;
import javax.annotation.Nullable;
import appeng.api.recipes.ICraftHandler; import appeng.api.recipes.ICraftHandler;
import appeng.api.recipes.IRecipeHandler; import appeng.api.recipes.IRecipeHandler;
import appeng.api.recipes.ISubItemResolver; import appeng.api.recipes.ISubItemResolver;
/**
* @author AlgorithmX2
* @author thatsIch
* @version rv3 - 10.08.2015
* @since rv0
*/
public interface IRecipeHandlerRegistry public interface IRecipeHandlerRegistry
{ {
@@ -37,7 +45,7 @@ public interface IRecipeHandlerRegistry
* *
* MUST BE CALLED IN PRE-INIT * MUST BE CALLED IN PRE-INIT
* *
* @param name name of crafthandler * @param name name of crafthandler
* @param handler class of crafthandler * @param handler class of crafthandler
*/ */
void addNewCraftHandler( String name, Class<? extends ICraftHandler> handler ); void addNewCraftHandler( String name, Class<? extends ICraftHandler> handler );
@@ -56,6 +64,7 @@ public interface IRecipeHandlerRegistry
* *
* @return A recipe handler by name, returns null on failure. * @return A recipe handler by name, returns null on failure.
*/ */
@Nullable
ICraftHandler getCraftHandlerFor( String name ); ICraftHandler getCraftHandlerFor( String name );
/** /**
@@ -67,9 +76,10 @@ public interface IRecipeHandlerRegistry
* resolve sub items by name. * resolve sub items by name.
* *
* @param nameSpace namespace of item * @param nameSpace namespace of item
* @param itemName full name of item * @param itemName full name of item
* *
* @return ResolverResult or ResolverResultSet * @return ResolverResult or ResolverResultSet or null if could not resolve
*/ */
@Nullable
Object resolveItem( String nameSpace, String itemName ); Object resolveItem( String nameSpace, String itemName );
} }
+10 -7
View File
@@ -20,6 +20,7 @@ package appeng.core;
import java.util.HashMap; import java.util.HashMap;
import java.util.Locale;
import java.util.Map; import java.util.Map;
import cpw.mods.fml.common.event.FMLInterModComms; import cpw.mods.fml.common.event.FMLInterModComms;
@@ -35,6 +36,10 @@ import appeng.core.api.imc.IMCSpatial;
/** /**
* Handles the delegation of the corresponding IMC messages to the suitable IMC processors * Handles the delegation of the corresponding IMC messages to the suitable IMC processors
*
* @author thatsIch
* @version rv3 - 10.08.2015
* @since rv1
*/ */
public class IMCHandler public class IMCHandler
{ {
@@ -43,8 +48,7 @@ public class IMCHandler
/** /**
* Contains the processors, * Contains the processors,
* *
* is mutable, * is mutable, but write access only by the constructor
* but write access only by the constructor
*/ */
private final Map<String, IIMCProcessor> processors; private final Map<String, IIMCProcessor> processors;
@@ -62,13 +66,12 @@ public class IMCHandler
for( TunnelType type : TunnelType.values() ) for( TunnelType type : TunnelType.values() )
{ {
this.processors.put( "add-p2p-attunement-" + type.name().replace( '_', '-' ).toLowerCase(), new IMCP2PAttunement() ); this.processors.put( "add-p2p-attunement-" + type.name().replace( '_', '-' ).toLowerCase( Locale.ENGLISH ), new IMCP2PAttunement() );
} }
} }
/** /**
* Tries to find every message matching the internal IMC keys. * Tries to find every message matching the internal IMC keys. When found the corresponding handler will process the attached message.
* When found the corresponding handler will process the attached message.
* *
* @param event Event carrying the identifier and message for the handlers * @param event Event carrying the identifier and message for the handlers
*/ */
@@ -80,7 +83,7 @@ public class IMCHandler
try try
{ {
IIMCProcessor handler = this.processors.get( key ); final IIMCProcessor handler = this.processors.get( key );
if( handler != null ) if( handler != null )
{ {
handler.process( message ); handler.process( message );
@@ -90,7 +93,7 @@ public class IMCHandler
throw new IllegalStateException( "Invalid IMC Called: " + key ); throw new IllegalStateException( "Invalid IMC Called: " + key );
} }
} }
catch( Throwable t ) catch( Exception t )
{ {
AELog.warning( "Problem detected when processing IMC " + key + " from " + message.getSender() ); AELog.warning( "Problem detected when processing IMC " + key + " from " + message.getSender() );
AELog.error( t ); AELog.error( t );
+4 -5
View File
@@ -22,7 +22,6 @@ package appeng.core;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.net.URISyntaxException; import java.net.URISyntaxException;
import javax.annotation.Nonnull; import javax.annotation.Nonnull;
import com.google.common.base.Preconditions; import com.google.common.base.Preconditions;
@@ -70,11 +69,11 @@ public class RecipeLoader implements Runnable
final File readmeGenDest = new File( generatedRecipesDir, "README.html" ); final File readmeGenDest = new File( generatedRecipesDir, "README.html" );
final File readmeUserDest = new File( userRecipesDir, "README.html" ); final File readmeUserDest = new File( userRecipesDir, "README.html" );
final IRecipeLoader oreDictLoader = new JarLoader("/assets/appliedenergistics2/oredict/"); final IRecipeLoader oreDictLoader = new JarLoader( "/assets/appliedenergistics2/oredict/" );
this.handler.parseRecipes(oreDictLoader, "vanilla.oredict" ); this.handler.parseRecipes( oreDictLoader, "vanilla.oredict" );
this.handler.parseRecipes(oreDictLoader, "ae2.oredict" ); this.handler.parseRecipes( oreDictLoader, "ae2.oredict" );
// generates generated and user recipes dir // generates generated and user recipes dir
// will clean the generated every time to keep it up to date // will clean the generated every time to keep it up to date
// copies over the recipes in the jar over to the generated folder // copies over the recipes in the jar over to the generated folder
// copies over the readmes // copies over the readmes
@@ -1,6 +1,6 @@
/* /*
* This file is part of Applied Energistics 2. * This file is part of Applied Energistics 2.
* Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved. * Copyright (c) 2013 - 2015, AlgorithmX2, All rights reserved.
* *
* Applied Energistics 2 is free software: you can redistribute it and/or modify * Applied Energistics 2 is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by * it under the terms of the GNU Lesser General Public License as published by
@@ -31,6 +31,7 @@ package appeng.core.api.imc;
import java.util.Arrays; import java.util.Arrays;
import java.util.Locale;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
@@ -47,7 +48,7 @@ public class IMCP2PAttunement implements IIMCProcessor
@Override @Override
public void process( IMCMessage m ) public void process( IMCMessage m )
{ {
String key = m.key.substring( "add-p2p-attunement-".length() ).replace( '-', '_' ).toUpperCase(); String key = m.key.substring( "add-p2p-attunement-".length() ).replace( '-', '_' ).toUpperCase( Locale.ENGLISH );
TunnelType type = TunnelType.valueOf( key ); TunnelType type = TunnelType.valueOf( key );
@@ -1,6 +1,6 @@
/* /*
* This file is part of Applied Energistics 2. * This file is part of Applied Energistics 2.
* Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved. * Copyright (c) 2013 - 2015, AlgorithmX2, All rights reserved.
* *
* Applied Energistics 2 is free software: you can redistribute it and/or modify * Applied Energistics 2 is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by * it under the terms of the GNU Lesser General Public License as published by
@@ -19,8 +19,12 @@
package appeng.core.features.registries; package appeng.core.features.registries;
import java.util.Collection;
import java.util.HashMap; import java.util.HashMap;
import java.util.LinkedList; import java.util.LinkedList;
import java.util.Locale;
import java.util.Map;
import javax.annotation.Nullable;
import appeng.api.features.IRecipeHandlerRegistry; import appeng.api.features.IRecipeHandlerRegistry;
import appeng.api.recipes.ICraftHandler; import appeng.api.recipes.ICraftHandler;
@@ -30,16 +34,21 @@ import appeng.core.AELog;
import appeng.recipes.RecipeHandler; import appeng.recipes.RecipeHandler;
/**
* @author AlgorithmX2
* @author thatsIch
* @version rv3 - 10.08.2015
* @since rv0
*/
public class RecipeHandlerRegistry implements IRecipeHandlerRegistry public class RecipeHandlerRegistry implements IRecipeHandlerRegistry
{ {
private final Map<String, Class<? extends ICraftHandler>> handlers = new HashMap<String, Class<? extends ICraftHandler>>( 20 );
final HashMap<String, Class<? extends ICraftHandler>> handlers = new HashMap<String, Class<? extends ICraftHandler>>(); private final Collection<ISubItemResolver> resolvers = new LinkedList<ISubItemResolver>();
final LinkedList<ISubItemResolver> resolvers = new LinkedList<ISubItemResolver>();
@Override @Override
public void addNewCraftHandler( String name, Class<? extends ICraftHandler> handler ) public void addNewCraftHandler( String name, Class<? extends ICraftHandler> handler )
{ {
this.handlers.put( name.toLowerCase(), handler ); this.handlers.put( name.toLowerCase( Locale.ENGLISH ), handler );
} }
@Override @Override
@@ -48,6 +57,7 @@ public class RecipeHandlerRegistry implements IRecipeHandlerRegistry
this.resolvers.add( sir ); this.resolvers.add( sir );
} }
@Nullable
@Override @Override
public ICraftHandler getCraftHandlerFor( String name ) public ICraftHandler getCraftHandlerFor( String name )
{ {
@@ -64,7 +74,9 @@ public class RecipeHandlerRegistry implements IRecipeHandlerRegistry
{ {
AELog.severe( "Error Caused when trying to construct " + clz.getName() ); AELog.severe( "Error Caused when trying to construct " + clz.getName() );
AELog.error( e ); AELog.error( e );
this.handlers.put( name, null ); // clear it.. this.handlers.put( name, null ); // clear it..
return null; return null;
} }
} }
@@ -75,6 +87,7 @@ public class RecipeHandlerRegistry implements IRecipeHandlerRegistry
return new RecipeHandler(); return new RecipeHandler();
} }
@Nullable
@Override @Override
public Object resolveItem( String nameSpace, String itemName ) public Object resolveItem( String nameSpace, String itemName )
{ {
@@ -26,11 +26,11 @@ import java.io.IOException;
import java.util.HashMap; import java.util.HashMap;
import java.util.LinkedList; import java.util.LinkedList;
import java.util.List; import java.util.List;
import java.util.Locale;
import java.util.Map; import java.util.Map;
import java.util.Map.Entry; import java.util.Map.Entry;
import java.util.zip.ZipEntry; import java.util.zip.ZipEntry;
import java.util.zip.ZipOutputStream; import java.util.zip.ZipOutputStream;
import javax.annotation.Nonnull; import javax.annotation.Nonnull;
import com.google.common.base.Optional; import com.google.common.base.Optional;
@@ -70,7 +70,7 @@ import appeng.recipes.handlers.OreRegistration;
/** /**
* @author AlgorithmX2 * @author AlgorithmX2
* @author thatsIch * @author thatsIch
* @version rv2 * @version rv3 - 10.08.2015
* @since rv0 * @since rv0
*/ */
public class RecipeHandler implements IRecipeHandler public class RecipeHandler implements IRecipeHandler
@@ -455,7 +455,7 @@ public class RecipeHandler implements IRecipeHandler
try try
{ {
Ingredient i = new Ingredient( this, s, 1 ); IIngredient i = new Ingredient( this, s, 1 );
for( ItemStack is : i.getItemStackSet() ) for( ItemStack is : i.getItemStackSet() )
{ {
@@ -555,7 +555,7 @@ public class RecipeHandler implements IRecipeHandler
int split = this.tokens.indexOf( "->" ); int split = this.tokens.indexOf( "->" );
if( split != -1 ) if( split != -1 )
{ {
String operation = this.tokens.remove( 0 ).toLowerCase(); final String operation = this.tokens.remove( 0 ).toLowerCase( Locale.ENGLISH );
if( operation.equals( "alias" ) ) if( operation.equals( "alias" ) )
{ {
@@ -692,7 +692,7 @@ public class RecipeHandler implements IRecipeHandler
this.tokens.clear(); this.tokens.clear();
} }
private List<List<IIngredient>> parseLines( List<String> subList ) throws RecipeError private List<List<IIngredient>> parseLines( Iterable<String> subList ) throws RecipeError
{ {
List<List<IIngredient>> out = new LinkedList<List<IIngredient>>(); List<List<IIngredient>> out = new LinkedList<List<IIngredient>>();
List<IIngredient> cList = new LinkedList<IIngredient>(); List<IIngredient> cList = new LinkedList<IIngredient>();
@@ -767,7 +767,7 @@ public class RecipeHandler implements IRecipeHandler
} }
} }
private boolean isNumber( String v ) private boolean isNumber( CharSequence v )
{ {
if( v.length() <= 0 ) if( v.length() <= 0 )
{ {