ScriptsLab
WikiDownloadsSourcesSupport
ScriptsLab
DocumentationDownloadsGitHubDiscord

ยฉ 2026 ScriptsLab

Back to root
M

FINAL_README.md

Markdown ยท 389 lines ยท 9.1 KB

FINAL_README.md
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
# FrameworkPlugin - Production-Grade Modular Framework

## ๐ŸŽฏ Overview

FrameworkPlugin is a **production-ready**, **framework-level** plugin system for Minecraft Paper 1.21.8. It's not just a pluginโ€”it's a **mini game engine** inside Minecraft.

### Key Features

โœ… **Modular Architecture** - Clean Architecture with SOLID principles  
โœ… **Dependency Injection** - Lightweight custom DI container  
โœ… **JavaScript Support** - GraalVM with ECMAScript 2022  
โœ… **Custom Event Bus** - Cross-module communication  
โœ… **Item System** - Custom items with abilities and NBT  
โœ… **Task Scheduler** - CompletableFuture-based async operations  
โœ… **Hot Reload** - Reload modules and scripts without restart  
โœ… **Thread-Safe** - Concurrent collections and atomic operations  
โœ… **Zero Hardcoded Logic** - Everything configurable or scriptable  

## ๐Ÿ“ Project Structure

```
FrameworkPlugin/
โ”œโ”€โ”€ src/main/java/com/myplugin/
โ”‚   โ”œโ”€โ”€ FrameworkPlugin.java           # Main plugin class
โ”‚   โ”‚
โ”‚   โ”œโ”€โ”€ api/                            # Public interfaces (API layer)
โ”‚   โ”‚   โ”œโ”€โ”€ module/                     # Module system API
โ”‚   โ”‚   โ”œโ”€โ”€ item/                       # Item system API
โ”‚   โ”‚   โ”œโ”€โ”€ event/                      # Event bus API
โ”‚   โ”‚   โ”œโ”€โ”€ scheduler/                  # Scheduler API
โ”‚   โ”‚   โ”œโ”€โ”€ script/                     # Script engine API
โ”‚   โ”‚   โ””โ”€โ”€ storage/                    # Storage API
โ”‚   โ”‚
โ”‚   โ”œโ”€โ”€ core/                           # Implementation layer
โ”‚   โ”‚   โ”œโ”€โ”€ di/                         # Dependency injection
โ”‚   โ”‚   โ”œโ”€โ”€ module/                     # Module management
โ”‚   โ”‚   โ”œโ”€โ”€ item/                       # Item management
โ”‚   โ”‚   โ”œโ”€โ”€ event/                      # Event bus implementation
โ”‚   โ”‚   โ”œโ”€โ”€ scheduler/                  # Task scheduler
โ”‚   โ”‚   โ””โ”€โ”€ script/                     # GraalVM script engine
โ”‚   โ”‚
โ”‚   โ””โ”€โ”€ modules/                        # Built-in modules
โ”‚       โ””โ”€โ”€ demo/                       # Demo module
โ”‚           โ””โ”€โ”€ DemoModule.java
โ”‚
โ”œโ”€โ”€ src/main/resources/
โ”‚   โ”œโ”€โ”€ plugin.yml
โ”‚   โ”œโ”€โ”€ config.yml
โ”‚   โ”œโ”€โ”€ messages.yml
โ”‚   โ””โ”€โ”€ modules/demo/module.yml
โ”‚
โ”œโ”€โ”€ scripts/examples/                   # JavaScript examples
โ”‚   โ”œโ”€โ”€ custom_item_example.js
โ”‚   โ”œโ”€โ”€ scheduler_example.js
โ”‚   โ””โ”€โ”€ simple_command.js
โ”‚
โ”œโ”€โ”€ README.md                           # This file
โ”œโ”€โ”€ ARCHITECTURE.md                     # Architecture documentation
โ”œโ”€โ”€ BUILD.md                            # Build instructions
โ”œโ”€โ”€ INSTALL.md                          # Installation guide
โ””โ”€โ”€ pom.xml                             # Maven configuration
```

## ๐Ÿš€ Quick Start

### Prerequisites

- **Java 21+** (required for GraalVM)
- **Maven 3.8+**
- **Paper 1.21.8+**

### Build

```bash
mvn clean package
```

### Install

```bash
cp target/FrameworkPlugin-1.0.0.jar /path/to/server/plugins/
```

### Run

Start your Paper server. The plugin will:
1. Initialize DI container
2. Load core services
3. Load modules (demo module included)
4. Load JavaScript scripts

## ๐Ÿ“š Documentation

- **[ARCHITECTURE.md](ARCHITECTURE.md)** - Detailed architecture documentation
- **[BUILD.md](BUILD.md)** - Build and development guide
- **[INSTALL.md](INSTALL.md)** - Installation instructions
- **[PROJECT_STRUCTURE.md](PROJECT_STRUCTURE.md)** - Project organization

## ๐ŸŽฎ Demo Module

The included demo module showcases framework capabilities:

### Magic Wand Item
- Right-click to teleport forward 5 blocks
- Particle effects and sounds
- Cooldown system
- Given to new players automatically

### /fly Command
- Toggle flight mode
- Sound feedback
- Permission-based

### Welcome Message
- Customizable via config
- Sent on player join

## ๐Ÿ’ป JavaScript API

### Example: Custom Item

```javascript
// Register a fire sword
API.registerItem(
    "fire_sword",
    "DIAMOND_SWORD",
    "&c&lFire Sword",
    "&7Sets enemies on fire",
    "&6Epic Item"
);

// Give to player
var player = API.getPlayer("PlayerName");
API.giveItem(player, "fire_sword", 1);
```

