Mojira Archive
MC-131738

Commands data report creates a server instance for no reason

The commands data report creates a new server instance (along with setting up a ton of other stuff) to create a command tree instance:

(using forge's MCPConfig with 18w22c mappings; the same code is present in 1.13-pre2 though)

    public void func_200398_a(DirectoryCache p_200398_1_) throws IOException
    {
        YggdrasilAuthenticationService yggdrasilauthenticationservice = new YggdrasilAuthenticationService(Proxy.NO_PROXY, UUID.randomUUID().toString());
        MinecraftSessionService minecraftsessionservice = yggdrasilauthenticationservice.createMinecraftSessionService();
        GameProfileRepository gameprofilerepository = yggdrasilauthenticationservice.createProfileRepository();
        File file1 = new File(this.field_200400_a.func_200391_b().toFile(), "tmp");
        PlayerProfileCache playerprofilecache = new PlayerProfileCache(gameprofilerepository, new File(file1, MinecraftServer.USER_CACHE_FILE.getName()));
        MinecraftServer minecraftserver = new DedicatedServer(file1, DataFixesManager.createFixer(), yggdrasilauthenticationservice, minecraftsessionservice, gameprofilerepository, playerprofilecache);
        minecraftserver.func_195571_aL().func_200378_a(this.field_200400_a.func_200391_b().resolve("reports/commands.json").toFile());
    }

This takes several seconds, while it prepares all the authentication stuff and then the server. However, it could just be replaced with:

    public void func_200398_a(DirectoryCache p_200398_1_) throws IOException
    {
        new Commands(true).func_200378_a(this.field_200400_a.func_200391_b().resolve("reports/commands.json").toFile());
    }

which is much faster and simpler. This produces the exact same report (I have tested it), and still detects the ambiguous /teleport commands.


This also causes the dedicated server classes to be included in the client JAR, since they are still referenced.