Skip to content

Commit 73d963d

Browse files
committed
[ci skip] Begin work on Fabric/NeoForge modules using Architectury
1 parent 83b1f11 commit 73d963d

File tree

24 files changed

+613
-5
lines changed

24 files changed

+613
-5
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ A battery packed, multi-platform plugin template for Minecraft servers to get yo
66
- [Cloud](https://github.com/Incendo/cloud) for platform-agnostic command registration and handling.
77
- [Configurate](https://github.com/SpongePowered/Configurate) for cross-platform configuration.
88

9-
Currently supporting Bukkit, Bungeecord, Paper and Velocity.
9+
Currently supporting Bukkit, Bungeecord, Fabric, NeoForge, Paper and Velocity.
1010

1111
## License
1212
This project is licensed under the [CC0 1.0 Universal](https://github.com/RealTriassic/plugin-template/blob/main/LICENSE) license, meaning you are free to use this project however you like, including changing the license for your own projects.

bootstrap/mod/build.gradle.kts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
plugins {
2+
id("architectury-plugin")
3+
id("dev.architectury.loom") version "1.11-SNAPSHOT"
4+
}
5+
6+
architectury {
7+
minecraft = "1.21.8"
8+
common("fabric", "neoforge")
9+
}
10+
11+
loom {
12+
silentMojangMappingsLicense()
13+
}
14+
15+
dependencies {
16+
minecraft("net.minecraft:minecraft:1.21.8")
17+
mappings(loom.officialMojangMappings())
18+
}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
plugins {
2+
id("dev.architectury.loom") version "1.11-SNAPSHOT"
3+
id("architectury-plugin")
4+
id("conventions.modded")
5+
}
6+
7+
architectury {
8+
platformSetupLoomIde()
9+
fabric()
10+
}
11+
12+
dependencies {
13+
minecraft("net.minecraft:minecraft:1.21.8")
14+
mappings(loom.officialMojangMappings())
15+
modImplementation("net.fabricmc:fabric-loader:0.17.2")
16+
modImplementation(libs.adventure.api)
17+
include(libs.adventure.api)
18+
modImplementation(libs.adventure.minimessage)
19+
include(libs.adventure.minimessage)
20+
include(libs.adventure.fabric)
21+
modImplementation(libs.adventure.fabric)
22+
include(libs.cloud.fabric)
23+
modImplementation(libs.cloud.fabric)
24+
shade(project(mapOf("path" to ":core", "configuration" to "shadow")))
25+
}
26+
27+
relocate("org.spongepowered")
28+
29+
tasks.named<com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar>("shadowJar") {
30+
exclude("org/incendo/cloud/**")
31+
exclude("META-INF/services/org.incendo.cloud.*")
32+
exclude("org/slf4j/**")
33+
relocate("io.leangen.geantyref", "dev.triassic.template.lib.geantyref")
34+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
loom.platform=fabric
Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
/*
2+
* This is free and unencumbered software released into the public domain.
3+
*
4+
* Anyone is free to copy, modify, publish, use, compile, sell, or
5+
* distribute this software, either in source code form or as a compiled
6+
* binary, for any purpose, commercial or non-commercial, and by any
7+
* means.
8+
*
9+
* In jurisdictions that recognize copyright laws, the author or authors
10+
* of this software dedicate any and all copyright interest in the
11+
* software to the public domain. We make this dedication for the benefit
12+
* of the public at large and to the detriment of our heirs and
13+
* successors. We intend this dedication to be an overt act of
14+
* relinquishment in perpetuity of all present and future rights to this
15+
* software under copyright law.
16+
*
17+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18+
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19+
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
20+
* IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
21+
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
22+
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
23+
* OTHER DEALINGS IN THE SOFTWARE.
24+
*
25+
* For more information, please refer to <https://unlicense.org/>
26+
*/
27+
28+
package dev.triassic.template.mod.fabric;
29+
30+
import dev.triassic.template.TemplateImpl;
31+
import dev.triassic.template.TemplatePlugin;
32+
import dev.triassic.template.command.Commander;
33+
import dev.triassic.template.mod.fabric.command.FabricCommander;
34+
import dev.triassic.template.util.PlatformType;
35+
import java.nio.file.Path;
36+
import net.fabricmc.api.ModInitializer;
37+
import net.fabricmc.loader.api.FabricLoader;
38+
import org.checkerframework.checker.nullness.qual.NonNull;
39+
import org.incendo.cloud.CommandManager;
40+
import org.incendo.cloud.SenderMapper;
41+
import org.incendo.cloud.execution.ExecutionCoordinator;
42+
import org.incendo.cloud.fabric.FabricServerCommandManager;
43+
import org.slf4j.Logger;
44+
import org.slf4j.LoggerFactory;
45+
46+
/**
47+
* hey!!!.
48+
*/
49+
public final class FabricTemplateMod implements ModInitializer, TemplatePlugin {
50+
51+
private Logger logger;
52+
private FabricServerCommandManager<Commander> commandManager;
53+
private TemplateImpl impl;
54+
55+
@Override
56+
public void onInitialize() {
57+
this.logger = LoggerFactory.getLogger(FabricTemplateMod.class);
58+
this.commandManager = new FabricServerCommandManager<>(
59+
ExecutionCoordinator.simpleCoordinator(),
60+
SenderMapper.create(
61+
FabricCommander::from,
62+
commander -> ((FabricCommander) commander).source()
63+
)
64+
);
65+
66+
this.impl = new TemplateImpl(this);
67+
impl.initialize();
68+
}
69+
70+
@Override
71+
public @NonNull Logger logger() {
72+
return logger;
73+
}
74+
75+
@Override
76+
public @NonNull Path dataDirectory() {
77+
return FabricLoader.getInstance().getConfigDir();
78+
}
79+
80+
@Override
81+
public @NonNull PlatformType platformType() {
82+
return PlatformType.FABRIC;
83+
}
84+
85+
@Override
86+
public @NonNull CommandManager<Commander> commandManager() {
87+
return this.commandManager;
88+
}
89+
}
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
/*
2+
* This is free and unencumbered software released into the public domain.
3+
*
4+
* Anyone is free to copy, modify, publish, use, compile, sell, or
5+
* distribute this software, either in source code form or as a compiled
6+
* binary, for any purpose, commercial or non-commercial, and by any
7+
* means.
8+
*
9+
* In jurisdictions that recognize copyright laws, the author or authors
10+
* of this software dedicate any and all copyright interest in the
11+
* software to the public domain. We make this dedication for the benefit
12+
* of the public at large and to the detriment of our heirs and
13+
* successors. We intend this dedication to be an overt act of
14+
* relinquishment in perpetuity of all present and future rights to this
15+
* software under copyright law.
16+
*
17+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18+
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19+
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
20+
* IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
21+
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
22+
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
23+
* OTHER DEALINGS IN THE SOFTWARE.
24+
*
25+
* For more information, please refer to <https://unlicense.org/>
26+
*/
27+
28+
package dev.triassic.template.mod.fabric.command;
29+
30+
import dev.triassic.template.command.Commander;
31+
import net.kyori.adventure.audience.Audience;
32+
import net.kyori.adventure.audience.ForwardingAudience;
33+
import net.minecraft.commands.CommandSourceStack;
34+
import org.checkerframework.checker.nullness.qual.NonNull;
35+
import org.checkerframework.framework.qual.DefaultQualifier;
36+
37+
/**
38+
* Represents a Fabric-specific {@link Commander}.
39+
*
40+
* <p>Slightly borrowed from <a href="https://github.com/Hexaoxide/Carbon">Carbon's</a> implementation.</p>
41+
*/
42+
@DefaultQualifier(NonNull.class)
43+
public interface FabricCommander extends Commander, ForwardingAudience.Single {
44+
45+
/**
46+
* Create a new {@link FabricCommander} from a {@link CommandSourceStack}.
47+
*
48+
* @param source the {@link CommandSourceStack}
49+
* @return a new {@link FabricCommander}
50+
*/
51+
static FabricCommander from(final CommandSourceStack source) {
52+
return new FabricCommanderImpl(source);
53+
}
54+
55+
/**
56+
* Gets the underlying {@link CommandSourceStack}.
57+
*
58+
* @return the {@link CommandSourceStack}
59+
*/
60+
CommandSourceStack source();
61+
62+
/**
63+
* A record implementation of {@link FabricCommander}.
64+
*/
65+
record FabricCommanderImpl(CommandSourceStack source) implements FabricCommander {
66+
67+
@Override
68+
public Audience audience() {
69+
return source.audience();
70+
}
71+
72+
@Override
73+
public boolean hasPermission(final String permission) {
74+
return true; // TODO: Check for permission in Fabric.
75+
}
76+
}
77+
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
{
2+
"schemaVersion": 1,
3+
"id": "example_mod",
4+
"version": "${version}",
5+
"name": "${name}",
6+
"description": "${description}",
7+
"authors": [
8+
"${author}"
9+
],
10+
"contact": {
11+
"homepage": "${url}"
12+
},
13+
"license": "UNLICENSED",
14+
"environment": "*",
15+
"entrypoints": {
16+
"main": [
17+
"dev.triassic.template.mod.fabric.FabricTemplateMod"
18+
],
19+
"client": []
20+
},
21+
"mixins": [],
22+
"depends": {
23+
"fabricloader": ">=0.16.14",
24+
"minecraft": "~1.21.8",
25+
"java": ">=21",
26+
"cloud": "*"
27+
}
28+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
[Architectury Transformer DEBUG] Closed File Systems for /var/home/triassic/Desktop/plugin-template/bootstrap/mod/build/libs/mod-1.0.0-SNAPSHOT.jar
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
plugins {
2+
id("dev.architectury.loom") version "1.11-SNAPSHOT"
3+
id("architectury-plugin")
4+
id("conventions.modded")
5+
}
6+
7+
architectury {
8+
platformSetupLoomIde()
9+
neoForge()
10+
}
11+
12+
dependencies {
13+
modImplementation(libs.adventure.api)
14+
include(libs.adventure.api)
15+
modImplementation(libs.adventure.minimessage)
16+
include(libs.adventure.minimessage)
17+
minecraft("net.minecraft:minecraft:1.21.8")
18+
mappings(loom.officialMojangMappings())
19+
neoForge("net.neoforged:neoforge:21.8.46")
20+
include(libs.adventure.neoforge)
21+
modImplementation(libs.adventure.neoforge)
22+
include(libs.cloud.neoforge)
23+
modImplementation(libs.cloud.neoforge)
24+
shade(project(mapOf("path" to ":core", "configuration" to "shadow")))
25+
}
26+
27+
relocate("org.spongepowered")
28+
29+
tasks.named<com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar>("shadowJar") {
30+
exclude("org/incendo/cloud/**")
31+
exclude("META-INF/services/org.incendo.cloud.*")
32+
exclude("org/slf4j/**")
33+
relocate("io.leangen.geantyref", "dev.triassic.template.lib.geantyref")
34+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
loom.platform=neoforge

0 commit comments

Comments
 (0)