Made plugins' onNewConnection work and added a onConnectionClosed method to plugins