Solved Commands not registering

Discussion in 'Plugin Development' started by SoTotallyRoary, Jan 31, 2014.

Thread Status:
Not open for further replies.
  1. The video explains it all :)



    Thanks for any help!
     
  2. Offline

    bobthefish

    SoTotallyRoary
    It appears as all of your commands (such as /bank check) are registered as one work, like /bankcheck Try entering that and see if it helps
     
    SoTotallyRoary likes this.
  3. That worked but the other commands do not
     
  4. Offline

    bobthefish

    SoTotallyRoary so even if you entered your commands exactly as they appeared in the plugin.yml, they dont work?

    lol oops, i meant one word ^^^^^^

    Can you by any chance see if you can help me with my problem? HashMaps

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 6, 2016
  5. bobthefish
    Here's the second video to help


    Code:
    Code:java
    1. package sototallyroary.superbank.assassinhero;
    2.  
    3. import java.util.logging.Logger;
    4.  
    5. import net.milkbowl.vault.chat.Chat;
    6. import net.milkbowl.vault.economy.Economy;
    7. import net.milkbowl.vault.permission.Permission;
    8.  
    9. import org.bukkit.command.Command;
    10. import org.bukkit.command.CommandSender;
    11. import org.bukkit.entity.Player;
    12. import org.bukkit.event.EventHandler;
    13. import org.bukkit.event.Listener;
    14. import org.bukkit.event.player.PlayerJoinEvent;
    15. import org.bukkit.plugin.RegisteredServiceProvider;
    16. import org.bukkit.plugin.java.JavaPlugin;
    17.  
    18. public class Main extends JavaPlugin implements Listener{
    19.  
    20. public static final Logger logger = Logger.getLogger("Minecraft");
    21. public static Economy Econ = null;
    22. public static Permission perms = null;
    23. public static Chat chat = null;
    24.  
    25.  
    26. public void onEnable(){
    27. logger.info("SuperBank Has Been Enabled Successfully!");
    28. getConfig().options().copyDefaults(true);
    29. saveConfig();
    30. if (!setupEconomy()){
    31. logger.severe(String.format("[%s] - Disabled due to no Vault dependency found!", getDescription().getName()));
    32. getServer().getPluginManager().disablePlugin(this);
    33. return;
    34. }
    35. setupPermissions();
    36. setupChat();
    37.  
    38.  
    39. }
    40.  
    41. private boolean setupEconomy(){
    42. if(getServer().getPluginManager().getPlugin("Vault") == null){
    43. return false;
    44. }
    45. RegisteredServiceProvider<Economy> rsp = getServer().getServicesManager().getRegistration(Economy.class);
    46. if (rsp == null){
    47. return false;
    48. }
    49. Econ = rsp.getProvider();
    50. return Econ != null;
    51.  
    52. }
    53.  
    54. private boolean setupChat(){
    55. RegisteredServiceProvider<Chat> rsp = getServer().getServicesManager().getRegistration(Chat.class);
    56. chat = rsp.getProvider();
    57. return chat !=null;
    58. }
    59.  
    60. private boolean setupPermissions(){
    61. RegisteredServiceProvider<Permission> rsp = getServer().getServicesManager().getRegistration(Permission.class);
    62. perms = rsp.getProvider();
    63. return perms !=null;
    64. }
    65.  
    66. public void onDisable(){
    67. logger.info("SuperBank Has Been Disabled Successfully!");
    68. logger.info(String.format("[%s] Disabled Version %s", getDescription(),getName(), getDescription().getVersion()));
    69. saveConfig();
    70. }
    71.  
    72. public static double amount;
    73.  
    74. @EventHandler
    75. public void PlayerJoinEvent(PlayerJoinEvent event){
    76. if(!event.getPlayer().hasPlayedBefore()){
    77. Econ.createBank("WorldBank", getName());
    78. }
    79.  
    80. }
    81.  
    82. public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args){
    83. Player player = (Player) sender;
    84. if(cmd.getName().equalsIgnoreCase("BankCheck")){
    85. player.hasPermission("Bank.Check");
    86. Econ.isBankOwner("WorldBank", getName());
    87. Econ.getBalance(getName());
    88. }
    89.  
    90. if (cmd.getName().equalsIgnoreCase("BankDeposit")){
    91. player.hasPermission("Bank.Deposit");
    92. Econ.bankDeposit(getName(), amount);
    93. player.sendMessage("You have deposited" + amount + "from your bank!");
    94. Econ.getBalance(getName());
    95. }
    96.  
    97. if(cmd.getName().equalsIgnoreCase("BankList")){
    98. player.hasPermission("Bank.List");
    99. Econ.getBanks();
    100. }else{
    101. player.sendMessage("You Do NOT Have Permissions");
    102. }
    103. if(cmd.getName().equalsIgnoreCase("BankWithdraw")){
    104. player.hasPermission("Bank.Withdraw");
    105. Econ.bankWithdraw(getName(), amount);
    106. player.sendMessage("You have withdrawn" + amount + "from your bank!");
    107. Econ.getBalance(getName());
    108. }
    109.  
    110. if(cmd.getName().equalsIgnoreCase("BankDelete")){
    111. player.hasPermission("Bank.Delete");
    112. Econ.deleteBank(getName());
    113. }
    114. return true;
    115.  
    116. }
    117. }


    plugin.yml
    Code:
    name: SuperBank
    main: sototallyroary.superbank.assassinhero.Main
    version: 1.0.0
    author: SoTotallyRoary
    commands:
      Bank Check:
        description: Allows you to check the balance of your bank
        usage: /Bank Check
      Bank Deposit:
        description: Allows you to deposit into your bank
        usage: /Bank Deposit
      Bank Withdraw:
        description: Allows you to withdraw money from your bank
        usage: /Bank Withdraw
      Bank List:
        description: Allows you to check the list of banks
        usage: /Bank List
      Bank Delete:
        description: Allows you to delete a bank USE ADMIN ONLY
        usage: /Bank Delete
    permissions:
        Bank.Check:
          description: Allows the use of command Bank Check
          default: true
        Bank.Deposit:
          description: Allows the use of command Bank Deposit
          default: true
        Bank.Withdraw:
          description: Allows the use of command Bank Withdraw
          default: true
        Bank.List:
          description: Allows the use of command Bank List
          default: op
        Bank.Delete:
          description: Allows the use of command Bank Delete
          default: op
     
  6. Offline

    bobthefish

    SoTotallyRoary First, your welcome, 2nd, you see where it says:
    Code:java
    1. if (cmd.getName().equalsIgnoreCase("BankDeposit")){


    Between "Bank" and "Deposit" you need a space, so it should look like:
    Code:java
    1. if (cmd.getName().equalsIgnoreCase("Bank Deposit")){


    And also, typically commands are only one word long, with argument, if you want me to show you how to do that then I can, but for now, i believe that adding that space should work :)
     
    SoTotallyRoary likes this.
  7. It's working now. I've just gotta bug fix :) Thank you so much!!
     
  8. Offline

    bobthefish

    SoTotallyRoary
    Did I fix it? Or was it something else, sorry just would like to know ;)
     
    SoTotallyRoary likes this.
  9. You fixed it :) I changed it to a one word command as you said and now it works! :)
     
  10. Offline

    bobthefish

    SoTotallyRoary
    ok, great! now, do you want any help with arguments for the commands? or are you good?
     
    SoTotallyRoary likes this.
  11. I'm good now pal. Thanks! :)
     
Thread Status:
Not open for further replies.

Share This Page