Added defaults to new PermissionValidator functions

This commit is contained in:
Paul
2024-11-22 09:37:12 +10:00
parent ce6087f368
commit 40957b6eac
3 changed files with 9 additions and 4 deletions
@@ -22,6 +22,11 @@ enum class PermissionLevel(val numericalValue: Int) {
SPAWN_PROTECTION_BYPASS(1),
CHEAT_COMMANDS_AND_COMMAND_BLOCKS(2),
MULTIPLAYER_MANAGEMENT(3),
ALL_COMMANDS(4)
ALL_COMMANDS(4);
companion object {
fun byNumericValue(value: Int): PermissionLevel {
return entries.first { it.numericalValue == value }
}
}
}
@@ -42,7 +42,7 @@ interface PermissionValidator {
* @param permission The permission string being queried such as cobblemon.command.giveallpokemon.
* @param level The permission level being queried. 4 is generally used for cheats.
*/
fun hasPermission(player: ServerPlayer, permission: String, level: Int): Boolean
fun hasPermission(player: ServerPlayer, permission: String, level: Int): Boolean = hasPermission(player, CobblemonPermission(permission, PermissionLevel.byNumericValue(level)))
/**
* Validates a permission for [CommandSource].
@@ -59,5 +59,5 @@ interface PermissionValidator {
* @param permission The permission string being queried such as cobblemon.command.giveallpokemon.
* @param level The permission level being queried. 4 is generally used for cheats.
*/
fun hasPermission(source: CommandSourceStack, permission: String, level: Int): Boolean
fun hasPermission(source: CommandSourceStack, permission: String, level: Int): Boolean = hasPermission(source, CobblemonPermission(permission, PermissionLevel.byNumericValue(level)))
}
@@ -133,7 +133,7 @@ object CatchRateModifiers {
*/
val LURE = WorldStateModifier { _, entity ->
if (FishingSpawnCause.FISHED_ASPECT in entity.aspects)
4f
4F
else
1F
}