This commit is contained in:
BuildTools 2023-08-21 12:47:42 +05:00
parent a8750a17e4
commit e48e76e503
12 changed files with 46 additions and 30 deletions

View File

@ -5,7 +5,7 @@
<parent>
<artifactId>ExcellentEnchants</artifactId>
<groupId>su.nightexpress.excellentenchants</groupId>
<version>3.5.4</version>
<version>3.5.5</version>
</parent>
<modelVersion>4.0.0</modelVersion>
@ -81,27 +81,27 @@
<dependency>
<groupId>su.nightexpress.excellentenchants</groupId>
<artifactId>NMS</artifactId>
<version>3.5.4</version>
<version>3.5.5</version>
</dependency>
<dependency>
<groupId>su.nightexpress.excellentenchants</groupId>
<artifactId>V1_17_R1</artifactId>
<version>3.5.4</version>
<version>3.5.5</version>
</dependency>
<dependency>
<groupId>su.nightexpress.excellentenchants</groupId>
<artifactId>V1_18_R2</artifactId>
<version>3.5.4</version>
<version>3.5.5</version>
</dependency>
<dependency>
<groupId>su.nightexpress.excellentenchants</groupId>
<artifactId>V1_19_R3</artifactId>
<version>3.5.4</version>
<version>3.5.5</version>
</dependency>
<dependency>
<groupId>su.nightexpress.excellentenchants</groupId>
<artifactId>V1_20_R1</artifactId>
<version>3.5.4</version>
<version>3.5.5</version>
</dependency>
</dependencies>

View File

@ -60,6 +60,10 @@ public class Config {
"Use '" + Placeholders.GENERIC_AMOUNT + "' placeholder for amount of charges.")
.setWriter((cfg, path, map) -> map.forEach((perc, str) -> cfg.set(path + "." + perc, str)));
public static final JOption<Boolean> ENCHANTMENTS_CHARGES_COMPARE_TYPE_ONLY = JOption.create("Enchantments.Charges.Compare_Material_Only", false,
"When enabled, only item material will be checked to determine if item can be used as an enchantment fuel.",
"When disabled (default), it will compare the whole item meta including name, lore, model data etc.");
public static final JOption<ItemStack> ENCHANTMENTS_CHARGES_FUEL_ITEM = JOption.create("Enchantments.Charges.Fuel_Item",
new ItemStack(Material.LAPIS_LAZULI),
"Default item used to recharge item's enchantments on anvils.",

View File

@ -333,6 +333,9 @@ public abstract class ExcellentEnchant extends Enchantment implements IEnchantme
}
public boolean isChargesFuel(@NotNull ItemStack item) {
if (Config.ENCHANTMENTS_CHARGES_COMPARE_TYPE_ONLY.get()) {
return item.getType() == this.getChargesFuel().getType();
}
return item.isSimilar(this.getChargesFuel());
}

View File

