2012-01-09 20:00:13 +01:00
|
|
|
package com.gmail.nossr50;
|
|
|
|
|
2012-06-05 16:13:10 +02:00
|
|
|
import java.io.File;
|
|
|
|
import java.io.IOException;
|
|
|
|
import java.util.ArrayList;
|
|
|
|
import java.util.HashMap;
|
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
import net.shatteredlands.shatt.backup.ZipLibrary;
|
|
|
|
|
2013-02-20 21:44:17 +01:00
|
|
|
import org.bukkit.Bukkit;
|
2012-06-05 16:13:10 +02:00
|
|
|
import org.bukkit.OfflinePlayer;
|
2013-01-23 22:34:01 +01:00
|
|
|
import org.bukkit.block.Block;
|
2012-06-05 16:13:10 +02:00
|
|
|
import org.bukkit.entity.Player;
|
2013-02-20 18:53:24 +01:00
|
|
|
import org.bukkit.event.HandlerList;
|
2013-02-19 01:13:33 +01:00
|
|
|
import org.bukkit.metadata.FixedMetadataValue;
|
2012-06-05 16:13:10 +02:00
|
|
|
import org.bukkit.plugin.PluginManager;
|
|
|
|
import org.bukkit.plugin.java.JavaPlugin;
|
|
|
|
import org.bukkit.scheduler.BukkitScheduler;
|
2013-02-15 17:08:00 +01:00
|
|
|
|
2013-01-30 21:25:48 +01:00
|
|
|
import com.gmail.nossr50.util.blockmeta.chunkmeta.ChunkManager;
|
|
|
|
import com.gmail.nossr50.util.blockmeta.chunkmeta.ChunkManagerFactory;
|
2013-02-15 17:11:47 +01:00
|
|
|
import com.gmail.nossr50.util.metrics.MetricsManager;
|
2013-02-01 18:27:24 +01:00
|
|
|
import com.gmail.nossr50.commands.CommandRegistrationHelper;
|
2012-11-21 21:49:54 +01:00
|
|
|
import com.gmail.nossr50.config.AdvancedConfig;
|
2012-05-05 19:51:54 +02:00
|
|
|
import com.gmail.nossr50.config.Config;
|
2012-05-19 04:01:15 +02:00
|
|
|
import com.gmail.nossr50.config.HiddenConfig;
|
2012-05-17 16:26:21 +02:00
|
|
|
import com.gmail.nossr50.config.TreasuresConfig;
|
2013-01-25 04:53:02 +01:00
|
|
|
import com.gmail.nossr50.database.Database;
|
2013-02-05 18:56:31 +01:00
|
|
|
import com.gmail.nossr50.database.Leaderboard;
|
2013-01-30 17:53:51 +01:00
|
|
|
import com.gmail.nossr50.database.runnables.UserPurgeTask;
|
2012-06-05 16:13:10 +02:00
|
|
|
import com.gmail.nossr50.datatypes.PlayerProfile;
|
|
|
|
import com.gmail.nossr50.listeners.BlockListener;
|
|
|
|
import com.gmail.nossr50.listeners.EntityListener;
|
2013-01-23 22:34:01 +01:00
|
|
|
import com.gmail.nossr50.listeners.InventoryListener;
|
2012-06-05 16:13:10 +02:00
|
|
|
import com.gmail.nossr50.listeners.PlayerListener;
|
|
|
|
import com.gmail.nossr50.listeners.WorldListener;
|
2013-02-18 22:54:47 +01:00
|
|
|
import com.gmail.nossr50.locale.LocaleLoader;
|
2013-01-30 17:35:33 +01:00
|
|
|
import com.gmail.nossr50.mods.config.CustomArmorConfig;
|
|
|
|
import com.gmail.nossr50.mods.config.CustomBlocksConfig;
|
2013-02-06 04:40:19 +01:00
|
|
|
import com.gmail.nossr50.mods.config.CustomEntityConfig;
|
2013-01-30 17:35:33 +01:00
|
|
|
import com.gmail.nossr50.mods.config.CustomToolsConfig;
|
2012-06-08 23:48:41 +02:00
|
|
|
import com.gmail.nossr50.party.PartyManager;
|
2013-02-12 20:36:38 +01:00
|
|
|
import com.gmail.nossr50.party.runnables.PartiesLoader;
|
|
|
|
import com.gmail.nossr50.party.runnables.PartyAutoKick;
|
2012-06-05 16:13:10 +02:00
|
|
|
import com.gmail.nossr50.runnables.SaveTimer;
|
2012-05-22 06:57:24 +02:00
|
|
|
import com.gmail.nossr50.skills.repair.RepairManager;
|
|
|
|
import com.gmail.nossr50.skills.repair.RepairManagerFactory;
|
|
|
|
import com.gmail.nossr50.skills.repair.Repairable;
|
2013-01-22 18:43:25 +01:00
|
|
|
import com.gmail.nossr50.skills.repair.config.RepairConfigManager;
|
2013-01-30 17:53:51 +01:00
|
|
|
import com.gmail.nossr50.skills.runnables.BleedTimer;
|
|
|
|
import com.gmail.nossr50.skills.runnables.SkillMonitor;
|
2013-01-30 14:08:29 +01:00
|
|
|
import com.gmail.nossr50.spout.SpoutConfig;
|
|
|
|
import com.gmail.nossr50.spout.SpoutTools;
|
2013-02-20 17:43:23 +01:00
|
|
|
import com.gmail.nossr50.util.Permissions;
|
2013-02-20 17:47:08 +01:00
|
|
|
import com.gmail.nossr50.util.LogFilter;
|
2013-02-18 22:54:47 +01:00
|
|
|
import com.gmail.nossr50.util.UpdateCheck;
|
2012-04-27 11:47:11 +02:00
|
|
|
import com.gmail.nossr50.util.Users;
|
2012-11-04 22:36:57 +01:00
|
|
|
|
2012-06-07 00:02:22 +02: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);
|
2013-01-24 00:53:39 +01:00
|
|
|
private final InventoryListener inventoryListener = new InventoryListener(this);
|
2012-05-08 04:38:22 +02:00
|
|
|
private final WorldListener worldListener = new WorldListener();
|
2012-03-08 22:17:57 +01:00
|
|
|
|
2012-06-06 21:38:44 +02:00
|
|
|
private HashMap<Integer, String> tntTracker = new HashMap<Integer, String>();
|
2013-01-23 22:34:01 +01:00
|
|
|
private HashMap<Block, String> furnaceTracker = new HashMap<Block, String>();
|
2012-03-08 22:17:57 +01:00
|
|
|
|
2012-06-07 00:02:22 +02:00
|
|
|
public static mcMMO p;
|
2012-03-08 22:17:57 +01:00
|
|
|
|
2013-02-17 16:05:35 +01:00
|
|
|
public static ChunkManager placeStore;
|
2012-05-22 06:57:24 +02:00
|
|
|
public static RepairManager repairManager;
|
2012-05-08 04:38:22 +02:00
|
|
|
|
2013-01-27 01:32:41 +01:00
|
|
|
// Jar Stuff
|
2012-06-05 17:05:44 +02:00
|
|
|
public static File mcmmo;
|
2013-02-02 10:38:15 +01:00
|
|
|
|
2013-01-27 01:32:41 +01:00
|
|
|
// File Paths
|
2012-07-09 16:55:33 +02:00
|
|
|
private static String mainDirectory;
|
|
|
|
private static String flatFileDirectory;
|
|
|
|
private static String usersFile;
|
|
|
|
private static String modDirectory;
|
2012-04-21 20:05:39 +02:00
|
|
|
|
2013-02-18 22:54:47 +01:00
|
|
|
// Update Check
|
|
|
|
public boolean updateAvailable;
|
|
|
|
|
2013-01-27 01:32:41 +01:00
|
|
|
// Spout Check
|
2013-01-30 14:08:29 +01:00
|
|
|
public static boolean spoutEnabled = false;
|
2012-05-23 20:31:03 +02:00
|
|
|
|
2013-01-27 01:32:41 +01:00
|
|
|
// XP Event Check
|
2013-01-24 20:19:26 +01:00
|
|
|
private boolean xpEventEnabled = false;
|
|
|
|
|
2013-02-24 00:13:12 +01:00
|
|
|
// Metadata Values
|
|
|
|
public static FixedMetadataValue metadataValue;
|
2013-02-19 01:13:33 +01:00
|
|
|
public final static String entityMetadataKey = "mcMMO: Spawned Entity";
|
2013-02-23 06:29:25 +01:00
|
|
|
public final static String blockMetadataKey = "mcMMO: Piston Tracking";
|
|
|
|
|
2012-03-08 22:17:57 +01:00
|
|
|
/**
|
|
|
|
* Things to be run when the plugin is enabled.
|
|
|
|
*/
|
2012-06-05 15:57:10 +02:00
|
|
|
@Override
|
2012-03-08 22:17:57 +01:00
|
|
|
public void onEnable() {
|
2013-02-20 21:44:17 +01:00
|
|
|
try {
|
|
|
|
p = this;
|
|
|
|
getLogger().setFilter(new LogFilter(this));
|
2013-02-24 00:13:12 +01:00
|
|
|
metadataValue = new FixedMetadataValue(this, true);
|
2013-02-23 06:29:25 +01:00
|
|
|
|
2013-02-20 21:44:17 +01:00
|
|
|
setupFilePaths();
|
|
|
|
setupSpout();
|
|
|
|
loadConfigFiles();
|
|
|
|
|
|
|
|
if (!Config.getInstance().getUseMySQL()) {
|
|
|
|
Users.loadUsers();
|
|
|
|
}
|
2013-01-30 08:44:01 +01:00
|
|
|
|
2013-02-20 21:44:17 +01:00
|
|
|
registerEvents();
|
2013-02-05 15:35:06 +01:00
|
|
|
|
2013-02-20 21:44:17 +01:00
|
|
|
// Setup the leader boards
|
|
|
|
if (Config.getInstance().getUseMySQL()) {
|
|
|
|
// TODO: Why do we have to check for a connection that hasn't be made yet?
|
|
|
|
Database.checkConnected();
|
|
|
|
Database.createStructure();
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
Leaderboard.updateLeaderboards();
|
|
|
|
}
|
2013-02-05 15:35:06 +01:00
|
|
|
|
2013-02-20 21:44:17 +01:00
|
|
|
for (Player player : getServer().getOnlinePlayers()) {
|
|
|
|
Users.addUser(player); // In case of reload add all users back into PlayerProfile
|
|
|
|
}
|
2013-02-05 15:35:06 +01:00
|
|
|
|
2013-02-20 21:44:17 +01:00
|
|
|
getLogger().info("Version " + getDescription().getVersion() + " is enabled!");
|
2013-02-05 15:35:06 +01:00
|
|
|
|
2013-02-20 21:44:17 +01:00
|
|
|
scheduleTasks();
|
|
|
|
registerCommands();
|
2013-02-15 17:11:47 +01:00
|
|
|
|
2013-02-20 21:44:17 +01:00
|
|
|
MetricsManager.setup();
|
2013-02-05 15:35:06 +01:00
|
|
|
|
2013-02-20 21:44:17 +01:00
|
|
|
placeStore = ChunkManagerFactory.getChunkManager(); // Get our ChunkletManager
|
2013-02-05 15:35:06 +01:00
|
|
|
|
2013-02-20 21:44:17 +01:00
|
|
|
checkForUpdates();
|
2013-02-20 17:43:23 +01:00
|
|
|
|
2013-02-20 21:44:17 +01:00
|
|
|
if (Config.getInstance().getPTPCommandWorldPermissions()) {
|
|
|
|
Permissions.generateWorldTeleportPermissions();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
catch (Throwable t) {
|
2013-02-21 00:30:42 +01:00
|
|
|
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-02-20 21:44:17 +01:00
|
|
|
Bukkit.getPluginManager().disablePlugin(this);
|
2013-02-20 17:43:23 +01:00
|
|
|
}
|
2013-02-05 15:35:06 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Setup the various storage file paths
|
|
|
|
*/
|
|
|
|
private void setupFilePaths() {
|
|
|
|
mcmmo = getFile();
|
|
|
|
mainDirectory = getDataFolder().getPath() + File.separator;
|
|
|
|
flatFileDirectory = mainDirectory + "FlatFileStuff" + File.separator;
|
|
|
|
usersFile = flatFileDirectory + "mcmmo.users";
|
|
|
|
modDirectory = mainDirectory + "ModConfigs" + File.separator;
|
|
|
|
}
|
|
|
|
|
2013-02-20 17:04:05 +01:00
|
|
|
private void checkForUpdates() {
|
|
|
|
if (Config.getInstance().getUpdateCheckEnabled()) {
|
|
|
|
try {
|
|
|
|
updateAvailable = UpdateCheck.updateAvailable();
|
|
|
|
}
|
|
|
|
catch (Exception e) {
|
|
|
|
updateAvailable = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (updateAvailable) {
|
|
|
|
getLogger().info(LocaleLoader.getString("UpdateChecker.outdated"));
|
|
|
|
getLogger().info(LocaleLoader.getString("UpdateChecker.newavailable"));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-02-05 15:35:06 +01:00
|
|
|
/**
|
|
|
|
* Get profile of the player by name.
|
|
|
|
* </br>
|
|
|
|
* This function is designed for API usage.
|
|
|
|
*
|
|
|
|
* @param playerName Name of player whose profile to get
|
|
|
|
* @return the PlayerProfile object
|
|
|
|
*/
|
|
|
|
public PlayerProfile getPlayerProfile(String playerName) {
|
|
|
|
return Users.getPlayer(playerName).getProfile();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get profile of the player.
|
|
|
|
* </br>
|
|
|
|
* This function is designed for API usage.
|
|
|
|
*
|
|
|
|
* @param player player whose profile to get
|
|
|
|
* @return the PlayerProfile object
|
|
|
|
*/
|
|
|
|
public PlayerProfile getPlayerProfile(OfflinePlayer player) {
|
|
|
|
return Users.getPlayer(player.getName()).getProfile();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get profile of the player.
|
|
|
|
* </br>
|
|
|
|
* This function is designed for API usage.
|
|
|
|
*
|
|
|
|
* @param player player whose profile to get
|
|
|
|
* @return the PlayerProfile object
|
|
|
|
*/
|
|
|
|
@Deprecated
|
|
|
|
public PlayerProfile getPlayerProfile(Player player) {
|
|
|
|
return Users.getProfile(player);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Things to be run when the plugin is disabled.
|
|
|
|
*/
|
|
|
|
@Override
|
|
|
|
public void onDisable() {
|
2013-02-20 21:44:17 +01:00
|
|
|
try {
|
|
|
|
Users.saveAll(); // Make sure to save player information if the server shuts down
|
|
|
|
PartyManager.saveParties();
|
|
|
|
placeStore.saveAll(); // Save our metadata
|
|
|
|
placeStore.cleanUp(); // Cleanup empty metadata stores
|
|
|
|
}
|
|
|
|
catch (NullPointerException e) {}
|
|
|
|
|
2013-02-05 15:35:06 +01:00
|
|
|
getServer().getScheduler().cancelTasks(this); // This removes our tasks
|
2013-02-20 18:53:24 +01:00
|
|
|
HandlerList.unregisterAll(this); // Cancel event registrations
|
2013-02-05 15:35:06 +01:00
|
|
|
|
2013-02-15 13:50:32 +01:00
|
|
|
if (Config.getInstance().getBackupsEnabled()) {
|
|
|
|
// Remove other tasks BEFORE starting the Backup, or we just cancel it straight away.
|
|
|
|
try {
|
|
|
|
ZipLibrary.mcMMObackup();
|
|
|
|
}
|
|
|
|
catch (IOException e) {
|
|
|
|
getLogger().severe(e.toString());
|
|
|
|
}
|
2013-02-20 21:44:17 +01:00
|
|
|
catch (Throwable e) {
|
|
|
|
if (e instanceof NoClassDefFoundError) {
|
2013-02-21 00:30:42 +01:00
|
|
|
getLogger().severe("Backup class not found!");
|
|
|
|
getLogger().info("Please do not replace the mcMMO jar while the server is running.");
|
2013-02-20 21:44:17 +01:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
getLogger().severe(e.toString());
|
|
|
|
}
|
|
|
|
}
|
2013-02-05 15:35:06 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
getLogger().info("Was disabled."); //How informative!
|
|
|
|
}
|
2013-01-30 06:08:19 +01:00
|
|
|
|
2013-02-05 15:35:06 +01:00
|
|
|
private void loadConfigFiles() {
|
2013-01-27 01:32:41 +01:00
|
|
|
// Force the loading of config files
|
2012-05-09 15:58:11 +02:00
|
|
|
Config configInstance = Config.getInstance();
|
2012-05-17 16:26:21 +02:00
|
|
|
TreasuresConfig.getInstance();
|
2012-05-19 04:01:15 +02:00
|
|
|
HiddenConfig.getInstance();
|
2012-11-21 21:49:54 +01:00
|
|
|
AdvancedConfig.getInstance();
|
2013-02-09 15:16:57 +01:00
|
|
|
|
|
|
|
|
2012-05-05 19:02:36 +02:00
|
|
|
|
2012-05-22 13:56:48 +02:00
|
|
|
List<Repairable> repairables = new ArrayList<Repairable>();
|
2012-05-22 06:57:24 +02:00
|
|
|
|
2012-05-05 19:02:36 +02:00
|
|
|
if (configInstance.getToolModsEnabled()) {
|
2012-05-22 13:56:48 +02:00
|
|
|
repairables.addAll(CustomToolsConfig.getInstance().getLoadedRepairables());
|
2012-05-05 19:02:36 +02:00
|
|
|
}
|
2012-05-05 19:51:54 +02:00
|
|
|
|
2012-05-15 22:12:59 +02:00
|
|
|
if (configInstance.getArmorModsEnabled()) {
|
2012-05-22 13:56:48 +02:00
|
|
|
repairables.addAll(CustomArmorConfig.getInstance().getLoadedRepairables());
|
2012-05-15 22:12:59 +02:00
|
|
|
}
|
|
|
|
|
2012-05-17 14:33:50 +02:00
|
|
|
if (configInstance.getBlockModsEnabled()) {
|
2012-07-03 21:57:24 +02:00
|
|
|
CustomBlocksConfig.getInstance();
|
2012-05-17 14:33:50 +02:00
|
|
|
}
|
|
|
|
|
2013-02-06 04:40:19 +01:00
|
|
|
if (configInstance.getEntityModsEnabled()) {
|
|
|
|
CustomEntityConfig.getInstance();
|
|
|
|
}
|
|
|
|
|
2013-01-27 01:32:41 +01:00
|
|
|
// Load repair configs, make manager, and register them at this time
|
2012-05-22 13:56:48 +02:00
|
|
|
RepairConfigManager rManager = new RepairConfigManager(this);
|
|
|
|
repairables.addAll(rManager.getLoadedRepairables());
|
|
|
|
repairManager = RepairManagerFactory.getRepairManager(repairables.size());
|
|
|
|
repairManager.registerRepairables(repairables);
|
2012-12-24 22:56:25 +01:00
|
|
|
|
2013-01-27 01:32:41 +01:00
|
|
|
// Check if Repair Anvil and Salvage Anvil have different itemID's
|
2013-01-10 05:03:17 +01:00
|
|
|
if (configInstance.getSalvageAnvilId() == configInstance.getRepairAnvilId()) {
|
2012-12-30 00:02:39 +01:00
|
|
|
getLogger().warning("Can't use the same itemID for Repair/Salvage Anvils!");
|
2012-11-13 16:50:00 +01:00
|
|
|
}
|
2013-02-05 15:35:06 +01:00
|
|
|
}
|
2012-05-22 13:56:48 +02:00
|
|
|
|
2013-02-05 15:35:06 +01:00
|
|
|
private void setupSpout() {
|
|
|
|
// Check for Spout
|
|
|
|
if (getServer().getPluginManager().isPluginEnabled("Spout")) {
|
|
|
|
spoutEnabled = true;
|
|
|
|
|
|
|
|
SpoutConfig.getInstance();
|
|
|
|
SpoutTools.setupSpoutConfigs();
|
|
|
|
SpoutTools.registerCustomEvent();
|
|
|
|
SpoutTools.preCacheFiles();
|
|
|
|
SpoutTools.reloadSpoutPlayers(); // Handle spout players after a /reload
|
2012-03-08 22:17:57 +01:00
|
|
|
}
|
2013-02-05 15:35:06 +01:00
|
|
|
}
|
2012-03-08 22:17:57 +01:00
|
|
|
|
2013-02-05 15:35:06 +01:00
|
|
|
private void registerEvents() {
|
2012-07-04 21:38:09 +02:00
|
|
|
PluginManager pluginManager = getServer().getPluginManager();
|
2012-03-08 22:17:57 +01:00
|
|
|
|
2013-01-27 01:32:41 +01:00
|
|
|
// Register events
|
2012-07-04 21:38:09 +02:00
|
|
|
pluginManager.registerEvents(playerListener, this);
|
|
|
|
pluginManager.registerEvents(blockListener, this);
|
|
|
|
pluginManager.registerEvents(entityListener, this);
|
2013-01-23 22:34:01 +01:00
|
|
|
pluginManager.registerEvents(inventoryListener, this);
|
2013-01-24 00:53:39 +01:00
|
|
|
pluginManager.registerEvents(worldListener, this);
|
2013-02-05 15:35:06 +01:00
|
|
|
}
|
2012-03-08 22:17:57 +01:00
|
|
|
|
2013-02-05 15:35:06 +01:00
|
|
|
/**
|
|
|
|
* Register the commands.
|
|
|
|
*/
|
|
|
|
private void registerCommands() {
|
|
|
|
CommandRegistrationHelper.registerSkillCommands();
|
2012-03-08 22:17:57 +01:00
|
|
|
|
2013-02-05 15:35:06 +01:00
|
|
|
// mc* commands
|
2013-02-05 18:50:09 +01:00
|
|
|
CommandRegistrationHelper.registerMcpurgeCommand();
|
2013-02-06 18:49:43 +01:00
|
|
|
CommandRegistrationHelper.registerMcremoveCommand();
|
2013-02-05 15:35:06 +01:00
|
|
|
CommandRegistrationHelper.registerMcabilityCommand();
|
|
|
|
CommandRegistrationHelper.registerMcgodCommand();
|
|
|
|
CommandRegistrationHelper.registerMcmmoCommand();
|
|
|
|
CommandRegistrationHelper.registerMcrefreshCommand();
|
2013-02-05 16:54:53 +01:00
|
|
|
CommandRegistrationHelper.registerMctopCommand();
|
2013-02-05 15:35:06 +01:00
|
|
|
CommandRegistrationHelper.registerMcrankCommand();
|
|
|
|
CommandRegistrationHelper.registerMcstatsCommand();
|
2012-03-08 22:17:57 +01:00
|
|
|
|
2013-02-05 15:35:06 +01:00
|
|
|
// Party commands
|
2013-02-06 23:57:16 +01:00
|
|
|
CommandRegistrationHelper.registerAdminChatCommand();
|
2013-02-08 05:05:59 +01:00
|
|
|
CommandRegistrationHelper.registerPartyCommand();
|
2013-02-06 23:57:16 +01:00
|
|
|
CommandRegistrationHelper.registerPartyChatCommand();
|
2013-02-12 21:05:02 +01:00
|
|
|
CommandRegistrationHelper.registerPtpCommand();
|
2012-03-08 22:17:57 +01:00
|
|
|
|
2013-02-05 15:35:06 +01:00
|
|
|
// Other commands
|
|
|
|
CommandRegistrationHelper.registerAddxpCommand();
|
|
|
|
CommandRegistrationHelper.registerAddlevelsCommand();
|
|
|
|
CommandRegistrationHelper.registerMmoeditCommand();
|
|
|
|
CommandRegistrationHelper.registerInspectCommand();
|
|
|
|
CommandRegistrationHelper.registerXprateCommand();
|
2013-02-06 23:10:05 +01:00
|
|
|
CommandRegistrationHelper.registerMmoupdateCommand();
|
2013-02-05 15:35:06 +01:00
|
|
|
CommandRegistrationHelper.registerSkillresetCommand();
|
2013-02-13 14:15:38 +01:00
|
|
|
CommandRegistrationHelper.registerHardcoreCommand();
|
|
|
|
CommandRegistrationHelper.registerVampirismCommand();
|
2013-02-19 19:18:27 +01:00
|
|
|
CommandRegistrationHelper.registerMcnotifyCommand();
|
2012-03-08 22:17:57 +01:00
|
|
|
|
2013-02-05 15:35:06 +01:00
|
|
|
// Spout commands
|
2013-02-07 14:25:54 +01:00
|
|
|
CommandRegistrationHelper.registerXplockCommand();
|
|
|
|
CommandRegistrationHelper.registerMchudCommand();
|
2013-02-05 15:35:06 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
private void scheduleTasks() {
|
2012-03-18 21:59:35 +01:00
|
|
|
BukkitScheduler scheduler = getServer().getScheduler();
|
2012-03-08 22:17:57 +01:00
|
|
|
|
2013-02-09 15:42:02 +01:00
|
|
|
// Parties are loaded at the end of first server tick otherwise Server.getOfflinePlayer throws an IndexOutOfBoundsException
|
|
|
|
scheduler.scheduleSyncDelayedTask(this, new PartiesLoader(), 0);
|
|
|
|
|
2013-01-27 01:32:41 +01:00
|
|
|
// Periodic save timer (Saves every 10 minutes by default)
|
2013-02-09 15:45:41 +01:00
|
|
|
long saveIntervalTicks = Config.getInstance().getSaveInterval() * 1200;
|
|
|
|
|
|
|
|
scheduler.scheduleSyncRepeatingTask(this, new SaveTimer(), saveIntervalTicks, saveIntervalTicks);
|
2013-01-27 01:32:41 +01:00
|
|
|
// Regen & Cooldown timer (Runs every second)
|
2013-02-09 15:45:41 +01:00
|
|
|
scheduler.scheduleSyncRepeatingTask(this, new SkillMonitor(), 20, 20);
|
2013-01-27 01:32:41 +01:00
|
|
|
// Bleed timer (Runs every two seconds)
|
2013-02-09 15:45:41 +01:00
|
|
|
scheduler.scheduleSyncRepeatingTask(this, new BleedTimer(), 40, 40);
|
2013-01-11 01:58:25 +01:00
|
|
|
|
2013-01-27 01:32:41 +01:00
|
|
|
// Old & Powerless User remover
|
2013-01-11 01:58:25 +01:00
|
|
|
int purgeInterval = Config.getInstance().getPurgeInterval();
|
2013-01-27 01:32:41 +01:00
|
|
|
|
2013-01-11 01:58:25 +01:00
|
|
|
if (purgeInterval == 0) {
|
2013-01-27 01:32:41 +01:00
|
|
|
scheduler.scheduleSyncDelayedTask(this, new UserPurgeTask(), 40); // Start 2 seconds after startup.
|
2013-01-11 01:58:25 +01:00
|
|
|
}
|
|
|
|
else if (purgeInterval > 0) {
|
2013-02-09 15:45:41 +01:00
|
|
|
long purgeIntervalTicks = purgeInterval * 60 * 60 * 20;
|
|
|
|
|
|
|
|
scheduler.scheduleSyncRepeatingTask(this, new UserPurgeTask(), purgeIntervalTicks, purgeIntervalTicks);
|
2013-01-11 01:58:25 +01:00
|
|
|
}
|
2012-03-08 22:17:57 +01:00
|
|
|
|
2013-02-05 00:42:19 +01:00
|
|
|
// Automatically remove old members from parties
|
|
|
|
long kickInterval = Config.getInstance().getAutoPartyKickInterval();
|
|
|
|
|
|
|
|
if (kickInterval == 0) {
|
|
|
|
scheduler.scheduleSyncDelayedTask(this, new PartyAutoKick(), 40); // Start 2 seconds after startup.
|
|
|
|
}
|
|
|
|
else if (kickInterval > 0) {
|
2013-02-09 15:45:41 +01:00
|
|
|
long kickIntervalTicks = kickInterval * 60 * 60 * 20;
|
|
|
|
|
|
|
|
scheduler.scheduleSyncRepeatingTask(this, new PartyAutoKick(), kickIntervalTicks, kickIntervalTicks);
|
2013-02-05 00:42:19 +01:00
|
|
|
}
|
2013-02-05 15:35:06 +01:00
|
|
|
}
|
2013-02-05 00:42:19 +01:00
|
|
|
|
2012-06-06 21:38:44 +02:00
|
|
|
/**
|
|
|
|
* Add a set of values to the TNT tracker.
|
|
|
|
*
|
|
|
|
* @param tntID The EntityID of the TNT
|
|
|
|
* @param playerName The name of the detonating player
|
|
|
|
*/
|
|
|
|
public void addToTNTTracker(int tntID, String playerName) {
|
|
|
|
tntTracker.put(tntID, playerName);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Check to see if a given TNT Entity is tracked.
|
|
|
|
*
|
|
|
|
* @param tntID The EntityID of the TNT
|
|
|
|
* @return true if the TNT is being tracked, false otherwise
|
|
|
|
*/
|
|
|
|
public boolean tntIsTracked(int tntID) {
|
|
|
|
return tntTracker.containsKey(tntID);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the player who detonated the TNT.
|
|
|
|
*
|
|
|
|
* @param tntID The EntityID of the TNT
|
|
|
|
* @return the Player who detonated it
|
|
|
|
*/
|
|
|
|
public Player getTNTPlayer(int tntID) {
|
|
|
|
return getServer().getPlayer(tntTracker.get(tntID));
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Remove TNT from the tracker after it explodes.
|
|
|
|
*
|
|
|
|
* @param tntID The EntityID of the TNT
|
|
|
|
*/
|
|
|
|
public void removeFromTNTTracker(int tntID) {
|
|
|
|
tntTracker.remove(tntID);
|
|
|
|
}
|
2012-07-09 16:55:33 +02:00
|
|
|
|
2013-01-23 22:34:01 +01:00
|
|
|
public void addToOpenFurnaceTracker(Block furnace, String playerName) {
|
|
|
|
furnaceTracker.put(furnace, playerName);
|
|
|
|
}
|
|
|
|
|
|
|
|
public boolean furnaceIsTracked(Block furnace) {
|
|
|
|
return furnaceTracker.containsKey(furnace);
|
|
|
|
}
|
|
|
|
|
|
|
|
public void removeFromFurnaceTracker(Block furnace) {
|
|
|
|
furnaceTracker.remove(furnace);
|
|
|
|
}
|
|
|
|
|
|
|
|
public Player getFurnacePlayer(Block furnace) {
|
|
|
|
return getServer().getPlayer(furnaceTracker.get(furnace));
|
|
|
|
}
|
|
|
|
|
2012-07-09 16:55:33 +02:00
|
|
|
public static String getMainDirectory() {
|
|
|
|
return mainDirectory;
|
|
|
|
}
|
|
|
|
|
|
|
|
public static String getFlatFileDirectory() {
|
|
|
|
return flatFileDirectory;
|
|
|
|
}
|
|
|
|
|
2013-01-26 23:01:55 +01:00
|
|
|
public static String getUsersFilePath() {
|
2012-07-09 16:55:33 +02:00
|
|
|
return usersFile;
|
|
|
|
}
|
|
|
|
|
|
|
|
public static String getModDirectory() {
|
|
|
|
return modDirectory;
|
|
|
|
}
|
2012-07-09 17:12:46 +02:00
|
|
|
|
2013-01-24 20:19:26 +01:00
|
|
|
public boolean isXPEventEnabled() {
|
|
|
|
return xpEventEnabled;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setXPEventEnabled(boolean enabled) {
|
|
|
|
this.xpEventEnabled = enabled;
|
|
|
|
}
|
2013-02-04 14:47:54 +01:00
|
|
|
|
|
|
|
public void toggleXpEventEnabled() {
|
|
|
|
xpEventEnabled = !xpEventEnabled;
|
|
|
|
}
|
2013-02-20 17:47:08 +01:00
|
|
|
|
|
|
|
public void debug(String message) {
|
|
|
|
getLogger().info("[Debug] " + message);
|
|
|
|
}
|
2012-03-08 22:55:43 +01:00
|
|
|
}
|