From 2d96ea28b3f451d3ae877f9d1b74a5b7b0f4a84a Mon Sep 17 00:00:00 2001 From: FlorianMichael Date: Tue, 24 Dec 2024 12:36:30 +0100 Subject: [PATCH] Finish code base rewrite --- .../viafabricplus/ViaFabricPlus.java | 5 +- .../settings/SettingsManager.java | 47 +++++++++++++ api/build.gradle | 4 ++ .../viafabricplus/api/ViaFabricPlusBase.java | 61 +++++++++++++++++ .../ChangeProtocolVersionCallback.java | 2 +- .../{ => events}/LoadingCycleCallback.java | 2 +- .../api/settings}/AbstractSetting.java | 9 +-- .../api/settings}/SettingGroup.java | 2 +- .../api/settings/type}/BooleanSetting.java | 11 +--- .../api/settings/type}/ButtonSetting.java | 10 +-- .../api/settings/type}/ModeSetting.java | 11 +--- .../type}/VersionedBooleanSetting.java | 15 ++--- .../viafabricplus/util/ChatUtil.java | 0 build.gradle | 4 +- .../viafabricplus/ViaFabricPlusImpl.java | 66 +++++++++++++++---- .../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 +- .../LanguageUtil.java | 2 +- .../UnicodeFontFix1_12_2.java | 1 - .../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 +- .../translator/ItemTranslator.java | 14 ---- .../viafabricplus/save/SaveManager.java | 12 ++-- .../viafabricplus/save/impl/SettingsSave.java | 18 ++--- .../{base => }/screen/VFPList.java | 6 +- .../{base => }/screen/VFPListEntry.java | 12 ++-- .../{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 | 6 +- .../settings/ButtonSettingRenderer.java | 8 +-- .../settings/ModeSettingRenderer.java | 6 +- .../{ => impl}/settings/SettingsScreen.java | 25 +++++-- .../{ => impl}/settings/TitleRenderer.java | 4 +- .../VersionedBooleanSettingRenderer.java | 7 +- .../settings/SettingsManager.java | 8 ++- .../settings/impl/AuthenticationSettings.java | 4 +- .../settings/impl/BedrockSettings.java | 14 ++-- .../settings/impl/DebugSettings.java | 33 +++++----- .../settings/impl/GeneralSettings.java | 6 +- .../settings/impl/VisualSettings.java | 8 +-- src/main/resources/fabric.mod.json | 2 +- 69 files changed, 376 insertions(+), 239 deletions(-) create mode 100644 api-legacy/src/main/java/de/florianmichael/viafabricplus/settings/SettingsManager.java 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 (90%) rename {src/main/java/com/viaversion/viafabricplus/settings/base => api/src/main/java/com/viaversion/viafabricplus/api/settings}/SettingGroup.java (97%) rename {src/main/java/com/viaversion/viafabricplus/settings/base => api/src/main/java/com/viaversion/viafabricplus/api/settings/type}/BooleanSetting.java (82%) rename {src/main/java/com/viaversion/viafabricplus/settings/base => api/src/main/java/com/viaversion/viafabricplus/api/settings/type}/ButtonSetting.java (82%) rename {src/main/java/com/viaversion/viafabricplus/settings/base => api/src/main/java/com/viaversion/viafabricplus/api/settings/type}/ModeSetting.java (88%) rename {src/main/java/com/viaversion/viafabricplus/settings/base => api/src/main/java/com/viaversion/viafabricplus/api/settings/type}/VersionedBooleanSetting.java (84%) rename {src => api/src}/main/java/com/viaversion/viafabricplus/util/ChatUtil.java (100%) 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/{protocoltranslator/util => features/filter_non_existing_characters}/LanguageUtil.java (95%) 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 (94%) 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 (92%) rename src/main/java/com/viaversion/viafabricplus/screen/{ => impl}/settings/ButtonSettingRenderer.java (89%) rename src/main/java/com/viaversion/viafabricplus/screen/{ => impl}/settings/ModeSettingRenderer.java (93%) rename src/main/java/com/viaversion/viafabricplus/screen/{ => impl}/settings/SettingsScreen.java (62%) 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 (92%) diff --git a/api-legacy/src/main/java/de/florianmichael/viafabricplus/ViaFabricPlus.java b/api-legacy/src/main/java/de/florianmichael/viafabricplus/ViaFabricPlus.java index 040d54c7c..21e34d8ff 100644 --- a/api-legacy/src/main/java/de/florianmichael/viafabricplus/ViaFabricPlus.java +++ b/api-legacy/src/main/java/de/florianmichael/viafabricplus/ViaFabricPlus.java @@ -21,6 +21,7 @@ package de.florianmichael.viafabricplus; +import de.florianmichael.viafabricplus.settings.SettingsManager; import org.apache.logging.log4j.Logger; import java.io.File; @@ -33,6 +34,8 @@ public class ViaFabricPlus { private static final ViaFabricPlus INSTANCE = new ViaFabricPlus(); + private final SettingsManager settingsManager = new SettingsManager(); + @Deprecated public static ViaFabricPlus global() { return INSTANCE; @@ -50,7 +53,7 @@ public File getDirectory() { @Deprecated public Object getSettingsManager() { - throw new IllegalArgumentException("ViaFabricPlus#getSettingsManager is not supported anymore."); + return settingsManager; } @Deprecated diff --git a/api-legacy/src/main/java/de/florianmichael/viafabricplus/settings/SettingsManager.java b/api-legacy/src/main/java/de/florianmichael/viafabricplus/settings/SettingsManager.java new file mode 100644 index 000000000..02eab3f9a --- /dev/null +++ b/api-legacy/src/main/java/de/florianmichael/viafabricplus/settings/SettingsManager.java @@ -0,0 +1,47 @@ +/* + * This file is part of ViaFabricPlus - https://github.com/ViaVersion/ViaFabricPlus + * Copyright (C) 2021-2024 the original authors + * - FlorianMichael/EnZaXD + * - RK_01/RaphiMC + * Copyright (C) 2023-2024 ViaVersion and contributors + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package de.florianmichael.viafabricplus.settings; + +import com.viaversion.viafabricplus.ViaFabricPlus; +import com.viaversion.viafabricplus.api.settings.SettingGroup; + +import java.util.List; + +/** + * Please migrate to the general {@link com.viaversion.viafabricplus.ViaFabricPlus} API point. + */ +@Deprecated +public class SettingsManager { + + @Deprecated + public void addGroup(final SettingGroup... groups) { + for (SettingGroup group : groups) { + ViaFabricPlus.getImpl().addSettingGroup(group); + } + } + + @Deprecated + public List getGroups() { + return ViaFabricPlus.getImpl().settingGroups(); + } + +} \ No newline at end of file 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..18f20fcb6 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,19 @@ 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.minecraft.item.Item; import com.viaversion.viaversion.api.protocol.version.ProtocolVersion; import io.netty.channel.Channel; +import net.minecraft.client.gui.screen.Screen; +import net.minecraft.item.ItemStack; 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 +125,58 @@ 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); + + /** + * Open the protocol selection screen. + * + * @param parent The parent screen + */ + void openProtocolSelectionScreen(final Screen parent); + + /** + * Open the settings screen. + * + * @param parent The parent screen + */ + void openSettingsScreen(final Screen parent); + + /** + * Converts a Minecraft item stack to a ViaVersion item + * + * @param stack The Minecraft item stack + * @param targetVersion The target version to convert to (e.g. v1.13) + * @return The ViaVersion item for the target version + */ + Item translateItem(final ItemStack stack, final ProtocolVersion targetVersion); + + /** + * Converts a ViaVersion item to a Minecraft item stack + * + * @param item The ViaVersion item + * @param sourceVersion The source version of the item (e.g. b1.8) + * @return The Minecraft item stack + */ + ItemStack translateItem(final Item item, final ProtocolVersion sourceVersion); + } 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 90% 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..dc7c138f8 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,10 +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; @@ -53,12 +52,6 @@ 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); 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 97% 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..6f3e723ef 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,7 +19,7 @@ * along with this program. If not, see . */ -package com.viaversion.viafabricplus.settings.base; +package com.viaversion.viafabricplus.api.settings; import net.minecraft.text.Text; 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 82% 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..ef5554cbe 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,11 +19,11 @@ * 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 com.viaversion.viafabricplus.api.settings.AbstractSetting; +import com.viaversion.viafabricplus.api.settings.SettingGroup; import net.minecraft.text.MutableText; public class BooleanSetting extends AbstractSetting { @@ -32,11 +32,6 @@ public BooleanSetting(SettingGroup parent, MutableText name, Boolean defaultValu super(parent, name, defaultValue); } - @Override - public VFPListEntry makeSettingRenderer() { - return new BooleanSettingRenderer(this); - } - @Override public void write(JsonObject object) { object.addProperty(getTranslationKey(), getValue()); 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 82% 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..895652d0b 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,11 +19,11 @@ * 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 com.viaversion.viafabricplus.api.settings.AbstractSetting; +import com.viaversion.viafabricplus.api.settings.SettingGroup; import net.minecraft.text.MutableText; public class ButtonSetting extends AbstractSetting { @@ -32,10 +32,6 @@ public ButtonSetting(SettingGroup parent, MutableText name, Runnable onClick) { super(parent, name, onClick); } - @Override - public VFPListEntry makeSettingRenderer() { - return new ButtonSettingRenderer(this); - } public MutableText displayValue() { return getName(); 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 88% 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..d80b1ff28 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,11 +19,11 @@ * 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.api.settings.AbstractSetting; +import com.viaversion.viafabricplus.api.settings.SettingGroup; import com.viaversion.viafabricplus.util.ChatUtil; import net.minecraft.text.MutableText; @@ -42,11 +42,6 @@ public ModeSetting(SettingGroup parent, MutableText name, int defaultOption, Mut this.options = options; } - @Override - public VFPListEntry makeSettingRenderer() { - return new ModeSettingRenderer(this); - } - @Override public void write(JsonObject object) { object.addProperty(getTranslationKey(), mapTranslationKey(ChatUtil.uncoverTranslationKey(getValue()))); 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 84% 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..6e72056ee 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,13 +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; @@ -43,11 +43,6 @@ public VersionedBooleanSetting(SettingGroup parent, MutableText name, VersionRan 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 +60,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/util/ChatUtil.java b/api/src/main/java/com/viaversion/viafabricplus/util/ChatUtil.java similarity index 100% rename from src/main/java/com/viaversion/viafabricplus/util/ChatUtil.java rename to api/src/main/java/com/viaversion/viafabricplus/util/ChatUtil.java diff --git a/build.gradle b/build.gradle index accf4c081..664a8e29b 100644 --- a/build.gradle +++ b/build.gradle @@ -28,8 +28,8 @@ dependencies { modJij fabricApi.module("fabric-particles-v1", project.fabric_api_version) modJij fabricApi.module("fabric-registry-sync-v0", project.fabric_api_version) - // Workaround resolution errors by not using jij tasks - include implementation(project(":viafabricplus-api")) + // Manually include to ignore dependencies + include implementation(project(path: ":viafabricplus-api", configuration: "namedElements")) include implementation(project(":viafabricplus-api-legacy")) jij "com.viaversion:viaversion-common:5.2.1-SNAPSHOT" diff --git a/src/main/java/com/viaversion/viafabricplus/ViaFabricPlusImpl.java b/src/main/java/com/viaversion/viafabricplus/ViaFabricPlusImpl.java index 786d80e26..ece1f34e1 100644 --- a/src/main/java/com/viaversion/viafabricplus/ViaFabricPlusImpl.java +++ b/src/main/java/com/viaversion/viafabricplus/ViaFabricPlusImpl.java @@ -21,26 +21,36 @@ 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.protocoltranslator.translator.ItemTranslator; +import com.viaversion.viafabricplus.util.ChatUtil; import com.viaversion.viafabricplus.base.Events; +import com.viaversion.viafabricplus.base.sync_tasks.SyncTasks; import com.viaversion.viafabricplus.save.SaveManager; +import com.viaversion.viafabricplus.screen.impl.ProtocolSelectionScreen; +import com.viaversion.viafabricplus.screen.impl.settings.SettingsScreen; 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.minecraft.item.Item; import com.viaversion.viaversion.api.protocol.version.ProtocolVersion; import io.netty.channel.Channel; import net.fabricmc.loader.api.FabricLoader; +import net.minecraft.client.gui.screen.Screen; +import net.minecraft.item.ItemStack; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; 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 +91,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 +109,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 +124,7 @@ public void init() { return; } loadingFuture.join(); - saveManager.postInit(); + SaveManager.INSTANCE.postInit(); }); } @@ -175,12 +183,44 @@ 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); + } + + @Override + public SettingGroup getSettingGroup(String translationKey) { + for (SettingGroup group : SettingsManager.INSTANCE.getGroups()) { + if (ChatUtil.uncoverTranslationKey(group.getName()).equals(translationKey)) { + return group; + } + } + return null; + } + + @Override + public void openProtocolSelectionScreen(Screen parent) { + ProtocolSelectionScreen.INSTANCE.open(parent); + } + + @Override + public void openSettingsScreen(Screen parent) { + SettingsScreen.INSTANCE.open(parent); } - public SaveManager getSaveManager() { - return saveManager; + @Override + public Item translateItem(ItemStack stack, ProtocolVersion targetVersion) { + return ItemTranslator.mcToVia(stack, targetVersion); + } + + @Override + public ItemStack translateItem(Item item, ProtocolVersion sourceVersion) { + return ItemTranslator.viaToMc(item, sourceVersion); } } 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/protocoltranslator/util/LanguageUtil.java b/src/main/java/com/viaversion/viafabricplus/features/filter_non_existing_characters/LanguageUtil.java similarity index 95% rename from src/main/java/com/viaversion/viafabricplus/protocoltranslator/util/LanguageUtil.java rename to src/main/java/com/viaversion/viafabricplus/features/filter_non_existing_characters/LanguageUtil.java index de69ac47e..b61f1d8af 100644 --- a/src/main/java/com/viaversion/viafabricplus/protocoltranslator/util/LanguageUtil.java +++ b/src/main/java/com/viaversion/viafabricplus/features/filter_non_existing_characters/LanguageUtil.java @@ -19,7 +19,7 @@ * along with this program. If not, see . */ -package com.viaversion.viafabricplus.protocoltranslator.util; +package com.viaversion.viafabricplus.features.filter_non_existing_characters; import java.util.Map; diff --git a/src/main/java/com/viaversion/viafabricplus/features/filter_non_existing_characters/UnicodeFontFix1_12_2.java b/src/main/java/com/viaversion/viafabricplus/features/filter_non_existing_characters/UnicodeFontFix1_12_2.java index 5db319c74..e07bcc114 100644 --- a/src/main/java/com/viaversion/viafabricplus/features/filter_non_existing_characters/UnicodeFontFix1_12_2.java +++ b/src/main/java/com/viaversion/viafabricplus/features/filter_non_existing_characters/UnicodeFontFix1_12_2.java @@ -23,7 +23,6 @@ import com.viaversion.viafabricplus.base.Events; import com.viaversion.viaversion.api.protocol.version.ProtocolVersion; -import com.viaversion.viafabricplus.protocoltranslator.util.LanguageUtil; import com.viaversion.viafabricplus.settings.impl.VisualSettings; import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents; import net.minecraft.client.MinecraftClient; 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/protocoltranslator/translator/ItemTranslator.java b/src/main/java/com/viaversion/viafabricplus/protocoltranslator/translator/ItemTranslator.java index 2d63ed39f..d9be59461 100644 --- a/src/main/java/com/viaversion/viafabricplus/protocoltranslator/translator/ItemTranslator.java +++ b/src/main/java/com/viaversion/viafabricplus/protocoltranslator/translator/ItemTranslator.java @@ -47,13 +47,6 @@ public final class ItemTranslator { - /** - * Converts a Minecraft item stack to a ViaVersion item - * - * @param stack The Minecraft item stack - * @param targetVersion The target version to convert to (e.g. v1.13) - * @return The ViaVersion item for the target version - */ public static Item mcToVia(final ItemStack stack, final ProtocolVersion targetVersion) { final UserConnection user = ProtocolTranslator.createDummyUserConnection(ProtocolTranslator.NATIVE_VERSION, targetVersion); @@ -73,13 +66,6 @@ public static Item mcToVia(final ItemStack stack, final ProtocolVersion targetVe } } - /** - * Converts a ViaVersion item to a Minecraft item stack - * - * @param item The ViaVersion item - * @param sourceVersion The source version of the item (e.g. b1.8) - * @return The Minecraft item stack - */ public static ItemStack viaToMc(final Item item, final ProtocolVersion sourceVersion) { final UserConnection user = ProtocolTranslator.createDummyUserConnection(ProtocolTranslator.NATIVE_VERSION, sourceVersion); 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..5f55b4839 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,28 @@ 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 +55,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 94% 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..359c67257 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,10 +99,10 @@ 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); } } 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 92% 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..e833788e0 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,10 +19,10 @@ * 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; 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 89% 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..df4447914 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,10 +19,10 @@ * 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; @@ -38,7 +38,7 @@ public ButtonSettingRenderer(ButtonSetting value) { @Override public Text getNarration() { - return this.value.getName(); + return this.value.displayValue(); } @Override 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 93% 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..3fb426aeb 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,10 +19,10 @@ * 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; 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 62% 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..5bdada721 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()) { + for (SettingGroup group : SettingsManager.INSTANCE.getGroups()) { this.addEntry(new TitleRenderer(group.getName())); 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 92% 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..dc2f23c5c 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; 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..247867d11 100644 --- a/src/main/java/com/viaversion/viafabricplus/settings/impl/AuthenticationSettings.java +++ b/src/main/java/com/viaversion/viafabricplus/settings/impl/AuthenticationSettings.java @@ -21,8 +21,8 @@ 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 { 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..b8f51dd09 100644 --- a/src/main/java/com/viaversion/viafabricplus/settings/impl/BedrockSettings.java +++ b/src/main/java/com/viaversion/viafabricplus/settings/impl/BedrockSettings.java @@ -21,13 +21,13 @@ 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; @@ -70,7 +70,7 @@ public final class BedrockSettings extends SettingGroup { @Override public MutableText displayValue() { - final StepFullBedrockSession.FullBedrockSession account = ViaFabricPlusImpl.INSTANCE.getSaveManager().getAccountsSave().getBedrockAccount(); + final StepFullBedrockSession.FullBedrockSession account = SaveManager.INSTANCE.getAccountsSave().getBedrockAccount(); if (account != null) { return Text.translatable("click_to_set_bedrock_account.viafabricplus.display", account.getMcChain().getDisplayName()); } else { @@ -100,7 +100,7 @@ public BedrockSettings() { } 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..53681fbc3 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; 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..fe03fb38f 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; 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": [