Skip to content

Commit dff8632

Browse files
committed
Add back filling background with air
1 parent 86550f2 commit dff8632

File tree

3 files changed

+19
-3
lines changed

3 files changed

+19
-3
lines changed

interfaces/src/main/kotlin/com/noxcrew/interfaces/pane/CompletedPane.kt

+15
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
11
package com.noxcrew.interfaces.pane
22

3+
import com.noxcrew.interfaces.click.ClickHandler
34
import com.noxcrew.interfaces.element.CompletedElement
45
import com.noxcrew.interfaces.element.complete
56
import com.noxcrew.interfaces.grid.GridMap
67
import com.noxcrew.interfaces.grid.GridPoint
78
import com.noxcrew.interfaces.grid.HashGridMap
9+
import com.noxcrew.interfaces.utilities.forEachInGrid
10+
import com.noxcrew.interfaces.view.AbstractInterfaceView.Companion.COLUMNS_IN_CHEST
811
import org.bukkit.entity.Player
912

1013
/** A grid map of completed elements. */
@@ -34,6 +37,18 @@ internal suspend fun Pane.complete(player: Player): CompletedPane {
3437
return pane
3538
}
3639

40+
/** Fills up a completed pane with empty elements. */
41+
internal fun Pane.convertToEmptyCompletedPaneAndFill(rows: Int): CompletedPane {
42+
val pane = convertToEmptyCompletedPane()
43+
val airElement = CompletedElement(null, ClickHandler.EMPTY)
44+
45+
forEachInGrid(rows, COLUMNS_IN_CHEST) { row, column ->
46+
pane[row, column] = airElement
47+
}
48+
49+
return pane
50+
}
51+
3752
/** Converts this pane to either a [CompletedPane] or [CompletedOrderedPane] based on its type. */
3853
internal fun Pane.convertToEmptyCompletedPane(): CompletedPane {
3954
if (this is OrderedPane) {

interfaces/src/main/kotlin/com/noxcrew/interfaces/utilities/CollapsablePaneMap.kt

+3-2
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package com.noxcrew.interfaces.utilities
33
import com.noxcrew.interfaces.pane.CompletedPane
44
import com.noxcrew.interfaces.pane.Pane
55
import com.noxcrew.interfaces.pane.convertToEmptyCompletedPane
6+
import com.noxcrew.interfaces.pane.convertToEmptyCompletedPaneAndFill
67

78
/** A collection of completed panes that can be collapsed to create a new merged [CompletedPane]. */
89
internal class CollapsablePaneMap private constructor(
@@ -29,12 +30,12 @@ internal class CollapsablePaneMap private constructor(
2930
return internal.put(key, value)
3031
}
3132

32-
internal fun collapse(): CompletedPane {
33+
internal fun collapse(rows: Int, fill: Boolean): CompletedPane {
3334
cachedPane?.let { pane ->
3435
return pane
3536
}
3637

37-
val pane = basePane.convertToEmptyCompletedPane()
38+
val pane = if (fill) basePane.convertToEmptyCompletedPaneAndFill(rows) else basePane.convertToEmptyCompletedPane()
3839
val current = internal.toMap().values
3940

4041
current.forEach { layer ->

interfaces/src/main/kotlin/com/noxcrew/interfaces/view/AbstractInterfaceView.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ public abstract class AbstractInterfaceView<I : InterfacesInventory, T : Interfa
201201
semaphore.acquire()
202202
try {
203203
withTimeout(6.seconds) {
204-
pane = panes.collapse()
204+
pane = panes.collapse(backing.totalRows(), builder.fillMenuWithAir)
205205
renderToInventory { createdNewInventory ->
206206
// send an update packet if necessary
207207
if (!createdNewInventory && requiresPlayerUpdate()) {

0 commit comments

Comments
 (0)