diff options
Diffstat (limited to 'src/main')
12 files changed, 287 insertions, 51 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt index fc3fd348a..c7e544839 100644 --- a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt +++ b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt @@ -2,6 +2,7 @@ package at.hannibal2.skyhanni import at.hannibal2.skyhanni.api.CollectionAPI import at.hannibal2.skyhanni.api.DataWatcherAPI +import at.hannibal2.skyhanni.api.GetFromSackAPI import at.hannibal2.skyhanni.config.ConfigFileType import at.hannibal2.skyhanni.config.ConfigManager import at.hannibal2.skyhanni.config.Features @@ -428,6 +429,7 @@ class SkyHanniMod { loadModule(ToolTipData()) loadModule(HighlightVisitorsOutsideOfGarden()) loadModule(GuiEditManager()) + loadModule(GetFromSackAPI) loadModule(UpdateManager) loadModule(CropAccessoryData()) loadModule(MayorElection()) diff --git a/src/main/java/at/hannibal2/skyhanni/api/GetFromSackAPI.kt b/src/main/java/at/hannibal2/skyhanni/api/GetFromSackAPI.kt new file mode 100644 index 000000000..942114203 --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/api/GetFromSackAPI.kt @@ -0,0 +1,198 @@ +package at.hannibal2.skyhanni.api + +import at.hannibal2.skyhanni.SkyHanniMod +import at.hannibal2.skyhanni.data.jsonobjects.repo.SacksJson +import at.hannibal2.skyhanni.events.GuiContainerEvent +import at.hannibal2.skyhanni.events.InventoryCloseEvent +import at.hannibal2.skyhanni.events.LorenzChatEvent +import at.hannibal2.skyhanni.events.LorenzTickEvent +import at.hannibal2.skyhanni.events.LorenzToolTipEvent +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 +import at.hannibal2.skyhanni.utils.NEUInternalName.Companion.asInternalName +import at.hannibal2.skyhanni.utils.NumberUtil.isInt +import at.hannibal2.skyhanni.utils.PrimitiveItemStack +import at.hannibal2.skyhanni.utils.PrimitiveItemStack.Companion.makePrimitiveStack +import at.hannibal2.skyhanni.utils.SimpleTimeMark +import at.hannibal2.skyhanni.utils.StringUtils.firstLetterUppercase +import at.hannibal2.skyhanni.utils.StringUtils.matchMatcher +import at.hannibal2.skyhanni.utils.repopatterns.RepoPattern +import net.minecraft.inventory.Slot +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent +import java.util.Deque +import java.util.LinkedList +import kotlin.time.Duration.Companion.seconds + +object GetFromSackAPI { + private val config get() = SkyHanniMod.feature.inventory.gfs + + val commands = arrayOf("gfs", "getfromsacks") + val commandsWithSlash = commands.map { "/$it" } + + private val fromSacksChatPattern by RepoPattern.pattern( + "gfs.chat.from", + "§aMoved §r§e(?<amount>\\d+) (?<item>.+)§r§a from your Sacks to your inventory." + ) + private val missingChatPattern by RepoPattern.pattern( + "gfs.chat.missing", + "§cYou have no (?<item>.+) in your Sacks!" + ) + + fun getFromSack(item: NEUInternalName, amount: Int) = getFromSack(item.makePrimitiveStack(amount)) + + fun getFromSack(item: PrimitiveItemStack) = getFromSack(listOf(item)) + + fun getFromSack(items: List<PrimitiveItemStack>) = addToQueue(items) + + fun getFromChatMessageSackItems( + item: PrimitiveItemStack, + text: String = "§lCLICK HERE§r§e to grab §ax${item.amount} §9${item.name.asString()}§e from sacks!" + ) = + ChatUtils.clickableChat(text, "${commands.first()} ${item.name.asString()} ${item.amount}") + + fun getFromSlotClickedSackItems(items: List<PrimitiveItemStack>, slotIndex: Int) = addToInventory(items, slotIndex) + + fun Slot.getFromSackWhenClicked(items: List<PrimitiveItemStack>) = getFromSlotClickedSackItems(items, slotIndex) + + private val minimumDelay = 1.65.seconds + + private val queue: Deque<PrimitiveItemStack> = LinkedList() + private val inventoryMap = mutableMapOf<Int, List<PrimitiveItemStack>>() + + private var lastTimeOfCommand = SimpleTimeMark.farPast() + + private var lastItemStack: PrimitiveItemStack? = null + + var sackList = emptyList<NEUInternalName>() + private set + + private fun addToQueue(items: List<PrimitiveItemStack>) = queue.addAll(items) + + private fun addToInventory(items: List<PrimitiveItemStack>, slotId: Int) = inventoryMap.put(slotId, items) + + @SubscribeEvent + fun onTick(event: LorenzTickEvent) { + if (!LorenzUtils.inSkyBlock) return + if (queue.isNotEmpty() && lastTimeOfCommand.passedSince() >= minimumDelay) { + val item = queue.poll() + LorenzUtils.sendCommandToServer("gfs ${item.name.asString()} ${item.amount}") + lastTimeOfCommand = ChatUtils.getTimeWhenNewlyQueuedMessageGetsExecuted() + } + } + + @SubscribeEvent + fun onInventoryClose(event: InventoryCloseEvent) { + inventoryMap.clear() + } + + @SubscribeEvent + fun onSlotClicked(event: GuiContainerEvent.SlotClickEvent) { + if (!LorenzUtils.inSkyBlock) return + if (event.clickedButton != 1) return // filter none right clicks + addToQueue(inventoryMap[event.slotId] ?: return) + inventoryMap.remove(event.slotId) + event.isCanceled = true + } + + @SubscribeEvent + fun onTooltipRender(event: LorenzToolTipEvent) { + if (!LorenzUtils.inSkyBlock) return + val list = inventoryMap[event.slot.slotIndex] ?: return + event.toolTip.let { tip -> + tip.add("") + tip.add("§ePress right click to get from sack:") + tip.addAll(list.map { "§ex" + it.amount.toString() + " " + it.name.asString() }) + } + } + + @SubscribeEvent + fun onMessageToServer(event: MessageSendToServerEvent) { + if (!LorenzUtils.inSkyBlock) return + if (!config.queuedGFS && !config.bazaarGFS) return + if (!event.isCommand(commandsWithSlash)) return + queuedHandler(event) + bazaarHandler(event) + } + + private fun queuedHandler(event: MessageSendToServerEvent) { + if (!config.queuedGFS) return + if (event.originatingModContainer?.modId == "skyhanni") return + + val (result, stack) = commandValidator(event.splitMessage.drop(1)) + + when (result) { + CommandResult.VALID -> getFromSack(stack ?: return) + CommandResult.WRONG_ARGUMENT -> ChatUtils.userError("Missing arguments! Usage: /getfromsacks <name/id> <amount>") + CommandResult.WRONG_IDENTIFIER -> ChatUtils.userError("Couldn't find an item with this name or identifier!") + CommandResult.WRONG_AMOUNT -> ChatUtils.userError("Invalid amount!") + } + event.isCanceled = true + } + + private fun bazaarHandler(event: MessageSendToServerEvent) { + if (event.isCanceled) return + if (!config.bazaarGFS || LorenzUtils.noTradeMode) return + lastItemStack = commandValidator(event.splitMessage.drop(1)).second + } + + private fun bazaarMessage(item: String, amount: Int, isRemaining: Boolean = false) = ChatUtils.clickableChat( + "§lCLICK §r§eto get the ${if (isRemaining) "remaining " else ""}§ax${amount} §9$item §efrom bazaar", + "bz $item" + ) + + private fun commandValidator(args: List<String>): Pair<CommandResult, PrimitiveItemStack?> { + if (args.size != 2) { + return CommandResult.WRONG_ARGUMENT to null + } + + val item = args[0].asInternalName() + + if (!sackList.contains(item)) { + return CommandResult.WRONG_IDENTIFIER to null + } + + val amountString = args[1] + + if (!amountString.isInt()) { + return CommandResult.WRONG_AMOUNT to null + } + + return CommandResult.VALID to item.makePrimitiveStack(amountString.toInt()) + } + + @SubscribeEvent + fun onChat(event: LorenzChatEvent) { + if (!LorenzUtils.inSkyBlock) return + if (!config.bazaarGFS || LorenzUtils.noTradeMode) return + val stack = lastItemStack ?: return + val message = event.message + fromSacksChatPattern.matchMatcher(message) { + val diff = stack.amount - group("amount").toInt() + if (diff <= 0) return + bazaarMessage(stack.name.asString().firstLetterUppercase(), diff, true) + lastItemStack = null + return + } + missingChatPattern.matchMatcher(message) { + bazaarMessage(stack.name.asString().firstLetterUppercase(), stack.amount) + lastItemStack = null + return + } + } + + private enum class CommandResult { + VALID, + WRONG_ARGUMENT, + WRONG_IDENTIFIER, + WRONG_AMOUNT + } + + @SubscribeEvent + fun onRepoReload(event: RepositoryReloadEvent) { + sackList = event.getConstant<SacksJson>("Sacks").sackList.map { it.replace(" ", "_").asInternalName() } + } +} diff --git a/src/main/java/at/hannibal2/skyhanni/config/commands/Commands.kt b/src/main/java/at/hannibal2/skyhanni/config/commands/Commands.kt index 3a0290b6a..5283c0c6e 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/commands/Commands.kt +++ b/src/main/java/at/hannibal2/skyhanni/config/commands/Commands.kt @@ -14,7 +14,6 @@ import at.hannibal2.skyhanni.features.chat.Translator import at.hannibal2.skyhanni.features.combat.endernodetracker.EnderNodeTracker import at.hannibal2.skyhanni.features.combat.ghostcounter.GhostUtil import at.hannibal2.skyhanni.features.commands.PartyCommands -import at.hannibal2.skyhanni.features.commands.WikiManager import at.hannibal2.skyhanni.features.event.diana.BurrowWarpHelper import at.hannibal2.skyhanni.features.event.diana.DianaProfitTracker import at.hannibal2.skyhanni.features.event.diana.GriffinBurrowHelper @@ -240,28 +239,22 @@ object Commands { "shresetseacreaturetracker", "Resets the Sea Creature Tracker" ) { SeaCreatureTracker.resetCommand(it) } - registerCommand( - "shfandomwiki", - "Searches the fandom wiki with SkyHanni's own method." - ) {WikiManager.otherWikiCommands(it, true)} - registerCommand( - "shfandomwikithis", - "Searches the fandom wiki with SkyHanni's own method." - ) {WikiManager.otherWikiCommands(it, true, true)} - registerCommand( - "shofficialwiki", - "Searches the official wiki with SkyHanni's own method." - ) {WikiManager.otherWikiCommands(it, false)} - registerCommand( - "shofficialwikithis", - "Searches the official wiki with SkyHanni's own method." - ) {WikiManager.otherWikiCommands(it, false, true)} - registerCommand0("shcalccrop", "Calculate how many crops need to be farmed between different crop milestones.", { - FarmingMilestoneCommand.onCommand(it.getOrNull(0), it.getOrNull(1), it.getOrNull(2), false) - }, FarmingMilestoneCommand::onComplete) - registerCommand0("shcalccroptime", "Calculate how long you need to farm crops between different crop milestones.", { - FarmingMilestoneCommand.onCommand(it.getOrNull(0), it.getOrNull(1), it.getOrNull(2), true) - }, FarmingMilestoneCommand::onComplete) + registerCommand0( + "shcalccrop", + "Calculate how many crops need to be farmed between different crop milestones.", + { + FarmingMilestoneCommand.onCommand(it.getOrNull(0), it.getOrNull(1), it.getOrNull(2), false) + }, + FarmingMilestoneCommand::onComplete + ) + registerCommand0( + "shcalccroptime", + "Calculate how long you need to farm crops between different crop milestones.", + { + FarmingMilestoneCommand.onCommand(it.getOrNull(0), it.getOrNull(1), it.getOrNull(2), true) + }, + FarmingMilestoneCommand::onComplete + ) } private fun usersBugFix() { diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/inventory/GetFromSackConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/inventory/GetFromSackConfig.java new file mode 100644 index 000000000..9454bd3fe --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/config/features/inventory/GetFromSackConfig.java @@ -0,0 +1,20 @@ +package at.hannibal2.skyhanni.config.features.inventory; + +import at.hannibal2.skyhanni.config.FeatureToggle; +import com.google.gson.annotations.Expose; +import io.github.moulberry.moulconfig.annotations.ConfigEditorBoolean; +import io.github.moulberry.moulconfig.annotations.ConfigOption; + +public class GetFromSackConfig { + + @Expose + @ConfigOption(name = "Queued GfS", desc = "If §e/gfs §for §e/getfromsacks §fis used it queues up the commands so all items are guarantied to be received.") + @ConfigEditorBoolean + @FeatureToggle + public boolean queuedGFS = true; + + @Expose + @ConfigOption(name = "Bazaar GfS", desc = "If you don't have enough items in sack get a prompt to buy them from bazaar.") + @ConfigEditorBoolean + public boolean bazaarGFS = false; +} diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/inventory/InventoryConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/inventory/InventoryConfig.java index 9e7a88e9d..ce60c05ff 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/features/inventory/InventoryConfig.java +++ b/src/main/java/at/hannibal2/skyhanni/config/features/inventory/InventoryConfig.java @@ -57,6 +57,11 @@ public class InventoryConfig { public HelperConfig helper = new HelperConfig(); @Expose + @ConfigOption(name = "Get From Sack", desc = "") + @Accordion + public GetFromSackConfig gfs = new GetFromSackConfig(); + + @Expose @ConfigOption( name = "Item Number", desc = "Showing the item number as a stack size for these items." @@ -200,5 +205,4 @@ public class InventoryConfig { @ConfigEditorBoolean @FeatureToggle public boolean shiftClickBrewing = false; - } diff --git a/src/main/java/at/hannibal2/skyhanni/data/ChatManager.kt b/src/main/java/at/hannibal2/skyhanni/data/ChatManager.kt index 9a5f93c0f..8b9ebc0d0 100644 --- a/src/main/java/at/hannibal2/skyhanni/data/ChatManager.kt +++ b/src/main/java/at/hannibal2/skyhanni/data/ChatManager.kt @@ -93,7 +93,7 @@ object ChatManager { ) messageHistory[IdentityCharacteristics(component)] = result - if (MessageSendToServerEvent(message).postAndCatch()) { + if (MessageSendToServerEvent(message, message.split(" "), originatingModContainer).postAndCatch()) { event.isCanceled = true messageHistory[IdentityCharacteristics(component)] = result.copy(actionKind = ActionKind.OUTGOING_BLOCKED) } diff --git a/src/main/java/at/hannibal2/skyhanni/data/SackAPI.kt b/src/main/java/at/hannibal2/skyhanni/data/SackAPI.kt index ee9ea621c..73ca7ca17 100644 --- a/src/main/java/at/hannibal2/skyhanni/data/SackAPI.kt +++ b/src/main/java/at/hannibal2/skyhanni/data/SackAPI.kt @@ -15,7 +15,6 @@ import at.hannibal2.skyhanni.utils.CollectionUtils.editCopy import at.hannibal2.skyhanni.utils.ItemUtils.getInternalName import at.hannibal2.skyhanni.utils.ItemUtils.getLore import at.hannibal2.skyhanni.utils.ItemUtils.name -import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.NEUInternalName import at.hannibal2.skyhanni.utils.NEUInternalName.Companion.asInternalName import at.hannibal2.skyhanni.utils.NEUItems.getNpcPriceOrNull @@ -299,8 +298,6 @@ object SackAPI { return sackData[item] ?: return SackItem(0, 0, SackStatus.MISSING) } - fun commandGetFromSacks(item: String, amount: Int) = LorenzUtils.sendCommandToServer("gfs $item $amount") - private fun saveSackData() { ProfileStorageData.sackProfiles?.sackContents = sackData SkyHanniMod.configManager.saveConfig(ConfigFileType.SACKS, "saving-data") diff --git a/src/main/java/at/hannibal2/skyhanni/events/MessageSendToServerEvent.kt b/src/main/java/at/hannibal2/skyhanni/events/MessageSendToServerEvent.kt index b6dff658e..49e51a30b 100644 --- a/src/main/java/at/hannibal2/skyhanni/events/MessageSendToServerEvent.kt +++ b/src/main/java/at/hannibal2/skyhanni/events/MessageSendToServerEvent.kt @@ -1,6 +1,11 @@ package at.hannibal2.skyhanni.events +import net.minecraftforge.fml.common.ModContainer import net.minecraftforge.fml.common.eventhandler.Cancelable @Cancelable -class MessageSendToServerEvent(val message: String) : LorenzEvent() +class MessageSendToServerEvent( + val message: String, + val splitMessage: List<String>, + val originatingModContainer: ModContainer? +) : LorenzEvent() 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 diff --git a/src/main/java/at/hannibal2/skyhanni/utils/ChatUtils.kt b/src/main/java/at/hannibal2/skyhanni/utils/ChatUtils.kt index f8a156644..533c67731 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/ChatUtils.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/ChatUtils.kt @@ -2,6 +2,7 @@ package at.hannibal2.skyhanni.utils import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.events.LorenzTickEvent +import at.hannibal2.skyhanni.events.MessageSendToServerEvent import at.hannibal2.skyhanni.utils.StringUtils.removeColor import net.minecraft.client.Minecraft import net.minecraft.event.ClickEvent @@ -11,6 +12,7 @@ import net.minecraftforge.fml.common.eventhandler.SubscribeEvent import java.util.LinkedList import java.util.Queue import kotlin.time.Duration.Companion.milliseconds +import kotlin.time.times object ChatUtils { @@ -183,6 +185,10 @@ object ChatUtils { private var lastMessageSent = SimpleTimeMark.farPast() private val sendQueue: Queue<String> = LinkedList() + private val messageDelay = 300.milliseconds + + fun getTimeWhenNewlyQueuedMessageGetsExecuted() = + (lastMessageSent + sendQueue.size * messageDelay).takeIf { !it.isInPast() } ?: SimpleTimeMark.now() @SubscribeEvent fun sendQueuedChatMessages(event: LorenzTickEvent) { @@ -191,7 +197,7 @@ object ChatUtils { sendQueue.clear() return } - if (lastMessageSent.passedSince() > 300.milliseconds) { + if (lastMessageSent.passedSince() > messageDelay) { player.sendChatMessage(sendQueue.poll() ?: return) lastMessageSent = SimpleTimeMark.now() } @@ -204,4 +210,10 @@ object ChatUtils { fun sendCommandToServer(command: String) { sendMessageToServer("/$command") } + + fun MessageSendToServerEvent.isCommand(commandWithSlash: String) = + splitMessage.takeIf { it.isNotEmpty() }?.get(0) == commandWithSlash + + fun MessageSendToServerEvent.isCommand(commandsWithSlash: Collection<String>) = + splitMessage.takeIf { it.isNotEmpty() }?.get(0) in commandsWithSlash } diff --git a/src/main/java/at/hannibal2/skyhanni/utils/PrimitiveItemStack.kt b/src/main/java/at/hannibal2/skyhanni/utils/PrimitiveItemStack.kt new file mode 100644 index 000000000..ad7b864b1 --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/utils/PrimitiveItemStack.kt @@ -0,0 +1,13 @@ +package at.hannibal2.skyhanni.utils + +import at.hannibal2.skyhanni.utils.NEUItems.getItemStack + +data class PrimitiveItemStack(val name: NEUInternalName, val amount: Int) { + + fun createItem() = name.getItemStack().apply { stackSize = amount } + + companion object { + + fun NEUInternalName.makePrimitiveStack(amount: Int) = PrimitiveItemStack(this, amount) + } +} |