Compare commits
10 commits
8ac2119c67
...
df6fe0f084
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
df6fe0f084 | ||
|
|
b04ef4c77f | ||
|
|
d21a4be023 | ||
|
|
e85017fded | ||
|
|
cef23ea82d | ||
|
|
5add72f67d | ||
|
|
598d71fa30 | ||
|
|
b7b69c3637 | ||
|
|
30bd847ac0 | ||
|
|
d4c3b1e4e9 |
9 changed files with 157 additions and 43 deletions
3
.github/workflows/dev-build-release.yml
vendored
3
.github/workflows/dev-build-release.yml
vendored
|
|
@ -32,6 +32,9 @@ jobs:
|
||||||
|
|
||||||
- name: Run build & publish with Gradle Wrapper
|
- name: Run build & publish with Gradle Wrapper
|
||||||
if: github.ref == 'refs/heads/master'
|
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
|
run: chmod +x ./gradlew && ./gradlew publishAllPublicationsToMavenRepository
|
||||||
|
|
||||||
- name: Run build with Gradle Wrapper
|
- name: Run build with Gradle Wrapper
|
||||||
|
|
|
||||||
37
.github/workflows/publish-to-maven-central.yml
vendored
Normal file
37
.github/workflows/publish-to-maven-central.yml
vendored
Normal 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
|
||||||
38
README.md
38
README.md
|
|
@ -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
|
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)
|
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.
|
||||||
The examples below use my repository, open the jitpack link for its group information.
|
|
||||||
|
|
||||||
Gradle (Groovy DSL):
|
Gradle (Groovy DSL):
|
||||||
```groovy
|
```groovy
|
||||||
repositories {
|
repositories {
|
||||||
maven { url 'https://maven.evokegames.gg/snapshots' }
|
mavenCentral()
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
implementation 'me.tofaa.entitylib:<platform>:<latest-release-version'
|
implementation 'io.github.tofaa2:<platform>:<version>'
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
Gradle (Kotlin DSL):
|
Gradle (Kotlin DSL):
|
||||||
```kotlin
|
```kotlin
|
||||||
repositories {
|
repositories {
|
||||||
maven(url = "https://maven.evokegames.gg/snapshots")
|
mavenCentral()
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
implementation("me.tofaa.entitylib:<platform>:<latest-release-version>")
|
implementation("io.github.tofaa2:<platform>:<version>")
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
Maven:
|
Maven:
|
||||||
```xml
|
```xml
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>me.tofaa.entitylib</groupId>
|
<groupId>io.github.tofaa2</groupId>
|
||||||
<artifactId>(platform)</artifactId>
|
<artifactId><platform></artifactId>
|
||||||
<version>(latest-release-version)</version>
|
<version><version></version>
|
||||||
</dependency>
|
</dependency>
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
@ -50,8 +49,6 @@ EntityLib does not provide packet-events as a dependency, you must have it in yo
|
||||||
- Creation of WrapperEntities
|
- Creation of WrapperEntities
|
||||||
- Keeping track of entities.
|
- Keeping track of entities.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
|
|
||||||
For more realistic examples, please take a look at the `test-plugin` module. It has an example `Bukkit` plugin that uses EntityLib.
|
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:
|
### TODO:
|
||||||
Once this list is complete, i will release a stable version of the library.
|
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.
|
- [ ] Implement checks for each EntityMeta to make sure the version specific data is correct.
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,7 @@
|
||||||
package me.tofaa.entitylib.meta.mobs.tameable;
|
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 com.github.retrooper.packetevents.protocol.entity.data.EntityDataTypes;
|
||||||
import me.tofaa.entitylib.extras.DyeColor;
|
import me.tofaa.entitylib.extras.DyeColor;
|
||||||
import me.tofaa.entitylib.meta.Metadata;
|
import me.tofaa.entitylib.meta.Metadata;
|
||||||
|
|
@ -20,11 +22,12 @@ public class CatMeta extends TameableMeta {
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
public CatMeta.Variant getVariant() {
|
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) {
|
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() {
|
public boolean isLying() {
|
||||||
|
|
@ -51,21 +54,40 @@ public class CatMeta extends TameableMeta {
|
||||||
super.metadata.setIndex(offset(OFFSET, 3), EntityDataTypes.INT, value.ordinal());
|
super.metadata.setIndex(offset(OFFSET, 3), EntityDataTypes.INT, value.ordinal());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public enum Variant {
|
public enum Variant {
|
||||||
TABBY,
|
ALL_BLACK(CatVariants.ALL_BLACK),
|
||||||
BLACK,
|
BLACK(CatVariants.BLACK),
|
||||||
RED,
|
BRITISH_SHORTHAIR(CatVariants.BRITISH_SHORTHAIR),
|
||||||
SIAMESE,
|
CALICO(CatVariants.CALICO),
|
||||||
BRITISH_SHORTHAIR,
|
JELLIE(CatVariants.JELLIE),
|
||||||
CALICO,
|
PERSIAN(CatVariants.PERSIAN),
|
||||||
PERSIAN,
|
RAGDOLL(CatVariants.RAGDOLL),
|
||||||
RAGDOLL,
|
RED(CatVariants.RED),
|
||||||
WHITE,
|
SIAMESE(CatVariants.SIAMESE),
|
||||||
JELLIE,
|
TABBY(CatVariants.TABBY),
|
||||||
ALL_BLACK;
|
WHITE(CatVariants.WHITE);
|
||||||
|
|
||||||
|
private final CatVariant catVariant;
|
||||||
|
|
||||||
|
Variant(final CatVariant catVariant) {
|
||||||
|
this.catVariant = catVariant;
|
||||||
|
}
|
||||||
|
|
||||||
private static final Variant[] VALUES = values();
|
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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,19 +1,31 @@
|
||||||
package me.tofaa.entitylib.meta.mobs.tameable;
|
package me.tofaa.entitylib.meta.mobs.tameable;
|
||||||
|
|
||||||
import com.github.retrooper.packetevents.protocol.entity.data.EntityDataTypes;
|
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.extras.DyeColor;
|
||||||
import me.tofaa.entitylib.meta.Metadata;
|
import me.tofaa.entitylib.meta.Metadata;
|
||||||
import me.tofaa.entitylib.meta.types.TameableMeta;
|
import me.tofaa.entitylib.meta.types.TameableMeta;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
public class WolfMeta extends TameableMeta {
|
public class WolfMeta extends TameableMeta {
|
||||||
|
|
||||||
public static final byte OFFSET = TameableMeta.MAX_OFFSET;
|
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) {
|
public WolfMeta(int entityId, Metadata metadata) {
|
||||||
super(entityId, 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() {
|
public boolean isBegging() {
|
||||||
return super.metadata.getIndex(OFFSET, false);
|
return super.metadata.getIndex(OFFSET, false);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -21,11 +21,11 @@ public class ItemFrameMeta extends EntityMeta implements ObjectData {
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
public ItemStack getItem() {
|
public ItemStack getItem() {
|
||||||
return super.metadata.getIndex(9, ItemStack.EMPTY);
|
return super.metadata.getIndex((byte)9, ItemStack.EMPTY);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setItem(@NotNull ItemStack value) {
|
public void setItem(@NotNull ItemStack value) {
|
||||||
super.metadata.setIndex(9, EntityDataTypes.ITEMSTACK, value);
|
super.metadata.setIndex((byte)9, EntityDataTypes.ITEMSTACK, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
|
|
|
||||||
|
|
@ -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.protocol.entity.data.EntityDataTypes;
|
||||||
import com.github.retrooper.packetevents.wrapper.play.server.WrapperPlayServerEntityMetadata;
|
import com.github.retrooper.packetevents.wrapper.play.server.WrapperPlayServerEntityMetadata;
|
||||||
import me.tofaa.entitylib.EntityLib;
|
import me.tofaa.entitylib.EntityLib;
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
@ -15,6 +16,11 @@ public class PacketUtil {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void renderPacket(UUID user, WrapperPlayServerEntityMetadata metadata) {
|
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);
|
Locale locale = EntityLib.getApi().getUserLocaleProvider().locale(user);
|
||||||
for (final EntityData<?> entityData : metadata.getEntityMetadata()) {
|
for (final EntityData<?> entityData : metadata.getEntityMetadata()) {
|
||||||
if (entityData.getType() == EntityDataTypes.ADV_COMPONENT) {
|
if (entityData.getType() == EntityDataTypes.ADV_COMPONENT) {
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@ import java.io.ByteArrayOutputStream
|
||||||
val fullVersion = "3.0.3"
|
val fullVersion = "3.0.3"
|
||||||
val snapshot = true
|
val snapshot = true
|
||||||
|
|
||||||
group = "me.tofaa.entitylib"
|
group = "io.github.tofaa2"
|
||||||
description = rootProject.name
|
description = rootProject.name
|
||||||
|
|
||||||
fun getVersionMeta(includeHash: Boolean): String {
|
fun getVersionMeta(includeHash: Boolean): String {
|
||||||
|
|
@ -21,8 +21,8 @@ fun getVersionMeta(includeHash: Boolean): String {
|
||||||
}
|
}
|
||||||
return "$commitHash-SNAPSHOT"
|
return "$commitHash-SNAPSHOT"
|
||||||
}
|
}
|
||||||
version = "$fullVersion${getVersionMeta(true)}"
|
version = "$fullVersion${getVersionMeta(false)}"
|
||||||
ext["versionBeta"] = getVersionMeta(true)
|
ext["versionBeta"] = getVersionMeta(false)
|
||||||
ext["versionNoHash"] = "$fullVersion${getVersionMeta(false)}"
|
ext["versionNoHash"] = "$fullVersion${getVersionMeta(false)}"
|
||||||
|
|
||||||
tasks {
|
tasks {
|
||||||
|
|
@ -62,6 +62,12 @@ tasks {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
register("publishAllPublicationsToMavenRepository") {
|
||||||
|
val publishTasks = subModuleTasks("publishAllPublicationsToMavenRepository")
|
||||||
|
dependsOn(publishTasks)
|
||||||
|
group = "publishing"
|
||||||
|
}
|
||||||
|
|
||||||
register<Delete>("clean") {
|
register<Delete>("clean") {
|
||||||
val cleanTasks = subModuleTasks("clean")
|
val cleanTasks = subModuleTasks("clean")
|
||||||
dependsOn(cleanTasks)
|
dependsOn(cleanTasks)
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
plugins {
|
plugins {
|
||||||
`java-library`
|
`java-library`
|
||||||
`maven-publish`
|
`maven-publish`
|
||||||
|
signing
|
||||||
}
|
}
|
||||||
|
|
||||||
group = rootProject.group
|
group = rootProject.group
|
||||||
|
|
@ -45,17 +46,6 @@ tasks {
|
||||||
}
|
}
|
||||||
|
|
||||||
publishing {
|
publishing {
|
||||||
|
|
||||||
repositories {
|
|
||||||
maven {
|
|
||||||
url = uri("https://maven.evokegames.gg/snapshots")
|
|
||||||
credentials {
|
|
||||||
username = System.getenv("TYCOONS_REPO_USER")
|
|
||||||
password = System.getenv("TYCOONS_REPO_PASS")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
publications {
|
publications {
|
||||||
create<MavenPublication>("EntityLib") {
|
create<MavenPublication>("EntityLib") {
|
||||||
groupId = project.group as String
|
groupId = project.group as String
|
||||||
|
|
@ -75,6 +65,14 @@ publishing {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
developers {
|
||||||
|
developer {
|
||||||
|
id = "Tofaa2"
|
||||||
|
name = "Tofaa"
|
||||||
|
email = "tofaadev@gmail.com"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
scm {
|
scm {
|
||||||
connection = "scm:git:https://github.com/Tofaa2/EntityLib.git"
|
connection = "scm:git:https://github.com/Tofaa2/EntityLib.git"
|
||||||
developerConnection = "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
|
// So that SNAPSHOT is always the latest SNAPSHOT
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue