mirror of
https://github.com/GeyserMC/Geyser.git
synced 2024-08-14 23:57:35 +00:00
Some small changes
This commit is contained in:
parent
50b51f5f57
commit
01492647fc
15 changed files with 33 additions and 54 deletions
|
@ -25,7 +25,7 @@
|
||||||
|
|
||||||
package org.geysermc.floodgate.util;
|
package org.geysermc.floodgate.util;
|
||||||
|
|
||||||
public class Base64Utils {
|
public final class Base64Utils {
|
||||||
public static int getEncodedLength(int length) {
|
public static int getEncodedLength(int length) {
|
||||||
if (length <= 0) {
|
if (length <= 0) {
|
||||||
return -1;
|
return -1;
|
||||||
|
|
|
@ -28,7 +28,7 @@ package org.geysermc.floodgate.util;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
|
|
||||||
public class FloodgateConfigHolder {
|
public final class FloodgateConfigHolder {
|
||||||
@Getter
|
@Getter
|
||||||
@Setter
|
@Setter
|
||||||
private static Object config;
|
private static Object config;
|
||||||
|
|
|
@ -48,7 +48,7 @@ public final class LinkedPlayer implements Cloneable {
|
||||||
*/
|
*/
|
||||||
private final UUID bedrockId;
|
private final UUID bedrockId;
|
||||||
/**
|
/**
|
||||||
* If the LinkedPlayer is send from a different platform. For example the LinkedPlayer is from
|
* If the LinkedPlayer is sent from a different platform. For example the LinkedPlayer is from
|
||||||
* Bungee but the data has been sent to the Bukkit server.
|
* Bungee but the data has been sent to the Bukkit server.
|
||||||
*/
|
*/
|
||||||
private boolean fromDifferentPlatform = false;
|
private boolean fromDifferentPlatform = false;
|
||||||
|
|
|
@ -39,6 +39,7 @@
|
||||||
<groupId>org.java-websocket</groupId>
|
<groupId>org.java-websocket</groupId>
|
||||||
<artifactId>Java-WebSocket</artifactId>
|
<artifactId>Java-WebSocket</artifactId>
|
||||||
<version>1.5.1</version>
|
<version>1.5.1</version>
|
||||||
|
<scope>compile</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.github.CloudburstMC.Protocol</groupId>
|
<groupId>com.github.CloudburstMC.Protocol</groupId>
|
||||||
|
@ -214,11 +215,13 @@
|
||||||
<groupId>org.reflections</groupId>
|
<groupId>org.reflections</groupId>
|
||||||
<artifactId>reflections</artifactId>
|
<artifactId>reflections</artifactId>
|
||||||
<version>0.9.11</version> <!-- This isn't the latest version to get round https://github.com/ronmamo/reflections/issues/273 -->
|
<version>0.9.11</version> <!-- This isn't the latest version to get round https://github.com/ronmamo/reflections/issues/273 -->
|
||||||
|
<scope>compile</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.dom4j</groupId>
|
<groupId>org.dom4j</groupId>
|
||||||
<artifactId>dom4j</artifactId>
|
<artifactId>dom4j</artifactId>
|
||||||
<version>2.1.3</version>
|
<version>2.1.3</version>
|
||||||
|
<scope>compile</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>net.kyori</groupId>
|
<groupId>net.kyori</groupId>
|
||||||
|
@ -254,6 +257,7 @@
|
||||||
<groupId>com.github.GeyserMC</groupId>
|
<groupId>com.github.GeyserMC</groupId>
|
||||||
<artifactId>MCAuthLib</artifactId>
|
<artifactId>MCAuthLib</artifactId>
|
||||||
<version>0e48a094f2</version>
|
<version>0e48a094f2</version>
|
||||||
|
<scope>compile</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
|
|
|
@ -109,7 +109,7 @@ public class GeyserConnector {
|
||||||
@Setter
|
@Setter
|
||||||
private AuthType defaultAuthType;
|
private AuthType defaultAuthType;
|
||||||
|
|
||||||
private TimeSyncer timeSyncer;
|
private final TimeSyncer timeSyncer;
|
||||||
private FloodgateCipher cipher;
|
private FloodgateCipher cipher;
|
||||||
private FloodgateSkinUploader skinUploader;
|
private FloodgateSkinUploader skinUploader;
|
||||||
private final NewsHandler newsHandler;
|
private final NewsHandler newsHandler;
|
||||||
|
@ -202,6 +202,7 @@ public class GeyserConnector {
|
||||||
|
|
||||||
defaultAuthType = AuthType.getByName(config.getRemote().getAuthType());
|
defaultAuthType = AuthType.getByName(config.getRemote().getAuthType());
|
||||||
|
|
||||||
|
TimeSyncer timeSyncer = null;
|
||||||
if (defaultAuthType == AuthType.FLOODGATE) {
|
if (defaultAuthType == AuthType.FLOODGATE) {
|
||||||
timeSyncer = new TimeSyncer(Constants.NTP_SERVER);
|
timeSyncer = new TimeSyncer(Constants.NTP_SERVER);
|
||||||
try {
|
try {
|
||||||
|
@ -214,6 +215,7 @@ public class GeyserConnector {
|
||||||
logger.severe(LanguageUtils.getLocaleStringLog("geyser.auth.floodgate.bad_key"), exception);
|
logger.severe(LanguageUtils.getLocaleStringLog("geyser.auth.floodgate.bad_key"), exception);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
this.timeSyncer = timeSyncer;
|
||||||
|
|
||||||
String branch = "unknown";
|
String branch = "unknown";
|
||||||
int buildNumber = -1;
|
int buildNumber = -1;
|
||||||
|
|
|
@ -53,7 +53,7 @@ public abstract class CommandManager {
|
||||||
registerCommand(new VersionCommand(connector, "version", "geyser.commands.version.desc", "geyser.command.version"));
|
registerCommand(new VersionCommand(connector, "version", "geyser.commands.version.desc", "geyser.command.version"));
|
||||||
registerCommand(new SettingsCommand(connector, "settings", "geyser.commands.settings.desc", "geyser.command.settings"));
|
registerCommand(new SettingsCommand(connector, "settings", "geyser.commands.settings.desc", "geyser.command.settings"));
|
||||||
registerCommand(new StatisticsCommand(connector, "statistics", "geyser.commands.statistics.desc", "geyser.command.statistics"));
|
registerCommand(new StatisticsCommand(connector, "statistics", "geyser.commands.statistics.desc", "geyser.command.statistics"));
|
||||||
registerCommand(new AdvancementsCommand( "advancements", "geyser.commands.advancements.desc", "geyser.command.advancements"));
|
registerCommand(new AdvancementsCommand("advancements", "geyser.commands.advancements.desc", "geyser.command.advancements"));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void registerCommand(GeyserCommand command) {
|
public void registerCommand(GeyserCommand command) {
|
||||||
|
|
|
@ -140,10 +140,10 @@ public class GeyserSession implements CommandSender {
|
||||||
private ChunkCache chunkCache;
|
private ChunkCache chunkCache;
|
||||||
private EntityCache entityCache;
|
private EntityCache entityCache;
|
||||||
private EntityEffectCache effectCache;
|
private EntityEffectCache effectCache;
|
||||||
|
private final FormCache formCache;
|
||||||
private final PreferencesCache preferencesCache;
|
private final PreferencesCache preferencesCache;
|
||||||
private final TagCache tagCache;
|
private final TagCache tagCache;
|
||||||
private WorldCache worldCache;
|
private WorldCache worldCache;
|
||||||
private FormCache formCache;
|
|
||||||
private final Int2ObjectMap<TeleportCache> teleportMap = new Int2ObjectOpenHashMap<>();
|
private final Int2ObjectMap<TeleportCache> teleportMap = new Int2ObjectOpenHashMap<>();
|
||||||
|
|
||||||
private final PlayerInventory playerInventory;
|
private final PlayerInventory playerInventory;
|
||||||
|
@ -445,12 +445,13 @@ public class GeyserSession implements CommandSender {
|
||||||
this.chunkCache = new ChunkCache(this);
|
this.chunkCache = new ChunkCache(this);
|
||||||
this.entityCache = new EntityCache(this);
|
this.entityCache = new EntityCache(this);
|
||||||
this.effectCache = new EntityEffectCache();
|
this.effectCache = new EntityEffectCache();
|
||||||
|
this.formCache = new FormCache(this);
|
||||||
this.preferencesCache = new PreferencesCache(this);
|
this.preferencesCache = new PreferencesCache(this);
|
||||||
this.tagCache = new TagCache();
|
this.tagCache = new TagCache();
|
||||||
this.worldCache = new WorldCache(this);
|
this.worldCache = new WorldCache(this);
|
||||||
this.formCache = new FormCache(this);
|
|
||||||
|
|
||||||
this.collisionManager = new CollisionManager(this);
|
this.collisionManager = new CollisionManager(this);
|
||||||
|
|
||||||
this.playerEntity = new SessionPlayerEntity(this);
|
this.playerEntity = new SessionPlayerEntity(this);
|
||||||
collisionManager.updatePlayerBoundingBox(this.playerEntity.getPosition());
|
collisionManager.updatePlayerBoundingBox(this.playerEntity.getPosition());
|
||||||
|
|
||||||
|
@ -851,7 +852,6 @@ public class GeyserSession implements CommandSender {
|
||||||
this.entityCache = null;
|
this.entityCache = null;
|
||||||
this.effectCache = null;
|
this.effectCache = null;
|
||||||
this.worldCache = null;
|
this.worldCache = null;
|
||||||
this.formCache = null;
|
|
||||||
|
|
||||||
closed = true;
|
closed = true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,26 +25,18 @@
|
||||||
|
|
||||||
package org.geysermc.connector.network.session.auth;
|
package org.geysermc.connector.network.session.auth;
|
||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
|
||||||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
import com.fasterxml.jackson.databind.JsonNode;
|
|
||||||
import com.google.common.base.Charsets;
|
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import org.geysermc.connector.skin.SkinProvider;
|
|
||||||
import org.geysermc.floodgate.util.DeviceOs;
|
import org.geysermc.floodgate.util.DeviceOs;
|
||||||
import org.geysermc.floodgate.util.InputMode;
|
import org.geysermc.floodgate.util.InputMode;
|
||||||
import org.geysermc.floodgate.util.UiProfile;
|
import org.geysermc.floodgate.util.UiProfile;
|
||||||
|
|
||||||
import java.util.Base64;
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||||
@Getter
|
@Getter
|
||||||
public final class BedrockClientData {
|
public final class BedrockClientData {
|
||||||
@JsonIgnore
|
|
||||||
private JsonNode jsonData;
|
|
||||||
|
|
||||||
@JsonProperty(value = "GameVersion")
|
@JsonProperty(value = "GameVersion")
|
||||||
private String gameVersion;
|
private String gameVersion;
|
||||||
@JsonProperty(value = "ServerAddress")
|
@JsonProperty(value = "ServerAddress")
|
||||||
|
@ -115,27 +107,6 @@ public final class BedrockClientData {
|
||||||
@JsonProperty(value = "PlayFabId")
|
@JsonProperty(value = "PlayFabId")
|
||||||
private String playFabId;
|
private String playFabId;
|
||||||
|
|
||||||
public void setJsonData(JsonNode data) {
|
|
||||||
if (this.jsonData == null && data != null) {
|
|
||||||
this.jsonData = data;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isAlex() {
|
|
||||||
try {
|
|
||||||
byte[] bytes = Base64.getDecoder().decode(geometryName.getBytes(Charsets.UTF_8));
|
|
||||||
String geometryName =
|
|
||||||
SkinProvider.OBJECT_MAPPER
|
|
||||||
.readTree(bytes)
|
|
||||||
.get("geometry").get("default")
|
|
||||||
.asText();
|
|
||||||
return "geometry.humanoid.customSlim".equals(geometryName);
|
|
||||||
} catch (Exception exception) {
|
|
||||||
exception.printStackTrace();
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public DeviceOs getDeviceOs() {
|
public DeviceOs getDeviceOs() {
|
||||||
return deviceOs != null ? deviceOs : DeviceOs.UNKNOWN;
|
return deviceOs != null ? deviceOs : DeviceOs.UNKNOWN;
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,7 +29,6 @@ import com.github.steveice10.mc.protocol.data.game.advancement.Advancement;
|
||||||
import com.github.steveice10.mc.protocol.packet.ingame.client.window.ClientAdvancementTabPacket;
|
import com.github.steveice10.mc.protocol.packet.ingame.client.window.ClientAdvancementTabPacket;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
import lombok.experimental.Accessors;
|
|
||||||
import org.geysermc.connector.network.session.GeyserSession;
|
import org.geysermc.connector.network.session.GeyserSession;
|
||||||
import org.geysermc.connector.network.translators.chat.MessageTranslator;
|
import org.geysermc.connector.network.translators.chat.MessageTranslator;
|
||||||
import org.geysermc.connector.utils.GeyserAdvancement;
|
import org.geysermc.connector.utils.GeyserAdvancement;
|
||||||
|
@ -58,7 +57,7 @@ public class AdvancementsCache {
|
||||||
/**
|
/**
|
||||||
* Stores player's chosen advancement's ID and title for use in form creators.
|
* Stores player's chosen advancement's ID and title for use in form creators.
|
||||||
*/
|
*/
|
||||||
@Setter @Accessors(chain = true)
|
@Setter
|
||||||
private String currentAdvancementCategoryId = null;
|
private String currentAdvancementCategoryId = null;
|
||||||
|
|
||||||
private final GeyserSession session;
|
private final GeyserSession session;
|
||||||
|
|
|
@ -33,6 +33,7 @@ import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import org.geysermc.connector.network.session.GeyserSession;
|
import org.geysermc.connector.network.session.GeyserSession;
|
||||||
import org.geysermc.cumulus.Form;
|
import org.geysermc.cumulus.Form;
|
||||||
|
import org.geysermc.cumulus.SimpleForm;
|
||||||
|
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
import java.util.concurrent.atomic.AtomicInteger;
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
|
@ -58,13 +59,15 @@ public class FormCache {
|
||||||
formRequestPacket.setFormData(form.getJsonData());
|
formRequestPacket.setFormData(form.getJsonData());
|
||||||
session.sendUpstreamPacket(formRequestPacket);
|
session.sendUpstreamPacket(formRequestPacket);
|
||||||
|
|
||||||
// Hack to fix the url image loading bug
|
// Hack to fix the (url) image loading bug
|
||||||
NetworkStackLatencyPacket latencyPacket = new NetworkStackLatencyPacket();
|
if (form instanceof SimpleForm) {
|
||||||
latencyPacket.setFromServer(true);
|
NetworkStackLatencyPacket latencyPacket = new NetworkStackLatencyPacket();
|
||||||
latencyPacket.setTimestamp(-System.currentTimeMillis());
|
latencyPacket.setFromServer(true);
|
||||||
session.getConnector().getGeneralThreadPool().schedule(
|
latencyPacket.setTimestamp(-System.currentTimeMillis());
|
||||||
() -> session.sendUpstreamPacket(latencyPacket),
|
session.getConnector().getGeneralThreadPool().schedule(
|
||||||
500, TimeUnit.MILLISECONDS);
|
() -> session.sendUpstreamPacket(latencyPacket),
|
||||||
|
500, TimeUnit.MILLISECONDS);
|
||||||
|
}
|
||||||
|
|
||||||
return windowId;
|
return windowId;
|
||||||
}
|
}
|
||||||
|
|
|
@ -52,7 +52,6 @@ public class BedrockNetworkStackLatencyTranslator extends PacketTranslator<Netwo
|
||||||
// PS4 divides the network stack latency timestamp FOR US!!!
|
// PS4 divides the network stack latency timestamp FOR US!!!
|
||||||
// WTF
|
// WTF
|
||||||
if (session.getClientData().getDeviceOs().equals(DeviceOs.PS4)) {
|
if (session.getClientData().getDeviceOs().equals(DeviceOs.PS4)) {
|
||||||
// Ignore the weird DeviceOS, our order is wrong and will be fixed in Floodgate 2.0
|
|
||||||
pingId = packet.getTimestamp();
|
pingId = packet.getTimestamp();
|
||||||
} else {
|
} else {
|
||||||
pingId = packet.getTimestamp() / 1000;
|
pingId = packet.getTimestamp() / 1000;
|
||||||
|
|
|
@ -27,6 +27,7 @@ package org.geysermc.connector.network.translators.java;
|
||||||
|
|
||||||
import com.github.steveice10.mc.protocol.packet.ingame.server.ServerAdvancementTabPacket;
|
import com.github.steveice10.mc.protocol.packet.ingame.server.ServerAdvancementTabPacket;
|
||||||
import org.geysermc.connector.network.session.GeyserSession;
|
import org.geysermc.connector.network.session.GeyserSession;
|
||||||
|
import org.geysermc.connector.network.session.cache.AdvancementsCache;
|
||||||
import org.geysermc.connector.network.translators.PacketTranslator;
|
import org.geysermc.connector.network.translators.PacketTranslator;
|
||||||
import org.geysermc.connector.network.translators.Translator;
|
import org.geysermc.connector.network.translators.Translator;
|
||||||
|
|
||||||
|
@ -37,8 +38,8 @@ import org.geysermc.connector.network.translators.Translator;
|
||||||
public class JavaAdvancementsTabTranslator extends PacketTranslator<ServerAdvancementTabPacket> {
|
public class JavaAdvancementsTabTranslator extends PacketTranslator<ServerAdvancementTabPacket> {
|
||||||
@Override
|
@Override
|
||||||
public void translate(ServerAdvancementTabPacket packet, GeyserSession session) {
|
public void translate(ServerAdvancementTabPacket packet, GeyserSession session) {
|
||||||
session.getAdvancementsCache()
|
AdvancementsCache advancementsCache = session.getAdvancementsCache();
|
||||||
.setCurrentAdvancementCategoryId(packet.getTabId())
|
advancementsCache.setCurrentAdvancementCategoryId(packet.getTabId());
|
||||||
.buildAndShowListForm();
|
advancementsCache.buildAndShowListForm();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,6 +33,7 @@ import org.geysermc.connector.utils.StatisticsUtils;
|
||||||
|
|
||||||
@Translator(packet = ServerStatisticsPacket.class)
|
@Translator(packet = ServerStatisticsPacket.class)
|
||||||
public class JavaStatisticsTranslator extends PacketTranslator<ServerStatisticsPacket> {
|
public class JavaStatisticsTranslator extends PacketTranslator<ServerStatisticsPacket> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void translate(ServerStatisticsPacket packet, GeyserSession session) {
|
public void translate(ServerStatisticsPacket packet, GeyserSession session) {
|
||||||
session.updateStatistics(packet.getStatistics());
|
session.updateStatistics(packet.getStatistics());
|
||||||
|
|
|
@ -134,7 +134,6 @@ public class LoginEncryptionUtils {
|
||||||
|
|
||||||
JsonNode clientDataJson = JSON_MAPPER.readTree(clientJwt.getPayload().toBytes());
|
JsonNode clientDataJson = JSON_MAPPER.readTree(clientJwt.getPayload().toBytes());
|
||||||
BedrockClientData data = JSON_MAPPER.convertValue(clientDataJson, BedrockClientData.class);
|
BedrockClientData data = JSON_MAPPER.convertValue(clientDataJson, BedrockClientData.class);
|
||||||
data.setJsonData(clientDataJson);
|
|
||||||
session.setClientData(data);
|
session.setClientData(data);
|
||||||
|
|
||||||
if (EncryptionUtils.canUseEncryption()) {
|
if (EncryptionUtils.canUseEncryption()) {
|
||||||
|
@ -243,7 +242,7 @@ public class LoginEncryptionUtils {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Promts the user between either OAuth code login or manual password authentication
|
* Prompts the user between either OAuth code login or manual password authentication
|
||||||
*/
|
*/
|
||||||
public static void buildAndShowMicrosoftAuthenticationWindow(GeyserSession session) {
|
public static void buildAndShowMicrosoftAuthenticationWindow(GeyserSession session) {
|
||||||
session.sendForm(
|
session.sendForm(
|
||||||
|
|
|
@ -180,8 +180,8 @@ public class StatisticsUtils {
|
||||||
session.sendForm(
|
session.sendForm(
|
||||||
builder.content(content.toString())
|
builder.content(content.toString())
|
||||||
.button("gui.back", FormImage.Type.PATH, "textures/gui/newgui/undo")
|
.button("gui.back", FormImage.Type.PATH, "textures/gui/newgui/undo")
|
||||||
.responseHandler((form1, responseData1) -> {
|
.responseHandler((form1, subFormResponseData) -> {
|
||||||
SimpleFormResponse response1 = form.parseResponse(responseData1);
|
SimpleFormResponse response1 = form.parseResponse(subFormResponseData);
|
||||||
if (response1.isCorrect()) {
|
if (response1.isCorrect()) {
|
||||||
buildAndSendStatisticsMenu(session);
|
buildAndSendStatisticsMenu(session);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue