Format code [skip actions]

This commit is contained in:
github-actions 2023-09-16 21:33:36 +00:00
parent cf8092e8ba
commit b8f7aea168
3 changed files with 53 additions and 52 deletions

View File

@ -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 = {
"<add|remove|unlockall> <sceneTagId>" }, permission = "player.setscenetag", permissionTargeted = "player.setscenetag.others")
@Command(
label = "setSceneTag",
aliases = {"tag"},
usage = {"<add|remove|unlockall> <sceneTagId>"},
permission = "player.setscenetag",
permissionTargeted = "player.setscenetag.others")
public final class SetSceneTagCommand implements CommandHandler {
private final Int2ObjectMap<SceneTagData> 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,7 +76,10 @@ public final class SetSceneTagCommand implements CommandHandler {
var allData = sceneTagData.values();
// Add all SceneTags
allData.stream().toList().forEach(sceneTag -> {
allData.stream()
.toList()
.forEach(
sceneTag -> {
if (targetPlayer.getSceneTags().get(sceneTag.getSceneId()) == null) {
targetPlayer.getSceneTags().put(sceneTag.getSceneId(), new HashSet<>());
}
@ -81,10 +87,12 @@ public final class SetSceneTagCommand implements CommandHandler {
});
// 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 -> {
.forEach(
sceneTag -> {
targetPlayer.getSceneTags().get(sceneTag.getSceneId()).remove(sceneTag.getId());
});
@ -94,5 +102,4 @@ public final class SetSceneTagCommand implements CommandHandler {
private void setSceneTags(Player targetPlayer) {
targetPlayer.sendPacket(new PacketPlayerWorldSceneInfoListNotify(targetPlayer));
}
}

View File

@ -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;

View File

@ -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,26 +17,23 @@ 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);
var worldInfoBuilder = PlayerWorldSceneInfo.newBuilder().setSceneId(scene).setIsLocked(false);
/** Add scene-specific data */
// Scenetags
if (sceneTags.keySet().contains(scene)) {
worldInfoBuilder
.addAllSceneTagIdList(
worldInfoBuilder.addAllSceneTagIdList(
sceneTags.entrySet().stream()
.filter(e -> e.getKey().equals(scene))
.map(Map.Entry::getValue)
.toList()
.get(0)
);
.get(0));
}
// Map layer information (Big world)
@ -46,8 +42,7 @@ public class PacketPlayerWorldSceneInfoListNotify extends BasePacket {
MapLayerInfoOuterClass.MapLayerInfo.newBuilder()
.addAllUnlockedMapLayerIdList(
GameData.getMapLayerDataMap().keySet()) // MapLayer Ids
.addAllUnlockedMapLayerFloorIdList(
GameData.getMapLayerFloorDataMap().keySet())
.addAllUnlockedMapLayerFloorIdList(GameData.getMapLayerFloorDataMap().keySet())
.addAllUnlockedMapLayerGroupIdList(
GameData.getMapLayerGroupDataMap()
.keySet()) // will show MapLayer options when hovered over