A library for communication with a Minecraft client/server.
Find a file
Mansi Patil cc8f0a55b1
Some checks failed
Build / build (push) Has been cancelled
Refactor: Component structural cleanup (Extract Class, Move Method, Replace Conditional) (#923)
* refactor: replace magic numbers with named constants in ServerListener.keepAlive

Replace unexplained numeric literals 15000L and 50 with named constants
KEEPALIVE_TIMEOUT_MS and KEEPALIVE_TICK_INTERVAL_MS for improved readability.

* refactor: introduce explaining variables for URI construction in SessionService

Extract inline URI.create(String.format(...)) calls into named local variables
hasJoinedUri and profileUri for improved readability and debuggability.

* refactor: extract state handler methods in ServerListener.packetReceived

Split the 100+ line packetReceived method into five private helper methods:
handleHandshakePacket, handleLoginPacket, handleStatusPacket,
handleGamePacket, and handleConfigurationPacket, improving readability
and adhering to the Extract Method refactoring technique.

* Refactor (Set II-1): Extract Texture classes from GameProfile

* Refactor (Set II-2): Move keep-alive logic into KeepAliveState class

* Refactor (Set II-3): Replace Conditional with Polymorphism (ContainerActionType)

* style: revert automatic javadoc and line-length formatting

* style: revert automatic formatting in several files

* style: revert formatting of setCompression call

* style: revert formatting changes, move Texture classes to auth/texture package

- Revert Javadoc alignment in GameProfile.java
- Revert comment line wrapping in ResolvableProfile.java
- Revert all line-length/indentation changes in MinecraftTypes.java
- Move Texture, TextureModel, TextureType to auth/texture/ package
- Update imports in GameProfile.java, MinecraftTypes.java, ResolvableProfile.java
2026-03-18 02:13:03 +00:00
.github/workflows Update github action 2025-10-20 15:58:11 +02:00
buildSrc Actually fix publishing, prevent snapshots publishing to releases. 2025-07-02 17:10:55 +01:00
example Updated to MinecraftAuth 5 (#915) 2025-11-16 21:55:58 +01:00
gradle Bump cloudburstmc/nbt library 2026-03-04 02:26:29 +01:00
protocol Refactor: Component structural cleanup (Extract Class, Move Method, Replace Conditional) (#923) 2026-03-18 02:13:03 +00:00
.editorconfig Add .editorconfig (#801) 2024-05-08 14:44:49 +01:00
.gitignore Migrate to gradle, fix examples (#769) 2023-12-19 13:01:53 -05:00
build.gradle.kts Move package/license to GeyserMC, gradle conventions and submodules (#782) 2024-01-11 12:21:23 -05:00
gradlew Migrate to gradle, fix examples (#769) 2023-12-19 13:01:53 -05:00
gradlew.bat Migrate to gradle, fix examples (#769) 2023-12-19 13:01:53 -05:00
jitpack.yml Create jitpack.yml (#778) 2023-12-22 19:32:29 -08:00
LICENSE.txt Move package/license to GeyserMC, gradle conventions and submodules (#782) 2024-01-11 12:21:23 -05:00
lombok.config Remove unused exceptions, use java 9+ features and checkerframework, other cleanup (#780) 2024-01-04 13:04:25 -05:00
README.md Update javadoc link in readme 2025-01-13 16:33:47 +00:00
settings.gradle.kts Replace MCAuth with RK_01 MinecraftAuth (#795) 2024-06-17 13:23:42 -07:00

MCProtocolLib

MCProtocolLib is a simple library for communicating with Minecraft clients and servers. It allows developers to build custom bots, clients, or servers for Minecraft with ease.

Example Code

See the example folder for sample usage.

Adding as a Dependency

MCProtocolLib builds are published to the Open Collaboration repository. Follow the below steps to add MCProtocolLib as a dependency to your project.

Maven

Add the Repository

<repositories>
    <repository>
        <id>opencollab</id>
        <url>https://repo.opencollab.dev/main/</url>
    </repository>
</repositories>

Add the Dependency

<dependency>
    <groupId>org.geysermc.mcprotocollib</groupId>
    <artifactId>protocol</artifactId>
    <version>(version here)</version>
</dependency>

Gradle (Groovy DSL)

Add the Repository

repositories {
    maven { 
        name 'opencollab'
        url 'https://repo.opencollab.dev/main/'
    }
}

Add the Dependency

dependencies {
    implementation 'org.geysermc.mcprotocollib:protocol:(version here)'
}

Gradle (Kotlin DSL)

Add the Repository

repositories {
    maven("https://repo.opencollab.dev/main/") {
        name = "opencollab"
    }
}

Add the Dependency

dependencies {
    implementation("org.geysermc.mcprotocollib:protocol:(version here)")
}

Snapshots

To use snapshot builds, switch the URL to https://repo.opencollab.dev/maven-snapshots/.

Javadocs

You can find the Javadocs for MCProtocolLib on opencollab.

Building the Source

MCProtocolLib uses Gradle to manage dependencies. To build the source code, run ./gradlew clean build in the project root directory.

Support and Development

Please join the GeyserMC Discord server and visit the #mcprotocollib channel for discussion and support for this project.

License

MCProtocolLib is licensed under the MIT license.