### Example: Scheduler

```javascript
// Run after 5 seconds
API.runLater(function() {
    API.broadcast("&aHello World!");
}, 100); // 100 ticks = 5 seconds

// Repeating task
API.runTimer(function() {
    console.log("This runs every 30 seconds");
}, 600, 600);
```

### Example: Player Management

```javascript
// Get online players
var players = API.getOnlinePlayers();

// Send message
players.forEach(function(player) {
    API.sendMessage(player, "&6Welcome!");
});

// Broadcast
API.broadcast("&aServer announcement!");
```

## ๐Ÿ—๏ธ Creating Modules

### 1. Create module.yml

```yaml
id: mymodule
name: My Module
version: 1.0.0
description: My custom module
authors: [YourName]
dependencies: []
soft-dependencies: []
load-order: STARTUP
enabled: true
```

### 2. Create Module Class

```java
package com.myplugin.modules.mymodule;

import com.myplugin.api.module.ModuleDescriptor;
import com.myplugin.core.module.BaseModule;

import java.nio.file.Path;
import java.util.concurrent.CompletableFuture;

public class MyModule extends BaseModule {
    
    public MyModule(ModuleDescriptor descriptor, Path dataFolder) {
        super(descriptor, dataFolder);
    }
    
    @Override
    public CompletableFuture<Void> onEnable() {
        return super.onEnable().thenRun(() -> {
            log("My module enabled!");
            // Your initialization code
        });
    }
    
    @Override
    public CompletableFuture<Void> onDisable() {
        return super.onDisable().thenRun(() -> {
            log("My module disabled!");
            // Cleanup code
        });
    }
}
```

### 3. Place in modules/ folder

```
plugins/FrameworkPlugin/modules/mymodule/
โ”œโ”€โ”€ module.yml
โ””โ”€โ”€ config.yml
```

## ๐Ÿ”ง Configuration

### Main Config (config.yml)

```yaml
settings:
  debug: false
  language: en

modules:
  auto-load: true
  
scripting:
  enabled: true
  sandbox: true
  timeout: 5000

performance:
  async-loading: true
  cache-enabled: true
```

## ๐ŸŽฏ Architecture Highlights

### Dependency Injection

```java
Container container = Container.getInstance();
container.registerSingleton(EventBus.class, new EventBusImpl());

EventBus eventBus = container.resolve(EventBus.class).orElseThrow();
```

### Event Bus

```java
eventBus.subscribe(MyEvent.class, event -> {
    // Handle event
}, EventBus.EventPriority.NORMAL);

eventBus.post(new MyEvent()).join();
```

### Module System

- **Dependency Resolution**: Topological sorting
- **Load Order**: STARTUP โ†’ POSTWORLD โ†’ LAZY
- **Hot Reload**: Reload without restart
- **Isolation**: Each module has isolated state

### Script Engine

- **Sandboxed**: No file I/O, restricted class access
- **Hot Reload**: Reload scripts without restart
- **Error Isolation**: Script errors don't crash plugin
- **Performance**: Scripts compile once, execute many times

## ๐Ÿ”’ Security

- **Sandboxed Scripts**: No access to file system or dangerous APIs
- **Class Whitelisting**: Only allowed classes accessible
- **Permission System**: Fine-grained permissions
- **Input Validation**: All inputs validated
- **Error Isolation**: Errors contained to modules

## โšก Performance

- **Async Operations**: All I/O operations async
- **Lazy Loading**: Load on demand
- **Caching**: Frequently used data cached
- **Object Pooling**: Reuse expensive objects
- **Batch Operations**: Batch saves and updates

## ๐Ÿงช Testing

```bash
# Run tests
mvn test

# Run with coverage
mvn test jacoco:report

# Integration tests
mvn verify
```

## ๐Ÿ“Š Monitoring

The framework provides:
- Module load times
- Script execution times
- Event processing metrics
- Memory usage tracking
- Error rates

## ๐Ÿค Contributing

1. Fork the repository
2. Create feature branch
3. Follow code style (Google Java Style)
4. Write tests
5. Submit pull request

## ๐Ÿ“ License

This project is provided as-is for educational and production use.

## ๐Ÿ†˜ Support

### Common Issues

**Module won't load**
- Check module.yml syntax
- Verify dependencies
- Check logs for errors

**Script errors**
- Enable debug mode
- Check script syntax
- Verify API usage

**Performance issues**
- Enable profiling
- Check async operations
- Review module count

### Getting Help

1. Check documentation
2. Review examples
3. Enable debug logging
4. Check server logs

## ๐ŸŽ“ Learning Resources

- [Clean Architecture](https://blog.cleancoder.com/uncle-bob/2012/08/13/the-clean-architecture.html)
- [SOLID Principles](https://en.wikipedia.org/wiki/SOLID)
- [Paper API Docs](https://docs.papermc.io/)
- [GraalVM Docs](https://www.graalvm.org/latest/docs/)

## ๐Ÿš€ Roadmap

- [ ] Web dashboard
- [ ] Database integration (MySQL, PostgreSQL)
- [ ] Metrics system (Prometheus)
- [ ] Plugin marketplace
- [ ] REST API
- [ ] Distributed modules
- [ ] Hot code reload

## โœจ Credits

Built with:
- Paper API
- GraalVM
- Java 21
- Maven

---

**Version**: 1.0.0  
**Compatibility**: Paper 1.21.8+, Java 21+  
**Architecture**: Clean Architecture + SOLID  
**Status**: Production Ready โœ