From 2c7c8bf4fd94daf800ef42addf26014e86fc5e3b Mon Sep 17 00:00:00 2001 From: KingRainbow44 Date: Thu, 1 Jun 2023 14:23:12 -0400 Subject: [PATCH] Add option for enabling costumes on trial avatars --- .../grasscutter/config/ConfigContainer.java | 26 +++++++++++-------- .../emu/grasscutter/game/avatar/Avatar.java | 23 +++++++++------- 2 files changed, 28 insertions(+), 21 deletions(-) diff --git a/src/main/java/emu/grasscutter/config/ConfigContainer.java b/src/main/java/emu/grasscutter/config/ConfigContainer.java index 4b5928015..7694e6d9a 100644 --- a/src/main/java/emu/grasscutter/config/ConfigContainer.java +++ b/src/main/java/emu/grasscutter/config/ConfigContainer.java @@ -17,19 +17,21 @@ import static emu.grasscutter.Grasscutter.*; public class ConfigContainer { /* * Configuration changes: - * Version 5 - 'questing' has been changed from a boolean - * to a container of options ('questOptions'). - * This field will be removed in future versions. - * Version 6 - 'questing' has been fully replaced with 'questOptions'. - * The field for 'legacyResources' has been removed. - * Version 7 - 'regionKey' is being added for authentication - * with the new dispatch server. - * Version 8 - 'server' is being added for enforcing handbook server - * addresses. - * Version 9 - 'limits' was added for handbook requests. + * Version 5 - 'questing' has been changed from a boolean + * to a container of options ('questOptions'). + * This field will be removed in future versions. + * Version 6 - 'questing' has been fully replaced with 'questOptions'. + * The field for 'legacyResources' has been removed. + * Version 7 - 'regionKey' is being added for authentication + * with the new dispatch server. + * Version 8 - 'server' is being added for enforcing handbook server + * addresses. + * Version 9 - 'limits' was added for handbook requests. + * Version 10 - 'trialCostumes' was added for enabling costumes + * on trial avatars. */ private static int version() { - return 9; + return 10; } /** @@ -255,6 +257,8 @@ public class ConfigContainer { public boolean staminaUsage = true; public boolean energyUsage = true; public boolean fishhookTeleport = true; + public boolean trialCostumes = false; + @SerializedName(value = "questing", alternate = "questOptions") public Questing questing = new Questing(); public ResinOptions resinOptions = new ResinOptions(); diff --git a/src/main/java/emu/grasscutter/game/avatar/Avatar.java b/src/main/java/emu/grasscutter/game/avatar/Avatar.java index b87f32272..2838a7697 100644 --- a/src/main/java/emu/grasscutter/game/avatar/Avatar.java +++ b/src/main/java/emu/grasscutter/game/avatar/Avatar.java @@ -1,7 +1,5 @@ package emu.grasscutter.game.avatar; -import static emu.grasscutter.config.Configuration.GAME_OPTIONS; - import dev.morphia.annotations.*; import emu.grasscutter.GameConstants; import emu.grasscutter.data.GameData; @@ -32,12 +30,15 @@ import emu.grasscutter.net.proto.TrialAvatarInfoOuterClass.TrialAvatarInfo; import emu.grasscutter.server.packet.send.*; import emu.grasscutter.utils.helpers.ProtoHelper; import it.unimi.dsi.fastutil.ints.*; -import java.util.*; -import java.util.stream.Stream; -import javax.annotation.*; import lombok.*; import org.bson.types.ObjectId; +import javax.annotation.*; +import java.util.*; +import java.util.stream.Stream; + +import static emu.grasscutter.config.Configuration.GAME_OPTIONS; + @Entity(value = "avatars", useDiscriminator = false) public class Avatar { @Transient @Getter private final Int2ObjectMap equips; @@ -1243,13 +1244,15 @@ public class Avatar { }); // Add costume if avatar has a costume. - GameData.getAvatarCostumeDataItemIdMap() + if (GAME_OPTIONS.trialCostumes) { + GameData.getAvatarCostumeDataItemIdMap() .values() .forEach( - costumeData -> { - if (costumeData.getCharacterId() != this.getAvatarId()) return; - this.setCostume(costumeData.getId()); - }); + costumeData -> { + if (costumeData.getCharacterId() != this.getAvatarId()) return; + this.setCostume(costumeData.getId()); + }); + } } /** Equips the items applied from {@link Avatar#applyTrialItems()}. */