Skip to content
This repository has been archived by the owner. It is now read-only.
Permalink
Browse files

Use Minecraft Language System

  • Loading branch information...
ComputerBaer committed Jan 4, 2017
1 parent 4411888 commit eb1dcae8ed176548fc270c1438f514e540ea6b85
Showing with 96 additions and 538 deletions.
  1. +9 −12 RewiMod-Core/src/main/java/tv/rewinside/rewimod/core/RewiMod.java
  2. +9 −11 ...edEvent.java → RewiMod-Core/src/main/java/tv/rewinside/rewimod/core/handlers/IMessageHandler.java
  3. +0 −111 RewiMod-Core/src/main/java/tv/rewinside/rewimod/core/util/Messages.java
  4. +3 −4 RewiMod-Core/src/main/resources/assets/rewimod/lang/de_DE.lang
  5. +3 −4 RewiMod-Core/src/main/resources/assets/rewimod/lang/en_US.lang
  6. +2 −2 RewiMod-Forge1.10/src/main/java/tv/rewinside/rewimod/forge/RewiForgeMod.java
  7. +1 −1 RewiMod-Forge1.10/src/main/java/tv/rewinside/rewimod/forge/gui/GuiRewiIngameMenu.java
  8. +1 −1 RewiMod-Forge1.10/src/main/java/tv/rewinside/rewimod/forge/gui/GuiRewiIngameOverlay.java
  9. +0 −44 RewiMod-Forge1.10/src/main/java/tv/rewinside/rewimod/forge/gui/GuiRewiLanguage.java
  10. +1 −1 RewiMod-Forge1.10/src/main/java/tv/rewinside/rewimod/forge/gui/objects/GuiRewiReportsButton.java
  11. +7 −8 .../java/tv/rewinside/rewimod/forge/{event/LanguageChangedEvent.java → handlers/MessageHandler.java}
  12. +0 −11 RewiMod-Forge1.10/src/main/java/tv/rewinside/rewimod/forge/listener/GuiListener.java
  13. +0 −33 RewiMod-Forge1.10/src/main/java/tv/rewinside/rewimod/forge/listener/LanguageListener.java
  14. +2 −2 RewiMod-Forge1.11/src/main/java/tv/rewinside/rewimod/forge/RewiForgeMod.java
  15. +1 −1 RewiMod-Forge1.11/src/main/java/tv/rewinside/rewimod/forge/gui/GuiRewiIngameMenu.java
  16. +1 −1 RewiMod-Forge1.11/src/main/java/tv/rewinside/rewimod/forge/gui/GuiRewiIngameOverlay.java
  17. +0 −44 RewiMod-Forge1.11/src/main/java/tv/rewinside/rewimod/forge/gui/GuiRewiLanguage.java
  18. +1 −1 RewiMod-Forge1.11/src/main/java/tv/rewinside/rewimod/forge/gui/objects/GuiRewiReportsButton.java
  19. +7 −8 ...nt.java → RewiMod-Forge1.11/src/main/java/tv/rewinside/rewimod/forge/handlers/MessageHandler.java
  20. +0 −11 RewiMod-Forge1.11/src/main/java/tv/rewinside/rewimod/forge/listener/GuiListener.java
  21. +0 −33 RewiMod-Forge1.11/src/main/java/tv/rewinside/rewimod/forge/listener/LanguageListener.java
  22. +2 −2 RewiMod-Forge1.8/src/main/java/tv/rewinside/rewimod/forge/RewiForgeMod.java
  23. +1 −1 RewiMod-Forge1.8/src/main/java/tv/rewinside/rewimod/forge/gui/GuiRewiIngameMenu.java
  24. +1 −1 RewiMod-Forge1.8/src/main/java/tv/rewinside/rewimod/forge/gui/GuiRewiIngameOverlay.java
  25. +0 −44 RewiMod-Forge1.8/src/main/java/tv/rewinside/rewimod/forge/gui/GuiRewiLanguage.java
  26. +1 −1 RewiMod-Forge1.8/src/main/java/tv/rewinside/rewimod/forge/gui/objects/GuiRewiReportsButton.java
  27. +7 −8 ...ent.java → RewiMod-Forge1.8/src/main/java/tv/rewinside/rewimod/forge/handlers/MessageHandler.java
  28. +0 −11 RewiMod-Forge1.8/src/main/java/tv/rewinside/rewimod/forge/listener/GuiListener.java
  29. +0 −33 RewiMod-Forge1.8/src/main/java/tv/rewinside/rewimod/forge/listener/LanguageListener.java
  30. +2 −2 RewiMod-Forge1.9/src/main/java/tv/rewinside/rewimod/forge/RewiForgeMod.java
  31. +1 −1 RewiMod-Forge1.9/src/main/java/tv/rewinside/rewimod/forge/gui/GuiRewiIngameMenu.java
  32. +1 −1 RewiMod-Forge1.9/src/main/java/tv/rewinside/rewimod/forge/gui/GuiRewiIngameOverlay.java
  33. +0 −44 RewiMod-Forge1.9/src/main/java/tv/rewinside/rewimod/forge/gui/GuiRewiLanguage.java
  34. +1 −1 RewiMod-Forge1.9/src/main/java/tv/rewinside/rewimod/forge/gui/objects/GuiRewiReportsButton.java
  35. +31 −0 RewiMod-Forge1.9/src/main/java/tv/rewinside/rewimod/forge/handlers/MessageHandler.java
  36. +0 −11 RewiMod-Forge1.9/src/main/java/tv/rewinside/rewimod/forge/listener/GuiListener.java
  37. +0 −33 RewiMod-Forge1.9/src/main/java/tv/rewinside/rewimod/forge/listener/LanguageListener.java
