2012-01-09 20:00:13 +01:00
|
|
|
package com.gmail.nossr50;
|
|
|
|
|
|
|
|
import com.gmail.nossr50.datatypes.PlayerProfile;
|
|
|
|
import com.gmail.nossr50.commands.skills.*;
|
|
|
|
import com.gmail.nossr50.commands.spout.*;
|
|
|
|
import com.gmail.nossr50.commands.mc.*;
|
|
|
|
import com.gmail.nossr50.commands.party.*;
|
|
|
|
import com.gmail.nossr50.commands.general.*;
|
2012-05-05 19:51:54 +02:00
|
|
|
import com.gmail.nossr50.config.Config;
|
|
|
|
import com.gmail.nossr50.config.LoadTreasures;
|
2012-05-05 19:02:36 +02:00
|
|
|
import com.gmail.nossr50.config.mods.LoadCustomTools;
|
2012-01-30 16:09:45 +01:00
|
|
|
import com.gmail.nossr50.runnables.*;
|
2012-04-27 11:47:11 +02:00
|
|
|
import com.gmail.nossr50.util.Database;
|
|
|
|
import com.gmail.nossr50.util.Leaderboard;
|
|
|
|
import com.gmail.nossr50.util.Metrics;
|
|
|
|
import com.gmail.nossr50.util.Users;
|
2012-05-08 04:38:22 +02:00
|
|
|
import com.gmail.nossr50.util.blockmeta.ChunkletManager;
|
2012-05-15 07:43:34 +02:00
|
|
|
import com.gmail.nossr50.util.blockmeta.ChunkletManagerFactory;
|
2012-04-26 19:42:09 +02:00
|
|
|
import com.gmail.nossr50.listeners.BlockListener;
|
|
|
|
import com.gmail.nossr50.listeners.EntityListener;
|
2012-04-30 15:43:12 +02:00
|
|
|
import com.gmail.nossr50.listeners.HardcoreListener;
|
2012-04-26 19:42:09 +02:00
|
|
|
import com.gmail.nossr50.listeners.PlayerListener;
|
2012-05-08 04:38:22 +02:00
|
|
|
import com.gmail.nossr50.listeners.WorldListener;
|
2012-04-27 11:47:11 +02:00
|
|
|
import com.gmail.nossr50.locale.LocaleLoader;
|
2012-01-09 20:00:13 +01:00
|
|
|
|
2012-05-01 00:48:59 +02:00
|
|
|
import net.shatteredlands.shatt.backup.ZipLibrary;
|
|
|
|
|
2012-01-09 20:00:13 +01:00
|
|
|
import java.io.File;
|
|
|
|
import java.io.IOException;
|
2012-02-29 05:28:14 +01:00
|
|
|
import java.io.InputStream;
|
2012-01-09 20:00:13 +01:00
|
|
|
import java.util.HashMap;
|
|
|
|
|
2012-04-04 16:34:35 +02:00
|
|
|
import org.bukkit.OfflinePlayer;
|
2012-01-09 20:00:13 +01:00
|
|
|
import org.bukkit.plugin.PluginDescriptionFile;
|
|
|
|
import org.bukkit.plugin.java.JavaPlugin;
|
|
|
|
import org.bukkit.plugin.PluginManager;
|
2012-03-18 21:59:35 +01:00
|
|
|
import org.bukkit.scheduler.BukkitScheduler;
|
2012-02-29 05:28:14 +01:00
|
|
|
import org.bukkit.configuration.file.FileConfiguration;
|
|
|
|
import org.bukkit.configuration.file.YamlConfiguration;
|
2012-01-09 20:00:13 +01:00
|
|
|
import org.bukkit.entity.Player;
|
|
|
|
|
2012-03-08 22:17:57 +01:00
|
|
|
public class mcMMO extends JavaPlugin {
|
|
|
|
|
2012-04-26 19:42:09 +02:00
|
|
|
private final PlayerListener playerListener = new PlayerListener(this);
|
|
|
|
private final BlockListener blockListener = new BlockListener(this);
|
|
|
|
private final EntityListener entityListener = new EntityListener(this);
|
2012-05-08 04:38:22 +02:00
|
|
|
private final WorldListener worldListener = new WorldListener();
|
2012-04-30 15:43:12 +02:00
|
|
|
private final HardcoreListener hardcoreListener = new HardcoreListener();
|
2012-03-08 22:17:57 +01:00
|
|
|
|
2012-04-21 20:05:39 +02:00
|
|
|
public HashMap<String, String> aliasMap = new HashMap<String, String>(); //Alias - Command
|
2012-03-20 23:36:47 +01:00
|
|
|
public HashMap<Integer, Player> tntTracker = new HashMap<Integer, Player>();
|
2012-03-08 22:17:57 +01:00
|
|
|
|
2012-04-21 20:05:39 +02:00
|
|
|
public static File versionFile;
|
|
|
|
public static Database database;
|
2012-04-21 00:09:50 +02:00
|
|
|
public static mcMMO p;
|
2012-03-08 22:17:57 +01:00
|
|
|
|
2012-05-15 07:43:34 +02:00
|
|
|
public static ChunkletManager placeStore;
|
2012-05-08 04:38:22 +02:00
|
|
|
|
2012-05-05 19:02:36 +02:00
|
|
|
/* Jar Stuff */
|
2012-05-06 23:51:25 +02:00
|
|
|
public File mcmmo;
|
2012-05-05 19:20:26 +02:00
|
|
|
|
2012-04-21 20:05:39 +02:00
|
|
|
//File Paths
|
2012-05-09 15:58:11 +02:00
|
|
|
public String mainDirectory, flatFileDirectory, usersFile, leaderboardDirectory, modDirectory;
|
2012-04-21 20:05:39 +02:00
|
|
|
|
2012-03-08 22:17:57 +01:00
|
|
|
/**
|
|
|
|
* Things to be run when the plugin is enabled.
|
|
|
|
*/
|
|
|
|
public void onEnable() {
|
2012-04-21 00:09:50 +02:00
|
|
|
p = this;
|
2012-05-06 23:51:25 +02:00
|
|
|
setupFilePaths();
|
2012-05-09 15:58:11 +02:00
|
|
|
|
|
|
|
//Force the loading of config files
|
|
|
|
Config configInstance = Config.getInstance();
|
|
|
|
LoadTreasures.getInstance();
|
2012-05-05 19:02:36 +02:00
|
|
|
|
|
|
|
if (configInstance.getToolModsEnabled()) {
|
|
|
|
LoadCustomTools.getInstance().load();
|
|
|
|
}
|
2012-05-05 19:51:54 +02:00
|
|
|
|
|
|
|
if (!configInstance.getUseMySQL()) {
|
2012-04-21 20:05:39 +02:00
|
|
|
Users.loadUsers();
|
2012-03-08 22:17:57 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
PluginManager pm = getServer().getPluginManager();
|
|
|
|
|
|
|
|
//Register events
|
|
|
|
pm.registerEvents(playerListener, this);
|
|
|
|
pm.registerEvents(blockListener, this);
|
|
|
|
pm.registerEvents(entityListener, this);
|
2012-05-08 04:38:22 +02:00
|
|
|
pm.registerEvents(worldListener, this);
|
2012-05-04 20:04:42 +02:00
|
|
|
|
2012-05-05 19:02:36 +02:00
|
|
|
if (configInstance.getHardcoreEnabled()) {
|
2012-05-01 10:43:04 +02:00
|
|
|
pm.registerEvents(hardcoreListener, this);
|
|
|
|
}
|
2012-03-08 22:17:57 +01:00
|
|
|
|
2012-05-04 20:04:42 +02:00
|
|
|
PluginDescriptionFile pdfFile = getDescription();
|
2012-03-08 22:17:57 +01:00
|
|
|
|
|
|
|
//Setup the leaderboards
|
2012-05-05 19:02:36 +02:00
|
|
|
if (configInstance.getUseMySQL()) {
|
2012-03-08 22:17:57 +01:00
|
|
|
database = new Database(this);
|
|
|
|
database.createStructure();
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
Leaderboard.makeLeaderboards();
|
|
|
|
}
|
|
|
|
|
|
|
|
for (Player player : getServer().getOnlinePlayers()) {
|
|
|
|
Users.addUser(player); //In case of reload add all users back into PlayerProfile
|
|
|
|
}
|
|
|
|
|
|
|
|
System.out.println(pdfFile.getName() + " version " + pdfFile.getVersion() + " is enabled!" );
|
|
|
|
|
2012-03-18 21:59:35 +01:00
|
|
|
BukkitScheduler scheduler = getServer().getScheduler();
|
2012-03-08 22:17:57 +01:00
|
|
|
|
2012-04-21 20:05:39 +02:00
|
|
|
//Schedule Spout Activation 1 second after start-up
|
|
|
|
scheduler.scheduleSyncDelayedTask(this, new SpoutStart(this), 20);
|
2012-03-18 21:59:35 +01:00
|
|
|
//Periodic save timer (Saves every 10 minutes)
|
2012-05-05 19:02:36 +02:00
|
|
|
scheduler.scheduleSyncRepeatingTask(this, new SaveTimer(this), 0, configInstance.getSaveInterval() * 1200);
|
2012-03-18 21:59:35 +01:00
|
|
|
//Regen & Cooldown timer (Runs every second)
|
2012-04-27 11:47:11 +02:00
|
|
|
scheduler.scheduleSyncRepeatingTask(this, new SkillMonitor(this), 0, 20);
|
2012-03-18 21:59:35 +01:00
|
|
|
//Bleed timer (Runs every two seconds)
|
2012-04-28 06:14:19 +02:00
|
|
|
scheduler.scheduleSyncRepeatingTask(this, new BleedTimer(), 0, 40);
|
2012-03-08 22:17:57 +01:00
|
|
|
|
|
|
|
registerCommands();
|
|
|
|
|
2012-05-05 19:02:36 +02:00
|
|
|
if (configInstance.getStatsTrackingEnabled()) {
|
2012-04-27 03:41:30 +02:00
|
|
|
try {
|
2012-05-01 01:32:50 +02:00
|
|
|
Metrics metrics = new Metrics(this);
|
|
|
|
metrics.start();
|
2012-05-04 20:04:42 +02:00
|
|
|
}
|
|
|
|
catch (IOException e) {
|
2012-05-01 01:32:50 +02:00
|
|
|
System.out.println("Failed to submit stats.");
|
2012-04-27 03:41:30 +02:00
|
|
|
}
|
2012-03-08 22:17:57 +01:00
|
|
|
}
|
2012-05-15 07:43:34 +02:00
|
|
|
|
|
|
|
// Get our ChunkletManager
|
|
|
|
placeStore = ChunkletManagerFactory.getChunkletManager();
|
2012-03-08 22:17:57 +01:00
|
|
|
}
|
2012-05-06 23:51:25 +02:00
|
|
|
|
|
|
|
public void setupFilePaths() {
|
|
|
|
mcmmo = getFile();
|
|
|
|
mainDirectory = getDataFolder().getPath() + File.separator;
|
|
|
|
flatFileDirectory = mainDirectory + "FlatFileStuff" + File.separator;
|
|
|
|
usersFile = flatFileDirectory + "mcmmo.users";
|
|
|
|
leaderboardDirectory = flatFileDirectory + "Leaderboards" + File.separator;
|
|
|
|
modDirectory = mainDirectory + "ModConfigs" + File.separator;
|
|
|
|
}
|
2012-03-08 22:17:57 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Get profile of the player.
|
|
|
|
* </br>
|
|
|
|
* This function is designed for API usage.
|
|
|
|
*
|
|
|
|
* @param player Player whose profile to get
|
|
|
|
* @return the PlayerProfile object
|
|
|
|
*/
|
2012-03-31 21:39:09 +02:00
|
|
|
public PlayerProfile getPlayerProfile(Player player) {
|
2012-03-08 22:17:57 +01:00
|
|
|
return Users.getProfile(player);
|
|
|
|
}
|
|
|
|
|
2012-04-04 16:34:35 +02:00
|
|
|
/**
|
|
|
|
* Get profile of the player by name.
|
|
|
|
* </br>
|
|
|
|
* This function is designed for API usage.
|
|
|
|
*
|
2012-04-26 04:07:01 +02:00
|
|
|
* @param playerName Name of player whose profile to get
|
2012-04-04 16:34:35 +02:00
|
|
|
* @return the PlayerProfile object
|
|
|
|
*/
|
|
|
|
public PlayerProfile getPlayerProfileByName(String playerName) {
|
|
|
|
return Users.getProfileByName(playerName);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get profile of the offline player.
|
|
|
|
* </br>
|
|
|
|
* This function is designed for API usage.
|
|
|
|
*
|
|
|
|
* @param player Offline player whose profile to get
|
|
|
|
* @return the PlayerProfile object
|
|
|
|
*/
|
|
|
|
public PlayerProfile getOfflinePlayerProfile(OfflinePlayer player) {
|
|
|
|
return Users.getProfile(player);
|
|
|
|
}
|
|
|
|
|
2012-03-08 22:17:57 +01:00
|
|
|
/**
|
|
|
|
* Things to be run when the plugin is disabled.
|
|
|
|
*/
|
|
|
|
public void onDisable() {
|
|
|
|
//Make sure to save player information if the server shuts down
|
2012-03-22 20:59:26 +01:00
|
|
|
for (PlayerProfile x : Users.getProfiles().values()) {
|
|
|
|
x.save();
|
2012-03-08 22:17:57 +01:00
|
|
|
}
|
2012-03-08 22:55:43 +01:00
|
|
|
|
2012-05-04 20:04:42 +02:00
|
|
|
getServer().getScheduler().cancelTasks(this); //This removes our tasks
|
2012-05-01 01:32:50 +02:00
|
|
|
|
2012-05-08 04:38:22 +02:00
|
|
|
//Save our metadata
|
|
|
|
placeStore.saveAll();
|
|
|
|
|
|
|
|
//Cleanup empty metadata stores
|
|
|
|
placeStore.cleanUp();
|
|
|
|
|
2012-05-01 00:48:59 +02:00
|
|
|
//Remove other tasks BEFORE starting the Backup, or we just cancel it straight away.
|
2012-05-01 01:32:50 +02:00
|
|
|
try {
|
|
|
|
ZipLibrary.mcMMObackup();
|
2012-05-04 20:04:42 +02:00
|
|
|
}
|
|
|
|
catch (IOException e) {
|
2012-05-01 07:25:13 +02:00
|
|
|
getLogger().severe(e.toString());
|
2012-05-01 01:32:50 +02:00
|
|
|
}
|
|
|
|
|
2012-03-08 22:17:57 +01:00
|
|
|
System.out.println("mcMMO was disabled."); //How informative!
|
|
|
|
}
|
2012-03-08 22:55:43 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Register the commands.
|
|
|
|
*/
|
2012-03-08 22:17:57 +01:00
|
|
|
private void registerCommands() {
|
|
|
|
//Register aliases with the aliasmap (used in the playercommandpreprocessevent to ugly alias them to actual commands)
|
|
|
|
//Skills commands
|
2012-04-27 11:47:11 +02:00
|
|
|
aliasMap.put(LocaleLoader.getString("Acrobatics.SkillName").toLowerCase(), "acrobatics");
|
|
|
|
aliasMap.put(LocaleLoader.getString("Archery.SkillName").toLowerCase(), "archery");
|
|
|
|
aliasMap.put(LocaleLoader.getString("Axes.SkillName").toLowerCase(), "axes");
|
|
|
|
aliasMap.put(LocaleLoader.getString("Excavation.SkillName").toLowerCase(), "excavation");
|
|
|
|
aliasMap.put(LocaleLoader.getString("Fishing.SkillName").toLowerCase(), "fishing");
|
|
|
|
aliasMap.put(LocaleLoader.getString("Herbalism.SkillName").toLowerCase(), "herbalism");
|
|
|
|
aliasMap.put(LocaleLoader.getString("Mining.SkillName").toLowerCase(), "mining");
|
|
|
|
aliasMap.put(LocaleLoader.getString("Repair.SkillName").toLowerCase(), "repair");
|
|
|
|
aliasMap.put(LocaleLoader.getString("Swords.SkillName").toLowerCase(), "swords");
|
|
|
|
aliasMap.put(LocaleLoader.getString("Taming.SkillName").toLowerCase(), "taming");
|
|
|
|
aliasMap.put(LocaleLoader.getString("Unarmed.SkillName").toLowerCase(), "unarmed");
|
2012-05-09 13:06:40 +02:00
|
|
|
aliasMap.put(LocaleLoader.getString("Woodcutting.SkillName").toLowerCase(), "woodcutting");
|
2012-03-08 22:55:43 +01:00
|
|
|
|
2012-03-08 22:17:57 +01:00
|
|
|
//Register commands
|
|
|
|
//Skills commands
|
|
|
|
getCommand("acrobatics").setExecutor(new AcrobaticsCommand());
|
|
|
|
getCommand("archery").setExecutor(new ArcheryCommand());
|
|
|
|
getCommand("axes").setExecutor(new AxesCommand());
|
|
|
|
getCommand("excavation").setExecutor(new ExcavationCommand());
|
|
|
|
getCommand("fishing").setExecutor(new FishingCommand());
|
|
|
|
getCommand("herbalism").setExecutor(new HerbalismCommand());
|
|
|
|
getCommand("mining").setExecutor(new MiningCommand());
|
|
|
|
getCommand("repair").setExecutor(new RepairCommand());
|
|
|
|
getCommand("swords").setExecutor(new SwordsCommand());
|
|
|
|
getCommand("taming").setExecutor(new TamingCommand());
|
|
|
|
getCommand("unarmed").setExecutor(new UnarmedCommand());
|
|
|
|
getCommand("woodcutting").setExecutor(new WoodcuttingCommand());
|
2012-03-08 22:55:43 +01:00
|
|
|
|
2012-05-09 15:58:11 +02:00
|
|
|
Config configInstance = Config.getInstance();
|
|
|
|
|
2012-03-08 22:55:43 +01:00
|
|
|
//mc* commands
|
2012-05-05 19:02:36 +02:00
|
|
|
if (configInstance.getCommandMCRemoveEnabled()) {
|
2012-04-21 00:09:50 +02:00
|
|
|
getCommand("mcremove").setExecutor(new McremoveCommand(this));
|
2012-03-08 22:55:43 +01:00
|
|
|
}
|
|
|
|
|
2012-05-05 19:02:36 +02:00
|
|
|
if (configInstance.getCommandMCAbilityEnabled()) {
|
2012-03-08 22:55:43 +01:00
|
|
|
getCommand("mcability").setExecutor(new McabilityCommand());
|
|
|
|
}
|
|
|
|
|
2012-05-05 19:02:36 +02:00
|
|
|
if (configInstance.getCommandMCCEnabled()) {
|
2012-03-08 22:55:43 +01:00
|
|
|
getCommand("mcc").setExecutor(new MccCommand());
|
|
|
|
}
|
|
|
|
|
2012-05-05 19:02:36 +02:00
|
|
|
if (configInstance.getCommandMCGodEnabled()) {
|
2012-03-08 22:55:43 +01:00
|
|
|
getCommand("mcgod").setExecutor(new McgodCommand());
|
|
|
|
}
|
|
|
|
|
2012-05-05 19:02:36 +02:00
|
|
|
if (configInstance.getCommandmcMMOEnabled()) {
|
2012-03-08 22:55:43 +01:00
|
|
|
getCommand("mcmmo").setExecutor(new McmmoCommand());
|
|
|
|
}
|
|
|
|
|
2012-05-05 19:02:36 +02:00
|
|
|
if (configInstance.getCommandMCRefreshEnabled()) {
|
2012-03-08 22:55:43 +01:00
|
|
|
getCommand("mcrefresh").setExecutor(new McrefreshCommand(this));
|
|
|
|
}
|
|
|
|
|
2012-05-05 19:02:36 +02:00
|
|
|
if (configInstance.getCommandMCTopEnabled()) {
|
2012-03-08 22:55:43 +01:00
|
|
|
getCommand("mctop").setExecutor(new MctopCommand());
|
|
|
|
}
|
|
|
|
|
2012-05-05 19:02:36 +02:00
|
|
|
if (configInstance.getCommandMCStatsEnabled()) {
|
2012-03-08 22:55:43 +01:00
|
|
|
getCommand("mcstats").setExecutor(new McstatsCommand());
|
|
|
|
}
|
|
|
|
|
2012-03-08 22:17:57 +01:00
|
|
|
//Party commands
|
2012-05-05 19:02:36 +02:00
|
|
|
if (configInstance.getCommandAcceptEnabled()) {
|
2012-04-21 00:09:50 +02:00
|
|
|
getCommand("accept").setExecutor(new AcceptCommand(this));
|
2012-03-08 22:55:43 +01:00
|
|
|
}
|
|
|
|
|
2012-05-05 19:02:36 +02:00
|
|
|
if (configInstance.getCommandAdminChatAEnabled()) {
|
2012-04-21 00:09:50 +02:00
|
|
|
getCommand("a").setExecutor(new ACommand(this));
|
2012-03-08 22:55:43 +01:00
|
|
|
}
|
|
|
|
|
2012-05-05 19:02:36 +02:00
|
|
|
if (configInstance.getCommandInviteEnabled()) {
|
2012-03-08 22:55:43 +01:00
|
|
|
getCommand("invite").setExecutor(new InviteCommand(this));
|
|
|
|
}
|
|
|
|
|
2012-05-05 19:02:36 +02:00
|
|
|
if (configInstance.getCommandPartyEnabled()) {
|
2012-04-21 00:09:50 +02:00
|
|
|
getCommand("party").setExecutor(new PartyCommand(this));
|
2012-03-08 22:55:43 +01:00
|
|
|
}
|
|
|
|
|
2012-05-05 19:02:36 +02:00
|
|
|
if (configInstance.getCommandPartyChatPEnabled()) {
|
2012-04-21 00:09:50 +02:00
|
|
|
getCommand("p").setExecutor(new PCommand(this));
|
2012-03-08 22:55:43 +01:00
|
|
|
}
|
|
|
|
|
2012-05-05 19:02:36 +02:00
|
|
|
if (configInstance.getCommandPTPEnabled()) {
|
2012-03-08 22:55:43 +01:00
|
|
|
getCommand("ptp").setExecutor(new PtpCommand(this));
|
|
|
|
}
|
|
|
|
|
2012-03-08 22:17:57 +01:00
|
|
|
//Other commands
|
2012-05-05 19:02:36 +02:00
|
|
|
if (configInstance.getCommandAddXPEnabled()) {
|
2012-03-08 22:55:43 +01:00
|
|
|
getCommand("addxp").setExecutor(new AddxpCommand(this));
|
|
|
|
}
|
|
|
|
|
2012-05-05 19:02:36 +02:00
|
|
|
if (configInstance.getCommandAddLevelsEnabled()) {
|
2012-03-08 22:55:43 +01:00
|
|
|
getCommand("addlevels").setExecutor(new AddlevelsCommand(this));
|
|
|
|
}
|
|
|
|
|
2012-05-05 19:02:36 +02:00
|
|
|
if (configInstance.getCommandMmoeditEnabled()) {
|
2012-04-04 16:34:35 +02:00
|
|
|
getCommand("mmoedit").setExecutor(new MmoeditCommand(this));
|
2012-03-08 22:55:43 +01:00
|
|
|
}
|
|
|
|
|
2012-05-05 19:02:36 +02:00
|
|
|
if (configInstance.getCommandInspectEnabled()) {
|
2012-03-08 22:55:43 +01:00
|
|
|
getCommand("inspect").setExecutor(new InspectCommand(this));
|
|
|
|
}
|
|
|
|
|
2012-05-05 19:02:36 +02:00
|
|
|
if (configInstance.getCommandXPRateEnabled()) {
|
2012-04-21 00:09:50 +02:00
|
|
|
getCommand("xprate").setExecutor(new XprateCommand(this));
|
2012-03-08 22:55:43 +01:00
|
|
|
}
|
|
|
|
|
2012-04-21 00:09:50 +02:00
|
|
|
getCommand("mmoupdate").setExecutor(new MmoupdateCommand(this));
|
2012-03-08 22:55:43 +01:00
|
|
|
|
2012-03-08 22:17:57 +01:00
|
|
|
//Spout commands
|
2012-05-05 19:02:36 +02:00
|
|
|
if (configInstance.getCommandXPLockEnabled()) {
|
2012-03-08 22:55:43 +01:00
|
|
|
getCommand("xplock").setExecutor(new XplockCommand());
|
|
|
|
}
|
|
|
|
|
2012-04-21 00:09:50 +02:00
|
|
|
getCommand("mchud").setExecutor(new MchudCommand(this));
|
2012-03-08 22:17:57 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2012-05-04 20:04:42 +02:00
|
|
|
* Boilerplate Custom Config Stuff (Treasures)
|
2012-03-08 22:17:57 +01:00
|
|
|
*/
|
2012-03-08 22:55:43 +01:00
|
|
|
|
2012-03-08 22:17:57 +01:00
|
|
|
private FileConfiguration treasuresConfig = null;
|
|
|
|
private File treasuresConfigFile = null;
|
2012-03-08 22:55:43 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Reload the Treasures.yml file.
|
|
|
|
*/
|
2012-03-08 22:17:57 +01:00
|
|
|
public void reloadTreasuresConfig() {
|
|
|
|
if (treasuresConfigFile == null) {
|
2012-03-08 22:55:43 +01:00
|
|
|
treasuresConfigFile = new File(getDataFolder(), "treasures.yml");
|
2012-03-08 22:17:57 +01:00
|
|
|
}
|
2012-03-08 22:55:43 +01:00
|
|
|
|
2012-03-08 22:17:57 +01:00
|
|
|
treasuresConfig = YamlConfiguration.loadConfiguration(treasuresConfigFile);
|
2012-03-08 22:55:43 +01:00
|
|
|
InputStream defConfigStream = getResource("treasures.yml"); // Look for defaults in the jar
|
|
|
|
|
2012-03-08 22:17:57 +01:00
|
|
|
if (defConfigStream != null) {
|
|
|
|
YamlConfiguration defConfig = YamlConfiguration.loadConfiguration(defConfigStream);
|
|
|
|
treasuresConfig.setDefaults(defConfig);
|
|
|
|
}
|
|
|
|
}
|
2012-03-08 22:55:43 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the Treasures config information.
|
|
|
|
*
|
|
|
|
* @return the configuration object for treasures.yml
|
|
|
|
*/
|
2012-03-08 22:17:57 +01:00
|
|
|
public FileConfiguration getTreasuresConfig() {
|
|
|
|
if (treasuresConfig == null) {
|
|
|
|
reloadTreasuresConfig();
|
|
|
|
}
|
2012-03-08 22:55:43 +01:00
|
|
|
|
2012-03-08 22:17:57 +01:00
|
|
|
return treasuresConfig;
|
|
|
|
}
|
2012-03-08 22:55:43 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Save the Treasures config informtion.
|
|
|
|
*/
|
2012-03-08 22:17:57 +01:00
|
|
|
public void saveTreasuresConfig() {
|
|
|
|
if (treasuresConfig == null || treasuresConfigFile == null) {
|
2012-03-08 22:55:43 +01:00
|
|
|
return;
|
2012-03-08 22:17:57 +01:00
|
|
|
}
|
2012-03-08 22:55:43 +01:00
|
|
|
|
2012-03-08 22:17:57 +01:00
|
|
|
try {
|
|
|
|
treasuresConfig.save(treasuresConfigFile);
|
2012-03-08 22:55:43 +01:00
|
|
|
}
|
|
|
|
catch (IOException ex) {
|
2012-05-04 20:04:42 +02:00
|
|
|
getLogger().severe("Could not save config to " + treasuresConfigFile + ex.toString());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Boilerplate Custom Config Stuff (Tools)
|
|
|
|
*/
|
|
|
|
|
|
|
|
private FileConfiguration toolsConfig = null;
|
|
|
|
private File toolsConfigFile = null;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Reload the Tools.yml file.
|
|
|
|
*/
|
|
|
|
public void reloadToolsConfig() {
|
|
|
|
if (toolsConfigFile == null) {
|
|
|
|
toolsConfigFile = new File(modDirectory, "tools.yml");
|
|
|
|
}
|
|
|
|
|
|
|
|
toolsConfig = YamlConfiguration.loadConfiguration(toolsConfigFile);
|
|
|
|
InputStream defConfigStream = getResource("tools.yml"); // Look for defaults in the jar
|
|
|
|
|
|
|
|
if (defConfigStream != null) {
|
|
|
|
YamlConfiguration defConfig = YamlConfiguration.loadConfiguration(defConfigStream);
|
|
|
|
toolsConfig.setDefaults(defConfig);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the Tools config information.
|
|
|
|
*
|
|
|
|
* @return the configuration object for tools.yml
|
|
|
|
*/
|
|
|
|
public FileConfiguration getToolsConfig() {
|
|
|
|
if (toolsConfig == null) {
|
|
|
|
reloadToolsConfig();
|
|
|
|
}
|
|
|
|
|
|
|
|
return toolsConfig;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Save the Tools config informtion.
|
|
|
|
*/
|
|
|
|
public void saveToolsConfig() {
|
|
|
|
if (toolsConfig == null || toolsConfigFile == null) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
try {
|
|
|
|
toolsConfig.save(toolsConfigFile);
|
|
|
|
}
|
|
|
|
catch (IOException ex) {
|
|
|
|
getLogger().severe("Could not save config to " + toolsConfigFile + ex.toString());
|
2012-03-08 22:17:57 +01:00
|
|
|
}
|
|
|
|
}
|
2012-03-08 22:55:43 +01:00
|
|
|
}
|