implement block & check functions

This commit is contained in:
dfsek
2020-12-22 17:32:17 -07:00
parent e5d9ae62fa
commit f47b975fe7
6 changed files with 105 additions and 9 deletions

View File

@@ -4,6 +4,8 @@ import com.dfsek.terra.api.math.vector.Location;
import com.dfsek.terra.api.structures.parser.Parser;
import com.dfsek.terra.api.structures.parser.exceptions.ParseException;
import com.dfsek.terra.api.structures.parser.lang.Block;
import com.dfsek.terra.api.structures.script.builders.BlockFunctionBuilder;
import com.dfsek.terra.api.structures.script.builders.CheckFunctionBuilder;
import com.dfsek.terra.bukkit.BukkitWorld;
import com.dfsek.terra.bukkit.command.DebugCommand;
import org.apache.commons.io.IOUtils;
@@ -37,7 +39,15 @@ public class LoadRawCommand extends LoadCommand implements DebugCommand {
public boolean execute(@NotNull Player sender, @NotNull Command command, @NotNull String s, @NotNull String[] args) {
try {
Parser parser = new Parser(IOUtils.toString(new FileInputStream(new File(getMain().getDataFolder(), "test.tesf"))));
parser.addFunction("block", new BlockFunctionBuilder(getMain()))
.addFunction("check", new CheckFunctionBuilder(getMain()));
System.out.println("Parsing...");
Block main = parser.parse();
System.out.println("Done parsing");
main.apply(new Location(new BukkitWorld(sender.getWorld()), sender.getLocation().getX(), sender.getLocation().getY(), sender.getLocation().getZ()));
} catch(IOException | ParseException e) {