Results 1 to 6 of 6

Thread: Spacing issues

  1. #1
    evilpauwse is offline Member
    Join Date
    Aug 2016
    Posts
    3
    Rep Power
    0

    Default Spacing issues

    Hi, I am new to programing in Java, and I was wonder if someone could help me fix my spacing.
    Thanks, evilpauwse

    package me.evilpauwse; import java.util.Set; import org.bukkit.invento - Pastebin.com

  2. #2
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    20,003
    Rep Power
    33

    Default Re: Spacing issues

    Please explain what problems you are having. Post any code you are working with that you are having problems with here on the forum.
    If you don't understand my response, don't ignore it, ask a question.

  3. #3
    evilpauwse is offline Member
    Join Date
    Aug 2016
    Posts
    3
    Rep Power
    0

    Default Re: Spacing issues

    I'm having trouble lining up my curly braces.

    Java Code:
    import java.util.Set;
    
    
    
    import org.bukkit.inventory.ItemStack;
    import org.bukkit.Material;
    import org.bukkit.command.Command;
    import org.bukkit.command.CommandExecutor;
    import org.bukkit.command.CommandSender;
    
    import org.bukkit.entity.EntityType;
    import org.bukkit.entity.Player;
    import org.bukkit.event.EventHandler;
    import org.bukkit.event.Listener;
    import org.bukkit.event.block.Action;
    import org.bukkit.event.player.PlayerInteractEvent;
    
    public class Abilities implements Listener {
    	Kits plugin;
    	public Abilities (Kits plugin) 
    	{ this.plugin = plugin; {
    	}
    	}
    }
    
    
    
    
    
    
    	
    	
    	@EventHandler
    	public void onClick(PlayerInteractEvent e) {
    		final Player player = e.getPlayer();
    		Action a = e.getAction();
    		ItemStack is = e.getItem();
    		if((a == Action.PHYSICAL) || (is == null) || (is.getType() == Material.AIR)) {
    		}
    			return;
    		{
    	
    		if (is.getType() == Material.STICK) {
    			org.bukkit.Location use = player.getTargetBlock((Set<Material>)null, 10).getLocation();    
    			player.getWorld().spawnEntity(use.add(0.0, 2.0, 0.0), EntityType.FIREBALL);
    			{
    	
    				
    	
    		
    	
    }
    		
    		}
    }
    	}
    Last edited by evilpauwse; 08-10-2016 at 05:20 PM.

  4. #4
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    13,541
    Rep Power
    27

    Default Re: Spacing issues

    You have lots of unnecessary brackets there.

    Start from the top and pair them up.
    So the first open bracket is paired with the last close bracket.

    Then for each of the two methods, there should be a corresponding open and close bracket.

    The first method should not have any other brackets inside it as there are no conditional statements or controls that might warrant it, so you can tidy that one up.
    For the second method, each if statement will have a corresponding open and close bracket, covering the lines associated with that conditional.

    Any left over brackets should be removed.
    Please do not ask for code as refusal often offends.

    ** This space for rent **

  5. #5
    evilpauwse is offline Member
    Join Date
    Aug 2016
    Posts
    3
    Rep Power
    0

    Default Re: Spacing issues

    Thank you Tolls!

  6. #6
    computerchris is offline Member
    Join Date
    Aug 2016
    Location
    Westerly, RI
    Posts
    1
    Rep Power
    0

    Default Re: Spacing issues

    I know it is a personal preference thing but I prefer this style of using brackets:
    XML Code:
    public void foo()
    {
         System.out.println("Code here");
    }
    
    Versus using this style:
    public void foo(){
         System.out.println("Code here");
    }
    I feel it is much easier to line up the braces and looks cleaner. I know there are die hards for other style but like I said, personal preference.

Similar Threads

  1. Spacing issues when appending to JTextArea
    By togie in forum Forum Lobby
    Replies: 1
    Last Post: 11-28-2013, 01:39 PM
  2. Spacing....
    By micolord in forum New To Java
    Replies: 8
    Last Post: 10-10-2011, 02:53 PM
  3. [Q] Spacing Help
    By iriscience in forum New To Java
    Replies: 7
    Last Post: 02-08-2011, 01:44 AM
  4. digit spacing
    By puk284 in forum New To Java
    Replies: 3
    Last Post: 06-09-2009, 02:49 PM
  5. Help with spacing in java
    By barney in forum New To Java
    Replies: 1
    Last Post: 07-31-2007, 08:03 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •