Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

Let's fight X-Ray cheat with simple Math!

This simple plugin monitors players' mining activity and detects possible X-Ray cheeting based on statistical analysis. When a player mines significantly more valuable ores (like diamonds, gold, emeralds) compared to common blocks (like stone, coal), the plugin flags them for potential cheating. Thedetection is based on configurable thresholds, allowing server admins to customize sensitivity according to their needs. Used [LogBlock](https://www.spigotmc.org/resources/logblock.67333/) data to analyze mining patterns over time.
This simple plugin monitors players' mining activity and detects possible X-Ray cheeting based on statistical analysis. When a player mines significantly more valuable ores (like diamonds, gold, emeralds) compared to common blocks (like stone, coal), the plugin flags them for potential cheating. The detection is based on configurable thresholds, allowing server admins to customize sensitivity according to their needs. Used [LogBlock](https://www.spigotmc.org/resources/logblock.67333/) data to analyze mining patterns over time.

This plugin requires Java 21 or higher and is compatible with Minecraft server versions 1.20.x and above. Also, it supports both Paper and Spigot server implementations.

Expand Down
15 changes: 12 additions & 3 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

<groupId>me.drendov.xRayMonitor</groupId>
<artifactId>XRayMonitor</artifactId>
<version>1.1.0</version>
<version>1.1.1</version>
<packaging>jar</packaging>
<name>XRayMonitor</name>
<description>Let's fight X-Ray cheat with simple Math!</description>
Expand All @@ -17,17 +17,18 @@
</properties>

<dependencies>
<!-- Paper API (recommended over Spigot API) -->
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<version>1.21.9-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<!-- LogBlock - provided by server, do NOT shade -->
<dependency>
<groupId>de.diddiz</groupId>
<artifactId>logblock</artifactId>
<version>1.20.0.0-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<!-- bStats -->
<dependency>
Expand Down Expand Up @@ -59,7 +60,7 @@
</dependencies>

<repositories>
<!-- Paper API -->
<!-- Paper API (recommended over Spigot API) -->
<repository>
<id>papermc</id>
<url>https://repo.papermc.io/repository/maven-public/</url>
Expand All @@ -81,6 +82,14 @@
<id>logblock-repo</id>
<url>https://www.iani.de/nexus/content/repositories/snapshots/</url>
</repository>
<repository>
<id>bukkit-repo</id>
<url>http://repo.md-5.net/content/repositories/snapshots/</url>
</repository>
<repository>
<id>spigot-repo-new</id>
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
</repository>
</repositories>


