Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Itemrefill fallback #462

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions COPYING
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Copyright (C) 2022-2024, Su386 and FlagMaster.
Copyright (C) 2022-2025, Su386 and FlagMaster.
All rights reserved.


Expand Down Expand Up @@ -27,4 +27,4 @@ LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,7 @@ object ItemRefill {

fun registerCommand() {
PSSCommand("itemrefill")
.addAlias("refillitems")
.addAlias("ir")
.addAlias("pearlrefill")
.addAlias("refillpearl")
.addAlias("pr")
.addAlias("refillitems", "ir", "pearlrefill", "refillpearl", "pr")
.setDescription("Refills your dungeon items.")
.setRunnable { runItemRefil() }
.register()
Expand All @@ -43,36 +39,24 @@ object ItemRefill {
}
}

private fun runItemRefil() {
private fun runItemRefill() {
Thread {
val list = ArrayList<String>()
val list = mutableMapOf<String, Int>()

if (config.refillPearls) {
list.add("ENDER_PEARL")
}
if (config.refillDecoys) {
list.add("DUNGEON_DECOY")
}
if (config.refillSpiritLeaps) {
list.add("SPIRIT_LEAP")
}
if (config.refillSuperboomTnt) {
list.add("SUPERBOOM_TNT")
}

val itemAmount = HashMap<String, Int>()

for (item in list) {
itemAmount[item] = countItemInInventory(item)
}
if (config.refillPearls) list["ENDER_PEARL"] = 16
if (config.refillDecoys) list["DUNGEON_DECOY"] = 64
if (config.refillSpiritLeaps) list["SPIRIT_LEAP"] = 16
if (config.refillSuperboomTnt) list["SUPERBOOM_TNT"] = 64

for (entry in itemAmount.entries) {
val maxStackSize = SkyblockDataManager.getItem(entry.key)?.getStackSize() ?: 64
val itemName = SkyblockDataManager.getItem(entry.key)?.name ?: ""
if (entry.value < maxStackSize) {
ChatUtils.sendClientMessage("Refilling ${maxStackSize - entry.value} ${itemName}s...")
list.forEach { (item, fallbackMax) ->
val currentAmount = countItemInInventory(item)
val maxStackSize = SkyblockDataManager.getItem(item)?.getStackSize() ?: fallbackMax
val itemName = SkyblockDataManager.getItem(item)?.name ?: ""
if (currentAmount < maxStackSize) {
val diff = maxStackSize - currentAmount
ChatUtils.sendClientMessage("Refilling ${diff} ${itemName.pluralize(diff)}s...")
PartlySaneSkies.minecraft.thePlayer.sendChatMessage(
"/gfs ${entry.key.lowercase(Locale.getDefault())} ${maxStackSize - entry.value}",
"/gfs ${item.lowercase()} ${diff}"
)
}

Expand Down
Loading