diff --git a/src/main/java/me/partlysanestudios/partlysaneskies/features/mining/MiningEvents.java b/src/main/java/me/partlysanestudios/partlysaneskies/features/mining/MiningEvents.java index 18d28e7f2..077393248 100644 --- a/src/main/java/me/partlysanestudios/partlysaneskies/features/mining/MiningEvents.java +++ b/src/main/java/me/partlysanestudios/partlysaneskies/features/mining/MiningEvents.java @@ -197,4 +197,4 @@ public void onChat(ClientChatReceivedEvent event) { FALLEN STAR §r§5§l✯ §r§eA §r§5Fallen Star §r§ehas crashed at §r§bRoyal Mines§r§e! Nearby ore and Powder drops are amplified!§r - */ \ No newline at end of file + */ diff --git a/src/main/kotlin/me/partlysanestudios/partlysaneskies/PartlySaneSkies.kt b/src/main/kotlin/me/partlysanestudios/partlysaneskies/PartlySaneSkies.kt index adfa280c7..1d449c325 100644 --- a/src/main/kotlin/me/partlysanestudios/partlysaneskies/PartlySaneSkies.kt +++ b/src/main/kotlin/me/partlysanestudios/partlysaneskies/PartlySaneSkies.kt @@ -80,6 +80,7 @@ import me.partlysanestudios.partlysaneskies.features.gui.hud.CooldownHud import me.partlysanestudios.partlysaneskies.features.gui.hud.LocationBannerDisplay import me.partlysanestudios.partlysaneskies.features.gui.hud.rngdropbanner.DropBannerDisplay import me.partlysanestudios.partlysaneskies.features.gui.hud.rngdropbanner.DropWebhook +import me.partlysanestudios.partlysaneskies.features.gui.hud.rngdropbanner.RareDropGUIManager import me.partlysanestudios.partlysaneskies.features.gui.mainmenu.PSSMainMenu import me.partlysanestudios.partlysaneskies.features.information.WikiArticleOpener import me.partlysanestudios.partlysaneskies.features.mining.MiningEvents @@ -223,6 +224,11 @@ class PartlySaneSkies { } catch (e: IOException) { e.printStackTrace() } + try { + RareDropGUIManager.loadData() + } catch (e: IOException) { + e.printStackTrace() + } }.start() @@ -306,6 +312,7 @@ class PartlySaneSkies { PlayerRating.registerReprintCommand() ModChecker.registerModCheckCommand() ItemRefill.registerCommand() + RareDropGUIManager.registerCommand() WebhookMenu.registerWebhookCommand() registerCoreConfig() diff --git a/src/main/kotlin/me/partlysanestudios/partlysaneskies/config/psconfig/Config.kt b/src/main/kotlin/me/partlysanestudios/partlysaneskies/config/psconfig/Config.kt index ae80a4868..dba0593e5 100644 --- a/src/main/kotlin/me/partlysanestudios/partlysaneskies/config/psconfig/Config.kt +++ b/src/main/kotlin/me/partlysanestudios/partlysaneskies/config/psconfig/Config.kt @@ -16,6 +16,7 @@ class Config : ConfigOption() { companion object { val ConfigOption.asConfig get() = this as Config } + // Recursively find paths for options fun find(path: String): ConfigOption? { val indexOfSplit = path.indexOf("/") @@ -34,6 +35,7 @@ class Config : ConfigOption() { } private val options = LinkedHashMap() + // Recursively create new options to get to the path fun registerOption(path: String, configOption: ConfigOption): Config { val indexOfSplit = path.indexOf("/") @@ -55,9 +57,7 @@ class Config : ConfigOption() { return this } - fun getAllOptions(): LinkedHashMap { - return options.clone() as LinkedHashMap - } + fun getAllOptions(): LinkedHashMap = options.clone() as LinkedHashMap override fun loadFromJson(element: JsonElement) { val obj = element.asJsonObject @@ -66,7 +66,7 @@ class Config : ConfigOption() { // If the parameter exists if (obj.has(option.key)) { try { - option.value.loadFromJson(obj.get(option.key)) + option.value.loadFromJson(obj[option.key]) } catch (e: Exception) { log(Level.ERROR, "Error loading option ${option.key}") @@ -88,9 +88,11 @@ class Config : ConfigOption() { var savePath: String? = null fun save() { if (parent == null) { - ConfigManager.saveConfig(savePath ?: throw IllegalArgumentException("Unable to Save. No save path provided. Config is not registered."), this) + ConfigManager.saveConfig( + savePath ?: throw IllegalArgumentException("Unable to Save. No save path provided. Config is not registered."), this, + ) } else { (parent as? Config)?.save() ?: throw IllegalArgumentException("Unable to save. Parent of config is not a config.") } } -} \ No newline at end of file +} diff --git a/src/main/kotlin/me/partlysanestudios/partlysaneskies/data/skyblockdata/SkyblockPlayer.kt b/src/main/kotlin/me/partlysanestudios/partlysaneskies/data/skyblockdata/SkyblockPlayer.kt index a7c8a60b1..fc6471c1e 100644 --- a/src/main/kotlin/me/partlysanestudios/partlysaneskies/data/skyblockdata/SkyblockPlayer.kt +++ b/src/main/kotlin/me/partlysanestudios/partlysaneskies/data/skyblockdata/SkyblockPlayer.kt @@ -9,7 +9,6 @@ import com.google.gson.JsonParser import me.partlysanestudios.partlysaneskies.PartlySaneSkies.Companion.config import me.partlysanestudios.partlysaneskies.PartlySaneSkies.Companion.time import me.partlysanestudios.partlysaneskies.data.api.GetRequest -import me.partlysanestudios.partlysaneskies.data.api.Request import me.partlysanestudios.partlysaneskies.data.api.RequestsManager import me.partlysanestudios.partlysaneskies.utils.MathUtils import me.partlysanestudios.partlysaneskies.utils.StringUtils.titleCase diff --git a/src/main/kotlin/me/partlysanestudios/partlysaneskies/features/debug/CrystalHollowsGemstoneMapper.kt b/src/main/kotlin/me/partlysanestudios/partlysaneskies/features/debug/CrystalHollowsGemstoneMapper.kt index b93f2bdc0..6bac1f495 100644 --- a/src/main/kotlin/me/partlysanestudios/partlysaneskies/features/debug/CrystalHollowsGemstoneMapper.kt +++ b/src/main/kotlin/me/partlysanestudios/partlysaneskies/features/debug/CrystalHollowsGemstoneMapper.kt @@ -21,7 +21,7 @@ import java.time.Instant import java.time.LocalDateTime import java.time.ZoneId import java.time.format.DateTimeFormatter -import java.util.* +import java.util.LinkedList object CrystalHollowsGemstoneMapper { @@ -102,17 +102,15 @@ object CrystalHollowsGemstoneMapper { val coordObj = coordElement.asJsonObject val point = Point3d(coordObj.get("x").asDouble, coordObj.get("y").asDouble, coordObj.get("z").asDouble) try { + val type = "COLOR_${ + world.getBlockState(point.toBlockPosInt()) + .getValue(PropertyEnum.create("color", EnumDyeColor::class.java)) + }" val color = world.getBlockState(point.toBlockPosInt()) .getValue(PropertyEnum.create("color", EnumDyeColor::class.java)) - val type = "COLOR_$color" - - if (!map.contains(type)) { - map[type] = ArrayList() - } map[type]?.add(coordObj) } catch (e: Exception) { - e.printStackTrace() continue } } @@ -306,4 +304,4 @@ object CrystalHollowsGemstoneMapper { } } -} \ No newline at end of file +} diff --git a/src/main/kotlin/me/partlysanestudios/partlysaneskies/features/dungeons/RequiredSecretsFound.kt b/src/main/kotlin/me/partlysanestudios/partlysaneskies/features/dungeons/RequiredSecretsFound.kt index f38236d85..102e95f0e 100644 --- a/src/main/kotlin/me/partlysanestudios/partlysaneskies/features/dungeons/RequiredSecretsFound.kt +++ b/src/main/kotlin/me/partlysanestudios/partlysaneskies/features/dungeons/RequiredSecretsFound.kt @@ -71,4 +71,4 @@ object RequiredSecretsFound { } } } -} \ No newline at end of file +} diff --git a/src/main/kotlin/me/partlysanestudios/partlysaneskies/features/farming/garden/SkymartValue.kt b/src/main/kotlin/me/partlysanestudios/partlysaneskies/features/farming/garden/SkymartValue.kt index 00ed9bc87..5b1964f58 100644 --- a/src/main/kotlin/me/partlysanestudios/partlysaneskies/features/farming/garden/SkymartValue.kt +++ b/src/main/kotlin/me/partlysanestudios/partlysaneskies/features/farming/garden/SkymartValue.kt @@ -104,7 +104,9 @@ object SkymartValue : SidePanel() { for ((key, value) in sortedMap) { val item = getItem(key) ?: SkyblockItem.emptyItem - str += "§6$i. §d${item.name}§7 costs §d${copperCost[key]?.formatNumber() ?: 0}§7 copper and sells for §d${item.getSellPrice().round(1).formatNumber()}§7 coins \n§8 (${value.round(1).formatNumber()} coins per copper)\n" + str += "§6$i. §d${item.name}§7 costs §d${copperCost[key]?.formatNumber() ?: 0}§7 copper and sells for §d${ + item.getSellPrice().round(1).formatNumber() + }§7 coins \n§8 (${value.round(1).formatNumber()} coins per copper)\n" i++ if (i > 5) { diff --git a/src/main/kotlin/me/partlysanestudios/partlysaneskies/features/gui/hud/rngdropbanner/DropBannerDisplay.kt b/src/main/kotlin/me/partlysanestudios/partlysaneskies/features/gui/hud/rngdropbanner/DropBannerDisplay.kt index c0d64f602..fbf9cd12f 100644 --- a/src/main/kotlin/me/partlysanestudios/partlysaneskies/features/gui/hud/rngdropbanner/DropBannerDisplay.kt +++ b/src/main/kotlin/me/partlysanestudios/partlysaneskies/features/gui/hud/rngdropbanner/DropBannerDisplay.kt @@ -19,6 +19,7 @@ import me.partlysanestudios.partlysaneskies.PartlySaneSkies.Companion.minecraft import me.partlysanestudios.partlysaneskies.PartlySaneSkies.Companion.time import me.partlysanestudios.partlysaneskies.data.skyblockdata.Rarity import me.partlysanestudios.partlysaneskies.data.skyblockdata.Rarity.Companion.getRarityFromColorCode +import me.partlysanestudios.partlysaneskies.features.gui.hud.rngdropbanner.RareDropGUIManager.isAllowedDrop import me.partlysanestudios.partlysaneskies.render.gui.constraints.ScaledPixelConstraint.Companion.scaledPixels import me.partlysanestudios.partlysaneskies.utils.MathUtils.onCooldown import me.partlysanestudios.partlysaneskies.utils.StringUtils.colorCodeToColor @@ -69,11 +70,14 @@ object DropBannerDisplay { val (dropCategoryColor, dropCategory, dropColor, name, magicFind) = match.destructured val rarity = dropColor.getRarityFromColorCode() - // TODO: add check for blocked drop if (checkRarity(rarity)) { return } + if (!isAllowedDrop(name.trim())) { + return + } + if (config.rareDropBannerSound) { minecraft.thePlayer.playSound("partlysaneskies:rngdropjingle", 100f, 1f) } diff --git a/src/main/kotlin/me/partlysanestudios/partlysaneskies/features/gui/hud/rngdropbanner/RareDropGUI.kt b/src/main/kotlin/me/partlysanestudios/partlysaneskies/features/gui/hud/rngdropbanner/RareDropGUI.kt new file mode 100644 index 000000000..0e74bdafd --- /dev/null +++ b/src/main/kotlin/me/partlysanestudios/partlysaneskies/features/gui/hud/rngdropbanner/RareDropGUI.kt @@ -0,0 +1,216 @@ +// +// Written by J10an15. +// See LICENSE for copyright and license notices. +// + + +package me.partlysanestudios.partlysaneskies.features.gui.hud.rngdropbanner + +import gg.essential.elementa.ElementaVersion +import gg.essential.elementa.WindowScreen +import gg.essential.elementa.components.ScrollComponent +import gg.essential.elementa.components.UIBlock +import gg.essential.elementa.components.UIText +import gg.essential.elementa.components.UIWrappedText +import gg.essential.elementa.components.input.UITextInput +import gg.essential.elementa.constraints.CenterConstraint +import gg.essential.elementa.constraints.CramSiblingConstraint +import gg.essential.elementa.constraints.SiblingConstraint +import gg.essential.elementa.dsl.childOf +import gg.essential.elementa.dsl.constrain +import gg.essential.elementa.dsl.constraint +import gg.essential.elementa.dsl.percent +import gg.essential.elementa.dsl.pixels +import me.partlysanestudios.partlysaneskies.features.gui.hud.rngdropbanner.RareDropGUIManager.currentFilter +import me.partlysanestudios.partlysaneskies.features.gui.hud.rngdropbanner.RareDropGUIManager.currentFilterType +import me.partlysanestudios.partlysaneskies.features.themes.ThemeManager +import me.partlysanestudios.partlysaneskies.features.themes.ThemeManager.primaryColor +import me.partlysanestudios.partlysaneskies.render.gui.components.PSSButton +import me.partlysanestudios.partlysaneskies.render.gui.constraints.ScaledPixelConstraint.Companion.scaledPixels +import java.awt.Color + +class RareDropGUI : WindowScreen(ElementaVersion.V5) { + private val backgroundBox = UIBlock().constrain { + width = 75.percent + height = 75.percent + x = CenterConstraint() + y = CenterConstraint() + color = Color(0, 0, 0, 0).constraint + } childOf window + + + /** + * Create Filter Container + */ + private val createFilterContainer = ThemeManager.currentBackgroundUIImage.constrain { + width = 60.percent + height = 75.percent + x = 40.percent + y = 0.percent + } childOf backgroundBox + + private val createFiltersHeading = UIWrappedText("Create Filters:").constrain { + width = 90.percent + x = 5.percent + y = 2.percent + textScale = 1.5.scaledPixels + color = Color.gray.constraint + } childOf createFilterContainer + + private val createFiltersInput = UITextInput("Create a ${currentFilterType.displayName} Filter...").constrain { + width = 90.percent + height = 5.percent + x = 5.percent + y = 7.percent + }.onMouseClick { + grabWindowFocus() + } as UITextInput childOf createFilterContainer + + private val createFiltersScrollComponent = ScrollComponent( + scrollIconColor = primaryColor.toJavaColor(), + innerPadding = 10f, + scrollAcceleration = 2f, + ).constrain { + width = 100.percent + height = 90.percent + x = 0.percent + y = 10.percent + } childOf createFilterContainer + + private val createFilterButton = PSSButton() + .setText("Add ${currentFilterType.displayName} Filter") + .setX(5.percent) + .setY(15.percent) + .setHeight(50.pixels) + .setWidth(60.pixels) + .setChildOf(createFilterContainer) + .onMouseClickConsumer { + val text = createFiltersInput.getText() + if (text.isBlank()) return@onMouseClickConsumer + RareDropGUIManager.addFilter(text) + createFiltersInput.setText("") + updateFilterList() + } + + private var opposite = RareDropGUIManager.FilterType.entries.first { it != currentFilterType } + private val switchTypeButton = PSSButton() + .setText("Switch to ${opposite.displayName}") + .setX(5.percent) + .setY(SiblingConstraint(5f)) + .setHeight(50.pixels) + .setWidth(60.pixels) + .setChildOf(createFilterContainer) + .onMouseClickConsumer { + currentFilterType = opposite + opposite = RareDropGUIManager.FilterType.entries.first { it != currentFilterType } + RareDropGUIManager.saveData() + update() + } + + /** + * Active Filter Container + */ + private val activeFiltersContainer = ThemeManager.currentBackgroundUIImage.constrain { + width = 35.percent + height = 100.percent + x = 0.percent + y = 0.percent + } childOf backgroundBox + + private val activeFiltersHeading = UIWrappedText("${currentFilterType.displayName} Filters:").constrain { + width = 90.percent + x = 5.percent + y = 2.percent + textScale = 1.5.scaledPixels + color = Color.green.constraint + } childOf activeFiltersContainer + + private val activeFiltersSearchBar: UITextInput = UITextInput("Search...").constrain { + width = 90.percent + height = 5.percent + x = 5.percent + y = 7.percent + }.onMouseClick { + grabWindowFocus() + }.onKeyType { _, _ -> + updateFilterList() + } as UITextInput childOf activeFiltersContainer + + private val activeFiltersScrollComponent = ScrollComponent( + scrollIconColor = primaryColor.toJavaColor(), + innerPadding = 10f, + ).constrain { + width = 100.percent + height = 90.percent + x = 0.percent + y = 10.percent + } childOf activeFiltersContainer + + + /** + * Presets Container + */ + private val presetsContainer = ThemeManager.currentBackgroundUIImage.constrain { + width = 60.percent + height = 20.percent + x = 40.percent + y = 80.percent + } childOf backgroundBox + + private val presetButtons = RareDropGUIManager.presets.forEachIndexed { columnIndex, (presetName, items) -> + PSSButton() + .setText(presetName) + .setX((15 * columnIndex + 5).percent) + .setY(CenterConstraint()) + .setHeight(50.pixels) + .setWidth(60.pixels) + .setChildOf(presetsContainer) + .onMouseClickConsumer { + RareDropGUIManager.addFilter(*items.toTypedArray()) + updateFilterList() + } + } + + init { + update() + } + + private fun update() { + updateFilterList() + updateTitles() + } + + private fun updateTitles() { + activeFiltersHeading.setText("${currentFilterType.displayName} Filters:") + createFilterButton.setText("Add ${currentFilterType.displayName} Filter") + switchTypeButton.setText("Switch to ${opposite.displayName}") + } + + private fun updateFilterList() { + activeFiltersScrollComponent.clearChildren() + + currentFilter + .filter { it.contains(activeFiltersSearchBar.getText(), ignoreCase = true) } + .forEach { filter -> + val xText = UIText("§cx").constrain { + x = 0.percent + y = SiblingConstraint(4f) + }.onMouseClick { + currentFilter -= filter + RareDropGUIManager.saveData() + updateFilterList() + } childOf activeFiltersScrollComponent + + val filterText = UIText(filter).constrain { + x = 5.percent + y = CramSiblingConstraint() + } childOf activeFiltersScrollComponent + + xText.onMouseEnter { + filterText.setText("§m$filter") + }.onMouseLeave { + filterText.setText(filter) + } + } + } +} diff --git a/src/main/kotlin/me/partlysanestudios/partlysaneskies/features/gui/hud/rngdropbanner/RareDropGUIManager.kt b/src/main/kotlin/me/partlysanestudios/partlysaneskies/features/gui/hud/rngdropbanner/RareDropGUIManager.kt new file mode 100644 index 000000000..4714863f0 --- /dev/null +++ b/src/main/kotlin/me/partlysanestudios/partlysaneskies/features/gui/hud/rngdropbanner/RareDropGUIManager.kt @@ -0,0 +1,153 @@ +// +// Written by J10an15. +// See LICENSE for copyright and license notices. +// + +package me.partlysanestudios.partlysaneskies.features.gui.hud.rngdropbanner + +import cc.polyfrost.oneconfig.utils.gui.GuiUtils +import com.google.gson.Gson +import com.google.gson.GsonBuilder +import com.google.gson.JsonParser +import me.partlysanestudios.partlysaneskies.commands.PSSCommand +import me.partlysanestudios.partlysaneskies.utils.ChatUtils +import me.partlysanestudios.partlysaneskies.utils.StringUtils.pluralize +import java.io.File +import java.io.FileWriter +import java.io.IOException +import java.io.Reader +import java.nio.file.Files +import java.nio.file.Paths + +object RareDropGUIManager { + + private var filters: MutableMap> = mutableMapOf() + private const val CONFIG_PATH = "./config/partly-sane-skies/rareDropFilters.json" + + var currentFilterType: FilterType = FilterType.BLACKLIST + set(value) { + field = value + saveData() + } + + var currentFilter: Set + get() = filters[currentFilterType] ?: emptySet() + set(value) { + filters[currentFilterType] = value + } + + fun isAllowedDrop(drop: String) = (FilterType.WHITELIST.isEnabled() && currentFilter.contains(drop)) || + (FilterType.BLACKLIST.isEnabled() && !currentFilter.contains(drop)) + + fun registerCommand() { + PSSCommand("raredrop") + .addAlias("rd") + .setDescription("Opens the Rare Drop GUI") + .setRunnable { _ -> + openGui() + } + .register() + } + + fun addFilter(vararg filters: String) { + ChatUtils.sendClientMessage("Added ${"filter".pluralize(filters.size)}") + currentFilter += filters + saveData() + } + + private fun openGui() { + GuiUtils.displayScreen(RareDropGUI()) + } + + val presets = listOf( + RareDropPreset( + "Dungeons", + listOf( + "Conjuring", "Silent Death", "Dreadlord Sword", "Zombie Soldier Cutlass", "Earth Shard", + "Zombie Commander Whip", "Zombie Knight Sword", "Soulstealer Bow", "Sniper Bow", "Machine Gun Shortbow", + "Bouncy Helmet", "Bouncy Chestplate", "Bouncy Leggings", "Bouncy Boots", "Heavy Helmet", "Heavy Chestplate", + "Heavy Leggings", "Heavy Boots", "Rotten Helmet", "Rotten Chestplate", "Rotten Leggings", "Rotten Boots", + "Sniper Helmet", "Skeleton Grunt Helmet", "Skeleton Grunt Chestplate", "Skeleton Grunt Leggings", + "Skeleton Grunt Boots", "Skeleton Lord Helmet", "Skeleton Lord Chestplate", "Skeleton Lord Leggings", + "Skeleton Lord Boots", "Skeleton Master Helmet", "Skeleton Master Chestplate", "Skeleton Master Leggings", + "Skeleton Master Boots", "Skeleton Soldier Helmet", "Skeleton Soldier Chestplate", "Skeleton Soldier Leggings", + "Skeleton Soldier Boots", "Skeletor Helmet", "Skeletor Chestplate", "Skeletor Leggings", "Skeletor Boots", + "Super Heavy Helmet", "Super Heavy Chestplate", "Super Heavy Leggings", "Super Heavy Boots", + "Zombie Commander Helmet", "Zombie Commander Chestplate", "Zombie Commander Leggings", "Zombie Commander Boots", + "Zombie Knight Helmet", "Zombie Knight Chestplate", "Zombie Knight Leggings", "Zombie Knight Boots", + "Zombie Lord Helmet", "Zombie Lord Chestplate", "Zombie Lord Leggings", "Zombie Lord Boots", + "Zombie Soldier Helmet", "Zombie Soldier Chestplate", "Zombie Soldier Leggings", "Zombie Soldier Boots", + ), + ), + RareDropPreset( + "Useless End Drops", + listOf( + "Ender Helmet", "Ender Chestplate", "Ender Leggings", "Ender Boots", "Ender Belt", "Ender Cloak", + "Ender Gauntlet", "Ender Necklace", "Enchanted Ender Pearl", "End Stone Bow", "Ender Monocle", + "Enchanted Eye of Ender", "Enchanted End Stone", "Enchanted Obsidian", + ), + ), + RareDropPreset( + "Useless Garden Drops", + listOf( + "Beady Eyes", "Buzzin' Beats Vinyl", "Cicada Symphony Vinyl", "Clipped Wings", "DynaMITES Vinyl", + "Earthworm Ensemble Vinyl", "Not Just A Pest Vinyl", "Pretty Fly Vinyl", + ), + ), + ) + + enum class FilterType(val displayName: String) { + BLACKLIST("Blacklist"), + WHITELIST("Whitelist"), + ; + + fun isEnabled() = this == currentFilterType + } + + @Throws(IOException::class) + fun saveData() { + val file = File(CONFIG_PATH) + file.createNewFile() + val gson = GsonBuilder() + .setPrettyPrinting() + .serializeSpecialFloatingPointValues() + .create() + + val data = mutableMapOf( + "currentFilterType" to currentFilterType.name, + "filters" to filters, + ) + + val writer = FileWriter(file) + writer.write(gson.toJson(data)) + writer.close() + } + + @Throws(IOException::class) + fun loadData() { + val file = File(CONFIG_PATH) + file.setWritable(true) + + if (file.createNewFile()) { + val writer = FileWriter(file) + writer.write(Gson().toJson(emptyMap())) + writer.close() + } + + val reader: Reader = Files.newBufferedReader(Paths.get(file.path)) + val jsonElement = JsonParser().parse(reader) + reader.close() + + val jsonObject = jsonElement.asJsonObject + + filters = mutableMapOf>().apply { + jsonObject.getAsJsonObject("filters").entrySet().forEach { (key, value) -> + val filterType = FilterType.valueOf(key) + val filterSet = value.asJsonArray.map { it.asString }.toSet() + this[filterType] = filterSet + } + } + + currentFilterType = FilterType.valueOf(jsonObject["currentFilterType"].asString) + } +} diff --git a/src/main/kotlin/me/partlysanestudios/partlysaneskies/features/gui/hud/rngdropbanner/RareDropPreset.kt b/src/main/kotlin/me/partlysanestudios/partlysaneskies/features/gui/hud/rngdropbanner/RareDropPreset.kt new file mode 100644 index 000000000..8d72e5c08 --- /dev/null +++ b/src/main/kotlin/me/partlysanestudios/partlysaneskies/features/gui/hud/rngdropbanner/RareDropPreset.kt @@ -0,0 +1,3 @@ +package me.partlysanestudios.partlysaneskies.features.gui.hud.rngdropbanner + +data class RareDropPreset(val name: String, val items: List) \ No newline at end of file diff --git a/src/main/kotlin/me/partlysanestudios/partlysaneskies/features/themes/ThemeManager.kt b/src/main/kotlin/me/partlysanestudios/partlysaneskies/features/themes/ThemeManager.kt index e508f69e0..641d0b6ac 100644 --- a/src/main/kotlin/me/partlysanestudios/partlysaneskies/features/themes/ThemeManager.kt +++ b/src/main/kotlin/me/partlysanestudios/partlysaneskies/features/themes/ThemeManager.kt @@ -44,7 +44,7 @@ object ThemeManager { Theme("Partly Cloudy (Light)", Color(245, 245, 245), Color(84, 95, 117), Color(217, 114, 255)), Theme("Waterfall (Colorful)", Color(214, 237, 246), Color(172, 215, 236), Color(108, 197, 81)), Theme("Jungle (Colorful)", Color(201, 227, 172), Color(144, 190, 109), Color(254, 100, 163)), - Theme("Dunes (Colorful)", Color(229, 177, 129), Color(222, 107, 72), Color(131, 34, 50)) + Theme("Dunes (Colorful)", Color(229, 177, 129), Color(222, 107, 72), Color(131, 34, 50)), ) fun tick() { @@ -87,11 +87,13 @@ object ThemeManager { val currentBackgroundUIImage: UIImage get() { - val image: UIImage = if (config.disableThemes) { ResourceLocation("partlysaneskies", "textures/gui/base_color_background.png").uiImage + val image: UIImage = if (config.disableThemes) { + ResourceLocation("partlysaneskies", "textures/gui/base_color_background.png").uiImage } else { try { UIImage.ofFile(currentBackgroundFile) - } catch (e: IOException) { ResourceLocation("partlysaneskies", "textures/gui/base_color_background.png").uiImage + } catch (e: IOException) { + ResourceLocation("partlysaneskies", "textures/gui/base_color_background.png").uiImage } } backgroundUIImages.add(image) @@ -101,19 +103,20 @@ object ThemeManager { get() = getCurrentButtonUIImage(accentColor) fun getCurrentButtonUIImage(accentColor: OneColor): UIImage { - val image: UIImage - if (config.disableThemes) { - image = if ((accentColor == ThemeManager.accentColor)) { + val image = if (config.disableThemes) { + if ((accentColor == ThemeManager.accentColor)) { ResourceLocation("partlysaneskies", "textures/gui/base_color_button.png").uiImage } else { ResourceLocation("partlysaneskies", "textures/gui/base_color_button_transparent.png").uiImage } } else { - image = try { + try { UIImage.ofFile(getCurrentButtonFile(accentColor)) } catch (e: IOException) { - if ((accentColor == ThemeManager.accentColor)) { ResourceLocation("partlysaneskies", "textures/gui/base_color_button.png").uiImage - } else { ResourceLocation("partlysaneskies", "textures/gui/base_color_button_transparent.png").uiImage + if ((accentColor == ThemeManager.accentColor)) { + ResourceLocation("partlysaneskies", "textures/gui/base_color_button.png").uiImage + } else { + ResourceLocation("partlysaneskies", "textures/gui/base_color_button_transparent.png").uiImage } } } @@ -233,7 +236,7 @@ object ThemeManager { val averageR: Int = (color.red * .761).toInt() val averageG: Int = (color.green * .761).toInt() val averageB: Int = (color.blue * .761).toInt() - return Color(averageR, averageG, averageB, color.getTransparency()) + return Color(averageR, averageG, averageB, color.alpha) } private fun lightenColor(color: OneColor): Color { @@ -293,10 +296,7 @@ object ThemeManager { filePath.toFile().createNewFile() replaceColor(debugImage, PRIMARY_DEBUG_COLOR, primaryColor) replaceColor(debugImage, SECONDARY_DEBUG_COLOR, secondaryColor) - replaceColor( - debugImage, ACCENT_DEBUG_COLOR, - (accentColor) - ) + replaceColor(debugImage, ACCENT_DEBUG_COLOR, accentColor) saveImage(debugImage, filePath) return filePath.toFile() } @@ -320,10 +320,7 @@ object ThemeManager { filePath.toFile().createNewFile() replaceColor(debugImage, PRIMARY_DEBUG_COLOR, primaryColor) replaceColor(debugImage, SECONDARY_DEBUG_COLOR, secondaryColor) - replaceColor( - debugImage, ACCENT_DEBUG_COLOR, - (accentColor) - ) + replaceColor(debugImage, ACCENT_DEBUG_COLOR, accentColor) saveImage(debugImage, filePath) return filePath.toFile() } diff --git a/src/main/kotlin/me/partlysanestudios/partlysaneskies/render/gui/components/PSSButton.kt b/src/main/kotlin/me/partlysanestudios/partlysaneskies/render/gui/components/PSSButton.kt index 472e330b2..485ad914a 100644 --- a/src/main/kotlin/me/partlysanestudios/partlysaneskies/render/gui/components/PSSButton.kt +++ b/src/main/kotlin/me/partlysanestudios/partlysaneskies/render/gui/components/PSSButton.kt @@ -7,9 +7,12 @@ package me.partlysanestudios.partlysaneskies.render.gui.components import cc.polyfrost.oneconfig.config.core.OneColor import gg.essential.elementa.UIComponent import gg.essential.elementa.components.UIBlock -import gg.essential.elementa.components.UIImage import gg.essential.elementa.components.UIWrappedText -import gg.essential.elementa.constraints.* +import gg.essential.elementa.constraints.CenterConstraint +import gg.essential.elementa.constraints.HeightConstraint +import gg.essential.elementa.constraints.WidthConstraint +import gg.essential.elementa.constraints.XConstraint +import gg.essential.elementa.constraints.YConstraint import gg.essential.elementa.dsl.childOf import gg.essential.elementa.dsl.constrain import gg.essential.elementa.dsl.constraint