Skip to content

Commit bb9bd18

Browse files
committed
Cleanup, fully implement ExprName, many docs, some other improvements
- allows stateful property handlers - removes use of AnyNamed - removes NameHandler in favor of just using ExpressionPropertyHandler - Avoid exposing silly cast to users when possible in PropertyBaseExpression - fix issue with handling DELETE and RESET changers in PropertyBaseExpression - add support for default toString impl in PropertyBaseExpression
1 parent 7d15cea commit bb9bd18

25 files changed

Lines changed: 1764 additions & 1182 deletions

src/main/java/ch/njol/skript/aliases/ItemType.java

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
import ch.njol.skript.bukkitutil.ItemUtils;
77
import ch.njol.skript.lang.Unit;
88
import ch.njol.skript.lang.util.common.AnyAmount;
9-
import ch.njol.skript.lang.util.common.AnyNamed;
109
import ch.njol.skript.localization.Adjective;
1110
import ch.njol.skript.localization.GeneralWords;
1211
import ch.njol.skript.localization.Language;
@@ -49,8 +48,7 @@
4948
import java.util.stream.Collectors;
5049

5150
@ContainerType(ItemStack.class)
52-
public class ItemType implements Unit, Iterable<ItemData>, Container<ItemStack>, YggdrasilExtendedSerializable,
53-
AnyNamed, AnyAmount {
51+
public class ItemType implements Unit, Iterable<ItemData>, Container<ItemStack>, YggdrasilExtendedSerializable, AnyAmount {
5452

5553
private static final boolean IS_RUNNING_1_21 = Skript.isRunningMinecraft(1, 21);
5654

@@ -1611,18 +1609,11 @@ public ItemType getBaseType() {
16111609
return copy;
16121610
}
16131611

1614-
@Override
16151612
public @Nullable String name() {
16161613
ItemMeta meta = this.getItemMeta();
16171614
return meta.hasDisplayName() ? meta.getDisplayName() : null;
16181615
}
16191616

1620-
@Override
1621-
public boolean supportsNameChange() {
1622-
return true;
1623-
}
1624-
1625-
@Override
16261617
public void setName(String name) {
16271618
ItemMeta meta = this.getItemMeta();
16281619
meta.setDisplayName(name);

src/main/java/ch/njol/skript/classes/ClassInfo.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
import org.jetbrains.annotations.NotNull;
1414
import org.jetbrains.annotations.Nullable;
1515
import org.skriptlang.skript.lang.properties.Property;
16+
import org.skriptlang.skript.lang.properties.Property.PropertyInfo;
1617
import org.skriptlang.skript.lang.properties.PropertyHandler;
1718

1819
import java.util.*;
@@ -477,13 +478,13 @@ public String toString(final @Nullable Event event, final boolean debug) {
477478
}
478479

479480

480-
private final Map<Property<?>, Property.PropertyInfo<?>> propertyInfos = new HashMap<>();
481+
private final Map<Property<?>, PropertyInfo<?>> propertyInfos = new HashMap<>();
481482

482483
public <Handler extends PropertyHandler<T>> ClassInfo<T> property(Property<? super Handler> property, @NotNull Handler handler) {
483484
if (propertyInfos.containsKey(property)) {
484485
throw new IllegalStateException("Property " + property.name() + " is already registered for the " + c.getName() + " type.");
485486
}
486-
propertyInfos.put(property, new Property.PropertyInfo<>(property, handler));
487+
propertyInfos.put(property, new PropertyInfo<>(property, handler));
487488
Classes.CLASS_INFOS_BY_PROPERTY.computeIfAbsent(property, k -> new ArrayList<>()).add(this);
488489
return this;
489490
}
@@ -492,12 +493,12 @@ public boolean hasProperty(Property<?> property) {
492493
return propertyInfos.containsKey(property);
493494
}
494495

495-
public <Handler extends PropertyHandler<?>> @Nullable Property.PropertyInfo<Handler> getPropertyInfo(Property<Handler> property) {
496+
public <Handler extends PropertyHandler<?>> @Nullable PropertyInfo<Handler> getPropertyInfo(Property<Handler> property) {
496497
if (!propertyInfos.containsKey(property)) {
497498
return null;
498499
}
499500
//noinspection unchecked
500-
return (Property.PropertyInfo<Handler>) propertyInfos.get(property);
501+
return (PropertyInfo<Handler>) propertyInfos.get(property);
501502
}
502503

503504

0 commit comments

Comments
 (0)