Skip to content
Open
Show file tree
Hide file tree
Changes from 4 commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
13d7af5
refactor(syntax): migrate enchantments to module-based system
bluelhf May 28, 2026
d021d94
feat(enchantments): add min level, max level, and stored enchantments…
bluelhf May 28, 2026
0f8b9ca
fix(codestyle): remove duplicate code and assert non-nullability in E…
bluelhf May 28, 2026
6fbe3ff
style(enchantment): address code style issues and use converters wher…
bluelhf May 28, 2026
a8e34ff
style: apply suggestions from code review
bluelhf May 28, 2026
555fb4c
fix(enchantment): fix enchantment glint override logic
bluelhf May 28, 2026
decd611
style(enchantments): newline before closing brace in ExprStoredEnchan…
bluelhf May 29, 2026
23c9750
Revert "style(enchantments): newline before closing brace in ExprStor…
bluelhf May 29, 2026
68cb97a
chore(enchantments): add explicit syntax instance suppliers
bluelhf Jun 2, 2026
3fa0fc4
style: add blank lines and fix annotations
bluelhf Jun 2, 2026
faba4ad
fix(classes): allow 'enchantmenttype' user input
bluelhf Jun 2, 2026
28026d3
style(tests): replace spaces with tabs
bluelhf Jun 2, 2026
7138a8b
chore(math): add more saturating arithmetic tools to math2
bluelhf Jun 12, 2026
bb0caeb
chore(test): move enchantment tests to enchantments module
bluelhf Jun 12, 2026
2c0efd1
refactor(enchantments): merge min and max enchantment level expressions
bluelhf Jun 12, 2026
3d80def
style(enchantments): apply code style to registrations
bluelhf Jun 12, 2026
5745638
fix(enchantment-offer): add bounds checks and use Integer rather than…
bluelhf Jun 12, 2026
363b06c
fix(enchantment-offer): correct pattern
bluelhf Jun 12, 2026
cd4d41a
fix(enchantment-offer): compute enchantment cost correctly
bluelhf Jun 12, 2026
d452bb2
fix(enchantments): use saturating arithmetic in ExprEnchantmentLevel …
bluelhf Jun 12, 2026
88d8429
fix(enchantments): fix typo in enchant item
bluelhf Jun 12, 2026
b852974
fix(enchantments): improve legacy handling of ExprEnchantItem changer
bluelhf Jun 12, 2026
54ecd1f
fix(enchantments): add article to ExprAppliedEnchantments#toString
bluelhf Jun 12, 2026
5ee0deb
fix(enchantments): use pattern matching instanceof in ExprAppliedEnch…
bluelhf Jun 12, 2026
33e6859
feat(enchantments): add ExprEnchantmentHint and alphabetise registrat…
bluelhf Jun 12, 2026
150ffbe
fix(enchantments): use index-based detection for override type in Con…
bluelhf Jun 12, 2026
b7ccc61
Merge branch 'dev/feature' into feature/enchantments-module
bluelhf Jun 13, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 0 additions & 38 deletions src/main/java/ch/njol/skript/classes/data/BukkitClasses.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@
import org.bukkit.block.banner.PatternType;
import org.bukkit.block.data.BlockData;
import org.bukkit.command.CommandSender;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.enchantments.EnchantmentOffer;
import org.bukkit.entity.*;
import org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason;
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
Expand Down Expand Up @@ -424,17 +422,6 @@ public boolean mustSyncDeserialization() {
}
}));

Classes.registerClass(new RegistryClassInfo<>(Enchantment.class, Registry.ENCHANTMENT, "enchantment", "enchantments")
.user("enchantments?")
.name("Enchantment")
.description("An enchantment, e.g. 'sharpness' or 'fortune'. Unlike <a href='#enchantmenttype'>enchantment type</a> " +
"this type has no level, but you usually don't need to use this type anyway.",
"NOTE: Minecraft namespaces are supported, ex: 'minecraft:basalt_deltas'.",
"As of Minecraft 1.21 this will also support custom enchantments using namespaces, ex: 'myenchants:explosive'.")
.examples("")
.since("1.4.6")
.before("enchantmenttype"));

Material[] allMaterials = Material.values();
Classes.registerClass(new ClassInfo<>(Material.class, "material")
.name(ClassInfo.NO_DOC)
Expand Down Expand Up @@ -615,31 +602,6 @@ public String[] getPatterns() {
ExpressionPropertyHandler.of(GameRule::getName, String.class)
));

Classes.registerClass(new ClassInfo<>(EnchantmentOffer.class, "enchantmentoffer")
.user("enchant[ment][ ]offers?")
.name("Enchantment Offer")
.description("The enchantmentoffer in an enchant prepare event.")
.examples("on enchant prepare:",
"\tset enchant offer 1 to sharpness 1",
"\tset the cost of enchant offer 1 to 10 levels")
.since("2.5")
.parser(new Parser<>() {
@Override
public boolean canParse(ParseContext context) {
return false;
}

@Override
public String toString(EnchantmentOffer eo, int flags) {
return Classes.toString(eo.getEnchantment()) + " " + eo.getEnchantmentLevel();
}

@Override
public String toVariableNameString(EnchantmentOffer eo) {
return "offer:" + Classes.toString(eo.getEnchantment()) + "=" + eo.getEnchantmentLevel();
}
}));

Classes.registerClass(new RegistryClassInfo<>(Attribute.class, Registry.ATTRIBUTE, "attributetype", "attribute types")
.user("attribute ?types?")
.name("Attribute Type")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -545,35 +545,6 @@ public boolean supportsOrdering() {
}
});

// EnchantmentOffer Comparators
// EnchantmentOffer - EnchantmentType
Comparators.registerComparator(EnchantmentOffer.class, EnchantmentType.class, new Comparator<EnchantmentOffer, EnchantmentType>() {
@Override
public Relation compare(EnchantmentOffer eo, EnchantmentType et) {
return Relation.get(eo.getEnchantment() == et.getType() && eo.getEnchantmentLevel() == et.getLevel());
}

@Override
public boolean supportsOrdering() {
return false;
}
});
// EnchantmentOffer - Experience
Comparators.registerComparator(EnchantmentOffer.class, Experience.class, new Comparator<EnchantmentOffer, Experience>() {
@Override
public Relation compare(EnchantmentOffer eo, Experience exp) {
return Relation.get(eo.getCost() == exp.getXP());
}

@Override public boolean supportsOrdering() {
return false;
}
});

//EnchantmentType - Enchantment
Comparators.registerComparator(EnchantmentType.class, Enchantment.class, ((enchantmentType, enchantment) ->
Relation.get(enchantmentType.getType().equals(enchantment))));

Comparators.registerComparator(Inventory.class, InventoryType.class, new Comparator<Inventory, InventoryType>() {
@Override
public Relation compare(Inventory inventory, InventoryType inventoryType) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@
import org.bukkit.block.DoubleChest;
import org.bukkit.command.BlockCommandSender;
import org.bukkit.command.CommandSender;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.enchantments.EnchantmentOffer;
import org.bukkit.entity.Entity;
import org.bukkit.entity.EntitySnapshot;
import org.bukkit.entity.LivingEntity;
Expand Down Expand Up @@ -304,15 +302,9 @@ public void setAmount(Number amount) {
return null;
});

// Enchantment - EnchantmentType
Converters.registerConverter(Enchantment.class, EnchantmentType.class, e -> new EnchantmentType(e, -1));

// Vector - Direction
Converters.registerConverter(Vector.class, Direction.class, Direction::new);

// EnchantmentOffer - EnchantmentType
Converters.registerConverter(EnchantmentOffer.class, EnchantmentType.class, eo -> new EnchantmentType(eo.getEnchantment(), eo.getEnchantmentLevel()));

Converters.registerConverter(String.class, World.class, Bukkit::getWorld);

if (Skript.classExists("org.bukkit.entity.EntitySnapshot"))
Expand Down
27 changes: 0 additions & 27 deletions src/main/java/ch/njol/skript/classes/data/SkriptClasses.java
Original file line number Diff line number Diff line change
Expand Up @@ -382,33 +382,6 @@ public String toVariableNameString(Color color) {
"grow a huge red mushroom above the block")
.since("1.0"));

Classes.registerClass(new ClassInfo<>(EnchantmentType.class, "enchantmenttype")
.user("enchant(ing|ment) types?")
.name("Enchantment Type")
.description("An enchantment with an optional level, e.g. 'sharpness 2' or 'fortune'.")
.usage("<enchantment> [<level>]")
.examples("enchant the player's tool with sharpness 5",
"helmet is enchanted with waterbreathing")
.since("1.4.6")
.parser(new Parser<EnchantmentType>() {
@Override
@Nullable
public EnchantmentType parse(final String s, final ParseContext context) {
return EnchantmentType.parse(s);
}

@Override
public String toString(final EnchantmentType t, final int flags) {
return t.toString();
}

@Override
public String toVariableNameString(final EnchantmentType o) {
return o.toString();
}
})
.serializer(new YggdrasilSerializer<>()));

Classes.registerClass(new ClassInfo<>(Experience.class, "experience")
.user("experience ?(points?)?")
.name("Experience")
Expand Down
105 changes: 0 additions & 105 deletions src/main/java/ch/njol/skript/expressions/ExprEnchantingExpCost.java

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import org.skriptlang.skript.bukkit.breeding.BreedingModule;
import org.skriptlang.skript.bukkit.brewing.BrewingModule;
import org.skriptlang.skript.bukkit.damagesource.DamageSourceModule;
import org.skriptlang.skript.bukkit.enchantments.EnchantmentModule;
import org.skriptlang.skript.bukkit.entity.EntityModule;
import org.skriptlang.skript.bukkit.fishing.FishingModule;
import org.skriptlang.skript.bukkit.input.InputModule;
Expand Down Expand Up @@ -50,7 +51,8 @@ public Iterable<AddonModule> children() {
new PDCModule(this),
new PotionModule(this),
new TagModule(this),
new TextModule(this)
new TextModule(this),
new EnchantmentModule(this)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Should be ordered alphabetically in the list

);
}

Expand Down
Loading