use of me.botsko.prism.monitors.OreMonitor in project Prism-Bukkit by prism.
the class Prism method onEnable.
/**
* Enables the plugin and activates our player listeners
*/
@SuppressWarnings("rawtypes")
@Override
public void onEnable() {
plugin_name = this.getDescription().getName();
plugin_version = this.getDescription().getVersion();
prism = this;
log("Initializing Prism " + plugin_version + ". By Viveleroi.");
// Load configuration, or install if new
loadConfig();
if (getConfig().getBoolean("prism.allow-metrics")) {
try {
final Metrics metrics = new Metrics(this);
metrics.start();
} catch (final IOException e) {
log("MCStats submission failed.");
}
}
// init db
pool = initDbPool();
final Connection test_conn = dbc();
if (pool == null || test_conn == null) {
final String[] dbDisabled = new String[3];
dbDisabled[0] = "Prism will disable itself because it couldn't connect to a database.";
dbDisabled[1] = "If you're using MySQL, check your config. Be sure MySQL is running.";
dbDisabled[2] = "For help - try http://discover-prism.com/wiki/view/troubleshooting/";
logSection(dbDisabled);
disablePlugin();
}
if (test_conn != null) {
try {
test_conn.close();
} catch (final SQLException e) {
handleDatabaseException(e);
}
}
if (isEnabled()) {
// Info needed for setup, init these here
handlerRegistry = new HandlerRegistry();
actionRegistry = new ActionRegistry();
// Setup databases
setupDatabase();
// Cache world IDs
cacheWorldPrimaryKeys();
PlayerIdentification.cacheOnlinePlayerPrimaryKeys();
// ensure current worlds are added
for (final World w : getServer().getWorlds()) {
if (!Prism.prismWorlds.containsKey(w.getName())) {
Prism.addWorldName(w.getName());
}
}
// Apply any updates
final Updater up = new Updater(this);
up.apply_updates();
eventTimer = new TimeTaken(this);
queueStats = new QueueStats();
ignore = new Ignore(this);
// Plugins we use
checkPluginDependancies();
// Assign event listeners
getServer().getPluginManager().registerEvents(new PrismBlockEvents(this), this);
getServer().getPluginManager().registerEvents(new PrismEntityEvents(this), this);
getServer().getPluginManager().registerEvents(new PrismWorldEvents(), this);
getServer().getPluginManager().registerEvents(new PrismPlayerEvents(this), this);
getServer().getPluginManager().registerEvents(new PrismInventoryEvents(this), this);
getServer().getPluginManager().registerEvents(new PrismVehicleEvents(this), this);
// InventoryMoveItem
if (getConfig().getBoolean("prism.track-hopper-item-events") && Prism.getIgnore().event("item-insert")) {
getServer().getPluginManager().registerEvents(new PrismInventoryMoveItemEvent(), this);
}
if (getConfig().getBoolean("prism.tracking.api.enabled")) {
getServer().getPluginManager().registerEvents(new PrismCustomEvents(this), this);
}
// Assign listeners to our own events
// getServer().getPluginManager().registerEvents(new
// PrismRollbackEvents(), this);
getServer().getPluginManager().registerEvents(new PrismMiscEvents(), this);
// Add commands
getCommand("prism").setExecutor(new PrismCommands(this));
getCommand("prism").setTabCompleter(new PrismCommands(this));
getCommand("what").setExecutor(new WhatCommand(this));
// Register official parameters
registerParameter(new ActionParameter());
registerParameter(new BeforeParameter());
registerParameter(new BlockParameter());
registerParameter(new EntityParameter());
registerParameter(new FlagParameter());
registerParameter(new IdParameter());
registerParameter(new KeywordParameter());
registerParameter(new PlayerParameter());
registerParameter(new RadiusParameter());
registerParameter(new SinceParameter());
registerParameter(new WorldParameter());
// Init re-used classes
messenger = new Messenger(plugin_name);
actionsQuery = new ActionsQuery(this);
oreMonitor = new OreMonitor(this);
useMonitor = new UseMonitor(this);
// Init async tasks
actionRecorderTask();
// Init scheduled events
endExpiredQueryCaches();
endExpiredPreviews();
removeExpiredLocations();
// Delete old data based on config
launchScheduledPurgeManager();
// Keep watch on db connections, other sanity
launchInternalAffairs();
}
}
Aggregations