From 8c9f756e6baecf612d3728696ddd91cd65812498 Mon Sep 17 00:00:00 2001 From: Aurora Date: Mon, 20 Jul 2020 14:55:27 +0200 Subject: [PATCH] Adjust kitAmount for Roulette Option --- .../com/songoda/ultimatekits/kit/Kit.java | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/src/main/java/com/songoda/ultimatekits/kit/Kit.java b/src/main/java/com/songoda/ultimatekits/kit/Kit.java index 8b2d74b..9c9ddb6 100644 --- a/src/main/java/com/songoda/ultimatekits/kit/Kit.java +++ b/src/main/java/com/songoda/ultimatekits/kit/Kit.java @@ -84,7 +84,7 @@ public class Kit { private boolean hasRoom(Player player, int itemAmount) { int space = 0; - for (ItemStack content : player.getInventory().getContents()) { + for (ItemStack content : player.getInventory().getStorageContents()) { if (content == null) { space++; } @@ -285,7 +285,15 @@ public class Kit { } private boolean giveKit(Player player, int itemAmount, int kitAmount) { - if (Settings.NO_REDEEM_WHEN_FULL.getBoolean() && !hasRoom(player, itemAmount)) { + List innerContents = new ArrayList<>(getContents()); + int kitSize = innerContents.size(); + + // Amount of items from the kit to give to the player. + if (kitAnimation == KitAnimation.ROULETTE) itemAmount = 1; //TODO how about kitAmount > 1? generateRandomItem() will only give 1 random item instead of kitAmount + int itemGiveAmount = itemAmount > 0 ? itemAmount : kitSize; + if (kitAmount > 0) itemGiveAmount = itemGiveAmount * kitAmount; + + if (Settings.NO_REDEEM_WHEN_FULL.getBoolean() && !hasRoom(player, itemGiveAmount)) { plugin.getLocale().getMessage("event.claim.full").sendPrefixedMessage(player); return false; } @@ -293,13 +301,6 @@ public class Kit { if (Settings.SOUNDS_ENABLED.getBoolean() && kitAnimation == KitAnimation.NONE) CompatibleSound.ENTITY_PLAYER_LEVELUP.play(player, 0.6F, 15.0F); - List innerContents = new ArrayList<>(getContents()); - int kitSize = innerContents.size(); - - // Amount of items from the kit to give to the player. - int itemGiveAmount = itemAmount > 0 ? itemAmount : kitSize; - if (kitAmount > 0) itemGiveAmount = itemGiveAmount * kitAmount; - return generateRandomItem(innerContents, itemGiveAmount, player); }