Skip to content

Commit 31cc0b8

Browse files
authored
Merge branch 'dev/feature' into barter
2 parents 20b518f + 8e67dcb commit 31cc0b8

File tree

9 files changed

+358
-57
lines changed

9 files changed

+358
-57
lines changed

.github/workflows/archive-docs.yml

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
name: Archive documentation
2+
3+
on:
4+
release:
5+
types: [published]
6+
workflow_dispatch:
7+
8+
jobs:
9+
archive-docs:
10+
if: "! contains(toJSON(github.event.commits.*.message), '[ci skip]')"
11+
needs: release-docs
12+
runs-on: ubuntu-latest
13+
steps:
14+
- name: Configure workflow
15+
id: configuration
16+
run: |
17+
echo "BRANCH_NAME=${GITHUB_REF#refs/*/}" >> $GITHUB_OUTPUT
18+
echo "DOCS_OUTPUT_DIR=${GITHUB_WORKSPACE}/skript-docs/docs/archives/${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT
19+
echo "DOCS_REPO_DIR=${GITHUB_WORKSPACE}/skript-docs" >> $GITHUB_OUTPUT
20+
echo "SKRIPT_REPO_DIR=${GITHUB_WORKSPACE}/skript" >> $GITHUB_OUTPUT
21+
- name: Checkout Skript
22+
uses: actions/checkout@v4
23+
with:
24+
submodules: recursive
25+
path: skript
26+
- name: Setup documentation environment
27+
uses: ./skript/.github/workflows/docs/setup-docs
28+
with:
29+
docs_deploy_key: ${{ secrets.DOCS_DEPLOY_KEY }}
30+
docs_output_dir: ${{ steps.configuration.outputs.DOCS_OUTPUT_DIR }}
31+
- name: Generate documentation
32+
uses: ./skript/.github/workflows/docs/generate-docs
33+
with:
34+
docs_output_dir: ${{ steps.configuration.outputs.DOCS_OUTPUT_DIR }}
35+
docs_repo_dir: ${{ steps.configuration.outputs.DOCS_REPO_DIR }}
36+
skript_repo_dir: ${{ steps.configuration.outputs.SKRIPT_REPO_DIR }}
37+
is_release: true
38+
generate_javadocs: true
39+
- name: Push archive documentation
40+
uses: ./skript/.github/workflows/docs/push-docs
41+
with:
42+
docs_repo_dir: ${{ steps.configuration.outputs.DOCS_REPO_DIR }}
43+
git_name: Archive Docs Bot
44+
git_email: archivedocs@skriptlang.org
45+
git_commit_message: "Update ${{ steps.configuration.outputs.BRANCH_NAME }} archive docs"

.github/workflows/docs/generate-docs/action.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,15 +69,15 @@ runs:
6969
7070
cd $SKRIPT_REPO_DIR
7171
if [[ "${IS_RELEASE}" == "true" ]]; then
72-
./gradlew genReleaseDocs releaseJavadoc
72+
./gradlew genReleaseDocs javadoc
7373
elif [[ "${GENERATE_JAVADOCS}" == "true" ]]; then
7474
./gradlew genNightlyDocs javadoc
7575
else
7676
./gradlew genNightlyDocs
7777
fi
7878
7979
if [ -d "${DOCS_OUTPUT_DIR}" ]; then
80-
if [[ "${GENERATE_JAVADOCS}" == "true" ]]; then
80+
if [[ "${GENERATE_JAVADOCS}" == "true" ]] || [[ "${IS_RELEASE}" == "true" ]] ; then
8181
mkdir -p "${SKRIPT_DOCS_OUTPUT_DIR}/javadocs" && cp -a "./build/docs/javadoc/." "$_"
8282
fi
8383

.github/workflows/release-docs.yml

Lines changed: 2 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ name: Release documentation
33
on:
44
release:
55
types: [published]
6+
workflow_dispatch:
67

