Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package me.whatapigdoes.craftsg;
- import java.util.ArrayList;
- import java.util.HashMap;
- import java.util.List;
- import org.bukkit.ChatColor;
- import org.bukkit.Location;
- import org.bukkit.entity.Player;
- public class Arena {
- public HashMap<Location, Boolean> spawns = new HashMap<Location, Boolean>();
- public Location lobby = null;
- public List<PlayerData> players = new ArrayList<PlayerData>();
- public String name = "Unknown";
- public State state = State.UNKNOWN;
- public boolean enabled = false;
- public Arena(String name, Location lobby, boolean enabled) {
- this.name = name;
- this.lobby = lobby;
- this.enabled = enabled;
- if (enabled == false){
- state = State.DISABLED;
- }else{
- state = State.WAITING;
- }
- }
- public String addPlayer(Player p) {
- if (state != State.WAITING || enabled == false) {
- return ChatColor.RED + " This arena is not joinable";
- } else {
- if ((spawns.size() + 1) > spawns.size()) {
- players.add(new PlayerData(p, this));
- p.teleport(lobby);
- return ChatColor.GREEN + " Successfully joined arena";
- } else {
- return ChatColor.RED + "This arena is full!";
- }
- }
- }
- public void removePlayer(Player p) {
- for (PlayerData pd : players) {
- if (pd.getPlayer().equals(p)) {
- pd.reset();
- players.remove(pd);
- }
- }
- }
- public void disable() {
- for (PlayerData pd : players) {
- pd.getPlayer().sendMessage(
- ChatColor.GRAY + "[TurtleSG]" + ChatColor.RED
- + " This arena has been disabled!");
- pd.reset();
- players.remove(pd);
- }
- state = State.DISABLED;
- enabled = false;
- ArenaManager.getManager().plugin.getLogger().info(
- "Disabled arena " + name);
- }
- public void enable() {
- state = State.WAITING;
- enabled = true;
- ArenaManager.getManager().plugin.getLogger().info(
- "Enabled arena" + name);
- }
- public void addSpawn(Location spawn) {
- spawns.put(spawn, false);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement