Improve registry and config (#33)

Use namespace instead of name to identify enchantments
This commit is contained in:
alexcrea 2024-10-04 22:57:09 +02:00 committed by GitHub
parent a00bb919f4
commit 7029254526
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
22 changed files with 822 additions and 885 deletions

View file

@ -97,49 +97,46 @@ default_limit: 5
# #
# Valid range of 1 - 255 for each enchantment # Valid range of 1 - 255 for each enchantment
enchant_limits: enchant_limits:
aqua_affinity: 1 minecraft:aqua_affinity: 1
binding_curse: 1 minecraft:binding_curse: 1
channeling: 1 minecraft:channeling: 1
flame: 1 minecraft:flame: 1
infinity: 1 minecraft:infinity: 1
mending: 1 minecraft:mending: 1
multishot: 1 minecraft:multishot: 1
silk_touch: 1 minecraft:silk_touch: 1
vanishing_curse: 1 minecraft:vanishing_curse: 1
depth_strider: 3 # anything more than 3 is treated as 3 by the game minecraft:depth_strider: 3 # anything more than 3 is treated as 3 by the game
protection: 4 minecraft:protection: 4
fire_protection: 4 minecraft:fire_protection: 4
blast_protection: 4 minecraft:blast_protection: 4
projectile_protection: 4 minecraft:projectile_protection: 4
feather_falling: 4 minecraft:feather_falling: 4
thorns: 3 minecraft:thorns: 3
respiration: 3 minecraft:respiration: 3
sharpness: 5 minecraft:sharpness: 5
smite: 5 minecraft:smite: 5
bane_of_arthropods: 5 minecraft:bane_of_arthropods: 5
knockback: 2 minecraft:knockback: 2
fire_aspect: 2 minecraft:fire_aspect: 2
looting: 3 minecraft:looting: 3
sweeping: 3 minecraft:sweeping: 3
sweeping_edge: 3 minecraft:sweeping_edge: 3
efficiency: 5 minecraft:efficiency: 5
unbreaking: 3 minecraft:unbreaking: 3
fortune: 3 minecraft:fortune: 3
power: 5 minecraft:power: 5
punch: 2 minecraft:punch: 2
luck_of_the_sea: 3 minecraft:luck_of_the_sea: 3
lure: 3 minecraft:lure: 3
frost_walker: 2 minecraft:frost_walker: 2
impaling: 5 minecraft:impaling: 5
riptide: 3 minecraft:riptide: 3
loyalty: 3 minecraft:loyalty: 3
piercing: 4 minecraft:piercing: 4
quick_charge: 3 minecraft:quick_charge: 3
soul_speed: 3 minecraft:soul_speed: 3
swift_sneak: 3 minecraft:swift_sneak: 3
density: 5
breach: 4
wind_burst: 3
# Multipliers used to calculate the enchantment's value in repair/combining # Multipliers used to calculate the enchantment's value in repair/combining
# #
@ -153,135 +150,137 @@ enchant_limits:
# With default values protection 4 would have a value of 4 when # With default values protection 4 would have a value of 4 when
# coming from either a book (4 * 1) or an item (4 * 1) # coming from either a book (4 * 1) or an item (4 * 1)
enchant_values: enchant_values:
aqua_affinity: minecraft:aqua_affinity:
item: 4 item: 4
book: 2 book: 2
bane_of_arthropods: minecraft:bane_of_arthropods:
item: 2 item: 2
book: 1 book: 1
binding_curse: minecraft:binding_curse:
item: 8 item: 8
book: 4 book: 4
blast_protection: minecraft:blast_protection:
item: 4 item: 4
book: 2 book: 2
channeling: minecraft:channeling:
item: 8 item: 8
book: 4 book: 4
depth_strider: minecraft:depth_strider:
item: 4 item: 4
book: 2 book: 2
efficiency: minecraft:efficiency:
item: 1 item: 1
book: 1 book: 1
flame: minecraft:flame:
item: 4 item: 4
book: 2 book: 2
feather_falling: minecraft:feather_falling:
item: 2 item: 2
book: 1 book: 1
fire_aspect: minecraft:fire_aspect:
item: 4 item: 4
book: 2 book: 2
fire_protection: minecraft:fire_protection:
item: 2 item: 2
book: 1 book: 1
fortune: minecraft:fortune:
item: 4 item: 4
book: 2 book: 2
frost_walker: minecraft:frost_walker:
item: 4 item: 4
book: 2 book: 2
impaling: minecraft:impaling:
item: 4 item: 4
book: 2 book: 2
infinity: minecraft:infinity:
item: 8 item: 8
book: 4 book: 4
knockback: minecraft:knockback:
item: 2 item: 2
book: 1 book: 1
looting: minecraft:looting:
item: 4 item: 4
book: 2 book: 2
loyalty: minecraft:loyalty:
item: 1 item: 1
book: 1 book: 1
luck_of_the_sea: minecraft:luck_of_the_sea:
item: 4 item: 4
book: 2 book: 2
lure: minecraft:lure:
item: 4 item: 4
book: 2 book: 2
mending: minecraft:mending:
item: 4 item: 4
book: 2 book: 2
multishot: minecraft:multishot:
item: 4 item: 4
book: 2 book: 2
piercing: minecraft:piercing:
item: 1 item: 1
book: 1 book: 1
power: minecraft:power:
item: 1 item: 1
book: 1 book: 1
projectile_protection: minecraft:projectile_protection:
item: 2 item: 2
book: 1 book: 1
protection: minecraft:protection:
item: 1 item: 1
book: 1 book: 1
punch: minecraft:punch:
item: 4 item: 4
book: 2 book: 2
quick_charge: minecraft:quick_charge:
item: 2 item: 2
book: 1 book: 1
respiration: minecraft:respiration:
item: 4 item: 4
book: 2 book: 2
riptide: minecraft:riptide:
item: 4 item: 4
book: 2 book: 2
silk_touch: minecraft:silk_touch:
item: 8 item: 8
book: 4 book: 4
sharpness: minecraft:sharpness:
item: 1 item: 1
book: 1 book: 1
smite: minecraft:smite:
item: 2 item: 2
book: 1 book: 1
soul_speed: minecraft:soul_speed:
item: 8 item: 8
book: 4 book: 4
swift_sneak: minecraft:swift_sneak:
item: 8 item: 8
book: 4 book: 4
sweeping: minecraft:sweeping:
item: 4 item: 4
book: 2 book: 2
sweeping_edge: minecraft:sweeping_edge:
item: 4 item: 4
book: 2 book: 2
thorns: minecraft:thorns:
item: 8 item: 8
book: 4 book: 4
unbreaking: minecraft:unbreaking:
item: 2 item: 2
book: 1 book: 1
vanishing_curse: minecraft:vanishing_curse:
item: 8 item: 8
book: 4 book: 4
density:
item: 1 # Disable enchantment merging for level above the set value
book: 1 # Enchantment merging is when, for example, 2 unbreaking II book combine to give sharpness III
breach: # But Enchantment above this value can still be applied. following the previous example, we could still apply a unbreaking III book to a sword
item: 4 # Even if disable-merge-over of unbreaking is set to 2
book: 2 # -1 mean enchantment merge for this enchantment is not disabled. default to -1 if absent.
wind_burst: disable-merge-over:
item: 4 # Sharpness is set to -1. it equivalent to it not being set to anything (and work as vanilla)
book: 2 minecraft:sharpness: -1
# If uncommented. 2 unbreaking II book would not give an unbreaking III book. but unbreaking III book can still be applied
#minecraft:unbreaking: 2
# Whether to show debug logging # Whether to show debug logging
debug_log: false debug_log: false
@ -296,4 +295,3 @@ debug_log_verbose: false
force_protocolib: false force_protocolib: false
configVersion: 1.6.2 configVersion: 1.6.2
lowMinecraftVersion: '1.21'

View file

@ -17,158 +17,158 @@
# ---------------------------------------------------- # ----------------------------------------------------
restriction_aqua_affinity: restriction_aqua_affinity:
enchantments: [ aqua_affinity ] enchantments: [ minecraft:aqua_affinity ]
notAffectedGroups: [ enchanted_book, helmets ] notAffectedGroups: [ enchanted_book, helmets ]
restriction_bane_of_arthropods: restriction_bane_of_arthropods:
enchantments: [ bane_of_arthropods ] enchantments: [ minecraft:bane_of_arthropods ]
notAffectedGroups: [ enchanted_book, melee_weapons ] notAffectedGroups: [ enchanted_book, melee_weapons ]
restriction_blast_protection: restriction_blast_protection:
enchantments: [ blast_protection ] enchantments: [ minecraft:blast_protection ]
notAffectedGroups: [ enchanted_book, armors ] notAffectedGroups: [ enchanted_book, armors ]
restriction_channeling: restriction_channeling:
enchantments: [ channeling ] enchantments: [ minecraft:channeling ]
notAffectedGroups: [ enchanted_book, trident ] notAffectedGroups: [ enchanted_book, trident ]
restriction_binding_curse: restriction_binding_curse:
enchantments: [ binding_curse ] enchantments: [ minecraft:binding_curse ]
notAffectedGroups: [ enchanted_book, wearable ] notAffectedGroups: [ enchanted_book, wearable ]
restriction_vanishing_curse: restriction_vanishing_curse:
enchantments: [ vanishing_curse ] enchantments: [ minecraft:vanishing_curse ]
notAffectedGroups: [ enchanted_book, can_vanish ] notAffectedGroups: [ enchanted_book, can_vanish ]
restriction_depth_strider: restriction_depth_strider:
enchantments: [ depth_strider ] enchantments: [ minecraft:depth_strider ]
notAffectedGroups: [ enchanted_book, boots ] notAffectedGroups: [ enchanted_book, boots ]
restriction_efficiency: restriction_efficiency:
enchantments: [ efficiency ] enchantments: [ minecraft:efficiency ]
notAffectedGroups: [ enchanted_book, tools, shears ] notAffectedGroups: [ enchanted_book, tools, shears ]
restriction_feather_falling: restriction_feather_falling:
enchantments: [ feather_falling ] enchantments: [ minecraft:feather_falling ]
notAffectedGroups: [ enchanted_book, boots ] notAffectedGroups: [ enchanted_book, boots ]
restriction_fire_aspect: restriction_fire_aspect:
enchantments: [ fire_aspect ] enchantments: [ minecraft:fire_aspect ]
notAffectedGroups: [ enchanted_book, swords ] notAffectedGroups: [ enchanted_book, swords ]
restriction_fire_protection: restriction_fire_protection:
enchantments: [ fire_protection ] enchantments: [ minecraft:fire_protection ]
notAffectedGroups: [ enchanted_book, armors ] notAffectedGroups: [ enchanted_book, armors ]
restriction_flame: restriction_flame:
enchantments: [ flame ] enchantments: [ minecraft:flame ]
notAffectedGroups: [ enchanted_book, bow ] notAffectedGroups: [ enchanted_book, bow ]
restriction_fortune: restriction_fortune:
enchantments: [ fortune ] enchantments: [ minecraft:fortune ]
notAffectedGroups: [ enchanted_book, tools ] notAffectedGroups: [ enchanted_book, tools ]
restriction_frost_walker: restriction_frost_walker:
enchantments: [ frost_walker ] enchantments: [ minecraft:frost_walker ]
notAffectedGroups: [ enchanted_book, boots ] notAffectedGroups: [ enchanted_book, boots ]
restriction_impaling: restriction_impaling:
enchantments: [ impaling ] enchantments: [ minecraft:impaling ]
notAffectedGroups: [ enchanted_book, trident ] notAffectedGroups: [ enchanted_book, trident ]
restriction_infinity: restriction_infinity:
enchantments: [ infinity ] enchantments: [ minecraft:infinity ]
notAffectedGroups: [ enchanted_book, bow ] notAffectedGroups: [ enchanted_book, bow ]
restriction_knockback: restriction_knockback:
enchantments: [ knockback ] enchantments: [ minecraft:knockback ]
notAffectedGroups: [ enchanted_book, swords ] notAffectedGroups: [ enchanted_book, swords ]
restriction_looting: restriction_looting:
enchantments: [ looting ] enchantments: [ minecraft:looting ]
notAffectedGroups: [ enchanted_book, swords ] notAffectedGroups: [ enchanted_book, swords ]
restriction_loyalty: restriction_loyalty:
enchantments: [ loyalty ] enchantments: [ minecraft:loyalty ]
notAffectedGroups: [ enchanted_book, trident ] notAffectedGroups: [ enchanted_book, trident ]
restriction_lure: restriction_lure:
enchantments: [ lure ] enchantments: [ minecraft:lure ]
notAffectedGroups: [ enchanted_book, fishing_rod ] notAffectedGroups: [ enchanted_book, fishing_rod ]
restriction_mending: restriction_mending:
enchantments: [ mending ] enchantments: [ minecraft:mending ]
notAffectedGroups: [ enchanted_book, can_unbreak ] notAffectedGroups: [ enchanted_book, can_unbreak ]
restriction_multishot: restriction_minecraft_multishot:
enchantments: [ multishot ] enchantments: [ minecraft:multishot ]
notAffectedGroups: [ enchanted_book, crossbow ] notAffectedGroups: [ enchanted_book, crossbow ]
restriction_piercing: restriction_piercing:
enchantments: [ piercing ] enchantments: [ minecraft:piercing ]
notAffectedGroups: [ enchanted_book, crossbow ] notAffectedGroups: [ enchanted_book, crossbow ]
restriction_power: restriction_power:
enchantments: [ power ] enchantments: [ minecraft:power ]
notAffectedGroups: [ enchanted_book, bow ] notAffectedGroups: [ enchanted_book, bow ]
restriction_projectile_protection: restriction_projectile_protection:
enchantments: [ projectile_protection ] enchantments: [ minecraft:projectile_protection ]
notAffectedGroups: [ enchanted_book, armors ] notAffectedGroups: [ enchanted_book, armors ]
restriction_protection: restriction_protection:
enchantments: [ protection ] enchantments: [ minecraft:protection ]
notAffectedGroups: [ enchanted_book, armors ] notAffectedGroups: [ enchanted_book, armors ]
restriction_punch: restriction_punch:
enchantments: [ punch ] enchantments: [ minecraft:punch ]
notAffectedGroups: [ enchanted_book, bow ] notAffectedGroups: [ enchanted_book, bow ]
restriction_quick_charge: restriction_quick_charge:
enchantments: [ quick_charge ] enchantments: [ minecraft:quick_charge ]
notAffectedGroups: [ enchanted_book, crossbow ] notAffectedGroups: [ enchanted_book, crossbow ]
restriction_respiration: restriction_respiration:
enchantments: [ respiration ] enchantments: [ minecraft:respiration ]
notAffectedGroups: [ enchanted_book, helmets ] notAffectedGroups: [ enchanted_book, helmets ]
restriction_riptide: restriction_riptide:
enchantments: [ riptide ] enchantments: [ minecraft:riptide ]
notAffectedGroups: [ enchanted_book, trident ] notAffectedGroups: [ enchanted_book, trident ]
restriction_sharpness: restriction_sharpness:
enchantments: [ sharpness ] enchantments: [ minecraft:sharpness ]
notAffectedGroups: [ enchanted_book, melee_weapons ] notAffectedGroups: [ enchanted_book, melee_weapons ]
restriction_silk_touch: restriction__silk_touch:
enchantments: [ silk_touch ] enchantments: [ minecraft:silk_touch ]
notAffectedGroups: [ enchanted_book, tools ] notAffectedGroups: [ enchanted_book, tools ]
restriction_smite: restriction_smite:
enchantments: [ smite ] enchantments: [ minecraft:smite ]
notAffectedGroups: [ enchanted_book, melee_weapons ] notAffectedGroups: [ enchanted_book, melee_weapons ]
restriction_soul_speed: restriction_soul_speed:
enchantments: [ soul_speed ] enchantments: [ minecraft:soul_speed ]
notAffectedGroups: [ enchanted_book, boots ] notAffectedGroups: [ enchanted_book, boots ]
restriction_sweeping_edge: restriction_sweeping_edge:
enchantments: [ sweeping, sweeping_edge ] enchantments: [ minecraft:sweeping, minecraft:sweeping_edge ]
notAffectedGroups: [ enchanted_book, swords ] notAffectedGroups: [ enchanted_book, swords ]
# Do not exist in 1.18, that mean useInFuture will be set to true # Do not exist in 1.18, that mean useInFuture will be set to true
# useInFuture set to true also mean it will not warn if there is an issue # useInFuture set to true also mean it will not warn if there is an issue
restriction_swift_sneak: restriction_swift_sneak:
useInFuture: true useInFuture: true
enchantments: [ swift_sneak ] enchantments: [ minecraft:swift_sneak ]
notAffectedGroups: [ enchanted_book, leggings ] notAffectedGroups: [ enchanted_book, leggings ]
restriction_thorns: restriction_thorns:
enchantments: [ thorns ] enchantments: [ minecraft:thorns ]
notAffectedGroups: [ enchanted_book, armors ] notAffectedGroups: [ enchanted_book, armors ]
restriction_unbreaking: restriction__unbreaking:
enchantments: [ unbreaking ] enchantments: [ minecraft:unbreaking ]
notAffectedGroups: [ enchanted_book, can_unbreak ] notAffectedGroups: [ enchanted_book, can_unbreak ]
# ---------------------------------------------------- # ----------------------------------------------------
@ -180,60 +180,60 @@ restriction_unbreaking:
sword_enchant_conflict: sword_enchant_conflict:
enchantments: enchantments:
- bane_of_arthropods - minecraft:bane_of_arthropods
- smite - minecraft:smite
- sharpness - minecraft:sharpness
notAffectedGroups: [ ] notAffectedGroups: [ ]
maxEnchantmentBeforeConflict: 1 maxEnchantmentBeforeConflict: 1
protection_enchant_conflict: protection_enchant_conflict:
enchantments: enchantments:
- blast_protection - minecraft:blast_protection
- fire_protection - minecraft:fire_protection
- projectile_protection - minecraft:projectile_protection
- protection - minecraft:protection
notAffectedGroups: [ ] notAffectedGroups: [ ]
maxEnchantmentBeforeConflict: 1 maxEnchantmentBeforeConflict: 1
trident_conflict1: trident_conflict1:
enchantments: enchantments:
- channeling - minecraft:channeling
- riptide - minecraft:riptide
notAffectedGroups: [ ] notAffectedGroups: [ ]
maxEnchantmentBeforeConflict: 1 maxEnchantmentBeforeConflict: 1
trident_conflict2: trident_conflict2:
enchantments: enchantments:
- loyalty - minecraft:loyalty
- riptide - minecraft:riptide
notAffectedGroups: [ ] notAffectedGroups: [ ]
maxEnchantmentBeforeConflict: 1 maxEnchantmentBeforeConflict: 1
boot_conflict: boot_conflict:
enchantments: enchantments:
- depth_strider - minecraft:depth_strider
- frost_walker - minecraft:frost_walker
notAffectedGroups: [ ] notAffectedGroups: [ ]
maxEnchantmentBeforeConflict: 1 maxEnchantmentBeforeConflict: 1
tool_conflict: tool_conflict:
enchantments: enchantments:
- fortune - minecraft:fortune
- silk_touch - minecraft:silk_touch
notAffectedGroups: [ ] notAffectedGroups: [ ]
maxEnchantmentBeforeConflict: 1 maxEnchantmentBeforeConflict: 1
bow_conflict: bow_conflict:
enchantments: enchantments:
- mending - minecraft:mending
- infinity - minecraft:infinity
notAffectedGroups: [ ] notAffectedGroups: [ ]
maxEnchantmentBeforeConflict: 1 maxEnchantmentBeforeConflict: 1
crossbow_conflict: crossbow_conflict:
enchantments: enchantments:
- multishot - minecraft:multishot
- piercing - minecraft:piercing
notAffectedGroups: [ ] notAffectedGroups: [ ]
maxEnchantmentBeforeConflict: 1 maxEnchantmentBeforeConflict: 1

View file

@ -97,49 +97,46 @@ default_limit: 5
# #
# Valid range of 1 - 255 for each enchantment # Valid range of 1 - 255 for each enchantment
enchant_limits: enchant_limits:
aqua_affinity: 1 minecraft:aqua_affinity: 1
binding_curse: 1 minecraft:binding_curse: 1
channeling: 1 minecraft:channeling: 1
flame: 1 minecraft:flame: 1
infinity: 1 minecraft:infinity: 1
mending: 1 minecraft:mending: 1
multishot: 1 minecraft:multishot: 1
silk_touch: 1 minecraft:silk_touch: 1
vanishing_curse: 1 minecraft:vanishing_curse: 1
depth_strider: 3 # anything more than 3 is treated as 3 by the game minecraft:depth_strider: 3 # anything more than 3 is treated as 3 by the game
protection: 4 minecraft:protection: 4
fire_protection: 4 minecraft:fire_protection: 4
blast_protection: 4 minecraft:blast_protection: 4
projectile_protection: 4 minecraft:projectile_protection: 4
feather_falling: 4 minecraft:feather_falling: 4
thorns: 3 minecraft:thorns: 3
respiration: 3 minecraft:respiration: 3
sharpness: 5 minecraft:sharpness: 5
smite: 5 minecraft:smite: 5
bane_of_arthropods: 5 minecraft:bane_of_arthropods: 5
knockback: 2 minecraft:knockback: 2
fire_aspect: 2 minecraft:fire_aspect: 2
looting: 3 minecraft:looting: 3
sweeping: 3 minecraft:sweeping: 3
sweeping_edge: 3 minecraft:sweeping_edge: 3
efficiency: 5 minecraft:efficiency: 5
unbreaking: 3 minecraft:unbreaking: 3
fortune: 3 minecraft:fortune: 3
power: 5 minecraft:power: 5
punch: 2 minecraft:punch: 2
luck_of_the_sea: 3 minecraft:luck_of_the_sea: 3
lure: 3 minecraft:lure: 3
frost_walker: 2 minecraft:frost_walker: 2
impaling: 5 minecraft:impaling: 5
riptide: 3 minecraft:riptide: 3
loyalty: 3 minecraft:loyalty: 3
piercing: 4 minecraft:piercing: 4
quick_charge: 3 minecraft:quick_charge: 3
soul_speed: 3 minecraft:soul_speed: 3
swift_sneak: 3 minecraft:swift_sneak: 3
density: 5
breach: 4
wind_burst: 3
# Multipliers used to calculate the enchantment's value in repair/combining # Multipliers used to calculate the enchantment's value in repair/combining
# #
@ -153,135 +150,137 @@ enchant_limits:
# With default values protection 4 would have a value of 4 when # With default values protection 4 would have a value of 4 when
# coming from either a book (4 * 1) or an item (4 * 1) # coming from either a book (4 * 1) or an item (4 * 1)
enchant_values: enchant_values:
aqua_affinity: minecraft:aqua_affinity:
item: 4 item: 4
book: 2 book: 2
bane_of_arthropods: minecraft:bane_of_arthropods:
item: 2 item: 2
book: 1 book: 1
binding_curse: minecraft:binding_curse:
item: 8 item: 8
book: 4 book: 4
blast_protection: minecraft:blast_protection:
item: 4 item: 4
book: 2 book: 2
channeling: minecraft:channeling:
item: 8 item: 8
book: 4 book: 4
depth_strider: minecraft:depth_strider:
item: 4 item: 4
book: 2 book: 2
efficiency: minecraft:efficiency:
item: 1 item: 1
book: 1 book: 1
flame: minecraft:flame:
item: 4 item: 4
book: 2 book: 2
feather_falling: minecraft:feather_falling:
item: 2 item: 2
book: 1 book: 1
fire_aspect: minecraft:fire_aspect:
item: 4 item: 4
book: 2 book: 2
fire_protection: minecraft:fire_protection:
item: 2 item: 2
book: 1 book: 1
fortune: minecraft:fortune:
item: 4 item: 4
book: 2 book: 2
frost_walker: minecraft:frost_walker:
item: 4 item: 4
book: 2 book: 2
impaling: minecraft:impaling:
item: 4 item: 4
book: 2 book: 2
infinity: minecraft:infinity:
item: 8 item: 8
book: 4 book: 4
knockback: minecraft:knockback:
item: 2 item: 2
book: 1 book: 1
looting: minecraft:looting:
item: 4 item: 4
book: 2 book: 2
loyalty: minecraft:loyalty:
item: 1 item: 1
book: 1 book: 1
luck_of_the_sea: minecraft:luck_of_the_sea:
item: 4 item: 4
book: 2 book: 2
lure: minecraft:lure:
item: 4 item: 4
book: 2 book: 2
mending: minecraft:mending:
item: 4 item: 4
book: 2 book: 2
multishot: minecraft:multishot:
item: 4 item: 4
book: 2 book: 2
piercing: minecraft:piercing:
item: 1 item: 1
book: 1 book: 1
power: minecraft:power:
item: 1 item: 1
book: 1 book: 1
projectile_protection: minecraft:projectile_protection:
item: 2 item: 2
book: 1 book: 1
protection: minecraft:protection:
item: 1 item: 1
book: 1 book: 1
punch: minecraft:punch:
item: 4 item: 4
book: 2 book: 2
quick_charge: minecraft:quick_charge:
item: 2 item: 2
book: 1 book: 1
respiration: minecraft:respiration:
item: 4 item: 4
book: 2 book: 2
riptide: minecraft:riptide:
item: 4 item: 4
book: 2 book: 2
silk_touch: minecraft:silk_touch:
item: 8 item: 8
book: 4 book: 4
sharpness: minecraft:sharpness:
item: 1 item: 1
book: 1 book: 1
smite: minecraft:smite:
item: 2 item: 2
book: 1 book: 1
soul_speed: minecraft:soul_speed:
item: 8 item: 8
book: 4 book: 4
swift_sneak: minecraft:swift_sneak:
item: 8 item: 8
book: 4 book: 4
sweeping: minecraft:sweeping:
item: 4 item: 4
book: 2 book: 2
sweeping_edge: minecraft:sweeping_edge:
item: 4 item: 4
book: 2 book: 2
thorns: minecraft:thorns:
item: 8 item: 8
book: 4 book: 4
unbreaking: minecraft:unbreaking:
item: 2 item: 2
book: 1 book: 1
vanishing_curse: minecraft:vanishing_curse:
item: 8 item: 8
book: 4 book: 4
density:
item: 1 # Disable enchantment merging for level above the set value
book: 1 # Enchantment merging is when, for example, 2 unbreaking II book combine to give sharpness III
breach: # But Enchantment above this value can still be applied. following the previous example, we could still apply a unbreaking III book to a sword
item: 4 # Even if disable-merge-over of unbreaking is set to 2
book: 2 # -1 mean enchantment merge for this enchantment is not disabled. default to -1 if absent.
wind_burst: disable-merge-over:
item: 4 # Sharpness is set to -1. it equivalent to it not being set to anything (and work as vanilla)
book: 2 minecraft:sharpness: -1
# If uncommented. 2 unbreaking II book would not give an unbreaking III book. but unbreaking III book can still be applied
#minecraft:unbreaking: 2
# Whether to show debug logging # Whether to show debug logging
debug_log: false debug_log: false
@ -296,4 +295,3 @@ debug_log_verbose: false
force_protocolib: false force_protocolib: false
configVersion: 1.6.2 configVersion: 1.6.2
lowMinecraftVersion: '1.21'

View file

@ -17,278 +17,159 @@
# ---------------------------------------------------- # ----------------------------------------------------
restriction_aqua_affinity: restriction_aqua_affinity:
enchantments: enchantments: [ minecraft:aqua_affinity ]
- aqua_affinity notAffectedGroups: [ enchanted_book, helmets ]
notAffectedGroups:
- enchanted_book
- helmets
restriction_bane_of_arthropods: restriction_bane_of_arthropods:
enchantments: enchantments: [ minecraft:bane_of_arthropods ]
- bane_of_arthropods notAffectedGroups: [ enchanted_book, melee_weapons ]
notAffectedGroups:
- enchanted_book
- melee_weapons
- mace
restriction_blast_protection: restriction_blast_protection:
enchantments: enchantments: [ minecraft:blast_protection ]
- blast_protection notAffectedGroups: [ enchanted_book, armors ]
notAffectedGroups:
- enchanted_book
- armors
restriction_channeling: restriction_channeling:
enchantments: enchantments: [ minecraft:channeling ]
- channeling notAffectedGroups: [ enchanted_book, trident ]
notAffectedGroups:
- enchanted_book
- trident
restriction_binding_curse: restriction_binding_curse:
enchantments: enchantments: [ minecraft:binding_curse ]
- binding_curse notAffectedGroups: [ enchanted_book, wearable ]
notAffectedGroups:
- enchanted_book
- wearable
restriction_vanishing_curse: restriction_vanishing_curse:
enchantments: enchantments: [ minecraft:vanishing_curse ]
- vanishing_curse notAffectedGroups: [ enchanted_book, can_vanish ]
notAffectedGroups:
- enchanted_book
- can_vanish
restriction_depth_strider: restriction_depth_strider:
enchantments: enchantments: [ minecraft:depth_strider ]
- depth_strider notAffectedGroups: [ enchanted_book, boots ]
notAffectedGroups:
- enchanted_book
- boots
restriction_efficiency: restriction_efficiency:
enchantments: enchantments: [ minecraft:efficiency ]
- efficiency notAffectedGroups: [ enchanted_book, tools, shears ]
notAffectedGroups:
- enchanted_book
- tools
- shears
restriction_feather_falling: restriction_feather_falling:
enchantments: enchantments: [ minecraft:feather_falling ]
- feather_falling notAffectedGroups: [ enchanted_book, boots ]
notAffectedGroups:
- enchanted_book
- boots
restriction_fire_aspect: restriction_fire_aspect:
enchantments: enchantments: [ minecraft:fire_aspect ]
- fire_aspect notAffectedGroups: [ enchanted_book, swords ]
notAffectedGroups:
- enchanted_book
- swords
- mace
restriction_fire_protection: restriction_fire_protection:
enchantments: enchantments: [ minecraft:fire_protection ]
- fire_protection notAffectedGroups: [ enchanted_book, armors ]
notAffectedGroups:
- enchanted_book
- armors
restriction_flame: restriction_flame:
enchantments: enchantments: [ minecraft:flame ]
- flame notAffectedGroups: [ enchanted_book, bow ]
notAffectedGroups:
- enchanted_book
- bow
restriction_fortune: restriction_fortune:
enchantments: enchantments: [ minecraft:fortune ]
- fortune notAffectedGroups: [ enchanted_book, tools ]
notAffectedGroups:
- enchanted_book
- tools
restriction_frost_walker: restriction_frost_walker:
enchantments: enchantments: [ minecraft:frost_walker ]
- frost_walker notAffectedGroups: [ enchanted_book, boots ]
notAffectedGroups:
- enchanted_book
- boots
restriction_impaling: restriction_impaling:
enchantments: enchantments: [ minecraft:impaling ]
- impaling notAffectedGroups: [ enchanted_book, trident ]
notAffectedGroups:
- enchanted_book
- trident
restriction_infinity: restriction_infinity:
enchantments: enchantments: [ minecraft:infinity ]
- infinity notAffectedGroups: [ enchanted_book, bow ]
notAffectedGroups:
- enchanted_book
- bow
restriction_knockback: restriction_knockback:
enchantments: enchantments: [ minecraft:knockback ]
- knockback notAffectedGroups: [ enchanted_book, swords ]
notAffectedGroups:
- enchanted_book
- swords
restriction_looting: restriction_looting:
enchantments: enchantments: [ minecraft:looting ]
- looting notAffectedGroups: [ enchanted_book, swords ]
notAffectedGroups:
- enchanted_book
- swords
restriction_loyalty: restriction_loyalty:
enchantments: enchantments: [ minecraft:loyalty ]
- loyalty notAffectedGroups: [ enchanted_book, trident ]
notAffectedGroups:
- enchanted_book
- trident
restriction_lure: restriction_lure:
enchantments: enchantments: [ minecraft:lure ]
- lure notAffectedGroups: [ enchanted_book, fishing_rod ]
notAffectedGroups:
- enchanted_book
- fishing_rod
restriction_mending: restriction_mending:
enchantments: enchantments: [ minecraft:mending ]
- mending notAffectedGroups: [ enchanted_book, can_unbreak ]
notAffectedGroups:
- enchanted_book
- can_unbreak
restriction_multishot: restriction_minecraft_multishot:
enchantments: enchantments: [ minecraft:multishot ]
- multishot notAffectedGroups: [ enchanted_book, crossbow ]
notAffectedGroups:
- enchanted_book
- crossbow
restriction_piercing: restriction_piercing:
enchantments: enchantments: [ minecraft:piercing ]
- piercing notAffectedGroups: [ enchanted_book, crossbow ]
notAffectedGroups:
- enchanted_book
- crossbow
restriction_power: restriction_power:
enchantments: enchantments: [ minecraft:power ]
- power notAffectedGroups: [ enchanted_book, bow ]
notAffectedGroups:
- enchanted_book
- bow
restriction_projectile_protection: restriction_projectile_protection:
enchantments: enchantments: [ minecraft:projectile_protection ]
- projectile_protection notAffectedGroups: [ enchanted_book, armors ]
notAffectedGroups:
- enchanted_book
- armors
restriction_protection: restriction_protection:
enchantments: enchantments: [ minecraft:protection ]
- protection notAffectedGroups: [ enchanted_book, armors ]
notAffectedGroups:
- enchanted_book
- armors
restriction_punch: restriction_punch:
enchantments: enchantments: [ minecraft:punch ]
- punch notAffectedGroups: [ enchanted_book, bow ]
notAffectedGroups:
- enchanted_book
- bow
restriction_quick_charge: restriction_quick_charge:
enchantments: enchantments: [ minecraft:quick_charge ]
- quick_charge notAffectedGroups: [ enchanted_book, crossbow ]
notAffectedGroups:
- enchanted_book
- crossbow
restriction_respiration: restriction_respiration:
enchantments: enchantments: [ minecraft:respiration ]
- respiration notAffectedGroups: [ enchanted_book, helmets ]
notAffectedGroups:
- enchanted_book
- helmets
restriction_riptide: restriction_riptide:
enchantments: enchantments: [ minecraft:riptide ]
- riptide notAffectedGroups: [ enchanted_book, trident ]
notAffectedGroups:
- enchanted_book
- trident
restriction_sharpness: restriction_sharpness:
enchantments: enchantments: [ minecraft:sharpness ]
- sharpness notAffectedGroups: [ enchanted_book, melee_weapons ]
notAffectedGroups:
- enchanted_book
- melee_weapons
restriction_silk_touch: restriction__silk_touch:
enchantments: enchantments: [ minecraft:silk_touch ]
- silk_touch notAffectedGroups: [ enchanted_book, tools ]
notAffectedGroups:
- enchanted_book
- tools
restriction_smite: restriction_smite:
enchantments: enchantments: [ minecraft:smite ]
- smite notAffectedGroups: [ enchanted_book, melee_weapons ]
notAffectedGroups:
- enchanted_book
- melee_weapons
- mace
restriction_soul_speed: restriction_soul_speed:
enchantments: enchantments: [ minecraft:soul_speed ]
- soul_speed notAffectedGroups: [ enchanted_book, boots ]
notAffectedGroups:
- enchanted_book
- boots
restriction_sweeping_edge: restriction_sweeping_edge:
enchantments: enchantments: [ minecraft:sweeping, minecraft:sweeping_edge ]
- sweeping notAffectedGroups: [ enchanted_book, swords ]
- sweeping_edge
notAffectedGroups:
- enchanted_book
- swords
# Do not exist in 1.18, that mean useInFuture will be set to true # Do not exist in 1.18, that mean useInFuture will be set to true
# useInFuture set to true also mean it will not warn if there is an issue # useInFuture set to true also mean it will not warn if there is an issue
restriction_swift_sneak: restriction_swift_sneak:
useInFuture: true useInFuture: true
enchantments: enchantments: [ minecraft:swift_sneak ]
- swift_sneak notAffectedGroups: [ enchanted_book, leggings ]
notAffectedGroups:
- enchanted_book
- leggings
restriction_thorns: restriction_thorns:
enchantments: enchantments: [ minecraft:thorns ]
- thorns notAffectedGroups: [ enchanted_book, armors ]
notAffectedGroups:
- enchanted_book
- armors
restriction_unbreaking: restriction__unbreaking:
enchantments: enchantments: [ minecraft:unbreaking ]
- unbreaking notAffectedGroups: [ enchanted_book, can_unbreak ]
notAffectedGroups:
- enchanted_book
- can_unbreak
# ---------------------------------------------------- # ----------------------------------------------------
# Now we have conflicts about enchantment Incompatibility # Now we have conflicts about enchantment Incompatibility
@ -299,87 +180,62 @@ restriction_unbreaking:
sword_enchant_conflict: sword_enchant_conflict:
enchantments: enchantments:
- bane_of_arthropods - minecraft:bane_of_arthropods
- smite - minecraft:smite
- sharpness - minecraft:sharpness
notAffectedGroups: [ ] notAffectedGroups: [ ]
maxEnchantmentBeforeConflict: 1 maxEnchantmentBeforeConflict: 1
protection_enchant_conflict: protection_enchant_conflict:
enchantments: enchantments:
- blast_protection - minecraft:blast_protection
- fire_protection - minecraft:fire_protection
- projectile_protection - minecraft:projectile_protection
- protection - minecraft:protection
notAffectedGroups: [ ] notAffectedGroups: [ ]
maxEnchantmentBeforeConflict: 1 maxEnchantmentBeforeConflict: 1
trident_conflict1: trident_conflict1:
enchantments: enchantments:
- channeling - minecraft:channeling
- riptide - minecraft:riptide
notAffectedGroups: [ ] notAffectedGroups: [ ]
maxEnchantmentBeforeConflict: 1 maxEnchantmentBeforeConflict: 1
trident_conflict2: trident_conflict2:
enchantments: enchantments:
- loyalty - minecraft:loyalty
- riptide - minecraft:riptide
notAffectedGroups: [ ] notAffectedGroups: [ ]
maxEnchantmentBeforeConflict: 1 maxEnchantmentBeforeConflict: 1
boot_conflict: boot_conflict:
enchantments: enchantments:
- depth_strider - minecraft:depth_strider
- frost_walker - minecraft:frost_walker
notAffectedGroups: [ ] notAffectedGroups: [ ]
maxEnchantmentBeforeConflict: 1 maxEnchantmentBeforeConflict: 1
tool_conflict: tool_conflict:
enchantments: enchantments:
- fortune - minecraft:fortune
- silk_touch - minecraft:silk_touch
notAffectedGroups: [ ] notAffectedGroups: [ ]
maxEnchantmentBeforeConflict: 1 maxEnchantmentBeforeConflict: 1
bow_conflict: bow_conflict:
enchantments: enchantments:
- mending - minecraft:mending
- infinity - minecraft:infinity
notAffectedGroups: [ ] notAffectedGroups: [ ]
maxEnchantmentBeforeConflict: 1 maxEnchantmentBeforeConflict: 1
crossbow_conflict: crossbow_conflict:
enchantments: enchantments:
- multishot - minecraft:multishot
- piercing - minecraft:piercing
notAffectedGroups: [ ] notAffectedGroups: [ ]
maxEnchantmentBeforeConflict: 1 maxEnchantmentBeforeConflict: 1
restriction_density:
enchantments:
- density
notAffectedGroups:
- mace
- enchanted_book
restriction_breach:
enchantments:
- breach
notAffectedGroups:
- mace
- enchanted_book
restriction_wind_burst:
enchantments:
- wind_burst
notAffectedGroups:
- mace
- enchanted_book
mace_enchant_conflict:
enchantments:
- density
- breach
- smite
- bane_of_arthropods
maxEnchantmentBeforeConflict: 1
# ---------------------------------------------------- # ----------------------------------------------------
# Bellow is for custom conflicts. # Bellow is for custom conflicts.

View file

@ -121,6 +121,7 @@ wearable:
- player_head - player_head
- creeper_head - creeper_head
- dragon_head - dragon_head
# do not exist in 1.18 but exist in future update
- piglin_head - piglin_head
groups: groups:
- armors - armors
@ -187,6 +188,7 @@ can_unbreak:
- shield - shield
- carrot_on_a_stick - carrot_on_a_stick
- warped_fungus_on_a_stick - warped_fungus_on_a_stick
# do not exist in 1.18 but exist in future update
- brush - brush
groups: groups:
- melee_weapons - melee_weapons
@ -197,7 +199,6 @@ can_unbreak:
- crossbow - crossbow
- fishing_rod - fishing_rod
- shears - shears
- mace
can_vanish: can_vanish:
type: include type: include
@ -206,8 +207,4 @@ can_vanish:
groups: groups:
- wearable - wearable
- can_unbreak - can_unbreak
mace:
type: include
items:
- mace

View file

@ -188,5 +188,3 @@ warped_planks:
wooden_shovel: 0.25 wooden_shovel: 0.25
wooden_hoe: 0.25 wooden_hoe: 0.25
shield: 0.25 shield: 0.25
breeze_rod:
mace: 0.25

View file

@ -119,7 +119,7 @@ public class ConflictAPI {
private static List<String> extractEnchantments(@NotNull ConflictBuilder builder){ private static List<String> extractEnchantments(@NotNull ConflictBuilder builder){
List<String> result = new ArrayList<>(builder.getEnchantmentNames()); List<String> result = new ArrayList<>(builder.getEnchantmentNames());
for (NamespacedKey enchantmentKey : builder.getEnchantmentKeys()) { for (NamespacedKey enchantmentKey : builder.getEnchantmentKeys()) {
result.add(enchantmentKey.getKey()); result.add(enchantmentKey.toString());
} }
return result; return result;

View file

@ -10,6 +10,7 @@ import xyz.alexcrea.cuanvil.enchant.CAEnchantment;
import xyz.alexcrea.cuanvil.group.*; import xyz.alexcrea.cuanvil.group.*;
import java.util.HashSet; import java.util.HashSet;
import java.util.List;
import java.util.Set; import java.util.Set;
/** /**
@ -372,7 +373,7 @@ public class ConflictBuilder {
*/ */
protected void appendEnchantments(@NotNull EnchantConflictGroup conflict){ protected void appendEnchantments(@NotNull EnchantConflictGroup conflict){
for (String enchantmentName : getEnchantmentNames()){ for (String enchantmentName : getEnchantmentNames()){
if(appendEnchantment(conflict, EnchantmentApi.getByName(enchantmentName))){ if(appendEnchantments(conflict, EnchantmentApi.getListByName(enchantmentName)) == 0){
CustomAnvil.instance.getLogger().warning("Could not find enchantment " + enchantmentName + " for conflict " + getName()); CustomAnvil.instance.getLogger().warning("Could not find enchantment " + enchantmentName + " for conflict " + getName());
ConflictAPI.logConflictOrigin(this); ConflictAPI.logConflictOrigin(this);
} }
@ -399,6 +400,24 @@ public class ConflictBuilder {
return true; return true;
} }
/**
* Append a list of enchantments.
*
* @param conflict The conflict target
* @param enchantments List of enchantment to add
* @return Number of enchantment added
*/
protected static int appendEnchantments(@NotNull EnchantConflictGroup conflict, @NotNull List<CAEnchantment> enchantments){
int numberValid = 0;
for (CAEnchantment enchantment : enchantments) {
if(appendEnchantment(conflict, enchantment)){
numberValid++;
}
}
return numberValid;
}
/** /**
* Extract group abstract material group. * Extract group abstract material group.
* *

View file

@ -18,6 +18,7 @@ import xyz.alexcrea.cuanvil.gui.config.global.EnchantCostConfigGui;
import xyz.alexcrea.cuanvil.gui.config.global.EnchantLimitConfigGui; import xyz.alexcrea.cuanvil.gui.config.global.EnchantLimitConfigGui;
import java.util.Collections; import java.util.Collections;
import java.util.List;
import java.util.Map; import java.util.Map;
/** /**
@ -104,7 +105,7 @@ public class EnchantmentApi {
* @return True if successful. * @return True if successful.
*/ */
public static boolean unregisterEnchantment(@NotNull NamespacedKey key){ public static boolean unregisterEnchantment(@NotNull NamespacedKey key){
CAEnchantment enchantment = CAEnchantmentRegistry.getInstance().getByKey(key); CAEnchantment enchantment = CAEnchantment.getByKey(key);
return unregisterEnchantment(enchantment); return unregisterEnchantment(enchantment);
} }
@ -126,7 +127,7 @@ public class EnchantmentApi {
*/ */
@Nullable @Nullable
public static CAEnchantment getByKey(@NotNull NamespacedKey key){ public static CAEnchantment getByKey(@NotNull NamespacedKey key){
return CAEnchantmentRegistry.getInstance().getByKey(key); return CAEnchantment.getByKey(key);
} }
/** /**
@ -134,10 +135,22 @@ public class EnchantmentApi {
* *
* @param name The name used to fetch * @param name The name used to fetch
* @return The custom anvil enchantment of this name. null if not found. * @return The custom anvil enchantment of this name. null if not found.
* @deprecated use {@link #getListByName(String)}
*/ */
@Deprecated(since = "1.6.3")
@Nullable @Nullable
public static CAEnchantment getByName(@NotNull String name){ public static CAEnchantment getByName(@NotNull String name){
return CAEnchantmentRegistry.getInstance().getByName(name); return CAEnchantment.getByName(name);
}
/**
* Get list of enchantment using the provided name.
*
* @param name The name used to fetch
* @return List of custom anvil enchantments of this name. May be empty if not found.
*/
public static List<CAEnchantment> getListByName(@NotNull String name){
return CAEnchantment.getListByName(name);
} }
/** /**
@ -167,9 +180,9 @@ public class EnchantmentApi {
private static void writeDefaultConfig(FileConfiguration defaultConfig, CAEnchantment enchantment) { private static void writeDefaultConfig(FileConfiguration defaultConfig, CAEnchantment enchantment) {
defaultConfig.set("enchant_limits." + enchantment.getKey().getKey(), enchantment.defaultMaxLevel()); defaultConfig.set("enchant_limits." + enchantment.getKey(), enchantment.defaultMaxLevel());
String basePath = "enchant_values." + enchantment.getKey().getKey(); String basePath = "enchant_values." + enchantment.getKey();
EnchantmentRarity rarity = enchantment.defaultRarity(); EnchantmentRarity rarity = enchantment.defaultRarity();
defaultConfig.set(basePath + ".item", rarity.getItemValue()); defaultConfig.set(basePath + ".item", rarity.getItemValue());

View file

@ -12,6 +12,7 @@ import xyz.alexcrea.cuanvil.group.EnchantConflictGroup;
import java.util.Collection; import java.util.Collection;
import java.util.HashMap; import java.util.HashMap;
import java.util.List;
import java.util.Map; import java.util.Map;
/** /**
@ -226,12 +227,24 @@ public interface CAEnchantment {
} }
/** /**
* Gets a list of all the unoptimised enchantments. * Gets the enchantment by the provided name.
* @param name The enchantment name * @param name Name to fetch.
* @return List of enchantment. * @return Registered enchantment. null if absent.
*
* @deprecated use {@link #getListByName(String)}
*/ */
@Deprecated(since = "1.6.3")
static @Nullable CAEnchantment getByName(@NotNull String name){ static @Nullable CAEnchantment getByName(@NotNull String name){
return CAEnchantmentRegistry.getInstance().getByName(name); return CAEnchantmentRegistry.getInstance().getByName(name);
} }
/**
* Gets list of enchantment using the provided name.
* @param name Name to fetch.
* @return List of registered enchantment.
*/
static List<CAEnchantment> getListByName(@NotNull String name){
return CAEnchantmentRegistry.getInstance().getListByName(name);
}
} }

View file

@ -22,7 +22,7 @@ public class CAEnchantmentRegistry {
// Register enchantment functions // Register enchantment functions
private final HashMap<NamespacedKey, CAEnchantment> byKeyMap; private final HashMap<NamespacedKey, CAEnchantment> byKeyMap;
private final HashMap<String, CAEnchantment> byNameMap; private final HashMap<String, List<CAEnchantment>> byNameMap;
private final SortedSet<CAEnchantment> nameSortedEnchantments; private final SortedSet<CAEnchantment> nameSortedEnchantments;
@ -62,6 +62,8 @@ public class CAEnchantmentRegistry {
} }
private static boolean hasWarnedRegistering = false;
/** /**
* Can be used to register new enchantment. * Can be used to register new enchantment.
* <p> * <p>
@ -73,19 +75,25 @@ public class CAEnchantmentRegistry {
public boolean register(@NotNull CAEnchantment enchantment){ public boolean register(@NotNull CAEnchantment enchantment){
if(byKeyMap.containsKey(enchantment.getKey())){ if(byKeyMap.containsKey(enchantment.getKey())){
CustomAnvil.instance.getLogger().log(Level.WARNING, CustomAnvil.instance.getLogger().log(Level.WARNING,
"Duplicate registered enchantment. This should NOT happen.", "Duplicate registered enchantment. This should NOT happen any time.\n" +
"If you are a custom anvil developer. You maybe custom anvil detected your enchantment as a bukkit enchantment. " +
"maybe remove enchantment with the same key before registering yours",
new IllegalStateException(enchantment.getKey()+" enchantment was already registered")); new IllegalStateException(enchantment.getKey()+" enchantment was already registered"));
return false; return false;
} }
if(byNameMap.containsKey(enchantment.getName())){
if((!hasWarnedRegistering) && byNameMap.containsKey(enchantment.getName())){
hasWarnedRegistering = true;
CustomAnvil.instance.getLogger().log(Level.WARNING, CustomAnvil.instance.getLogger().log(Level.WARNING,
"Duplicate registered enchantment name. There will have issue. " + "Duplicate registered enchantment name. Please check that configuration is using namespace.");
"\nI hope this do not happen to you on a production server. If it do, there is probably a plugin trying to register an enchantment with the same name than another one",
new IllegalStateException(enchantment.getKey()+" enchantment name was already registered"));
} }
byKeyMap.put(enchantment.getKey(), enchantment); byKeyMap.put(enchantment.getKey(), enchantment);
byNameMap.put(enchantment.getName(), enchantment);
byNameMap.putIfAbsent(enchantment.getName(), new ArrayList<>());
byNameMap.get(enchantment.getName()).add(enchantment);
nameSortedEnchantments.add(enchantment); nameSortedEnchantments.add(enchantment);
if(!enchantment.isGetOptimised()){ if(!enchantment.isGetOptimised()){
@ -112,7 +120,7 @@ public class CAEnchantmentRegistry {
public boolean unregister(@Nullable CAEnchantment enchantment){ public boolean unregister(@Nullable CAEnchantment enchantment){
if(enchantment == null) return false; if(enchantment == null) return false;
byKeyMap.remove(enchantment.getKey()); byKeyMap.remove(enchantment.getKey());
byNameMap.remove(enchantment.getName()); byNameMap.get(enchantment.getName()).remove(enchantment);
nameSortedEnchantments.remove(enchantment); nameSortedEnchantments.remove(enchantment);
@ -135,10 +143,26 @@ public class CAEnchantmentRegistry {
* Gets the enchantment by the provided name. * Gets the enchantment by the provided name.
* @param name Name to fetch. * @param name Name to fetch.
* @return Registered enchantment. null if absent. * @return Registered enchantment. null if absent.
*
* @deprecated use {@link #getListByName(String)}
*/ */
@Deprecated(since = "1.6.3")
@Nullable @Nullable
public CAEnchantment getByName(@NotNull String name){ public CAEnchantment getByName(@NotNull String name){
return byNameMap.get(name); List<CAEnchantment> enchantments = getListByName(name);
if(enchantments.isEmpty()) return null;
return enchantments.get(0);
}
/**
* Gets list of enchantment using the provided name.
* @param name Name to fetch.
* @return List of registered enchantment.
*/
@NotNull
public List<CAEnchantment> getListByName(@NotNull String name){
return byNameMap.getOrDefault(name, Collections.emptyList());
} }
/** /**

View file

@ -44,24 +44,16 @@ public class EnchantCostConfigGui extends AbstractEnchantConfigGui<EnchantCostSe
@Override @Override
public EnchantCostSettingsGui.EnchantCostSettingFactory createFactory(CAEnchantment enchant) { public EnchantCostSettingsGui.EnchantCostSettingFactory createFactory(CAEnchantment enchant) {
String key = enchant.getKey().getKey().toLowerCase(Locale.ENGLISH); String key = enchant.getKey().toString().toLowerCase(Locale.ENGLISH);
String prettyKey = CasedStringUtil.snakeToUpperSpacedCase(key); String prettyKey = CasedStringUtil.snakeToUpperSpacedCase(key.replace(":", "_"));
// try to find rarity. default to 0 if not found return new EnchantCostSettingsGui.EnchantCostSettingFactory(prettyKey + " Cost", this,
EnchantmentRarity rarity = enchant.defaultRarity(); SECTION_NAME + '.' + key, ConfigHolder.DEFAULT_CONFIG,
try {
rarity = EnchantmentProperties.valueOf(key.toUpperCase(Locale.ENGLISH)).getRarity();
} catch (IllegalArgumentException ignored) {
}
return EnchantCostSettingsGui.enchantCostFactory(prettyKey + " Level Cost", this,
ConfigHolder.DEFAULT_CONFIG, SECTION_NAME + '.' + key,
Arrays.asList( Arrays.asList(
"§7How many level should " + prettyKey, "§7How many level should " + prettyKey,
"§7cost when applied by book or by another item." "§7cost when applied by book or by another item."
), ),
0, 255, enchant, 0, 255,
rarity.getItemValue(), rarity.getBookValue(),
1, 10, 50); 1, 10, 50);
} }

View file

@ -1,6 +1,7 @@
package xyz.alexcrea.cuanvil.gui.config.global; package xyz.alexcrea.cuanvil.gui.config.global;
import com.github.stefvanschie.inventoryframework.gui.GuiItem; import com.github.stefvanschie.inventoryframework.gui.GuiItem;
import io.delilaheve.util.ConfigOptions;
import org.bukkit.Material; import org.bukkit.Material;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
import xyz.alexcrea.cuanvil.config.ConfigHolder; import xyz.alexcrea.cuanvil.config.ConfigHolder;
@ -37,17 +38,23 @@ public class EnchantLimitConfigGui extends AbstractEnchantConfigGui<IntSettingsG
@Override @Override
public IntSettingsGui.IntSettingFactory createFactory(CAEnchantment enchant) { public IntSettingsGui.IntSettingFactory createFactory(CAEnchantment enchant) {
String key = enchant.getKey().getKey().toLowerCase(Locale.ROOT); String key = enchant.getKey().toString().toLowerCase(Locale.ROOT);
String prettyKey = CasedStringUtil.snakeToUpperSpacedCase(key); String prettyKey = CasedStringUtil.snakeToUpperSpacedCase(key.replace(":", "_"));
return new IntSettingsGui.IntSettingFactory(prettyKey + " Level Limit", this, return new IntSettingsGui.IntSettingFactory(prettyKey + " Limit", this,
SECTION_NAME + '.' + key, ConfigHolder.DEFAULT_CONFIG, SECTION_NAME + '.' + key, ConfigHolder.DEFAULT_CONFIG,
Collections.singletonList( Collections.singletonList(
"§7Maximum applied level of " + prettyKey "§7Maximum applied level of " + prettyKey
), ),
0, 255, 0, 255,
enchant.defaultMaxLevel(), enchant.defaultMaxLevel(),
1, 5, 10, 50, 100); 1, 5, 10, 50, 100){
@Override
public int getConfiguredValue() {
return ConfigOptions.INSTANCE.enchantLimit(enchant);
}
};
} }
@Override @Override

View file

@ -1,6 +1,7 @@
package xyz.alexcrea.cuanvil.gui.config.global; package xyz.alexcrea.cuanvil.gui.config.global;
import com.github.stefvanschie.inventoryframework.gui.GuiItem; import com.github.stefvanschie.inventoryframework.gui.GuiItem;
import io.delilaheve.util.ConfigOptions;
import org.bukkit.Material; import org.bukkit.Material;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
import xyz.alexcrea.cuanvil.config.ConfigHolder; import xyz.alexcrea.cuanvil.config.ConfigHolder;
@ -34,8 +35,8 @@ public class EnchantMergeLimitConfigGui extends AbstractEnchantConfigGui<IntSett
@Override @Override
public IntSettingsGui.IntSettingFactory createFactory(CAEnchantment enchant) { public IntSettingsGui.IntSettingFactory createFactory(CAEnchantment enchant) {
String key = enchant.getKey().getKey().toLowerCase(Locale.ROOT); String key = enchant.getKey().toString().toLowerCase(Locale.ROOT);
String prettyKey = CasedStringUtil.snakeToUpperSpacedCase(key); String prettyKey = CasedStringUtil.snakeToUpperSpacedCase(key.replace(":", "_"));
return new IntSettingsGui.IntSettingFactory(prettyKey + " Merge Limit", this, return new IntSettingsGui.IntSettingFactory(prettyKey + " Merge Limit", this,
SECTION_NAME + '.' + key, ConfigHolder.DEFAULT_CONFIG, SECTION_NAME + '.' + key, ConfigHolder.DEFAULT_CONFIG,
@ -48,7 +49,13 @@ public class EnchantMergeLimitConfigGui extends AbstractEnchantConfigGui<IntSett
"§e-1 §7(default) will set the merge limit to enchantment's maximum level" "§e-1 §7(default) will set the merge limit to enchantment's maximum level"
), ),
-1, 255, -1, -1, 255, -1,
1, 5, 10, 50, 100); 1, 5, 10, 50, 100){
@Override
public int getConfiguredValue() {
return ConfigOptions.INSTANCE.maxBeforeMergeDisabled(enchant);
}
};
} }
@Override @Override

View file

@ -258,7 +258,7 @@ public class EnchantConflictSubSettingGui extends MappedToListSubSettingGui impl
String[] enchantKeys = new String[enchantments.size()]; String[] enchantKeys = new String[enchantments.size()];
int index = 0; int index = 0;
for (CAEnchantment enchantment : enchantments) { for (CAEnchantment enchantment : enchantments) {
enchantKeys[index++] = enchantment.getKey().getKey(); enchantKeys[index++] = enchantment.getKey().toString();
} }
ConfigHolder.CONFLICT_HOLDER.getConfig().set(enchantConflict + ".enchantments", enchantKeys); ConfigHolder.CONFLICT_HOLDER.getConfig().set(enchantConflict + ".enchantments", enchantKeys);

View file

@ -5,6 +5,7 @@ import com.github.stefvanschie.inventoryframework.gui.type.util.Gui;
import com.github.stefvanschie.inventoryframework.pane.PatternPane; import com.github.stefvanschie.inventoryframework.pane.PatternPane;
import com.github.stefvanschie.inventoryframework.pane.util.Pattern; import com.github.stefvanschie.inventoryframework.pane.util.Pattern;
import io.delilaheve.CustomAnvil; import io.delilaheve.CustomAnvil;
import io.delilaheve.util.ConfigOptions;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.event.inventory.InventoryClickEvent; import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.inventory.ItemFlag; import org.bukkit.inventory.ItemFlag;
@ -13,6 +14,7 @@ import org.bukkit.inventory.meta.ItemMeta;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
import xyz.alexcrea.cuanvil.config.ConfigHolder; import xyz.alexcrea.cuanvil.config.ConfigHolder;
import xyz.alexcrea.cuanvil.enchant.CAEnchantment;
import xyz.alexcrea.cuanvil.gui.ValueUpdatableGui; import xyz.alexcrea.cuanvil.gui.ValueUpdatableGui;
import xyz.alexcrea.cuanvil.gui.util.GuiGlobalActions; import xyz.alexcrea.cuanvil.gui.util.GuiGlobalActions;
import xyz.alexcrea.cuanvil.gui.util.GuiGlobalItems; import xyz.alexcrea.cuanvil.gui.util.GuiGlobalItems;
@ -237,43 +239,13 @@ public class EnchantCostSettingsGui extends IntSettingsGui {
return super.hadChange() || nowBook != beforeBook; return super.hadChange() || nowBook != beforeBook;
} }
/**
* Create an int setting factory from setting's parameters.
*
* @param title The title of the gui.
* @param parent Parent gui to go back when completed.
* @param config Configuration holder of this setting.
* @param configPath Configuration path of this setting.
* @param displayLore Gui display item lore.
* @param min Minimum value of this setting.
* @param max Maximum value of this setting.
* @param defaultItemVal Default item value if not found on the config.
* @param defaultBookVal Default book value if not found on the config.
* @param steps List of step the value can increment/decrement.
* List's size should be between 1 (included) and 3 (included).
* it is visually preferable to have an odd number of step.
* If step only contain 1 value, no step item should be displayed.
* @return A factory for an enchant cost setting gui.
*/
public static EnchantCostSettingFactory enchantCostFactory(
@NotNull String title, @NotNull ValueUpdatableGui parent,
@NotNull ConfigHolder config, @NotNull String configPath,
@Nullable List<String> displayLore,
int min, int max, int defaultItemVal, int defaultBookVal,
int... steps) {
return new EnchantCostSettingFactory(
title, parent,
configPath, config,
displayLore,
min, max, defaultItemVal, defaultBookVal, steps);
}
/** /**
* A factory for an enchantment cost setting gui that hold setting's information. * A factory for an enchantment cost setting gui that hold setting's information.
*/ */
public static class EnchantCostSettingFactory extends IntSettingsGui.IntSettingFactory { public static class EnchantCostSettingFactory extends IntSettingsGui.IntSettingFactory {
int defaultBookVal; int defaultBookVal;
@NotNull CAEnchantment enchantment;
/** /**
* Constructor for an enchantment cost setting gui factory. * Constructor for an enchantment cost setting gui factory.
@ -285,25 +257,27 @@ public class EnchantCostSettingsGui extends IntSettingsGui {
* @param displayLore Gui display item lore. * @param displayLore Gui display item lore.
* @param min Minimum value of this setting. * @param min Minimum value of this setting.
* @param max Maximum value of this setting. * @param max Maximum value of this setting.
* @param defaultItemVal Default item value if not found on the config. * @param enchantment Enchantment to change the cost to
* @param defaultBookVal Default book value if not found on the config.
* @param steps List of step the value can increment/decrement. * @param steps List of step the value can increment/decrement.
* List's size should be between 1 (included) and 3 (included). * List's size should be between 1 (included) and 3 (included).
* it is visually preferable to have an odd number of step. * it is visually preferable to have an odd number of step.
* If step only contain 1 value, no step item should be displayed. * If step only contain 1 value, no step item should be displayed.
*/ */
protected EnchantCostSettingFactory( public EnchantCostSettingFactory(
@NotNull String title, ValueUpdatableGui parent, @NotNull String title, ValueUpdatableGui parent,
@NotNull String configPath, @NotNull ConfigHolder config, @NotNull String configPath, @NotNull ConfigHolder config,
@Nullable List<String> displayLore, @Nullable List<String> displayLore,
int min, int max, int defaultItemVal, int defaultBookVal, @NotNull CAEnchantment enchantment,
int... steps) { int min, int max, int... steps) {
super(title, parent, super(title, parent,
configPath, config, configPath, config,
displayLore, displayLore,
min, max, defaultItemVal, steps); min, max, enchantment.defaultRarity().getItemValue(),
this.defaultBookVal = defaultBookVal; steps);
this.defaultBookVal = enchantment.defaultRarity().getBookValue();
this.enchantment = enchantment;
} }
/** /**
@ -311,14 +285,14 @@ public class EnchantCostSettingsGui extends IntSettingsGui {
*/ */
@Override @Override
public int getConfiguredValue() { public int getConfiguredValue() {
return this.config.getConfig().getInt(this.configPath + ITEM_PATH, this.defaultVal); return ConfigOptions.INSTANCE.enchantmentValue(enchantment, false);
} }
/** /**
* @return The configured value for the enchant setting book value. * @return The configured value for the enchant setting book value.
*/ */
public int getConfiguredBookValue() { public int getConfiguredBookValue() {
return this.config.getConfig().getInt(this.configPath + BOOK_PATH, this.defaultBookVal); return ConfigOptions.INSTANCE.enchantmentValue(enchantment, true);
} }
@Override @Override

View file

@ -45,13 +45,13 @@ public class Update_1_21 {
addToStringList(groupConfig, "can_unbreak.groups", "mace"); addToStringList(groupConfig, "can_unbreak.groups", "mace");
// Add new enchant conflicts // Add new enchant conflicts
addToStringList(conflictConfig, "restriction_density.enchantments", "density"); addToStringList(conflictConfig, "restriction_density.enchantments", "minecraft:density");
addToStringList(conflictConfig, "restriction_density.notAffectedGroups", "mace", "enchanted_book"); addToStringList(conflictConfig, "restriction_density.notAffectedGroups", "mace", "enchanted_book");
addToStringList(conflictConfig, "restriction_breach.enchantments", "breach"); addToStringList(conflictConfig, "restriction_breach.enchantments", "minecraft:breach");
addToStringList(conflictConfig, "restriction_breach.notAffectedGroups", "mace", "enchanted_book"); addToStringList(conflictConfig, "restriction_breach.notAffectedGroups", "mace", "enchanted_book");
addToStringList(conflictConfig, "restriction_wind_burst.enchantments", "wind_burst"); addToStringList(conflictConfig, "restriction_wind_burst.enchantments", "minecraft:wind_burst");
addToStringList(conflictConfig, "restriction_wind_burst.notAffectedGroups", "mace", "enchanted_book"); addToStringList(conflictConfig, "restriction_wind_burst.notAffectedGroups", "mace", "enchanted_book");
// Add mace to conflicts // Add mace to conflicts
@ -59,13 +59,14 @@ public class Update_1_21 {
addToStringList(conflictConfig, "restriction_smite.notAffectedGroups", "mace"); addToStringList(conflictConfig, "restriction_smite.notAffectedGroups", "mace");
addToStringList(conflictConfig, "restriction_bane_of_arthropods.notAffectedGroups", "mace"); addToStringList(conflictConfig, "restriction_bane_of_arthropods.notAffectedGroups", "mace");
addToStringList(conflictConfig, "mace_enchant_conflict.enchantments", "density", "breach", "smite", "bane_of_arthropods"); addToStringList(conflictConfig, "mace_enchant_conflict.enchantments",
"minecraft:density", "minecraft:breach", "minecraft:smite", "minecraft:bane_of_arthropods");
conflictConfig.set("mace_enchant_conflict.maxEnchantmentBeforeConflict", 1); conflictConfig.set("mace_enchant_conflict.maxEnchantmentBeforeConflict", 1);
// Add level limit // Add level limit
baseConfig.set("enchant_limits.density", 5); baseConfig.set("enchant_limits.minecraft:density", 5);
baseConfig.set("enchant_limits.breach", 4); baseConfig.set("enchant_limits.minecraft:breach", 4);
baseConfig.set("enchant_limits.wind_burst", 3); baseConfig.set("enchant_limits.minecraft:wind_burst", 3);
// Add enchant values // Add enchant values
baseConfig.set("enchant_values.density.item", 1); baseConfig.set("enchant_values.density.item", 1);

View file

@ -301,21 +301,28 @@ object ConfigOptions {
* Get the given [enchantment]'s limit * Get the given [enchantment]'s limit
*/ */
fun enchantLimit(enchantment: CAEnchantment): Int { fun enchantLimit(enchantment: CAEnchantment): Int {
return enchantLimit(enchantment.enchantmentName) // Test namespace
var limit = enchantLimit(enchantment.key.toString())
if(limit != null) return limit;
// Test legacy (name only)
limit = enchantLimit(enchantment.enchantmentName)
if(limit != null) return limit;
// get default (and test old legacy if present)
return getDefaultLevel(enchantment.enchantmentName)
} }
/** /**
* Get the given [enchantmentName]'s limit * Get the given [enchantmentName]'s limit
*/ */
private fun enchantLimit(enchantmentName: String): Int { private fun enchantLimit(enchantmentName: String): Int? {
val default = getDefaultLevel(enchantmentName)
val path = "${ENCHANT_LIMIT_ROOT}.$enchantmentName" val path = "${ENCHANT_LIMIT_ROOT}.$enchantmentName"
return CustomAnvil.instance return CustomAnvil.instance
.config .config
.getInt(path, default) .getInt(path, ENCHANT_LIMIT_RANGE.first-1)
.takeIf { it in ENCHANT_LIMIT_RANGE } .takeIf { it in ENCHANT_LIMIT_RANGE }
?: default
} }
/** /**
@ -324,7 +331,9 @@ object ConfigOptions {
private fun getDefaultLevel(enchantmentName: String, // compatibility with 1.20.5. TODO better update system private fun getDefaultLevel(enchantmentName: String, // compatibility with 1.20.5. TODO better update system
) : Int { ) : Int {
if(enchantmentName == "sweeping_edge"){ if(enchantmentName == "sweeping_edge"){
return enchantLimit("sweeping") val limit = enchantLimit("sweeping")
if(limit != null) return limit
} }
return defaultEnchantLimit return defaultEnchantLimit
} }
@ -337,7 +346,17 @@ object ConfigOptions {
enchantment: CAEnchantment, enchantment: CAEnchantment,
isFromBook: Boolean isFromBook: Boolean
): Int { ): Int {
return enchantmentValue(enchantment.enchantmentName, isFromBook) // Test namespace
var limit = enchantmentValue(enchantment.key.toString(), isFromBook)
if(limit != null) return limit;
// Test legacy (name only)
limit = enchantmentValue(enchantment.enchantmentName, isFromBook)
if(limit != null) return limit;
// get default (and test old legacy if present)
return getDefaultValue(enchantment, isFromBook)
} }
/** /**
@ -347,36 +366,36 @@ object ConfigOptions {
private fun enchantmentValue( private fun enchantmentValue(
enchantmentName: String, enchantmentName: String,
isFromBook: Boolean isFromBook: Boolean
): Int { ): Int? {
val default = getDefaultValue(enchantmentName, isFromBook)
val typeKey = if (isFromBook) KEY_BOOK else KEY_ITEM val typeKey = if (isFromBook) KEY_BOOK else KEY_ITEM
val path = "${ENCHANT_VALUES_ROOT}.${enchantmentName}.$typeKey" val path = "${ENCHANT_VALUES_ROOT}.${enchantmentName}.$typeKey"
return CustomAnvil.instance return CustomAnvil.instance
.config .config
.getInt(path, default) .getInt(path, DEFAULT_ENCHANT_VALUE - 1)
.takeIf { it >= DEFAULT_ENCHANT_VALUE } .takeIf { it >= DEFAULT_ENCHANT_VALUE }
?: DEFAULT_ENCHANT_VALUE
} }
/** /**
* Get default value if enchantment do not exist on config * Get default value if enchantment do not exist on config
*/ */
private fun getDefaultValue(enchantmentName: String, // compatibility with 1.20.5. TODO better update system private fun getDefaultValue(enchantment: CAEnchantment, // compatibility with 1.20.5. TODO better update system
isFromBook: Boolean) : Int { isFromBook: Boolean) : Int {
if(enchantmentName == "sweeping_edge"){
return enchantmentValue("sweeping", isFromBook) val enchantmentName = enchantment.key.toString()
if(enchantmentName == "minecraft:sweeping_edge"){
var limit = enchantmentValue("minecraft:sweeping", isFromBook)
if(limit != null) return limit
// legacy name
limit = enchantmentValue("sweeping", isFromBook)
if(limit != null) return limit
} }
val enchantment = CAEnchantment.getByName(enchantmentName)
if(enchantment != null){
val rarity = enchantment.defaultRarity() val rarity = enchantment.defaultRarity()
return if(isFromBook)
return if(isFromBook) rarity.bookValue rarity.bookValue
else rarity.itemValue else
} rarity.itemValue
return DEFAULT_ENCHANT_VALUE
} }
/** /**
@ -384,28 +403,39 @@ object ConfigOptions {
* a negative value would mean never disabled * a negative value would mean never disabled
*/ */
fun maxBeforeMergeDisabled(enchantment: CAEnchantment): Int { fun maxBeforeMergeDisabled(enchantment: CAEnchantment): Int {
return maxBeforeMergeDisabled(enchantment.enchantmentName) val key = enchantment.key.toString()
var value = maxBeforeMergeDisabled(key)
if(value != null) return value
// Legacy name
val legacy = enchantment.enchantmentName
value = maxBeforeMergeDisabled(legacy)
if(value != null) return value
if(key == "minecraft:sweeping_edge"){
value = maxBeforeMergeDisabled("minecraft:sweeping")
if(value != null) return value
// legacy name of legacy enchantment name
value = maxBeforeMergeDisabled("sweeping")
if(value != null) return value
}
return DEFAULT_MAX_BEFORE_MERGE_DISABLED
} }
/** /**
* Get the given [enchantmentName]'s level before merge is disabled * Get the given [enchantmentName]'s level before merge is disabled
* a negative value would mean never disabled * a negative value would mean never disabled
*/ */
private fun maxBeforeMergeDisabled(enchantmentName: String) : Int { private fun maxBeforeMergeDisabled(enchantmentName: String) : Int? {
// find if set // find if set
val path = "${DISABLE_MERGE_OVER_ROOT}.$enchantmentName" val path = "${DISABLE_MERGE_OVER_ROOT}.$enchantmentName"
val value = CustomAnvil.instance return CustomAnvil.instance
.config .config
.getInt(path, DEFAULT_MAX_BEFORE_MERGE_DISABLED) .getInt(path, ENCHANT_LIMIT_RANGE.min() - 1)
.takeIf { it in ENCHANT_LIMIT_RANGE } .takeIf { it in ENCHANT_LIMIT_RANGE }
?: DEFAULT_MAX_BEFORE_MERGE_DISABLED;
if((value == DEFAULT_MAX_BEFORE_MERGE_DISABLED) && (enchantmentName == "sweeping_edge")){
return maxBeforeMergeDisabled("sweeping")
}
return value
} }
} }

View file

@ -15,6 +15,9 @@ class EnchantConflictGroup(
fun addEnchantment(enchant: CAEnchantment) { fun addEnchantment(enchant: CAEnchantment) {
enchantments.add(enchant) enchantments.add(enchant)
} }
fun addEnchantments(enchants: List<CAEnchantment>) {
enchantments.addAll(enchants)
}
fun allowed(enchants: Set<CAEnchantment>, mat: Material): Boolean { fun allowed(enchants: Set<CAEnchantment>, mat: Material): Boolean {
if (enchantments.size < minBeforeBlock) { if (enchantments.size < minBeforeBlock) {

View file

@ -30,9 +30,9 @@ class EnchantConflictManager {
const val DEFAULT_GROUP_NAME = "joinedGroup" const val DEFAULT_GROUP_NAME = "joinedGroup"
// 1.20.5 compatibility TODO better update system // 1.20.5 compatibility TODO better update system
private val SWEEPING_EDGE_ENCHANT = private val SWEEPING_EDGE_ENCHANT = Collections.singletonList<CAEnchantment>(
CAEnchantment.getByKey(NamespacedKey.minecraft("sweeping_edge")) ?: CAEnchantment.getByKey(NamespacedKey.minecraft("sweeping_edge")) ?:
CAEnchantment.getByKey(Enchantment.SWEEPING_EDGE.key) CAEnchantment.getByKey(Enchantment.SWEEPING_EDGE.key))
} }
@ -94,14 +94,14 @@ class EnchantConflictManager {
// Read and add enchantment to conflict // Read and add enchantment to conflict
val enchantList = section.getStringList(ENCH_LIST_PATH) val enchantList = section.getStringList(ENCH_LIST_PATH)
for (enchantName in enchantList) { for (enchantName in enchantList) {
val enchant = getEnchantByName(enchantName) val enchants = getEnchantByIdentifier(enchantName)
if (enchant == null) { if (enchants.isEmpty()) {
if (!futureUse) { //TODO future use will be deprecated once the new update system is finished if (!futureUse) { //TODO future use will be deprecated once the new update system is finished
CustomAnvil.instance.logger.warning("Enchantment $enchantName do not exist but was asked for conflict $conflictName") CustomAnvil.instance.logger.warning("Enchantment $enchantName do not exist but was asked for conflict $conflictName")
} }
continue continue
} }
conflict.addEnchantment(enchant) conflict.addEnchantments(enchants)
} }
if (conflict.getEnchants().isEmpty()) { if (conflict.getEnchants().isEmpty()) {
if (!futureUse) { //TODO future use will be deprecated once the new update system is finished if (!futureUse) { //TODO future use will be deprecated once the new update system is finished
@ -112,16 +112,23 @@ class EnchantConflictManager {
return conflict return conflict
} }
private fun getEnchantByName(enchantName: String): CAEnchantment? { private fun getEnchantByIdentifier(enchantName: String): List<CAEnchantment> {
val key = NamespacedKey.fromString(enchantName)
if(key != null){
val enchantment = CAEnchantment.getByKey(key)
if(enchantment != null) return Collections.singletonList(enchantment)
}
// Temporary solution for 1.20.5 // Temporary solution for 1.20.5
when(enchantName){ when(enchantName){
"sweeping", "sweeping_edge" -> { "minecraft:sweeping", "sweeping",
"minecraft:sweeping_edge", "sweeping_edge" -> {
return SWEEPING_EDGE_ENCHANT return SWEEPING_EDGE_ENCHANT
} }
} }
return CAEnchantment.getByName(enchantName) return CAEnchantment.getListByName(enchantName)
} }

View file

@ -97,46 +97,46 @@ default_limit: 5
# #
# Valid range of 1 - 255 for each enchantment # Valid range of 1 - 255 for each enchantment
enchant_limits: enchant_limits:
aqua_affinity: 1 minecraft:aqua_affinity: 1
binding_curse: 1 minecraft:binding_curse: 1
channeling: 1 minecraft:channeling: 1
flame: 1 minecraft:flame: 1
infinity: 1 minecraft:infinity: 1
mending: 1 minecraft:mending: 1
multishot: 1 minecraft:multishot: 1
silk_touch: 1 minecraft:silk_touch: 1
vanishing_curse: 1 minecraft:vanishing_curse: 1
depth_strider: 3 # anything more than 3 is treated as 3 by the game minecraft:depth_strider: 3 # anything more than 3 is treated as 3 by the game
protection: 4 minecraft:protection: 4
fire_protection: 4 minecraft:fire_protection: 4
blast_protection: 4 minecraft:blast_protection: 4
projectile_protection: 4 minecraft:projectile_protection: 4
feather_falling: 4 minecraft:feather_falling: 4
thorns: 3 minecraft:thorns: 3
respiration: 3 minecraft:respiration: 3
sharpness: 5 minecraft:sharpness: 5
smite: 5 minecraft:smite: 5
bane_of_arthropods: 5 minecraft:bane_of_arthropods: 5
knockback: 2 minecraft:knockback: 2
fire_aspect: 2 minecraft:fire_aspect: 2
looting: 3 minecraft:looting: 3
sweeping: 3 minecraft:sweeping: 3
sweeping_edge: 3 minecraft:sweeping_edge: 3
efficiency: 5 minecraft:efficiency: 5
unbreaking: 3 minecraft:unbreaking: 3
fortune: 3 minecraft:fortune: 3
power: 5 minecraft:power: 5
punch: 2 minecraft:punch: 2
luck_of_the_sea: 3 minecraft:luck_of_the_sea: 3
lure: 3 minecraft:lure: 3
frost_walker: 2 minecraft:frost_walker: 2
impaling: 5 minecraft:impaling: 5
riptide: 3 minecraft:riptide: 3
loyalty: 3 minecraft:loyalty: 3
piercing: 4 minecraft:piercing: 4
quick_charge: 3 minecraft:quick_charge: 3
soul_speed: 3 minecraft:soul_speed: 3
swift_sneak: 3 minecraft:swift_sneak: 3
# Multipliers used to calculate the enchantment's value in repair/combining # Multipliers used to calculate the enchantment's value in repair/combining
# #
@ -150,124 +150,124 @@ enchant_limits:
# With default values protection 4 would have a value of 4 when # With default values protection 4 would have a value of 4 when
# coming from either a book (4 * 1) or an item (4 * 1) # coming from either a book (4 * 1) or an item (4 * 1)
enchant_values: enchant_values:
aqua_affinity: minecraft:aqua_affinity:
item: 4 item: 4
book: 2 book: 2
bane_of_arthropods: minecraft:bane_of_arthropods:
item: 2 item: 2
book: 1 book: 1
binding_curse: minecraft:binding_curse:
item: 8 item: 8
book: 4 book: 4
blast_protection: minecraft:blast_protection:
item: 4 item: 4
book: 2 book: 2
channeling: minecraft:channeling:
item: 8 item: 8
book: 4 book: 4
depth_strider: minecraft:depth_strider:
item: 4 item: 4
book: 2 book: 2
efficiency: minecraft:efficiency:
item: 1 item: 1
book: 1 book: 1
flame: minecraft:flame:
item: 4 item: 4
book: 2 book: 2
feather_falling: minecraft:feather_falling:
item: 2 item: 2
book: 1 book: 1
fire_aspect: minecraft:fire_aspect:
item: 4 item: 4
book: 2 book: 2
fire_protection: minecraft:fire_protection:
item: 2 item: 2
book: 1 book: 1
fortune: minecraft:fortune:
item: 4 item: 4
book: 2 book: 2
frost_walker: minecraft:frost_walker:
item: 4 item: 4
book: 2 book: 2
impaling: minecraft:impaling:
item: 4 item: 4
book: 2 book: 2
infinity: minecraft:infinity:
item: 8 item: 8
book: 4 book: 4
knockback: minecraft:knockback:
item: 2 item: 2
book: 1 book: 1
looting: minecraft:looting:
item: 4 item: 4
book: 2 book: 2
loyalty: minecraft:loyalty:
item: 1 item: 1
book: 1 book: 1
luck_of_the_sea: minecraft:luck_of_the_sea:
item: 4 item: 4
book: 2 book: 2
lure: minecraft:lure:
item: 4 item: 4
book: 2 book: 2
mending: minecraft:mending:
item: 4 item: 4
book: 2 book: 2
multishot: minecraft:multishot:
item: 4 item: 4
book: 2 book: 2
piercing: minecraft:piercing:
item: 1 item: 1
book: 1 book: 1
power: minecraft:power:
item: 1 item: 1
book: 1 book: 1
projectile_protection: minecraft:projectile_protection:
item: 2 item: 2
book: 1 book: 1
protection: minecraft:protection:
item: 1 item: 1
book: 1 book: 1
punch: minecraft:punch:
item: 4 item: 4
book: 2 book: 2
quick_charge: minecraft:quick_charge:
item: 2 item: 2
book: 1 book: 1
respiration: minecraft:respiration:
item: 4 item: 4
book: 2 book: 2
riptide: minecraft:riptide:
item: 4 item: 4
book: 2 book: 2
silk_touch: minecraft:silk_touch:
item: 8 item: 8
book: 4 book: 4
sharpness: minecraft:sharpness:
item: 1 item: 1
book: 1 book: 1
smite: minecraft:smite:
item: 2 item: 2
book: 1 book: 1
soul_speed: minecraft:soul_speed:
item: 8 item: 8
book: 4 book: 4
swift_sneak: minecraft:swift_sneak:
item: 8 item: 8
book: 4 book: 4
sweeping: minecraft:sweeping:
item: 4 item: 4
book: 2 book: 2
sweeping_edge: minecraft:sweeping_edge:
item: 4 item: 4
book: 2 book: 2
thorns: minecraft:thorns:
item: 8 item: 8
book: 4 book: 4
unbreaking: minecraft:unbreaking:
item: 2 item: 2
book: 1 book: 1
vanishing_curse: minecraft:vanishing_curse:
item: 8 item: 8
book: 4 book: 4
@ -278,9 +278,9 @@ enchant_values:
# -1 mean enchantment merge for this enchantment is not disabled. default to -1 if absent. # -1 mean enchantment merge for this enchantment is not disabled. default to -1 if absent.
disable-merge-over: disable-merge-over:
# Sharpness is set to -1. it equivalent to it not being set to anything (and work as vanilla) # Sharpness is set to -1. it equivalent to it not being set to anything (and work as vanilla)
sharpness: -1 minecraft:sharpness: -1
# If uncommented. 2 unbreaking II book would not give an unbreaking III book. but unbreaking III book can still be applied # If uncommented. 2 unbreaking II book would not give an unbreaking III book. but unbreaking III book can still be applied
#unbreaking: 2 #minecraft:unbreaking: 2
# Whether to show debug logging # Whether to show debug logging
debug_log: false debug_log: false

View file

@ -17,158 +17,158 @@
# ---------------------------------------------------- # ----------------------------------------------------
restriction_aqua_affinity: restriction_aqua_affinity:
enchantments: [ aqua_affinity ] enchantments: [ minecraft:aqua_affinity ]
notAffectedGroups: [ enchanted_book, helmets ] notAffectedGroups: [ enchanted_book, helmets ]
restriction_bane_of_arthropods: restriction_bane_of_arthropods:
enchantments: [ bane_of_arthropods ] enchantments: [ minecraft:bane_of_arthropods ]
notAffectedGroups: [ enchanted_book, melee_weapons ] notAffectedGroups: [ enchanted_book, melee_weapons ]
restriction_blast_protection: restriction_blast_protection:
enchantments: [ blast_protection ] enchantments: [ minecraft:blast_protection ]
notAffectedGroups: [ enchanted_book, armors ] notAffectedGroups: [ enchanted_book, armors ]
restriction_channeling: restriction_channeling:
enchantments: [ channeling ] enchantments: [ minecraft:channeling ]
notAffectedGroups: [ enchanted_book, trident ] notAffectedGroups: [ enchanted_book, trident ]
restriction_binding_curse: restriction_binding_curse:
enchantments: [ binding_curse ] enchantments: [ minecraft:binding_curse ]
notAffectedGroups: [ enchanted_book, wearable ] notAffectedGroups: [ enchanted_book, wearable ]
restriction_vanishing_curse: restriction_vanishing_curse:
enchantments: [ vanishing_curse ] enchantments: [ minecraft:vanishing_curse ]
notAffectedGroups: [ enchanted_book, can_vanish ] notAffectedGroups: [ enchanted_book, can_vanish ]
restriction_depth_strider: restriction_depth_strider:
enchantments: [ depth_strider ] enchantments: [ minecraft:depth_strider ]
notAffectedGroups: [ enchanted_book, boots ] notAffectedGroups: [ enchanted_book, boots ]
restriction_efficiency: restriction_efficiency:
enchantments: [ efficiency ] enchantments: [ minecraft:efficiency ]
notAffectedGroups: [ enchanted_book, tools, shears ] notAffectedGroups: [ enchanted_book, tools, shears ]
restriction_feather_falling: restriction_feather_falling:
enchantments: [ feather_falling ] enchantments: [ minecraft:feather_falling ]
notAffectedGroups: [ enchanted_book, boots ] notAffectedGroups: [ enchanted_book, boots ]
restriction_fire_aspect: restriction_fire_aspect:
enchantments: [ fire_aspect ] enchantments: [ minecraft:fire_aspect ]
notAffectedGroups: [ enchanted_book, swords ] notAffectedGroups: [ enchanted_book, swords ]
restriction_fire_protection: restriction_fire_protection:
enchantments: [ fire_protection ] enchantments: [ minecraft:fire_protection ]
notAffectedGroups: [ enchanted_book, armors ] notAffectedGroups: [ enchanted_book, armors ]
restriction_flame: restriction_flame:
enchantments: [ flame ] enchantments: [ minecraft:flame ]
notAffectedGroups: [ enchanted_book, bow ] notAffectedGroups: [ enchanted_book, bow ]
restriction_fortune: restriction_fortune:
enchantments: [ fortune ] enchantments: [ minecraft:fortune ]
notAffectedGroups: [ enchanted_book, tools ] notAffectedGroups: [ enchanted_book, tools ]
restriction_frost_walker: restriction_frost_walker:
enchantments: [ frost_walker ] enchantments: [ minecraft:frost_walker ]
notAffectedGroups: [ enchanted_book, boots ] notAffectedGroups: [ enchanted_book, boots ]
restriction_impaling: restriction_impaling:
enchantments: [ impaling ] enchantments: [ minecraft:impaling ]
notAffectedGroups: [ enchanted_book, trident ] notAffectedGroups: [ enchanted_book, trident ]
restriction_infinity: restriction_infinity:
enchantments: [ infinity ] enchantments: [ minecraft:infinity ]
notAffectedGroups: [ enchanted_book, bow ] notAffectedGroups: [ enchanted_book, bow ]
restriction_knockback: restriction_knockback:
enchantments: [ knockback ] enchantments: [ minecraft:knockback ]
notAffectedGroups: [ enchanted_book, swords ] notAffectedGroups: [ enchanted_book, swords ]
restriction_looting: restriction_looting:
enchantments: [ looting ] enchantments: [ minecraft:looting ]
notAffectedGroups: [ enchanted_book, swords ] notAffectedGroups: [ enchanted_book, swords ]
restriction_loyalty: restriction_loyalty:
enchantments: [ loyalty ] enchantments: [ minecraft:loyalty ]
notAffectedGroups: [ enchanted_book, trident ] notAffectedGroups: [ enchanted_book, trident ]
restriction_lure: restriction_lure:
enchantments: [ lure ] enchantments: [ minecraft:lure ]
notAffectedGroups: [ enchanted_book, fishing_rod ] notAffectedGroups: [ enchanted_book, fishing_rod ]
restriction_mending: restriction_mending:
enchantments: [ mending ] enchantments: [ minecraft:mending ]
notAffectedGroups: [ enchanted_book, can_unbreak ] notAffectedGroups: [ enchanted_book, can_unbreak ]
restriction_multishot: restriction_minecraft_multishot:
enchantments: [ multishot ] enchantments: [ minecraft:multishot ]
notAffectedGroups: [ enchanted_book, crossbow ] notAffectedGroups: [ enchanted_book, crossbow ]
restriction_piercing: restriction_piercing:
enchantments: [ piercing ] enchantments: [ minecraft:piercing ]
notAffectedGroups: [ enchanted_book, crossbow ] notAffectedGroups: [ enchanted_book, crossbow ]
restriction_power: restriction_power:
enchantments: [ power ] enchantments: [ minecraft:power ]
notAffectedGroups: [ enchanted_book, bow ] notAffectedGroups: [ enchanted_book, bow ]
restriction_projectile_protection: restriction_projectile_protection:
enchantments: [ projectile_protection ] enchantments: [ minecraft:projectile_protection ]
notAffectedGroups: [ enchanted_book, armors ] notAffectedGroups: [ enchanted_book, armors ]
restriction_protection: restriction_protection:
enchantments: [ protection ] enchantments: [ minecraft:protection ]
notAffectedGroups: [ enchanted_book, armors ] notAffectedGroups: [ enchanted_book, armors ]
restriction_punch: restriction_punch:
enchantments: [ punch ] enchantments: [ minecraft:punch ]
notAffectedGroups: [ enchanted_book, bow ] notAffectedGroups: [ enchanted_book, bow ]
restriction_quick_charge: restriction_quick_charge:
enchantments: [ quick_charge ] enchantments: [ minecraft:quick_charge ]
notAffectedGroups: [ enchanted_book, crossbow ] notAffectedGroups: [ enchanted_book, crossbow ]
restriction_respiration: restriction_respiration:
enchantments: [ respiration ] enchantments: [ minecraft:respiration ]
notAffectedGroups: [ enchanted_book, helmets ] notAffectedGroups: [ enchanted_book, helmets ]
restriction_riptide: restriction_riptide:
enchantments: [ riptide ] enchantments: [ minecraft:riptide ]
notAffectedGroups: [ enchanted_book, trident ] notAffectedGroups: [ enchanted_book, trident ]
restriction_sharpness: restriction_sharpness:
enchantments: [ sharpness ] enchantments: [ minecraft:sharpness ]
notAffectedGroups: [ enchanted_book, melee_weapons ] notAffectedGroups: [ enchanted_book, melee_weapons ]
restriction_silk_touch: restriction__silk_touch:
enchantments: [ silk_touch ] enchantments: [ minecraft:silk_touch ]
notAffectedGroups: [ enchanted_book, tools ] notAffectedGroups: [ enchanted_book, tools ]
restriction_smite: restriction_smite:
enchantments: [ smite ] enchantments: [ minecraft:smite ]
notAffectedGroups: [ enchanted_book, melee_weapons ] notAffectedGroups: [ enchanted_book, melee_weapons ]
restriction_soul_speed: restriction_soul_speed:
enchantments: [ soul_speed ] enchantments: [ minecraft:soul_speed ]
notAffectedGroups: [ enchanted_book, boots ] notAffectedGroups: [ enchanted_book, boots ]
restriction_sweeping_edge: restriction_sweeping_edge:
enchantments: [ sweeping, sweeping_edge ] enchantments: [ minecraft:sweeping, minecraft:sweeping_edge ]
notAffectedGroups: [ enchanted_book, swords ] notAffectedGroups: [ enchanted_book, swords ]
# Do not exist in 1.18, that mean useInFuture will be set to true # Do not exist in 1.18, that mean useInFuture will be set to true
# useInFuture set to true also mean it will not warn if there is an issue # useInFuture set to true also mean it will not warn if there is an issue
restriction_swift_sneak: restriction_swift_sneak:
useInFuture: true useInFuture: true
enchantments: [ swift_sneak ] enchantments: [ minecraft:swift_sneak ]
notAffectedGroups: [ enchanted_book, leggings ] notAffectedGroups: [ enchanted_book, leggings ]
restriction_thorns: restriction_thorns:
enchantments: [ thorns ] enchantments: [ minecraft:thorns ]
notAffectedGroups: [ enchanted_book, armors ] notAffectedGroups: [ enchanted_book, armors ]
restriction_unbreaking: restriction__unbreaking:
enchantments: [ unbreaking ] enchantments: [ minecraft:unbreaking ]
notAffectedGroups: [ enchanted_book, can_unbreak ] notAffectedGroups: [ enchanted_book, can_unbreak ]
# ---------------------------------------------------- # ----------------------------------------------------
@ -180,60 +180,60 @@ restriction_unbreaking:
sword_enchant_conflict: sword_enchant_conflict:
enchantments: enchantments:
- bane_of_arthropods - minecraft:bane_of_arthropods
- smite - minecraft:smite
- sharpness - minecraft:sharpness
notAffectedGroups: [ ] notAffectedGroups: [ ]
maxEnchantmentBeforeConflict: 1 maxEnchantmentBeforeConflict: 1
protection_enchant_conflict: protection_enchant_conflict:
enchantments: enchantments:
- blast_protection - minecraft:blast_protection
- fire_protection - minecraft:fire_protection
- projectile_protection - minecraft:projectile_protection
- protection - minecraft:protection
notAffectedGroups: [ ] notAffectedGroups: [ ]
maxEnchantmentBeforeConflict: 1 maxEnchantmentBeforeConflict: 1
trident_conflict1: trident_conflict1:
enchantments: enchantments:
- channeling - minecraft:channeling
- riptide - minecraft:riptide
notAffectedGroups: [ ] notAffectedGroups: [ ]
maxEnchantmentBeforeConflict: 1 maxEnchantmentBeforeConflict: 1
trident_conflict2: trident_conflict2:
enchantments: enchantments:
- loyalty - minecraft:loyalty
- riptide - minecraft:riptide
notAffectedGroups: [ ] notAffectedGroups: [ ]
maxEnchantmentBeforeConflict: 1 maxEnchantmentBeforeConflict: 1
boot_conflict: boot_conflict:
enchantments: enchantments:
- depth_strider - minecraft:depth_strider
- frost_walker - minecraft:frost_walker
notAffectedGroups: [ ] notAffectedGroups: [ ]
maxEnchantmentBeforeConflict: 1 maxEnchantmentBeforeConflict: 1
tool_conflict: tool_conflict:
enchantments: enchantments:
- fortune - minecraft:fortune
- silk_touch - minecraft:silk_touch
notAffectedGroups: [ ] notAffectedGroups: [ ]
maxEnchantmentBeforeConflict: 1 maxEnchantmentBeforeConflict: 1
bow_conflict: bow_conflict:
enchantments: enchantments:
- mending - minecraft:mending
- infinity - minecraft:infinity
notAffectedGroups: [ ] notAffectedGroups: [ ]
maxEnchantmentBeforeConflict: 1 maxEnchantmentBeforeConflict: 1
crossbow_conflict: crossbow_conflict:
enchantments: enchantments:
- multishot - minecraft:multishot
- piercing - minecraft:piercing
notAffectedGroups: [ ] notAffectedGroups: [ ]
maxEnchantmentBeforeConflict: 1 maxEnchantmentBeforeConflict: 1