當前位置: 首頁>>代碼示例>>Java>>正文


Java GameProfile.getId方法代碼示例

本文整理匯總了Java中com.mojang.authlib.GameProfile.getId方法的典型用法代碼示例。如果您正苦於以下問題:Java GameProfile.getId方法的具體用法?Java GameProfile.getId怎麽用?Java GameProfile.getId使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在com.mojang.authlib.GameProfile的用法示例。


在下文中一共展示了GameProfile.getId方法的11個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: fetchUUID

import com.mojang.authlib.GameProfile; //導入方法依賴的package包/類
public static UUID fetchUUID(String name)
{
    GameProfile profile = WorldBorder.SERVER
        .getPlayerProfileCache()
        .getGameProfileForUsername(name);

    if (profile == null)
        throw new RuntimeException(name + " is not a valid user");
    else
        return profile.getId();
}
 
開發者ID:abused,項目名稱:World-Border,代碼行數:12,代碼來源:Profiles.java

示例2: convertMobOwnerIfNeeded

import com.mojang.authlib.GameProfile; //導入方法依賴的package包/類
public static String convertMobOwnerIfNeeded(final MinecraftServer server, String username)
{
    if (!StringUtils.isNullOrEmpty(username) && username.length() <= 16)
    {
        GameProfile gameprofile = server.getPlayerProfileCache().getGameProfileForUsername(username);

        if (gameprofile != null && gameprofile.getId() != null)
        {
            return gameprofile.getId().toString();
        }
        else if (!server.isSinglePlayer() && server.isServerInOnlineMode())
        {
            final List<GameProfile> list = Lists.<GameProfile>newArrayList();
            ProfileLookupCallback profilelookupcallback = new ProfileLookupCallback()
            {
                public void onProfileLookupSucceeded(GameProfile p_onProfileLookupSucceeded_1_)
                {
                    server.getPlayerProfileCache().addEntry(p_onProfileLookupSucceeded_1_);
                    list.add(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_});
                }
            };
            lookupNames(server, Lists.newArrayList(new String[] {username}), profilelookupcallback);
            return !list.isEmpty() && ((GameProfile)list.get(0)).getId() != null ? ((GameProfile)list.get(0)).getId().toString() : "";
        }
        else
        {
            return EntityPlayer.getUUID(new GameProfile((UUID)null, username)).toString();
        }
    }
    else
    {
        return username;
    }
}
 
開發者ID:F1r3w477,項目名稱:CustomWorldGen,代碼行數:39,代碼來源:PreYggdrasilConverter.java

示例3: hasPlayerHacked

import com.mojang.authlib.GameProfile; //導入方法依賴的package包/類
public boolean hasPlayerHacked(EntityPlayer player) {
    for (int i = 0; i < hackedUsers.size(); i++) {
        GameProfile user = hackedUsers.get(i);
        if (gameProfileEquals(user, player.getGameProfile())) {
            if (user.getId() == null && player.getGameProfile().getId() != null) {
                hackedUsers.set(i, player.getGameProfile());
                Log.info("Legacy conversion: Security Station hacked username '" + player.getName() + "' is now using UUID '" + player.getGameProfile().getId() + "'.");
            }
            return true;
        }
    }
    return false;
}
 
開發者ID:TeamPneumatic,項目名稱:pnc-repressurized,代碼行數:14,代碼來源:TileEntitySecurityStation.java

示例4: getUUID

import com.mojang.authlib.GameProfile; //導入方法依賴的package包/類
/**
 * Gets a players UUID given their GameProfie
 */
public static UUID getUUID(GameProfile profile)
{
    UUID uuid = profile.getId();

    if (uuid == null)
    {
        uuid = getOfflineUUID(profile.getName());
    }

    return uuid;
}
 
開發者ID:sudofox,項目名稱:Backmemed,代碼行數:15,代碼來源:EntityPlayer.java

示例5: 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

示例6: getStringUUIDFromName

import com.mojang.authlib.GameProfile; //導入方法依賴的package包/類
public static String getStringUUIDFromName(String p_152719_0_)
{
    if (!StringUtils.isNullOrEmpty(p_152719_0_) && p_152719_0_.length() <= 16)
    {
        final MinecraftServer minecraftserver = MinecraftServer.getServer();
        GameProfile gameprofile = minecraftserver.getPlayerProfileCache().getGameProfileForUsername(p_152719_0_);

        if (gameprofile != null && gameprofile.getId() != null)
        {
            return gameprofile.getId().toString();
        }
        else if (!minecraftserver.isSinglePlayer() && minecraftserver.isServerInOnlineMode())
        {
            final List<GameProfile> list = Lists.<GameProfile>newArrayList();
            ProfileLookupCallback profilelookupcallback = new ProfileLookupCallback()
            {
                public void onProfileLookupSucceeded(GameProfile p_onProfileLookupSucceeded_1_)
                {
                    minecraftserver.getPlayerProfileCache().addEntry(p_onProfileLookupSucceeded_1_);
                    list.add(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_);
                }
            };
            lookupNames(minecraftserver, Lists.newArrayList(new String[] {p_152719_0_}), profilelookupcallback);
            return list.size() > 0 && ((GameProfile)list.get(0)).getId() != null ? ((GameProfile)list.get(0)).getId().toString() : "";
        }
        else
        {
            return EntityPlayer.getUUID(new GameProfile((UUID)null, p_152719_0_)).toString();
        }
    }
    else
    {
        return p_152719_0_;
    }
}
 
