mirror of
https://github.com/danbulant/flying-squid
synced 2026-06-16 21:11:22 +00:00
gameMode handling and better spawn point : now choose randomly in an array of points
This commit is contained in:
parent
0022f59d8c
commit
0b2967c5db
7 changed files with 28 additions and 25 deletions
3
app.js
3
app.js
|
|
@ -6,7 +6,8 @@ var options = {
|
|||
motd: settings.motd,
|
||||
'max-players': settings.maxPlayers,
|
||||
port: settings.port,
|
||||
'online-mode': settings.onlineMode
|
||||
'online-mode': settings.onlineMode,
|
||||
gameMode:settings.gameMode
|
||||
};
|
||||
|
||||
mcServer.createMCServer(options);
|
||||
|
|
|
|||
|
|
@ -3,5 +3,6 @@
|
|||
"port": 25565,
|
||||
"maxPlayers": 10,
|
||||
"onlineMode": true,
|
||||
"logging": false
|
||||
"logging": false,
|
||||
"gameMode":1
|
||||
}
|
||||
|
|
|
|||
|
|
@ -52,7 +52,6 @@
|
|||
- [player.login()](#playerlogin)
|
||||
- [player.others()](#playerothers)
|
||||
- [player.chat(message)](#playerchatmessage)
|
||||
- [player.setSpawnPoint()](#playersetspawnpoint)
|
||||
- [Low level properties](#low-level-properties)
|
||||
- [player._client](#player_client)
|
||||
- [Low level methods](#low-level-methods)
|
||||
|
|
@ -243,10 +242,6 @@ return the other players than `player`
|
|||
|
||||
sends `message` to the player
|
||||
|
||||
#### player.setSpawnPoint()
|
||||
|
||||
set the spawn point of a player
|
||||
|
||||
### Low level properties
|
||||
|
||||
#### player._client
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ function inject(serv,player)
|
|||
player._client.write('login', {
|
||||
entityId: player.entity.id,
|
||||
levelType: 'default',
|
||||
gameMode: 0,
|
||||
gameMode: player.gameMode,
|
||||
dimension: 0,
|
||||
difficulty: 0,
|
||||
reducedDebugInfo: false,
|
||||
|
|
@ -82,7 +82,7 @@ function inject(serv,player)
|
|||
{
|
||||
player._client.write('game_state_change', {
|
||||
reason: 3,
|
||||
gameMode: 0
|
||||
gameMode: player.gameMode
|
||||
});
|
||||
}
|
||||
|
||||
|
|
@ -94,7 +94,7 @@ function inject(serv,player)
|
|||
UUID: transformUuid(player._client.uuid),
|
||||
name: player.username,
|
||||
properties: [],
|
||||
gamemode: 0,
|
||||
gamemode: player.gameMode,
|
||||
ping: 1,
|
||||
hasDisplayName: true,
|
||||
displayName: player.username
|
||||
|
|
@ -109,7 +109,7 @@ function inject(serv,player)
|
|||
UUID: transformUuid(otherPlayer._client.uuid),
|
||||
name: otherPlayer.username,
|
||||
properties: [],
|
||||
gamemode: 0,
|
||||
gamemode: otherPlayer.gameMode,
|
||||
ping: 1,
|
||||
hasDisplayName: true,
|
||||
displayName: otherPlayer.username
|
||||
|
|
@ -165,7 +165,6 @@ function inject(serv,player)
|
|||
addPlayer();
|
||||
sendLogin();
|
||||
sendMap();
|
||||
player.setSpawnPoint();
|
||||
sendSpawn();
|
||||
sendInitialPosition();
|
||||
|
||||
|
|
|
|||
11
lib/playerPlugins/settings.js
Normal file
11
lib/playerPlugins/settings.js
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
module.exports=inject;
|
||||
|
||||
function randomInt (low, high) {
|
||||
return Math.floor(Math.random() * (high - low) + low);
|
||||
}
|
||||
|
||||
function inject(serv,player)
|
||||
{
|
||||
player.gameMode=serv.gameMode;
|
||||
player.spawnPoint=serv.spawnPoints[randomInt(0,serv.spawnPoints.length)];
|
||||
}
|
||||
|
|
@ -1,13 +0,0 @@
|
|||
var vec3 = require("vec3");
|
||||
|
||||
module.exports=inject;
|
||||
|
||||
function inject(serv,player)
|
||||
{
|
||||
function setSpawnPoint()
|
||||
{
|
||||
player.spawnPoint=new vec3(6,51,6);
|
||||
}
|
||||
|
||||
player.setSpawnPoint=setSpawnPoint;
|
||||
}
|
||||
9
lib/serverPlugins/settings.js
Normal file
9
lib/serverPlugins/settings.js
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
var vec3=require("vec3");
|
||||
|
||||
module.exports=inject;
|
||||
|
||||
function inject(serv,settings)
|
||||
{
|
||||
serv.gameMode=settings.gameMode;
|
||||
serv.spawnPoints=[new vec3(6,51,6),new vec3(3,51,6),new vec3(8,51,6)];
|
||||
}
|
||||
Loading…
Reference in a new issue