-
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
3269f93
commit 26a3cd8
Showing
9 changed files
with
67 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
20 changes: 18 additions & 2 deletions
20
src/main/kotlin/com/fardragi/nyaruko/auth/handlers/CheckHandler.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,18 +1,34 @@ | ||
package com.fardragi.nyaruko.auth.handlers | ||
|
||
import com.fardragi.nyaruko.auth.messages.LoginMessage | ||
import com.fardragi.nyaruko.core.events.PlayerMoveEvent | ||
import com.fardragi.nyaruko.extensions.isTruePlayer | ||
import com.fardragi.nyaruko.extensions.sendMessages | ||
import com.fardragi.nyaruko.services.SessionsService | ||
import com.fardragi.nyaruko.shared.handlers.NyarukoHandlerBase | ||
import cpw.mods.fml.common.eventhandler.EventPriority | ||
import cpw.mods.fml.common.eventhandler.SubscribeEvent | ||
import net.minecraftforge.event.entity.item.ItemTossEvent | ||
|
||
class CheckHandler(private val sessionsService: SessionsService) : NyarukoHandlerBase() { | ||
@SubscribeEvent(priority = EventPriority.HIGHEST) | ||
fun onPlayerMove(event: PlayerMoveEvent) { | ||
if (sessionsService.isLoggedIn(event.player.uniqueID)) { | ||
if (sessionsService.isAuthenticated(event.player.uniqueID) || !event.player.isTruePlayer()) | ||
return | ||
} | ||
|
||
event.player.sendMessages(LoginMessage.loginBeforeGaming()) | ||
event.isCanceled = true | ||
} | ||
|
||
@SubscribeEvent(priority = EventPriority.HIGHEST) | ||
fun onDropItem(event: ItemTossEvent) { | ||
if (sessionsService.isAuthenticated(event.player.uniqueID) || !event.player.isTruePlayer()) | ||
return | ||
|
||
event.player.sendMessages(LoginMessage.loginBeforeGaming()) | ||
event.isCanceled = true | ||
|
||
val stack = event.entityItem.entityItem | ||
event.player.inventory.addItemStackToInventory(stack) | ||
} | ||
} |
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
4 changes: 3 additions & 1 deletion
4
src/main/kotlin/com/fardragi/nyaruko/viewmodels/PlayerInfoViewModel.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,3 +1,5 @@ | ||
package com.fardragi.nyaruko.viewmodels | ||
|
||
data class PlayerInfoViewModel(val name: String) | ||
data class PlayerInfoViewModel(val name: String, val initialPosition: PositionViewModel) { | ||
var authenticated: Boolean = false | ||
} |