T-MiniGameAPI - library for creating Minecraft minigames. icon

T-MiniGameAPI - library for creating Minecraft minigames. -----

T-MinigameAPI is a modern, flexible, and easy-to-use library for creating Minecraft minigames.



[​IMG]
T-MinigameAPI is a modern, flexible, and easy-to-use library for creating Minecraft minigames.

JavaDocs: https://timsixth.pl/javadocs/minigame_api/2.0.0/
Documentation: https://timsixths-plugins.gitbook.io/minigameapi-docs/

Support discord server: https://discord.com/invite/zKmMy8bK56
Do you have a bug? Report it in the issues section on Github:
https://github.com/timsixth/MinigameAPI/issues

Do you want to contribute, create a fork of this repository and create a pull request.

Why I have created the library?
I created this library because I have seen that more minigame components are repeatable, maybe timers, stats systems, arena systems, team systems, and coins systems.
I have tried to implement a library that can be easy to use. In my opinion, this library is simple to use because e.g. arena system is already implemented and can you only use this implementation or create your own. The second good example is the default statistics system which is already implemented, but you can create your own.

Main library features:
  • Arena management system
  • Game management system
  • Game cosmetics system
  • Teams in-game
  • Advanced loading system from YAML files
  • Game statistics system
  • Coins system
  • Simple minigame configuration
  • Simple saving, deleting and updating system (You don't have to write a query to a database or use YAML spigot API to execute these actions)
  • Modules system (You can install modules, which are add more functionality)
  • Rejoin feature
Features which are included via modules:
  • Advanced loading system from SQL databases (MySQL or SQLite)
  • Integration with T-DataBasesAPI (Thanks to this plugin management of SQL databases is really simple)
  • Commands API (You can create parent commands and subcommands in separate classes)
  • MongoDb support
Adding dependency:

Tag - current version form GitHub releases section:
https://github.com/timsixth/MinigameAPI/releases

Code (Text):
<repositories>
  <repository>
   <id>jitpack.io</id>
   <url>https://jitpack.io</url>
  </repository>
</repositories>


<!-- library module includes addon system, api, addons-api and runnable plugin-->
<dependency>
<groupId>com.github.timsixth.MinigameAPI</groupId>
<artifactId>library</artifactId>
<version>Tag</version>
</dependency>

<!-- library-lite module includes only api and runnable plugin-->
<dependency>
<groupId>com.github.timsixth.MinigameAPI</groupId>
<artifactId>library-lite</artifactId>
<version>Tag</version>
</dependency>

<!-- api module includes only api and T-DataBasesAPI (It's recommended to use this module
to create the minigame)-->
<dependency>
<groupId>com.github.timsixth.MinigameAPI</groupId>
<artifactId>api</artifactId>
<version>Tag</version>
</dependency>

 
Code (Text):

allprojects {
   repositories {
       maven { url 'https://jitpack.io' }
   }
}
dependencies {

//includes all modules
implementation 'com.github.timsixth:MinigameAPI:Tag'

//includes only library, api, and addons-api modules
implementation 'com.github.timsixth.MinigameAPI:library:Tag'

//includes only api module
implementation 'com.github.timsixth.MinigameAPI:api:Tag'
}
 

Features showcase:

Getting started:
https://timsixths-plugins.gitbook.io/minigameapi-docs/minigame-setup

Basic features:
What is configuration?
Configuration is a set of settings that are necessary to build a minigame.
Default values for these settings are set in configurators.
The library has three types of configuration:

  1. PluginConfiguration - This configuration contains settings about plugin configuration
  • tablesPrefix (string) - prefix of every table in SQL database
  • useDefaultStatsSystem (true|false) - enables or disables using default stats system
  • arenaSaveType - (SINGLE_FILE | MANY_FILES) - sets arena save type (SINGLE_FILE - this type means arenas will be loaded from single file, MANY_FILES - every arena has single file)
  1. GameConfiguration
  • blockBreaking (true|false) - enables or disables breaking blocks during the game
  • blocksPlacing (true|false) - enables or disables placing blocks during the game
  • droppingItems (true|false) - enables or disables dropping itmes during the game
How to override the configurator?

Configurator defines default settings necessary to minigame work.
You can override the default configuration.

Code (Java):

public class MyPluginConfigurator extends DefaultPluginConfigurator {

    @Override
    public PluginConfiguration configure ( ) {
        return PluginConfiguration. builder ( )
                . tablesPrefix ( "thetag_" )
                . useDataBase ( true )
                . arenaSaveType (ArenaSaveType. SINGLE_FILE )
                . useDefaultStatsSystem ( true )
                . build ( ) ;
    }
}

The model represents one object in YAML or database.
The model is updatable, savable, and deletable.
Every model must have a field that will be annotated Id or IdSection annotation. These methods are saving, updating and delating your data immediately.
Code (Java):

Object save ( ) ; //Saves new model to database or file
boolean delete ( ) ; //Deletes model from file or table
Object update ( ) ; //Updates new model to database or file

//For example
User user = new User ( ) ;
user. save ( ) ;
 
See more: https://timsixths-plugins.gitbook.io/minigameapi-docs/basic-features/models

Minigame features:
Arena is saved into a YAML file by default.
Every arena system functions are provided by the library.
You can create your arena loader, the default loader loads data from YAML file.
The arena system uses Bukkit serialization to store data.

Arena:

The arena has a lobby location, name as arena ID, and a Map of locations.
How to create a new instance of Arena?
The first parameter is an arena's name.
The second parameter is the lobby location.
The third parameter is a map of locations.

Code (Java):

ArenaFactory arenaFactory = MiniGame. getArenaFactory ( )
Arena arena = arenaFactory. createArena ( "arenaName", player. getLocation ( ), new HashMap <> ( ) ) ;

//or
Arena arena = arenaFactory. createArena ( "arenaName", player. getLocation ( ) ) ;
 
How to manage arena locations?
Code (Java):

void addLocation (name, location ) ; //Adds new location
Map < String, Location > getLocations ( ) ; //Gets map of locations
void removeLocation (name ) ; //Removes location from map
Location getLocationByName (name ) //Gets location by name
Optional <Location > getLocation (name ) ; //Gets location by name
 

The game system has methods to manage teams, game states, and rounds in the game.
The game class has methods:

Code (Java):

Arena getArena ( ) ; //Gets arena which is using to play this game
List <UserGame > getPlayingUsers ( ) ; //Gets list of game users
GameState getState ( ) ; //Gets current game state
void setState (GameState gameState ) ; //Sets new game state
Optional <UserGame > getUserGame (UUID uuid ) ; //Gets UserGame by player's uuid
void sendMessage ( String message ) ; //Sends message to everyone who is playing on this game
int getRounds ( ) ; //Gets rounds amount
void setRounds ( int rounds ) ; //Sets rounds amount
void addRound ( ) ; //Adds one round to rounds
List <Team > getTeams ( ) ; //Gets list of teams
Optional <Team > getTeamByName ( String name ) ; //Gets team by name
Optional <Team > getTeamByPlayer (Player player ) ; //Gets team by player
void addUserGame (UserGame userGame ) ; //Adds a player to playing users
void removeUserGame (UserGame userGame ) ; //Removes a player from playing users
UserGame createUserGame (UUID playerUUID ) //Creates new user game
Team createTeam ( String name, String displayName, ChatColor color ) //Creates new team
runState ( ) //Runes current game state
void addRecoverableUserGame (RecoverableUserGame recoverableUserGame ) ; //Added new recoverableUserGame
void removeRecoverableUserGame (RecoverableUserGame recoverableUserGame ) ; //Removes recoverableUserGame
Optional <RecoverableUserGame > getRecoverableUserGame (UUID playerUuid ) ; //Gets user by uuid
List <RecoverableUserGame > getRecoverableUserGames ( ) ; //Gets list of RecoverableUserGames
void hidePlayers (UserGame user ) //Hides all online players for user who is playing in the game
void showPlayers (UserGame user ) // Show all online players for user who is playing in the game
 
How to create a new game instance?
Code (Java):

Game game = new GameImpl (arena ) ; //creates new game instance

UserGame userGame = game. createUserGame (player. getUniqueId ( ) ) ;

//create the first player who joined this game

game. addUserGame (userGame ) ; //adds this player to list
gameManager. addGame (game ) ; //adds this game to list
 
GameStates
The game state is the state of the game that is currently running, maybe playing, starting .etc.

How to set a new game state?
Code (Java):
game. setState ( new MyState ( ) ) ;
This state runs immediately after setting a new game state.

How to create a new GameState?
Code (Java):

public class MyGameState implements GameState {

  @Override
  public void run ( ) {
      //define your logic
    }
}
 

UserCoins

This class represents the user's coins.
In the class, the coins are saved in int type. In the future, this will be changed to double type.
How to create a new instance of the user?

Code (Java):

UserCoinsFactory userCoinsFactory = MiniGame. getUserCoinsFactory ( ) ;

UserCoins userCoins   = userCoinsFactory. createUserCoins (player. getUniqueId ( ) ) ;

//or with default coins

UserCoins userCoins = userCoinsFactory. createUserCoins (player. getUniqueId ( ), 100.0 ) ;
 
UserCoins methods:

Code (Java):

double getCoins ( ) ; //Gets coins
void setCoins ( double coins ) ; //Sets coins
void addCoins ( double coins ) ; //Adds coins
void removeCoins ( double coins ) ; //Removes coins
boolean hasCoins ( double coins ) ; //Chceks when player has coins
 
Code (Java):

userCoins. getCoins ( ) ;
userCoins. setCoins ( 100.1 ) ;
 

The default statistics system by default saves data in the database in the table users_stats.
Statistics are saved for an arena.
The library has a default statistics system, but you can implement your own.
The default statistics system saves only wins and loses.

How to enable the default stats system?
Set useDefaultStatsSystem to true in your PluginConfiguartion.

Code (Java):
builder. useDefaultStatsSystem ( true )
How to add stats to users?
Code (Java):

UserStats userStats = statisticsManager. getUserStatsOrCreate (player, arena ) ;
userStats. addWin ( ) ;
 

In the cosmetics system, there are two different types of cosmetics.
  • Cosmetic
  • ParticleCosmetic
Cosmetics must be registered in the main class.

How to create your cosmetics?
Code (Java):

public class MyCosmetic implements Cosmetic {

@Override
public String getName ( ) {
return "MY_COSEMTIC_NAME"
}

@Override
public void show (Player player ) {
    //your logic
  }
}
 
How to register comsetic?
Code (Java):
getCosmeticsManager ( ). addCosmetic ( new MyCosmetic ( ) ) ;
How to register more than one cosmetics?
Code (Java):
getCosmeticsManager ( ). addCosmetics ( new MyCosmetic ( ), new MyParticleCosmetic ( ) ) ;
How to unregister cosmetic?
Code (Java):
getCosmeticsManager ( ). removeCosmetic ( new MyCosmetic ( ) ) ;
UserCosmetics

Code (Java):

Optional <UserCosmetics > userCosmeticsOptional = userCosmeticsManager. getUserByUuid (player. getUniqueId ( ) ) ;

if ( !userCosmetics =Optional. isPresent ( ) ) return ;

UserCosmetics userCosmetics userCosmeticsDbModelOptional. get ( ) ;

userCosmetics. addCosmetic ( new MyCosmetic ( ) ) ;
userCosmetics. enableCosmetic ( new MyCosmetic ( ) ) ;
 


Code (Java):

boolean hasCosmetic (Cosmetic cosmetic ) ; //Checks having cosmetic

void removeCosmetic (Cosmetic cosmetic ) ; //Removes cosmetic
void addCosmetic (Cosmetic cosmetic ) ; // Adds cosmetic
boolean isCosmeticEnable (Cosmetic cosmetic ) ; //Checks that cosmetic is enabled
void enableCosmetic (Cosmetic cosmetic ) ; //Enables cosmetic
void disableCosmetic (Cosmetic cosmetic ) ; //Disables cosmetic
 

Resource Information
Author:
----------
Total Downloads: 221
First Release: Dec 30, 2023
Last Update: Sep 23, 2024
Category: ---------------
All-Time Rating:
1 ratings
Find more info at timsixth.pl...
Version -----
Released: --------------------
Downloads: ------
Version Rating:
----------------------
-- ratings