EndstoneMC / endstone

Endstone - High-level Plugin API for Bedrock Dedicated Servers (BDS), in both Python and C++.
http://endstone.dev/
Apache License 2.0
267 stars 24 forks source link

[bug] ScriptEvent not being registered properly #79

Closed syylaxx closed 1 month ago

syylaxx commented 1 month ago

Description Using self.server.dispatch_command() with scheduler doesnt result in actual scriptEvent.

To Reproduce Use this code below, and set a scheduler. I run this every 5 seconds, 100 Minecraft-Ticks.

def interval(self) -> None:
    for player in self.server.online_players:
        playerPings = dumps([
            { "playerId": player.id, "ping": player.ping }
            for player in self.server.online_players
        ])

    if self.server.online_players:
        player = self.server.online_players[0]

        self.server.dispatch_command(player, f'scriptEvent PlayerInformation:ping {playerPings}')

Expected behavior Triggering scriptEventReceiveEvent in Minecraft Script API.

Screenshots: image

When running /rename Console logs an Error due to it executing scriptevent. scriptEvent ran with scheduler doesnt output error "ASDASD".

Details:

Additional context Console sends a message whenever the commands should be performed but Script API doesnt receive ScriptEventMessage. For example when running scriptEvent on "on_command", scriptEvent works perfectly fine. Using scheduler doesnt.

wu-vincent commented 1 month ago

Have you checked the return value of dispatch_command? It could be that the player doesn't have the permission to run the /scriptevent command. In which case I suggest using the execute as command to run it. See the solution here: https://github.com/EndstoneMC/endstone/issues/64.

syylaxx commented 1 month ago

I didn't check the return value. But whenever you try running a scriptEvent as a player without op. It sends a error message "You do not have permission to use that command". In the screenshot I sent, we can see that it says it performed scriptEvent. I will try using execute as soon as I will hop on.

syylaxx commented 1 month ago

Update: i had one mistake in my command: you cannot send a message stating with [] without quotes... Works how it should, so my mistake.