use of pl.themolka.arcade.event.EventBus in project Arcade2 by ShootGame.
the class ArcadePlugin method start.
public final void start() throws Throwable {
if (this.isRunning()) {
throw new IllegalStateException("Already running!");
} else if (this.getStartTime() != null) {
throw new IllegalStateException("Outdated class!");
}
this.running = true;
this.startTime = Time.now();
this.loadParsers();
try (InputStream input = this.getClass().getClassLoader().getResourceAsStream(ManifestFile.DEFAULT_FILE)) {
this.manifest = new ManifestFile(this.domEngines.forFile(ManifestFile.DEFAULT_FILE).read(input));
}
this.eventBus = new EventBus(this);
this.console = new ConsoleSender(this);
this.commands = new BukkitCommands(this, this.getName());
this.commands.setPrefix(BukkitCommands.BUKKIT_COMMAND_PREFIX);
this.settings = new Settings(this);
this.reloadConfig();
if (!this.getSettings().isEnabled()) {
this.getLogger().log(Level.INFO, this.getName() + " isn't enabled in the settings file, skipped enabling...");
return;
}
this.domPreprocessor.install(new Include(this.domEngines, this.domPreprocessor, this.settings.getIncludeRepository()));
this.getEventBus().publish(new PluginStartEvent(this));
this.loadServer();
try {
this.loadEnvironment();
this.getEnvironment().onEnable();
} catch (DOMException ex) {
this.getLogger().log(Level.SEVERE, "Could not enable the environment: " + ex.toString());
return;
}
this.loadCommands();
this.loadModules();
this.loadMaps();
this.loadTasks();
this.loadWindows();
this.loadGames();
this.tickableTask = this.getServer().getScheduler().runTaskTimer(this, this, 1L, 1L);
this.getEventBus().publish(new PluginReadyEvent(this));
// begin the plugin logic
this.getServer().getScheduler().runTaskLater(this, () -> {
World defaultWorld = this.getServer().getWorlds().get(0);
Vector spawn = this.getSettings().getSpawn();
defaultWorld.setSpawnLocation(spawn.getBlockX(), spawn.getBlockY(), spawn.getBlockZ());
if (this.beginLogic()) {
this.getEventBus().publish(new PluginFreshEvent(this));
this.getLogger().info(getName() + " is fresh and ready to use.");
} else {
this.getLogger().severe("Could not start - see logs above. Shutting down the server...");
this.getServer().shutdown();
}
}, Time.ZERO.toTicks());
}
Aggregations