From c8d6cf413e3a5f19b3bdef89e2fd45a93742c826 Mon Sep 17 00:00:00 2001 From: FlorianMichael Date: Sat, 7 Dec 2024 00:45:41 +0100 Subject: [PATCH] Remove usages of var, brackets around returns --- .../viafabricplus/fixes/ClientsideFixes.java | 2 +- .../data/recipe/AddBannerPatternRecipe.java | 4 +++- .../fixes/data/recipe/Recipes1_11_2.java | 15 +++++++++------ .../ClientPlayerInteractionManager1_18_2.java | 13 ++++++++----- .../versioned/classic/WorldHeightSupport.java | 12 +++++++++--- .../base/integration/MixinConnectScreen_1.java | 7 +++++-- .../minecraft/entity/MixinPlayerEntity.java | 8 ++++++-- .../minecraft/screen/MixinConnectScreen_1.java | 5 +++-- .../screen/MixinGameModeSelectionScreen.java | 9 +++++---- .../MixinMerchantScreenHandler.java | 16 ++++++++++++---- .../viaversion/MixinItemPacketRewriter1_9.java | 16 ++++++++++++---- .../viaversion/MixinWorldPacketRewriter1_19.java | 2 +- .../protocoltranslator/ProtocolTranslator.java | 8 +++++--- .../command/ViaFabricPlusVLCommandHandler.java | 2 +- .../ViaFabricPlusGameProfileFetcher.java | 12 ++++++++---- .../vialegacy/ViaFabricPlusOldAuthProvider.java | 8 +++++--- .../viafabricplus/screen/VFPListEntry.java | 5 +++-- .../screen/classic4j/BetaCraftScreen.java | 4 +++- .../classic4j/ClassiCubeServerListScreen.java | 7 ++++--- .../settings/impl/BedrockSettings.java | 2 +- 20 files changed, 104 insertions(+), 53 deletions(-) diff --git a/src/main/java/de/florianmichael/viafabricplus/fixes/ClientsideFixes.java b/src/main/java/de/florianmichael/viafabricplus/fixes/ClientsideFixes.java index 8391e4fa..5e53a8f6 100644 --- a/src/main/java/de/florianmichael/viafabricplus/fixes/ClientsideFixes.java +++ b/src/main/java/de/florianmichael/viafabricplus/fixes/ClientsideFixes.java @@ -205,7 +205,7 @@ public class ClientsideFixes { if (PENDING_EXECUTION_TASKS.containsKey(uuid)) { MinecraftClient.getInstance().execute(() -> { // Execute the task on the main thread - final var task = PENDING_EXECUTION_TASKS.remove(uuid); + final Consumer task = PENDING_EXECUTION_TASKS.remove(uuid); task.accept(new RegistryByteBuf(buf, MinecraftClient.getInstance().getNetworkHandler().getRegistryManager())); }); } diff --git a/src/main/java/de/florianmichael/viafabricplus/fixes/data/recipe/AddBannerPatternRecipe.java b/src/main/java/de/florianmichael/viafabricplus/fixes/data/recipe/AddBannerPatternRecipe.java index 865f40ec..4c40d815 100644 --- a/src/main/java/de/florianmichael/viafabricplus/fixes/data/recipe/AddBannerPatternRecipe.java +++ b/src/main/java/de/florianmichael/viafabricplus/fixes/data/recipe/AddBannerPatternRecipe.java @@ -21,6 +21,7 @@ package de.florianmichael.viafabricplus.fixes.data.recipe; import com.viaversion.viaversion.api.protocol.version.ProtocolVersion; import de.florianmichael.viafabricplus.protocoltranslator.ProtocolTranslator; +import net.minecraft.block.entity.BannerPattern; import net.minecraft.component.DataComponentTypes; import net.minecraft.component.type.BannerPatternsComponent; import net.minecraft.item.BannerItem; @@ -33,6 +34,7 @@ import net.minecraft.recipe.book.CraftingRecipeCategory; import net.minecraft.recipe.input.CraftingRecipeInput; import net.minecraft.registry.RegistryKeys; import net.minecraft.registry.RegistryWrapper; +import net.minecraft.registry.entry.RegistryEntry; import net.minecraft.util.DyeColor; import net.minecraft.world.World; @@ -75,7 +77,7 @@ public class AddBannerPatternRecipe extends SpecialCraftingRecipe { final BannerPattern_1_13_2 pattern = getBannerPattern(input); if (pattern != null) { - final var patternKey = lookup.getOrThrow(RegistryKeys.BANNER_PATTERN).getOrThrow(pattern.getKey()); + final RegistryEntry.Reference patternKey = lookup.getOrThrow(RegistryKeys.BANNER_PATTERN).getOrThrow(pattern.getKey()); DyeColor color = ProtocolTranslator.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_12_2) ? DyeColor.BLACK : DyeColor.WHITE; for (int i = 0; i < input.size(); i++) { Item item = input.getStackInSlot(i).getItem(); diff --git a/src/main/java/de/florianmichael/viafabricplus/fixes/data/recipe/Recipes1_11_2.java b/src/main/java/de/florianmichael/viafabricplus/fixes/data/recipe/Recipes1_11_2.java index ee909897..8db1b15a 100644 --- a/src/main/java/de/florianmichael/viafabricplus/fixes/data/recipe/Recipes1_11_2.java +++ b/src/main/java/de/florianmichael/viafabricplus/fixes/data/recipe/Recipes1_11_2.java @@ -23,6 +23,8 @@ import com.viaversion.viaversion.api.protocol.version.ProtocolVersion; import de.florianmichael.viafabricplus.protocoltranslator.ProtocolTranslator; import net.minecraft.block.Blocks; import net.minecraft.client.MinecraftClient; +import net.minecraft.client.network.ClientPlayNetworkHandler; +import net.minecraft.client.world.ClientWorld; import net.minecraft.inventory.RecipeInputInventory; import net.minecraft.item.ItemConvertible; import net.minecraft.item.ItemStack; @@ -30,6 +32,7 @@ import net.minecraft.item.Items; import net.minecraft.network.packet.s2c.play.ScreenHandlerSlotUpdateS2CPacket; import net.minecraft.recipe.*; import net.minecraft.recipe.book.CraftingRecipeCategory; +import net.minecraft.recipe.input.CraftingRecipeInput; import net.minecraft.registry.RegistryKey; import net.minecraft.registry.RegistryKeys; import net.minecraft.screen.ScreenHandler; @@ -729,13 +732,13 @@ public class Recipes1_11_2 { */ @ApiStatus.Internal public static void setCraftingResultSlot(final int syncId, final ScreenHandler screenHandler, final RecipeInputInventory inventory) { - final var network = MinecraftClient.getInstance().getNetworkHandler(); - final var world = MinecraftClient.getInstance().world; - final var craftingRecipeInput = inventory.createRecipeInput(); + final ClientPlayNetworkHandler network = MinecraftClient.getInstance().getNetworkHandler(); + final ClientWorld world = MinecraftClient.getInstance().world; + final CraftingRecipeInput input = inventory.createRecipeInput(); - final var result = getRecipeManager() - .getFirstMatch(RecipeType.CRAFTING, craftingRecipeInput, world) // Get the first matching recipe - .map(recipe -> recipe.value().craft(craftingRecipeInput, network.getRegistryManager())) // Craft the recipe to get the result + final ItemStack result = getRecipeManager() + .getFirstMatch(RecipeType.CRAFTING, input, world) // Get the first matching recipe + .map(recipe -> recipe.value().craft(input, network.getRegistryManager())) // Craft the recipe to get the result .orElse(ItemStack.EMPTY); // If there is no recipe, set the result to air // Update the result slot diff --git a/src/main/java/de/florianmichael/viafabricplus/fixes/versioned/ClientPlayerInteractionManager1_18_2.java b/src/main/java/de/florianmichael/viafabricplus/fixes/versioned/ClientPlayerInteractionManager1_18_2.java index b8daa036..27ed5c0f 100644 --- a/src/main/java/de/florianmichael/viafabricplus/fixes/versioned/ClientPlayerInteractionManager1_18_2.java +++ b/src/main/java/de/florianmichael/viafabricplus/fixes/versioned/ClientPlayerInteractionManager1_18_2.java @@ -27,6 +27,7 @@ import net.minecraft.block.Block; import net.minecraft.block.BlockState; import net.minecraft.client.MinecraftClient; import net.minecraft.client.network.ClientPlayerEntity; +import net.minecraft.client.world.ClientWorld; import net.minecraft.network.packet.c2s.play.PlayerActionC2SPacket; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.Vec2f; @@ -50,13 +51,15 @@ public class ClientPlayerInteractionManager1_18_2 { } public void handleBlockBreakAck(final BlockPos blockPos, final BlockState expectedState, final PlayerActionC2SPacket.Action action, final boolean allGood) { - final var player = MinecraftClient.getInstance().player; - if (player == null) return; + final ClientPlayerEntity player = MinecraftClient.getInstance().player; + if (player == null) { + return; + } - final var world = MinecraftClient.getInstance().getNetworkHandler().getWorld(); + final ClientWorld world = MinecraftClient.getInstance().getNetworkHandler().getWorld(); - final var oldPlayerState = unAckedActions.remove(Pair.of(blockPos, action)); - final var actualState = world.getBlockState(blockPos); + final Pair oldPlayerState = unAckedActions.remove(Pair.of(blockPos, action)); + final BlockState actualState = world.getBlockState(blockPos); if ((oldPlayerState == null || !allGood || action != PlayerActionC2SPacket.Action.START_DESTROY_BLOCK && actualState != expectedState) && (actualState != expectedState || ProtocolTranslator.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_15_2))) { world.setBlockState(blockPos, expectedState, Block.NOTIFY_ALL | Block.FORCE_STATE); diff --git a/src/main/java/de/florianmichael/viafabricplus/fixes/versioned/classic/WorldHeightSupport.java b/src/main/java/de/florianmichael/viafabricplus/fixes/versioned/classic/WorldHeightSupport.java index 97cd4597..e1384631 100644 --- a/src/main/java/de/florianmichael/viafabricplus/fixes/versioned/classic/WorldHeightSupport.java +++ b/src/main/java/de/florianmichael/viafabricplus/fixes/versioned/classic/WorldHeightSupport.java @@ -44,7 +44,9 @@ public class WorldHeightSupport { public static PacketHandler handleJoinGame(final PacketHandler parentHandler) { return wrapper -> { parentHandler.handle(wrapper); - if (wrapper.isCancelled()) return; + if (wrapper.isCancelled()) { + return; + } if (wrapper.user().getProtocolInfo().serverProtocolVersion().olderThanOrEqualTo(LegacyProtocolVersion.c0_28toc0_30)) { for (CompoundTag dimension : wrapper.get(Types.NAMED_COMPOUND_TAG, 0).getCompoundTag("minecraft:dimension_type").getListTag("value", CompoundTag.class)) { @@ -58,7 +60,9 @@ public class WorldHeightSupport { public static PacketHandler handleRespawn(final PacketHandler parentHandler) { return wrapper -> { parentHandler.handle(wrapper); - if (wrapper.isCancelled()) return; + if (wrapper.isCancelled()) { + return; + } if (wrapper.user().getProtocolInfo().serverProtocolVersion().olderThanOrEqualTo(LegacyProtocolVersion.c0_28toc0_30)) { changeDimensionTagHeight(wrapper.user(), wrapper.get(Types.NAMED_COMPOUND_TAG, 0)); @@ -69,7 +73,9 @@ public class WorldHeightSupport { public static PacketHandler handleChunkData(final PacketHandler parentHandler) { return wrapper -> { parentHandler.handle(wrapper); - if (wrapper.isCancelled()) return; + if (wrapper.isCancelled()) { + return; + } if (wrapper.user().getProtocolInfo().serverProtocolVersion().olderThanOrEqualTo(LegacyProtocolVersion.c0_28toc0_30)) { wrapper.resetReader(); diff --git a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/base/integration/MixinConnectScreen_1.java b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/base/integration/MixinConnectScreen_1.java index a40c06c5..443918f2 100644 --- a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/base/integration/MixinConnectScreen_1.java +++ b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/base/integration/MixinConnectScreen_1.java @@ -22,6 +22,7 @@ package de.florianmichael.viafabricplus.injection.mixin.base.integration; import com.llamalad7.mixinextras.injector.wrapoperation.Operation; import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation; import com.viaversion.viaversion.api.protocol.version.ProtocolVersion; +import de.florianmichael.classic4j.model.classicube.account.CCAccount; import de.florianmichael.viafabricplus.ViaFabricPlus; import de.florianmichael.viafabricplus.injection.access.IServerInfo; import de.florianmichael.viafabricplus.protocoltranslator.ProtocolTranslator; @@ -83,8 +84,10 @@ public abstract class MixinConnectScreen_1 { @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 var account = ViaFabricPlus.global().getSaveManager().getAccountsSave().getClassicubeAccount(); - if (account != null) return account.username(); + final CCAccount account = ViaFabricPlus.global().getSaveManager().getAccountsSave().getClassicubeAccount(); + if (account != null) { + return account.username(); + } } return instance.getUsername(); } diff --git a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/entity/MixinPlayerEntity.java b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/entity/MixinPlayerEntity.java index c71547e7..af33218f 100644 --- a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/entity/MixinPlayerEntity.java +++ b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/entity/MixinPlayerEntity.java @@ -204,7 +204,9 @@ public abstract class MixinPlayerEntity extends LivingEntity { final boolean hasMiningFatigue = instance.hasStatusEffect(statusEffect); if (hasMiningFatigue && ProtocolTranslator.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_7_6)) { f.set(f.get() * (1.0F - (this.getStatusEffect(StatusEffects.MINING_FATIGUE).getAmplifier() + 1) * 0.2F)); - if (f.get() < 0) f.set(0); + if (f.get() < 0) { + f.set(0); + } return false; // disable original code } return hasMiningFatigue; @@ -213,7 +215,9 @@ public abstract class MixinPlayerEntity extends LivingEntity { @Inject(method = "getBlockBreakingSpeed", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/effect/StatusEffectUtil;hasHaste(Lnet/minecraft/entity/LivingEntity;)Z", shift = At.Shift.BEFORE)) private void changeSpeedCalculation(BlockState block, CallbackInfoReturnable cir, @Local LocalFloatRef f) { final float efficiency = (float) this.getAttributeValue(EntityAttributes.MINING_EFFICIENCY); - if (efficiency <= 0) return; + if (efficiency <= 0) { + return; + } final float speed = this.inventory.getBlockBreakingSpeed(block); if (ProtocolTranslator.getTargetVersion().olderThanOrEqualTo(LegacyProtocolVersion.r1_4_4tor1_4_5) && this.canHarvest(block)) { diff --git a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/screen/MixinConnectScreen_1.java b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/screen/MixinConnectScreen_1.java index f4459835..2f10c9ef 100644 --- a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/screen/MixinConnectScreen_1.java +++ b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/screen/MixinConnectScreen_1.java @@ -35,6 +35,7 @@ import net.minecraft.network.ClientConnection; import net.minecraft.network.encryption.PlayerKeyPair; import net.minecraft.network.encryption.PlayerPublicKey; import net.raphimc.minecraftauth.step.bedrock.StepMCChain; +import net.raphimc.minecraftauth.step.bedrock.session.StepFullBedrockSession; import net.raphimc.viabedrock.api.BedrockProtocolVersion; import net.raphimc.viabedrock.protocol.storage.AuthChainData; import org.spongepowered.asm.mixin.Final; @@ -93,7 +94,7 @@ public abstract class MixinConnectScreen_1 { userConnection.put(new ChatSession1_19_1(uuid, privateKey, new ProfileKey(expiresAt, publicKey, publicKeyData.keySignature()))); if (ProtocolTranslator.getTargetVersion() == ProtocolVersion.v1_19) { - final var legacyKeySignature = ((ILegacyKeySignatureStorage) (Object) publicKeyData).viafabricplus$getLegacyPublicKeySignature(); + final byte[] legacyKeySignature = ((ILegacyKeySignatureStorage) (Object) publicKeyData).viafabricplus$getLegacyPublicKeySignature(); if (legacyKeySignature != null) { userConnection.put(new ChatSession1_19_0(uuid, privateKey, new ProfileKey(expiresAt, publicKey, legacyKeySignature))); } @@ -102,7 +103,7 @@ public abstract class MixinConnectScreen_1 { ViaFabricPlus.global().getLogger().error("Could not get public key signature. Joining servers with enforce-secure-profiles enabled will not work!"); } } else if (ProtocolTranslator.getTargetVersion() == BedrockProtocolVersion.bedrockLatest) { - final var bedrockSession = ViaFabricPlus.global().getSaveManager().getAccountsSave().refreshAndGetBedrockAccount(); + final StepFullBedrockSession.FullBedrockSession bedrockSession = ViaFabricPlus.global().getSaveManager().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/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/screen/MixinGameModeSelectionScreen.java b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/screen/MixinGameModeSelectionScreen.java index 18c0a8b3..f404ea39 100644 --- a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/screen/MixinGameModeSelectionScreen.java +++ b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/screen/MixinGameModeSelectionScreen.java @@ -33,6 +33,7 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import java.util.ArrayList; import java.util.Arrays; +import java.util.List; @Mixin(GameModeSelectionScreen.class) public abstract class MixinGameModeSelectionScreen extends Screen { @@ -52,14 +53,14 @@ public abstract class MixinGameModeSelectionScreen extends Screen { @Inject(method = "", at = @At("RETURN")) private void fixUIWidth(CallbackInfo ci) { if (ProtocolTranslator.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_7_6)) { - final var gameModeSelections = new ArrayList<>(Arrays.stream(GameModeSelectionScreen.GameModeSelection.values()).toList()); + final List selections = new ArrayList<>(Arrays.stream(GameModeSelectionScreen.GameModeSelection.values()).toList()); - gameModeSelections.remove(GameModeSelectionScreen.GameModeSelection.SPECTATOR); + selections.remove(GameModeSelectionScreen.GameModeSelection.SPECTATOR); if (ProtocolTranslator.getTargetVersion().olderThanOrEqualTo(LegacyProtocolVersion.r1_2_4tor1_2_5)) { - gameModeSelections.remove(GameModeSelectionScreen.GameModeSelection.ADVENTURE); + selections.remove(GameModeSelectionScreen.GameModeSelection.ADVENTURE); } - viaFabricPlus$unwrappedGameModes = gameModeSelections.toArray(GameModeSelectionScreen.GameModeSelection[]::new); + viaFabricPlus$unwrappedGameModes = selections.toArray(GameModeSelectionScreen.GameModeSelection[]::new); UI_WIDTH = viaFabricPlus$unwrappedGameModes.length * 31 - 5; } } diff --git a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/screen/screenhandler/MixinMerchantScreenHandler.java b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/screen/screenhandler/MixinMerchantScreenHandler.java index 0f6d08ad..133e0e7e 100644 --- a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/screen/screenhandler/MixinMerchantScreenHandler.java +++ b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/minecraft/screen/screenhandler/MixinMerchantScreenHandler.java @@ -63,7 +63,9 @@ public abstract class MixinMerchantScreenHandler extends ScreenHandler { if (ProtocolTranslator.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_13_2)) { ci.cancel(); - if (recipeId >= this.getRecipes().size()) return; + if (recipeId >= this.getRecipes().size()) { + return; + } final ClientPlayerInteractionManager interactionManager = MinecraftClient.getInstance().interactionManager; final ClientPlayerEntity player = MinecraftClient.getInstance().player; @@ -72,14 +74,18 @@ public abstract class MixinMerchantScreenHandler extends ScreenHandler { if (!this.merchantInventory.getStack(0).isEmpty()) { final int count = this.merchantInventory.getStack(0).getCount(); interactionManager.clickSlot(syncId, 0, 0, SlotActionType.QUICK_MOVE, player); - if (count == this.merchantInventory.getStack(0).getCount()) return; + if (count == this.merchantInventory.getStack(0).getCount()) { + return; + } } // move 2nd input slot to inventory if (!this.merchantInventory.getStack(1).isEmpty()) { final int count = this.merchantInventory.getStack(1).getCount(); interactionManager.clickSlot(syncId, 1, 0, SlotActionType.QUICK_MOVE, player); - if (count == this.merchantInventory.getStack(1).getCount()) return; + if (count == this.merchantInventory.getStack(1).getCount()) { + return; + } } // refill the slots @@ -110,7 +116,9 @@ public abstract class MixinMerchantScreenHandler extends ScreenHandler { } } } - if (slot == 39) return; + if (slot == 39) { + return; + } final boolean wasHoldingItem = !player.currentScreenHandler.getCursorStack().isEmpty(); interactionManager.clickSlot(syncId, slot, 0, SlotActionType.PICKUP, player); diff --git a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/viaversion/MixinItemPacketRewriter1_9.java b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/viaversion/MixinItemPacketRewriter1_9.java index b367b3c1..499953fe 100644 --- a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/viaversion/MixinItemPacketRewriter1_9.java +++ b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/viaversion/MixinItemPacketRewriter1_9.java @@ -84,7 +84,9 @@ public abstract class MixinItemPacketRewriter1_9 extends ItemRewriter cir) { final Item item = cir.getReturnValue(); - if (item == null) return; + if (item == null) { + return; + } final String identifier = viaFabricPlus$itemIdentifiers.get(item.identifier()); if (identifier != null && viaFabricPlus$itemAttributes.containsKey(identifier)) { @@ -121,11 +123,17 @@ public abstract class MixinItemPacketRewriter1_9 extends ItemRewriter cir) { final Item item = cir.getReturnValue(); - if (item == null) return; + if (item == null) { + return; + } final CompoundTag tag = item.tag(); - if (tag == null) return; + if (tag == null) { + return; + } final CompoundTag attributeFixTag = tag.removeUnchecked(nbtTagName("attributeFix")); - if (attributeFixTag == null) return; + if (attributeFixTag == null) { + return; + } if (attributeFixTag.contains("RemoveAttributeModifiers")) { tag.remove("AttributeModifiers"); diff --git a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/viaversion/MixinWorldPacketRewriter1_19.java b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/viaversion/MixinWorldPacketRewriter1_19.java index 37ee2385..3769d327 100644 --- a/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/viaversion/MixinWorldPacketRewriter1_19.java +++ b/src/main/java/de/florianmichael/viafabricplus/injection/mixin/fixes/viaversion/MixinWorldPacketRewriter1_19.java @@ -51,7 +51,7 @@ public abstract class MixinWorldPacketRewriter1_19 { final PlayerActionC2SPacket.Action action = data.readEnumConstant(PlayerActionC2SPacket.Action.class); final boolean allGood = data.readBoolean(); - final var mixinInteractionManager = (IClientPlayerInteractionManager) MinecraftClient.getInstance().interactionManager; + final IClientPlayerInteractionManager mixinInteractionManager = (IClientPlayerInteractionManager) MinecraftClient.getInstance().interactionManager; mixinInteractionManager.viaFabricPlus$get1_18_2InteractionManager().handleBlockBreakAck(pos, blockState, action, allGood); } catch (Throwable t) { throw new RuntimeException("Failed to handle BlockBreakAck packet data", t); diff --git a/src/main/java/de/florianmichael/viafabricplus/protocoltranslator/ProtocolTranslator.java b/src/main/java/de/florianmichael/viafabricplus/protocoltranslator/ProtocolTranslator.java index a1f65355..f82378f5 100644 --- a/src/main/java/de/florianmichael/viafabricplus/protocoltranslator/ProtocolTranslator.java +++ b/src/main/java/de/florianmichael/viafabricplus/protocoltranslator/ProtocolTranslator.java @@ -195,7 +195,9 @@ public class ProtocolTranslator { * @param revertOnDisconnect if true, the previous version will be set when the player disconnects from the server */ public static void setTargetVersion(final ProtocolVersion newVersion, final boolean revertOnDisconnect) { - if (newVersion == null) return; + if (newVersion == null) { + return; + } final ProtocolVersion oldVersion = targetVersion; targetVersion = newVersion; @@ -331,8 +333,8 @@ public class ProtocolTranslator { // Register command callback for /viafabricplus ClientCommandRegistrationCallback.EVENT.register((dispatcher, registryAccess) -> { - final var commandHandler = (ViaFabricPlusVLCommandHandler) Via.getManager().getCommandHandler(); - final var executor = RequiredArgumentBuilder.argument("args", StringArgumentType.greedyString()).executes(commandHandler::execute).suggests(commandHandler::suggestion); + final ViaFabricPlusVLCommandHandler commandHandler = (ViaFabricPlusVLCommandHandler) Via.getManager().getCommandHandler(); + final RequiredArgumentBuilder executor = RequiredArgumentBuilder.argument("args", StringArgumentType.greedyString()).executes(commandHandler::execute).suggests(commandHandler::suggestion); dispatcher.register(LiteralArgumentBuilder.literal("viafabricplus").then(executor).executes(commandHandler::execute)); }); diff --git a/src/main/java/de/florianmichael/viafabricplus/protocoltranslator/impl/command/ViaFabricPlusVLCommandHandler.java b/src/main/java/de/florianmichael/viafabricplus/protocoltranslator/impl/command/ViaFabricPlusVLCommandHandler.java index 5a8d1415..9d6b3e63 100644 --- a/src/main/java/de/florianmichael/viafabricplus/protocoltranslator/impl/command/ViaFabricPlusVLCommandHandler.java +++ b/src/main/java/de/florianmichael/viafabricplus/protocoltranslator/impl/command/ViaFabricPlusVLCommandHandler.java @@ -65,7 +65,7 @@ public class ViaFabricPlusVLCommandHandler extends VLCommandHandler { final String prefix = String.join(" ", pref); onTabComplete(new ViaFabricPlusViaCommandSender(ctx.getSource()), args).stream().map(it -> { - final var b = new SuggestionsBuilder(builder.getInput(), prefix.length() + builder.getStart()); + final SuggestionsBuilder b = new SuggestionsBuilder(builder.getInput(), prefix.length() + builder.getStart()); b.suggest(it); return b; }).forEach(builder::add); diff --git a/src/main/java/de/florianmichael/viafabricplus/protocoltranslator/impl/provider/vialegacy/ViaFabricPlusGameProfileFetcher.java b/src/main/java/de/florianmichael/viafabricplus/protocoltranslator/impl/provider/vialegacy/ViaFabricPlusGameProfileFetcher.java index 691a7a02..91d433a4 100644 --- a/src/main/java/de/florianmichael/viafabricplus/protocoltranslator/impl/provider/vialegacy/ViaFabricPlusGameProfileFetcher.java +++ b/src/main/java/de/florianmichael/viafabricplus/protocoltranslator/impl/provider/vialegacy/ViaFabricPlusGameProfileFetcher.java @@ -23,6 +23,7 @@ import com.mojang.authlib.GameProfileRepository; import com.mojang.authlib.HttpAuthenticationService; import com.mojang.authlib.ProfileLookupCallback; import com.mojang.authlib.minecraft.MinecraftSessionService; +import com.mojang.authlib.properties.Property; import com.mojang.authlib.yggdrasil.ProfileNotFoundException; import com.mojang.authlib.yggdrasil.ProfileResult; import com.mojang.authlib.yggdrasil.YggdrasilAuthenticationService; @@ -30,6 +31,7 @@ import net.raphimc.vialegacy.protocol.release.r1_7_6_10tor1_8.model.GameProfile; import net.raphimc.vialegacy.protocol.release.r1_7_6_10tor1_8.provider.GameProfileFetcher; import java.net.Proxy; +import java.util.Map; import java.util.UUID; import java.util.concurrent.CompletableFuture; @@ -62,12 +64,14 @@ public class ViaFabricPlusGameProfileFetcher extends GameProfileFetcher { @Override public GameProfile loadGameProfile(UUID uuid) { final ProfileResult result = SESSION_SERVICE.fetchProfile(uuid, true); - if (result == null) throw new ProfileNotFoundException(); + if (result == null) { + throw new ProfileNotFoundException(); + } - final var authLibProfile = result.profile(); - final var mcProfile = new GameProfile(authLibProfile.getName(), authLibProfile.getId()); + final com.mojang.authlib.GameProfile authLibProfile = result.profile(); + final GameProfile mcProfile = new GameProfile(authLibProfile.getName(), authLibProfile.getId()); - for (final var entry : authLibProfile.getProperties().entries()) { + for (final Map.Entry entry : authLibProfile.getProperties().entries()) { mcProfile.addProperty(new GameProfile.Property(entry.getValue().name(), entry.getValue().value(), entry.getValue().signature())); } return mcProfile; diff --git a/src/main/java/de/florianmichael/viafabricplus/protocoltranslator/impl/provider/vialegacy/ViaFabricPlusOldAuthProvider.java b/src/main/java/de/florianmichael/viafabricplus/protocoltranslator/impl/provider/vialegacy/ViaFabricPlusOldAuthProvider.java index 81526351..42b12e5d 100644 --- a/src/main/java/de/florianmichael/viafabricplus/protocoltranslator/impl/provider/vialegacy/ViaFabricPlusOldAuthProvider.java +++ b/src/main/java/de/florianmichael/viafabricplus/protocoltranslator/impl/provider/vialegacy/ViaFabricPlusOldAuthProvider.java @@ -32,11 +32,13 @@ public class ViaFabricPlusOldAuthProvider extends OldAuthProvider { @Override public void sendAuthRequest(UserConnection user, String serverId) { - if (!AuthenticationSettings.global().verifySessionForOnlineModeServers.getValue()) return; + if (!AuthenticationSettings.global().verifySessionForOnlineModeServers.getValue()) { + return; + } try { - final var mc = MinecraftClient.getInstance(); - mc.getSessionService().joinServer(mc.getSession().getUuidOrNull(), mc.getSession().getAccessToken(), serverId); + final MinecraftClient client = MinecraftClient.getInstance(); + client.getSessionService().joinServer(client.getSession().getUuidOrNull(), client.getSession().getAccessToken(), serverId); } catch (Exception e) { user.getChannel().attr(ProtocolTranslator.CLIENT_CONNECTION_ATTRIBUTE_KEY).get().disconnect(ChatUtil.prefixText(Text.translatable("betacraft.viafabricplus.failed_to_verify_session"))); ViaFabricPlus.global().getLogger().error("Error occurred while calling join server to verify session", e); diff --git a/src/main/java/de/florianmichael/viafabricplus/screen/VFPListEntry.java b/src/main/java/de/florianmichael/viafabricplus/screen/VFPListEntry.java index 25fd86b3..8f9ead91 100644 --- a/src/main/java/de/florianmichael/viafabricplus/screen/VFPListEntry.java +++ b/src/main/java/de/florianmichael/viafabricplus/screen/VFPListEntry.java @@ -20,6 +20,7 @@ package de.florianmichael.viafabricplus.screen; import net.minecraft.client.MinecraftClient; +import net.minecraft.client.font.TextRenderer; import net.minecraft.client.gui.DrawContext; import net.minecraft.client.gui.widget.AlwaysSelectedEntryListWidget; import net.minecraft.client.util.math.MatrixStack; @@ -74,7 +75,7 @@ public abstract class VFPListEntry extends AlwaysSelectedEntryListWidget.Entry (entryWidth - offset)) { diff --git a/src/main/java/de/florianmichael/viafabricplus/screen/classic4j/BetaCraftScreen.java b/src/main/java/de/florianmichael/viafabricplus/screen/classic4j/BetaCraftScreen.java index 24790bc5..782c77ae 100644 --- a/src/main/java/de/florianmichael/viafabricplus/screen/classic4j/BetaCraftScreen.java +++ b/src/main/java/de/florianmichael/viafabricplus/screen/classic4j/BetaCraftScreen.java @@ -79,7 +79,9 @@ public class BetaCraftScreen extends VFPScreen { public SlotList(MinecraftClient minecraftClient, int width, int height, int top, int bottom, int entryHeight) { super(minecraftClient, width, height, top, bottom, entryHeight); - if (SERVER_LIST == null) return; + if (SERVER_LIST == null) { + return; + } for (BCVersionCategory value : BCVersionCategory.values()) { final List servers = SERVER_LIST.serversOfVersionCategory(value); diff --git a/src/main/java/de/florianmichael/viafabricplus/screen/classic4j/ClassiCubeServerListScreen.java b/src/main/java/de/florianmichael/viafabricplus/screen/classic4j/ClassiCubeServerListScreen.java index 09a42683..c92481be 100644 --- a/src/main/java/de/florianmichael/viafabricplus/screen/classic4j/ClassiCubeServerListScreen.java +++ b/src/main/java/de/florianmichael/viafabricplus/screen/classic4j/ClassiCubeServerListScreen.java @@ -21,6 +21,7 @@ package de.florianmichael.viafabricplus.screen.classic4j; 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 de.florianmichael.viafabricplus.ViaFabricPlus; import de.florianmichael.viafabricplus.protocoltranslator.impl.provider.vialegacy.ViaFabricPlusClassicMPPassProvider; @@ -49,7 +50,7 @@ public 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 var account = ViaFabricPlus.global().getSaveManager().getAccountsSave().getClassicubeAccount(); + final CCAccount account = ViaFabricPlus.global().getSaveManager().getAccountsSave().getClassicubeAccount(); ClassiCubeHandler.requestServerList(account, serverList -> { ClassiCubeServerListScreen.SERVER_LIST.addAll(serverList.servers()); @@ -63,7 +64,7 @@ public class ClassiCubeServerListScreen extends VFPScreen { @Override protected void init() { - final var account = ViaFabricPlus.global().getSaveManager().getAccountsSave().getClassicubeAccount(); + final CCAccount account = ViaFabricPlus.global().getSaveManager().getAccountsSave().getClassicubeAccount(); if (account != null) { this.setupUrlSubtitle(CLASSICUBE_SERVER_LIST_URL); } @@ -83,7 +84,7 @@ public class ClassiCubeServerListScreen extends VFPScreen { public void render(DrawContext context, int mouseX, int mouseY, float delta) { super.render(context, mouseX, mouseY, delta); - final var account = ViaFabricPlus.global().getSaveManager().getAccountsSave().getClassicubeAccount(); + final CCAccount account = ViaFabricPlus.global().getSaveManager().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/de/florianmichael/viafabricplus/settings/impl/BedrockSettings.java b/src/main/java/de/florianmichael/viafabricplus/settings/impl/BedrockSettings.java index c986f574..7f3233ab 100644 --- a/src/main/java/de/florianmichael/viafabricplus/settings/impl/BedrockSettings.java +++ b/src/main/java/de/florianmichael/viafabricplus/settings/impl/BedrockSettings.java @@ -64,7 +64,7 @@ public class BedrockSettings extends SettingGroup { @Override public MutableText displayValue() { - final var account = ViaFabricPlus.global().getSaveManager().getAccountsSave().getBedrockAccount(); + final StepFullBedrockSession.FullBedrockSession account = ViaFabricPlus.global().getSaveManager().getAccountsSave().getBedrockAccount(); if (account != null) { return Text.translatable("click_to_set_bedrock_account.viafabricplus.display", account.getMcChain().getDisplayName()); } else {