Compare commits

..

No commits in common. "e1477bb5999aeb70d4cebbb17a8f6a7e64ce729f" and "f6ef89c7156cffc8fd12ef424bd983fdc1ade0da" have entirely different histories.

9 changed files with 33 additions and 126 deletions

View file

@ -18,18 +18,10 @@ jobs:
TYCOONS_REPO_PASS: ${{ secrets.EVOKE_REPO_PASSWORD }} TYCOONS_REPO_PASS: ${{ secrets.EVOKE_REPO_PASSWORD }}
steps: steps:
- name: Clone project - name: Clone project
uses: actions/checkout@v4 uses: actions/checkou@v4
- name: Install JDK 8 - name: Install JDK 21
uses: actions/setup-java@v4 uses: actions/setup-java@v4
with:
java-version: '8'
distribution: 'temurin'
check-latest: true
- name: Setup gradle
uses: gradle/actions/setup-gradle@v4
- 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'
run: chmod +x ./gradlew && ./gradlew publishAllPublicationsToMavenRepository run: chmod +x ./gradlew && ./gradlew publishAllPublicationsToMavenRepository

View file

@ -1,29 +0,0 @@
# Thanks paper: https://github.com/papermc/paper/blob/master/.github/workflows/close_invalid_prs.yml
name: Close invalid PRs
on:
pull_request_target:
types: [ opened ]
jobs:
run:
name: Close invalid PRs
if: |
github.repository != github.event.pull_request.head.repo.full_name &&
(
github.head_ref == 'master' ||
github.event.pull_request.head.repo.owner.type != 'User'
)
runs-on: ubuntu-latest
steps:
- uses: superbrothers/close-pull-request@v3
id: "master_branch"
if: github.head_ref == 'master'
with:
comment: "Please do not open pull requests from the `master` branch, create a new branch instead."
- uses: superbrothers/close-pull-request@v3
id: "org_account"
if: github.event.pull_request.head.repo.owner.type != 'User' && steps.master_branch.outcome == 'skipped'
with:
comment: "Please do not open pull requests from non-user accounts like organisations. Create a fork on a user account instead."

View file

