SteamWar/MissileWars
Archiviert
13
0

Simplify ItemCountdown

Balance ItemCountdown
Dieser Commit ist enthalten in:
jojo 2020-09-20 13:13:24 +02:00
Ursprung 388323e6b0
Commit 25ae5ce352
2 geänderte Dateien mit 14 neuen und 14 gelöschten Zeilen

Datei anzeigen

@ -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;

Datei anzeigen

@ -43,21 +43,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);
}
}