summaryrefslogtreecommitdiff
path: root/src/main/java/at/hannibal2/skyhanni/features
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni/features')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/commands/tabcomplete/GetFromSacksTabComplete.kt28
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/minion/MinionXp.kt6
2 files changed, 13 insertions, 21 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/features/commands/tabcomplete/GetFromSacksTabComplete.kt b/src/main/java/at/hannibal2/skyhanni/features/commands/tabcomplete/GetFromSacksTabComplete.kt
index 1cbc853b2..a777c76b4 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/commands/tabcomplete/GetFromSacksTabComplete.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/commands/tabcomplete/GetFromSacksTabComplete.kt
@@ -1,44 +1,38 @@
package at.hannibal2.skyhanni.features.commands.tabcomplete
import at.hannibal2.skyhanni.SkyHanniMod
-import at.hannibal2.skyhanni.data.jsonobjects.repo.SacksJson
+import at.hannibal2.skyhanni.api.GetFromSackAPI
+import at.hannibal2.skyhanni.api.GetFromSackAPI.commands
import at.hannibal2.skyhanni.events.MessageSendToServerEvent
-import at.hannibal2.skyhanni.events.RepositoryReloadEvent
import at.hannibal2.skyhanni.utils.ChatUtils
+import at.hannibal2.skyhanni.utils.ChatUtils.isCommand
import at.hannibal2.skyhanni.utils.LorenzUtils
+import at.hannibal2.skyhanni.utils.NEUInternalName.Companion.asInternalName
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
object GetFromSacksTabComplete {
private val config get() = SkyHanniMod.feature.commands.tabComplete
- private var sackList = emptyList<String>()
- private val commands = arrayOf("gfs", "getfromsacks")
-
- @SubscribeEvent
- fun onRepoReload(event: RepositoryReloadEvent) {
- sackList = event.getConstant<SacksJson>("Sacks").sackList
- }
fun handleTabComplete(command: String): List<String>? {
if (!isEnabled()) return null
if (command !in commands) return null
- return sackList.map { it.replace(" ", "_") }
+ return GetFromSackAPI.sackList.map { it.asString() }
}
@SubscribeEvent
fun onMessageSendToServer(event: MessageSendToServerEvent) {
if (!isEnabled()) return
- val message = event.message
- if (!commands.any { message.startsWith("/$it ") }) return
+ if (!event.isCommand(GetFromSackAPI.commandsWithSlash)) return
- val rawName = message.split(" ")[1]
- val realName = rawName.replace("_", " ")
- if (realName == rawName) return
- if (realName !in sackList) return
+ val rawName = event.splitMessage[1]
+ val realName = rawName.asInternalName()
+ if (realName.asString() == rawName) return
+ if (realName !in GetFromSackAPI.sackList) return
event.isCanceled = true
- ChatUtils.sendMessageToServer(message.replace(rawName, realName))
+ ChatUtils.sendMessageToServer(event.message.replace(rawName, realName.asString()))
}
fun isEnabled() = LorenzUtils.inSkyBlock && config.gfsSack
diff --git a/src/main/java/at/hannibal2/skyhanni/features/minion/MinionXp.kt b/src/main/java/at/hannibal2/skyhanni/features/minion/MinionXp.kt
index ddebeb7c4..d866ecc8d 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/minion/MinionXp.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/minion/MinionXp.kt
@@ -16,6 +16,7 @@ import at.hannibal2.skyhanni.utils.LorenzVec
import at.hannibal2.skyhanni.utils.NEUInternalName
import at.hannibal2.skyhanni.utils.NEUInternalName.Companion.asInternalName
import at.hannibal2.skyhanni.utils.NumberUtil.addSeparators
+import at.hannibal2.skyhanni.utils.PrimitiveItemStack
import at.hannibal2.skyhanni.utils.SimpleTimeMark
import net.minecraft.block.BlockChest
import net.minecraft.client.Minecraft
@@ -44,9 +45,6 @@ class MinionXp {
val timestamp: SimpleTimeMark = SimpleTimeMark.now()
}
- // TODO move to some other spot. This can be used at other features as well
- private data class PrimitiveItemStack(val name: NEUInternalName, val stackSize: Int)
-
private fun toPrimitiveItemStack(itemStack: ItemStack) =
PrimitiveItemStack(itemStack.getInternalName(), itemStack.stackSize)
@@ -113,7 +111,7 @@ class MinionXp {
val xp = xpInfoMap[name] ?: return@forEach
// TODO add wisdom and temporary skill exp (Events) to calculation
- val baseXp = xp.amount * item.stackSize
+ val baseXp = xp.amount * item.amount
val xpAmount = if (MayorElection.isPerkActive("Derpy", "MOAR SKILLZ!!!")) {
baseXp * 1.5
} else baseXp