PreYggdrasilConverter .java

net.minecraft.server.management.PreYggdrasilConverter (class, 92 lines): members: getStringUUIDFromName, OLD_PLAYERBAN_FILE, OLD_WHITELIST_FILE, LOGGER.

net.minecraft.server.managementclass92 linesserver3.8 KB

API Surface (4)

boolean apply(String p_apply_1_)
String getStringUUIDFromName(String p_152719_0_)
void onProfileLookupSucceeded(GameProfile p_onProfileLookupSucceeded_1_)
void onProfileLookupFailed(GameProfile p_onProfileLookupFailed_1_, Exception p_onProfileLookupFailed_2_)

Fields & Constants (5)

LOGGER
OLD_IPBAN_FILE
OLD_PLAYERBAN_FILE
OLD_OPS_FILE
OLD_WHITELIST_FILE

String literals (5)

"banned-ips.txt"
"banned-players.txt"
"ops.txt"
"white-list.txt"
"Could not lookup user whitelist entry for "

Code Graph: Dependencies (3)

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

Full Source

PreYggdrasilConverter.java92 lines · MCP 1.8.9 · verbatimOriginal ↗
1
package net.minecraft.server.management;
2
3
import com.google.common.base.Predicate;
4
import com.google.common.collect.Iterators;
5
import com.google.common.collect.Lists;
6
import com.mojang.authlib.Agent;
7
import com.mojang.authlib.GameProfile;
8
import com.mojang.authlib.ProfileLookupCallback;
9
import java.io.File;
10
import java.util.Collection;
11
import java.util.List;
12
import java.util.UUID;
13
import net.minecraft.entity.player.EntityPlayer;
14
import net.minecraft.server.MinecraftServer;
15
import net.minecraft.util.StringUtils;
16
import org.apache.logging.log4j.LogManager;
17
import org.apache.logging.log4j.Logger;
18
19
public class PreYggdrasilConverter
20
{
21
    private static final Logger LOGGER = LogManager.getLogger();
22
    public static final File OLD_IPBAN_FILE = new File("banned-ips.txt");
23
    public static final File OLD_PLAYERBAN_FILE = new File("banned-players.txt");
24
    public static final File OLD_OPS_FILE = new File("ops.txt");
25
    public static final File OLD_WHITELIST_FILE = new File("white-list.txt");
26
27
    private static void lookupNames(MinecraftServer server, Collection<String> names, ProfileLookupCallback callback)
28
    {
29
        String[] astring = (String[])Iterators.toArray(Iterators.filter(names.iterator(), new Predicate<String>()
30
        {
31
            public boolean apply(String p_apply_1_)
32
            {
33
                return !StringUtils.isNullOrEmpty(p_apply_1_);
34
            }
35
        }), String.class);
36
37
        if (server.isServerInOnlineMode())
38
        {
39
            server.getGameProfileRepository().findProfilesByNames(astring, Agent.MINECRAFT, callback);
40
        }
41
        else
42
        {
43
            for (String s : astring)
44
            {
45
                UUID uuid = EntityPlayer.getUUID(new GameProfile((UUID)null, s));
46
                GameProfile gameprofile = new GameProfile(uuid, s);
47
                callback.onProfileLookupSucceeded(gameprofile);
48
            }
49
        }
50
    }
51
52
    public static String getStringUUIDFromName(String p_152719_0_)
53
    {
54
        if (!StringUtils.isNullOrEmpty(p_152719_0_) && p_152719_0_.length() <= 16)
55
        {
56
            final MinecraftServer minecraftserver = MinecraftServer.getServer();
57
            GameProfile gameprofile = minecraftserver.getPlayerProfileCache().getGameProfileForUsername(p_152719_0_);
58
59
            if (gameprofile != null && gameprofile.getId() != null)
60
            {
61
                return gameprofile.getId().toString();
62
            }
63
            else if (!minecraftserver.isSinglePlayer() && minecraftserver.isServerInOnlineMode())
64
            {
65
                final List<GameProfile> list = Lists.<GameProfile>newArrayList();
66
                ProfileLookupCallback profilelookupcallback = new ProfileLookupCallback()
67
                {
68
                    public void onProfileLookupSucceeded(GameProfile p_onProfileLookupSucceeded_1_)
69
                    {
70
                        minecraftserver.getPlayerProfileCache().addEntry(p_onProfileLookupSucceeded_1_);
71
                        list.add(p_onProfileLookupSucceeded_1_);
72
                    }
73
                    public void onProfileLookupFailed(GameProfile p_onProfileLookupFailed_1_, Exception p_onProfileLookupFailed_2_)
74
                    {
75
                        PreYggdrasilConverter.LOGGER.warn((String)("Could not lookup user whitelist entry for " + p_onProfileLookupFailed_1_.getName()), (Throwable)p_onProfileLookupFailed_2_);
76
                    }
77
                };
78
                lookupNames(minecraftserver, Lists.newArrayList(new String[] {p_152719_0_}), profilelookupcallback);
79
                return list.size() > 0 && ((GameProfile)list.get(0)).getId() != null ? ((GameProfile)list.get(0)).getId().toString() : "";
80
            }
81
            else
82
            {
83
                return EntityPlayer.getUUID(new GameProfile((UUID)null, p_152719_0_)).toString();
84
            }
85
        }
86
        else
87
        {
88
            return p_152719_0_;
89
        }
90
    }
91
}
92

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