Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
5dd71b8
basic implementations for Contains and Named properties
sovdeeth Aug 29, 2025
cbc9107
fix rogue find+replace
sovdeeth Aug 29, 2025
7c90f01
cleanup and move lookupPropertyInfo to override of get(Class)
sovdeeth Aug 29, 2025
5160466
Remove necessary usage of toHandlerType
APickledWalrus Aug 29, 2025
85122a3
add base handler class
sovdeeth Aug 29, 2025
1afb977
Improve property resolution, add back-compat for AnyNamed, AnyContain…
sovdeeth Aug 31, 2025
50a5314
cleaning and reorganization
sovdeeth Aug 31, 2025
7d15cea
implement common module
sovdeeth Aug 31, 2025
bb9bd18
Cleanup, fully implement ExprName, many docs, some other improvements
sovdeeth Aug 31, 2025
56a4dad
re-add type in register() and Script#name()
sovdeeth Aug 31, 2025
a7d068a
implement documents plus a bit more cleanup
sovdeeth Sep 1, 2025
2bd6f39
cleanup entity/player changer usage
sovdeeth Sep 1, 2025
61aeff7
add property info itself to related syntaxes docs
sovdeeth Sep 1, 2025
69a4dff
Update name's description
sovdeeth Sep 1, 2025
e239267
Merge branch 'dev/feature' into feature/type-properties
sovdeeth Sep 1, 2025
cc14eba
Merge branch 'dev/feature' into feature/type-properties
sovdeeth Sep 2, 2025
2c4f1ef
update docs, add since
sovdeeth Sep 10, 2025
903bf63
small fixes
sovdeeth Sep 10, 2025
2b77441
Replace AnyAmount/ExprAmount
sovdeeth Sep 11, 2025
8e1705a
Finish replacing AnyAmount, add Empty property, add PropertyBaseSynta…
sovdeeth Sep 11, 2025
9876223
banish utils class
sovdeeth Sep 11, 2025
3126300
AnyValued replacement
sovdeeth Sep 12, 2025
11ace37
better errors
sovdeeth Sep 12, 2025
e158111
some docs
sovdeeth Sep 12, 2025
e61c782
fix PropCondContains with somewhat horrible code that works
sovdeeth Sep 15, 2025
a87aee9
final cleanup
sovdeeth Sep 17, 2025
5342ea7
final cleanup 2
sovdeeth Sep 17, 2025
fa7fab9
Apply suggestions from code review
sovdeeth Sep 17, 2025
5f375a3
reorder methods + missing continue
sovdeeth Sep 17, 2025
54a2dab
Update PropExprValueOf.java
sovdeeth Sep 18, 2025
2c5d638
Merge branch 'dev/feature' into feature/type-properties
sovdeeth Sep 18, 2025
f4c6bea
Update JSONGenerator.java
sovdeeth Sep 18, 2025
066b37f
Apply suggestions from code review
sovdeeth Sep 24, 2025
ee5551a
requested changes
sovdeeth Sep 25, 2025
741a5c1
add config option to enable type properties
sovdeeth Sep 25, 2025
db61980
Update ExprName.java
sovdeeth Sep 25, 2025
538b17d
Use ChangeInPlace when changing property expressions
sovdeeth Sep 29, 2025
d87115f
Merge branch 'dev/feature' into feature/type-properties
sovdeeth Sep 29, 2025
ef80692
Update JSONGenerator.java
sovdeeth Sep 29, 2025
cbe1913
Merge branch 'feature/type-properties' of https://github.com/sovdeeth…
sovdeeth Sep 29, 2025
1e85835
Update JSONGenerator.java
sovdeeth Sep 29, 2025
4690ee4
better CIP requirement detection
sovdeeth Sep 29, 2025
e7e386e
improve error message for missing properties
sovdeeth Sep 29, 2025
ee4f737
requested changes
sovdeeth Oct 1, 2025
d9378bc
Merge branch 'dev/feature' into feature/type-properties
sovdeeth Oct 1, 2025
44cef9a
Merge branch 'dev/feature' into feature/type-properties
sovdeeth Oct 2, 2025
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
55 changes: 17 additions & 38 deletions src/main/java/ch/njol/skript/Skript.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,54 +3,30 @@
import ch.njol.skript.aliases.Aliases;
import ch.njol.skript.bukkitutil.BurgerHelper;
import ch.njol.skript.classes.ClassInfo;
import ch.njol.skript.classes.data.BukkitClasses;
import ch.njol.skript.classes.data.BukkitEventValues;
import ch.njol.skript.classes.data.DefaultComparators;
import ch.njol.skript.classes.data.DefaultConverters;
import ch.njol.skript.classes.data.DefaultFunctions;
import ch.njol.skript.classes.data.DefaultOperations;
import ch.njol.skript.classes.data.JavaClasses;
import ch.njol.skript.classes.data.SkriptClasses;
import ch.njol.skript.classes.data.*;
import ch.njol.skript.command.Commands;
import ch.njol.skript.doc.Documentation;
import ch.njol.skript.events.EvtSkript;
import ch.njol.skript.expressions.arithmetic.ExprArithmetic;
import ch.njol.skript.hooks.Hook;
import ch.njol.skript.lang.*;
import ch.njol.skript.lang.Effect;
import ch.njol.skript.lang.Condition.ConditionType;
import ch.njol.skript.lang.util.SimpleExpression;
import ch.njol.skript.localization.Language;
import ch.njol.skript.localization.Message;
import ch.njol.skript.localization.PluralizingArgsMessage;
import ch.njol.skript.log.BukkitLoggerFilter;
import ch.njol.skript.log.CountingLogHandler;
import ch.njol.skript.log.ErrorDescLogHandler;
import ch.njol.skript.log.ErrorQuality;
import ch.njol.skript.log.LogEntry;
import ch.njol.skript.log.LogHandler;
import ch.njol.skript.log.SkriptLogger;
import ch.njol.skript.log.TestingLogHandler;
import ch.njol.skript.log.Verbosity;
import ch.njol.skript.log.*;
import ch.njol.skript.registrations.Classes;
import ch.njol.skript.registrations.EventValues;
import ch.njol.skript.registrations.Feature;
import ch.njol.skript.test.runner.EffObjectives;
import ch.njol.skript.test.runner.SkriptAsyncJUnitTest;
import ch.njol.skript.test.runner.SkriptJUnitTest;
import ch.njol.skript.test.runner.SkriptTestEvent;
import ch.njol.skript.test.runner.TestMode;
import ch.njol.skript.test.runner.TestTracker;
import ch.njol.skript.test.runner.*;
import ch.njol.skript.timings.SkriptTimings;
import ch.njol.skript.update.ReleaseManifest;
import ch.njol.skript.update.ReleaseStatus;
import ch.njol.skript.update.UpdateManifest;
import ch.njol.skript.util.Date;
import ch.njol.skript.util.EmptyStacktraceException;
import ch.njol.skript.util.ExceptionUtils;
import ch.njol.skript.util.FileUtils;
import ch.njol.skript.util.Task;
import ch.njol.skript.util.Utils;
import ch.njol.skript.util.Version;
import ch.njol.skript.util.*;
import ch.njol.skript.util.chat.BungeeConverter;
import ch.njol.skript.util.chat.ChatMessages;
import ch.njol.skript.variables.Variables;
Expand All @@ -63,11 +39,7 @@
import com.google.gson.GsonBuilder;
import io.papermc.lib.PaperLib;
import org.bstats.bukkit.Metrics;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.OfflinePlayer;
import org.bukkit.Server;
import org.bukkit.*;
import org.bukkit.command.CommandSender;
import org.bukkit.command.PluginCommand;
import org.bukkit.entity.Player;
Expand Down Expand Up @@ -104,12 +76,15 @@
import org.skriptlang.skript.bukkit.registration.BukkitRegistryKeys;
import org.skriptlang.skript.bukkit.registration.BukkitSyntaxInfos;
import org.skriptlang.skript.bukkit.tags.TagModule;
import org.skriptlang.skript.common.CommonModule;
import org.skriptlang.skript.lang.comparator.Comparator;
import org.skriptlang.skript.lang.comparator.Comparators;
import org.skriptlang.skript.lang.converter.Converter;
import org.skriptlang.skript.lang.converter.Converters;
import org.skriptlang.skript.lang.entry.EntryValidator;
import org.skriptlang.skript.lang.experiment.ExperimentRegistry;
import org.skriptlang.skript.lang.properties.Property;
import org.skriptlang.skript.lang.properties.PropertyRegistry;
import org.skriptlang.skript.lang.script.Script;
import org.skriptlang.skript.lang.structure.Structure;
import org.skriptlang.skript.lang.structure.StructureInfo;
Expand Down Expand Up @@ -502,6 +477,9 @@ public void onEnable() {
experimentRegistry = new ExperimentRegistry(this);
Feature.registerAll(getAddonInstance(), experimentRegistry);

skript.storeRegistry(PropertyRegistry.class, new PropertyRegistry(this));
Property.registerDefaultProperties();

// Load classes which are always safe to use
new JavaClasses(); // These may be needed in configuration

Expand Down Expand Up @@ -590,10 +568,11 @@ public void onEnable() {
FurnaceModule.load();
LootTableModule.load();
skript.loadModules(
new DamageSourceModule(),
new ItemComponentModule(),
new BrewingModule()
);
new DamageSourceModule(),
new ItemComponentModule(),
new BrewingModule(),
new CommonModule()
);
} catch (final Exception e) {
exception(e, "Could not load required .class files: " + e.getLocalizedMessage());
setEnabled(false);
Expand Down
3 changes: 3 additions & 0 deletions src/main/java/ch/njol/skript/SkriptConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,9 @@ public static String formatDate(final long timestamp) {
})
.optional(true);

