Sponge: Completing phase - detected runaway phase in plugin

Created on 22 May 2018  路  12Comments  路  Source: SpongePowered/Sponge

  • SpongeVanilla version: 1.12.2-7.1.0-BETA-48

I have implemented new things to the plugin CommandUtils. One new thing is the

/cmdUtils execute if <condition_cmd> <command>

It executes the command if condition_command returns CommandsResult.SUCCESS.
One command which does this with the balance of the player is

/cmdUtils has money <player> <amount>

which returns success if the player has more than the specified amount.

This is the config:

aliases {
    "wealth {0}" {
        commands=[
            """*cu execute if "*cu has money {0} 12" "internal_wealth_1 {0}"""",
            """*cu execute if not "*cu has money {0} 12" "*say {0} is broke!""""
        ]
        permission=""
    }
    "internal_wealth_1 {0}" {
        commands=[
            "*say {0} has a little money",
            """*cu execute if "*cu has money {0} 25" "*say and even a bit more!""""
        ]
        permission=admin
    }
}

{0} is an argument, here for a player name. It is placed into the executed command(has money).

/wealth KitCrafty first checks if the player has more than 12 money. If that's true, it executes the internal command which can only be executed by the ones which have the admin permission. This is also true here because of the * which executes a command as the console.
In the internal command a message is broadcasted and another check is performed. If the player has more than 25 money, and even a bit more! is appended.

I hope you can understand what's going on. If not, please ask.

Now the error from Sponge, with KitCrafty having 30 money:
https://gist.github.com/randombyte-developer/c771a419b6500f205922d3b8cce055ac

This error doesn't happen when the command is executed from the console.
It seems like Sponge doesn't like executing commands in other CommandExecutors.

Compiled plugin: https://github.com/randombyte-developer/command-utils/releases/tag/v2.0-pre
it needs an economy plugin and PlaceolderAPI.
Source: https://github.com/randombyte-developer/command-utils

Edit1: This doesn't happen on SV-BETA-22.

command bug 1.12

All 12 comments

So I worked around this issue like I have done with other similar problems:

Task.builder()
  .delayTicks(1)
  .execute { /*execute the command in here and then give the command result in a callback to allow other methods to react to the result*/ }
  .submit(plugin)

@randombyte-developer Does this occur when using the Vanilla execute commands? If not, I wonder what's different.

I don't know. Will test.

But the error doesn't happen when the command is executed from the console.

/execute KitCrafty ~ ~ ~ say Hi
/execute KitCrafty ~ ~ ~ execute Kitcrafty ~ ~ ~ say Hi

both work without any error. I think especially the second one is the case I am replicating with CommandUtils. Maybe Sponge doesn't track the executed commands in the /execute command in the same way as it does with CommandManager#proccess()?

I can't reproduce this with CommandUtils 2.0.5 on SpongeForge 3148.

Actually, I think I'm getting an issue with PlaceholderAPI that's keeping me from accurately reproducing this. I'll try and get that fixed.

@Jbyoshi I've implemented the above mentioned workaround with the scheduler into command utils. I should setup a test repo.

Test repo: https://github.com/randombyte-developer/sponge-common-issue-1922

Just clone and run the plugin.

The command /test <i> wants an integer which sets how often the command calls itself.

The numbers 0, 1, 2 worked. 3 threw the runaway phase error

This would be a tricky one. It's not showing up on any versions in my development environment, but it shows up every time when I run it in production (using a JAR from the Sponge website). Looks like it's time for me to get down and dirty with the remote debugger.

Turns out, it's all about recursion. /test 7 is guaranteed to blow up for every CommandExecutor, as long as verbose = true is set in config/sponge/global.conf.

https://github.com/SpongePowered/SpongeCommon/blob/0c66655b02da00af4c73ab5550d53b5f66e5989a/src/main/java/org/spongepowered/common/event/tracking/PhaseTracker.java#L197-L201

@gabizou Could you take a look at this?

I think we can expect then that command states can be re-entrant.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

me4502 picture me4502  路  5Comments

randombyte-developer picture randombyte-developer  路  5Comments

gabizou picture gabizou  路  5Comments

TBlueF picture TBlueF  路  5Comments

therealmikz picture therealmikz  路  4Comments