Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,17 @@
*/
public interface ScriptFunctionExecutor {

/**
* Retrieves the executor method.
*
* @return A {@link Method}
*/
Method getMethod();

/**
* Retrieves the argument definitions for this executor.
*
* @return a list of {@link ScriptFunctionArgumentDefinition}
* @return A list of {@link ScriptFunctionArgumentDefinition}
*/
List<ScriptFunctionArgumentDefinition> getArguments();

Expand Down
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ java {

allprojects {
group = "com.instancify.scriptify"
version = "1.4.1-SNAPSHOT"
version = "1.4.2-SNAPSHOT"
}

subprojects {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ public CommonFunctionManager() {
this.register(new ScriptFunctionRandomLong());
this.register(new ScriptFunctionRandomFloat());
this.register(new ScriptFunctionRandomDouble());
this.register(new ScriptFunctionRandomBoolean());
this.register(new ScriptFunctionMD5());
this.register(new ScriptFunctionSHA256());
this.register(new ScriptFunctionExecCommand());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public class ScriptFunctionDeleteFile implements ScriptFunction {
}

@ExecuteAt
public Object execute(
public boolean execute(
@Executor Script<?> script,
@Argument(name = "filePath") String filePath,
@Argument(name = "recursive", required = false) Boolean recursive
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public class ScriptFunctionExistsFile implements ScriptFunction {
}

@ExecuteAt
public Object execute(
public boolean execute(
@Executor Script<?> script,
@Argument(name = "filePath") String filePath
) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

import java.io.File;
import java.util.Arrays;
import java.util.List;
import java.util.Objects;

/**
Expand All @@ -22,7 +23,7 @@ public class ScriptFunctionListFiles implements ScriptFunction {
}

@ExecuteAt
public Object execute(
public List<String> execute(
@Executor Script<?> script,
@Argument(name = "filePath") String filePath
) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public class ScriptFunctionMoveFile implements ScriptFunction {
}

@ExecuteAt
public Object execute(
public boolean execute(
@Executor Script<?> script,
@Argument(name = "original") String originalFilePath,
@Argument(name = "target") String targetFilePath
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public class ScriptFunctionReadFile implements ScriptFunction {
}

@ExecuteAt
public Object execute(
public String execute(
@Executor Script<?> script,
@Argument(name = "filePath") String filePath
) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@ public class ScriptFunctionWriteFile implements ScriptFunction {
}

@ExecuteAt
public Object execute(
public String execute(
@Executor Script<?> script,
@Argument(name = "filePath") String filePath,
@Argument(name = "fileContent") String fileContent
) {
try {
return Files.writeString(script.getSecurityManager().getFileSystem().getPath(filePath), fileContent);
return Files.writeString(script.getSecurityManager().getFileSystem().getPath(filePath), fileContent).toString();
} catch (IOException e) {
throw new RuntimeException(e);

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package com.instancify.scriptify.common.script.function.impl.random;

import com.instancify.scriptify.api.script.function.ScriptFunction;
import com.instancify.scriptify.api.script.function.annotation.ExecuteAt;
import org.jetbrains.annotations.NotNull;

import java.util.Random;

/**
* Represents a function to generate random long number
*/
public class ScriptFunctionRandomBoolean implements ScriptFunction {

@Override
public @NotNull String getName() {
return "randomBoolean";
}

@ExecuteAt
public boolean execute() {
return new Random().nextBoolean();
}
}