Skip to content

Commit

Permalink
Spotless
Browse files Browse the repository at this point in the history
  • Loading branch information
Aeltumn committed Jul 14, 2024
1 parent 4f32191 commit c9fccf6
Show file tree
Hide file tree
Showing 6 changed files with 46 additions and 22 deletions.
4 changes: 2 additions & 2 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@ end_of_line = lf
indent_size = 4
indent_style = space
insert_final_newline = true
max_line_length = 160
max_line_length = 130
tab_width = 4
ij_continuation_indent_size = 8
ij_formatter_off_tag = @formatter:off
ij_formatter_on_tag = @formatter:on
ij_formatter_tags_enabled = false
ij_smart_tabs = false
ij_wrap_on_typing = false
ij_wrap_on_typing = true

[*.conf]
indent_size = 2
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import com.noxcrew.interfaces.drawable.Drawable
import com.noxcrew.interfaces.element.StaticElement
import com.noxcrew.interfaces.interfaces.Interface
import com.noxcrew.interfaces.interfaces.buildChestInterface
import com.noxcrew.interfaces.interfaces.buildCombinedInterface
import kotlinx.coroutines.DelicateCoroutinesApi
import kotlinx.coroutines.GlobalScope
import kotlinx.coroutines.delay
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import org.incendo.cloud.execution.ExecutionCoordinator
import org.incendo.cloud.kotlin.coroutines.extension.suspendingHandler
import org.incendo.cloud.kotlin.extension.buildAndRegister
import org.incendo.cloud.paper.LegacyPaperCommandManager
import org.incendo.cloud.paper.PaperCommandManager

