Download inject — Minecraft Mods — MetaMods

inject

Active

Downloads

0

Last update

5 months ago

Versions

1.21 — 1.21.4
Server
Fabric
Libraries
Technological

inject

inject is a server-side library designed to significantly simplify the process of injecting into Netty for developers.

Usage Capabilities

Using the HttpInjector class, developers can process HTTP requests sent to the Minecraft server. Let's consider a practical example:

class MyEpicHttpInjector extends HttpInjector {
    @Override
    public HttpByteBuf intercept(ChannelHandlerContext ctx, HttpRequest request) {
        HttpByteBuf buf = HttpByteBuf.httpBuf(ctx);
        buf.writeStatusLine("1.1", 200, "OK");
        buf.writeText("Hello from Minecraft!");
        return buf;
    }
}

Registration Process

For Fabric, use the InjectFabric class:

public class MyMod implements ModInitializer {
    @Override
    public void onInitialize() {
        InjectFabric.INSTANCE.registerInjector(new MyEpicHttpInjector());
    }
}

For Spigot, Paper, and compatible platforms, use the InjectSpigot class:

public class MyPlugin extends JavaPlugin {
    @Override
    public void onEnable() {
        InjectSpigot.INSTANCE.registerInjector(new MyEpicHttpInjector());
    }
}

After configuration, the HTTP injector will respond with "Hello from Minecraft!" text to any HTTP request sent to the Minecraft server port.

$ curl http://localhost:25565
Hello from Minecraft!

Supported Web Servers

The library is compatible with various popular web servers:

  • Spring Boot: spring module
  • Javalin: javalin module
  • Ktor: ktor module
  • Jetty: jetty module
  • Manual request handling: http module

For more detailed study, practical examples are available in the examples module.

Project Integration

Add the andante repository to gradle:

repositories {
    maven("https://maven.mcbrawls.net/releases/")
}

Include the necessary dependencies:

dependencies {
    implementation("net.mcbrawls.inject:api:VERSION")

    // For HTTP operations
    implementation("net.mcbrawls.inject:http:VERSION")

    // Fabric:
    include(modImplementation("net.mcbrawls.inject:fabric:VERSION")!!)

    // Spigot/Paper:
    implementation("net.mcbrawls.inject:spigot:VERSION")

    // Additional modules for Spring, Ktor, and other platforms can be found: Github repo.
}

Replace VERSION with the current version from the releases section.

Project members
andante

andante

Developer

radstevee

radstevee

Developer

Created: 6 Nov 2024

ID: 63726