Skip to content

Commit

Permalink
Merge branch 'dev/feature' into clear-message
Browse files Browse the repository at this point in the history
  • Loading branch information
sovdeeth authored Jul 1, 2024
2 parents 7f0c723 + 9db5426 commit eab54ff
Show file tree
Hide file tree
Showing 14 changed files with 106 additions and 33 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Java 8 CI (MC 1.13-1.16)
name: Java 11 CI (MC 1.13-1.16)

on:
push:
Expand Down Expand Up @@ -26,7 +26,7 @@ jobs:
- name: Grant execute permission for gradlew
run: chmod +x gradlew
- name: Build Skript and run test scripts
run: ./gradlew clean skriptTestJava8
run: ./gradlew clean skriptTestJava11
- name: Upload Nightly Build
uses: actions/upload-artifact@v4
if: success()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,4 @@ jobs:
- name: Grant execute permission for gradlew
run: chmod +x gradlew
- name: Build Skript and run JUnit
run: ./gradlew clean JUnitJava8
run: ./gradlew clean JUnitJava11
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ 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.9+.
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*.
Testing with all old patch versions is not feasible for us.

Minecraft 1.8 and earlier are not, and will not be supported. New Minecraft
Minecraft 1.12 and earlier are not, and will not be supported. New Minecraft
versions will be supported as soon as possible.

