Skip to content
This repository has been archived by the owner on Mar 17, 2023. It is now read-only.

Commit

Permalink
A "sentinel" to be used in conjunction with RemoteSync.
Browse files Browse the repository at this point in the history
This mod exists so that we can provide a better user experience.
  • Loading branch information
3TUSK committed Jan 15, 2022
1 parent dbe4303 commit 185f7d5
Show file tree
Hide file tree
Showing 8 changed files with 217 additions and 0 deletions.
156 changes: 156 additions & 0 deletions Sentinel/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,156 @@
import java.time.Instant
import java.time.format.DateTimeFormatter
import java.time.temporal.ChronoUnit

buildscript {
repositories {
maven { url = 'https://maven.minecraftforge.net' }
mavenCentral()
}
dependencies {
classpath group: 'net.minecraftforge.gradle', name: 'ForgeGradle', version: '5.1.+', changing: true
}
}
apply plugin: 'net.minecraftforge.gradle'
// Only edit below this line, the above code adds and enables the necessary things for Forge to be setup.
apply plugin: 'eclipse'
apply plugin: 'maven-publish'

version = '1.0'
group = 'org.teacon.sync.sentinel' // http://maven.apache.org/guides/mini/guide-naming-conventions.html
archivesBaseName = 'RemoteSyncSentinel'

// We need to target the lowest version possible to make sure this still runs on pre-1.17+ (Java 16+)
// TODO We might want to do a multi-release or something in the future.
java.toolchain.languageVersion = JavaLanguageVersion.of(8)

// Print out current JVM info for debug purpose
println('Java: ' + System.getProperty('java.version') + ' JVM: ' + System.getProperty('java.vm.version') + '(' + System.getProperty('java.vendor') + ') Arch: ' + System.getProperty('os.arch'))

minecraft {
// The mappings can be changed at any time and must be in the following format.
// Channel: Version:
// snapshot YYYYMMDD Snapshot are built nightly.
// stable # Stables are built at the discretion of the MCP team.
// official MCVersion Official field/method names from Mojang mapping files
//
// You must be aware of the Mojang license when using the 'official' mappings.
// See more information here: https://github.com/MinecraftForge/MCPConfig/blob/master/Mojang.md
//
// Use non-default mappings at your own risk. They may not always work.
// Simply re-run your setup task after changing the mappings to update your workspace.
mappings channel: 'official', version: '1.16.5'

runs {
client {
workingDirectory project.file('run_client')

// Recommended logging data for a userdev environment
// The markers can be added/remove as needed separated by commas.
// "SCAN": For mods scan.
// "REGISTRIES": For firing of registry events.
// "REGISTRYDUMP": For getting the contents of all registries.
//property 'forge.logging.markers', 'REGISTRIES'

property 'forge.logging.console.level', 'info'
property 'fml.earlyprogresswindow', 'false'
property 'mixin.env.remapRefMap', 'true'
property 'mixin.env.refMapRemappingFile', "${projectDir}/build/createSrgToMcp/output.srg"

mods {
remote_sync_sentinel {
source sourceSets.main
}
}
}

server {
workingDirectory project.file('run_server')

// property 'forge.logging.markers', 'REGISTRIES'

property 'forge.logging.console.level', 'info'

mods {
remote_sync_sentinel {
source sourceSets.main
}
}
}

// There is no data to generate.
}
}

repositories {
// Put repositories for dependencies here
// ForgeGradle automatically adds the Forge maven and Maven Central for you

// If you have mod jar dependencies in ./libs, you can declare them as a repository like so:
// flatDir {
// dir 'libs'
// }
}

dependencies {
minecraft 'net.minecraftforge:forge:1.16.5-36.2.23'
}

// Example for how to get properties into the manifest for reading at runtime.
jar {
manifest {
attributes([
"Specification-Title": "ModSyncSentinel",
"Specification-Vendor": "3TUSK",
"Specification-Version": "1.0",
"Implementation-Title": "ModSyncSentinel",
"Implementation-Version": archiveVersion.get(),
"Implementation-Vendor": "3TUSK",
"Implementation-Timestamp": DateTimeFormatter.ISO_INSTANT.format(Instant.now().truncatedTo(ChronoUnit.SECONDS))
], 'org.teacon.sync.sentinel')
}
}

