/* * Skytils - Hypixel Skyblock Quality of Life Mod * Copyright (C) 2021 Skytils * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as published * by the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . */ package skytils.skytilsmod.commands.impl import gg.essential.universal.UChat import net.minecraft.command.ICommandSender import net.minecraft.command.WrongUsageException import net.minecraft.util.ChatComponentText import skytils.skytilsmod.Skytils import skytils.skytilsmod.commands.BaseCommand import skytils.skytilsmod.core.PersistentSave import skytils.skytilsmod.features.impl.handlers.CooldownTracker object TrackCooldownCommand : BaseCommand("trackcooldown", listOf("cooldowntracker")) { override fun getCommandUsage(sender: ICommandSender): String = "/trackcooldown " override fun processCommand(sender: ICommandSender, args: Array) { if (!Skytils.config.itemCooldownDisplay) return UChat.chat("You must turn on Item Cooldown Display to use this command!") if (args.size < 2) throw WrongUsageException(getCommandUsage(sender)) val seconds = args[0].toDoubleOrNull() ?: throw WrongUsageException("You must specify a valid number") val ability = args.drop(1).joinToString(" ") if (ability.isBlank()) throw WrongUsageException("You must specify valid arguments.") if (CooldownTracker.itemCooldowns[ability] == seconds) { CooldownTracker.itemCooldowns.remove(ability) PersistentSave.markDirty() sender.addChatMessage(ChatComponentText("Removed the cooldown for $ability.")) } else { CooldownTracker.itemCooldowns[ability] = seconds PersistentSave.markDirty() sender.addChatMessage(ChatComponentText("Set the cooldown for $ability to $seconds seconds.")) } } }