Skip to content

Latest commit

 

History

History
147 lines (101 loc) · 4.12 KB

README-en.md

File metadata and controls

147 lines (101 loc) · 4.12 KB

☢️ ️Tekore

Server's core.

This plugin handles synchronisation between player's data and the SQL database. It ensures that servers work properly between them.

Important

Every Hashtek plugin MUST use Tekore.
You MUST put the .jar file in the plugins folder in your server.

🇫🇷 Egalement disponible en Français !

Usage

To use Tekore, you have to store an instance at the root of your plugin.

Example :

public class Test extends JavaPlugin {

    private Tekore core;
    
    @Override
    public void onEnable()
    {
        try { // Important !
            this.core = Tekore.getInstance();
        } catch (NullPointerException exception) {
            System.err.println("Tekore failed to load. Stopping.");
            this.getServer().shutdown();
            return;
        }
    }
    
    public Tekore getCore()
    {
        return this.core;
    }
    
}

Important

You must surround Tekore's loading with a try/catch block in case Tekore doesn't load properly. (incorrect configuration, for example).

Features

  • Tekore#getRanks() : Returns every existing rank

HashLogger

In order to centralize logs (and maybe in the future create a log history), you need to use the HashLogger instance present in the Tekore.

You can get it using Tekore#getHashLogger().

See the example.

PlayerData

The PlayerData class stores all player data. This class is the main reason why we made this plugin.

Usage

You will use Tekore to get player's data, modify it and save it to the database.

In an event handler, for example, here is how to get player's data, edit it and save it to the database:

public class JoinEvent implements Listener, HashLoggable {
    
    private Tekore core;
    private HashLogger logger; // Tekore's Logger
    
    public JoinEvent(Tekore core)
    {
        this.core = core;
        this.logger = this.core.getHashLogger(); // Here we get Tekore's logger
    }
    
    @EventHandler
    public void onJoin(PlayerJoinEvent event)
    {
        Player player = event.getPlayer();
        PlayerData playerData = this.core.getPlayerData(player); // Data fetching
        
        /* Edit whatever you want */
        
        // Save data to the database.
        try {
            this.core.getAccountManager().updatePlayerAccount(playerData);
        } catch (SQLException exception) {
            this.logger.critical(this, "Failed to update PlayerData.", exception);
        }
    }
    
}

Tip

It is strongly recommended that you pass the Tekore instance to the class constructor, and not to make the instance static in the root of the plugin.

Note

Whenever a player disconnects from the server, its data will be automatically saved to the database.

Features

  • setRank() : Sets a player's rank

Caution

All functions not listed above are not intended to be used by anything other than the Tekore!

Database

To make the plugin work, it needs a database with a precise structure.

You will need:
- MySQL
- PhpMyAdmin
- Apache

Once these programs have been installed, import the hashtekdb.sql database with PhpMyAdmin.

Configuration files

HashLogger (/plugins/Tekore)

loggerLevel : Log level (see HashLogger)

Database (/.env)

DB_DATABASE : Database name (hashtekdb)
DB_HOST : Database's IP (127.0.0.1)
DB_PORT : Port to use (3306 by default)
DB_USER : Username (root by default)
DB_PASSWORD : Password (nothing by default)

Important

You must create the .env file at the server's root.

Made with 💜 by Lysandre B.wakatime