From 1edce7b6f47a59fde23cce9216c9ce90d06b3b83 Mon Sep 17 00:00:00 2001 From: cons-tan-tan <132136681+cons-tan-tan@users.noreply.github.com> Date: Mon, 25 Mar 2024 19:39:24 +0900 Subject: [PATCH 1/6] chore: update build script --- settings.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/settings.gradle b/settings.gradle index 1e614a5..ffc5108 100644 --- a/settings.gradle +++ b/settings.gradle @@ -17,5 +17,5 @@ pluginManagement { } plugins { - id 'com.gtnewhorizons.gtnhsettingsconvention' version '1.0.15' + id 'com.gtnewhorizons.gtnhsettingsconvention' version '1.0.19' } From ced6e837eaed36a86f55f718cc0b010e57f39e0b Mon Sep 17 00:00:00 2001 From: cons-tan-tan <132136681+cons-tan-tan@users.noreply.github.com> Date: Mon, 25 Mar 2024 20:20:48 +0900 Subject: [PATCH 2/6] feat: add quest-complete log --- .../java/bqlogging/BetterQuestLogging.java | 78 +++++++++++++------ 1 file changed, 55 insertions(+), 23 deletions(-) diff --git a/src/main/java/bqlogging/BetterQuestLogging.java b/src/main/java/bqlogging/BetterQuestLogging.java index 25a62e8..e685d73 100644 --- a/src/main/java/bqlogging/BetterQuestLogging.java +++ b/src/main/java/bqlogging/BetterQuestLogging.java @@ -1,50 +1,82 @@ package bqlogging; +import java.util.Set; +import java.util.UUID; + +import net.minecraftforge.common.MinecraftForge; + import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; +import betterquesting.api.api.QuestingAPI; +import betterquesting.api.events.QuestEvent; +import betterquesting.api2.utils.QuestTranslation; +import betterquesting.questing.QuestDatabase; +import cpw.mods.fml.common.Loader; import cpw.mods.fml.common.Mod; -import cpw.mods.fml.common.SidedProxy; -import cpw.mods.fml.common.event.FMLInitializationEvent; -import cpw.mods.fml.common.event.FMLPostInitializationEvent; import cpw.mods.fml.common.event.FMLPreInitializationEvent; -import cpw.mods.fml.common.event.FMLServerStartingEvent; +import cpw.mods.fml.common.eventhandler.SubscribeEvent; @Mod( modid = BetterQuestLogging.MODID, version = Tags.VERSION, name = "Better Quest Logging", - acceptedMinecraftVersions = "[1.7.10]") + acceptedMinecraftVersions = "[1.7.10]", + dependencies = "required-after:betterquesting") public class BetterQuestLogging { public static final String MODID = "bqlogging"; public static final Logger LOG = LogManager.getLogger(MODID); - @SidedProxy(clientSide = MODID + ".ClientProxy", serverSide = MODID + ".CommonProxy") - public static CommonProxy proxy; + // @SidedProxy(clientSide = MODID + ".ClientProxy", serverSide = MODID + ".CommonProxy") + // public static CommonProxy proxy; @Mod.EventHandler // preInit "Run before anything else. Read your config, create blocks, items, etc, and register them with the // GameRegistry." (Remove if not needed) public void preInit(FMLPreInitializationEvent event) { - proxy.preInit(event); - } - - @Mod.EventHandler - // load "Do your mod setup. Build whatever data structures you care about. Register recipes." (Remove if not needed) - public void init(FMLInitializationEvent event) { - proxy.init(event); + // proxy.preInit(event); + if (Loader.isModLoaded("betterquesting")) { + LOG.info("BetterQuesting is already loaded"); + MinecraftForge.EVENT_BUS.register(this); + } else { + LOG.error("BetterQuesting is not loaded"); + } } - @Mod.EventHandler - // postInit "Handle interaction with other mods, complete your setup based on this." (Remove if not needed) - public void postInit(FMLPostInitializationEvent event) { - proxy.postInit(event); + @SubscribeEvent + public void onQuestEvent(QuestEvent event) { + Set questIds = event.getQuestIDs(); + if (questIds.isEmpty()) { + return; + } + String playerName = QuestingAPI.getPlayer(event.getPlayerID()) + .getDisplayName(); + questIds.forEach(uuid -> { + LOG.info( + String.format( + "%s completed the quest: %s", + playerName, + QuestTranslation.translateQuestName(uuid, QuestDatabase.INSTANCE.get(uuid)))); + }); } - @Mod.EventHandler - // register server commands in this event handler (Remove if not needed) - public void serverStarting(FMLServerStartingEvent event) { - proxy.serverStarting(event); - } + // @Mod.EventHandler + // // load "Do your mod setup. Build whatever data structures you care about. Register recipes." (Remove if not + // needed) + // public void init(FMLInitializationEvent event) { + // proxy.init(event); + // } + // + // @Mod.EventHandler + // // postInit "Handle interaction with other mods, complete your setup based on this." (Remove if not needed) + // public void postInit(FMLPostInitializationEvent event) { + // proxy.postInit(event); + // } + // + // @Mod.EventHandler + // // register server commands in this event handler (Remove if not needed) + // public void serverStarting(FMLServerStartingEvent event) { + // proxy.serverStarting(event); + // } } From bf7154fb8ca4e3a9ec4e337065cfa68ca336fad6 Mon Sep 17 00:00:00 2001 From: cons-tan-tan <132136681+cons-tan-tan@users.noreply.github.com> Date: Tue, 26 Mar 2024 01:20:37 +0900 Subject: [PATCH 3/6] docs: add info --- LICENSE | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/LICENSE b/LICENSE index 242da62..491007a 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ MIT License -Copyright (c) +Copyright (c) 2024 constantan Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal From 972e30bdb9f266a8883b7a335e9a624b6b3c70f3 Mon Sep 17 00:00:00 2001 From: cons-tan-tan <132136681+cons-tan-tan@users.noreply.github.com> Date: Tue, 26 Mar 2024 01:26:33 +0900 Subject: [PATCH 4/6] fix: change mod name --- gradle.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle.properties b/gradle.properties index 70e9050..98f9b9e 100644 --- a/gradle.properties +++ b/gradle.properties @@ -3,7 +3,7 @@ gtnh.settings.blowdryerTag = 0.2.2 # Human-readable mod name, available for mcmod.info population. -modName = Better Quest Logging +modName = BetterQuestLogging # Case-sensitive identifier string, available for mcmod.info population and used for automatic mixin JSON generation. # Conventionally lowercase. From 618a73d495c26f67de05652f7e39a1af0f189a7d Mon Sep 17 00:00:00 2001 From: cons-tan-tan <132136681+cons-tan-tan@users.noreply.github.com> Date: Tue, 26 Mar 2024 01:37:29 +0900 Subject: [PATCH 5/6] fix: add mod info --- src/main/resources/mcmod.info | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/main/resources/mcmod.info b/src/main/resources/mcmod.info index 6275554..26c5498 100644 --- a/src/main/resources/mcmod.info +++ b/src/main/resources/mcmod.info @@ -3,19 +3,19 @@ "modList": [{ "modid": "${modId}", "name": "${modName}", - "description": "An example mod for Minecraft 1.7.10 with Forge focused on a stable setup.", + "description": "This mod outputs the log when a quest is completed.", "version": "${modVersion}", "mcversion": "${minecraftVersion}", - "url": "https://github.com/SinTh0r4s/MyMod", + "url": "https://github.com/cons-tan-tan/BetterQuestLogging", "updateUrl": "", - "authorList": ["SinTho0r4s"], + "authorList": ["constantan"], "credits": "", "logoFile": "", "screenshots": [], "parent": "", - "requiredMods": [], + "requiredMods": ["betterquesting"], "dependencies": [], "dependants": [], - "useDependencyInformation": false + "useDependencyInformation": true }] } From 40bf6ef32dbff32da6c0316803434c968fea055c Mon Sep 17 00:00:00 2001 From: cons-tan-tan <132136681+cons-tan-tan@users.noreply.github.com> Date: Tue, 26 Mar 2024 01:38:53 +0900 Subject: [PATCH 6/6] fix: enhance log system --- .../java/bqlogging/BetterQuestLogging.java | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/src/main/java/bqlogging/BetterQuestLogging.java b/src/main/java/bqlogging/BetterQuestLogging.java index e685d73..d3ee217 100644 --- a/src/main/java/bqlogging/BetterQuestLogging.java +++ b/src/main/java/bqlogging/BetterQuestLogging.java @@ -10,6 +10,8 @@ import betterquesting.api.api.QuestingAPI; import betterquesting.api.events.QuestEvent; +import betterquesting.api.properties.NativeProps; +import betterquesting.api.questing.IQuest; import betterquesting.api2.utils.QuestTranslation; import betterquesting.questing.QuestDatabase; import cpw.mods.fml.common.Loader; @@ -20,7 +22,7 @@ @Mod( modid = BetterQuestLogging.MODID, version = Tags.VERSION, - name = "Better Quest Logging", + name = "BetterQuestLogging", acceptedMinecraftVersions = "[1.7.10]", dependencies = "required-after:betterquesting") public class BetterQuestLogging { @@ -46,18 +48,29 @@ public void preInit(FMLPreInitializationEvent event) { @SubscribeEvent public void onQuestEvent(QuestEvent event) { + if (event.getType() != QuestEvent.Type.COMPLETED) { + return; + } Set questIds = event.getQuestIDs(); if (questIds.isEmpty()) { return; } + String playerName = QuestingAPI.getPlayer(event.getPlayerID()) .getDisplayName(); questIds.forEach(uuid -> { + IQuest quest = QuestDatabase.INSTANCE.get(uuid); + if (quest == null) { + LOG.error(String.format("Quest with ID %s does not exist", uuid)); + return; + } LOG.info( String.format( - "%s completed the quest: %s", + "%s completed the quest %s: %s", playerName, - QuestTranslation.translateQuestName(uuid, QuestDatabase.INSTANCE.get(uuid)))); + quest.getProperty(NativeProps.GLOBAL) ? "[GLOBAL]" : "", + QuestTranslation.translateQuestName(uuid, quest) + .replaceAll("ยง.", ""))); }); }