Compare commits

...

10 commits

Author SHA1 Message Date
Tofaa2
df6fe0f084 Attempt at central publishing 4
Some checks are pending
Build / build (push) Waiting to run
2025-10-25 18:50:50 +04:00
Tofaa2
b04ef4c77f Attempt at central publishing 2 2025-10-25 18:15:53 +04:00
Tofaa2
d21a4be023 Attempt at central publishing 2 2025-10-25 17:42:36 +04:00
Tofaa2
e85017fded Attempt at central publishing 2025-10-25 17:37:40 +04:00
Tofaa
cef23ea82d
Merge pull request #44 from huanmeng-qwq/fix/render-packet
Fix the rendered packet overwrites the original metadata
2025-09-01 22:20:22 +04:00
huanmeng-qwq
5add72f67d
fix: Fix the rendered packet overwrites the original metadata 2025-09-02 01:14:28 +08:00
Tofaa
598d71fa30
Merge pull request #43 from steveb05/fix/use-variant-registry
Use registry for cat and wolf variant
2025-08-20 04:21:28 +04:00
steve
b7b69c3637
feat: add wolf variants 2025-08-20 00:44:41 +02:00
steve
30bd847ac0
fix: use registry for cat variants 2025-08-20 00:44:33 +02:00
Tofaa
d4c3b1e4e9
Update ItemFrameMeta.java 2025-08-06 10:14:31 +04:00
9 changed files with 157 additions and 43 deletions

View file

@ -32,6 +32,9 @@ jobs:
- name: Run build & publish with Gradle Wrapper
if: github.ref == 'refs/heads/master'
env:
OSSRH_USERNAME: ${{ secrets.CENTRAL_PORTAL_USERNAME }}
OSSRH_PASSWORD: ${{ secrets.CENTRAL_PORTAL_TOKEN }}
run: chmod +x ./gradlew && ./gradlew publishAllPublicationsToMavenRepository
- name: Run build with Gradle Wrapper

View file

@ -0,0 +1,37 @@
name: Publish to Maven Central
on:
release:
types: [published]
permissions:
contents: read
jobs:
publish:
runs-on: ubuntu-latest
steps:
- name: Clone project
uses: actions/checkout@v4
- name: Install JDK 8
uses: actions/setup-java@v4
with:
java-version: '8'
distribution: 'temurin'
check-latest: true
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v4
- name: Import GPG key
run: |
echo "${{ secrets.GPG_PRIVATE_KEY }}" | gpg --import --batch --yes
echo "${{ secrets.GPG_PASSPHRASE }}" | gpg --pinentry-mode loopback --passphrase-fd 0 --batch --yes --import
- name: Publish to Maven Central
env:
OSSRH_USERNAME: ${{ secrets.CENTRAL_PORTAL_USERNAME }}
OSSRH_PASSWORD: ${{ secrets.CENTRAL_PORTAL_TOKEN }}
GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
run: ./gradlew publishAllPublicationsToMavenRepository --no-daemon

View file

