Strange bug I cant seem to find...

Discussion in 'Plugin Development' started by SleepyDog, Nov 2, 2014.

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

    SleepyDog

    I am creating a simple plugin for my personal server and i have a problem. I have made 4 commands.
    /apply /checkapp /denyapp /acceptapp. This is for my whitelisted server i am creating. People will need to apply to play.


    On the second 'if' statement i cant make it be 'else if' or i get an error. The first command is the only one that works. I have counted the brackets countless times and everything seems to be okay.
    Also i need to know if what i am doing to manage the config is correct. I have tried to check if it exists to give a message. This should be simple to see how it works. I you can find the problem please comment! Thanks!

    This is the code.
    Code:java
    1. package me.sleepydog935;
    2.  
    3. import org.bukkit.Bukkit;
    4. import org.bukkit.command.Command;
    5. import org.bukkit.command.CommandSender;
    6. import org.bukkit.plugin.java.JavaPlugin;
    7.  
    8. public class Main extends JavaPlugin{
    9.  
    10. public void OnEnable(){
    11.  
    12. this.saveDefaultConfig();
    13. }
    14.  
    15. public void OnDisable(){
    16.  
    17.  
    18. }
    19.  
    20. public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args){
    21. this.reloadConfig();
    22.  
    23. if (cmd.getName().equalsIgnoreCase("apply")){
    24. sender.sendMessage("§0§l§m====================");
    25. sender.sendMessage("§a§l" + getConfig().getString("apply.1"));
    26. sender.sendMessage("§a§l" + getConfig().getString("apply.2"));
    27. sender.sendMessage("§a§l" + getConfig().getString("apply.3"));
    28. sender.sendMessage("§a§l" + getConfig().getString("apply.4"));
    29. sender.sendMessage("§a§l" + getConfig().getString("apply.5"));
    30. sender.sendMessage("§a§l" + getConfig().getString("apply.6"));
    31. sender.sendMessage("§a§l" + getConfig().getString("apply.7"));
    32. sender.sendMessage("§0§l§m====================");
    33. }
    34. if (cmd.getName().equalsIgnoreCase("acceptapp")){
    35.  
    36. if (sender.isOp()) {
    37. String name = "";
    38. //Set name to args if they are not blank
    39. if (args.length > 0) name = args[0];
    40. //run code if name is not blank
    41. if (!name.equalsIgnoreCase("")) {
    42. //set <name>.isAccepted: True
    43. getConfig().set(name + ".isAccepted", "True");
    44. sender.sendMessage("§a" + name +"was accepted!");
    45. }
    46. else {
    47. sender.sendMessage("Usage: /accept <player>");
    48. //send the user the usage message
    49. }
    50.  
    51. }
    52. }
    53. else if (cmd.getName().equalsIgnoreCase("denyapp")){
    54.  
    55. if (sender.isOp()) {
    56. String name = "";
    57. //Set name to args if they are not blank
    58. if (args.length > 0) name = args[0];
    59. //run code if name is not blank
    60. if (!name.equalsIgnoreCase("")) {
    61. //set <name>.isAccepted: False
    62. getConfig().set(name + ".isAccepted", "False");
    63. }
    64. else {
    65. sender.sendMessage("Usage: /deny <player>");
    66. //send the user the usage message
    67. }
    68.  
    69. }
    70. }
    71. else if (cmd.getName().equalsIgnoreCase("checkapp")){
    72.  
    73. String isAccepted = getConfig().getString(sender + ".isAccepted.");
    74. if (isAccepted == null) {
    75.  
    76. getConfig().set(sender + ".isAccepted", "pending");
    77.  
    78. }
    79. else{
    80. if (isAccepted == "pending"){
    81. sender.sendMessage("§0§l§m====================");
    82. sender.sendMessage("§5§lYour application is pending...");
    83. sender.sendMessage("§5§lAn admin will read your application soon!");
    84. sender.sendMessage("§5§lDo /apply if you have not applied.");
    85. sender.sendMessage("§0§l§m====================");
    86. sender.sendMessage("§a§lDo not ask an admin to read your application till it has been 3 days since you have applied!");
    87.  
    88. }
    89. if (isAccepted == "True"){
    90. sender.sendMessage("§0§l§m====================");
    91. sender.sendMessage("§5§lYour application was §5Accepted!");
    92. sender.sendMessage("§5§lWelcome to the server!");
    93. sender.sendMessage("§0§l§m====================");
    94. Bukkit.getServer().dispatchCommand(getServer().getConsoleSender(), "pex user " + sender + " group set member");
    95. sender.sendMessage("§a§lYou are now in group member!");
    96. getConfig().set(sender + ".isAccepted", "Accepted and Promoted");
    97.  
    98.  
    99. }
    100. else if (isAccepted == "False"){
    101.  
    102. }
    103. else if (isAccepted == "Accepted and Promoted"){
    104.  
    105. sender.sendMessage("§0§l§m====================");
    106. sender.sendMessage("§5§lYour application was §5Accepted!");
    107. sender.sendMessage("§5§lWelcome to the server!");
    108. sender.sendMessage("§0§l§m====================");
    109. sender.sendMessage("§c§lYou have already been promoted!");
    110. sender.sendMessage("§c§lIf you are still not promoted ask a member of staff!");
    111.  
    112. }
    113.  
    114. }}
    115.  
    116.  
    117.  
    118.  
    119.  
    120. return false;
    121. }
    122.  
    123. }
    124.  


    bump

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

    Skionz

    SleepyDog Off-topic but if it is a whitelisted server then how would they run the command to apply in the first place if they cannot get on?
     
    leon3001 likes this.
  3. Offline

    SleepyDog

    They will be able to join, just wont be able to do anything.
     
  4. Offline

    Gnat008

    SleepyDog
    What error do you get when you have an else if statement?
     
  5. Offline

    SleepyDog

    I just retried it. It works again... Let me try the plugin quick
     
Thread Status:
Not open for further replies.

Share This Page