11package com .cyr1en .commandprompter .config ;
22
3+ import com .cyr1en .commandprompter .api .prompt .InputValidator ;
34import com .cyr1en .commandprompter .config .annotations .field .*;
45import com .cyr1en .commandprompter .config .annotations .type .ConfigHeader ;
56import com .cyr1en .commandprompter .config .annotations .type .ConfigPath ;
67import com .cyr1en .commandprompter .config .annotations .type .Configuration ;
78import com .cyr1en .commandprompter .prompt .ui .CacheFilter ;
9+ import com .cyr1en .commandprompter .prompt .validators .NoopValidator ;
10+ import com .cyr1en .commandprompter .prompt .validators .OnlinePlayerValidator ;
11+ import com .cyr1en .commandprompter .prompt .validators .RegexValidator ;
812import com .cyr1en .kiso .mc .configuration .base .Config ;
913
14+ import java .util .regex .Pattern ;
15+
1016@ Configuration
1117@ ConfigPath ("prompt-config.yml" )
1218@ ConfigHeader ({"Prompts" , "Configuration" })
@@ -21,6 +27,8 @@ public record PromptConfig(
2127 "PlayerUI formatting" , "" ,
2228 "Skull-Name-Format - The display name format" ,
2329 " for the player heads" , "" ,
30+ "Skull-Custom-Model-Data - The custom model data for the" ,
31+ " player heads" , "" ,
2432 "Size - the size of the UI (multiple of 9, between 18-54)" , "" ,
2533 "Cache-Size - Size for the head cache" , "" ,
2634 "Cache-Delay - Delay in ticks after the player" , "" ,
@@ -33,6 +41,11 @@ public record PromptConfig(
3341 })
3442 String skullNameFormat ,
3543
44+ @ ConfigNode
45+ @ NodeName ("PlayerUI.Skull-Custom-Model-Data" )
46+ @ NodeDefault ("0" )
47+ int skullCustomModelData ,
48+
3649 @ ConfigNode
3750 @ NodeName ("PlayerUI.Size" )
3851 @ NodeDefault ("54" )
@@ -287,20 +300,28 @@ public record PromptConfig(
287300 String strSampleErrMessage
288301
289302) implements AliasedSection {
290- public String findIVRegexCheckInConfig (String alias ) {
303+ private String findIVRegexCheckInConfig (String alias ) {
291304 return getIVValue ("Alias" , alias , "Regex" );
292305 }
293306
294- public String getIVErrMessage (String alias ) {
307+ private String getIVErrMessage (String alias ) {
295308 return getIVValue ("Alias" , alias , "Err-Message" );
296309 }
297310
298- public String getIVErrMessageWithRegex (String regex ) {
299- return getIVValue ( "Regex " , regex , "Err-Message" );
311+ private String getIVValue (String key , String keyVal , String query ) {
312+ return getInputValidationValue ( "Input-Validation " , key , keyVal , query );
300313 }
301314
302- public String getIVValue (String key , String keyVal , String query ) {
303- return getInputValidationValue ("Input-Validation" , key , keyVal , query );
315+ public InputValidator getInputValidator (String alias ) {
316+ if (alias == null || alias .isBlank ())
317+ return new NoopValidator ();
318+ var isPlayer = Boolean .parseBoolean (getIVValue ("Alias" , alias , "Online-Player" ));
319+ if (isPlayer )
320+ return new OnlinePlayerValidator (alias , getIVErrMessage (alias ));
321+ var regex = findIVRegexCheckInConfig (alias );
322+ if (regex != null && !regex .isBlank ())
323+ return new RegexValidator (alias , Pattern .compile (regex ), getIVErrMessage (alias ));
324+ return new NoopValidator ();
304325 }
305326
306327 /**
0 commit comments