Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
9424d26
Combine 1.8.9 and 1.12.2 legacy versions in the same repository
BlockyTheDev Oct 16, 2025
5408510
Move assets and RadarListVisibility, RadarListEntry, GsonLocalDateTim…
BlockyTheDev Oct 16, 2025
8ba8ca4
Introduce a GeneralUtils class in the common module and move code to it
BlockyTheDev Oct 17, 2025
42b890b
Move Subcommand interface to common module
BlockyTheDev Oct 18, 2025
ef98303
Introduce VersionBridge interface with a version Getter and its versi…
BlockyTheDev Oct 18, 2025
ef995a7
Introduce a CommonHandler
BlockyTheDev Oct 18, 2025
2ef7ff2
Do not expose the VersionBridge instance
BlockyTheDev Oct 18, 2025
c9088f1
Add CommonHandler#addMessageToChat to the common module
BlockyTheDev Oct 18, 2025
2d22705
Rename Radarmessage variables and parameter names from text to messag…
BlockyTheDev Oct 18, 2025
65137bd
Use the CommonHandler#addMessageToChat
BlockyTheDev Oct 18, 2025
d6b9094
Move RadarMessage, ListsSubcommand and HelpSubcommand to common module
BlockyTheDev Oct 18, 2025
84bdd86
Move Utils#getUUID and Utils#requestUuidForName to CommonHandler
BlockyTheDev Oct 18, 2025
2752a4b
Introduce a PlayerInfo class with the uuid and player name
BlockyTheDev Oct 19, 2025
82cf3af
Move the CheckSubcommand to the common module
BlockyTheDev Oct 19, 2025
30025a7
Remove unnecessary replace
BlockyTheDev Oct 19, 2025
409ce61
Introduce a RootRadarCommand and move ListSubcommand and PlayerSubcom…
BlockyTheDev Oct 19, 2025
913029a
Move main logic of KeyInputListener to CommonHandler
BlockyTheDev Oct 19, 2025
bed8e18
Optimize the code by deduplicating some code
BlockyTheDev Oct 19, 2025
e488032
Add missing javadocs
BlockyTheDev Oct 19, 2025
e998dee
Remove todo
BlockyTheDev Oct 19, 2025
a1c125e
Add more missing javadoc
BlockyTheDev Oct 19, 2025
56d2c7b
Remove unused code
BlockyTheDev Oct 19, 2025
0f6e3de
Combine the radarlistmanager and list package
BlockyTheDev Oct 19, 2025
b99a774
Use a cache with a one-day lifetime instead of a normal HashMap and c…
BlockyTheDev Oct 19, 2025
75a1ade
Fill the cache on client to server connection
BlockyTheDev Oct 19, 2025
1e78514
Copy jars in main build/libs directory also if remapJar task is up-to…
BlockyTheDev Oct 20, 2025
3bceee9
Fix common module is not included into the output jars
BlockyTheDev Oct 20, 2025
04cf594
Fix including common module in legacy forge versions
BlockyTheDev Oct 20, 2025
a47ad3c
Set CommonHandler instance in RadarList after fromJson calls
BlockyTheDev Oct 21, 2025
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
119 changes: 67 additions & 52 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -13,78 +13,87 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import dev.architectury.pack200.java.Pack200Adapter

plugins {
id("java")
alias(libs.plugins.ggEssentialLoom)
alias(libs.plugins.spotless)
alias(libs.plugins.ggEssentialLoom) apply false
}

val modId = providers.gradleProperty("mod_id")
val versionText = providers.gradleProperty("mod_version")
val mavenGroup = providers.gradleProperty("maven_group")
val groupTextProvider = providers.gradleProperty("maven_group")
val versionTextProvider = providers.gradleProperty("mod_version")
val modIdProvider = providers.gradleProperty("mod_id")

