当前位置: 首页>>代码示例>>Java>>正文


Java GameProfile.getName方法代码示例

本文整理汇总了Java中com.mojang.authlib.GameProfile.getName方法的典型用法代码示例。如果您正苦于以下问题:Java GameProfile.getName方法的具体用法?Java GameProfile.getName怎么用?Java GameProfile.getName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.mojang.authlib.GameProfile的用法示例。


在下文中一共展示了GameProfile.getName方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: build

import com.mojang.authlib.GameProfile; //导入方法依赖的package包/类
/**
 * Attempts to login with the specified username and password.
 * If the login is successful then a session will be created. If
 * not, {@code null} will be returned
 *
 * @return A valid session, if able to login, otherwise {@code null}
 */
@Override
public Session build() {
    UserAuthentication auth = new YggdrasilAuthenticationService(this.proxy, "").createUserAuthentication(Agent.MINECRAFT);
    auth.setUsername(this.username);
    auth.setPassword(this.password);

    try {
        auth.logIn();
    } catch (AuthenticationException e) {
        return null;
    }

    GameProfile profile = auth.getSelectedProfile();
    return new Session(profile.getName(), profile.getId().toString(), auth.getAuthenticatedToken(), "MOJANG");
}
 
开发者ID:ImpactDevelopment,项目名称:ClientAPI,代码行数:23,代码来源:SessionBuilder.java

示例2: fetchNames

import com.mojang.authlib.GameProfile; //导入方法依赖的package包/类
public static String[] fetchNames(UUID[] uuids)
{
    PlayerProfileCache cache = WorldBorder.SERVER.getPlayerProfileCache();
    String[]           names = new String[uuids.length];

    // Makes sure server reads from cache first
    cache.load();

    for (int i = 0; i < uuids.length; i++)
    {
        GameProfile profile = cache.getProfileByUUID(uuids[i]);

        names[i] = (profile != null)
            ? profile.getName()
            : "<unknown:" + uuids[i].toString() + ">";
    }

    return names;
}
 
开发者ID:abused,项目名称:World-Border,代码行数:20,代码来源:Profiles.java

示例3: serialize

import com.mojang.authlib.GameProfile; //导入方法依赖的package包/类
@Override
public JsonElement serialize(GameProfile profile, Type type, JsonSerializationContext context)
{
    JsonObject result = new JsonObject();
    if (profile.getId() != null)
    {
        result.add("uuid", context.serialize(profile.getId()));
    }

    if (profile.getName() != null)
    {
        result.addProperty("username", profile.getName());
    }

    if (!profile.getProperties().isEmpty())
    {
        result.add("properties", context.serialize(profile.getProperties()));
    }

    if (result.has("properties"))
    {
        JsonArray properties = result.getAsJsonArray("properties");
        for (JsonElement entry : properties)
        {
            JsonObject property = (JsonObject) entry;
            String value = property.getAsJsonPrimitive("value").getAsString();
            value = Base64Coder.decodeString(value);
            property.remove("value");
            property.add("value", new JsonParser().parse(value));
        }
    }

    return result;
}
 
开发者ID:SamaGames,项目名称:SamaGamesAPI,代码行数:35,代码来源:GameProfileBuilder.java

示例4: fromHandle

import com.mojang.authlib.GameProfile; //导入方法依赖的package包/类
public static GameProfileWrapper fromHandle(Object object) {
    Validate.isTrue(object instanceof GameProfile, "object is not a GameProfile");
    GameProfile gameProfile = (GameProfile) object;
    GameProfileWrapper wrapper = new GameProfileWrapper(gameProfile.getId(), gameProfile.getName());
    for (Map.Entry<String, Collection<Property>> entry : gameProfile.getProperties().asMap().entrySet()) {
        for (Property property : entry.getValue()) {
            wrapper.getProperties().put(entry.getKey(), PropertyWrapper.fromHandle(property));
        }
    }
    return wrapper;
}
 
开发者ID:Alvin-LB,项目名称:NameTagChanger,代码行数:12,代码来源:GameProfileWrapper.java

示例5: serialize

import com.mojang.authlib.GameProfile; //导入方法依赖的package包/类
public JsonElement serialize(GameProfile profile, Type type, JsonSerializationContext context) {
    JsonObject result = new JsonObject();
    if (profile.getId() != null)
        result.add("id", context.serialize(profile.getId()));
    if (profile.getName() != null)
        result.addProperty("name", profile.getName());
    if (!profile.getProperties().isEmpty())
        result.add("properties", context.serialize(profile.getProperties()));
    return result;
}
 
开发者ID:AlphaHelixDev,项目名称:AlphaLibary,代码行数:11,代码来源:JSONUtil.java

示例6: AbstractClientPlayer

