Skip to content

Modernise enchantments#8668

Open
bluelhf wants to merge 8 commits into
SkriptLang:dev/featurefrom
bluelhf:feature/enchantments-module
Open

Modernise enchantments#8668
bluelhf wants to merge 8 commits into
SkriptLang:dev/featurefrom
bluelhf:feature/enchantments-module

Conversation

@bluelhf
Copy link
Copy Markdown
Contributor

@bluelhf bluelhf commented May 28, 2026

Problem

The current enchantment syntaxes are not yet migrated to the new module-based registration system, and their code is in many places out of date both in style and in logic.

Solution

This PR adds a new module for syntaxes related to enchantments, moves the existing syntaxes to the new module, improves their code style and flow and implements three new syntaxes:

  1. Minimum enchantment level: the minimum starting level for an enchantment in vanilla Minecraft. This is 1 for all currently existing enchantments (but I still made it use the Bukkit API instead of just returning 1!)
  2. Maximum enchantment level: the minimum's more useful sibling, e.g. 5 for Efficiency.
  3. Stored enchantments: the enchantments stored in an enchanted book (or anything else with the data component!)

Testing Completed

There is a new unit test for stored enchantments. I ran quickTest to ensure that my changes don't break any of the existing tests.

Supporting Information

I would appreciate if people with scripts that use these syntaxes extensively could test to make sure they still work identically to how they were before.


Completes: none
Related: none
AI assistance: Gemini 3.1 Pro was used to evaluate human-made changes

@bluelhf bluelhf requested a review from a team as a code owner May 28, 2026 20:43
@bluelhf bluelhf requested review from Pesekjak and TheMug06 and removed request for a team May 28, 2026 20:43
Comment thread src/main/java/org/skriptlang/skript/bukkit/enchantments/EnchantmentModule.java Outdated
Comment thread src/main/java/org/skriptlang/skript/bukkit/enchantments/EnchantmentModule.java Outdated
Comment thread src/main/java/org/skriptlang/skript/bukkit/enchantments/EnchantmentModule.java Outdated
bluelhf and others added 4 commits May 29, 2026 00:56
thanks @SirSmurfy2!

Co-authored-by: SirSmurfy2 <82696841+theabsolutionism@users.noreply.github.com>
…tments

Co-authored-by: SirSmurfy2 <82696841+Absolutionism@users.noreply.github.com>
…edEnchantments"

This reverts commit decd611, which was an incorrectly applied suggestion in GitHub UI.
@skriptlang-automation skriptlang-automation Bot added the needs reviews A PR that needs additional reviews label May 29, 2026
}

private static final Patterns<Operation> patterns;
private static final Patterns<Operation> patterns = new Patterns<>(new Object[][]{
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
private static final Patterns<Operation> patterns = new Patterns<>(new Object[][]{
private static final Patterns<Operation> PATTERNS = new Patterns<>(new Object[][]{

register(CondItemEnchantmentGlint.class, PropertyType.BE, "forced to [:not] glint", "itemtypes");
}
public static void register(SyntaxRegistry registry) {
registry.register(SyntaxRegistry.CONDITION, PropertyCondition
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing #supplier

});
Skript.registerEffect(EffEnchant.class, patterns.getPatterns());
public static void register(SyntaxRegistry registry) {
registry.register(SyntaxRegistry.EFFECT, SyntaxInfo.builder(EffEnchant.class)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing #supplier

"(clear|delete|reset) %itemtypes%'s enchantment glint override");
public static void register(SyntaxRegistry registry) {
registry.register(SyntaxRegistry.EFFECT, SyntaxInfo.builder(EffForceEnchantmentGlint.class)
.addPatterns(
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing #supplier

Skript.registerExpression(ExprAppliedEnchantments.class, EnchantmentType.class, ExpressionType.SIMPLE, "[the] applied enchant[ment]s");
public static void register(SyntaxRegistry registry) {
registry.register(SyntaxRegistry.EXPRESSION,
builder(ExprAppliedEnchantments.class, EnchantmentType.class)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing #supplier

Skript.registerExpression(ExprItemWithEnchantmentGlint.class, ItemType.class, ExpressionType.PROPERTY, "%itemtypes% with[:out] [enchant[ment]] glint");
public static void register(SyntaxRegistry registry) {
registry.register(SyntaxRegistry.EXPRESSION, builder(ExprItemWithEnchantmentGlint.class, ItemType.class)
.addPattern("%itemtypes% with[:out] [enchant[ment]] glint")
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing #supplier


public static void register(SyntaxRegistry registry) {
registry.register(SyntaxRegistry.EXPRESSION, infoBuilder(
ExprMaximumEnchantmentLevel.class, Integer.class,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing #supplier


public static void register(SyntaxRegistry registry) {
registry.register(SyntaxRegistry.EXPRESSION, infoBuilder(
ExprMinimumEnchantmentLevel.class, Integer.class,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing #supplier

.before("enchantmenttype"));

Classes.registerClass(new ClassInfo<>(EnchantmentType.class, "enchantmenttype")
.user("enchant(ing|ment) types?")
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
.user("enchant(ing|ment) types?")
.user("enchant(ing|ment) ?types?")

Comment on lines +148 to +149
}
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
}
}
}
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs reviews A PR that needs additional reviews

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants