UserListBansEntry .java

net.minecraft.server.management.UserListBansEntry (class, 63 lines): members: onSerialization. strings: "uuid". imports: JsonObject, GameProfile.

net.minecraft.server.managementclass63 linesserverextends BanEntry<GameProfile>1.8 KB

API Surface (1)

void onSerialization(JsonObject data)

String literals (1)

"uuid"

Code Graph: Dependencies (1)

Edges (calls / imports / inherits / references) resolved by graphify from the AST. Every chip opens the class source.

Full Source

UserListBansEntry.java63 lines · MCP 1.8.9 · verbatimOriginal ↗
1
package net.minecraft.server.management;
2
3
import com.google.gson.JsonObject;
4
import com.mojang.authlib.GameProfile;
5
import java.util.Date;
6
import java.util.UUID;
7
8
public class UserListBansEntry extends BanEntry<GameProfile>
9
{
10
    public UserListBansEntry(GameProfile profile)
11
    {
12
        this(profile, (Date)null, (String)null, (Date)null, (String)null);
13
    }
14
15
    public UserListBansEntry(GameProfile profile, Date startDate, String banner, Date endDate, String banReason)
16
    {
17
        super(profile, endDate, banner, endDate, banReason);
18
    }
19
20
    public UserListBansEntry(JsonObject json)
21
    {
22
        super(toGameProfile(json), json);
23
    }
24
25
    protected void onSerialization(JsonObject data)
26
    {
27
        if (this.getValue() != null)
28
        {
29
            data.addProperty("uuid", ((GameProfile)this.getValue()).getId() == null ? "" : ((GameProfile)this.getValue()).getId().toString());
30
            data.addProperty("name", ((GameProfile)this.getValue()).getName());
31
            super.onSerialization(data);
32
        }
33
    }
34
35
    /**
36
     * Convert a {@linkplain com.google.gson.JsonObject JsonObject} into a {@linkplain com.mojang.authlib.GameProfile}.
37
     * The json object must have {@code uuid} and {@code name} attributes or {@code null} will be returned.
38
     */
39
    private static GameProfile toGameProfile(JsonObject json)
40
    {
41
        if (json.has("uuid") && json.has("name"))
42
        {
43
            String s = json.get("uuid").getAsString();
44
            UUID uuid;
45
46
            try
47
            {
48
                uuid = UUID.fromString(s);
49
            }
50
            catch (Throwable var4)
51
            {
52
                return null;
53
            }
54
55
            return new GameProfile(uuid, json.get("name").getAsString());
56
        }
57
        else
58
        {
59
            return null;
60
        }
61
    }
62
}
63

Deobfuscated MCP 1.8.9 source of UserListBansEntry from Marcelektro/MavenMCP-1.8.9 (net/minecraft/server/management/UserListBansEntry.java), stored verbatim.