mirror of
https://github.com/zoriya/PluginSDG.git
synced 2026-06-03 06:05:41 +00:00
Starting to create lobby management
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
package moe.sdg.PluginSDG;
|
||||
|
||||
import org.apache.commons.lang.NotImplementedException;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
public class GameManager extends JavaPlugin
|
||||
@@ -9,4 +11,9 @@ public class GameManager extends JavaPlugin
|
||||
{
|
||||
getLogger().info("Game manager loaded.");
|
||||
}
|
||||
|
||||
public Location getHubLocation()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,15 +1,20 @@
|
||||
package moe.sdg.PluginSDG;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
public abstract class MiniGame
|
||||
{
|
||||
private final ArrayList<Player> _players;
|
||||
private final GameManager _manager;
|
||||
private final Location _lobbyLocation;
|
||||
|
||||
public MiniGame()
|
||||
|
||||
public MiniGame(GameManager manager)
|
||||
{
|
||||
this._manager = manager;
|
||||
this._lobbyLocation = null;
|
||||
this._players = new ArrayList<Player>();
|
||||
}
|
||||
|
||||
@@ -23,18 +28,24 @@ public abstract class MiniGame
|
||||
public abstract int getMaxPlayers();
|
||||
|
||||
///! @brief Method called when a player wants to join the game.
|
||||
//! @param player The player who will join
|
||||
//! @param player The player who will join.
|
||||
//! @return True if the player has joined the game, false otherwise.
|
||||
public boolean join(Player player)
|
||||
{
|
||||
if (this.getMaxPlayers() < this.getCurrentPlayers() + 1)
|
||||
return false;
|
||||
this._players.add(player);
|
||||
player.teleport(this._lobbyLocation);
|
||||
return true;
|
||||
}
|
||||
|
||||
//! @brief Method called when a player wants to leave the game.
|
||||
public abstract void leave();
|
||||
//! @param player The player who will leave.
|
||||
public void leave(Player player)
|
||||
{
|
||||
this._players.remove(player);
|
||||
player.teleport(_manager.getHubLocation());
|
||||
}
|
||||
|
||||
//! @brief Start the game.
|
||||
public abstract void start();
|
||||
|
||||
@@ -11,6 +11,7 @@ class Team
|
||||
|
||||
public Team(String name, int maxPlayer)
|
||||
{
|
||||
super();
|
||||
this.name = name;
|
||||
this.maxPlayer = maxPlayer;
|
||||
this._players = new ArrayList<Player>();
|
||||
@@ -36,8 +37,10 @@ public abstract class TeamMiniGame extends MiniGame
|
||||
{
|
||||
private final ArrayList<Team> _teams;
|
||||
|
||||
public TeamMiniGame()
|
||||
|
||||
public TeamMiniGame(GameManager manager)
|
||||
{
|
||||
super(manager);
|
||||
this._teams = new ArrayList<Team>();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user