Format code [skip actions]

This commit is contained in:
github-actions 2023-09-08 03:35:28 +00:00
parent fc42f665a7
commit cdcdf924bd
24 changed files with 236 additions and 184 deletions

View File

@ -12,14 +12,27 @@ import lombok.experimental.FieldDefaults;
@FieldDefaults(level = AccessLevel.PRIVATE) @FieldDefaults(level = AccessLevel.PRIVATE)
@Getter @Getter
public class HomeWorldEventData extends GameResource { public class HomeWorldEventData extends GameResource {
@SerializedName(value = "id", alternate = {"BBEIIPEFDPE"}) @SerializedName(
value = "id",
alternate = {"BBEIIPEFDPE"})
int id; int id;
@SerializedName(value = "eventType", alternate = {"JOCKIMECHDP"})
@SerializedName(
value = "eventType",
alternate = {"JOCKIMECHDP"})
SuiteEventType eventType; SuiteEventType eventType;
int avatarID; int avatarID;
@SerializedName(value = "talkId", alternate = {"IGNJAICDFPD"})
@SerializedName(
value = "talkId",
alternate = {"IGNJAICDFPD"})
int talkId; int talkId;
int rewardID; int rewardID;
@SerializedName(value = "suiteId", alternate = {"FEHOKMJPOED"})
@SerializedName(
value = "suiteId",
alternate = {"FEHOKMJPOED"})
int suiteId; int suiteId;
} }

View File

