generated from FabricMC/fabric-example-mod
-
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
Polyana
committed
Dec 22, 2023
1 parent
ef58bd2
commit 9507f21
Showing
6 changed files
with
49 additions
and
16 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
15 changes: 15 additions & 0 deletions
15
api/src/main/kotlin/br/com/gamemods/minecity/api/service/MineCityInternal.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,15 @@ | ||
package br.com.gamemods.minecity.api.service | ||
|
||
import br.com.gamemods.minecity.api.MineCity | ||
import br.com.gamemods.minecity.api.annotation.internal.InternalMineCityApi | ||
|
||
/** | ||
* Internal MineCity states and services, should not be used by API users. | ||
*/ | ||
@InternalMineCityApi | ||
public object MineCityInternal { | ||
/** | ||
* Access to the MineCity API implementation, must be modified only by MineCity itself, can be accessed freely. | ||
*/ | ||
public lateinit var implementation: MineCity | ||
} |
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
20 changes: 20 additions & 0 deletions
20
...src/main/kotlin/br/com/gamemods/minecity/core/service/permission/CorePermissionService.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 br.com.gamemods.minecity.core.service.permission | ||
|
||
import br.com.gamemods.minecity.api.annotation.internal.InternalMineCityApi | ||
import br.com.gamemods.minecity.api.id.ClaimPermissionId | ||
import br.com.gamemods.minecity.api.service.permission.ClaimPermission | ||
import br.com.gamemods.minecity.api.service.permission.PermissionService | ||
|
||
@InternalMineCityApi | ||
class CorePermissionService: PermissionService { | ||
private val permissions = mutableMapOf<ClaimPermissionId, ClaimPermission>() | ||
|
||
override fun get(id: ClaimPermissionId): ClaimPermission = permissions[id] ?: error("Unknown permission $id") | ||
|
||
override fun plusAssign(permission: ClaimPermission) { | ||
permissions.compute(permission.id) { _, old -> | ||
if(old == null) permission | ||
else error("Permission ${permission.id} already registered") | ||
} | ||
} | ||
} |
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