aboutsummaryrefslogtreecommitdiff
path: root/src/main/kotlin/com/ambientaddons/commands/SalvageCommand.kt
blob: 0d11e790fe5f7b2ba726713f228ab4f9522c5a0d (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
package com.ambientaddons.commands

import AmbientAddons.Companion.persistentData
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())
            }
            "remove" -> {
                val item = args[1]
                val removed = persistentData.salvageMap.remove(item) != null
                persistentData.save()
                UChat.chat((if (removed) "§aRemoving item §a§l${item}." else "§cItem not in list.").withModPrefix())
            }
            "list" -> {
                UChat.chat("§2§lItems §7(§aalways salvage, §callow salvaging§7)".withModPrefix())
                persistentData.salvageMap.forEach {
                    if (it.value == SalvageStrategy.Always) {
                        UChat.chat(" §a${it.key}")
                    } else {
                        UChat.chat(" §e${it.key}")
                    }
                }
            }
            else -> {
                UChat.chat("§2§lUsage".withModPrefix())
                UChat.chat(" §aAlways salvage item: §b/ambient salvage auto <Skyblock ID>")
                UChat.chat(" §aAllow salvaging item: §b/ambient salvage allow <Skyblock ID>")
                UChat.chat(" §aBlock salvaging item: §b/ambient remove <Skyblock ID>")
            }
        }
    }
}