當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。