@dimzxzzx07/mc-headless 2.0.0 → 2.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -5,12 +5,12 @@
5
5
  </div>
6
6
 
7
7
  <div align="center">
8
- <img src="https://img.shields.io/badge/Version-2.0.0-2563eb?style=for-the-badge&logo=typescript" alt="Version">
8
+ <img src="https://img.shields.io/badge/Version-2.2.0-2563eb?style=for-the-badge&logo=typescript" alt="Version">
9
9
  <img src="https://img.shields.io/badge/License-MIT-green?style=for-the-badge&logo=open-source-initiative" alt="License">
10
10
  <img src="https://img.shields.io/badge/Node-18%2B-339933?style=for-the-badge&logo=nodedotjs" alt="Node">
11
11
  <img src="https://img.shields.io/badge/Java-Portable-007396?style=for-the-badge&logo=openjdk" alt="Java Portable">
12
- <img src="https://img.shields.io/badge/Termux-Friendly-00A98F?style=for-the-badge&logo=termux" alt="Termux">
13
- <img src="https://img.shields.io/badge/Stable-2.0.0-brightgreen?style=for-the-badge" alt="Stable">
12
+ <img src="https://img.shields.io/badge/Downloads-10K%2B-brightgreen?style=for-the-badge" alt="Downloads">
13
+ <img src="https://img.shields.io/badge/Minecraft-1.21.11-00A98F?style=for-the-badge&logo=minecraft" alt="Minecraft">
14
14
  </div>
15
15
 
16
16
  <div align="center">
@@ -20,20 +20,42 @@
20
20
  <a href="https://github.com/Dimzxzzz">
21
21
  <img src="https://img.shields.io/badge/GitHub-Dimzxzzx07-181717?style=for-the-badge&logo=github&logoColor=white" alt="GitHub">
22
22
  </a>
23
- <a href="#">
24
- <img src="https://img.shields.io/badge/Documentation-Read-8B5CF6?style=for-the-badge&logo=gitbook&logoColor=white" alt="Documentation">
25
- </a>
26
- <a href="#">
27
- <img src="https://img.shields.io/badge/Download-NPM-CB3837?style=for-the-badge&logo=npm&logoColor=white" alt="NPM">
23
+ <a href="https://www.npmjs.com/package/@dimzxzzx07/mc-headless">
24
+ <img src="https://img.shields.io/badge/NPM-@dimzxzzx07/mc--headless-CB3837?style=for-the-badge&logo=npm" alt="NPM">
28
25
  </a>
29
26
  </div>
30
27
 
31
28
  ---
32
29
 
30
+ ## Platform Support
31
+
32
+ <div align="center">
33
+ <table>
34
+ <tr>
35
+ <td align="center"><img src="https://i.imgur.com/YNDuxZz.png" width="64" height="64" alt="Pterodactyl"><br><strong>Pterodactyl</strong></td>
36
+ <td align="center"><img src="https://i.imgur.com/ibeGaLU.png" width="64" height="64" alt="Ubuntu"><br><strong>Ubuntu</strong></td>
37
+ <td align="center"><img src="https://i.imgur.com/WdYzwTu.png" width="64" height="64" alt="Linux"><br><strong>Linux</strong></td>
38
+ <td align="center"><img src="https://i.imgur.com/CODPucn.png" width="64" height="64" alt="Windows"><br><strong>Windows</strong></td>
39
+ <td align="center"><img src="https://i.imgur.com/sUU24jx.png" width="64" height="64" alt="Termux"><br><strong>Termux</strong></td>
40
+ <td align="center"><img src="https://i.imgur.com/sbBQLaZ.jpeg" width="64" height="64" alt="Darwin"><br><strong>macOS</strong></td>
41
+ </tr>
42
+ </table>
43
+ </div>
44
+
45
+ **MC-Headless** runs perfectly on all platforms above:
46
+ - **Pterodactyl** - Popular game hosting panel
47
+ - **Ubuntu/Debian** - Most popular Linux servers
48
+ - **Linux** - All distributions (CentOS, Fedora, Arch, etc.)
49
+ - **Windows** - Windows Server with PowerShell
50
+ - **Termux** - Turn your Android into a Minecraft server
51
+ - **macOS** - Darwin / Mac OS X
52
+
53
+ ---
54
+
33
55
  ## Table of Contents
34
56
 