## Download
Expand Down Expand Up @@ -77,15 +77,15 @@ 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|skriptTestJava8|skriptTestJava17|skriptTestJava21)
./gradlew (quickTest|skriptTest|skriptTestJava11|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>skriptTestJava8</code> (1.13-1.16) runs the tests on Java 8 supported versions.
<code>skriptTestJava11</code> (1.13-1.16) runs the tests on Java 11 supported versions.
<code>skriptTest</code> runs the tests on all versions.
That is, it runs skriptTestJava8, skriptTestJava17, and skriptTestJava21.
That is, it runs skriptTestJava11, skriptTestJava17, and skriptTestJava21.

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

Expand Down Expand Up @@ -164,7 +164,7 @@ dependencies {
}
```

An example of the version tag would be ```dev37c```.
An example of the version tag would be ```2.8.5```.

> Note: If Gradle isn't able to resolve Skript's dependencies, just [disable the resolution of transitive dependencies](https://docs.gradle.org/current/userguide/resolution_rules.html#sec:disabling_resolution_transitive_dependencies) for Skript in your project.
Expand Down
18 changes: 9 additions & 9 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, junitJava8, skriptTest, quickTest.
// Excludes the tests for the build task. Should be using junit, junitJava17, junitJava11, 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 @@ -224,7 +224,7 @@ void createTestTask(String name, String desc, String environments, int javaVersi
if (!gradle.taskGraph.hasTask(":tasks") && !gradle.startParameter.dryRun && modifiers.contains(Modifiers.PROFILE)) {
if (!project.hasProperty('profiler'))
throw new MissingPropertyException('Add parameter -Pprofiler=<path to profiler>', 'profiler', String.class)

args += '-agentpath:' + project.property('profiler') + '=port=8849,nowait'
}
}
Expand All @@ -233,11 +233,11 @@ void createTestTask(String name, String desc, String environments, int javaVersi

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

def latestEnv = 'java21/paper-1.20.6.json'
def latestJava = java21
def oldestJava = java8
def oldestJava = java11

def latestJUnitEnv = 'java17/paper-1.20.4.json'
def latestJUnitJava = java17
Expand All @@ -260,25 +260,25 @@ 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('skriptTestJava8', 'Runs tests on all Java 8 environments.', environments + 'java8', java8, 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 skriptTestJava8, skriptTestJava17, skriptTestJava21
dependsOn skriptTestJava11, 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('JUnitJava8', 'Runs JUnit tests on all Java 8 environments.', environments + 'java8', java8, 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 JUnitJava8, JUnitJava17//, JUnitJava21
dependsOn JUnitJava11, JUnitJava17//, JUnitJava21
}

// Build flavor configurations
Expand Down Expand Up @@ -394,7 +394,7 @@ javadoc {
exclude("ch/njol/skript/lang/function/ExprFunctionCall.java")
exclude("ch/njol/skript/hooks/**")
exclude("ch/njol/skript/test/**")

classpath = configurations.compileClasspath + sourceSets.main.output
options.encoding = 'UTF-8'
// currently our javadoc has a lot of errors, so we need to suppress the linter
Expand Down
2 changes: 1 addition & 1 deletion code-conventions.md
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ Your comments should look something like these:
## Language Features

### Compatibility
[//]: # (To be updated after feature/2.9 for Java 17)
[//]: # (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
* Versions up to and including Java 21 should work too
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,7 @@ public boolean mustSyncDeserialization() {
protected boolean canBeInstantiated() {
return false;
}
}));
}).cloner(BlockData::clone));

Classes.registerClass(new ClassInfo<>(Location.class, "location")
.user("locations?")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@
import org.bukkit.event.inventory.InventoryType;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack;
import org.bukkit.potion.PotionEffectType;
import org.skriptlang.skript.lang.comparator.Comparator;
import org.skriptlang.skript.lang.comparator.Comparators;
import org.skriptlang.skript.lang.comparator.Relation;
Expand Down Expand Up @@ -653,6 +654,9 @@ public boolean supportsOrdering() {
return false;
}
});

// Potion Effect Type
Comparators.registerComparator(PotionEffectType.class, PotionEffectType.class, (one, two) -> Relation.get(one.equals(two)));
}

}
39 changes: 26 additions & 13 deletions src/main/java/ch/njol/skript/effects/EffBan.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
import org.bukkit.OfflinePlayer;
import org.bukkit.entity.Player;
import org.bukkit.event.Event;
import org.eclipse.jdt.annotation.Nullable;

import ch.njol.skript.Skript;
import ch.njol.skript.doc.Description;
Expand All @@ -38,6 +37,7 @@
import ch.njol.skript.lang.SkriptParser.ParseResult;
import ch.njol.skript.util.Timespan;
import ch.njol.util.Kleenean;
import org.jetbrains.annotations.Nullable;

@Name("Ban")
@Description({"Bans or unbans a player or an IP address.",
Expand All @@ -46,19 +46,23 @@
"We recommend that you test your scripts so that no accidental permanent bans are applied.",
"",
"Note that banning people does not kick them from the server.",
"Consider using the <a href='effects.html#EffKick'>kick effect</a> after applying a ban."})
"You can optionally use 'and kick' or consider using the <a href='effects.html#EffKick'>kick effect</a> after applying a ban."})
@Examples({"unban player",
"ban \"127.0.0.1\"",
"IP-ban the player because \"he is an idiot\"",
"ban player due to \"inappropriate language\" for 2 days"})
@Since("1.4, 2.1.1 (ban reason), 2.5 (timespan)")
"ban player due to \"inappropriate language\" for 2 days",
"ban and kick player due to \"inappropriate language\" for 2 days"})
@Since("1.4, 2.1.1 (ban reason), 2.5 (timespan), INSERT VERSION (kick)")
public class EffBan extends Effect {

static {
Skript.registerEffect(EffBan.class,
"ban %strings/offlineplayers% [(by reason of|because [of]|on account of|due to) %-string%] [for %-timespan%]", "unban %strings/offlineplayers%",
"ban %players% by IP [(by reason of|because [of]|on account of|due to) %-string%] [for %-timespan%]", "unban %players% by IP",
"IP(-| )ban %players% [(by reason of|because [of]|on account of|due to) %-string%] [for %-timespan%]", "(IP(-| )unban|un[-]IP[-]ban) %players%");
"ban [kick:and kick] %strings/offlineplayers% [(by reason of|because [of]|on account of|due to) %-string%] [for %-timespan%]",
"unban %strings/offlineplayers%",
"ban [kick:and kick] %players% by IP [(by reason of|because [of]|on account of|due to) %-string%] [for %-timespan%]",
"unban %players% by IP",
"IP(-| )ban [kick:and kick] %players% [(by reason of|because [of]|on account of|due to) %-string%] [for %-timespan%]",
"(IP(-| )unban|un[-]IP[-]ban) %players%");
}

@SuppressWarnings("null")
Expand All @@ -70,6 +74,7 @@ public class EffBan extends Effect {

private boolean ban;
private boolean ipBan;
private boolean kick;

@SuppressWarnings({"null", "unchecked"})
@Override
Expand All @@ -79,6 +84,7 @@ public boolean init(final Expression<?>[] exprs, final int matchedPattern, final
expires = exprs.length > 1 ? (Expression<Timespan>) exprs[2] : null;
ban = matchedPattern % 2 == 0;
ipBan = matchedPattern >= 2;
kick = parseResult.hasTag("kick");
return true;
}

Expand All @@ -91,8 +97,9 @@ protected void execute(final Event e) {
final String source = "Skript ban effect";
for (final Object o : players.getArray(e)) {
if (o instanceof Player) {
Player player = (Player) o;
if (ipBan) {
InetSocketAddress addr = ((Player) o).getAddress();
InetSocketAddress addr = player.getAddress();
if (addr == null)
return; // Can't ban unknown IP
final String ip = addr.getAddress().getHostAddress();
Expand All @@ -102,10 +109,12 @@ protected void execute(final Event e) {
Bukkit.getBanList(BanList.Type.IP).pardon(ip);
} else {
if (ban)
Bukkit.getBanList(BanList.Type.NAME).addBan(((Player) o).getName(), reason, expires, source); // FIXME [UUID] ban UUID
Bukkit.getBanList(BanList.Type.NAME).addBan(player.getName(), reason, expires, source); // FIXME [UUID] ban UUID
else
Bukkit.getBanList(BanList.Type.NAME).pardon(((Player) o).getName());
Bukkit.getBanList(BanList.Type.NAME).pardon(player.getName());
}
if (kick)
player.kickPlayer(reason);
} else if (o instanceof OfflinePlayer) {
String name = ((OfflinePlayer) o).getName();
if (name == null)
Expand All @@ -130,9 +139,13 @@ protected void execute(final Event e) {
}

@Override
public String toString(final @Nullable Event e, final boolean debug) {
return (ipBan ? "IP-" : "") + (ban ? "" : "un") + "ban " + players.toString(e, debug) +
(reason != null ? " on account of " + reason.toString(e, debug) : "") + (expires != null ? " for " + expires.toString(e, debug) : "");
public String toString(final @Nullable Event event, final boolean debug) {
return (ipBan ? "IP-" : "") +
(this.ban ? "ban " : "unban ") +
(kick ? "and kick " : "") +
this.players.toString(event, debug) +
(this.reason != null ? " on account of " + this.reason.toString(event, debug) : "") +
(expires != null ? " for " + expires.toString(event, debug) : "");
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
/**
* This file is part of Skript.
*
* Skript is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Skript is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Skript. If not, see <http://www.gnu.org/licenses/>.
*
* Copyright Peter Güttinger, SkriptLang team and contributors
*/
package org.skriptlang.skript.test.tests.regression;

import ch.njol.skript.lang.Effect;
import ch.njol.skript.lang.TriggerItem;
import ch.njol.skript.lang.util.ContextlessEvent;
import ch.njol.skript.test.runner.SkriptJUnitTest;
import ch.njol.skript.variables.Variables;
import org.bukkit.block.data.type.Tripwire;
import org.bukkit.event.Event;
import org.junit.Assert;
import org.junit.Test;

import java.util.Objects;

public class BlockDataNotCloned6829 extends SkriptJUnitTest {

public void run(String unparsedEffect, Event event) {
Effect effect = Effect.parse(unparsedEffect, "Can't understand this effect: " + unparsedEffect);
if (effect == null)
throw new IllegalStateException();
TriggerItem.walk(effect, event);
}

@Test
public void test() {
Event event = ContextlessEvent.get();
run("set {_original tripwire} to tripwire[]", event);
run("set {_another tripwire} to {_original tripwire}", event);
Tripwire originalTripwire = (Tripwire) Objects.requireNonNull(Variables.getVariable("original tripwire", event, true));
Tripwire anotherTripwire = (Tripwire) Objects.requireNonNull(Variables.getVariable("another tripwire", event, true));
anotherTripwire.setDisarmed(true);
Assert.assertFalse(originalTripwire.isDisarmed());
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
test "compare potion effect types":
assert nausea = nausea with "2 nausea potion effect types should match"
assert type of (potion effect of nausea for 1 minute) = nausea with "type of potion effect of nausea should equal nausea"

0 comments on commit eab54ff

Please sign in to comment.