aboutsummaryrefslogtreecommitdiff
path: root/src/main/kotlin/com/ambientaddons
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/kotlin/com/ambientaddons')
-rw-r--r--src/main/kotlin/com/ambientaddons/commands/AutoBuyCommand.kt10
-rw-r--r--src/main/kotlin/com/ambientaddons/commands/SalvageCommand.kt99
-rw-r--r--src/main/kotlin/com/ambientaddons/config/Config.kt4
-rw-r--r--src/main/kotlin/com/ambientaddons/config/PersistentData.kt16
-rw-r--r--src/main/kotlin/com/ambientaddons/features/misc/Salvage.kt5
5 files changed, 97 insertions, 37 deletions
diff --git a/src/main/kotlin/com/ambientaddons/commands/AutoBuyCommand.kt b/src/main/kotlin/com/ambientaddons/commands/AutoBuyCommand.kt
index 1cead71..9899d40 100644
--- a/src/main/kotlin/com/ambientaddons/commands/AutoBuyCommand.kt
+++ b/src/main/kotlin/com/ambientaddons/commands/AutoBuyCommand.kt
@@ -13,7 +13,7 @@ object AutoBuyCommand {
val newPrice = args.getOrNull(2)?.toIntOrNull()
persistentData.autoBuyItems[item] = newPrice
persistentData.save()
- UChat.chat("§aAdded item §a§l$item §awith ${if (newPrice == null) "no minimum price." else " minimum price §a§l$newPrice"}".withModPrefix())
+ UChat.chat("§aAdded item §a§l$item §awith ${if (newPrice == null) "no maximum price." else "maximum price §a§l$newPrice"}".withModPrefix())
}
"remove" -> {
val item = args[1]
@@ -24,14 +24,16 @@ object AutoBuyCommand {
} else UChat.chat("§cItem §c§l$item §cdoes not exist!".withModPrefix())
}
"list" -> {
- UChat.chat("§2§lItems".withModPrefix())
+ UChat.chat(Chat.getChatBreak())
+ UChat.chat("§b§lAutobuy List")
persistentData.autoBuyItems.forEach {
if (it.value == null) {
- UChat.chat(" §b${it.key}")
+ UChat.chat(" §a${it.key}")
} else {
- UChat.chat(" §b${it.key} §7(max price §a${it.value} §7coins)")
+ UChat.chat(" §a${it.key} §e(maximum price §a§l${it.value} §ecoins)")
}
}
+ UChat.chat(Chat.getChatBreak())
}
else -> {
UChat.chat("""
diff --git a/src/main/kotlin/com/ambientaddons/commands/SalvageCommand.kt b/src/main/kotlin/com/ambientaddons/commands/SalvageCommand.kt
index 5e86757..bc8d442 100644
--- a/src/main/kotlin/com/ambientaddons/commands/SalvageCommand.kt
+++ b/src/main/kotlin/com/ambientaddons/commands/SalvageCommand.kt
@@ -1,64 +1,105 @@
package com.ambientaddons.commands
import AmbientAddons.Companion.persistentData
+import com.ambientaddons.features.misc.Salvage
import com.ambientaddons.utils.Chat
import com.ambientaddons.utils.Extensions.withModPrefix
import com.ambientaddons.utils.SalvageStrategy
import gg.essential.universal.UChat
object SalvageCommand {
+
+ private val armorSuffixes = listOf("_HELMET", "_CHESTPLATE", "_LEGGINGS", "_BOOTS")
+
fun processCommand(args: List<String>) {
when (args.getOrNull(0)) {
"auto" -> {
- val item = args[1]
- val added = persistentData.salvageMap.put(item, SalvageStrategy.Always) != SalvageStrategy.Always
- persistentData.save()
- UChat.chat((if (added) "§aAdded item §a§l${item}." else "§cItem already added.").withModPrefix())
+ val item = args[1].uppercase()
+ addItem(item, SalvageStrategy.Always)
}
"allow" -> {
- val item = args[1]
- val allowed = persistentData.salvageMap.put(item, SalvageStrategy.Allow) != SalvageStrategy.Allow
- persistentData.save()
- UChat.chat((if (allowed) "§aAllowing item §a§l${item}." else "§cItem already allowed.").withModPrefix())
+ val item = args[1].uppercase()
+ addItem(item, SalvageStrategy.Allow)
}
"block" -> {
- val item = args[1]
- val blocked = persistentData.salvageMap.put(item, SalvageStrategy.Block) != SalvageStrategy.Block
- persistentData.save()
- UChat.chat((if (blocked) "§aBlocking item §a§l${item}." else "§cItem already blocked.").withModPrefix())
+ val item = args[1].uppercase()
+ addItem(item, SalvageStrategy.Block)
}
"remove" -> {
- val item = args[1]
- val removed = persistentData.salvageMap.remove(item) != null
- persistentData.save()
- UChat.chat((if (removed) "§aRemoved item §a§l${item}." else "§cItem not in list.").withModPrefix())
+ val item = args[1].uppercase()
+ if (item.endsWith("_ARMOR")) {
+ val itemWithoutSuffix = item.substringBeforeLast("_")
+ val removedAny = armorSuffixes.map {
+ persistentData.salvageMap.remove(itemWithoutSuffix + it)
+ }.any { it != null }
+ persistentData.save()
+ UChat.chat((if (removedAny) "§aRemoved armor set §a§l${item}." else "§cSet not in list.").withModPrefix())
+ } else {
+ val removed = persistentData.salvageMap.remove(item) != null
+ UChat.chat((if (removed) "§aRemoved item §a§l${item}." else "§cItem not in list.").withModPrefix())
+ }
}
"list" -> {
- UChat.chat("§2§lItems §7(§aalways salvage, §eallow salvaging, §cblock salvaging§7)".withModPrefix())
- persistentData.salvageMap.forEach {
- when (it.value) {
- SalvageStrategy.Always -> UChat.chat(" §a${it.key}")
- SalvageStrategy.Allow -> UChat.chat(" §e${it.key}")
- else -> UChat.chat(" §c${it.key}")
- }
+ val sortedMap = persistentData.salvageMap.let { salvageMap ->
+ val armorSets = salvageMap.filter { entry ->
+ if (entry.key.endsWith(armorSuffixes.first())) {
+ val itemWithoutSuffix = entry.key.substringBeforeLast("_")
+ armorSuffixes.all { salvageMap[itemWithoutSuffix + it] == entry.value }
+ } else false
+ }.map { (it.key.substringBeforeLast("_") + "_ARMOR") to it.value }.toMap()
+ (salvageMap.filter {
+ !armorSets.contains(it.key.substringBeforeLast("_") + "_ARMOR")
+ } + armorSets).toSortedMap()
}
+ UChat.chat(Chat.getChatBreak())
+ UChat.chat("§b§lAlways salvage")
+ UChat.chat(sortedMap.entries.filter {
+ it.value == SalvageStrategy.Always
+ }.joinToString("\n") { " §a${it.key}" })
+ UChat.chat("§b§lAllow salvaging")
+ UChat.chat(sortedMap.entries.filter {
+ it.value == SalvageStrategy.Allow
+ }.joinToString("\n") { " §e${it.key}" })
+ UChat.chat("§b§lBlock salvaging")
+ UChat.chat(sortedMap.entries.filter {
+ it.value == SalvageStrategy.Block
+ }.joinToString("\n") { " §c${it.key}" })
+ UChat.chat(Chat.getChatBreak())
}
else -> {
- UChat.chat("""
+ UChat.chat(
+ """
${Chat.getChatBreak()}
§b§lUsage:
- §a/ambient salvage auto <Skyblock ID> §eto always salvage item.
- §a/ambient salvage allow <Skyblock ID> §eto allow salvaging item.
- §a/ambient salvage block <Skyblock ID> §eto block salvaging item.
- §a/ambient salvage remove <Skyblock ID> §eto removet item.
+ §a/ambient salvage auto <Skyblock ID> §eto always salvage.
+ §a/ambient salvage allow <Skyblock ID> §eto allow salvaging.
+ §a/ambient salvage block <Skyblock ID> §eto block salvaging.
+ §a/ambient salvage remove <Skyblock ID> §eto remove item.
§a/ambient salvage list §eto view current salvage list.
§b§lNotes:
§eSome items are explicitly blocked due to past item quality bugs.
§eIf not blocked in list, this will salvage all dungeon mob drops unless starred.
+ §eArmor set ids can be combined into a single name ending with _ARMOR.
${Chat.getChatBreak()}
- """.trimIndent())
+ """.trimIndent()
+ )
}
}
}
+
+ private fun addItem(item: String, strategy: SalvageStrategy) {
+ if (item.endsWith("_ARMOR")) {
+ val itemWithoutSuffix = item.substringBeforeLast("_")
+ val addedAny = armorSuffixes.map {
+ persistentData.salvageMap.put(itemWithoutSuffix + it, strategy)
+ }.any { it != strategy }
+ persistentData.save()
+ UChat.chat((if (addedAny) "§aAdded armor set §a§l${item}." else "§cSet already added.").withModPrefix())
+ } else {
+ val added = persistentData.salvageMap.put(item, strategy) != strategy
+ persistentData.save()
+ UChat.chat((if (added) "§aAdded item §a§l${item}." else "§cItem already added.").withModPrefix())
+ }
+ }
} \ No newline at end of file
diff --git a/src/main/kotlin/com/ambientaddons/config/Config.kt b/src/main/kotlin/com/ambientaddons/config/Config.kt
index 47bc085..9f25914 100644
--- a/src/main/kotlin/com/ambientaddons/config/Config.kt
+++ b/src/main/kotlin/com/ambientaddons/config/Config.kt
@@ -250,7 +250,7 @@ object Config : Vigilant(
selector(
::pingDisplay,
name = "Ping and TPS display",
- description = "Displays current ping and TPS. Ping requires ",
+ description = "Displays current ping and TPS.",
options = listOf("Off", "Default", "Shadow", "Outline")
)
}
@@ -280,7 +280,7 @@ object Config : Vigilant(
switch(
::closeSecretChests,
name = "Block opening secret chests",
- description = "Cancels opening chests containing secrets."
+ description = "Cancels opening secret chest GUIs."
)
switch(
::ignoreCarpet, name = "Ignore carpet hitboxes", description = "Removes all carpet hitboxes"
diff --git a/src/main/kotlin/com/ambientaddons/config/PersistentData.kt b/src/main/kotlin/com/ambientaddons/config/PersistentData.kt
index 2c63e76..f1e5873 100644
--- a/src/main/kotlin/com/ambientaddons/config/PersistentData.kt
+++ b/src/main/kotlin/com/ambientaddons/config/PersistentData.kt
@@ -25,7 +25,8 @@ data class PersistentData(
"DARK_CLAYMORE" to null,
"THUNDERLORD_7" to null,
"WITHER_CHESTPLATE" to null,
- "ULTIMATE_ONE_FOR_ALL_1" to null
+ "ULTIMATE_ONE_FOR_ALL_1" to null,
+ "NECRON_HANDLE" to null
),
var positions: MutableMap<String, GuiPosition> = mutableMapOf(),
var salvageMap: MutableMap<String, SalvageStrategy> = mutableMapOf(
@@ -40,10 +41,23 @@ data class PersistentData(
"RAMPART_LEGGINGS" to SalvageStrategy.Always,
"RAMPART_BOOTS" to SalvageStrategy.Always,
"SWORD_OF_BAD_HEALTH" to SalvageStrategy.Always,
+ "ARACK" to SalvageStrategy.Always,
"ARACHNE_HELMET" to SalvageStrategy.Always,
"ARACHNE_CHESTPLATE" to SalvageStrategy.Always,
"ARACHNE_LEGGINGS" to SalvageStrategy.Always,
"ARACHNE_BOOTS" to SalvageStrategy.Always,
+ "BOUNCY_HELMET" to SalvageStrategy.Allow,
+ "BOUNCY_CHESTPLATE" to SalvageStrategy.Allow,
+ "BOUNCY_LEGGINGS" to SalvageStrategy.Allow,
+ "BOUNCY_BOOTS" to SalvageStrategy.Allow,
+ "SKELETON_LORD_HELMET" to SalvageStrategy.Allow,
+ "SKELETON_LORD_CHESTPLATE" to SalvageStrategy.Allow,
+ "SKELETON_LORD_LEGGINGS" to SalvageStrategy.Allow,
+ "SKELETON_LORD_BOOTS" to SalvageStrategy.Allow,
+ "ZOMBIE_LORD_HELMET" to SalvageStrategy.Allow,
+ "ZOMBIE_LORD_CHESTPLATE" to SalvageStrategy.Allow,
+ "ZOMBIE_LORD_LEGGINGS" to SalvageStrategy.Allow,
+ "ZOMBIE_LORD_BOOTS" to SalvageStrategy.Allow,
"WITHER_CLOAK_SWORD" to SalvageStrategy.Block,
"DARK_CLAYMORE" to SalvageStrategy.Block,
"GIANTS_SWORD" to SalvageStrategy.Block,
diff --git a/src/main/kotlin/com/ambientaddons/features/misc/Salvage.kt b/src/main/kotlin/com/ambientaddons/features/misc/Salvage.kt
index a1ee583..e0f6cf5 100644
--- a/src/main/kotlin/com/ambientaddons/features/misc/Salvage.kt
+++ b/src/main/kotlin/com/ambientaddons/features/misc/Salvage.kt
@@ -8,6 +8,7 @@ import com.ambientaddons.utils.Extensions.itemQuality
import com.ambientaddons.utils.Extensions.items
import com.ambientaddons.utils.Extensions.skyblockID
import com.ambientaddons.utils.Extensions.stars
+import com.ambientaddons.utils.Extensions.substringBetween
import com.ambientaddons.utils.SBLocation
import com.ambientaddons.utils.SalvageStrategy
import com.ambientaddons.utils.render.OverlayUtils
@@ -29,6 +30,7 @@ object Salvage {
private val canClick: Boolean
get() = (System.currentTimeMillis() - nextClickTime) >= 0
+
@SubscribeEvent
fun onGuiDraw(event: GuiScreenEvent.DrawScreenEvent) {
if (!SBLocation.inSkyblock) return
@@ -112,7 +114,8 @@ object Salvage {
}
private fun getSalvageStrategy(item: ItemStack): SalvageStrategy {
- AmbientAddons.persistentData.salvageMap[item.skyblockID]?.let { return it }
+ val skyblockId = item.skyblockID ?: return SalvageStrategy.Block
+ AmbientAddons.persistentData.salvageMap[skyblockId]?.let { return it }
return when {
item.stars != null -> SalvageStrategy.Block
item.itemQuality == 50 -> if (config.topQualityStrategy) SalvageStrategy.Always else SalvageStrategy.Allow