From 94471bf96145ce28cfa6be4f10bd092501289136 Mon Sep 17 00:00:00 2001 From: FlorianMichael <60033407+FlorianMichael@users.noreply.github.com> Date: Mon, 27 Nov 2023 19:59:01 +0100 Subject: [PATCH] Code cleanup --- .../viafabricplus/ViaFabricPlus.java | 1 + .../protocolhack/ProtocolHack.java | 3 ++- .../impl/ViaFabricPlusVLLoader.java | 2 +- .../ViaFabricPlusAlphaInventoryProvider.java | 20 +++++++++---------- .../protocolhack/util/ConfigPatcher.java | 2 +- .../settings/impl/DebugSettings.java | 2 +- .../settings/impl/GeneralSettings.java | 2 +- ...viaversion-config.yml => dummy-config.yml} | 0 .../assets/viafabricplus/lang/en_us.json | 2 +- 9 files changed, 17 insertions(+), 17 deletions(-) rename src/main/resources/assets/viafabricplus/{viaversion-config.yml => dummy-config.yml} (100%) diff --git a/src/main/java/de/florianmichael/viafabricplus/ViaFabricPlus.java b/src/main/java/de/florianmichael/viafabricplus/ViaFabricPlus.java index a1dff3a0..05946743 100644 --- a/src/main/java/de/florianmichael/viafabricplus/ViaFabricPlus.java +++ b/src/main/java/de/florianmichael/viafabricplus/ViaFabricPlus.java @@ -93,4 +93,5 @@ public class ViaFabricPlus { public SaveManager getSaveManager() { return saveManager; } + } diff --git a/src/main/java/de/florianmichael/viafabricplus/protocolhack/ProtocolHack.java b/src/main/java/de/florianmichael/viafabricplus/protocolhack/ProtocolHack.java index 38262040..b20cbe8a 100644 --- a/src/main/java/de/florianmichael/viafabricplus/protocolhack/ProtocolHack.java +++ b/src/main/java/de/florianmichael/viafabricplus/protocolhack/ProtocolHack.java @@ -48,6 +48,7 @@ import net.fabricmc.fabric.api.client.command.v2.FabricClientCommandSource; import net.minecraft.client.MinecraftClient; import net.minecraft.client.network.ClientPlayNetworkHandler; import net.minecraft.network.ClientConnection; +import net.raphimc.viabedrock.protocol.data.ProtocolConstants; import net.raphimc.vialoader.ViaLoader; import net.raphimc.vialoader.impl.platform.ViaAprilFoolsPlatformImpl; import net.raphimc.vialoader.impl.platform.ViaBackwardsPlatformImpl; @@ -101,7 +102,7 @@ public class ProtocolHack { channel.attr(ProtocolHack.TARGET_VERSION_ATTRIBUTE_KEY).set(serverVersion); if (VersionEnum.bedrockLatest.equals(serverVersion)) { - channel.config().setOption(RakChannelOption.RAK_PROTOCOL_VERSION, 11); + channel.config().setOption(RakChannelOption.RAK_PROTOCOL_VERSION, ProtocolConstants.BEDROCK_RAKNET_PROTOCOL_VERSION); channel.config().setOption(RakChannelOption.RAK_CONNECT_TIMEOUT, 4_000L); channel.config().setOption(RakChannelOption.RAK_SESSION_TIMEOUT, 30_000L); channel.config().setOption(RakChannelOption.RAK_GUID, ThreadLocalRandom.current().nextLong()); diff --git a/src/main/java/de/florianmichael/viafabricplus/protocolhack/impl/ViaFabricPlusVLLoader.java b/src/main/java/de/florianmichael/viafabricplus/protocolhack/impl/ViaFabricPlusVLLoader.java index 94438b5f..1a7c6b22 100644 --- a/src/main/java/de/florianmichael/viafabricplus/protocolhack/impl/ViaFabricPlusVLLoader.java +++ b/src/main/java/de/florianmichael/viafabricplus/protocolhack/impl/ViaFabricPlusVLLoader.java @@ -66,7 +66,7 @@ public class ViaFabricPlusVLLoader extends VLLoader { providers.use(GameProfileFetcher.class, new ViaFabricPlusGameProfileFetcher()); providers.use(ClassicMPPassProvider.class, new ViaFabricPlusClassicMPPassProvider()); - providers.use(AlphaInventoryProvider.class, new ViaFabricPlusAlphaInventoryProvider(providers.get(TrackingAlphaInventoryProvider.class))); + providers.use(AlphaInventoryProvider.class, new ViaFabricPlusAlphaInventoryProvider(providers.get(AlphaInventoryProvider.class))); providers.use(NettyPipelineProvider.class, new ViaFabricPlusNettyPipelineProvider()); providers.use(BlobCacheProvider.class, new ViaFabricPlusBlobCacheProvider()); diff --git a/src/main/java/de/florianmichael/viafabricplus/protocolhack/provider/vialegacy/ViaFabricPlusAlphaInventoryProvider.java b/src/main/java/de/florianmichael/viafabricplus/protocolhack/provider/vialegacy/ViaFabricPlusAlphaInventoryProvider.java index fd353a09..5374116a 100644 --- a/src/main/java/de/florianmichael/viafabricplus/protocolhack/provider/vialegacy/ViaFabricPlusAlphaInventoryProvider.java +++ b/src/main/java/de/florianmichael/viafabricplus/protocolhack/provider/vialegacy/ViaFabricPlusAlphaInventoryProvider.java @@ -27,8 +27,6 @@ import net.minecraft.client.MinecraftClient; import net.minecraft.client.network.ClientPlayerEntity; import net.minecraft.item.ItemStack; import net.raphimc.vialegacy.protocols.alpha.protocolb1_0_1_1_1toa1_2_3_5_1_2_6.providers.AlphaInventoryProvider; -import net.raphimc.vialegacy.protocols.alpha.protocolb1_0_1_1_1toa1_2_3_5_1_2_6.providers.TrackingAlphaInventoryProvider; -import net.raphimc.vialegacy.protocols.alpha.protocolb1_0_1_1_1toa1_2_3_5_1_2_6.storage.AlphaInventoryTracker; import net.raphimc.vialoader.util.VersionEnum; import java.util.List; @@ -36,15 +34,15 @@ import java.util.List; import static net.raphimc.vialegacy.protocols.alpha.protocolb1_0_1_1_1toa1_2_3_5_1_2_6.Protocolb1_0_1_1_1toa1_2_3_5_1_2_6.copyItems; public class ViaFabricPlusAlphaInventoryProvider extends AlphaInventoryProvider { - private final TrackingAlphaInventoryProvider trackingAlphaInventoryProvider; + private final AlphaInventoryProvider alphaInventoryProvider; - public ViaFabricPlusAlphaInventoryProvider(final TrackingAlphaInventoryProvider trackingAlphaInventoryProvider) { - this.trackingAlphaInventoryProvider = trackingAlphaInventoryProvider; + public ViaFabricPlusAlphaInventoryProvider(final AlphaInventoryProvider alphaInventoryProvider) { + this.alphaInventoryProvider = alphaInventoryProvider; } @Override public boolean usesInventoryTracker() { - return !GeneralSettings.global().emulateInventoryActionsInLegacyVersions.getValue(); + return !GeneralSettings.global().emulateInventoryActionsInAlphaVersions.getValue(); } protected Item[] getMinecraftContainerItems(final List trackingItems) { @@ -62,7 +60,7 @@ public class ViaFabricPlusAlphaInventoryProvider extends AlphaInventoryProvider @Override public Item[] getMainInventoryItems(UserConnection user) { if (usesInventoryTracker()) { - return trackingAlphaInventoryProvider.getMainInventoryItems(user); + return alphaInventoryProvider.getMainInventoryItems(user); } else if (getPlayer() == null) { return new Item[37]; } @@ -73,7 +71,7 @@ public class ViaFabricPlusAlphaInventoryProvider extends AlphaInventoryProvider @Override public Item[] getCraftingInventoryItems(UserConnection user) { if (usesInventoryTracker()) { - return trackingAlphaInventoryProvider.getCraftingInventoryItems(user); + return alphaInventoryProvider.getCraftingInventoryItems(user); } else if (getPlayer() == null) { return new Item[4]; } @@ -84,7 +82,7 @@ public class ViaFabricPlusAlphaInventoryProvider extends AlphaInventoryProvider @Override public Item[] getArmorInventoryItems(UserConnection user) { if (usesInventoryTracker()) { - return trackingAlphaInventoryProvider.getArmorInventoryItems(user); + return alphaInventoryProvider.getArmorInventoryItems(user); } else if (getPlayer() == null) { return new Item[4]; } @@ -95,7 +93,7 @@ public class ViaFabricPlusAlphaInventoryProvider extends AlphaInventoryProvider @Override public Item[] getContainerItems(UserConnection user) { if (usesInventoryTracker()) { - return trackingAlphaInventoryProvider.getContainerItems(user); + return alphaInventoryProvider.getContainerItems(user); } else if (getPlayer() == null) { return new Item[37]; } @@ -106,7 +104,7 @@ public class ViaFabricPlusAlphaInventoryProvider extends AlphaInventoryProvider @Override public void addToInventory(UserConnection user, Item item) { if (usesInventoryTracker()) { - trackingAlphaInventoryProvider.addToInventory(user, item); + alphaInventoryProvider.addToInventory(user, item); } else { getPlayer().getInventory().insertStack(ItemTranslator.viaB1_8toMc(item)); } diff --git a/src/main/java/de/florianmichael/viafabricplus/protocolhack/util/ConfigPatcher.java b/src/main/java/de/florianmichael/viafabricplus/protocolhack/util/ConfigPatcher.java index 0a505b9a..6aabdccc 100644 --- a/src/main/java/de/florianmichael/viafabricplus/protocolhack/util/ConfigPatcher.java +++ b/src/main/java/de/florianmichael/viafabricplus/protocolhack/util/ConfigPatcher.java @@ -40,7 +40,7 @@ public class ConfigPatcher extends Config { @Override public URL getDefaultConfigURL() { - return ConfigPatcher.class.getClassLoader().getResource("assets/viafabricplus/viaversion-config.yml"); + return ConfigPatcher.class.getClassLoader().getResource("assets/viafabricplus/dummy-config.yml"); } @Override diff --git a/src/main/java/de/florianmichael/viafabricplus/settings/impl/DebugSettings.java b/src/main/java/de/florianmichael/viafabricplus/settings/impl/DebugSettings.java index 2677b7a2..eade4c0e 100644 --- a/src/main/java/de/florianmichael/viafabricplus/settings/impl/DebugSettings.java +++ b/src/main/java/de/florianmichael/viafabricplus/settings/impl/DebugSettings.java @@ -49,7 +49,7 @@ public class DebugSettings extends SettingGroup { public final VersionedBooleanSetting preventEntityCramming = new VersionedBooleanSetting(this, Text.translatable("debug_settings.viafabricplus.prevent_entity_cramming"), VersionRange.andOlder(VersionEnum.r1_8)); // 1.8.x -> 1.7.6 - public final VersionedBooleanSetting replaceSneaking = new VersionedBooleanSetting(this, Text.translatable("debug_settings.viafabricplus.replace_sneaking"), VersionRange.andOlder(VersionEnum.r1_7_6tor1_7_10)); + public final VersionedBooleanSetting replaceSneaking = new VersionedBooleanSetting(this, Text.translatable("debug_settings.viafabricplus.replace_sneaking"), VersionRange.andOlder(VersionEnum.r1_8)); public final VersionedBooleanSetting longSneaking = new VersionedBooleanSetting(this, Text.translatable("debug_settings.viafabricplus.long_sneaking"), VersionRange.andOlder(VersionEnum.r1_7_6tor1_7_10)); // 1.5/1.5.1 -> 1.4.6/1.4.7 diff --git a/src/main/java/de/florianmichael/viafabricplus/settings/impl/GeneralSettings.java b/src/main/java/de/florianmichael/viafabricplus/settings/impl/GeneralSettings.java index 11a51fdb..43a5f3d6 100644 --- a/src/main/java/de/florianmichael/viafabricplus/settings/impl/GeneralSettings.java +++ b/src/main/java/de/florianmichael/viafabricplus/settings/impl/GeneralSettings.java @@ -56,7 +56,7 @@ public class GeneralSettings extends SettingGroup { Text.translatable("base.viafabricplus.cancel") ); public final BooleanSetting loadSkinsAndSkullsInLegacyVersions = new BooleanSetting(this, Text.translatable("general_settings.viafabricplus.load_skins_and_skulls_in_legacy_versions"), true); - public final BooleanSetting emulateInventoryActionsInLegacyVersions = new BooleanSetting(this, Text.translatable("general_settings.viafabricplus.emulate_inventory_actions_in_legacy_versions"), true); + public final BooleanSetting emulateInventoryActionsInAlphaVersions = new BooleanSetting(this, Text.translatable("general_settings.viafabricplus.emulate_inventory_actions_in_alpha_versions"), true); public GeneralSettings() { super(Text.translatable("setting_group_name.viafabricplus.general")); diff --git a/src/main/resources/assets/viafabricplus/viaversion-config.yml b/src/main/resources/assets/viafabricplus/dummy-config.yml similarity index 100% rename from src/main/resources/assets/viafabricplus/viaversion-config.yml rename to src/main/resources/assets/viafabricplus/dummy-config.yml diff --git a/src/main/resources/assets/viafabricplus/lang/en_us.json b/src/main/resources/assets/viafabricplus/lang/en_us.json index 5cd255bb..9ad79bbb 100644 --- a/src/main/resources/assets/viafabricplus/lang/en_us.json +++ b/src/main/resources/assets/viafabricplus/lang/en_us.json @@ -42,7 +42,7 @@ "general_settings.viafabricplus.show_advertised_server_version": "Show advertised/server version in Multiplayer", "general_settings.viafabricplus.ignore_packet_translation_errors": "Ignore packet translation errors", "general_settings.viafabricplus.load_skins_and_skulls_in_legacy_versions": "Load skins and skulls in legacy versions", - "general_settings.viafabricplus.emulate_inventory_actions_in_legacy_versions": "Emulate inventory actions in legacy versions", + "general_settings.viafabricplus.emulate_inventory_actions_in_alpha_versions": "Emulate inventory actions in alpha versions", "bedrock_settings.viafabricplus.confirm_transfer_server_prompt": "Open prompt GUI to confirm transferring to other servers", "bedrock_settings.viafabricplus.click_to_set_bedrock_account": "Click to set account for Bedrock edition",