Solved Weird StackTrace, Please Help <3

Discussion in 'Plugin Development' started by Monkey_Swag, Jun 25, 2014.

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

    Monkey_Swag

    I'm getting this really weird stacktrace that I can't seem to figure out. Please help.
    Stacktrace: http://prntscr.com/3wjjts

    Main.java:
    Code:java
    1. package me.Monkey_Swag.McCommon;
    2.  
    3.  
    4. import me.Monkey_Swag.McCommon.cmds.Banning;
    5. import me.Monkey_Swag.McCommon.cmds.Help;
    6. import me.Monkey_Swag.McCommon.cmds.Kick;
    7. import me.Monkey_Swag.McCommon.cmds.Kits;
    8. import me.Monkey_Swag.McCommon.cmds.List;
    9. import me.Monkey_Swag.McCommon.cmds.Mute;
    10. import me.Monkey_Swag.McCommon.cmds.Teleportation;
    11. import me.Monkey_Swag.McCommon.events.PlayerChat;
    12. import me.Monkey_Swag.McCommon.events.PlayerLogin;
    13.  
    14. import org.bukkit.plugin.PluginManager;
    15. import org.bukkit.plugin.java.JavaPlugin;
    16.  
    17. public class Main extends JavaPlugin{
    18.  
    19. public void onEnable(){
    20. getCommand("list").setExecutor(new List());
    21. getCommand("who").setExecutor(new List());
    22. getCommand("help").setExecutor(new Help());
    23. getCommand("ban").setExecutor(new Banning());
    24. getCommand("unban").setExecutor(new Banning());
    25. getCommand("kick").setExecutor(new Kick());
    26. getCommand("tp").setExecutor(new Teleportation());
    27. getCommand("mute").setExecutor(new Mute());
    28. getCommand("kit").setExecutor(new Kits());
    29.  
    30. PluginManager pm = getServer().getPluginManager();
    31. pm.registerEvents(new PlayerLogin(), this);
    32. pm.registerEvents(new PlayerChat(), this);
    33. }
    34.  
    35. }
    36.  


    Kits.java:
    Code:java
    1. package me.Monkey_Swag.McCommon.cmds;
    2.  
    3. import org.bukkit.Material;
    4. import org.bukkit.command.Command;
    5. import org.bukkit.command.CommandExecutor;
    6. import org.bukkit.command.CommandSender;
    7. import org.bukkit.enchantments.Enchantment;
    8. import org.bukkit.entity.Player;
    9. import org.bukkit.inventory.ItemStack;
    10. import org.bukkit.inventory.PlayerInventory;
    11. import org.bukkit.potion.Potion;
    12. import org.bukkit.potion.PotionType;
    13.  
    14. public class Kits implements CommandExecutor{
    15.  
    16. public boolean onCommand(CommandSender sender, Command cmd, String arg2, String[] args) {
    17. if(!(sender instanceof Player)){
    18. sender.sendMessage("§4PLAYERS ONLY!");
    19. return true;
    20. }
    21. Player p = (Player) sender;
    22. if(cmd.getName().equalsIgnoreCase("kit")){
    23. if(args.length == 0){
    24. if(p.hasPermission("hc.default")){
    25. p.sendMessage("§cAvailable Kits: " + "§7PvP, Starter");
    26. return true;
    27. }
    28. if(args.length == 1){
    29. if(args[0].equalsIgnoreCase("pvp")){
    30. PlayerInventory pi = p.getInventory();
    31. pi.setItem(0, new ItemStack(Material.IRON_HELMET));
    32. pi.setItem(1, new ItemStack(Material.IRON_CHESTPLATE));
    33. pi.setItem(2, new ItemStack(Material.IRON_LEGGINGS));
    34. pi.setItem(3, new ItemStack(Material.IRON_HELMET));
    35. ItemStack dsword = new ItemStack(Material.DIAMOND_SWORD);
    36. dsword.addEnchantment(Enchantment.DAMAGE_ALL, 1);
    37. pi.setItem(4, new ItemStack(dsword));
    38. Potion strp2 = new Potion(PotionType.STRENGTH, 2);
    39. pi.addItem(strp2.toItemStack(1));
    40. Potion swp2 = new Potion(PotionType.SPEED, 2);
    41. pi.addItem(swp2.toItemStack(1));
    42. }
    43. }
    44. }
    45. }
    46.  
    47. return false;
    48. }
    49.  
    50. }
    51.  
     
  2. Offline

    MCForger

    Monkey_Swag
    Did you define the command kit in your plugin.yml?

    Monkey_Swag
    Also for these lines:
    Code:java
    1. getCommand("list").setExecutor(new List());
    2. getCommand("who").setExecutor(new List());

    You could just do this:
    Code:java
    1. List lists = new List();
    2. getCommand("who").setExecutor(lists);
    3. getCommand("list").setExecutor(lists);


    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 9, 2016
  3. Offline

    Monkey_Swag

    MCForger oh thanks for that
    and here is the plugin.yml (without the permissions):
    Code:java
    1. name: McCommon
    2. main: me.Monkey_Swag.McCommon.Main
    3. version: 0.1
    4. description: Useful plugins for a Minecraft server!
    5. commands:
    6. kit:
    7. description: see the kits or get a kit!
    8. unmute:
    9. description: unmute a player!
    10. mute:
    11. description: mute a player!
    12. tp:
    13. description: teleport to a player!
    14. ban:
    15. description: ban someone!
    16. kick:
    17. description: kick someone!
    18. unban:
    19. description: unban someone !
    20. list:
    21. description: See a list of who's online!
    22. who:
    23. description: See a list of who's online!
    24. help:
    25. description: A list of helpful commands!
     
  4. Offline

    MCForger

    Monkey_Swag
    Try re-exporting and seeing if the error still occurs. Cause the StackTrace points to an empty line.
     
  5. Offline

    Monkey_Swag

    MCForger I did, and it still says line 29
     
  6. Offline

    HeadGam3z

    Monkey_Swag
    Remove the empty line and see what stack-trace you get.
     
  7. Offline

    MCForger

    Monkey_Swag
    Can I see any of your other command classes just to compare something?
     
  8. Offline

    Monkey_Swag

    HeadGam3z still says line 29
    MCForger
    Banning.java:
    Code:java
    1. package me.Monkey_Swag.McCommon.cmds;
    2.  
    3. import me.Monkey_Swag.McCommon.utils.EssentialsUtils;
    4.  
    5. import org.bukkit.Bukkit;
    6. import org.bukkit.OfflinePlayer;
    7. import org.bukkit.command.Command;
    8. import org.bukkit.command.CommandExecutor;
    9. import org.bukkit.command.CommandSender;
    10. import org.bukkit.entity.Player;
    11.  
    12. public class Banning implements CommandExecutor{
    13.  
    14. @SuppressWarnings("deprecation")
    15. public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
    16. if(cmd.getName().equalsIgnoreCase("ban")){
    17. if(sender.hasPermission("hc.ban")){
    18. if(args.length < 1){
    19. sender.sendMessage("§4Usage: /ban {player}");
    20. return true;
    21. }
    22. Player target = sender.getServer().getPlayer(args[0]);
    23. if(target == null){
    24. sender.sendMessage("§4" + args[0] + " is not online!");
    25. return true;
    26. } else {
    27. Bukkit.broadcastMessage("§7" + target.getName() + " has been banned by " + sender.getName());
    28. target.kickPlayer("§aYou have been banned by " + sender.getName() + " for " + EssentialsUtils.getMessage(args, 1));
    29. target.setBanned(true);
    30. return true;
    31. }
    32. } else {
    33. sender.sendMessage("§4You do not have permission to perform this command!");
    34. return true;
    35. }
    36. }
    37. if(cmd.getName().equalsIgnoreCase("unban")){
    38. if(sender.hasPermission("hc.unban")){
    39. if(args.length < 1){
    40. sender.sendMessage("§4Usage: /unban {player}");
    41. return true;
    42. }
    43. OfflinePlayer target = sender.getServer().getOfflinePlayer(args[0]);
    44. Bukkit.broadcastMessage("§7" + target.getName() + " has been unbanned by " + sender.getName());
    45. target.setBanned(false);
    46. return true;
    47. }
    48. } else {
    49. sender.sendMessage("§4You do not have permission to perform this command!");
    50. return true;
    51. }
    52. return false;
    53. }
    54. }
    55.  


    no one seems to really know, I've been coding sfor 7 months, I normally know what to do in these situations, but this seems kinda weird to me. Maybe @xTrollxDudex or Garris0n know what to do :S

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 9, 2016
  9. Offline

    Searchndstroy

    Did you register all your commands in plugin.yml?
    Check and add any you missed.
     
  10. Offline

    AoH_Ruthless

    Monkey_Swag
    Me thinks your stacktrace is not updated.

    Recompile the plugin.
    Restart your server so you have a fresh, empty log (Not reload).

    Post the full stacktrace again, and the updated Main class.
     
  11. Monkey_Swag
    Try refreshing your project (highlight the project folder in your IDE and press F5) and export again.
     
  12. Offline

    iiHeroo

    Also please post it on pastebin or pastie, much easier to read.
     
  13. Offline

    AoH_Ruthless

    iiHeroo
    The stacktrace is easy to read on printscr ... it's white on black (well I guess it's easy to read for me). If you meant the code, java syntax on these forums is pretty formidable imo
     
    Monkey_Swag likes this.
  14. Offline

    Monkey_Swag

    The Gaming Grunts AoH_Ruthless did both of these, same exact stacktrace, same exact code....
    Main.java:
    Code:java
    1. package me.Monkey_Swag.McCommon;
    2.  
    3.  
    4. import me.Monkey_Swag.McCommon.cmds.Banning;
    5. import me.Monkey_Swag.McCommon.cmds.Help;
    6. import me.Monkey_Swag.McCommon.cmds.Kick;
    7. import me.Monkey_Swag.McCommon.cmds.Kits;
    8. import me.Monkey_Swag.McCommon.cmds.List;
    9. import me.Monkey_Swag.McCommon.cmds.Mute;
    10. import me.Monkey_Swag.McCommon.cmds.Teleportation;
    11. import me.Monkey_Swag.McCommon.events.PlayerChat;
    12. import me.Monkey_Swag.McCommon.events.PlayerLogin;
    13.  
    14. import org.bukkit.plugin.PluginManager;
    15. import org.bukkit.plugin.java.JavaPlugin;
    16.  
    17. public class Main extends JavaPlugin{
    18.  
    19. public void onEnable(){
    20. getCommand("list").setExecutor(new List());
    21. getCommand("who").setExecutor(new List());
    22. getCommand("help").setExecutor(new Help());
    23. getCommand("ban").setExecutor(new Banning());
    24. getCommand("unban").setExecutor(new Banning());
    25. getCommand("kick").setExecutor(new Kick());
    26. getCommand("tp").setExecutor(new Teleportation());
    27. getCommand("mute").setExecutor(new Mute());
    28. getCommand("kit").setExecutor(new Kits());
    29.  
    30. PluginManager pm = getServer().getPluginManager();
    31. pm.registerEvents(new PlayerLogin(), this);
    32. pm.registerEvents(new PlayerChat(), this);
    33. }
    34.  
    35. }
    36.  
     
  15. Offline

    AoH_Ruthless

    Monkey_Swag
    You didn't actually fix what MCForger said; why are you creating two instances of the same command? Makes 0 sense and actually might result in future errors. Fix that first.

    Try debugging.
    i.e:

    System.out.println(if null, print null, otherwise print not null, etc) for one of your commands, and for the PluginManager.
     
  16. Offline

    Monkey_Swag

    AoH_Ruthless oops....
    I still get the same stacktrace though
    Updated Main.java class:
    Code:java
    1. package me.Monkey_Swag.McCommon;
    2.  
    3.  
    4. import me.Monkey_Swag.McCommon.cmds.Banning;
    5. import me.Monkey_Swag.McCommon.cmds.Help;
    6. import me.Monkey_Swag.McCommon.cmds.Kick;
    7. import me.Monkey_Swag.McCommon.cmds.Kits;
    8. import me.Monkey_Swag.McCommon.cmds.List;
    9. import me.Monkey_Swag.McCommon.cmds.Mute;
    10. import me.Monkey_Swag.McCommon.cmds.Teleportation;
    11. import me.Monkey_Swag.McCommon.events.PlayerChat;
    12. import me.Monkey_Swag.McCommon.events.PlayerLogin;
    13.  
    14. import org.bukkit.plugin.PluginManager;
    15. import org.bukkit.plugin.java.JavaPlugin;
    16.  
    17. public class Main extends JavaPlugin{
    18.  
    19. List lists = new List();
    20. Banning banning = new Banning();
    21.  
    22. public void onEnable(){
    23. getCommand("list").setExecutor(lists);
    24. getCommand("who").setExecutor(lists);
    25. getCommand("help").setExecutor(new Help());
    26. getCommand("ban").setExecutor(banning);
    27. getCommand("unban").setExecutor(banning);
    28. getCommand("kick").setExecutor(new Kick());
    29. getCommand("tp").setExecutor(new Teleportation());
    30. getCommand("mute").setExecutor(new Mute());
    31. getCommand("kit").setExecutor(new Kits());
    32.  
    33. PluginManager pm = getServer().getPluginManager();
    34. pm.registerEvents(new PlayerLogin(), this);
    35. pm.registerEvents(new PlayerChat(), this);
    36. }
    37.  
    38. }
    39.  
     
  17. Monkey_Swag
    What line # is it pointing to this time?
     
    Garris0n likes this.
  18. Offline

    Garris0n

    The stack trace is identical?
     
  19. Offline

    Monkey_Swag

  20. Offline

    Garris0n

    And you have registered the "tp" command in your plugin.yml?
     
  21. Garris0n
    From his previous post:

    Code:
    name: McCommon
    main: me.Monkey_Swag.McCommon.Main
    version: 0.1
    description: Useful plugins for a Minecraft server!
    commands:
        kit:
          description: see the kits or get a kit!
        unmute:
          description: unmute a player!
        mute:
          description: mute a player!
        tp:
          description: teleport to a player!
        ban:
          description: ban someone!
        kick:
          description: kick someone!
        unban:
          description: unban someone !
        list:
          description: See a list of who's online!
        who:
          description: See a list of who's online!
        help:
          description: A list of helpful commands!
     
    Monkey_Swag likes this.
  22. The Gaming Grunts He's definitely not doing something right.
    Monkey_Swag What IDE do you use? Check your output, make sure you are refreshing the project. Go to the plugins folder of your server and check if the date modified on the .jar was as recent as you exported. Stop and Start the server, don't reload. Make sure no other plugins by you are in the plugins folder(seeing as how you used Main as the class name for that plugin, you probably do the same for others and the package name in the error could be the same).

    Even go an extra step and DECOMPILE the plugin.jar and look at the line number there. May not be the best result but could help.
     
  23. Offline

    Monkey_Swag

    HeyAwesomePeople I'm using Eclipse, I am refreshing it, and yes, it is exporting correctly, I deleted all my plugins except McCommon.
     
  24. Offline

    Garris0n

    I guess double check with an if statement to see what's null?
     
  25. Monkey_Swag Same error on same line?
    Contact me on Skype: heyawesomepeople41
    and send me over the plugin.jar
     
  26. Offline

    Monkey_Swag

    Problem Solved, thanks
     
Thread Status:
Not open for further replies.

Share This Page