Skip to content

Commit

Permalink
fix: 마인크래프트 오프라인 플레이어 못찾는 버그 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
Cosine-A committed Nov 17, 2024
1 parent f3065c9 commit dcf38d3
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 7 deletions.
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ plugins {
}

group = "kr.cosine.discordauth"
version = "1.2.0"
version = "1.2.1"

repositories {
maven("https://maven.hqservice.kr/repository/maven-public")
Expand Down
11 changes: 6 additions & 5 deletions src/main/kotlin/kr/cosine/discordauth/service/AuthService.kt
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import net.dv8tion.jda.api.utils.messages.MessageCreateBuilder
import net.md_5.bungee.api.chat.ClickEvent
import net.md_5.bungee.api.chat.HoverEvent
import net.md_5.bungee.api.chat.TextComponent
import org.bukkit.Bukkit
import org.bukkit.command.CommandSender
import org.bukkit.entity.Player
import java.time.LocalDateTime
Expand Down Expand Up @@ -100,7 +101,7 @@ class AuthService(
return reply("올바르지 않은 코드입니다.")
}
val playerUniqueId = authCodeRegistry.removeByAuthCode(code) ?: return reply("UUID를 찾지 못했습니다.")
val offlinePlayer = server.getOfflinePlayer(playerUniqueId)
val offlinePlayer = Bukkit.getOfflinePlayer(playerUniqueId)
val minecraftName = offlinePlayer.name ?: return reply("마인크래프트 닉네임을 찾지 못했습니다.")

authorizedPlayerRegistry.setAuthorizedPlayer(playerUniqueId, userId)
Expand Down Expand Up @@ -168,7 +169,7 @@ class AuthService(

suspend fun removeAuth(name: String): Boolean {
return withContext(Dispatchers.IO) {
val targetOfflinePlayer = server.getOfflinePlayer(name)
val targetOfflinePlayer = Bukkit.getOfflinePlayer(name)
val targetUniqueId = targetOfflinePlayer.uniqueId
if (!isAuthorizedPlayer(targetUniqueId)) {
return@withContext false
Expand All @@ -188,8 +189,8 @@ class AuthService(
plugin.launch(Dispatchers.IO) {
val target = runCatching {
val targetUniqueId = UUID.fromString(uniqueIdOrName)
server.getOfflinePlayer(targetUniqueId)
}.getOrNull() ?: server.getOfflinePlayer(uniqueIdOrName)
Bukkit.getOfflinePlayer(targetUniqueId)
}.getOrNull() ?: Bukkit.getOfflinePlayer(uniqueIdOrName)
val targetUniqueId = target.uniqueId
val targetDiscordId = authorizedPlayerRegistry.findDiscordId(targetUniqueId) ?: run {
sender.sendMessage("§c인증되지 않은 유저입니다.")
Expand All @@ -214,7 +215,7 @@ class AuthService(
sender.sendMessage("§c인증하지 않은 유저입니다.")
return@launch
}
val target = server.getOfflinePlayer(targetUniqueId)
val target = Bukkit.getOfflinePlayer(targetUniqueId)
val targetMember = botService.findMemberById(discordId)
sender.sendMessage("§6${targetMember?.user?.name ?: "§c불러오지 못함"}§6님의 마인크래프트 정보")
sender.spigot().sendMessage(createClipboardTextComponent("디스코드 아이디", "§7(${discordId})", "$discordId"))
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/plugin.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: HQDiscordAuth
main: kr.cosine.discordauth.HQDiscordAuth
version: 1.2.0
version: 1.2.1
api-version: 1.17
author: Cosine_A
depend:
Expand Down

0 comments on commit dcf38d3

Please sign in to comment.