From d1298c0cd271c2451c1a49fbbe7befb494f0a80d Mon Sep 17 00:00:00 2001 From: nossr50 Date: Mon, 13 May 2019 03:49:33 -0700 Subject: [PATCH] Further cleanup --- .../hocon/experience/ConfigExperience.java | 19 ++---------------- .../nossr50/core/DynamicSettingsManager.java | 4 ++-- .../gmail/nossr50/core/MetadataConstants.java | 2 +- .../nossr50/listeners/EntityListener.java | 2 +- src/main/java/com/gmail/nossr50/mcMMO.java | 20 +++++++++---------- .../nossr50/util/skills/CombatUtils.java | 8 ++++---- 6 files changed, 20 insertions(+), 35 deletions(-) diff --git a/src/main/java/com/gmail/nossr50/config/hocon/experience/ConfigExperience.java b/src/main/java/com/gmail/nossr50/config/hocon/experience/ConfigExperience.java index ef016b552..da4229599 100644 --- a/src/main/java/com/gmail/nossr50/config/hocon/experience/ConfigExperience.java +++ b/src/main/java/com/gmail/nossr50/config/hocon/experience/ConfigExperience.java @@ -1,6 +1,7 @@ package com.gmail.nossr50.config.hocon.experience; import com.gmail.nossr50.datatypes.experience.CustomXPPerk; +import com.gmail.nossr50.datatypes.experience.SpecialXPKey; import ninja.leaping.configurate.objectmapping.Setting; import ninja.leaping.configurate.objectmapping.serialize.ConfigSerializable; @@ -162,7 +163,7 @@ public class ConfigExperience { return getConfigExperienceSkills().getCombatExperienceMap(); } - public HashMap getSpecialCombatExperienceMap() { + public HashMap getSpecialCombatExperienceMap() { return configExperienceSkills.getSpecialCombatExperienceMap(); } @@ -190,22 +191,6 @@ public class ConfigExperience { return getConfigExperienceSkills().getShakeXP(); } - public Float getSpawnedMobXPMult() { - return getConfigExperienceSkills().getSpawnedMobXPMult(); - } - - public Float getPlayerBredMobsXPMult() { - return getExperienceCombat().getPlayerBredMobsXPMult(); - } - - public Float getPVPXPMult() { - return getConfigExperienceSkills().getPVPXPMult(); - } - - public Float getAnimalsXPMult() { - return getConfigExperienceSkills().getAnimalsXPMult(); - } - public ConfigExperienceSkills getConfigExperienceSkills() { return configExperienceSkills; } diff --git a/src/main/java/com/gmail/nossr50/core/DynamicSettingsManager.java b/src/main/java/com/gmail/nossr50/core/DynamicSettingsManager.java index 68fb5754c..d39390470 100644 --- a/src/main/java/com/gmail/nossr50/core/DynamicSettingsManager.java +++ b/src/main/java/com/gmail/nossr50/core/DynamicSettingsManager.java @@ -115,8 +115,8 @@ public class DynamicSettingsManager { */ public void registerBonusDrops() { bonusDropManager.addToWhitelistByNameID(mcMMO.getConfigManager().getConfigMining().getBonusDrops()); -// bonusDropManager.addToWhitelistByNameID(configHerbalism.getBonusDrops()); -// bonusDropManager.addToWhitelistByNameID(configWoodcutting.getBonusDrops()); +// bonusDropManager.addToWhitelistByNameID(mcMMO.getConfigManager().getConfigHerbalism().getBonusDrops()); +// bonusDropManager.addToWhitelistByNameID(mcMMO.getConfigManager().getConfigWoodcutting().getBonusDrops()); } public RepairableManager getRepairableManager() { diff --git a/src/main/java/com/gmail/nossr50/core/MetadataConstants.java b/src/main/java/com/gmail/nossr50/core/MetadataConstants.java index 274cd7d61..d143842cd 100644 --- a/src/main/java/com/gmail/nossr50/core/MetadataConstants.java +++ b/src/main/java/com/gmail/nossr50/core/MetadataConstants.java @@ -27,7 +27,7 @@ public class MetadataConstants { public final static String PLAYER_DATA_METAKEY = "mcMMO: Player Data"; public final static String GREEN_THUMB_METAKEY = "mcMMO: Green Thumb"; public final static String DATABASE_PROCESSING_COMMAND_METAKEY = "mcMMO: Processing Database Command"; - public final static String BRED_ANIMAL_TRACKING_METAKEY = "mcMMO: Bred Animal"; + public final static String PETS_ANIMAL_TRACKING_METAKEY = "mcMMO: Pet Animal"; public static FixedMetadataValue metadataValue; //Gains value in onEnable diff --git a/src/main/java/com/gmail/nossr50/listeners/EntityListener.java b/src/main/java/com/gmail/nossr50/listeners/EntityListener.java index 0660450ac..c1a973f2c 100644 --- a/src/main/java/com/gmail/nossr50/listeners/EntityListener.java +++ b/src/main/java/com/gmail/nossr50/listeners/EntityListener.java @@ -629,7 +629,7 @@ public class EntityListener implements Listener { return; case BREEDING: - entity.setMetadata(MetadataConstants.BRED_ANIMAL_TRACKING_METAKEY, MetadataConstants.metadataValue); + entity.setMetadata(MetadataConstants.PETS_ANIMAL_TRACKING_METAKEY, MetadataConstants.metadataValue); return; default: diff --git a/src/main/java/com/gmail/nossr50/mcMMO.java b/src/main/java/com/gmail/nossr50/mcMMO.java index 41b9e7baa..5ba8fab3c 100644 --- a/src/main/java/com/gmail/nossr50/mcMMO.java +++ b/src/main/java/com/gmail/nossr50/mcMMO.java @@ -144,7 +144,7 @@ public class mcMMO extends JavaPlugin { formulaManager = new FormulaManager(); for (Player player : getServer().getOnlinePlayers()) { - new PlayerProfileLoadingTask(player).runTaskLaterAsynchronously(mcMMO.p, 1); // 1 Tick delay to ensure the player is marked as online before we begin loading + new PlayerProfileLoadingTask(player).runTaskLaterAsynchronously(this, 1); // 1 Tick delay to ensure the player is marked as online before we begin loading } debug("Version " + getDescription().getVersion() + " is enabled!"); @@ -154,7 +154,7 @@ public class mcMMO extends JavaPlugin { placeStore = ChunkManagerFactory.getChunkManager(); // Get our ChunkletManager - if (mcMMO.getConfigManager().getConfigParty().getPTP().isPtpWorldBasedPermissions()) { + if (getConfigManager().getConfigParty().getPTP().isPtpWorldBasedPermissions()) { Permissions.generateWorldTeleportPermissions(); } @@ -205,7 +205,7 @@ public class mcMMO extends JavaPlugin { PartyManager.saveParties(); // Save our parties //TODO: Needed? - if (mcMMO.getScoreboardSettings().getScoreboardsEnabled()) + if (getScoreboardSettings().getScoreboardsEnabled()) ScoreboardManager.teardownAll(); formulaManager.saveFormula(); @@ -221,7 +221,7 @@ public class mcMMO extends JavaPlugin { debug("Unregister all events..."); HandlerList.unregisterAll(this); // Cancel event registrations - if (mcMMO.getConfigManager().getConfigAutomatedBackups().isZipBackupsEnabled()) { + if (getConfigManager().getConfigAutomatedBackups().isZipBackupsEnabled()) { // Remove other tasks BEFORE starting the Backup, or we just cancel it straight away. try { ZipLibrary.mcMMOBackup(); @@ -318,8 +318,8 @@ public class mcMMO extends JavaPlugin { } @Deprecated - public static void setDatabaseManager(DatabaseManager databaseManager) { - mcMMO.databaseManager = databaseManager; + public static void setDatabaseManager(DatabaseManager newDatabaseManager) { + databaseManager = newDatabaseManager; } /** @@ -533,7 +533,7 @@ public class mcMMO extends JavaPlugin { new SaveTimerTask().runTaskTimer(this, saveIntervalTicks, saveIntervalTicks); // Cleanup the backups folder - new CleanBackupsTask().runTaskAsynchronously(mcMMO.p); + new CleanBackupsTask().runTaskAsynchronously(this); // Bleed timer (Runs every 0.5 seconds) new BleedTimerTask().runTaskTimer(this, Misc.TICK_CONVERSION_FACTOR, (Misc.TICK_CONVERSION_FACTOR / 2)); @@ -541,14 +541,14 @@ public class mcMMO extends JavaPlugin { // Old & Powerless User remover long purgeIntervalTicks = getConfigManager().getConfigDatabase().getConfigSectionCleaning().getPurgeInterval() * 60L * 60L * Misc.TICK_CONVERSION_FACTOR; - if (mcMMO.getDatabaseCleaningSettings().isOnlyPurgeAtStartup()) { + if (getDatabaseCleaningSettings().isOnlyPurgeAtStartup()) { new UserPurgeTask().runTaskLaterAsynchronously(this, 2 * Misc.TICK_CONVERSION_FACTOR); // Start 2 seconds after startup. } else if (purgeIntervalTicks > 0) { new UserPurgeTask().runTaskTimerAsynchronously(this, purgeIntervalTicks, purgeIntervalTicks); } //Party System Stuff - if (mcMMO.configManager.getConfigParty().isPartySystemEnabled()) { + if (configManager.getConfigParty().isPartySystemEnabled()) { // Automatically remove old members from parties long kickIntervalTicks = getConfigManager().getConfigParty().getPartyCleanup().getPartyAutoKickHoursInterval() * 60L * 60L * Misc.TICK_CONVERSION_FACTOR; @@ -563,7 +563,7 @@ public class mcMMO extends JavaPlugin { new PowerLevelUpdatingTask().runTaskTimer(this, 2 * Misc.TICK_CONVERSION_FACTOR, 2 * Misc.TICK_CONVERSION_FACTOR); // Clear the registered XP data so players can earn XP again - if (mcMMO.getConfigManager().getConfigExperience().get) { + if (getConfigManager().getConfigLeveling().getConfigLevelingDiminishedReturns().isDiminishedReturnsEnabled()) { new ClearRegisteredXPGainTask().runTaskTimer(this, 60, 60); } diff --git a/src/main/java/com/gmail/nossr50/util/skills/CombatUtils.java b/src/main/java/com/gmail/nossr50/util/skills/CombatUtils.java index ab7b128f0..cdbfedd98 100644 --- a/src/main/java/com/gmail/nossr50/util/skills/CombatUtils.java +++ b/src/main/java/com/gmail/nossr50/util/skills/CombatUtils.java @@ -544,7 +544,7 @@ public final class CombatUtils { Player defender = (Player) target; if (defender.isOnline() && SkillUtils.cooldownExpired(mcMMOPlayer.getRespawnATS(), Misc.PLAYER_RESPAWN_COOLDOWN_SECONDS)) { - baseXPMultiplier = 20 * mcMMO.getConfigManager().getConfigExperience().getPVPXPMult(); + baseXPMultiplier = 20 * mcMMO.getDynamicSettingsManager().getExperienceManager().getSpecialCombatXP(SpecialXPKey.PVP); } } else { /*if (mcMMO.getModManager().isCustomEntity(target)) { @@ -574,11 +574,11 @@ public final class CombatUtils { } if (target.hasMetadata(MetadataConstants.UNNATURAL_MOB_METAKEY)) { - baseXPMultiplier *= mcMMO.getConfigManager().getConfigExperience().getSpawnedMobXPMult(); + baseXPMultiplier *= mcMMO.getDynamicSettingsManager().getExperienceManager().getSpecialCombatXP(SpecialXPKey.SPAWNED); } - if (target.hasMetadata(MetadataConstants.BRED_ANIMAL_TRACKING_METAKEY)) { - baseXPMultiplier *= mcMMO.getConfigManager().getConfigExperience().getPlayerBredMobsXPMult(); + if (target.hasMetadata(MetadataConstants.PETS_ANIMAL_TRACKING_METAKEY)) { + baseXPMultiplier *= mcMMO.getDynamicSettingsManager().getExperienceManager().getSpecialCombatXP(SpecialXPKey.PETS); } xpGainReason = XPGainReason.PVE;