Skip to content

Commit

Permalink
Merge branch 'dev/feature' into barter
Browse files Browse the repository at this point in the history
  • Loading branch information
Efnilite authored Jun 28, 2024
2 parents 20b518f + 8e67dcb commit 31cc0b8
Show file tree
Hide file tree
Showing 9 changed files with 358 additions and 57 deletions.
45 changes: 45 additions & 0 deletions .github/workflows/archive-docs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: Archive documentation

on:
release:
types: [published]
workflow_dispatch:

jobs:
archive-docs:
if: "! contains(toJSON(github.event.commits.*.message), '[ci skip]')"
needs: release-docs
runs-on: ubuntu-latest
steps:
- name: Configure workflow
id: configuration
run: |
echo "BRANCH_NAME=${GITHUB_REF#refs/*/}" >> $GITHUB_OUTPUT
echo "DOCS_OUTPUT_DIR=${GITHUB_WORKSPACE}/skript-docs/docs/archives/${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT
echo "DOCS_REPO_DIR=${GITHUB_WORKSPACE}/skript-docs" >> $GITHUB_OUTPUT
echo "SKRIPT_REPO_DIR=${GITHUB_WORKSPACE}/skript" >> $GITHUB_OUTPUT
- name: Checkout Skript
uses: actions/checkout@v4
with:
submodules: recursive
path: skript
- name: Setup documentation environment
uses: ./skript/.github/workflows/docs/setup-docs
with:
docs_deploy_key: ${{ secrets.DOCS_DEPLOY_KEY }}
docs_output_dir: ${{ steps.configuration.outputs.DOCS_OUTPUT_DIR }}
- name: Generate documentation
uses: ./skript/.github/workflows/docs/generate-docs
with:
docs_output_dir: ${{ steps.configuration.outputs.DOCS_OUTPUT_DIR }}
docs_repo_dir: ${{ steps.configuration.outputs.DOCS_REPO_DIR }}
skript_repo_dir: ${{ steps.configuration.outputs.SKRIPT_REPO_DIR }}
is_release: true
generate_javadocs: true
- name: Push archive documentation
uses: ./skript/.github/workflows/docs/push-docs
with:
docs_repo_dir: ${{ steps.configuration.outputs.DOCS_REPO_DIR }}
git_name: Archive Docs Bot
git_email: [email protected]
git_commit_message: "Update ${{ steps.configuration.outputs.BRANCH_NAME }} archive docs"
4 changes: 2 additions & 2 deletions .github/workflows/docs/generate-docs/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -69,15 +69,15 @@ runs:
cd $SKRIPT_REPO_DIR
if [[ "${IS_RELEASE}" == "true" ]]; then
./gradlew genReleaseDocs releaseJavadoc
./gradlew genReleaseDocs javadoc
elif [[ "${GENERATE_JAVADOCS}" == "true" ]]; then
./gradlew genNightlyDocs javadoc
else
./gradlew genNightlyDocs
fi
if [ -d "${DOCS_OUTPUT_DIR}" ]; then
if [[ "${GENERATE_JAVADOCS}" == "true" ]]; then
if [[ "${GENERATE_JAVADOCS}" == "true" ]] || [[ "${IS_RELEASE}" == "true" ]] ; then
mkdir -p "${SKRIPT_DOCS_OUTPUT_DIR}/javadocs" && cp -a "./build/docs/javadoc/." "$_"
fi
Expand Down
39 changes: 2 additions & 37 deletions .github/workflows/release-docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ name: Release documentation
on:
release:
types: [published]
workflow_dispatch:

jobs:
release-docs:
Expand Down Expand Up @@ -33,6 +34,7 @@ jobs:
docs_repo_dir: ${{ steps.configuration.outputs.DOCS_REPO_DIR }}
skript_repo_dir: ${{ steps.configuration.outputs.SKRIPT_REPO_DIR }}
is_release: true
generate_javadocs: true
cleanup_pattern: "!(nightly|archives|templates)"
- name: Push release documentation
uses: ./skript/.github/workflows/docs/push-docs
Expand All @@ -41,40 +43,3 @@ jobs:
git_name: Release Docs Bot
git_email: [email protected]
git_commit_message: "Update release docs to ${{ steps.configuration.outputs.BRANCH_NAME }}"

archive-docs:
if: "! contains(toJSON(github.event.commits.*.message), '[ci skip]')"
needs: release-docs
runs-on: ubuntu-latest
steps:
- name: Configure workflow
id: configuration
run: |
echo "BRANCH_NAME=${GITHUB_REF#refs/*/}" >> $GITHUB_OUTPUT
echo "DOCS_OUTPUT_DIR=${GITHUB_WORKSPACE}/skript-docs/docs/archives/${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT
echo "DOCS_REPO_DIR=${GITHUB_WORKSPACE}/skript-docs" >> $GITHUB_OUTPUT
echo "SKRIPT_REPO_DIR=${GITHUB_WORKSPACE}/skript" >> $GITHUB_OUTPUT
- name: Checkout Skript
uses: actions/checkout@v4
with:
submodules: recursive
path: skript
- name: Setup documentation environment
uses: ./skript/.github/workflows/docs/setup-docs
with:
docs_deploy_key: ${{ secrets.DOCS_DEPLOY_KEY }}
docs_output_dir: ${{ steps.configuration.outputs.DOCS_OUTPUT_DIR }}
- name: Generate documentation
uses: ./skript/.github/workflows/docs/generate-docs
with:
docs_repo_dir: ${{ steps.configuration.outputs.DOCS_REPO_DIR }}
docs_output_dir: ${{ steps.configuration.outputs.DOCS_OUTPUT_DIR }}
skript_repo_dir: ${{ steps.configuration.outputs.SKRIPT_REPO_DIR }}
is_release: true
- name: Push archive documentation
uses: ./skript/.github/workflows/docs/push-docs
with:
docs_repo_dir: ${{ steps.configuration.outputs.DOCS_REPO_DIR }}
git_name: Archive Docs Bot
git_email: [email protected]
git_commit_message: "Update ${{ steps.configuration.outputs.BRANCH_NAME }} archive docs"
18 changes: 4 additions & 14 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -140,15 +140,6 @@ publishing {
}
}