@ -8,37 +8,36 @@ You can easily use EntityLib platformless by using the `api` or `common` module
If you like EntityLib and or want to sponsor me, visit my [ko-fi page](https://ko-fi.com/tofaa) :D
EntityLib builds are available on [Jitpack](https://jitpack.io/#Tofaa2/EntityLib) and my own [Maven Repository](https://maven.evokegames.gg/#/snapshots/me/tofaa/entitylib)
The examples below use my repository, open the jitpack link for its group information.
EntityLib is published to [Maven Central](https://central.sonatype.com/artifact/io.github.tofaa2). Snapshots are available on pushes to the main branch, and stable releases are published on GitHub releases.
Gradle (Groovy DSL):
```groovy
repositories {
maven { url 'https://maven.evokegames.gg/snapshots' }
mavenCentral()
}
dependencies {
implementation 'me.tofaa.entitylib:<platform>:<latest-release-version'
implementation 'io.github.tofaa2:<platform>:<version>'
}
```
Gradle (Kotlin DSL):
```kotlin
repositories {
maven(url = "https://maven.evokegames.gg/snapshots")
mavenCentral()
}
dependencies {
implementation("me.tofaa.entitylib:<platform>:<latest-release-version>")
implementation("io.github.tofaa2:<platform>:<version>")
}
```
Maven:
```xml
```xml
<dependency>
<groupId>me.tofaa.entitylib</groupId>
<artifactId>(platform)</artifactId>
<version>(latest-release-version)</version>
<groupId>io.github.tofaa2</groupId>
<artifactId><platform></artifactId>
<version><version></version>
</dependency>
```
@ -50,8 +49,6 @@ EntityLib does not provide packet-events as a dependency, you must have it in yo
- Creation of WrapperEntities
- Keeping track of entities.
## Usage
For more realistic examples, please take a look at the `test-plugin` module. It has an example `Bukkit` plugin that uses EntityLib.
@ -131,6 +128,23 @@ class Example {
```
## Publishing to Maven Central
EntityLib uses the new Maven Central publishing system via the Central Portal (replacing the deprecated OSSRH). To publish, set up the following GitHub secrets:
- `OSSRH_USERNAME`: Your Central Portal username (usually your email).
- `OSSRH_PASSWORD`: Your publishing token from the Central Portal.
- `GPG_PRIVATE_KEY`: Your GPG private key (for signing artifacts).
- `GPG_PASSPHRASE`: The passphrase for your GPG key.
### Setting Up Central Portal Credentials
1. Go to [Central Portal](https://central.sonatype.com/) and log in with your GitHub account.
2. **Create a namespace**: In the "Namespaces" section, create a new namespace for your group ID (`io.github.tofaa2`). This is crucial for publishing to work.
3. Generate a publishing token from the "Account Settings" > "Publishing Tokens".
4. Use your email as the username and the token as the password.
Snapshots are automatically published on pushes to the `master` branch. Stable releases are published when a GitHub release is created.
### TODO:
Once this list is complete, i will release a stable version of the library.
- [ ] Implement checks for each EntityMeta to make sure the version specific data is correct.

View file

@ -1,5 +1,7 @@
package me.tofaa.entitylib.meta.mobs.tameable;
import com.github.retrooper.packetevents.protocol.entity.cat.CatVariant;
import com.github.retrooper.packetevents.protocol.entity.cat.CatVariants;
import com.github.retrooper.packetevents.protocol.entity.data.EntityDataTypes;
import me.tofaa.entitylib.extras.DyeColor;
import me.tofaa.entitylib.meta.Metadata;
@ -20,11 +22,12 @@ public class CatMeta extends TameableMeta {
@NotNull
public CatMeta.Variant getVariant() {
return super.metadata.getIndex(OFFSET, Variant.BLACK);
final CatVariant catVariant = super.metadata.getIndex(OFFSET, CatVariants.BLACK);
return Variant.fromCatVariant(catVariant);
}
public void setVariant(@NotNull CatMeta.Variant value) {
super.metadata.setIndex(OFFSET, EntityDataTypes.CAT_VARIANT, value.ordinal());
super.metadata.setIndex(OFFSET, EntityDataTypes.TYPED_CAT_VARIANT, value.getCatVariant());
}
public boolean isLying() {
@ -51,21 +54,40 @@ public class CatMeta extends TameableMeta {
super.metadata.setIndex(offset(OFFSET, 3), EntityDataTypes.INT, value.ordinal());
}
public enum Variant {
TABBY,
BLACK,
RED,
SIAMESE,
BRITISH_SHORTHAIR,
CALICO,
PERSIAN,
RAGDOLL,
WHITE,
JELLIE,
ALL_BLACK;
ALL_BLACK(CatVariants.ALL_BLACK),
BLACK(CatVariants.BLACK),
BRITISH_SHORTHAIR(CatVariants.BRITISH_SHORTHAIR),
CALICO(CatVariants.CALICO),
JELLIE(CatVariants.JELLIE),
PERSIAN(CatVariants.PERSIAN),
RAGDOLL(CatVariants.RAGDOLL),
RED(CatVariants.RED),
SIAMESE(CatVariants.SIAMESE),
TABBY(CatVariants.TABBY),
WHITE(CatVariants.WHITE);
private final CatVariant catVariant;
Variant(final CatVariant catVariant) {
this.catVariant = catVariant;
}
private static final Variant[] VALUES = values();
public CatVariant getCatVariant() {
return catVariant;
}
@NotNull
public static Variant fromCatVariant(@NotNull final CatVariant catVariant) {
for (final Variant variant : VALUES) {
if (variant.getCatVariant().equals(catVariant)) {
return variant;
}
}
return BLACK;
}
}
}

View file

@ -1,19 +1,31 @@
package me.tofaa.entitylib.meta.mobs.tameable;
import com.github.retrooper.packetevents.protocol.entity.data.EntityDataTypes;
import com.github.retrooper.packetevents.protocol.entity.wolfvariant.WolfVariant;
import com.github.retrooper.packetevents.protocol.entity.wolfvariant.WolfVariants;
import me.tofaa.entitylib.extras.DyeColor;
import me.tofaa.entitylib.meta.Metadata;
import me.tofaa.entitylib.meta.types.TameableMeta;
import org.jetbrains.annotations.NotNull;
public class WolfMeta extends TameableMeta {
public static final byte OFFSET = TameableMeta.MAX_OFFSET;
public static final byte MAX_OFFSET = OFFSET + 3;
public static final byte MAX_OFFSET = OFFSET + 5;
public WolfMeta(int entityId, Metadata metadata) {
super(entityId, metadata);
}
@NotNull
public WolfVariant getVariant() {
return super.metadata.getIndex(offset(OFFSET, 3), WolfVariants.PALE);
}
public void setVariant(@NotNull WolfVariant value) {
super.metadata.setIndex(offset(OFFSET, 3), EntityDataTypes.TYPED_WOLF_VARIANT, value);
}
public boolean isBegging() {
return super.metadata.getIndex(OFFSET, false);
}

View file

@ -21,11 +21,11 @@ public class ItemFrameMeta extends EntityMeta implements ObjectData {
@NotNull
public ItemStack getItem() {
return super.metadata.getIndex(9, ItemStack.EMPTY);
return super.metadata.getIndex((byte)9, ItemStack.EMPTY);
}
public void setItem(@NotNull ItemStack value) {
super.metadata.setIndex(9, EntityDataTypes.ITEMSTACK, value);
super.metadata.setIndex((byte)9, EntityDataTypes.ITEMSTACK, value);
}
@NotNull

View file

@ -4,6 +4,7 @@ import com.github.retrooper.packetevents.protocol.entity.data.EntityData;
import com.github.retrooper.packetevents.protocol.entity.data.EntityDataTypes;
import com.github.retrooper.packetevents.wrapper.play.server.WrapperPlayServerEntityMetadata;
import me.tofaa.entitylib.EntityLib;
import java.util.ArrayList;
import java.util.Locale;
import java.util.Optional;
import java.util.UUID;
@ -15,6 +16,11 @@ public class PacketUtil {
}
public static void renderPacket(UUID user, WrapperPlayServerEntityMetadata metadata) {
final ArrayList<EntityData<?>> copiedEntityData = new ArrayList<>();
metadata.getEntityMetadata().forEach(entityData ->
copiedEntityData.add(new EntityData(entityData.getIndex(), entityData.getType(), entityData.getValue()))
);
metadata.setEntityMetadata(copiedEntityData);
Locale locale = EntityLib.getApi().getUserLocaleProvider().locale(user);
for (final EntityData<?> entityData : metadata.getEntityMetadata()) {
if (entityData.getType() == EntityDataTypes.ADV_COMPONENT) {

View file

@ -3,7 +3,7 @@ import java.io.ByteArrayOutputStream
val fullVersion = "3.0.3"
val snapshot = true
group = "me.tofaa.entitylib"
group = "io.github.tofaa2"
description = rootProject.name
fun getVersionMeta(includeHash: Boolean): String {
@ -21,8 +21,8 @@ fun getVersionMeta(includeHash: Boolean): String {
}
return "$commitHash-SNAPSHOT"
}
version = "$fullVersion${getVersionMeta(true)}"
ext["versionBeta"] = getVersionMeta(true)
version = "$fullVersion${getVersionMeta(false)}"
ext["versionBeta"] = getVersionMeta(false)
ext["versionNoHash"] = "$fullVersion${getVersionMeta(false)}"
tasks {
@ -62,6 +62,12 @@ tasks {
}
}
register("publishAllPublicationsToMavenRepository") {
val publishTasks = subModuleTasks("publishAllPublicationsToMavenRepository")
dependsOn(publishTasks)
group = "publishing"
}
register<Delete>("clean") {
val cleanTasks = subModuleTasks("clean")
dependsOn(cleanTasks)

View file

@ -1,6 +1,7 @@
plugins {
`java-library`
`maven-publish`
signing
}
group = rootProject.group
@ -45,17 +46,6 @@ tasks {
}
publishing {
repositories {
maven {
url = uri("https://maven.evokegames.gg/snapshots")
credentials {
username = System.getenv("TYCOONS_REPO_USER")
password = System.getenv("TYCOONS_REPO_PASS")
}
}
}
publications {
create<MavenPublication>("EntityLib") {
groupId = project.group as String
@ -75,6 +65,14 @@ publishing {
}
}
developers {
developer {
id = "Tofaa2"
name = "Tofaa"
email = "tofaadev@gmail.com"
}
}
scm {
connection = "scm:git:https://github.com/Tofaa2/EntityLib.git"
developerConnection = "scm:git:https://github.com/Tofaa2/EntityLib.git"
@ -83,6 +81,22 @@ publishing {
}
}
}
repositories {
maven {
url = uri("https://central.sonatype.com/api/v1/publisher/upload")
credentials {
username = System.getenv("OSSRH_USERNAME")
password = System.getenv("OSSRH_PASSWORD")
}
}
}
}
signing {
if (!version.toString().endsWith("-SNAPSHOT")) {
sign(publishing.publications["EntityLib"])
}
}
// So that SNAPSHOT is always the latest SNAPSHOT