mirror of
https://github.com/alexcrea/CustomAnvil.git
synced 2026-06-23 16:16:17 +02:00
Do not check conflict if player can bypass & log it
This commit is contained in:
parent
c0af35fa0b
commit
36e26d762d
1 changed files with 25 additions and 16 deletions
|
|
@ -30,13 +30,15 @@ object EnchantmentUtil {
|
||||||
) = mutableMapOf<CAEnchantment, Int>().apply {
|
) = mutableMapOf<CAEnchantment, Int>().apply {
|
||||||
putAll(this@combineWith)
|
putAll(this@combineWith)
|
||||||
|
|
||||||
|
val bypassFuse = player.hasPermission(CustomAnvil.bypassFusePermission)
|
||||||
|
val bypassLevel = player.hasPermission(CustomAnvil.bypassLevelPermission)
|
||||||
|
|
||||||
other.forEach { (enchantment, level) ->
|
other.forEach { (enchantment, level) ->
|
||||||
if(!enchantment.isAllowed(player)) return@forEach
|
if(!enchantment.isAllowed(player)) return@forEach
|
||||||
|
|
||||||
// Get max level or 255 if player can bypass
|
// Get max level or 255 if player can bypass
|
||||||
val maxLevel = if (player.hasPermission(CustomAnvil.bypassLevelPermission))
|
val maxLevel = if (bypassLevel) { 255 }
|
||||||
{ 255 } else
|
else { ConfigOptions.enchantLimit(enchantment) }
|
||||||
{ ConfigOptions.enchantLimit(enchantment) }
|
|
||||||
|
|
||||||
val cappedLevel = min(level, maxLevel)
|
val cappedLevel = min(level, maxLevel)
|
||||||
|
|
||||||
|
|
@ -44,11 +46,15 @@ object EnchantmentUtil {
|
||||||
if (!containsKey(enchantment)) {
|
if (!containsKey(enchantment)) {
|
||||||
// Add the enchantment if it doesn't have conflicts, or if player is allowed to bypass enchantment restrictions
|
// Add the enchantment if it doesn't have conflicts, or if player is allowed to bypass enchantment restrictions
|
||||||
this[enchantment] = cappedLevel
|
this[enchantment] = cappedLevel
|
||||||
val conflictType =
|
if(bypassFuse){
|
||||||
ConfigHolder.CONFLICT_HOLDER.conflictManager.isConflicting(this, item, enchantment)
|
CustomAnvil.verboseLog("Bypassed conflict check for ${enchantment.key}")
|
||||||
if (!player.hasPermission(CustomAnvil.bypassFusePermission) &&
|
return@forEach
|
||||||
(conflictType != ConflictType.NO_CONFLICT)
|
}
|
||||||
) {
|
|
||||||
|
val conflictType = ConfigHolder.CONFLICT_HOLDER.conflictManager
|
||||||
|
.isConflicting(this, item, enchantment)
|
||||||
|
|
||||||
|
if (conflictType != ConflictType.NO_CONFLICT) {
|
||||||
CustomAnvil.verboseLog("Enchantment not yet in result list, but there is conflict (${enchantment.key}, conflict: $conflictType)")
|
CustomAnvil.verboseLog("Enchantment not yet in result list, but there is conflict (${enchantment.key}, conflict: $conflictType)")
|
||||||
this.remove(enchantment)
|
this.remove(enchantment)
|
||||||
}
|
}
|
||||||
|
|
@ -58,14 +64,17 @@ object EnchantmentUtil {
|
||||||
else {
|
else {
|
||||||
val oldLevel = this[enchantment]!! // <- should not be null. (enchantment already in result list)
|
val oldLevel = this[enchantment]!! // <- should not be null. (enchantment already in result list)
|
||||||
|
|
||||||
// ... and they are conflicting
|
if(bypassFuse){
|
||||||
val conflictType =
|
CustomAnvil.verboseLog("Bypassed conflict check for ${enchantment.key}")
|
||||||
ConfigHolder.CONFLICT_HOLDER.conflictManager.isConflicting(this, item, enchantment)
|
} else {
|
||||||
if ((conflictType != ConflictType.NO_CONFLICT)
|
val conflictType = ConfigHolder.CONFLICT_HOLDER.conflictManager
|
||||||
&& !player.hasPermission(CustomAnvil.bypassFusePermission)
|
.isConflicting(this, item, enchantment)
|
||||||
) {
|
|
||||||
CustomAnvil.verboseLog("Enchantment already in result list, and they are conflicting (${enchantment.key}, conflict: $conflictType)")
|
// ... and they are conflicting
|
||||||
return@forEach
|
if(conflictType != ConflictType.NO_CONFLICT){
|
||||||
|
CustomAnvil.verboseLog(
|
||||||
|
"Enchantment already in result list, and they are conflicting (${enchantment.key}, conflict: $conflictType)")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// ... and they're not the same level
|
// ... and they're not the same level
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue