本文整理汇总了Java中com.github.steveice10.mc.auth.data.GameProfile类的典型用法代码示例。如果您正苦于以下问题:Java GameProfile类的具体用法?Java GameProfile怎么用?Java GameProfile使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
GameProfile类属于com.github.steveice10.mc.auth.data包,在下文中一共展示了GameProfile类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: run
import com.github.steveice10.mc.auth.data.GameProfile; //导入依赖的package包/类
@Override
public void run() {
try {
GameProfile profile = session.getFlag(MinecraftConstants.PROFILE_KEY);
String ep = "/account/" + (register ? "register" : "checkLogin");
String args = "username=" + URLEncoder.encode(profile.getName(), "UTF-8")
+ "&password=" + URLEncoder.encode(password, "UTF-8");
if(register) {
args += "&uuid=" + URLEncoder.encode(SessionUtils.getUUID(profile).toString(), "UTF-8");
}
JsonObject result = URUtils.request(ep, args);
String error = URUtils.checkError(result);
if(error != null) {
session.getFlags().remove(AuthProcessor.FLAG_ACCOUNT_TASK_KEY);
callback.call(false, Lang.PLAYER_FAILED.build(register ? Lang.ACTION_REGISTRATION.build() : Lang.ACTION_LOGIN.build(), error));
return;
}
callback.call(true, null);
}catch (Exception e){
e.printStackTrace();
callback.call(false, Lang.SERVER_ERROR.build());
}
}
开发者ID:DragonetMC,项目名称:AuthServer,代码行数:24,代码来源:PlayerAccountTask.java
示例2: getPlayers
import com.github.steveice10.mc.auth.data.GameProfile; //导入依赖的package包/类
private GameProfile[] getPlayers(Config config) {
boolean disabled = Boolean.parseBoolean(config.get("disabledSlots"));
if (disabled) {
return new GameProfile[0];
}
Properties properties = config.getProperties();
Set<String> propertyNames = properties.stringPropertyNames();
List<GameProfile> profiles = new ArrayList<>();
propertyNames.stream()
.filter(key -> key.startsWith("fakePlayer."))
.forEach(key -> {
String playerName = key.replace("fakePlayer.", "");
UUID uuid = UUID.fromString(properties.getProperty(key));
profiles.add(new GameProfile(uuid, playerName));
});
return profiles.toArray(new GameProfile[profiles.size()]);
}
开发者ID:games647,项目名称:MinecraftVerificationServer,代码行数:22,代码来源:ServerInfoListener.java
示例3: fillProfileProperties
import com.github.steveice10.mc.auth.data.GameProfile; //导入依赖的package包/类
/**
* Fills in the properties of a profile.
*
* @param profile Profile to fill in the properties of.
* @return The given profile, after filling in its properties.
* @throws ProfileException If the property lookup fails.
*/
public GameProfile fillProfileProperties(GameProfile profile) throws ProfileException {
if(profile.getId() == null) {
return profile;
}
try {
MinecraftProfileResponse response = HTTP.makeRequest(this.proxy, PROFILE_URL + "/" + UUIDSerializer.fromUUID(profile.getId()) + "?unsigned=false", null, MinecraftProfileResponse.class);
if(response == null) {
throw new ProfileNotFoundException("Couldn't fetch profile properties for " + profile + " as the profile does not exist.");
}
if(response.properties != null) {
profile.getProperties().addAll(response.properties);
}
return profile;
} catch(RequestException e) {
throw new ProfileLookupException("Couldn't look up profile properties for " + profile + ".", e);
}
}
开发者ID:surgeplay,项目名称:Visage,代码行数:28,代码来源:SessionService.java
示例4: selectGameProfile
import com.github.steveice10.mc.auth.data.GameProfile; //导入依赖的package包/类
/**
* Selects a game profile.
*
* @param profile Profile to select.
* @throws RequestException If an error occurs while making the request.
*/
public void selectGameProfile(GameProfile profile) throws RequestException {
if(!this.loggedIn) {
throw new RequestException("Cannot change game profile while not logged in.");
} else if(this.selectedProfile != null) {
throw new RequestException("Cannot change game profile when it is already selected.");
} else if(profile != null && this.profiles.contains(profile)) {
RefreshRequest request = new RefreshRequest(this.clientToken, this.accessToken, profile);
RefreshResponse response = HTTP.makeRequest(this.proxy, REFRESH_URL, request, RefreshResponse.class);
if(response.clientToken.equals(this.clientToken)) {
this.accessToken = response.accessToken;
this.selectedProfile = response.selectedProfile;
} else {
throw new RequestException("Server requested we change our client token. Don't know how to handle this!");
}
} else {
throw new IllegalArgumentException("Invalid profile '" + profile + "'.");
}
}
开发者ID:surgeplay,项目名称:Visage,代码行数:25,代码来源:AuthenticationService.java
示例5: readGameProfile
import com.github.steveice10.mc.auth.data.GameProfile; //导入依赖的package包/类
public static GameProfile readGameProfile(DataInputStream data) throws IOException {
boolean present = data.readBoolean();
if (!present)
return new GameProfile(new UUID(0, 0), "<unknown>");
UUID uuid = new UUID(data.readLong(), data.readLong());
String name = data.readUTF();
GameProfile profile = new GameProfile(uuid, name);
int len = data.readUnsignedShort();
for (int i = 0; i < len; i++) {
TextureType type = TextureType.values()[data.readUnsignedByte()];
TextureModel model = TextureModel.values()[data.readUnsignedByte()];
String url = data.readUTF();
Map<String, String> m = Maps.newHashMap();
m.put("model", model.name().toLowerCase(Locale.ROOT));
profile.getTextures().put(type, new Texture(url, m));
}
return profile;
}
开发者ID:surgeplay,项目名称:Visage,代码行数:19,代码来源:Profiles.java
示例6: writeGameProfile
import com.github.steveice10.mc.auth.data.GameProfile; //导入依赖的package包/类
public static void writeGameProfile(DataOutputStream data, GameProfile profile) throws IOException {
if (profile == null) {
data.writeBoolean(false);
return;
}
data.writeBoolean(true);
data.writeLong(profile.getId().getMostSignificantBits());
data.writeLong(profile.getId().getLeastSignificantBits());
data.writeUTF(profile.getName());
data.writeShort(profile.getTextures().size());
for (Map.Entry<TextureType, Texture> en : profile.getTextures().entrySet()) {
data.writeByte(en.getKey().ordinal());
data.writeByte(en.getValue().getModel().ordinal());
data.writeUTF(en.getValue().getURL());
}
}
开发者ID:surgeplay,项目名称:Visage,代码行数:17,代码来源:Profiles.java
示例7: onPlayerLoggedIn
import com.github.steveice10.mc.auth.data.GameProfile; //导入依赖的package包/类
public void onPlayerLoggedIn(Session session){
GameProfile profile = session.getFlag(MinecraftConstants.PROFILE_KEY);
session.addListener(new AuthSession(session));
server.getLogger().info(Lang.SERVER_PLAYER_JOINED.build(profile.getName(), session.getRemoteAddress().toString()));
boolean cached = playerCache.contains(profile.getName().toLowerCase());
if(cached) {
onPlayerStatusFetched(session, true);
} else {
SessionUtils.sendChat(session, Lang.PLAYER_LOADING.build());
Future f = threads.submit(new PlayerStatusChecker(session, profile, (r) -> onPlayerStatusFetched(session, r)));
session.setFlag(FLAG_CHECK_TASK_KEY, f);
}
}
开发者ID:DragonetMC,项目名称:AuthServer,代码行数:14,代码来源:AuthProcessor.java
示例8: ServerInfoListener
import com.github.steveice10.mc.auth.data.GameProfile; //导入依赖的package包/类
public ServerInfoListener(VerificationServer verificationServer, Config config) throws IOException {
this.verificationServer = verificationServer;
int onlinePlayers = Integer.parseInt(config.get("onlinePlayers"));
int maxPlayers = Integer.parseInt(config.get("maxPlayers"));
GameProfile[] players = getPlayers(config);
playerInfo = new PlayerInfo(onlinePlayers, maxPlayers, players);
String motd = config.get("motd");
textMessage = new TextMessage(motd);
String version = config.get("version");
if (version.trim().isEmpty()) {
version = MinecraftConstants.GAME_VERSION;
}
this.gameVersion = version;
String protocol = config.get("protocol");
if (protocol.trim().isEmpty()) {
this.protocolVersion = MinecraftConstants.PROTOCOL_VERSION;
} else {
this.protocolVersion = Integer.parseInt(protocol);
}
Path file = Paths.get("favicon.png");
if (Files.exists(file)) {
favicon = ImageIO.read(file.toFile());
} else {
favicon = null;
}
}
开发者ID:games647,项目名称:MinecraftVerificationServer,代码行数:33,代码来源:ServerInfoListener.java
示例9: loggedIn
import com.github.steveice10.mc.auth.data.GameProfile; //导入依赖的package包/类
@Override
public void loggedIn(Session session) {
String host = session.getHost();
GameProfile profile = session.getFlag(MinecraftConstants.PROFILE_KEY);
final UUID uuid = profile.getId();
final String username = profile.getName();
VerificationServer.getLogger().info("Session verified: {} {}", uuid, username);
verificationServer.getExecutor().execute(() -> saveVerification(uuid, username, host, session));
}
开发者ID:games647,项目名称:MinecraftVerificationServer,代码行数:12,代码来源:LoginListener.java
示例10: getProfileByServer
import com.github.steveice10.mc.auth.data.GameProfile; //导入依赖的package包/类
/**
* Gets the profile of the given user if they are currently logged in to the given server.
*
* @param name Name of the user to get the profile of.
* @param serverId ID of the server to check if they're logged in to.
* @return The profile of the given user, or null if they are not logged in to the given server.
* @throws RequestException If an error occurs while making the request.
*/
public GameProfile getProfileByServer(String name, String serverId) throws RequestException {
HasJoinedResponse response = HTTP.makeRequest(this.proxy, HAS_JOINED_URL + "?username=" + name + "&serverId=" + serverId, null, HasJoinedResponse.class);
if(response != null && response.id != null) {
GameProfile result = new GameProfile(response.id, name);
if(response.properties != null) {
result.getProperties().addAll(response.properties);
}
return result;
} else {
return null;
}
}
开发者ID:surgeplay,项目名称:Visage,代码行数:22,代码来源:SessionService.java
示例11: loginWithPassword
import com.github.steveice10.mc.auth.data.GameProfile; //导入依赖的package包/类
private void loginWithPassword() throws RequestException {
if(this.username == null || this.username.isEmpty()) {
throw new InvalidCredentialsException("Invalid username.");
} else if(this.password == null || this.password.isEmpty()) {
throw new InvalidCredentialsException("Invalid password.");
} else {
AuthenticationRequest request = new AuthenticationRequest(this.username, this.password, this.clientToken);
AuthenticationResponse response = HTTP.makeRequest(this.proxy, AUTHENTICATE_URL, request, AuthenticationResponse.class);
if(response.clientToken.equals(this.clientToken)) {
if(response.user != null && response.user.id != null) {
this.id = response.user.id;
} else {
this.id = this.username;
}
this.loggedIn = true;
this.accessToken = response.accessToken;
this.profiles = response.availableProfiles != null ? Arrays.asList(response.availableProfiles) : Collections.<GameProfile>emptyList();
this.selectedProfile = response.selectedProfile;
this.properties.clear();
if(response.user != null && response.user.properties != null) {
this.properties.addAll(response.user.properties);
}
} else {
throw new RequestException("Server requested we change our client token. Don't know how to handle this!");
}
}
}
开发者ID:surgeplay,项目名称:Visage,代码行数:29,代码来源:AuthenticationService.java
示例12: loginWithToken
import com.github.steveice10.mc.auth.data.GameProfile; //导入依赖的package包/类
private void loginWithToken() throws RequestException {
if(this.id == null || this.id.isEmpty()) {
if(this.username == null || this.username.isEmpty()) {
throw new InvalidCredentialsException("Invalid uuid and username.");
}
this.id = this.username;
}
if(this.accessToken == null || this.accessToken.equals("")) {
throw new InvalidCredentialsException("Invalid access token.");
} else {
RefreshRequest request = new RefreshRequest(this.clientToken, this.accessToken, null);
RefreshResponse response = HTTP.makeRequest(this.proxy, REFRESH_URL, request, RefreshResponse.class);
if(response.clientToken.equals(this.clientToken)) {
if(response.user != null && response.user.id != null) {
this.id = response.user.id;
} else {
this.id = this.username;
}
this.loggedIn = true;
this.accessToken = response.accessToken;
this.profiles = response.availableProfiles != null ? Arrays.asList(response.availableProfiles) : Collections.<GameProfile>emptyList();
this.selectedProfile = response.selectedProfile;
this.properties.clear();
if(response.user != null && response.user.properties != null) {
this.properties.addAll(response.user.properties);
}
} else {
throw new RequestException("Server requested we change our client token. Don't know how to handle this!");
}
}
}
开发者ID:surgeplay,项目名称:Visage,代码行数:35,代码来源:AuthenticationService.java
示例13: processDelivery
import com.github.steveice10.mc.auth.data.GameProfile; //导入依赖的package包/类
private void processDelivery(Delivery delivery) throws Exception {
BasicProperties props = delivery.getProperties();
BasicProperties replyProps = new BasicProperties.Builder().correlationId(props.getCorrelationId()).build();
DataInputStream data = new DataInputStream(new InflaterInputStream(new ByteArrayInputStream(delivery.getBody())));
RenderMode mode = RenderMode.values()[data.readUnsignedByte()];
int width = data.readUnsignedShort();
int height = data.readUnsignedShort();
GameProfile profile = Profiles.readGameProfile(data);
Map<String, String[]> params = Maps.newHashMap();
int len = data.readUnsignedShort();
for (int i = 0; i < len; i++) {
String key = data.readUTF();
String[] val = new String[data.readUnsignedByte()];
for (int v = 0; v < val.length; v++) {
val[v] = data.readUTF();
}
params.put(key, val);
}
byte[] skinData = new byte[data.readInt()];
data.readFully(skinData);
BufferedImage skin = new PngImage().read(new ByteArrayInputStream(skinData), false);
Visage.log.info("Received a job to render a "+width+"x"+height+" "+mode.name().toLowerCase()+" for "+(profile == null ? "null" : profile.getName()));
RenderConfiguration conf = new RenderConfiguration(Type.fromMode(mode), Profiles.isSlim(profile), mode.isTall(), Profiles.isFlipped(profile));
glClearColor(0, 0, 0, 0);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
byte[] pngBys = draw(conf, width, height, profile, skin, params);
if (Visage.trace) Visage.log.finest("Got png bytes");
parent.channel.basicPublish("", props.getReplyTo(), replyProps, buildResponse(0, pngBys));
if (Visage.trace) Visage.log.finest("Published response");
parent.channel.basicAck(delivery.getEnvelope().getDeliveryTag(), false);
if (Visage.trace) Visage.log.finest("Ack'd message");
}
开发者ID:surgeplay,项目名称:Visage,代码行数:35,代码来源:RenderContext.java
示例14: isSlim
import com.github.steveice10.mc.auth.data.GameProfile; //导入依赖的package包/类
public static boolean isSlim(GameProfile profile) throws IOException {
if (profile.getTextures().containsKey(TextureType.SKIN)) {
Texture t = profile.getTexture(TextureType.SKIN);
return t.getModel() == TextureModel.SLIM;
}
return UUIDs.isAlex(profile.getId());
}
开发者ID:surgeplay,项目名称:Visage,代码行数:8,代码来源:Profiles.java
示例15: getUsername
import com.github.steveice10.mc.auth.data.GameProfile; //导入依赖的package包/类
@Override
public String getUsername() {
if(this.conn == null) {
return this.username;
}
return this.conn.getSession().<GameProfile>getFlag(MinecraftConstants.PROFILE_KEY).getName();
}
开发者ID:Steveice10,项目名称:LibBot,代码行数:9,代码来源:MinecraftModule.java
示例16: PlayerStatusChecker
import com.github.steveice10.mc.auth.data.GameProfile; //导入依赖的package包/类
public PlayerStatusChecker(Session session, GameProfile player, PlayerStatusCallback callback) {
this.session = session;
this.player = player;
this.callback = callback;
}
开发者ID:DragonetMC,项目名称:AuthServer,代码行数:6,代码来源:PlayerStatusChecker.java
示例17: getUUID
import com.github.steveice10.mc.auth.data.GameProfile; //导入依赖的package包/类
public static UUID getUUID(GameProfile profile) {
return UUID.nameUUIDFromBytes(profile.getName().toLowerCase().getBytes(StandardCharsets.UTF_8));
}
开发者ID:DragonetMC,项目名称:AuthServer,代码行数:4,代码来源:SessionUtils.java
示例18: ProtocolWrapper
import com.github.steveice10.mc.auth.data.GameProfile; //导入依赖的package包/类
public ProtocolWrapper(GameProfile profile, String accessToken) {
super(profile, accessToken);
}
开发者ID:games647,项目名称:LambdaAttack,代码行数:4,代码来源:ProtocolWrapper.java
示例19: getGameProfile
import com.github.steveice10.mc.auth.data.GameProfile; //导入依赖的package包/类
public GameProfile getGameProfile() {
return account.getProfile();
}
开发者ID:games647,项目名称:LambdaAttack,代码行数:4,代码来源:Bot.java
示例20: RefreshRequest
import com.github.steveice10.mc.auth.data.GameProfile; //导入依赖的package包/类
protected RefreshRequest(String clientToken, String accessToken, GameProfile selectedProfile) {
this.clientToken = clientToken;
this.accessToken = accessToken;
this.selectedProfile = selectedProfile;
this.requestUser = true;
}
开发者ID:surgeplay,项目名称:Visage,代码行数:7,代码来源:AuthenticationService.java
注:本文中的com.github.steveice10.mc.auth.data.GameProfile类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论