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 !
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).
Tekore#getRanks()
: Returns every existing rank
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.
The PlayerData
class stores all player data.
This class is the main reason why we made this plugin.
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.
setRank()
: Sets a player's rank
Caution
All functions not listed above are not intended to be used by anything other than the Tekore!
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.
loggerLevel
: Log level (see HashLogger)
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.