Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ data class PlayerData(
@SerializedName("player")
val player: Player? = null,

@SerializedName("groups")
val groups: List<Group> = emptyList(),
@SerializedName("roles")
val roles: List<Role> = emptyList(),

@SerializedName("badges")
val badges: List<Badge> = emptyList(),
Expand All @@ -21,5 +21,5 @@ data class PlayerData(
val elevation: HttpOpElevation? = null,
) {
val isStaff: Boolean
get() = groups.firstOrNull { it.groupType?.lowercase() == "staff" } != null
get() = roles.firstOrNull { it.roleType?.lowercase() == "staff" } != null
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import com.google.gson.annotations.SerializedName
import kotlinx.serialization.Serializable

@Serializable
data class Group(
@SerializedName("group_id")
data class Role(
@SerializedName("id")
val id: Int,

@SerializedName("name")
Expand All @@ -20,8 +20,8 @@ data class Group(
@SerializedName("minecraft_display_name")
val displayName: String?,

@SerializedName("group_type")
val groupType: String?,
@SerializedName("role_type")
val roleType: String?,

@SerializedName("display_priority")
val displayPriority: Int?,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,14 @@ internal interface PCBRequest {
@Body players: PlayersStatsRequest,
)

@POST("v3/server/op/grant")
@POST("v3/server/pim/op/grant")
@FormUrlEncoded
suspend fun opGrant(
@Field(value = "uuid") uuid: String,
@Field(value = "reason") reason: String,
): HttpOpElevation

@POST("v3/server/op/revoke")
@POST("v3/server/pim/op/revoke")
@FormUrlEncoded
suspend fun opRevoke(
@Field(value = "uuid") uuid: String,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ import com.projectcitybuild.pcbridge.paper.features.builds.buildsModule
import com.projectcitybuild.pcbridge.paper.features.chatbadge.chatBadgeModule
import com.projectcitybuild.pcbridge.paper.features.chatformatting.chatFormattingModule
import com.projectcitybuild.pcbridge.paper.features.config.configModule
import com.projectcitybuild.pcbridge.paper.features.groups.groupsModule
import com.projectcitybuild.pcbridge.paper.features.roles.rolesModule
import com.projectcitybuild.pcbridge.paper.features.homes.homesModule
import com.projectcitybuild.pcbridge.paper.features.joinmessages.joinMessagesModule
import com.projectcitybuild.pcbridge.paper.features.maintenance.maintenanceModule
Expand Down Expand Up @@ -113,7 +113,7 @@ private val featureModules = listOf(
chatBadgeModule,
chatFormattingModule,
configModule,
groupsModule,
rolesModule,
homesModule,
joinMessagesModule,
maintenanceModule,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,11 @@ import com.projectcitybuild.pcbridge.paper.features.chatformatting.hooks.listene
import com.projectcitybuild.pcbridge.paper.features.chatformatting.hooks.decorators.ChatUrlDecorator
import com.projectcitybuild.pcbridge.paper.features.config.hooks.commands.ConfigCommand
import com.projectcitybuild.pcbridge.paper.features.config.hooks.listeners.ConfigWebhookListener
import com.projectcitybuild.pcbridge.paper.features.groups.hooks.decorators.ChatGroupDecorator
import com.projectcitybuild.pcbridge.paper.features.groups.hooks.listener.ChatGroupInvalidateListener
import com.projectcitybuild.pcbridge.paper.features.groups.hooks.listener.RoleStateChangeListener
import com.projectcitybuild.pcbridge.paper.features.groups.hooks.placeholders.TabGroupListPlaceholder
import com.projectcitybuild.pcbridge.paper.features.groups.hooks.placeholders.TabGroupsPlaceholder
import com.projectcitybuild.pcbridge.paper.features.roles.hooks.decorators.ChatRoleDecorator
import com.projectcitybuild.pcbridge.paper.features.roles.hooks.listener.ChatRoleInvalidateListener
import com.projectcitybuild.pcbridge.paper.features.roles.hooks.listener.RoleStateChangeListener
import com.projectcitybuild.pcbridge.paper.features.roles.hooks.placeholders.TabRoleListPlaceholder
import com.projectcitybuild.pcbridge.paper.features.roles.hooks.placeholders.TabRolesPlaceholder
import com.projectcitybuild.pcbridge.paper.features.homes.hooks.commands.HomeCommand
import com.projectcitybuild.pcbridge.paper.features.homes.hooks.commands.HomesCommand
import com.projectcitybuild.pcbridge.paper.features.homes.hooks.listeners.HomeRenameDialogListener
Expand Down Expand Up @@ -203,7 +203,7 @@ class PluginLifecycle : KoinComponent {
get<BanDialogListener>(),
get<BlockChangeListener>(),
get<ChatBadgeInvalidateListener>(),
get<ChatGroupInvalidateListener>(),
get<ChatRoleInvalidateListener>(),
get<ConfigWebhookListener>(),
get<CoroutineExceptionListener>(),
get<EmojiConfigListener>(),
Expand Down Expand Up @@ -233,7 +233,7 @@ class PluginLifecycle : KoinComponent {
private fun registerDecorators() {
get<ChatDecoratorChain>().apply{
senders(
get<ChatGroupDecorator>(),
get<ChatRoleDecorator>(),
get<ChatBadgeDecorator>(),
)
messages(
Expand All @@ -252,13 +252,13 @@ class PluginLifecycle : KoinComponent {
get<OnlinePlayerCountPlaceholder>(),
get<MaxPlayerCountPlaceholder>(),
get<PlayerWorldPlaceholder>(),
get<TabGroupListPlaceholder>(),
get<TabRoleListPlaceholder>(),
)
players(
get<PlayerNamePlaceholder>(),
get<PlayerAFKPlaceholder>(),
get<PlayerPingPlaceholder>(),
get<TabGroupsPlaceholder>(),
get<TabRolesPlaceholder>(),
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package com.projectcitybuild.pcbridge.paper.architecture.state.data

import com.projectcitybuild.pcbridge.http.pcb.models.Account
import com.projectcitybuild.pcbridge.http.pcb.models.Badge
import com.projectcitybuild.pcbridge.http.pcb.models.Group
import com.projectcitybuild.pcbridge.http.pcb.models.Role
import com.projectcitybuild.pcbridge.http.pcb.models.Player
import com.projectcitybuild.pcbridge.http.pcb.models.PlayerData
import com.projectcitybuild.pcbridge.paper.core.libs.datetime.services.LocalizedTime
Expand Down Expand Up @@ -35,7 +35,7 @@ data class PlayerSession(
else PlayerSyncedState.Valid(
account = data.account,
player = data.player,
groups = data.groups,
roles = data.roles,
badges = data.badges,
opElevation = data.elevation?.toDomain(),
),
Expand All @@ -49,7 +49,7 @@ sealed class PlayerSyncedState {
data class Valid(
val account: Account? = null,
val player: Player? = null,
val groups: List<Group> = emptyList(),
val roles: List<Role> = emptyList(),
val badges: List<Badge> = emptyList(),
val opElevation: OpElevation? = null,
): PlayerSyncedState()
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class HomeLimitCommand(
.joinToString()

context.source.sender.sendRichMessage("<gray>---</gray>")
context.source.sender.sendRichMessage("<gray>The following groups grant you homes:</gray> $sources")
context.source.sender.sendRichMessage("<gray>The following roles grant you homes:</gray> $sources")
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class RolesDebugCommand(
return Commands.literal("debug")
.requiresPermission(PermissionNode.PIM_ROLES)
.then(
Commands.argument("groups", StringArgumentType.greedyString())
Commands.argument("roles", StringArgumentType.greedyString())
.executesSuspending(plugin, ::execute)
)
.build()
Expand All @@ -31,14 +31,14 @@ class RolesDebugCommand(
private suspend fun execute(context: PaperCommandContext) = context.scoped(syncTracer) {
val player = context.source.requirePlayer()

val groupsArg = context.getArgument("groups", String::class.java)
val groups = groupsArg.split(" ").toSet()
check(groups.isNotEmpty()) { "No groups specified" }
val rolesArg = context.getArgument("roles", String::class.java)
val roles = rolesArg.split(" ").toSet()
check(roles.isNotEmpty()) { "No roles specified" }

permissions.provider.setUserRoles(player.uniqueId, groups)
permissions.provider.setUserRoles(player.uniqueId, roles)

player.sendRichMessage(
"<red>Your groups have been set to ${groups.joinToString(",")}</red>\n" +
"<red>Your roles have been set to ${roles.joinToString(",")}</red>\n" +
"<gray>Use /sync or reconnect to revert this</gray>"
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ val registerModule = module {
factory {
VerifyCodeDialogListener(
registerHttpService = get<PCBHttp>().register,
syncPlayer = get(),
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import com.projectcitybuild.pcbridge.paper.core.libs.observability.logging.log
import com.projectcitybuild.pcbridge.paper.core.libs.observability.logging.logSync
import com.projectcitybuild.pcbridge.paper.features.register.dialogs.VerifyRegistrationCodeDialog
import com.projectcitybuild.pcbridge.paper.features.register.registerTracer
import com.projectcitybuild.pcbridge.paper.features.sync.domain.actions.SyncPlayer
import com.projectcitybuild.pcbridge.paper.l10n.l10n
import io.papermc.paper.connection.PlayerGameConnection
import io.papermc.paper.event.player.PlayerCustomClickEvent
Expand All @@ -15,6 +16,7 @@ import org.bukkit.event.Listener

class VerifyCodeDialogListener(
private val registerHttpService: RegisterHttpService,
private val syncPlayer: SyncPlayer,
) : Listener {
@EventHandler
suspend fun onPlayerCustomClickEvent(
Expand Down Expand Up @@ -50,6 +52,8 @@ class VerifyCodeDialogListener(
playerUUID = player.uniqueId,
)
player.sendRichMessage(l10n.registrationComplete)
syncPlayer.execute(playerUUID = player.uniqueId)

} catch (_: ResponseParserError.NotFound) {
val dialog = VerifyRegistrationCodeDialog.build(
email = null,
Expand Down
Loading