1919import eu .pb4 .styledchat .config .data .VersionedChatStyleData ;
2020import eu .pb4 .styledchat .ducks .ExtPlayNetworkHandler ;
2121import eu .pb4 .styledchat .ducks .ExtPlayerChatMessage ;
22+ import eu .pb4 .styledchat .other .FabricPermissionBridge ;
2223import eu .pb4 .styledchat .parser .LinkParser ;
2324import eu .pb4 .styledchat .parser .MentionParser ;
2425import eu .pb4 .styledchat .parser .SpoilerNode ;
25- import me .lucko .fabric .api .permissions .v0 .Permissions ;
26- import net .fabricmc .fabric .api .event .lifecycle .v1 .ServerLifecycleEvents ;
2726import net .minecraft .ChatFormatting ;
2827import net .minecraft .commands .CommandSourceStack ;
2928import net .minecraft .commands .arguments .selector .EntitySelector ;
3635import net .minecraft .network .chat .TextColor ;
3736import net .minecraft .network .chat .contents .PlainTextContents ;
3837import net .minecraft .network .protocol .game .ClientboundCustomChatCompletionsPacket ;
38+ import net .minecraft .resources .Identifier ;
3939import net .minecraft .resources .ResourceKey ;
4040import net .minecraft .server .level .ServerPlayer ;
41+ import net .minecraft .server .permissions .PermissionLevel ;
4142import net .minecraft .world .scores .PlayerTeam ;
4243import org .jetbrains .annotations .Nullable ;
4344
@@ -60,8 +61,8 @@ public final class StyledChatUtils {
6061 public static JsonDataStorage <VersionedChatStyleData > PLAYER_DATA = new JsonDataStorage <>("styled_chat_style" , VersionedChatStyleData .class );
6162 public static final TextTag SPOILER_TEXT_TAG_NEW = TextTag .enclosing (SPOILER_TAG , List .of ("hide" ), "styledchat" , true , ((nodes , arg , parser ) -> new SpoilerNode (nodes )));
6263
63- public static final String FORMAT_PERMISSION_BASE = "styledchat. format. " ;
64- public static final String FORMAT_PERMISSION_UNSAFE = "styledchat. unsafe_format. " ;
64+ public static final String FORMAT_PERMISSION_BASE = "format/ " ;
65+ public static final String FORMAT_PERMISSION_UNSAFE = "unsafe_format/ " ;
6566
6667
6768 public static final TagLikeParser .Format EMOTE_FORMAT = TagLikeParser .Format .of (':' , ':' );
@@ -119,6 +120,10 @@ public static NodeParser createParser(ServerPlaceholderContext context) {
119120 form .add (MarkdownLiteParserV1 .MarkdownFormat .URL );
120121 }
121122
123+ if (tags .getTag ("quote" ) != null ) {
124+ form .add (MarkdownLiteParserV1 .MarkdownFormat .QUOTE );
125+ }
126+
122127 builder .markdown (SpoilerNode ::new , MarkdownLiteParserV1 ::defaultQuoteFormatting , MarkdownLiteParserV1 ::defaultUrlFormatting ,
123128 form .toArray (new MarkdownLiteParserV1 .MarkdownFormat [0 ]));
124129 }
@@ -155,15 +160,15 @@ public static TagRegistry getTextTagRegistry(CommandSourceStack source) {
155160
156161 for (var entry : TagRegistry .DEFAULT .getTags ()) {
157162 if (allowedFormatting .getBoolean (entry .name ())
158- || Permissions . check (source , ( entry .userSafe () ? FORMAT_PERMISSION_BASE : FORMAT_PERMISSION_UNSAFE ) + entry .name (), entry .userSafe () ? 2 : 4 )
159- || Permissions . check (source , ( entry .userSafe () ? FORMAT_PERMISSION_BASE : FORMAT_PERMISSION_UNSAFE ) + ". type. " + entry .type (), entry .userSafe () ? 2 : 4 )
163+ || FabricPermissionBridge . checkPermission (source , id (( entry .userSafe () ? FORMAT_PERMISSION_BASE : FORMAT_PERMISSION_UNSAFE ) + entry .name ()) , entry .userSafe () ? PermissionLevel . GAMEMASTERS : PermissionLevel . ADMINS )
164+ || FabricPermissionBridge . checkPermission (source , id (( entry .userSafe () ? FORMAT_PERMISSION_BASE : FORMAT_PERMISSION_UNSAFE ) + "type/ " + entry .type ()) , entry .userSafe () ? PermissionLevel . GAMEMASTERS : PermissionLevel . ADMINS )
160165 ) {
161166 registry .register (entry );
162167 }
163168 }
164169
165170 if (allowedFormatting .getBoolean (SPOILER_TAG )
166- || Permissions . check (source , FORMAT_PERMISSION_BASE + SPOILER_TAG , 2 )) {
171+ || FabricPermissionBridge . checkPermission (source , id ( FORMAT_PERMISSION_BASE + SPOILER_TAG ), PermissionLevel . GAMEMASTERS )) {
167172 registry .register (SPOILER_TEXT_TAG_NEW );
168173 }
169174
@@ -471,4 +476,8 @@ public static ChatStyle createStyleOf(ServerPlayer player) {
471476 public static ChatType .Bound createParameters (Component override ) {
472477 return ChatType .bind (StyledChatMod .MESSAGE_TYPE_ID , StyledChatMod .server .registryAccess (), override );
473478 }
479+
480+ public static Identifier id (String path ) {
481+ return Identifier .fromNamespaceAndPath ("styledchat" , path );
482+ }
474483}
0 commit comments