From 14b7e837d87a02eceacb5c445173edd8ab18ad4f Mon Sep 17 00:00:00 2001 From: Zrips Date: Tue, 29 Aug 2023 15:18:05 +0300 Subject: [PATCH] Lets keep loading in plugin when some none essential files fail to load --- .../jobs/config/GeneralConfigManager.java | 27 ++++++++++++++----- .../com/gamingmesh/jobs/container/Job.java | 4 +-- .../java/com/gamingmesh/jobs/stuff/Util.java | 7 +++++ 3 files changed, 29 insertions(+), 9 deletions(-) diff --git a/src/main/java/com/gamingmesh/jobs/config/GeneralConfigManager.java b/src/main/java/com/gamingmesh/jobs/config/GeneralConfigManager.java index 411d6cbe..db601aaa 100644 --- a/src/main/java/com/gamingmesh/jobs/config/GeneralConfigManager.java +++ b/src/main/java/com/gamingmesh/jobs/config/GeneralConfigManager.java @@ -111,7 +111,7 @@ public class GeneralConfigManager { DisabledWorldsUse, UseAsWhiteListWorldList, MythicMobsEnabled, LoggingUse, payForCombiningItems, BlastFurnacesReassign = false, SmokerReassign = false, payForStackedEntities, payForAbove = false, payForEachVTradeItem, allowEnchantingBoostedItems, bossBarAsync = false, preventShopItemEnchanting; - + public boolean jobsshopenabled; public boolean DailyQuestsEnabled; @@ -273,11 +273,24 @@ public class GeneralConfigManager { // Load locale Jobs.getLanguageManager().load(); // title settings - Jobs.getTitleManager().load(); + try { + Jobs.getTitleManager().load(); + } catch (Throwable e) { + e.printStackTrace(); + } // restricted areas - Jobs.getRestrictedAreaManager().load(); + try { + Jobs.getRestrictedAreaManager().load(); + } catch (Throwable e) { + e.printStackTrace(); + } // restricted blocks - Jobs.getRestrictedBlockManager().load(); + try { + Jobs.getRestrictedBlockManager().load(); + } catch (Throwable e) { + e.printStackTrace(); + } + // Item/Block/mobs name list Jobs.getNameTranslatorManager().load(); // signs information @@ -426,7 +439,7 @@ public class GeneralConfigManager { c.addComment("DailyQuests.Enabled", "Enables or disables daily quests"); DailyQuestsEnabled = c.get("DailyQuests.Enabled", true); - + c.addComment("DailyQuests.ResetTime", "Defines time in 24hour format when we want to give out new daily quests", "Any daily quests given before reset will be invalid and new ones will be given out"); ResetTimeHour = c.get("DailyQuests.ResetTime.Hour", 4); @@ -445,7 +458,7 @@ public class GeneralConfigManager { c.addComment("max-jobs", "Maximum number of jobs a player can join.", "Use -1 to disable limitations", "Keep in mind that jobs.max.[amount] will bypass this setting"); maxJobs = c.get("max-jobs", 3); - + c.addComment("disable-payment-if-max-level-reached", "Disabling the payment if the user reached the maximum level of a job."); disablePaymentIfMaxLevelReached = c.get("disable-payment-if-max-level-reached", false); @@ -457,7 +470,7 @@ public class GeneralConfigManager { c.addComment("prevent-shop-item-enchanting", "Prevent players to enchant items from the shop in the anvil with enchanted books"); preventShopItemEnchanting = c.get("prevent-shop-item-enchanting", true); - + c.addComment("jobs-shop-enabled", "Enables or disables jobs shop"); jobsshopenabled = c.get("jobs-shop-enabled", true); diff --git a/src/main/java/com/gamingmesh/jobs/container/Job.java b/src/main/java/com/gamingmesh/jobs/container/Job.java index cdf3a685..08ac41fc 100644 --- a/src/main/java/com/gamingmesh/jobs/container/Job.java +++ b/src/main/java/com/gamingmesh/jobs/container/Job.java @@ -237,7 +237,7 @@ public class Job { if (now < Jobs.getGCManager().DynamicPaymentMaxPenalty) now = Jobs.getGCManager().DynamicPaymentMaxPenalty; - + if (Double.isNaN(now)) now = 0; @@ -310,7 +310,7 @@ public class Job { }; String shortActionName = CMIMaterial.getGeneralMaterialName(action.getName()); - + for (JobInfo info : getJobInfo(action.getType())) { if (condition.test(info, action)) { if (!info.isInLevelRange(level)) { diff --git a/src/main/java/com/gamingmesh/jobs/stuff/Util.java b/src/main/java/com/gamingmesh/jobs/stuff/Util.java index 5e82a31f..0b71622d 100644 --- a/src/main/java/com/gamingmesh/jobs/stuff/Util.java +++ b/src/main/java/com/gamingmesh/jobs/stuff/Util.java @@ -3,6 +3,7 @@ package com.gamingmesh.jobs.stuff; import java.net.URISyntaxException; import java.net.URL; import java.net.URLClassLoader; +import java.text.DecimalFormat; import java.util.ArrayList; import java.util.Enumeration; import java.util.HashMap; @@ -63,6 +64,12 @@ public final class Util { return blocks; } + private final static DecimalFormat dcf = new DecimalFormat("##.##"); + + public static String format2Decimals(double number) { + return dcf.format(number); + } + public static String getRealType(Entity entity) { if (Version.isCurrentEqualOrHigher(Version.v1_11_R1)) { return entity.getType().name();