task releaseJavadoc(type: Javadoc) {
title = project.name + ' ' + project.property('version')
source = sourceSets.main.allJava
classpath = configurations.compileClasspath
options.encoding = 'UTF-8'
// currently our javadoc has a lot of errors, so we need to suppress the linter
options.addStringOption('Xdoclint:none', '-quiet')
}

// Task to check that test scripts are named correctly
tasks.register('testNaming') {
doLast {
Expand Down Expand Up @@ -188,7 +179,7 @@ void createTestTask(String name, String desc, String environments, int javaVersi
if (junit) {
artifact += 'Skript-JUnit.jar'
} else if (releaseDocs) {
artifact += 'Skript-github.jar'
artifact += 'Skript-' + version + '.jar'
} else {
artifact += 'Skript-nightly.jar'
}
Expand Down Expand Up @@ -367,7 +358,7 @@ task nightlyResources(type: ProcessResources) {
'today' : '' + LocalTime.now(),
'release-flavor' : 'skriptlang-nightly', // SkriptLang build, automatically done by CI
'release-channel' : 'prerelease', // No update checking, but these are VERY unstable
'release-updater' : 'ch.njol.skript.update.NoUpdateChecker', // No autoupdates for now
'release-updater' : 'ch.njol.skript.update.NoUpdateChecker', // No auto updates for now
'release-source' : '',
'release-download': 'null'
]
Expand All @@ -389,8 +380,8 @@ task nightlyRelease(type: ShadowJar) {
}

javadoc {
dependsOn nightlyResources

mustRunAfter(tasks.withType(ProcessResources))
title = 'Skript ' + project.property('version')
source = sourceSets.main.allJava

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

14 changes: 11 additions & 3 deletions src/main/java/ch/njol/skript/classes/data/BukkitClasses.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.OfflinePlayer;
import org.bukkit.Registry;
import org.bukkit.SoundCategory;
import org.bukkit.World;
import org.bukkit.World.Environment;
Expand Down Expand Up @@ -77,7 +78,6 @@
import org.bukkit.potion.PotionEffectType;
import org.bukkit.util.CachedServerIcon;
import org.bukkit.util.Vector;
import org.eclipse.jdt.annotation.Nullable;

import ch.njol.skript.Skript;
import ch.njol.skript.SkriptConfig;
Expand All @@ -90,6 +90,7 @@
import ch.njol.skript.classes.EnumClassInfo;
import ch.njol.skript.classes.Parser;
import ch.njol.skript.classes.Serializer;
import ch.njol.skript.classes.registry.RegistryClassInfo;
import ch.njol.skript.entity.EntityData;
import ch.njol.skript.expressions.ExprDamageCause;
import ch.njol.skript.expressions.base.EventValueExpression;
Expand All @@ -104,6 +105,7 @@
import ch.njol.util.StringUtils;
import ch.njol.yggdrasil.Fields;
import io.papermc.paper.world.MoonPhase;
import org.jetbrains.annotations.Nullable;

/**
* @author Peter Güttinger
Expand Down Expand Up @@ -976,8 +978,14 @@ public String toVariableNameString(final ItemStack i) {
.name(ClassInfo.NO_DOC)
.since("2.0")
.changer(DefaultChangers.itemChanger));

Classes.registerClass(new EnumClassInfo<>(Biome.class, "biome", "biomes")

ClassInfo<?> biomeClassInfo;
if (Skript.classExists("org.bukkit.Registry") && Skript.fieldExists(Registry.class, "BIOME")) {
biomeClassInfo = new RegistryClassInfo<>(Biome.class, Registry.BIOME, "biome", "biomes");
} else {
biomeClassInfo = new EnumClassInfo<>(Biome.class, "biome", "biomes");
}
Classes.registerClass(biomeClassInfo
.user("biomes?")
.name("Biome")
.description("All possible biomes Minecraft uses to generate a world.")
Expand Down
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 ch.njol.skript.classes.registry;

import ch.njol.skript.classes.ClassInfo;
import ch.njol.skript.expressions.base.EventValueExpression;
import ch.njol.skript.lang.DefaultExpression;
import org.bukkit.Keyed;
import org.bukkit.Registry;

/**
* This class can be used for easily creating ClassInfos for {@link Registry}s.
* It registers a language node with usage, a serializer, default expression, and a parser.
*
* @param <R> The Registry class.
*/
public class RegistryClassInfo<R extends Keyed> extends ClassInfo<R> {

public RegistryClassInfo(Class<R> registryClass, Registry<R> registry, String codeName, String languageNode) {
this(registryClass, registry, codeName, languageNode, new EventValueExpression<>(registryClass));
}

/**
* @param registry The registry
* @param codeName The name used in patterns
*/
public RegistryClassInfo(Class<R> registryClass, Registry<R> registry, String codeName, String languageNode, DefaultExpression<R> defaultExpression) {
super(registryClass, codeName);
RegistryParser<R> registryParser = new RegistryParser<>(registry, languageNode);
usage(registryParser.getAllNames())
.supplier(registry::iterator)
.serializer(new RegistrySerializer<R>(registry))
.defaultExpression(defaultExpression)
.parser(registryParser);
}

}
Loading

0 comments on commit 31cc0b8

Please sign in to comment.