@ -27,6 +27,7 @@ import su.nexmedia.engine.utils.EntityUtil;
import su.nightexpress.excellentenchants.ExcellentEnchants;
import su.nightexpress.excellentenchants.api.enchantment.meta.Arrowed;
import su.nightexpress.excellentenchants.api.enchantment.type.*;
import su.nightexpress.excellentenchants.config.Config;
import su.nightexpress.excellentenchants.enchantment.EnchantManager;
import su.nightexpress.excellentenchants.enchantment.util.EnchantDropContainer;
import su.nightexpress.excellentenchants.enchantment.util.EnchantUtils;
@ -97,7 +98,7 @@ public class EnchantHandlerListener extends AbstractListener<ExcellentEnchants>
combatEnchant.consumeChargesNoUpdate(weapon, level);
}
});
EnchantUtils.updateDisplay(weapon);
EnchantUtils.updateChargesDisplay(weapon);
}
private void handleCombatArmorEnchants(@NotNull EntityDamageByEntityEvent e,
@ -116,7 +117,7 @@ public class EnchantHandlerListener extends AbstractListener<ExcellentEnchants>
combatEnchant.consumeChargesNoUpdate(armor, level);
}
});
EnchantUtils.updateDisplay(armor);
EnchantUtils.updateChargesDisplay(armor);
}
}
@ -128,7 +129,7 @@ public class EnchantHandlerListener extends AbstractListener<ExcellentEnchants>
enchant.consumeChargesNoUpdate(item, level);
}
});
EnchantUtils.updateDisplay(item);
EnchantUtils.updateChargesDisplay(item);
});
}
@ -165,7 +166,7 @@ public class EnchantHandlerListener extends AbstractListener<ExcellentEnchants>
bowEnchant.consumeChargesNoUpdate(bow, level);
}
});
EnchantUtils.updateDisplay(bow);
EnchantUtils.updateChargesDisplay(bow);
if (e.getProjectile() instanceof Projectile projectile) {
this.setSourceWeapon(projectile, bow);
@ -208,7 +209,7 @@ public class EnchantHandlerListener extends AbstractListener<ExcellentEnchants>
interEnchant.consumeChargesNoUpdate(item, level);
}
});
EnchantUtils.updateDisplay(item);
EnchantUtils.updateChargesDisplay(item);
}
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
@ -225,7 +226,7 @@ public class EnchantHandlerListener extends AbstractListener<ExcellentEnchants>
enchant.consumeChargesNoUpdate(item, level);
}
});
EnchantUtils.updateDisplay(item);
EnchantUtils.updateChargesDisplay(item);
}
// ---------------------------------------------------------------
@ -242,7 +243,9 @@ public class EnchantHandlerListener extends AbstractListener<ExcellentEnchants>
deathEnchant.consumeChargesNoUpdate(item, level);
}
}));
EnchantUtils.updateDisplay(item);
if (Config.ENCHANTMENTS_CHARGES_ENABLED.get()) {
EnchantUtils.updateChargesDisplay(item);
}
});
Player killer = entity.getKiller();
@ -257,7 +260,7 @@ public class EnchantHandlerListener extends AbstractListener<ExcellentEnchants>
deathEnchant.consumeChargesNoUpdate(weapon, level);
}
});
EnchantUtils.updateDisplay(weapon);
EnchantUtils.updateChargesDisplay(weapon);
}
// Handle BlockBreak enchantments.
@ -275,7 +278,7 @@ public class EnchantHandlerListener extends AbstractListener<ExcellentEnchants>
blockEnchant.consumeChargesNoUpdate(tool, level);
}
});
EnchantUtils.updateDisplay(tool);
EnchantUtils.updateChargesDisplay(tool);
}
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
@ -293,7 +296,7 @@ public class EnchantHandlerListener extends AbstractListener<ExcellentEnchants>
enchant.consumeChargesNoUpdate(tool, level);
}
});
EnchantUtils.updateDisplay(tool);
EnchantUtils.updateChargesDisplay(tool);
BlockState state = e.getBlockState();
World world = state.getWorld();

View File

@ -124,7 +124,7 @@ public class EnchantmentsListMenu extends ConfigMenu<ExcellentEnchants> implemen
if (lore == null) lore = new ArrayList<>();
List<String> conflicts = enchant.getConflicts().isEmpty() ? Collections.emptyList() : new ArrayList<>(this.enchantLoreConflicts);
List<String> conflictNames = enchant.getConflicts().stream().map(EnchantUtils::getLocalized).toList();
List<String> conflictNames = enchant.getConflicts().stream().map(EnchantUtils::getLocalized).filter(Objects::nonNull).toList();
conflicts = StringUtil.replace(conflicts, Placeholders.ENCHANTMENT_NAME, true, conflictNames);
List<String> charges = enchant.isChargesEnabled() ? new ArrayList<>(this.enchantLoreCharges) : Collections.emptyList();

View File

