diff options
| author | Petr Ilin <hevav@hevav.dev> | 2022-03-25 18:12:16 +0300 |
|---|---|---|
| committer | Petr Ilin <hevav@hevav.dev> | 2022-03-25 18:32:05 +0300 |
| commit | a992cfc04be8f330f669923360199b7b57a49e35 (patch) | |
| tree | 19ce4f06ea28f1be49efb05bee8698b26e709471 /src/main/java/net/elytrium/limboauth/event | |
| parent | ef636472638b0aec8b7f56fbd3a22943aaa2a47a (diff) | |
| download | LimboAuth-a992cfc04be8f330f669923360199b7b57a49e35.tar.gz LimboAuth-a992cfc04be8f330f669923360199b7b57a49e35.tar.bz2 LimboAuth-a992cfc04be8f330f669923360199b7b57a49e35.zip | |
Events implementation
Diffstat (limited to 'src/main/java/net/elytrium/limboauth/event')
7 files changed, 242 insertions, 0 deletions
diff --git a/src/main/java/net/elytrium/limboauth/event/PostAuthorizationEvent.java b/src/main/java/net/elytrium/limboauth/event/PostAuthorizationEvent.java new file mode 100644 index 0000000..cd13c73 --- /dev/null +++ b/src/main/java/net/elytrium/limboauth/event/PostAuthorizationEvent.java @@ -0,0 +1,27 @@ +/* + * Copyright (C) 2021 Elytrium + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +package net.elytrium.limboauth.event; + +import net.elytrium.limboapi.api.player.LimboPlayer; +import net.elytrium.limboauth.model.RegisteredPlayer; + +public class PostAuthorizationEvent extends PostEvent { + public PostAuthorizationEvent(LimboPlayer player, RegisteredPlayer playerInfo) { + super(player, playerInfo); + } +} diff --git a/src/main/java/net/elytrium/limboauth/event/PostEvent.java b/src/main/java/net/elytrium/limboauth/event/PostEvent.java new file mode 100644 index 0000000..e86fbcf --- /dev/null +++ b/src/main/java/net/elytrium/limboauth/event/PostEvent.java @@ -0,0 +1,42 @@ +/* + * Copyright (C) 2021 Elytrium + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +package net.elytrium.limboauth.event; + +import net.elytrium.limboapi.api.player.LimboPlayer; +import net.elytrium.limboauth.model.RegisteredPlayer; + +public abstract class PostEvent extends TaskEvent { + + private final LimboPlayer player; + private final RegisteredPlayer playerInfo; + + protected PostEvent(LimboPlayer player, RegisteredPlayer playerInfo) { + super(); + + this.player = player; + this.playerInfo = playerInfo; + } + + public RegisteredPlayer getPlayerInfo() { + return this.playerInfo; + } + + public LimboPlayer getPlayer() { + return this.player; + } +} diff --git a/src/main/java/net/elytrium/limboauth/event/PostRegisterEvent.java b/src/main/java/net/elytrium/limboauth/event/PostRegisterEvent.java new file mode 100644 index 0000000..df2fd2a --- /dev/null +++ b/src/main/java/net/elytrium/limboauth/event/PostRegisterEvent.java @@ -0,0 +1,27 @@ +/* + * Copyright (C) 2021 Elytrium + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +package net.elytrium.limboauth.event; + +import net.elytrium.limboapi.api.player.LimboPlayer; +import net.elytrium.limboauth.model.RegisteredPlayer; + +public class PostRegisterEvent extends PostEvent { + public PostRegisterEvent(LimboPlayer player, RegisteredPlayer playerInfo) { + super(player, playerInfo); + } +} diff --git a/src/main/java/net/elytrium/limboauth/event/PreAuthorizationEvent.java b/src/main/java/net/elytrium/limboauth/event/PreAuthorizationEvent.java new file mode 100644 index 0000000..d8e4dc7 --- /dev/null +++ b/src/main/java/net/elytrium/limboauth/event/PreAuthorizationEvent.java @@ -0,0 +1,34 @@ +/* + * Copyright (C) 2021 Elytrium + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +package net.elytrium.limboauth.event; + +import com.velocitypowered.api.proxy.Player; +import net.elytrium.limboauth.model.RegisteredPlayer; + +public class PreAuthorizationEvent extends PreEvent { + private final RegisteredPlayer playerInfo; + + public PreAuthorizationEvent(Player player, RegisteredPlayer playerInfo) { + super(player); + this.playerInfo = playerInfo; + } + + public RegisteredPlayer getPlayerInfo() { + return this.playerInfo; + } +} diff --git a/src/main/java/net/elytrium/limboauth/event/PreEvent.java b/src/main/java/net/elytrium/limboauth/event/PreEvent.java new file mode 100644 index 0000000..08f9b6b --- /dev/null +++ b/src/main/java/net/elytrium/limboauth/event/PreEvent.java @@ -0,0 +1,33 @@ +/* + * Copyright (C) 2021 Elytrium + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +package net.elytrium.limboauth.event; + +import com.velocitypowered.api.proxy.Player; + +public abstract class PreEvent extends TaskEvent { + private final Player player; + + protected PreEvent(Player player) { + super(); + this.player = player; + } + + public Player getPlayer() { + return this.player; + } +} diff --git a/src/main/java/net/elytrium/limboauth/event/PreRegisterEvent.java b/src/main/java/net/elytrium/limboauth/event/PreRegisterEvent.java new file mode 100644 index 0000000..8f642d3 --- /dev/null +++ b/src/main/java/net/elytrium/limboauth/event/PreRegisterEvent.java @@ -0,0 +1,26 @@ +/* + * Copyright (C) 2021 Elytrium + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +package net.elytrium.limboauth.event; + +import com.velocitypowered.api.proxy.Player; + +public class PreRegisterEvent extends PreEvent { + public PreRegisterEvent(Player player) { + super(player); + } +} diff --git a/src/main/java/net/elytrium/limboauth/event/TaskEvent.java b/src/main/java/net/elytrium/limboauth/event/TaskEvent.java new file mode 100644 index 0000000..4df70c8 --- /dev/null +++ b/src/main/java/net/elytrium/limboauth/event/TaskEvent.java @@ -0,0 +1,53 @@ +/* + * Copyright (C) 2021 Elytrium + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +package net.elytrium.limboauth.event; + +import net.elytrium.limboauth.Settings; +import net.kyori.adventure.text.Component; +import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer; +import org.jetbrains.annotations.NotNull; + +public abstract class TaskEvent { + private static final Component defaultReason + = LegacyComponentSerializer.legacyAmpersand().deserialize(Settings.IMP.MAIN.STRINGS.EVENT_CANCELLED); + private Result result = Result.NORMAL; + private Component reason = defaultReason; + + public Result getResult() { + return this.result; + } + + public void setResult(@NotNull Result result) { + this.result = result; + } + + public void cancel(@NotNull Component reason) { + this.result = Result.CANCEL; + this.reason = reason; + } + + public Component getReason() { + return this.reason; + } + + public enum Result { + CANCEL, + BYPASS, + NORMAL + } +} |