// Example configuration to allow publishing using the maven-publish plugin
// This is the preferred method to reobfuscate your jar file
jar.finalizedBy('reobfJar')
// However if you are in a multi-project build, dev time needs unobfed jar files, so you can delay the obfuscation until publishing by doing
// publish.dependsOn('reobfJar')

publishing {
publications {
release(MavenPublication) {
groupId = "org.teacon"
artifactId = "RemoteSync-Sentinel-FML"

artifact jar

pom {
name = 'RemoteSync Sentinel for FML'
description = 'Companion mod for RemonteSync'
url = 'https://github.com/teaconmc/RemoteSync'
licenses {
license {
name = 'LGPL-2.1-or-later'
url = 'https://github.com/teaconmc/RemoteSync/tree/bleeding/COPYING.LGPL'
}
}
developers {
developer {
id = '3TUSK'
name = '3TUSK'
}
}
issueManagement {
system = 'GitHub Issues'
url = 'https://github.com/teaconmc/RemoteSync/issues'
}
scm {
url = 'https://github.com/teaconmc/RemoteSync'
connection = 'scm:git:git://github.com/teaconmc/RemoteSync.git'
developerConnection = 'scm:git:[email protected]:teaconmc/RemoteSync.git'
}
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package org.teacon.sync.sentinel;

import net.minecraftforge.eventbus.api.EventPriority;
import net.minecraftforge.fml.ModContainer;
import net.minecraftforge.fml.ModList;
import net.minecraftforge.fml.ModLoader;
import net.minecraftforge.fml.ModLoadingStage;
import net.minecraftforge.fml.ModLoadingWarning;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent;
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
import net.minecraftforge.forgespi.language.IModInfo;

@Mod("remote_sync_sentinel")
public class RemoteSyncSentinel {

public RemoteSyncSentinel() {
FMLJavaModLoadingContext.get()
.getModEventBus()
.addListener(EventPriority.NORMAL, false, FMLCommonSetupEvent.class, RemoteSyncSentinel::setup);
}

public static void setup(FMLCommonSetupEvent event) {
if (Boolean.getBoolean("org.teacon.sync.failed")) {
IModInfo modInfo = ModList.get().getModContainerById("remote_sync_sentinel")
.map(ModContainer::getModInfo)
.orElseThrow(() -> new IllegalStateException("ModInfo absent while mod itself is present"));
ModLoader.get().addWarning(new ModLoadingWarning(modInfo, ModLoadingStage.COMMON_SETUP, "remote_sync.warn.incomplete"));
}
}
}
19 changes: 19 additions & 0 deletions Sentinel/src/main/resources/META-INF/mods.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
modLoader="javafml"
loaderVersion="[36,)"
issueTrackerURL="https://github.com/teaconmc/RemoteSync"
license="LGPL-2.1-or-later"

[[mods]]
modId="remote_sync_sentinel"
displayName="RemoteSync Sentinel"
version="${file.jarVersion}"
authors="TeaConMC members"
credits="cpw, for original idea"
description="Companion mod used in conjunction with RemoteSync, for friendlier UX."

[[dependencies.remote_sync_sentinel]]
modId="forge"
mandatory=true
versionRange="[36.0.0,)"
ordering="AFTER"
side="BOTH"
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"remote_sync.warn.incomplete": "RemoteSync has encountered error while fetching latest mods. The mod list is thus incomplete; joining server will cause error. Please restart the game."
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"remote_sync.warn.incomplete": "RemoteSync 在加载最新 Mod 时遇到错误。当前 Mod 列表因此不完整,加入服务器时将会遇到错误。请重启游戏。"
}
1 change: 1 addition & 0 deletions Sentinel/src/main/resources/pack.mcmeta
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"pack":{"pack_format":6,"description":""}}
3 changes: 3 additions & 0 deletions settings.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
rootProject.name = 'RemoteSync'

include ':Sentinel'
1 change: 1 addition & 0 deletions src/main/java/org/teacon/sync/SyncedModLocator.java
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,7 @@ public List<IModFile> scanMods() {
} catch (Exception e) {
LOGGER.error("Mod downloading worker encountered error and cannot continue. " +
"No mod will be loaded from the remote-synced locator. ", e);
System.setProperty("org.teacon.sync.failed", "true");
return Collections.emptyList();
}
}
Expand Down

0 comments on commit 185f7d5

Please sign in to comment.