@ -8,9 +8,8 @@ import emu.grasscutter.game.world.Scene;
import emu.grasscutter.net.proto.VisionTypeOuterClass; import emu.grasscutter.net.proto.VisionTypeOuterClass;
import emu.grasscutter.server.packet.send.PacketSceneEntityAppearNotify; import emu.grasscutter.server.packet.send.PacketSceneEntityAppearNotify;
import emu.grasscutter.server.packet.send.PacketSceneEntityDisappearNotify; import emu.grasscutter.server.packet.send.PacketSceneEntityDisappearNotify;
import lombok.Getter;
import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicBoolean;
import lombok.Getter;
public class EntityHomeAnimal extends EntityMonster implements Rebornable { public class EntityHomeAnimal extends EntityMonster implements Rebornable {
private int rebornCDTickCount; private int rebornCDTickCount;

View File

@ -12,17 +12,16 @@ import emu.grasscutter.game.props.SceneType;
import emu.grasscutter.net.proto.HomeAvatarTalkFinishInfoOuterClass; import emu.grasscutter.net.proto.HomeAvatarTalkFinishInfoOuterClass;
import emu.grasscutter.server.packet.send.*; import emu.grasscutter.server.packet.send.*;
import it.unimi.dsi.fastutil.ints.Int2ObjectMap; import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
import lombok.AccessLevel;
import lombok.Builder;
import lombok.Data;
import lombok.experimental.FieldDefaults;
import java.time.ZonedDateTime; import java.time.ZonedDateTime;
import java.time.temporal.ChronoUnit; import java.time.temporal.ChronoUnit;
import java.util.*; import java.util.*;
import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentHashMap;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import java.util.stream.Stream; import java.util.stream.Stream;
import lombok.AccessLevel;
import lombok.Builder;
import lombok.Data;
import lombok.experimental.FieldDefaults;
@Entity(value = "homes", useDiscriminator = false) @Entity(value = "homes", useDiscriminator = false)
@Data @Data

View File

@ -67,7 +67,8 @@ public class HomeBlockItem {
.map(homeNpcData -> HomeNPCItem.parseFrom(homeNpcData, owner)) .map(homeNpcData -> HomeNPCItem.parseFrom(homeNpcData, owner))
.toList(); .toList();
this.suiteList = homeBlockArrangementInfo.getFurnitureSuiteListList().stream() this.suiteList =
homeBlockArrangementInfo.getFurnitureSuiteListList().stream()
.map(HomeSuiteItem::parseFrom) .map(HomeSuiteItem::parseFrom)
.toList(); .toList();
} }
@ -98,7 +99,11 @@ public class HomeBlockItem {
public List<? extends HomeMarkPointProtoFactory> getMarkPointProtoFactories() { public List<? extends HomeMarkPointProtoFactory> getMarkPointProtoFactories() {
this.reassignIfNull(); this.reassignIfNull();
return Stream.of(this.deployFurnitureList, this.persistentFurnitureList, this.deployNPCList, this.suiteList) return Stream.of(
this.deployFurnitureList,
this.persistentFurnitureList,
this.deployNPCList,
this.suiteList)
.flatMap(Collection::stream) .flatMap(Collection::stream)
.toList(); .toList();
} }

View File

@ -1,7 +1,6 @@
package emu.grasscutter.game.home; package emu.grasscutter.game.home;
import com.github.davidmoten.guavamini.Lists; import com.github.davidmoten.guavamini.Lists;
import emu.grasscutter.Grasscutter;
import emu.grasscutter.game.home.suite.event.HomeAvatarRewardEvent; import emu.grasscutter.game.home.suite.event.HomeAvatarRewardEvent;
import emu.grasscutter.game.home.suite.event.HomeAvatarSummonEvent; import emu.grasscutter.game.home.suite.event.HomeAvatarSummonEvent;
import emu.grasscutter.game.home.suite.event.SuiteEventType; import emu.grasscutter.game.home.suite.event.SuiteEventType;
@ -12,13 +11,12 @@ import emu.grasscutter.net.proto.HomeAvatarSummonAllEventNotifyOuterClass;
import emu.grasscutter.net.proto.RetcodeOuterClass; import emu.grasscutter.net.proto.RetcodeOuterClass;
import emu.grasscutter.server.packet.send.PacketHomeAvatarSummonAllEventNotify; import emu.grasscutter.server.packet.send.PacketHomeAvatarSummonAllEventNotify;
import emu.grasscutter.utils.Either; import emu.grasscutter.utils.Either;
import java.util.*;
import java.util.stream.Stream;
import lombok.AccessLevel; import lombok.AccessLevel;
import lombok.Getter; import lombok.Getter;
import lombok.experimental.FieldDefaults; import lombok.experimental.FieldDefaults;
import java.util.*;
import java.util.stream.Stream;
@Getter @Getter
@FieldDefaults(level = AccessLevel.PRIVATE) @FieldDefaults(level = AccessLevel.PRIVATE)
public class HomeModuleManager { public class HomeModuleManager {
@ -59,13 +57,15 @@ public class HomeModuleManager {
private void fireAllAvatarRewardEvent() { private void fireAllAvatarRewardEvent() {
this.rewardEvents.clear(); this.rewardEvents.clear();
var allBlockItems = Stream.of(this.getOutdoorSceneItem(), this.getIndoorSceneItem()) var allBlockItems =
Stream.of(this.getOutdoorSceneItem(), this.getIndoorSceneItem())
.map(HomeSceneItem::getBlockItems) .map(HomeSceneItem::getBlockItems)
.map(Map::values) .map(Map::values)
.flatMap(Collection::stream) .flatMap(Collection::stream)
.toList(); .toList();
var suites = allBlockItems.stream() var suites =
allBlockItems.stream()
.map(HomeBlockItem::getSuiteList) .map(HomeBlockItem::getSuiteList)
.flatMap(Collection::stream) .flatMap(Collection::stream)
.distinct() .distinct()
@ -74,14 +74,25 @@ public class HomeModuleManager {
allBlockItems.stream() allBlockItems.stream()
.map(HomeBlockItem::getDeployNPCList) .map(HomeBlockItem::getDeployNPCList)
.flatMap(Collection::stream) .flatMap(Collection::stream)
.forEach(avatar -> { .forEach(
suites.forEach(suite -> { avatar -> {
var data = SuiteEventType.HOME_AVATAR_REWARD_EVENT.getEventDataFrom(avatar.getAvatarId(), suite.getSuiteId()); suites.forEach(
suite -> {
var data =
SuiteEventType.HOME_AVATAR_REWARD_EVENT.getEventDataFrom(
avatar.getAvatarId(), suite.getSuiteId());
if (data == null || this.home.isRewardEventFinished(data.getId())) { if (data == null || this.home.isRewardEventFinished(data.getId())) {
return; return;
} }
this.rewardEvents.add(new HomeAvatarRewardEvent(homeOwner, data.getId(), data.getRewardID(), data.getAvatarID(), data.getSuiteId(), suite.getGuid())); this.rewardEvents.add(
new HomeAvatarRewardEvent(
homeOwner,
data.getId(),
data.getRewardID(),
data.getAvatarID(),
data.getSuiteId(),
suite.getGuid()));
}); });
}); });
@ -92,7 +103,8 @@ public class HomeModuleManager {
} }
private void cancelSummonEventIfAvatarLeave() { private void cancelSummonEventIfAvatarLeave() {
var avatars = Stream.of(this.getOutdoorSceneItem(), this.getIndoorSceneItem()) var avatars =
Stream.of(this.getOutdoorSceneItem(), this.getIndoorSceneItem())
.map(HomeSceneItem::getBlockItems) .map(HomeSceneItem::getBlockItems)
.map(Map::values) .map(Map::values)
.flatMap(Collection::stream) .flatMap(Collection::stream)
@ -121,8 +133,11 @@ public class HomeModuleManager {
return Either.left(event.giveRewards()); return Either.left(event.giveRewards());
} }
public Either<HomeAvatarSummonEvent, Integer> fireAvatarSummonEvent(Player owner, int avatarId, int guid, int suiteId) { public Either<HomeAvatarSummonEvent, Integer> fireAvatarSummonEvent(
var targetSuite = ((HomeScene) owner.getScene()).getSceneItem().getBlockItems().values().stream() Player owner, int avatarId, int guid, int suiteId) {
var targetSuite =
((HomeScene) owner.getScene())
.getSceneItem().getBlockItems().values().stream()
.map(HomeBlockItem::getSuiteList) .map(HomeBlockItem::getSuiteList)
.flatMap(Collection::stream) .flatMap(Collection::stream)
.filter(suite -> suite.getGuid() == guid) .filter(suite -> suite.getGuid() == guid)
@ -148,7 +163,9 @@ public class HomeModuleManager {
return Either.right(RetcodeOuterClass.Retcode.RET_HOME_CLIENT_PARAM_INVALID_VALUE); return Either.right(RetcodeOuterClass.Retcode.RET_HOME_CLIENT_PARAM_INVALID_VALUE);
} }
var event = new HomeAvatarSummonEvent(owner, eventData.getId(), eventData.getRewardID(), avatarId, suiteId, guid); var event =
new HomeAvatarSummonEvent(
owner, eventData.getId(), eventData.getRewardID(), avatarId, suiteId, guid);
this.summonEvents.add(event); this.summonEvents.add(event);
owner.sendPacket(new PacketHomeAvatarSummonAllEventNotify(owner)); owner.sendPacket(new PacketHomeAvatarSummonAllEventNotify(owner));
return Either.left(event); return Either.left(event);
@ -163,7 +180,8 @@ public class HomeModuleManager {
if (!this.rewardEvents.isEmpty()) { if (!this.rewardEvents.isEmpty()) {
notify.setRewardEvent(this.rewardEvents.get(0).toProto()).setIsEventTrigger(true); notify.setRewardEvent(this.rewardEvents.get(0).toProto()).setIsEventTrigger(true);
notify.addAllPendingList(this.rewardEvents.subList(1, this.rewardEvents.size()).stream() notify.addAllPendingList(
this.rewardEvents.subList(1, this.rewardEvents.size()).stream()
.map(HomeAvatarRewardEvent::toProto) .map(HomeAvatarRewardEvent::toProto)
.toList()); .toList());
} }
@ -171,11 +189,11 @@ public class HomeModuleManager {
return notify.build(); return notify.build();
} }
public HomeAvatarSummonAllEventNotifyOuterClass.HomeAvatarSummonAllEventNotify toSummonEventProto() { public HomeAvatarSummonAllEventNotifyOuterClass.HomeAvatarSummonAllEventNotify
toSummonEventProto() {
return HomeAvatarSummonAllEventNotifyOuterClass.HomeAvatarSummonAllEventNotify.newBuilder() return HomeAvatarSummonAllEventNotifyOuterClass.HomeAvatarSummonAllEventNotify.newBuilder()
.addAllSummonEventList(this.summonEvents.stream() .addAllSummonEventList(
.map(HomeAvatarSummonEvent::toProto) this.summonEvents.stream().map(HomeAvatarSummonEvent::toProto).toList())
.toList())
.build(); .build();
} }

View File

@ -10,16 +10,15 @@ import emu.grasscutter.game.player.Player;
import emu.grasscutter.game.world.Position; import emu.grasscutter.game.world.Position;
import emu.grasscutter.game.world.Scene; import emu.grasscutter.game.world.Scene;
import emu.grasscutter.net.proto.HomeSceneArrangementInfoOuterClass.HomeSceneArrangementInfo; import emu.grasscutter.net.proto.HomeSceneArrangementInfoOuterClass.HomeSceneArrangementInfo;
import lombok.AccessLevel;
import lombok.Builder;
import lombok.Data;
import lombok.experimental.FieldDefaults;
import javax.annotation.Nullable;
import java.util.Collection; import java.util.Collection;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import javax.annotation.Nullable;
import lombok.AccessLevel;
import lombok.Builder;
import lombok.Data;
import lombok.experimental.FieldDefaults;
@Entity @Entity
@Data @Data

View File

@ -11,10 +11,9 @@ import emu.grasscutter.server.game.GameServer;
import emu.grasscutter.server.packet.send.PacketDelTeamEntityNotify; import emu.grasscutter.server.packet.send.PacketDelTeamEntityNotify;
import emu.grasscutter.server.packet.send.PacketPlayerChatNotify; import emu.grasscutter.server.packet.send.PacketPlayerChatNotify;
import emu.grasscutter.server.packet.send.PacketPlayerGameTimeNotify; import emu.grasscutter.server.packet.send.PacketPlayerGameTimeNotify;
import lombok.Getter;
import java.util.List; import java.util.List;
import java.util.function.Consumer; import java.util.function.Consumer;
import lombok.Getter;
public class HomeWorld extends World { public class HomeWorld extends World {
@Getter private final GameHome home; @Getter private final GameHome home;

View File

@ -212,7 +212,10 @@ public class HomeWorldMPSystem extends BaseGameSystem {
player.setCurHomeWorld(myHome); player.setCurHomeWorld(myHome);
myHome.getHome().onOwnerLogin(player); myHome.getHome().onOwnerLogin(player);
player.sendPacket(new PacketPlayerQuitFromHomeNotify(PlayerQuitFromHomeNotifyOuterClass.PlayerQuitFromHomeNotify.QuitReason.BACK_TO_MY_WORLD)); player.sendPacket(
new PacketPlayerQuitFromHomeNotify(
PlayerQuitFromHomeNotifyOuterClass.PlayerQuitFromHomeNotify.QuitReason
.BACK_TO_MY_WORLD));
player.sendPacket( player.sendPacket(
new PacketPlayerEnterSceneNotify( new PacketPlayerEnterSceneNotify(
player, player,
@ -261,7 +264,9 @@ public class HomeWorldMPSystem extends BaseGameSystem {
victim.setCurHomeWorld(myHome); victim.setCurHomeWorld(myHome);
myHome.getHome().onOwnerLogin(victim); myHome.getHome().onOwnerLogin(victim);
victim.sendPacket(new PacketPlayerQuitFromHomeNotify(PlayerQuitFromHomeNotifyOuterClass.PlayerQuitFromHomeNotify.QuitReason.KICK_BY_HOST)); victim.sendPacket(
new PacketPlayerQuitFromHomeNotify(
PlayerQuitFromHomeNotifyOuterClass.PlayerQuitFromHomeNotify.QuitReason.KICK_BY_HOST));
victim.sendPacket( victim.sendPacket(
new PacketPlayerEnterSceneNotify( new PacketPlayerEnterSceneNotify(
victim, victim,

View File

@ -7,15 +7,14 @@ import emu.grasscutter.game.world.Position;
import emu.grasscutter.net.proto.HomeFurnitureSuiteDataOuterClass; import emu.grasscutter.net.proto.HomeFurnitureSuiteDataOuterClass;
import emu.grasscutter.net.proto.HomeMarkPointFurnitureDataOuterClass; import emu.grasscutter.net.proto.HomeMarkPointFurnitureDataOuterClass;
import emu.grasscutter.net.proto.HomeMarkPointSuiteDataOuterClass; import emu.grasscutter.net.proto.HomeMarkPointSuiteDataOuterClass;
import java.util.List;
import java.util.Objects;
import lombok.AccessLevel; import lombok.AccessLevel;
import lombok.Builder; import lombok.Builder;
import lombok.Getter; import lombok.Getter;
import lombok.experimental.FieldDefaults; import lombok.experimental.FieldDefaults;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
import java.util.List;
import java.util.Objects;
@Entity @Entity
@Builder(builderMethodName = "of") @Builder(builderMethodName = "of")
@Getter @Getter
@ -28,7 +27,8 @@ public class HomeSuiteItem implements HomeMarkPointProtoFactory {
List<Integer> includedFurnitureIndexList; List<Integer> includedFurnitureIndexList;
boolean isAllowSummon; boolean isAllowSummon;
public static HomeSuiteItem parseFrom(HomeFurnitureSuiteDataOuterClass.HomeFurnitureSuiteData data) { public static HomeSuiteItem parseFrom(
HomeFurnitureSuiteDataOuterClass.HomeFurnitureSuiteData data) {
return HomeSuiteItem.of() return HomeSuiteItem.of()
.guid(data.getGuid()) .guid(data.getGuid())
.suiteId(data.getSuiteId()) .suiteId(data.getSuiteId())
@ -48,15 +48,15 @@ public class HomeSuiteItem implements HomeMarkPointProtoFactory {
.build(); .build();
} }
@Nullable @Nullable @Override
@Override
public HomeMarkPointFurnitureDataOuterClass.HomeMarkPointFurnitureData toMarkPointProto() { public HomeMarkPointFurnitureDataOuterClass.HomeMarkPointFurnitureData toMarkPointProto() {
return HomeMarkPointFurnitureDataOuterClass.HomeMarkPointFurnitureData.newBuilder() return HomeMarkPointFurnitureDataOuterClass.HomeMarkPointFurnitureData.newBuilder()
.setFurnitureId(SUITE_FURNITURE_ID) .setFurnitureId(SUITE_FURNITURE_ID)
.setPos(this.pos.toProto()) .setPos(this.pos.toProto())
.setFurnitureType(this.getType().getValue()) .setFurnitureType(this.getType().getValue())
.setGuid(this.guid) .setGuid(this.guid)
.setSuiteData(HomeMarkPointSuiteDataOuterClass.HomeMarkPointSuiteData.newBuilder() .setSuiteData(
HomeMarkPointSuiteDataOuterClass.HomeMarkPointSuiteData.newBuilder()
.setSuiteId(this.suiteId) .setSuiteId(this.suiteId)
.build()) .build())
.build(); .build();

View File

@ -3,13 +3,12 @@ package emu.grasscutter.game.home.suite.event;
import emu.grasscutter.game.inventory.GameItem; import emu.grasscutter.game.inventory.GameItem;
import emu.grasscutter.game.player.Player; import emu.grasscutter.game.player.Player;
import emu.grasscutter.utils.Utils; import emu.grasscutter.utils.Utils;
import java.util.List;
import java.util.Objects;
import lombok.AccessLevel; import lombok.AccessLevel;
import lombok.Getter; import lombok.Getter;
import lombok.experimental.FieldDefaults; import lombok.experimental.FieldDefaults;
import java.util.List;
import java.util.Objects;
@Getter @Getter
@FieldDefaults(level = AccessLevel.PRIVATE) @FieldDefaults(level = AccessLevel.PRIVATE)
public abstract class HomeAvatarEvent { public abstract class HomeAvatarEvent {
@ -21,7 +20,8 @@ public abstract class HomeAvatarEvent {
final int guid; final int guid;
final int randomPos; final int randomPos;
public HomeAvatarEvent(Player homeOwner, int eventId, int rewardId, int avatarId, int suiteId, int guid) { public HomeAvatarEvent(
Player homeOwner, int eventId, int rewardId, int avatarId, int suiteId, int guid) {
this.homeOwner = homeOwner; this.homeOwner = homeOwner;
this.eventId = eventId; this.eventId = eventId;
this.rewardId = rewardId; this.rewardId = rewardId;

View File

@ -5,11 +5,11 @@ import emu.grasscutter.game.inventory.GameItem;
import emu.grasscutter.game.player.Player; import emu.grasscutter.game.player.Player;
import emu.grasscutter.game.props.ActionReason; import emu.grasscutter.game.props.ActionReason;
import emu.grasscutter.net.proto.HomeAvatarRewardEventInfoOuterClass; import emu.grasscutter.net.proto.HomeAvatarRewardEventInfoOuterClass;
import java.util.List; import java.util.List;
public class HomeAvatarRewardEvent extends HomeAvatarEvent { public class HomeAvatarRewardEvent extends HomeAvatarEvent {
public HomeAvatarRewardEvent(Player homeOwner, int eventId, int rewardId, int avatarId, int suiteId, int guid) { public HomeAvatarRewardEvent(
Player homeOwner, int eventId, int rewardId, int avatarId, int suiteId, int guid) {
super(homeOwner, eventId, rewardId, avatarId, suiteId, guid); super(homeOwner, eventId, rewardId, avatarId, suiteId, guid);
} }

View File

@ -13,7 +13,8 @@ public class HomeAvatarSummonEvent extends HomeAvatarEvent {
public static final int TIME_LIMIT_SECS = 240; public static final int TIME_LIMIT_SECS = 240;
final int eventOverTime; final int eventOverTime;
public HomeAvatarSummonEvent(Player homeOwner, int eventId, int rewardId, int avatarId, int suiteId, int guid) { public HomeAvatarSummonEvent(
Player homeOwner, int eventId, int rewardId, int avatarId, int suiteId, int guid) {
super(homeOwner, eventId, rewardId, avatarId, suiteId, guid); super(homeOwner, eventId, rewardId, avatarId, suiteId, guid);
this.eventOverTime = Utils.getCurrentSeconds() + TIME_LIMIT_SECS; this.eventOverTime = Utils.getCurrentSeconds() + TIME_LIMIT_SECS;

View File

@ -2,17 +2,19 @@ package emu.grasscutter.game.home.suite.event;
import emu.grasscutter.data.GameData; import emu.grasscutter.data.GameData;
import emu.grasscutter.data.excels.HomeWorldEventData; import emu.grasscutter.data.excels.HomeWorldEventData;
import javax.annotation.Nullable; import javax.annotation.Nullable;
public enum SuiteEventType { public enum SuiteEventType {
HOME_AVATAR_REWARD_EVENT, HOME_AVATAR_REWARD_EVENT,
HOME_AVATAR_SUMMON_EVENT; HOME_AVATAR_SUMMON_EVENT;
@Nullable @Nullable public HomeWorldEventData getEventDataFrom(int avatarId, int suiteId) {
public HomeWorldEventData getEventDataFrom(int avatarId, int suiteId) {
return GameData.getHomeWorldEventDataMap().values().stream() return GameData.getHomeWorldEventDataMap().values().stream()
.filter(data -> data.getEventType() == this && data.getAvatarID() == avatarId && data.getSuiteId() == suiteId) .filter(
data ->
data.getEventType() == this
&& data.getAvatarID() == avatarId
&& data.getSuiteId() == suiteId)
.findFirst() .findFirst()
.orElse(null); .orElse(null);
} }

View File

@ -16,15 +16,14 @@ public class HandlerHomeAvatarRewardEventGetReq extends PacketHandler {
var req = HomeAvatarRewardEventGetReqOuterClass.HomeAvatarRewardEventGetReq.parseFrom(payload); var req = HomeAvatarRewardEventGetReqOuterClass.HomeAvatarRewardEventGetReq.parseFrom(payload);
var player = session.getPlayer(); var player = session.getPlayer();
var rewardsOrError = player.getCurHomeWorld().getModuleManager().claimAvatarRewards(req.getEventId()); var rewardsOrError =
player.getCurHomeWorld().getModuleManager().claimAvatarRewards(req.getEventId());
session.send(new PacketHomeAvatarRewardEventNotify(player)); session.send(new PacketHomeAvatarRewardEventNotify(player));
session.send(new PacketHomeAvatarAllFinishRewardNotify(player)); session.send(new PacketHomeAvatarAllFinishRewardNotify(player));
session.send( session.send(
rewardsOrError.map( rewardsOrError.map(
gameItems -> new PacketHomeAvatarRewardEventGetRsp(req.getEventId(), gameItems), gameItems -> new PacketHomeAvatarRewardEventGetRsp(req.getEventId(), gameItems),
integer -> new PacketHomeAvatarRewardEventGetRsp(req.getEventId(), integer) integer -> new PacketHomeAvatarRewardEventGetRsp(req.getEventId(), integer)));
)
);
} }
} }

View File

@ -13,7 +13,10 @@ public class HandlerHomeAvatarSummonEventReq extends PacketHandler {
public void handle(GameSession session, byte[] header, byte[] payload) throws Exception { public void handle(GameSession session, byte[] header, byte[] payload) throws Exception {
var req = HomeAvatarSummonEventReqOuterClass.HomeAvatarSummonEventReq.parseFrom(payload); var req = HomeAvatarSummonEventReqOuterClass.HomeAvatarSummonEventReq.parseFrom(payload);
var moduleManager = session.getPlayer().getCurHomeWorld().getModuleManager(); var moduleManager = session.getPlayer().getCurHomeWorld().getModuleManager();
var eventOrError = moduleManager.fireAvatarSummonEvent(session.getPlayer(), req.getAvatarId(), req.getGuid(), req.getSuitId()); var eventOrError =
session.send(eventOrError.map(PacketHomeAvatarSummonEventRsp::new, PacketHomeAvatarSummonEventRsp::new)); moduleManager.fireAvatarSummonEvent(
session.getPlayer(), req.getAvatarId(), req.getGuid(), req.getSuitId());
session.send(
eventOrError.map(PacketHomeAvatarSummonEventRsp::new, PacketHomeAvatarSummonEventRsp::new));
} }
} }

View File

@ -28,7 +28,9 @@ public class HandlerHomeSceneInitFinishReq extends PacketHandler {
} }
} }
curHomeWorld.ifHost(session.getPlayer(), player -> { curHomeWorld.ifHost(
session.getPlayer(),
player -> {
player.sendPacket(new PacketHomeAvatarRewardEventNotify(player)); player.sendPacket(new PacketHomeAvatarRewardEventNotify(player));
player.sendPacket(new PacketHomeAvatarSummonAllEventNotify(player)); player.sendPacket(new PacketHomeAvatarSummonAllEventNotify(player));
}); });

View File

@ -11,7 +11,8 @@ public class PacketHomeAvatarAllFinishRewardNotify extends BasePacket {
var list = player.getHome().getFinishedRewardEventIdSet(); var list = player.getHome().getFinishedRewardEventIdSet();
if (list != null) { if (list != null) {
this.setData(HomeAvatarAllFinishRewardNotifyOuterClass.HomeAvatarAllFinishRewardNotify.newBuilder() this.setData(
HomeAvatarAllFinishRewardNotifyOuterClass.HomeAvatarAllFinishRewardNotify.newBuilder()
.addAllEventIdList(player.getHome().getFinishedRewardEventIdSet())); .addAllEventIdList(player.getHome().getFinishedRewardEventIdSet()));
} }
} }

View File

@ -4,14 +4,14 @@ import emu.grasscutter.game.inventory.GameItem;
import emu.grasscutter.net.packet.BasePacket; import emu.grasscutter.net.packet.BasePacket;
import emu.grasscutter.net.packet.PacketOpcodes; import emu.grasscutter.net.packet.PacketOpcodes;
import emu.grasscutter.net.proto.HomeAvatarRewardEventGetRspOuterClass; import emu.grasscutter.net.proto.HomeAvatarRewardEventGetRspOuterClass;
import java.util.List; import java.util.List;
public class PacketHomeAvatarRewardEventGetRsp extends BasePacket { public class PacketHomeAvatarRewardEventGetRsp extends BasePacket {
public PacketHomeAvatarRewardEventGetRsp(int eventId, List<GameItem> rewards) { public PacketHomeAvatarRewardEventGetRsp(int eventId, List<GameItem> rewards) {
super(PacketOpcodes.HomeAvatarRewardEventGetRsp); super(PacketOpcodes.HomeAvatarRewardEventGetRsp);
this.setData(HomeAvatarRewardEventGetRspOuterClass.HomeAvatarRewardEventGetRsp.newBuilder() this.setData(
HomeAvatarRewardEventGetRspOuterClass.HomeAvatarRewardEventGetRsp.newBuilder()
.setEventId(eventId) .setEventId(eventId)
.addAllItemList(rewards.stream().map(GameItem::toItemParam).toList())); .addAllItemList(rewards.stream().map(GameItem::toItemParam).toList()));
} }
@ -19,7 +19,8 @@ public class PacketHomeAvatarRewardEventGetRsp extends BasePacket {
public PacketHomeAvatarRewardEventGetRsp(int eventId, int retcode) { public PacketHomeAvatarRewardEventGetRsp(int eventId, int retcode) {
super(PacketOpcodes.HomeAvatarRewardEventGetRsp); super(PacketOpcodes.HomeAvatarRewardEventGetRsp);
this.setData(HomeAvatarRewardEventGetRspOuterClass.HomeAvatarRewardEventGetRsp.newBuilder() this.setData(
HomeAvatarRewardEventGetRspOuterClass.HomeAvatarRewardEventGetRsp.newBuilder()
.setEventId(eventId) .setEventId(eventId)
.setRetcode(retcode)); .setRetcode(retcode));
} }

View File

@ -9,14 +9,16 @@ public class PacketHomeAvatarSummonEventRsp extends BasePacket {
public PacketHomeAvatarSummonEventRsp(HomeAvatarSummonEvent event) { public PacketHomeAvatarSummonEventRsp(HomeAvatarSummonEvent event) {
super(PacketOpcodes.HomeAvatarSummonEventRsp); super(PacketOpcodes.HomeAvatarSummonEventRsp);
this.setData(HomeAvatarSummonEventRspOuterClass.HomeAvatarSummonEventRsp.newBuilder() this.setData(
HomeAvatarSummonEventRspOuterClass.HomeAvatarSummonEventRsp.newBuilder()
.setEventId(event.getEventId())); .setEventId(event.getEventId()));
} }
public PacketHomeAvatarSummonEventRsp(int retcode) { public PacketHomeAvatarSummonEventRsp(int retcode) {
super(PacketOpcodes.HomeAvatarSummonEventRsp); super(PacketOpcodes.HomeAvatarSummonEventRsp);
this.setData(HomeAvatarSummonEventRspOuterClass.HomeAvatarSummonEventRsp.newBuilder() this.setData(
HomeAvatarSummonEventRspOuterClass.HomeAvatarSummonEventRsp.newBuilder()
.setRetcode(retcode)); .setRetcode(retcode));
} }
} }

View File

@ -8,7 +8,8 @@ public class PacketHomeAvatarSummonFinishRsp extends BasePacket {
public PacketHomeAvatarSummonFinishRsp(int eventId) { public PacketHomeAvatarSummonFinishRsp(int eventId) {
super(PacketOpcodes.HomeAvatarSummonFinishRsp); super(PacketOpcodes.HomeAvatarSummonFinishRsp);
this.setData(HomeAvatarSummonFinishRspOuterClass.HomeAvatarSummonFinishRsp.newBuilder() this.setData(
HomeAvatarSummonFinishRspOuterClass.HomeAvatarSummonFinishRsp.newBuilder()
.setEventId(eventId)); .setEventId(eventId));
} }
} }

View File

@ -5,10 +5,11 @@ import emu.grasscutter.net.packet.PacketOpcodes;
import emu.grasscutter.net.proto.PlayerQuitFromHomeNotifyOuterClass; import emu.grasscutter.net.proto.PlayerQuitFromHomeNotifyOuterClass;
public class PacketPlayerQuitFromHomeNotify extends BasePacket { public class PacketPlayerQuitFromHomeNotify extends BasePacket {
public PacketPlayerQuitFromHomeNotify(PlayerQuitFromHomeNotifyOuterClass.PlayerQuitFromHomeNotify.QuitReason reason) { public PacketPlayerQuitFromHomeNotify(
PlayerQuitFromHomeNotifyOuterClass.PlayerQuitFromHomeNotify.QuitReason reason) {
super(PacketOpcodes.PlayerQuitFromHomeNotify); super(PacketOpcodes.PlayerQuitFromHomeNotify);
this.setData(PlayerQuitFromHomeNotifyOuterClass.PlayerQuitFromHomeNotify.newBuilder() this.setData(
.setReason(reason)); PlayerQuitFromHomeNotifyOuterClass.PlayerQuitFromHomeNotify.newBuilder().setReason(reason));
} }
} }

View File

@ -14,7 +14,8 @@ public abstract class Either<L, R> {
} }
@Override @Override
public <U, V> Either<U, V> mapBoth(Function<? super L, ? extends U> f1, Function<? super R, ? extends V> f2) { public <U, V> Either<U, V> mapBoth(
Function<? super L, ? extends U> f1, Function<? super R, ? extends V> f2) {
return new Left<>(f1.apply(this.value)); return new Left<>(f1.apply(this.value));
} }
@ -71,7 +72,8 @@ public abstract class Either<L, R> {
} }
@Override @Override
public <U, V> Either<U, V> mapBoth(Function<? super L, ? extends U> f1, Function<? super R, ? extends V> f2) { public <U, V> Either<U, V> mapBoth(
Function<? super L, ? extends U> f1, Function<? super R, ? extends V> f2) {
return new Right<>(f2.apply(this.value)); return new Right<>(f2.apply(this.value));
} }
@ -120,10 +122,10 @@ public abstract class Either<L, R> {
} }
} }
private Either() { private Either() {}
}
public abstract <U, V> Either<U, V> mapBoth(Function<? super L, ? extends U> f1, Function<? super R, ? extends V> f2); public abstract <U, V> Either<U, V> mapBoth(
Function<? super L, ? extends U> f1, Function<? super R, ? extends V> f2);
public abstract <T> T map(Function<? super L, ? extends T> l, Function<? super R, ? extends T> r); public abstract <T> T map(Function<? super L, ? extends T> l, Function<? super R, ? extends T> r);