Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
onebeastchris committed Feb 27, 2025
1 parent b6a07bd commit d9336c4
Show file tree
Hide file tree
Showing 65 changed files with 259 additions and 202 deletions.
10 changes: 3 additions & 7 deletions core/src/main/java/org/geysermc/geyser/GeyserImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -602,7 +602,7 @@ private void startInstance() {
}

if (config.isNotifyOnNewBedrockUpdate()) {
VersionCheckUtils.checkForGeyserUpdate(this::getLogger);
VersionCheckUtils.checkForGeyserUpdate(GeyserLogger::get);
}
}

Expand Down Expand Up @@ -795,7 +795,7 @@ public PlatformType platformType() {

@Override
public @NonNull CommandSource consoleCommandSource() {
return getLogger();
return GeyserLogger.get();
}

public int buildNumber() {
Expand Down Expand Up @@ -828,10 +828,6 @@ public static void start() {
instance.setEnabled(true);
}

public GeyserLogger getLogger() {
return bootstrap.getGeyserLogger();
}

public GeyserConfiguration getConfig() {
return bootstrap.getGeyserConfig();
}
Expand Down Expand Up @@ -874,7 +870,7 @@ private void scheduleAuthChainsWrite() {
.withDefaultPrettyPrinter()
.writeValue(writer, this.savedAuthChains);
} catch (IOException e) {
getLogger().error("Unable to write saved refresh tokens!", e);
GeyserLogger.get().error("Unable to write saved refresh tokens!", e);
}
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
import org.cloudburstmc.protocol.bedrock.data.command.CommandParamData;
import org.cloudburstmc.protocol.bedrock.data.command.CommandPermission;
import org.geysermc.geyser.GeyserImpl;
import org.geysermc.geyser.GeyserLogger;
import org.geysermc.geyser.api.command.Command;
import org.geysermc.geyser.api.event.EventRegistrar;
import org.geysermc.geyser.api.event.lifecycle.GeyserDefineCommandsEvent;
Expand Down Expand Up @@ -236,7 +237,7 @@ protected void register(GeyserCommand command, Map<String, GeyserCommand> comman

command.register(cloud);
commands.put(name, command);
geyser.getLogger().debug(GeyserLocale.getLocaleStringLog("geyser.commands.registered", root + " " + name));
GeyserLogger.get().debug(GeyserLocale.getLocaleStringLog("geyser.commands.registered", root + " " + name));

for (String alias : command.aliases()) {
commands.put(alias, command);
Expand All @@ -249,7 +250,7 @@ protected void register(GeyserCommand command, Map<String, GeyserCommand> comman
TriState existingDefault = permissionDefaults.get(permission);
// Extensions might be using the same permission for two different commands
if (existingDefault != null && existingDefault != defaultValue) {
geyser.getLogger().debug("Overriding permission default %s:%s with %s".formatted(permission, existingDefault, defaultValue));
GeyserLogger.get().debug("Overriding permission default %s:%s with %s".formatted(permission, existingDefault, defaultValue));
}

permissionDefaults.put(permission, defaultValue);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ public void execute(CommandContext<GeyserCommandSource> context) {
sendLinks(source);
} catch (Exception e) {
source.sendMessage("An error occurred while trying to check your connection! Check the console for more information.");
geyser.getLogger().error("Error while trying to check your connection!", e);
GeyserLogger.get().error("Error while trying to check your connection!", e);
}
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
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;
Expand Down Expand Up @@ -125,7 +126,7 @@ public void execute(CommandContext<GeyserCommandSource> context) {
}
} catch (IOException e) {
source.sendMessage(ChatColor.RED + GeyserLocale.getPlayerLocaleString("geyser.commands.dump.collect_error", source.locale()));
geyser.getLogger().error(GeyserLocale.getLocaleStringLog("geyser.commands.dump.collect_error_short"), e);
GeyserLogger.get().error(GeyserLocale.getLocaleStringLog("geyser.commands.dump.collect_error_short"), e);
return;
}

Expand All @@ -140,7 +141,7 @@ public void execute(CommandContext<GeyserCommandSource> context) {
outputStream.close();
} catch (IOException e) {
source.sendMessage(ChatColor.RED + GeyserLocale.getPlayerLocaleString("geyser.commands.dump.write_error", source.locale()));
geyser.getLogger().error(GeyserLocale.getLocaleStringLog("geyser.commands.dump.write_error_short"), e);
GeyserLogger.get().error(GeyserLocale.getLocaleStringLog("geyser.commands.dump.write_error_short"), e);
return;
}

Expand All @@ -155,7 +156,7 @@ public void execute(CommandContext<GeyserCommandSource> context) {
responseNode = MAPPER.readTree(response);
} catch (IOException e) {
source.sendMessage(ChatColor.RED + GeyserLocale.getPlayerLocaleString("geyser.commands.dump.upload_error", source.locale()));
geyser.getLogger().error(GeyserLocale.getLocaleStringLog("geyser.commands.dump.upload_error_short"), e);
GeyserLogger.get().error(GeyserLocale.getLocaleStringLog("geyser.commands.dump.upload_error_short"), e);
return;
}

Expand All @@ -169,7 +170,7 @@ public void execute(CommandContext<GeyserCommandSource> context) {

source.sendMessage(GeyserLocale.getPlayerLocaleString("geyser.commands.dump.message", source.locale()) + " " + ChatColor.DARK_AQUA + uploadedDumpUrl);
if (!source.isConsole()) {
geyser.getLogger().info(GeyserLocale.getLocaleStringLog("geyser.commands.dump.created", source.name(), uploadedDumpUrl));
GeyserLogger.get().info(GeyserLocale.getLocaleStringLog("geyser.commands.dump.created", source.name(), uploadedDumpUrl));
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
import org.cloudburstmc.protocol.bedrock.packet.MoveEntityDeltaPacket;
import org.cloudburstmc.protocol.bedrock.packet.RemoveEntityPacket;
import org.cloudburstmc.protocol.bedrock.packet.SetEntityDataPacket;
import org.geysermc.geyser.GeyserLogger;
import org.geysermc.geyser.api.entity.type.GeyserEntity;
import org.geysermc.geyser.entity.EntityDefinition;
import org.geysermc.geyser.entity.GeyserDirtyMetadata;
Expand Down Expand Up @@ -207,7 +208,7 @@ public void spawnEntity() {
if (session.getGeyser().getConfig().isDebugMode() && PRINT_ENTITY_SPAWN_DEBUG) {
EntityType type = definition.entityType();
String name = type != null ? type.name() : getClass().getSimpleName();
session.getGeyser().getLogger().debug("Spawned entity " + name + " at location " + position + " with id " + geyserId + " (java id " + entityId + ")");
GeyserLogger.get().debug("Spawned entity " + name + " at location " + position + " with id " + geyserId + " (java id " + entityId + ")");
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
import org.cloudburstmc.protocol.bedrock.data.inventory.ItemData;
import org.cloudburstmc.protocol.bedrock.packet.BlockEntityDataPacket;
import org.cloudburstmc.protocol.bedrock.packet.UpdateBlockPacket;
import org.geysermc.geyser.GeyserLogger;
import org.geysermc.geyser.entity.EntityDefinition;
import org.geysermc.geyser.session.GeyserSession;
import org.geysermc.geyser.translator.item.ItemTranslator;
Expand Down Expand Up @@ -105,7 +106,7 @@ protected void initializeMetadata() {
@Override
public void spawnEntity() {
updateBlock(true);
session.getGeyser().getLogger().debug("Spawned item frame at location " + bedrockPosition + " with java id " + entityId);
GeyserLogger.get().debug("Spawned item frame at location " + bedrockPosition + " with java id " + entityId);
valid = true;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@

import org.cloudburstmc.math.vector.Vector3f;
import org.cloudburstmc.protocol.bedrock.packet.AddPaintingPacket;
import org.geysermc.geyser.GeyserLogger;
import org.geysermc.geyser.entity.EntityDefinition;
import org.geysermc.geyser.level.PaintingType;
import org.geysermc.geyser.session.GeyserSession;
Expand Down Expand Up @@ -76,7 +77,7 @@ public void setPaintingType(ObjectEntityMetadata<Holder<PaintingVariant>> entity

valid = true;

session.getGeyser().getLogger().debug("Spawned painting on " + position);
GeyserLogger.get().debug("Spawned painting on " + position);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,16 @@
package org.geysermc.geyser.erosion;

import org.checkerframework.checker.nullness.qual.Nullable;
import org.geysermc.erosion.packet.geyserbound.*;
import org.geysermc.erosion.packet.geyserbound.GeyserboundBatchBlockIdPacket;
import org.geysermc.erosion.packet.geyserbound.GeyserboundBlockEntityPacket;
import org.geysermc.erosion.packet.geyserbound.GeyserboundBlockIdPacket;
import org.geysermc.erosion.packet.geyserbound.GeyserboundBlockLookupFailPacket;
import org.geysermc.erosion.packet.geyserbound.GeyserboundBlockPlacePacket;
import org.geysermc.erosion.packet.geyserbound.GeyserboundPacket;
import org.geysermc.erosion.packet.geyserbound.GeyserboundPacketHandler;
import org.geysermc.erosion.packet.geyserbound.GeyserboundPickBlockPacket;
import org.geysermc.erosion.packet.geyserbound.GeyserboundPistonEventPacket;
import org.geysermc.geyser.GeyserLogger;
import org.geysermc.geyser.session.GeyserSession;

public abstract class AbstractGeyserboundPacketHandler implements GeyserboundPacketHandler {
Expand Down Expand Up @@ -83,6 +92,6 @@ public void close() {
}

protected final void illegalPacket(GeyserboundPacket packet) {
session.getGeyser().getLogger().warning("Illegal packet sent from backend server! " + packet);
GeyserLogger.get().warning("Illegal packet sent from backend server! " + packet);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,15 @@
import org.geysermc.erosion.packet.ErosionPacketSender;
import org.geysermc.erosion.packet.backendbound.BackendboundInitializePacket;
import org.geysermc.erosion.packet.backendbound.BackendboundPacket;
import org.geysermc.erosion.packet.geyserbound.*;
import org.geysermc.erosion.packet.geyserbound.GeyserboundBatchBlockIdPacket;
import org.geysermc.erosion.packet.geyserbound.GeyserboundBlockEntityPacket;
import org.geysermc.erosion.packet.geyserbound.GeyserboundBlockIdPacket;
import org.geysermc.erosion.packet.geyserbound.GeyserboundBlockLookupFailPacket;
import org.geysermc.erosion.packet.geyserbound.GeyserboundBlockPlacePacket;
import org.geysermc.erosion.packet.geyserbound.GeyserboundHandshakePacket;
import org.geysermc.erosion.packet.geyserbound.GeyserboundPickBlockPacket;
import org.geysermc.erosion.packet.geyserbound.GeyserboundPistonEventPacket;
import org.geysermc.geyser.GeyserLogger;
import org.geysermc.geyser.level.block.BlockStateValues;
import org.geysermc.geyser.level.block.property.Properties;
import org.geysermc.geyser.level.block.type.Block;
Expand Down Expand Up @@ -81,7 +89,7 @@ public void handleBatchBlockId(GeyserboundBatchBlockIdPacket packet) {
if (this.pendingBatchLookup != null) {
this.pendingBatchLookup.complete(packet.getBlocks());
} else {
session.getGeyser().getLogger().warning("Batch block ID packet received with no future to complete.");
GeyserLogger.get().warning("Batch block ID packet received with no future to complete.");
}
}

Expand All @@ -104,7 +112,7 @@ public void handleBlockId(GeyserboundBlockIdPacket packet) {
future.complete(packet.getBlockId());
return;
}
session.getGeyser().getLogger().warning("Block ID packet received with no future to complete.");
GeyserLogger.get().warning("Block ID packet received with no future to complete.");
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,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.get(), description.id());
return new GeyserExtensionContainer(extension, dataFolder, description, this, logger, eventBus);
}

Expand Down Expand Up @@ -159,7 +159,7 @@ void setClass(String name, final Class<?> clazz) {

@Override
protected void loadAllExtensions(@NonNull ExtensionManager extensionManager) {
GeyserLogger logger = GeyserImpl.getInstance().getLogger();
GeyserLogger logger = GeyserLogger.get();
try {
if (Files.notExists(extensionsDirectory)) {
Files.createDirectory(extensionsDirectory);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
import org.checkerframework.checker.nullness.qual.NonNull;
import org.checkerframework.checker.nullness.qual.Nullable;
import org.cloudburstmc.protocol.bedrock.data.inventory.ItemData;
import org.geysermc.geyser.GeyserImpl;
import org.geysermc.geyser.GeyserLogger;
import org.geysermc.geyser.item.Items;
import org.geysermc.geyser.item.type.Item;
import org.geysermc.geyser.registry.Registries;
Expand Down Expand Up @@ -103,7 +103,7 @@ private GeyserItemStack(int javaId, int amount, DataComponents components, int n
if (slotDisplay instanceof ItemStackSlotDisplay itemStackSlotDisplay) {
return GeyserItemStack.from(itemStackSlotDisplay.itemStack());
}
GeyserImpl.getInstance().getLogger().warning("Unsure how to convert to ItemStack: " + slotDisplay);
GeyserLogger.get().warning("Unsure how to convert to ItemStack: " + slotDisplay);
return GeyserItemStack.EMPTY;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ public GeyserItemStack getItem(int slot) {

public void setItem(int slot, @NonNull GeyserItemStack newItem, GeyserSession session) {
if (slot > this.size) {
session.getGeyser().getLogger().debug("Tried to set an item out of bounds! " + this);
GeyserLogger.get().debug("Tried to set an item out of bounds! " + this);
return;
}
GeyserItemStack oldItem = items[slot];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
import it.unimi.dsi.fastutil.ints.IntOpenHashSet;
import it.unimi.dsi.fastutil.ints.IntSet;
import org.geysermc.geyser.GeyserLogger;
import org.geysermc.geyser.inventory.GeyserItemStack;
import org.geysermc.geyser.inventory.Inventory;
import org.geysermc.geyser.inventory.SlotType;
Expand Down Expand Up @@ -454,7 +455,7 @@ private int stateIdHack(ClickAction action) {
stateIdIncrements = 1;
} else {
if (session.getGeyser().getConfig().isDebugMode()) {
session.getGeyser().getLogger().debug("Not sure how to handle state ID hack in crafting table: " + plan);
GeyserLogger.get().debug("Not sure how to handle state ID hack in crafting table: " + plan);
}
stateIdIncrements = 1;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws E
.findFirst()
.orElse(cause);

GeyserLogger logger = GeyserImpl.getInstance().getLogger();
GeyserLogger logger = GeyserLogger.get();

if (!(rootCause instanceof IllegalArgumentException)) {
// Kick users that cause exceptions
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,18 +25,19 @@

package org.geysermc.geyser.registry;

import org.cloudburstmc.protocol.bedrock.packet.ServerboundDiagnosticsPacket;
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.cloudburstmc.protocol.bedrock.packet.ServerboundDiagnosticsPacket;
import org.geysermc.geyser.GeyserImpl;
import org.geysermc.geyser.GeyserLogger;
import org.geysermc.geyser.erosion.ErosionCancellationException;
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;
Expand Down Expand Up @@ -75,7 +76,7 @@ public <P extends T> boolean translate(Class<? extends P> 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.get().debug("Could not find packet for " + (packet.toString().length() > 25 ? packet.getClass().getSimpleName() : packet));
}
}

Expand All @@ -91,9 +92,9 @@ private <P extends T> void translate0(GeyserSession session, PacketTranslator<P>
try {
translator.translate(session, packet);
} catch (ErosionCancellationException ex) {
GeyserImpl.getInstance().getLogger().debug("Caught ErosionCancellationException");
GeyserLogger.get().debug("Caught ErosionCancellationException");
} catch (Throwable ex) {
GeyserImpl.getInstance().getLogger().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();
}
}
Expand Down
Loading

0 comments on commit d9336c4

Please sign in to comment.