@Override @SuppressWarnings("unchecked") public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { if (method.getName().equals("close")) { serverDescriptor.remove(connection); LOGGER.info("Client closed {}", formatConnectionId(connection)); } if (method.getName().equals("getEntityRef")) { serverDescriptor.addKnownEntity((Class<? extends Entity>) args[0], args[1], args[2]); } try { return method.invoke(connection, args); } catch (InvocationTargetException e) { throw e.getCause(); } }