use of com.velocitypowered.api.util.GameProfile in project Floodgate by GeyserMC.
the class VelocityListener method onGameProfileRequest.
@Subscribe(order = PostOrder.EARLY)
public void onGameProfileRequest(GameProfileRequestEvent event) {
FloodgatePlayer player = playerCache.getIfPresent(event.getConnection());
if (player != null) {
playerCache.invalidate(event.getConnection());
// The texture properties addition is to fix the February 2 2022 Mojang authentication changes
event.setGameProfile(new GameProfile(player.getCorrectUniqueId(), player.getCorrectUsername(), Collections.singletonList(new Property("textures", "", ""))));
}
}
use of com.velocitypowered.api.util.GameProfile in project LimboAPI by Elytrium.
the class EventManagerHook method proxyHook.
private <E> CompletableFuture<E> proxyHook(E event) {
if (event instanceof GameProfileRequestEvent) {
GameProfile originalProfile = ((GameProfileRequestEvent) event).getGameProfile();
if (this.proceededProfiles.contains(originalProfile)) {
this.proceededProfiles.remove(originalProfile);
return null;
}
CompletableFuture<E> fireFuture = new CompletableFuture<>();
CompletableFuture<E> hookFuture = new CompletableFuture<>();
fireFuture.thenAccept((modifiedEvent) -> {
try {
GameProfileRequestEvent requestEvent = (GameProfileRequestEvent) modifiedEvent;
GameProfile profile = requestEvent.getGameProfile();
this.plugin.getLoginListener().hookLoginSession(requestEvent);
this.proceededProfiles.add(profile);
hookFuture.complete(modifiedEvent);
} catch (IllegalAccessException ex) {
ex.printStackTrace();
}
});
try {
if (this.hasHandlerRegistration) {
fire.invoke(this, fireFuture, event, 0, false, this.handlerRegistrations);
} else {
fireFuture.complete(event);
}
} catch (IllegalAccessException | InvocationTargetException e) {
fireFuture.complete(event);
}
return hookFuture;
}
return null;
}
Aggregations