MoneySQL - Developers API

MoneySQL Developers API

Back to main site

Using API you can:

  • Listen to MoneySQLUpdateEvent which is called when updating players money
  • Check reason of updating using CausedBy enumeration (EVENT, PLUGIN_DISABLE, COMMAND, AUTO_SCHEDULER, OTHER)
  • Use powerfull mr.wruczek.moneysql.Methods class (you can get: player UUID, player money, check if event from configuration is enabled, and get numerous of asynchronous and non-asynchronous updating methods)
  • Check information about database, execute sql and more
    • mr.wruczek.moneysql.data.MySQLManager - methods which MoneySQL are using (creating player in database ect.).
    • mr.wruczek.moneysql.data.MoneySQLManager - mysql variable - everything about MySQL (executing query, opening and closing connection ect.)
  • Get configuration variables: mr.wruczek.moneysql.ConfigManager

Examples

Basics:

// Our player
Player player = Bukkit.getPlayer("Wruczek");

// Get his UUID
Methods.getUUID(player);

// Getting his money
Methods.getPlayerMoney(player);

// Using string with name
Methods.getPlayerMoney("Wruczek");

// Check if event from configuration is enabled
Methods.isEventEnabled("PlayerJoinEvent");

// Update player (easiest way)
Methods.update(player);

// Update player (lets set CausedBy and get response)
Methods.update(player, CausedBy.COMMAND, new Runnable() {
	@Override
	public void run() {
		System.out.println("Done updating");
	}
});

// Get MySQL host name from config
ConfigManager.mysql_host;

// Get list of events
ConfigManager.update_events;

// Lets execute query
MySQLManager.mysql.updateSQL("UPDATE moneysql SET money=100 WHERE last_known_name=\"Wruczek\"");

// Lets execute query, but this time we want to get ResultSet
ResultSet rs = MySQLManager.mysql.querySQL("SELECT * FROM moneysql");

Examples with events:

// Lets inform about working PlayerJoinEvent
@EventHandler
public void join(PlayerJoinEvent event) {
	if(Methods.isEventEnabled("PlayerJoinEvent")) {
		System.out.println("You enabled updating player money when player join...");
		System.out.println("Updating player " + event.getPlayer().getName() + "...");
	}
}

// Lets use our custom event
@EventHandler
public void onMoneySQLUpdate(MoneySQLUpdateEvent event) {
	// Lets make that player Wruczek will never be updated by command /moneysql update...
	if(event.getPlayer().getName().equals("Wruczek") && event.getCausedBy() == CausedBy.COMMAND) {
		event.setCancelled(true);
	}
}

Comments

Posts Quoted:
Reply
Clear All Quotes