类net.minecraft.util.com.mojang.authlib.GameProfile源码实例Demo

下面列出了怎么用net.minecraft.util.com.mojang.authlib.GameProfile的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: PingAPI   文件: ServerInfoPacketHandler.java
/**
 * Creates a new PacketStatusOutServerInfo packet from the data found in a PingReply instance
 * @param reply The PingReply instance
 * @return A PacketStatusOutServerInfo packet
 */
public static PacketStatusOutServerInfo constructPacket(PingReply reply) {
	GameProfile[] sample = new GameProfile[reply.getPlayerSample().size()];
	List<String> list = reply.getPlayerSample();
	for(int i = 0; i < list.size(); i++) {
		sample[i] = new GameProfile(UUID.randomUUID(), list.get(i));
	}
	ServerPingPlayerSample playerSample = new ServerPingPlayerSample(reply.getMaxPlayers(), reply.getOnlinePlayers());
	playerSample.a(sample);
	ServerPing ping = new ServerPing();
	ping.setMOTD(new ChatComponentText(reply.getMOTD()));
	ping.setPlayerSample(playerSample);
	ping.setServerInfo(new ServerPingServerData(reply.getProtocolName(), reply.getProtocolVersion()));
	ping.setFavicon(((CraftIconCache) reply.getIcon()).value);
	return new PacketStatusOutServerInfo(ping);
}
 
源代码2 项目: PingAPI   文件: ServerInfoPacketHandler.java
/**
 * Creates a new PingReply instance from the data found in a PacketStatusOutServerInfo packet
 * @param packet The PacketStatusOutServerInfo instance
 * @param ctx The ChannelHandlerContext instance
 * @return A PingReply instance
 */
public static PingReply constructReply(PacketStatusOutServerInfo packet, ChannelHandlerContext ctx) {
	try {
		ServerPing ping = (ServerPing) SERVER_PING_FIELD.get(packet);
		String motd = ChatSerializer.a(ping.a());
		int max = ping.b().a();
		int online = ping.b().b();
		int protocolVersion = ping.c().b();
		String protocolName = ping.c().a();
		GameProfile[] profiles = ping.b().c();
		List<String> list = new ArrayList<String>();
		for(int i = 0; i < profiles.length; i++) {
			list.add(profiles[i].getName());
		}
		PingReply reply = new PingReply(ctx, motd, online, max, protocolVersion, protocolName, list);
		return reply;
	} catch(IllegalAccessException e) {
		e.printStackTrace();
	}
	return null;
}
 
源代码3 项目: PingAPI   文件: ServerInfoPacketHandler.java
/**
 * Creates a new PacketStatusOutServerInfo packet from the data found in a PingReply instance
 * @param reply The PingReply instance
 * @return A PacketStatusOutServerInfo packet
 */
public static PacketStatusOutServerInfo constructPacket(PingReply reply) {
	GameProfile[] sample = new GameProfile[reply.getPlayerSample().size()];
	List<String> list = reply.getPlayerSample();
	for(int i = 0; i < list.size(); i++) {
		sample[i] = new GameProfile(UUID.randomUUID(), list.get(i));
	}
	ServerPingPlayerSample playerSample = new ServerPingPlayerSample(reply.getMaxPlayers(), reply.getOnlinePlayers());
       playerSample.a(sample);
       ServerPing ping = new ServerPing();
       ping.setMOTD(new ChatComponentText(reply.getMOTD()));
       ping.setPlayerSample(playerSample);
       ping.setServerInfo(new ServerPingServerData(reply.getProtocolName(), reply.getProtocolVersion()));
       ping.setFavicon(((CraftIconCache) reply.getIcon()).value);
       return new PacketStatusOutServerInfo(ping);
}
 
源代码4 项目: PingAPI   文件: ServerInfoPacketHandler.java
/**
 * Creates a new PingReply instance from the data found in a PacketStatusOutServerInfo packet
 * @param packet The PacketStatusOutServerInfo instance
 * @param ctx The ChannelHandlerContext instance
 * @return A PingReply instance
 */
public static PingReply constructReply(PacketStatusOutServerInfo packet, ChannelHandlerContext ctx) {
	try {
		ServerPing ping = (ServerPing) SERVER_PING_FIELD.get(packet);
		String motd = ChatSerializer.a(ping.a());
		int max = ping.b().a();
		int online = ping.b().b();
		int protocolVersion = ping.c().b();
		String protocolName = ping.c().a();
		GameProfile[] profiles = ping.b().c();
		List<String> list = new ArrayList<String>();
		for(int i = 0; i < profiles.length; i++) {
			list.add(profiles[i].getName());
		}
		PingReply reply = new PingReply(ctx, motd, online, max, protocolVersion, protocolName, list);
		return reply;
	} catch(IllegalAccessException e) {
		e.printStackTrace();
	}
	return null;
}
 
