151 Zeilen
4.1 KiB
Java
151 Zeilen
4.1 KiB
Java
package me.yaruma.fightsystem.fight;
|
|
|
|
import me.yaruma.fightsystem.FightSystem;
|
|
import me.yaruma.fightsystem.utils.ItemBuilder;
|
|
import org.bukkit.Material;
|
|
import org.bukkit.enchantments.Enchantment;
|
|
import org.bukkit.entity.Player;
|
|
|
|
import java.util.ArrayList;
|
|
|
|
public class FightTeam {
|
|
|
|
private FightPlayer leader;
|
|
private ArrayList<FightPlayer> players;
|
|
private FightSystem plugin;
|
|
private boolean ready;
|
|
private ArrayList<Player> invited;
|
|
private String name;
|
|
private String prefix;
|
|
|
|
public FightTeam(Player leader, FightSystem plugin) {
|
|
this.plugin = plugin;
|
|
this.leader = new FightPlayer(leader, false);
|
|
players = new ArrayList<>();
|
|
invited = new ArrayList<>();
|
|
}
|
|
|
|
public FightPlayer getFightPlayer(Player player) {
|
|
for(FightPlayer fightPlayer : players) {
|
|
if(fightPlayer.getPlayer().equals(player))
|
|
return fightPlayer;
|
|
}
|
|
return null;
|
|
}
|
|
|
|
public void setPlayerOut(Player player) {
|
|
getFightPlayer(player).setOut(true);
|
|
}
|
|
|
|
public boolean allPlayersOut() {
|
|
for(FightPlayer fightPlayer : this.players) {
|
|
if(!fightPlayer.isOut())
|
|
return false;
|
|
}
|
|
return true;
|
|
}
|
|
|
|
public boolean isPlayerInTeam(Player player) {
|
|
for(FightPlayer fightPlayer : this.players) {
|
|
if(fightPlayer.getPlayer().equals(player))
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
|
|
public boolean isPlayerLeader(Player player) {
|
|
return leader.getPlayer().equals(player);
|
|
}
|
|
|
|
public boolean isPlayerMember(Player player) {
|
|
return isPlayerInTeam(player) && !isPlayerLeader(player);
|
|
}
|
|
|
|
public void broadcast(String message) {
|
|
for(FightPlayer fightPlayer : players) {
|
|
fightPlayer.sendMessage(message);
|
|
}
|
|
}
|
|
|
|
public void addMember(Player player) {
|
|
FightPlayer fightPlayer = new FightPlayer(player, false);
|
|
players.add(fightPlayer);
|
|
invited.remove(player);
|
|
}
|
|
|
|
public void removePlayer(Player player) {
|
|
FightPlayer fightPlayer = Fight.getPlayerTeam(player).getFightPlayer(player);
|
|
players.remove(fightPlayer);
|
|
}
|
|
|
|
public boolean hasTeamLeader() {
|
|
return leader.getPlayer() != null;
|
|
}
|
|
|
|
public FightPlayer getLeader() {
|
|
return leader;
|
|
}
|
|
|
|
public void setLeader(FightPlayer leader) {
|
|
this.leader = leader;
|
|
if(!this.players.contains(leader))
|
|
this.players.add(leader);
|
|
}
|
|
|
|
public ArrayList<FightPlayer> getPlayers() {
|
|
return players;
|
|
}
|
|
|
|
public FightSystem getPlugin() {
|
|
return plugin;
|
|
}
|
|
|
|
public void setPlugin(FightSystem plugin) {
|
|
this.plugin = plugin;
|
|
}
|
|
|
|
public boolean isReady() {
|
|
return ready;
|
|
}
|
|
|
|
public void setReady(boolean ready) {
|
|
this.ready = ready;
|
|
|
|
FightTeam fightTeam = Fight.getPlayerTeam(this.leader.getPlayer());
|
|
|
|
FightSystem instance = FightSystem.getPlugin();
|
|
|
|
if(this.ready == true) {
|
|
|
|
fightTeam.getLeader().getPlayer().getInventory().setItem(3, new ItemBuilder(Material.INK_SACK, (short) 8).removeAllAtributs().addEnchantment(Enchantment.DURABILITY,1 ).setDisplayName("§aBereit").build());
|
|
broadcast(FightSystem.PREFIX + "§aEuer Team ist nun bereit!");
|
|
if(Fight.getOpposite(fightTeam).isReady()) {
|
|
instance.setPreRunningState();
|
|
}
|
|
} else {
|
|
fightTeam.getLeader().getPlayer().getInventory().setItem(3, new ItemBuilder(Material.INK_SACK, (short) 10).removeAllAtributs().addEnchantment(Enchantment.DURABILITY, 1).setDisplayName("§cNicht bereit").build());
|
|
fightTeam.broadcast(FightSystem.PREFIX + "§cEuer Team ist nicht mehr bereit!");
|
|
}
|
|
}
|
|
|
|
public ArrayList<Player> getInvited() {
|
|
return invited;
|
|
}
|
|
|
|
public String getName() {
|
|
return name;
|
|
}
|
|
|
|
public void setName(String name) {
|
|
this.name = name;
|
|
}
|
|
|
|
public String getPrefix() {
|
|
return prefix;
|
|
}
|
|
|
|
public void setPrefix(String prefix) {
|
|
this.prefix = prefix;
|
|
}
|
|
}
|