Skip to content

Commit 2899dea

Browse files
committed
Merge remote-tracking branch 'origin/master'
2 parents 6be47d5 + f5c5366 commit 2899dea

File tree

18 files changed

+102
-52
lines changed

18 files changed

+102
-52
lines changed

.github/workflows/gradle-publish.yml renamed to .github/workflows/gradle.yml

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
1-
name: Gradle Package
1+
name: Build & Upload
22

33
on:
4-
release:
5-
types: [ created ]
4+
push:
5+
branches: [ "master" ]
6+
pull_request:
7+
branches: [ "master" ]
68

79
jobs:
810
build:
@@ -12,15 +14,12 @@ jobs:
1214
packages: write
1315

1416
steps:
15-
- uses: actions/checkout@v3
16-
17+
- uses: actions/checkout@v4
1718
- name: Set up JDK 21
18-
uses: actions/setup-java@v3
19+
uses: actions/setup-java@v4
1920
with:
2021
java-version: '21'
21-
distribution: 'adopt'
22-
server-id: github # Value of the distributionManagement/repository/id field of the pom.xml
23-
settings-path: ${{ github.workspace }} # location for the settings.xml file
22+
distribution: 'temurin'
2423

2524
- name: Build with Gradle
2625
run: chmod +x gradlew && ./gradlew build

