Solved Simple } error,

Discussion in 'Plugin Development' started by nirajm34, Dec 2, 2013.

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

    nirajm34

    Hey, i have a error at the bottom } is red underline.

    Code:java
    1. package com.saicogaming;
    2.  
    3. import org.bukkit.Bukkit;
    4. import org.bukkit.ChatColor;
    5. import org.bukkit.Location;
    6. import org.bukkit.Material;
    7. import org.bukkit.command.Command;
    8. import org.bukkit.command.CommandExecutor;
    9. import org.bukkit.command.CommandSender;
    10. import org.bukkit.enchantments.Enchantment;
    11. import org.bukkit.entity.EntityType;
    12. import org.bukkit.entity.Player;
    13. import org.bukkit.inventory.ItemStack;
    14. import org.bukkit.potion.PotionEffect;
    15. import org.bukkit.potion.PotionEffectType;
    16.  
    17. public class StartCommandExecutor implements CommandExecutor {
    18.  
    19. start plugin;
    20.  
    21. public StartCommandExecutor(start instance){
    22. plugin = instance;
    23. }
    24.  
    25.  
    26. @Override
    27. public boolean onCommand(CommandSender sender, Command cmd, String label,
    28. String[] args) {
    29. Player p = (Player) sender;
    30. if (cmd.getName().equalsIgnoreCase("enchant")) {
    31. // Make sure that the player specified exactly one argument (the
    32. // name of the player to give enchanted item too).
    33. if (args.length != 1) {
    34. // For The Player himself
    35. ItemStack item = new ItemStack(Material.DIAMOND_SWORD);
    36. item.addEnchantment(Enchantment.DAMAGE_ALL, 5);
    37. p.getInventory().addItem(item);
    38. sender.sendMessage(ChatColor.BLUE
    39. + "[Enchantment]"
    40. + ChatColor.RED
    41. + p.getName()
    42. + " Here is a Diamond Sword, Enchanted with Sharpness 5");
    43. return true;
    44. }
    45.  
    46. // Make sure the send is a player.
    47. if (!(sender instanceof Player)) {
    48. sender.sendMessage("Only players another player an item");
    49. sender.sendMessage("This is an arbitrary requirement for demonstration purposes only.");
    50. return true;
    51. }
    52.  
    53. // Get the player who should be set on fire. Remember that indecies
    54. // start with 0, not 1.
    55. Player target = Bukkit.getServer().getPlayer(args[0]);
    56. // Make sure the player is online.
    57. if (target == null) {
    58. sender.sendMessage(args[0] + " is not currently online.");
    59. return true;
    60. }
    61. ItemStack item = new ItemStack(Material.DIAMOND_SWORD);
    62. item.addEnchantment(Enchantment.DAMAGE_ALL, 5);
    63. target.getInventory().addItem(item);
    64. sender.sendMessage(ChatColor.BLUE + "[Enchantment] "
    65. + ChatColor.RED + args[0]
    66. + " Here is a Diamond Sword, Enchanted with Sharpness 100");
    67. return true;
    68.  
    69. // Ignite Area
    70.  
    71. } else if (cmd.getName().equalsIgnoreCase("ignite")) {
    72. // Make sure that the player specified exactly one argument (the
    73. // name of the player to ignite).
    74. if (args.length != 1) {
    75. // When onCommand() returns false, the help message associated
    76. // with that command is displayed.
    77. return false;
    78. }
    79.  
    80. // Make sure the sender is a player.
    81. if (!(sender instanceof Player)) {
    82. sender.sendMessage("Only players can set other players on fire.");
    83. sender.sendMessage("This is an arbitrary requirement for demonstration purposes only.");
    84. return true;
    85. }
    86.  
    87. // Get the player who should be set on fire. Remember that indecies
    88. // start with 0, not 1.
    89. Player target = Bukkit.getServer().getPlayer(args[0]);
    90.  
    91. // Make sure the player is online.
    92. if (target == null) {
    93. sender.sendMessage(args[0] + " is not currently online.");
    94. return true;
    95. }
    96.  
    97. // Sets the player on fire for 1,000 ticks (there are ~20 ticks in
    98. // second, so 50 seconds total).
    99. target.setFireTicks(1000);
    100. target.setAllowFlight(true);
    101. return true;
    102.  
    103.  
    104. // This is for the Heal Command
    105.  
    106.  
    107.  
    108. } else if (cmd.getName().equalsIgnoreCase("heal")) {
    109. if (args.length != 1) {
    110. // if no player is added
    111. p.setFireTicks(0);
    112. p.setFoodLevel(20);
    113. ItemStack item = new ItemStack(Material.GOLDEN_APPLE);
    114. p.getInventory().addItem(item);
    115. p.sendMessage((p.getName() + " §6You have been healed."));
    116. return true;
    117. }
    118.  
    119. Player target = Bukkit.getServer().getPlayer(args[0]);
    120. // Make sure the player is online.
    121. if (target == null) {
    122. sender.sendMessage(args[0] + " is not currently online.");
    123. // find the player, if he/she is online
    124. return true;
    125. }
    126. target.addPotionEffect(new PotionEffect(
    127. PotionEffectType.REGENERATION, 1000, 10));
    128. // gives player regen 10
    129. target.setFireTicks(0);
    130. target.setFoodLevel(20);
    131. target.sendMessage((args[0] + " §6You have been healed."));
    132. // Takes fire off and also gives full food and displays msg
    133. return true;
    134. } else if (cmd.getName().equalsIgnoreCase("sex")) {
    135. // Make sure that the player specified exactly one argument (the
    136. // name of the player to ignite).
    137. if (args.length == 0) {
    138. p.sendMessage(ChatColor.AQUA + "</sex> <targetPlayer> ");
    139. }
    140. if (args.length == 1) {
    141. Player targetPlayer = p.getServer().getPlayer(args[0]);
    142. Player p2 = targetPlayer;
    143. Location targetlocation = targetPlayer.getLocation();
    144. targetPlayer.getWorld().spawnEntity(targetlocation,
    145. EntityType.PIG);
    146. targetPlayer.getWorld().spawnEntity(targetlocation,
    147. EntityType.PIG);
    148. ItemStack item = new ItemStack(Material.CARROT_ITEM);
    149. p2.getInventory().addItem(item);
    150. p2.getInventory().addItem(item);
    151. sender.sendMessage(ChatColor.BLUE + "[Sex] " + ChatColor.RED
    152. + args[0] + " Have some wheat and cause some Lovin");
    153. return true;
    154. //HighJmp Command to jump high!
    155. }else if (cmd.getName().equalsIgnoreCase("highjmp")) {
    156. if (args.length == 0) {
    157. p.sendMessage( ChatColor.AQUA + "</highjmp> <on/off> " );
    158. }if (args[0].equalsIgnoreCase("on"));{
    159. p.addPotionEffect(new PotionEffect(PotionEffectType.JUMP, Integer.MAX_VALUE, 10));
    160. p.setAllowFlight(true);
    161. p.sendMessage("§5[HighJmp] §6You have been given Jump 10, to turn off do /highjmp off");
    162. return true;
    163.  
    164. }if (args[0].equalsIgnoreCase("off")) {
    165. for(PotionEffect pe : p.getActivePotionEffects()){
    166. if(pe.getType() == PotionEffectType.JUMP){
    167. p.removePotionEffect(pe.getType());
    168. p.setAllowFlight(false);
    169. p.sendMessage("§5[HighJmp] §6Your Jump is gone :( do /highjmp on to get it back!");
    170. }
    171.  
    172. }
    173. return true;
    174. }
    175. return false;
    176. }
    177.  
    178. }
    179. }


    can you see why?
     
  2. Offline

    _feva_

    You are missing a return statement.
     
  3. Offline

    felixfritz

    Does it say one of those messages when you hover it?

    1. Syntax error, insert "}" to complete ClassBody
    2. Syntax error on token "}", delete this token
     
  4. Offline

    sgavster

    nirajm34 Because you need 1 more bracket. Here is a fixed class:
    PHP:
    package com.saicogaming;
     
    import org.bukkit.Bukkit;
    import org.bukkit.ChatColor;
    import org.bukkit.Location;
    import org.bukkit.Material;
    import org.bukkit.command.Command;
    import org.bukkit.command.CommandExecutor;
    import org.bukkit.command.CommandSender;
    import org.bukkit.enchantments.Enchantment;
    import org.bukkit.entity.EntityType;
    import org.bukkit.entity.Player;
    import org.bukkit.inventory.ItemStack;
    import org.bukkit.potion.PotionEffect;
    import org.bukkit.potion.PotionEffectType;
     
    public class 
    StartCommandExecutor implements CommandExecutor {
     
        
    start plugin;
     
        public 
    StartCommandExecutor(start instance){
            
    plugin instance;
        }
     
     
        @
    Override
        
    public boolean onCommand(CommandSender senderCommand cmdString label,
                
    String[] args) {
            
    Player p = (Playersender;
            if (
    cmd.getName().equalsIgnoreCase("enchant")) {
                
    // Make sure that the player specified exactly one argument (the
                // name of the player to give enchanted item too).
                
    if (args.length != 1) {
                    
    // For The Player himself
                    
    ItemStack item = new ItemStack(Material.DIAMOND_SWORD);
                    
    item.addEnchantment(Enchantment.DAMAGE_ALL5);
                    
    p.getInventory().addItem(item);
                    
    sender.sendMessage(ChatColor.BLUE
                            
    "[Enchantment]"
                            
    ChatColor.RED
                            
    p.getName()
                            + 
    " Here is a Diamond Sword, Enchanted with Sharpness 5");
                    return 
    true;
                }
     
                
    // Make sure the send is a player.
                
    if (!(sender instanceof Player)) {
                    
    sender.sendMessage("Only players another player an item");
                    
    sender.sendMessage("This is an arbitrary requirement for demonstration purposes only.");
                    return 
    true;
                }
     
                
    // Get the player who should be set on fire. Remember that indecies
                // start with 0, not 1.
                
    Player target Bukkit.getServer().getPlayer(args[0]);
                
    // Make sure the player is online.
                
    if (target == null) {
                    
    sender.sendMessage(args[0] + " is not currently online.");
                    return 
    true;
                }
                
    ItemStack item = new ItemStack(Material.DIAMOND_SWORD);
                
    item.addEnchantment(Enchantment.DAMAGE_ALL5);
                
    target.getInventory().addItem(item);
                
    sender.sendMessage(ChatColor.BLUE "[Enchantment] "
                        
    ChatColor.RED args[0]
                                + 
    " Here is a Diamond Sword, Enchanted with Sharpness 100");
                return 
    true;
     
                
    // Ignite Area
     
            
    } else if (cmd.getName().equalsIgnoreCase("ignite")) {
                
    // Make sure that the player specified exactly one argument (the
                // name of the player to ignite).
                
    if (args.length != 1) {
                    
    // When onCommand() returns false, the help message associated
                    // with that command is displayed.
                    
    return false;
                }
     
                
    // Make sure the sender is a player.
                
    if (!(sender instanceof Player)) {
                    
    sender.sendMessage("Only players can set other players on fire.");
                    
    sender.sendMessage("This is an arbitrary requirement for demonstration purposes only.");
                    return 
    true;
                }
     
                
    // Get the player who should be set on fire. Remember that indecies
                // start with 0, not 1.
                
    Player target Bukkit.getServer().getPlayer(args[0]);
     
                
    // Make sure the player is online.
                
    if (target == null) {
                    
    sender.sendMessage(args[0] + " is not currently online.");
                    return 
    true;
                }
     
                
    // Sets the player on fire for 1,000 ticks (there are ~20 ticks in
                // second, so 50 seconds total).
                
    target.setFireTicks(1000);
                
    target.setAllowFlight(true);
                return 
    true;
     
     
                
    // This is for the Heal Command
     
     
     
            
    } else if (cmd.getName().equalsIgnoreCase("heal")) {
                if (
    args.length != 1) {
                    
    // if no player is added
                    
    p.setFireTicks(0);
                    
    p.setFoodLevel(20);
                    
    ItemStack item = new ItemStack(Material.GOLDEN_APPLE);
                    
    p.getInventory().addItem(item);
                    
    p.sendMessage((p.getName() + " §6You have been healed."));
                    return 
    true;
                }
     
                
    Player target Bukkit.getServer().getPlayer(args[0]);
                
    // Make sure the player is online.
                
    if (target == null) {
                    
    sender.sendMessage(args[0] + " is not currently online.");
                    
    // find the player, if he/she is online
                    
    return true;
                }
                
    target.addPotionEffect(new PotionEffect(
                        
    PotionEffectType.REGENERATION100010));
                
    // gives player regen 10
                
    target.setFireTicks(0);
                
    target.setFoodLevel(20);
                
    target.sendMessage((args[0] + " §6You have been healed."));
                
    // Takes fire off and also gives full food and displays msg
                
    return true;
            } else if (
    cmd.getName().equalsIgnoreCase("sex")) {
                
    // Make sure that the player specified exactly one argument (the
                // name of the player to ignite).
                
    if (args.length == 0) {
                    
    p.sendMessage(ChatColor.AQUA "</sex> <targetPlayer> ");
                }
                if (
    args.length == 1) {
                    
    Player targetPlayer p.getServer().getPlayer(args[0]);
                    
    Player p2 targetPlayer;
                    
    Location targetlocation targetPlayer.getLocation();
                    
    targetPlayer.getWorld().spawnEntity(targetlocation,
                            
    EntityType.PIG);
                    
    targetPlayer.getWorld().spawnEntity(targetlocation,
                            
    EntityType.PIG);
                    
    ItemStack item = new ItemStack(Material.CARROT_ITEM);
                    
    p2.getInventory().addItem(item);
                    
    p2.getInventory().addItem(item);
                    
    sender.sendMessage(ChatColor.BLUE "[Sex] " ChatColor.RED
                            
    args[0] + " Have some wheat and cause some Lovin");
                    return 
    true;
                    
    //HighJmp Command to jump high!
                
    }else if (cmd.getName().equalsIgnoreCase("highjmp")) {
                    if (
    args.length == 0) {
                        
    p.sendMessageChatColor.AQUA "</highjmp> <on/off> " );
                    }if (
    args[0].equalsIgnoreCase("on"));{
                        
    p.addPotionEffect(new PotionEffect(PotionEffectType.JUMPInteger.MAX_VALUE10));
                        
    p.setAllowFlight(true);
                        
    p.sendMessage("§5[HighJmp] §6You have been given Jump 10, to turn off do /highjmp off");
                        return 
    true;
     
                    }if (
    args[0].equalsIgnoreCase("off")) {
                        for(
    PotionEffect pe p.getActivePotionEffects()){
                            if(
    pe.getType() == PotionEffectType.JUMP){
                                
    p.removePotionEffect(pe.getType());
                                
    p.setAllowFlight(false);
                                
    p.sendMessage("§5[HighJmp] §6Your Jump is gone :( do /highjmp on to get it back!");
                            }
     
                        }
                        return 
    true;     
                    }
                }
     
            }
            return 
    false;
        }
    }
     
  5. Offline

    nirajm34

    yes
     
  6. I believe you need a close brace } after line 153.
    Doing this would return true if on /XXX they use 1 parameter. CUrrently you have /XXX enclosing /highjump.

    Oh sorry this was posted before I saw the other posts
     
  7. Offline

    nirajm34

    and thanks, but this is what happened when pasted in

    http://gyazo.com/66902830af1a26bd777b6f5dc1464055.png
     
  8. Offline

    sgavster

    nirajm34 Just remove the return true.
     
  9. That code still needs a curly brace after return true at:
    return true;
    //HighJmp Command to jump high!
    }else if (cmd.getName().equalsIgnoreCase("highjmp")) {
     
Thread Status:
Not open for further replies.

Share This Page