78
jobs:
89
release-docs:
@@ -33,6 +34,7 @@ jobs:
3334
docs_repo_dir: ${{ steps.configuration.outputs.DOCS_REPO_DIR }}
3435
skript_repo_dir: ${{ steps.configuration.outputs.SKRIPT_REPO_DIR }}
3536
is_release: true
37+
generate_javadocs: true
3638
cleanup_pattern: "!(nightly|archives|templates)"
3739
- name: Push release documentation
3840
uses: ./skript/.github/workflows/docs/push-docs
@@ -41,40 +43,3 @@ jobs:
4143
git_name: Release Docs Bot
4244
git_email: releasedocs@skriptlang.org
4345
git_commit_message: "Update release docs to ${{ steps.configuration.outputs.BRANCH_NAME }}"
44-
45-
archive-docs:
46-
if: "! contains(toJSON(github.event.commits.*.message), '[ci skip]')"
47-
needs: release-docs
48-
runs-on: ubuntu-latest
49-
steps:
50-
- name: Configure workflow
51-
id: configuration
52-
run: |
53-
echo "BRANCH_NAME=${GITHUB_REF#refs/*/}" >> $GITHUB_OUTPUT
54-
echo "DOCS_OUTPUT_DIR=${GITHUB_WORKSPACE}/skript-docs/docs/archives/${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT
55-
echo "DOCS_REPO_DIR=${GITHUB_WORKSPACE}/skript-docs" >> $GITHUB_OUTPUT
56-
echo "SKRIPT_REPO_DIR=${GITHUB_WORKSPACE}/skript" >> $GITHUB_OUTPUT
57-
- name: Checkout Skript
58-
uses: actions/checkout@v4
59-
with:
60-
submodules: recursive
61-
path: skript
62-
- name: Setup documentation environment
63-
uses: ./skript/.github/workflows/docs/setup-docs
64-
with:
65-
docs_deploy_key: ${{ secrets.DOCS_DEPLOY_KEY }}
66-
docs_output_dir: ${{ steps.configuration.outputs.DOCS_OUTPUT_DIR }}
67-
- name: Generate documentation
68-
uses: ./skript/.github/workflows/docs/generate-docs
69-
with:
70-
docs_repo_dir: ${{ steps.configuration.outputs.DOCS_REPO_DIR }}
71-
docs_output_dir: ${{ steps.configuration.outputs.DOCS_OUTPUT_DIR }}
72-
skript_repo_dir: ${{ steps.configuration.outputs.SKRIPT_REPO_DIR }}
73-
is_release: true
74-
- name: Push archive documentation
75-
uses: ./skript/.github/workflows/docs/push-docs
76-
with:
77-
docs_repo_dir: ${{ steps.configuration.outputs.DOCS_REPO_DIR }}
78-
git_name: Archive Docs Bot
79-
git_email: archivedocs@skriptlang.org
80-
git_commit_message: "Update ${{ steps.configuration.outputs.BRANCH_NAME }} archive docs"

build.gradle

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -140,15 +140,6 @@ publishing {
140140
}
141141
}
142142

