From 05bb52459783665f835b326bb6b95e597f925d18 Mon Sep 17 00:00:00 2001 From: TheFaser Date: Sun, 19 Nov 2023 20:53:10 +0500 Subject: [PATCH] ChatBubble: add spawn height setting --- .../chat/module/chatBubble/ChatBubbleModule.java | 9 ++++++++- .../chat/module/chatBubble/ChatBubbleTicker.java | 3 ++- src/main/resources/config.yml | 1 + 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/main/java/net/flectone/chat/module/chatBubble/ChatBubbleModule.java b/src/main/java/net/flectone/chat/module/chatBubble/ChatBubbleModule.java index c54001c..200f475 100644 --- a/src/main/java/net/flectone/chat/module/chatBubble/ChatBubbleModule.java +++ b/src/main/java/net/flectone/chat/module/chatBubble/ChatBubbleModule.java @@ -42,13 +42,20 @@ public void add(@NotNull Player player, @NotNull String message) { fPlayer.addChatBubble(message); } - public void spawn(@NotNull Player player, @NotNull String message, @NotNull String color, int maxPerLine, int readSpeed) { + public void spawn(@NotNull Player player, @NotNull String message, @NotNull String color, int height, int maxPerLine, int readSpeed) { List messageStrings = divideText(message, maxPerLine); int duration = (message.length() + 8 * messageStrings.size()) * 1200 / readSpeed; Entity lastVehicle = player; + while (height > 0) { + if (lastVehicle == null) return; + + lastVehicle = spawnStringBubble(lastVehicle, "", lastVehicle.getLocation(), duration); + height--; + } + for (int x = messageStrings.size() - 1; x > -1; x--) { if(lastVehicle == null) return; diff --git a/src/main/java/net/flectone/chat/module/chatBubble/ChatBubbleTicker.java b/src/main/java/net/flectone/chat/module/chatBubble/ChatBubbleTicker.java index fafc888..c4fa348 100644 --- a/src/main/java/net/flectone/chat/module/chatBubble/ChatBubbleTicker.java +++ b/src/main/java/net/flectone/chat/module/chatBubble/ChatBubbleTicker.java @@ -59,9 +59,10 @@ public void run() { int maxPerLine = config.getVaultInt(player, getModule() + ".max-per-line"); String color = config.getVaultString(player, getModule() + ".color"); int readSpeed = config.getVaultInt(player, getModule() + ".read-speed"); + int height = config.getVaultInt(player, getModule() + ".height"); ((ChatBubbleModule) getModule()).spawn(player, message, MessageUtil.formatAll(player, color), - maxPerLine, readSpeed); + height, maxPerLine, readSpeed); }); } } diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index 80fb240..c7ec444 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -352,6 +352,7 @@ default: chat-bubble: enable: true color: "#999999" + height: 1 max-per-line: 35 read-speed: 800