-
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
1 parent
26a3cd8
commit 4230c8c
Showing
24 changed files
with
170 additions
and
65 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
package com.fardragi.nyaruko.client | ||
|
||
import com.fardragi.nyaruko.server.ServerProxy | ||
import com.fardragi.nyaruko.shared.IProxy | ||
|
||
class ClientProxy : ServerProxy() { | ||
class ClientProxy : IProxy { | ||
} |
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
2 changes: 1 addition & 1 deletion
2
src/main/kotlin/com/fardragi/nyaruko/core/events/PlayerMoveEvent.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
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
12 changes: 12 additions & 0 deletions
12
src/main/kotlin/com/fardragi/nyaruko/database/tables/Commands.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,12 @@ | ||
package com.fardragi.nyaruko.database.tables | ||
|
||
import com.fardragi.nyaruko.enums.PermissionLevel | ||
import org.jetbrains.exposed.dao.id.IdTable | ||
|
||
object Commands : IdTable<UInt>("commands") { | ||
override val id = uinteger("id").entityId().autoIncrement() | ||
val name = varchar("name", 255) | ||
val level = enumerationByName("level", 6, PermissionLevel::class) | ||
|
||
override val primaryKey = PrimaryKey(id) | ||
} |
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
14 changes: 12 additions & 2 deletions
14
src/main/kotlin/com/fardragi/nyaruko/enums/PermissionLevel.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 |
---|---|---|
@@ -1,7 +1,17 @@ | ||
package com.fardragi.nyaruko.enums | ||
|
||
enum class PermissionLevel(val level: Int) { | ||
True(0), | ||
All(0), | ||
Op(4), | ||
False(5), | ||
Nobody(5); | ||
|
||
companion object { | ||
fun fromLevel(level: Int): PermissionLevel { | ||
return when (level) { | ||
0 -> All | ||
in 1..4 -> Op | ||
else -> Nobody | ||
} | ||
} | ||
} | ||
} |
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,13 @@ | ||
package com.fardragi.nyaruko.models | ||
|
||
import com.fardragi.nyaruko.database.tables.Commands | ||
import org.jetbrains.exposed.dao.Entity | ||
import org.jetbrains.exposed.dao.EntityClass | ||
import org.jetbrains.exposed.dao.id.EntityID | ||
|
||
class Command(id: EntityID<UInt>) : Entity<UInt>(id) { | ||
companion object : EntityClass<UInt, Command>(Commands) | ||
|
||
var name by Commands.name | ||
var level by Commands.level | ||
} |
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
22 changes: 16 additions & 6 deletions
22
src/main/kotlin/com/fardragi/nyaruko/permission/PermissionModule.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 |
---|---|---|
@@ -1,13 +1,23 @@ | ||
package com.fardragi.nyaruko.permission | ||
|
||
import com.fardragi.nyaruko.enums.PermissionLevel | ||
import com.fardragi.nyaruko.services.CommandService | ||
import com.fardragi.nyaruko.shared.IModule | ||
import org.koin.core.component.KoinScopeComponent | ||
import org.koin.core.component.createScope | ||
import net.minecraft.command.CommandBase | ||
import net.minecraft.server.MinecraftServer | ||
import org.koin.core.component.KoinComponent | ||
import org.koin.core.component.inject | ||
|
||
class PermissionModule() : KoinScopeComponent, IModule { | ||
override val scope by lazy { createScope(this) } | ||
class PermissionModule() : IModule, KoinComponent { | ||
private val commandService: CommandService by inject() | ||
|
||
override fun start() { | ||
TODO("Not yet implemented") | ||
override suspend fun start() { | ||
val commands = MinecraftServer.getServer().commandManager.commands.mapValues { (_, v) -> | ||
return@mapValues if (v is CommandBase) | ||
PermissionLevel.fromLevel(v.requiredPermissionLevel) | ||
else PermissionLevel.Op | ||
} | ||
|
||
commandService.registerCommands(commands as HashMap<String, PermissionLevel>) | ||
} | ||
} |
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
Oops, something went wrong.