Format code [skip actions]

This commit is contained in:
github-actions 2023-11-10 02:57:50 +00:00
parent f1c1a84683
commit 13c40b53a7
8 changed files with 124 additions and 134 deletions

View File

@ -13,17 +13,16 @@ import emu.grasscutter.net.proto.HomeAvatarTalkFinishInfoOuterClass.HomeAvatarTa
import emu.grasscutter.server.packet.send.*;
import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
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.temporal.ChronoUnit;
import java.util.*;
import java.util.concurrent.ConcurrentHashMap;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import lombok.AccessLevel;
import lombok.Builder;
import lombok.Data;
import lombok.experimental.FieldDefaults;
@Entity(value = "homes", useDiscriminator = false)
@Data
@ -39,8 +38,9 @@ public class GameHome {
.map(SceneData::getId)
.collect(Collectors.toUnmodifiableSet());
public static final Set<Integer> HOME_MODULE_IDS =
GameData.getHomeWorldModuleDataMap().isEmpty() ?
IntSets.fromTo(1, 6) : GameData.getHomeWorldModuleDataMap().keySet();
GameData.getHomeWorldModuleDataMap().isEmpty()
? IntSets.fromTo(1, 6)
: GameData.getHomeWorldModuleDataMap().keySet();
@Id String id;
@ -205,7 +205,9 @@ public class GameHome {
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()) {
this.player.setRealmList(null);
@ -217,7 +219,11 @@ public class GameHome {
int firstRId = this.player.getRealmList().iterator().next();
this.player.setCurrentRealmId(firstRId);
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.
@ -268,8 +274,7 @@ public class GameHome {
return this.finishedTalkIdMap.get(avatarId);
}
public List<HomeAvatarTalkFinishInfo>
toAvatarTalkFinishInfoProto() {
public List<HomeAvatarTalkFinishInfo> toAvatarTalkFinishInfoProto() {
if (this.finishedTalkIdMap == null) {
this.finishedTalkIdMap = new HashMap<>();
}

View File

@ -12,14 +12,13 @@ import emu.grasscutter.net.proto.HomeAvatarSummonAllEventNotifyOuterClass.HomeAv
import emu.grasscutter.net.proto.RetcodeOuterClass.Retcode;
import emu.grasscutter.server.packet.send.PacketHomeAvatarSummonAllEventNotify;
import emu.grasscutter.utils.Either;
import java.util.*;
import java.util.stream.Stream;
import javax.annotation.Nullable;
import lombok.AccessLevel;
import lombok.Getter;
import lombok.experimental.FieldDefaults;
import javax.annotation.Nullable;
import java.util.*;
import java.util.stream.Stream;
@Getter
@FieldDefaults(level = AccessLevel.PRIVATE)
public class HomeModuleManager {
@ -27,10 +26,8 @@ public class HomeModuleManager {
final HomeWorld homeWorld;
final GameHome home;
final int moduleId;
@Nullable
final HomeScene outdoor;
@Nullable
HomeScene indoor;
@Nullable final HomeScene outdoor;
@Nullable HomeScene indoor;
final List<HomeAvatarRewardEvent> rewardEvents;
final List<HomeAvatarSummonEvent> summonEvents;
@ -159,8 +156,8 @@ public class HomeModuleManager {
Player owner, int avatarId, int guid, int suiteId) {
HomeSuiteItem targetSuite = null;
if (owner.getScene() instanceof HomeScene homeScene) {
targetSuite = homeScene
.getSceneItem().getBlockItems().values().stream()
targetSuite =
homeScene.getSceneItem().getBlockItems().values().stream()
.map(HomeBlockItem::getSuiteList)
.flatMap(Collection::stream)
.filter(suite -> suite.getGuid() == guid)
@ -224,13 +221,11 @@ public class HomeModuleManager {
return this.rewardEvents.stream().anyMatch(e -> e.getAvatarId() == avatarId);
}
@Nullable
public HomeSceneItem getOutdoorSceneItem() {
@Nullable public HomeSceneItem getOutdoorSceneItem() {
return this.outdoor == null ? null : this.outdoor.getSceneItem();
}
@Nullable
public HomeSceneItem getIndoorSceneItem() {
@Nullable public HomeSceneItem getIndoorSceneItem() {
return this.indoor == null ? null : this.indoor.getSceneItem();
}

View File

@ -10,11 +10,10 @@ import emu.grasscutter.server.game.GameServer;
import emu.grasscutter.server.packet.send.PacketDelTeamEntityNotify;
import emu.grasscutter.server.packet.send.PacketPlayerChatNotify;
import emu.grasscutter.server.packet.send.PacketPlayerGameTimeNotify;
import lombok.Getter;
import javax.annotation.Nullable;
import java.util.List;
import java.util.function.Consumer;
import javax.annotation.Nullable;
import lombok.Getter;
@Getter
public class HomeWorld extends World {
@ -170,8 +169,7 @@ public class HomeWorld extends World {
}
@Override
@Nullable
public HomeScene getSceneById(int sceneId) {
@Nullable public HomeScene getSceneById(int sceneId) {
var scene = this.getScenes().get(sceneId);
if (scene instanceof HomeScene homeScene) {
return homeScene;

View File

@ -144,10 +144,7 @@ public class HomeWorldMPSystem extends BaseGameSystem {
Position pos;
if (scene != null) {
pos =
toSafe
? scene.getScriptManager().getConfig().born_pos
: item.getBornPos();
pos = toSafe ? scene.getScriptManager().getConfig().born_pos : item.getBornPos();
} else {
pos = item.getBornPos();
}

View File

@ -1,5 +1,7 @@
package emu.grasscutter.game.world;
import static emu.grasscutter.server.event.player.PlayerTeleportEvent.TeleportType.SCRIPT;
import emu.grasscutter.Grasscutter;
import emu.grasscutter.data.GameData;
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.Int2ObjectMaps;
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.Collections;
import java.util.Iterator;
@ -40,8 +37,10 @@ import java.util.concurrent.ExecutorService;
import java.util.concurrent.LinkedBlockingDeque;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
import static emu.grasscutter.server.event.player.PlayerTeleportEvent.TeleportType.SCRIPT;
import javax.annotation.Nullable;
import lombok.Getter;
import lombok.val;
import org.jetbrains.annotations.NotNull;
public class World implements Iterable<Player> {
@Getter private final GameServer server;
@ -140,8 +139,7 @@ public class World implements Iterable<Player> {
* @param sceneId The scene ID.
* @return The scene.
*/
@Nullable
public Scene getSceneById(int sceneId) {
@Nullable public Scene getSceneById(int sceneId) {
// Get scene normally
var scene = this.getScenes().get(sceneId);
if (scene != null) {

View File

@ -34,8 +34,7 @@ public class HandlerHomeSceneJumpReq extends PacketHandler {
pos = home.getSceneMap().get(realmId).getBornPos();
}
world.transferPlayerToScene(
session.getPlayer(), scene.getId(), pos);
world.transferPlayerToScene(session.getPlayer(), scene.getId(), pos);
session.send(new PacketHomeSceneJumpRsp(req.getIsEnterRoomScene()));
}

View File

@ -10,10 +10,8 @@ public class PacketHomeChangeModuleRsp extends BasePacket {
public PacketHomeChangeModuleRsp(int targetModuleId) {
super(PacketOpcodes.HomeChangeModuleRsp);
var proto = HomeChangeModuleRsp.newBuilder()
.setRetcode(0)
.setTargetModuleId(targetModuleId)
.build();
var proto =
HomeChangeModuleRsp.newBuilder().setRetcode(0).setTargetModuleId(targetModuleId).build();
this.setData(proto);
}
@ -21,7 +19,6 @@ public class PacketHomeChangeModuleRsp extends BasePacket {
public PacketHomeChangeModuleRsp(Retcode retcode) {
super(PacketOpcodes.HomeChangeModuleRsp);
this.setData(HomeChangeModuleRsp.newBuilder()
.setRetcode(retcode.getNumber()));
this.setData(HomeChangeModuleRsp.newBuilder().setRetcode(retcode.getNumber()));
}
}

View File

@ -8,7 +8,6 @@ import emu.grasscutter.net.packet.BasePacket;
import emu.grasscutter.net.packet.PacketOpcodes;
import emu.grasscutter.net.proto.HomeMarkPointNotifyOuterClass.HomeMarkPointNotify;
import emu.grasscutter.net.proto.HomeMarkPointSceneDataOuterClass.HomeMarkPointSceneData;
import java.util.Collection;
import java.util.Set;
@ -30,7 +29,9 @@ public class PacketHomeMarkPointNotify extends BasePacket {
var moduleId = owner.getCurrentRealmId();
var scene = world.getSceneById(moduleId + 2000);
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;
}
var homeScene = home.getHomeSceneItem(moduleId + 2000);