Search in sources :

Example 1 with VelocityPlayerAudience

use of org.geysermc.floodgate.player.VelocityUserAudience.VelocityPlayerAudience in project Floodgate by GeyserMC.

the class VelocityCommandUtil method getAudience.

@Override
@NonNull
public UserAudience getAudience(@NonNull Object sourceObj) {
    if (!(sourceObj instanceof CommandSource)) {
        throw new IllegalArgumentException("Can only work with CommandSource!");
    }
    CommandSource source = (CommandSource) sourceObj;
    if (!(source instanceof Player)) {
        if (console != null) {
            return console;
        }
        return console = new VelocityConsoleAudience(source, this);
    }
    Player player = (Player) source;
    UUID uuid = player.getUniqueId();
    String username = player.getUsername();
    String locale = Utils.getLocale(player.getPlayerSettings().getLocale());
    return AUDIENCE_CACHE.computeIfAbsent(uuid, $ -> new VelocityPlayerAudience(uuid, username, locale, source, true, this));
}
Also used : VelocityPlayerAudience(org.geysermc.floodgate.player.VelocityUserAudience.VelocityPlayerAudience) Player(com.velocitypowered.api.proxy.Player) VelocityConsoleAudience(org.geysermc.floodgate.player.VelocityUserAudience.VelocityConsoleAudience) CommandSource(com.velocitypowered.api.command.CommandSource) UUID(java.util.UUID) NonNull(org.checkerframework.checker.nullness.qual.NonNull)

Aggregations

CommandSource (com.velocitypowered.api.command.CommandSource)1 Player (com.velocitypowered.api.proxy.Player)1 UUID (java.util.UUID)1 NonNull (org.checkerframework.checker.nullness.qual.NonNull)1 VelocityConsoleAudience (org.geysermc.floodgate.player.VelocityUserAudience.VelocityConsoleAudience)1 VelocityPlayerAudience (org.geysermc.floodgate.player.VelocityUserAudience.VelocityPlayerAudience)1