diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..1dcef2d --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +node_modules +.env \ No newline at end of file diff --git a/.npmignore b/.npmignore new file mode 100644 index 0000000..a263413 --- /dev/null +++ b/.npmignore @@ -0,0 +1,8 @@ +*/__tests__/ +docs/ +src/ +metadata/ +.vscode/ +.github/ +.env +tsconfig.json \ No newline at end of file diff --git a/README.md b/README.md index e4e1778..bf1d982 100644 --- a/README.md +++ b/README.md @@ -1 +1,123 @@ -# ForgeMinecraft \ No newline at end of file +
+
+# ForgeMinecraft
+
+ForgeMinecraft is an extension that provides real-time Minecraft server management via the management server protocol, alongside various functions for retrieving status and metadata from Java and Bedrock servers.
+
+OptionalcalendarReadonlyruntimeOptionalprops: Partial<IRunnable>OptionalsyncVars: booleanFetches all emojis of the application.
+Optionalonce: booleanWhether to fetch only when the collection is empty.
+StatictraverseReadonlyoptionsOptionalrequireA list of extension names this extension requires
+OptionalserverOptionaltargetOnly the versions written here will be allowed
+Gets the status response of a Bedrock Minecraft server. Uses the bedrock client options if no parameters are provided.
Optionalhost: string | nullThe host domain of the server.
+Optionalport: numberThe port for the host domain.
+Gets the status response of a Java Minecraft server. Uses the java client options if no parameters are provided.
Optionalhost: string | nullThe host domain of the server.
+Optionalport: numberThe port for the host domain.
+ProtectedloadProtectedvalidateStaticdefaultOptionalfn: (cmd: BaseCommand<keyof IMinecraftEvents>) => booleanOptionalevent: "update"OptionalconnectionOptionalserverStaticdefaultOptionalevent: keyof IConnectionEvents
+ForgeMinecraft is an extension that provides real-time Minecraft server management via the management server protocol, alongside various functions for retrieving status and metadata from Java and Bedrock servers.
+ +Run the following command to install the required npm packages:
npm i @tryforge/forge.minecraft
+
+
+Here’s an example of how your main file should look:
+const { ForgeClient } = require("@tryforge/forgescript")
const { ForgeMinecraft } = require("@tryforge/forge.minecraft")
const minecraft = new ForgeMinecraft({
java: {
host: "0.0.0.0", // Default Java Server
port: 25565
},
bedrock: {
host: "0.0.0.0" // Default Bedrock Server
}
})
const client = new ForgeClient({
...options, // The options you currently have
extensions: [
minecraft
]
})
client.commands.load("commands")
client.login("YourToken")
+
+
+++💡 Tip
+
+View all available client options here.
Minecraft’s management server protocol, introduced in 1.21.9, enables remote management and monitoring of your Minecraft server. It allows this extension to connect to the server, execute administrative actions, and receive real-time events such as player activity, server status changes, and configuration updates, making automation and server control easier.
+To enable the management server protocol, set up management-server-enabled, management-server-port and management-server-host in the server.properties file of your Minecraft server:
management-server-enabled=true
management-server-port=25585
management-server-host=0.0.0.0
management-server-secret=
+
+
+You can either set management-server-secret to a random 40 character long alphanumeric string or leave it empty and let the Minecraft server generate a random token on startup. You will need this token to connect to the server.
If you want to establish connections from a web browser, you need to set the allowed origins:
+management-server-allowed-origins=http\://localhost\:63315
+
+
+By default, TLS is enabled, but the server will crash if you don't provide a certificate. If the management server protocol is not exposed to the internet, or you are using a reverse proxy, the easiest option would be to disable TLS:
+management-server-tls-enabled=false
+
+
+Next, configure the ForgeMinecraft client. This is where you specify which server events you want to listen to and provide the management server connection details, such as host, port, and authentication token (secret). These options determine how ForgeMinecraft connects to your server and which real-time events the extension receives.
const minecraft = new ForgeMinecraft({
events: [
"playerJoined",
"serverStarted"
],
server: {
host: "0.0.0.0",
port: 3000,
token: "YourAuthToken",
}
})
// ...
minecraft.commands.load("minecraft") // Load your server events folder
// ...
+
+
+++💡 Tip
+
+View all available server options here.
Desired Java and Bedrock functions let you fetch status and metadata from Minecraft servers on demand. You can call these functions with custom host and port arguments, or define default Java and Bedrock server settings in the client configuration to avoid passing arguments each time. The responses include various details such as server status, version, players, and more. Note that availability depends on the server, as not all servers allow full information to be queried.
OptionalallowOptionalargsThe args used in the message command
+The available discord client
+The command used for this execution
+OptionalcontainerThe container reference to use
+The compiled data to execute
+OptionaldisableRemoves errors output to console
+OptionaldoWhether to suppress sending the response to discord.
+OptionalenvironmentThe already existing env variables
+OptionalextrasExtras data
+OptionalkeywordsThe already existing variables defined with $let
+The context this code will run in
+OptionalredirectWhether to suppress errors from being sent to discord, and be sent to console instead
+OptionalstatesThe old and new states of an event
+OptionalbedrockThe default Bedrock server options to use for bedrock functions.
+OptionaleventsThe events to receive from the management server.
+OptionaljavaThe default Java server options to use for java functions.
+OptionalserverThe management server options used to establish a connection.
+The host domain of the server.
+OptionalmaxThe maximum number of times to attempt to reconnect to the server. Set to 0 for infinite attempts.
The port for the host connection.
+OptionalreconnectWhether to automatically reconnect to the server if the connection is lost.
+OptionalreconnectThe interval in ms used to reconnect to the server.
+The token needed to connect to the server.
+Const
Clones keywords and environment vars
+