Add semi Random Item for player #4
@ -1,6 +1,7 @@
|
|||||||
package de.steamwar.misslewars.countdowns;
|
package de.steamwar.misslewars.countdowns;
|
||||||
|
|
||||||
import de.steamwar.misslewars.*;
|
import de.steamwar.misslewars.*;
|
||||||
|
import de.steamwar.misslewars.items.Missile;
|
||||||
import de.steamwar.misslewars.items.SpecialItem;
|
import de.steamwar.misslewars.items.SpecialItem;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
@ -9,25 +10,33 @@ import org.bukkit.inventory.Inventory;
|
|||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
import org.bukkit.scheduler.BukkitTask;
|
import org.bukkit.scheduler.BukkitTask;
|
||||||
|
|
||||||
import java.util.EnumSet;
|
import java.util.*;
|
||||||
|
|
||||||
public class ItemCountdown extends StateDependent {
|
public class ItemCountdown extends StateDependent {
|
||||||
|
|
||||||
private BukkitTask task;
|
private BukkitTask task;
|
||||||
|
private Random random = new Random();
|
||||||
|
|
||||||
public ItemCountdown() {
|
public ItemCountdown() {
|
||||||
super(EnumSet.of(FightState.FIGHTING));
|
super(EnumSet.of(FightState.FIGHTING));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void run(){
|
private void run(){
|
||||||
ItemStack item = SpecialItem.getRandomItem();
|
int items = Math.max(MissileWars.getBlueTeam().getPlayers().size(), MissileWars.getRedTeam().getPlayers().size());
|
||||||
giveTeamItem(MissileWars.getBlueTeam(), item);
|
List<ItemStack> itemList = new ArrayList<>();
|
||||||
giveTeamItem(MissileWars.getRedTeam(), item);
|
for (int i = 0; i < items; i++) {
|
||||||
|
itemList.add(SpecialItem.getRandomItem());
|
||||||
}
|
}
|
||||||
|
|
||||||
private void giveTeamItem(MWTeam team, ItemStack item){
|
giveTeamItem(MissileWars.getBlueTeam(), itemList);
|
||||||
for(Player p : team.getPlayers()){
|
giveTeamItem(MissileWars.getRedTeam(), itemList);
|
||||||
givePlayerItem(p, item);
|
}
|
||||||
|
|
||||||
|
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
In neuem Issue referenzieren
Einen Benutzer sperren