From 616f7e52a05a5f223d99dff3b778ec44c3ae9ca5 Mon Sep 17 00:00:00 2001 From: kdh8219 <65698239+kdh8219@users.noreply.github.com> Date: Wed, 3 May 2023 19:24:07 +0900 Subject: [PATCH] =?UTF-8?q?fix=20#5=20=EC=9D=B4=EC=A0=9C=20=EB=8B=89?= =?UTF-8?q?=EB=84=A4=EC=9E=84=EC=9D=B4=20=EB=BA=8F=EA=B8=B0=EB=8D=94?= =?UTF-8?q?=EB=9D=BC=EB=8F=84=20=EB=B2=84=EA=B7=B8=EA=B0=80=20=EC=95=88?= =?UTF-8?q?=EB=82=A9=EB=8B=88=EB=8B=A4!?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 이걸 시뮬레이션만 가지고 잡네 역시나야 --- src/wrapper/mojang-api.ts | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/wrapper/mojang-api.ts b/src/wrapper/mojang-api.ts index c02af26..845af7c 100644 --- a/src/wrapper/mojang-api.ts +++ b/src/wrapper/mojang-api.ts @@ -3,24 +3,24 @@ import axios from "axios"; import TwoWayMap from "../utils/two-way-map.js"; class MojangAPI { - private cached: TwoWayMap = new TwoWayMap(); // uuid, id + private cache: TwoWayMap = new TwoWayMap(); // uuid, id async getIdFromUUID(minecraft_uuid: string): Promise { - let id = this.cached.get_by_first(minecraft_uuid); + let id = this.cache.get_by_first(minecraft_uuid); if (id) return id; const request = await axios.get( `https://api.mojang.com/user/profile/${minecraft_uuid}` ); id = request.data.name; - if (!id) throw new Error("Failed to get minecraft id from api"); - this.cached.set_by_first(minecraft_uuid, id); + this.cache.remove_by_second(id); + this.cache.set_by_first(minecraft_uuid, id); return id; } async getUUIDFromId(minecraft_id): Promise { - let uuid = this.cached.get_by_second(minecraft_id); + let uuid = this.cache.get_by_second(minecraft_id); if (uuid) return uuid; const response = await axios.get( @@ -29,8 +29,8 @@ class MojangAPI { uuid = response.data.id; if (!uuid) throw new Error("Failed to get minecraft id from api"); - this.cached.remove_by_first(uuid); - this.cached.set_by_second(uuid, minecraft_id); + this.cache.remove_by_first(uuid); + this.cache.set_by_second(uuid, minecraft_id); return uuid; } }