use of be.pyrrh4.core.util.Handler in project PyrCore by PYRRH4.
the class Utils method createCompatEconomy.
public static EconomyHandler createCompatEconomy() {
EconomyHandler handler = null;
try {
handler = new VaultEconomyHandler();
} catch (Exception ignored) {
}
if (handler == null || !handler.initialize()) {
handler = new EmptyEconomyHandler();
}
Logger.log(Level.INFO, "PyrCore", "Creating economy compatibility for " + handler.getClass().getSimpleName().replace("EconomyHandler", ""));
return handler;
}
use of be.pyrrh4.core.util.Handler in project PyrCore by PYRRH4.
the class Core method enable.
// ------------------------------------------------------------
// On enable
// ------------------------------------------------------------
@Override
protected void enable() {
// Auto update
allowAutoUpdate = getConfiguration().getBoolean("auto_update");
if (allowAutoUpdate) {
autoUpdateTaskId = new AutoUpdateTask().runTaskTimerAsynchronously(this, 100L, 18000L).getTaskId();
}
Logger.log(Level.INFO, this, "Allowing AutoUpdate : " + allowAutoUpdate);
// MySQL
if (getConfiguration() != null && (allowMySql = getConfiguration().getBoolean("mysql.enable"))) {
String host = getConfiguration().getString("mysql.host");
String name = getConfiguration().getString("mysql.name");
String usr = getConfiguration().getString("mysql.user");
String pwd = getConfiguration().getString("mysql.pass");
String url = "jdbc:mysql://" + host + "/" + name + "?allowMultiQueries=true";
mySQL = new MySQL(url, usr, pwd);
try {
mySQL.connect();
allowMySqlStats = getConfiguration().getBoolean("mysql_stats");
if (allowMySqlStats) {
new Handler() {
@Override
public void execute() {
mySQL.executeQuery("CREATE TABLE IF NOT EXISTS pyrcore_stats(uid INT NOT NULL AUTO_INCREMENT,uuid TINYTEXT NOT NULL,stats TEXT NOT NULL,PRIMARY KEY(uid))ENGINE=MYISAM DEFAULT CHARSET='utf8';");
}
}.runAsync();
}
Logger.log(Level.INFO, this, "Using mysql : yes");
Logger.log(Level.INFO, this, "Using mysql stats : " + (allowMySqlStats ? "yes" : "no"));
} catch (Exception exception) {
exception.printStackTrace();
mySQL = null;
Logger.log(Level.INFO, this, "Using mysql : no (unknown error)");
}
} else {
mySQL = null;
Logger.log(Level.INFO, this, "Using mysql : no");
}
// Load online users
for (Player player : Utils.getOnlinePlayers()) {
User.from(player);
}
// Core events
Bukkit.getPluginManager().registerEvents(this, this);
// Core commands
Command command = new Command(this, "pyr", "pyr", null);
command.addArguments(new Arguments("plugins|pl", "plugins", "list PyrCore dependant plugins", "pyr.core.admin", false, new CommandPlugins()));
command.addArguments(new Arguments("reload|rl [string]", "reload", "reload a plugin", "pyr.core.reload", false, new CommandReload()));
command.addArguments(new Arguments("support|bug|bugreport|report [string]", "support", "get support for a plugin", "pyr.core.admin", false, new CommandSupport()));
command.addArguments(new Arguments("mat", null, null, "pyr.core.admin", true, new CommandMat()));
// Task
long delay = Utils.getMinutesInTicks(30);
coreTaskId = new BukkitRunnable() {
@Override
public void run() {
// plugin data
for (PyrPlugin plugin : registeredPlugins) {
try {
plugin.savePluginData();
} catch (Exception ignored) {
}
}
}
}.runTaskTimerAsynchronously(this, delay, delay).getTaskId();
// Enable log
Logger.log(Level.SUCCESS, this, getDescription().getName() + " v" + getDescription().getVersion() + " has been enabled !");
}
Aggregations