English | 中文
192.168.*.*)cwhitelist-x.x-NeoForge-1.21.x.jar from Releasesmods folderFor Local-Only Mode:
# config/cwhitelist-common.toml
[basic]
enableLogging = true
logRetentionDays = 7
logCutSizeMB = 10
[checks]
enableNameCheck = true
enableUuidCheck = true
enableIpCheck = true
[api]
enableApi = false # Disable API integration
For API-Enabled Mode:
[api]
enableApi = true
baseUrl = "http://your-api-server.com/api"
token = "your-secure-api-token-here"
useHeaderAuth = true
timeoutSeconds = 10
syncOnStartup = true
logLoginEvents = true
Backend program repository address:cwhitelist-backend
[basic])| Parameter | Default | Description | Range |
|---|---|---|---|
enableLogging |
true |
Enable local file logging | boolean |
logRetentionDays |
7 |
Days to keep log files | 1-365 |
logCutSizeMB |
10 |
Maximum log file size (MB) | 1-100 |
[checks])| Parameter | Default | Description |
|---|---|---|
enableNameCheck |
true |
Validate by player name |
enableUuidCheck |
true |
Validate by player UUID |
enableIpCheck |
true |
Validate by IP address |
[api])| Parameter | Default | Description |
|---|---|---|
enableApi |
false |
Enable API integration |
baseUrl |
http://127.0.0.1:5000/api |
API server base URL |
token |
"" |
API authentication token |
useHeaderAuth |
true |
Use Authorization header (true) or query param (false) |
timeoutSeconds |
10 |
API request timeout |
cacheDurationSeconds |
30 |
Local cache duration (0 to disable) |
syncOnStartup |
true |
Sync with API on server start |
logLoginEvents |
true |
Send login events to API |
serverId |
"" |
Optional server identifier |
sendServerId |
false |
Include server ID in API requests |
includeExpired |
false |
Include expired entries when syncing |
| Command | Description | Permission |
|---|---|---|
| No direct player commands | All whitelist management requires admin permissions | - |
Basic Whitelist Management:
# Add entries
/cwhitelist add name <username>
/cwhitelist add uuid <uuid>
/cwhitelist add ip <ip-address>
# Remove entries
/cwhitelist remove name <username>
/cwhitelist remove uuid <uuid>
/cwhitelist remove ip <ip-address>
# View entries
/cwhitelist list
# Reload configuration
/cwhitelist reload
API Management Commands:
# Check API status
/cwhitelist api status
# Verify API token
/cwhitelist api verify
# Perform health check
/cwhitelist api health
# Manual sync from API
/cwhitelist api sync
# Clear API cache
/cwhitelist api clearcache
CWhitelist supports integration with compatible API servers that implement the following endpoints:
GET /health - Health check (no authentication required)GET /whitelist/sync - Retrieve whitelist entries (requires read permission)POST /whitelist/entries - Add new entries (requires write permission)DELETE /whitelist/entries/{type}/{value} - Remove entries (requires delete permission)POST /login/log - Log login events (requires write permission)GET /tokens/verify - Verify token validity (requires authentication)API tokens must be created with appropriate permissions:
Header Authentication (Recommended):
Authorization: Bearer your-token-here
Query Parameter Authentication:
GET /api/whitelist/sync?token=your-token-here
config/
├── cwhitelist-common.toml # Main configuration
└── cwhitelist_entries.json # Local whitelist backup
logs/
└── cwhitelist/
├── 2024-01-01.log # Daily log files
└── 2024-01-01.log.1704067200000 # Rotated logs
cwhitelist_entries.json:
[
{"type": "name", "value": "PlayerOne"},
{"type": "uuid", "value": "123e4567-e89b-12d3-a456-426614174000"},
{"type": "ip", "value": "192.168.1.*"}
]
// Configurable cache duration
cacheDurationSeconds = 30 // Balance between freshness and API load
// Smart cache invalidation
- Add/Remove operations clear cache
- Manual sync refreshes cache
- Automatic periodic validation
API Connection Failed:
[Server] WARN API health check failed, falling back to local file
Solution: Verify API server is running and accessible. Check network connectivity and firewall settings.
Authentication Failed:
[Server] ERROR Token verification failed: Authentication required
Solution: Verify API token is correct and has required permissions. Use /cwhitelist api verify to test.
Permission Denied:
[Server] ERROR Token does not have write permission
Solution: Generate new token with appropriate permissions or use existing token with correct permissions.
Cache Issues:
[Server] DEBUG API cache cleared
Solution: Cache automatically clears on modification. Use /cwhitelist api clearcache to force refresh.
Check log files for detailed error information:
logs/cwhitelist/YYYY-MM-DD.log[HH:mm:ss] [RESULT] PlayerName UUID IP# Check current mode
/cwhitelist list
# Verify API connectivity
/cwhitelist api health
# Test token permissions
/cwhitelist api verify
# View detailed status
/cwhitelist api status
{
"success": true,
"message": "Operation successful",
"data": { /* operation-specific data */ }
}
The mod handles the following HTTP status codes:
200-299: Success - Process response401: Unauthorized - Token invalid/expired403: Forbidden - Insufficient permissions429: Rate Limited - Automatic retry with backoff500+: Server Error - Fallback to local mode# Clone repository
git clone https://github.com/SkyDreamLG/CWhitelist.git
cd CWhitelist
# Build with Gradle
./gradlew build
# Output: build/libs/cwhitelist-x.x.x.jar
src/main/java/org/skydream/cwhitelist/
├── Cwhitelist.java # Main mod class
├── Config.java # Configuration management
├── ApiClient.java # API communication
├── WhitelistManager.java # Core whitelist logic
├── WhitelistCommand.java # Command implementation
├── LogHandler.java # Logging system
└── WhitelistEntry.java # Data model
Adding New Authentication Methods:
Config.java with new check settingWhitelistManager.isAllowed() methodCustom API Integration:
// Implement custom ApiClient interface
public interface CustomApiClient {
CompletableFuture<List<WhitelistEntry>> fetchEntries();
CompletableFuture<Boolean> validateEntry(WhitelistEntry entry);
}
We welcome contributions! Please see our Contributing Guidelines for details.
git checkout -b feature/amazing-feature)git commit -m 'Add amazing feature')git push origin feature/amazing-feature)cacheDurationSeconds based on update frequencylogCutSizeMB to prevent disk space issuestimeoutSeconds based on network latencyReady to secure your Minecraft server? Install CWhitelist today and experience professional-grade whitelist management!