File tree Expand file tree Collapse file tree
src/main/java/net/apple70cents/chattools/features/general Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -19,11 +19,20 @@ public class NickHider {
1919 private static String nickname ;
2020
2121 private static final CircuitBreakerExecutor executor = CircuitBreakerExecutor .of (() -> {
22+ Component original = text .copy ();
2223 try {
23- text = TextUtils .replaceComponentText (text .copy (), RegExUtils .getOrCompilePattern (Pattern .quote (playerName )), nickname );
24+ Component result = TextUtils .replaceComponentText (text .copy (),
25+ RegExUtils .getOrCompilePattern (Pattern .quote (playerName )), nickname );
26+ if (result != null && !"ERROR" .equals (result .getString ())) {
27+ text = result ;
28+ } else {
29+ LoggerUtils .error ("[ChatTools] ERROR was returned on nick-hiding this text: " + text + ", let's show it raw..." );
30+ text = original ;
31+ }
2432 } catch (Exception e ) {
2533 LoggerUtils .error ("[ChatTools] Error occurred on nick-hiding this text: " + text + ", let's show it raw..." );
2634 e .printStackTrace ();
35+ text = original ;
2736 }
2837 }).setMaxLimitPerSecond (() -> ((Number ) ConfigUtils .get ("general.CircuitBreaker.NickHiderThreshold" )).intValue ())
2938 .setFailsafeFunction (() -> {
You can’t perform that action at this time.
0 commit comments