Simplify ItemCountdown
Balance ItemCountdown
Dieser Commit ist enthalten in:
Ursprung
388323e6b0
Commit
25ae5ce352
@ -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;
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
In neuem Issue referenzieren
Einen Benutzer sperren