use of com.archyx.aureliumskills.leveler.Leveler in project AureliumSkills by Archy-X.
the class FishingLeveler method onFish.
@EventHandler(priority = EventPriority.HIGHEST)
public void onFish(PlayerFishEvent event) {
if (OptionL.isEnabled(Skills.FISHING)) {
// Check cancelled
if (OptionL.getBoolean(Option.FISHING_CHECK_CANCELLED)) {
if (event.isCancelled()) {
return;
}
}
if (event.getState().equals(State.CAUGHT_FISH)) {
Player player = event.getPlayer();
if (blockXpGain(player))
return;
if (event.getCaught() instanceof Item) {
ItemStack item = ((Item) event.getCaught()).getItemStack();
Leveler leveler = plugin.getLeveler();
FishingSource source = FishingSource.valueOf(item);
if (source != null) {
leveler.addXp(player, Skills.FISHING, getXp(player, source));
}
}
}
}
}
use of com.archyx.aureliumskills.leveler.Leveler in project AureliumSkills by Archy-X.
the class HealingLeveler method onConsume.
@EventHandler(priority = EventPriority.HIGHEST)
@SuppressWarnings("deprecation")
public void onConsume(PlayerItemConsumeEvent event) {
if (OptionL.isEnabled(Skills.HEALING)) {
// Check cancelled
if (OptionL.getBoolean(Option.HEALING_CHECK_CANCELLED)) {
if (event.isCancelled()) {
return;
}
}
if (blockXpGain(event.getPlayer()))
return;
Player player = event.getPlayer();
Skill skill = Skills.HEALING;
Leveler leveler = plugin.getLeveler();
if (event.getItem().getType().equals(Material.POTION)) {
if (event.getItem().getItemMeta() instanceof PotionMeta) {
PotionMeta meta = (PotionMeta) event.getItem().getItemMeta();
PotionData data = meta.getBasePotionData();
if (OptionL.getBoolean(Option.HEALING_EXCLUDE_NEGATIVE_POTIONS) && PotionUtil.isNegativePotion(data.getType())) {
return;
}
if (!data.getType().equals(PotionType.MUNDANE) && !data.getType().equals(PotionType.THICK) && !data.getType().equals(PotionType.WATER) && !data.getType().equals(PotionType.AWKWARD)) {
if (data.isExtended()) {
leveler.addXp(player, skill, getXp(player, HealingSource.DRINK_EXTENDED));
} else if (data.isUpgraded()) {
leveler.addXp(player, skill, getXp(player, HealingSource.DRINK_UPGRADED));
} else {
leveler.addXp(player, skill, getXp(player, HealingSource.DRINK_REGULAR));
}
}
}
} else if (XMaterial.isNewVersion()) {
if (event.getItem().getType().equals(Material.GOLDEN_APPLE)) {
leveler.addXp(player, skill, getXp(player, HealingSource.GOLDEN_APPLE));
} else if (event.getItem().getType().equals(XMaterial.ENCHANTED_GOLDEN_APPLE.parseMaterial())) {
leveler.addXp(player, skill, getXp(player, HealingSource.ENCHANTED_GOLDEN_APPLE));
}
} else {
if (event.getItem().getType().equals(Material.GOLDEN_APPLE)) {
MaterialData materialData = event.getItem().getData();
if (materialData != null) {
if (materialData.getData() == 0) {
leveler.addXp(player, skill, getXp(player, HealingSource.GOLDEN_APPLE));
} else if (materialData.getData() == 1) {
leveler.addXp(player, skill, getXp(player, HealingSource.ENCHANTED_GOLDEN_APPLE));
}
}
}
}
}
}
use of com.archyx.aureliumskills.leveler.Leveler in project AureliumSkills by Archy-X.
the class AureliumSkills method onEnable.
public void onEnable() {
// Registries
statRegistry = new StatRegistry();
registerStats();
skillRegistry = new SkillRegistry();
registerSkills();
sourceRegistry = new SourceRegistry();
itemRegistry = new ItemRegistry(this);
inventoryManager = new InventoryManager(this);
inventoryManager.init();
AureliumAPI.setPlugin(this);
// Checks for world guard
if (getServer().getPluginManager().isPluginEnabled("WorldGuard")) {
if (WorldGuardPlugin.inst().getDescription().getVersion().contains("7.0")) {
worldGuardEnabled = true;
worldGuardSupport = new WorldGuardSupport(this);
worldGuardSupport.loadRegions();
}
} else {
worldGuardEnabled = false;
}
// Checks for PlaceholderAPI
if (Bukkit.getPluginManager().isPluginEnabled("PlaceholderAPI")) {
new PlaceholderSupport(this).register();
placeholderAPIEnabled = true;
getLogger().info("PlaceholderAPI Support Enabled!");
} else {
placeholderAPIEnabled = false;
}
// Checks for Vault
if (setupEconomy()) {
vaultEnabled = true;
getLogger().info("Vault Support Enabled!");
} else {
vaultEnabled = false;
}
// Check for protocol lib
protocolLibEnabled = Bukkit.getPluginManager().isPluginEnabled("ProtocolLib");
// Check towny
townyEnabled = Bukkit.getPluginManager().isPluginEnabled("Towny");
townySupport = new TownySupport(this);
// Check for LuckPerms
luckPermsEnabled = Bukkit.getPluginManager().isPluginEnabled("LuckPerms");
if (luckPermsEnabled) {
luckPermsSupport = new LuckPermsSupport();
}
// Check for Slimefun
slimefunEnabled = Bukkit.getPluginManager().isPluginEnabled("Slimefun");
if (slimefunEnabled) {
getServer().getPluginManager().registerEvents(new SlimefunSupport(this), this);
getLogger().info("Slimefun Support Enabled!");
}
// Load health
Health health = new Health(this);
this.health = health;
getServer().getPluginManager().registerEvents(health, this);
// Load config
loadConfig();
this.requirementManager = new RequirementManager(this);
optionLoader = new OptionL(this);
optionLoader.loadOptions();
requirementManager.load();
this.modifierManager = new ModifierManager(this);
// Load sources
sourceManager = new SourceManager(this);
sourceManager.loadSources();
// Load boss bar
bossBar = new SkillBossBar(this);
bossBar.loadOptions();
// Checks for holographic displays
if (Bukkit.getPluginManager().isPluginEnabled("HolographicDisplays")) {
holographicDisplaysEnabled = true;
getServer().getPluginManager().registerEvents(new HologramSupport(this), this);
getLogger().info("HolographicDisplays Support Enabled!");
} else {
holographicDisplaysEnabled = false;
}
commandManager = new PaperCommandManager(this);
// Load items
itemRegistry.loadFromFile();
// Load languages
lang = new Lang(this);
getServer().getPluginManager().registerEvents(lang, this);
lang.init();
lang.loadEmbeddedMessages(commandManager);
lang.loadLanguages(commandManager);
// Load rewards
rewardManager = new RewardManager(this);
rewardManager.loadRewards();
// Registers Commands
registerCommands();
// Load menu
menuLoader = new MenuLoader(this);
try {
menuLoader.load();
} catch (IllegalAccessException | InstantiationException | InvocationTargetException e) {
e.printStackTrace();
getLogger().warning("Error loading menus!");
}
// Region manager
this.regionManager = new RegionManager(this);
// Registers events
registerEvents();
// Load ability manager
manaAbilityManager = new ManaAbilityManager(this);
getServer().getPluginManager().registerEvents(manaAbilityManager, this);
manaAbilityManager.init();
// Load ability options
abilityManager = new AbilityManager(this);
abilityManager.loadOptions();
// Load stats
Regeneration regeneration = new Regeneration(this);
getServer().getPluginManager().registerEvents(regeneration, this);
regeneration.startRegen();
regeneration.startSaturationRegen();
// Load Action Bar
if (protocolLibEnabled) {
protocolLibSupport = new ProtocolLibSupport();
new ActionBarCompatHandler(this).registerListeners();
}
actionBar.startUpdateActionBar();
// Initialize storage
this.playerManager = new PlayerManager(this);
this.leaderboardManager = new LeaderboardManager();
// Set proper storage provider
if (OptionL.getBoolean(Option.MYSQL_ENABLED)) {
MySqlStorageProvider mySqlStorageProvider = new MySqlStorageProvider(this);
mySqlStorageProvider.init();
MysqlBackup mysqlBackup = new MysqlBackup(this, mySqlStorageProvider);
if (!mySqlStorageProvider.localeColumnExists()) {
mysqlBackup.saveBackup(Bukkit.getConsoleSender(), false);
}
new LegacyMysqlToMysqlConverter(this, mySqlStorageProvider).convert();
setStorageProvider(mySqlStorageProvider);
this.backupProvider = mysqlBackup;
} else {
// Try to backup and convert legacy files
new LegacyFileBackup(this).saveBackup(Bukkit.getConsoleSender(), false);
new LegacyFileToYamlConverter(this).convert();
setStorageProvider(new YamlStorageProvider(this));
this.backupProvider = new YamlBackup(this);
}
// Initialize leaderboards
new BukkitRunnable() {
@Override
public void run() {
if (leaderboardManager.isNotSorting()) {
storageProvider.updateLeaderboards();
}
}
}.runTaskTimerAsynchronously(this, 0, 12000);
// Load leveler
leveler = new Leveler(this);
leveler.loadLevelRequirements();
// Load loot tables
lootTableManager = new LootTableManager(this);
// Load world manager
worldManager = new WorldManager(this);
worldManager.loadWorlds();
// B-stats
int pluginId = 8629;
new Metrics(this, pluginId);
getLogger().info("Aurelium Skills has been enabled");
if (System.currentTimeMillis() > ReleaseData.RELEASE_TIME + 21600000L) {
checkUpdates();
}
MinecraftVersion.disableUpdateCheck();
// Check if NBT API is supported for the version
if (MinecraftVersion.getVersion() == MinecraftVersion.UNKNOWN) {
getLogger().warning("NBT API is not yet supported for your Minecraft version, item modifier, requirement, and some other functionality is disabled!");
nbtAPIEnabled = false;
} else {
nbtAPIEnabled = true;
}
}
Aggregations