Allow assembly and loading of new scripts
This commit is contained in:
@@ -64,17 +64,38 @@ public abstract class RSIndexDataBaseMixin implements RSIndexDataBase
|
||||
return rsData;
|
||||
}
|
||||
|
||||
HashCode rsDataHash = Hashing.sha256().hashBytes(rsData);
|
||||
|
||||
String rsHash = BaseEncoding.base16().encode(rsDataHash.asBytes());
|
||||
|
||||
InputStream in2 = getClass().getResourceAsStream("/runelite/" + indexData.getIndex() + "/" + archiveId + ".hash");
|
||||
if (rsData == null)
|
||||
{
|
||||
if (in2 != null)
|
||||
{
|
||||
log.warn("Hash file for non existing archive {}/{}", indexData.getIndex(), archiveId);
|
||||
return null;
|
||||
}
|
||||
|
||||
log.debug("Adding archive {}/{}", indexData.getIndex(), archiveId);
|
||||
|
||||
try
|
||||
{
|
||||
return ByteStreams.toByteArray(in);
|
||||
}
|
||||
catch (IOException ex)
|
||||
{
|
||||
log.warn("error loading archive replacement", ex);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
if (in2 == null)
|
||||
{
|
||||
log.warn("Missing hash file for {}/{}", indexData.getIndex(), archiveId);
|
||||
return rsData;
|
||||
}
|
||||
|
||||
HashCode rsDataHash = Hashing.sha256().hashBytes(rsData);
|
||||
|
||||
String rsHash = BaseEncoding.base16().encode(rsDataHash.asBytes());
|
||||
|
||||
try
|
||||
{
|
||||
String replaceHash = CharStreams.toString(new InputStreamReader(in2));
|
||||
|
||||
@@ -73,12 +73,6 @@ public class AssembleMojo extends AbstractMojo
|
||||
|
||||
try (FileInputStream fin = new FileInputStream(scriptFile))
|
||||
{
|
||||
File hashFile = new File(scriptDirectory, Files.getNameWithoutExtension(scriptFile.getName()) + ".hash");
|
||||
if (!hashFile.exists())
|
||||
{
|
||||
throw new MojoExecutionException("Unable to find hash file for " + scriptFile);
|
||||
}
|
||||
|
||||
ScriptDefinition script = assembler.assemble(fin);
|
||||
byte[] packedScript = saver.save(script);
|
||||
|
||||
@@ -86,7 +80,16 @@ public class AssembleMojo extends AbstractMojo
|
||||
Files.write(packedScript, targetFile);
|
||||
|
||||
// Copy hash file
|
||||
Files.copy(hashFile, new File(scriptOut, Integer.toString(script.getId()) + ".hash"));
|
||||
|
||||
File hashFile = new File(scriptDirectory, Files.getNameWithoutExtension(scriptFile.getName()) + ".hash");
|
||||
if (hashFile.exists())
|
||||
{
|
||||
Files.copy(hashFile, new File(scriptOut, Integer.toString(script.getId()) + ".hash"));
|
||||
}
|
||||
else if (script.getId() < 10000) // Scripts >=10000 are RuneLite scripts, so they shouldn't have a .hash
|
||||
{
|
||||
throw new MojoExecutionException("Unable to find hash file for " + scriptFile);
|
||||
}
|
||||
|
||||
++count;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user