Search in sources :

Example 6 with SpongeUser

use of org.spongepowered.common.entity.player.SpongeUser in project SpongeCommon by SpongePowered.

the class UserDiscoverer method getFromStoredData.

private static User getFromStoredData(org.spongepowered.api.profile.GameProfile profile) {
    // Always cache user to avoid constant lookups in storage when file does not exist
    final User user = create((GameProfile) profile);
    // Note: Uses the overworld's player data
    final File dataFile = getPlayerDataFile(profile.getUniqueId());
    if (dataFile == null) {
        return null;
    }
    try {
        ((SpongeUser) user).readFromNbt(CompressedStreamTools.readCompressed(new FileInputStream(dataFile)));
    } catch (IOException e) {
        SpongeImpl.getLogger().warn("Corrupt user file {}", dataFile, e);
    }
    return user;
}
Also used : SpongeUser(org.spongepowered.common.entity.player.SpongeUser) User(org.spongepowered.api.entity.living.player.User) IOException(java.io.IOException) File(java.io.File) FileInputStream(java.io.FileInputStream) SpongeUser(org.spongepowered.common.entity.player.SpongeUser)

Aggregations

SpongeUser (org.spongepowered.common.entity.player.SpongeUser)6 User (org.spongepowered.api.entity.living.player.User)3 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)2 Inject (org.spongepowered.asm.mixin.injection.Inject)2 GameProfile (com.mojang.authlib.GameProfile)1 File (java.io.File)1 FileInputStream (java.io.FileInputStream)1 IOException (java.io.IOException)1 Instant (java.time.Instant)1 UUID (java.util.UUID)1 Nullable (javax.annotation.Nullable)1 Entity (net.minecraft.entity.Entity)1 IInventory (net.minecraft.inventory.IInventory)1 NetHandlerPlayServer (net.minecraft.network.NetHandlerPlayServer)1 PacketBuffer (net.minecraft.network.PacketBuffer)1 SPacketCustomPayload (net.minecraft.network.play.server.SPacketCustomPayload)1 SPacketEntityEffect (net.minecraft.network.play.server.SPacketEntityEffect)1 SPacketHeldItemChange (net.minecraft.network.play.server.SPacketHeldItemChange)1 SPacketJoinGame (net.minecraft.network.play.server.SPacketJoinGame)1 SPacketPlayerAbilities (net.minecraft.network.play.server.SPacketPlayerAbilities)1