public class ExamplePlugin : JavaPlugin(), Listener {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import com.noxcrew.interfaces.drawable.Drawable.Companion.drawable
import com.noxcrew.interfaces.element.StaticElement
import com.noxcrew.interfaces.interfaces.Interface
import com.noxcrew.interfaces.interfaces.buildChestInterface
import com.noxcrew.interfaces.interfaces.buildCombinedInterface
import com.noxcrew.interfaces.utilities.BoundInteger
import org.bukkit.Material

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ public class InterfacesListeners private constructor(private val plugin: Plugin)
MaterialTags.WOODEN_DOORS,
MaterialTags.WOODEN_TRAPDOORS,
MaterialTags.FENCE_GATES,
MaterialSetTag.BUTTONS,
MaterialSetTag.BUTTONS
)
// Add blocks with inventories
.add(
Expand All @@ -96,7 +96,7 @@ public class InterfacesListeners private constructor(private val plugin: Plugin)
Material.LOOM,
Material.CARTOGRAPHY_TABLE,
Material.ENCHANTING_TABLE,
Material.SMITHING_TABLE,
Material.SMITHING_TABLE
)
.add(Material.LEVER)
.add(Material.CAKE)
Expand All @@ -105,25 +105,25 @@ public class InterfacesListeners private constructor(private val plugin: Plugin)
Material.COPPER_DOOR,
Material.EXPOSED_COPPER_DOOR,
Material.WEATHERED_COPPER_DOOR,
Material.OXIDIZED_COPPER_DOOR,
Material.OXIDIZED_COPPER_DOOR
)
.add(
Material.WAXED_COPPER_DOOR,
Material.WAXED_EXPOSED_COPPER_DOOR,
Material.WAXED_WEATHERED_COPPER_DOOR,
Material.WAXED_OXIDIZED_COPPER_DOOR,
Material.WAXED_OXIDIZED_COPPER_DOOR
)
.add(
Material.COPPER_TRAPDOOR,
Material.EXPOSED_COPPER_TRAPDOOR,
Material.WEATHERED_COPPER_TRAPDOOR,
Material.OXIDIZED_COPPER_TRAPDOOR,
Material.OXIDIZED_COPPER_TRAPDOOR
)
.add(
Material.WAXED_COPPER_TRAPDOOR,
Material.WAXED_EXPOSED_COPPER_TRAPDOOR,
Material.WAXED_WEATHERED_COPPER_TRAPDOOR,
Material.WAXED_OXIDIZED_COPPER_TRAPDOOR,
Material.WAXED_OXIDIZED_COPPER_TRAPDOOR
)
// You can click signs to edit them
.add(MaterialTags.SIGNS)
Expand Down Expand Up @@ -253,13 +253,23 @@ public class InterfacesListeners private constructor(private val plugin: Plugin)
if (view.backing.includesPlayerInventory) {
// If you use a number key we check if the item you're swapping with is
// protected.
if (event.click == ClickType.NUMBER_KEY && !canFreelyMove(view, view.backing.relativizePlayerInventorySlot(GridPoint.at(3, event.hotbarButton)), true)) {
if (event.click == ClickType.NUMBER_KEY && !canFreelyMove(
view,
view.backing.relativizePlayerInventorySlot(GridPoint.at(3, event.hotbarButton)),
true
)
) {
event.isCancelled = true
return
}

// If you try to swap with the off-hand we have to specifically check for that.
if (event.click == ClickType.SWAP_OFFHAND && !canFreelyMove(view, view.backing.relativizePlayerInventorySlot(GridPoint.at(4, 4)), true)) {
if (event.click == ClickType.SWAP_OFFHAND && !canFreelyMove(
view,
view.backing.relativizePlayerInventorySlot(GridPoint.at(4, 4)),
true
)
) {
event.isCancelled = true
return
}
Expand All @@ -274,14 +284,26 @@ public class InterfacesListeners private constructor(private val plugin: Plugin)

// Don't check top inventory if we're in the player inventory!
if (
(!isInPlayerInventory && topInventory.withIndex().any { (index, it) ->
// Check if any item is being collected that cannot be moved!
it != null && it.isSimilar(clickedItem) && !canFreelyMove(view, requireNotNull(GridPoint.fromBukkitChestSlot(index)), false)
}) ||
(
!isInPlayerInventory && topInventory.withIndex().any { (index, it) ->
// Check if any item is being collected that cannot be moved!
it != null && it.isSimilar(clickedItem) && !canFreelyMove(
view,
requireNotNull(GridPoint.fromBukkitChestSlot(index)),
false
)
}
) ||
bottomInventory.withIndex().any { (index, it) ->
it != null && it.isSimilar(clickedItem) &&
// These slots are always in the player inventory and always need to be relativized!
!canFreelyMove(view, view.backing.relativizePlayerInventorySlot(requireNotNull(GridPoint.fromBukkitPlayerSlot(index))), true)
// These slots are always in the player inventory and always need to be relativized!
!canFreelyMove(
view,
view.backing.relativizePlayerInventorySlot(
requireNotNull(GridPoint.fromBukkitPlayerSlot(index))
),
true
)
}
) {
event.isCancelled = true
Expand Down Expand Up @@ -509,7 +531,11 @@ public class InterfacesListeners private constructor(private val plugin: Plugin)
isPlayerInventory: Boolean
): Boolean {
// If we don't allow clicking empty slots we never allow freely moving
if (view.builder.preventClickingEmptySlots && !(view.builder.allowClickingOwnInventoryIfClickingEmptySlotsIsPrevented && isPlayerInventory)) return false
if (view.builder.preventClickingEmptySlots &&
!(view.builder.allowClickingOwnInventoryIfClickingEmptySlotsIsPrevented && isPlayerInventory)
) {
return false
}

// If this inventory has no player inventory then the player inventory is always allowed to be edited
if (!view.backing.includesPlayerInventory && isPlayerInventory) return true
Expand All @@ -531,7 +557,9 @@ public class InterfacesListeners private constructor(private val plugin: Plugin)

// Optionally cancel clicking on other slots
if (raw == null) {
if (view.builder.preventClickingEmptySlots && !(view.builder.allowClickingOwnInventoryIfClickingEmptySlotsIsPrevented && isPlayerInventory)) {
if (view.builder.preventClickingEmptySlots &&
!(view.builder.allowClickingOwnInventoryIfClickingEmptySlotsIsPrevented && isPlayerInventory)
) {
return true
}
return false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package com.noxcrew.interfaces.interfaces
import com.noxcrew.interfaces.InterfacesListeners
import com.noxcrew.interfaces.grid.GridPoint
import com.noxcrew.interfaces.pane.CombinedPane
import com.noxcrew.interfaces.pane.OrderedPane
import com.noxcrew.interfaces.pane.Pane
import com.noxcrew.interfaces.view.InterfaceView
import org.bukkit.entity.Player
Expand Down

0 comments on commit c9fccf6

Please sign in to comment.