本文整理汇总了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();
}
示例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;
}
}
示例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;
}
示例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;
}
示例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;
}
示例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_;
}
}
示例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();
}
示例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;
}
示例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 ;
}
示例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 ;
}
示例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;
}