import com.mojang.authlib.GameProfile; //导入方法依赖的package包/类
public AbstractClientPlayer(World worldIn, GameProfile playerProfile)
{
    super(worldIn, playerProfile);
    this.nameClear = playerProfile.getName();

    if (this.nameClear != null && !this.nameClear.isEmpty())
    {
        this.nameClear = StringUtils.stripControlCodes(this.nameClear);
    }

    CapeUtils.downloadCape(this);
    PlayerConfigurations.getPlayerConfiguration(this);
}
 
开发者ID:SkidJava,项目名称:BaseClient,代码行数:14,代码来源:AbstractClientPlayer.java

示例7: AbstractClientPlayer

import com.mojang.authlib.GameProfile; //导入方法依赖的package包/类
public AbstractClientPlayer(World worldIn, GameProfile playerProfile)
{
    super(worldIn, playerProfile);
    String s = playerProfile.getName();
    this.downloadCape(s);
    PlayerConfigurations.getPlayerConfiguration(this);
}
 
开发者ID:SkidJava,项目名称:BaseClient,代码行数:8,代码来源:AbstractClientPlayer.java

示例8: AbstractClientPlayer

import com.mojang.authlib.GameProfile; //导入方法依赖的package包/类
public AbstractClientPlayer(World worldIn, GameProfile playerProfile) {
  super(worldIn, playerProfile);
  this.nameClear = playerProfile.getName();

  if (this.nameClear != null && !this.nameClear.isEmpty()) {
    this.nameClear = StringUtils.stripControlCodes(this.nameClear);
  }

  //CapeUtils.downloadCape(this); // Optifine capes
  PlayerConfigurations.getPlayerConfiguration(this);

  CapesAPI.loadCape(playerProfile.getId());
}
 
开发者ID:halfpetal,项目名称:CapesAPI-ClientImplementation,代码行数:14,代码来源:AbstractClientPlayer.java

示例9: getNameFromUUID

import com.mojang.authlib.GameProfile; //导入方法依赖的package包/类
public static String getNameFromUUID ( UUID id ) {
  
	GameProfile profile = MinecraftServer . getServer ( ) . func_152358_ax ( ) . func_152652_a ( id ) ;
  
    if ( profile != null ) {
    
    	return profile . getName ( ) ;
  
    } else {
    
    	MineDonate . logError ( "Null profile, for id[" + id + "]!" ) ;
    
    }
    
    return "";
    
}
 
开发者ID:Pishka,项目名称:MineDonate,代码行数:18,代码来源:Utils.java

示例10: getNameFromComponent

import com.mojang.authlib.GameProfile; //导入方法依赖的package包/类
private String getNameFromComponent(GameProfile profile) {
    return Objects.nonNull(profile) ? profile.getName() : "";
}
 
开发者ID:fr1kin,项目名称:ForgeHax,代码行数:4,代码来源:LogoutSpot.java

示例11: getOfflineProfile

import com.mojang.authlib.GameProfile; //导入方法依赖的package包/类
protected GameProfile getOfflineProfile(GameProfile original)
{
    UUID uuid = UUID.nameUUIDFromBytes(("OfflinePlayer:" + original.getName()).getBytes(Charsets.UTF_8));
    return new GameProfile(uuid, original.getName());
}
 
开发者ID:Notoh,项目名称:DecompiledMinecraft,代码行数:6,代码来源:NetHandlerLoginServer.java

示例12: convertWhitelist

