From 66a27974bfcb0bc59a6ef7fd515521a125063d39 Mon Sep 17 00:00:00 2001 From: FalsePattern <30945458+FalsePattern@users.noreply.github.com> Date: Mon, 25 Jul 2022 00:32:10 +0200 Subject: [PATCH] begin server-client config sync impl --- .../com/falsepattern/lib/config/Config.java | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/src/main/java/com/falsepattern/lib/config/Config.java b/src/main/java/com/falsepattern/lib/config/Config.java index 5fa234a..55c2698 100644 --- a/src/main/java/com/falsepattern/lib/config/Config.java +++ b/src/main/java/com/falsepattern/lib/config/Config.java @@ -185,4 +185,31 @@ public @interface Config { @Target({ElementType.FIELD, ElementType.TYPE}) @interface RequiresWorldRestart { } + + /** + * Signals that this configuration entry/class should be synchronized between the client and the server when + * joining a multiplayer instance. + * + * Note that synchronization ALWAYS happens FROM the server TO the client. The server should NEVER attempt to get + * configuration values from a client. This is to avoid malicious clients manipulating the server configs. + */ + @StableAPI(since = "0.10.0") + @Documented + @Retention(RetentionPolicy.RUNTIME) + @Target({ElementType.FIELD, ElementType.TYPE}) + @interface Synchronize { + /** + * This is a limit on how many bytes the client will accept from the server. If this limit is exceeded, + * the client shall refuse to connect to the server. For String[]-s, the amount of bytes is the sum of all + * strings inside the array.

+ * + * This limitation option exists to avoid malicious servers flooding clients with data.

+ * + * By default, the client will accept any amount of bytes.

+ * + * This only applies for String and String[] configurations, and is ignored on the other config types. + * For enums, this value is computed automatically. + */ + int maxLength(); + } } \ No newline at end of file