Skip to content

Data types

Daniel Saukel edited this page May 13, 2018 · 10 revisions

Key and value

Basically means this:

key: value

Note that keys are always Strings, while values may be any value listed here.

Common data types

Primitive values

Type Size Annotation Example
Byte 8 Bit Numeric value from -128 to 127 key: 64
Short 16 Bit Numeric value from -32,768 to 32,767 key: 367
Integer 32 Bit Numeric value from -2^31 to 2^31-1 key: 5000
Long 64 Bit Numeric value from -2^63 to 2^63-1 key: 1525199972497
Float 32 Bit Decimal number key: .23
Double 64 Bit Decimal number (may be large af) key: 5430.674343
Boolean 1 Bit True / false value key: true

String

A String is a sequence of characters. Since some values break the YAML syntax, you might need to add "" to indicate the beginning and the end of the string.

key: "This is a String"

List

key:
  - "value"
  - "also part of the value"

Map

key:
  value_key: "Value String"
  another_value_key: 5.678

UUID

key: "c3fd48a2-c23c-4952-84e7-bf62a1408c99"

Base64

https://www.base64encode.org can be used to encode Base64 strings. A common Minecraft related use case is the serialization of user profiles to make persistent texture values.

Many nice texture values meant to be used with heads can be found here.

key: "eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvZjM0ODdkNDU3ZjkwNjJkNzg3YTNlNmNlMWM0NjY0YmY3NDAyZWM2N2RkMTExMjU2ZjE5YjM4Y2U0ZjY3MCJ9fX0="

Data types related to Minecraft

Attribute data

key:
  nameOfFirstAttribute:
    type: "GENERIC_ATTACK_DAMAGE"
    slots:
      - "MAIN_HAND"
      - "OFF_HAND"
      - "HEAD"
      - "TORSO"
      - "LEGS"
      - "FEET"
    operation: "ADD_NUMBER"
    amount: 8.5 # double
  nameOfSecondAttribute:
    type: "GENERIC_MOVEMENT_SPEED"
    slots:
      - "OFF_HAND"
    operation: "ADD_NUMBER"
    amount: 8.5

Firework effects

key:
  power: 40 # 0-128
  effects:
    type: # See https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/FireworkEffect.Type.html
    colors: LIST OF NUMERIC BGR VALUES
    fadeColors: LIST OF NUMERIC BGR VALUES
    hasFlicker: true
    hasTrail: true

Items

Caliburn provides multiple ways to (de-) serialize item stacks.

Bukkit

Caliburn recognizes the internal item stack serialization format of Bukkit:

key:
  ==: org.bukkit.inventory.ItemStack
  type: IRON_SWORD
  damage: 55
  amount: 1

Simple item stack serialization

This format allows to create customizable item stacks with just one line of the config file:

key: "item:<id>,<amount>,<damage>,<data>"

Example:

key: "item:golden_sword,16,50,E:PROTECTION_ENVIRONMENTAL#4,F:HIDE_ATTRIBUTES,L:&6Lore line 1<br>&7Lore line 2,U"

The "item:" prefix may also be left out.

"Data" may be:

Tag Valid input Example
ENCHANTMENT / ENCH / E enchantment#level E:PROTECTION_ENVIRONMENTAL#4
ITEMFLAG / FLAG / F Item flag F:HIDE_ATTRIBUTES
LORE / L String (color codes are supported; use <br> to indicate the start of the next line) L:&6Lore line 1
&7Lore line 2
NAME / N String (color codes are supported) N:&4Custom item name
UNBREAKABLE / U (nothing) U

Item ID

The item ID determines the item type. One of the key features of Caliburn is that items and mobs can be identified by fully version independent identifier strings. Possible identifiers are:

Format Example: golden sword Example: lapis lazuli
Numeric ID key: 283 (none)
Numeric ID and data key: "283:0" key: "351:4"
Minecraft key: "golden_sword" key: "lapis_lazuli"
Bukkit 1.13+ key: "GOLDEN_SWORD" key: "LAPIS_LAZULI"
Bukkit -1.12 key: "GOLD_SWORD" (none)
Bukkit -1.12 and data key: "GOLD_SWORD:0" key: "INK_SACK:4"

Mobs

Caliburn provides multiple ways to (de-) serialize mobs.

Mob ID

Just like for item IDs, Caliburn also provides multiple types of mob identifiers.

Format Example: Mushroom cow Example: Magma Cube
Numeric ID key: 96 key: 62
Minecraft 1.11+ key: "mooshroom" key: "magma_cube"
Minecraft -1.10 key: "MushroomCow" key: "LavaSlime"
Bukkit key: "MOOSHROOM" key: "MAGMA_CUBE"