API Tutorial
First of all add LobbyAPI as a dependency:
depend: [LobbyAPI]
Then create an instance of Lobby:
Lobby lob = new Lobby();
After that you have to do several settings. Here are some examples:
lob.setName("exampleLobby"); lob.setPrefix("examplePrefix"); lob.setMinPlayers(2); lob.setMaxPlayers(24); Location LobbyLoc; //Just define any location you want as the lobby. lob.setLobbyLocation(loc); //Do the same for OutOfGameLocation and GameLocation lob.setCountdown(61); //The time the players have to wait in seconds lob.setLobbyPhase(LobbyState.WAITING);
Now the game will start when enough players are in the lobby. To do execute commands, etc. when the game starts, simply create a listener and register it.
public void onEnable(){ this.getServer().getPluginManager().registerEvents(this, new ListenerClass()); }
and in the ListenerClass:
@EventHandler public void onStart(StartEvent){ Lobby startedLobby = e.getLobby(); }
Now you can do some things like this with the lobby.
ArrayList<Player> Players = startedLobby.getPlayers(); for(Player all : Players){ all.getInventory().addItem(new ItemStack(Material.DIAMOND)); }
That´s it. Thank you for reading!
Comments