From 6383c9dae8ab5f8476f4b3b8ccd21292ab00e724 Mon Sep 17 00:00:00 2001 From: Auxilor Date: Wed, 27 Jan 2021 19:25:33 +0000 Subject: Cached bool values --- .../leonardobishop/quests/commands/CommandQuests.java | 1 + .../java/com/leonardobishop/quests/obj/Options.java | 18 ++++++++++++++++-- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/leonardobishop/quests/commands/CommandQuests.java b/src/main/java/com/leonardobishop/quests/commands/CommandQuests.java index 0ea56759..382c3c1a 100644 --- a/src/main/java/com/leonardobishop/quests/commands/CommandQuests.java +++ b/src/main/java/com/leonardobishop/quests/commands/CommandQuests.java @@ -65,6 +65,7 @@ public class CommandQuests implements CommandExecutor { } else if (args[1].equalsIgnoreCase("reload")) { plugin.reloadConfig(); plugin.reloadQuests(); + Options.clearBoolValues(); if (!plugin.getQuestsConfigLoader().getBrokenFiles().isEmpty()) { sender.sendMessage(ChatColor.RED + "Quests has failed to load the following files:"); for (Map.Entry entry : plugin.getQuestsConfigLoader().getBrokenFiles().entrySet()) { diff --git a/src/main/java/com/leonardobishop/quests/obj/Options.java b/src/main/java/com/leonardobishop/quests/obj/Options.java index afcb8fcf..ffe8f6b7 100644 --- a/src/main/java/com/leonardobishop/quests/obj/Options.java +++ b/src/main/java/com/leonardobishop/quests/obj/Options.java @@ -3,11 +3,13 @@ package com.leonardobishop.quests.obj; import com.leonardobishop.quests.Quests; import org.bukkit.ChatColor; +import java.time.temporal.ValueRange; import java.util.ArrayList; +import java.util.HashMap; import java.util.List; +import java.util.Map; public enum Options { - CATEGORIES_ENABLED("options.categories-enabled"), TRIM_GUI_SIZE("options.trim-gui-size"), QUESTS_START_LIMIT("options.quest-started-limit"), @@ -22,6 +24,8 @@ public enum Options { ALLOW_QUEST_CANCEL("options.allow-quest-cancel"), QUEST_AUTOSTART("options.quest-autostart"); + private static final Map cachedBools = new HashMap<>(); + private final String path; Options(String path) { @@ -37,7 +41,13 @@ public enum Options { } public boolean getBooleanValue() { - return Quests.get().getConfig().getBoolean(path); + Boolean val = cachedBools.get(path); + if (val != null) { + return val; + } else { + cachedBools.put(path, Quests.get().getConfig().getBoolean(path)); + return getBooleanValue(); + } } public List getStringListValue() { @@ -55,4 +65,8 @@ public enum Options { } return colored; } + + public static void clearBoolValues() { + cachedBools.clear(); + } } -- cgit v1.2.3-70-g09d2 From 90c6f1cbb832bdc00280ecfa9dd98fd9cd3aa891 Mon Sep 17 00:00:00 2001 From: Auxilor Date: Wed, 27 Jan 2021 19:27:23 +0000 Subject: Changed authors --- src/main/resources/plugin.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml index 9a96f719..2b2629c2 100644 --- a/src/main/resources/plugin.yml +++ b/src/main/resources/plugin.yml @@ -4,7 +4,7 @@ name: Quests version: %PLUGIN_VERSION% main: com.leonardobishop.quests.Quests -author: LMBishop +authors: [LMBishop, Auxilor] softdepend: [ASkyBlock, uSkyBlock, Citizens, PlaceholderAPI] prefix: Quests api-version: "1.13" # allows new API features but Quests will still work pre-1.13 -- cgit v1.2.3-70-g09d2 From 504d0f5b4b3d1d2e5ec3dfa836591cc8bc420ef7 Mon Sep 17 00:00:00 2001 From: Auxilor Date: Wed, 27 Jan 2021 19:28:09 +0000 Subject: Updated to 2.10.2 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 2e34a887..62951e0a 100644 --- a/pom.xml +++ b/pom.xml @@ -7,7 +7,7 @@ com.leonardobishop quests - 2.10.1 + 2.10.2 Quests -- cgit v1.2.3-70-g09d2