Skip to content

Commit

Permalink
Fix!
Browse files Browse the repository at this point in the history
  • Loading branch information
Tofaa2 committed Jul 16, 2024
1 parent 24887cb commit 96e1401
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 4 deletions.
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
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
1 change: 1 addition & 0 deletions test-plugin/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ repositories {
dependencies {
compileOnly(libs.paper)
compileOnly(libs.packetevents.spigot)
implementation("com.github.Tofaa2.EntityLib:spigot:24887cb05a")
implementation(project(":platforms:spigot"))
}

Expand Down

0 comments on commit 96e1401

Please sign in to comment.