@@ -33,9 +33,9 @@
import tv.rewinside.rewimod.core.handlers.IFontRendererObjHandler;
import tv.rewinside.rewimod.core.handlers.IGlStateManagerHandler;
import tv.rewinside.rewimod.core.handlers.IGuiHandler;
import tv.rewinside.rewimod.core.handlers.IMessageHandler;
import tv.rewinside.rewimod.core.handlers.ITextureHandler;
import tv.rewinside.rewimod.core.util.Chatlog;
import tv.rewinside.rewimod.core.util.Messages;

public abstract class RewiMod {

@@ -45,8 +45,6 @@

@Getter private static RewiMod instance;

@Getter private final Messages messages = new Messages();

@Getter private final ScheduledExecutorService executorService = Executors.newScheduledThreadPool(1);

@Getter private final int confirmDisconnectButtonColor = new Color(252, 53, 57).getRGB();
@@ -58,13 +56,6 @@
@Getter private final List<String> blacklistedWords = new ArrayList<>();
@Getter private final List<Chatlog> chatlogs = new ArrayList<>();

/**
* Constructs a new RewiMod with the default Language loaded
*/
protected RewiMod() {
this.messages.load(null);
}

/**
* Initializes the Mod
*
@@ -79,7 +70,6 @@ protected void initialize(String language, String mcVersion, String uuid, String
this.uuid = uuid;
this.username = username;

this.messages.load(language);
this.registerEvents();

this.setDisplayTitle("Minecraft " + this.getMinecraftVersion() + " - " + this.getName() + " " + this.getVersion() + " - " + this.getUsername());
@@ -91,7 +81,7 @@ protected void initialize(String language, String mcVersion, String uuid, String
* Logs a warning, that the Fingerprint is invalid
*/
protected void onFingerprintViolation() {
LOGGER.warn(this.messages.getMessage("startup.signedFail"));
LOGGER.warn("!!! NO ORIGINAL REWIMOD VERSION !!!");
}

/**
@@ -189,4 +179,11 @@ public void openUrl(String url) {
*/
public abstract IGlStateManagerHandler getGlStateManagerHandler();

/**
* Gets the handler for handling the Messages
*
* @return an implementation of {@link tv.rewinside.rewimod.core.handlers.IMessageHandler}
*/
public abstract IMessageHandler getMessageHandler();

}
@@ -16,17 +16,15 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package tv.rewinside.rewimod.forge.event;
package tv.rewinside.rewimod.core.handlers;

import lombok.Getter;
import net.minecraftforge.fml.common.eventhandler.Event;

