boolean translate(Class extends P> clazz, P packet, GeyserSession session) {
+ public boolean translate(Class extends P> clazz, P packet, GeyserSessionImpl session) {
if (session.getUpstream().isClosed() || session.isClosed()) {
return false;
}
@@ -77,7 +77,7 @@ public class PacketTranslatorRegistry extends AbstractMappedRegistry void translate0(GeyserSession session, PacketTranslator translator, P packet) {
+ private
void translate0(GeyserSessionImpl session, PacketTranslator
translator, P packet) {
if (session.isClosed()) {
return;
}
diff --git a/core/src/main/java/org/geysermc/geyser/registry/type/ParticleMapping.java b/core/src/main/java/org/geysermc/geyser/registry/type/ParticleMapping.java
index cd5ad17ce..7cdb85838 100644
--- a/core/src/main/java/org/geysermc/geyser/registry/type/ParticleMapping.java
+++ b/core/src/main/java/org/geysermc/geyser/registry/type/ParticleMapping.java
@@ -26,14 +26,14 @@
package org.geysermc.geyser.registry.type;
import com.nukkitx.protocol.bedrock.data.LevelEventType;
-import org.geysermc.geyser.session.GeyserSession;
+import org.geysermc.geyser.session.GeyserSessionImpl;
import javax.annotation.ParametersAreNullableByDefault;
@ParametersAreNullableByDefault
public record ParticleMapping(LevelEventType levelEventType, String identifier) {
- public int getParticleId(GeyserSession session) {
+ public int getParticleId(GeyserSessionImpl session) {
if (this.levelEventType == null) {
return -1;
}
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 3dc416c6c..be7ca3c84 100644
--- a/core/src/main/java/org/geysermc/geyser/scoreboard/Scoreboard.java
+++ b/core/src/main/java/org/geysermc/geyser/scoreboard/Scoreboard.java
@@ -32,10 +32,10 @@ import com.nukkitx.protocol.bedrock.packet.SetDisplayObjectivePacket;
import com.nukkitx.protocol.bedrock.packet.SetScorePacket;
import lombok.Getter;
import org.geysermc.geyser.GeyserImpl;
-import org.geysermc.geyser.api.logger.GeyserLogger;
+import org.geysermc.geyser.GeyserLogger;
import org.geysermc.geyser.entity.type.Entity;
import org.geysermc.geyser.entity.type.player.PlayerEntity;
-import org.geysermc.geyser.session.GeyserSession;
+import org.geysermc.geyser.session.GeyserSessionImpl;
import org.geysermc.geyser.text.GeyserLocale;
import javax.annotation.Nullable;
@@ -46,7 +46,7 @@ import java.util.concurrent.atomic.AtomicLong;
import static org.geysermc.geyser.scoreboard.UpdateType.*;
public final class Scoreboard {
- private final GeyserSession session;
+ private final GeyserSessionImpl session;
private final GeyserLogger logger;
@Getter
private final AtomicLong nextId = new AtomicLong(0);
@@ -59,7 +59,7 @@ public final class Scoreboard {
private int lastAddScoreCount = 0;
private int lastRemoveScoreCount = 0;
- public Scoreboard(GeyserSession session) {
+ public Scoreboard(GeyserSessionImpl session) {
this.session = session;
this.logger = GeyserImpl.getInstance().getLogger();
}
diff --git a/core/src/main/java/org/geysermc/geyser/scoreboard/ScoreboardUpdater.java b/core/src/main/java/org/geysermc/geyser/scoreboard/ScoreboardUpdater.java
index 2f817a918..4f4cd8601 100644
--- a/core/src/main/java/org/geysermc/geyser/scoreboard/ScoreboardUpdater.java
+++ b/core/src/main/java/org/geysermc/geyser/scoreboard/ScoreboardUpdater.java
@@ -29,7 +29,7 @@ import lombok.Getter;
import lombok.RequiredArgsConstructor;
import org.geysermc.geyser.GeyserImpl;
import org.geysermc.geyser.configuration.GeyserConfiguration;
-import org.geysermc.geyser.session.GeyserSession;
+import org.geysermc.geyser.session.GeyserSessionImpl;
import org.geysermc.geyser.session.cache.WorldCache;
import org.geysermc.geyser.text.GeyserLocale;
@@ -73,10 +73,10 @@ public final class ScoreboardUpdater extends Thread {
long currentTime = System.currentTimeMillis();
// reset score-packets per second every second
- Collection sessions = geyser.getSessionManager().getSessions().values();
+ Collection sessions = geyser.getSessionManager().getSessions().values();
if (currentTime - lastPacketsPerSecondUpdate >= 1000) {
lastPacketsPerSecondUpdate = currentTime;
- for (GeyserSession session : sessions) {
+ for (GeyserSessionImpl session : sessions) {
ScoreboardSession scoreboardSession = session.getWorldCache().getScoreboardSession();
int oldPps = scoreboardSession.getPacketsPerSecond();
@@ -96,7 +96,7 @@ public final class ScoreboardUpdater extends Thread {
if (currentTime - lastUpdate >= FIRST_MILLIS_BETWEEN_UPDATES) {
lastUpdate = currentTime;
- for (GeyserSession session : sessions) {
+ for (GeyserSessionImpl session : sessions) {
WorldCache worldCache = session.getWorldCache();
ScoreboardSession scoreboardSession = worldCache.getScoreboardSession();
@@ -118,7 +118,7 @@ public final class ScoreboardUpdater extends Thread {
FIRST_SCORE_PACKETS_PER_SECOND_THRESHOLD;
geyser.getLogger().info(
- GeyserLocale.getLocaleStringLog("geyser.scoreboard.updater.threshold_reached.log", session.getName(), threshold, pps) +
+ GeyserLocale.getLocaleStringLog("geyser.scoreboard.updater.threshold_reached.log", session.name(), threshold, pps) +
GeyserLocale.getLocaleStringLog("geyser.scoreboard.updater.threshold_reached", (millisBetweenUpdates / 1000.0))
);
@@ -172,7 +172,7 @@ public final class ScoreboardUpdater extends Thread {
@RequiredArgsConstructor
@Getter
public static final class ScoreboardSession {
- private final GeyserSession session;
+ private final GeyserSessionImpl session;
private final AtomicInteger pendingPacketsPerSecond = new AtomicInteger(0);
private int packetsPerSecond;
private long lastUpdate;
diff --git a/core/src/main/java/org/geysermc/geyser/session/GeyserSession.java b/core/src/main/java/org/geysermc/geyser/session/GeyserSessionImpl.java
similarity index 97%
rename from core/src/main/java/org/geysermc/geyser/session/GeyserSession.java
rename to core/src/main/java/org/geysermc/geyser/session/GeyserSessionImpl.java
index cf5f5c6af..7a93a2653 100644
--- a/core/src/main/java/org/geysermc/geyser/session/GeyserSession.java
+++ b/core/src/main/java/org/geysermc/geyser/session/GeyserSessionImpl.java
@@ -76,6 +76,7 @@ import lombok.Setter;
import org.geysermc.common.PlatformType;
import org.geysermc.geyser.Constants;
import org.geysermc.geyser.GeyserImpl;
+import org.geysermc.geyser.api.session.GeyserSession;
import org.geysermc.geyser.command.CommandSender;
import org.geysermc.geyser.entity.InteractiveTagManager;
import org.geysermc.geyser.session.auth.AuthType;
@@ -120,7 +121,7 @@ import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger;
@Getter
-public class GeyserSession implements CommandSender {
+public class GeyserSessionImpl implements GeyserSession, CommandSender {
private final GeyserImpl geyser;
private final UpstreamSession upstream;
@@ -226,7 +227,7 @@ public class GeyserSession implements CommandSender {
/**
* Stores a list of all lectern locations and their block entity tags.
- * See {@link WorldManager#getLecternDataAt(GeyserSession, int, int, int, boolean)}
+ * See {@link WorldManager#getLecternDataAt(GeyserSessionImpl, int, int, int, boolean)}
* for more information.
*/
private final Set lecternCache;
@@ -458,7 +459,7 @@ public class GeyserSession implements CommandSender {
private MinecraftProtocol protocol;
- public GeyserSession(GeyserImpl geyser, BedrockServerSession bedrockServerSession, EventLoop eventLoop) {
+ public GeyserSessionImpl(GeyserImpl geyser, BedrockServerSession bedrockServerSession, EventLoop eventLoop) {
this.geyser = geyser;
this.upstream = new UpstreamSession(bedrockServerSession);
this.eventLoop = eventLoop;
@@ -579,7 +580,7 @@ public class GeyserSession implements CommandSender {
} else {
geyser.getLogger().info(GeyserLocale.getLocaleStringLog("geyser.auth.login.floodgate"));
}
- authenticate(authData.getName());
+ authenticate(authData.name());
}
}
@@ -658,7 +659,7 @@ public class GeyserSession implements CommandSender {
*/
public void authenticateWithMicrosoftCode() {
if (loggedIn) {
- geyser.getLogger().severe(GeyserLocale.getLocaleStringLog("geyser.auth.already_loggedin", getAuthData().getName()));
+ geyser.getLogger().severe(GeyserLocale.getLocaleStringLog("geyser.auth.already_loggedin", getAuthData().name()));
return;
}
@@ -771,8 +772,8 @@ public class GeyserSession implements CommandSender {
encryptedData = cipher.encryptFromString(BedrockData.of(
clientData.getGameVersion(),
- authData.getName(),
- authData.getXuid(),
+ authData.name(),
+ authData.xuid(),
clientData.getDeviceOs().ordinal(),
clientData.getLanguageCode(),
clientData.getUiProfile().ordinal(),
@@ -822,18 +823,18 @@ public class GeyserSession implements CommandSender {
if (downstream instanceof LocalSession) {
// Connected directly to the server
geyser.getLogger().info(GeyserLocale.getLocaleStringLog("geyser.network.remote.connect_internal",
- authData.getName(), protocol.getProfile().getName()));
+ authData.name(), protocol.getProfile().getName()));
} else {
// Connected to an IP address
geyser.getLogger().info(GeyserLocale.getLocaleStringLog("geyser.network.remote.connect",
- authData.getName(), protocol.getProfile().getName(), remoteAddress));
+ authData.name(), protocol.getProfile().getName(), remoteAddress));
}
UUID uuid = protocol.getProfile().getId();
if (uuid == null) {
// Set what our UUID *probably* is going to be
if (remoteAuthType == AuthType.FLOODGATE) {
- uuid = new UUID(0, Long.parseLong(authData.getXuid()));
+ uuid = new UUID(0, Long.parseLong(authData.xuid()));
} else {
uuid = UUID.nameUUIDFromBytes(("OfflinePlayer:" + protocol.getProfile().getName()).getBytes(StandardCharsets.UTF_8));
}
@@ -887,9 +888,9 @@ public class GeyserSession implements CommandSender {
}
if (downstream instanceof LocalSession) {
- geyser.getLogger().info(GeyserLocale.getLocaleStringLog("geyser.network.remote.disconnect_internal", authData.getName(), disconnectMessage));
+ geyser.getLogger().info(GeyserLocale.getLocaleStringLog("geyser.network.remote.disconnect_internal", authData.name(), disconnectMessage));
} else {
- geyser.getLogger().info(GeyserLocale.getLocaleStringLog("geyser.network.remote.disconnect", authData.getName(), remoteAddress, disconnectMessage));
+ geyser.getLogger().info(GeyserLocale.getLocaleStringLog("geyser.network.remote.disconnect", authData.name(), remoteAddress, disconnectMessage));
}
if (cause != null) {
cause.printStackTrace();
@@ -901,7 +902,7 @@ public class GeyserSession implements CommandSender {
@Override
public void packetReceived(PacketReceivedEvent event) {
Packet packet = event.getPacket();
- Registries.JAVA_PACKET_TRANSLATORS.translate(packet.getClass(), packet, GeyserSession.this);
+ Registries.JAVA_PACKET_TRANSLATORS.translate(packet.getClass(), packet, GeyserSessionImpl.this);
}
@Override
@@ -951,7 +952,7 @@ public class GeyserSession implements CommandSender {
try {
runnable.run();
} catch (Throwable e) {
- geyser.getLogger().error("Error thrown in " + getName() + "'s event loop!", e);
+ geyser.getLogger().error("Error thrown in " + this.name() + "'s event loop!", e);
}
});
}
@@ -964,7 +965,7 @@ public class GeyserSession implements CommandSender {
try {
runnable.run();
} catch (Throwable e) {
- geyser.getLogger().error("Error thrown in " + getName() + "'s event loop!", e);
+ geyser.getLogger().error("Error thrown in " + this.name() + "'s event loop!", e);
}
}, duration, timeUnit);
}
@@ -1104,8 +1105,18 @@ public class GeyserSession implements CommandSender {
}
@Override
- public String getName() {
- return authData.getName();
+ public String name() {
+ return authData.name();
+ }
+
+ @Override
+ public UUID uuid() {
+ return authData.uuid();
+ }
+
+ @Override
+ public String xuid() {
+ return authData.xuid();
}
@Override
@@ -1452,7 +1463,7 @@ public class GeyserSession implements CommandSender {
public void refreshEmotes(List emotes) {
this.emotes.addAll(emotes);
- for (GeyserSession player : geyser.getSessionManager().getSessions().values()) {
+ for (GeyserSessionImpl player : geyser.getSessionManager().getSessions().values()) {
List pieces = new ArrayList<>();
for (UUID piece : emotes) {
if (!player.getEmotes().contains(piece)) {
diff --git a/core/src/main/java/org/geysermc/geyser/session/SessionManager.java b/core/src/main/java/org/geysermc/geyser/session/SessionManager.java
index c5f30d3b2..e70015b81 100644
--- a/core/src/main/java/org/geysermc/geyser/session/SessionManager.java
+++ b/core/src/main/java/org/geysermc/geyser/session/SessionManager.java
@@ -28,7 +28,6 @@ package org.geysermc.geyser.session;
import com.google.common.collect.ImmutableList;
import lombok.AccessLevel;
import lombok.Getter;
-import org.geysermc.geyser.session.GeyserSession;
import org.geysermc.geyser.text.GeyserLocale;
import java.util.*;
@@ -39,29 +38,29 @@ public final class SessionManager {
* A list of all players who don't currently have a permanent UUID attached yet.
*/
@Getter(AccessLevel.PACKAGE)
- private final Set pendingSessions = ConcurrentHashMap.newKeySet();
+ private final Set pendingSessions = ConcurrentHashMap.newKeySet();
/**
* A list of all players who are currently in-game.
*/
@Getter
- private final Map sessions = new ConcurrentHashMap<>();
+ private final Map sessions = new ConcurrentHashMap<>();
/**
* Called once the player has successfully authenticated to the Geyser server.
*/
- public void addPendingSession(GeyserSession session) {
+ public void addPendingSession(GeyserSessionImpl session) {
pendingSessions.add(session);
}
/**
* Called once a player has successfully logged into their Java server.
*/
- public void addSession(UUID uuid, GeyserSession session) {
+ public void addSession(UUID uuid, GeyserSessionImpl session) {
pendingSessions.remove(session);
sessions.put(uuid, session);
}
- public void removeSession(GeyserSession session) {
+ public void removeSession(GeyserSessionImpl session) {
if (sessions.remove(session.getPlayerEntity().getUuid()) == null) {
// Session was likely pending
pendingSessions.remove(session);
@@ -71,16 +70,16 @@ public final class SessionManager {
/**
* Creates a new, immutable list containing all pending and active sessions.
*/
- public Collection getAllSessions() {
- return ImmutableList.builder() // builderWithExpectedSize is probably not a good idea yet as older Spigot builds probably won't have it.
+ public List getAllSessions() {
+ return ImmutableList.builder() // builderWithExpectedSize is probably not a good idea yet as older Spigot builds probably won't have it.
.addAll(pendingSessions)
.addAll(sessions.values())
.build();
}
public void disconnectAll(String message) {
- Collection sessions = getAllSessions();
- for (GeyserSession session : sessions) {
+ Collection sessions = getAllSessions();
+ for (GeyserSessionImpl session : sessions) {
session.disconnect(GeyserLocale.getPlayerLocaleString(message, session.getLocale()));
}
}
diff --git a/core/src/main/java/org/geysermc/geyser/session/auth/AuthData.java b/core/src/main/java/org/geysermc/geyser/session/auth/AuthData.java
index eb142eec6..d48cf3889 100644
--- a/core/src/main/java/org/geysermc/geyser/session/auth/AuthData.java
+++ b/core/src/main/java/org/geysermc/geyser/session/auth/AuthData.java
@@ -26,20 +26,12 @@
package org.geysermc.geyser.session.auth;
import com.fasterxml.jackson.databind.JsonNode;
-import lombok.Getter;
-import lombok.RequiredArgsConstructor;
import org.geysermc.geyser.GeyserImpl;
import java.util.UUID;
-@RequiredArgsConstructor
-public class AuthData {
- @Getter private final String name;
- @Getter private final UUID uuid;
- @Getter private final String xuid;
-
- private final JsonNode certChainData;
- private final String clientData;
+public record AuthData(String name, UUID uuid, String xuid,
+ JsonNode certChainData, String clientData) {
public void upload(GeyserImpl geyser) {
// we can't upload the skin in LoginEncryptionUtil since the global server would return
diff --git a/core/src/main/java/org/geysermc/geyser/session/cache/AdvancementsCache.java b/core/src/main/java/org/geysermc/geyser/session/cache/AdvancementsCache.java
index b6dde975c..d99f963ad 100644
--- a/core/src/main/java/org/geysermc/geyser/session/cache/AdvancementsCache.java
+++ b/core/src/main/java/org/geysermc/geyser/session/cache/AdvancementsCache.java
@@ -29,7 +29,7 @@ import com.github.steveice10.mc.protocol.data.game.advancement.Advancement;
import com.github.steveice10.mc.protocol.packet.ingame.serverbound.inventory.ServerboundSeenAdvancementsPacket;
import lombok.Getter;
import lombok.Setter;
-import org.geysermc.geyser.session.GeyserSession;
+import org.geysermc.geyser.session.GeyserSessionImpl;
import org.geysermc.geyser.translator.text.MessageTranslator;
import org.geysermc.geyser.level.GeyserAdvancement;
import org.geysermc.geyser.text.GeyserLocale;
@@ -60,9 +60,9 @@ public class AdvancementsCache {
@Setter
private String currentAdvancementCategoryId = null;
- private final GeyserSession session;
+ private final GeyserSessionImpl session;
- public AdvancementsCache(GeyserSession session) {
+ public AdvancementsCache(GeyserSessionImpl session) {
this.session = session;
}
diff --git a/core/src/main/java/org/geysermc/geyser/session/cache/BookEditCache.java b/core/src/main/java/org/geysermc/geyser/session/cache/BookEditCache.java
index faaeafdb9..55ed10df4 100644
--- a/core/src/main/java/org/geysermc/geyser/session/cache/BookEditCache.java
+++ b/core/src/main/java/org/geysermc/geyser/session/cache/BookEditCache.java
@@ -28,7 +28,7 @@ package org.geysermc.geyser.session.cache;
import com.github.steveice10.mc.protocol.packet.ingame.serverbound.inventory.ServerboundEditBookPacket;
import lombok.Setter;
import org.geysermc.geyser.inventory.GeyserItemStack;
-import org.geysermc.geyser.session.GeyserSession;
+import org.geysermc.geyser.session.GeyserSessionImpl;
/**
* Manages updating the current writable book.
@@ -37,7 +37,7 @@ import org.geysermc.geyser.session.GeyserSession;
* book packets. Because of this, we need to ensure packets are only send every second or so at maximum.
*/
public class BookEditCache {
- private final GeyserSession session;
+ private final GeyserSessionImpl session;
@Setter
private ServerboundEditBookPacket packet;
/**
@@ -45,7 +45,7 @@ public class BookEditCache {
*/
private long lastBookUpdate;
- public BookEditCache(GeyserSession session) {
+ public BookEditCache(GeyserSessionImpl session) {
this.session = session;
}
diff --git a/core/src/main/java/org/geysermc/geyser/session/cache/BossBar.java b/core/src/main/java/org/geysermc/geyser/session/cache/BossBar.java
index 9595a3daf..842be51d6 100644
--- a/core/src/main/java/org/geysermc/geyser/session/cache/BossBar.java
+++ b/core/src/main/java/org/geysermc/geyser/session/cache/BossBar.java
@@ -32,12 +32,12 @@ import com.nukkitx.protocol.bedrock.packet.BossEventPacket;
import com.nukkitx.protocol.bedrock.packet.RemoveEntityPacket;
import lombok.AllArgsConstructor;
import net.kyori.adventure.text.Component;
-import org.geysermc.geyser.session.GeyserSession;
+import org.geysermc.geyser.session.GeyserSessionImpl;
import org.geysermc.geyser.translator.text.MessageTranslator;
@AllArgsConstructor
public class BossBar {
- private final GeyserSession session;
+ private final GeyserSessionImpl session;
private final long entityId;
private Component title;
diff --git a/core/src/main/java/org/geysermc/geyser/session/cache/ChunkCache.java b/core/src/main/java/org/geysermc/geyser/session/cache/ChunkCache.java
index 522c00d2a..eda21b9ce 100644
--- a/core/src/main/java/org/geysermc/geyser/session/cache/ChunkCache.java
+++ b/core/src/main/java/org/geysermc/geyser/session/cache/ChunkCache.java
@@ -30,7 +30,7 @@ import it.unimi.dsi.fastutil.longs.Long2ObjectMap;
import it.unimi.dsi.fastutil.longs.Long2ObjectOpenHashMap;
import lombok.Getter;
import lombok.Setter;
-import org.geysermc.geyser.session.GeyserSession;
+import org.geysermc.geyser.session.GeyserSessionImpl;
import org.geysermc.geyser.level.block.BlockStateValues;
import org.geysermc.geyser.level.chunk.GeyserChunk;
import org.geysermc.geyser.util.MathUtils;
@@ -51,7 +51,7 @@ public class ChunkCache {
@Setter
private boolean isExtendedHeight = false;
- public ChunkCache(GeyserSession session) {
+ public ChunkCache(GeyserSessionImpl session) {
this.cache = !session.getGeyser().getWorldManager().hasOwnChunkCache(); // To prevent Spigot from initializing
chunks = cache ? new Long2ObjectOpenHashMap<>() : null;
}
diff --git a/core/src/main/java/org/geysermc/geyser/session/cache/EntityCache.java b/core/src/main/java/org/geysermc/geyser/session/cache/EntityCache.java
index eb1bc6e9a..48b05fd70 100644
--- a/core/src/main/java/org/geysermc/geyser/session/cache/EntityCache.java
+++ b/core/src/main/java/org/geysermc/geyser/session/cache/EntityCache.java
@@ -35,7 +35,7 @@ import lombok.Getter;
import org.geysermc.geyser.entity.type.Entity;
import org.geysermc.geyser.entity.type.Tickable;
import org.geysermc.geyser.entity.type.player.PlayerEntity;
-import org.geysermc.geyser.session.GeyserSession;
+import org.geysermc.geyser.session.GeyserSessionImpl;
import java.util.*;
import java.util.concurrent.atomic.AtomicLong;
@@ -59,7 +59,7 @@ public class EntityCache {
@Getter
private final AtomicLong nextEntityId = new AtomicLong(2L);
- public EntityCache(GeyserSession session) {
+ public EntityCache(GeyserSessionImpl session) {
cachedPlayerEntityLinks.defaultReturnValue(-1L);
}
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 6f7d180de..e3e5f3b7c 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
@@ -32,7 +32,7 @@ import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
import lombok.RequiredArgsConstructor;
import org.geysermc.geyser.GeyserImpl;
-import org.geysermc.geyser.session.GeyserSession;
+import org.geysermc.geyser.session.GeyserSessionImpl;
import org.geysermc.cumulus.Form;
import org.geysermc.cumulus.SimpleForm;
@@ -44,7 +44,7 @@ import java.util.function.Consumer;
public class FormCache {
private final AtomicInteger formId = new AtomicInteger(0);
private final Int2ObjectMap