Skip to content

Commit

Permalink
Update toString
Browse files Browse the repository at this point in the history
  • Loading branch information
AyhamAl-Ali committed Apr 5, 2024
1 parent a139e22 commit 1cc0840
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions src/main/java/ch/njol/skript/effects/EffEnchant.java
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
})
@Since("2.0, INSERT VERSION (store, specific disenchant)")
public class EffEnchant extends Effect {

static {
Skript.registerEffect(EffEnchant.class,
"enchant %~itemtypes% with %enchantmenttypes%",
Expand Down Expand Up @@ -84,7 +85,7 @@ public boolean init(Expression<?>[] exprs, int matchedPattern, Kleenean isDelaye
@Override
protected void execute(Event event) {
ItemType[] items = this.items.getArray(event);
if (items.length < 1)
if (items.length == 0) // shortcut
return;

EnchantmentType[] types = null;
Expand All @@ -94,7 +95,7 @@ protected void execute(Event event) {
return;

types = enchantments.getArray(event);
if (types.length < 1)
if (types.length == 0) // shortcut
return;
}

Expand Down Expand Up @@ -130,11 +131,13 @@ protected void execute(Event event) {

@Override
public String toString(@Nullable Event event, boolean debug) {
if (enchantments == null) {
return "disenchant " + (isStored ? "stored " + (isSpecificDisenchant ? enchantments.toString(event, debug) :
"enchantments") + " of " : "") + items.toString(event, debug) + (!isStored && isSpecificDisenchant ? " of " +
enchantments.toString(event, debug) : "");
return "enchant " + items.toString(event, debug) + " with " + (isStored ? "stored " : "") + enchantments;
if (isDisenchant) {
if (isStored)
return "unstore " + (isSpecificDisenchant ? enchantments.toString(event, debug) : "enchantments") + " of " + items.toString(event, debug);
else
return "disenchant " + items.toString(event, debug) + " from " + (isSpecificDisenchant ? enchantments.toString(event, debug) : "enchantments");
}
return (isStored ? "store " : "enchant ") + items.toString(event, debug) + (isStored ? " on " : " with ") + enchantments;
}

}

0 comments on commit 1cc0840

Please sign in to comment.