mirror of
https://github.com/alexcrea/CustomAnvil.git
synced 2026-06-23 08:14:00 +02:00
change permission and update gitignore
This commit is contained in:
parent
60dd28024e
commit
181dbbb1e4
4 changed files with 10 additions and 16 deletions
2
.gitignore
vendored
2
.gitignore
vendored
|
|
@ -1,2 +1,4 @@
|
||||||
/.idea/
|
/.idea/
|
||||||
/.gradle/
|
/.gradle/
|
||||||
|
/build/
|
||||||
|
/out/
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,6 @@ import org.bukkit.event.inventory.PrepareAnvilEvent
|
||||||
import org.bukkit.inventory.AnvilInventory
|
import org.bukkit.inventory.AnvilInventory
|
||||||
import org.bukkit.inventory.InventoryView.Property.REPAIR_COST
|
import org.bukkit.inventory.InventoryView.Property.REPAIR_COST
|
||||||
import org.bukkit.inventory.ItemStack
|
import org.bukkit.inventory.ItemStack
|
||||||
import org.bukkit.permissions.Permission
|
|
||||||
import kotlin.math.min
|
import kotlin.math.min
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -33,13 +32,6 @@ class AnvilEventListener : Listener {
|
||||||
private const val ANVIL_OUTPUT_SLOT = 2
|
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
|
* 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{
|
private fun itemAllowed(item: ItemStack, player: HumanEntity): Boolean{
|
||||||
if(!player.hasPermission(bypassPermission)){
|
if(player.hasPermission(UnsafeEnchants.unsafeBypassPermission)) return true
|
||||||
if(player.hasPermission(requirePermission)){
|
|
||||||
if(UnsafeEnchants.conflictManager.isConflicting(item))
|
|
||||||
return false
|
|
||||||
|
|
||||||
} else if(item.findEnchantments().hasConflicts())
|
if(player.hasPermission(UnsafeEnchants.unsafePermission)){
|
||||||
|
if(UnsafeEnchants.conflictManager.isConflicting(item))
|
||||||
return false
|
return false
|
||||||
|
}else if (item.findEnchantments().hasConflicts()){
|
||||||
|
return false
|
||||||
}
|
}
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -18,8 +18,8 @@ class UnsafeEnchants : JavaPlugin() {
|
||||||
companion object {
|
companion object {
|
||||||
// Permission string required to use the plugin's features
|
// Permission string required to use the plugin's features
|
||||||
const val unsafePermission = "ue.unsafe"
|
const val unsafePermission = "ue.unsafe"
|
||||||
// Permission string required to bypass illegal enchantment group
|
// Permission string required to bypass enchantment conflicts test
|
||||||
const val unsafeBypassPermission = "ue.unsafe_all"
|
const val unsafeBypassPermission = "ue.bypass.fuse"
|
||||||
// Item Grouping Configuration file name
|
// Item Grouping Configuration file name
|
||||||
const val itemGroupingConfigName = "item_groups.yml"
|
const val itemGroupingConfigName = "item_groups.yml"
|
||||||
// Conflict Configuration file name
|
// Conflict Configuration file name
|
||||||
|
|
|
||||||
|
|
@ -12,6 +12,6 @@ permissions:
|
||||||
ue.unsafe:
|
ue.unsafe:
|
||||||
default: true
|
default: true
|
||||||
description: Allow player to combine allowed "unsafe" enchants
|
description: Allow player to combine allowed "unsafe" enchants
|
||||||
ue.unsafe_all:
|
ue.bypass.fuse:
|
||||||
default: false
|
default: false
|
||||||
description: Allow player to combine every "unsafe" enchants
|
description: Allow player to combine every "unsafe" enchants
|
||||||
Loading…
Add table
Add a link
Reference in a new issue