Skip to content

Commit

Permalink
Merge branch 'main' into world-format
Browse files Browse the repository at this point in the history
  • Loading branch information
NichtStudioCode committed Mar 29, 2024
2 parents a9a9ad4 + 0b97246 commit 5ef03c5
Show file tree
Hide file tree
Showing 21 changed files with 175 additions and 104 deletions.
10 changes: 10 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
version: 2
updates:
- package-ecosystem: "gradle"
directory: "/"
schedule:
interval: "daily"
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "weekly"
12 changes: 6 additions & 6 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,21 +12,21 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Set Up JDK 17
uses: actions/setup-java@v3
uses: actions/setup-java@v4
with:
java-version: 17
distribution: adopt

- name: Setup Gradle
uses: gradle/gradle-build-action@v2
uses: gradle/gradle-build-action@v3
with:
cache-disabled: true

- name: Build Spigot-Mapped
uses: gradle/gradle-build-action@v2
uses: gradle/gradle-build-action@v3
with:
arguments: |
loaderJarSpigot
Expand All @@ -35,14 +35,14 @@ jobs:
- name: Upload Artifacts
id: upload
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v4
with:
name: Artifacts
path: ./artifacts/*.jar

- name: Deploy Mojang-Mapped
if: github.event_name == 'release'
uses: gradle/gradle-build-action@v2
uses: gradle/gradle-build-action@v3
with:
arguments: |
publishNovaPublicationToXenondevsRepository
Expand Down
22 changes: 22 additions & 0 deletions .github/workflows/dependency-submission.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: Dependency Submission

on: [ push ]

permissions:
contents: write

jobs:
dependency-submission:
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@v4

- name: Set Up JDK 17
uses: actions/setup-java@v4
with:
java-version: 17
distribution: adopt

- name: Generate and submit dependency graph
uses: gradle/actions/dependency-submission@v3
10 changes: 5 additions & 5 deletions .github/workflows/dokka.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,27 +13,27 @@ jobs:

steps:
- name: Checkout Code
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Set Up JDK 17
uses: actions/setup-java@v3
uses: actions/setup-java@v4
with:
java-version: 17
distribution: adopt

- name: Setup Gradle
uses: gradle/gradle-build-action@v2
uses: gradle/gradle-build-action@v3
with:
cache-disabled: true

- name: Run Dokka
uses: gradle/gradle-build-action@v2
uses: gradle/gradle-build-action@v3
with:
arguments: |
dokkaHtmlMultiModule
--scan
- name: Deploy to Github Pages
uses: JamesIves/github-pages-deploy-action@v4.4.1
uses: JamesIves/github-pages-deploy-action@v4.5.0
with:
folder: build/dokka/htmlMultiModule
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
version = 0.16-alpha.4
version = 0.16-RC.1
kotlin.daemon.jvmargs=-Xmx2g
org.gradle.jvmargs=-Xmx2g
4 changes: 2 additions & 2 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ ktor-client-core-jvm = { group = "io.ktor", name = "ktor-client-core-jvm", versi
ktor-serialization-gson-jvm = { group = "io.ktor", name = "ktor-serialization-gson-jvm", version.ref = "ktor" }
ktor-server-cio-jvm = { group = "io.ktor", name = "ktor-server-cio-jvm", version.ref = "ktor" }
ktor-server-core-jvm = { group = "io.ktor", name = "ktor-server-core-jvm", version.ref = "ktor" }
maven-resolver-connector-basic = { group = "org.apache.maven.resolver", name = "maven-resolver-connector-basic", version = "1.8.2" }
maven-resolver-connector-basic = { group = "org.apache.maven.resolver", name = "maven-resolver-connector-basic", version = "1.9.18" }
maven-resolver-provider = { group = "org.apache.maven", name = "maven-resolver-provider", version = "3.8.5" }
maven-resolver-transport-http = { group = "org.apache.maven.resolver", name = "maven-resolver-transport-http", version = "1.8.2" }
minecraft-asset-downloader = { group = "xyz.xenondevs", name = "minecraft-asset-downloader", version = "1.3" }
Expand All @@ -56,7 +56,7 @@ nmsutilities = { group = "xyz.xenondevs", name = "nms-utilities", version = "0.1
paper-api = { group = "io.papermc.paper", name = "paper-api", version.ref = "paper" }
specialsource = { group = "net.md-5", name = "SpecialSource", version = "1.11.0" }
stringremapper = { group = "xyz.xenondevs.string-remapper", name = "string-remapper-core", version.ref = "stringremapper" }
zip4j = { group = "net.lingala.zip4j", name = "zip4j", version = "2.11.2" }
zip4j = { group = "net.lingala.zip4j", name = "zip4j", version = "2.11.5" }

[bundles]
cbf = ["cosmic-binary-format", "cosmic-binary-format-netty-adapter"]
Expand Down
2 changes: 1 addition & 1 deletion nova-api/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ plugins {
}

dependencies {
implementation("org.jetbrains:annotations:24.0.1")
implementation("org.jetbrains:annotations:24.1.0")
compileOnly(project(":nova-loader"))
compileOnly(libs.paper.api)
}
Expand Down
2 changes: 1 addition & 1 deletion nova-hooks/nova-hook-fastasyncworldedit/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ plugins {
dependencies {
paperweight.paperDevBundle(libs.versions.paper)
implementation(project(":nova"))
compileOnly("com.fastasyncworldedit:FastAsyncWorldEdit-Libs-Core:2.6.0") { isTransitive = false }
compileOnly("com.fastasyncworldedit:FastAsyncWorldEdit-Libs-Core:2.9.1") { isTransitive = false }
compileOnly("com.fastasyncworldedit:FastAsyncWorldEdit-Core:2.6.0") { isTransitive = false }
compileOnly("com.fastasyncworldedit:FastAsyncWorldEdit-Bukkit:2.6.0") { isTransitive = false }
}
2 changes: 1 addition & 1 deletion nova-hooks/nova-hook-plotsquared/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@ dependencies {
implementation(project(":nova"))
implementation(project(":nova-api"))
compileOnly("com.plotsquared:PlotSquared-Core:6.10.5") { isTransitive = false }
compileOnly("com.plotsquared:PlotSquared-Bukkit:6.10.5") { isTransitive = false }
compileOnly("com.plotsquared:PlotSquared-Bukkit:6.11.2") { isTransitive = false }
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
public class NovaBootstrapper implements PluginBootstrap {

private static final String NOVA_JAR_PATH = "/nova.jar";
private static final String LIBRARIES_PATH = "/libraries.json";
private static final String PRIORITIZED_LIBRARIES_PATH = "/prioritized_libraries.json";

private static final String BUNDLER_DIR_PATH = ".internal_data/bundler";
Expand All @@ -36,7 +35,6 @@ public void bootstrap(@NotNull BootstrapContext context) {
var novaJar = extractNovaJar(context);
var classLoader = new NovaClassLoader(
novaJar.toURI().toURL(),
loadLibraries(logger, LIBRARIES_PATH),
loadLibraries(logger, PRIORITIZED_LIBRARIES_PATH),
getClass().getClassLoader() // PaperPluginClassLoader
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,11 @@ public class NovaClassLoader extends URLClassLoader {
// Under no circumstances should it be used to load classes, only to find resources.
private final URLClassLoader prioritizedLibraries;

public NovaClassLoader(@NotNull URL nova, @NotNull URL @NotNull [] libraries, @NotNull URL @NotNull [] prioritizedLibraries, @Nullable ClassLoader parent) {
super(concatUrls(nova, libraries), parent);
public NovaClassLoader(@NotNull URL nova, @NotNull URL @NotNull [] prioritizedLibraries, @Nullable ClassLoader parent) {
super(new URL[] {nova}, parent);
this.prioritizedLibraries = new URLClassLoader(prioritizedLibraries, null);
}

private static URL[] concatUrls(URL url, URL[] arr) {
URL[] result = new URL[arr.length + 1];
result[0] = url;
System.arraycopy(arr, 0, result, 1, arr.length);
return result;
}

@Override
public @NotNull Class<?> loadClass(@NotNull String name, boolean resolve) throws ClassNotFoundException {
return loadClass(name, resolve, true, true);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
package xyz.xenondevs.nova.loader;

import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
import io.papermc.paper.plugin.loader.PluginClasspathBuilder;
import io.papermc.paper.plugin.loader.PluginLoader;
import io.papermc.paper.plugin.loader.library.impl.MavenLibraryResolver;
import org.eclipse.aether.repository.RemoteRepository;
import org.jetbrains.annotations.NotNull;
import xyz.xenondevs.nova.loader.library.LibraryFileParser;
import xyz.xenondevs.nova.loader.library.NovaLibraryLoader;

import java.io.IOException;
import java.io.InputStreamReader;

public class NovaLoader implements PluginLoader {

private static final String LIBRARIES_PATH = "/libraries.json";

@Override
public void classloader(@NotNull PluginClasspathBuilder pluginClasspathBuilder) {
JsonObject librariesJson;
try (var stream = NovaLibraryLoader.class.getResourceAsStream(LIBRARIES_PATH)) {
assert stream != null;
librariesJson = JsonParser.parseReader(new InputStreamReader(stream)).getAsJsonObject();
} catch (IOException e) {
throw new RuntimeException(e);
}

var repositories = LibraryFileParser.readRepositories(librariesJson);
var dependencies = LibraryFileParser.readLibraries(librariesJson);

MavenLibraryResolver resolver = new MavenLibraryResolver();
for (var dependency : dependencies)
resolver.addDependency(dependency);
for (var repository : repositories)
resolver.addRepository(new RemoteRepository.Builder(repository, "default", repository).build());

pluginClasspathBuilder.addLibrary(resolver);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,7 @@

public class LibraryLoader {

private static final File LIBRARIES_DIR;

static {
var repoProperty = System.getProperty("repo");
LIBRARIES_DIR = repoProperty != null ? new File(repoProperty) : new File("libraries");
}
private static final File LIBRARIES_DIR = new File("libraries");

public static List<File> downloadLibraries(List<String> repositories, List<Dependency> dependencies, Set<String> exclusions, Logger logger) throws DependencyResolutionException {
// setup connection
Expand Down
1 change: 1 addition & 0 deletions nova-loader/src/main/resources/paper-plugin.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ version: "${version}"
api-version: "1.20"
authors: [ "StudioCode", "ByteZ1337", "Javahase" ]
website: "https://github.com/xenondevs/Nova/"
loader: xyz.xenondevs.nova.loader.NovaLoader
bootstrapper: xyz.xenondevs.nova.loader.NovaBootstrapper
main: xyz.xenondevs.nova.loader.NovaJavaPlugin
load: STARTUP
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package xyz.xenondevs.nova.data.resources.builder.font.provider.bitmap

import org.joml.Vector2i
import org.joml.Vector2ic
import xyz.xenondevs.nova.util.data.ImageUtils
import java.awt.image.BufferedImage

Expand All @@ -20,16 +22,16 @@ interface BitmapGlyphImageType<T> {
* The values in the returned Pair<Top, Bottom> correspond with the
* y-coordinate of the first non-empty row from the top and bottom side of the image.
*
* @return An integer pair containing the top and bottom borders, or null if the image is completely empty.
* @return A vector containing the top and bottom borders, or null if the image is completely empty.
*/
fun findHorizontalBorders(image: T, width: Int, height: Int): Pair<Int, Int>?
fun findTopBottomBorders(image: T, width: Int, height: Int): Vector2ic?