@ -1,7 +1,6 @@
package me.tofaa.entitylib; package me.tofaa.entitylib;
import com.github.retrooper.packetevents.PacketEventsAPI; import com.github.retrooper.packetevents.PacketEventsAPI;
import com.github.retrooper.packetevents.manager.server.ServerVersion;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
public final class APIConfig { public final class APIConfig {
@ -12,7 +11,6 @@ public final class APIConfig {
private boolean tickTickables = false; private boolean tickTickables = false;
private boolean platformLogger = false; private boolean platformLogger = false;
private boolean bstats = true; private boolean bstats = true;
private boolean forceBundle = false;
public APIConfig(PacketEventsAPI<?> packetEvents) { public APIConfig(PacketEventsAPI<?> packetEvents) {
this.packetEvents = packetEvents; this.packetEvents = packetEvents;
@ -28,11 +26,6 @@ public final class APIConfig {
return this; return this;
} }
public @NotNull APIConfig forceBundles() {
this.forceBundle = true;
return this;
}
public @NotNull APIConfig usePlatformLogger() { public @NotNull APIConfig usePlatformLogger() {
this.platformLogger = true; this.platformLogger = true;
return this; return this;
@ -77,10 +70,4 @@ public final class APIConfig {
return bstats; return bstats;
} }
public boolean shouldForceBundles() {
return this.forceBundle
&& EntityLib.getOptionalApi().isPresent()
&& EntityLib.getOptionalApi().get().getPacketEvents().getServerManager().getVersion().isNewerThanOrEquals(ServerVersion.V_1_19_4);
}
} }

View file

@ -14,13 +14,18 @@ import com.github.retrooper.packetevents.wrapper.play.server.WrapperPlayServerEn
import me.tofaa.entitylib.EntityLib; import me.tofaa.entitylib.EntityLib;
import me.tofaa.entitylib.extras.InvalidVersionException; import me.tofaa.entitylib.extras.InvalidVersionException;
import net.kyori.adventure.text.Component; import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.serializer.gson.GsonComponentSerializer;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
import java.util.List; import java.util.List;
import java.util.Map;
import java.util.Optional; import java.util.Optional;
import java.util.concurrent.ConcurrentHashMap;
import java.util.function.BiFunction; import java.util.function.BiFunction;
import static me.tofaa.entitylib.meta.MetaOffsetConverter.EntityMetaOffsets.*;
public class EntityMeta implements EntityMetadataProvider { public class EntityMeta implements EntityMetadataProvider {
private static final MetaConverterRegistry registry = new MetaConverterRegistry(); private static final MetaConverterRegistry registry = new MetaConverterRegistry();
@ -140,60 +145,60 @@ public class EntityMeta implements EntityMetadataProvider {
} }
public short getAirTicks() { public short getAirTicks() {
return this.metadata.getIndex((byte)1, (short) 300); return this.metadata.getIndex(airTicksOffset(), (short) 300);
} }
public void setAirTicks(short value) { public void setAirTicks(short value) {
this.metadata.setIndex((byte)1, EntityDataTypes.SHORT, value); this.metadata.setIndex(airTicksOffset(), EntityDataTypes.SHORT, value);
} }
public Component getCustomName() { public Component getCustomName() {
Optional<Component> component = this.metadata.getIndex((byte)2, Optional.empty()); Optional<Component> component = this.metadata.getIndex(customNameOffset(), Optional.empty());
return component.orElse(null); return component.orElse(null);
} }
public void setCustomName(Component value) { public void setCustomName(Component value) {
this.metadata.setIndex((byte)2, EntityDataTypes.OPTIONAL_ADV_COMPONENT, Optional.ofNullable(value)); this.metadata.setIndex(customNameOffset(), EntityDataTypes.OPTIONAL_ADV_COMPONENT, Optional.ofNullable(value));
} }
public boolean isCustomNameVisible() { public boolean isCustomNameVisible() {
return this.metadata.getIndex((byte)3, false); return this.metadata.getIndex(customNameVisibleOffset(), false);
} }
public void setCustomNameVisible(boolean value) { public void setCustomNameVisible(boolean value) {
this.metadata.setIndex((byte)3, EntityDataTypes.BOOLEAN, value); this.metadata.setIndex(customNameVisibleOffset(), EntityDataTypes.BOOLEAN, value);
} }
public boolean isSilent() { public boolean isSilent() {
return this.metadata.getIndex((byte)4, false); return this.metadata.getIndex(silentOffset(), false);
} }
public void setSilent(boolean value) { public void setSilent(boolean value) {
this.metadata.setIndex((byte)4, EntityDataTypes.BOOLEAN, value); this.metadata.setIndex(silentOffset(), EntityDataTypes.BOOLEAN, value);
} }
public boolean hasNoGravity() { public boolean hasNoGravity() {
return this.metadata.getIndex((byte)5, true); return this.metadata.getIndex(hasNoGravityOffset(), true);
} }
public void setHasNoGravity(boolean value) { public void setHasNoGravity(boolean value) {
this.metadata.setIndex((byte)5, EntityDataTypes.BOOLEAN, value); this.metadata.setIndex(hasNoGravityOffset(), EntityDataTypes.BOOLEAN, value);
} }
public EntityPose getPose() { public EntityPose getPose() {
return this.metadata.getIndex((byte)6, EntityPose.STANDING); return this.metadata.getIndex(poseOffset(), EntityPose.STANDING);
} }
public void setPose(EntityPose value) { public void setPose(EntityPose value) {
this.metadata.setIndex((byte)6, EntityDataTypes.ENTITY_POSE, value); this.metadata.setIndex(poseOffset(), EntityDataTypes.ENTITY_POSE, value);
} }
public int getTicksFrozenInPowderedSnow() { public int getTicksFrozenInPowderedSnow() {
return this.metadata.getIndex((byte)7, 0); return this.metadata.getIndex(ticksFrozenInPowderedSnowOffset(), 0);
} }
public void setTicksFrozenInPowderedSnow(int value) { public void setTicksFrozenInPowderedSnow(int value) {
this.metadata.setIndex((byte)7, EntityDataTypes.INT, value); this.metadata.setIndex(ticksFrozenInPowderedSnowOffset(), EntityDataTypes.INT, value);
} }
public WrapperPlayServerEntityMetadata createPacket() { public WrapperPlayServerEntityMetadata createPacket() {

View file

@ -8,14 +8,10 @@ import org.jetbrains.annotations.ApiStatus;
@ApiStatus.Internal @ApiStatus.Internal
@SuppressWarnings("unused") @SuppressWarnings("unused")
@Deprecated
@ApiStatus.ScheduledForRemoval
public final class MetaOffsetConverter { public final class MetaOffsetConverter {
private MetaOffsetConverter() { private MetaOffsetConverter() {
} }
@Deprecated
@ApiStatus.ScheduledForRemoval
public static final class EntityMetaOffsets { public static final class EntityMetaOffsets {
private EntityMetaOffsets() { private EntityMetaOffsets() {
} }
@ -77,8 +73,6 @@ public final class MetaOffsetConverter {
} }
} }
@Deprecated
@ApiStatus.ScheduledForRemoval
public static final class AreaEffectCloudOffsets { public static final class AreaEffectCloudOffsets {
private AreaEffectCloudOffsets() { private AreaEffectCloudOffsets() {
} }
@ -93,10 +87,10 @@ public final class MetaOffsetConverter {
public static byte waitingOffset() { public static byte waitingOffset() {
int protocolVersion = getApi().getPacketEvents().getServerManager().getVersion().getProtocolVersion(); int protocolVersion = getApi().getPacketEvents().getServerManager().getVersion().getProtocolVersion();
if (protocolVersion >= 769 && protocolVersion <= 757) {
return 9; return 9;
// if (protocolVersion >= 769 && protocolVersion <= 757) { }
// } throw new RuntimeException("Unknown protocol version for this method");
// throw new RuntimeException("Unknown protocol version for this method");
} }
public static byte particleOffset() { public static byte particleOffset() {
@ -108,8 +102,6 @@ public final class MetaOffsetConverter {
} }
} }
@Deprecated
@ApiStatus.ScheduledForRemoval
public static final class AbstractDisplayMetaOffsets { public static final class AbstractDisplayMetaOffsets {
private AbstractDisplayMetaOffsets() { private AbstractDisplayMetaOffsets() {
} }
@ -271,8 +263,6 @@ public final class MetaOffsetConverter {
} }
} }
@Deprecated
@ApiStatus.ScheduledForRemoval
public static final class BlockDisplayMetaOffsets { public static final class BlockDisplayMetaOffsets {
private BlockDisplayMetaOffsets() { private BlockDisplayMetaOffsets() {
} }
@ -289,8 +279,6 @@ public final class MetaOffsetConverter {
} }
} }
@Deprecated
@ApiStatus.ScheduledForRemoval
public static final class ItemDisplayMetaOffsets { public static final class ItemDisplayMetaOffsets {
private ItemDisplayMetaOffsets() { private ItemDisplayMetaOffsets() {
} }
@ -318,8 +306,6 @@ public final class MetaOffsetConverter {
} }
} }
@Deprecated
@ApiStatus.ScheduledForRemoval
public static final class TextDisplayMetaOffsets { public static final class TextDisplayMetaOffsets {
private TextDisplayMetaOffsets() { private TextDisplayMetaOffsets() {
} }

View file

@ -52,7 +52,6 @@ public class WrapperEntity implements Tickable {
this.passengers = ConcurrentHashMap.newKeySet(); this.passengers = ConcurrentHashMap.newKeySet();
this.location = new Location(0, 0, 0, 0, 0); this.location = new Location(0, 0, 0, 0, 0);
this.viewerRules = new CopyOnWriteArrayList<>(); this.viewerRules = new CopyOnWriteArrayList<>();
this.velocity = Vector3d.zero();
} }
public WrapperEntity(int entityId, EntityType entityType) { public WrapperEntity(int entityId, EntityType entityType) {
@ -74,7 +73,7 @@ public class WrapperEntity implements Tickable {
if (spawned) return false; if (spawned) return false;
this.location = location; this.location = location;
this.spawned = true; this.spawned = true;
sendPacketsToViewers( sendPacketToViewers(
new WrapperPlayServerSpawnEntity( new WrapperPlayServerSpawnEntity(
entityId, entityId,
Optional.of(this.uuid), Optional.of(this.uuid),
@ -85,12 +84,9 @@ public class WrapperEntity implements Tickable {
location.getYaw(), location.getYaw(),
getObjectData(), getObjectData(),
createVeloPacket() createVeloPacket()
), )
entityMeta.createPacket()
); );
if (this instanceof WrapperLivingEntity) { sendPacketToViewers(entityMeta.createPacket());
sendPacketsToViewers(((WrapperLivingEntity)this).getAttributes().createPacket());
}
this.parent = parent; this.parent = parent;
parent.addEntity(this); parent.addEntity(this);
return true; return true;
@ -200,9 +196,6 @@ public class WrapperEntity implements Tickable {
sendPacket(uuid, createSpawnPacket()); sendPacket(uuid, createSpawnPacket());
sendPacket(uuid, entityMeta.createPacket()); sendPacket(uuid, entityMeta.createPacket());
sendPacket(uuid, createPassengerPacket()); sendPacket(uuid, createPassengerPacket());
if (this instanceof WrapperLivingEntity) {
sendPacket(uuid, ((WrapperLivingEntity)this).getAttributes().createPacket());
}
} }
if (EntityLib.getApi().getSettings().isDebugMode()) { if (EntityLib.getApi().getSettings().isDebugMode()) {
EntityLib.getPlatform().getLogger().info("Added viewer " + uuid + " to entity " + entityId); EntityLib.getPlatform().getLogger().info("Added viewer " + uuid + " to entity " + entityId);
@ -348,6 +341,7 @@ public class WrapperEntity implements Tickable {
consumer.accept(entityMeta); consumer.accept(entityMeta);
} }
public @NotNull UUID getUuid() { public @NotNull UUID getUuid() {
return uuid; return uuid;
} }
@ -399,7 +393,7 @@ public class WrapperEntity implements Tickable {
return viewerRules.get(index); return viewerRules.get(index);
} }
public WrapperPlayServerEntityVelocity getVelocityPacket() { private WrapperPlayServerEntityVelocity getVelocityPacket() {
Vector3d velocity = this.velocity.multiply(8000.0f / 20.0f); Vector3d velocity = this.velocity.multiply(8000.0f / 20.0f);
return new WrapperPlayServerEntityVelocity(entityId, velocity); return new WrapperPlayServerEntityVelocity(entityId, velocity);
} }
@ -447,21 +441,13 @@ public class WrapperEntity implements Tickable {
public void refresh() { public void refresh() {
if (!spawned) return; if (!spawned) return;
sendPacketsToViewers(entityMeta.createPacket(), createPassengerPacket()); sendPacketToViewers(entityMeta.createPacket());
sendPacketToViewers(createPassengerPacket());
} }
public void sendPacketToViewers(PacketWrapper<?> packet) { public void sendPacketToViewers(PacketWrapper<?> packet) {
if (EntityLib.getApi().getSettings().shouldForceBundles()) {
viewers.forEach(uuid -> {
sendPacket(uuid, new WrapperPlayServerBundle());
sendPacket(uuid, packet);
sendPacket(uuid, new WrapperPlayServerBundle());
});
}
else {
viewers.forEach(uuid -> sendPacket(uuid, packet)); viewers.forEach(uuid -> sendPacket(uuid, packet));
} }
}
public void sendPacketsToViewers(PacketWrapper<?>... wrappers) { public void sendPacketsToViewers(PacketWrapper<?>... wrappers) {
for (PacketWrapper<?> wrapper : wrappers) { for (PacketWrapper<?> wrapper : wrappers) {

View file

@ -45,8 +45,6 @@ public interface Hologram {
void setLine(int index, @Nullable Component line); void setLine(int index, @Nullable Component line);
void removeLine(int index);
void addLine(@Nullable Component line); void addLine(@Nullable Component line);
void addViewer(@NotNull UUID viewer); void addViewer(@NotNull UUID viewer);

View file

@ -110,15 +110,6 @@ final class LegacyHologram implements Hologram.Legacy {
teleport(location); teleport(location);
} }
@Override
public void removeLine(int index) {
if (index < 0 || index >= lines.size()) {
return;
}
this.lines.get(index).remove();
this.lines.remove(index);
}
@Override @Override
public void addLine(@Nullable Component line) { public void addLine(@Nullable Component line) {
setLine(lines.size(), line); setLine(lines.size(), line);

View file

@ -89,15 +89,6 @@ final class ModernHologram implements Hologram.Modern {
} }
} }
@Override
public void removeLine(int index) {
if (index < 0 || index >= lines.size()) {
return;
}
this.lines.get(index).remove();
this.lines.remove(index);
}
@Override @Override
public void addLine(@Nullable Component line) { public void addLine(@Nullable Component line) {
setLine(lines.size(), line); setLine(lines.size(), line);