mirror of
https://github.com/Cubicake/RaycastedAntiESP.git
synced 2026-11-17 06:26:04 -05:00
Compare commits
10
Commits
main
...
eventbench
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c667c49f01 | ||
|
|
8d8a327cb0 | ||
|
|
a80b72c008 | ||
|
|
0725062d9c | ||
|
|
0e74a1ba15 | ||
|
|
9a822af8bc | ||
|
|
c6afbf0733 | ||
|
|
4eaa11b193 | ||
|
|
258e47c39f | ||
|
|
c825a4af96 |
No files matched your search
@@ -0,0 +1,13 @@
|
||||
/*
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
* Copyright © 2026 Cubicake.
|
||||
* This file is part of RaycastedAntiESP.
|
||||
* RaycastedAntiESP is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License v3.0 only, which can be accessed at https://www.gnu.org/licenses/agpl-3.0.html.
|
||||
* See README.md for warranty disclaimer and further information.
|
||||
*/
|
||||
|
||||
plugins {
|
||||
id("io.papermc.paperweight.userdev") version "2.0.0-beta.21" apply false
|
||||
id("xyz.jpenilla.run-paper") version "3.0.2" apply false
|
||||
id("com.gradleup.shadow") version "9.4.0" apply false
|
||||
}
|
||||
@@ -8,7 +8,6 @@
|
||||
|
||||
package games.cubi.raycastedantiesp.core.engine;
|
||||
|
||||
import games.cubi.locatables.api.ImmutableSpatial;
|
||||
import games.cubi.locatables.api.Locatable;
|
||||
import games.cubi.logs.Logger;
|
||||
import games.cubi.raycastedantiesp.core.config.ConfigManager;
|
||||
@@ -25,6 +24,8 @@ import games.cubi.raycastedantiesp.core.raycast.RaycastUtil;
|
||||
import games.cubi.raycastedantiesp.core.utils.PrimitiveIntArrayList;
|
||||
import games.cubi.raycastedantiesp.core.view.BlockView;
|
||||
import games.cubi.raycastedantiesp.core.view.EntityView;
|
||||
import games.cubi.utils.events.CancellableEvent;
|
||||
import games.cubi.utils.events.CancellableEventRegistry;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
@@ -120,6 +121,9 @@ public abstract class AsyncEngine implements Engine {
|
||||
}
|
||||
}
|
||||
|
||||
public static class EngineTickEvent extends CancellableEvent {}
|
||||
|
||||
public final CancellableEventRegistry<EngineTickEvent> engineTickEventRegistry = new CancellableEventRegistry<>();
|
||||
/**
|
||||
* Claims worker capacity and either runs work immediately or schedules worker batches.
|
||||
*
|
||||
@@ -127,6 +131,11 @@ public abstract class AsyncEngine implements Engine {
|
||||
* lifecycle; false if this attempt was skipped or cleaned up during setup.
|
||||
*/
|
||||
private boolean dispatchTick(int scheduledTick, int startTick, long scheduledNanos) {
|
||||
if (!engineTickEventRegistry.dispatch(EngineTickEvent::new)) {
|
||||
Logger.debug("Skipping tick due to event being cancelled");
|
||||
finishTickState();
|
||||
return false;
|
||||
}
|
||||
int threads = config.getEngineConfig().asyncConfig().asyncProcessingThreads();
|
||||
if (threads < 1) threads = 1;
|
||||
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
Run 1:
|
||||
[16:27:33 INFO]: [EventDispatchBenchmark] Event dispatch results (average ns/op, error is 99.9% confidence interval):
|
||||
[16:27:33 INFO]: [EventDispatchBenchmark] listeners | cubi ns/op | bukkit ns/op | bukkit/cubi
|
||||
[16:27:33 INFO]: [EventDispatchBenchmark] 0 | 2.529 ± 0.006 | 4.589 ± 0.037 | 1.81x
|
||||
[16:27:33 INFO]: [EventDispatchBenchmark] 1 | 3.489 ± 0.013 | 7.568 ± 0.102 | 2.17x
|
||||
[16:27:33 INFO]: [EventDispatchBenchmark] 4 | 5.855 ± 0.025 | 17.063 ± 0.616 | 2.91x
|
||||
[16:27:33 INFO]: [EventDispatchBenchmark] 16 | 10.737 ± 0.356 | 52.979 ± 0.236 | 4.93x
|
||||
[16:27:33 INFO]: [EventDispatchBenchmark] 32 | 18.078 ± 3.040 | 101.260 ± 1.882 | 5.60x
|
||||
[16:27:33 INFO]: [EventDispatchBenchmark] 64 | 29.596 ± 0.088 | 203.622 ± 0.996 | 6.88x
|
||||
|
||||
Run 2:
|
||||
[16:33:24 INFO]: [EventDispatchBenchmark] Event dispatch results (average ns/op, error is 99.9% confidence interval):
|
||||
[16:33:24 INFO]: [EventDispatchBenchmark] listeners | cubi ns/op | bukkit ns/op | bukkit/cubi
|
||||
[16:33:24 INFO]: [EventDispatchBenchmark] 0 | 2.550 ± 0.010 | 4.608 ± 0.016 | 1.81x
|
||||
[16:33:24 INFO]: [EventDispatchBenchmark] 1 | 4.381 ± 0.015 | 7.511 ± 0.011 | 1.71x
|
||||
[16:33:24 INFO]: [EventDispatchBenchmark] 4 | 6.053 ± 0.009 | 17.762 ± 3.984 | 2.93x
|
||||
[16:33:24 INFO]: [EventDispatchBenchmark] 16 | 14.320 ± 0.598 | 52.959 ± 0.099 | 3.70x
|
||||
[16:33:24 INFO]: [EventDispatchBenchmark] 32 | 23.392 ± 0.095 | 101.222 ± 0.228 | 4.33x
|
||||
[16:33:24 INFO]: [EventDispatchBenchmark] 64 | 41.709 ± 0.692 | 204.705 ± 2.331 | 4.91x
|
||||
|
||||
Using CopyOnWriteArray `for (BaseEventHandler<E> eventHandler : handlers.eventHandlers)`, without special-pathing monitor.
|
||||
Ignore bukkit results, they were made to not fire the event.
|
||||
[21:01:41 INFO]: [EventDispatchBenchmark] listeners | cubi ns/op | bukkit ns/op | bukkit/cubi
|
||||
[21:01:41 INFO]: [EventDispatchBenchmark] 0 | 4.287 ± 0.036 | 1.526 ± 0.176 | 0.36x
|
||||
[21:01:41 INFO]: [EventDispatchBenchmark] 1 | 7.566 ± 0.046 | 1.609 ± 0.123 | 0.21x
|
||||
[21:01:41 INFO]: [EventDispatchBenchmark] 4 | 8.813 ± 0.019 | 1.576 ± 0.061 | 0.18x
|
||||
[21:01:41 INFO]: [EventDispatchBenchmark] 16 | 17.443 ± 0.018 | 1.564 ± 0.002 | 0.09x
|
||||
[21:01:41 INFO]: [EventDispatchBenchmark] 32 | 34.947 ± 1.051 | 1.575 ± 0.042 | 0.05x
|
||||
[21:01:41 INFO]: [EventDispatchBenchmark] 64 | 74.946 ± 0.066 | 1.572 ± 0.039 | 0.02x
|
||||
|
||||
This benchmark is not a strictly apples-to-apples comparison because Bukkit’s event-dispatch path performs additional work,
|
||||
including thread validation, plugin-state checks, listener/executor indirection, and exception handling.
|
||||
The results therefore compare `games.cubi.utils.events`’s specialised handler registry with Bukkit’s broader public event infrastructure,
|
||||
rather than two dispatch mechanisms providing identical functionality.
|
||||
|
||||
However, since that extra work is unnecessary for our use-cases, `games.cubi.utils.events` is still better.
|
||||
@@ -0,0 +1,54 @@
|
||||
/*
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
* Copyright © 2026 Cubicake.
|
||||
* This file is part of RaycastedAntiESP.
|
||||
* RaycastedAntiESP is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License v3.0 only, which can be accessed at https://www.gnu.org/licenses/agpl-3.0.html.
|
||||
* See README.md for warranty disclaimer and further information.
|
||||
*/
|
||||
|
||||
plugins {
|
||||
id("java")
|
||||
id("xyz.jpenilla.run-paper")
|
||||
id("com.gradleup.shadow")
|
||||
}
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
maven { url = uri("https://repo.papermc.io/repository/maven-public/") }
|
||||
}
|
||||
|
||||
dependencies {
|
||||
compileOnly("io.papermc.paper:paper-api:1.21.11-R0.1-SNAPSHOT")
|
||||
|
||||
implementation(project(":leafpile"))
|
||||
implementation("org.openjdk.jmh:jmh-core:1.37")
|
||||
annotationProcessor("org.openjdk.jmh:jmh-generator-annprocess:1.37")
|
||||
}
|
||||
|
||||
group = "games.cubi.raycastedantiesp.benchmark"
|
||||
version = "1.0.0-SNAPSHOT"
|
||||
|
||||
java {
|
||||
toolchain.languageVersion = JavaLanguageVersion.of(21)
|
||||
}
|
||||
|
||||
tasks.shadowJar {
|
||||
archiveBaseName.set("EventDispatchBenchmark")
|
||||
archiveClassifier.set("")
|
||||
}
|
||||
|
||||
tasks.jar {
|
||||
archiveBaseName.set("Incorrectly-Compiled-Without-ShadowJar")
|
||||
}
|
||||
|
||||
tasks.runServer {
|
||||
minecraftVersion("1.21.11")
|
||||
jvmArgs(
|
||||
"-Xms1G",
|
||||
"-Xmx1G",
|
||||
"-Dcom.mojang.eula.agree=true",
|
||||
"-Dterminal.jline=false",
|
||||
"-Dterminal.ansi=false",
|
||||
"-DeventBenchmark.resultFile=${layout.buildDirectory.file("reports/event-benchmark/results.json").get().asFile.absolutePath}",
|
||||
)
|
||||
}
|
||||
+120
@@ -0,0 +1,120 @@
|
||||
/*
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
* Copyright © 2026 Cubicake.
|
||||
* This file is part of RaycastedAntiESP.
|
||||
* RaycastedAntiESP is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License v3.0 only, which can be accessed at https://www.gnu.org/licenses/agpl-3.0.html.
|
||||
* See README.md for warranty disclaimer and further information.
|
||||
*/
|
||||
|
||||
package games.cubi.raycastedantiesp.benchmark;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
import org.openjdk.jmh.results.RunResult;
|
||||
import org.openjdk.jmh.results.format.ResultFormatType;
|
||||
import org.openjdk.jmh.runner.Runner;
|
||||
import org.openjdk.jmh.runner.options.Options;
|
||||
import org.openjdk.jmh.runner.options.OptionsBuilder;
|
||||
import org.openjdk.jmh.runner.options.TimeValue;
|
||||
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.util.Collection;
|
||||
import java.util.Comparator;
|
||||
import java.util.HashMap;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.logging.Level;
|
||||
|
||||
public final class EventBenchmarkPlugin extends JavaPlugin {
|
||||
private static EventBenchmarkPlugin instance;
|
||||
|
||||
@Override
|
||||
public void onEnable() {
|
||||
instance = this;
|
||||
getLogger().info("Starting the event-dispatch benchmark asynchronously.");
|
||||
Bukkit.getScheduler().runTaskAsynchronously(this, this::runBenchmark);
|
||||
}
|
||||
|
||||
static EventBenchmarkPlugin instance() {
|
||||
EventBenchmarkPlugin current = instance;
|
||||
if (current == null) {
|
||||
throw new IllegalStateException("Benchmark plugin is not enabled");
|
||||
}
|
||||
return current;
|
||||
}
|
||||
|
||||
private void runBenchmark() {
|
||||
try {
|
||||
Path resultFile = Path.of(System.getProperty(
|
||||
"eventBenchmark.resultFile",
|
||||
getDataPath().resolve("results.json").toString()
|
||||
));
|
||||
Files.createDirectories(resultFile.toAbsolutePath().getParent());
|
||||
|
||||
Options options = new OptionsBuilder()
|
||||
.include(EventDispatchBenchmark.class.getName())
|
||||
.mode(org.openjdk.jmh.annotations.Mode.AverageTime)
|
||||
.timeUnit(TimeUnit.NANOSECONDS)
|
||||
.threads(1)
|
||||
.forks(0)
|
||||
.warmupIterations(5)
|
||||
.warmupTime(TimeValue.seconds(1))
|
||||
.measurementIterations(10)
|
||||
.measurementTime(TimeValue.seconds(1))
|
||||
.shouldFailOnError(true)
|
||||
.resultFormat(ResultFormatType.JSON)
|
||||
.result(resultFile.toString())
|
||||
.build();
|
||||
|
||||
Collection<RunResult> results = new Runner(options).run();
|
||||
logSummary(results, resultFile);
|
||||
} catch (Throwable throwable) {
|
||||
getLogger().log(Level.SEVERE, "Event-dispatch benchmark failed", throwable);
|
||||
} finally {
|
||||
Bukkit.getScheduler().runTask(this, Bukkit::shutdown);
|
||||
}
|
||||
}
|
||||
|
||||
private void logSummary(Collection<RunResult> results, Path resultFile) {
|
||||
record Score(double value, double error) {}
|
||||
|
||||
Map<Integer, Score> cubi = new HashMap<>();
|
||||
Map<Integer, Score> bukkit = new HashMap<>();
|
||||
results.stream()
|
||||
.sorted(Comparator.comparingInt(result -> Integer.parseInt(
|
||||
result.getParams().getParam("listenerCount")
|
||||
)))
|
||||
.forEach(result -> {
|
||||
int count = Integer.parseInt(result.getParams().getParam("listenerCount"));
|
||||
Score score = new Score(
|
||||
result.getPrimaryResult().getScore(),
|
||||
result.getPrimaryResult().getScoreError()
|
||||
);
|
||||
if (result.getParams().getBenchmark().endsWith(".cubi")) {
|
||||
cubi.put(count, score);
|
||||
} else if (result.getParams().getBenchmark().endsWith(".bukkit")) {
|
||||
bukkit.put(count, score);
|
||||
}
|
||||
});
|
||||
|
||||
getLogger().info("Event dispatch results (average ns/op, error is 99.9% confidence interval):");
|
||||
getLogger().info("listeners | cubi ns/op | bukkit ns/op | bukkit/cubi");
|
||||
cubi.keySet().stream().sorted().forEach(count -> {
|
||||
Score cubiScore = cubi.get(count);
|
||||
Score bukkitScore = bukkit.get(count);
|
||||
getLogger().info(String.format(
|
||||
Locale.ROOT,
|
||||
"%9d | %8.3f ± %-8.3f | %10.3f ± %-8.3f | %.2fx",
|
||||
count,
|
||||
cubiScore.value(),
|
||||
cubiScore.error(),
|
||||
bukkitScore.value(),
|
||||
bukkitScore.error(),
|
||||
bukkitScore.value() / cubiScore.value()
|
||||
));
|
||||
});
|
||||
getLogger().info("Machine-readable JMH results: " + resultFile.toAbsolutePath());
|
||||
}
|
||||
}
|
||||
+178
@@ -0,0 +1,178 @@
|
||||
/*
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
* Copyright © 2026 Cubicake.
|
||||
* This file is part of RaycastedAntiESP.
|
||||
* RaycastedAntiESP is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License v3.0 only, which can be accessed at https://www.gnu.org/licenses/agpl-3.0.html.
|
||||
* See README.md for warranty disclaimer and further information.
|
||||
*/
|
||||
|
||||
package games.cubi.raycastedantiesp.benchmark;
|
||||
|
||||
import games.cubi.utils.events.CancellableEventRegistry;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.event.Cancellable;
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.openjdk.jmh.annotations.Benchmark;
|
||||
import org.openjdk.jmh.annotations.Param;
|
||||
import org.openjdk.jmh.annotations.Scope;
|
||||
import org.openjdk.jmh.annotations.Setup;
|
||||
import org.openjdk.jmh.annotations.State;
|
||||
import org.openjdk.jmh.annotations.TearDown;
|
||||
import org.openjdk.jmh.annotations.Level;
|
||||
|
||||
@State(Scope.Benchmark)
|
||||
public class EventDispatchBenchmark {
|
||||
private static final CancellableEventRegistry.Order[] CUBI_PRIORITIES = {
|
||||
CancellableEventRegistry.Order.EARLY,
|
||||
CancellableEventRegistry.Order.NORMAL,
|
||||
CancellableEventRegistry.Order.LATE,
|
||||
CancellableEventRegistry.Order.MONITOR,
|
||||
};
|
||||
private static final EventPriority[] BUKKIT_PRIORITIES = {
|
||||
EventPriority.LOWEST,
|
||||
EventPriority.NORMAL,
|
||||
EventPriority.HIGHEST,
|
||||
EventPriority.MONITOR,
|
||||
};
|
||||
|
||||
@Param({"0", "1", "4", "16", "32", "64"})
|
||||
public int listenerCount;
|
||||
|
||||
private CancellableEventRegistry<CubiBenchmarkEvent> cubiRegistry;
|
||||
private CubiBenchmarkEvent cubiEvent;
|
||||
private BukkitBenchmarkEvent bukkitEvent;
|
||||
|
||||
@Setup(Level.Trial)
|
||||
public void setup() {
|
||||
EventBenchmarkPlugin plugin = EventBenchmarkPlugin.instance();
|
||||
BukkitBenchmarkEvent.getHandlerList().unregister(plugin);
|
||||
|
||||
cubiRegistry = new CancellableEventRegistry<>();
|
||||
cubiEvent = new CubiBenchmarkEvent();
|
||||
bukkitEvent = new BukkitBenchmarkEvent();
|
||||
|
||||
for (int index = 0; index < listenerCount; index++) {
|
||||
CancellableEventRegistry.Order cubiPriority = listenerCount < 16
|
||||
? CancellableEventRegistry.Order.NORMAL
|
||||
: CUBI_PRIORITIES[index % CUBI_PRIORITIES.length];
|
||||
EventPriority bukkitPriority = listenerCount < 16
|
||||
? EventPriority.NORMAL
|
||||
: BUKKIT_PRIORITIES[index % BUKKIT_PRIORITIES.length];
|
||||
|
||||
cubiRegistry.register(cubiPriority, CubiBenchmarkEvent::recordHandling);
|
||||
Bukkit.getPluginManager().registerEvent(
|
||||
BukkitBenchmarkEvent.class,
|
||||
new Listener() {},
|
||||
bukkitPriority,
|
||||
(ignored, event) -> ((BukkitBenchmarkEvent) event).recordHandling(),
|
||||
plugin,
|
||||
true
|
||||
);
|
||||
}
|
||||
|
||||
BukkitBenchmarkEvent.getHandlerList().bake();
|
||||
verifySetup();
|
||||
}
|
||||
|
||||
private void verifySetup() {
|
||||
int registeredBukkitListeners = BukkitBenchmarkEvent.getHandlerList().getRegisteredListeners().length;
|
||||
if (registeredBukkitListeners != listenerCount) {
|
||||
throw new IllegalStateException("Expected " + listenerCount + " Bukkit listeners, found " + registeredBukkitListeners);
|
||||
}
|
||||
if (!cubiRegistry.dispatch(cubiEvent) || !bukkitEvent.callEvent()) {
|
||||
throw new IllegalStateException("An uncancelled verification dispatch returned cancelled");
|
||||
}
|
||||
if (cubiEvent.handledCount() != listenerCount || bukkitEvent.handledCount() != listenerCount) {
|
||||
throw new IllegalStateException(
|
||||
"Verification dispatch count mismatch: cubi=" + cubiEvent.handledCount()
|
||||
+ ", bukkit=" + bukkitEvent.handledCount()
|
||||
+ ", expected=" + listenerCount
|
||||
);
|
||||
}
|
||||
cubiEvent.resetHandledCount();
|
||||
bukkitEvent.resetHandledCount();
|
||||
}
|
||||
|
||||
@TearDown(Level.Trial)
|
||||
public void tearDown() {
|
||||
BukkitBenchmarkEvent.getHandlerList().unregister(EventBenchmarkPlugin.instance());
|
||||
BukkitBenchmarkEvent.getHandlerList().bake();
|
||||
}
|
||||
|
||||
@Benchmark
|
||||
public long cubi() {
|
||||
boolean dispatched = cubiRegistry.dispatch(cubiEvent);
|
||||
long handled = cubiEvent.handledCount();
|
||||
return dispatched ? handled : ~handled;
|
||||
}
|
||||
|
||||
@Benchmark
|
||||
public long bukkit() {/*
|
||||
boolean dispatched = bukkitEvent.callEvent();
|
||||
long handled = bukkitEvent.handledCount();
|
||||
return dispatched ? handled : ~handled;
|
||||
*/
|
||||
return 0;
|
||||
}
|
||||
|
||||
public static final class CubiBenchmarkEvent extends games.cubi.utils.events.CancellableEvent {
|
||||
private long handledCount;
|
||||
|
||||
void recordHandling() {
|
||||
handledCount++;
|
||||
}
|
||||
|
||||
long handledCount() {
|
||||
return handledCount;
|
||||
}
|
||||
|
||||
void resetHandledCount() {
|
||||
handledCount = 0L;
|
||||
}
|
||||
}
|
||||
|
||||
public static final class BukkitBenchmarkEvent extends Event implements Cancellable {
|
||||
private static final HandlerList HANDLERS = new HandlerList();
|
||||
|
||||
private boolean cancelled;
|
||||
private long handledCount;
|
||||
|
||||
BukkitBenchmarkEvent() {
|
||||
super(true);
|
||||
}
|
||||
|
||||
public static HandlerList getHandlerList() {
|
||||
return HANDLERS;
|
||||
}
|
||||
|
||||
@Override
|
||||
public HandlerList getHandlers() {
|
||||
return HANDLERS;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCancelled() {
|
||||
return cancelled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCancelled(boolean cancelled) {
|
||||
this.cancelled = cancelled;
|
||||
}
|
||||
|
||||
void recordHandling() {
|
||||
handledCount++;
|
||||
}
|
||||
|
||||
long handledCount() {
|
||||
return handledCount;
|
||||
}
|
||||
|
||||
void resetHandledCount() {
|
||||
handledCount = 0L;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
name: EventDispatchBenchmark
|
||||
version: 1.0.0-SNAPSHOT
|
||||
main: games.cubi.raycastedantiesp.benchmark.EventBenchmarkPlugin
|
||||
api-version: '1.21.11'
|
||||
authors: [ _Cubicake ]
|
||||
description: Temporary JMH comparison of Cubi and Paper event dispatch.
|
||||
+1
-1
Submodule leafpile updated: dca89261e9...eeaa8f812f.
+1
-1
Submodule locatables updated: 7de6bff030...97ff3c29dc.
@@ -11,9 +11,9 @@ import org.gradle.jvm.toolchain.JavaToolchainService
|
||||
|
||||
plugins {
|
||||
id("java-library")
|
||||
id("io.papermc.paperweight.userdev") version "2.0.0-beta.21"
|
||||
id("xyz.jpenilla.run-paper") version "3.0.2"
|
||||
id("com.gradleup.shadow") version "9.4.0"
|
||||
id("io.papermc.paperweight.userdev")
|
||||
id("xyz.jpenilla.run-paper")
|
||||
id("com.gradleup.shadow")
|
||||
}
|
||||
|
||||
repositories {
|
||||
@@ -21,19 +21,15 @@ repositories {
|
||||
maven { url = uri("https://repo.codemc.io/repository/maven-releases/") }
|
||||
maven { url = uri("https://repo.codemc.io/repository/maven-snapshots/") }
|
||||
maven { url = uri("https://eldonexus.de/repository/maven-public/") }
|
||||
maven("https://repo.fancyinnovations.com/releases")
|
||||
}
|
||||
|
||||
dependencies {
|
||||
paperweight.paperDevBundle("1.21.4-R0.1-SNAPSHOT")
|
||||
paperweight.paperDevBundle("1.21.6-R0.1-SNAPSHOT")
|
||||
//paperweight.paperDevBundle("26.2.build.+")
|
||||
compileOnly("com.github.retrooper:packetevents-spigot:2.12.0")
|
||||
compileOnly("org.spongepowered:configurate-core:4.2.0")
|
||||
compileOnly("org.spongepowered:configurate-yaml:4.2.0")
|
||||
|
||||
compileOnly("de.oliver:FancyHolograms:2.9.1")
|
||||
compileOnly("de.oliver:FancyNpcs:2.9.2")
|
||||
|
||||
compileOnly("net.strokkur.commands:annotations-paper:2.1.2")
|
||||
annotationProcessor("net.strokkur.commands:processor-paper:2.1.2")
|
||||
|
||||
@@ -109,10 +105,10 @@ tasks {
|
||||
// Your plugin's jar (or shadowJar if present) will be used automatically.
|
||||
javaLauncher = javaToolchainService.launcherFor {
|
||||
//languageVersion.set(paperRunJavaVersion.map(JavaLanguageVersion::of))
|
||||
languageVersion.set(JavaLanguageVersion.of(25))
|
||||
languageVersion.set(JavaLanguageVersion.of(21))
|
||||
}
|
||||
minecraftVersion("26.1.2")
|
||||
//minecraftVersion("1.21.11")
|
||||
//minecraftVersion("26.1.2")
|
||||
minecraftVersion("1.21.11")
|
||||
jvmArgs("-Xms4G", "-Xmx4G", "-Dcom.mojang.eula.agree=true")
|
||||
}
|
||||
|
||||
|
||||
@@ -17,9 +17,10 @@ import games.cubi.raycastedantiesp.core.players.PlayerRegistry;
|
||||
import games.cubi.raycastedantiesp.paper.engine.PaperAsyncEngine;
|
||||
import games.cubi.raycastedantiesp.core.players.PlayerData;
|
||||
import games.cubi.raycastedantiesp.paper.utils.PaperListener;
|
||||
import games.cubi.utils.events.CancellableEvent;
|
||||
import games.cubi.utils.events.CancellableEventRegistry;
|
||||
import io.papermc.paper.event.player.PlayerClientLoadedWorldEvent;
|
||||
import net.kyori.adventure.text.minimessage.MiniMessage;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
@@ -44,6 +45,9 @@ public class EventListener extends PaperListener {
|
||||
this.plugin = plugin;
|
||||
this.engine = engine;
|
||||
this.currentTickSupplier = currentTickSupplier;
|
||||
playerValidityCheckEventRegistry.register(CancellableEventRegistry.Order.NORMAL, (event) -> {
|
||||
if (event.player.hasMetadata("NPC")) event.cancel();
|
||||
});
|
||||
}
|
||||
|
||||
public static EventListener initialise(RaycastedAntiESP plugin, PaperAsyncEngine engine, IntSupplier currentTickSupplier) {
|
||||
@@ -58,11 +62,23 @@ public class EventListener extends PaperListener {
|
||||
EntityBypassRegistry.markEntityDespawned(event.getEntity().getEntityId());
|
||||
}
|
||||
|
||||
public static final class PlayerValidityCheckEvent extends CancellableEvent {
|
||||
public final Player player;
|
||||
PlayerValidityCheckEvent(Player player) {
|
||||
this.player = player;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* If this event is cancelled, player join processing will be skipped for this entity
|
||||
*/
|
||||
public static final CancellableEventRegistry<PlayerValidityCheckEvent> playerValidityCheckEventRegistry = new CancellableEventRegistry<PlayerValidityCheckEvent>();
|
||||
|
||||
@EventHandler(priority = EventPriority.LOWEST) //Runs first
|
||||
public void onPlayerJoin(PlayerClientLoadedWorldEvent e) {
|
||||
Player player = e.getPlayer();
|
||||
|
||||
if (player.hasMetadata("NPC")) return;
|
||||
if (!playerValidityCheckEventRegistry.dispatch(new PlayerValidityCheckEvent(player))) return;
|
||||
|
||||
PlayerData playerData = PlayerRegistry.getInstance().getPlayerData(player.getUniqueId());
|
||||
if (playerData == null) {
|
||||
|
||||
-78
@@ -1,78 +0,0 @@
|
||||
/*
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
* Copyright © 2026 Cubicake.
|
||||
* This file is part of RaycastedAntiESP.
|
||||
* RaycastedAntiESP is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License v3.0 only, which can be accessed at https://www.gnu.org/licenses/agpl-3.0.html.
|
||||
* See README.md for warranty disclaimer and further information.
|
||||
*/
|
||||
|
||||
package games.cubi.raycastedantiesp.paper;
|
||||
|
||||
import de.oliver.fancyholograms.api.events.*;
|
||||
import de.oliver.fancyholograms.api.hologram.Hologram;
|
||||
import de.oliver.fancynpcs.api.events.NpcCreateEvent;
|
||||
import de.oliver.fancynpcs.api.events.NpcModifyEvent;
|
||||
import de.oliver.fancynpcs.api.events.NpcSpawnEvent;
|
||||
import games.cubi.logs.Logger;
|
||||
import games.cubi.raycastedantiesp.core.entity.EntityBypassRegistry;
|
||||
import games.cubi.raycastedantiesp.paper.utils.PaperListener;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
|
||||
// Entity remove events aren't listened to because the event names are a bit confusing to me and I'm unclear when each event is called.
|
||||
// This should not be an issue as NPCs and Holograms are typically static entities which are not spawned or unspawned.
|
||||
public class FancyCompatibility {
|
||||
FancyCompatibility() {
|
||||
Logger.info("Attempting to initiate FancyNPCs and FancyHolograms compatibility layer. If you are not using those plugins, you will see an error. This is safe to ignore.", 5);
|
||||
new NPCs();
|
||||
new Holograms();
|
||||
}
|
||||
|
||||
static class NPCs extends PaperListener {
|
||||
|
||||
@EventHandler(priority = EventPriority.LOWEST)
|
||||
public void npcLoad(NpcSpawnEvent event) {
|
||||
int id = event.getNpc().getEntityId();
|
||||
Logger.info("NpcSpawnEvent called, adding entity: " + id, 1);
|
||||
EntityBypassRegistry.addEntity(id);
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOWEST)
|
||||
public void npcLoad(NpcCreateEvent event) {
|
||||
int id = event.getNpc().getEntityId();
|
||||
Logger.info("NpcCreateEvent called, adding entity: " + id, 1);
|
||||
EntityBypassRegistry.addEntity(id);
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOWEST)
|
||||
public void npcLoad(NpcModifyEvent event) {
|
||||
int id = event.getNpc().getEntityId();
|
||||
Logger.info("NpcModifyEvent called, adding entity: " + id, 1);
|
||||
EntityBypassRegistry.addEntity(id);
|
||||
}
|
||||
}
|
||||
|
||||
static class Holograms extends PaperListener {
|
||||
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
|
||||
public void onHologramCreate(HologramCreateEvent event) {
|
||||
add(event.getHologram());
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
|
||||
public void onHologramShow(HologramShowEvent event) {
|
||||
add(event.getHologram());
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOWEST)
|
||||
public void onHologramsLoaded(HologramsLoadedEvent event) {
|
||||
event.getManager().forEach(this::add);
|
||||
}
|
||||
|
||||
private void add(Hologram hologram) {
|
||||
int id = hologram.getEntityId();
|
||||
Logger.info("Hologram event called, adding entity: " + id, 1);
|
||||
EntityBypassRegistry.addEntity(id);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -120,7 +120,6 @@ public final class RaycastedAntiESP extends JavaPlugin implements CommandExecuto
|
||||
}
|
||||
}, 1200, 1200);*/
|
||||
/*Do not delete, this is a legal notice*/Attribution.sendAttributionMessage(Bukkit.getConsoleSender()); // Legal notice as required by AGPLv3, it prominently offers users of this plugin the source code and displays an appropriate copyright notice. If you are a fork developer, do NOT remove this unless you have a thorough understanding of the AGPL and have replaced it with a suitable equivalent notice which is "prominently visible", displays the copyright notice, and includes a link to the source code of your fork which is accessible to all users of the plugin.
|
||||
new FancyCompatibility();
|
||||
}
|
||||
|
||||
private String parseTrackers(Set<Player> trackers) {
|
||||
|
||||
+7
-6
@@ -69,7 +69,8 @@ public class PacketEventsPaperBlockInfoResolver implements BlockInfoResolver {
|
||||
run = false;
|
||||
continue;
|
||||
}
|
||||
if (blockData.getMaterial() == Material.AIR) {
|
||||
Material material = blockData.getMaterial();
|
||||
if (material == Material.AIR) {
|
||||
airs++;
|
||||
if (airs > 80000) { // There is a sequence of ~40 air blocks around ID 100, and another of several hundred at ~3000. We scan forwards 80k to future-proof any mojank. Since it runs once at startup, perf is irrelevant here
|
||||
run = false;
|
||||
@@ -79,12 +80,12 @@ public class PacketEventsPaperBlockInfoResolver implements BlockInfoResolver {
|
||||
else {
|
||||
airs = 0;
|
||||
lastNonAirID = iterator;
|
||||
if (materialToIDMode) {
|
||||
Logger.info(blockData.getAsString() + iterator,1);
|
||||
}
|
||||
}
|
||||
|
||||
occlusion.put(iterator, blockData.getMaterial().isOccluding());
|
||||
boolean occluding = material != Material.BARRIER && material.isOccluding();
|
||||
if (materialToIDMode && material != Material.AIR) {
|
||||
Logger.info(blockData.getAsString() + iterator + occluding,1);
|
||||
}
|
||||
occlusion.put(iterator, occluding);
|
||||
try {
|
||||
if (blockData.createBlockState() instanceof TileState) {
|
||||
//Logger.debug("tile at" + iterator + " is tile entity" + material.name());
|
||||
|
||||
@@ -1,3 +1,11 @@
|
||||
/*
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
* Copyright © 2026 Cubicake.
|
||||
* This file is part of RaycastedAntiESP.
|
||||
* RaycastedAntiESP is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License v3.0 only, which can be accessed at https://www.gnu.org/licenses/agpl-3.0.html.
|
||||
* See README.md for warranty disclaimer and further information.
|
||||
*/
|
||||
|
||||
rootProject.name = 'RaycastedAntiESP'
|
||||
dependencyResolutionManagement {
|
||||
versionCatalogs {
|
||||
@@ -13,3 +21,4 @@ include 'core'
|
||||
include 'platform-paper'
|
||||
include 'packetevents'
|
||||
include 'leafpile'
|
||||
include 'event-benchmark'
|
||||
Reference in new issue
Block a user