Compare commits

...

34 commits

Author SHA1 Message Date
eeff628da6
update from v1.x.x 2026-07-08 03:58:03 +02:00
b56782b234
remove legacy command 2026-07-08 03:53:23 +02:00
8078e54b15
rebase on news update 2026-07-08 03:52:39 +02:00
5e5493b0e8
prepare for v2 2026-07-08 03:52:37 +02:00
b5843756c7
rebase on new update 2026-07-08 03:52:16 +02:00
fba34fecb8
1.21 cleanup and fix
also random cleanup
2026-07-08 03:52:14 +02:00
aeda3d7112
fix from rebase 2026-07-08 03:51:50 +02:00
7ecfc12b5c
progress on 1.21 transition 2026-07-08 03:51:47 +02:00
007a664db1
initial 1.21 transition 2026-07-08 03:51:41 +02:00
cf768d67bd
more proper comment [ci skip] 2026-07-08 03:42:37 +02:00
4fc037ebce
version bump 2026-07-08 03:28:41 +02:00
a202df9f0a
add /ca enchant 2026-07-08 03:28:10 +02:00
c062684a3c
do not allow gui in tab completer
Some checks are pending
Java CI with Gradle / build (push) Waiting to run
2026-07-07 22:13:57 +02:00
99306b6fee
Per enchant and item config gui (#121)
Add a config GUI for in hand item and enchantments
2026-07-07 22:03:16 +02:00
b2561f55ae
per enchant config finished 2026-07-07 21:55:41 +02:00
341dd10e3f
start of enchant config gui 2026-07-07 17:27:32 +02:00
a9af606ae9
refactor gui item creation 2026-07-07 15:22:22 +02:00
23c7b0c753
disable create item if has filter 2026-07-07 12:33:20 +02:00
8ea1db382f
add custom recipe filter 2026-07-07 12:33:10 +02:00
bc9ac1cc13
add unit repair to item config 2026-07-07 12:33:10 +02:00
6178282386
append new unit repair as minecraft namespace 2026-07-07 12:33:09 +02:00
d1d01f90b8
unit repair gui and internal update 2026-07-07 12:33:09 +02:00
799008f652
reworked unit repair 2026-07-07 12:33:09 +02:00
a78f83f6f4
item config group config gui 2026-07-07 12:33:08 +02:00
25f676f7f3
enchant conflict working 2026-07-07 12:33:08 +02:00
554fba008e
made main command logic 2026-07-07 12:33:08 +02:00
5f0a601e5b
add edit config tab completer 2026-07-07 12:33:08 +02:00
a79e341ea8
add list gui filter 2026-07-07 12:33:07 +02:00
4c3b3b09ad
replace gui to config subcommand 2026-07-07 12:33:07 +02:00
f6f68d1971
add current minecraft version to update checker [ci skip] 2026-07-07 11:51:31 +02:00
460114ac01
add book on book
Some checks failed
Java CI with Gradle / build (push) Has been cancelled
2026-07-01 14:37:59 +02:00
d67d998dc1
remove legacy compatibility code 2026-07-01 12:18:57 +02:00
f1c3cf46e1
fix turtle scule unit repair and force migratation of sweeping edge 2026-07-01 12:13:13 +02:00
45dd92e0f4
prefer /ca reload over /configanvilreload 2026-07-01 10:15:34 +02:00
145 changed files with 1782 additions and 3075 deletions

View file

@ -9,9 +9,9 @@ name: Java CI with Gradle
on:
push:
branches: [ "v1.x.x", "v2.x.x" ]
branches: [ "v1.x.x", "v2.x.x", "v3.x.x" ]
pull_request:
branches: [ "v1.x.x", "v2.x.x" ]
branches: [ "v1.x.x", "v2.x.x", "v3.x.x" ]
release:
types: [published]
@ -26,7 +26,7 @@ jobs:
contents: write
env:
MODRINTH_VERSIONS: '["1.18.x", "1.19.x", "1.20.x", "1.21.x", "26.1.x", "26.2.x"]'
MODRINTH_VERSIONS: '["1.21.x", "26.1.x", "26.2.x"]'
MODRINTH_PLATFORMS: '["spigot", "paper", "purpur", "folia"]'
steps:

View file

@ -17,7 +17,7 @@ These plugins have compatibility handled by custom anvil. seek help on custom an
Also use ExcellentEnchant max enchant limit
- [EcoEnchant](https://www.spigotmc.org/resources/ecoenchants-%E2%AD%95-250-enchantments-%E2%9C%85-create-custom-enchants-%E2%9C%A8-essentials-cmi-support.79573/) by Auxilor:
Need to use /anvilconfigreload or a server restart to add newly added enchantment.
Need to use /ca reload or a server restart to add newly added enchantment.
Use EcoEnchant restriction system but new restriction can be added in custom anvil
- [Enchantment²](https://www.spigotmc.org/resources/enchants-squared-the-enchantsplus-rewrite-custom-enchantments-that-act-like-vanilla-ones.86747/) by Athlaeos:

View file

@ -39,7 +39,8 @@ ca.bypass.level: Allow player to bypass every level limit (no custom limit)
# Command permissions
ca.command.reload: Allow administrator to reload the plugin's configs
ca.command.diagnostic: Allow adminastator to diagnistic some simple problem with the plugin
ca.command.diagnostic: Get debug information about the plugin and server
ca.command.enchantment: Allows to set enchantment to holden item
ca.config.edit: Allow administrator to edit the plugin's config in game
# -----------------------------------------------------------------------------
@ -72,10 +73,9 @@ See the [Compatibility list](https://github.com/alexcrea/CustomAnvil/blob/v1.x.x
One of the configurations allow displaying price about 40 and removing Too Expensive. \
By how the minecraft client work: price above 40 can only be displayed green, even if the player does not own enough experience level.
spigot version 1.18 to 1.21.11 do not need any ProtocoLib dependency. (26.1.0 or above requires it) \
Any recent paper version also are supported for this feature.
But you should wait for update for new version containing new enchantable item or new enchantments if any of this got added.
Else it is, likely, fine to use the current version you are ussing on a new paper version
You do not need Protocolib unless you are using spigot above in 26.1 or above \
But you should wait for update or announcement for new version containing new enchantable item or new enchantments.
### For custom enchantment plugin developers
For information about the API, please refer to [the Wiki](https://github.com/alexcrea/CustomAnvil/wiki) \

View file

@ -22,7 +22,7 @@ plugins {
}
group = "xyz.alexcrea"
version = "1.17.6"
version = "2.0.0"
val isDevBuild = System.getenv("SMALL_COMMIT_HASH") != null
val isPreRelease = System.getenv("IS_GITHUB_PRERELEASE") == "true"
@ -55,7 +55,7 @@ val reobfNMS = providers.gradleProperty("subprojects.reobfnms")
dependencies {
// Spigot api
compileOnly("org.spigotmc:spigot-api:1.18-R0.1-SNAPSHOT")
compileOnly("org.spigotmc:spigot-api:1.21-R0.1-SNAPSHOT")
// fast stats
implementation("dev.faststats.metrics:bukkit:0.27.0")

View file

@ -1,6 +0,0 @@
### Default Plugin's Configurations For 1.18 to 1.20.6
- [config.yml](https://github.com/alexcrea/CustomAnvil/blob/master/defaultconfigs/1.18/config.yml)
- [enchant_conflict.yml](https://github.com/alexcrea/CustomAnvil/blob/master/defaultconfigs/1.18/enchant_conflict.yml)
- [item_groups.yml](https://github.com/alexcrea/CustomAnvil/blob/master/defaultconfigs/1.18/item_groups.yml)
- [unit_repair_item.yml](https://github.com/alexcrea/CustomAnvil/blob/master/defaultconfigs/1.18/unit_repair_item.yml)
- [custom_recipes.yml](https://github.com/alexcrea/CustomAnvil/blob/master/defaultconfigs/1.18/custom_recipes.yml)

View file

@ -1,472 +0,0 @@
#
# It is recommended that you use /configanvil to edit theses config.
# You can still manually edit here if you like to. but if you do, don't forget to /anvilconfigreload after you changes !
#
# What service of metric should custom anvil use
# Custom anvil collect generic information like server minecraft version, type, etc...
# It can also collect error information if error is happening (currently faststats only)
# It can also be disabled
# Please refer to README for public metric link
# Possible options: auto, bstat, faststats, disabled (auto by default)
metric_type: auto
# Allow to report errors made caused by this plugin (only for faststats)
# This allows me to fix potentials issue that I'm not aware of
# Accept true or false (true by default)
metric_collect_errors: true
# All anvil cost will be capped to limit_repair_value if enabled.
#
# In other words:
# For any anvil cost greater than limit_repair_value, Cost will be set to limit_repair_value.
limit_repair_cost: false
# Max cost value the Anvil can get to.
#
# Valid values include 0 to 1000.
# Cost will be displayed as "Too Expensive":
# - If Cost is above 39
# - And replace_too_expensive is disabled (false)
limit_repair_value: 39
# Whether the anvil's cost limit should be removed entirely.
#
# The anvil will still visually display "Too Expensive" if "replace_too_expensive" is disabled
# However, the action will be completable if xp requirement is meet.
remove_repair_limit: false
# Whenever anvil cost is above 39 should display the true price and not "Too Expensive".
#
# However, when bypassing "Too Expensive", anvil price will be displayed as Green.
# If the action is not completable, the cost will still be displayed as "Too expensive".
# That mean you also need to change other settings like remove_repair_limit or limit_repair_cost.
#
# Require ProtocoLib.
replace_too_expensive: false
# XP Level amount added to the anvil when the item is repaired by another item of the same type
#
# Valid values include 0 to 1000
item_repair_cost: 2
# XP Level amount added to the anvil when the item is renamed
#
# Valid values include 0 to 1000
item_rename_cost: 1
# XP Level amount added to the anvil when the item is repaired by an "unit"
# For example: a Diamond on a Diamond Sword
# What's considered unit for what can be edited on the unit repair configuration.
#
# Valid values include 0 to 1000
unit_repair_cost: 1
# XP Level amount added to the anvil when a sacrifice enchantment
# conflict with one of the left item enchantment
#
# Valid values include 0 to 1000
sacrifice_illegal_enchant_cost: 1
# Allow using color code and hexadecimal color.
#
# Color code are prefixed by "&" and hexadecimal color by "#".
# Color code will not be applied if it colors nothing. "&&" can be used to write "&".
# For minimessage see minimessage formating https://docs.papermc.io/adventure/minimessage/format/
allow_color_code: false
allow_hexadecimal_color: false
allow_minimessage: false
# This enables restricting color code for player having specific permission
# It requires allow_color_code enabled for... obvious reasons
#
# For example: if player want to use "&aHello" it will be required that the player has
# the permission "ca.color.code.a" as he used the color code "a"
# In general permission to give to the player is "ca.color.code.[code]"
# where [code] is the color code you wish to allow the player
#
# It is kinda of useless when minimessage is supported as players would be able to bypass
# that using the equivalent minimessage tag
per_color_code_permission: false
# Toggle if color should only be applicable if the player a certain permission.
#
# permission are "ca.color.code" for use of color code and "ca.color.hex" for use of hexadecimal color.
permission_needed_for_color: true
# Xp cost if the player use color in the items name on rename.
#
# Valid values include 0 to 1000.
use_of_color_cost: 0
# Dialogue rename menu make use of dialog menu to allow bigger rename
# You can also change the maximum size and set it to -1 or less for maximum
#
# This feature only work on paper 1.21.7 or later
#
# At the moment only english is available for this menu... sorry !
#
# CustomAnvil use "ca.rename.dialog" when permission
enable_dialog_rename: false
dialog_rename_max_size: 256
permission_needed_for_dialog_rename: false
# This allows custom anvil to not "guess" the text used for rename but store it in the item
# It will make item stackable only and only if it had used the same rename text
#
# For practical reason. this only work when dialog rename is enabled
dialog_rename_keep_user_text: true
# Also count left item enchantments for the final price
include_left_enchantment_for_cost: false
# Override limits for specific enchants
#
# Enchantments not listed here will use the value of default_limit
#
# Overrides provided default from aqua_affinity to depth_strider won't change effect with extra levels
#
# Valid range of 0 - 255 for each enchantment
# -1 mean keep default
enchant_limits:
minecraft:aqua_affinity: 1
minecraft:binding_curse: 1
minecraft:channeling: 1
minecraft:flame: 1
minecraft:infinity: 1
minecraft:mending: 1
minecraft:multishot: 1
minecraft:silk_touch: 1
minecraft:vanishing_curse: 1
minecraft:depth_strider: 3 # anything more than 3 is treated as 3 by the game
minecraft:protection: 4
minecraft:fire_protection: 4
minecraft:blast_protection: 4
minecraft:projectile_protection: 4
minecraft:feather_falling: 4
minecraft:thorns: 3
minecraft:respiration: 3
minecraft:sharpness: 5
minecraft:smite: 5
minecraft:bane_of_arthropods: 5
minecraft:knockback: 2
minecraft:fire_aspect: 2
minecraft:looting: 3
minecraft:sweeping: 3
minecraft:sweeping_edge: 3
minecraft:efficiency: 5
minecraft:unbreaking: 3
minecraft:fortune: 3
minecraft:power: 5
minecraft:punch: 2
minecraft:luck_of_the_sea: 3
minecraft:lure: 3
minecraft:frost_walker: 2
minecraft:impaling: 5
minecraft:riptide: 3
minecraft:loyalty: 3
minecraft:piercing: 4
minecraft:quick_charge: 3
minecraft:soul_speed: 3
minecraft:swift_sneak: 3
# Multipliers used to calculate the enchantment's value in repair/combining
#
# Values here are pulled from the minecraft wiki:
# https://minecraft.wiki/w/Anvil_mechanics#Costs_for_combining_enchantments
#
# If an enchantment is missing values here, or is less than 0, it will default to 0
#
# Calculated as: [Enchantment lvl] * [multiplier]
#
# With default values protection 4 would have a value of 4 when
# coming from either a book (4 * 1) or an item (4 * 1)
enchant_values:
minecraft:aqua_affinity:
item: 4
book: 2
minecraft:bane_of_arthropods:
item: 2
book: 1
minecraft:binding_curse:
item: 8
book: 4
minecraft:blast_protection:
item: 4
book: 2
minecraft:channeling:
item: 8
book: 4
minecraft:depth_strider:
item: 4
book: 2
minecraft:efficiency:
item: 1
book: 1
minecraft:flame:
item: 4
book: 2
minecraft:feather_falling:
item: 2
book: 1
minecraft:fire_aspect:
item: 4
book: 2
minecraft:fire_protection:
item: 2
book: 1
minecraft:fortune:
item: 4
book: 2
minecraft:frost_walker:
item: 4
book: 2
minecraft:impaling:
item: 4
book: 2
minecraft:infinity:
item: 8
book: 4
minecraft:knockback:
item: 2
book: 1
minecraft:looting:
item: 4
book: 2
minecraft:loyalty:
item: 1
book: 1
minecraft:luck_of_the_sea:
item: 4
book: 2
minecraft:lure:
item: 4
book: 2
minecraft:mending:
item: 4
book: 2
minecraft:multishot:
item: 4
book: 2
minecraft:piercing:
item: 1
book: 1
minecraft:power:
item: 1
book: 1
minecraft:projectile_protection:
item: 2
book: 1
minecraft:protection:
item: 1
book: 1
minecraft:punch:
item: 4
book: 2
minecraft:quick_charge:
item: 2
book: 1
minecraft:respiration:
item: 4
book: 2
minecraft:riptide:
item: 4
book: 2
minecraft:silk_touch:
item: 8
book: 4
minecraft:sharpness:
item: 1
book: 1
minecraft:smite:
item: 2
book: 1
minecraft:soul_speed:
item: 8
book: 4
minecraft:swift_sneak:
item: 8
book: 4
minecraft:sweeping:
item: 4
book: 2
minecraft:sweeping_edge:
item: 4
book: 2
minecraft:thorns:
item: 8
book: 4
minecraft:unbreaking:
item: 2
book: 1
minecraft:vanishing_curse:
item: 8
book: 4
# Disable enchantment merging for level above the set value
# Enchantment merging is when, for example, 2 unbreaking II book combine to give sharpness III
# But Enchantment above this value can still be applied. following the previous example, we could still apply a unbreaking III book to a sword
# Even if disable-merge-over of unbreaking is set to 2
# -1 mean enchantment merge for this enchantment is not disabled. default to -1 if absent.
disable-merge-over:
# Sharpness is set to -1. it equivalent to it not being set to anything (and work as vanilla on default configuration)
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
# The maximum number of enchantment an item can get. -1 for infinity
# Use eco enchant enchant_limit if present by default unless "default" is not equal to -1
enchantment_count_limit:
default: -1
# Limit for specific items. example bellow is an example with stick
# Per item enchantment limit override eco enchant enchant_limit and default limit
items:
stick: -1
# Settings for lore modification
lore_edit:
book_and_quil:
# Permission is ca.lore_edit.book
use_permission: true
append:
# If adding lore using book & quil is enabled
enabled: false
# Cost used every time
fixed_cost: 1
# Cost used for every lore line added
per_line_cost: 0
# Use left item vanilla cost penalty if any
shared_increase: false
# Increase shared left item cost penalty
shared_additive: false
# If adding the lore consume the book & quil
do_consume: false
# Allow using color code and hexadecimal color when editing lore via book & quil
#
# Color code are prefixed by "&" and hexadecimal color by "#"
# Color code will not be applied if it colors nothing. "&&" can be used to write "&"
# For minimessage see minimessage formating https://docs.papermc.io/adventure/minimessage/format/
#
# Note that currently minimessage would disable hex code when adding color
allow_color_code: true
allow_hexadecimal_color: false
allow_minimessage: true
remove:
# If removing lore using book & quil is enabled
enabled: false
# Cost used every time
fixed_cost: 1
# Cost used for every lore line removed
per_line_cost: 0
# Use left item vanilla cost penalty if any
shared_increase: false
# Increase shared left item cost penalty
shared_additive: false
# If removing the lore consume the book & quil
do_consume: false
# Cost of replacing colors
remove_color_cost: 0
# Allowed some color and tags to be reverted to plain text
# Custom anvil will prioritise format that result is a smaller resulting text
# Note that not allowing certain format will lead to some lost of color or tags.
# If configuration are exact as append appending this book should result in the exact same color
#
# Color code will be prefixed by "&" and hexadecimal color by "#".
# If color code is allowed, "&" in the text will get converted to "&&"
# For minimessage see minimessage formating https://docs.papermc.io/adventure/minimessage/format/
allow_color_code: true
allow_hexadecimal_color: false
allow_minimessage: true
paper:
# Permission is ca.lore_edit.paper
use_permission: true
# what order should the lines should get added/removed (start/end, if invalid or not present will be end)
order: end
append_line:
# If adding lore line using paper is enabled
enabled: false
# Cost used every time
fixed_cost: 1
# Use left item vanilla cost penalty if any
shared_increase: false
# Increase shared left item cost penalty
shared_additive: false
# If adding the lore line consume the paper
do_consume: false
# Allow using color code and hexadecimal color when editing lore via book & quil
#
# Color code are prefixed by "&" and hexadecimal color by "#"
# Color code will not be applied if it colors nothing. "&&" can be used to write "&"
# For minimessage see minimessage formating https://docs.papermc.io/adventure/minimessage/format/
#
# Note that currently minimessage would disable hex code when adding color
allow_color_code: true
allow_hexadecimal_color: false
allow_minimessage: true
color_use_cost: 0
remove_line:
# If removing lore line using paper is enabled
enabled: false
# Cost used every time
fixed_cost: 1
# Use left item vanilla cost penalty if any
shared_increase: false
# Increase shared left item cost penalty
shared_additive: false
# If removing the lore line consume the paper
do_consume: false
# Cost of replacing colors
remove_color_cost: 0
# Allowed some color and tags to be reverted to plain text
# Custom anvil will prioritise format that result is a smaller resulting text
# Note that not allowing certain format will lead to some lost of color or tags.
# If configuration are exact as append appending this paper should result in the exact same color
#
# Color code will be prefixed by "&" and hexadecimal color by "#".
# If color code is allowed, "&" in the text will get converted to "&&"
# For minimessage see minimessage formating https://docs.papermc.io/adventure/minimessage/format/
allow_color_code: true
allow_hexadecimal_color: false
allow_minimessage: true
# Allow to replace the xp cost by a monetary cost
# If enabled it will not be bound to the experience level limits
#
# It also requires to enable dialog rename (set "enable_dialog_rename: false" a bit higher)
# If dialog rename permission is enabled and player do not have the permission merge will fall back to vanilla xp cost
#
# If you are using custom craft I recommend using Linear Xp Cost with Exact Linear Xp as normal Xp Cost will act "weird"
# But Linear Xp will act as 1$ time global multiplier. In other word: like you expect
#
# As this feature require dialog rename, it can only be enabled starting with paper 1.21.6 and later
monetary_cost:
enabled: false
# If using vault unlocked this allow to specify what currency should be used for anvil usage
# default being the default currency
currency: default
# multiply the anvil cost by a value to allow to have price a big bigger than like 40
multipliers:
# global multipliers. all usage type will be multiplied by this value
global: 1.0
# usage specific type. it will only apply for specific xp "reason"
enchantment: 1.0 # related to enchantments level
repair: 1.0 # for repairing via unit repair (per unit)
rename: 1.0 # for renaming the item
lore_edit: 1.0 # for changing the lore of the item (only if lore edit is enabled)
work_penalty: 1.0 # for work penalty (aka use penalty)
recipe: 1.0 # for custom anvil recipe cost
# Whether to show debug logging
debug_log: false
# Whether to show verbose debug logging
debug_log_verbose: false
# Whether to show inside the console or require to run /ca debug get
display_debug_in_console: false
configVersion: 1.11.0

View file

@ -1,5 +0,0 @@
# ----------------------------------------------------
# This config file is to store custom craft
# It is recommended to use the in game config editor for this configuration.
# /customanvilconfig With ca.config.edit permission
# ----------------------------------------------------

View file

@ -1,247 +0,0 @@
#
# It is recommended that you use /configanvil to edit theses config.
# You can still manually edit here if you like to. but if you do, don't forget to /anvilconfigreload after you changes !
#
# material conflicts
#
# If you want to edit this file:
# - A conflict will apply to every item except if in one of the notAffectedGroups group
# - the conflict will count only if the user try to combine at least as
# many conflicting enchantment as "maxEnchantmentBeforeConflict"
#
#
# ----------------------------------------------------
# These restriction are about not allowing enchantment
# on illegal items
# ----------------------------------------------------
restriction_aqua_affinity:
enchantments: [ minecraft:aqua_affinity ]
notAffectedGroups: [ enchanted_book, helmets ]
restriction_bane_of_arthropods:
enchantments: [ minecraft:bane_of_arthropods ]
notAffectedGroups: [ enchanted_book, melee_weapons ]
restriction_blast_protection:
enchantments: [ minecraft:blast_protection ]
notAffectedGroups: [ enchanted_book, armors ]
restriction_channeling:
enchantments: [ minecraft:channeling ]
notAffectedGroups: [ enchanted_book, trident ]
restriction_binding_curse:
enchantments: [ minecraft:binding_curse ]
notAffectedGroups: [ enchanted_book, wearable ]
restriction_vanishing_curse:
enchantments: [ minecraft:vanishing_curse ]
notAffectedGroups: [ enchanted_book, can_vanish ]
restriction_depth_strider:
enchantments: [ minecraft:depth_strider ]
notAffectedGroups: [ enchanted_book, boots ]
restriction_efficiency:
enchantments: [ minecraft:efficiency ]
notAffectedGroups: [ enchanted_book, tools, shears ]
restriction_feather_falling:
enchantments: [ minecraft:feather_falling ]
notAffectedGroups: [ enchanted_book, boots ]
restriction_fire_aspect:
enchantments: [ minecraft:fire_aspect ]
notAffectedGroups: [ enchanted_book, swords ]
restriction_fire_protection:
enchantments: [ minecraft:fire_protection ]
notAffectedGroups: [ enchanted_book, armors ]
restriction_flame:
enchantments: [ minecraft:flame ]
notAffectedGroups: [ enchanted_book, bow ]
restriction_fortune:
enchantments: [ minecraft:fortune ]
notAffectedGroups: [ enchanted_book, tools ]
restriction_frost_walker:
enchantments: [ minecraft:frost_walker ]
notAffectedGroups: [ enchanted_book, boots ]
restriction_impaling:
enchantments: [ minecraft:impaling ]
notAffectedGroups: [ enchanted_book, trident ]
restriction_infinity:
enchantments: [ minecraft:infinity ]
notAffectedGroups: [ enchanted_book, bow ]
restriction_knockback:
enchantments: [ minecraft:knockback ]
notAffectedGroups: [ enchanted_book, swords ]
restriction_looting:
enchantments: [ minecraft:looting ]
notAffectedGroups: [ enchanted_book, swords ]
restriction_loyalty:
enchantments: [ minecraft:loyalty ]
notAffectedGroups: [ enchanted_book, trident ]
restriction_luck_of_the_sea:
enchantments: [ minecraft:luck_of_the_sea ]
notAffectedGroups: [ enchanted_book, fishing_rod ]
restriction_lure:
enchantments: [ minecraft:lure ]
notAffectedGroups: [ enchanted_book, fishing_rod ]
restriction_mending:
enchantments: [ minecraft:mending ]
notAffectedGroups: [ enchanted_book, can_unbreak ]
restriction_minecraft_multishot:
enchantments: [ minecraft:multishot ]
notAffectedGroups: [ enchanted_book, crossbow ]
restriction_piercing:
enchantments: [ minecraft:piercing ]
notAffectedGroups: [ enchanted_book, crossbow ]
restriction_power:
enchantments: [ minecraft:power ]
notAffectedGroups: [ enchanted_book, bow ]
restriction_projectile_protection:
enchantments: [ minecraft:projectile_protection ]
notAffectedGroups: [ enchanted_book, armors ]
restriction_protection:
enchantments: [ minecraft:protection ]
notAffectedGroups: [ enchanted_book, armors ]
restriction_punch:
enchantments: [ minecraft:punch ]
notAffectedGroups: [ enchanted_book, bow ]
restriction_quick_charge:
enchantments: [ minecraft:quick_charge ]
notAffectedGroups: [ enchanted_book, crossbow ]
restriction_respiration:
enchantments: [ minecraft:respiration ]
notAffectedGroups: [ enchanted_book, helmets ]
restriction_riptide:
enchantments: [ minecraft:riptide ]
notAffectedGroups: [ enchanted_book, trident ]
restriction_sharpness:
enchantments: [ minecraft:sharpness ]
notAffectedGroups: [ enchanted_book, melee_weapons ]
restriction__silk_touch:
enchantments: [ minecraft:silk_touch ]
notAffectedGroups: [ enchanted_book, tools ]
restriction_smite:
enchantments: [ minecraft:smite ]
notAffectedGroups: [ enchanted_book, melee_weapons ]
restriction_soul_speed:
enchantments: [ minecraft:soul_speed ]
notAffectedGroups: [ enchanted_book, boots ]
restriction_sweeping_edge:
enchantments: [ minecraft:sweeping, minecraft:sweeping_edge ]
notAffectedGroups: [ enchanted_book, swords ]
# 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
restriction_swift_sneak:
useInFuture: true
enchantments: [ minecraft:swift_sneak ]
notAffectedGroups: [ enchanted_book, leggings ]
restriction_thorns:
enchantments: [ minecraft:thorns ]
notAffectedGroups: [ enchanted_book, armors ]
restriction__unbreaking:
enchantments: [ minecraft:unbreaking ]
notAffectedGroups: [ enchanted_book, can_unbreak ]
# ----------------------------------------------------
# Now we have conflicts about enchantment Incompatibility
# We just filtered what item enchantments can be applied
# notAffectedGroups is empty as we don't want anything to not respect theses rules
# maxEnchantmentBeforeConflict is set to 1 to only have 1 on those enchantment available
# ----------------------------------------------------
sword_enchant_conflict:
enchantments:
- minecraft:bane_of_arthropods
- minecraft:smite
- minecraft:sharpness
notAffectedGroups: [ ]
maxEnchantmentBeforeConflict: 1
protection_enchant_conflict:
enchantments:
- minecraft:blast_protection
- minecraft:fire_protection
- minecraft:projectile_protection
- minecraft:protection
notAffectedGroups: [ ]
maxEnchantmentBeforeConflict: 1
trident_conflict1:
enchantments:
- minecraft:channeling
- minecraft:riptide
notAffectedGroups: [ ]
maxEnchantmentBeforeConflict: 1
trident_conflict2:
enchantments:
- minecraft:loyalty
- minecraft:riptide
notAffectedGroups: [ ]
maxEnchantmentBeforeConflict: 1
boot_conflict:
enchantments:
- minecraft:depth_strider
- minecraft:frost_walker
notAffectedGroups: [ ]
maxEnchantmentBeforeConflict: 1
tool_conflict:
enchantments:
- minecraft:fortune
- minecraft:silk_touch
notAffectedGroups: [ ]
maxEnchantmentBeforeConflict: 1
bow_conflict:
enchantments:
- minecraft:mending
- minecraft:infinity
notAffectedGroups: [ ]
maxEnchantmentBeforeConflict: 1
crossbow_conflict:
enchantments:
- minecraft:multishot
- minecraft:piercing
notAffectedGroups: [ ]
maxEnchantmentBeforeConflict: 1
# ----------------------------------------------------
# Bellow is for custom conflicts.
# This is also where conflict create from the gui will be placed.
# ----------------------------------------------------

View file

@ -1,210 +0,0 @@
#
# It is recommended that you use /configanvil to edit theses config.
# You can still manually edit here if you like to. but if you do, don't forget to /anvilconfigreload after you changes !
#
# Please note this config use spigot material names.
# It should match minecraft name in most case, maybe every case, but I can't be sure
# In case there an issue with material name, you can found them here:
# https://hub.spigotmc.org/javadocs/spigot/org/bukkit/Material.html
# An empty Exclude group exclude nothing, so it contain everything
everything:
type: exclude
# An empty include group will include nothing
nothing:
type: include
# This group is an example of a group including only stone and polished granite
example_include:
type: include
items:
- stone
- polished_granite
# This group contain everything except polished granite and elements of example_include
example_exclude:
type: exclude
items:
- polished_granite
groups:
- example_include
# Default configuration should be vanilla enchantment conflict group
# there may have error, if you find one you can fix it !
# https://minecraft.fandom.com/wiki/Enchanting
swords:
type: include
items:
- wooden_sword
- stone_sword
- iron_sword
- diamond_sword
- golden_sword
- netherite_sword
axes:
type: include
items:
- wooden_axe
- stone_axe
- iron_axe
- diamond_axe
- golden_axe
- netherite_axe
melee_weapons:
type: include
groups:
- swords
- axes
helmets:
type: include
items:
- leather_helmet
- chainmail_helmet
- iron_helmet
- diamond_helmet
- golden_helmet
- netherite_helmet
- turtle_helmet
chestplate:
type: include
items:
- leather_chestplate
- chainmail_chestplate
- iron_chestplate
- diamond_chestplate
- golden_chestplate
- netherite_chestplate
leggings:
type: include
items:
- leather_leggings
- chainmail_leggings
- iron_leggings
- diamond_leggings
- golden_leggings
- netherite_leggings
boots:
type: include
items:
- leather_boots
- chainmail_boots
- iron_boots
- diamond_boots
- golden_boots
- netherite_boots
armors:
type: include
groups:
- helmets
- chestplate
- leggings
- boots
wearable:
type: include
items:
- elytra
- carved_pumpkin
- skeleton_skull
- wither_skeleton_skull
- zombie_head
- player_head
- creeper_head
- dragon_head
# do not exist in 1.18 but exist in future update
- piglin_head
groups:
- armors
tools:
type: include
items:
- wooden_pickaxe
- stone_pickaxe
- iron_pickaxe
- diamond_pickaxe
- golden_pickaxe
- netherite_pickaxe
- wooden_shovel
- stone_shovel
- iron_shovel
- diamond_shovel
- golden_shovel
- netherite_shovel
- wooden_hoe
- stone_hoe
- iron_hoe
- diamond_hoe
- golden_hoe
- netherite_hoe
groups:
- axes
enchanted_book:
type: include
items:
- enchanted_book
trident:
type: include
items:
- trident
bow:
type: include
items:
- bow
crossbow:
type: include
items:
- crossbow
fishing_rod:
type: include
items:
- fishing_rod
shears:
type: include
items:
- shears
can_unbreak:
type: include
items:
- elytra
- flint_and_steel
- shield
- carrot_on_a_stick
- warped_fungus_on_a_stick
# do not exist in 1.18 but exist in future update
- brush
groups:
- melee_weapons
- tools
- armors
- trident
- bow
- crossbow
- fishing_rod
- shears
can_vanish:
type: include
items:
- compass
groups:
- wearable
- can_unbreak

View file

@ -1,190 +0,0 @@
#
# It is recommended that you use /configanvil to edit theses config.
# You can still manually edit here if you like to. but if you do, don't forget to /anvilconfigreload after you changes !
#
# Unit repair configuration
#
# This configuration is to make custom unit repair
# A unit repair is, for example, a diamond to repair a diamond sword
# In vanilla, a unit repair 25% of object durability
# you can make a custom value here
#
# Item name should NOT combine caps and no caps (example: Stone)
# Default value if the config is an invalid value (value <= 0 )
# If value > 1 it will be treated as being = 1
default_repair_amount: 0.25
# You can add custom unit repair
# The example bellow make a shield repaired by 10% by sticks
#stick:
# shield: 0.10
# Vanilla unit repair group is bellow
diamond:
diamond_helmet: 0.25
diamond_chestplate: 0.25
diamond_leggings: 0.25
diamond_boots: 0.25
diamond_sword: 0.25
diamond_pickaxe: 0.25
diamond_axe: 0.25
diamond_shovel: 0.25
diamond_hoe: 0.25
netherite_ingot:
netherite_helmet: 0.25
netherite_chestplate: 0.25
netherite_leggings: 0.25
netherite_boots: 0.25
netherite_sword: 0.25
netherite_pickaxe: 0.25
netherite_axe: 0.25
netherite_shovel: 0.25
netherite_hoe: 0.25
gold_ingot:
golden_helmet: 0.25
golden_chestplate: 0.25
golden_leggings: 0.25
golden_boots: 0.25
golden_sword: 0.25
golden_pickaxe: 0.25
golden_axe: 0.25
golden_shovel: 0.25
golden_hoe: 0.25
iron_ingot:
iron_helmet: 0.25
iron_chestplate: 0.25
iron_leggings: 0.25
iron_boots: 0.25
iron_sword: 0.25
iron_pickaxe: 0.25
iron_axe: 0.25
iron_shovel: 0.25
iron_hoe: 0.25
cobblestone:
stone_sword: 0.25
stone_pickaxe: 0.25
stone_axe: 0.25
stone_shovel: 0.25
stone_hoe: 0.25
cobbled_deepslate:
stone_sword: 0.25
stone_pickaxe: 0.25
stone_axe: 0.25
stone_shovel: 0.25
stone_hoe: 0.25
blackstone:
stone_sword: 0.25
stone_pickaxe: 0.25
stone_axe: 0.25
stone_shovel: 0.25
stone_hoe: 0.25
leather:
leather_helmet: 0.25
leather_chestplate: 0.25
leather_leggings: 0.25
leather_boots: 0.25
phantom_membrane:
elytra: 0.25
scute:
turtle_helmet: 0.25
oak_planks:
wooden_sword: 0.25
wooden_pickaxe: 0.25
wooden_axe: 0.25
wooden_shovel: 0.25
wooden_hoe: 0.25
shield: 0.25
spruce_planks:
wooden_sword: 0.25
wooden_pickaxe: 0.25
wooden_axe: 0.25
wooden_shovel: 0.25
wooden_hoe: 0.25
shield: 0.25
birch_planks:
wooden_sword: 0.25
wooden_pickaxe: 0.25
wooden_axe: 0.25
wooden_shovel: 0.25
wooden_hoe: 0.25
shield: 0.25
jungle_planks:
wooden_sword: 0.25
wooden_pickaxe: 0.25
wooden_axe: 0.25
wooden_shovel: 0.25
wooden_hoe: 0.25
shield: 0.25
acacia_planks:
wooden_sword: 0.25
wooden_pickaxe: 0.25
wooden_axe: 0.25
wooden_shovel: 0.25
wooden_hoe: 0.25
shield: 0.25
dark_oak_planks:
wooden_sword: 0.25
wooden_pickaxe: 0.25
wooden_axe: 0.25
wooden_shovel: 0.25
wooden_hoe: 0.25
shield: 0.25
mangrove_planks:
wooden_sword: 0.25
wooden_pickaxe: 0.25
wooden_axe: 0.25
wooden_shovel: 0.25
wooden_hoe: 0.25
shield: 0.25
cherry_planks:
wooden_sword: 0.25
wooden_pickaxe: 0.25
wooden_axe: 0.25
wooden_shovel: 0.25
wooden_hoe: 0.25
shield: 0.25
bamboo_planks:
wooden_sword: 0.25
wooden_pickaxe: 0.25
wooden_axe: 0.25
wooden_shovel: 0.25
wooden_hoe: 0.25
shield: 0.25
crimson_planks:
wooden_sword: 0.25
wooden_pickaxe: 0.25
wooden_axe: 0.25
wooden_shovel: 0.25
wooden_hoe: 0.25
shield: 0.25
warped_planks:
wooden_sword: 0.25
wooden_pickaxe: 0.25
wooden_axe: 0.25
wooden_shovel: 0.25
wooden_hoe: 0.25
shield: 0.25

View file

@ -1,6 +1,6 @@
#
# It is recommended that you use /configanvil to edit theses config.
# You can still manually edit here if you like to. but if you do, don't forget to /anvilconfigreload after you changes !
# You can still manually edit here if you like to. but if you do, don't forget to /ca reload after you changes !
#
# What service of metric should custom anvil use
@ -154,7 +154,6 @@ enchant_limits:
minecraft:knockback: 2
minecraft:fire_aspect: 2
minecraft:looting: 3
minecraft:sweeping: 3
minecraft:sweeping_edge: 3
minecraft:efficiency: 5
minecraft:unbreaking: 3
@ -293,9 +292,6 @@ enchant_values:
minecraft:swift_sneak:
item: 8
book: 4
minecraft:sweeping:
item: 4
book: 2
minecraft:sweeping_edge:
item: 4
book: 2
@ -489,5 +485,5 @@ debug_log_verbose: false
# Whether to show inside the console or require to run /ca debug get
display_debug_in_console: false
configVersion: 1.15.5
configVersion: 1.17.7
lowMinecraftVersion: 1.21.11

View file

@ -1,6 +1,6 @@
#
# It is recommended that you use /configanvil to edit theses config.
# You can still manually edit here if you like to. but if you do, don't forget to /anvilconfigreload after you changes !
# You can still manually edit here if you like to. but if you do, don't forget to /ca reload after you changes !
#
# material conflicts
@ -270,7 +270,6 @@ restriction_soul_speed:
restriction_sweeping_edge:
enchantments:
- minecraft:sweeping
- minecraft:sweeping_edge
notAffectedGroups:
- enchanted_book

View file

@ -1,6 +1,6 @@
#
# It is recommended that you use /configanvil to edit theses config.
# You can still manually edit here if you like to. but if you do, don't forget to /anvilconfigreload after you changes !
# You can still manually edit here if you like to. but if you do, don't forget to /ca reload after you changes !
#
# Please note this config use spigot material names.

View file

@ -1,6 +1,6 @@
#
# It is recommended that you use /configanvil to edit theses config.
# You can still manually edit here if you like to. but if you do, don't forget to /anvilconfigreload after you changes !
# You can still manually edit here if you like to. but if you do, don't forget to /ca reload after you changes !
#
# Unit repair configuration
@ -104,7 +104,7 @@ leather:
phantom_membrane:
elytra: 0.25
scute:
turtle_scute:
turtle_helmet: 0.25
oak_planks:

View file

@ -1,6 +1,6 @@
#
# It is recommended that you use /configanvil to edit theses config.
# You can still manually edit here if you like to. but if you do, don't forget to /anvilconfigreload after you changes !
# You can still manually edit here if you like to. but if you do, don't forget to /ca reload after you changes !
#
# What service of metric should custom anvil use
@ -152,7 +152,6 @@ enchant_limits:
minecraft:knockback: 2
minecraft:fire_aspect: 2
minecraft:looting: 3
minecraft:sweeping: 3
minecraft:sweeping_edge: 3
minecraft:efficiency: 5
minecraft:unbreaking: 3
@ -290,9 +289,6 @@ enchant_values:
minecraft:swift_sneak:
item: 8
book: 4
minecraft:sweeping:
item: 4
book: 2
minecraft:sweeping_edge:
item: 4
book: 2

View file

@ -1,6 +1,6 @@
#
# It is recommended that you use /configanvil to edit theses config.
# You can still manually edit here if you like to. but if you do, don't forget to /anvilconfigreload after you changes !
# You can still manually edit here if you like to. but if you do, don't forget to /ca reload after you changes !
#
# material conflicts
@ -267,7 +267,6 @@ restriction_soul_speed:
restriction_sweeping_edge:
enchantments:
- minecraft:sweeping
- minecraft:sweeping_edge
notAffectedGroups:
- enchanted_book

View file

@ -1,6 +1,6 @@
#
# It is recommended that you use /configanvil to edit theses config.
# You can still manually edit here if you like to. but if you do, don't forget to /anvilconfigreload after you changes !
# You can still manually edit here if you like to. but if you do, don't forget to /ca reload after you changes !
#
# Please note this config use spigot material names.

View file

@ -1,6 +1,6 @@
#
# It is recommended that you use /configanvil to edit theses config.
# You can still manually edit here if you like to. but if you do, don't forget to /anvilconfigreload after you changes !
# You can still manually edit here if you like to. but if you do, don't forget to /ca reload after you changes !
#
# Unit repair configuration
@ -98,7 +98,7 @@ leather:
phantom_membrane:
elytra: 0.25
scute:
turtle_scute:
turtle_helmet: 0.25
oak_planks:

View file

@ -1,6 +1,6 @@
#
# It is recommended that you use /configanvil to edit theses config.
# You can still manually edit here if you like to. but if you do, don't forget to /anvilconfigreload after you changes !
# You can still manually edit here if you like to. but if you do, don't forget to /ca reload after you changes !
#
# What service of metric should custom anvil use
@ -152,7 +152,6 @@ enchant_limits:
minecraft:knockback: 2
minecraft:fire_aspect: 2
minecraft:looting: 3
minecraft:sweeping: 3
minecraft:sweeping_edge: 3
minecraft:efficiency: 5
minecraft:unbreaking: 3
@ -287,9 +286,6 @@ enchant_values:
minecraft:swift_sneak:
item: 8
book: 4
minecraft:sweeping:
item: 4
book: 2
minecraft:sweeping_edge:
item: 4
book: 2

View file

@ -1,6 +1,6 @@
#
# It is recommended that you use /configanvil to edit theses config.
# You can still manually edit here if you like to. but if you do, don't forget to /anvilconfigreload after you changes !
# You can still manually edit here if you like to. but if you do, don't forget to /ca reload after you changes !
#
# material conflicts
@ -157,13 +157,10 @@ restriction_soul_speed:
notAffectedGroups: [ enchanted_book, boots ]
restriction_sweeping_edge:
enchantments: [ minecraft:sweeping, minecraft:sweeping_edge ]
enchantments: [ minecraft:sweeping_edge ]
notAffectedGroups: [ enchanted_book, swords ]
# 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
restriction_swift_sneak:
useInFuture: true
enchantments: [ minecraft:swift_sneak ]
notAffectedGroups: [ enchanted_book, leggings ]

View file

@ -1,6 +1,6 @@
#
# It is recommended that you use /configanvil to edit theses config.
# You can still manually edit here if you like to. but if you do, don't forget to /anvilconfigreload after you changes !
# You can still manually edit here if you like to. but if you do, don't forget to /ca reload after you changes !
#
# Please note this config use spigot material names.

View file

@ -1,6 +1,6 @@
#
# It is recommended that you use /configanvil to edit theses config.
# You can still manually edit here if you like to. but if you do, don't forget to /anvilconfigreload after you changes !
# You can still manually edit here if you like to. but if you do, don't forget to /ca reload after you changes !
#
# Unit repair configuration
@ -98,7 +98,7 @@ leather:
phantom_membrane:
elytra: 0.25
scute:
turtle_scute:
turtle_helmet: 0.25
oak_planks:

View file

@ -1,5 +1,4 @@
### Default Plugin's Configurations
From 1.18 to 1.20.6 use [1.18 configurations](https://github.com/alexcrea/CustomAnvil/tree/master/defaultconfigs/1.18) \
From 1.21 to 1.21.8 use [1.21 configurations](https://github.com/alexcrea/CustomAnvil/tree/master/defaultconfigs/1.21) \
From 1.21.9 to 1.21.10 use [1.21.9 configurations](https://github.com/alexcrea/CustomAnvil/tree/master/defaultconfigs/1.21.9) \
From 1.21.11 use [1.21.11 configurations](https://github.com/alexcrea/CustomAnvil/tree/master/defaultconfigs/1.21.11)

View file

@ -6,7 +6,7 @@ signing.secretKeyRingFile=~/.gnupg/secring.gpg
kotlin.daemon.jvmargs=-Xmx8G
# list of nms
subprojects.reobfnms=v1_17R1,v1_18R1,v1_18R2,v1_19R1,v1_19R2,v1_19R3,v1_20R1,v1_20R2,v1_20R3,v1_20R4,v1_21R1,v1_21R2,v1_21R3,v1_21R4,v1_21R5,v1_21R6,v1_21R7
subprojects.reobfnms=v1_21R1,v1_21R2,v1_21R3,v1_21R4,v1_21R5,v1_21R6,v1_21R7
# list of version for hangar release
paperVersion=1.18-26.2

View file

@ -8,6 +8,6 @@ plugins {
// Imitate needed class and method to support legacy version of EcoEnchant
dependencies {
// Spigot api
compileOnly("org.spigotmc:spigot-api:1.18-R0.1-SNAPSHOT")
compileOnly("org.spigotmc:spigot-api:1.21-R0.1-SNAPSHOT")
}

View file

@ -21,8 +21,8 @@ repositories {
// Set target version
tasks.withType<JavaCompile>().configureEach {
sourceCompatibility = "16"
targetCompatibility = "16"
sourceCompatibility = "21"
targetCompatibility = "21"
options.encoding = "UTF-8"
}
@ -30,6 +30,6 @@ tasks.withType<JavaCompile>().configureEach {
kotlin {
compilerOptions {
apiVersion.set(org.jetbrains.kotlin.gradle.dsl.KotlinVersion.KOTLIN_2_2)
jvmTarget.set(JvmTarget.JVM_16)
jvmTarget.set(JvmTarget.JVM_21)
}
}

View file

@ -21,8 +21,8 @@ repositories {
// Set target version
tasks.withType<JavaCompile>().configureEach {
sourceCompatibility = "18"
targetCompatibility = "18"
sourceCompatibility = "21"
targetCompatibility = "21"
options.encoding = "UTF-8"
}
@ -30,6 +30,6 @@ tasks.withType<JavaCompile>().configureEach {
kotlin {
compilerOptions {
apiVersion.set(org.jetbrains.kotlin.gradle.dsl.KotlinVersion.KOTLIN_2_2)
jvmTarget.set(JvmTarget.JVM_18)
jvmTarget.set(JvmTarget.JVM_21)
}
}

View file

@ -2,37 +2,19 @@ package xyz.alexcrea.cuanvil.dependency.datapack
import io.papermc.paper.datapack.Datapack
import org.bukkit.Bukkit
import org.bukkit.packs.DataPack
import java.util.*
object DataPackTester {
val legacyNames: List<String>
get() = Bukkit.getDataPackManager().dataPacks
.stream().filter { obj -> obj.isEnabled }
.map { pack -> pack.key.key }
.toList()
val enabledPacks: List<String>
get() {
try {
// will throw error if do not exist
Bukkit::class.java.getDeclaredMethod("getDatapackManager")
return Bukkit.getDatapackManager().enabledPacks
return try {
Bukkit.getDatapackManager().enabledPacks
.stream().map { obj: Datapack -> obj.name }
.toList()
} catch (e: NoSuchMethodException) {
try {
DataPack::class.java.getDeclaredMethod("getKey")
} catch (e: NoSuchMethodException) {
System.err.println("Could not find compatible datapack manager")
System.err.println("If you are using a datapack that should be compatible with CustomAnvil. It will not get detected...")
return emptyList()
}
return legacyNames
} catch (e: Exception){
} catch (_: Exception){
// Assume cause UnimplementedOperationException on mock server
return Collections.emptyList()
Collections.emptyList()
}
}
}

View file

@ -1 +0,0 @@
.lastDeploymentsId

View file

@ -1,35 +0,0 @@
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
group = rootProject.group
version = rootProject.version
plugins {
id("io.papermc.paperweight.userdev")
}
dependencies {
implementation(project(":nms:nms-common"))
// Used for nms
paperweight.paperDevBundle("1.17.1-R0.1-SNAPSHOT")
}
repositories {
maven("https://repo.papermc.io/repository/maven-public/")
}
// Set target version
tasks.withType<JavaCompile>().configureEach {
sourceCompatibility = "16"
targetCompatibility = "16"
options.encoding = "UTF-8"
}
kotlin {
compilerOptions {
apiVersion.set(org.jetbrains.kotlin.gradle.dsl.KotlinVersion.KOTLIN_2_2)
jvmTarget.set(JvmTarget.JVM_16)
}
}

View file

@ -1,33 +0,0 @@
package xyz.alexcrea.cuanvil.dependency.packet.versions
import net.minecraft.network.protocol.game.ClientboundPlayerAbilitiesPacket
import net.minecraft.world.entity.player.Abilities
import org.bukkit.craftbukkit.v1_17_R1.entity.CraftPlayer
import org.bukkit.entity.Player
import xyz.alexcrea.cuanvil.dependency.packet.PacketManager
import xyz.alexcrea.cuanvil.dependency.packet.PacketManagerBase
class V1_17R1_PacketManager : PacketManagerBase(), PacketManager {
override val canSetInstantBuild: Boolean
get() = true
override fun setInstantBuild(player: Player, instantBuild: Boolean) {
val nmsPlayer = (player as CraftPlayer).handle
val playerAbilities = nmsPlayer.abilities
val sendedAbilities: Abilities
if (playerAbilities.instabuild == instantBuild) {
sendedAbilities = playerAbilities
} else {
sendedAbilities = Abilities()
sendedAbilities.invulnerable = playerAbilities.invulnerable
sendedAbilities.flying = playerAbilities.flying
sendedAbilities.mayfly = playerAbilities.mayfly
sendedAbilities.instabuild = instantBuild
sendedAbilities.mayBuild = playerAbilities.mayBuild
sendedAbilities.flyingSpeed = playerAbilities.flyingSpeed
sendedAbilities.walkingSpeed = playerAbilities.walkingSpeed
}
val packet = ClientboundPlayerAbilitiesPacket(sendedAbilities)
nmsPlayer.connection.send(packet)
}
}

View file

@ -1 +0,0 @@
.lastDeploymentsId

View file

@ -1,35 +0,0 @@
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
group = rootProject.group
version = rootProject.version
plugins {
id("io.papermc.paperweight.userdev")
}
dependencies {
implementation(project(":nms:nms-common"))
// Used for nms
paperweight.paperDevBundle("1.18.1-R0.1-SNAPSHOT")
}
repositories {
maven("https://repo.papermc.io/repository/maven-public/")
}
// Set target version
tasks.withType<JavaCompile>().configureEach {
sourceCompatibility = "17"
targetCompatibility = "17"
options.encoding = "UTF-8"
}
kotlin {
compilerOptions {
apiVersion.set(org.jetbrains.kotlin.gradle.dsl.KotlinVersion.KOTLIN_2_2)
jvmTarget.set(JvmTarget.JVM_17)
}
}

View file

@ -1,33 +0,0 @@
package xyz.alexcrea.cuanvil.dependency.packet.versions
import net.minecraft.network.protocol.game.ClientboundPlayerAbilitiesPacket
import net.minecraft.world.entity.player.Abilities
import org.bukkit.craftbukkit.v1_18_R1.entity.CraftPlayer
import org.bukkit.entity.Player
import xyz.alexcrea.cuanvil.dependency.packet.PacketManager
import xyz.alexcrea.cuanvil.dependency.packet.PacketManagerBase
class V1_18R1_PacketManager : PacketManagerBase(), PacketManager {
override val canSetInstantBuild: Boolean
get() = true
override fun setInstantBuild(player: Player, instantBuild: Boolean) {
val nmsPlayer = (player as CraftPlayer).handle
val playerAbilities = nmsPlayer.abilities
val sendedAbilities: Abilities
if (playerAbilities.instabuild == instantBuild) {
sendedAbilities = playerAbilities
} else {
sendedAbilities = Abilities()
sendedAbilities.invulnerable = playerAbilities.invulnerable
sendedAbilities.flying = playerAbilities.flying
sendedAbilities.mayfly = playerAbilities.mayfly
sendedAbilities.instabuild = instantBuild
sendedAbilities.mayBuild = playerAbilities.mayBuild
sendedAbilities.flyingSpeed = playerAbilities.flyingSpeed
sendedAbilities.walkingSpeed = playerAbilities.walkingSpeed
}
val packet = ClientboundPlayerAbilitiesPacket(sendedAbilities)
nmsPlayer.connection.send(packet)
}
}

View file

@ -1 +0,0 @@
.lastDeploymentsId

View file

@ -1,35 +0,0 @@
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
group = rootProject.group
version = rootProject.version
plugins {
id("io.papermc.paperweight.userdev")
}
dependencies {
implementation(project(":nms:nms-common"))
// Used for nms
paperweight.paperDevBundle("1.18.2-R0.1-SNAPSHOT")
}
repositories {
maven("https://repo.papermc.io/repository/maven-public/")
}
// Set target version
tasks.withType<JavaCompile>().configureEach {
sourceCompatibility = "17"
targetCompatibility = "17"
options.encoding = "UTF-8"
}
kotlin {
compilerOptions {
apiVersion.set(org.jetbrains.kotlin.gradle.dsl.KotlinVersion.KOTLIN_2_2)
jvmTarget.set(JvmTarget.JVM_17)
}
}

View file

@ -1,33 +0,0 @@
package xyz.alexcrea.cuanvil.dependency.packet.versions
import net.minecraft.network.protocol.game.ClientboundPlayerAbilitiesPacket
import net.minecraft.world.entity.player.Abilities
import org.bukkit.craftbukkit.v1_18_R2.entity.CraftPlayer
import org.bukkit.entity.Player
import xyz.alexcrea.cuanvil.dependency.packet.PacketManager
import xyz.alexcrea.cuanvil.dependency.packet.PacketManagerBase
class V1_18R2_PacketManager : PacketManagerBase(), PacketManager {
override val canSetInstantBuild: Boolean
get() = true
override fun setInstantBuild(player: Player, instantBuild: Boolean) {
val nmsPlayer = (player as CraftPlayer).handle
val playerAbilities = nmsPlayer.abilities
val sendedAbilities: Abilities
if (playerAbilities.instabuild == instantBuild) {
sendedAbilities = playerAbilities
} else {
sendedAbilities = Abilities()
sendedAbilities.invulnerable = playerAbilities.invulnerable
sendedAbilities.flying = playerAbilities.flying
sendedAbilities.mayfly = playerAbilities.mayfly
sendedAbilities.instabuild = instantBuild
sendedAbilities.mayBuild = playerAbilities.mayBuild
sendedAbilities.flyingSpeed = playerAbilities.flyingSpeed
sendedAbilities.walkingSpeed = playerAbilities.walkingSpeed
}
val packet = ClientboundPlayerAbilitiesPacket(sendedAbilities)
nmsPlayer.connection.send(packet)
}
}

View file

@ -1 +0,0 @@
.lastDeploymentsId

View file

@ -1,35 +0,0 @@
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
group = rootProject.group
version = rootProject.version
plugins {
id("io.papermc.paperweight.userdev")
}
dependencies {
implementation(project(":nms:nms-common"))
// Used for nms
paperweight.paperDevBundle("1.19.2-R0.1-SNAPSHOT")
}
repositories {
maven("https://repo.papermc.io/repository/maven-public/")
}
// Set target version
tasks.withType<JavaCompile>().configureEach {
sourceCompatibility = "17"
targetCompatibility = "17"
options.encoding = "UTF-8"
}
kotlin {
compilerOptions {
apiVersion.set(org.jetbrains.kotlin.gradle.dsl.KotlinVersion.KOTLIN_2_2)
jvmTarget.set(JvmTarget.JVM_17)
}
}

View file

@ -1,33 +0,0 @@
package xyz.alexcrea.cuanvil.dependency.packet.versions
import net.minecraft.network.protocol.game.ClientboundPlayerAbilitiesPacket
import net.minecraft.world.entity.player.Abilities
import org.bukkit.craftbukkit.v1_19_R1.entity.CraftPlayer
import org.bukkit.entity.Player
import xyz.alexcrea.cuanvil.dependency.packet.PacketManager
import xyz.alexcrea.cuanvil.dependency.packet.PacketManagerBase
class V1_19R1_PacketManager : PacketManagerBase(), PacketManager {
override val canSetInstantBuild: Boolean
get() = true
override fun setInstantBuild(player: Player, instantBuild: Boolean) {
val nmsPlayer = (player as CraftPlayer).handle
val playerAbilities = nmsPlayer.abilities
val sendedAbilities: Abilities
if (playerAbilities.instabuild == instantBuild) {
sendedAbilities = playerAbilities
} else {
sendedAbilities = Abilities()
sendedAbilities.invulnerable = playerAbilities.invulnerable
sendedAbilities.flying = playerAbilities.flying
sendedAbilities.mayfly = playerAbilities.mayfly
sendedAbilities.instabuild = instantBuild
sendedAbilities.mayBuild = playerAbilities.mayBuild
sendedAbilities.flyingSpeed = playerAbilities.flyingSpeed
sendedAbilities.walkingSpeed = playerAbilities.walkingSpeed
}
val packet = ClientboundPlayerAbilitiesPacket(sendedAbilities)
nmsPlayer.connection.send(packet)
}
}

View file

@ -1 +0,0 @@
.lastDeploymentsId

View file

@ -1,35 +0,0 @@
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
group = rootProject.group
version = rootProject.version
plugins {
id("io.papermc.paperweight.userdev")
}
dependencies {
implementation(project(":nms:nms-common"))
// Used for nms
paperweight.paperDevBundle("1.19.3-R0.1-SNAPSHOT")
}
repositories {
maven("https://repo.papermc.io/repository/maven-public/")
}
// Set target version
tasks.withType<JavaCompile>().configureEach {
sourceCompatibility = "17"
targetCompatibility = "17"
options.encoding = "UTF-8"
}
kotlin {
compilerOptions {
apiVersion.set(org.jetbrains.kotlin.gradle.dsl.KotlinVersion.KOTLIN_2_2)
jvmTarget.set(JvmTarget.JVM_17)
}
}

View file

@ -1,33 +0,0 @@
package xyz.alexcrea.cuanvil.dependency.packet.versions
import net.minecraft.network.protocol.game.ClientboundPlayerAbilitiesPacket
import net.minecraft.world.entity.player.Abilities
import org.bukkit.craftbukkit.v1_19_R2.entity.CraftPlayer
import org.bukkit.entity.Player
import xyz.alexcrea.cuanvil.dependency.packet.PacketManager
import xyz.alexcrea.cuanvil.dependency.packet.PacketManagerBase
class V1_19R2_PacketManager : PacketManagerBase(), PacketManager {
override val canSetInstantBuild: Boolean
get() = true
override fun setInstantBuild(player: Player, instantBuild: Boolean) {
val nmsPlayer = (player as CraftPlayer).handle
val playerAbilities = nmsPlayer.abilities
val sendedAbilities: Abilities
if (playerAbilities.instabuild == instantBuild) {
sendedAbilities = playerAbilities
} else {
sendedAbilities = Abilities()
sendedAbilities.invulnerable = playerAbilities.invulnerable
sendedAbilities.flying = playerAbilities.flying
sendedAbilities.mayfly = playerAbilities.mayfly
sendedAbilities.instabuild = instantBuild
sendedAbilities.mayBuild = playerAbilities.mayBuild
sendedAbilities.flyingSpeed = playerAbilities.flyingSpeed
sendedAbilities.walkingSpeed = playerAbilities.walkingSpeed
}
val packet = ClientboundPlayerAbilitiesPacket(sendedAbilities)
nmsPlayer.connection.send(packet)
}
}

View file

@ -1 +0,0 @@
.lastDeploymentsId

View file

@ -1,35 +0,0 @@
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
group = rootProject.group
version = rootProject.version
plugins {
id("io.papermc.paperweight.userdev")
}
dependencies {
implementation(project(":nms:nms-common"))
// Used for nms
paperweight.paperDevBundle("1.19.4-R0.1-SNAPSHOT")
}
repositories {
maven("https://repo.papermc.io/repository/maven-public/")
}
// Set target version
tasks.withType<JavaCompile>().configureEach {
sourceCompatibility = "17"
targetCompatibility = "17"
options.encoding = "UTF-8"
}
kotlin {
compilerOptions {
apiVersion.set(org.jetbrains.kotlin.gradle.dsl.KotlinVersion.KOTLIN_2_2)
jvmTarget.set(JvmTarget.JVM_17)
}
}

View file

@ -1,33 +0,0 @@
package xyz.alexcrea.cuanvil.dependency.packet.versions
import net.minecraft.network.protocol.game.ClientboundPlayerAbilitiesPacket
import net.minecraft.world.entity.player.Abilities
import org.bukkit.craftbukkit.v1_19_R3.entity.CraftPlayer
import org.bukkit.entity.Player
import xyz.alexcrea.cuanvil.dependency.packet.PacketManager
import xyz.alexcrea.cuanvil.dependency.packet.PacketManagerBase
class V1_19R3_PacketManager : PacketManagerBase(), PacketManager {
override val canSetInstantBuild: Boolean
get() = true
override fun setInstantBuild(player: Player, instantBuild: Boolean) {
val nmsPlayer = (player as CraftPlayer).handle
val playerAbilities = nmsPlayer.abilities
val sendedAbilities: Abilities
if (playerAbilities.instabuild == instantBuild) {
sendedAbilities = playerAbilities
} else {
sendedAbilities = Abilities()
sendedAbilities.invulnerable = playerAbilities.invulnerable
sendedAbilities.flying = playerAbilities.flying
sendedAbilities.mayfly = playerAbilities.mayfly
sendedAbilities.instabuild = instantBuild
sendedAbilities.mayBuild = playerAbilities.mayBuild
sendedAbilities.flyingSpeed = playerAbilities.flyingSpeed
sendedAbilities.walkingSpeed = playerAbilities.walkingSpeed
}
val packet = ClientboundPlayerAbilitiesPacket(sendedAbilities)
nmsPlayer.connection.send(packet)
}
}

View file

@ -1 +0,0 @@
.lastDeploymentsId

View file

@ -1,35 +0,0 @@
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
group = rootProject.group
version = rootProject.version
plugins {
id("io.papermc.paperweight.userdev")
}
dependencies {
implementation(project(":nms:nms-common"))
// Used for nms
paperweight.paperDevBundle("1.20.1-R0.1-SNAPSHOT")
}
repositories {
maven("https://repo.papermc.io/repository/maven-public/")
}
// Set target version
tasks.withType<JavaCompile>().configureEach {
sourceCompatibility = "18"
targetCompatibility = "18"
options.encoding = "UTF-8"
}
kotlin {
compilerOptions {
apiVersion.set(org.jetbrains.kotlin.gradle.dsl.KotlinVersion.KOTLIN_2_2)
jvmTarget.set(JvmTarget.JVM_18)
}
}

View file

@ -1,33 +0,0 @@
package xyz.alexcrea.cuanvil.dependency.packet.versions
import net.minecraft.network.protocol.game.ClientboundPlayerAbilitiesPacket
import net.minecraft.world.entity.player.Abilities
import org.bukkit.craftbukkit.v1_20_R1.entity.CraftPlayer
import org.bukkit.entity.Player
import xyz.alexcrea.cuanvil.dependency.packet.PacketManager
import xyz.alexcrea.cuanvil.dependency.packet.PacketManagerBase
class V1_20R1_PacketManager : PacketManagerBase(), PacketManager {
override val canSetInstantBuild: Boolean
get() = true
override fun setInstantBuild(player: Player, instantBuild: Boolean) {
val nmsPlayer = (player as CraftPlayer).handle
val playerAbilities = nmsPlayer.abilities
val sendedAbilities: Abilities
if (playerAbilities.instabuild == instantBuild) {
sendedAbilities = playerAbilities
} else {
sendedAbilities = Abilities()
sendedAbilities.invulnerable = playerAbilities.invulnerable
sendedAbilities.flying = playerAbilities.flying
sendedAbilities.mayfly = playerAbilities.mayfly
sendedAbilities.instabuild = instantBuild
sendedAbilities.mayBuild = playerAbilities.mayBuild
sendedAbilities.flyingSpeed = playerAbilities.flyingSpeed
sendedAbilities.walkingSpeed = playerAbilities.walkingSpeed
}
val packet = ClientboundPlayerAbilitiesPacket(sendedAbilities)
nmsPlayer.connection.send(packet)
}
}

View file

@ -1 +0,0 @@
.lastDeploymentsId

View file

@ -1,35 +0,0 @@
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
group = rootProject.group
version = rootProject.version
plugins {
id("io.papermc.paperweight.userdev")
}
dependencies {
implementation(project(":nms:nms-common"))
// Used for nms
paperweight.paperDevBundle("1.20.2-R0.1-SNAPSHOT")
}
repositories {
maven("https://repo.papermc.io/repository/maven-public/")
}
// Set target version
tasks.withType<JavaCompile>().configureEach {
sourceCompatibility = "18"
targetCompatibility = "18"
options.encoding = "UTF-8"
}
kotlin {
compilerOptions {
apiVersion.set(org.jetbrains.kotlin.gradle.dsl.KotlinVersion.KOTLIN_2_2)
jvmTarget.set(JvmTarget.JVM_18)
}
}

View file

@ -1,33 +0,0 @@
package xyz.alexcrea.cuanvil.dependency.packet.versions
import net.minecraft.network.protocol.game.ClientboundPlayerAbilitiesPacket
import net.minecraft.world.entity.player.Abilities
import org.bukkit.craftbukkit.v1_20_R2.entity.CraftPlayer
import org.bukkit.entity.Player
import xyz.alexcrea.cuanvil.dependency.packet.PacketManager
import xyz.alexcrea.cuanvil.dependency.packet.PacketManagerBase
class V1_20R2_PacketManager : PacketManagerBase(), PacketManager {
override val canSetInstantBuild: Boolean
get() = true
override fun setInstantBuild(player: Player, instantBuild: Boolean) {
val nmsPlayer = (player as CraftPlayer).handle
val playerAbilities = nmsPlayer.abilities
val sendedAbilities: Abilities
if (playerAbilities.instabuild == instantBuild) {
sendedAbilities = playerAbilities
} else {
sendedAbilities = Abilities()
sendedAbilities.invulnerable = playerAbilities.invulnerable
sendedAbilities.flying = playerAbilities.flying
sendedAbilities.mayfly = playerAbilities.mayfly
sendedAbilities.instabuild = instantBuild
sendedAbilities.mayBuild = playerAbilities.mayBuild
sendedAbilities.flyingSpeed = playerAbilities.flyingSpeed
sendedAbilities.walkingSpeed = playerAbilities.walkingSpeed
}
val packet = ClientboundPlayerAbilitiesPacket(sendedAbilities)
nmsPlayer.connection.send(packet)
}
}

View file

@ -1 +0,0 @@
.lastDeploymentsId

View file

@ -1,35 +0,0 @@
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
group = rootProject.group
version = rootProject.version
plugins {
id("io.papermc.paperweight.userdev")
}
dependencies {
implementation(project(":nms:nms-common"))
// Used for nms
paperweight.paperDevBundle("1.20.4-R0.1-SNAPSHOT")
}
repositories {
maven("https://repo.papermc.io/repository/maven-public/")
}
// Set target version
tasks.withType<JavaCompile>().configureEach {
sourceCompatibility = "18"
targetCompatibility = "18"
options.encoding = "UTF-8"
}
kotlin {
compilerOptions {
apiVersion.set(org.jetbrains.kotlin.gradle.dsl.KotlinVersion.KOTLIN_2_2)
jvmTarget.set(JvmTarget.JVM_18)
}
}

View file

@ -1,33 +0,0 @@
package xyz.alexcrea.cuanvil.dependency.packet.versions
import net.minecraft.network.protocol.game.ClientboundPlayerAbilitiesPacket
import net.minecraft.world.entity.player.Abilities
import org.bukkit.craftbukkit.v1_20_R3.entity.CraftPlayer
import org.bukkit.entity.Player
import xyz.alexcrea.cuanvil.dependency.packet.PacketManager
import xyz.alexcrea.cuanvil.dependency.packet.PacketManagerBase
class V1_20R3_PacketManager : PacketManagerBase(), PacketManager {
override val canSetInstantBuild: Boolean
get() = true
override fun setInstantBuild(player: Player, instantBuild: Boolean) {
val nmsPlayer = (player as CraftPlayer).handle
val playerAbilities = nmsPlayer.abilities
val sendedAbilities: Abilities
if (playerAbilities.instabuild == instantBuild) {
sendedAbilities = playerAbilities
} else {
sendedAbilities = Abilities()
sendedAbilities.invulnerable = playerAbilities.invulnerable
sendedAbilities.flying = playerAbilities.flying
sendedAbilities.mayfly = playerAbilities.mayfly
sendedAbilities.instabuild = instantBuild
sendedAbilities.mayBuild = playerAbilities.mayBuild
sendedAbilities.flyingSpeed = playerAbilities.flyingSpeed
sendedAbilities.walkingSpeed = playerAbilities.walkingSpeed
}
val packet = ClientboundPlayerAbilitiesPacket(sendedAbilities)
nmsPlayer.connection.send(packet)
}
}

View file

@ -1 +0,0 @@
.lastDeploymentsId

View file

@ -1,35 +0,0 @@
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
group = rootProject.group
version = rootProject.version
plugins {
id("io.papermc.paperweight.userdev")
}
dependencies {
implementation(project(":nms:nms-common"))
// Used for nms
paperweight.paperDevBundle("1.20.6-R0.1-SNAPSHOT")
}
repositories {
maven("https://repo.papermc.io/repository/maven-public/")
}
// Set target version
tasks.withType<JavaCompile>().configureEach {
sourceCompatibility = "18"
targetCompatibility = "18"
options.encoding = "UTF-8"
}
kotlin {
compilerOptions {
apiVersion.set(org.jetbrains.kotlin.gradle.dsl.KotlinVersion.KOTLIN_2_0)
jvmTarget.set(JvmTarget.JVM_18)
}
}

View file

@ -1,33 +0,0 @@
package xyz.alexcrea.cuanvil.dependency.packet.versions
import net.minecraft.network.protocol.game.ClientboundPlayerAbilitiesPacket
import net.minecraft.world.entity.player.Abilities
import org.bukkit.craftbukkit.entity.CraftPlayer
import org.bukkit.entity.Player
import xyz.alexcrea.cuanvil.dependency.packet.PacketManager
import xyz.alexcrea.cuanvil.dependency.packet.PacketManagerBase
class V1_20R4_PacketManager : PacketManagerBase(), PacketManager {
override val canSetInstantBuild: Boolean
get() = true
override fun setInstantBuild(player: Player, instantBuild: Boolean) {
val nmsPlayer = (player as CraftPlayer).handle
val playerAbilities = nmsPlayer.abilities
val sendedAbilities: Abilities
if (playerAbilities.instabuild == instantBuild) {
sendedAbilities = playerAbilities
} else {
sendedAbilities = Abilities()
sendedAbilities.invulnerable = playerAbilities.invulnerable
sendedAbilities.flying = playerAbilities.flying
sendedAbilities.mayfly = playerAbilities.mayfly
sendedAbilities.instabuild = instantBuild
sendedAbilities.mayBuild = playerAbilities.mayBuild
sendedAbilities.flyingSpeed = playerAbilities.flyingSpeed
sendedAbilities.walkingSpeed = playerAbilities.walkingSpeed
}
val packet = ClientboundPlayerAbilitiesPacket(sendedAbilities)
nmsPlayer.connection.send(packet)
}
}

View file

@ -1,18 +0,0 @@
package xyz.alexcrea.cuanvil.util
import org.bukkit.inventory.meta.Damageable
// I LOVE support of old versions and needing to do modules like that
// That truly is my favorite activity
// TODO clean this one of legacy removal branch
object MaxDamageCheckerUtil {
/**
* @return max damage or int max if not set
*/
fun getMaxDamage(meta: Damageable): Int {
if(!meta.hasMaxDamage()) return Integer.MAX_VALUE
return meta.maxDamage
}
}

View file

@ -90,29 +90,6 @@ public class AnvilRecipeBuilder {
return this;
}
/**
* Get the xp level cost per craft. (default 0)
*
* @return The xp level cost per craft
* @deprecated use {@link #getLevelCostPerCraft() getLevelCostPerCraft} instead
*/
@Deprecated(since = "1.13.0")
public int getXpCostPerCraft() {
return getLevelCostPerCraft();
}
/**
* Sets the xp level cost per craft.
*
* @param xpCostPerCraft The xp level cost per craft
* @return This recipe builder instance.
* @deprecated use {@link #setLevelCostPerCraft(int) setLevelCostPerCraft} instead
*/
@Deprecated(since = "1.13.0")
public AnvilRecipeBuilder setXpCostPerCraft(int xpCostPerCraft) {
return setLevelCostPerCraft(xpCostPerCraft);
}
/**
* Get the xp level cost per craft. (default 0)
*

View file

@ -387,7 +387,7 @@ public class ConflictBuilder {
*/
protected void appendEnchantments(@NotNull EnchantConflictGroup conflict) {
for (String enchantmentName : getEnchantmentNames()) {
if (appendEnchantments(conflict, EnchantmentApi.getListByName(enchantmentName)) == 0) {
if (appendEnchantments(conflict, EnchantmentApi.getByName(enchantmentName)) == 0) {
CustomAnvil.instance.getLogger().warning("Could not find enchantment " + enchantmentName + " for conflict " + getName());
ConflictAPI.logConflictOrigin(this);
}

View file

@ -132,27 +132,14 @@ public class EnchantmentApi {
return CAEnchantment.getByKey(key);
}
/**
* Get by name an enchantment.
*
* @param name The name used to fetch
* @return The custom anvil enchantment of this name. null if not found.
* @deprecated use {@link #getListByName(String)}
*/
@Deprecated(since = "1.6.3")
@Nullable
public static CAEnchantment getByName(@NotNull String 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);
public static List<CAEnchantment> getByName(@NotNull String name) {
return CAEnchantment.getByName(name);
}
/**

View file

@ -3,18 +3,16 @@ package xyz.alexcrea.cuanvil.api;
import io.delilaheve.CustomAnvil;
import kotlin.Triple;
import org.bukkit.Material;
import org.bukkit.NamespacedKey;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.configuration.file.FileConfiguration;
import org.jetbrains.annotations.NotNull;
import xyz.alexcrea.cuanvil.config.ConfigHolder;
import xyz.alexcrea.cuanvil.dependency.DependencyManager;
import xyz.alexcrea.cuanvil.gui.config.global.UnitRepairConfigGui;
import xyz.alexcrea.cuanvil.gui.config.list.MappedGuiListConfigGui;
import xyz.alexcrea.cuanvil.gui.config.list.UnitRepairElementListGui;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.*;
/**
* Custom Anvil api for unit repair.
@ -22,7 +20,8 @@ import java.util.List;
@SuppressWarnings("unused")
public class UnitRepairApi {
private UnitRepairApi(){}
private UnitRepairApi() {
}
private static Object saveChangeTask = null;
@ -39,6 +38,19 @@ public class UnitRepairApi {
return addUnitRepair(unit, repairable, 0.25, false);
}
/**
* Write and add a custom anvil unit repair recipe.
* Will not write the recipe if it already exists or was deleted.
* Set the value to minecraft default value (0.25 = 25%)
*
* @param unit The unit material used to repair the bellow item.
* @param repairable The item to be repaired.
* @return true if successful.
*/
public static boolean addUnitRepair(@NotNull NamespacedKey unit, @NotNull NamespacedKey repairable) {
return addUnitRepair(unit, repairable, 0.25, false);
}
/**
* Write and add a custom anvil unit repair recipe.
* Will not write the recipe if it already exists or was deleted.
@ -63,8 +75,22 @@ public class UnitRepairApi {
* @return true if successful.
*/
public static boolean addUnitRepair(@NotNull Material unit, @NotNull Material repairable, double value, boolean overrideDeleted) {
return addUnitRepair(unit.getKey(), repairable.getKey(), value, overrideDeleted);
}
/**
* Write and add a custom anvil unit repair recipe.
* Will not write the recipe if it already exists.
*
* @param unit The unit material used to repair the bellow item.
* @param repairable The item to be repaired.
* @param value The amount to be repaired by every unit. (1% = 0.01)
* @param overrideDeleted If we should write even if the recipe was previously deleted.
* @return true if successful.
*/
public static boolean addUnitRepair(@NotNull NamespacedKey unit, @NotNull NamespacedKey repairable, double value, boolean overrideDeleted) {
FileConfiguration config = ConfigHolder.UNIT_REPAIR_HOLDER.getConfig();
String path = unit.name().toLowerCase() + "." + repairable.name().toLowerCase();
String path = unit.toString().toLowerCase() + "." + repairable.toString().toLowerCase();
if (!overrideDeleted && ConfigHolder.UNIT_REPAIR_HOLDER.isDeleted(path)) return false;
if (config.contains(path)) return false;
@ -83,10 +109,23 @@ public class UnitRepairApi {
* @return true if successful.
*/
public static boolean setUnitRepair(@NotNull Material unit, @NotNull Material repairable, double value) {
return setUnitRepair(unit.getKey(), repairable.getKey(), value);
}
/**
* Write and add a custom anvil unit repair recipe.
* Do not check if it previously existed or exist.
*
* @param unit The unit material used to repair the bellow item.
* @param repairable The item to be repaired.
* @param value The amount to be repaired by every unit. (1% = 0.01)
* @return true if successful.
*/
public static boolean setUnitRepair(@NotNull NamespacedKey unit, @NotNull NamespacedKey repairable, double value) {
FileConfiguration config = ConfigHolder.UNIT_REPAIR_HOLDER.getConfig();
String repairableName = repairable.name().toLowerCase();
String path = unit.name().toLowerCase() + "." + repairableName;
String repairableName = repairable.toString().toLowerCase();
String path = unit.toString().toLowerCase() + "." + repairableName;
// Add to config then prepare save
config.set(path, value);
@ -97,7 +136,7 @@ public class UnitRepairApi {
if (repairConfigGui != null) {
UnitRepairElementListGui elementGui = repairConfigGui.getInstanceOrCreate(unit).getStored();
if(elementGui != null) elementGui.updateValueForGeneric(repairableName, true);
if (elementGui != null) elementGui.updateValueForGeneric(repairable, true);
repairConfigGui.updateValueForGeneric(unit, true);
}
@ -112,38 +151,46 @@ public class UnitRepairApi {
* @return true if successful.
*/
public static boolean removeUnitRepair(@NotNull Material unit, @NotNull Material repairable) {
return removeUnitRepair(unit.getKey(), repairable.getKey());
}
/**
* Remove a custom anvil unit repair recipe.
*
* @param unit The unit material used to repair the bellow item.
* @param repairable The item used to be repaired.
* @return true if successful.
*/
public static boolean removeUnitRepair(@NotNull NamespacedKey unit, @NotNull NamespacedKey repairable) {
// Delete every possible variation and save to file
String unitName = unit.name();
String repairableName = repairable.name();
FileConfiguration config = ConfigHolder.UNIT_REPAIR_HOLDER.getConfig();
config.set(unitName.toLowerCase() + "." + repairableName.toUpperCase(), null);
config.set(unitName.toUpperCase() + "." + repairableName.toLowerCase(), null);
config.set(unitName.toUpperCase() + "." + repairableName.toUpperCase(), null);
config.set(unitName.toLowerCase() + "." + repairableName.toLowerCase(), null);
config.set(unit.getKey() + "." + repairable.getKey(), null);
config.set(unit.getKey() + "." + repairable, null);
config.set(unit + "." + repairable.getKey(), null);
config.set(unit + "." + repairable, null);
// Test if it was the last value of this section
boolean lastValue = false;
if(config.isConfigurationSection(unitName.toLowerCase())) {
ConfigurationSection section = config.getConfigurationSection(unitName.toLowerCase());
if (config.isConfigurationSection(unit.toString())) {
ConfigurationSection section = config.getConfigurationSection(unit.toString());
if (section != null && section.getKeys(false).isEmpty()) {
lastValue = true;
config.set(unitName.toLowerCase(), null);
config.set(unit.toString(), null);
}
} else if (config.isConfigurationSection(unitName.toUpperCase())) {
ConfigurationSection section = config.getConfigurationSection(unitName.toUpperCase());
} else if (config.isConfigurationSection(unit.getKey())) {
ConfigurationSection section = config.getConfigurationSection(unit.getKey());
if (section != null && section.getKeys(false).isEmpty()) {
lastValue = true;
config.set(unitName.toUpperCase(), null);
config.set(unit.getKey(), null);
}
} else lastValue = true;
// We only need to "delete" as the lower case to be counted as deleted
ConfigHolder.UNIT_REPAIR_HOLDER.delete(unitName.toLowerCase() + "." + repairableName.toLowerCase());
ConfigHolder.UNIT_REPAIR_HOLDER.delete(unit.toString().toLowerCase() + "." + repairable.toString().toLowerCase());
prepareSaveTask();
// Remove from gui
@ -151,7 +198,7 @@ public class UnitRepairApi {
if (repairConfigGui != null) {
UnitRepairElementListGui elementGui = repairConfigGui.getInstanceOrCreate(unit).getStored();
if(elementGui != null) elementGui.removeGeneric(repairableName);
if (elementGui != null) elementGui.removeGeneric(repairable);
if (lastValue) {
repairConfigGui.removeGeneric(unit);
}
@ -174,6 +221,7 @@ public class UnitRepairApi {
/**
* Get every unit repair recipes.
*
* @return An immutable collection of unit repair recipes.
* <p>
* Each element of the provided triple represent a part of the recipe
@ -182,7 +230,10 @@ public class UnitRepairApi {
* <li>Second object is the item to be repaired.
* <li>Last object is the amount to be repaired by every unit. (1% = 0.01)
* </ul>
* @deprecated some may be missing. use {@link #getModernUnitRepairs()}
*
*/
@Deprecated
@NotNull
public static List<Triple<Material, Material, Double>> getUnitRepairs() {
List<Triple<Material, Material, Double>> mutableList = new ArrayList<>();
@ -215,4 +266,53 @@ public class UnitRepairApi {
return Collections.unmodifiableList(mutableList);
}
/**
* Get every unit repair recipes.
*
* @return An immutable collection of unit repair recipes.
* <p>
* <li>First map contain a key the unit material used to repair the bellow item and value the second map
* <li>Second map contain as key the item to be repaired and as value the amount to be repaired by every unit. (1% = 0.01)
* </ul>
*/
@NotNull
public static Map<NamespacedKey, Map<NamespacedKey, Double>> getModernUnitRepairs() {
Map<NamespacedKey, Map<NamespacedKey, Double>> mutableList = new HashMap<>();
FileConfiguration config = ConfigHolder.UNIT_REPAIR_HOLDER.getConfig();
for (String unitKey : config.getKeys(false)) {
// Test if config section exist
if (!config.isConfigurationSection(unitKey)) continue;
// Test if unit is a material
NamespacedKey unit = NamespacedKey.fromString(unitKey.toLowerCase());
if (unit == null) continue;
Map<NamespacedKey, Double> map;
if (!mutableList.containsKey(unit)) {
map = new HashMap<>();
mutableList.put(unit, map);
} else {
map = mutableList.get(unit);
}
// Iterate over reparable items
ConfigurationSection section = config.getConfigurationSection(unitKey);
for (String repairableKey : section.getKeys(false)) {
// Test if value section exist
if (!section.isDouble(repairableKey)) continue;
// Test if repairable is valid a material
NamespacedKey repairable = NamespacedKey.fromString(repairableKey.toLowerCase());
if (repairable == null) continue;
// Add the values
map.put(repairable, section.getDouble(repairableKey));
}
}
return mutableList;
}
}

View file

@ -17,7 +17,7 @@ import org.jetbrains.annotations.NotNull;
* Most of the time you would likely need {@link CAPreAnvilBypassEvent} or {@link CAEarlyPreAnvilBypassEvent}
* for this event to be useful.
* <p>
* There is also {@link CATreatAnvilResult2Event} that may be better for some use case.
* There is also {@link CATreatAnvilResultEvent} that may be better for some use case.
*/
public class CAClickResultBypassEvent extends Event implements Cancellable {

View file

@ -15,7 +15,7 @@ import org.jetbrains.annotations.NotNull;
* <p>
* You should also use {@link CAClickResultBypassEvent} if you want to use this event for something useful.
* <p>
* It is also recommended that you read about {@link CAPreAnvilBypassEvent} and {@link CATreatAnvilResult2Event}
* It is also recommended that you read about {@link CAPreAnvilBypassEvent} and {@link CATreatAnvilResultEvent}
* as your use case may be more prone to use theses.
*/
public class CAEarlyPreAnvilBypassEvent extends Event implements Cancellable {

View file

@ -18,7 +18,7 @@ import org.jetbrains.annotations.NotNull;
* <p>
* You should also use {@link CAClickResultBypassEvent} if you want to use this event for something useful.
* <p>
* It is also recommended that you read about {@link CAEarlyPreAnvilBypassEvent} and {@link CATreatAnvilResult2Event}
* It is also recommended that you read about {@link CAEarlyPreAnvilBypassEvent} and {@link CATreatAnvilResultEvent}
* as your use case may be more prone to use theses.
*/
public class CAPreAnvilBypassEvent extends Event implements Cancellable {

View file

@ -1,196 +0,0 @@
package xyz.alexcrea.cuanvil.api.event.listener;
import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.InventoryView;
import org.bukkit.inventory.ItemStack;
import org.jetbrains.annotations.ApiStatus;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import xyz.alexcrea.cuanvil.anvil.AnvilCost;
import xyz.alexcrea.cuanvil.anvil.AnvilUseType;
/**
* Called after custom anvil processed the click on the result on the anvil inventory.
* This event should be used to modify the result of an anvil use.
* <p>
* You may also want to check {@link CAClickResultBypassEvent},
* {@link CAPreAnvilBypassEvent}
* and {@link CAEarlyPreAnvilBypassEvent} for your use case
* <p>
* A null result will cancel this event
*/
@SuppressWarnings("unused")
public class CATreatAnvilResult2Event extends Event {
private static final HandlerList HANDLERS = new HandlerList();
public static HandlerList getHandlerList() {
return HANDLERS;
}
@Override
public @NotNull HandlerList getHandlers() {
return HANDLERS;
}
@NotNull
private final InventoryView view;
private final AnvilUseType useType;
@Nullable
private final ItemStack left;
@Nullable
private final ItemStack right;
@Nullable
private ItemStack result;
private final AnvilCost cost;
@ApiStatus.Internal
public CATreatAnvilResult2Event(
@NotNull InventoryView view,
Inventory inv,
AnvilUseType useType,
@Nullable ItemStack result,
AnvilCost cost) {
this.view = view;
this.useType = useType;
this.left = inv.getItem(0); // TODO use view here
this.right = inv.getItem(1);
this.result = result;
this.cost = cost;
}
/**
* Get the bukkit inventory view.
* <p>
* Temporarily marked as internal as it will get changed to anvil view on legacy removal
* so signature will change
*
* @return The inventory view of this event.
*/
@ApiStatus.Internal
public @NotNull InventoryView getView() {
return view;
}
/**
* Get the type of use source of the result.
*
* @return The craft use type.
*/
public AnvilUseType getUseType() {
return useType;
}
/**
* Get the left item of the anvil use
*
* @return the left item
*/
public @Nullable ItemStack getLeftItem() {
return left;
}
/**
* Get the right item of the anvil use
*
* @return the right item
*/
public @Nullable ItemStack getRightItem() {
return right;
}
/**
* Get the current result
* <p>
* note that it will not be null unless another listener previously set it to null.
*
* @return The current result.
*/
public @Nullable ItemStack getResult() {
return result;
}
/**
* Set the current result
* <p>
* note that a null result will cancel this anvil use.
*
* @param result The new result
*/
public void setResult(@Nullable ItemStack result) {
this.result = result;
}
/**
* Get the level cost displayed on the anvil.
* <h3>Important note:</h3>
* the final price are re calculated on click for the following use case:
* <ul>
* <li>Custom craft</li>
* <li>Unit repair</li>
* <li>Lore edit</li>
* </ul>
* This value will be used as final price for:
* <li>Item merge</li>
* <li>Item rename</li>
* </ul>
*
* @return The current cost.
* @deprecated use #{@link #getCost()} instead
*/
@Deprecated(forRemoval = true, since = "1.17.0")
public int getLevelCost() {
return cost.asXpCost();
}
/**
* Set the level cost displayed on the anvil.
* <h3>Important note:</h3>
* the final price are re calculated on click for the following use case:
* <ul>
* <li>Custom craft</li>
* <li>Unit repair</li>
* <li>Lore edit</li>
* </ul>
* This value will be used as final price for:
* <li>Item merge</li>
* <li>Item rename</li>
* </ul>
*
* @param levelCost The new cost.
* @deprecated use #{@link #getCost()} and set value on this instead
*/
@Deprecated(forRemoval = true, since = "1.17.0")
public void setLevelCost(int levelCost) {
cost.setGeneric(levelCost - cost.getGeneric() - cost.asXpCost());
}
/**
* Allow access to the current cost of the event
* Note that modifying this object will change the event resulting cost
*
* <h3>Important note:</h3>
* the final price are re calculated on click for the following use case:
* <ul>
* <li>Custom craft</li>
* <li>Unit repair</li>
* <li>Lore edit</li>
* </ul>
* This value will be used as final price for:
* <li>Item merge</li>
* <li>Item rename</li>
*
* @return the current anvil cost
*/
public AnvilCost getCost() {
return cost;
}
}

View file

@ -2,8 +2,8 @@ package xyz.alexcrea.cuanvil.api.event.listener;
import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;
import org.bukkit.event.inventory.PrepareAnvilEvent;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.view.AnvilView;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import xyz.alexcrea.cuanvil.anvil.AnvilCost;
@ -17,13 +17,9 @@ import xyz.alexcrea.cuanvil.anvil.AnvilUseType;
* {@link CAPreAnvilBypassEvent}
* and {@link CAEarlyPreAnvilBypassEvent} for your use case
* <p>
* A null result will cancel this pre anvil event
*
* @deprecated Prepare anvil Event cannot be provided as it can be called on result and therefore not have prepared anvil event
* use {@link CATreatAnvilResult2Event} instead
* A null result will cancel this event
*/
@SuppressWarnings("unused")
@Deprecated(forRemoval = true, since = "1.17.0")
@SuppressWarnings({"unused", "UnstableApiUsage"})
public class CATreatAnvilResultEvent extends Event {
private static final HandlerList HANDLERS = new HandlerList();
@ -38,31 +34,44 @@ public class CATreatAnvilResultEvent extends Event {
}
@NotNull
private final PrepareAnvilEvent event;
private final AnvilView view;
private final AnvilUseType useType;
@Nullable
private final ItemStack left;
@Nullable
private final ItemStack right;
@Nullable
private ItemStack result;
private final AnvilCost cost;
public CATreatAnvilResultEvent(@NotNull PrepareAnvilEvent event, AnvilUseType useType, @Nullable ItemStack result, AnvilCost cost) {
this.event = event;
public CATreatAnvilResultEvent(
@NotNull AnvilView view,
AnvilUseType useType,
@Nullable ItemStack result,
AnvilCost cost) {
this.view = view;
this.useType = useType;
this.left = view.getItem(0);
this.right = view.getItem(1);
this.result = result;
this.cost = cost;
}
/**
* Get the bukkit inventory click event causing to this event.
* Get the bukkit inventory view.
*
* @return The click event causing to this event.
* @return The inventory view of this event.
*/
public @NotNull PrepareAnvilEvent getEvent() {
return event;
public @NotNull AnvilView getView() {
return view;
}
/**
* Get the type of use source of the result.
*
@ -72,6 +81,24 @@ public class CATreatAnvilResultEvent extends Event {
return useType;
}
/**
* Get the left item of the anvil use
*
* @return the left item
*/
public @Nullable ItemStack getLeftItem() {
return left;
}
/**
* Get the right item of the anvil use
*
* @return the right item
*/
public @Nullable ItemStack getRightItem() {
return right;
}
/**
* Get the current result
* <p>
@ -94,50 +121,6 @@ public class CATreatAnvilResultEvent extends Event {
this.result = result;
}
/**
* Get the level cost displayed on the anvil.
* <h3>Important note:</h3>
* the final price are re calculated on click for the following use case:
* <ul>
* <li>Custom craft</li>
* <li>Unit repair</li>
* <li>Lore edit</li>
* </ul>
* This value will be used as final price for:
* <li>Item merge</li>
* <li>Item rename</li>
* </ul>
*
* @return The current cost.
* @deprecated use #{@link #getCost()} instead
*/
@Deprecated(forRemoval = true, since = "1.17.0")
public int getLevelCost() {
return cost.asXpCost();
}
/**
* Set the level cost displayed on the anvil.
* <h3>Important note:</h3>
* the final price are re calculated on click for the following use case:
* <ul>
* <li>Custom craft</li>
* <li>Unit repair</li>
* <li>Lore edit</li>
* </ul>
* This value will be used as final price for:
* <li>Item merge</li>
* <li>Item rename</li>
* </ul>
*
* @param levelCost The new cost.
* @deprecated use #{@link #getCost()} and set value on this instead
*/
@Deprecated(forRemoval = true, since = "1.17.0")
public void setLevelCost(int levelCost) {
cost.setGeneric(levelCost - cost.getGeneric() - cost.asXpCost());
}
/**
* Allow access to the current cost of the event
* Note that modifying this object will change the event resulting cost
@ -158,5 +141,4 @@ public class CATreatAnvilResultEvent extends Event {
public AnvilCost getCost() {
return cost;
}
}

View file

@ -9,6 +9,7 @@ import org.jetbrains.annotations.Nullable;
import xyz.alexcrea.cuanvil.enchant.bulk.BulkCleanEnchantOperation;
import xyz.alexcrea.cuanvil.enchant.bulk.BulkGetEnchantOperation;
import xyz.alexcrea.cuanvil.group.EnchantConflictGroup;
import xyz.alexcrea.cuanvil.util.CasedStringUtil;
import java.util.Collection;
import java.util.HashMap;
@ -45,6 +46,14 @@ public interface CAEnchantment {
@NotNull
String getName();
/**
* Get the enchantment name prettified (upper spaced case)
* @return Prettier enchantment name
*/
default String getPrettyName() {
return CasedStringUtil.snakeToUpperSpacedCase(getName());
}
/**
* Get the default maximum level of this enchantment.
* @return The default maximum level of this enchantment.
@ -225,25 +234,14 @@ public interface CAEnchantment {
return CAEnchantmentRegistry.getInstance().getByKey(key);
}
/**
* Gets the enchantment by the provided name.
* @param name Name to fetch.
* @return Registered enchantment. null if absent.
*
* @deprecated use {@link #getListByName(String)}
*/
@Deprecated(since = "1.6.3")
static @Nullable CAEnchantment getByName(@NotNull String 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);
static List<CAEnchantment> getByName(@NotNull String name){
return CAEnchantmentRegistry.getInstance().getByName(name);
}
}

View file

@ -155,22 +155,6 @@ public class CAEnchantmentRegistry {
return byKeyMap.get(key);
}
/**
* Gets the enchantment by the provided name.
*
* @param name Name to fetch.
* @return Registered enchantment. null if absent.
* @deprecated use {@link #getListByName(String)}
*/
@Deprecated(since = "1.6.3")
@Nullable
public CAEnchantment getByName(@NotNull String name) {
List<CAEnchantment> enchantments = getListByName(name);
if (enchantments.isEmpty()) return null;
return enchantments.get(0);
}
/**
* Gets list of enchantment using the provided name.
*
@ -178,7 +162,7 @@ public class CAEnchantmentRegistry {
* @return List of registered enchantment.
*/
@NotNull
public List<CAEnchantment> getListByName(@NotNull String name) {
public List<CAEnchantment> getByName(@NotNull String name) {
return byNameMap.getOrDefault(name, Collections.emptyList());
}

View file

@ -1,6 +1,6 @@
package xyz.alexcrea.cuanvil.enchant;
// because spigot (1.18) do not look like to provide access to enchantment rarity I need to do it myself...
// because spigot (1.21) do not look like to provide access to enchantment rarity I need to do it myself...
public class EnchantmentRarity {
public static final EnchantmentRarity NO_RARITY = new EnchantmentRarity(0, 0);

View file

@ -2,6 +2,7 @@ package xyz.alexcrea.cuanvil.gui.config;
import com.github.stefvanschie.inventoryframework.gui.GuiItem;
import com.github.stefvanschie.inventoryframework.gui.type.ChestGui;
import com.github.stefvanschie.inventoryframework.gui.type.util.Gui;
import com.github.stefvanschie.inventoryframework.pane.PatternPane;
import com.github.stefvanschie.inventoryframework.pane.util.Pattern;
import io.delilaheve.CustomAnvil;
@ -39,116 +40,142 @@ public class MainConfigGui extends ChestGui {
GuiGlobalItems.addBackgroundItem(pane);
// Basic config item
ItemStack basicConfigItemstack = new ItemStack(Material.COMMAND_BLOCK);
ItemMeta basicConfigMeta = basicConfigItemstack.getItemMeta();
assert basicConfigMeta != null;
basicConfigMeta.setDisplayName("§aBasic Config Menu");
basicConfigMeta.setLore(Collections.singletonList("§7Click here to open basic config menu"));
basicConfigItemstack.setItemMeta(basicConfigMeta);
GuiItem basicConfigItem = GuiGlobalItems.goToGuiItem(basicConfigItemstack, new BasicConfigGui(packetManager));
var basicConfigItem = basicConfigItem(new BasicConfigGui(packetManager));
pane.bindItem('1', basicConfigItem);
// enchant level limit item
ItemStack enchantLimitItemstack = new ItemStack(Material.ENCHANTED_BOOK);
ItemMeta enchantLimitMeta = enchantLimitItemstack.getItemMeta();
assert enchantLimitMeta != null;
enchantLimitMeta.setDisplayName("§aEnchantment Level Limit");
enchantLimitMeta.setLore(Collections.singletonList("§7Click here to open enchantment level limit menu"));
enchantLimitItemstack.setItemMeta(enchantLimitMeta);
GuiItem enchantLimitItem = GuiGlobalItems.goToGuiItem(enchantLimitItemstack, new EnchantLimitConfigGui());
var enchantLimitItem = enchantLimitItem(new EnchantLimitConfigGui());
pane.bindItem('2', enchantLimitItem);
// enchant level limit item
ItemStack enchantMergeLimitItemstack = new ItemStack(Material.ENCHANTED_BOOK);
ItemMeta enchantMergeLimitMeta = enchantMergeLimitItemstack.getItemMeta();
assert enchantMergeLimitMeta != null;
enchantMergeLimitMeta.setDisplayName("§aEnchantment Merge Limit");
enchantMergeLimitMeta.setLore(Collections.singletonList("§7Click here to open enchantment merge limit menu"));
enchantMergeLimitItemstack.setItemMeta(enchantMergeLimitMeta);
GuiItem enchantMergeLimitItem = GuiGlobalItems.goToGuiItem(enchantMergeLimitItemstack, new EnchantMergeLimitConfigGui());
var enchantMergeLimitItem = enchantMergeLimitItem(new EnchantMergeLimitConfigGui());
pane.bindItem('3', enchantMergeLimitItem);
// enchant cost item
ItemStack enchantCostItemstack = new ItemStack(Material.EXPERIENCE_BOTTLE);
ItemMeta enchantCostMeta = enchantCostItemstack.getItemMeta();
assert enchantCostMeta != null;
enchantCostMeta.setDisplayName("§aEnchantment Cost");
enchantCostMeta.setLore(Collections.singletonList("§7Click here to open enchantment costs menu"));
enchantCostItemstack.setItemMeta(enchantCostMeta);
GuiItem enchantCostItem = GuiGlobalItems.goToGuiItem(enchantCostItemstack, new EnchantCostConfigGui());
var enchantCostItem = enchantCostItem(new EnchantCostConfigGui());
pane.bindItem('4', enchantCostItem);
// Enchantment Conflicts item
ItemStack enchantConflictItemstack = new ItemStack(Material.OAK_FENCE);
ItemMeta enchantConflictMeta = enchantConflictItemstack.getItemMeta();
assert enchantConflictMeta != null;
enchantConflictMeta.setDisplayName("§aEnchantment Conflict");
enchantConflictMeta.setLore(Collections.singletonList("§7Click here to open enchantment conflict menu"));
enchantConflictItemstack.setItemMeta(enchantConflictMeta);
GuiItem enchantConflictItem = GuiGlobalItems.goToGuiItem(enchantConflictItemstack, EnchantConflictGui.getInstance());
var enchantConflictItem = enchantConflictItem(EnchantConflictGui.getInstance());
pane.bindItem('5', enchantConflictItem);
// Group config items
ItemStack groupItemstack = new ItemStack(Material.CHEST);
ItemMeta groupMeta = groupItemstack.getItemMeta();
assert groupMeta != null;
groupMeta.setDisplayName("§aItem Groups");
groupMeta.setLore(Collections.singletonList("§7Click here to open item group menu"));
groupItemstack.setItemMeta(groupMeta);
GuiItem groupConfigItem = GuiGlobalItems.goToGuiItem(groupItemstack, GroupConfigGui.getInstance());
var groupConfigItem = groupConfigItem(GroupConfigGui.getInstance());
pane.bindItem('6', groupConfigItem);
// Unit repair item
ItemStack unirRepairItemstack = new ItemStack(Material.DIAMOND);
ItemMeta unitRepairMeta = unirRepairItemstack.getItemMeta();
assert unitRepairMeta != null;
unitRepairMeta.setDisplayName("§aUnit Repair");
unitRepairMeta.setLore(Collections.singletonList("§7Click here to open anvil unit repair menu"));
unirRepairItemstack.setItemMeta(unitRepairMeta);
GuiItem unitRepairItem = GuiGlobalItems.goToGuiItem(unirRepairItemstack, UnitRepairConfigGui.getInstance());
var unitRepairItem = unitRepairItem(UnitRepairConfigGui.getInstance());
pane.bindItem('7', unitRepairItem);
// Custom recipe item
ItemStack customRecipeItemstack = new ItemStack(Material.CRAFTING_TABLE);
ItemMeta customRecipeMeta = customRecipeItemstack.getItemMeta();
assert customRecipeMeta != null;
customRecipeMeta.setDisplayName("§aCustom recipes");
customRecipeMeta.setLore(Collections.singletonList("§7Click here to open anvil custom recipe menu"));
customRecipeItemstack.setItemMeta(customRecipeMeta);
GuiItem customRecipeItem = GuiGlobalItems.goToGuiItem(customRecipeItemstack, CustomRecipeConfigGui.getInstance());
var customRecipeItem = customRecipeItem(CustomRecipeConfigGui.getInstance());
pane.bindItem('8', customRecipeItem);
// quit item
ItemStack quitItemstack = new ItemStack(Material.BARRIER);
ItemMeta quitMeta = quitItemstack.getItemMeta();
assert quitMeta != null;
pane.bindItem('Q', quitItem());
}
quitMeta.setDisplayName("§cQuit");
quitItemstack.setItemMeta(quitMeta);
public static GuiItem basicConfigItem(Gui target) {
var item = new ItemStack(Material.COMMAND_BLOCK);
var meta = item.getItemMeta();
assert meta != null;
GuiItem quitItem = new GuiItem(quitItemstack, event -> {
meta.setDisplayName("§aBasic Config Menu");
meta.setLore(Collections.singletonList("§7Click here to open basic config menu"));
item.setItemMeta(meta);
return GuiGlobalItems.goToGuiItem(item, target);
}
public static GuiItem enchantLimitItem(Gui target) {
var item = new ItemStack(Material.ENCHANTED_BOOK);
var meta = item.getItemMeta();
assert meta != null;
meta.setDisplayName("§aEnchantment Level Limit");
meta.setLore(Collections.singletonList("§7Click here to open enchantment level limit menu"));
item.setItemMeta(meta);
return GuiGlobalItems.goToGuiItem(item, target);
}
public static GuiItem enchantMergeLimitItem(Gui target) {
ItemStack item = new ItemStack(Material.ENCHANTED_BOOK);
ItemMeta meta = item.getItemMeta();
assert meta != null;
meta.setDisplayName("§aEnchantment Merge Limit");
meta.setLore(Collections.singletonList("§7Click here to open enchantment merge limit menu"));
item.setItemMeta(meta);
return GuiGlobalItems.goToGuiItem(item, target);
}
public static GuiItem enchantCostItem(Gui target) {
ItemStack item = new ItemStack(Material.EXPERIENCE_BOTTLE);
ItemMeta meta = item.getItemMeta();
assert meta != null;
meta.setDisplayName("§aEnchantment Cost");
meta.setLore(Collections.singletonList("§7Click here to open enchantment costs menu"));
item.setItemMeta(meta);
return GuiGlobalItems.goToGuiItem(item, target);
}
public static GuiItem enchantConflictItem(Gui target) {
var item = new ItemStack(Material.OAK_FENCE);
var meta = item.getItemMeta();
assert meta != null;
meta.setDisplayName("§aEnchantment Conflict");
meta.setLore(Collections.singletonList("§7Click here to open enchantment conflict menu"));
item.setItemMeta(meta);
return GuiGlobalItems.goToGuiItem(item, target);
}
public static GuiItem groupConfigItem(Gui target) {
var item = new ItemStack(Material.CHEST);
var meta = item.getItemMeta();
assert meta != null;
meta.setDisplayName("§aItem Groups");
meta.setLore(Collections.singletonList("§7Click here to open item group menu"));
item.setItemMeta(meta);
return GuiGlobalItems.goToGuiItem(item, target);
}
public static GuiItem unitRepairItem(Gui target) {
var item = new ItemStack(Material.DIAMOND);
var meta = item.getItemMeta();
assert meta != null;
meta.setDisplayName("§aUnit Repair");
meta.setLore(Collections.singletonList("§7Click here to open anvil unit repair menu"));
item.setItemMeta(meta);
return GuiGlobalItems.goToGuiItem(item, target);
}
public static GuiItem customRecipeItem(Gui target) {
var item = new ItemStack(Material.CRAFTING_TABLE);
var meta = item.getItemMeta();
assert meta != null;
meta.setDisplayName("§aCustom recipes");
meta.setLore(Collections.singletonList("§7Click here to open anvil custom recipe menu"));
item.setItemMeta(meta);
return GuiGlobalItems.goToGuiItem(item, target);
}
public static GuiItem quitItem() {
var item = new ItemStack(Material.BARRIER);
var meta = item.getItemMeta();
assert meta != null;
meta.setDisplayName("§cQuit");
item.setItemMeta(meta);
return new GuiItem(item, event -> {
event.setCancelled(true);
event.getWhoClicked().closeInventory();
}, CustomAnvil.instance);
pane.bindItem('Q', quitItem);
}
}

View file

@ -1,11 +1,11 @@
package xyz.alexcrea.cuanvil.gui.config.global;
import com.github.stefvanschie.inventoryframework.gui.GuiItem;
import com.github.stefvanschie.inventoryframework.gui.type.util.Gui;
import com.github.stefvanschie.inventoryframework.pane.util.Pattern;
import org.bukkit.event.inventory.InventoryClickEvent;
import xyz.alexcrea.cuanvil.enchant.CAEnchantment;
import xyz.alexcrea.cuanvil.enchant.CAEnchantmentRegistry;
import xyz.alexcrea.cuanvil.gui.ValueUpdatableGui;
import xyz.alexcrea.cuanvil.gui.config.list.SettingGuiListConfigGui;
import xyz.alexcrea.cuanvil.gui.config.settings.SettingGui;
import xyz.alexcrea.cuanvil.gui.util.GuiSharedConstant;
@ -31,13 +31,17 @@ public abstract class AbstractEnchantConfigGui<T extends SettingGui.SettingGuiFa
super(title);
}
protected AbstractEnchantConfigGui(String title, Gui parent) {
super(title, parent);
}
@Override
public void updateGuiValues() { //TODO maybe optimise it.
reloadValues();
}
@Override
protected Collection<CAEnchantment> getEveryDisplayableInstanceOfGeneric() {
protected Collection<CAEnchantment> getEveryInstanceOfGeneric() {
return CAEnchantmentRegistry.getInstance().getNameSortedEnchantments();
}
@ -73,7 +77,7 @@ public abstract class AbstractEnchantConfigGui<T extends SettingGui.SettingGuiFa
this.pages.clear();
this.pages.add(this.firstPage);
for (CAEnchantment enchantment : getEveryDisplayableInstanceOfGeneric()) {
for (CAEnchantment enchantment : getDisplayableInstanceOfGeneric()) {
GuiItem item = this.guiItemMap.get(enchantment);
if(item == null) {

View file

@ -1,6 +1,7 @@
package xyz.alexcrea.cuanvil.gui.config.global;
import com.github.stefvanschie.inventoryframework.gui.GuiItem;
import com.github.stefvanschie.inventoryframework.gui.type.util.Gui;
import org.bukkit.Material;
import org.bukkit.inventory.ItemFlag;
import org.bukkit.inventory.ItemStack;
@ -40,6 +41,10 @@ public class CustomRecipeConfigGui extends MappedGuiListConfigGui<AnvilCustomRec
init();
}
public CustomRecipeConfigGui(Gui parent) {
super("Custom Recipe Config", parent);
}
@Override
protected ItemStack createItemForGeneric(AnvilCustomRecipe recipe) {
// Get base item to display
@ -113,7 +118,7 @@ public class CustomRecipeConfigGui extends MappedGuiListConfigGui<AnvilCustomRec
@Override
protected Collection<AnvilCustomRecipe> getEveryDisplayableInstanceOfGeneric() {
protected Collection<AnvilCustomRecipe> getEveryInstanceOfGeneric() {
return ConfigHolder.CUSTOM_RECIPE_HOLDER.getRecipeManager().getRecipeList();
}
}

View file

@ -0,0 +1,196 @@
package xyz.alexcrea.cuanvil.gui.config.global;
import com.github.stefvanschie.inventoryframework.gui.GuiItem;
import com.github.stefvanschie.inventoryframework.gui.type.ChestGui;
import com.github.stefvanschie.inventoryframework.gui.type.util.Gui;
import com.github.stefvanschie.inventoryframework.pane.PatternPane;
import com.github.stefvanschie.inventoryframework.pane.util.Pattern;
import io.delilaheve.CustomAnvil;
import org.bukkit.Material;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import org.jetbrains.annotations.Contract;
import org.jetbrains.annotations.NotNull;
import xyz.alexcrea.cuanvil.api.EnchantmentApi;
import xyz.alexcrea.cuanvil.config.ConfigHolder;
import xyz.alexcrea.cuanvil.enchant.CAEnchantment;
import xyz.alexcrea.cuanvil.group.EnchantConflictGroup;
import xyz.alexcrea.cuanvil.gui.ValueUpdatableGui;
import xyz.alexcrea.cuanvil.gui.config.MainConfigGui;
import xyz.alexcrea.cuanvil.gui.util.GuiGlobalActions;
import xyz.alexcrea.cuanvil.gui.util.GuiGlobalItems;
import java.util.HashMap;
import java.util.Set;
import java.util.function.Predicate;
import java.util.stream.Collectors;
public class EnchantConfigGui extends ChestGui implements ValueUpdatableGui {
private final Set<CAEnchantment> enchantments;
private final PatternPane pane;
private EnchantLimitConfigGui enchantLimitConfigGui;
private EnchantMergeLimitConfigGui enchantMergeLimitConfigGui;
private EnchantCostConfigGui enchantCostConfigGui;
private EnchantConflictGui enchantConflictGui;
private GroupConfigGui groupConfigGui;
public EnchantConfigGui(@NotNull Set<CAEnchantment> enchantments) {
super(3,
"Configuring Enchantments",
CustomAnvil.instance);
this.enchantments = enchantments;
Pattern pattern = new Pattern(
"0000D0000",
"023405600",
"Q00000000"
);
pane = new PatternPane(0, 0, 9, 3, pattern);
addPane(pane);
GuiGlobalItems.addBackgroundItem(pane);
ItemStack displayItemstack = new ItemStack(Material.ENCHANTED_BOOK);
ItemMeta displayMeta = displayItemstack.getItemMeta();
assert displayMeta != null;
displayMeta.setDisplayName("§aConfiguring Enchantments:");
displayItemstack.setItemMeta(displayMeta);
// Set enchantments
HashMap<CAEnchantment, Integer> enchantmentMap = new HashMap<>();
for (CAEnchantment enchantment : enchantments) {
enchantmentMap.put(enchantment, 1);
}
EnchantmentApi.setEnchantments(displayItemstack, enchantmentMap);
pane.bindItem('D', new GuiItem(displayItemstack, GuiGlobalActions.stayInPlace, CustomAnvil.instance));
updateGuiValues();
// Enchantment Conflicts item
var enchantConflictItem = MainConfigGui.enchantConflictItem(getEnchantConflictGui());
pane.bindItem('5', enchantConflictItem);
// Group config items
var groupConfigItem = MainConfigGui.groupConfigItem(getGroupConfigGui());
pane.bindItem('6', groupConfigItem);
// quit item
pane.bindItem('Q', MainConfigGui.quitItem());
}
private GuiItem enchantLimitConfigGui() {
if (enchantLimitConfigGui == null) {
enchantLimitConfigGui = new EnchantLimitConfigGui(this);
enchantLimitConfigGui.setFilter(enchantments::contains);
enchantLimitConfigGui.init();
}
// Bypass
if(enchantments.size() == 1) {
var enchant = enchantments.iterator().next();
var factory = EnchantLimitConfigGui.createFactory(enchant, this);
return enchantLimitConfigGui.itemFromFactory(enchant, factory);
}
return MainConfigGui.enchantLimitItem(enchantLimitConfigGui);
}
private GuiItem enchantMergeLimitConfigGui() {
if (enchantMergeLimitConfigGui == null) {
enchantMergeLimitConfigGui = new EnchantMergeLimitConfigGui(this);
enchantMergeLimitConfigGui.setFilter(enchantments::contains);
enchantMergeLimitConfigGui.init();
}
// Bypass
if(enchantments.size() == 1) {
var enchant = enchantments.iterator().next();
var factory = EnchantMergeLimitConfigGui.createFactory(enchant, this);
return enchantMergeLimitConfigGui.itemFromFactory(enchant, factory);
}
return MainConfigGui.enchantMergeLimitItem(enchantMergeLimitConfigGui);
}
private GuiItem enchantCostConfigGui() {
if (enchantCostConfigGui == null) {
enchantCostConfigGui = new EnchantCostConfigGui(this);
enchantCostConfigGui.setFilter(enchantments::contains);
enchantCostConfigGui.init();
}
// Bypass
if(enchantments.size() == 1) {
var enchant = enchantments.iterator().next();
var factory = EnchantCostConfigGui.createFactory(enchant, this);
return enchantCostConfigGui.itemFromFactory(enchant, factory);
}
return MainConfigGui.enchantCostItem(enchantCostConfigGui);
}
@NotNull
@Contract(pure = true)
private Predicate<EnchantConflictGroup> getGroupFilter() {
return group -> group.getEnchants()
.stream()
.anyMatch(enchantments::contains);
}
private EnchantConflictGui getEnchantConflictGui() {
if (enchantConflictGui == null) {
enchantConflictGui = new EnchantConflictGui(this);
enchantConflictGui.setFilter(getGroupFilter());
enchantConflictGui.init();
}
return enchantConflictGui;
}
private GroupConfigGui getGroupConfigGui() {
if (groupConfigGui == null) {
groupConfigGui = new GroupConfigGui(this);
// Get all the conflict related to this enchantment
var groups = ConfigHolder.CONFLICT_HOLDER
.getConflictManager()
.getConflictList()
.stream()
.filter(getGroupFilter())
.map(EnchantConflictGroup::getCantConflictGroup)
.collect(Collectors.toSet());
groupConfigGui.setFilter(group ->
groups.stream().anyMatch(other -> other.isReferencing(group))
);
groupConfigGui.init();
}
return groupConfigGui;
}
@Override
public void updateGuiValues() {
// enchant level limit item
pane.bindItem('2', enchantLimitConfigGui());
// enchant level limit item
pane.bindItem('3', enchantMergeLimitConfigGui());
// enchant cost item
pane.bindItem('4', enchantCostConfigGui());
}
@Override
public Gui getConnectedGui() {
return this;
}
}

View file

@ -1,6 +1,7 @@
package xyz.alexcrea.cuanvil.gui.config.global;
import com.github.stefvanschie.inventoryframework.gui.GuiItem;
import com.github.stefvanschie.inventoryframework.gui.type.util.Gui;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.inventory.ItemFlag;
import org.bukkit.inventory.ItemStack;
@ -35,6 +36,10 @@ public class EnchantConflictGui extends MappedGuiListConfigGui<EnchantConflictGr
return INSTANCE;
}
// Need to init myself
public EnchantConflictGui(Gui parent) {
super("Conflict Config", parent);
}
private EnchantConflictGui() {
super("Conflict Config");
@ -97,7 +102,7 @@ public class EnchantConflictGui extends MappedGuiListConfigGui<EnchantConflictGr
}
@Override
protected Collection<EnchantConflictGroup> getEveryDisplayableInstanceOfGeneric() {
protected Collection<EnchantConflictGroup> getEveryInstanceOfGeneric() {
return ConfigHolder.CONFLICT_HOLDER.getConflictManager().getConflictList();
}

View file

@ -1,14 +1,14 @@
package xyz.alexcrea.cuanvil.gui.config.global;
import com.github.stefvanschie.inventoryframework.gui.GuiItem;
import com.github.stefvanschie.inventoryframework.gui.type.util.Gui;
import org.bukkit.Material;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import org.jetbrains.annotations.Nullable;
import xyz.alexcrea.cuanvil.config.ConfigHolder;
import xyz.alexcrea.cuanvil.enchant.CAEnchantment;
import xyz.alexcrea.cuanvil.enchant.EnchantmentProperties;
import xyz.alexcrea.cuanvil.enchant.EnchantmentRarity;
import xyz.alexcrea.cuanvil.gui.ValueUpdatableGui;
import xyz.alexcrea.cuanvil.gui.config.settings.EnchantCostSettingsGui;
import xyz.alexcrea.cuanvil.gui.util.GuiGlobalItems;
import xyz.alexcrea.cuanvil.util.CasedStringUtil;
@ -18,13 +18,13 @@ import java.util.Arrays;
import java.util.List;
import java.util.Locale;
import static io.delilaheve.util.ConfigOptions.ENCHANT_VALUES_ROOT;
/**
* Global Config gui for enchantment cost settings.
*/
public class EnchantCostConfigGui extends AbstractEnchantConfigGui<EnchantCostSettingsGui.EnchantCostSettingFactory> {
private static final String SECTION_NAME = "enchant_values";
private static EnchantCostConfigGui INSTANCE = null;
@Nullable
@ -42,13 +42,24 @@ public class EnchantCostConfigGui extends AbstractEnchantConfigGui<EnchantCostSe
init();
}
/**
* Constructor of this Global gui for enchantment cost settings.
*/
public EnchantCostConfigGui(Gui parent) {
super("§8Enchantment Level Cost", parent);
}
@Override
public EnchantCostSettingsGui.EnchantCostSettingFactory createFactory(CAEnchantment enchant) {
return createFactory(enchant, this);
}
public static EnchantCostSettingsGui.EnchantCostSettingFactory createFactory(CAEnchantment enchant, ValueUpdatableGui parent) {
String key = enchant.getKey().toString().toLowerCase(Locale.ENGLISH);
String prettyKey = CasedStringUtil.snakeToUpperSpacedCase(key.replace(":", "_"));
return new EnchantCostSettingsGui.EnchantCostSettingFactory(prettyKey + " Cost", this,
SECTION_NAME + '.' + key, ConfigHolder.DEFAULT_CONFIG,
return new EnchantCostSettingsGui.EnchantCostSettingFactory(prettyKey + " Cost", parent,
ENCHANT_VALUES_ROOT + '.' + key, ConfigHolder.DEFAULT_CONFIG,
Arrays.asList(
"§7How many level should " + prettyKey,
"§7cost when applied by book or by another item."

View file

@ -1,11 +1,13 @@
package xyz.alexcrea.cuanvil.gui.config.global;
import com.github.stefvanschie.inventoryframework.gui.GuiItem;
import com.github.stefvanschie.inventoryframework.gui.type.util.Gui;
import io.delilaheve.util.ConfigOptions;
import org.bukkit.Material;
import org.jetbrains.annotations.Nullable;
import xyz.alexcrea.cuanvil.config.ConfigHolder;
import xyz.alexcrea.cuanvil.enchant.CAEnchantment;
import xyz.alexcrea.cuanvil.gui.ValueUpdatableGui;
import xyz.alexcrea.cuanvil.gui.config.settings.IntSettingsGui;
import xyz.alexcrea.cuanvil.util.CasedStringUtil;
@ -36,14 +38,22 @@ public class EnchantLimitConfigGui extends AbstractEnchantConfigGui<IntSettingsG
init();
}
public EnchantLimitConfigGui(Gui parent) {
super("§8Enchantment Level Limit", parent);
}
@Override
public IntSettingsGui.IntSettingFactory createFactory(CAEnchantment enchant) {
return createFactory(enchant, this);
}
public static IntSettingsGui.IntSettingFactory createFactory(CAEnchantment enchant, ValueUpdatableGui parent) {
String key = enchant.getKey().toString().toLowerCase(Locale.ROOT);
String prettyKey = CasedStringUtil.snakeToUpperSpacedCase(key.replace(":", "_"));
var defaultValue = enchant.defaultMaxLevel();
return new IntSettingsGui.IntSettingFactory(prettyKey + " Limit", this,
return new IntSettingsGui.IntSettingFactory(prettyKey + " Limit", parent,
SECTION_NAME + '.' + key, ConfigHolder.DEFAULT_CONFIG,
Collections.singletonList(
"§7Maximum applied level of " + prettyKey

View file

@ -1,11 +1,13 @@
package xyz.alexcrea.cuanvil.gui.config.global;
import com.github.stefvanschie.inventoryframework.gui.GuiItem;
import com.github.stefvanschie.inventoryframework.gui.type.util.Gui;
import io.delilaheve.util.ConfigOptions;
import org.bukkit.Material;
import org.jetbrains.annotations.Nullable;
import xyz.alexcrea.cuanvil.config.ConfigHolder;
import xyz.alexcrea.cuanvil.enchant.CAEnchantment;
import xyz.alexcrea.cuanvil.gui.ValueUpdatableGui;
import xyz.alexcrea.cuanvil.gui.config.settings.IntSettingsGui;
import xyz.alexcrea.cuanvil.util.CasedStringUtil;
@ -33,12 +35,24 @@ public class EnchantMergeLimitConfigGui extends AbstractEnchantConfigGui<IntSett
init();
}
/**
* Constructor of this Global gui for enchantment level limit settings.
*/
public EnchantMergeLimitConfigGui(Gui parent) {
super("§8Enchantment Maximum Merge Level", parent);
}
@Override
public IntSettingsGui.IntSettingFactory createFactory(CAEnchantment enchant) {
return createFactory(enchant, this);
}
public static IntSettingsGui.IntSettingFactory createFactory(CAEnchantment enchant, ValueUpdatableGui parent) {
String key = enchant.getKey().toString().toLowerCase(Locale.ROOT);
String prettyKey = CasedStringUtil.snakeToUpperSpacedCase(key.replace(":", "_"));
return new IntSettingsGui.IntSettingFactory(prettyKey + " Merge Limit", this,
return new IntSettingsGui.IntSettingFactory(prettyKey + " Merge Limit", parent,
SECTION_NAME + '.' + key, ConfigHolder.DEFAULT_CONFIG,
Arrays.asList(
"§7Maximum merge level for for " + prettyKey,

View file

@ -1,6 +1,7 @@
package xyz.alexcrea.cuanvil.gui.config.global;
import com.github.stefvanschie.inventoryframework.gui.GuiItem;
import com.github.stefvanschie.inventoryframework.gui.type.util.Gui;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.inventory.ItemFlag;
import org.bukkit.inventory.ItemStack;
@ -43,6 +44,10 @@ public class GroupConfigGui extends MappedGuiListConfigGui<IncludeGroup, MappedG
init();
}
public GroupConfigGui(Gui parent) {
super("Group Config", parent);
}
@Override
protected ItemStack createItemForGeneric(IncludeGroup group) {
ItemStack item = new ItemStack(group.getRepresentativeMaterial());
@ -62,7 +67,7 @@ public class GroupConfigGui extends MappedGuiListConfigGui<IncludeGroup, MappedG
}
@Override
protected Collection<IncludeGroup> getEveryDisplayableInstanceOfGeneric() {
protected Collection<IncludeGroup> getEveryInstanceOfGeneric() {
ArrayList<IncludeGroup> includeGroups = new ArrayList<>();
for (AbstractMaterialGroup group : ConfigHolder.ITEM_GROUP_HOLDER.getItemGroupsManager().getGroupMap().values()) {

View file

@ -0,0 +1,132 @@
package xyz.alexcrea.cuanvil.gui.config.global;
import com.github.stefvanschie.inventoryframework.gui.GuiItem;
import com.github.stefvanschie.inventoryframework.gui.type.ChestGui;
import com.github.stefvanschie.inventoryframework.pane.PatternPane;
import com.github.stefvanschie.inventoryframework.pane.util.Pattern;
import io.delilaheve.CustomAnvil;
import org.bukkit.Material;
import org.bukkit.NamespacedKey;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import xyz.alexcrea.cuanvil.config.ConfigHolder;
import xyz.alexcrea.cuanvil.gui.config.MainConfigGui;
import xyz.alexcrea.cuanvil.gui.util.GuiGlobalActions;
import xyz.alexcrea.cuanvil.gui.util.GuiGlobalItems;
import xyz.alexcrea.cuanvil.util.CasedStringUtil;
import xyz.alexcrea.cuanvil.util.MaterialUtil;
import xyz.alexcrea.cuanvil.util.UnitRepairUtil;
public class ItemConfigGui extends ChestGui {
private EnchantConflictGui enchantConflictGui;
private GroupConfigGui groupConfigGui;
private UnitRepairConfigGui unitRepairConfigGui;
private CustomRecipeConfigGui customRecipeConfigGui;
public ItemConfigGui(@NotNull Material display, @NotNull NamespacedKey material) {
super(3,
CasedStringUtil.snakeToUpperSpacedCase(
material.getKey().toLowerCase()
) + " Config",
CustomAnvil.instance);
Pattern pattern = new Pattern(
"0000D0000",
"056000780",
"Q00000000"
);
PatternPane pane = new PatternPane(0, 0, 9, 3, pattern);
addPane(pane);
GuiGlobalItems.addBackgroundItem(pane);
ItemStack displayItemstack = new ItemStack(display);
ItemMeta displayMeta = displayItemstack.getItemMeta();
assert displayMeta != null;
displayMeta.setDisplayName("§aConfiguring " + material);
displayItemstack.setItemMeta(displayMeta);
pane.bindItem('D', new GuiItem(displayItemstack, GuiGlobalActions.stayInPlace, CustomAnvil.instance));
// Enchantment Conflicts item
GuiItem enchantConflictItem = MainConfigGui.enchantConflictItem(getEnchantConflictGui(material));
pane.bindItem('5', enchantConflictItem);
// Group config items
GuiItem groupConfigItem = MainConfigGui.groupConfigItem(getGroupConfigGui(material));
pane.bindItem('6', groupConfigItem);
// Unit repair item
GuiItem unitRepairItem = MainConfigGui.unitRepairItem(getUnitRepairConfigGui(material));
pane.bindItem('7', unitRepairItem);
// Custom recipe item
GuiItem customRecipeItem = MainConfigGui.customRecipeItem(getCustomRecipeConfigGui(material));
pane.bindItem('8', customRecipeItem);
// quit item
pane.bindItem('Q', MainConfigGui.quitItem());
}
private EnchantConflictGui getEnchantConflictGui(@NotNull NamespacedKey material) {
if (enchantConflictGui == null) {
enchantConflictGui = new EnchantConflictGui(this);
enchantConflictGui.setFilter(group ->
group.getCantConflictGroup().contain(material)
);
enchantConflictGui.init();
}
return enchantConflictGui;
}
private GroupConfigGui getGroupConfigGui(@NotNull NamespacedKey material) {
if (groupConfigGui == null) {
groupConfigGui = new GroupConfigGui(this);
groupConfigGui.setFilter(group ->
group.contain(material)
);
groupConfigGui.init();
}
return groupConfigGui;
}
private UnitRepairConfigGui getUnitRepairConfigGui(@NotNull NamespacedKey material) {
if (unitRepairConfigGui == null) {
unitRepairConfigGui = new UnitRepairConfigGui(this);
unitRepairConfigGui.setFilter(otherMat ->
otherMat.equals(material) || UnitRepairUtil.INSTANCE.findRawRepairValue(
material, otherMat, ConfigHolder.UNIT_REPAIR_HOLDER.getConfig()) != null
);
unitRepairConfigGui.init();
}
return unitRepairConfigGui;
}
private CustomRecipeConfigGui getCustomRecipeConfigGui(@NotNull NamespacedKey material) {
if (customRecipeConfigGui == null) {
customRecipeConfigGui = new CustomRecipeConfigGui(this);
customRecipeConfigGui.setFilter(recipe -> {
if (isMaterial(recipe.getLeftItem(), material)) return true;
if (isMaterial(recipe.getRightItem(), material)) return true;
return isMaterial(recipe.getResultItem(), material);
}
);
customRecipeConfigGui.init();
}
return customRecipeConfigGui;
}
private boolean isMaterial(@Nullable ItemStack item, @NotNull NamespacedKey material) {
if (item == null) return false;
return material.equals(MaterialUtil.INSTANCE.getCustomType(item));
}
}

View file

@ -1,9 +1,10 @@
package xyz.alexcrea.cuanvil.gui.config.global;
import com.github.stefvanschie.inventoryframework.gui.GuiItem;
import com.github.stefvanschie.inventoryframework.gui.type.util.Gui;
import io.delilaheve.CustomAnvil;
import org.bukkit.Material;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.NamespacedKey;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import org.jetbrains.annotations.NotNull;
@ -13,13 +14,14 @@ import xyz.alexcrea.cuanvil.gui.config.ask.SelectItemTypeGui;
import xyz.alexcrea.cuanvil.gui.config.list.MappedGuiListConfigGui;
import xyz.alexcrea.cuanvil.gui.config.list.UnitRepairElementListGui;
import xyz.alexcrea.cuanvil.util.CasedStringUtil;
import xyz.alexcrea.cuanvil.util.MaterialUtil;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.HashSet;
public class UnitRepairConfigGui extends
MappedGuiListConfigGui<Material, MappedGuiListConfigGui.LazyElement<UnitRepairElementListGui>> {
MappedGuiListConfigGui<NamespacedKey, MappedGuiListConfigGui.LazyElement<UnitRepairElementListGui>> {
private static UnitRepairConfigGui INSTANCE;
@ -41,8 +43,12 @@ public class UnitRepairConfigGui extends
init();
}
public UnitRepairConfigGui(Gui parent) {
super("Unit Repair Config", parent);
}
@Override
protected LazyElement<UnitRepairElementListGui> newInstanceOfGui(Material material, GuiItem item) {
protected LazyElement<UnitRepairElementListGui> newInstanceOfGui(NamespacedKey material, GuiItem item) {
return new LazyElement<>(item, () -> {
UnitRepairElementListGui element = new UnitRepairElementListGui(material, this);
element.init();
@ -51,17 +57,28 @@ public class UnitRepairConfigGui extends
}
@Override
protected ItemStack createItemForGeneric(Material material) {
ConfigurationSection materialSection = ConfigHolder.UNIT_REPAIR_HOLDER.getConfig().getConfigurationSection(material.name().toLowerCase());
String materialName = CasedStringUtil.snakeToUpperSpacedCase(material.name().toLowerCase());
protected ItemStack createItemForGeneric(@NotNull NamespacedKey material) {
var unitConfig = ConfigHolder.UNIT_REPAIR_HOLDER.getConfig();
var section = unitConfig.getConfigurationSection(material.toString().toLowerCase());
var legacySection = unitConfig.getConfigurationSection(material.getKey().toLowerCase());
if(material.isAir()){
material = Material.BARRIER;
String materialName = CasedStringUtil.snakeToUpperSpacedCase(material.getKey().toLowerCase());
var display = MaterialUtil.INSTANCE.getMatFromKey(material);
if (display == null || display.isAir()) {
display = Material.BARRIER;
}
int reparableItemCount = materialSection == null ? 0 : materialSection.getKeys(false).size(); // Probably an expensive call but... why not
var reparable = new HashSet<String>();
if (section != null)
reparable.addAll(section.getKeys(false));
if (legacySection != null)
reparable.addAll(legacySection.getKeys(false));
ItemStack item = new ItemStack(material);
var reparableItemCount = reparable.size();
ItemStack item = new ItemStack(display);
ItemMeta meta = item.getItemMeta();
assert meta != null;
@ -77,13 +94,16 @@ public class UnitRepairConfigGui extends
}
@Override
protected Collection<Material> getEveryDisplayableInstanceOfGeneric() {
ArrayList<Material> materials = new ArrayList<>();
protected Collection<NamespacedKey> getEveryInstanceOfGeneric() {
var materials = new HashSet<NamespacedKey>();
var config = ConfigHolder.UNIT_REPAIR_HOLDER.getConfig();
for (String matName : ConfigHolder.UNIT_REPAIR_HOLDER.getConfig().getKeys(false)) {
Material mat = Material.getMaterial(matName.toUpperCase());
if(mat != null){
materials.add(mat);
for (String matName : config.getKeys(false)) {
if(!config.isConfigurationSection(matName)) continue;
NamespacedKey material = NamespacedKey.fromString(matName.toLowerCase());
if (material != null) {
materials.add(material);
}
}
return materials;
@ -113,7 +133,7 @@ public class UnitRepairConfigGui extends
"§7You like to be an unit repair item",
this,
(itemStack, player) -> {
Material type = itemStack.getType();
NamespacedKey type = MaterialUtil.INSTANCE.getCustomType(itemStack);
// Add new material
updateValueForGeneric(type, true);
@ -126,7 +146,7 @@ public class UnitRepairConfigGui extends
}
@NotNull
public LazyElement<UnitRepairElementListGui> getInstanceOrCreate(Material mat){
public LazyElement<UnitRepairElementListGui> getInstanceOrCreate(NamespacedKey mat) {
LazyElement<UnitRepairElementListGui> element = this.elementGuiMap.get(mat);
if (element == null) {
updateValueForGeneric(mat, false);
@ -141,8 +161,10 @@ public class UnitRepairConfigGui extends
protected String genericDisplayedName() {
return "this function Should not be used.";
}
@Override // Not used in this implementation.
protected Material createAndSaveNewEmptyGeneric(String name) {
protected NamespacedKey createAndSaveNewEmptyGeneric(String name) {
return null;
}
}

View file

@ -23,18 +23,22 @@ import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.UUID;
import java.util.function.Predicate;
public abstract class ElementListConfigGui<T> extends ChestGui implements ValueUpdatableGui {
private final String namePrefix;
protected PatternPane backgroundPane;
public static final int LIST_FILLER_START_X = 1;
public static final int LIST_FILLER_START_Y = 1;
public static final int LIST_FILLER_LENGTH = 7;
public static final int LIST_FILLER_HEIGHT = 4;
private final String namePrefix;
protected PatternPane backgroundPane;
private Predicate<T> filter = (t) -> true;
private boolean hasDefaultFilter = true;
protected ElementListConfigGui(@NotNull String title, Gui parent) {
super(6, title, CustomAnvil.instance);
this.namePrefix = title;
@ -46,6 +50,11 @@ public abstract class ElementListConfigGui< T > extends ChestGui implements Valu
}
public void setFilter(Predicate<T> filter) {
this.filter = filter;
this.hasDefaultFilter = false;
}
protected Pattern getBackgroundPattern() {
return new Pattern(
GuiSharedConstant.UPPER_FILLER_FULL_PLANE,
@ -61,7 +70,7 @@ public abstract class ElementListConfigGui< T > extends ChestGui implements Valu
protected ArrayList<OutlinePane> pages;
protected HashMap<UUID, Integer> pageMap;
public void init() { // Why I'm using an init function ? //TODO determine why is it using a init function and not used on constructor.
public void init() {
GuiGlobalItems.addBackgroundItem(this.backgroundPane);
this.backgroundPane.bindItem('1', GuiSharedConstant.SECONDARY_BACKGROUND_ITEM);
addPane(this.backgroundPane);
@ -112,17 +121,23 @@ public abstract class ElementListConfigGui< T > extends ChestGui implements Valu
viewer.setItemOnCursor(cursor);
}, CustomAnvil.instance);
GuiItem createNew = prepareCreateNewItem();
GuiItem createNew;
if(hasDefaultFilter)
createNew = prepareCreateNewItem();
else
createNew = GuiSharedConstant.SECONDARY_BACKGROUND_ITEM;
if (createNew != null) {
this.backgroundPane.bindItem('C', createNew);
}
}
protected void reloadValues() {
this.firstPage.clear();
this.pages.clear();
this.pages.add(this.firstPage);
for (T generic : getEveryDisplayableInstanceOfGeneric()) {
for (T generic : getDisplayableInstanceOfGeneric()) {
updateValueForGeneric(generic, false);
}
@ -300,7 +315,11 @@ public abstract class ElementListConfigGui< T > extends ChestGui implements Valu
protected abstract void updateGeneric(T generic, ItemStack usedItem);
protected abstract Collection<T> getEveryDisplayableInstanceOfGeneric();
protected abstract Collection<T> getEveryInstanceOfGeneric();
protected Collection<T> getDisplayableInstanceOfGeneric() {
return getEveryInstanceOfGeneric().stream().filter(filter).toList();
}
@Override
public void updateGuiValues() {

View file

@ -1,6 +1,7 @@
package xyz.alexcrea.cuanvil.gui.config.list;
import com.github.stefvanschie.inventoryframework.gui.GuiItem;
import com.github.stefvanschie.inventoryframework.gui.type.util.Gui;
import io.delilaheve.CustomAnvil;
import org.bukkit.Material;
import org.bukkit.entity.HumanEntity;
@ -17,12 +18,17 @@ import java.util.function.Consumer;
public abstract class MappedElementListConfigGui<T, S> extends ElementListConfigGui<T> {
protected final HashMap<T, S> elementGuiMap;
protected MappedElementListConfigGui(@NotNull String title) {
super(title, MainConfigGui.getInstance());
protected MappedElementListConfigGui(@NotNull String title, @NotNull Gui parent) {
super(title, parent);
this.elementGuiMap = new HashMap<>();
}
protected MappedElementListConfigGui(@NotNull String title) {
this(title, MainConfigGui.getInstance());
}
@Override
protected GuiItem prepareCreateNewItem() {
// Create new conflict item

View file

@ -1,6 +1,7 @@
package xyz.alexcrea.cuanvil.gui.config.list;
import com.github.stefvanschie.inventoryframework.gui.GuiItem;
import com.github.stefvanschie.inventoryframework.gui.type.util.Gui;
import io.delilaheve.CustomAnvil;
import org.bukkit.entity.HumanEntity;
import org.bukkit.event.inventory.InventoryClickEvent;
@ -19,7 +20,10 @@ public abstract class MappedGuiListConfigGui< T, S extends MappedGuiListConfigGu
protected MappedGuiListConfigGui(@NotNull String title) {
super(title);
}
protected MappedGuiListConfigGui(@NotNull String title, @NotNull Gui parent) {
super(title, parent);
}
@Override
@ -80,7 +84,7 @@ public abstract class MappedGuiListConfigGui< T, S extends MappedGuiListConfigGu
// Try to find if it already exists in a for loop
// Not the most efficient on large number of conflict, but it should not run often.
for (T generic : getEveryDisplayableInstanceOfGeneric()) {
for (T generic : getDisplayableInstanceOfGeneric()) {
if (generic.toString().equalsIgnoreCase(message)) {
player.sendMessage("§cPlease enter a " + genericDisplayedName() + " name that do not already exist...");
// wait next message.
@ -117,6 +121,7 @@ public abstract class MappedGuiListConfigGui< T, S extends MappedGuiListConfigGu
private final GuiItem parentItem;
private final LazyValue<Consumer<InventoryClickEvent>> lazyOpenConsumer;
public LazyElement(GuiItem parentItem, Supplier<T> valueSupplier) {
super(valueSupplier);
this.parentItem = parentItem;

View file

@ -19,6 +19,7 @@ public abstract class SettingGuiListConfigGui< T, S extends SettingGui.SettingGu
protected HashMap<T, GuiItem> guiItemMap;
protected HashMap<T, S> factoryMap;
protected SettingGuiListConfigGui(@NotNull String title, Gui parent) {
super(title, parent);
this.guiItemMap = new HashMap<>();
@ -86,17 +87,22 @@ public abstract class SettingGuiListConfigGui< T, S extends SettingGui.SettingGu
}
@Override // Not used
protected void updateGeneric(T generic, ItemStack usedItem) {}
protected void updateGeneric(T generic, ItemStack usedItem) {
}
@Override // Not used
protected ItemStack createItemForGeneric(T generic) {
return null;
}
protected abstract List<String> getCreateItemLore();
protected abstract Consumer<InventoryClickEvent> getCreateClickConsumer();
protected abstract String createItemName();
protected abstract S createFactory(T generic);
protected abstract GuiItem itemFromFactory(T generic, S factory);

View file

@ -3,12 +3,14 @@ package xyz.alexcrea.cuanvil.gui.config.list;
import com.github.stefvanschie.inventoryframework.gui.GuiItem;
import com.github.stefvanschie.inventoryframework.gui.type.util.Gui;
import org.bukkit.Material;
import org.bukkit.NamespacedKey;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.entity.HumanEntity;
import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.inventory.meta.Damageable;
import org.bukkit.inventory.meta.ItemMeta;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import xyz.alexcrea.cuanvil.config.ConfigHolder;
import xyz.alexcrea.cuanvil.gui.config.ask.SelectItemTypeGui;
import xyz.alexcrea.cuanvil.gui.config.global.UnitRepairConfigGui;
@ -17,26 +19,25 @@ import xyz.alexcrea.cuanvil.gui.config.settings.DoubleSettingGui;
import xyz.alexcrea.cuanvil.gui.util.GuiGlobalItems;
import xyz.alexcrea.cuanvil.gui.util.GuiSharedConstant;
import xyz.alexcrea.cuanvil.util.CasedStringUtil;
import xyz.alexcrea.cuanvil.util.MaterialUtil;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.List;
import java.util.*;
import java.util.function.Consumer;
public class UnitRepairElementListGui extends SettingGuiListConfigGui<String, DoubleSettingGui.DoubleSettingFactory> implements ElementMappedToListGui {
public class UnitRepairElementListGui extends SettingGuiListConfigGui<NamespacedKey, DoubleSettingGui.DoubleSettingFactory> implements ElementMappedToListGui {
private final Material parentMaterial;
private final NamespacedKey parentMaterial;
private final UnitRepairConfigGui parentGui;
private final String materialName;
private boolean shouldWork = true;
public UnitRepairElementListGui(@NotNull Material parentMaterial,
public UnitRepairElementListGui(@NotNull NamespacedKey parentMaterial,
@NotNull UnitRepairConfigGui parentGui) {
super("§e" + CasedStringUtil.snakeToUpperSpacedCase(parentMaterial.name().toLowerCase()) + " §rUnit repair");
super("§e" + CasedStringUtil.snakeToUpperSpacedCase(parentMaterial.getKey().toLowerCase()) + " §rUnit repair");
this.parentMaterial = parentMaterial;
this.parentGui = parentGui;
this.materialName = CasedStringUtil.snakeToUpperSpacedCase(parentMaterial.name().toLowerCase());
this.materialName = CasedStringUtil.snakeToUpperSpacedCase(parentMaterial.getKey().toLowerCase());
GuiGlobalItems.addBackItem(this.backgroundPane, parentGui);
}
@ -66,28 +67,28 @@ public class UnitRepairElementListGui extends SettingGuiListConfigGui<String, Do
this,
(itemStack, player) -> {
ItemMeta meta = itemStack.getItemMeta();
Material type = itemStack.getType();
NamespacedKey type = MaterialUtil.INSTANCE.getCustomType(itemStack);
if(!(meta instanceof Damageable) || (type.getMaxDurability() <= 0)) {
if (!(meta instanceof Damageable)) {
player.sendMessage("§cThis item can't be damaged, so it can't be repaired.");
return;
}
if(type == this.parentMaterial){
if (type.equals(this.parentMaterial)) {
player.sendMessage("§cItem can't repair something of the same type.");
return;
}
String materialName = type.name().toLowerCase();
String materialName = type.toString();
// Add new material
ConfigHolder.UNIT_REPAIR_HOLDER.getConfig().set(parentMaterial.name().toLowerCase() + "." + materialName,0.25);
ConfigHolder.UNIT_REPAIR_HOLDER.getConfig().set(parentMaterial.toString().toLowerCase() + "." + materialName, 0.25);
if (GuiSharedConstant.TEMPORARY_DO_SAVE_TO_DISK_EVERY_CHANGE) {
ConfigHolder.UNIT_REPAIR_HOLDER.saveToDisk(GuiSharedConstant.TEMPORARY_DO_BACKUP_EVERY_SAVE);
}
// Update gui
updateValueForGeneric(materialName, true);
updateValueForGeneric(type, true);
this.parentGui.updateValueForGeneric(this.parentMaterial, true);
@ -106,14 +107,14 @@ public class UnitRepairElementListGui extends SettingGuiListConfigGui<String, Do
}
@Override
protected DoubleSettingGui.DoubleSettingFactory createFactory(String materialName) {
String materialDisplayName = CasedStringUtil.snakeToUpperSpacedCase(materialName);
protected DoubleSettingGui.DoubleSettingFactory createFactory(NamespacedKey materialName) {
String materialDisplayName = CasedStringUtil.snakeToUpperSpacedCase(materialName.getKey());
return new DoubleSettingGui.DoubleSettingFactory(
"§0%§8" + materialDisplayName + " Repair",
this,
ConfigHolder.UNIT_REPAIR_HOLDER,
this.parentMaterial.name().toLowerCase()+"."+materialName,
this.parentMaterial.toString().toLowerCase() + "." + materialName,
Arrays.asList(
"§7Click here to change how many §e% §7of §a" + materialDisplayName,
"§7Should get repaired by §e" + this.materialName
@ -128,28 +129,39 @@ public class UnitRepairElementListGui extends SettingGuiListConfigGui<String, Do
}
@Override
protected GuiItem itemFromFactory(String materialName, DoubleSettingGui.DoubleSettingFactory factory) {
protected GuiItem itemFromFactory(NamespacedKey materialName, DoubleSettingGui.DoubleSettingFactory factory) {
return factory.getItem(materialFromName(materialName),
"§7%§a" + CasedStringUtil.snakeToUpperSpacedCase(materialName)+ " §erepaired by §a" + this.materialName);
"§7%§a" + CasedStringUtil.snakeToUpperSpacedCase(materialName.getKey()) + " §erepaired by §a" + this.materialName);
}
@Override
protected Collection<String> getEveryDisplayableInstanceOfGeneric() {
ArrayList<String> keys = new ArrayList<>();
protected Collection<NamespacedKey> getEveryInstanceOfGeneric() {
Set<NamespacedKey> keys = new HashSet<>();
if (!this.shouldWork) {
return keys;
}
ConfigurationSection materialSection = ConfigHolder.UNIT_REPAIR_HOLDER.getConfig().getConfigurationSection(parentMaterial.name().toLowerCase());
if(materialSection == null){
return keys;
}
keys.addAll(materialSection.getKeys(false));
ConfigurationSection legacySection = ConfigHolder.UNIT_REPAIR_HOLDER.getConfig().getConfigurationSection(parentMaterial.getKey().toLowerCase());
ConfigurationSection materialSection = ConfigHolder.UNIT_REPAIR_HOLDER.getConfig().getConfigurationSection(parentMaterial.toString().toLowerCase());
addAllKeys(legacySection, keys);
addAllKeys(materialSection, keys);
return keys;
}
private Material materialFromName(String materialName){
Material mat = Material.getMaterial(materialName.toUpperCase());
private void addAllKeys(@Nullable ConfigurationSection section, @NotNull Set<NamespacedKey> keys) {
if (section == null) return;
for (var key : section.getKeys(false)) {
var material = NamespacedKey.fromString(key);
if (material == null) continue;
keys.add(material);
}
}
private Material materialFromName(NamespacedKey material) {
Material mat = MaterialUtil.INSTANCE.getMatFromKey(material);
if (mat == null || mat.isAir()) return Material.BARRIER;
return mat;
}
@ -163,7 +175,8 @@ public class UnitRepairElementListGui extends SettingGuiListConfigGui<String, Do
// ElementMappedToListGui methods
@Override // Not used in this implementation
public void updateLocal() {}
public void updateLocal() {
}
@Override
public void cleanAndBeUnusable() {

View file

@ -202,7 +202,6 @@ public class EnchantCostSettingsGui extends IntSettingsGui {
}
pane.bindItem('D', returnToDefault);
}
/**
@ -285,14 +284,14 @@ public class EnchantCostSettingsGui extends IntSettingsGui {
*/
@Override
public int getConfiguredValue() {
return ConfigOptions.INSTANCE.enchantmentValue(enchantment, false);
return ConfigOptions.INSTANCE.enchantmentValue(enchantment, false, false);
}
/**
* @return The configured value for the enchant setting book value.
*/
public int getConfiguredBookValue() {
return ConfigOptions.INSTANCE.enchantmentValue(enchantment, true);
return ConfigOptions.INSTANCE.enchantmentValue(enchantment, false, true);
}
@Override

View file

@ -63,7 +63,7 @@ public class EnchantSelectSettingGui extends SettingGuiListConfigGui<CAEnchantme
}
@Override
protected Collection<CAEnchantment> getEveryDisplayableInstanceOfGeneric() {
protected Collection<CAEnchantment> getEveryInstanceOfGeneric() {
Stream<CAEnchantment> toDisplayStream;
if(this.displayUnselected){
toDisplayStream = CAEnchantmentRegistry.getInstance().getNameSortedEnchantments().stream();
@ -141,10 +141,10 @@ public class EnchantSelectSettingGui extends SettingGuiListConfigGui<CAEnchantme
meta.setDisplayName("§" + (isIn ? 'a' : 'c') + CasedStringUtil.snakeToUpperSpacedCase(name));
if (isIn) {
meta.addEnchant(Enchantment.DAMAGE_UNDEAD, 1, true);
meta.addEnchant(Enchantment.SHARPNESS, 1, true);
meta.setLore(TRUE_LORE);
} else {
meta.removeEnchant(Enchantment.DAMAGE_UNDEAD);
meta.removeEnchant(Enchantment.SHARPNESS);
meta.setLore(FALSE_LORE);
}
meta.addItemFlags(ItemFlag.HIDE_ATTRIBUTES, ItemFlag.HIDE_ENCHANTS);

View file

@ -112,10 +112,10 @@ public class GroupSelectSettingGui extends AbstractSettingGui {
meta.setDisplayName("§" + (isIn ? 'a' : 'c') + CasedStringUtil.snakeToUpperSpacedCase(name));
if (isIn) {
meta.addEnchant(Enchantment.DAMAGE_UNDEAD, 1, true);
meta.addEnchant(Enchantment.SHARPNESS, 1, true);
meta.setLore(TRUE_LORE);
} else {
meta.removeEnchant(Enchantment.DAMAGE_UNDEAD);
meta.removeEnchant(Enchantment.SHARPNESS);
meta.setLore(FALSE_LORE);
}
meta.addItemFlags(ItemFlag.values());

View file

@ -217,7 +217,7 @@ public class MaterialSelectSettingGui extends MappedElementListConfigGui<Namespa
}
@Override
protected Collection<NamespacedKey> getEveryDisplayableInstanceOfGeneric() {
protected Collection<NamespacedKey> getEveryInstanceOfGeneric() {
return this.defaultMaterials;
}

View file

@ -2,10 +2,7 @@ package xyz.alexcrea.cuanvil.update;
import io.delilaheve.CustomAnvil;
import xyz.alexcrea.cuanvil.config.ConfigHolder;
import xyz.alexcrea.cuanvil.update.minecraft.MCUpdate;
import xyz.alexcrea.cuanvil.update.minecraft.Update_1_21;
import xyz.alexcrea.cuanvil.update.minecraft.Update_1_21_11;
import xyz.alexcrea.cuanvil.update.minecraft.Update_1_21_9;
import xyz.alexcrea.cuanvil.update.minecraft.*;
import xyz.alexcrea.cuanvil.update.plugin.*;
import javax.annotation.Nonnull;
@ -32,10 +29,12 @@ public class UpdateHandler {
new Version(1, 8, 0), PUpdate_1_8_0::handleUpdate,
new Version(1, 11, 0), PUpdate_1_11_0::handleUpdate,
new Version(1, 15, 5), PUpdate_1_15_5::handleUpdate,
new Version(1, 15, 6), PUpdate_1_15_6::handleUpdate
new Version(1, 15, 6), PUpdate_1_15_6::handleUpdate,
new Version(1, 17, 7), PUpdate_1_17_7::handleUpdate
);
private static final List<MCUpdate> mcUpdateMap = List.of(
new Update_1_20_5(),
new Update_1_21(),
new Update_1_21_9(),
new Update_1_21_11()

View file

@ -1,6 +1,7 @@
package xyz.alexcrea.cuanvil.update;
import org.bukkit.Bukkit;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.configuration.file.FileConfiguration;
import java.util.ArrayList;
@ -33,4 +34,20 @@ public class UpdateUtils {
}
public static boolean removeFromList(FileConfiguration config, String path, String toRemove) {
List<String> groups = new ArrayList<>(config.getStringList(path));
if (!groups.remove(toRemove)) return false;
config.set(path, groups);
return true;
}
public static void mergeSections(ConfigurationSection source, ConfigurationSection target) {
for (String key : source.getKeys(false)) {
if(target.contains(key)) continue;
target.set(key, source.get(key));
}
}
}

View file

@ -0,0 +1,98 @@
package xyz.alexcrea.cuanvil.update.minecraft;
import org.bukkit.configuration.file.FileConfiguration;
import org.jetbrains.annotations.NotNull;
import xyz.alexcrea.cuanvil.config.ConfigHolder;
import xyz.alexcrea.cuanvil.update.Version;
import java.util.HashSet;
import java.util.Set;
import static xyz.alexcrea.cuanvil.update.UpdateUtils.*;
public class Update_1_20_5 extends MCUpdate {
public Update_1_20_5() {
super(new Version(1, 20, 5));
}
@Override
protected void doUpdate() {
var tosave = new HashSet<ConfigHolder>();
updateName(tosave);
for (ConfigHolder holder : tosave) {
holder.saveToDisk(true);
}
}
private static String SWEEPING_ENCHANTS = "restriction_sweeping_edge.enchantments";
public static void updateName(@NotNull Set<ConfigHolder> tosave) {
var config = ConfigHolder.DEFAULT_CONFIG.getConfig();
var unitConfig = ConfigHolder.UNIT_REPAIR_HOLDER.getConfig();
var conflict = ConfigHolder.CONFLICT_HOLDER.getConfig();
// Rename sweeping to sweeping_edge
migrateEnchantLimit(config, "minecraft:sweeping");
migrateEnchantLimit(config, "sweeping");
migrateEnchantValues(config, "minecraft:sweeping");
migrateEnchantValues(config, "sweeping");
if (removeFromList(conflict, SWEEPING_ENCHANTS, "minecraft:sweeping"))
addAbsentToList(conflict, SWEEPING_ENCHANTS, "minecraft:sweeping_edge");
if (removeFromList(conflict, SWEEPING_ENCHANTS, "sweeping"))
addAbsentToList(conflict, SWEEPING_ENCHANTS, "minecraft:sweeping_edge");
// Rename scute to turtle_scute
migrateUnitRepair(unitConfig, "minecraft:scute");
migrateUnitRepair(unitConfig, "scute");
ConfigHolder.ITEM_GROUP_HOLDER.reload();
tosave.add(ConfigHolder.DEFAULT_CONFIG);
tosave.add(ConfigHolder.UNIT_REPAIR_HOLDER);
tosave.add(ConfigHolder.CONFLICT_HOLDER);
}
private static void migrateEnchantLimit(FileConfiguration config, String path) {
var finalPath = "enchant_limits." + path;
if (!config.isInt(finalPath)) return;
var value = config.getInt(finalPath);
config.set(finalPath, null);
if (!config.contains("enchant_limits.minecraft:sweeping_edge")) return;
if (!config.contains("enchant_limits.sweeping_edge")) return;
config.set("enchant_limits.minecraft:sweeping_edge", value);
}
private static void migrateEnchantValues(FileConfiguration config, String path) {
migrateEnchantValues(config, path, "item");
migrateEnchantValues(config, path, "book");
}
private static void migrateEnchantValues(FileConfiguration config, String path, String child) {
var finalPath = "enchant_values." + path + "." + child;
if (config.isInt(finalPath)) return;
var value = config.getInt(finalPath);
config.set(finalPath, null);
if (!config.contains("enchant_values.minecraft:sweeping_edge." + child)) return;
if (!config.contains("enchant_values.sweeping_edge." + child)) return;
config.set("enchant_values.minecraft:sweeping_edge." + child, value);
}
private static void migrateUnitRepair(FileConfiguration config, String path) {
var section = config.getConfigurationSection(path);
if (section == null) return;
config.set(path, null);
var turtle_scute = config.getConfigurationSection("minecraft:turtle_scute");
if (turtle_scute == null) config.set("minecraft:turtle_scute", section);
else mergeSections(section, turtle_scute);
}
}

View file

@ -1,6 +1,5 @@
package xyz.alexcrea.cuanvil.update.minecraft;
import io.delilaheve.CustomAnvil;
import xyz.alexcrea.cuanvil.config.ConfigHolder;
import xyz.alexcrea.cuanvil.update.UpdateUtils;
import xyz.alexcrea.cuanvil.update.Version;

View file

@ -38,26 +38,26 @@ public class Update_1_21_11 extends MCUpdate{
addAbsentToList(conflictConfig, "restriction_fire_aspect.notAffectedGroups", "spears");
// Unit repair for spears
unitConfig.set("gold_ingot.golden_spear", 0.25);
unitConfig.set("copper_ingot.copper_spear", 0.25);
unitConfig.set("iron_ingot.iron_spear", 0.25);
unitConfig.set("diamond.diamond_spear", 0.25);
unitConfig.set("netherite_ingot.netherite_spear", 0.25);
unitConfig.set("minecraft:gold_ingot.minecraft:golden_spear", 0.25);
unitConfig.set("minecraft:copper_ingot.minecraft:copper_spear", 0.25);
unitConfig.set("minecraft:iron_ingot.minecraft:iron_spear", 0.25);
unitConfig.set("minecraft:diamond.minecraft:diamond_spear", 0.25);
unitConfig.set("minecraft:netherite_ingot.minecraft:netherite_spear", 0.25);
unitConfig.set("cobblestone.stone_spear", 0.25);
unitConfig.set("cobbled_deepslate.stone_spear", 0.25);
unitConfig.set("minecraft:cobblestone.stone_spear", 0.25);
unitConfig.set("minecraft:cobbled_deepslate.stone_spear", 0.25);
unitConfig.set("oak_planks.wooden_spear", 0.25);
unitConfig.set("spruce_planks.wooden_spear", 0.25);
unitConfig.set("birch_planks.wooden_spear", 0.25);
unitConfig.set("jungle_planks.wooden_spear", 0.25);
unitConfig.set("acacia_planks.wooden_spear", 0.25);
unitConfig.set("dark_oak_planks.wooden_spear", 0.25);
unitConfig.set("mangrove_planks.wooden_spear", 0.25);
unitConfig.set("cherry_planks.wooden_spear", 0.25);
unitConfig.set("bamboo_planks.wooden_spear", 0.25);
unitConfig.set("crimson_planks.wooden_spear", 0.25);
unitConfig.set("warped_planks.wooden_spear", 0.25);
unitConfig.set("minecraft:oak_planks.minecraft:wooden_spear", 0.25);
unitConfig.set("minecraft:spruce_planks.minecraft:wooden_spear", 0.25);
unitConfig.set("minecraft:birch_planks.minecraft:wooden_spear", 0.25);
unitConfig.set("minecraft:jungle_planks.minecraft:wooden_spear", 0.25);
unitConfig.set("minecraft:acacia_planks.minecraft:wooden_spear", 0.25);
unitConfig.set("minecraft:dark_oak_planks.minecraft:wooden_spear", 0.25);
unitConfig.set("minecraft:mangrove_planks.minecraft:wooden_spear", 0.25);
unitConfig.set("minecraft:cherry_planks.minecraft:wooden_spear", 0.25);
unitConfig.set("minecraft:bamboo_planks.minecraft:wooden_spear", 0.25);
unitConfig.set("minecraft:crimson_planks.minecraft:wooden_spear", 0.25);
unitConfig.set("minecraft:warped_planks.minecraft:wooden_spear", 0.25);
// Create lunge enchant value and group
baseConfig.set("enchant_limits.minecraft:lunge", 3);

View file

@ -49,16 +49,16 @@ public class Update_1_21_9 extends MCUpdate{
public static void addCopperUnitRepair(FileConfiguration unitConfig) {
// Add unit repair
unitConfig.set("copper_ingot.copper_helmet", 0.25);
unitConfig.set("copper_ingot.copper_chestplate", 0.25);
unitConfig.set("copper_ingot.copper_leggings", 0.25);
unitConfig.set("copper_ingot.copper_boots", 0.25);
unitConfig.set("minecraft:copper_ingot.minecraft:copper_helmet", 0.25);
unitConfig.set("minecraft:copper_ingot.minecraft:copper_chestplate", 0.25);
unitConfig.set("minecraft:copper_ingot.minecraft:copper_leggings", 0.25);
unitConfig.set("minecraft:copper_ingot.minecraft:copper_boots", 0.25);
unitConfig.set("copper_ingot.copper_pickaxe", 0.25);
unitConfig.set("copper_ingot.copper_shovel", 0.25);
unitConfig.set("copper_ingot.copper_hoe", 0.25);
unitConfig.set("copper_ingot.copper_axe", 0.25);
unitConfig.set("copper_ingot.copper_sword", 0.25);
unitConfig.set("minecraft:copper_ingot.minecraft:copper_pickaxe", 0.25);
unitConfig.set("minecraft:copper_ingot.minecraft:copper_shovel", 0.25);
unitConfig.set("minecraft:copper_ingot.minecraft:copper_hoe", 0.25);
unitConfig.set("minecraft:copper_ingot.minecraft:copper_axe", 0.25);
unitConfig.set("minecraft:copper_ingot.minecraft:copper_sword", 0.25);
}
}

View file

@ -0,0 +1,21 @@
package xyz.alexcrea.cuanvil.update.plugin;
import xyz.alexcrea.cuanvil.config.ConfigHolder;
import xyz.alexcrea.cuanvil.update.UpdateUtils;
import xyz.alexcrea.cuanvil.update.Version;
import xyz.alexcrea.cuanvil.update.minecraft.Update_1_20_5;
import javax.annotation.Nonnull;
import java.util.Set;
public class PUpdate_1_17_7 {
public static void handleUpdate(@Nonnull Set<ConfigHolder> toSave) {
// fix only needed for 1.20.5 and above
Version current = UpdateUtils.currentMinecraftVersion();
if (new Version(1, 20, 5).greaterThan(current)) return;
Update_1_20_5.updateName(toSave);
}
}

View file

@ -24,6 +24,7 @@ import xyz.alexcrea.cuanvil.listener.PrepareAnvilListener
import xyz.alexcrea.cuanvil.update.ModrinthUpdateChecker
import xyz.alexcrea.cuanvil.update.PluginSetDefault
import xyz.alexcrea.cuanvil.update.UpdateHandler
import xyz.alexcrea.cuanvil.update.UpdateUtils
import xyz.alexcrea.cuanvil.util.MetricsUtil
import java.io.File
import java.io.FileReader
@ -56,6 +57,8 @@ open class CustomAnvil : JavaPlugin() {
// Permission string required to edit the plugin's config
const val editConfigPermission = "ca.config.edit"
// Permission string required to edit the plugin's config
const val giveEnchantmentPermission = "ca.command.enchantment"
// Command Name to reload the config
const val commandReloadName = "anvilconfigreload"
@ -142,7 +145,7 @@ open class CustomAnvil : JavaPlugin() {
// Add commands
try {
prepareCommand()
CustomAnvilCommand(this)
} catch (e: Exception) {
logger.log(Level.SEVERE, "error trying to register commands", e)
MetricsUtil.trackError(e)
@ -223,7 +226,8 @@ open class CustomAnvil : JavaPlugin() {
val version = description.version
val featured = if(version.contains("dev")) null else true
ModrinthUpdateChecker(modrinthPluginID, loader, null)
ModrinthUpdateChecker(modrinthPluginID, loader,
UpdateUtils.currentMinecraftVersion().toString())
.setFeatured(featured)
.setOnError {
logger.log(Level.WARNING, "error trying to fetch latest update", it)
@ -326,14 +330,4 @@ open class CustomAnvil : JavaPlugin() {
return yamlConfig
}
fun prepareCommand() {
var command = getCommand(commandReloadName)
command?.setExecutor(ReloadExecutor())
command = getCommand(commandConfigName)
command?.setExecutor(EditConfigExecutor())
CustomAnvilCommand(this)
}
}

View file

@ -86,6 +86,7 @@ object ConfigOptions {
// Keys for specific enchantment values
private const val KEY_BOOK = "book"
private const val KEY_BOOK_ON_BOOK = "book_on_book"
private const val KEY_ITEM = "item"
// Debug flag
@ -578,14 +579,15 @@ object ConfigOptions {
*/
fun enchantmentValue(
enchantment: CAEnchantment,
isFromBook: Boolean
isToBook: Boolean,
isFromBook: Boolean,
): Int {
// Test namespace
var limit = enchantmentValue(enchantment.key.toString(), isFromBook)
var limit = enchantmentValue(enchantment.key.toString(), isToBook, isFromBook)
if (limit != null) return limit
// Test legacy (name only)
limit = enchantmentValue(enchantment.enchantmentName, isFromBook)
limit = enchantmentValue(enchantment.enchantmentName, isToBook, isFromBook)
if (limit != null) return limit
// get default (and test old legacy if present)
@ -599,13 +601,22 @@ object ConfigOptions {
*/
private fun enchantmentValue(
enchantmentName: String,
isFromBook: Boolean
isToBook: Boolean,
isFromBook: Boolean,
): Int? {
val typeKey = if (isFromBook) KEY_BOOK else KEY_ITEM
val path = "${ENCHANT_VALUES_ROOT}.${enchantmentName}.$typeKey"
return CustomAnvil.instance
.config
.getInt(path, DEFAULT_ENCHANT_VALUE - 1)
val config = ConfigHolder.DEFAULT_CONFIG.config
if(isFromBook && isToBook) {
val specialPath = "${ENCHANT_VALUES_ROOT}.${enchantmentName}.$KEY_BOOK_ON_BOOK"
if(config.isInt(specialPath))
return config.getInt(specialPath)
.takeIf { it >= DEFAULT_ENCHANT_VALUE }
}
return config.getInt(path, DEFAULT_ENCHANT_VALUE - 1)
.takeIf { it >= DEFAULT_ENCHANT_VALUE }
}
@ -613,20 +624,9 @@ object ConfigOptions {
* Get default value if enchantment do not exist on config
*/
private fun getDefaultValue(
enchantment: CAEnchantment, // compatibility with 1.20.5. TODO better update system
enchantment: CAEnchantment,
isFromBook: Boolean
): Int {
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 rarity = enchantment.defaultRarity()
return if (isFromBook)
rarity.bookValue
@ -648,15 +648,6 @@ object ConfigOptions {
value = maxBeforeMergeDisabled(legacy)
if (value >= 0) return value
if (key == "minecraft:sweeping_edge") {
value = maxBeforeMergeDisabled("minecraft:sweeping")
if (value >= 0) return value
// legacy name of legacy enchantment name
value = maxBeforeMergeDisabled("sweeping")
if (value >= 0) return value
}
return DEFAULT_MAX_BEFORE_MERGE_DISABLED
}

Some files were not shown because too many files have changed in this diff Show more