diff --git a/src/main/kotlin/net/axay/kspigot/gui/elements/GUISpaceCompound.kt b/src/main/kotlin/net/axay/kspigot/gui/elements/GUISpaceCompound.kt index d8e63432..d86b9e97 100644 --- a/src/main/kotlin/net/axay/kspigot/gui/elements/GUISpaceCompound.kt +++ b/src/main/kotlin/net/axay/kspigot/gui/elements/GUISpaceCompound.kt @@ -149,22 +149,47 @@ abstract class AbstractGUISpaceCompound internal constructo /** * Adds a new element to the compound. */ - fun addContent(element: E) { - addContent(listOf(element)) - } + fun addContent(element: E) = addContent(listOf(element)) /** * Adds new elements to the compound. */ fun addContent(elements: Iterable) { - content += elements + refreshAfterContentChange() + } + + /** + * Removes this element from the compound. + */ + fun removeContent(element: E) = removeContent(listOf(element)) + + /** + * Removes these elements from the compound. + */ + fun removeContent(elements: Iterable) { + content -= elements + refreshAfterContentChange() + } + + /** + * Set the content of the compound to this single element. + */ + fun setContent(element: E) = setContent(listOf(element)) + + /** + * Set the content of the compound to these elements. + */ + fun setContent(elements: Iterable) { + content.clear() + content += elements + refreshAfterContentChange() + } + + private fun refreshAfterContentChange() { contentSort.invoke() - recalculateCurrentContent() - updateOpenGUIs() - } }