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

/hunger command treats second argument as both player and value. #146

Closed
James103 opened this issue May 20, 2020 · 0 comments
Closed

/hunger command treats second argument as both player and value. #146

James103 opened this issue May 20, 2020 · 0 comments

Comments

@James103
Copy link
Contributor

It appears that when the /hunger command is used with two arguments, the second argument is treated as both the player and the value. This causes the command to break if used with two arguments, effectively preventing it from being used this way. The wiki lists the command syntax to be /hunger [player] <value>, but /hunger <value> works and sets the hunger value for the executor.

This behavior is caused by the following code:

EntityPlayerMP playerToActOn = args.length >= 2 ? getPlayer(server, commandSender, args[1]) : getCommandSenderAsPlayer(commandSender);
int maxHunger = AppleCoreAPI.accessor.getMaxHunger(playerToActOn);
int newHunger = args.length >= 2 ? parseInt(args[1], 0, maxHunger) : parseInt(args[0], 0, maxHunger);

The fix is as simple as changing the first args[1] on line 43 of the above code to args[0].

squeek502 added a commit that referenced this issue May 20, 2020
Fix #146: Conflicting arguments in /hunger command
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

1 participant