Serialization methods

This commit is contained in:
jglrxavpok 2020-08-10 21:42:54 +02:00
parent 5a8f58d9dd
commit d2df5fdc60
2 changed files with 21 additions and 1 deletions

View File

@ -1,10 +1,14 @@
package net.minestom.server.permission; package net.minestom.server.permission;
import net.minestom.server.command.CommandSender; 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 * Representation of a permission granted to a CommandSender
*/ */
@FunctionalInterface
public interface Permission { public interface Permission {
/** /**
@ -14,5 +18,18 @@ public interface Permission {
*/ */
boolean isValidFor(CommandSender commandSender); 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;
}
} }

View File

@ -2,8 +2,11 @@ package permissions;
import net.minestom.server.MinecraftServer; import net.minestom.server.MinecraftServer;
import net.minestom.server.command.CommandSender; import net.minestom.server.command.CommandSender;
import net.minestom.server.data.Data;
import net.minestom.server.entity.Player; import net.minestom.server.entity.Player;
import net.minestom.server.permission.Permission; 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.AfterEach;
import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;