mirror of
https://github.com/PaperMC/Velocity.git
synced 2026-02-17 22:47:42 +01:00
I missed a spot
This commit is contained in:
@@ -7,53 +7,23 @@
|
||||
|
||||
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.
|
||||
* 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 GameProfileRequestEvent {
|
||||
public interface GameProfileRequestEvent {
|
||||
|
||||
private final String username;
|
||||
private final InboundConnection connection;
|
||||
private final GameProfile originalProfile;
|
||||
private final boolean onlineMode;
|
||||
private @Nullable GameProfile gameProfile;
|
||||
InboundConnection getConnection();
|
||||
|
||||
/**
|
||||
* 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;
|
||||
}
|
||||
String getUsername();
|
||||
|
||||
public InboundConnection getConnection() {
|
||||
return connection;
|
||||
}
|
||||
GameProfile getOriginalProfile();
|
||||
|
||||
public String getUsername() {
|
||||
return username;
|
||||
}
|
||||
|
||||
public GameProfile getOriginalProfile() {
|
||||
return originalProfile;
|
||||
}
|
||||
|
||||
public boolean isOnlineMode() {
|
||||
return onlineMode;
|
||||
}
|
||||
boolean isOnlineMode();
|
||||
|
||||
/**
|
||||
* 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}
|
||||
*/
|
||||
public GameProfile getGameProfile() {
|
||||
return gameProfile == null ? originalProfile : gameProfile;
|
||||
}
|
||||
GameProfile getGameProfile();
|
||||
|
||||
/**
|
||||
* Sets the game profile to use for this connection.
|
||||
*
|
||||
* @param gameProfile the profile for this connection, {@code null} uses the original profile
|
||||
*/
|
||||
public void setGameProfile(@Nullable GameProfile gameProfile) {
|
||||
this.gameProfile = gameProfile;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "GameProfileRequestEvent{"
|
||||
+ "username=" + username
|
||||
+ ", gameProfile=" + gameProfile
|
||||
+ "}";
|
||||
}
|
||||
|
||||
|
||||
void setGameProfile(@Nullable 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
|
||||
+ "}";
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user