aboutsummaryrefslogtreecommitdiff
path: root/src/main/kotlin/com/ambientaddons/commands/SalvageCommand.kt
blob: d5390b4b16c7448ed1d598636748a835d919b67d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
package com.ambientaddons.commands

import AmbientAddons.Companion.persistentData
import com.ambientaddons.utils.Chat
import com.ambientaddons.utils.Extensions.withModPrefix
import com.ambientaddons.utils.SalvageStrategy
import gg.essential.universal.UChat

object SalvageCommand {
    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())
            }
            "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())
            }
            "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())
            }
            "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())
            }
            "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}")
                    }
                }
            }
            else -> {
                UChat.chat("""
                    ${Chat.getChatBreak()}
                    §b§lUsage:
                     §a/ambient salvage auto <Skyblock ID> §eto always salvage an item.          
                     §a/ambient salvage allow <Skyblock ID> §eto allow salvaging an item.
                     §a/ambient salvage block <Skyblock ID> §eto block salvaging an item.
                     §a/ambient salvage remove <Skyblock ID> §eto remove an 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.
                    ${Chat.getChatBreak()}
                """.trimIndent())
            }
        }
    }
}