Skip to content

Commit

Permalink
Added talisman slot type
Browse files Browse the repository at this point in the history
  • Loading branch information
WillFP committed Jan 6, 2024
1 parent 05e4b4c commit 0ce22d3
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,12 @@ import com.willfp.libreforge.registerHolderProvider
import com.willfp.libreforge.registerPlayerRefreshFunction
import com.willfp.libreforge.registerSpecificHolderProvider
import com.willfp.libreforge.registerSpecificRefreshFunction
import com.willfp.libreforge.slot.SlotTypes
import com.willfp.talismans.bag.TalismanBag
import com.willfp.talismans.command.CommandTalismans
import com.willfp.talismans.display.TalismanDisplay
import com.willfp.talismans.libreforge.ConditionHasTalisman
import com.willfp.talismans.libreforge.SlotTypeTalisman
import com.willfp.talismans.talismans.Talismans
import com.willfp.talismans.talismans.util.BlockPlaceListener
import com.willfp.talismans.talismans.util.DiscoverRecipeListener
Expand All @@ -34,6 +36,8 @@ class TalismansPlugin : LibreforgePlugin() {
}

override fun handleEnable() {
SlotTypes.register(SlotTypeTalisman)

registerSpecificHolderProvider<Player> {
TalismanChecks.getTalismansOnPlayer(it)
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package com.willfp.talismans.libreforge

import com.willfp.libreforge.slot.SlotType
import com.willfp.talismans.talismans.util.TalismanChecks
import org.bukkit.entity.LivingEntity
import org.bukkit.entity.Player
import org.bukkit.inventory.ItemStack

object SlotTypeTalisman: SlotType("talisman") {
override fun getItems(entity: LivingEntity): List<ItemStack> {
return if (entity is Player) {
TalismanChecks.getTalismanItemsOnPlayer(entity).toList()
} else {
emptyList()
}
}

override fun addToSlot(player: Player, item: ItemStack): Boolean {
return false
}

override fun getItemSlots(player: Player): List<Int> {
return emptyList()
}
}

0 comments on commit 0ce22d3

Please sign in to comment.