mirror of
https://github.com/Grasscutters/Grasscutter.git
synced 2025-01-08 08:33:22 +08:00
Format code [skip actions]
This commit is contained in:
parent
f1c1a84683
commit
13c40b53a7
@ -13,17 +13,16 @@ import emu.grasscutter.net.proto.HomeAvatarTalkFinishInfoOuterClass.HomeAvatarTa
|
|||||||
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 it.unimi.dsi.fastutil.ints.IntSets;
|
import it.unimi.dsi.fastutil.ints.IntSets;
|
||||||
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
|
||||||
@ -39,8 +38,9 @@ public class GameHome {
|
|||||||
.map(SceneData::getId)
|
.map(SceneData::getId)
|
||||||
.collect(Collectors.toUnmodifiableSet());
|
.collect(Collectors.toUnmodifiableSet());
|
||||||
public static final Set<Integer> HOME_MODULE_IDS =
|
public static final Set<Integer> HOME_MODULE_IDS =
|
||||||
GameData.getHomeWorldModuleDataMap().isEmpty() ?
|
GameData.getHomeWorldModuleDataMap().isEmpty()
|
||||||
IntSets.fromTo(1, 6) : GameData.getHomeWorldModuleDataMap().keySet();
|
? IntSets.fromTo(1, 6)
|
||||||
|
: GameData.getHomeWorldModuleDataMap().keySet();
|
||||||
|
|
||||||
@Id String id;
|
@Id String id;
|
||||||
|
|
||||||
@ -205,7 +205,9 @@ public class GameHome {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.player.getRealmList().removeIf(integer -> !HOME_MODULE_IDS.contains(integer)); // Delete invalid module ids.
|
this.player
|
||||||
|
.getRealmList()
|
||||||
|
.removeIf(integer -> !HOME_MODULE_IDS.contains(integer)); // Delete invalid module ids.
|
||||||
|
|
||||||
if (this.player.getRealmList().isEmpty()) {
|
if (this.player.getRealmList().isEmpty()) {
|
||||||
this.player.setRealmList(null);
|
this.player.setRealmList(null);
|
||||||
@ -217,7 +219,11 @@ public class GameHome {
|
|||||||
int firstRId = this.player.getRealmList().iterator().next();
|
int firstRId = this.player.getRealmList().iterator().next();
|
||||||
this.player.setCurrentRealmId(firstRId);
|
this.player.setCurrentRealmId(firstRId);
|
||||||
this.player.save();
|
this.player.save();
|
||||||
Grasscutter.getLogger().info("Set player {}'s current realm id to {} cuz the id is invalid.", this.player.getUid(), firstRId);
|
Grasscutter.getLogger()
|
||||||
|
.info(
|
||||||
|
"Set player {}'s current realm id to {} cuz the id is invalid.",
|
||||||
|
this.player.getUid(),
|
||||||
|
firstRId);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.player.getCurHomeWorld().refreshModuleManager(); // Apply module id fix.
|
this.player.getCurHomeWorld().refreshModuleManager(); // Apply module id fix.
|
||||||
@ -268,8 +274,7 @@ public class GameHome {
|
|||||||
return this.finishedTalkIdMap.get(avatarId);
|
return this.finishedTalkIdMap.get(avatarId);
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<HomeAvatarTalkFinishInfo>
|
public List<HomeAvatarTalkFinishInfo> toAvatarTalkFinishInfoProto() {
|
||||||
toAvatarTalkFinishInfoProto() {
|
|
||||||
if (this.finishedTalkIdMap == null) {
|
if (this.finishedTalkIdMap == null) {
|
||||||
this.finishedTalkIdMap = new HashMap<>();
|
this.finishedTalkIdMap = new HashMap<>();
|
||||||
}
|
}
|
||||||
|
@ -12,14 +12,13 @@ import emu.grasscutter.net.proto.HomeAvatarSummonAllEventNotifyOuterClass.HomeAv
|
|||||||
import emu.grasscutter.net.proto.RetcodeOuterClass.Retcode;
|
import emu.grasscutter.net.proto.RetcodeOuterClass.Retcode;
|
||||||
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 javax.annotation.Nullable;
|
||||||
import lombok.AccessLevel;
|
import lombok.AccessLevel;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.experimental.FieldDefaults;
|
import lombok.experimental.FieldDefaults;
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
|
||||||
import java.util.*;
|
|
||||||
import java.util.stream.Stream;
|
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
@FieldDefaults(level = AccessLevel.PRIVATE)
|
@FieldDefaults(level = AccessLevel.PRIVATE)
|
||||||
public class HomeModuleManager {
|
public class HomeModuleManager {
|
||||||
@ -27,10 +26,8 @@ public class HomeModuleManager {
|
|||||||
final HomeWorld homeWorld;
|
final HomeWorld homeWorld;
|
||||||
final GameHome home;
|
final GameHome home;
|
||||||
final int moduleId;
|
final int moduleId;
|
||||||
@Nullable
|
@Nullable final HomeScene outdoor;
|
||||||
final HomeScene outdoor;
|
@Nullable HomeScene indoor;
|
||||||
@Nullable
|
|
||||||
HomeScene indoor;
|
|
||||||
final List<HomeAvatarRewardEvent> rewardEvents;
|
final List<HomeAvatarRewardEvent> rewardEvents;
|
||||||
final List<HomeAvatarSummonEvent> summonEvents;
|
final List<HomeAvatarSummonEvent> summonEvents;
|
||||||
|
|
||||||
@ -77,45 +74,45 @@ public class HomeModuleManager {
|
|||||||
private void fireAllAvatarRewardEvents() {
|
private void fireAllAvatarRewardEvents() {
|
||||||
this.rewardEvents.clear();
|
this.rewardEvents.clear();
|
||||||
var allBlockItems =
|
var allBlockItems =
|
||||||
Stream.of(this.getOutdoorSceneItem(), this.getIndoorSceneItem())
|
Stream.of(this.getOutdoorSceneItem(), this.getIndoorSceneItem())
|
||||||
.filter(Objects::nonNull)
|
.filter(Objects::nonNull)
|
||||||
.map(HomeSceneItem::getBlockItems)
|
.map(HomeSceneItem::getBlockItems)
|
||||||
.map(Map::values)
|
.map(Map::values)
|
||||||
.flatMap(Collection::stream)
|
.flatMap(Collection::stream)
|
||||||
.toList();
|
.toList();
|
||||||
|
|
||||||
var suites =
|
var suites =
|
||||||
allBlockItems.stream()
|
allBlockItems.stream()
|
||||||
.map(HomeBlockItem::getSuiteList)
|
.map(HomeBlockItem::getSuiteList)
|
||||||
.filter(Objects::nonNull)
|
.filter(Objects::nonNull)
|
||||||
.flatMap(Collection::stream)
|
.flatMap(Collection::stream)
|
||||||
.distinct()
|
.distinct()
|
||||||
.toList();
|
.toList();
|
||||||
|
|
||||||
allBlockItems.stream()
|
allBlockItems.stream()
|
||||||
.map(HomeBlockItem::getDeployNPCList)
|
.map(HomeBlockItem::getDeployNPCList)
|
||||||
.flatMap(Collection::stream)
|
.flatMap(Collection::stream)
|
||||||
.forEach(
|
.forEach(
|
||||||
avatar -> {
|
avatar -> {
|
||||||
suites.forEach(
|
suites.forEach(
|
||||||
suite -> {
|
suite -> {
|
||||||
var data =
|
var data =
|
||||||
SuiteEventType.HOME_AVATAR_REWARD_EVENT.getEventDataFrom(
|
SuiteEventType.HOME_AVATAR_REWARD_EVENT.getEventDataFrom(
|
||||||
avatar.getAvatarId(), suite.getSuiteId());
|
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(
|
this.rewardEvents.add(
|
||||||
new HomeAvatarRewardEvent(
|
new HomeAvatarRewardEvent(
|
||||||
homeOwner,
|
homeOwner,
|
||||||
data.getId(),
|
data.getId(),
|
||||||
data.getRewardID(),
|
data.getRewardID(),
|
||||||
data.getAvatarID(),
|
data.getAvatarID(),
|
||||||
data.getSuiteId(),
|
data.getSuiteId(),
|
||||||
suite.getGuid()));
|
suite.getGuid()));
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
|
||||||
|
|
||||||
if (this.summonEvents != null) {
|
if (this.summonEvents != null) {
|
||||||
var suiteIdList = this.rewardEvents.stream().map(HomeAvatarRewardEvent::getSuiteId).toList();
|
var suiteIdList = this.rewardEvents.stream().map(HomeAvatarRewardEvent::getSuiteId).toList();
|
||||||
@ -125,15 +122,15 @@ public class HomeModuleManager {
|
|||||||
|
|
||||||
private void cancelSummonEventsIfAvatarLeave() {
|
private void cancelSummonEventsIfAvatarLeave() {
|
||||||
var avatars =
|
var avatars =
|
||||||
Stream.of(this.getOutdoorSceneItem(), this.getIndoorSceneItem())
|
Stream.of(this.getOutdoorSceneItem(), this.getIndoorSceneItem())
|
||||||
.filter(Objects::nonNull)
|
.filter(Objects::nonNull)
|
||||||
.map(HomeSceneItem::getBlockItems)
|
.map(HomeSceneItem::getBlockItems)
|
||||||
.map(Map::values)
|
.map(Map::values)
|
||||||
.flatMap(Collection::stream)
|
.flatMap(Collection::stream)
|
||||||
.map(HomeBlockItem::getDeployNPCList)
|
.map(HomeBlockItem::getDeployNPCList)
|
||||||
.flatMap(Collection::stream)
|
.flatMap(Collection::stream)
|
||||||
.map(HomeNPCItem::getAvatarId)
|
.map(HomeNPCItem::getAvatarId)
|
||||||
.toList();
|
.toList();
|
||||||
|
|
||||||
this.summonEvents.removeIf(event -> !avatars.contains(event.getAvatarId()));
|
this.summonEvents.removeIf(event -> !avatars.contains(event.getAvatarId()));
|
||||||
}
|
}
|
||||||
@ -156,16 +153,16 @@ public class HomeModuleManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public Either<HomeAvatarSummonEvent, Integer> fireAvatarSummonEvent(
|
public Either<HomeAvatarSummonEvent, Integer> fireAvatarSummonEvent(
|
||||||
Player owner, int avatarId, int guid, int suiteId) {
|
Player owner, int avatarId, int guid, int suiteId) {
|
||||||
HomeSuiteItem targetSuite = null;
|
HomeSuiteItem targetSuite = null;
|
||||||
if (owner.getScene() instanceof HomeScene homeScene) {
|
if (owner.getScene() instanceof HomeScene homeScene) {
|
||||||
targetSuite = homeScene
|
targetSuite =
|
||||||
.getSceneItem().getBlockItems().values().stream()
|
homeScene.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)
|
||||||
.findFirst()
|
.findFirst()
|
||||||
.orElse(null);
|
.orElse(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.isInRewardEvent(avatarId)) {
|
if (this.isInRewardEvent(avatarId)) {
|
||||||
@ -188,8 +185,8 @@ public class HomeModuleManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var event =
|
var event =
|
||||||
new HomeAvatarSummonEvent(
|
new HomeAvatarSummonEvent(
|
||||||
owner, eventData.getId(), eventData.getRewardID(), avatarId, suiteId, guid);
|
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);
|
||||||
@ -205,9 +202,9 @@ public class HomeModuleManager {
|
|||||||
notify.setRewardEvent(this.rewardEvents.get(0).toProto()).setIsEventTrigger(true);
|
notify.setRewardEvent(this.rewardEvents.get(0).toProto()).setIsEventTrigger(true);
|
||||||
|
|
||||||
notify.addAllPendingList(
|
notify.addAllPendingList(
|
||||||
this.rewardEvents.subList(1, this.rewardEvents.size()).stream()
|
this.rewardEvents.subList(1, this.rewardEvents.size()).stream()
|
||||||
.map(HomeAvatarRewardEvent::toProto)
|
.map(HomeAvatarRewardEvent::toProto)
|
||||||
.toList());
|
.toList());
|
||||||
}
|
}
|
||||||
|
|
||||||
return notify.build();
|
return notify.build();
|
||||||
@ -215,22 +212,20 @@ public class HomeModuleManager {
|
|||||||
|
|
||||||
public HomeAvatarSummonAllEventNotify toSummonEventProto() {
|
public HomeAvatarSummonAllEventNotify toSummonEventProto() {
|
||||||
return HomeAvatarSummonAllEventNotify.newBuilder()
|
return HomeAvatarSummonAllEventNotify.newBuilder()
|
||||||
.addAllSummonEventList(
|
.addAllSummonEventList(
|
||||||
this.summonEvents.stream().map(HomeAvatarSummonEvent::toProto).toList())
|
this.summonEvents.stream().map(HomeAvatarSummonEvent::toProto).toList())
|
||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isInRewardEvent(int avatarId) {
|
public boolean isInRewardEvent(int avatarId) {
|
||||||
return this.rewardEvents.stream().anyMatch(e -> e.getAvatarId() == avatarId);
|
return this.rewardEvents.stream().anyMatch(e -> e.getAvatarId() == avatarId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable public HomeSceneItem getOutdoorSceneItem() {
|
||||||
public HomeSceneItem getOutdoorSceneItem() {
|
|
||||||
return this.outdoor == null ? null : this.outdoor.getSceneItem();
|
return this.outdoor == null ? null : this.outdoor.getSceneItem();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable public HomeSceneItem getIndoorSceneItem() {
|
||||||
public HomeSceneItem getIndoorSceneItem() {
|
|
||||||
return this.indoor == null ? null : this.indoor.getSceneItem();
|
return this.indoor == null ? null : this.indoor.getSceneItem();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -10,11 +10,10 @@ 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 javax.annotation.Nullable;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
|
import javax.annotation.Nullable;
|
||||||
|
import lombok.Getter;
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
public class HomeWorld extends World {
|
public class HomeWorld extends World {
|
||||||
@ -170,8 +169,7 @@ public class HomeWorld extends World {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Nullable
|
@Nullable public HomeScene getSceneById(int sceneId) {
|
||||||
public HomeScene getSceneById(int sceneId) {
|
|
||||||
var scene = this.getScenes().get(sceneId);
|
var scene = this.getScenes().get(sceneId);
|
||||||
if (scene instanceof HomeScene homeScene) {
|
if (scene instanceof HomeScene homeScene) {
|
||||||
return homeScene;
|
return homeScene;
|
||||||
|
@ -144,10 +144,7 @@ public class HomeWorldMPSystem extends BaseGameSystem {
|
|||||||
|
|
||||||
Position pos;
|
Position pos;
|
||||||
if (scene != null) {
|
if (scene != null) {
|
||||||
pos =
|
pos = toSafe ? scene.getScriptManager().getConfig().born_pos : item.getBornPos();
|
||||||
toSafe
|
|
||||||
? scene.getScriptManager().getConfig().born_pos
|
|
||||||
: item.getBornPos();
|
|
||||||
} else {
|
} else {
|
||||||
pos = item.getBornPos();
|
pos = item.getBornPos();
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
package emu.grasscutter.game.world;
|
package emu.grasscutter.game.world;
|
||||||
|
|
||||||
|
import static emu.grasscutter.server.event.player.PlayerTeleportEvent.TeleportType.SCRIPT;
|
||||||
|
|
||||||
import emu.grasscutter.Grasscutter;
|
import emu.grasscutter.Grasscutter;
|
||||||
import emu.grasscutter.data.GameData;
|
import emu.grasscutter.data.GameData;
|
||||||
import emu.grasscutter.data.excels.dungeon.DungeonData;
|
import emu.grasscutter.data.excels.dungeon.DungeonData;
|
||||||
@ -27,11 +29,6 @@ import io.netty.util.concurrent.FastThreadLocalThread;
|
|||||||
import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
|
import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
|
||||||
import it.unimi.dsi.fastutil.ints.Int2ObjectMaps;
|
import it.unimi.dsi.fastutil.ints.Int2ObjectMaps;
|
||||||
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
|
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
|
||||||
import lombok.Getter;
|
|
||||||
import lombok.val;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
@ -40,8 +37,10 @@ import java.util.concurrent.ExecutorService;
|
|||||||
import java.util.concurrent.LinkedBlockingDeque;
|
import java.util.concurrent.LinkedBlockingDeque;
|
||||||
import java.util.concurrent.ThreadPoolExecutor;
|
import java.util.concurrent.ThreadPoolExecutor;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
import javax.annotation.Nullable;
|
||||||
import static emu.grasscutter.server.event.player.PlayerTeleportEvent.TeleportType.SCRIPT;
|
import lombok.Getter;
|
||||||
|
import lombok.val;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
public class World implements Iterable<Player> {
|
public class World implements Iterable<Player> {
|
||||||
@Getter private final GameServer server;
|
@Getter private final GameServer server;
|
||||||
@ -140,8 +139,7 @@ public class World implements Iterable<Player> {
|
|||||||
* @param sceneId The scene ID.
|
* @param sceneId The scene ID.
|
||||||
* @return The scene.
|
* @return The scene.
|
||||||
*/
|
*/
|
||||||
@Nullable
|
@Nullable public Scene getSceneById(int sceneId) {
|
||||||
public Scene getSceneById(int sceneId) {
|
|
||||||
// Get scene normally
|
// Get scene normally
|
||||||
var scene = this.getScenes().get(sceneId);
|
var scene = this.getScenes().get(sceneId);
|
||||||
if (scene != null) {
|
if (scene != null) {
|
||||||
|
@ -34,8 +34,7 @@ public class HandlerHomeSceneJumpReq extends PacketHandler {
|
|||||||
pos = home.getSceneMap().get(realmId).getBornPos();
|
pos = home.getSceneMap().get(realmId).getBornPos();
|
||||||
}
|
}
|
||||||
|
|
||||||
world.transferPlayerToScene(
|
world.transferPlayerToScene(session.getPlayer(), scene.getId(), pos);
|
||||||
session.getPlayer(), scene.getId(), pos);
|
|
||||||
|
|
||||||
session.send(new PacketHomeSceneJumpRsp(req.getIsEnterRoomScene()));
|
session.send(new PacketHomeSceneJumpRsp(req.getIsEnterRoomScene()));
|
||||||
}
|
}
|
||||||
|
@ -10,10 +10,8 @@ public class PacketHomeChangeModuleRsp extends BasePacket {
|
|||||||
public PacketHomeChangeModuleRsp(int targetModuleId) {
|
public PacketHomeChangeModuleRsp(int targetModuleId) {
|
||||||
super(PacketOpcodes.HomeChangeModuleRsp);
|
super(PacketOpcodes.HomeChangeModuleRsp);
|
||||||
|
|
||||||
var proto = HomeChangeModuleRsp.newBuilder()
|
var proto =
|
||||||
.setRetcode(0)
|
HomeChangeModuleRsp.newBuilder().setRetcode(0).setTargetModuleId(targetModuleId).build();
|
||||||
.setTargetModuleId(targetModuleId)
|
|
||||||
.build();
|
|
||||||
|
|
||||||
this.setData(proto);
|
this.setData(proto);
|
||||||
}
|
}
|
||||||
@ -21,7 +19,6 @@ public class PacketHomeChangeModuleRsp extends BasePacket {
|
|||||||
public PacketHomeChangeModuleRsp(Retcode retcode) {
|
public PacketHomeChangeModuleRsp(Retcode retcode) {
|
||||||
super(PacketOpcodes.HomeChangeModuleRsp);
|
super(PacketOpcodes.HomeChangeModuleRsp);
|
||||||
|
|
||||||
this.setData(HomeChangeModuleRsp.newBuilder()
|
this.setData(HomeChangeModuleRsp.newBuilder().setRetcode(retcode.getNumber()));
|
||||||
.setRetcode(retcode.getNumber()));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -8,7 +8,6 @@ import emu.grasscutter.net.packet.BasePacket;
|
|||||||
import emu.grasscutter.net.packet.PacketOpcodes;
|
import emu.grasscutter.net.packet.PacketOpcodes;
|
||||||
import emu.grasscutter.net.proto.HomeMarkPointNotifyOuterClass.HomeMarkPointNotify;
|
import emu.grasscutter.net.proto.HomeMarkPointNotifyOuterClass.HomeMarkPointNotify;
|
||||||
import emu.grasscutter.net.proto.HomeMarkPointSceneDataOuterClass.HomeMarkPointSceneData;
|
import emu.grasscutter.net.proto.HomeMarkPointSceneDataOuterClass.HomeMarkPointSceneData;
|
||||||
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
@ -30,41 +29,43 @@ public class PacketHomeMarkPointNotify extends BasePacket {
|
|||||||
var moduleId = owner.getCurrentRealmId();
|
var moduleId = owner.getCurrentRealmId();
|
||||||
var scene = world.getSceneById(moduleId + 2000);
|
var scene = world.getSceneById(moduleId + 2000);
|
||||||
if (scene == null) {
|
if (scene == null) {
|
||||||
Grasscutter.getLogger().warn("Current Realm id is invalid! SceneExcelConfigData.json, game resource not loaded correctly or the realm id maybe wrong?!");
|
Grasscutter.getLogger()
|
||||||
|
.warn(
|
||||||
|
"Current Realm id is invalid! SceneExcelConfigData.json, game resource not loaded correctly or the realm id maybe wrong?!");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var homeScene = home.getHomeSceneItem(moduleId + 2000);
|
var homeScene = home.getHomeSceneItem(moduleId + 2000);
|
||||||
var mainHouse = home.getMainHouseItem(moduleId + 2000);
|
var mainHouse = home.getMainHouseItem(moduleId + 2000);
|
||||||
|
|
||||||
Set.of(homeScene, mainHouse)
|
Set.of(homeScene, mainHouse)
|
||||||
.forEach(
|
.forEach(
|
||||||
homeSceneItem -> {
|
homeSceneItem -> {
|
||||||
var markPointData =
|
var markPointData =
|
||||||
HomeMarkPointSceneData.newBuilder()
|
HomeMarkPointSceneData.newBuilder()
|
||||||
.setModuleId(moduleId)
|
.setModuleId(moduleId)
|
||||||
.setSceneId(homeSceneItem.getSceneId());
|
.setSceneId(homeSceneItem.getSceneId());
|
||||||
|
|
||||||
if (!homeSceneItem.isRoom()) {
|
if (!homeSceneItem.isRoom()) {
|
||||||
var config = scene.getScriptManager().getConfig();
|
var config = scene.getScriptManager().getConfig();
|
||||||
markPointData
|
markPointData
|
||||||
.setSafePointPos(
|
.setSafePointPos(
|
||||||
config == null
|
config == null
|
||||||
? homeSceneItem.getBornPos().toProto()
|
? homeSceneItem.getBornPos().toProto()
|
||||||
: config.born_pos.toProto())
|
: config.born_pos.toProto())
|
||||||
.setTeapotSpiritPos(homeSceneItem.getDjinnPos().toProto());
|
.setTeapotSpiritPos(homeSceneItem.getDjinnPos().toProto());
|
||||||
}
|
}
|
||||||
|
|
||||||
var marks =
|
var marks =
|
||||||
homeSceneItem.getBlockItems().values().stream()
|
homeSceneItem.getBlockItems().values().stream()
|
||||||
.map(HomeBlockItem::getMarkPointProtoFactories)
|
.map(HomeBlockItem::getMarkPointProtoFactories)
|
||||||
.flatMap(Collection::stream)
|
.flatMap(Collection::stream)
|
||||||
.filter(HomeMarkPointProtoFactory::isProtoConvertible)
|
.filter(HomeMarkPointProtoFactory::isProtoConvertible)
|
||||||
.map(HomeMarkPointProtoFactory::toMarkPointProto)
|
.map(HomeMarkPointProtoFactory::toMarkPointProto)
|
||||||
.toList();
|
.toList();
|
||||||
|
|
||||||
markPointData.addAllFurnitureList(marks);
|
markPointData.addAllFurnitureList(marks);
|
||||||
proto.addMarkPointDataList(markPointData);
|
proto.addMarkPointDataList(markPointData);
|
||||||
});
|
});
|
||||||
|
|
||||||
this.setData(proto);
|
this.setData(proto);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user