File tree Expand file tree Collapse file tree 5 files changed +58
-3
lines changed
src/main/java/com/maximde/betterchatbubbles/api Expand file tree Collapse file tree 5 files changed +58
-3
lines changed Original file line number Diff line number Diff line change @@ -5,7 +5,7 @@ plugins {
55}
66
77group = ' com.maximde'
8- version = ' 1.5.2 '
8+ version = ' 1.5.3 '
99
1010tasks. withType(JavaCompile ). configureEach {
1111 options. release = 17
@@ -28,6 +28,7 @@ dependencies {
2828 compileOnly (" org.spigotmc:spigot-api:1.19.4-R0.1-SNAPSHOT" )
2929 compileOnly ' com.github.retrooper.packetevents:api:2.2.1'
3030 implementation " net.kyori:adventure-text-minimessage:4.17.0"
31+ compileOnly ' com.github.LoneDev6:API-ItemsAdder:3.6.1'
3132}
3233
3334publishing {
Original file line number Diff line number Diff line change 11package com .maximde .betterchatbubbles .api ;
22
3+ import com .maximde .betterchatbubbles .api .utils .ItemsAdderHolder ;
4+ import com .maximde .betterchatbubbles .api .utils .ReplaceText ;
5+ import lombok .Getter ;
36import org .bukkit .Bukkit ;
47
58import java .util .Optional ;
@@ -9,8 +12,20 @@ public record BubbleAPI(BubbleGenerator bubbleGenerator) {
912
1013 private static BubbleAPI bubbleAPI ;
1114
15+ private static ReplaceText replaceText ;
16+
1217 public static void setAPI (BubbleAPI bubbleAPI ) {
1318 BubbleAPI .bubbleAPI = bubbleAPI ;
19+ try {
20+ replaceText = new ItemsAdderHolder ();
21+ } catch (ClassNotFoundException exception ) {
22+ replaceText = new ReplaceText () {
23+ @ Override
24+ public String replace (String s ) {
25+ return s ;
26+ }
27+ };
28+ }
1429 }
1530
1631 public static Optional <BubbleAPI > getBubbleAPI () {
@@ -21,4 +36,8 @@ public static Optional<BubbleAPI> getBubbleAPI() {
2136
2237 return Optional .of (bubbleAPI );
2338 }
39+
40+ public ReplaceText getReplaceText () {
41+ return replaceText ;
42+ }
2443}
Original file line number Diff line number Diff line change 1919import java .lang .reflect .Field ;
2020import java .util .ArrayList ;
2121import java .util .List ;
22+ import java .util .Optional ;
23+ import java .util .concurrent .atomic .AtomicReference ;
2224import java .util .logging .Level ;
2325
2426public class ChatBubble {
@@ -223,7 +225,7 @@ public String getTextWithoutColor() {
223225 }
224226
225227 public ChatBubble setText (String text ) {
226- this .text = Component .text (text );
228+ this .text = Component .text (replaceFontImages ( text ) );
227229 return this ;
228230 }
229231
@@ -233,10 +235,17 @@ public ChatBubble setText(Component component) {
233235 }
234236
235237 public ChatBubble setMiniMessageText (String text ) {
236- this .text = Mini .message (text );
238+ this .text = Mini .message (replaceFontImages ( text ) );
237239 return this ;
238240 }
239241
242+ private String replaceFontImages (String s ) {
243+ AtomicReference <String > news = new AtomicReference <>(s );
244+ Optional <BubbleAPI > bubble = BubbleAPI .getBubbleAPI ();
245+ bubble .ifPresent (bubbleAPI -> news .set (bubbleAPI .getReplaceText ().replace (news .get ())));
246+ return news .get ();
247+ }
248+
240249 /**
241250 * This is the correct way to get the location without any possible errors!
242251 */
Original file line number Diff line number Diff line change 1+ package com .maximde .betterchatbubbles .api .utils ;
2+
3+ import dev .lone .itemsadder .api .FontImages .FontImageWrapper ;
4+ import org .bukkit .Bukkit ;
5+
6+ import java .util .logging .Level ;
7+
8+ public class ItemsAdderHolder implements ReplaceText {
9+
10+ public ItemsAdderHolder () throws ClassNotFoundException {
11+ if (Bukkit .getPluginManager ().getPlugin ("ItemsAdder" ) == null ) {
12+ Bukkit .getLogger ().log (Level .WARNING , "[BetterChatBubbles] ItemsAdder plugin not found! No custom emojis support." );
13+ throw new ClassNotFoundException ();
14+ }
15+ }
16+
17+ @ Override
18+ public String replace (String s ) {
19+ return FontImageWrapper .replaceFontImages (s );
20+ }
21+ }
Original file line number Diff line number Diff line change 1+ package com .maximde .betterchatbubbles .api .utils ;
2+
3+ public interface ReplaceText {
4+ String replace (String s );
5+ }
You can’t perform that action at this time.
0 commit comments