From b8f7aea1680f1176fc1a55f6e0b6662d78189253 Mon Sep 17 00:00:00 2001 From: github-actions <41898282+github-actions[bot]@users.noreply.github.com> Date: Sat, 16 Sep 2023 21:33:36 +0000 Subject: [PATCH] Format code [skip actions] --- .../command/commands/SetSceneTagCommand.java | 41 +++++++----- .../game/player/PlayerProgressManager.java | 1 - .../PacketPlayerWorldSceneInfoListNotify.java | 63 +++++++++---------- 3 files changed, 53 insertions(+), 52 deletions(-) diff --git a/src/main/java/emu/grasscutter/command/commands/SetSceneTagCommand.java b/src/main/java/emu/grasscutter/command/commands/SetSceneTagCommand.java index fcef0d165..3406cce66 100644 --- a/src/main/java/emu/grasscutter/command/commands/SetSceneTagCommand.java +++ b/src/main/java/emu/grasscutter/command/commands/SetSceneTagCommand.java @@ -6,12 +6,15 @@ import emu.grasscutter.data.excels.scene.SceneTagData; import emu.grasscutter.game.player.Player; import emu.grasscutter.server.packet.send.*; import it.unimi.dsi.fastutil.ints.Int2ObjectMap; +import java.util.*; import lombok.val; -import java.util.*; - -@Command(label = "setSceneTag", aliases = { "tag" }, usage = { - " " }, permission = "player.setscenetag", permissionTargeted = "player.setscenetag.others") +@Command( + label = "setSceneTag", + aliases = {"tag"}, + usage = {" "}, + permission = "player.setscenetag", + permissionTargeted = "player.setscenetag.others") public final class SetSceneTagCommand implements CommandHandler { private final Int2ObjectMap sceneTagData = GameData.getSceneTagDataMap(); @@ -44,7 +47,8 @@ public final class SetSceneTagCommand implements CommandHandler { val userVal = value; - var sceneData = sceneTagData.values().stream().filter(sceneTag -> sceneTag.getId() == userVal).findFirst(); + var sceneData = + sceneTagData.values().stream().filter(sceneTag -> sceneTag.getId() == userVal).findFirst(); if (sceneData == null) { CommandHandler.sendTranslatedMessage(sender, "commands.generic.invalid.id"); return; @@ -58,7 +62,6 @@ public final class SetSceneTagCommand implements CommandHandler { } CommandHandler.sendTranslatedMessage(sender, "commands.generic.set_to", value, actionStr); - } private void addSceneTag(Player targetPlayer, int scene, int value) { @@ -73,20 +76,25 @@ public final class SetSceneTagCommand implements CommandHandler { var allData = sceneTagData.values(); // Add all SceneTags - allData.stream().toList().forEach(sceneTag -> { - if (targetPlayer.getSceneTags().get(sceneTag.getSceneId()) == null) { - targetPlayer.getSceneTags().put(sceneTag.getSceneId(), new HashSet<>()); - } - targetPlayer.getSceneTags().get(sceneTag.getSceneId()).add(sceneTag.getId()); - }); + allData.stream() + .toList() + .forEach( + sceneTag -> { + if (targetPlayer.getSceneTags().get(sceneTag.getSceneId()) == null) { + targetPlayer.getSceneTags().put(sceneTag.getSceneId(), new HashSet<>()); + } + targetPlayer.getSceneTags().get(sceneTag.getSceneId()).add(sceneTag.getId()); + }); // Remove default SceneTags, as most are "before" or "locked" states - allData.stream().filter(sceneTag -> sceneTag.isDefaultValid()) + allData.stream() + .filter(sceneTag -> sceneTag.isDefaultValid()) // Only remove for big world as some other scenes only have defaults .filter(sceneTag -> sceneTag.getSceneId() == 3) - .forEach(sceneTag -> { - targetPlayer.getSceneTags().get(sceneTag.getSceneId()).remove(sceneTag.getId()); - }); + .forEach( + sceneTag -> { + targetPlayer.getSceneTags().get(sceneTag.getSceneId()).remove(sceneTag.getId()); + }); this.setSceneTags(targetPlayer); } @@ -94,5 +102,4 @@ public final class SetSceneTagCommand implements CommandHandler { private void setSceneTags(Player targetPlayer) { targetPlayer.sendPacket(new PacketPlayerWorldSceneInfoListNotify(targetPlayer)); } - } diff --git a/src/main/java/emu/grasscutter/game/player/PlayerProgressManager.java b/src/main/java/emu/grasscutter/game/player/PlayerProgressManager.java index c284ad76b..50acd0d9c 100644 --- a/src/main/java/emu/grasscutter/game/player/PlayerProgressManager.java +++ b/src/main/java/emu/grasscutter/game/player/PlayerProgressManager.java @@ -12,7 +12,6 @@ import emu.grasscutter.game.quest.enums.*; import emu.grasscutter.net.proto.RetcodeOuterClass.Retcode; import emu.grasscutter.scripts.data.ScriptArgs; import emu.grasscutter.server.packet.send.*; - import java.util.HashSet; import java.util.Set; import java.util.stream.Collectors; diff --git a/src/main/java/emu/grasscutter/server/packet/send/PacketPlayerWorldSceneInfoListNotify.java b/src/main/java/emu/grasscutter/server/packet/send/PacketPlayerWorldSceneInfoListNotify.java index dcf5ca43d..600bd1e2f 100644 --- a/src/main/java/emu/grasscutter/server/packet/send/PacketPlayerWorldSceneInfoListNotify.java +++ b/src/main/java/emu/grasscutter/server/packet/send/PacketPlayerWorldSceneInfoListNotify.java @@ -6,7 +6,6 @@ import emu.grasscutter.net.packet.*; import emu.grasscutter.net.proto.MapLayerInfoOuterClass; import emu.grasscutter.net.proto.PlayerWorldSceneInfoListNotifyOuterClass.PlayerWorldSceneInfoListNotify; import emu.grasscutter.net.proto.PlayerWorldSceneInfoOuterClass.PlayerWorldSceneInfo; - import java.util.Map; public class PacketPlayerWorldSceneInfoListNotify extends BasePacket { @@ -18,44 +17,40 @@ public class PacketPlayerWorldSceneInfoListNotify extends BasePacket { PlayerWorldSceneInfoListNotify.Builder proto = PlayerWorldSceneInfoListNotify.newBuilder() - .addInfoList(PlayerWorldSceneInfo.newBuilder().setSceneId(1).setIsLocked(false).build()); + .addInfoList( + PlayerWorldSceneInfo.newBuilder().setSceneId(1).setIsLocked(false).build()); - // Iterate over all scenes - for (int scene : GameData.getSceneDataMap().keySet()) { - var worldInfoBuilder = PlayerWorldSceneInfo.newBuilder() - .setSceneId(scene) - .setIsLocked(false); + // Iterate over all scenes + for (int scene : GameData.getSceneDataMap().keySet()) { + var worldInfoBuilder = PlayerWorldSceneInfo.newBuilder().setSceneId(scene).setIsLocked(false); - /** Add scene-specific data */ + /** Add scene-specific data */ - // Scenetags - if (sceneTags.keySet().contains(scene)) { - worldInfoBuilder - .addAllSceneTagIdList( - sceneTags.entrySet().stream() - .filter(e -> e.getKey().equals(scene)) - .map(Map.Entry::getValue) - .toList() - .get(0) - ); - } + // Scenetags + if (sceneTags.keySet().contains(scene)) { + worldInfoBuilder.addAllSceneTagIdList( + sceneTags.entrySet().stream() + .filter(e -> e.getKey().equals(scene)) + .map(Map.Entry::getValue) + .toList() + .get(0)); + } - // Map layer information (Big world) - if (scene == 3) { - worldInfoBuilder.setMapLayerInfo( - MapLayerInfoOuterClass.MapLayerInfo.newBuilder() - .addAllUnlockedMapLayerIdList( - GameData.getMapLayerDataMap().keySet()) // MapLayer Ids - .addAllUnlockedMapLayerFloorIdList( - GameData.getMapLayerFloorDataMap().keySet()) - .addAllUnlockedMapLayerGroupIdList( - GameData.getMapLayerGroupDataMap() - .keySet()) // will show MapLayer options when hovered over - .build()); // map layer test - } + // Map layer information (Big world) + if (scene == 3) { + worldInfoBuilder.setMapLayerInfo( + MapLayerInfoOuterClass.MapLayerInfo.newBuilder() + .addAllUnlockedMapLayerIdList( + GameData.getMapLayerDataMap().keySet()) // MapLayer Ids + .addAllUnlockedMapLayerFloorIdList(GameData.getMapLayerFloorDataMap().keySet()) + .addAllUnlockedMapLayerGroupIdList( + GameData.getMapLayerGroupDataMap() + .keySet()) // will show MapLayer options when hovered over + .build()); // map layer test + } - proto.addInfoList(worldInfoBuilder.build()); - } + proto.addInfoList(worldInfoBuilder.build()); + } this.setData(proto); }