This repository has been archived by the owner on Mar 17, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
A "sentinel" to be used in conjunction with RemoteSync.
This mod exists so that we can provide a better user experience.
- Loading branch information
Showing
8 changed files
with
217 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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' | ||
} | ||
} | ||
} | ||
} | ||
} |
31 changes: 31 additions & 0 deletions
31
Sentinel/src/main/java/org/teacon/sync/sentinel/RemoteSyncSentinel.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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")); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" |
3 changes: 3 additions & 0 deletions
3
Sentinel/src/main/resources/assets/remote_sync_sentinel/lang/en_us.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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." | ||
} |
3 changes: 3 additions & 0 deletions
3
Sentinel/src/main/resources/assets/remote_sync_sentinel/lang/zh_cn.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"remote_sync.warn.incomplete": "RemoteSync 在加载最新 Mod 时遇到错误。当前 Mod 列表因此不完整,加入服务器时将会遇到错误。请重启游戏。" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{"pack":{"pack_format":6,"description":""}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
rootProject.name = 'RemoteSync' | ||
|
||
include ':Sentinel' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters