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

Illegal argument exception for boolean type #18

Closed
ThaBalla1148 opened this issue Jun 15, 2016 · 2 comments
Closed

Illegal argument exception for boolean type #18

ThaBalla1148 opened this issue Jun 15, 2016 · 2 comments

Comments

@ThaBalla1148
Copy link

Creating a command with a boolean as an argument does not work.

Example:

public class MyCommandExecutor extends CommandExecutor {
        public void test(boolean t) {
            console.log(String.valueOf(t));
        }
    }
@ThaBalla1148
Copy link
Author

ThaBalla1148 commented Jun 15, 2016

This part of exeCommand(String command) does not account for a boolean:

// attempt to convert arguments to numbers. If the conversion does not work, keep the argument as a string.
        Object[] args = null;
        if (sArgs != null) {
            args = new Object[sArgs.length];
            for (int i = 0; i < sArgs.length; i++) {
                String s = sArgs[i];
                try {
                    int j = Integer.parseInt(s);
                    args[i] = j;
                } catch (NumberFormatException e) {
                    try {
                        float f = Float.parseFloat(s);
                        args[i] = f;
                    } catch (NumberFormatException e2) {
                        args[i] = s;
                    }
                }
            }
        }

I'm actually looking into rewriting and fixing this code.

@ThaBalla1148
Copy link
Author

Fixed in pull request #19

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

2 participants