forked from Upstream/mmocore
Merge
This commit is contained in:
parent
39e5096c3b
commit
b3d783dea4
@ -7,6 +7,7 @@ import io.lumine.mythic.utils.plugin.LuminePlugin;
|
|||||||
import net.Indyuce.mmocore.api.ConfigFile;
|
import net.Indyuce.mmocore.api.ConfigFile;
|
||||||
import net.Indyuce.mmocore.api.PlayerActionBar;
|
import net.Indyuce.mmocore.api.PlayerActionBar;
|
||||||
import net.Indyuce.mmocore.api.player.PlayerData;
|
import net.Indyuce.mmocore.api.player.PlayerData;
|
||||||
|
import net.Indyuce.mmocore.api.player.attribute.AttributeModifier;
|
||||||
import net.Indyuce.mmocore.api.player.profess.resource.PlayerResource;
|
import net.Indyuce.mmocore.api.player.profess.resource.PlayerResource;
|
||||||
import net.Indyuce.mmocore.api.player.stats.StatType;
|
import net.Indyuce.mmocore.api.player.stats.StatType;
|
||||||
import net.Indyuce.mmocore.api.util.debug.DebugMode;
|
import net.Indyuce.mmocore.api.util.debug.DebugMode;
|
||||||
@ -24,6 +25,7 @@ import net.Indyuce.mmocore.comp.region.WorldGuardMMOLoader;
|
|||||||
import net.Indyuce.mmocore.comp.region.WorldGuardRegionHandler;
|
import net.Indyuce.mmocore.comp.region.WorldGuardRegionHandler;
|
||||||
import net.Indyuce.mmocore.comp.vault.VaultEconomy;
|
import net.Indyuce.mmocore.comp.vault.VaultEconomy;
|
||||||
import net.Indyuce.mmocore.comp.vault.VaultMMOLoader;
|
import net.Indyuce.mmocore.comp.vault.VaultMMOLoader;
|
||||||
|
import net.Indyuce.mmocore.guild.GuildModule;
|
||||||
import net.Indyuce.mmocore.guild.GuildModuleType;
|
import net.Indyuce.mmocore.guild.GuildModuleType;
|
||||||
import net.Indyuce.mmocore.guild.provided.Guild;
|
import net.Indyuce.mmocore.guild.provided.Guild;
|
||||||
import net.Indyuce.mmocore.guild.provided.MMOCoreGuildModule;
|
import net.Indyuce.mmocore.guild.provided.MMOCoreGuildModule;
|
||||||
@ -46,11 +48,17 @@ import net.Indyuce.mmocore.party.PartyModule;
|
|||||||
import net.Indyuce.mmocore.party.PartyModuleType;
|
import net.Indyuce.mmocore.party.PartyModuleType;
|
||||||
import net.Indyuce.mmocore.party.provided.MMOCorePartyModule;
|
import net.Indyuce.mmocore.party.provided.MMOCorePartyModule;
|
||||||
import net.Indyuce.mmocore.skill.cast.SkillCastingMode;
|
import net.Indyuce.mmocore.skill.cast.SkillCastingMode;
|
||||||
|
import net.Indyuce.mmocore.skill.custom.mechanic.ExperienceMechanic;
|
||||||
|
import net.Indyuce.mmocore.skill.custom.mechanic.ManaMechanic;
|
||||||
|
import net.Indyuce.mmocore.skill.custom.mechanic.StaminaMechanic;
|
||||||
|
import net.Indyuce.mmocore.skill.custom.mechanic.StelliumMechanic;
|
||||||
import org.apache.commons.lang.Validate;
|
import org.apache.commons.lang.Validate;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
|
import io.lumine.mythic.lib.metrics.bukkit.Metrics;
|
||||||
import org.bukkit.command.CommandMap;
|
import org.bukkit.command.CommandMap;
|
||||||
import org.bukkit.configuration.file.FileConfiguration;
|
import org.bukkit.configuration.file.FileConfiguration;
|
||||||
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
import org.bukkit.scheduler.BukkitRunnable;
|
import org.bukkit.scheduler.BukkitRunnable;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
@ -59,268 +67,253 @@ import java.lang.reflect.Field;
|
|||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
|
|
||||||
public class MMOCore extends LuminePlugin {
|
public class MMOCore extends JavaPlugin {
|
||||||
public static MMOCore plugin;
|
public static MMOCore plugin;
|
||||||
|
|
||||||
public final WaypointManager waypointManager = new WaypointManager();
|
public final WaypointManager waypointManager = new WaypointManager();
|
||||||
public final SoundManager soundManager = new SoundManager();
|
public final SoundManager soundManager = new SoundManager();
|
||||||
public final RequestManager requestManager = new RequestManager();
|
public final RequestManager requestManager = new RequestManager();
|
||||||
public final ConfigItemManager configItems = new ConfigItemManager();
|
public final ConfigItemManager configItems = new ConfigItemManager();
|
||||||
public final PlayerActionBar actionBarManager = new PlayerActionBar();
|
public final PlayerActionBar actionBarManager = new PlayerActionBar();
|
||||||
public final SkillManager skillManager = new SkillManager();
|
public final SkillManager skillManager = new SkillManager();
|
||||||
public final ClassManager classManager = new ClassManager();
|
public final ClassManager classManager = new ClassManager();
|
||||||
public final DropTableManager dropTableManager = new DropTableManager();
|
public final DropTableManager dropTableManager = new DropTableManager();
|
||||||
public final BoosterManager boosterManager = new BoosterManager();
|
public final BoosterManager boosterManager = new BoosterManager();
|
||||||
public final AttributeManager attributeManager = new AttributeManager();
|
public final AttributeManager attributeManager = new AttributeManager();
|
||||||
public final PartyManager partyManager = new PartyManager();
|
public final PartyManager partyManager = new PartyManager();
|
||||||
public final QuestManager questManager = new QuestManager();
|
public final QuestManager questManager = new QuestManager();
|
||||||
public final ProfessionManager professionManager = new ProfessionManager();
|
public final ProfessionManager professionManager = new ProfessionManager();
|
||||||
public final ExperienceManager experience = new ExperienceManager();
|
public final ExperienceManager experience = new ExperienceManager();
|
||||||
public final LootChestManager lootChests = new LootChestManager();
|
public final LootChestManager lootChests = new LootChestManager();
|
||||||
public final MMOLoadManager loadManager = new MMOLoadManager();
|
public final MMOLoadManager loadManager = new MMOLoadManager();
|
||||||
public final RestrictionManager restrictionManager = new RestrictionManager();
|
public final RestrictionManager restrictionManager = new RestrictionManager();
|
||||||
public final SkillTreeManager skillTreeManager = new SkillTreeManager();
|
public final SkillTreeManager skillTreeManager = new SkillTreeManager();
|
||||||
|
|
||||||
// Profession managers
|
// Profession managers
|
||||||
public final CustomBlockManager mineManager = new CustomBlockManager();
|
public final CustomBlockManager mineManager = new CustomBlockManager();
|
||||||
public final FishingManager fishingManager = new FishingManager();
|
public final FishingManager fishingManager = new FishingManager();
|
||||||
public final AlchemyManager alchemyManager = new AlchemyManager();
|
public final AlchemyManager alchemyManager = new AlchemyManager();
|
||||||
public final EnchantManager enchantManager = new EnchantManager();
|
public final EnchantManager enchantManager = new EnchantManager();
|
||||||
public final SmithingManager smithingManager = new SmithingManager();
|
public final SmithingManager smithingManager = new SmithingManager();
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
public ConfigManager configManager;
|
public ConfigManager configManager;
|
||||||
public VaultEconomy economy;
|
public VaultEconomy economy;
|
||||||
public RegionHandler regionHandler = new DefaultRegionHandler();
|
public RegionHandler regionHandler = new DefaultRegionHandler();
|
||||||
public PlaceholderParser placeholderParser = new DefaultParser();
|
public PlaceholderParser placeholderParser = new DefaultParser();
|
||||||
public DataProvider dataProvider = new YAMLDataProvider();
|
public DataProvider dataProvider = new YAMLDataProvider();
|
||||||
|
|
||||||
// Modules
|
// Modules
|
||||||
@NotNull
|
@NotNull
|
||||||
public PartyModule partyModule;
|
public PartyModule partyModule;
|
||||||
|
public GuildModule guildModule;
|
||||||
|
public boolean shouldDebugSQL = false;
|
||||||
|
|
||||||
public boolean shouldDebugSQL = false;
|
private static final int MYTHICLIB_COMPATIBILITY_INDEX = 7;
|
||||||
|
|
||||||
private static final int MYTHICLIB_COMPATIBILITY_INDEX = 7;
|
public MMOCore() {
|
||||||
|
plugin = this;
|
||||||
|
}
|
||||||
|
|
||||||
public MMOCore() {
|
@Override
|
||||||
plugin = this;
|
public void onLoad() {
|
||||||
}
|
|
||||||
|
|
||||||
public void load() {
|
|
||||||
|
|
||||||
// Check if the ML build matches
|
|
||||||
if (MYTHICLIB_COMPATIBILITY_INDEX != MythicLib.MMOCORE_COMPATIBILITY_INDEX) {
|
|
||||||
getLogger().log(Level.WARNING, "Your versions of MythicLib and MMOCore do not match. Make sure you are using the latest builds of both plugins");
|
|
||||||
disable();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Register target restrictions due to MMOCore in MythicLib
|
|
||||||
MythicLib.plugin.getEntities().registerRestriction(new MMOCoreTargetRestriction());
|
|
||||||
|
|
||||||
// Register extra objective, drop items...
|
|
||||||
if (Bukkit.getPluginManager().getPlugin("WorldGuard") != null)
|
|
||||||
loadManager.registerLoader(new WorldGuardMMOLoader());
|
|
||||||
|
|
||||||
if (Bukkit.getPluginManager().getPlugin("Citizens") != null)
|
|
||||||
loadManager.registerLoader(new CitizensMMOLoader());
|
|
||||||
|
|
||||||
if (Bukkit.getPluginManager().getPlugin("Vault") != null) loadManager.registerLoader(new VaultMMOLoader());
|
|
||||||
|
|
||||||
if (Bukkit.getPluginManager().getPlugin("MythicMobs") != null)
|
|
||||||
loadManager.registerLoader(new MythicMobsMMOLoader());
|
|
||||||
}
|
|
||||||
|
|
||||||
public void enable() {
|
|
||||||
new SpigotPlugin(70575, this).checkForUpdate();
|
|
||||||
new Metrics(this);
|
|
||||||
saveDefaultConfig();
|
|
||||||
|
|
||||||
final int configVersion = getConfig().contains("config-version", true) ? getConfig().getInt("config-version") : -1;
|
|
||||||
final int defConfigVersion = getConfig().getDefaults().getInt("config-version");
|
|
||||||
if (configVersion != defConfigVersion) {
|
|
||||||
getLogger().warning("You may be using an outdated config.yml!");
|
|
||||||
getLogger().warning("(Your config version: '" + configVersion + "' | Expected config version: '" + defConfigVersion + "')");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (getConfig().isConfigurationSection("mysql") && getConfig().getBoolean("mysql.enabled"))
|
|
||||||
dataProvider = new MySQLDataProvider(getConfig());
|
|
||||||
shouldDebugSQL = getConfig().getBoolean("mysql.debug");
|
|
||||||
|
|
||||||
if (getConfig().isConfigurationSection("default-playerdata"))
|
|
||||||
dataProvider.getDataManager().loadDefaultData(getConfig().getConfigurationSection("default-playerdata"));
|
|
||||||
|
|
||||||
if (Bukkit.getPluginManager().getPlugin("Vault") != null) economy = new VaultEconomy();
|
|
||||||
|
|
||||||
if (Bukkit.getPluginManager().getPlugin("PlaceholderAPI") != null) {
|
|
||||||
placeholderParser = new PlaceholderAPIParser();
|
|
||||||
getLogger().log(Level.INFO, "Hooked onto PlaceholderAPI");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (Bukkit.getPluginManager().getPlugin("Citizens") != null) {
|
|
||||||
Bukkit.getPluginManager().registerEvents(new CitizenInteractEventListener(), this);
|
|
||||||
getLogger().log(Level.INFO, "Hooked onto Citizens");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (Bukkit.getPluginManager().getPlugin("WorldGuard") != null) {
|
|
||||||
regionHandler = new WorldGuardRegionHandler();
|
|
||||||
getLogger().log(Level.INFO, "Hooked onto WorldGuard");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (Bukkit.getPluginManager().getPlugin("MythicMobs") != null) {
|
|
||||||
Bukkit.getServer().getPluginManager().registerEvents(new MythicHook(), this);
|
|
||||||
MMOCore.plugin.getLogger().log(Level.INFO, "Hooked onto MythicMobs");
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Resource regeneration. Must check if entity is dead otherwise regen will make
|
|
||||||
* the 'respawn' button glitched plus HURT entity effect bug
|
|
||||||
*/
|
|
||||||
new BukkitRunnable() {
|
|
||||||
public void run() {
|
|
||||||
for (PlayerData player : PlayerData.getAll())
|
|
||||||
if (player.isOnline() && !player.getPlayer().isDead())
|
|
||||||
for (PlayerResource resource : PlayerResource.values()) {
|
|
||||||
double regenAmount = player.getProfess().getHandler(resource).getRegen(player);
|
|
||||||
if (regenAmount != 0)
|
|
||||||
resource.regen(player, regenAmount);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}.runTaskTimer(MMOCore.plugin, 100, 20);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Clean active loot chests every 5 minutes. Cannot register this runnable in
|
|
||||||
* the loot chest manager because it is instanced when the plugin loads
|
|
||||||
*/
|
|
||||||
new BukkitRunnable() {
|
|
||||||
public void run() {
|
|
||||||
Iterator<LootChest> iterator = lootChests.getActive().iterator();
|
|
||||||
while (iterator.hasNext()) {
|
|
||||||
LootChest next = iterator.next();
|
|
||||||
if (next.shouldExpire()) {
|
|
||||||
iterator.remove();
|
|
||||||
next.expire(false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}.runTaskTimer(this, 5 * 60 * 20, 5 * 60 * 20);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* For the sake of the lord, make sure they aren't using MMOItems Mana and
|
|
||||||
* Stamina Addon...This should prevent a couple error reports produced by people
|
|
||||||
* not reading the installation guide...
|
|
||||||
*/
|
|
||||||
if (Bukkit.getPluginManager().getPlugin("MMOMana") != null) {
|
|
||||||
getLogger().log(Level.SEVERE, ChatColor.DARK_RED + "MMOCore is not meant to be used with MMOItems ManaAndStamina");
|
|
||||||
getLogger().log(Level.SEVERE, ChatColor.DARK_RED + "Please read the installation guide!");
|
|
||||||
Bukkit.broadcastMessage(ChatColor.DARK_RED + "[MMOCore] MMOCore is not meant to be used with MMOItems ManaAndStamina");
|
|
||||||
Bukkit.broadcastMessage(ChatColor.DARK_RED + "[MMOCore] Please read the installation guide!");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
initializePlugin(false);
|
|
||||||
|
|
||||||
if (getConfig().getBoolean("vanilla-exp-redirection.enabled"))
|
|
||||||
Bukkit.getPluginManager().registerEvents(new RedirectVanillaExp(getConfig().getDouble("vanilla-exp-redirection.ratio")), this);
|
|
||||||
|
|
||||||
// Enable debug mode for extra debug tools
|
|
||||||
if (getConfig().contains("debug")) {
|
|
||||||
DebugMode.setLevel(getConfig().getInt("debug", 0));
|
|
||||||
DebugMode.enableActionBar();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Load quest module
|
|
||||||
try {
|
|
||||||
String questPluginName = UtilityMethods.enumName(getConfig().getString("quest-plugin"));
|
|
||||||
PartyModuleType moduleType = PartyModuleType.valueOf(questPluginName);
|
|
||||||
Validate.isTrue(moduleType.isValid(), "Plugin '" + moduleType.name() + "' is not installed");
|
|
||||||
partyModule = moduleType.provideModule();
|
|
||||||
} catch (RuntimeException exception) {
|
|
||||||
getLogger().log(Level.WARNING, "Could not initialize quest module: " + exception.getMessage());
|
|
||||||
partyModule = new MMOCorePartyModule();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
// Register MMOCore-specific objects
|
||||||
|
MythicLib.plugin.getEntities().registerRestriction(new MMOCoreTargetRestriction());
|
||||||
|
MythicLib.plugin.getModifiers().registerModifierType("attribute", configObject -> new AttributeModifier(configObject));
|
||||||
|
|
||||||
// Load party module
|
// Skill creation
|
||||||
try {
|
MythicLib.plugin.getSkills().registerMechanic("mana", config -> new ManaMechanic(config));
|
||||||
String partyPluginName = UtilityMethods.enumName(getConfig().getString("party-plugin"));
|
MythicLib.plugin.getSkills().registerMechanic("stamina", config -> new StaminaMechanic(config));
|
||||||
PartyModuleType moduleType = PartyModuleType.valueOf(partyPluginName);
|
MythicLib.plugin.getSkills().registerMechanic("stellium", config -> new StelliumMechanic(config));
|
||||||
Validate.isTrue(moduleType.isValid(), "Plugin '" + moduleType.name() + "' is not installed");
|
MythicLib.plugin.getSkills().registerMechanic("experience", config -> new ExperienceMechanic(config));
|
||||||
partyModule = moduleType.provideModule();
|
|
||||||
} catch (RuntimeException exception) {
|
|
||||||
getLogger().log(Level.WARNING, "Could not initialize party module: " + exception.getMessage());
|
|
||||||
partyModule = new MMOCorePartyModule();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Load guild module
|
// Register extra objective, drop items...
|
||||||
try {
|
if (Bukkit.getPluginManager().getPlugin("WorldGuard") != null)
|
||||||
String pluginName = UtilityMethods.enumName(getConfig().getString("guild-plugin"));
|
loadManager.registerLoader(new WorldGuardMMOLoader());
|
||||||
GuildModuleType moduleType = GuildModuleType.valueOf(pluginName);
|
|
||||||
Validate.isTrue(moduleType.isValid(), "Plugin '" + moduleType.name() + "' is not installed");
|
|
||||||
guildModule = moduleType.provideModule();
|
|
||||||
} catch (RuntimeException exception) {
|
|
||||||
getLogger().log(Level.WARNING, "Could not initialize guild module: " + exception.getMessage());
|
|
||||||
guildModule = new MMOCoreGuildModule();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Skill casting
|
if (Bukkit.getPluginManager().getPlugin("Citizens") != null)
|
||||||
try {
|
loadManager.registerLoader(new CitizensMMOLoader());
|
||||||
SkillCastingMode mode = SkillCastingMode.valueOf(UtilityMethods.enumName(getConfig().getString("skill-casting.mode")));
|
|
||||||
Bukkit.getPluginManager().registerEvents(mode.loadFromConfig(getConfig().getConfigurationSection("skill-casting")), this);
|
|
||||||
} catch (RuntimeException exception) {
|
|
||||||
getLogger().log(Level.WARNING, "Could not load skill casting: " + exception.getMessage());
|
|
||||||
}
|
|
||||||
|
|
||||||
if (configManager.overrideVanillaExp = getConfig().getBoolean("override-vanilla-exp"))
|
if (Bukkit.getPluginManager().getPlugin("Vault") != null) loadManager.registerLoader(new VaultMMOLoader());
|
||||||
Bukkit.getPluginManager().registerEvents(new VanillaExperienceOverride(), this);
|
|
||||||
|
|
||||||
if (getConfig().getBoolean("hotbar-swapping.enabled"))
|
if (Bukkit.getPluginManager().getPlugin("MythicMobs") != null)
|
||||||
try {
|
loadManager.registerLoader(new MythicMobsMMOLoader());
|
||||||
Bukkit.getPluginManager().registerEvents(new HotbarSwap(getConfig().getConfigurationSection("hotbar-swapping")), this);
|
}
|
||||||
} catch (RuntimeException exception) {
|
|
||||||
getLogger().log(Level.WARNING, "Could not load hotbar swapping: " + exception.getMessage());
|
|
||||||
}
|
|
||||||
|
|
||||||
if (getConfig().getBoolean("prevent-spawner-xp"))
|
public void enable() {
|
||||||
Bukkit.getPluginManager().registerEvents(new NoSpawnerEXP(), this);
|
new SpigotPlugin(70575, this).checkForUpdate();
|
||||||
|
new Metrics(this);
|
||||||
|
saveDefaultConfig();
|
||||||
|
|
||||||
if (getConfig().getBoolean("death-exp-loss.enabled"))
|
final int configVersion = getConfig().contains("config-version", true) ? getConfig().getInt("config-version") : -1;
|
||||||
Bukkit.getPluginManager().registerEvents(new DeathExperienceLoss(), this);
|
final int defConfigVersion = getConfig().getDefaults().getInt("config-version");
|
||||||
|
if (configVersion != defConfigVersion) {
|
||||||
|
getLogger().warning("You may be using an outdated config.yml!");
|
||||||
|
getLogger().warning("(Your config version: '" + configVersion + "' | Expected config version: '" + defConfigVersion + "')");
|
||||||
|
}
|
||||||
|
|
||||||
if (getConfig().getBoolean("shift-click-player-profile-check"))
|
if (getConfig().isConfigurationSection("mysql") && getConfig().getBoolean("mysql.enabled"))
|
||||||
Bukkit.getPluginManager().registerEvents(new PlayerProfileCheck(), this);
|
dataProvider = new MySQLDataProvider(getConfig());
|
||||||
|
shouldDebugSQL = getConfig().getBoolean("mysql.debug");
|
||||||
|
|
||||||
Bukkit.getPluginManager().registerEvents(new WaypointsListener(), this);
|
if (getConfig().isConfigurationSection("default-playerdata"))
|
||||||
Bukkit.getPluginManager().registerEvents(new PlayerListener(), this);
|
dataProvider.getDataManager().loadDefaultData(getConfig().getConfigurationSection("default-playerdata"));
|
||||||
Bukkit.getPluginManager().registerEvents(new GoldPouchesListener(), this);
|
|
||||||
Bukkit.getPluginManager().registerEvents(new BlockListener(), this);
|
|
||||||
Bukkit.getPluginManager().registerEvents(new LootableChestsListener(), this);
|
|
||||||
Bukkit.getPluginManager().registerEvents(new GuildListener(), this);
|
|
||||||
Bukkit.getPluginManager().registerEvents(new FishingListener(), this);
|
|
||||||
Bukkit.getPluginManager().registerEvents(new PlayerCollectStats(), this);
|
|
||||||
Bukkit.getPluginManager().registerEvents(new PlayerPressKeyListener(), this);
|
|
||||||
// Bukkit.getPluginManager().registerEvents(new ClassTriggers(), this);
|
|
||||||
|
|
||||||
/*
|
if (Bukkit.getPluginManager().getPlugin("Vault") != null) economy = new VaultEconomy();
|
||||||
* Initialize player data from all online players. This is very important to do
|
|
||||||
* that after registering all the professses otherwise the player datas can't
|
|
||||||
* recognize what profess the player has and professes will be lost
|
|
||||||
*/
|
|
||||||
Bukkit.getOnlinePlayers().forEach(player -> dataProvider.getDataManager().setup(player.getUniqueId()));
|
|
||||||
|
|
||||||
// load guild data after loading player data
|
if (Bukkit.getPluginManager().getPlugin("PlaceholderAPI") != null) {
|
||||||
dataProvider.getGuildManager().load();
|
placeholderParser = new PlaceholderAPIParser();
|
||||||
|
getLogger().log(Level.INFO, "Hooked onto PlaceholderAPI");
|
||||||
|
}
|
||||||
|
|
||||||
// Command
|
if (Bukkit.getPluginManager().getPlugin("Citizens") != null) {
|
||||||
try {
|
Bukkit.getPluginManager().registerEvents(new CitizenInteractEventListener(), this);
|
||||||
final Field bukkitCommandMap = Bukkit.getServer().getClass().getDeclaredField("commandMap");
|
getLogger().log(Level.INFO, "Hooked onto Citizens");
|
||||||
|
}
|
||||||
|
|
||||||
bukkitCommandMap.setAccessible(true);
|
if (Bukkit.getPluginManager().getPlugin("WorldGuard") != null) {
|
||||||
CommandMap commandMap = (CommandMap) bukkitCommandMap.get(Bukkit.getServer());
|
regionHandler = new WorldGuardRegionHandler();
|
||||||
|
getLogger().log(Level.INFO, "Hooked onto WorldGuard");
|
||||||
|
}
|
||||||
|
|
||||||
FileConfiguration config = new ConfigFile("commands").getConfig();
|
if (Bukkit.getPluginManager().getPlugin("MythicMobs") != null) {
|
||||||
|
Bukkit.getServer().getPluginManager().registerEvents(new MythicHook(), this);
|
||||||
|
MMOCore.plugin.getLogger().log(Level.INFO, "Hooked onto MythicMobs");
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Resource regeneration. Must check if entity is dead otherwise regen will make
|
||||||
|
* the 'respawn' button glitched plus HURT entity effect bug
|
||||||
|
*/
|
||||||
|
new BukkitRunnable() {
|
||||||
|
public void run() {
|
||||||
|
for (PlayerData player : PlayerData.getAll())
|
||||||
|
if (player.isOnline() && !player.getPlayer().isDead())
|
||||||
|
for (PlayerResource resource : PlayerResource.values()) {
|
||||||
|
double regenAmount = player.getProfess().getHandler(resource).getRegen(player);
|
||||||
|
if (regenAmount != 0)
|
||||||
|
resource.regen(player, regenAmount);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}.runTaskTimer(MMOCore.plugin, 100, 20);
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* For the sake of the lord, make sure they aren't using MMOItems Mana and
|
||||||
|
* Stamina Addon...This should prevent a couple error reports produced by people
|
||||||
|
* not reading the installation guide...
|
||||||
|
*/
|
||||||
|
if (Bukkit.getPluginManager().getPlugin("MMOMana") != null) {
|
||||||
|
getLogger().log(Level.SEVERE, ChatColor.DARK_RED + "MMOCore is not meant to be used with MMOItems ManaAndStamina");
|
||||||
|
getLogger().log(Level.SEVERE, ChatColor.DARK_RED + "Please read the installation guide!");
|
||||||
|
Bukkit.broadcastMessage(ChatColor.DARK_RED + "[MMOCore] MMOCore is not meant to be used with MMOItems ManaAndStamina");
|
||||||
|
Bukkit.broadcastMessage(ChatColor.DARK_RED + "[MMOCore] Please read the installation guide!");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
initializePlugin(false);
|
||||||
|
|
||||||
|
if (getConfig().getBoolean("vanilla-exp-redirection.enabled"))
|
||||||
|
Bukkit.getPluginManager().registerEvents(new RedirectVanillaExp(getConfig().getDouble("vanilla-exp-redirection.ratio")), this);
|
||||||
|
|
||||||
|
// Enable debug mode for extra debug tools
|
||||||
|
if (getConfig().contains("debug")) {
|
||||||
|
DebugMode.setLevel(getConfig().getInt("debug", 0));
|
||||||
|
DebugMode.enableActionBar();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Load quest module
|
||||||
|
try {
|
||||||
|
String questPluginName = UtilityMethods.enumName(getConfig().getString("quest-plugin"));
|
||||||
|
PartyModuleType moduleType = PartyModuleType.valueOf(questPluginName);
|
||||||
|
Validate.isTrue(moduleType.isValid(), "Plugin '" + moduleType.name() + "' is not installed");
|
||||||
|
partyModule = moduleType.provideModule();
|
||||||
|
} catch (RuntimeException exception) {
|
||||||
|
getLogger().log(Level.WARNING, "Could not initialize quest module: " + exception.getMessage());
|
||||||
|
partyModule = new MMOCorePartyModule();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Load party module
|
||||||
|
try {
|
||||||
|
String partyPluginName = UtilityMethods.enumName(getConfig().getString("party-plugin"));
|
||||||
|
PartyModuleType moduleType = PartyModuleType.valueOf(partyPluginName);
|
||||||
|
Validate.isTrue(moduleType.isValid(), "Plugin '" + moduleType.name() + "' is not installed");
|
||||||
|
partyModule = moduleType.provideModule();
|
||||||
|
} catch (RuntimeException exception) {
|
||||||
|
getLogger().log(Level.WARNING, "Could not initialize party module: " + exception.getMessage());
|
||||||
|
partyModule = new MMOCorePartyModule();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Load guild module
|
||||||
|
try {
|
||||||
|
String pluginName = UtilityMethods.enumName(getConfig().getString("guild-plugin"));
|
||||||
|
GuildModuleType moduleType = GuildModuleType.valueOf(pluginName);
|
||||||
|
Validate.isTrue(moduleType.isValid(), "Plugin '" + moduleType.name() + "' is not installed");
|
||||||
|
guildModule = moduleType.provideModule();
|
||||||
|
} catch (RuntimeException exception) {
|
||||||
|
getLogger().log(Level.WARNING, "Could not initialize guild module: " + exception.getMessage());
|
||||||
|
guildModule = new MMOCoreGuildModule();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Skill casting
|
||||||
|
try {
|
||||||
|
SkillCastingMode mode = SkillCastingMode.valueOf(UtilityMethods.enumName(getConfig().getString("skill-casting.mode")));
|
||||||
|
Bukkit.getPluginManager().registerEvents(mode.loadFromConfig(getConfig().getConfigurationSection("skill-casting")), this);
|
||||||
|
} catch (RuntimeException exception) {
|
||||||
|
getLogger().log(Level.WARNING, "Could not load skill casting: " + exception.getMessage());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (configManager.overrideVanillaExp = getConfig().getBoolean("override-vanilla-exp"))
|
||||||
|
Bukkit.getPluginManager().registerEvents(new VanillaExperienceOverride(), this);
|
||||||
|
|
||||||
|
if (getConfig().getBoolean("hotbar-swapping.enabled"))
|
||||||
|
try {
|
||||||
|
Bukkit.getPluginManager().registerEvents(new HotbarSwap(getConfig().getConfigurationSection("hotbar-swapping")), this);
|
||||||
|
} catch (RuntimeException exception) {
|
||||||
|
getLogger().log(Level.WARNING, "Could not load hotbar swapping: " + exception.getMessage());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (getConfig().getBoolean("prevent-spawner-xp"))
|
||||||
|
Bukkit.getPluginManager().registerEvents(new NoSpawnerEXP(), this);
|
||||||
|
|
||||||
|
if (getConfig().getBoolean("death-exp-loss.enabled"))
|
||||||
|
Bukkit.getPluginManager().registerEvents(new DeathExperienceLoss(), this);
|
||||||
|
|
||||||
|
if (getConfig().getBoolean("shift-click-player-profile-check"))
|
||||||
|
Bukkit.getPluginManager().registerEvents(new PlayerProfileCheck(), this);
|
||||||
|
|
||||||
|
Bukkit.getPluginManager().registerEvents(new WaypointsListener(), this);
|
||||||
|
Bukkit.getPluginManager().registerEvents(new PlayerListener(), this);
|
||||||
|
Bukkit.getPluginManager().registerEvents(new GoldPouchesListener(), this);
|
||||||
|
Bukkit.getPluginManager().registerEvents(new BlockListener(), this);
|
||||||
|
Bukkit.getPluginManager().registerEvents(new LootableChestsListener(), this);
|
||||||
|
Bukkit.getPluginManager().registerEvents(new GuildListener(), this);
|
||||||
|
Bukkit.getPluginManager().registerEvents(new FishingListener(), this);
|
||||||
|
Bukkit.getPluginManager().registerEvents(new PlayerCollectStats(), this);
|
||||||
|
Bukkit.getPluginManager().registerEvents(new PlayerPressKeyListener(), this);
|
||||||
|
// Bukkit.getPluginManager().registerEvents(new ClassTriggers(), this);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Initialize player data from all online players. This is very important to do
|
||||||
|
* that after registering all the professses otherwise the player datas can't
|
||||||
|
* recognize what profess the player has and professes will be lost
|
||||||
|
*/
|
||||||
|
Bukkit.getOnlinePlayers().forEach(player -> dataProvider.getDataManager().setup(player.getUniqueId()));
|
||||||
|
|
||||||
|
// load guild data after loading player data
|
||||||
|
dataProvider.getGuildManager().load();
|
||||||
|
|
||||||
|
// Command
|
||||||
|
try {
|
||||||
|
final Field bukkitCommandMap = Bukkit.getServer().getClass().getDeclaredField("commandMap");
|
||||||
|
|
||||||
|
bukkitCommandMap.setAccessible(true);
|
||||||
|
CommandMap commandMap = (CommandMap) bukkitCommandMap.get(Bukkit.getServer());
|
||||||
|
|
||||||
|
FileConfiguration config = new ConfigFile("commands").getConfig();
|
||||||
|
|
||||||
if (config.contains("player"))
|
if (config.contains("player"))
|
||||||
commandMap.register("mmocore", new PlayerStatsCommand(config.getConfigurationSection("player")));
|
commandMap.register("mmocore", new PlayerStatsCommand(config.getConfigurationSection("player")));
|
||||||
@ -352,128 +345,128 @@ public class MMOCore extends LuminePlugin {
|
|||||||
ex.printStackTrace();
|
ex.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
||||||
MMOCoreCommandTreeRoot mmoCoreCommand = new MMOCoreCommandTreeRoot();
|
MMOCoreCommandTreeRoot mmoCoreCommand = new MMOCoreCommandTreeRoot();
|
||||||
getCommand("mmocore").setExecutor(mmoCoreCommand);
|
getCommand("mmocore").setExecutor(mmoCoreCommand);
|
||||||
getCommand("mmocore").setTabCompleter(mmoCoreCommand);
|
getCommand("mmocore").setTabCompleter(mmoCoreCommand);
|
||||||
|
|
||||||
if (getConfig().getBoolean("auto-save.enabled")) {
|
if (getConfig().getBoolean("auto-save.enabled")) {
|
||||||
int autosave = getConfig().getInt("auto-save.interval") * 20;
|
int autosave = getConfig().getInt("auto-save.interval") * 20;
|
||||||
new BukkitRunnable() {
|
new BukkitRunnable() {
|
||||||
public void run() {
|
public void run() {
|
||||||
|
|
||||||
// Save player data
|
// Save player data
|
||||||
for (PlayerData data : PlayerData.getAll())
|
for (PlayerData data : PlayerData.getAll())
|
||||||
if (data.isFullyLoaded())
|
if (data.isFullyLoaded())
|
||||||
dataProvider.getDataManager().saveData(data);
|
dataProvider.getDataManager().saveData(data);
|
||||||
|
|
||||||
// Save guild info
|
// Save guild info
|
||||||
for (Guild guild : dataProvider.getGuildManager().getAll())
|
for (Guild guild : dataProvider.getGuildManager().getAll())
|
||||||
dataProvider.getGuildManager().save(guild);
|
dataProvider.getGuildManager().save(guild);
|
||||||
}
|
}
|
||||||
}.runTaskTimerAsynchronously(MMOCore.plugin, autosave, autosave);
|
}.runTaskTimerAsynchronously(MMOCore.plugin, autosave, autosave);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void disable() {
|
@Override
|
||||||
|
public void onDisable() {
|
||||||
|
|
||||||
// Save player data
|
// Save player data
|
||||||
for (PlayerData data : PlayerData.getAll())
|
for (PlayerData data : PlayerData.getAll())
|
||||||
if (data.isFullyLoaded()) {
|
if (data.isFullyLoaded()) {
|
||||||
data.close();
|
data.close();
|
||||||
dataProvider.getDataManager().saveData(data);
|
dataProvider.getDataManager().saveData(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Save guild info
|
// Save guild info
|
||||||
for (Guild guild : dataProvider.getGuildManager().getAll())
|
for (Guild guild : dataProvider.getGuildManager().getAll())
|
||||||
dataProvider.getGuildManager().save(guild);
|
dataProvider.getGuildManager().save(guild);
|
||||||
|
|
||||||
// Close MySQL data provider (memory leaks)
|
// Close MySQL data provider (memory leaks)
|
||||||
if (dataProvider instanceof MySQLDataProvider)
|
if (dataProvider instanceof MySQLDataProvider)
|
||||||
((MySQLDataProvider) dataProvider).close();
|
((MySQLDataProvider) dataProvider).close();
|
||||||
|
|
||||||
// Reset active blocks
|
// Reset active blocks
|
||||||
mineManager.resetRemainingBlocks();
|
mineManager.resetRemainingBlocks();
|
||||||
|
|
||||||
// Clear spawned loot chests
|
// Clear spawned loot chests
|
||||||
lootChests.getActive().forEach(chest -> chest.expire(false));
|
lootChests.getActive().forEach(chest -> chest.expire(false));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called either when the server starts when initializing the manager for
|
* Called either when the server starts when initializing the manager for
|
||||||
* the first time, or when issuing a plugin reload; in that case, stuff
|
* the first time, or when issuing a plugin reload; in that case, stuff
|
||||||
* like listeners must all be cleared before.
|
* like listeners must all be cleared before.
|
||||||
*
|
* <p>
|
||||||
* Also see {@link MMOCoreManager}
|
* Also see {@link MMOCoreManager}
|
||||||
*
|
*
|
||||||
* @param clearBefore True when issuing a plugin reload
|
* @param clearBefore True when issuing a plugin reload
|
||||||
*/
|
*/
|
||||||
public void initializePlugin(boolean clearBefore) {
|
public void initializePlugin(boolean clearBefore) {
|
||||||
if (clearBefore)
|
if (clearBefore)
|
||||||
reloadConfig();
|
reloadConfig();
|
||||||
|
|
||||||
configManager = new ConfigManager();
|
configManager = new ConfigManager();
|
||||||
|
|
||||||
if (clearBefore)
|
if (clearBefore)
|
||||||
MythicLib.plugin.getSkills().initialize(true);
|
MythicLib.plugin.getSkills().initialize(true);
|
||||||
skillManager.initialize(clearBefore);
|
skillManager.initialize(clearBefore);
|
||||||
mineManager.initialize(clearBefore);
|
mineManager.initialize(clearBefore);
|
||||||
partyManager.initialize(clearBefore);
|
partyManager.initialize(clearBefore);
|
||||||
attributeManager.initialize(clearBefore);
|
attributeManager.initialize(clearBefore);
|
||||||
|
|
||||||
// Experience must be loaded before professions and classes
|
// Experience must be loaded before professions and classes
|
||||||
experience.initialize(clearBefore);
|
experience.initialize(clearBefore);
|
||||||
|
|
||||||
// Drop tables must be loaded before professions
|
// Drop tables must be loaded before professions
|
||||||
dropTableManager.initialize(clearBefore);
|
dropTableManager.initialize(clearBefore);
|
||||||
|
|
||||||
professionManager.initialize(clearBefore);
|
professionManager.initialize(clearBefore);
|
||||||
classManager.initialize(clearBefore);
|
classManager.initialize(clearBefore);
|
||||||
|
|
||||||
InventoryManager.load();
|
InventoryManager.load();
|
||||||
|
|
||||||
questManager.initialize(clearBefore);
|
questManager.initialize(clearBefore);
|
||||||
lootChests.initialize(clearBefore);
|
lootChests.initialize(clearBefore);
|
||||||
restrictionManager.initialize(clearBefore);
|
restrictionManager.initialize(clearBefore);
|
||||||
waypointManager.initialize(clearBefore);
|
waypointManager.initialize(clearBefore);
|
||||||
requestManager.initialize(clearBefore);
|
requestManager.initialize(clearBefore);
|
||||||
soundManager.initialize(clearBefore);
|
soundManager.initialize(clearBefore);
|
||||||
configItems.initialize(clearBefore);
|
configItems.initialize(clearBefore);
|
||||||
|
|
||||||
if (getConfig().isConfigurationSection("action-bar"))
|
if (getConfig().isConfigurationSection("action-bar"))
|
||||||
actionBarManager.reload(getConfig().getConfigurationSection("action-bar"));
|
actionBarManager.reload(getConfig().getConfigurationSection("action-bar"));
|
||||||
|
|
||||||
StatType.load();
|
|
||||||
|
|
||||||
if (clearBefore)
|
if (clearBefore)
|
||||||
PlayerData.getAll().forEach(PlayerData::update);
|
PlayerData.getAll().forEach(PlayerData::update);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void log(String message) {
|
public static void log(String message) {
|
||||||
log(Level.INFO, message);
|
log(Level.INFO, message);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void debug(int value, String message) {
|
public static void debug(int value, String message) {
|
||||||
debug(value, Level.INFO, message);
|
debug(value, Level.INFO, message);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void log(Level level, String message) {
|
public static void log(Level level, String message) {
|
||||||
plugin.getLogger().log(level, message);
|
plugin.getLogger().log(level, message);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void debug(int value, Level level, String message) {
|
public static void debug(int value, Level level, String message) {
|
||||||
if (DebugMode.level > (value - 1)) plugin.getLogger().log(level, message);
|
if (DebugMode.level > (value - 1)) plugin.getLogger().log(level, message);
|
||||||
}
|
}
|
||||||
|
|
||||||
public File getJarFile() {
|
public File getJarFile() {
|
||||||
return getFile();
|
return getFile();
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean hasEconomy() {
|
public boolean hasEconomy() {
|
||||||
return economy != null && economy.isValid();
|
return economy != null && economy.isValid();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void sqlDebug(String s) {
|
public static void sqlDebug(String s) {
|
||||||
if(!MMOCore.plugin.shouldDebugSQL) return;
|
if (!MMOCore.plugin.shouldDebugSQL) return;
|
||||||
MMOCore.plugin.getLogger().warning("- [SQL Debug] " + s);
|
MMOCore.plugin.getLogger().warning("- [SQL Debug] " + s);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -278,7 +278,7 @@ public class PlayerData extends OfflinePlayerData implements Closable, Experienc
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Bukkit.broadcastMessage(playerStats.getStat(StatType.HEALTH_REGENERATION)+"");
|
Bukkit.broadcastMessage(playerStats.getStat("HEALTH_REGENERATION")+"");
|
||||||
|
|
||||||
if (nodeStates.get(node) == NodeState.UNLOCKABLE)
|
if (nodeStates.get(node) == NodeState.UNLOCKABLE)
|
||||||
setNodeState(node, NodeState.UNLOCKED);
|
setNodeState(node, NodeState.UNLOCKED);
|
||||||
@ -812,8 +812,9 @@ public class PlayerData extends OfflinePlayerData implements Closable, Experienc
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
value = MMOCore.plugin.boosterManager.calculateExp(null, value);
|
// Apply buffs AFTER splitting exp
|
||||||
value *= 1 + getStats().getStat(StatType.ADDITIONAL_EXPERIENCE) / 100;
|
value *= (1 + getStats().getStat("ADDITIONAL_EXPERIENCE") / 100) * MMOCore.plugin.boosterManager.getMultiplier(null);
|
||||||
|
|
||||||
|
|
||||||
// Splitting exp through party members
|
// Splitting exp through party members
|
||||||
AbstractParty party;
|
AbstractParty party;
|
||||||
|
Loading…
Reference in New Issue
Block a user