("maven") {
76 | groupId = rootProject.group.toString()
77 | artifactId = rootProject.name
78 | version = rootProject.version.toString()
79 | from(project.components["java"])
80 | }
81 | }
82 | }
--------------------------------------------------------------------------------
/docs/allpackages-index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | All Packages
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
21 |
22 | JavaScript is disabled on your browser.
23 |
24 |
25 |
48 |
49 |
50 |
53 | Package Summary
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
--------------------------------------------------------------------------------
/docs/element-list:
--------------------------------------------------------------------------------
1 | org.lushplugins.chatcolorhandler
2 | org.lushplugins.chatcolorhandler.parsers
3 | org.lushplugins.chatcolorhandler.parsers.custom
4 |
--------------------------------------------------------------------------------
/docs/index-files/index-1.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | A-Index
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
21 |
22 | JavaScript is disabled on your browser.
23 |
24 |
62 |
63 |
64 |
--------------------------------------------------------------------------------
/docs/index-files/index-10.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | O-Index
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
21 |
22 | JavaScript is disabled on your browser.
23 |
24 |
70 |
71 |
72 |
--------------------------------------------------------------------------------
/docs/index-files/index-2.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | B-Index
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
21 |
22 | JavaScript is disabled on your browser.
23 |
24 |
68 |
69 |
70 |
--------------------------------------------------------------------------------
/docs/index-files/index-3.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | C-Index
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
21 |
22 | JavaScript is disabled on your browser.
23 |
24 |
66 |
67 |
68 |
--------------------------------------------------------------------------------
/docs/index-files/index-4.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | D-Index
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
21 |
22 | JavaScript is disabled on your browser.
23 |
24 |
62 |
63 |
64 |
--------------------------------------------------------------------------------
/docs/index-files/index-6.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | H-Index
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
21 |
22 | JavaScript is disabled on your browser.
23 |
24 |
62 |
63 |
64 |
--------------------------------------------------------------------------------
/docs/index-files/index-7.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | I-Index
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
21 |
22 | JavaScript is disabled on your browser.
23 |
24 |
86 |
87 |
88 |
--------------------------------------------------------------------------------
/docs/index-files/index-8.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | L-Index
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
21 |
22 | JavaScript is disabled on your browser.
23 |
24 |
64 |
65 |
66 |
--------------------------------------------------------------------------------
/docs/index-files/index-9.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | M-Index
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
21 |
22 | JavaScript is disabled on your browser.
23 |
24 |
76 |
77 |
78 |
--------------------------------------------------------------------------------
/docs/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Overview
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
21 |
22 | JavaScript is disabled on your browser.
23 |
24 |
25 |
48 |
49 |
50 |
51 |
Packages
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
--------------------------------------------------------------------------------
/docs/jquery-ui.overrides.css:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2020, 2022, Oracle and/or its affiliates. All rights reserved.
3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 | *
5 | * This code is free software; you can redistribute it and/or modify it
6 | * under the terms of the GNU General Public License version 2 only, as
7 | * published by the Free Software Foundation. Oracle designates this
8 | * particular file as subject to the "Classpath" exception as provided
9 | * by Oracle in the LICENSE file that accompanied this code.
10 | *
11 | * This code is distributed in the hope that it will be useful, but WITHOUT
12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 | * version 2 for more details (a copy is included in the LICENSE file that
15 | * accompanied this code).
16 | *
17 | * You should have received a copy of the GNU General Public License version
18 | * 2 along with this work; if not, write to the Free Software Foundation,
19 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 | *
21 | * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 | * or visit www.oracle.com if you need additional information or have any
23 | * questions.
24 | */
25 |
26 | .ui-state-active,
27 | .ui-widget-content .ui-state-active,
28 | .ui-widget-header .ui-state-active,
29 | a.ui-button:active,
30 | .ui-button:active,
31 | .ui-button.ui-state-active:hover {
32 | /* Overrides the color of selection used in jQuery UI */
33 | background: #F8981D;
34 | border: 1px solid #F8981D;
35 | }
36 |
--------------------------------------------------------------------------------
/docs/legal/ADDITIONAL_LICENSE_INFO:
--------------------------------------------------------------------------------
1 | Please see ..\java.base\ADDITIONAL_LICENSE_INFO
2 |
--------------------------------------------------------------------------------
/docs/legal/ASSEMBLY_EXCEPTION:
--------------------------------------------------------------------------------
1 | Please see ..\java.base\ASSEMBLY_EXCEPTION
2 |
--------------------------------------------------------------------------------
/docs/legal/LICENSE:
--------------------------------------------------------------------------------
1 | Please see ..\java.base\LICENSE
2 |
--------------------------------------------------------------------------------
/docs/legal/jquery.md:
--------------------------------------------------------------------------------
1 | ## jQuery v3.6.1
2 |
3 | ### jQuery License
4 | ```
5 | jQuery v 3.6.1
6 | Copyright OpenJS Foundation and other contributors, https://openjsf.org/
7 |
8 | Permission is hereby granted, free of charge, to any person obtaining
9 | a copy of this software and associated documentation files (the
10 | "Software"), to deal in the Software without restriction, including
11 | without limitation the rights to use, copy, modify, merge, publish,
12 | distribute, sublicense, and/or sell copies of the Software, and to
13 | permit persons to whom the Software is furnished to do so, subject to
14 | the following conditions:
15 |
16 | The above copyright notice and this permission notice shall be
17 | included in all copies or substantial portions of the Software.
18 |
19 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
20 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
21 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
22 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
23 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
24 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
25 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
26 |
27 | ******************************************
28 |
29 | The jQuery JavaScript Library v3.6.1 also includes Sizzle.js
30 |
31 | Sizzle.js includes the following license:
32 |
33 | Copyright JS Foundation and other contributors, https://js.foundation/
34 |
35 | This software consists of voluntary contributions made by many
36 | individuals. For exact contribution history, see the revision history
37 | available at https://github.com/jquery/sizzle
38 |
39 | The following license applies to all parts of this software except as
40 | documented below:
41 |
42 | ====
43 |
44 | Permission is hereby granted, free of charge, to any person obtaining
45 | a copy of this software and associated documentation files (the
46 | "Software"), to deal in the Software without restriction, including
47 | without limitation the rights to use, copy, modify, merge, publish,
48 | distribute, sublicense, and/or sell copies of the Software, and to
49 | permit persons to whom the Software is furnished to do so, subject to
50 | the following conditions:
51 |
52 | The above copyright notice and this permission notice shall be
53 | included in all copies or substantial portions of the Software.
54 |
55 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
56 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
57 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
58 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
59 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
60 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
61 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
62 |
63 | ====
64 |
65 | All files located in the node_modules and external directories are
66 | externally maintained libraries used by this software which have their
67 | own licenses; we recommend you read them, as their terms may differ from
68 | the terms above.
69 |
70 | *********************
71 |
72 | ```
73 |
--------------------------------------------------------------------------------
/docs/legal/jqueryUI.md:
--------------------------------------------------------------------------------
1 | ## jQuery UI v1.13.2
2 |
3 | ### jQuery UI License
4 | ```
5 | Copyright jQuery Foundation and other contributors, https://jquery.org/
6 |
7 | This software consists of voluntary contributions made by many
8 | individuals. For exact contribution history, see the revision history
9 | available at https://github.com/jquery/jquery-ui
10 |
11 | The following license applies to all parts of this software except as
12 | documented below:
13 |
14 | ====
15 |
16 | Permission is hereby granted, free of charge, to any person obtaining
17 | a copy of this software and associated documentation files (the
18 | "Software"), to deal in the Software without restriction, including
19 | without limitation the rights to use, copy, modify, merge, publish,
20 | distribute, sublicense, and/or sell copies of the Software, and to
21 | permit persons to whom the Software is furnished to do so, subject to
22 | the following conditions:
23 |
24 | The above copyright notice and this permission notice shall be
25 | included in all copies or substantial portions of the Software.
26 |
27 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
28 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
29 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
30 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
31 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
32 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
33 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
34 |
35 | ====
36 |
37 | Copyright and related rights for sample code are waived via CC0. Sample
38 | code is defined as all source code contained within the demos directory.
39 |
40 | CC0: http://creativecommons.org/publicdomain/zero/1.0/
41 |
42 | ====
43 |
44 | All files located in the node_modules and external directories are
45 | externally maintained libraries used by this software which have their
46 | own licenses; we recommend you read them, as their terms may differ from
47 | the terms above.
48 |
49 | ```
50 |
--------------------------------------------------------------------------------
/docs/module-search-index.js:
--------------------------------------------------------------------------------
1 | moduleSearchIndex = [];updateSearchResults();
--------------------------------------------------------------------------------
/docs/org/lushplugins/chatcolorhandler/package-summary.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | org.lushplugins.chatcolorhandler
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
21 |
22 | JavaScript is disabled on your browser.
23 |
24 |
25 |
56 |
57 |
58 |
61 |
62 | package org.lushplugins.chatcolorhandler
63 |
64 |
65 |
66 |
75 |
76 |
77 |
78 |
Classes
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
--------------------------------------------------------------------------------
/docs/org/lushplugins/chatcolorhandler/package-tree.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | org.lushplugins.chatcolorhandler Class Hierarchy
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
21 |
22 | JavaScript is disabled on your browser.
23 |
24 |
25 |
48 |
49 |
50 |
57 |
58 | Class Hierarchy
59 |
60 | java.lang.Object
61 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
--------------------------------------------------------------------------------
/docs/org/lushplugins/chatcolorhandler/parsers/custom/Parser.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Parser
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
25 |
26 | JavaScript is disabled on your browser.
27 |
28 |
29 |
68 |
69 |
70 |
71 |
75 |
83 |
84 |
85 |
86 |
87 |
88 | Method Summary
89 |
90 |
All Methods Instance Methods Abstract Methods
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 |
110 |
111 |
112 |
113 |
114 |
115 | Method Details
116 |
117 |
118 |
119 | parseString
120 |
121 |
122 |
123 |
124 |
125 | parseString
126 | String parseString (String string,
127 | org.bukkit.entity.Player player)
128 |
129 |
130 |
131 |
132 |
133 |
134 |
135 |
136 |
137 |
138 |
139 |
140 |
141 |
--------------------------------------------------------------------------------
/docs/org/lushplugins/chatcolorhandler/parsers/custom/package-summary.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | org.lushplugins.chatcolorhandler.parsers.custom
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
21 |
22 | JavaScript is disabled on your browser.
23 |
24 |
25 |
56 |
57 |
58 |
61 |
62 | package org.lushplugins.chatcolorhandler.parsers.custom
63 |
64 |
65 |
66 |
75 |
76 |
77 |
78 |
Classes
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 |
110 |
111 |
112 |
--------------------------------------------------------------------------------
/docs/org/lushplugins/chatcolorhandler/parsers/custom/package-tree.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | org.lushplugins.chatcolorhandler.parsers.custom Class Hierarchy
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
21 |
22 | JavaScript is disabled on your browser.
23 |
24 |
25 |
48 |
49 |
50 |
57 |
58 | Class Hierarchy
59 |
60 | java.lang.Object
61 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
--------------------------------------------------------------------------------
/docs/org/lushplugins/chatcolorhandler/parsers/package-summary.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | org.lushplugins.chatcolorhandler.parsers
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
25 |
26 | JavaScript is disabled on your browser.
27 |
28 |
29 |
60 |
61 |
62 |
65 |
66 | package org.lushplugins.chatcolorhandler.parsers
67 |
68 |
69 |
70 |
81 |
82 |
83 |
84 |
All Classes and Interfaces Interfaces Classes Enum Classes
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 |
110 |
--------------------------------------------------------------------------------
/docs/org/lushplugins/chatcolorhandler/parsers/package-tree.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | org.lushplugins.chatcolorhandler.parsers Class Hierarchy
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
21 |
22 | JavaScript is disabled on your browser.
23 |
24 |
25 |
48 |
49 |
50 |
57 |
58 | Class Hierarchy
59 |
60 | java.lang.Object
61 |
62 | org.lushplugins.chatcolorhandler.parsers.Parsers
63 | org.lushplugins.chatcolorhandler.parsers.ParserTypes
64 |
65 |
66 |
67 |
68 |
69 | Interface Hierarchy
70 |
71 | org.lushplugins.chatcolorhandler.parsers.Parser
72 |
73 | org.lushplugins.chatcolorhandler.parsers.Resolver
74 |
75 |
76 |
77 |
78 |
79 | Enum Class Hierarchy
80 |
81 | java.lang.Object
82 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
--------------------------------------------------------------------------------
/docs/org/lushplugins/chatcolorhandler/resolvers/Resolver.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Resolver
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
25 |
26 | JavaScript is disabled on your browser.
27 |
28 |
29 |
68 |
69 |
70 |
71 |
75 |
83 |
84 |
85 |
86 |
87 |
88 | Method Summary
89 |
90 |
All Methods Instance Methods Abstract Methods Default Methods
91 |
92 |
93 |
94 |
95 |
96 |
@NotNull net.kyori.adventure.text.minimessage.tag.resolver.TagResolver
97 |
98 |
99 |
default @NotNull net.kyori.adventure.text.minimessage.tag.resolver.TagResolver
100 |
getResolver (net.kyori.adventure.audience.Audience audience)
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 |
110 |
111 |
112 |
113 |
114 | Method Details
115 |
116 |
117 |
118 | getResolver
119 | @NotNull
120 | @NotNull net.kyori.adventure.text.minimessage.tag.resolver.TagResolver getResolver ()
121 |
122 |
123 |
124 |
125 | getResolver
126 | @NotNull
127 | default @NotNull net.kyori.adventure.text.minimessage.tag.resolver.TagResolver getResolver (net.kyori.adventure.audience.Audience audience)
128 |
129 |
130 |
131 |
132 |
133 |
134 |
135 |
136 |
137 |
138 |
139 |
140 |
141 |
--------------------------------------------------------------------------------
/docs/org/lushplugins/chatcolorhandler/resolvers/package-summary.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | org.lushplugins.chatcolorhandler.resolvers
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
25 |
26 | JavaScript is disabled on your browser.
27 |
28 |
29 |
61 |
62 |
63 |
66 |
67 | package org.lushplugins.chatcolorhandler.resolvers
68 |
69 |
70 |
71 |
82 |
83 |
84 |
85 |
All Classes and Interfaces Interfaces Classes
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
--------------------------------------------------------------------------------
/docs/org/lushplugins/chatcolorhandler/resolvers/package-tree.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | org.lushplugins.chatcolorhandler.resolvers Class Hierarchy
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
21 |
22 | JavaScript is disabled on your browser.
23 |
24 |
25 |
49 |
50 |
51 |
58 |
59 | Class Hierarchy
60 |
61 | java.lang.Object
62 |
66 |
67 |
68 |
69 |
70 | Interface Hierarchy
71 |
72 | org.lushplugins.chatcolorhandler.resolvers.Resolver
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
--------------------------------------------------------------------------------
/docs/overview-summary.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Generated Documentation (Untitled)
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 | JavaScript is disabled on your browser.
22 |
23 | index.html
24 |
25 |
26 |
27 |
--------------------------------------------------------------------------------
/docs/package-search-index.js:
--------------------------------------------------------------------------------
1 | packageSearchIndex = [{"l":"All Packages","u":"allpackages-index.html"},{"l":"org.lushplugins.chatcolorhandler"},{"l":"org.lushplugins.chatcolorhandler.parsers"},{"l":"org.lushplugins.chatcolorhandler.parsers.custom"}];updateSearchResults();
--------------------------------------------------------------------------------
/docs/resources/glass.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/OakLoaf/ChatColorHandler/85179056ed3b74d1827558ba4c6fd650ae5d7058/docs/resources/glass.png
--------------------------------------------------------------------------------
/docs/resources/x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/OakLoaf/ChatColorHandler/85179056ed3b74d1827558ba4c6fd650ae5d7058/docs/resources/x.png
--------------------------------------------------------------------------------
/docs/script-dir/images/ui-bg_glass_55_fbf9ee_1x400.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/OakLoaf/ChatColorHandler/85179056ed3b74d1827558ba4c6fd650ae5d7058/docs/script-dir/images/ui-bg_glass_55_fbf9ee_1x400.png
--------------------------------------------------------------------------------
/docs/script-dir/images/ui-bg_glass_65_dadada_1x400.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/OakLoaf/ChatColorHandler/85179056ed3b74d1827558ba4c6fd650ae5d7058/docs/script-dir/images/ui-bg_glass_65_dadada_1x400.png
--------------------------------------------------------------------------------
/docs/script-dir/images/ui-bg_glass_75_dadada_1x400.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/OakLoaf/ChatColorHandler/85179056ed3b74d1827558ba4c6fd650ae5d7058/docs/script-dir/images/ui-bg_glass_75_dadada_1x400.png
--------------------------------------------------------------------------------
/docs/script-dir/images/ui-bg_glass_75_e6e6e6_1x400.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/OakLoaf/ChatColorHandler/85179056ed3b74d1827558ba4c6fd650ae5d7058/docs/script-dir/images/ui-bg_glass_75_e6e6e6_1x400.png
--------------------------------------------------------------------------------
/docs/script-dir/images/ui-bg_glass_95_fef1ec_1x400.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/OakLoaf/ChatColorHandler/85179056ed3b74d1827558ba4c6fd650ae5d7058/docs/script-dir/images/ui-bg_glass_95_fef1ec_1x400.png
--------------------------------------------------------------------------------
/docs/script-dir/images/ui-bg_highlight-soft_75_cccccc_1x100.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/OakLoaf/ChatColorHandler/85179056ed3b74d1827558ba4c6fd650ae5d7058/docs/script-dir/images/ui-bg_highlight-soft_75_cccccc_1x100.png
--------------------------------------------------------------------------------
/docs/script-dir/images/ui-icons_222222_256x240.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/OakLoaf/ChatColorHandler/85179056ed3b74d1827558ba4c6fd650ae5d7058/docs/script-dir/images/ui-icons_222222_256x240.png
--------------------------------------------------------------------------------
/docs/script-dir/images/ui-icons_2e83ff_256x240.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/OakLoaf/ChatColorHandler/85179056ed3b74d1827558ba4c6fd650ae5d7058/docs/script-dir/images/ui-icons_2e83ff_256x240.png
--------------------------------------------------------------------------------
/docs/script-dir/images/ui-icons_454545_256x240.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/OakLoaf/ChatColorHandler/85179056ed3b74d1827558ba4c6fd650ae5d7058/docs/script-dir/images/ui-icons_454545_256x240.png
--------------------------------------------------------------------------------
/docs/script-dir/images/ui-icons_888888_256x240.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/OakLoaf/ChatColorHandler/85179056ed3b74d1827558ba4c6fd650ae5d7058/docs/script-dir/images/ui-icons_888888_256x240.png
--------------------------------------------------------------------------------
/docs/script-dir/images/ui-icons_cd0a0a_256x240.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/OakLoaf/ChatColorHandler/85179056ed3b74d1827558ba4c6fd650ae5d7058/docs/script-dir/images/ui-icons_cd0a0a_256x240.png
--------------------------------------------------------------------------------
/docs/script-dir/jquery-ui.min.css:
--------------------------------------------------------------------------------
1 | /*! jQuery UI - v1.13.2 - 2023-02-27
2 | * http://jqueryui.com
3 | * Includes: core.css, autocomplete.css, menu.css
4 | * Copyright jQuery Foundation and other contributors; Licensed MIT */
5 |
6 | .ui-helper-hidden{display:none}.ui-helper-hidden-accessible{border:0;clip:rect(0 0 0 0);height:1px;margin:-1px;overflow:hidden;padding:0;position:absolute;width:1px}.ui-helper-reset{margin:0;padding:0;border:0;outline:0;line-height:1.3;text-decoration:none;font-size:100%;list-style:none}.ui-helper-clearfix:before,.ui-helper-clearfix:after{content:"";display:table;border-collapse:collapse}.ui-helper-clearfix:after{clear:both}.ui-helper-zfix{width:100%;height:100%;top:0;left:0;position:absolute;opacity:0;-ms-filter:"alpha(opacity=0)"}.ui-front{z-index:100}.ui-state-disabled{cursor:default!important;pointer-events:none}.ui-icon{display:inline-block;vertical-align:middle;margin-top:-.25em;position:relative;text-indent:-99999px;overflow:hidden;background-repeat:no-repeat}.ui-widget-icon-block{left:50%;margin-left:-8px;display:block}.ui-widget-overlay{position:fixed;top:0;left:0;width:100%;height:100%}.ui-autocomplete{position:absolute;top:0;left:0;cursor:default}.ui-menu{list-style:none;padding:0;margin:0;display:block;outline:0}.ui-menu .ui-menu{position:absolute}.ui-menu .ui-menu-item{margin:0;cursor:pointer;list-style-image:url("data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7")}.ui-menu .ui-menu-item-wrapper{position:relative;padding:3px 1em 3px .4em}.ui-menu .ui-menu-divider{margin:5px 0;height:0;font-size:0;line-height:0;border-width:1px 0 0 0}.ui-menu .ui-state-focus,.ui-menu .ui-state-active{margin:-1px}.ui-menu-icons{position:relative}.ui-menu-icons .ui-menu-item-wrapper{padding-left:2em}.ui-menu .ui-icon{position:absolute;top:0;bottom:0;left:.2em;margin:auto 0}.ui-menu .ui-menu-icon{left:auto;right:0}
--------------------------------------------------------------------------------
/docs/script-dir/jquery-ui.structure.min.css:
--------------------------------------------------------------------------------
1 | /*! jQuery UI - v1.12.1 - 2018-12-06
2 | * http://jqueryui.com
3 | * Copyright jQuery Foundation and other contributors; Licensed MIT */
4 |
5 | .ui-helper-hidden{display:none}.ui-helper-hidden-accessible{border:0;clip:rect(0 0 0 0);height:1px;margin:-1px;overflow:hidden;padding:0;position:absolute;width:1px}.ui-helper-reset{margin:0;padding:0;border:0;outline:0;line-height:1.3;text-decoration:none;font-size:100%;list-style:none}.ui-helper-clearfix:before,.ui-helper-clearfix:after{content:"";display:table;border-collapse:collapse}.ui-helper-clearfix:after{clear:both}.ui-helper-zfix{width:100%;height:100%;top:0;left:0;position:absolute;opacity:0;filter:Alpha(Opacity=0)}.ui-front{z-index:100}.ui-state-disabled{cursor:default!important;pointer-events:none}.ui-icon{display:inline-block;vertical-align:middle;margin-top:-.25em;position:relative;text-indent:-99999px;overflow:hidden;background-repeat:no-repeat}.ui-widget-icon-block{left:50%;margin-left:-8px;display:block}.ui-widget-overlay{position:fixed;top:0;left:0;width:100%;height:100%}.ui-autocomplete{position:absolute;top:0;left:0;cursor:default}.ui-menu{list-style:none;padding:0;margin:0;display:block;outline:0}.ui-menu .ui-menu{position:absolute}.ui-menu .ui-menu-item{margin:0;cursor:pointer;list-style-image:url("data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7")}.ui-menu .ui-menu-item-wrapper{position:relative;padding:3px 1em 3px .4em}.ui-menu .ui-menu-divider{margin:5px 0;height:0;font-size:0;line-height:0;border-width:1px 0 0 0}.ui-menu .ui-state-focus,.ui-menu .ui-state-active{margin:-1px}.ui-menu-icons{position:relative}.ui-menu-icons .ui-menu-item-wrapper{padding-left:2em}.ui-menu .ui-icon{position:absolute;top:0;bottom:0;left:.2em;margin:auto 0}.ui-menu .ui-menu-icon{left:auto;right:0}
--------------------------------------------------------------------------------
/docs/script.js:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2013, 2020, Oracle and/or its affiliates. All rights reserved.
3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 | *
5 | * This code is free software; you can redistribute it and/or modify it
6 | * under the terms of the GNU General Public License version 2 only, as
7 | * published by the Free Software Foundation. Oracle designates this
8 | * particular file as subject to the "Classpath" exception as provided
9 | * by Oracle in the LICENSE file that accompanied this code.
10 | *
11 | * This code is distributed in the hope that it will be useful, but WITHOUT
12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 | * version 2 for more details (a copy is included in the LICENSE file that
15 | * accompanied this code).
16 | *
17 | * You should have received a copy of the GNU General Public License version
18 | * 2 along with this work; if not, write to the Free Software Foundation,
19 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 | *
21 | * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 | * or visit www.oracle.com if you need additional information or have any
23 | * questions.
24 | */
25 |
26 | var moduleSearchIndex;
27 | var packageSearchIndex;
28 | var typeSearchIndex;
29 | var memberSearchIndex;
30 | var tagSearchIndex;
31 | function loadScripts(doc, tag) {
32 | createElem(doc, tag, 'search.js');
33 |
34 | createElem(doc, tag, 'module-search-index.js');
35 | createElem(doc, tag, 'package-search-index.js');
36 | createElem(doc, tag, 'type-search-index.js');
37 | createElem(doc, tag, 'member-search-index.js');
38 | createElem(doc, tag, 'tag-search-index.js');
39 | }
40 |
41 | function createElem(doc, tag, path) {
42 | var script = doc.createElement(tag);
43 | var scriptElement = doc.getElementsByTagName(tag)[0];
44 | script.src = pathtoroot + path;
45 | scriptElement.parentNode.insertBefore(script, scriptElement);
46 | }
47 |
48 | function show(tableId, selected, columns) {
49 | if (tableId !== selected) {
50 | document.querySelectorAll('div.' + tableId + ':not(.' + selected + ')')
51 | .forEach(function(elem) {
52 | elem.style.display = 'none';
53 | });
54 | }
55 | document.querySelectorAll('div.' + selected)
56 | .forEach(function(elem, index) {
57 | elem.style.display = '';
58 | var isEvenRow = index % (columns * 2) < columns;
59 | elem.classList.remove(isEvenRow ? oddRowColor : evenRowColor);
60 | elem.classList.add(isEvenRow ? evenRowColor : oddRowColor);
61 | });
62 | updateTabs(tableId, selected);
63 | }
64 |
65 | function updateTabs(tableId, selected) {
66 | document.getElementById(tableId + '.tabpanel')
67 | .setAttribute('aria-labelledby', selected);
68 | document.querySelectorAll('button[id^="' + tableId + '"]')
69 | .forEach(function(tab, index) {
70 | if (selected === tab.id || (tableId === selected && index === 0)) {
71 | tab.className = activeTableTab;
72 | tab.setAttribute('aria-selected', true);
73 | tab.setAttribute('tabindex',0);
74 | } else {
75 | tab.className = tableTab;
76 | tab.setAttribute('aria-selected', false);
77 | tab.setAttribute('tabindex',-1);
78 | }
79 | });
80 | }
81 |
82 | function switchTab(e) {
83 | var selected = document.querySelector('[aria-selected=true]');
84 | if (selected) {
85 | if ((e.keyCode === 37 || e.keyCode === 38) && selected.previousSibling) {
86 | // left or up arrow key pressed: move focus to previous tab
87 | selected.previousSibling.click();
88 | selected.previousSibling.focus();
89 | e.preventDefault();
90 | } else if ((e.keyCode === 39 || e.keyCode === 40) && selected.nextSibling) {
91 | // right or down arrow key pressed: move focus to next tab
92 | selected.nextSibling.click();
93 | selected.nextSibling.focus();
94 | e.preventDefault();
95 | }
96 | }
97 | }
98 |
99 | var updateSearchResults = function() {};
100 |
101 | function indexFilesLoaded() {
102 | return moduleSearchIndex
103 | && packageSearchIndex
104 | && typeSearchIndex
105 | && memberSearchIndex
106 | && tagSearchIndex;
107 | }
108 |
109 | // Workaround for scroll position not being included in browser history (8249133)
110 | document.addEventListener("DOMContentLoaded", function(e) {
111 | var contentDiv = document.querySelector("div.flex-content");
112 | window.addEventListener("popstate", function(e) {
113 | if (e.state !== null) {
114 | contentDiv.scrollTop = e.state;
115 | }
116 | });
117 | window.addEventListener("hashchange", function(e) {
118 | history.replaceState(contentDiv.scrollTop, document.title);
119 | });
120 | contentDiv.addEventListener("scroll", function(e) {
121 | var timeoutID;
122 | if (!timeoutID) {
123 | timeoutID = setTimeout(function() {
124 | history.replaceState(contentDiv.scrollTop, document.title);
125 | timeoutID = null;
126 | }, 100);
127 | }
128 | });
129 | if (!location.hash) {
130 | history.replaceState(contentDiv.scrollTop, document.title);
131 | }
132 | });
133 |
--------------------------------------------------------------------------------
/docs/tag-search-index.js:
--------------------------------------------------------------------------------
1 | tagSearchIndex = [{"l":"Constant Field Values","h":"","u":"constant-values.html"}];updateSearchResults();
--------------------------------------------------------------------------------
/docs/type-search-index.js:
--------------------------------------------------------------------------------
1 | typeSearchIndex = [{"l":"All Classes and Interfaces","u":"allclasses-index.html"},{"p":"org.lushplugins.chatcolorhandler","l":"ChatColorHandler"},{"p":"org.lushplugins.chatcolorhandler.parsers.custom","l":"HexParser"},{"p":"org.lushplugins.chatcolorhandler.parsers.custom","l":"LegacyHexParser"},{"p":"org.lushplugins.chatcolorhandler.parsers.custom","l":"LegacySpigotParser"},{"p":"org.lushplugins.chatcolorhandler.parsers.custom","l":"MiniMessageColorParser"},{"p":"org.lushplugins.chatcolorhandler.parsers.custom","l":"MiniMessageInteractionParser"},{"p":"org.lushplugins.chatcolorhandler.parsers.custom","l":"MiniMessagePlaceholderParser"},{"p":"org.lushplugins.chatcolorhandler.parsers.custom","l":"MiniMessageResolverParser"},{"p":"org.lushplugins.chatcolorhandler.parsers.custom","l":"MiniMessageTextFormattingParser"},{"p":"org.lushplugins.chatcolorhandler.parsers.custom","l":"MiniPlaceholdersParser"},{"p":"org.lushplugins.chatcolorhandler","l":"ModernChatColorHandler"},{"p":"org.lushplugins.chatcolorhandler.parsers","l":"Parser.OutputType"},{"p":"org.lushplugins.chatcolorhandler.parsers","l":"Parser"},{"p":"org.lushplugins.chatcolorhandler.parsers","l":"Parsers"},{"p":"org.lushplugins.chatcolorhandler.parsers","l":"ParserTypes"},{"p":"org.lushplugins.chatcolorhandler.parsers.custom","l":"PlaceholderAPIParser"},{"p":"org.lushplugins.chatcolorhandler.parsers","l":"Resolver"}];updateSearchResults();
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/OakLoaf/ChatColorHandler/85179056ed3b74d1827558ba4c6fd650ae5d7058/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | distributionBase=GRADLE_USER_HOME
2 | distributionPath=wrapper/dists
3 | distributionUrl=https\://services.gradle.org/distributions/gradle-8.6-bin.zip
4 | zipStoreBase=GRADLE_USER_HOME
5 | zipStorePath=wrapper/dists
6 |
--------------------------------------------------------------------------------
/gradlew.bat:
--------------------------------------------------------------------------------
1 | @rem
2 | @rem Copyright 2015 the original author or authors.
3 | @rem
4 | @rem Licensed under the Apache License, Version 2.0 (the "License");
5 | @rem you may not use this file except in compliance with the License.
6 | @rem You may obtain a copy of the License at
7 | @rem
8 | @rem https://www.apache.org/licenses/LICENSE-2.0
9 | @rem
10 | @rem Unless required by applicable law or agreed to in writing, software
11 | @rem distributed under the License is distributed on an "AS IS" BASIS,
12 | @rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | @rem See the License for the specific language governing permissions and
14 | @rem limitations under the License.
15 | @rem
16 |
17 | @if "%DEBUG%"=="" @echo off
18 | @rem ##########################################################################
19 | @rem
20 | @rem Gradle startup script for Windows
21 | @rem
22 | @rem ##########################################################################
23 |
24 | @rem Set local scope for the variables with windows NT shell
25 | if "%OS%"=="Windows_NT" setlocal
26 |
27 | set DIRNAME=%~dp0
28 | if "%DIRNAME%"=="" set DIRNAME=.
29 | @rem This is normally unused
30 | set APP_BASE_NAME=%~n0
31 | set APP_HOME=%DIRNAME%
32 |
33 | @rem Resolve any "." and ".." in APP_HOME to make it shorter.
34 | for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
35 |
36 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
37 | set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
38 |
39 | @rem Find java.exe
40 | if defined JAVA_HOME goto findJavaFromJavaHome
41 |
42 | set JAVA_EXE=java.exe
43 | %JAVA_EXE% -version >NUL 2>&1
44 | if %ERRORLEVEL% equ 0 goto execute
45 |
46 | echo.
47 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
48 | echo.
49 | echo Please set the JAVA_HOME variable in your environment to match the
50 | echo location of your Java installation.
51 |
52 | goto fail
53 |
54 | :findJavaFromJavaHome
55 | set JAVA_HOME=%JAVA_HOME:"=%
56 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
57 |
58 | if exist "%JAVA_EXE%" goto execute
59 |
60 | echo.
61 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
62 | echo.
63 | echo Please set the JAVA_HOME variable in your environment to match the
64 | echo location of your Java installation.
65 |
66 | goto fail
67 |
68 | :execute
69 | @rem Setup the command line
70 |
71 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
72 |
73 |
74 | @rem Execute Gradle
75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
76 |
77 | :end
78 | @rem End local scope for the variables with windows NT shell
79 | if %ERRORLEVEL% equ 0 goto mainEnd
80 |
81 | :fail
82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
83 | rem the _cmd.exe /c_ return code!
84 | set EXIT_CODE=%ERRORLEVEL%
85 | if %EXIT_CODE% equ 0 set EXIT_CODE=1
86 | if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE%
87 | exit /b %EXIT_CODE%
88 |
89 | :mainEnd
90 | if "%OS%"=="Windows_NT" endlocal
91 |
92 | :omega
93 |
--------------------------------------------------------------------------------
/settings.gradle.kts:
--------------------------------------------------------------------------------
1 | rootProject.name = "ChatColorHandler"
2 | include("test:spigot")
3 | include("test:paper")
--------------------------------------------------------------------------------
/src/main/java/org/lushplugins/chatcolorhandler/ChatColorHandlerSettings.java:
--------------------------------------------------------------------------------
1 | package org.lushplugins.chatcolorhandler;
2 |
3 | import org.lushplugins.chatcolorhandler.parsers.Parser;
4 |
5 | import java.util.Collections;
6 | import java.util.List;
7 |
8 | @SuppressWarnings({"unused", "UnusedReturnValue"})
9 | public class ChatColorHandlerSettings {
10 | private List defaultParsers = Collections.emptyList();
11 | private boolean debug = false;
12 |
13 | public List defaultParsers() {
14 | ChatColorHandler.ensureInitialised();
15 | return defaultParsers;
16 | }
17 |
18 | /**
19 | * Set the default parsers to use, when not overridden all registered parsers are used
20 | * @param parsers The default parsers to use when none are specified
21 | */
22 | public ChatColorHandlerSettings defaultParsers(List parsers) {
23 | this.defaultParsers = parsers;
24 | return this;
25 | }
26 |
27 | public boolean debug() {
28 | return debug;
29 | }
30 |
31 | /**
32 | * @param debug Whether to enable debug logs
33 | */
34 | public ChatColorHandlerSettings debug(boolean debug) {
35 | this.debug = debug;
36 | return this;
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/src/main/java/org/lushplugins/chatcolorhandler/ModernChatColorHandler.java:
--------------------------------------------------------------------------------
1 | package org.lushplugins.chatcolorhandler;
2 |
3 | import net.kyori.adventure.text.minimessage.tag.resolver.TagResolver;
4 | import org.jetbrains.annotations.NotNull;
5 | import org.lushplugins.chatcolorhandler.messengers.MiniMessageMessenger;
6 | import org.lushplugins.chatcolorhandler.parsers.Parser;
7 | import org.lushplugins.chatcolorhandler.parsers.Resolver;
8 | import net.kyori.adventure.audience.Audience;
9 | import net.kyori.adventure.text.Component;
10 | import org.bukkit.entity.Player;
11 | import org.jetbrains.annotations.Nullable;
12 |
13 | import java.util.Collection;
14 | import java.util.List;
15 | import java.util.Objects;
16 |
17 | @SuppressWarnings("unused")
18 | public class ModernChatColorHandler {
19 |
20 | /**
21 | * Translates a string to allow for hex colours and placeholders
22 | *
23 | * @param string String to be translated
24 | */
25 | public static Component translate(@Nullable String string) {
26 | return translate(string, ChatColorHandler.settings().defaultParsers());
27 | }
28 |
29 | /**
30 | * Translates a string to allow for hex colours and placeholders
31 | *
32 | * @param string String to be translated
33 | * @param parsers Parsers which this message won't be parsed through
34 | */
35 | public static Component translate(@Nullable String string, @NotNull List parsers) {
36 | return translate(string, null, parsers);
37 | }
38 |
39 | /**
40 | * Translates a string to allow for hex colours and placeholders
41 | *
42 | * @param string String to be translated
43 | * @param player Player to parse placeholders for
44 | */
45 | public static Component translate(@Nullable String string, Player player) {
46 | return translate(string, player, ChatColorHandler.settings().defaultParsers());
47 | }
48 |
49 | /**
50 | * Translates a string to allow for hex colours and placeholders
51 | *
52 | * @param string String to be converted
53 | * @param player Player to parse placeholders for
54 | * @param parsers Parsers which this message will be parsed through
55 | */
56 | public static Component translate(@Nullable String string, Player player, @NotNull List parsers) {
57 | ChatColorHandler.ensureInitialised();
58 |
59 | if (string == null || string.isBlank()) {
60 | return Component.empty();
61 | }
62 |
63 | String legacyParsed = ChatColorHandler.parsers().parseString(string, Parser.OutputType.MINI_MESSAGE, player, parsers);
64 |
65 | TagResolver tagResolver = Resolver.combineResolvers((Audience) player, parsers.stream()
66 | .map(parser -> parser instanceof Resolver resolver ? resolver : null)
67 | .filter(Objects::nonNull)
68 | .toList());
69 |
70 | return MiniMessageMessenger.MINI_MESSAGE.deserialize(legacyParsed, tagResolver);
71 | }
72 |
73 | /**
74 | * Translates a collection of strings to allow for hex colours and placeholders
75 | *
76 | * @param strings Strings to be translated
77 | */
78 | public static List translate(@NotNull Collection strings) {
79 | return translate(strings, ChatColorHandler.settings().defaultParsers());
80 | }
81 |
82 | /**
83 | * Translates a collection of strings to allow for hex colours and placeholders
84 | *
85 | * @param strings Strings to be translated
86 | * @param parsers Parsers which this message will be parsed through
87 | */
88 | public static List translate(@NotNull Collection strings, List parsers) {
89 | return translate(strings, null, parsers);
90 | }
91 |
92 | /**
93 | * Translates a collection of strings to allow for hex colours and placeholders
94 | *
95 | * @param strings Strings to be translated
96 | * @param player Player to parse placeholders for
97 | */
98 | public static List translate(@NotNull Collection strings, Player player) {
99 | return translate(strings, player, ChatColorHandler.settings().defaultParsers());
100 | }
101 |
102 | /**
103 | * Translates a collection of strings to allow for hex colours and placeholders
104 | *
105 | * @param strings Strings to be translated
106 | * @param player Player to parse placeholders for
107 | * @param parsers Parsers which this message will be parsed through
108 | */
109 | public static List translate(@NotNull Collection strings, Player player, List parsers) {
110 | return strings.stream().map(string -> translate(string, player, parsers)).toList();
111 | }
112 |
113 | private ModernChatColorHandler() {}
114 | }
115 |
--------------------------------------------------------------------------------
/src/main/java/org/lushplugins/chatcolorhandler/messengers/AbstractMessenger.java:
--------------------------------------------------------------------------------
1 | package org.lushplugins.chatcolorhandler.messengers;
2 |
3 | import org.bukkit.command.CommandSender;
4 | import org.bukkit.entity.Player;
5 | import org.jetbrains.annotations.NotNull;
6 | import org.jetbrains.annotations.Nullable;
7 |
8 | public abstract class AbstractMessenger implements Messenger {
9 |
10 | /**
11 | * Sends a recipient multiple messages
12 | *
13 | * @param recipient Sender to receive messages
14 | * @param messages Messages to be displayed
15 | */
16 | @Override
17 | public void sendMessage(@NotNull CommandSender recipient, @Nullable String... messages) {
18 | if (messages == null) {
19 | return;
20 | }
21 |
22 | for (String message : messages) {
23 | sendMessage(recipient, message);
24 | }
25 | }
26 |
27 | /**
28 | * Sends multiple recipients a message
29 | *
30 | * @param recipients Senders to receive message
31 | * @param message Message to be displayed
32 | */
33 | @Override
34 | public void sendMessage(CommandSender[] recipients, @Nullable String message) {
35 | if (message == null || message.isBlank()) {
36 | return;
37 | }
38 |
39 | for (CommandSender recipient : recipients) {
40 | sendMessage(recipient, message);
41 | }
42 | }
43 |
44 | /**
45 | * Sends multiple recipients, multiple messages
46 | *
47 | * @param recipients Senders to receive messages
48 | * @param messages Messages to be displayed
49 | */
50 | @Override
51 | public void sendMessage(CommandSender[] recipients, @Nullable String... messages) {
52 | if (messages == null) {
53 | return;
54 | }
55 |
56 | for (CommandSender recipient : recipients) {
57 | for (String message : messages) {
58 | sendMessage(recipient, message);
59 | }
60 | }
61 | }
62 |
63 | /**
64 | * Sends all online players multiple messages
65 | *
66 | * @param messages Messages to be displayed
67 | */
68 | @Override
69 | public void broadcastMessage(@NotNull String... messages) {
70 | if (messages == null) {
71 | return;
72 | }
73 |
74 | for (String message : messages) {
75 | broadcastMessage(message);
76 | }
77 | }
78 |
79 | /**
80 | * Sends multiple players an ACTION_BAR message
81 | *
82 | * @param players Players to receive this action bar message
83 | * @param message Message to be displayed
84 | */
85 | @Override
86 | public void sendActionBarMessage(@NotNull Player[] players, @Nullable String message) {
87 | if (message == null || message.isBlank()) {
88 | return;
89 | }
90 |
91 | for (Player player : players) {
92 | sendActionBarMessage(player, message);
93 | }
94 | }
95 |
96 | /**
97 | * Sends a player a TITLE message
98 | *
99 | * @param player Players to receive this action bar message
100 | * @param title Title to be displayed
101 | */
102 | @Override
103 | public void sendTitle(@NotNull Player player, @Nullable String title) {
104 | sendTitle(player, title, null);
105 | }
106 |
107 | /**
108 | * Sends a player a TITLE message
109 | *
110 | * @param player Player to receive this title
111 | * @param title Title to be displayed
112 | * @param subtitle Subtitle to be displayed
113 | */
114 | @Override
115 | public void sendTitle(@NotNull Player player, @Nullable String title, @Nullable String subtitle) {
116 | sendTitle(player, title, subtitle, 10, 20);
117 | }
118 |
119 | /**
120 | * Sends a player a TITLE message
121 | *
122 | * @param player Player to receive this title
123 | * @param title Title to be displayed
124 | * @param subtitle Subtitle to be displayed
125 | * @param fadeIn Duration for title to fade in
126 | * @param fadeOut Duration for title to fade out
127 | */
128 | @Override
129 | public void sendTitle(@NotNull Player player, @Nullable String title, @Nullable String subtitle, int fadeIn, int fadeOut) {
130 | sendTitle(player, title, subtitle, fadeIn, 70, fadeOut);
131 | }
132 |
133 | /**
134 | * Sends multiple players a TITLE message
135 | *
136 | * @param players Players to receive this title message
137 | * @param title Title to be displayed
138 | */
139 | @Override
140 | public void sendTitle(@NotNull Player[] players, @Nullable String title) {
141 | sendTitle(players, title, null);
142 | }
143 |
144 | /**
145 | * Sends multiple players a TITLE message
146 | *
147 | * @param players Player to receive this title
148 | * @param title Title to be displayed
149 | * @param subtitle Subtitle to be displayed
150 | */
151 | @Override
152 | public void sendTitle(@NotNull Player[] players, @Nullable String title, @Nullable String subtitle) {
153 | sendTitle(players, title, subtitle, 10, 20);
154 | }
155 |
156 | /**
157 | * Sends multiple players a TITLE message
158 | *
159 | * @param players Player to receive this title
160 | * @param title Title to be displayed
161 | * @param subtitle Subtitle to be displayed
162 | * @param fadeIn Duration for title to fade in
163 | * @param fadeOut Duration for title to fade out
164 | */
165 | @Override
166 | public void sendTitle(@NotNull Player[] players, @Nullable String title, @Nullable String subtitle, int fadeIn, int fadeOut) {
167 | sendTitle(players, title, subtitle, fadeIn, 70, fadeOut);
168 | }
169 |
170 | /**
171 | * Sends multiple players a TITLE message
172 | *
173 | * @param players Player to receive this title
174 | * @param title Title to be displayed
175 | * @param subtitle Subtitle to be displayed
176 | * @param fadeIn Duration for title to fade in
177 | * @param stay Duration for title to appear
178 | * @param fadeOut Duration for title to fade out
179 | */
180 | @Override
181 | public void sendTitle(@NotNull Player[] players, @Nullable String title, @Nullable String subtitle, int fadeIn, int stay, int fadeOut) {
182 | if ((title == null || title.isBlank()) && (subtitle == null || subtitle.isBlank())) {
183 | return;
184 | }
185 |
186 | for (Player player : players) {
187 | sendTitle(player, title, subtitle, fadeIn, stay, fadeOut);
188 | }
189 | }
190 | }
191 |
--------------------------------------------------------------------------------
/src/main/java/org/lushplugins/chatcolorhandler/messengers/LegacyMessenger.java:
--------------------------------------------------------------------------------
1 | package org.lushplugins.chatcolorhandler.messengers;
2 |
3 | import org.lushplugins.chatcolorhandler.ChatColorHandler;
4 | import net.md_5.bungee.api.ChatMessageType;
5 | import net.md_5.bungee.api.chat.TextComponent;
6 | import org.bukkit.Bukkit;
7 | import org.bukkit.command.CommandSender;
8 | import org.bukkit.entity.Player;
9 | import org.jetbrains.annotations.NotNull;
10 | import org.jetbrains.annotations.Nullable;
11 |
12 | public class LegacyMessenger extends AbstractMessenger {
13 |
14 | @Override
15 | public void sendMessage(@NotNull CommandSender recipient, @Nullable String message) {
16 | if (message == null || message.isBlank()) {
17 | return;
18 | }
19 |
20 | recipient.sendMessage(ChatColorHandler.translate(message, recipient instanceof Player player ? player : null));
21 | }
22 |
23 | @Override
24 | public void broadcastMessage(@Nullable String message) {
25 | if (message == null || message.isBlank()) {
26 | return;
27 | }
28 |
29 | Bukkit.broadcastMessage(ChatColorHandler.translate(message));
30 | }
31 |
32 | @Override
33 | public void sendActionBarMessage(@NotNull Player player, @Nullable String message) {
34 | if (message == null || message.isBlank()) {
35 | return;
36 | }
37 |
38 | player.spigot().sendMessage(ChatMessageType.ACTION_BAR, new TextComponent(ChatColorHandler.translate(message, player)));
39 | }
40 |
41 | @Override
42 | public void sendTitle(@NotNull Player player, @Nullable String title, @Nullable String subtitle, int fadeIn, int stay, int fadeOut) {
43 | if ((title == null || title.isBlank()) && (subtitle == null || subtitle.isBlank())) {
44 | return;
45 | }
46 |
47 | player.sendTitle(ChatColorHandler.translate(title, player), ChatColorHandler.translate(subtitle, player), fadeIn, stay, fadeOut);
48 | }
49 | }
50 |
--------------------------------------------------------------------------------
/src/main/java/org/lushplugins/chatcolorhandler/messengers/Messenger.java:
--------------------------------------------------------------------------------
1 | package org.lushplugins.chatcolorhandler.messengers;
2 |
3 | import org.bukkit.command.CommandSender;
4 | import org.bukkit.entity.Player;
5 | import org.jetbrains.annotations.NotNull;
6 | import org.jetbrains.annotations.Nullable;
7 |
8 | public interface Messenger {
9 |
10 | /**
11 | * Sends a recipient a message
12 | *
13 | * @param recipient Sender to receive this message
14 | * @param message Message to be displayed
15 | */
16 | void sendMessage(@NotNull CommandSender recipient, @Nullable String message);
17 |
18 | /**
19 | * Sends a recipient multiple messages
20 | *
21 | * @param recipient Sender to receive message
22 | * @param messages Messages to be displayed
23 | */
24 | void sendMessage(@NotNull CommandSender recipient, @Nullable String... messages);
25 |
26 | /**
27 | * Sends multiple recipients a message
28 | *
29 | * @param recipients Senders to receive message
30 | * @param message Message to be displayed
31 | */
32 | void sendMessage(CommandSender[] recipients, @Nullable String message);
33 |
34 | /**
35 | * Sends multiple recipients, multiple messages
36 | *
37 | * @param recipients Senders to receive this message
38 | * @param messages Messages to be displayed
39 | */
40 | void sendMessage(CommandSender[] recipients, @Nullable String... messages);
41 |
42 | /**
43 | * Sends all online players a message
44 | *
45 | * @param message Message to be displayed
46 | */
47 | void broadcastMessage(@Nullable String message);
48 |
49 | /**
50 | * Sends all online players multiple messages
51 | *
52 | * @param messages Messages to be displayed
53 | */
54 | void broadcastMessage(@NotNull String... messages);
55 |
56 | /**
57 | * Sends a player an ACTION_BAR message
58 | *
59 | * @param player Player to receive this action bar message
60 | * @param message Message to be displayed
61 | */
62 | void sendActionBarMessage(@NotNull Player player, @Nullable String message);
63 |
64 | /**
65 | * Sends multiple players an ACTION_BAR message
66 | *
67 | * @param players Players to receive this action bar message
68 | * @param message Message to be displayed
69 | */
70 | void sendActionBarMessage(@NotNull Player[] players, @Nullable String message);
71 |
72 | /**
73 | * Send a player a TITLE message
74 | *
75 | * @param player Player to receive this title
76 | * @param title Title to be displayed
77 | */
78 | void sendTitle(@NotNull Player player, @Nullable String title);
79 |
80 | /**
81 | * Send a player a TITLE message
82 | *
83 | * @param player Player to receive this title
84 | * @param title Title to be displayed
85 | * @param subtitle Subtitle to be displayed
86 | */
87 | void sendTitle(@NotNull Player player, @Nullable String title, @Nullable String subtitle);
88 |
89 | /**
90 | * Send a player a TITLE message
91 | *
92 | * @param player Player to receive this title
93 | * @param title Title to be displayed
94 | * @param subtitle Subtitle to be displayed
95 | * @param fadeIn Duration for title to fade in
96 | * @param fadeOut Duration for title to fade out
97 | */
98 | void sendTitle(@NotNull Player player, @Nullable String title, @Nullable String subtitle, int fadeIn, int fadeOut);
99 |
100 | /**
101 | * Send a player a TITLE message
102 | *
103 | * @param player Player to receive this title
104 | * @param title Title to be displayed
105 | * @param subtitle Subtitle to be displayed
106 | * @param fadeIn Duration for title to fade in
107 | * @param stay Duration for title to appear
108 | * @param fadeOut Duration for title to fade out
109 | */
110 | void sendTitle(@NotNull Player player, @Nullable String title, @Nullable String subtitle, int fadeIn, int stay, int fadeOut);
111 |
112 | /**
113 | * Send multiple players a TITLE message
114 | *
115 | * @param players Player to receive this title
116 | * @param title Title to be displayed
117 | */
118 | void sendTitle(@NotNull Player[] players, @Nullable String title);
119 |
120 | /**
121 | * Send multiple players a TITLE message
122 | *
123 | * @param players Player to receive this title
124 | * @param title Title to be displayed
125 | * @param subtitle Subtitle to be displayed
126 | */
127 | void sendTitle(@NotNull Player[] players, @Nullable String title, @Nullable String subtitle);
128 |
129 | /**
130 | * Send multiple players a TITLE message
131 | *
132 | * @param players Player to receive this title
133 | * @param title Title to be displayed
134 | * @param subtitle Subtitle to be displayed
135 | * @param fadeIn Duration for title to fade in
136 | * @param fadeOut Duration for title to fade out
137 | */
138 | void sendTitle(@NotNull Player[] players, @Nullable String title, @Nullable String subtitle, int fadeIn, int fadeOut);
139 |
140 | /**
141 | * Send multiple players a TITLE message
142 | *
143 | * @param players Player to receive this title
144 | * @param title Title to be displayed
145 | * @param subtitle Subtitle to be displayed
146 | * @param fadeIn Duration for title to fade in
147 | * @param stay Duration for title to appear
148 | * @param fadeOut Duration for title to fade out
149 | */
150 | void sendTitle(@NotNull Player[] players, @Nullable String title, @Nullable String subtitle, int fadeIn, int stay, int fadeOut);
151 | }
152 |
--------------------------------------------------------------------------------
/src/main/java/org/lushplugins/chatcolorhandler/messengers/MiniMessageMessenger.java:
--------------------------------------------------------------------------------
1 | package org.lushplugins.chatcolorhandler.messengers;
2 |
3 | import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
4 | import org.lushplugins.chatcolorhandler.ModernChatColorHandler;
5 | import net.kyori.adventure.audience.Audience;
6 | import net.kyori.adventure.text.Component;
7 | import net.kyori.adventure.text.minimessage.MiniMessage;
8 | import net.kyori.adventure.text.minimessage.tag.resolver.TagResolver;
9 | import net.kyori.adventure.title.Title;
10 | import net.kyori.adventure.title.TitlePart;
11 | import org.bukkit.Bukkit;
12 | import org.bukkit.command.CommandSender;
13 | import org.bukkit.entity.Player;
14 | import org.jetbrains.annotations.NotNull;
15 | import org.jetbrains.annotations.Nullable;
16 |
17 | import java.time.Duration;
18 |
19 | public class MiniMessageMessenger extends AbstractMessenger {
20 | public static final MiniMessage MINI_MESSAGE = MiniMessage.builder()
21 | .tags(TagResolver.empty())
22 | .build();
23 | public static final LegacyComponentSerializer LEGACY_COMPONENT_SERIALIZER = LegacyComponentSerializer.builder()
24 | .character('§')
25 | .hexColors()
26 | .useUnusualXRepeatedCharacterHexFormat()
27 | .build();
28 |
29 |
30 | @Override
31 | public void sendMessage(@NotNull CommandSender recipient, @Nullable String message) {
32 | if (message == null || message.isBlank()) {
33 | return;
34 | }
35 |
36 | Audience audience = Audience.audience((Audience) recipient);
37 | Component parsed = ModernChatColorHandler.translate(message, (recipient instanceof Player player ? player : null));
38 | audience.sendMessage(parsed);
39 | }
40 |
41 | @Override
42 | public void broadcastMessage(@Nullable String message) {
43 | if (message == null || message.isBlank()) {
44 | return;
45 | }
46 |
47 | Audience audience = Audience.audience((Audience) Bukkit.getServer());
48 | audience.sendMessage(ModernChatColorHandler.translate(message));
49 | }
50 |
51 | @Override
52 | public void sendActionBarMessage(@NotNull Player player, @Nullable String message) {
53 | if (message == null || message.isBlank()) {
54 | return;
55 | }
56 |
57 | Audience audience = Audience.audience((Audience) player);
58 | audience.sendActionBar(ModernChatColorHandler.translate(message, player));
59 | }
60 |
61 | @Override
62 | public void sendTitle(@NotNull Player player, @Nullable String title, @Nullable String subtitle, int fadeIn, int stay, int fadeOut) {
63 | if ((title == null || title.isBlank()) && (subtitle == null || subtitle.isBlank())) {
64 | return;
65 | }
66 |
67 | Audience audience = Audience.audience((Audience) player);
68 | Title.Times times = Title.Times.times(Duration.ofMillis(fadeIn * 50L), Duration.ofMillis(stay * 50L), Duration.ofMillis(fadeOut * 50L));
69 | audience.sendTitlePart(TitlePart.TIMES, times);
70 | audience.sendTitlePart(TitlePart.SUBTITLE, ModernChatColorHandler.translate(subtitle, player));
71 | audience.sendTitlePart(TitlePart.TITLE, ModernChatColorHandler.translate(title, player));
72 | }
73 | }
74 |
--------------------------------------------------------------------------------
/src/main/java/org/lushplugins/chatcolorhandler/parsers/Parser.java:
--------------------------------------------------------------------------------
1 | package org.lushplugins.chatcolorhandler.parsers;
2 |
3 | import org.bukkit.entity.Player;
4 | import org.jetbrains.annotations.NotNull;
5 |
6 | public interface Parser {
7 |
8 | /**
9 | * @return The type of the parser {@link ParserTypes}
10 | */
11 | String getType();
12 |
13 | /**
14 | * Parse a string
15 | * @param string The string to parse
16 | * @param outputType The output type to parse for
17 | * @return The parsed string
18 | */
19 | String parseString(@NotNull String string, @NotNull OutputType outputType);
20 |
21 | /**
22 | * Parse a string in relation to a player
23 | * @param string The string to parse
24 | * @param outputType The output type to parse for
25 | * @param player The player to apply whilst parsing
26 | * @return The parsed string
27 | */
28 | default String parseString(@NotNull String string, @NotNull OutputType outputType, Player player) {
29 | return parseString(string, outputType);
30 | }
31 |
32 | enum OutputType {
33 | SPIGOT,
34 | MINI_MESSAGE
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/src/main/java/org/lushplugins/chatcolorhandler/parsers/ParserTypes.java:
--------------------------------------------------------------------------------
1 | package org.lushplugins.chatcolorhandler.parsers;
2 |
3 | import org.lushplugins.chatcolorhandler.ChatColorHandler;
4 |
5 | import java.util.List;
6 |
7 | public class ParserTypes {
8 | public static final String COLOR = "color";
9 | public static final String SOUND = "sound";
10 | public static final String PARTICLE = "particle";
11 | public static final String INTERACTION = "interaction";
12 | public static final String PLACEHOLDER = "placeholder";
13 | public static final String TEXT_FORMATTING = "text-formatting";
14 |
15 | /**
16 | * @return A list of color and decoration based parsers
17 | */
18 | public static List color() {
19 | return ChatColorHandler.parsers().ofType(COLOR);
20 | }
21 |
22 | /**
23 | * @return A list of sound based parsers
24 | */
25 | public static List sound() {
26 | return ChatColorHandler.parsers().ofType(SOUND);
27 | }
28 |
29 | /**
30 | * @return A list of particle based parsers
31 | */
32 | public static List particle() {
33 | return ChatColorHandler.parsers().ofType(PARTICLE);
34 | }
35 |
36 | /**
37 | * @return A list of interaction based parsers, this includes hover, click and nbt elements
38 | */
39 | public static List interact() {
40 | return ChatColorHandler.parsers().ofType(INTERACTION);
41 | }
42 |
43 | /**
44 | * @return A list of placeholder based parsers
45 | */
46 | public static List placeholder() {
47 | return ChatColorHandler.parsers().ofType(PLACEHOLDER);
48 | }
49 |
50 | /**
51 | * @return A list of text formatting based parsers, this includes font and newlines
52 | */
53 | public static List textFormatting() {
54 | return ChatColorHandler.parsers().ofType(TEXT_FORMATTING);
55 | }
56 |
57 |
58 | /**
59 | * @return A list of all parsers
60 | */
61 | public static List all() {
62 | return ChatColorHandler.parsers().getRegisteredParsers();
63 | }
64 | }
65 |
--------------------------------------------------------------------------------
/src/main/java/org/lushplugins/chatcolorhandler/parsers/Parsers.java:
--------------------------------------------------------------------------------
1 | package org.lushplugins.chatcolorhandler.parsers;
2 |
3 | import org.bukkit.Bukkit;
4 | import org.jetbrains.annotations.NotNull;
5 | import org.bukkit.entity.Player;
6 | import org.jetbrains.annotations.Nullable;
7 |
8 | import java.util.*;
9 | import java.util.logging.Level;
10 |
11 | public class Parsers {
12 | private Map parsers = new HashMap<>();
13 |
14 | /**
15 | * @param parser parser to register
16 | * @param priority priority of parser, higher value will go first
17 | */
18 | public void register(Parser parser, int priority) {
19 | parsers.put(parser, priority);
20 | parsers = sortByValue(parsers);
21 | }
22 |
23 | public String parseString(@NotNull String string, @NotNull Parser.OutputType outputType, @Nullable Player player, @NotNull List parsers) {
24 | for (Parser parser : parsers) {
25 | try {
26 | string = parser.parseString(string, outputType, player);
27 | } catch (Throwable e) {
28 | Bukkit.getLogger().log(Level.WARNING, "[ChatColorHandler] Failed to parse string '%s' through parser '%s: ".formatted(string, parser.getClass().getSimpleName()), e);
29 | }
30 | }
31 |
32 | return string;
33 | }
34 |
35 | public List getRegisteredParsers() {
36 | return parsers.keySet().stream().toList();
37 | }
38 |
39 | public List getRegisteredResolvers() {
40 | return parsers.keySet().stream()
41 | .map(parser -> parser instanceof Resolver resolver ? resolver : null)
42 | .filter(Objects::nonNull)
43 | .toList();
44 | }
45 |
46 | public List ofType(@NotNull String type) {
47 | return ofTypes(type);
48 | }
49 |
50 | public List ofTypes(@NotNull String... types) {
51 | return parsers.keySet().stream()
52 | .filter(parser -> {
53 | for (String type : types) {
54 | if (parser.getType().equals(type)) {
55 | return true;
56 | }
57 | }
58 |
59 | return false;
60 | })
61 | .toList();
62 | }
63 |
64 | private static > Map sortByValue(Map map) {
65 | List> list = new ArrayList<>(map.entrySet());
66 | list.sort(Map.Entry.comparingByValue());
67 | Collections.reverse(list);
68 |
69 | Map result = new LinkedHashMap<>();
70 | for (Map.Entry entry : list) {
71 | result.put(entry.getKey(), entry.getValue());
72 | }
73 |
74 | return result;
75 | }
76 | }
77 |
--------------------------------------------------------------------------------
/src/main/java/org/lushplugins/chatcolorhandler/parsers/Resolver.java:
--------------------------------------------------------------------------------
1 | package org.lushplugins.chatcolorhandler.parsers;
2 |
3 | import net.kyori.adventure.audience.Audience;
4 | import net.kyori.adventure.text.minimessage.tag.resolver.TagResolver;
5 | import org.bukkit.Bukkit;
6 | import org.jetbrains.annotations.NotNull;
7 | import org.jetbrains.annotations.Nullable;
8 |
9 | import java.util.List;
10 | import java.util.logging.Level;
11 |
12 | public interface Resolver extends Parser {
13 |
14 | @Override
15 | default String parseString(@NotNull String string, @NotNull OutputType outputType) {
16 | return string;
17 | }
18 |
19 | @NotNull TagResolver getResolver();
20 |
21 | default @NotNull TagResolver getResolver(Audience audience) {
22 | return getResolver();
23 | }
24 |
25 | static TagResolver combineResolvers(@Nullable Audience audience, @NotNull List resolvers) {
26 | TagResolver.Builder tagResolver = TagResolver.builder();
27 | for (Resolver resolver : resolvers) {
28 | try {
29 | tagResolver.resolver(audience != null ? resolver.getResolver(audience) : resolver.getResolver());
30 | } catch (Throwable e) {
31 | Bukkit.getLogger().log(Level.WARNING, "[ChatColorHandler] Failed to combine resolver: ", e);
32 | }
33 | }
34 |
35 | return tagResolver.build();
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/src/main/java/org/lushplugins/chatcolorhandler/parsers/custom/HexParser.java:
--------------------------------------------------------------------------------
1 | package org.lushplugins.chatcolorhandler.parsers.custom;
2 |
3 | import net.md_5.bungee.api.ChatColor;
4 | import org.jetbrains.annotations.NotNull;
5 | import org.lushplugins.chatcolorhandler.parsers.Parser;
6 | import org.lushplugins.chatcolorhandler.parsers.ParserTypes;
7 |
8 | import java.util.regex.Matcher;
9 | import java.util.regex.Pattern;
10 |
11 | // Hex in format "rrggbb" or "#rrggbb"
12 | public class HexParser implements Parser {
13 | public static final HexParser INSTANCE = new HexParser();
14 | private static final Pattern HEX_PATTERN = Pattern.compile("&(#[a-fA-F0-9]{6})");
15 |
16 | private HexParser() {}
17 |
18 | @Override
19 | public String getType() {
20 | return ParserTypes.COLOR;
21 | }
22 |
23 | @Override
24 | public String parseString(@NotNull String string, @NotNull OutputType outputType) {
25 | Matcher match = HEX_PATTERN.matcher(string);
26 | return switch (outputType) {
27 | case SPIGOT -> match.replaceAll(result -> ChatColor.of(result.group(1)).toString());
28 | case MINI_MESSAGE -> match.replaceAll("<$1>");
29 | };
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/src/main/java/org/lushplugins/chatcolorhandler/parsers/custom/LegacyHexParser.java:
--------------------------------------------------------------------------------
1 | package org.lushplugins.chatcolorhandler.parsers.custom;
2 |
3 | import org.jetbrains.annotations.NotNull;
4 | import org.lushplugins.chatcolorhandler.parsers.Parser;
5 | import org.lushplugins.chatcolorhandler.parsers.ParserTypes;
6 |
7 | import java.util.regex.Matcher;
8 | import java.util.regex.Pattern;
9 |
10 | // Hex in format '§x§r§r§g§g§b§b'
11 | public class LegacyHexParser implements Parser {
12 | public static final LegacyHexParser INSTANCE = new LegacyHexParser();
13 | private static final Pattern HEX_PATTERN = Pattern.compile("[§&]x[§&]([a-fA-F0-9])[§&]([a-fA-F0-9])[§&]([a-fA-F0-9])[§&]([a-fA-F0-9])[§&]([a-fA-F0-9])[§&]([a-fA-F0-9])");
14 |
15 | private LegacyHexParser() {}
16 |
17 | @Override
18 | public String getType() {
19 | return ParserTypes.COLOR;
20 | }
21 |
22 | @Override
23 | public String parseString(@NotNull String string, @NotNull OutputType outputType) {
24 | return switch (outputType) {
25 | case SPIGOT -> string;
26 | case MINI_MESSAGE -> {
27 | Matcher match = HEX_PATTERN.matcher(string);
28 | yield match.replaceAll("<#$1$2$3$4$5$6>");
29 | }
30 | };
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/src/main/java/org/lushplugins/chatcolorhandler/parsers/custom/LegacySpigotParser.java:
--------------------------------------------------------------------------------
1 | package org.lushplugins.chatcolorhandler.parsers.custom;
2 |
3 | import org.jetbrains.annotations.NotNull;
4 | import org.lushplugins.chatcolorhandler.parsers.Parser;
5 | import org.lushplugins.chatcolorhandler.parsers.ParserTypes;
6 |
7 | public class LegacySpigotParser implements Parser {
8 | public static final LegacySpigotParser INSTANCE = new LegacySpigotParser();
9 |
10 | private LegacySpigotParser() {}
11 |
12 | @Override
13 | public String getType() {
14 | return ParserTypes.COLOR;
15 | }
16 |
17 | @Override
18 | public String parseString(@NotNull String string, @NotNull OutputType outputType) {
19 | return switch (outputType) {
20 | case SPIGOT -> string;
21 | case MINI_MESSAGE -> string
22 | // Legacy Ampersand
23 | .replace("§", "&")
24 | // Colours
25 | .replace("&0", "")
26 | .replace("&1", "")
27 | .replace("&2", "")
28 | .replace("&3", "")
29 | .replace("&4", "")
30 | .replace("&5", "")
31 | .replace("&6", "")
32 | .replace("&7", "")
33 | .replace("&8", "")
34 | .replace("&9", "")
35 | .replace("&a", "")
36 | .replace("&b", "")
37 | .replace("&c", "")
38 | .replace("&d", "")
39 | .replace("&e", "")
40 | .replace("&f", "")
41 | // Decorations
42 | .replace("&m", "")
43 | .replace("&k", "")
44 | .replace("&n", "")
45 | .replace("&o", "")
46 | .replace("&l", "")
47 | .replace("&r", "");
48 | };
49 | }
50 | }
51 |
--------------------------------------------------------------------------------
/src/main/java/org/lushplugins/chatcolorhandler/parsers/custom/MiniMessageColorParser.java:
--------------------------------------------------------------------------------
1 | package org.lushplugins.chatcolorhandler.parsers.custom;
2 |
3 | import net.kyori.adventure.text.minimessage.tag.resolver.TagResolver;
4 | import net.kyori.adventure.text.minimessage.tag.standard.*;
5 | import org.jetbrains.annotations.NotNull;
6 | import org.lushplugins.chatcolorhandler.messengers.MiniMessageMessenger;
7 | import org.lushplugins.chatcolorhandler.parsers.ParserTypes;
8 | import org.lushplugins.chatcolorhandler.parsers.Resolver;
9 |
10 | import java.util.ArrayList;
11 | import java.util.List;
12 |
13 | public class MiniMessageColorParser implements Resolver {
14 | public static final MiniMessageColorParser INSTANCE = new MiniMessageColorParser();
15 | private static final TagResolver BASIC_COLORS = TagResolver.builder()
16 | .resolvers(tagResolvers())
17 | .build();
18 |
19 | private MiniMessageColorParser() {}
20 |
21 | @Override
22 | public String getType() {
23 | return ParserTypes.COLOR;
24 | }
25 |
26 | @Override
27 | public String parseString(@NotNull String string, @NotNull OutputType outputType) {
28 | return switch (outputType) {
29 | case SPIGOT -> {
30 | string = string.replace('§', '&');
31 | yield MiniMessageMessenger.LEGACY_COMPONENT_SERIALIZER.serialize(MiniMessageMessenger.MINI_MESSAGE.deserialize(string, BASIC_COLORS));
32 | }
33 | case MINI_MESSAGE -> string;
34 | };
35 | }
36 |
37 | @Override
38 | public @NotNull TagResolver getResolver() {
39 | return BASIC_COLORS;
40 | }
41 |
42 | private static List tagResolvers() {
43 | List resolvers = new ArrayList<>();
44 |
45 | try {
46 | // Resolvers are ordered in order of their addition to MiniMessage
47 | resolvers.add(StandardTags.color());
48 | resolvers.add(StandardTags.decorations());
49 | resolvers.add(StandardTags.gradient());
50 | resolvers.add(StandardTags.rainbow());
51 | resolvers.add(StandardTags.reset());
52 | resolvers.add(StandardTags.transition());
53 | resolvers.add(StandardTags.pride());
54 | resolvers.add(StandardTags.shadowColor());
55 | } catch (NoSuchMethodError ignored) {}
56 |
57 | return resolvers;
58 | }
59 | }
60 |
--------------------------------------------------------------------------------
/src/main/java/org/lushplugins/chatcolorhandler/parsers/custom/MiniMessageInteractionParser.java:
--------------------------------------------------------------------------------
1 | package org.lushplugins.chatcolorhandler.parsers.custom;
2 |
3 | import net.kyori.adventure.text.minimessage.tag.resolver.TagResolver;
4 | import net.kyori.adventure.text.minimessage.tag.standard.*;
5 | import org.jetbrains.annotations.NotNull;
6 | import org.lushplugins.chatcolorhandler.messengers.MiniMessageMessenger;
7 | import org.lushplugins.chatcolorhandler.parsers.ParserTypes;
8 | import org.lushplugins.chatcolorhandler.parsers.Resolver;
9 |
10 | public class MiniMessageInteractionParser implements Resolver {
11 | public static final MiniMessageInteractionParser INSTANCE = new MiniMessageInteractionParser();
12 | private static final TagResolver INTERACTION = TagResolver.builder()
13 | .resolvers(
14 | StandardTags.hoverEvent(),
15 | StandardTags.clickEvent(),
16 | StandardTags.insertion()
17 | )
18 | .build();
19 |
20 | private MiniMessageInteractionParser() {}
21 |
22 | @Override
23 | public String getType() {
24 | return ParserTypes.INTERACTION;
25 | }
26 |
27 | @Override
28 | public String parseString(@NotNull String string, @NotNull OutputType outputType) {
29 | return switch (outputType) {
30 | case SPIGOT -> {
31 | string = string.replace('§', '&');
32 | yield MiniMessageMessenger.LEGACY_COMPONENT_SERIALIZER.serialize(MiniMessageMessenger.MINI_MESSAGE.deserialize(string, INTERACTION));
33 | }
34 | case MINI_MESSAGE -> string;
35 | };
36 | }
37 |
38 | @Override
39 | public @NotNull TagResolver getResolver() {
40 | return INTERACTION;
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/src/main/java/org/lushplugins/chatcolorhandler/parsers/custom/MiniMessagePlaceholderParser.java:
--------------------------------------------------------------------------------
1 | package org.lushplugins.chatcolorhandler.parsers.custom;
2 |
3 | import net.kyori.adventure.text.minimessage.tag.resolver.TagResolver;
4 | import net.kyori.adventure.text.minimessage.tag.standard.StandardTags;
5 | import org.jetbrains.annotations.NotNull;
6 | import org.lushplugins.chatcolorhandler.messengers.MiniMessageMessenger;
7 | import org.lushplugins.chatcolorhandler.parsers.ParserTypes;
8 | import org.lushplugins.chatcolorhandler.parsers.Resolver;
9 |
10 | public class MiniMessagePlaceholderParser implements Resolver {
11 | public static final MiniMessagePlaceholderParser INSTANCE = new MiniMessagePlaceholderParser();
12 | private static final TagResolver VANILLA_PLACEHOLDERS = TagResolver.builder()
13 | .resolvers(
14 | StandardTags.keybind(),
15 | StandardTags.translatable(),
16 | StandardTags.translatableFallback(),
17 | StandardTags.selector(),
18 | StandardTags.score(),
19 | StandardTags.nbt()
20 | )
21 | .build();
22 |
23 | private MiniMessagePlaceholderParser() {}
24 |
25 | @Override
26 | public String getType() {
27 | return ParserTypes.PLACEHOLDER;
28 | }
29 |
30 | @Override
31 | public String parseString(@NotNull String string, @NotNull OutputType outputType) {
32 | return switch (outputType) {
33 | case SPIGOT -> {
34 | string = string.replace('§', '&');
35 | yield MiniMessageMessenger.LEGACY_COMPONENT_SERIALIZER.serialize(MiniMessageMessenger.MINI_MESSAGE.deserialize(string, VANILLA_PLACEHOLDERS));
36 | }
37 | case MINI_MESSAGE -> string;
38 | };
39 | }
40 |
41 | @Override
42 | public @NotNull TagResolver getResolver() {
43 | return VANILLA_PLACEHOLDERS;
44 | }
45 | }
46 |
--------------------------------------------------------------------------------
/src/main/java/org/lushplugins/chatcolorhandler/parsers/custom/MiniMessageResolverParser.java:
--------------------------------------------------------------------------------
1 | package org.lushplugins.chatcolorhandler.parsers.custom;
2 |
3 | import net.kyori.adventure.audience.Audience;
4 | import net.kyori.adventure.text.minimessage.tag.resolver.TagResolver;
5 | import org.bukkit.entity.Player;
6 | import org.jetbrains.annotations.NotNull;
7 | import org.lushplugins.chatcolorhandler.messengers.MiniMessageMessenger;
8 | import org.lushplugins.chatcolorhandler.parsers.Parser;
9 | import org.lushplugins.chatcolorhandler.parsers.ParserTypes;
10 | import org.lushplugins.chatcolorhandler.parsers.Resolver;
11 |
12 | import java.util.List;
13 | import java.util.Objects;
14 |
15 | public class MiniMessageResolverParser implements Parser {
16 | public static final MiniMessageResolverParser INSTANCE = new MiniMessageResolverParser();
17 |
18 | private MiniMessageResolverParser() {}
19 |
20 | @Override
21 | public String getType() {
22 | return ParserTypes.PLACEHOLDER;
23 | }
24 |
25 | @Override
26 | public String parseString(@NotNull String string, @NotNull OutputType outputType) {
27 | return parseString(string, outputType, null);
28 | }
29 |
30 | @Override
31 | public String parseString(@NotNull String string, @NotNull OutputType outputType, Player player) {
32 | return switch (outputType) {
33 | case SPIGOT -> {
34 | string = string.replace('§', '&');
35 |
36 | TagResolver resolver = Resolver.combineResolvers(player instanceof Audience audience ? audience : null, getPlaceholderResolvers());
37 | yield MiniMessageMessenger.LEGACY_COMPONENT_SERIALIZER.serialize(MiniMessageMessenger.MINI_MESSAGE.deserialize(string, resolver));
38 | }
39 | case MINI_MESSAGE -> string;
40 | };
41 | }
42 |
43 | private static List getPlaceholderResolvers() {
44 | return ParserTypes.placeholder().stream()
45 | .map(parser -> parser instanceof Resolver parserResolver ? parserResolver : null)
46 | .filter(Objects::nonNull)
47 | .toList();
48 | }
49 | }
50 |
--------------------------------------------------------------------------------
/src/main/java/org/lushplugins/chatcolorhandler/parsers/custom/MiniMessageTextFormattingParser.java:
--------------------------------------------------------------------------------
1 | package org.lushplugins.chatcolorhandler.parsers.custom;
2 |
3 | import net.kyori.adventure.text.minimessage.tag.resolver.TagResolver;
4 | import net.kyori.adventure.text.minimessage.tag.standard.StandardTags;
5 | import org.jetbrains.annotations.NotNull;
6 | import org.lushplugins.chatcolorhandler.messengers.MiniMessageMessenger;
7 | import org.lushplugins.chatcolorhandler.parsers.ParserTypes;
8 | import org.lushplugins.chatcolorhandler.parsers.Resolver;
9 |
10 | public class MiniMessageTextFormattingParser implements Resolver {
11 | public static final MiniMessageTextFormattingParser INSTANCE = new MiniMessageTextFormattingParser();
12 | private static final TagResolver TEXT_FORMATTING = TagResolver.builder()
13 | .resolvers(
14 | StandardTags.font(),
15 | StandardTags.newline()
16 | )
17 | .build();
18 |
19 | private MiniMessageTextFormattingParser() {}
20 |
21 | @Override
22 | public String getType() {
23 | return ParserTypes.TEXT_FORMATTING;
24 | }
25 |
26 | @Override
27 | public String parseString(@NotNull String string, @NotNull OutputType outputType) {
28 | return switch (outputType) {
29 | case SPIGOT -> {
30 | string = string.replace('§', '&');
31 | yield MiniMessageMessenger.LEGACY_COMPONENT_SERIALIZER.serialize(MiniMessageMessenger.MINI_MESSAGE.deserialize(string, TEXT_FORMATTING));
32 | }
33 | case MINI_MESSAGE -> string;
34 | };
35 | }
36 |
37 | @Override
38 | public @NotNull TagResolver getResolver() {
39 | return TEXT_FORMATTING;
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/src/main/java/org/lushplugins/chatcolorhandler/parsers/custom/MiniPlaceholdersParser.java:
--------------------------------------------------------------------------------
1 | package org.lushplugins.chatcolorhandler.parsers.custom;
2 |
3 | import io.github.miniplaceholders.api.MiniPlaceholders;
4 | import net.kyori.adventure.audience.Audience;
5 | import net.kyori.adventure.text.minimessage.tag.resolver.TagResolver;
6 | import org.jetbrains.annotations.NotNull;
7 | import org.lushplugins.chatcolorhandler.parsers.ParserTypes;
8 | import org.lushplugins.chatcolorhandler.parsers.Resolver;
9 |
10 | public class MiniPlaceholdersParser implements Resolver {
11 | public static final MiniPlaceholdersParser INSTANCE = new MiniPlaceholdersParser();
12 |
13 | private MiniPlaceholdersParser() {}
14 |
15 | @Override
16 | public String getType() {
17 | return ParserTypes.PLACEHOLDER;
18 | }
19 |
20 | @Override
21 | public @NotNull TagResolver getResolver() {
22 | return MiniPlaceholders.getGlobalPlaceholders();
23 | }
24 |
25 | @Override
26 | public @NotNull TagResolver getResolver(Audience audience) {
27 | return MiniPlaceholders.getAudienceGlobalPlaceholders(audience);
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/src/main/java/org/lushplugins/chatcolorhandler/parsers/custom/ParticleParser.java:
--------------------------------------------------------------------------------
1 | package org.lushplugins.chatcolorhandler.parsers.custom;
2 |
3 | import org.bukkit.Location;
4 | import org.bukkit.Particle;
5 | import org.bukkit.entity.Player;
6 | import org.jetbrains.annotations.NotNull;
7 | import org.lushplugins.chatcolorhandler.parsers.Parser;
8 | import org.lushplugins.chatcolorhandler.parsers.ParserTypes;
9 |
10 | import java.util.regex.Matcher;
11 | import java.util.regex.Pattern;
12 |
13 | public class ParticleParser implements Parser {
14 |
15 | private static final Pattern PARTICLE_PATTERN = Pattern.compile("");
16 |
17 | public static final ParticleParser INSTANCE = new ParticleParser();
18 |
19 | private ParticleParser() {}
20 |
21 | @Override
22 | public String getType() {
23 | return ParserTypes.PARTICLE;
24 | }
25 |
26 | @Override
27 | public String parseString(@NotNull String string, @NotNull OutputType outputType) {
28 | return string;
29 | }
30 |
31 | @Override
32 | public String parseString(@NotNull String string, @NotNull Parser.OutputType outputType, Player player) {
33 | if (!string.contains("");
16 |
17 | private static final float DEFAULT_VOLUME = 1.0f;
18 | private static final float DEFAULT_PITCH = 1.0f;
19 |
20 | public static final SoundParser INSTANCE = new SoundParser();
21 |
22 | private SoundParser() {}
23 |
24 | @Override
25 | public String getType() {
26 | return ParserTypes.SOUND;
27 | }
28 |
29 | @Override
30 | public String parseString(@NotNull String string, @NotNull OutputType outputType) {
31 | return string;
32 | }
33 |
34 | @Override
35 | public String parseString(@NotNull String string, @NotNull OutputType outputType, Player player) {
36 | if (!string.contains(" ChatColor.translateAlternateColorCodes('&', string);
22 | case MINI_MESSAGE -> string;
23 | };
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/test/build.gradle.kts:
--------------------------------------------------------------------------------
1 | subprojects {
2 | group = "org.lushplugins"
3 | version = "2.0.0-beta"
4 |
5 | java {
6 | toolchain.languageVersion.set(JavaLanguageVersion.of(21))
7 | }
8 | }
--------------------------------------------------------------------------------
/test/paper/build.gradle.kts:
--------------------------------------------------------------------------------
1 | plugins {
2 | id("xyz.jpenilla.run-paper") version ("2.2.4")
3 | }
4 |
5 | dependencies {
6 | // Dependencies
7 | compileOnly("io.papermc.paper:paper-api:1.21.1-R0.1-SNAPSHOT")
8 |
9 | // Libraries
10 | implementation(project(":"))
11 | implementation("io.github.revxrsal:lamp.common:4.0.0-rc.12")
12 | implementation("io.github.revxrsal:lamp.bukkit:4.0.0-rc.12")
13 | }
14 |
15 | tasks {
16 | shadowJar {
17 | relocate("org.lushplugins.chatcolorhandler.", "org.lushplugins.chatcolorhandlerpapertest.libraries.chatcolor.")
18 | }
19 |
20 | processResources{
21 | expand(project.properties)
22 |
23 | inputs.property("version", rootProject.version)
24 | filesMatching("plugin.yml") {
25 | expand("version" to rootProject.version)
26 | }
27 | filesMatching("paper-plugin.yml") {
28 | expand("version" to rootProject.version)
29 | }
30 | }
31 |
32 | runServer {
33 | minecraftVersion("1.21.4")
34 |
35 | downloadPlugins {
36 | hangar("PlaceholderAPI", "2.11.6")
37 | modrinth("miniplaceholders", "wck4v0R0")
38 | modrinth("viaversion", "5.4.0-SNAPSHOT+742")
39 | modrinth("viabackwards", "5.4.0-SNAPSHOT+425")
40 | }
41 | }
42 | }
--------------------------------------------------------------------------------
/test/paper/src/main/java/org/lushplugins/chatcolorhandlertest/paper/ChatColorHandlerTest.java:
--------------------------------------------------------------------------------
1 | package org.lushplugins.chatcolorhandlertest.paper;
2 |
3 | import org.lushplugins.chatcolorhandlertest.paper.command.MainCommand;
4 | import org.bukkit.plugin.java.JavaPlugin;
5 | import revxrsal.commands.Lamp;
6 | import revxrsal.commands.bukkit.BukkitLamp;
7 | import revxrsal.commands.bukkit.actor.BukkitCommandActor;
8 |
9 | public final class ChatColorHandlerTest extends JavaPlugin {
10 | private static ChatColorHandlerTest plugin;
11 |
12 | @Override
13 | public void onEnable() {
14 | plugin = this;
15 |
16 | Lamp lamp = BukkitLamp.builder(this).build();
17 | lamp.register(new MainCommand());
18 | }
19 |
20 | @Override
21 | public void onDisable() {
22 | plugin = null;
23 | }
24 |
25 | public static ChatColorHandlerTest getInstance() {
26 | return plugin;
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/test/paper/src/main/java/org/lushplugins/chatcolorhandlertest/paper/command/MainCommand.java:
--------------------------------------------------------------------------------
1 | package org.lushplugins.chatcolorhandlertest.paper.command;
2 |
3 | import org.lushplugins.chatcolorhandlertest.paper.ChatColorHandlerTest;
4 | import net.kyori.adventure.audience.Audience;
5 | import net.kyori.adventure.text.Component;
6 | import org.bukkit.command.CommandSender;
7 | import org.bukkit.entity.Player;
8 | import org.lushplugins.chatcolorhandler.ChatColorHandler;
9 | import org.lushplugins.chatcolorhandler.ModernChatColorHandler;
10 | import org.lushplugins.chatcolorhandlertest.paper.test.TestRunner;
11 | import revxrsal.commands.annotation.Command;
12 | import revxrsal.commands.annotation.Subcommand;
13 | import revxrsal.commands.bukkit.actor.BukkitCommandActor;
14 |
15 | @SuppressWarnings("unused")
16 | @Command("chatcolorhandlerpapertest")
17 | public class MainCommand {
18 |
19 | @Subcommand("parse")
20 | public void parse(CommandSender sender, String content) {
21 | Audience audience = Audience.audience(sender);
22 |
23 | Component message;
24 | if (sender instanceof Player player) {
25 | message = ModernChatColorHandler.translate(content, player);
26 | } else {
27 | message = ModernChatColorHandler.translate(content);
28 | }
29 |
30 | audience.sendMessage(message);
31 | }
32 |
33 | @Subcommand("parse-legacy")
34 | public void parseLegacy(CommandSender sender, String content) {
35 | String message;
36 | if (sender instanceof Player player) {
37 | message = ChatColorHandler.translate(content, player);
38 | } else {
39 | message = ChatColorHandler.translate(content);
40 | }
41 |
42 | sender.sendMessage(message);
43 | }
44 |
45 | @Subcommand("run-tests")
46 | public void runTests(BukkitCommandActor actor) {
47 | TestRunner.runTest(actor.sender(), actor.asPlayer());
48 | }
49 |
50 | @Subcommand("version")
51 | public void version(CommandSender sender) {
52 | ChatColorHandler.sendMessage(sender, "a8e1ffYou are currently running ChatColorHandlerTest (paper) version :b1e0" + ChatColorHandlerTest.getInstance().getDescription().getVersion());
53 | }
54 | }
55 |
--------------------------------------------------------------------------------
/test/paper/src/main/java/org/lushplugins/chatcolorhandlertest/paper/test/TestRunner.java:
--------------------------------------------------------------------------------
1 | package org.lushplugins.chatcolorhandlertest.paper.test;
2 |
3 | import org.bukkit.Bukkit;
4 | import org.bukkit.command.CommandSender;
5 | import org.bukkit.entity.Player;
6 | import org.jetbrains.annotations.NotNull;
7 | import org.jetbrains.annotations.Nullable;
8 | import org.lushplugins.chatcolorhandler.ChatColorHandler;
9 | import org.lushplugins.chatcolorhandler.ModernChatColorHandler;
10 | import org.lushplugins.chatcolorhandler.parsers.ParserTypes;
11 | import org.lushplugins.chatcolorhandlertest.paper.ChatColorHandlerTest;
12 |
13 | import java.util.ArrayList;
14 | import java.util.List;
15 | import java.util.function.Function;
16 | import java.util.logging.Level;
17 |
18 | public class TestRunner {
19 | private boolean ran = false;
20 | private final @Nullable Player player;
21 | private final List tests = new ArrayList<>();
22 |
23 | public TestRunner() {
24 | this(null);
25 | }
26 |
27 | public TestRunner(@Nullable Player player) {
28 | this.player = player;
29 | }
30 |
31 | public TestRunner addTest(@NotNull String input, @Nullable String expectedOutput, @NotNull Function translate) {
32 | this.tests.add(new Test(input, expectedOutput, translate));
33 | return this;
34 | }
35 |
36 | public void run() {
37 | if (ran) {
38 | throw new IllegalStateException("This test has already been ran");
39 | }
40 | ran = true;
41 |
42 | for (Test test : tests) {
43 | test.run(player);
44 | }
45 | }
46 |
47 | record Test(@NotNull String input, @Nullable String expectedOutput, @NotNull Function translate) {
48 |
49 | private String run() {
50 | return run(null);
51 | }
52 |
53 | private String run(Player player) {
54 | String output = "";
55 | try {
56 | output = translate.apply(input);
57 | } catch (Exception e) {
58 | Bukkit.getLogger().log(Level.WARNING, e.getMessage(), e);
59 | }
60 |
61 | if (expectedOutput == null || expectedOutput.equals(output)) {
62 | ChatColorHandlerTest.getInstance().getLogger().info("""
63 | Test Passed:
64 | Input '%s' passed tests.
65 | Received: '%s'
66 | """.formatted(input, output));
67 |
68 | if (player != null) {
69 | player.sendMessage("§a✔§r: " + output);
70 | }
71 | } else {
72 | ChatColorHandlerTest.getInstance().getLogger().info("""
73 | Test Failed:
74 | Input '%s' failed tests.
75 | Expected: '%s'
76 | Received: '%s'
77 | """.formatted(input, expectedOutput, output));
78 |
79 | if (player != null) {
80 | player.sendMessage("§c✕§r: " + output);
81 | }
82 | }
83 |
84 | return output;
85 | }
86 | }
87 |
88 | public static void runTest(CommandSender sender, @Nullable Player player) {
89 | String inputOne = "A4D3F9This is a test string &rusing &lbold, underline &r and shows your name: <#F9CAA4>%player_name%#F9CAA4>";
90 |
91 | new TestRunner(player)
92 | .addTest(
93 | inputOne,
94 | "§x§a§4§d§3§f§9This is a test string §rusing §lbold, §nunderline§r§r and shows your name: ",
95 | ChatColorHandler::translate)
96 | .addTest(
97 | inputOne,
98 | "§x§a§4§d§3§f§9This is a test string §rusing §lbold, §nunderline§r§r and shows your name: §x§f§9§c§a§a§4" + (player != null ? player.getName() : "%player_name%"),
99 | (input) -> ChatColorHandler.translate(input, player))
100 | .addTest(
101 | inputOne,
102 | "§x§a§4§d§3§f§9This is a test string §rusing §lbold, §nunderline§r§r and shows your name: §x§f§9§c§a§a§4%player_name%",
103 | (input) -> ChatColorHandler.translate(input, ParserTypes.color()))
104 | .addTest(
105 | inputOne,
106 | "§x§a§4§d§3§f§9This is a test string §rusing §lbold, §nunderline§r§r and shows your name: §x§f§9§c§a§a§4%player_name%",
107 | (input) -> ChatColorHandler.translate(input, player, ParserTypes.color()))
108 | .addTest(
109 | inputOne,
110 | "A4D3F9This is a test string &rusing &lbold, underline &r and shows your name: <#F9CAA4>" + (player != null ? player.getName() : "%player_name%") + "#F9CAA4>",
111 | (input) -> ChatColorHandler.translate(input, player, ParserTypes.placeholder()))
112 | .run();
113 |
114 | player.sendMessage(" ");
115 | player.sendMessage(ModernChatColorHandler.translate(inputOne));
116 | player.sendMessage(ModernChatColorHandler.translate(inputOne, player));
117 | player.sendMessage(ModernChatColorHandler.translate(inputOne, ParserTypes.color()));
118 | player.sendMessage(ModernChatColorHandler.translate(inputOne, player, ParserTypes.color()));
119 | player.sendMessage(ModernChatColorHandler.translate(inputOne, player, ParserTypes.placeholder()));
120 | }
121 | }
122 |
--------------------------------------------------------------------------------
/test/paper/src/main/resources/paper-plugin.yml:
--------------------------------------------------------------------------------
1 | name: ChatColorHandlerPaperTest
2 | version: '${version}'
3 | main: org.lushplugins.chatcolorhandlertest.paper.ChatColorHandlerTest
4 | api-version: '1.20'
5 | dependencies:
6 | server:
7 | PlaceholderAPI:
8 | load: BEFORE
9 | required: false
10 | MiniPlaceholders:
11 | load: BEFORE
12 | required: false
--------------------------------------------------------------------------------
/test/paper/src/main/resources/plugin.yml:
--------------------------------------------------------------------------------
1 | name: ChatColorHandlerPaperTest
2 | version: '${version}'
3 | main: org.lushplugins.chatcolorhandlertest.paper.ChatColorHandlerTest
4 | api-version: '1.20'
5 | depend:
6 | - PlaceholderAPI
7 | - MiniPlaceholders
--------------------------------------------------------------------------------
/test/spigot/build.gradle.kts:
--------------------------------------------------------------------------------
1 | plugins {
2 | id("xyz.jpenilla.run-paper") version ("2.2.4")
3 | }
4 |
5 | dependencies {
6 | // Dependencies
7 | compileOnly("org.spigotmc:spigot-api:1.21.1-R0.1-SNAPSHOT")
8 |
9 | // Libraries
10 | implementation(project(":"))
11 | implementation("io.github.revxrsal:lamp.common:4.0.0-rc.12")
12 | implementation("io.github.revxrsal:lamp.bukkit:4.0.0-rc.12")
13 | }
14 |
15 | tasks {
16 | shadowJar {
17 | relocate("org.lushplugins.chatcolorhandler.", "org.lushplugins.chatcolorhandlerpapertest.libraries.chatcolor.")
18 | }
19 |
20 | processResources{
21 | expand(project.properties)
22 |
23 | inputs.property("version", rootProject.version)
24 | filesMatching("plugin.yml") {
25 | expand("version" to rootProject.version)
26 | }
27 | filesMatching("paper-plugin.yml") {
28 | expand("version" to rootProject.version)
29 | }
30 | }
31 |
32 | runServer {
33 | minecraftVersion("1.21.1")
34 |
35 | downloadPlugins {
36 | hangar("PlaceholderAPI", "2.11.6")
37 | modrinth("miniplaceholders", "wck4v0R0")
38 | }
39 | }
40 | }
--------------------------------------------------------------------------------
/test/spigot/src/main/java/org/lushplugins/chatcolorhandlertest/spigot/ChatColorHandlerTest.java:
--------------------------------------------------------------------------------
1 | package org.lushplugins.chatcolorhandlertest.spigot;
2 |
3 | import org.lushplugins.chatcolorhandlertest.spigot.command.MainCommand;
4 | import org.bukkit.plugin.java.JavaPlugin;
5 | import revxrsal.commands.Lamp;
6 | import revxrsal.commands.bukkit.BukkitLamp;
7 | import revxrsal.commands.bukkit.actor.BukkitCommandActor;
8 |
9 | public final class ChatColorHandlerTest extends JavaPlugin {
10 | private static ChatColorHandlerTest plugin;
11 |
12 | @Override
13 | public void onEnable() {
14 | plugin = this;
15 |
16 | Lamp lamp = BukkitLamp.builder(this).build();
17 | lamp.register(new MainCommand());
18 | }
19 |
20 | @Override
21 | public void onDisable() {
22 | plugin = null;
23 | }
24 |
25 | public static ChatColorHandlerTest getInstance() {
26 | return plugin;
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/test/spigot/src/main/java/org/lushplugins/chatcolorhandlertest/spigot/command/MainCommand.java:
--------------------------------------------------------------------------------
1 | package org.lushplugins.chatcolorhandlertest.spigot.command;
2 |
3 | import org.lushplugins.chatcolorhandlertest.spigot.ChatColorHandlerTest;
4 | import org.bukkit.command.CommandSender;
5 | import org.bukkit.entity.Player;
6 | import org.lushplugins.chatcolorhandler.ChatColorHandler;
7 | import revxrsal.commands.annotation.Command;
8 | import revxrsal.commands.annotation.Subcommand;
9 |
10 | @SuppressWarnings("unused")
11 | @Command("chatcolorhandlerpapertest")
12 | public class MainCommand {
13 |
14 | @Subcommand("parse")
15 | public void parse(CommandSender sender, String content) {
16 | String message;
17 | if (sender instanceof Player player) {
18 | message = ChatColorHandler.translate(content, player);
19 | } else {
20 | message = ChatColorHandler.translate(content);
21 | }
22 |
23 | sender.sendMessage(message);
24 | }
25 |
26 | @Subcommand("version")
27 | public void version(CommandSender sender) {
28 | ChatColorHandler.sendMessage(sender, "a8e1ffYou are currently running ChatColorHandlerTest (spigot) version :b1e0" + ChatColorHandlerTest.getInstance().getDescription().getVersion());
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/test/spigot/src/main/resources/plugin.yml:
--------------------------------------------------------------------------------
1 | name: ChatColorHandlerTest
2 | version: '${version}'
3 | main: org.lushplugins.chatcolorhandlertest.spigot.ChatColorHandlerTest
4 | api-version: '1.20'
5 | depend:
6 | - PlaceholderAPI
7 | - MiniPlaceholders
--------------------------------------------------------------------------------