change permission and update gitignore

This commit is contained in:
alexcrea 2024-02-03 00:13:00 +01:00
parent 60dd28024e
commit 181dbbb1e4
4 changed files with 10 additions and 16 deletions

2
.gitignore vendored
View file

@ -1,2 +1,4 @@
/.idea/
/.gradle/
/build/
/out/

View file

@ -20,7 +20,6 @@ import org.bukkit.event.inventory.PrepareAnvilEvent
import org.bukkit.inventory.AnvilInventory
import org.bukkit.inventory.InventoryView.Property.REPAIR_COST
import org.bukkit.inventory.ItemStack
import org.bukkit.permissions.Permission
import kotlin.math.min
/**
@ -33,13 +32,6 @@ class AnvilEventListener : Listener {
private const val ANVIL_OUTPUT_SLOT = 2
}
// Permission node required for the plugin to take over enchantment combination
private val requirePermission: Permission
get() = Permission(UnsafeEnchants.unsafePermission)
// Permission node to bypass illegal group check
private val bypassPermission: Permission
get() = Permission(UnsafeEnchants.unsafeBypassPermission)
/**
* Event handler logic for when an anvil contains items to be combined
*/
@ -116,12 +108,12 @@ class AnvilEventListener : Listener {
private fun itemAllowed(item: ItemStack, player: HumanEntity): Boolean{
if(!player.hasPermission(bypassPermission)){
if(player.hasPermission(requirePermission)){
if(player.hasPermission(UnsafeEnchants.unsafeBypassPermission)) return true
if(player.hasPermission(UnsafeEnchants.unsafePermission)){
if(UnsafeEnchants.conflictManager.isConflicting(item))
return false
} else if(item.findEnchantments().hasConflicts())
}else if (item.findEnchantments().hasConflicts()){
return false
}
return true

View file

@ -18,8 +18,8 @@ class UnsafeEnchants : JavaPlugin() {
companion object {
// Permission string required to use the plugin's features
const val unsafePermission = "ue.unsafe"
// Permission string required to bypass illegal enchantment group
const val unsafeBypassPermission = "ue.unsafe_all"
// Permission string required to bypass enchantment conflicts test
const val unsafeBypassPermission = "ue.bypass.fuse"
// Item Grouping Configuration file name
const val itemGroupingConfigName = "item_groups.yml"
// Conflict Configuration file name

View file

@ -12,6 +12,6 @@ permissions:
ue.unsafe:
default: true
description: Allow player to combine allowed "unsafe" enchants
ue.unsafe_all:
ue.bypass.fuse:
default: false
description: Allow player to combine every "unsafe" enchants