mirror of
https://github.com/GeyserMC/Floodgate.git
synced 2026-01-06 15:42:03 +00:00
Fixed a bug where linked accounts would get their Bedrock skin
This commit is contained in:
@@ -107,6 +107,11 @@ public final class FloodgatePlayerImpl implements FloodgatePlayer {
|
||||
return linkedPlayer != null ? linkedPlayer.getJavaUsername() : javaUsername;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isLinked() {
|
||||
return linkedPlayer != null;
|
||||
}
|
||||
|
||||
public BedrockData toBedrockData() {
|
||||
TimeSyncer timeSyncer = TimeSyncerHolder.get();
|
||||
|
||||
|
||||
@@ -36,6 +36,7 @@ import org.geysermc.floodgate.config.FloodgateConfig;
|
||||
import org.geysermc.floodgate.config.ProxyFloodgateConfig;
|
||||
import org.geysermc.floodgate.pluginmessage.PluginMessageChannel;
|
||||
import org.geysermc.floodgate.skin.SkinApplier;
|
||||
import org.geysermc.floodgate.skin.SkinData;
|
||||
|
||||
public class SkinChannel implements PluginMessageChannel {
|
||||
@Inject private FloodgateApi api;
|
||||
@@ -91,6 +92,10 @@ public class SkinChannel implements PluginMessageChannel {
|
||||
return Result.kick("Got invalid skin data");
|
||||
}
|
||||
|
||||
if (floodgatePlayer.isLinked()) {
|
||||
return Result.handled();
|
||||
}
|
||||
|
||||
String value = split[0];
|
||||
String signature = split[1];
|
||||
|
||||
@@ -98,8 +103,10 @@ public class SkinChannel implements PluginMessageChannel {
|
||||
result.addProperty("value", value);
|
||||
result.addProperty("signature", signature);
|
||||
|
||||
floodgatePlayer.addProperty(PropertyKey.SKIN_UPLOADED, result);
|
||||
skinApplier.applySkin(floodgatePlayer, result);
|
||||
SkinData skinData = new SkinData(value, signature);
|
||||
|
||||
floodgatePlayer.addProperty(PropertyKey.SKIN_UPLOADED, skinData);
|
||||
skinApplier.applySkin(floodgatePlayer, skinData);
|
||||
|
||||
return Result.handled();
|
||||
}
|
||||
|
||||
@@ -25,9 +25,8 @@
|
||||
|
||||
package org.geysermc.floodgate.skin;
|
||||
|
||||
import com.google.gson.JsonObject;
|
||||
import org.geysermc.floodgate.api.player.FloodgatePlayer;
|
||||
|
||||
public interface SkinApplier {
|
||||
void applySkin(FloodgatePlayer floodgatePlayer, JsonObject skinResult);
|
||||
void applySkin(FloodgatePlayer floodgatePlayer, SkinData skinData);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,47 @@
|
||||
/*
|
||||
* Copyright (c) 2019-2021 GeyserMC. http://geysermc.org
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*
|
||||
* @author GeyserMC
|
||||
* @link https://github.com/GeyserMC/Floodgate
|
||||
*/
|
||||
|
||||
package org.geysermc.floodgate.skin;
|
||||
|
||||
import com.google.gson.JsonObject;
|
||||
import lombok.Getter;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
|
||||
@Getter
|
||||
@RequiredArgsConstructor
|
||||
public class SkinData {
|
||||
private final String value;
|
||||
private final String signature;
|
||||
|
||||
public static SkinData from(JsonObject data) {
|
||||
if (data.has("signature") && !data.get("signature").isJsonNull()) {
|
||||
return new SkinData(
|
||||
data.get("value").getAsString(),
|
||||
data.get("signature").getAsString()
|
||||
);
|
||||
}
|
||||
return new SkinData(data.get("value").getAsString(), null);
|
||||
}
|
||||
}
|
||||
@@ -37,6 +37,7 @@ import lombok.Getter;
|
||||
import org.geysermc.floodgate.api.FloodgateApi;
|
||||
import org.geysermc.floodgate.api.logger.FloodgateLogger;
|
||||
import org.geysermc.floodgate.api.player.FloodgatePlayer;
|
||||
import org.geysermc.floodgate.api.player.PropertyKey;
|
||||
import org.geysermc.floodgate.util.Utils;
|
||||
import org.geysermc.floodgate.util.WebsocketEventType;
|
||||
import org.java_websocket.client.WebSocketClient;
|
||||
@@ -113,7 +114,11 @@ final class SkinUploadSocket extends WebSocketClient {
|
||||
player.getCorrectUsername());
|
||||
return;
|
||||
}
|
||||
applier.applySkin(player, message.getAsJsonObject("data"));
|
||||
if (!player.isLinked()) {
|
||||
SkinData skinData = SkinData.from(message.getAsJsonObject("data"));
|
||||
player.addProperty(PropertyKey.SKIN_UPLOADED, skinData);
|
||||
applier.applySkin(player, skinData);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case LOG_MESSAGE:
|
||||
|
||||
Reference in New Issue
Block a user