true, // durable -> true ]); } public function routeUsernameChanged(UsernameChanged $body) { $mojangApi = new MojangApi(); try { $response = $mojangApi->usernameToUUID($body->newUsername); } catch (NoContentException $e) { $response = false; } /** @var MojangUsername|null $mojangUsername */ $mojangUsername = MojangUsername::findOne($body->newUsername); if ($response === false) { if ($mojangUsername !== null) { $mojangUsername->delete(); } } else { if ($mojangUsername === null) { $mojangUsername = new MojangUsername(); $mojangUsername->username = $response->name; $mojangUsername->uuid = $response->id; } else { $mojangUsername->uuid = $response->id; $mojangUsername->touch('last_pulled_at'); } $mojangUsername->save(); } return true; } }