2013-03-01 06:52:01 +01:00
|
|
|
package com.gmail.nossr50;
|
|
|
|
|
|
|
|
import java.io.File;
|
|
|
|
import java.io.IOException;
|
|
|
|
import java.util.ArrayList;
|
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
import org.bukkit.entity.Player;
|
|
|
|
import org.bukkit.event.HandlerList;
|
|
|
|
import org.bukkit.metadata.FixedMetadataValue;
|
|
|
|
import org.bukkit.plugin.PluginManager;
|
|
|
|
import org.bukkit.plugin.java.JavaPlugin;
|
|
|
|
|
|
|
|
import com.gmail.nossr50.config.AdvancedConfig;
|
|
|
|
import com.gmail.nossr50.config.Config;
|
|
|
|
import com.gmail.nossr50.config.HiddenConfig;
|
|
|
|
import com.gmail.nossr50.config.mods.CustomArmorConfig;
|
|
|
|
import com.gmail.nossr50.config.mods.CustomBlockConfig;
|
|
|
|
import com.gmail.nossr50.config.mods.CustomEntityConfig;
|
|
|
|
import com.gmail.nossr50.config.mods.CustomToolConfig;
|
|
|
|
import com.gmail.nossr50.config.treasure.TreasureConfig;
|
|
|
|
import com.gmail.nossr50.database.DatabaseManager;
|
2013-06-04 18:14:43 +02:00
|
|
|
import com.gmail.nossr50.database.DatabaseManagerFactory;
|
2013-03-01 06:52:01 +01:00
|
|
|
import com.gmail.nossr50.listeners.BlockListener;
|
|
|
|
import com.gmail.nossr50.listeners.EntityListener;
|
|
|
|
import com.gmail.nossr50.listeners.InventoryListener;
|
|
|
|
import com.gmail.nossr50.listeners.PlayerListener;
|
2013-09-12 04:42:27 +02:00
|
|
|
import com.gmail.nossr50.listeners.ScoreboardsListener;
|
2013-03-28 07:17:38 +01:00
|
|
|
import com.gmail.nossr50.listeners.SelfListener;
|
2013-03-01 06:52:01 +01:00
|
|
|
import com.gmail.nossr50.listeners.WorldListener;
|
|
|
|
import com.gmail.nossr50.locale.LocaleLoader;
|
2013-09-22 20:33:01 +02:00
|
|
|
import com.gmail.nossr50.metrics.MetricsManager;
|
2013-03-01 06:52:01 +01:00
|
|
|
import com.gmail.nossr50.party.PartyManager;
|
|
|
|
import com.gmail.nossr50.runnables.SaveTimerTask;
|
2013-11-01 16:07:56 +01:00
|
|
|
import com.gmail.nossr50.runnables.backups.CleanBackupsTask;
|
2013-03-01 06:52:01 +01:00
|
|
|
import com.gmail.nossr50.runnables.database.UserPurgeTask;
|
|
|
|
import com.gmail.nossr50.runnables.party.PartyAutoKickTask;
|
2013-09-12 04:42:27 +02:00
|
|
|
import com.gmail.nossr50.runnables.player.PowerLevelUpdatingTask;
|
2013-03-01 06:52:01 +01:00
|
|
|
import com.gmail.nossr50.runnables.skills.BleedTimerTask;
|
|
|
|
import com.gmail.nossr50.skills.child.ChildConfig;
|
|
|
|
import com.gmail.nossr50.skills.repair.config.RepairConfigManager;
|
2013-10-07 16:23:04 +02:00
|
|
|
import com.gmail.nossr50.skills.repair.repairables.Repairable;
|
|
|
|
import com.gmail.nossr50.skills.repair.repairables.RepairableManager;
|
2013-10-09 06:10:32 +02:00
|
|
|
import com.gmail.nossr50.skills.repair.repairables.SimpleRepairableManager;
|
2013-03-08 21:46:05 +01:00
|
|
|
import com.gmail.nossr50.util.ChimaeraWing;
|
2013-03-01 06:52:01 +01:00
|
|
|
import com.gmail.nossr50.util.LogFilter;
|
2013-06-13 01:26:09 +02:00
|
|
|
import com.gmail.nossr50.util.Misc;
|
2013-03-01 06:52:01 +01:00
|
|
|
import com.gmail.nossr50.util.Permissions;
|
|
|
|
import com.gmail.nossr50.util.blockmeta.chunkmeta.ChunkManager;
|
|
|
|
import com.gmail.nossr50.util.blockmeta.chunkmeta.ChunkManagerFactory;
|
|
|
|
import com.gmail.nossr50.util.commands.CommandRegistrationManager;
|
2013-09-10 15:28:07 +02:00
|
|
|
import com.gmail.nossr50.util.experience.FormulaManager;
|
2013-03-01 06:52:01 +01:00
|
|
|
import com.gmail.nossr50.util.player.UserManager;
|
2013-09-12 04:42:27 +02:00
|
|
|
import com.gmail.nossr50.util.scoreboards.ScoreboardManager;
|
2013-03-01 06:52:01 +01:00
|
|
|
|
2013-10-12 03:02:09 +02:00
|
|
|
import net.gravitydevelopment.updater.mcmmo.Updater;
|
|
|
|
import net.gravitydevelopment.updater.mcmmo.Updater.UpdateResult;
|
|
|
|
import net.gravitydevelopment.updater.mcmmo.Updater.UpdateType;
|
2013-09-10 15:28:07 +02:00
|
|
|
import net.shatteredlands.shatt.backup.ZipLibrary;
|
|
|
|
|
2013-03-01 06:52:01 +01:00
|
|
|
public class mcMMO extends JavaPlugin {
|
2013-04-25 15:27:48 +02:00
|
|
|
/* Managers */
|
2013-04-30 21:07:29 +02:00
|
|
|
private static ChunkManager placeStore;
|
2013-04-25 15:16:42 +02:00
|
|
|
private static RepairableManager repairableManager;
|
2013-04-30 21:07:29 +02:00
|
|
|
private static DatabaseManager databaseManager;
|
2013-05-20 15:38:30 +02:00
|
|
|
private static FormulaManager formulaManager;
|
2013-03-01 06:52:01 +01:00
|
|
|
|
2013-04-25 15:27:48 +02:00
|
|
|
/* File Paths */
|
2013-03-01 06:52:01 +01:00
|
|
|
private static String mainDirectory;
|
|
|
|
private static String flatFileDirectory;
|
|
|
|
private static String usersFile;
|
|
|
|
private static String modDirectory;
|
|
|
|
|
2013-04-25 15:27:48 +02:00
|
|
|
public static mcMMO p;
|
|
|
|
|
|
|
|
// Jar Stuff
|
|
|
|
public static File mcmmo;
|
|
|
|
|
2013-03-01 06:52:01 +01:00
|
|
|
// Update Check
|
2013-04-25 15:27:48 +02:00
|
|
|
private boolean updateAvailable;
|
2013-03-01 06:52:01 +01:00
|
|
|
|
2013-04-30 21:07:29 +02:00
|
|
|
/* Plugin Checks */
|
|
|
|
private static boolean combatTagEnabled;
|
2013-09-29 23:57:13 +02:00
|
|
|
private static boolean healthBarPluginEnabled;
|
2013-10-19 00:27:07 +02:00
|
|
|
private static boolean noCheatPlusPluginEnabled;
|
|
|
|
private static boolean compatNoCheatPlusPluginEnabled;
|
2013-10-04 15:41:01 +02:00
|
|
|
private static boolean mcpcEnabled;
|
2013-03-01 06:52:01 +01:00
|
|
|
|
2013-08-10 19:33:21 +02:00
|
|
|
// Config Validation Check
|
|
|
|
public boolean noErrorsInConfigFiles = true;
|
|
|
|
|
2013-03-01 06:52:01 +01:00
|
|
|
// XP Event Check
|
2013-04-25 15:27:48 +02:00
|
|
|
private boolean xpEventEnabled;
|
2013-03-01 06:52:01 +01:00
|
|
|
|
2013-04-30 21:07:29 +02:00
|
|
|
/* Metadata Values */
|
2013-04-02 14:41:51 +02:00
|
|
|
public final static String entityMetadataKey = "mcMMO: Spawned Entity";
|
|
|
|
public final static String blockMetadataKey = "mcMMO: Piston Tracking";
|
2013-03-08 16:23:21 +01:00
|
|
|
public final static String furnaceMetadataKey = "mcMMO: Tracked Furnace";
|
2013-04-02 14:41:51 +02:00
|
|
|
public final static String tntMetadataKey = "mcMMO: Tracked TNT";
|
2013-10-12 03:30:10 +02:00
|
|
|
public final static String tntsafeMetadataKey = "mcMMO: Safe TNT";
|
2013-04-05 04:11:11 +02:00
|
|
|
public final static String customNameKey = "mcMMO: Custom Name";
|
|
|
|
public final static String customVisibleKey = "mcMMO: Name Visibility";
|
2013-04-17 15:19:50 +02:00
|
|
|
public final static String droppedItemKey = "mcMMO: Tracked Item";
|
2013-05-15 04:43:13 +02:00
|
|
|
public final static String infiniteArrowKey = "mcMMO: Infinite Arrow";
|
2013-05-15 07:19:14 +02:00
|
|
|
public final static String bowForceKey = "mcMMO: Bow Force";
|
2013-05-15 14:35:12 +02:00
|
|
|
public final static String arrowDistanceKey = "mcMMO: Arrow Distance";
|
2013-09-09 18:44:03 +02:00
|
|
|
public final static String customDamageKey = "mcMMO: Custom Damage";
|
2013-04-02 14:41:51 +02:00
|
|
|
|
|
|
|
public static FixedMetadataValue metadataValue;
|
2013-03-01 06:52:01 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Things to be run when the plugin is enabled.
|
|
|
|
*/
|
|
|
|
@Override
|
|
|
|
public void onEnable() {
|
|
|
|
try {
|
|
|
|
p = this;
|
|
|
|
getLogger().setFilter(new LogFilter(this));
|
|
|
|
metadataValue = new FixedMetadataValue(this, true);
|
|
|
|
|
2013-10-31 13:15:19 +01:00
|
|
|
mcpcEnabled = getServer().getName().equals("MCPC+");
|
|
|
|
combatTagEnabled = getServer().getPluginManager().getPlugin("CombatTag") != null;
|
|
|
|
healthBarPluginEnabled = getServer().getPluginManager().getPlugin("HealthBar") != null;
|
|
|
|
noCheatPlusPluginEnabled = getServer().getPluginManager().getPlugin("NoCheatPlus") != null;
|
|
|
|
compatNoCheatPlusPluginEnabled = getServer().getPluginManager().getPlugin("CompatNoCheatPlus") != null;
|
|
|
|
|
2013-03-01 06:52:01 +01:00
|
|
|
setupFilePaths();
|
2013-10-04 15:41:01 +02:00
|
|
|
|
2013-03-01 06:52:01 +01:00
|
|
|
loadConfigFiles();
|
|
|
|
|
2013-08-10 19:33:21 +02:00
|
|
|
if (!noErrorsInConfigFiles) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2013-10-04 15:41:01 +02:00
|
|
|
if (mcpcEnabled) {
|
|
|
|
checkModConfigs();
|
|
|
|
}
|
2013-09-22 14:39:20 +02:00
|
|
|
|
2013-09-29 23:57:13 +02:00
|
|
|
if (healthBarPluginEnabled) {
|
2013-09-22 14:39:20 +02:00
|
|
|
getLogger().info("HealthBar plugin found, mcMMO's healthbars are automatically disabled.");
|
|
|
|
}
|
2013-04-29 06:29:38 +02:00
|
|
|
|
2013-10-19 00:27:07 +02:00
|
|
|
if (noCheatPlusPluginEnabled && !compatNoCheatPlusPluginEnabled) {
|
|
|
|
getLogger().warning("NoCheatPlus plugin found, but CompatNoCheatPlus was not found!");
|
|
|
|
getLogger().warning("mcMMO will not work properly alongside NoCheatPlus without CompatNoCheatPlus");
|
|
|
|
}
|
|
|
|
|
2013-06-04 18:14:43 +02:00
|
|
|
databaseManager = DatabaseManagerFactory.getDatabaseManager();
|
2013-03-01 06:52:01 +01:00
|
|
|
|
|
|
|
registerEvents();
|
2013-03-08 21:46:05 +01:00
|
|
|
registerCustomRecipes();
|
2013-03-01 06:52:01 +01:00
|
|
|
|
2013-04-02 19:47:52 +02:00
|
|
|
PartyManager.loadParties();
|
|
|
|
|
2013-08-21 19:18:50 +02:00
|
|
|
formulaManager = new FormulaManager();
|
2013-05-20 15:38:30 +02:00
|
|
|
|
2013-03-01 06:52:01 +01:00
|
|
|
for (Player player : getServer().getOnlinePlayers()) {
|
2013-04-02 14:20:55 +02:00
|
|
|
UserManager.addUser(player); // In case of reload add all users back into UserManager
|
2013-09-12 04:42:27 +02:00
|
|
|
ScoreboardManager.setupPlayer(player);
|
2013-03-01 06:52:01 +01:00
|
|
|
}
|
|
|
|
|
2013-04-13 21:53:00 +02:00
|
|
|
debug("Version " + getDescription().getVersion() + " is enabled!");
|
2013-03-01 06:52:01 +01:00
|
|
|
|
|
|
|
scheduleTasks();
|
2013-04-30 21:07:29 +02:00
|
|
|
CommandRegistrationManager.registerCommands();
|
2013-03-01 06:52:01 +01:00
|
|
|
|
2013-09-22 20:33:01 +02:00
|
|
|
MetricsManager.setup();
|
|
|
|
|
2013-03-01 06:52:01 +01:00
|
|
|
placeStore = ChunkManagerFactory.getChunkManager(); // Get our ChunkletManager
|
|
|
|
|
|
|
|
checkForUpdates();
|
|
|
|
|
|
|
|
if (Config.getInstance().getPTPCommandWorldPermissions()) {
|
|
|
|
Permissions.generateWorldTeleportPermissions();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
catch (Throwable t) {
|
|
|
|
getLogger().severe("There was an error while enabling mcMMO!");
|
|
|
|
|
|
|
|
if (!(t instanceof ExceptionInInitializerError)) {
|
|
|
|
t.printStackTrace();
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
getLogger().info("Please do not replace the mcMMO jar while the server is running.");
|
|
|
|
}
|
|
|
|
|
2013-03-10 20:07:07 +01:00
|
|
|
getServer().getPluginManager().disablePlugin(this);
|
2013-03-01 06:52:01 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Things to be run when the plugin is disabled.
|
|
|
|
*/
|
|
|
|
@Override
|
|
|
|
public void onDisable() {
|
|
|
|
try {
|
2013-04-02 14:29:38 +02:00
|
|
|
UserManager.saveAll(); // Make sure to save player information if the server shuts down
|
|
|
|
PartyManager.saveParties(); // Save our parties
|
2013-09-12 04:42:27 +02:00
|
|
|
ScoreboardManager.teardownAll();
|
2013-05-20 15:38:30 +02:00
|
|
|
formulaManager.saveFormula();
|
2013-04-02 14:29:38 +02:00
|
|
|
placeStore.saveAll(); // Save our metadata
|
|
|
|
placeStore.cleanUp(); // Cleanup empty metadata stores
|
2013-03-01 06:52:01 +01:00
|
|
|
}
|
|
|
|
catch (NullPointerException e) {}
|
|
|
|
|
|
|
|
getServer().getScheduler().cancelTasks(this); // This removes our tasks
|
|
|
|
HandlerList.unregisterAll(this); // Cancel event registrations
|
|
|
|
|
|
|
|
if (Config.getInstance().getBackupsEnabled()) {
|
|
|
|
// Remove other tasks BEFORE starting the Backup, or we just cancel it straight away.
|
|
|
|
try {
|
2013-11-01 16:28:42 +01:00
|
|
|
ZipLibrary.mcMMOBackup();
|
2013-03-01 06:52:01 +01:00
|
|
|
}
|
|
|
|
catch (IOException e) {
|
|
|
|
getLogger().severe(e.toString());
|
|
|
|
}
|
|
|
|
catch (Throwable e) {
|
|
|
|
if (e instanceof NoClassDefFoundError) {
|
|
|
|
getLogger().severe("Backup class not found!");
|
|
|
|
getLogger().info("Please do not replace the mcMMO jar while the server is running.");
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
getLogger().severe(e.toString());
|
|
|
|
}
|
|
|
|
}
|
2013-11-01 16:07:56 +01:00
|
|
|
|
|
|
|
new CleanBackupsTask().runTaskAsynchronously(mcMMO.p);
|
2013-03-01 06:52:01 +01:00
|
|
|
}
|
|
|
|
|
2013-04-13 21:53:00 +02:00
|
|
|
debug("Was disabled."); // How informative!
|
2013-03-01 06:52:01 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public static String getMainDirectory() {
|
|
|
|
return mainDirectory;
|
|
|
|
}
|
|
|
|
|
|
|
|
public static String getFlatFileDirectory() {
|
|
|
|
return flatFileDirectory;
|
|
|
|
}
|
|
|
|
|
|
|
|
public static String getUsersFilePath() {
|
|
|
|
return usersFile;
|
|
|
|
}
|
|
|
|
|
|
|
|
public static String getModDirectory() {
|
|
|
|
return modDirectory;
|
|
|
|
}
|
|
|
|
|
2013-04-25 15:27:48 +02:00
|
|
|
public boolean isUpdateAvailable() {
|
|
|
|
return updateAvailable;
|
|
|
|
}
|
|
|
|
|
2013-03-01 06:52:01 +01:00
|
|
|
public boolean isXPEventEnabled() {
|
|
|
|
return xpEventEnabled;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setXPEventEnabled(boolean enabled) {
|
|
|
|
this.xpEventEnabled = enabled;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void toggleXpEventEnabled() {
|
|
|
|
xpEventEnabled = !xpEventEnabled;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void debug(String message) {
|
|
|
|
getLogger().info("[Debug] " + message);
|
|
|
|
}
|
|
|
|
|
2013-05-20 15:38:30 +02:00
|
|
|
public static FormulaManager getFormulaManager() {
|
|
|
|
return formulaManager;
|
|
|
|
}
|
|
|
|
|
2013-04-25 15:16:42 +02:00
|
|
|
public static ChunkManager getPlaceStore() {
|
|
|
|
return placeStore;
|
|
|
|
}
|
|
|
|
|
2013-06-04 18:14:43 +02:00
|
|
|
public static RepairableManager getRepairableManager() {
|
|
|
|
return repairableManager;
|
|
|
|
}
|
|
|
|
|
2013-04-25 15:16:42 +02:00
|
|
|
public static DatabaseManager getDatabaseManager() {
|
|
|
|
return databaseManager;
|
|
|
|
}
|
|
|
|
|
2013-06-04 18:14:43 +02:00
|
|
|
@Deprecated
|
|
|
|
public static void setDatabaseManager(DatabaseManager databaseManager) {
|
|
|
|
mcMMO.databaseManager = databaseManager;
|
2013-04-25 15:16:42 +02:00
|
|
|
}
|
|
|
|
|
2013-04-30 21:07:29 +02:00
|
|
|
public static boolean isCombatTagEnabled() {
|
|
|
|
return combatTagEnabled;
|
|
|
|
}
|
|
|
|
|
2013-09-29 23:57:13 +02:00
|
|
|
public static boolean isHealthBarPluginEnabled() {
|
|
|
|
return healthBarPluginEnabled;
|
2013-09-22 14:39:20 +02:00
|
|
|
}
|
|
|
|
|
2013-10-04 15:41:01 +02:00
|
|
|
public static boolean isMCPCEnabled() {
|
|
|
|
return mcpcEnabled;
|
|
|
|
}
|
|
|
|
|
2013-03-01 06:52:01 +01:00
|
|
|
/**
|
|
|
|
* Setup the various storage file paths
|
|
|
|
*/
|
|
|
|
private void setupFilePaths() {
|
|
|
|
mcmmo = getFile();
|
|
|
|
mainDirectory = getDataFolder().getPath() + File.separator;
|
2013-10-07 16:33:14 +02:00
|
|
|
flatFileDirectory = mainDirectory + "flatfile" + File.separator;
|
2013-03-01 06:52:01 +01:00
|
|
|
usersFile = flatFileDirectory + "mcmmo.users";
|
2013-10-07 16:32:40 +02:00
|
|
|
modDirectory = mainDirectory + "mods" + File.separator;
|
2013-10-07 16:43:22 +02:00
|
|
|
fixFilePaths();
|
|
|
|
}
|
|
|
|
|
|
|
|
private void fixFilePaths() {
|
|
|
|
File oldFlatfilePath = new File(mainDirectory + "FlatFileStuff" + File.separator);
|
|
|
|
File oldModPath = new File(mainDirectory + "ModConfigs" + File.separator);
|
|
|
|
|
|
|
|
if (oldFlatfilePath.exists()) {
|
|
|
|
oldFlatfilePath.renameTo(new File(flatFileDirectory));
|
|
|
|
}
|
|
|
|
|
|
|
|
if (oldModPath.exists()) {
|
|
|
|
oldModPath.renameTo(new File(modDirectory));
|
|
|
|
}
|
2013-03-01 06:52:01 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
private void checkForUpdates() {
|
2013-06-07 19:55:49 +02:00
|
|
|
if (!Config.getInstance().getUpdateCheckEnabled()) {
|
|
|
|
return;
|
|
|
|
}
|
2013-03-01 06:52:01 +01:00
|
|
|
|
2013-10-12 03:02:09 +02:00
|
|
|
Updater updater = new Updater(this, 31030, mcmmo, UpdateType.NO_DOWNLOAD, false);
|
2013-09-13 06:34:03 +02:00
|
|
|
|
|
|
|
if (updater.getResult() != UpdateResult.UPDATE_AVAILABLE) {
|
2013-09-13 14:11:32 +02:00
|
|
|
this.updateAvailable = false;
|
2013-09-13 06:34:03 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2013-10-12 03:02:09 +02:00
|
|
|
if (updater.getLatestType().equals("beta") && !Config.getInstance().getPreferBeta()) {
|
2013-09-13 14:11:32 +02:00
|
|
|
this.updateAvailable = false;
|
2013-09-13 06:34:03 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2013-09-13 14:11:32 +02:00
|
|
|
this.updateAvailable = true;
|
2013-09-30 11:32:35 +02:00
|
|
|
getLogger().info(LocaleLoader.getString("UpdateChecker.Outdated"));
|
|
|
|
getLogger().info(LocaleLoader.getString("UpdateChecker.NewAvailable"));
|
2013-03-01 06:52:01 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
private void loadConfigFiles() {
|
|
|
|
// Force the loading of config files
|
|
|
|
TreasureConfig.getInstance();
|
|
|
|
HiddenConfig.getInstance();
|
|
|
|
AdvancedConfig.getInstance();
|
|
|
|
new ChildConfig();
|
|
|
|
|
|
|
|
List<Repairable> repairables = new ArrayList<Repairable>();
|
|
|
|
|
2013-06-07 19:55:49 +02:00
|
|
|
if (Config.getInstance().getToolModsEnabled()) {
|
2013-03-01 06:52:01 +01:00
|
|
|
repairables.addAll(CustomToolConfig.getInstance().getLoadedRepairables());
|
|
|
|
}
|
|
|
|
|
2013-06-07 19:55:49 +02:00
|
|
|
if (Config.getInstance().getArmorModsEnabled()) {
|
2013-03-01 06:52:01 +01:00
|
|
|
repairables.addAll(CustomArmorConfig.getInstance().getLoadedRepairables());
|
|
|
|
}
|
|
|
|
|
2013-06-07 19:55:49 +02:00
|
|
|
if (Config.getInstance().getBlockModsEnabled()) {
|
2013-03-01 06:52:01 +01:00
|
|
|
CustomBlockConfig.getInstance();
|
|
|
|
}
|
|
|
|
|
2013-06-07 19:55:49 +02:00
|
|
|
if (Config.getInstance().getEntityModsEnabled()) {
|
2013-03-01 06:52:01 +01:00
|
|
|
CustomEntityConfig.getInstance();
|
|
|
|
}
|
|
|
|
|
|
|
|
// Load repair configs, make manager, and register them at this time
|
|
|
|
RepairConfigManager rManager = new RepairConfigManager(this);
|
|
|
|
repairables.addAll(rManager.getLoadedRepairables());
|
2013-10-09 06:10:32 +02:00
|
|
|
repairableManager = new SimpleRepairableManager(repairables.size());
|
2013-03-06 15:37:09 +01:00
|
|
|
repairableManager.registerRepairables(repairables);
|
2013-03-01 06:52:01 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
private void registerEvents() {
|
|
|
|
PluginManager pluginManager = getServer().getPluginManager();
|
|
|
|
|
|
|
|
// Register events
|
2013-05-15 21:39:40 +02:00
|
|
|
pluginManager.registerEvents(new PlayerListener(this), this);
|
|
|
|
pluginManager.registerEvents(new BlockListener(this), this);
|
|
|
|
pluginManager.registerEvents(new EntityListener(this), this);
|
|
|
|
pluginManager.registerEvents(new InventoryListener(this), this);
|
|
|
|
pluginManager.registerEvents(new SelfListener(), this);
|
2013-10-25 23:07:56 +02:00
|
|
|
pluginManager.registerEvents(new ScoreboardsListener(), this);
|
2013-05-15 21:39:40 +02:00
|
|
|
pluginManager.registerEvents(new WorldListener(this), this);
|
2013-03-01 06:52:01 +01:00
|
|
|
}
|
|
|
|
|
2013-03-08 21:46:05 +01:00
|
|
|
private void registerCustomRecipes() {
|
|
|
|
if (Config.getInstance().getChimaeraEnabled()) {
|
|
|
|
getServer().addRecipe(ChimaeraWing.getChimaeraWingRecipe());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-03-01 06:52:01 +01:00
|
|
|
private void scheduleTasks() {
|
|
|
|
// Periodic save timer (Saves every 10 minutes by default)
|
|
|
|
long saveIntervalTicks = Config.getInstance().getSaveInterval() * 1200;
|
2013-03-20 08:11:16 +01:00
|
|
|
new SaveTimerTask().runTaskTimer(this, saveIntervalTicks, saveIntervalTicks);
|
|
|
|
|
2013-03-01 06:52:01 +01:00
|
|
|
// Bleed timer (Runs every two seconds)
|
2013-06-13 01:26:09 +02:00
|
|
|
new BleedTimerTask().runTaskTimer(this, 2 * Misc.TICK_CONVERSION_FACTOR, 2 * Misc.TICK_CONVERSION_FACTOR);
|
2013-03-01 06:52:01 +01:00
|
|
|
|
|
|
|
// Old & Powerless User remover
|
2013-06-13 01:26:09 +02:00
|
|
|
long purgeIntervalTicks = Config.getInstance().getPurgeInterval() * 60 * 60 * Misc.TICK_CONVERSION_FACTOR;
|
2013-03-01 06:52:01 +01:00
|
|
|
|
2013-04-30 21:19:41 +02:00
|
|
|
if (purgeIntervalTicks == 0) {
|
2013-06-13 01:26:09 +02:00
|
|
|
new UserPurgeTask().runTaskLater(this, 2 * Misc.TICK_CONVERSION_FACTOR); // Start 2 seconds after startup.
|
2013-03-01 06:52:01 +01:00
|
|
|
}
|
2013-04-30 21:19:41 +02:00
|
|
|
else if (purgeIntervalTicks > 0) {
|
|
|
|
new UserPurgeTask().runTaskTimer(this, purgeIntervalTicks, purgeIntervalTicks);
|
2013-03-01 06:52:01 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// Automatically remove old members from parties
|
2013-06-13 01:26:09 +02:00
|
|
|
long kickIntervalTicks = Config.getInstance().getAutoPartyKickInterval() * 60 * 60 * Misc.TICK_CONVERSION_FACTOR;
|
2013-03-01 06:52:01 +01:00
|
|
|
|
2013-04-30 21:19:41 +02:00
|
|
|
if (kickIntervalTicks == 0) {
|
2013-06-13 01:26:09 +02:00
|
|
|
new PartyAutoKickTask().runTaskLater(this, 2 * Misc.TICK_CONVERSION_FACTOR); // Start 2 seconds after startup.
|
2013-03-01 06:52:01 +01:00
|
|
|
}
|
2013-04-30 21:19:41 +02:00
|
|
|
else if (kickIntervalTicks > 0) {
|
|
|
|
new PartyAutoKickTask().runTaskTimer(this, kickIntervalTicks, kickIntervalTicks);
|
2013-03-01 06:52:01 +01:00
|
|
|
}
|
2013-09-12 04:42:27 +02:00
|
|
|
|
|
|
|
// Update power level tag scoreboards
|
|
|
|
new PowerLevelUpdatingTask().runTaskTimer(this, 2 * Misc.TICK_CONVERSION_FACTOR, 2 * Misc.TICK_CONVERSION_FACTOR);
|
2013-03-01 06:52:01 +01:00
|
|
|
}
|
2013-10-04 15:41:01 +02:00
|
|
|
|
|
|
|
private void checkModConfigs() {
|
|
|
|
if (!Config.getInstance().getToolModsEnabled()) {
|
|
|
|
getLogger().info("MCPC+ implementation found, but the custom tool config for mcMMO is disabled!");
|
|
|
|
getLogger().info("To enable, set Mods.Tool_Mods_Enabled to TRUE in config.yml.");
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!Config.getInstance().getArmorModsEnabled()) {
|
|
|
|
getLogger().info("MCPC+ implementation found, but the custom armor config for mcMMO is disabled!");
|
|
|
|
getLogger().info("To enable, set Mods.Armor_Mods_Enabled to TRUE in config.yml.");
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!Config.getInstance().getBlockModsEnabled()) {
|
|
|
|
getLogger().info("MCPC+ implementation found, but the custom block config for mcMMO is disabled!");
|
|
|
|
getLogger().info("To enable, set Mods.Block_Mods_Enabled to TRUE in config.yml.");
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!Config.getInstance().getEntityModsEnabled()) {
|
|
|
|
getLogger().info("MCPC+ implementation found, but the custom entity config for mcMMO is disabled!");
|
|
|
|
getLogger().info("To enable, set Mods.Entity_Mods_Enabled to TRUE in config.yml.");
|
|
|
|
}
|
|
|
|
}
|
2013-03-01 06:52:01 +01:00
|
|
|
}
|