Skip to content

Commit

Permalink
Merge branch 'dev/feature' into feature/expr-enchantment-glint
Browse files Browse the repository at this point in the history
  • Loading branch information
Moderocky authored Aug 15, 2024
2 parents e17c558 + bc0fe53 commit cad832e
Show file tree
Hide file tree
Showing 76 changed files with 705 additions and 901 deletions.
35 changes: 0 additions & 35 deletions .github/workflows/java-11-builds.yml

This file was deleted.

2 changes: 1 addition & 1 deletion .github/workflows/java-17-builds.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Java 17 CI (MC 1.17-1.20.4)
name: Java 17 CI (MC 1.19.4-1.20.4)

on:
push:
Expand Down
29 changes: 0 additions & 29 deletions .github/workflows/junit-11-builds.yml

This file was deleted.

2 changes: 1 addition & 1 deletion .github/workflows/junit-17-builds.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: JUnit (MC 1.17-1.20.4)
name: JUnit (MC 1.19.4-1.20.4)

on:
push:
Expand Down
11 changes: 5 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ Skript requires **Spigot** to work. You heard it right, **CraftBukkit** does *no
**Paper**, which is a fork of Spigot, is recommended; it is required for some
parts of Skript to be available.

Skript supports only the **latest** patch versions of Minecraft 1.13+.
For example, this means that 1.16.5 is supported, but 1.16.4 is *not*.
Skript supports only the **latest** patch versions of Minecraft 1.19 and newer.
For example, this means that 1.19.4 is supported, but 1.19.3 is *not*.
Testing with all old patch versions is not feasible for us.

Minecraft 1.12 and earlier are not, and will not be supported. New Minecraft
Expand Down Expand Up @@ -77,15 +77,14 @@ Skript has some tests written in Skript. Running them requires a Minecraft
server, but our build script will create one for you. Running the tests is easy:

```
./gradlew (quickTest|skriptTest|skriptTestJava11|skriptTestJava17|skriptTestJava21)
./gradlew (quickTest|skriptTest|skriptTestJava17|skriptTestJava21)
```

<code>quickTest</code> runs the test suite on newest supported server version.
<code>skriptTestJava21</code> (1.20.6+) runs the tests on Java 21 supported versions.
<code>skriptTestJava17</code> (1.17-1.20.4) runs the tests on Java 17 supported versions.
<code>skriptTestJava11</code> (1.13-1.16) runs the tests on Java 11 supported versions.
<code>skriptTestJava17</code> (1.19.4-1.20.4) runs the tests on Java 17 supported versions.
<code>skriptTest</code> runs the tests on all versions.
That is, it runs skriptTestJava11, skriptTestJava17, and skriptTestJava21.
That is, it runs skriptTestJava17, and skriptTestJava21.

By running the tests, you agree to Mojang's End User License Agreement.

Expand Down
11 changes: 4 additions & 7 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ task build(overwrite: true, type: ShadowJar) {
from sourceSets.main.output
}

