diff --git a/pom.xml b/pom.xml index e515c43..993e679 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ ADHDMC VillagerInfo - 2.1 + 2.2 jar VillagerInfo diff --git a/src/main/java/adhdmc/villagerinfo/Config/Defaults.java b/src/main/java/adhdmc/villagerinfo/Config/Defaults.java index e7a8d01..2e937d4 100644 --- a/src/main/java/adhdmc/villagerinfo/Config/Defaults.java +++ b/src/main/java/adhdmc/villagerinfo/Config/Defaults.java @@ -40,6 +40,7 @@ public static void localeDefaults() { public static void configDefaults() { FileConfiguration config = VillagerInfo.getInstance().getConfig(); + config.addDefault("baby-age", true); config.addDefault("profession", true); config.addDefault("job-site", true); config.addDefault("last-worked", true); diff --git a/src/main/java/adhdmc/villagerinfo/Config/Message.java b/src/main/java/adhdmc/villagerinfo/Config/Message.java index c60eec0..da5bedf 100644 --- a/src/main/java/adhdmc/villagerinfo/Config/Message.java +++ b/src/main/java/adhdmc/villagerinfo/Config/Message.java @@ -17,6 +17,7 @@ public enum Message { NOT_A_PLAYER("Sorry, you must be a player to use this command"), // Villager Info + VILLAGER_AGE("TIME UNTIL ADULT: \n"), VILLAGER_PROFESSION("PROFESSION:\n"), VILLAGER_JOBSITE("JOB SITE:\n"), VILLAGER_LAST_WORKED("LAST WORKED AT WORKSTATION:\n"), @@ -59,6 +60,7 @@ public static void reloadLocale() { HELP_RELOAD.setMessage(locale.getString("help-reload", "<#4dd5ff> • /vill reload\nReloads the plugin, applies config values")); NOT_A_PLAYER.setMessage(locale.getString("not-a-player", "Sorry, you must be a player to use this command")); // Villager Info + VILLAGER_AGE.setMessage(locale.getString("villager-age", "TIME UNTIL ADULT: \n")); VILLAGER_PROFESSION.setMessage(locale.getString("villager-profession", "PROFESSION:\n")); VILLAGER_JOBSITE.setMessage(locale.getString("villager-jobsite-msg", "JOB SITE:\n")); VILLAGER_LAST_WORKED.setMessage(locale.getString("villager-last-worked-msg", "LAST WORKED AT WORKSTATION:\n")); diff --git a/src/main/java/adhdmc/villagerinfo/Config/ToggleSetting.java b/src/main/java/adhdmc/villagerinfo/Config/ToggleSetting.java index ac52fa9..41179b3 100644 --- a/src/main/java/adhdmc/villagerinfo/Config/ToggleSetting.java +++ b/src/main/java/adhdmc/villagerinfo/Config/ToggleSetting.java @@ -4,6 +4,7 @@ import org.bukkit.configuration.file.FileConfiguration; public enum ToggleSetting { + BABY_AGE(true), PROFESSION(true), JOB_SITE(true), LAST_WORKED(true), @@ -23,6 +24,7 @@ public enum ToggleSetting { public static void reloadToggles() { FileConfiguration config = VillagerInfo.getInstance().getConfig(); + BABY_AGE.setEnabled(config.getBoolean("baby-age", true)); PROFESSION.setEnabled(config.getBoolean("profession", true)); JOB_SITE.setEnabled(config.getBoolean("job-site", true)); LAST_WORKED.setEnabled(config.getBoolean("last-worked", true)); diff --git a/src/main/java/adhdmc/villagerinfo/VillagerHandling/VillagerHandler.java b/src/main/java/adhdmc/villagerinfo/VillagerHandling/VillagerHandler.java index 55934d8..9a7ba30 100644 --- a/src/main/java/adhdmc/villagerinfo/VillagerHandling/VillagerHandler.java +++ b/src/main/java/adhdmc/villagerinfo/VillagerHandling/VillagerHandler.java @@ -1,6 +1,5 @@ package adhdmc.villagerinfo.VillagerHandling; -import adhdmc.villagerinfo.Config.ConfigValidator; import adhdmc.villagerinfo.Config.Message; import adhdmc.villagerinfo.Config.Perms; import adhdmc.villagerinfo.Config.ToggleSetting; @@ -25,7 +24,6 @@ import java.util.ArrayList; import java.util.Arrays; -import java.util.Map; import java.util.UUID; public class VillagerHandler implements Listener { @@ -65,6 +63,10 @@ public void onVillagerClick(PlayerInteractEntityEvent event) { boolean hasWorkSite = villager.getMemory(MemoryKey.JOB_SITE) != null; boolean hasBed = villager.getMemory(MemoryKey.HOME) != null; boolean isAdult = villager.isAdult(); + //time until adult + if (ToggleSetting.BABY_AGE.isEnabled() && !isAdult) { + messageList.add(villagerTimeTillAdult(villager)); + } //profession if (ToggleSetting.PROFESSION.isEnabled() && isAdult) { messageList.add(villagerProfession(villager)); @@ -111,6 +113,16 @@ public void onVillagerClick(PlayerInteractEntityEvent event) { } } + private Component villagerTimeTillAdult(Villager villager) { + Component timeTillAdultFinal; + long villAge = villager.getAge(); + villAge = villAge * -1; + VillagerInfo.getInstance().getLogger().info("" + villAge); + String timeCalc = timeMath(villAge); + timeTillAdultFinal = miniMessage.deserialize(Message.VILLAGER_AGE.getMessage(), Placeholder.unparsed("age", timeCalc)); + return timeTillAdultFinal; + } + private Component villagerProfession(Villager villager) { Component professionFinal; String villagerProfessionString = villager.getProfession().toString(); @@ -149,7 +161,7 @@ private Component villagerLastWorked(Villager villager) { Placeholder.parsed("worktime", Message.NEVER.getMessage())); } else { Long timeSinceWorked = villager.getWorld().getGameTime() - lastWorked; - String formattedTime = timeMath(timeSinceWorked); + String formattedTime = timeMath(timeSinceWorked) + Message.AGO.getMessage(); villagerLastWorkedFinal = miniMessage.deserialize(Message.VILLAGER_LAST_WORKED.getMessage(), Placeholder.unparsed("worktime", formattedTime)); } @@ -183,7 +195,7 @@ private Component villagerLastSlept(Villager villager) { Placeholder.parsed("sleeptime", Message.NEVER.getMessage())); } else { Long timeSinceSlept = villager.getWorld().getGameTime() - lastSlept; - String formattedTime = timeMath(timeSinceSlept); + String formattedTime = timeMath(timeSinceSlept) + Message.AGO.getMessage() ; villagerLastSleptFinal = miniMessage.deserialize(Message.VILLAGER_SLEPT.getMessage(), Placeholder.unparsed("sleeptime", formattedTime)); } @@ -252,10 +264,8 @@ private String timeMath(Long mathTime) { if (mathTimeC > 0) mathResult += mathTimeC + Message.MINUTE.getMessage(); if (mathTimeD > 0) mathResult += mathTimeD + Message.SECOND.getMessage(); if (mathResult.isEmpty()) { - mathResult += "0" + Message.SECOND.getMessage() + Message.AGO.getMessage(); - return mathResult; + mathResult += "0" + Message.SECOND.getMessage(); } - mathResult += Message.AGO.getMessage(); return mathResult; } } diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index ed32123..91b9be7 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -2,6 +2,7 @@ #Information Toggles #True to enable the information to display when requested, false for it not to display +baby-age: true profession: true job-site: true last-worked: true