Files
SchematicEvent
Code
15 892
SchematicEvent/src/main/java/com/schematicevent/SchematicEventPlugin.java
package com.schematicevent;
import com.schematicevent.command.SchematicEventCommand;
import com.schematicevent.config.ConfigManager;
import com.schematicevent.drop.DropManager;
import com.schematicevent.listener.SchematicProtectionListener;
import com.schematicevent.spawner.ActiveSchematic;
import com.schematicevent.spawner.SchematicSpawner;
import com.schematicevent.spawner.SpawnTask;
import org.bukkit.plugin.java.JavaPlugin;
public class SchematicEventPlugin extends JavaPlugin {
private ConfigManager configManager;
private DropManager dropManager;
private SchematicSpawner schematicSpawner;
private ActiveSchematic activeSchematic;
private SpawnTask spawnTask;
@Override
public void onEnable() {
saveDefaultConfig();
configManager = new ConfigManager(this);
dropManager = new DropManager();
schematicSpawner = new SchematicSpawner(this);
configManager.reload();
getServer().getPluginManager().registerEvents(
new SchematicProtectionListener(this), this);
getCommand("schematicevent").setExecutor(
new SchematicEventCommand(this));
startSpawnTask();
getLogger().info("SchematicEvent enabled!");
}
@Override
public void onDisable() {
if (spawnTask != null) {
spawnTask.cancel();
}
if (activeSchematic != null) {
schematicSpawner.destroySchematic(activeSchematic);
activeSchematic = null;
}
getLogger().info("SchematicEvent disabled!");
}
public void startSpawnTask() {
if (spawnTask != null) {
spawnTask.cancel();
}
spawnTask = new SpawnTask(this);
spawnTask.runTaskTimer(this, 100L,
configManager.getSpawnInterval() * 20L);
}
public ConfigManager getConfigManager() { return configManager; }
public DropManager getDropManager() { return dropManager; }
public SchematicSpawner getSchematicSpawner() { return schematicSpawner; }
public ActiveSchematic getActiveSchematic() { return activeSchematic; }
public void setActiveSchematic(ActiveSchematic active) { this.activeSchematic = active; }
}