diff options
author | IlmarsXd <ilmars500@gmail.com> | 2023-03-21 17:37:12 +0200 |
---|---|---|
committer | IlmarsXd <ilmars500@gmail.com> | 2023-03-21 17:37:12 +0200 |
commit | 623f260e2f1d586336fca13dc86bf2ffb0c6565c (patch) | |
tree | d54f367541619b80ae1863f5acb3d9f09de7bada /src/main/kotlin/dulkirmod/utils/Utils.kt | |
parent | e7723d5ff52da94eb65992b5bdd9c5bb316d5959 (diff) | |
download | DulkirMod-623f260e2f1d586336fca13dc86bf2ffb0c6565c.tar.gz DulkirMod-623f260e2f1d586336fca13dc86bf2ffb0c6565c.tar.bz2 DulkirMod-623f260e2f1d586336fca13dc86bf2ffb0c6565c.zip |
refactor modules
Diffstat (limited to 'src/main/kotlin/dulkirmod/utils/Utils.kt')
-rw-r--r-- | src/main/kotlin/dulkirmod/utils/Utils.kt | 98 |
1 files changed, 46 insertions, 52 deletions
diff --git a/src/main/kotlin/dulkirmod/utils/Utils.kt b/src/main/kotlin/dulkirmod/utils/Utils.kt index 2ae50cc..ce19b32 100644 --- a/src/main/kotlin/dulkirmod/utils/Utils.kt +++ b/src/main/kotlin/dulkirmod/utils/Utils.kt @@ -11,60 +11,54 @@ import java.awt.datatransfer.StringSelection import java.util.* object Utils { - fun stripColorCodes(string: String): String { - return string.replace("§.".toRegex(), "") - } + fun stripColorCodes(string: String): String { + return string.replace("§.".toRegex(), "") + } - fun animationConfigToString() { - var s = "" - var gson = Gson() - var jsonString = gson.toJson(ConfigData()) - s = Base64.getEncoder().encodeToString(jsonString.toByteArray()) - // set clipboard - val selection = StringSelection(s) - val clipboard: Clipboard = Toolkit.getDefaultToolkit().systemClipboard - clipboard.setContents(selection, selection) - } + fun animationConfigToString() { + var s = "" + var gson = Gson() + var jsonString = gson.toJson(ConfigData()) + s = Base64.getEncoder().encodeToString(jsonString.toByteArray()) + // set clipboard + val selection = StringSelection(s) + val clipboard: Clipboard = Toolkit.getDefaultToolkit().systemClipboard + clipboard.setContents(selection, selection) + } - fun animationStringtoConfig() { - val gson = Gson() - val clipboard: Clipboard = Toolkit.getDefaultToolkit().systemClipboard - val base64 = clipboard.getData(DataFlavor.stringFlavor) as String - try { - val jsonString = String(Base64.getDecoder().decode(base64)) - val import = gson.fromJson(jsonString, ConfigData::class.java) - Config.customSize = import.size - Config.customSpeed = import.speed - Config.doesScaleSwing = import.scaleSwing - Config.customX = import.x - Config.customY = import.y - Config.customZ = import.z - Config.customYaw = import.yaw - Config.customPitch = import.pitch - Config.customRoll = import.roll - Config.drinkingSelector = import.drinkingFix - Config.ignoreHaste = import.ignoreHaste - } catch (e: Exception) { - TextUtils.info("§6§lCurrent clipboard is not a recognizable Custom Animation Preset.") - } - mc.displayGuiScreen(null) - } + fun animationStringtoConfig() { + val gson = Gson() + val clipboard = Toolkit.getDefaultToolkit().systemClipboard + val base64 = clipboard.getData(DataFlavor.stringFlavor) as String + try { + val jsonString = String(Base64.getDecoder().decode(base64)) + val import = gson.fromJson(jsonString, ConfigData::class.java) + Config.customSize = import.size + Config.customSpeed = import.speed + Config.doesScaleSwing = import.scaleSwing + Config.customX = import.x + Config.customY = import.y + Config.customZ = import.z + Config.customYaw = import.yaw + Config.customPitch = import.pitch + Config.customRoll = import.roll + Config.drinkingSelector = import.drinkingFix + Config.ignoreHaste = import.ignoreHaste + } catch (e: Exception) { + TextUtils.info("§6§lCurrent clipboard is not a recognizable Custom Animation Preset.") + } + mc.displayGuiScreen(null) + } - fun isInSkyblock(): Boolean { - if ((mc.theWorld != null) && (mc.thePlayer != null)) { - if (mc.isSingleplayer || mc.thePlayer.clientBrand == null || - !mc.thePlayer.clientBrand.lowercase(Locale.getDefault()).contains("hypixel") - ) { - return false - } - if (mc.thePlayer.worldScoreboard.getObjectiveInDisplaySlot(1) == null) - return false - return stripColorCodes(mc.thePlayer.worldScoreboard.getObjectiveInDisplaySlot(1).displayName).contains("SKYBLOCK") - } - return false - } + fun isInSkyblock(): Boolean { + if (mc.theWorld == null || mc.thePlayer == null) return false + if (mc.isSingleplayer) return false + if (mc.thePlayer.clientBrand?.contains("hypixel", true) == false) return false + val objective = mc.thePlayer.worldScoreboard.getObjectiveInDisplaySlot(1) ?: return false + return stripColorCodes(objective.displayName).contains("skyblock", true) + } - fun getColorString(int: Int): String { - return if (int == 16) "§z" else EnumChatFormatting.values()[int].toString() - } + fun getColorString(int: Int): String { + return if (int == 16) "§z" else EnumChatFormatting.values()[int].toString() + } }
\ No newline at end of file |