mirror of
https://github.com/Grasscutters/Grasscutter.git
synced 2025-12-22 03:45:10 +01:00
Run IntelliJ IDEA code formatter
This commit is contained in:
@@ -3,7 +3,6 @@ package emu.grasscutter.game.home;
|
||||
import dev.morphia.annotations.Entity;
|
||||
import dev.morphia.annotations.Id;
|
||||
import emu.grasscutter.net.proto.FurnitureMakeDataOuterClass;
|
||||
import emu.grasscutter.net.proto.FurnitureMakeSlotOuterClass;
|
||||
import lombok.AccessLevel;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
@@ -23,11 +22,11 @@ public class FurnitureMakeSlotItem {
|
||||
|
||||
public FurnitureMakeDataOuterClass.FurnitureMakeData toProto() {
|
||||
return FurnitureMakeDataOuterClass.FurnitureMakeData.newBuilder()
|
||||
.setIndex(index)
|
||||
.setAvatarId(avatarId)
|
||||
.setMakeId(makeId)
|
||||
.setBeginTime(beginTime)
|
||||
.setDurTime(durTime)
|
||||
.build();
|
||||
.setIndex(index)
|
||||
.setAvatarId(avatarId)
|
||||
.setMakeId(makeId)
|
||||
.setBeginTime(beginTime)
|
||||
.setDurTime(durTime)
|
||||
.build();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,10 +1,6 @@
|
||||
package emu.grasscutter.game.home;
|
||||
|
||||
import dev.morphia.annotations.Entity;
|
||||
import dev.morphia.annotations.Id;
|
||||
import dev.morphia.annotations.IndexOptions;
|
||||
import dev.morphia.annotations.Indexed;
|
||||
import dev.morphia.annotations.Transient;
|
||||
import dev.morphia.annotations.*;
|
||||
import emu.grasscutter.Grasscutter;
|
||||
import emu.grasscutter.data.GameData;
|
||||
import emu.grasscutter.data.excels.HomeWorldLevelData;
|
||||
@@ -19,12 +15,7 @@ import lombok.experimental.FieldDefaults;
|
||||
|
||||
import java.time.ZonedDateTime;
|
||||
import java.time.temporal.ChronoUnit;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@@ -38,7 +29,8 @@ public class GameHome {
|
||||
|
||||
@Indexed(options = @IndexOptions(unique = true))
|
||||
long ownerUid;
|
||||
@Transient Player player;
|
||||
@Transient
|
||||
Player player;
|
||||
|
||||
int level;
|
||||
int exp;
|
||||
@@ -51,10 +43,6 @@ public class GameHome {
|
||||
Set<Integer> unlockedHomeBgmList;
|
||||
int enterHomeOption;
|
||||
|
||||
public void save() {
|
||||
DatabaseHelper.saveHome(this);
|
||||
}
|
||||
|
||||
public static GameHome getByUid(Integer uid) {
|
||||
var home = DatabaseHelper.getHomeByUid(uid);
|
||||
if (home == null) {
|
||||
@@ -65,11 +53,15 @@ public class GameHome {
|
||||
|
||||
public static GameHome create(Integer uid) {
|
||||
return GameHome.of()
|
||||
.ownerUid(uid)
|
||||
.level(1)
|
||||
.sceneMap(new ConcurrentHashMap<>())
|
||||
.unlockedHomeBgmList(new HashSet<>())
|
||||
.build();
|
||||
.ownerUid(uid)
|
||||
.level(1)
|
||||
.sceneMap(new ConcurrentHashMap<>())
|
||||
.unlockedHomeBgmList(new HashSet<>())
|
||||
.build();
|
||||
}
|
||||
|
||||
public void save() {
|
||||
DatabaseHelper.saveHome(this);
|
||||
}
|
||||
|
||||
public HomeSceneItem getHomeSceneItem(int sceneId) {
|
||||
|
||||
@@ -2,7 +2,6 @@ package emu.grasscutter.game.home;
|
||||
|
||||
import dev.morphia.annotations.Entity;
|
||||
import emu.grasscutter.net.proto.HomeAnimalDataOuterClass;
|
||||
import emu.grasscutter.net.proto.HomeFurnitureDataOuterClass;
|
||||
import emu.grasscutter.utils.Position;
|
||||
import lombok.AccessLevel;
|
||||
import lombok.Builder;
|
||||
@@ -18,20 +17,20 @@ public class HomeAnimalItem {
|
||||
Position spawnPos;
|
||||
Position spawnRot;
|
||||
|
||||
public HomeAnimalDataOuterClass.HomeAnimalData toProto(){
|
||||
return HomeAnimalDataOuterClass.HomeAnimalData.newBuilder()
|
||||
.setFurnitureId(furnitureId)
|
||||
.setSpawnPos(spawnPos.toProto())
|
||||
.setSpawnRot(spawnRot.toProto())
|
||||
.build();
|
||||
}
|
||||
|
||||
public static HomeAnimalItem parseFrom(HomeAnimalDataOuterClass.HomeAnimalData homeAnimalData) {
|
||||
return HomeAnimalItem.of()
|
||||
.furnitureId(homeAnimalData.getFurnitureId())
|
||||
.spawnPos(new Position(homeAnimalData.getSpawnPos()))
|
||||
.spawnRot(new Position(homeAnimalData.getSpawnRot()))
|
||||
.build();
|
||||
.furnitureId(homeAnimalData.getFurnitureId())
|
||||
.spawnPos(new Position(homeAnimalData.getSpawnPos()))
|
||||
.spawnRot(new Position(homeAnimalData.getSpawnRot()))
|
||||
.build();
|
||||
}
|
||||
|
||||
public HomeAnimalDataOuterClass.HomeAnimalData toProto() {
|
||||
return HomeAnimalDataOuterClass.HomeAnimalData.newBuilder()
|
||||
.setFurnitureId(furnitureId)
|
||||
.setSpawnPos(spawnPos.toProto())
|
||||
.setSpawnRot(spawnRot.toProto())
|
||||
.build();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -4,7 +4,6 @@ import dev.morphia.annotations.Entity;
|
||||
import dev.morphia.annotations.Id;
|
||||
import emu.grasscutter.data.binout.HomeworldDefaultSaveData;
|
||||
import emu.grasscutter.net.proto.HomeBlockArrangementInfoOuterClass.HomeBlockArrangementInfo;
|
||||
import emu.grasscutter.utils.Position;
|
||||
import lombok.AccessLevel;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
@@ -25,37 +24,57 @@ public class HomeBlockItem {
|
||||
List<HomeAnimalItem> deployAnimalList;
|
||||
List<HomeNPCItem> deployNPCList;
|
||||
|
||||
public static HomeBlockItem parseFrom(HomeworldDefaultSaveData.HomeBlock homeBlock) {
|
||||
// create from default setting
|
||||
return HomeBlockItem.of()
|
||||
.blockId(homeBlock.getBlockId())
|
||||
.unlocked(homeBlock.getFurnitures() != null)
|
||||
.deployFurnitureList(
|
||||
homeBlock.getFurnitures() == null ? List.of() :
|
||||
homeBlock.getFurnitures().stream()
|
||||
.map(HomeFurnitureItem::parseFrom)
|
||||
.toList())
|
||||
.persistentFurnitureList(
|
||||
homeBlock.getPersistentFurnitures() == null ? List.of() :
|
||||
homeBlock.getPersistentFurnitures().stream()
|
||||
.map(HomeFurnitureItem::parseFrom)
|
||||
.toList())
|
||||
.deployAnimalList(List.of())
|
||||
.deployNPCList(List.of())
|
||||
.build();
|
||||
}
|
||||
|
||||
public void update(HomeBlockArrangementInfo homeBlockArrangementInfo) {
|
||||
this.blockId = homeBlockArrangementInfo.getBlockId();
|
||||
|
||||
this.deployFurnitureList = homeBlockArrangementInfo.getDeployFurniureListList().stream()
|
||||
.map(HomeFurnitureItem::parseFrom)
|
||||
.toList();
|
||||
.map(HomeFurnitureItem::parseFrom)
|
||||
.toList();
|
||||
|
||||
this.persistentFurnitureList = homeBlockArrangementInfo.getPersistentFurnitureListList().stream()
|
||||
.map(HomeFurnitureItem::parseFrom)
|
||||
.toList();
|
||||
.map(HomeFurnitureItem::parseFrom)
|
||||
.toList();
|
||||
|
||||
this.deployAnimalList = homeBlockArrangementInfo.getDeployAnimalListList().stream()
|
||||
.map(HomeAnimalItem::parseFrom)
|
||||
.toList();
|
||||
.map(HomeAnimalItem::parseFrom)
|
||||
.toList();
|
||||
|
||||
this.deployNPCList = homeBlockArrangementInfo.getDeployNpcListList().stream()
|
||||
.map(HomeNPCItem::parseFrom)
|
||||
.toList();
|
||||
.map(HomeNPCItem::parseFrom)
|
||||
.toList();
|
||||
}
|
||||
|
||||
public int calComfort() {
|
||||
return this.deployFurnitureList.stream()
|
||||
.mapToInt(HomeFurnitureItem::getComfort)
|
||||
.sum();
|
||||
.mapToInt(HomeFurnitureItem::getComfort)
|
||||
.sum();
|
||||
}
|
||||
|
||||
public HomeBlockArrangementInfo toProto() {
|
||||
var proto = HomeBlockArrangementInfo.newBuilder()
|
||||
.setBlockId(blockId)
|
||||
.setIsUnlocked(unlocked)
|
||||
.setComfortValue(calComfort());
|
||||
.setBlockId(blockId)
|
||||
.setIsUnlocked(unlocked)
|
||||
.setComfortValue(calComfort());
|
||||
|
||||
this.deployFurnitureList.forEach(f -> proto.addDeployFurniureList(f.toProto()));
|
||||
this.persistentFurnitureList.forEach(f -> proto.addPersistentFurnitureList(f.toProto()));
|
||||
@@ -64,24 +83,4 @@ public class HomeBlockItem {
|
||||
|
||||
return proto.build();
|
||||
}
|
||||
|
||||
public static HomeBlockItem parseFrom(HomeworldDefaultSaveData.HomeBlock homeBlock) {
|
||||
// create from default setting
|
||||
return HomeBlockItem.of()
|
||||
.blockId(homeBlock.getBlockId())
|
||||
.unlocked(homeBlock.getFurnitures() != null)
|
||||
.deployFurnitureList(
|
||||
homeBlock.getFurnitures() == null ? List.of() :
|
||||
homeBlock.getFurnitures().stream()
|
||||
.map(HomeFurnitureItem::parseFrom)
|
||||
.toList())
|
||||
.persistentFurnitureList(
|
||||
homeBlock.getPersistentFurnitures() == null ? List.of() :
|
||||
homeBlock.getPersistentFurnitures().stream()
|
||||
.map(HomeFurnitureItem::parseFrom)
|
||||
.toList())
|
||||
.deployAnimalList(List.of())
|
||||
.deployNPCList(List.of())
|
||||
.build();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,7 +6,6 @@ import emu.grasscutter.data.binout.HomeworldDefaultSaveData;
|
||||
import emu.grasscutter.data.excels.ItemData;
|
||||
import emu.grasscutter.net.proto.HomeFurnitureDataOuterClass;
|
||||
import emu.grasscutter.net.proto.HomeMarkPointFurnitureDataOuterClass;
|
||||
import emu.grasscutter.net.proto.VectorOuterClass;
|
||||
import emu.grasscutter.utils.Position;
|
||||
import lombok.AccessLevel;
|
||||
import lombok.Builder;
|
||||
@@ -24,45 +23,46 @@ public class HomeFurnitureItem {
|
||||
Position spawnPos;
|
||||
Position spawnRot;
|
||||
int version;
|
||||
public HomeFurnitureDataOuterClass.HomeFurnitureData toProto(){
|
||||
return HomeFurnitureDataOuterClass.HomeFurnitureData.newBuilder()
|
||||
.setFurnitureId(furnitureId)
|
||||
.setGuid(guid)
|
||||
.setParentFurnitureIndex(parentFurnitureIndex)
|
||||
.setSpawnPos(spawnPos.toProto())
|
||||
.setSpawnRot(spawnRot.toProto())
|
||||
.setVersion(version)
|
||||
.build();
|
||||
}
|
||||
|
||||
public HomeMarkPointFurnitureDataOuterClass.HomeMarkPointFurnitureData toMarkPointProto(int type){
|
||||
return HomeMarkPointFurnitureDataOuterClass.HomeMarkPointFurnitureData.newBuilder()
|
||||
.setFurnitureId(furnitureId)
|
||||
.setGuid(guid)
|
||||
.setFurnitureType(type)
|
||||
.setPos(spawnPos.toProto())
|
||||
// TODO NPC and farm
|
||||
.build();
|
||||
}
|
||||
|
||||
public static HomeFurnitureItem parseFrom(HomeFurnitureDataOuterClass.HomeFurnitureData homeFurnitureData) {
|
||||
return HomeFurnitureItem.of()
|
||||
.furnitureId(homeFurnitureData.getFurnitureId())
|
||||
.guid(homeFurnitureData.getGuid())
|
||||
.parentFurnitureIndex(homeFurnitureData.getParentFurnitureIndex())
|
||||
.spawnPos(new Position(homeFurnitureData.getSpawnPos()))
|
||||
.spawnRot(new Position(homeFurnitureData.getSpawnRot()))
|
||||
.version(homeFurnitureData.getVersion())
|
||||
.build();
|
||||
.furnitureId(homeFurnitureData.getFurnitureId())
|
||||
.guid(homeFurnitureData.getGuid())
|
||||
.parentFurnitureIndex(homeFurnitureData.getParentFurnitureIndex())
|
||||
.spawnPos(new Position(homeFurnitureData.getSpawnPos()))
|
||||
.spawnRot(new Position(homeFurnitureData.getSpawnRot()))
|
||||
.version(homeFurnitureData.getVersion())
|
||||
.build();
|
||||
}
|
||||
|
||||
public static HomeFurnitureItem parseFrom(HomeworldDefaultSaveData.HomeFurniture homeFurniture) {
|
||||
return HomeFurnitureItem.of()
|
||||
.furnitureId(homeFurniture.getId())
|
||||
.parentFurnitureIndex(1)
|
||||
.spawnPos(homeFurniture.getPos() == null ? new Position() : homeFurniture.getPos())
|
||||
.spawnRot(homeFurniture.getRot() == null ? new Position() : homeFurniture.getRot())
|
||||
.build();
|
||||
.furnitureId(homeFurniture.getId())
|
||||
.parentFurnitureIndex(1)
|
||||
.spawnPos(homeFurniture.getPos() == null ? new Position() : homeFurniture.getPos())
|
||||
.spawnRot(homeFurniture.getRot() == null ? new Position() : homeFurniture.getRot())
|
||||
.build();
|
||||
}
|
||||
|
||||
public HomeFurnitureDataOuterClass.HomeFurnitureData toProto() {
|
||||
return HomeFurnitureDataOuterClass.HomeFurnitureData.newBuilder()
|
||||
.setFurnitureId(furnitureId)
|
||||
.setGuid(guid)
|
||||
.setParentFurnitureIndex(parentFurnitureIndex)
|
||||
.setSpawnPos(spawnPos.toProto())
|
||||
.setSpawnRot(spawnRot.toProto())
|
||||
.setVersion(version)
|
||||
.build();
|
||||
}
|
||||
|
||||
public HomeMarkPointFurnitureDataOuterClass.HomeMarkPointFurnitureData toMarkPointProto(int type) {
|
||||
return HomeMarkPointFurnitureDataOuterClass.HomeMarkPointFurnitureData.newBuilder()
|
||||
.setFurnitureId(furnitureId)
|
||||
.setGuid(guid)
|
||||
.setFurnitureType(type)
|
||||
.setPos(spawnPos.toProto())
|
||||
// TODO NPC and farm
|
||||
.build();
|
||||
}
|
||||
|
||||
public ItemData getAsItem() {
|
||||
@@ -72,7 +72,7 @@ public class HomeFurnitureItem {
|
||||
public int getComfort() {
|
||||
var item = getAsItem();
|
||||
|
||||
if (item == null){
|
||||
if (item == null) {
|
||||
return 0;
|
||||
}
|
||||
return item.getComfort();
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package emu.grasscutter.game.home;
|
||||
|
||||
import dev.morphia.annotations.Entity;
|
||||
import emu.grasscutter.net.proto.HomeAnimalDataOuterClass;
|
||||
import emu.grasscutter.net.proto.HomeNpcDataOuterClass;
|
||||
import emu.grasscutter.utils.Position;
|
||||
import lombok.AccessLevel;
|
||||
@@ -19,21 +18,21 @@ public class HomeNPCItem {
|
||||
Position spawnRot;
|
||||
int costumeId;
|
||||
|
||||
public HomeNpcDataOuterClass.HomeNpcData toProto(){
|
||||
return HomeNpcDataOuterClass.HomeNpcData.newBuilder()
|
||||
.setAvatarId(avatarId)
|
||||
.setSpawnPos(spawnPos.toProto())
|
||||
.setSpawnRot(spawnRot.toProto())
|
||||
.setCostumeId(costumeId)
|
||||
.build();
|
||||
}
|
||||
|
||||
public static HomeNPCItem parseFrom(HomeNpcDataOuterClass.HomeNpcData homeNpcData) {
|
||||
return HomeNPCItem.of()
|
||||
.avatarId(homeNpcData.getAvatarId())
|
||||
.spawnPos(new Position(homeNpcData.getSpawnPos()))
|
||||
.spawnRot(new Position(homeNpcData.getSpawnRot()))
|
||||
.costumeId(homeNpcData.getCostumeId())
|
||||
.build();
|
||||
.avatarId(homeNpcData.getAvatarId())
|
||||
.spawnPos(new Position(homeNpcData.getSpawnPos()))
|
||||
.spawnRot(new Position(homeNpcData.getSpawnRot()))
|
||||
.costumeId(homeNpcData.getCostumeId())
|
||||
.build();
|
||||
}
|
||||
|
||||
public HomeNpcDataOuterClass.HomeNpcData toProto() {
|
||||
return HomeNpcDataOuterClass.HomeNpcData.newBuilder()
|
||||
.setAvatarId(avatarId)
|
||||
.setSpawnPos(spawnPos.toProto())
|
||||
.setSpawnRot(spawnRot.toProto())
|
||||
.setCostumeId(costumeId)
|
||||
.build();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,18 +28,19 @@ public class HomeSceneItem {
|
||||
int homeBgmId;
|
||||
HomeFurnitureItem mainHouse;
|
||||
int tmpVersion;
|
||||
|
||||
public static HomeSceneItem parseFrom(HomeworldDefaultSaveData defaultItem, int sceneId) {
|
||||
return HomeSceneItem.of()
|
||||
.sceneId(sceneId)
|
||||
.blockItems(defaultItem.getHomeBlockLists().stream()
|
||||
.map(HomeBlockItem::parseFrom)
|
||||
.collect(Collectors.toMap(HomeBlockItem::getBlockId, y -> y)))
|
||||
.bornPos(defaultItem.getBornPos())
|
||||
.bornRot(defaultItem.getBornRot() == null ? new Position() : defaultItem.getBornRot())
|
||||
.djinnPos(defaultItem.getDjinPos() == null ? new Position() : defaultItem.getDjinPos())
|
||||
.mainHouse(defaultItem.getMainhouse() == null ? null :
|
||||
HomeFurnitureItem.parseFrom(defaultItem.getMainhouse()))
|
||||
.build();
|
||||
.sceneId(sceneId)
|
||||
.blockItems(defaultItem.getHomeBlockLists().stream()
|
||||
.map(HomeBlockItem::parseFrom)
|
||||
.collect(Collectors.toMap(HomeBlockItem::getBlockId, y -> y)))
|
||||
.bornPos(defaultItem.getBornPos())
|
||||
.bornRot(defaultItem.getBornRot() == null ? new Position() : defaultItem.getBornRot())
|
||||
.djinnPos(defaultItem.getDjinPos() == null ? new Position() : defaultItem.getDjinPos())
|
||||
.mainHouse(defaultItem.getMainhouse() == null ? null :
|
||||
HomeFurnitureItem.parseFrom(defaultItem.getMainhouse()))
|
||||
.build();
|
||||
}
|
||||
|
||||
public void update(HomeSceneArrangementInfo arrangementInfo) {
|
||||
@@ -70,8 +71,8 @@ public class HomeSceneItem {
|
||||
|
||||
public int calComfort() {
|
||||
return this.blockItems.values().stream()
|
||||
.mapToInt(HomeBlockItem::calComfort)
|
||||
.sum();
|
||||
.mapToInt(HomeBlockItem::calComfort)
|
||||
.sum();
|
||||
}
|
||||
|
||||
public HomeSceneArrangementInfo toProto() {
|
||||
@@ -79,13 +80,13 @@ public class HomeSceneItem {
|
||||
blockItems.values().forEach(b -> proto.addBlockArrangementInfoList(b.toProto()));
|
||||
|
||||
proto.setComfortValue(calComfort())
|
||||
.setBornPos(bornPos.toProto())
|
||||
.setBornRot(bornRot.toProto())
|
||||
.setDjinnPos(djinnPos.toProto())
|
||||
.setIsSetBornPos(true)
|
||||
.setSceneId(sceneId)
|
||||
.setBgmId(homeBgmId)
|
||||
.setTmpVersion(tmpVersion);
|
||||
.setBornPos(bornPos.toProto())
|
||||
.setBornRot(bornRot.toProto())
|
||||
.setDjinnPos(djinnPos.toProto())
|
||||
.setIsSetBornPos(true)
|
||||
.setSceneId(sceneId)
|
||||
.setBgmId(homeBgmId)
|
||||
.setTmpVersion(tmpVersion);
|
||||
|
||||
if (mainHouse != null) {
|
||||
proto.setMainHouse(mainHouse.toProto());
|
||||
|
||||
Reference in New Issue
Block a user