diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 066b4eb6..33926018 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -9,10 +9,10 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout repository - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Setup java - uses: actions/setup-java@v3 + uses: actions/setup-java@v4 with: distribution: 'temurin' java-version: '21' @@ -22,7 +22,7 @@ jobs: run: ./gradlew build shadowJar --no-daemon - name: Upload plugin file - uses: actions/upload-artifact@v2 + uses: actions/upload-artifact@v4 with: name: ProtocolLib path: build/libs/ProtocolLib.jar diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index 12ca758b..6f97dc2d 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -20,17 +20,17 @@ jobs: steps: - name: Checkout repository - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Setup java - uses: actions/setup-java@v3 + uses: actions/setup-java@v4 with: distribution: 'temurin' java-version: '21' cache: 'gradle' - name: Initialize CodeQL - uses: github/codeql-action/init@v2 + uses: github/codeql-action/init@v3 with: languages: 'java' @@ -38,4 +38,4 @@ jobs: run: ./gradlew build -x test --no-daemon - name: Perform CodeQL Analysis - uses: github/codeql-action/analyze@v2 + uses: github/codeql-action/analyze@v3 diff --git a/src/test/java/com/comphenix/protocol/BukkitInitialization.java b/src/test/java/com/comphenix/protocol/BukkitInitialization.java index 0fdb5de2..490a7d1c 100644 --- a/src/test/java/com/comphenix/protocol/BukkitInitialization.java +++ b/src/test/java/com/comphenix/protocol/BukkitInitialization.java @@ -1,8 +1,11 @@ package com.comphenix.protocol; import java.util.Collections; +import java.util.Iterator; import java.util.List; import java.util.stream.Collectors; +import java.util.stream.Stream; +import java.util.stream.StreamSupport; import com.comphenix.protocol.reflect.accessors.Accessors; import com.comphenix.protocol.reflect.accessors.FieldAccessor; @@ -41,6 +44,7 @@ import org.apache.logging.log4j.LogManager; import org.bukkit.Bukkit; import org.bukkit.Keyed; import org.bukkit.NamespacedKey; +import org.bukkit.Registry; import org.bukkit.World; import org.bukkit.craftbukkit.v1_21_R1.CraftLootTable; import org.bukkit.craftbukkit.v1_21_R1.CraftRegistry; @@ -162,7 +166,14 @@ public class BukkitInitialization { }); when(mockedServer.getRegistry(any())).thenAnswer(invocation -> { Class registryType = invocation.getArgument(0); - return CraftRegistry.createRegistry(registryType, registryCustom); + Object registry = CraftRegistry.createRegistry(registryType, registryCustom); + + // this is very temporary fix to the version mismatch between spigot-api (spigot-repo) and spigot (dmulloy2-repo) + // if you remove this fix please also remove the DummyRegistry class down below + if (registry == null) + return new DummyRegistry<>(); + + return registry; }); when(mockedServer.getTag(any(), any(), any())).then(mock -> { @@ -250,4 +261,23 @@ public class BukkitInitialization { MinecraftReflectionTestUtil.init(); } } + + class DummyRegistry implements Registry { + + @Override + public Iterator iterator() { + return Collections.emptyIterator(); + } + + @Override + public T get(NamespacedKey key) { + return null; + } + + @Override + public Stream stream() { + List emtpy = Collections.emptyList(); + return emtpy.stream(); + } + } }