Search in sources :

Example 1 with GameProfileCache

use of net.minecraft.server.players.GameProfileCache in project pollen by MoonflowerTeam.

the class SkinHelper method init.

@ApiStatus.Internal
public static void init() {
    AuthenticationService authenticationservice = new YggdrasilAuthenticationService(Minecraft.getInstance().getProxy());
    sessionService = authenticationservice.createMinecraftSessionService();
    gameProfileCache = new GameProfileCache(authenticationservice.createProfileRepository(), new File(Minecraft.getInstance().gameDirectory, MinecraftServer.USERID_CACHE_FILE.getName()));
}
Also used : GameProfileCache(net.minecraft.server.players.GameProfileCache) YggdrasilAuthenticationService(com.mojang.authlib.yggdrasil.YggdrasilAuthenticationService) YggdrasilAuthenticationService(com.mojang.authlib.yggdrasil.YggdrasilAuthenticationService) AuthenticationService(com.mojang.authlib.AuthenticationService) File(java.io.File)

Example 2 with GameProfileCache

use of net.minecraft.server.players.GameProfileCache in project refinedstorage by refinedmods.

the class LevelUtils method getFakePlayer.

public static FakePlayer getFakePlayer(ServerLevel level, @Nullable UUID owner) {
    if (owner != null) {
        GameProfileCache profileCache = level.getServer().getProfileCache();
        Optional<GameProfile> profile = profileCache.get(owner);
        if (profile.isPresent()) {
            return FakePlayerFactory.get(level, profile.get());
        }
    }
    return FakePlayerFactory.getMinecraft(level);
}
Also used : GameProfile(com.mojang.authlib.GameProfile) GameProfileCache(net.minecraft.server.players.GameProfileCache)

Example 3 with GameProfileCache

use of net.minecraft.server.players.GameProfileCache in project SkyblockBuilder by MelanX.

the class ListCommand method listPlayers.

private static int listPlayers(CommandSourceStack source, String teamName) throws CommandSyntaxException {
    WorldUtil.checkSkyblock(source);
    ServerLevel level = source.getLevel();
    SkyblockSavedData data = SkyblockSavedData.get(level);
    Team team = data.getTeam(teamName);
    if (team == null) {
        source.sendSuccess(new TranslatableComponent("skyblockbuilder.command.error.team_not_exist").withStyle(ChatFormatting.RED), false);
        return 0;
    }
    GameProfileCache profileCache = source.getServer().getProfileCache();
    source.sendSuccess(new TranslatableComponent("skyblockbuilder.command.info.team_detailed", team.getName(), team.getPlayers().size()).withStyle(ChatFormatting.GOLD), false);
    team.getPlayers().forEach(id -> {
        Optional<GameProfile> profile = profileCache.get(id);
        if (profile.isPresent()) {
            String name = profile.get().getName();
            if (!StringUtil.isNullOrEmpty(name)) {
                source.sendSuccess(new TextComponent("- " + name), false);
            }
        }
    });
    return 1;
}
Also used : TextComponent(net.minecraft.network.chat.TextComponent) ServerLevel(net.minecraft.server.level.ServerLevel) SkyblockSavedData(de.melanx.skyblockbuilder.data.SkyblockSavedData) TranslatableComponent(net.minecraft.network.chat.TranslatableComponent) GameProfile(com.mojang.authlib.GameProfile) GameProfileCache(net.minecraft.server.players.GameProfileCache) Team(de.melanx.skyblockbuilder.data.Team)

Aggregations

GameProfileCache (net.minecraft.server.players.GameProfileCache)3 GameProfile (com.mojang.authlib.GameProfile)2 AuthenticationService (com.mojang.authlib.AuthenticationService)1 YggdrasilAuthenticationService (com.mojang.authlib.yggdrasil.YggdrasilAuthenticationService)1 SkyblockSavedData (de.melanx.skyblockbuilder.data.SkyblockSavedData)1 Team (de.melanx.skyblockbuilder.data.Team)1 File (java.io.File)1 TextComponent (net.minecraft.network.chat.TextComponent)1 TranslatableComponent (net.minecraft.network.chat.TranslatableComponent)1 ServerLevel (net.minecraft.server.level.ServerLevel)1