companion object {

/**
* A glyph texture represented by a one-dimensional array of argb integers.
*/
val INT_ARRAY: BitmapGlyphImageType<IntArray> = object : BitmapGlyphImageType<IntArray> {
val ARGB_ARRAY: BitmapGlyphImageType<IntArray> = object : BitmapGlyphImageType<IntArray> {

// TODO: consider moving these to ImageUtils as well?
override fun findRightBorder(image: IntArray, width: Int, height: Int): Int? {
Expand All @@ -46,7 +48,7 @@ interface BitmapGlyphImageType<T> {
return if (x != -1) x else null
}

override fun findHorizontalBorders(image: IntArray, width: Int, height: Int): Pair<Int, Int>? {
override fun findTopBottomBorders(image: IntArray, width: Int, height: Int): Vector2ic? {
fun isRowEmpty(y: Int): Boolean {
for (x in 0..<width) {
if (image[y * width + x] ushr 24 != 0)
Expand All @@ -62,7 +64,7 @@ interface BitmapGlyphImageType<T> {
var bottom = height - 1
while (bottom > top && isRowEmpty(bottom)) bottom--

return top to bottom
return Vector2i(top, bottom)
}

}
Expand All @@ -72,7 +74,7 @@ interface BitmapGlyphImageType<T> {
*/
val BUFFERED_IMAGE: BitmapGlyphImageType<BufferedImage> = object : BitmapGlyphImageType<BufferedImage> {
override fun findRightBorder(image: BufferedImage, width: Int, height: Int): Int? = ImageUtils.findRightBorder(image)
override fun findHorizontalBorders(image: BufferedImage, width: Int, height: Int): Pair<Int, Int>? = ImageUtils.findHorizontalBorders(image)
override fun findTopBottomBorders(image: BufferedImage, width: Int, height: Int): Vector2ic? = ImageUtils.findTopBottomBorders(image)
}

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,10 +101,10 @@ abstract class BitmapProvider<T> internal constructor() : FontProvider() {

var minY = 0f
var maxY = 0f
val horizontalBorders = glyphImageType.findHorizontalBorders(glyph, glyphWidth, glyphHeight)
val horizontalBorders = glyphImageType.findTopBottomBorders(glyph, glyphWidth, glyphHeight)
if (horizontalBorders != null) {
minY = ((minY - ascent) * rescale)
maxY = ((maxY - ascent) * rescale)
minY = ((horizontalBorders.x() - ascent) * rescale)
maxY = ((horizontalBorders.y() - ascent) * rescale)
}

map.put(codePoint, floatArrayOf(width, minY, maxY))
Expand Down Expand Up @@ -239,7 +239,7 @@ abstract class BitmapProvider<T> internal constructor() : FontProvider() {
*/
@JvmName("custom1")
fun custom(file: ResourcePath, codePointGrid: CodePointGrid, glyphGrid: GlyphGrid<IntArray>, height: Int, ascent: Int): BitmapProvider<IntArray> =
Custom(BitmapGlyphImageType.INT_ARRAY, file, codePointGrid, glyphGrid, height, ascent)
Custom(BitmapGlyphImageType.ARGB_ARRAY, file, codePointGrid, glyphGrid, height, ascent)

/**
* Creates a new immutable [BitmapProvider] that references another one, but with a different ascent.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ abstract class MutableBitmapProvider<T> : BitmapProvider<T>() {
*/
@JvmName("custom1")
fun custom(file: ResourcePath, codePointGrid: MutableCodePointGrid, glyphGrid: MutableGlyphGrid<IntArray>, height: Int, ascent: Int): MutableBitmapProvider<IntArray> =
Custom(BitmapGlyphImageType.INT_ARRAY, file, codePointGrid, glyphGrid, height, ascent)
Custom(BitmapGlyphImageType.ARGB_ARRAY, file, codePointGrid, glyphGrid, height, ascent)

/**
* Creates a new [BitmapProvider] with a single glyph from a texture.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import xyz.xenondevs.nova.item.behavior.Damageable.Companion.isValidRepairItem
import xyz.xenondevs.nova.item.behavior.Damageable.Companion.setDamage
import xyz.xenondevs.nova.item.behavior.Enchantable
import xyz.xenondevs.nova.item.enchantment.Enchantment
import xyz.xenondevs.nova.item.enchantment.VanillaEnchantment
import xyz.xenondevs.nova.registry.NovaRegistries
import xyz.xenondevs.nova.transformer.MethodTransformer
import xyz.xenondevs.nova.util.bukkitMirror
Expand Down Expand Up @@ -244,9 +245,9 @@ internal object AnvilResultPatch : MethodTransformer(AnvilMenu::createResult) {
}

private fun canEnchant(itemStack: ItemStack, enchantment: Enchantment): Boolean {
return NovaRegistries.ENCHANTMENT_CATEGORY.any { category ->
enchantment in category.enchantments && category.canEnchant(itemStack)
}
return NovaRegistries.ENCHANTMENT_CATEGORY.any { category ->
enchantment in category.enchantments && category.canEnchant(itemStack)
} || (enchantment is VanillaEnchantment && enchantment.enchantment.canEnchant(itemStack))
}

}
Loading

0 comments on commit 5ef03c5

Please sign in to comment.