From 8ae1150c8026af625bd39143b50f3b9a08acdfed Mon Sep 17 00:00:00 2001 From: onebeastchris Date: Fri, 7 Jun 2024 19:47:21 +0200 Subject: [PATCH] Remove unused lectern code in ModWorldManager, fix spelling error in SessionLoginEvent --- .../api/event/bedrock/SessionLoginEvent.java | 6 +-- .../mod/world/GeyserModWorldManager.java | 38 ------------------- 2 files changed, 3 insertions(+), 41 deletions(-) diff --git a/api/src/main/java/org/geysermc/geyser/api/event/bedrock/SessionLoginEvent.java b/api/src/main/java/org/geysermc/geyser/api/event/bedrock/SessionLoginEvent.java index 522562d11..86a5ec6f8 100644 --- a/api/src/main/java/org/geysermc/geyser/api/event/bedrock/SessionLoginEvent.java +++ b/api/src/main/java/org/geysermc/geyser/api/event/bedrock/SessionLoginEvent.java @@ -36,7 +36,7 @@ import java.util.Map; import java.util.Objects; /** - * Called when a session has logged in, and is about to connect to a remote java server. + * Called when a session has logged in, and is about to connect to a remote Java server. * This event is cancellable, and can be used to prevent the player from connecting to the remote server. */ public final class SessionLoginEvent extends ConnectionEvent implements Cancellable { @@ -99,9 +99,9 @@ public final class SessionLoginEvent extends ConnectionEvent implements Cancella } /** - * Gets the {@link RemoteServer} the section will attempt to connect to. + * Gets the {@link RemoteServer} the session will attempt to connect to. * - * @return the {@link RemoteServer} the section will attempt to connect to. + * @return the {@link RemoteServer} the session will attempt to connect to. */ public @NonNull RemoteServer remoteServer() { return this.remoteServer; diff --git a/bootstrap/mod/src/main/java/org/geysermc/geyser/platform/mod/world/GeyserModWorldManager.java b/bootstrap/mod/src/main/java/org/geysermc/geyser/platform/mod/world/GeyserModWorldManager.java index 7aac684bb..5543dbcee 100644 --- a/bootstrap/mod/src/main/java/org/geysermc/geyser/platform/mod/world/GeyserModWorldManager.java +++ b/bootstrap/mod/src/main/java/org/geysermc/geyser/platform/mod/world/GeyserModWorldManager.java @@ -26,7 +26,6 @@ package org.geysermc.geyser.platform.mod.world; import net.kyori.adventure.text.serializer.gson.GsonComponentSerializer; -import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer; import net.minecraft.SharedConstants; import net.minecraft.core.BlockPos; import net.minecraft.core.RegistryAccess; @@ -34,10 +33,7 @@ import net.minecraft.core.component.DataComponents; import net.minecraft.network.chat.Component; import net.minecraft.server.MinecraftServer; import net.minecraft.server.level.ServerPlayer; -import net.minecraft.server.network.Filterable; import net.minecraft.world.item.ItemStack; -import net.minecraft.world.item.component.WritableBookContent; -import net.minecraft.world.item.component.WrittenBookContent; import net.minecraft.world.level.Level; import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.entity.BannerBlockEntity; @@ -63,7 +59,6 @@ import java.util.concurrent.CompletableFuture; public class GeyserModWorldManager extends GeyserWorldManager { private static final GsonComponentSerializer GSON_SERIALIZER = GsonComponentSerializer.gson(); - private static final LegacyComponentSerializer LEGACY_SERIALIZER = LegacyComponentSerializer.legacySection(); private final MinecraftServer server; public GeyserModWorldManager(MinecraftServer server) { @@ -169,39 +164,6 @@ public class GeyserModWorldManager extends GeyserWorldManager { return server.getPlayerList().getPlayer(session.getPlayerEntity().getUuid()); } - private static int getPageCount(ItemStack itemStack) { - WrittenBookContent writtenBookContent = itemStack.get(DataComponents.WRITTEN_BOOK_CONTENT); - if (writtenBookContent != null) { - return writtenBookContent.pages().size(); - } else { - WritableBookContent writableBookContent = itemStack.get(DataComponents.WRITABLE_BOOK_CONTENT); - return writableBookContent != null ? writableBookContent.pages().size() : 0; - } - } - - private static List getPages(ItemStack itemStack) { - WrittenBookContent writtenBookContent = itemStack.get(DataComponents.WRITTEN_BOOK_CONTENT); - if (writtenBookContent != null) { - return writtenBookContent.pages().stream() - .map(Filterable::raw) - .map(GeyserModWorldManager::fromComponent) - .toList(); - } else { - WritableBookContent writableBookContent = itemStack.get(DataComponents.WRITABLE_BOOK_CONTENT); - if (writableBookContent == null) { - return List.of(); - } - return writableBookContent.pages().stream() - .map(Filterable::raw) - .toList(); - } - } - - private static String fromComponent(Component component) { - String json = Component.Serializer.toJson(component, RegistryAccess.EMPTY); - return LEGACY_SERIALIZER.serialize(GSON_SERIALIZER.deserializeOr(json, net.kyori.adventure.text.Component.empty())); - } - private static net.kyori.adventure.text.Component toKyoriComponent(Component component) { String json = Component.Serializer.toJson(component, RegistryAccess.EMPTY); return GSON_SERIALIZER.deserializeOr(json, net.kyori.adventure.text.Component.empty());