diff --git a/src/main/java/org/codeoverflow/chatoverflow/api/io/input/RconInput.java b/src/main/java/org/codeoverflow/chatoverflow/api/io/input/RconInput.java new file mode 100644 index 0000000..bda2ae9 --- /dev/null +++ b/src/main/java/org/codeoverflow/chatoverflow/api/io/input/RconInput.java @@ -0,0 +1,14 @@ +package org.codeoverflow.chatoverflow.api.io.input; + +public interface RconInput extends Input { + + /** + * Get the output of a rcon command + * Command will be directly executed on the rcon server and the returned response will be returned + * If null is returned this means that there is some problem with the connection (typically the server is shut down or there is some other reason for a lost connection) + * Notice: There is no way of knowing that a command exists, which does not return a response. Every command without response will return an empty string. + * @param command the command which should be executed on the remote server + * @return response of the server or null + */ + String getCommandOutput(String command); +} diff --git a/src/main/java/org/codeoverflow/chatoverflow/api/io/output/RconOutput.java b/src/main/java/org/codeoverflow/chatoverflow/api/io/output/RconOutput.java new file mode 100644 index 0000000..2e6d4be --- /dev/null +++ b/src/main/java/org/codeoverflow/chatoverflow/api/io/output/RconOutput.java @@ -0,0 +1,13 @@ +package org.codeoverflow.chatoverflow.api.io.output; + +public interface RconOutput extends Output { + + + /** + * Execute a command on a remote (rcon) server. + * Notice: There is no way of knowing if the commands exists. + * @param command the command which should be executed + * @return if the command was successfully sent to the server. (Returns false for e.g. a not anymore existent server) + */ + boolean sendCommand(String command); +} diff --git a/src/main/java/org/codeoverflow/chatoverflow/api/plugin/configuration/Input.java b/src/main/java/org/codeoverflow/chatoverflow/api/plugin/configuration/Input.java index b1516e2..b0f9afb 100644 --- a/src/main/java/org/codeoverflow/chatoverflow/api/plugin/configuration/Input.java +++ b/src/main/java/org/codeoverflow/chatoverflow/api/plugin/configuration/Input.java @@ -1,6 +1,7 @@ package org.codeoverflow.chatoverflow.api.plugin.configuration; import org.codeoverflow.chatoverflow.api.io.input.FileInput; +import org.codeoverflow.chatoverflow.api.io.input.RconInput; import org.codeoverflow.chatoverflow.api.io.input.SampleInput; import org.codeoverflow.chatoverflow.api.io.input.SerialInput; import org.codeoverflow.chatoverflow.api.io.input.chat.DiscordChatInput; @@ -101,6 +102,18 @@ public Requirement file(String uniqueRequirementId, String displayNam return requirements.requireInput(uniqueRequirementId, displayName, isOptional, FileInput.class); } + /** + * Requires a connection to a RCON Server + * + * @param uniqueRequirementId any unique id by which your plugin can identify the requirement + * @param displayName Is displayed to the framework user and to tell him what to enter + * @param isOptional true if this requirement is optional, false if mandatory + * @return the requirement object + */ + public Requirement rcon(String uniqueRequirementId, String displayName, boolean isOptional) { + return requirements.requireInput(uniqueRequirementId, displayName, isOptional, RconInput.class); + } + // Add more inputs here } diff --git a/src/main/java/org/codeoverflow/chatoverflow/api/plugin/configuration/Output.java b/src/main/java/org/codeoverflow/chatoverflow/api/plugin/configuration/Output.java index c8444a6..0aafc5e 100644 --- a/src/main/java/org/codeoverflow/chatoverflow/api/plugin/configuration/Output.java +++ b/src/main/java/org/codeoverflow/chatoverflow/api/plugin/configuration/Output.java @@ -1,6 +1,7 @@ package org.codeoverflow.chatoverflow.api.plugin.configuration; import org.codeoverflow.chatoverflow.api.io.output.FileOutput; +import org.codeoverflow.chatoverflow.api.io.output.RconOutput; import org.codeoverflow.chatoverflow.api.io.output.SerialOutput; import org.codeoverflow.chatoverflow.api.io.output.chat.DiscordChatOutput; import org.codeoverflow.chatoverflow.api.io.output.chat.TwitchChatOutput; @@ -62,6 +63,18 @@ public Requirement file(String uniqueRequirementId, String displayNa return requirements.requireOutput(uniqueRequirementId, displayName, isOptional, FileOutput.class); } + /** + * Requires a game server with enabled rcon + * + * @param uniqueRequirementId any unique id by which your plugin can identify the requirement + * @param displayName Is displayed to the framework user and to tell him what to enter + * @param isOptional true if this requirement is optional, false if mandatory + * @return the requirement object + */ + public Requirement rcon(String uniqueRequirementId, String displayName, boolean isOptional) { + return requirements.requireOutput(uniqueRequirementId, displayName, isOptional, RconOutput.class); + } + // Add more outputs here }