35
- - [Overview](#overview)
36
- - [What's New in 2.0.0](#whats-new-in-200)
57
+ - [What is MC-Headless?](#what-is-mc-headless)
58
+ - [What's New in 2.2.0](#whats-new-in-220)
37
59
  - [Features](#features)
38
60
  - [Why MC-Headless?](#why-mc-headless)
39
61
  - [Installation](#installation)
@@ -56,34 +78,52 @@
56
78
  - [SkinRestorer Support](#skinrestorer-support)
57
79
  - [Portable Java](#portable-java)
58
80
  - [Performance Tuning](#performance-tuning)
81
+ - [Pterodactyl Setup](#pterodactyl-setup)
82
+ - [Termux Setup](#termux-setup)
59
83
  - [Troubleshooting](#troubleshooting)
60
84
  - [Contributing](#contributing)
61
85
  - [License](#license)
62
86
 
63
87
  ---
64
88
 
65
- ## Overview
89
+ ## What is MC-Headless?
66
90
 
67
91
  **MC-Headless** is a powerful Node.js library that simplifies running Minecraft servers (Java, Bedrock, or Cross-play) with a clean, promise-based API. No more dealing with complex Java commands, server.properties files, or manual downloads - just simple JavaScript methods.
68
92
 
69
- Built specifically for developers, sysadmins, and Minecraft enthusiasts who want to automate server management, run headless servers on VPS/Termux, or integrate Minecraft servers into their applications.
93
+ Built specifically for developers, sysadmins, and Minecraft enthusiasts who want to automate server management, run headless servers on VPS/Pterodactyl/Termux, or integrate Minecraft servers into their applications.
94
+
95
+ ### Keywords for Search Engine Optimization
96
+ - Minecraft server hosting
97
+ - Minecraft server manager
98
+ - Minecraft headless server
99
+ - PaperMC server setup
100
+ - Minecraft VPS hosting
101
+ - Pterodactyl Minecraft egg
102
+ - Minecraft server automation
103
+ - Minecraft cross-play server
104
+ - Java portable Minecraft
105
+ - Minecraft Termux server
106
+ - Minecraft Ubuntu server
107
+ - Minecraft Docker container
108
+ - Minecraft server control panel
109
+ - Minecraft server API
110
+ - Minecraft hosting solution
70
111
 
71
112
  ---
72
113
 
73
- ## What's New in 2.0.0
114
+ ## What's New in 2.2.0
74
115
 
75
- ### Version 2.0.0 - March 2026
116
+ ### Version 2.2.0 - March 2026
76
117
 
77
- - **Portable Java** - Auto-download JRE to `/tmp` (no system installation required)
78
- - **Smart Java Detection** - Uses `which java` to check existing installation
79
- - **Auto-cleanup** - Removes old Java files after 24 hours
80
- - **Cgroups Support** - Reads CPU/Memory stats directly from kernel (like Pterodactyl)
81
- - **Silent Mode** - Direct pipe for logs, no Node.js processing overhead
82
- - **30-second Stats** - Resource monitoring every 30 seconds (not real-time)
83
- - **MALLOC_ARENA_MAX=2** - Environment optimization for memory efficiency
84
- - **SkinRestorer Plugin** - Auto-download and install SkinRestorer
85
- - **System RAM Detection** - Auto-recommend memory based on available RAM
86
- - **Better Error Handling** - Improved error messages and recovery
118
+ - **Pterodactyl Optimized** - Full compatibility with Pterodactyl panel
119
+ - **No curl/wget required** - Pure Node.js downloader works everywhere
120
+ - **Better error handling** - Clear messages for disk space issues
121
+ - **Smaller Java downloads** - Uses JRE instead of full JDK (saves 150MB)
122
+ - **Automatic disk space check** - Warns before downloading
123
+ - **Improved platform detection** - Works on all Linux distros
124
+ - **Fallback URLs** - Multiple mirrors for Java downloads
125
+ - **Corrupted file detection** - Auto-retry on bad downloads
126
+ - **Memory limit awareness** - Respects cgroup limits in containers
87
127
 
88
128
  ---
89
129
 
@@ -94,15 +134,16 @@ Built specifically for developers, sysadmins, and Minecraft enthusiasts who want
94
134
  | **Server Types** | Paper, Purpur, Vanilla, Spigot, Forge, Fabric |
95
135
  | **Platforms** | Java Edition, Bedrock Edition, Cross-play (Geyser) |
96
136
  | **Auto Setup** | Automatic Java detection, EULA acceptance, server.properties generation |
97
- | **Portable Java** | Download JRE to `/tmp`, no system installation required |
137
+ | **Portable Java** | Download JRE to current directory, no system installation required |
98
138
  | **Cgroups Stats** | CPU/Memory stats like Pterodactyl (30s interval) |
99
- | **Downloader** | Automatic download of server jars from official sources |
139
+ | **Downloader** | Pure Node.js downloader (no curl/wget needed) |
100
140
  | **Memory Management** | Custom memory allocation, Aikar's flags optimization |
101
141
  | **Backup System** | Automatic scheduled backups, manual backup triggers |
102
142
  | **Monitoring** | Real-time CPU/memory usage, player tracking, server events |
103
143
  | **Cross-play** | Built-in Geyser & Floodgate support for Bedrock clients |
104
144
  | **ViaVersion** | Built-in ViaVersion, ViaBackwards, ViaRewind support |
105
145
  | **SkinRestorer** | Auto-download and install SkinRestorer plugin |
146
+ | **Pterodactyl Ready** | Optimized for panel hosting |
106
147
  | **Termux Friendly** | Optimized for Android/Termux environments |
107
148
  | **Headless Ready** | No GUI required, perfect for servers and automation |
108
149
  | **Silent Mode** | Direct log piping for minimal CPU usage |
@@ -114,13 +155,13 @@ Built specifically for developers, sysadmins, and Minecraft enthusiasts who want
114
155
  ### Before (Manual Setup)
115
156
  ```bash
116
157
  # Download server jar
117
- wget https://api.papermc.io/v2/projects/paper/versions/1.21.11/builds/69/downloads/paper-1.21.11-69.jar
158
+ wget https://api.papermc.io/v2/projects/paper/versions/1.21.11/builds/196/downloads/paper-1.21.11-196.jar
118
159
 
119
160
  # Check if Java installed
120
161
  which java || echo "Java not found"
121
162
 
122
163
  # Install Java manually if needed
123
- sudo apt install openjdk-17-jre-headless
164
+ sudo apt install openjdk-21-jre-headless
124
165
 
125
166
  # Accept EULA
126
167
  echo "eula=true" > eula.txt
@@ -130,7 +171,7 @@ echo "server-port=25565" > server.properties
130
171
  echo "max-players=20" >> server.properties
131
172
 
132
173
  # Run server with complex Java flags
133
- java -Xms4G -Xmx12G -XX:+UseG1GC -jar paper-1.21.11-69.jar nogui
174
+ java -Xms4G -Xmx12G -XX:+UseG1GC -jar paper-1.21.11-196.jar nogui
134
175
 
135
176
  # Download plugins manually
136
177
  wget https://github.com/ViaVersion/ViaVersion/releases/download/5.7.2/ViaVersion-5.7.2.jar -P plugins/
@@ -140,9 +181,11 @@ wget https://github.com/SkinsRestorer/SkinsRestorerX/releases/latest/download/Sk
140
181
  tail -f logs/latest.log
141
182
  ```
142
183
 
143
- After (MC-Headless v2.0.0)
184
+ After (MC-Headless v2.2.0)
144
185
 
145
186
  ```javascript
187
+ const { MinecraftServer } = require('@dimzxzzx07/mc-headless');
188
+
146
189
  const server = new MinecraftServer({
147
190
  version: '1.21.11',
148
191
  type: 'paper',
@@ -177,7 +220,7 @@ Requirements
177
220
  Requirement Minimum Recommended
178
221
  Node.js 18.0.0 20.0.0 or higher
179
222
  RAM 2 GB 4 GB or more
180
- Storage 1 GB 5 GB
223
+ Storage 2 GB 10 GB
181
224
  OS Linux, macOS, Windows, Termux Linux (production)
182
225
 
183
226
  Note: Java is auto-downloaded as portable JRE (no system installation needed)
@@ -298,7 +341,7 @@ async function startServer() {
298
341
  server.on("ready", (info) => {
299
342
  console.clear();
300
343
  console.log(`\n==========================================`);
301
- console.log(`Minecraft Server - v2.0.0`);
344
+ console.log(`Minecraft Server - v2.2.0`);
302
345
  console.log(` IP: ${publicIp}:${info.port}`);
303
346
  console.log(` Version: ${info.version}`);
304
347
  console.log(` Memory: ${info.memory.used}/${info.memory.max} MB`);
@@ -318,7 +361,7 @@ async function startServer() {
318
361
 
319
362
  server.on("resource", (info) => {
320
363
  if (info.memory.used > info.memory.max * 0.8) {
321
- console.log(`high memory: ${info.memory.used}/${info.memory.max} MB`);
364
+ console.log(` High memory: ${info.memory.used}/${info.memory.max} MB`);
322
365
  }
323
366
  });
324
367
 
@@ -427,7 +470,7 @@ autoAcceptEula boolean true Automatically accept Minecraft EULA
427
470
  Java Options
428
471
 
429
472
  Option Type Default Description
430
- usePortableJava boolean true Download portable JRE to /tmp
473
+ usePortableJava boolean true Download portable JRE to current directory
431
474
  javaVersion string 'auto' '17', '21', or 'auto'
432
475
 
433
476
  Memory Options
@@ -472,6 +515,13 @@ Option Type Default Description
472
515
  silentMode boolean true Direct pipe logs (no Node.js processing)
473
516
  statsInterval number 30000 Stats update interval in ms
474
517
 
518
+ Owner Options
519
+
520
+ Option Type Default Description
521
+ owners array [] List of owner usernames
522
+ ownerCommands.prefix string '!' Command prefix for owners
523
+ ownerCommands.enabled boolean true Enable owner commands
524
+
475
525
  ---
476
526
 
477
527
  API Reference
@@ -522,6 +572,18 @@ interface ServerInfo {
522
572
  }
523
573
  ```
524
574
 
575
+ Player Interface
576
+
577
+ ```javascript
578
+ interface Player {
579
+ name: string;
580
+ uuid: string;
581
+ ip: string;
582
+ ping: number;
583
+ connectedAt: Date;
584
+ }
585
+ ```
586
+
525
587
  ---
526
588
 
527
589
  Usage Examples
@@ -587,25 +649,397 @@ await manager.startAll();
587
649
  await manager.broadcastCommand('say Server is running!');
588
650
  ```
589
651
 
652
+ Server with Owner Commands
653
+
654
+ ```javascript
655
+ const { MinecraftServer } = require('@dimzxzzx07/mc-headless');
656
+
657
+ const server = new MinecraftServer({
658
+ version: '1.21.11',
659
+ type: 'paper',
660
+ owners: ['dimzxind', 'admin1', 'tesuser'],
661
+ ownerCommands: {
662
+ prefix: '!',
663
+ enabled: true
664
+ }
665
+ });
666
+
667
+ server.on('player-join', (player) => {
668
+ if (['dimzxind', 'admin1', 'tesuser'].includes(player.name)) {
669
+ server.sendCommand(`tellraw ${player.name} {"text":"Welcome Owner! Use !help for commands","color":"gold"}`);
670
+ }
671
+ });
672
+
673
+ server.start();
674
+ ```
675
+
676
+ Owner Commands Available
677
+
678
+ Command Description Example
679
+ !gamemode <mode> [player] Change gamemode !gamemode creative
680
+ !gm <mode> [player] Shortcut for gamemode !gm survival
681
+ !tp <player> [x y z] Teleport !tp player2
682
+ !give <player> <item> [amount] Give items !give player2 diamond 64
683
+ !time <set\|add> <value> Change time !time set day
684
+ !weather <clear\|rain\|thunder> Change weather !weather clear
685
+ !kill [player] Kill player !kill player2
686
+ !ban <player> [reason] Ban player !ban hacker
687
+ !kick <player> [reason] Kick player !kick spammer
688
+ !op <player> Give operator !op friend
689
+ !deop <player> Remove operator !deop friend
690
+ !reload Reload server !reload
691
+ !save Save world !save
692
+ !list List players !list
693
+ !help Show owner commands !help
694
+
590
695
  ---
591
696
 
592
- Portable Java
697
+ Server Types
593
698
 
594
- How It Works
699
+ Paper (Recommended for Performance)
595
700
 
596
701
  ```javascript
597
702
  const server = new MinecraftServer({
598
- usePortableJava: true, // Download JRE to /tmp
599
- javaVersion: '17' // or '21', 'auto'
703
+ type: 'paper',
704
+ version: '1.21.11',
705
+ memory: { useAikarsFlags: true }
600
706
  });
601
707
  ```
602
708
 
603
- · Downloads JRE (not full JDK) ~50MB
604
- · Extracts to /tmp/.mc-headless-java/
605
- · Auto-cleanup after 24 hours
606
- · No system installation required
607
- · Sets JAVA_HOME and PATH automatically
608
- · Adds MALLOC_ARENA_MAX=2 for memory efficiency
709
+ Vanilla (Official Mojang)
710
+
711
+ ```javascript
712
+ const server = new MinecraftServer({
713
+ type: 'vanilla',
714
+ version: '1.21.11'
715
+ });
716
+ ```
717
+
718
+ Forge (Modded)
719
+
720
+ ```javascript
721
+ const server = new MinecraftServer({
722
+ type: 'forge',
723
+ version: '1.21.11',
724
+ folders: { mods: './mods' }
725
+ });
726
+ ```
727
+
728
+ Fabric (Lightweight Modding)
729
+
730
+ ```javascript
731
+ const server = new MinecraftServer({
732
+ type: 'fabric',
733
+ version: '1.21.11',
734
+ folders: { mods: './mods' }
735
+ });
736
+ ```
737
+
738
+ ---
739
+
740
+ Platform Options
741
+
742
+ Java Edition Only
743
+
744
+ ```javascript
745
+ const server = new MinecraftServer({
746
+ platform: 'java',
747
+ version: '1.21.11',
748
+ type: 'paper',
749
+ network: { port: 25565 }
750
+ });
751
+ ```
752
+
753
+ Bedrock Edition Only
754
+
755
+ ```javascript
756
+ const server = new MinecraftServer({
757
+ platform: 'bedrock',
758
+ version: '1.21.11',
759
+ network: { port: 19132 },
760
+ folders: { addons: './addons' }
761
+ });
762
+ ```
763
+
764
+ Cross-Play (Java + Bedrock)
765
+
766
+ ```javascript
767
+ const server = new MinecraftServer({
768
+ platform: 'all',
769
+ version: '1.21.11',
770
+ type: 'paper',
771
+ network: {
772
+ port: 25565,
773
+ bedrockPort: 19132
774
+ }
775
+ });
776
+ ```
777
+
778
+ ---
779
+
780
+ Memory Management
781
+
782
+ Basic Memory Configuration
783
+
784
+ ```javascript
785
+ memory: {
786
+ init: '2G',
787
+ max: '4G',
788
+ useAikarsFlags: false
789
+ }
790
+ ```
791
+
792
+ Aikar's Flags (Optimized)
793
+
794
+ ```javascript
795
+ memory: {
796
+ init: '2G',
797
+ max: '8G',
798
+ useAikarsFlags: true
799
+ }
800
+ ```
801
+
802
+ Memory Recommendations
803
+
804
+ Players RAM Init Max
805
+ 1-10 2 GB 1G 2G
806
+ 10-20 4 GB 2G 4G
807
+ 20-50 8 GB 4G 8G
808
+ 50-100 16 GB 8G 16G
809
+
810
+ ---
811
+
812
+ Network Settings
813
+
814
+ Basic Network
815
+
816
+ ```javascript
817
+ network: {
818
+ port: 25565,
819
+ ip: '0.0.0.0',
820
+ onlineMode: false,
821
+ motd: 'My Server'
822
+ }
823
+ ```
824
+
825
+ Cross-Play Network
826
+
827
+ ```javascript
828
+ network: {
829
+ port: 25565,
830
+ bedrockPort: 19132,
831
+ ip: '0.0.0.0',
832
+ onlineMode: false,
833
+ motd: 'Cross-Play Server'
834
+ }
835
+ ```
836
+
837
+ ---
838
+
839
+ World Configuration
840
+
841
+ Basic World
842
+
843
+ ```javascript
844
+ world: {
845
+ difficulty: 'normal',
846
+ gamemode: 'survival',
847
+ maxPlayers: 20,
848
+ viewDistance: 6,
849
+ simulationDistance: 4,
850
+ levelName: 'world'
851
+ }
852
+ ```
853
+
854
+ Hardcore Mode
855
+
856
+ ```javascript
857
+ world: {
858
+ difficulty: 'hard',
859
+ hardcore: true,
860
+ gamemode: 'survival',
861
+ maxPlayers: 10,
862
+ viewDistance: 6
863
+ }
864
+ ```
865
+
866
+ Custom Seed
867
+
868
+ ```javascript
869
+ world: {
870
+ seed: 'my-amazing-seed-12345',
871
+ levelName: 'custom_world'
872
+ }
873
+ ```
874
+
875
+ ---
876
+
877
+ Folder Structure
878
+
879
+ ```
880
+ server/
881
+ ├── plugins/ # Paper/Spigot plugins
882
+ ├── mods/ # Forge/Fabric mods
883
+ ├── addons/ # Bedrock addons
884
+ ├── world/ # World data
885
+ ├── logs/ # Server logs
886
+ ├── backups/ # Backup files
887
+ └── .java/ # Portable Java (if enabled)
888
+ ```
889
+
890
+ ---
891
+
892
+ Backup System
893
+
894
+ Enable Automatic Backups
895
+
896
+ ```javascript
897
+ backup: {
898
+ enabled: true,
899
+ interval: '24h',
900
+ path: './backups'
901
+ }
902
+ ```
903
+
904
+ Manual Backup
905
+
906
+ ```javascript
907
+ // Full backup
908
+ const fullPath = await server.backup('full');
909
+
910
+ // World only backup
911
+ const worldPath = await server.backup('world');
912
+
913
+ // Plugins only backup
914
+ const pluginsPath = await server.backup('plugins');
915
+ ```
916
+
917
+ ---
918
+
919
+ Event System
920
+
921
+ Server Events
922
+
923
+ ```javascript
924
+ server.on('ready', (info) => {
925
+ console.log('Server ready at', info.port);
926
+ });
927
+
928
+ server.on('stop', ({ code }) => {
929
+ console.log('Server stopped with code', code);
930
+ });
931
+
932
+ server.on('resource', (info) => {
933
+ console.log(`Memory: ${info.memory.used}/${info.memory.max} MB`);
934
+ });
935
+ ```
936
+
937
+ Player Events
938
+
939
+ ```javascript
940
+ server.on('player-join', (player) => {
941
+ console.log(`${player.name} joined from ${player.ip}`);
942
+ server.sendCommand(`say Welcome ${player.name}!`);
943
+ });
944
+
945
+ server.on('player-leave', (name) => {
946
+ console.log(`${name} left the game`);
947
+ });
948
+ ```
949
+
950
+ ---
951
+
952
+ Commands
953
+
954
+ Built-in Commands
955
+
956
+ ```javascript
957
+ // Send any Minecraft command
958
+ server.sendCommand('say Hello world');
959
+ server.sendCommand('time set day');
960
+ server.sendCommand('weather clear');
961
+ server.sendCommand('difficulty hard');
962
+ server.sendCommand('gamemode creative @a');
963
+ ```
964
+
965
+ Console Commands
966
+
967
+ ```javascript
968
+ // Stop server
969
+ server.sendCommand('stop');
970
+
971
+ // Save world
972
+ server.sendCommand('save-all');
973
+
974
+ // List players
975
+ server.sendCommand('list');
976
+
977
+ // Ban player
978
+ server.sendCommand('ban Notch');
979
+ ```
980
+
981
+ ---
982
+
983
+ Player Management
984
+
985
+ Get Player List
986
+
987
+ ```javascript
988
+ const players = server.getPlayers();
989
+ players.forEach(player => {
990
+ console.log(`${player.name} - Ping: ${player.ping}ms`);
991
+ });
992
+ ```
993
+
994
+ Player Count
995
+
996
+ ```javascript
997
+ const info = await server.getInfo();
998
+ console.log(`Players online: ${info.players}/${info.maxPlayers}`);
999
+ ```
1000
+
1001
+ ---
1002
+
1003
+ Cross-Play (Geyser)
1004
+
1005
+ Automatic Setup
1006
+
1007
+ ```javascript
1008
+ const server = new MinecraftServer({
1009
+ platform: 'all',
1010
+ version: '1.21.11',
1011
+ type: 'paper',
1012
+ network: {
1013
+ port: 25565,
1014
+ bedrockPort: 19132
1015
+ }
1016
+ });
1017
+ ```
1018
+
1019
+ ---
1020
+
1021
+ ViaVersion Support
1022
+
1023
+ Enable All ViaVersion Plugins
1024
+
1025
+ ```javascript
1026
+ const server = new MinecraftServer({
1027
+ version: '1.21.11',
1028
+ type: 'paper',
1029
+ enableViaVersion: true,
1030
+ enableViaBackwards: true,
1031
+ enableViaRewind: true
1032
+ });
1033
+ ```
1034
+
1035
+ What Each Plugin Does
1036
+
1037
+ Plugin Function
1038
+ ViaVersion Allows newer clients to connect to older servers
1039
+ ViaBackwards Allows older clients to connect to newer servers
1040
+ ViaRewind Adds support for 1.7.x - 1.8.x clients
1041
+
1042
+ With ViaVersion enabled, your server can accept connections from Minecraft versions 1.7.x through 1.21.x.
609
1043
 
610
1044
  ---
611
1045
 
@@ -615,14 +1049,43 @@ Enable SkinRestorer
615
1049
 
616
1050
  ```javascript
617
1051
  const server = new MinecraftServer({
618
- enableSkinRestorer: true // Auto-download and install
1052
+ enableSkinRestorer: true
619
1053
  });
620
1054
  ```
621
1055
 
622
1056
  · Auto-downloads latest SkinRestorer
623
1057
  · Fixes player skins for offline mode
624
1058
  · Works with Geyser (Bedrock players)
625
- · No manual plugin installation needed
1059
+
1060
+ ---
1061
+
1062
+ Portable Java
1063
+
1064
+ How It Works
1065
+
1066
+ ```javascript
1067
+ const server = new MinecraftServer({
1068
+ usePortableJava: true, // Download JRE to .java folder
1069
+ javaVersion: 'auto' // Auto-detect required version
1070
+ });
1071
+ ```
1072
+
1073
+ · Downloads JRE (not full JDK) ~50MB
1074
+ · Extracts to .java/jre-{version}/ in current directory
1075
+ · Auto-cleanup after 24 hours
1076
+ · No system installation required
1077
+ · Sets JAVA_HOME and PATH automatically
1078
+ · Adds MALLOC_ARENA_MAX=2 for memory efficiency
1079
+
1080
+ Java Version Requirements
1081
+
1082
+ Minecraft Version Java Version
1083
+ 1.21.x Java 21
1084
+ 1.20.x Java 17
1085
+ 1.19.x Java 17
1086
+ 1.18.x Java 17
1087
+ 1.17.x Java 16
1088
+ 1.16.x Java 8
626
1089
 
627
1090
  ---
628
1091
 
@@ -659,26 +1122,235 @@ JAVA_HOME (auto) Points to portable Java
659
1122
 
660
1123
  ---
661
1124
 
1125
+ Pterodactyl Setup
1126
+
1127
+ Installation on Pterodactyl
1128
+
1129
+ ```bash
1130
+ # Connect to your Pterodactyl server via SSH
1131
+ ssh user@your-server.com
1132
+
1133
+ # Create directory for your server
1134
+ mkdir minecraft-server
1135
+ cd minecraft-server
1136
+
1137
+ # Install Node.js (if not available)
1138
+ curl -fsSL https://deb.nodesource.com/setup_20.x | bash -
1139
+ apt install -y nodejs
1140
+
1141
+ # Install mc-headless
1142
+ npm init -y
1143
+ npm install @dimzxzzx07/mc-headless
1144
+
1145
+ # Create server script
1146
+ cat > index.js << 'EOF'
1147
+ const { MinecraftServer } = require('@dimzxzzx07/mc-headless');
1148
+
1149
+ const server = new MinecraftServer({
1150
+ version: '1.21.11',
1151
+ type: 'paper',
1152
+ usePortableJava: true,
1153
+ memory: {
1154
+ init: '2G',
1155
+ max: '4G'
1156
+ },
1157
+ network: {
1158
+ port: 25565
1159
+ }
1160
+ });
1161
+
1162
+ server.on('ready', (info) => {
1163
+ console.log(`Server ready on port ${info.port}`);
1164
+ });
1165
+
1166
+ server.start();
1167
+ EOF
1168
+
1169
+ # Run server
1170
+ node index.js
1171
+ ```
1172
+
1173
+ Pterodactyl Egg Configuration
1174
+
1175
+ If you want to create a custom Pterodactyl egg:
1176
+
1177
+ ```json
1178
+ {
1179
+ "name": "MC-Headless",
1180
+ "description": "Minecraft Headless Server Manager",
1181
+ "docker_images": {
1182
+ "node:20": "node:20"
1183
+ },
1184
+ "startup": "node /home/container/index.js",
1185
+ "environment": {
1186
+ "SERVER_VERSION": "1.21.11",
1187
+ "SERVER_TYPE": "paper",
1188
+ "MEMORY_INIT": "2G",
1189
+ "MEMORY_MAX": "4G"
1190
+ }
1191
+ }
1192
+ ```
1193
+
1194
+ ---
1195
+
1196
+ Termux Setup
1197
+
1198
+ Install in Termux
1199
+
1200
+ ```bash
1201
+ # Update packages
1202
+ pkg update && pkg upgrade
1203
+
1204
+ # Install Node.js
1205
+ pkg install nodejs
1206
+
1207
+ # Install mc-headless
1208
+ npm install -g @dimzxzzx07/mc-headless
1209
+
1210
+ # Create server directory
1211
+ mkdir minecraft-server
1212
+ cd minecraft-server
1213
+
1214
+ # Create server script
1215
+ cat > server.js << 'EOF'
1216
+ const { MinecraftServer } = require('@dimzxzzx07/mc-headless');
1217
+
1218
+ const server = new MinecraftServer({
1219
+ platform: 'java',
1220
+ version: '1.21.11',
1221
+ type: 'paper',
1222
+ usePortableJava: true,
1223
+ memory: {
1224
+ init: '512M',
1225
+ max: '2G'
1226
+ }
1227
+ });
1228
+
1229
+ server.start();
1230
+ EOF
1231
+
1232
+ # Run server
1233
+ node server.js
1234
+ ```
1235
+
1236
+ Termux Optimizations
1237
+
1238
+ ```javascript
1239
+ const server = new MinecraftServer({
1240
+ version: '1.21.11',
1241
+ type: 'paper',
1242
+ usePortableJava: true,
1243
+ memory: {
1244
+ init: '512M',
1245
+ max: '2G'
1246
+ },
1247
+ world: {
1248
+ viewDistance: 4,
1249
+ simulationDistance: 3,
1250
+ maxPlayers: 10
1251
+ }
1252
+ });
1253
+ ```
1254
+
1255
+ ---
1256
+
662
1257
  Troubleshooting
663
1258
 
664
1259
  Common Issues
665
1260
 
666
1261
  Issue Cause Solution
667
- Java not found No system Java Enable usePortableJava: true
668
- High memory usage Too many chunks Reduce viewDistance
669
- High CPU usage Stats interval too low Increase statsInterval to 60000
1262
+ Java not found Java not installed Enable usePortableJava: true
1263
+ ENOSPC: no space left Disk full Free disk space, reduce memory
1264
+ Download failed: 302 URL redirect Using Node.js downloader (fixed in v2.2.0)
1265
+ Port already in use Another server running Change port number
670
1266
  Plugin corrupt Bad download Delete plugin and restart
671
- Port in use Another server Change port number
1267
+ High CPU usage Too many chunks Reduce viewDistance to 4
1268
+ Out of memory RAM too low Reduce max memory or add RAM
1269
+
1270
+ Disk Space Issues
1271
+
1272
+ ```bash
1273
+ # Check disk usage
1274
+ df -h
1275
+
1276
+ # Clean up old Java files
1277
+ rm -rf .java/jre-*
672
1278
 
673
- Check Logs
1279
+ # Clean npm cache
1280
+ npm cache clean --force
1281
+
1282
+ # Remove old backups
1283
+ rm -rf backups/*
1284
+ ```
1285
+
1286
+ Debug Mode
1287
+
1288
+ ```javascript
1289
+ const server = new MinecraftServer({
1290
+ silentMode: false, // Disable silent mode to see all logs
1291
+ statsInterval: 5000 // Update stats every 5 seconds
1292
+ });
1293
+ ```
1294
+
1295
+ Logs Location
1296
+
1297
+ ```bash
1298
+ # Server logs are piped directly to console
1299
+ # Check console output for errors
1300
+
1301
+ # Java portable logs
1302
+ ls -la .java/
1303
+ ```
1304
+
1305
+ ---
1306
+
1307
+ Contributing
1308
+
1309
+ Development Setup
674
1310
 
675
1311
  ```bash
676
- # Server logs are piped directly
677
- # Just look at console output
1312
+ git clone https://github.com/Dimzxzzx07/mc-headless.git
1313
+ cd mc-headless
1314
+ npm install
1315
+ npm run build
1316
+ npm test
1317
+ ```
1318
+
1319
+ Project Structure
678
1320
 
679
- # Or check cgroup stats
680
- cat /sys/fs/cgroup/memory/memory.usage_in_bytes
681
1321
  ```
1322
+ mc-headless/
1323
+ ├── src/
1324
+ │ ├── core/
1325
+ │ │ ├── MinecraftServer.ts
1326
+ │ │ ├── ConfigHandler.ts
1327
+ │ │ ├── JavaChecker.ts
1328
+ │ │ └── ServerManager.ts
1329
+ │ ├── engines/
1330
+ │ │ ├── PaperEngine.ts
1331
+ │ │ ├── VanillaEngine.ts
1332
+ │ │ ├── ForgeEngine.ts
1333
+ │ │ └── FabricEngine.ts
1334
+ │ ├── platforms/
1335
+ │ │ ├── GeyserBridge.ts
1336
+ │ │ ├── ViaVersion.ts
1337
+ │ │ └── SkinRestorer.ts
1338
+ │ └── utils/
1339
+ │ ├── Logger.ts
1340
+ │ ├── FileUtils.ts
1341
+ │ └── SystemDetector.ts
1342
+ ├── tests/
1343
+ ├── examples/
1344
+ └── README.md
1345
+ ```
1346
+
1347
+ Pull Request Process
1348
+
1349
+ 1. Fork the repository
1350
+ 2. Create feature branch
1351
+ 3. Commit changes
1352
+ 4. Push to branch
1353
+ 5. Open pull request
682
1354
 
683
1355
  ---
684
1356