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 }}
steps:
- name: Clone project
uses: actions/checkout@v4
uses: actions/checkou@v4
- name: Install JDK 8
- name: Install JDK 21
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
if: github.ref == 'refs/heads/master'
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;
import com.github.retrooper.packetevents.PacketEventsAPI;
import com.github.retrooper.packetevents.manager.server.ServerVersion;
import org.jetbrains.annotations.NotNull;
public final class APIConfig {
@ -12,7 +11,6 @@ public final class APIConfig {
private boolean tickTickables = false;
private boolean platformLogger = false;
private boolean bstats = true;
private boolean forceBundle = false;
public APIConfig(PacketEventsAPI<?> packetEvents) {
this.packetEvents = packetEvents;
@ -28,11 +26,6 @@ public final class APIConfig {
return this;
}
public @NotNull APIConfig forceBundles() {
this.forceBundle = true;
return this;
}
public @NotNull APIConfig usePlatformLogger() {
this.platformLogger = true;
return this;
@ -77,10 +70,4 @@ public final class APIConfig {
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.extras.InvalidVersionException;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.serializer.gson.GsonComponentSerializer;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.concurrent.ConcurrentHashMap;
import java.util.function.BiFunction;
import static me.tofaa.entitylib.meta.MetaOffsetConverter.EntityMetaOffsets.*;
public class EntityMeta implements EntityMetadataProvider {
private static final MetaConverterRegistry registry = new MetaConverterRegistry();
@ -140,60 +145,60 @@ public class EntityMeta implements EntityMetadataProvider {
}
public short getAirTicks() {
return this.metadata.getIndex((byte)1, (short) 300);
return this.metadata.getIndex(airTicksOffset(), (short) 300);
}
public void setAirTicks(short value) {
this.metadata.setIndex((byte)1, EntityDataTypes.SHORT, value);
this.metadata.setIndex(airTicksOffset(), EntityDataTypes.SHORT, value);
}
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);
}
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() {
return this.metadata.getIndex((byte)3, false);
return this.metadata.getIndex(customNameVisibleOffset(), false);
}
public void setCustomNameVisible(boolean value) {
this.metadata.setIndex((byte)3, EntityDataTypes.BOOLEAN, value);
this.metadata.setIndex(customNameVisibleOffset(), EntityDataTypes.BOOLEAN, value);
}
public boolean isSilent() {
return this.metadata.getIndex((byte)4, false);
return this.metadata.getIndex(silentOffset(), false);
}
public void setSilent(boolean value) {
this.metadata.setIndex((byte)4, EntityDataTypes.BOOLEAN, value);
this.metadata.setIndex(silentOffset(), EntityDataTypes.BOOLEAN, value);
}
public boolean hasNoGravity() {
return this.metadata.getIndex((byte)5, true);
return this.metadata.getIndex(hasNoGravityOffset(), true);
}
public void setHasNoGravity(boolean value) {
this.metadata.setIndex((byte)5, EntityDataTypes.BOOLEAN, value);
this.metadata.setIndex(hasNoGravityOffset(), EntityDataTypes.BOOLEAN, value);
}
public EntityPose getPose() {
return this.metadata.getIndex((byte)6, EntityPose.STANDING);
return this.metadata.getIndex(poseOffset(), EntityPose.STANDING);
}
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() {
return this.metadata.getIndex((byte)7, 0);
return this.metadata.getIndex(ticksFrozenInPowderedSnowOffset(), 0);
}
public void setTicksFrozenInPowderedSnow(int value) {
this.metadata.setIndex((byte)7, EntityDataTypes.INT, value);
this.metadata.setIndex(ticksFrozenInPowderedSnowOffset(), EntityDataTypes.INT, value);
}
public WrapperPlayServerEntityMetadata createPacket() {

View file

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

View file

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

View file

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

View file

@ -110,15 +110,6 @@ final class LegacyHologram implements Hologram.Legacy {
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
public void addLine(@Nullable Component 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
public void addLine(@Nullable Component line) {
setLine(lines.size(), line);