goauth

Fabric plugin for enhanced whitelists
git clone git://git.bain.cz/goauth.git
Log | Files | Refs | README | LICENSE

commit 8ec705d7794716a49965ee9776751578abbb1e17
parent 71e10f78010c9b6c0bcf46770464c78a16eefab4
Author: bain <bain@bain.cz>
Date:   Sun, 18 Sep 2022 16:16:30 +0200

update plugin to 1.19

Diffstat:
Mbuild.gradle | 4++--
Mgradle.properties | 10+++++-----
Msrc/main/java/cz/bain/plugins/goauth/AuthUpdateRunner.java | 106+++++++++++++++++++++++++++++++++++++++++--------------------------------------
Msrc/main/java/cz/bain/plugins/goauth/DummyServerPlayNetworkHandler.java | 123+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++------------
Msrc/main/java/cz/bain/plugins/goauth/GoauthConfig.java | 3++-
Msrc/main/java/cz/bain/plugins/goauth/events/listeners/OnPlayerConnectListener.java | 84++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++--------------
Msrc/main/java/cz/bain/plugins/goauth/events/listeners/OnServerTickListener.java | 5++---
Dsrc/main/java/cz/bain/plugins/goauth/mixin/DimensionTypeAccessor.java | 14--------------
Msrc/main/java/cz/bain/plugins/goauth/mixin/PlayerManagerAccessor.java | 2+-
Msrc/main/resources/fabric.mod.json | 6+++---
Msrc/main/resources/goauth.mixins.json | 3+--
11 files changed, 246 insertions(+), 114 deletions(-)

