Compatibility
Minecraft: Java Edition
1.21–1.21.3
Platforms
Fabric
Supported environments
75% of ad revenue goes to creators
Support creators and Modrinth ad-free with Modrinth+Creators
Details
Licensed MIT
Published 4 weeks ago
Updated 3 weeks ago
Inject is a server-side library which aims to help developers inject into Netty easier!
Examples
You can register an Injector which logs every incoming packet:
class MyCoolPacketLogger extends Injector {
@Override
public boolean isRelevant(InjectorContext ctx, PacketDirection direction) {
return true;
}
@Override
public boolean onRead(ChannelHandlerContext ctx, ByteBuf msg) {
System.out.println("Packet received!");
return false;
}
}
Which you can then register:
Injector packetLogger = new MyCoolPacketLogger();
// On Paper:
InjectPaper.INSTANCE.registerInjector(packetLogger);
// On Spigot:
InjectSpigot.INSTANCE.registerInjector(packetLogger);
// On Fabric:
InjectFabric.INSTANCE.registerInjector(packetLogger);
inject also has built-in support for HTTP:
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;
}
}
This will respond to any incoming HTTP request on the Minecraft Server's connection.
Usage
Add the andante repo to gradle:
repositories {
maven("https://maven.andante.dev/releases/")
}
Add the dependency:
dependencies {
implementation("net.mcbrawls.inject:api:VERSION")
// Fabric:
include(modImplementation("net.mcbrawls.inject:fabric:VERSION")!!)
// Paper:
implementation("net.mcbrawls.inject:paper:VERSION")
// Spigot:
implementation("net.mcbrawls.inject:spigot:VERSION")
}
NOTE: The Spigot and Paper modules are licensed under GPL-3.0 but I was unable to set the license to both.