diff options
author | Lorenz <ESs95s3P5z8Pheb> | 2022-07-08 10:05:47 +0200 |
---|---|---|
committer | Lorenz <ESs95s3P5z8Pheb> | 2022-07-08 10:05:47 +0200 |
commit | 697389e5a2bffdbe40be6ee9418dcf19e64ba3ce (patch) | |
tree | a75ee28dd19d85be47c635013ec601f762fb5504 /src | |
parent | f255bd7048d1cc4a29423b7b538ee32416570700 (diff) | |
download | skyhanni-697389e5a2bffdbe40be6ee9418dcf19e64ba3ce.tar.gz skyhanni-697389e5a2bffdbe40be6ee9418dcf19e64ba3ce.tar.bz2 skyhanni-697389e5a2bffdbe40be6ee9418dcf19e64ba3ce.zip |
code cleanup
Diffstat (limited to 'src')
10 files changed, 97 insertions, 101 deletions
diff --git a/src/main/java/at/lorenz/mod/HideNotClickableItems.kt b/src/main/java/at/lorenz/mod/HideNotClickableItems.kt index 404390955..e58dbd92c 100644 --- a/src/main/java/at/lorenz/mod/HideNotClickableItems.kt +++ b/src/main/java/at/lorenz/mod/HideNotClickableItems.kt @@ -4,11 +4,11 @@ import at.lorenz.mod.bazaar.BazaarApi import at.lorenz.mod.config.LorenzConfig import at.lorenz.mod.events.GuiContainerEvent import at.lorenz.mod.utils.ItemUtils -import at.lorenz.mod.utils.ItemUtils.Companion.cleanName -import at.lorenz.mod.utils.ItemUtils.Companion.getLore +import at.lorenz.mod.utils.ItemUtils.cleanName +import at.lorenz.mod.utils.ItemUtils.getLore import at.lorenz.mod.utils.LorenzColor import at.lorenz.mod.utils.LorenzUtils -import at.lorenz.mod.utils.LorenzUtils.Companion.removeColorCodes +import at.lorenz.mod.utils.LorenzUtils.removeColorCodes import at.lorenz.mod.utils.RenderUtils.highlight import net.minecraft.client.Minecraft import net.minecraft.client.gui.inventory.GuiChest diff --git a/src/main/java/at/lorenz/mod/ItemDisplayOverlayFeatures.kt b/src/main/java/at/lorenz/mod/ItemDisplayOverlayFeatures.kt index ec5078bdc..2a0ab1a92 100644 --- a/src/main/java/at/lorenz/mod/ItemDisplayOverlayFeatures.kt +++ b/src/main/java/at/lorenz/mod/ItemDisplayOverlayFeatures.kt @@ -3,10 +3,10 @@ package at.lorenz.mod import at.lorenz.mod.config.LorenzConfig import at.lorenz.mod.events.GuiRenderItemEvent import at.lorenz.mod.utils.ItemUtils -import at.lorenz.mod.utils.ItemUtils.Companion.cleanName +import at.lorenz.mod.utils.ItemUtils.cleanName import at.lorenz.mod.utils.LorenzUtils -import at.lorenz.mod.utils.LorenzUtils.Companion.between -import at.lorenz.mod.utils.LorenzUtils.Companion.matchRegex +import at.lorenz.mod.utils.LorenzUtils.between +import at.lorenz.mod.utils.LorenzUtils.matchRegex import at.lorenz.mod.utils.NumberUtil.romanToDecimal import net.minecraft.client.renderer.GlStateManager import net.minecraft.item.ItemStack diff --git a/src/main/java/at/lorenz/mod/bazaar/BazaarDataGrabber.kt b/src/main/java/at/lorenz/mod/bazaar/BazaarDataGrabber.kt index 78341e05c..884d26515 100644 --- a/src/main/java/at/lorenz/mod/bazaar/BazaarDataGrabber.kt +++ b/src/main/java/at/lorenz/mod/bazaar/BazaarDataGrabber.kt @@ -2,7 +2,7 @@ package at.lorenz.mod.bazaar import at.lorenz.mod.utils.APIUtil import at.lorenz.mod.utils.LorenzUtils -import at.lorenz.mod.utils.LorenzUtils.Companion.round +import at.lorenz.mod.utils.LorenzUtils.round import kotlin.concurrent.fixedRateTimer internal class BazaarDataGrabber(private var bazaarMap: MutableMap<String, BazaarData>) { diff --git a/src/main/java/at/lorenz/mod/bazaar/BazaarOrderHelper.kt b/src/main/java/at/lorenz/mod/bazaar/BazaarOrderHelper.kt index ba12838e2..a393e8b31 100644 --- a/src/main/java/at/lorenz/mod/bazaar/BazaarOrderHelper.kt +++ b/src/main/java/at/lorenz/mod/bazaar/BazaarOrderHelper.kt @@ -2,7 +2,7 @@ package at.lorenz.mod.bazaar import at.lorenz.mod.config.LorenzConfig import at.lorenz.mod.events.GuiContainerEvent -import at.lorenz.mod.utils.ItemUtils.Companion.getLore +import at.lorenz.mod.utils.ItemUtils.getLore import at.lorenz.mod.utils.LorenzColor import at.lorenz.mod.utils.RenderUtils.highlight import net.minecraft.client.gui.inventory.GuiChest diff --git a/src/main/java/at/lorenz/mod/chat/ChatFilter.kt b/src/main/java/at/lorenz/mod/chat/ChatFilter.kt index 8e2160928..0951b3d4b 100644 --- a/src/main/java/at/lorenz/mod/chat/ChatFilter.kt +++ b/src/main/java/at/lorenz/mod/chat/ChatFilter.kt @@ -2,7 +2,7 @@ package at.lorenz.mod.chat import at.lorenz.mod.config.LorenzConfig import at.lorenz.mod.utils.LorenzUtils -import at.lorenz.mod.utils.LorenzUtils.Companion.matchRegex +import at.lorenz.mod.utils.LorenzUtils.matchRegex import at.lorenz.mod.events.LorenzChatEvent import net.minecraftforge.fml.common.eventhandler.SubscribeEvent diff --git a/src/main/java/at/lorenz/mod/chat/PlayerChatFilter.kt b/src/main/java/at/lorenz/mod/chat/PlayerChatFilter.kt index 427b25e37..b8ec7f87f 100644 --- a/src/main/java/at/lorenz/mod/chat/PlayerChatFilter.kt +++ b/src/main/java/at/lorenz/mod/chat/PlayerChatFilter.kt @@ -2,7 +2,7 @@ package at.lorenz.mod.chat import at.lorenz.mod.utils.LorenzLogger import at.lorenz.mod.utils.LorenzUtils -import at.lorenz.mod.utils.LorenzUtils.Companion.removeColorCodes +import at.lorenz.mod.utils.LorenzUtils.removeColorCodes import at.lorenz.mod.events.PlayerSendChatEvent class PlayerChatFilter { diff --git a/src/main/java/at/lorenz/mod/dungeon/DungeonChatFilter.kt b/src/main/java/at/lorenz/mod/dungeon/DungeonChatFilter.kt index 86fc67cfd..1fc986f7b 100644 --- a/src/main/java/at/lorenz/mod/dungeon/DungeonChatFilter.kt +++ b/src/main/java/at/lorenz/mod/dungeon/DungeonChatFilter.kt @@ -2,7 +2,7 @@ package at.lorenz.mod.dungeon import at.lorenz.mod.config.LorenzConfig import at.lorenz.mod.events.LorenzChatEvent -import at.lorenz.mod.utils.LorenzUtils.Companion.matchRegex +import at.lorenz.mod.utils.LorenzUtils.matchRegex import net.minecraftforge.fml.common.eventhandler.SubscribeEvent class DungeonChatFilter { diff --git a/src/main/java/at/lorenz/mod/utils/ItemUtils.kt b/src/main/java/at/lorenz/mod/utils/ItemUtils.kt index 44972fb0c..168b41ddf 100644 --- a/src/main/java/at/lorenz/mod/utils/ItemUtils.kt +++ b/src/main/java/at/lorenz/mod/utils/ItemUtils.kt @@ -1,51 +1,49 @@ package at.lorenz.mod.utils -import at.lorenz.mod.utils.LorenzUtils.Companion.matchRegex -import at.lorenz.mod.utils.LorenzUtils.Companion.removeColorCodes +import at.lorenz.mod.utils.LorenzUtils.matchRegex +import at.lorenz.mod.utils.LorenzUtils.removeColorCodes import net.minecraft.client.Minecraft import net.minecraft.client.gui.inventory.GuiChest import net.minecraft.item.ItemStack -class ItemUtils { - - companion object { - fun ItemStack.cleanName() = this.displayName.removeColorCodes() - - fun getItemsInOpenChest(): List<ItemStack> { - val list = mutableListOf<ItemStack>() - val guiChest = Minecraft.getMinecraft().currentScreen as GuiChest - val inventorySlots = guiChest.inventorySlots.inventorySlots - val skipAt = inventorySlots.size - 9 * 4 - var i = 0 - for (slot in inventorySlots) { - val stack = slot.stack - if (stack != null) { - list.add(stack) - } - i++ - if (i == skipAt) break +object ItemUtils { + + fun ItemStack.cleanName() = this.displayName.removeColorCodes() + + fun getItemsInOpenChest(): List<ItemStack> { + val list = mutableListOf<ItemStack>() + val guiChest = Minecraft.getMinecraft().currentScreen as GuiChest + val inventorySlots = guiChest.inventorySlots.inventorySlots + val skipAt = inventorySlots.size - 9 * 4 + var i = 0 + for (slot in inventorySlots) { + val stack = slot.stack + if (stack != null) { + list.add(stack) } - return list + i++ + if (i == skipAt) break } + return list + } - fun isSack(name: String): Boolean = name.endsWith(" Sack") + fun isSack(name: String): Boolean = name.endsWith(" Sack") - fun ItemStack.getLore() = ItemUtil.getItemLore(this) + fun ItemStack.getLore() = ItemUtil.getItemLore(this) - fun isCoOpSoulBound(stack: ItemStack): Boolean = stack.getLore().any { it.contains("Co-op Soulbound") } + fun isCoOpSoulBound(stack: ItemStack): Boolean = stack.getLore().any { it.contains("Co-op Soulbound") } - fun isRecombobulated(stack: ItemStack): Boolean = stack.getLore().any { it.contains("§k") } + fun isRecombobulated(stack: ItemStack): Boolean = stack.getLore().any { it.contains("§k") } - fun isPet(name: String): Boolean = name.matchRegex("\\[Lvl (.*)] (.*)") && !listOf( - "Archer", - "Berserk", - "Mage", - "Tank", - "Healer", - "➡", - ).any { name.contains(it) } + fun isPet(name: String): Boolean = name.matchRegex("\\[Lvl (.*)] (.*)") && !listOf( + "Archer", + "Berserk", + "Mage", + "Tank", + "Healer", + "➡", + ).any { name.contains(it) } - fun maxPetLevel(name: String) = if (name.contains("Golden Dragon")) 200 else 100 + fun maxPetLevel(name: String) = if (name.contains("Golden Dragon")) 200 else 100 - } }
\ No newline at end of file diff --git a/src/main/java/at/lorenz/mod/utils/LorenzLogger.kt b/src/main/java/at/lorenz/mod/utils/LorenzLogger.kt index de69e7e66..48bfc6099 100644 --- a/src/main/java/at/lorenz/mod/utils/LorenzLogger.kt +++ b/src/main/java/at/lorenz/mod/utils/LorenzLogger.kt @@ -1,6 +1,6 @@ package at.lorenz.mod.utils -import at.lorenz.mod.utils.LorenzUtils.Companion.formatCurrentTime +import at.lorenz.mod.utils.LorenzUtils.formatCurrentTime import java.io.File import java.io.IOException import java.text.SimpleDateFormat diff --git a/src/main/java/at/lorenz/mod/utils/LorenzUtils.kt b/src/main/java/at/lorenz/mod/utils/LorenzUtils.kt index 3bcb630e0..e27e0f50f 100644 --- a/src/main/java/at/lorenz/mod/utils/LorenzUtils.kt +++ b/src/main/java/at/lorenz/mod/utils/LorenzUtils.kt @@ -5,63 +5,62 @@ import net.minecraft.util.ChatComponentText import org.intellij.lang.annotations.Language import java.text.SimpleDateFormat -class LorenzUtils { +object LorenzUtils { - companion object { - const val DEBUG_PREFIX = "[Debug] §7" + const val DEBUG_PREFIX = "[Debug] §7" - fun debug(message: String) { - internaChat(DEBUG_PREFIX + message) - } + fun debug(message: String) { + internaChat(DEBUG_PREFIX + message) + } - fun warning(message: String) { - internaChat("§cWarning! $message") - } + fun warning(message: String) { + internaChat("§cWarning! $message") + } - fun error(message: String) { - internaChat("§4$message") - } + fun error(message: String) { + internaChat("§4$message") + } - fun chat(message: String) { - internaChat(message) - } + fun chat(message: String) { + internaChat(message) + } - private fun internaChat(message: String) { - val thePlayer = Minecraft.getMinecraft().thePlayer - thePlayer.addChatMessage(ChatComponentText(message)) - } + private fun internaChat(message: String) { + val thePlayer = Minecraft.getMinecraft().thePlayer + thePlayer.addChatMessage(ChatComponentText(message)) + } - fun String.matchRegex(@Language("RegExp") regex: String): Boolean = regex.toRegex().matches(this) - - fun String.removeColorCodes(): String { - val builder = StringBuilder() - var skipNext = false - for (c in this.toCharArray()) { - if (c == '§') { - skipNext = true - continue - } - if (skipNext) { - skipNext = false - continue - } - builder.append(c) - } + fun String.matchRegex(@Language("RegExp") regex: String): Boolean = regex.toRegex().matches(this) - return builder.toString() + fun String.removeColorCodes(): String { + val builder = StringBuilder() + var skipNext = false + for (c in this.toCharArray()) { + if (c == '§') { + skipNext = true + continue + } + if (skipNext) { + skipNext = false + continue + } + builder.append(c) } - fun SimpleDateFormat.formatCurrentTime(): String = this.format(System.currentTimeMillis()) + return builder.toString() + } - fun stripVanillaMessage(originalMessage: String): String { - var message = originalMessage + fun SimpleDateFormat.formatCurrentTime(): String = this.format(System.currentTimeMillis()) - while (message.startsWith("§r")) { - message = message.substring(2) - } - while (message.endsWith("§r")) { - message = message.substring(0, message.length - 2) - } + fun stripVanillaMessage(originalMessage: String): String { + var message = originalMessage + + while (message.startsWith("§r")) { + message = message.substring(2) + } + while (message.endsWith("§r")) { + message = message.substring(0, message.length - 2) + } // if (!message.startsWith(LorenzUtils.DEBUG_PREFIX + "chat api got (123)")) { // if (message.matchRegex("(.*)§r§7 \\((.{1,3})\\)")) { @@ -79,15 +78,14 @@ class LorenzUtils { // } // } - return message - } - - fun Double.round(decimals: Int): Double { - var multiplier = 1.0 - repeat(decimals) { multiplier *= 10 } - return kotlin.math.round(this * multiplier) / multiplier - } + return message + } - fun String.between(start: String, end: String): String = this.split(start, end)[1] + fun Double.round(decimals: Int): Double { + var multiplier = 1.0 + repeat(decimals) { multiplier *= 10 } + return kotlin.math.round(this * multiplier) / multiplier } + + fun String.between(start: String, end: String): String = this.split(start, end)[1] }
\ No newline at end of file |