Format code [skip actions]

This commit is contained in:
github-actions 2023-09-02 23:06:00 +00:00
parent 1894296ed4
commit 88d7be86da
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.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 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.concurrent.atomic.AtomicReference; import java.util.concurrent.atomic.AtomicReference;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import javax.annotation.Nullable;
import lombok.*; import lombok.*;
import lombok.experimental.FieldDefaults; import lombok.experimental.FieldDefaults;
@ -84,8 +83,7 @@ public class HomeSceneItem {
return mainHouse == null || mainHouse.getAsItem() == null; return mainHouse == null || mainHouse.getAsItem() == null;
} }
@Nullable @Nullable public Position getTeleportPointPos(int guid) {
public Position getTeleportPointPos(int guid) {
var pos = new AtomicReference<Position>(); var pos = new AtomicReference<Position>();
this.getBlockItems().values().stream() this.getBlockItems().values().stream()

View File

@ -143,7 +143,10 @@ public class HomeWorldMPSystem extends BaseGameSystem {
int realmId = 2000 + owner.getCurrentRealmId(); int realmId = 2000 + owner.getCurrentRealmId();
var item = targetHome.getHomeSceneItem(realmId); var item = targetHome.getHomeSceneItem(realmId);
targetHome.save(); 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) { if (teleportPoint != 0) {
var target = item.getTeleportPointPos(teleportPoint); var target = item.getTeleportPointPos(teleportPoint);
@ -202,12 +205,23 @@ public class HomeWorldMPSystem extends BaseGameSystem {
player.getPosition().set(pos); player.getPosition().set(pos);
var world = new World(player); var world = new World(player);
world.addPlayer(player, prevScene); 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); var myHome = this.server.getHomeWorldOrCreate(player);
player.setCurHomeWorld(myHome); player.setCurHomeWorld(myHome);
myHome.getHome().onOwnerLogin(player); 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; return true;
} }
@ -239,7 +253,12 @@ public class HomeWorldMPSystem extends BaseGameSystem {
victim.getPosition().set(victim.getPrevPosForHome()); victim.getPosition().set(victim.getPrevPosForHome());
var world = new World(victim); var world = new World(victim);
world.addPlayer(victim, 3); 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); var myHome = this.server.getHomeWorldOrCreate(victim);
victim.setCurHomeWorld(myHome); victim.setCurHomeWorld(myHome);
myHome.getHome().onOwnerLogin(victim); myHome.getHome().onOwnerLogin(victim);

View File

@ -16,7 +16,15 @@ public class HandlerHomeTransferReq extends PacketHandler {
var home = player.getCurHomeWorld().getHome(); var home = player.getCurHomeWorld().getHome();
var item = home.getHomeSceneItem(player.getSceneId()); 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) { if (req.getGuid() != 0) {
var target = item.getTeleportPointPos(req.getGuid()); var target = item.getTeleportPointPos(req.getGuid());
if (target != null) { if (target != null) {

View File

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