added translation base

This commit is contained in:
FlorianMichael 2023-03-19 16:05:42 +01:00
parent 2751da2c36
commit 652a4deafd
21 changed files with 168 additions and 93 deletions

View File

@ -20,6 +20,13 @@ If you encounter any issues, please report them on the
[issue tracker](https://github.com/FlorianMichael/ViaFabricPlus/issues).
Contributions in the form of pull requests are always welcome, please just stick to my code style and make sure your code is easy to update and compatible with other mods.
## Translations
Translations for other languages are always welcome, in ~/resources/assets/viafabricplus/lang you can find all translations,
if you know a language well, feel free to make a PR and add translations for that language <br>
**Currently supported languages**:
- English
## Compatibility
ViaFabricPlus is structured to interfere with mods as little as possible.
It should work fine with most if not all mods and modpacks.

View File

@ -9,7 +9,7 @@ loader_version=0.14.17
fabric_api_version=0.76.0+1.19.4
# viafabricplus
mod_version=2.1.8
mod_version=2.1.9
maven_group=de.florianmichael
archives_base_name=viafabricplus

View File

@ -67,7 +67,7 @@ public class ProtocolSelectionScreen extends Screen {
this.addDrawableChild(new SlotList(this.client, width, height, 3 + 3 /* start offset */ + (textRenderer.fontHeight + 2) * 3 /* title is 2 */, height + 5, textRenderer.fontHeight + 4));
this.addDrawableChild(ButtonWidget.builder(Text.literal("<-"), button -> this.close()).position(0, 0).size(20, 20).build());
this.addDrawableChild(ButtonWidget.builder(Text.literal("Settings"), button -> client.setScreen(SettingsScreen.get(this))).position(width - 98, 0).size(98, 20).build());
this.addDrawableChild(ButtonWidget.builder(Text.translatable("words.viafabricplus.settings"), button -> client.setScreen(SettingsScreen.get(this))).position(width - 98, 0).size(98, 20).build());
}
@Override

View File

@ -17,8 +17,20 @@
*/
package de.florianmichael.viafabricplus.screen.settings;
import net.minecraft.client.gui.DrawableHelper;
import net.minecraft.client.gui.widget.AlwaysSelectedEntryListWidget;
import net.minecraft.client.util.math.MatrixStack;
public abstract class AbstractSettingRenderer extends AlwaysSelectedEntryListWidget.Entry<AbstractSettingRenderer> {
public abstract void renderSetting(MatrixStack matrices, int index, int y, int x, int entryWidth, int entryHeight, int mouseX, int mouseY, boolean hovered, float tickDelta);
@Override
public void render(MatrixStack matrices, int index, int y, int x, int entryWidth, int entryHeight, int mouseX, int mouseY, boolean hovered, float tickDelta) {
matrices.push();
matrices.translate(x, y, 0);
DrawableHelper.fill(matrices, 0, 0, entryWidth - 4 /* int i = this.left + (this.width - entryWidth) / 2; int j = this.left + (this.width + entryWidth) / 2; */, entryHeight, Integer.MIN_VALUE);
renderSetting(matrices, index, y, x, entryWidth, entryHeight, mouseX, mouseY, hovered, tickDelta);
matrices.pop();
}
}

View File

@ -38,7 +38,7 @@ public class BooleanSettingRenderer extends AbstractSettingRenderer {
@Override
public Text getNarration() {
return Text.literal(this.value.getName());
return this.value.getName();
}
@Override
@ -49,17 +49,12 @@ public class BooleanSettingRenderer extends AbstractSettingRenderer {
}
@Override
public void render(MatrixStack matrices, int index, int y, int x, int entryWidth, int entryHeight, int mouseX, int mouseY, boolean hovered, float tickDelta) {
matrices.push();
matrices.translate(x, y, 0);
DrawableHelper.fill(matrices, 0, 0, entryWidth - 4 /* int i = this.left + (this.width - entryWidth) / 2; int j = this.left + (this.width + entryWidth) / 2; */, entryHeight, Integer.MIN_VALUE);
public void renderSetting(MatrixStack matrices, int index, int y, int x, int entryWidth, int entryHeight, int mouseX, int mouseY, boolean hovered, float tickDelta) {
final TextRenderer textRenderer = MinecraftClient.getInstance().textRenderer;
final String text = this.value.getValue() ? "On" : "Off";
final Text text = this.value.getValue() ? Text.translatable("words.viafabricplus.on") : Text.translatable("words.viafabricplus.off");
textRenderer.drawWithShadow(matrices, Formatting.GRAY + this.value.getName(), 3, entryHeight / 2F - textRenderer.fontHeight / 2F, -1);
textRenderer.drawWithShadow(matrices, this.value.getName().formatted(Formatting.GRAY), 3, entryHeight / 2F - textRenderer.fontHeight / 2F, -1);
textRenderer.drawWithShadow(matrices, text, entryWidth - textRenderer.getWidth(text) - 3 - 3, entryHeight / 2F - textRenderer.fontHeight / 2F, this.value.getValue() ? Color.GREEN.getRGB() : Color.RED.getRGB());
matrices.pop();
}
}

View File

@ -35,7 +35,7 @@ public class ButtonSettingRenderer extends AbstractSettingRenderer {
@Override
public Text getNarration() {
return Text.literal(this.value.getName());
return this.value.getName();
}
@Override
@ -46,14 +46,9 @@ public class ButtonSettingRenderer extends AbstractSettingRenderer {
}
@Override
public void render(MatrixStack matrices, int index, int y, int x, int entryWidth, int entryHeight, int mouseX, int mouseY, boolean hovered, float tickDelta) {
matrices.push();
matrices.translate(x, y, 0);
DrawableHelper.fill(matrices, 0, 0, entryWidth - 4 /* int i = this.left + (this.width - entryWidth) / 2; int j = this.left + (this.width + entryWidth) / 2; */, entryHeight, Integer.MIN_VALUE);
public void renderSetting(MatrixStack matrices, int index, int y, int x, int entryWidth, int entryHeight, int mouseX, int mouseY, boolean hovered, float tickDelta) {
final TextRenderer textRenderer = MinecraftClient.getInstance().textRenderer;
DrawableHelper.drawCenteredTextWithShadow(matrices, textRenderer, this.value.displayValue(), entryWidth / 2, entryHeight / 2 - textRenderer.fontHeight / 2, -1);
matrices.pop();
}
}

View File

@ -38,7 +38,7 @@ public class ModeSettingRenderer extends AbstractSettingRenderer {
@Override
public Text getNarration() {
return Text.literal(this.value.getName());
return this.value.getName();
}
@Override
@ -50,15 +50,10 @@ public class ModeSettingRenderer extends AbstractSettingRenderer {
}
@Override
public void render(MatrixStack matrices, int index, int y, int x, int entryWidth, int entryHeight, int mouseX, int mouseY, boolean hovered, float tickDelta) {
matrices.push();
matrices.translate(x, y, 0);
DrawableHelper.fill(matrices, 0, 0, entryWidth - 4 /* int i = this.left + (this.width - entryWidth) / 2; int j = this.left + (this.width + entryWidth) / 2; */, entryHeight, Integer.MIN_VALUE);
public void renderSetting(MatrixStack matrices, int index, int y, int x, int entryWidth, int entryHeight, int mouseX, int mouseY, boolean hovered, float tickDelta) {
final TextRenderer textRenderer = MinecraftClient.getInstance().textRenderer;
textRenderer.drawWithShadow(matrices, Formatting.GRAY + this.value.getName(), 3, entryHeight / 2F - textRenderer.fontHeight / 2F, -1);
textRenderer.drawWithShadow(matrices, this.value.getName().formatted(Formatting.GRAY), 3, entryHeight / 2F - textRenderer.fontHeight / 2F, -1);
textRenderer.drawWithShadow(matrices, this.value.getValue(), entryWidth - textRenderer.getWidth(this.value.getValue()) - 3 - 3, entryHeight / 2F - textRenderer.fontHeight / 2F, -1);
matrices.pop();
}
}

View File

@ -39,7 +39,7 @@ public class ProtocolSyncBooleanSettingRenderer extends AbstractSettingRenderer
@Override
public Text getNarration() {
return Text.literal(this.value.getName());
return this.value.getName();
}
@Override
@ -50,21 +50,16 @@ public class ProtocolSyncBooleanSettingRenderer extends AbstractSettingRenderer
}
@Override
public void render(MatrixStack matrices, int index, int y, int x, int entryWidth, int entryHeight, int mouseX, int mouseY, boolean hovered, float tickDelta) {
matrices.push();
matrices.translate(x, y, 0);
DrawableHelper.fill(matrices, 0, 0, entryWidth - 4 /* int i = this.left + (this.width - entryWidth) / 2; int j = this.left + (this.width + entryWidth) / 2; */, entryHeight, Integer.MIN_VALUE);
public void renderSetting(MatrixStack matrices, int index, int y, int x, int entryWidth, int entryHeight, int mouseX, int mouseY, boolean hovered, float tickDelta) {
final TextRenderer textRenderer = MinecraftClient.getInstance().textRenderer;
final String text = this.value.getValue() ? "On" : "Off";
final Text text = this.value.getValue() ? Text.translatable("words.viafabricplus.on") : Text.translatable("words.viafabricplus.off");
Color color = this.value.getValue() ? Color.GREEN : Color.RED;
final int length = textRenderer.drawWithShadow(matrices, Formatting.GRAY + this.value.getName(), 3, entryHeight / 2F - textRenderer.fontHeight / 2F, -1);
final int length = textRenderer.drawWithShadow(matrices, this.value.getName().formatted(Formatting.GRAY), 3, entryHeight / 2F - textRenderer.fontHeight / 2F, -1);
textRenderer.drawWithShadow(matrices, "(" + this.value.getProtocolRange().toString() + ")", length + 2, entryHeight / 2F - textRenderer.fontHeight / 2F, -1);
if (GeneralSettings.INSTANCE.automaticallyChangeValuesBasedOnTheCurrentVersion.getValue()) color = color.darker().darker();
textRenderer.drawWithShadow(matrices, text, entryWidth - textRenderer.getWidth(text) - 3 - 3, entryHeight / 2F - textRenderer.fontHeight / 2F, color.getRGB());
matrices.pop();
}
}

View File

@ -38,11 +38,13 @@ public class TitleRenderer extends AbstractSettingRenderer {
@Override
public void render(MatrixStack matrices, int index, int y, int x, int entryWidth, int entryHeight, int mouseX, int mouseY, boolean hovered, float tickDelta) {
renderSetting(matrices, index, y, x, entryWidth, entryHeight, mouseX, mouseY, hovered, tickDelta);
}
@Override
public void renderSetting(MatrixStack matrices, int index, int y, int x, int entryWidth, int entryHeight, int mouseX, int mouseY, boolean hovered, float tickDelta) {
final TextRenderer textRenderer = MinecraftClient.getInstance().textRenderer;
matrices.push();
matrices.translate(x, y, 0);
textRenderer.drawWithShadow(matrices, Formatting.BOLD + this.name, 3, entryHeight / 2F - textRenderer.fontHeight / 2F, -1);
matrices.pop();
}
}

View File

@ -19,14 +19,17 @@ package de.florianmichael.viafabricplus.settings.base;
import com.google.gson.JsonObject;
import de.florianmichael.viafabricplus.screen.settings.AbstractSettingRenderer;
import net.minecraft.text.MutableText;
import net.minecraft.text.Text;
import net.minecraft.text.TranslatableTextContent;
public abstract class AbstractSetting<T> {
private final String name;
private final MutableText name;
private final T defaultValue;
public T value;
public AbstractSetting(final SettingGroup parent, final String name, final T defaultValue) {
public AbstractSetting(final SettingGroup parent, final MutableText name, final T defaultValue) {
this.name = name;
this.defaultValue = defaultValue;
@ -40,10 +43,14 @@ public abstract class AbstractSetting<T> {
public abstract void write(final JsonObject object);
public abstract void read(final JsonObject object);
public String getName() {
public MutableText getName() {
return name;
}
public String getTranslationKey() {
return ((TranslatableTextContent) name.getContent()).getKey();
}
public T getDefaultValue() {
return defaultValue;
}

View File

@ -26,6 +26,7 @@ import net.minecraft.client.MinecraftClient;
import net.minecraft.client.gui.screen.NoticeScreen;
import net.minecraft.client.gui.screen.TitleScreen;
import net.minecraft.client.gui.screen.multiplayer.MultiplayerScreen;
import net.minecraft.text.MutableText;
import net.minecraft.text.Text;
import net.minecraft.util.Formatting;
import net.minecraft.util.Util;
@ -38,13 +39,13 @@ import java.util.concurrent.CompletableFuture;
public class BedrockSettings extends SettingGroup {
public final static BedrockSettings INSTANCE = new BedrockSettings();
public final ButtonSetting BEDROCK_ACCOUNT = new ButtonSetting(this, "Click to set account for Bedrock edition", () -> CompletableFuture.runAsync(() -> {
public final ButtonSetting BEDROCK_ACCOUNT = new ButtonSetting(this, Text.translatable("bedrock.viafabricplus.set"), () -> CompletableFuture.runAsync(() -> {
try {
BedrockAccountManager.INSTANCE.setAccount(MinecraftAuth.requestBedrockLogin(msaDeviceCode -> {
MinecraftClient.getInstance().execute(() -> MinecraftClient.getInstance().setScreen(new NoticeScreen(() -> {
MinecraftClient.getInstance().setScreen(SettingsScreen.get(new MultiplayerScreen(new TitleScreen())));
Thread.currentThread().interrupt();
}, Text.literal("Microsoft Bedrock login"), Text.literal("Your browser should have opened.\nPlease enter the following Code: " + Formatting.BOLD + msaDeviceCode.userCode() + Formatting.RESET + "\nClosing this screen will cancel the process!"), Text.literal("Cancel"), false)));
}, Text.literal("Microsoft Bedrock login"), Text.translatable("bedrocklogin.viafabricplus.text", msaDeviceCode.userCode()), Text.translatable("words.viafabricplus.cancel"), false)));
try {
Util.getOperatingSystem().open(new URI(msaDeviceCode.verificationUri()));
} catch (URISyntaxException e) {
@ -57,9 +58,9 @@ public class BedrockSettings extends SettingGroup {
}
})) {
@Override
public String displayValue() {
public MutableText displayValue() {
if (BedrockAccountManager.INSTANCE.getAccount() != null) {
return super.displayValue() + ", current: " + BedrockAccountManager.INSTANCE.getAccount().displayName();
return Text.literal("Bedrock account: " + BedrockAccountManager.INSTANCE.getAccount().displayName());
}
return super.displayValue();
}

View File

@ -19,13 +19,14 @@ package de.florianmichael.viafabricplus.settings.groups;
import de.florianmichael.viafabricplus.settings.base.SettingGroup;
import de.florianmichael.viafabricplus.settings.type_impl.BooleanSetting;
import net.minecraft.text.Text;
public class BridgeSettings extends SettingGroup {
public final static BridgeSettings INSTANCE = new BridgeSettings();
public final BooleanSetting showSuperSecretSettings = new BooleanSetting(this, "Show Super Secret Settings", true);
public final BooleanSetting showExtraInformationInDebugHud = new BooleanSetting(this, "Show extra information in Debug Hud", true);
public final BooleanSetting showClassicLoadingProgressInConnectScreen = new BooleanSetting(this, "Show classic loading progress in connect screen", true);
public final BooleanSetting showSuperSecretSettings = new BooleanSetting(this, Text.translatable("bridge.viafabricplus.secret"), true);
public final BooleanSetting showExtraInformationInDebugHud = new BooleanSetting(this, Text.translatable("bridge.viafabricplus.extrainformation"), true);
public final BooleanSetting showClassicLoadingProgressInConnectScreen = new BooleanSetting(this, Text.translatable("bridge.viafabricplus.classicloading"), true);
public BridgeSettings() {
super("Bridge");

View File

@ -21,35 +21,36 @@ import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
import de.florianmichael.viafabricplus.settings.base.SettingGroup;
import de.florianmichael.viafabricplus.settings.type_impl.ProtocolSyncBooleanSetting;
import de.florianmichael.vialoadingbase.platform.ProtocolRange;
import net.minecraft.text.Text;
import net.raphimc.vialegacy.api.LegacyProtocolVersion;
public class DebugSettings extends SettingGroup {
public final static DebugSettings INSTANCE = new DebugSettings();
// 1.19 -> 1.18.2
public final ProtocolSyncBooleanSetting disableSequencing = new ProtocolSyncBooleanSetting(this, "Disable sequencing", ProtocolRange.andOlder(ProtocolVersion.v1_18_2));
public final ProtocolSyncBooleanSetting disableSequencing = new ProtocolSyncBooleanSetting(this, Text.translatable("debug.viafabricplus.sequence"), ProtocolRange.andOlder(ProtocolVersion.v1_18_2));
// 1.14 -> 1.13.2
public final ProtocolSyncBooleanSetting smoothOutMerchantScreens = new ProtocolSyncBooleanSetting(this, "Smooth out merchant screens", ProtocolRange.andOlder(ProtocolVersion.v1_13_2));
public final ProtocolSyncBooleanSetting smoothOutMerchantScreens = new ProtocolSyncBooleanSetting(this, Text.translatable("debug.viafabricplus.merchant"), ProtocolRange.andOlder(ProtocolVersion.v1_13_2));
// 1.13 -> 1.12.2
public final ProtocolSyncBooleanSetting executeInputsInSync = new ProtocolSyncBooleanSetting(this, "Execute inputs in sync", ProtocolRange.andOlder(ProtocolVersion.v1_12_2));
public final ProtocolSyncBooleanSetting sneakInstant = new ProtocolSyncBooleanSetting(this, "Sneak instant", new ProtocolRange(ProtocolVersion.v1_12_2, ProtocolVersion.v1_8));
public final ProtocolSyncBooleanSetting executeInputsInSync = new ProtocolSyncBooleanSetting(this, Text.translatable("debug.viafabricplus.postfix"), ProtocolRange.andOlder(ProtocolVersion.v1_12_2));
public final ProtocolSyncBooleanSetting sneakInstant = new ProtocolSyncBooleanSetting(this, Text.translatable("debug.viafabricplus.sneakinstant"), new ProtocolRange(ProtocolVersion.v1_12_2, ProtocolVersion.v1_8));
// 1.12 -> 1.11.1-1.11.2
public final ProtocolSyncBooleanSetting sendOpenInventoryPacket = new ProtocolSyncBooleanSetting(this, "Send open inventory packet", ProtocolRange.andOlder(ProtocolVersion.v1_11_1));
public final ProtocolSyncBooleanSetting sendOpenInventoryPacket = new ProtocolSyncBooleanSetting(this, Text.translatable("debug.viafabricplus.inventory"), ProtocolRange.andOlder(ProtocolVersion.v1_11_1));
// 1.9 -> 1.8.x
public final ProtocolSyncBooleanSetting removeCooldowns = new ProtocolSyncBooleanSetting(this, "Remove cooldowns", ProtocolRange.andOlder(ProtocolVersion.v1_8));
public final ProtocolSyncBooleanSetting sendIdlePacket = new ProtocolSyncBooleanSetting(this, "Send idle packet", new ProtocolRange(ProtocolVersion.v1_8, LegacyProtocolVersion.r1_3_1tor1_3_2));
public final ProtocolSyncBooleanSetting replaceAttributeModifiers = new ProtocolSyncBooleanSetting(this, "Replace attribute modifiers", ProtocolRange.andOlder(ProtocolVersion.v1_8));
public final ProtocolSyncBooleanSetting removeCooldowns = new ProtocolSyncBooleanSetting(this, Text.translatable("debug.viafabricplus.cooldown"), ProtocolRange.andOlder(ProtocolVersion.v1_8));
public final ProtocolSyncBooleanSetting sendIdlePacket = new ProtocolSyncBooleanSetting(this, Text.translatable("debug.viafabricplus.idle"), new ProtocolRange(ProtocolVersion.v1_8, LegacyProtocolVersion.r1_3_1tor1_3_2));
public final ProtocolSyncBooleanSetting replaceAttributeModifiers = new ProtocolSyncBooleanSetting(this, Text.translatable("debug.viafabricplus.attribute"), ProtocolRange.andOlder(ProtocolVersion.v1_8));
// 1.8.x -> 1.7.6
public final ProtocolSyncBooleanSetting replaceSneaking = new ProtocolSyncBooleanSetting(this, "Replace sneaking", ProtocolRange.andOlder(ProtocolVersion.v1_7_6));
public final ProtocolSyncBooleanSetting longSneaking = new ProtocolSyncBooleanSetting(this, "Long sneaking", ProtocolRange.andOlder(ProtocolVersion.v1_7_6));
public final ProtocolSyncBooleanSetting replaceSneaking = new ProtocolSyncBooleanSetting(this, Text.translatable("debug.viafabricplus.replacesneak"), ProtocolRange.andOlder(ProtocolVersion.v1_7_6));
public final ProtocolSyncBooleanSetting longSneaking = new ProtocolSyncBooleanSetting(this, Text.translatable("debug.viafabricplus.longsneak"), ProtocolRange.andOlder(ProtocolVersion.v1_7_6));
// r1_5tor1_5_1 -> r1_4_6tor1_4_7
public final ProtocolSyncBooleanSetting legacyMiningSpeeds = new ProtocolSyncBooleanSetting(this, "Legacy mining speeds", ProtocolRange.andOlder(LegacyProtocolVersion.r1_4_6tor1_4_7));
public final ProtocolSyncBooleanSetting legacyMiningSpeeds = new ProtocolSyncBooleanSetting(this, Text.translatable("debug.viafabricplus.legacypseeds"), ProtocolRange.andOlder(LegacyProtocolVersion.r1_4_6tor1_4_7));
public DebugSettings() {
super("Debug");

View File

@ -20,14 +20,20 @@ package de.florianmichael.viafabricplus.settings.groups;
import de.florianmichael.viafabricplus.settings.base.SettingGroup;
import de.florianmichael.viafabricplus.settings.type_impl.BooleanSetting;
import de.florianmichael.viafabricplus.settings.type_impl.ModeSetting;
import net.minecraft.text.Text;
public class GeneralSettings extends SettingGroup {
public final static GeneralSettings INSTANCE = new GeneralSettings();
public final ModeSetting mainButtonOrientation = new ModeSetting(this, "Main button orientation", "Left; Top", "Right; Top", "Left; Bottom", "Right: Bottom");
public final BooleanSetting removeNotAvailableItemsFromCreativeTab = new BooleanSetting(this, "Remove not available items from creative tab", true);
public final BooleanSetting allowClassicProtocolCommandUsage = new BooleanSetting(this, "Allow classic protocol command usage", true);
public final BooleanSetting automaticallyChangeValuesBasedOnTheCurrentVersion = new BooleanSetting(this, "Automatically change Settings based on the current version", true);
public final ModeSetting mainButtonOrientation = new ModeSetting(this, Text.translatable("general.viafabricplus.main"),
Text.translatable("words.viafabricplus.lt"),
Text.translatable("words.viafabricplus.rt"),
Text.translatable("words.viafabricplus.lb"),
Text.translatable("words.viafabricplus.rb")
);
public final BooleanSetting removeNotAvailableItemsFromCreativeTab = new BooleanSetting(this, Text.translatable("general.viafabricplus.creative"), true);
public final BooleanSetting allowClassicProtocolCommandUsage = new BooleanSetting(this, Text.translatable("general.viafabricplus.classiccommands"), true);
public final BooleanSetting automaticallyChangeValuesBasedOnTheCurrentVersion = new BooleanSetting(this, Text.translatable("general.viafabricplus.protocolsync"), true);
public GeneralSettings() {
super("General");

View File

@ -19,13 +19,14 @@ package de.florianmichael.viafabricplus.settings.groups;
import de.florianmichael.viafabricplus.settings.base.SettingGroup;
import de.florianmichael.viafabricplus.settings.type_impl.BooleanSetting;
import net.minecraft.text.Text;
public class MPPassSettings extends SettingGroup {
public final static MPPassSettings INSTANCE = new MPPassSettings();
public final BooleanSetting useBetaCraftAuthentication = new BooleanSetting(this, "Use BetaCraft authentication", true);
public final BooleanSetting allowViaLegacyToCallJoinServerToVerifySession = new BooleanSetting(this, "Allow ViaLegacy to call joinServer() to verify session", true);
public final BooleanSetting disconnectIfJoinServerCallFails = new BooleanSetting(this, "Disconnect if joinServer() call fails", true);
public final BooleanSetting useBetaCraftAuthentication = new BooleanSetting(this, Text.translatable("mppass.viafabricplus.betacraft"), true);
public final BooleanSetting allowViaLegacyToCallJoinServerToVerifySession = new BooleanSetting(this, Text.translatable("mppass.viafabricplus.verify"), true);
public final BooleanSetting disconnectIfJoinServerCallFails = new BooleanSetting(this, Text.translatable("mppass.viafabricplus.fail"), true);
public MPPassSettings() {
super("MP Pass");

View File

@ -21,36 +21,37 @@ import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
import de.florianmichael.viafabricplus.settings.base.SettingGroup;
import de.florianmichael.viafabricplus.settings.type_impl.ProtocolSyncBooleanSetting;
import de.florianmichael.vialoadingbase.platform.ProtocolRange;
import net.minecraft.text.Text;
import net.raphimc.vialegacy.api.LegacyProtocolVersion;
public class VisualSettings extends SettingGroup {
public final static VisualSettings INSTANCE = new VisualSettings();
// 1.19.2 -> 1.19
public final ProtocolSyncBooleanSetting disableSecureChatWarning = new ProtocolSyncBooleanSetting(this, "Disable secure chat warning", ProtocolRange.andOlder(ProtocolVersion.v1_19));
public final ProtocolSyncBooleanSetting disableSecureChatWarning = new ProtocolSyncBooleanSetting(this, Text.translatable("visual.viafabricplus.secure"), ProtocolRange.andOlder(ProtocolVersion.v1_19));
// 1.19 -> 1.18.2
public final ProtocolSyncBooleanSetting hideSignatureIndicator = new ProtocolSyncBooleanSetting(this, "Hide signature indicator", ProtocolRange.andOlder(ProtocolVersion.v1_18_2));
public final ProtocolSyncBooleanSetting hideSignatureIndicator = new ProtocolSyncBooleanSetting(this, Text.translatable("visual.viafabricplus.indicator"), ProtocolRange.andOlder(ProtocolVersion.v1_18_2));
// 1.16 -> 1.15.2
public final ProtocolSyncBooleanSetting removeNewerFeaturesFromJigsawScreen = new ProtocolSyncBooleanSetting(this, "Remove newer features from Jigsaw screen", ProtocolRange.andOlder(ProtocolVersion.v1_15_2));
public final ProtocolSyncBooleanSetting removeNewerFeaturesFromJigsawScreen = new ProtocolSyncBooleanSetting(this, Text.translatable("visual.viafabricplus.jigsaw"), ProtocolRange.andOlder(ProtocolVersion.v1_15_2));
// 1.13 -> 1.12.2
public final ProtocolSyncBooleanSetting replacePetrifiedOakSlab = new ProtocolSyncBooleanSetting(this, "Replace petrified oak slab", new ProtocolRange(ProtocolVersion.v1_12_2, LegacyProtocolVersion.r1_3_1tor1_3_2));
public final ProtocolSyncBooleanSetting replacePetrifiedOakSlab = new ProtocolSyncBooleanSetting(this, Text.translatable("visual.viafabricplus.stoneslab"), new ProtocolRange(ProtocolVersion.v1_12_2, LegacyProtocolVersion.r1_3_1tor1_3_2));
// 1.9 -> 1.8.x
public final ProtocolSyncBooleanSetting emulateArmorHud = new ProtocolSyncBooleanSetting(this, "Emulate Armor hud", ProtocolRange.andOlder(ProtocolVersion.v1_8));
public final ProtocolSyncBooleanSetting removeNewerFeaturesFromCommandBlockScreen = new ProtocolSyncBooleanSetting(this, "Remove newer features from Command block screen", ProtocolRange.andOlder(ProtocolVersion.v1_8));
public final ProtocolSyncBooleanSetting emulateArmorHud = new ProtocolSyncBooleanSetting(this, Text.translatable("visual.viafabricplus.armor"), ProtocolRange.andOlder(ProtocolVersion.v1_8));
public final ProtocolSyncBooleanSetting removeNewerFeaturesFromCommandBlockScreen = new ProtocolSyncBooleanSetting(this, Text.translatable("visual.viafabricplus.command"), ProtocolRange.andOlder(ProtocolVersion.v1_8));
// r1_0_0tor1_0_1 -> b1_8tob1_8_1
public final ProtocolSyncBooleanSetting replaceHurtSoundWithOOFSound = new ProtocolSyncBooleanSetting(this, "Replace hurt sound with OOF sound", ProtocolRange.andOlder(LegacyProtocolVersion.b1_8tob1_8_1));
public final ProtocolSyncBooleanSetting replaceHurtSoundWithOOFSound = new ProtocolSyncBooleanSetting(this, Text.translatable("visual.viafabricplus.oof"), ProtocolRange.andOlder(LegacyProtocolVersion.b1_8tob1_8_1));
// b1_8tob1_8_1 -> b1_7tob1_7_3
public final ProtocolSyncBooleanSetting removeNewerHudElements = new ProtocolSyncBooleanSetting(this, "Remove newer HUD elements", ProtocolRange.andOlder(LegacyProtocolVersion.b1_7tob1_7_3));
public final ProtocolSyncBooleanSetting removeNewerHudElements = new ProtocolSyncBooleanSetting(this, Text.translatable("visual.viafabricplus.betahud"), ProtocolRange.andOlder(LegacyProtocolVersion.b1_7tob1_7_3));
// a1_0_15 -> c0_28toc0_30
public final ProtocolSyncBooleanSetting replaceCreativeInventory = new ProtocolSyncBooleanSetting(this, "Replace creative inventory", ProtocolRange.andOlder(LegacyProtocolVersion.c0_28toc0_30));
public final ProtocolSyncBooleanSetting oldWalkingAnimation = new ProtocolSyncBooleanSetting(this, "Old walking animation", ProtocolRange.andOlder(LegacyProtocolVersion.c0_28toc0_30));
public final ProtocolSyncBooleanSetting replaceCreativeInventory = new ProtocolSyncBooleanSetting(this, Text.translatable("visual.viafabricplus.classic"), ProtocolRange.andOlder(LegacyProtocolVersion.c0_28toc0_30));
public final ProtocolSyncBooleanSetting oldWalkingAnimation = new ProtocolSyncBooleanSetting(this, Text.translatable("visual.viafabricplus.walkanimation"), ProtocolRange.andOlder(LegacyProtocolVersion.c0_28toc0_30));
public VisualSettings() {
super("Visual");

View File

@ -22,10 +22,12 @@ import de.florianmichael.viafabricplus.screen.settings.AbstractSettingRenderer;
import de.florianmichael.viafabricplus.screen.settings.settingrenderer.BooleanSettingRenderer;
import de.florianmichael.viafabricplus.settings.base.AbstractSetting;
import de.florianmichael.viafabricplus.settings.base.SettingGroup;
import net.minecraft.text.MutableText;
import net.minecraft.text.Text;
public class BooleanSetting extends AbstractSetting<Boolean> {
public BooleanSetting(SettingGroup parent, String name, Boolean defaultValue) {
public BooleanSetting(SettingGroup parent, MutableText name, Boolean defaultValue) {
super(parent, name, defaultValue);
}
@ -36,13 +38,13 @@ public class BooleanSetting extends AbstractSetting<Boolean> {
@Override
public void write(JsonObject object) {
object.addProperty(getName(), getValue());
object.addProperty(getTranslationKey(), getValue());
}
@Override
public void read(JsonObject object) {
if (!object.has(getName())) return;
if (!object.has(getTranslationKey())) return;
setValue(object.get(getName()).getAsBoolean());
setValue(object.get(getTranslationKey()).getAsBoolean());
}
}

View File

@ -22,10 +22,11 @@ import de.florianmichael.viafabricplus.screen.settings.AbstractSettingRenderer;
import de.florianmichael.viafabricplus.screen.settings.settingrenderer.ButtonSettingRenderer;
import de.florianmichael.viafabricplus.settings.base.AbstractSetting;
import de.florianmichael.viafabricplus.settings.base.SettingGroup;
import net.minecraft.text.MutableText;
public class ButtonSetting extends AbstractSetting<Runnable> {
public ButtonSetting(SettingGroup parent, String name, Runnable onClick) {
public ButtonSetting(SettingGroup parent, MutableText name, Runnable onClick) {
super(parent, name, onClick);
}
@ -34,7 +35,7 @@ public class ButtonSetting extends AbstractSetting<Runnable> {
return new ButtonSettingRenderer(this);
}
public String displayValue() {
public MutableText displayValue() {
return getName();
}

View File

@ -22,13 +22,15 @@ import de.florianmichael.viafabricplus.screen.settings.AbstractSettingRenderer;
import de.florianmichael.viafabricplus.screen.settings.settingrenderer.ModeSettingRenderer;
import de.florianmichael.viafabricplus.settings.base.AbstractSetting;
import de.florianmichael.viafabricplus.settings.base.SettingGroup;
import net.minecraft.text.MutableText;
import net.minecraft.text.Text;
import java.util.Arrays;
public class ModeSetting extends AbstractSetting<String> {
private final String[] options;
public class ModeSetting extends AbstractSetting<MutableText> {
private final MutableText[] options;
public ModeSetting(SettingGroup parent, String name, String... options) {
public ModeSetting(SettingGroup parent, MutableText name, MutableText... options) {
super(parent, name, options[0]);
this.options = options;
}
@ -40,14 +42,14 @@ public class ModeSetting extends AbstractSetting<String> {
@Override
public void write(JsonObject object) {
object.addProperty(getName(), getValue());
object.addProperty(getTranslationKey(), Arrays.stream(options).toList().indexOf(getValue()));
}
@Override
public void read(JsonObject object) {
if (!object.has(getName())) return;
if (!object.has(getTranslationKey())) return;
setValue(object.get(getName()).getAsString());
setValue(object.get(getTranslationKey()).getAsInt());
}
public void setValue(int index) {
@ -58,7 +60,7 @@ public class ModeSetting extends AbstractSetting<String> {
return Arrays.stream(options).toList().indexOf(getValue());
}
public String[] getOptions() {
public MutableText[] getOptions() {
return options;
}
}

View File

@ -24,11 +24,12 @@ import de.florianmichael.viafabricplus.settings.base.SettingGroup;
import de.florianmichael.viafabricplus.settings.groups.GeneralSettings;
import de.florianmichael.vialoadingbase.ViaLoadingBase;
import de.florianmichael.vialoadingbase.platform.ProtocolRange;
import net.minecraft.text.MutableText;
public class ProtocolSyncBooleanSetting extends BooleanSetting {
private final ProtocolRange protocolRange;
public ProtocolSyncBooleanSetting(SettingGroup parent, String name, ProtocolRange protocolRange) {
public ProtocolSyncBooleanSetting(SettingGroup parent, MutableText name, ProtocolRange protocolRange) {
super(parent, name, true);
this.protocolRange = protocolRange;
@ -41,14 +42,14 @@ public class ProtocolSyncBooleanSetting extends BooleanSetting {
@Override
public void write(JsonObject object) {
object.addProperty(getName(), getValue());
object.addProperty(getTranslationKey(), getValue());
}
@Override
public void read(JsonObject object) {
if (!object.has(getName())) return;
if (!object.has(getTranslationKey())) return;
setValue(object.get(getName()).getAsBoolean());
setValue(object.get(getTranslationKey()).getAsBoolean());
}
@Override

View File

@ -0,0 +1,50 @@
{
"words.viafabricplus.settings": "Settings",
"words.viafabricplus.on": "On",
"words.viafabricplus.off": "Off",
"words.viafabricplus.lt": "Left; Top",
"words.viafabricplus.rt": "Right; Top",
"words.viafabricplus.lb": "Left; Bottom",
"words.viafabricplus.rb": "Right; Bottom",
"words.viafabricplus.cancel": "Cancel",
"bedrock.viafabricplus.set": "Click to set account for Bedrock edition",
"bridge.viafabricplus.secret": "Show Super Secret Settings",
"bridge.viafabricplus.extrainformation": "Show extra information in Debug Hud",
"bridge.viafabricplus.classicloading": "Show classic loading progress in connect screen",
"debug.viafabricplus.sequence": "Disable sequencing",
"debug.viafabricplus.merchant": "Smooth out merchant screens",
"debug.viafabricplus.postfix": "Execute inputs in sync",
"debug.viafabricplus.sneakinstant": "Sneak instant",
"debug.viafabricplus.inventory": "Send open inventory packet",
"debug.viafabricplus.cooldown": "Remove cooldowns",
"debug.viafabricplus.idle": "Send idle packet",
"debug.viafabricplus.attribute": "Replace attribute modifiers",
"debug.viafabricplus.replacesneak": "Replace sneaking",
"debug.viafabricplus.longsneak": "Long sneaking",
"debug.viafabricplus.legacypseeds": "Legacy mining speeds",
"general.viafabricplus.main": "Main button orientation",
"general.viafabricplus.creative": "Remove not available items from creative tab",
"general.viafabricplus.classiccommands": "Allow classic protocol command usage",
"general.viafabricplus.protocolsync": "Automatically change Settings based on the current version",
"mppass.viafabricplus.betacraft": "Use BetaCraft authentication",
"mppass.viafabricplus.verify": "Allow ViaLegacy to call joinServer() to verify session",
"mppass.viafabricplus.fail": "Disconnect if joinServer() call fails",
"visual.viafabricplus.secure": "Disable secure chat warning",
"visual.viafabricplus.indicator": "Hide signature indicator",
"visual.viafabricplus.jigsaw": "Remove newer features from Jigsaw screen",
"visual.viafabricplus.stoneslab": "Replace petrified oak slab",
"visual.viafabricplus.armor": "Emulate Armor hud",
"visual.viafabricplus.command": "Remove newer features from Command block screen",
"visual.viafabricplus.oof": "Replace hurt sound with OOF sound",
"visual.viafabricplus.betahud": "Remove newer HUD elements",
"visual.viafabricplus.classic": "Replace creative inventory",
"visual.viafabricplus.walkanimation": "Old walking animation",
"bedrocklogin.viafabricplus.text": "Your browser should have opened.\nPlease enter the following Code: %s\nClosing this screen will cancel the process!"
}