From 350bd38c80b9b5bda8c11b4fbdf7dd6b1adbbbcd Mon Sep 17 00:00:00 2001 From: Vankka Date: Sun, 28 Jul 2024 02:19:55 +0300 Subject: [PATCH] Player Events --- api/src/main/java/com/discordsrv/api/events/PlayerEvent.java | 2 ++ .../message/receive/game/AwardMessageReceiveEvent.java | 5 ++++- .../message/receive/game/DeathMessageReceiveEvent.java | 4 +++- .../message/receive/game/GameChatMessageReceiveEvent.java | 2 +- .../events/message/receive/game/JoinMessageReceiveEvent.java | 4 +++- .../message/receive/game/LeaveMessageReceiveEvent.java | 4 +++- .../receive/game/ServerSwitchMessageReceiveEvent.java | 4 +++- 7 files changed, 19 insertions(+), 6 deletions(-) diff --git a/api/src/main/java/com/discordsrv/api/events/PlayerEvent.java b/api/src/main/java/com/discordsrv/api/events/PlayerEvent.java index 37561e9f..fb3c50a3 100644 --- a/api/src/main/java/com/discordsrv/api/events/PlayerEvent.java +++ b/api/src/main/java/com/discordsrv/api/events/PlayerEvent.java @@ -24,6 +24,7 @@ package com.discordsrv.api.events; import com.discordsrv.api.player.DiscordSRVPlayer; +import org.jetbrains.annotations.NotNull; /** * An event that is related to a {@link DiscordSRVPlayer}. @@ -34,5 +35,6 @@ public interface PlayerEvent extends Event { * The player that this event is related to. * @return the player */ + @NotNull DiscordSRVPlayer getPlayer(); } diff --git a/api/src/main/java/com/discordsrv/api/events/message/receive/game/AwardMessageReceiveEvent.java b/api/src/main/java/com/discordsrv/api/events/message/receive/game/AwardMessageReceiveEvent.java index c858531d..56c8947b 100644 --- a/api/src/main/java/com/discordsrv/api/events/message/receive/game/AwardMessageReceiveEvent.java +++ b/api/src/main/java/com/discordsrv/api/events/message/receive/game/AwardMessageReceiveEvent.java @@ -26,6 +26,7 @@ package com.discordsrv.api.events.message.receive.game; import com.discordsrv.api.channel.GameChannel; import com.discordsrv.api.component.MinecraftComponent; import com.discordsrv.api.eventbus.EventPriority; +import com.discordsrv.api.events.PlayerEvent; import com.discordsrv.api.player.DiscordSRVPlayer; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -34,7 +35,7 @@ import org.jetbrains.annotations.Nullable; * Indicates that an advancement or achievement message was received will be processed * at {@link EventPriority#DEFAULT} unless cancelled or processed by a 3rd party. */ -public class AwardMessageReceiveEvent extends AbstractGameMessageReceiveEvent { +public class AwardMessageReceiveEvent extends AbstractGameMessageReceiveEvent implements PlayerEvent { private final DiscordSRVPlayer player; private MinecraftComponent name; @@ -56,6 +57,8 @@ public class AwardMessageReceiveEvent extends AbstractGameMessageReceiveEvent { this.gameChannel = gameChannel; } + @Override + @NotNull public DiscordSRVPlayer getPlayer() { return player; } diff --git a/api/src/main/java/com/discordsrv/api/events/message/receive/game/DeathMessageReceiveEvent.java b/api/src/main/java/com/discordsrv/api/events/message/receive/game/DeathMessageReceiveEvent.java index a774cd58..4cb9acfb 100644 --- a/api/src/main/java/com/discordsrv/api/events/message/receive/game/DeathMessageReceiveEvent.java +++ b/api/src/main/java/com/discordsrv/api/events/message/receive/game/DeathMessageReceiveEvent.java @@ -26,6 +26,7 @@ package com.discordsrv.api.events.message.receive.game; import com.discordsrv.api.channel.GameChannel; import com.discordsrv.api.component.MinecraftComponent; import com.discordsrv.api.eventbus.EventPriority; +import com.discordsrv.api.events.PlayerEvent; import com.discordsrv.api.player.DiscordSRVPlayer; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -34,7 +35,7 @@ import org.jetbrains.annotations.Nullable; * Indicates that a death message was received and will be processed * at {@link EventPriority#DEFAULT} unless cancelled or processed by a 3rd party. */ -public class DeathMessageReceiveEvent extends AbstractGameMessageReceiveEvent { +public class DeathMessageReceiveEvent extends AbstractGameMessageReceiveEvent implements PlayerEvent { private final DiscordSRVPlayer player; private MinecraftComponent message; @@ -52,6 +53,7 @@ public class DeathMessageReceiveEvent extends AbstractGameMessageReceiveEvent { this.gameChannel = gameChannel; } + @Override @NotNull public DiscordSRVPlayer getPlayer() { return player; diff --git a/api/src/main/java/com/discordsrv/api/events/message/receive/game/GameChatMessageReceiveEvent.java b/api/src/main/java/com/discordsrv/api/events/message/receive/game/GameChatMessageReceiveEvent.java index f5266848..fbc0fdce 100644 --- a/api/src/main/java/com/discordsrv/api/events/message/receive/game/GameChatMessageReceiveEvent.java +++ b/api/src/main/java/com/discordsrv/api/events/message/receive/game/GameChatMessageReceiveEvent.java @@ -72,7 +72,7 @@ public class GameChatMessageReceiveEvent extends AbstractGameMessageReceiveEvent } @Override - public DiscordSRVPlayer getPlayer() { + public @NotNull DiscordSRVPlayer getPlayer() { return player; } } diff --git a/api/src/main/java/com/discordsrv/api/events/message/receive/game/JoinMessageReceiveEvent.java b/api/src/main/java/com/discordsrv/api/events/message/receive/game/JoinMessageReceiveEvent.java index 9b9c429d..7cbfd825 100644 --- a/api/src/main/java/com/discordsrv/api/events/message/receive/game/JoinMessageReceiveEvent.java +++ b/api/src/main/java/com/discordsrv/api/events/message/receive/game/JoinMessageReceiveEvent.java @@ -26,6 +26,7 @@ package com.discordsrv.api.events.message.receive.game; import com.discordsrv.api.channel.GameChannel; import com.discordsrv.api.component.MinecraftComponent; import com.discordsrv.api.eventbus.EventPriority; +import com.discordsrv.api.events.PlayerEvent; import com.discordsrv.api.player.DiscordSRVPlayer; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -34,7 +35,7 @@ import org.jetbrains.annotations.Nullable; * Indicates that a join message was received and will be processed * at {@link EventPriority#DEFAULT} unless cancelled or processed by a 3rd party. */ -public class JoinMessageReceiveEvent extends AbstractGameMessageReceiveEvent { +public class JoinMessageReceiveEvent extends AbstractGameMessageReceiveEvent implements PlayerEvent { private final DiscordSRVPlayer player; private MinecraftComponent message; @@ -55,6 +56,7 @@ public class JoinMessageReceiveEvent extends AbstractGameMessageReceiveEvent { this.firstJoin = firstJoin; } + @Override @NotNull public DiscordSRVPlayer getPlayer() { return player; diff --git a/api/src/main/java/com/discordsrv/api/events/message/receive/game/LeaveMessageReceiveEvent.java b/api/src/main/java/com/discordsrv/api/events/message/receive/game/LeaveMessageReceiveEvent.java index 99f8e3df..e82b151d 100644 --- a/api/src/main/java/com/discordsrv/api/events/message/receive/game/LeaveMessageReceiveEvent.java +++ b/api/src/main/java/com/discordsrv/api/events/message/receive/game/LeaveMessageReceiveEvent.java @@ -26,6 +26,7 @@ package com.discordsrv.api.events.message.receive.game; import com.discordsrv.api.channel.GameChannel; import com.discordsrv.api.component.MinecraftComponent; import com.discordsrv.api.eventbus.EventPriority; +import com.discordsrv.api.events.PlayerEvent; import com.discordsrv.api.player.DiscordSRVPlayer; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -34,7 +35,7 @@ import org.jetbrains.annotations.Nullable; * Indicates that a leave message was received and will be processed * at {@link EventPriority#DEFAULT} unless cancelled or processed by a 3rd party. */ -public class LeaveMessageReceiveEvent extends AbstractGameMessageReceiveEvent { +public class LeaveMessageReceiveEvent extends AbstractGameMessageReceiveEvent implements PlayerEvent { private final DiscordSRVPlayer player; private MinecraftComponent message; @@ -52,6 +53,7 @@ public class LeaveMessageReceiveEvent extends AbstractGameMessageReceiveEvent { this.gameChannel = gameChannel; } + @Override @NotNull public DiscordSRVPlayer getPlayer() { return player; diff --git a/api/src/main/java/com/discordsrv/api/events/message/receive/game/ServerSwitchMessageReceiveEvent.java b/api/src/main/java/com/discordsrv/api/events/message/receive/game/ServerSwitchMessageReceiveEvent.java index 31346d10..1208fc9f 100644 --- a/api/src/main/java/com/discordsrv/api/events/message/receive/game/ServerSwitchMessageReceiveEvent.java +++ b/api/src/main/java/com/discordsrv/api/events/message/receive/game/ServerSwitchMessageReceiveEvent.java @@ -25,6 +25,7 @@ package com.discordsrv.api.events.message.receive.game; import com.discordsrv.api.component.MinecraftComponent; import com.discordsrv.api.eventbus.EventPriority; +import com.discordsrv.api.events.PlayerEvent; import com.discordsrv.api.player.DiscordSRVPlayer; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -33,7 +34,7 @@ import org.jetbrains.annotations.Nullable; * Indicates that a server switch message was received and will be processed * at {@link EventPriority#DEFAULT} unless cancelled or processed by a 3rd party. */ -public class ServerSwitchMessageReceiveEvent extends AbstractGameMessageReceiveEvent { +public class ServerSwitchMessageReceiveEvent extends AbstractGameMessageReceiveEvent implements PlayerEvent { private final DiscordSRVPlayer player; private MinecraftComponent message; @@ -49,6 +50,7 @@ public class ServerSwitchMessageReceiveEvent extends AbstractGameMessageReceiveE this.message = message; } + @Override @NotNull public DiscordSRVPlayer getPlayer() { return player;