ScriptsLab
WikiDownloadsSourcesSupport
ScriptsLab
DocumentationDownloadsGitHubDiscord

© 2026 ScriptsLab

Back to root
M

PROJECT_STRUCTURE.md

Markdown · 162 lines · 5.2 KB

PROJECT_STRUCTURE.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
# ModularPlugin - Production Architecture

## Project Structure

```
ModularPlugin/
├── pom.xml
├── README.md
├── INSTALL.md
├── .gitignore
│
├── src/main/java/com/myplugin/
│   │
│   ├── ModularPlugin.java                    # Main plugin class
│   │
│   ├── api/                                   # Public API interfaces
│   │   ├── module/
│   │   │   ├── Module.java
│   │   │   ├── ModuleManager.java
│   │   │   └── ModuleDescriptor.java
│   │   ├── item/
│   │   │   ├── CustomItem.java
│   │   │   ├── ItemManager.java
│   │   │   └── ItemAbility.java
│   │   ├── command/
│   │   │   ├── CommandExecutor.java
│   │   │   └── CommandManager.java
│   │   ├── script/
│   │   │   ├── ScriptEngine.java
│   │   │   └── ScriptContext.java
│   │   ├── storage/
│   │   │   ├── StorageProvider.java
│   │   │   └── DataRepository.java
│   │   ├── event/
│   │   │   ├── EventBus.java
│   │   │   └── Event.java
│   │   └── scheduler/
│   │       └── TaskScheduler.java
│   │
│   ├── core/                                  # Core implementation
│   │   ├── di/
│   │   │   ├── Container.java
│   │   │   ├── Injectable.java
│   │   │   └── ServiceRegistry.java
│   │   ├── module/
│   │   │   ├── ModuleManagerImpl.java
│   │   │   ├── ModuleLoader.java
│   │   │   └── DependencyResolver.java
│   │   ├── item/
│   │   │   ├── ItemManagerImpl.java
│   │   │   ├── ItemRegistry.java
│   │   │   └── AbilityExecutor.java
│   │   ├── command/
│   │   │   ├── CommandManagerImpl.java
│   │   │   ├── CommandRegistry.java
│   │   │   └── TabCompleter.java
│   │   ├── script/
│   │   │   ├── GraalScriptEngine.java
│   │   │   ├── ScriptSandbox.java
│   │   │   ├── ScriptAPI.java
│   │   │   └── ScriptLoader.java
│   │   ├── storage/
│   │   │   ├── StorageManager.java
│   │   │   ├── YamlProvider.java
│   │   │   ├── JsonProvider.java
│   │   │   ├── SQLiteProvider.java
│   │   │   └── CacheLayer.java
│   │   ├── event/
│   │   │   ├── EventBusImpl.java
│   │   │   ├── EventDispatcher.java
│   │   │   └── EventSubscriber.java
│   │   ├── scheduler/
│   │   │   ├── TaskSchedulerImpl.java
│   │   │   └── TaskRegistry.java
│   │   └── config/
│   │       ├── ConfigManager.java
│   │       └── MessageManager.java
│   │
│   ├── modules/                               # Built-in modules
│   │   └── demo/
│   │       ├── DemoModule.java
│   │       ├── MagicWandItem.java
│   │       └── FlyCommand.java
│   │
│   ├── gui/                                   # GUI system
│   │   ├── InventoryGUI.java
│   │   ├── GUIBuilder.java
│   │   └── GUIManager.java
│   │
│   └── utils/                                 # Utilities
│       ├── TextUtils.java
│       ├── LocationUtils.java
│       ├── ItemBuilder.java
│       └── Validate.java
│
├── src/main/resources/
│   ├── plugin.yml
│   ├── config.yml
│   ├── messages.yml
│   └── modules/
│       └── demo/
│           └── module.yml
│
└── scripts/                                   # JavaScript files
    ├── examples/
    │   ├── custom_item.js
    │   ├── custom_command.js
    │   └── event_handler.js
    └── modules/
        └── demo/
            └── welcome.js
```

## Architecture Layers

### 1. API Layer (`api/`)
- Pure interfaces
- No implementation details
- Contracts for all systems

### 2. Core Layer (`core/`)
- Implementation of API
- Business logic
- Thread-safe operations
- Dependency injection

### 3. Module Layer (`modules/`)
- Pluggable modules
- Self-contained functionality
- Can depend on other modules

### 4. Script Layer (`scripts/`)
- JavaScript integration
- Hot-reloadable
- Sandboxed execution

## Key Design Patterns

- **Dependency Injection**: Custom lightweight DI container
- **Repository Pattern**: Storage abstraction
- **Observer Pattern**: Event bus
- **Strategy Pattern**: Storage providers
- **Builder Pattern**: Item creation, GUI building
- **Factory Pattern**: Module creation
- **Singleton**: Service registry (thread-safe)

## Thread Safety

- All managers use `ConcurrentHashMap`
- Async operations use `CompletableFuture`
- Proper synchronization on shared state
- Lock-free where possible

## Performance Optimizations

- Lazy loading of modules
- Caching layer for storage
- Batch operations for saves
- Async I/O operations
- Object pooling for frequent allocations
- Efficient event dispatching