Session .java

net.minecraft.util.Session (class): members: getSessionType, getSessionID, getPlayerID, getUsername, sessionType, getToken, username, token, playerID.

net.minecraft.utilclass91 linescommon2.2 KB

API Surface (7)

String getSessionID()
String getPlayerID()
String getUsername()
String getToken()
GameProfile getProfile()
Session.Type getSessionType()
Session.Type setSessionType(String sessionTypeIn)

Fields & Constants (4)

username
playerID
token
sessionType

String literals (3)

"token:"
"legacy"
"mojang"

Full Source

Session.java91 lines · MCP 1.8.9 · verbatimOriginal ↗
1
package net.minecraft.util;
2
3
import com.google.common.collect.Maps;
4
import com.mojang.authlib.GameProfile;
5
import com.mojang.util.UUIDTypeAdapter;
6
import java.util.Map;
7
import java.util.UUID;
8
9
public class Session
10
{
11
    private final String username;
12
    private final String playerID;
13
    private final String token;
14
    private final Session.Type sessionType;
15
16
    public Session(String usernameIn, String playerIDIn, String tokenIn, String sessionTypeIn)
17
    {
18
        this.username = usernameIn;
19
        this.playerID = playerIDIn;
20
        this.token = tokenIn;
21
        this.sessionType = Session.Type.setSessionType(sessionTypeIn);
22
    }
23
24
    public String getSessionID()
25
    {
26
        return "token:" + this.token + ":" + this.playerID;
27
    }
28
29
    public String getPlayerID()
30
    {
31
        return this.playerID;
32
    }
33
34
    public String getUsername()
35
    {
36
        return this.username;
37
    }
38
39
    public String getToken()
40
    {
41
        return this.token;
42
    }
43
44
    public GameProfile getProfile()
45
    {
46
        try
47
        {
48
            UUID uuid = UUIDTypeAdapter.fromString(this.getPlayerID());
49
            return new GameProfile(uuid, this.getUsername());
50
        }
51
        catch (IllegalArgumentException var2)
52
        {
53
            return new GameProfile((UUID)null, this.getUsername());
54
        }
55
    }
56
57
    /**
58
     * Returns either 'legacy' or 'mojang' whether the account is migrated or not
59
     */
60
    public Session.Type getSessionType()
61
    {
62
        return this.sessionType;
63
    }
64
65
    public static enum Type
66
    {
67
        LEGACY("legacy"),
68
        MOJANG("mojang");
69
70
        private static final Map<String, Session.Type> SESSION_TYPES = Maps.<String, Session.Type>newHashMap();
71
        private final String sessionType;
72
73
        private Type(String sessionTypeIn)
74
        {
75
            this.sessionType = sessionTypeIn;
76
        }
77
78
        public static Session.Type setSessionType(String sessionTypeIn)
79
        {
80
            return (Session.Type)SESSION_TYPES.get(sessionTypeIn.toLowerCase());
81
        }
82
83
        static {
84
            for (Session.Type session$type : values())
85
            {
86
                SESSION_TYPES.put(session$type.sessionType, session$type);
87
            }
88
        }
89
    }
90
}
91

Deobfuscated MCP 1.8.9 source of Session from Marcelektro/MavenMCP-1.8.9 (net/minecraft/util/Session.java), stored verbatim.