源代码5 项目: PingAPI   文件: ServerInfoPacketHandler.java
/**
 * Creates a new PacketStatusOutServerInfo packet from the data found in a PingReply instance
 * @param reply The PingReply instance
 * @return A PacketStatusOutServerInfo packet
 */
public static PacketStatusOutServerInfo constructPacket(PingReply reply) {
	GameProfile[] sample = new GameProfile[reply.getPlayerSample().size()];
	List<String> list = reply.getPlayerSample();
	for(int i = 0; i < list.size(); i++) {
		sample[i] = new GameProfile(UUID.randomUUID(), list.get(i));
	}
	ServerPingPlayerSample playerSample = new ServerPingPlayerSample(reply.getMaxPlayers(), reply.getOnlinePlayers());
       playerSample.a(sample);
       ServerPing ping = new ServerPing();
       ping.setMOTD(new ChatComponentText(reply.getMOTD()));
       ping.setPlayerSample(playerSample);
       ping.setServerInfo(new ServerPingServerData(reply.getProtocolName(), reply.getProtocolVersion()));
       ping.setFavicon(((CraftIconCache) reply.getIcon()).value);
       return new PacketStatusOutServerInfo(ping);
}
 
源代码6 项目: PingAPI   文件: ServerInfoPacketHandler.java
/**
 * Creates a new PingReply instance from the data found in a PacketStatusOutServerInfo packet
 * @param packet The PacketStatusOutServerInfo instance
 * @param ctx The ChannelHandlerContext instance
 * @return A PingReply instance
 */
public static PingReply constructReply(PacketStatusOutServerInfo packet, ChannelHandlerContext ctx) {
	try {
		ServerPing ping = (ServerPing) SERVER_PING_FIELD.get(packet);
		String motd = ChatSerializer.a(ping.a());
		int max = ping.b().a();
		int online = ping.b().b();
		int protocolVersion = ping.c().b();
		String protocolName = ping.c().a();
		GameProfile[] profiles = ping.b().c();
		List<String> list = new ArrayList<String>();
		for(int i = 0; i < profiles.length; i++) {
			list.add(profiles[i].getName());
		}
		PingReply reply = new PingReply(ctx, motd, online, max, protocolVersion, protocolName, list);
		return reply;
	} catch(IllegalAccessException e) {
		e.printStackTrace();
	}
	return null;
}
 
源代码7 项目: Carbon   文件: OptimizedUserCache.java
@Override
public GameProfile getProfile(String name) {
	String playername = name.toLowerCase(Locale.ROOT);
	UserCacheEntry entry = stringToProfile.get(playername);
	if (entry != null && entry.isExpired()) {
		stringToProfile.remove(playername);
		uuidToProfile.remove(entry.getProfile().getId());
		return null;
	}
	if (entry != null) {
		uuidToProfile.get(entry.getProfile().getId()); //push profile to the top of access ordered linkedhashmap, do not remove this
		return entry.getProfile();
	} else {
		GameProfile profile = lookupProfile(MinecraftServer.getServer(), playername);
		if (profile != null) {
			a(profile);
			return profile;
		}
		return null;
	}
}
 
源代码8 项目: EntityAPI   文件: EntitySpawnHandler.java
@Override
public ControllablePlayerHandle createPlayerHandle(ControllablePlayer player, Location location, String name, UUID uuid) {
    WorldServer worldServer = ((CraftWorld) location.getWorld()).getHandle();

    if (name.length() > 16)
        name = name.substring(0, 16);

    GameProfile profile = new GameProfile(uuid.toString().replaceAll("-", ""), name);

    ControllablePlayerEntity handle = new ControllablePlayerEntity(worldServer.getMinecraftServer(), worldServer, profile, new PlayerInteractManager(worldServer), player);
    handle.setPositionRotation(location.getX(), location.getY(), location.getZ(), location.getYaw(), location.getPitch());
    worldServer.addEntity(handle);
    handle.world.players.remove(handle);

    if (location.getBlock().getRelative(BlockFace.DOWN).getType().isBlock())
        handle.onGround = true;

    return handle;
}
 
源代码9 项目: EntityAPI   文件: EntitySpawnHandler.java
@Override
public ControllablePlayerHandle createPlayerHandle(ControllablePlayer player, Location location, String name, UUID uuid) {
    WorldServer worldServer = ((CraftWorld) location.getWorld()).getHandle();

    if (name.length() > 16)
        name = name.substring(0, 16);

    GameProfile profile = new GameProfile(uuid.toString().replaceAll("-", ""), name);

    ControllablePlayerEntity handle = new ControllablePlayerEntity(worldServer.getMinecraftServer(), worldServer, profile, new PlayerInteractManager(worldServer), player);
    handle.setPositionRotation(location.getX(), location.getY(), location.getZ(), location.getYaw(), location.getPitch());
    worldServer.addEntity(handle);
    handle.world.players.remove(handle);

    if (location.getBlock().getRelative(BlockFace.DOWN).getType().isBlock())
        handle.onGround = true;

    return handle;
}
 
