Create a Paper plugin named AntiDupeDetector.
Package: me.patplays2.antidupe
Commands:
- /antidupe reload
Detect and log:
- /openinv check <player>
- /openinv
- /inv
- /invsee
- /offlineinv
Features:
- Staff alerts (permission antidupe.alerts)
- Console logging
- File logging
- Discord webhook support
- Configurable messages in config.yml
Target:
Paper 26.1.2
Create the Gradle project and Paper plugin metadata for Paper 26.1.2.
Implement
/antidupe reloadwith permission-protected configurable messages.Add detection for the requested inventory commands with staff alerts.
Add configurable console, file, and Discord webhook logging.
Created the AntiDupeDetector Paper plugin project with:
/antidupe reloadand permission handlingDetection for
/openinv,/openinv check <player>,/inv,/invsee, and/offlineinvStaff alerts via
antidupe.alertsConfigurable console and file logging
Optional Discord webhook notifications
Configurable messages in
config.ymlPaper 26.1.2 Gradle configuration
Java package
me.patplays2.antidupe
Alr i love it but could we make the dc webhook cleaner also wanna add auto kick when they do it (if enabled in config)
Clean up Discord webhook formatting with a structured, readable embed-style payload.
Add configurable automatic kicking for players who trigger a detected command.
The detector currently passes only the sender name into logging, so I’m wiring the actual Player through the detection path to support a synchronous kick. The webhook will use a Discord embed with separate player, command, target, and type fields instead of a dense text block.
Implemented both updates:
Cleaner Discord webhook
Uses a structured Discord embed.
Separate fields for player, command, target, and detection type.
Configurable title, description, color, and footer.
Includes a timestamp.
Automatic kicking
Added
auto-kick.enabledtoconfig.yml.When enabled, players are kicked immediately after triggering a detected command.
Kick message is configurable through
messages.kick.Settings apply after
/antidupe reload.
Example configuration:
auto-kick:
enabled: true
messages:
kick: '&cYou have been removed from the server.'
Discord embed settings:
discord:
enabled: true
webhook-url: 'YOUR_WEBHOOK_URL'
username: AntiDupeDetector
embed:
title: 'AntiDupe Detection'
description: 'An inventory command was detected.'
color: 15158332
footer: 'AntiDupeDetector'
Give me the .jar
I can’t attach a compiled .jar from this workspace because Gradle/Javac and a Gradle wrapper aren’t available here. The complete plugin source is ready to build.
From the project directory, run:
gradle build
The jar will be generated at:
build/libs/AntiDupeDetector-1.0.0.jar
Copy it into your server’s plugins/ folder and restart the server.
gradle build
I can’t execute gradle build in this workspace because Gradle/Javac aren’t available here.
Run this from the project directory:
gradle build
The compiled plugin will be at:
build/libs/AntiDupeDetector-1.0.0.jar
Where do I find that
The .jar does not exist yet because the project has not been compiled.
Run gradle build from the folder containing build.gradle. After it succeeds, find it here:
AntiDupeDetector/
└── build/
└── libs/
└── AntiDupeDetector-1.0.0.jar
Then copy the JAR into:
your-minecraft-server/plugins/
If you’re using a terminal, navigate to the project folder first:
cd path/to/AntiDupeDetector
gradle build
If gradle is not recognized, install Gradle or use IntelliJ IDEA’s Gradle panel to run the build task.
Give me source code so I can continue my self
The complete source is below. Create this folder structure:
AntiDupeDetector/
├── build.gradle
├── settings.gradle
└── src/
└── main/
├── java/
│ └── me/patplays2/antidupe/
│ ├── AntiDupeDetector.java
│ └── DetectionLogger.java
└── resources/
├── plugin.yml
└── config.yml
build.gradle
plugins {
id 'java'
}
group = 'me.patplays2'
version = '1.0.0'
java {
toolchain {
languageVersion = JavaLanguageVersion.of(21)
}
}
repositories {
mavenCentral()
maven { url = uri('https://repo.papermc.io/repository/maven-public/') }
}
dependencies {
compileOnly 'io.papermc.paper:paper-api:26.1.2-R0.1-SNAPSHOT'
}
tasks.withType(JavaCompile).configureEach {
options.encoding = 'UTF-8'
}
settings.gradle
pluginManagement {
repositories {
gradlePluginPortal()
}
}
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
mavenCentral()
maven { url = uri("https://repo.papermc.io/repository/maven-public/") }
}
}
rootProject.name = "AntiDupeDetector"
src/main/resources/plugin.yml
name: AntiDupeDetector
version: '1.0.0'
main: me.patplays2.antidupe.AntiDupeDetector
api-version: '26.1'
description: Detects and logs inventory access commands commonly used by dupe tools.
author: patplays2
commands:
antidupe:
description: Manage AntiDupeDetector.
usage: /antidupe reload
permission: antidupe.reload
permissions:
antidupe.reload:
description: Reload AntiDupeDetector configuration.
default: op
antidupe.alerts:
description: Receive AntiDupeDetector staff alerts.
default: op
src/main/resources/config.yml
messages:
reload-success: '&aAntiDupeDetector configuration reloaded.'
no-permission: '&cYou do not have permission to use this command.'
usage: '&eUsage: /antidupe reload'
alert: '&c[AntiDupe] &f%sender% used &e%command% &7(target: %target%)'
kick: '&cYou have been removed from the server.'
auto-kick:
enabled: false
logging:
console: true
file: true
file-name: detections.log
discord:
enabled: false
webhook-url: ''
username: AntiDupeDetector
embed:
title: 'AntiDupe Detection'
description: 'An inventory command was detected.'
color: 15158332
footer: 'AntiDupeDetector'
src/main/java/me/patplays2/antidupe/AntiDupeDetector.java
package me.patplays2.antidupe;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
import org.bukkit.plugin.java.JavaPlugin;
public final class AntiDupeDetector extends JavaPlugin implements Listener {
private DetectionLogger detectionLogger;
@Override
public void onEnable() {
saveDefaultConfig();
this.detectionLogger = new DetectionLogger(this);
getServer().getPluginManager().registerEvents(this, this);
getLogger().info("AntiDupeDetector enabled.");
}
@Override
public void onDisable() {
getLogger().info("AntiDupeDetector disabled.");
}
@Override
public boolean onCommand(
CommandSender sender,
Command command,
String label,
String[] args
) {
if (!command.getName().equalsIgnoreCase("antidupe")) {
return false;
}
if (!sender.hasPermission("antidupe.reload")) {
sender.sendMessage(message("messages.no-permission"));
return true;
}
if (args.length == 1 && args[0].equalsIgnoreCase("reload")) {
reloadConfig();
sender.sendMessage(message("messages.reload-success"));
return true;
}
sender.sendMessage(message("messages.usage"));
return true;
}
@EventHandler(priority = EventPriority.MONITOR)
public void onPlayerCommand(PlayerCommandPreprocessEvent event) {
detectionLogger.processCommand(
event.getPlayer(),
event.getMessage()
);
}
String message(String path) {
String configured = getConfig().getString(path, "");
return ChatColor.translateAlternateColorCodes('&', configured);
}
}
src/main/java/me/patplays2/antidupe/DetectionLogger.java
package me.patplays2.antidupe;
import java.io.IOException;
import java.net.HttpURLConnection;
import java.net.URI;
import java.net.URISyntaxException;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.StandardOpenOption;
import java.time.OffsetDateTime;
import java.time.format.DateTimeFormatter;
import java.util.Locale;
import java.util.Set;
import java.util.regex.Pattern;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.entity.Player;
final class DetectionLogger {
private static final Set<String> DETECTED_COMMANDS = Set.of(
"openinv",
"inv",
"invsee",
"offlineinv"
);
private static final Pattern WHITESPACE = Pattern.compile("\\s+");
private final AntiDupeDetector plugin;
DetectionLogger(AntiDupeDetector plugin) {
this.plugin = plugin;
}
void processCommand(Player player, String rawCommand) {
Detection detection = createDetection(
player.getName(),
rawCommand,
"player-command"
);
if (detection != null) {
log(detection);
if (plugin.getConfig().getBoolean("auto-kick.enabled", false)) {
player.kickPlayer(plugin.message("messages.kick"));
}
}
}
private Detection createDetection(
String sender,
String rawCommand,
String type
) {
if (rawCommand == null || rawCommand.isBlank()) {
return null;
}
String commandLine = rawCommand.charAt(0) == '/'
? rawCommand.substring(1)
: rawCommand;
String[] parts = WHITESPACE.split(commandLine.trim(), 2);
if (parts.length == 0) {
return null;
}
String commandName = parts[0].toLowerCase(Locale.ROOT);
int namespaceSeparator = commandName.indexOf(':');
if (namespaceSeparator >= 0) {
commandName = commandName.substring(namespaceSeparator + 1);
}
if (!DETECTED_COMMANDS.contains(commandName)) {
return null;
}
String target = "none";
if (commandName.equals("openinv") && parts.length == 2) {
String[] arguments = WHITESPACE.split(parts[1].trim());
if (arguments.length >= 2
&& arguments[0].equalsIgnoreCase("check")) {
target = arguments[1];
}
}
return new Detection(sender, rawCommand, target, type);
}
private void log(Detection detection) {
String alert = format(
plugin.getConfig().getString("messages.alert", ""),
detection
);
for (Player player : Bukkit.getOnlinePlayers()) {
if (player.hasPermission("antidupe.alerts")
&& !alert.isEmpty()) {
player.sendMessage(
ChatColor.translateAlternateColorCodes('&', alert)
);
}
}
boolean consoleLogging = plugin.getConfig().getBoolean(
"logging.console",
true
);
boolean fileLogging = plugin.getConfig().getBoolean(
"logging.file",
true
);
boolean discordLogging = plugin.getConfig().getBoolean(
"discord.enabled",
false
);
String fileName = plugin.getConfig().getString(
"logging.file-name",
"detections.log"
);
String discordUrl = plugin.getConfig().getString(
"discord.webhook-url",
""
);
String discordUsername = plugin.getConfig().getString(
"discord.username",
"AntiDupeDetector"
);
String timestamp = OffsetDateTime.now().format(
DateTimeFormatter.ISO_OFFSET_DATE_TIME
);
String logLine = timestamp
+ " | " + detection.type()
+ " | sender=" + detection.sender()
+ " | command=" + detection.command()
+ " | target=" + detection.target();
if (consoleLogging) {
plugin.getLogger().warning(logLine);
}
if (fileLogging
|| (discordLogging && !discordUrl.isBlank())) {
Bukkit.getScheduler().runTaskAsynchronously(
plugin,
() -> {
if (fileLogging) {
appendToFile(fileName, logLine);
}
if (discordLogging && !discordUrl.isBlank()) {
sendWebhook(
discordUrl,
discordUsername,
detection,
timestamp
);
}
}
);
}
}
private void appendToFile(String configuredName, String line) {
String fileName = configuredName == null
|| configuredName.isBlank()
? "detections.log"
: configuredName;
Path file = plugin.getDataFolder()
.toPath()
.resolve(fileName)
.normalize();
Path dataFolder = plugin.getDataFolder()
.toPath()
.toAbsolutePath()
.normalize();
if (!file.toAbsolutePath().startsWith(dataFolder)) {
plugin.getLogger().warning(
"Configured detection log file must be inside "
+ "the plugin data folder."
);
return;
}
try {
Files.createDirectories(file.getParent());
Files.writeString(
file,
line + System.lineSeparator(),
StandardCharsets.UTF_8,
StandardOpenOption.CREATE,
StandardOpenOption.WRITE,
StandardOpenOption.APPEND
);
} catch (IOException exception) {
plugin.getLogger().warning(
"Could not write detection log: "
+ exception.getMessage()
);
}
}
private void sendWebhook(
String configuredUrl,
String username,
Detection detection,
String timestamp
) {
HttpURLConnection connection = null;
try {
URI uri = new URI(configuredUrl);
if (!uri.getScheme().equalsIgnoreCase("http")
&& !uri.getScheme().equalsIgnoreCase("https")) {
plugin.getLogger().warning(
"Discord webhook URL must use HTTP or HTTPS."
);
return;
}
connection = (HttpURLConnection) uri.toURL().openConnection();
connection.setRequestMethod("POST");
connection.setConnectTimeout(5000);
connection.setReadTimeout(5000);
connection.setDoOutput(true);
connection.setRequestProperty(
"Content-Type",
"application/json; charset=UTF-8"
);
String title = format(
plugin.getConfig().getString(
"discord.embed.title",
"AntiDupe Detection"
),
detection
);
String description = format(
plugin.getConfig().getString(
"discord.embed.description",
"An inventory command was detected."
),
detection
);
String footer = format(
plugin.getConfig().getString(
"discord.embed.footer",
"AntiDupeDetector"
),
detection
);
int color = plugin.getConfig().getInt(
"discord.embed.color",
15158332
);
String payload = "{\"username\":\""
+ jsonEscape(username)
+ "\",\"embeds\":[{"
+ "\"title\":\""
+ jsonEscape(title)
+ "\","
+ "\"description\":\""
+ jsonEscape(description)
+ "\","
+ "\"color\":"
+ color
+ ","
+ "\"fields\":["
+ fieldJson(
"Player",
detection.sender(),
true
)
+ ","
+ fieldJson(
"Command",
detection.command(),
true
)
+ ","
+ fieldJson(
"Target",
detection.target(),
true
)
+ ","
+ fieldJson(
"Type",
detection.type(),
true
)
+ "],"
+ "\"timestamp\":\""
+ jsonEscape(timestamp)
+ "\","
+ "\"footer\":{\"text\":\""
+ jsonEscape(footer)
+ "\"}"
+ "}]}";
try (var output = connection.getOutputStream()) {
output.write(payload.getBytes(StandardCharsets.UTF_8));
}
int status = connection.getResponseCode();
if (status < 200 || status >= 300) {
plugin.getLogger().warning(
"Discord webhook returned HTTP "
+ status
+ "."
);
}
} catch (URISyntaxException | IOException exception) {
plugin.getLogger().warning(
"Could not send Discord webhook: "
+ exception.getMessage()
);
} finally {
if (connection != null) {
connection.disconnect();
}
}
}
private String fieldJson(
String name,
String value,
boolean inline
) {
return "{\"name\":\""
+ jsonEscape(name)
+ "\",\"value\":\""
+ jsonEscape(value)
+ "\",\"inline\":"
+ inline
+ "}";
}
private String format(String template, Detection detection) {
if (template == null) {
return "";
}
return template
.replace("%sender%", detection.sender())
.replace("%player%", detection.sender())
.replace("%command%", detection.command())
.replace("%target%", detection.target())
.replace("%type%", detection.type());
}
private String jsonEscape(String value) {
if (value == null) {
return "";
}
return value
.replace("\\", "\\\\")
.replace("\"", "\\\"")
.replace("\r", "\\r")
.replace("\n", "\\n")
.replace("\t", "\\t");
}
private record Detection(
String sender,
String command,
String target,
String type
) {
}
}
To build it, install Java 21 and Gradle, then run this inside the AntiDupeDetector folder:
gradle build
The compiled plugin will be located at:
build/libs/AntiDupeDetector-1.0.0.jar
package me.patplays2.antidupe;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
import org.bukkit.plugin.java.JavaPlugin;
public final class AntiDupeDetector extends JavaPlugin implements Listener {
private DetectionLogger detectionLogger;
@Override
public void onEnable() {
saveDefaultConfig();
this.detectionLogger = new DetectionLogger(this);
getServer().getPluginManager().registerEvents(this, this);
getLogger().info("AntiDupeDetector enabled.");
}
@Override
public void onDisable() {
getLogger().info("AntiDupeDetector disabled.");
}
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (!command.getName().equalsIgnoreCase("antidupe")) {
return false;
}
if (!sender.hasPermission("antidupe.reload")) {
sender.sendMessage(message("messages.no-permission"));
return true;
}
if (args.length == 1 && args[0].equalsIgnoreCase("reload")) {
reloadConfig();
sender.sendMessage(message("messages.reload-success"));
return true;
}
sender.sendMessage(message("messages.usage"));
return true;
}
@EventHandler(priority = EventPriority.MONITOR)
public void onPlayerCommand(PlayerCommandPreprocessEvent event) {
detectionLogger.processCommand(event.getPlayer(), event.getMessage());
}
String message(String path) {
String configured = getConfig().getString(path, "");
return ChatColor.translateAlternateColorCodes('&', configured);
}
}