import com.mojang.authlib.GameProfile; //导入方法依赖的package包/类
@SideOnly(Side.SERVER)
public static boolean convertWhitelist(final MinecraftServer server) throws IOException
{
    final UserListWhitelist userlistwhitelist = new UserListWhitelist(PlayerList.FILE_WHITELIST);

    if (OLD_WHITELIST_FILE.exists() && OLD_WHITELIST_FILE.isFile())
    {
        if (userlistwhitelist.getSaveFile().exists())
        {
            try
            {
                userlistwhitelist.readSavedFile();
            }
            catch (FileNotFoundException filenotfoundexception)
            {
                LOGGER.warn("Could not load existing file {}", new Object[] {userlistwhitelist.getSaveFile().getName(), filenotfoundexception});
            }
        }

        try
        {
            List<String> list = Files.readLines(OLD_WHITELIST_FILE, Charsets.UTF_8);
            ProfileLookupCallback profilelookupcallback = new ProfileLookupCallback()
            {
                public void onProfileLookupSucceeded(GameProfile p_onProfileLookupSucceeded_1_)
                {
                    server.getPlayerProfileCache().addEntry(p_onProfileLookupSucceeded_1_);
                    userlistwhitelist.addEntry(new UserListWhitelistEntry(p_onProfileLookupSucceeded_1_));
                }
                public void onProfileLookupFailed(GameProfile p_onProfileLookupFailed_1_, Exception p_onProfileLookupFailed_2_)
                {
                    PreYggdrasilConverter.LOGGER.warn("Could not lookup user whitelist entry for {}", new Object[] {p_onProfileLookupFailed_1_.getName(), p_onProfileLookupFailed_2_});

                    if (!(p_onProfileLookupFailed_2_ instanceof ProfileNotFoundException))
                    {
                        throw new PreYggdrasilConverter.ConversionError("Could not request user " + p_onProfileLookupFailed_1_.getName() + " from backend systems", p_onProfileLookupFailed_2_);
                    }
                }
            };
            lookupNames(server, list, profilelookupcallback);
            userlistwhitelist.writeChanges();
            backupConverted(OLD_WHITELIST_FILE);
            return true;
        }
        catch (IOException ioexception)
        {
            LOGGER.warn((String)"Could not read old whitelist to convert it!", (Throwable)ioexception);
            return false;
        }
        catch (PreYggdrasilConverter.ConversionError preyggdrasilconverter$conversionerror)
        {
            LOGGER.error((String)"Conversion failed, please try again later", (Throwable)preyggdrasilconverter$conversionerror);
            return false;
        }
    }
    else
    {
        return true;
    }
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:61,代码来源:PreYggdrasilConverter.java

示例13: convertOplist

import com.mojang.authlib.GameProfile; //导入方法依赖的package包/类
public static boolean convertOplist(final MinecraftServer server) throws IOException
{
    final UserListOps userlistops = new UserListOps(ServerConfigurationManager.FILE_OPS);

    if (OLD_OPS_FILE.exists() && OLD_OPS_FILE.isFile())
    {
        if (userlistops.getSaveFile().exists())
        {
            try
            {
                userlistops.readSavedFile();
            }
            catch (FileNotFoundException filenotfoundexception)
            {
                LOGGER.warn((String)("Could not load existing file " + userlistops.getSaveFile().getName()), (Throwable)filenotfoundexception);
            }
        }

        try
        {
            List<String> list = Files.readLines(OLD_OPS_FILE, Charsets.UTF_8);
            ProfileLookupCallback profilelookupcallback = new ProfileLookupCallback()
            {
                public void onProfileLookupSucceeded(GameProfile p_onProfileLookupSucceeded_1_)
                {
                    server.getPlayerProfileCache().addEntry(p_onProfileLookupSucceeded_1_);
                    userlistops.addEntry(new UserListOpsEntry(p_onProfileLookupSucceeded_1_, server.getOpPermissionLevel(), false));
                }
                public void onProfileLookupFailed(GameProfile p_onProfileLookupFailed_1_, Exception p_onProfileLookupFailed_2_)
                {
                    PreYggdrasilConverter.LOGGER.warn((String)("Could not lookup oplist entry for " + p_onProfileLookupFailed_1_.getName()), (Throwable)p_onProfileLookupFailed_2_);

                    if (!(p_onProfileLookupFailed_2_ instanceof ProfileNotFoundException))
                    {
                        throw new PreYggdrasilConverter.ConversionError("Could not request user " + p_onProfileLookupFailed_1_.getName() + " from backend systems", p_onProfileLookupFailed_2_);
                    }
                }
            };
            lookupNames(server, list, profilelookupcallback);
            userlistops.writeChanges();
            backupConverted(OLD_OPS_FILE);
            return true;
        }
        catch (IOException ioexception)
        {
            LOGGER.warn((String)"Could not read old oplist to convert it!", (Throwable)ioexception);
            return false;
        }
        catch (PreYggdrasilConverter.ConversionError preyggdrasilconverter$conversionerror)
        {
            LOGGER.error((String)"Conversion failed, please try again later", (Throwable)preyggdrasilconverter$conversionerror);
            return false;
        }
    }
    else
    {
        return true;
    }
}
 
开发者ID:Notoh,项目名称:DecompiledMinecraft,代码行数:60,代码来源:PreYggdrasilConverter.java

示例14: convertWhitelist

import com.mojang.authlib.GameProfile; //导入方法依赖的package包/类
public static boolean convertWhitelist(final MinecraftServer server) throws IOException
{
    final UserListWhitelist userlistwhitelist = new UserListWhitelist(ServerConfigurationManager.FILE_WHITELIST);

    if (OLD_WHITELIST_FILE.exists() && OLD_WHITELIST_FILE.isFile())
    {
        if (userlistwhitelist.getSaveFile().exists())
        {
            try
            {
                userlistwhitelist.readSavedFile();
            }
            catch (FileNotFoundException filenotfoundexception)
            {
                LOGGER.warn((String)("Could not load existing file " + userlistwhitelist.getSaveFile().getName()), (Throwable)filenotfoundexception);
            }
        }

        try
        {
            List<String> list = Files.readLines(OLD_WHITELIST_FILE, Charsets.UTF_8);
            ProfileLookupCallback profilelookupcallback = new ProfileLookupCallback()
            {
                public void onProfileLookupSucceeded(GameProfile p_onProfileLookupSucceeded_1_)
                {
                    server.getPlayerProfileCache().addEntry(p_onProfileLookupSucceeded_1_);
                    userlistwhitelist.addEntry(new UserListWhitelistEntry(p_onProfileLookupSucceeded_1_));
                }
                public void onProfileLookupFailed(GameProfile p_onProfileLookupFailed_1_, Exception p_onProfileLookupFailed_2_)
                {
                    PreYggdrasilConverter.LOGGER.warn((String)("Could not lookup user whitelist entry for " + p_onProfileLookupFailed_1_.getName()), (Throwable)p_onProfileLookupFailed_2_);

                    if (!(p_onProfileLookupFailed_2_ instanceof ProfileNotFoundException))
                    {
                        throw new PreYggdrasilConverter.ConversionError("Could not request user " + p_onProfileLookupFailed_1_.getName() + " from backend systems", p_onProfileLookupFailed_2_);
                    }
                }
            };
            lookupNames(server, list, profilelookupcallback);
            userlistwhitelist.writeChanges();
            backupConverted(OLD_WHITELIST_FILE);
            return true;
        }
        catch (IOException ioexception)
        {
            LOGGER.warn((String)"Could not read old whitelist to convert it!", (Throwable)ioexception);
            return false;
        }
        catch (PreYggdrasilConverter.ConversionError preyggdrasilconverter$conversionerror)
        {
            LOGGER.error((String)"Conversion failed, please try again later", (Throwable)preyggdrasilconverter$conversionerror);
            return false;
        }
    }
    else
    {
        return true;
    }
}
 
开发者ID:Notoh,项目名称:DecompiledMinecraft,代码行数:60,代码来源:PreYggdrasilConverter.java

示例15: convertOplist

import com.mojang.authlib.GameProfile; //导入方法依赖的package包/类
@SideOnly(Side.SERVER)
public static boolean convertOplist(final MinecraftServer server) throws IOException
{
    final UserListOps userlistops = new UserListOps(PlayerList.FILE_OPS);

    if (OLD_OPS_FILE.exists() && OLD_OPS_FILE.isFile())
    {
        if (userlistops.getSaveFile().exists())
        {
            try
            {
                userlistops.readSavedFile();
            }
            catch (FileNotFoundException filenotfoundexception)
            {
                LOGGER.warn("Could not load existing file {}", new Object[] {userlistops.getSaveFile().getName(), filenotfoundexception});
            }
        }

        try
        {
            List<String> list = Files.readLines(OLD_OPS_FILE, Charsets.UTF_8);
            ProfileLookupCallback profilelookupcallback = new ProfileLookupCallback()
            {
                public void onProfileLookupSucceeded(GameProfile p_onProfileLookupSucceeded_1_)
                {
                    server.getPlayerProfileCache().addEntry(p_onProfileLookupSucceeded_1_);
                    userlistops.addEntry(new UserListOpsEntry(p_onProfileLookupSucceeded_1_, server.getOpPermissionLevel(), false));
                }
                public void onProfileLookupFailed(GameProfile p_onProfileLookupFailed_1_, Exception p_onProfileLookupFailed_2_)
                {
                    PreYggdrasilConverter.LOGGER.warn("Could not lookup oplist entry for {}", new Object[] {p_onProfileLookupFailed_1_.getName(), p_onProfileLookupFailed_2_});

                    if (!(p_onProfileLookupFailed_2_ instanceof ProfileNotFoundException))
                    {
                        throw new PreYggdrasilConverter.ConversionError("Could not request user " + p_onProfileLookupFailed_1_.getName() + " from backend systems", p_onProfileLookupFailed_2_);
                    }
                }
            };
            lookupNames(server, list, profilelookupcallback);
            userlistops.writeChanges();
            backupConverted(OLD_OPS_FILE);
            return true;
        }
        catch (IOException ioexception)
        {
            LOGGER.warn((String)"Could not read old oplist to convert it!", (Throwable)ioexception);
            return false;
        }
        catch (PreYggdrasilConverter.ConversionError preyggdrasilconverter$conversionerror)
        {
            LOGGER.error((String)"Conversion failed, please try again later", (Throwable)preyggdrasilconverter$conversionerror);
            return false;
        }
    }
    else
    {
        return true;
    }
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:61,代码来源:PreYggdrasilConverter.java


注:本文中的com.mojang.authlib.GameProfile.getName方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。