diff --git a/src/de/steamwar/misslewars/MWTeam.java b/src/de/steamwar/misslewars/MWTeam.java index 42e4022..7ccdced 100644 --- a/src/de/steamwar/misslewars/MWTeam.java +++ b/src/de/steamwar/misslewars/MWTeam.java @@ -104,6 +104,11 @@ public class MWTeam { Inventory inventory = p.getInventory(); for (int i = 0; i <= 35; i++) { // 35 is the last normal inventory slot ItemStack itemStack = inventory.getItem(i); + if (itemStack != null && itemStack.isSimilar(item) && itemStack.getAmount() + item.getAmount() <= item.getMaxStackSize()) { + itemStack.setAmount(itemStack.getAmount() + item.getAmount()); + inventory.setItem(i, itemStack); + return; + } if (itemStack != null && itemStack.getType() == item.getType() && getUsesOfItem(itemStack) + getUsesOfItem(item) <= itemStack.getType().getMaxDurability()) { int uses = getUsesOfItem(itemStack) + getUsesOfItem(item); ItemMeta itemMeta = itemStack.getItemMeta(); @@ -112,10 +117,6 @@ public class MWTeam { itemStack.setItemMeta(damageable); inventory.setItem(i, itemStack); return; - } else if (itemStack != null && itemStack.isSimilar(item) && itemStack.getAmount() + item.getAmount() <= item.getMaxStackSize()) { - itemStack.setAmount(itemStack.getAmount() + item.getAmount()); - inventory.setItem(i, itemStack); - return; } } diff --git a/src/de/steamwar/misslewars/countdowns/ItemCountdown.java b/src/de/steamwar/misslewars/countdowns/ItemCountdown.java index 8026fc6..5270934 100644 --- a/src/de/steamwar/misslewars/countdowns/ItemCountdown.java +++ b/src/de/steamwar/misslewars/countdowns/ItemCountdown.java @@ -41,11 +41,6 @@ public class ItemCountdown extends StateDependent { } private void run() { - if (currenTime == 0) { - ItemStack itemStack = SpecialItem.getRandomItem(); - MissileWars.getBlueTeam().givePlayerItem(itemStack); - MissileWars.getRedTeam().givePlayerItem(itemStack); - } currenTime++; int teamCount = Math.max(MissileWars.getBlueTeam().size(), MissileWars.getRedTeam().size()); diff --git a/src/de/steamwar/misslewars/items/SpecialItem.java b/src/de/steamwar/misslewars/items/SpecialItem.java index bce889e..de8b684 100644 --- a/src/de/steamwar/misslewars/items/SpecialItem.java +++ b/src/de/steamwar/misslewars/items/SpecialItem.java @@ -40,7 +40,8 @@ import java.util.Random; public abstract class SpecialItem { private static final Random random = new Random(); - private static long count = 0; + private static double count = 0; + private static int consecutiveSupportItems = 0; private static List supportItems = new ArrayList<>(); private static List missileItems = new ArrayList<>(); @@ -110,14 +111,21 @@ public abstract class SpecialItem { } public static ItemStack getRandomItem() { + if (Config.MissileChance == 0 || consecutiveSupportItems > 1) { + consecutiveSupportItems = 0; + return supportItems.get(random.nextInt(supportItems.size())).getItem(); + } + if (Config.MissileChance == 1) { + return missileItems.get(random.nextInt(missileItems.size())).getItem(); + } + double missileChance = Config.MissileChance + count * 0.1; - if (Config.MissileChance == 0) missileChance = 0.0; - if (Config.MissileChance == 1) missileChance = 1.0; if (random.nextDouble() > missileChance) { - count++; + count += Config.MissileChance; + consecutiveSupportItems++; return supportItems.get(random.nextInt(supportItems.size())).getItem(); } else { - count--; + count -= 1 - Config.MissileChance; return missileItems.get(random.nextInt(missileItems.size())).getItem(); } }