version = versionText.get()
group = mavenGroup.get()
allprojects {
group = groupTextProvider.get()
version = versionTextProvider.get()

base {
archivesName.set(modId)
repositories {
mavenCentral()
}
}

repositories {
mavenCentral()
}
subprojects {
apply(plugin = "java")
apply(plugin = rootProject.libs.plugins.spotless.get().pluginId)

dependencies {
minecraft(libs.minecraft)
mappings(libs.mcpMappings)
forge(libs.forge)
}

loom {
forge {
pack200Provider.set(Pack200Adapter())
// accessTransformer("src/main/resources/META-INF/${modId.get()}_at.cfg")
val computedVersion = if (path.startsWith(":versions:")) {
"${versionTextProvider.get()}+$name"
} else {
versionTextProvider.get()
}
}

java {
toolchain.languageVersion.set(JavaLanguageVersion.of(8))
}
version = computedVersion

tasks {
withType<JavaCompile> {
options.encoding = Charsets.UTF_8.name()
extra["versionText"] = computedVersion
extra["modIdText"] = modIdProvider.get()

base {
archivesName.set(modIdProvider.get())
}

withType<ProcessResources> {
// https://github.com/gradle/gradle/issues/861
inputs.property("version", versionText.get())
inputs.property("mc_version", libs.versions.minecraft.get())
inputs.property("mod_id", modId.get())

filesMatching("mcmod.info") {
expand(
mapOf(
"version" to versionText.get(),
"mc_version" to libs.versions.minecraft.get(),
"mod_id" to modId.get()
)
)
}
project(":versions").childProjects.values.forEach { versionProject ->
versionProject.apply(plugin = rootProject.libs.plugins.ggEssentialLoom.get().pluginId)
}

jar {
from(layout.projectDirectory) {
include("LICENSE", "NOTICE")
java {
toolchain {
languageVersion.set(JavaLanguageVersion.of(8))
}
}
}

sourceSets {
main {
output.setResourcesDir(java.classesDirectory)
tasks {
withType<JavaCompile> {
options.encoding = Charsets.UTF_8.name()
}

withType<Jar> {
from(rootProject.layout.projectDirectory) {
include("LICENSE", "NOTICE")
}

manifest {
attributes(
"Specification-Title" to rootProject.name,
"Specification-Version" to versionTextProvider.get(),
"Implementation-Title" to rootProject.name,
"Implementation-Version" to versionTextProvider.get()
)
}

plugins.withId(rootProject.libs.plugins.ggEssentialLoom.get().pluginId) {
val remapJarTask = named("remapJar")

register<Copy>("copyRemappedJars") {
dependsOn(remapJarTask)
from(remapJarTask.map { it.outputs.files })
into(rootProject.layout.buildDirectory.dir("libs"))
}

named("build") {
finalizedBy("copyRemappedJars")
}
}
}
}
}

Expand All @@ -103,3 +112,9 @@ spotless {
trimTrailingWhitespace()
}
}

tasks {
named<Jar>("jar").configure {
enabled = false
}
}
13 changes: 13 additions & 0 deletions common/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import org.gradle.kotlin.dsl.libs

base {
archivesName.set("common")
}

@Suppress("VulnerableLibrariesLocal") // some libs need to stay at the game versions
dependencies {
compileOnly(rootProject.libs.jetbrainsJavaAnnotations)
compileOnly(rootProject.libs.gson)
compileOnly(rootProject.libs.log4j)
compileOnly(rootProject.libs.guava)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
/*
* Copyright 2024 - present CommunityRadarGG <https://community-radar.de/>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.github.communityradargg.forgemod.command;

import io.github.communityradargg.forgemod.list.RadarListEntry;
import io.github.communityradargg.forgemod.util.CommonHandler;
import io.github.communityradargg.forgemod.util.Messages;
import io.github.communityradargg.forgemod.util.PlayerInfo;
import io.github.communityradargg.forgemod.util.RadarMessage;
import java.util.Optional;
import org.jetbrains.annotations.NotNull;

/**
* Holds the logic of the check subcommand.
*/
public class CheckSubcommand implements Subcommand {
private final CommonHandler commonHandler;
private final String[] args;

/**
* Constructs a {@link CheckSubcommand}.
*
* @param commonHandler The common handler.
* @param args The args.
*/
public CheckSubcommand(final @NotNull CommonHandler commonHandler, final @NotNull String[] args) {
this.commonHandler = commonHandler;
this.args = args;
}

@Override
public void run() {
if (args.length != 2) {
// missing arguments
commonHandler.addMessageToChat(new RadarMessage.RadarMessageBuilder(Messages.MISSING_ARGS)
.build().getMessage());
return;
}

if (args[1].equalsIgnoreCase("*")) {
// check all argument
handleCheckAllSubcommand();
return;
}
handleCheckPlayerSubcommand(args);
}

/**
* Handles the check - player subcommand.
*
* @param args The arguments passed to the main command.
*/
private void handleCheckPlayerSubcommand(final @NotNull String[] args) {
commonHandler.addMessageToChat(new RadarMessage.RadarMessageBuilder(Messages.INPUT_PROCESSING)
.build().getMessage());
commonHandler.getUuidByPlayerName(commonHandler, args[1]).thenAccept(checkPlayerOptional -> {
if (!checkPlayerOptional.isPresent()) {
// player uuid could not be fetched
commonHandler.addMessageToChat(new RadarMessage.RadarMessageBuilder(Messages.Check.FAILED)
.build().getMessage());
return;
}

final Optional<RadarListEntry> entryOptional = commonHandler.getListManager().getRadarListEntry(checkPlayerOptional.get());
if (!entryOptional.isPresent()) {
// player uuid is on no list
commonHandler.addMessageToChat(new RadarMessage.RadarMessageBuilder(Messages.Check.FAILED)
.build().getMessage());
return;
}

final RadarListEntry entry = entryOptional.get();
commonHandler.addMessageToChat(new RadarMessage.RadarMessageBuilder(Messages.Check.FOUND + "\n" + Messages.Check.CHECK_ENTRY)
.replaceWithColorCodes("{prefix}", commonHandler.getListManager().getPrefix(entry.uuid()))
.replace("{name}", entry.name())
.replace("{cause}", entry.cause())
.replace("{entryCreationDate}", commonHandler.formatDateTime(entry.entryCreationDate()))
.replace("{entryUpdateDate}", commonHandler.formatDateTime(entry.entryUpdateDate()))
.build().getMessage());
});
}

/**
* Handles the check - all subcommand.
*/
private void handleCheckAllSubcommand() {
boolean anyPlayerFound = false;
for (final PlayerInfo playerInfo : commonHandler.getWorldPlayers()) {
if (playerInfo.getUuid() == null) {
continue;
}

final Optional<RadarListEntry> listEntryOptional = commonHandler.getListManager()
.getRadarListEntry(playerInfo.getUuid());
if (!listEntryOptional.isPresent()) {
// player uuid is on no list
continue;
}

if (!anyPlayerFound) {
commonHandler.addMessageToChat(new RadarMessage.RadarMessageBuilder(Messages.Check.EVERYONE)
.build().getMessage());
anyPlayerFound = true;
}

final RadarListEntry entry = listEntryOptional.get();
commonHandler.addMessageToChat(new RadarMessage.RadarMessageBuilder(Messages.Check.CHECK_ENTRY)
.replaceWithColorCodes("{prefix}", commonHandler.getListManager().getPrefix(entry.uuid()))
.replace("{name}", entry.name())
.replace("{cause}", entry.cause())
.replace("{entryCreationDate}", commonHandler.formatDateTime(entry.entryCreationDate()))
.replace("{entryUpdateDate}", commonHandler.formatDateTime(entry.entryUpdateDate()))
.build().getMessage());
}

if (!anyPlayerFound) {
commonHandler.addMessageToChat(new RadarMessage.RadarMessageBuilder(Messages.Check.NOT_FOUND)
.build().getMessage());
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,35 +15,31 @@
*/
package io.github.communityradargg.forgemod.command;

import io.github.communityradargg.forgemod.CommunityRadarMod;
import io.github.communityradargg.forgemod.util.CommonHandler;
import io.github.communityradargg.forgemod.util.Messages;
import io.github.communityradargg.forgemod.util.RadarMessage;
import net.minecraft.entity.player.EntityPlayer;
import org.jetbrains.annotations.NotNull;

/**
* Holds the logic of the help subcommand.
*/
public class HelpSubcommand implements Subcommand {
private final CommunityRadarMod communityRadarMod;
private final EntityPlayer player;
private final CommonHandler commonHandler;

/**
* Constructs a {@link HelpSubcommand}.
*
* @param communityRadarMod The mod main class instance.
* @param player The player.
* @param commonHandler The common handler
*/
public HelpSubcommand(final @NotNull CommunityRadarMod communityRadarMod, final @NotNull EntityPlayer player) {
this.communityRadarMod = communityRadarMod;
this.player = player;
public HelpSubcommand(final @NotNull CommonHandler commonHandler) {
this.commonHandler = commonHandler;
}

@Override
public void run() {
player.addChatComponentMessage(new RadarMessage.RadarMessageBuilder(Messages.HELP)
.replace("{code_version}", communityRadarMod.getVersion())
commonHandler.addMessageToChat(new RadarMessage.RadarMessageBuilder(Messages.HELP)
.replace("{code_version}", commonHandler.getVersion())
.excludePrefix()
.build().toChatComponentText());
.build().getMessage());
}
}
Loading