源代码10 项目: AnnihilationPro   文件: EntityNPCPlayer.java
public static GameProfile makeProfile(String name, UUID skinId) {
	GameProfile profile = new GameProfile(UUID.randomUUID(), name);
	if (skinId != null) {
		GameProfile skin = new GameProfile(skinId, null);
		skin = NMS.getServer().av().fillProfileProperties(skin, true); //Srg = func_147130_as
		if (skin.getProperties().get("textures") == null || !skin.getProperties().get("textures").isEmpty()) {
			Property textures = skin.getProperties().get("textures").iterator().next();
			profile.getProperties().put("textures", textures);
		}
	}
	return profile;	
}
 
源代码11 项目: Carbon   文件: OptimizedUserCache.java
@Override
public void a(GameProfile gameProfile) {
	String playername = gameProfile.getName().toLowerCase(Locale.ROOT);
	UUID uuid = gameProfile.getId();
	UserCacheEntry entry = new UserCacheEntry(gameProfile);
	if (uuidToProfile.containsKey(uuid)) {
		stringToProfile.remove(uuidToProfile.get(uuid).getProfile().getName().toLowerCase(Locale.ROOT));
		stringToProfile.put(playername, entry);
	} else {
		uuidToProfile.put(uuid, entry);
		stringToProfile.put(playername, entry);
	}
}
 
源代码12 项目: Carbon   文件: OptimizedUserCache.java
private GameProfile lookupProfile(MinecraftServer minecraftserver, String name) {
	GameProfile[] gameProfileArrayHolder = new GameProfile[1];
	GameProfileLookup gameProfileLookup = new GameProfileLookup(gameProfileArrayHolder);
	minecraftserver.getGameProfileRepository().findProfilesByNames(new String[] { name }, Agent.MINECRAFT, gameProfileLookup);
	if ((!minecraftserver.getOnlineMode()) && (gameProfileArrayHolder[0] == null)) {
		UUID uuid = EntityHuman.a(new GameProfile(null, name));
		GameProfile gameprofile = new GameProfile(uuid, name);
		gameProfileLookup.onProfileLookupSucceeded(gameprofile);
	}
	return gameProfileArrayHolder[0];
}
 
源代码13 项目: Carbon   文件: UserCacheEntryJsonSerializer.java
@Override
public UserCacheEntry deserialize(JsonElement element, Type type, JsonDeserializationContext ctx) throws JsonParseException {
	if (element.isJsonObject()) {
		JsonObject jsonobject = element.getAsJsonObject();
		JsonElement nameElement = jsonobject.get("name");
		JsonElement uuidElement = jsonobject.get("uuid");
		JsonElement expireDateElement = jsonobject.get("expiresOn");
		if ((nameElement != null) && (uuidElement != null)) {
			String name = uuidElement.getAsString();
			String uuidstring = nameElement.getAsString();
			Date date = null;
			if (expireDateElement != null) {
				try {
					date = UserCache.a.parse(expireDateElement.getAsString());
				} catch (ParseException parseexception) {
					date = null;
				}
			}
			if ((uuidstring != null) && (name != null)) {
				UUID uuid;
				try {
					uuid = UUID.fromString(name);
				} catch (Throwable throwable) {
					return null;
				}
				UserCacheEntry usercacheentry = new UserCacheEntry(new GameProfile(uuid, uuidstring), date);

				return usercacheentry;
			}
			return null;
		}
		return null;
	}
	return null;
}
 
源代码14 项目: Carbon   文件: UserCacheEntry.java
public UserCacheEntry(GameProfile profile) {
	this.profile = profile;
	Calendar calendar = Calendar.getInstance();
	calendar.setTime(new Date());
	calendar.add(Calendar.MONTH, 1);
	expireDate = calendar.getTime();
}
 
源代码15 项目: EntityAPI   文件: ControllablePlayerEntity.java
public ControllablePlayerEntity(MinecraftServer minecraftserver, WorldServer worldserver, GameProfile gameprofile, PlayerInteractManager playerinteractmanager) {
    super(minecraftserver, worldserver, gameprofile, playerinteractmanager);

    NetworkManager manager = new FixedNetworkManager();
    playerConnection = new NullPlayerConnection(server, manager, this);
    manager.a(playerConnection);

    noDamageTicks = 1;

    this.navigation = new PlayerNavigation(this, this.world);
    this.moveController = new PlayerControllerMove(this);
    this.lookController = new PlayerControllerLook(this);
    this.jumpController = new PlayerControllerJump(this);
}
 
