From 2c0e73deb53f54d78bd5594786313ac82151be1a Mon Sep 17 00:00:00 2001 From: Appability Date: Tue, 11 Oct 2022 23:59:37 -0700 Subject: added chest qol features (complete, i think) --- .../com/ambientaddons/commands/AutoBuyCommand.kt | 43 ++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 src/main/kotlin/com/ambientaddons/commands/AutoBuyCommand.kt (limited to 'src/main/kotlin/com/ambientaddons/commands/AutoBuyCommand.kt') diff --git a/src/main/kotlin/com/ambientaddons/commands/AutoBuyCommand.kt b/src/main/kotlin/com/ambientaddons/commands/AutoBuyCommand.kt new file mode 100644 index 0000000..c7ff9a7 --- /dev/null +++ b/src/main/kotlin/com/ambientaddons/commands/AutoBuyCommand.kt @@ -0,0 +1,43 @@ +package com.ambientaddons.commands + +import AmbientAddons.Companion.persistentData +import com.ambientaddons.utils.Extensions.withModPrefix +import gg.essential.universal.UChat + +object AutoBuyCommand { + fun processCommand(args: List) { + when (args.getOrNull(0)) { + "add" -> { + val item = args[1] + 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()) + } + "remove" -> { + val item = args[1] + if (persistentData.autoBuyItems.contains(item)) { + persistentData.autoBuyItems.remove(item) + persistentData.save() + UChat.chat("§aRemoved item §a§l$item.".withModPrefix()) + } else UChat.chat("§cItem §a§l$item does not exist!".withModPrefix()) + } + "list" -> { + UChat.chat("§2§lItems".withModPrefix()) + persistentData.autoBuyItems.forEach { + if (it.value == null) { + UChat.chat(" §b${it.key}") + } else { + UChat.chat(" §b${it.key} §7(max price §a${it.value} §7coins)") + } + } + } + else -> { + UChat.chat("§2§lUsage".withModPrefix()) + UChat.chat(" §aAdd item: §b/ambient buy add [max allowable price]") + UChat.chat(" §aRemove item: §b/ambient buy remove ") + UChat.chat(" §aList: §b/ambient buy list") + } + } + } +} \ No newline at end of file -- cgit