Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
Bram1903 committed Aug 16, 2024
2 parents 6be47d5 + f5c5366 commit 2899dea
Show file tree
Hide file tree
Showing 18 changed files with 102 additions and 52 deletions.
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
name: Gradle Package
name: Build & Upload

on:
release:
types: [ created ]
push:
branches: [ "master" ]
pull_request:
branches: [ "master" ]

jobs:
build:
Expand All @@ -12,15 +14,12 @@ jobs:
packages: write

steps:
- uses: actions/checkout@v3

- uses: actions/checkout@v4
- name: Set up JDK 21
uses: actions/setup-java@v3
uses: actions/setup-java@v4
with:
java-version: '21'
distribution: 'adopt'
server-id: github # Value of the distributionManagement/repository/id field of the pom.xml
settings-path: ${{ github.workspace }} # location for the settings.xml file
distribution: 'temurin'

- name: Build with Gradle
run: chmod +x gradlew && ./gradlew build
Expand Down
13 changes: 7 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,34 +6,35 @@ For general support and reports of bugs, join the [Discord](https://discord.gg/j
Currently supported platforms are `spigot` and `velocity`
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

Gradle (Groovy DSL):
```groovy
//https://jitpack.io/#Tofaa2/EntityLib/
//https://maven.evokegames.gg/#/snapshots/me/tofaa/entitylib
repositories {
maven { url 'https://jitpack.io' }
maven { url 'https://maven.evokegames.gg/snapshots' }
}
dependencies {
implementation 'com.github.Tofaa2.EntityLib:<platform>:<latest-release-version'
implementation 'me.tofaa.entitylib:<platform>:<latest-release-version'
}
```

Gradle (Kotlin DSL):
```kotlin
repositories {
maven(url = "https://jitpack.io")
maven(url = "https://maven.evokegames.gg/snapshots")
}

dependencies {
implementation("com.github.Tofaa2.EntityLib:<platform>:<latest-release-version>")
implementation("me.tofaa.entitylib:<platform>:<latest-release-version>")
}
```

Maven:
```xml
<dependency>
<groupId>com.github.Tofaa2.EntityLib</groupId>
<groupId>me.tofaa.entitylib</groupId>
<artifactId>(platform)</artifactId>
<version>(latest-release-version)</version>
</dependency>
Expand Down
4 changes: 2 additions & 2 deletions api/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ plugins {
dependencies {
api(libs.jetbrains.annotations)

compileOnlyApi(libs.bundles.adventure)
compileOnlyApi(libs.packetevents.api)
compileOnly(libs.bundles.adventure)
compileOnly(libs.packetevents.api)
}

tasks {
Expand Down
19 changes: 16 additions & 3 deletions api/src/main/java/me/tofaa/entitylib/meta/EntityMeta.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package me.tofaa.entitylib.meta;

import com.github.retrooper.packetevents.PacketEvents;
import com.github.retrooper.packetevents.manager.server.ServerVersion;
import com.github.retrooper.packetevents.manager.server.VersionComparison;
import com.github.retrooper.packetevents.protocol.entity.data.EntityData;
Expand Down Expand Up @@ -203,17 +204,29 @@ public WrapperPlayServerEntityMetadata createPacket() {
}

protected static void isVersionNewer(ServerVersion version) {
if (!EntityLib.getApi().getPacketEvents().getServerManager().getVersion().is(VersionComparison.NEWER_THAN, version)) {
if (EntityLib.getOptionalApi().isPresent()) {
if (!EntityLib.getApi().getPacketEvents().getServerManager().getVersion().is(VersionComparison.NEWER_THAN, version)) {
throw new InvalidVersionException("This method is only available for versions newer than " + version.name() + ".");
}
}
if (!PacketEvents.getAPI().getServerManager().getVersion().is(VersionComparison.NEWER_THAN, version)) {
throw new InvalidVersionException("This method is only available for versions newer than " + version.name() + ".");
}
}

protected static boolean isVersion(ServerVersion version, VersionComparison comparison) {
return EntityLib.getApi().getPacketEvents().getServerManager().getVersion().is(comparison, version);
if (EntityLib.getOptionalApi().isPresent()) {

return EntityLib.getApi().getPacketEvents().getServerManager().getVersion().is(comparison, version);
}
return PacketEvents.getAPI().getServerManager().getVersion().is(comparison, version);
}

protected static boolean isVersion(ServerVersion version) {
return EntityLib.getApi().getPacketEvents().getServerManager().getVersion().is(VersionComparison.EQUALS, version);
if (EntityLib.getOptionalApi().isPresent()) {
return EntityLib.getApi().getPacketEvents().getServerManager().getVersion().is(VersionComparison.EQUALS, version);
}
return PacketEvents.getAPI().getServerManager().getVersion().is(VersionComparison.EQUALS, version);
}

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package me.tofaa.entitylib.meta;

import com.github.retrooper.packetevents.protocol.entity.type.EntityType;
import com.github.retrooper.packetevents.protocol.entity.type.EntityTypes;
import me.tofaa.entitylib.meta.display.BlockDisplayMeta;
import me.tofaa.entitylib.meta.display.ItemDisplayMeta;
import me.tofaa.entitylib.meta.display.TextDisplayMeta;
Expand Down Expand Up @@ -82,6 +83,7 @@ final class MetaConverterRegistry {
put(ENDERMAN, EndermanMeta.class, EndermanMeta::new);
put(ENDERMITE, EndermiteMeta.class, EndermiteMeta::new);
put(EVOKER, EvokerMeta.class, EvokerMeta::new);
put(EYE_OF_ENDER, EyeOfEnderMeta.class, EyeOfEnderMeta::new);
put(EVOKER_FANGS, EvokerFangsMeta.class, EvokerFangsMeta::new);
put(FALLING_BLOCK, FallingBlockMeta.class, FallingBlockMeta::new);
put(FIREBALL, LargeFireballMeta.class, LargeFireballMeta::new); // TODO: Verify correctness
Expand All @@ -104,6 +106,7 @@ final class MetaConverterRegistry {
put(IRON_GOLEM, IronGolemMeta.class, IronGolemMeta::new);
put(ITEM_DISPLAY, ItemDisplayMeta.class, ItemDisplayMeta::new);
put(ITEM_FRAME, ItemFrameMeta.class, ItemFrameMeta::new);
put(ITEM, ItemEntityMeta.class, ItemEntityMeta::new);
put(LEASH_KNOT, LeashKnotMeta.class, LeashKnotMeta::new);
put(LIGHTNING_BOLT, LightningBoltMeta.class, LightningBoltMeta::new);
put(LLAMA, LlamaMeta.class, LlamaMeta::new);
Expand All @@ -114,6 +117,7 @@ final class MetaConverterRegistry {
put(OCELOT, OcelotMeta.class, OcelotMeta::new);
put(PAINTING, PaintingMeta.class, PaintingMeta::new);
put(PANDA, PandaMeta.class, PandaMeta::new);
put(POTION, ThrownPotionMeta.class, ThrownPotionMeta::new);
put(PARROT, ParrotMeta.class, ParrotMeta::new);
put(PIG, PigMeta.class, PigMeta::new);
put(PIGLIN, PiglinMeta.class, PiglinMeta::new);
Expand All @@ -128,6 +132,7 @@ final class MetaConverterRegistry {
put(RAVAGER, RavagerMeta.class, RavagerMeta::new);
put(SALMON, SalmonMeta.class, SalmonMeta::new);
put(SHEEP, SheepMeta.class, SheepMeta::new);
put(SNOWBALL, SnowballMeta.class, SnowballMeta::new);
put(SHULKER, ShulkerMeta.class, ShulkerMeta::new);
put(SHULKER_BULLET, ShulkerBulletMeta.class, ShulkerBulletMeta::new);
put(SILVERFISH, SilverfishMeta.class, SilverfishMeta::new);
Expand All @@ -144,6 +149,7 @@ final class MetaConverterRegistry {
put(TADPOLE, LivingEntityMeta.class, LivingEntityMeta::new); // TODO: Implement
put(TEXT_DISPLAY, TextDisplayMeta.class, TextDisplayMeta::new);
put(THROWN_EXP_BOTTLE, ThrownExpBottleMeta.class, ThrownExpBottleMeta::new);
put(ENDER_PEARL, ThrownEnderPearlMeta.class, ThrownEnderPearlMeta::new);
put(TNT_MINECART, TntMinecartMeta.class, TntMinecartMeta::new);
put(TRADER_LLAMA, TraderLlamaMeta.class, TraderLlamaMeta::new);
put(TRIDENT, ThrownTridentMeta.class, ThrownTridentMeta::new);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ public class ItemEntityMeta extends ItemContainerMeta implements ObjectData {
public static final byte OFFSET = ItemContainerMeta.MAX_OFFSET;
public static final byte MAX_OFFSET = OFFSET + 0;

protected ItemEntityMeta(int entityId, Metadata metadata) {
public ItemEntityMeta(int entityId, Metadata metadata) {
super(entityId, metadata, ItemStack.EMPTY);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public abstract class ItemContainerMeta extends EntityMeta {

private final ItemStack baseItem;

protected ItemContainerMeta(int entityId, Metadata metadata, ItemStack baseItem) {
public ItemContainerMeta(int entityId, Metadata metadata, ItemStack baseItem) {
super(entityId, metadata);
this.baseItem = baseItem;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import com.github.retrooper.packetevents.protocol.entity.data.EntityDataTypes;
import com.github.retrooper.packetevents.protocol.nbt.NBTCompound;
import me.tofaa.entitylib.EntityLib;
import me.tofaa.entitylib.meta.EntityMeta;
import me.tofaa.entitylib.meta.Metadata;
import org.jetbrains.annotations.Nullable;

Expand Down
12 changes: 10 additions & 2 deletions api/src/main/java/me/tofaa/entitylib/wrapper/WrapperEntity.java
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ public WrapperEntity(int entityId, UUID uuid, EntityType entityType, EntityMeta
this.ticking = true;
this.viewers = ConcurrentHashMap.newKeySet();
this.passengers = ConcurrentHashMap.newKeySet();
this.location = new Location(0, 0, 0, 0, 0);
}

public WrapperEntity(int entityId, EntityType entityType) {
Expand Down Expand Up @@ -121,7 +122,12 @@ public void setLocation(Location location) {
}

public void remove() {
parent.removeEntity(this, true);
if (parent != null) {
parent.removeEntity(this, true);
}
else {
despawn();
}
}

public void despawn() {
Expand Down Expand Up @@ -378,10 +384,12 @@ public boolean hasVelocity() {
}

public void rotateHead(float yaw, float pitch) {
sendPacketsToViewers(
sendPacketsToViewersIfSpawned(
new WrapperPlayServerEntityRotation(entityId, yaw, pitch, onGround),
new WrapperPlayServerEntityHeadLook(entityId, yaw)
);
this.location.setYaw(yaw);
this.location.setPitch(pitch);
}

public void rotateHead(Location location) {
Expand Down
10 changes: 5 additions & 5 deletions api/src/main/java/me/tofaa/entitylib/wrapper/WrapperPlayer.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ public List<TextureProperty> getTextures() {
return profile.getTextureProperties();
}

public WrapperPlayServerPlayerInfoRemove tabListRemovePacket() {
return new WrapperPlayServerPlayerInfoRemove(getUuid());
public WrapperPlayServerPlayerInfoUpdate tabListRemovePacket() {
return new WrapperPlayServerPlayerInfoUpdate(EnumSet.of(WrapperPlayServerPlayerInfoUpdate.Action.UPDATE_LISTED), createInfo());
}

public void setGameMode(GameMode gameMode) {
Expand Down Expand Up @@ -95,9 +95,9 @@ public boolean isInTablist() {
public void setInTablist(boolean tablist) {
this.tablist = tablist;
sendPacketsToViewersIfSpawned(tabListPacket());
if (!tablist) {
sendPacketsToViewersIfSpawned(tabListRemovePacket());
}
// if (!tablist) {
// sendPacketsToViewersIfSpawned(tabListRemovePacket());
// }
}

public int getLatency() {
Expand Down
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import java.io.ByteArrayOutputStream

val fullVersion = "2.4.5"
val fullVersion = "2.4.9"
val snapshot = true

group = "me.tofaa.entitylib"
Expand Down
11 changes: 11 additions & 0 deletions buildSrc/src/main/kotlin/entitylib.library-conventions.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,17 @@ 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
Expand Down
2 changes: 2 additions & 0 deletions common/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,6 @@ plugins {

dependencies {
api(project(":api"))
compileOnly(libs.bundles.adventure)
compileOnly(libs.packetevents.api)
}
15 changes: 0 additions & 15 deletions jitpack.yml

This file was deleted.

9 changes: 9 additions & 0 deletions model-engine-addon/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,18 @@ repositories {
maven {
url = uri("https://mvn.lumine.io/repository/maven-public/")
}
maven("https://jitpack.io")
}

dependencies {
// compileOnly("com.ticxo.modelengine:ModelEngine:R4.0.4")
api(project(":api"))

implementation("commons-io:commons-io:2.11.0")
implementation("org.zeroturnaround:zt-zip:1.8")

implementation("javax.json:javax.json-api:1.1.4")
implementation("org.glassfish:javax.json:1.1.4")

implementation("com.github.hollow-cube.common:mql:2b48ad430f")
}

This file was deleted.

4 changes: 3 additions & 1 deletion test-plugin/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,15 @@ plugins {
}

repositories {
maven("https://maven.evokegames.gg/snapshots")
maven("https://repo.papermc.io/repository/maven-public/")
}

dependencies {
compileOnly(libs.paper)
compileOnly(libs.packetevents.spigot)
implementation(project(":platforms:spigot"))
implementation("me.tofaa.entitylib:spigot:2.4.5-SNAPSHOT")
// implementation(project(":platforms:spigot"))
}

tasks {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@

public class TestPlayerCommand extends BukkitCommand {


private static final char UNICODE_EMPTY = '\u2800';

private WrapperPlayer p;
private SkinFetcher sf;
public TestPlayerCommand() {
Expand All @@ -28,6 +31,22 @@ public TestPlayerCommand() {

@Override
public boolean execute(@NotNull CommandSender commandSender, @NotNull String s, @NotNull String[] strings) {
Player player = (Player) commandSender;
if (p != null) {
p.setInTablist(!p.isInTablist());
return true;
}

p = new WrapperPlayer(new UserProfile(UUID.randomUUID(), "\u2800"), EntityLib.getPlatform().getEntityIdProvider().provide(UUID.randomUUID(), EntityTypes.PLAYER));
p.setInTablist(true);
p.setTextureProperties(ExtraConversionUtil.getProfileFromBukkitPlayer(player).getTextureProperties());
p.spawn(SpigotConversionUtil.fromBukkitLocation(player.getLocation()));
p.addViewer(player.getUniqueId());
player.sendMessage("Entity spawned");
return true;
}

private boolean legacyProcess(@NotNull CommandSender commandSender, @NotNull String s, @NotNull String[] strings) {
Player player = (Player) commandSender;
if (strings.length < 1) {
player.sendMessage("Usage: /testplayer <spawn|hello|ping|gamemode|displayname|tablist|remove>");
Expand Down Expand Up @@ -92,6 +111,7 @@ public boolean execute(@NotNull CommandSender commandSender, @NotNull String s,
return true;
}


@NotNull
@Override
public List<String> tabComplete(@NotNull CommandSender sender, @NotNull String alias, @NotNull String[] args) throws IllegalArgumentException {
Expand Down

0 comments on commit 2899dea

Please sign in to comment.