143-
task releaseJavadoc(type: Javadoc) {
144-
title = project.name + ' ' + project.property('version')
145-
source = sourceSets.main.allJava
146-
classpath = configurations.compileClasspath
147-
options.encoding = 'UTF-8'
148-
// currently our javadoc has a lot of errors, so we need to suppress the linter
149-
options.addStringOption('Xdoclint:none', '-quiet')
150-
}
151-
152143
// Task to check that test scripts are named correctly
153144
tasks.register('testNaming') {
154145
doLast {
@@ -188,7 +179,7 @@ void createTestTask(String name, String desc, String environments, int javaVersi
188179
if (junit) {
189180
artifact += 'Skript-JUnit.jar'
190181
} else if (releaseDocs) {
191-
artifact += 'Skript-github.jar'
182+
artifact += 'Skript-' + version + '.jar'
192183
} else {
193184
artifact += 'Skript-nightly.jar'
194185
}
@@ -367,7 +358,7 @@ task nightlyResources(type: ProcessResources) {
367358
'today' : '' + LocalTime.now(),
368359
'release-flavor' : 'skriptlang-nightly', // SkriptLang build, automatically done by CI
369360
'release-channel' : 'prerelease', // No update checking, but these are VERY unstable
370-
'release-updater' : 'ch.njol.skript.update.NoUpdateChecker', // No autoupdates for now
361+
'release-updater' : 'ch.njol.skript.update.NoUpdateChecker', // No auto updates for now
371362
'release-source' : '',
372363
'release-download': 'null'
373364
]
@@ -389,8 +380,8 @@ task nightlyRelease(type: ShadowJar) {
389380
}
390381

391382
javadoc {
392-
dependsOn nightlyResources
393-
383+
mustRunAfter(tasks.withType(ProcessResources))
384+
title = 'Skript ' + project.property('version')
394385
source = sourceSets.main.allJava
395386

396387
exclude("ch/njol/skript/conditions/**")
@@ -409,4 +400,3 @@ javadoc {
409400
// currently our javadoc has a lot of errors, so we need to suppress the linter
410401
options.addStringOption('Xdoclint:none', '-quiet')
411402
}
412-

src/main/java/ch/njol/skript/classes/data/BukkitClasses.java

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
import org.bukkit.Location;
3939
import org.bukkit.Material;
4040
import org.bukkit.OfflinePlayer;
41+
import org.bukkit.Registry;
4142
import org.bukkit.SoundCategory;
4243
import org.bukkit.World;
4344
import org.bukkit.World.Environment;
@@ -77,7 +78,6 @@
7778
import org.bukkit.potion.PotionEffectType;
7879
import org.bukkit.util.CachedServerIcon;
7980
import org.bukkit.util.Vector;
80-
import org.eclipse.jdt.annotation.Nullable;
8181

8282
import ch.njol.skript.Skript;
8383
import ch.njol.skript.SkriptConfig;
@@ -90,6 +90,7 @@
9090
import ch.njol.skript.classes.EnumClassInfo;
9191
import ch.njol.skript.classes.Parser;
9292
import ch.njol.skript.classes.Serializer;
93+
import ch.njol.skript.classes.registry.RegistryClassInfo;
9394
import ch.njol.skript.entity.EntityData;
9495
import ch.njol.skript.expressions.ExprDamageCause;
9596
import ch.njol.skript.expressions.base.EventValueExpression;
@@ -104,6 +105,7 @@
104105
import ch.njol.util.StringUtils;
105106
import ch.njol.yggdrasil.Fields;
106107
import io.papermc.paper.world.MoonPhase;
108+
import org.jetbrains.annotations.Nullable;
107109

108110
/**
109111
* @author Peter Güttinger
@@ -976,8 +978,14 @@ public String toVariableNameString(final ItemStack i) {
976978
.name(ClassInfo.NO_DOC)
977979
.since("2.0")
978980
.changer(DefaultChangers.itemChanger));
979-
980-
Classes.registerClass(new EnumClassInfo<>(Biome.class, "biome", "biomes")
981+
982+
ClassInfo<?> biomeClassInfo;
983+
if (Skript.classExists("org.bukkit.Registry") && Skript.fieldExists(Registry.class, "BIOME")) {
984+
biomeClassInfo = new RegistryClassInfo<>(Biome.class, Registry.BIOME, "biome", "biomes");
985+
} else {
986+
biomeClassInfo = new EnumClassInfo<>(Biome.class, "biome", "biomes");
987+
}
988+
Classes.registerClass(biomeClassInfo
981989
.user("biomes?")
982990
.name("Biome")
983991
.description("All possible biomes Minecraft uses to generate a world.")
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
/**
2+
* This file is part of Skript.
3+
*
4+
* Skript is free software: you can redistribute it and/or modify
5+
* it under the terms of the GNU General Public License as published by
6+
* the Free Software Foundation, either version 3 of the License, or
7+
* (at your option) any later version.
8+
*
9+
* Skript is distributed in the hope that it will be useful,
10+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
* GNU General Public License for more details.
13+
*
14+
* You should have received a copy of the GNU General Public License
15+
* along with Skript. If not, see <http://www.gnu.org/licenses/>.
16+
*
17+
* Copyright Peter Güttinger, SkriptLang team and contributors
18+
*/
19+
package ch.njol.skript.classes.registry;
20+
21+
import ch.njol.skript.classes.ClassInfo;
22+
import ch.njol.skript.expressions.base.EventValueExpression;
23+
import ch.njol.skript.lang.DefaultExpression;
24+
import org.bukkit.Keyed;
25+
import org.bukkit.Registry;
26+
27+
/**
28+
* This class can be used for easily creating ClassInfos for {@link Registry}s.
29+
* It registers a language node with usage, a serializer, default expression, and a parser.
30+
*
31+
* @param <R> The Registry class.
32+
*/
33+
public class RegistryClassInfo<R extends Keyed> extends ClassInfo<R> {
34+
35+
public RegistryClassInfo(Class<R> registryClass, Registry<R> registry, String codeName, String languageNode) {
36+
this(registryClass, registry, codeName, languageNode, new EventValueExpression<>(registryClass));
37+
}
38+
39+
/**
40+
* @param registry The registry
41+
* @param codeName The name used in patterns
42+
*/
43+
public RegistryClassInfo(Class<R> registryClass, Registry<R> registry, String codeName, String languageNode, DefaultExpression<R> defaultExpression) {
44+
super(registryClass, codeName);
45+
RegistryParser<R> registryParser = new RegistryParser<>(registry, languageNode);
46+
usage(registryParser.getAllNames())
47+
.supplier(registry::iterator)
48+
.serializer(new RegistrySerializer<R>(registry))
49+
.defaultExpression(defaultExpression)
50+
.parser(registryParser);
51+
}
52+
53+
}

0 commit comments

Comments
 (0)