public class LanguageChangedEvent extends Event {

@Getter private final String locale;

public LanguageChangedEvent(String locale) {
this.locale = locale;
}
public interface IMessageHandler {

/**
* Gets the Message
*
* @param key the key of the message
* @return the message
*/
public String getMessage(String key);
}

This file was deleted.

@@ -2,7 +2,6 @@
# Language File for Germany #
# # # # # # # # # # # # # # #

startup.signedFail = !!! KEINE ORIGINALE AUSGABE DER REWIMOD !!!
gui.confirmDisconnect = Verlassen bestätigen
gui.chatlogHistory = Deine Reports
gui.overlay.time = Zeit
gui.confirmDisconnect=Verlassen bestätigen
gui.chatlogHistory=Deine Reports
gui.overlay.time=Zeit
@@ -2,7 +2,6 @@
# Language File for the USA #
# # # # # # # # # # # # # # #

startup.signedFail = !!! NO ORIGINAL REWIMOD VERSION !!!
gui.confirmDisconnect = Confirm disconnect
gui.chatlogHistory = Your reports
gui.overlay.time = Time
gui.confirmDisconnect=Confirm disconnect
gui.chatlogHistory=Your reports
gui.overlay.time=Time
@@ -36,11 +36,11 @@
import tv.rewinside.rewimod.forge.handlers.FontRendererObjHandler;
import tv.rewinside.rewimod.forge.handlers.GlStateManagerHandler;
import tv.rewinside.rewimod.forge.handlers.GuiHandler;
import tv.rewinside.rewimod.forge.handlers.MessageHandler;
import tv.rewinside.rewimod.forge.handlers.TextureHandler;
import tv.rewinside.rewimod.forge.listener.ChatListener;
import tv.rewinside.rewimod.forge.listener.ConnectListener;
import tv.rewinside.rewimod.forge.listener.GuiListener;
import tv.rewinside.rewimod.forge.listener.LanguageListener;
import tv.rewinside.rewimod.forge.listener.RenderListener;

@Mod(modid = "%MOD_ID%", name = "%MOD_NAME%", version = "%MOD_VERSION%", canBeDeactivated = RewiMod.DEACTIVATEABLE, certificateFingerprint = RewiMod.FINGERPRINT)
@@ -50,6 +50,7 @@
@Getter private final TextureHandler textureHandler = new TextureHandler();
@Getter private final GuiHandler guiHandler = new GuiHandler();
@Getter private final GlStateManagerHandler glStateManagerHandler = new GlStateManagerHandler();
@Getter private final MessageHandler messageHandler = new MessageHandler();
@Getter private final ButtonFactory defaultButtonFactory = new ButtonFactory("textures/gui/widgets.png", 200, 20, new Point(0, 46), new Point(0, 66), new Point(0, 86));

@Getter private final ServerPinger pinger = new ServerPinger();
@@ -75,7 +76,6 @@ protected void registerEvents() {
MinecraftForge.EVENT_BUS.register(new ChatListener());
MinecraftForge.EVENT_BUS.register(new ConnectListener());
MinecraftForge.EVENT_BUS.register(new RenderListener());
MinecraftForge.EVENT_BUS.register(new LanguageListener());
}

@Override
@@ -85,7 +85,7 @@ protected void mouseClicked(int mouseX, int mouseY, int mouseButton) throws IOEx

@Override
protected void actionPerformed(GuiButton button) throws IOException {
String confirmMessage = RewiMod.getInstance().getMessages().getMessage("gui.confirmDisconnect");
String confirmMessage = RewiMod.getInstance().getMessageHandler().getMessage("gui.confirmDisconnect");

if (button.id == 1 && !button.displayString.equals(confirmMessage)) {
button.displayString = confirmMessage;
@@ -44,7 +44,7 @@ public GuiRewiIngameOverlay() {
}

public void drawOverlay() {
String timeText = RewiMod.getInstance().getMessages().getMessage("gui.overlay.time");
String timeText = RewiMod.getInstance().getMessageHandler().getMessage("gui.overlay.time");
ServerData serverData = this.mc.getCurrentServerData();
long ping = serverData != null ? serverData.pingToServer : -1;

This file was deleted.

@@ -27,7 +27,7 @@
public class GuiRewiReportsButton extends GuiButton implements IGuiButton {

public GuiRewiReportsButton(int buttonId, int x, int y, int width) {
super(buttonId, x, y, width, 20, RewiForgeMod.getInstance().getMessages().getMessage("gui.chatlogHistory"));
super(buttonId, x, y, width, 20, RewiForgeMod.getInstance().getMessageHandler().getMessage("gui.chatlogHistory"));
}

@Override
@@ -16,17 +16,16 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package tv.rewinside.rewimod.forge.event;
package tv.rewinside.rewimod.forge.handlers;

import lombok.Getter;
import net.minecraftforge.fml.common.eventhandler.Event;
import net.minecraft.client.resources.I18n;
import tv.rewinside.rewimod.core.handlers.IMessageHandler;

public class LanguageChangedEvent extends Event {
public class MessageHandler implements IMessageHandler {

@Getter private final String locale;

public LanguageChangedEvent(String locale) {
this.locale = locale;
@Override
public String getMessage(String key) {
return I18n.format(key, new Object[0]);
}

}
@@ -18,21 +18,15 @@
*/
package tv.rewinside.rewimod.forge.listener;

import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiIngameMenu;
import net.minecraft.client.gui.GuiLanguage;
import net.minecraft.client.gui.GuiMainMenu;
import net.minecraft.client.gui.GuiScreen;
import net.minecraftforge.client.event.GuiOpenEvent;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import tv.rewinside.rewimod.forge.gui.GuiRewiIngameMenu;
import tv.rewinside.rewimod.forge.gui.GuiRewiLanguage;
import tv.rewinside.rewimod.forge.gui.GuiRewiMainMenu;

public class GuiListener {

private GuiScreen oldScreen;

@SubscribeEvent
public void onGuiOpen(GuiOpenEvent event) {
if (event.getGui() instanceof GuiMainMenu) {
@@ -41,11 +35,6 @@ public void onGuiOpen(GuiOpenEvent event) {
if (event.getGui() instanceof GuiIngameMenu) {
event.setGui(new GuiRewiIngameMenu());
}
if (event.getGui() instanceof GuiLanguage) {
event.setGui(new GuiRewiLanguage(oldScreen, Minecraft.getMinecraft().gameSettings, Minecraft.getMinecraft().getLanguageManager()));
}

oldScreen = event.getGui();
}

}

0 comments on commit eb1dcae

Please sign in to comment.
You can’t perform that action at this time.