Skip to content
PlasmaBase edited this page Dec 30, 2021 · 13 revisions

Welcome to the PastimeGames wiki!

Setup:

1. Download the .jar from spigotmc.org

2. Add the .jar to your Maven Project

<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)

3. Copy the .jar to the plugins folder on the server and (re)start the server to use the API.

How to use it:

1. GameManager:

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.

2. Events:

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:

1. Example:

GameManager.gameEnded.subscribe(new EventListener<GameResult>() {
    @Override
    public void onCall(GameResult arg) {
        //your code here


    }
});

2. Example:

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());