Skip to content
Merged
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
13 changes: 8 additions & 5 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# Disable autocrlf on generated files, they always generate with LF
# Add any extra files or paths here to make git stop saying they
# are changed when only line endings change.
src/generated/**/.cache/cache text eol=lf
src/generated/**/*.json text eol=lf
#
# https://help.github.com/articles/dealing-with-line-endings/
#
# Linux start script should use lf
/gradlew text eol=lf

# These are Windows script files and should use crlf
*.bat text eol=crlf
48 changes: 31 additions & 17 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,26 +1,40 @@
# gradle

.gradle/
build/
out/
classes/

# eclipse
bin

*.launch
.settings
.metadata
.classpath
.project

# idea
out

.idea/
*.iml
*.ipr
*.iws
*.iml
.idea

# gradle
build
.gradle
# vscode

.settings/
.vscode/
bin/
.classpath
.project

# macos

*.DS_Store

# fabric

run/

# other
eclipse
run
runs
run-data
# java

repo
hs_err_*.log
replay_*.log
*.hprof
*.jfr
89 changes: 25 additions & 64 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,31 +1,25 @@
plugins {
id 'java-library'
id 'maven-publish'
id 'net.neoforged.moddev' version '2.0.78'
id 'idea'
}

tasks.named('wrapper', Wrapper).configure {
// Define wrapper values here so as to not have to always do so when updating gradlew.properties.
// Switching this to Wrapper.DistributionType.ALL will download the full gradle sources that comes with
// documentation attached on cursor hover of gradle classes and methods. However, this comes with increased
// file size for Gradle. If you do switch this to ALL, run the Gradle wrapper task twice afterwards.
// (Verify by checking gradle/wrapper/gradle-wrapper.properties to see if distributionUrl now points to `-all`)
distributionType = Wrapper.DistributionType.BIN
id 'net.neoforged.moddev' version '2.0.107'
}

version = mod_version
group = mod_group_id

repositories {
mavenLocal()

maven {
url "https://cursemaven.com"
}
}

base {
archivesName = mod_id
}

// Mojang ships Java 21 to end users starting in 1.20.5, so mods should target Java 21.
java.toolchain.languageVersion = JavaLanguageVersion.of(21)

