SteamWar/MissileWars
Archiviert
13
0

Update1.0 #11

Geschlossen
YoyoNow möchte 11 Commits von Update1.0 nach master mergen
2 geänderte Dateien mit 14 neuen und 14 gelöschten Zeilen
Nur Änderungen aus Commit 25ae5ce352 werden angezeigt - Alle Commits anzeigen

Datei anzeigen

@ -19,7 +19,10 @@
package de.steamwar.misslewars; 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.enchantments.Enchantment;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;

Datei anzeigen

@ -43,21 +43,18 @@ public class ItemCountdown extends StateDependent {
} }
private void run(){ private void run(){
int items = Math.max(MissileWars.getBlueTeam().getPlayers().size(), MissileWars.getRedTeam().getPlayers().size()); List<Player> blue = new ArrayList<>(MissileWars.getBlueTeam().getPlayers());
List<ItemStack> itemList = new ArrayList<>(); 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++) { for (int i = 0; i < items; i++) {
itemList.add(SpecialItem.getRandomItem()); ItemStack itemStack = SpecialItem.getRandomItem();
}
giveTeamItem(MissileWars.getBlueTeam(), itemList); givePlayerItem(blue.get((i + randomOffsetBlue) % blue.size()), itemStack);
giveTeamItem(MissileWars.getRedTeam(), itemList); givePlayerItem(red.get((i + randomOffsetRed) % red.size()), itemStack);
}
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);
} }
} }