Can't Use Command Without Op?

Discussion in 'Plugin Development' started by TheChinski, Sep 23, 2012.

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

    TheChinski

    Hello all. I have been learning Java the past few days by following a Stanford course on ItunesU. I decided to have a go at making a plugin, and I think i'm getting ok at it, but I've reached a dead end. :/ Here is my CommandExecuter class:

    Code:java
    1. package com.SludgeCraft.Help;
    2.  
    3. import java.util.List;
    4. import java.util.logging.Logger;
    5.  
    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.  
    11.  
    12. public class HelpCommandExecutor implements CommandExecutor {
    13. static String colorize(String string) { return string.replaceAll("(?i)&([a-l0-9])", "\u00A7$1"); }
    14. public main plugin;
    15. public final Logger logger = Logger.getLogger("Minecraft");
    16.  
    17.  
    18. public HelpCommandExecutor(main plugin) {
    19. this.plugin = plugin;
    20. }
    21.  
    22. @Override
    23. public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args){
    24. if(commandLabel.equalsIgnoreCase("help")){
    25. Player player = (Player) sender;
    26. if(args.length < 1) {
    27. if(player.hasPermission("help.help")) {
    28. String servername = (plugin.getConfig().getString("ServerName"));
    29. List<String> ranks = plugin.getConfig().getStringList("ColouredRanks");
    30. String opening = colorize("&6----------------<&a" + servername + "&6>----------------");
    31. String instructions = colorize("&6Please Enter Your Rank As Shown: /Help <Rank>");
    32. sender.sendMessage(opening);
    33. sender.sendMessage(instructions);
    34. for (int i = 0; i < ranks.size(); i++) {
    35. sender.sendMessage(colorize("&7-" + ranks.get(i)));
    36. }
    37. return true;
    38. }
    39. sender.sendMessage(colorize("&4You don't have permission to do that!"));
    40. }
    41. }
    42.  
    43. if(args.length == 1) {
    44. String arguement1 = args[0];
    45. List<String> ranks = plugin.getConfig().getStringList("Ranks");
    46. for (int i = 0; i < ranks.size(); i++) {
    47. String rank = (ranks.get(i));
    48. if(arguement1.equalsIgnoreCase(rank)) {
    49. sender.sendMessage(colorize("&6The rank: &4" + arguement1 + "&6, Has Access To These Plugins:"));
    50. List<String> plugins = plugin.getConfig().getStringList("Plugins." + rank);
    51. for (int l = 0; l < plugins.size(); l++) {
    52. sender.sendMessage(colorize("&7-" + plugins.get(l)));
    53. }
    54. sender.sendMessage(colorize("&6To find what commands you can use in a plugin, do /Help <Plugin> <Rank>"));
    55. return true;
    56. }
    57. }
    58. if(arguement1.equalsIgnoreCase("reload")) {
    59. plugin.reloadConfig();
    60. this.logger.info("[PLAYER_COMMAND] " + sender.getName() + ": /" + commandLabel + " reload");
    61. sender.sendMessage(colorize("&eConfiguration reload complete."));
    62. return true;
    63. }
    64. }
    65. if(args.length == 2) {
    66. String arguement1 = args[0];
    67. String arguement2 = args[1];
    68. List<String> commands = plugin.getConfig().getStringList("Commands." + arguement1 + "." + arguement2);
    69. sender.sendMessage(colorize("&6In the plugin: &4" + arguement1 + "&6, rank: &4" + arguement2 + "&6, has permission to do the following commands:"));
    70. for (int i = 0; i < commands.size(); i++) {
    71. sender.sendMessage("-" + commands.get(i));
    72. }
    73. return true;
    74. }
    75. sender.sendMessage(colorize("&4Error - Correct Syntax: /Help <Plugin> <Rank>"));
    76. return true;
    77. }
    78. }
    79.  


    No matter what I try, I can't use the /help command without being op, or having the *.* command. I've tried setting the Plugin.yml up in every way imaginable :p Im sorry if its something really simple, as I said i'm new to Java. :)

    Oh yeah, and if you spot any stupid ways of doing things, or unnecessary code etc. once again that will be due to my lack of experience. Thanks!
     
  2. Offline

    d33k40

    give the player group the permision help.help

    what plugins are u using?
     
  3. Offline

    TheChinski

    I've tried that. :p I only ever get through to this error:

    I'm sorry, but you do not have permission to perform this command. Please contact the server administrators if you believe that this is an error.

    Which is odd, as that isn't the 'No Permission' error in my code. Its like it isn't getting through to the command. But it is, as it works when I have op.


    Edit: I am using Pex for my permissions.

    Edit2: I tried a fresh everything (Plugins folder, help.jar and permissionsex.jar) and it all worked. So another plugin is interfering?
     
  4. Offline

    kaZep

  5. Offline

    TheChinski

    Code:java
    1. name: Help
    2. main: com.SludgeCraft.Help.main
    3. version: 0.1
    4. author: TheChinski
    5. commands:
    6. Help:
    7. description: The Base Of The Plugin.
    8. usage: /help
    9. permission: help.help
    10. Help <Rank>:
    11. description: Find What Plugins <Rank> Has Permissions To Use.
    12. usage: /help <rank>
    13. Help <plugin> <rank>:
    14. description: Find What Commands <Rank> Has Permission To Use With <Plugin>
    15. usage: /help <plugin> <rank>


    But then again, i'm thinking its a plugin messing things up... :/
     
  6. Offline

    d33k40

    Code:
    name: Help
    main: com.SludgeCraft.Help.main
    version: 0.1
    author: TheChinski
    commands:
      help:
          description: The Base Of The Plugin.
          usage: /help | /help <rank> | /help <plugin> <rank>
          permission: help.help
     
  7. Offline

    TheChinski

    Nah, still nothing. When i'm on a fresh server, with only Pex and Help, it seems to work fine. I'm guessing its another plugin messing with something or the other.
     
  8. Offline

    d33k40

    it can be essentials

    u just set the comand, u dont need to set the others premissions for every argument for that command in the plugin.yml
     
  9. Offline

    TheChinski

    Well, done a ton of removing plugins and starting the server, and I can say that NoCheatPlus is breaking my plugin. For some reason... :'(
     
  10. Offline

    Lolmewn

    Heh, that's weird. Check their Config?
     
  11. Offline

    CXdur

    Did you register the command in the mainclass?
     
  12. Offline

    MYCRAFTisbest

    That is odd. Maybe NoCheatPlus thinks that getting help is cheating.
    LOL. But seriously i don't know what could be wrong. Try to see if it is incompatable with any other plugins
     
  13. Offline

    krazytraynz

    The reason he didn't get the message he has set is probably because Bukkit automatically makes /help commands for plugins, which is why he got the Bukkit permission message... It's just the Bukkit /help and his /help conflicting with eachother.
     
Thread Status:
Not open for further replies.

Share This Page