
Security News
ECMAScript 2025 Finalized with Iterator Helpers, Set Methods, RegExp.escape, and More
ECMAScript 2025 introduces Iterator Helpers, Set methods, JSON modules, and more in its latest spec update approved by Ecma in June 2025.
minekhan-server
Advanced tools
First, install the package. Type this in your shell.
npm install minekhan-server
Then, add something like this to you code:
const express = require('express');
const app = express();
const router = express.Router();
const cors = require('cors');
app.use(cors({
origin: function(origin, callback){
return callback(null, true);
},
credentials: true
}))
let serverPort = app.listen(3000, function(){
console.log("App server is running on port 3000");
});
Now, choose the name and description of you server. Add this to your code and customize it:
const mkServer = MineKhanServer("name", "description", {
server: serverPort, //What server to use?
url: "https://server", //The URL of the server
wsurl:"wss://server", //Websocket URL of the server
thumbnail: "image URL", //(Optional) The thumbnail of the server
saveActivity:true, //(Optional) Should it add any activity to the log?
operators: ["username"], //(Optional) Who can edit blocks and use commands other people can't
loadDistance: 4 //(Optional) How many chunks to load around players? Default is 4.
})
If you want to know what the server property is for, click here.
If you want your server to have a world loaded when someone joins, you should create a room.
Room means a world.
This is how you create a room. You can customize it.
var room = mkServer.createRoom("room name", {
code: "your save code",
spawn: [x,y,z], //(Optional) Where will the players spawn when they go to this room?
canEdit:false, //(Optional) Can the players change anything in the room?
autosave:false, //(Optional) Should changes in this room be saved?
cheats:false, //(Optional) Is cheats enabled for this room? Cheats is always enabled for creative mode.
savePlayersInv:false, //(Optional) Should player data be saved when there are players in this room (this also saves position)?
resourcePacks:[], //(Optional) What resource packs should be used in this room? Items should be urls to resource packs.
settings:{ //This and everything inside are optional.
tntExplode:true,
killCmdOff:false,
dayNightCycle: false,
blocksFall: true,
attack: true,
fireSpreads: true,
weatherCycle: false,
mobSpawning: false
}
})
If you want the players to go to another room when in a specific place, for example: when players go in a portal, add this to your code and customize it:
room.addPortal("room name", coordinates)
If you want a function to be done when a player goes to a specific place, add this to your code and customize it:
room.addPortal(function(player){
//do something
}, coordinates)
Coordinates should be like this: x,y,z,x,y,z You could also add text to the room. To add text, add this to your code and customize it.
room.addText(x,y,z,"text",color,background,size)
Color should be an array with three numbers from 0 to 1.
Background should be an array with four numbers from 0 to 1.
To make a place not editable, add this to your code and customize it.
room.addUneditable(coordinates)
Coordinates should be like this: x,y,z,x,y,z
When players join this server, nothing happens, so you should send them to a room when they join. This code will do that:
mkServer.on("join", function({player}){
player.goToRoom("room name")
})
Replace room name with the name of the room you want the player to go to when they join.
Server commands are commands run on the server. These commands can only be used on your server. To add a server command, add this to your code and change some things.
mkServer.addServerCmd({
name: "command_name",
args: ["argument1","argument2" /*...*/],//(Optional) The argument names of the command
lastArgRaw:true,//(Optional) Is the last argument raw?
argValues:{argument1:["a-possible-value-for-argument1"] /*...*/}, //What types are for each argument?
info: "a description",//(Optional)
func: (args,pos,player) => {
doSomething()
},
in:"all"//(Optional, defaults to all) where is this command used? Array of room names or "all"
},
{
//Another command
//...
} /*...*/ )
split is an array of the argument values. pos is the position of the player.
To generate custom terrain, set customChunkGenerate
and customChunkPopulate
to a function on the world (room.world
). The arguments for the function is a chunk. When it is set, it will not do normal terrain generation unless the function returns true
.
Example:
room.world.customChunkGenerate = function(chunk){
for(let x=0;x<16;x++)for(let z=0;z<16;z++){
chunk.setBlock(x,0,z,mkServer.blockIds.stone)
}
}
Here is a list of functions and other things:
mkServer.getLog()
mkServer.getInfo()
mkServer.createRoom(name, options)
mkServer.getRoom(name)
mkServer.deleteRoom(name)
mkServer.save()//Saves all rooms with autosave
room.addPortal(name, x,y,z, x,y,z)
room.addUneditable(x,y,z, x,y,z)
room.world//The world instance for the room
player.send(object)//Send a packet to client
player.close()//Kicks a client
The server is used to create a websocket server that the client can connect to.
It also adds these paths to the server: /info /validateServer
This means you can't use those urls so you have to ignore them when you recieve it.
Click here to see an example
FAQs
The package for making a server on MineKhan
The npm package minekhan-server receives a total of 2 weekly downloads. As such, minekhan-server popularity was classified as not popular.
We found that minekhan-server demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
ECMAScript 2025 introduces Iterator Helpers, Set methods, JSON modules, and more in its latest spec update approved by Ecma in June 2025.
Security News
A new Node.js homepage button linking to paid support for EOL versions has sparked a heated discussion among contributors and the wider community.
Research
North Korean threat actors linked to the Contagious Interview campaign return with 35 new malicious npm packages using a stealthy multi-stage malware loader.