Added talisman bag size
This commit is contained in:
@@ -62,7 +62,7 @@ allprojects {
|
||||
}
|
||||
|
||||
dependencies {
|
||||
compileOnly 'com.willfp:eco:6.36.2'
|
||||
compileOnly 'com.willfp:eco:6.36.3'
|
||||
implementation 'com.willfp:libreforge:3.53.0'
|
||||
implementation 'org.joml:joml:1.10.4'
|
||||
|
||||
|
||||
@@ -11,6 +11,7 @@ import com.willfp.eco.core.gui.menu.Menu
|
||||
import com.willfp.eco.core.gui.slot
|
||||
import com.willfp.eco.core.items.Items
|
||||
import com.willfp.eco.core.recipe.parts.EmptyTestableItem
|
||||
import com.willfp.eco.util.MenuUtils
|
||||
import com.willfp.talismans.talismans.util.TalismanChecks
|
||||
import org.bukkit.Material
|
||||
import org.bukkit.entity.Player
|
||||
@@ -23,6 +24,27 @@ object TalismanBag {
|
||||
|
||||
private val savedItems = mutableMapOf<UUID, List<ItemStack>>()
|
||||
|
||||
private val Player.bagSize: Int
|
||||
get() {
|
||||
val prefix = "talismans.bagsize."
|
||||
var highest = -1
|
||||
for (permission in this.effectivePermissions.map { it.permission }) {
|
||||
if (!permission.startsWith(prefix)) {
|
||||
continue
|
||||
}
|
||||
|
||||
val limit = permission.substring(permission.lastIndexOf(".") + 1).toInt()
|
||||
if (limit > highest) {
|
||||
highest = limit
|
||||
}
|
||||
}
|
||||
return if (highest < 0) {
|
||||
10000
|
||||
} else {
|
||||
highest
|
||||
}
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
@ConfigUpdater
|
||||
fun update(plugin: EcoPlugin) {
|
||||
@@ -38,12 +60,19 @@ object TalismanBag {
|
||||
for (row in 1..rows) {
|
||||
for (column in 1..9) {
|
||||
setSlot(row, column, slot({ player, _ ->
|
||||
val inBag = player.profile.read(key).map { Items.lookup(it).item }
|
||||
val index = (column - 1) + ((row - 1) * 9)
|
||||
val bagSize = player.bagSize
|
||||
|
||||
inBag.toList().getOrNull(index)?.clone() ?: ItemStack(Material.AIR)
|
||||
val inBag = player.profile.read(key).map { Items.lookup(it).item }
|
||||
val index = MenuUtils.rowColumnToSlot(row, column)
|
||||
|
||||
if (index >= bagSize) {
|
||||
Items.lookup(plugin.configYml.getString("bag.blocked-item")).item
|
||||
} else {
|
||||
inBag.toList().getOrNull(index)?.clone() ?: ItemStack(Material.AIR)
|
||||
}
|
||||
}) {
|
||||
setCaptive(true)
|
||||
notCaptiveFor { MenuUtils.rowColumnToSlot(row, column) >= it.bagSize }
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,13 +35,22 @@ object TalismanUtils {
|
||||
|
||||
fun getLimit(player: Player): Int {
|
||||
val prefix = "talismans.limit."
|
||||
for (permissionAttachmentInfo in player.effectivePermissions) {
|
||||
val permission = permissionAttachmentInfo.permission
|
||||
if (permission.startsWith(prefix)) {
|
||||
return permission.substring(permission.lastIndexOf(".") + 1).toInt()
|
||||
var highest = -1
|
||||
for (permission in player.effectivePermissions.map { it.permission }) {
|
||||
if (!permission.startsWith(prefix)) {
|
||||
continue
|
||||
}
|
||||
|
||||
val limit = permission.substring(permission.lastIndexOf(".") + 1).toInt()
|
||||
if (limit > highest) {
|
||||
highest = limit
|
||||
}
|
||||
}
|
||||
return 100000
|
||||
return if (highest < 0) {
|
||||
10000
|
||||
} else {
|
||||
highest
|
||||
}
|
||||
}
|
||||
|
||||
fun isTalismanMaterial(material: Material): Boolean {
|
||||
|
||||
@@ -15,6 +15,7 @@ offhand-only: false # If talismans or shulkers of talismans need to be in the of
|
||||
bag:
|
||||
title: "Talisman Bag"
|
||||
rows: 4
|
||||
blocked-item: black_stained_glass_pane name:"&cYour talisman bag is not big enough!"
|
||||
|
||||
cannot-afford:
|
||||
in-actionbar: true
|
||||
|
||||
Reference in New Issue
Block a user