99import com .bitaspire .sir .channel .Logging ;
1010import com .bitaspire .sir .channel .Style ;
1111import com .bitaspire .sir .module .channel .channel .Resolver ;
12- import com .bitaspire .sir .user .ColorData ;
1312import com .bitaspire .sir .user .SIRUser ;
14- import lombok .AccessLevel ;
15- import lombok .Getter ;
16- import lombok .RequiredArgsConstructor ;
17- import lombok .Setter ;
13+ import lombok .*;
14+ import lombok .experimental .Accessors ;
1815import lombok .experimental .UtilityClass ;
1916import me .croabeast .common .CollectionBuilder ;
2017import me .croabeast .common .applier .StringApplier ;
@@ -59,6 +56,8 @@ abstract class BaseChannel implements ChatChannel {
5956
6057 private final String permission ;
6158 private final int priority ;
59+ @ Accessors (fluent = true )
60+ private final boolean relayToDiscord ;
6261
6362 private final Access access ;
6463 private final Audience audience ;
@@ -85,6 +84,7 @@ abstract class BaseChannel implements ChatChannel {
8584 "priority" , ChatChannel ::getPriority ,
8685 permission .matches ("(?i)DEFAULT" ) ? 0 : 1
8786 );
87+ relayToDiscord = fromParent ("relay-to-discord" , ChatChannel ::relayToDiscord , false );
8888
8989 access = new AccessImpl (
9090 fromParent ("access.default" , c -> c .getAccess ().isDefault (), false ),
@@ -110,6 +110,7 @@ abstract class BaseChannel implements ChatChannel {
110110 fromParent ("color-options.normal" , c -> c .getStyle ().allowsNormalColors (), false ),
111111 fromParent ("color-options.special" , c -> c .getStyle ().allowsSpecialColors (), false ),
112112 fromParent ("color-options.rgb" , c -> c .getStyle ().allowsRgbColors (), false ),
113+ fromParent ("color-options.mini-message" , c -> c .getStyle ().allowsMiniMessage (), false ),
113114 clickAction (),
114115 fromList ("hover" , c -> c .getStyle ().getHover ()),
115116 fromParent ("format" , c -> c .getStyle ().getFormat (), DEFAULT_FORMAT ).trim ()
@@ -118,7 +119,8 @@ abstract class BaseChannel implements ChatChannel {
118119 checker = new ColorChecker (
119120 style .allowsNormalColors (),
120121 style .allowsSpecialColors (),
121- style .allowsRgbColors ()
122+ style .allowsRgbColors (),
123+ style .allowsMiniMessage ()
122124 );
123125
124126 logging = new LoggingImpl (
@@ -127,12 +129,6 @@ abstract class BaseChannel implements ChatChannel {
127129 );
128130 }
129131
130- @ NotNull
131- @ Override
132- public String getName () {
133- return name ;
134- }
135-
136132 private boolean useParents (String path ) {
137133 return !section .isSet (path ) && parent != null ;
138134 }
@@ -282,18 +278,12 @@ public String[] getChatValues(SIRUser user, String message) {
282278
283279 @ NotNull
284280 private String chatColorStart (@ Nullable SIRUser user ) {
285- if (user == null ) return "" ;
286-
287- ColorData data = user .getColorData ();
288- return data == null ? "" : StringUtils .defaultString (data .getStart ());
281+ return user == null ? "" : StringUtils .defaultString (user .getColorData ().getStart ());
289282 }
290283
291284 @ NotNull
292285 private String chatColorEnd (@ Nullable SIRUser user ) {
293- if (user == null ) return "" ;
294-
295- ColorData data = user .getColorData ();
296- return data == null ? "" : StringUtils .defaultString (data .getEnd ());
286+ return user == null ? "" : StringUtils .defaultString (user .getColorData ().getEnd ());
297287 }
298288
299289 private boolean hasPermission (SIRUser user , String permission ) {
@@ -340,12 +330,13 @@ public String toString() {
340330 return "BaseChannel{path=" + section .getCurrentPath () +
341331 ", permission='" + permission + '\'' +
342332 ", priority=" + priority + ", global=" + global +
333+ ", relayToDiscord=" + relayToDiscord +
343334 ", format='" + style .getFormat () + '\'' + '}' ;
344335 }
345336 }
346337
347- @ Getter
348338 @ RequiredArgsConstructor
339+ @ Getter
349340 class AccessImpl implements Access {
350341
351342 private final boolean defaultAccess ;
@@ -372,8 +363,8 @@ public String toString() {
372363 }
373364 }
374365
375- @ Getter
376366 @ RequiredArgsConstructor
367+ @ Getter
377368 class AudienceImpl implements Audience {
378369
379370 private final int radius ;
@@ -399,8 +390,8 @@ public String toString() {
399390 }
400391 }
401392
402- @ Getter
403393 @ RequiredArgsConstructor
394+ @ Getter
404395 class ClickImpl implements Click {
405396
406397 private final ChatComponent .Click action ;
@@ -424,6 +415,7 @@ public String toString() {
424415 }
425416 }
426417
418+ @ AllArgsConstructor
427419 @ Getter
428420 class StyleImpl implements Style {
429421
@@ -434,36 +426,13 @@ class StyleImpl implements Style {
434426 private final boolean normalColors ;
435427 private final boolean specialColors ;
436428 private final boolean rgbColors ;
429+ private final boolean miniMessage ;
437430 private final Click click ;
438431 private final List <String > hover ;
439432
440433 @ Setter
441434 private String format ;
442435
443- private StyleImpl (
444- String tag ,
445- String prefix ,
446- String suffix ,
447- String color ,
448- boolean normalColors ,
449- boolean specialColors ,
450- boolean rgbColors ,
451- Click click ,
452- List <String > hover ,
453- String format
454- ) {
455- this .tag = tag ;
456- this .prefix = prefix ;
457- this .suffix = suffix ;
458- this .color = color ;
459- this .normalColors = normalColors ;
460- this .specialColors = specialColors ;
461- this .rgbColors = rgbColors ;
462- this .click = click ;
463- this .hover = hover ;
464- this .format = format ;
465- }
466-
467436 @ Override
468437 public boolean allowsNormalColors () {
469438 return normalColors ;
@@ -479,6 +448,11 @@ public boolean allowsRgbColors() {
479448 return rgbColors ;
480449 }
481450
451+ @ Override
452+ public boolean allowsMiniMessage () {
453+ return miniMessage ;
454+ }
455+
482456 @ Override
483457 public String toString () {
484458 return "Style{tag='" + tag + '\'' +
@@ -488,12 +462,13 @@ public String toString() {
488462 ", normal=" + normalColors +
489463 ", special=" + specialColors +
490464 ", rgb=" + rgbColors +
465+ ", miniMessage=" + miniMessage +
491466 ", format='" + format + '\'' + '}' ;
492467 }
493468 }
494469
495- @ Getter
496470 @ RequiredArgsConstructor
471+ @ Getter
497472 class LoggingImpl implements Logging {
498473
499474 private final boolean enabled ;
@@ -509,7 +484,7 @@ public String toString() {
509484 class ColorChecker {
510485
511486 static final String PERM = "sir.color.chat." ;
512- final boolean normal , special , rgb ;
487+ final boolean normal , special , rgb , miniMessage ;
513488
514489 boolean notColor (Player player , String perm ) {
515490 boolean allowed ;
@@ -520,6 +495,9 @@ boolean notColor(Player player, String perm) {
520495 case "rgb" :
521496 allowed = rgb ;
522497 break ;
498+ case "mini-message" :
499+ allowed = miniMessage ;
500+ break ;
523501 case "normal" :
524502 default :
525503 allowed = normal ;
@@ -538,13 +516,16 @@ String check(Player player, String string) {
538516 applier .apply (PrismaticAPI ::stripRGB );
539517 if (notColor (player , "special" ))
540518 applier .apply (PrismaticAPI ::stripSpecial );
519+ if (notColor (player , "mini-message" ))
520+ applier .apply (PrismaticAPI ::stripMiniMessage );
541521
542522 return applier .toString ();
543523 }
544524
545525 @ Override
546526 public String toString () {
547- return "ColorChecker{normal=" + normal + ", special=" + special + ", rgb=" + rgb + '}' ;
527+ return "ColorChecker{normal=" + normal + ", special=" + special +
528+ ", rgb=" + rgb + ", miniMessage=" + miniMessage + '}' ;
548529 }
549530 }
550531}
0 commit comments