mirror of
https://github.com/Melledy/Grasscutter.git
synced 2024-11-22 07:37:43 +00:00
Format code [skip actions]
This commit is contained in:
parent
cf8092e8ba
commit
b8f7aea168
@ -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,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));
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -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;
|
||||
|
@ -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);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user