Импорт класса

Link to импорт-класса

It might be required for you to import the package if you encounter any issues (like casting an Array), so better be safe than sorry and add the import at the very top of the file.

ZenScript
Copy
import crafttweaker.api.data.MapData;

Implemented Interfaces

Link to implemented-interfaces

MapData implements the following interfaces. That means all methods defined in these interfaces are also available in MapData

ZenScript
Copy
new MapData() as MapData
new MapData();
ZenScript
Copy
new MapData(map as IData[string]) as MapData
ПараметрТип
Параметр
map
Тип
IData[string]
Result TypeЯвляется неявным
Result Type
boolean
Является неявным
false
Result Type
ICollectionData
Является неявным
false
Result Type
IData[string]
Является неявным
true
Result Type
INumberData
Является неявным
false

Name: asBoolean

Return Type: boolean

ZenScript
Copy
// MapData.asBoolean() as boolean

{Hello : "World", Somewhere: "Over the rainbow"}.asBoolean();

Name: asCollection

Return Type: ICollectionData

ZenScript
Copy
// MapData.asCollection() as ICollectionData

{Hello : "World", Somewhere: "Over the rainbow"}.asCollection();

Name: asList

Gets a List representation of this IData, returns null on anything but ListData.

Returns: null if this IData is not a list.
Return Type: stdlib.List<IData>

ZenScript
Copy
// MapData.asList() as stdlib.List<IData>

{Hello : "World", Somewhere: "Over the rainbow"}.asList();

Name: asNumber

Return Type: INumberData

ZenScript
Copy
// MapData.asNumber() as INumberData

{Hello : "World", Somewhere: "Over the rainbow"}.asNumber();

Name: asString

Gets the String representation of this IData

Returns: String that represents this IData (value and type).
Return Type: string

ZenScript
Copy
// MapData.asString() as string

{Hello : "World", Somewhere: "Over the rainbow"}.asString();

Name: contains

Checks if the Map contains the given key.

Returns: True if the Map contains the key
Return Type: boolean

ZenScript
Copy
// MapData.contains(key as string) as boolean

{Hello : "World", Somewhere: "Over the rainbow"}.contains("Hello");
ПараметрТипОписание
Параметр
key
Тип
string
Описание
The key to search for

Name: getAt

Retrieves the value associated with the key

Returns: The value if present, null otherwise
Return Type: IData?

ZenScript
Copy
// MapData.getAt(key as string) as IData?

{Hello : "World", Somewhere: "Over the rainbow"}.getAt("Hello");
ПараметрТипОписание
Параметр
key
Тип
string
Описание
The key to search for

Name: getData

Retrieves the value associated with the key and returns it as the given type.

Returns: The value if present, null otherwise.
Return Type: @org.openzen.zencode.java.ZenCodeType.Nullable T

ZenScript
Copy
MapData.getData<T : IData>(key as string) as @org.openzen.zencode.java.ZenCodeType.Nullable T
ПараметрТипОписание
Параметр
key
Тип
string
Описание
The key to search for.
Параметр
T
Тип
IData
Описание

Name: getId

Gets the ID of the internal NBT tag.

Used to determine what NBT type is stored (in a list for example)

Returns: ID of the NBT tag that this data represents.
Return Type: byte

ZenScript
Copy
// MapData.getId() as byte

{Hello : "World", Somewhere: "Over the rainbow"}.getId();

Name: getString

Gets the String representation of the internal INBT tag

Returns: String that represents the internal INBT of this IData.
Return Type: string

ZenScript
Copy
// MapData.getString() as string

{Hello : "World", Somewhere: "Over the rainbow"}.getString();

Name: merge

Merges this map and the other map. If entries from this map and the other map share the values are tried to be merged. If that does not work, then the value from the other map is used.

Returns: This map, after the merge
Return Type: MapData

ZenScript
Copy
// MapData.merge(other as MapData) as MapData

{Hello : "World", Somewhere: "Over the rainbow"}.merge({Doodle: "Do"});
ПараметрТипОписание
Параметр
other
Тип
MapData
Описание
The other map.

Name: put

Adds sets the value for the given key or creates a new entry if it did not exist before.

Returns: The previous value if present, null otherwise
Return Type: IData?

ZenScript
Copy
// MapData.put(key as string, value as IData) as IData?

{Hello : "World", Somewhere: "Over the rainbow"}.put("Hello", "Goodbye");
ПараметрТипОписание
Параметр
key
Тип
string
Описание
The key to set the value for.
Параметр
value
Тип
IData
Описание
The value to set.

Name: putAll

Adds all entries from the given map into this one. Can override existing keys.

ZenScript
Copy
// MapData.putAll(map as IData[string])

{Hello : "World", Somewhere: "Over the rainbow"}.putAll({Hello: "Goodbye", Item: "Bedrock"});
ПараметрТипОписание
Параметр
map
Тип
IData[string]
Описание
The other entries to be added to this map

Name: remove

Removes the entry with the given key from the Map

ZenScript
Copy
// MapData.remove(key as string)

{Hello : "World", Somewhere: "Over the rainbow"}.remove("Somewhere");
ПараметрТипОписание
Параметр
key
Тип
string
Описание
The key of the entry to remove

Операторы

Link to операторы

Name: ADD

Adds all entries from the given IData to this entry

ZenScript
Copy
myMapData + data as IData

Name: CONTAINS

Checks if the Map contains the given key.

ZenScript
Copy
key as string in myMapData
"Hello" in {Hello : "World", Somewhere: "Over the rainbow"}

Name: MEMBERGETTER

Retrieves the value associated with the key

ZenScript
Copy
myMapData.key as string
{Hello : "World", Somewhere: "Over the rainbow"}."Hello"

Name: MEMBERSETTER

Adds sets the value for the given key or creates a new entry if it did not exist before.

ZenScript
Copy
myMapData.key as string = value as IData
{Hello : "World", Somewhere: "Over the rainbow"}."Hello" = "Goodbye"

Свойства

Link to свойства

НазваниеТипИмеет GetterИмеет Setter
Название
isEmpty
Тип
boolean
Имеет Getter
true
Имеет Setter
false
Название
keySet
Тип
Set<string>
Имеет Getter
true
Имеет Setter
false
Название
size
Тип
int
Имеет Getter
true
Имеет Setter
false