diff --git a/build.gradle b/build.gradle @@ -1,5 +1,5 @@ plugins { - id 'fabric-loom' version '0.10-SNAPSHOT' + id 'fabric-loom' version '1.0-SNAPSHOT' id 'maven-publish' } @@ -36,7 +36,7 @@ processResources { } } -def targetJavaVersion = 16 +def targetJavaVersion = 17 tasks.withType(JavaCompile).configureEach { // ensure that the encoding is set to UTF-8, no matter what the system default is // this fixes some edge cases with special characters not displaying correctly diff --git a/gradle.properties b/gradle.properties @@ -2,13 +2,13 @@ org.gradle.jvmargs=-Xmx1G # Fabric Properties # check these on https://modmuss50.me/fabric.html -minecraft_version=1.18 -yarn_mappings=1.18+build.1 -loader_version=0.12.6 +minecraft_version=1.19.2 +yarn_mappings=1.19.2+build.13 +loader_version=0.14.9 # Mod Properties -mod_version=1.0.1 +mod_version=1.1.1 maven_group=cz.bain.plugins archives_base_name=goauth # Dependencies # check this on https://modmuss50.me/fabric.html -fabric_version=0.43.1+1.18 +fabric_version=0.61.0+1.19.2 diff --git a/src/main/java/cz/bain/plugins/goauth/AuthUpdateRunner.java b/src/main/java/cz/bain/plugins/goauth/AuthUpdateRunner.java @@ -39,61 +39,65 @@ public class AuthUpdateRunner implements Runnable { plugin.logger.error("Failed to create socket for updates!"); return; } - while (this.plugin.running) { - try ( - Socket socket = serverSocket.accept(); - InputStream inputStream = socket.getInputStream(); - OutputStream outputStream = socket.getOutputStream() - ) { - // protecting ourselves from being bombarded with large amounts of data - byte[] sizeBytes = inputStream.readNBytes(4); - if (sizeBytes.length != 4) continue; - int size = fromByteArray(sizeBytes); - if (size > 2048 || size <= 0) { - outputStream.write(0x01); - outputStream.flush(); - plugin.logger.warn("Whitelist update rejected: payload size too big ({})", size); - continue; - } else { - outputStream.write(0x00); - outputStream.flush(); - } - byte[] iv = inputStream.readNBytes(12); - if (iv.length != 12) continue; - byte[] cipherText = inputStream.readNBytes(size); - if (cipherText.length != size) continue; - byte[] plainText; - try { - plainText = decryptMessage(cipherText, iv); - } catch (GeneralSecurityException e) { - plugin.logger.warn("Whitelist update rejected: failed to decrypt payload"); - outputStream.write(0x01); - outputStream.flush(); - continue; - } - JsonArray el = JsonParser.parseString(new String(plainText, StandardCharsets.UTF_8)).getAsJsonArray(); - plugin.logger.info("Got " + el.size() + " new whitelist updates"); - Gson gson = new Gson(); - synchronized (this.plugin.completed) { - for (JsonElement user : el) { - AuthUpdate update; - try { - update = gson.fromJson(user, AuthUpdate.class); - } catch (JsonSyntaxException ignored) { - plugin.logger.warn("Whitelist update rejected: bad update data"); - outputStream.write(0x01); - outputStream.flush(); - break; - } - this.plugin.completed.add(update); + try (serverSocket) { + while (this.plugin.running) { + try ( + Socket socket = serverSocket.accept(); + InputStream inputStream = socket.getInputStream(); + OutputStream outputStream = socket.getOutputStream() + ) { + // protecting ourselves from being bombarded with large amounts of data + byte[] sizeBytes = inputStream.readNBytes(4); + if (sizeBytes.length != 4) continue; + int size = fromByteArray(sizeBytes); + if (size > 2048 || size <= 0) { + outputStream.write(0x01); + outputStream.flush(); + plugin.logger.warn("Whitelist update rejected: payload size too big ({})", size); + continue; + } else { outputStream.write(0x00); + outputStream.flush(); + } + byte[] iv = inputStream.readNBytes(12); + if (iv.length != 12) continue; + byte[] cipherText = inputStream.readNBytes(size); + if (cipherText.length != size) continue; + byte[] plainText; + try { + plainText = decryptMessage(cipherText, iv); + } catch (GeneralSecurityException e) { + plugin.logger.warn("Whitelist update rejected: failed to decrypt payload"); + outputStream.write(0x01); + outputStream.flush(); + continue; } + JsonArray el = JsonParser.parseString(new String(plainText, StandardCharsets.UTF_8)).getAsJsonArray(); + plugin.logger.info("Got " + el.size() + " new whitelist updates"); + Gson gson = new Gson(); + synchronized (this.plugin.completed) { + for (JsonElement user : el) { + AuthUpdate update; + try { + update = gson.fromJson(user, AuthUpdate.class); + } catch (JsonSyntaxException ignored) { + plugin.logger.warn("Whitelist update rejected: bad update data"); + outputStream.write(0x01); + outputStream.flush(); + break; + } + this.plugin.completed.add(update); + outputStream.write(0x00); + } + } + } catch (SocketTimeoutException ignored) { + } catch (IOException | IllegalStateException e) { + plugin.logger.warn("Error while processing OAuth updates, dropping connection"); + e.printStackTrace(); } - } catch (SocketTimeoutException ignored) { - } catch (IOException | IllegalStateException e) { - plugin.logger.warn("Error while processing OAuth updates, dropping connection"); - e.printStackTrace(); } + } catch (IOException e) { + throw new RuntimeException(e); } } diff --git a/src/main/java/cz/bain/plugins/goauth/DummyServerPlayNetworkHandler.java b/src/main/java/cz/bain/plugins/goauth/DummyServerPlayNetworkHandler.java @@ -1,7 +1,7 @@ package cz.bain.plugins.goauth; import net.minecraft.network.ClientConnection; -import net.minecraft.network.MessageType; +import net.minecraft.network.Packet; import net.minecraft.network.packet.c2s.play.*; import net.minecraft.network.packet.s2c.play.GameMessageS2CPacket; import net.minecraft.network.packet.s2c.play.KeepAliveS2CPacket; @@ -9,7 +9,6 @@ import net.minecraft.server.MinecraftServer; import net.minecraft.server.network.ServerPlayNetworkHandler; import net.minecraft.server.network.ServerPlayerEntity; import net.minecraft.text.Text; -import net.minecraft.text.TranslatableText; import net.minecraft.util.Util; import java.util.UUID; @@ -29,7 +28,6 @@ public class DummyServerPlayNetworkHandler extends ServerPlayNetworkHandler { this.plugin = plugin; } - @Override public void tick() { ++this.ticks; @@ -38,13 +36,13 @@ public class DummyServerPlayNetworkHandler extends ServerPlayNetworkHandler { } if (this.ticks > 160 && this.ticks % 40 == 0) - this.sendPacket(new GameMessageS2CPacket(Text.of("Please authenticate in chat"), MessageType.GAME_INFO, new UUID(0, 0))); + this.sendPacket(new GameMessageS2CPacket(Text.of("Please authenticate in chat"), true)); server.getProfiler().push("keepAlive"); long l = Util.getMeasuringTimeMs(); if (l - this.lastKeepAliveTime >= 15000L) { if (this.waitingForKeepAlive) { - this.disconnect(new TranslatableText("disconnect.timeout")); + this.disconnect(Text.translatable("disconnect.timeout")); } else { this.waitingForKeepAlive = true; this.lastKeepAliveTime = l; @@ -63,99 +61,188 @@ public class DummyServerPlayNetworkHandler extends ServerPlayNetworkHandler { this.player.pingMilliseconds = (this.player.pingMilliseconds * 3 + i) / 4; this.waitingForKeepAlive = false; } else { - this.disconnect(new TranslatableText("disconnect.timeout")); + this.disconnect(Text.translatable("disconnect.timeout")); } } @Override public void onDisconnected(Text reason) { - Goauth.LOGGER.info("{} disconnected from limbo", this.player.getName().getString()); + this.plugin.logger.info("{} disconnected from limbo", this.player.getName().getString()); this.player.onDisconnect(); this.player.getTextStream().onDisconnect(); this.plugin.playersLimbo.remove(this.getPlayer().getGameProfile().getName()); } - /* Override most of the methods to do nothing, the player can't do it anyways */ + /* Override rest of the methods to do nothing, the player can't do it anyway */ public void onTeleportConfirm(TeleportConfirmC2SPacket packet) { +// this.plugin.logger.info("packet handler {} triggered", "onTeleportConfirm"); } public void onPlayerMove(PlayerMoveC2SPacket packet) { +// this.plugin.logger.info("packet handler {} triggered", "onPlayerMove"); +// this.plugin.logger.info("{} {}", packet.getX(0), packet.getY(0)); } public void onRecipeBookData(RecipeBookDataC2SPacket packet) { + this.plugin.logger.info("packet handler {} triggered", "onRecipeBookData"); } public void onRecipeCategoryOptions(RecipeCategoryOptionsC2SPacket packet) { + this.plugin.logger.info("packet handler {} triggered", "onRecipeCategoryOptions"); } public void onAdvancementTab(AdvancementTabC2SPacket packet) { + this.plugin.logger.info("packet handler {} triggered", "onAdvancementTab"); } public void onRequestCommandCompletions(RequestCommandCompletionsC2SPacket packet) { + this.plugin.logger.info("packet handler {} triggered", "onRequestCommandCompletions"); } public void onUpdateCommandBlock(UpdateCommandBlockC2SPacket packet) { + this.plugin.logger.info("packet handler {} triggered", "onUpdateCommandBlock"); } public void onUpdateCommandBlockMinecart(UpdateCommandBlockMinecartC2SPacket packet) { + this.plugin.logger.info("packet handler {} triggered", "onUpdateCommandBlockMinecart"); } public void onPickFromInventory(PickFromInventoryC2SPacket packet) { + this.plugin.logger.info("packet handler {} triggered", "onPickFromInventory"); } public void onRenameItem(RenameItemC2SPacket packet) { + this.plugin.logger.info("packet handler {} triggered", "onRenameItem"); } public void onUpdateBeacon(UpdateBeaconC2SPacket packet) { - } - - public void onStructureBlockUpdate(UpdateStructureBlockC2SPacket packet) { - } - - public void onJigsawUpdate(UpdateJigsawC2SPacket packet) { + this.plugin.logger.info("packet handler {} triggered", "onUpdateBeacon"); } public void onJigsawGenerating(JigsawGeneratingC2SPacket packet) { - } - - public void onMerchantTradeSelect(SelectMerchantTradeC2SPacket packet) { + this.plugin.logger.info("packet handler {} triggered", "onJigsawGenerating"); } public void onBookUpdate(BookUpdateC2SPacket packet) { + this.plugin.logger.info("packet handler {} triggered", "onBookUpdate"); } public void onQueryEntityNbt(QueryEntityNbtC2SPacket packet) { + this.plugin.logger.info("packet handler {} triggered", "onQueryEntityNbt"); } public void onQueryBlockNbt(QueryBlockNbtC2SPacket packet) { + this.plugin.logger.info("packet handler {} triggered", "onQueryBlockNbt"); } public void onPlayerAction(PlayerActionC2SPacket packet) { + this.plugin.logger.info("packet handler {} triggered", "onPlayerAction"); } public void onPlayerInteractBlock(PlayerInteractBlockC2SPacket packet) { + this.plugin.logger.info("packet handler {} triggered", "onPlayerInteractBlock"); } public void onPlayerInteractItem(PlayerInteractItemC2SPacket packet) { + this.plugin.logger.info("packet handler {} triggered", "onPlayerInteractItem"); } public void onSpectatorTeleport(SpectatorTeleportC2SPacket packet) { + this.plugin.logger.info("packet handler {} triggered", "onSpectatorTeleport"); } public void onResourcePackStatus(ResourcePackStatusC2SPacket packet) { + this.plugin.logger.info("packet handler {} triggered", "onResourcePackStatus"); } public void onBoatPaddleState(BoatPaddleStateC2SPacket packet) { + this.plugin.logger.info("packet handler {} triggered", "onBoatPaddleState"); } public void onPlayerInput(PlayerInputC2SPacket packet) { + this.plugin.logger.info("packet handler {} triggered", "onPlayerInput"); } public void onVehicleMove(VehicleMoveC2SPacket packet) { + this.plugin.logger.info("packet handler {} triggered", "onVehicleMove"); + } + + public void onUpdateStructureBlock(UpdateStructureBlockC2SPacket packet) { + this.plugin.logger.info("packet handler {} triggered", "onUpdateStructureBlock"); + } + + public void onUpdateJigsaw(UpdateJigsawC2SPacket packet) { + this.plugin.logger.info("packet handler {} triggered", "onUpdateJigsaw"); + } + + public void onUpdateSelectedSlot(UpdateSelectedSlotC2SPacket packet) { + this.plugin.logger.info("packet handler {} triggered", "onUpdateSelectedSlot"); + } + + public void onChatMessage(ChatMessageC2SPacket packet) { + this.plugin.logger.info("packet handler {} triggered", "onChatMessage"); + } + + public void onCommandExecution(CommandExecutionC2SPacket packet) { + this.plugin.logger.info("packet handler {} triggered", "onCommandExecution"); + } + + public void onRequestChatPreview(RequestChatPreviewC2SPacket packet) { + this.plugin.logger.info("packet handler {} triggered", "onRequestChatPreview"); + } + + public void onMessageAcknowledgment(MessageAcknowledgmentC2SPacket packet) { + this.plugin.logger.info("packet handler {} triggered", "onMessageAcknowledgment"); + } + + public void onHandSwing(HandSwingC2SPacket packet) { + this.plugin.logger.info("packet handler {} triggered", "onHandSwing"); + } + + public void onClientCommand(ClientCommandC2SPacket packet) { + this.plugin.logger.info("packet handler {} triggered", "onClientCommand"); + } + + public void onPlayerInteractEntity(PlayerInteractEntityC2SPacket packet) { + this.plugin.logger.info("packet handler {} triggered", "onPlayerInteractEntity"); + } + + public void onClickSlot(ClickSlotC2SPacket packet) { + this.plugin.logger.info("packet handler {} triggered", "onClickSlot"); + } + + public void onCraftRequest(CraftRequestC2SPacket packet) { + this.plugin.logger.info("packet handler {} triggered", "onCraftRequest"); + } + + public void onButtonClick(ButtonClickC2SPacket packet) { + this.plugin.logger.info("packet handler {} triggered", "onButtonClick"); } - public void onGameMessage(ChatMessageC2SPacket packet) { + public void onCreativeInventoryAction(CreativeInventoryActionC2SPacket packet) { + this.plugin.logger.info("packet handler {} triggered", "onCreativeInventoryAction"); } + + public void onUpdateSign(UpdateSignC2SPacket packet) { + this.plugin.logger.info("packet handler {} triggered", "onUpdateSign"); + } + + public void onUpdatePlayerAbilities(UpdatePlayerAbilitiesC2SPacket packet) { + this.plugin.logger.info("packet handler {} triggered", "onUpdatePlayerAbilities"); + } + + public void onUpdateDifficulty(UpdateDifficultyC2SPacket packet) { + this.plugin.logger.info("packet handler {} triggered", "onUpdateDifficulty"); + } + + public void onSelectMerchantTrade(SelectMerchantTradeC2SPacket packet) { + this.plugin.logger.info("packet handler {} triggered", "onSelectMerchantTrade"); + } + + public void onUpdateDifficultyLock(UpdateDifficultyLockC2SPacket packet) { + this.plugin.logger.info("packet handler {} triggered", "onUpdateDifficultyLock"); + } + } \ No newline at end of file diff --git a/src/main/java/cz/bain/plugins/goauth/GoauthConfig.java b/src/main/java/cz/bain/plugins/goauth/GoauthConfig.java @@ -1,6 +1,7 @@ package cz.bain.plugins.goauth; import java.io.*; +import java.util.ArrayList; import java.util.Arrays; import java.util.HashMap; import java.util.List; @@ -19,7 +20,7 @@ public class GoauthConfig { } BufferedReader reader = new BufferedReader(new FileReader(file)); - List<String> required = Arrays.asList("port", "key", "auth-link-text"); + List<String> required = new ArrayList<>(Arrays.asList("port", "key", "auth-link-text")); String line; int line_no = 0; while ((line = reader.readLine()) != null) { diff --git a/src/main/java/cz/bain/plugins/goauth/events/listeners/OnPlayerConnectListener.java b/src/main/java/cz/bain/plugins/goauth/events/listeners/OnPlayerConnectListener.java @@ -2,29 +2,32 @@ package cz.bain.plugins.goauth.events.listeners; import cz.bain.plugins.goauth.DummyServerPlayNetworkHandler; import cz.bain.plugins.goauth.Goauth; -import cz.bain.plugins.goauth.StringRepository; import cz.bain.plugins.goauth.events.callbacks.OnPlayerConnectCallback; -import cz.bain.plugins.goauth.mixin.DimensionTypeAccessor; import cz.bain.plugins.goauth.mixin.PlayerManagerAccessor; import io.netty.buffer.Unpooled; +import net.minecraft.nbt.NbtCompound; +import net.minecraft.nbt.NbtLongArray; import net.minecraft.network.ClientConnection; -import net.minecraft.network.MessageType; import net.minecraft.network.PacketByteBuf; import net.minecraft.network.packet.s2c.play.*; +import net.minecraft.recipe.book.RecipeBookOptions; import net.minecraft.server.MinecraftServer; import net.minecraft.server.network.ServerPlayNetworkHandler; import net.minecraft.server.network.ServerPlayerEntity; +import net.minecraft.tag.TagPacketSerializer; import net.minecraft.text.*; import net.minecraft.util.ActionResult; +import net.minecraft.util.Formatting; +import net.minecraft.util.collection.PackedIntegerArray; import net.minecraft.util.math.BlockPos; +import net.minecraft.util.math.GlobalPos; import net.minecraft.world.Difficulty; import net.minecraft.world.GameMode; import net.minecraft.world.World; import net.minecraft.world.border.WorldBorder; +import net.minecraft.world.dimension.DimensionTypes; -import java.util.Collections; -import java.util.Objects; -import java.util.UUID; +import java.util.*; public class OnPlayerConnectListener implements OnPlayerConnectCallback { @@ -50,23 +53,46 @@ public class OnPlayerConnectListener implements OnPlayerConnectCallback { // fake initial connection info, use DummyServerPlayNetworkHandler to override all events and ignore them ServerPlayNetworkHandler serverPlayNetworkHandler = new DummyServerPlayNetworkHandler(server, connection, player, this.plugin); serverPlayNetworkHandler.sendPacket(new GameJoinS2CPacket( - player.getId(), false, GameMode.SPECTATOR, null, - server.getWorldRegistryKeys(), ((PlayerManagerAccessor) server.getPlayerManager()).getRegistryManager(), - DimensionTypeAccessor.getTHE_END(), World.END, 0, 69, 3, 3, true, false, false, true + player.getId(), + false, + GameMode.SPECTATOR, + GameMode.SPECTATOR, + server.getWorldRegistryKeys(), + ((PlayerManagerAccessor) server.getPlayerManager()).getRegistryManager(), + DimensionTypes.THE_END, + World.END, + 420, + 69, + 3, + 3, + true, + false, + false, + true, + Optional.of(GlobalPos.create(World.END, new BlockPos(0, 0, 0))) )); serverPlayNetworkHandler.sendPacket(new CustomPayloadS2CPacket(CustomPayloadS2CPacket.BRAND, (new PacketByteBuf(Unpooled.buffer())).writeString("limbo"))); serverPlayNetworkHandler.sendPacket(new DifficultyS2CPacket(Difficulty.PEACEFUL, true)); serverPlayNetworkHandler.sendPacket(new PlayerAbilitiesS2CPacket(player.getAbilities())); serverPlayNetworkHandler.sendPacket(new UpdateSelectedSlotS2CPacket(player.getInventory().selectedSlot)); - serverPlayNetworkHandler.sendPacket(new PlayerPositionLookS2CPacket(0, 0, 0, 0, 0, Collections.emptySet(), 0, true)); + serverPlayNetworkHandler.sendPacket(new PlayerPositionLookS2CPacket(0, 0, 0, 0, 0, Collections.emptySet(), 1, true)); serverPlayNetworkHandler.sendPacket(new GameStateChangeS2CPacket(GameStateChangeS2CPacket.GAME_MODE_CHANGED, GameMode.SPECTATOR.getId())); serverPlayNetworkHandler.sendPacket(new WorldBorderInitializeS2CPacket(new WorldBorder())); serverPlayNetworkHandler.sendPacket(new WorldTimeUpdateS2CPacket(0, 0, false)); + + // From 1.19 the client will show a "Loading terrain..." screen until a chunk is sent. + // Unfortunately there is no empty chunk constructor for ChunkDataS2CPacket, + // so we have to create a buffer with the custom empty chunk, and only then create + // the packet from the buffer. + serverPlayNetworkHandler.sendPacket(new ChunkRenderDistanceCenterS2CPacket(0, 0)); + PacketByteBuf buf = new PacketByteBuf(Unpooled.buffer(800)); + writeEmptyChunk(buf, 0, 0); + serverPlayNetworkHandler.sendPacket(new ChunkDataS2CPacket(buf)); + serverPlayNetworkHandler.sendPacket(new PlayerSpawnPositionS2CPacket(new BlockPos(0, 0, 0), 0.0f)); - LiteralText welcomeMsg = new LiteralText("Welcome! Please authenticate: "); - welcomeMsg.setStyle(Style.EMPTY.withBold(true).withColor(TextColor.parse("yellow"))); - LiteralText text = new LiteralText(this.plugin.authLinkText); + MutableText welcomeMsg = Text.literal("Welcome! Please authenticate: ").formatted(Formatting.BOLD, Formatting.YELLOW); + MutableText text = Text.literal(this.plugin.authLinkText); Style urlStyle = Style.EMPTY .withBold(false) .withColor(TextColor.parse("white")) @@ -75,11 +101,41 @@ public class OnPlayerConnectListener implements OnPlayerConnectCallback { .withHoverEvent(!this.plugin.authLink.isEmpty() ? new HoverEvent(HoverEvent.Action.SHOW_TEXT, Text.of("Open link")) : null); text.setStyle(urlStyle); welcomeMsg.append(text); - player.sendMessage(welcomeMsg, MessageType.SYSTEM, new UUID(0, 0)); + player.sendMessage(welcomeMsg); this.plugin.playersLimbo.put(player.getGameProfile().getName(), player); // return completely return ActionResult.FAIL; } + + public void writeEmptyChunk(PacketByteBuf buf, int x, int z) { + // chunk coords + buf.writeInt(x); + buf.writeInt(z); + + // ChunkData + // heightmap + NbtCompound compound = new NbtCompound(); + compound.put("WORLD_SURFACE", new NbtLongArray(new PackedIntegerArray(9, 256).getData())); + compound.put("MOTION_BLOCKING", new NbtLongArray(new PackedIntegerArray(9, 256).getData())); + buf.writeNbt(compound); + + // Write 16 empty chunk sections consisting of + // - 2 bytes of a short (nonEmptyBlockCount) + // - 3 bytes for an empty blockStateContainer + // - 4 bytes for an empty biomeContainer + buf.writeVarInt(16 * 9); + buf.writeZero(16 * 9); + buf.writeVarInt(0); + + // LightData + buf.writeBoolean(true); // nonEdge + buf.writeBitSet(new BitSet()); // initedSky + buf.writeBitSet(new BitSet()); // initedBlock + buf.writeBitSet(new BitSet()); // uninitedSky + buf.writeBitSet(new BitSet()); // uninitedBlock + buf.writeVarInt(0); // skyNibbles array length + buf.writeVarInt(0); // blockNibbles array length + } } diff --git a/src/main/java/cz/bain/plugins/goauth/events/listeners/OnServerTickListener.java b/src/main/java/cz/bain/plugins/goauth/events/listeners/OnServerTickListener.java @@ -9,7 +9,6 @@ import net.minecraft.server.network.ServerPlayerEntity; import net.minecraft.text.Text; import net.minecraft.util.ActionResult; -@SuppressWarnings("ClassCanBeRecord") public class OnServerTickListener implements OnServerTickCallback { private final Goauth plugin; @@ -27,7 +26,7 @@ public class OnServerTickListener implements OnServerTickCallback { case UPDATE -> { ServerPlayerEntity player = this.plugin.playersLimbo.get(update.getUsername()); if (player == null) { - Goauth.LOGGER.info("Cannot authenticate an offline player! {}", update.getUsername()); + this.plugin.logger.info("Cannot authenticate an offline player! {}", update.getUsername()); continue; } this.plugin.authStore.put(player); @@ -35,7 +34,7 @@ public class OnServerTickListener implements OnServerTickCallback { } case REMOVE -> { if (this.plugin.authStore.remove(update.getUsername())) { - Goauth.LOGGER.info("Removed " + update.getUsername() + " from authentication db"); + this.plugin.logger.info("Removed " + update.getUsername() + " from authentication db"); ServerPlayerEntity player = playerManager.getPlayer(update.getUsername()); if (player != null) player.networkHandler.disconnect(Text.of(StringRepository.playerUnregisterKick)); diff --git a/src/main/java/cz/bain/plugins/goauth/mixin/DimensionTypeAccessor.java b/src/main/java/cz/bain/plugins/goauth/mixin/DimensionTypeAccessor.java @@ -1,14 +0,0 @@ -package cz.bain.plugins.goauth.mixin; - -import net.minecraft.world.dimension.DimensionType; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.gen.Accessor; - -@Mixin(DimensionType.class) -public interface DimensionTypeAccessor { - - @Accessor - static DimensionType getTHE_END() { - throw new UnsupportedOperationException(); - } -} diff --git a/src/main/java/cz/bain/plugins/goauth/mixin/PlayerManagerAccessor.java b/src/main/java/cz/bain/plugins/goauth/mixin/PlayerManagerAccessor.java @@ -13,5 +13,5 @@ public interface PlayerManagerAccessor { void callSavePlayerData(ServerPlayerEntity player); @Accessor - DynamicRegistryManager.Impl getRegistryManager(); + DynamicRegistryManager.Immutable getRegistryManager(); } diff --git a/src/main/resources/fabric.mod.json b/src/main/resources/fabric.mod.json @@ -2,8 +2,8 @@ "schemaVersion": 1, "id": "goauth", "version": "${version}", - "name": "GoogleOAuth", - "description": "Implements a Google OAuth whitelist", + "name": "GOAuth", + "description": "Implements an external whitelist", "authors": [ "bain" ], @@ -24,6 +24,6 @@ "depends": { "fabricloader": ">=0.12.5", "fabric": "*", - "minecraft": "1.18" + "minecraft": "1.19.2" } } diff --git a/src/main/resources/goauth.mixins.json b/src/main/resources/goauth.mixins.json @@ -4,10 +4,9 @@ "package": "cz.bain.plugins.goauth.mixin", "compatibilityLevel": "JAVA_16", "mixins": [ - "DimensionTypeAccessor", "MinecraftServerMixin", "OnPlayerConnectMixin", - "PlayerManagerAccessor" + "PlayerManagerAccessor", ], "client": [ ],