Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

1.20.5 Support #6617

Merged
merged 23 commits into from
May 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
87d0be6
Internal support for aliases item components
APickledWalrus Apr 26, 2024
69a779d
Update aliases submodule
APickledWalrus Apr 27, 2024
9625ea8
Update isRunningMethod check
APickledWalrus Apr 27, 2024
68fbfbc
Add ability to opt out of deduplication
APickledWalrus Apr 27, 2024
c073ccc
Update skript-aliases
APickledWalrus Apr 27, 2024
20d18ad
Merge branch 'dev/patch' into patch/1.20.5-support
Moderocky Apr 27, 2024
0a10072
Update skript-aliases
APickledWalrus Apr 30, 2024
45ef181
Update skript-aliases
APickledWalrus Apr 30, 2024
0437153
Update Gradle to 8.7
APickledWalrus Apr 30, 2024
bdd19cd
Update Paper to 1.20.6
APickledWalrus Apr 30, 2024
dff1ab7
Merge branch 'dev/patch' into patch/1.20.5-support
APickledWalrus Apr 30, 2024
a69e518
Fix latest env for testing
APickledWalrus Apr 30, 2024
46f9db2
Fix AreaEffectCloudApplyEvent event value
APickledWalrus Apr 30, 2024
822cf42
Fix vehicle dismount events
APickledWalrus Apr 30, 2024
822c8c4
Fix potions
APickledWalrus Apr 30, 2024
314d72c
Get visual effects building
APickledWalrus Apr 30, 2024
2d96d8e
Fix unused AbstractList implementation
APickledWalrus Apr 30, 2024
dcf806d
Fix remaining Java 17 references
APickledWalrus Apr 30, 2024
337fcba
Fix 1.17 testing
APickledWalrus Apr 30, 2024
442e5f2
Add missing PotionDataUtils check
APickledWalrus Apr 30, 2024
0ebd6d2
Add missing lang entries
APickledWalrus Apr 30, 2024
2f6f093
Rework Test Environments
APickledWalrus Apr 30, 2024
16a8ecc
Update workflow names
APickledWalrus May 1, 2024
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
2 changes: 1 addition & 1 deletion .github/workflows/docs/setup-docs/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ runs:
ssh-key: ${{ inputs.docs_deploy_key }}
- uses: actions/setup-java@v3
with:
java-version: '17'
java-version: '21'
distribution: 'adopt'
cache: gradle
- shell: bash
Expand Down
8 changes: 4 additions & 4 deletions .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+)
name: Java 17 CI (MC 1.17-1.20.4)

on:
push:
Expand All @@ -17,10 +17,10 @@ jobs:
submodules: recursive
- name: validate gradle wrapper
uses: gradle/wrapper-validation-action@v2
- name: Set up JDK 17
uses: actions/setup-java@v3
- name: Set up JDK 21
uses: actions/setup-java@v4
with:
java-version: '17'
java-version: '21'
distribution: 'adopt'
cache: gradle
- name: Grant execute permission for gradlew
Expand Down
35 changes: 35 additions & 0 deletions .github/workflows/java-21-builds.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: Java 21 CI (MC 1.20.6+)

on:
push:
branches:
- master
- 'dev/**'
pull_request:

jobs:
build:
if: "! contains(toJSON(github.event.commits.*.message), '[ci skip]')"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
- name: validate gradle wrapper
uses: gradle/wrapper-validation-action@v2
- name: Set up JDK 21
uses: actions/setup-java@v4
with:
java-version: '21'
distribution: 'adopt'
cache: gradle
- name: Grant execute permission for gradlew
run: chmod +x gradlew
- name: Build Skript and run test scripts
run: ./gradlew clean skriptTestJava21
- name: Upload Nightly Build
uses: actions/upload-artifact@v4
if: success()
with:
name: skript-nightly
path: build/libs/*
4 changes: 2 additions & 2 deletions .github/workflows/java-8-builds.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ jobs:
submodules: recursive
- name: validate gradle wrapper
uses: gradle/wrapper-validation-action@v2
- name: Set up JDK 17
- name: Set up JDK 21
uses: actions/setup-java@v4
with:
java-version: '17'
java-version: '21'
distribution: 'adopt'
cache: gradle
- name: Grant execute permission for gradlew
Expand Down
6 changes: 3 additions & 3 deletions .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+)
name: JUnit (MC 1.17-1.20.4)

on:
push:
Expand All @@ -17,10 +17,10 @@ jobs:
submodules: recursive
- name: validate gradle wrapper
uses: gradle/wrapper-validation-action@v2
- name: Set up JDK 17
- name: Set up JDK 21
uses: actions/setup-java@v4
with:
java-version: '17'
java-version: '21'
distribution: 'adopt'
cache: gradle
- name: Grant execute permission for gradlew
Expand Down
31 changes: 31 additions & 0 deletions .github/workflows/junit-21-builds.disabled
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# 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)
name: JUnit (MC 1.20.6+)

on:
push:
branches:
- master
- 'dev/**'
pull_request:

jobs:
build:
if: "! contains(toJSON(github.event.commits.*.message), '[ci skip]')"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
- name: validate gradle wrapper
uses: gradle/wrapper-validation-action@v2
- name: Set up JDK 21
uses: actions/setup-java@v4
with:
java-version: '21'
distribution: 'adopt'
cache: gradle
- name: Grant execute permission for gradlew
run: chmod +x gradlew
- name: Build Skript and run JUnit
run: ./gradlew clean JUnitJava21
4 changes: 2 additions & 2 deletions .github/workflows/junit-8-builds.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ jobs:
submodules: recursive
- name: validate gradle wrapper
uses: gradle/wrapper-validation-action@v2
- name: Set up JDK 17
- name: Set up JDK 21
uses: actions/setup-java@v4
with:
java-version: '17'
java-version: '21'
distribution: 'adopt'
cache: gradle
- name: Grant execute permission for gradlew
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/repo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ jobs:
submodules: recursive
- name: validate gradle wrapper
uses: gradle/wrapper-validation-action@v2
- name: Set up JDK 17
- name: Set up JDK 21
uses: actions/setup-java@v4
with:
java-version: '17'
java-version: '21'
distribution: 'adopt'
cache: gradle
- name: Publish Skript
Expand Down
1 change: 1 addition & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
[submodule "skript-aliases"]
path = skript-aliases
url = https://github.com/SkriptLang/skript-aliases
branch = patch/1.20.5-support
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,13 +77,13 @@ 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)
./gradlew (quickTest|skriptTest|skriptTestJava8|skriptTestJava21)
```

<code>quickTest</code> runs the test suite on newest supported server version.
<code>skriptTestJava17</code> (1.17+) runs the tests on the latest supported Java version.
<code>skriptTestJava21</code> (1.17+) runs the tests on the latest supported Java version.
<code>skriptTestJava8</code> (1.13-1.16) runs the tests on the oldest supported Java version.
<code>skriptTest</code> runs both skriptTestJava8 and skriptTestJava17
<code>skriptTest</code> runs both skriptTestJava8 and skriptTestJava21

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

Expand Down
36 changes: 24 additions & 12 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ allprojects {
maven { url 'https://hub.spigotmc.org/nexus/content/repositories/snapshots/' }
maven { url 'https://oss.sonatype.org/content/repositories/snapshots/' }
maven { url 'https://repo.papermc.io/repository/maven-public/' }
maven { url = 'https://s01.oss.sonatype.org/content/repositories/snapshots/' } // needed for paper adventure snapshot
maven { url 'https://ci.emc.gs/nexus/content/groups/aikar/' }
}
}
Expand All @@ -29,7 +30,7 @@ dependencies {
shadow group: 'org.bstats', name: 'bstats-bukkit', version: '3.0.2'
shadow group: 'net.kyori', name: 'adventure-text-serializer-bungeecord', version: '4.3.2'

implementation group: 'io.papermc.paper', name: 'paper-api', version: '1.20.4-R0.1-SNAPSHOT'
implementation group: 'io.papermc.paper', name: 'paper-api', version: '1.20.6-R0.1-SNAPSHOT'
implementation group: 'org.eclipse.jdt', name: 'org.eclipse.jdt.annotation', version: '2.2.700'
implementation group: 'com.google.code.findbugs', name: 'findbugs', version: '3.0.1'
implementation group: 'com.sk89q.worldguard', name: 'worldguard-legacy', version: '7.0.0-SNAPSHOT'
Expand Down Expand Up @@ -70,7 +71,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, junitJava21, junitJava8, 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 @@ -250,9 +251,16 @@ void createTestTask(String name, String desc, String environments, int javaVersi
}
}

def latestEnv = 'java17/paper-1.20.4.json'
def latestJava = 17
def oldestJava = 8
def java21 = 21
def java17 = 17
def java8 = 8

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

def latestJUnitEnv = 'java17/paper-1.20.4.json'
def latestJUnitJava = java17

java {
toolchain.languageVersion.set(JavaLanguageVersion.of(latestJava))
Expand All @@ -270,23 +278,27 @@ String environments = 'src/test/skript/environments/';
String env = project.property('testEnv') == null ? latestEnv : project.property('testEnv') + '.json'
int envJava = project.property('testEnvJavaVersion') == null ? latestJava : Integer.parseInt(project.property('testEnvJavaVersion') as String)
createTestTask('quickTest', 'Runs tests on one environment being the latest supported Java and Minecraft.', environments + latestEnv, latestJava, 0)
createTestTask('skriptTestJava17', 'Runs tests on all Java 17 environments.', environments + 'java17', latestJava, 0)
createTestTask('skriptTestJava8', 'Runs tests on all Java 8 environments.', environments + 'java8', oldestJava, 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('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
dependsOn skriptTestJava8, skriptTestJava17, skriptTestJava21
}

createTestTask('JUnitQuick', 'Runs JUnit tests on one environment being the latest supported Java and Minecraft.', environments + latestEnv, latestJava, 0, Modifiers.JUNIT)
createTestTask('JUnitJava17', 'Runs JUnit tests on all Java 17 environments.', environments + 'java17', latestJava, 0, Modifiers.JUNIT)
createTestTask('JUnitJava8', 'Runs JUnit tests on all Java 8 environments.', environments + 'java8', oldestJava, 0, Modifiers.JUNIT)
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)
tasks.register('JUnit') {
description = 'Runs JUnit tests on all environments.'
dependsOn JUnitJava8, JUnitJava17
dependsOn JUnitJava8, JUnitJava17//, JUnitJava21
}

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

### Compatibility
* Contributions should maintain Java 8 source/binary compatibility, even though compiling Skript requires Java 17
* Contributions should maintain Java 8 source/binary compatibility, even though compiling Skript requires Java 21
- Users must not need JRE newer than version 8
* Versions up to and including Java 17 should work too
* 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
* Local variables and method parameters should not be declared final
Expand Down
4 changes: 2 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@ groupid=ch.njol
name=skript
version=2.8.4
jarName=Skript.jar
testEnv=java17/paper-1.20.4
testEnvJavaVersion=17
testEnv=java21/paper-1.20.4
testEnvJavaVersion=21
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.3-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
Expand Down
2 changes: 1 addition & 1 deletion skript-aliases
Submodule skript-aliases updated 4 files
+128 −0 +global-variations.sk
+9 −76 brewing.sk
+185 −49 combat.sk
+68 −26 misc.sk
4 changes: 3 additions & 1 deletion src/main/java/ch/njol/skript/Skript.java
Original file line number Diff line number Diff line change
Expand Up @@ -1159,7 +1159,9 @@ public void onPluginDisable(PluginDisableEvent event) {
// 1.19 mapping is u and 1.18 is v
String isRunningMethod = "isRunning";

if (Skript.isRunningMinecraft(1, 20)) {
if (Skript.isRunningMinecraft(1, 20, 5)) {
isRunningMethod = "x";
} else if (Skript.isRunningMinecraft(1, 20)) {
isRunningMethod = "v";
} else if (Skript.isRunningMinecraft(1, 19)) {
isRunningMethod = "u";
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/ch/njol/skript/aliases/Aliases.java
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@

public abstract class Aliases {

static final boolean USING_ITEM_COMPONENTS = Skript.isRunningMinecraft(1, 20, 5);

private static final AliasesProvider provider = createProvider(10000, null);
private static final AliasesParser parser = createParser(provider);

Expand Down
17 changes: 14 additions & 3 deletions src/main/java/ch/njol/skript/aliases/AliasesParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -218,9 +218,20 @@ protected Variation parseVariation(String item) {
throw new AssertionError("missing space between id and tags in " + item);
}
id = item.substring(0, firstBracket - 1);
String json = item.substring(firstBracket);
assert json != null;
tags = provider.parseMojangson(json);
String json;
int jsonEndIndex = item.indexOf("} ["); // may also have block states/data
if (jsonEndIndex == -1) {
json = item.substring(firstBracket);
} else {
json = item.substring(firstBracket, jsonEndIndex + 1);
id = id + item.substring(jsonEndIndex + 2); // essentially rips out json part
}
if (Aliases.USING_ITEM_COMPONENTS) {
json = "[" + json.substring(1, json.length() - 1) + "]"; // replace brackets (not json :))
tags = Collections.singletonMap("components", json);
} else {
tags = provider.parseMojangson(json);
}
}

// Separate block state from id
Expand Down
35 changes: 27 additions & 8 deletions src/main/java/ch/njol/skript/aliases/AliasesProvider.java
Original file line number Diff line number Diff line change
Expand Up @@ -218,9 +218,18 @@ public int applyTags(ItemStack stack, Map<String, Object> tags) {
return flags;

// Apply random tags using JSON
String json = gson.toJson(tags);
assert json != null;
BukkitUnsafe.modifyItemStack(stack, json);
if (Aliases.USING_ITEM_COMPONENTS) {
String components = (String) tags.get("components"); // only components are supported for modifying a stack
assert components != null;
// for modifyItemStack to work, you have to include an item id ... e.g. "minecraft:dirt[<components>]"
// just to be safe we use the same one as the provided stack
components = stack.getType().getKey() + components;
BukkitUnsafe.modifyItemStack(stack, components);
} else {
String json = gson.toJson(tags);
assert json != null;
BukkitUnsafe.modifyItemStack(stack, json);
}
flags |= ItemFlags.CHANGED_TAGS;

return flags;
Expand Down Expand Up @@ -269,6 +278,14 @@ public void addAlias(AliasName name, String id, @Nullable Map<String, Object> ta
ItemType typeOfId = getAlias(id);
EntityData<?> related = null;
List<ItemData> datas;

// check whether deduplication will occur
boolean deduplicate = true;
String deduplicateFlag = blockStates.remove("deduplicate");
if (deduplicateFlag != null) {
deduplicate = !deduplicateFlag.equals("false");
}

if (typeOfId != null) { // If it exists, use datas from it
datas = typeOfId.getTypes();
} else { // ... but quite often, we just got Vanilla id
Expand Down Expand Up @@ -301,11 +318,13 @@ public void addAlias(AliasName name, String id, @Nullable Map<String, Object> ta
data.itemFlags = itemFlags;

// Deduplicate item data if this has been loaded before
AliasesMap.Match canonical = aliasesMap.exactMatch(data);
if (canonical.getQuality().isAtLeast(MatchQuality.EXACT)) {
AliasesMap.AliasData aliasData = canonical.getData();
assert aliasData != null; // Match quality guarantees this
data = aliasData.getItem();
if (deduplicate) {
AliasesMap.Match canonical = aliasesMap.exactMatch(data);
if (canonical.getQuality().isAtLeast(MatchQuality.EXACT)) {
AliasesMap.AliasData aliasData = canonical.getData();
assert aliasData != null; // Match quality guarantees this
data = aliasData.getItem();
}
}

datas = Collections.singletonList(data);
Expand Down
Loading