From 433121979c3a61468f7e74fff06f48e24be67770 Mon Sep 17 00:00:00 2001 From: fullwall Date: Mon, 2 Jan 2023 08:37:27 +0800 Subject: [PATCH] Add a random text delay default setting of 20-40ticks --- main/src/main/java/net/citizensnpcs/Settings.java | 2 ++ main/src/main/java/net/citizensnpcs/trait/text/Text.java | 4 ++++ 2 files changed, 6 insertions(+) diff --git a/main/src/main/java/net/citizensnpcs/Settings.java b/main/src/main/java/net/citizensnpcs/Settings.java index 145f04573..50a89f870 100644 --- a/main/src/main/java/net/citizensnpcs/Settings.java +++ b/main/src/main/java/net/citizensnpcs/Settings.java @@ -110,6 +110,8 @@ public class Settings { value = list; } }, + DEFAULT_TEXT_DELAY_MAX("npc.text.default-random-text-delay-max", 40), + DEFAULT_TEXT_DELAY_MIN("npc.text.default-random-text-delay-min", 20), DEFAULT_TEXT_SPEECH_BUBBLE_TICKS("npc.text.speech-bubble-ticks", 50), DISABLE_LOOKCLOSE_WHILE_NAVIGATING("npc.default.look-close.disable-while-navigating", true), DISABLE_MC_NAVIGATION_FALLBACK("npc.pathfinding.disable-mc-fallback-navigation", true), diff --git a/main/src/main/java/net/citizensnpcs/trait/text/Text.java b/main/src/main/java/net/citizensnpcs/trait/text/Text.java index bd20f06b4..4bcafaae1 100644 --- a/main/src/main/java/net/citizensnpcs/trait/text/Text.java +++ b/main/src/main/java/net/citizensnpcs/trait/text/Text.java @@ -278,6 +278,10 @@ public class Text extends Trait implements Runnable, Listener { sendText(player); + int delay = this.delay == -1 + ? Util.getFastRandom().nextInt(Setting.DEFAULT_TEXT_DELAY_MIN.asInt(), + Setting.DEFAULT_TEXT_DELAY_MAX.asInt()) + : this.delay; if (delay <= 0) return; cooldowns.put(player.getUniqueId(), System.currentTimeMillis() + (delay * 50));