-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
15 changed files
with
286 additions
and
7 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
src/main/kotlin/kr/cosine/discordauth/command/AutoFindUserAdminCommand.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package kr.cosine.discordauth.command | ||
|
||
import kr.cosine.discordauth.command.argument.DiscordIdArgument | ||
import kr.cosine.discordauth.command.argument.UniqueIdOrNameArgument | ||
import kr.cosine.discordauth.service.AuthService | ||
import kr.hqservice.framework.command.ArgumentLabel | ||
import kr.hqservice.framework.command.Command | ||
import kr.hqservice.framework.command.CommandExecutor | ||
import org.bukkit.command.CommandSender | ||
|
||
@Command(parent = AuthAdminCommand::class, label = "유저조회") | ||
class AutoFindUserAdminCommand( | ||
private val authService: AuthService | ||
) { | ||
@CommandExecutor("마크", "마크 UUID/닉네임을 기반으로 디코 닉네임/아이디를 조회합니다.", priority = 1) | ||
fun showDiscordNameAndId( | ||
sender: CommandSender, | ||
@ArgumentLabel("마크 UUID/닉네임") uniqueIdOrNameArgument: UniqueIdOrNameArgument | ||
) { | ||
authService.showDiscordNicknameAndIdByMinecraftUniqueIdOrName(sender, uniqueIdOrNameArgument.uniqueIdOrName) | ||
} | ||
|
||
@CommandExecutor("디코", "디코 아이디를 기반으로 마크 닉네임/UUID를 조회합니다.", priority = 2) | ||
fun showMinecraftNameAndUniqueId( | ||
sender: CommandSender, | ||
@ArgumentLabel("디코 아이디") discordIdArgument: DiscordIdArgument | ||
) { | ||
authService.showMinecraftNameAndUniqueIdByDiscordId(sender, discordIdArgument.discordId) | ||
} | ||
} |
5 changes: 5 additions & 0 deletions
5
src/main/kotlin/kr/cosine/discordauth/command/argument/DiscordIdArgument.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package kr.cosine.discordauth.command.argument | ||
|
||
data class DiscordIdArgument( | ||
val discordId: Long | ||
) |
5 changes: 5 additions & 0 deletions
5
src/main/kotlin/kr/cosine/discordauth/command/argument/UniqueIdOrNameArgument.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package kr.cosine.discordauth.command.argument | ||
|
||
data class UniqueIdOrNameArgument( | ||
val uniqueIdOrName: String | ||
) |
26 changes: 26 additions & 0 deletions
26
src/main/kotlin/kr/cosine/discordauth/command/provider/DiscordIdArgumentProvider.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package kr.cosine.discordauth.command.provider | ||
|
||
import kr.cosine.discordauth.command.argument.DiscordIdArgument | ||
import kr.cosine.discordauth.registry.AuthorizedPlayerRegistry | ||
import kr.hqservice.framework.command.CommandArgumentProvider | ||
import kr.hqservice.framework.command.CommandContext | ||
import kr.hqservice.framework.command.argument.exception.ArgumentFeedback | ||
import kr.hqservice.framework.global.core.component.Component | ||
import org.bukkit.Location | ||
|
||
@Component | ||
class DiscordIdArgumentProvider( | ||
private val authorizedPlayerRegistry: AuthorizedPlayerRegistry | ||
) : CommandArgumentProvider<DiscordIdArgument> { | ||
override suspend fun cast(context: CommandContext, argument: String?): DiscordIdArgument { | ||
if (argument == null) { | ||
throw ArgumentFeedback.Message("§c디스코드 아이디를 입력해주세요.") | ||
} | ||
val discordId = argument.toLongOrNull() ?: throw ArgumentFeedback.Message("§c숫자만 입력할 수 있습니다.") | ||
return DiscordIdArgument(discordId) | ||
} | ||
|
||
override suspend fun getTabComplete(context: CommandContext, location: Location?): List<String> { | ||
return authorizedPlayerRegistry.getDiscordIds().map(Long::toString) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
src/main/kotlin/kr/cosine/discordauth/command/provider/UniqueIdOrNameArgumentProvider.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package kr.cosine.discordauth.command.provider | ||
|
||
import kr.cosine.discordauth.command.argument.NameArgument | ||
import kr.cosine.discordauth.command.argument.UniqueIdOrNameArgument | ||
import kr.hqservice.framework.command.CommandArgumentProvider | ||
import kr.hqservice.framework.command.CommandContext | ||
import kr.hqservice.framework.command.argument.exception.ArgumentFeedback | ||
import kr.hqservice.framework.global.core.component.Component | ||
import org.bukkit.Location | ||
import org.bukkit.Server | ||
|
||
@Component | ||
class UniqueIdOrNameArgumentProvider( | ||
private val server: Server | ||
) : CommandArgumentProvider<UniqueIdOrNameArgument> { | ||
override suspend fun cast(context: CommandContext, argument: String?): UniqueIdOrNameArgument { | ||
if (argument == null) { | ||
throw ArgumentFeedback.Message("§cUUID 또는 닉네임을 입력해주세요.") | ||
} | ||
return UniqueIdOrNameArgument(argument) | ||
} | ||
|
||
override suspend fun getTabComplete(context: CommandContext, location: Location?): List<String> { | ||
val onlinePlayers = server.onlinePlayers | ||
return onlinePlayers.map { it.name } + onlinePlayers.map { "${it.uniqueId}" } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters