PrismarineJS / flying-squid

Create Minecraft servers with a powerful, stable, and high level JavaScript API.
https://prismarinejs.github.io/flying-squid/
MIT License
547 stars 100 forks source link

Set max-players to 3, but managed to connect 6 players with prismarine-web-client #615

Open kf106 opened 1 year ago

kf106 commented 1 year ago

Minecraft authentication is off, and I am connecting with 3 normal and 3 incognito browsers (Brave, Chrome) from two different PCs. Here is the settings file:

const mcServer = require('flying-squid')

const orthoverse = mcServer.createMCServer({
  motd: 'The Orthoverse metaverse world',
  port: 20565,
  'max-players': 3,
  'online-mode': false,
  logging: true,
  gameMode: 0,
  difficulty: 1,
  worldFolder: 'world',
  generation: {
    name: 'orthogen',
    options: {
      seed: 100,
      version: '1.15.2',
      pregen: 6*2
    }
  },
  kickTimeout: 60000,
  checkTimoutInterval: 4000,
  plugins: {
    hengeportals: 'hengeportals',
    ethereum: 'ethereum'
  },
  modpe: false,
  'view-distance': 6,
  'player-list-text': {
    header: 'Orthoverse',
    footer: 'Voxel World'
  },
  'everybody-op': false,
  'max-entities': 100,
  version: '1.15.2'
})

console.log(orthoverse.motd)

I'll look further myself to see how max-players is used, but I'm guessing this is a bug.

kf106 commented 1 year ago

So the logging in happens in minecraft-protocol/src/server/login.js and there does not appear to be anything to check that the number of players exceeds max players.

If you add

    console.log("There are " + server.playerCount + " players and the maximum is " + server.maxPlayers)
    if (server.playerCount >= server.maxPlayers) {
      client.end('The server is full')
      return
    } 

after line 37, which says client.username = packet.username then it kicks any extra players trying to log on after the maximum.