mirror of
https://github.com/alexcrea/CustomAnvil.git
synced 2026-06-23 16:16:17 +02:00
add default value for enchantment cost config
This commit is contained in:
parent
1fd8501461
commit
3dc272ec97
3 changed files with 100 additions and 2 deletions
|
|
@ -0,0 +1,57 @@
|
||||||
|
package xyz.alexcrea.cuanvil.enchant;
|
||||||
|
|
||||||
|
// to bind EnchantmentRarity to an enchantment...
|
||||||
|
public enum EnchantmentProperties {
|
||||||
|
|
||||||
|
AQUA_AFFINITY(EnchantmentRarity.RARE),
|
||||||
|
BANE_OF_ARTHROPODS(EnchantmentRarity.UNCOMMON),
|
||||||
|
BINDING_CURSE(EnchantmentRarity.VERY_RARE),
|
||||||
|
BLAST_PROTECTION(EnchantmentRarity.RARE),
|
||||||
|
CHANNELING(EnchantmentRarity.VERY_RARE),
|
||||||
|
DEPTH_STRIDER(EnchantmentRarity.RARE),
|
||||||
|
EFFICIENCY(EnchantmentRarity.COMMON),
|
||||||
|
FLAME(EnchantmentRarity.RARE),
|
||||||
|
FEATHER_FALLING(EnchantmentRarity.UNCOMMON),
|
||||||
|
FIRE_ASPECT(EnchantmentRarity.RARE),
|
||||||
|
FIRE_PROTECTION(EnchantmentRarity.UNCOMMON),
|
||||||
|
FORTUNE(EnchantmentRarity.RARE),
|
||||||
|
FROST_WALKER(EnchantmentRarity.RARE),
|
||||||
|
IMPALING(EnchantmentRarity.RARE),
|
||||||
|
INFINITY(EnchantmentRarity.VERY_RARE),
|
||||||
|
KNOCKBACK(EnchantmentRarity.UNCOMMON),
|
||||||
|
LOOTING(EnchantmentRarity.RARE),
|
||||||
|
LOYALTY(EnchantmentRarity.COMMON),
|
||||||
|
LUCK_OF_THE_SEA(EnchantmentRarity.RARE),
|
||||||
|
LURE(EnchantmentRarity.RARE),
|
||||||
|
MENDING(EnchantmentRarity.RARE),
|
||||||
|
MULTISHOT(EnchantmentRarity.RARE),
|
||||||
|
PIERCING(EnchantmentRarity.COMMON),
|
||||||
|
POWER(EnchantmentRarity.COMMON),
|
||||||
|
PROJECTILE_PROTECTION(EnchantmentRarity.UNCOMMON),
|
||||||
|
PROTECTION(EnchantmentRarity.COMMON),
|
||||||
|
PUNCH(EnchantmentRarity.RARE),
|
||||||
|
QUICK_CHARGE(EnchantmentRarity.UNCOMMON),
|
||||||
|
RESPIRATION(EnchantmentRarity.RARE),
|
||||||
|
RIPTIDE(EnchantmentRarity.RARE),
|
||||||
|
SILK_TOUCH(EnchantmentRarity.VERY_RARE),
|
||||||
|
SHARPNESS(EnchantmentRarity.COMMON),
|
||||||
|
SMITE(EnchantmentRarity.UNCOMMON),
|
||||||
|
SOUL_SPEED(EnchantmentRarity.VERY_RARE),
|
||||||
|
SWIFT_SNEAK(EnchantmentRarity.VERY_RARE),
|
||||||
|
SWEEPING(EnchantmentRarity.RARE),
|
||||||
|
THORNS(EnchantmentRarity.VERY_RARE),
|
||||||
|
UNBREAKING(EnchantmentRarity.UNCOMMON),
|
||||||
|
VANISHING_CURSE(EnchantmentRarity.VERY_RARE)
|
||||||
|
|
||||||
|
;
|
||||||
|
|
||||||
|
private final EnchantmentRarity rarity;
|
||||||
|
EnchantmentProperties(EnchantmentRarity rarity){
|
||||||
|
this.rarity = rarity;
|
||||||
|
}
|
||||||
|
|
||||||
|
public EnchantmentRarity getRarity() {
|
||||||
|
return rarity;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,33 @@
|
||||||
|
package xyz.alexcrea.cuanvil.enchant;
|
||||||
|
|
||||||
|
// because spigot (1.18) do not support enchantment rarity, I need to do it myself...
|
||||||
|
public enum EnchantmentRarity {
|
||||||
|
|
||||||
|
NO_RARITY(0, 0),
|
||||||
|
COMMON(1),
|
||||||
|
UNCOMMON(2),
|
||||||
|
RARE(4),
|
||||||
|
VERY_RARE(8)
|
||||||
|
|
||||||
|
;
|
||||||
|
|
||||||
|
private final int itemValue;
|
||||||
|
private final int bookValue;
|
||||||
|
|
||||||
|
EnchantmentRarity(int itemValue, int bookValue){
|
||||||
|
this.itemValue = itemValue;
|
||||||
|
this.bookValue = bookValue;
|
||||||
|
}
|
||||||
|
EnchantmentRarity(int itemValue){
|
||||||
|
this(itemValue, Math.max(1,itemValue/2));
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getBookValue() {
|
||||||
|
return bookValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getItemValue() {
|
||||||
|
return itemValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -6,6 +6,8 @@ import org.bukkit.enchantments.Enchantment;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
import org.bukkit.inventory.meta.ItemMeta;
|
import org.bukkit.inventory.meta.ItemMeta;
|
||||||
import xyz.alexcrea.cuanvil.config.ConfigHolder;
|
import xyz.alexcrea.cuanvil.config.ConfigHolder;
|
||||||
|
import xyz.alexcrea.cuanvil.enchant.EnchantmentProperties;
|
||||||
|
import xyz.alexcrea.cuanvil.enchant.EnchantmentRarity;
|
||||||
import xyz.alexcrea.cuanvil.gui.config.settings.EnchantCostSettingsGui;
|
import xyz.alexcrea.cuanvil.gui.config.settings.EnchantCostSettingsGui;
|
||||||
import xyz.alexcrea.cuanvil.gui.util.GuiGlobalItems;
|
import xyz.alexcrea.cuanvil.gui.util.GuiGlobalItems;
|
||||||
import xyz.alexcrea.cuanvil.util.StringUtil;
|
import xyz.alexcrea.cuanvil.util.StringUtil;
|
||||||
|
|
@ -30,12 +32,18 @@ public class EnchantCostConfigGui extends AbstractEnchantConfigGui<EnchantCostSe
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public EnchantCostSettingsGui.EnchantCostSettingFactory getFactoryFromEnchant(Enchantment enchant) {
|
public EnchantCostSettingsGui.EnchantCostSettingFactory getFactoryFromEnchant(Enchantment enchant) {
|
||||||
String key = enchant.getKey().getKey().toLowerCase(Locale.ROOT);
|
String key = enchant.getKey().getKey().toLowerCase(Locale.ENGLISH);
|
||||||
String prettyKey = StringUtil.snakeToUpperSpacedCase(key);
|
String prettyKey = StringUtil.snakeToUpperSpacedCase(key);
|
||||||
|
|
||||||
|
// try to find rarity. default to 0 if not found
|
||||||
|
EnchantmentRarity rarity = EnchantmentRarity.NO_RARITY;
|
||||||
|
try {
|
||||||
|
rarity = EnchantmentProperties.valueOf(key.toUpperCase(Locale.ENGLISH)).getRarity();
|
||||||
|
}catch (IllegalArgumentException ignored){}
|
||||||
|
|
||||||
return EnchantCostSettingsGui.enchFactory(prettyKey+" Level Cost", this,
|
return EnchantCostSettingsGui.enchFactory(prettyKey+" Level Cost", this,
|
||||||
SECTION_NAME+'.'+key, ConfigHolder.DEFAULT_CONFIG, 0, 255,
|
SECTION_NAME+'.'+key, ConfigHolder.DEFAULT_CONFIG, 0, 255,
|
||||||
enchant.getMaxLevel(),4,
|
rarity.getItemValue(), rarity.getBookValue(),
|
||||||
1, 10, 50);
|
1, 10, 50);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue