mirror of
https://github.com/Melledy/LunarCore.git
synced 2025-12-23 10:44:36 +01:00
Add config options for starting TB level and auto equilibrium level upgrade
This commit is contained in:
@@ -110,10 +110,12 @@ public class Config {
|
|||||||
public static class ServerOptions {
|
public static class ServerOptions {
|
||||||
public boolean autoCreateAccount = true;
|
public boolean autoCreateAccount = true;
|
||||||
public int sceneMaxEntites = 500;
|
public int sceneMaxEntites = 500;
|
||||||
public boolean spendStamina = true;
|
|
||||||
public boolean unlockAllChallenges = true;
|
public boolean unlockAllChallenges = true;
|
||||||
|
public boolean spendStamina = true;
|
||||||
public int staminaRecoveryRate = 5 * 60;
|
public int staminaRecoveryRate = 5 * 60;
|
||||||
public int staminaReserveRecoveryRate = 18 * 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 String language = "EN";
|
||||||
public Set<String> defaultPermissions = Set.of("*");
|
public Set<String> defaultPermissions = Set.of("*");
|
||||||
|
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ public class GameConstants {
|
|||||||
public static final String DEFAULT_NAME = "Trailblazer";
|
public static final String DEFAULT_NAME = "Trailblazer";
|
||||||
public static final int TRAILBLAZER_AVATAR_ID = 8001;
|
public static final int TRAILBLAZER_AVATAR_ID = 8001;
|
||||||
public static final int MAX_TRAILBLAZER_LEVEL = 70;
|
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 = 240;
|
||||||
public static final int MAX_STAMINA_RESERVE = 2400;
|
public static final int MAX_STAMINA_RESERVE = 2400;
|
||||||
public static final int MAX_AVATARS_IN_TEAM = 4;
|
public static final int MAX_AVATARS_IN_TEAM = 4;
|
||||||
|
|||||||
@@ -11,9 +11,9 @@ public class SetLevelCommand implements CommandHandler {
|
|||||||
@Override
|
@Override
|
||||||
public void execute(CommandArgs args) {
|
public void execute(CommandArgs args) {
|
||||||
int targetLevel = Utils.parseSafeInt(args.get(0));
|
int targetLevel = Utils.parseSafeInt(args.get(0));
|
||||||
|
|
||||||
args.getTarget().setLevel(targetLevel);
|
args.getTarget().setLevel(targetLevel);
|
||||||
|
args.sendMessage("Set level to " + args.getTarget().getLevel());
|
||||||
args.sendMessage("Set level to " + targetLevel);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -160,6 +160,7 @@ public class Player {
|
|||||||
this.isNew = true;
|
this.isNew = true;
|
||||||
this.initUid();
|
this.initUid();
|
||||||
this.resetPosition();
|
this.resetPosition();
|
||||||
|
this.setLevel(LunarCore.getConfig().getServerOptions().startTrailblazerLevel);
|
||||||
|
|
||||||
// Setup player data
|
// Setup player data
|
||||||
this.name = GameConstants.DEFAULT_NAME;
|
this.name = GameConstants.DEFAULT_NAME;
|
||||||
@@ -167,7 +168,6 @@ public class Player {
|
|||||||
this.headIcon = 200001;
|
this.headIcon = 200001;
|
||||||
this.phoneTheme = 221000;
|
this.phoneTheme = 221000;
|
||||||
this.chatBubble = 220000;
|
this.chatBubble = 220000;
|
||||||
this.level = 1;
|
|
||||||
this.stamina = GameConstants.MAX_STAMINA;
|
this.stamina = GameConstants.MAX_STAMINA;
|
||||||
this.nextStaminaRecover = System.currentTimeMillis();
|
this.nextStaminaRecover = System.currentTimeMillis();
|
||||||
|
|
||||||
@@ -196,13 +196,36 @@ public class Player {
|
|||||||
return session.getAccount();
|
return session.getAccount();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setLevel(int newLevel) {
|
public void setLevel(int lvl) {
|
||||||
this.level = Math.max(Math.min(newLevel, GameConstants.MAX_TRAILBLAZER_LEVEL), 1);
|
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.exp = GameData.getPlayerExpRequired(this.level);
|
||||||
this.sendPacket(new PacketPlayerSyncScNotify(this));
|
this.sendPacket(new PacketPlayerSyncScNotify(this));
|
||||||
this.save();
|
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() {
|
public boolean isOnline() {
|
||||||
return this.getSession() != null && this.loggedIn;
|
return this.getSession() != null && this.loggedIn;
|
||||||
}
|
}
|
||||||
@@ -383,7 +406,8 @@ public class Player {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void addExp(int amount) {
|
public void addExp(int amount) {
|
||||||
// Required exp
|
// Setup
|
||||||
|
int oldLevel = this.level;
|
||||||
int reqExp = GameData.getPlayerExpRequired(level + 1);
|
int reqExp = GameData.getPlayerExpRequired(level + 1);
|
||||||
|
|
||||||
// Add exp
|
// Add exp
|
||||||
@@ -394,7 +418,7 @@ public class Player {
|
|||||||
reqExp = GameData.getPlayerExpRequired(this.level + 1);
|
reqExp = GameData.getPlayerExpRequired(this.level + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Save
|
this.onLevelChange(oldLevel, this.level);
|
||||||
this.save();
|
this.save();
|
||||||
|
|
||||||
// Send packet
|
// Send packet
|
||||||
|
|||||||
Reference in New Issue
Block a user