StringData
Importing the class
If you need to reference this type directly, like when casting an Array, or as a parameter, you will need to import it. Simply add the import at the top of the file.
import crafttweaker.api.data.StringData;
Description
Implements
StringData
implements the following interfaces:
Constructors
// new StringData(internal as string);new StringData(myString);
Parameters:
internal: string
Type: string
Operators
Members
Returns: this data as a byte array
// StringData.asByteArray() as byte[];("Hello" as IData).asByteArray();
Return Type:
byte[]
// StringData as byte[]("Hello" as IData) as byte[]
Return Type:
byte[]
Returns: this data as an int array
// StringData.asIntArray() as int[];("Hello" as IData).asIntArray();
Return Type:
int[]
// StringData as int[]("Hello" as IData) as int[]
Return Type:
int[]
Returns: this data as a long array
// StringData.asLongArray() as long[];("Hello" as IData).asLongArray();
Return Type:
long[]
// StringData as long[]("Hello" as IData) as long[]
Return Type:
long[]
E.G println(("hello" as IData).asString())
prints "hello"
Returns: The escaped string version of this IData.
// StringData.asString() as string;("Hello" as IData).asString();
Return Type:
string
E.G println(("hello" as IData).getAsString())
prints hello
Returns: The literal string version of this IData.
// StringData.getAsString() as string;("Hello" as IData).getAsString();
Return Type:
string
E.G println(("hello" as IData).getAsString())
prints hello
// StringData as string("Hello" as IData) as string
Return Type:
string
Returns: the intenral ID of this data.
// StringData.getId() as byte;("Hello" as IData).getId();
Return Type:
byte
// StringData.isEmpty as bool("Hello" as IData).isEmpty
Return Type:
bool
Returns: True if empty.
// StringData.isEmpty() as bool;("Hello" as IData).isEmpty();
Return Type:
bool
// StringData.keys as Set<string>("Hello" as IData).keys
Return Type:
Set<string>
Returns: The keys of this IData.
// StringData.keys() as Set<string>;("Hello" as IData).keys();
Return Type:
Set<string>
This attempts to give the most accurate type for the given members, for example, if all the members are bytes, then it returns a ByteArrayData.
However if the types are mixed or do not have a *ArrayData version, then a ListData is returned.
Returns: A list of the given members.
Return Type:
IData
Returns: A new IData from the operation
("Hello" as IData).map((data) => 3);
Parameters:
Return Type:
IData
// StringData.remove(index as int);("Hello" as IData).remove(0);
Parameters:
index: int
Type: int
- The index to remove. // StringData.remove(key as string);("Hello" as IData).remove("key");
Parameters:
key: string
Type: string
- The key to remove.