-
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
d53646c
commit bf1691a
Showing
30 changed files
with
195 additions
and
95 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
21 changes: 0 additions & 21 deletions
21
src/main/kotlin/com/fardragi/dragiutils/auth/handlers/LoginHandler.kt
This file was deleted.
Oops, something went wrong.
6 changes: 0 additions & 6 deletions
6
src/main/kotlin/com/fardragi/dragiutils/client/ClientProxy.kt
This file was deleted.
Oops, something went wrong.
21 changes: 0 additions & 21 deletions
21
src/main/kotlin/com/fardragi/dragiutils/database/DatabaseConnection.kt
This file was deleted.
Oops, something went wrong.
12 changes: 6 additions & 6 deletions
12
...ain/kotlin/com/fardragi/dragiutils/App.kt → src/main/kotlin/com/fardragi/nyaruko/App.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package com.fardragi.nyaruko | ||
|
||
import org.apache.logging.log4j.LogManager | ||
|
||
object NyarukoLog { | ||
private val logger = LogManager.getLogger("Nyaruko") | ||
|
||
fun info(message: String) { | ||
logger.info(message) | ||
} | ||
} |
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
4 changes: 2 additions & 2 deletions
4
...tlin/com/fardragi/dragiutils/auth/Auth.kt → .../kotlin/com/fardragi/nyaruko/auth/Auth.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
6 changes: 3 additions & 3 deletions
6
...om/fardragi/dragiutils/auth/AuthModule.kt → ...n/com/fardragi/nyaruko/auth/AuthModule.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
4 changes: 2 additions & 2 deletions
4
...agiutils/auth/commands/RegisterCommand.kt → .../nyaruko/auth/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
34 changes: 34 additions & 0 deletions
34
src/main/kotlin/com/fardragi/nyaruko/auth/handlers/LoginHandler.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,34 @@ | ||
package com.fardragi.nyaruko.auth.handlers | ||
|
||
import com.fardragi.nyaruko.auth.messages.LoginMessage | ||
import com.fardragi.nyaruko.auth.messages.RegisterMessage | ||
import com.fardragi.nyaruko.services.UserService | ||
import cpw.mods.fml.common.eventhandler.EventPriority | ||
import cpw.mods.fml.common.eventhandler.SubscribeEvent | ||
import cpw.mods.fml.common.gameevent.PlayerEvent.PlayerLoggedInEvent | ||
import kotlinx.coroutines.CoroutineScope | ||
import kotlinx.coroutines.Dispatchers | ||
import kotlinx.coroutines.delay | ||
import kotlinx.coroutines.launch | ||
|
||
class LoginHandler(private val userService: UserService) { | ||
@SubscribeEvent(priority = EventPriority.HIGHEST) | ||
fun onPlayerJoin(event: PlayerLoggedInEvent) { | ||
val player = event.player | ||
val userId = player.uniqueID.toString() | ||
val userName = player.displayName | ||
|
||
CoroutineScope(Dispatchers.IO).launch { | ||
val user = userService.getOrCreateUser(userId, userName) | ||
|
||
delay(2000) | ||
|
||
val message = if (user.isRegistered) | ||
LoginMessage.create() | ||
else | ||
RegisterMessage.create() | ||
|
||
player.addChatMessage(message) | ||
} | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
src/main/kotlin/com/fardragi/nyaruko/auth/messages/LoginMessage.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,14 @@ | ||
package com.fardragi.nyaruko.auth.messages | ||
|
||
import net.minecraft.util.ChatComponentText | ||
import net.minecraft.util.ChatStyle | ||
import net.minecraft.util.EnumChatFormatting | ||
|
||
object LoginMessage { | ||
fun create(): ChatComponentText { | ||
val text = ChatComponentText("use /login <password>"); | ||
text.chatStyle = ChatStyle().setColor(EnumChatFormatting.YELLOW) | ||
|
||
return text | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
src/main/kotlin/com/fardragi/nyaruko/auth/messages/RegisterMessage.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,14 @@ | ||
package com.fardragi.nyaruko.auth.messages | ||
|
||
import net.minecraft.util.ChatComponentText | ||
import net.minecraft.util.ChatStyle | ||
import net.minecraft.util.EnumChatFormatting | ||
|
||
object RegisterMessage { | ||
fun create(): ChatComponentText { | ||
val text = ChatComponentText("use /register <password> <password>"); | ||
text.chatStyle = ChatStyle().setColor(EnumChatFormatting.YELLOW) | ||
|
||
return text | ||
} | ||
} |
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,6 @@ | ||
package com.fardragi.nyaruko.client | ||
|
||
import com.fardragi.nyaruko.server.ServerProxy | ||
|
||
class ClientProxy : ServerProxy() { | ||
} |
4 changes: 2 additions & 2 deletions
4
.../com/fardragi/dragiutils/config/Config.kt → ...lin/com/fardragi/nyaruko/config/Config.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
2 changes: 1 addition & 1 deletion
2
...dragi/dragiutils/config/DatabaseConfig.kt → ...fardragi/nyaruko/config/DatabaseConfig.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
26 changes: 26 additions & 0 deletions
26
src/main/kotlin/com/fardragi/nyaruko/database/DatabaseConnection.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,26 @@ | ||
package com.fardragi.nyaruko.database | ||
|
||
import com.fardragi.nyaruko.config.DatabaseConfig | ||
import com.fardragi.nyaruko.database.tables.UsersTable | ||
import kotlinx.coroutines.CoroutineScope | ||
import kotlinx.coroutines.Dispatchers | ||
import kotlinx.coroutines.launch | ||
import org.jetbrains.exposed.sql.Database | ||
import org.jetbrains.exposed.sql.SchemaUtils | ||
|
||
class DatabaseConnection(config: DatabaseConfig) { | ||
init { | ||
Database.connect( | ||
url = "jdbc:mariadb://${config.host}:${config.port}/${config.name}", | ||
driver = "org.mariadb.jdbc.Driver", | ||
user = config.user, | ||
password = config.password | ||
) | ||
|
||
CoroutineScope(Dispatchers.IO).launch { | ||
query { | ||
SchemaUtils.createMissingTablesAndColumns(UsersTable) | ||
} | ||
} | ||
} | ||
} |
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
...dragi/dragiutils/database/tables/Users.kt → ...fardragi/nyaruko/database/tables/Users.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
2 changes: 1 addition & 1 deletion
2
...dragi/dragiutils/enums/PermissionLevel.kt → ...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
2 changes: 1 addition & 1 deletion
2
...ragiutils/exceptions/NotFoundException.kt → ...i/nyaruko/exceptions/NotFoundException.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,4 +1,4 @@ | ||
package com.fardragi.dragiutils.exceptions | ||
package com.fardragi.nyaruko.exceptions | ||
|
||
class NotFoundException(message: String) : Exception(message) { | ||
} |
4 changes: 2 additions & 2 deletions
4
...in/com/fardragi/dragiutils/models/User.kt → ...otlin/com/fardragi/nyaruko/models/User.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
2 changes: 1 addition & 1 deletion
2
...dragi/dragiutils/permission/Permission.kt → ...fardragi/nyaruko/permission/Permission.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,4 +1,4 @@ | ||
package com.fardragi.dragiutils.permission | ||
package com.fardragi.nyaruko.permission | ||
|
||
import org.koin.dsl.module | ||
|
||
|
2 changes: 1 addition & 1 deletion
2
...dragiutils/permission/PermissionModule.kt → ...gi/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
6 changes: 3 additions & 3 deletions
6
...fardragi/dragiutils/server/ServerProxy.kt → ...om/fardragi/nyaruko/server/ServerProxy.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
Oops, something went wrong.