diff options
Diffstat (limited to 'src/main/java/com/encrox/zombie/Lobby.java')
-rwxr-xr-x | src/main/java/com/encrox/zombie/Lobby.java | 72 |
1 files changed, 72 insertions, 0 deletions
diff --git a/src/main/java/com/encrox/zombie/Lobby.java b/src/main/java/com/encrox/zombie/Lobby.java new file mode 100755 index 0000000..c33c3c3 --- /dev/null +++ b/src/main/java/com/encrox/zombie/Lobby.java @@ -0,0 +1,72 @@ +package com.encrox.zombie;
+
+import java.util.ArrayList;
+
+import org.bukkit.ChatColor;
+import org.bukkit.entity.Player;
+
+public class Lobby {
+
+ private ArrayList<Player> players;
+ private Player creator;
+ private String identifier;
+ private Map map;
+
+ public Lobby(Player creator, String identifier, Map map) {
+ this.creator = creator;
+ this.identifier = identifier;
+ this.map = map;
+ players = new ArrayList<Player>();
+ players.add(creator);
+ }
+
+ public String getIdentifier() {
+ return identifier;
+ }
+
+ public Player getCreator() {
+ return creator;
+ }
+
+ public boolean containsPlayer(Player player) {
+ if(creator.equals(player)) return true;
+ return players.contains(player);
+ }
+
+ public void removePlayer(Player player) {
+ if(creator.equals(player)) {
+ for(int i = 0, size = players.size(); i<size; i++) {
+ players.get(i).sendMessage(ChatColor.YELLOW + Zombie.lang.getProperty("lobby_disbanded"));
+ }
+ Zombie.lobbies.remove(this);
+ return;
+ }
+ if(players.contains(player)) {
+ for(int i = 0, size = players.size(); i<size; i++) {
+ players.get(i).sendMessage(ChatColor.YELLOW + Zombie.lang.getProperty("lobby_left").replace("%player%", player.getName()));
+ }
+ players.remove(player);
+ }
+ }
+
+ public void addPlayer(Player player) {
+ players.add(player);
+ for(int i = 0, size = players.size(); i<size; i++) {
+ players.get(i).sendMessage(ChatColor.YELLOW + Zombie.lang.getProperty("lobby_joined").replace("%player%", player.getName()));
+ }
+ }
+
+ public int getMax() {
+ return map.getPlayers();
+ }
+
+ public int getCurrent() {
+ return players.size();
+ }
+
+ public void start() {
+ Zombie.games.add(new Game(players, map));
+ Zombie.lobbies.remove(this);
+ }
+
+}
|