garrettjoecox / scriptserver

A Minecraft server wrapper, allows for simple plugins in vanilla
GNU General Public License v3.0
68 stars 10 forks source link

Bugs and suggestions #41

Open XtoManuel opened 3 years ago

XtoManuel commented 3 years ago

[BUGS]

We are using this repository for a Minecraft server and there are several sections that do not work well for us:

[SUGGESTIONS]

garrettjoecox commented 3 years ago

Thanks for the report! What version of Minecraft are you using? Invalid regex might be the reasoning “stop” and “login” events are not firing, the current regex was tested for all flavors of 1.17 servers

There is an achievement event already, but it’s a bit flaky because the format in which achievements are logged to console is inconsistent across achievement types.

There is simply no death event because of the reasoning above, every death type in Minecraft is formatted differently and would be pretty tough to determine, you would be better off using a command block to trigger a console message somehow on death instead, I might investigate further how this can be done and put it in the docs

XtoManuel commented 3 years ago

We are using Minecraft version 1.12.2 with Forge.

These days we have tried javaServer.command (cmd: string, callback: (event: CommandEvent) => void) and it worked for us, but did javaServer.on ('command', (event: CommandEvent) => void) also works with Minecraft slash commands ? That is, if a player does /spawn, does the event recognize the command?

garrettjoecox commented 3 years ago

One of the limitations of ScriptServer is we are only able to parse messages that are logged to the console, in vanilla invalid command attempts are not logged to the console, meaning you have to use chat messages instead, so I would type into chat something like ~spawn instead of /spawn.

If forge does log invalid command attempts in the console you can parse for them with javaServer.on('console', (message: string) => void)

iojanis commented 2 years ago
server.on('console', (event) => {
    const stripped = event.match(/([\w]+).was.(.+).by.([\w]+)/)
    if (stripped) {
      server.emit('slain', {
        player: stripped[1],
        by: stripped[2],
        killer: stripped[3]
      })
    }
  })

This is what I'm using to determine the dead player, type of death and the killer. But it does not (intentional) get triggered by death not related to other players. (With one exception... using Labels with the name of a player on mobs like zombies)

I got around by creating a scoreboard objective:

server.send(
  'scoreboard objectives add killCount playerKillCount'
)

and testing for a value saved in a database (every time the 'slain' event happens)

server
    .send(
      `execute if score ${killer} killCount matches ${killCount}`,
      /Test passed/,
      /Test failed/
    )

Don't know if helpful, just wanted to dump it here.