Class RemoteConfigEntries
An entry is one @ConfigEntry field whose declared type the frozen protocol can carry: a
String (string), an int/long/short/byte and their boxed
forms (integer), a float/double and their boxed forms (number), a
boolean (boolean), a List<String> (string_list) or an enum
(enum, whose constant names are the allowed options). Every other declared type - a map, an
object, a Bukkit value, a list of anything but strings - is not editable through the panel and is not
listed, so a panel change can only ever name a value the contract has a shape for.
Values come from the file's raw bytes through ConfigDocument, never from the module's
in-memory state: the panel reads what the operator's file holds, and the version it then sends back
is the hash of exactly those bytes. An entry whose value cannot be carried inside the contract's own
bounds (a text longer than 8192 characters, a list longer than 500 items, an integer outside the safe
integer range) is omitted rather than truncated, because a truncated value is one the panel would
write back.
Every frame the builder produces therefore stays inside the vendored
config.entries.result schema: bounds are applied while the entry is built, and an entry that
cannot satisfy them is dropped, never emitted in a shape the schema rejects.
- Since:
- 6.3.1
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescription(package private) static final classOne editable setting: its dotted key, label, type, comment line, value and constraints.(package private) static enumThe declared Java types the contract can carry. -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final int(package private) static final intconfig.entries.resultallows at most this many entries.private static final intprivate static final intprivate static final intprivate static final intprivate static final intprivate static final intprivate static final longThe largest whole number the wire can carry exactly (2^53 - 1).(package private) static final String(package private) static final String(package private) static final String(package private) static final String(package private) static final StringContract entry types, asconfig.entries.resultspells them.(package private) static final Stringprivate static final int -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate static Longbound(double value, boolean min) (package private) static Stringcheck(com.google.gson.JsonElement value, RemoteConfigEntries.Entry entry) Checks one panel change against its entry: the JSON value's shape for that entry type and, for a bounded number, the declared range.private static StringcheckEnum(com.google.gson.JsonElement value, RemoteConfigEntries.Entry entry) private static StringcheckInteger(com.google.gson.JsonElement value, RemoteConfigEntries.Entry entry) private static StringcheckList(com.google.gson.JsonElement value) private static StringcheckNumber(com.google.gson.JsonElement value, RemoteConfigEntries.Entry entry) private static Stringprivate static com.google.gson.JsonObjectconstraints(Field field, RemoteConfigEntries.Kind kind, List<String> options) (package private) static List<RemoteConfigEntries.Entry> describe(AbstractConfigEntity entity, ConfigDocument document) Builds the editable entries of one file as it is on disk.(package private) static RemoteConfigEntries.Entryfind(List<RemoteConfigEntries.Entry> entries, String key) Finds the entry a dotted key names.private static Long(package private) static StringThe dotted key of one@ConfigEntryfield: itspath()split at every dot, or the field name when no path is declared - the same rule the entity applies when it binds the field.(package private) static RemoteConfigEntries.KindMaps one field's declared type to the contract entry type.private static Stringprivate static com.google.gson.JsonElementprivate static Double(package private) static Objectplain(com.google.gson.JsonElement value, RemoteConfigEntries.Kind kind) Converts a checked JSON value to the plain value the configuration document stores.private static StringrangeMessage(com.google.gson.JsonObject constraints) private static booleanstringList(Field field) (package private) static booleanprivate static booleanusableNumberBound(double bound) The default@Rangebound is the whole double range, which means "no bound".private static com.google.gson.JsonElementvalueOf(Object plain, RemoteConfigEntries.Kind kind, List<String> options) Converts one plain value read from the file to the entry's wire value.private static booleanwithinRange(com.google.gson.JsonObject constraints, double number)
-
Field Details
-
TYPE_STRING
Contract entry types, asconfig.entries.resultspells them.- See Also:
-
TYPE_INTEGER
- See Also:
-
TYPE_NUMBER
- See Also:
-
TYPE_BOOLEAN
- See Also:
-
TYPE_STRING_LIST
- See Also:
-
TYPE_ENUM
- See Also:
-
SAFE_INTEGER
private static final long SAFE_INTEGERThe largest whole number the wire can carry exactly (2^53 - 1).- See Also:
-
KEY_MAX
private static final int KEY_MAX- See Also:
-
LABEL_MAX
private static final int LABEL_MAX- See Also:
-
COMMENT_MAX
private static final int COMMENT_MAX- See Also:
-
VALUE_TEXT_MAX
private static final int VALUE_TEXT_MAX- See Also:
-
LIST_MAX
private static final int LIST_MAX- See Also:
-
LIST_ITEM_MAX
private static final int LIST_ITEM_MAX- See Also:
-
OPTIONS_MAX
private static final int OPTIONS_MAX- See Also:
-
OPTIONS_ITEM_MAX
private static final int OPTIONS_ITEM_MAX- See Also:
-
ENTRIES_MAX
static final int ENTRIES_MAXconfig.entries.resultallows at most this many entries.- See Also:
-
-
Constructor Details
-
RemoteConfigEntries
private RemoteConfigEntries()
-
-
Method Details
-
kindOf
Maps one field's declared type to the contract entry type.- Parameters:
field- the@ConfigEntryfield- Returns:
- the kind, or null when the type is not editable through the panel
-
stringList
-
keyOf
The dotted key of one@ConfigEntryfield: itspath()split at every dot, or the field name when no path is declared - the same rule the entity applies when it binds the field.- Parameters:
field- the annotated field- Returns:
- the dotted key
-
usableKey
- Parameters:
key- a dotted key @return whether the contract's key pattern accepts it
-
describe
static List<RemoteConfigEntries.Entry> describe(AbstractConfigEntity entity, ConfigDocument document) Builds the editable entries of one file as it is on disk.- Parameters:
entity- the module's config entity that registered the filedocument- the document loaded from the file's current bytes- Returns:
- the entries the panel may show, in declaration order, bounded by the contract
-
label
-
commentOf
-
options
-
valueOf
private static com.google.gson.JsonElement valueOf(Object plain, RemoteConfigEntries.Kind kind, List<String> options) Converts one plain value read from the file to the entry's wire value.- Parameters:
plain- the plain value, or null when the file does not hold the keykind- the entry kindoptions- the enum constant names, empty for every other kind- Returns:
- the wire value, or null when the value cannot be carried inside the contract's bounds
-
integral
-
number
-
list
-
constraints
private static com.google.gson.JsonObject constraints(Field field, RemoteConfigEntries.Kind kind, List<String> options) -
usableNumberBound
private static boolean usableNumberBound(double bound) The default@Rangebound is the whole double range, which means "no bound". -
bound
-
check
Checks one panel change against its entry: the JSON value's shape for that entry type and, for a bounded number, the declared range. Constraints the entity declares for a whole field (a size, a pattern, the module's own converter) are checked by the entity itself, not here.- Parameters:
value- the JSON value the panel sententry- the entry the change names, or null when the key is not an editable entry- Returns:
- null when the value may be written, otherwise a short reason for the key's result row
-
checkInteger
private static String checkInteger(com.google.gson.JsonElement value, RemoteConfigEntries.Entry entry) -
checkNumber
private static String checkNumber(com.google.gson.JsonElement value, RemoteConfigEntries.Entry entry) -
withinRange
private static boolean withinRange(com.google.gson.JsonObject constraints, double number) -
rangeMessage
-
checkList
-
checkEnum
-
plain
Converts a checked JSON value to the plain value the configuration document stores.- Parameters:
value- the JSON valuekind- the entry kind- Returns:
- the plain value
-
find
Finds the entry a dotted key names.- Parameters:
entries- the described entrieskey- the change's dotted key- Returns:
- the entry, or null when that key is not an editable entry of this file
-