Skip to content

Commit

Permalink
Merge pull request #1 from cons-tan-tan/feature
Browse files Browse the repository at this point in the history
Create log system
  • Loading branch information
cons-tan-tan authored Mar 25, 2024
2 parents 0378543 + 40bf6ef commit b7eddd1
Show file tree
Hide file tree
Showing 5 changed files with 76 additions and 31 deletions.
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) <year> <copyright holders>
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
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,5 @@ pluginManagement {
}

plugins {
id 'com.gtnewhorizons.gtnhsettingsconvention' version '1.0.15'
id 'com.gtnewhorizons.gtnhsettingsconvention' version '1.0.19'
}
91 changes: 68 additions & 23 deletions src/main/java/bqlogging/BetterQuestLogging.java
Original file line number Diff line number Diff line change
@@ -1,50 +1,95 @@
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.api.properties.NativeProps;
import betterquesting.api.questing.IQuest;
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]")
name = "BetterQuestLogging",
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);
// 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
// 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);
}
@SubscribeEvent
public void onQuestEvent(QuestEvent event) {
if (event.getType() != QuestEvent.Type.COMPLETED) {
return;
}
Set<UUID> questIds = event.getQuestIDs();
if (questIds.isEmpty()) {
return;
}

@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);
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",
playerName,
quest.getProperty(NativeProps.GLOBAL) ? "[GLOBAL]" : "",
QuestTranslation.translateQuestName(uuid, quest)
.replaceAll("§.", "")));
});
}

@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);
// }
}
10 changes: 5 additions & 5 deletions src/main/resources/mcmod.info
Original file line number Diff line number Diff line change
Expand Up @@ -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
}]
}

0 comments on commit b7eddd1

Please sign in to comment.