From ac388af880c9e08c2070d93f03d390c77873799a Mon Sep 17 00:00:00 2001 From: FlorianMichael Date: Tue, 24 Dec 2024 12:05:57 +0100 Subject: [PATCH] Finish code base rewrite --- api/build.gradle | 4 + .../viafabricplus/api/ViaFabricPlusBase.java | 26 ++++++ .../ChangeProtocolVersionCallback.java | 2 +- .../{ => events}/LoadingCycleCallback.java | 2 +- .../api/settings}/AbstractSetting.java | 37 ++++----- .../api/settings}/SettingGroup.java | 30 +++++-- .../api/settings/type}/BooleanSetting.java | 16 ++-- .../api/settings/type}/ButtonSetting.java | 32 ++++---- .../api/settings/type}/ModeSetting.java | 33 +++----- .../type}/VersionedBooleanSetting.java | 20 ++--- .../viafabricplus/ViaFabricPlusImpl.java | 39 ++++++--- .../viaversion/viafabricplus/base/Events.java | 4 +- .../modmenu}/ModMenuScreenFactory.java | 4 +- .../ClassLoaderPriorityUtil.java | 3 +- .../sync_tasks}/DataCustomPayload.java | 3 +- .../base/{ => sync_tasks}/SyncTasks.java | 10 ++- .../features/FeaturesLoading.java | 4 +- .../GridItemSelectionScreen.java | 2 +- .../injection/mixin/base/MixinMain.java | 2 +- .../mixin/base/integration/MixinDebugHud.java | 2 +- .../integration/MixinMinecraftClient.java | 2 +- .../bedrock/MixinConnectScreen_1.java | 3 +- .../MixinClientCommonNetworkHandler.java | 4 +- .../mixin/base/ui/MixinAddServerScreen.java | 2 +- .../mixin/base/ui/MixinConnectScreen_1.java | 3 +- .../base/ui/MixinDirectConnectScreen.java | 2 +- .../mixin/base/ui/MixinMultiplayerScreen.java | 2 +- .../MixinWorldPacketRewriter1_19.java | 2 +- .../MixinBlockItemPacketRewriter1_20_5.java | 2 +- .../MixinItemPacketRewriter1_14.java | 2 +- .../viabedrock/MixinJoinPackets.java | 2 +- .../viaversion/ViaFabricPlusVLLoader.java | 2 +- .../protocol/ViaFabricPlusProtocol.java | 2 +- .../storage}/BedrockJoinGameTracker.java | 2 +- .../viafabricplus/save/SaveManager.java | 12 +-- .../viafabricplus/save/impl/SettingsSave.java | 17 ++-- .../{base => }/screen/VFPList.java | 6 +- .../{base => }/screen/VFPListEntry.java | 37 ++++++--- .../{base => }/screen/VFPScreen.java | 2 +- .../{ => impl}/PerServerVersionScreen.java | 8 +- .../{ => impl}/ProtocolSelectionScreen.java | 10 +-- .../screen/{ => impl}/ReportIssuesScreen.java | 4 +- .../screen/{ => impl}/ServerListScreen.java | 18 ++--- .../{ => impl}/classic4j/BetaCraftScreen.java | 10 +-- .../classic4j/ClassiCubeLoginScreen.java | 9 ++- .../classic4j/ClassiCubeMFAScreen.java | 11 +-- .../classic4j/ClassiCubeServerListScreen.java | 17 ++-- .../realms/AcceptInvitationCodeScreen.java | 4 +- .../realms/BedrockRealmsScreen.java | 11 +-- .../settings/BooleanSettingRenderer.java | 13 +-- .../settings/ButtonSettingRenderer.java | 18 +++-- .../settings/ModeSettingRenderer.java | 19 +++-- .../{ => impl}/settings/SettingsScreen.java | 27 +++++-- .../{ => impl}/settings/TitleRenderer.java | 4 +- .../VersionedBooleanSettingRenderer.java | 13 +-- .../settings/SettingsManager.java | 8 +- .../settings/impl/AuthenticationSettings.java | 14 ++-- .../settings/impl/BedrockSettings.java | 27 ++++--- .../settings/impl/DebugSettings.java | 33 ++++---- .../settings/impl/GeneralSettings.java | 58 +++++++------- .../settings/impl/VisualSettings.java | 80 +++++++++---------- src/main/resources/fabric.mod.json | 2 +- 62 files changed, 443 insertions(+), 356 deletions(-) rename api/src/main/java/com/viaversion/viafabricplus/api/{ => events}/ChangeProtocolVersionCallback.java (96%) rename api/src/main/java/com/viaversion/viafabricplus/api/{ => events}/LoadingCycleCallback.java (97%) rename {src/main/java/com/viaversion/viafabricplus/settings/base => api/src/main/java/com/viaversion/viafabricplus/api/settings}/AbstractSetting.java (72%) rename {src/main/java/com/viaversion/viafabricplus/settings/base => api/src/main/java/com/viaversion/viafabricplus/api/settings}/SettingGroup.java (70%) rename {src/main/java/com/viaversion/viafabricplus/settings/base => api/src/main/java/com/viaversion/viafabricplus/api/settings/type}/BooleanSetting.java (73%) rename {src/main/java/com/viaversion/viafabricplus/settings/base => api/src/main/java/com/viaversion/viafabricplus/api/settings/type}/ButtonSetting.java (61%) rename {src/main/java/com/viaversion/viafabricplus/settings/base => api/src/main/java/com/viaversion/viafabricplus/api/settings/type}/ModeSetting.java (61%) rename {src/main/java/com/viaversion/viafabricplus/settings/base => api/src/main/java/com/viaversion/viafabricplus/api/settings/type}/VersionedBooleanSetting.java (78%) rename src/main/java/com/viaversion/viafabricplus/{util => base/modmenu}/ModMenuScreenFactory.java (92%) rename src/main/java/com/viaversion/viafabricplus/{util => base/overriding_jars}/ClassLoaderPriorityUtil.java (97%) rename src/main/java/com/viaversion/viafabricplus/{util => base/sync_tasks}/DataCustomPayload.java (95%) rename src/main/java/com/viaversion/viafabricplus/base/{ => sync_tasks}/SyncTasks.java (93%) rename src/main/java/com/viaversion/viafabricplus/{base/bedrock => protocoltranslator/protocol/storage}/BedrockJoinGameTracker.java (95%) rename src/main/java/com/viaversion/viafabricplus/{base => }/screen/VFPList.java (93%) rename src/main/java/com/viaversion/viafabricplus/{base => }/screen/VFPListEntry.java (82%) rename src/main/java/com/viaversion/viafabricplus/{base => }/screen/VFPScreen.java (99%) rename src/main/java/com/viaversion/viafabricplus/screen/{ => impl}/PerServerVersionScreen.java (95%) rename src/main/java/com/viaversion/viafabricplus/screen/{ => impl}/ProtocolSelectionScreen.java (94%) rename src/main/java/com/viaversion/viafabricplus/screen/{ => impl}/ReportIssuesScreen.java (97%) rename src/main/java/com/viaversion/viafabricplus/screen/{ => impl}/ServerListScreen.java (80%) rename src/main/java/com/viaversion/viafabricplus/screen/{ => impl}/classic4j/BetaCraftScreen.java (94%) rename src/main/java/com/viaversion/viafabricplus/screen/{ => impl}/classic4j/ClassiCubeLoginScreen.java (93%) rename src/main/java/com/viaversion/viafabricplus/screen/{ => impl}/classic4j/ClassiCubeMFAScreen.java (89%) rename src/main/java/com/viaversion/viafabricplus/screen/{ => impl}/classic4j/ClassiCubeServerListScreen.java (89%) rename src/main/java/com/viaversion/viafabricplus/screen/{ => impl}/realms/AcceptInvitationCodeScreen.java (95%) rename src/main/java/com/viaversion/viafabricplus/screen/{ => impl}/realms/BedrockRealmsScreen.java (96%) rename src/main/java/com/viaversion/viafabricplus/screen/{ => impl}/settings/BooleanSettingRenderer.java (84%) rename src/main/java/com/viaversion/viafabricplus/screen/{ => impl}/settings/ButtonSettingRenderer.java (74%) rename src/main/java/com/viaversion/viafabricplus/screen/{ => impl}/settings/ModeSettingRenderer.java (75%) rename src/main/java/com/viaversion/viafabricplus/screen/{ => impl}/settings/SettingsScreen.java (60%) rename src/main/java/com/viaversion/viafabricplus/screen/{ => impl}/settings/TitleRenderer.java (95%) rename src/main/java/com/viaversion/viafabricplus/screen/{ => impl}/settings/VersionedBooleanSettingRenderer.java (82%) diff --git a/api/build.gradle b/api/build.gradle index 7c601c6c9..2d54ab527 100644 --- a/api/build.gradle +++ b/api/build.gradle @@ -4,4 +4,8 @@ plugins { dependencies { compileOnly "com.viaversion:viaversion-common:5.2.1-SNAPSHOT" + compileOnly ("net.raphimc:ViaLoader:3.0.4") { + exclude group: "com.google.guava", module: "guava" + exclude group: "org.slf4j", module: "slf4j-api" + } } \ No newline at end of file diff --git a/api/src/main/java/com/viaversion/viafabricplus/api/ViaFabricPlusBase.java b/api/src/main/java/com/viaversion/viafabricplus/api/ViaFabricPlusBase.java index d869bdef7..f33be7672 100644 --- a/api/src/main/java/com/viaversion/viafabricplus/api/ViaFabricPlusBase.java +++ b/api/src/main/java/com/viaversion/viafabricplus/api/ViaFabricPlusBase.java @@ -22,12 +22,16 @@ package com.viaversion.viafabricplus.api; import com.viaversion.viafabricplus.ViaFabricPlus; +import com.viaversion.viafabricplus.api.events.ChangeProtocolVersionCallback; +import com.viaversion.viafabricplus.api.events.LoadingCycleCallback; +import com.viaversion.viafabricplus.api.settings.SettingGroup; import com.viaversion.viaversion.api.connection.UserConnection; import com.viaversion.viaversion.api.protocol.version.ProtocolVersion; import io.netty.channel.Channel; import org.apache.logging.log4j.Logger; import java.nio.file.Path; +import java.util.List; /** * General API point for mods. Get instance via {@link ViaFabricPlus#getImpl()}. @@ -118,4 +122,26 @@ default int apiVersion() { */ int getMaxChatLength(final ProtocolVersion version); + /** + * All setting groups of the mod. + * + * @return The setting groups + */ + List settingGroups(); + + /** + * Add a setting group to the mod. + * + * @param group The setting group + */ + void addSettingGroup(final SettingGroup group); + + /** + * Get a setting group by its translationKey. + * + * @param translationKey The translationKey of the setting group + * @return The setting group or null if it does not exist + */ + SettingGroup getSettingGroup(final String translationKey); + } diff --git a/api/src/main/java/com/viaversion/viafabricplus/api/ChangeProtocolVersionCallback.java b/api/src/main/java/com/viaversion/viafabricplus/api/events/ChangeProtocolVersionCallback.java similarity index 96% rename from api/src/main/java/com/viaversion/viafabricplus/api/ChangeProtocolVersionCallback.java rename to api/src/main/java/com/viaversion/viafabricplus/api/events/ChangeProtocolVersionCallback.java index 54e5d76f9..0fda9d83f 100644 --- a/api/src/main/java/com/viaversion/viafabricplus/api/ChangeProtocolVersionCallback.java +++ b/api/src/main/java/com/viaversion/viafabricplus/api/events/ChangeProtocolVersionCallback.java @@ -19,7 +19,7 @@ * along with this program. If not, see . */ -package com.viaversion.viafabricplus.api; +package com.viaversion.viafabricplus.api.events; import com.viaversion.viaversion.api.protocol.version.ProtocolVersion; diff --git a/api/src/main/java/com/viaversion/viafabricplus/api/LoadingCycleCallback.java b/api/src/main/java/com/viaversion/viafabricplus/api/events/LoadingCycleCallback.java similarity index 97% rename from api/src/main/java/com/viaversion/viafabricplus/api/LoadingCycleCallback.java rename to api/src/main/java/com/viaversion/viafabricplus/api/events/LoadingCycleCallback.java index 79a0b9075..024abb5cb 100644 --- a/api/src/main/java/com/viaversion/viafabricplus/api/LoadingCycleCallback.java +++ b/api/src/main/java/com/viaversion/viafabricplus/api/events/LoadingCycleCallback.java @@ -19,7 +19,7 @@ * along with this program. If not, see . */ -package com.viaversion.viafabricplus.api; +package com.viaversion.viafabricplus.api.events; /** * This event is fired in various loading stages of ViaFabricPlus. See {@link LoadingCycle} for more information. diff --git a/src/main/java/com/viaversion/viafabricplus/settings/base/AbstractSetting.java b/api/src/main/java/com/viaversion/viafabricplus/api/settings/AbstractSetting.java similarity index 72% rename from src/main/java/com/viaversion/viafabricplus/settings/base/AbstractSetting.java rename to api/src/main/java/com/viaversion/viafabricplus/api/settings/AbstractSetting.java index 168567373..b1ba87b7c 100644 --- a/src/main/java/com/viaversion/viafabricplus/settings/base/AbstractSetting.java +++ b/api/src/main/java/com/viaversion/viafabricplus/api/settings/AbstractSetting.java @@ -19,13 +19,9 @@ * along with this program. If not, see . */ -package com.viaversion.viafabricplus.settings.base; +package com.viaversion.viafabricplus.api.settings; import com.google.gson.JsonObject; -import com.viaversion.viafabricplus.base.screen.VFPListEntry; -import com.viaversion.viafabricplus.util.ChatUtil; -import net.minecraft.text.MutableText; -import net.minecraft.text.Text; import java.util.function.Supplier; @@ -37,15 +33,15 @@ */ public abstract class AbstractSetting { - private final MutableText name; + private final String translationKey; private final T defaultValue; private T value; - private Supplier tooltip; + private Supplier tooltip; - public AbstractSetting(final SettingGroup parent, final MutableText name, final T defaultValue) { - this.name = name; + public AbstractSetting(final SettingGroup parent, final String translationKey, final T defaultValue) { + this.translationKey = translationKey; this.defaultValue = defaultValue; this.value = defaultValue; @@ -53,27 +49,22 @@ public AbstractSetting(final SettingGroup parent, final MutableText name, final parent.getSettings().add(this); } - /** - * This method is used to create a renderer for the setting. - * @return The renderer, see {@link VFPListEntry} for more details. - */ - public abstract VFPListEntry makeSettingRenderer(); - public abstract void write(final JsonObject object); + public abstract void read(final JsonObject object); public void onValueChanged() { } - public MutableText getName() { - return name; + public String getTranslationKey() { + return translationKey; } /** - * @return The translation key of the name. + * @return a more readable name for the config. */ - public String getTranslationKey() { - return mapTranslationKey(ChatUtil.uncoverTranslationKey(name)); + public String getConfigName() { + return mapTranslationKey(getTranslationKey()); } /** @@ -99,7 +90,7 @@ public void setValue(T value) { onValueChanged(); } - public Text getTooltip() { + public String getTooltip() { if (tooltip == null) { return null; } else { @@ -107,11 +98,11 @@ public Text getTooltip() { } } - public void setTooltip(Text tooltip) { + public void setTooltip(String tooltip) { this.tooltip = () -> tooltip; } - public void setTooltip(Supplier tooltip) { + public void setTooltip(Supplier tooltip) { this.tooltip = tooltip; } diff --git a/src/main/java/com/viaversion/viafabricplus/settings/base/SettingGroup.java b/api/src/main/java/com/viaversion/viafabricplus/api/settings/SettingGroup.java similarity index 70% rename from src/main/java/com/viaversion/viafabricplus/settings/base/SettingGroup.java rename to api/src/main/java/com/viaversion/viafabricplus/api/settings/SettingGroup.java index 7999795d9..98ff4f336 100644 --- a/src/main/java/com/viaversion/viafabricplus/settings/base/SettingGroup.java +++ b/api/src/main/java/com/viaversion/viafabricplus/api/settings/SettingGroup.java @@ -19,24 +19,23 @@ * along with this program. If not, see . */ -package com.viaversion.viafabricplus.settings.base; - -import net.minecraft.text.Text; +package com.viaversion.viafabricplus.api.settings; import java.util.ArrayList; import java.util.List; /** * This class represents a group of settings. It is used to group settings in the settings screen. + * * @see AbstractSetting */ public class SettingGroup { private final List> settings = new ArrayList<>(); - private final Text name; + private final String translationKey; - public SettingGroup(Text name) { - this.name = name; + public SettingGroup(String translationKey) { + this.translationKey = translationKey; } /** @@ -49,8 +48,23 @@ public List> getSettings() { return settings; } - public Text getName() { - return name; + /** + * Returns a setting by its name. + * + * @param name The name of the setting. + * @return The setting or null if it does not exist. + */ + public AbstractSetting getSetting(final String name) { + for (AbstractSetting setting : settings) { + if (setting.getTranslationKey().equals(name)) { + return setting; + } + } + return null; + } + + public String getTranslationKey() { + return translationKey; } } diff --git a/src/main/java/com/viaversion/viafabricplus/settings/base/BooleanSetting.java b/api/src/main/java/com/viaversion/viafabricplus/api/settings/type/BooleanSetting.java similarity index 73% rename from src/main/java/com/viaversion/viafabricplus/settings/base/BooleanSetting.java rename to api/src/main/java/com/viaversion/viafabricplus/api/settings/type/BooleanSetting.java index ca0af174f..152bf0bbb 100644 --- a/src/main/java/com/viaversion/viafabricplus/settings/base/BooleanSetting.java +++ b/api/src/main/java/com/viaversion/viafabricplus/api/settings/type/BooleanSetting.java @@ -19,22 +19,16 @@ * along with this program. If not, see . */ -package com.viaversion.viafabricplus.settings.base; +package com.viaversion.viafabricplus.api.settings.type; import com.google.gson.JsonObject; -import com.viaversion.viafabricplus.base.screen.VFPListEntry; -import com.viaversion.viafabricplus.screen.settings.BooleanSettingRenderer; -import net.minecraft.text.MutableText; +import com.viaversion.viafabricplus.api.settings.AbstractSetting; +import com.viaversion.viafabricplus.api.settings.SettingGroup; public class BooleanSetting extends AbstractSetting { - public BooleanSetting(SettingGroup parent, MutableText name, Boolean defaultValue) { - super(parent, name, defaultValue); - } - - @Override - public VFPListEntry makeSettingRenderer() { - return new BooleanSettingRenderer(this); + public BooleanSetting(SettingGroup parent, String translationKey, Boolean defaultValue) { + super(parent, translationKey, defaultValue); } @Override diff --git a/src/main/java/com/viaversion/viafabricplus/settings/base/ButtonSetting.java b/api/src/main/java/com/viaversion/viafabricplus/api/settings/type/ButtonSetting.java similarity index 61% rename from src/main/java/com/viaversion/viafabricplus/settings/base/ButtonSetting.java rename to api/src/main/java/com/viaversion/viafabricplus/api/settings/type/ButtonSetting.java index 24c0d4d83..70262acd8 100644 --- a/src/main/java/com/viaversion/viafabricplus/settings/base/ButtonSetting.java +++ b/api/src/main/java/com/viaversion/viafabricplus/api/settings/type/ButtonSetting.java @@ -19,32 +19,34 @@ * along with this program. If not, see . */ -package com.viaversion.viafabricplus.settings.base; +package com.viaversion.viafabricplus.api.settings.type; import com.google.gson.JsonObject; -import com.viaversion.viafabricplus.base.screen.VFPListEntry; -import com.viaversion.viafabricplus.screen.settings.ButtonSettingRenderer; -import net.minecraft.text.MutableText; +import com.viaversion.viafabricplus.api.settings.AbstractSetting; +import com.viaversion.viafabricplus.api.settings.SettingGroup; public class ButtonSetting extends AbstractSetting { - public ButtonSetting(SettingGroup parent, MutableText name, Runnable onClick) { - super(parent, name, onClick); + public ButtonSetting(SettingGroup parent, String translationKey, Runnable onClick) { + super(parent, translationKey, onClick); } - @Override - public VFPListEntry makeSettingRenderer() { - return new ButtonSettingRenderer(this); - } - - public MutableText displayValue() { - return getName(); + /** + * If overriden, this string is used as replacement for the provided translation key in the GUI. Note that this function + * does not support localization. + * + * @return The string to display in the GUI + */ + public String displayString() { + return null; } @Override - public void write(JsonObject object) {} + public void write(JsonObject object) { + } @Override - public void read(JsonObject object) {} + public void read(JsonObject object) { + } } diff --git a/src/main/java/com/viaversion/viafabricplus/settings/base/ModeSetting.java b/api/src/main/java/com/viaversion/viafabricplus/api/settings/type/ModeSetting.java similarity index 61% rename from src/main/java/com/viaversion/viafabricplus/settings/base/ModeSetting.java rename to api/src/main/java/com/viaversion/viafabricplus/api/settings/type/ModeSetting.java index aa92e56b6..87c5351d4 100644 --- a/src/main/java/com/viaversion/viafabricplus/settings/base/ModeSetting.java +++ b/api/src/main/java/com/viaversion/viafabricplus/api/settings/type/ModeSetting.java @@ -19,44 +19,37 @@ * along with this program. If not, see . */ -package com.viaversion.viafabricplus.settings.base; +package com.viaversion.viafabricplus.api.settings.type; import com.google.gson.JsonObject; -import com.viaversion.viafabricplus.base.screen.VFPListEntry; -import com.viaversion.viafabricplus.screen.settings.ModeSettingRenderer; -import com.viaversion.viafabricplus.util.ChatUtil; -import net.minecraft.text.MutableText; +import com.viaversion.viafabricplus.api.settings.AbstractSetting; +import com.viaversion.viafabricplus.api.settings.SettingGroup; import java.util.Arrays; -public class ModeSetting extends AbstractSetting { +public class ModeSetting extends AbstractSetting { - private final MutableText[] options; + private final String[] options; - public ModeSetting(SettingGroup parent, MutableText name, MutableText... options) { - this(parent, name, 0, options); + public ModeSetting(SettingGroup parent, String translationKey, String... options) { + this(parent, translationKey, 0, options); } - public ModeSetting(SettingGroup parent, MutableText name, int defaultOption, MutableText... options) { - super(parent, name, options[defaultOption]); + public ModeSetting(SettingGroup parent, String translationKey, int defaultOption, String... options) { + super(parent, translationKey, options[defaultOption]); this.options = options; } - @Override - public VFPListEntry makeSettingRenderer() { - return new ModeSettingRenderer(this); - } - @Override public void write(JsonObject object) { - object.addProperty(getTranslationKey(), mapTranslationKey(ChatUtil.uncoverTranslationKey(getValue()))); + object.addProperty(getTranslationKey(), mapTranslationKey(getValue())); } @Override public void read(JsonObject object) { final String selected = object.get(getTranslationKey()).getAsString(); - for (MutableText option : options) { - if (mapTranslationKey(ChatUtil.uncoverTranslationKey(option)).equals(selected)) { + for (String option : options) { + if (mapTranslationKey(option).equals(selected)) { setValue(option); break; } @@ -71,7 +64,7 @@ public int getIndex() { return Arrays.stream(options).toList().indexOf(getValue()); } - public MutableText[] getOptions() { + public String[] getOptions() { return options; } diff --git a/src/main/java/com/viaversion/viafabricplus/settings/base/VersionedBooleanSetting.java b/api/src/main/java/com/viaversion/viafabricplus/api/settings/type/VersionedBooleanSetting.java similarity index 78% rename from src/main/java/com/viaversion/viafabricplus/settings/base/VersionedBooleanSetting.java rename to api/src/main/java/com/viaversion/viafabricplus/api/settings/type/VersionedBooleanSetting.java index 4b3186c96..7adf6114b 100644 --- a/src/main/java/com/viaversion/viafabricplus/settings/base/VersionedBooleanSetting.java +++ b/api/src/main/java/com/viaversion/viafabricplus/api/settings/type/VersionedBooleanSetting.java @@ -19,14 +19,13 @@ * along with this program. If not, see . */ -package com.viaversion.viafabricplus.settings.base; +package com.viaversion.viafabricplus.api.settings.type; import com.google.gson.JsonObject; +import com.viaversion.viafabricplus.ViaFabricPlus; +import com.viaversion.viafabricplus.api.settings.AbstractSetting; +import com.viaversion.viafabricplus.api.settings.SettingGroup; import com.viaversion.viaversion.api.protocol.version.ProtocolVersion; -import com.viaversion.viafabricplus.protocoltranslator.ProtocolTranslator; -import com.viaversion.viafabricplus.base.screen.VFPListEntry; -import com.viaversion.viafabricplus.screen.settings.VersionedBooleanSettingRenderer; -import net.minecraft.text.MutableText; import net.raphimc.vialoader.util.VersionRange; public class VersionedBooleanSetting extends AbstractSetting { @@ -37,17 +36,12 @@ public class VersionedBooleanSetting extends AbstractSetting { private final VersionRange protocolRange; - public VersionedBooleanSetting(SettingGroup parent, MutableText name, VersionRange protocolRange) { - super(parent, name, AUTO_INDEX); + public VersionedBooleanSetting(SettingGroup parent, String translationKey, VersionRange protocolRange) { + super(parent, translationKey, AUTO_INDEX); this.protocolRange = protocolRange; } - @Override - public VFPListEntry makeSettingRenderer() { - return new VersionedBooleanSettingRenderer(this); - } - @Override public void write(JsonObject object) { object.addProperty(getTranslationKey(), getValue() == AUTO_INDEX ? "auto" : getValue() == ENABLED_INDEX ? "enabled" : "disabled"); @@ -65,7 +59,7 @@ public boolean isAuto() { } public boolean isEnabled() { - return isEnabled(ProtocolTranslator.getTargetVersion()); + return isEnabled(ViaFabricPlus.getImpl().getTargetVersion()); } public boolean isEnabled(final ProtocolVersion version) { diff --git a/src/main/java/com/viaversion/viafabricplus/ViaFabricPlusImpl.java b/src/main/java/com/viaversion/viafabricplus/ViaFabricPlusImpl.java index 786d80e26..3f9070eca 100644 --- a/src/main/java/com/viaversion/viafabricplus/ViaFabricPlusImpl.java +++ b/src/main/java/com/viaversion/viafabricplus/ViaFabricPlusImpl.java @@ -21,16 +21,18 @@ package com.viaversion.viafabricplus; -import com.viaversion.viafabricplus.api.ChangeProtocolVersionCallback; -import com.viaversion.viafabricplus.api.LoadingCycleCallback; +import com.viaversion.viafabricplus.api.events.ChangeProtocolVersionCallback; +import com.viaversion.viafabricplus.api.events.LoadingCycleCallback; import com.viaversion.viafabricplus.api.ViaFabricPlusBase; +import com.viaversion.viafabricplus.api.settings.SettingGroup; import com.viaversion.viafabricplus.base.Events; +import com.viaversion.viafabricplus.base.sync_tasks.SyncTasks; import com.viaversion.viafabricplus.save.SaveManager; import com.viaversion.viafabricplus.settings.SettingsManager; import com.viaversion.viafabricplus.features.FeaturesLoading; import com.viaversion.viafabricplus.features.max_chat_length.MaxChatLength; import com.viaversion.viafabricplus.protocoltranslator.ProtocolTranslator; -import com.viaversion.viafabricplus.util.ClassLoaderPriorityUtil; +import com.viaversion.viafabricplus.base.overriding_jars.ClassLoaderPriorityUtil; import com.viaversion.viaversion.api.connection.UserConnection; import com.viaversion.viaversion.api.protocol.version.ProtocolVersion; import io.netty.channel.Channel; @@ -41,6 +43,7 @@ import java.io.IOException; import java.nio.file.Files; import java.nio.file.Path; +import java.util.List; import java.util.concurrent.CompletableFuture; /* @@ -81,9 +84,6 @@ public final class ViaFabricPlusImpl implements ViaFabricPlusBase { private final Logger logger = LogManager.getLogger("ViaFabricPlus"); private final Path path = FabricLoader.getInstance().getConfigDir().resolve("viafabricplus"); - private SettingsManager settingsManager; - private SaveManager saveManager; - private CompletableFuture loadingFuture; public void init() { @@ -102,10 +102,11 @@ public void init() { ClassLoaderPriorityUtil.loadOverridingJars(path, logger); // Load settings and config files - settingsManager = new SettingsManager(); - saveManager = new SaveManager(settingsManager); + SettingsManager.INSTANCE.init(); + SaveManager.INSTANCE.init(); // Init features + SyncTasks.init(); FeaturesLoading.init(); // Init ViaVersion protocol translator platform @@ -116,7 +117,7 @@ public void init() { return; } loadingFuture.join(); - saveManager.postInit(); + SaveManager.INSTANCE.postInit(); }); } @@ -175,12 +176,24 @@ public int getMaxChatLength(ProtocolVersion version) { return MaxChatLength.getChatLength(); } - public SettingsManager getSettingsManager() { - return settingsManager; + @Override + public List settingGroups() { + return SettingsManager.INSTANCE.getGroups(); + } + + @Override + public void addSettingGroup(SettingGroup group) { + SettingsManager.INSTANCE.addGroup(group); } - public SaveManager getSaveManager() { - return saveManager; + @Override + public SettingGroup getSettingGroup(String translationKey) { + for (SettingGroup group : SettingsManager.INSTANCE.getGroups()) { + if (group.getTranslationKey().equals(translationKey)) { + return group; + } + } + return null; } } diff --git a/src/main/java/com/viaversion/viafabricplus/base/Events.java b/src/main/java/com/viaversion/viafabricplus/base/Events.java index 60a5ac352..490db21b8 100644 --- a/src/main/java/com/viaversion/viafabricplus/base/Events.java +++ b/src/main/java/com/viaversion/viafabricplus/base/Events.java @@ -21,8 +21,8 @@ package com.viaversion.viafabricplus.base; -import com.viaversion.viafabricplus.api.ChangeProtocolVersionCallback; -import com.viaversion.viafabricplus.api.LoadingCycleCallback; +import com.viaversion.viafabricplus.api.events.ChangeProtocolVersionCallback; +import com.viaversion.viafabricplus.api.events.LoadingCycleCallback; import net.fabricmc.fabric.api.event.Event; import net.fabricmc.fabric.api.event.EventFactory; diff --git a/src/main/java/com/viaversion/viafabricplus/util/ModMenuScreenFactory.java b/src/main/java/com/viaversion/viafabricplus/base/modmenu/ModMenuScreenFactory.java similarity index 92% rename from src/main/java/com/viaversion/viafabricplus/util/ModMenuScreenFactory.java rename to src/main/java/com/viaversion/viafabricplus/base/modmenu/ModMenuScreenFactory.java index 443ef064f..8bff1bd33 100644 --- a/src/main/java/com/viaversion/viafabricplus/util/ModMenuScreenFactory.java +++ b/src/main/java/com/viaversion/viafabricplus/base/modmenu/ModMenuScreenFactory.java @@ -19,11 +19,11 @@ * along with this program. If not, see . */ -package com.viaversion.viafabricplus.util; +package com.viaversion.viafabricplus.base.modmenu; import com.terraformersmc.modmenu.api.ConfigScreenFactory; import com.terraformersmc.modmenu.api.ModMenuApi; -import com.viaversion.viafabricplus.screen.settings.SettingsScreen; +import com.viaversion.viafabricplus.screen.impl.settings.SettingsScreen; /** * Implementation of the ModMenu integration allowing users to open the settings screen from the mod menu. diff --git a/src/main/java/com/viaversion/viafabricplus/util/ClassLoaderPriorityUtil.java b/src/main/java/com/viaversion/viafabricplus/base/overriding_jars/ClassLoaderPriorityUtil.java similarity index 97% rename from src/main/java/com/viaversion/viafabricplus/util/ClassLoaderPriorityUtil.java rename to src/main/java/com/viaversion/viafabricplus/base/overriding_jars/ClassLoaderPriorityUtil.java index a132b0af3..3503e82cc 100644 --- a/src/main/java/com/viaversion/viafabricplus/util/ClassLoaderPriorityUtil.java +++ b/src/main/java/com/viaversion/viafabricplus/base/overriding_jars/ClassLoaderPriorityUtil.java @@ -19,12 +19,11 @@ * along with this program. If not, see . */ -package com.viaversion.viafabricplus.util; +package com.viaversion.viafabricplus.base.overriding_jars; import net.lenni0451.reflect.ClassLoaders; import net.lenni0451.reflect.stream.RStream; import org.apache.logging.log4j.Logger; -import org.jetbrains.annotations.ApiStatus; import java.io.File; import java.nio.file.Files; diff --git a/src/main/java/com/viaversion/viafabricplus/util/DataCustomPayload.java b/src/main/java/com/viaversion/viafabricplus/base/sync_tasks/DataCustomPayload.java similarity index 95% rename from src/main/java/com/viaversion/viafabricplus/util/DataCustomPayload.java rename to src/main/java/com/viaversion/viafabricplus/base/sync_tasks/DataCustomPayload.java index 5880ab242..43784a995 100644 --- a/src/main/java/com/viaversion/viafabricplus/util/DataCustomPayload.java +++ b/src/main/java/com/viaversion/viafabricplus/base/sync_tasks/DataCustomPayload.java @@ -19,9 +19,8 @@ * along with this program. If not, see . */ -package com.viaversion.viafabricplus.util; +package com.viaversion.viafabricplus.base.sync_tasks; -import com.viaversion.viafabricplus.base.SyncTasks; import io.netty.buffer.Unpooled; import net.fabricmc.fabric.api.networking.v1.PayloadTypeRegistry; import net.minecraft.network.PacketByteBuf; diff --git a/src/main/java/com/viaversion/viafabricplus/base/SyncTasks.java b/src/main/java/com/viaversion/viafabricplus/base/sync_tasks/SyncTasks.java similarity index 93% rename from src/main/java/com/viaversion/viafabricplus/base/SyncTasks.java rename to src/main/java/com/viaversion/viafabricplus/base/sync_tasks/SyncTasks.java index bf50f675f..5e05f99b3 100644 --- a/src/main/java/com/viaversion/viafabricplus/base/SyncTasks.java +++ b/src/main/java/com/viaversion/viafabricplus/base/sync_tasks/SyncTasks.java @@ -19,7 +19,7 @@ * along with this program. If not, see . */ -package com.viaversion.viafabricplus.base; +package com.viaversion.viafabricplus.base.sync_tasks; import net.minecraft.client.MinecraftClient; import net.minecraft.network.PacketByteBuf; @@ -42,6 +42,14 @@ public final class SyncTasks { */ public static final String PACKET_SYNC_IDENTIFIER = UUID.randomUUID() + ":" + UUID.randomUUID(); + static { + DataCustomPayload.init(); + } + + public static void init() { + // Calls the static block + } + /** * Executes a task synchronized with the main thread from networking threads * diff --git a/src/main/java/com/viaversion/viafabricplus/features/FeaturesLoading.java b/src/main/java/com/viaversion/viafabricplus/features/FeaturesLoading.java index 93b122cc3..7a57009cf 100644 --- a/src/main/java/com/viaversion/viafabricplus/features/FeaturesLoading.java +++ b/src/main/java/com/viaversion/viafabricplus/features/FeaturesLoading.java @@ -21,7 +21,7 @@ package com.viaversion.viafabricplus.features; -import com.viaversion.viafabricplus.api.LoadingCycleCallback; +import com.viaversion.viafabricplus.api.events.LoadingCycleCallback; import com.viaversion.viafabricplus.base.Events; import com.viaversion.viafabricplus.settings.impl.VisualSettings; import com.viaversion.viafabricplus.features.block.CollisionShapes; @@ -34,7 +34,7 @@ import com.viaversion.viafabricplus.features.ui.classic_creative_menu.GridItemSelectionScreen; import com.viaversion.viafabricplus.features.entity.EntityDimensionDiff; import com.viaversion.viafabricplus.features.entity.enchantment_attributes.EnchantmentAttributesEmulation1_20_6; -import com.viaversion.viafabricplus.util.DataCustomPayload; +import com.viaversion.viafabricplus.base.sync_tasks.DataCustomPayload; import com.viaversion.viaversion.api.protocol.version.ProtocolVersion; import net.minecraft.client.MinecraftClient; import net.raphimc.viaaprilfools.api.AprilFoolsProtocolVersion; diff --git a/src/main/java/com/viaversion/viafabricplus/features/ui/classic_creative_menu/GridItemSelectionScreen.java b/src/main/java/com/viaversion/viafabricplus/features/ui/classic_creative_menu/GridItemSelectionScreen.java index d878d5134..90b9be93d 100644 --- a/src/main/java/com/viaversion/viafabricplus/features/ui/classic_creative_menu/GridItemSelectionScreen.java +++ b/src/main/java/com/viaversion/viafabricplus/features/ui/classic_creative_menu/GridItemSelectionScreen.java @@ -22,7 +22,7 @@ package com.viaversion.viafabricplus.features.ui.classic_creative_menu; import com.viaversion.viafabricplus.features.item.filter_creative_tabs.ItemRegistryDiff; -import com.viaversion.viafabricplus.base.screen.VFPScreen; +import com.viaversion.viafabricplus.screen.VFPScreen; import net.minecraft.client.gui.DrawContext; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; diff --git a/src/main/java/com/viaversion/viafabricplus/injection/mixin/base/MixinMain.java b/src/main/java/com/viaversion/viafabricplus/injection/mixin/base/MixinMain.java index e61d08849..3ac369cf7 100644 --- a/src/main/java/com/viaversion/viafabricplus/injection/mixin/base/MixinMain.java +++ b/src/main/java/com/viaversion/viafabricplus/injection/mixin/base/MixinMain.java @@ -22,7 +22,7 @@ package com.viaversion.viafabricplus.injection.mixin.base; import com.viaversion.viafabricplus.ViaFabricPlusImpl; -import com.viaversion.viafabricplus.api.LoadingCycleCallback; +import com.viaversion.viafabricplus.api.events.LoadingCycleCallback; import com.viaversion.viafabricplus.base.Events; import net.minecraft.client.main.Main; import org.spongepowered.asm.mixin.Mixin; diff --git a/src/main/java/com/viaversion/viafabricplus/injection/mixin/base/integration/MixinDebugHud.java b/src/main/java/com/viaversion/viafabricplus/injection/mixin/base/integration/MixinDebugHud.java index aff44d5f0..c8e7c49c4 100644 --- a/src/main/java/com/viaversion/viafabricplus/injection/mixin/base/integration/MixinDebugHud.java +++ b/src/main/java/com/viaversion/viafabricplus/injection/mixin/base/integration/MixinDebugHud.java @@ -23,7 +23,7 @@ import com.viaversion.viaversion.api.connection.ProtocolInfo; import com.viaversion.viaversion.api.connection.UserConnection; -import com.viaversion.viafabricplus.base.bedrock.BedrockJoinGameTracker; +import com.viaversion.viafabricplus.protocoltranslator.protocol.storage.BedrockJoinGameTracker; import com.viaversion.viafabricplus.injection.ViaFabricPlusMixinPlugin; import com.viaversion.viafabricplus.injection.access.base.bedrock.IChunkTracker; import com.viaversion.viafabricplus.injection.access.base.bedrock.IRakSessionCodec; diff --git a/src/main/java/com/viaversion/viafabricplus/injection/mixin/base/integration/MixinMinecraftClient.java b/src/main/java/com/viaversion/viafabricplus/injection/mixin/base/integration/MixinMinecraftClient.java index afebb2803..75310a003 100644 --- a/src/main/java/com/viaversion/viafabricplus/injection/mixin/base/integration/MixinMinecraftClient.java +++ b/src/main/java/com/viaversion/viafabricplus/injection/mixin/base/integration/MixinMinecraftClient.java @@ -21,7 +21,7 @@ package com.viaversion.viafabricplus.injection.mixin.base.integration; -import com.viaversion.viafabricplus.api.LoadingCycleCallback; +import com.viaversion.viafabricplus.api.events.LoadingCycleCallback; import com.viaversion.viafabricplus.base.Events; import net.minecraft.client.MinecraftClient; import net.minecraft.client.RunArgs; diff --git a/src/main/java/com/viaversion/viafabricplus/injection/mixin/base/integration/bedrock/MixinConnectScreen_1.java b/src/main/java/com/viaversion/viafabricplus/injection/mixin/base/integration/bedrock/MixinConnectScreen_1.java index c1a0c2325..b86f5bafd 100644 --- a/src/main/java/com/viaversion/viafabricplus/injection/mixin/base/integration/bedrock/MixinConnectScreen_1.java +++ b/src/main/java/com/viaversion/viafabricplus/injection/mixin/base/integration/bedrock/MixinConnectScreen_1.java @@ -22,6 +22,7 @@ package com.viaversion.viafabricplus.injection.mixin.base.integration.bedrock; import com.llamalad7.mixinextras.sugar.Local; +import com.viaversion.viafabricplus.save.SaveManager; import com.viaversion.viaversion.api.connection.UserConnection; import com.viaversion.viafabricplus.ViaFabricPlusImpl; import com.viaversion.viafabricplus.injection.access.base.IClientConnection; @@ -46,7 +47,7 @@ private void setupBedrockAccount(CallbackInfo ci, @Local ClientConnection client final UserConnection userConnection = ((IClientConnection) clientConnection).viaFabricPlus$getUserConnection(); if (ProtocolTranslator.getTargetVersion() == BedrockProtocolVersion.bedrockLatest) { - final StepFullBedrockSession.FullBedrockSession bedrockSession = ViaFabricPlusImpl.INSTANCE.getSaveManager().getAccountsSave().refreshAndGetBedrockAccount(); + final StepFullBedrockSession.FullBedrockSession bedrockSession = SaveManager.INSTANCE.getAccountsSave().refreshAndGetBedrockAccount(); if (bedrockSession != null) { final StepMCChain.MCChain mcChain = bedrockSession.getMcChain(); final UUID deviceId = mcChain.getXblXsts().getInitialXblSession().getXblDeviceToken().getId(); diff --git a/src/main/java/com/viaversion/viafabricplus/injection/mixin/base/integration/sync_tasks/MixinClientCommonNetworkHandler.java b/src/main/java/com/viaversion/viafabricplus/injection/mixin/base/integration/sync_tasks/MixinClientCommonNetworkHandler.java index 64bb719d5..5e74b34e5 100644 --- a/src/main/java/com/viaversion/viafabricplus/injection/mixin/base/integration/sync_tasks/MixinClientCommonNetworkHandler.java +++ b/src/main/java/com/viaversion/viafabricplus/injection/mixin/base/integration/sync_tasks/MixinClientCommonNetworkHandler.java @@ -21,8 +21,8 @@ package com.viaversion.viafabricplus.injection.mixin.base.integration.sync_tasks; -import com.viaversion.viafabricplus.base.SyncTasks; -import com.viaversion.viafabricplus.util.DataCustomPayload; +import com.viaversion.viafabricplus.base.sync_tasks.SyncTasks; +import com.viaversion.viafabricplus.base.sync_tasks.DataCustomPayload; import net.minecraft.client.network.ClientCommonNetworkHandler; import net.minecraft.network.packet.s2c.common.CustomPayloadS2CPacket; import org.spongepowered.asm.mixin.Mixin; diff --git a/src/main/java/com/viaversion/viafabricplus/injection/mixin/base/ui/MixinAddServerScreen.java b/src/main/java/com/viaversion/viafabricplus/injection/mixin/base/ui/MixinAddServerScreen.java index 5a481da2d..e816c7016 100644 --- a/src/main/java/com/viaversion/viafabricplus/injection/mixin/base/ui/MixinAddServerScreen.java +++ b/src/main/java/com/viaversion/viafabricplus/injection/mixin/base/ui/MixinAddServerScreen.java @@ -23,7 +23,7 @@ import com.viaversion.viaversion.api.protocol.version.ProtocolVersion; import com.viaversion.viafabricplus.injection.access.base.IServerInfo; -import com.viaversion.viafabricplus.screen.PerServerVersionScreen; +import com.viaversion.viafabricplus.screen.impl.PerServerVersionScreen; import com.viaversion.viafabricplus.settings.impl.GeneralSettings; import net.minecraft.client.gui.screen.Screen; import net.minecraft.client.gui.screen.multiplayer.AddServerScreen; diff --git a/src/main/java/com/viaversion/viafabricplus/injection/mixin/base/ui/MixinConnectScreen_1.java b/src/main/java/com/viaversion/viafabricplus/injection/mixin/base/ui/MixinConnectScreen_1.java index 476fe3c18..e3384338d 100644 --- a/src/main/java/com/viaversion/viafabricplus/injection/mixin/base/ui/MixinConnectScreen_1.java +++ b/src/main/java/com/viaversion/viafabricplus/injection/mixin/base/ui/MixinConnectScreen_1.java @@ -23,6 +23,7 @@ import com.llamalad7.mixinextras.injector.wrapoperation.Operation; import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation; +import com.viaversion.viafabricplus.save.SaveManager; import com.viaversion.viaversion.api.protocol.version.ProtocolVersion; import de.florianmichael.classic4j.model.classicube.account.CCAccount; import com.viaversion.viafabricplus.ViaFabricPlusImpl; @@ -86,7 +87,7 @@ private ChannelFuture setServerInfoAndHandleDisconnect(InetSocketAddress address @Redirect(method = "run", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/session/Session;getUsername()Ljava/lang/String;")) private String useClassiCubeUsername(Session instance) { if (this.viaFabricPlus$useClassiCubeAccount) { - final CCAccount account = ViaFabricPlusImpl.INSTANCE.getSaveManager().getAccountsSave().getClassicubeAccount(); + final CCAccount account = SaveManager.INSTANCE.getAccountsSave().getClassicubeAccount(); if (account != null) { return account.username(); } diff --git a/src/main/java/com/viaversion/viafabricplus/injection/mixin/base/ui/MixinDirectConnectScreen.java b/src/main/java/com/viaversion/viafabricplus/injection/mixin/base/ui/MixinDirectConnectScreen.java index b04a214f5..7943b182d 100644 --- a/src/main/java/com/viaversion/viafabricplus/injection/mixin/base/ui/MixinDirectConnectScreen.java +++ b/src/main/java/com/viaversion/viafabricplus/injection/mixin/base/ui/MixinDirectConnectScreen.java @@ -21,7 +21,7 @@ package com.viaversion.viafabricplus.injection.mixin.base.ui; -import com.viaversion.viafabricplus.screen.ProtocolSelectionScreen; +import com.viaversion.viafabricplus.screen.impl.ProtocolSelectionScreen; import com.viaversion.viafabricplus.settings.impl.GeneralSettings; import net.minecraft.client.gui.screen.Screen; import net.minecraft.client.gui.screen.multiplayer.DirectConnectScreen; diff --git a/src/main/java/com/viaversion/viafabricplus/injection/mixin/base/ui/MixinMultiplayerScreen.java b/src/main/java/com/viaversion/viafabricplus/injection/mixin/base/ui/MixinMultiplayerScreen.java index 983a2a259..94e11d740 100644 --- a/src/main/java/com/viaversion/viafabricplus/injection/mixin/base/ui/MixinMultiplayerScreen.java +++ b/src/main/java/com/viaversion/viafabricplus/injection/mixin/base/ui/MixinMultiplayerScreen.java @@ -28,7 +28,7 @@ import com.viaversion.viaversion.api.protocol.version.ProtocolVersion; import com.viaversion.viafabricplus.injection.access.base.IServerInfo; import com.viaversion.viafabricplus.protocoltranslator.ProtocolTranslator; -import com.viaversion.viafabricplus.screen.ProtocolSelectionScreen; +import com.viaversion.viafabricplus.screen.impl.ProtocolSelectionScreen; import com.viaversion.viafabricplus.settings.impl.GeneralSettings; import net.minecraft.client.gui.screen.Screen; import net.minecraft.client.gui.screen.multiplayer.MultiplayerScreen; diff --git a/src/main/java/com/viaversion/viafabricplus/injection/mixin/features/interaction/MixinWorldPacketRewriter1_19.java b/src/main/java/com/viaversion/viafabricplus/injection/mixin/features/interaction/MixinWorldPacketRewriter1_19.java index 0edb7ea07..2499019c8 100644 --- a/src/main/java/com/viaversion/viafabricplus/injection/mixin/features/interaction/MixinWorldPacketRewriter1_19.java +++ b/src/main/java/com/viaversion/viafabricplus/injection/mixin/features/interaction/MixinWorldPacketRewriter1_19.java @@ -21,7 +21,7 @@ package com.viaversion.viafabricplus.injection.mixin.features.interaction; -import com.viaversion.viafabricplus.base.SyncTasks; +import com.viaversion.viafabricplus.base.sync_tasks.SyncTasks; import com.viaversion.viaversion.api.protocol.packet.ClientboundPacketType; import com.viaversion.viaversion.api.type.Types; import com.viaversion.viaversion.protocols.v1_17_1to1_18.packet.ClientboundPackets1_18; diff --git a/src/main/java/com/viaversion/viafabricplus/injection/mixin/features/item/mining_speeds/MixinBlockItemPacketRewriter1_20_5.java b/src/main/java/com/viaversion/viafabricplus/injection/mixin/features/item/mining_speeds/MixinBlockItemPacketRewriter1_20_5.java index cf5b57ae9..a515d6ff5 100644 --- a/src/main/java/com/viaversion/viafabricplus/injection/mixin/features/item/mining_speeds/MixinBlockItemPacketRewriter1_20_5.java +++ b/src/main/java/com/viaversion/viafabricplus/injection/mixin/features/item/mining_speeds/MixinBlockItemPacketRewriter1_20_5.java @@ -21,7 +21,7 @@ package com.viaversion.viafabricplus.injection.mixin.features.item.mining_speeds; -import com.viaversion.viafabricplus.api.LoadingCycleCallback; +import com.viaversion.viafabricplus.api.events.LoadingCycleCallback; import com.viaversion.viafabricplus.base.Events; import com.viaversion.viaversion.api.connection.UserConnection; import com.viaversion.viaversion.api.minecraft.HolderSet; diff --git a/src/main/java/com/viaversion/viafabricplus/injection/mixin/features/ui/triple_chests/MixinItemPacketRewriter1_14.java b/src/main/java/com/viaversion/viafabricplus/injection/mixin/features/ui/triple_chests/MixinItemPacketRewriter1_14.java index 45f258f59..73a902e04 100644 --- a/src/main/java/com/viaversion/viafabricplus/injection/mixin/features/ui/triple_chests/MixinItemPacketRewriter1_14.java +++ b/src/main/java/com/viaversion/viafabricplus/injection/mixin/features/ui/triple_chests/MixinItemPacketRewriter1_14.java @@ -22,7 +22,7 @@ package com.viaversion.viafabricplus.injection.mixin.features.ui.triple_chests; import com.llamalad7.mixinextras.sugar.Local; -import com.viaversion.viafabricplus.base.SyncTasks; +import com.viaversion.viafabricplus.base.sync_tasks.SyncTasks; import com.viaversion.viaversion.api.minecraft.item.Item; import com.viaversion.viaversion.api.protocol.packet.PacketWrapper; import com.viaversion.viaversion.api.type.Type; diff --git a/src/main/java/com/viaversion/viafabricplus/injection/mixin/integration/viabedrock/MixinJoinPackets.java b/src/main/java/com/viaversion/viafabricplus/injection/mixin/integration/viabedrock/MixinJoinPackets.java index c5112097e..8eb79295c 100644 --- a/src/main/java/com/viaversion/viafabricplus/injection/mixin/integration/viabedrock/MixinJoinPackets.java +++ b/src/main/java/com/viaversion/viafabricplus/injection/mixin/integration/viabedrock/MixinJoinPackets.java @@ -23,7 +23,7 @@ import com.viaversion.viaversion.api.protocol.packet.PacketWrapper; import com.viaversion.viaversion.api.type.Type; -import com.viaversion.viafabricplus.base.bedrock.BedrockJoinGameTracker; +import com.viaversion.viafabricplus.protocoltranslator.protocol.storage.BedrockJoinGameTracker; import net.raphimc.viabedrock.protocol.packet.JoinPackets; import net.raphimc.viabedrock.protocol.types.primitive.LongLEType; import net.raphimc.viabedrock.protocol.types.primitive.StringType; diff --git a/src/main/java/com/viaversion/viafabricplus/protocoltranslator/impl/viaversion/ViaFabricPlusVLLoader.java b/src/main/java/com/viaversion/viafabricplus/protocoltranslator/impl/viaversion/ViaFabricPlusVLLoader.java index 8d1f0ea11..2cfcb9f6c 100644 --- a/src/main/java/com/viaversion/viafabricplus/protocoltranslator/impl/viaversion/ViaFabricPlusVLLoader.java +++ b/src/main/java/com/viaversion/viafabricplus/protocoltranslator/impl/viaversion/ViaFabricPlusVLLoader.java @@ -21,7 +21,7 @@ package com.viaversion.viafabricplus.protocoltranslator.impl.viaversion; -import com.viaversion.viafabricplus.api.LoadingCycleCallback; +import com.viaversion.viafabricplus.api.events.LoadingCycleCallback; import com.viaversion.viafabricplus.base.Events; import com.viaversion.viafabricplus.protocoltranslator.impl.provider.vialegacy.*; import com.viaversion.viafabricplus.protocoltranslator.impl.provider.viaversion.*; diff --git a/src/main/java/com/viaversion/viafabricplus/protocoltranslator/protocol/ViaFabricPlusProtocol.java b/src/main/java/com/viaversion/viafabricplus/protocoltranslator/protocol/ViaFabricPlusProtocol.java index 769037a11..c6f6dab2d 100644 --- a/src/main/java/com/viaversion/viafabricplus/protocoltranslator/protocol/ViaFabricPlusProtocol.java +++ b/src/main/java/com/viaversion/viafabricplus/protocoltranslator/protocol/ViaFabricPlusProtocol.java @@ -21,7 +21,7 @@ package com.viaversion.viafabricplus.protocoltranslator.protocol; -import com.viaversion.viafabricplus.base.bedrock.BedrockJoinGameTracker; +import com.viaversion.viafabricplus.protocoltranslator.protocol.storage.BedrockJoinGameTracker; import com.viaversion.viafabricplus.features.entity.metadata_handling.WolfHealthTracker1_14_4; import com.viaversion.viaversion.api.connection.UserConnection; import com.viaversion.viaversion.api.protocol.AbstractSimpleProtocol; diff --git a/src/main/java/com/viaversion/viafabricplus/base/bedrock/BedrockJoinGameTracker.java b/src/main/java/com/viaversion/viafabricplus/protocoltranslator/protocol/storage/BedrockJoinGameTracker.java similarity index 95% rename from src/main/java/com/viaversion/viafabricplus/base/bedrock/BedrockJoinGameTracker.java rename to src/main/java/com/viaversion/viafabricplus/protocoltranslator/protocol/storage/BedrockJoinGameTracker.java index b5853bc8c..7f733ae30 100644 --- a/src/main/java/com/viaversion/viafabricplus/base/bedrock/BedrockJoinGameTracker.java +++ b/src/main/java/com/viaversion/viafabricplus/protocoltranslator/protocol/storage/BedrockJoinGameTracker.java @@ -19,7 +19,7 @@ * along with this program. If not, see . */ -package com.viaversion.viafabricplus.base.bedrock; +package com.viaversion.viafabricplus.protocoltranslator.protocol.storage; import com.viaversion.viaversion.api.connection.StorableObject; diff --git a/src/main/java/com/viaversion/viafabricplus/save/SaveManager.java b/src/main/java/com/viaversion/viafabricplus/save/SaveManager.java index 9cf01e714..2203d5412 100644 --- a/src/main/java/com/viaversion/viafabricplus/save/SaveManager.java +++ b/src/main/java/com/viaversion/viafabricplus/save/SaveManager.java @@ -21,7 +21,7 @@ package com.viaversion.viafabricplus.save; -import com.viaversion.viafabricplus.api.LoadingCycleCallback; +import com.viaversion.viafabricplus.api.events.LoadingCycleCallback; import com.viaversion.viafabricplus.base.Events; import com.viaversion.viafabricplus.save.impl.AccountsSave; import com.viaversion.viafabricplus.save.impl.SettingsSave; @@ -33,17 +33,19 @@ public final class SaveManager { + public static final SaveManager INSTANCE = new SaveManager(); + private final List saves = new ArrayList<>(); - private final SettingsSave settingsSave; - private final AccountsSave accountsSave; + private SettingsSave settingsSave; + private AccountsSave accountsSave; - public SaveManager(final SettingsManager settingsManager) { + public void init() { Events.LOADING_CYCLE.invoker().onLoadCycle(LoadingCycleCallback.LoadingCycle.PRE_FILES_LOAD); // Register saves add( - settingsSave = new SettingsSave(settingsManager), + settingsSave = new SettingsSave(), accountsSave = new AccountsSave() ); diff --git a/src/main/java/com/viaversion/viafabricplus/save/impl/SettingsSave.java b/src/main/java/com/viaversion/viafabricplus/save/impl/SettingsSave.java index 7f753e26b..39eeb1760 100644 --- a/src/main/java/com/viaversion/viafabricplus/save/impl/SettingsSave.java +++ b/src/main/java/com/viaversion/viafabricplus/save/impl/SettingsSave.java @@ -26,32 +26,29 @@ import com.viaversion.viafabricplus.protocoltranslator.ProtocolTranslator; import com.viaversion.viafabricplus.save.AbstractSave; import com.viaversion.viafabricplus.settings.SettingsManager; -import com.viaversion.viafabricplus.settings.base.AbstractSetting; -import com.viaversion.viafabricplus.settings.base.SettingGroup; +import com.viaversion.viafabricplus.api.settings.AbstractSetting; +import com.viaversion.viafabricplus.api.settings.SettingGroup; import com.viaversion.viafabricplus.settings.impl.GeneralSettings; import com.viaversion.viafabricplus.util.ChatUtil; import net.raphimc.viabedrock.api.BedrockProtocolVersion; public final class SettingsSave extends AbstractSave { - private final SettingsManager settingsManager; private String selectedProtocolVersion; - public SettingsSave(final SettingsManager settingsManager) { + public SettingsSave() { super("settings"); - - this.settingsManager = settingsManager; } @Override public void write(JsonObject object) { - for (SettingGroup group : settingsManager.getGroups()) { + for (SettingGroup group : SettingsManager.INSTANCE.getGroups()) { final JsonObject groupObject = new JsonObject(); for (AbstractSetting setting : group.getSettings()) { setting.write(groupObject); } - object.add(AbstractSetting.mapTranslationKey(ChatUtil.uncoverTranslationKey(group.getName())), groupObject); + object.add(AbstractSetting.mapTranslationKey(group.getTranslationKey()), groupObject); } object.addProperty("selected-protocol-version", ProtocolTranslator.getTargetVersion().getName()); @@ -59,8 +56,8 @@ public void write(JsonObject object) { @Override public void read(JsonObject object) { - for (SettingGroup group : settingsManager.getGroups()) { - final String translationKey = ChatUtil.uncoverTranslationKey(group.getName()); + for (SettingGroup group : SettingsManager.INSTANCE.getGroups()) { + final String translationKey = group.getTranslationKey(); final JsonObject groupObject = object.getAsJsonObject(AbstractSetting.mapTranslationKey(translationKey)); for (AbstractSetting setting : group.getSettings()) { diff --git a/src/main/java/com/viaversion/viafabricplus/base/screen/VFPList.java b/src/main/java/com/viaversion/viafabricplus/screen/VFPList.java similarity index 93% rename from src/main/java/com/viaversion/viafabricplus/base/screen/VFPList.java rename to src/main/java/com/viaversion/viafabricplus/screen/VFPList.java index 7e908fcdf..bd93fee3d 100644 --- a/src/main/java/com/viaversion/viafabricplus/base/screen/VFPList.java +++ b/src/main/java/com/viaversion/viafabricplus/screen/VFPList.java @@ -19,10 +19,10 @@ * along with this program. If not, see . */ -package com.viaversion.viafabricplus.base.screen; +package com.viaversion.viafabricplus.screen; -import com.viaversion.viafabricplus.screen.PerServerVersionScreen; -import com.viaversion.viafabricplus.screen.ProtocolSelectionScreen; +import com.viaversion.viafabricplus.screen.impl.PerServerVersionScreen; +import com.viaversion.viafabricplus.screen.impl.ProtocolSelectionScreen; import com.viaversion.viafabricplus.settings.impl.GeneralSettings; import net.minecraft.client.MinecraftClient; import net.minecraft.client.gui.DrawContext; diff --git a/src/main/java/com/viaversion/viafabricplus/base/screen/VFPListEntry.java b/src/main/java/com/viaversion/viafabricplus/screen/VFPListEntry.java similarity index 82% rename from src/main/java/com/viaversion/viafabricplus/base/screen/VFPListEntry.java rename to src/main/java/com/viaversion/viafabricplus/screen/VFPListEntry.java index 67fc97e4c..e68efbff8 100644 --- a/src/main/java/com/viaversion/viafabricplus/base/screen/VFPListEntry.java +++ b/src/main/java/com/viaversion/viafabricplus/screen/VFPListEntry.java @@ -19,7 +19,7 @@ * along with this program. If not, see . */ -package com.viaversion.viafabricplus.base.screen; +package com.viaversion.viafabricplus.screen; import net.minecraft.client.MinecraftClient; import net.minecraft.client.font.TextRenderer; @@ -84,14 +84,14 @@ public void renderScrollableText(final Text name, final int offset) { /** * Automatically scrolls the text if it is too long to be displayed in the slot. The text will be scrolled from right to left * - * @param name The text which should be displayed + * @param text The text which should be displayed * @param textY The Y position of the text * @param offset The offset of the text from the left side of the slot, this is used to calculate the width of the text, which should be scrolled (Scrolling is enabled when entryWidth - offset < textWidth) */ - public void renderScrollableText(final Text name, final int textY, final int offset) { + public void renderScrollableText(final Text text, final int textY, final int offset) { final TextRenderer font = MinecraftClient.getInstance().textRenderer; - final int fontWidth = font.getWidth(name); + final int fontWidth = font.getWidth(text); if (fontWidth > (entryWidth - offset)) { final double time = (double) Util.getMeasuringTimeMs() / 1000.0; final double interpolateEnd = fontWidth - (entryWidth - offset - (SCISSORS_OFFSET + SLOT_MARGIN)); @@ -99,23 +99,36 @@ public void renderScrollableText(final Text name, final int textY, final int off final double interpolatedValue = Math.sin((Math.PI / 2) * Math.cos(Math.PI * 2 * time / Math.max(interpolateEnd * 0.5, 3.0))) / 2.0 + 0.5; context.enableScissor(0, 0, entryWidth - offset - SCISSORS_OFFSET, entryHeight); - context.drawTextWithShadow(font, name, SLOT_MARGIN - (int) MathHelper.lerp(interpolatedValue, 0.0, interpolateEnd), textY, -1); + context.drawTextWithShadow(font, text, SLOT_MARGIN - (int) MathHelper.lerp(interpolatedValue, 0.0, interpolateEnd), textY, -1); context.disableScissor(); } else { - context.drawTextWithShadow(font, name, SLOT_MARGIN, textY, -1); + context.drawTextWithShadow(font, text, SLOT_MARGIN, textY, -1); } } /** * Draws a tooltip if the mouse is hovering over the slot * - * @param tooltip The tooltip which should be displayed - * @param mouseX The current mouse X position - * @param mouseY The current mouse Y position + * @param translationKey The tooltip which should be displayed + * @param mouseX The current mouse X position + * @param mouseY The current mouse Y position */ - public void renderTooltip(final @Nullable Text tooltip, final int mouseX, final int mouseY) { - if (tooltip != null && mouseX >= x && mouseX <= x + entryWidth && mouseY >= y && mouseY <= y + entryHeight) { - context.drawTooltip(MinecraftClient.getInstance().textRenderer, tooltip, mouseX - x, mouseY - y); + public void renderTooltip(final @Nullable String translationKey, final int mouseX, final int mouseY) { + if (translationKey != null) { + renderTooltip(Text.translatable(translationKey), mouseX, mouseY); + } + } + + /** + * Draws a tooltip if the mouse is hovering over the slot + * + * @param text The tooltip which should be displayed + * @param mouseX The current mouse X position + * @param mouseY The current mouse Y position + */ + public void renderTooltip(final @Nullable Text text, final int mouseX, final int mouseY) { + if (text != null && mouseX >= x && mouseX <= x + entryWidth && mouseY >= y && mouseY <= y + entryHeight) { + context.drawTooltip(MinecraftClient.getInstance().textRenderer, text, mouseX - x, mouseY - y); } } diff --git a/src/main/java/com/viaversion/viafabricplus/base/screen/VFPScreen.java b/src/main/java/com/viaversion/viafabricplus/screen/VFPScreen.java similarity index 99% rename from src/main/java/com/viaversion/viafabricplus/base/screen/VFPScreen.java rename to src/main/java/com/viaversion/viafabricplus/screen/VFPScreen.java index e39e5af3b..dc6fb2562 100644 --- a/src/main/java/com/viaversion/viafabricplus/base/screen/VFPScreen.java +++ b/src/main/java/com/viaversion/viafabricplus/screen/VFPScreen.java @@ -19,7 +19,7 @@ * along with this program. If not, see . */ -package com.viaversion.viafabricplus.base.screen; +package com.viaversion.viafabricplus.screen; import com.viaversion.viafabricplus.ViaFabricPlusImpl; import net.minecraft.client.MinecraftClient; diff --git a/src/main/java/com/viaversion/viafabricplus/screen/PerServerVersionScreen.java b/src/main/java/com/viaversion/viafabricplus/screen/impl/PerServerVersionScreen.java similarity index 95% rename from src/main/java/com/viaversion/viafabricplus/screen/PerServerVersionScreen.java rename to src/main/java/com/viaversion/viafabricplus/screen/impl/PerServerVersionScreen.java index 827a71813..29dd86ab9 100644 --- a/src/main/java/com/viaversion/viafabricplus/screen/PerServerVersionScreen.java +++ b/src/main/java/com/viaversion/viafabricplus/screen/impl/PerServerVersionScreen.java @@ -19,12 +19,12 @@ * along with this program. If not, see . */ -package com.viaversion.viafabricplus.screen; +package com.viaversion.viafabricplus.screen.impl; import com.viaversion.viaversion.api.protocol.version.ProtocolVersion; -import com.viaversion.viafabricplus.base.screen.VFPList; -import com.viaversion.viafabricplus.base.screen.VFPListEntry; -import com.viaversion.viafabricplus.base.screen.VFPScreen; +import com.viaversion.viafabricplus.screen.VFPList; +import com.viaversion.viafabricplus.screen.VFPListEntry; +import com.viaversion.viafabricplus.screen.VFPScreen; import net.minecraft.client.MinecraftClient; import net.minecraft.client.font.TextRenderer; import net.minecraft.client.gui.DrawContext; diff --git a/src/main/java/com/viaversion/viafabricplus/screen/ProtocolSelectionScreen.java b/src/main/java/com/viaversion/viafabricplus/screen/impl/ProtocolSelectionScreen.java similarity index 94% rename from src/main/java/com/viaversion/viafabricplus/screen/ProtocolSelectionScreen.java rename to src/main/java/com/viaversion/viafabricplus/screen/impl/ProtocolSelectionScreen.java index 681a9304f..5ecef1648 100644 --- a/src/main/java/com/viaversion/viafabricplus/screen/ProtocolSelectionScreen.java +++ b/src/main/java/com/viaversion/viafabricplus/screen/impl/ProtocolSelectionScreen.java @@ -19,14 +19,14 @@ * along with this program. If not, see . */ -package com.viaversion.viafabricplus.screen; +package com.viaversion.viafabricplus.screen.impl; import com.viaversion.viaversion.api.protocol.version.ProtocolVersion; import com.viaversion.viafabricplus.protocoltranslator.ProtocolTranslator; -import com.viaversion.viafabricplus.base.screen.VFPList; -import com.viaversion.viafabricplus.base.screen.VFPListEntry; -import com.viaversion.viafabricplus.base.screen.VFPScreen; -import com.viaversion.viafabricplus.screen.settings.SettingsScreen; +import com.viaversion.viafabricplus.screen.VFPList; +import com.viaversion.viafabricplus.screen.VFPListEntry; +import com.viaversion.viafabricplus.screen.VFPScreen; +import com.viaversion.viafabricplus.screen.impl.settings.SettingsScreen; import net.minecraft.client.MinecraftClient; import net.minecraft.client.font.TextRenderer; import net.minecraft.client.gui.DrawContext; diff --git a/src/main/java/com/viaversion/viafabricplus/screen/ReportIssuesScreen.java b/src/main/java/com/viaversion/viafabricplus/screen/impl/ReportIssuesScreen.java similarity index 97% rename from src/main/java/com/viaversion/viafabricplus/screen/ReportIssuesScreen.java rename to src/main/java/com/viaversion/viafabricplus/screen/impl/ReportIssuesScreen.java index 3247ef179..11a899286 100644 --- a/src/main/java/com/viaversion/viafabricplus/screen/ReportIssuesScreen.java +++ b/src/main/java/com/viaversion/viafabricplus/screen/impl/ReportIssuesScreen.java @@ -19,11 +19,11 @@ * along with this program. If not, see . */ -package com.viaversion.viafabricplus.screen; +package com.viaversion.viafabricplus.screen.impl; import com.viaversion.viaversion.util.DumpUtil; import com.viaversion.viafabricplus.ViaFabricPlusImpl; -import com.viaversion.viafabricplus.base.screen.VFPScreen; +import com.viaversion.viafabricplus.screen.VFPScreen; import net.minecraft.client.gui.widget.ButtonWidget; import net.minecraft.text.Text; import net.minecraft.util.Util; diff --git a/src/main/java/com/viaversion/viafabricplus/screen/ServerListScreen.java b/src/main/java/com/viaversion/viafabricplus/screen/impl/ServerListScreen.java similarity index 80% rename from src/main/java/com/viaversion/viafabricplus/screen/ServerListScreen.java rename to src/main/java/com/viaversion/viafabricplus/screen/impl/ServerListScreen.java index 66aebad4d..8dede8c3f 100644 --- a/src/main/java/com/viaversion/viafabricplus/screen/ServerListScreen.java +++ b/src/main/java/com/viaversion/viafabricplus/screen/impl/ServerListScreen.java @@ -19,14 +19,14 @@ * along with this program. If not, see . */ -package com.viaversion.viafabricplus.screen; +package com.viaversion.viafabricplus.screen.impl; -import com.viaversion.viafabricplus.ViaFabricPlusImpl; -import com.viaversion.viafabricplus.base.screen.VFPScreen; -import com.viaversion.viafabricplus.screen.classic4j.BetaCraftScreen; -import com.viaversion.viafabricplus.screen.classic4j.ClassiCubeLoginScreen; -import com.viaversion.viafabricplus.screen.classic4j.ClassiCubeServerListScreen; -import com.viaversion.viafabricplus.screen.realms.BedrockRealmsScreen; +import com.viaversion.viafabricplus.save.SaveManager; +import com.viaversion.viafabricplus.screen.VFPScreen; +import com.viaversion.viafabricplus.screen.impl.classic4j.BetaCraftScreen; +import com.viaversion.viafabricplus.screen.impl.classic4j.ClassiCubeLoginScreen; +import com.viaversion.viafabricplus.screen.impl.classic4j.ClassiCubeServerListScreen; +import com.viaversion.viafabricplus.screen.impl.realms.BedrockRealmsScreen; import net.minecraft.client.gui.tooltip.Tooltip; import net.minecraft.client.gui.widget.ButtonWidget; import net.minecraft.text.Text; @@ -45,7 +45,7 @@ protected void init() { this.setupDefaultSubtitle(); // ClassiCube - final boolean loggedIn = ViaFabricPlusImpl.INSTANCE.getSaveManager().getAccountsSave().getClassicubeAccount() != null; + final boolean loggedIn = SaveManager.INSTANCE.getAccountsSave().getClassicubeAccount() != null; final ButtonWidget.Builder classiCubeBuilder = ButtonWidget.builder(ClassiCubeServerListScreen.INSTANCE.getTitle(), button -> { if (!loggedIn) { @@ -70,7 +70,7 @@ protected void init() { final ButtonWidget.Builder bedrockRealmsBuilder = ButtonWidget.builder(BedrockRealmsScreen.INSTANCE.getTitle(), button -> { BedrockRealmsScreen.INSTANCE.open(this); }).position(this.width / 2 - 100, this.height / 2 - 25 + 40 + 6).size(200, 20); - final boolean missingAccount = ViaFabricPlusImpl.INSTANCE.getSaveManager().getAccountsSave().getBedrockAccount() == null; // Only check for presence, later validate + final boolean missingAccount = SaveManager.INSTANCE.getAccountsSave().getBedrockAccount() == null; // Only check for presence, later validate if (missingAccount) { bedrockRealmsBuilder.tooltip(Tooltip.of(Text.translatable("bedrock_realms.viafabricplus.warning"))); } diff --git a/src/main/java/com/viaversion/viafabricplus/screen/classic4j/BetaCraftScreen.java b/src/main/java/com/viaversion/viafabricplus/screen/impl/classic4j/BetaCraftScreen.java similarity index 94% rename from src/main/java/com/viaversion/viafabricplus/screen/classic4j/BetaCraftScreen.java rename to src/main/java/com/viaversion/viafabricplus/screen/impl/classic4j/BetaCraftScreen.java index fdcac43be..c4b13b237 100644 --- a/src/main/java/com/viaversion/viafabricplus/screen/classic4j/BetaCraftScreen.java +++ b/src/main/java/com/viaversion/viafabricplus/screen/impl/classic4j/BetaCraftScreen.java @@ -19,16 +19,16 @@ * along with this program. If not, see . */ -package com.viaversion.viafabricplus.screen.classic4j; +package com.viaversion.viafabricplus.screen.impl.classic4j; -import com.viaversion.viafabricplus.base.screen.VFPList; -import com.viaversion.viafabricplus.base.screen.VFPListEntry; -import com.viaversion.viafabricplus.base.screen.VFPScreen; +import com.viaversion.viafabricplus.screen.VFPList; +import com.viaversion.viafabricplus.screen.VFPListEntry; +import com.viaversion.viafabricplus.screen.VFPScreen; import de.florianmichael.classic4j.BetaCraftHandler; import de.florianmichael.classic4j.model.betacraft.BCServerInfoSpec; import de.florianmichael.classic4j.model.betacraft.BCServerList; import de.florianmichael.classic4j.model.betacraft.BCVersionCategory; -import com.viaversion.viafabricplus.screen.settings.TitleRenderer; +import com.viaversion.viafabricplus.screen.impl.settings.TitleRenderer; import com.viaversion.viafabricplus.util.ConnectionUtil; import net.minecraft.client.MinecraftClient; import net.minecraft.client.font.TextRenderer; diff --git a/src/main/java/com/viaversion/viafabricplus/screen/classic4j/ClassiCubeLoginScreen.java b/src/main/java/com/viaversion/viafabricplus/screen/impl/classic4j/ClassiCubeLoginScreen.java similarity index 93% rename from src/main/java/com/viaversion/viafabricplus/screen/classic4j/ClassiCubeLoginScreen.java rename to src/main/java/com/viaversion/viafabricplus/screen/impl/classic4j/ClassiCubeLoginScreen.java index 0d4b78018..6b14309e3 100644 --- a/src/main/java/com/viaversion/viafabricplus/screen/classic4j/ClassiCubeLoginScreen.java +++ b/src/main/java/com/viaversion/viafabricplus/screen/impl/classic4j/ClassiCubeLoginScreen.java @@ -19,15 +19,16 @@ * along with this program. If not, see . */ -package com.viaversion.viafabricplus.screen.classic4j; +package com.viaversion.viafabricplus.screen.impl.classic4j; +import com.viaversion.viafabricplus.save.SaveManager; import de.florianmichael.classic4j.ClassiCubeHandler; import de.florianmichael.classic4j.api.LoginProcessHandler; import de.florianmichael.classic4j.model.classicube.account.CCAccount; import com.viaversion.viafabricplus.ViaFabricPlusImpl; import com.viaversion.viafabricplus.injection.access.base.ITextFieldWidget; import com.viaversion.viafabricplus.save.impl.AccountsSave; -import com.viaversion.viafabricplus.base.screen.VFPScreen; +import com.viaversion.viafabricplus.screen.VFPScreen; import net.minecraft.client.gui.DrawContext; import net.minecraft.client.gui.screen.ConfirmLinkScreen; import net.minecraft.client.gui.widget.ButtonWidget; @@ -63,7 +64,7 @@ protected void init() { ((ITextFieldWidget) nameField).viaFabricPlus$unlockForbiddenCharacters(); ((ITextFieldWidget) passwordField).viaFabricPlus$unlockForbiddenCharacters(); - final AccountsSave accountsSave = ViaFabricPlusImpl.INSTANCE.getSaveManager().getAccountsSave(); + final AccountsSave accountsSave = SaveManager.INSTANCE.getAccountsSave(); if (accountsSave.getClassicubeAccount() != null) { nameField.setText(accountsSave.getClassicubeAccount().username()); passwordField.setText(accountsSave.getClassicubeAccount().username()); @@ -97,7 +98,7 @@ public void handleException(Throwable throwable) { @Override public void close() { // The user wasn't logged in when opening this screen, so he cancelled the login process, so we can safely unset the account - ViaFabricPlusImpl.INSTANCE.getSaveManager().getAccountsSave().setClassicubeAccount(null); + SaveManager.INSTANCE.getAccountsSave().setClassicubeAccount(null); super.close(); } diff --git a/src/main/java/com/viaversion/viafabricplus/screen/classic4j/ClassiCubeMFAScreen.java b/src/main/java/com/viaversion/viafabricplus/screen/impl/classic4j/ClassiCubeMFAScreen.java similarity index 89% rename from src/main/java/com/viaversion/viafabricplus/screen/classic4j/ClassiCubeMFAScreen.java rename to src/main/java/com/viaversion/viafabricplus/screen/impl/classic4j/ClassiCubeMFAScreen.java index 25f474527..f91f4ec3e 100644 --- a/src/main/java/com/viaversion/viafabricplus/screen/classic4j/ClassiCubeMFAScreen.java +++ b/src/main/java/com/viaversion/viafabricplus/screen/impl/classic4j/ClassiCubeMFAScreen.java @@ -19,14 +19,15 @@ * along with this program. If not, see . */ -package com.viaversion.viafabricplus.screen.classic4j; +package com.viaversion.viafabricplus.screen.impl.classic4j; +import com.viaversion.viafabricplus.save.SaveManager; import de.florianmichael.classic4j.ClassiCubeHandler; import de.florianmichael.classic4j.api.LoginProcessHandler; import de.florianmichael.classic4j.model.classicube.account.CCAccount; import com.viaversion.viafabricplus.ViaFabricPlusImpl; -import com.viaversion.viafabricplus.base.screen.VFPScreen; -import com.viaversion.viafabricplus.screen.ProtocolSelectionScreen; +import com.viaversion.viafabricplus.screen.VFPScreen; +import com.viaversion.viafabricplus.screen.impl.ProtocolSelectionScreen; import net.minecraft.client.gui.DrawContext; import net.minecraft.client.gui.widget.ButtonWidget; import net.minecraft.client.gui.widget.TextFieldWidget; @@ -53,7 +54,7 @@ protected void init() { this.addDrawableChild(ButtonWidget.builder(Text.translatable("base.viafabricplus.login"), button -> { this.setupSubtitle(Text.translatable("classicube.viafabricplus.loading")); - final CCAccount account = ViaFabricPlusImpl.INSTANCE.getSaveManager().getAccountsSave().getClassicubeAccount(); + final CCAccount account = SaveManager.INSTANCE.getAccountsSave().getClassicubeAccount(); ClassiCubeHandler.requestAuthentication(account, mfaField.getText(), new LoginProcessHandler() { @Override @@ -77,7 +78,7 @@ public void handleException(Throwable throwable) { @Override public void close() { // The user wasn't logged in when opening this screen, so he cancelled the login process, so we can safely unset the account - ViaFabricPlusImpl.INSTANCE.getSaveManager().getAccountsSave().setClassicubeAccount(null); + SaveManager.INSTANCE.getAccountsSave().setClassicubeAccount(null); ProtocolSelectionScreen.INSTANCE.open(prevScreen); } diff --git a/src/main/java/com/viaversion/viafabricplus/screen/classic4j/ClassiCubeServerListScreen.java b/src/main/java/com/viaversion/viafabricplus/screen/impl/classic4j/ClassiCubeServerListScreen.java similarity index 89% rename from src/main/java/com/viaversion/viafabricplus/screen/classic4j/ClassiCubeServerListScreen.java rename to src/main/java/com/viaversion/viafabricplus/screen/impl/classic4j/ClassiCubeServerListScreen.java index 26bbb15ab..7d505e150 100644 --- a/src/main/java/com/viaversion/viafabricplus/screen/classic4j/ClassiCubeServerListScreen.java +++ b/src/main/java/com/viaversion/viafabricplus/screen/impl/classic4j/ClassiCubeServerListScreen.java @@ -19,17 +19,18 @@ * along with this program. If not, see . */ -package com.viaversion.viafabricplus.screen.classic4j; +package com.viaversion.viafabricplus.screen.impl.classic4j; +import com.viaversion.viafabricplus.save.SaveManager; import de.florianmichael.classic4j.ClassiCubeHandler; import de.florianmichael.classic4j.api.LoginProcessHandler; import de.florianmichael.classic4j.model.classicube.account.CCAccount; import de.florianmichael.classic4j.model.classicube.server.CCServerInfo; import com.viaversion.viafabricplus.ViaFabricPlusImpl; import com.viaversion.viafabricplus.protocoltranslator.impl.provider.vialegacy.ViaFabricPlusClassicMPPassProvider; -import com.viaversion.viafabricplus.base.screen.VFPList; -import com.viaversion.viafabricplus.base.screen.VFPListEntry; -import com.viaversion.viafabricplus.base.screen.VFPScreen; +import com.viaversion.viafabricplus.screen.VFPList; +import com.viaversion.viafabricplus.screen.VFPListEntry; +import com.viaversion.viafabricplus.screen.VFPScreen; import com.viaversion.viafabricplus.settings.impl.AuthenticationSettings; import com.viaversion.viafabricplus.util.ConnectionUtil; import net.minecraft.client.MinecraftClient; @@ -52,7 +53,7 @@ public final class ClassiCubeServerListScreen extends VFPScreen { private static final String CLASSICUBE_SERVER_LIST_URL = "https://www.classicube.net/server/list/"; public static void open(final Screen prevScreen, final LoginProcessHandler loginProcessHandler) { - final CCAccount account = ViaFabricPlusImpl.INSTANCE.getSaveManager().getAccountsSave().getClassicubeAccount(); + final CCAccount account = SaveManager.INSTANCE.getAccountsSave().getClassicubeAccount(); ClassiCubeHandler.requestServerList(account, serverList -> { ClassiCubeServerListScreen.SERVER_LIST.addAll(serverList.servers()); @@ -66,7 +67,7 @@ public ClassiCubeServerListScreen() { @Override protected void init() { - final CCAccount account = ViaFabricPlusImpl.INSTANCE.getSaveManager().getAccountsSave().getClassicubeAccount(); + final CCAccount account = SaveManager.INSTANCE.getAccountsSave().getClassicubeAccount(); if (account != null) { this.setupUrlSubtitle(CLASSICUBE_SERVER_LIST_URL); } @@ -75,7 +76,7 @@ protected void init() { this.addDrawableChild(ButtonWidget.builder(Text.translatable("base.viafabricplus.logout"), button -> { close(); - ViaFabricPlusImpl.INSTANCE.getSaveManager().getAccountsSave().setClassicubeAccount(null); + SaveManager.INSTANCE.getAccountsSave().setClassicubeAccount(null); SERVER_LIST.clear(); }).position(width - 60 - 5, 5).size(60, 20).build()); @@ -86,7 +87,7 @@ protected void init() { public void render(DrawContext context, int mouseX, int mouseY, float delta) { super.render(context, mouseX, mouseY, delta); - final CCAccount account = ViaFabricPlusImpl.INSTANCE.getSaveManager().getAccountsSave().getClassicubeAccount(); + final CCAccount account = SaveManager.INSTANCE.getAccountsSave().getClassicubeAccount(); if (account != null) { context.drawTextWithShadow(textRenderer, Text.translatable("classicube.viafabricplus.profile"), 32, 6, -1); context.drawTextWithShadow(textRenderer, Text.of(account.username()), 32, 16, -1); diff --git a/src/main/java/com/viaversion/viafabricplus/screen/realms/AcceptInvitationCodeScreen.java b/src/main/java/com/viaversion/viafabricplus/screen/impl/realms/AcceptInvitationCodeScreen.java similarity index 95% rename from src/main/java/com/viaversion/viafabricplus/screen/realms/AcceptInvitationCodeScreen.java rename to src/main/java/com/viaversion/viafabricplus/screen/impl/realms/AcceptInvitationCodeScreen.java index f223a1cbd..27f915b4d 100644 --- a/src/main/java/com/viaversion/viafabricplus/screen/realms/AcceptInvitationCodeScreen.java +++ b/src/main/java/com/viaversion/viafabricplus/screen/impl/realms/AcceptInvitationCodeScreen.java @@ -19,9 +19,9 @@ * along with this program. If not, see . */ -package com.viaversion.viafabricplus.screen.realms; +package com.viaversion.viafabricplus.screen.impl.realms; -import com.viaversion.viafabricplus.base.screen.VFPScreen; +import com.viaversion.viafabricplus.screen.VFPScreen; import net.minecraft.client.gui.widget.ButtonWidget; import net.minecraft.client.gui.widget.TextFieldWidget; import net.minecraft.text.Text; diff --git a/src/main/java/com/viaversion/viafabricplus/screen/realms/BedrockRealmsScreen.java b/src/main/java/com/viaversion/viafabricplus/screen/impl/realms/BedrockRealmsScreen.java similarity index 96% rename from src/main/java/com/viaversion/viafabricplus/screen/realms/BedrockRealmsScreen.java rename to src/main/java/com/viaversion/viafabricplus/screen/impl/realms/BedrockRealmsScreen.java index 753edf1d9..164cd99b3 100644 --- a/src/main/java/com/viaversion/viafabricplus/screen/realms/BedrockRealmsScreen.java +++ b/src/main/java/com/viaversion/viafabricplus/screen/impl/realms/BedrockRealmsScreen.java @@ -19,12 +19,13 @@ * along with this program. If not, see . */ -package com.viaversion.viafabricplus.screen.realms; +package com.viaversion.viafabricplus.screen.impl.realms; import com.viaversion.viafabricplus.ViaFabricPlusImpl; -import com.viaversion.viafabricplus.base.screen.VFPList; -import com.viaversion.viafabricplus.base.screen.VFPListEntry; -import com.viaversion.viafabricplus.base.screen.VFPScreen; +import com.viaversion.viafabricplus.save.SaveManager; +import com.viaversion.viafabricplus.screen.VFPList; +import com.viaversion.viafabricplus.screen.VFPListEntry; +import com.viaversion.viafabricplus.screen.VFPScreen; import com.viaversion.viafabricplus.util.ConnectionUtil; import net.minecraft.client.MinecraftClient; import net.minecraft.client.font.TextRenderer; @@ -72,7 +73,7 @@ protected void init() { } private void loadRealms() { - final StepFullBedrockSession.FullBedrockSession account = ViaFabricPlusImpl.INSTANCE.getSaveManager().getAccountsSave().refreshAndGetBedrockAccount(); + final StepFullBedrockSession.FullBedrockSession account = SaveManager.INSTANCE.getAccountsSave().refreshAndGetBedrockAccount(); if (account == null) { // Just in case... setupSubtitle(Text.translatable("bedrock_realms.viafabricplus.warning")); return; diff --git a/src/main/java/com/viaversion/viafabricplus/screen/settings/BooleanSettingRenderer.java b/src/main/java/com/viaversion/viafabricplus/screen/impl/settings/BooleanSettingRenderer.java similarity index 84% rename from src/main/java/com/viaversion/viafabricplus/screen/settings/BooleanSettingRenderer.java rename to src/main/java/com/viaversion/viafabricplus/screen/impl/settings/BooleanSettingRenderer.java index 2c2be1413..a0071730b 100644 --- a/src/main/java/com/viaversion/viafabricplus/screen/settings/BooleanSettingRenderer.java +++ b/src/main/java/com/viaversion/viafabricplus/screen/impl/settings/BooleanSettingRenderer.java @@ -19,13 +19,14 @@ * along with this program. If not, see . */ -package com.viaversion.viafabricplus.screen.settings; +package com.viaversion.viafabricplus.screen.impl.settings; -import com.viaversion.viafabricplus.base.screen.VFPListEntry; -import com.viaversion.viafabricplus.settings.base.BooleanSetting; +import com.viaversion.viafabricplus.screen.VFPListEntry; +import com.viaversion.viafabricplus.api.settings.type.BooleanSetting; import net.minecraft.client.MinecraftClient; import net.minecraft.client.font.TextRenderer; import net.minecraft.client.gui.DrawContext; +import net.minecraft.text.MutableText; import net.minecraft.text.Text; import net.minecraft.util.Formatting; @@ -33,14 +34,16 @@ public final class BooleanSettingRenderer extends VFPListEntry { private final BooleanSetting value; + private final MutableText name; public BooleanSettingRenderer(BooleanSetting value) { this.value = value; + this.name = Text.translatable(value.getTranslationKey()); } @Override public Text getNarration() { - return this.value.getName(); + return this.name; } @Override @@ -55,7 +58,7 @@ public void mappedRender(DrawContext context, int index, int y, int x, int entry final Text text = this.value.getValue() ? Text.translatable("base.viafabricplus.on") : Text.translatable("base.viafabricplus.off"); final int offset = textRenderer.getWidth(text) + 6; - renderScrollableText(this.value.getName().formatted(Formatting.GRAY), offset); + renderScrollableText(this.name.formatted(Formatting.GRAY), offset); context.drawTextWithShadow(textRenderer, text, entryWidth - offset, entryHeight / 2 - textRenderer.fontHeight / 2, this.value.getValue() ? Color.GREEN.getRGB() : Color.RED.getRGB()); renderTooltip(value.getTooltip(), mouseX, mouseY); diff --git a/src/main/java/com/viaversion/viafabricplus/screen/settings/ButtonSettingRenderer.java b/src/main/java/com/viaversion/viafabricplus/screen/impl/settings/ButtonSettingRenderer.java similarity index 74% rename from src/main/java/com/viaversion/viafabricplus/screen/settings/ButtonSettingRenderer.java rename to src/main/java/com/viaversion/viafabricplus/screen/impl/settings/ButtonSettingRenderer.java index fdd170475..5bb2e0a1d 100644 --- a/src/main/java/com/viaversion/viafabricplus/screen/settings/ButtonSettingRenderer.java +++ b/src/main/java/com/viaversion/viafabricplus/screen/impl/settings/ButtonSettingRenderer.java @@ -19,26 +19,34 @@ * along with this program. If not, see . */ -package com.viaversion.viafabricplus.screen.settings; +package com.viaversion.viafabricplus.screen.impl.settings; -import com.viaversion.viafabricplus.base.screen.VFPListEntry; -import com.viaversion.viafabricplus.settings.base.ButtonSetting; +import com.viaversion.viafabricplus.screen.VFPListEntry; +import com.viaversion.viafabricplus.api.settings.type.ButtonSetting; import net.minecraft.client.MinecraftClient; import net.minecraft.client.font.TextRenderer; import net.minecraft.client.gui.DrawContext; +import net.minecraft.text.MutableText; import net.minecraft.text.Text; public final class ButtonSettingRenderer extends VFPListEntry { private final ButtonSetting value; + private final MutableText name; public ButtonSettingRenderer(ButtonSetting value) { this.value = value; + + if (value.displayString() == null) { + this.name = Text.translatable(value.getTranslationKey()); + } else { + this.name = Text.literal(value.displayString()); + } } @Override public Text getNarration() { - return this.value.getName(); + return this.name; } @Override @@ -50,7 +58,7 @@ public void mappedMouseClicked(double mouseX, double mouseY, int button) { public void mappedRender(DrawContext context, int index, int y, int x, int entryWidth, int entryHeight, int mouseX, int mouseY, boolean hovered, float tickDelta) { final TextRenderer textRenderer = MinecraftClient.getInstance().textRenderer; - context.drawCenteredTextWithShadow(textRenderer, this.value.displayValue(), entryWidth / 2, entryHeight / 2 - textRenderer.fontHeight / 2, -1); + context.drawCenteredTextWithShadow(textRenderer, this.name, entryWidth / 2, entryHeight / 2 - textRenderer.fontHeight / 2, -1); renderTooltip(value.getTooltip(), mouseX, mouseY); } diff --git a/src/main/java/com/viaversion/viafabricplus/screen/settings/ModeSettingRenderer.java b/src/main/java/com/viaversion/viafabricplus/screen/impl/settings/ModeSettingRenderer.java similarity index 75% rename from src/main/java/com/viaversion/viafabricplus/screen/settings/ModeSettingRenderer.java rename to src/main/java/com/viaversion/viafabricplus/screen/impl/settings/ModeSettingRenderer.java index d20b4caf0..f8c1286b7 100644 --- a/src/main/java/com/viaversion/viafabricplus/screen/settings/ModeSettingRenderer.java +++ b/src/main/java/com/viaversion/viafabricplus/screen/impl/settings/ModeSettingRenderer.java @@ -19,13 +19,14 @@ * along with this program. If not, see . */ -package com.viaversion.viafabricplus.screen.settings; +package com.viaversion.viafabricplus.screen.impl.settings; -import com.viaversion.viafabricplus.base.screen.VFPListEntry; -import com.viaversion.viafabricplus.settings.base.ModeSetting; +import com.viaversion.viafabricplus.screen.VFPListEntry; +import com.viaversion.viafabricplus.api.settings.type.ModeSetting; import net.minecraft.client.MinecraftClient; import net.minecraft.client.font.TextRenderer; import net.minecraft.client.gui.DrawContext; +import net.minecraft.text.MutableText; import net.minecraft.text.Text; import net.minecraft.util.Formatting; @@ -33,14 +34,16 @@ public final class ModeSettingRenderer extends VFPListEntry { private final ModeSetting value; + private final MutableText name; public ModeSettingRenderer(ModeSetting value) { this.value = value; + this.name = Text.translatable(value.getTranslationKey()); } @Override public Text getNarration() { - return this.value.getName(); + return this.name; } @Override @@ -53,9 +56,11 @@ public void mappedMouseClicked(double mouseX, double mouseY, int button) { public void mappedRender(DrawContext context, int index, int y, int x, int entryWidth, int entryHeight, int mouseX, int mouseY, boolean hovered, float tickDelta) { final TextRenderer textRenderer = MinecraftClient.getInstance().textRenderer; - final int offset = textRenderer.getWidth(this.value.getValue()) + 6; - renderScrollableText(this.value.getName().formatted(Formatting.GRAY), offset); - context.drawTextWithShadow(textRenderer, this.value.getValue(), entryWidth - offset, entryHeight / 2 - textRenderer.fontHeight / 2, -1); + final Text name = Text.translatable(this.value.getValue()); + + final int offset = textRenderer.getWidth(name) + 6; + renderScrollableText(this.name.formatted(Formatting.GRAY), offset); + context.drawTextWithShadow(textRenderer, name, entryWidth - offset, entryHeight / 2 - textRenderer.fontHeight / 2, -1); renderTooltip(value.getTooltip(), mouseX, mouseY); } diff --git a/src/main/java/com/viaversion/viafabricplus/screen/settings/SettingsScreen.java b/src/main/java/com/viaversion/viafabricplus/screen/impl/settings/SettingsScreen.java similarity index 60% rename from src/main/java/com/viaversion/viafabricplus/screen/settings/SettingsScreen.java rename to src/main/java/com/viaversion/viafabricplus/screen/impl/settings/SettingsScreen.java index 0ef677dff..5131aab14 100644 --- a/src/main/java/com/viaversion/viafabricplus/screen/settings/SettingsScreen.java +++ b/src/main/java/com/viaversion/viafabricplus/screen/impl/settings/SettingsScreen.java @@ -19,13 +19,18 @@ * along with this program. If not, see . */ -package com.viaversion.viafabricplus.screen.settings; +package com.viaversion.viafabricplus.screen.impl.settings; import com.viaversion.viafabricplus.ViaFabricPlusImpl; -import com.viaversion.viafabricplus.base.screen.VFPList; -import com.viaversion.viafabricplus.base.screen.VFPScreen; -import com.viaversion.viafabricplus.settings.base.AbstractSetting; -import com.viaversion.viafabricplus.settings.base.SettingGroup; +import com.viaversion.viafabricplus.api.settings.type.BooleanSetting; +import com.viaversion.viafabricplus.api.settings.type.ButtonSetting; +import com.viaversion.viafabricplus.api.settings.type.ModeSetting; +import com.viaversion.viafabricplus.api.settings.type.VersionedBooleanSetting; +import com.viaversion.viafabricplus.screen.VFPList; +import com.viaversion.viafabricplus.screen.VFPScreen; +import com.viaversion.viafabricplus.api.settings.AbstractSetting; +import com.viaversion.viafabricplus.api.settings.SettingGroup; +import com.viaversion.viafabricplus.settings.SettingsManager; import net.minecraft.client.MinecraftClient; import net.minecraft.text.Text; @@ -51,11 +56,17 @@ public static class SlotList extends VFPList { public SlotList(MinecraftClient minecraftClient, int width, int height, int top, int bottom, int entryHeight) { super(minecraftClient, width, height, top, bottom, entryHeight); - for (SettingGroup group : ViaFabricPlusImpl.INSTANCE.getSettingsManager().getGroups()) { - this.addEntry(new TitleRenderer(group.getName())); + for (SettingGroup group : SettingsManager.INSTANCE.getGroups()) { + this.addEntry(new TitleRenderer(Text.translatable(group.getTranslationKey()))); for (AbstractSetting setting : group.getSettings()) { - this.addEntry(setting.makeSettingRenderer()); + switch (setting) { + case final BooleanSetting booleanSetting -> this.addEntry(new BooleanSettingRenderer(booleanSetting)); + case final ButtonSetting buttonSetting -> this.addEntry(new ButtonSettingRenderer(buttonSetting)); + case final ModeSetting modeSetting -> this.addEntry(new ModeSettingRenderer(modeSetting)); + case final VersionedBooleanSetting versionedBooleanSetting -> this.addEntry(new VersionedBooleanSettingRenderer(versionedBooleanSetting)); + case null, default -> ViaFabricPlusImpl.INSTANCE.logger().warn("Unknown setting type: " + setting.getClass().getName()); + } } } initScrollY(scrollAmount); diff --git a/src/main/java/com/viaversion/viafabricplus/screen/settings/TitleRenderer.java b/src/main/java/com/viaversion/viafabricplus/screen/impl/settings/TitleRenderer.java similarity index 95% rename from src/main/java/com/viaversion/viafabricplus/screen/settings/TitleRenderer.java rename to src/main/java/com/viaversion/viafabricplus/screen/impl/settings/TitleRenderer.java index 97e038b49..ddef83208 100644 --- a/src/main/java/com/viaversion/viafabricplus/screen/settings/TitleRenderer.java +++ b/src/main/java/com/viaversion/viafabricplus/screen/impl/settings/TitleRenderer.java @@ -19,9 +19,9 @@ * along with this program. If not, see . */ -package com.viaversion.viafabricplus.screen.settings; +package com.viaversion.viafabricplus.screen.impl.settings; -import com.viaversion.viafabricplus.base.screen.VFPListEntry; +import com.viaversion.viafabricplus.screen.VFPListEntry; import net.minecraft.client.MinecraftClient; import net.minecraft.client.font.TextRenderer; import net.minecraft.client.gui.DrawContext; diff --git a/src/main/java/com/viaversion/viafabricplus/screen/settings/VersionedBooleanSettingRenderer.java b/src/main/java/com/viaversion/viafabricplus/screen/impl/settings/VersionedBooleanSettingRenderer.java similarity index 82% rename from src/main/java/com/viaversion/viafabricplus/screen/settings/VersionedBooleanSettingRenderer.java rename to src/main/java/com/viaversion/viafabricplus/screen/impl/settings/VersionedBooleanSettingRenderer.java index befa930e1..c6a8cf819 100644 --- a/src/main/java/com/viaversion/viafabricplus/screen/settings/VersionedBooleanSettingRenderer.java +++ b/src/main/java/com/viaversion/viafabricplus/screen/impl/settings/VersionedBooleanSettingRenderer.java @@ -19,13 +19,14 @@ * along with this program. If not, see . */ -package com.viaversion.viafabricplus.screen.settings; +package com.viaversion.viafabricplus.screen.impl.settings; -import com.viaversion.viafabricplus.base.screen.VFPListEntry; -import com.viaversion.viafabricplus.settings.base.VersionedBooleanSetting; +import com.viaversion.viafabricplus.screen.VFPListEntry; +import com.viaversion.viafabricplus.api.settings.type.VersionedBooleanSetting; import net.minecraft.client.MinecraftClient; import net.minecraft.client.font.TextRenderer; import net.minecraft.client.gui.DrawContext; +import net.minecraft.text.MutableText; import net.minecraft.text.Text; import net.minecraft.util.Formatting; @@ -33,14 +34,16 @@ public final class VersionedBooleanSettingRenderer extends VFPListEntry { private final VersionedBooleanSetting value; + private final MutableText name; public VersionedBooleanSettingRenderer(VersionedBooleanSetting value) { this.value = value; + this.name = Text.translatable(value.getTranslationKey()); } @Override public Text getNarration() { - return this.value.getName(); + return this.name; } @Override @@ -57,7 +60,7 @@ public void mappedRender(DrawContext context, int index, int y, int x, int entry Color color = this.value.isAuto() ? Color.ORANGE : this.value.isEnabled() ? Color.GREEN : Color.RED; final int offset = textRenderer.getWidth(text) + 6; - renderScrollableText(Text.of(Formatting.GRAY + this.value.getName().getString() + " " + Formatting.RESET + this.value.getProtocolRange().toString()), offset); + renderScrollableText(Text.of(Formatting.GRAY + this.name.getString() + " " + Formatting.RESET + this.value.getProtocolRange().toString()), offset); context.drawTextWithShadow(textRenderer, text, entryWidth - offset, entryHeight / 2 - textRenderer.fontHeight / 2, color.getRGB()); renderTooltip(value.getTooltip(), mouseX, mouseY); diff --git a/src/main/java/com/viaversion/viafabricplus/settings/SettingsManager.java b/src/main/java/com/viaversion/viafabricplus/settings/SettingsManager.java index 7ecb2a73b..254b0cf9d 100644 --- a/src/main/java/com/viaversion/viafabricplus/settings/SettingsManager.java +++ b/src/main/java/com/viaversion/viafabricplus/settings/SettingsManager.java @@ -21,9 +21,9 @@ package com.viaversion.viafabricplus.settings; -import com.viaversion.viafabricplus.api.LoadingCycleCallback; +import com.viaversion.viafabricplus.api.events.LoadingCycleCallback; import com.viaversion.viafabricplus.base.Events; -import com.viaversion.viafabricplus.settings.base.SettingGroup; +import com.viaversion.viafabricplus.api.settings.SettingGroup; import com.viaversion.viafabricplus.settings.impl.*; import java.util.ArrayList; @@ -32,9 +32,11 @@ public final class SettingsManager { + public static final SettingsManager INSTANCE = new SettingsManager(); + private final List groups = new ArrayList<>(); - public SettingsManager() { + public void init() { Events.LOADING_CYCLE.invoker().onLoadCycle(LoadingCycleCallback.LoadingCycle.PRE_SETTINGS_LOAD); addGroup( diff --git a/src/main/java/com/viaversion/viafabricplus/settings/impl/AuthenticationSettings.java b/src/main/java/com/viaversion/viafabricplus/settings/impl/AuthenticationSettings.java index 76fc78718..082122400 100644 --- a/src/main/java/com/viaversion/viafabricplus/settings/impl/AuthenticationSettings.java +++ b/src/main/java/com/viaversion/viafabricplus/settings/impl/AuthenticationSettings.java @@ -21,21 +21,21 @@ package com.viaversion.viafabricplus.settings.impl; -import com.viaversion.viafabricplus.settings.base.BooleanSetting; -import com.viaversion.viafabricplus.settings.base.SettingGroup; +import com.viaversion.viafabricplus.api.settings.type.BooleanSetting; +import com.viaversion.viafabricplus.api.settings.SettingGroup; import net.minecraft.text.Text; public final class AuthenticationSettings extends SettingGroup { public static final AuthenticationSettings INSTANCE = new AuthenticationSettings(); - public final BooleanSetting useBetaCraftAuthentication = new BooleanSetting(this, Text.translatable("authentication_settings.viafabricplus.use_beta_craft_authentication"), true); - public final BooleanSetting verifySessionForOnlineModeServers = new BooleanSetting(this, Text.translatable("authentication_settings.viafabricplus.verify_session_for_online_mode"), true); - public final BooleanSetting automaticallySelectCPEInClassiCubeServerList = new BooleanSetting(this, Text.translatable("authentication_settings.viafabricplus.automatically_select_cpe_when_using_classicube"), true); - public final BooleanSetting setSessionNameToClassiCubeNameInServerList = new BooleanSetting(this, Text.translatable("authentication_settings.viafabricplus.set_session_name_to_classicube_name"), true); + public final BooleanSetting useBetaCraftAuthentication = new BooleanSetting(this, "authentication_settings.viafabricplus.use_beta_craft_authentication", true); + public final BooleanSetting verifySessionForOnlineModeServers = new BooleanSetting(this, "authentication_settings.viafabricplus.verify_session_for_online_mode", true); + public final BooleanSetting automaticallySelectCPEInClassiCubeServerList = new BooleanSetting(this, "authentication_settings.viafabricplus.automatically_select_cpe_when_using_classicube", true); + public final BooleanSetting setSessionNameToClassiCubeNameInServerList = new BooleanSetting(this, "authentication_settings.viafabricplus.set_session_name_to_classicube_name", true); public AuthenticationSettings() { - super(Text.translatable("setting_group_name.viafabricplus.authentication")); + super("setting_group_name.viafabricplus.authentication"); } } diff --git a/src/main/java/com/viaversion/viafabricplus/settings/impl/BedrockSettings.java b/src/main/java/com/viaversion/viafabricplus/settings/impl/BedrockSettings.java index b166b7d15..ff6eb21ea 100644 --- a/src/main/java/com/viaversion/viafabricplus/settings/impl/BedrockSettings.java +++ b/src/main/java/com/viaversion/viafabricplus/settings/impl/BedrockSettings.java @@ -21,17 +21,18 @@ package com.viaversion.viafabricplus.settings.impl; -import com.viaversion.viafabricplus.ViaFabricPlusImpl; import com.viaversion.viafabricplus.injection.access.base.bedrock.IConfirmScreen; +import com.viaversion.viafabricplus.save.SaveManager; import com.viaversion.viafabricplus.save.impl.AccountsSave; -import com.viaversion.viafabricplus.base.screen.VFPScreen; -import com.viaversion.viafabricplus.settings.base.BooleanSetting; -import com.viaversion.viafabricplus.settings.base.ButtonSetting; -import com.viaversion.viafabricplus.settings.base.SettingGroup; +import com.viaversion.viafabricplus.screen.VFPScreen; +import com.viaversion.viafabricplus.api.settings.type.BooleanSetting; +import com.viaversion.viafabricplus.api.settings.type.ButtonSetting; +import com.viaversion.viafabricplus.api.settings.SettingGroup; import com.viaversion.viaversion.api.protocol.version.ProtocolVersion; import net.minecraft.client.MinecraftClient; import net.minecraft.client.gui.screen.ConfirmScreen; import net.minecraft.client.gui.screen.Screen; +import net.minecraft.client.resource.language.I18n; import net.minecraft.text.MutableText; import net.minecraft.text.Text; import net.minecraft.util.Util; @@ -63,22 +64,22 @@ public final class BedrockSettings extends SettingGroup { .buildMinecraftBedrockChainStep(true, true); private Thread thread; - private final ButtonSetting clickToSetBedrockAccount = new ButtonSetting(this, Text.translatable("bedrock_settings.viafabricplus.click_to_set_bedrock_account"), () -> { + private final ButtonSetting clickToSetBedrockAccount = new ButtonSetting(this, "bedrock_settings.viafabricplus.click_to_set_bedrock_account", () -> { thread = new Thread(this::openBedrockAccountLogin); thread.start(); }) { @Override - public MutableText displayValue() { - final StepFullBedrockSession.FullBedrockSession account = ViaFabricPlusImpl.INSTANCE.getSaveManager().getAccountsSave().getBedrockAccount(); + public String displayString() { + final StepFullBedrockSession.FullBedrockSession account = SaveManager.INSTANCE.getAccountsSave().getBedrockAccount(); if (account != null) { - return Text.translatable("click_to_set_bedrock_account.viafabricplus.display", account.getMcChain().getDisplayName()); + return I18n.translate("click_to_set_bedrock_account.viafabricplus.display", account.getMcChain().getDisplayName()); } else { - return super.displayValue(); + return null; } } }; - public final BooleanSetting replaceDefaultPort = new BooleanSetting(this, Text.translatable("bedrock_settings.viafabricplus.replace_default_port"), true); + public final BooleanSetting replaceDefaultPort = new BooleanSetting(this, "bedrock_settings.viafabricplus.replace_default_port", true); private final ILogger GUI_LOGGER = new ConsoleLogger() { @Override @@ -96,11 +97,11 @@ public void info(AbstractStep step, String message) { }; public BedrockSettings() { - super(Text.translatable("setting_group_name.viafabricplus.bedrock")); + super("setting_group_name.viafabricplus.bedrock"); } private void openBedrockAccountLogin() { - final AccountsSave accountsSave = ViaFabricPlusImpl.INSTANCE.getSaveManager().getAccountsSave(); + final AccountsSave accountsSave = SaveManager.INSTANCE.getAccountsSave(); final MinecraftClient client = MinecraftClient.getInstance(); final Screen prevScreen = client.currentScreen; diff --git a/src/main/java/com/viaversion/viafabricplus/settings/impl/DebugSettings.java b/src/main/java/com/viaversion/viafabricplus/settings/impl/DebugSettings.java index 951cdd4ed..e8a7a3bad 100644 --- a/src/main/java/com/viaversion/viafabricplus/settings/impl/DebugSettings.java +++ b/src/main/java/com/viaversion/viafabricplus/settings/impl/DebugSettings.java @@ -22,10 +22,9 @@ package com.viaversion.viafabricplus.settings.impl; import com.viaversion.viaversion.api.protocol.version.ProtocolVersion; -import com.viaversion.viafabricplus.settings.base.BooleanSetting; -import com.viaversion.viafabricplus.settings.base.SettingGroup; -import com.viaversion.viafabricplus.settings.base.VersionedBooleanSetting; -import net.minecraft.text.Text; +import com.viaversion.viafabricplus.api.settings.type.BooleanSetting; +import com.viaversion.viafabricplus.api.settings.SettingGroup; +import com.viaversion.viafabricplus.api.settings.type.VersionedBooleanSetting; import net.raphimc.vialegacy.api.LegacyProtocolVersion; import net.raphimc.vialoader.util.VersionRange; @@ -33,37 +32,37 @@ public final class DebugSettings extends SettingGroup { public static final DebugSettings INSTANCE = new DebugSettings(); - public final BooleanSetting queueConfigPackets = new BooleanSetting(this, Text.translatable("debug_settings.viafabricplus.queue_config_packets"), true); - public final BooleanSetting printNetworkingErrorsToLogs = new BooleanSetting(this, Text.translatable("debug_settings.viafabricplus.print_networking_errors_to_logs"), true); - public final BooleanSetting ignoreFabricSyncErrors = new BooleanSetting(this, Text.translatable("debug_settings.viafabricplus.ignore_fabric_sync_errors"), false); + public final BooleanSetting queueConfigPackets = new BooleanSetting(this, "debug_settings.viafabricplus.queue_config_packets", true); + public final BooleanSetting printNetworkingErrorsToLogs = new BooleanSetting(this, "debug_settings.viafabricplus.print_networking_errors_to_logs", true); + public final BooleanSetting ignoreFabricSyncErrors = new BooleanSetting(this, "debug_settings.viafabricplus.ignore_fabric_sync_errors", false); // 1.20.5 -> 1.20.4 - public final VersionedBooleanSetting dontCreatePacketErrorCrashReports = new VersionedBooleanSetting(this, Text.translatable("debug_settings.viafabricplus.dont_create_packet_error_crash_reports"), VersionRange.andOlder(ProtocolVersion.v1_20_3)); + public final VersionedBooleanSetting dontCreatePacketErrorCrashReports = new VersionedBooleanSetting(this, "debug_settings.viafabricplus.dont_create_packet_error_crash_reports", VersionRange.andOlder(ProtocolVersion.v1_20_3)); // 1.19 -> 1.18.2 - public final VersionedBooleanSetting disableSequencing = new VersionedBooleanSetting(this, Text.translatable("debug_settings.viafabricplus.disable_sequencing"), VersionRange.andOlder(ProtocolVersion.v1_18_2)); + public final VersionedBooleanSetting disableSequencing = new VersionedBooleanSetting(this, "debug_settings.viafabricplus.disable_sequencing", VersionRange.andOlder(ProtocolVersion.v1_18_2)); // 1.17 -> 1.16.5 - public final VersionedBooleanSetting alwaysTickClientPlayer = new VersionedBooleanSetting(this, Text.translatable("debug_settings.viafabricplus.always_tick_client_player"), VersionRange.andOlder(ProtocolVersion.v1_8).add(VersionRange.andNewer(ProtocolVersion.v1_17))); + public final VersionedBooleanSetting alwaysTickClientPlayer = new VersionedBooleanSetting(this, "debug_settings.viafabricplus.always_tick_client_player", VersionRange.andOlder(ProtocolVersion.v1_8).add(VersionRange.andNewer(ProtocolVersion.v1_17))); // 1.13 -> 1.12.2 - public final VersionedBooleanSetting executeInputsSynchronously = new VersionedBooleanSetting(this, Text.translatable("debug_settings.viafabricplus.execute_inputs_synchronously"), VersionRange.andOlder(ProtocolVersion.v1_12_2)); - public final VersionedBooleanSetting legacyTabCompletions = new VersionedBooleanSetting(this, Text.translatable("debug_settings.viafabricplus.legacy_tab_completions"), VersionRange.andOlder(ProtocolVersion.v1_12_2)); + public final VersionedBooleanSetting executeInputsSynchronously = new VersionedBooleanSetting(this, "debug_settings.viafabricplus.execute_inputs_synchronously", VersionRange.andOlder(ProtocolVersion.v1_12_2)); + public final VersionedBooleanSetting legacyTabCompletions = new VersionedBooleanSetting(this, "debug_settings.viafabricplus.legacy_tab_completions", VersionRange.andOlder(ProtocolVersion.v1_12_2)); // 1.12 -> 1.11.1-1.11.2 @Deprecated/*(forRemoval = true)*/ - public final VersionedBooleanSetting sendOpenInventoryPacket = new VersionedBooleanSetting(this, Text.translatable("debug_settings.viafabricplus.send_open_inventory_packet"), VersionRange.andOlder(ProtocolVersion.v1_11_1)); + public final VersionedBooleanSetting sendOpenInventoryPacket = new VersionedBooleanSetting(this, "debug_settings.viafabricplus.send_open_inventory_packet", VersionRange.andOlder(ProtocolVersion.v1_11_1)); // 1.9 -> 1.8.x @Deprecated/*(forRemoval = true)*/ - public final VersionedBooleanSetting removeCooldowns = new VersionedBooleanSetting(this, Text.translatable("debug_settings.viafabricplus.remove_cooldowns"), VersionRange.andOlder(ProtocolVersion.v1_8)); + public final VersionedBooleanSetting removeCooldowns = new VersionedBooleanSetting(this, "debug_settings.viafabricplus.remove_cooldowns", VersionRange.andOlder(ProtocolVersion.v1_8)); @Deprecated/*(forRemoval = true)*/ - public final VersionedBooleanSetting sendIdlePacket = new VersionedBooleanSetting(this, Text.translatable("debug_settings.viafabricplus.send_idle_packet"), VersionRange.andOlder(LegacyProtocolVersion.r1_2_4tor1_2_5).add(VersionRange.of(LegacyProtocolVersion.r1_4_2, ProtocolVersion.v1_8))); + public final VersionedBooleanSetting sendIdlePacket = new VersionedBooleanSetting(this, "debug_settings.viafabricplus.send_idle_packet", VersionRange.andOlder(LegacyProtocolVersion.r1_2_4tor1_2_5).add(VersionRange.of(LegacyProtocolVersion.r1_4_2, ProtocolVersion.v1_8))); @Deprecated/*(forRemoval = true)*/ - public final VersionedBooleanSetting preventEntityCramming = new VersionedBooleanSetting(this, Text.translatable("debug_settings.viafabricplus.prevent_entity_cramming"), VersionRange.andOlder(ProtocolVersion.v1_8)); + public final VersionedBooleanSetting preventEntityCramming = new VersionedBooleanSetting(this, "debug_settings.viafabricplus.prevent_entity_cramming", VersionRange.andOlder(ProtocolVersion.v1_8)); public DebugSettings() { - super(Text.translatable("setting_group_name.viafabricplus.debug")); + super("setting_group_name.viafabricplus.debug"); } } diff --git a/src/main/java/com/viaversion/viafabricplus/settings/impl/GeneralSettings.java b/src/main/java/com/viaversion/viafabricplus/settings/impl/GeneralSettings.java index f9a7d5bd0..b768feac2 100644 --- a/src/main/java/com/viaversion/viafabricplus/settings/impl/GeneralSettings.java +++ b/src/main/java/com/viaversion/viafabricplus/settings/impl/GeneralSettings.java @@ -21,9 +21,9 @@ package com.viaversion.viafabricplus.settings.impl; -import com.viaversion.viafabricplus.settings.base.BooleanSetting; -import com.viaversion.viafabricplus.settings.base.ModeSetting; -import com.viaversion.viafabricplus.settings.base.SettingGroup; +import com.viaversion.viafabricplus.api.settings.type.BooleanSetting; +import com.viaversion.viafabricplus.api.settings.type.ModeSetting; +import com.viaversion.viafabricplus.api.settings.SettingGroup; import net.minecraft.client.gui.widget.ButtonWidget; import net.minecraft.text.MutableText; import net.minecraft.text.Text; @@ -32,38 +32,38 @@ public final class GeneralSettings extends SettingGroup { public static final GeneralSettings INSTANCE = new GeneralSettings(); - private final MutableText[] ORIENTATION_OPTIONS = new MutableText[] { - Text.translatable("base.viafabricplus.none"), - Text.translatable("base.viafabricplus.left_top"), - Text.translatable("base.viafabricplus.right_top"), - Text.translatable("base.viafabricplus.left_bottom"), - Text.translatable("base.viafabricplus.right_bottom") + private final String[] ORIENTATION_OPTIONS = new String[] { + "base.viafabricplus.none", + "base.viafabricplus.left_top", + "base.viafabricplus.right_top", + "base.viafabricplus.left_bottom", + "base.viafabricplus.right_bottom" }; - public final ModeSetting multiplayerScreenButtonOrientation = new ModeSetting(this, Text.translatable("general_settings.viafabricplus.multiplayer_screen_button_orientation"), 2, ORIENTATION_OPTIONS); - public final ModeSetting addServerScreenButtonOrientation = new ModeSetting(this, Text.translatable("general_settings.viafabricplus.add_server_screen_button_orientation"), 2, ORIENTATION_OPTIONS); - public final ModeSetting directConnectScreenButtonOrientation = new ModeSetting(this, Text.translatable("general_settings.viafabricplus.direct_connect_screen_button_orientation"), 2, ORIENTATION_OPTIONS); - public final ModeSetting removeNotAvailableItemsFromCreativeTab = new ModeSetting(this, Text.translatable("general_settings.viafabricplus.filter_creative_tabs"), - Text.translatable("base.viafabricplus.vanilla_and_modded"), - Text.translatable("base.viafabricplus.vanilla_only"), - Text.translatable("base.viafabricplus.off") + public final ModeSetting multiplayerScreenButtonOrientation = new ModeSetting(this, "general_settings.viafabricplus.multiplayer_screen_button_orientation", 2, ORIENTATION_OPTIONS); + public final ModeSetting addServerScreenButtonOrientation = new ModeSetting(this, "general_settings.viafabricplus.add_server_screen_button_orientation", 2, ORIENTATION_OPTIONS); + public final ModeSetting directConnectScreenButtonOrientation = new ModeSetting(this, "general_settings.viafabricplus.direct_connect_screen_button_orientation", 2, ORIENTATION_OPTIONS); + public final ModeSetting removeNotAvailableItemsFromCreativeTab = new ModeSetting(this, "general_settings.viafabricplus.filter_creative_tabs", + "base.viafabricplus.vanilla_and_modded", + "base.viafabricplus.vanilla_only", + "base.viafabricplus.off" ); - public final BooleanSetting saveSelectedProtocolVersion = new BooleanSetting(this, Text.translatable("general_settings.viafabricplus.save_selected_protocol_version"), true); - public final BooleanSetting showExtraInformationInDebugHud = new BooleanSetting(this, Text.translatable("general_settings.viafabricplus.extra_information_in_debug_hud"), true); - public final BooleanSetting showClassicLoadingProgressInConnectScreen = new BooleanSetting(this, Text.translatable("general_settings.viafabricplus.show_classic_loading_progress"), true); - public final BooleanSetting showAdvertisedServerVersion = new BooleanSetting(this, Text.translatable("general_settings.viafabricplus.show_advertised_server_version"), true); - public final ModeSetting ignorePacketTranslationErrors = new ModeSetting(this, Text.translatable("general_settings.viafabricplus.ignore_packet_translation_errors"), - Text.translatable("base.viafabricplus.kick"), - Text.translatable("base.viafabricplus.cancel_and_notify"), - Text.translatable("base.viafabricplus.cancel") + public final BooleanSetting saveSelectedProtocolVersion = new BooleanSetting(this, "general_settings.viafabricplus.save_selected_protocol_version", true); + public final BooleanSetting showExtraInformationInDebugHud = new BooleanSetting(this, "general_settings.viafabricplus.extra_information_in_debug_hud", true); + public final BooleanSetting showClassicLoadingProgressInConnectScreen = new BooleanSetting(this, "general_settings.viafabricplus.show_classic_loading_progress", true); + public final BooleanSetting showAdvertisedServerVersion = new BooleanSetting(this, "general_settings.viafabricplus.show_advertised_server_version", true); + public final ModeSetting ignorePacketTranslationErrors = new ModeSetting(this, "general_settings.viafabricplus.ignore_packet_translation_errors", + "base.viafabricplus.kick", + "base.viafabricplus.cancel_and_notify", + "base.viafabricplus.cancel" ); - public final BooleanSetting loadSkinsAndSkullsInLegacyVersions = new BooleanSetting(this, Text.translatable("general_settings.viafabricplus.load_skins_and_skulls_in_legacy_versions"), true); - public final BooleanSetting emulateInventoryActionsInAlphaVersions = new BooleanSetting(this, Text.translatable("general_settings.viafabricplus.emulate_inventory_actions_in_alpha_versions"), true); - public final BooleanSetting saveScrollPositionInSlotScreens = new BooleanSetting(this, Text.translatable("general_settings.viafabricplus.save_scroll_position_in_slot_screens"), true); + public final BooleanSetting loadSkinsAndSkullsInLegacyVersions = new BooleanSetting(this, "general_settings.viafabricplus.load_skins_and_skulls_in_legacy_versions", true); + public final BooleanSetting emulateInventoryActionsInAlphaVersions = new BooleanSetting(this, "general_settings.viafabricplus.emulate_inventory_actions_in_alpha_versions", true); + public final BooleanSetting saveScrollPositionInSlotScreens = new BooleanSetting(this, "general_settings.viafabricplus.save_scroll_position_in_slot_screens", true); public GeneralSettings() { - super(Text.translatable("setting_group_name.viafabricplus.general")); - emulateInventoryActionsInAlphaVersions.setTooltip(Text.translatable("base.viafabricplus.this_will_require_a_restart")); + super("setting_group_name.viafabricplus.general"); + emulateInventoryActionsInAlphaVersions.setTooltip("base.viafabricplus.this_will_require_a_restart"); } public static ButtonWidget.Builder withOrientation(final ButtonWidget.Builder builder, final int orientationIndex, final int width, final int height) { diff --git a/src/main/java/com/viaversion/viafabricplus/settings/impl/VisualSettings.java b/src/main/java/com/viaversion/viafabricplus/settings/impl/VisualSettings.java index 4f6f4fd88..ff088ef61 100644 --- a/src/main/java/com/viaversion/viafabricplus/settings/impl/VisualSettings.java +++ b/src/main/java/com/viaversion/viafabricplus/settings/impl/VisualSettings.java @@ -22,10 +22,10 @@ package com.viaversion.viafabricplus.settings.impl; import com.viaversion.viaversion.api.protocol.version.ProtocolVersion; -import com.viaversion.viafabricplus.settings.base.BooleanSetting; -import com.viaversion.viafabricplus.settings.base.ModeSetting; -import com.viaversion.viafabricplus.settings.base.SettingGroup; -import com.viaversion.viafabricplus.settings.base.VersionedBooleanSetting; +import com.viaversion.viafabricplus.api.settings.type.BooleanSetting; +import com.viaversion.viafabricplus.api.settings.type.ModeSetting; +import com.viaversion.viafabricplus.api.settings.SettingGroup; +import com.viaversion.viafabricplus.api.settings.type.VersionedBooleanSetting; import net.minecraft.client.MinecraftClient; import net.minecraft.client.font.FontStorage; import net.minecraft.text.Text; @@ -36,12 +36,12 @@ public final class VisualSettings extends SettingGroup { public static final VisualSettings INSTANCE = new VisualSettings(); - public final ModeSetting changeGameMenuScreenLayout = new ModeSetting(this, Text.translatable("visual_settings.viafabricplus.change_game_menu_screen_layout"), - Text.translatable("change_game_menu_screen_layout.viafabricplus.authentic"), - Text.translatable("change_game_menu_screen_layout.viafabricplus.adjusted"), - Text.translatable("base.viafabricplus.off") + public final ModeSetting changeGameMenuScreenLayout = new ModeSetting(this, "visual_settings.viafabricplus.change_game_menu_screen_layout", + "change_game_menu_screen_layout.viafabricplus.authentic", + "change_game_menu_screen_layout.viafabricplus.adjusted", + "base.viafabricplus.off" ); - public final BooleanSetting filterNonExistingGlyphs = new BooleanSetting(this, Text.translatable("visual_settings.viafabricplus.filter_non_existing_glyphs"), true) { + public final BooleanSetting filterNonExistingGlyphs = new BooleanSetting(this, "visual_settings.viafabricplus.filter_non_existing_glyphs", true) { @Override public void onValueChanged() { final MinecraftClient client = MinecraftClient.getInstance(); @@ -53,64 +53,64 @@ public void onValueChanged() { } } }; - public final BooleanSetting hideModernJigsawScreenFeatures = new BooleanSetting(this, Text.translatable("visual_settings.viafabricplus.hide_modern_jigsaw_screen_features"), true); - public final BooleanSetting removeBubblePopSound = new BooleanSetting(this, Text.translatable("visual_settings.viafabricplus.remove_bubble_pop_sound"), false); - public final BooleanSetting hideEmptyBubbleIcons = new BooleanSetting(this, Text.translatable("visual_settings.viafabricplus.hide_empty_bubble_icons"), false); - public final BooleanSetting hideVillagerProfession = new BooleanSetting(this, Text.translatable("visual_settings.viafabricplus.hide_villager_profession"), false); + public final BooleanSetting hideModernJigsawScreenFeatures = new BooleanSetting(this, "visual_settings.viafabricplus.hide_modern_jigsaw_screen_features", true); + public final BooleanSetting removeBubblePopSound = new BooleanSetting(this, "visual_settings.viafabricplus.remove_bubble_pop_sound", false); + public final BooleanSetting hideEmptyBubbleIcons = new BooleanSetting(this, "visual_settings.viafabricplus.hide_empty_bubble_icons", false); + public final BooleanSetting hideVillagerProfession = new BooleanSetting(this, "visual_settings.viafabricplus.hide_villager_profession", false); // 1.21 -> 1.20.5 - public final VersionedBooleanSetting hideDownloadTerrainScreenTransitionEffects = new VersionedBooleanSetting(this, Text.translatable("visual_settings.viafabricplus.hide_download_terrain_screen_transition_effects"), VersionRange.andOlder(ProtocolVersion.v1_20_5)); + public final VersionedBooleanSetting hideDownloadTerrainScreenTransitionEffects = new VersionedBooleanSetting(this, "visual_settings.viafabricplus.hide_download_terrain_screen_transition_effects", VersionRange.andOlder(ProtocolVersion.v1_20_5)); // 1.20.3 -> 1.20.2 - public final VersionedBooleanSetting lockBlockingArmRotation = new VersionedBooleanSetting(this, Text.translatable("visual_settings.viafabricplus.lock_blocking_arm_rotation"), VersionRange.andOlder(ProtocolVersion.v1_20_2)); + public final VersionedBooleanSetting lockBlockingArmRotation = new VersionedBooleanSetting(this, "visual_settings.viafabricplus.lock_blocking_arm_rotation", VersionRange.andOlder(ProtocolVersion.v1_20_2)); // 1.19.4 -> 1.19.3 - public final VersionedBooleanSetting changeBodyRotationInterpolation = new VersionedBooleanSetting(this, Text.translatable("visual_settings.viafabricplus.change_body_rotation_interpolation"), VersionRange.andOlder(ProtocolVersion.v1_19_3)); + public final VersionedBooleanSetting changeBodyRotationInterpolation = new VersionedBooleanSetting(this, "visual_settings.viafabricplus.change_body_rotation_interpolation", VersionRange.andOlder(ProtocolVersion.v1_19_3)); // 1.19.2 -> 1.19 - public final VersionedBooleanSetting disableSecureChatWarning = new VersionedBooleanSetting(this, Text.translatable("visual_settings.viafabricplus.disable_secure_chat_warning"), VersionRange.andOlder(ProtocolVersion.v1_19)); + public final VersionedBooleanSetting disableSecureChatWarning = new VersionedBooleanSetting(this, "visual_settings.viafabricplus.disable_secure_chat_warning", VersionRange.andOlder(ProtocolVersion.v1_19)); // 1.19 -> 1.18.2 - public final VersionedBooleanSetting hideSignatureIndicator = new VersionedBooleanSetting(this, Text.translatable("visual_settings.viafabricplus.hide_signature_indicator"), VersionRange.andOlder(ProtocolVersion.v1_18_2)); + public final VersionedBooleanSetting hideSignatureIndicator = new VersionedBooleanSetting(this, "visual_settings.viafabricplus.hide_signature_indicator", VersionRange.andOlder(ProtocolVersion.v1_18_2)); // 1.13 -> 1.12.2 - public final VersionedBooleanSetting replacePetrifiedOakSlab = new VersionedBooleanSetting(this, Text.translatable("visual_settings.viafabricplus.replace_petrified_oak_slab"), VersionRange.of(LegacyProtocolVersion.r1_3_1tor1_3_2, ProtocolVersion.v1_12_2)); - public final VersionedBooleanSetting changeFontRendererBehaviour = new VersionedBooleanSetting(this, Text.translatable("visual_settings.viafabricplus.change_font_renderer_behaviour"), VersionRange.andOlder(ProtocolVersion.v1_12_2)); - public final VersionedBooleanSetting hideFurnaceRecipeBook = new VersionedBooleanSetting(this, Text.translatable("visual_settings.viafabricplus.hide_furnace_recipe_book"), VersionRange.andOlder(ProtocolVersion.v1_12_2)); - public final VersionedBooleanSetting forceUnicodeFontForNonAsciiLanguages = new VersionedBooleanSetting(this, Text.translatable("visual_settings.viafabricplus.force_unicode_font_for_non_ascii_languages"), VersionRange.andOlder(ProtocolVersion.v1_12_2)); - public final VersionedBooleanSetting sneakInstantly = new VersionedBooleanSetting(this, Text.translatable("visual_settings.viafabricplus.sneak_instantly"), VersionRange.andOlder(ProtocolVersion.v1_12_2)); + public final VersionedBooleanSetting replacePetrifiedOakSlab = new VersionedBooleanSetting(this, "visual_settings.viafabricplus.replace_petrified_oak_slab", VersionRange.of(LegacyProtocolVersion.r1_3_1tor1_3_2, ProtocolVersion.v1_12_2)); + public final VersionedBooleanSetting changeFontRendererBehaviour = new VersionedBooleanSetting(this, "visual_settings.viafabricplus.change_font_renderer_behaviour", VersionRange.andOlder(ProtocolVersion.v1_12_2)); + public final VersionedBooleanSetting hideFurnaceRecipeBook = new VersionedBooleanSetting(this, "visual_settings.viafabricplus.hide_furnace_recipe_book", VersionRange.andOlder(ProtocolVersion.v1_12_2)); + public final VersionedBooleanSetting forceUnicodeFontForNonAsciiLanguages = new VersionedBooleanSetting(this, "visual_settings.viafabricplus.force_unicode_font_for_non_ascii_languages", VersionRange.andOlder(ProtocolVersion.v1_12_2)); + public final VersionedBooleanSetting sneakInstantly = new VersionedBooleanSetting(this, "visual_settings.viafabricplus.sneak_instantly", VersionRange.andOlder(ProtocolVersion.v1_12_2)); // 1.12 -> 1.11.1 - public final VersionedBooleanSetting sidewaysBackwardsRunning = new VersionedBooleanSetting(this, Text.translatable("visual_settings.viafabricplus.sideways_backwards_walking"), VersionRange.andOlder(ProtocolVersion.v1_11_1)); - public final VersionedBooleanSetting hideCraftingRecipeBook = new VersionedBooleanSetting(this, Text.translatable("visual_settings.viafabricplus.hide_crafting_recipe_book"), VersionRange.andOlder(ProtocolVersion.v1_11_1)); + public final VersionedBooleanSetting sidewaysBackwardsRunning = new VersionedBooleanSetting(this, "visual_settings.viafabricplus.sideways_backwards_walking", VersionRange.andOlder(ProtocolVersion.v1_11_1)); + public final VersionedBooleanSetting hideCraftingRecipeBook = new VersionedBooleanSetting(this, "visual_settings.viafabricplus.hide_crafting_recipe_book", VersionRange.andOlder(ProtocolVersion.v1_11_1)); // 1.9 -> 1.8.x - public final VersionedBooleanSetting alwaysRenderCrosshair = new VersionedBooleanSetting(this, Text.translatable("visual_settings.viafabricplus.always_render_crosshair"), VersionRange.andOlder(ProtocolVersion.v1_8)); - public final VersionedBooleanSetting emulateArmorHud = new VersionedBooleanSetting(this, Text.translatable("visual_settings.viafabricplus.emulate_armor_hud"), VersionRange.andOlder(ProtocolVersion.v1_8)); - public final VersionedBooleanSetting hideModernCommandBlockScreenFeatures = new VersionedBooleanSetting(this, Text.translatable("visual_settings.viafabricplus.hide_modern_command_block_screen_features"), VersionRange.andOlder(ProtocolVersion.v1_8)); + public final VersionedBooleanSetting alwaysRenderCrosshair = new VersionedBooleanSetting(this, "visual_settings.viafabricplus.always_render_crosshair", VersionRange.andOlder(ProtocolVersion.v1_8)); + public final VersionedBooleanSetting emulateArmorHud = new VersionedBooleanSetting(this, "visual_settings.viafabricplus.emulate_armor_hud", VersionRange.andOlder(ProtocolVersion.v1_8)); + public final VersionedBooleanSetting hideModernCommandBlockScreenFeatures = new VersionedBooleanSetting(this, "visual_settings.viafabricplus.hide_modern_command_block_screen_features", VersionRange.andOlder(ProtocolVersion.v1_8)); // 1.8.x -> 1.7.6 - 1.7.10 - public final VersionedBooleanSetting swingHandOnItemUse = new VersionedBooleanSetting(this, Text.translatable("visual_settings.viafabricplus.swing_hand_on_item_use"), VersionRange.andOlder(ProtocolVersion.v1_7_6)); - public final VersionedBooleanSetting tiltItemPositions = new VersionedBooleanSetting(this, Text.translatable("visual_settings.viafabricplus.tilt_item_positions"), VersionRange.andOlder(ProtocolVersion.v1_7_6)); - public final VersionedBooleanSetting enableLegacyTablist = new VersionedBooleanSetting(this, Text.translatable("visual_settings.viafabricplus.enable_legacy_tablist"), VersionRange.andOlder(ProtocolVersion.v1_7_6)); + public final VersionedBooleanSetting swingHandOnItemUse = new VersionedBooleanSetting(this, "visual_settings.viafabricplus.swing_hand_on_item_use", VersionRange.andOlder(ProtocolVersion.v1_7_6)); + public final VersionedBooleanSetting tiltItemPositions = new VersionedBooleanSetting(this, "visual_settings.viafabricplus.tilt_item_positions", VersionRange.andOlder(ProtocolVersion.v1_7_6)); + public final VersionedBooleanSetting enableLegacyTablist = new VersionedBooleanSetting(this, "visual_settings.viafabricplus.enable_legacy_tablist", VersionRange.andOlder(ProtocolVersion.v1_7_6)); // 1.0.0-1.0.1 -> b1.8-b1.8.1 - public final VersionedBooleanSetting replaceHurtSoundWithOOFSound = new VersionedBooleanSetting(this, Text.translatable("visual_settings.viafabricplus.replace_hurt_sound_with_oof_sound"), VersionRange.andOlder(LegacyProtocolVersion.b1_8tob1_8_1)); + public final VersionedBooleanSetting replaceHurtSoundWithOOFSound = new VersionedBooleanSetting(this, "visual_settings.viafabricplus.replace_hurt_sound_with_oof_sound", VersionRange.andOlder(LegacyProtocolVersion.b1_8tob1_8_1)); // b1.8/b1.8.1 -> b1_7/b1.7.3 - public final VersionedBooleanSetting hideModernHUDElements = new VersionedBooleanSetting(this, Text.translatable("visual_settings.viafabricplus.hide_modern_hud_elements"), VersionRange.andOlder(LegacyProtocolVersion.b1_7tob1_7_3)); - public final VersionedBooleanSetting disableServerPinging = new VersionedBooleanSetting(this, Text.translatable("visual_settings.viafabricplus.disable_server_pinging"), VersionRange.andOlder(LegacyProtocolVersion.b1_7tob1_7_3)); + public final VersionedBooleanSetting hideModernHUDElements = new VersionedBooleanSetting(this, "visual_settings.viafabricplus.hide_modern_hud_elements", VersionRange.andOlder(LegacyProtocolVersion.b1_7tob1_7_3)); + public final VersionedBooleanSetting disableServerPinging = new VersionedBooleanSetting(this, "visual_settings.viafabricplus.disable_server_pinging", VersionRange.andOlder(LegacyProtocolVersion.b1_7tob1_7_3)); // a1.0.15 -> c0_28/c0_30 - public final VersionedBooleanSetting replaceCreativeInventory = new VersionedBooleanSetting(this, Text.translatable("visual_settings.viafabricplus.replace_creative_inventory_with_classic_inventory"), VersionRange.andOlder(LegacyProtocolVersion.c0_28toc0_30)); - public final VersionedBooleanSetting oldWalkingAnimation = new VersionedBooleanSetting(this, Text.translatable("visual_settings.viafabricplus.old_walking_animation"), VersionRange.andOlder(LegacyProtocolVersion.c0_28toc0_30)); + public final VersionedBooleanSetting replaceCreativeInventory = new VersionedBooleanSetting(this, "visual_settings.viafabricplus.replace_creative_inventory_with_classic_inventory", VersionRange.andOlder(LegacyProtocolVersion.c0_28toc0_30)); + public final VersionedBooleanSetting oldWalkingAnimation = new VersionedBooleanSetting(this, "visual_settings.viafabricplus.old_walking_animation", VersionRange.andOlder(LegacyProtocolVersion.c0_28toc0_30)); public VisualSettings() { - super(Text.translatable("setting_group_name.viafabricplus.visual")); + super("setting_group_name.viafabricplus.visual"); changeGameMenuScreenLayout.setTooltip(() -> switch (changeGameMenuScreenLayout.getIndex()) { - case 0 -> Text.translatable("change_game_menu_screen_layout.viafabricplus.authentic.tooltip"); - case 1 -> Text.translatable("change_game_menu_screen_layout.viafabricplus.adjusted.tooltip"); - default -> Text.translatable("change_game_menu_screen_layout.viafabricplus.off.tooltip"); + case 0 -> "change_game_menu_screen_layout.viafabricplus.authentic.tooltip"; + case 1 -> "change_game_menu_screen_layout.viafabricplus.adjusted.tooltip"; + default -> "change_game_menu_screen_layout.viafabricplus.off.tooltip"; }); changeGameMenuScreenLayout.setValue(1); diff --git a/src/main/resources/fabric.mod.json b/src/main/resources/fabric.mod.json index fa2f7def9..c87a337c8 100644 --- a/src/main/resources/fabric.mod.json +++ b/src/main/resources/fabric.mod.json @@ -40,7 +40,7 @@ "environment": "client", "entrypoints": { "modmenu": [ - "com.viaversion.viafabricplus.util.ModMenuScreenFactory" + "com.viaversion.viafabricplus.base.modmenu.ModMenuScreenFactory" ] }, "mixins": [