Merge remote-tracking branch 'origin/development' into development

This commit is contained in:
KingRainbow44 2023-09-02 19:48:39 -04:00
commit 34589d0128
No known key found for this signature in database
GPG Key ID: FC2CB64B00D257BE
4 changed files with 58 additions and 19 deletions

View File

@ -9,13 +9,12 @@ import emu.grasscutter.game.entity.EntityHomeAnimal;
import emu.grasscutter.game.world.Position;
import emu.grasscutter.game.world.Scene;
import emu.grasscutter.net.proto.HomeSceneArrangementInfoOuterClass.HomeSceneArrangementInfo;
import javax.annotation.Nullable;
import java.util.Collection;
import java.util.List;
import java.util.Map;
import java.util.concurrent.atomic.AtomicReference;
import java.util.stream.Collectors;
import javax.annotation.Nullable;
import lombok.*;
import lombok.experimental.FieldDefaults;
@ -84,17 +83,16 @@ public class HomeSceneItem {
return mainHouse == null || mainHouse.getAsItem() == null;
}
@Nullable
public Position getTeleportPointPos(int guid) {
@Nullable public Position getTeleportPointPos(int guid) {
var pos = new AtomicReference<Position>();
this.getBlockItems().values().stream()
.map(HomeBlockItem::getDeployFurnitureList)
.flatMap(Collection::stream)
.filter(homeFurnitureItem -> homeFurnitureItem.getGuid() == guid)
.map(HomeFurnitureItem::getSpawnPos)
.findFirst()
.ifPresent(pos::set);
.map(HomeBlockItem::getDeployFurnitureList)
.flatMap(Collection::stream)
.filter(homeFurnitureItem -> homeFurnitureItem.getGuid() == guid)
.map(HomeFurnitureItem::getSpawnPos)
.findFirst()
.ifPresent(pos::set);
return pos.get();
}

View File

@ -143,7 +143,10 @@ public class HomeWorldMPSystem extends BaseGameSystem {
int realmId = 2000 + owner.getCurrentRealmId();
var item = targetHome.getHomeSceneItem(realmId);
targetHome.save();
var pos = toSafe ? world.getSceneById(realmId).getScriptManager().getConfig().born_pos : item.getBornPos();
var pos =
toSafe
? world.getSceneById(realmId).getScriptManager().getConfig().born_pos
: item.getBornPos();
if (teleportPoint != 0) {
var target = item.getTeleportPointPos(teleportPoint);
@ -202,12 +205,23 @@ public class HomeWorldMPSystem extends BaseGameSystem {
player.getPosition().set(pos);
var world = new World(player);
world.addPlayer(player, prevScene);
player.getCurHomeWorld().sendPacketToHostIfOnline(new PacketOtherPlayerEnterOrLeaveHomeNotify(player, OtherPlayerEnterHomeNotifyOuterClass.OtherPlayerEnterHomeNotify.Reason.LEAVE));
player
.getCurHomeWorld()
.sendPacketToHostIfOnline(
new PacketOtherPlayerEnterOrLeaveHomeNotify(
player,
OtherPlayerEnterHomeNotifyOuterClass.OtherPlayerEnterHomeNotify.Reason.LEAVE));
var myHome = this.server.getHomeWorldOrCreate(player);
player.setCurHomeWorld(myHome);
myHome.getHome().onOwnerLogin(player);
player.sendPacket(new PacketPlayerEnterSceneNotify(player, EnterTypeOuterClass.EnterType.ENTER_TYPE_BACK, EnterReason.TeamBack, prevScene, pos));
player.sendPacket(
new PacketPlayerEnterSceneNotify(
player,
EnterTypeOuterClass.EnterType.ENTER_TYPE_BACK,
EnterReason.TeamBack,
prevScene,
pos));
return true;
}
@ -239,7 +253,12 @@ public class HomeWorldMPSystem extends BaseGameSystem {
victim.getPosition().set(victim.getPrevPosForHome());
var world = new World(victim);
world.addPlayer(victim, 3);
victim.getCurHomeWorld().sendPacketToHostIfOnline(new PacketOtherPlayerEnterOrLeaveHomeNotify(victim, OtherPlayerEnterHomeNotifyOuterClass.OtherPlayerEnterHomeNotify.Reason.LEAVE));
victim
.getCurHomeWorld()
.sendPacketToHostIfOnline(
new PacketOtherPlayerEnterOrLeaveHomeNotify(
victim,
OtherPlayerEnterHomeNotifyOuterClass.OtherPlayerEnterHomeNotify.Reason.LEAVE));
var myHome = this.server.getHomeWorldOrCreate(victim);
victim.setCurHomeWorld(myHome);
myHome.getHome().onOwnerLogin(victim);

View File

@ -16,7 +16,15 @@ public class HandlerHomeTransferReq extends PacketHandler {
var home = player.getCurHomeWorld().getHome();
var item = home.getHomeSceneItem(player.getSceneId());
var pos = req.getIsTransferToMainHousePoint() ? item.getBornPos() : player.getCurHomeWorld().getSceneById(player.getSceneId()).getScriptManager().getConfig().born_pos;
var pos =
req.getIsTransferToMainHousePoint()
? item.getBornPos()
: player
.getCurHomeWorld()
.getSceneById(player.getSceneId())
.getScriptManager()
.getConfig()
.born_pos;
if (req.getGuid() != 0) {
var target = item.getTeleportPointPos(req.getGuid());
if (target != null) {

View File

@ -50,15 +50,29 @@ public class HandlerTryEnterHomeReq extends PacketHandler {
req.getTargetUid()));
}
case FriendEnterHomeOptionOuterClass.FriendEnterHomeOption.FRIEND_ENTER_HOME_OPTION_DIRECT_VALUE -> {
session.getServer().getHomeWorldMPSystem().enterHome(session.getPlayer(), targetPlayer, req.getTargetPoint(), req.getIsTransferToSafePoint());
case FriendEnterHomeOptionOuterClass.FriendEnterHomeOption
.FRIEND_ENTER_HOME_OPTION_DIRECT_VALUE -> {
session
.getServer()
.getHomeWorldMPSystem()
.enterHome(
session.getPlayer(),
targetPlayer,
req.getTargetPoint(),
req.getIsTransferToSafePoint());
}
}
return;
}
session.getServer().getHomeWorldMPSystem().enterHome(session.getPlayer(), targetPlayer, req.getTargetPoint(), req.getIsTransferToSafePoint());
session
.getServer()
.getHomeWorldMPSystem()
.enterHome(
session.getPlayer(),
targetPlayer,
req.getTargetPoint(),
req.getIsTransferToSafePoint());
}
}