+ Added plugin

This commit is contained in:
Matthew Cech
2019-04-20 02:00:32 -07:00
parent 25c1e9a1a2
commit 7e57ad79a0
9 changed files with 174 additions and 15 deletions
+28 -2
View File
@@ -1,8 +1,34 @@
package core.lua;
// To promote flexibility, plugins are lua file with predefined callbacks.
// They are executed between the initial built-in preprocessing and the command parsing.
import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.stream.Stream;
//To promote flexibility, plugins are lua file with predefined callbacks.
//They are executed between the initial built-in preprocessing and the command parsing.
public class Plugin
{
public Path filepath;
public String contents;
public Plugin(Path filepath)
{
this.filepath = filepath;
StringBuilder contentBuilder = new StringBuilder();
try
{
Stream<String> stream = Files.lines(filepath, StandardCharsets.UTF_8);
stream.forEach(str -> contentBuilder.append(str).append("\n"));
stream.close();
contents = contentBuilder.toString();
}
catch (IOException e)
{
PluginLog.Error(e.getMessage());
}
}
}