diff --git a/src/main/java/net/minestom/server/permission/Permission.java b/src/main/java/net/minestom/server/permission/Permission.java index 1bd40a25e..8f7e31d12 100644 --- a/src/main/java/net/minestom/server/permission/Permission.java +++ b/src/main/java/net/minestom/server/permission/Permission.java @@ -1,10 +1,14 @@ package net.minestom.server.permission; import net.minestom.server.command.CommandSender; +import net.minestom.server.data.Data; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; /** * Representation of a permission granted to a CommandSender */ +@FunctionalInterface public interface Permission { /** @@ -14,5 +18,18 @@ public interface Permission { */ boolean isValidFor(CommandSender commandSender); - // TODO: Serialization? + /** + * Writes any required data for this permission inside the given destination + * @param destination Data to write to + */ + default void write(@NotNull Data destination) {} + + /** + * Reads any required data for this permission from the given destination + * @param source Data to read from + * @return this for chaining + */ + default Permission read(@Nullable Data source) { + return this; + } } diff --git a/src/test/java/permissions/TestPermissions.java b/src/test/java/permissions/TestPermissions.java index e7c448414..e2b87e416 100644 --- a/src/test/java/permissions/TestPermissions.java +++ b/src/test/java/permissions/TestPermissions.java @@ -2,8 +2,11 @@ package permissions; import net.minestom.server.MinecraftServer; import net.minestom.server.command.CommandSender; +import net.minestom.server.data.Data; import net.minestom.server.entity.Player; import net.minestom.server.permission.Permission; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test;