neoForge {
Expand All @@ -38,7 +32,7 @@ neoForge {
}

// This line is optional. Access Transformers are automatically detected
// accessTransformers = project.files('src/main/resources/META-INF/accesstransformer.cfg')
// accessTransformers.add('src/main/resources/META-INF/accesstransformer.cfg')

// Default run configurations.
// These can be tweaked, removed, or duplicated as needed.
Expand Down Expand Up @@ -93,42 +87,24 @@ neoForge {
mods {
// define mod <-> source bindings
// these are used to tell the game which sources are for which mod
// multi mod projects should define one per mod
// mostly optional in a single mod project
// but multi mod projects should define one per mod
"${mod_id}" {
sourceSet(sourceSets.main)
}
}

unitTest {
// Enable JUnit support in the moddev plugin
enable()
// Configure which mod is being tested.
// This allows NeoForge to load the test/ classes and resources as belonging to the mod.
testedMod = mods."${mod_id}" // <mod name> must match the name in the mods { } block.
// Configure which mods are loaded in the test environment, if the default (all declared mods) is not appropriate.
// This must contain testedMod, and can include other mods as well.
// loadedMods = [mods.<mod name >, mods.<mod name 2>]
}
}

// Include resources generated by data generators.
sourceSets.main.resources { srcDir 'src/generated/resources' }

// Sets up a dependency configuration called 'localRuntime'.
// This configuration should be used instead of 'runtimeOnly' to declare
// a dependency that will be present for runtime testing but that is
// "optional", meaning it will not be pulled by dependents of this mod.
configurations {
runtimeClasspath.extendsFrom localRuntime
}

dependencies {
// Example optional mod dependency with JEI
// Example mod dependency with JEI
// The JEI API is declared for compile time use, while the full JEI artifact is used at runtime
// compileOnly "mezz.jei:jei-${mc_version}-common-api:${jei_version}"
// compileOnly "mezz.jei:jei-${mc_version}-neoforge-api:${jei_version}"
// We add the full version to localRuntime, not runtimeOnly, so that we do not publish a dependency on it
// localRuntime "mezz.jei:jei-${mc_version}-neoforge:${jei_version}"
// compileOnly "mezz.jei:jei-${mc_version}-forge-api:${jei_version}"
// runtimeOnly "mezz.jei:jei-${mc_version}-forge:${jei_version}"

// Example mod dependency using a mod jar from ./libs with a flat dir repository
// This maps to ./libs/coolmod-${mc_version}-${coolmod_version}.jar
Expand All @@ -144,34 +120,32 @@ dependencies {
// For more info:
// http://www.gradle.org/docs/current/userguide/artifact_dependencies_tutorial.html
// http://www.gradle.org/docs/current/userguide/dependency_management.html
implementation "curse.maven:simple-discord-link-bot-forge-fabric-spigot-541320:6736713"
implementation "curse.maven:craterlib-867099:6534798"

testImplementation 'org.junit.jupiter:junit-jupiter:5.7.1'
testRuntimeOnly 'org.junit.platform:junit-platform-launcher'

implementation 'com.fasterxml.jackson.core:jackson-databind:2.18.3'
}

// This block of code expands all declared replace properties in the specified resource targets.
// A missing property will result in an error. Properties are expanded using ${} Groovy notation.
var generateModMetadata = tasks.register("generateModMetadata", ProcessResources) {
var replaceProperties = [
minecraft_version : minecraft_version,
minecraft_version_range: minecraft_version_range,
neo_version : neo_version,
neo_version_range : neo_version_range,
loader_version_range : loader_version_range,
mod_id : mod_id,
mod_name : mod_name,
mod_license : mod_license,
mod_version : mod_version,
mod_authors : mod_authors,
mod_description : mod_description
]
var replaceProperties = [minecraft_version : minecraft_version,
minecraft_version_range: minecraft_version_range,
neo_version : neo_version,
neo_version_range : neo_version_range,
loader_version_range : loader_version_range,
mod_id : mod_id,
mod_name : mod_name,
mod_license : mod_license,
mod_version : mod_version,
mod_authors : mod_authors,
mod_description : mod_description]
inputs.properties replaceProperties
expand replaceProperties
from "src/main/templates"
into "build/generated/sources/modMetadata"
}

// Include the output of "generateModMetadata" as an input directory for the build
// this works with both building through Gradle and the IDE.
sourceSets.main.resources.srcDir generateModMetadata
Expand All @@ -192,23 +166,10 @@ publishing {
}
}

tasks.withType(JavaCompile).configureEach {
options.encoding = 'UTF-8' // Use the UTF-8 charset for Java compilation
}

// IDEA no longer automatically downloads sources/javadoc jars for dependencies, so we need to explicitly enable the behavior.
idea {
module {
downloadSources = true
downloadJavadoc = true
}
}

test {
useJUnitPlatform()
testLogging {
events "passed", "skipped", "failed"
exceptionFormat "full"
showStandardStreams true
}
}
27 changes: 11 additions & 16 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,31 +1,26 @@
# Sets default memory used for gradle commands. Can be overridden by user or command line properties.
org.gradle.jvmargs=-Xmx1G
org.gradle.jvmargs=-Xmx2G
org.gradle.daemon=true
org.gradle.parallel=true
org.gradle.caching=true
org.gradle.configuration-cache=true

#read more on this at https://github.com/neoforged/ModDevGradle?tab=readme-ov-file#better-minecraft-parameter-names--javadoc-parchment
# you can also find the latest versions at: https://parchmentmc.org/docs/getting-started
parchment_minecraft_version=1.21.1
parchment_mappings_version=2024.11.17
# Environment Properties
## Environment Properties
# You can find the latest versions here: https://projects.neoforged.net/neoforged/neoforge
# The Minecraft version must agree with the Neo version to get a valid artifact
minecraft_version=1.21.1
# The Minecraft version range can use any release version of Minecraft as bounds.
# Snapshots, pre-releases, and release candidates are not guaranteed to sort properly
# as they do not follow standard versioning conventions.
minecraft_version_range=[1.21.1]
minecraft_version_range=[1.21.1,1.22)
# The Neo version must agree with the Minecraft version to get a valid artifact
neo_version=21.1.132
neo_version=21.1.200
# The Neo version range can use any version of Neo as bounds
neo_version_range=[21.1.132,)
neo_version_range=[21,)
# The loader version range can only use the major version of FML as bounds
loader_version_range=[1,)

loader_version_range=[4,)
parchment_minecraft_version=1.21.8
parchment_mappings_version=2025.07.20
## Mod Properties

# The unique mod identifier for the mod. Must be lowercase in English locale. Must fit the regex [a-z][a-z0-9_]{1,63}
# Must match the String constant located in the main mod class annotated with @Mod.
mod_id=tsukichat
Expand All @@ -34,12 +29,12 @@ mod_name=Tsuki Chat
# The license of the mod. Review your options at https://choosealicense.com/. All Rights Reserved is the default.
mod_license=MIT
# The mod version. See https://semver.org/
mod_version=2.0.0
mod_version=1.4.0-alpha.5
# The group ID for the mod. It is only important when publishing as an artifact to a Maven repository.
# This should match the base package used for the mod sources.
# See https://maven.apache.org/guides/mini/guide-naming-conventions.html
mod_group_id=io.github.meatwo310.tsukichat
mod_group_id=io.github.meatwo310
# The authors of the mod. This is a simple text string that is used for display purposes in the mod list.
mod_authors=Meatwo310
# The description of the mod. This is a simple multiline text string that is used for display purposes in the mod list.
mod_description=Converts Romaji to Japanese in chat. /tsukichat to customize features. Highly configurable.
mod_description=Converts Romaji to Japanese in chat.
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.12-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.8-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
Expand Down
5 changes: 1 addition & 4 deletions gradlew

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 0 additions & 2 deletions gradlew.bat

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@ pluginManagement {
}

plugins {
id 'org.gradle.toolchains.foojay-resolver-convention' version '0.9.0'
id 'org.gradle.toolchains.foojay-resolver-convention' version '0.8.0'
}
44 changes: 39 additions & 5 deletions src/main/java/io/github/meatwo310/tsukichat/TsukiChat.java
Original file line number Diff line number Diff line change
@@ -1,18 +1,52 @@
package io.github.meatwo310.tsukichat;

import com.mojang.logging.LogUtils;
import io.github.meatwo310.tsukichat.config.CommonConfig;
import net.neoforged.fml.ModContainer;
import io.github.meatwo310.tsukichat.compat.SDLinkServerChatEvent;
import io.github.meatwo310.tsukichat.compat.mohist.MohistHelper;
import io.github.meatwo310.tsukichat.config.CommonConfigs;
import net.neoforged.api.distmarker.Dist;
import net.neoforged.bus.api.IEventBus;
import net.neoforged.fml.ModList;
import net.neoforged.fml.ModLoadingContext;
import net.neoforged.fml.common.Mod;
import net.neoforged.fml.config.ModConfig;
import net.neoforged.fml.event.lifecycle.FMLCommonSetupEvent;
import net.neoforged.fml.loading.FMLEnvironment;
import net.neoforged.neoforge.common.NeoForge;
import org.slf4j.Logger;

// The value here should match an entry in the META-INF/mods.toml file
@Mod(TsukiChat.MODID)
public class TsukiChat {
public static final String MODID = "tsukichat";
private static final Logger LOGGER = LogUtils.getLogger();
public static final Logger LOGGER = LogUtils.getLogger();

public TsukiChat(ModContainer modContainer) {
modContainer.registerConfig(ModConfig.Type.COMMON, CommonConfig.SPEC);
public TsukiChat(IEventBus modEventBus) {
modEventBus.addListener(this::commonSetup);
ModLoadingContext.get().getActiveContainer().registerConfig(ModConfig.Type.COMMON, CommonConfigs.COMMON_SPEC, "tsukichat-common.toml");

// sdlink compat
if (FMLEnvironment.dist == Dist.DEDICATED_SERVER) {
if (ModList.get().isLoaded("sdlink")) {
LOGGER.info("Simple Discord Link is present!");
LOGGER.info("Replacing the default chat event handler with Forge's event handler 😡");
NeoForge.EVENT_BUS.register(new SDLinkServerChatEvent());
}
}

// Mohist Compat
if (FMLEnvironment.dist == Dist.DEDICATED_SERVER) {
if (!MohistHelper.isMohistLoaded()) return;
if (CommonConfigs.mohistCompat.get()) {
LOGGER.warn("Mohist is present! Oh no!");
LOGGER.warn("We will check if the compat plugin is loaded...");
} else {
LOGGER.warn("Mohist is present!");
LOGGER.warn("Although the compat feature is disabled in the config so we will not do anything.");
}
}
}

private void commonSetup(final FMLCommonSetupEvent event) {
}
}
Loading