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.

script.zs
import crafttweaker.api.data.StringData;

Description

Implements

StringData implements the following interfaces:

IData

Undocumented Interfaces

Comparable<IData>,Iterable<IData>

Constructors

new(internal as string)
script.zs
// new StringData(internal as string);
new StringData(myString);

Parameters:

internal Type: string

Operators

&(other as IData) as IData
Applies a bitwise AND (&) operation to this IData and the other IData
script.zs
// (StringData & (other as IData)) as IData
myStringData & myIData

Parameters:

other Type: IData - the other data.

Return Type: IData

/(other as IData) as IData
Divides the given IData from this IData.
script.zs
// (StringData / (other as IData)) as IData
myStringData / myIData

Parameters:

other Type: IData - the other data to divide by.

Return Type: IData

[](index as int) as IData
Gets the data at the given index.
script.zs
// StringData[index as int] as IData
myStringData[myInt]

Parameters:

index Type: int - The index to get

Return Type: IData

[](key as string) as IData
Gets the data at the given key.
script.zs
// StringData[key as string] as IData
myStringData[myString]

Parameters:

key Type: string - The key to get

Return Type: IData

%(other as IData) as IData
Applies a modulo operation to this IData against the other IData.
script.zs
// (StringData % (other as IData)) as IData
myStringData % myIData

Parameters:

other Type: IData - the other data to modulo by.

Return Type: IData

*(other as IData) as IData
Multiplies the given IData to this IData.
script.zs
// (StringData * (other as IData)) as IData
myStringData * myIData

Parameters:

other Type: IData - the other data to multiply by.

Return Type: IData

- as IData
Negates this IData.
script.zs
// (-StringData) as IData
-myStringData

Return Type: IData

! as IData
Applies a NOT (!) operation to this IData.
script.zs
// (!StringData) as IData
!myStringData

Return Type: IData

|(other as IData) as IData
Applies a bitwise OR (|) operation to this IData and the other IData
script.zs
// (StringData | (other as IData)) as IData
myStringData | myIData

Parameters:

other Type: IData - the other data.

Return Type: IData

[]=(index as string, value as IData)
Puts the given value inside this IData at the given index.
script.zs
// StringData[index as string] = (value as IData)
myStringData[myString] = myIData

Parameters:

index Type: string - The key to store the data at
value Type: IData - The data to store.
<<(other as IData) as IData
Applies a SHL (<<) operation to this data by the other data
script.zs
// (StringData << (other as IData)) as IData
myStringData << myIData

Parameters:

other Type: IData - The data to SHL by.

Return Type: IData

>>(other as IData) as IData
Applies a SHR (>>) operation to this data by the other data
script.zs
// (StringData >> (other as IData)) as IData
myStringData >> myIData

Parameters:

other Type: IData - The data to SHR by.

Return Type: IData

-(other as IData) as IData
Subtracts the given IData from this IData.
script.zs
// (StringData - (other as IData)) as IData
-myStringData

Parameters:

other Type: IData - the other data to remove.

Return Type: IData

^(other as IData) as IData
Applies a bitwise XOR (^) operation to this IData and the other IData
script.zs
// (StringData ^ (other as IData)) as IData
myStringData ^ myIData

Parameters:

other Type: IData - the other data.

Return Type: IData

Members

asByteArray() as byte[]
Casts this IData to a byte array.

Returns: this data as a byte array

script.zs
// StringData.asByteArray() as byte[];
myStringData.asByteArray();

Return Type: byte[]

as byte[]
Casts this IData to a byte array.
script.zs
// StringData as byte[]
myStringData as byte[]

Return Type: byte[]

asIntArray() as int[]
Casts this IData to an int array.

Returns: this data as an int array

script.zs
// StringData.asIntArray() as int[];
myStringData.asIntArray();

Return Type: int[]

as int[]
Casts this IData to an int array.
script.zs
// StringData as int[]
myStringData as int[]

Return Type: int[]

asList() as List<IData>
Casts this IData to a list.

Returns: this data as a list

script.zs
// StringData.asList() as List<IData>;
myStringData.asList();

