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

Completing phase - detected runaway phase in plugin #1922

Open
randombyte-developer opened this issue May 22, 2018 · 12 comments
Open

Completing phase - detected runaway phase in plugin #1922

randombyte-developer opened this issue May 22, 2018 · 12 comments
Labels
system: command type: bug Something isn't working version: 1.12 (u) API: 7 (unsupported since May 21st 2021)

Comments

@randombyte-developer
Copy link

randombyte-developer commented May 22, 2018

  • 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.

@limbo-app limbo-app added the status: needs triage This label is automatically applied to new issues and pull requests to indicate they require triage label May 22, 2018
@randombyte-developer
Copy link
Author

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 added a commit to randombyte-developer/command-utils that referenced this issue May 24, 2018
@ryantheleach
Copy link
Contributor

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

@randombyte-developer
Copy link
Author

I don't know. Will test.

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

@randombyte-developer
Copy link
Author

/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()?

@JBYoshi JBYoshi added type: bug Something isn't working system: command version: 1.12 (u) API: 7 (unsupported since May 21st 2021) and removed status: needs triage This label is automatically applied to new issues and pull requests to indicate they require triage labels Jun 5, 2018
@JBYoshi
Copy link
Member

JBYoshi commented Jun 5, 2018

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

@JBYoshi
Copy link
Member

JBYoshi commented Jun 5, 2018

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.

@randombyte-developer
Copy link
Author

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

@randombyte-developer
Copy link
Author

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

@JBYoshi
Copy link
Member

JBYoshi commented Jun 9, 2018

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.

@JBYoshi
Copy link
Member

JBYoshi commented Jun 9, 2018

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?

@gabizou
Copy link
Member

gabizou commented Jun 9, 2018

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

@ryantheleach
Copy link
Contributor

Definitely considering https://minecraft.gamepedia.com/Function

randombyte-developer added a commit to randombyte-developer/command-utils that referenced this issue Jun 27, 2018
- Fixed workaround for SpongePowered/Sponge#1922, the commands got out of order
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
system: command type: bug Something isn't working version: 1.12 (u) API: 7 (unsupported since May 21st 2021)
Projects
None yet
Development

No branches or pull requests

5 participants