當前位置: 首頁>>代碼示例>>Java>>正文


Java Minecraft.getSessionInfo方法代碼示例

本文整理匯總了Java中net.minecraft.client.Minecraft.getSessionInfo方法的典型用法代碼示例。如果您正苦於以下問題:Java Minecraft.getSessionInfo方法的具體用法?Java Minecraft.getSessionInfo怎麽用?Java Minecraft.getSessionInfo使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在net.minecraft.client.Minecraft的用法示例。


在下文中一共展示了Minecraft.getSessionInfo方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: downloadResourcePack

import net.minecraft.client.Minecraft; //導入方法依賴的package包/類
public ListenableFuture<Object> downloadResourcePack(String url, String hash)
{
    String s;

    if (hash.matches("^[a-f0-9]{40}$"))
    {
        s = hash;
    }
    else
    {
        s = "legacy";
    }

    final File file1 = new File(this.dirServerResourcepacks, s);
    this.lock.lock();

    try
    {
        this.func_148529_f();

        if (file1.exists() && hash.length() == 40)
        {
            try
            {
                String s1 = Hashing.sha1().hashBytes(Files.toByteArray(file1)).toString();

                if (s1.equals(hash))
                {
                    ListenableFuture listenablefuture1 = this.setResourcePackInstance(file1);
                    return listenablefuture1;
                }

                logger.warn("File " + file1 + " had wrong hash (expected " + hash + ", found " + s1 + "). Deleting it.");
                FileUtils.deleteQuietly(file1);
            }
            catch (IOException ioexception)
            {
                logger.warn((String)("File " + file1 + " couldn\'t be hashed. Deleting it."), (Throwable)ioexception);
                FileUtils.deleteQuietly(file1);
            }
        }

        this.func_183028_i();
        final GuiScreenWorking guiscreenworking = new GuiScreenWorking();
        Map<String, String> map = Minecraft.getSessionInfo();
        final Minecraft minecraft = Minecraft.getMinecraft();
        Futures.getUnchecked(minecraft.addScheduledTask(new Runnable()
        {
            public void run()
            {
                minecraft.displayGuiScreen(guiscreenworking);
            }
        }));
        final SettableFuture<Object> settablefuture = SettableFuture.<Object>create();
        this.field_177322_i = HttpUtil.downloadResourcePack(file1, url, map, 52428800, guiscreenworking, minecraft.getProxy());
        Futures.addCallback(this.field_177322_i, new FutureCallback<Object>()
        {
            public void onSuccess(Object p_onSuccess_1_)
            {
                ResourcePackRepository.this.setResourcePackInstance(file1);
                settablefuture.set((Object)null);
            }
            public void onFailure(Throwable p_onFailure_1_)
            {
                settablefuture.setException(p_onFailure_1_);
            }
        });
        ListenableFuture listenablefuture = this.field_177322_i;
        return listenablefuture;
    }
    finally
    {
        this.lock.unlock();
    }
}
 
開發者ID:Notoh,項目名稱:DecompiledMinecraft,代碼行數:76,代碼來源:ResourcePackRepository.java


注:本文中的net.minecraft.client.Minecraft.getSessionInfo方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。