mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2026-10-25 21:40:05 +00:00
Download translations on demand instead of bundling them
Locales are fetched from the Iris repository at runtime into languages/downloaded and cached against the revision the jar was built from; the artifact ships only a manifest of the available locales. IrisLanguage gains a player language service, per-audience snapshots and an in-game message editor that writes locale overrides. The Bukkit artifact verifier now fails when any locale file is embedded, and the modded shadow jars drop the Bukkit-only switcher and editor classes.
This commit is contained in:
10 files changed
+472
-191
No files matched your search
+1
-58
@@ -3,8 +3,6 @@ import org.gradle.api.tasks.Copy
|
||||
import org.gradle.api.tasks.compile.JavaCompile
|
||||
import org.gradle.jvm.tasks.Jar
|
||||
import org.gradle.jvm.toolchain.JavaLanguageVersion
|
||||
import groovy.json.JsonOutput
|
||||
import groovy.json.JsonSlurper
|
||||
|
||||
/*
|
||||
* Iris is a World Generator for Minecraft Bukkit Servers
|
||||
@@ -147,16 +145,6 @@ nmsBindings.each { key, value ->
|
||||
|
||||
def included = configurations.create('included')
|
||||
def jarJar = configurations.create('jarJar')
|
||||
def bukkitLanguagesDirectory = layout.buildDirectory.dir('generated/bukkit-languages')
|
||||
Set<String> sharedNonEnglishBukkitMessages = [
|
||||
'iris.desktop.vision.fps',
|
||||
'iris.desktop.vision.tiles',
|
||||
'iris.bukkit.runtime.commandpack.message_2',
|
||||
'iris.bukkit.commanddatapack.message_2',
|
||||
'iris.runtime.chunk_job.bossbar.progress',
|
||||
'iris.runtime.studio.action.progress',
|
||||
'iris.runtime.chunk_job.action.progress'
|
||||
] as Set
|
||||
dependencies {
|
||||
nmsBindings.keySet().each { key ->
|
||||
add('included', project(path: ":adapters:bukkit:nms:${key}", configuration: 'runtimeElements'))
|
||||
@@ -166,48 +154,6 @@ dependencies {
|
||||
add('jarJar', project(':core:agent'))
|
||||
}
|
||||
|
||||
def prepareBukkitLanguages = tasks.register('prepareBukkitLanguages') {
|
||||
inputs.files(fileTree(project(':core').file('src/main/resources/languages')) {
|
||||
include('*.json')
|
||||
})
|
||||
outputs.dir(bukkitLanguagesDirectory)
|
||||
doLast {
|
||||
File outputDirectory = bukkitLanguagesDirectory.get().asFile
|
||||
delete(outputDirectory)
|
||||
outputDirectory.mkdirs()
|
||||
List<File> sources = fileTree(project(':core').file('src/main/resources/languages')) {
|
||||
include('*.json')
|
||||
}.files.sort { File left, File right -> left.name <=> right.name }
|
||||
List<Map<String, Object>> catalogs = sources.collect { File source ->
|
||||
(Map<String, Object>) new JsonSlurper().parse(source)
|
||||
}
|
||||
Map<String, Object> referenceMessages = (Map<String, Object>) catalogs.first().get('messages')
|
||||
List<String> messageIds = referenceMessages.keySet()
|
||||
.findAll { String key -> !key.startsWith('iris.modded.') }
|
||||
.sort()
|
||||
Set<String> sharedFallbackIds = new LinkedHashSet<>(messageIds)
|
||||
catalogs.each { Map<String, Object> catalog ->
|
||||
Map<String, Object> messages = (Map<String, Object>) catalog.get('messages')
|
||||
if (!messages.keySet().containsAll(messageIds)) {
|
||||
throw new GradleException("Bundled locale ${catalog.get('locale')} is missing Bukkit messages")
|
||||
}
|
||||
sharedFallbackIds.removeIf { String key -> messages.get(key) != referenceMessages.get(key) }
|
||||
}
|
||||
sharedFallbackIds.removeAll(sharedNonEnglishBukkitMessages)
|
||||
|
||||
sources.eachWithIndex { File source, int index ->
|
||||
Map<String, Object> catalog = catalogs.get(index)
|
||||
Map<String, Object> messages = (Map<String, Object>) catalog.get('messages')
|
||||
List<Object> compactMessages = messageIds.collect { String key ->
|
||||
sharedFallbackIds.contains(key) ? null : messages.get(key)
|
||||
}
|
||||
new File(outputDirectory, source.name).setText(
|
||||
JsonOutput.toJson([catalog.get('locale'), compactMessages]),
|
||||
'UTF-8')
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
tasks.named('jar', Jar).configure {
|
||||
inputs.files(included)
|
||||
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
|
||||
@@ -216,9 +162,6 @@ tasks.named('jar', Jar).configure {
|
||||
from(provider { included.resolve().collect { zipTree(it) } }) {
|
||||
exclude('languages/**')
|
||||
}
|
||||
from(prepareBukkitLanguages) {
|
||||
into('languages')
|
||||
}
|
||||
doFirst {
|
||||
delete(layout.buildDirectory.file("libs/Iris-${project.version}.jar"))
|
||||
}
|
||||
@@ -591,6 +534,7 @@ List<String> requiredBukkitArtifactEntries = [
|
||||
'paper-plugin.yml',
|
||||
'slimjar.dat',
|
||||
'slimjar-resolutions.dat',
|
||||
'iris-language-source.properties',
|
||||
'agent.jar',
|
||||
'art/arcane/iris/Iris.class',
|
||||
'art/arcane/iris/IrisBootstrap.class',
|
||||
@@ -618,7 +562,6 @@ tasks.register('verifyBukkitArtifact') {
|
||||
BukkitArtifactVerifier.verify(
|
||||
artifact,
|
||||
requiredBukkitArtifactEntries,
|
||||
17,
|
||||
16,
|
||||
maximumBukkitArtifactBytes)
|
||||
logger.lifecycle("Verified ${artifact.name} packaging and class reference graph")
|
||||
|
||||
Reference in new issue
Block a user