README.md

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,34 +6,35 @@ For general support and reports of bugs, join the [Discord](https://discord.gg/j
66
Currently supported platforms are `spigot` and `velocity`
77
You can easily use EntityLib platformless by using the `api` or `common` module
88

9+
If you like EntityLib and or want to sponsor me, visit my [ko-fi page](https://ko-fi.com/tofaa) :D
910

1011
Gradle (Groovy DSL):
1112
```groovy
12-
//https://jitpack.io/#Tofaa2/EntityLib/
13+
//https://maven.evokegames.gg/#/snapshots/me/tofaa/entitylib
1314
repositories {
14-
maven { url 'https://jitpack.io' }
15+
maven { url 'https://maven.evokegames.gg/snapshots' }
1516
}
1617
1718
dependencies {
18-
implementation 'com.github.Tofaa2.EntityLib:<platform>:<latest-release-version'
19+
implementation 'me.tofaa.entitylib:<platform>:<latest-release-version'
1920
}
2021
```
2122

2223
Gradle (Kotlin DSL):
2324
```kotlin
2425
repositories {
25-
maven(url = "https://jitpack.io")
26+
maven(url = "https://maven.evokegames.gg/snapshots")
2627
}
2728

2829
dependencies {
29-
implementation("com.github.Tofaa2.EntityLib:<platform>:<latest-release-version>")
30+
implementation("me.tofaa.entitylib:<platform>:<latest-release-version>")
3031
}
3132
```
3233

3334
Maven:
3435
```xml
3536
<dependency>
36-
<groupId>com.github.Tofaa2.EntityLib</groupId>
37+
<groupId>me.tofaa.entitylib</groupId>
3738
<artifactId>(platform)</artifactId>
3839
<version>(latest-release-version)</version>
3940
</dependency>

api/build.gradle.kts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ plugins {
77
dependencies {
88
api(libs.jetbrains.annotations)
99

10-
compileOnlyApi(libs.bundles.adventure)
11-
compileOnlyApi(libs.packetevents.api)
10+
compileOnly(libs.bundles.adventure)
11+
compileOnly(libs.packetevents.api)
1212
}
1313

1414
tasks {

api/src/main/java/me/tofaa/entitylib/meta/EntityMeta.java

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package me.tofaa.entitylib.meta;
22

3+
import com.github.retrooper.packetevents.PacketEvents;
34
import com.github.retrooper.packetevents.manager.server.ServerVersion;
45
import com.github.retrooper.packetevents.manager.server.VersionComparison;
56
import com.github.retrooper.packetevents.protocol.entity.data.EntityData;
@@ -203,17 +204,29 @@ public WrapperPlayServerEntityMetadata createPacket() {
203204
}
204205

205206
protected static void isVersionNewer(ServerVersion version) {
206-
if (!EntityLib.getApi().getPacketEvents().getServerManager().getVersion().is(VersionComparison.NEWER_THAN, version)) {
207+
if (EntityLib.getOptionalApi().isPresent()) {
208+
if (!EntityLib.getApi().getPacketEvents().getServerManager().getVersion().is(VersionComparison.NEWER_THAN, version)) {
209+
throw new InvalidVersionException("This method is only available for versions newer than " + version.name() + ".");
210+
}
211+
}
212+
if (!PacketEvents.getAPI().getServerManager().getVersion().is(VersionComparison.NEWER_THAN, version)) {
207213
throw new InvalidVersionException("This method is only available for versions newer than " + version.name() + ".");
208214
}
209215
}
210216

211217
protected static boolean isVersion(ServerVersion version, VersionComparison comparison) {
212-
return EntityLib.getApi().getPacketEvents().getServerManager().getVersion().is(comparison, version);
218+
if (EntityLib.getOptionalApi().isPresent()) {
219+
220+
return EntityLib.getApi().getPacketEvents().getServerManager().getVersion().is(comparison, version);
221+
}
222+
return PacketEvents.getAPI().getServerManager().getVersion().is(comparison, version);
213223
}
214224

215225
protected static boolean isVersion(ServerVersion version) {
216-
return EntityLib.getApi().getPacketEvents().getServerManager().getVersion().is(VersionComparison.EQUALS, version);
226+
if (EntityLib.getOptionalApi().isPresent()) {
227+
return EntityLib.getApi().getPacketEvents().getServerManager().getVersion().is(VersionComparison.EQUALS, version);
228+
}
229+
return PacketEvents.getAPI().getServerManager().getVersion().is(VersionComparison.EQUALS, version);
217230
}
218231

219232
/**

api/src/main/java/me/tofaa/entitylib/meta/MetaConverterRegistry.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package me.tofaa.entitylib.meta;
22

33
import com.github.retrooper.packetevents.protocol.entity.type.EntityType;
4+
import com.github.retrooper.packetevents.protocol.entity.type.EntityTypes;
45
import me.tofaa.entitylib.meta.display.BlockDisplayMeta;
56
import me.tofaa.entitylib.meta.display.ItemDisplayMeta;
67
import me.tofaa.entitylib.meta.display.TextDisplayMeta;
@@ -82,6 +83,7 @@ final class MetaConverterRegistry {
8283
put(ENDERMAN, EndermanMeta.class, EndermanMeta::new);
8384
put(ENDERMITE, EndermiteMeta.class, EndermiteMeta::new);
8485
put(EVOKER, EvokerMeta.class, EvokerMeta::new);
86+
put(EYE_OF_ENDER, EyeOfEnderMeta.class, EyeOfEnderMeta::new);
8587
put(EVOKER_FANGS, EvokerFangsMeta.class, EvokerFangsMeta::new);
8688
put(FALLING_BLOCK, FallingBlockMeta.class, FallingBlockMeta::new);
8789
put(FIREBALL, LargeFireballMeta.class, LargeFireballMeta::new); // TODO: Verify correctness
@@ -104,6 +106,7 @@ final class MetaConverterRegistry {
104106
put(IRON_GOLEM, IronGolemMeta.class, IronGolemMeta::new);
105107
put(ITEM_DISPLAY, ItemDisplayMeta.class, ItemDisplayMeta::new);
106108
put(ITEM_FRAME, ItemFrameMeta.class, ItemFrameMeta::new);
109+
put(ITEM, ItemEntityMeta.class, ItemEntityMeta::new);
107110
put(LEASH_KNOT, LeashKnotMeta.class, LeashKnotMeta::new);
108111
put(LIGHTNING_BOLT, LightningBoltMeta.class, LightningBoltMeta::new);
109112
put(LLAMA, LlamaMeta.class, LlamaMeta::new);
@@ -114,6 +117,7 @@ final class MetaConverterRegistry {
114117
put(OCELOT, OcelotMeta.class, OcelotMeta::new);
115118
put(PAINTING, PaintingMeta.class, PaintingMeta::new);
116119
put(PANDA, PandaMeta.class, PandaMeta::new);
120+
put(POTION, ThrownPotionMeta.class, ThrownPotionMeta::new);
117121
put(PARROT, ParrotMeta.class, ParrotMeta::new);
118122
put(PIG, PigMeta.class, PigMeta::new);
119123
put(PIGLIN, PiglinMeta.class, PiglinMeta::new);
@@ -128,6 +132,7 @@ final class MetaConverterRegistry {
128132
put(RAVAGER, RavagerMeta.class, RavagerMeta::new);
129133
put(SALMON, SalmonMeta.class, SalmonMeta::new);
130134
put(SHEEP, SheepMeta.class, SheepMeta::new);
135+
put(SNOWBALL, SnowballMeta.class, SnowballMeta::new);
131136
put(SHULKER, ShulkerMeta.class, ShulkerMeta::new);
132137
put(SHULKER_BULLET, ShulkerBulletMeta.class, ShulkerBulletMeta::new);
133138
put(SILVERFISH, SilverfishMeta.class, SilverfishMeta::new);
@@ -144,6 +149,7 @@ final class MetaConverterRegistry {
144149
put(TADPOLE, LivingEntityMeta.class, LivingEntityMeta::new); // TODO: Implement
145150
put(TEXT_DISPLAY, TextDisplayMeta.class, TextDisplayMeta::new);
146151
put(THROWN_EXP_BOTTLE, ThrownExpBottleMeta.class, ThrownExpBottleMeta::new);
152+
put(ENDER_PEARL, ThrownEnderPearlMeta.class, ThrownEnderPearlMeta::new);
147153
put(TNT_MINECART, TntMinecartMeta.class, TntMinecartMeta::new);
148154
put(TRADER_LLAMA, TraderLlamaMeta.class, TraderLlamaMeta::new);
149155
put(TRIDENT, ThrownTridentMeta.class, ThrownTridentMeta::new);

api/src/main/java/me/tofaa/entitylib/meta/projectile/ItemEntityMeta.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ public class ItemEntityMeta extends ItemContainerMeta implements ObjectData {
1010
public static final byte OFFSET = ItemContainerMeta.MAX_OFFSET;
1111
public static final byte MAX_OFFSET = OFFSET + 0;
1212

13-
protected ItemEntityMeta(int entityId, Metadata metadata) {
13+
public ItemEntityMeta(int entityId, Metadata metadata) {
1414
super(entityId, metadata, ItemStack.EMPTY);
1515
}
1616

api/src/main/java/me/tofaa/entitylib/meta/types/ItemContainerMeta.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ public abstract class ItemContainerMeta extends EntityMeta {
1111

1212
private final ItemStack baseItem;
1313

14-
protected ItemContainerMeta(int entityId, Metadata metadata, ItemStack baseItem) {
14+
public ItemContainerMeta(int entityId, Metadata metadata, ItemStack baseItem) {
1515
super(entityId, metadata);
1616
this.baseItem = baseItem;
1717
}

api/src/main/java/me/tofaa/entitylib/meta/types/PlayerMeta.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
import com.github.retrooper.packetevents.protocol.entity.data.EntityDataTypes;
55
import com.github.retrooper.packetevents.protocol.nbt.NBTCompound;
66
import me.tofaa.entitylib.EntityLib;
7-
import me.tofaa.entitylib.meta.EntityMeta;
87
import me.tofaa.entitylib.meta.Metadata;
98
import org.jetbrains.annotations.Nullable;
109

api/src/main/java/me/tofaa/entitylib/wrapper/WrapperEntity.java

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ public WrapperEntity(int entityId, UUID uuid, EntityType entityType, EntityMeta
4545
this.ticking = true;
4646
this.viewers = ConcurrentHashMap.newKeySet();
4747
this.passengers = ConcurrentHashMap.newKeySet();
48+
this.location = new Location(0, 0, 0, 0, 0);
4849
}
4950

5051
public WrapperEntity(int entityId, EntityType entityType) {
@@ -121,7 +122,12 @@ public void setLocation(Location location) {
121122
}
122123

123124
public void remove() {
124-
parent.removeEntity(this, true);
125+
if (parent != null) {
126+
parent.removeEntity(this, true);
127+
}
128+
else {
129+
despawn();
130+
}
125131
}
126132

127133
public void despawn() {
@@ -378,10 +384,12 @@ public boolean hasVelocity() {
378384
}
379385

380386
public void rotateHead(float yaw, float pitch) {
381-
sendPacketsToViewers(
387+
sendPacketsToViewersIfSpawned(
382388
new WrapperPlayServerEntityRotation(entityId, yaw, pitch, onGround),
383389
new WrapperPlayServerEntityHeadLook(entityId, yaw)
384390
);
391+
this.location.setYaw(yaw);
392+
this.location.setPitch(pitch);
385393
}
386394

387395
public void rotateHead(Location location) {

api/src/main/java/me/tofaa/entitylib/wrapper/WrapperPlayer.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@ public List<TextureProperty> getTextures() {
4040
return profile.getTextureProperties();
4141
}
4242

43-
public WrapperPlayServerPlayerInfoRemove tabListRemovePacket() {
44-
return new WrapperPlayServerPlayerInfoRemove(getUuid());
43+
public WrapperPlayServerPlayerInfoUpdate tabListRemovePacket() {
44+
return new WrapperPlayServerPlayerInfoUpdate(EnumSet.of(WrapperPlayServerPlayerInfoUpdate.Action.UPDATE_LISTED), createInfo());
4545
}
4646

4747
public void setGameMode(GameMode gameMode) {
@@ -95,9 +95,9 @@ public boolean isInTablist() {
9595
public void setInTablist(boolean tablist) {
9696
this.tablist = tablist;
9797
sendPacketsToViewersIfSpawned(tabListPacket());
98-
if (!tablist) {
99-
sendPacketsToViewersIfSpawned(tabListRemovePacket());
100-
}
98+
// if (!tablist) {
99+
// sendPacketsToViewersIfSpawned(tabListRemovePacket());
100+
// }
101101
}
102102

103103
public int getLatency() {

build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import java.io.ByteArrayOutputStream
22

3-
val fullVersion = "2.4.5"
3+
val fullVersion = "2.4.9"
44
val snapshot = true
55

66
group = "me.tofaa.entitylib"

buildSrc/src/main/kotlin/entitylib.library-conventions.gradle.kts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,17 @@ tasks {
4545
}
4646

4747
publishing {
48+
49+
repositories {
50+
maven {
51+
url = uri("https://maven.evokegames.gg/snapshots")
52+
credentials {
53+
username = System.getenv("TYCOONS_REPO_USER")
54+
password = System.getenv("TYCOONS_REPO_PASS")
55+
}
56+
}
57+
}
58+
4859
publications {
4960
create<MavenPublication>("EntityLib") {
5061
groupId = project.group as String

common/build.gradle.kts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,6 @@ plugins {
55

66
dependencies {
77
api(project(":api"))
8+
compileOnly(libs.bundles.adventure)
9+
compileOnly(libs.packetevents.api)
810
}

jitpack.yml

Lines changed: 0 additions & 15 deletions
This file was deleted.

model-engine-addon/build.gradle.kts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,18 @@ repositories {
77
maven {
88
url = uri("https://mvn.lumine.io/repository/maven-public/")
99
}
10+
maven("https://jitpack.io")
1011
}
1112

1213
dependencies {
1314
// compileOnly("com.ticxo.modelengine:ModelEngine:R4.0.4")
1415
api(project(":api"))
16+
17+
implementation("commons-io:commons-io:2.11.0")
18+
implementation("org.zeroturnaround:zt-zip:1.8")
19+
20+
implementation("javax.json:javax.json-api:1.1.4")
21+
implementation("org.glassfish:javax.json:1.1.4")
22+
23+
implementation("com.github.hollow-cube.common:mql:2b48ad430f")
1524
}

model-engine-addon/src/main/java/me/tofaa/entitylib/modelengine/ELibBaseEntity.java

Lines changed: 0 additions & 5 deletions
This file was deleted.

test-plugin/build.gradle.kts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,15 @@ plugins {
55
}
66

77
repositories {
8+
maven("https://maven.evokegames.gg/snapshots")
89
maven("https://repo.papermc.io/repository/maven-public/")
910
}
1011

1112
dependencies {
1213
compileOnly(libs.paper)
1314
compileOnly(libs.packetevents.spigot)
14-
implementation(project(":platforms:spigot"))
15+
implementation("me.tofaa.entitylib:spigot:2.4.5-SNAPSHOT")
16+
// implementation(project(":platforms:spigot"))
1517
}
1618

1719
tasks {

test-plugin/src/main/java/me/tofaa/testentitylib/TestPlayerCommand.java

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@
2020

2121
public class TestPlayerCommand extends BukkitCommand {
2222

23+
24+
private static final char UNICODE_EMPTY = '\u2800';
25+
2326
private WrapperPlayer p;
2427
private SkinFetcher sf;
2528
public TestPlayerCommand() {
@@ -28,6 +31,22 @@ public TestPlayerCommand() {
2831

2932
@Override
3033
public boolean execute(@NotNull CommandSender commandSender, @NotNull String s, @NotNull String[] strings) {
34+
Player player = (Player) commandSender;
35+
if (p != null) {
36+
p.setInTablist(!p.isInTablist());
37+
return true;
38+
}
39+
40+
p = new WrapperPlayer(new UserProfile(UUID.randomUUID(), "\u2800"), EntityLib.getPlatform().getEntityIdProvider().provide(UUID.randomUUID(), EntityTypes.PLAYER));
41+
p.setInTablist(true);
42+
p.setTextureProperties(ExtraConversionUtil.getProfileFromBukkitPlayer(player).getTextureProperties());
43+
p.spawn(SpigotConversionUtil.fromBukkitLocation(player.getLocation()));
44+
p.addViewer(player.getUniqueId());
45+
player.sendMessage("Entity spawned");
46+
return true;
47+
}
48+
49+
private boolean legacyProcess(@NotNull CommandSender commandSender, @NotNull String s, @NotNull String[] strings) {
3150
Player player = (Player) commandSender;
3251
if (strings.length < 1) {
3352
player.sendMessage("Usage: /testplayer <spawn|hello|ping|gamemode|displayname|tablist|remove>");
@@ -92,6 +111,7 @@ public boolean execute(@NotNull CommandSender commandSender, @NotNull String s,
92111
return true;
93112
}
94113

114+
95115
@NotNull
96116
@Override
97117
public List<String> tabComplete(@NotNull CommandSender sender, @NotNull String alias, @NotNull String[] args) throws IllegalArgumentException {

0 commit comments

Comments
 (0)