OverWatch-ML includes a powerful machine learning system for detecting cheaters in Minecraft. The system is built on modern principles with emphasis on performance, reliability and maintainability.
Main ML system manager, coordinating all components.
public class ModernMLManager implements Listener {
// Asynchronous processing of all ML operations
public void analyzePlayerAsync(UUID playerId, AnalysisCallback callback);
// Synchronous analysis (critical cases only)
public ReasoningMLModel.DetectionResult analyzePlayerSync(UUID playerId);
// Training management
public void startTraining(Player player, boolean isCheater);
public void stopTraining(UUID playerId);
}public interface MLModel {
DetectionResult analyze(PlayerMiningData data);
boolean train(Collection<PlayerMiningData> trainingData);
boolean isTrained();
}
public interface DataCollector {
void startCollecting(Player player, boolean isCheater);
PlayerMiningData stopCollecting(Player player);
boolean isCollecting(UUID playerId);
}
public interface AnalysisManager {
CompletableFuture<DetectionResult> analyzeAsync(UUID playerId);
double getSuspicionScore(UUID playerId);
boolean isUnderAnalysis(UUID playerId);
}// Getting the ML manager
ModernMLManager mlManager = (ModernMLManager) plugin.getMLManager();
// Asynchronous player analysis
mlManager.analyzePlayerAsync(playerId, new AnalysisCallback() {
@Override
public void onAnalysisComplete(UUID playerId, DetectionResult result) {
if (result == DetectionResult.CHEATER_HIGH_CONFIDENCE) {
// Apply punishment
punishPlayer(playerId);
}
}
@Override
public void onAnalysisFailed(UUID playerId, Throwable error) {
logger.warning("ML analysis failed for " + playerId + ": " + error.getMessage());
}
});
// Synchronous analysis (use with caution!)
DetectionResult result = mlManager.analyzePlayerSync(playerId);// Start collecting training data
mlManager.startTraining(player, true); // true = cheater
// After 60 seconds, collection will automatically stop and the model will retrainml:
enabled: true
trainingSessionDuration: 60 # seconds
detectionThreshold: 0.75 # detection threshold
autoAnalysis:
enabled: true
suspiciousThreshold: 5
maxPlayers: 5
performance:
executorPoolSize: 0 # 0 = auto-detection
analysisTimeoutSeconds: 30
maxConcurrentAnalyses: 10
cache:
analysis:
maxSize: 1000
expiryMinutes: 5
features:
maxSize: 500
expiryMinutes: 10
playerData:
maxSize: 200
expiryMinutes: 30
maintenance:
cleanupIntervalMinutes: 5
metricsReportIntervalMinutes: 15
maxTrainingQueueSize: 1000
maxAnalysisQueueSize: 500MLConfig config = mlManager.getMLConfig();
// Performance Configuration
config.setExecutorPoolSize(8);
config.setAnalysisTimeoutSeconds(45);
config.setMaxConcurrentAnalyses(15);
// Cache Configuration
config.setAnalysisCacheMaxSize(2000);
config.setAnalysisCacheExpiryMinutes(3);
// Saving changes
config.saveConfig();enum DetectionResult {
CHEATER_HIGH_CONFIDENCE, // High confidence in cheating
CHEATER_MEDIUM_CONFIDENCE, // Medium confidence
CHEATER_LOW_CONFIDENCE, // Low confidence
SUSPICIOUS, // Suspicious behavior
NORMAL // Normal behavior
}// Getting statistics
String performanceStats = mlManager.getPerformanceStats();
// Output: "ML Performance: [detailed statistics]"
// Getting metrics in code
MLMetrics.MLStats stats = mlManager.getMetrics().getStats();
System.out.println("Total predictions: " + stats.totalPredictions);
System.out.println("Average time: " + stats.avgPredictionTimeMs + "ms");
System.out.println("Cache hits: " + stats.cacheHitRate * 100 + "%");MLCache cache = mlManager.getCache();
// Manual cache management
cache.invalidatePlayer(playerId); // Clear player data
cache.clearAll(); // Clear entire cache
// Cache statistics
MLCache.CacheStats cacheStats = cache.getStats();
System.out.println(cacheStats.toString());public class CustomMLModel implements MLModel {
@Override
public DetectionResult analyze(PlayerMiningData data) {
// Your analysis logic
return DetectionResult.NORMAL;
}
@Override
public boolean train(Collection<PlayerMiningData> trainingData) {
// Your training logic
return true;
}
@Override
public boolean isTrained() {
return true;
}
@Override
public void save() { /* saving */ }
@Override
public void load() { /* loading */ }
@Override
public void dispose() { /* disposal */ }
}
// Registering a custom model
ModernMLManager mlManager = new ModernMLManager(plugin, configManager);
// Replace model via reflection or create a new constructorpublic class AdvancedDataCollector implements DataCollector {
private final Map<UUID, CustomPlayerData> collectingData = new ConcurrentHashMap<>();
@Override
public void startCollecting(Player player, boolean isCheater) {
collectingData.put(player.getUniqueId(),
new CustomPlayerData(player.getUniqueId(), isCheater));
}
@Override
public PlayerMiningData stopCollecting(Player player) {
return collectingData.remove(player.getUniqueId());
}
// ... other methods
}The system automatically logs important events:
[INFO] ML model successfully trained!
[WARNING] ML analysis failed for player123: Timeout
[INFO] ML Metrics: Predictions=150 (Success: 95.3%), Training=3, Avg Prediction=45.2ms
/owml ml status # System status
/owml ml train <player> <type> # Train on player (cheater|normal)
/owml ml autotrain [count] # Automatically train on multiple players
/owml ml spawn <type> <count> # Spawn bots for training
/owml ml bots <status|remove|auto> # Bot management
/owml ml analyze <player> # Analyze player
/owml ml metrics # Show metrics
/owml ml cache # Cache statistics
The /owml ml autotrain [count] command allows you to automatically start ML model training on multiple online players simultaneously:
- Without parameters: trains on all available players
- With a number: trains on the specified number of players (max. 10)
Usage Example:
/owml ml autotrain # Train on all players
/owml ml autotrain 5 # Train on 5 random players
How it works:
- Automatically selects online players (except you)
- Half of the players are marked as "normal", the other half as "cheaters"
- Starts training sessions for 60 seconds each
- Players must behave according to their role
Important:
- Normal players must mine ore legitimately
- "Cheaters" must simulate X-ray behavior (straight tunnels to ore)
- All players must actively mine during the session
OverWatch-ML includes an innovative training bot system that allows training the ML model without real player involvement. Bots spawn automatically, simulate various mining behaviors, and generate training data.
- Mines ore in a normal way
- Explores caves and creates branches
- Avoids straight tunnels to valuable ores
- Simulates legitimate player behavior
- Creates straight tunnels to diamond veins
- Ignores iron/coal, focuses on diamonds
- Makes long straight corridors
- Simulates classic X-ray behavior
- Creates long straight tunnels
- Mines all ores in its path
- Does not seek specific valuable materials
- Mines blocks completely randomly
- Has no logic or patterns
- Simulates unskilled players
- Uses branch mining technique
- Finds optimal paths to ores
- Mines efficiently but legitimately
- Mines close to the surface
- Avoids deep mines
- Simulates beginners
/owml ml spawn NORMAL_MINER 5 # Spawn 5 normal miners
/owml ml spawn XRAY_CHEATER 3 # Spawn 3 x-ray cheaters
/owml ml spawn TUNNEL_MINER 2 # Spawn 2 tunnelers/owml ml bots status # Show status of all bots
/owml ml bots remove # Remove all active bots
/owml ml bots auto on # Enable automatic spawn
/owml ml bots auto off # Disable automatic spawn- Spawn: Bots appear in safe mining locations
- Behavior: Each bot performs specific behavior for 2 minutes
- Data Collection: All bot actions are recorded (broken blocks, movements)
- Feature Generation: ML features are calculated based on actions
- Training: Data is automatically fed into the ML system for training
When auto-mode (/owml ml bots auto on) is enabled, the system:
- Automatically spawns different types of bots every ~30 seconds
- Maintains a maximum of 5 concurrent bots
- Guarantees a variety of behavior types
- Automatically removes bots after the session ends
✅ No players needed - training works 24/7 ✅ Controlled training - precise behavior patterns ✅ Safety - does not affect real players ✅ Scalability - can generate thousands of examples ✅ Diversity - different behavior types for better training
The system provides detailed statistics:
Training Bots Status
Active Bots: 3
Total Spawned: 127
Training Sessions: 124
Auto Training: true
Max Concurrent: 5
Session Duration: 120s
Spawn Locations: 4
Active Types:
• normal miner: 1
• xray cheater: 2
- Session duration: 120 seconds (configurable)
- Max bots: 20 concurrent (configurable)
- Spawn frequency: Every 30 seconds in auto-mode
- Search radius: Bots search for ore within a 50-block radius
- Safety: Bots spawn only in safe locations
- ✅ Use asynchronous methods for heavy operations
- ✅ Configure cache sizes for your workload
- ✅ Monitor metrics and configure timeouts
- ✅ Always handle exceptions
- ✅ Use fallback logic on ML errors
- ✅ Implement graceful degradation
- ✅ Separate training and analysis
- ✅ Use queue limits
- ✅ Optimize data collection
- ✅ Create unit tests for components
- ✅ Use mock objects for testing
- ✅ Test error scenarios
ml:
performance:
executorPoolSize: 2 # Reduce thread count
cache:
analysis:
maxSize: 500 # Reduce cache sizeml:
maintenance:
cleanupIntervalMinutes: 2 # Frequent cleanup
cache:
playerData:
expiryMinutes: 15 # Reduce lifetimeml:
performance:
maxConcurrentAnalyses: 5 # Limit parallelism
cache:
features:
maxSize: 1000 # Increase feature cacheIf you are using the old MLManager:
// Old code
MLManager oldManager = plugin.getMLManager();
oldManager.startAnalysis(player);
// New code
ModernMLManager newManager = (ModernMLManager) plugin.getMLManager();
newManager.analyzePlayerAsync(player.getUniqueId(), callback);- 📧 Issues: Create issues on GitHub
- 📖 Wiki: Detailed documentation in wiki
- 🏗️ Architecture: SOLID principles, Clean Architecture
- 🧪 Testing: 95%+ code coverage
- 🚀 Performance: Optimized for production
API Version: 2.0.0 Compatibility: Minecraft 1.21+ Java: 21+