mirror of
https://github.com/PaperMC/Velocity.git
synced 2026-02-19 07:27:42 +01:00
I missed a spot
This commit is contained in:
@@ -7,53 +7,23 @@
|
|||||||
|
|
||||||
package com.velocitypowered.api.event.player;
|
package com.velocitypowered.api.event.player;
|
||||||
|
|
||||||
import com.google.common.base.Preconditions;
|
|
||||||
import com.velocitypowered.api.proxy.connection.InboundConnection;
|
import com.velocitypowered.api.proxy.connection.InboundConnection;
|
||||||
import com.velocitypowered.api.util.GameProfile;
|
import com.velocitypowered.api.util.GameProfile;
|
||||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This event is fired after the {@link PreLoginEventImpl} in
|
* This event is fired after the {@link PreLoginEventImpl} in order to set up the game profile for
|
||||||
* order to set up the game profile for the user. This can be used to configure a custom profile for
|
* the user. This can be used to configure a custom profile for a user, i.e. skin replacement.
|
||||||
* a user, i.e. skin replacement.
|
|
||||||
*/
|
*/
|
||||||
public final class GameProfileRequestEvent {
|
public interface GameProfileRequestEvent {
|
||||||
|
|
||||||
private final String username;
|
InboundConnection getConnection();
|
||||||
private final InboundConnection connection;
|
|
||||||
private final GameProfile originalProfile;
|
|
||||||
private final boolean onlineMode;
|
|
||||||
private @Nullable GameProfile gameProfile;
|
|
||||||
|
|
||||||
/**
|
String getUsername();
|
||||||
* Creates a new instance.
|
|
||||||
* @param connection the connection connecting to the proxy
|
|
||||||
* @param originalProfile the original {@link GameProfile} for the user
|
|
||||||
* @param onlineMode whether or not the user connected in online or offline mode
|
|
||||||
*/
|
|
||||||
public GameProfileRequestEvent(InboundConnection connection, GameProfile originalProfile,
|
|
||||||
boolean onlineMode) {
|
|
||||||
this.connection = Preconditions.checkNotNull(connection, "connection");
|
|
||||||
this.originalProfile = Preconditions.checkNotNull(originalProfile, "originalProfile");
|
|
||||||
this.username = originalProfile.getName();
|
|
||||||
this.onlineMode = onlineMode;
|
|
||||||
}
|
|
||||||
|
|
||||||
public InboundConnection getConnection() {
|
GameProfile getOriginalProfile();
|
||||||
return connection;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getUsername() {
|
boolean isOnlineMode();
|
||||||
return username;
|
|
||||||
}
|
|
||||||
|
|
||||||
public GameProfile getOriginalProfile() {
|
|
||||||
return originalProfile;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isOnlineMode() {
|
|
||||||
return onlineMode;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the game profile that will be used to initialize the connection with. Should no profile
|
* Returns the game profile that will be used to initialize the connection with. Should no profile
|
||||||
@@ -62,26 +32,12 @@ public final class GameProfileRequestEvent {
|
|||||||
*
|
*
|
||||||
* @return the user's {@link GameProfile}
|
* @return the user's {@link GameProfile}
|
||||||
*/
|
*/
|
||||||
public GameProfile getGameProfile() {
|
GameProfile getGameProfile();
|
||||||
return gameProfile == null ? originalProfile : gameProfile;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the game profile to use for this connection.
|
* Sets the game profile to use for this connection.
|
||||||
*
|
*
|
||||||
* @param gameProfile the profile for this connection, {@code null} uses the original profile
|
* @param gameProfile the profile for this connection, {@code null} uses the original profile
|
||||||
*/
|
*/
|
||||||
public void setGameProfile(@Nullable GameProfile gameProfile) {
|
void setGameProfile(@Nullable GameProfile gameProfile);
|
||||||
this.gameProfile = gameProfile;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toString() {
|
|
||||||
return "GameProfileRequestEvent{"
|
|
||||||
+ "username=" + username
|
|
||||||
+ ", gameProfile=" + gameProfile
|
|
||||||
+ "}";
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,92 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2018 Velocity Contributors
|
||||||
|
*
|
||||||
|
* The Velocity API is licensed under the terms of the MIT License. For more details,
|
||||||
|
* reference the LICENSE file in the api top-level directory.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.velocitypowered.api.event.player;
|
||||||
|
|
||||||
|
import com.google.common.base.Preconditions;
|
||||||
|
import com.velocitypowered.api.proxy.connection.InboundConnection;
|
||||||
|
import com.velocitypowered.api.util.GameProfile;
|
||||||
|
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This event is fired after the {@link PreLoginEventImpl} in order to set up the game profile for
|
||||||
|
* the user. This can be used to configure a custom profile for a user, i.e. skin replacement.
|
||||||
|
*/
|
||||||
|
public final class GameProfileRequestEventImpl implements GameProfileRequestEvent {
|
||||||
|
|
||||||
|
private final String username;
|
||||||
|
private final InboundConnection connection;
|
||||||
|
private final GameProfile originalProfile;
|
||||||
|
private final boolean onlineMode;
|
||||||
|
private @Nullable GameProfile gameProfile;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new instance.
|
||||||
|
* @param connection the connection connecting to the proxy
|
||||||
|
* @param originalProfile the original {@link GameProfile} for the user
|
||||||
|
* @param onlineMode whether or not the user connected in online or offline mode
|
||||||
|
*/
|
||||||
|
public GameProfileRequestEventImpl(InboundConnection connection, GameProfile originalProfile,
|
||||||
|
boolean onlineMode) {
|
||||||
|
this.connection = Preconditions.checkNotNull(connection, "connection");
|
||||||
|
this.originalProfile = Preconditions.checkNotNull(originalProfile, "originalProfile");
|
||||||
|
this.username = originalProfile.getName();
|
||||||
|
this.onlineMode = onlineMode;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public InboundConnection getConnection() {
|
||||||
|
return connection;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getUsername() {
|
||||||
|
return username;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public GameProfile getOriginalProfile() {
|
||||||
|
return originalProfile;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isOnlineMode() {
|
||||||
|
return onlineMode;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the game profile that will be used to initialize the connection with. Should no profile
|
||||||
|
* be currently specified, the one generated by the proxy (for offline mode) or retrieved from the
|
||||||
|
* Mojang session servers (for online mode) will be returned instead.
|
||||||
|
*
|
||||||
|
* @return the user's {@link GameProfile}
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public GameProfile getGameProfile() {
|
||||||
|
return gameProfile == null ? originalProfile : gameProfile;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the game profile to use for this connection.
|
||||||
|
*
|
||||||
|
* @param gameProfile the profile for this connection, {@code null} uses the original profile
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void setGameProfile(@Nullable GameProfile gameProfile) {
|
||||||
|
this.gameProfile = gameProfile;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "GameProfileRequestEvent{"
|
||||||
|
+ "username=" + username
|
||||||
|
+ ", gameProfile=" + gameProfile
|
||||||
|
+ "}";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@@ -29,6 +29,7 @@ import com.velocitypowered.api.event.permission.PermissionsSetupEventImpl;
|
|||||||
import com.velocitypowered.api.event.player.DisconnectEvent.LoginStatus;
|
import com.velocitypowered.api.event.player.DisconnectEvent.LoginStatus;
|
||||||
import com.velocitypowered.api.event.player.DisconnectEventImpl;
|
import com.velocitypowered.api.event.player.DisconnectEventImpl;
|
||||||
import com.velocitypowered.api.event.player.GameProfileRequestEvent;
|
import com.velocitypowered.api.event.player.GameProfileRequestEvent;
|
||||||
|
import com.velocitypowered.api.event.player.GameProfileRequestEventImpl;
|
||||||
import com.velocitypowered.api.event.player.LoginEventImpl;
|
import com.velocitypowered.api.event.player.LoginEventImpl;
|
||||||
import com.velocitypowered.api.event.player.PlayerChooseInitialServerEvent;
|
import com.velocitypowered.api.event.player.PlayerChooseInitialServerEvent;
|
||||||
import com.velocitypowered.api.event.player.PlayerChooseInitialServerEventImpl;
|
import com.velocitypowered.api.event.player.PlayerChooseInitialServerEventImpl;
|
||||||
@@ -225,7 +226,7 @@ public class LoginSessionHandler implements MinecraftSessionHandler {
|
|||||||
// Some connection types may need to alter the game profile.
|
// Some connection types may need to alter the game profile.
|
||||||
profile = mcConnection.getType().addGameProfileTokensIfRequired(profile,
|
profile = mcConnection.getType().addGameProfileTokensIfRequired(profile,
|
||||||
server.getConfiguration().getPlayerInfoForwardingMode());
|
server.getConfiguration().getPlayerInfoForwardingMode());
|
||||||
GameProfileRequestEvent profileRequestEvent = new GameProfileRequestEvent(inbound, profile,
|
GameProfileRequestEvent profileRequestEvent = new GameProfileRequestEventImpl(inbound, profile,
|
||||||
onlineMode);
|
onlineMode);
|
||||||
final GameProfile finalProfile = profile;
|
final GameProfile finalProfile = profile;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user