From 3a46457a4ba9cb1a2a43c27d7ddba2850da42e33 Mon Sep 17 00:00:00 2001 From: onebeastchris Date: Mon, 26 Aug 2024 22:18:42 +0200 Subject: [PATCH 1/4] add static getInstance method to the GeyserLogger interface --- core/src/main/java/org/geysermc/geyser/GeyserImpl.java | 5 +++-- .../main/java/org/geysermc/geyser/GeyserLogger.java | 10 ++++++++++ 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/core/src/main/java/org/geysermc/geyser/GeyserImpl.java b/core/src/main/java/org/geysermc/geyser/GeyserImpl.java index 8febf4d2179..68b3f5183e2 100644 --- a/core/src/main/java/org/geysermc/geyser/GeyserImpl.java +++ b/core/src/main/java/org/geysermc/geyser/GeyserImpl.java @@ -198,6 +198,7 @@ private GeyserImpl(PlatformType platformType, GeyserBootstrap bootstrap) { instance = this; Geyser.set(this); + GeyserLogger.INSTANCE.set(bootstrap.getGeyserLogger()); this.platformType = platformType; this.bootstrap = bootstrap; @@ -591,7 +592,7 @@ private void startInstance() { String authChain = gson.toJson(javaSession.toJson(fullJavaSession)); savedAuthChains.put(user, authChain); } catch (Exception e) { - GeyserImpl.getInstance().getLogger().warning("Could not migrate " + entry.getKey() + " to an auth chain! " + + GeyserLogger.getInstance().warning("Could not migrate " + entry.getKey() + " to an auth chain! " + "They will need to sign in the next time they join Geyser."); } @@ -914,7 +915,7 @@ private void scheduleAuthChainsWrite() { .withDefaultPrettyPrinter() .writeValue(writer, this.savedAuthChains); } catch (IOException e) { - getLogger().error("Unable to write saved refresh tokens!", e); + GeyserLogger.getInstance().error("Unable to write saved refresh tokens!", e); } }); } diff --git a/core/src/main/java/org/geysermc/geyser/GeyserLogger.java b/core/src/main/java/org/geysermc/geyser/GeyserLogger.java index f408de29c02..86650bc1d1b 100644 --- a/core/src/main/java/org/geysermc/geyser/GeyserLogger.java +++ b/core/src/main/java/org/geysermc/geyser/GeyserLogger.java @@ -31,9 +31,19 @@ import org.geysermc.geyser.command.GeyserCommandSource; import java.util.UUID; +import java.util.concurrent.atomic.AtomicReference; public interface GeyserLogger extends GeyserCommandSource { + AtomicReference INSTANCE = new AtomicReference<>(); + + /** + * Returns the current GeyserLogger instance. + */ + static GeyserLogger getInstance() { + return INSTANCE.get(); + } + /** * Logs a severe message to console * From 4bfff615631f42df45c3c5d8a741055b4d00b07f Mon Sep 17 00:00:00 2001 From: onebeastchris Date: Mon, 26 Aug 2024 22:26:32 +0200 Subject: [PATCH 2/4] add GeyserLogger#debug(message, args) --- .../geyser/platform/bungeecord/GeyserBungeeLogger.java | 7 +++++++ .../geysermc/geyser/platform/mod/GeyserModLogger.java | 7 +++++++ .../geyser/platform/spigot/GeyserSpigotLogger.java | 7 +++++++ .../platform/standalone/GeyserStandaloneLogger.java | 5 +++++ .../geyser/platform/velocity/GeyserVelocityLogger.java | 9 ++++++++- .../geyser/platform/viaproxy/GeyserViaProxyLogger.java | 7 +++++++ core/src/main/java/org/geysermc/geyser/GeyserLogger.java | 8 ++++++++ 7 files changed, 49 insertions(+), 1 deletion(-) diff --git a/bootstrap/bungeecord/src/main/java/org/geysermc/geyser/platform/bungeecord/GeyserBungeeLogger.java b/bootstrap/bungeecord/src/main/java/org/geysermc/geyser/platform/bungeecord/GeyserBungeeLogger.java index e8cf7ee39b0..924a95a7978 100644 --- a/bootstrap/bungeecord/src/main/java/org/geysermc/geyser/platform/bungeecord/GeyserBungeeLogger.java +++ b/bootstrap/bungeecord/src/main/java/org/geysermc/geyser/platform/bungeecord/GeyserBungeeLogger.java @@ -75,4 +75,11 @@ public void debug(String message) { info(message); } } + + @Override + public void debug(String message, Object... parameters) { + if (debug) { + info(String.format(message, parameters)); + } + } } diff --git a/bootstrap/mod/src/main/java/org/geysermc/geyser/platform/mod/GeyserModLogger.java b/bootstrap/mod/src/main/java/org/geysermc/geyser/platform/mod/GeyserModLogger.java index 9260288d7ab..020a5757995 100644 --- a/bootstrap/mod/src/main/java/org/geysermc/geyser/platform/mod/GeyserModLogger.java +++ b/bootstrap/mod/src/main/java/org/geysermc/geyser/platform/mod/GeyserModLogger.java @@ -84,6 +84,13 @@ public void debug(String message) { } } + @Override + public void debug(String message, Object... parameters) { + if (debug) { + logger.info(message, parameters); + } + } + @Override public void setDebug(boolean debug) { this.debug = debug; diff --git a/bootstrap/spigot/src/main/java/org/geysermc/geyser/platform/spigot/GeyserSpigotLogger.java b/bootstrap/spigot/src/main/java/org/geysermc/geyser/platform/spigot/GeyserSpigotLogger.java index 5c6101eaefe..88b32844e8f 100644 --- a/bootstrap/spigot/src/main/java/org/geysermc/geyser/platform/spigot/GeyserSpigotLogger.java +++ b/bootstrap/spigot/src/main/java/org/geysermc/geyser/platform/spigot/GeyserSpigotLogger.java @@ -75,4 +75,11 @@ public void debug(String message) { info(message); } } + + @Override + public void debug(String message, Object... parameters) { + if (debug) { + info(String.format(message, parameters)); + } + } } diff --git a/bootstrap/standalone/src/main/java/org/geysermc/geyser/platform/standalone/GeyserStandaloneLogger.java b/bootstrap/standalone/src/main/java/org/geysermc/geyser/platform/standalone/GeyserStandaloneLogger.java index 21e6a5e8283..dba4f3db150 100644 --- a/bootstrap/standalone/src/main/java/org/geysermc/geyser/platform/standalone/GeyserStandaloneLogger.java +++ b/bootstrap/standalone/src/main/java/org/geysermc/geyser/platform/standalone/GeyserStandaloneLogger.java @@ -89,6 +89,11 @@ public void debug(String message) { log.debug(ChatColor.GRAY + message); } + @Override + public void debug(String message, Object... parameters) { + log.debug(ChatColor.GRAY + message, parameters); + } + @Override public void setDebug(boolean debug) { Configurator.setLevel(log.getName(), debug ? Level.DEBUG : Level.INFO); diff --git a/bootstrap/velocity/src/main/java/org/geysermc/geyser/platform/velocity/GeyserVelocityLogger.java b/bootstrap/velocity/src/main/java/org/geysermc/geyser/platform/velocity/GeyserVelocityLogger.java index 4d10e4daf0d..b99bd0e5b69 100644 --- a/bootstrap/velocity/src/main/java/org/geysermc/geyser/platform/velocity/GeyserVelocityLogger.java +++ b/bootstrap/velocity/src/main/java/org/geysermc/geyser/platform/velocity/GeyserVelocityLogger.java @@ -73,4 +73,11 @@ public void debug(String message) { info(message); } } -} \ No newline at end of file + + @Override + public void debug(String message, Object... parameters) { + if (debug) { + logger.info(message, parameters); + } + } +} diff --git a/bootstrap/viaproxy/src/main/java/org/geysermc/geyser/platform/viaproxy/GeyserViaProxyLogger.java b/bootstrap/viaproxy/src/main/java/org/geysermc/geyser/platform/viaproxy/GeyserViaProxyLogger.java index 10f414b51dc..5cf0183c725 100644 --- a/bootstrap/viaproxy/src/main/java/org/geysermc/geyser/platform/viaproxy/GeyserViaProxyLogger.java +++ b/bootstrap/viaproxy/src/main/java/org/geysermc/geyser/platform/viaproxy/GeyserViaProxyLogger.java @@ -75,6 +75,13 @@ public void debug(String message) { } } + @Override + public void debug(String message, Object... parameters) { + if (this.debug) { + this.logger.debug(ConsoleFormatter.convert(message.formatted(parameters))); + } + } + @Override public void setDebug(boolean debug) { this.debug = debug; diff --git a/core/src/main/java/org/geysermc/geyser/GeyserLogger.java b/core/src/main/java/org/geysermc/geyser/GeyserLogger.java index 86650bc1d1b..8f20c83e5d7 100644 --- a/core/src/main/java/org/geysermc/geyser/GeyserLogger.java +++ b/core/src/main/java/org/geysermc/geyser/GeyserLogger.java @@ -113,6 +113,14 @@ default void debug(@Nullable Object object) { debug(String.valueOf(object)); } + /** + * Logs a message with parameters if debug mode is enabled. + * + * @param message the message with placeholders for the objects + * @param parameters the parameters for the message + */ + void debug(String message, Object... parameters); + /** * Sets if the logger should print debug messages * From e6dcef31cce2604519865d9a7f9a1694bf07b78b Mon Sep 17 00:00:00 2001 From: onebeastchris Date: Mon, 26 Aug 2024 22:29:17 +0200 Subject: [PATCH 3/4] Use GeyserLogger#getInstance() where possible --- .../GeyserBungeePingPassthrough.java | 3 +- .../platform/mod/GeyserModInjector.java | 4 +-- .../mod/command/ModCommandSource.java | 3 +- .../GeyserSpigotCompressionDisabler.java | 4 +-- .../platform/spigot/PaperAdventure.java | 16 ++++----- .../manager/GeyserSpigotWorldManager.java | 10 +++--- .../GeyserVelocityCompressionDisabler.java | 4 +-- .../command/CommandSourceConverter.java | 2 +- .../geyser/command/ExceptionHandlers.java | 4 +-- .../defaults/ConnectionTestCommand.java | 3 +- .../command/defaults/VersionCommand.java | 3 +- .../StandaloneCloudCommandManager.java | 3 +- .../geyser/entity/EntityDefinition.java | 11 ++++--- .../entity/type/ThrownPotionEntity.java | 4 +-- .../extension/GeyserExtensionClassLoader.java | 4 +-- .../extension/GeyserExtensionLoader.java | 11 ++++--- .../extension/GeyserExtensionManager.java | 13 ++++---- .../geyser/inventory/CrafterContainer.java | 8 ++--- .../geysermc/geyser/inventory/Inventory.java | 4 +-- .../geyser/inventory/PlayerInventory.java | 6 ++-- .../holder/BlockInventoryHolder.java | 10 +++--- .../updater/AnvilInventoryUpdater.java | 8 ++--- .../geyser/item/type/EnchantedBookItem.java | 4 +-- .../org/geysermc/geyser/item/type/Item.java | 4 +-- .../geysermc/geyser/item/type/PotionItem.java | 4 +-- .../geyser/item/type/TippedArrowItem.java | 4 +-- .../geysermc/geyser/level/JukeboxSong.java | 4 +-- .../level/block/GeyserCustomBlockData.java | 10 ++++-- .../geyser/network/netty/Bootstraps.java | 8 ++--- .../geyser/network/netty/GeyserServer.java | 9 ++--- .../geyser/pack/SkullResourcePackManager.java | 29 +++++++++------- .../geyser/pack/path/GeyserPathPackCodec.java | 4 +-- .../registry/PacketTranslatorRegistry.java | 13 ++++---- .../loader/CollisionRegistryLoader.java | 13 +++++--- .../loader/ParticleTypesRegistryLoader.java | 8 ++--- .../registry/loader/ResourcePackLoader.java | 7 ++-- .../loader/SoundEventsRegistryLoader.java | 8 ++--- .../mappings/MappingsConfigReader.java | 9 ++--- .../mappings/versions/MappingsReader_v1.java | 24 ++++++++++---- .../populator/BlockRegistryPopulator.java | 29 ++++++++++++---- .../CreativeItemRegistryPopulator.java | 3 +- .../CustomBlockRegistryPopulator.java | 17 +++++----- .../CustomItemRegistryPopulator.java | 22 ++++++++----- .../CustomSkullRegistryPopulator.java | 19 ++++++----- .../populator/ItemRegistryPopulator.java | 33 +++++++++++++++---- .../populator/PacketRegistryPopulator.java | 8 ++--- .../geyser/registry/type/ItemMappings.java | 4 +-- .../geyser/scoreboard/Scoreboard.java | 2 +- .../geyser/session/GeyserSession.java | 5 +-- .../PendingMicrosoftAuthentication.java | 2 +- .../geyser/session/cache/FormCache.java | 10 +++--- .../geyser/session/cache/RegistryCache.java | 4 +-- .../geyser/session/cache/TagCache.java | 4 +-- .../geyser/skin/FakeHeadProvider.java | 20 +++++------ .../org/geysermc/geyser/skin/SkinManager.java | 11 ++++--- .../geysermc/geyser/skin/SkinProvider.java | 27 ++++++++------- .../geyser/skin/SkullSkinManager.java | 6 ++-- .../geysermc/geyser/text/MinecraftLocale.java | 21 ++++++------ .../translator/item/ItemTranslator.java | 4 +-- .../protocol/java/JavaCommandsTranslator.java | 23 ++++++++++--- .../java/JavaCustomPayloadTranslator.java | 3 +- .../java/JavaUpdateRecipesTranslator.java | 5 +-- .../JavaPlayerInfoUpdateTranslator.java | 6 ++-- .../entity/spawn/JavaAddEntityTranslator.java | 24 ++++++++------ .../java/level/JavaLevelEventTranslator.java | 4 +-- .../JavaSetObjectiveTranslator.java | 3 +- .../JavaSetPlayerTeamTranslator.java | 3 +- .../scoreboard/JavaSetScoreTranslator.java | 3 +- .../translator/text/MessageTranslator.java | 20 +++++++---- .../org/geysermc/geyser/util/AssetUtils.java | 31 +++++++++++------ .../org/geysermc/geyser/util/FileUtils.java | 10 ++++-- .../geysermc/geyser/util/InventoryUtils.java | 17 ++++++---- .../geyser/util/MinecraftAuthLogger.java | 8 ++--- .../org/geysermc/geyser/util/NewsHandler.java | 2 +- .../org/geysermc/geyser/util/SoundUtils.java | 4 +-- .../geyser/util/VersionCheckUtils.java | 2 +- .../org/geysermc/geyser/util/WebUtils.java | 9 +++-- 77 files changed, 435 insertions(+), 293 deletions(-) diff --git a/bootstrap/bungeecord/src/main/java/org/geysermc/geyser/platform/bungeecord/GeyserBungeePingPassthrough.java b/bootstrap/bungeecord/src/main/java/org/geysermc/geyser/platform/bungeecord/GeyserBungeePingPassthrough.java index 1193a52b39e..f3906934ea8 100644 --- a/bootstrap/bungeecord/src/main/java/org/geysermc/geyser/platform/bungeecord/GeyserBungeePingPassthrough.java +++ b/bootstrap/bungeecord/src/main/java/org/geysermc/geyser/platform/bungeecord/GeyserBungeePingPassthrough.java @@ -37,6 +37,7 @@ import net.md_5.bungee.protocol.ProtocolConstants; import org.checkerframework.checker.nullness.qual.Nullable; import org.geysermc.geyser.GeyserImpl; +import org.geysermc.geyser.GeyserLogger; import org.geysermc.geyser.ping.GeyserPingInfo; import org.geysermc.geyser.ping.IGeyserPingPassthrough; @@ -68,7 +69,7 @@ public GeyserPingInfo getPingInformation(InetSocketAddress inetSocketAddress) { event = future.get(100, TimeUnit.MILLISECONDS); } catch (Throwable cause) { String address = GeyserImpl.getInstance().getConfig().isLogPlayerIpAddresses() ? inetSocketAddress.toString() : ""; - GeyserImpl.getInstance().getLogger().error("Failed to get ping information for " + address, cause); + GeyserLogger.getInstance().error("Failed to get ping information for " + address, cause); return null; } diff --git a/bootstrap/mod/src/main/java/org/geysermc/geyser/platform/mod/GeyserModInjector.java b/bootstrap/mod/src/main/java/org/geysermc/geyser/platform/mod/GeyserModInjector.java index 624eccb3f24..63ba0e07ed0 100644 --- a/bootstrap/mod/src/main/java/org/geysermc/geyser/platform/mod/GeyserModInjector.java +++ b/bootstrap/mod/src/main/java/org/geysermc/geyser/platform/mod/GeyserModInjector.java @@ -37,7 +37,7 @@ import net.minecraft.server.network.ServerConnectionListener; import org.checkerframework.checker.nullness.qual.NonNull; import org.geysermc.geyser.GeyserBootstrap; -import org.geysermc.geyser.GeyserImpl; +import org.geysermc.geyser.GeyserLogger; import org.geysermc.geyser.network.netty.GeyserInjector; import org.geysermc.geyser.network.netty.LocalServerChannelWrapper; import org.geysermc.geyser.platform.mod.platform.GeyserModPlatform; @@ -149,7 +149,7 @@ public void shutdown() { eventLoopGroup.shutdownGracefully().sync(); eventLoopGroup = null; } catch (Exception e) { - GeyserImpl.getInstance().getLogger().error("Unable to shut down injector! " + e.getMessage()); + GeyserLogger.getInstance().error("Unable to shut down injector! " + e.getMessage()); e.printStackTrace(); } } diff --git a/bootstrap/mod/src/main/java/org/geysermc/geyser/platform/mod/command/ModCommandSource.java b/bootstrap/mod/src/main/java/org/geysermc/geyser/platform/mod/command/ModCommandSource.java index af1f368b3de..a78b373898e 100644 --- a/bootstrap/mod/src/main/java/org/geysermc/geyser/platform/mod/command/ModCommandSource.java +++ b/bootstrap/mod/src/main/java/org/geysermc/geyser/platform/mod/command/ModCommandSource.java @@ -33,6 +33,7 @@ import org.checkerframework.checker.nullness.qual.NonNull; import org.checkerframework.checker.nullness.qual.Nullable; import org.geysermc.geyser.GeyserImpl; +import org.geysermc.geyser.GeyserLogger; import org.geysermc.geyser.command.GeyserCommandSource; import org.geysermc.geyser.text.ChatColor; @@ -58,7 +59,7 @@ public void sendMessage(@NonNull String message) { if (source.getEntity() instanceof ServerPlayer) { ((ServerPlayer) source.getEntity()).displayClientMessage(Component.literal(message), false); } else { - GeyserImpl.getInstance().getLogger().info(ChatColor.toANSI(message + ChatColor.RESET)); + GeyserLogger.getInstance().info(ChatColor.toANSI(message + ChatColor.RESET)); } } diff --git a/bootstrap/spigot/src/main/java/org/geysermc/geyser/platform/spigot/GeyserSpigotCompressionDisabler.java b/bootstrap/spigot/src/main/java/org/geysermc/geyser/platform/spigot/GeyserSpigotCompressionDisabler.java index 2a6056df9c9..9119a022642 100644 --- a/bootstrap/spigot/src/main/java/org/geysermc/geyser/platform/spigot/GeyserSpigotCompressionDisabler.java +++ b/bootstrap/spigot/src/main/java/org/geysermc/geyser/platform/spigot/GeyserSpigotCompressionDisabler.java @@ -29,7 +29,7 @@ import io.netty.channel.ChannelOutboundHandlerAdapter; import io.netty.channel.ChannelPromise; import org.bukkit.Bukkit; -import org.geysermc.geyser.GeyserImpl; +import org.geysermc.geyser.GeyserLogger; /** * Disables the compression packet (and the compression handlers from being added to the pipeline) for Geyser clients @@ -56,7 +56,7 @@ public class GeyserSpigotCompressionDisabler extends ChannelOutboundHandlerAdapt loginSuccessPacketClass = findLoginSuccessPacket(); enabled = true; } catch (Exception e) { - GeyserImpl.getInstance().getLogger().error("Could not initialize compression disabler!", e); + GeyserLogger.getInstance().error("Could not initialize compression disabler!", e); } COMPRESSION_PACKET_CLASS = compressionPacketClass; LOGIN_SUCCESS_PACKET_CLASS = loginSuccessPacketClass; diff --git a/bootstrap/spigot/src/main/java/org/geysermc/geyser/platform/spigot/PaperAdventure.java b/bootstrap/spigot/src/main/java/org/geysermc/geyser/platform/spigot/PaperAdventure.java index fa7555ac623..032b12618ba 100644 --- a/bootstrap/spigot/src/main/java/org/geysermc/geyser/platform/spigot/PaperAdventure.java +++ b/bootstrap/spigot/src/main/java/org/geysermc/geyser/platform/spigot/PaperAdventure.java @@ -25,11 +25,11 @@ package org.geysermc.geyser.platform.spigot; -import org.geysermc.mcprotocollib.protocol.data.DefaultComponentSerializer; import net.kyori.adventure.text.Component; import org.bukkit.command.CommandSender; import org.checkerframework.checker.nullness.qual.Nullable; -import org.geysermc.geyser.GeyserImpl; +import org.geysermc.geyser.GeyserLogger; +import org.geysermc.mcprotocollib.protocol.data.DefaultComponentSerializer; import java.lang.invoke.MethodHandle; import java.lang.invoke.MethodHandles; @@ -79,7 +79,7 @@ public final class PaperAdventure { nativeGsonComponentSerializerDeserializeMethodBound = nativeGsonComponentSerializerDeserializeMethod .bindTo(nativeGsonComponentSerializerGsonGetter.invoke()); } catch (final Throwable throwable) { - GeyserImpl.getInstance().getLogger().error("Failed to access native GsonComponentSerializer", throwable); + GeyserLogger.getInstance().error("Failed to access native GsonComponentSerializer", throwable); } } } @@ -94,7 +94,7 @@ public final class PaperAdventure { try { playerComponentSendMessage = CommandSender.class.getMethod("sendMessage", nativeComponentClass); } catch (final NoSuchMethodException e) { - if (GeyserImpl.getInstance().getLogger().isDebug()) { + if (GeyserLogger.getInstance().isDebug()) { e.printStackTrace(); } } @@ -104,21 +104,21 @@ public final class PaperAdventure { public static @Nullable Object toNativeComponent(final Component component) { if (NATIVE_GSON_COMPONENT_SERIALIZER_DESERIALIZE_METHOD_BOUND == null) { - GeyserImpl.getInstance().getLogger().error("Illegal state where Component serialization was called when it wasn't available!"); + GeyserLogger.getInstance().error("Illegal state where Component serialization was called when it wasn't available!"); return null; } try { return NATIVE_GSON_COMPONENT_SERIALIZER_DESERIALIZE_METHOD_BOUND.invoke(DefaultComponentSerializer.get().serialize(component)); } catch (final Throwable throwable) { - GeyserImpl.getInstance().getLogger().error("Failed to create native Component message", throwable); + GeyserLogger.getInstance().error("Failed to create native Component message", throwable); return null; } } public static void sendMessage(final CommandSender sender, final Component component) { if (SEND_MESSAGE_COMPONENT == null) { - GeyserImpl.getInstance().getLogger().error("Illegal state where Component sendMessage was called when it wasn't available!"); + GeyserLogger.getInstance().error("Illegal state where Component sendMessage was called when it wasn't available!"); return; } @@ -127,7 +127,7 @@ public static void sendMessage(final CommandSender sender, final Component compo try { SEND_MESSAGE_COMPONENT.invoke(sender, nativeComponent); } catch (final InvocationTargetException | IllegalAccessException e) { - GeyserImpl.getInstance().getLogger().error("Failed to send native Component message", e); + GeyserLogger.getInstance().error("Failed to send native Component message", e); } } } diff --git a/bootstrap/spigot/src/main/java/org/geysermc/geyser/platform/spigot/world/manager/GeyserSpigotWorldManager.java b/bootstrap/spigot/src/main/java/org/geysermc/geyser/platform/spigot/world/manager/GeyserSpigotWorldManager.java index 6588a22a3d6..a026515cc64 100644 --- a/bootstrap/spigot/src/main/java/org/geysermc/geyser/platform/spigot/world/manager/GeyserSpigotWorldManager.java +++ b/bootstrap/spigot/src/main/java/org/geysermc/geyser/platform/spigot/world/manager/GeyserSpigotWorldManager.java @@ -38,7 +38,7 @@ import org.geysermc.erosion.bukkit.BukkitUtils; import org.geysermc.erosion.bukkit.PickBlockUtils; import org.geysermc.erosion.bukkit.SchedulerUtils; -import org.geysermc.geyser.GeyserImpl; +import org.geysermc.geyser.GeyserLogger; import org.geysermc.geyser.level.GameRule; import org.geysermc.geyser.level.WorldManager; import org.geysermc.geyser.registry.BlockRegistries; @@ -94,7 +94,7 @@ public boolean hasOwnChunkCache() { public boolean getGameRuleBool(GeyserSession session, GameRule gameRule) { org.bukkit.GameRule bukkitGameRule = org.bukkit.GameRule.getByName(gameRule.getJavaID()); if (bukkitGameRule == null) { - GeyserImpl.getInstance().getLogger().debug("Unknown game rule " + gameRule.getJavaID()); + GeyserLogger.getInstance().debug("Unknown game rule " + gameRule.getJavaID()); return gameRule.getDefaultBooleanValue(); } @@ -103,7 +103,7 @@ public boolean getGameRuleBool(GeyserSession session, GameRule gameRule) { if (value instanceof Boolean booleanValue) { return booleanValue; } - GeyserImpl.getInstance().getLogger().debug("Expected a bool for " + gameRule + " but got " + value); + GeyserLogger.getInstance().debug("Expected a bool for " + gameRule + " but got " + value); return gameRule.getDefaultBooleanValue(); } @@ -111,7 +111,7 @@ public boolean getGameRuleBool(GeyserSession session, GameRule gameRule) { public int getGameRuleInt(GeyserSession session, GameRule gameRule) { org.bukkit.GameRule bukkitGameRule = org.bukkit.GameRule.getByName(gameRule.getJavaID()); if (bukkitGameRule == null) { - GeyserImpl.getInstance().getLogger().debug("Unknown game rule " + gameRule.getJavaID()); + GeyserLogger.getInstance().debug("Unknown game rule " + gameRule.getJavaID()); return gameRule.getDefaultIntValue(); } Player bukkitPlayer = Objects.requireNonNull(Bukkit.getPlayer(session.getPlayerEntity().getUuid())); @@ -119,7 +119,7 @@ public int getGameRuleInt(GeyserSession session, GameRule gameRule) { if (value instanceof Integer intValue) { return intValue; } - GeyserImpl.getInstance().getLogger().debug("Expected an int for " + gameRule + " but got " + value); + GeyserLogger.getInstance().debug("Expected an int for " + gameRule + " but got " + value); return gameRule.getDefaultIntValue(); } diff --git a/bootstrap/velocity/src/main/java/org/geysermc/geyser/platform/velocity/GeyserVelocityCompressionDisabler.java b/bootstrap/velocity/src/main/java/org/geysermc/geyser/platform/velocity/GeyserVelocityCompressionDisabler.java index 99c759767a7..5e2ba8b2720 100644 --- a/bootstrap/velocity/src/main/java/org/geysermc/geyser/platform/velocity/GeyserVelocityCompressionDisabler.java +++ b/bootstrap/velocity/src/main/java/org/geysermc/geyser/platform/velocity/GeyserVelocityCompressionDisabler.java @@ -28,7 +28,7 @@ import io.netty.channel.ChannelDuplexHandler; import io.netty.channel.ChannelHandlerContext; import io.netty.channel.ChannelPromise; -import org.geysermc.geyser.GeyserImpl; +import org.geysermc.geyser.GeyserLogger; import java.lang.reflect.Method; @@ -61,7 +61,7 @@ public class GeyserVelocityCompressionDisabler extends ChannelDuplexHandler { .getMethod("setCompressionThreshold", int.class); enabled = true; } catch (Exception e) { - GeyserImpl.getInstance().getLogger().error("Could not initialize compression disabler!", e); + GeyserLogger.getInstance().error("Could not initialize compression disabler!", e); } ENABLED = enabled; diff --git a/core/src/main/java/org/geysermc/geyser/command/CommandSourceConverter.java b/core/src/main/java/org/geysermc/geyser/command/CommandSourceConverter.java index 1fa5871e09e..9dd9fad804e 100644 --- a/core/src/main/java/org/geysermc/geyser/command/CommandSourceConverter.java +++ b/core/src/main/java/org/geysermc/geyser/command/CommandSourceConverter.java @@ -95,7 +95,7 @@ public static CommandSourceConverter layered(Class senderType, } if (!(source instanceof GeyserSession)) { - GeyserLogger logger = GeyserImpl.getInstance().getLogger(); + GeyserLogger logger = GeyserLogger.getInstance(); if (logger.isDebug()) { logger.debug("Falling back to UUID for command sender lookup for a command source that is not a GeyserSession: " + source); Thread.dumpStack(); diff --git a/core/src/main/java/org/geysermc/geyser/command/ExceptionHandlers.java b/core/src/main/java/org/geysermc/geyser/command/ExceptionHandlers.java index 45657a596a9..f8f45a30ef6 100644 --- a/core/src/main/java/org/geysermc/geyser/command/ExceptionHandlers.java +++ b/core/src/main/java/org/geysermc/geyser/command/ExceptionHandlers.java @@ -112,7 +112,7 @@ private static void handleNoPermission(GeyserCommandSource source, NoPermissionE return; } } else { - GeyserLogger logger = GeyserImpl.getInstance().getLogger(); + GeyserLogger logger = GeyserLogger.getInstance(); if (logger.isDebug()) { logger.debug("Expected a GeyserPermission.Result for %s but instead got %s from %s".formatted(exception.currentChain(), exception.permissionResult(), exception.missingPermission())); } @@ -124,6 +124,6 @@ private static void handleNoPermission(GeyserCommandSource source, NoPermissionE private static void handleUnexpectedThrowable(GeyserCommandSource source, Throwable throwable) { source.sendMessage(MinecraftLocale.getLocaleString("command.failed", source.locale())); // java edition translation key - GeyserImpl.getInstance().getLogger().error("Exception while executing command handler", throwable); + GeyserLogger.getInstance().error("Exception while executing command handler", throwable); } } diff --git a/core/src/main/java/org/geysermc/geyser/command/defaults/ConnectionTestCommand.java b/core/src/main/java/org/geysermc/geyser/command/defaults/ConnectionTestCommand.java index d2066dba179..44ba6223b99 100644 --- a/core/src/main/java/org/geysermc/geyser/command/defaults/ConnectionTestCommand.java +++ b/core/src/main/java/org/geysermc/geyser/command/defaults/ConnectionTestCommand.java @@ -27,6 +27,7 @@ import com.fasterxml.jackson.databind.JsonNode; import org.geysermc.geyser.GeyserImpl; +import org.geysermc.geyser.GeyserLogger; import org.geysermc.geyser.api.util.TriState; import org.geysermc.geyser.command.GeyserCommand; import org.geysermc.geyser.command.GeyserCommandSource; @@ -155,7 +156,7 @@ public void execute(CommandContext context) { } // Issue: does Loopback need applying? - if (LoopbackUtil.needsLoopback(GeyserImpl.getInstance().getLogger())) { + if (LoopbackUtil.needsLoopback(GeyserLogger.getInstance())) { source.sendMessage("Loopback is not applied on this computer! You will have issues connecting from the same computer. " + "See here for steps on how to resolve: " + "https://wiki.geysermc.org/geyser/fixing-unable-to-connect-to-world/#using-geyser-on-the-same-computer"); } diff --git a/core/src/main/java/org/geysermc/geyser/command/defaults/VersionCommand.java b/core/src/main/java/org/geysermc/geyser/command/defaults/VersionCommand.java index 8d34c1bf047..83ae9ba77db 100644 --- a/core/src/main/java/org/geysermc/geyser/command/defaults/VersionCommand.java +++ b/core/src/main/java/org/geysermc/geyser/command/defaults/VersionCommand.java @@ -28,6 +28,7 @@ import com.fasterxml.jackson.databind.JsonNode; import org.cloudburstmc.protocol.bedrock.codec.BedrockCodec; import org.geysermc.geyser.GeyserImpl; +import org.geysermc.geyser.GeyserLogger; import org.geysermc.geyser.api.util.PlatformType; import org.geysermc.geyser.api.util.TriState; import org.geysermc.geyser.command.GeyserCommand; @@ -98,7 +99,7 @@ public void execute(CommandContext context) { source.locale(), (latestBuildNumber - buildNumber), "https://geysermc.org/download" )); } catch (IOException e) { - GeyserImpl.getInstance().getLogger().error(GeyserLocale.getLocaleStringLog("geyser.commands.version.failed"), e); + GeyserLogger.getInstance().error(GeyserLocale.getLocaleStringLog("geyser.commands.version.failed"), e); source.sendMessage(ChatColor.RED + GeyserLocale.getPlayerLocaleString("geyser.commands.version.failed", source.locale())); } } diff --git a/core/src/main/java/org/geysermc/geyser/command/standalone/StandaloneCloudCommandManager.java b/core/src/main/java/org/geysermc/geyser/command/standalone/StandaloneCloudCommandManager.java index 99c53f319a8..190380d8374 100644 --- a/core/src/main/java/org/geysermc/geyser/command/standalone/StandaloneCloudCommandManager.java +++ b/core/src/main/java/org/geysermc/geyser/command/standalone/StandaloneCloudCommandManager.java @@ -28,6 +28,7 @@ import it.unimi.dsi.fastutil.objects.ObjectOpenHashSet; import org.checkerframework.checker.nullness.qual.NonNull; import org.geysermc.geyser.GeyserImpl; +import org.geysermc.geyser.GeyserLogger; import org.geysermc.geyser.api.event.lifecycle.GeyserRegisterPermissionCheckersEvent; import org.geysermc.geyser.api.event.lifecycle.GeyserRegisterPermissionsEvent; import org.geysermc.geyser.api.permission.PermissionChecker; @@ -75,7 +76,7 @@ public StandaloneCloudCommandManager(GeyserImpl geyser) { PermissionConfiguration config = FileUtils.loadConfig(permissionsFile, PermissionConfiguration.class); basePermissions.addAll(config.getDefaultPermissions()); } catch (Exception e) { - geyser.getLogger().error("Failed to load permissions.yml - proceeding without it", e); + GeyserLogger.getInstance().error("Failed to load permissions.yml - proceeding without it", e); } } diff --git a/core/src/main/java/org/geysermc/geyser/entity/EntityDefinition.java b/core/src/main/java/org/geysermc/geyser/entity/EntityDefinition.java index f9b65a545ff..2f4e9a54537 100644 --- a/core/src/main/java/org/geysermc/geyser/entity/EntityDefinition.java +++ b/core/src/main/java/org/geysermc/geyser/entity/EntityDefinition.java @@ -25,18 +25,19 @@ package org.geysermc.geyser.entity; -import org.geysermc.mcprotocollib.protocol.data.game.entity.metadata.EntityMetadata; -import org.geysermc.mcprotocollib.protocol.data.game.entity.metadata.MetadataType; -import org.geysermc.mcprotocollib.protocol.data.game.entity.type.EntityType; import it.unimi.dsi.fastutil.objects.ObjectArrayList; import lombok.Setter; import lombok.experimental.Accessors; import org.geysermc.geyser.GeyserImpl; +import org.geysermc.geyser.GeyserLogger; import org.geysermc.geyser.entity.factory.EntityFactory; import org.geysermc.geyser.entity.properties.GeyserEntityProperties; import org.geysermc.geyser.entity.type.Entity; import org.geysermc.geyser.registry.Registries; import org.geysermc.geyser.translator.entity.EntityMetadataTranslator; +import org.geysermc.mcprotocollib.protocol.data.game.entity.metadata.EntityMetadata; +import org.geysermc.mcprotocollib.protocol.data.game.entity.metadata.MetadataType; +import org.geysermc.mcprotocollib.protocol.data.game.entity.type.EntityType; import java.util.List; import java.util.Locale; @@ -70,9 +71,9 @@ public void translateMetadata(T entity, EntityMetadata entityMetadata) { setFlag(EntityFlag.ENCHANTED, !NON_ENCHANTED_POTIONS.contains(potion)); } else { dirtyMetadata.put(EntityDataTypes.AUX_VALUE_DATA, (short) 0); - GeyserImpl.getInstance().getLogger().debug("Unknown java potion: " + potionContents.getPotionId()); + GeyserLogger.getInstance().debug("Unknown java potion: " + potionContents.getPotionId()); } } diff --git a/core/src/main/java/org/geysermc/geyser/extension/GeyserExtensionClassLoader.java b/core/src/main/java/org/geysermc/geyser/extension/GeyserExtensionClassLoader.java index dca11dfcd87..15546fc24f1 100644 --- a/core/src/main/java/org/geysermc/geyser/extension/GeyserExtensionClassLoader.java +++ b/core/src/main/java/org/geysermc/geyser/extension/GeyserExtensionClassLoader.java @@ -27,7 +27,7 @@ import it.unimi.dsi.fastutil.objects.Object2ObjectMap; import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap; -import org.geysermc.geyser.GeyserImpl; +import org.geysermc.geyser.GeyserLogger; import org.geysermc.geyser.api.extension.Extension; import org.geysermc.geyser.api.extension.ExtensionDescription; import org.geysermc.geyser.api.extension.exception.InvalidExtensionException; @@ -90,7 +90,7 @@ protected Class findClass(String name, boolean checkGlobal) throws ClassNotFo // This is used for classes that are not in the extension, but are in other extensions if (checkGlobal) { if (!warnedForExternalClassAccess) { - GeyserImpl.getInstance().getLogger().warning("Extension " + this.description.name() + " loads class " + name + " from an external source. " + + GeyserLogger.getInstance().warning("Extension " + this.description.name() + " loads class " + name + " from an external source. " + "This can change at any time and break the extension, additionally to potentially causing unexpected behaviour!"); warnedForExternalClassAccess = true; } diff --git a/core/src/main/java/org/geysermc/geyser/extension/GeyserExtensionLoader.java b/core/src/main/java/org/geysermc/geyser/extension/GeyserExtensionLoader.java index a56e00671a7..111b1dff050 100644 --- a/core/src/main/java/org/geysermc/geyser/extension/GeyserExtensionLoader.java +++ b/core/src/main/java/org/geysermc/geyser/extension/GeyserExtensionLoader.java @@ -31,6 +31,7 @@ import org.checkerframework.checker.nullness.qual.NonNull; import org.geysermc.api.util.ApiVersion; import org.geysermc.geyser.GeyserImpl; +import org.geysermc.geyser.GeyserLogger; import org.geysermc.geyser.api.GeyserApi; import org.geysermc.geyser.api.event.ExtensionEventBus; import org.geysermc.geyser.api.extension.Extension; @@ -113,7 +114,7 @@ public GeyserExtensionContainer loadExtension(Path path, GeyserExtensionDescript } private GeyserExtensionContainer setup(Extension extension, GeyserExtensionDescription description, Path dataFolder, ExtensionEventBus eventBus) { - GeyserExtensionLogger logger = new GeyserExtensionLogger(GeyserImpl.getInstance().getLogger(), description.id()); + GeyserExtensionLogger logger = new GeyserExtensionLogger(GeyserLogger.getInstance(), description.id()); return new GeyserExtensionContainer(extension, dataFolder, description, this, logger, eventBus); } @@ -182,7 +183,7 @@ protected void loadAllExtensions(@NonNull ExtensionManager extensionManager) { String name = description.name(); String id = description.id(); if (extensions.containsKey(id) || extensionManager.extension(id) != null) { - GeyserImpl.getInstance().getLogger().warning(GeyserLocale.getLocaleStringLog("geyser.extensions.load.duplicate", name, path.toString())); + GeyserLogger.getInstance().warning(GeyserLocale.getLocaleStringLog("geyser.extensions.load.duplicate", name, path.toString())); return; } @@ -196,10 +197,10 @@ protected void loadAllExtensions(@NonNull ExtensionManager extensionManager) { if (compatibility != ApiVersion.Compatibility.COMPATIBLE) { // Workaround for the switch to the Geyser API version instead of the Base API version in extensions if (compatibility == ApiVersion.Compatibility.HUMAN_DIFFER && description.humanApiVersion() == 1) { - GeyserImpl.getInstance().getLogger().warning("The extension %s requested the Base API version %s, which is deprecated in favor of specifying the Geyser API version. Please update the extension, or contact its developer." + GeyserLogger.getInstance().warning("The extension %s requested the Base API version %s, which is deprecated in favor of specifying the Geyser API version. Please update the extension, or contact its developer." .formatted(name, description.apiVersion())); } else { - GeyserImpl.getInstance().getLogger().error(GeyserLocale.getLocaleStringLog("geyser.extensions.load.failed_api_version", name, description.apiVersion())); + GeyserLogger.getInstance().error(GeyserLocale.getLocaleStringLog("geyser.extensions.load.failed_api_version", name, description.apiVersion())); return; } } @@ -208,7 +209,7 @@ protected void loadAllExtensions(@NonNull ExtensionManager extensionManager) { extensions.put(id, path); loadedExtensions.put(id, container); } catch (Throwable e) { - GeyserImpl.getInstance().getLogger().error(GeyserLocale.getLocaleStringLog("geyser.extensions.load.failed_with_name", path.getFileName(), path.toAbsolutePath()), e); + GeyserLogger.getInstance().error(GeyserLocale.getLocaleStringLog("geyser.extensions.load.failed_with_name", path.getFileName(), path.toAbsolutePath()), e); } }); diff --git a/core/src/main/java/org/geysermc/geyser/extension/GeyserExtensionManager.java b/core/src/main/java/org/geysermc/geyser/extension/GeyserExtensionManager.java index 3c41c4329cb..10779bd2bcc 100644 --- a/core/src/main/java/org/geysermc/geyser/extension/GeyserExtensionManager.java +++ b/core/src/main/java/org/geysermc/geyser/extension/GeyserExtensionManager.java @@ -28,6 +28,7 @@ import org.checkerframework.checker.nullness.qual.NonNull; import org.checkerframework.checker.nullness.qual.Nullable; import org.geysermc.geyser.GeyserImpl; +import org.geysermc.geyser.GeyserLogger; import org.geysermc.geyser.api.extension.Extension; import org.geysermc.geyser.api.extension.ExtensionLoader; import org.geysermc.geyser.api.extension.ExtensionManager; @@ -43,12 +44,12 @@ public class GeyserExtensionManager extends ExtensionManager { private final Map extensions = new LinkedHashMap<>(); public void init() { - GeyserImpl.getInstance().getLogger().info(GeyserLocale.getLocaleStringLog("geyser.extensions.load.loading")); + GeyserLogger.getInstance().info(GeyserLocale.getLocaleStringLog("geyser.extensions.load.loading")); loadAllExtensions(this.extensionLoader); enableExtensions(); - GeyserImpl.getInstance().getLogger().info(GeyserLocale.getLocaleStringLog("geyser.extensions.load.done", this.extensions.size())); + GeyserLogger.getInstance().info(GeyserLocale.getLocaleStringLog("geyser.extensions.load.done", this.extensions.size())); } @Override @@ -62,7 +63,7 @@ public void enable(@NonNull Extension extension) { try { this.enableExtension(extension); } catch (Exception e) { - GeyserImpl.getInstance().getLogger().error(GeyserLocale.getLocaleStringLog("geyser.extensions.enable.failed", extension.name()), e); + GeyserLogger.getInstance().error(GeyserLocale.getLocaleStringLog("geyser.extensions.enable.failed", extension.name()), e); this.disable(extension); } } @@ -74,7 +75,7 @@ public void disable(@NonNull Extension extension) { try { this.disableExtension(extension); } catch (Exception e) { - GeyserImpl.getInstance().getLogger().error(GeyserLocale.getLocaleStringLog("geyser.extensions.disable.failed", extension.name()), e); + GeyserLogger.getInstance().error(GeyserLocale.getLocaleStringLog("geyser.extensions.disable.failed", extension.name()), e); } } } @@ -83,7 +84,7 @@ public void enableExtension(Extension extension) { if (!extension.isEnabled()) { extension.setEnabled(true); GeyserImpl.getInstance().eventBus().register(extension, extension); - GeyserImpl.getInstance().getLogger().info(GeyserLocale.getLocaleStringLog("geyser.extensions.enable.success", extension.name())); + GeyserLogger.getInstance().info(GeyserLocale.getLocaleStringLog("geyser.extensions.enable.success", extension.name())); } } @@ -98,7 +99,7 @@ private void disableExtension(@NonNull Extension extension) { GeyserImpl.getInstance().eventBus().unregisterAll(extension); extension.setEnabled(false); - GeyserImpl.getInstance().getLogger().info(GeyserLocale.getLocaleStringLog("geyser.extensions.disable.success", extension.name())); + GeyserLogger.getInstance().info(GeyserLocale.getLocaleStringLog("geyser.extensions.disable.success", extension.name())); } } diff --git a/core/src/main/java/org/geysermc/geyser/inventory/CrafterContainer.java b/core/src/main/java/org/geysermc/geyser/inventory/CrafterContainer.java index fb118252d16..d9df6af1497 100644 --- a/core/src/main/java/org/geysermc/geyser/inventory/CrafterContainer.java +++ b/core/src/main/java/org/geysermc/geyser/inventory/CrafterContainer.java @@ -25,14 +25,14 @@ package org.geysermc.geyser.inventory; +import lombok.Getter; +import lombok.Setter; import org.checkerframework.checker.nullness.qual.NonNull; +import org.geysermc.geyser.GeyserLogger; import org.geysermc.geyser.session.GeyserSession; import org.geysermc.geyser.translator.inventory.CrafterInventoryTranslator; import org.geysermc.geyser.translator.inventory.InventoryTranslator; import org.geysermc.mcprotocollib.protocol.data.game.inventory.ContainerType; -import lombok.Getter; -import lombok.Setter; -import org.geysermc.geyser.GeyserImpl; import org.jetbrains.annotations.Range; @Getter @@ -82,7 +82,7 @@ public void setItem(int slot, @NonNull GeyserItemStack newItem, GeyserSession se public void setSlot(int slot, boolean enabled) { if (!isCraftingGrid(slot)) { - GeyserImpl.getInstance().getLogger().warning("Crafter slot out of bounds: " + slot); + GeyserLogger.getInstance().warning("Crafter slot out of bounds: " + slot); return; } diff --git a/core/src/main/java/org/geysermc/geyser/inventory/Inventory.java b/core/src/main/java/org/geysermc/geyser/inventory/Inventory.java index 09d04f17c79..09a94991c87 100644 --- a/core/src/main/java/org/geysermc/geyser/inventory/Inventory.java +++ b/core/src/main/java/org/geysermc/geyser/inventory/Inventory.java @@ -31,7 +31,7 @@ import org.checkerframework.checker.nullness.qual.NonNull; import org.cloudburstmc.math.vector.Vector3i; import org.cloudburstmc.protocol.bedrock.data.definitions.ItemDefinition; -import org.geysermc.geyser.GeyserImpl; +import org.geysermc.geyser.GeyserLogger; import org.geysermc.geyser.item.Items; import org.geysermc.geyser.session.GeyserSession; import org.geysermc.geyser.translator.item.ItemTranslator; @@ -116,7 +116,7 @@ public int getBedrockId() { public GeyserItemStack getItem(int slot) { if (slot > this.size) { - GeyserImpl.getInstance().getLogger().debug("Tried to get an item out of bounds! " + this); + GeyserLogger.getInstance().debug("Tried to get an item out of bounds! " + this); return GeyserItemStack.EMPTY; } return items[slot]; diff --git a/core/src/main/java/org/geysermc/geyser/inventory/PlayerInventory.java b/core/src/main/java/org/geysermc/geyser/inventory/PlayerInventory.java index 3ea9cd112e3..cb56fd94aac 100644 --- a/core/src/main/java/org/geysermc/geyser/inventory/PlayerInventory.java +++ b/core/src/main/java/org/geysermc/geyser/inventory/PlayerInventory.java @@ -28,7 +28,7 @@ import lombok.Getter; import lombok.Setter; import org.checkerframework.checker.nullness.qual.NonNull; -import org.geysermc.geyser.GeyserImpl; +import org.geysermc.geyser.GeyserLogger; import org.geysermc.geyser.item.type.Item; import org.geysermc.geyser.session.GeyserSession; import org.geysermc.mcprotocollib.protocol.data.game.entity.player.Hand; @@ -78,7 +78,7 @@ public GeyserItemStack getItemInHand(@NonNull Hand hand) { public GeyserItemStack getItemInHand() { if (36 + heldItemSlot > this.size) { - GeyserImpl.getInstance().getLogger().debug("Held item slot was larger than expected!"); + GeyserLogger.getInstance().debug("Held item slot was larger than expected!"); return GeyserItemStack.EMPTY; } return items[36 + heldItemSlot]; @@ -90,7 +90,7 @@ public boolean eitherHandMatchesItem(@NonNull Item item) { public void setItemInHand(@NonNull GeyserItemStack item) { if (36 + heldItemSlot > this.size) { - GeyserImpl.getInstance().getLogger().debug("Held item slot was larger than expected!"); + GeyserLogger.getInstance().debug("Held item slot was larger than expected!"); return; } items[36 + heldItemSlot] = item; diff --git a/core/src/main/java/org/geysermc/geyser/inventory/holder/BlockInventoryHolder.java b/core/src/main/java/org/geysermc/geyser/inventory/holder/BlockInventoryHolder.java index cdda4fe4cef..cfa78d24a97 100644 --- a/core/src/main/java/org/geysermc/geyser/inventory/holder/BlockInventoryHolder.java +++ b/core/src/main/java/org/geysermc/geyser/inventory/holder/BlockInventoryHolder.java @@ -32,7 +32,7 @@ import org.cloudburstmc.protocol.bedrock.packet.ContainerClosePacket; import org.cloudburstmc.protocol.bedrock.packet.ContainerOpenPacket; import org.cloudburstmc.protocol.bedrock.packet.UpdateBlockPacket; -import org.geysermc.geyser.GeyserImpl; +import org.geysermc.geyser.GeyserLogger; import org.geysermc.geyser.inventory.Container; import org.geysermc.geyser.inventory.Inventory; import org.geysermc.geyser.inventory.LecternContainer; @@ -168,10 +168,10 @@ public void closeInventory(InventoryTranslator translator, GeyserSession session return; } } else { - GeyserImpl.getInstance().getLogger().warning("Tried to close a non-container inventory in a block inventory holder! "); - if (GeyserImpl.getInstance().getLogger().isDebug()) { - GeyserImpl.getInstance().getLogger().debug("Current inventory: " + inventory); - GeyserImpl.getInstance().getLogger().debug("Open inventory: " + session.getOpenInventory()); + GeyserLogger.getInstance().warning("Tried to close a non-container inventory in a block inventory holder! "); + if (GeyserLogger.getInstance().isDebug()) { + GeyserLogger.getInstance().debug("Current inventory: " + inventory); + GeyserLogger.getInstance().debug("Open inventory: " + session.getOpenInventory()); } // Try to save ourselves? maybe? // https://github.com/GeyserMC/Geyser/issues/4141 diff --git a/core/src/main/java/org/geysermc/geyser/inventory/updater/AnvilInventoryUpdater.java b/core/src/main/java/org/geysermc/geyser/inventory/updater/AnvilInventoryUpdater.java index 7afd31cc9f2..4e10ae94956 100644 --- a/core/src/main/java/org/geysermc/geyser/inventory/updater/AnvilInventoryUpdater.java +++ b/core/src/main/java/org/geysermc/geyser/inventory/updater/AnvilInventoryUpdater.java @@ -27,20 +27,19 @@ import it.unimi.dsi.fastutil.objects.Object2IntMap; import it.unimi.dsi.fastutil.objects.Object2IntOpenHashMap; -import java.util.stream.IntStream; import net.kyori.adventure.text.Component; import org.cloudburstmc.nbt.NbtMap; import org.cloudburstmc.nbt.NbtMapBuilder; import org.cloudburstmc.protocol.bedrock.data.inventory.ContainerId; import org.cloudburstmc.protocol.bedrock.data.inventory.ItemData; import org.cloudburstmc.protocol.bedrock.packet.InventorySlotPacket; -import org.geysermc.geyser.GeyserImpl; +import org.geysermc.geyser.GeyserLogger; import org.geysermc.geyser.inventory.AnvilContainer; import org.geysermc.geyser.inventory.GeyserItemStack; import org.geysermc.geyser.inventory.Inventory; import org.geysermc.geyser.inventory.item.BedrockEnchantment; -import org.geysermc.geyser.item.enchantment.Enchantment; import org.geysermc.geyser.item.Items; +import org.geysermc.geyser.item.enchantment.Enchantment; import org.geysermc.geyser.session.GeyserSession; import org.geysermc.geyser.session.cache.tags.EnchantmentTag; import org.geysermc.geyser.session.cache.tags.ItemTag; @@ -55,6 +54,7 @@ import java.util.Map; import java.util.Objects; +import java.util.stream.IntStream; public class AnvilInventoryUpdater extends InventoryUpdater { public static final AnvilInventoryUpdater INSTANCE = new AnvilInventoryUpdater(); @@ -383,7 +383,7 @@ private Object2IntMap getEnchantments(GeyserSession session, Geyser for (Map.Entry entry : enchantmentComponent.getEnchantments().entrySet()) { Enchantment enchantment = session.getRegistryCache().enchantments().byId(entry.getKey()); if (enchantment == null) { - GeyserImpl.getInstance().getLogger().debug("Unknown Java enchantment in anvil: " + entry.getKey()); + GeyserLogger.getInstance().debug("Unknown Java enchantment in anvil: " + entry.getKey()); continue; } enchantments.put(enchantment, entry.getValue().intValue()); diff --git a/core/src/main/java/org/geysermc/geyser/item/type/EnchantedBookItem.java b/core/src/main/java/org/geysermc/geyser/item/type/EnchantedBookItem.java index 8b0f3e22e82..1e8c44d7802 100644 --- a/core/src/main/java/org/geysermc/geyser/item/type/EnchantedBookItem.java +++ b/core/src/main/java/org/geysermc/geyser/item/type/EnchantedBookItem.java @@ -30,7 +30,7 @@ import org.checkerframework.checker.nullness.qual.NonNull; import org.cloudburstmc.nbt.NbtMap; import org.cloudburstmc.nbt.NbtType; -import org.geysermc.geyser.GeyserImpl; +import org.geysermc.geyser.GeyserLogger; import org.geysermc.geyser.inventory.item.BedrockEnchantment; import org.geysermc.geyser.item.enchantment.Enchantment; import org.geysermc.geyser.registry.type.ItemMapping; @@ -90,7 +90,7 @@ public void translateNbtToJava(@NonNull GeyserSession session, @NonNull NbtMap b } } } else { - GeyserImpl.getInstance().getLogger().debug("Unknown bedrock enchantment: " + bedrockId); + GeyserLogger.getInstance().debug("Unknown bedrock enchantment: " + bedrockId); } } if (!javaEnchantments.isEmpty()) { diff --git a/core/src/main/java/org/geysermc/geyser/item/type/Item.java b/core/src/main/java/org/geysermc/geyser/item/type/Item.java index a8a477025bb..a1eba13ccf1 100644 --- a/core/src/main/java/org/geysermc/geyser/item/type/Item.java +++ b/core/src/main/java/org/geysermc/geyser/item/type/Item.java @@ -32,7 +32,7 @@ import org.cloudburstmc.nbt.NbtMap; import org.cloudburstmc.nbt.NbtType; import org.cloudburstmc.protocol.bedrock.data.inventory.ItemData; -import org.geysermc.geyser.GeyserImpl; +import org.geysermc.geyser.GeyserLogger; import org.geysermc.geyser.inventory.GeyserItemStack; import org.geysermc.geyser.inventory.item.BedrockEnchantment; import org.geysermc.geyser.item.Items; @@ -219,7 +219,7 @@ public void translateNbtToJava(@NonNull GeyserSession session, @NonNull NbtMap b protected final @Nullable NbtMap remapEnchantment(GeyserSession session, int enchantId, int level, BedrockItemBuilder builder) { Enchantment enchantment = session.getRegistryCache().enchantments().byId(enchantId); if (enchantment == null) { - GeyserImpl.getInstance().getLogger().debug("Unknown Java enchantment while NBT item translating: " + enchantId); + GeyserLogger.getInstance().debug("Unknown Java enchantment while NBT item translating: " + enchantId); return null; } diff --git a/core/src/main/java/org/geysermc/geyser/item/type/PotionItem.java b/core/src/main/java/org/geysermc/geyser/item/type/PotionItem.java index f8fe2b4ee3b..b5525175317 100644 --- a/core/src/main/java/org/geysermc/geyser/item/type/PotionItem.java +++ b/core/src/main/java/org/geysermc/geyser/item/type/PotionItem.java @@ -28,7 +28,7 @@ import org.checkerframework.checker.nullness.qual.NonNull; import org.cloudburstmc.protocol.bedrock.data.definitions.ItemDefinition; import org.cloudburstmc.protocol.bedrock.data.inventory.ItemData; -import org.geysermc.geyser.GeyserImpl; +import org.geysermc.geyser.GeyserLogger; import org.geysermc.geyser.inventory.GeyserItemStack; import org.geysermc.geyser.inventory.item.Potion; import org.geysermc.geyser.registry.type.ItemMapping; @@ -57,7 +57,7 @@ public ItemData.Builder translateToBedrock(int count, DataComponents components, .damage(potion.getBedrockId()) .count(count); } - GeyserImpl.getInstance().getLogger().debug("Unknown Java potion: " + potionContents.getPotionId()); + GeyserLogger.getInstance().debug("Unknown Java potion: " + potionContents.getPotionId()); } else { return ItemData.builder() .definition(customItemDefinition) diff --git a/core/src/main/java/org/geysermc/geyser/item/type/TippedArrowItem.java b/core/src/main/java/org/geysermc/geyser/item/type/TippedArrowItem.java index d9e58eaf97b..d258435b073 100644 --- a/core/src/main/java/org/geysermc/geyser/item/type/TippedArrowItem.java +++ b/core/src/main/java/org/geysermc/geyser/item/type/TippedArrowItem.java @@ -26,7 +26,7 @@ package org.geysermc.geyser.item.type; import org.cloudburstmc.protocol.bedrock.data.inventory.ItemData; -import org.geysermc.geyser.GeyserImpl; +import org.geysermc.geyser.GeyserLogger; import org.geysermc.geyser.inventory.item.Potion; import org.geysermc.geyser.registry.type.ItemMapping; import org.geysermc.geyser.registry.type.ItemMappings; @@ -51,7 +51,7 @@ public ItemData.Builder translateToBedrock(int count, DataComponents components, .damage(potion.tippedArrowId()) .count(count); } - GeyserImpl.getInstance().getLogger().debug("Unknown Java potion (tipped arrow): " + potionContents.getPotionId()); + GeyserLogger.getInstance().debug("Unknown Java potion (tipped arrow): " + potionContents.getPotionId()); } } return super.translateToBedrock(count, components, mapping, mappings); diff --git a/core/src/main/java/org/geysermc/geyser/level/JukeboxSong.java b/core/src/main/java/org/geysermc/geyser/level/JukeboxSong.java index b00dc9f98cf..fe7d263e763 100644 --- a/core/src/main/java/org/geysermc/geyser/level/JukeboxSong.java +++ b/core/src/main/java/org/geysermc/geyser/level/JukeboxSong.java @@ -26,7 +26,7 @@ package org.geysermc.geyser.level; import org.cloudburstmc.nbt.NbtMap; -import org.geysermc.geyser.GeyserImpl; +import org.geysermc.geyser.GeyserLogger; import org.geysermc.geyser.session.cache.registry.RegistryEntryContext; import org.geysermc.geyser.translator.text.MessageTranslator; @@ -42,7 +42,7 @@ public static JukeboxSong read(RegistryEntryContext context) { soundEvent = string; } else { soundEvent = ""; - GeyserImpl.getInstance().getLogger().debug("Sound event for " + context.id() + " was of an unexpected type! Expected string or NBT map, got " + soundEventObject); + GeyserLogger.getInstance().debug("Sound event for " + context.id() + " was of an unexpected type! Expected string or NBT map, got " + soundEventObject); } String description = MessageTranslator.deserializeDescription(data); return new JukeboxSong(soundEvent, description); diff --git a/core/src/main/java/org/geysermc/geyser/level/block/GeyserCustomBlockData.java b/core/src/main/java/org/geysermc/geyser/level/block/GeyserCustomBlockData.java index d717e33c517..15f9d669b06 100644 --- a/core/src/main/java/org/geysermc/geyser/level/block/GeyserCustomBlockData.java +++ b/core/src/main/java/org/geysermc/geyser/level/block/GeyserCustomBlockData.java @@ -25,12 +25,16 @@ package org.geysermc.geyser.level.block; -import it.unimi.dsi.fastutil.objects.*; +import it.unimi.dsi.fastutil.objects.Object2ObjectArrayMap; +import it.unimi.dsi.fastutil.objects.Object2ObjectMap; +import it.unimi.dsi.fastutil.objects.Object2ObjectMaps; +import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap; +import it.unimi.dsi.fastutil.objects.ObjectLists; import lombok.RequiredArgsConstructor; import org.checkerframework.checker.nullness.qual.NonNull; import org.checkerframework.checker.nullness.qual.Nullable; import org.geysermc.geyser.Constants; -import org.geysermc.geyser.GeyserImpl; +import org.geysermc.geyser.GeyserLogger; import org.geysermc.geyser.api.block.custom.CustomBlockData; import org.geysermc.geyser.api.block.custom.CustomBlockPermutation; import org.geysermc.geyser.api.block.custom.CustomBlockState; @@ -71,7 +75,7 @@ public class GeyserCustomBlockData implements CustomBlockData { Object2ObjectMap defaultProperties = new Object2ObjectOpenHashMap<>(this.properties.size()); for (CustomBlockProperty property : properties.values()) { if (property.values().size() > 16) { - GeyserImpl.getInstance().getLogger().warning(property.name() + " contains more than 16 values, but BDS specifies it should not. This may break in future versions."); + GeyserLogger.getInstance().warning(property.name() + " contains more than 16 values, but BDS specifies it should not. This may break in future versions."); } if (property.values().stream().distinct().count() != property.values().size()) { throw new IllegalStateException(property.name() + " has duplicate values."); diff --git a/core/src/main/java/org/geysermc/geyser/network/netty/Bootstraps.java b/core/src/main/java/org/geysermc/geyser/network/netty/Bootstraps.java index fbc33310631..e66e21ba95f 100644 --- a/core/src/main/java/org/geysermc/geyser/network/netty/Bootstraps.java +++ b/core/src/main/java/org/geysermc/geyser/network/netty/Bootstraps.java @@ -31,7 +31,7 @@ import io.netty.channel.epoll.Native; import io.netty.channel.unix.UnixChannelOption; import lombok.experimental.UtilityClass; -import org.geysermc.geyser.GeyserImpl; +import org.geysermc.geyser.GeyserLogger; import java.util.concurrent.CompletableFuture; import java.util.regex.Matcher; @@ -49,9 +49,9 @@ public final class Bootstraps { String kernelVersion; try { kernelVersion = Native.KERNEL_VERSION; - GeyserImpl.getInstance().getLogger().debug("Kernel version: " + kernelVersion); + GeyserLogger.getInstance().debug("Kernel version: " + kernelVersion); } catch (Throwable e) { - GeyserImpl.getInstance().getLogger().debug("Could not determine kernel version! " + e.getMessage()); + GeyserLogger.getInstance().debug("Could not determine kernel version! " + e.getMessage()); kernelVersion = null; } @@ -77,7 +77,7 @@ public static boolean setupBootstrap(AbstractBootstrap bootstrap) { bootstrap.option(UnixChannelOption.SO_REUSEPORT, true); } else { // If this occurs, we guessed wrong and reuseport is not available - GeyserImpl.getInstance().getLogger().debug("so_reuseport is not available despite version being " + Native.KERNEL_VERSION); + GeyserLogger.getInstance().debug("so_reuseport is not available despite version being " + Native.KERNEL_VERSION); success = false; } // Now yeet that channel diff --git a/core/src/main/java/org/geysermc/geyser/network/netty/GeyserServer.java b/core/src/main/java/org/geysermc/geyser/network/netty/GeyserServer.java index 5166bde4d94..b9ba4082563 100644 --- a/core/src/main/java/org/geysermc/geyser/network/netty/GeyserServer.java +++ b/core/src/main/java/org/geysermc/geyser/network/netty/GeyserServer.java @@ -51,6 +51,7 @@ import org.cloudburstmc.netty.handler.codec.raknet.server.RakServerRateLimiter; import org.cloudburstmc.protocol.bedrock.BedrockPong; import org.geysermc.geyser.GeyserImpl; +import org.geysermc.geyser.GeyserLogger; import org.geysermc.geyser.api.event.connection.ConnectionRequestEvent; import org.geysermc.geyser.command.defaults.ConnectionTestCommand; import org.geysermc.geyser.configuration.GeyserConfiguration; @@ -125,7 +126,7 @@ public final class GeyserServer { public GeyserServer(GeyserImpl geyser, int threadCount) { this.geyser = geyser; this.listenCount = Bootstraps.isReusePortAvailable() ? Integer.getInteger("Geyser.ListenCount", 2) : 1; - GeyserImpl.getInstance().getLogger().debug("Listen thread count: " + listenCount); + GeyserLogger.getInstance().debug("Listen thread count: " + listenCount); this.group = TRANSPORT.eventLoopGroupFactory().apply(listenCount); this.childGroup = TRANSPORT.eventLoopGroupFactory().apply(threadCount); @@ -198,7 +199,7 @@ public void shutdown() { SkinProvider.shutdown(); } catch (InterruptedException e) { - GeyserImpl.getInstance().getLogger().severe("Exception in shutdown process", e); + GeyserLogger.getInstance().severe("Exception in shutdown process", e); } for (ChannelFuture f : bootstrapFutures) { f.channel().closeFuture().syncUninterruptibly(); @@ -419,7 +420,7 @@ private static int positivePropOrDefault(String property, int defaultValue) { int parsed = value != null ? Integer.parseInt(value) : defaultValue; if (parsed < 1) { - GeyserImpl.getInstance().getLogger().warning( + GeyserLogger.getInstance().warning( "Non-postive integer value for " + property + ": " + value + ". Using default value: " + defaultValue ); return defaultValue; @@ -427,7 +428,7 @@ private static int positivePropOrDefault(String property, int defaultValue) { return parsed; } catch (NumberFormatException e) { - GeyserImpl.getInstance().getLogger().warning( + GeyserLogger.getInstance().warning( "Invalid integer value for " + property + ": " + value + ". Using default value: " + defaultValue ); return defaultValue; diff --git a/core/src/main/java/org/geysermc/geyser/pack/SkullResourcePackManager.java b/core/src/main/java/org/geysermc/geyser/pack/SkullResourcePackManager.java index 59651d1393a..f711488c6c6 100644 --- a/core/src/main/java/org/geysermc/geyser/pack/SkullResourcePackManager.java +++ b/core/src/main/java/org/geysermc/geyser/pack/SkullResourcePackManager.java @@ -30,6 +30,7 @@ import org.checkerframework.checker.nullness.qual.Nullable; import org.geysermc.geyser.Constants; import org.geysermc.geyser.GeyserImpl; +import org.geysermc.geyser.GeyserLogger; import org.geysermc.geyser.api.pack.ResourcePackManifest; import org.geysermc.geyser.registry.BlockRegistries; import org.geysermc.geyser.registry.type.CustomSkull; @@ -39,7 +40,11 @@ import javax.imageio.ImageIO; import java.awt.*; import java.awt.image.BufferedImage; -import java.io.*; +import java.io.BufferedReader; +import java.io.File; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; import java.nio.ByteBuffer; import java.nio.charset.StandardCharsets; import java.nio.file.Files; @@ -71,7 +76,7 @@ public class SkullResourcePackManager { try { Files.createDirectories(cachePath); } catch (IOException e) { - GeyserImpl.getInstance().getLogger().severe("Unable to create directories for player skull resource pack!", e); + GeyserLogger.getInstance().severe("Unable to create directories for player skull resource pack!", e); return null; } cleanSkullSkinCache(); @@ -83,22 +88,22 @@ public class SkullResourcePackManager { return null; } if (packFile.exists() && canReusePack(packFile)) { - GeyserImpl.getInstance().getLogger().info("Reusing cached player skull resource pack."); + GeyserLogger.getInstance().info("Reusing cached player skull resource pack."); return packPath; } // We need to create the resource pack from scratch - GeyserImpl.getInstance().getLogger().info("Creating skull resource pack."); + GeyserLogger.getInstance().info("Creating skull resource pack."); packFile.delete(); try (ZipOutputStream zipOS = new ZipOutputStream(Files.newOutputStream(packPath, StandardOpenOption.WRITE, StandardOpenOption.CREATE))) { addBaseResources(zipOS); addSkinTextures(zipOS); addAttachables(zipOS); - GeyserImpl.getInstance().getLogger().info("Finished creating skull resource pack."); + GeyserLogger.getInstance().info("Finished creating skull resource pack."); return packPath; } catch (IOException e) { - GeyserImpl.getInstance().getLogger().severe("Unable to create player skull resource pack!", e); - GeyserImpl.getInstance().getLogger().severe("Bedrock players will see dirt blocks instead of custom skull blocks."); + GeyserLogger.getInstance().severe("Unable to create player skull resource pack!", e); + GeyserLogger.getInstance().severe("Bedrock players will see dirt blocks instead of custom skull blocks."); packFile.delete(); } return null; @@ -138,7 +143,7 @@ public static void cacheSkullSkin(String skinHash) throws IOException { ImageIO.write(skullTexture, "png", skinPath.toFile()); SKULL_SKINS.put(skinHash, skinPath); - GeyserImpl.getInstance().getLogger().debug("Cached player skull to " + skinPath + " for " + skinHash); + GeyserLogger.getInstance().debug("Cached player skull to " + skinPath + " for " + skinHash); } public static void cleanSkullSkinCache() { @@ -157,10 +162,10 @@ public static void cleanSkullSkinCache() { } } if (removeCount != 0) { - GeyserImpl.getInstance().getLogger().debug("Removed " + removeCount + " unnecessary skull skins."); + GeyserLogger.getInstance().debug("Removed " + removeCount + " unnecessary skull skins."); } } catch (IOException e) { - GeyserImpl.getInstance().getLogger().debug("Unable to clean up skull skin cache."); + GeyserLogger.getInstance().debug("Unable to clean up skull skin cache."); if (GeyserImpl.getInstance().getConfig().isDebugMode()) { e.printStackTrace(); } @@ -279,7 +284,7 @@ private static Pair generatePackUUIDs() { uuid1 = new UUID(skinHashes.getLong(), skinHashes.getLong()); uuid2 = new UUID(skinHashes.getLong(), skinHashes.getLong()); } catch (NoSuchAlgorithmException e) { - GeyserImpl.getInstance().getLogger().severe("Unable to get SHA-256 Message Digest instance! Bedrock players will have to re-downloaded the player skull resource pack after each server restart.", e); + GeyserLogger.getInstance().severe("Unable to get SHA-256 Message Digest instance! Bedrock players will have to re-downloaded the player skull resource pack after each server restart.", e); } return Pair.of(uuid1, uuid2); @@ -303,7 +308,7 @@ private static boolean canReusePack(File packFile) { return resourceUUID.isPresent() && uuids.second().equals(resourceUUID.get()); } } catch (IOException e) { - GeyserImpl.getInstance().getLogger().debug("Cached player skull resource pack was invalid! The pack will be recreated."); + GeyserLogger.getInstance().debug("Cached player skull resource pack was invalid! The pack will be recreated."); } return false; } diff --git a/core/src/main/java/org/geysermc/geyser/pack/path/GeyserPathPackCodec.java b/core/src/main/java/org/geysermc/geyser/pack/path/GeyserPathPackCodec.java index 84067600fce..1c1048a8f72 100644 --- a/core/src/main/java/org/geysermc/geyser/pack/path/GeyserPathPackCodec.java +++ b/core/src/main/java/org/geysermc/geyser/pack/path/GeyserPathPackCodec.java @@ -27,7 +27,7 @@ import lombok.RequiredArgsConstructor; import org.checkerframework.checker.nullness.qual.NonNull; -import org.geysermc.geyser.GeyserImpl; +import org.geysermc.geyser.GeyserLogger; import org.geysermc.geyser.api.pack.PathPackCodec; import org.geysermc.geyser.api.pack.ResourcePack; import org.geysermc.geyser.registry.loader.ResourcePackLoader; @@ -97,7 +97,7 @@ private void checkLastModified() { } if (lastModified.toInstant().isAfter(this.lastModified.toInstant())) { - GeyserImpl.getInstance().getLogger().warning("Detected a change in the resource pack " + path + ". This is likely to cause undefined behavior for new clients joining. It is suggested you restart Geyser."); + GeyserLogger.getInstance().warning("Detected a change in the resource pack " + path + ". This is likely to cause undefined behavior for new clients joining. It is suggested you restart Geyser."); this.lastModified = lastModified; this.sha256 = null; this.size = -1; diff --git a/core/src/main/java/org/geysermc/geyser/registry/PacketTranslatorRegistry.java b/core/src/main/java/org/geysermc/geyser/registry/PacketTranslatorRegistry.java index 9a5b43816fd..c126efc7d69 100644 --- a/core/src/main/java/org/geysermc/geyser/registry/PacketTranslatorRegistry.java +++ b/core/src/main/java/org/geysermc/geyser/registry/PacketTranslatorRegistry.java @@ -25,16 +25,17 @@ package org.geysermc.geyser.registry; -import org.geysermc.mcprotocollib.protocol.packet.ingame.clientbound.ClientboundDelimiterPacket; -import org.geysermc.mcprotocollib.protocol.packet.ingame.clientbound.ClientboundTabListPacket; -import org.geysermc.mcprotocollib.protocol.packet.ingame.clientbound.level.ClientboundChunkBatchStartPacket; -import org.geysermc.mcprotocollib.protocol.packet.ingame.clientbound.level.ClientboundLightUpdatePacket; import io.netty.channel.EventLoop; import org.geysermc.geyser.GeyserImpl; +import org.geysermc.geyser.GeyserLogger; import org.geysermc.geyser.registry.loader.RegistryLoaders; import org.geysermc.geyser.session.GeyserSession; import org.geysermc.geyser.text.GeyserLocale; import org.geysermc.geyser.translator.protocol.PacketTranslator; +import org.geysermc.mcprotocollib.protocol.packet.ingame.clientbound.ClientboundDelimiterPacket; +import org.geysermc.mcprotocollib.protocol.packet.ingame.clientbound.ClientboundTabListPacket; +import org.geysermc.mcprotocollib.protocol.packet.ingame.clientbound.level.ClientboundChunkBatchStartPacket; +import org.geysermc.mcprotocollib.protocol.packet.ingame.clientbound.level.ClientboundLightUpdatePacket; import java.util.Collections; import java.util.IdentityHashMap; @@ -72,7 +73,7 @@ public

boolean translate(Class clazz, P packet, Geyse } else { if (GeyserImpl.getInstance().getConfig().isDebugMode()) { if (!IGNORED_PACKETS.contains(clazz)) { - GeyserImpl.getInstance().getLogger().debug("Could not find packet for " + (packet.toString().length() > 25 ? packet.getClass().getSimpleName() : packet)); + GeyserLogger.getInstance().debug("Could not find packet for " + (packet.toString().length() > 25 ? packet.getClass().getSimpleName() : packet)); } } @@ -88,7 +89,7 @@ private

void translate0(GeyserSession session, PacketTranslator

try { translator.translate(session, packet); } catch (Throwable ex) { - GeyserImpl.getInstance().getLogger().error(GeyserLocale.getLocaleStringLog("geyser.network.translator.packet.failed", packet.getClass().getSimpleName()), ex); + GeyserLogger.getInstance().error(GeyserLocale.getLocaleStringLog("geyser.network.translator.packet.failed", packet.getClass().getSimpleName()), ex); ex.printStackTrace(); } } diff --git a/core/src/main/java/org/geysermc/geyser/registry/loader/CollisionRegistryLoader.java b/core/src/main/java/org/geysermc/geyser/registry/loader/CollisionRegistryLoader.java index bd98ae0a5a0..205832fb1a6 100644 --- a/core/src/main/java/org/geysermc/geyser/registry/loader/CollisionRegistryLoader.java +++ b/core/src/main/java/org/geysermc/geyser/registry/loader/CollisionRegistryLoader.java @@ -35,6 +35,7 @@ import org.cloudburstmc.nbt.NbtType; import org.cloudburstmc.nbt.NbtUtils; import org.geysermc.geyser.GeyserImpl; +import org.geysermc.geyser.GeyserLogger; import org.geysermc.geyser.level.block.type.BlockState; import org.geysermc.geyser.level.physics.BoundingBox; import org.geysermc.geyser.registry.BlockRegistries; @@ -46,7 +47,11 @@ import java.io.InputStream; import java.lang.reflect.InvocationTargetException; -import java.util.*; +import java.util.Arrays; +import java.util.Comparator; +import java.util.IdentityHashMap; +import java.util.List; +import java.util.Map; import java.util.regex.Pattern; /** @@ -58,7 +63,7 @@ public class CollisionRegistryLoader extends MultiResourceRegistryLoader load(Pair input) { Map, CollisionInfo> annotationMap = new IdentityHashMap<>(); for (Class clazz : FileUtils.getGeneratedClassesForAnnotation(CollisionRemapper.class.getName())) { - GeyserImpl.getInstance().getLogger().debug("Found annotated collision translator: " + clazz.getCanonicalName()); + GeyserLogger.getInstance().debug("Found annotated collision translator: " + clazz.getCanonicalName()); CollisionRemapper collisionRemapper = clazz.getAnnotation(CollisionRemapper.class); annotationMap.put(clazz, new CollisionInfo(collisionRemapper, Pattern.compile(collisionRemapper.regex()))); @@ -84,7 +89,7 @@ public List load(Pair input) { for (int i = 0; i < blockStates.size(); i++) { BlockState state = blockStates.get(i); if (state == null) { - GeyserImpl.getInstance().getLogger().warning("Missing block state for Java block " + i); + GeyserLogger.getInstance().warning("Missing block state for Java block " + i); continue; } @@ -172,4 +177,4 @@ public static class CollisionInfo { private final CollisionRemapper collisionRemapper; private final Pattern pattern; } -} \ No newline at end of file +} diff --git a/core/src/main/java/org/geysermc/geyser/registry/loader/ParticleTypesRegistryLoader.java b/core/src/main/java/org/geysermc/geyser/registry/loader/ParticleTypesRegistryLoader.java index a09d6d6d3a1..e744e013e43 100644 --- a/core/src/main/java/org/geysermc/geyser/registry/loader/ParticleTypesRegistryLoader.java +++ b/core/src/main/java/org/geysermc/geyser/registry/loader/ParticleTypesRegistryLoader.java @@ -26,12 +26,12 @@ package org.geysermc.geyser.registry.loader; import com.fasterxml.jackson.databind.JsonNode; -import org.geysermc.mcprotocollib.protocol.data.game.level.particle.ParticleType; import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap; import org.cloudburstmc.protocol.bedrock.data.LevelEvent; import org.cloudburstmc.protocol.bedrock.data.LevelEventType; -import org.geysermc.geyser.GeyserImpl; +import org.geysermc.geyser.GeyserLogger; import org.geysermc.geyser.registry.type.ParticleMapping; +import org.geysermc.mcprotocollib.protocol.data.game.level.particle.ParticleType; import java.util.Iterator; import java.util.Locale; @@ -55,7 +55,7 @@ public Map load(String input) { JsonNode bedrockId = entry.getValue().get("bedrockId"); JsonNode eventType = entry.getValue().get("eventType"); if (eventType == null && bedrockId == null) { - GeyserImpl.getInstance().getLogger().debug("Skipping particle mapping " + key + " because no Bedrock equivalent exists."); + GeyserLogger.getInstance().debug("Skipping particle mapping " + key + " because no Bedrock equivalent exists."); continue; } @@ -80,4 +80,4 @@ public Map load(String input) { } return particles; } -} \ No newline at end of file +} diff --git a/core/src/main/java/org/geysermc/geyser/registry/loader/ResourcePackLoader.java b/core/src/main/java/org/geysermc/geyser/registry/loader/ResourcePackLoader.java index 800a3d22c6e..b8bb96c913e 100644 --- a/core/src/main/java/org/geysermc/geyser/registry/loader/ResourcePackLoader.java +++ b/core/src/main/java/org/geysermc/geyser/registry/loader/ResourcePackLoader.java @@ -26,6 +26,7 @@ package org.geysermc.geyser.registry.loader; import org.geysermc.geyser.GeyserImpl; +import org.geysermc.geyser.GeyserLogger; import org.geysermc.geyser.api.event.lifecycle.GeyserLoadResourcePacksEvent; import org.geysermc.geyser.api.pack.ResourcePack; import org.geysermc.geyser.pack.GeyserResourcePack; @@ -71,7 +72,7 @@ public Map load(Path directory) { try { Files.createDirectory(directory); } catch (IOException e) { - GeyserImpl.getInstance().getLogger().error("Could not create packs directory", e); + GeyserLogger.getInstance().error("Could not create packs directory", e); } } @@ -80,7 +81,7 @@ public Map load(Path directory) { resourcePacks = stream.filter(PACK_MATCHER::matches) .collect(Collectors.toCollection(ArrayList::new)); // toList() does not guarantee mutability } catch (Exception e) { - GeyserImpl.getInstance().getLogger().error("Could not list packs directory", e); + GeyserLogger.getInstance().error("Could not list packs directory", e); // Ensure the event is fired even if there was an issue reading // from our own resource pack directory. External projects may have @@ -128,7 +129,7 @@ public static GeyserResourcePack readPack(Path path) throws IllegalArgumentExcep stream.forEach(x -> { String name = x.getName(); if (SHOW_RESOURCE_PACK_LENGTH_WARNING && name.length() >= 80) { - GeyserImpl.getInstance().getLogger().warning("The resource pack " + path.getFileName() + GeyserLogger.getInstance().warning("The resource pack " + path.getFileName() + " has a file in it that meets or exceeds 80 characters in its path (" + name + ", " + name.length() + " characters long). This will cause problems on some Bedrock platforms." + " Please rename it to be shorter, or reduce the amount of folders needed to get to the file."); diff --git a/core/src/main/java/org/geysermc/geyser/registry/loader/SoundEventsRegistryLoader.java b/core/src/main/java/org/geysermc/geyser/registry/loader/SoundEventsRegistryLoader.java index 4e3fbe40a51..9964e05c5e5 100644 --- a/core/src/main/java/org/geysermc/geyser/registry/loader/SoundEventsRegistryLoader.java +++ b/core/src/main/java/org/geysermc/geyser/registry/loader/SoundEventsRegistryLoader.java @@ -26,14 +26,14 @@ package org.geysermc.geyser.registry.loader; import com.fasterxml.jackson.databind.JsonNode; -import org.geysermc.mcprotocollib.protocol.data.game.level.event.LevelEvent; import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap; import org.cloudburstmc.protocol.bedrock.data.LevelEventType; -import org.geysermc.geyser.GeyserImpl; +import org.geysermc.geyser.GeyserLogger; import org.geysermc.geyser.translator.level.event.LevelEventTranslator; import org.geysermc.geyser.translator.level.event.PlaySoundEventTranslator; import org.geysermc.geyser.translator.level.event.SoundEventEventTranslator; import org.geysermc.geyser.translator.level.event.SoundLevelEventTranslator; +import org.geysermc.mcprotocollib.protocol.data.game.level.event.LevelEvent; import java.util.Iterator; import java.util.Map; @@ -85,9 +85,9 @@ public Map load(String input) { soundEffects.put(javaEffect, transformer); } } catch (Exception e) { - GeyserImpl.getInstance().getLogger().warning("Failed to map sound effect " + entry.getKey() + " : " + e); + GeyserLogger.getInstance().warning("Failed to map sound effect " + entry.getKey() + " : " + e); } } return soundEffects; } -} \ No newline at end of file +} diff --git a/core/src/main/java/org/geysermc/geyser/registry/mappings/MappingsConfigReader.java b/core/src/main/java/org/geysermc/geyser/registry/mappings/MappingsConfigReader.java index d09e0b5a1e1..45ba463ba92 100644 --- a/core/src/main/java/org/geysermc/geyser/registry/mappings/MappingsConfigReader.java +++ b/core/src/main/java/org/geysermc/geyser/registry/mappings/MappingsConfigReader.java @@ -30,6 +30,7 @@ import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap; import org.checkerframework.checker.nullness.qual.Nullable; import org.geysermc.geyser.GeyserImpl; +import org.geysermc.geyser.GeyserLogger; import org.geysermc.geyser.api.item.custom.CustomItemData; import org.geysermc.geyser.registry.mappings.util.CustomBlockMapping; import org.geysermc.geyser.registry.mappings.versions.MappingsReader; @@ -66,7 +67,7 @@ public boolean ensureMappingsDirectory(Path mappingsDirectory) { Files.createDirectories(mappingsDirectory); return true; } catch (IOException e) { - GeyserImpl.getInstance().getLogger().error("Failed to create mappings directory", e); + GeyserLogger.getInstance().error("Failed to create mappings directory", e); return false; } } @@ -100,12 +101,12 @@ public void loadBlockMappingsFromJson(BiConsumer con try { mappingsRoot = GeyserImpl.JSON_MAPPER.readTree(file.toFile()); } catch (IOException e) { - GeyserImpl.getInstance().getLogger().error("Failed to read custom mapping file: " + file, e); + GeyserLogger.getInstance().error("Failed to read custom mapping file: " + file, e); return null; } if (!mappingsRoot.has("format_version")) { - GeyserImpl.getInstance().getLogger().error("Mappings file " + file + " is missing the format version field!"); + GeyserLogger.getInstance().error("Mappings file " + file + " is missing the format version field!"); return null; } @@ -115,7 +116,7 @@ public void loadBlockMappingsFromJson(BiConsumer con public int getFormatVersion(JsonNode mappingsRoot, Path file) { int formatVersion = mappingsRoot.get("format_version").asInt(); if (!this.mappingReaders.containsKey(formatVersion)) { - GeyserImpl.getInstance().getLogger().error("Mappings file " + file + " has an unknown format version: " + formatVersion); + GeyserLogger.getInstance().error("Mappings file " + file + " has an unknown format version: " + formatVersion); return -1; } return formatVersion; diff --git a/core/src/main/java/org/geysermc/geyser/registry/mappings/versions/MappingsReader_v1.java b/core/src/main/java/org/geysermc/geyser/registry/mappings/versions/MappingsReader_v1.java index b5e25a4ba5c..55b74d34ab4 100644 --- a/core/src/main/java/org/geysermc/geyser/registry/mappings/versions/MappingsReader_v1.java +++ b/core/src/main/java/org/geysermc/geyser/registry/mappings/versions/MappingsReader_v1.java @@ -30,13 +30,18 @@ import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap; import it.unimi.dsi.fastutil.objects.ObjectOpenHashSet; import org.checkerframework.checker.nullness.qual.Nullable; -import org.geysermc.geyser.GeyserImpl; +import org.geysermc.geyser.GeyserLogger; import org.geysermc.geyser.api.block.custom.CustomBlockData; import org.geysermc.geyser.api.block.custom.CustomBlockPermutation; import org.geysermc.geyser.api.block.custom.CustomBlockState; -import org.geysermc.geyser.api.block.custom.component.*; +import org.geysermc.geyser.api.block.custom.component.BoxComponent; +import org.geysermc.geyser.api.block.custom.component.CustomBlockComponents; +import org.geysermc.geyser.api.block.custom.component.GeometryComponent; +import org.geysermc.geyser.api.block.custom.component.MaterialInstance; +import org.geysermc.geyser.api.block.custom.component.PlacementConditions; import org.geysermc.geyser.api.block.custom.component.PlacementConditions.BlockFilterType; import org.geysermc.geyser.api.block.custom.component.PlacementConditions.Face; +import org.geysermc.geyser.api.block.custom.component.TransformationComponent; import org.geysermc.geyser.api.item.custom.CustomItemData; import org.geysermc.geyser.api.item.custom.CustomItemOptions; import org.geysermc.geyser.api.util.CreativeCategory; @@ -57,7 +62,14 @@ import org.geysermc.geyser.util.MinecraftKey; import java.nio.file.Path; -import java.util.*; +import java.util.ArrayList; +import java.util.EnumSet; +import java.util.Iterator; +import java.util.LinkedHashMap; +import java.util.LinkedHashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; import java.util.function.BiConsumer; import java.util.function.Function; import java.util.function.Predicate; @@ -96,7 +108,7 @@ public void readItemMappingsV1(Path file, JsonNode mappingsRoot, BiConsumer Long.compareUnsigned(fnv164(a.getString("name")), fnv164(b.getString("name")))); @@ -343,7 +360,7 @@ private static void registerBedrockBlocks() { for (Map.Entry entry : nonVanillaStateOverrides.entrySet()) { GeyserBedrockBlock bedrockDefinition = customBlockStateDefinitions.get(entry.getValue()); if (bedrockDefinition == null) { - GeyserImpl.getInstance().getLogger().warning("Unable to find custom block for " + entry.getValue()); + GeyserLogger.getInstance().warning("Unable to find custom block for " + entry.getValue()); continue; } @@ -445,7 +462,7 @@ public ItemStack pickItem(BlockState state) { if (this.item == null) { this.item = Registries.JAVA_ITEM_IDENTIFIERS.get(pickItem); if (this.item == null) { - GeyserImpl.getInstance().getLogger().warning("We could not find item " + pickItem + GeyserLogger.getInstance().warning("We could not find item " + pickItem + " for getting the item for block " + javaBlockState.identifier()); this.item = Items.AIR; } diff --git a/core/src/main/java/org/geysermc/geyser/registry/populator/CreativeItemRegistryPopulator.java b/core/src/main/java/org/geysermc/geyser/registry/populator/CreativeItemRegistryPopulator.java index 8e42887ff0b..b1b1132fe67 100644 --- a/core/src/main/java/org/geysermc/geyser/registry/populator/CreativeItemRegistryPopulator.java +++ b/core/src/main/java/org/geysermc/geyser/registry/populator/CreativeItemRegistryPopulator.java @@ -34,6 +34,7 @@ import org.cloudburstmc.protocol.bedrock.data.inventory.ItemData; import org.geysermc.geyser.GeyserBootstrap; import org.geysermc.geyser.GeyserImpl; +import org.geysermc.geyser.GeyserLogger; import org.geysermc.geyser.registry.BlockRegistries; import org.geysermc.geyser.registry.type.BlockMappings; import org.geysermc.geyser.registry.type.GeyserBedrockBlock; @@ -134,7 +135,7 @@ static void populate(ItemRegistryPopulator.PaletteVersion palette, Map entry : BLOCK_STATE_OVERRIDES_QUEUE.entrySet()) { int id = BlockRegistries.JAVA_IDENTIFIER_TO_ID.getOrDefault(entry.getKey(), -1); if (id == -1) { - GeyserImpl.getInstance().getLogger().warning("Custom block state override for Java Identifier: " + + GeyserLogger.getInstance().warning("Custom block state override for Java Identifier: " + entry.getKey() + " could not be registered as it is not a valid block state."); continue; } CustomBlockState oldBlockState = blockStateOverrides.put(id, entry.getValue()); if (oldBlockState != null) { - GeyserImpl.getInstance().getLogger().warning("Duplicate block state override for Java Identifier: " + + GeyserLogger.getInstance().warning("Duplicate block state override for Java Identifier: " + entry.getKey() + " Old override: " + oldBlockState.name() + " New override: " + entry.getValue().name()); } } @@ -212,17 +213,17 @@ private static void populateVanilla() { BlockRegistries.CUSTOM_BLOCK_STATE_OVERRIDES.set(blockStateOverrides); if (!blockStateOverrides.isEmpty()) { - GeyserImpl.getInstance().getLogger().info("Registered " + blockStateOverrides.size() + " custom block overrides."); + GeyserLogger.getInstance().info("Registered " + blockStateOverrides.size() + " custom block overrides."); } BlockRegistries.CUSTOM_BLOCK_ITEM_OVERRIDES.set(CUSTOM_BLOCK_ITEM_OVERRIDES); if (!CUSTOM_BLOCK_ITEM_OVERRIDES.isEmpty()) { - GeyserImpl.getInstance().getLogger().info("Registered " + CUSTOM_BLOCK_ITEM_OVERRIDES.size() + " custom block item overrides."); + GeyserLogger.getInstance().info("Registered " + CUSTOM_BLOCK_ITEM_OVERRIDES.size() + " custom block item overrides."); } BlockRegistries.EXTENDED_COLLISION_BOXES.set(extendedCollisionBoxes); if (!extendedCollisionBoxes.isEmpty()) { - GeyserImpl.getInstance().getLogger().info("Registered " + extendedCollisionBoxes.size() + " custom block extended collision boxes."); + GeyserLogger.getInstance().info("Registered " + extendedCollisionBoxes.size() + " custom block extended collision boxes."); } } @@ -232,7 +233,7 @@ private static void populateVanilla() { private static void populateNonVanilla() { BlockRegistries.NON_VANILLA_BLOCK_STATE_OVERRIDES.set(NON_VANILLA_BLOCK_STATE_OVERRIDES); if (!NON_VANILLA_BLOCK_STATE_OVERRIDES.isEmpty()) { - GeyserImpl.getInstance().getLogger().info("Registered " + NON_VANILLA_BLOCK_STATE_OVERRIDES.size() + " non-vanilla block overrides."); + GeyserLogger.getInstance().info("Registered " + NON_VANILLA_BLOCK_STATE_OVERRIDES.size() + " non-vanilla block overrides."); } } @@ -242,7 +243,7 @@ private static void populateNonVanilla() { private static void registration() { BlockRegistries.CUSTOM_BLOCKS.set(CUSTOM_BLOCKS.toArray(new CustomBlockData[0])); if (!CUSTOM_BLOCKS.isEmpty()) { - GeyserImpl.getInstance().getLogger().info("Registered " + CUSTOM_BLOCKS.size() + " custom blocks."); + GeyserLogger.getInstance().info("Registered " + CUSTOM_BLOCKS.size() + " custom blocks."); } } diff --git a/core/src/main/java/org/geysermc/geyser/registry/populator/CustomItemRegistryPopulator.java b/core/src/main/java/org/geysermc/geyser/registry/populator/CustomItemRegistryPopulator.java index 0a9c93980a7..067bc11d974 100644 --- a/core/src/main/java/org/geysermc/geyser/registry/populator/CustomItemRegistryPopulator.java +++ b/core/src/main/java/org/geysermc/geyser/registry/populator/CustomItemRegistryPopulator.java @@ -35,6 +35,7 @@ import org.cloudburstmc.protocol.bedrock.data.definitions.SimpleItemDefinition; import org.cloudburstmc.protocol.bedrock.data.inventory.ComponentItemData; import org.geysermc.geyser.GeyserImpl; +import org.geysermc.geyser.GeyserLogger; import org.geysermc.geyser.api.item.custom.CustomItemData; import org.geysermc.geyser.api.item.custom.CustomRenderOffsets; import org.geysermc.geyser.api.item.custom.NonVanillaCustomItemData; @@ -49,7 +50,12 @@ import org.geysermc.geyser.registry.type.ItemMapping; import org.geysermc.geyser.registry.type.NonVanillaItemRegistration; -import java.util.*; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.Set; public class CustomItemRegistryPopulator { public static void populate(Map items, Multimap customItems, List nonVanillaCustomItems) { @@ -74,14 +80,14 @@ public boolean register(@NonNull String identifier, @NonNull CustomItemData cust @Override public boolean register(@NonNull NonVanillaCustomItemData customItemData) { if (customItemData.identifier().startsWith("minecraft:")) { - GeyserImpl.getInstance().getLogger().error("The custom item " + customItemData.identifier() + + GeyserLogger.getInstance().error("The custom item " + customItemData.identifier() + " is attempting to masquerade as a vanilla Minecraft item!"); return false; } if (customItemData.javaId() < items.size()) { // Attempting to overwrite an item that already exists in the protocol - GeyserImpl.getInstance().getLogger().error("The custom item " + customItemData.identifier() + + GeyserLogger.getInstance().error("The custom item " + customItemData.identifier() + " is attempting to overwrite a vanilla Minecraft item!"); return false; } @@ -93,7 +99,7 @@ public boolean register(@NonNull NonVanillaCustomItemData customItemData) { int customItemCount = customItems.size() + nonVanillaCustomItems.size(); if (customItemCount > 0) { - GeyserImpl.getInstance().getLogger().info("Registered " + customItemCount + " custom items"); + GeyserLogger.getInstance().info("Registered " + customItemCount + " custom items"); } } @@ -108,18 +114,18 @@ public static GeyserCustomMappingData registerCustomItem(String customItemName, static boolean initialCheck(String identifier, CustomItemData item, Map mappings) { if (!mappings.containsKey(identifier)) { - GeyserImpl.getInstance().getLogger().error("Could not find the Java item to add custom item properties to for " + item.name()); + GeyserLogger.getInstance().error("Could not find the Java item to add custom item properties to for " + item.name()); return false; } if (!item.customItemOptions().hasCustomItemOptions()) { - GeyserImpl.getInstance().getLogger().error("The custom item " + item.name() + " has no registration types"); + GeyserLogger.getInstance().error("The custom item " + item.name() + " has no registration types"); } String name = item.name(); if (name.isEmpty()) { - GeyserImpl.getInstance().getLogger().warning("Custom item name is empty?"); + GeyserLogger.getInstance().warning("Custom item name is empty?"); } else if (Character.isDigit(name.charAt(0))) { // As of 1.19.31 - GeyserImpl.getInstance().getLogger().warning("Custom item name (" + name + ") begins with a digit. This may cause issues!"); + GeyserLogger.getInstance().warning("Custom item name (" + name + ") begins with a digit. This may cause issues!"); } return true; } diff --git a/core/src/main/java/org/geysermc/geyser/registry/populator/CustomSkullRegistryPopulator.java b/core/src/main/java/org/geysermc/geyser/registry/populator/CustomSkullRegistryPopulator.java index ec72433964c..735da3ae291 100644 --- a/core/src/main/java/org/geysermc/geyser/registry/populator/CustomSkullRegistryPopulator.java +++ b/core/src/main/java/org/geysermc/geyser/registry/populator/CustomSkullRegistryPopulator.java @@ -31,6 +31,7 @@ import org.checkerframework.checker.nullness.qual.Nullable; import org.geysermc.geyser.GeyserBootstrap; import org.geysermc.geyser.GeyserImpl; +import org.geysermc.geyser.GeyserLogger; import org.geysermc.geyser.api.event.lifecycle.GeyserDefineCustomSkullsEvent; import org.geysermc.geyser.configuration.GeyserCustomSkullConfiguration; import org.geysermc.geyser.pack.SkullResourcePackManager; @@ -66,7 +67,7 @@ public static void populate() { File skullConfigFile = FileUtils.fileOrCopiedFromResource(skullConfigPath.toFile(), "custom-skulls.yml", Function.identity(), bootstrap); skullConfig = FileUtils.loadConfig(skullConfigFile, GeyserCustomSkullConfiguration.class); } catch (IOException e) { - GeyserImpl.getInstance().getLogger().severe(GeyserLocale.getLocaleStringLog("geyser.config.failed"), e); + GeyserLogger.getInstance().severe(GeyserLocale.getLocaleStringLog("geyser.config.failed"), e); return; } @@ -118,7 +119,7 @@ public void register(@NonNull String texture, @NonNull SkullTextureType type) { skinHashes.forEach((skinHash) -> { if (!skinHash.matches("^[a-fA-F0-9]+$")) { - GeyserImpl.getInstance().getLogger().error("Skin hash " + skinHash + " does not match required format ^[a-fA-F0-9]{64}$ and will not be added as a custom block."); + GeyserLogger.getInstance().error("Skin hash " + skinHash + " does not match required format ^[a-fA-F0-9]{64}$ and will not be added as a custom block."); return; } @@ -126,12 +127,12 @@ public void register(@NonNull String texture, @NonNull SkullTextureType type) { SkullResourcePackManager.cacheSkullSkin(skinHash); BlockRegistries.CUSTOM_SKULLS.register(skinHash, new CustomSkull(skinHash)); } catch (IOException e) { - GeyserImpl.getInstance().getLogger().error("Failed to cache skin for skull texture " + skinHash + " This skull will not be added as a custom block.", e); + GeyserLogger.getInstance().error("Failed to cache skin for skull texture " + skinHash + " This skull will not be added as a custom block.", e); } }); if (!BlockRegistries.CUSTOM_SKULLS.get().isEmpty()) { - GeyserImpl.getInstance().getLogger().info("Registered " + BlockRegistries.CUSTOM_SKULLS.get().size() + " custom skulls as custom blocks."); + GeyserLogger.getInstance().info("Registered " + BlockRegistries.CUSTOM_SKULLS.get().size() + " custom skulls as custom blocks."); } } @@ -144,13 +145,13 @@ public void register(@NonNull String texture, @NonNull SkullTextureType type) { try { SkinManager.GameProfileData profileData = SkinManager.GameProfileData.loadFromJson(profile); if (profileData == null) { - GeyserImpl.getInstance().getLogger().warning("Skull texture " + profile + " contained no skins and will not be added as a custom block."); + GeyserLogger.getInstance().warning("Skull texture " + profile + " contained no skins and will not be added as a custom block."); return null; } String skinUrl = profileData.skinUrl(); return skinUrl.substring(skinUrl.lastIndexOf("/") + 1); } catch (IOException e) { - GeyserImpl.getInstance().getLogger().error("Skull texture " + profile + " is invalid and will not be added as a custom block.", e); + GeyserLogger.getInstance().error("Skull texture " + profile + " is invalid and will not be added as a custom block.", e); return null; } } @@ -164,7 +165,7 @@ public void register(@NonNull String texture, @NonNull SkullTextureType type) { try { return SkinProvider.requestTexturesFromUsername(username).get(); } catch (InterruptedException | ExecutionException e) { - GeyserImpl.getInstance().getLogger().error("Unable to request skull textures for " + username + " This skull will not be added as a custom block.", e); + GeyserLogger.getInstance().error("Unable to request skull textures for " + username + " This skull will not be added as a custom block.", e); return null; } } @@ -178,12 +179,12 @@ public void register(@NonNull String texture, @NonNull SkullTextureType type) { try { String uuidDigits = uuid.replace("-", ""); if (uuidDigits.length() != 32) { - GeyserImpl.getInstance().getLogger().error("Invalid skull uuid " + uuid + " This skull will not be added as a custom block."); + GeyserLogger.getInstance().error("Invalid skull uuid " + uuid + " This skull will not be added as a custom block."); return null; } return SkinProvider.requestTexturesFromUUID(uuid).get(); } catch (InterruptedException | ExecutionException e) { - GeyserImpl.getInstance().getLogger().error("Unable to request skull textures for " + uuid + " This skull will not be added as a custom block.", e); + GeyserLogger.getInstance().error("Unable to request skull textures for " + uuid + " This skull will not be added as a custom block.", e); return null; } } diff --git a/core/src/main/java/org/geysermc/geyser/registry/populator/ItemRegistryPopulator.java b/core/src/main/java/org/geysermc/geyser/registry/populator/ItemRegistryPopulator.java index f11b58bfe8a..d2c496c7873 100644 --- a/core/src/main/java/org/geysermc/geyser/registry/populator/ItemRegistryPopulator.java +++ b/core/src/main/java/org/geysermc/geyser/registry/populator/ItemRegistryPopulator.java @@ -33,7 +33,13 @@ import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap; import it.unimi.dsi.fastutil.ints.IntOpenHashSet; import it.unimi.dsi.fastutil.ints.IntSet; -import it.unimi.dsi.fastutil.objects.*; +import it.unimi.dsi.fastutil.objects.Object2IntMap; +import it.unimi.dsi.fastutil.objects.Object2IntOpenHashMap; +import it.unimi.dsi.fastutil.objects.Object2ObjectLinkedOpenHashMap; +import it.unimi.dsi.fastutil.objects.Object2ObjectMap; +import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap; +import it.unimi.dsi.fastutil.objects.ObjectArrayList; +import it.unimi.dsi.fastutil.objects.ObjectOpenHashSet; import org.checkerframework.checker.nullness.qual.NonNull; import org.cloudburstmc.nbt.NbtMap; import org.cloudburstmc.nbt.NbtMapBuilder; @@ -50,6 +56,7 @@ import org.geysermc.geyser.Constants; import org.geysermc.geyser.GeyserBootstrap; import org.geysermc.geyser.GeyserImpl; +import org.geysermc.geyser.GeyserLogger; import org.geysermc.geyser.api.block.custom.CustomBlockData; import org.geysermc.geyser.api.block.custom.CustomBlockState; import org.geysermc.geyser.api.block.custom.NonVanillaCustomBlockData; @@ -64,10 +71,22 @@ import org.geysermc.geyser.item.type.Item; import org.geysermc.geyser.registry.BlockRegistries; import org.geysermc.geyser.registry.Registries; -import org.geysermc.geyser.registry.type.*; +import org.geysermc.geyser.registry.type.BlockMappings; +import org.geysermc.geyser.registry.type.GeyserBedrockBlock; +import org.geysermc.geyser.registry.type.GeyserMappingItem; +import org.geysermc.geyser.registry.type.ItemMapping; +import org.geysermc.geyser.registry.type.ItemMappings; +import org.geysermc.geyser.registry.type.NonVanillaItemRegistration; +import org.geysermc.geyser.registry.type.PaletteItem; import java.io.InputStream; -import java.util.*; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Collections; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.Set; import java.util.concurrent.atomic.AtomicInteger; /** @@ -416,7 +435,7 @@ public static void populate() { // These items don't exist on Bedrock, so set up a variable that indicates they should have custom names // Or, ensure that we are translating these at all times to account for rarity colouring mappingBuilder = mappingBuilder.translationString((javaItem instanceof BlockItem ? "block." : "item.") + entry.getKey().replace(":", ".")); - GeyserImpl.getInstance().getLogger().debug("Adding " + entry.getKey() + " as an item that needs to be translated."); + GeyserLogger.getInstance().debug("Adding " + entry.getKey() + " as an item that needs to be translated."); } // Add the custom item properties, if applicable @@ -431,7 +450,7 @@ public static void populate() { String customItemName = customItem instanceof NonVanillaCustomItemData nonVanillaItem ? nonVanillaItem.identifier() : Constants.GEYSER_CUSTOM_NAMESPACE + ":" + customItem.name(); if (!registeredItemNames.add(customItemName)) { if (firstMappingsPass) { - GeyserImpl.getInstance().getLogger().error("Custom item name '" + customItemName + "' already exists and was registered again! Skipping..."); + GeyserLogger.getInstance().error("Custom item name '" + customItemName + "' already exists and was registered again! Skipping..."); } continue; } @@ -517,7 +536,7 @@ public static void populate() { for (NonVanillaCustomItemData customItem : nonVanillaCustomItems) { if (!registeredJavaIds.add(customItem.javaId())) { if (firstMappingsPass) { - GeyserImpl.getInstance().getLogger().error("Custom item java id " + customItem.javaId() + " already exists and was registered again! Skipping..."); + GeyserLogger.getInstance().error("Custom item java id " + customItem.javaId() + " already exists and was registered again! Skipping..."); } continue; } @@ -550,7 +569,7 @@ public static void populate() { ItemDefinition definition = definitions.get(id); if (definition == null) { // Newer item most likely - GeyserImpl.getInstance().getLogger().debug( + GeyserLogger.getInstance().debug( "Skipping vanilla component " + id + " for protocol " + palette.protocolVersion() ); continue; diff --git a/core/src/main/java/org/geysermc/geyser/registry/populator/PacketRegistryPopulator.java b/core/src/main/java/org/geysermc/geyser/registry/populator/PacketRegistryPopulator.java index 9be00732ceb..695b57fa408 100644 --- a/core/src/main/java/org/geysermc/geyser/registry/populator/PacketRegistryPopulator.java +++ b/core/src/main/java/org/geysermc/geyser/registry/populator/PacketRegistryPopulator.java @@ -26,7 +26,7 @@ package org.geysermc.geyser.registry.populator; import org.cloudburstmc.protocol.bedrock.packet.BedrockPacket; -import org.geysermc.geyser.GeyserImpl; +import org.geysermc.geyser.GeyserLogger; import org.geysermc.geyser.registry.Registries; import org.geysermc.geyser.translator.protocol.PacketTranslator; import org.geysermc.geyser.translator.protocol.Translator; @@ -40,7 +40,7 @@ public static void populate() { for (Class clazz : FileUtils.getGeneratedClassesForAnnotation(Translator.class)) { Class packet = clazz.getAnnotation(Translator.class).packet(); - GeyserImpl.getInstance().getLogger().debug("Found annotated translator: " + clazz.getCanonicalName() + " : " + packet.getSimpleName()); + GeyserLogger.getInstance().debug("Found annotated translator: " + clazz.getCanonicalName() + " : " + packet.getSimpleName()); try { if (Packet.class.isAssignableFrom(packet)) { @@ -54,10 +54,10 @@ public static void populate() { Registries.BEDROCK_PACKET_TRANSLATORS.register(targetPacket, translator); } else { - GeyserImpl.getInstance().getLogger().error("Class " + clazz.getCanonicalName() + " is annotated as a translator but has an invalid target packet."); + GeyserLogger.getInstance().error("Class " + clazz.getCanonicalName() + " is annotated as a translator but has an invalid target packet."); } } catch (Exception e) { - GeyserImpl.getInstance().getLogger().error("Could not instantiate annotated translator " + clazz.getCanonicalName()); + GeyserLogger.getInstance().error("Could not instantiate annotated translator " + clazz.getCanonicalName()); } } } diff --git a/core/src/main/java/org/geysermc/geyser/registry/type/ItemMappings.java b/core/src/main/java/org/geysermc/geyser/registry/type/ItemMappings.java index 189474238e1..fb068e3d86f 100644 --- a/core/src/main/java/org/geysermc/geyser/registry/type/ItemMappings.java +++ b/core/src/main/java/org/geysermc/geyser/registry/type/ItemMappings.java @@ -35,7 +35,7 @@ import org.cloudburstmc.protocol.bedrock.data.inventory.ComponentItemData; import org.cloudburstmc.protocol.bedrock.data.inventory.ItemData; import org.cloudburstmc.protocol.common.DefinitionRegistry; -import org.geysermc.geyser.GeyserImpl; +import org.geysermc.geyser.GeyserLogger; import org.geysermc.geyser.api.block.custom.CustomBlockData; import org.geysermc.geyser.inventory.item.StoredItemMappings; import org.geysermc.geyser.item.Items; @@ -159,7 +159,7 @@ public ItemMapping getMapping(ItemData data) { } } - GeyserImpl.getInstance().getLogger().debug("Missing mapping for bedrock item " + data); + GeyserLogger.getInstance().debug("Missing mapping for bedrock item " + data); return ItemMapping.AIR; } diff --git a/core/src/main/java/org/geysermc/geyser/scoreboard/Scoreboard.java b/core/src/main/java/org/geysermc/geyser/scoreboard/Scoreboard.java index acce86f4d95..0888a74d6cd 100644 --- a/core/src/main/java/org/geysermc/geyser/scoreboard/Scoreboard.java +++ b/core/src/main/java/org/geysermc/geyser/scoreboard/Scoreboard.java @@ -76,7 +76,7 @@ public final class Scoreboard { public Scoreboard(GeyserSession session) { this.session = session; - this.logger = GeyserImpl.getInstance().getLogger(); + this.logger = GeyserLogger.getInstance(); } public void removeScoreboard() { diff --git a/core/src/main/java/org/geysermc/geyser/session/GeyserSession.java b/core/src/main/java/org/geysermc/geyser/session/GeyserSession.java index 607a58e0b88..1d46c86fc40 100644 --- a/core/src/main/java/org/geysermc/geyser/session/GeyserSession.java +++ b/core/src/main/java/org/geysermc/geyser/session/GeyserSession.java @@ -107,6 +107,7 @@ import org.geysermc.floodgate.util.BedrockData; import org.geysermc.geyser.Constants; import org.geysermc.geyser.GeyserImpl; +import org.geysermc.geyser.GeyserLogger; import org.geysermc.geyser.api.bedrock.camera.CameraData; import org.geysermc.geyser.api.bedrock.camera.CameraShake; import org.geysermc.geyser.api.connection.GeyserConnection; @@ -1108,9 +1109,9 @@ public void disconnected(DisconnectedEvent event) { } if (cause != null) { if (cause.getMessage() != null) { - GeyserImpl.getInstance().getLogger().error(cause.getMessage()); + GeyserLogger.getInstance().error(cause.getMessage()); } else { - GeyserImpl.getInstance().getLogger().error("An exception occurred: ", cause); + GeyserLogger.getInstance().error("An exception occurred: ", cause); } if (geyser.getConfig().isDebugMode()) { cause.printStackTrace(); diff --git a/core/src/main/java/org/geysermc/geyser/session/PendingMicrosoftAuthentication.java b/core/src/main/java/org/geysermc/geyser/session/PendingMicrosoftAuthentication.java index 7d0e2fbf9a3..fa7aee3e04a 100644 --- a/core/src/main/java/org/geysermc/geyser/session/PendingMicrosoftAuthentication.java +++ b/core/src/main/java/org/geysermc/geyser/session/PendingMicrosoftAuthentication.java @@ -117,7 +117,7 @@ public void resetRunningFlow() { } public void cleanup() { - GeyserLogger logger = GeyserImpl.getInstance().getLogger(); + GeyserLogger logger = GeyserLogger.getInstance(); if (logger.isDebug()) { logger.debug("Cleaning up authentication task for " + userKey); } diff --git a/core/src/main/java/org/geysermc/geyser/session/cache/FormCache.java b/core/src/main/java/org/geysermc/geyser/session/cache/FormCache.java index 3f7df97c1b2..e0475b3a26f 100644 --- a/core/src/main/java/org/geysermc/geyser/session/cache/FormCache.java +++ b/core/src/main/java/org/geysermc/geyser/session/cache/FormCache.java @@ -25,16 +25,16 @@ package org.geysermc.geyser.session.cache; -import org.cloudburstmc.protocol.bedrock.packet.ModalFormRequestPacket; -import org.cloudburstmc.protocol.bedrock.packet.ModalFormResponsePacket; -import org.cloudburstmc.protocol.bedrock.packet.NetworkStackLatencyPacket; import it.unimi.dsi.fastutil.ints.Int2ObjectMap; import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap; import lombok.RequiredArgsConstructor; +import org.cloudburstmc.protocol.bedrock.packet.ModalFormRequestPacket; +import org.cloudburstmc.protocol.bedrock.packet.ModalFormResponsePacket; +import org.cloudburstmc.protocol.bedrock.packet.NetworkStackLatencyPacket; import org.geysermc.cumulus.form.Form; import org.geysermc.cumulus.form.SimpleForm; import org.geysermc.cumulus.form.impl.FormDefinitions; -import org.geysermc.geyser.GeyserImpl; +import org.geysermc.geyser.GeyserLogger; import org.geysermc.geyser.session.GeyserSession; import java.util.concurrent.TimeUnit; @@ -104,7 +104,7 @@ public void handleResponse(ModalFormResponsePacket response) { formDefinitions.definitionFor(form) .handleFormResponse(form, response.getFormData()); } catch (Exception e) { - GeyserImpl.getInstance().getLogger().error("Error while processing form response!", e); + GeyserLogger.getInstance().error("Error while processing form response!", e); } } } diff --git a/core/src/main/java/org/geysermc/geyser/session/cache/RegistryCache.java b/core/src/main/java/org/geysermc/geyser/session/cache/RegistryCache.java index a393d461d7a..e298c0472ca 100644 --- a/core/src/main/java/org/geysermc/geyser/session/cache/RegistryCache.java +++ b/core/src/main/java/org/geysermc/geyser/session/cache/RegistryCache.java @@ -37,7 +37,7 @@ import org.cloudburstmc.nbt.NbtType; import org.cloudburstmc.protocol.bedrock.data.TrimMaterial; import org.cloudburstmc.protocol.bedrock.data.TrimPattern; -import org.geysermc.geyser.GeyserImpl; +import org.geysermc.geyser.GeyserLogger; import org.geysermc.geyser.entity.type.living.animal.tameable.WolfEntity; import org.geysermc.geyser.inventory.item.BannerPattern; import org.geysermc.geyser.inventory.recipe.TrimRecipe; @@ -141,7 +141,7 @@ public void load(ClientboundRegistryDataPacket packet) { if (reader != null) { reader.accept(this, packet.getEntries()); } else { - GeyserImpl.getInstance().getLogger().debug("Ignoring registry of type " + packet.getRegistry()); + GeyserLogger.getInstance().debug("Ignoring registry of type " + packet.getRegistry()); } } diff --git a/core/src/main/java/org/geysermc/geyser/session/cache/TagCache.java b/core/src/main/java/org/geysermc/geyser/session/cache/TagCache.java index f4d69dcdb76..eefe5ecdafe 100644 --- a/core/src/main/java/org/geysermc/geyser/session/cache/TagCache.java +++ b/core/src/main/java/org/geysermc/geyser/session/cache/TagCache.java @@ -89,7 +89,7 @@ public void loadPacket(GeyserSession session, ClientboundUpdateTagsPacket packet private void loadTags(String type, @Nullable Map packetTags, Map allTags, int[][] localValues) { if (packetTags == null) { Arrays.fill(localValues, IntArrays.EMPTY_ARRAY); - GeyserImpl.getInstance().getLogger().debug("Not loading " + type + " tags; they do not exist here."); + GeyserLogger.getInstance().debug("Not loading " + type + " tags; they do not exist here."); return; } allTags.forEach((location, tag) -> { @@ -102,7 +102,7 @@ private void loadTags(String type, @Nullable Map } } else { localValues[tag.ordinal()] = IntArrays.EMPTY_ARRAY; - GeyserImpl.getInstance().getLogger().debug(type + " tag not found from server: " + location); + GeyserLogger.getInstance().debug(type + " tag not found from server: " + location); } }); } diff --git a/core/src/main/java/org/geysermc/geyser/skin/FakeHeadProvider.java b/core/src/main/java/org/geysermc/geyser/skin/FakeHeadProvider.java index 22786a4eeb6..1e0537aba78 100644 --- a/core/src/main/java/org/geysermc/geyser/skin/FakeHeadProvider.java +++ b/core/src/main/java/org/geysermc/geyser/skin/FakeHeadProvider.java @@ -25,10 +25,6 @@ package org.geysermc.geyser.skin; -import org.geysermc.mcprotocollib.auth.GameProfile; -import org.geysermc.mcprotocollib.auth.GameProfile.Texture; -import org.geysermc.mcprotocollib.auth.GameProfile.TextureModel; -import org.geysermc.mcprotocollib.auth.GameProfile.TextureType; import com.google.common.cache.CacheBuilder; import com.google.common.cache.CacheLoader; import com.google.common.cache.LoadingCache; @@ -36,7 +32,7 @@ import lombok.Getter; import lombok.Setter; import org.checkerframework.checker.nullness.qual.NonNull; -import org.geysermc.geyser.GeyserImpl; +import org.geysermc.geyser.GeyserLogger; import org.geysermc.geyser.api.skin.Cape; import org.geysermc.geyser.api.skin.Skin; import org.geysermc.geyser.api.skin.SkinData; @@ -46,6 +42,10 @@ import org.geysermc.geyser.session.GeyserSession; import org.geysermc.geyser.skin.SkinManager.GameProfileData; import org.geysermc.geyser.text.GeyserLocale; +import org.geysermc.mcprotocollib.auth.GameProfile; +import org.geysermc.mcprotocollib.auth.GameProfile.Texture; +import org.geysermc.mcprotocollib.auth.GameProfile.TextureModel; +import org.geysermc.mcprotocollib.auth.GameProfile.TextureType; import org.geysermc.mcprotocollib.protocol.data.game.item.component.DataComponentType; import org.geysermc.mcprotocollib.protocol.data.game.item.component.DataComponents; @@ -116,7 +116,7 @@ public static void setHead(GeyserSession session, PlayerEntity entity, DataCompo try { textures = profile.getTextures(false); } catch (IllegalStateException e) { - GeyserImpl.getInstance().getLogger().debug("Could not decode player head from profile %s, got: %s".formatted(profile, e.getMessage())); + GeyserLogger.getInstance().debug("Could not decode player head from profile %s, got: %s".formatted(profile, e.getMessage())); textures = null; } @@ -147,7 +147,7 @@ public static void loadHead(GeyserSession session, PlayerEntity entity, String o CompletableFuture completableFuture = SkinProvider.requestTexturesFromUsername(owner); completableFuture.whenCompleteAsync((encodedJson, throwable) -> { if (throwable != null) { - GeyserImpl.getInstance().getLogger().error(GeyserLocale.getLocaleStringLog("geyser.skin.fail", entity.getUuid()), throwable); + GeyserLogger.getInstance().error(GeyserLocale.getLocaleStringLog("geyser.skin.fail", entity.getUuid()), throwable); return; } try { @@ -157,7 +157,7 @@ public static void loadHead(GeyserSession session, PlayerEntity entity, String o } loadHead(session, entity, gameProfileData); } catch (IOException e) { - GeyserImpl.getInstance().getLogger().error(GeyserLocale.getLocaleStringLog("geyser.skin.fail", entity.getUuid(), e.getMessage())); + GeyserLogger.getInstance().error(GeyserLocale.getLocaleStringLog("geyser.skin.fail", entity.getUuid(), e.getMessage())); } }); } @@ -172,7 +172,7 @@ public static void loadHead(GeyserSession session, PlayerEntity entity, SkinMana SkinData mergedSkinData = MERGED_SKINS_LOADING_CACHE.get(new FakeHeadEntry(texturesProperty, fakeHeadSkinUrl, entity, session)); SkinManager.sendSkinPacket(session, entity, mergedSkinData); } catch (ExecutionException e) { - GeyserImpl.getInstance().getLogger().error("Couldn't merge skin of " + entity.getUsername() + " with head skin url " + fakeHeadSkinUrl, e); + GeyserLogger.getInstance().error("Couldn't merge skin of " + entity.getUsername() + " with head skin url " + fakeHeadSkinUrl, e); } }); } @@ -188,7 +188,7 @@ public static void restoreOriginalSkin(GeyserSession session, LivingEntity livin SkinProvider.requestSkinData(entity, session).whenCompleteAsync((skinData, throwable) -> { if (throwable != null) { - GeyserImpl.getInstance().getLogger().error(GeyserLocale.getLocaleStringLog("geyser.skin.fail", entity.getUuid()), throwable); + GeyserLogger.getInstance().error(GeyserLocale.getLocaleStringLog("geyser.skin.fail", entity.getUuid()), throwable); return; } diff --git a/core/src/main/java/org/geysermc/geyser/skin/SkinManager.java b/core/src/main/java/org/geysermc/geyser/skin/SkinManager.java index 4c3db7504c9..6bfb6e701c2 100644 --- a/core/src/main/java/org/geysermc/geyser/skin/SkinManager.java +++ b/core/src/main/java/org/geysermc/geyser/skin/SkinManager.java @@ -34,6 +34,7 @@ import org.cloudburstmc.protocol.bedrock.packet.PlayerListPacket; import org.cloudburstmc.protocol.bedrock.packet.PlayerSkinPacket; import org.geysermc.geyser.GeyserImpl; +import org.geysermc.geyser.GeyserLogger; import org.geysermc.geyser.api.skin.Cape; import org.geysermc.geyser.api.skin.Skin; import org.geysermc.geyser.api.skin.SkinData; @@ -245,7 +246,7 @@ public record GameProfileData(String skinUrl, String capeUrl, boolean isAlex) { try { return loadFromJson(skinDataValue); } catch (IOException e) { - GeyserImpl.getInstance().getLogger().debug("Something went wrong while processing skin for tag " + tag); + GeyserLogger.getInstance().debug("Something went wrong while processing skin for tag " + tag); if (GeyserImpl.getInstance().getConfig().isDebugMode()) { e.printStackTrace(); } @@ -270,9 +271,9 @@ public record GameProfileData(String skinUrl, String capeUrl, boolean isAlex) { return loadFromJson(texturesProperty); } catch (Exception exception) { if (entity instanceof SkullPlayerEntity skullEntity) { - GeyserImpl.getInstance().getLogger().debug("Something went wrong while processing skin for skull at " + skullEntity.getSkullPosition() + " with Value: " + texturesProperty); + GeyserLogger.getInstance().debug("Something went wrong while processing skin for skull at " + skullEntity.getSkullPosition() + " with Value: " + texturesProperty); } else { - GeyserImpl.getInstance().getLogger().debug("Something went wrong while processing skin for " + entity.getUsername() + " with Value: " + texturesProperty); + GeyserLogger.getInstance().debug("Something went wrong while processing skin for " + entity.getUsername() + " with Value: " + texturesProperty); } if (GeyserImpl.getInstance().getConfig().isDebugMode()) { exception.printStackTrace(); @@ -286,7 +287,7 @@ public record GameProfileData(String skinUrl, String capeUrl, boolean isAlex) { try { skinObject = GeyserImpl.JSON_MAPPER.readTree(new String(Base64.getDecoder().decode(encodedJson), StandardCharsets.UTF_8)); } catch (IllegalArgumentException e) { - GeyserImpl.getInstance().getLogger().debug("Invalid base64 encoded skin entry: " + encodedJson); + GeyserLogger.getInstance().debug("Invalid base64 encoded skin entry: " + encodedJson); return null; } @@ -334,4 +335,4 @@ public record GameProfileData(String skinUrl, String capeUrl, boolean isAlex) { private static final String DEFAULT_FLOODGATE_STEVE = "https://textures.minecraft.net/texture/31f477eb1a7beee631c2ca64d06f8f68fa93a3386d04452ab27f43acdf1b60cb"; } -} \ No newline at end of file +} diff --git a/core/src/main/java/org/geysermc/geyser/skin/SkinProvider.java b/core/src/main/java/org/geysermc/geyser/skin/SkinProvider.java index aec1fa4de4c..041fe1d53e0 100644 --- a/core/src/main/java/org/geysermc/geyser/skin/SkinProvider.java +++ b/core/src/main/java/org/geysermc/geyser/skin/SkinProvider.java @@ -32,6 +32,7 @@ import org.checkerframework.checker.nullness.qual.NonNull; import org.checkerframework.checker.nullness.qual.Nullable; import org.geysermc.geyser.GeyserImpl; +import org.geysermc.geyser.GeyserLogger; import org.geysermc.geyser.api.event.bedrock.SessionSkinApplyEvent; import org.geysermc.geyser.api.network.AuthType; import org.geysermc.geyser.api.skin.Cape; @@ -56,7 +57,11 @@ import java.util.Map; import java.util.Objects; import java.util.UUID; -import java.util.concurrent.*; +import java.util.concurrent.CompletableFuture; +import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; +import java.util.concurrent.TimeUnit; import java.util.function.Predicate; public class SkinProvider { @@ -165,7 +170,7 @@ public static void registerCacheImageTask(GeyserImpl geyser) { } if (count > 0) { - GeyserImpl.getInstance().getLogger().debug(String.format("Removed %d cached image files as they have expired", count)); + GeyserLogger.getInstance().debug(String.format("Removed %d cached image files as they have expired", count)); } }, 10, 1440, TimeUnit.MINUTES); } @@ -286,7 +291,7 @@ public void geometry(@NonNull SkinGeometry newGeometry) { return eventSkinData.skinData(); } catch (Exception e) { - GeyserImpl.getInstance().getLogger().error(GeyserLocale.getLocaleStringLog("geyser.skin.fail", entity.getUuid()), e); + GeyserLogger.getInstance().error(GeyserLocale.getLocaleStringLog("geyser.skin.fail", entity.getUuid()), e); } return new SkinData(skinAndCape.skin(), skinAndCape.cape(), null); @@ -302,7 +307,7 @@ private static CompletableFuture requestSkinAndCape(UUID playerId, getOrDefault(requestCape(capeUrl, false), EMPTY_CAPE, 5) ); - GeyserImpl.getInstance().getLogger().debug("Took " + (System.currentTimeMillis() - time) + "ms for " + playerId); + GeyserLogger.getInstance().debug("Took " + (System.currentTimeMillis() - time) + "ms for " + playerId); return skinAndCape; }, getExecutorService()); } @@ -413,7 +418,7 @@ public static BufferedImage requestImage(String imageUrl, boolean isCape) throws File imageFile = GeyserImpl.getInstance().getBootstrap().getConfigFolder().resolve("cache").resolve("images").resolve(UUID.nameUUIDFromBytes(imageUrl.getBytes()) + ".png").toFile(); if (imageFile.exists()) { try { - GeyserImpl.getInstance().getLogger().debug("Reading cached image from file " + imageFile.getPath() + " for " + imageUrl); + GeyserLogger.getInstance().debug("Reading cached image from file " + imageFile.getPath() + " for " + imageUrl); imageFile.setLastModified(System.currentTimeMillis()); image = ImageIO.read(imageFile); } catch (IOException ignored) {} @@ -422,16 +427,16 @@ public static BufferedImage requestImage(String imageUrl, boolean isCape) throws // If no image we download it if (image == null) { image = downloadImage(imageUrl); - GeyserImpl.getInstance().getLogger().debug("Downloaded " + imageUrl); + GeyserLogger.getInstance().debug("Downloaded " + imageUrl); // Write to cache if we are allowed if (GeyserImpl.getInstance().getConfig().getCacheImages() > 0) { imageFile.getParentFile().mkdirs(); try { ImageIO.write(image, "png", imageFile); - GeyserImpl.getInstance().getLogger().debug("Writing cached skin to file " + imageFile.getPath() + " for " + imageUrl); + GeyserLogger.getInstance().debug("Writing cached skin to file " + imageFile.getPath() + " for " + imageUrl); } catch (IOException e) { - GeyserImpl.getInstance().getLogger().error("Failed to write cached skin to file " + imageFile.getPath() + " for " + imageUrl); + GeyserLogger.getInstance().error("Failed to write cached skin to file " + imageFile.getPath() + " for " + imageUrl); } } } @@ -488,12 +493,12 @@ private static byte[] requestImageData(String imageUrl, boolean isCape) throws E JsonNode node = WebUtils.getJson("https://sessionserver.mojang.com/session/minecraft/profile/" + uuid); JsonNode properties = node.get("properties"); if (properties == null) { - GeyserImpl.getInstance().getLogger().debug("No properties found in Mojang response for " + uuid); + GeyserLogger.getInstance().debug("No properties found in Mojang response for " + uuid); return null; } return node.get("properties").get(0).get("value").asText(); } catch (Exception e) { - GeyserImpl.getInstance().getLogger().debug("Unable to request textures for " + uuid); + GeyserLogger.getInstance().debug("Unable to request textures for " + uuid); if (GeyserImpl.getInstance().getConfig().isDebugMode()) { e.printStackTrace(); } @@ -515,7 +520,7 @@ private static byte[] requestImageData(String imageUrl, boolean isCape) throws E JsonNode node = WebUtils.getJson("https://api.mojang.com/users/profiles/minecraft/" + username); JsonNode id = node.get("id"); if (id == null) { - GeyserImpl.getInstance().getLogger().debug("No UUID found in Mojang response for " + username); + GeyserLogger.getInstance().debug("No UUID found in Mojang response for " + username); return null; } return id.asText(); diff --git a/core/src/main/java/org/geysermc/geyser/skin/SkullSkinManager.java b/core/src/main/java/org/geysermc/geyser/skin/SkullSkinManager.java index e3f00d3b76a..3c4e136f834 100644 --- a/core/src/main/java/org/geysermc/geyser/skin/SkullSkinManager.java +++ b/core/src/main/java/org/geysermc/geyser/skin/SkullSkinManager.java @@ -28,7 +28,7 @@ import org.cloudburstmc.protocol.bedrock.data.skin.ImageData; import org.cloudburstmc.protocol.bedrock.data.skin.SerializedSkin; import org.cloudburstmc.protocol.bedrock.packet.PlayerSkinPacket; -import org.geysermc.geyser.GeyserImpl; +import org.geysermc.geyser.GeyserLogger; import org.geysermc.geyser.api.skin.Skin; import org.geysermc.geyser.api.skin.SkinData; import org.geysermc.geyser.entity.type.player.SkullPlayerEntity; @@ -63,7 +63,7 @@ public static void requestAndHandleSkin(SkullPlayerEntity entity, GeyserSession packet.setTrustedSkin(true); session.sendUpstreamPacket(packet); } catch (Exception e) { - GeyserImpl.getInstance().getLogger().error(GeyserLocale.getLocaleStringLog("geyser.skin.fail", entity.getUuid()), e); + GeyserLogger.getInstance().error(GeyserLocale.getLocaleStringLog("geyser.skin.fail", entity.getUuid()), e); } if (skinConsumer != null) { @@ -73,7 +73,7 @@ public static void requestAndHandleSkin(SkullPlayerEntity entity, GeyserSession GameProfileData data = GameProfileData.from(entity); if (data == null) { - GeyserImpl.getInstance().getLogger().debug("Using fallback skin for skull at " + entity.getSkullPosition() + + GeyserLogger.getInstance().debug("Using fallback skin for skull at " + entity.getSkullPosition() + " with texture value: " + entity.getTexturesProperty() + " and UUID: " + entity.getSkullUUID()); // No texture available, fallback using the UUID SkinData fallback = SkinProvider.determineFallbackSkinData(entity.getSkullUUID()); diff --git a/core/src/main/java/org/geysermc/geyser/text/MinecraftLocale.java b/core/src/main/java/org/geysermc/geyser/text/MinecraftLocale.java index 94d8b254fc7..50a1e771df8 100644 --- a/core/src/main/java/org/geysermc/geyser/text/MinecraftLocale.java +++ b/core/src/main/java/org/geysermc/geyser/text/MinecraftLocale.java @@ -28,6 +28,7 @@ import com.fasterxml.jackson.databind.JsonNode; import org.checkerframework.checker.nullness.qual.Nullable; import org.geysermc.geyser.GeyserImpl; +import org.geysermc.geyser.GeyserLogger; import org.geysermc.geyser.util.AssetUtils; import org.geysermc.geyser.util.FileUtils; import org.geysermc.geyser.util.WebUtils; @@ -79,7 +80,7 @@ public static void downloadAndLoadLocale(String locale) { locale = locale.toLowerCase(Locale.ROOT); if (isLocaleLoaded(locale)) { - GeyserImpl.getInstance().getLogger().debug("Locale already loaded: " + locale); + GeyserLogger.getInstance().debug("Locale already loaded: " + locale); return; } @@ -91,18 +92,18 @@ public static void downloadAndLoadLocale(String locale) { // Check the locale isn't already loaded if (!AssetUtils.isAssetKnown("minecraft/lang/" + locale + ".json") && !locale.equals("en_us")) { if (loadLocale(locale)) { - GeyserImpl.getInstance().getLogger().debug("Loaded locale locally while not being in asset map: " + locale); + GeyserLogger.getInstance().debug("Loaded locale locally while not being in asset map: " + locale); } else { - GeyserImpl.getInstance().getLogger().warning(GeyserLocale.getLocaleStringLog("geyser.locale.fail.invalid", locale)); + GeyserLogger.getInstance().warning(GeyserLocale.getLocaleStringLog("geyser.locale.fail.invalid", locale)); } return; } - GeyserImpl.getInstance().getLogger().debug("Downloading and loading locale: " + locale); + GeyserLogger.getInstance().debug("Downloading and loading locale: " + locale); downloadLocale(locale); if (!loadLocale(locale)) { - GeyserImpl.getInstance().getLogger().warning(GeyserLocale.getLocaleStringLog("geyser.locale.fail.missing", locale)); + GeyserLogger.getInstance().warning(GeyserLocale.getLocaleStringLog("geyser.locale.fail.missing", locale)); } } @@ -123,9 +124,9 @@ private static void downloadLocale(String locale) { String targetHash = AssetUtils.getAsset("minecraft/lang/" + locale + ".json").getHash(); if (!curHash.equals(targetHash)) { - GeyserImpl.getInstance().getLogger().debug("Locale out of date; re-downloading: " + locale); + GeyserLogger.getInstance().debug("Locale out of date; re-downloading: " + locale); } else { - GeyserImpl.getInstance().getLogger().debug("Locale already downloaded and up-to date: " + locale); + GeyserLogger.getInstance().debug("Locale already downloaded and up-to date: " + locale); return; } } @@ -135,7 +136,7 @@ private static void downloadLocale(String locale) { String hash = AssetUtils.getAsset("minecraft/lang/" + locale + ".json").getHash(); WebUtils.downloadFile("https://resources.download.minecraft.net/" + hash.substring(0, 2) + "/" + hash, localeFile.toString()); } catch (Exception e) { - GeyserImpl.getInstance().getLogger().error("Unable to download locale file hash", e); + GeyserLogger.getInstance().error("Unable to download locale file hash", e); } } @@ -219,7 +220,7 @@ public static String getLocaleString(String messageText, String locale) { localeStrings = LOCALE_MAPPINGS.get(GeyserLocale.getDefaultLocale()); if (localeStrings == null) { // Don't cause a NPE if the locale is STILL missing - GeyserImpl.getInstance().getLogger().debug("MISSING DEFAULT LOCALE: " + GeyserLocale.getDefaultLocale()); + GeyserLogger.getInstance().debug("MISSING DEFAULT LOCALE: " + GeyserLocale.getDefaultLocale()); return messageText; } } @@ -266,4 +267,4 @@ private static String byteArrayToHexString(byte[] b) { } return result.toString(); } -} \ No newline at end of file +} diff --git a/core/src/main/java/org/geysermc/geyser/translator/item/ItemTranslator.java b/core/src/main/java/org/geysermc/geyser/translator/item/ItemTranslator.java index 163eef20b32..9ebee236633 100644 --- a/core/src/main/java/org/geysermc/geyser/translator/item/ItemTranslator.java +++ b/core/src/main/java/org/geysermc/geyser/translator/item/ItemTranslator.java @@ -35,7 +35,7 @@ import org.cloudburstmc.protocol.bedrock.data.definitions.BlockDefinition; import org.cloudburstmc.protocol.bedrock.data.definitions.ItemDefinition; import org.cloudburstmc.protocol.bedrock.data.inventory.ItemData; -import org.geysermc.geyser.GeyserImpl; +import org.geysermc.geyser.GeyserLogger; import org.geysermc.geyser.api.block.custom.CustomBlockData; import org.geysermc.geyser.inventory.GeyserItemStack; import org.geysermc.geyser.item.Items; @@ -498,7 +498,7 @@ private static void translateCustomBlock(CustomBlockData customBlockData, Geyser try { textures = profile.getTextures(false); } catch (IllegalStateException e) { - GeyserImpl.getInstance().getLogger().debug("Could not decode player head from profile %s, got: %s".formatted(profile, e.getMessage())); + GeyserLogger.getInstance().debug("Could not decode player head from profile %s, got: %s".formatted(profile, e.getMessage())); return null; } diff --git a/core/src/main/java/org/geysermc/geyser/translator/protocol/java/JavaCommandsTranslator.java b/core/src/main/java/org/geysermc/geyser/translator/protocol/java/JavaCommandsTranslator.java index f189658cd82..6a4ff0ab50b 100644 --- a/core/src/main/java/org/geysermc/geyser/translator/protocol/java/JavaCommandsTranslator.java +++ b/core/src/main/java/org/geysermc/geyser/translator/protocol/java/JavaCommandsTranslator.java @@ -37,9 +37,15 @@ import net.kyori.adventure.key.Key; import net.kyori.adventure.text.format.NamedTextColor; import org.checkerframework.checker.nullness.qual.MonotonicNonNull; -import org.cloudburstmc.protocol.bedrock.data.command.*; +import org.cloudburstmc.protocol.bedrock.data.command.CommandData; +import org.cloudburstmc.protocol.bedrock.data.command.CommandEnumConstraint; +import org.cloudburstmc.protocol.bedrock.data.command.CommandEnumData; +import org.cloudburstmc.protocol.bedrock.data.command.CommandOverloadData; +import org.cloudburstmc.protocol.bedrock.data.command.CommandParam; +import org.cloudburstmc.protocol.bedrock.data.command.CommandParamData; +import org.cloudburstmc.protocol.bedrock.data.command.CommandPermission; import org.cloudburstmc.protocol.bedrock.packet.AvailableCommandsPacket; -import org.geysermc.geyser.GeyserImpl; +import org.geysermc.geyser.GeyserLogger; import org.geysermc.geyser.api.event.java.ServerDefineCommandsEvent; import org.geysermc.geyser.command.CommandRegistry; import org.geysermc.geyser.item.enchantment.Enchantment; @@ -55,7 +61,16 @@ import org.geysermc.mcprotocollib.protocol.data.game.entity.attribute.AttributeType; import org.geysermc.mcprotocollib.protocol.packet.ingame.clientbound.ClientboundCommandsPacket; -import java.util.*; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.EnumSet; +import java.util.HashSet; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Locale; +import java.util.Map; +import java.util.Set; import java.util.function.Supplier; @SuppressWarnings("removal") // We know. This is our doing. @@ -235,7 +250,7 @@ private static CommandOverloadData[] getParams(GeyserSession session, CommandNod // Check if the command is an alias and redirect it if (commandNode.getRedirectIndex().isPresent()) { int redirectIndex = commandNode.getRedirectIndex().getAsInt(); - GeyserImpl.getInstance().getLogger().debug("Redirecting command " + commandNode.getName() + " to " + allNodes[redirectIndex].getName()); + GeyserLogger.getInstance().debug("Redirecting command " + commandNode.getName() + " to " + allNodes[redirectIndex].getName()); commandNode = allNodes[redirectIndex]; } diff --git a/core/src/main/java/org/geysermc/geyser/translator/protocol/java/JavaCustomPayloadTranslator.java b/core/src/main/java/org/geysermc/geyser/translator/protocol/java/JavaCustomPayloadTranslator.java index 811449a99b1..6c70f8aad15 100644 --- a/core/src/main/java/org/geysermc/geyser/translator/protocol/java/JavaCustomPayloadTranslator.java +++ b/core/src/main/java/org/geysermc/geyser/translator/protocol/java/JavaCustomPayloadTranslator.java @@ -38,7 +38,6 @@ import org.geysermc.erosion.packet.Packets; import org.geysermc.erosion.packet.geyserbound.GeyserboundPacket; import org.geysermc.floodgate.pluginmessage.PluginMessageChannels; -import org.geysermc.geyser.GeyserImpl; import org.geysermc.geyser.GeyserLogger; import org.geysermc.geyser.session.GeyserSession; import org.geysermc.geyser.translator.protocol.PacketTranslator; @@ -50,7 +49,7 @@ @Translator(packet = ClientboundCustomPayloadPacket.class) public class JavaCustomPayloadTranslator extends PacketTranslator { - private final GeyserLogger logger = GeyserImpl.getInstance().getLogger(); + private final GeyserLogger logger = GeyserLogger.getInstance(); @Override public void translate(GeyserSession session, ClientboundCustomPayloadPacket packet) { diff --git a/core/src/main/java/org/geysermc/geyser/translator/protocol/java/JavaUpdateRecipesTranslator.java b/core/src/main/java/org/geysermc/geyser/translator/protocol/java/JavaUpdateRecipesTranslator.java index 689e0448a02..bdf9219f6ab 100644 --- a/core/src/main/java/org/geysermc/geyser/translator/protocol/java/JavaUpdateRecipesTranslator.java +++ b/core/src/main/java/org/geysermc/geyser/translator/protocol/java/JavaUpdateRecipesTranslator.java @@ -44,6 +44,7 @@ import org.cloudburstmc.protocol.bedrock.packet.CraftingDataPacket; import org.cloudburstmc.protocol.bedrock.packet.TrimDataPacket; import org.geysermc.geyser.GeyserImpl; +import org.geysermc.geyser.GeyserLogger; import org.geysermc.geyser.inventory.recipe.GeyserRecipe; import org.geysermc.geyser.inventory.recipe.GeyserShapedRecipe; import org.geysermc.geyser.inventory.recipe.GeyserShapelessRecipe; @@ -153,7 +154,7 @@ public void translate(GeyserSession session, ClientboundUpdateRecipesPacket pack StoneCuttingRecipeData stoneCuttingData = (StoneCuttingRecipeData) recipe.getData(); if (stoneCuttingData.getIngredient().getOptions().length == 0) { if (GeyserImpl.getInstance().getConfig().isDebugMode()) { - GeyserImpl.getInstance().getLogger().debug("Received broken stone cutter recipe: " + stoneCuttingData + " " + + GeyserLogger.getInstance().debug("Received broken stone cutter recipe: " + stoneCuttingData + " " + recipe.getIdentifier() + " " + Registries.JAVA_ITEMS.get().get(stoneCuttingData.getResult().getId()).javaIdentifier()); } continue; @@ -420,7 +421,7 @@ private ItemDescriptorWithCount getDescriptorFromId(GeyserSession session, Strin if (bedrockDefinition != null) { return ItemDescriptorWithCount.fromItem(ItemData.builder().definition(bedrockDefinition).count(1).build()); } - GeyserImpl.getInstance().getLogger().debug("Unable to find item with identifier " + bedrockId); + GeyserLogger.getInstance().debug("Unable to find item with identifier " + bedrockId); return ItemDescriptorWithCount.EMPTY; } diff --git a/core/src/main/java/org/geysermc/geyser/translator/protocol/java/entity/player/JavaPlayerInfoUpdateTranslator.java b/core/src/main/java/org/geysermc/geyser/translator/protocol/java/entity/player/JavaPlayerInfoUpdateTranslator.java index 19f34db74b6..929028b0def 100644 --- a/core/src/main/java/org/geysermc/geyser/translator/protocol/java/entity/player/JavaPlayerInfoUpdateTranslator.java +++ b/core/src/main/java/org/geysermc/geyser/translator/protocol/java/entity/player/JavaPlayerInfoUpdateTranslator.java @@ -25,16 +25,16 @@ package org.geysermc.geyser.translator.protocol.java.entity.player; -import org.geysermc.mcprotocollib.auth.GameProfile; import org.checkerframework.checker.nullness.qual.Nullable; import org.cloudburstmc.math.vector.Vector3f; import org.cloudburstmc.protocol.bedrock.packet.PlayerListPacket; -import org.geysermc.geyser.GeyserImpl; +import org.geysermc.geyser.GeyserLogger; import org.geysermc.geyser.entity.type.player.PlayerEntity; import org.geysermc.geyser.session.GeyserSession; import org.geysermc.geyser.skin.SkinManager; import org.geysermc.geyser.translator.protocol.PacketTranslator; import org.geysermc.geyser.translator.protocol.Translator; +import org.geysermc.mcprotocollib.auth.GameProfile; import org.geysermc.mcprotocollib.protocol.data.game.PlayerListEntry; import org.geysermc.mcprotocollib.protocol.data.game.PlayerListEntryAction; import org.geysermc.mcprotocollib.protocol.packet.ingame.clientbound.ClientboundPlayerInfoUpdatePacket; @@ -94,7 +94,7 @@ public void translate(GeyserSession session, ClientboundPlayerInfoUpdatePacket p if (self) { SkinManager.requestAndHandleSkinAndCape(playerEntity, session, skinAndCape -> - GeyserImpl.getInstance().getLogger().debug("Loaded Local Bedrock Java Skin Data for " + session.getClientData().getUsername())); + GeyserLogger.getInstance().debug("Loaded Local Bedrock Java Skin Data for " + session.getClientData().getUsername())); } else { playerEntity.setValid(true); } diff --git a/core/src/main/java/org/geysermc/geyser/translator/protocol/java/entity/spawn/JavaAddEntityTranslator.java b/core/src/main/java/org/geysermc/geyser/translator/protocol/java/entity/spawn/JavaAddEntityTranslator.java index 572d233d03b..41bcde61177 100644 --- a/core/src/main/java/org/geysermc/geyser/translator/protocol/java/entity/spawn/JavaAddEntityTranslator.java +++ b/core/src/main/java/org/geysermc/geyser/translator/protocol/java/entity/spawn/JavaAddEntityTranslator.java @@ -25,17 +25,14 @@ package org.geysermc.geyser.translator.protocol.java.entity.spawn; -import org.geysermc.mcprotocollib.protocol.data.game.entity.metadata.Pose; -import org.geysermc.mcprotocollib.protocol.data.game.entity.object.Direction; -import org.geysermc.mcprotocollib.protocol.data.game.entity.object.FallingBlockData; -import org.geysermc.mcprotocollib.protocol.data.game.entity.object.ProjectileData; -import org.geysermc.mcprotocollib.protocol.data.game.entity.object.WardenData; -import org.geysermc.mcprotocollib.protocol.data.game.entity.type.EntityType; -import org.geysermc.mcprotocollib.protocol.packet.ingame.clientbound.entity.spawn.ClientboundAddEntityPacket; import org.cloudburstmc.math.vector.Vector3f; -import org.geysermc.geyser.GeyserImpl; +import org.geysermc.geyser.GeyserLogger; import org.geysermc.geyser.entity.EntityDefinition; -import org.geysermc.geyser.entity.type.*; +import org.geysermc.geyser.entity.type.Entity; +import org.geysermc.geyser.entity.type.FallingBlockEntity; +import org.geysermc.geyser.entity.type.FishingHookEntity; +import org.geysermc.geyser.entity.type.ItemFrameEntity; +import org.geysermc.geyser.entity.type.PaintingEntity; import org.geysermc.geyser.entity.type.player.PlayerEntity; import org.geysermc.geyser.registry.Registries; import org.geysermc.geyser.session.GeyserSession; @@ -43,6 +40,13 @@ import org.geysermc.geyser.text.GeyserLocale; import org.geysermc.geyser.translator.protocol.PacketTranslator; import org.geysermc.geyser.translator.protocol.Translator; +import org.geysermc.mcprotocollib.protocol.data.game.entity.metadata.Pose; +import org.geysermc.mcprotocollib.protocol.data.game.entity.object.Direction; +import org.geysermc.mcprotocollib.protocol.data.game.entity.object.FallingBlockData; +import org.geysermc.mcprotocollib.protocol.data.game.entity.object.ProjectileData; +import org.geysermc.mcprotocollib.protocol.data.game.entity.object.WardenData; +import org.geysermc.mcprotocollib.protocol.data.game.entity.type.EntityType; +import org.geysermc.mcprotocollib.protocol.packet.ingame.clientbound.entity.spawn.ClientboundAddEntityPacket; @Translator(packet = ClientboundAddEntityPacket.class) public class JavaAddEntityTranslator extends PacketTranslator { @@ -72,7 +76,7 @@ public void translate(GeyserSession session, ClientboundAddEntityPacket packet) } else { entity = session.getEntityCache().getPlayerEntity(packet.getUuid()); if (entity == null) { - GeyserImpl.getInstance().getLogger().error(GeyserLocale.getLocaleStringLog("geyser.entity.player.failed_list", packet.getUuid())); + GeyserLogger.getInstance().error(GeyserLocale.getLocaleStringLog("geyser.entity.player.failed_list", packet.getUuid())); return; } diff --git a/core/src/main/java/org/geysermc/geyser/translator/protocol/java/level/JavaLevelEventTranslator.java b/core/src/main/java/org/geysermc/geyser/translator/protocol/java/level/JavaLevelEventTranslator.java index c10cfa018fc..67bfe416b1e 100644 --- a/core/src/main/java/org/geysermc/geyser/translator/protocol/java/level/JavaLevelEventTranslator.java +++ b/core/src/main/java/org/geysermc/geyser/translator/protocol/java/level/JavaLevelEventTranslator.java @@ -37,7 +37,7 @@ import org.cloudburstmc.protocol.bedrock.packet.SpawnParticleEffectPacket; import org.cloudburstmc.protocol.bedrock.packet.StopSoundPacket; import org.cloudburstmc.protocol.bedrock.packet.TextPacket; -import org.geysermc.geyser.GeyserImpl; +import org.geysermc.geyser.GeyserLogger; import org.geysermc.geyser.level.JukeboxSong; import org.geysermc.geyser.registry.Registries; import org.geysermc.geyser.registry.type.SoundMapping; @@ -449,7 +449,7 @@ public void translate(GeyserSession session, ClientboundLevelEventPacket packet) return; } default -> { - GeyserImpl.getInstance().getLogger().debug("Unhandled level event: " + packet.getEvent()); + GeyserLogger.getInstance().debug("Unhandled level event: " + packet.getEvent()); return; } } diff --git a/core/src/main/java/org/geysermc/geyser/translator/protocol/java/scoreboard/JavaSetObjectiveTranslator.java b/core/src/main/java/org/geysermc/geyser/translator/protocol/java/scoreboard/JavaSetObjectiveTranslator.java index 85d93c0b542..da2001cac05 100644 --- a/core/src/main/java/org/geysermc/geyser/translator/protocol/java/scoreboard/JavaSetObjectiveTranslator.java +++ b/core/src/main/java/org/geysermc/geyser/translator/protocol/java/scoreboard/JavaSetObjectiveTranslator.java @@ -28,7 +28,6 @@ import org.geysermc.mcprotocollib.protocol.data.game.scoreboard.ObjectiveAction; import org.geysermc.mcprotocollib.protocol.data.game.scoreboard.ScoreboardPosition; import org.geysermc.mcprotocollib.protocol.packet.ingame.clientbound.scoreboard.ClientboundSetObjectivePacket; -import org.geysermc.geyser.GeyserImpl; import org.geysermc.geyser.GeyserLogger; import org.geysermc.geyser.entity.type.player.PlayerEntity; import org.geysermc.geyser.scoreboard.Objective; @@ -43,7 +42,7 @@ @Translator(packet = ClientboundSetObjectivePacket.class) public class JavaSetObjectiveTranslator extends PacketTranslator { - private final GeyserLogger logger = GeyserImpl.getInstance().getLogger(); + private final GeyserLogger logger = GeyserLogger.getInstance(); @Override public void translate(GeyserSession session, ClientboundSetObjectivePacket packet) { diff --git a/core/src/main/java/org/geysermc/geyser/translator/protocol/java/scoreboard/JavaSetPlayerTeamTranslator.java b/core/src/main/java/org/geysermc/geyser/translator/protocol/java/scoreboard/JavaSetPlayerTeamTranslator.java index 999edcc8c7b..62915222d7f 100644 --- a/core/src/main/java/org/geysermc/geyser/translator/protocol/java/scoreboard/JavaSetPlayerTeamTranslator.java +++ b/core/src/main/java/org/geysermc/geyser/translator/protocol/java/scoreboard/JavaSetPlayerTeamTranslator.java @@ -29,7 +29,6 @@ import org.geysermc.mcprotocollib.protocol.data.game.scoreboard.TeamAction; import org.geysermc.mcprotocollib.protocol.data.game.scoreboard.TeamColor; import org.geysermc.mcprotocollib.protocol.packet.ingame.clientbound.scoreboard.ClientboundSetPlayerTeamPacket; -import org.geysermc.geyser.GeyserImpl; import org.geysermc.geyser.GeyserLogger; import org.geysermc.geyser.scoreboard.Scoreboard; import org.geysermc.geyser.scoreboard.ScoreboardUpdater; @@ -45,7 +44,7 @@ @Translator(packet = ClientboundSetPlayerTeamPacket.class) public class JavaSetPlayerTeamTranslator extends PacketTranslator { - private final GeyserLogger logger = GeyserImpl.getInstance().getLogger(); + private final GeyserLogger logger = GeyserLogger.getInstance(); @Override public void translate(GeyserSession session, ClientboundSetPlayerTeamPacket packet) { diff --git a/core/src/main/java/org/geysermc/geyser/translator/protocol/java/scoreboard/JavaSetScoreTranslator.java b/core/src/main/java/org/geysermc/geyser/translator/protocol/java/scoreboard/JavaSetScoreTranslator.java index d1645b49660..4105b8f4462 100644 --- a/core/src/main/java/org/geysermc/geyser/translator/protocol/java/scoreboard/JavaSetScoreTranslator.java +++ b/core/src/main/java/org/geysermc/geyser/translator/protocol/java/scoreboard/JavaSetScoreTranslator.java @@ -28,7 +28,6 @@ import org.geysermc.mcprotocollib.protocol.data.game.scoreboard.ScoreboardPosition; import org.geysermc.mcprotocollib.protocol.packet.ingame.clientbound.scoreboard.ClientboundSetScorePacket; import org.checkerframework.checker.nullness.qual.Nullable; -import org.geysermc.geyser.GeyserImpl; import org.geysermc.geyser.GeyserLogger; import org.geysermc.geyser.entity.type.player.PlayerEntity; import org.geysermc.geyser.scoreboard.Objective; @@ -47,7 +46,7 @@ public class JavaSetScoreTranslator extends PacketTranslator generateAssetCache() { VersionInfo versionInfo = GeyserImpl.JSON_MAPPER.readValue(WebUtils.getBody(latestInfoURL), VersionInfo.class); // Get the client jar for use when downloading the en_us locale - GeyserImpl.getInstance().getLogger().debug(GeyserImpl.JSON_MAPPER.writeValueAsString(versionInfo.getDownloads())); + GeyserLogger.getInstance().debug(GeyserImpl.JSON_MAPPER.writeValueAsString(versionInfo.getDownloads())); CLIENT_JAR_INFO = versionInfo.getDownloads().get("client"); - GeyserImpl.getInstance().getLogger().debug(GeyserImpl.JSON_MAPPER.writeValueAsString(CLIENT_JAR_INFO)); + GeyserLogger.getInstance().debug(GeyserImpl.JSON_MAPPER.writeValueAsString(CLIENT_JAR_INFO)); // Get the assets list JsonNode assets = GeyserImpl.JSON_MAPPER.readTree(WebUtils.getBody(versionInfo.getAssetIndex().getUrl())).get("objects"); @@ -125,7 +136,7 @@ public static CompletableFuture generateAssetCache() { } } catch (Exception e) { - GeyserImpl.getInstance().getLogger().error(GeyserLocale.getLocaleStringLog("geyser.locale.fail.asset_cache", (!e.getMessage().isEmpty() ? e.getMessage() : e.getStackTrace()))); + GeyserLogger.getInstance().error(GeyserLocale.getLocaleStringLog("geyser.locale.fail.asset_cache", (!e.getMessage().isEmpty() ? e.getMessage() : e.getStackTrace()))); } return null; }); @@ -134,7 +145,7 @@ public static CompletableFuture generateAssetCache() { public static void downloadAndRunClientJarTasks() { if (CLIENT_JAR_INFO == null) { // Likely failed to download - GeyserImpl.getInstance().getLogger().debug("Skipping en_US hash check as client jar is null."); + GeyserLogger.getInstance().debug("Skipping en_US hash check as client jar is null."); return; } @@ -161,8 +172,8 @@ public static void downloadAndRunClientJarTasks() { try { // Let the user know we are downloading the JAR - GeyserImpl.getInstance().getLogger().info(GeyserLocale.getLocaleStringLog("geyser.locale.download.en_us")); - GeyserImpl.getInstance().getLogger().debug("Download URL: " + CLIENT_JAR_INFO.getUrl()); + GeyserLogger.getInstance().info(GeyserLocale.getLocaleStringLog("geyser.locale.download.en_us")); + GeyserLogger.getInstance().debug("Download URL: " + CLIENT_JAR_INFO.getUrl()); Path tmpFilePath = GeyserImpl.getInstance().getBootstrap().getConfigFolder().resolve("tmp_locale.jar"); WebUtils.downloadFile(CLIENT_JAR_INFO.getUrl(), tmpFilePath.toString()); @@ -186,9 +197,9 @@ public static void downloadAndRunClientJarTasks() { // Delete the nolonger needed client/server jar Files.delete(tmpFilePath); - GeyserImpl.getInstance().getLogger().info(GeyserLocale.getLocaleStringLog("geyser.locale.download.en_us.done")); + GeyserLogger.getInstance().info(GeyserLocale.getLocaleStringLog("geyser.locale.download.en_us.done")); } catch (Exception e) { - GeyserImpl.getInstance().getLogger().error(GeyserLocale.getLocaleStringLog("geyser.locale.fail.en_us"), e); + GeyserLogger.getInstance().error(GeyserLocale.getLocaleStringLog("geyser.locale.fail.en_us"), e); } } diff --git a/core/src/main/java/org/geysermc/geyser/util/FileUtils.java b/core/src/main/java/org/geysermc/geyser/util/FileUtils.java index 87ed8af02c3..4766b8a3920 100644 --- a/core/src/main/java/org/geysermc/geyser/util/FileUtils.java +++ b/core/src/main/java/org/geysermc/geyser/util/FileUtils.java @@ -32,8 +32,14 @@ import com.fasterxml.jackson.dataformat.yaml.YAMLFactory; import org.geysermc.geyser.GeyserBootstrap; import org.geysermc.geyser.GeyserImpl; +import org.geysermc.geyser.GeyserLogger; -import java.io.*; +import java.io.BufferedReader; +import java.io.File; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; import java.lang.annotation.Annotation; import java.nio.charset.StandardCharsets; import java.nio.file.Files; @@ -246,7 +252,7 @@ public static Set> getGeneratedClassesForAnnotation(String input) { try { return Class.forName(className); } catch (ClassNotFoundException ex) { - GeyserImpl.getInstance().getLogger().error("Failed to find class " + className, ex); + GeyserLogger.getInstance().error("Failed to find class " + className, ex); throw new RuntimeException(ex); } }).collect(Collectors.toSet()); diff --git a/core/src/main/java/org/geysermc/geyser/util/InventoryUtils.java b/core/src/main/java/org/geysermc/geyser/util/InventoryUtils.java index d8c41d626d0..fe7e5283e60 100644 --- a/core/src/main/java/org/geysermc/geyser/util/InventoryUtils.java +++ b/core/src/main/java/org/geysermc/geyser/util/InventoryUtils.java @@ -36,7 +36,12 @@ import org.cloudburstmc.protocol.bedrock.packet.InventorySlotPacket; import org.cloudburstmc.protocol.bedrock.packet.PlayerHotbarPacket; import org.geysermc.geyser.GeyserImpl; -import org.geysermc.geyser.inventory.*; +import org.geysermc.geyser.GeyserLogger; +import org.geysermc.geyser.inventory.Container; +import org.geysermc.geyser.inventory.GeyserItemStack; +import org.geysermc.geyser.inventory.Inventory; +import org.geysermc.geyser.inventory.LecternContainer; +import org.geysermc.geyser.inventory.PlayerInventory; import org.geysermc.geyser.inventory.click.Click; import org.geysermc.geyser.inventory.recipe.GeyserRecipe; import org.geysermc.geyser.inventory.recipe.GeyserShapedRecipe; @@ -196,10 +201,10 @@ private static void canStackDebug(GeyserItemStack item1, GeyserItemStack item2) DataComponents components2 = item2.getComponents(); if (components1 != null && components2 != null) { if (components1.hashCode() == components2.hashCode() && !components1.equals(components2)) { - GeyserImpl.getInstance().getLogger().error("DEBUG: DataComponents hash collision"); - GeyserImpl.getInstance().getLogger().error("hash: " + components1.hashCode()); - GeyserImpl.getInstance().getLogger().error("components1: " + components1); - GeyserImpl.getInstance().getLogger().error("components2: " + components2); + GeyserLogger.getInstance().error("DEBUG: DataComponents hash collision"); + GeyserLogger.getInstance().error("hash: " + components1.hashCode()); + GeyserLogger.getInstance().error("components1: " + components1); + GeyserLogger.getInstance().error("components2: " + components2); } } } @@ -240,7 +245,7 @@ private static ItemDefinition getUnusableSpaceBlockDefinition(int protocolVersio ItemDefinition itemDefinition = mappings.getDefinition(unusableSpaceBlock); if (itemDefinition == null) { - GeyserImpl.getInstance().getLogger().error("Invalid value " + unusableSpaceBlock + ". Resorting to barrier block."); + GeyserLogger.getInstance().error("Invalid value " + unusableSpaceBlock + ". Resorting to barrier block."); return mappings.getStoredItems().barrier().getBedrockDefinition(); } else { return itemDefinition; diff --git a/core/src/main/java/org/geysermc/geyser/util/MinecraftAuthLogger.java b/core/src/main/java/org/geysermc/geyser/util/MinecraftAuthLogger.java index 4e928d47e13..51e4bccfc3a 100644 --- a/core/src/main/java/org/geysermc/geyser/util/MinecraftAuthLogger.java +++ b/core/src/main/java/org/geysermc/geyser/util/MinecraftAuthLogger.java @@ -26,7 +26,7 @@ package org.geysermc.geyser.util; import net.raphimc.minecraftauth.util.logging.ILogger; -import org.geysermc.geyser.GeyserImpl; +import org.geysermc.geyser.GeyserLogger; public class MinecraftAuthLogger implements ILogger { @@ -34,16 +34,16 @@ public class MinecraftAuthLogger implements ILogger { @Override public void info(String message) { - GeyserImpl.getInstance().getLogger().debug(message); + GeyserLogger.getInstance().debug(message); } @Override public void warn(String message) { - GeyserImpl.getInstance().getLogger().warning(message); + GeyserLogger.getInstance().warning(message); } @Override public void error(String message) { - GeyserImpl.getInstance().getLogger().error(message); + GeyserLogger.getInstance().error(message); } } diff --git a/core/src/main/java/org/geysermc/geyser/util/NewsHandler.java b/core/src/main/java/org/geysermc/geyser/util/NewsHandler.java index 71e7c99c12a..00bb64af5eb 100644 --- a/core/src/main/java/org/geysermc/geyser/util/NewsHandler.java +++ b/core/src/main/java/org/geysermc/geyser/util/NewsHandler.java @@ -47,7 +47,7 @@ public class NewsHandler { private final ScheduledExecutorService executorService = Executors.newScheduledThreadPool(1); - private final GeyserLogger logger = GeyserImpl.getInstance().getLogger(); + private final GeyserLogger logger = GeyserLogger.getInstance(); private final Gson gson = new Gson(); private final Map activeNewsItems = new HashMap<>(); diff --git a/core/src/main/java/org/geysermc/geyser/util/SoundUtils.java b/core/src/main/java/org/geysermc/geyser/util/SoundUtils.java index 693ce136acc..373d3144125 100644 --- a/core/src/main/java/org/geysermc/geyser/util/SoundUtils.java +++ b/core/src/main/java/org/geysermc/geyser/util/SoundUtils.java @@ -32,7 +32,7 @@ import org.cloudburstmc.protocol.bedrock.packet.LevelEventPacket; import org.cloudburstmc.protocol.bedrock.packet.LevelSoundEventPacket; import org.cloudburstmc.protocol.bedrock.packet.PlaySoundPacket; -import org.geysermc.geyser.GeyserImpl; +import org.geysermc.geyser.GeyserLogger; import org.geysermc.geyser.level.block.type.Block; import org.geysermc.geyser.registry.BlockRegistries; import org.geysermc.geyser.registry.Registries; @@ -70,7 +70,7 @@ public static String translatePlaySound(String javaIdentifier) { SoundMapping soundMapping = Registries.SOUNDS.get(soundIdentifier); if (soundMapping == null || soundMapping.getPlaysound() == null) { // no mapping - GeyserImpl.getInstance().getLogger().debug("[PlaySound] Defaulting to sound server gave us for " + javaIdentifier); + GeyserLogger.getInstance().debug("[PlaySound] Defaulting to sound server gave us for " + javaIdentifier); return soundIdentifier; } return soundMapping.getPlaysound(); diff --git a/core/src/main/java/org/geysermc/geyser/util/VersionCheckUtils.java b/core/src/main/java/org/geysermc/geyser/util/VersionCheckUtils.java index cf90a6bcdc0..a249086b1e2 100644 --- a/core/src/main/java/org/geysermc/geyser/util/VersionCheckUtils.java +++ b/core/src/main/java/org/geysermc/geyser/util/VersionCheckUtils.java @@ -121,7 +121,7 @@ public static void checkForGeyserUpdate(Supplier recipient) .build(); sender.sendMessage(message); } catch (Exception e) { - GeyserImpl.getInstance().getLogger().error("Error whilst checking for Geyser update!", e); + GeyserLogger.getInstance().error("Error whilst checking for Geyser update!", e); } }); } diff --git a/core/src/main/java/org/geysermc/geyser/util/WebUtils.java b/core/src/main/java/org/geysermc/geyser/util/WebUtils.java index 1b7f2d9d966..f17c118dd08 100644 --- a/core/src/main/java/org/geysermc/geyser/util/WebUtils.java +++ b/core/src/main/java/org/geysermc/geyser/util/WebUtils.java @@ -28,10 +28,15 @@ import com.fasterxml.jackson.databind.JsonNode; import org.checkerframework.checker.nullness.qual.Nullable; import org.geysermc.geyser.GeyserImpl; +import org.geysermc.geyser.GeyserLogger; import javax.naming.directory.Attribute; import javax.naming.directory.InitialDirContext; -import java.io.*; +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.io.OutputStream; import java.net.HttpURLConnection; import java.net.URL; import java.net.URLEncoder; @@ -219,7 +224,7 @@ public static Stream getLineStream(String reqURL) { return connectionToString(con).lines(); } catch (Exception e) { - GeyserImpl.getInstance().getLogger().error("Error while trying to get a stream from " + reqURL, e); + GeyserLogger.getInstance().error("Error while trying to get a stream from " + reqURL, e); return Stream.empty(); } } From e57a90f5afacee06a7b1abd24c5a41457ba79283 Mon Sep 17 00:00:00 2001 From: onebeastchris Date: Tue, 27 Aug 2024 12:57:57 +0200 Subject: [PATCH 4/4] Rename GeyserLogger#getInstance to just GeyserLogger#get --- .../bungeecord/GeyserBungeeLogger.java | 7 ------ .../GeyserBungeePingPassthrough.java | 2 +- .../platform/mod/GeyserModInjector.java | 2 +- .../mod/command/ModCommandSource.java | 2 +- .../GeyserSpigotCompressionDisabler.java | 2 +- .../platform/spigot/GeyserSpigotLogger.java | 7 ------ .../platform/spigot/PaperAdventure.java | 12 +++++----- .../manager/GeyserSpigotWorldManager.java | 8 +++---- .../GeyserVelocityCompressionDisabler.java | 2 +- .../viaproxy/GeyserViaProxyLogger.java | 7 ------ .../java/org/geysermc/geyser/GeyserImpl.java | 4 ++-- .../org/geysermc/geyser/GeyserLogger.java | 8 +++++-- .../command/CommandSourceConverter.java | 3 +-- .../geyser/command/ExceptionHandlers.java | 5 ++--- .../defaults/ConnectionTestCommand.java | 2 +- .../command/defaults/VersionCommand.java | 2 +- .../StandaloneCloudCommandManager.java | 2 +- .../geyser/entity/EntityDefinition.java | 4 ++-- .../entity/type/ThrownPotionEntity.java | 2 +- .../extension/GeyserExtensionClassLoader.java | 2 +- .../extension/GeyserExtensionLoader.java | 10 ++++----- .../extension/GeyserExtensionManager.java | 12 +++++----- .../geyser/inventory/CrafterContainer.java | 2 +- .../geysermc/geyser/inventory/Inventory.java | 2 +- .../geyser/inventory/PlayerInventory.java | 4 ++-- .../holder/BlockInventoryHolder.java | 8 +++---- .../updater/AnvilInventoryUpdater.java | 2 +- .../geyser/item/type/EnchantedBookItem.java | 2 +- .../org/geysermc/geyser/item/type/Item.java | 2 +- .../geysermc/geyser/item/type/PotionItem.java | 2 +- .../geyser/item/type/TippedArrowItem.java | 2 +- .../geysermc/geyser/level/JukeboxSong.java | 2 +- .../level/block/GeyserCustomBlockData.java | 2 +- .../geyser/network/netty/Bootstraps.java | 6 ++--- .../geyser/network/netty/GeyserServer.java | 8 +++---- .../geyser/pack/SkullResourcePackManager.java | 22 +++++++++---------- .../geyser/pack/path/GeyserPathPackCodec.java | 2 +- .../registry/PacketTranslatorRegistry.java | 4 ++-- .../loader/CollisionRegistryLoader.java | 4 ++-- .../loader/ParticleTypesRegistryLoader.java | 2 +- .../registry/loader/ResourcePackLoader.java | 6 ++--- .../loader/SoundEventsRegistryLoader.java | 2 +- .../mappings/MappingsConfigReader.java | 8 +++---- .../mappings/versions/MappingsReader_v1.java | 6 ++--- .../populator/BlockRegistryPopulator.java | 6 ++--- .../CreativeItemRegistryPopulator.java | 2 +- .../CustomBlockRegistryPopulator.java | 14 ++++++------ .../CustomItemRegistryPopulator.java | 14 ++++++------ .../CustomSkullRegistryPopulator.java | 18 +++++++-------- .../populator/ItemRegistryPopulator.java | 8 +++---- .../populator/PacketRegistryPopulator.java | 6 ++--- .../geyser/registry/type/ItemMappings.java | 2 +- .../geyser/scoreboard/Scoreboard.java | 3 +-- .../geyser/session/GeyserSession.java | 4 ++-- .../PendingMicrosoftAuthentication.java | 2 +- .../geyser/session/cache/FormCache.java | 2 +- .../geyser/session/cache/RegistryCache.java | 2 +- .../geyser/session/cache/TagCache.java | 5 ++--- .../geyser/skin/FakeHeadProvider.java | 10 ++++----- .../org/geysermc/geyser/skin/SkinManager.java | 8 +++---- .../geysermc/geyser/skin/SkinProvider.java | 20 ++++++++--------- .../geyser/skin/SkullSkinManager.java | 4 ++-- .../geysermc/geyser/text/MinecraftLocale.java | 18 +++++++-------- .../translator/item/ItemTranslator.java | 2 +- .../protocol/java/JavaCommandsTranslator.java | 2 +- .../java/JavaCustomPayloadTranslator.java | 2 +- .../java/JavaUpdateRecipesTranslator.java | 4 ++-- .../JavaPlayerInfoUpdateTranslator.java | 2 +- .../entity/spawn/JavaAddEntityTranslator.java | 2 +- .../java/level/JavaLevelEventTranslator.java | 2 +- .../JavaSetObjectiveTranslator.java | 2 +- .../JavaSetPlayerTeamTranslator.java | 2 +- .../scoreboard/JavaSetScoreTranslator.java | 2 +- .../translator/text/MessageTranslator.java | 6 ++--- .../org/geysermc/geyser/util/AssetUtils.java | 16 +++++++------- .../org/geysermc/geyser/util/FileUtils.java | 2 +- .../geysermc/geyser/util/InventoryUtils.java | 10 ++++----- .../geyser/util/MinecraftAuthLogger.java | 6 ++--- .../org/geysermc/geyser/util/NewsHandler.java | 2 +- .../org/geysermc/geyser/util/SoundUtils.java | 2 +- .../geyser/util/VersionCheckUtils.java | 3 +-- .../org/geysermc/geyser/util/WebUtils.java | 2 +- 82 files changed, 202 insertions(+), 224 deletions(-) diff --git a/bootstrap/bungeecord/src/main/java/org/geysermc/geyser/platform/bungeecord/GeyserBungeeLogger.java b/bootstrap/bungeecord/src/main/java/org/geysermc/geyser/platform/bungeecord/GeyserBungeeLogger.java index 924a95a7978..e8cf7ee39b0 100644 --- a/bootstrap/bungeecord/src/main/java/org/geysermc/geyser/platform/bungeecord/GeyserBungeeLogger.java +++ b/bootstrap/bungeecord/src/main/java/org/geysermc/geyser/platform/bungeecord/GeyserBungeeLogger.java @@ -75,11 +75,4 @@ public void debug(String message) { info(message); } } - - @Override - public void debug(String message, Object... parameters) { - if (debug) { - info(String.format(message, parameters)); - } - } } diff --git a/bootstrap/bungeecord/src/main/java/org/geysermc/geyser/platform/bungeecord/GeyserBungeePingPassthrough.java b/bootstrap/bungeecord/src/main/java/org/geysermc/geyser/platform/bungeecord/GeyserBungeePingPassthrough.java index f3906934ea8..c407ab479e0 100644 --- a/bootstrap/bungeecord/src/main/java/org/geysermc/geyser/platform/bungeecord/GeyserBungeePingPassthrough.java +++ b/bootstrap/bungeecord/src/main/java/org/geysermc/geyser/platform/bungeecord/GeyserBungeePingPassthrough.java @@ -69,7 +69,7 @@ public GeyserPingInfo getPingInformation(InetSocketAddress inetSocketAddress) { event = future.get(100, TimeUnit.MILLISECONDS); } catch (Throwable cause) { String address = GeyserImpl.getInstance().getConfig().isLogPlayerIpAddresses() ? inetSocketAddress.toString() : ""; - GeyserLogger.getInstance().error("Failed to get ping information for " + address, cause); + GeyserLogger.get().error("Failed to get ping information for " + address, cause); return null; } diff --git a/bootstrap/mod/src/main/java/org/geysermc/geyser/platform/mod/GeyserModInjector.java b/bootstrap/mod/src/main/java/org/geysermc/geyser/platform/mod/GeyserModInjector.java index 63ba0e07ed0..c72ecdcb167 100644 --- a/bootstrap/mod/src/main/java/org/geysermc/geyser/platform/mod/GeyserModInjector.java +++ b/bootstrap/mod/src/main/java/org/geysermc/geyser/platform/mod/GeyserModInjector.java @@ -149,7 +149,7 @@ public void shutdown() { eventLoopGroup.shutdownGracefully().sync(); eventLoopGroup = null; } catch (Exception e) { - GeyserLogger.getInstance().error("Unable to shut down injector! " + e.getMessage()); + GeyserLogger.get().error("Unable to shut down injector! " + e.getMessage()); e.printStackTrace(); } } diff --git a/bootstrap/mod/src/main/java/org/geysermc/geyser/platform/mod/command/ModCommandSource.java b/bootstrap/mod/src/main/java/org/geysermc/geyser/platform/mod/command/ModCommandSource.java index a78b373898e..6b449a34797 100644 --- a/bootstrap/mod/src/main/java/org/geysermc/geyser/platform/mod/command/ModCommandSource.java +++ b/bootstrap/mod/src/main/java/org/geysermc/geyser/platform/mod/command/ModCommandSource.java @@ -59,7 +59,7 @@ public void sendMessage(@NonNull String message) { if (source.getEntity() instanceof ServerPlayer) { ((ServerPlayer) source.getEntity()).displayClientMessage(Component.literal(message), false); } else { - GeyserLogger.getInstance().info(ChatColor.toANSI(message + ChatColor.RESET)); + GeyserLogger.get().info(ChatColor.toANSI(message + ChatColor.RESET)); } } diff --git a/bootstrap/spigot/src/main/java/org/geysermc/geyser/platform/spigot/GeyserSpigotCompressionDisabler.java b/bootstrap/spigot/src/main/java/org/geysermc/geyser/platform/spigot/GeyserSpigotCompressionDisabler.java index 9119a022642..7cea782d9c5 100644 --- a/bootstrap/spigot/src/main/java/org/geysermc/geyser/platform/spigot/GeyserSpigotCompressionDisabler.java +++ b/bootstrap/spigot/src/main/java/org/geysermc/geyser/platform/spigot/GeyserSpigotCompressionDisabler.java @@ -56,7 +56,7 @@ public class GeyserSpigotCompressionDisabler extends ChannelOutboundHandlerAdapt loginSuccessPacketClass = findLoginSuccessPacket(); enabled = true; } catch (Exception e) { - GeyserLogger.getInstance().error("Could not initialize compression disabler!", e); + GeyserLogger.get().error("Could not initialize compression disabler!", e); } COMPRESSION_PACKET_CLASS = compressionPacketClass; LOGIN_SUCCESS_PACKET_CLASS = loginSuccessPacketClass; diff --git a/bootstrap/spigot/src/main/java/org/geysermc/geyser/platform/spigot/GeyserSpigotLogger.java b/bootstrap/spigot/src/main/java/org/geysermc/geyser/platform/spigot/GeyserSpigotLogger.java index 88b32844e8f..5c6101eaefe 100644 --- a/bootstrap/spigot/src/main/java/org/geysermc/geyser/platform/spigot/GeyserSpigotLogger.java +++ b/bootstrap/spigot/src/main/java/org/geysermc/geyser/platform/spigot/GeyserSpigotLogger.java @@ -75,11 +75,4 @@ public void debug(String message) { info(message); } } - - @Override - public void debug(String message, Object... parameters) { - if (debug) { - info(String.format(message, parameters)); - } - } } diff --git a/bootstrap/spigot/src/main/java/org/geysermc/geyser/platform/spigot/PaperAdventure.java b/bootstrap/spigot/src/main/java/org/geysermc/geyser/platform/spigot/PaperAdventure.java index 032b12618ba..a36d6a856f3 100644 --- a/bootstrap/spigot/src/main/java/org/geysermc/geyser/platform/spigot/PaperAdventure.java +++ b/bootstrap/spigot/src/main/java/org/geysermc/geyser/platform/spigot/PaperAdventure.java @@ -79,7 +79,7 @@ public final class PaperAdventure { nativeGsonComponentSerializerDeserializeMethodBound = nativeGsonComponentSerializerDeserializeMethod .bindTo(nativeGsonComponentSerializerGsonGetter.invoke()); } catch (final Throwable throwable) { - GeyserLogger.getInstance().error("Failed to access native GsonComponentSerializer", throwable); + GeyserLogger.get().error("Failed to access native GsonComponentSerializer", throwable); } } } @@ -94,7 +94,7 @@ public final class PaperAdventure { try { playerComponentSendMessage = CommandSender.class.getMethod("sendMessage", nativeComponentClass); } catch (final NoSuchMethodException e) { - if (GeyserLogger.getInstance().isDebug()) { + if (GeyserLogger.get().isDebug()) { e.printStackTrace(); } } @@ -104,21 +104,21 @@ public final class PaperAdventure { public static @Nullable Object toNativeComponent(final Component component) { if (NATIVE_GSON_COMPONENT_SERIALIZER_DESERIALIZE_METHOD_BOUND == null) { - GeyserLogger.getInstance().error("Illegal state where Component serialization was called when it wasn't available!"); + GeyserLogger.get().error("Illegal state where Component serialization was called when it wasn't available!"); return null; } try { return NATIVE_GSON_COMPONENT_SERIALIZER_DESERIALIZE_METHOD_BOUND.invoke(DefaultComponentSerializer.get().serialize(component)); } catch (final Throwable throwable) { - GeyserLogger.getInstance().error("Failed to create native Component message", throwable); + GeyserLogger.get().error("Failed to create native Component message", throwable); return null; } } public static void sendMessage(final CommandSender sender, final Component component) { if (SEND_MESSAGE_COMPONENT == null) { - GeyserLogger.getInstance().error("Illegal state where Component sendMessage was called when it wasn't available!"); + GeyserLogger.get().error("Illegal state where Component sendMessage was called when it wasn't available!"); return; } @@ -127,7 +127,7 @@ public static void sendMessage(final CommandSender sender, final Component compo try { SEND_MESSAGE_COMPONENT.invoke(sender, nativeComponent); } catch (final InvocationTargetException | IllegalAccessException e) { - GeyserLogger.getInstance().error("Failed to send native Component message", e); + GeyserLogger.get().error("Failed to send native Component message", e); } } } diff --git a/bootstrap/spigot/src/main/java/org/geysermc/geyser/platform/spigot/world/manager/GeyserSpigotWorldManager.java b/bootstrap/spigot/src/main/java/org/geysermc/geyser/platform/spigot/world/manager/GeyserSpigotWorldManager.java index a026515cc64..ac7b3262990 100644 --- a/bootstrap/spigot/src/main/java/org/geysermc/geyser/platform/spigot/world/manager/GeyserSpigotWorldManager.java +++ b/bootstrap/spigot/src/main/java/org/geysermc/geyser/platform/spigot/world/manager/GeyserSpigotWorldManager.java @@ -94,7 +94,7 @@ public boolean hasOwnChunkCache() { public boolean getGameRuleBool(GeyserSession session, GameRule gameRule) { org.bukkit.GameRule bukkitGameRule = org.bukkit.GameRule.getByName(gameRule.getJavaID()); if (bukkitGameRule == null) { - GeyserLogger.getInstance().debug("Unknown game rule " + gameRule.getJavaID()); + GeyserLogger.get().debug("Unknown game rule " + gameRule.getJavaID()); return gameRule.getDefaultBooleanValue(); } @@ -103,7 +103,7 @@ public boolean getGameRuleBool(GeyserSession session, GameRule gameRule) { if (value instanceof Boolean booleanValue) { return booleanValue; } - GeyserLogger.getInstance().debug("Expected a bool for " + gameRule + " but got " + value); + GeyserLogger.get().debug("Expected a bool for " + gameRule + " but got " + value); return gameRule.getDefaultBooleanValue(); } @@ -111,7 +111,7 @@ public boolean getGameRuleBool(GeyserSession session, GameRule gameRule) { public int getGameRuleInt(GeyserSession session, GameRule gameRule) { org.bukkit.GameRule bukkitGameRule = org.bukkit.GameRule.getByName(gameRule.getJavaID()); if (bukkitGameRule == null) { - GeyserLogger.getInstance().debug("Unknown game rule " + gameRule.getJavaID()); + GeyserLogger.get().debug("Unknown game rule " + gameRule.getJavaID()); return gameRule.getDefaultIntValue(); } Player bukkitPlayer = Objects.requireNonNull(Bukkit.getPlayer(session.getPlayerEntity().getUuid())); @@ -119,7 +119,7 @@ public int getGameRuleInt(GeyserSession session, GameRule gameRule) { if (value instanceof Integer intValue) { return intValue; } - GeyserLogger.getInstance().debug("Expected an int for " + gameRule + " but got " + value); + GeyserLogger.get().debug("Expected an int for " + gameRule + " but got " + value); return gameRule.getDefaultIntValue(); } diff --git a/bootstrap/velocity/src/main/java/org/geysermc/geyser/platform/velocity/GeyserVelocityCompressionDisabler.java b/bootstrap/velocity/src/main/java/org/geysermc/geyser/platform/velocity/GeyserVelocityCompressionDisabler.java index 5e2ba8b2720..7c342f696fe 100644 --- a/bootstrap/velocity/src/main/java/org/geysermc/geyser/platform/velocity/GeyserVelocityCompressionDisabler.java +++ b/bootstrap/velocity/src/main/java/org/geysermc/geyser/platform/velocity/GeyserVelocityCompressionDisabler.java @@ -61,7 +61,7 @@ public class GeyserVelocityCompressionDisabler extends ChannelDuplexHandler { .getMethod("setCompressionThreshold", int.class); enabled = true; } catch (Exception e) { - GeyserLogger.getInstance().error("Could not initialize compression disabler!", e); + GeyserLogger.get().error("Could not initialize compression disabler!", e); } ENABLED = enabled; diff --git a/bootstrap/viaproxy/src/main/java/org/geysermc/geyser/platform/viaproxy/GeyserViaProxyLogger.java b/bootstrap/viaproxy/src/main/java/org/geysermc/geyser/platform/viaproxy/GeyserViaProxyLogger.java index 5cf0183c725..10f414b51dc 100644 --- a/bootstrap/viaproxy/src/main/java/org/geysermc/geyser/platform/viaproxy/GeyserViaProxyLogger.java +++ b/bootstrap/viaproxy/src/main/java/org/geysermc/geyser/platform/viaproxy/GeyserViaProxyLogger.java @@ -75,13 +75,6 @@ public void debug(String message) { } } - @Override - public void debug(String message, Object... parameters) { - if (this.debug) { - this.logger.debug(ConsoleFormatter.convert(message.formatted(parameters))); - } - } - @Override public void setDebug(boolean debug) { this.debug = debug; diff --git a/core/src/main/java/org/geysermc/geyser/GeyserImpl.java b/core/src/main/java/org/geysermc/geyser/GeyserImpl.java index 68b3f5183e2..24ee0bdcc48 100644 --- a/core/src/main/java/org/geysermc/geyser/GeyserImpl.java +++ b/core/src/main/java/org/geysermc/geyser/GeyserImpl.java @@ -592,7 +592,7 @@ private void startInstance() { String authChain = gson.toJson(javaSession.toJson(fullJavaSession)); savedAuthChains.put(user, authChain); } catch (Exception e) { - GeyserLogger.getInstance().warning("Could not migrate " + entry.getKey() + " to an auth chain! " + + GeyserLogger.get().warning("Could not migrate " + entry.getKey() + " to an auth chain! " + "They will need to sign in the next time they join Geyser."); } @@ -915,7 +915,7 @@ private void scheduleAuthChainsWrite() { .withDefaultPrettyPrinter() .writeValue(writer, this.savedAuthChains); } catch (IOException e) { - GeyserLogger.getInstance().error("Unable to write saved refresh tokens!", e); + GeyserLogger.get().error("Unable to write saved refresh tokens!", e); } }); } diff --git a/core/src/main/java/org/geysermc/geyser/GeyserLogger.java b/core/src/main/java/org/geysermc/geyser/GeyserLogger.java index 8f20c83e5d7..a90bc7e4842 100644 --- a/core/src/main/java/org/geysermc/geyser/GeyserLogger.java +++ b/core/src/main/java/org/geysermc/geyser/GeyserLogger.java @@ -40,7 +40,7 @@ public interface GeyserLogger extends GeyserCommandSource { /** * Returns the current GeyserLogger instance. */ - static GeyserLogger getInstance() { + static GeyserLogger get() { return INSTANCE.get(); } @@ -119,7 +119,11 @@ default void debug(@Nullable Object object) { * @param message the message with placeholders for the objects * @param parameters the parameters for the message */ - void debug(String message, Object... parameters); + default void debug(String message, Object... parameters) { + if (isDebug()) { + debug(String.format(message, parameters)); + } + } /** * Sets if the logger should print debug messages diff --git a/core/src/main/java/org/geysermc/geyser/command/CommandSourceConverter.java b/core/src/main/java/org/geysermc/geyser/command/CommandSourceConverter.java index 9dd9fad804e..0ace70a48d4 100644 --- a/core/src/main/java/org/geysermc/geyser/command/CommandSourceConverter.java +++ b/core/src/main/java/org/geysermc/geyser/command/CommandSourceConverter.java @@ -26,7 +26,6 @@ package org.geysermc.geyser.command; import org.checkerframework.checker.nullness.qual.NonNull; -import org.geysermc.geyser.GeyserImpl; import org.geysermc.geyser.GeyserLogger; import org.geysermc.geyser.session.GeyserSession; import org.incendo.cloud.SenderMapper; @@ -95,7 +94,7 @@ public static CommandSourceConverter layered(Class senderType, } if (!(source instanceof GeyserSession)) { - GeyserLogger logger = GeyserLogger.getInstance(); + GeyserLogger logger = GeyserLogger.get(); if (logger.isDebug()) { logger.debug("Falling back to UUID for command sender lookup for a command source that is not a GeyserSession: " + source); Thread.dumpStack(); diff --git a/core/src/main/java/org/geysermc/geyser/command/ExceptionHandlers.java b/core/src/main/java/org/geysermc/geyser/command/ExceptionHandlers.java index f8f45a30ef6..5cbf9cf23a1 100644 --- a/core/src/main/java/org/geysermc/geyser/command/ExceptionHandlers.java +++ b/core/src/main/java/org/geysermc/geyser/command/ExceptionHandlers.java @@ -26,7 +26,6 @@ package org.geysermc.geyser.command; import io.leangen.geantyref.GenericTypeReflector; -import org.geysermc.geyser.GeyserImpl; import org.geysermc.geyser.GeyserLogger; import org.geysermc.geyser.text.ChatColor; import org.geysermc.geyser.text.GeyserLocale; @@ -112,7 +111,7 @@ private static void handleNoPermission(GeyserCommandSource source, NoPermissionE return; } } else { - GeyserLogger logger = GeyserLogger.getInstance(); + GeyserLogger logger = GeyserLogger.get(); if (logger.isDebug()) { logger.debug("Expected a GeyserPermission.Result for %s but instead got %s from %s".formatted(exception.currentChain(), exception.permissionResult(), exception.missingPermission())); } @@ -124,6 +123,6 @@ private static void handleNoPermission(GeyserCommandSource source, NoPermissionE private static void handleUnexpectedThrowable(GeyserCommandSource source, Throwable throwable) { source.sendMessage(MinecraftLocale.getLocaleString("command.failed", source.locale())); // java edition translation key - GeyserLogger.getInstance().error("Exception while executing command handler", throwable); + GeyserLogger.get().error("Exception while executing command handler", throwable); } } diff --git a/core/src/main/java/org/geysermc/geyser/command/defaults/ConnectionTestCommand.java b/core/src/main/java/org/geysermc/geyser/command/defaults/ConnectionTestCommand.java index 44ba6223b99..786a1461412 100644 --- a/core/src/main/java/org/geysermc/geyser/command/defaults/ConnectionTestCommand.java +++ b/core/src/main/java/org/geysermc/geyser/command/defaults/ConnectionTestCommand.java @@ -156,7 +156,7 @@ public void execute(CommandContext context) { } // Issue: does Loopback need applying? - if (LoopbackUtil.needsLoopback(GeyserLogger.getInstance())) { + if (LoopbackUtil.needsLoopback(GeyserLogger.get())) { source.sendMessage("Loopback is not applied on this computer! You will have issues connecting from the same computer. " + "See here for steps on how to resolve: " + "https://wiki.geysermc.org/geyser/fixing-unable-to-connect-to-world/#using-geyser-on-the-same-computer"); } diff --git a/core/src/main/java/org/geysermc/geyser/command/defaults/VersionCommand.java b/core/src/main/java/org/geysermc/geyser/command/defaults/VersionCommand.java index 83ae9ba77db..66d8649c81a 100644 --- a/core/src/main/java/org/geysermc/geyser/command/defaults/VersionCommand.java +++ b/core/src/main/java/org/geysermc/geyser/command/defaults/VersionCommand.java @@ -99,7 +99,7 @@ public void execute(CommandContext context) { source.locale(), (latestBuildNumber - buildNumber), "https://geysermc.org/download" )); } catch (IOException e) { - GeyserLogger.getInstance().error(GeyserLocale.getLocaleStringLog("geyser.commands.version.failed"), e); + GeyserLogger.get().error(GeyserLocale.getLocaleStringLog("geyser.commands.version.failed"), e); source.sendMessage(ChatColor.RED + GeyserLocale.getPlayerLocaleString("geyser.commands.version.failed", source.locale())); } } diff --git a/core/src/main/java/org/geysermc/geyser/command/standalone/StandaloneCloudCommandManager.java b/core/src/main/java/org/geysermc/geyser/command/standalone/StandaloneCloudCommandManager.java index 190380d8374..1537691105a 100644 --- a/core/src/main/java/org/geysermc/geyser/command/standalone/StandaloneCloudCommandManager.java +++ b/core/src/main/java/org/geysermc/geyser/command/standalone/StandaloneCloudCommandManager.java @@ -76,7 +76,7 @@ public StandaloneCloudCommandManager(GeyserImpl geyser) { PermissionConfiguration config = FileUtils.loadConfig(permissionsFile, PermissionConfiguration.class); basePermissions.addAll(config.getDefaultPermissions()); } catch (Exception e) { - GeyserLogger.getInstance().error("Failed to load permissions.yml - proceeding without it", e); + GeyserLogger.get().error("Failed to load permissions.yml - proceeding without it", e); } } diff --git a/core/src/main/java/org/geysermc/geyser/entity/EntityDefinition.java b/core/src/main/java/org/geysermc/geyser/entity/EntityDefinition.java index 2f4e9a54537..df4d91e4243 100644 --- a/core/src/main/java/org/geysermc/geyser/entity/EntityDefinition.java +++ b/core/src/main/java/org/geysermc/geyser/entity/EntityDefinition.java @@ -71,9 +71,9 @@ public void translateMetadata(T entity, EntityMetadata entityMetadata) { setFlag(EntityFlag.ENCHANTED, !NON_ENCHANTED_POTIONS.contains(potion)); } else { dirtyMetadata.put(EntityDataTypes.AUX_VALUE_DATA, (short) 0); - GeyserLogger.getInstance().debug("Unknown java potion: " + potionContents.getPotionId()); + GeyserLogger.get().debug("Unknown java potion: " + potionContents.getPotionId()); } } diff --git a/core/src/main/java/org/geysermc/geyser/extension/GeyserExtensionClassLoader.java b/core/src/main/java/org/geysermc/geyser/extension/GeyserExtensionClassLoader.java index 15546fc24f1..0d3b3bd5bf8 100644 --- a/core/src/main/java/org/geysermc/geyser/extension/GeyserExtensionClassLoader.java +++ b/core/src/main/java/org/geysermc/geyser/extension/GeyserExtensionClassLoader.java @@ -90,7 +90,7 @@ protected Class findClass(String name, boolean checkGlobal) throws ClassNotFo // This is used for classes that are not in the extension, but are in other extensions if (checkGlobal) { if (!warnedForExternalClassAccess) { - GeyserLogger.getInstance().warning("Extension " + this.description.name() + " loads class " + name + " from an external source. " + + GeyserLogger.get().warning("Extension " + this.description.name() + " loads class " + name + " from an external source. " + "This can change at any time and break the extension, additionally to potentially causing unexpected behaviour!"); warnedForExternalClassAccess = true; } diff --git a/core/src/main/java/org/geysermc/geyser/extension/GeyserExtensionLoader.java b/core/src/main/java/org/geysermc/geyser/extension/GeyserExtensionLoader.java index 111b1dff050..89ff29ceaea 100644 --- a/core/src/main/java/org/geysermc/geyser/extension/GeyserExtensionLoader.java +++ b/core/src/main/java/org/geysermc/geyser/extension/GeyserExtensionLoader.java @@ -114,7 +114,7 @@ public GeyserExtensionContainer loadExtension(Path path, GeyserExtensionDescript } private GeyserExtensionContainer setup(Extension extension, GeyserExtensionDescription description, Path dataFolder, ExtensionEventBus eventBus) { - GeyserExtensionLogger logger = new GeyserExtensionLogger(GeyserLogger.getInstance(), description.id()); + GeyserExtensionLogger logger = new GeyserExtensionLogger(GeyserLogger.get(), description.id()); return new GeyserExtensionContainer(extension, dataFolder, description, this, logger, eventBus); } @@ -183,7 +183,7 @@ protected void loadAllExtensions(@NonNull ExtensionManager extensionManager) { String name = description.name(); String id = description.id(); if (extensions.containsKey(id) || extensionManager.extension(id) != null) { - GeyserLogger.getInstance().warning(GeyserLocale.getLocaleStringLog("geyser.extensions.load.duplicate", name, path.toString())); + GeyserLogger.get().warning(GeyserLocale.getLocaleStringLog("geyser.extensions.load.duplicate", name, path.toString())); return; } @@ -197,10 +197,10 @@ protected void loadAllExtensions(@NonNull ExtensionManager extensionManager) { if (compatibility != ApiVersion.Compatibility.COMPATIBLE) { // Workaround for the switch to the Geyser API version instead of the Base API version in extensions if (compatibility == ApiVersion.Compatibility.HUMAN_DIFFER && description.humanApiVersion() == 1) { - GeyserLogger.getInstance().warning("The extension %s requested the Base API version %s, which is deprecated in favor of specifying the Geyser API version. Please update the extension, or contact its developer." + GeyserLogger.get().warning("The extension %s requested the Base API version %s, which is deprecated in favor of specifying the Geyser API version. Please update the extension, or contact its developer." .formatted(name, description.apiVersion())); } else { - GeyserLogger.getInstance().error(GeyserLocale.getLocaleStringLog("geyser.extensions.load.failed_api_version", name, description.apiVersion())); + GeyserLogger.get().error(GeyserLocale.getLocaleStringLog("geyser.extensions.load.failed_api_version", name, description.apiVersion())); return; } } @@ -209,7 +209,7 @@ protected void loadAllExtensions(@NonNull ExtensionManager extensionManager) { extensions.put(id, path); loadedExtensions.put(id, container); } catch (Throwable e) { - GeyserLogger.getInstance().error(GeyserLocale.getLocaleStringLog("geyser.extensions.load.failed_with_name", path.getFileName(), path.toAbsolutePath()), e); + GeyserLogger.get().error(GeyserLocale.getLocaleStringLog("geyser.extensions.load.failed_with_name", path.getFileName(), path.toAbsolutePath()), e); } }); diff --git a/core/src/main/java/org/geysermc/geyser/extension/GeyserExtensionManager.java b/core/src/main/java/org/geysermc/geyser/extension/GeyserExtensionManager.java index 10779bd2bcc..2c819b2de5d 100644 --- a/core/src/main/java/org/geysermc/geyser/extension/GeyserExtensionManager.java +++ b/core/src/main/java/org/geysermc/geyser/extension/GeyserExtensionManager.java @@ -44,12 +44,12 @@ public class GeyserExtensionManager extends ExtensionManager { private final Map extensions = new LinkedHashMap<>(); public void init() { - GeyserLogger.getInstance().info(GeyserLocale.getLocaleStringLog("geyser.extensions.load.loading")); + GeyserLogger.get().info(GeyserLocale.getLocaleStringLog("geyser.extensions.load.loading")); loadAllExtensions(this.extensionLoader); enableExtensions(); - GeyserLogger.getInstance().info(GeyserLocale.getLocaleStringLog("geyser.extensions.load.done", this.extensions.size())); + GeyserLogger.get().info(GeyserLocale.getLocaleStringLog("geyser.extensions.load.done", this.extensions.size())); } @Override @@ -63,7 +63,7 @@ public void enable(@NonNull Extension extension) { try { this.enableExtension(extension); } catch (Exception e) { - GeyserLogger.getInstance().error(GeyserLocale.getLocaleStringLog("geyser.extensions.enable.failed", extension.name()), e); + GeyserLogger.get().error(GeyserLocale.getLocaleStringLog("geyser.extensions.enable.failed", extension.name()), e); this.disable(extension); } } @@ -75,7 +75,7 @@ public void disable(@NonNull Extension extension) { try { this.disableExtension(extension); } catch (Exception e) { - GeyserLogger.getInstance().error(GeyserLocale.getLocaleStringLog("geyser.extensions.disable.failed", extension.name()), e); + GeyserLogger.get().error(GeyserLocale.getLocaleStringLog("geyser.extensions.disable.failed", extension.name()), e); } } } @@ -84,7 +84,7 @@ public void enableExtension(Extension extension) { if (!extension.isEnabled()) { extension.setEnabled(true); GeyserImpl.getInstance().eventBus().register(extension, extension); - GeyserLogger.getInstance().info(GeyserLocale.getLocaleStringLog("geyser.extensions.enable.success", extension.name())); + GeyserLogger.get().info(GeyserLocale.getLocaleStringLog("geyser.extensions.enable.success", extension.name())); } } @@ -99,7 +99,7 @@ private void disableExtension(@NonNull Extension extension) { GeyserImpl.getInstance().eventBus().unregisterAll(extension); extension.setEnabled(false); - GeyserLogger.getInstance().info(GeyserLocale.getLocaleStringLog("geyser.extensions.disable.success", extension.name())); + GeyserLogger.get().info(GeyserLocale.getLocaleStringLog("geyser.extensions.disable.success", extension.name())); } } diff --git a/core/src/main/java/org/geysermc/geyser/inventory/CrafterContainer.java b/core/src/main/java/org/geysermc/geyser/inventory/CrafterContainer.java index d9df6af1497..84e54f38223 100644 --- a/core/src/main/java/org/geysermc/geyser/inventory/CrafterContainer.java +++ b/core/src/main/java/org/geysermc/geyser/inventory/CrafterContainer.java @@ -82,7 +82,7 @@ public void setItem(int slot, @NonNull GeyserItemStack newItem, GeyserSession se public void setSlot(int slot, boolean enabled) { if (!isCraftingGrid(slot)) { - GeyserLogger.getInstance().warning("Crafter slot out of bounds: " + slot); + GeyserLogger.get().warning("Crafter slot out of bounds: " + slot); return; } diff --git a/core/src/main/java/org/geysermc/geyser/inventory/Inventory.java b/core/src/main/java/org/geysermc/geyser/inventory/Inventory.java index 09a94991c87..5548b261490 100644 --- a/core/src/main/java/org/geysermc/geyser/inventory/Inventory.java +++ b/core/src/main/java/org/geysermc/geyser/inventory/Inventory.java @@ -116,7 +116,7 @@ public int getBedrockId() { public GeyserItemStack getItem(int slot) { if (slot > this.size) { - GeyserLogger.getInstance().debug("Tried to get an item out of bounds! " + this); + GeyserLogger.get().debug("Tried to get an item out of bounds! " + this); return GeyserItemStack.EMPTY; } return items[slot]; diff --git a/core/src/main/java/org/geysermc/geyser/inventory/PlayerInventory.java b/core/src/main/java/org/geysermc/geyser/inventory/PlayerInventory.java index cb56fd94aac..5fb455faa06 100644 --- a/core/src/main/java/org/geysermc/geyser/inventory/PlayerInventory.java +++ b/core/src/main/java/org/geysermc/geyser/inventory/PlayerInventory.java @@ -78,7 +78,7 @@ public GeyserItemStack getItemInHand(@NonNull Hand hand) { public GeyserItemStack getItemInHand() { if (36 + heldItemSlot > this.size) { - GeyserLogger.getInstance().debug("Held item slot was larger than expected!"); + GeyserLogger.get().debug("Held item slot was larger than expected!"); return GeyserItemStack.EMPTY; } return items[36 + heldItemSlot]; @@ -90,7 +90,7 @@ public boolean eitherHandMatchesItem(@NonNull Item item) { public void setItemInHand(@NonNull GeyserItemStack item) { if (36 + heldItemSlot > this.size) { - GeyserLogger.getInstance().debug("Held item slot was larger than expected!"); + GeyserLogger.get().debug("Held item slot was larger than expected!"); return; } items[36 + heldItemSlot] = item; diff --git a/core/src/main/java/org/geysermc/geyser/inventory/holder/BlockInventoryHolder.java b/core/src/main/java/org/geysermc/geyser/inventory/holder/BlockInventoryHolder.java index cfa78d24a97..d581959e022 100644 --- a/core/src/main/java/org/geysermc/geyser/inventory/holder/BlockInventoryHolder.java +++ b/core/src/main/java/org/geysermc/geyser/inventory/holder/BlockInventoryHolder.java @@ -168,10 +168,10 @@ public void closeInventory(InventoryTranslator translator, GeyserSession session return; } } else { - GeyserLogger.getInstance().warning("Tried to close a non-container inventory in a block inventory holder! "); - if (GeyserLogger.getInstance().isDebug()) { - GeyserLogger.getInstance().debug("Current inventory: " + inventory); - GeyserLogger.getInstance().debug("Open inventory: " + session.getOpenInventory()); + GeyserLogger.get().warning("Tried to close a non-container inventory in a block inventory holder! "); + if (GeyserLogger.get().isDebug()) { + GeyserLogger.get().debug("Current inventory: " + inventory); + GeyserLogger.get().debug("Open inventory: " + session.getOpenInventory()); } // Try to save ourselves? maybe? // https://github.com/GeyserMC/Geyser/issues/4141 diff --git a/core/src/main/java/org/geysermc/geyser/inventory/updater/AnvilInventoryUpdater.java b/core/src/main/java/org/geysermc/geyser/inventory/updater/AnvilInventoryUpdater.java index 4e10ae94956..f30230a4029 100644 --- a/core/src/main/java/org/geysermc/geyser/inventory/updater/AnvilInventoryUpdater.java +++ b/core/src/main/java/org/geysermc/geyser/inventory/updater/AnvilInventoryUpdater.java @@ -383,7 +383,7 @@ private Object2IntMap getEnchantments(GeyserSession session, Geyser for (Map.Entry entry : enchantmentComponent.getEnchantments().entrySet()) { Enchantment enchantment = session.getRegistryCache().enchantments().byId(entry.getKey()); if (enchantment == null) { - GeyserLogger.getInstance().debug("Unknown Java enchantment in anvil: " + entry.getKey()); + GeyserLogger.get().debug("Unknown Java enchantment in anvil: " + entry.getKey()); continue; } enchantments.put(enchantment, entry.getValue().intValue()); diff --git a/core/src/main/java/org/geysermc/geyser/item/type/EnchantedBookItem.java b/core/src/main/java/org/geysermc/geyser/item/type/EnchantedBookItem.java index 1e8c44d7802..585787d13fc 100644 --- a/core/src/main/java/org/geysermc/geyser/item/type/EnchantedBookItem.java +++ b/core/src/main/java/org/geysermc/geyser/item/type/EnchantedBookItem.java @@ -90,7 +90,7 @@ public void translateNbtToJava(@NonNull GeyserSession session, @NonNull NbtMap b } } } else { - GeyserLogger.getInstance().debug("Unknown bedrock enchantment: " + bedrockId); + GeyserLogger.get().debug("Unknown bedrock enchantment: " + bedrockId); } } if (!javaEnchantments.isEmpty()) { diff --git a/core/src/main/java/org/geysermc/geyser/item/type/Item.java b/core/src/main/java/org/geysermc/geyser/item/type/Item.java index a1eba13ccf1..eefeb4bd820 100644 --- a/core/src/main/java/org/geysermc/geyser/item/type/Item.java +++ b/core/src/main/java/org/geysermc/geyser/item/type/Item.java @@ -219,7 +219,7 @@ public void translateNbtToJava(@NonNull GeyserSession session, @NonNull NbtMap b protected final @Nullable NbtMap remapEnchantment(GeyserSession session, int enchantId, int level, BedrockItemBuilder builder) { Enchantment enchantment = session.getRegistryCache().enchantments().byId(enchantId); if (enchantment == null) { - GeyserLogger.getInstance().debug("Unknown Java enchantment while NBT item translating: " + enchantId); + GeyserLogger.get().debug("Unknown Java enchantment while NBT item translating: " + enchantId); return null; } diff --git a/core/src/main/java/org/geysermc/geyser/item/type/PotionItem.java b/core/src/main/java/org/geysermc/geyser/item/type/PotionItem.java index b5525175317..64b13e9b221 100644 --- a/core/src/main/java/org/geysermc/geyser/item/type/PotionItem.java +++ b/core/src/main/java/org/geysermc/geyser/item/type/PotionItem.java @@ -57,7 +57,7 @@ public ItemData.Builder translateToBedrock(int count, DataComponents components, .damage(potion.getBedrockId()) .count(count); } - GeyserLogger.getInstance().debug("Unknown Java potion: " + potionContents.getPotionId()); + GeyserLogger.get().debug("Unknown Java potion: " + potionContents.getPotionId()); } else { return ItemData.builder() .definition(customItemDefinition) diff --git a/core/src/main/java/org/geysermc/geyser/item/type/TippedArrowItem.java b/core/src/main/java/org/geysermc/geyser/item/type/TippedArrowItem.java index d258435b073..394e3e9990f 100644 --- a/core/src/main/java/org/geysermc/geyser/item/type/TippedArrowItem.java +++ b/core/src/main/java/org/geysermc/geyser/item/type/TippedArrowItem.java @@ -51,7 +51,7 @@ public ItemData.Builder translateToBedrock(int count, DataComponents components, .damage(potion.tippedArrowId()) .count(count); } - GeyserLogger.getInstance().debug("Unknown Java potion (tipped arrow): " + potionContents.getPotionId()); + GeyserLogger.get().debug("Unknown Java potion (tipped arrow): " + potionContents.getPotionId()); } } return super.translateToBedrock(count, components, mapping, mappings); diff --git a/core/src/main/java/org/geysermc/geyser/level/JukeboxSong.java b/core/src/main/java/org/geysermc/geyser/level/JukeboxSong.java index fe7d263e763..ae418a94bf7 100644 --- a/core/src/main/java/org/geysermc/geyser/level/JukeboxSong.java +++ b/core/src/main/java/org/geysermc/geyser/level/JukeboxSong.java @@ -42,7 +42,7 @@ public static JukeboxSong read(RegistryEntryContext context) { soundEvent = string; } else { soundEvent = ""; - GeyserLogger.getInstance().debug("Sound event for " + context.id() + " was of an unexpected type! Expected string or NBT map, got " + soundEventObject); + GeyserLogger.get().debug("Sound event for " + context.id() + " was of an unexpected type! Expected string or NBT map, got " + soundEventObject); } String description = MessageTranslator.deserializeDescription(data); return new JukeboxSong(soundEvent, description); diff --git a/core/src/main/java/org/geysermc/geyser/level/block/GeyserCustomBlockData.java b/core/src/main/java/org/geysermc/geyser/level/block/GeyserCustomBlockData.java index 15f9d669b06..a3cac5d0270 100644 --- a/core/src/main/java/org/geysermc/geyser/level/block/GeyserCustomBlockData.java +++ b/core/src/main/java/org/geysermc/geyser/level/block/GeyserCustomBlockData.java @@ -75,7 +75,7 @@ public class GeyserCustomBlockData implements CustomBlockData { Object2ObjectMap defaultProperties = new Object2ObjectOpenHashMap<>(this.properties.size()); for (CustomBlockProperty property : properties.values()) { if (property.values().size() > 16) { - GeyserLogger.getInstance().warning(property.name() + " contains more than 16 values, but BDS specifies it should not. This may break in future versions."); + GeyserLogger.get().warning(property.name() + " contains more than 16 values, but BDS specifies it should not. This may break in future versions."); } if (property.values().stream().distinct().count() != property.values().size()) { throw new IllegalStateException(property.name() + " has duplicate values."); diff --git a/core/src/main/java/org/geysermc/geyser/network/netty/Bootstraps.java b/core/src/main/java/org/geysermc/geyser/network/netty/Bootstraps.java index e66e21ba95f..95a8261039a 100644 --- a/core/src/main/java/org/geysermc/geyser/network/netty/Bootstraps.java +++ b/core/src/main/java/org/geysermc/geyser/network/netty/Bootstraps.java @@ -49,9 +49,9 @@ public final class Bootstraps { String kernelVersion; try { kernelVersion = Native.KERNEL_VERSION; - GeyserLogger.getInstance().debug("Kernel version: " + kernelVersion); + GeyserLogger.get().debug("Kernel version: " + kernelVersion); } catch (Throwable e) { - GeyserLogger.getInstance().debug("Could not determine kernel version! " + e.getMessage()); + GeyserLogger.get().debug("Could not determine kernel version! " + e.getMessage()); kernelVersion = null; } @@ -77,7 +77,7 @@ public static boolean setupBootstrap(AbstractBootstrap bootstrap) { bootstrap.option(UnixChannelOption.SO_REUSEPORT, true); } else { // If this occurs, we guessed wrong and reuseport is not available - GeyserLogger.getInstance().debug("so_reuseport is not available despite version being " + Native.KERNEL_VERSION); + GeyserLogger.get().debug("so_reuseport is not available despite version being " + Native.KERNEL_VERSION); success = false; } // Now yeet that channel diff --git a/core/src/main/java/org/geysermc/geyser/network/netty/GeyserServer.java b/core/src/main/java/org/geysermc/geyser/network/netty/GeyserServer.java index b9ba4082563..0f6860b01f6 100644 --- a/core/src/main/java/org/geysermc/geyser/network/netty/GeyserServer.java +++ b/core/src/main/java/org/geysermc/geyser/network/netty/GeyserServer.java @@ -126,7 +126,7 @@ public final class GeyserServer { public GeyserServer(GeyserImpl geyser, int threadCount) { this.geyser = geyser; this.listenCount = Bootstraps.isReusePortAvailable() ? Integer.getInteger("Geyser.ListenCount", 2) : 1; - GeyserLogger.getInstance().debug("Listen thread count: " + listenCount); + GeyserLogger.get().debug("Listen thread count: " + listenCount); this.group = TRANSPORT.eventLoopGroupFactory().apply(listenCount); this.childGroup = TRANSPORT.eventLoopGroupFactory().apply(threadCount); @@ -199,7 +199,7 @@ public void shutdown() { SkinProvider.shutdown(); } catch (InterruptedException e) { - GeyserLogger.getInstance().severe("Exception in shutdown process", e); + GeyserLogger.get().severe("Exception in shutdown process", e); } for (ChannelFuture f : bootstrapFutures) { f.channel().closeFuture().syncUninterruptibly(); @@ -420,7 +420,7 @@ private static int positivePropOrDefault(String property, int defaultValue) { int parsed = value != null ? Integer.parseInt(value) : defaultValue; if (parsed < 1) { - GeyserLogger.getInstance().warning( + GeyserLogger.get().warning( "Non-postive integer value for " + property + ": " + value + ". Using default value: " + defaultValue ); return defaultValue; @@ -428,7 +428,7 @@ private static int positivePropOrDefault(String property, int defaultValue) { return parsed; } catch (NumberFormatException e) { - GeyserLogger.getInstance().warning( + GeyserLogger.get().warning( "Invalid integer value for " + property + ": " + value + ". Using default value: " + defaultValue ); return defaultValue; diff --git a/core/src/main/java/org/geysermc/geyser/pack/SkullResourcePackManager.java b/core/src/main/java/org/geysermc/geyser/pack/SkullResourcePackManager.java index f711488c6c6..df7d4513b40 100644 --- a/core/src/main/java/org/geysermc/geyser/pack/SkullResourcePackManager.java +++ b/core/src/main/java/org/geysermc/geyser/pack/SkullResourcePackManager.java @@ -76,7 +76,7 @@ public class SkullResourcePackManager { try { Files.createDirectories(cachePath); } catch (IOException e) { - GeyserLogger.getInstance().severe("Unable to create directories for player skull resource pack!", e); + GeyserLogger.get().severe("Unable to create directories for player skull resource pack!", e); return null; } cleanSkullSkinCache(); @@ -88,22 +88,22 @@ public class SkullResourcePackManager { return null; } if (packFile.exists() && canReusePack(packFile)) { - GeyserLogger.getInstance().info("Reusing cached player skull resource pack."); + GeyserLogger.get().info("Reusing cached player skull resource pack."); return packPath; } // We need to create the resource pack from scratch - GeyserLogger.getInstance().info("Creating skull resource pack."); + GeyserLogger.get().info("Creating skull resource pack."); packFile.delete(); try (ZipOutputStream zipOS = new ZipOutputStream(Files.newOutputStream(packPath, StandardOpenOption.WRITE, StandardOpenOption.CREATE))) { addBaseResources(zipOS); addSkinTextures(zipOS); addAttachables(zipOS); - GeyserLogger.getInstance().info("Finished creating skull resource pack."); + GeyserLogger.get().info("Finished creating skull resource pack."); return packPath; } catch (IOException e) { - GeyserLogger.getInstance().severe("Unable to create player skull resource pack!", e); - GeyserLogger.getInstance().severe("Bedrock players will see dirt blocks instead of custom skull blocks."); + GeyserLogger.get().severe("Unable to create player skull resource pack!", e); + GeyserLogger.get().severe("Bedrock players will see dirt blocks instead of custom skull blocks."); packFile.delete(); } return null; @@ -143,7 +143,7 @@ public static void cacheSkullSkin(String skinHash) throws IOException { ImageIO.write(skullTexture, "png", skinPath.toFile()); SKULL_SKINS.put(skinHash, skinPath); - GeyserLogger.getInstance().debug("Cached player skull to " + skinPath + " for " + skinHash); + GeyserLogger.get().debug("Cached player skull to " + skinPath + " for " + skinHash); } public static void cleanSkullSkinCache() { @@ -162,10 +162,10 @@ public static void cleanSkullSkinCache() { } } if (removeCount != 0) { - GeyserLogger.getInstance().debug("Removed " + removeCount + " unnecessary skull skins."); + GeyserLogger.get().debug("Removed " + removeCount + " unnecessary skull skins."); } } catch (IOException e) { - GeyserLogger.getInstance().debug("Unable to clean up skull skin cache."); + GeyserLogger.get().debug("Unable to clean up skull skin cache."); if (GeyserImpl.getInstance().getConfig().isDebugMode()) { e.printStackTrace(); } @@ -284,7 +284,7 @@ private static Pair generatePackUUIDs() { uuid1 = new UUID(skinHashes.getLong(), skinHashes.getLong()); uuid2 = new UUID(skinHashes.getLong(), skinHashes.getLong()); } catch (NoSuchAlgorithmException e) { - GeyserLogger.getInstance().severe("Unable to get SHA-256 Message Digest instance! Bedrock players will have to re-downloaded the player skull resource pack after each server restart.", e); + GeyserLogger.get().severe("Unable to get SHA-256 Message Digest instance! Bedrock players will have to re-downloaded the player skull resource pack after each server restart.", e); } return Pair.of(uuid1, uuid2); @@ -308,7 +308,7 @@ private static boolean canReusePack(File packFile) { return resourceUUID.isPresent() && uuids.second().equals(resourceUUID.get()); } } catch (IOException e) { - GeyserLogger.getInstance().debug("Cached player skull resource pack was invalid! The pack will be recreated."); + GeyserLogger.get().debug("Cached player skull resource pack was invalid! The pack will be recreated."); } return false; } diff --git a/core/src/main/java/org/geysermc/geyser/pack/path/GeyserPathPackCodec.java b/core/src/main/java/org/geysermc/geyser/pack/path/GeyserPathPackCodec.java index 1c1048a8f72..155f075173c 100644 --- a/core/src/main/java/org/geysermc/geyser/pack/path/GeyserPathPackCodec.java +++ b/core/src/main/java/org/geysermc/geyser/pack/path/GeyserPathPackCodec.java @@ -97,7 +97,7 @@ private void checkLastModified() { } if (lastModified.toInstant().isAfter(this.lastModified.toInstant())) { - GeyserLogger.getInstance().warning("Detected a change in the resource pack " + path + ". This is likely to cause undefined behavior for new clients joining. It is suggested you restart Geyser."); + GeyserLogger.get().warning("Detected a change in the resource pack " + path + ". This is likely to cause undefined behavior for new clients joining. It is suggested you restart Geyser."); this.lastModified = lastModified; this.sha256 = null; this.size = -1; diff --git a/core/src/main/java/org/geysermc/geyser/registry/PacketTranslatorRegistry.java b/core/src/main/java/org/geysermc/geyser/registry/PacketTranslatorRegistry.java index c126efc7d69..2a3706c33aa 100644 --- a/core/src/main/java/org/geysermc/geyser/registry/PacketTranslatorRegistry.java +++ b/core/src/main/java/org/geysermc/geyser/registry/PacketTranslatorRegistry.java @@ -73,7 +73,7 @@ public

boolean translate(Class clazz, P packet, Geyse } else { if (GeyserImpl.getInstance().getConfig().isDebugMode()) { if (!IGNORED_PACKETS.contains(clazz)) { - GeyserLogger.getInstance().debug("Could not find packet for " + (packet.toString().length() > 25 ? packet.getClass().getSimpleName() : packet)); + GeyserLogger.get().debug("Could not find packet for " + (packet.toString().length() > 25 ? packet.getClass().getSimpleName() : packet)); } } @@ -89,7 +89,7 @@ private

void translate0(GeyserSession session, PacketTranslator

try { translator.translate(session, packet); } catch (Throwable ex) { - GeyserLogger.getInstance().error(GeyserLocale.getLocaleStringLog("geyser.network.translator.packet.failed", packet.getClass().getSimpleName()), ex); + GeyserLogger.get().error(GeyserLocale.getLocaleStringLog("geyser.network.translator.packet.failed", packet.getClass().getSimpleName()), ex); ex.printStackTrace(); } } diff --git a/core/src/main/java/org/geysermc/geyser/registry/loader/CollisionRegistryLoader.java b/core/src/main/java/org/geysermc/geyser/registry/loader/CollisionRegistryLoader.java index 205832fb1a6..7d9b12ac956 100644 --- a/core/src/main/java/org/geysermc/geyser/registry/loader/CollisionRegistryLoader.java +++ b/core/src/main/java/org/geysermc/geyser/registry/loader/CollisionRegistryLoader.java @@ -63,7 +63,7 @@ public class CollisionRegistryLoader extends MultiResourceRegistryLoader load(Pair input) { Map, CollisionInfo> annotationMap = new IdentityHashMap<>(); for (Class clazz : FileUtils.getGeneratedClassesForAnnotation(CollisionRemapper.class.getName())) { - GeyserLogger.getInstance().debug("Found annotated collision translator: " + clazz.getCanonicalName()); + GeyserLogger.get().debug("Found annotated collision translator: " + clazz.getCanonicalName()); CollisionRemapper collisionRemapper = clazz.getAnnotation(CollisionRemapper.class); annotationMap.put(clazz, new CollisionInfo(collisionRemapper, Pattern.compile(collisionRemapper.regex()))); @@ -89,7 +89,7 @@ public List load(Pair input) { for (int i = 0; i < blockStates.size(); i++) { BlockState state = blockStates.get(i); if (state == null) { - GeyserLogger.getInstance().warning("Missing block state for Java block " + i); + GeyserLogger.get().warning("Missing block state for Java block " + i); continue; } diff --git a/core/src/main/java/org/geysermc/geyser/registry/loader/ParticleTypesRegistryLoader.java b/core/src/main/java/org/geysermc/geyser/registry/loader/ParticleTypesRegistryLoader.java index e744e013e43..4640ed2afc3 100644 --- a/core/src/main/java/org/geysermc/geyser/registry/loader/ParticleTypesRegistryLoader.java +++ b/core/src/main/java/org/geysermc/geyser/registry/loader/ParticleTypesRegistryLoader.java @@ -55,7 +55,7 @@ public Map load(String input) { JsonNode bedrockId = entry.getValue().get("bedrockId"); JsonNode eventType = entry.getValue().get("eventType"); if (eventType == null && bedrockId == null) { - GeyserLogger.getInstance().debug("Skipping particle mapping " + key + " because no Bedrock equivalent exists."); + GeyserLogger.get().debug("Skipping particle mapping " + key + " because no Bedrock equivalent exists."); continue; } diff --git a/core/src/main/java/org/geysermc/geyser/registry/loader/ResourcePackLoader.java b/core/src/main/java/org/geysermc/geyser/registry/loader/ResourcePackLoader.java index b8bb96c913e..bd7f5df5188 100644 --- a/core/src/main/java/org/geysermc/geyser/registry/loader/ResourcePackLoader.java +++ b/core/src/main/java/org/geysermc/geyser/registry/loader/ResourcePackLoader.java @@ -72,7 +72,7 @@ public Map load(Path directory) { try { Files.createDirectory(directory); } catch (IOException e) { - GeyserLogger.getInstance().error("Could not create packs directory", e); + GeyserLogger.get().error("Could not create packs directory", e); } } @@ -81,7 +81,7 @@ public Map load(Path directory) { resourcePacks = stream.filter(PACK_MATCHER::matches) .collect(Collectors.toCollection(ArrayList::new)); // toList() does not guarantee mutability } catch (Exception e) { - GeyserLogger.getInstance().error("Could not list packs directory", e); + GeyserLogger.get().error("Could not list packs directory", e); // Ensure the event is fired even if there was an issue reading // from our own resource pack directory. External projects may have @@ -129,7 +129,7 @@ public static GeyserResourcePack readPack(Path path) throws IllegalArgumentExcep stream.forEach(x -> { String name = x.getName(); if (SHOW_RESOURCE_PACK_LENGTH_WARNING && name.length() >= 80) { - GeyserLogger.getInstance().warning("The resource pack " + path.getFileName() + GeyserLogger.get().warning("The resource pack " + path.getFileName() + " has a file in it that meets or exceeds 80 characters in its path (" + name + ", " + name.length() + " characters long). This will cause problems on some Bedrock platforms." + " Please rename it to be shorter, or reduce the amount of folders needed to get to the file."); diff --git a/core/src/main/java/org/geysermc/geyser/registry/loader/SoundEventsRegistryLoader.java b/core/src/main/java/org/geysermc/geyser/registry/loader/SoundEventsRegistryLoader.java index 9964e05c5e5..1a272396c79 100644 --- a/core/src/main/java/org/geysermc/geyser/registry/loader/SoundEventsRegistryLoader.java +++ b/core/src/main/java/org/geysermc/geyser/registry/loader/SoundEventsRegistryLoader.java @@ -85,7 +85,7 @@ public Map load(String input) { soundEffects.put(javaEffect, transformer); } } catch (Exception e) { - GeyserLogger.getInstance().warning("Failed to map sound effect " + entry.getKey() + " : " + e); + GeyserLogger.get().warning("Failed to map sound effect " + entry.getKey() + " : " + e); } } return soundEffects; diff --git a/core/src/main/java/org/geysermc/geyser/registry/mappings/MappingsConfigReader.java b/core/src/main/java/org/geysermc/geyser/registry/mappings/MappingsConfigReader.java index 45ba463ba92..cbe9932c65b 100644 --- a/core/src/main/java/org/geysermc/geyser/registry/mappings/MappingsConfigReader.java +++ b/core/src/main/java/org/geysermc/geyser/registry/mappings/MappingsConfigReader.java @@ -67,7 +67,7 @@ public boolean ensureMappingsDirectory(Path mappingsDirectory) { Files.createDirectories(mappingsDirectory); return true; } catch (IOException e) { - GeyserLogger.getInstance().error("Failed to create mappings directory", e); + GeyserLogger.get().error("Failed to create mappings directory", e); return false; } } @@ -101,12 +101,12 @@ public void loadBlockMappingsFromJson(BiConsumer con try { mappingsRoot = GeyserImpl.JSON_MAPPER.readTree(file.toFile()); } catch (IOException e) { - GeyserLogger.getInstance().error("Failed to read custom mapping file: " + file, e); + GeyserLogger.get().error("Failed to read custom mapping file: " + file, e); return null; } if (!mappingsRoot.has("format_version")) { - GeyserLogger.getInstance().error("Mappings file " + file + " is missing the format version field!"); + GeyserLogger.get().error("Mappings file " + file + " is missing the format version field!"); return null; } @@ -116,7 +116,7 @@ public void loadBlockMappingsFromJson(BiConsumer con public int getFormatVersion(JsonNode mappingsRoot, Path file) { int formatVersion = mappingsRoot.get("format_version").asInt(); if (!this.mappingReaders.containsKey(formatVersion)) { - GeyserLogger.getInstance().error("Mappings file " + file + " has an unknown format version: " + formatVersion); + GeyserLogger.get().error("Mappings file " + file + " has an unknown format version: " + formatVersion); return -1; } return formatVersion; diff --git a/core/src/main/java/org/geysermc/geyser/registry/mappings/versions/MappingsReader_v1.java b/core/src/main/java/org/geysermc/geyser/registry/mappings/versions/MappingsReader_v1.java index 55b74d34ab4..5afc327fbec 100644 --- a/core/src/main/java/org/geysermc/geyser/registry/mappings/versions/MappingsReader_v1.java +++ b/core/src/main/java/org/geysermc/geyser/registry/mappings/versions/MappingsReader_v1.java @@ -108,7 +108,7 @@ public void readItemMappingsV1(Path file, JsonNode mappingsRoot, BiConsumer Long.compareUnsigned(fnv164(a.getString("name")), fnv164(b.getString("name")))); @@ -360,7 +360,7 @@ private static void registerBedrockBlocks() { for (Map.Entry entry : nonVanillaStateOverrides.entrySet()) { GeyserBedrockBlock bedrockDefinition = customBlockStateDefinitions.get(entry.getValue()); if (bedrockDefinition == null) { - GeyserLogger.getInstance().warning("Unable to find custom block for " + entry.getValue()); + GeyserLogger.get().warning("Unable to find custom block for " + entry.getValue()); continue; } @@ -462,7 +462,7 @@ public ItemStack pickItem(BlockState state) { if (this.item == null) { this.item = Registries.JAVA_ITEM_IDENTIFIERS.get(pickItem); if (this.item == null) { - GeyserLogger.getInstance().warning("We could not find item " + pickItem + GeyserLogger.get().warning("We could not find item " + pickItem + " for getting the item for block " + javaBlockState.identifier()); this.item = Items.AIR; } diff --git a/core/src/main/java/org/geysermc/geyser/registry/populator/CreativeItemRegistryPopulator.java b/core/src/main/java/org/geysermc/geyser/registry/populator/CreativeItemRegistryPopulator.java index b1b1132fe67..71fa2ed883e 100644 --- a/core/src/main/java/org/geysermc/geyser/registry/populator/CreativeItemRegistryPopulator.java +++ b/core/src/main/java/org/geysermc/geyser/registry/populator/CreativeItemRegistryPopulator.java @@ -135,7 +135,7 @@ static void populate(ItemRegistryPopulator.PaletteVersion palette, Map entry : BLOCK_STATE_OVERRIDES_QUEUE.entrySet()) { int id = BlockRegistries.JAVA_IDENTIFIER_TO_ID.getOrDefault(entry.getKey(), -1); if (id == -1) { - GeyserLogger.getInstance().warning("Custom block state override for Java Identifier: " + + GeyserLogger.get().warning("Custom block state override for Java Identifier: " + entry.getKey() + " could not be registered as it is not a valid block state."); continue; } CustomBlockState oldBlockState = blockStateOverrides.put(id, entry.getValue()); if (oldBlockState != null) { - GeyserLogger.getInstance().warning("Duplicate block state override for Java Identifier: " + + GeyserLogger.get().warning("Duplicate block state override for Java Identifier: " + entry.getKey() + " Old override: " + oldBlockState.name() + " New override: " + entry.getValue().name()); } } @@ -213,17 +213,17 @@ private static void populateVanilla() { BlockRegistries.CUSTOM_BLOCK_STATE_OVERRIDES.set(blockStateOverrides); if (!blockStateOverrides.isEmpty()) { - GeyserLogger.getInstance().info("Registered " + blockStateOverrides.size() + " custom block overrides."); + GeyserLogger.get().info("Registered " + blockStateOverrides.size() + " custom block overrides."); } BlockRegistries.CUSTOM_BLOCK_ITEM_OVERRIDES.set(CUSTOM_BLOCK_ITEM_OVERRIDES); if (!CUSTOM_BLOCK_ITEM_OVERRIDES.isEmpty()) { - GeyserLogger.getInstance().info("Registered " + CUSTOM_BLOCK_ITEM_OVERRIDES.size() + " custom block item overrides."); + GeyserLogger.get().info("Registered " + CUSTOM_BLOCK_ITEM_OVERRIDES.size() + " custom block item overrides."); } BlockRegistries.EXTENDED_COLLISION_BOXES.set(extendedCollisionBoxes); if (!extendedCollisionBoxes.isEmpty()) { - GeyserLogger.getInstance().info("Registered " + extendedCollisionBoxes.size() + " custom block extended collision boxes."); + GeyserLogger.get().info("Registered " + extendedCollisionBoxes.size() + " custom block extended collision boxes."); } } @@ -233,7 +233,7 @@ private static void populateVanilla() { private static void populateNonVanilla() { BlockRegistries.NON_VANILLA_BLOCK_STATE_OVERRIDES.set(NON_VANILLA_BLOCK_STATE_OVERRIDES); if (!NON_VANILLA_BLOCK_STATE_OVERRIDES.isEmpty()) { - GeyserLogger.getInstance().info("Registered " + NON_VANILLA_BLOCK_STATE_OVERRIDES.size() + " non-vanilla block overrides."); + GeyserLogger.get().info("Registered " + NON_VANILLA_BLOCK_STATE_OVERRIDES.size() + " non-vanilla block overrides."); } } @@ -243,7 +243,7 @@ private static void populateNonVanilla() { private static void registration() { BlockRegistries.CUSTOM_BLOCKS.set(CUSTOM_BLOCKS.toArray(new CustomBlockData[0])); if (!CUSTOM_BLOCKS.isEmpty()) { - GeyserLogger.getInstance().info("Registered " + CUSTOM_BLOCKS.size() + " custom blocks."); + GeyserLogger.get().info("Registered " + CUSTOM_BLOCKS.size() + " custom blocks."); } } diff --git a/core/src/main/java/org/geysermc/geyser/registry/populator/CustomItemRegistryPopulator.java b/core/src/main/java/org/geysermc/geyser/registry/populator/CustomItemRegistryPopulator.java index 067bc11d974..1e1f7a54254 100644 --- a/core/src/main/java/org/geysermc/geyser/registry/populator/CustomItemRegistryPopulator.java +++ b/core/src/main/java/org/geysermc/geyser/registry/populator/CustomItemRegistryPopulator.java @@ -80,14 +80,14 @@ public boolean register(@NonNull String identifier, @NonNull CustomItemData cust @Override public boolean register(@NonNull NonVanillaCustomItemData customItemData) { if (customItemData.identifier().startsWith("minecraft:")) { - GeyserLogger.getInstance().error("The custom item " + customItemData.identifier() + + GeyserLogger.get().error("The custom item " + customItemData.identifier() + " is attempting to masquerade as a vanilla Minecraft item!"); return false; } if (customItemData.javaId() < items.size()) { // Attempting to overwrite an item that already exists in the protocol - GeyserLogger.getInstance().error("The custom item " + customItemData.identifier() + + GeyserLogger.get().error("The custom item " + customItemData.identifier() + " is attempting to overwrite a vanilla Minecraft item!"); return false; } @@ -99,7 +99,7 @@ public boolean register(@NonNull NonVanillaCustomItemData customItemData) { int customItemCount = customItems.size() + nonVanillaCustomItems.size(); if (customItemCount > 0) { - GeyserLogger.getInstance().info("Registered " + customItemCount + " custom items"); + GeyserLogger.get().info("Registered " + customItemCount + " custom items"); } } @@ -114,18 +114,18 @@ public static GeyserCustomMappingData registerCustomItem(String customItemName, static boolean initialCheck(String identifier, CustomItemData item, Map mappings) { if (!mappings.containsKey(identifier)) { - GeyserLogger.getInstance().error("Could not find the Java item to add custom item properties to for " + item.name()); + GeyserLogger.get().error("Could not find the Java item to add custom item properties to for " + item.name()); return false; } if (!item.customItemOptions().hasCustomItemOptions()) { - GeyserLogger.getInstance().error("The custom item " + item.name() + " has no registration types"); + GeyserLogger.get().error("The custom item " + item.name() + " has no registration types"); } String name = item.name(); if (name.isEmpty()) { - GeyserLogger.getInstance().warning("Custom item name is empty?"); + GeyserLogger.get().warning("Custom item name is empty?"); } else if (Character.isDigit(name.charAt(0))) { // As of 1.19.31 - GeyserLogger.getInstance().warning("Custom item name (" + name + ") begins with a digit. This may cause issues!"); + GeyserLogger.get().warning("Custom item name (" + name + ") begins with a digit. This may cause issues!"); } return true; } diff --git a/core/src/main/java/org/geysermc/geyser/registry/populator/CustomSkullRegistryPopulator.java b/core/src/main/java/org/geysermc/geyser/registry/populator/CustomSkullRegistryPopulator.java index 735da3ae291..682d708b7c0 100644 --- a/core/src/main/java/org/geysermc/geyser/registry/populator/CustomSkullRegistryPopulator.java +++ b/core/src/main/java/org/geysermc/geyser/registry/populator/CustomSkullRegistryPopulator.java @@ -67,7 +67,7 @@ public static void populate() { File skullConfigFile = FileUtils.fileOrCopiedFromResource(skullConfigPath.toFile(), "custom-skulls.yml", Function.identity(), bootstrap); skullConfig = FileUtils.loadConfig(skullConfigFile, GeyserCustomSkullConfiguration.class); } catch (IOException e) { - GeyserLogger.getInstance().severe(GeyserLocale.getLocaleStringLog("geyser.config.failed"), e); + GeyserLogger.get().severe(GeyserLocale.getLocaleStringLog("geyser.config.failed"), e); return; } @@ -119,7 +119,7 @@ public void register(@NonNull String texture, @NonNull SkullTextureType type) { skinHashes.forEach((skinHash) -> { if (!skinHash.matches("^[a-fA-F0-9]+$")) { - GeyserLogger.getInstance().error("Skin hash " + skinHash + " does not match required format ^[a-fA-F0-9]{64}$ and will not be added as a custom block."); + GeyserLogger.get().error("Skin hash " + skinHash + " does not match required format ^[a-fA-F0-9]{64}$ and will not be added as a custom block."); return; } @@ -127,12 +127,12 @@ public void register(@NonNull String texture, @NonNull SkullTextureType type) { SkullResourcePackManager.cacheSkullSkin(skinHash); BlockRegistries.CUSTOM_SKULLS.register(skinHash, new CustomSkull(skinHash)); } catch (IOException e) { - GeyserLogger.getInstance().error("Failed to cache skin for skull texture " + skinHash + " This skull will not be added as a custom block.", e); + GeyserLogger.get().error("Failed to cache skin for skull texture " + skinHash + " This skull will not be added as a custom block.", e); } }); if (!BlockRegistries.CUSTOM_SKULLS.get().isEmpty()) { - GeyserLogger.getInstance().info("Registered " + BlockRegistries.CUSTOM_SKULLS.get().size() + " custom skulls as custom blocks."); + GeyserLogger.get().info("Registered " + BlockRegistries.CUSTOM_SKULLS.get().size() + " custom skulls as custom blocks."); } } @@ -145,13 +145,13 @@ public void register(@NonNull String texture, @NonNull SkullTextureType type) { try { SkinManager.GameProfileData profileData = SkinManager.GameProfileData.loadFromJson(profile); if (profileData == null) { - GeyserLogger.getInstance().warning("Skull texture " + profile + " contained no skins and will not be added as a custom block."); + GeyserLogger.get().warning("Skull texture " + profile + " contained no skins and will not be added as a custom block."); return null; } String skinUrl = profileData.skinUrl(); return skinUrl.substring(skinUrl.lastIndexOf("/") + 1); } catch (IOException e) { - GeyserLogger.getInstance().error("Skull texture " + profile + " is invalid and will not be added as a custom block.", e); + GeyserLogger.get().error("Skull texture " + profile + " is invalid and will not be added as a custom block.", e); return null; } } @@ -165,7 +165,7 @@ public void register(@NonNull String texture, @NonNull SkullTextureType type) { try { return SkinProvider.requestTexturesFromUsername(username).get(); } catch (InterruptedException | ExecutionException e) { - GeyserLogger.getInstance().error("Unable to request skull textures for " + username + " This skull will not be added as a custom block.", e); + GeyserLogger.get().error("Unable to request skull textures for " + username + " This skull will not be added as a custom block.", e); return null; } } @@ -179,12 +179,12 @@ public void register(@NonNull String texture, @NonNull SkullTextureType type) { try { String uuidDigits = uuid.replace("-", ""); if (uuidDigits.length() != 32) { - GeyserLogger.getInstance().error("Invalid skull uuid " + uuid + " This skull will not be added as a custom block."); + GeyserLogger.get().error("Invalid skull uuid " + uuid + " This skull will not be added as a custom block."); return null; } return SkinProvider.requestTexturesFromUUID(uuid).get(); } catch (InterruptedException | ExecutionException e) { - GeyserLogger.getInstance().error("Unable to request skull textures for " + uuid + " This skull will not be added as a custom block.", e); + GeyserLogger.get().error("Unable to request skull textures for " + uuid + " This skull will not be added as a custom block.", e); return null; } } diff --git a/core/src/main/java/org/geysermc/geyser/registry/populator/ItemRegistryPopulator.java b/core/src/main/java/org/geysermc/geyser/registry/populator/ItemRegistryPopulator.java index d2c496c7873..f561ad33041 100644 --- a/core/src/main/java/org/geysermc/geyser/registry/populator/ItemRegistryPopulator.java +++ b/core/src/main/java/org/geysermc/geyser/registry/populator/ItemRegistryPopulator.java @@ -435,7 +435,7 @@ public static void populate() { // These items don't exist on Bedrock, so set up a variable that indicates they should have custom names // Or, ensure that we are translating these at all times to account for rarity colouring mappingBuilder = mappingBuilder.translationString((javaItem instanceof BlockItem ? "block." : "item.") + entry.getKey().replace(":", ".")); - GeyserLogger.getInstance().debug("Adding " + entry.getKey() + " as an item that needs to be translated."); + GeyserLogger.get().debug("Adding " + entry.getKey() + " as an item that needs to be translated."); } // Add the custom item properties, if applicable @@ -450,7 +450,7 @@ public static void populate() { String customItemName = customItem instanceof NonVanillaCustomItemData nonVanillaItem ? nonVanillaItem.identifier() : Constants.GEYSER_CUSTOM_NAMESPACE + ":" + customItem.name(); if (!registeredItemNames.add(customItemName)) { if (firstMappingsPass) { - GeyserLogger.getInstance().error("Custom item name '" + customItemName + "' already exists and was registered again! Skipping..."); + GeyserLogger.get().error("Custom item name '" + customItemName + "' already exists and was registered again! Skipping..."); } continue; } @@ -536,7 +536,7 @@ public static void populate() { for (NonVanillaCustomItemData customItem : nonVanillaCustomItems) { if (!registeredJavaIds.add(customItem.javaId())) { if (firstMappingsPass) { - GeyserLogger.getInstance().error("Custom item java id " + customItem.javaId() + " already exists and was registered again! Skipping..."); + GeyserLogger.get().error("Custom item java id " + customItem.javaId() + " already exists and was registered again! Skipping..."); } continue; } @@ -569,7 +569,7 @@ public static void populate() { ItemDefinition definition = definitions.get(id); if (definition == null) { // Newer item most likely - GeyserLogger.getInstance().debug( + GeyserLogger.get().debug( "Skipping vanilla component " + id + " for protocol " + palette.protocolVersion() ); continue; diff --git a/core/src/main/java/org/geysermc/geyser/registry/populator/PacketRegistryPopulator.java b/core/src/main/java/org/geysermc/geyser/registry/populator/PacketRegistryPopulator.java index 695b57fa408..47bca5f1dbb 100644 --- a/core/src/main/java/org/geysermc/geyser/registry/populator/PacketRegistryPopulator.java +++ b/core/src/main/java/org/geysermc/geyser/registry/populator/PacketRegistryPopulator.java @@ -40,7 +40,7 @@ public static void populate() { for (Class clazz : FileUtils.getGeneratedClassesForAnnotation(Translator.class)) { Class packet = clazz.getAnnotation(Translator.class).packet(); - GeyserLogger.getInstance().debug("Found annotated translator: " + clazz.getCanonicalName() + " : " + packet.getSimpleName()); + GeyserLogger.get().debug("Found annotated translator: " + clazz.getCanonicalName() + " : " + packet.getSimpleName()); try { if (Packet.class.isAssignableFrom(packet)) { @@ -54,10 +54,10 @@ public static void populate() { Registries.BEDROCK_PACKET_TRANSLATORS.register(targetPacket, translator); } else { - GeyserLogger.getInstance().error("Class " + clazz.getCanonicalName() + " is annotated as a translator but has an invalid target packet."); + GeyserLogger.get().error("Class " + clazz.getCanonicalName() + " is annotated as a translator but has an invalid target packet."); } } catch (Exception e) { - GeyserLogger.getInstance().error("Could not instantiate annotated translator " + clazz.getCanonicalName()); + GeyserLogger.get().error("Could not instantiate annotated translator " + clazz.getCanonicalName()); } } } diff --git a/core/src/main/java/org/geysermc/geyser/registry/type/ItemMappings.java b/core/src/main/java/org/geysermc/geyser/registry/type/ItemMappings.java index fb068e3d86f..66bb6f01574 100644 --- a/core/src/main/java/org/geysermc/geyser/registry/type/ItemMappings.java +++ b/core/src/main/java/org/geysermc/geyser/registry/type/ItemMappings.java @@ -159,7 +159,7 @@ public ItemMapping getMapping(ItemData data) { } } - GeyserLogger.getInstance().debug("Missing mapping for bedrock item " + data); + GeyserLogger.get().debug("Missing mapping for bedrock item " + data); return ItemMapping.AIR; } diff --git a/core/src/main/java/org/geysermc/geyser/scoreboard/Scoreboard.java b/core/src/main/java/org/geysermc/geyser/scoreboard/Scoreboard.java index 0888a74d6cd..0c5fb51188a 100644 --- a/core/src/main/java/org/geysermc/geyser/scoreboard/Scoreboard.java +++ b/core/src/main/java/org/geysermc/geyser/scoreboard/Scoreboard.java @@ -33,7 +33,6 @@ import org.cloudburstmc.protocol.bedrock.packet.RemoveObjectivePacket; import org.cloudburstmc.protocol.bedrock.packet.SetDisplayObjectivePacket; import org.cloudburstmc.protocol.bedrock.packet.SetScorePacket; -import org.geysermc.geyser.GeyserImpl; import org.geysermc.geyser.GeyserLogger; import org.geysermc.geyser.entity.type.Entity; import org.geysermc.geyser.entity.type.player.PlayerEntity; @@ -76,7 +75,7 @@ public final class Scoreboard { public Scoreboard(GeyserSession session) { this.session = session; - this.logger = GeyserLogger.getInstance(); + this.logger = GeyserLogger.get(); } public void removeScoreboard() { diff --git a/core/src/main/java/org/geysermc/geyser/session/GeyserSession.java b/core/src/main/java/org/geysermc/geyser/session/GeyserSession.java index 1d46c86fc40..2d47320e65e 100644 --- a/core/src/main/java/org/geysermc/geyser/session/GeyserSession.java +++ b/core/src/main/java/org/geysermc/geyser/session/GeyserSession.java @@ -1109,9 +1109,9 @@ public void disconnected(DisconnectedEvent event) { } if (cause != null) { if (cause.getMessage() != null) { - GeyserLogger.getInstance().error(cause.getMessage()); + GeyserLogger.get().error(cause.getMessage()); } else { - GeyserLogger.getInstance().error("An exception occurred: ", cause); + GeyserLogger.get().error("An exception occurred: ", cause); } if (geyser.getConfig().isDebugMode()) { cause.printStackTrace(); diff --git a/core/src/main/java/org/geysermc/geyser/session/PendingMicrosoftAuthentication.java b/core/src/main/java/org/geysermc/geyser/session/PendingMicrosoftAuthentication.java index fa7aee3e04a..f204843122c 100644 --- a/core/src/main/java/org/geysermc/geyser/session/PendingMicrosoftAuthentication.java +++ b/core/src/main/java/org/geysermc/geyser/session/PendingMicrosoftAuthentication.java @@ -117,7 +117,7 @@ public void resetRunningFlow() { } public void cleanup() { - GeyserLogger logger = GeyserLogger.getInstance(); + GeyserLogger logger = GeyserLogger.get(); if (logger.isDebug()) { logger.debug("Cleaning up authentication task for " + userKey); } diff --git a/core/src/main/java/org/geysermc/geyser/session/cache/FormCache.java b/core/src/main/java/org/geysermc/geyser/session/cache/FormCache.java index e0475b3a26f..9a99e75037e 100644 --- a/core/src/main/java/org/geysermc/geyser/session/cache/FormCache.java +++ b/core/src/main/java/org/geysermc/geyser/session/cache/FormCache.java @@ -104,7 +104,7 @@ public void handleResponse(ModalFormResponsePacket response) { formDefinitions.definitionFor(form) .handleFormResponse(form, response.getFormData()); } catch (Exception e) { - GeyserLogger.getInstance().error("Error while processing form response!", e); + GeyserLogger.get().error("Error while processing form response!", e); } } } diff --git a/core/src/main/java/org/geysermc/geyser/session/cache/RegistryCache.java b/core/src/main/java/org/geysermc/geyser/session/cache/RegistryCache.java index e298c0472ca..31a18fb4c74 100644 --- a/core/src/main/java/org/geysermc/geyser/session/cache/RegistryCache.java +++ b/core/src/main/java/org/geysermc/geyser/session/cache/RegistryCache.java @@ -141,7 +141,7 @@ public void load(ClientboundRegistryDataPacket packet) { if (reader != null) { reader.accept(this, packet.getEntries()); } else { - GeyserLogger.getInstance().debug("Ignoring registry of type " + packet.getRegistry()); + GeyserLogger.get().debug("Ignoring registry of type " + packet.getRegistry()); } } diff --git a/core/src/main/java/org/geysermc/geyser/session/cache/TagCache.java b/core/src/main/java/org/geysermc/geyser/session/cache/TagCache.java index eefe5ecdafe..cf7c6dd98f2 100644 --- a/core/src/main/java/org/geysermc/geyser/session/cache/TagCache.java +++ b/core/src/main/java/org/geysermc/geyser/session/cache/TagCache.java @@ -28,7 +28,6 @@ import it.unimi.dsi.fastutil.ints.IntArrays; import net.kyori.adventure.key.Key; import org.checkerframework.checker.nullness.qual.Nullable; -import org.geysermc.geyser.GeyserImpl; import org.geysermc.geyser.GeyserLogger; import org.geysermc.geyser.inventory.GeyserItemStack; import org.geysermc.geyser.item.type.Item; @@ -89,7 +88,7 @@ public void loadPacket(GeyserSession session, ClientboundUpdateTagsPacket packet private void loadTags(String type, @Nullable Map packetTags, Map allTags, int[][] localValues) { if (packetTags == null) { Arrays.fill(localValues, IntArrays.EMPTY_ARRAY); - GeyserLogger.getInstance().debug("Not loading " + type + " tags; they do not exist here."); + GeyserLogger.get().debug("Not loading " + type + " tags; they do not exist here."); return; } allTags.forEach((location, tag) -> { @@ -102,7 +101,7 @@ private void loadTags(String type, @Nullable Map } } else { localValues[tag.ordinal()] = IntArrays.EMPTY_ARRAY; - GeyserLogger.getInstance().debug(type + " tag not found from server: " + location); + GeyserLogger.get().debug(type + " tag not found from server: " + location); } }); } diff --git a/core/src/main/java/org/geysermc/geyser/skin/FakeHeadProvider.java b/core/src/main/java/org/geysermc/geyser/skin/FakeHeadProvider.java index 1e0537aba78..a88c0ca202d 100644 --- a/core/src/main/java/org/geysermc/geyser/skin/FakeHeadProvider.java +++ b/core/src/main/java/org/geysermc/geyser/skin/FakeHeadProvider.java @@ -116,7 +116,7 @@ public static void setHead(GeyserSession session, PlayerEntity entity, DataCompo try { textures = profile.getTextures(false); } catch (IllegalStateException e) { - GeyserLogger.getInstance().debug("Could not decode player head from profile %s, got: %s".formatted(profile, e.getMessage())); + GeyserLogger.get().debug("Could not decode player head from profile %s, got: %s".formatted(profile, e.getMessage())); textures = null; } @@ -147,7 +147,7 @@ public static void loadHead(GeyserSession session, PlayerEntity entity, String o CompletableFuture completableFuture = SkinProvider.requestTexturesFromUsername(owner); completableFuture.whenCompleteAsync((encodedJson, throwable) -> { if (throwable != null) { - GeyserLogger.getInstance().error(GeyserLocale.getLocaleStringLog("geyser.skin.fail", entity.getUuid()), throwable); + GeyserLogger.get().error(GeyserLocale.getLocaleStringLog("geyser.skin.fail", entity.getUuid()), throwable); return; } try { @@ -157,7 +157,7 @@ public static void loadHead(GeyserSession session, PlayerEntity entity, String o } loadHead(session, entity, gameProfileData); } catch (IOException e) { - GeyserLogger.getInstance().error(GeyserLocale.getLocaleStringLog("geyser.skin.fail", entity.getUuid(), e.getMessage())); + GeyserLogger.get().error(GeyserLocale.getLocaleStringLog("geyser.skin.fail", entity.getUuid(), e.getMessage())); } }); } @@ -172,7 +172,7 @@ public static void loadHead(GeyserSession session, PlayerEntity entity, SkinMana SkinData mergedSkinData = MERGED_SKINS_LOADING_CACHE.get(new FakeHeadEntry(texturesProperty, fakeHeadSkinUrl, entity, session)); SkinManager.sendSkinPacket(session, entity, mergedSkinData); } catch (ExecutionException e) { - GeyserLogger.getInstance().error("Couldn't merge skin of " + entity.getUsername() + " with head skin url " + fakeHeadSkinUrl, e); + GeyserLogger.get().error("Couldn't merge skin of " + entity.getUsername() + " with head skin url " + fakeHeadSkinUrl, e); } }); } @@ -188,7 +188,7 @@ public static void restoreOriginalSkin(GeyserSession session, LivingEntity livin SkinProvider.requestSkinData(entity, session).whenCompleteAsync((skinData, throwable) -> { if (throwable != null) { - GeyserLogger.getInstance().error(GeyserLocale.getLocaleStringLog("geyser.skin.fail", entity.getUuid()), throwable); + GeyserLogger.get().error(GeyserLocale.getLocaleStringLog("geyser.skin.fail", entity.getUuid()), throwable); return; } diff --git a/core/src/main/java/org/geysermc/geyser/skin/SkinManager.java b/core/src/main/java/org/geysermc/geyser/skin/SkinManager.java index 6bfb6e701c2..7175329b28c 100644 --- a/core/src/main/java/org/geysermc/geyser/skin/SkinManager.java +++ b/core/src/main/java/org/geysermc/geyser/skin/SkinManager.java @@ -246,7 +246,7 @@ public record GameProfileData(String skinUrl, String capeUrl, boolean isAlex) { try { return loadFromJson(skinDataValue); } catch (IOException e) { - GeyserLogger.getInstance().debug("Something went wrong while processing skin for tag " + tag); + GeyserLogger.get().debug("Something went wrong while processing skin for tag " + tag); if (GeyserImpl.getInstance().getConfig().isDebugMode()) { e.printStackTrace(); } @@ -271,9 +271,9 @@ public record GameProfileData(String skinUrl, String capeUrl, boolean isAlex) { return loadFromJson(texturesProperty); } catch (Exception exception) { if (entity instanceof SkullPlayerEntity skullEntity) { - GeyserLogger.getInstance().debug("Something went wrong while processing skin for skull at " + skullEntity.getSkullPosition() + " with Value: " + texturesProperty); + GeyserLogger.get().debug("Something went wrong while processing skin for skull at " + skullEntity.getSkullPosition() + " with Value: " + texturesProperty); } else { - GeyserLogger.getInstance().debug("Something went wrong while processing skin for " + entity.getUsername() + " with Value: " + texturesProperty); + GeyserLogger.get().debug("Something went wrong while processing skin for " + entity.getUsername() + " with Value: " + texturesProperty); } if (GeyserImpl.getInstance().getConfig().isDebugMode()) { exception.printStackTrace(); @@ -287,7 +287,7 @@ public record GameProfileData(String skinUrl, String capeUrl, boolean isAlex) { try { skinObject = GeyserImpl.JSON_MAPPER.readTree(new String(Base64.getDecoder().decode(encodedJson), StandardCharsets.UTF_8)); } catch (IllegalArgumentException e) { - GeyserLogger.getInstance().debug("Invalid base64 encoded skin entry: " + encodedJson); + GeyserLogger.get().debug("Invalid base64 encoded skin entry: " + encodedJson); return null; } diff --git a/core/src/main/java/org/geysermc/geyser/skin/SkinProvider.java b/core/src/main/java/org/geysermc/geyser/skin/SkinProvider.java index 041fe1d53e0..385e8201189 100644 --- a/core/src/main/java/org/geysermc/geyser/skin/SkinProvider.java +++ b/core/src/main/java/org/geysermc/geyser/skin/SkinProvider.java @@ -170,7 +170,7 @@ public static void registerCacheImageTask(GeyserImpl geyser) { } if (count > 0) { - GeyserLogger.getInstance().debug(String.format("Removed %d cached image files as they have expired", count)); + GeyserLogger.get().debug(String.format("Removed %d cached image files as they have expired", count)); } }, 10, 1440, TimeUnit.MINUTES); } @@ -291,7 +291,7 @@ public void geometry(@NonNull SkinGeometry newGeometry) { return eventSkinData.skinData(); } catch (Exception e) { - GeyserLogger.getInstance().error(GeyserLocale.getLocaleStringLog("geyser.skin.fail", entity.getUuid()), e); + GeyserLogger.get().error(GeyserLocale.getLocaleStringLog("geyser.skin.fail", entity.getUuid()), e); } return new SkinData(skinAndCape.skin(), skinAndCape.cape(), null); @@ -307,7 +307,7 @@ private static CompletableFuture requestSkinAndCape(UUID playerId, getOrDefault(requestCape(capeUrl, false), EMPTY_CAPE, 5) ); - GeyserLogger.getInstance().debug("Took " + (System.currentTimeMillis() - time) + "ms for " + playerId); + GeyserLogger.get().debug("Took " + (System.currentTimeMillis() - time) + "ms for " + playerId); return skinAndCape; }, getExecutorService()); } @@ -418,7 +418,7 @@ public static BufferedImage requestImage(String imageUrl, boolean isCape) throws File imageFile = GeyserImpl.getInstance().getBootstrap().getConfigFolder().resolve("cache").resolve("images").resolve(UUID.nameUUIDFromBytes(imageUrl.getBytes()) + ".png").toFile(); if (imageFile.exists()) { try { - GeyserLogger.getInstance().debug("Reading cached image from file " + imageFile.getPath() + " for " + imageUrl); + GeyserLogger.get().debug("Reading cached image from file " + imageFile.getPath() + " for " + imageUrl); imageFile.setLastModified(System.currentTimeMillis()); image = ImageIO.read(imageFile); } catch (IOException ignored) {} @@ -427,16 +427,16 @@ public static BufferedImage requestImage(String imageUrl, boolean isCape) throws // If no image we download it if (image == null) { image = downloadImage(imageUrl); - GeyserLogger.getInstance().debug("Downloaded " + imageUrl); + GeyserLogger.get().debug("Downloaded " + imageUrl); // Write to cache if we are allowed if (GeyserImpl.getInstance().getConfig().getCacheImages() > 0) { imageFile.getParentFile().mkdirs(); try { ImageIO.write(image, "png", imageFile); - GeyserLogger.getInstance().debug("Writing cached skin to file " + imageFile.getPath() + " for " + imageUrl); + GeyserLogger.get().debug("Writing cached skin to file " + imageFile.getPath() + " for " + imageUrl); } catch (IOException e) { - GeyserLogger.getInstance().error("Failed to write cached skin to file " + imageFile.getPath() + " for " + imageUrl); + GeyserLogger.get().error("Failed to write cached skin to file " + imageFile.getPath() + " for " + imageUrl); } } } @@ -493,12 +493,12 @@ private static byte[] requestImageData(String imageUrl, boolean isCape) throws E JsonNode node = WebUtils.getJson("https://sessionserver.mojang.com/session/minecraft/profile/" + uuid); JsonNode properties = node.get("properties"); if (properties == null) { - GeyserLogger.getInstance().debug("No properties found in Mojang response for " + uuid); + GeyserLogger.get().debug("No properties found in Mojang response for " + uuid); return null; } return node.get("properties").get(0).get("value").asText(); } catch (Exception e) { - GeyserLogger.getInstance().debug("Unable to request textures for " + uuid); + GeyserLogger.get().debug("Unable to request textures for " + uuid); if (GeyserImpl.getInstance().getConfig().isDebugMode()) { e.printStackTrace(); } @@ -520,7 +520,7 @@ private static byte[] requestImageData(String imageUrl, boolean isCape) throws E JsonNode node = WebUtils.getJson("https://api.mojang.com/users/profiles/minecraft/" + username); JsonNode id = node.get("id"); if (id == null) { - GeyserLogger.getInstance().debug("No UUID found in Mojang response for " + username); + GeyserLogger.get().debug("No UUID found in Mojang response for " + username); return null; } return id.asText(); diff --git a/core/src/main/java/org/geysermc/geyser/skin/SkullSkinManager.java b/core/src/main/java/org/geysermc/geyser/skin/SkullSkinManager.java index 3c4e136f834..811ad813aca 100644 --- a/core/src/main/java/org/geysermc/geyser/skin/SkullSkinManager.java +++ b/core/src/main/java/org/geysermc/geyser/skin/SkullSkinManager.java @@ -63,7 +63,7 @@ public static void requestAndHandleSkin(SkullPlayerEntity entity, GeyserSession packet.setTrustedSkin(true); session.sendUpstreamPacket(packet); } catch (Exception e) { - GeyserLogger.getInstance().error(GeyserLocale.getLocaleStringLog("geyser.skin.fail", entity.getUuid()), e); + GeyserLogger.get().error(GeyserLocale.getLocaleStringLog("geyser.skin.fail", entity.getUuid()), e); } if (skinConsumer != null) { @@ -73,7 +73,7 @@ public static void requestAndHandleSkin(SkullPlayerEntity entity, GeyserSession GameProfileData data = GameProfileData.from(entity); if (data == null) { - GeyserLogger.getInstance().debug("Using fallback skin for skull at " + entity.getSkullPosition() + + GeyserLogger.get().debug("Using fallback skin for skull at " + entity.getSkullPosition() + " with texture value: " + entity.getTexturesProperty() + " and UUID: " + entity.getSkullUUID()); // No texture available, fallback using the UUID SkinData fallback = SkinProvider.determineFallbackSkinData(entity.getSkullUUID()); diff --git a/core/src/main/java/org/geysermc/geyser/text/MinecraftLocale.java b/core/src/main/java/org/geysermc/geyser/text/MinecraftLocale.java index 50a1e771df8..16367bc1a1f 100644 --- a/core/src/main/java/org/geysermc/geyser/text/MinecraftLocale.java +++ b/core/src/main/java/org/geysermc/geyser/text/MinecraftLocale.java @@ -80,7 +80,7 @@ public static void downloadAndLoadLocale(String locale) { locale = locale.toLowerCase(Locale.ROOT); if (isLocaleLoaded(locale)) { - GeyserLogger.getInstance().debug("Locale already loaded: " + locale); + GeyserLogger.get().debug("Locale already loaded: " + locale); return; } @@ -92,18 +92,18 @@ public static void downloadAndLoadLocale(String locale) { // Check the locale isn't already loaded if (!AssetUtils.isAssetKnown("minecraft/lang/" + locale + ".json") && !locale.equals("en_us")) { if (loadLocale(locale)) { - GeyserLogger.getInstance().debug("Loaded locale locally while not being in asset map: " + locale); + GeyserLogger.get().debug("Loaded locale locally while not being in asset map: " + locale); } else { - GeyserLogger.getInstance().warning(GeyserLocale.getLocaleStringLog("geyser.locale.fail.invalid", locale)); + GeyserLogger.get().warning(GeyserLocale.getLocaleStringLog("geyser.locale.fail.invalid", locale)); } return; } - GeyserLogger.getInstance().debug("Downloading and loading locale: " + locale); + GeyserLogger.get().debug("Downloading and loading locale: " + locale); downloadLocale(locale); if (!loadLocale(locale)) { - GeyserLogger.getInstance().warning(GeyserLocale.getLocaleStringLog("geyser.locale.fail.missing", locale)); + GeyserLogger.get().warning(GeyserLocale.getLocaleStringLog("geyser.locale.fail.missing", locale)); } } @@ -124,9 +124,9 @@ private static void downloadLocale(String locale) { String targetHash = AssetUtils.getAsset("minecraft/lang/" + locale + ".json").getHash(); if (!curHash.equals(targetHash)) { - GeyserLogger.getInstance().debug("Locale out of date; re-downloading: " + locale); + GeyserLogger.get().debug("Locale out of date; re-downloading: " + locale); } else { - GeyserLogger.getInstance().debug("Locale already downloaded and up-to date: " + locale); + GeyserLogger.get().debug("Locale already downloaded and up-to date: " + locale); return; } } @@ -136,7 +136,7 @@ private static void downloadLocale(String locale) { String hash = AssetUtils.getAsset("minecraft/lang/" + locale + ".json").getHash(); WebUtils.downloadFile("https://resources.download.minecraft.net/" + hash.substring(0, 2) + "/" + hash, localeFile.toString()); } catch (Exception e) { - GeyserLogger.getInstance().error("Unable to download locale file hash", e); + GeyserLogger.get().error("Unable to download locale file hash", e); } } @@ -220,7 +220,7 @@ public static String getLocaleString(String messageText, String locale) { localeStrings = LOCALE_MAPPINGS.get(GeyserLocale.getDefaultLocale()); if (localeStrings == null) { // Don't cause a NPE if the locale is STILL missing - GeyserLogger.getInstance().debug("MISSING DEFAULT LOCALE: " + GeyserLocale.getDefaultLocale()); + GeyserLogger.get().debug("MISSING DEFAULT LOCALE: " + GeyserLocale.getDefaultLocale()); return messageText; } } diff --git a/core/src/main/java/org/geysermc/geyser/translator/item/ItemTranslator.java b/core/src/main/java/org/geysermc/geyser/translator/item/ItemTranslator.java index 9ebee236633..89e64e496b4 100644 --- a/core/src/main/java/org/geysermc/geyser/translator/item/ItemTranslator.java +++ b/core/src/main/java/org/geysermc/geyser/translator/item/ItemTranslator.java @@ -498,7 +498,7 @@ private static void translateCustomBlock(CustomBlockData customBlockData, Geyser try { textures = profile.getTextures(false); } catch (IllegalStateException e) { - GeyserLogger.getInstance().debug("Could not decode player head from profile %s, got: %s".formatted(profile, e.getMessage())); + GeyserLogger.get().debug("Could not decode player head from profile %s, got: %s".formatted(profile, e.getMessage())); return null; } diff --git a/core/src/main/java/org/geysermc/geyser/translator/protocol/java/JavaCommandsTranslator.java b/core/src/main/java/org/geysermc/geyser/translator/protocol/java/JavaCommandsTranslator.java index 6a4ff0ab50b..7d92b1e9a8e 100644 --- a/core/src/main/java/org/geysermc/geyser/translator/protocol/java/JavaCommandsTranslator.java +++ b/core/src/main/java/org/geysermc/geyser/translator/protocol/java/JavaCommandsTranslator.java @@ -250,7 +250,7 @@ private static CommandOverloadData[] getParams(GeyserSession session, CommandNod // Check if the command is an alias and redirect it if (commandNode.getRedirectIndex().isPresent()) { int redirectIndex = commandNode.getRedirectIndex().getAsInt(); - GeyserLogger.getInstance().debug("Redirecting command " + commandNode.getName() + " to " + allNodes[redirectIndex].getName()); + GeyserLogger.get().debug("Redirecting command " + commandNode.getName() + " to " + allNodes[redirectIndex].getName()); commandNode = allNodes[redirectIndex]; } diff --git a/core/src/main/java/org/geysermc/geyser/translator/protocol/java/JavaCustomPayloadTranslator.java b/core/src/main/java/org/geysermc/geyser/translator/protocol/java/JavaCustomPayloadTranslator.java index 6c70f8aad15..7e15c257299 100644 --- a/core/src/main/java/org/geysermc/geyser/translator/protocol/java/JavaCustomPayloadTranslator.java +++ b/core/src/main/java/org/geysermc/geyser/translator/protocol/java/JavaCustomPayloadTranslator.java @@ -49,7 +49,7 @@ @Translator(packet = ClientboundCustomPayloadPacket.class) public class JavaCustomPayloadTranslator extends PacketTranslator { - private final GeyserLogger logger = GeyserLogger.getInstance(); + private final GeyserLogger logger = GeyserLogger.get(); @Override public void translate(GeyserSession session, ClientboundCustomPayloadPacket packet) { diff --git a/core/src/main/java/org/geysermc/geyser/translator/protocol/java/JavaUpdateRecipesTranslator.java b/core/src/main/java/org/geysermc/geyser/translator/protocol/java/JavaUpdateRecipesTranslator.java index bdf9219f6ab..8bb9954946c 100644 --- a/core/src/main/java/org/geysermc/geyser/translator/protocol/java/JavaUpdateRecipesTranslator.java +++ b/core/src/main/java/org/geysermc/geyser/translator/protocol/java/JavaUpdateRecipesTranslator.java @@ -154,7 +154,7 @@ public void translate(GeyserSession session, ClientboundUpdateRecipesPacket pack StoneCuttingRecipeData stoneCuttingData = (StoneCuttingRecipeData) recipe.getData(); if (stoneCuttingData.getIngredient().getOptions().length == 0) { if (GeyserImpl.getInstance().getConfig().isDebugMode()) { - GeyserLogger.getInstance().debug("Received broken stone cutter recipe: " + stoneCuttingData + " " + + GeyserLogger.get().debug("Received broken stone cutter recipe: " + stoneCuttingData + " " + recipe.getIdentifier() + " " + Registries.JAVA_ITEMS.get().get(stoneCuttingData.getResult().getId()).javaIdentifier()); } continue; @@ -421,7 +421,7 @@ private ItemDescriptorWithCount getDescriptorFromId(GeyserSession session, Strin if (bedrockDefinition != null) { return ItemDescriptorWithCount.fromItem(ItemData.builder().definition(bedrockDefinition).count(1).build()); } - GeyserLogger.getInstance().debug("Unable to find item with identifier " + bedrockId); + GeyserLogger.get().debug("Unable to find item with identifier " + bedrockId); return ItemDescriptorWithCount.EMPTY; } diff --git a/core/src/main/java/org/geysermc/geyser/translator/protocol/java/entity/player/JavaPlayerInfoUpdateTranslator.java b/core/src/main/java/org/geysermc/geyser/translator/protocol/java/entity/player/JavaPlayerInfoUpdateTranslator.java index 929028b0def..6fb0b482110 100644 --- a/core/src/main/java/org/geysermc/geyser/translator/protocol/java/entity/player/JavaPlayerInfoUpdateTranslator.java +++ b/core/src/main/java/org/geysermc/geyser/translator/protocol/java/entity/player/JavaPlayerInfoUpdateTranslator.java @@ -94,7 +94,7 @@ public void translate(GeyserSession session, ClientboundPlayerInfoUpdatePacket p if (self) { SkinManager.requestAndHandleSkinAndCape(playerEntity, session, skinAndCape -> - GeyserLogger.getInstance().debug("Loaded Local Bedrock Java Skin Data for " + session.getClientData().getUsername())); + GeyserLogger.get().debug("Loaded Local Bedrock Java Skin Data for " + session.getClientData().getUsername())); } else { playerEntity.setValid(true); } diff --git a/core/src/main/java/org/geysermc/geyser/translator/protocol/java/entity/spawn/JavaAddEntityTranslator.java b/core/src/main/java/org/geysermc/geyser/translator/protocol/java/entity/spawn/JavaAddEntityTranslator.java index 41bcde61177..565e34ca693 100644 --- a/core/src/main/java/org/geysermc/geyser/translator/protocol/java/entity/spawn/JavaAddEntityTranslator.java +++ b/core/src/main/java/org/geysermc/geyser/translator/protocol/java/entity/spawn/JavaAddEntityTranslator.java @@ -76,7 +76,7 @@ public void translate(GeyserSession session, ClientboundAddEntityPacket packet) } else { entity = session.getEntityCache().getPlayerEntity(packet.getUuid()); if (entity == null) { - GeyserLogger.getInstance().error(GeyserLocale.getLocaleStringLog("geyser.entity.player.failed_list", packet.getUuid())); + GeyserLogger.get().error(GeyserLocale.getLocaleStringLog("geyser.entity.player.failed_list", packet.getUuid())); return; } diff --git a/core/src/main/java/org/geysermc/geyser/translator/protocol/java/level/JavaLevelEventTranslator.java b/core/src/main/java/org/geysermc/geyser/translator/protocol/java/level/JavaLevelEventTranslator.java index 67bfe416b1e..913f188ed0d 100644 --- a/core/src/main/java/org/geysermc/geyser/translator/protocol/java/level/JavaLevelEventTranslator.java +++ b/core/src/main/java/org/geysermc/geyser/translator/protocol/java/level/JavaLevelEventTranslator.java @@ -449,7 +449,7 @@ public void translate(GeyserSession session, ClientboundLevelEventPacket packet) return; } default -> { - GeyserLogger.getInstance().debug("Unhandled level event: " + packet.getEvent()); + GeyserLogger.get().debug("Unhandled level event: " + packet.getEvent()); return; } } diff --git a/core/src/main/java/org/geysermc/geyser/translator/protocol/java/scoreboard/JavaSetObjectiveTranslator.java b/core/src/main/java/org/geysermc/geyser/translator/protocol/java/scoreboard/JavaSetObjectiveTranslator.java index da2001cac05..80c15ebc213 100644 --- a/core/src/main/java/org/geysermc/geyser/translator/protocol/java/scoreboard/JavaSetObjectiveTranslator.java +++ b/core/src/main/java/org/geysermc/geyser/translator/protocol/java/scoreboard/JavaSetObjectiveTranslator.java @@ -42,7 +42,7 @@ @Translator(packet = ClientboundSetObjectivePacket.class) public class JavaSetObjectiveTranslator extends PacketTranslator { - private final GeyserLogger logger = GeyserLogger.getInstance(); + private final GeyserLogger logger = GeyserLogger.get(); @Override public void translate(GeyserSession session, ClientboundSetObjectivePacket packet) { diff --git a/core/src/main/java/org/geysermc/geyser/translator/protocol/java/scoreboard/JavaSetPlayerTeamTranslator.java b/core/src/main/java/org/geysermc/geyser/translator/protocol/java/scoreboard/JavaSetPlayerTeamTranslator.java index 62915222d7f..003c13bf9d9 100644 --- a/core/src/main/java/org/geysermc/geyser/translator/protocol/java/scoreboard/JavaSetPlayerTeamTranslator.java +++ b/core/src/main/java/org/geysermc/geyser/translator/protocol/java/scoreboard/JavaSetPlayerTeamTranslator.java @@ -44,7 +44,7 @@ @Translator(packet = ClientboundSetPlayerTeamPacket.class) public class JavaSetPlayerTeamTranslator extends PacketTranslator { - private final GeyserLogger logger = GeyserLogger.getInstance(); + private final GeyserLogger logger = GeyserLogger.get(); @Override public void translate(GeyserSession session, ClientboundSetPlayerTeamPacket packet) { diff --git a/core/src/main/java/org/geysermc/geyser/translator/protocol/java/scoreboard/JavaSetScoreTranslator.java b/core/src/main/java/org/geysermc/geyser/translator/protocol/java/scoreboard/JavaSetScoreTranslator.java index 4105b8f4462..8553e76ff0a 100644 --- a/core/src/main/java/org/geysermc/geyser/translator/protocol/java/scoreboard/JavaSetScoreTranslator.java +++ b/core/src/main/java/org/geysermc/geyser/translator/protocol/java/scoreboard/JavaSetScoreTranslator.java @@ -46,7 +46,7 @@ public class JavaSetScoreTranslator extends PacketTranslator generateAssetCache() { VersionInfo versionInfo = GeyserImpl.JSON_MAPPER.readValue(WebUtils.getBody(latestInfoURL), VersionInfo.class); // Get the client jar for use when downloading the en_us locale - GeyserLogger.getInstance().debug(GeyserImpl.JSON_MAPPER.writeValueAsString(versionInfo.getDownloads())); + GeyserLogger.get().debug(GeyserImpl.JSON_MAPPER.writeValueAsString(versionInfo.getDownloads())); CLIENT_JAR_INFO = versionInfo.getDownloads().get("client"); - GeyserLogger.getInstance().debug(GeyserImpl.JSON_MAPPER.writeValueAsString(CLIENT_JAR_INFO)); + GeyserLogger.get().debug(GeyserImpl.JSON_MAPPER.writeValueAsString(CLIENT_JAR_INFO)); // Get the assets list JsonNode assets = GeyserImpl.JSON_MAPPER.readTree(WebUtils.getBody(versionInfo.getAssetIndex().getUrl())).get("objects"); @@ -136,7 +136,7 @@ public static CompletableFuture generateAssetCache() { } } catch (Exception e) { - GeyserLogger.getInstance().error(GeyserLocale.getLocaleStringLog("geyser.locale.fail.asset_cache", (!e.getMessage().isEmpty() ? e.getMessage() : e.getStackTrace()))); + GeyserLogger.get().error(GeyserLocale.getLocaleStringLog("geyser.locale.fail.asset_cache", (!e.getMessage().isEmpty() ? e.getMessage() : e.getStackTrace()))); } return null; }); @@ -145,7 +145,7 @@ public static CompletableFuture generateAssetCache() { public static void downloadAndRunClientJarTasks() { if (CLIENT_JAR_INFO == null) { // Likely failed to download - GeyserLogger.getInstance().debug("Skipping en_US hash check as client jar is null."); + GeyserLogger.get().debug("Skipping en_US hash check as client jar is null."); return; } @@ -172,8 +172,8 @@ public static void downloadAndRunClientJarTasks() { try { // Let the user know we are downloading the JAR - GeyserLogger.getInstance().info(GeyserLocale.getLocaleStringLog("geyser.locale.download.en_us")); - GeyserLogger.getInstance().debug("Download URL: " + CLIENT_JAR_INFO.getUrl()); + GeyserLogger.get().info(GeyserLocale.getLocaleStringLog("geyser.locale.download.en_us")); + GeyserLogger.get().debug("Download URL: " + CLIENT_JAR_INFO.getUrl()); Path tmpFilePath = GeyserImpl.getInstance().getBootstrap().getConfigFolder().resolve("tmp_locale.jar"); WebUtils.downloadFile(CLIENT_JAR_INFO.getUrl(), tmpFilePath.toString()); @@ -197,9 +197,9 @@ public static void downloadAndRunClientJarTasks() { // Delete the nolonger needed client/server jar Files.delete(tmpFilePath); - GeyserLogger.getInstance().info(GeyserLocale.getLocaleStringLog("geyser.locale.download.en_us.done")); + GeyserLogger.get().info(GeyserLocale.getLocaleStringLog("geyser.locale.download.en_us.done")); } catch (Exception e) { - GeyserLogger.getInstance().error(GeyserLocale.getLocaleStringLog("geyser.locale.fail.en_us"), e); + GeyserLogger.get().error(GeyserLocale.getLocaleStringLog("geyser.locale.fail.en_us"), e); } } diff --git a/core/src/main/java/org/geysermc/geyser/util/FileUtils.java b/core/src/main/java/org/geysermc/geyser/util/FileUtils.java index 4766b8a3920..41895900ba3 100644 --- a/core/src/main/java/org/geysermc/geyser/util/FileUtils.java +++ b/core/src/main/java/org/geysermc/geyser/util/FileUtils.java @@ -252,7 +252,7 @@ public static Set> getGeneratedClassesForAnnotation(String input) { try { return Class.forName(className); } catch (ClassNotFoundException ex) { - GeyserLogger.getInstance().error("Failed to find class " + className, ex); + GeyserLogger.get().error("Failed to find class " + className, ex); throw new RuntimeException(ex); } }).collect(Collectors.toSet()); diff --git a/core/src/main/java/org/geysermc/geyser/util/InventoryUtils.java b/core/src/main/java/org/geysermc/geyser/util/InventoryUtils.java index fe7e5283e60..39ed45d69eb 100644 --- a/core/src/main/java/org/geysermc/geyser/util/InventoryUtils.java +++ b/core/src/main/java/org/geysermc/geyser/util/InventoryUtils.java @@ -201,10 +201,10 @@ private static void canStackDebug(GeyserItemStack item1, GeyserItemStack item2) DataComponents components2 = item2.getComponents(); if (components1 != null && components2 != null) { if (components1.hashCode() == components2.hashCode() && !components1.equals(components2)) { - GeyserLogger.getInstance().error("DEBUG: DataComponents hash collision"); - GeyserLogger.getInstance().error("hash: " + components1.hashCode()); - GeyserLogger.getInstance().error("components1: " + components1); - GeyserLogger.getInstance().error("components2: " + components2); + GeyserLogger.get().error("DEBUG: DataComponents hash collision"); + GeyserLogger.get().error("hash: " + components1.hashCode()); + GeyserLogger.get().error("components1: " + components1); + GeyserLogger.get().error("components2: " + components2); } } } @@ -245,7 +245,7 @@ private static ItemDefinition getUnusableSpaceBlockDefinition(int protocolVersio ItemDefinition itemDefinition = mappings.getDefinition(unusableSpaceBlock); if (itemDefinition == null) { - GeyserLogger.getInstance().error("Invalid value " + unusableSpaceBlock + ". Resorting to barrier block."); + GeyserLogger.get().error("Invalid value " + unusableSpaceBlock + ". Resorting to barrier block."); return mappings.getStoredItems().barrier().getBedrockDefinition(); } else { return itemDefinition; diff --git a/core/src/main/java/org/geysermc/geyser/util/MinecraftAuthLogger.java b/core/src/main/java/org/geysermc/geyser/util/MinecraftAuthLogger.java index 51e4bccfc3a..aa2aaceb782 100644 --- a/core/src/main/java/org/geysermc/geyser/util/MinecraftAuthLogger.java +++ b/core/src/main/java/org/geysermc/geyser/util/MinecraftAuthLogger.java @@ -34,16 +34,16 @@ public class MinecraftAuthLogger implements ILogger { @Override public void info(String message) { - GeyserLogger.getInstance().debug(message); + GeyserLogger.get().debug(message); } @Override public void warn(String message) { - GeyserLogger.getInstance().warning(message); + GeyserLogger.get().warning(message); } @Override public void error(String message) { - GeyserLogger.getInstance().error(message); + GeyserLogger.get().error(message); } } diff --git a/core/src/main/java/org/geysermc/geyser/util/NewsHandler.java b/core/src/main/java/org/geysermc/geyser/util/NewsHandler.java index 00bb64af5eb..602a7d411a9 100644 --- a/core/src/main/java/org/geysermc/geyser/util/NewsHandler.java +++ b/core/src/main/java/org/geysermc/geyser/util/NewsHandler.java @@ -47,7 +47,7 @@ public class NewsHandler { private final ScheduledExecutorService executorService = Executors.newScheduledThreadPool(1); - private final GeyserLogger logger = GeyserLogger.getInstance(); + private final GeyserLogger logger = GeyserLogger.get(); private final Gson gson = new Gson(); private final Map activeNewsItems = new HashMap<>(); diff --git a/core/src/main/java/org/geysermc/geyser/util/SoundUtils.java b/core/src/main/java/org/geysermc/geyser/util/SoundUtils.java index 373d3144125..e2e0de5c95b 100644 --- a/core/src/main/java/org/geysermc/geyser/util/SoundUtils.java +++ b/core/src/main/java/org/geysermc/geyser/util/SoundUtils.java @@ -70,7 +70,7 @@ public static String translatePlaySound(String javaIdentifier) { SoundMapping soundMapping = Registries.SOUNDS.get(soundIdentifier); if (soundMapping == null || soundMapping.getPlaysound() == null) { // no mapping - GeyserLogger.getInstance().debug("[PlaySound] Defaulting to sound server gave us for " + javaIdentifier); + GeyserLogger.get().debug("[PlaySound] Defaulting to sound server gave us for " + javaIdentifier); return soundIdentifier; } return soundMapping.getPlaysound(); diff --git a/core/src/main/java/org/geysermc/geyser/util/VersionCheckUtils.java b/core/src/main/java/org/geysermc/geyser/util/VersionCheckUtils.java index a249086b1e2..4ecd6cd47a3 100644 --- a/core/src/main/java/org/geysermc/geyser/util/VersionCheckUtils.java +++ b/core/src/main/java/org/geysermc/geyser/util/VersionCheckUtils.java @@ -33,7 +33,6 @@ import net.kyori.adventure.text.format.TextDecoration; import org.checkerframework.checker.nullness.qual.NonNull; import org.geysermc.geyser.Constants; -import org.geysermc.geyser.GeyserImpl; import org.geysermc.geyser.GeyserLogger; import org.geysermc.geyser.command.GeyserCommandSource; import org.geysermc.geyser.network.GameProtocol; @@ -121,7 +120,7 @@ public static void checkForGeyserUpdate(Supplier recipient) .build(); sender.sendMessage(message); } catch (Exception e) { - GeyserLogger.getInstance().error("Error whilst checking for Geyser update!", e); + GeyserLogger.get().error("Error whilst checking for Geyser update!", e); } }); } diff --git a/core/src/main/java/org/geysermc/geyser/util/WebUtils.java b/core/src/main/java/org/geysermc/geyser/util/WebUtils.java index f17c118dd08..66b887ba13b 100644 --- a/core/src/main/java/org/geysermc/geyser/util/WebUtils.java +++ b/core/src/main/java/org/geysermc/geyser/util/WebUtils.java @@ -224,7 +224,7 @@ public static Stream getLineStream(String reqURL) { return connectionToString(con).lines(); } catch (Exception e) { - GeyserLogger.getInstance().error("Error while trying to get a stream from " + reqURL, e); + GeyserLogger.get().error("Error while trying to get a stream from " + reqURL, e); return Stream.empty(); } }