Expand Down
134 changes: 67 additions & 67 deletions src/main/java/me/drendov/XRayMonitor/Listeners.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,11 @@ public void run() {
int count_diorite = 0;
int count_granite = 0;
int count_deepslate = 0;
int count_deepslate_bricks = 0;
int count_deepslate_tiles = 0;
int count_polished_deepslate = 0;
int count_chiseled_deepslate = 0;
int count_calcite = 0;
int count_blackstone = 0;

int diamond_count = 0;
Expand All @@ -67,8 +72,13 @@ public void run() {
count_diorite = Listeners.this.lb.oreLookup(playerName, "diorite", world, hours);
count_granite = Listeners.this.lb.oreLookup(playerName, "granite", world, hours);
count_deepslate = Listeners.this.lb.oreLookup(playerName, "deepslate", world, hours);
count_deepslate_bricks = Listeners.this.lb.oreLookup(playerName, "deepslate_bricks", world, hours);
count_deepslate_tiles = Listeners.this.lb.oreLookup(playerName, "deepslate_tiles", world, hours);
count_polished_deepslate = Listeners.this.lb.oreLookup(playerName, "polished_deepslate", world, hours);
count_chiseled_deepslate = Listeners.this.lb.oreLookup(playerName, "chiseled_deepslate", world, hours);
count_calcite = Listeners.this.lb.oreLookup(playerName, "calcite", world, hours);
count_blackstone = Listeners.this.lb.oreLookup(playerName, "blackstone", world, hours);
count_stones = count_stone + count_andesite + count_diorite + count_granite + count_deepslate + count_blackstone;
count_stones = count_stone + count_andesite + count_diorite + count_granite + count_deepslate + count_deepslate_bricks + count_deepslate_tiles + count_polished_deepslate + count_chiseled_deepslate + count_calcite + count_blackstone;

diamond_count = Listeners.this.lb.oreLookup(playerName, "diamond_ore", world, hours);
diamond_count += Listeners.this.lb.oreLookup(playerName, "deepslate_diamond_ore", world, hours);
Expand Down Expand Up @@ -211,10 +221,31 @@ public void run() {
}
}

private void notifyStaffOfOreBreak(String player, String message) {
for (Player staff : this.plugin.getServer().getOnlinePlayers()) {
if (staff.hasPermission("xcheck.receive")) {
staff.sendMessage(ChatColor.RED + "[XRayMonitor] " + ChatColor.AQUA + message);
}
}
}

private void checkAndNotifyOre(Material block, String configKey, String message,
Material... materials) {
if (this.plugin.getConfig().getBoolean(configKey)) {
for (Material material : materials) {
if (block == material) {
notifyStaffOfOreBreak(null, message);
return;
}
}
}
}

@EventHandler
public void onOreBreak(BlockBreakEvent event) {
String player = event.getPlayer().getName();
Material block = event.getBlock().getType();

if ((block != Material.DIAMOND_ORE) && (block != Material.DEEPSLATE_DIAMOND_ORE) &&
(block != Material.IRON_ORE) && (block != Material.DEEPSLATE_IRON_ORE) &&
(block != Material.COPPER_ORE) && (block != Material.DEEPSLATE_COPPER_ORE) &&
Expand All @@ -226,82 +257,51 @@ public void onOreBreak(BlockBreakEvent event) {
(block != Material.ANCIENT_DEBRIS) && (block != Material.SPAWNER) && (block != Material.MOSSY_COBBLESTONE)) {
return;
}
if ( ((block == Material.IRON_ORE) || (block == Material.DEEPSLATE_IRON_ORE)) && (this.plugin.getConfig().getBoolean("logOreBreaks.iron"))) {
for (Player staff : this.plugin.getServer().getOnlinePlayers()) {
if (staff.hasPermission("xcheck.receive")) {
staff.sendMessage(ChatColor.RED + "[XRayMonitor] " + ChatColor.AQUA + player + " has just mined an iron ore.");
}
}

// Check each ore type and notify staff
if ((block == Material.IRON_ORE || block == Material.DEEPSLATE_IRON_ORE) &&
this.plugin.getConfig().getBoolean("logOreBreaks.iron")) {
notifyStaffOfOreBreak(player, player + " has just mined an iron ore.");
}
if ( ((block == Material.COPPER_ORE) || (block == Material.DEEPSLATE_COPPER_ORE)) && (this.plugin.getConfig().getBoolean("logOreBreaks.copper"))) {
for (Player staff : this.plugin.getServer().getOnlinePlayers()) {
if (staff.hasPermission("xcheck.receive")) {
staff.sendMessage(ChatColor.RED + "[XRayMonitor] " + ChatColor.AQUA + player + " has just mined an iron ore.");
}
}
if ((block == Material.COPPER_ORE || block == Material.DEEPSLATE_COPPER_ORE) &&
this.plugin.getConfig().getBoolean("logOreBreaks.copper")) {
notifyStaffOfOreBreak(player, player + " has just mined a copper ore.");
}
if ( ((block == Material.COAL_ORE) || (block == Material.DEEPSLATE_COAL_ORE)) && (this.plugin.getConfig().getBoolean("logOreBreaks.coal"))) {
for (Player staff : this.plugin.getServer().getOnlinePlayers()) {
if (staff.hasPermission("xcheck.receive")) {
staff.sendMessage(ChatColor.RED + "[XRayMonitor] " + ChatColor.AQUA + player + " has just mined a coal ore.");
}
}
if ((block == Material.COAL_ORE || block == Material.DEEPSLATE_COAL_ORE) &&
this.plugin.getConfig().getBoolean("logOreBreaks.coal")) {
notifyStaffOfOreBreak(player, player + " has just mined a coal ore.");
}
if ( ((block == Material.REDSTONE_ORE) || (block == Material.DEEPSLATE_REDSTONE_ORE)) && (this.plugin.getConfig().getBoolean("logOreBreaks.redstone"))) {
for (Player staff : this.plugin.getServer().getOnlinePlayers()) {
if (staff.hasPermission("xcheck.receive")) {
staff.sendMessage(ChatColor.RED + "[XRayMonitor] " + ChatColor.AQUA + player + " has just mined a redstone ore.");
}
}
if ((block == Material.REDSTONE_ORE || block == Material.DEEPSLATE_REDSTONE_ORE) &&
this.plugin.getConfig().getBoolean("logOreBreaks.redstone")) {
notifyStaffOfOreBreak(player, player + " has just mined a redstone ore.");
}
if ( ((block == Material.GOLD_ORE) || (block == Material.DEEPSLATE_GOLD_ORE) || (block == Material.NETHER_GOLD_ORE)) && (this.plugin.getConfig().getBoolean("logOreBreaks.gold"))) {
for (Player staff : this.plugin.getServer().getOnlinePlayers()) {
if (staff.hasPermission("xcheck.receive")) {
staff.sendMessage(ChatColor.RED + "[XRayMonitor] " + ChatColor.AQUA + player + " has just mined a gold ore.");
}
}
if ((block == Material.GOLD_ORE || block == Material.DEEPSLATE_GOLD_ORE || block == Material.NETHER_GOLD_ORE) &&
this.plugin.getConfig().getBoolean("logOreBreaks.gold")) {
notifyStaffOfOreBreak(player, player + " has just mined a gold ore.");
}
if ( ((block == Material.LAPIS_ORE) || (block == Material.DEEPSLATE_LAPIS_ORE)) && (this.plugin.getConfig().getBoolean("logOreBreaks.lapis"))) {
for (Player staff : this.plugin.getServer().getOnlinePlayers()) {
if (staff.hasPermission("xcheck.receive")) {
staff.sendMessage(ChatColor.RED + "[XRayMonitor] " + ChatColor.AQUA + player + " has just mined a lapis ore.");
}
}
if ((block == Material.LAPIS_ORE || block == Material.DEEPSLATE_LAPIS_ORE) &&
this.plugin.getConfig().getBoolean("logOreBreaks.lapis")) {
notifyStaffOfOreBreak(player, player + " has just mined a lapis ore.");
}
if ( ((block == Material.EMERALD_ORE) || (block == Material.DEEPSLATE_EMERALD_ORE)) && (this.plugin.getConfig().getBoolean("logOreBreaks.emerald"))) {
for (Player staff : this.plugin.getServer().getOnlinePlayers()) {
if (staff.hasPermission("xcheck.receive")) {
staff.sendMessage(ChatColor.RED + "[XRayMonitor] " + ChatColor.AQUA + player + " has just mined a emerald ore.");
}
}
if ((block == Material.EMERALD_ORE || block == Material.DEEPSLATE_EMERALD_ORE) &&
this.plugin.getConfig().getBoolean("logOreBreaks.emerald")) {
notifyStaffOfOreBreak(player, player + " has just mined a emerald ore.");
}
if ((block == Material.ANCIENT_DEBRIS) && (this.plugin.getConfig().getBoolean("logOreBreaks.ancient_debris"))) {
for (Player staff : this.plugin.getServer().getOnlinePlayers()) {
if (staff.hasPermission("xcheck.receive")) {
staff.sendMessage(ChatColor.RED + "[XRayMonitor] " + ChatColor.AQUA + player + " has just mined a ancient_debris ore.");
}
}
if (block == Material.ANCIENT_DEBRIS &&
this.plugin.getConfig().getBoolean("logOreBreaks.ancient")) {
notifyStaffOfOreBreak(player, player + " has just mined an ancient debris.");
}
if ( ((block == Material.DIAMOND_ORE) || (block == Material.DEEPSLATE_DIAMOND_ORE)) && (this.plugin.getConfig().getBoolean("logOreBreaks.diamond"))) {
for (Player staff : this.plugin.getServer().getOnlinePlayers()) {
if (staff.hasPermission("xcheck.receive")) {
staff.sendMessage(ChatColor.RED + "[XRayMonitor] " + ChatColor.AQUA + player + " has just mined a diamond ore.");
}
}
if ((block == Material.DIAMOND_ORE || block == Material.DEEPSLATE_DIAMOND_ORE) &&
this.plugin.getConfig().getBoolean("logOreBreaks.diamond")) {
notifyStaffOfOreBreak(player, player + " has just mined a diamond ore.");
}
if ((block == Material.MOSSY_COBBLESTONE) && (this.plugin.getConfig().getBoolean("logOreBreaks.mossy"))) {
for (Player staff : this.plugin.getServer().getOnlinePlayers()) {
if (staff.hasPermission("xcheck.receive")) {
staff.sendMessage(ChatColor.RED + "[XRayMonitor] " + ChatColor.AQUA + player + " has just mined a mossy cobblestone block.");
}
}
if (block == Material.MOSSY_COBBLESTONE &&
this.plugin.getConfig().getBoolean("logOreBreaks.mossy")) {
notifyStaffOfOreBreak(player, player + " has just mined a mossy cobblestone block.");
}
if ((block == Material.SPAWNER) && (this.plugin.getConfig().getBoolean("logOreBreaks.spawners"))) {
for (Player staff : this.plugin.getServer().getOnlinePlayers()) {
if (staff.hasPermission("xcheck.receive")) {
staff.sendMessage(ChatColor.RED + "[XRayMonitor] " + ChatColor.AQUA + player + " has just mined a monster spawner.");
}
}
if (block == Material.SPAWNER &&
this.plugin.getConfig().getBoolean("logOreBreaks.spawner")) {
notifyStaffOfOreBreak(player, player + " has just mined a spawner.");
}
}
}
Loading