Skip to content

Commit 2dfd9fe

Browse files
committed
Add implementations for the newest fabric/forge/neoforge versions
1 parent 75b562e commit 2dfd9fe

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+1990
-58
lines changed

.github/workflows/build.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ jobs:
2626
java-version: |
2727
16
2828
17
29+
21
2930
cache: 'gradle'
3031
- name: Build with Gradle
3132
run: ./gradlew clean spotlessCheck test build

.github/workflows/publish.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ jobs:
2121
java-version: |
2222
16
2323
17
24+
21
2425
cache: 'gradle'
2526
- name: Build with Gradle
2627
run: ./gradlew clean :BlueMapCore:publish :BlueMapCommon:publish

implementations/cli/build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ plugins {
33
`java-library`
44
id("com.diffplug.spotless") version "6.1.2"
55
id ("com.github.node-gradle.node") version "3.0.1"
6-
id ("com.github.johnrengelman.shadow") version "7.1.2"
6+
id ("com.github.johnrengelman.shadow") version "8.1.1"
77
}
88

99
group = "de.bluecolored.bluemap"

implementations/fabric-1.18/build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ plugins {
99
`java-library`
1010
id("com.diffplug.spotless") version "6.1.2"
1111
id ("com.github.node-gradle.node") version "3.0.1"
12-
id ("com.github.johnrengelman.shadow") version "7.1.2"
12+
id ("com.github.johnrengelman.shadow") version "8.1.1"
1313
id ("fabric-loom") version "1.3-SNAPSHOT"
1414
id ("com.modrinth.minotaur") version "2.+"
1515
id ("com.matthewprenger.cursegradle") version "1.4.0"

implementations/fabric-1.19.4/build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ plugins {
99
`java-library`
1010
id("com.diffplug.spotless") version "6.1.2"
1111
id ("com.github.node-gradle.node") version "3.0.1"
12-
id ("com.github.johnrengelman.shadow") version "7.1.2"
12+
id ("com.github.johnrengelman.shadow") version "8.1.1"
1313
id ("fabric-loom") version "1.3-SNAPSHOT"
1414
id ("com.modrinth.minotaur") version "2.+"
1515
id ("com.matthewprenger.cursegradle") version "1.4.0"

implementations/fabric-1.20/build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ plugins {
99
`java-library`
1010
id("com.diffplug.spotless") version "6.1.2"
1111
id ("com.github.node-gradle.node") version "3.0.1"
12-
id ("com.github.johnrengelman.shadow") version "7.1.2"
12+
id ("com.github.johnrengelman.shadow") version "8.1.1"
1313
id ("fabric-loom") version "1.5-SNAPSHOT"
1414
id ("com.modrinth.minotaur") version "2.+"
1515
id ("com.matthewprenger.cursegradle") version "1.4.0"
Lines changed: 177 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,177 @@
1+
import com.matthewprenger.cursegradle.CurseArtifact
2+
import com.matthewprenger.cursegradle.CurseProject
3+
import com.matthewprenger.cursegradle.CurseRelation
4+
import com.matthewprenger.cursegradle.Options
5+
import net.fabricmc.loom.task.RemapJarTask
6+
7+
plugins {
8+
java
9+
`java-library`
10+
id("com.diffplug.spotless") version "6.1.2"
11+
id ("com.github.node-gradle.node") version "3.0.1"
12+
id ("com.github.johnrengelman.shadow") version "8.1.1"
13+
id ("fabric-loom") version "1.6-SNAPSHOT"
14+
id ("com.modrinth.minotaur") version "2.+"
15+
id ("com.matthewprenger.cursegradle") version "1.4.0"
16+
}
17+
18+
group = "de.bluecolored.bluemap"
19+
version = System.getProperty("bluemap.version") ?: "?" // set by BlueMapCore
20+
21+
val javaTarget = 21
22+
java {
23+
sourceCompatibility = JavaVersion.toVersion(javaTarget)
24+
targetCompatibility = JavaVersion.toVersion(javaTarget)
25+
26+
withSourcesJar()
27+
}
28+
29+
repositories {
30+
mavenCentral()
31+
maven ("https://libraries.minecraft.net")
32+
maven ("https://maven.fabricmc.net/")
33+
maven ("https://oss.sonatype.org/content/repositories/snapshots")
34+
maven ("https://repo.bluecolored.de/releases")
35+
}
36+
37+
val shadowInclude: Configuration by configurations.creating
38+
39+
configurations {
40+
implementation.get().extendsFrom(shadowInclude)
41+
}
42+
43+
dependencies {
44+
shadowInclude ("de.bluecolored.bluemap:BlueMapCommon") {
45+
//exclude dependencies provided by fabric
46+
exclude (group = "com.google.guava", module = "guava")
47+
exclude (group = "com.google.code.gson", module = "gson")
48+
exclude (group = "com.mojang", module = "brigadier")
49+
}
50+
51+
minecraft ("com.mojang:minecraft:1.20.5")
52+
mappings ("net.fabricmc:yarn:1.20.5+build.1")
53+
modImplementation ("net.fabricmc:fabric-loader:0.15.10")
54+
modImplementation ("net.fabricmc.fabric-api:fabric-api:0.97.8+1.20.5")
55+
modImplementation("me.lucko:fabric-permissions-api:0.1-SNAPSHOT")
56+
57+
testImplementation ("org.junit.jupiter:junit-jupiter:5.9.0")
58+
testRuntimeOnly ("org.junit.jupiter:junit-jupiter-engine:5.9.0")
59+
}
60+
61+
spotless {
62+
java {
63+
target ("src/*/java/**/*.java")
64+
65+
licenseHeaderFile("../../HEADER")
66+
indentWithSpaces()
67+
trimTrailingWhitespace()
68+
}
69+
}
70+
71+
tasks.withType(JavaCompile::class).configureEach {
72+
options.apply {
73+
encoding = "utf-8"
74+
}
75+
}
76+
77+
tasks.withType(AbstractArchiveTask::class).configureEach {
78+
isReproducibleFileOrder = true
79+
isPreserveFileTimestamps = false
80+
}
81+
82+
tasks.test {
83+
useJUnitPlatform()
84+
}
85+
86+
tasks.processResources {
87+
inputs.property ("version", project.version)
88+
89+
filesMatching("fabric.mod.json") {
90+
expand ("version" to project.version)
91+
}
92+
}
93+
94+
tasks.shadowJar {
95+
configurations = listOf(shadowInclude)
96+
97+
//relocate ("com.flowpowered.math", "de.bluecolored.shadow.flowpowered.math") //DON"T relocate this, because the API depends on it
98+
relocate ("com.typesafe.config", "de.bluecolored.shadow.typesafe.config")
99+
relocate ("de.bluecolored.bluenbt", "de.bluecolored.shadow.bluenbt")
100+
relocate ("org.spongepowered.configurate", "de.bluecolored.shadow.configurate")
101+
relocate ("com.github.benmanes.caffeine", "de.bluecolored.shadow.benmanes.caffeine")
102+
relocate ("org.aopalliance", "de.bluecolored.shadow.aopalliance")
103+
relocate ("javax.inject", "de.bluecolored.shadow.javax.inject")
104+
relocate ("org.checkerframework", "de.bluecolored.shadow.checkerframework")
105+
relocate ("org.codehaus", "de.bluecolored.shadow.codehaus")
106+
relocate ("io.leangen.geantyref", "de.bluecolored.shadow.geantyref")
107+
relocate ("io.airlift", "de.bluecolored.shadow.airlift")
108+
relocate ("net.jpountz", "de.bluecolored.shadow.jpountz")
109+
110+
relocate ("com.google.errorprone", "de.bluecolored.shadow.google.errorprone")
111+
relocate ("com.google.inject", "de.bluecolored.shadow.google.inject")
112+
113+
relocate ("org.apache.commons.dbcp2", "de.bluecolored.shadow.apache.commons.dbcp2")
114+
relocate ("org.apache.commons.logging", "de.bluecolored.shadow.apache.commons.logging")
115+
relocate ("org.apache.commons.pool2", "de.bluecolored.shadow.apache.commons.pool2")
116+
}
117+
118+
tasks.register("remappedShadowJar", type = RemapJarTask::class) {
119+
destinationDirectory.set(file("../../build/release"))
120+
archiveFileName.set("BlueMap-${project.version}-${project.name}.jar")
121+
dependsOn (tasks.shadowJar)
122+
inputFile.set(tasks.shadowJar.get().archiveFile)
123+
addNestedDependencies.set(true)
124+
}
125+
126+
tasks.register("release") {
127+
dependsOn("remappedShadowJar")
128+
}
129+
130+
modrinth {
131+
token.set(System.getenv("MODRINTH_TOKEN"))
132+
projectId.set("swbUV1cr")
133+
versionNumber.set("${project.version}-${project.name}")
134+
changelog.set(file("../../release.md")
135+
.readText()
136+
.replace("{version}", project.version.toString()))
137+
uploadFile.set(tasks.findByName("remappedShadowJar"))
138+
gameVersions.addAll("1.20.5", "1.20.6")
139+
dependencies {
140+
required.project("P7dR8mSH") // Fabric API
141+
}
142+
}
143+
144+
curseforge {
145+
apiKey = System.getenv("CURSEFORGE_TOKEN") ?: ""
146+
project(closureOf<CurseProject> {
147+
id = "406463"
148+
changelogType = "markdown"
149+
changelog = file("../../release.md")
150+
.readText()
151+
.replace("{version}", project.version.toString())
152+
releaseType = "release"
153+
154+
addGameVersion("Fabric")
155+
156+
addGameVersion("Java 21")
157+
158+
addGameVersion("1.20.5")
159+
addGameVersion("1.20.6")
160+
161+
mainArtifact(tasks.findByName("remappedShadowJar"), closureOf<CurseArtifact> {
162+
relations(closureOf<CurseRelation> {
163+
requiredDependency("fabric-api")
164+
})
165+
})
166+
})
167+
options(closureOf<Options> {
168+
javaVersionAutoDetect = false
169+
javaIntegration = false
170+
forgeGradleIntegration = false
171+
})
172+
}
173+
174+
tasks.register("publish") {
175+
dependsOn("modrinth")
176+
dependsOn("curseforge")
177+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
pluginManagement {
2+
repositories {
3+
maven {
4+
name = "Fabric"
5+
url = uri("https://maven.fabricmc.net/")
6+
}
7+
gradlePluginPortal()
8+
}
9+
}
10+
11+
rootProject.name = "fabric"
12+
13+
includeBuild("../../BlueMapCommon")
Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
/*
2+
* This file is part of BlueMap, licensed under the MIT License (MIT).
3+
*
4+
* Copyright (c) Blue (Lukas Rieger) <https://bluecolored.de>
5+
* Copyright (c) contributors
6+
*
7+
* Permission is hereby granted, free of charge, to any person obtaining a copy
8+
* of this software and associated documentation files (the "Software"), to deal
9+
* in the Software without restriction, including without limitation the rights
10+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11+
* copies of the Software, and to permit persons to whom the Software is
12+
* furnished to do so, subject to the following conditions:
13+
*
14+
* The above copyright notice and this permission notice shall be included in
15+
* all copies or substantial portions of the Software.
16+
*
17+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
23+
* THE SOFTWARE.
24+
*/
25+
package de.bluecolored.bluemap.fabric;
26+
27+
import com.flowpowered.math.vector.Vector3d;
28+
import de.bluecolored.bluemap.common.plugin.Plugin;
29+
import de.bluecolored.bluemap.common.plugin.text.Text;
30+
import de.bluecolored.bluemap.common.serverinterface.CommandSource;
31+
import de.bluecolored.bluemap.common.serverinterface.ServerWorld;
32+
import de.bluecolored.bluemap.core.world.World;
33+
import me.lucko.fabric.api.permissions.v0.Permissions;
34+
import net.minecraft.registry.BuiltinRegistries;
35+
import net.minecraft.registry.RegistryWrapper;
36+
import net.minecraft.server.command.ServerCommandSource;
37+
import net.minecraft.util.math.Vec3d;
38+
39+
import java.util.Optional;
40+
41+
public class FabricCommandSource implements CommandSource {
42+
43+
private static final RegistryWrapper.WrapperLookup lookup = BuiltinRegistries.createWrapperLookup();
44+
45+
private final FabricMod mod;
46+
private final Plugin plugin;
47+
private final ServerCommandSource delegate;
48+
49+
public FabricCommandSource(FabricMod mod, Plugin plugin, ServerCommandSource delegate) {
50+
this.mod = mod;
51+
this.plugin = plugin;
52+
this.delegate = delegate;
53+
}
54+
55+
@Override
56+
public void sendMessage(Text text) {
57+
delegate.sendFeedback(
58+
() -> net.minecraft.text.Text.Serialization
59+
.fromJson(text.toJSONString(), lookup),
60+
false
61+
);
62+
}
63+
64+
@Override
65+
public boolean hasPermission(String permission) {
66+
try {
67+
Class.forName("me.lucko.fabric.api.permissions.v0.Permissions");
68+
return Permissions.check(delegate, permission, 1);
69+
} catch (ClassNotFoundException ex) {
70+
return delegate.hasPermissionLevel(1);
71+
}
72+
}
73+
74+
@Override
75+
public Optional<Vector3d> getPosition() {
76+
Vec3d pos = delegate.getPosition();
77+
if (pos != null) {
78+
return Optional.of(new Vector3d(pos.x, pos.y, pos.z));
79+
}
80+
81+
return Optional.empty();
82+
}
83+
84+
@Override
85+
public Optional<World> getWorld() {
86+
ServerWorld serverWorld = mod.getServerWorld(delegate.getWorld());
87+
return Optional.ofNullable(plugin.getWorld(serverWorld));
88+
}
89+
90+
}

0 commit comments

Comments
 (0)