Files
src
pom.xml
Code
10 786
src/main/java/com/kodari/disneyland/DisneylandPlugin.java
package com.kodari.disneyland;
import com.kodari.disneyland.command.DisneylandCommand;
import com.kodari.disneyland.listener.DisneylandListener;
import com.kodari.disneyland.manager.AmbientSoundTask;
import com.kodari.disneyland.manager.BuildManager;
import com.kodari.disneyland.manager.QuestManager;
import com.kodari.disneyland.manager.TeleportManager;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.plugin.java.JavaPlugin;
public final class DisneylandPlugin extends JavaPlugin {
private BuildManager buildManager;
private TeleportManager teleportManager;
private QuestManager questManager;
private Location parkOrigin;
@Override
public void onEnable() {
saveDefaultConfig();
this.buildManager = new BuildManager(this);
this.teleportManager = new TeleportManager(this);
this.questManager = new QuestManager(this);
this.parkOrigin = loadParkOrigin();
if (this.parkOrigin != null) {
this.teleportManager.setParkOrigin(this.parkOrigin);
this.questManager.spawnGuides(this.parkOrigin);
}
DisneylandListener listener = new DisneylandListener(this);
Bukkit.getPluginManager().registerEvents(listener, this);
DisneylandCommand command = new DisneylandCommand(this);
if (getCommand("disneyland") != null) {
getCommand("disneyland").setExecutor(command);
getCommand("disneyland").setTabCompleter(command);
}
if (getConfig().getBoolean("ambient-sounds", true)) {
Bukkit.getScheduler().runTaskTimer(this, new AmbientSoundTask(this), 200L, 360L);
}
}
public void setParkOrigin(Location origin) {
this.parkOrigin = origin.clone();
getConfig().set("park.world", origin.getWorld().getName());
getConfig().set("park.x", origin.getBlockX());
getConfig().set("park.y", origin.getBlockY());
getConfig().set("park.z", origin.getBlockZ());
saveConfig();
}
private Location loadParkOrigin() {
String worldName = getConfig().getString("park.world", "");
if (worldName.isEmpty()) {
return null;
}
World world = Bukkit.getWorld(worldName);
if (world == null) {
getLogger().warning("The saved park world '" + worldName + "' is not loaded.");
return null;
}
return new Location(world, getConfig().getInt("park.x"), getConfig().getInt("park.y"), getConfig().getInt("park.z"));
}
public BuildManager getBuildManager() {
return buildManager;
}
public TeleportManager getTeleportManager() {
return teleportManager;
}
public QuestManager getQuestManager() {
return questManager;
}
public Location getParkOrigin() {
return parkOrigin == null ? null : parkOrigin.clone();
}
}