New options to config.yml

This commit is contained in:
Jules 2025-11-06 19:04:21 +01:00
parent e0b5f914d8
commit 5b2255356c
4 changed files with 46 additions and 27 deletions

View File

@ -738,9 +738,13 @@ public class PlayerData extends SynchronizedDataHolder implements OfflinePlayerD
public void setLevel(int level, @NotNull PlayerLevelChangeEvent.Reason reason) { public void setLevel(int level, @NotNull PlayerLevelChangeEvent.Reason reason) {
// Compute effective new level
final var oldLevel = getLevel(); final var oldLevel = getLevel();
var newLevel = Math.max(1, level); var newLevel = Math.max(1, level);
if (getProfess().hasMaxLevel()) newLevel = Math.min(getProfess().getMaxLevel(), newLevel); if (getProfess().hasMaxLevel()) newLevel = Math.min(getProfess().getMaxLevel(), newLevel);
if (oldLevel == newLevel) return; // Safeguard when changing class
this.level = newLevel; this.level = newLevel;
if (reason != PlayerLevelChangeEvent.Reason.CHOOSE_PROFILE) // No event, data is loaded async if (reason != PlayerLevelChangeEvent.Reason.CHOOSE_PROFILE) // No event, data is loaded async

View File

@ -316,32 +316,25 @@ public class SavedClassInformation implements ClassDataContainer {
// Patch player data // Patch player data
/////////////////////////////////////////////// ///////////////////////////////////////////////
final int targetLevel, final var conf = MMOCore.plugin.configManager;
targetSkillPoints, final var targetLevel = lastClassPlayed != null && conf.shareExp
targetAttributePoints, ? lastClassPlayed.level
targetSkillReallocationPoints, : level;
targetAttributeReallocationPoints; final var targetExp = lastClassPlayed != null && conf.shareExp
final double targetExp; ? lastClassPlayed.experience
: experience;
// Fetch info from last class final var targetSkillPoints = lastClassPlayed != null && conf.shareSkillPts
if (lastClassPlayed != null) { ? lastClassPlayed.skillPoints + lastClassPlayed.countSpentSkillPoints() - this.countSpentSkillPoints()
targetLevel = lastClassPlayed.level; : this.skillPoints;
targetExp = lastClassPlayed.experience; final var targetAttributePoints = lastClassPlayed != null && conf.shareAttributePts
targetSkillPoints = lastClassPlayed.skillPoints + lastClassPlayed.countSpentSkillPoints() - this.countSpentSkillPoints(); ? lastClassPlayed.attributePoints + lastClassPlayed.countSpentAttributePoints() - this.countSpentAttributePoints()
targetAttributePoints = lastClassPlayed.attributePoints + lastClassPlayed.countSpentAttributePoints() - this.countSpentAttributePoints(); : this.attributePoints;
targetSkillReallocationPoints = lastClassPlayed.skillReallocationPoints; final var targetSkillReallocationPoints = lastClassPlayed != null && conf.shareSkillReallocPts
targetAttributeReallocationPoints = lastClassPlayed.attributeReallocationPoints; ? lastClassPlayed.skillReallocationPoints
} : this.skillReallocationPoints;
final var targetAttributeReallocationPoints = lastClassPlayed != null && conf.shareAttributeReallocPts
// Fetch info from saved class info ? lastClassPlayed.attributeReallocationPoints
else { : this.attributeReallocationPoints;
targetLevel = level;
targetExp = experience;
targetSkillPoints = this.skillPoints;
targetAttributePoints = this.attributePoints;
targetSkillReallocationPoints = this.skillReallocationPoints;
targetAttributeReallocationPoints = this.attributeReallocationPoints;
}
/////////////////////////////////////////////// ///////////////////////////////////////////////
// Apply player data // Apply player data

View File

@ -25,7 +25,8 @@ import java.util.logging.Level;
public class ConfigManager { public class ConfigManager {
public boolean overrideVanillaExp, canCreativeCast, passiveSkillsNeedBinding, cobbleGeneratorXP, saveDefaultClassInfo, public boolean overrideVanillaExp, canCreativeCast, passiveSkillsNeedBinding, cobbleGeneratorXP, saveDefaultClassInfo,
splitMainExp, splitProfessionExp, disableQuestBossBar, pvpModeEnabled, pvpModeInvulnerabilityCanDamage, forceClassSelection, splitMainExp, splitProfessionExp, disableQuestBossBar, pvpModeEnabled, pvpModeInvulnerabilityCanDamage, forceClassSelection,
enableGlobalSkillTreeGUI, enableSpecificSkillTreeGUI, waypointAutoPathCalculation, waypointLinkReciprocity; enableGlobalSkillTreeGUI, enableSpecificSkillTreeGUI, waypointAutoPathCalculation, waypointLinkReciprocity,
shareExp, shareSkillPts, shareAttributePts, shareSkillReallocPts, shareAttributeReallocPts;
public String partyChatPrefix, noSkillBoundPlaceholder; public String partyChatPrefix, noSkillBoundPlaceholder;
public ChatColor staminaFull, staminaHalf, staminaEmpty; public ChatColor staminaFull, staminaHalf, staminaEmpty;
public long combatLogTimer, lootChestExpireTime, lootChestPlayerCooldown, globalSkillCooldown; public long combatLogTimer, lootChestExpireTime, lootChestPlayerCooldown, globalSkillCooldown;
@ -171,6 +172,13 @@ public class ConfigManager {
cobbleGeneratorXP = MMOCore.plugin.getConfig().getBoolean("should-cobblestone-generators-give-exp"); cobbleGeneratorXP = MMOCore.plugin.getConfig().getBoolean("should-cobblestone-generators-give-exp");
saveDefaultClassInfo = MMOCore.plugin.getConfig().getBoolean("save-default-class-info"); saveDefaultClassInfo = MMOCore.plugin.getConfig().getBoolean("save-default-class-info");
overrideVanillaExp = MMOCore.plugin.getConfig().getBoolean("override-vanilla-exp"); overrideVanillaExp = MMOCore.plugin.getConfig().getBoolean("override-vanilla-exp");
// Data share across classes
shareExp = MMOCore.plugin.getConfig().getBoolean("share_across_classes.experience");
shareSkillPts = MMOCore.plugin.getConfig().getBoolean("share_across_classes.skill_points");
shareAttributePts = MMOCore.plugin.getConfig().getBoolean("share_across_classes.attribute_points");
shareSkillReallocPts = MMOCore.plugin.getConfig().getBoolean("share_across_classes.skill_reallocation_points");
shareAttributeReallocPts = MMOCore.plugin.getConfig().getBoolean("share_across_classes.attribute_reallocation_points");
} }
@NotNull @NotNull

View File

@ -329,6 +329,20 @@ resource-bar-colors:
stamina-half: 'DARK_GREEN' stamina-half: 'DARK_GREEN'
stamina-empty: 'WHITE' stamina-empty: 'WHITE'
# Define what data you want to be passed along new
# classes when a player changes class.
share_across_classes:
# When toggling on this, all classes of the player
# will share experience and level. This only makes
# sense if all classes share the same exp curves!
experience: false
skill_points: false
attribute_points: false
skill_reallocation_points: false
attribute_reallocation_points: false
# Requires WorldGuard to work. Do NOT enable unless # Requires WorldGuard to work. Do NOT enable unless
# you have WG to avoid weird interact rule issues! # you have WG to avoid weird interact rule issues!
# #