@Override
        public void run() {
                try {
                        try {
                                output = new ObjectOutputStream(connection.getSocket().getOutputStream());
                        } catch (IOException ioe) {
                                connection.sendMessage(new SocketDisconnectedMessage(connection, DisconnectCause.IO_ERROR));
                                return;
                        }
                        while (true) {
                                Object msg = null;
                                try {
                                        msg = input.take();
                                } catch (InterruptedException ie) {
                                        continue;
                                }
                                if (msg instanceof SendPacketMessage) { // send the packet
                                        SendPacketMessage sendPacket = (SendPacketMessage)msg;
                                        try {
                                                output.writeObject(sendPacket.packet);
                                        } catch (IOException ioe) {
                                                getPlugin().getLogger().warning("SocketWriter.run(): writeObject(): " + ioe);
                                                break;
                                        }
                                } else if (msg instanceof ShutdownMessage) { // shut down
                                        break;
                                } else { // unhandled message type
                                        getPlugin().getLogger().warning("SocketWriter.run(): Unhandled Message type: " + msg.getClass().getName());
                                }
                        }
                } catch (Exception e) {
                        e.printStackTrace();
                }
                try { output.close(); } catch (IOException ioe) {}
                output = null;
                connection.shutdown();
        }