Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@ private boolean canStart() {
}

LOGGER.info("Starting modpack host server on port {}", serverConfig.hostPort);

return true;
}
}
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ fabric_versions = 1.18.2, 1.19.2, 1.19.4, 1.20.1, 1.20.4, 1.20.6, 1.21.1, 1.21.3
neoforge_versions = 1.20.4, 1.20.6, 1.21.1, 1.21.3
forge_versions = 1.18.2, 1.19.2, 1.19.4, 1.20.1

core_modules = core, fabric-core, fabric-15, fabric-16, forge-fml40, forge-fml47, neoforge-fml2, neoforge-fml4
core_modules = core, fabric-core, fabric-15, fabric-16, forge-fml40, forge-fml47, neoforge-fml2, neoforge-fml4, velocity

loader_fabric = 0.15.11
mixin_extras = 0.3.6
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,13 +82,13 @@ private void updateAll() {
private void initializeGlobalVariables() {
// Initialize global variables
preload = true;
LOADER_MANAGER = new LoaderManager();
// LOADER_MANAGER = new LoaderManager();
MODPACK_LOADER = new ModpackLoader();
MC_VERSION = LOADER_MANAGER.getModVersion("minecraft");
// MC_VERSION = LOADER_MANAGER.getModVersion("minecraft"); // TODO: reenable it
// Can't get via automodpack version though loader methods since this mod isn't loaded yet... At least on forge...
AM_VERSION = ManifestReader.getAutoModpackVersion();
LOADER_VERSION = LOADER_MANAGER.getLoaderVersion();
LOADER = LOADER_MANAGER.getPlatformType().toString().toLowerCase();
// LOADER_VERSION = LOADER_MANAGER.getLoaderVersion(); // TODO: reenable it
// LOADER = LOADER_MANAGER.getPlatformType().toString().toLowerCase(); // TODO: reenable it
AUTOMODPACK_JAR = FileInspection.getAutoModpackJar();
MODS_DIR = AUTOMODPACK_JAR.getParent();

Expand Down Expand Up @@ -168,4 +168,4 @@ private void loadConfigs() {

LOGGER.info("Loaded config! took " + (System.currentTimeMillis() - startTime) + "ms");
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public Stream<Path> scanCandidates() {

new Preload();

ModpackLoader.modsToAdd.forEach(path -> LOGGER.info("Adding mod: {}", path.getFileName()));
ModpackLoader.modsToAdd.forEach(path -> LOGGER.info(" Adding mod: {}", path.getFileName()));

// we would need to force load there e.g. connector mod and its locators to loader
// and in the lazy mod locator load its dependency locator
Expand Down
71 changes: 71 additions & 0 deletions loader/loader-velocity.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar

plugins {
java
id("com.github.johnrengelman.shadow")
}

base {
archivesName = property("mod_id") as String + project.name.replace("loader", "")
version = property("mod_version") as String
group = property("mod_group") as String
}

repositories {
mavenCentral()
maven { url = uri("https://repo.papermc.io/repository/maven-public/") }
}

dependencies {
compileOnly("com.velocitypowered:velocity-api:3.4.0-SNAPSHOT")
annotationProcessor("com.velocitypowered:velocity-api:3.4.0-SNAPSHOT")

implementation(project(":core"))
implementation(project(":loader-core"))

// our needed dependencies
implementation("com.google.code.gson:gson:2.10.1")
implementation("org.apache.logging.log4j:log4j-core:2.20.0")
implementation("org.tomlj:tomlj:1.1.1")
}

configurations {
create("shadowImplementation") {
extendsFrom(configurations.getByName("implementation"))
isCanBeResolved = true
}
}

tasks.named<ShadowJar>("shadowJar") {
archiveClassifier.set("")
mergeServiceFiles()

// Include the tomlj dependency in the shadow jar
configurations = listOf(project.configurations.getByName("shadowImplementation"))

relocate("org.antlr.v4", "reloc.org.antlr.v4")
relocate("org.tomlj", "reloc.org.tomlj")
relocate("org.checkerframework", "reloc.org.checkerframework")

exclude("log4j2.xml")

manifest {
attributes["AutoModpack-Version"] = version
}
}

java {
// leave it on java 17 to be compatible with older versions and we dont really need 21 there anyway
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17

withSourcesJar()
}

tasks.withType<JavaCompile> {
options.encoding = "UTF-8"
}

tasks.named("assemble") {
dependsOn("shadowJar")
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,205 @@
package pl.skidam.automodpack_loader_velocity;

import com.mojang.brigadier.Command;
import com.mojang.brigadier.tree.LiteralCommandNode;
import com.velocitypowered.api.command.BrigadierCommand;
import com.velocitypowered.api.command.CommandSource;
import com.velocitypowered.api.proxy.ProxyServer;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.format.NamedTextColor;

public class Commands {

public static BrigadierCommand register(final ProxyServer proxy) {
LiteralCommandNode<CommandSource> commandNode = BrigadierCommand.literalArgumentBuilder("automodpack")
.executes(context -> {
CommandSource source = context.getSource();
Component message = Component.text("AutoModpack", NamedTextColor.GREEN);
source.sendMessage(message);
return Command.SINGLE_SUCCESS;
})
.then(BrigadierCommand.literalArgumentBuilder("generate")
.requires(source -> source.hasPermission("automodpack.generate"))
.executes(context -> {
CommandSource source = context.getSource();
// Add your generateModpack logic here
source.sendMessage(Component.text("Generating Modpack...", NamedTextColor.YELLOW));
return Command.SINGLE_SUCCESS;
})
)
.then(BrigadierCommand.literalArgumentBuilder("host")
.requires(source -> source.hasPermission("automodpack.host"))
.executes(context -> {
CommandSource source = context.getSource();
// Add your modpackHostAbout logic here
source.sendMessage(Component.text("Modpack hosting status", NamedTextColor.GREEN));
return Command.SINGLE_SUCCESS;
})
.then(BrigadierCommand.literalArgumentBuilder("start")
.requires(source -> source.hasPermission("automodpack.host.start"))
.executes(context -> {
CommandSource source = context.getSource();
// Add your startModpackHost logic here
source.sendMessage(Component.text("Starting modpack hosting...", NamedTextColor.YELLOW));
return Command.SINGLE_SUCCESS;
})
)
.then(BrigadierCommand.literalArgumentBuilder("stop")
.requires(source -> source.hasPermission("automodpack.host.stop"))
.executes(context -> {
CommandSource source = context.getSource();
// Add your stopModpackHost logic here
source.sendMessage(Component.text("Stopping modpack hosting...", NamedTextColor.RED));
return Command.SINGLE_SUCCESS;
})
)
.then(BrigadierCommand.literalArgumentBuilder("restart")
.requires(source -> source.hasPermission("automodpack.host.restart"))
.executes(context -> {
CommandSource source = context.getSource();
// Add your restartModpackHost logic here
source.sendMessage(Component.text("Restarting modpack hosting...", NamedTextColor.YELLOW));
return Command.SINGLE_SUCCESS;
})
)
)
.then(BrigadierCommand.literalArgumentBuilder("config")
.requires(source -> source.hasPermission("automodpack.config"))
.then(BrigadierCommand.literalArgumentBuilder("reload")
.requires(source -> source.hasPermission("automodpack.config.reload"))
.executes(context -> {
CommandSource source = context.getSource();
// Add your reload logic here
source.sendMessage(Component.text("AutoModpack server config reloaded!", NamedTextColor.GREEN));
return Command.SINGLE_SUCCESS;
})
)
)
.build();

return new BrigadierCommand(commandNode);
}


// TODO: implement the following methods

// private static int reload(CommandSource context) {
// Util.getMainWorkerExecutor().execute(() -> {
// serverConfig = ConfigTools.load(serverConfigFile, Jsons.ServerConfigFields.class);
// send(context, "AutoModpack server config reloaded!", Formatting.GREEN, true);
// });
//
// return Command.SINGLE_SUCCESS;
// }
//
// private static int startModpackHost(CommandContext<ServerCommandSource> context) {
// Util.getMainWorkerExecutor().execute(() -> {
// if (!httpServer.shouldRunInternally()) {
// send(context, "Starting modpack hosting...", Formatting.YELLOW, true);
// httpServer.start();
// if (httpServer.shouldRunInternally()) {
// send(context, "Modpack hosting started!", Formatting.GREEN, true);
// } else {
// send(context, "Couldn't start server!", Formatting.RED, true);
// }
// } else {
// send(context, "Modpack hosting is already running!", Formatting.RED, false);
// }
// });
//
// return Command.SINGLE_SUCCESS;
// }
//
// private static int stopModpackHost(CommandContext<ServerCommandSource> context) {
// Util.getMainWorkerExecutor().execute(() -> {
// if (httpServer.shouldRunInternally()) {
// send(context, "Stopping modpack hosting...", Formatting.RED, true);
// if (httpServer.stop()) {
// send(context, "Modpack hosting stopped!", Formatting.RED, true);
// } else {
// send(context, "Couldn't stop server!", Formatting.RED, true);
// }
// } else {
// send(context, "Modpack hosting is not running!", Formatting.RED, false);
// }
// });
//
// return Command.SINGLE_SUCCESS;
// }
//
// private static int restartModpackHost(CommandContext<ServerCommandSource> context) {
// Util.getMainWorkerExecutor().execute(() -> {
// send(context, "Restarting modpack hosting...", Formatting.YELLOW, true);
// boolean needStop = httpServer.shouldRunInternally();
// boolean stopped = false;
// if (needStop) {
// stopped = httpServer.stop();
// }
//
// if (needStop && !stopped) {
// send(context, "Couldn't restart server!", Formatting.RED, true);
// } else {
// httpServer.start();
// if (httpServer.shouldRunInternally()) {
// send(context, "Modpack hosting restarted!", Formatting.GREEN, true);
// } else {
// send(context, "Couldn't restart server!", Formatting.RED, true);
// }
// }
// });
//
// return Command.SINGLE_SUCCESS;
// }
//
//
// private static int modpackHostAbout(CommandContext<ServerCommandSource> context) {
// Formatting statusColor = httpServer.shouldRunInternally() ? Formatting.GREEN : Formatting.RED;
// String status = httpServer.shouldRunInternally() ? "running" : "not running";
// send(context, "Modpack hosting status", Formatting.GREEN, status, statusColor, false);
// return Command.SINGLE_SUCCESS;
// }
//
// private static int about(CommandContext<ServerCommandSource> context) {
// send(context, "AutoModpack", Formatting.GREEN, AM_VERSION, Formatting.WHITE, false);
// send(context, "/automodpack generate", Formatting.YELLOW, false);
// send(context, "/automodpack host start/stop/restart", Formatting.YELLOW, false);
// send(context, "/automodpack config reload", Formatting.YELLOW, false);
// return Command.SINGLE_SUCCESS;
// }
//
// private static int generateModpack(CommandContext<ServerCommandSource> context) {
// Util.getMainWorkerExecutor().execute(() -> {
// if (modpack.isGenerating()) {
// send(context, "Modpack is already generating! Please wait!", Formatting.RED, false);
// return;
// }
// send(context, "Generating Modpack...", Formatting.YELLOW, true);
// long start = System.currentTimeMillis();
// if (modpack.generateNew()) {
// send(context, "Modpack generated! took " + (System.currentTimeMillis() - start) + "ms", Formatting.GREEN, true);
// } else {
// send(context, "Modpack generation failed! Check logs for more info.", Formatting.RED, true);
// }
// });
//
// return Command.SINGLE_SUCCESS;
// }
//
// private static void send(CommandContext<ServerCommandSource> context, String msg, Formatting msgColor, boolean broadcast) {
// VersionedCommandSource.sendFeedback(context,
// VersionedText.literal(msg)
// .formatted(msgColor),
// broadcast);
// }
//
// private static void send(CommandContext<ServerCommandSource> context, String msg, Formatting msgColor, String appendMsg, Formatting appendMsgColor, boolean broadcast) {
// VersionedCommandSource.sendFeedback(context,
// VersionedText.literal(msg)
// .formatted(msgColor)
// .append(VersionedText.literal(" - ")
// .formatted(Formatting.WHITE))
// .append(VersionedText.literal(appendMsg)
// .formatted(appendMsgColor)),
// broadcast);
// }
}
Loading