diff options
| author | hannibal2 <24389977+hannibal002@users.noreply.github.com> | 2022-10-23 13:33:15 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-10-23 13:33:15 +0200 |
| commit | dd6a4011a95da0481b98ff472dedc7911f9a3741 (patch) | |
| tree | c526a50c3dd178cc55b6d92529e6c89d265dc0ce /src/main/java/io/github/moulberry/notenoughupdates/util/Utils.java | |
| parent | a2e1983b47392d7724df78f842ef81bfb6f67d60 (diff) | |
| download | notenoughupdates-dd6a4011a95da0481b98ff472dedc7911f9a3741.tar.gz notenoughupdates-dd6a4011a95da0481b98ff472dedc7911f9a3741.tar.bz2 notenoughupdates-dd6a4011a95da0481b98ff472dedc7911f9a3741.zip | |
Minion Helper (#254)
Co-authored-by: hannibal2 <24389977+hannibal00212@users.noreply.github.com>
Co-authored-by: ThexXTURBOXx <nico.mexis@kabelmail.de>
Co-authored-by: efefury <69400149+efefury@users.noreply.github.com>
Diffstat (limited to 'src/main/java/io/github/moulberry/notenoughupdates/util/Utils.java')
| -rw-r--r-- | src/main/java/io/github/moulberry/notenoughupdates/util/Utils.java | 30 |
1 files changed, 23 insertions, 7 deletions
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/util/Utils.java b/src/main/java/io/github/moulberry/notenoughupdates/util/Utils.java index b02565cd..57f24370 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/util/Utils.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/util/Utils.java @@ -78,6 +78,7 @@ import java.math.BigInteger; import java.nio.FloatBuffer; import java.nio.charset.StandardCharsets; import java.nio.file.Files; +import java.text.DecimalFormat; import java.util.ArrayList; import java.util.Collections; import java.util.HashMap; @@ -143,6 +144,7 @@ public class Utils { public static Splitter PATH_SPLITTER = Splitter.on(".").omitEmptyStrings().limit(2); private static ScaledResolution lastScale = new ScaledResolution(Minecraft.getMinecraft()); private static long startTime = 0; + private static DecimalFormat simpleDoubleFormat = new DecimalFormat("0.0"); public static <T> ArrayList<T> createList(T... values) { ArrayList<T> list = new ArrayList<>(); @@ -325,6 +327,11 @@ public class Utils { } public static String shortNumberFormat(double n, int iteration) { + if (n < 3 && n > 0) { + return simpleDoubleFormat.format(n); + } + + if (n < 1000 && iteration == 0) return "" + (int) n; double d = ((long) n / 100) / 10.0; boolean isRound = (d * 10) % 10 == 0; return (d < 1000 ? @@ -1941,13 +1948,13 @@ public class Utils { if (NotEnoughUpdates.INSTANCE.config.notifications.outdatedRepo) { NotificationHandler.displayNotification(Lists.newArrayList( EnumChatFormatting.RED + EnumChatFormatting.BOLD.toString() + "Missing repo data", - EnumChatFormatting.RED + - "Data used for many NEU features is not up to date, this should normally not be the case.", - EnumChatFormatting.RED + "You can try " + EnumChatFormatting.BOLD + "/neuresetrepo" + EnumChatFormatting.RESET + - EnumChatFormatting.RED + " and restart your game" + - " to see if that fixes the issue.", - EnumChatFormatting.RED + "If the problem persists please join " + EnumChatFormatting.BOLD + - "discord.gg/moulberry" + + EnumChatFormatting.RED + + "Data used for many NEU features is not up to date, this should normally not be the case.", + EnumChatFormatting.RED + "You can try " + EnumChatFormatting.BOLD + "/neuresetrepo" + EnumChatFormatting.RESET + + EnumChatFormatting.RED + " and restart your game" + + " to see if that fixes the issue.", + EnumChatFormatting.RED + "If the problem persists please join " + EnumChatFormatting.BOLD + + "discord.gg/moulberry" + EnumChatFormatting.RESET + EnumChatFormatting.RED + " and message in " + EnumChatFormatting.BOLD + "#neu-support" + EnumChatFormatting.RESET + EnumChatFormatting.RED + " to get support" ), @@ -2011,4 +2018,13 @@ public class Utils { } return username; } + + public static void addChatMessage(String message) { + EntityPlayerSP thePlayer = Minecraft.getMinecraft().thePlayer; + if (thePlayer != null) { + thePlayer.addChatMessage(new ChatComponentText(message)); + } else { + System.out.println(message); + } + } } |