@ -45,10 +45,10 @@ public class EnchantUtils {
return NamespacedKey.minecraft(id.toLowerCase());
}
@NotNull
@Nullable
public static String getLocalized(@NotNull String keyRaw) {
Enchantment enchantment = Enchantment.getByKey(NamespacedKey.minecraft(keyRaw));
return enchantment == null ? "null" : getLocalized(enchantment);
return enchantment == null ? null : getLocalized(enchantment);
}
@NotNull
@ -175,6 +175,12 @@ public class EnchantUtils {
item.setItemMeta(meta);
}
public static void updateChargesDisplay(@NotNull ItemStack item) {
if (Config.ENCHANTMENTS_CHARGES_ENABLED.get()) {
updateDisplay(item);
}
}
public static boolean updateDisplay(@NotNull ItemStack item) {
if (Config.ENCHANTMENTS_DISPLAY_MODE.get() != 1) return false;
@ -399,7 +405,7 @@ public class EnchantUtils {
}
}
});
EnchantUtils.updateDisplay(item);
EnchantUtils.updateChargesDisplay(item);
});
}
}

View File

@ -5,7 +5,7 @@
<parent>
<artifactId>ExcellentEnchants</artifactId>
<groupId>su.nightexpress.excellentenchants</groupId>
<version>3.5.4</version>
<version>3.5.5</version>
</parent>
<modelVersion>4.0.0</modelVersion>

View File

@ -5,7 +5,7 @@
<parent>
<artifactId>ExcellentEnchants</artifactId>
<groupId>su.nightexpress.excellentenchants</groupId>
<version>3.5.4</version>
<version>3.5.5</version>
</parent>
<modelVersion>4.0.0</modelVersion>
@ -26,7 +26,7 @@
<dependency>
<groupId>su.nightexpress.excellentenchants</groupId>
<artifactId>NMS</artifactId>
<version>3.5.4</version>
<version>3.5.5</version>
</dependency>
</dependencies>

View File

@ -5,7 +5,7 @@
<parent>
<artifactId>ExcellentEnchants</artifactId>
<groupId>su.nightexpress.excellentenchants</groupId>
<version>3.5.4</version>
<version>3.5.5</version>
</parent>
<modelVersion>4.0.0</modelVersion>
@ -26,7 +26,7 @@
<dependency>
<groupId>su.nightexpress.excellentenchants</groupId>
<artifactId>NMS</artifactId>
<version>3.5.4</version>
<version>3.5.5</version>
</dependency>
</dependencies>

View File

@ -5,7 +5,7 @@
<parent>
<artifactId>ExcellentEnchants</artifactId>
<groupId>su.nightexpress.excellentenchants</groupId>
<version>3.5.4</version>
<version>3.5.5</version>
</parent>
<modelVersion>4.0.0</modelVersion>
@ -26,7 +26,7 @@
<dependency>
<groupId>su.nightexpress.excellentenchants</groupId>
<artifactId>NMS</artifactId>
<version>3.5.4</version>
<version>3.5.5</version>
</dependency>
</dependencies>

View File

@ -5,7 +5,7 @@
<parent>
<artifactId>ExcellentEnchants</artifactId>
<groupId>su.nightexpress.excellentenchants</groupId>
<version>3.5.4</version>
<version>3.5.5</version>
</parent>
<modelVersion>4.0.0</modelVersion>
@ -26,7 +26,7 @@
<dependency>
<groupId>su.nightexpress.excellentenchants</groupId>
<artifactId>NMS</artifactId>
<version>3.5.4</version>
<version>3.5.5</version>
</dependency>
</dependencies>

View File

@ -7,7 +7,7 @@
<groupId>su.nightexpress.excellentenchants</groupId>
<artifactId>ExcellentEnchants</artifactId>
<packaging>pom</packaging>
<version>3.5.4</version>
<version>3.5.5</version>
<modules>
<module>Core</module>
<module>NMS</module>