本文整理汇总了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");
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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);
}
示例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);
}
示例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());
}
示例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 "";
}
示例10: getNameFromComponent
import com.mojang.authlib.GameProfile; //导入方法依赖的package包/类
private String getNameFromComponent(GameProfile profile) {
return Objects.nonNull(profile) ? profile.getName() : "";
}
示例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());
}
示例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;
}
}
示例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;
}
}
示例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;
}
}
示例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;
}
}