源代码16 项目: EntityAPI   文件: ControllablePlayerEntity.java
public ControllablePlayerEntity(MinecraftServer minecraftserver, WorldServer worldserver, GameProfile gameprofile, PlayerInteractManager playerinteractmanager) {
    super(minecraftserver, worldserver, gameprofile, playerinteractmanager);

    NetworkManager manager = new FixedNetworkManager();
    playerConnection = new NullPlayerConnection(server, manager, this);
    manager.a(playerConnection);

    noDamageTicks = 1;

    this.navigation = new PlayerNavigation(this, this.world);
    this.moveController = new PlayerControllerMove(this);
    this.lookController = new PlayerControllerLook(this);
    this.jumpController = new PlayerControllerJump(this);
}
 
源代码17 项目: EntityAPI   文件: ControllablePlayerEntity.java
public ControllablePlayerEntity(MinecraftServer minecraftServer, WorldServer worldServer, GameProfile gameProfile, PlayerInteractManager playerInteractManager, ControllablePlayer controllablePlayer) {
    this(minecraftServer, worldServer, gameProfile, playerInteractManager);
    this.controllableEntity = controllablePlayer;

    if (this.controllableEntity != null)
        initialise(minecraftServer);
}
 
源代码18 项目: EntityAPI   文件: ControllablePlayerEntity.java
public ControllablePlayerEntity(MinecraftServer minecraftserver, WorldServer worldserver, GameProfile gameprofile, PlayerInteractManager playerinteractmanager) {
    super(minecraftserver, worldserver, gameprofile, playerinteractmanager);

    initialise(minecraftserver);

    playerinteractmanager.b(EnumGamemode.SURVIVAL);

    this.noDamageTicks = 1;
    this.X = 1;
    this.fauxSleeping = true;
}
 
源代码19 项目: EntityAPI   文件: ControllablePlayerEntity.java
public ControllablePlayerEntity(MinecraftServer minecraftServer, WorldServer worldServer, GameProfile gameProfile, PlayerInteractManager playerInteractManager, ControllablePlayer controllablePlayer) {
    this(minecraftServer, worldServer, gameProfile, playerInteractManager);
    this.controllableEntity = controllablePlayer;

    if (this.controllableEntity != null)
        initialise(minecraftServer);
}
 
源代码20 项目: EntityAPI   文件: ControllablePlayerEntity.java
public ControllablePlayerEntity(MinecraftServer minecraftserver, WorldServer worldserver, GameProfile gameprofile, PlayerInteractManager playerinteractmanager) {
    super(minecraftserver, worldserver, gameprofile, playerinteractmanager);

    initialise(minecraftserver);

    playerinteractmanager.b(EnumGamemode.SURVIVAL);

    this.noDamageTicks = 1;
    this.X = 1;
    this.fauxSleeping = true;
}
 
源代码21 项目: Carbon   文件: OptimizedUserCache.java
@Override
public GameProfile a(UUID uuid) {
	UserCacheEntry entry = uuidToProfile.get(uuid);
	return entry == null ? null : entry.getProfile();
}
 
源代码22 项目: Carbon   文件: UserCacheEntry.java
public UserCacheEntry(GameProfile profile, Date date) {
	this.profile = profile;
	this.expireDate = date;
}
 
源代码23 项目: Carbon   文件: UserCacheEntry.java
public GameProfile getProfile() {
	return profile;
}
 
源代码24 项目: Carbon   文件: GameProfileLookup.java
public GameProfileLookup(GameProfile[] gameProfileHolderArray) {
	this.gameProfileHolderArray = gameProfileHolderArray;
}
 
源代码25 项目: Carbon   文件: GameProfileLookup.java
@Override
public void onProfileLookupFailed(GameProfile profile, Exception exception) {
	this.gameProfileHolderArray[0] = null;
}
 
源代码26 项目: Carbon   文件: GameProfileLookup.java
@Override
public void onProfileLookupSucceeded(GameProfile profile) {
	this.gameProfileHolderArray[0] = profile;
}
 
源代码27 项目: EntityAPI   文件: ControllablePlayerEntity.java
public ControllablePlayerEntity(MinecraftServer minecraftServer, WorldServer worldServer, GameProfile gameProfile, PlayerInteractManager playerInteractManager, ControllablePlayer controllablePlayer) {
    this(minecraftServer, worldServer, gameProfile, playerInteractManager);
    this.controllablePlayer = controllablePlayer;
}
 
源代码28 项目: EntityAPI   文件: ControllablePlayerEntity.java
public ControllablePlayerEntity(MinecraftServer minecraftServer, WorldServer worldServer, GameProfile gameProfile, PlayerInteractManager playerInteractManager, ControllablePlayer controllablePlayer) {
    this(minecraftServer, worldServer, gameProfile, playerInteractManager);
    this.controllablePlayer = controllablePlayer;
}
 
 类所在包
 同包方法