-
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.
add: message events add: command events
- Loading branch information
Showing
23 changed files
with
345 additions
and
66 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
54 changes: 54 additions & 0 deletions
54
src/main/kotlin/fyi/fyw/mc/pluginnonebot/events/broadcasters/BroadcasterPlayerChat.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,54 @@ | ||
package fyi.fyw.mc.pluginnonebot.events.broadcasters | ||
|
||
import fyi.fyw.mc.pluginnonebot.events.EventBroadcaster | ||
import fyi.fyw.mc.pluginnonebot.models.NEntityLocation | ||
import fyi.fyw.mc.pluginnonebot.models.NSimplePlayer | ||
import fyi.fyw.mc.pluginnonebot.models.event.BaseEventFrame | ||
import fyi.fyw.mc.pluginnonebot.models.event.EventPlayerChat | ||
import org.bukkit.event.EventHandler | ||
import org.bukkit.event.EventPriority | ||
import org.bukkit.event.player.AsyncPlayerChatEvent | ||
|
||
class BroadcasterPlayerChat : EventBroadcaster() { | ||
@EventHandler(priority = EventPriority.MONITOR) | ||
fun listen(event: AsyncPlayerChatEvent) { | ||
broadcast( | ||
BaseEventFrame( | ||
data = EventPlayerChat( | ||
NSimplePlayer( | ||
event.player.displayName, | ||
event.player.uniqueId.toString(), | ||
event.player.isOnline, | ||
NEntityLocation( | ||
event.player.location.world!!.name, | ||
event.player.location.x, | ||
event.player.location.y, | ||
event.player.location.z, | ||
event.player.location.yaw, | ||
event.player.location.pitch, | ||
), | ||
), | ||
event.recipients.map { | ||
NSimplePlayer( | ||
it.displayName, | ||
it.uniqueId.toString(), | ||
it.isOnline, | ||
NEntityLocation( | ||
it.location.world!!.name, | ||
it.location.x, | ||
it.location.y, | ||
it.location.z, | ||
it.location.yaw, | ||
it.location.pitch, | ||
), | ||
) | ||
}.toSet(), | ||
event.message, | ||
event.isCancelled, | ||
), | ||
type = "message", | ||
detailType = "player_chat", | ||
), | ||
) | ||
} | ||
} |
39 changes: 39 additions & 0 deletions
39
src/main/kotlin/fyi/fyw/mc/pluginnonebot/events/broadcasters/BroadcasterPlayerCommand.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,39 @@ | ||
package fyi.fyw.mc.pluginnonebot.events.broadcasters | ||
|
||
import fyi.fyw.mc.pluginnonebot.events.EventBroadcaster | ||
import fyi.fyw.mc.pluginnonebot.models.NEntityLocation | ||
import fyi.fyw.mc.pluginnonebot.models.NSimplePlayer | ||
import fyi.fyw.mc.pluginnonebot.models.event.BaseEventFrame | ||
import fyi.fyw.mc.pluginnonebot.models.event.EventPlayerCommand | ||
import org.bukkit.event.EventHandler | ||
import org.bukkit.event.EventPriority | ||
import org.bukkit.event.player.PlayerCommandPreprocessEvent | ||
|
||
class BroadcasterPlayerCommand : EventBroadcaster() { | ||
@EventHandler(priority = EventPriority.MONITOR) | ||
fun listen(event: PlayerCommandPreprocessEvent) { | ||
broadcast( | ||
BaseEventFrame( | ||
data = EventPlayerCommand( | ||
NSimplePlayer( | ||
event.player.displayName, | ||
event.player.uniqueId.toString(), | ||
event.player.isOnline, | ||
NEntityLocation( | ||
event.player.location.world!!.name, | ||
event.player.location.x, | ||
event.player.location.y, | ||
event.player.location.z, | ||
event.player.location.yaw, | ||
event.player.location.pitch, | ||
), | ||
), | ||
event.message, | ||
event.isCancelled, | ||
), | ||
type = "command", | ||
detailType = "player_command", | ||
), | ||
) | ||
} | ||
} |
40 changes: 40 additions & 0 deletions
40
src/main/kotlin/fyi/fyw/mc/pluginnonebot/events/broadcasters/BroadcasterPlayerJoin.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,40 @@ | ||
package fyi.fyw.mc.pluginnonebot.events.broadcasters | ||
|
||
import fyi.fyw.mc.pluginnonebot.events.EventBroadcaster | ||
import fyi.fyw.mc.pluginnonebot.models.NEntityLocation | ||
import fyi.fyw.mc.pluginnonebot.models.NSimplePlayer | ||
import fyi.fyw.mc.pluginnonebot.models.event.BaseEventFrame | ||
import fyi.fyw.mc.pluginnonebot.models.event.EventPlayerJoin | ||
import org.bukkit.event.EventHandler | ||
import org.bukkit.event.EventPriority | ||
import org.bukkit.event.player.PlayerJoinEvent | ||
|
||
class BroadcasterPlayerJoin : EventBroadcaster() { | ||
|
||
@EventHandler(priority = EventPriority.MONITOR) | ||
fun listen(event: PlayerJoinEvent) { | ||
broadcast( | ||
BaseEventFrame( | ||
data = EventPlayerJoin( | ||
NSimplePlayer( | ||
event.player.displayName, | ||
event.player.uniqueId.toString(), | ||
event.player.isOnline, | ||
NEntityLocation( | ||
event.player.location.world!!.name, | ||
event.player.location.x, | ||
event.player.location.y, | ||
event.player.location.z, | ||
event.player.location.yaw, | ||
event.player.location.pitch, | ||
), | ||
), | ||
event.joinMessage ?: "", | ||
), | ||
type = "player", | ||
detailType = "player_join", | ||
), | ||
|
||
) | ||
} | ||
} |
33 changes: 0 additions & 33 deletions
33
src/main/kotlin/fyi/fyw/mc/pluginnonebot/events/broadcasters/BroadcasterPlayerLogin.kt
This file was deleted.
Oops, something went wrong.
39 changes: 39 additions & 0 deletions
39
src/main/kotlin/fyi/fyw/mc/pluginnonebot/events/broadcasters/BroadcasterPlayerQuit.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,39 @@ | ||
package fyi.fyw.mc.pluginnonebot.events.broadcasters | ||
|
||
import fyi.fyw.mc.pluginnonebot.events.EventBroadcaster | ||
import fyi.fyw.mc.pluginnonebot.models.NEntityLocation | ||
import fyi.fyw.mc.pluginnonebot.models.NSimplePlayer | ||
import fyi.fyw.mc.pluginnonebot.models.event.BaseEventFrame | ||
import fyi.fyw.mc.pluginnonebot.models.event.EventPlayerQuit | ||
import org.bukkit.event.EventHandler | ||
import org.bukkit.event.EventPriority | ||
import org.bukkit.event.player.PlayerQuitEvent | ||
|
||
class BroadcasterPlayerQuit : EventBroadcaster() { | ||
@EventHandler(priority = EventPriority.MONITOR) | ||
fun listen(event: PlayerQuitEvent) { | ||
broadcast( | ||
BaseEventFrame( | ||
data = EventPlayerQuit( | ||
NSimplePlayer( | ||
event.player.displayName, | ||
event.player.uniqueId.toString(), | ||
event.player.isOnline, | ||
NEntityLocation( | ||
event.player.location.world!!.name, | ||
event.player.location.x, | ||
event.player.location.y, | ||
event.player.location.z, | ||
event.player.location.yaw, | ||
event.player.location.pitch, | ||
), | ||
), | ||
event.quitMessage ?: "", | ||
), | ||
type = "player", | ||
detailType = "player_quit", | ||
), | ||
|
||
) | ||
} | ||
} |
42 changes: 42 additions & 0 deletions
42
src/main/kotlin/fyi/fyw/mc/pluginnonebot/events/broadcasters/BroadcasterServerChat.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,42 @@ | ||
package fyi.fyw.mc.pluginnonebot.events.broadcasters | ||
|
||
import fyi.fyw.mc.pluginnonebot.events.EventBroadcaster | ||
import fyi.fyw.mc.pluginnonebot.models.NEntityLocation | ||
import fyi.fyw.mc.pluginnonebot.models.NSimplePlayer | ||
import fyi.fyw.mc.pluginnonebot.models.event.BaseEventFrame | ||
import fyi.fyw.mc.pluginnonebot.models.event.EventServerChat | ||
import org.bukkit.entity.Player | ||
import org.bukkit.event.EventHandler | ||
import org.bukkit.event.EventPriority | ||
import org.bukkit.event.server.BroadcastMessageEvent | ||
|
||
class BroadcasterServerChat : EventBroadcaster() { | ||
@EventHandler(priority = EventPriority.MONITOR) | ||
fun listen(event: BroadcastMessageEvent) { | ||
broadcast( | ||
BaseEventFrame( | ||
data = EventServerChat( | ||
event.recipients.filterIsInstance<Player>().map { | ||
NSimplePlayer( | ||
it.displayName, | ||
it.uniqueId.toString(), | ||
it.isOnline, | ||
NEntityLocation( | ||
it.location.world!!.name, | ||
it.location.x, | ||
it.location.y, | ||
it.location.z, | ||
it.location.yaw, | ||
it.location.pitch, | ||
), | ||
) | ||
}.toSet(), | ||
message = event.message, | ||
event.isCancelled, | ||
), | ||
type = "message", | ||
detailType = "server_broadcast", | ||
), | ||
) | ||
} | ||
} |
28 changes: 28 additions & 0 deletions
28
src/main/kotlin/fyi/fyw/mc/pluginnonebot/events/broadcasters/BroadcasterServerCommand.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,28 @@ | ||
package fyi.fyw.mc.pluginnonebot.events.broadcasters | ||
|
||
import fyi.fyw.mc.pluginnonebot.events.EventBroadcaster | ||
import fyi.fyw.mc.pluginnonebot.models.NSimpleCommandSender | ||
import fyi.fyw.mc.pluginnonebot.models.event.BaseEventFrame | ||
import fyi.fyw.mc.pluginnonebot.models.event.EventServerCommand | ||
import org.bukkit.event.EventHandler | ||
import org.bukkit.event.EventPriority | ||
import org.bukkit.event.server.ServerCommandEvent | ||
|
||
class BroadcasterServerCommand : EventBroadcaster() { | ||
@EventHandler(priority = EventPriority.MONITOR) | ||
fun listen(event: ServerCommandEvent) { | ||
broadcast( | ||
BaseEventFrame( | ||
data = EventServerCommand( | ||
NSimpleCommandSender( | ||
event.sender.name, | ||
), | ||
event.command, | ||
event.isCancelled, | ||
), | ||
type = "command", | ||
detailType = "server_command", | ||
), | ||
) | ||
} | ||
} |
10 changes: 0 additions & 10 deletions
10
src/main/kotlin/fyi/fyw/mc/pluginnonebot/models/NEventBase.kt
This file was deleted.
Oops, something went wrong.
9 changes: 0 additions & 9 deletions
9
src/main/kotlin/fyi/fyw/mc/pluginnonebot/models/NEventFrame.kt
This file was deleted.
Oops, something went wrong.
6 changes: 0 additions & 6 deletions
6
src/main/kotlin/fyi/fyw/mc/pluginnonebot/models/NEventPlayerLogin.kt
This file was deleted.
Oops, something went wrong.
3 changes: 3 additions & 0 deletions
3
src/main/kotlin/fyi/fyw/mc/pluginnonebot/models/NSimpleCommandSender.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,3 @@ | ||
package fyi.fyw.mc.pluginnonebot.models | ||
|
||
class NSimpleCommandSender(val name: String) |
3 changes: 3 additions & 0 deletions
3
src/main/kotlin/fyi/fyw/mc/pluginnonebot/models/event/BaseEvent.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,3 @@ | ||
package fyi.fyw.mc.pluginnonebot.models.event | ||
|
||
interface BaseEvent |
14 changes: 14 additions & 0 deletions
14
src/main/kotlin/fyi/fyw/mc/pluginnonebot/models/event/BaseEventFrame.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 fyi.fyw.mc.pluginnonebot.models.event | ||
|
||
import com.google.gson.annotations.SerializedName | ||
import java.io.Serializable | ||
import java.util.* | ||
|
||
class BaseEventFrame( | ||
val id: String = UUID.randomUUID().toString(), // Version 4 UUID | ||
val time: Long = System.currentTimeMillis(), // Unix timestamp | ||
val data: BaseEvent? = null, | ||
val type: String, | ||
@SerializedName("detail_type") val detailType: String, | ||
@SerializedName("sub_type") val subType: String = "", | ||
) : Serializable |
Oops, something went wrong.