mirror of
https://github.com/Grasscutters/Grasscutter.git
synced 2025-12-16 08:56:04 +01:00
Remove BPLevel, GodMode, NoStamina, SetWorldLevel, UnlimitEnergy, UnlockTower commands
This commit is contained in:
@@ -31,19 +31,20 @@ import emu.grasscutter.net.proto.BattlePassScheduleOuterClass.BattlePassSchedule
|
||||
import emu.grasscutter.server.packet.send.PacketBattlePassCurScheduleUpdateNotify;
|
||||
import emu.grasscutter.server.packet.send.PacketBattlePassMissionUpdateNotify;
|
||||
import emu.grasscutter.server.packet.send.PacketTakeBattlePassRewardRsp;
|
||||
import lombok.Getter;
|
||||
|
||||
@Entity(value = "battlepass", useDiscriminator = false)
|
||||
public class BattlePassManager {
|
||||
@Id private ObjectId id;
|
||||
@Transient private Player player;
|
||||
@Id @Getter private ObjectId id;
|
||||
@Transient @Getter private Player player;
|
||||
|
||||
@Indexed private int ownerUid;
|
||||
private int point;
|
||||
private int cyclePoints; // Weekly maximum cap
|
||||
private int level;
|
||||
@Getter private int point;
|
||||
@Getter private int cyclePoints; // Weekly maximum cap
|
||||
@Getter private int level;
|
||||
|
||||
private boolean viewed;
|
||||
private boolean paid;
|
||||
@Getter private boolean viewed;
|
||||
@Getter private boolean paid;
|
||||
|
||||
private Map<Integer, BattlePassMission> missions;
|
||||
private Map<Integer, BattlePassReward> takenRewards;
|
||||
@@ -55,52 +56,34 @@ public class BattlePassManager {
|
||||
this.setPlayer(player);
|
||||
}
|
||||
|
||||
public ObjectId getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public Player getPlayer() {
|
||||
return this.player;
|
||||
}
|
||||
|
||||
public void setPlayer(Player player) {
|
||||
this.player = player;
|
||||
this.ownerUid = player.getUid();
|
||||
}
|
||||
|
||||
public int getPoint() {
|
||||
return this.point;
|
||||
}
|
||||
|
||||
public int getCyclePoints() {
|
||||
return cyclePoints;
|
||||
}
|
||||
|
||||
public int getLevel() {
|
||||
return this.level;
|
||||
}
|
||||
|
||||
public boolean isViewed() {
|
||||
return viewed;
|
||||
}
|
||||
|
||||
public void updateViewed() {
|
||||
this.viewed = true;
|
||||
}
|
||||
|
||||
public boolean isPaid() {
|
||||
return paid;
|
||||
public boolean setLevel(int level) {
|
||||
if (level >= 0 && level <= GameConstants.BATTLE_PASS_MAX_LEVEL) {
|
||||
this.level = level;
|
||||
this.point = 0;
|
||||
this.player.sendPacket(new PacketBattlePassCurScheduleUpdateNotify(this.player));
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public void addPoints(int point){
|
||||
this.addPointsDirectly(point, false);
|
||||
public void addPoints(int points){
|
||||
this.addPointsDirectly(points, false);
|
||||
|
||||
player.getSession().send(new PacketBattlePassCurScheduleUpdateNotify(player.getSession().getPlayer()));
|
||||
this.player.sendPacket(new PacketBattlePassCurScheduleUpdateNotify(player));
|
||||
this.save();
|
||||
}
|
||||
|
||||
public void addPointsDirectly(int point, boolean isWeekly) {
|
||||
int amount = point;
|
||||
public void addPointsDirectly(int points, boolean isWeekly) {
|
||||
int amount = points;
|
||||
|
||||
if (isWeekly) {
|
||||
amount = Math.min(amount, GameConstants.BATTLE_PASS_POINT_PER_WEEK - this.cyclePoints);
|
||||
@@ -114,7 +97,7 @@ public class BattlePassManager {
|
||||
this.cyclePoints += amount;
|
||||
|
||||
if (this.point >= GameConstants.BATTLE_PASS_POINT_PER_LEVEL && this.getLevel() < GameConstants.BATTLE_PASS_MAX_LEVEL) {
|
||||
int levelups = (int) Math.floor((float) this.point / GameConstants.BATTLE_PASS_POINT_PER_LEVEL);
|
||||
int levelups = Math.floorDiv(this.point, GameConstants.BATTLE_PASS_POINT_PER_LEVEL);
|
||||
|
||||
// Make sure player cant go above max BP level
|
||||
levelups = Math.min(levelups, GameConstants.BATTLE_PASS_MAX_LEVEL - levelups);
|
||||
|
||||
@@ -446,5 +446,10 @@ public class EnergyManager {
|
||||
|
||||
public void setEnergyUsage(Boolean energyUsage) {
|
||||
this.energyUsage = energyUsage;
|
||||
if (!energyUsage) { // Refill team energy if usage is disabled
|
||||
for (EntityAvatar entityAvatar : player.getTeamManager().getActiveTeam()) {
|
||||
entityAvatar.addEnergy(1000, PropChangeReason.PROP_CHANGE_REASON_GM,true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -283,7 +283,7 @@ public class StaminaManager {
|
||||
// Returns new stamina and sends PlayerPropNotify or VehicleStaminaNotify
|
||||
public int setStamina(GameSession session, String reason, int newStamina, boolean isCharacterStamina) {
|
||||
// Target Player
|
||||
if (!GAME_OPTIONS.staminaUsage || session.getPlayer().getStamina()) {
|
||||
if (!GAME_OPTIONS.staminaUsage || session.getPlayer().getUnlimitedStamina()) {
|
||||
newStamina = getMaxCharacterStamina();
|
||||
}
|
||||
|
||||
|
||||
@@ -437,12 +437,13 @@ public class Player {
|
||||
return this.getProperty(PlayerProperty.PROP_PLAYER_LEVEL);
|
||||
}
|
||||
|
||||
public void setLevel(int level) {
|
||||
this.setProperty(PlayerProperty.PROP_PLAYER_LEVEL, level);
|
||||
this.sendPacket(new PacketPlayerPropNotify(this, PlayerProperty.PROP_PLAYER_LEVEL));
|
||||
|
||||
this.updateWorldLevel();
|
||||
this.updateProfile();
|
||||
public boolean setLevel(int level) {
|
||||
if (this.setProperty(PlayerProperty.PROP_PLAYER_LEVEL, level)) {
|
||||
this.updateWorldLevel();
|
||||
this.updateProfile();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public int getExp() {
|
||||
@@ -452,59 +453,59 @@ public class Player {
|
||||
public int getWorldLevel() {
|
||||
return this.getProperty(PlayerProperty.PROP_PLAYER_WORLD_LEVEL);
|
||||
}
|
||||
|
||||
public void setWorldLevel(int level) {
|
||||
this.getWorld().setWorldLevel(level);
|
||||
|
||||
this.setProperty(PlayerProperty.PROP_PLAYER_WORLD_LEVEL, level);
|
||||
this.sendPacket(new PacketPlayerPropNotify(this, PlayerProperty.PROP_PLAYER_WORLD_LEVEL));
|
||||
|
||||
this.updateProfile();
|
||||
|
||||
public boolean setWorldLevel(int level) {
|
||||
if (this.setProperty(PlayerProperty.PROP_PLAYER_WORLD_LEVEL, level)) {
|
||||
if (this.world.getHost() == this) // Don't update World's WL if we are in someone else's world
|
||||
this.world.setWorldLevel(level);
|
||||
this.updateProfile();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public int getForgePoints() {
|
||||
return this.getProperty(PlayerProperty.PROP_PLAYER_FORGE_POINT);
|
||||
}
|
||||
|
||||
public void setForgePoints(int value) {
|
||||
public boolean setForgePoints(int value) {
|
||||
if (value == this.getForgePoints()) {
|
||||
return;
|
||||
return true;
|
||||
}
|
||||
|
||||
this.setProperty(PlayerProperty.PROP_PLAYER_FORGE_POINT, value);
|
||||
this.sendPacket(new PacketPlayerPropNotify(this, PlayerProperty.PROP_PLAYER_FORGE_POINT));
|
||||
return this.setProperty(PlayerProperty.PROP_PLAYER_FORGE_POINT, value);
|
||||
}
|
||||
|
||||
public int getPrimogems() {
|
||||
return this.getProperty(PlayerProperty.PROP_PLAYER_HCOIN);
|
||||
}
|
||||
|
||||
public void setPrimogems(int primogem) {
|
||||
this.setProperty(PlayerProperty.PROP_PLAYER_HCOIN, primogem);
|
||||
public boolean setPrimogems(int primogem) {
|
||||
return this.setProperty(PlayerProperty.PROP_PLAYER_HCOIN, primogem);
|
||||
}
|
||||
|
||||
public int getMora() {
|
||||
return this.getProperty(PlayerProperty.PROP_PLAYER_SCOIN);
|
||||
}
|
||||
|
||||
public void setMora(int mora) {
|
||||
this.setProperty(PlayerProperty.PROP_PLAYER_SCOIN, mora);
|
||||
public boolean setMora(int mora) {
|
||||
return this.setProperty(PlayerProperty.PROP_PLAYER_SCOIN, mora);
|
||||
}
|
||||
|
||||
public int getCrystals() {
|
||||
return this.getProperty(PlayerProperty.PROP_PLAYER_MCOIN);
|
||||
}
|
||||
|
||||
public void setCrystals(int crystals) {
|
||||
this.setProperty(PlayerProperty.PROP_PLAYER_MCOIN, crystals);
|
||||
public boolean setCrystals(int crystals) {
|
||||
return this.setProperty(PlayerProperty.PROP_PLAYER_MCOIN, crystals);
|
||||
}
|
||||
|
||||
public int getHomeCoin() {
|
||||
return this.getProperty(PlayerProperty.PROP_PLAYER_HOME_COIN);
|
||||
}
|
||||
|
||||
public void setHomeCoin(int coin) {
|
||||
this.setProperty(PlayerProperty.PROP_PLAYER_HOME_COIN, coin);
|
||||
public boolean setHomeCoin(int coin) {
|
||||
return this.setProperty(PlayerProperty.PROP_PLAYER_HOME_COIN, coin);
|
||||
}
|
||||
private int getExpRequired(int level) {
|
||||
PlayerLevelData levelData = GameData.getPlayerLevelDataMap().get(level);
|
||||
@@ -581,7 +582,7 @@ public class Player {
|
||||
}
|
||||
|
||||
public TowerData getTowerData() {
|
||||
if(towerData==null){
|
||||
if (towerData == null) {
|
||||
// because of mistake, null may be saved as storage at some machine, this if can be removed in future
|
||||
towerData = new TowerData();
|
||||
}
|
||||
@@ -953,12 +954,10 @@ public class Player {
|
||||
}
|
||||
this.save();
|
||||
}
|
||||
public boolean getStamina() {
|
||||
// Get Stamina
|
||||
public boolean getUnlimitedStamina() {
|
||||
return stamina;
|
||||
}
|
||||
public void setStamina(boolean stamina) {
|
||||
// Set Stamina
|
||||
public void setUnlimitedStamina(boolean stamina) {
|
||||
this.stamina = stamina;
|
||||
}
|
||||
public boolean inGodmode() {
|
||||
|
||||
@@ -6,6 +6,7 @@ import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
|
||||
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
|
||||
|
||||
public enum PlayerProperty {
|
||||
PROP_NONE (0),
|
||||
PROP_EXP (1001, 0),
|
||||
PROP_BREAK_LEVEL (1002),
|
||||
PROP_SATIATION_VAL (1003),
|
||||
|
||||
@@ -9,6 +9,7 @@ import emu.grasscutter.server.game.GameServer;
|
||||
import java.io.FileReader;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.Reader;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import static emu.grasscutter.Configuration.*;
|
||||
@@ -49,6 +50,12 @@ public class TowerScheduleManager {
|
||||
return data;
|
||||
}
|
||||
|
||||
public List<Integer> getAllFloors() {
|
||||
List<Integer> floors = new ArrayList<>(this.getCurrentTowerScheduleData().getEntranceFloorId());
|
||||
floors.addAll(this.getScheduleFloors());
|
||||
return floors;
|
||||
}
|
||||
|
||||
public List<Integer> getScheduleFloors() {
|
||||
return getCurrentTowerScheduleData().getSchedules().get(0).getFloorList();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user