Package ch.njol.skript.registrations
Class Classes
java.lang.Object
ch.njol.skript.registrations.Classes
-
Method Summary
Modifier and TypeMethodDescriptionstatic Object
Clones the given object by callingClassInfo.clone(Object)
, getting theClassInfo
from the closest registered superclass (or the given object's class).static @Nullable Object
deserialize(ClassInfo<?> type, byte[] value)
static @Nullable Object
deserialize(ClassInfo<?> type, InputStream value)
static @Nullable Object
deserialize(String type, byte[] value)
static @Nullable Object
deserialize(String type, String value)
Deprecated.static Class<?>
Gets a class by its code namestatic @Nullable Class<?>
getClassFromUserInput(String name)
As the name impliesstatic ClassInfo<?>
getClassInfo(String codeName)
This method can be called even while Skript is loading.static @Nullable ClassInfo<?>
getClassInfoFromUserInput(String name)
As the name impliesstatic @Nullable ClassInfo<?>
getClassInfoNoError(@Nullable String codeName)
This method can be called even while Skript is loading.static String
getDebugMessage(@Nullable Object o)
static <T> @Nullable DefaultExpression<T>
getDefaultExpression(Class<T> c)
Gets the default expression of a classstatic @Nullable DefaultExpression<?>
getDefaultExpression(String codeName)
Gets the default of a classstatic <T> @Nullable ClassInfo<T>
getExactClassInfo(@Nullable Class<T> c)
Gets the class info for the given class.static @Nullable String
getExactClassName(Class<?> c)
Gets the name a class was registered with.static <T> @Nullable Parser<? extends T>
getExactParser(Class<T> c)
Gets a parser for an exactly known class.static <T> @Nullable Parser<? extends T>
Gets a parser for parsing instances of the desired type from strings.static <T> ClassInfo<? super T>
getSuperClassInfo(Class<T> c)
Gets the class info of the given class or its closest registered superclass.static void
static <T> @Nullable T
parse(String s, Class<T> c, ParseContext context)
Parses a string to get an object of the desired type.static <T> @Nullable T
parseSimple(String s, Class<T> c, ParseContext context)
Parses without trying to convert anything.static <T> void
registerClass(ClassInfo<T> info)
static @Nullable SerializedVariable.Value
Must be called on the appropriate thread for the given value (i.e.static String
static <T> String
toString(@Nullable T o, StringMode mode)
static String
static String
toString(Object[] os, boolean and, StringMode mode)
static String
static String
-
Method Details
-
registerClass
- Parameters:
info
- info about the class to register
-
onRegistrationsStop
public static void onRegistrationsStop() -
getClassInfos
-
getClassInfo
This method can be called even while Skript is loading.- Parameters:
codeName
-- Returns:
- The ClassInfo with the given code name
- Throws:
SkriptAPIException
- If the given class was not registered
-
getClassInfoNoError
This method can be called even while Skript is loading.- Parameters:
codeName
-- Returns:
- The class info registered with the given code name or null if the code name is invalid or not yet registered
-
getExactClassInfo
Gets the class info for the given class.This method can be called even while Skript is loading.
- Parameters:
c
- The exact class to get the class info for- Returns:
- The class info for the given class of null if no info was found.
-
getSuperClassInfo
Gets the class info of the given class or its closest registered superclass. This method will never return null unless c is null.- Parameters:
c
-- Returns:
- The closest superclass's info
-
getClass
Gets a class by its code name- Parameters:
codeName
-- Returns:
- the class with the given code name
- Throws:
SkriptAPIException
- If the given class was not registered
-
getClassInfoFromUserInput
As the name implies- Parameters:
name
-- Returns:
- the class info or null if the name was not recognised
-
getClassFromUserInput
As the name implies- Parameters:
name
-- Returns:
- the class or null if the name was not recognized
-
getDefaultExpression
Gets the default of a class- Parameters:
codeName
-- Returns:
- the expression holding the default value or null if this class doesn't have one
- Throws:
SkriptAPIException
- If the given class was not registered
-
getDefaultExpression
Gets the default expression of a class- Parameters:
c
- The class- Returns:
- The expression holding the default value or null if this class doesn't have one
-
clone
Clones the given object by callingClassInfo.clone(Object)
, getting theClassInfo
from the closest registered superclass (or the given object's class). Supports arrays too. -
getExactClassName
Gets the name a class was registered with.- Parameters:
c
- The exact class- Returns:
- The name of the class or null if the given class wasn't registered.
-
parseSimple
Parses without trying to convert anything.Can log an error xor other log messages.
- Parameters:
s
-c
-- Returns:
- The parsed object
-
parse
Parses a string to get an object of the desired type.Instead of repeatedly calling this with the same class argument, you should get a parser with
getParser(Class)
and use it for parsing.Can log an error if it returned null.
- Parameters:
s
- The string to parsec
- The desired type. The returned value will be of this type or a subclass if it.- Returns:
- The parsed object
-
getParser
Gets a parser for parsing instances of the desired type from strings. The returned parser may only be used for parsing, i.e. you must not use its toString methods.- Parameters:
to
-- Returns:
- A parser to parse object of the desired type
-
getExactParser
Gets a parser for an exactly known class. You should usually usegetParser(Class)
instead of this method.The main benefit of this method is that it's the only class info method of Skript that can be used while Skript is initializing and thus useful for parsing configs.
- Parameters:
c
-- Returns:
- A parser to parse object of the desired type
-
toString
- Parameters:
o
- Any object, preferably not an array: usetoString(Object[], boolean)
instead.- Returns:
- String representation of the object (using a parser if found or
String.valueOf(Object)
otherwise). - See Also:
toString(Object, StringMode)
,toString(Object[], boolean)
,toString(Object[], boolean, StringMode)
,Parser
-
getDebugMessage
-
toString
-
toString
-
toString
-
toString
-
toString
-
serialize
Must be called on the appropriate thread for the given value (i.e. the main thread currently) -
deserialize
-
deserialize
-
deserialize
-
deserialize
Deprecated.Deserialises an object.This method must only be called from Bukkits main thread!
- Parameters:
type
-value
-- Returns:
- Deserialised value or null if the input is invalid
-