Skip to content

Repository files navigation


Introduction

Minecraft Protocol is a project I developed because all existing libraries for packet handling are either outdated or insufficiently lightweight for use in my projects (also due to a complete rewrite of the Abelix codebase).

The project was written in a single attempt by one person, so there might be bugs or less-than-perfect code. I would greatly appreciate any pull requests or issues.

Project Overview

Purpose

This project is designed for the most convenient and integrable development of systems that require the use of Minecraft protocol packets (e.g., fake entities, nametags for servers, proxy systems).

Key Objectives

  • Simplify packet handling and monitoring as much as possible.
  • Ensure integration with all modern server cores and standalone applications.

Usage Guide

Maven / Gradle library adding

  1. Add a repository:

Maven:

<repositories>
<repository>
<id>milansky-repo</id>
<url>https://maven.milansky.ovh/releases</url>
</repository>
</repositories>

Gradle:

repositories {
maven {
url ="https://maven.milansky.ovh/releases"
}
}
  1. Add dependencies

Maven:

<properties>
<protocol.version>1.1.1</protocol.version>
</properties>
<dependencies>
<dependency>
<groupId>by.milansky.protocol</groupId>
<artifactId>api</artifactId>
<version>${protocol.version}</version>
</dependency>
<dependency>
<groupId>by.milansky.protocol</groupId>
<artifactId>base</artifactId>
<version>${protocol.version}</version>
</dependency>
<dependency>
<groupId>by.milansky.protocol</groupId>
<artifactId>vanilla-protocol</artifactId>
<version>${protocol.version}</version>
</dependency>
<!-- Add bukkit if you need it -->
<dependency>
<groupId>by.milansky.protocol</groupId>
<artifactId>bukkit</artifactId>
<version>${protocol.version}</version>
</dependency>
</dependencies>

Gradle:

dependencies {
// It's better to use gradle's dependencyResolutionManagementdef protocolVersion ='1.1.1'
compileOnly "by.milansky.protocol:api:${protocolVersion}"
compileOnly "by.milansky.protocol:base:${protocolVersion}"
compileOnly "by.milansky.protocol:vanilla-protocol:${protocolVersion}"// Add bukkit if you need it
compileOnly "by.milansky.protocol:bukkit:${protocolVersion}"
}

Java API usage

More detailed usage examples can be found in the examples directory. However, to briefly explain, here's how you can listen to all ClientboundTeam packets:

  1. Create a handler to process packets:
@Log4j2publicfinalclassClientboundTeamHandler {
@PacketProcessorpublic@NotNullPacketHandleResulthandle(finalChannelchannel, finalClientboundTeamteam) {
// Log that the server is attempting to send a packetlog.info("Outbound team packet: {}", team);
if (team.containsPlayer("milanskyy")) {
// Prevent the packet from being sentreturnBasePacketHandleResult.cancel();
}
// Everything is fine; allow the packet to be sentreturnBasePacketHandleResult.ok();
}
}
  1. Add the handler on player join:
publicfinalclassNametagListenerimplementsListener {
@EventHandlerpublicvoidonCreate(finalProtocolPlayerCreateEventevent) {
valprotocolPlayer = event.protocolPlayer();
// Since this handler is annotation-based, wrap it in an AnnotationBasedHandler// and add it to the playerprotocolPlayer.appendPacketHandler(AnnotationBasedHandler.create(ClientboundTeamHandler.create()));
}
}

Credits

Special thanks for ideas and inspiration to these projects:

About

Fast and easy minecraft protocol library

Topics

Resources

Stars

17 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages