-
Notifications
You must be signed in to change notification settings - Fork 0
Home
PlasmaBase edited this page Dec 30, 2021
·
13 revisions
1. Download the .jar from spigotmc.org
<dependency>
<groupId>me.plasmabase</groupId>
<artifactId>PastimeGames</artifactId>
<version>VERSION</version>
<scope>system</scope>
<systemPath>your/path/to/PastimeGames-VERSION.jar</systemPath>
</dependency>
Change VERSION to the downloaded version. (e.g. 0.0.1)
In this example we want to create a connect4 game with Player player1 and Player player2.
GameManager.createGame(GameType.CONNECT4, player1, player2);
This returns a Game which we can use to end the Game in advance, get the participation Players, find out whose turn it is and other things. If a Player is already in a game you can't add the Player to another game, and you can't play against yourself.
This plugin has its own eventsystem which is easy to use: You can subscribe to the desired event you want to listen to. Here are 2 examples with GameManager.endGame:
GameManager.gameEnded.subscribe(new EventListener<GameResult>() {
@Override
public void onCall(GameResult arg) {
//your code here
}
});
Create a class (in this case ExampleClass) which implements EventListener. Implement onCall(T arg), which get called when the event occurs and subscribe the class to the Event Manager:
GameManager.gameEnded.subscribe(new ExampleClass());