開發者ID:SkidJava,項目名稱:BaseClient,代碼行數:40,代碼來源:PreYggdrasilConverter.java

示例7: addEntry

import com.mojang.authlib.GameProfile; //導入方法依賴的package包/類
/**
 * Add an entry to this cache
 */
private void addEntry(GameProfile gameProfile, Date expirationDate)
{
    UUID uuid = gameProfile.getId();

    if (expirationDate == null)
    {
        Calendar calendar = Calendar.getInstance();
        calendar.setTime(new Date());
        calendar.add(2, 1);
        expirationDate = calendar.getTime();
    }

    String s = gameProfile.getName().toLowerCase(Locale.ROOT);
    PlayerProfileCache.ProfileEntry playerprofilecache$profileentry = new PlayerProfileCache.ProfileEntry(gameProfile, expirationDate);

    if (this.uuidToProfileEntryMap.containsKey(uuid))
    {
        PlayerProfileCache.ProfileEntry playerprofilecache$profileentry1 = (PlayerProfileCache.ProfileEntry)this.uuidToProfileEntryMap.get(uuid);
        this.usernameToProfileEntryMap.remove(playerprofilecache$profileentry1.getGameProfile().getName().toLowerCase(Locale.ROOT));
        this.gameProfiles.remove(gameProfile);
    }

    this.usernameToProfileEntryMap.put(gameProfile.getName().toLowerCase(Locale.ROOT), playerprofilecache$profileentry);
    this.uuidToProfileEntryMap.put(uuid, playerprofilecache$profileentry);
    this.gameProfiles.addFirst(gameProfile);
    this.save();
}
 
開發者ID:SkidJava,項目名稱:BaseClient,代碼行數:31,代碼來源:PlayerProfileCache.java

示例8: isBlocked

import com.mojang.authlib.GameProfile; //導入方法依賴的package包/類
/**
 * Called from {@link NetHandlerLoginServer#tryAcceptPlayer()}
 */
public static boolean isBlocked(NetHandlerLoginServer login, GameProfile profile) {
    if(profile == null) return false;

    UUID uuid = profile.getId();
    if(uuid == null) return false;

    if(Blocker.isBlocked(uuid)) {
        login.func_194026_b(new TextComponentString(Blocker.MESSAGE));
        return true;
    }
    return false;
}
 
開發者ID:Guichaguri,項目名稱:BOHA,代碼行數:16,代碼來源:BlockerHooks.java

示例9: getUUIDFromName

import com.mojang.authlib.GameProfile; //導入方法依賴的package包/類
public static UUID getUUIDFromName ( String name ) {
  
	GameProfile profile = MinecraftServer . getServer ( ) . func_152358_ax ( ) . func_152655_a ( name ) ;
   
    if (profile != null) {
    
    	return profile . getId ( ) ;
    
    } else {
    
    	MineDonate . logError ( "Null profile for name[" + name + "]!" ) ;
    
    }
    
    return null ;
    
}
 
開發者ID:Pishka,項目名稱:MineDonate,代碼行數:18,代碼來源:Utils.java

示例10: getUUIDFromPlayer

import com.mojang.authlib.GameProfile; //導入方法依賴的package包/類
public static UUID getUUIDFromPlayer ( EntityPlayerMP serverPlayer ) {
	
    GameProfile profile = MinecraftServer . getServer ( ) . func_152358_ax ( ) . func_152655_a ( serverPlayer . getDisplayName ( ) ) ;
   
    if ( profile != null ) {
    	
        return profile . getId ( ) ;
        
    } else {
    	
    	MineDonate . logError ( "Null profile, for player[" + serverPlayer + "]!" ) ;
        
    }
    
    return null ;
    
}
 
開發者ID:Pishka,項目名稱:MineDonate,代碼行數:18,代碼來源:Utils.java

示例11: writeGameProfile

import com.mojang.authlib.GameProfile; //導入方法依賴的package包/類
/**
 * Writes a GameProfile to an NBTTagCompound.
 */
public static NBTTagCompound writeGameProfile(NBTTagCompound tagCompound, GameProfile profile)
{
    if (!StringUtils.isNullOrEmpty(profile.getName()))
    {
        tagCompound.setString("Name", profile.getName());
    }

    if (profile.getId() != null)
    {
        tagCompound.setString("Id", profile.getId().toString());
    }

    if (!profile.getProperties().isEmpty())
    {
        NBTTagCompound nbttagcompound = new NBTTagCompound();

        for (String s : profile.getProperties().keySet())
        {
            NBTTagList nbttaglist = new NBTTagList();

            for (Property property : profile.getProperties().get(s))
            {
                NBTTagCompound nbttagcompound1 = new NBTTagCompound();
                nbttagcompound1.setString("Value", property.getValue());

                if (property.hasSignature())
                {
                    nbttagcompound1.setString("Signature", property.getSignature());
                }

                nbttaglist.appendTag(nbttagcompound1);
            }

            nbttagcompound.setTag(s, nbttaglist);
        }

        tagCompound.setTag("Properties", nbttagcompound);
    }

    return tagCompound;
}
 
開發者ID:Notoh,項目名稱:DecompiledMinecraft,代碼行數:45,代碼來源:NBTUtil.java


注:本文中的com.mojang.authlib.GameProfile.getId方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。