Create a Minecraft AntiCheat plugin named "ZenAC" with package me.zen.zenac, using Java 21 and supporting Minecraft 1.21+. The plugin must be compatible with Paper, Spigot, and Folia servers.
This is an AI-powered anti-cheat where the admin configures AI API keys (OpenAI, Google Gemini, Anthropic Claude, or custom endpoints) in config.yml. The plugin sends player actions to the AI for real-time analysis and cheat detection, with support for multiple API keys for load balancing and fallback.
=== ARCHITECTURE ===
me.zen.zenac/ ├── ZenAC.java (main plugin class) ├── api/ │ ├── AIProvider.java (interface for AI providers) │ ├── OpenAIProvider.java │ ├── GeminiProvider.java │ ├── ClaudeProvider.java │ ├── CustomAPIProvider.java │ ├── APIKeyManager.java (manages multiple keys) │ └── LoadBalancer.java (distributes requests) ├── monitor/ │ ├── ActionCollector.java (collects player actions) │ ├── ActionBuffer.java (buffers actions before sending) │ ├── BatchProcessor.java (processes and sends batches to AI) │ └── AnalysisCache.java (caches AI results) ├── action/ │ ├── ActionType.java (enum: MOVE, ATTACK, BLOCK_PLACE, etc.) │ ├── GameAction.java (action data structure) │ └── ActionSerializer.java (converts actions to JSON) ├── learning/ │ ├── FalsePositiveLearner.java (learns from false positives) │ ├── PromptUpdater.java (updates AI prompt with feedback) │ └── FeedbackCollector.java (stores false positive cases) ├── integration/ │ ├── LiteBansHook.java (auto-ban integration) │ ├── LuckPermsHook.java (rank/suspect tag integration) │ ├── PlaceholderAPIHook.java (provides placeholders) │ └── VaultHook.java (fine system) ├── check/ │ ├── AICheck.java (main AI analysis check) │ ├── MovementCheck.java (fallback movement checks) │ ├── CombatCheck.java (fallback combat checks) │ └── PlayerCheck.java (fallback player checks) ├── alert/ │ └── AlertManager.java (in-game alerts) ├── commands/ │ └── ZenACCommand.java (all plugin commands) └── utils/ ├── HttpUtils.java (HTTP requests to AI APIs) ├── RateLimiter.java (prevents spam) └── ConfigManager.java (handles configuration)
=== CORE FEATURES ===
- MULTIPLE AI API SUPPORT (admin configured):
- OpenAI (GPT-4, GPT-3.5) - Google Gemini - Anthropic Claude - Custom API endpoint (any JSON-compatible API)
- AUTO-LEARNING FROM FALSE POSITIVES:
- Admin command: /zenac false <player> marks a false positive - Stores the player's last 30 seconds of actions - AI automatically adjusts detection thresholds for that check type - False positive cases are added to the prompt to prevent recurrence - Command: /zenac feedback list shows all recorded false positives - Command: /zenac feedback clear clears feedback data - Data saved to false_positives.yml
- PLUGIN INTEGRATIONS:
- LiteBans / AdvancedBan: * Auto-ban when AI confidence > 0.95 * Command: /zenac ban <player> bans with AI evidence - LuckPerms: * Auto-assign "suspect" tag to players with high violations * Temporary rank demotion configurable - PlaceholderAPI: * Placeholders: %zenac_violations%, %zenac_status% - Vault: * Fine players instead of banning (configurable amount per cheat type)
- MULTI-API KEY MANAGEMENT:
- Load balancing: round-robin, least-used - Automatic fallback when a key hits rate limit or fails - Quota tracking per API key - Command: /zenac stats shows quota remaining and request counts
- PLAYER ACTION COLLECTION:
- Collects actions in real-time: * Movement: position, speed, direction, jumping, falling * Combat: target, distance, damage, crit, knockback * Block actions: place, break, block type, time * Item usage: item type, right/left click * Damage taken: source, amount, type - Each action includes timestamp, location, and world
- AI ANALYSIS PROCESSING:
- Batches actions (5-10 per batch) to reduce API calls - Sends every 2-3 seconds or when batch is full - Prompt template with embedded false positive feedback:
# ZenAC Configuration
ai:
enabled: true
provider: openai # openai, gemini, claude, custom
timeout: 5000 # milliseconds
# Multiple API keys for load balancing
api_keys:
openai:
- key: "sk-xxxxx1"
quota_limit: 100000 # tokens
- key: "sk-xxxxx2"
quota_limit: 100000
gemini:
- key: "AIzaSyxxxxx1"
- key: "AIzaSyxxxxx2"
claude:
- key: "sk-ant-xxxxx1"
custom:
url: "https://your-api.com/analyze"
headers:
Authorization: "Bearer token"
load_balancing: round_robin # round_robin, least_used
fallback_to_rule: true
batch:
size: 5 # actions per batch
interval: 3 # seconds between batches
# False Positive Learning
false_positive:
enabled: true
auto_adjust_threshold: true
save_path: "plugins/ZenAC/false_positives.yml"
# Plugin Integrations
integration:
LiteBans:
enabled: true
auto_ban: true
ban_threshold: 0.95
ban_reason: "Cheat detected by ZenAC AI"
LuckPerms:
enabled: true
suspect_tag: "suspect"
rank_demote_on_violations: 5
PlaceholderAPI:
enabled: true
Vault:
enabled: true
fine_amount: 1000
fine_on_violations: 3
# Action Collection
action_collection:
max_actions_per_player: 50 # stored actions before sending
send_interval: 3 # seconds
include:
- movement
- combat
- block_place
- block_break
- item_use
# Detection
detection:
confidence_threshold:
warn: 0.7
kick: 0.85
ban: 0.95
auto_punish: false # if false, only alerts
max_violations_before_ban: 10 # cumulative violations count
# Rate Limit
rate_limit:
requests_per_player_per_minute: 12
requests_global_per_minute: 100
# Alerts
alerts:
in_game: true
alert_format: "&c[ZenAC] &f{player} &7failed &c{check} &7(Confidence: {confidence}%)"
alert_delay: 5 # seconds between alerts for same player
# Logging
logging:
log_file: "logs/zenac.log"
log_actions: false # warning: can be large
log_api_calls: true
log_punishments: true
# Database
database:
type: sqlite # sqlite or mysql
mysql:
host: localhost
port: 3306
database: zenac
username: root
password: ""
- RESULT HANDLING:
- Confidence ≥ 0.7 → in-game alert - Confidence ≥ 0.85 → auto-kick (configurable) - Confidence ≥ 0.95 → auto-ban via LiteBans (configurable) - Results cached for 5 minutes to avoid duplicate API calls
- FALLBACK MECHANISM:
- If AI API fails to respond → use rule-based checks - If all API keys hit quota → disable AI mode, use rule-based - Admin receives console notification when fallback activates
- RATE LIMITING:
- Per player: max 1 request every 5 seconds - Global: max 100 requests per minute (configurable) - Prevents API abuse and quota exhaustion
- COMMANDS & PERMISSIONS:
Admin commands:
/zenac reload - Reload config/zenac stats - Show API statistics (quota, requests, detections)/zenac test <player> - Test AI on a player's recent actions/zenac false <player> - Mark as false positive (AI learns)/zenac feedback list - List all false positive cases/zenac feedback clear - Clear feedback data/zenac toggle <player> - Enable/disable AI monitoring for a player/zenac queue - Show pending API request queue/zenac ban <player> - Ban player with AI evidence
Player commands:
/zenac - Show plugin info and personal stats
Permissions:
zenac.admin - All admin commandszenac.alerts - Receive in-game alerts
=== CONFIGURATION (config.yml) ===
You are a Minecraft cheat detection expert.
Analyze this player's action sequence from the last [X] seconds:
[JSON actions]
Return JSON response:
{
"is_cheating": true/false,
"cheat_type": "fly/speed/killaura/reach/autoclicker/scaffold/timer/none",
"confidence": 0.0-1.0,
"reason": "detailed explanation",
"evidence": ["evidence 1", "evidence 2"]
}
=== TECHNICAL REQUIREMENTS ===
· Java 21 · Minecraft 1.21+ (Paper, Spigot, Folia compatible) · Async processing for all API calls (never block main thread) · Thread-safe for Folia's regionized threading · Request queue system to prevent overwhelming APIs · Clean, well-commented code · MySQL and SQLite support for storing violations and statistics
Write the complete source code for this plugin.
``
---
📋 Summary
| Item | Detail | |------|--------| | Plugin Name | ZenAC | | Package | me.zen.zenac` | | Minecraft Version | 1.21+ | | Server Platforms | Paper, Spigot, Folia | | Java Version | 21 | | AI Providers | OpenAI, Google Gemini, Anthropic Claude, Custom |