Browse Source

Formatted and organized imports

Made a custom formatter and formatted project.
Tankernn 9 years ago
parent
commit
2f5b5289e9

+ 2 - 2
src/main/java/client/ChatClient.java

@@ -17,7 +17,7 @@ public class ChatClient {
 	static Properties prop = new Properties();
 	static File confFile = new File("client.properties");
 	
-	public static void main (String[] arg) {
+	public static void main(String[] arg) {
 		try {
 			prop.load(new FileInputStream(confFile));
 		} catch (FileNotFoundException e) {
@@ -51,7 +51,7 @@ public class ChatClient {
 		int port = sc.nextInt();
 		sc.close();
 		prop.setProperty("port", portString);
-
+		
 		writeConfFile();
 		
 		new ChatWindow(host, port, username);

+ 51 - 40
src/main/java/client/ChatWindow.java

@@ -19,14 +19,23 @@ import java.net.Socket;
 import java.net.SocketTimeoutException;
 import java.util.ArrayList;
 
-import javax.swing.*;
+import javax.swing.DefaultListModel;
+import javax.swing.JButton;
+import javax.swing.JFrame;
+import javax.swing.JLabel;
+import javax.swing.JList;
+import javax.swing.JPanel;
+import javax.swing.JScrollPane;
+import javax.swing.JTextField;
+import javax.swing.ListSelectionModel;
+import javax.swing.WindowConstants;
 import javax.swing.border.EmptyBorder;
 
 import common.Message;
 import common.Message.MessageType;
 
 @SuppressWarnings("serial")
-public class ChatWindow extends JFrame implements ActionListener, Runnable, KeyListener{
+public class ChatWindow extends JFrame implements ActionListener, Runnable, KeyListener {
 	Thread getMessages;
 	static File confFile = new File("client.properties");
 	
@@ -69,17 +78,19 @@ public class ChatWindow extends JFrame implements ActionListener, Runnable, KeyL
 		con.gridx = 0;
 		
 		right.add(lblUsersOnline, con);
-
+		
 		con.weighty = 1;
 		con.fill = GridBagConstraints.BOTH;
 		right.add(userList, con);
-
+		
 		con.weighty = 0;
 		con.fill = GridBagConstraints.HORIZONTAL;
 		right.add(reconnect, con);
 		
 		setLayout(new BorderLayout());
-		add(chat, BorderLayout.NORTH); add(write, BorderLayout.SOUTH); add(right, BorderLayout.EAST);
+		add(chat, BorderLayout.NORTH);
+		add(write, BorderLayout.SOUTH);
+		add(right, BorderLayout.EAST);
 		
 		//Scrollbar config
 		add(scroll);
@@ -128,8 +139,8 @@ public class ChatWindow extends JFrame implements ActionListener, Runnable, KeyL
 		try {
 			so = new Socket();
 			so.connect(new InetSocketAddress(address, port), 1000);
-			objIn =		new ObjectInputStream(so.getInputStream());
-			out =		new PrintWriter(so.getOutputStream(), true);
+			objIn = new ObjectInputStream(so.getInputStream());
+			out = new PrintWriter(so.getOutputStream(), true);
 		} catch (SocketTimeoutException ex) {
 			chat.log(new Message("Could not connect to server. (Connection timed out!)", MessageType.ERROR, false));
 			return;
@@ -151,7 +162,7 @@ public class ChatWindow extends JFrame implements ActionListener, Runnable, KeyL
 		if (e.getSource() == reconnect)
 			connect(adress, port, username);
 	}
-
+	
 	@Override
 	public void run() {
 		try {
@@ -166,10 +177,10 @@ public class ChatWindow extends JFrame implements ActionListener, Runnable, KeyL
 	}
 	
 	public void getMessages() throws IOException, ClassNotFoundException {
-		while(!getMessages.isInterrupted()) {
+		while (!getMessages.isInterrupted()) {
 			Object fromServer = objIn.readObject();
 			if (fromServer instanceof Message) {
-				Message mess = ((Message)fromServer);
+				Message mess = ((Message) fromServer);
 				chat.log(mess);
 				
 				if (mess.usersOnline == null)
@@ -181,46 +192,46 @@ public class ChatWindow extends JFrame implements ActionListener, Runnable, KeyL
 				
 				userList.setModel(model);
 			} else if (fromServer instanceof String) {
-				chat.log(new Message((String)fromServer, MessageType.NORMAL, false));
+				chat.log(new Message((String) fromServer, MessageType.NORMAL, false));
 			} else
 				throw new ClassNotFoundException();
 		}
 	}
-
+	
 	@Override
 	public void keyPressed(KeyEvent eKey) {
 		int keyCode = eKey.getKeyCode();
-		 switch( keyCode ) {
-	        case KeyEvent.VK_UP:
-	        	if (messIndex > 0)
-	        		messIndex--;
-	        	if (!lastMess.isEmpty())
-	        		write.setText(lastMess.get(messIndex));
-	            break;
-	        case KeyEvent.VK_DOWN:
-	        	if (messIndex <= lastMess.size())
-	        		messIndex++;
-	        	if (messIndex >= lastMess.size()) {
-	        		messIndex = lastMess.size();
-	        		write.setText("");
-	        	} else
-	        		write.setText(lastMess.get(messIndex));
-	            break;
-	        case KeyEvent.VK_ENTER:
-	        	String text = write.getText().trim();
-	    		if (!text.equals("")) {
-	    			send(text);
-	    			lastMess.add(text);
-	    			messIndex = lastMess.size();
-	    			write.setText("");
-	    		}
-	        	break;
-	     }
+		switch (keyCode) {
+		case KeyEvent.VK_UP:
+			if (messIndex > 0)
+				messIndex--;
+			if (!lastMess.isEmpty())
+				write.setText(lastMess.get(messIndex));
+			break;
+		case KeyEvent.VK_DOWN:
+			if (messIndex <= lastMess.size())
+				messIndex++;
+			if (messIndex >= lastMess.size()) {
+				messIndex = lastMess.size();
+				write.setText("");
+			} else
+				write.setText(lastMess.get(messIndex));
+			break;
+		case KeyEvent.VK_ENTER:
+			String text = write.getText().trim();
+			if (!text.equals("")) {
+				send(text);
+				lastMess.add(text);
+				messIndex = lastMess.size();
+				write.setText("");
+			}
+			break;
+		}
 	}
-
+	
 	@Override
 	public void keyReleased(KeyEvent arg0) {}
-
+	
 	@Override
 	public void keyTyped(KeyEvent arg0) {}
 }

+ 6 - 4
src/main/java/client/Console.java

@@ -1,7 +1,9 @@
 package client;
 
-import javax.swing.*;
-import javax.swing.text.*;
+import javax.swing.JTextPane;
+import javax.swing.SwingUtilities;
+import javax.swing.text.SimpleAttributeSet;
+import javax.swing.text.StyledDocument;
 
 import common.Message;
 
@@ -30,8 +32,8 @@ public class Console extends JTextPane {
 		@Override
 		public synchronized void run() {
 			try {
-			    doc.insertString(doc.getLength(), text + "\n", style);
-			} catch(Exception e) {
+				doc.insertString(doc.getLength(), text + "\n", style);
+			} catch (Exception e) {
 				System.out.println(e);
 			}
 		}

+ 11 - 11
src/main/java/command/Ban.java

@@ -3,17 +3,18 @@ package command;
 import java.util.InputMismatchException;
 import java.util.Optional;
 
-import common.Command;
-import common.Message;
-import common.Message.MessageType;
+import server.BanNote;
 import server.Client;
 import server.Server;
-import server.BanNote;
 import util.Numbers;
 import util.StringArrays;
 
-public class Ban extends Command {
+import common.Command;
+import common.Message;
+import common.Message.MessageType;
 
+public class Ban extends Command {
+	
 	@Override
 	public void execute(String[] args, Client caller) {
 		String IP = null;
@@ -29,7 +30,6 @@ public class Ban extends Command {
 			return;
 		}
 		
-		
 		IP = victim.sock.getInetAddress().toString();
 		
 		BanNote bn = new BanNote(IP);
@@ -48,25 +48,25 @@ public class Ban extends Command {
 		
 		Server.banNotes.add(bn);
 	}
-
+	
 	@Override
 	public String getName() {
 		return "ban";
 	}
-
+	
 	@Override
 	public String getPermission() {
 		return "server.ban";
 	}
-
+	
 	@Override
 	public String getDescription() {
 		return "Bans a user. (/ban <username> [seconds] [reason])";
 	}
-
+	
 	@Override
 	public int getMinArgNumber() {
 		return 1;
 	}
-
+	
 }

+ 9 - 8
src/main/java/command/CreateChannel.java

@@ -1,37 +1,38 @@
 package command;
 
-import common.Command;
-import common.Message;
 import server.Client;
 import server.Server;
 
-public class CreateChannel extends Command{
+import common.Command;
+import common.Message;
 
+public class CreateChannel extends Command {
+	
 	@Override
 	public void execute(String[] args, Client caller) throws Exception {
 		Server.channels.add(new server.Channel(args[0]));
 		
 		Server.wideBroadcast(new Message("Channel " + args[0] + " is now available. Use '/join " + args[0] + "' to join."));
 	}
-
+	
 	@Override
 	public String getName() {
 		return "createchannel";
 	}
-
+	
 	@Override
 	public String getPermission() {
 		return "server.createchannel";
 	}
-
+	
 	@Override
 	public String getDescription() {
 		return "Creates a channel with specified settings. (/createchannel <name>)";
 	}
-
+	
 	@Override
 	public int getMinArgNumber() {
 		return 1;
 	}
-
+	
 }

+ 8 - 8
src/main/java/command/Exit.java

@@ -1,35 +1,35 @@
 package command;
 
-import common.Command;
-
 import server.Client;
 import server.Server;
 
-public class Exit extends Command{
+import common.Command;
 
+public class Exit extends Command {
+	
 	@Override
 	public void execute(String[] args, Client caller) {
 		Server.exit();
 	}
-
+	
 	@Override
 	public String getName() {
 		return "exit";
 	}
-
+	
 	@Override
 	public int getMinArgNumber() {
 		return 0;
 	}
-
+	
 	@Override
 	public String getDescription() {
 		return "Exits the server.";
 	}
-
+	
 	@Override
 	public String getPermission() {
 		return "server.exit";
 	}
-
+	
 }

+ 11 - 10
src/main/java/command/Help.java

@@ -4,47 +4,48 @@ import java.util.Iterator;
 import java.util.Map;
 import java.util.Map.Entry;
 
+import server.Client;
+import server.Server;
+
 import common.Command;
 import common.Message;
 import common.Message.MessageType;
-import server.Client;
-import server.Server;
 
 public class Help extends Command {
-
+	
 	@Override
 	public void execute(String[] args, Client caller) {
 		String help = "Help for all commands:" + "\n";
 		Iterator<Entry<String, Command>> it = Server.commReg.entrySet().iterator();
-
+		
 		while (it.hasNext()) {
 			Map.Entry<String, Command> pair = it.next();
-
+			
 			help += pair.getKey() + ": " + "\t" + pair.getValue().getDescription();
 			if (it.hasNext())
 				help += "\n";
 		}
 		caller.send(new Message(help, MessageType.COMMAND, false));
 	}
-
+	
 	@Override
 	public String getName() {
 		return "help";
 	}
-
+	
 	@Override
 	public int getMinArgNumber() {
 		return 0;
 	}
-
+	
 	@Override
 	public String getDescription() {
 		return "Writes the descriptions for all commands.";
 	}
-
+	
 	@Override
 	public String getPermission() {
 		return "noob.help";
 	}
-
+	
 }

+ 11 - 10
src/main/java/command/JoinChannel.java

@@ -2,15 +2,16 @@ package command;
 
 import java.util.Optional;
 
-import common.Command;
-import common.Message;
-import common.Message.MessageType;
 import server.Channel;
 import server.Client;
 import server.Server;
 
-public class JoinChannel extends Command {
+import common.Command;
+import common.Message;
+import common.Message.MessageType;
 
+public class JoinChannel extends Command {
+	
 	@Override
 	public void execute(String[] args, Client caller) {
 		if (caller.equals(Server.OPClient)) {
@@ -19,7 +20,7 @@ public class JoinChannel extends Command {
 		}
 		
 		Optional<Channel> maybeChannel = Server.getChannelByName(args[0]);
-		Channel selectedChannel = maybeChannel.isPresent()? maybeChannel.get() : null;
+		Channel selectedChannel = maybeChannel.isPresent() ? maybeChannel.get() : null;
 		
 		try {
 			selectedChannel.add(caller);
@@ -29,25 +30,25 @@ public class JoinChannel extends Command {
 			caller.send(new Message("No such channel!", MessageType.ERROR, false));
 		}
 	}
-
+	
 	@Override
 	public String getName() {
 		return "join";
 	}
-
+	
 	@Override
 	public String getPermission() {
 		return "noob.channel";
 	}
-
+	
 	@Override
 	public String getDescription() {
 		return "Sets specified channel as primary (/join <channel>)";
 	}
-
+	
 	@Override
 	public int getMinArgNumber() {
 		return 1;
 	}
-
+	
 }

+ 8 - 7
src/main/java/command/Kick.java

@@ -2,14 +2,15 @@ package command;
 
 import java.util.Optional;
 
+import server.Client;
+import server.Server;
+
 import common.Command;
 import common.Message;
 import common.Message.MessageType;
-import server.Client;
-import server.Server;
 
 public class Kick extends Command {
-
+	
 	@Override
 	public void execute(String[] args, Client caller) {
 		Optional<Client> maybeVictim = Server.getUserByName(args[0]);
@@ -20,22 +21,22 @@ public class Kick extends Command {
 			caller.send(new Message("No user called " + args[0] + "!", MessageType.ERROR, false));
 		}
 	}
-
+	
 	@Override
 	public String getName() {
 		return "kick";
 	}
-
+	
 	@Override
 	public int getMinArgNumber() {
 		return 1;
 	}
-
+	
 	@Override
 	public String getDescription() {
 		return "Kicks a user. (/kick <username>)";
 	}
-
+	
 	@Override
 	public String getPermission() {
 		return "server.kick";

+ 13 - 12
src/main/java/command/LeaveChannel.java

@@ -2,24 +2,25 @@ package command;
 
 import java.util.Optional;
 
-import common.Command;
-import common.Message;
-import common.Message.MessageType;
 import server.Channel;
 import server.Client;
 import server.Server;
 
-public class LeaveChannel extends Command{
+import common.Command;
+import common.Message;
+import common.Message.MessageType;
 
+public class LeaveChannel extends Command {
+	
 	@Override
 	public void execute(String[] args, Client caller) throws Exception {
-		if (caller.equals(Server.OPClient)){
+		if (caller.equals(Server.OPClient)) {
 			caller.send("Client-only command.");
 			return;
 		}
 		
 		Optional<Channel> maybeChannel = Server.getChannelByName(args[0]);
-		Channel selectedChannel = maybeChannel.isPresent()? maybeChannel.get() : null;
+		Channel selectedChannel = maybeChannel.isPresent() ? maybeChannel.get() : null;
 		
 		try {
 			selectedChannel.remove(caller);
@@ -27,30 +28,30 @@ public class LeaveChannel extends Command{
 				caller.primaryChannel = Server.channels.get(0);
 			caller.send(new Message("You left channel " + args[0] + ".", MessageType.COMMAND, false));
 			caller.send(new Message("You are now speaking in channel " + caller.primaryChannel.name + ".", MessageType.COMMAND, false));
-		} catch(NullPointerException ex) {
+		} catch (NullPointerException ex) {
 			caller.send(new Message("No channel named " + args[0] + ".", MessageType.ERROR, false));
 			return;
 		}
 	}
-
+	
 	@Override
 	public String getName() {
 		return "leave";
 	}
-
+	
 	@Override
 	public String getPermission() {
 		return "noob.leave";
 	}
-
+	
 	@Override
 	public String getDescription() {
 		return "Removes caller from specified channel. (/leave <channel>)";
 	}
-
+	
 	@Override
 	public int getMinArgNumber() {
 		return 1;
 	}
-
+	
 }

+ 11 - 10
src/main/java/command/List.java

@@ -2,13 +2,14 @@ package command;
 
 import java.util.Optional;
 
-import common.Command;
-import common.Message;
-import common.Message.MessageType;
 import server.Channel;
 import server.Client;
 import server.Server;
 
+import common.Command;
+import common.Message;
+import common.Message.MessageType;
+
 public class List extends Command {
 	
 	@Override
@@ -17,7 +18,7 @@ public class List extends Command {
 		
 		if (args.length >= 1) {
 			Optional<Channel> maybeChannel = Server.getChannelByName(args[0]);
-			Channel selectedChannel = maybeChannel.isPresent()? maybeChannel.get() : null;
+			Channel selectedChannel = maybeChannel.isPresent() ? maybeChannel.get() : null;
 			try {
 				arr = selectedChannel.listClients();
 				channelName = selectedChannel.name;
@@ -26,32 +27,32 @@ public class List extends Command {
 				return;
 			}
 		} else
-			arr =  Server.listClients();
+			arr = Server.listClients();
 		
 		if (channelName == null)
 			caller.send(new Message("Users online are:" + "\n" + arr, MessageType.COMMAND, false));
 		else
 			caller.send(new Message("Users in channel " + channelName + " are:" + "\n" + arr, MessageType.COMMAND, false));
 	}
-
+	
 	@Override
 	public String getName() {
 		return "list";
 	}
-
+	
 	@Override
 	public int getMinArgNumber() {
 		return 0;
 	}
-
+	
 	@Override
 	public String getDescription() {
 		return "Lists all users online. (/list [channel])";
 	}
-
+	
 	@Override
 	public String getPermission() {
 		return "noob.list";
 	}
-
+	
 }

+ 14 - 12
src/main/java/command/PrivateMessage.java

@@ -2,15 +2,16 @@ package command;
 
 import java.util.Optional;
 
-import common.Command;
-import common.Message;
-import common.Message.MessageType;
 import server.Client;
 import server.Server;
 import util.StringArrays;
 
-public class PrivateMessage extends Command {
+import common.Command;
+import common.Message;
+import common.Message.MessageType;
 
+public class PrivateMessage extends Command {
+	
 	@Override
 	public void execute(String[] args, Client caller) {
 		Client reciever;
@@ -31,29 +32,30 @@ public class PrivateMessage extends Command {
 		}
 		
 		Message mess = new Message("PM", caller.username, StringArrays.arrayToString(StringArrays.removeFirst(args)), Message.MessageType.PM);
-
-		reciever.send(mess); caller.send(mess);
-
+		
+		reciever.send(mess);
+		caller.send(mess);
+		
 	}
-
+	
 	@Override
 	public String getName() {
 		return "pm";
 	}
-
+	
 	@Override
 	public String getPermission() {
 		return "noob.pm";
 	}
-
+	
 	@Override
 	public String getDescription() {
 		return "Sends a private message to a user";
 	}
-
+	
 	@Override
 	public int getMinArgNumber() {
 		return 2;
 	}
-
+	
 }

+ 9 - 5
src/main/java/common/Command.java

@@ -3,9 +3,13 @@ package common;
 import server.Client;
 
 public abstract class Command {
-	public abstract void execute (String[] args, Client caller) throws Exception;
-	public abstract String getName ();
-	public abstract String getPermission ();
-	public abstract String getDescription ();
-	public abstract int getMinArgNumber ();
+	public abstract void execute(String[] args, Client caller) throws Exception;
+	
+	public abstract String getName();
+	
+	public abstract String getPermission();
+	
+	public abstract String getDescription();
+	
+	public abstract int getMinArgNumber();
 }

+ 2 - 2
src/main/java/common/Message.java

@@ -41,7 +41,7 @@ public class Message implements java.io.Serializable {
 	
 	public Message(String con, MessageType messType, boolean preInfo) { //TODO Needs to include Server.getUsersOnline() to prevent NullPointerException
 		this.content = con;
-		this.preInfo = preInfo; 
+		this.preInfo = preInfo;
 		this.messType = messType;
 		if (preInfo)
 			usersOnline = Server.getUsersOnline();
@@ -78,7 +78,7 @@ public class Message implements java.io.Serializable {
 			break;
 		default:
 			break;
-		}	
+		}
 		
 		DateFormat dateFormat = new SimpleDateFormat("[HH:mm:ss]");
 		Date time = new Date();

+ 5 - 4
src/main/java/server/Client.java

@@ -8,6 +8,7 @@ import java.io.InputStreamReader;
 import java.io.ObjectOutputStream;
 import java.net.Socket;
 import java.time.LocalDateTime;
+
 import javax.swing.Timer;
 
 import common.Message;
@@ -58,7 +59,7 @@ public class Client implements Runnable, ActionListener {
 	
 	private boolean validateUser() {
 		//No spaces
-		if (username.contains(" ")){
+		if (username.contains(" ")) {
 			send("No spaces in usernames please!");
 			return false;
 		}
@@ -68,7 +69,7 @@ public class Client implements Runnable, ActionListener {
 			send("Username already taken!");
 			return false;
 		}
-			
+		
 		//No connect if banned
 		for (BanNote note: Server.banNotes)
 			if (note.ip.equals(sock.getInetAddress().toString())) {
@@ -123,7 +124,7 @@ public class Client implements Runnable, ActionListener {
 		}
 		return false;
 	}
-
+	
 	@Override
 	public void run() {
 		String lastMess;
@@ -164,7 +165,7 @@ public class Client implements Runnable, ActionListener {
 	public String toString() {
 		return username;
 	}
-
+	
 	@Override
 	public void actionPerformed(ActionEvent e) {
 		messLastPeriod = 0;

+ 2 - 2
src/main/java/server/ClientCollection.java

@@ -5,7 +5,7 @@ import java.util.Optional;
 
 import common.Message;
 
-public class ClientCollection extends ArrayList<Client>{
+public class ClientCollection extends ArrayList<Client> {
 	/**
 	 * 
 	 */
@@ -29,7 +29,7 @@ public class ClientCollection extends ArrayList<Client>{
 	}
 	
 	void broadcast(Message mess) { //Broadcast to all
-		 if (mess.validate()) {
+		if (mess.validate()) {
 			for (Client c: this)
 				c.send(mess);
 			Server.OPClient.send(mess.toString());

+ 5 - 4
src/main/java/server/CommandRegistry.java

@@ -5,15 +5,16 @@ import java.util.List;
 
 import util.ClassFinder;
 import util.StringArrays;
+
 import common.Command;
 
 public class CommandRegistry extends HashMap<String, Command> {
-
+	
 	/**
 	 * 
 	 */
 	private static final long serialVersionUID = 1L;
-
+	
 	public CommandRegistry() {
 		List<Class<?>> classes = ClassFinder.find("command");
 		
@@ -26,7 +27,7 @@ public class CommandRegistry extends HashMap<String, Command> {
 			}
 		}
 	}
-
+	
 	public void executeCommand(String[] command, Client caller) {
 		Command comm;
 		if ((comm = get(command[0])) != null) // Get the command
@@ -51,5 +52,5 @@ public class CommandRegistry extends HashMap<String, Command> {
 		else
 			caller.send("No such command! Type '/help' for a list of commands.");
 	}
-
+	
 }

+ 4 - 3
src/main/java/server/Pong.java

@@ -9,15 +9,16 @@ public class Pong implements ActionListener {
 	
 	Timer tim = new Timer(100, this);
 	
-	Client player1; Client player2;
+	Client player1;
+	Client player2;
 	
-	public Pong (Client p1, Client p2) {
+	public Pong(Client p1, Client p2) {
 		player1 = p1;
 		player2 = p2;
 		
 		// TODO Initialize game here
 	}
-
+	
 	@Override
 	public void actionPerformed(ActionEvent arg0) {
 		// TODO Update game logic here

+ 11 - 11
src/main/java/server/Server.java

@@ -5,12 +5,11 @@ import java.net.ServerSocket;
 import java.util.ArrayList;
 import java.util.Optional;
 
-import common.Message;
-import server.CommandRegistry;
-import server.Channel;
 import util.Logger;
 import util.ServerProperties;
 
+import common.Message;
+
 public class Server {
 	static ServerProperties prop = new ServerProperties();
 	static int port, maxUsers;
@@ -25,7 +24,7 @@ public class Server {
 	public static Logger log;
 	public static CommandRegistry commReg;
 	
-	public static void main(String[] arg){
+	public static void main(String[] arg) {
 		System.out.println("Starting ChatServer version " + version + "...");
 		
 		System.out.print("Loadning properties file...");
@@ -40,7 +39,7 @@ public class Server {
 		System.out.print("Setting up socket...");
 		try {
 			so = new ServerSocket(port);
-		} catch(IOException ex) {
+		} catch (IOException ex) {
 			System.out.println("Error setting up socket. Server already running?");
 			System.exit(0);
 		}
@@ -73,9 +72,9 @@ public class Server {
 		
 		getClients();
 	}
-
+	
 	static void getClients() {
-		while(!so.isClosed()) {
+		while (!so.isClosed()) {
 			Client newClient = null;
 			try {
 				newClient = new Client(Server.so.accept());
@@ -100,11 +99,11 @@ public class Server {
 	public static Optional<Channel> getChannelByName(String name) throws NullPointerException {
 		return channels.stream().filter(c -> c.name.equals(name)).findFirst();
 	}
-
+	
 	public static void wideBroadcast(Message mess) {
 		clients.broadcast(mess);
 	}
-
+	
 	public static String[] getUsersOnline() {
 		return clients.listClientsArray();
 	}
@@ -112,7 +111,7 @@ public class Server {
 	public static String listClients() {
 		return clients.listClients();
 	}
-
+	
 	public static Optional<Client> getUserByName(String username) {
 		return clients.getClientByName(username);
 	}
@@ -125,7 +124,8 @@ public class Server {
 	public static void exit() {
 		wideBroadcast(new Message("Shutting down server!"));
 		
-		for (int i = 0; i < clients.size(); i++) //Has to be done with number iteration, otherwise unsafe
+		for (int i = 0; i < clients.size(); i++)
+			//Has to be done with number iteration, otherwise unsafe
 			clients.get(i).disconnect();
 		
 		log.close();

+ 38 - 38
src/main/java/util/ClassFinder.java

@@ -9,42 +9,42 @@ import java.util.List;
 
 public class ClassFinder {
 	private static final char DOT = '.';
-
-    private static final char SLASH = '/';
-
-    private static final String CLASS_SUFFIX = ".class";
-
-    private static final String BAD_PACKAGE_ERROR = "Unable to get resources from path '%s'. Are you sure the package '%s' exists?";
-
-    public static List<Class<?>> find(String scannedPackage) {
-        String scannedPath = scannedPackage.replace(DOT, SLASH);
-        URL scannedUrl = Thread.currentThread().getContextClassLoader().getResource(scannedPath);
-        if (scannedUrl == null) {
-            throw new IllegalArgumentException(String.format(BAD_PACKAGE_ERROR, scannedPath, scannedPackage));
-        }
-        File scannedDir = new File(scannedUrl.getFile());
-        List<Class<?>> classes = new ArrayList<Class<?>>();
-        for (File file : scannedDir.listFiles()) {
-            classes.addAll(find(file, scannedPackage));
-        }
-        return classes;
-    }
-
-    private static List<Class<?>> find(File file, String scannedPackage) {
-        List<Class<?>> classes = new ArrayList<Class<?>>();
-        String resource = scannedPackage + DOT + file.getName();
-        if (file.isDirectory()) {
-            for (File child : file.listFiles()) {
-                classes.addAll(find(child, resource));
-            }
-        } else if (resource.endsWith(CLASS_SUFFIX)) {
-            int endIndex = resource.length() - CLASS_SUFFIX.length();
-            String className = resource.substring(0, endIndex);
-            try {
-                classes.add(Class.forName(className));
-            } catch (ClassNotFoundException ignore) {
-            }
-        }
-        return classes;
-    }
+	
+	private static final char SLASH = '/';
+	
+	private static final String CLASS_SUFFIX = ".class";
+	
+	private static final String BAD_PACKAGE_ERROR = "Unable to get resources from path '%s'. Are you sure the package '%s' exists?";
+	
+	public static List<Class<?>> find(String scannedPackage) {
+		String scannedPath = scannedPackage.replace(DOT, SLASH);
+		URL scannedUrl = Thread.currentThread().getContextClassLoader().getResource(scannedPath);
+		if (scannedUrl == null) {
+			throw new IllegalArgumentException(String.format(BAD_PACKAGE_ERROR, scannedPath, scannedPackage));
+		}
+		File scannedDir = new File(scannedUrl.getFile());
+		List<Class<?>> classes = new ArrayList<Class<?>>();
+		for (File file: scannedDir.listFiles()) {
+			classes.addAll(find(file, scannedPackage));
+		}
+		return classes;
+	}
+	
+	private static List<Class<?>> find(File file, String scannedPackage) {
+		List<Class<?>> classes = new ArrayList<Class<?>>();
+		String resource = scannedPackage + DOT + file.getName();
+		if (file.isDirectory()) {
+			for (File child: file.listFiles()) {
+				classes.addAll(find(child, resource));
+			}
+		} else if (resource.endsWith(CLASS_SUFFIX)) {
+			int endIndex = resource.length() - CLASS_SUFFIX.length();
+			String className = resource.substring(0, endIndex);
+			try {
+				classes.add(Class.forName(className));
+			} catch (ClassNotFoundException ignore) {
+			}
+		}
+		return classes;
+	}
 }

+ 1 - 1
src/main/java/util/ServerProperties.java

@@ -6,7 +6,7 @@ import java.io.FileNotFoundException;
 import java.io.FileWriter;
 import java.io.IOException;
 
-public class ServerProperties extends java.util.Properties{
+public class ServerProperties extends java.util.Properties {
 	/**
 	 * 
 	 */

+ 3 - 3
src/main/java/util/StringArrays.java

@@ -2,13 +2,13 @@ package util;
 
 public class StringArrays {
 	public static String[] removeFirst(String[] oldArr) {
-		String[] newArr = new String[oldArr.length -1];
+		String[] newArr = new String[oldArr.length - 1];
 		for (int i = 1; i < oldArr.length; i++) {
-			newArr[i -1] = oldArr[i];
+			newArr[i - 1] = oldArr[i];
 		}
 		return newArr;
 	}
-
+	
 	public static String arrayToString(String[] arr) {
 		return arr.toString().replace("[", "").replace("]", "")
 				.replace(", ", " ");

+ 13 - 13
src/test/java/client/ClientTestCase.java

@@ -1,6 +1,6 @@
 package client;
 
-import static org.junit.Assert.*;
+import static org.junit.Assert.assertTrue;
 
 import org.junit.AfterClass;
 import org.junit.BeforeClass;
@@ -12,19 +12,19 @@ public class ClientTestCase {
 	public static ChatWindow user1;
 	public static ChatWindow user2;
 	
-	static Thread runServer = new Thread(){
-    	@Override
-    	public void run() {
-    		Server.main(new String[]{});
-    	}
-    };
+	static Thread runServer = new Thread() {
+		@Override
+		public void run() {
+			Server.main(new String[] {});
+		}
+	};
 	
-    @BeforeClass 
-    public static void setUpClass() {
+	@BeforeClass
+	public static void setUpClass() {
 		runServer.start();
-        user1 = new ChatWindow("localhost", 25566, "user1");
-        assertTrue(user1.so.isConnected());
-    }
+		user1 = new ChatWindow("localhost", 25566, "user1");
+		assertTrue(user1.so.isConnected());
+	}
 	
 	@Test
 	public void testSend() {
@@ -42,5 +42,5 @@ public class ClientTestCase {
 	public static void tearDownClass() {
 		Server.exit();
 	}
-
+	
 }

+ 1 - 1
src/test/java/client/ClientTestSuite.java

@@ -5,5 +5,5 @@ import org.junit.runners.Suite;
 import org.junit.runners.Suite.SuiteClasses;
 
 @RunWith(value = Suite.class)
-@SuiteClasses(value = { ClientTestCase.class })
+@SuiteClasses(value = {ClientTestCase.class})
 public class ClientTestSuite {}

+ 3 - 3
src/test/java/common/CompleteTestSuite.java

@@ -1,22 +1,22 @@
 package common;
 
-
 import org.junit.AfterClass;
 import org.junit.BeforeClass;
 import org.junit.runner.RunWith;
 import org.junit.runners.Suite;
 import org.junit.runners.Suite.SuiteClasses;
+
 import server.ServerTestSuite;
 
 @RunWith(Suite.class)
-@SuiteClasses({ ServerTestSuite.class, client.ClientTestSuite.class })
+@SuiteClasses({ServerTestSuite.class, client.ClientTestSuite.class})
 public class CompleteTestSuite {
 	
 	@BeforeClass
 	public static void setUpBeforeClass() throws Exception {
 		
 	}
-
+	
 	@AfterClass
 	public static void tearDownAfterClass() throws Exception {
 		

+ 5 - 5
src/test/java/server/ServerTestCase.java

@@ -1,6 +1,6 @@
 package server;
 
-import static org.junit.Assert.*;
+import static org.junit.Assert.assertEquals;
 
 import org.junit.AfterClass;
 import org.junit.BeforeClass;
@@ -10,10 +10,10 @@ import util.Numbers;
 
 public class ServerTestCase {
 	
-	@BeforeClass 
-    public static void setUpClass() {
-    	ServerTestSuite.runServer.start();
-    }
+	@BeforeClass
+	public static void setUpClass() {
+		ServerTestSuite.runServer.start();
+	}
 	
 	@Test
 	public void testCInt() {

+ 7 - 7
src/test/java/server/ServerTestSuite.java

@@ -5,13 +5,13 @@ import org.junit.runners.Suite;
 import org.junit.runners.Suite.SuiteClasses;
 
 @RunWith(value = Suite.class)
-@SuiteClasses(value = { client.ClientTestSuite.class })
+@SuiteClasses(value = {client.ClientTestSuite.class})
 public class ServerTestSuite {
 	
-	public static Thread runServer = new Thread(){
-    	@Override
-    	public void run() {
-    		Server.main(new String[]{});
-    	}
-    };
+	public static Thread runServer = new Thread() {
+		@Override
+		public void run() {
+			Server.main(new String[] {});
+		}
+	};
 }