mirror of
https://github.com/Grasscutters/Grasscutter.git
synced 2026-02-07 02:26:43 +01:00
Merge branch 'development' into dev-quests
This commit is contained in:
@@ -63,6 +63,8 @@ import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.LinkedBlockingQueue;
|
||||
|
||||
import static emu.grasscutter.Configuration.*;
|
||||
|
||||
@Entity(value = "players", useDiscriminator = false)
|
||||
public class Player {
|
||||
|
||||
@@ -358,7 +360,7 @@ public class Player {
|
||||
}
|
||||
|
||||
private float getExpModifier() {
|
||||
return Grasscutter.getConfig().getGameServerOptions().getGameRates().ADVENTURE_EXP_RATE;
|
||||
return GAME_OPTIONS.rates.adventureExp;
|
||||
}
|
||||
|
||||
// Affected by exp rate
|
||||
@@ -1248,7 +1250,7 @@ public class Player {
|
||||
} else if (prop == PlayerProperty.PROP_LAST_CHANGE_AVATAR_TIME) { // 10001
|
||||
// TODO: implement sanity check
|
||||
} else if (prop == PlayerProperty.PROP_MAX_SPRING_VOLUME) { // 10002
|
||||
if (!(value >= 0 && value <= getSotSManager().GlobalMaximumSpringVolume)) { return false; }
|
||||
if (!(value >= 0 && value <= SotSManager.GlobalMaximumSpringVolume)) { return false; }
|
||||
} else if (prop == PlayerProperty.PROP_CUR_SPRING_VOLUME) { // 10003
|
||||
int playerMaximumSpringVolume = getProperty(PlayerProperty.PROP_MAX_SPRING_VOLUME);
|
||||
if (!(value >= 0 && value <= playerMaximumSpringVolume)) { return false; }
|
||||
@@ -1265,7 +1267,7 @@ public class Player {
|
||||
} else if (prop == PlayerProperty.PROP_IS_TRANSFERABLE) { // 10009
|
||||
if (!(0 <= value && value <= 1)) { return false; }
|
||||
} else if (prop == PlayerProperty.PROP_MAX_STAMINA) { // 10010
|
||||
if (!(value >= 0 && value <= getStaminaManager().GlobalMaximumStamina)) { return false; }
|
||||
if (!(value >= 0 && value <= StaminaManager.GlobalMaximumStamina)) { return false; }
|
||||
} else if (prop == PlayerProperty.PROP_CUR_PERSIST_STAMINA) { // 10011
|
||||
int playerMaximumStamina = getProperty(PlayerProperty.PROP_MAX_STAMINA);
|
||||
if (!(value >= 0 && value <= playerMaximumStamina)) { return false; }
|
||||
|
||||
@@ -4,10 +4,10 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import dev.morphia.annotations.Entity;
|
||||
import emu.grasscutter.GameConstants;
|
||||
import emu.grasscutter.Grasscutter;
|
||||
import emu.grasscutter.game.avatar.Avatar;
|
||||
|
||||
import static emu.grasscutter.Configuration.*;
|
||||
|
||||
@Entity
|
||||
public class TeamInfo {
|
||||
private String name;
|
||||
@@ -15,7 +15,7 @@ public class TeamInfo {
|
||||
|
||||
public TeamInfo() {
|
||||
this.name = "";
|
||||
this.avatars = new ArrayList<>(Grasscutter.getConfig().getGameServerOptions().MaxAvatarsInTeam);
|
||||
this.avatars = new ArrayList<>(GAME_OPTIONS.avatarLimits.singlePlayerTeam);
|
||||
}
|
||||
|
||||
public TeamInfo(List<Integer> avatars) {
|
||||
@@ -44,7 +44,7 @@ public class TeamInfo {
|
||||
}
|
||||
|
||||
public boolean addAvatar(Avatar avatar) {
|
||||
if (size() >= Grasscutter.getConfig().getGameServerOptions().MaxAvatarsInTeam || contains(avatar)) {
|
||||
if (size() >= GAME_OPTIONS.avatarLimits.singlePlayerTeam || contains(avatar)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -64,7 +64,7 @@ public class TeamInfo {
|
||||
}
|
||||
|
||||
public void copyFrom(TeamInfo team) {
|
||||
copyFrom(team, Grasscutter.getConfig().getGameServerOptions().MaxAvatarsInTeam);
|
||||
copyFrom(team, GAME_OPTIONS.avatarLimits.singlePlayerTeam);
|
||||
}
|
||||
|
||||
public void copyFrom(TeamInfo team, int maxTeamSize) {
|
||||
|
||||
@@ -5,7 +5,6 @@ import java.util.*;
|
||||
import dev.morphia.annotations.Entity;
|
||||
import dev.morphia.annotations.Transient;
|
||||
import emu.grasscutter.GameConstants;
|
||||
import emu.grasscutter.Grasscutter;
|
||||
import emu.grasscutter.data.def.AvatarSkillDepotData;
|
||||
import emu.grasscutter.game.avatar.Avatar;
|
||||
import emu.grasscutter.game.entity.EntityAvatar;
|
||||
@@ -40,6 +39,8 @@ import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
|
||||
import it.unimi.dsi.fastutil.ints.IntOpenHashSet;
|
||||
import it.unimi.dsi.fastutil.ints.IntSet;
|
||||
|
||||
import static emu.grasscutter.Configuration.*;
|
||||
|
||||
@Entity
|
||||
public class TeamManager {
|
||||
@Transient private Player player;
|
||||
@@ -174,13 +175,14 @@ public class TeamManager {
|
||||
|
||||
public int getMaxTeamSize() {
|
||||
if (getPlayer().isInMultiplayer()) {
|
||||
int max = Grasscutter.getConfig().getGameServerOptions().MaxAvatarsInTeamMultiplayer;
|
||||
int max = GAME_OPTIONS.avatarLimits.multiplayerTeam;
|
||||
if (getPlayer().getWorld().getHost() == this.getPlayer()) {
|
||||
return Math.max(1, (int) Math.ceil(max / (double) getWorld().getPlayerCount()));
|
||||
}
|
||||
return Math.max(1, (int) Math.floor(max / (double) getWorld().getPlayerCount()));
|
||||
}
|
||||
return Grasscutter.getConfig().getGameServerOptions().MaxAvatarsInTeam;
|
||||
|
||||
return GAME_OPTIONS.avatarLimits.singlePlayerTeam;
|
||||
}
|
||||
|
||||
// Methods
|
||||
@@ -236,7 +238,7 @@ public class TeamManager {
|
||||
// Add back entities into team
|
||||
for (int i = 0; i < this.getCurrentTeamInfo().getAvatars().size(); i++) {
|
||||
int avatarId = this.getCurrentTeamInfo().getAvatars().get(i);
|
||||
EntityAvatar entity = null;
|
||||
EntityAvatar entity;
|
||||
|
||||
if (existingAvatars.containsKey(avatarId)) {
|
||||
entity = existingAvatars.get(avatarId);
|
||||
@@ -303,8 +305,8 @@ public class TeamManager {
|
||||
|
||||
// Set team data
|
||||
LinkedHashSet<Avatar> newTeam = new LinkedHashSet<>();
|
||||
for (int i = 0; i < list.size(); i++) {
|
||||
Avatar avatar = getPlayer().getAvatars().getAvatarByGuid(list.get(i));
|
||||
for (Long aLong : list) {
|
||||
Avatar avatar = getPlayer().getAvatars().getAvatarByGuid(aLong);
|
||||
if (avatar == null || newTeam.contains(avatar)) {
|
||||
// Should never happen
|
||||
return;
|
||||
@@ -339,8 +341,8 @@ public class TeamManager {
|
||||
|
||||
// Set team data
|
||||
LinkedHashSet<Avatar> newTeam = new LinkedHashSet<>();
|
||||
for (int i = 0; i < list.size(); i++) {
|
||||
Avatar avatar = getPlayer().getAvatars().getAvatarByGuid(list.get(i));
|
||||
for (Long aLong : list) {
|
||||
Avatar avatar = getPlayer().getAvatars().getAvatarByGuid(aLong);
|
||||
if (avatar == null || newTeam.contains(avatar)) {
|
||||
// Should never happen
|
||||
return;
|
||||
@@ -359,7 +361,7 @@ public class TeamManager {
|
||||
}
|
||||
|
||||
public void setupTemporaryTeam(List<List<Long>> guidList) {
|
||||
var team = guidList.stream().map(list -> {
|
||||
this.temporaryTeam = guidList.stream().map(list -> {
|
||||
// Sanity checks
|
||||
if (list.size() == 0 || list.size() > getMaxTeamSize()) {
|
||||
return null;
|
||||
@@ -367,8 +369,8 @@ public class TeamManager {
|
||||
|
||||
// Set team data
|
||||
LinkedHashSet<Avatar> newTeam = new LinkedHashSet<>();
|
||||
for (int i = 0; i < list.size(); i++) {
|
||||
Avatar avatar = getPlayer().getAvatars().getAvatarByGuid(list.get(i));
|
||||
for (Long aLong : list) {
|
||||
Avatar avatar = getPlayer().getAvatars().getAvatarByGuid(aLong);
|
||||
if (avatar == null || newTeam.contains(avatar)) {
|
||||
// Should never happen
|
||||
return null;
|
||||
@@ -384,7 +386,6 @@ public class TeamManager {
|
||||
.filter(Objects::nonNull)
|
||||
.map(TeamInfo::new)
|
||||
.toList();
|
||||
this.temporaryTeam = team;
|
||||
}
|
||||
|
||||
public void useTemporaryTeam(int index) {
|
||||
|
||||
Reference in New Issue
Block a user