public static final Option<Boolean> useTypeProperties = new Option<>("use type properties", false)
.optional(true);

public static final Option<Boolean> allowUnsafePlatforms = new Option<>("allow unsafe platforms", false)
.optional(true);

Expand Down
2 changes: 2 additions & 0 deletions src/main/java/ch/njol/skript/classes/AnyInfo.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@
* These auto-generate their user patterns (e.g. {@code named} -> {@code any named thing}).
*
* @see AnyProvider
* @deprecated Use {@link org.skriptlang.skript.lang.properties.Property} instead.
*/
@Deprecated(since="INSERT VERSION", forRemoval = true)
public class AnyInfo<Type extends AnyProvider> extends ClassInfo<Type> {

/**
Expand Down
82 changes: 78 additions & 4 deletions src/main/java/ch/njol/skript/classes/ClassInfo.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,20 @@
import ch.njol.skript.lang.DefaultExpression;
import ch.njol.skript.lang.util.SimpleLiteral;
import ch.njol.skript.localization.Noun;
import ch.njol.skript.registrations.Classes;
import ch.njol.util.coll.iterator.ArrayIterator;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import org.bukkit.event.Event;
import org.jetbrains.annotations.ApiStatus;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.annotations.Unmodifiable;
import org.skriptlang.skript.addon.SkriptAddon;
import org.skriptlang.skript.lang.properties.Property;
import org.skriptlang.skript.lang.properties.Property.PropertyInfo;
import org.skriptlang.skript.lang.properties.PropertyHandler;

import java.util.Arrays;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Set;
import java.util.*;
import java.util.function.Supplier;
import java.util.regex.Pattern;
import java.util.regex.PatternSyntaxException;
Expand Down Expand Up @@ -476,4 +480,74 @@ public String toString(final @Nullable Event event, final boolean debug) {
return getName().getSingular();
}

private final Map<Property<?>, PropertyInfo<?>> propertyInfos = new HashMap<>();
private final Map<Property<?>, PropertyDocs> propertyDocumentation = new HashMap<>();

@ApiStatus.Experimental
public record PropertyDocs(Property<?> property, String description, SkriptAddon provider) {}

/**
* Registers this class as having the given property, using the given property handler.
* @param property The property this class should have
* @param description A short description of the property for documentation
* @param handler The handler for this property
* @return This ClassInfo object
* @param <Handler> The type of the property handler
* @throws IllegalStateException If this property is already registered for this class
*/
@ApiStatus.Experimental
public <Handler extends PropertyHandler<T>> ClassInfo<T> property(Property<? super Handler> property, String description, SkriptAddon addon, @NotNull Handler handler) {
if (propertyInfos.containsKey(property)) {
throw new IllegalStateException("Property " + property.name() + " is already registered for the " + c.getName() + " type.");
}
propertyInfos.put(property, new PropertyInfo<>(property, handler));
Classes.hasProperty(property, this);
propertyDocumentation.put(property, new PropertyDocs(property, description, addon));
return this;
}

/**
* Checks whether this class already has the given property registered.
* @param property The property to check
* @return True if this class has the property, false otherwise
*/
@ApiStatus.Experimental
public boolean hasProperty(Property<?> property) {
return propertyInfos.containsKey(property);
}

/**
* @return An unmodifiable collection of all the properties this class has.
*/
@ApiStatus.Experimental
public @Unmodifiable Collection<Property<?>> getAllProperties() {
return Collections.unmodifiableCollection(propertyInfos.keySet());
}

/**
* Gets the property info for the given property, or null if this class does not have the property.
* @param property The property to get the info for
* @return The property info, or null if this class does not have the property
* @param <Handler> The type of the property handler
*/
@ApiStatus.Experimental
public <Handler extends PropertyHandler<?>> @Nullable PropertyInfo<Handler> getPropertyInfo(Property<Handler> property) {
if (!propertyInfos.containsKey(property)) {
return null;
}
//noinspection unchecked
return (PropertyInfo<Handler>) propertyInfos.get(property);
}

/**
* Gets the type-specific documentation for the given property, or null if this type does not have the property.
* Meant to be used for documentation.
* @param property The property to get the documentation for
* @return The documentation, or null if this type does not have the property
*/
@ApiStatus.Experimental
public PropertyDocs getPropertyDocumentation(Property<?> property) {
return propertyDocumentation.get(property);
}

}
Loading