Compare commits

...
Author SHA1 Message Date
Cubicake 8cb78056ed Move UpdateChecker to core 2026-08-30 17:59:41 +09:30
Cubicake dec5ba5de2 Begin spigot support 2026-08-30 17:08:04 +09:30
16 changed files with 241 additions and 59 deletions

No files matched your search

+4
View File
@@ -0,0 +1,4 @@
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
}
+2
View File
@@ -36,6 +36,8 @@ dependencies {
testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine")
testRuntimeOnly("org.junit.platform:junit-platform-launcher")
testImplementation("it.unimi.dsi:fastutil:8.5.18")
compileOnly("com.google.code.gson:gson:2.11.0")
}
val coreVersion = "0.7.2-SNAPSHOT"
@@ -6,7 +6,7 @@
* See README.md for warranty disclaimer and further information.
*/
package games.cubi.raycastedantiesp.core.engine;
package games.cubi.raycastedantiesp.core;
public interface AsyncRunner {
void runNow(Runnable task);
@@ -1,27 +1,14 @@
/*
* 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;
package games.cubi.raycastedantiesp.core;
import com.google.gson.JsonArray;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
import org.bukkit.Bukkit;
import org.bukkit.command.CommandSender;
import games.cubi.logs.Logger;
import games.cubi.raycastedantiesp.core.config.ConfigManager;
import games.cubi.raycastedantiesp.core.config.UpdateConfig;
import games.cubi.raycastedantiesp.core.utils.BuildProperties;
import games.cubi.raycastedantiesp.core.utils.BuildProperties.Version;
import games.cubi.raycastedantiesp.paper.utils.PaperScheduler;
import java.io.BufferedReader;
import java.io.IOException;
@@ -39,6 +26,8 @@ public class UpdateChecker {
private static final String VERSION_API_ENDPOINT = "https://api.modrinth.com/v2/project/bCjNZu0C/version?include_changelog=false";
private static final String PLATFORM_NAME = "Paper";
private static final String MODRINTH_PAGE_URL = "https://modrinth.com/project/bCjNZu0C/";
private static final String MODRINTH_MM_LINK = "<hover:show_text:'" + MODRINTH_PAGE_URL + "'><aqua><u><click:open_url:'" + MODRINTH_PAGE_URL + "'>" + MODRINTH_PAGE_URL + "</click></u></aqua></hover>";
enum UpdateChannel {
STABLE("release", "release"),
@@ -82,8 +71,8 @@ public class UpdateChecker {
record ApiVersion(String rawVersion, Version coreVersion, Version platformVersion) {}
record UpdateCheckReport(List<UpdateCheckResult> results) {
UpdateCheckReport {
public record UpdateCheckReport(List<UpdateCheckResult> results) {
public UpdateCheckReport {
results = List.copyOf(results);
}
@@ -114,20 +103,20 @@ public class UpdateChecker {
}
}
private static CompletableFuture<List<VersionEntry>> fetchVersions(RaycastedAntiESP plugin) {
private static CompletableFuture<List<VersionEntry>> fetchVersions(AsyncRunner runner) {
CompletableFuture<List<VersionEntry>> future = new CompletableFuture<>();
Bukkit.getAsyncScheduler().runNow(plugin, ignored -> {
runner.runNow(() -> {
try {
URLConnection connection = new URI(VERSION_API_ENDPOINT).toURL().openConnection();
connection.setConnectTimeout(5_000); //ms
connection.setReadTimeout(5_000); //ms
try (
final InputStreamReader reader = new InputStreamReader(connection.getInputStream());
final BufferedReader bufferedReader = new BufferedReader(reader)
) {
future.complete(parseVersionEntries(bufferedReader));
}
URLConnection connection = new URI(VERSION_API_ENDPOINT).toURL().openConnection();
connection.setConnectTimeout(5_000); //ms
connection.setReadTimeout(5_000); //ms
try (
final InputStreamReader reader = new InputStreamReader(connection.getInputStream());
final BufferedReader bufferedReader = new BufferedReader(reader)
) {
future.complete(parseVersionEntries(bufferedReader));
}
} catch (IOException | URISyntaxException e) {
future.completeExceptionally(new IllegalStateException("Unable to fetch latest version", e));
}
@@ -158,13 +147,13 @@ public class UpdateChecker {
return List.copyOf(versionEntries);
}
private static CompletableFuture<UpdateCheckReport> fetchUpdateCheck(RaycastedAntiESP plugin) {
public static CompletableFuture<UpdateCheckReport> fetchUpdateCheck(AsyncRunner runner) {
UpdateConfig updateConfig = ConfigManager.get().getUpdateConfig();
if (!updateConfig.anyChannelEnabled()) {
return CompletableFuture.completedFuture(new UpdateCheckReport(List.of()));
}
return fetchVersions(plugin).thenApply(versionEntries -> checkVersions(
return fetchVersions(runner).thenApply(versionEntries -> checkVersions(
BuildProperties.CORE.version(),
BuildProperties.PLATFORM.version(),
versionEntries,
@@ -275,14 +264,14 @@ public class UpdateChecker {
static String formatUpdateMessage(UpdateCheckResult result) {
return switch (result.status()) {
case BEHIND -> "<red>You are behind the latest " + result.channel().messageName() + " of RaycastedAntiESP. Please upgrade to <green>v" + result.apiVersion().rawVersion() + "<red> at " + modrinthLink() + "<red>.";
case BEHIND -> "<red>You are behind the latest " + result.channel().messageName() + " of RaycastedAntiESP. Please upgrade to <green>v" + result.apiVersion().rawVersion() + "<red> at " + MODRINTH_MM_LINK + "<red>.";
case UP_TO_DATE -> "<green>You are up to date with the latest " + result.channel().messageName() + " of RaycastedAntiESP.";
case AHEAD, NO_COMPARABLE_VERSION -> "<yellow>You are ahead of the latest " + result.channel().messageName() + " of RaycastedAntiESP.";
case INVALID_CURRENT_VERSION -> "<red>Unable to check for updates to RaycastedAntiESP, invalid current version format.";
};
}
static String formatUpdateMessage(UpdateCheckReport report) {
public static String formatUpdateMessage(UpdateCheckReport report) {
List<String> messages = new ArrayList<>();
for (UpdateCheckResult result : report.results()) {
messages.add(formatUpdateMessage(result));
@@ -290,20 +279,4 @@ public class UpdateChecker {
return String.join("\n", messages);
}
private static String modrinthLink() {
return "<hover:show_text:'" + MODRINTH_PAGE_URL + "'><aqua><u><click:open_url:'" + MODRINTH_PAGE_URL + "'>" + MODRINTH_PAGE_URL + "</click></u></aqua></hover>";
}
public static void checkForUpdates(RaycastedAntiESP plugin, CommandSender audience) {
fetchUpdateCheck(plugin).thenAccept(report -> {
if (report.results().isEmpty()) {
return;
}
PaperScheduler.runForAudience(plugin, audience, () -> audience.sendRichMessage(formatUpdateMessage(report)));
}).exceptionally(ex -> {
Logger.error("An error occurred while checking for plugin updates", ex, 4, UpdateChecker.class);
return null;
});
}
}
@@ -10,6 +10,7 @@ package games.cubi.raycastedantiesp.core.engine;
import games.cubi.locatables.api.Locatable;
import games.cubi.logs.Logger;
import games.cubi.raycastedantiesp.core.AsyncRunner;
import games.cubi.raycastedantiesp.core.config.ConfigManager;
import games.cubi.raycastedantiesp.core.config.DebugConfig;
import games.cubi.raycastedantiesp.core.config.raycast.EntityConfig;
@@ -26,7 +27,6 @@ import games.cubi.raycastedantiesp.core.view.BlockView;
import games.cubi.raycastedantiesp.core.view.EntityView;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.atomic.AtomicLong;
@@ -6,7 +6,7 @@
* See README.md for warranty disclaimer and further information.
*/
package games.cubi.raycastedantiesp.paper;
package games.cubi.raycastedantiesp.core;
import games.cubi.raycastedantiesp.core.utils.BuildProperties.Version;
import org.junit.jupiter.api.Test;
+2 -2
View File
@@ -11,8 +11,8 @@ 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("io.papermc.paperweight.userdev")
id("xyz.jpenilla.run-paper")
id("com.gradleup.shadow") version "9.4.0"
}
@@ -31,7 +31,7 @@ import org.bukkit.event.player.PlayerTeleportEvent;
import java.util.function.IntSupplier;
import static games.cubi.raycastedantiesp.paper.UpdateChecker.checkForUpdates;
import static games.cubi.raycastedantiesp.paper.RaycastedAntiESP.checkForUpdates;
public class EventListener extends PaperListener {
private final RaycastedAntiESP plugin;
@@ -9,6 +9,7 @@
package games.cubi.raycastedantiesp.paper;
import games.cubi.raycastedantiesp.core.Core;
import games.cubi.raycastedantiesp.core.UpdateChecker;
import games.cubi.raycastedantiesp.paper.commands.Attribution;
import games.cubi.raycastedantiesp.paper.commands.AttributionBrigadier;
import games.cubi.raycastedantiesp.paper.commands.RaycastedAntiESPCommandBrigadier;
@@ -28,12 +29,14 @@ import games.cubi.raycastedantiesp.paper.bStats.MetricsCollector;
import games.cubi.logs.Logger;
import games.cubi.raycastedantiesp.paper.utils.FoliaTicker;
import games.cubi.raycastedantiesp.paper.utils.PaperScheduler;
import games.cubi.raycastedantiesp.paper.utils.PaperTicker;
import io.papermc.paper.plugin.lifecycle.event.types.LifecycleEvents;
import org.bukkit.Bukkit;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.java.JavaPlugin;
@@ -103,7 +106,7 @@ public final class RaycastedAntiESP extends JavaPlugin implements CommandExecuto
new PaperPacketEventsBlockViewController(blockInfoResolver, trackAllBlocks, currentTickSupplier);
engine = new PaperAsyncEngine(this, config, currentTickSupplier);
UpdateChecker.checkForUpdates(this, Bukkit.getConsoleSender());
checkForUpdates(this, Bukkit.getConsoleSender());
EventListener.initialise(this, engine, currentTickSupplier);
this.getLifecycleManager().registerEventHandler(LifecycleEvents.COMMANDS.newHandler(event -> {
@@ -143,6 +146,18 @@ public final class RaycastedAntiESP extends JavaPlugin implements CommandExecuto
loggerAdapter.forceFlushToFileNow();
}
public static void checkForUpdates(RaycastedAntiESP plugin, CommandSender audience) {
UpdateChecker.fetchUpdateCheck(new PaperAsyncEngine.PaperAsyncRunner(plugin.getServer().getAsyncScheduler())).thenAccept(report -> {
if (report.results().isEmpty()) {
return;
}
PaperScheduler.runForAudience(plugin, audience, () -> audience.sendRichMessage(UpdateChecker.formatUpdateMessage(report)));
}).exceptionally(ex -> {
Logger.error("An error occurred while checking for plugin updates", ex, 4, UpdateChecker.class);
return null;
});
}
public static ConfigManager getConfigManager() {
return config;
@@ -23,7 +23,6 @@ import games.cubi.raycastedantiesp.core.view.AbstractBlockView;
import games.cubi.raycastedantiesp.core.view.BlockView;
import games.cubi.raycastedantiesp.core.view.EntityView;
import games.cubi.raycastedantiesp.paper.RaycastedAntiESP;
import games.cubi.raycastedantiesp.paper.UpdateChecker;
import games.cubi.raycastedantiesp.paper.packets.PacketEventsPaperBlockInfoResolver;
import games.cubi.raycastedantiesp.paper.utils.PaperScheduler;
@@ -115,7 +114,7 @@ public class RaycastedAntiESPCommand {
@Executes("check-for-updates")
void checkForUpdatesCommand(CommandSender sender) {
UpdateChecker.checkForUpdates(RaycastedAntiESP.get(), sender);
RaycastedAntiESP.checkForUpdates(RaycastedAntiESP.get(), sender);
}
@Executes("print-block-ids")
@@ -9,7 +9,7 @@
package games.cubi.raycastedantiesp.paper.engine;
import games.cubi.raycastedantiesp.core.config.ConfigManager;
import games.cubi.raycastedantiesp.core.engine.AsyncRunner;
import games.cubi.raycastedantiesp.core.AsyncRunner;
import games.cubi.raycastedantiesp.core.engine.AsyncEngine;
import games.cubi.raycastedantiesp.paper.PaperParticleSpawner;
import games.cubi.raycastedantiesp.paper.RaycastedAntiESP;
@@ -12,7 +12,6 @@ import com.destroystokyo.paper.event.server.ServerTickStartEvent;
import games.cubi.logs.Logger;
import games.cubi.raycastedantiesp.core.Ticker;
import games.cubi.raycastedantiesp.core.engine.AsyncEngine;
import games.cubi.raycastedantiesp.core.engine.AsyncRunner;
import games.cubi.raycastedantiesp.core.utils.VarHandler;
import games.cubi.raycastedantiesp.paper.EventListener;
import games.cubi.raycastedantiesp.paper.RaycastedAntiESP;
@@ -22,7 +21,6 @@ import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import java.lang.invoke.VarHandle;
import java.util.function.IntSupplier;
public class PaperTicker extends PaperListener implements Ticker {
private volatile int currentTick; private static final VarHandle CURRENT_TICK = VarHandler.get(PaperTicker.class, "currentTick", int.class);
+165
View File
@@ -0,0 +1,165 @@
import java.time.Instant
import org.gradle.jvm.toolchain.JavaToolchainService
plugins {
id("java-library")
id("com.gradleup.shadow") version "9.4.0"
id("xyz.jpenilla.run-paper")
}
repositories {
mavenCentral()
maven("https://hub.spigotmc.org/nexus/content/repositories/snapshots/")
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/") }
}
dependencies {
compileOnly("org.spigotmc:spigot-api:1.21.2-R0.1-SNAPSHOT")
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")
implementation("org.jetbrains:annotations:24.0.1")
implementation("org.bstats:bstats-bukkit:3.2.1")
implementation(project(":leafpile"))
implementation(project(":locatables"))
implementation(project(":logging"))
implementation(project(":core"))
implementation(project(":packetevents"))
testImplementation(platform("org.junit:junit-bom:5.10.2"))
testImplementation("org.junit.jupiter:junit-jupiter-api")
testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine")
testRuntimeOnly("org.junit.platform:junit-platform-launcher")
}
configurations.named("testRuntimeClasspath") {
exclude(group = "at.yawk.lz4", module = "lz4-java")
}
java {
toolchain.languageVersion = JavaLanguageVersion.of(21)
}
val javaToolchainService = project.extensions.getByType(JavaToolchainService::class.java)
group = "games.cubi.raycastedantiesp.spigot"
val platformPaperVersion: String = "0.0.1-SNAPSHOT"
val coreVersion = project(":core").version.toString()
val commitShort = providers.exec {
commandLine("git", "rev-parse", "--short=8", "HEAD")
}.standardOutput.asText.map { it.trim() }
val commitFull = providers.exec {
commandLine("git", "rev-parse", "HEAD")
}.standardOutput.asText.map { it.trim() }
val buildTime = providers.provider {
Instant.now().toString().replace(":", "-") // Replace colons to avoid issues in file names on some platforms
}
val isRelease = gradle.startParameter.taskNames.any {
it.contains("buildSpigotRelease")
}
fun getVersionString(): String {
if (isRelease) {
val paperVersion = platformPaperVersion.substringBefore("-") // Remove any suffixes like "-SNAPSHOT"
return "${coreVersion}-Spigot-${paperVersion}-RELEASE"
} else {
return "${coreVersion}-Spigot-${platformPaperVersion}+build-${buildTime.get()}+git-${commitShort.get()}"
}
}
fun getBasicVersionString(): String {
return if (isRelease) {
platformPaperVersion.substringBefore("-") // Remove any suffixes like "-SNAPSHOT"
} else {
platformPaperVersion
}
}
version = getVersionString()
tasks {
runServer {
// Configure the Minecraft version for our task.
// This is the only required configuration besides applying the plugin.
// 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))
}
minecraftVersion("26.1.2")
//minecraftVersion("1.21.11")
jvmArgs("-Xms4G", "-Xmx4G", "-Dcom.mojang.eula.agree=true")
}
processResources {
val props = mapOf("version" to version.toString())
inputs.properties(props)
filesMatching("plugin.yml") {
expand(props)
}
val gitProps = mapOf(
"short_git" to commitShort.get(),
"long_git" to commitFull.get(),
"build_time" to buildTime.get(),
"version" to getBasicVersionString()
)
inputs.properties(gitProps)
filesMatching("build-properties/platform.yml") {
expand(gitProps)
}
}
test {
useJUnitPlatform()
}
}
tasks.shadowJar {
dependencies {
include(project(":logging"))
include(project(":locatables"))
include(project(":core"))
include(project(":packetevents"))
include(project(":leafpile"))
include(dependency("org.bstats:bstats-base:3.2.1"))
include(dependency("org.bstats:bstats-bukkit:3.2.1"))
}
relocate(
"ca.spottedleaf",
"games.cubi.libs.raycastedantiesp.spottedleaf"
)
relocate(
"org.bstats",
"games.cubi.libs.raycastedantiesp.bstats"
)
minimize {} // get rid of leafpile bloat
archiveBaseName.set("RaycastedAntiESP")
archiveClassifier.set("")
}
tasks.jar {
archiveBaseName.set("Incorrectly-Compiled-Without-ShadowJar")
}
// This is the task to run to test if changes to the plugin are working
tasks.register("buildSpigotSnapshot") {
group = "raycasted anti-esp" //Not caps sensitive so using spacing and hyphen
description = "Builds a snapshot version of the plugin with git and build-time metadata included in the file name."
dependsOn("shadowJar")
}
tasks.register("buildSpigotRelease") {
group = "raycasted anti-esp"
description = "Builds a release version of the plugin with a clean version number (no git or build-time metadata) included in the file name."
dependsOn("shadowJar")
}
@@ -0,0 +1,16 @@
package games.cubi.raycastedantiesp.spigot;
import org.bukkit.plugin.java.JavaPlugin;
public final class RaycastedAntiESP extends JavaPlugin {
@Override
public void onEnable() {
// Plugin startup logic
}
@Override
public void onDisable() {
// Plugin shutdown logic
}
}
@@ -0,0 +1,9 @@
name: RaycastedAntiESP
prefix: RaycastedAntiESP
version: '$version'
main: games.cubi.raycastedantiesp.spigot.RaycastedAntiESP
api-version: '1.21'
load: STARTUP
authors: [_Cubicake]
+1
View File
@@ -11,5 +11,6 @@ include 'locatables'
include 'logging'
include 'core'
include 'platform-paper'
include 'platform-spigot'
include 'packetevents'
include 'leafpile'