1616import pl .olafcio .avoid_impl .net .chat .converter .COToNative ;
1717import pl .olafcio .avoid_impl .net .id .IdentificationNative ;
1818
19+ import java .lang .reflect .AnnotatedElement ;
1920import java .lang .reflect .Constructor ;
2021import java .lang .reflect .InvocationTargetException ;
2122import java .util .Collections ;
@@ -32,6 +33,38 @@ private Advancements() {}
3233 public static final HashMap <Identifier , Advancement > ADVANCEMENTS
3334 = new HashMap <>();
3435
36+ public static void register (Identification id , Supplier <? extends pl .olafcio .avoid .net .advancement .Advancement > advancement , AnnotatedElement config ) {
37+ var display = config .getDeclaredAnnotation (_display .class );
38+ var type = config .getDeclaredAnnotation (_type .class )
39+ .value ();
40+
41+ ADVANCEMENTS .put (IdentificationNative .convert (id ), new Advancement (
42+ config .isAnnotationPresent (_parent .class )
43+ ? IdentificationNative .convertOptional (
44+ config .getDeclaredAnnotation (_parent .class )
45+ .id ()
46+ )
47+ : Optional .empty (),
48+ Optional .of (new DisplayInfo (
49+ BuiltInRegistries .ITEM .get (IdentificationNative .convert (display .icon ())).orElseThrow ().value ().getDefaultInstance (),
50+ COToNative .from (Components .Parse .minimessage (display .title ())),
51+ COToNative .from (Components .Parse .minimessage (display .description ())),
52+ IdentificationNative .convertOptional (display .background ())
53+ .map (ClientAsset .ResourceTexture ::new ),
54+ type == AdvancementType .GOAL ? net .minecraft .advancements .AdvancementType .GOAL :
55+ type == AdvancementType .TASK ? net .minecraft .advancements .AdvancementType .TASK :
56+ net .minecraft .advancements .AdvancementType .CHALLENGE ,
57+ display .showToast (),
58+ display .announceChat (),
59+ display .hidden ()
60+ )),
61+ AdvancementRewards .EMPTY ,
62+ Map .of ("toggle" , new Criterion <>(CriteriaTriggers .IMPOSSIBLE , new ImpossibleTrigger .TriggerInstance ())),
63+ AdvancementRequirements .anyOf (Collections .singleton ("toggle" )),
64+ false
65+ ));
66+ }
67+
3568 public static void register (Identification id , Class <? extends pl .olafcio .avoid .net .advancement .Advancement > advancement ) {
3669 var display = advancement .getDeclaredAnnotation (_display .class );
3770 var type = advancement .getDeclaredAnnotation (_type .class )
0 commit comments