diff --git a/AccessWidener/src/main/java/de/steamwar/Agent.java b/AccessWidener/src/main/java/de/steamwar/Agent.java
index 6558508c..e078d357 100644
--- a/AccessWidener/src/main/java/de/steamwar/Agent.java
+++ b/AccessWidener/src/main/java/de/steamwar/Agent.java
@@ -28,17 +28,15 @@ import java.util.logging.Logger;
/**
* Java agent entry point.
- *
- * Can be used two ways:
- * 1. At JVM startup: java -javaagent:paper-access-widener-agent.jar -jar server.jar
- * 2. Late attach: from inside a Paper plugin via the Attach API
- *
+ *
+ * At JVM startup: java -javaagent:paper-access-widener-agent.jar -jar server.jar
+ *
* On attach the agent:
- * 1. Scans all existing plugin ClassLoaders for "plugin.accesswidener" resources
- * 2. Registers a ClassFileTransformer that:
- * a. Applies widening to every class as it loads
- * b. Detects new plugin ClassLoaders and scans them automatically
- * 3. Retransforms any Minecraft/server classes that are already loaded
+ *
+ * - Find all .jar files inside the plugins folder
+ * - Scan all found jars for *.accesswidener resources
+ * - Transform any class during loading
+ *
*/
public class Agent {
private Agent() {
diff --git a/BauSystem/BauSystem_Main/build.gradle.kts b/BauSystem/BauSystem_Main/build.gradle.kts
index f51b33cd..f81b7614 100644
--- a/BauSystem/BauSystem_Main/build.gradle.kts
+++ b/BauSystem/BauSystem_Main/build.gradle.kts
@@ -30,6 +30,45 @@ java {
targetCompatibility = JavaVersion.VERSION_21
}
+// ─── Collect all .accesswidener files from this plugin's resources ────────────
+val accessWidenerFiles: FileCollection = fileTree("src/") {
+ include("**/*.accesswidener")
+}
+
+val paperJarProvider: Provider = provider {
+ val dep = libs.nms.get()
+ configurations["compileClasspath"].resolvedConfiguration.resolvedArtifacts.first { artifact ->
+ artifact.moduleVersion.id.module.group == dep.module.group && artifact.moduleVersion.id.module.name == dep.module.name
+ }.file
+}
+
+// ─── Widen the Paper dev JAR so the IDE / javac see the patched access ────────
+val widenedJar by tasks.registering(JavaExec::class) {
+ description = "Produces a widened copy of the Paper dev JAR for compile-time use."
+ group = "widener"
+
+ // Re-run whenever the .accesswidener files change
+ inputs.file(paperJarProvider)
+ inputs.files(accessWidenerFiles)
+
+ val output = layout.buildDirectory.file("widened/paper-widened.jar")
+ outputs.file(output)
+
+ classpath = project(":AccessWidener").tasks.named("shadowJar").get().outputs.files
+
+ mainClass.set("de.steamwar.Main")
+
+ doFirst {
+ args = buildList {
+ add(paperJarProvider.get().absolutePath)
+ add(output.get().asFile.absolutePath)
+ addAll(accessWidenerFiles.map { it.absolutePath })
+ }
+ }
+
+ dependsOn(":AccessWidener:shadowJar")
+}
+
dependencies {
compileOnly(libs.classindex)
annotationProcessor(libs.classindex)
@@ -40,6 +79,7 @@ dependencies {
compileOnly(libs.paperapi)
compileOnly(libs.nms)
+ compileOnly(files(widenedJar))
compileOnly(libs.fawe)
compileOnly(libs.netty)
@@ -47,3 +87,7 @@ dependencies {
implementation(libs.luaj)
implementation(files("$projectDir/../libs/YAPION-SNAPSHOT.jar"))
}
+
+tasks.compileJava {
+ dependsOn(widenedJar)
+}
diff --git a/BauSystem/BauSystem_Main/src/bausystem.accesswidener b/BauSystem/BauSystem_Main/src/bausystem.accesswidener
index 7a0f195d..921ce434 100644
--- a/BauSystem/BauSystem_Main/src/bausystem.accesswidener
+++ b/BauSystem/BauSystem_Main/src/bausystem.accesswidener
@@ -1,3 +1,8 @@
accessWidener v2 named
accessible field net/minecraft/server/level/ServerPlayerGameMode gameModeForPlayer Lnet/minecraft/world/level/GameType;
+accessible field org/bukkit/craftbukkit/block/CraftBlockState position Lnet/minecraft/core/BlockPos;
+accessible field org/bukkit/craftbukkit/block/CraftBlockState world Lorg/bukkit/craftbukkit/CraftWorld;
+mutable field org/bukkit/craftbukkit/block/CraftBlockState position Lnet/minecraft/core/BlockPos;
+mutable field org/bukkit/craftbukkit/block/CraftBlockState world Lorg/bukkit/craftbukkit/CraftWorld;
+accessible field net/minecraft/server/ServerTickRateManager remainingSprintTicks J
\ No newline at end of file
diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/util/NoClipCommand.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/util/NoClipCommand.java
index 6ead52d4..19bffd3f 100644
--- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/util/NoClipCommand.java
+++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/util/NoClipCommand.java
@@ -102,7 +102,7 @@ public class NoClipCommand extends SWCommand implements Listener {
}
private void setInternalGameMode(Player player, GameMode gameMode) {
- // ((CraftPlayer) player).getHandle().gameMode.gameModeForPlayer = GameType.byId(gameMode.getValue());
+ ((CraftPlayer) player).getHandle().gameMode.gameModeForPlayer = GameType.byId(gameMode.getValue());
}
@Register(help = true)
diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/utils/PlaceItemUtils.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/utils/PlaceItemUtils.java
index c4ab9a54..71f42cbb 100644
--- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/utils/PlaceItemUtils.java
+++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/utils/PlaceItemUtils.java
@@ -19,7 +19,6 @@
package de.steamwar.bausystem.utils;
-import de.steamwar.Reflection;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.experimental.UtilityClass;
@@ -86,9 +85,6 @@ public class PlaceItemUtils {
.collect(Collectors.toSet());
}
- private static final Reflection.Field> positionAccessor = Reflection.getField(CraftBlockState.class, BlockPos.class, 0);
- private static final Reflection.Field> worldAccessor = Reflection.getField(CraftBlockState.class, CraftWorld.class, 0);
-
/**
* Attempt to place an {@link ItemStack} the {@link Player} is holding against a {@link Block} inside the World.
* This can be easily used inside the {@link org.bukkit.event.player.PlayerInteractEvent} to mimik placing a
@@ -288,8 +284,9 @@ public class PlaceItemUtils {
} else {
// If a BlockState is present set the Position and World to the Block you want to place
Location blockLocation = block.getLocation();
- positionAccessor.set(blockState, new BlockPos(blockLocation.getBlockX(), blockLocation.getBlockY(), blockLocation.getBlockZ()));
- worldAccessor.set(blockState, blockLocation.getWorld());
+ CraftBlockState craftBlockState = (CraftBlockState) blockState;
+ craftBlockState.position = new BlockPos(blockLocation.getBlockX(), blockLocation.getBlockY(), blockLocation.getBlockZ());
+ craftBlockState.world = (CraftWorld) blockLocation.getWorld();
}
if (blockData.getMaterial().isSolid()) {
diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/utils/TickManager.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/utils/TickManager.java
index 59d12df2..613b3ea4 100644
--- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/utils/TickManager.java
+++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/utils/TickManager.java
@@ -20,7 +20,6 @@
package de.steamwar.bausystem.utils;
import com.comphenix.tinyprotocol.TinyProtocol;
-import de.steamwar.Reflection;
import de.steamwar.bausystem.BauSystem;
import net.minecraft.network.protocol.game.ClientboundTickingStatePacket;
import net.minecraft.server.MinecraftServer;
@@ -33,7 +32,6 @@ public class TickManager implements Listener {
public static final TickManager impl = new TickManager();
private static final ServerTickRateManager manager = MinecraftServer.getServer().tickRateManager();
- private static final Reflection.Field remainingSprintTicks = Reflection.getField(ServerTickRateManager.class, long.class, 0);
private boolean blockTpsPacket = true;
private int totalSteps;
@@ -121,7 +119,7 @@ public class TickManager implements Listener {
public long getRemainingTicks() {
if (isSprinting()) {
- return remainingSprintTicks.get(manager);
+ return manager.remainingSprintTicks;
} else {
return manager.frozenTicksToRun();
}