2017-09-04 114 views
0

所以你一定知道遊戲我的世界。你可以通過僞造添加mod。有一個MOD,一個真正想擁有,但空空時,它給我一個錯誤:資源URL url

物業例外成分:「simpleNGramModel」屬性:「位置」 - 錯誤的URL C:\用戶\薩穆埃爾\桌面\ MultiMC \實例\ gfwg \我的世界\ CONFIG \ spells.lmunknown協議:C

雖然我是絕對希望這個mod,我認爲開發已經aboonded我想要的項目,尋找魔女功能使反編譯後的MOD我Minecraft崩潰我真的不知道發生了什麼問題(我不是一個大的Java開發者):

EDU/CMU /獅身人面像/ UTIL /道具/ ConfigurationManagerUtils.class

public static URL getResource(String name, PropertySheet ps) 
    throws PropertyException 
    { 
    String location = ps.getString(name); 
    if (location == null) { 
     throw new InternalConfigurationException(ps.getInstanceName(), name, "Required resource property '" + name + "' not set"); 
    } 
    try 
    { 
     URL url = resourceToURL(location); 
     if (url == null) { 
     throw new InternalConfigurationException(ps.getInstanceName(), name, "Can't locate " + location); 
     } 
     return url; 
    } 
    catch (MalformedURLException e) 
    { 
     throw new InternalConfigurationException(e, ps.getInstanceName(), name, "Bad URL " + location + e.getMessage()); 
    } 
    } 

    static final Pattern jarPattern = Pattern.compile("resource:(.*)", 2); 

    public static URL resourceToURL(String location) 
    throws MalformedURLException 
    { 
    Matcher jarMatcher = jarPattern.matcher(location); 
    if (jarMatcher.matches()) 
    { 
     String resourceName = jarMatcher.group(1); 
     return ConfigurationManagerUtils.class.getResource(resourceName); 
    } 
    if (location.indexOf(':') == -1) { 
     location = "file:" + location; 
    } 
    return new URL(location); 
    } 

的幫助如果我提出我的Minecraft到另一個磁盤(I://)我得到這個錯誤

物業例外成分: 'simpleNGramModel' 屬性: '位置' - 壞URL I:\ MultiMC \實例\ gfwg \我的世界\ CONFIG \ spells.lmunknown協議:我

原國防部螺紋:http://www.minecraftforum.net/forums/mapping-and-modding/minecraft-mods/2692177-forge-hp-spells-cast-spells-with-your-voice?page=7

PS:我的錯誤法國對不起

回答

1
if (location.indexOf(':') == -1) { 
    location = "file:" + location; 
} 

改變,要

if (location.indexOf(':') != -1) { 
    location = "file:///" + location.replace('\\', '/'); 
} 

如果還是失敗,那麼,另一種解決方案可能是

if (location.indexOf(':') != -1) { 
    File f = new File(location); 
    return f.toURI().toURL(); 
} 

有一個toURL方法在java.io.File以及,但它已棄用我避免使用不推薦的方法。

+0

以及如何操作 – TurtleForGaming

+0

@TurtleForGaming你是什麼意思? – Lothar

+0

我的意思是編輯源文件.class文件。我設法在java反編譯器中打開它來查看類的源代碼,但是如何重新編譯它。我確切地說我有一個.java文件被修改 – TurtleForGaming