Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,12 @@ Create client-side entities, send packets, and change what individual players se

| Dependency | Version | Notes |
| :--- | :--- | :--- |
| Paper | **26.3+** | Required |
| Paper | **1.21.11+** | Required |
| Skript | **2.17.0+** | Required |
| PacketEvents | **2.14.0+** | Required |
| [SkBee](https://modrinth.com/plugin/skbee/versions) | **3.26.0+** | Optional; enables the NBT Compound hook |

Only the latest supported Skript and Minecraft versions receive support. Older versions may work, but are not officially supported.
Minecraft 1.21.11 and newer versions supported by the required dependencies are supported. Java 21 or newer is required; use the Java version required by your Paper version.

---

Expand Down
8 changes: 5 additions & 3 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
}

group = "org.crebs"
version = "1.0.2"
version = "1.0.3"

val mockitoAgent by configurations.creating

Expand All @@ -27,6 +27,7 @@
}

dependencies {
implementation("org.ow2.asm:asm-tree:9.11.1")
implementation("org.bstats:bstats-bukkit:3.2.1")
testImplementation(platform("org.junit:junit-bom:6.0.0"))
testImplementation("org.junit.jupiter:junit-jupiter")
Expand All @@ -47,7 +48,7 @@
isTransitive = false
}
implementation("com.github.ShaneBeee:SkriptRegistration:1.5.0")
compileOnly("io.papermc.paper:paper-api:26.3.build.195-stable") {
compileOnly("io.papermc.paper:paper-api:1.21.11-R0.1-SNAPSHOT") {

Check notice on line 51 in build.gradle.kts

View workflow job for this annotation

GitHub Actions / Qodana for JVM

Vulnerable declared dependency

Provides transitive vulnerable dependency maven:com.google.guava:guava:33.3.1-jre * [CVE-2026-118042](https://www.mend.io/vulnerability-database/CVE-2026-118042?utm_source=Jetbrains) 3.7 Insufficient Information Results powered by [Mend.io](https://www.mend.io/jetbrains-lp/?utm_source=JetBrains)
exclude(group = "org.apache.maven", module = "maven-resolver-provider")
exclude(group = "org.apache.logging.log4j", module = "log4j-api")
}
Expand All @@ -65,7 +66,7 @@

tasks.withType<JavaCompile>().configureEach {
options.encoding = "UTF-8"
options.release.set(25)
options.release.set(21)
}

tasks.processResources {
Expand All @@ -78,6 +79,7 @@
tasks.shadowJar {
archiveClassifier.set("")
relocate("org.bstats", "org.crebs.skpackets.libs.bstats")
relocate("org.objectweb.asm", "org.crebs.skpackets.libs.asm")
relocate("me.tofaa.entitylib", "org.crebs.skpackets.libs.entitylib")
relocate("com.github.shanebeee.skr", "org.crebs.skpackets.libs.skr")
mergeServiceFiles()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -338,8 +338,7 @@ static void refreshPlayer(Player player) {
send(
player,
new WrapperPlayServerPlayerAbilities(
player.isInvulnerableTo(
org.bukkit.damage.DamageSource.builder(org.bukkit.damage.DamageType.GENERIC).build())
player.isInvulnerable()
|| player.getGameMode() == org.bukkit.GameMode.CREATIVE
|| player.getGameMode() == org.bukkit.GameMode.SPECTATOR,
player.isFlying(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@
import org.crebs.skpackets.api.util.field.ConstructionContext;

import java.io.IOException;
import java.lang.classfile.Attributes;
import java.lang.classfile.ClassFile;
import java.lang.classfile.MethodModel;
import java.lang.classfile.TypeAnnotation;
import org.objectweb.asm.ClassReader;
import org.objectweb.asm.TypeReference;
import org.objectweb.asm.tree.ClassNode;
import org.objectweb.asm.tree.MethodNode;
import java.lang.invoke.MethodType;
import java.lang.reflect.Constructor;
import java.lang.reflect.Type;
Expand Down Expand Up @@ -60,9 +60,11 @@ private static PacketConstructor discover(Class<?> wrapper) {
try (var stream = wrapper.getResourceAsStream("/" + wrapper.getName().replace('.', '/') + ".class")) {
if (stream == null) throw new IllegalStateException("Cannot read PacketEvents class " + wrapper.getName());
PacketConstructor selected = null;
for (MethodModel model : ClassFile.of().parse(stream.readAllBytes()).methods()) {
if (!model.methodName().equalsString("<init>")) continue;
Constructor<?> constructor = constructors.get(model.methodType().stringValue());
ClassNode classNode = new ClassNode();
new ClassReader(stream).accept(classNode, ClassReader.SKIP_CODE | ClassReader.SKIP_DEBUG | ClassReader.SKIP_FRAMES);
for (MethodNode model : classNode.methods) {
if (!model.name.equals("<init>")) continue;
Constructor<?> constructor = constructors.get(model.desc);
if (constructor == null || selected != null && constructor.getParameterCount() < selected.arguments().size()) continue;
var parameters = constructor.getParameters();
List<Argument> arguments = new ArrayList<>();
Expand Down Expand Up @@ -102,12 +104,16 @@ PacketWrapper<?> create(ConstructionContext<PacketTypeCommon, ?> values, Map<Str
}
}

private static boolean nullable(MethodModel model, int index) {
return Stream.concat(
model.findAttribute(Attributes.runtimeInvisibleTypeAnnotations()).stream().flatMap(attribute -> attribute.annotations().stream()),
model.findAttribute(Attributes.runtimeVisibleTypeAnnotations()).stream().flatMap(attribute -> attribute.annotations().stream()))
.anyMatch(annotation -> annotation.targetInfo() instanceof TypeAnnotation.FormalParameterTarget target
&& target.formalParameterIndex() == index && annotation.targetPath().isEmpty()
&& annotation.annotation().className().stringValue().endsWith("/Nullable;"));
private static boolean nullable(MethodNode model, int index) {
return Stream.of(model.invisibleTypeAnnotations, model.visibleTypeAnnotations)
.filter(Objects::nonNull)
.flatMap(Collection::stream)
.anyMatch(annotation -> {
TypeReference target = new TypeReference(annotation.typeRef);
return target.getSort() == TypeReference.METHOD_FORMAL_PARAMETER
&& target.getFormalParameterIndex() == index
&& (annotation.typePath == null || annotation.typePath.getLength() == 0)
&& annotation.desc.endsWith("/Nullable;");
});
}
}
2 changes: 1 addition & 1 deletion src/main/resources/plugin.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: skPackets
version: '${version}'
main: org.crebs.skpackets.SkPackets
api-version: '26.3'
api-version: '1.21.11'
description: A packet addon for Skript
depend: [Skript, packetevents]
softdepend: [SkBee]
Expand Down
Loading