本文整理汇总了Java中protocolsupport.api.events.PlayerPropertiesResolveEvent.ProfileProperty类的典型用法代码示例。如果您正苦于以下问题:Java ProfileProperty类的具体用法?Java ProfileProperty怎么用?Java ProfileProperty使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ProfileProperty类属于protocolsupport.api.events.PlayerPropertiesResolveEvent包,在下文中一共展示了ProfileProperty类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: hasJoinedServer
import protocolsupport.api.events.PlayerPropertiesResolveEvent.ProfileProperty; //导入依赖的package包/类
public static GameProfile hasJoinedServer(String name, String hash, String ip) throws AuthenticationUnavailableException, MalformedURLException {
final URL url = new URL(hasJoinedUrl + "?username=" + name + "&serverId=" + hash + (ip != null ? "&ip=" + ip : ""));
try {
JsonObject root = new JsonParser().parse(new InputStreamReader(url.openStream())).getAsJsonObject();
String rname = JsonUtils.getString(root, "name");
UUID ruuid = UUIDTypeAdapter.fromString(JsonUtils.getString(root, "id"));
GameProfile profile = new GameProfile(ruuid, rname);
JsonArray properties = JsonUtils.getJsonArray(root, "properties");
for (JsonElement property : properties) {
JsonObject propertyobj = property.getAsJsonObject();
profile.addProperty(new ProfileProperty(
JsonUtils.getString(propertyobj, "name"),
JsonUtils.getString(propertyobj, "value"),
JsonUtils.getString(propertyobj, "signature")
));
}
return profile;
} catch (IOException | IllegalStateException | JsonParseException e) {
throw new AuthenticationUnavailableException();
}
}
示例2: serialize
import protocolsupport.api.events.PlayerPropertiesResolveEvent.ProfileProperty; //导入依赖的package包/类
public static NBTTagCompoundWrapper serialize(GameProfile gameProfile) {
NBTTagCompoundWrapper tag = ServerPlatform.get().getWrapperFactory().createEmptyNBTCompound();
if (!StringUtils.isEmpty(gameProfile.getName())) {
tag.setString(NAME_KEY, gameProfile.getName());
}
if (gameProfile.getUUID() != null) {
tag.setString(UUID_KEY, gameProfile.getUUID().toString());
}
if (!gameProfile.getProperties().isEmpty()) {
NBTTagCompoundWrapper propertiesTag = ServerPlatform.get().getWrapperFactory().createEmptyNBTCompound();
for (Entry<String, ProfileProperty> entry : gameProfile.getProperties().entrySet()) {
NBTTagListWrapper propertiesListTag = ServerPlatform.get().getWrapperFactory().createEmptyNBTList();
ProfileProperty property = entry.getValue();
NBTTagCompoundWrapper propertyTag = ServerPlatform.get().getWrapperFactory().createEmptyNBTCompound();
propertyTag.setString(PROPERTY_VALUE_KEY, property.getValue());
if (property.hasSignature()) {
propertyTag.setString(PROPERTY_SIGNATURE_KEY, property.getSignature());
}
propertiesListTag.addCompound(propertyTag);
propertiesTag.setList(entry.getKey(), propertiesListTag);
}
tag.setCompound(PROPERTIES_KEY, propertiesTag);
}
return tag;
}
示例3: apply
import protocolsupport.api.events.PlayerPropertiesResolveEvent.ProfileProperty; //导入依赖的package包/类
@Override
public SpoofedData apply(String hostname) {
if (PlayerHandshakeEvent.getHandlerList().getRegisteredListeners().length != 0) {
PlayerHandshakeEvent handshakeEvent = new PlayerHandshakeEvent(hostname, false);
Bukkit.getPluginManager().callEvent(handshakeEvent);
if (!handshakeEvent.isCancelled()) {
if (handshakeEvent.isFailed()) {
return new SpoofedData(handshakeEvent.getFailMessage());
}
String spoofedHostname = handshakeEvent.getServerHostname();
String spoofedAddress = handshakeEvent.getSocketAddressHostname();
UUID uuid = handshakeEvent.getUniqueId();
ProfileProperty[] properties = Utils.GSON.fromJson(handshakeEvent.getPropertiesJson(), ProfileProperty[].class);
return new SpoofedData(spoofedHostname, spoofedAddress, uuid, properties);
}
}
return null;
}
示例4: toData
import protocolsupport.api.events.PlayerPropertiesResolveEvent.ProfileProperty; //导入依赖的package包/类
@Override
public RecyclableCollection<ClientBoundPacketData> toData() {
ProtocolVersion version = connection.getVersion();
ClientBoundPacketData serializer = ClientBoundPacketData.create(ClientBoundPacket.PLAY_SPAWN_NAMED_ID, version);
VarNumberSerializer.writeVarInt(serializer, entity.getId());
StringSerializer.writeString(serializer, version, version == ProtocolVersion.MINECRAFT_1_7_10 ? entity.getUUID().toString() : entity.getUUID().toString().replace("-", ""));
StringSerializer.writeString(serializer, version, name);
if (version == ProtocolVersion.MINECRAFT_1_7_10) {
VarNumberSerializer.writeVarInt(serializer, properties.size());
for (ProfileProperty property : properties) {
StringSerializer.writeString(serializer, version, property.getName());
StringSerializer.writeString(serializer, version, property.getValue());
StringSerializer.writeString(serializer, version, property.getSignature());
}
}
serializer.writeInt((int) (x * 32));
serializer.writeInt((int) (y * 32));
serializer.writeInt((int) (z * 32));
serializer.writeByte(yaw);
serializer.writeByte(pitch);
serializer.writeShort(0);
LegacyDataWatcherSerializer.encodeData(serializer, version, cache.getLocale(), metadata.getRemapped());
return RecyclableSingletonList.create(serializer);
}
示例5: deserialize
import protocolsupport.api.events.PlayerPropertiesResolveEvent.ProfileProperty; //导入依赖的package包/类
public static GameProfile deserialize(NBTTagCompoundWrapper tag) {
String name = null;
if (tag.hasKeyOfType(NAME_KEY, NBTTagType.STRING)) {
name = tag.getString(NAME_KEY);
}
UUID uuid = null;
try {
if (tag.hasKeyOfType(UUID_KEY, NBTTagType.STRING)) {
uuid = UUID.fromString(tag.getString(UUID_KEY));
}
} catch (Throwable t) {
}
if (StringUtils.isEmpty(name) && (uuid == null)) {
return null;
}
GameProfile gameProfile = new GameProfile(uuid, name);
if (tag.hasKeyOfType(PROPERTIES_KEY, NBTTagType.COMPOUND)) {
NBTTagCompoundWrapper compound = tag.getCompound(PROPERTIES_KEY);
for (String propertyName : compound.getKeys()) {
NBTTagListWrapper list = compound.getList(propertyName, NBTTagType.COMPOUND);
for (int i = 0; i < list.size(); ++i) {
NBTTagCompoundWrapper value = list.getCompound(i);
String propertyValue = value.getString(PROPERTY_VALUE_KEY);
if (value.hasKeyOfType(PROPERTY_SIGNATURE_KEY, NBTTagType.STRING)) {
gameProfile.getProperties().put(propertyName, new ProfileProperty(propertyName, propertyValue, value.getString(PROPERTY_SIGNATURE_KEY)));
} else {
gameProfile.getProperties().put(propertyName, new ProfileProperty(propertyName, propertyValue));
}
}
}
}
return gameProfile;
}
示例6: apply
import protocolsupport.api.events.PlayerPropertiesResolveEvent.ProfileProperty; //导入依赖的package包/类
@Override
public SpoofedData apply(String data) {
final String[] split = data.split("\u0000");
if ((split.length != 3) && (split.length != 4)) {
return null;
}
return new SpoofedData(split[0], split[1], UUIDTypeAdapter.fromString(split[2]), split.length == 4 ? Utils.GSON.fromJson(split[3], ProfileProperty[].class) : null);
}
示例7: SpoofedData
import protocolsupport.api.events.PlayerPropertiesResolveEvent.ProfileProperty; //导入依赖的package包/类
public SpoofedData(String hostname, String address, UUID uuid, ProfileProperty[] properties) {
this.hostname = hostname;
this.address = address;
this.uuid = uuid;
this.properties = properties;
this.failed = false;
this.failMessage = null;
}
示例8: add
import protocolsupport.api.events.PlayerPropertiesResolveEvent.ProfileProperty; //导入依赖的package包/类
public void add(ProfileProperty property) {
if (property.hasSignature()) {
signed.put(property.getName(), property);
} else {
unsigned.put(property.getName(), property);
}
}
示例9: getAll
import protocolsupport.api.events.PlayerPropertiesResolveEvent.ProfileProperty; //导入依赖的package包/类
public List<ProfileProperty> getAll(boolean signedOnly) {
if (signedOnly) {
return new ArrayList<>(signed.values());
} else {
ArrayList<ProfileProperty> properties = new ArrayList<>();
properties.addAll(signed.values());
properties.addAll(unsigned.values());
return properties;
}
}
示例10: initOfflineModeGameProfile
import protocolsupport.api.events.PlayerPropertiesResolveEvent.ProfileProperty; //导入依赖的package包/类
public void initOfflineModeGameProfile() {
profile = new GameProfile(networkManager.getSpoofedUUID() != null ? networkManager.getSpoofedUUID() : generateOffileModeUUID(), profile.getName());
if (networkManager.getSpoofedProperties() != null) {
for (ProfileProperty property : networkManager.getSpoofedProperties()) {
profile.addProperty(property);
}
}
}
示例11: getSpoofedProperties
import protocolsupport.api.events.PlayerPropertiesResolveEvent.ProfileProperty; //导入依赖的package包/类
@Override
public ProfileProperty[] getSpoofedProperties() {
PlayerProfile profile = getSpoofedProfile();
return profile == null ? null :
profile.getProperties().stream()
.map(property -> new ProfileProperty(property.getName(), property.getValue(), property.getSignature()))
.collect(Collectors.toList())
.toArray(new ProfileProperty[0]);
}
示例12: setSpoofedProfile
import protocolsupport.api.events.PlayerPropertiesResolveEvent.ProfileProperty; //导入依赖的package包/类
@Override
public void setSpoofedProfile(UUID uuid, ProfileProperty[] properties) {
ProxyData old = getSession().getProxyData();
List<PlayerProperty> glowproperties = Collections.emptyList();
if (properties != null) {
glowproperties = Arrays.stream(properties)
.map(prop -> new PlayerProperty(prop.getName(), prop.getValue(), prop.getSignature()))
.collect(Collectors.toList());
}
if (old != null) {
getSession().setProxyData(new ProxyData(null, null, old.getAddress(), null, uuid, glowproperties));
} else {
getSession().setProxyData(new ProxyData(null, null, getAddress(), null, uuid, glowproperties));
}
}
示例13: getSpoofedProperties
import protocolsupport.api.events.PlayerPropertiesResolveEvent.ProfileProperty; //导入依赖的package包/类
@Override
public ProfileProperty[] getSpoofedProperties() {
if (internal.spoofedProfile == null) {
return null;
}
return
Arrays.asList(internal.spoofedProfile)
.stream()
.map(prop -> new ProfileProperty(prop.getName(), prop.getValue(), prop.getSignature()))
.collect(Collectors.toList())
.toArray(new ProfileProperty[0]);
}
示例14: setSpoofedProfile
import protocolsupport.api.events.PlayerPropertiesResolveEvent.ProfileProperty; //导入依赖的package包/类
@Override
public void setSpoofedProfile(UUID uuid, ProfileProperty[] properties) {
internal.spoofedUUID = uuid;
if (properties != null) {
internal.spoofedProfile = Arrays.stream(properties)
.map(prop -> new Property(prop.getName(), prop.getValue(), prop.getSignature()))
.collect(Collectors.toList())
.toArray(new Property[0]);
}
}
示例15: toMojangGameProfile
import protocolsupport.api.events.PlayerPropertiesResolveEvent.ProfileProperty; //导入依赖的package包/类
public static com.mojang.authlib.GameProfile toMojangGameProfile(GameProfile profile) {
com.mojang.authlib.GameProfile mojangGameProfile = new com.mojang.authlib.GameProfile(profile.getUUID(), profile.getName());
for (Entry<String, ProfileProperty> entry : profile.getProperties().entrySet()) {
ProfileProperty property = entry.getValue();
mojangGameProfile.getProperties().put(entry.getKey(), new Property(property.getName(), property.getValue(), property.getSignature()));
}
return mojangGameProfile;
}