Java Plugin Help

Discussion in 'Plugin Development' started by moo3oo3oo3, Aug 22, 2014.

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

    moo3oo3oo3

    When ever I run the command I get "An internal error occurred while attempting to preform this command" Can someone please tell what's wrong in the code that's causing that?
    Code:java
    1. package me.moo3oo3oo3;
    2.  
    3. import org.bukkit.Bukkit;
    4. import org.bukkit.ChatColor;
    5. import org.bukkit.Location;
    6. import org.bukkit.Sound;
    7. import org.bukkit.command.Command;
    8. import org.bukkit.command.CommandSender;
    9. import org.bukkit.entity.Player;
    10. import org.bukkit.plugin.java.JavaPlugin;
    11.  
    12. public class Kowz5 extends JavaPlugin {
    13.  
    14. @Override
    15. public void onEnable() {
    16. getLogger().info("Kowz5 Loaded");
    17. }
    18.  
    19. @Override
    20. public void onDisable() {
    21. getLogger().info("Kowz5 Disabled D;");
    22. }
    23.  
    24. public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
    25. if (cmd.getName().equalsIgnoreCase(";3") && sender instanceof Player) {
    26.  
    27. Player player = (Player) sender;
    28.  
    29. int length = args.length;
    30.  
    31. if (length == 1) {
    32.  
    33. boolean playerFound = false;
    34.  
    35. for (Player playerToTroll : Bukkit.getServer().getOnlinePlayers()) {
    36. if (playerToTroll.getName().equalsIgnoreCase(args[0])) {
    37. Location location = playerToTroll.getLocation();
    38. playerToTroll.playSound(location, Sound.CAT_MEOW, 1, 0);
    39. player.sendMessage(ChatColor.GRAY + "You have successfully trolled " + playerToTroll.getName());
    40. playerFound = true;
    41. break;
    42. }
    43. }
    44.  
    45. if (playerFound == false){
    46. player.sendMessage(ChatColor.RED + args[0] + " was not found!");
    47. }
    48.  
    49. } else player.sendMessage(ChatColor.GRAY + "Incorrect aguments");
    50.  
    51. return true;
    52.  
    53. }
    54.  
    55. return false;
    56.  
    57. }
    58. }
     
  2. Offline

    JaguarJo

    Moved thread to a more appropriate forum section.
     
  3. Offline

    Gater12

    es359 likes this.
  4. Offline

    es359

    What exactly are you using the for loop for? moo3oo3oo3 Your logic doesn't make much sense.
     
  5. Offline

    PandazNWafflez

    When the player receives that message there will also be a stack trace (error) in the console. Please post it here.
     
Thread Status:
Not open for further replies.

Share This Page