Package Exports
- cloud-core-server
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (cloud-core-server) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
☁ Cloud Core
An open-source way to run Minecraft easily on linux using JavaScript.Install
npm install cloud-core-serverThen, in the directory of your Minecraft server, make a start.js file. Here is some sample code to go in here:
const CloudCore = require('cloud-core-server');
const server = new CloudCore({
core: {
jar: 'paper-1.16.4-310.jar', //Server Jar Name
args: ['-Xmx12G', '-Xms12G'], //Server Ram
port: 25533, //Minecraft Server Port
authorization: "b2x3AqYkjT2T6F5G", //HTTP Auth COde
backups: true, //enable the backup feature (backs up the server every week (Alternatively you can do "server.backup()" after "server.start()" at the bottom to back it up immediately OR do /backup in the console))
restartTime: 10 //Time in seconds that the server will wait before restarting after a stop or /restart
},
remote: {
port: 35533 //Websocket Port
}
});
server.start();Make sure you have the latest version of NodeJS and Java
How To Start
Start a server with:
node start.jsNOTE: You MUST start a server in the directory of the server.
We advise using pm2 to manage servers.
pm2 start start.js -n creativeYou may also initiate actions on startup in the start.js file.
For example:
server.start();
server.send("say Started Server");
setTimeout(() => {
server.backup() //backs up the server into backup folder.
server.stop()
}, 10000)How To Access
Accessing a server can be done by 3 methods:
- GET request to the remote port, it will return the last 100 lines of the console.
- POST request to the remote port with stringified form data: command=about.
- Open a websocket.
Look at examples.md for code examples and example.html for how to use it with html.
Authentication
All GET & POST requests have to have a authorization header attached. You can change the code in the server settings in start.js
Authorization: Basic <auth code here>For websockets please include a authorization feild inside the request body for each command. See example.html for more.
More on websockets...
Having multiple ports can be annoying, so running the websockets through a webserver can not only orginize them but also allow secure websocket connections.
It is strongly advised that you do this since non-secure websockets can easily be found and/or sniffed.
Here is a base apache config that can be used to achieve this. It assumes you have a domain and that you can add a subdomain to that.
<IfModule mod_ssl.c>
<VirtualHost *:443>
ServerAdmin admin@site.com
ServerName minecraft.site.com
Header set Access-Control-Allow-Origin "https://site.com" # PLEASE USE THIS (Only allows connections from certain sites)
ProxyRequests off
ProxyPassMatch ^/(creative/ws)$ ws://localhost:25565/
ProxyPass /creative http://localhost:25565/
# Now websocket will be wss://server.site.com/creative/ws/
# Now GET & POST will be https://server.site.com/creative/
# Unfortunately you will have to add a new entry into this file every time you add a server.
Redirect permanent / https://site.com/ # Redirects any traffic who have found the subdomain back to your site.
# Make sure you use encryption or this whole process will be a waste of time.
# The best in my opinion is Cert Bot (google it), It works very well with apache.
SSLCertificateFile /etc/letsencrypt/live/...
SSLCertificateKeyFile /etc/letsencrypt/live/...
Include /etc/letsencrypt/options-ssl-apache.conf
</VirtualHost>
</IfModule>Updating
To update your server to the latest version of cloud core, follow these steps:
- Delete
cloud-core.js&cloud-core.json. - Make
cloud-core.jsagain and populate it with the newer version. - Make sure your
start.jsfile is right by looking at the example one in the repo. cloud-core.jsonshould create itself again and you should be updated to the latest version.
Help
To get help feel free to message me on discord Chezzer#6969.