Skip to content

Commit f549420

Browse files
committed
Hide legacy flags from plot settings GUI
1 parent 808d17c commit f549420

1 file changed

Lines changed: 5 additions & 3 deletions

File tree

‎src/main/kotlin/pl/syntaxdevteam/plotsx/gui/FlagsGUI.kt‎

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,9 @@ class FlagsGUI(
3030
inventory.clear()
3131

3232
val flags = plugin.cacheManager.getFlags(plot.id) ?: plugin.databaseHandler.getPlotFlags(plot.id)
33+
val visibleFlags = PlotFlagRegistry.visibleFlags
3334

34-
PlotFlagRegistry.allFlags.values.drop(page * 45).take(45).forEachIndexed { idx: Int, flagMeta ->
35+
visibleFlags.drop(page * 45).take(45).forEachIndexed { idx: Int, flagMeta ->
3536

3637
val flagData = flags.firstOrNull { it.name == flagMeta.name }
3738
val current = flagData?.value?.toBooleanStrictOrNull() ?: flagMeta.defaultValue
@@ -56,7 +57,7 @@ class FlagsGUI(
5657

5758
if (page > 0) inventory.setItem(45, plugin.guiHandler.createItem(Material.ARROW,
5859
message.stringMessageToComponentNoPrefix("members", "previous")))
59-
if ((page + 1) * 45 < PlotFlagRegistry.allFlags.size) inventory.setItem(53, plugin.guiHandler.createItem(Material.ARROW,
60+
if ((page + 1) * 45 < visibleFlags.size) inventory.setItem(53, plugin.guiHandler.createItem(Material.ARROW,
6061
message.stringMessageToComponentNoPrefix("members", "next")))
6162
super.open(player)
6263
}
@@ -69,6 +70,7 @@ class FlagsGUI(
6970
val player = event.whoClicked as? Player ?: return
7071
val clicked = event.currentItem ?: return
7172
val meta = clicked.itemMeta ?: return
73+
val visibleFlags = PlotFlagRegistry.visibleFlags
7274

7375
plugin.guiHandler.unregisterGui(player)
7476
player.closeInventory()
@@ -80,7 +82,7 @@ class FlagsGUI(
8082
plugin.guiHandler.registerGui(player, FlagsGUI(plugin, plot, page - 1))
8183
return
8284
}
83-
if (event.slot == 53 && (page + 1) * 45 < PlotFlagRegistry.allFlags.size) {
85+
if (event.slot == 53 && (page + 1) * 45 < visibleFlags.size) {
8486
plugin.guiHandler.registerGui(player, FlagsGUI(plugin, plot, page + 1))
8587
return
8688
}

0 commit comments

Comments
 (0)