Compare commits

..
5 Commits
8 changed files with 118 additions and 20 deletions

No files matched your search

+1
View File
@@ -0,0 +1 @@
.gitea/CODEOWNERS linguist-detectable=false
+3
View File
@@ -0,0 +1,3 @@
# Pull requests request review from the eligible staff team(s).
# One approval from either an Admin or Developer satisfies branch protection.
* @trueog/Admins @trueog/Developers
+1 -4
View File
@@ -1,6 +1,4 @@
Latest version: v1.2.2
The latest version can currently only be found on Modrinth https://modrinth.com/plugin/raycasted-entity-occlusion/
RaycastedAntiESP-OG is an MIT Licensed fork of [RaycastedAntiESP](https://github.com/Cubicake/RaycastedAntiESP) maintained by [TrueOG Network](https://trueog.net) for Purpur 1.19.4.
This is a simple server-side plugin for PaperMC (May also work with Spigot, this is untested) that hides/culls entities from players if they do not have line-of-sight. All raycasts are run async to reduce performance impact.
Use cases:
@@ -32,7 +30,6 @@ MoreChecks toggles between two raycasting modes. By default (MoreChecks = false)
OccludePlayers toggles whether players will be checked. Enabling this prevents ESP mods from revealing players.
Known issues:
- Due to the nature of the plugin, there will be a short delay once an entity should be visible before it appears, causing it to appear like it "popped" into view. This issue is partially resolved by turning MoreChecks on
- If OccludePlayers is set to true any occluded players will be removed from tablist
@@ -19,7 +19,8 @@ public class CheckEntityVisibility {
private int raycastRadius;
private int searchRadius;
private boolean moreChecks;
private boolean occludePlayers;
private boolean cullPlayers;
private boolean sneakCull;
private int recheckInterval;
private int tickCounter = 0;
//ConcurrentHashMap allows for Thread-safe operations. Don't use regular hashmaps
@@ -32,7 +33,8 @@ public class CheckEntityVisibility {
this.raycastRadius = plugin.raycastRadius;
this.searchRadius = plugin.searchRadius;
this.moreChecks = plugin.moreChecks;
this.occludePlayers = plugin.occludePlayers;
this.cullPlayers = plugin.cullPlayers;
this.sneakCull = plugin.sneakCull;
this.recheckInterval = plugin.recheckInterval;
new BukkitRunnable() {
@Override
@@ -59,7 +61,8 @@ public class CheckEntityVisibility {
this.raycastRadius = plugin.raycastRadius;
this.searchRadius = plugin.searchRadius;
this.moreChecks = plugin.moreChecks;
this.occludePlayers = plugin.occludePlayers;
this.cullPlayers = plugin.cullPlayers;
this.sneakCull = plugin.sneakCull;
this.recheckInterval = plugin.recheckInterval;
}
@@ -71,7 +74,10 @@ public class CheckEntityVisibility {
if (world != player.getWorld()) {
return;
}
if (entity instanceof Player && !occludePlayers) {
if (entity instanceof Player && !cullPlayers) {
continue;
}
if (entity instanceof Player p && sneakCull && !p.isSneaking()) {
continue;
}
double distance = player.getLocation().distance(entity.getLocation());
@@ -134,12 +140,14 @@ public class CheckEntityVisibility {
}
private void addEntityToShow(Player player, Entity entity) {
public void addEntityToShow(Player player, Entity entity) {
entitiesToShow.computeIfAbsent(player, k -> ConcurrentHashMap.newKeySet()).add(entity);
entitiesToHide.computeIfAbsent(player, k -> ConcurrentHashMap.newKeySet()).remove(entity);
}
private void addEntityToHide(Player player, Entity entity) {
public void addEntityToHide(Player player, Entity entity) {
entitiesToHide.computeIfAbsent(player, k -> ConcurrentHashMap.newKeySet()).add(entity);
entitiesToShow.computeIfAbsent(player, k -> ConcurrentHashMap.newKeySet()).remove(entity);
}
@@ -25,7 +25,7 @@ public class CommandHandler implements CommandExecutor {
sender.sendMessage("RaycastRadius: " + plugin.raycastRadius);
sender.sendMessage("SearchRadius: " + plugin.searchRadius);
sender.sendMessage("MoreChecks: " + plugin.moreChecks);
sender.sendMessage("OccludePlayers: " + plugin.occludePlayers);
sender.sendMessage("CullPlayers: " + plugin.cullPlayers);
sender.sendMessage("RecheckInterval: " + plugin.recheckInterval);
return true;
}
@@ -9,11 +9,12 @@ public final class RaycastedEntityOcclusion extends JavaPlugin {
public int raycastRadius;
public int searchRadius;
public boolean moreChecks;
public boolean occludePlayers;
public boolean cullPlayers;
public int recheckInterval;
public int tickCounter = 0;
public boolean sneakCull;
public RaycastedEntityOcclusion plugin = this;
public CheckEntityVisibility checkEntityVisibility;
public SneakListener sneakListener;
@Override
public void onEnable() {
@@ -23,8 +24,10 @@ public final class RaycastedEntityOcclusion extends JavaPlugin {
new Metrics(this, pluginId);
checkEntityVisibility = new CheckEntityVisibility(plugin);
sneakListener = new SneakListener(plugin);
getCommand("raycastedentityocclusion").setExecutor(new CommandHandler(plugin));
getServer().getPluginManager().registerEvents(sneakListener, plugin);
}
@Override
@@ -39,21 +42,38 @@ public final class RaycastedEntityOcclusion extends JavaPlugin {
FileConfiguration config = getConfig();
alwaysShowRadius = config.getInt("AlwaysShowRadius", 4);
raycastRadius = config.getInt("RaycastRadius", 64);
searchRadius = config.getInt("SearchRadius", 72);
raycastRadius = config.getInt("RaycastRadius", 48);
searchRadius = config.getInt("SearchRadius", 48);
moreChecks = config.getBoolean("MoreChecks", false);
occludePlayers = config.getBoolean("OccludePlayers", false);
recheckInterval = config.getInt("RecheckInterval", 10);
cullPlayers = config.getBoolean("CullPlayers", false);
sneakCull = config.getBoolean("OnlyCullSneakingPlayers", false);
recheckInterval = config.getInt("RecheckInterval", 20);
// This ensures that if the config is not set, it will be set to the default value
if (alwaysShowRadius == 4) config.set("AlwaysShowRadius", 4);
if (raycastRadius == 48) config.set("RaycastRadius", 48);
if (searchRadius == 48) config.set("SearchRadius", 48);
if (!moreChecks) config.set("MoreChecks", false);
if (!cullPlayers) config.set("CullPlayers", false);
if (!sneakCull) config.set("OnlyCullSneakingPlayers", false);
if (recheckInterval == 20) config.set("RecheckInterval", 20);
getLogger().info("AlwaysShowRadius: " + alwaysShowRadius);
getLogger().info("RaycastRadius: " + raycastRadius);
getLogger().info("SearchRadius: " + searchRadius);
getLogger().info("MoreChecks: " + moreChecks);
getLogger().info("OccludePlayers: " + occludePlayers);
getLogger().info("CullPlayers: " + cullPlayers);
getLogger().info("OnlyCullSneakingPlayers: " + sneakCull);
getLogger().info("RecheckInterval: " + recheckInterval);
saveConfig();
}
public CheckEntityVisibility getCheckEntityVisibility() {
return checkEntityVisibility;
}
public SneakListener getSneakListener() {
return sneakListener;
}
}
@@ -0,0 +1,68 @@
package games.cubi.raycastedEntityOcclusion;
import jdk.jfr.Label;
import org.bukkit.Location;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import java.util.List;
public class SneakListener implements Listener {
RaycastedEntityOcclusion plugin;
public SneakListener(RaycastedEntityOcclusion plugin) {
this.plugin = plugin;
}
@EventHandler
public void onSneak(org.bukkit.event.player.PlayerToggleSneakEvent event) {
if (plugin.sneakCull) {
Player player = event.getPlayer();
int searchRadius = plugin.searchRadius;
List<Player> nearbyPlayers = player.getNearbyEntities(searchRadius, searchRadius, searchRadius).stream()
.filter(entity -> entity instanceof Player)
.map(entity -> (Player) entity)
.toList();
for (Player nearbyPlayer : nearbyPlayers) {
if (plugin.moreChecks){
double height = nearbyPlayer.getHeight();
double width = player.getWidth();
Location checkOne = player.getLocation().add(0, height - 0.01, 0);
Location checkTwo = player.getLocation().add(0, 0.01, 0);
Location checkThree = player.getLocation().add(width / 2, height / 2, 0);
Location checkFour = player.getLocation().add(-width / 2, height / 2, 0);
CheckEntityVisibility checkEntityVisibility = plugin.getCheckEntityVisibility();
Raycast.asyncRaycast(nearbyPlayer.getEyeLocation(), checkOne, plugin, canSeePlayer -> {
if (canSeePlayer) {
checkEntityVisibility.addEntityToShow(nearbyPlayer, player);
} else {
Raycast.asyncRaycast(player.getEyeLocation(), checkTwo, plugin, canSeePlayer2 -> {
if (canSeePlayer2) checkEntityVisibility.addEntityToShow(nearbyPlayer, player);
else {
Raycast.asyncRaycast(player.getEyeLocation(), checkThree, plugin, canSeePlayer3 -> {
if (canSeePlayer3) checkEntityVisibility.addEntityToShow(nearbyPlayer, player);
else {
Raycast.asyncRaycast(player.getEyeLocation(), checkFour, plugin, canSeePlayer4 -> {
if (canSeePlayer4) checkEntityVisibility.addEntityToShow(nearbyPlayer, player);
else checkEntityVisibility.addEntityToHide(nearbyPlayer, player);
});
}
});
}
});
}
});
}
else {
Raycast.asyncRaycast(nearbyPlayer.getEyeLocation(), player.getEyeLocation(), plugin, canSeePlayer -> {
if (canSeePlayer) {
plugin.checkEntityVisibility.addEntityToShow(nearbyPlayer, player);
} else {
plugin.checkEntityVisibility.addEntityToHide(nearbyPlayer, player);
}
});
}
}
}
}
}
+3 -2
View File
@@ -1,6 +1,7 @@
AlwaysShowRadius: 8
RaycastRadius: 48
SearchRadius: 52
SearchRadius: 48
MoreChecks: false #This will enable more raycasts per mob, increasing performance hit but showing partially visible mobs
OccludePlayers: false #Enabling this will make the plugin cull hidden players alongside entities
CullPlayers: false #Enabling this will make the plugin cull hidden players alongside entities
OnlyCullSneakingPlayers: false #Enabling this will make the plugin only cull hidden players that are sneaking. Note that CullPlayers must also be true.
RecheckInterval: 20 #Time in ticks between rechecking visible mobs