Skip to content

Commit

Permalink
Merge branch 'dev/patch' into fix/missing-attributes
Browse files Browse the repository at this point in the history
  • Loading branch information
sovdeeth authored Jul 1, 2024
2 parents efdfc86 + 4030757 commit aad5ef2
Show file tree
Hide file tree
Showing 7 changed files with 85 additions and 64 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')
}

35 changes: 25 additions & 10 deletions src/main/java/ch/njol/skript/bukkitutil/ItemUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,17 @@ public class ItemUtils {
* @return Damage.
*/
public static int getDamage(ItemStack itemStack) {
ItemMeta meta = itemStack.getItemMeta();
if (meta instanceof Damageable)
return ((Damageable) meta).getDamage();
return getDamage(itemStack.getItemMeta());
}

/**
* Gets damage/durability of an itemmeta, or 0 if it does not have damage.
* @param itemMeta ItemMeta.
* @return Damage.
*/
public static int getDamage(ItemMeta itemMeta) {
if (itemMeta instanceof Damageable)
return ((Damageable) itemMeta).getDamage();
return 0; // Non damageable item
}

Expand Down Expand Up @@ -143,15 +151,22 @@ public static Material asItem(Material type) {
/**
* Tests whether two item stacks are of the same type, i.e. it ignores the amounts.
*
* @param is1
* @param is2
* @param itemStack1
* @param itemStack2
* @return Whether the item stacks are of the same type
*/
public static boolean itemStacksEqual(final @Nullable ItemStack is1, final @Nullable ItemStack is2) {
if (is1 == null || is2 == null)
return is1 == is2;
return is1.getType() == is2.getType() && ItemUtils.getDamage(is1) == ItemUtils.getDamage(is2)
&& is1.getItemMeta().equals(is2.getItemMeta());
public static boolean itemStacksEqual(@Nullable ItemStack itemStack1, @Nullable ItemStack itemStack2) {
if (itemStack1 == null || itemStack2 == null)
return itemStack1 == itemStack2;
if (itemStack1.getType() != itemStack2.getType())
return false;

ItemMeta itemMeta1 = itemStack1.getItemMeta();
ItemMeta itemMeta2 = itemStack2.getItemMeta();
if (itemMeta1 == null || itemMeta2 == null)
return itemMeta1 == itemMeta2;

return itemStack1.getItemMeta().equals(itemStack2.getItemMeta());
}

// Only 1.15 and versions after have Material#isAir method
Expand Down
4 changes: 3 additions & 1 deletion src/main/java/ch/njol/skript/structures/StructCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,9 @@ private void scheduleCommandSync() {
if (SYNC_COMMANDS.get()) {
SYNC_COMMANDS.set(false);
if (DELAY_COMMAND_SYNCING) {
Bukkit.getScheduler().runTask(Skript.getInstance(), this::forceCommandSync);
// if the plugin is disabled, the server is likely closing and delaying will cause an error.
if (Bukkit.getPluginManager().isPluginEnabled(Skript.getInstance()))
Bukkit.getScheduler().runTask(Skript.getInstance(), this::forceCommandSync);
} else {
forceCommandSync();
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
test "remove air from air slot":
set {_chest} to chest inventory with 3 rows
# throws exception if not fixed
remove 1 of (slot 0 of {_chest}) from (slot 0 of {_chest})

0 comments on commit aad5ef2

Please sign in to comment.