Balance ItemCountdown for uneven Teams #12
@ -19,7 +19,10 @@
|
||||
|
||||
package de.steamwar.misslewars;
|
||||
|
||||
import org.bukkit.*;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.enchantments.Enchantment;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
@ -19,8 +19,10 @@
|
||||
|
||||
package de.steamwar.misslewars.countdowns;
|
||||
|
||||
import de.steamwar.misslewars.*;
|
||||
import de.steamwar.misslewars.items.Missile;
|
||||
import de.steamwar.misslewars.Config;
|
||||
import de.steamwar.misslewars.FightState;
|
||||
import de.steamwar.misslewars.MissileWars;
|
||||
import de.steamwar.misslewars.StateDependent;
|
||||
import de.steamwar.misslewars.items.SpecialItem;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
@ -29,7 +31,10 @@ import org.bukkit.inventory.Inventory;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.scheduler.BukkitTask;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.EnumSet;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
public class ItemCountdown extends StateDependent {
|
||||
|
||||
@ -41,21 +46,18 @@ public class ItemCountdown extends StateDependent {
|
||||
}
|
||||
|
||||
private void run(){
|
||||
int items = Math.max(MissileWars.getBlueTeam().getPlayers().size(), MissileWars.getRedTeam().getPlayers().size());
|
||||
List<ItemStack> itemList = new ArrayList<>();
|
||||
List<Player> blue = new ArrayList<>(MissileWars.getBlueTeam().getPlayers());
|
||||
List<Player> red = new ArrayList<>(MissileWars.getBlueTeam().getPlayers());
|
||||
|
||||
int items = Math.max(blue.size(), red.size());
|
||||
int randomOffsetBlue = random.nextInt(blue.size());
|
||||
int randomOffsetRed = random.nextInt(red.size());
|
||||
|
||||
for (int i = 0; i < items; i++) {
|
||||
itemList.add(SpecialItem.getRandomItem());
|
||||
}
|
||||
ItemStack itemStack = SpecialItem.getRandomItem();
|
||||
|
||||
giveTeamItem(MissileWars.getBlueTeam(), itemList);
|
||||
giveTeamItem(MissileWars.getRedTeam(), itemList);
|
||||
}
|
||||
|
||||
private void giveTeamItem(MWTeam team, List<ItemStack> itemList) {
|
||||
List<ItemStack> itemStackList = new ArrayList<>(itemList);
|
||||
for (Player p : team.getPlayers()) {
|
||||
ItemStack itemStack = itemStackList.remove(random.nextInt(itemStackList.size()));
|
||||
givePlayerItem(p, itemStack);
|
||||
givePlayerItem(blue.get((i + randomOffsetBlue) % blue.size()), itemStack);
|
||||
givePlayerItem(red.get((i + randomOffsetRed) % red.size()), itemStack);
|
||||
}
|
||||
}
|
||||
|
||||
|
In neuem Issue referenzieren
Einen Benutzer sperren