Templates

Tubing GUI has a system where it can transform XML files into Bukkit Inventories. This way we can describe what an inventory should look like and what exact actions should be performed when clicking on items.

Tubing provides an xml specification. The XML files can be converted by Tubing into TubingGui classes and eventually into Bukkit Inventories.

<xs:schema elementFormDefault="qualified"
           xmlns:xs="http://www.w3.org/2001/XMLSchema">
    <xs:element name="TubingGui">
        <xs:complexType>
            <xs:sequence>
                <xs:element name="title">
                    <xs:complexType mixed="true">
                        <xs:sequence>
                            <xs:element name="t" maxOccurs="unbounded" minOccurs="0">
                                <xs:complexType>
                                    <xs:simpleContent>
                                        <xs:extension base="xs:string">
                                            <xs:attribute type="xs:string" name="id"/>
                                            <xs:attribute type="xs:string" name="class"/>
                                            <xs:attribute type="xs:string" name="color"/>
                                        </xs:extension>
                                    </xs:simpleContent>
                                </xs:complexType>
                            </xs:element>
                        </xs:sequence>
                        <xs:attribute type="xs:string" name="id"/>
                        <xs:attribute type="xs:string" name="class"/>
                        <xs:attribute type="xs:string" name="color"/>
                    </xs:complexType>
                </xs:element>
                <xs:element name="GuiItem" maxOccurs="unbounded" minOccurs="0">
                    <xs:complexType>
                        <xs:sequence>
                            <xs:element name="name">
                                <xs:complexType mixed="true">
                                    <xs:sequence>
                                        <xs:element name="t" maxOccurs="unbounded" minOccurs="0">
                                            <xs:complexType>
                                                <xs:simpleContent>
                                                    <xs:extension base="xs:string">
                                                        <xs:attribute type="xs:string" name="id"/>
                                                        <xs:attribute type="xs:string" name="class"/>
                                                        <xs:attribute type="xs:string" name="color"/>
                                                    </xs:extension>
                                                </xs:simpleContent>
                                            </xs:complexType>
                                        </xs:element>
                                    </xs:sequence>
                                    <xs:attribute type="xs:string" name="permission"/>
                                    <xs:attribute type="xs:string" name="if"/>
                                    <xs:attribute type="xs:string" name="id"/>
                                    <xs:attribute type="xs:string" name="class"/>
                                    <xs:attribute type="xs:string" name="color"/>
                                </xs:complexType>
                            </xs:element>
                            <xs:element name="Lore" minOccurs="0">
                                <xs:complexType>
                                    <xs:sequence>
                                        <xs:element name="LoreLine" maxOccurs="unbounded" minOccurs="0">
                                            <xs:complexType mixed="true">
                                                <xs:sequence>
                                                    <xs:element name="t" maxOccurs="unbounded" minOccurs="0">
                                                        <xs:complexType>
                                                            <xs:simpleContent>
                                                                <xs:extension base="xs:string">
                                                                    <xs:attribute type="xs:string" name="id"
                                                                    />
                                                                    <xs:attribute type="xs:string" name="class"
                                                                    />
                                                                    <xs:attribute type="xs:string" name="color"
                                                                    />
                                                                </xs:extension>
                                                            </xs:simpleContent>
                                                        </xs:complexType>
                                                    </xs:element>
                                                </xs:sequence>
                                                <xs:attribute type="xs:string" name="permission"/>
                                                <xs:attribute type="xs:string" name="if"/>
                                                <xs:attribute type="xs:string" name="id"/>
                                                <xs:attribute type="xs:string" name="class"/>
                                                <xs:attribute type="xs:string" name="color"/>
                                            </xs:complexType>
                                        </xs:element>
                                    </xs:sequence>
                                </xs:complexType>
                            </xs:element>
                        </xs:sequence>
                        <xs:attribute type="xs:string" name="id"/>
                        <xs:attribute type="xs:string" name="class"/>
                        <xs:attribute type="xs:byte" name="slot"/>
                        <xs:attribute type="xs:string" name="onLeftClick"/>
                        <xs:attribute type="xs:string" name="onRightClick"/>
                        <xs:attribute type="xs:string" name="onMiddleClick"/>
                        <xs:attribute type="xs:string" name="material"/>
                    </xs:complexType>
                </xs:element>
            </xs:sequence>
            <xs:attribute type="xs:byte" name="size"/>
            <xs:attribute type="xs:string" name="id"/>
        </xs:complexType>
    </xs:element>
</xs:schema>

Template processing

The below diagram shows how a Freemarker template is processed by the tubing framework. What starts out as a Freemarker template file (.ftl), will be converted into the Tubing XML standard. That in turn can be converted to a TubingGui object. This object is used to show the player a bukkit inventory with actions linked to the items inside of it.

Last updated