Command Hider

Discussion in 'Plugin Development' started by xMwpgamer7ooox, Jul 14, 2014.

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

    xMwpgamer7ooox

    Code:java
    1. package me.xMwpgamer7ooox.PluginHider;
    2.  
    3. import java.util.logging.Logger;
    4.  
    5. import org.bukkit.ChatColor;
    6. import org.bukkit.command.Command;
    7. import org.bukkit.command.CommandSender;
    8. import org.bukkit.entity.Player;
    9. import org.bukkit.plugin.PluginDescriptionFile;
    10. import org.bukkit.plugin.java.JavaPlugin;
    11.  
    12. public class main
    13. extends JavaPlugin
    14. {
    15. public final Logger logger = Logger.getLogger("Minecraft");
    16.  
    17. public void onDisable()
    18. {
    19. PluginDescriptionFile p = getDescription();
    20. this.logger.info(p.getName() + "V" + p.getVersion() + "Has Been Disabled! D:");
    21. }
    22.  
    23. public void onEnable()
    24. {
    25. PluginDescriptionFile p = getDescription();
    26. this.logger.info(p.getName() + "V" + p.getVersion() + "Has Been Enabled! :D");
    27. getConfig().options().copyDefaults(true);
    28. saveConfig();
    29. }
    30.  
    31. public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args)
    32. {
    33. Player player = (Player)sender;
    34. if ((commandLabel.equalsIgnoreCase("plugin")) || (commandLabel.equalsIgnoreCase("plugins")) || (commandLabel.equalsIgnoreCase("pl")) || (commandLabel.equalsIgnoreCase("?"))) {
    35. player.sendMessage(ChatColor.AQUA + "You are not allowed to view HyruleCraft's plugins!");
    36.  
    37. }
    38.  
    39.  
    40. else if ((commandLabel.equalsIgnoreCase("help")) || (commandLabel.equalsIgnoreCase("bal")) || (commandLabel.equalsIgnoreCase("balance")) || (commandLabel.equalsIgnoreCase("msg")) || (commandLabel.equalsIgnoreCase("pm")) || (commandLabel.equalsIgnoreCase("sell")) || (commandLabel.equalsIgnoreCase("privatemessage")) || (commandLabel.equalsIgnoreCase("warp"))) {
    41. player.sendMessage(ChatColor.AQUA + "You are not allowed to view HyruleCraft's plugins, help or commands!");
    42. }
    43. return false;
    44. }
    45. }
    46.  

    In my code near the bottom, I would like help, bal, msg, warp and etc... to have a message error coming up when typed in game. For some reason only the help command comes up with the error but the others commands don't have the pop up error. Here is the code
     
  2. Offline

    fireblast709

    xMwpgamer7ooox you cannot override all commands. Use PlayerCommandPreprocessEvent instead
     
  3. Offline

    xMwpgamer7ooox

    fireblast709 so where would I add that? (Still new to coding)
     
  4. Offline

    fireblast709

  5. Offline

    Anonymous350

    xMwpgamer7ooox
    You create an EventHandler..

    Code:java
    1. @EventHandler
    2. public void onPlayerCommand(PlayerCommandPreProcessEvent event){
    3. }
     
  6. Offline

    xMwpgamer7ooox

  7. Offline

    fireblast709

Thread Status:
Not open for further replies.

Share This Page