Open XtoManuel opened 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
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?
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)
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.
[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 serverjavaServer.on('logout', (event: {player: string; reason: string;}) => void)
Does not run when a user logs out of the server[SUGGESTIONS]
javaServer.on('achievement', (event: {player: string; achievement: string;}) => void)
the description of the achievementjavaServer.on('death', (event: {player: string; reason: string;}) => void)
as an event to be able to log in when a player dies and the reasonjavaServer.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.