Commit be0307cbf33f964250f50943441194c5062fd2d4
1 parent
91f621ae
convert Input to abstract class, interface was causing binary compatibility issues
Showing
6 changed files
with
40 additions
and
4 deletions
java/client/com/mumfrey/liteloader/client/Translator.java
... | ... | @@ -16,4 +16,13 @@ public class Translator implements TranslationProvider |
16 | 16 | return I18n.format(key, args); |
17 | 17 | } |
18 | 18 | |
19 | + /* (non-Javadoc) | |
20 | + * @see com.mumfrey.liteloader.api.TranslationProvider#translate(java.lang.String, java.lang.String, java.lang.Object[]) | |
21 | + */ | |
22 | + @Override | |
23 | + public String translate(String locale, String key, Object... args) | |
24 | + { | |
25 | + // TODO doesn't currently honour the contract of TranslationProvider::translate, should return null if translation is missing | |
26 | + return I18n.format(key, args); | |
27 | + } | |
19 | 28 | } | ... | ... |
java/client/com/mumfrey/liteloader/util/InputManager.java
... | ... | @@ -37,7 +37,7 @@ import com.mumfrey.liteloader.util.jinput.ComponentRegistry; |
37 | 37 | * |
38 | 38 | * @author Adam Mummery-Smith |
39 | 39 | */ |
40 | -public final class InputManager implements Input | |
40 | +public final class InputManager extends Input | |
41 | 41 | { |
42 | 42 | private GameEngine<?, ?> engine; |
43 | 43 | ... | ... |
java/common/com/mumfrey/liteloader/api/TranslationProvider.java
... | ... | @@ -11,4 +11,9 @@ public interface TranslationProvider extends CustomisationProvider |
11 | 11 | * Translate the supplied key or return NULL if the provider has no translation for the specified key |
12 | 12 | */ |
13 | 13 | public abstract String translate(String key, Object... args); |
14 | + | |
15 | + /** | |
16 | + * Translate the supplied key to the specified locale, or return NULL if the provider has no translation for this key | |
17 | + */ | |
18 | + public abstract String translate(String locale, String key, Object... args); | |
14 | 19 | } | ... | ... |
java/common/com/mumfrey/liteloader/core/LiteLoaderEventBroker.java
... | ... | @@ -469,10 +469,12 @@ public abstract class LiteLoaderEventBroker<TClient, TServer extends MinecraftSe |
469 | 469 | |
470 | 470 | void onPlayerSettingsReceived(EntityPlayerMP player, C15PacketClientSettings packet) |
471 | 471 | { |
472 | - this.getPlayerState(player).setTraceDistance(PrivateFields.viewDistance.get(packet)); | |
472 | + PlayerEventState playerState = this.getPlayerState(player); | |
473 | + playerState.setTraceDistance(PrivateFields.viewDistance.get(packet)); | |
474 | + playerState.setLocale(packet.getLang()); | |
473 | 475 | } |
474 | 476 | |
475 | - protected PlayerEventState getPlayerState(EntityPlayerMP player) | |
477 | + public PlayerEventState getPlayerState(EntityPlayerMP player) | |
476 | 478 | { |
477 | 479 | PlayerEventState playerState = this.playerStates.get(player.getUniqueID()); |
478 | 480 | if (playerState == null) | ... | ... |
java/common/com/mumfrey/liteloader/core/PlayerEventState.java
... | ... | @@ -28,6 +28,8 @@ public class PlayerEventState implements IEventState |
28 | 28 | private boolean rightClick; |
29 | 29 | |
30 | 30 | private MovingObjectPosition hit; |
31 | + | |
32 | + private String locale = "en_US"; | |
31 | 33 | |
32 | 34 | public PlayerEventState(EntityPlayerMP player, LiteLoaderEventBroker<?, ?> broker) |
33 | 35 | { |
... | ... | @@ -39,6 +41,24 @@ public class PlayerEventState implements IEventState |
39 | 41 | { |
40 | 42 | this.traceDistance = renderDistance * 16.0; |
41 | 43 | } |
44 | + | |
45 | + public double getTraceDistance() | |
46 | + { | |
47 | + return this.traceDistance; | |
48 | + } | |
49 | + | |
50 | + public void setLocale(String lang) | |
51 | + { | |
52 | + if (lang.matches("^[a-z]{2}_[A-Z]{2}$")) | |
53 | + { | |
54 | + this.locale = lang; | |
55 | + } | |
56 | + } | |
57 | + | |
58 | + public String getLocale() | |
59 | + { | |
60 | + return this.locale; | |
61 | + } | |
42 | 62 | |
43 | 63 | public EntityPlayerMP getPlayer() |
44 | 64 | { | ... | ... |
java/common/com/mumfrey/liteloader/util/Input.java
... | ... | @@ -5,7 +5,7 @@ import net.minecraft.client.settings.KeyBinding; |
5 | 5 | import com.mumfrey.liteloader.api.CoreProvider; |
6 | 6 | import com.mumfrey.liteloader.util.jinput.ComponentRegistry; |
7 | 7 | |
8 | -public interface Input extends CoreProvider | |
8 | +public abstract class Input implements CoreProvider | |
9 | 9 | { |
10 | 10 | /** |
11 | 11 | * Register a key for a mod | ... | ... |