From 55ee2b01e25c7f7f6c4c893e18572150266ebd03 Mon Sep 17 00:00:00 2001 From: Draknyte1 Date: Mon, 18 Jul 2016 05:16:57 +1000 Subject: % Finalised a few things with Random Hex Generation related stuff. --- src/Java/miscutil/core/util/Utils.java | 29 ++++++++++++++++++----------- 1 file changed, 18 insertions(+), 11 deletions(-) (limited to 'src/Java/miscutil') diff --git a/src/Java/miscutil/core/util/Utils.java b/src/Java/miscutil/core/util/Utils.java index 5dd121f9b6..e85d65fff0 100644 --- a/src/Java/miscutil/core/util/Utils.java +++ b/src/Java/miscutil/core/util/Utils.java @@ -419,14 +419,20 @@ public class Utils { String hexChar = "0x"; String result; if (hexAsStringOrInt.getClass() == String.class){ - result = hexChar+hexAsStringOrInt; - if (result.length() != 6){ - String temp = leftPadWithZeroes(result, 6); + + if (((String) hexAsStringOrInt).length() != 6){ + String temp = leftPadWithZeroes((String) hexAsStringOrInt, 6); result = temp; } + result = hexChar+hexAsStringOrInt; return result; } else if (hexAsStringOrInt.getClass() == Integer.class){ + ; + if (((String) hexAsStringOrInt).length() != 6){ + String temp = leftPadWithZeroes((String) hexAsStringOrInt, 6); + result = temp; + } result = hexChar+String.valueOf(hexAsStringOrInt); return result; } @@ -445,20 +451,21 @@ public class Utils { public static int generateSingularRandomHexValue(){ String temp; - int usefuleNumber = 0; - int tDecided = randInt(1, 5); + int usefulNum = 0; + int randomInt = randInt(1, 5); final Map colours = Utils.hexColourGeneratorRandom(5); - if (colours.get(tDecided) != null && colours.size() > 0){ - usefuleNumber = Integer.getInteger(colours.get(tDecided)); + if (colours.get(randomInt) != null && colours.size() > 0){ + temp = colours.get(randomInt); } else { - usefuleNumber = 123456; + temp = "0F0F0F"; } - Utils.LOG_INFO("Operating with "+usefuleNumber); - temp = Utils.appenedHexNotationToString(String.valueOf(usefuleNumber)); - Utils.LOG_INFO("Made "+temp+" - Hopefully it's not a mess."); + Utils.LOG_INFO("Operating with "+temp); + temp = Utils.appenedHexNotationToString(String.valueOf(temp)); + Utils.LOG_INFO("Made "+temp+" - Hopefully it's not a mess."); + Utils.LOG_INFO("It will decode into "+Integer.decode(temp)+"."); return Integer.decode(temp); } -- cgit