mirror of
https://github.com/danbulant/flying-squid
synced 2026-06-16 13:01:12 +00:00
Implement difficulty
* added some code to set the difficulty of the server * Add difficulty variable Added difficulty to default-settings.json changed difficulty: 0 to difficulty: serv.difficulty in -respawn.js -world.js -login.js * set server diff * added setting serv difficulty on server start in settings.js * added serv in module.exports.player=function(player, serv) in player.js and in respawn.js
This commit is contained in:
parent
e3acaf8555
commit
3b563b64ce
6 changed files with 31 additions and 11 deletions
|
|
@ -5,6 +5,7 @@
|
|||
"online-mode": true,
|
||||
"logging": true,
|
||||
"gameMode": 1,
|
||||
"difficulty": 1,
|
||||
"worldFolder":"world",
|
||||
"generation": {
|
||||
"name": "diamond_square",
|
||||
|
|
@ -14,7 +15,7 @@
|
|||
},
|
||||
"kickTimeout": 10000,
|
||||
"plugins": {
|
||||
|
||||
|
||||
},
|
||||
"modpe": false,
|
||||
"view-distance": 10,
|
||||
|
|
|
|||
|
|
@ -56,7 +56,7 @@ module.exports.player=function(player,serv,settings)
|
|||
levelType: 'default',
|
||||
gameMode: player.gameMode,
|
||||
dimension: 0,
|
||||
difficulty: 0,
|
||||
difficulty: serv.difficulty,
|
||||
reducedDebugInfo: false,
|
||||
maxPlayers: serv._server.maxPlayers
|
||||
});
|
||||
|
|
@ -183,4 +183,4 @@ module.exports.player=function(player,serv,settings)
|
|||
player.sendRestMap();
|
||||
sendChunkWhenMove();
|
||||
};
|
||||
};
|
||||
};
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ module.exports.server=function(serv)
|
|||
};
|
||||
};
|
||||
|
||||
module.exports.player=function(player){
|
||||
module.exports.player=function(player, serv){
|
||||
player.commands.add({
|
||||
base: 'gamemode',
|
||||
aliases: ['gm'],
|
||||
|
|
@ -30,4 +30,22 @@ module.exports.player=function(player){
|
|||
player.setGameMode(mode);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
player.commands.add({
|
||||
base: 'difficulty',
|
||||
aliases: ['diff'],
|
||||
info: 'Sets the difficulty level',
|
||||
usage: '/difficulty <difficulty>',
|
||||
op: true,
|
||||
parse(str){
|
||||
let results;
|
||||
if(!(results = str.match(/^([0-3])$/)))
|
||||
return false;
|
||||
return parseInt(str);
|
||||
},
|
||||
action(diff){
|
||||
serv._writeAll('difficulty', {difficulty: diff});
|
||||
serv.difficulty = diff;
|
||||
}
|
||||
});
|
||||
};
|
||||
|
|
|
|||
|
|
@ -1,11 +1,11 @@
|
|||
module.exports.player=function(player)
|
||||
module.exports.player=function(player, serv)
|
||||
{
|
||||
player._client.on("client_command", ({payload}) => {
|
||||
if(payload == 0) {
|
||||
player.behavior('requestRespawn', {}, () => {
|
||||
player._client.write("respawn",{
|
||||
dimension:0,
|
||||
difficulty:0,
|
||||
difficulty:serv.difficulty,
|
||||
gamemode:player.gameMode,
|
||||
levelType:'default'
|
||||
});
|
||||
|
|
@ -16,4 +16,4 @@ module.exports.player=function(player)
|
|||
});
|
||||
}
|
||||
});
|
||||
};
|
||||
};
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ function randomInt (low, high) {
|
|||
module.exports.server=function(serv,settings)
|
||||
{
|
||||
serv.gameMode=settings.gameMode;
|
||||
serv.difficulty=settings.difficulty;
|
||||
|
||||
async function findSpawnZone(world,initialPoint)
|
||||
{
|
||||
|
|
@ -42,4 +43,4 @@ module.exports.player=async function(player,serv)
|
|||
player._client.on('settings',({viewDistance}) => {
|
||||
player.view=viewDistance;
|
||||
});
|
||||
};
|
||||
};
|
||||
|
|
|
|||
|
|
@ -184,7 +184,7 @@ module.exports.player=function(player,serv,settings) {
|
|||
if (typeof opt.gamemode != 'undefined') player.gameMode = opt.gamemode;
|
||||
player._client.write("respawn",{
|
||||
dimension: opt.dimension || 0,
|
||||
difficulty: opt.difficulty || 0,
|
||||
difficulty: opt.difficulty || serv.difficulty,
|
||||
gamemode: opt.gamemode || player.gameMode,
|
||||
levelType:'default'
|
||||
});
|
||||
|
|
@ -213,4 +213,4 @@ module.exports.player=function(player,serv,settings) {
|
|||
if(world=="overworld") player.changeWorld(serv.overworld, {dimension: 0});
|
||||
}
|
||||
});
|
||||
};
|
||||
};
|
||||
|
|
|
|||
Loading…
Reference in a new issue