Changes code to account for KnarLib changes

This commit is contained in:
Kristian Knarvik 2022-11-07 22:23:31 +01:00
parent c03e06b132
commit c33520d8f2
2 changed files with 19 additions and 7 deletions

View File

@ -8,7 +8,6 @@ import net.knarcraft.dynmapcitizens.handler.trait.MinstrelHandler;
import net.knarcraft.dynmapcitizens.handler.trait.SentinelHandler; import net.knarcraft.dynmapcitizens.handler.trait.SentinelHandler;
import net.knarcraft.dynmapcitizens.handler.trait.quests.QuestsHandler; import net.knarcraft.dynmapcitizens.handler.trait.quests.QuestsHandler;
import net.knarcraft.dynmapcitizens.settings.GlobalSettings; import net.knarcraft.dynmapcitizens.settings.GlobalSettings;
import net.knarcraft.knarlib.KnarLib;
import net.knarcraft.knarlib.formatting.TranslatableTimeUnit; import net.knarcraft.knarlib.formatting.TranslatableTimeUnit;
import net.knarcraft.knarlib.formatting.Translator; import net.knarcraft.knarlib.formatting.Translator;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
@ -26,6 +25,7 @@ import java.util.logging.Level;
public final class DynmapCitizens extends JavaPlugin { public final class DynmapCitizens extends JavaPlugin {
private static DynmapCitizens instance; private static DynmapCitizens instance;
private static Translator translator;
private DynmapAPI dynmapAPI; private DynmapAPI dynmapAPI;
private VaultHandler vaultHandler; private VaultHandler vaultHandler;
private GlobalSettings globalSettings; private GlobalSettings globalSettings;
@ -34,7 +34,6 @@ public final class DynmapCitizens extends JavaPlugin {
@Override @Override
public void onEnable() { public void onEnable() {
DynmapCitizens.instance = this; DynmapCitizens.instance = this;
KnarLib.setPlugin(this);
//Initialize quest and dynmap APIs //Initialize quest and dynmap APIs
PluginManager pluginManager = Bukkit.getPluginManager(); PluginManager pluginManager = Bukkit.getPluginManager();
@ -56,9 +55,10 @@ public final class DynmapCitizens extends JavaPlugin {
this.globalSettings.load(configuration); this.globalSettings.load(configuration);
//Load all messages //Load all messages
Translator.registerMessageCategory(TranslatableTimeUnit.UNIT_SECOND); translator = new Translator();
Translator.registerMessageCategory(DynmapCitizensTranslatableMessage.SENTINEL_DESCRIPTION); translator.registerMessageCategory(TranslatableTimeUnit.UNIT_SECOND);
Translator.loadLanguages("en"); translator.registerMessageCategory(DynmapCitizensTranslatableMessage.SENTINEL_DESCRIPTION);
translator.loadLanguages(this.getDataFolder(), "en");
//Initialize all enabled traits //Initialize all enabled traits
initializeTraitHandlers(configuration); initializeTraitHandlers(configuration);
@ -80,6 +80,15 @@ public final class DynmapCitizens extends JavaPlugin {
//TODO: Perhaps remove icons, just in case? //TODO: Perhaps remove icons, just in case?
} }
/**
* Gets the translator to use for translation
*
* @return <p>The translator to use</p>
*/
public static Translator getTranslator() {
return translator;
}
/** /**
* Gets the global settings for this plugin * Gets the global settings for this plugin
* *

View File

@ -2,6 +2,7 @@ package net.knarcraft.dynmapcitizens.handler.trait.quests;
import me.blackvein.quests.quests.IQuest; import me.blackvein.quests.quests.IQuest;
import me.blackvein.quests.quests.Planner; import me.blackvein.quests.quests.Planner;
import net.knarcraft.dynmapcitizens.DynmapCitizens;
import net.knarcraft.knarlib.formatting.TimeFormatter; import net.knarcraft.knarlib.formatting.TimeFormatter;
import java.text.DateFormat; import java.text.DateFormat;
@ -37,7 +38,8 @@ public class QuestPlannerInfoGenerator {
//Quest can be repeated after a cool-down //Quest can be repeated after a cool-down
if (planner.hasCooldown()) { if (planner.hasCooldown()) {
plannerInfo.append("<li>Quest repeatable after: "); plannerInfo.append("<li>Quest repeatable after: ");
plannerInfo.append(TimeFormatter.getDurationString(planner.getCooldown() / 1000)); plannerInfo.append(TimeFormatter.getDurationString(DynmapCitizens.getTranslator(),
planner.getCooldown() / 1000));
plannerInfo.append("</li>"); plannerInfo.append("</li>");
} else { } else {
plannerInfo.append("<li>Quest cannot be repeated!</li>"); plannerInfo.append("<li>Quest cannot be repeated!</li>");
@ -58,7 +60,8 @@ public class QuestPlannerInfoGenerator {
//Quest availability repeats //Quest availability repeats
if (planner.hasRepeat()) { if (planner.hasRepeat()) {
plannerInfo.append("<li>Quest will become available again after "); plannerInfo.append("<li>Quest will become available again after ");
plannerInfo.append(TimeFormatter.getDurationString(planner.getRepeat() / 1000)).append("</li>"); plannerInfo.append(TimeFormatter.getDurationString(DynmapCitizens.getTranslator(),
planner.getRepeat() / 1000)).append("</li>");
} }
plannerInfo.append("</ul>"); plannerInfo.append("</ul>");