Compare commits

...
11 Commits
16 changed files with 302 additions and 68 deletions

No files matched your search

+1 -3
View File
@@ -118,9 +118,7 @@ gradle-app.setting
**/build/
# Common working directory
run/
runs/
run-1-21-11/
run*/
# Avoid ignoring Gradle wrapper jar file (.jar files are usually ignored)
!gradle-wrapper.jar
+1 -1
View File
@@ -13,7 +13,7 @@ The supported minecraft versions are 1.21.4+. Only Paper and derivative software
- Prevent cheating (anti-esp hacks)
- This is the plugin's primary purpose.
- Block usage of pie-ray to locate underground bases or farms.
- Prevent mods such as mini-maps or cheat clients from displaying the locations of hidden entities.
- Prevent mods such as mini-maps or cheat clients from displaying the locations of entities which would not be visible to vanilla players.
- Increase client-side performance for low-end devices
- Massive megabases containing hundreds of armour stands, item frames, banners etc can cause performance issues on low-end devices unable to process so many entities. Raycasted AntiESP will cull those entities for the client, reducing the number of entities to process.
- Reduce network load by limiting packets
@@ -20,17 +20,21 @@ import org.spongepowered.configurate.ConfigurationNode;
import org.spongepowered.configurate.yaml.NodeStyle;
import org.spongepowered.configurate.yaml.YamlConfigurationLoader;
import java.lang.invoke.VarHandle;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.lang.annotation.Documented;
import java.lang.invoke.VarHandle;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.function.Supplier;
public class ConfigManager {
@@ -306,28 +310,13 @@ public class ConfigManager {
Files.createFile(configPath);
}
}
prependConfigDocumentationHeaderIfMissing();
ConfigMigrations.prependConfigDocumentationHeaderIfMissing(configPath);
ConfigMigrations.migrateSoundEffectsEnabled(configPath);
} catch (IOException e) {
throw new ConfigLoadException("Failed to create config.yml", e);
}
}
private void prependConfigDocumentationHeaderIfMissing() {
try {
String content = Files.readString(configPath);
if (content.startsWith("#")) {
Logger.debug("Config starts with comment");
return;
}
Logger.debug("no starting comment");
Files.writeString(configPath, "# An explanation of this configuration file and what all the options do can be found at https://raycastedantiesp.cubi.games/config/" + System.lineSeparator() + content);
} catch (Exception e) {
Logger.warning(e,3, ConfigManager.class);
}
}
private ConfigurationNode loadConfigNode() {
try {
return loader.load();
@@ -374,6 +363,108 @@ public class ConfigManager {
}
}
/**
* Temporary text-level config mutations. Remove this class when these migrations are no longer needed.
*/
private static final class ConfigMigrations {
private static final Pattern YAML_KEY = Pattern.compile("^([ \\t]*)([^:#\\s][^:]*):.*$");
private static final Pattern SOUND_EFFECTS_ENABLED_TRUE = Pattern.compile("^([ \\t]*enabled[ \\t]*:[ \\t]*)true([ \\t]*(?:#.*)?)$", Pattern.CASE_INSENSITIVE);
private ConfigMigrations() {
}
private static void prependConfigDocumentationHeaderIfMissing(Path configPath) {
try {
String content = Files.readString(configPath);
if (content.startsWith("#")) {
Logger.debug("Config starts with comment");
return;
}
Logger.debug("no starting comment");
Files.writeString(configPath, "# An explanation of this configuration file and what all the options do can be found at https://raycastedantiesp.cubi.games/config/" + System.lineSeparator() + content);
} catch (Exception e) {
Logger.warning(e,3, ConfigManager.class);
}
}
@Temporary(forRemovalIn = "0.8.0")
private static void migrateSoundEffectsEnabled(Path configPath) {
try {
String content = Files.readString(configPath, StandardCharsets.UTF_8);
String migrated = replaceSoundEffectsEnabled(content);
if (!content.equals(migrated)) {
Files.writeString(configPath, migrated, StandardCharsets.UTF_8);
}
} catch (IOException e) {
throw new ConfigLoadException("Failed to migrate sound-effects.enabled in config.yml", e);
}
}
private static String replaceSoundEffectsEnabled(String content) {
StringBuilder migrated = new StringBuilder(content.length());
int lineStart = 0;
int checksIndent = -1;
int soundEffectsIndent = -1;
boolean changed = false;
while (lineStart < content.length()) {
int lineEnd = content.indexOf('\n', lineStart);
boolean hasLineEnding = lineEnd >= 0;
int contentEnd = hasLineEnding ? lineEnd : content.length();
int lineContentEnd = contentEnd > lineStart && content.charAt(contentEnd - 1) == '\r'
? contentEnd - 1 : contentEnd;
String line = content.substring(lineStart, lineContentEnd);
String lineEnding = content.substring(lineContentEnd, contentEnd) + (hasLineEnding ? "\n" : "");
Matcher key = YAML_KEY.matcher(line);
if (key.matches()) {
int indent = key.group(1).length();
String name = key.group(2).trim();
if (checksIndent < 0) {
if (name.equals("checks")) {
checksIndent = indent;
}
} else if (indent <= checksIndent) {
checksIndent = name.equals("checks") ? indent : -1;
soundEffectsIndent = -1;
} else if (soundEffectsIndent < 0) {
if (name.equals("sound-effects")) {
soundEffectsIndent = indent;
}
} else if (indent <= soundEffectsIndent) {
soundEffectsIndent = name.equals("sound-effects") ? indent : -1;
}
}
if (soundEffectsIndent >= 0 && key.matches()
&& key.group(2).trim().equals("enabled")
&& key.group(1).length() > soundEffectsIndent) {
Matcher enabled = SOUND_EFFECTS_ENABLED_TRUE.matcher(line);
if (enabled.matches()) {
line = enabled.group(1) + "false" + enabled.group(2);
changed = true;
}
}
migrated.append(line).append(lineEnding);
if (!hasLineEnding) {
break;
}
lineStart = contentEnd + 1;
}
return changed ? migrated.toString() : content;
}
@Documented
private @interface Temporary {
String forRemovalIn();
}
}
private ConfigurationNode node(ConfigurationNode root, String path) {
String[] parts = path.split("\\.");
return ConfigReader.node(root, parts);
@@ -22,4 +22,6 @@ public interface ParticleSpawner {
void spawnParticleAt(Locatable locatable, Colour colour);
void spawnParticleAt(UUID world, Spatial spatial, Colour colour);
void spawnParticleAt(UUID world, double x, double y, double z, Colour colour);
}
@@ -189,72 +189,59 @@ public class RaycastUtil {
if (total > maxRaycastRadius) return false;
float finalDist = (float) (total - stepSize);
RayChunkSection currentChunk = new RayChunkSection().updateFrom(current);
ChunkOcclusionView currentOcclusionView = snap.getChunkOcclusionView(currentChunk.chunkX, currentChunk.chunkY, currentChunk.chunkZ);
int occluded = 0;
final RayAdvancer rayAdvancer = new RayAdvancer(current, direction, snap);
float traveled = 0;
final float fourSteps = stepSize * 4.0f;
while (traveled + fourSteps <= finalDist) {
current.advance(direction);
int blockX = current.blockX();
int blockY = current.blockY();
int blockZ = current.blockZ();
if (blockX >> 4 != currentChunk.chunkX || blockY >> 4 != currentChunk.chunkY || blockZ >> 4 != currentChunk.chunkZ) {
currentChunk.updateFrom(current);
currentOcclusionView = snap.getChunkOcclusionView(currentChunk.chunkX, currentChunk.chunkY, currentChunk.chunkZ);
}
if (currentOcclusionView != null && currentOcclusionView.isOccludingGlobal(blockX, blockY, blockZ)) occluded++;
rayAdvancer.advance();
current.advance(direction);
blockX = current.blockX();
blockY = current.blockY();
blockZ = current.blockZ();
if (blockX >> 4 != currentChunk.chunkX || blockY >> 4 != currentChunk.chunkY || blockZ >> 4 != currentChunk.chunkZ) {
currentChunk.updateFrom(current);
currentOcclusionView = snap.getChunkOcclusionView(currentChunk.chunkX, currentChunk.chunkY, currentChunk.chunkZ);
}
if (currentOcclusionView != null && currentOcclusionView.isOccludingGlobal(blockX, blockY, blockZ)) occluded++;
rayAdvancer.advance();
current.advance(direction);
blockX = current.blockX();
blockY = current.blockY();
blockZ = current.blockZ();
if (blockX >> 4 != currentChunk.chunkX || blockY >> 4 != currentChunk.chunkY || blockZ >> 4 != currentChunk.chunkZ) {
currentChunk.updateFrom(current);
currentOcclusionView = snap.getChunkOcclusionView(currentChunk.chunkX, currentChunk.chunkY, currentChunk.chunkZ);
}
if (currentOcclusionView != null && currentOcclusionView.isOccludingGlobal(blockX, blockY, blockZ)) occluded++;
rayAdvancer.advance();
current.advance(direction);
blockX = current.blockX();
blockY = current.blockY();
blockZ = current.blockZ();
if (blockX >> 4 != currentChunk.chunkX || blockY >> 4 != currentChunk.chunkY || blockZ >> 4 != currentChunk.chunkZ) {
currentChunk.updateFrom(current);
currentOcclusionView = snap.getChunkOcclusionView(currentChunk.chunkX, currentChunk.chunkY, currentChunk.chunkZ);
}
if (currentOcclusionView != null && currentOcclusionView.isOccludingGlobal(blockX, blockY, blockZ)) occluded++;
rayAdvancer.advance();
if (occluded >= maxOccluding) return false;
if (rayAdvancer.occluded >= maxOccluding) return false;
traveled += fourSteps;
}
for (; traveled < finalDist; traveled += stepSize) {
rayAdvancer.advance();
}
return rayAdvancer.occluded < maxOccluding;
}
private static final class RayAdvancer {
private final RayPosition current;
private final RayDirection direction;
private final RayChunkSection currentChunk;
private final BlockView blockView;
private ChunkOcclusionView currentOcclusionView;
private int occluded = 0;
private RayAdvancer(RayPosition rayPosition, RayDirection rayDirection, BlockView blockView) {
current = rayPosition;
direction = rayDirection;
currentChunk = new RayChunkSection().updateFrom(current);
currentOcclusionView = blockView.getChunkOcclusionView(currentChunk.chunkX, currentChunk.chunkY, currentChunk.chunkZ);
this.blockView = blockView;
}
private void advance() {
current.advance(direction);
int blockX = current.blockX();
int blockY = current.blockY();
int blockZ = current.blockZ();
if (blockX >> 4 != currentChunk.chunkX || blockY >> 4 != currentChunk.chunkY || blockZ >> 4 != currentChunk.chunkZ) {
currentChunk.updateFrom(current);
currentOcclusionView = snap.getChunkOcclusionView(currentChunk.chunkX, currentChunk.chunkY, currentChunk.chunkZ);
currentOcclusionView = blockView.getChunkOcclusionView(currentChunk.chunkX, currentChunk.chunkY, currentChunk.chunkZ);
}
if (currentOcclusionView != null && currentOcclusionView.isOccludingGlobal(blockX, blockY, blockZ)) occluded++;
}
return occluded < maxOccluding;
}
private static final class RayPosition {
@@ -8,6 +8,7 @@
package games.cubi.raycastedantiesp.packetevents.viewcontrollers;
import com.github.retrooper.packetevents.protocol.entity.data.EntityData;
import com.github.retrooper.packetevents.wrapper.PacketWrapper;
import com.github.retrooper.packetevents.wrapper.play.server.WrapperPlayServerEntityMetadata;
import games.cubi.logs.Logger;
@@ -33,6 +34,12 @@ final class PECacheablePacketReconciliationTask extends BaseEntitySpawnTask {
NettyEntity<?> entity = playerData.entityFromID(entityID);
if (entity == null) {
Logger.error("Reconciliation fail: Attempted to cache packet for unknown entity, id=" + entityID + " packet=" + packet.getClass().getSimpleName() + ".", 3, this.getClass());
if (packet instanceof WrapperPlayServerEntityMetadata metadataPacket) {
var data = metadataPacket.getEntityMetadata();
for (EntityData<?> eData : data) {
Logger.debug("Index:"+eData.getIndex()+"Type:"+eData.getType()+"Value:"+eData.getValue());
}
}
return;
}
if (packet instanceof WrapperPlayServerEntityMetadata metadataPacket) {
@@ -73,7 +73,7 @@ public class EventListener extends PaperListener {
if (ConfigManager.get().getUpdateConfig().notifyInGame()
&& player.hasPermission("raycastedantiesp.updatecheck")
&& (playerData.getJoinTick() - currentTickSupplier.getAsInt() < 10)) { //todo: centralise permission strings to prevent issues when perm names are changed
&& (currentTickSupplier.getAsInt() - playerData.getJoinTick() < 10)) { //todo: centralise permission strings to prevent issues when perm names are changed
checkForUpdates(plugin, player);
}
@@ -32,6 +32,11 @@ public class PaperParticleSpawner implements ParticleSpawner {
world.spawnParticle(Particle.DUST, spatial.x(), spatial.y(), spatial.z(), 0, toBukkitDust(colour));
}
public void spawnParticleAt(UUID worldUUID, double x, double y, double z, Colour colour) {
World world = Logger.requireNonNull(LocatableAdapterUtils.getWorld(worldUUID), "UUID resolved to nonexistent world", 2, PaperParticleSpawner.class);
world.spawnParticle(Particle.DUST, x, y, z, 0, toBukkitDust(colour));
}
private static final Particle.DustOptions RED_DUST = new Particle.DustOptions(Color.RED, 1);
private static final Particle.DustOptions GREEN_DUST = new Particle.DustOptions(Color.GREEN, 1);
private static final Particle.DustOptions BLUE_DUST = new Particle.DustOptions(Color.BLUE, 1);
+1 -1
View File
@@ -71,7 +71,7 @@ checks:
hide-on-spawn-distance: 24
visible-recheck-interval-ticks: -1 # -1 disables visible rechecks. When set to -1, once an entity is shown by any mechanism, it will be permanently visible.
sound-effects:
enabled: true
enabled: false
max-occluding-count: 3
always-play-radius: 8
raycast-radius: 48
+62
View File
@@ -0,0 +1,62 @@
/*
* 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-velocity") version "3.0.2"
}
group = 'games.cubi'
version = '0.0.1-SNAPSHOT'
repositories {
mavenCentral()
maven {
name = "papermc-repo"
url = "https://repo.papermc.io/repository/maven-public/"
}
}
dependencies {
compileOnly("com.velocitypowered:velocity-api:3.5.0-SNAPSHOT")
annotationProcessor("com.velocitypowered:velocity-api:3.5.0-SNAPSHOT")
}
tasks {
runVelocity {
// Configure the Velocity 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.
velocityVersion("3.5.0-SNAPSHOT")
}
}
def targetJavaVersion = 21
java {
toolchain.languageVersion = JavaLanguageVersion.of(targetJavaVersion)
}
tasks.withType(JavaCompile).configureEach {
options.encoding = 'UTF-8'
options.release.set(targetJavaVersion)
}
def templateSource = file('src/main/templates')
def templateDest = layout.buildDirectory.dir('generated/sources/templates')
def generateTemplates = tasks.register('generateTemplates', Copy) { task ->
def props = [
'version': project.version
]
task.inputs.properties props
task.from templateSource
task.into templateDest
task.expand props
}
sourceSets.main.java.srcDir(generateTemplates)
+8
View File
@@ -0,0 +1,8 @@
#
# 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.
#
@@ -0,0 +1,9 @@
#
# 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.
#
distributionUrl=https\://services.gradle.org/distributions/gradle-8.14.3-bin.zip
+9
View File
@@ -0,0 +1,9 @@
/*
* 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 = 'platform-velocity'
@@ -0,0 +1,32 @@
/*
* 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.velocity;
import com.google.inject.Inject;
import com.velocitypowered.api.event.proxy.ProxyInitializeEvent;
import com.velocitypowered.api.event.Subscribe;
import com.velocitypowered.api.plugin.Plugin;
import org.slf4j.Logger;
@Plugin(
id = "raycastedantiesp",
name = "RaycastedAntiESP",
version = BuildConstants.VERSION,
description = "Packet-based Anti-ESP plugin",
url = "https://cubi.games",
authors = {"_Cubicake"}
)
public class VeloRaycastedAntiESP {
@Inject private Logger logger;
@Subscribe
public void onProxyInitialization(ProxyInitializeEvent event) {
}
}
@@ -0,0 +1,15 @@
/*
* 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.velocity;
// The constants are replaced before compilation
public class BuildConstants {
public static final String VERSION = "${version}";
}
+9
View File
@@ -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 'platform-velocity'