// Excludes the tests for the build task. Should be using junit, junitJava17, junitJava11, skriptTest, quickTest.
// Excludes the tests for the build task. Should be using junit, junitJava17, skriptTest, quickTest.
// We do not want tests to run for building. That's time consuming and annoying. Especially in development.
test {
exclude '**/*'
Expand Down Expand Up @@ -233,11 +233,10 @@ void createTestTask(String name, String desc, String environments, int javaVersi

def java21 = 21
def java17 = 17
def java11 = 11

def latestEnv = 'java21/paper-1.21.0.json'
def latestJava = java21
def oldestJava = java11
def oldestJava = java17

def latestJUnitEnv = 'java17/paper-1.20.4.json'
def latestJUnitJava = java17
Expand All @@ -260,25 +259,23 @@ int envJava = project.property('testEnvJavaVersion') == null ? latestJava : Inte
createTestTask('quickTest', 'Runs tests on one environment being the latest supported Java and Minecraft.', environments + latestEnv, latestJava, 0)
createTestTask('skriptTestJava21', 'Runs tests on all Java 21 environments.', environments + 'java21', java21, 0)
createTestTask('skriptTestJava17', 'Runs tests on all Java 17 environments.', environments + 'java17', java17, 0)
createTestTask('skriptTestJava11', 'Runs tests on all Java 11 environments.', environments + 'java11', java11, 0)
createTestTask('skriptTestDev', 'Runs testing server and uses \'system.in\' for command input, stop server to finish.', environments + env, envJava, 0, Modifiers.DEV_MODE, Modifiers.DEBUG)
createTestTask('skriptProfile', 'Starts the testing server with JProfiler support.', environments + latestEnv, latestJava, -1, Modifiers.PROFILE)
createTestTask('genNightlyDocs', 'Generates the Skript documentation website html files.', environments + env, envJava, 0, Modifiers.GEN_NIGHTLY_DOCS)
createTestTask('genReleaseDocs', 'Generates the Skript documentation website html files for a release.', environments + env, envJava, 0, Modifiers.GEN_RELEASE_DOCS)
tasks.register('skriptTest') {
description = 'Runs tests on all environments.'
dependsOn skriptTestJava11, skriptTestJava17, skriptTestJava21
dependsOn skriptTestJava17, skriptTestJava21
}

createTestTask('JUnitQuick', 'Runs JUnit tests on one environment being the latest supported Java and Minecraft.', environments + latestJUnitEnv, latestJUnitJava, 0, Modifiers.JUNIT)
// Disabled as EasyMock 5.2.0 is required for Java 21 support
// However, we are currently using 5.0.1 (see https://github.com/SkriptLang/Skript/pull/6204#discussion_r1405302009)
//createTestTask('JUnitJava21', 'Runs JUnit tests on all Java 21 environments.', environments + 'java21', java21, 0, Modifiers.JUNIT)
createTestTask('JUnitJava17', 'Runs JUnit tests on all Java 17 environments.', environments + 'java17', java17, 0, Modifiers.JUNIT)
createTestTask('JUnitJava11', 'Runs JUnit tests on all Java 11 environments.', environments + 'java11', java11, 0, Modifiers.JUNIT)
tasks.register('JUnit') {
description = 'Runs JUnit tests on all environments.'
dependsOn JUnitJava11, JUnitJava17//, JUnitJava21
dependsOn JUnitJava17//, JUnitJava21
}

// Build flavor configurations
Expand Down
5 changes: 2 additions & 3 deletions code-conventions.md
Original file line number Diff line number Diff line change
Expand Up @@ -194,9 +194,8 @@ Your comments should look something like these:
## Language Features

### Compatibility
[//]: # (To be updated for 2.10 for Java 17)
* Contributions should maintain Java 11 source/binary compatibility, even though compiling Skript requires Java 21
- Users must not need JRE newer than version 11
* Contributions should maintain Java 17 source/binary compatibility, even though compiling Skript requires Java 21
- Users must not need JRE newer than version 17
* Versions up to and including Java 21 should work too
- Please avoid using unsafe reflection
* It is recommended to make fields final, if they are effectively final
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ org.gradle.parallel=true

groupid=ch.njol
name=skript
version=2.9.0
version=2.9.1
jarName=Skript.jar
testEnv=java21/paper-1.21.0
testEnvJavaVersion=21
1 change: 1 addition & 0 deletions src/main/java/ch/njol/skript/aliases/AliasesProvider.java
Original file line number Diff line number Diff line change
Expand Up @@ -416,6 +416,7 @@ public EntityData<?> getRelatedEntity(ItemData item) {

public void clearAliases() {
aliases.clear();
materials.clear();
variations.clear();
aliasesMap.clear();
}
Expand Down
36 changes: 17 additions & 19 deletions src/main/java/ch/njol/skript/classes/Changer.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,13 @@
* isn't overridden.
* <p>
* Some useful Changers can be found in {@link DefaultChangers}
*
* @author Peter Güttinger
*
* @see DefaultChangers
* @see Expression
*/
public interface Changer<T> {

public static enum ChangeMode {
enum ChangeMode {
ADD, SET, REMOVE, REMOVE_ALL, DELETE, RESET;
}

Expand All @@ -45,45 +44,44 @@ public static enum ChangeMode {
* <p>
* Unlike {@link Expression#acceptChange(ChangeMode)} this method must not print errors.
*
* @param mode
* @param mode The {@link ChangeMode} to test.
* @return An array of types that {@link #change(Object[], Object[], ChangeMode)} accepts as its <code>delta</code> parameter (which can be arrays to denote that multiple of
* that type are accepted), or null if the given mode is not supported. For {@link ChangeMode#DELETE} and {@link ChangeMode#RESET} this can return any non-null array to
* mark them as supported.
*/
@Nullable
public abstract Class<?>[] acceptChange(ChangeMode mode);
Class<?> @Nullable [] acceptChange(ChangeMode mode);

/**
* @param what The objects to change
* @param delta An array with one or more instances of one or more of the the classes returned by {@link #acceptChange(ChangeMode)} for the given change mode (null for
* {@link ChangeMode#DELETE} and {@link ChangeMode#RESET}). <b>This can be a Object[], thus casting is not allowed.</b>
* @param mode
* @param mode The {@link ChangeMode} to test.
* @throws UnsupportedOperationException (optional) if this method was called on an unsupported ChangeMode.
*/
public abstract void change(T[] what, @Nullable Object[] delta, ChangeMode mode);
void change(T[] what, Object @Nullable [] delta, ChangeMode mode);

public static abstract class ChangerUtils {
@SuppressWarnings("unchecked")
public static <T, V> void change(final Changer<T> changer, final Object[] what, final @Nullable Object[] delta, final ChangeMode mode) {
abstract class ChangerUtils {

public static <T> void change(Changer<T> changer, Object[] what, Object @Nullable [] delta, ChangeMode mode) {
//noinspection unchecked
changer.change((T[]) what, delta, mode);
}

/**
* Tests whether an expression accepts changes of a certain type. If multiple types are given it test for whether any of the types is accepted.
*
* @param e The expression to test
* @param expression The expression to test
* @param mode The ChangeMode to use in the test
* @param types The types to test for
* @return Whether <tt>e.{@link Expression#change(Event, Object[], ChangeMode) change}(event, type[], mode)</tt> can be used or not.
* @return Whether <tt>expression.{@link Expression#change(Event, Object[], ChangeMode) change}(event, type[], mode)</tt> can be used or not.
*/
public static boolean acceptsChange(final Expression<?> e, final ChangeMode mode, final Class<?>... types) {
final Class<?>[] cs = e.acceptChange(mode);
if (cs == null)
public static boolean acceptsChange(final Expression<?> expression, final ChangeMode mode, final Class<?>... types) {
final Class<?>[] validTypes = expression.acceptChange(mode);
if (validTypes == null)
return false;
for (final Class<?> type : types) {
for (final Class<?> c : cs) {
if (c.isArray() ? c.getComponentType().isAssignableFrom(type) : c.isAssignableFrom(type))
for (final Class<?> validType : validTypes) {
if (validType.isArray() ? validType.getComponentType().isAssignableFrom(type) : validType.isAssignableFrom(type))
return true;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,7 @@ public World[] executeSimple(Object[][] params) {
}, DefaultClasses.LOCATION, true) {
@Override
@Nullable
public Location[] execute(FunctionEvent<?> e, Object[][] params) {
public Location[] execute(FunctionEvent<?> event, Object[][] params) {
for (int i : new int[] {0, 1, 2, 4, 5}) {
if (params[i] == null || params[i].length == 0 || params[i][0] == null)
return null;
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/ch/njol/skript/command/Commands.java
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ public void onServerCommand(ServerCommandEvent event) {
};

static boolean handleEffectCommand(CommandSender sender, String command) {
if (!(sender instanceof ConsoleCommandSender || sender.hasPermission("skript.effectcommands") || SkriptConfig.allowOpsToUseEffectCommands.value() && sender.isOp()))
if (!(Skript.testing() || sender instanceof ConsoleCommandSender || sender.hasPermission("skript.effectcommands") || SkriptConfig.allowOpsToUseEffectCommands.value() && sender.isOp()))
return false;
try {
command = "" + command.substring(SkriptConfig.effectCommandToken.value().length()).trim();
Expand Down Expand Up @@ -300,7 +300,7 @@ public static void registerListeners() {
Bukkit.getPluginManager().registerEvents(new Listener() {
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
public void onPlayerChat(AsyncPlayerChatEvent event) {
if (!SkriptConfig.enableEffectCommands.value() || !event.getMessage().startsWith(SkriptConfig.effectCommandToken.value()))
if ((!SkriptConfig.enableEffectCommands.value() && !Skript.testing()) || !event.getMessage().startsWith(SkriptConfig.effectCommandToken.value()))
return;
if (!event.isAsynchronous()) {
if (handleEffectCommand(event.getPlayer(), event.getMessage()))
Expand Down
34 changes: 34 additions & 0 deletions src/main/java/ch/njol/skript/conditions/CondIsTamed.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package ch.njol.skript.conditions;

import ch.njol.skript.conditions.base.PropertyCondition;
import ch.njol.skript.doc.Description;
import ch.njol.skript.doc.Examples;
import ch.njol.skript.doc.Name;
import ch.njol.skript.doc.Since;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Tameable;

@Name("Is Tamed")
@Description("Check if a tameable entity is tamed (horse, parrot, cat, etc.).")
@Examples({
"send true if {_horse} is tamed",
"tame {_horse} if {_horse} is untamed"
})
@Since("INSERT VERSION")
public class CondIsTamed extends PropertyCondition<Entity> {

static {
register(CondIsTamed.class, "(tamed|domesticated)", "entities");
}

@Override
public boolean check(Entity entity) {
return (entity instanceof Tameable) && ((Tameable) entity).isTamed();
}

@Override
protected String getPropertyName() {
return "tamed";
}

}
Loading

0 comments on commit cad832e

Please sign in to comment.