Merge remote-tracking branch 'origin/master'

This commit is contained in:
Bram 2024-08-16 14:16:19 +02:00
commit 2899dea790
No known key found for this signature in database
GPG key ID: 13E608068F40E3CC
18 changed files with 102 additions and 52 deletions

View file

@ -1,8 +1,10 @@
name: Gradle Package name: Build & Upload
on: on:
release: push:
types: [ created ] branches: [ "master" ]
pull_request:
branches: [ "master" ]
jobs: jobs:
build: build:
@ -12,15 +14,12 @@ jobs:
packages: write packages: write
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v4
- name: Set up JDK 21 - name: Set up JDK 21
uses: actions/setup-java@v3 uses: actions/setup-java@v4
with: with:
java-version: '21' java-version: '21'
distribution: 'adopt' distribution: 'temurin'
server-id: github # Value of the distributionManagement/repository/id field of the pom.xml
settings-path: ${{ github.workspace }} # location for the settings.xml file
- name: Build with Gradle - name: Build with Gradle
run: chmod +x gradlew && ./gradlew build run: chmod +x gradlew && ./gradlew build

View file

@ -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` Currently supported platforms are `spigot` and `velocity`
You can easily use EntityLib platformless by using the `api` or `common` module 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): Gradle (Groovy DSL):
```groovy ```groovy
//https://jitpack.io/#Tofaa2/EntityLib/ //https://maven.evokegames.gg/#/snapshots/me/tofaa/entitylib
repositories { repositories {
maven { url 'https://jitpack.io' } maven { url 'https://maven.evokegames.gg/snapshots' }
} }
dependencies { dependencies {
implementation 'com.github.Tofaa2.EntityLib:<platform>:<latest-release-version' implementation 'me.tofaa.entitylib:<platform>:<latest-release-version'
} }
``` ```
Gradle (Kotlin DSL): Gradle (Kotlin DSL):
```kotlin ```kotlin
repositories { repositories {
maven(url = "https://jitpack.io") maven(url = "https://maven.evokegames.gg/snapshots")
} }
dependencies { dependencies {
implementation("com.github.Tofaa2.EntityLib:<platform>:<latest-release-version>") implementation("me.tofaa.entitylib:<platform>:<latest-release-version>")
} }
``` ```
Maven: Maven:
```xml ```xml
<dependency> <dependency>
<groupId>com.github.Tofaa2.EntityLib</groupId> <groupId>me.tofaa.entitylib</groupId>
<artifactId>(platform)</artifactId> <artifactId>(platform)</artifactId>
<version>(latest-release-version)</version> <version>(latest-release-version)</version>
</dependency> </dependency>

View file

@ -7,8 +7,8 @@ plugins {
dependencies { dependencies {
api(libs.jetbrains.annotations) api(libs.jetbrains.annotations)
compileOnlyApi(libs.bundles.adventure) compileOnly(libs.bundles.adventure)
compileOnlyApi(libs.packetevents.api) compileOnly(libs.packetevents.api)
} }
tasks { tasks {

View file

@ -1,5 +1,6 @@
package me.tofaa.entitylib.meta; 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.ServerVersion;
import com.github.retrooper.packetevents.manager.server.VersionComparison; import com.github.retrooper.packetevents.manager.server.VersionComparison;
import com.github.retrooper.packetevents.protocol.entity.data.EntityData; import com.github.retrooper.packetevents.protocol.entity.data.EntityData;
@ -203,18 +204,30 @@ public class EntityMeta implements EntityMetadataProvider {
} }
protected static void isVersionNewer(ServerVersion version) { protected static void isVersionNewer(ServerVersion version) {
if (EntityLib.getOptionalApi().isPresent()) {
if (!EntityLib.getApi().getPacketEvents().getServerManager().getVersion().is(VersionComparison.NEWER_THAN, version)) { 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() + "."); 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) { protected static boolean isVersion(ServerVersion version, VersionComparison comparison) {
if (EntityLib.getOptionalApi().isPresent()) {
return EntityLib.getApi().getPacketEvents().getServerManager().getVersion().is(comparison, version); return EntityLib.getApi().getPacketEvents().getServerManager().getVersion().is(comparison, version);
} }
return PacketEvents.getAPI().getServerManager().getVersion().is(comparison, version);
}
protected static boolean isVersion(ServerVersion version) { protected static boolean isVersion(ServerVersion version) {
if (EntityLib.getOptionalApi().isPresent()) {
return EntityLib.getApi().getPacketEvents().getServerManager().getVersion().is(VersionComparison.EQUALS, version); return EntityLib.getApi().getPacketEvents().getServerManager().getVersion().is(VersionComparison.EQUALS, version);
} }
return PacketEvents.getAPI().getServerManager().getVersion().is(VersionComparison.EQUALS, version);
}
/** /**
* Annoying java 8 not letting me do OFFSET + amount in the method call so this is a workaround * Annoying java 8 not letting me do OFFSET + amount in the method call so this is a workaround

View file

@ -1,6 +1,7 @@
package me.tofaa.entitylib.meta; package me.tofaa.entitylib.meta;
import com.github.retrooper.packetevents.protocol.entity.type.EntityType; 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.BlockDisplayMeta;
import me.tofaa.entitylib.meta.display.ItemDisplayMeta; import me.tofaa.entitylib.meta.display.ItemDisplayMeta;
import me.tofaa.entitylib.meta.display.TextDisplayMeta; import me.tofaa.entitylib.meta.display.TextDisplayMeta;
@ -82,6 +83,7 @@ final class MetaConverterRegistry {
put(ENDERMAN, EndermanMeta.class, EndermanMeta::new); put(ENDERMAN, EndermanMeta.class, EndermanMeta::new);
put(ENDERMITE, EndermiteMeta.class, EndermiteMeta::new); put(ENDERMITE, EndermiteMeta.class, EndermiteMeta::new);
put(EVOKER, EvokerMeta.class, EvokerMeta::new); put(EVOKER, EvokerMeta.class, EvokerMeta::new);
put(EYE_OF_ENDER, EyeOfEnderMeta.class, EyeOfEnderMeta::new);
put(EVOKER_FANGS, EvokerFangsMeta.class, EvokerFangsMeta::new); put(EVOKER_FANGS, EvokerFangsMeta.class, EvokerFangsMeta::new);
put(FALLING_BLOCK, FallingBlockMeta.class, FallingBlockMeta::new); put(FALLING_BLOCK, FallingBlockMeta.class, FallingBlockMeta::new);
put(FIREBALL, LargeFireballMeta.class, LargeFireballMeta::new); // TODO: Verify correctness put(FIREBALL, LargeFireballMeta.class, LargeFireballMeta::new); // TODO: Verify correctness
@ -104,6 +106,7 @@ final class MetaConverterRegistry {
put(IRON_GOLEM, IronGolemMeta.class, IronGolemMeta::new); put(IRON_GOLEM, IronGolemMeta.class, IronGolemMeta::new);
put(ITEM_DISPLAY, ItemDisplayMeta.class, ItemDisplayMeta::new); put(ITEM_DISPLAY, ItemDisplayMeta.class, ItemDisplayMeta::new);
put(ITEM_FRAME, ItemFrameMeta.class, ItemFrameMeta::new); put(ITEM_FRAME, ItemFrameMeta.class, ItemFrameMeta::new);
put(ITEM, ItemEntityMeta.class, ItemEntityMeta::new);
put(LEASH_KNOT, LeashKnotMeta.class, LeashKnotMeta::new); put(LEASH_KNOT, LeashKnotMeta.class, LeashKnotMeta::new);
put(LIGHTNING_BOLT, LightningBoltMeta.class, LightningBoltMeta::new); put(LIGHTNING_BOLT, LightningBoltMeta.class, LightningBoltMeta::new);
put(LLAMA, LlamaMeta.class, LlamaMeta::new); put(LLAMA, LlamaMeta.class, LlamaMeta::new);
@ -114,6 +117,7 @@ final class MetaConverterRegistry {
put(OCELOT, OcelotMeta.class, OcelotMeta::new); put(OCELOT, OcelotMeta.class, OcelotMeta::new);
put(PAINTING, PaintingMeta.class, PaintingMeta::new); put(PAINTING, PaintingMeta.class, PaintingMeta::new);
put(PANDA, PandaMeta.class, PandaMeta::new); put(PANDA, PandaMeta.class, PandaMeta::new);
put(POTION, ThrownPotionMeta.class, ThrownPotionMeta::new);
put(PARROT, ParrotMeta.class, ParrotMeta::new); put(PARROT, ParrotMeta.class, ParrotMeta::new);
put(PIG, PigMeta.class, PigMeta::new); put(PIG, PigMeta.class, PigMeta::new);
put(PIGLIN, PiglinMeta.class, PiglinMeta::new); put(PIGLIN, PiglinMeta.class, PiglinMeta::new);
@ -128,6 +132,7 @@ final class MetaConverterRegistry {
put(RAVAGER, RavagerMeta.class, RavagerMeta::new); put(RAVAGER, RavagerMeta.class, RavagerMeta::new);
put(SALMON, SalmonMeta.class, SalmonMeta::new); put(SALMON, SalmonMeta.class, SalmonMeta::new);
put(SHEEP, SheepMeta.class, SheepMeta::new); put(SHEEP, SheepMeta.class, SheepMeta::new);
put(SNOWBALL, SnowballMeta.class, SnowballMeta::new);
put(SHULKER, ShulkerMeta.class, ShulkerMeta::new); put(SHULKER, ShulkerMeta.class, ShulkerMeta::new);
put(SHULKER_BULLET, ShulkerBulletMeta.class, ShulkerBulletMeta::new); put(SHULKER_BULLET, ShulkerBulletMeta.class, ShulkerBulletMeta::new);
put(SILVERFISH, SilverfishMeta.class, SilverfishMeta::new); put(SILVERFISH, SilverfishMeta.class, SilverfishMeta::new);
@ -144,6 +149,7 @@ final class MetaConverterRegistry {
put(TADPOLE, LivingEntityMeta.class, LivingEntityMeta::new); // TODO: Implement put(TADPOLE, LivingEntityMeta.class, LivingEntityMeta::new); // TODO: Implement
put(TEXT_DISPLAY, TextDisplayMeta.class, TextDisplayMeta::new); put(TEXT_DISPLAY, TextDisplayMeta.class, TextDisplayMeta::new);
put(THROWN_EXP_BOTTLE, ThrownExpBottleMeta.class, ThrownExpBottleMeta::new); put(THROWN_EXP_BOTTLE, ThrownExpBottleMeta.class, ThrownExpBottleMeta::new);
put(ENDER_PEARL, ThrownEnderPearlMeta.class, ThrownEnderPearlMeta::new);
put(TNT_MINECART, TntMinecartMeta.class, TntMinecartMeta::new); put(TNT_MINECART, TntMinecartMeta.class, TntMinecartMeta::new);
put(TRADER_LLAMA, TraderLlamaMeta.class, TraderLlamaMeta::new); put(TRADER_LLAMA, TraderLlamaMeta.class, TraderLlamaMeta::new);
put(TRIDENT, ThrownTridentMeta.class, ThrownTridentMeta::new); put(TRIDENT, ThrownTridentMeta.class, ThrownTridentMeta::new);

View file

@ -10,7 +10,7 @@ public class ItemEntityMeta extends ItemContainerMeta implements ObjectData {
public static final byte OFFSET = ItemContainerMeta.MAX_OFFSET; public static final byte OFFSET = ItemContainerMeta.MAX_OFFSET;
public static final byte MAX_OFFSET = OFFSET + 0; 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); super(entityId, metadata, ItemStack.EMPTY);
} }

View file

@ -11,7 +11,7 @@ public abstract class ItemContainerMeta extends EntityMeta {
private final ItemStack baseItem; private final ItemStack baseItem;
protected ItemContainerMeta(int entityId, Metadata metadata, ItemStack baseItem) { public ItemContainerMeta(int entityId, Metadata metadata, ItemStack baseItem) {
super(entityId, metadata); super(entityId, metadata);
this.baseItem = baseItem; this.baseItem = baseItem;
} }

View file

@ -4,7 +4,6 @@ import com.github.retrooper.packetevents.manager.server.ServerVersion;
import com.github.retrooper.packetevents.protocol.entity.data.EntityDataTypes; import com.github.retrooper.packetevents.protocol.entity.data.EntityDataTypes;
import com.github.retrooper.packetevents.protocol.nbt.NBTCompound; import com.github.retrooper.packetevents.protocol.nbt.NBTCompound;
import me.tofaa.entitylib.EntityLib; import me.tofaa.entitylib.EntityLib;
import me.tofaa.entitylib.meta.EntityMeta;
import me.tofaa.entitylib.meta.Metadata; import me.tofaa.entitylib.meta.Metadata;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;

View file

@ -45,6 +45,7 @@ public class WrapperEntity implements Tickable, TrackedEntity {
this.ticking = true; this.ticking = true;
this.viewers = ConcurrentHashMap.newKeySet(); this.viewers = ConcurrentHashMap.newKeySet();
this.passengers = ConcurrentHashMap.newKeySet(); this.passengers = ConcurrentHashMap.newKeySet();
this.location = new Location(0, 0, 0, 0, 0);
} }
public WrapperEntity(int entityId, EntityType entityType) { public WrapperEntity(int entityId, EntityType entityType) {
@ -121,8 +122,13 @@ public class WrapperEntity implements Tickable, TrackedEntity {
} }
public void remove() { public void remove() {
if (parent != null) {
parent.removeEntity(this, true); parent.removeEntity(this, true);
} }
else {
despawn();
}
}
public void despawn() { public void despawn() {
if (!spawned) return; if (!spawned) return;
@ -378,10 +384,12 @@ public class WrapperEntity implements Tickable, TrackedEntity {
} }
public void rotateHead(float yaw, float pitch) { public void rotateHead(float yaw, float pitch) {
sendPacketsToViewers( sendPacketsToViewersIfSpawned(
new WrapperPlayServerEntityRotation(entityId, yaw, pitch, onGround), new WrapperPlayServerEntityRotation(entityId, yaw, pitch, onGround),
new WrapperPlayServerEntityHeadLook(entityId, yaw) new WrapperPlayServerEntityHeadLook(entityId, yaw)
); );
this.location.setYaw(yaw);
this.location.setPitch(pitch);
} }
public void rotateHead(Location location) { public void rotateHead(Location location) {

View file

@ -40,8 +40,8 @@ public class WrapperPlayer extends WrapperLivingEntity {
return profile.getTextureProperties(); return profile.getTextureProperties();
} }
public WrapperPlayServerPlayerInfoRemove tabListRemovePacket() { public WrapperPlayServerPlayerInfoUpdate tabListRemovePacket() {
return new WrapperPlayServerPlayerInfoRemove(getUuid()); return new WrapperPlayServerPlayerInfoUpdate(EnumSet.of(WrapperPlayServerPlayerInfoUpdate.Action.UPDATE_LISTED), createInfo());
} }
public void setGameMode(GameMode gameMode) { public void setGameMode(GameMode gameMode) {
@ -95,9 +95,9 @@ public class WrapperPlayer extends WrapperLivingEntity {
public void setInTablist(boolean tablist) { public void setInTablist(boolean tablist) {
this.tablist = tablist; this.tablist = tablist;
sendPacketsToViewersIfSpawned(tabListPacket()); sendPacketsToViewersIfSpawned(tabListPacket());
if (!tablist) { // if (!tablist) {
sendPacketsToViewersIfSpawned(tabListRemovePacket()); // sendPacketsToViewersIfSpawned(tabListRemovePacket());
} // }
} }
public int getLatency() { public int getLatency() {

View file

@ -1,6 +1,6 @@
import java.io.ByteArrayOutputStream import java.io.ByteArrayOutputStream
val fullVersion = "2.4.5" val fullVersion = "2.4.9"
val snapshot = true val snapshot = true
group = "me.tofaa.entitylib" group = "me.tofaa.entitylib"

View file

@ -45,6 +45,17 @@ 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

View file

@ -5,4 +5,6 @@ plugins {
dependencies { dependencies {
api(project(":api")) api(project(":api"))
compileOnly(libs.bundles.adventure)
compileOnly(libs.packetevents.api)
} }

View file

@ -1,15 +0,0 @@
jdk:
- temurin-21
stages:
- name: build
- name: publish
depends_on: build
build:
script:
- ./gradlew build
publish:
script:
- ./gradlew publishToMavenLocal

View file

@ -7,9 +7,18 @@ repositories {
maven { maven {
url = uri("https://mvn.lumine.io/repository/maven-public/") url = uri("https://mvn.lumine.io/repository/maven-public/")
} }
maven("https://jitpack.io")
} }
dependencies { dependencies {
// compileOnly("com.ticxo.modelengine:ModelEngine:R4.0.4") // compileOnly("com.ticxo.modelengine:ModelEngine:R4.0.4")
api(project(":api")) 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")
} }

View file

@ -1,5 +0,0 @@
package me.tofaa.entitylib.modelengine;
public class ELibBaseEntity {
}

View file

@ -5,13 +5,15 @@ plugins {
} }
repositories { repositories {
maven("https://maven.evokegames.gg/snapshots")
maven("https://repo.papermc.io/repository/maven-public/") maven("https://repo.papermc.io/repository/maven-public/")
} }
dependencies { dependencies {
compileOnly(libs.paper) compileOnly(libs.paper)
compileOnly(libs.packetevents.spigot) compileOnly(libs.packetevents.spigot)
implementation(project(":platforms:spigot")) implementation("me.tofaa.entitylib:spigot:2.4.5-SNAPSHOT")
// implementation(project(":platforms:spigot"))
} }
tasks { tasks {

View file

@ -20,6 +20,9 @@ import java.util.*;
public class TestPlayerCommand extends BukkitCommand { public class TestPlayerCommand extends BukkitCommand {
private static final char UNICODE_EMPTY = '\u2800';
private WrapperPlayer p; private WrapperPlayer p;
private SkinFetcher sf; private SkinFetcher sf;
public TestPlayerCommand() { public TestPlayerCommand() {
@ -28,6 +31,22 @@ public class TestPlayerCommand extends BukkitCommand {
@Override @Override
public boolean execute(@NotNull CommandSender commandSender, @NotNull String s, @NotNull String[] strings) { 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; Player player = (Player) commandSender;
if (strings.length < 1) { if (strings.length < 1) {
player.sendMessage("Usage: /testplayer <spawn|hello|ping|gamemode|displayname|tablist|remove>"); player.sendMessage("Usage: /testplayer <spawn|hello|ping|gamemode|displayname|tablist|remove>");
@ -92,6 +111,7 @@ public class TestPlayerCommand extends BukkitCommand {
return true; return true;
} }
@NotNull @NotNull
@Override @Override
public List<String> tabComplete(@NotNull CommandSender sender, @NotNull String alias, @NotNull String[] args) throws IllegalArgumentException { public List<String> tabComplete(@NotNull CommandSender sender, @NotNull String alias, @NotNull String[] args) throws IllegalArgumentException {