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) {
// Compute effective new level
final var oldLevel = getLevel();
var newLevel = Math.max(1, level);
if (getProfess().hasMaxLevel()) newLevel = Math.min(getProfess().getMaxLevel(), newLevel);
if (oldLevel == newLevel) return; // Safeguard when changing class
this.level = newLevel;
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
///////////////////////////////////////////////
final int targetLevel,
targetSkillPoints,
targetAttributePoints,
targetSkillReallocationPoints,
targetAttributeReallocationPoints;
final double targetExp;
// Fetch info from last class
if (lastClassPlayed != null) {
targetLevel = lastClassPlayed.level;
targetExp = lastClassPlayed.experience;
targetSkillPoints = lastClassPlayed.skillPoints + lastClassPlayed.countSpentSkillPoints() - this.countSpentSkillPoints();
targetAttributePoints = lastClassPlayed.attributePoints + lastClassPlayed.countSpentAttributePoints() - this.countSpentAttributePoints();
targetSkillReallocationPoints = lastClassPlayed.skillReallocationPoints;
targetAttributeReallocationPoints = lastClassPlayed.attributeReallocationPoints;
}
// Fetch info from saved class info
else {
targetLevel = level;
targetExp = experience;
targetSkillPoints = this.skillPoints;
targetAttributePoints = this.attributePoints;
targetSkillReallocationPoints = this.skillReallocationPoints;
targetAttributeReallocationPoints = this.attributeReallocationPoints;
}
final var conf = MMOCore.plugin.configManager;
final var targetLevel = lastClassPlayed != null && conf.shareExp
? lastClassPlayed.level
: level;
final var targetExp = lastClassPlayed != null && conf.shareExp
? lastClassPlayed.experience
: experience;
final var targetSkillPoints = lastClassPlayed != null && conf.shareSkillPts
? lastClassPlayed.skillPoints + lastClassPlayed.countSpentSkillPoints() - this.countSpentSkillPoints()
: this.skillPoints;
final var targetAttributePoints = lastClassPlayed != null && conf.shareAttributePts
? lastClassPlayed.attributePoints + lastClassPlayed.countSpentAttributePoints() - this.countSpentAttributePoints()
: this.attributePoints;
final var targetSkillReallocationPoints = lastClassPlayed != null && conf.shareSkillReallocPts
? lastClassPlayed.skillReallocationPoints
: this.skillReallocationPoints;
final var targetAttributeReallocationPoints = lastClassPlayed != null && conf.shareAttributeReallocPts
? lastClassPlayed.attributeReallocationPoints
: this.attributeReallocationPoints;
///////////////////////////////////////////////
// Apply player data

View File

@ -25,7 +25,8 @@ import java.util.logging.Level;
public class ConfigManager {
public boolean overrideVanillaExp, canCreativeCast, passiveSkillsNeedBinding, cobbleGeneratorXP, saveDefaultClassInfo,
splitMainExp, splitProfessionExp, disableQuestBossBar, pvpModeEnabled, pvpModeInvulnerabilityCanDamage, forceClassSelection,
enableGlobalSkillTreeGUI, enableSpecificSkillTreeGUI, waypointAutoPathCalculation, waypointLinkReciprocity;
enableGlobalSkillTreeGUI, enableSpecificSkillTreeGUI, waypointAutoPathCalculation, waypointLinkReciprocity,
shareExp, shareSkillPts, shareAttributePts, shareSkillReallocPts, shareAttributeReallocPts;
public String partyChatPrefix, noSkillBoundPlaceholder;
public ChatColor staminaFull, staminaHalf, staminaEmpty;
public long combatLogTimer, lootChestExpireTime, lootChestPlayerCooldown, globalSkillCooldown;
@ -171,6 +172,13 @@ public class ConfigManager {
cobbleGeneratorXP = MMOCore.plugin.getConfig().getBoolean("should-cobblestone-generators-give-exp");
saveDefaultClassInfo = MMOCore.plugin.getConfig().getBoolean("save-default-class-info");
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

View File

@ -329,6 +329,20 @@ resource-bar-colors:
stamina-half: 'DARK_GREEN'
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
# you have WG to avoid weird interact rule issues!
#