Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bugs and suggestions #41

Open
XtoMHA96 opened this issue Sep 24, 2021 · 4 comments
Open

Bugs and suggestions #41

XtoMHA96 opened this issue Sep 24, 2021 · 4 comments

Comments

@XtoMHA96
Copy link

XtoMHA96 commented Sep 24, 2021

[BUGS]

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

  • javaServer.stop(): void Does not stop the server correctly. We are currently using javaServer.send('stop') to stop the server properly.
  • javaServer.on('stop', () => void) It is not executed when the server is stopped with javaServer.stop() or with javaServer.send('stop')
  • javaServer.on('login', (event: {player: string; ip: string;}) => void) It is not executed when a user logs in to the server
  • javaServer.on('logout', (event: {player: string; reason: string;}) => void) Does not run when a user logs out of the server

[SUGGESTIONS]

  • Add to javaServer.on('achievement', (event: {player: string; achievement: string;}) => void) the description of the achievement
  • Add javaServer.on('death', (event: {player: string; reason: string;}) => void) as an event to be able to log in when a player dies and the reason
  • Add javaServer.restart(): void to be able to restart the server in case of internal problems. Something similar to doing javaServer.stop(): void and javaServer.start(): void, but in less code.
@garrettjoecox
Copy link
Owner

garrettjoecox commented Sep 29, 2021

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

@XtoMHA96
Copy link
Author

XtoMHA96 commented Oct 3, 2021

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
Copy link
Owner

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
Copy link

iojanis commented Apr 27, 2022

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants