@@ -65,55 +65,6 @@ public Style style(ParserContext context) {
6565 case RUN_COMMAND -> style = style .withClickEvent (new ClickEvent .RunCommand (node ));
6666 case SUGGEST_COMMAND -> style = style .withClickEvent (new ClickEvent .SuggestCommand (node ));
6767 case COPY_TO_CLIPBOARD -> style = style .withClickEvent (new ClickEvent .CopyToClipboard (node ));
68- case CUSTOM -> {
69- try {
70- RegistryWrapper .WrapperLookup wrapper ;
71- if (context .contains (ParserContext .Key .WRAPPER_LOOKUP )) {
72- wrapper = context .getOrThrow (ParserContext .Key .WRAPPER_LOOKUP );
73- } else if (context .contains (PlaceholderContext .KEY )) {
74- wrapper = context .getOrThrow (PlaceholderContext .KEY ).server ().getRegistryManager ();
75- } else {
76- wrapper = GeneralUtils .DEFAULT_WRAPPER ;
77- }
78-
79- style = style .withClickEvent (new ClickEvent .Custom (
80- Identifier .of (node ),
81- /*this.data == null ?*/ Optional .empty () //: Optional.of(StringNbtReader.fromOps(wrapper.getOps(NbtOps.INSTANCE)).read(this.data.toText(context).getString()))
82- ));
83- } catch (Throwable e ) {
84- // ignore
85- }
86-
87- }
88- case SHOW_DIALOG -> {
89- RegistryWrapper .WrapperLookup wrapper ;
90- if (context .contains (ParserContext .Key .WRAPPER_LOOKUP )) {
91- wrapper = context .getOrThrow (ParserContext .Key .WRAPPER_LOOKUP );
92- } else if (context .contains (PlaceholderContext .KEY )) {
93- wrapper = context .getOrThrow (PlaceholderContext .KEY ).server ().getRegistryManager ();
94- } else {
95- wrapper = GeneralUtils .DEFAULT_WRAPPER ;
96- }
97- RegistryEntry <Dialog > dialogRegistryEntry = null ;
98-
99- var id = Identifier .tryParse (node );
100-
101- if (id != null ) {
102- dialogRegistryEntry = wrapper .getOptionalEntry (RegistryKey .of (RegistryKeys .DIALOG , id )).orElse (null );
103- }
104-
105- if (dialogRegistryEntry == null ) {
106- try {
107- dialogRegistryEntry = Dialog .ENTRY_CODEC .decode (
108- wrapper .getOps (JsonOps .INSTANCE ), JsonParser .parseString (node )).getOrThrow ().getFirst ();
109- } catch (Throwable e ) {
110- // ignored
111- }
112- }
113- if (dialogRegistryEntry != null ) {
114- style = style .withClickEvent (new ClickEvent .ShowDialog (dialogRegistryEntry ));
115- }
116- }
11768 }
11869 }
11970
0 commit comments