Add config options for starting TB level and auto equilibrium level upgrade

This commit is contained in:
Melledy
2023-12-10 17:36:30 -08:00
parent f01d716631
commit 92a4fd379b
4 changed files with 35 additions and 8 deletions

View File

@@ -110,10 +110,12 @@ public class Config {
public static class ServerOptions {
public boolean autoCreateAccount = true;
public int sceneMaxEntites = 500;
public boolean spendStamina = true;
public boolean unlockAllChallenges = true;
public boolean spendStamina = true;
public int staminaRecoveryRate = 5 * 60;
public int staminaReserveRecoveryRate = 18 * 60;
public int startTrailblazerLevel = 1; // Starting trailblazer level for new players
public boolean autoUpgradeWorldLevel = true; // Automatically upgrades world level when the player reaches a certain TB level
public String language = "EN";
public Set<String> defaultPermissions = Set.of("*");

View File

@@ -15,6 +15,7 @@ public class GameConstants {
public static final String DEFAULT_NAME = "Trailblazer";
public static final int TRAILBLAZER_AVATAR_ID = 8001;
public static final int MAX_TRAILBLAZER_LEVEL = 70;
public static final int[] WORLD_LEVEL_UPGRADES = {0, 20, 30, 40, 50, 60, 65};
public static final int MAX_STAMINA = 240;
public static final int MAX_STAMINA_RESERVE = 2400;
public static final int MAX_AVATARS_IN_TEAM = 4;

View File

@@ -11,9 +11,9 @@ public class SetLevelCommand implements CommandHandler {
@Override
public void execute(CommandArgs args) {
int targetLevel = Utils.parseSafeInt(args.get(0));
args.getTarget().setLevel(targetLevel);
args.sendMessage("Set level to " + targetLevel);
args.getTarget().setLevel(targetLevel);
args.sendMessage("Set level to " + args.getTarget().getLevel());
}
}

View File

@@ -160,6 +160,7 @@ public class Player {
this.isNew = true;
this.initUid();
this.resetPosition();
this.setLevel(LunarCore.getConfig().getServerOptions().startTrailblazerLevel);
// Setup player data
this.name = GameConstants.DEFAULT_NAME;
@@ -167,7 +168,6 @@ public class Player {
this.headIcon = 200001;
this.phoneTheme = 221000;
this.chatBubble = 220000;
this.level = 1;
this.stamina = GameConstants.MAX_STAMINA;
this.nextStaminaRecover = System.currentTimeMillis();
@@ -196,13 +196,36 @@ public class Player {
return session.getAccount();
}
public void setLevel(int newLevel) {
this.level = Math.max(Math.min(newLevel, GameConstants.MAX_TRAILBLAZER_LEVEL), 1);
public void setLevel(int lvl) {
int oldLevel = this.level;
int newLevel = Math.max(Math.min(lvl, GameConstants.MAX_TRAILBLAZER_LEVEL), 1);
this.onLevelChange(oldLevel, newLevel);
this.level = newLevel;
this.exp = GameData.getPlayerExpRequired(this.level);
this.sendPacket(new PacketPlayerSyncScNotify(this));
this.save();
}
private void onLevelChange(int oldLevel, int newLevel) {
// Auto upgrades the player's world level when they level up to the right level
if (LunarCore.getConfig().getServerOptions().autoUpgradeWorldLevel) {
int maxWorldLevel = 0;
for (int i = 0; i < GameConstants.WORLD_LEVEL_UPGRADES.length; i++) {
if (newLevel >= GameConstants.WORLD_LEVEL_UPGRADES[i]) {
maxWorldLevel = i;
} else {
break;
}
}
if (maxWorldLevel > this.getWorldLevel()) {
this.setWorldLevel(maxWorldLevel);
}
}
}
public boolean isOnline() {
return this.getSession() != null && this.loggedIn;
}
@@ -383,7 +406,8 @@ public class Player {
}
public void addExp(int amount) {
// Required exp
// Setup
int oldLevel = this.level;
int reqExp = GameData.getPlayerExpRequired(level + 1);
// Add exp
@@ -394,7 +418,7 @@ public class Player {
reqExp = GameData.getPlayerExpRequired(this.level + 1);
}
// Save
this.onLevelChange(oldLevel, this.level);
this.save();
// Send packet