Solved Not sure how this isn't working, unless I'm dumb :p

Discussion in 'Plugin Development' started by fudool8, May 15, 2014.

Thread Status:
Not open for further replies.
  1. Offline

    fudool8

    Alright, so I'm having a problem with some output.

    I have this for a stand-alone class:

    Code:java
    1. public static void main(String[] args) {
    2. String target = "EhChris";
    3. String commandLabel = "pr EhChris -s -lvl5";
    4. String command = "pokegive " + target + " ";
    5. StringBuilder builder = new StringBuilder();
    6. builder.append(command);
    7. if (commandLabel.contains("-s")) {
    8. builder.append("S");
    9. }
    10. if (commandLabel.contains("-lvl")) {
    11. String level = commandLabel.replace(target, "").replaceAll("[^0-9]+", "");
    12. builder.append(" lvl" + level);
    13. }
    14. System.out.println(builder.toString());
    15. }


    And I have an output as such:

    pokegive EhChris S lvl5

    Which is what I'm looking for. However, when I run my plugin with this code:

    Code:java
    1. else if(args.length > 0) {
    2. if (Bukkit.getServer().getPlayer(args[0]) != null) {
    3. Player targetPlayer = Bukkit.getServer().getPlayer(args[0]);
    4. String target = targetPlayer.getName();
    5. String command = "pokegive " + target + " " + pokemon + " ";
    6. String commandnl = "pokegive " + target + " " + pokemonnl + " ";
    7. StringBuilder builder = new StringBuilder();
    8. if (use.contains("-nl")) {
    9. builder.append(commandnl);
    10. if (use.contains("-s")) {
    11. builder.append("S");
    12. }
    13. if (use.contains("-lvl")) {
    14. String level = commandLabel.replace(target, "").replaceAll("[^0-9]+", "");
    15. builder.append(" lvl" + level);
    16. }
    17. Bukkit.dispatchCommand(Bukkit.getConsoleSender(), builder.toString());
    18. Bukkit.broadcastMessage(ChatColor.RED + builder.toString());
    19. builder.setLength(0);
    20. }
    21. else {
    22. builder.append(command);
    23. if (use.contains("-s")) {
    24. builder.append("S");
    25. }
    26. if (use.contains("-lvl")) {
    27. String level = commandLabel.replace(target, "").replaceAll("[^0-9]+", "");
    28. builder.append(" lvl" + level);
    29. }
    30. Bukkit.dispatchCommand(Bukkit.getConsoleSender(), builder.toString());
    31. Bukkit.broadcastMessage(ChatColor.RED + builder.toString());
    32. builder.setLength(0);
    33. }
    34. }
    35. }
    36. }


    Even with the command "/pr EhChris lvl5 S" all I'm getting is:

    pokegive EhChris randompoke

    I'm not getting the correct appends, and I'm not sure why. Is this a Bukkit thing? How would I get around it? Open to ideas.
     
  2. Offline

    CarPet

    I have absolutely no idea what I am reading here, the indentation is horrid though...
     
Thread Status:
Not open for further replies.

Share This Page