51 lines
1.3 KiB
Java
51 lines
1.3 KiB
Java
/*
|
|
* Copyright (c) 2017 univento.eu - All rights reserved
|
|
* You are not allowed to use, distribute or modify this code
|
|
*/
|
|
|
|
package eu.univento.core.api.game;
|
|
|
|
import eu.univento.core.api.player.CustomPlayer;
|
|
import lombok.Getter;
|
|
import org.bukkit.Bukkit;
|
|
|
|
import java.util.ArrayList;
|
|
|
|
/**
|
|
* @author joethei
|
|
* @version 1.0
|
|
*/
|
|
|
|
@Getter
|
|
public class Team {
|
|
|
|
private ArrayList<CustomPlayer> players = new ArrayList<>();
|
|
private final String name;
|
|
private final String prefix;
|
|
private final org.bukkit.scoreboard.Team scoreboardTeam;
|
|
|
|
public Team(String name, String prefix) {
|
|
this.name = name;
|
|
this.prefix = prefix;
|
|
if(Bukkit.getScoreboardManager().getMainScoreboard().getTeam(name) == null) {
|
|
scoreboardTeam = Bukkit.getScoreboardManager().getMainScoreboard().registerNewTeam(name);
|
|
}else{
|
|
scoreboardTeam = Bukkit.getScoreboardManager().getMainScoreboard().getTeam(name);
|
|
}
|
|
scoreboardTeam.setPrefix(prefix);
|
|
}
|
|
|
|
public void addPlayer(CustomPlayer p) {
|
|
players.add(p);
|
|
scoreboardTeam.addEntry(p.getName());
|
|
}
|
|
|
|
public void removePlayer(CustomPlayer p) {
|
|
players.remove(p);
|
|
scoreboardTeam.removeEntry(p.getName());
|
|
}
|
|
|
|
public boolean isPlayer(CustomPlayer p) {
|
|
return players.contains(p);
|
|
}
|
|
} |