mirror of
https://github.com/songoda/UltimateKits.git
synced 2024-11-23 02:35:28 +01:00
Fixed kits sometimes giving no items.
This commit is contained in:
parent
63e6b8e090
commit
e8e2b26f10
@ -4,7 +4,7 @@ stages:
|
||||
variables:
|
||||
name: "UltimateKits"
|
||||
path: "/builds/$CI_PROJECT_PATH"
|
||||
version: "2.3.23"
|
||||
version: "2.3.24"
|
||||
|
||||
build:
|
||||
stage: build
|
||||
|
@ -286,11 +286,18 @@ public class Kit {
|
||||
if (amt != amtToGive || kitAnimation != KitAnimation.NONE)
|
||||
Collections.shuffle(innerContents);
|
||||
|
||||
return generateRandomItem(innerContents, amtToGive, player);
|
||||
}
|
||||
|
||||
private boolean generateRandomItem(List<KitItem> innerContents, int amtToGive, Player player) {
|
||||
boolean chosenItem = false;
|
||||
for (KitItem item : innerContents) {
|
||||
if (amtToGive == 0) continue;
|
||||
int ch = item.getChance() == 0 ? 100 : item.getChance();
|
||||
double rand = Math.random() * 100;
|
||||
if (rand - ch < 0 || ch == 100) {
|
||||
chosenItem = true;
|
||||
|
||||
if (item.getContent() instanceof KitContentEconomy) {
|
||||
try {
|
||||
Methods.pay(player, ((KitContentEconomy) item.getContent()).getAmount());
|
||||
@ -341,6 +348,8 @@ public class Kit {
|
||||
}
|
||||
}
|
||||
|
||||
if (!chosenItem) generateRandomItem(innerContents, amtToGive, player);
|
||||
|
||||
player.updateInventory();
|
||||
return true;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user