Return Type: List<IData>

as List<IData>
Casts this IData to a list.
script.zs
// StringData as List<IData>
myStringData as List<IData>

Return Type: List<IData>

asLongArray() as long[]
Casts this IData to a long array.

Returns: this data as a long array

script.zs
// StringData.asLongArray() as long[];
myStringData.asLongArray();

Return Type: long[]

as long[]
Casts this IData to a long array.
script.zs
// StringData as long[]
myStringData as long[]

Return Type: long[]

asMap() as IData[string]
Casts this IData to a map.

Returns: this data as a map

script.zs
// StringData.asMap() as IData[string];
myStringData.asMap();

Return Type: IData[string]

as IData[string]
Casts this IData to a map.
script.zs
// StringData as IData[string]
myStringData as IData[string]

Return Type: IData[string]

asString() as string
Gets an escaped string version of this IData, quotes are included in the output

E.G println(("hello" as IData).asString()) prints "hello"

Returns: The escaped string version of this IData.

script.zs
// StringData.asString() as string;
myStringData.asString();

Return Type: string

getAsString() as string
Gets the literal string version of this IData.

E.G println(("hello" as IData).getAsString()) prints hello

Returns: The literal string version of this IData.

script.zs
// StringData.getAsString() as string;
myStringData.getAsString();

Return Type: string

as string
Gets the literal string version of this IData.

E.G println(("hello" as IData).getAsString()) prints hello

script.zs
// StringData as string
myStringData as string

Return Type: string

getId() as byte
Gets the internal ID of this data.

Returns: the intenral ID of this data.

script.zs
// StringData.getId() as byte;
myStringData.getId();

Return Type: byte

Getter
Checks if this data is empty.
script.zs
// StringData.isEmpty as bool
myStringData.isEmpty

Return Type: bool

isEmpty() as bool
Checks if this data is empty.

Returns: True if empty.

script.zs
// StringData.isEmpty() as bool;
myStringData.isEmpty();

Return Type: bool

Getter
Gets the keys of this IData
script.zs
// StringData.keys as Set<string>
myStringData.keys

Return Type: Set<string>

keys() as Set<string>
Gets the keys of this IData

Returns: The keys of this IData.

script.zs
// StringData.keys() as Set<string>;
myStringData.keys();

Return Type: Set<string>

static listOf(members as IData[]) as IData
Creates a collection of the given IData members.


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.

script.zs
// StringData.listOf(members as IData[]) as IData;
StringData.listOf(1, 2, 3);

Parameters:

members Type: IData[] - The members to put in the list.

Return Type: IData

map(operation as function(r as IData) as IData) as IData
Maps this IData to another IData based on the given operation.

Returns: A new IData from the operation

script.zs
// StringData.map(operation as function(r as IData) as IData) as IData;
myStringData.map((data) => 3);

Parameters:

operation Type: function(r as IData) as IData - The operation to apply to this IData

Return Type: IData

merge(other as IData) as IData
Merges the given data with this data.

Returns: the result of merging the datas.

script.zs
// StringData.merge(other as IData) as IData;
myStringData.merge(myIData);

Parameters:

other Type: IData - the data to merge

Return Type: IData

put(index as string, value as IData)
Puts the given value inside this IData at the given index.
script.zs
// StringData.put(index as string, value as IData);
myStringData.put("key", "value");

Parameters:

index Type: string - The key to store the data at
value Type: IData - The data to store.
remove(index as int)
Removes the stored data at the given index.
script.zs
// StringData.remove(index as int);
myStringData.remove(0);

Parameters:

index Type: int - The index to remove.
remove(key as string)
Removes the stored data at the given key.
script.zs
// StringData.remove(key as string);
myStringData.remove("key");

Parameters:

key Type: string - The key to remove.
setAt(name as string, data as IData)
Sets the given value inside this IData at the given index.
script.zs
// StringData.setAt(name as string, data as IData);
myStringData.setAt(myString, myIData);

Parameters:

name Type: string - The key to store the data at
data Type: IData - The data to store.