Fixed exp bar frozen when reloading MMOCore

This commit is contained in:
Indyuce 2022-08-17 18:57:04 +02:00
parent 056d1f57ec
commit 4e72967321
4 changed files with 18 additions and 24 deletions

View File

@ -111,11 +111,11 @@ public class MMOCore extends JavaPlugin {
MythicLib.plugin.getEntities().registerRestriction(new MMOCoreTargetRestriction());
MythicLib.plugin.getModifiers().registerModifierType("attribute", configObject -> new AttributeModifier(configObject));
// Skill creation
// Custom scripts
MythicLib.plugin.getSkills().registerMechanic("mana", config -> new ManaMechanic(config));
MythicLib.plugin.getSkills().registerMechanic("stamina", config -> new StaminaMechanic(config));
MythicLib.plugin.getSkills().registerMechanic("stellium", config -> new StelliumMechanic(config));
MythicLib.plugin.getSkills().registerMechanic("experience", config -> new ExperienceMechanic(config));
MythicLib.plugin.getSkills().registerMechanic("mmocore_experience", config -> new ExperienceMechanic(config));
// Register extra objective, drop items...
if (Bukkit.getPluginManager().getPlugin("WorldGuard") != null)

View File

@ -4,7 +4,6 @@ import io.lumine.mythic.lib.MythicLib;
import io.lumine.mythic.lib.api.player.MMOPlayerData;
import io.lumine.mythic.lib.player.cooldown.CooldownMap;
import io.lumine.mythic.lib.player.modifier.PlayerModifier;
import net.Indyuce.mmocore.party.provided.Party;
import net.Indyuce.mmocore.MMOCore;
import net.Indyuce.mmocore.api.ConfigMessage;
import net.Indyuce.mmocore.api.SoundEvent;
@ -32,6 +31,7 @@ import net.Indyuce.mmocore.experience.droptable.ExperienceTable;
import net.Indyuce.mmocore.guild.provided.Guild;
import net.Indyuce.mmocore.loot.chest.particle.SmallParticleEffect;
import net.Indyuce.mmocore.party.AbstractParty;
import net.Indyuce.mmocore.party.provided.Party;
import net.Indyuce.mmocore.player.Unlockable;
import net.Indyuce.mmocore.skill.ClassSkill;
import net.Indyuce.mmocore.skill.RegisteredSkill;
@ -526,7 +526,6 @@ public class PlayerData extends OfflinePlayerData implements Closable, Experienc
if (!MMOCore.plugin.configManager.overrideVanillaExp)
return;
getPlayer().sendExperienceChange(0.01f);
getPlayer().setLevel(getLevel());
getPlayer().setExp(Math.max(0, Math.min(1, (float) experience / (float) getLevelUpExperience())));
}

View File

@ -2,8 +2,8 @@ package net.Indyuce.mmocore.manager;
import io.lumine.mythic.lib.MythicLib;
import net.Indyuce.mmocore.MMOCore;
import net.Indyuce.mmocore.api.player.PlayerData;
import net.Indyuce.mmocore.api.ConfigFile;
import net.Indyuce.mmocore.api.player.PlayerData;
import net.Indyuce.mmocore.api.util.input.ChatInput;
import net.Indyuce.mmocore.api.util.input.PlayerInput;
import net.Indyuce.mmocore.api.util.input.PlayerInput.InputType;
@ -21,21 +21,14 @@ import java.util.logging.Level;
public class ConfigManager {
public final CommandVerbose commandVerbose = new CommandVerbose();
public boolean overrideVanillaExp, canCreativeCast, cobbleGeneratorXP, saveDefaultClassInfo, attributesAsClassInfo, splitProfessionExp, questBossBar;
public String partyChatPrefix, noSkillBoundPlaceholder;
public ChatColor staminaFull, staminaHalf, staminaEmpty;
public long combatLogTimer, lootChestExpireTime, lootChestPlayerCooldown, globalSkillCooldown;
public double lootChestsChanceWeight, fishingDropsChanceWeight;
public int maxPartyLevelDifference,maxBoundSkills;
public final boolean overrideVanillaExp, canCreativeCast, cobbleGeneratorXP, saveDefaultClassInfo, splitProfessionExp, questBossBar;
public final String partyChatPrefix, noSkillBoundPlaceholder;
public final ChatColor staminaFull, staminaHalf, staminaEmpty;
public final long combatLogTimer, lootChestExpireTime, lootChestPlayerCooldown, globalSkillCooldown;
public final double lootChestsChanceWeight, fishingDropsChanceWeight;
public final int maxPartyLevelDifference, maxBoundSkills;
private final FileConfiguration messages;
/*
* the instance must be created after the other managers since all it does
* is to update them based on the config except for the classes which are
* already loaded based on the config
*/
public ConfigManager() {
// loadDefaultFile("recipes", "brewing.yml");
// loadDefaultFile("recipes", "furnace.yml");
@ -74,6 +67,7 @@ public class ConfigManager {
loadDefaultFile("expcurves", "levels.txt");
loadDefaultFile("expcurves", "mining.txt");
}
if(!new File(MMOCore.plugin.getDataFolder()+"/skilltree").exists()) {
loadDefaultFile("skilltree","combat.yml");
}
@ -116,6 +110,7 @@ public class ConfigManager {
cobbleGeneratorXP = MMOCore.plugin.getConfig().getBoolean("should-cobblestone-generators-give-exp");
saveDefaultClassInfo = MMOCore.plugin.getConfig().getBoolean("save-default-class-info");
maxBoundSkills = MMOCore.plugin.getConfig().getInt("max-bound-skills",6);
overrideVanillaExp = MMOCore.plugin.getConfig().getBoolean("override-vanilla-exp");
}
private ChatColor getColorOrDefault(String key, ChatColor defaultColor) {

View File

@ -16,7 +16,7 @@ public class MMOCoreBukkit {
* all the listeners required for MMOCore to run
*/
public MMOCoreBukkit(MMOCore plugin) {
if (plugin.configManager.overrideVanillaExp = plugin.getConfig().getBoolean("override-vanilla-exp"))
if (plugin.configManager.overrideVanillaExp)
Bukkit.getPluginManager().registerEvents(new VanillaExperienceOverride(), plugin);
if (plugin.getConfig().getBoolean("hotbar-swapping.enabled"))