Skip to content

Commit

Permalink
Format code [skip actions]
Browse files Browse the repository at this point in the history
  • Loading branch information
github-actions[bot] committed Sep 2, 2023
1 parent a49f37e commit 9c25060
Show file tree
Hide file tree
Showing 10 changed files with 49 additions and 41 deletions.
3 changes: 1 addition & 2 deletions src/main/java/emu/grasscutter/data/GameData.java
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@
import emu.grasscutter.game.world.GroupReplacementData;
import emu.grasscutter.utils.Utils;
import it.unimi.dsi.fastutil.ints.*;

import java.lang.reflect.Field;
import java.util.*;
import javax.annotation.Nullable;
Expand Down Expand Up @@ -281,7 +280,7 @@ public final class GameData {

@Getter
private static final Int2ObjectMap<HomeWorldAnimalData> homeWorldAnimalDataMap =
new Int2ObjectOpenHashMap<>();
new Int2ObjectOpenHashMap<>();

@Getter
private static final Int2ObjectMap<HomeWorldBgmData> homeWorldBgmDataMap =
Expand Down
17 changes: 8 additions & 9 deletions src/main/java/emu/grasscutter/game/entity/EntityHomeAnimal.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,8 @@
public class EntityHomeAnimal extends EntityMonster implements Rebornable {
private int rebornCDTickCount;
private final Position rebornPos;
@Getter
private final int rebirth;
@Getter
private final int rebirthCD;
@Getter private final int rebirth;
@Getter private final int rebirthCD;
private boolean disappeared;

public EntityHomeAnimal(Scene scene, HomeWorldAnimalData data, Position pos) {
Expand All @@ -28,8 +26,7 @@ public EntityHomeAnimal(Scene scene, HomeWorldAnimalData data, Position pos) {
}

@Override
public void damage(float amount, int killerId, ElementType attackType) {
}
public void damage(float amount, int killerId, ElementType attackType) {}

@Override
public void onTick(int sceneTime) {
Expand All @@ -44,8 +41,7 @@ public void onTick(int sceneTime) {
}

@Override
public void onCreate() {
}
public void onCreate() {}

@Override
public Position getRebornPos() {
Expand All @@ -59,7 +55,10 @@ public int getRebornCD() {

@Override
public void onAiKillSelf() {
this.getScene().broadcastPacket(new PacketSceneEntityDisappearNotify(this, VisionTypeOuterClass.VisionType.VISION_TYPE_REMOVE));
this.getScene()
.broadcastPacket(
new PacketSceneEntityDisappearNotify(
this, VisionTypeOuterClass.VisionType.VISION_TYPE_REMOVE));
this.rebornCDTickCount = this.getRebornCD();
this.disappeared = true;
}
Expand Down
19 changes: 8 additions & 11 deletions src/main/java/emu/grasscutter/game/home/HomeScene.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,31 +31,28 @@ public HomeSceneItem getSceneItem() {
}

@Override
public void setPaused(boolean paused) {
}
public void setPaused(boolean paused) {}

@Override
public void onTick() {
this.getEntities().values().forEach(gameEntity -> gameEntity.onTick(this.getSceneTimeSeconds()));
this.getEntities()
.values()
.forEach(gameEntity -> gameEntity.onTick(this.getSceneTimeSeconds()));

this.finishLoading();
this.checkPlayerRespawn();
if (this.tickCount++ % 10 == 0) this.broadcastPacket(new PacketSceneTimeNotify(this));
}

@Override
public void checkNpcGroup() {
}
public void checkNpcGroup() {}

@Override
public void checkSpawns() {
}
public void checkSpawns() {}

@Override
public void addItemEntity(int itemId, int amount, GameEntity bornForm) {
}
public void addItemEntity(int itemId, int amount, GameEntity bornForm) {}

@Override
public void loadNpcForPlayerEnter(Player player) {
}
public void loadNpcForPlayerEnter(Player player) {}
}
23 changes: 13 additions & 10 deletions src/main/java/emu/grasscutter/game/home/HomeSceneItem.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
import emu.grasscutter.game.world.Position;
import emu.grasscutter.game.world.Scene;
import emu.grasscutter.net.proto.HomeSceneArrangementInfoOuterClass.HomeSceneArrangementInfo;

import java.util.Collection;
import java.util.List;
import java.util.Map;
Expand Down Expand Up @@ -80,15 +79,19 @@ public boolean isRoom() {

public List<EntityHomeAnimal> getAnimals(Scene scene) {
return this.blockItems.values().stream()
.map(HomeBlockItem::getDeployAnimalList)
.flatMap(Collection::stream)
.filter(homeAnimalItem -> GameData.getHomeWorldAnimalDataMap().containsKey(homeAnimalItem.getFurnitureId()))
.map(homeAnimalItem -> {
return new EntityHomeAnimal(scene,
GameData.getHomeWorldAnimalDataMap().get(homeAnimalItem.getFurnitureId()),
homeAnimalItem.getSpawnPos());
})
.toList();
.map(HomeBlockItem::getDeployAnimalList)
.flatMap(Collection::stream)
.filter(
homeAnimalItem ->
GameData.getHomeWorldAnimalDataMap().containsKey(homeAnimalItem.getFurnitureId()))
.map(
homeAnimalItem -> {
return new EntityHomeAnimal(
scene,
GameData.getHomeWorldAnimalDataMap().get(homeAnimalItem.getFurnitureId()),
homeAnimalItem.getSpawnPos());
})
.toList();
}

public int calComfort() {
Expand Down
1 change: 0 additions & 1 deletion src/main/java/emu/grasscutter/game/home/HomeWorld.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import emu.grasscutter.net.packet.BasePacket;
import emu.grasscutter.net.proto.ChatInfoOuterClass;
import emu.grasscutter.server.game.GameServer;

import emu.grasscutter.server.packet.send.*;
import java.util.List;
import lombok.Getter;
Expand Down
9 changes: 5 additions & 4 deletions src/main/java/emu/grasscutter/game/world/Scene.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@
import emu.grasscutter.server.scheduler.ServerTaskScheduler;
import emu.grasscutter.utils.objects.KahnsSort;
import it.unimi.dsi.fastutil.ints.Int2ObjectMap;

import java.util.*;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.CopyOnWriteArrayList;
Expand Down Expand Up @@ -465,9 +464,11 @@ public void showOtherEntities(Player player) {
GameEntity currentEntity = player.getTeamManager().getCurrentAvatarEntity();
List<GameEntity> entities =
this.getEntities().values().stream()
.filter(entity -> entity != currentEntity)
.filter(gameEntity -> !(gameEntity instanceof Rebornable rebornable) || !rebornable.isInCD())
.toList();
.filter(entity -> entity != currentEntity)
.filter(
gameEntity ->
!(gameEntity instanceof Rebornable rebornable) || !rebornable.isInCD())
.toList();

player.sendPacket(new PacketSceneEntityAppearNotify(entities, VisionType.VISION_TYPE_MEET));
}
Expand Down
1 change: 0 additions & 1 deletion src/main/java/emu/grasscutter/server/game/GameServer.java
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@
import emu.grasscutter.server.scheduler.ServerTaskScheduler;
import emu.grasscutter.task.TaskMap;
import emu.grasscutter.utils.Utils;

import it.unimi.dsi.fastutil.ints.*;
import java.net.*;
import java.time.*;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
public class HandlerEntityAiKillSelfNotify extends PacketHandler {
@Override
public void handle(GameSession session, byte[] header, byte[] payload) throws Exception {
var entityId = EntityAiKillSelfNotifyOuterClass.EntityAiKillSelfNotify.parseFrom(payload).getEntityId();
var entityId =
EntityAiKillSelfNotifyOuterClass.EntityAiKillSelfNotify.parseFrom(payload).getEntityId();
if (session.getPlayer().getScene().getEntityById(entityId) instanceof Rebornable rebornable) {
rebornable.onAiKillSelf();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,13 @@ public void handle(GameSession session, byte[] header, byte[] payload) throws Ex

if (!req.getIsEnterEditMode()) {
var scene = session.getPlayer().getScene();
scene.addEntities(session.getPlayer().getCurHomeWorld().getHome().getHomeSceneItem(scene.getId()).getAnimals(scene));
scene.addEntities(
session
.getPlayer()
.getCurHomeWorld()
.getHome()
.getHomeSceneItem(scene.getId())
.getAnimals(scene));
}

session.send(new PacketHomeChangeEditModeRsp(req.getIsEnterEditMode()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,11 @@ public void handle(GameSession session, byte[] header, byte[] payload) throws Ex
*/

var scene = session.getPlayer().getScene();
scene.removeEntities(scene.getEntities().values().stream().filter(gameEntity -> gameEntity instanceof EntityHomeAnimal).toList(), VisionTypeOuterClass.VisionType.VISION_TYPE_REMOVE);
scene.removeEntities(
scene.getEntities().values().stream()
.filter(gameEntity -> gameEntity instanceof EntityHomeAnimal)
.toList(),
VisionTypeOuterClass.VisionType.VISION_TYPE_REMOVE);

session.send(new PacketHomeEnterEditModeFinishRsp());
}
Expand Down

0 comments on commit 9c25060

Please sign in to comment.