Interface Document
- All Superinterfaces:
DomQueryable
,EventTarget
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final int
Amount of ticks an element remains 'active' for after being clicked -
Method Summary
Modifier and TypeMethodDescriptionvoid
addStylesheet
(@NotNull Stylesheet stylesheet) Adds a stylesheet to this document.void
Adopts a node if it belongs to another document instance.Creates a component node.createComponent
(@Nullable net.kyori.adventure.text.Component component) Create a component node.createElement
(@NotNull String tagName) Creates an element with a specifiedtagName
.Create an<item>
element.@NotNull StylesheetBuilder
Creates a new style sheet builder.Creates an empty text nodecreateText
(@Nullable String content) Creates a text node with the specifiedcontent
@Nullable Element
Gets the last clicked element that's still active.getBody()
Gets the body element of the document.Get the root document element.@Nullable Element
getElementById
(String elementId) Gets the first descendant element of with the specifiedelementId
@NotNull EventTarget
Gets the global event target.getHead()
Get the<head>
element@Nullable Element
Gets the element the viewer's cursor is currently hovered over@Nullable String
Gets the value of the optionGets a set of all option keys.@NotNull List
<Stylesheet> Gets an unmodifiable list of stylesheets this document has.getView()
Gets the document view.newCustomEvent
(@NotNull String eventType) Create a new custom event.void
removeOption
(@NotNull String optionKey) Removes an option's value.void
Set an option's valueMethods inherited from interface com.juliewoolie.dom.DomQueryable
getElementsByClassName, getElementsByTagName, querySelector, querySelectorAll
Methods inherited from interface com.juliewoolie.dom.event.EventTarget
addEventListener, dispatchEvent, getOnAddAttribute, getOnAddOption, getOnAppendChild, getOnAttributeChange, getOnClick, getOnClosing, getOnInput, getOnLoaded, getOnMouseEnter, getOnMouseExit, getOnMouseMove, getOnOptionChange, getOnRemoveAttribute, getOnRemoveChild, getOnRemoveOption, getOnRightClick, getOnSetAttribute, getOnSetOption, getOnSpawned, onAddAttribute, onAddOption, onAppendChild, onAttributeChange, onClick, onClosing, onInput, onLoaded, onMouseEnter, onMouseExit, onMouseMove, onOptionChange, onRemoveAttribute, onRemoveChild, onRemoveOption, onRightClick, onSetAttribute, onSetOption, onSpawned, removeEventListener
-
Field Details
-
ACTIVE_TICKS
static final int ACTIVE_TICKSAmount of ticks an element remains 'active' for after being clicked- See Also:
-
-
Method Details
-
getView
DocumentView getView()Gets the document view.- Returns:
- Document view, or
null
, if the document hasn't been shown to a player yet.
-
getOption
-
setOption
Set an option's valueIf the option value is
null
or empty, then this acts the same as callingremoveOption(String)
Will trigger an
EventTypes.MODIFY_OPTION
event after changing the value.- Parameters:
optionKey
- Option keyvalue
- Option value- Throws:
NullPointerException
- ifoptionKey
is null
-
removeOption
Removes an option's value.If the option already has no set value, this method does nothing. Otherwise, it will trigger an
EventTypes.MODIFY_OPTION
event after changing the value.- Parameters:
optionKey
- Option key- Throws:
NullPointerException
- ifoptionKey
is null
-
getOptionKeys
-
createElement
Creates an element with a specifiedtagName
.The type returned by this method corresponds to the specified tag name.
- Parameters:
tagName
- Element's tag name.- Returns:
- Created element
- Throws:
NullPointerException
- iftagName
isnull
-
createItemElement
-
createText
-
createText
-
createComponent
ComponentElement createComponent()Creates a component node.Component nodes differ from
TextNode
s by the fact they use a fully-styled,Component
. It is not recommended to use this, because it can conflict with document styling.Components are required in certain instances, like in item tooltips, where it's not possible to dissect each line of the tooltip, and instead, a component node is used for the content.
- Returns:
- Created component node
-
createComponent
Create a component node.Component nodes differ from
TextNode
s by the fact they use a fully-styled,Component
. It is not recommended to use this, because it can conflict with document styling.Components are required in certain instances, like in item tooltips, where it's not possible to dissect each line of the tooltip, and instead, a component node is used for the content.
- Parameters:
component
- Node content- Returns:
- Created component node
-
newCustomEvent
Create a new custom event.Allows for creating and listening to custom event types with custom event properties.
Before the event can be dispatched, it must be initialized with
CustomEvent.initEvent(Element, boolean, boolean, Map)
.- Parameters:
eventType
- Event Type- Returns:
- Created event
- Throws:
NullPointerException
- IfeventType
isnull
IllegalArgumentException
- IfeventType
is an empty string
-
getActiveElement
Gets the last clicked element that's still active.When an element is clicked, it will remain active for
ACTIVE_TICKS
ticks.- Returns:
- Active element
-
getHoveredElement
Gets the element the viewer's cursor is currently hovered over- Returns:
- Hovered element
-
getBody
BodyElement getBody()Gets the body element of the document.The body element contains all the content of a document
- Returns:
- Document body
-
getDocumentElement
-
getHead
HeadElement getHead()Get the<head>
element- Returns:
- Head element, or
null
, if no header was declared.
-
getElementById
-
getGlobalTarget
Gets the global event target.The target returned by this method will be called after an event has finished propagation, unless the event has been cancelled.
This target will be invoked after ALL events.
Note that, calling the document's
EventTarget.addEventListener(String, EventListener)
is not the same as calling the add event listener on the returned event target.- Returns:
- Global event target
-
adopt
Adopts a node if it belongs to another document instance.- Parameters:
node
- Node to adopt.- Throws:
NullPointerException
- ifnode
isnull
-
addStylesheet
Adds a stylesheet to this document.- Parameters:
stylesheet
- Style sheet- Throws:
NullPointerException
- ifstylesheet
isnull
-
getStylesheets
Gets an unmodifiable list of stylesheets this document has.- Returns:
- Unmodifiable stylesheet list.
-
createStylesheet
Creates a new style sheet builder.When
StylesheetBuilder.build()
is called on the returned sheet, the stylesheet is automatically added to this document's stylesheet list.- Returns:
- Created stylesheet builder
-