From e26760a1e3da6d811d960aab750c7b329130e3a7 Mon Sep 17 00:00:00 2001 From: Oliver Date: Mon, 2 Jun 2025 09:21:01 +0200 Subject: [PATCH] fancynpcs: Update npc update interval to seconds --- .../java/de/oliver/fancynpcs/FancyNpcs.java | 2 +- .../oliver/fancynpcs/FancyNpcsConfigImpl.java | 10 ++++---- .../fancynpcs/tests/PlaceholderApiEnv.java | 23 +++++++++++-------- 3 files changed, 20 insertions(+), 15 deletions(-) diff --git a/plugins/fancynpcs/src/main/java/de/oliver/fancynpcs/FancyNpcs.java b/plugins/fancynpcs/src/main/java/de/oliver/fancynpcs/FancyNpcs.java index 954cb6bb..6bd15f44 100644 --- a/plugins/fancynpcs/src/main/java/de/oliver/fancynpcs/FancyNpcs.java +++ b/plugins/fancynpcs/src/main/java/de/oliver/fancynpcs/FancyNpcs.java @@ -316,7 +316,7 @@ public class FancyNpcs extends JavaPlugin implements FancyNpcsPlugin { npc.spawnForAll(); } } - }, 3, npcUpdateInterval, TimeUnit.MINUTES); + }, 30, npcUpdateInterval, TimeUnit.SECONDS); // Creating new instance of CloudCommandManager and registering all needed components. // NOTE: Brigadier is disabled by default. More detailed information about that can be found in CloudCommandManager class. diff --git a/plugins/fancynpcs/src/main/java/de/oliver/fancynpcs/FancyNpcsConfigImpl.java b/plugins/fancynpcs/src/main/java/de/oliver/fancynpcs/FancyNpcsConfigImpl.java index 6ef968a7..86bf5ad9 100644 --- a/plugins/fancynpcs/src/main/java/de/oliver/fancynpcs/FancyNpcsConfigImpl.java +++ b/plugins/fancynpcs/src/main/java/de/oliver/fancynpcs/FancyNpcsConfigImpl.java @@ -115,8 +115,8 @@ public class FancyNpcsConfigImpl implements FancyNpcsConfig { autoSaveInterval = (int) ConfigHelper.getOrDefault(config, "autosave_interval", 15); config.setInlineComments("autosave_interval", List.of("The interval at which autosave is performed in minutes.")); - npcUpdateInterval = (int) ConfigHelper.getOrDefault(config, "npc_update_interval", 30); - config.setInlineComments("npc_update_skin_interval", List.of("The interval at which the NPC is updated (in minutes). Only if the skin or displayName is a placeholder.")); + npcUpdateInterval = (int) ConfigHelper.getOrDefault(config, "npc_update_interval", 60); + config.setInlineComments("npc_update_skin_interval", List.of("The interval at which the NPC is updated (in seconds). Only if the skin or displayName is a placeholder.")); npcUpdateVisibilityInterval = (int) ConfigHelper.getOrDefault(config, "npc_update_visibility_interval", 20); config.setInlineComments("npc_update_visibility_interval", List.of("The interval at which the NPC visibility is updated (in ticks).")); @@ -211,15 +211,15 @@ public class FancyNpcsConfigImpl implements FancyNpcsConfig { if (distance <= 0 && distance != -1) { return false; } - + // Update the config value in memory this.turnToPlayerDistance = distance; - + // Persist to config file FileConfiguration config = FancyNpcs.getInstance().getConfig(); config.set("turn_to_player_distance", distance); FancyNpcs.getInstance().saveConfig(); - + return true; } diff --git a/plugins/fancynpcs/src/main/java/de/oliver/fancynpcs/tests/PlaceholderApiEnv.java b/plugins/fancynpcs/src/main/java/de/oliver/fancynpcs/tests/PlaceholderApiEnv.java index 3c23fc21..2abe97f9 100644 --- a/plugins/fancynpcs/src/main/java/de/oliver/fancynpcs/tests/PlaceholderApiEnv.java +++ b/plugins/fancynpcs/src/main/java/de/oliver/fancynpcs/tests/PlaceholderApiEnv.java @@ -8,7 +8,12 @@ import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; public class PlaceholderApiEnv extends PlaceholderExpansion { - public static String parsedString = "Grabsky"; + public static int i = 0; + public static String[] strings = new String[]{ + "Grabsky", + "OakLoaf", + "GommeHD", + }; public static void registerPlaceholders() { if (!Bukkit.getPluginManager().isPluginEnabled("PlaceholderAPI")) { @@ -36,20 +41,20 @@ public class PlaceholderApiEnv extends PlaceholderExpansion { @Override public @Nullable String onPlaceholderRequest(Player player, @NotNull String params) { - if (player == null) { - return null; + i++; + if (i >= strings.length) { + i = 0; } - - return parsedString; + return strings[i]; } @Override public @Nullable String onRequest(OfflinePlayer player, @NotNull String params) { - if (player == null) { - return null; + i++; + if (i >= strings.length) { + i = 0; } - - return parsedString; + return strings[i]; } }