Whats Wrong?

Discussion in 'Plugin Development' started by ThatBox, Feb 18, 2012.

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

    ThatBox

    My code keeps saying my home was never set when I do use /sethome.
    http://pastie.org/3411194

    Code:java
    1. package box.arcation.cmd;
    2.  
    3. import java.util.HashMap;
    4.  
    5. import org.bukkit.ChatColor;
    6. import org.bukkit.command.Command;
    7. import org.bukkit.command.CommandExecutor;
    8. import org.bukkit.command.CommandSender;
    9. import org.bukkit.entity.Player;
    10. import box.arcation.api.TinyLocation;
    11.  
    12. public class HomeCommand implements CommandExecutor
    13. {
    14. private HashMap<Player, TinyLocation> homes = new HashMap<Player, TinyLocation>();
    15. private HashMap<String, Integer> line = new HashMap<String, Integer>();
    16.  
    17. @Override
    18. public boolean onCommand(CommandSender sender, Command cmd, String cL, String[] args) {
    19. Player p = (Player) sender;
    20. if(sender instanceof Player)
    21. {
    22. if(cmd.getName().equalsIgnoreCase("sethome"))
    23. {
    24. if(args.length == 0)
    25. {
    26. if(p.hasPermission("arcation.sethome"))
    27. {
    28. TinyLocation location = new TinyLocation(p.getLocation());
    29. homes.put(p, location);
    30. p.sendMessage(ChatColor.GOLD + "Home set.");
    31. }
    32. }
    33. }
    34. if(cmd.getName().equalsIgnoreCase("home"))
    35. {
    36. if(args.length == 0)
    37. {
    38. if(p.hasPermission("arcation.home"))
    39. {
    40. if(homes.containsKey(p))
    41. {
    42. if(!line.containsKey("line"))
    43. {
    44. line.put("line", 1);
    45. }
    46. else
    47. {
    48. line.put("line", line.get("line") + 1);
    49. }
    50. try
    51. {
    52. int time;
    53. int secs;
    54. int size;
    55. time = line.get("line") * 1000;
    56. size = line.get("line");
    57. secs = time/100;
    58. if(!p.hasPermission("arcation.nowait"))
    59. {
    60. p.sendMessage(ChatColor.RED + "The line is currently " + ChatColor.YELLOW + size + " long.");
    61. p.sendMessage(ChatColor.RED + "Please wait " + ChatColor.YELLOW + secs + ChatColor.RED + " to teleport.");
    62. homes.wait(time);
    63. p.teleport(homes.get(p.getName()).toLocation());
    64. p.sendMessage(ChatColor.GOLD + "Welcome home!");
    65. }
    66. else
    67. {
    68. p.teleport(homes.get(p.getName()).toLocation());
    69. p.sendMessage(ChatColor.GOLD + "Welcome home!");
    70. }
    71. }
    72. catch(Exception ex)
    73. {
    74. ex.printStackTrace();
    75. }
    76. }
    77. else
    78. {
    79. p.sendMessage(ChatColor.RED + "Home never was set.");
    80. }
    81. }
    82. }
    83. }
    84. }
    85. else
    86. {
    87. System.out.println("[ArcationCommands] Command cannot be used here.");
    88. }
    89. return false;
    90. }
    91.  
    92. }
    93.  
     
Thread Status:
Not open for further replies.

Share This Page