From 181dbbb1e4142b891a3780311914847c62c2126d Mon Sep 17 00:00:00 2001 From: alexcrea Date: Sat, 3 Feb 2024 00:13:00 +0100 Subject: [PATCH] change permission and update gitignore --- .gitignore | 2 ++ .../kotlin/io/delilaheve/AnvilEventListener.kt | 18 +++++------------- .../kotlin/io/delilaheve/UnsafeEnchants.kt | 4 ++-- src/main/resources/plugin.yml | 2 +- 4 files changed, 10 insertions(+), 16 deletions(-) diff --git a/.gitignore b/.gitignore index 1dc1a34..80d6030 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,4 @@ /.idea/ /.gradle/ +/build/ +/out/ diff --git a/src/main/kotlin/io/delilaheve/AnvilEventListener.kt b/src/main/kotlin/io/delilaheve/AnvilEventListener.kt index 51a479c..f9fe27c 100644 --- a/src/main/kotlin/io/delilaheve/AnvilEventListener.kt +++ b/src/main/kotlin/io/delilaheve/AnvilEventListener.kt @@ -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,13 +108,13 @@ class AnvilEventListener : Listener { private fun itemAllowed(item: ItemStack, player: HumanEntity): Boolean{ - if(!player.hasPermission(bypassPermission)){ - if(player.hasPermission(requirePermission)){ - if(UnsafeEnchants.conflictManager.isConflicting(item)) - return false + if(player.hasPermission(UnsafeEnchants.unsafeBypassPermission)) return true - } else if(item.findEnchantments().hasConflicts()) + if(player.hasPermission(UnsafeEnchants.unsafePermission)){ + if(UnsafeEnchants.conflictManager.isConflicting(item)) return false + }else if (item.findEnchantments().hasConflicts()){ + return false } return true } diff --git a/src/main/kotlin/io/delilaheve/UnsafeEnchants.kt b/src/main/kotlin/io/delilaheve/UnsafeEnchants.kt index 957cbde..dc5f9bc 100644 --- a/src/main/kotlin/io/delilaheve/UnsafeEnchants.kt +++ b/src/main/kotlin/io/delilaheve/UnsafeEnchants.kt @@ -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 diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml index 901f6f2..af176c7 100644 --- a/src/main/resources/plugin.yml +++ b/src/main/resources/plugin.yml @@ -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 \ No newline at end of file