build in script load from resources, added 2 more events, added event test

This commit is contained in:
gnembon committed 2019-10-11 02:23:45 -03:00
1 parent 87eb46b773
commit fc66ec9c93
8 files changed
+487 -341

No files matched your search

@@ -0,0 +1,39 @@
package carpet.script.bundled;
import org.apache.commons.io.IOUtils;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
public class BundledModule implements ModuleInterface
{
private String name;
private String code;
public BundledModule(String scriptName)
{
try
{
name = scriptName;
code = IOUtils.toString(
getClass().getClassLoader().getResourceAsStream("assets/carpet/scripts/"+scriptName+".sc"),
StandardCharsets.UTF_8
);
}
catch ( NullPointerException | IOException e)
{
name = null;
code = null;
}
}
@Override
public String getName()
{
return name;
}
@Override
public String getCode()
{
return code;
}
}