feveromo dreambot-scripts .cursorrules file for Java

# DreamBot Script Development Guidelines

## Script Architecture Preference
1. Prefer node-based design over state-based architecture
2. Each node should handle a single responsibility
3. Implement validate() and execute() methods clearly
4. Return appropriate sleep times from execute()
5. Use proper node priority handling
6. Chain nodes logically
7. Handle node transitions cleanly

## Node-Based Best Practices
1. Keep validation logic fast and efficient
2. Handle all possible execution outcomes
3. Implement proper error recovery
4. Consider dynamic priorities
5. Account for script state in validation
6. Handle emergency situations
7. Balance competing nodes

## State Management Best Practices
1. If using states, keep them linear and simple
2. Consider converting state-based logic to nodes
3. Always have clear entry/exit conditions
4. Log state/node transitions for debugging
5. Reset states/nodes properly after completion
6. Use enums for clear definitions
7. Handle transitions atomically

## Fairy Ring Interactions
1. Check both location AND existence of rings
2. Add delays between code inputs (200ms minimum)
3. Wait for interface to fully open before entering codes
4. Verify teleport completion before proceeding
5. Use area checks to confirm successful teleports
6. Handle animation completion after teleport
7. Add proper error logging for ring detection

## Area Definitions
1. Make areas slightly larger than needed
2. Double-check coordinates with in-game positions
3. Use center points for walking destinations
4. Include object locations within areas
5. Define separate areas for different functionalities
6. Add buffer zones around interaction points
7. Verify area containment before actions

## Sleep Conditions
1. Use Sleep.sleepUntil() with proper conditions
2. Add timeouts to prevent infinite waits
3. Include animation checks after actions
4. Add small delays after successful actions
5. Use randomized delays between actions
6. Verify completion conditions
7. Add proper timeouts for interface interactions

## Walking Logic
1. Check Walking.walk() return value
2. Add Sleep conditions after walking calls
3. Verify arrival with area contains checks
4. Use proper distance checks before interactions
5. Handle walking failures gracefully
6. Add position logging for debugging
7. Use proper tile selection for destinations

## Inventory Management
1. Check inventory state at start of tasks
2. Track item counts for verification
3. Add proper full/empty checks
4. Use constants for all item IDs
5. Handle inventory state changes
6. Verify item existence before interactions
7. Track collection progress

## Task Design
1. Keep tasks focused on single responsibility
2. Add proper accept() conditions
3. Include state reset logic
4. Add proper logging in execute()
5. Pass script instance for statistics
6. Handle task transitions properly
7. Add proper documentation

## Interface Handling
1. Verify interface state before interactions
2. Add proper sleep conditions for interface opening
3. Handle interface closing properly
4. Add timeouts for interface operations
5. Verify successful interactions
6. Handle dialogue properly
7. Add proper delays between inputs

## Statistics Tracking
1. Track runtime properly
2. Calculate per hour rates correctly
3. Update statistics atomically
4. Add proper paint display
5. Track state information
6. Log important events
7. Handle counter updates properly

## Error Recovery
1. Add detailed error logging
2. Include position information in logs
3. Add retry logic for critical actions
4. Reset states on failures
5. Handle timeout conditions
6. Add fallback logic
7. Implement proper error states

## Script Structure
1. Use proper package organization
2. Add thorough documentation
3. Use consistent naming conventions
4. Implement proper configuration
5. Add GUI when needed
6. Handle script lifecycle properly
7. Follow DreamBot best practices

## Common Pitfalls to Avoid
1. State loops in accept() methods
2. Missing sleep conditions
3. Incorrect area definitions
4. Missing existence checks
5. Improper state transitions
6. Inadequate error handling
7. Poor documentation

## Debugging Essentials
1. Add detailed logging
2. Include position information
3. Log all state transitions
4. Track inventory changes
5. Monitor interaction results
6. Add timing information
7. Track success/failure rates

Remember: When stuck:
1. Add more logging
2. Simplify state logic
3. Verify area definitions
4. Check sleep conditions
5. Monitor state transitions 
java

First Time Repository

Java

Languages:

Java: 58.4KB
Created: 11/6/2024
Updated: 1/4/2025

All Repositories (1)