mirror of
https://github.com/songoda/UltimateKits.git
synced 2024-09-30 06:37:32 +02:00
Merge branch 'development' of gitlab.com:Songoda/ultimatekits into core
This commit is contained in:
commit
98525b9367
@ -4,7 +4,7 @@ stages:
|
||||
variables:
|
||||
name: "UltimateKits"
|
||||
path: "/builds/$CI_PROJECT_PATH"
|
||||
version: "2.3.23"
|
||||
version: "2.3.24"
|
||||
|
||||
build:
|
||||
stage: build
|
||||
|
@ -290,11 +290,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 {
|
||||
EconomyManager.deposit(player, ((KitContentEconomy) item.getContent()).getAmount());
|
||||
@ -345,6 +352,8 @@ public class Kit {
|
||||
}
|
||||
}
|
||||
|
||||
if (!chosenItem) generateRandomItem(innerContents, amtToGive, player);
|
||||
|
||||
player.updateInventory();
|
||||
return true;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user