diff --git a/src/main/java/com/enderio/core/client/handlers/SpecialTooltipHandler.java b/src/main/java/com/enderio/core/client/handlers/SpecialTooltipHandler.java index a9a8224..cdbf338 100644 --- a/src/main/java/com/enderio/core/client/handlers/SpecialTooltipHandler.java +++ b/src/main/java/com/enderio/core/client/handlers/SpecialTooltipHandler.java @@ -20,13 +20,13 @@ import net.minecraftforge.event.entity.player.ItemTooltipEvent; import org.lwjgl.input.Keyboard; +import com.enderio.core.EnderCore; import com.enderio.core.api.client.gui.IAdvancedTooltipProvider; import com.enderio.core.api.client.gui.IResourceTooltipProvider; import com.enderio.core.common.Handlers.Handler; import com.enderio.core.common.Handlers.Handler.HandlerType; import com.enderio.core.common.config.ConfigHandler; import com.enderio.core.common.util.ItemUtil; -import com.enderio.core.common.util.Lang; import com.google.common.collect.Lists; import cpw.mods.fml.common.eventhandler.SubscribeEvent; @@ -145,7 +145,7 @@ public class SpecialTooltipHandler { } public static void addShowDetailsTooltip(List list) { - list.add(EnumChatFormatting.WHITE + "" + EnumChatFormatting.ITALIC + Lang.localize("item.tooltip.showDetails")); + list.add(EnumChatFormatting.WHITE + "" + EnumChatFormatting.ITALIC + EnderCore.lang.localize("item.tooltip.showDetails")); } public static boolean showAdvancedTooltips() { @@ -169,7 +169,7 @@ public class SpecialTooltipHandler { int line = 1; while (!done) { String key = keyBase + line; - String val = Lang.localize(key, false); + String val = EnderCore.lang.localize(key, false); if(val == null || val.trim().length() < 0 || val.equals(key) || line > 12) { done = true; } else { diff --git a/src/main/java/com/enderio/core/common/Lang.java b/src/main/java/com/enderio/core/common/Lang.java index fdb950b..024d242 100644 --- a/src/main/java/com/enderio/core/common/Lang.java +++ b/src/main/java/com/enderio/core/common/Lang.java @@ -6,103 +6,104 @@ import net.minecraft.util.StatCollector; @AllArgsConstructor @Getter -public class Lang -{ - private static final String REGEX = "\\" + '|'; - public static final char CHAR = '|'; +public class Lang { - private String locKey; + private static final String REGEX = "\\" + '|'; + public static final char CHAR = '|'; - /** - * Adds the stored prefix to this string, separating with a period. Using this method returns the string that is used for localizing if you passed - * this arg into {@link #localize(String, Object...)}. - * - * @param suffix - * The suffix string - * @return The full string - */ - public String addPrefix(String suffix) - { - return locKey + "." + suffix; - } + private String locKey; - /** - * Localizes the string passed, first appending the prefix stored in this instance of the class. - * - * @param unloc - * The unlocalized string. - * @param args - * The args to format the localized text withi. - * - * @return A localized string. - */ - public String localize(String unloc, Object... args) - { - return localizeExact(addPrefix(unloc), args); - } + /** + * Adds the stored prefix to this string, separating with a period. Using this + * method returns the string that is used for localizing if you passed this + * arg into {@link #localize(String, Object...)}. + * + * @param suffix + * The suffix string + * @return The full string + */ + public String addPrefix(String suffix) { + return locKey + "." + suffix; + } - /** - * Ignores the prefix stored in this instance of the class and localizes the raw string passed. - * - * @param unloc - * The unlocalized string. - * @param args - * The args to format the localized text withi. - * - * @return A localized string. - */ - public String localizeExact(String unloc, Object... args) - { - return StatCollector.translateToLocalFormatted(unloc, args); - } + /** + * Localizes the string passed, first appending the prefix stored in this + * instance of the class. + * + * @param unloc + * The unlocalized string. + * @param args + * The args to format the localized text withi. + * + * @return A localized string. + */ + public String localize(String unloc, Object... args) { + return localizeExact(addPrefix(unloc), args); + } - /** - * Splits the localized text on "|" into a String[]. - * - * @param unloc - * The unlocalized string. - * @param args - * The args to format the localized text withi. - * @return A localized list of strings. - */ - public String[] localizeList(String unloc, String... args) - { - return splitList(localize(unloc, true, args)); - } + /** + * Ignores the prefix stored in this instance of the class and localizes the + * raw string passed. + * + * @param unloc + * The unlocalized string. + * @param args + * The args to format the localized text withi. + * + * @return A localized string. + */ + public String localizeExact(String unloc, Object... args) { + return StatCollector.translateToLocalFormatted(unloc, args); + } - /** - * Splits a list of strings based on {@value #CHAR} - * - * @param list - * The list of strings to split - * @return An array of strings split on {@value #CHAR} - */ - public String[] splitList(String list) - { - return list.split(REGEX); - } + /** + * Splits the localized text on "|" into a String[]. + * + * @param unloc + * The unlocalized string. + * @param args + * The args to format the localized text withi. + * @return A localized list of strings. + */ + public String[] localizeList(String unloc, String... args) { + return splitList(localize(unloc, true, args)); + } - /** - * Checks if the passed string (plus the prefix) has a localization mapped. - * - * @param unloc - * The unlocalized suffix - * @return True if there is a localization mapped, false otherwise. - */ - public boolean canLocalize(String unloc) - { - return canLocalizeExact(addPrefix(unloc)); - } + /** + * Splits a list of strings based on {@value #CHAR} + * + * @param list + * The list of strings to split + * @return An array of strings split on {@value #CHAR} + */ + public String[] splitList(String list) { + return list.split(REGEX); + } - /** - * Checks if the passed string has a localization mapped. Does not use the prefix. - * - * @param unloc - * The unlocalized string - * @return True if there is a localization mapped, false otherwise. - */ - public boolean canLocalizeExact(String unloc) - { - return StatCollector.canTranslate(unloc); - } + public String[] splitList(String list, String split) { + return list.split(split); + } + + /** + * Checks if the passed string (plus the prefix) has a localization mapped. + * + * @param unloc + * The unlocalized suffix + * @return True if there is a localization mapped, false otherwise. + */ + public boolean canLocalize(String unloc) { + return canLocalizeExact(addPrefix(unloc)); + } + + /** + * Checks if the passed string has a localization mapped. Does not use the + * prefix. + * + * @param unloc + * The unlocalized string + * @return True if there is a localization mapped, false otherwise. + */ + public boolean canLocalizeExact(String unloc) { + return StatCollector.canTranslate(unloc); + } } diff --git a/src/main/java/com/enderio/core/common/util/DyeColor.java b/src/main/java/com/enderio/core/common/util/DyeColor.java index fc71a25..03e92a9 100644 --- a/src/main/java/com/enderio/core/common/util/DyeColor.java +++ b/src/main/java/com/enderio/core/common/util/DyeColor.java @@ -1,5 +1,7 @@ package com.enderio.core.common.util; +import com.enderio.core.EnderCore; + import net.minecraft.item.ItemDye; import net.minecraft.item.ItemStack; import net.minecraftforge.oredict.OreDictionary; @@ -104,7 +106,7 @@ public enum DyeColor { } public String getLocalisedName() { - return Lang.localize(DYE_ORE_UNLOCAL_NAMES[ordinal()], false); + return EnderCore.lang.localize(DYE_ORE_UNLOCAL_NAMES[ordinal()], false); } @Override diff --git a/src/main/java/com/enderio/core/common/util/ItemUtil.java b/src/main/java/com/enderio/core/common/util/ItemUtil.java index 80b7477..540fe59 100644 --- a/src/main/java/com/enderio/core/common/util/ItemUtil.java +++ b/src/main/java/com/enderio/core/common/util/ItemUtil.java @@ -4,6 +4,7 @@ import java.util.ArrayList; import java.util.List; import java.util.Random; +import com.enderio.core.EnderCore; import com.enderio.core.api.common.util.IItemReceptor; import net.minecraft.block.Block; @@ -288,7 +289,7 @@ public class ItemUtil { if (item == null) { return null; } - return Lang.localize("item.darkSteel.tooltip.durability") + " " + (item.getMaxDamage() - item.getItemDamage()) + "/" + item.getMaxDamage(); + return EnderCore.lang.localize("item.darkSteel.tooltip.durability") + " " + (item.getMaxDamage() - item.getItemDamage()) + "/" + item.getMaxDamage(); } public static NBTTagCompound getOrCreateNBT(ItemStack stack) { diff --git a/src/main/java/com/enderio/core/common/util/Lang.java b/src/main/java/com/enderio/core/common/util/Lang.java deleted file mode 100644 index bcdfee4..0000000 --- a/src/main/java/com/enderio/core/common/util/Lang.java +++ /dev/null @@ -1,31 +0,0 @@ -package com.enderio.core.common.util; - -import java.util.IllegalFormatException; - -import net.minecraft.util.StatCollector; - -public class Lang { - - public static final String prefix = "enderio."; - - public static String localize(String s, String... args) { - return localize(s, true, args); - } - - public static String localize(String s, boolean appendEIO, String... args) { - if(appendEIO) { - s = prefix + s; - } - String ret = StatCollector.translateToLocal(s); - try { - return String.format(ret, (Object[]) args); - } catch (IllegalFormatException e) { - return ret; - } - } - - public static String[] localizeList(String string) { - String s = localize(string); - return s.split("\\|"); - } -}