-
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
9 changed files
with
98 additions
and
32 deletions.
There are no files selected for viewing
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
47 changes: 47 additions & 0 deletions
47
...c/main/kotlin/com/projectcitybuild/pcbridge/features/register/commands/RegisterCommand.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,47 @@ | ||
package com.projectcitybuild.pcbridge.features.register.commands | ||
|
||
import com.projectcitybuild.pcbridge.features.register.repositories.RegisterRepository | ||
import com.projectcitybuild.pcbridge.support.messages.CommandHelpBuilder | ||
import com.projectcitybuild.pcbridge.support.spigot.BadCommandUsageException | ||
import com.projectcitybuild.pcbridge.support.spigot.CommandArgsParser | ||
import com.projectcitybuild.pcbridge.support.spigot.SpigotCommand | ||
import org.bukkit.command.CommandSender | ||
import org.bukkit.entity.Player | ||
|
||
class RegisterCommand( | ||
private val registerRepository: RegisterRepository, | ||
) : SpigotCommand<RegisterCommand.Args> { | ||
override val label = "register" | ||
|
||
override val usage = CommandHelpBuilder() | ||
|
||
override suspend fun run( | ||
sender: CommandSender, | ||
args: Args, | ||
) { | ||
check(sender is Player) { | ||
"Only players can use this command" | ||
} | ||
registerRepository.sendCode( | ||
email = args.email, | ||
playerAlias = sender.name, | ||
playerUUID = sender.uniqueId, | ||
) | ||
} | ||
|
||
data class Args( | ||
val email: String, | ||
) { | ||
class Parser : CommandArgsParser<Args> { | ||
override fun parse(args: List<String>): Args { | ||
if (args.isEmpty()) { | ||
throw BadCommandUsageException() | ||
} | ||
if (args.size > 1) { | ||
throw BadCommandUsageException() | ||
} | ||
return Args(email = args[0]) | ||
} | ||
} | ||
} | ||
} |
20 changes: 20 additions & 0 deletions
20
...kotlin/com/projectcitybuild/pcbridge/features/register/repositories/RegisterRepository.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,20 @@ | ||
package com.projectcitybuild.pcbridge.features.register.repositories | ||
|
||
import com.projectcitybuild.pcbridge.http.services.pcb.RegisterHttpService | ||
import java.util.UUID | ||
|
||
class RegisterRepository( | ||
private val registerHttpService: RegisterHttpService, | ||
) { | ||
suspend fun sendCode( | ||
email: String, | ||
playerAlias: String, | ||
playerUUID: UUID, | ||
) { | ||
registerHttpService.sendCode( | ||
email = email, | ||
playerAlias = playerAlias, | ||
playerUUID = playerUUID, | ||
) | ||
} | ||
} |
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