mirror of
https://github.com/Suiranoil/SkinRestorer.git
synced 2026-01-16 04:42:12 +00:00
Compare commits
395 Commits
v1.2.6+1.2
...
1.20.3-mul
| Author | SHA1 | Date | |
|---|---|---|---|
|
41793a904f
|
|||
|
3c2269ca6e
|
|||
|
4cf35048b0
|
|||
|
965af68461
|
|||
|
8fba8a997e
|
|||
|
a0d8f3d518
|
|||
|
aa3cb3df09
|
|||
|
0524b5dab8
|
|||
|
301428147d
|
|||
|
2e655ce1f3
|
|||
|
7dcd1d4e81
|
|||
|
1aa606038e
|
|||
|
e832e02fd4
|
|||
|
ffd2a0dba7
|
|||
|
76e801c944
|
|||
|
da754aa830
|
|||
|
69a561f679
|
|||
|
b5bed1c441
|
|||
|
f36390a3d5
|
|||
|
b3b524c53a
|
|||
|
e6b2dcb4eb
|
|||
|
5f8a868e5c
|
|||
|
fce13237f9
|
|||
|
c987d48738
|
|||
|
583205febc
|
|||
|
fb7a4d11e9
|
|||
|
1d8472e35c
|
|||
|
f604ac2c8b
|
|||
|
8d4c2e9f83
|
|||
|
84a06898a2
|
|||
|
11ecf88eb2
|
|||
|
c192cdce7e
|
|||
|
d54cb48697
|
|||
|
6df0cf4fd2
|
|||
|
2cec50afae
|
|||
|
01a045541c
|
|||
|
5bab96e269
|
|||
|
a0b557be51
|
|||
|
7fad7de710
|
|||
|
06e5a2f5b7
|
|||
|
05ef681621
|
|||
|
daf0310072
|
|||
|
a3bd44af89
|
|||
|
8af1dd8f12
|
|||
|
1c7f97551d
|
|||
|
a8cc81e570
|
|||
|
6ce3484824
|
|||
|
b518305028
|
|||
|
e5134cdd71
|
|||
|
220f9c6ac3
|
|||
|
742b4cb4d0
|
|||
|
1bacee4b22
|
|||
|
4a87bd43ca
|
|||
|
96ea077004
|
|||
|
91eead3d1f
|
|||
|
2ea4d3f3e7
|
|||
|
e65501e620
|
|||
|
64aaf906b0
|
|||
|
fb644adbc3
|
|||
|
b4e76576c2
|
|||
|
556ecdc039
|
|||
|
1b8a6c2f5d
|
|||
|
4cc12e23dc
|
|||
|
28db1ee84c
|
|||
|
119e91e222
|
|||
|
ba6dc5a1e5
|
|||
|
b0333b4b7f
|
|||
|
21f00231af
|
|||
|
6f5b291008
|
|||
|
df58fe8c89
|
|||
|
2325b3b35c
|
|||
|
ad6d64e8d4
|
|||
|
07b4887f60
|
|||
|
30d21c9424
|
|||
|
1c51796409
|
|||
|
02613e40fd
|
|||
|
dc0d69f0f0
|
|||
|
53e0740e43
|
|||
|
1b6afd5d6e
|
|||
|
aeab757b05
|
|||
|
ef247f1ad3
|
|||
|
1eff73e9b3
|
|||
|
7e05f1eec9
|
|||
|
81d05fe991
|
|||
|
757d46b231
|
|||
|
3b15f7b341
|
|||
|
38a2fd7214
|
|||
|
7af35cda9f
|
|||
|
3d92617e47
|
|||
|
f357e6c985
|
|||
|
e4c9e1b3cd
|
|||
|
3ef3318ed3
|
|||
|
3fff2eb920
|
|||
|
50a49b33a2
|
|||
|
8de7f3a16f
|
|||
|
5b384c32d6
|
|||
|
8a730c7c61
|
|||
|
0feba3f4b2
|
|||
|
fcd76d9a87
|
|||
|
8119a08c80
|
|||
|
6c159d6aa2
|
|||
|
04e781d36f
|
|||
|
4b30b8b53d
|
|||
|
0921cf70bf
|
|||
|
760ac65ab3
|
|||
|
2e7a9edc20
|
|||
|
8457e6f4ab
|
|||
|
66a9c1fbbf
|
|||
|
e3754cda90
|
|||
|
daedf692a1
|
|||
|
c2afd37fae
|
|||
|
e0b1de4ae2
|
|||
|
100282d527
|
|||
|
4b48227eea
|
|||
|
a655e0c2ce
|
|||
|
a7298a1909
|
|||
|
e1a58f4246
|
|||
|
496c8d8078
|
|||
|
0070d3ab1c
|
|||
|
7ec929335b
|
|||
|
100c1d5974
|
|||
|
26d4a5ef51
|
|||
|
ced2801d1c
|
|||
|
41b6a5d030
|
|||
|
10534b01a7
|
|||
|
138350545a
|
|||
|
7ab9f722e8
|
|||
|
5c2a50fd98
|
|||
|
088ad089ed
|
|||
|
6fbc53e38b
|
|||
|
364ca540be
|
|||
|
cec5bac608
|
|||
|
040d26cb33
|
|||
|
ef79818d5c
|
|||
|
0d4a0034b8
|
|||
|
c70f780ec2
|
|||
|
ecdfff5dc7
|
|||
|
16ffeea4f3
|
|||
|
d374c80659
|
|||
|
d85942041b
|
|||
|
1cafc91935
|
|||
|
5d28269b94
|
|||
|
2293fc2399
|
|||
|
3971f2efbf
|
|||
|
516601a899
|
|||
|
2e3b2649b3
|
|||
|
07d620ae2f
|
|||
|
ad2177848c
|
|||
|
8136354af1
|
|||
|
fee25d2d04
|
|||
|
33926b15e1
|
|||
|
226d3f7bcb
|
|||
|
c81adc7320
|
|||
|
583e59f9d8
|
|||
|
8081e443b9
|
|||
|
61e1ada760
|
|||
|
|
d04a3beecf | ||
|
|
89b06fcfc7 | ||
|
|
d7fffdab1b | ||
|
|
9e175ddabb | ||
|
|
74a571b62c | ||
|
|
8ae29eae89 | ||
|
|
9f0fac4b2a | ||
|
|
e68aa90953 | ||
|
34de47e13e
|
|||
|
08e7f1792b
|
|||
|
6a7f5f2096
|
|||
|
4d6d4faafd
|
|||
|
823b2ea3f6
|
|||
|
a63b6c3867
|
|||
|
dfe6d7af42
|
|||
|
49b2a2fc1e
|
|||
|
592a6ac253
|
|||
|
33e5d80825
|
|||
|
348471b30d
|
|||
|
e52baaef4c
|
|||
|
03dad0f8dc
|
|||
|
9150179391
|
|||
|
374137bc47
|
|||
|
a35a64c017
|
|||
|
120a8b7e3d
|
|||
|
cab2ab3239
|
|||
|
95cc551df7
|
|||
|
3b71911ba0
|
|||
|
7d1d4966b0
|
|||
|
dda9a9632a
|
|||
|
b0d95a4d4f
|
|||
|
8338f5dac9
|
|||
|
b475168fb1
|
|||
|
b5ad427ff3
|
|||
|
f2b53f4f3f
|
|||
|
8820e3ba3f
|
|||
|
8329adc476
|
|||
|
71c826e8b7
|
|||
|
7e063977c5
|
|||
|
0d56c339d1
|
|||
|
fb7020354a
|
|||
|
da9afc4bef
|
|||
|
43df28381d
|
|||
|
1884256051
|
|||
|
60c890d2b0
|
|||
|
ba47986e94
|
|||
|
aa02759780
|
|||
|
4a43a0de41
|
|||
|
eeda2f5857
|
|||
|
5e0f67a1e6
|
|||
|
557ff88299
|
|||
|
7292a25d7f
|
|||
|
62256c77a9
|
|||
|
5f6236cdf5
|
|||
|
30f027d37f
|
|||
|
026ceb2337
|
|||
|
c650aa1386
|
|||
|
4be7335d7c
|
|||
|
bec3c9d179
|
|||
|
d9b5d6c12b
|
|||
|
86a1d4de14
|
|||
|
adcb696e35
|
|||
|
b3ca228d02
|
|||
|
f43fa13044
|
|||
|
3203435453
|
|||
|
8a9802f763
|
|||
|
7add58da44
|
|||
|
9bd8a53657
|
|||
|
4a40a52d24
|
|||
|
48976117cb
|
|||
|
7aa3316d0f
|
|||
|
7eedb79453
|
|||
|
93e9907e03
|
|||
|
de4e8a3178
|
|||
|
04faa2953f
|
|||
|
75b3abb847
|
|||
|
e7d8dfa6b6
|
|||
|
017478374d
|
|||
|
3360bc567b
|
|||
|
75889944e9
|
|||
|
8baad37227
|
|||
|
4280659c70
|
|||
|
2e7c42b619
|
|||
|
9873747dfb
|
|||
|
b209893511
|
|||
|
3a8a513180
|
|||
|
9e0c41482f
|
|||
|
449e286fba
|
|||
|
299a8b621f
|
|||
|
c536dd36e2
|
|||
|
5b45fcb25c
|
|||
|
b2ae60ac73
|
|||
|
b850086ad8
|
|||
|
6611077b93
|
|||
|
417ed7d695
|
|||
|
40cddfc2a7
|
|||
|
0d6ed15014
|
|||
|
182f0c4497
|
|||
|
3492f82214
|
|||
|
2f5edc7069
|
|||
|
29a8b406c1
|
|||
|
304c3b371d
|
|||
|
d286270bdc
|
|||
|
2bd9e55b53
|
|||
|
19677fe63b
|
|||
|
08b734bb27
|
|||
|
49290171e2
|
|||
|
abcc213ee0
|
|||
|
9e85e78398
|
|||
|
d4efe0a177
|
|||
|
7fcf515790
|
|||
|
4339753271
|
|||
|
251fdce7ff
|
|||
|
5a02ab83e8
|
|||
|
5c31b5f881
|
|||
|
b72d0c1e85
|
|||
|
067cd5c731
|
|||
|
1eed415053
|
|||
|
42cef73318
|
|||
|
266d56ed93
|
|||
|
423ee4e694
|
|||
|
7cf5b8e1d6
|
|||
|
e9bdfaefca
|
|||
|
e1773d4d79
|
|||
|
84da16fae6
|
|||
|
ac9189ecdc
|
|||
|
7131cb76d0
|
|||
|
4943c7d8f6
|
|||
|
82baf0b63e
|
|||
|
c755417ebf
|
|||
|
6cf7d0c465
|
|||
|
20feec931f
|
|||
|
73ffc37f2d
|
|||
|
726f4ed7a8
|
|||
|
fbbc37e4b1
|
|||
|
19114de347
|
|||
|
455d0deddc
|
|||
|
0eaaf6a950
|
|||
|
7c8aba6f71
|
|||
|
99675bb5ee
|
|||
|
6ad656c388
|
|||
|
fece751f0f
|
|||
|
ab75eddc90
|
|||
|
f9aa3f664a
|
|||
|
9edbb21128
|
|||
|
4851687fc9
|
|||
|
7bceb0d5ed
|
|||
|
65957b61c5
|
|||
|
|
8c3d1fe831 | ||
|
|
1dc1789fa4 | ||
|
|
85a0fa760b | ||
|
|
0a00b40655 | ||
|
f98808583d
|
|||
|
21c98a4224
|
|||
|
727fb7880f
|
|||
|
3ed9c67faa
|
|||
|
b6b10c1e9e
|
|||
|
399636e1ae
|
|||
|
3e88781186
|
|||
|
686d659126
|
|||
|
8f20c6a68a
|
|||
|
dd3c5ac58d
|
|||
|
3e8463c4ce
|
|||
|
ed8e961067
|
|||
|
1b36f6465c
|
|||
|
b1d2d1de7b
|
|||
|
f7e486cd24
|
|||
|
0294661375
|
|||
|
a555d61940
|
|||
|
a14f39a766
|
|||
|
952ec5b669
|
|||
|
d474c7902f
|
|||
|
b3c4340b89
|
|||
|
ca55fe845d
|
|||
|
8280c501cf
|
|||
|
baa9a93386
|
|||
|
2389b774e7
|
|||
|
af72f3eefd
|
|||
|
aa8086c417
|
|||
|
a4b4297af2
|
|||
|
a50c6e431c
|
|||
|
639901667f
|
|||
|
4969d171b7
|
|||
|
299601998d
|
|||
|
d07edf6913
|
|||
|
845c13dca5
|
|||
|
cd7e8c58c9
|
|||
|
d4746fcc0c
|
|||
|
56f05f5a88
|
|||
|
9b4406d840
|
|||
|
45840e0418
|
|||
|
abefad1f39
|
|||
|
b9699486ab
|
|||
|
bed53909a8
|
|||
|
799ec9d52e
|
|||
|
9733490dd0
|
|||
|
972bd4c8d8
|
|||
|
82f078bfdb
|
|||
|
f567996ced
|
|||
|
a8bc27395e
|
|||
|
440deda2ef
|
|||
|
18b0d6bd8e
|
|||
|
2f674abb01
|
|||
|
f6d9b26413
|
|||
|
1a7cea803f
|
|||
|
8febe5c496
|
|||
|
35a2c60161
|
|||
|
badc8c3494
|
|||
|
9ddfa334ea
|
|||
|
dbb7c19f10
|
|||
|
7b6937bf8e
|
|||
|
9816796cae
|
|||
|
c352560689
|
|||
|
5b918f4b90
|
|||
|
e45de1e180
|
|||
|
1f9e1b8f1e
|
|||
|
03a694bde2
|
|||
|
d59bff14c9
|
|||
|
fbb15a2dab
|
|||
|
e50035abc7
|
|||
|
f7bcca2476
|
|||
|
bdbf3e6748
|
|||
|
07e3aaf60c
|
|||
|
59ecc5a56a
|
|||
|
0ca106c3f5
|
|||
|
e4e1ff874d
|
|||
|
80f481ddd2
|
|||
|
e9784e6bd5
|
|||
|
74fb9798b4
|
|||
|
b3c1fa1c34
|
|||
|
a15cbdd512
|
|||
|
257068d37f
|
|||
|
c663423f33
|
|||
|
63fa9bfb98
|
|||
|
818a3439f1
|
|||
|
0890e369b4
|
|||
|
4cd0df4634
|
|||
|
1ef5cb4082
|
|||
|
e114ac2b37
|
262
.editorconfig
Normal file
262
.editorconfig
Normal file
@@ -0,0 +1,262 @@
|
||||
root = true
|
||||
|
||||
[*]
|
||||
charset = utf-8
|
||||
end_of_line = crlf
|
||||
indent_size = 4
|
||||
indent_style = space
|
||||
insert_final_newline = true
|
||||
tab_width = 4
|
||||
trim_trailing_whitespace = false
|
||||
ij_continuation_indent_size = 8
|
||||
|
||||
[*.properties]
|
||||
ij_any_keep_blank_lines_in_code = unset
|
||||
|
||||
[*.java]
|
||||
ij_java_align_consecutive_assignments = false
|
||||
ij_java_align_consecutive_variable_declarations = false
|
||||
ij_java_align_group_field_declarations = false
|
||||
ij_java_align_multiline_annotation_parameters = true
|
||||
ij_java_align_multiline_array_initializer_expression = false
|
||||
ij_java_align_multiline_assignment = false
|
||||
ij_java_align_multiline_binary_operation = true
|
||||
ij_java_align_multiline_chained_methods = false
|
||||
ij_java_align_multiline_extends_list = false
|
||||
ij_java_align_multiline_for = true
|
||||
ij_java_align_multiline_method_parentheses = false
|
||||
ij_java_align_multiline_parameters = false
|
||||
ij_java_align_multiline_parameters_in_calls = false
|
||||
ij_java_align_multiline_parenthesized_expression = false
|
||||
ij_java_align_multiline_records = true
|
||||
ij_java_align_multiline_resources = true
|
||||
ij_java_align_multiline_ternary_operation = false
|
||||
ij_java_align_multiline_text_blocks = false
|
||||
ij_java_align_multiline_throws_list = false
|
||||
ij_java_align_subsequent_simple_methods = false
|
||||
ij_java_align_throws_keyword = false
|
||||
ij_java_annotation_parameter_wrap = normal
|
||||
ij_java_array_initializer_new_line_after_left_brace = false
|
||||
ij_java_array_initializer_right_brace_on_new_line = false
|
||||
ij_java_array_initializer_wrap = off
|
||||
ij_java_assert_statement_colon_on_next_line = false
|
||||
ij_java_assert_statement_wrap = off
|
||||
ij_java_assignment_wrap = off
|
||||
ij_java_binary_operation_sign_on_next_line = false
|
||||
ij_java_binary_operation_wrap = off
|
||||
ij_java_blank_lines_after_anonymous_class_header = 0
|
||||
ij_java_blank_lines_after_class_header = 0
|
||||
ij_java_blank_lines_after_imports = 1
|
||||
ij_java_blank_lines_after_package = 1
|
||||
ij_java_blank_lines_around_class = 1
|
||||
ij_java_blank_lines_around_field = 0
|
||||
ij_java_blank_lines_around_field_in_interface = 0
|
||||
ij_java_blank_lines_around_initializer = 1
|
||||
ij_java_blank_lines_around_method = 1
|
||||
ij_java_blank_lines_around_method_in_interface = 1
|
||||
ij_java_blank_lines_before_class_end = 0
|
||||
ij_java_blank_lines_before_imports = 1
|
||||
ij_java_blank_lines_before_method_body = 0
|
||||
ij_java_blank_lines_before_package = 0
|
||||
ij_java_block_brace_style = end_of_line
|
||||
ij_java_block_comment_at_first_column = true
|
||||
ij_java_call_parameters_new_line_after_left_paren = false
|
||||
ij_java_call_parameters_right_paren_on_new_line = false
|
||||
ij_java_call_parameters_wrap = off
|
||||
ij_java_case_statement_on_separate_line = true
|
||||
ij_java_catch_on_new_line = false
|
||||
ij_java_class_annotation_wrap = split_into_lines
|
||||
ij_java_class_brace_style = end_of_line
|
||||
ij_java_class_count_to_use_import_on_demand = 5
|
||||
ij_java_class_names_in_javadoc = 1
|
||||
ij_java_do_not_indent_top_level_class_members = false
|
||||
ij_java_do_not_wrap_after_single_annotation = false
|
||||
ij_java_do_while_brace_force = never
|
||||
ij_java_doc_add_blank_line_after_description = true
|
||||
ij_java_doc_add_blank_line_after_param_comments = false
|
||||
ij_java_doc_add_blank_line_after_return = false
|
||||
ij_java_doc_add_p_tag_on_empty_lines = true
|
||||
ij_java_doc_align_exception_comments = true
|
||||
ij_java_doc_align_param_comments = true
|
||||
ij_java_doc_do_not_wrap_if_one_line = false
|
||||
ij_java_doc_enable_formatting = true
|
||||
ij_java_doc_enable_leading_asterisks = true
|
||||
ij_java_doc_indent_on_continuation = false
|
||||
ij_java_doc_keep_empty_lines = true
|
||||
ij_java_doc_keep_empty_parameter_tag = true
|
||||
ij_java_doc_keep_empty_return_tag = true
|
||||
ij_java_doc_keep_empty_throws_tag = true
|
||||
ij_java_doc_keep_invalid_tags = true
|
||||
ij_java_doc_param_description_on_new_line = false
|
||||
ij_java_doc_preserve_line_breaks = false
|
||||
ij_java_doc_use_throws_not_exception_tag = true
|
||||
ij_java_else_on_new_line = false
|
||||
ij_java_entity_dd_suffix = EJB
|
||||
ij_java_entity_eb_suffix = Bean
|
||||
ij_java_entity_hi_suffix = Home
|
||||
ij_java_entity_lhi_prefix = Local
|
||||
ij_java_entity_lhi_suffix = Home
|
||||
ij_java_entity_li_prefix = Local
|
||||
ij_java_entity_pk_class = java.lang.String
|
||||
ij_java_entity_vo_suffix = VO
|
||||
ij_java_enum_constants_wrap = split_into_lines
|
||||
ij_java_extends_keyword_wrap = off
|
||||
ij_java_extends_list_wrap = off
|
||||
ij_java_field_annotation_wrap = on_every_item
|
||||
ij_java_finally_on_new_line = false
|
||||
ij_java_for_brace_force = never
|
||||
ij_java_for_statement_new_line_after_left_paren = false
|
||||
ij_java_for_statement_right_paren_on_new_line = false
|
||||
ij_java_for_statement_wrap = off
|
||||
ij_java_generate_final_locals = false
|
||||
ij_java_generate_final_parameters = false
|
||||
ij_java_if_brace_force = never
|
||||
ij_java_imports_layout = *, |, javax.**, java.**, |, $*
|
||||
ij_java_indent_case_from_switch = true
|
||||
ij_java_insert_inner_class_imports = false
|
||||
ij_java_insert_override_annotation = true
|
||||
ij_java_keep_blank_lines_before_right_brace = 2
|
||||
ij_java_keep_blank_lines_between_package_declaration_and_header = 2
|
||||
ij_java_keep_blank_lines_in_code = 2
|
||||
ij_java_keep_blank_lines_in_declarations = 2
|
||||
ij_java_keep_control_statement_in_one_line = true
|
||||
ij_java_keep_first_column_comment = true
|
||||
ij_java_keep_indents_on_empty_lines = true
|
||||
ij_java_keep_line_breaks = true
|
||||
ij_java_keep_multiple_expressions_in_one_line = false
|
||||
ij_java_keep_simple_blocks_in_one_line = false
|
||||
ij_java_keep_simple_classes_in_one_line = true
|
||||
ij_java_keep_simple_lambdas_in_one_line = true
|
||||
ij_java_keep_simple_methods_in_one_line = true
|
||||
ij_java_label_indent_absolute = false
|
||||
ij_java_label_indent_size = 0
|
||||
ij_java_lambda_brace_style = end_of_line
|
||||
ij_java_layout_static_imports_separately = true
|
||||
ij_java_line_comment_add_space = false
|
||||
ij_java_line_comment_at_first_column = true
|
||||
ij_java_message_dd_suffix = EJB
|
||||
ij_java_message_eb_suffix = Bean
|
||||
ij_java_method_annotation_wrap = split_into_lines
|
||||
ij_java_method_brace_style = end_of_line
|
||||
ij_java_method_call_chain_wrap = off
|
||||
ij_java_method_parameters_new_line_after_left_paren = false
|
||||
ij_java_method_parameters_right_paren_on_new_line = false
|
||||
ij_java_method_parameters_wrap = off
|
||||
ij_java_modifier_list_wrap = false
|
||||
ij_java_names_count_to_use_import_on_demand = 3
|
||||
ij_java_new_line_after_lparen_in_record_header = false
|
||||
ij_java_parameter_annotation_wrap = normal
|
||||
ij_java_parentheses_expression_new_line_after_left_paren = false
|
||||
ij_java_parentheses_expression_right_paren_on_new_line = false
|
||||
ij_java_place_assignment_sign_on_next_line = false
|
||||
ij_java_prefer_longer_names = true
|
||||
ij_java_prefer_parameters_wrap = false
|
||||
ij_java_record_components_wrap = normal
|
||||
ij_java_repeat_synchronized = true
|
||||
ij_java_replace_instanceof_and_cast = false
|
||||
ij_java_replace_null_check = true
|
||||
ij_java_replace_sum_lambda_with_method_ref = true
|
||||
ij_java_resource_list_new_line_after_left_paren = false
|
||||
ij_java_resource_list_right_paren_on_new_line = false
|
||||
ij_java_resource_list_wrap = off
|
||||
ij_java_rparen_on_new_line_in_record_header = false
|
||||
ij_java_session_dd_suffix = EJB
|
||||
ij_java_session_eb_suffix = Bean
|
||||
ij_java_session_hi_suffix = Home
|
||||
ij_java_session_lhi_prefix = Local
|
||||
ij_java_session_lhi_suffix = Home
|
||||
ij_java_session_li_prefix = Local
|
||||
ij_java_session_si_suffix = Service
|
||||
ij_java_space_after_closing_angle_bracket_in_type_argument = false
|
||||
ij_java_space_after_colon = true
|
||||
ij_java_space_after_comma = true
|
||||
ij_java_space_after_comma_in_type_arguments = true
|
||||
ij_java_space_after_for_semicolon = true
|
||||
ij_java_space_after_quest = true
|
||||
ij_java_space_after_type_cast = true
|
||||
ij_java_space_before_annotation_array_initializer_left_brace = false
|
||||
ij_java_space_before_annotation_parameter_list = false
|
||||
ij_java_space_before_array_initializer_left_brace = false
|
||||
ij_java_space_before_catch_keyword = true
|
||||
ij_java_space_before_catch_left_brace = true
|
||||
ij_java_space_before_catch_parentheses = true
|
||||
ij_java_space_before_class_left_brace = true
|
||||
ij_java_space_before_colon = true
|
||||
ij_java_space_before_colon_in_foreach = true
|
||||
ij_java_space_before_comma = false
|
||||
ij_java_space_before_do_left_brace = true
|
||||
ij_java_space_before_else_keyword = true
|
||||
ij_java_space_before_else_left_brace = true
|
||||
ij_java_space_before_finally_keyword = true
|
||||
ij_java_space_before_finally_left_brace = true
|
||||
ij_java_space_before_for_left_brace = true
|
||||
ij_java_space_before_for_parentheses = true
|
||||
ij_java_space_before_for_semicolon = false
|
||||
ij_java_space_before_if_left_brace = true
|
||||
ij_java_space_before_if_parentheses = true
|
||||
ij_java_space_before_method_call_parentheses = false
|
||||
ij_java_space_before_method_left_brace = true
|
||||
ij_java_space_before_method_parentheses = false
|
||||
ij_java_space_before_opening_angle_bracket_in_type_parameter = false
|
||||
ij_java_space_before_quest = true
|
||||
ij_java_space_before_switch_left_brace = true
|
||||
ij_java_space_before_switch_parentheses = true
|
||||
ij_java_space_before_synchronized_left_brace = true
|
||||
ij_java_space_before_synchronized_parentheses = true
|
||||
ij_java_space_before_try_left_brace = true
|
||||
ij_java_space_before_try_parentheses = true
|
||||
ij_java_space_before_type_parameter_list = false
|
||||
ij_java_space_before_while_keyword = true
|
||||
ij_java_space_before_while_left_brace = true
|
||||
ij_java_space_before_while_parentheses = true
|
||||
ij_java_space_inside_one_line_enum_braces = false
|
||||
ij_java_space_within_empty_array_initializer_braces = false
|
||||
ij_java_space_within_empty_method_call_parentheses = false
|
||||
ij_java_space_within_empty_method_parentheses = false
|
||||
ij_java_spaces_around_additive_operators = true
|
||||
ij_java_spaces_around_assignment_operators = true
|
||||
ij_java_spaces_around_bitwise_operators = true
|
||||
ij_java_spaces_around_equality_operators = true
|
||||
ij_java_spaces_around_lambda_arrow = true
|
||||
ij_java_spaces_around_logical_operators = true
|
||||
ij_java_spaces_around_method_ref_dbl_colon = false
|
||||
ij_java_spaces_around_multiplicative_operators = true
|
||||
ij_java_spaces_around_relational_operators = true
|
||||
ij_java_spaces_around_shift_operators = true
|
||||
ij_java_spaces_around_type_bounds_in_type_parameters = true
|
||||
ij_java_spaces_around_unary_operator = false
|
||||
ij_java_spaces_within_angle_brackets = false
|
||||
ij_java_spaces_within_annotation_parentheses = false
|
||||
ij_java_spaces_within_array_initializer_braces = false
|
||||
ij_java_spaces_within_braces = false
|
||||
ij_java_spaces_within_brackets = false
|
||||
ij_java_spaces_within_cast_parentheses = false
|
||||
ij_java_spaces_within_catch_parentheses = false
|
||||
ij_java_spaces_within_for_parentheses = false
|
||||
ij_java_spaces_within_if_parentheses = false
|
||||
ij_java_spaces_within_method_call_parentheses = false
|
||||
ij_java_spaces_within_method_parentheses = false
|
||||
ij_java_spaces_within_parentheses = false
|
||||
ij_java_spaces_within_record_header = false
|
||||
ij_java_spaces_within_switch_parentheses = false
|
||||
ij_java_spaces_within_synchronized_parentheses = false
|
||||
ij_java_spaces_within_try_parentheses = false
|
||||
ij_java_spaces_within_while_parentheses = false
|
||||
ij_java_special_else_if_treatment = true
|
||||
ij_java_subclass_name_suffix = Impl
|
||||
ij_java_ternary_operation_signs_on_next_line = false
|
||||
ij_java_ternary_operation_wrap = off
|
||||
ij_java_test_name_suffix = Test
|
||||
ij_java_throws_keyword_wrap = normal
|
||||
ij_java_throws_list_wrap = off
|
||||
ij_java_use_external_annotations = false
|
||||
ij_java_use_fq_class_names = false
|
||||
ij_java_use_relative_indents = false
|
||||
ij_java_use_single_class_imports = true
|
||||
ij_java_variable_annotation_wrap = normal
|
||||
ij_java_visibility = public
|
||||
ij_java_while_brace_force = never
|
||||
ij_java_while_on_new_line = false
|
||||
ij_java_wrap_comments = false
|
||||
ij_java_wrap_first_method_in_call_chain = false
|
||||
ij_java_wrap_long_lines = false
|
||||
90
.github/ISSUE_TEMPLATE/bug_report.yaml
vendored
Normal file
90
.github/ISSUE_TEMPLATE/bug_report.yaml
vendored
Normal file
@@ -0,0 +1,90 @@
|
||||
name: Bug Report
|
||||
description: Report a bug encountered with SkinRestorer
|
||||
title: "[Bug]: "
|
||||
labels: ["bug"]
|
||||
body:
|
||||
- type: markdown
|
||||
attributes:
|
||||
value: |
|
||||
🐛 **Before submitting:**
|
||||
- Ensure you're using the latest mod version
|
||||
- Ensure this bug is reproducible consistently
|
||||
- Check existing issues for duplicates
|
||||
|
||||
- type: input
|
||||
id: mod-version
|
||||
attributes:
|
||||
label: SkinRestorer Version
|
||||
description: Exact version of the mod
|
||||
placeholder: e.g., 2.2.1
|
||||
validations:
|
||||
required: true
|
||||
|
||||
- type: input
|
||||
id: minecraft-version
|
||||
attributes:
|
||||
label: Minecraft Version
|
||||
description: Full Minecraft version
|
||||
placeholder: e.g., 1.21.4
|
||||
validations:
|
||||
required: true
|
||||
|
||||
- type: input
|
||||
id: loader-version
|
||||
attributes:
|
||||
label: Mod Loader & Version
|
||||
description: Fabric/Quilt/Forge/NeoForge version
|
||||
placeholder: e.g., Fabric 0.15.7
|
||||
validations:
|
||||
required: true
|
||||
|
||||
- type: input
|
||||
id: java-version
|
||||
attributes:
|
||||
label: Java Version
|
||||
placeholder: e.g. 17, 21
|
||||
validations:
|
||||
required: true
|
||||
|
||||
- type: textarea
|
||||
id: description
|
||||
attributes:
|
||||
label: Bug Description
|
||||
description: What happened vs what you expected to happen
|
||||
validations:
|
||||
required: true
|
||||
|
||||
- type: textarea
|
||||
id: steps
|
||||
attributes:
|
||||
label: Reproduction Steps
|
||||
description: Provide step-by-step instructions or a video showing how to reproduce the issue.
|
||||
placeholder: |
|
||||
1.
|
||||
2.
|
||||
3.
|
||||
Or a video demonstrating the issue.
|
||||
validations:
|
||||
required: true
|
||||
|
||||
- type: textarea
|
||||
id: logs
|
||||
attributes:
|
||||
label: Relevant Logs
|
||||
description: |
|
||||
Please provide any relevant logs, especially error logs from your server console or `latest.log` file.
|
||||
**Important**: Paste the FULL log content. Use a service like [mclo.gs](https://mclo.gs/).
|
||||
render: shell
|
||||
validations:
|
||||
required: true
|
||||
|
||||
- type: checkboxes
|
||||
id: confirmations
|
||||
attributes:
|
||||
label: Confirmations
|
||||
options:
|
||||
- label: I've checked for existing issues
|
||||
required: true
|
||||
- label: This bug is reproducible consistently
|
||||
required: true
|
||||
- label: I've tested without other mods
|
||||
1
.github/ISSUE_TEMPLATE/config.yml
vendored
Normal file
1
.github/ISSUE_TEMPLATE/config.yml
vendored
Normal file
@@ -0,0 +1 @@
|
||||
blank_issues_enabled: true
|
||||
52
.github/ISSUE_TEMPLATE/feature_request.yaml
vendored
Normal file
52
.github/ISSUE_TEMPLATE/feature_request.yaml
vendored
Normal file
@@ -0,0 +1,52 @@
|
||||
name: Feature Request
|
||||
description: Suggest a new feature for SkinRestorer
|
||||
title: "[Feature Request]: "
|
||||
labels: ["enhancement"]
|
||||
body:
|
||||
- type: markdown
|
||||
attributes:
|
||||
value: |
|
||||
💡 **Before submitting:**
|
||||
- Check existing feature requests for duplicates
|
||||
- Be clear and concise
|
||||
- Explain the *why* and the *how*
|
||||
|
||||
- type: textarea
|
||||
id: description
|
||||
attributes:
|
||||
label: Feature Description
|
||||
description: Detailed description of the feature
|
||||
validations:
|
||||
required: true
|
||||
|
||||
- type: textarea
|
||||
id: motivation
|
||||
attributes:
|
||||
label: Motivation
|
||||
description: Why is this feature needed? What problem does it solve?
|
||||
validations:
|
||||
required: true
|
||||
|
||||
- type: textarea
|
||||
id: use-cases
|
||||
attributes:
|
||||
label: Use Cases
|
||||
description: How would this feature be used and who would benefit?
|
||||
validations:
|
||||
required: true
|
||||
|
||||
- type: textarea
|
||||
id: implementation-ideas
|
||||
attributes:
|
||||
label: Implementation Ideas (Optional)
|
||||
description: Any thoughts on how it could be implemented?
|
||||
validations:
|
||||
required: false
|
||||
|
||||
- type: checkboxes
|
||||
id: confirmations
|
||||
attributes:
|
||||
label: Confirmations
|
||||
options:
|
||||
- label: I've checked for existing feature requests
|
||||
required: true
|
||||
66
.github/workflows/build.yml
vendored
66
.github/workflows/build.yml
vendored
@@ -1,33 +1,39 @@
|
||||
name: build
|
||||
on: [pull_request, push]
|
||||
on:
|
||||
push:
|
||||
paths-ignore:
|
||||
- '.github/**'
|
||||
- '*.md'
|
||||
pull_request:
|
||||
paths-ignore:
|
||||
- '.github/**'
|
||||
- '*.md'
|
||||
|
||||
jobs:
|
||||
build:
|
||||
strategy:
|
||||
matrix:
|
||||
java: [
|
||||
21,
|
||||
]
|
||||
os: [ubuntu-22.04]
|
||||
runs-on: ${{ matrix.os }}
|
||||
steps:
|
||||
- name: checkout repository
|
||||
uses: actions/checkout@v3
|
||||
- name: validate gradle wrapper
|
||||
uses: gradle/wrapper-validation-action@v1
|
||||
- name: setup jdk ${{ matrix.java }}
|
||||
uses: actions/setup-java@v3
|
||||
with:
|
||||
java-version: ${{ matrix.java }}
|
||||
distribution: 'microsoft'
|
||||
- name: make gradle wrapper executable
|
||||
if: ${{ runner.os != 'Windows' }}
|
||||
run: chmod +x ./gradlew
|
||||
- name: build
|
||||
run: ./gradlew build
|
||||
- name: capture build artifacts
|
||||
if: ${{ runner.os == 'Linux' && matrix.java == '21' }}
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: Artifacts
|
||||
path: build/libs/
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- uses: actions/setup-java@v4
|
||||
with:
|
||||
distribution: temurin
|
||||
java-version: 21
|
||||
|
||||
- name: Setup Gradle
|
||||
uses: gradle/actions/setup-gradle@v3
|
||||
with:
|
||||
cache-read-only: false
|
||||
|
||||
- name: Change wrapper permissions
|
||||
run: chmod +x ./gradlew
|
||||
|
||||
- name: Run build with Gradle Wrapper
|
||||
run: ./gradlew build
|
||||
|
||||
- name: Upload built JARs
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: skin-restorer-artifacts
|
||||
path: ./*/build/libs/*.jar
|
||||
|
||||
36
.github/workflows/release.yml
vendored
Normal file
36
.github/workflows/release.yml
vendored
Normal file
@@ -0,0 +1,36 @@
|
||||
name: release
|
||||
on:
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
release:
|
||||
environment: release
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- uses: actions/setup-java@v4
|
||||
with:
|
||||
distribution: temurin
|
||||
java-version: 21
|
||||
|
||||
- name: Setup Gradle
|
||||
uses: gradle/actions/setup-gradle@v3
|
||||
with:
|
||||
cache-read-only: false
|
||||
|
||||
- name: Change wrapper permissions
|
||||
run: chmod +x ./gradlew
|
||||
|
||||
- name: Publish to CurseForge, Modrinth
|
||||
run: ./gradlew build publishMods
|
||||
env:
|
||||
CURSEFORGE_API_KEY: ${{ secrets.CURSEFORGE_API_KEY }}
|
||||
MODRINTH_TOKEN: ${{ secrets.MODRINTH_TOKEN }}
|
||||
|
||||
- name: Upload built JARs
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: skin-restorer-artifacts
|
||||
path: ./*/build/libs/*.jar
|
||||
4
.gitignore
vendored
4
.gitignore
vendored
@@ -28,6 +28,6 @@ bin/
|
||||
|
||||
*.DS_Store
|
||||
|
||||
# fabric
|
||||
|
||||
.architectury-transformer/
|
||||
run/
|
||||
scripts/
|
||||
|
||||
159
CHANGELOG.md
Normal file
159
CHANGELOG.md
Normal file
@@ -0,0 +1,159 @@
|
||||
# Changelog
|
||||
All notable changes to this project will be documented in this file.
|
||||
|
||||
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
|
||||
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
||||
|
||||
## [2.5.0] - 2026-01-14
|
||||
### Added
|
||||
- Added collection skin provider (allows assigning random skins from a predefined set)
|
||||
- Added `forceFirstJoinSkinFetch` config option to force skin fetch on first join even if player already has a skin
|
||||
|
||||
## [2.4.3] - 2025-07-25
|
||||
### Fixed
|
||||
- Fixed crash on client when loading player head skin (fixes [#63](https://github.com/Suiranoil/SkinRestorer/issues/63) and [#64](https://github.com/Suiranoil/SkinRestorer/issues/64))
|
||||
- Fixed server freeze when loading player head skin
|
||||
|
||||
## [2.4.2] - 2025-07-13
|
||||
### Fixed
|
||||
- Fix crash when head profile name is null (fixes [#60](https://github.com/Suiranoil/SkinRestorer/issues/60) and [#61](https://github.com/Suiranoil/SkinRestorer/issues/61))
|
||||
|
||||
## [2.4.1] - 2025-07-09
|
||||
### Changed
|
||||
- Log full exception and argument when unable to fetch/set skin
|
||||
### Fixed
|
||||
- Fixed mojang provider using offline uuids when unable to fetch actual uuid resulting in `no profile with uuid` error
|
||||
|
||||
## [2.4.0] - 2025-07-05
|
||||
### Fixed
|
||||
- Added support for player heads
|
||||
|
||||
## [2.3.5] - 2025-06-21
|
||||
### Fixed
|
||||
- Fix mod not loading on client
|
||||
|
||||
## [2.3.4] - 2025-06-19
|
||||
### Added
|
||||
- Added support for minecraft 1.21.6
|
||||
|
||||
## [2.3.3] - 2025-06-01
|
||||
### Fixed
|
||||
- Fixed forge mixin crash (closes [#54](https://github.com/Suiranoil/SkinRestorer/issues/53))
|
||||
### Removed
|
||||
- Removed minecraft 1.19 support
|
||||
|
||||
## [2.3.2] - 2025-05-24
|
||||
### Fixed
|
||||
- Fixed mixin incompatibility with ModernFix (closes [#42](https://github.com/Suiranoil/SkinRestorer/issues/52))
|
||||
|
||||
## [2.3.1] - 2025-05-03
|
||||
### Added
|
||||
- Added support for minecraft 1.19-1.19.4
|
||||
### Changed
|
||||
- Use services and session server urls from environment
|
||||
|
||||
## [2.3.0] - 2025-03-27
|
||||
### Added
|
||||
- Added `skinApplyDelayOnJoin` config option (see [wiki](https://github.com/Suiranoil/SkinRestorer/wiki/Configuration#skinapplydelayonjoin))
|
||||
### Changed
|
||||
- Updated to 1.21.5
|
||||
### Removed
|
||||
- [NeoForge] Dropped support for NeoForge on Minecraft 1.20.5-1.20.6
|
||||
|
||||
## [2.2.1] - 2024-12-23
|
||||
### Fixed
|
||||
- Fixed game not closing because of mineskin working threads (closes [#41](https://github.com/Suiranoil/SkinRestorer/issues/41))
|
||||
|
||||
## [2.2.0] - 2024-12-02
|
||||
### Added
|
||||
- Added support for [SkinShuffle](https://modrinth.com/mod/skinshuffle) clients (requires FabricAPI on Fabric)
|
||||
(closes [#34](https://github.com/Suiranoil/SkinRestorer/issues/34))
|
||||
- Added `providers.mineskin.apiKey` config option (see [wiki](https://github.com/Suiranoil/SkinRestorer/wiki/Configuration#providersmineskin))
|
||||
### Changed
|
||||
- Migrated to MineSkin's new API V2
|
||||
### Fixed
|
||||
- Fixed `providers` config validation
|
||||
### Removed
|
||||
- Dropped support for NeoForge on Minecraft 1.20.2-1.20.4
|
||||
|
||||
## [2.1.0] - 2024-09-26
|
||||
### Added
|
||||
- Added `config reload` command for dynamic configuration updates
|
||||
- Added `refreshSkinOnJoin` config option (see [wiki](https://github.com/Suiranoil/SkinRestorer/wiki/Configuration#refreshskinonjoin))
|
||||
- Implemented caching for skin providers
|
||||
- Added provider configurations (see [wiki](https://github.com/Suiranoil/SkinRestorer/wiki/Configuration#providers))
|
||||
- Added username and url validation for requests
|
||||
### Fixed
|
||||
- Fixed old skin directory migration not working
|
||||
- Prevented overwriting existing skin files during migration
|
||||
|
||||
## [2.0.3] - 2024-08-20
|
||||
### Added
|
||||
- Added `firstJoinSkinProvider` config option (see [wiki](https://github.com/Suiranoil/SkinRestorer/wiki/Config#firstjoinskinprovider))
|
||||
### Fixed
|
||||
- Fixed ability to set config values to `null`
|
||||
|
||||
## [2.0.2] - 2024-08-04
|
||||
### Added
|
||||
- Backported to minecraft 1.20-1.20.2
|
||||
- [Forge] Added support for Forge
|
||||
### Changed
|
||||
- Changed minimum java version to 17 for minecraft 1.20-1.20.4
|
||||
|
||||
## [2.0.1] - 2024-07-16
|
||||
### Added
|
||||
- Added Traditional Chinese translation ([#24](https://github.com/Suiranoil/SkinRestorer/pull/24)) - *yichifauzi*, *notlin4*
|
||||
### Fixed
|
||||
- Fixed concurrent modification exception
|
||||
|
||||
## [2.0.0] - 2024-07-03
|
||||
### Added
|
||||
- Added support for NeoForge
|
||||
- Added support for singleplayer
|
||||
- Added ely.by skin provider
|
||||
- Added `/skin refresh` command to get up-to-date skin
|
||||
- Added `/skin reset` command to remove skin data
|
||||
- Added proper support for secure servers
|
||||
- Added support for permissions api
|
||||
- Added translations
|
||||
### Changed
|
||||
- Changed to save skin data per world
|
||||
### Fixed
|
||||
- Fixed entity flickering on skin reload
|
||||
- Fixed player being left in invalid state on skin reload if on death screen
|
||||
|
||||
## [1.2.6] - 2024-06-25
|
||||
### Added
|
||||
- Added support for command blocks
|
||||
### Changed
|
||||
- Changed to better skin refresh logic
|
||||
### Fixed
|
||||
- Fixed no permission level for /skin clear targets
|
||||
- Fixed loading world screen on skin change
|
||||
|
||||
## [1.2.4] - 2023-09-30
|
||||
### Fixed
|
||||
- Fixed player stops riding entity with skin change
|
||||
- Fixed armor and hand items not displaying with skin change
|
||||
|
||||
## [1.2.3] - 2023-06-10
|
||||
### Changed
|
||||
- Updated to 1.20-1.20.1
|
||||
|
||||
## [1.2.2] - 2022-12-21
|
||||
### Changed
|
||||
- Updated to 1.19.3
|
||||
|
||||
## [1.2.1] - 2022-11-24
|
||||
### Fixed
|
||||
- Fixed incorrect filepath resolvement on linux systems
|
||||
|
||||
## [1.2.0] - 2022-11-18
|
||||
### Added
|
||||
- Added support for fake players ([#4](https://github.com/Suiranoil/SkinRestorer/pull/4)) - *CaveNightingale*
|
||||
### Changed
|
||||
- Allow player to apply their skin changes immediately ([#4](https://github.com/Suiranoil/SkinRestorer/pull/4)) - _CaveNightingale_
|
||||
|
||||
## [1.0.4] - 2021-08-28
|
||||
### Fixed
|
||||
- Fixed "invalid player data" exception
|
||||
3
CHANGELOG_LATEST.md
Normal file
3
CHANGELOG_LATEST.md
Normal file
@@ -0,0 +1,3 @@
|
||||
### Added
|
||||
- Added collection skin provider (allows assigning random skins from a predefined set) (see [wiki](https://github.com/Suiranoil/SkinRestorer/wiki/Configuration#providerscollection))
|
||||
- Added `forceFirstJoinSkinFetch` config option to force skin fetch on first join even if player already has a skin (see [wiki](https://github.com/Suiranoil/SkinRestorer/wiki/Configuration#forcefirstjoinskinfetch))
|
||||
2
LICENSE
2
LICENSE
@@ -1,6 +1,6 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2021 LionariusPy
|
||||
Copyright (c) 2021-2024 Lionarius
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
|
||||
73
README.md
73
README.md
@@ -1,49 +1,44 @@
|
||||
# SkinRestorer
|
||||

|
||||

|
||||

|
||||
[](https://www.curseforge.com/minecraft/mc-mods/skinrestorer)
|
||||
[](https://modrinth.com/mod/skinrestorer)
|
||||
|
||||
<a href="https://modrinth.com/mod/skinrestorer"><img src="https://raw.githubusercontent.com/Suiranoil/badges/main/assets/minecraft/platform/modrinth/mini/badge.svg" alt="Modrinth"></a>
|
||||
<a href="https://www.curseforge.com/minecraft/mc-mods/skinrestorer"><img src="https://raw.githubusercontent.com/Suiranoil/badges/main/assets/minecraft/platform/curseforge/mini/badge.svg" alt="CurseForge"></a>
|
||||
|
||||
SkinRestorer is a **server-side** only mod for Fabric that allows players to use and change skins on servers running in offline/insecure mode.
|
||||
A server-side mod for managing and restoring player skins.
|
||||
|
||||
## Features
|
||||
- **Set Skins from Mojang Account**: Fetch and apply skins using a valid Minecraft account name.
|
||||
- **Set Skins from URL**: Apply skins from any image URL, supporting both classic (Steve) and slim (Alex) skin models.
|
||||
## ✨ Features
|
||||
|
||||
## Command Usage Guide
|
||||
- **Set skins from Mojang Account**: Fetch and apply skins using a valid Minecraft username.
|
||||
- **Set skins from Ely.by**: Fetch and apply skins using a valid [Ely.by](https://ely.by/) username.
|
||||
- **Set skins from URL**: Fetch and apply skins from any image URL, supporting both classic (Steve) and slim (Alex) skin
|
||||
models.
|
||||
- **Automatic skin fetching**: Automatically fetch skin from Mojang/Ely.by when a player joins the server running in
|
||||
offline/insecure mode ([configurable](https://github.com/Suiranoil/SkinRestorer/wiki/Configuration)).
|
||||
- **Singleplayer support**: Apply skins individually for each world.
|
||||
- **Permissions API support**
|
||||
- **SkinShuffle support**: Allow players with [SkinShuffle](https://modrinth.com/mod/skinshuffle) installed to apply skins using GUI.
|
||||
|
||||
### Set Mojang Skin
|
||||
```
|
||||
/skin set mojang <skin_name> [<targets>]
|
||||
```
|
||||
- **Parameters:**
|
||||
- `<skin_name>`: Minecraft account name to fetch the skin from.
|
||||
- `[<targets>]`: (Optional, server operators only) Player(s) to apply the skin to.
|
||||
## 📜 Command Usage Guide
|
||||
|
||||
### Set Web Skin
|
||||
```
|
||||
/skin set web (classic|slim) "<url>" [<targets>]
|
||||
```
|
||||
- **Parameters:**
|
||||
- `(classic|slim)`: Type of the skin model (`classic` for Steve model, `slim` for Alex model).
|
||||
- `"<url>"`: URL pointing to the skin image file (ensure it follows Minecraft's skin size and format requirements).
|
||||
- `[<targets>]`: (Optional, server operators only) Player(s) to apply the skin to.
|
||||
For a detailed list of available commands and their usage, please visit
|
||||
the [commands wiki page](https://github.com/Suiranoil/SkinRestorer/wiki/Commands).
|
||||
|
||||
### Clear Skin
|
||||
```
|
||||
/skin clear [<targets>]
|
||||
```
|
||||
- **Parameters:**
|
||||
- `[<targets>]`: (Optional, server operators only) Player(s) to clear the skin for.
|
||||
## ❌ Known Incompatibilities
|
||||
|
||||
### Notes:
|
||||
- If `targets` is not specified, the command will apply to the player executing the command.
|
||||
- **[Arclight](https://github.com/IzzelAliz/Arclight) (<=1.20.1)**: Trials or older versions are not compatible due to
|
||||
mixin conflicts.
|
||||
As an alternative, consider using the [SkinsRestorer](https://www.spigotmc.org/resources/skinsrestorer.2124/) plugin.
|
||||
|
||||
### Examples:
|
||||
```
|
||||
/skin set mojang Notch
|
||||
/skin set web classic "http://example.com/skin.png"
|
||||
/skin clear @a
|
||||
```
|
||||
## 🪙 Donation
|
||||
|
||||
If you enjoy using **SkinRestorer** and would like to support its development, you can contribute through the following
|
||||
platforms:
|
||||
|
||||
<a href="https://ko-fi.com/lionarius"><img src="https://raw.githubusercontent.com/Suiranoil/badges/main/assets/donation/kofi/mini/badge.svg" alt="Ko-fi" height="32"></a>
|
||||
|
||||
<a href="https://boosty.to/lionarius"><img src="https://raw.githubusercontent.com/Suiranoil/badges/main/assets/donation/boosty/mini/badge.svg" alt="Boosty" height="32"></a>
|
||||
|
||||
Bitcoin (BTC): `1Ndbwny8pxdnWXFgadp95fp97y5JqMJKTX`
|
||||
USDT (TRC20): `TGXn8wrqku5KLzwPWQAeH7wgnV4UzwHEae`
|
||||
USDT (TON): `UQAQF18Xlmx-V1oZ90C2YOju5qI7q1LgrCP5QaIUhqIELmDS`
|
||||
|
||||
Thank you for your generosity!
|
||||
|
||||
62
build.gradle
62
build.gradle
@@ -1,41 +1,29 @@
|
||||
plugins {
|
||||
id 'fabric-loom' version '1.7-SNAPSHOT'
|
||||
// see https://fabricmc.net/develop/ for new versions
|
||||
id 'fabric-loom' version '1.10-SNAPSHOT' apply false
|
||||
// see https://projects.neoforged.net/neoforged/moddevgradle for new versions
|
||||
id 'net.neoforged.moddev' version '2.0.+' apply false
|
||||
// see https://files.minecraftforge.net/net/minecraftforge/gradle/ForgeGradle/ for new versions
|
||||
id 'net.minecraftforge.gradle' version '6.0.+' apply false
|
||||
id 'org.parchmentmc.librarian.forgegradle' version '1.+' apply false
|
||||
|
||||
id 'org.spongepowered.mixin' version '0.7-SNAPSHOT' apply false
|
||||
|
||||
id 'me.modmuss50.mod-publish-plugin' version '0.8.+' apply false
|
||||
}
|
||||
|
||||
archivesBaseName = project.archives_base_name
|
||||
version = "${project.mod_version}+${project.minecraft_version}"
|
||||
group = project.maven_group
|
||||
|
||||
repositories {
|
||||
maven { url = "https://masa.dy.fi/maven" }
|
||||
}
|
||||
|
||||
dependencies {
|
||||
minecraft "com.mojang:minecraft:${project.minecraft_version}"
|
||||
mappings "net.fabricmc:yarn:${project.yarn_mappings}:v2"
|
||||
modImplementation "net.fabricmc:fabric-loader:${project.loader_version}"
|
||||
}
|
||||
|
||||
processResources {
|
||||
inputs.property "version", project.version
|
||||
|
||||
filesMatching("fabric.mod.json") {
|
||||
expand "version": project.version
|
||||
}
|
||||
}
|
||||
|
||||
tasks.withType(JavaCompile).configureEach {
|
||||
it.options.encoding = "UTF-8"
|
||||
|
||||
it.options.release.set(21)
|
||||
}
|
||||
|
||||
java {
|
||||
withSourcesJar()
|
||||
}
|
||||
|
||||
jar {
|
||||
from("LICENSE") {
|
||||
rename { "${it}_${project.archivesBaseName}"}
|
||||
}
|
||||
allprojects {
|
||||
repositories {
|
||||
exclusiveContent {
|
||||
forRepository {
|
||||
maven {
|
||||
name = 'lionarius-repository'
|
||||
url = 'https://reposilite.lionarius.ru/releases'
|
||||
}
|
||||
}
|
||||
filter {
|
||||
includeGroupAndSubgroups('org.mineskin')
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
3
buildSrc/build.gradle
Normal file
3
buildSrc/build.gradle
Normal file
@@ -0,0 +1,3 @@
|
||||
plugins {
|
||||
id 'groovy-gradle-plugin'
|
||||
}
|
||||
110
buildSrc/src/main/groovy/multiloader-common.gradle
Normal file
110
buildSrc/src/main/groovy/multiloader-common.gradle
Normal file
@@ -0,0 +1,110 @@
|
||||
plugins {
|
||||
id 'java-library'
|
||||
}
|
||||
|
||||
base {
|
||||
archivesName = "${mod_id}"
|
||||
version = "${mod_version}+${minecraft_version}-${project.name}"
|
||||
}
|
||||
|
||||
java {
|
||||
toolchain.languageVersion = JavaLanguageVersion.of(java_version)
|
||||
withSourcesJar()
|
||||
}
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
maven {
|
||||
name = 'ParchmentMC'
|
||||
url = 'https://maven.parchmentmc.org'
|
||||
}
|
||||
maven {
|
||||
name = 'Fabric'
|
||||
url = 'https://maven.fabricmc.net'
|
||||
}
|
||||
maven {
|
||||
name = 'Forge'
|
||||
url = 'https://maven.minecraftforge.net'
|
||||
}
|
||||
maven {
|
||||
name = 'NeoForge'
|
||||
url = 'https://maven.neoforged.net/releases'
|
||||
}
|
||||
exclusiveContent {
|
||||
forRepository {
|
||||
maven {
|
||||
name = 'Sponge'
|
||||
url = 'https://repo.spongepowered.org/repository/maven-public'
|
||||
}
|
||||
}
|
||||
filter {
|
||||
includeGroupAndSubgroups('org.spongepowered')
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Declare capabilities on the outgoing configurations.
|
||||
// Read more about capabilities here: https://docs.gradle.org/current/userguide/component_capabilities.html#sec:declaring-additional-capabilities-for-a-local-component
|
||||
['apiElements', 'runtimeElements', 'sourcesElements'].each { variant ->
|
||||
configurations."$variant".outgoing {
|
||||
capability("$group:${base.archivesName.get()}:$version")
|
||||
capability("$group:$mod_id-${project.name}:$version")
|
||||
capability("$group:$mod_id:$version")
|
||||
}
|
||||
}
|
||||
|
||||
sourcesJar {
|
||||
from(rootProject.file('LICENSE')) {
|
||||
rename { "${it}_${mod_name}" }
|
||||
}
|
||||
}
|
||||
|
||||
jar {
|
||||
from(rootProject.file('LICENSE')) {
|
||||
rename { "${it}_${mod_name}" }
|
||||
}
|
||||
|
||||
manifest {
|
||||
attributes([
|
||||
'Specification-Title' : mod_name,
|
||||
'Specification-Vendor' : mod_author,
|
||||
'Specification-Version' : project.jar.archiveVersion,
|
||||
'Implementation-Title' : project.name,
|
||||
'Implementation-Version': project.jar.archiveVersion,
|
||||
'Implementation-Vendor' : mod_author,
|
||||
'Built-On-Minecraft' : minecraft_version
|
||||
])
|
||||
}
|
||||
}
|
||||
|
||||
processResources {
|
||||
def expandProps = [
|
||||
'version' : version,
|
||||
'group' : project.group, //Else we target the task's group.
|
||||
'minecraft_version' : minecraft_version,
|
||||
'minecraft_version_range' : minecraft_version_range,
|
||||
'mod_name' : mod_name,
|
||||
'mod_author' : mod_author,
|
||||
'mod_id' : mod_id,
|
||||
'mod_homepage' : mod_homepage,
|
||||
'mod_sources' : mod_sources,
|
||||
'mod_issues' : mod_issues,
|
||||
'license' : license,
|
||||
'description' : project.description,
|
||||
'credits' : credits,
|
||||
'java_version' : java_version,
|
||||
|
||||
// Loader specific properties
|
||||
'fabric_loader_version' : project.hasProperty('fabric_loader_version') ? fabric_loader_version : '',
|
||||
'forge_version' : project.hasProperty('forge_version') ? forge_version : '',
|
||||
'forge_loader_version_range' : project.hasProperty('forge_loader_version_range') ? forge_loader_version_range : '',
|
||||
'neoforge_version' : project.hasProperty('neoforge_version') ? neoforge_version : '',
|
||||
'neoforge_loader_version_range': project.hasProperty('neoforge_loader_version_range') ? neoforge_loader_version_range : ''
|
||||
]
|
||||
|
||||
filesMatching(['pack.mcmeta', 'fabric.mod.json', 'META-INF/mods.toml', 'META-INF/neoforge.mods.toml', '*.mixins.json']) {
|
||||
expand expandProps
|
||||
}
|
||||
|
||||
inputs.properties(expandProps)
|
||||
}
|
||||
39
buildSrc/src/main/groovy/multiloader-loader.gradle
Normal file
39
buildSrc/src/main/groovy/multiloader-loader.gradle
Normal file
@@ -0,0 +1,39 @@
|
||||
plugins {
|
||||
id 'multiloader-common'
|
||||
}
|
||||
|
||||
configurations {
|
||||
commonJava {
|
||||
canBeResolved = true
|
||||
}
|
||||
commonResources {
|
||||
canBeResolved = true
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
compileOnly(project(':common')) {
|
||||
capabilities {
|
||||
requireCapability "$group:$mod_id"
|
||||
}
|
||||
}
|
||||
commonJava project(path: ':common', configuration: 'commonJava')
|
||||
commonResources project(path: ':common', configuration: 'commonResources')
|
||||
}
|
||||
|
||||
tasks.named('compileJava', JavaCompile) {
|
||||
dependsOn(configurations.commonJava)
|
||||
source(configurations.commonJava)
|
||||
}
|
||||
|
||||
processResources {
|
||||
dependsOn(configurations.commonResources)
|
||||
from(configurations.commonResources)
|
||||
}
|
||||
|
||||
tasks.named('sourcesJar', Jar) {
|
||||
dependsOn(configurations.commonJava)
|
||||
from(configurations.commonJava)
|
||||
dependsOn(configurations.commonResources)
|
||||
from(configurations.commonResources)
|
||||
}
|
||||
46
buildSrc/src/main/groovy/multiloader-publish.gradle
Normal file
46
buildSrc/src/main/groovy/multiloader-publish.gradle
Normal file
@@ -0,0 +1,46 @@
|
||||
plugins {
|
||||
id "me.modmuss50.mod-publish-plugin"
|
||||
}
|
||||
|
||||
publishMods {
|
||||
file = project.layout.buildDirectory.file("libs/${project.archivesBaseName}-${project.version}.jar").map { it.asFile }.getOrNull()
|
||||
|
||||
modLoaders.add(project.name)
|
||||
|
||||
if (project.hasProperty('additional_modloaders') && !additional_modloaders.isEmpty())
|
||||
{
|
||||
def loaders = additional_modloaders.split(',')
|
||||
for (loader in loaders)
|
||||
modLoaders.add(loader)
|
||||
}
|
||||
|
||||
type = STABLE
|
||||
version = project.version
|
||||
displayName = "[${project.name.capitalize()}] ${mod_name} ${mod_version}"
|
||||
changelog = rootProject.file('CHANGELOG_LATEST.md').text
|
||||
|
||||
curseforge {
|
||||
projectId = curseforge_id
|
||||
|
||||
dryRun = providers.environmentVariable("CURSEFORGE_API_KEY").getOrNull() == null
|
||||
accessToken = providers.environmentVariable("CURSEFORGE_API_KEY")
|
||||
|
||||
minecraftVersions.addAll(minecraft_version_list.split(','))
|
||||
serverRequired = true
|
||||
|
||||
if (project.hasProperty('optional_dependencies') && !optional_dependencies.isEmpty())
|
||||
optional(optional_dependencies.split(','))
|
||||
}
|
||||
|
||||
modrinth {
|
||||
projectId = modrinth_id
|
||||
|
||||
dryRun = providers.environmentVariable("MODRINTH_TOKEN").getOrNull() == null
|
||||
accessToken = providers.environmentVariable("MODRINTH_TOKEN")
|
||||
|
||||
minecraftVersions.addAll(minecraft_version_list.split(','))
|
||||
|
||||
if (project.hasProperty('optional_dependencies') && !optional_dependencies.isEmpty())
|
||||
optional(optional_dependencies.split(','))
|
||||
}
|
||||
}
|
||||
43
common/build.gradle
Normal file
43
common/build.gradle
Normal file
@@ -0,0 +1,43 @@
|
||||
plugins {
|
||||
id 'multiloader-common'
|
||||
|
||||
id 'fabric-loom'
|
||||
}
|
||||
|
||||
dependencies {
|
||||
minecraft "com.mojang:minecraft:${minecraft_version}"
|
||||
mappings loom.layered {
|
||||
officialMojangMappings()
|
||||
parchment("org.parchmentmc.data:parchment-${parchment_minecraft}:${parchment_version}@zip")
|
||||
}
|
||||
compileOnly group: 'org.spongepowered', name: 'mixin', version: '0.8.5'
|
||||
|
||||
implementation("org.mineskin:java-client:${mineskin_client_version}")
|
||||
}
|
||||
|
||||
loom {
|
||||
def aw = project.file("src/main/resources/${mod_id}.accesswidener")
|
||||
if (aw.exists()) {
|
||||
accessWidenerPath.set(aw)
|
||||
}
|
||||
|
||||
mixin {
|
||||
useLegacyMixinAp = false
|
||||
}
|
||||
}
|
||||
|
||||
configurations {
|
||||
commonJava {
|
||||
canBeResolved = false
|
||||
canBeConsumed = true
|
||||
}
|
||||
commonResources {
|
||||
canBeResolved = false
|
||||
canBeConsumed = true
|
||||
}
|
||||
}
|
||||
|
||||
artifacts {
|
||||
commonJava sourceSets.main.java.sourceDirectories.singleFile
|
||||
commonResources sourceSets.main.resources.sourceDirectories.singleFile
|
||||
}
|
||||
1
common/gradle.properties
Normal file
1
common/gradle.properties
Normal file
@@ -0,0 +1 @@
|
||||
fabric.loom.dontRemap=true
|
||||
@@ -0,0 +1,202 @@
|
||||
package net.lionarius.skinrestorer;
|
||||
|
||||
import com.google.common.base.Throwables;
|
||||
import com.mojang.authlib.GameProfile;
|
||||
import com.mojang.brigadier.CommandDispatcher;
|
||||
import net.lionarius.skinrestorer.command.SkinCommand;
|
||||
import net.lionarius.skinrestorer.config.Config;
|
||||
import net.lionarius.skinrestorer.config.provider.BuiltInProviderConfig;
|
||||
import net.lionarius.skinrestorer.exception.TransparentException;
|
||||
import net.lionarius.skinrestorer.platform.Services;
|
||||
import net.lionarius.skinrestorer.skin.SkinIO;
|
||||
import net.lionarius.skinrestorer.skin.SkinStorage;
|
||||
import net.lionarius.skinrestorer.skin.SkinValue;
|
||||
import net.lionarius.skinrestorer.skin.provider.*;
|
||||
import net.lionarius.skinrestorer.translation.Translation;
|
||||
import net.lionarius.skinrestorer.util.*;
|
||||
import net.minecraft.commands.CommandSourceStack;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.world.level.storage.LevelResource;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.nio.file.Path;
|
||||
import java.util.Collection;
|
||||
import java.util.HashSet;
|
||||
import java.util.Optional;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
public final class SkinRestorer {
|
||||
public static final String MOD_ID = "skinrestorer";
|
||||
public static final Logger LOGGER = LoggerFactory.getLogger("SkinRestorer");
|
||||
|
||||
private static final SkinProviderRegistry providersRegistry = new SkinProviderRegistry();
|
||||
private static SkinStorage skinStorage;
|
||||
private static Path configDir;
|
||||
private static Config config;
|
||||
private static TickedScheduler tickedScheduler;
|
||||
private static MinecraftServer minecraftServer;
|
||||
|
||||
private SkinRestorer() {}
|
||||
|
||||
public static SkinStorage getSkinStorage() {
|
||||
return SkinRestorer.skinStorage;
|
||||
}
|
||||
|
||||
public static Path getConfigDir() {
|
||||
return SkinRestorer.configDir;
|
||||
}
|
||||
|
||||
public static Config getConfig() {
|
||||
return SkinRestorer.config;
|
||||
}
|
||||
|
||||
public static SkinProviderRegistry getProvidersRegistry() {
|
||||
return SkinRestorer.providersRegistry;
|
||||
}
|
||||
|
||||
public static TickedScheduler getTickedScheduler() {
|
||||
return SkinRestorer.tickedScheduler;
|
||||
}
|
||||
|
||||
public static @Nullable MinecraftServer getMinecraftServer() {
|
||||
return SkinRestorer.minecraftServer;
|
||||
}
|
||||
|
||||
public static Optional<SkinProvider> getProvider(String name) {
|
||||
return Optional.ofNullable(SkinRestorer.providersRegistry.get(name));
|
||||
}
|
||||
|
||||
public static ResourceLocation resourceLocation(String name) {
|
||||
return new ResourceLocation(SkinRestorer.MOD_ID, name);
|
||||
}
|
||||
|
||||
public static String assetPath(String name) {
|
||||
return String.format("/assets/%s/%s", SkinRestorer.MOD_ID, name);
|
||||
}
|
||||
|
||||
public static void onInitialize() {
|
||||
SkinRestorer.configDir = Services.PLATFORM.getConfigDirectory().resolve(SkinRestorer.MOD_ID);
|
||||
SkinRestorer.reloadConfig();
|
||||
|
||||
SkinRestorer.providersRegistry.register(EmptySkinProvider.PROVIDER_NAME, SkinProvider.EMPTY, false);
|
||||
SkinRestorer.providersRegistry.register(SkinShuffleSkinProvider.PROVIDER_NAME, SkinProvider.SKIN_SHUFFLE, false);
|
||||
|
||||
SkinRestorer.registerDefaultSkinProvider(MojangSkinProvider.PROVIDER_NAME, SkinProvider.MOJANG, SkinRestorer.getConfig().providersConfig().mojang());
|
||||
SkinRestorer.registerDefaultSkinProvider(ElyBySkinProvider.PROVIDER_NAME, SkinProvider.ELY_BY, SkinRestorer.getConfig().providersConfig().ely_by());
|
||||
SkinRestorer.registerDefaultSkinProvider(MineskinSkinProvider.PROVIDER_NAME, SkinProvider.MINESKIN, SkinRestorer.getConfig().providersConfig().mineskin());
|
||||
SkinRestorer.registerDefaultSkinProvider(CollectionSkinProvider.PROVIDER_NAME, SkinProvider.COLLECTION, SkinRestorer.getConfig().providersConfig().collection());
|
||||
}
|
||||
|
||||
private static void registerDefaultSkinProvider(String defaultName, SkinProvider provider, BuiltInProviderConfig config) {
|
||||
var isDefaultName = config.name().equals(defaultName);
|
||||
SkinRestorer.providersRegistry.register(defaultName, provider, config.enabled() && isDefaultName);
|
||||
|
||||
if (!isDefaultName && !SkinProvider.BUILTIN_PROVIDER_NAMES.contains(config.name()))
|
||||
SkinRestorer.providersRegistry.register(config.name(), provider, config.enabled());
|
||||
}
|
||||
|
||||
public static void reloadConfig() {
|
||||
SkinRestorer.config = Config.load(SkinRestorer.getConfigDir());
|
||||
Translation.reloadTranslations();
|
||||
WebUtils.recreateHttpClient();
|
||||
|
||||
MojangSkinProvider.reload();
|
||||
ElyBySkinProvider.reload();
|
||||
MineskinSkinProvider.reload();
|
||||
CollectionSkinProvider.reload();
|
||||
}
|
||||
|
||||
public static Collection<ServerPlayer> applySkin(MinecraftServer server, Iterable<GameProfile> targets, SkinValue value, boolean save) {
|
||||
var acceptedPlayers = new HashSet<ServerPlayer>();
|
||||
|
||||
for (var profile : targets) {
|
||||
if (!SkinRestorer.getSkinStorage().hasSavedSkin(profile.getId()))
|
||||
value = value.setOriginalValue(PlayerUtils.getPlayerSkin(profile));
|
||||
|
||||
if (PlayerUtils.areSkinPropertiesEquals(value.value(), PlayerUtils.getPlayerSkin(profile)))
|
||||
continue;
|
||||
|
||||
if (save)
|
||||
SkinRestorer.getSkinStorage().setSkin(profile.getId(), value);
|
||||
|
||||
PlayerUtils.applyRestoredSkin(profile, value.value());
|
||||
|
||||
var player = server.getPlayerList().getPlayer(profile.getId());
|
||||
if (player == null)
|
||||
continue;
|
||||
|
||||
PlayerUtils.refreshPlayer(player);
|
||||
acceptedPlayers.add(player);
|
||||
|
||||
SkinRestorer.getTickedScheduler().cancel(player.getUUID());
|
||||
}
|
||||
|
||||
return acceptedPlayers;
|
||||
}
|
||||
|
||||
public static Collection<ServerPlayer> applySkin(MinecraftServer server, Iterable<GameProfile> targets, SkinValue value) {
|
||||
return SkinRestorer.applySkin(server, targets, value, true);
|
||||
}
|
||||
|
||||
public static CompletableFuture<Result<Collection<ServerPlayer>, String>> setSkinAsync(
|
||||
MinecraftServer server,
|
||||
Collection<GameProfile> targets,
|
||||
SkinProviderContext context,
|
||||
boolean save
|
||||
) {
|
||||
return CompletableFuture.supplyAsync(
|
||||
() -> SkinRestorer.getProvider(context.name()).map(provider -> provider.fetchSkin(context.argument(), context.variant()))
|
||||
)
|
||||
.thenApplyAsync(result -> {
|
||||
if (result.isEmpty())
|
||||
return Result.<Collection<ServerPlayer>, String>error("provider '" + context.name() + "' is not registered");
|
||||
|
||||
var skinResult = result.get();
|
||||
if (skinResult.isError())
|
||||
throw new TransparentException(Throwables.getRootCause(skinResult.getErrorValue()));
|
||||
|
||||
var skinValue = SkinValue.fromProviderContextWithValue(context, skinResult.getSuccessValue().orElse(null));
|
||||
|
||||
var acceptedPlayers = SkinRestorer.applySkin(server, targets, skinValue, save);
|
||||
|
||||
return Result.<Collection<ServerPlayer>, String>success(acceptedPlayers);
|
||||
}, server)
|
||||
.exceptionally(e -> {
|
||||
SkinRestorer.LOGGER.error("Failed to set skin '{}:{}'", context.name(), context.argument(), e);
|
||||
return Result.error(e.getMessage());
|
||||
});
|
||||
}
|
||||
|
||||
public static class Events {
|
||||
private Events() {}
|
||||
|
||||
public static void onServerStarted(MinecraftServer server) {
|
||||
Path worldSkinDirectory = server.getWorldPath(LevelResource.ROOT).resolve(SkinRestorer.MOD_ID);
|
||||
FileUtils.tryMigrateOldSkinDirectory(SkinRestorer.getConfigDir(), worldSkinDirectory);
|
||||
|
||||
SkinRestorer.skinStorage = new SkinStorage(new SkinIO(worldSkinDirectory));
|
||||
SkinRestorer.tickedScheduler = new TickedScheduler(server);
|
||||
server.addTickable(SkinRestorer.tickedScheduler);
|
||||
|
||||
SkinRestorer.minecraftServer = server;
|
||||
}
|
||||
|
||||
public static void onServerStopped(MinecraftServer server) {
|
||||
SkinRestorer.skinStorage = null;
|
||||
SkinRestorer.tickedScheduler = null;
|
||||
SkinRestorer.minecraftServer = null;
|
||||
}
|
||||
|
||||
public static void onCommandRegister(CommandDispatcher<CommandSourceStack> dispatcher) {
|
||||
SkinCommand.register(dispatcher);
|
||||
}
|
||||
|
||||
public static void onPlayerDisconnect(ServerPlayer player) {
|
||||
SkinRestorer.getSkinStorage().removeSkin(player.getUUID());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,265 @@
|
||||
package net.lionarius.skinrestorer.command;
|
||||
|
||||
import com.mojang.authlib.GameProfile;
|
||||
import com.mojang.brigadier.CommandDispatcher;
|
||||
import com.mojang.brigadier.arguments.StringArgumentType;
|
||||
import com.mojang.brigadier.builder.ArgumentBuilder;
|
||||
import com.mojang.brigadier.builder.LiteralArgumentBuilder;
|
||||
import com.mojang.brigadier.builder.RequiredArgumentBuilder;
|
||||
import com.mojang.brigadier.context.CommandContext;
|
||||
import net.lionarius.skinrestorer.SkinRestorer;
|
||||
import net.lionarius.skinrestorer.skin.SkinValue;
|
||||
import net.lionarius.skinrestorer.skin.SkinVariant;
|
||||
import net.lionarius.skinrestorer.skin.provider.MojangSkinProvider;
|
||||
import net.lionarius.skinrestorer.skin.provider.SkinProvider;
|
||||
import net.lionarius.skinrestorer.skin.provider.SkinProviderContext;
|
||||
import net.lionarius.skinrestorer.translation.Translation;
|
||||
import net.lionarius.skinrestorer.util.PlayerUtils;
|
||||
import net.minecraft.commands.CommandSourceStack;
|
||||
import net.minecraft.commands.arguments.GameProfileArgument;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.function.BiFunction;
|
||||
import java.util.function.Function;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
import static net.minecraft.commands.Commands.argument;
|
||||
import static net.minecraft.commands.Commands.literal;
|
||||
|
||||
public final class SkinCommand {
|
||||
|
||||
private SkinCommand() {}
|
||||
|
||||
public static void register(CommandDispatcher<CommandSourceStack> dispatcher) {
|
||||
var base =
|
||||
literal("skin")
|
||||
.then(buildSetSubcommand("clear", SkinValue.EMPTY::toProviderContext))
|
||||
.then(literal("reset")
|
||||
.executes(context -> resetSubcommand(context.getSource()))
|
||||
.then(makeTargetsArgument(
|
||||
(context, profiles) -> resetSubcommand(context.getSource(), profiles, true)
|
||||
)))
|
||||
.then(literal("refresh").executes(context -> refreshSubcommand(context.getSource())));
|
||||
|
||||
var set = literal("set");
|
||||
|
||||
var providers = SkinRestorer.getProvidersRegistry().getPublicProviders();
|
||||
for (var entry : providers)
|
||||
set.then(buildSetSubcommand(entry.first(), entry.second()));
|
||||
if (!providers.isEmpty())
|
||||
base.then(set);
|
||||
|
||||
base.then(
|
||||
literal("config")
|
||||
.requires(commandSourceStack -> commandSourceStack.hasPermission(4))
|
||||
.then(literal("reload").executes(SkinCommand::configReloadSubcommand))
|
||||
);
|
||||
|
||||
dispatcher.register(base);
|
||||
}
|
||||
|
||||
private static int refreshSubcommand(
|
||||
CommandSourceStack src
|
||||
) {
|
||||
var player = src.getPlayer();
|
||||
if (player == null)
|
||||
return 0;
|
||||
|
||||
var profile = player.getGameProfile();
|
||||
|
||||
SkinProviderContext context = null;
|
||||
var save = true;
|
||||
if (!SkinRestorer.getSkinStorage().hasSavedSkin(profile.getId())) {
|
||||
if (profile.getProperties().containsKey(PlayerUtils.TEXTURES_KEY)) {
|
||||
save = false;
|
||||
context = MojangSkinProvider.skinProviderContextFromProfile(profile);
|
||||
}
|
||||
} else {
|
||||
context = SkinRestorer.getSkinStorage().getSkin(profile.getId()).toProviderContext();
|
||||
}
|
||||
|
||||
if (context == null)
|
||||
return 0;
|
||||
|
||||
return SkinCommand.setSubcommand(src, Collections.singleton(profile), context, save, false);
|
||||
}
|
||||
|
||||
private static int resetSubcommand(
|
||||
CommandSourceStack src,
|
||||
Collection<GameProfile> targets,
|
||||
boolean setByOperator
|
||||
) {
|
||||
var updatedPlayers = new HashSet<ServerPlayer>();
|
||||
for (var profile : targets) {
|
||||
SkinValue skin = null;
|
||||
if (SkinRestorer.getSkinStorage().hasSavedSkin(profile.getId()))
|
||||
skin = SkinRestorer.getSkinStorage().getSkin(profile.getId()).replaceValueWithOriginal();
|
||||
|
||||
if (skin == null)
|
||||
continue;
|
||||
|
||||
var updatedPlayer = SkinRestorer.applySkin(src.getServer(), Collections.singleton(profile), skin, false);
|
||||
SkinRestorer.getSkinStorage().deleteSkin(profile.getId());
|
||||
|
||||
updatedPlayers.addAll(updatedPlayer);
|
||||
}
|
||||
|
||||
SkinCommand.sendResponse(src, updatedPlayers, setByOperator);
|
||||
|
||||
return targets.size();
|
||||
}
|
||||
|
||||
private static int resetSubcommand(
|
||||
CommandSourceStack src
|
||||
) {
|
||||
if (src.getPlayer() == null)
|
||||
return 0;
|
||||
|
||||
return resetSubcommand(src, Collections.singleton(src.getPlayer().getGameProfile()), false);
|
||||
}
|
||||
|
||||
private static int setSubcommand(
|
||||
CommandSourceStack src,
|
||||
Collection<GameProfile> targets,
|
||||
SkinProviderContext context,
|
||||
boolean save,
|
||||
boolean setByOperator
|
||||
) {
|
||||
src.sendSystemMessage(Translation.translatableWithFallback(Translation.COMMAND_SKIN_LOADING_KEY));
|
||||
|
||||
SkinRestorer.setSkinAsync(src.getServer(), targets, context, save).thenAccept(result -> {
|
||||
if (result.isError()) {
|
||||
src.sendFailure(Translation.translatableWithFallback(
|
||||
Translation.COMMAND_SKIN_FAILED_KEY,
|
||||
result.getErrorValue()
|
||||
));
|
||||
return;
|
||||
}
|
||||
|
||||
var updatedPlayers = result.getSuccessValue();
|
||||
|
||||
SkinCommand.sendResponse(src, updatedPlayers, setByOperator);
|
||||
});
|
||||
|
||||
return targets.size();
|
||||
}
|
||||
|
||||
private static int setSubcommand(
|
||||
CommandSourceStack src,
|
||||
Collection<GameProfile> targets,
|
||||
SkinProviderContext context,
|
||||
boolean setByOperator
|
||||
) {
|
||||
return SkinCommand.setSubcommand(src, targets, context, true, setByOperator);
|
||||
}
|
||||
|
||||
private static int setSubcommand(
|
||||
CommandSourceStack src,
|
||||
SkinProviderContext context
|
||||
) {
|
||||
if (src.getPlayer() == null)
|
||||
return 0;
|
||||
|
||||
return setSubcommand(src, Collections.singleton(src.getPlayer().getGameProfile()), context, false);
|
||||
}
|
||||
|
||||
private static int configReloadSubcommand(CommandContext<CommandSourceStack> context) {
|
||||
SkinRestorer.reloadConfig();
|
||||
|
||||
context.getSource().sendSuccess(() -> Translation.translatableWithFallback(
|
||||
Translation.COMMAND_SKIN_CONFIG_RELOADED_KEY
|
||||
), true);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
private static void sendResponse(CommandSourceStack src, Collection<ServerPlayer> updatedPlayers, boolean setByOperator) {
|
||||
if (updatedPlayers.isEmpty()) {
|
||||
src.sendSuccess(() -> Translation.translatableWithFallback(
|
||||
Translation.COMMAND_SKIN_NO_CHANGES_KEY
|
||||
), true);
|
||||
return;
|
||||
}
|
||||
|
||||
if (setByOperator) {
|
||||
var playersComponent = PlayerUtils.createPlayerListComponent(updatedPlayers);
|
||||
|
||||
src.sendSuccess(() -> Translation.translatableWithFallback(
|
||||
Translation.COMMAND_SKIN_AFFECTED_PLAYERS_KEY,
|
||||
playersComponent
|
||||
), true);
|
||||
} else {
|
||||
src.sendSuccess(() -> Translation.translatableWithFallback(
|
||||
Translation.COMMAND_SKIN_OK_KEY
|
||||
), true);
|
||||
}
|
||||
}
|
||||
|
||||
private static LiteralArgumentBuilder<CommandSourceStack> buildSetSubcommand(String name, SkinProvider provider) {
|
||||
var action = literal(name);
|
||||
|
||||
if (provider.hasVariantSupport()) {
|
||||
for (SkinVariant variant : SkinVariant.values()) {
|
||||
action.then(
|
||||
literal(variant.toString())
|
||||
.then(buildSetSubcommandArgument(
|
||||
argument(provider.getArgumentName(), StringArgumentType.string()),
|
||||
context -> {
|
||||
var argument = StringArgumentType.getString(context, provider.getArgumentName());
|
||||
return new SkinProviderContext(name, argument, variant);
|
||||
}
|
||||
))
|
||||
);
|
||||
}
|
||||
} else {
|
||||
action.then(
|
||||
buildSetSubcommandArgument(
|
||||
argument(provider.getArgumentName(), StringArgumentType.string()),
|
||||
context -> {
|
||||
var argument = StringArgumentType.getString(context, provider.getArgumentName());
|
||||
return new SkinProviderContext(name, argument, null);
|
||||
}
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
return action;
|
||||
}
|
||||
|
||||
private static ArgumentBuilder<CommandSourceStack, LiteralArgumentBuilder<CommandSourceStack>> buildSetSubcommand(
|
||||
String name,
|
||||
Supplier<SkinProviderContext> supplier
|
||||
) {
|
||||
return buildSetSubcommandArgument(literal(name), context -> supplier.get());
|
||||
}
|
||||
|
||||
private static <T extends ArgumentBuilder<CommandSourceStack, T>> ArgumentBuilder<CommandSourceStack, T> buildSetSubcommandArgument(
|
||||
ArgumentBuilder<CommandSourceStack, T> argument,
|
||||
Function<CommandContext<CommandSourceStack>, SkinProviderContext> provider
|
||||
) {
|
||||
return argument
|
||||
.executes(context -> setSubcommand(
|
||||
context.getSource(),
|
||||
provider.apply(context)
|
||||
))
|
||||
.then(makeTargetsArgument(
|
||||
(context, targets) -> setSubcommand(
|
||||
context.getSource(),
|
||||
targets,
|
||||
provider.apply(context),
|
||||
true
|
||||
)
|
||||
));
|
||||
}
|
||||
|
||||
private static RequiredArgumentBuilder<CommandSourceStack, GameProfileArgument.Result> makeTargetsArgument(
|
||||
BiFunction<CommandContext<CommandSourceStack>, Collection<GameProfile>, Integer> consumer
|
||||
) {
|
||||
return argument("targets", GameProfileArgument.gameProfile())
|
||||
.requires(source -> source.hasPermission(2))
|
||||
.executes(context -> consumer.apply(context, GameProfileArgument.getGameProfiles(context, "targets")));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
package net.lionarius.skinrestorer.compat.skinshuffle;
|
||||
|
||||
import net.lionarius.skinrestorer.SkinRestorer;
|
||||
import net.lionarius.skinrestorer.platform.Services;
|
||||
import net.lionarius.skinrestorer.skin.SkinValue;
|
||||
import net.lionarius.skinrestorer.skin.provider.SkinShuffleSkinProvider;
|
||||
import net.lionarius.skinrestorer.util.PlayerUtils;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
|
||||
import java.util.Collections;
|
||||
|
||||
public class SkinShuffleCompatibility {
|
||||
|
||||
public static final String MOD_ID = "skinshuffle";
|
||||
|
||||
private static final boolean SHOULD_APPLY = !Services.PLATFORM.isModLoaded(SkinShuffleCompatibility.MOD_ID);
|
||||
|
||||
private SkinShuffleCompatibility() {}
|
||||
|
||||
public static boolean shouldApply() {
|
||||
return SkinShuffleCompatibility.SHOULD_APPLY;
|
||||
}
|
||||
|
||||
public static ResourceLocation resourceLocation(String name) {
|
||||
return new ResourceLocation(SkinShuffleCompatibility.MOD_ID, name);
|
||||
}
|
||||
|
||||
public static void onPlayerJoin(ServerPlayer player) {
|
||||
Services.COMPATIBILITY.skinShuffle_sendHandshake(player);
|
||||
}
|
||||
|
||||
public static void handleSkinRefresh(MinecraftServer server, ServerPlayer player, SkinShuffleSkinRefreshPayload payload) {
|
||||
var property = payload.textureProperty();
|
||||
|
||||
if (!property.name().equals(PlayerUtils.TEXTURES_KEY))
|
||||
return;
|
||||
|
||||
if (!property.hasSignature())
|
||||
return;
|
||||
|
||||
server.execute(() -> {
|
||||
SkinRestorer.applySkin(
|
||||
server,
|
||||
Collections.singleton(player.getGameProfile()),
|
||||
new SkinValue(SkinShuffleSkinProvider.PROVIDER_NAME, null, null, property),
|
||||
!server.usesAuthentication()
|
||||
);
|
||||
|
||||
if (server.usesAuthentication() && SkinRestorer.getSkinStorage().hasSavedSkin(player.getUUID()))
|
||||
SkinRestorer.getSkinStorage().deleteSkin(player.getUUID());
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
package net.lionarius.skinrestorer.compat.skinshuffle;
|
||||
|
||||
import net.minecraft.network.FriendlyByteBuf;
|
||||
import net.minecraft.network.protocol.common.custom.CustomPacketPayload;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public record SkinShuffleHandshakePayload() implements CustomPacketPayload {
|
||||
|
||||
public static final SkinShuffleHandshakePayload INSTANCE = new SkinShuffleHandshakePayload();
|
||||
|
||||
public static final ResourceLocation PACKET_ID = SkinShuffleCompatibility.resourceLocation("handshake");
|
||||
|
||||
@Override
|
||||
public void write(@NotNull FriendlyByteBuf buf) {
|
||||
// NO-OP
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull ResourceLocation id() {
|
||||
return PACKET_ID;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
package net.lionarius.skinrestorer.compat.skinshuffle;
|
||||
|
||||
import com.mojang.authlib.properties.Property;
|
||||
|
||||
public interface SkinShuffleSkinRefreshPayload {
|
||||
Property textureProperty();
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
package net.lionarius.skinrestorer.compat.skinshuffle;
|
||||
|
||||
import com.mojang.authlib.properties.Property;
|
||||
import net.minecraft.network.FriendlyByteBuf;
|
||||
import net.minecraft.network.protocol.common.custom.CustomPacketPayload;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public record SkinShuffleSkinRefreshV1Payload(
|
||||
Property textureProperty) implements CustomPacketPayload, SkinShuffleSkinRefreshPayload {
|
||||
|
||||
public static final ResourceLocation PACKET_ID = SkinShuffleCompatibility.resourceLocation("refresh");
|
||||
|
||||
public static void encode(FriendlyByteBuf buf, SkinShuffleSkinRefreshV1Payload value) {
|
||||
var textureProperty = value.textureProperty();
|
||||
|
||||
buf.writeUtf(textureProperty.name());
|
||||
buf.writeUtf(textureProperty.value());
|
||||
buf.writeNullable(textureProperty.signature(), FriendlyByteBuf::writeUtf);
|
||||
}
|
||||
|
||||
public static SkinShuffleSkinRefreshV1Payload decode(FriendlyByteBuf buf) {
|
||||
return new SkinShuffleSkinRefreshV1Payload(new Property(buf.readUtf(), buf.readUtf(), buf.readNullable(FriendlyByteBuf::readUtf)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(@NotNull FriendlyByteBuf buf) {
|
||||
encode(buf, this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull ResourceLocation id() {
|
||||
return PACKET_ID;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
package net.lionarius.skinrestorer.compat.skinshuffle;
|
||||
|
||||
import com.mojang.authlib.properties.Property;
|
||||
import net.minecraft.network.FriendlyByteBuf;
|
||||
import net.minecraft.network.protocol.common.custom.CustomPacketPayload;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public record SkinShuffleSkinRefreshV2Payload(
|
||||
Property textureProperty) implements CustomPacketPayload, SkinShuffleSkinRefreshPayload {
|
||||
|
||||
public static final ResourceLocation PACKET_ID = SkinShuffleCompatibility.resourceLocation("skin_refresh");
|
||||
|
||||
public static void encode(FriendlyByteBuf buf, SkinShuffleSkinRefreshV2Payload value) {
|
||||
var textureProperty = value.textureProperty();
|
||||
|
||||
buf.writeBoolean(textureProperty.hasSignature());
|
||||
buf.writeUtf(textureProperty.name());
|
||||
buf.writeUtf(textureProperty.value());
|
||||
if (textureProperty.hasSignature()) {
|
||||
assert textureProperty.signature() != null;
|
||||
|
||||
buf.writeUtf(textureProperty.signature());
|
||||
}
|
||||
}
|
||||
|
||||
public static SkinShuffleSkinRefreshV2Payload decode(FriendlyByteBuf buf) {
|
||||
if (buf.readBoolean()) {
|
||||
return new SkinShuffleSkinRefreshV2Payload(new Property(buf.readUtf(), buf.readUtf(), buf.readUtf()));
|
||||
}
|
||||
return new SkinShuffleSkinRefreshV2Payload(new Property(buf.readUtf(), buf.readUtf(), null));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(@NotNull FriendlyByteBuf buf) {
|
||||
encode(buf, this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull ResourceLocation id() {
|
||||
return PACKET_ID;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,131 @@
|
||||
package net.lionarius.skinrestorer.config;
|
||||
|
||||
import net.lionarius.skinrestorer.SkinRestorer;
|
||||
import net.lionarius.skinrestorer.config.provider.ProvidersConfig;
|
||||
import net.lionarius.skinrestorer.util.FileUtils;
|
||||
import net.lionarius.skinrestorer.util.JsonUtils;
|
||||
import net.lionarius.skinrestorer.util.gson.GsonPostProcessable;
|
||||
|
||||
import java.nio.file.Path;
|
||||
import java.util.Optional;
|
||||
|
||||
public final class Config implements GsonPostProcessable {
|
||||
|
||||
public static final String CONFIG_FILENAME = "config.json";
|
||||
|
||||
|
||||
private String language = "en_us";
|
||||
|
||||
private boolean refreshSkinOnJoin = true;
|
||||
|
||||
private int skinApplyDelayOnJoin = 0;
|
||||
|
||||
private boolean fetchSkinOnFirstJoin = true;
|
||||
|
||||
private boolean forceFirstJoinSkinFetch = false;
|
||||
|
||||
private FirstJoinSkinProvider firstJoinSkinProvider = FirstJoinSkinProvider.MOJANG;
|
||||
|
||||
private String proxy = "";
|
||||
private transient Proxy parsedProxy = null;
|
||||
|
||||
private long requestTimeout = 10;
|
||||
|
||||
private ProvidersConfig providers = ProvidersConfig.DEFAULT;
|
||||
|
||||
public String language() {
|
||||
return this.language;
|
||||
}
|
||||
|
||||
public boolean refreshSkinOnJoin() {
|
||||
return this.refreshSkinOnJoin;
|
||||
}
|
||||
|
||||
public int skinApplyDelayOnJoin() {
|
||||
return this.skinApplyDelayOnJoin;
|
||||
}
|
||||
|
||||
public boolean fetchSkinOnFirstJoin() {
|
||||
return this.fetchSkinOnFirstJoin;
|
||||
}
|
||||
|
||||
public boolean forceFirstJoinSkinFetch() {
|
||||
return this.forceFirstJoinSkinFetch;
|
||||
}
|
||||
|
||||
public FirstJoinSkinProvider firstJoinSkinProvider() {
|
||||
return this.firstJoinSkinProvider;
|
||||
}
|
||||
|
||||
public Optional<Proxy> proxy() {
|
||||
return Optional.ofNullable(this.parsedProxy);
|
||||
}
|
||||
|
||||
public long requestTimeout() {
|
||||
return this.requestTimeout;
|
||||
}
|
||||
|
||||
public ProvidersConfig providersConfig() {
|
||||
return this.providers;
|
||||
}
|
||||
|
||||
public static Config load(Path path) {
|
||||
var configFile = path.resolve(Config.CONFIG_FILENAME);
|
||||
|
||||
Config config = null;
|
||||
try {
|
||||
config = JsonUtils.fromJson(FileUtils.readFile(configFile), Config.class);
|
||||
} catch (Exception e) {
|
||||
SkinRestorer.LOGGER.warn("Could not load config", e);
|
||||
}
|
||||
|
||||
if (config == null)
|
||||
config = new Config();
|
||||
|
||||
FileUtils.writeFile(path.resolve(Config.CONFIG_FILENAME), JsonUtils.toJson(config));
|
||||
|
||||
return config;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void gsonPostProcess() {
|
||||
if (this.language == null || this.language.isEmpty()) {
|
||||
SkinRestorer.LOGGER.warn("Language config is null or empty, defaulting to 'en_us'");
|
||||
this.language = "en_us";
|
||||
}
|
||||
|
||||
if (this.skinApplyDelayOnJoin < 0) {
|
||||
SkinRestorer.LOGGER.warn("SkinApplyDelayOnJoin config is less than 0, defaulting to 0");
|
||||
this.skinApplyDelayOnJoin = 0;
|
||||
}
|
||||
|
||||
if (this.firstJoinSkinProvider == null) {
|
||||
SkinRestorer.LOGGER.warn("FirstJoinSkinProvider config is null, defaulting to MOJANG");
|
||||
this.firstJoinSkinProvider = FirstJoinSkinProvider.MOJANG;
|
||||
}
|
||||
|
||||
if (this.proxy == null) {
|
||||
SkinRestorer.LOGGER.warn("Proxy config is null, defaulting to an empty string");
|
||||
this.proxy = "";
|
||||
}
|
||||
|
||||
if (!this.proxy.isEmpty()) {
|
||||
try {
|
||||
this.parsedProxy = Proxy.parse(this.proxy);
|
||||
} catch (Exception e) {
|
||||
SkinRestorer.LOGGER.warn("Could not parse proxy config: {}", e.getMessage());
|
||||
this.parsedProxy = null;
|
||||
}
|
||||
}
|
||||
|
||||
if (this.requestTimeout <= 0) {
|
||||
SkinRestorer.LOGGER.warn("Request timeout config is less than or equal to 0, defaulting to 10");
|
||||
this.requestTimeout = 10;
|
||||
}
|
||||
|
||||
if (this.providers == null) {
|
||||
SkinRestorer.LOGGER.warn("Providers config is null, using default");
|
||||
this.providers = ProvidersConfig.DEFAULT;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
package net.lionarius.skinrestorer.config;
|
||||
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
import net.lionarius.skinrestorer.skin.provider.CollectionSkinProvider;
|
||||
import net.lionarius.skinrestorer.skin.provider.ElyBySkinProvider;
|
||||
import net.lionarius.skinrestorer.skin.provider.MojangSkinProvider;
|
||||
|
||||
public enum FirstJoinSkinProvider {
|
||||
@SerializedName(value = "MOJANG", alternate = {"mojang"})
|
||||
MOJANG(MojangSkinProvider.PROVIDER_NAME),
|
||||
@SerializedName(value = "ELY.BY", alternate = {"ely.by", "ELY_BY", "ely_by"})
|
||||
ELY_BY(ElyBySkinProvider.PROVIDER_NAME),
|
||||
@SerializedName(value = "COLLECTION", alternate = {"collection"})
|
||||
COLLECTION(CollectionSkinProvider.PROVIDER_NAME);
|
||||
|
||||
private final String name;
|
||||
|
||||
FirstJoinSkinProvider(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return this.name;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
package net.lionarius.skinrestorer.config;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public record Proxy(@NotNull String host, int port) {
|
||||
|
||||
public static Proxy parse(@NotNull String proxy) {
|
||||
var colonIndex = proxy.lastIndexOf(':');
|
||||
if (colonIndex == -1)
|
||||
throw new IllegalArgumentException("no port in hostname");
|
||||
|
||||
var port = Integer.parseInt(proxy.substring(colonIndex + 1));
|
||||
|
||||
if (port < 0 || port > 0xFFFF)
|
||||
throw new IllegalArgumentException("port out of range: " + port);
|
||||
|
||||
var host = proxy.substring(0, colonIndex);
|
||||
|
||||
return new Proxy(host, port);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
package net.lionarius.skinrestorer.config.provider;
|
||||
|
||||
import net.lionarius.skinrestorer.SkinRestorer;
|
||||
import net.lionarius.skinrestorer.util.gson.GsonPostProcessable;
|
||||
|
||||
public abstract class BuiltInProviderConfig implements GsonPostProcessable {
|
||||
protected boolean enabled;
|
||||
protected String name;
|
||||
protected CacheConfig cache;
|
||||
|
||||
|
||||
public BuiltInProviderConfig(String name, CacheConfig cache) {
|
||||
this(name, cache, true);
|
||||
}
|
||||
|
||||
public BuiltInProviderConfig(String name, CacheConfig cache, boolean enabled) {
|
||||
this.enabled = enabled;
|
||||
this.name = name;
|
||||
this.cache = cache;
|
||||
}
|
||||
|
||||
public boolean enabled() {
|
||||
return enabled;
|
||||
}
|
||||
|
||||
public String name() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public CacheConfig cache() {
|
||||
return cache;
|
||||
}
|
||||
|
||||
protected void validate(String defaultName, CacheConfig defaultCache) {
|
||||
if (this.name == null || this.name.isEmpty()) {
|
||||
SkinRestorer.LOGGER.warn("Provider name is null or empty, defaulting to '{}'", defaultName);
|
||||
this.name = defaultName;
|
||||
}
|
||||
|
||||
if (this.cache == null) {
|
||||
SkinRestorer.LOGGER.warn("Provider cache is null, using default");
|
||||
this.cache = defaultCache;
|
||||
} else {
|
||||
this.cache.validate(defaultCache);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
package net.lionarius.skinrestorer.config.provider;
|
||||
|
||||
import net.lionarius.skinrestorer.SkinRestorer;
|
||||
|
||||
public final class CacheConfig {
|
||||
private boolean enabled;
|
||||
private long duration;
|
||||
|
||||
public CacheConfig(boolean enabled, long duration) {
|
||||
this.enabled = enabled;
|
||||
this.duration = duration;
|
||||
}
|
||||
|
||||
public boolean enabled() {
|
||||
return enabled;
|
||||
}
|
||||
|
||||
public long duration() {
|
||||
return duration;
|
||||
}
|
||||
|
||||
void validate(CacheConfig defaultValue) {
|
||||
if (this.duration <= 0) {
|
||||
SkinRestorer.LOGGER.warn("Cache duration is less than or equal to zero, defaulting to {}", defaultValue.duration());
|
||||
this.duration = defaultValue.duration();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package net.lionarius.skinrestorer.config.provider;
|
||||
|
||||
import net.lionarius.skinrestorer.skin.provider.ElyBySkinProvider;
|
||||
|
||||
public final class ElyByProviderConfig extends BuiltInProviderConfig {
|
||||
private static final CacheConfig DEFAULT_CACHE_VALUE = new CacheConfig(true, 60);
|
||||
|
||||
public ElyByProviderConfig() {
|
||||
super(ElyBySkinProvider.PROVIDER_NAME, DEFAULT_CACHE_VALUE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void gsonPostProcess() {
|
||||
super.validate(ElyBySkinProvider.PROVIDER_NAME, DEFAULT_CACHE_VALUE);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
package net.lionarius.skinrestorer.config.provider;
|
||||
|
||||
import net.lionarius.skinrestorer.SkinRestorer;
|
||||
import net.lionarius.skinrestorer.skin.provider.MineskinSkinProvider;
|
||||
|
||||
public final class MineskinProviderConfig extends BuiltInProviderConfig {
|
||||
private static final CacheConfig DEFAULT_CACHE_VALUE = new CacheConfig(true, 300);
|
||||
|
||||
private String apiKey;
|
||||
|
||||
public MineskinProviderConfig() {
|
||||
super(MineskinSkinProvider.PROVIDER_NAME, DEFAULT_CACHE_VALUE);
|
||||
|
||||
this.apiKey = "";
|
||||
}
|
||||
|
||||
public String apiKey() {
|
||||
return apiKey;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void gsonPostProcess() {
|
||||
super.validate(MineskinSkinProvider.PROVIDER_NAME, DEFAULT_CACHE_VALUE);
|
||||
|
||||
if (this.apiKey == null) {
|
||||
SkinRestorer.LOGGER.warn("Mineskin API key is null, defaulting to an empty string");
|
||||
this.apiKey = "";
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package net.lionarius.skinrestorer.config.provider;
|
||||
|
||||
import net.lionarius.skinrestorer.skin.provider.MojangSkinProvider;
|
||||
|
||||
public final class MojangProviderConfig extends BuiltInProviderConfig {
|
||||
private static final CacheConfig DEFAULT_CACHE_VALUE = new CacheConfig(true, 60);
|
||||
|
||||
public MojangProviderConfig() {
|
||||
super(MojangSkinProvider.PROVIDER_NAME, DEFAULT_CACHE_VALUE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void gsonPostProcess() {
|
||||
super.validate(MojangSkinProvider.PROVIDER_NAME, DEFAULT_CACHE_VALUE);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
package net.lionarius.skinrestorer.config.provider;
|
||||
|
||||
import net.lionarius.skinrestorer.SkinRestorer;
|
||||
import net.lionarius.skinrestorer.config.provider.collection.CollectionProviderConfig;
|
||||
import net.lionarius.skinrestorer.util.gson.GsonPostProcessable;
|
||||
|
||||
public final class ProvidersConfig implements GsonPostProcessable {
|
||||
public static final ProvidersConfig DEFAULT = new ProvidersConfig(
|
||||
new MojangProviderConfig(),
|
||||
new ElyByProviderConfig(),
|
||||
new MineskinProviderConfig(),
|
||||
new CollectionProviderConfig()
|
||||
);
|
||||
|
||||
private MojangProviderConfig mojang;
|
||||
private ElyByProviderConfig ely_by;
|
||||
private MineskinProviderConfig mineskin;
|
||||
private CollectionProviderConfig collection;
|
||||
|
||||
public ProvidersConfig(MojangProviderConfig mojang, ElyByProviderConfig ely_by, MineskinProviderConfig mineskin, CollectionProviderConfig collection) {
|
||||
this.mojang = mojang;
|
||||
this.ely_by = ely_by;
|
||||
this.mineskin = mineskin;
|
||||
this.collection = collection;
|
||||
}
|
||||
|
||||
public MojangProviderConfig mojang() {
|
||||
return this.mojang;
|
||||
}
|
||||
|
||||
public ElyByProviderConfig ely_by() {
|
||||
return this.ely_by;
|
||||
}
|
||||
|
||||
public MineskinProviderConfig mineskin() {
|
||||
return this.mineskin;
|
||||
}
|
||||
|
||||
public CollectionProviderConfig collection() {
|
||||
return this.collection;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void gsonPostProcess() {
|
||||
if (this.mojang == null) {
|
||||
SkinRestorer.LOGGER.warn("Mojang provider config is null, using default");
|
||||
this.mojang = ProvidersConfig.DEFAULT.mojang();
|
||||
}
|
||||
|
||||
if (this.ely_by == null) {
|
||||
SkinRestorer.LOGGER.warn("Ely.By provider config is null, using default");
|
||||
this.ely_by = ProvidersConfig.DEFAULT.ely_by();
|
||||
}
|
||||
|
||||
if (this.mineskin == null) {
|
||||
SkinRestorer.LOGGER.warn("Mineskin provider config is null, using default");
|
||||
this.mineskin = ProvidersConfig.DEFAULT.mineskin();
|
||||
}
|
||||
|
||||
if (this.collection == null) {
|
||||
SkinRestorer.LOGGER.warn("Collection provider config is null, using default");
|
||||
this.collection = ProvidersConfig.DEFAULT.collection();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
package net.lionarius.skinrestorer.config.provider.collection;
|
||||
|
||||
import com.google.gson.annotations.JsonAdapter;
|
||||
import net.lionarius.skinrestorer.config.provider.BuiltInProviderConfig;
|
||||
import net.lionarius.skinrestorer.config.provider.CacheConfig;
|
||||
import net.lionarius.skinrestorer.skin.provider.CollectionSkinProvider;
|
||||
import net.lionarius.skinrestorer.util.gson.GsonPostProcessable;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public final class CollectionProviderConfig extends BuiltInProviderConfig implements GsonPostProcessable {
|
||||
private static final CacheConfig DEFAULT_CACHE_VALUE = new CacheConfig(true, 604800);
|
||||
|
||||
@JsonAdapter(CollectionSkinSourceListDeserializer.class)
|
||||
private List<CollectionSkinSource> sources = new ArrayList<>();
|
||||
|
||||
public CollectionProviderConfig() {
|
||||
super(CollectionSkinProvider.PROVIDER_NAME, DEFAULT_CACHE_VALUE, false);
|
||||
}
|
||||
|
||||
public List<CollectionSkinSource> sources() {
|
||||
return this.sources;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void gsonPostProcess() {
|
||||
if (this.sources == null) {
|
||||
this.sources = new ArrayList<>();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
package net.lionarius.skinrestorer.config.provider.collection;
|
||||
|
||||
import net.lionarius.skinrestorer.SkinRestorer;
|
||||
import net.lionarius.skinrestorer.skin.SkinVariant;
|
||||
import net.lionarius.skinrestorer.util.gson.GsonPostProcessable;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.net.URI;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
|
||||
public final class CollectionSkinFile implements CollectionSkinSource, GsonPostProcessable {
|
||||
private String path = "";
|
||||
private SkinVariant variant = SkinVariant.CLASSIC;
|
||||
|
||||
@Override
|
||||
public @Nullable URI uri() {
|
||||
if (this.path.isEmpty())
|
||||
return null;
|
||||
|
||||
try {
|
||||
var filePath = SkinRestorer.getConfigDir().resolve(this.path);
|
||||
|
||||
if (!Files.exists(filePath)) {
|
||||
SkinRestorer.LOGGER.warn("Skin file does not exist: {}", this.path);
|
||||
return null;
|
||||
}
|
||||
|
||||
if (!Files.isRegularFile(filePath)) {
|
||||
SkinRestorer.LOGGER.warn("Skin path is not a file: {}", this.path);
|
||||
return null;
|
||||
}
|
||||
|
||||
if (!this.path.toLowerCase().endsWith(".png")) {
|
||||
SkinRestorer.LOGGER.warn("Skin file is not a PNG file: {}", this.path);
|
||||
return null;
|
||||
}
|
||||
|
||||
return filePath.toUri();
|
||||
} catch (Exception e) {
|
||||
SkinRestorer.LOGGER.warn("Invalid file path: {}", this.path, e);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public SkinVariant variant() {
|
||||
return this.variant;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void gsonPostProcess() {
|
||||
if (this.path == null) {
|
||||
this.path = "";
|
||||
}
|
||||
if (this.variant == null) {
|
||||
this.variant = SkinVariant.CLASSIC;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
package net.lionarius.skinrestorer.config.provider.collection;
|
||||
|
||||
import net.lionarius.skinrestorer.skin.SkinVariant;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.net.URI;
|
||||
|
||||
public interface CollectionSkinSource {
|
||||
@Nullable URI uri();
|
||||
|
||||
SkinVariant variant();
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
package net.lionarius.skinrestorer.config.provider.collection;
|
||||
|
||||
import com.google.gson.*;
|
||||
|
||||
import java.lang.reflect.Type;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class CollectionSkinSourceListDeserializer implements JsonSerializer<List<CollectionSkinSource>>, JsonDeserializer<List<CollectionSkinSource>> {
|
||||
@Override
|
||||
public JsonElement serialize(List<CollectionSkinSource> src, Type typeOfT, JsonSerializationContext context) {
|
||||
return context.serialize(src, List.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<CollectionSkinSource> deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context)
|
||||
throws JsonParseException {
|
||||
List<CollectionSkinSource> sources = new ArrayList<>();
|
||||
|
||||
if (json.isJsonArray()) {
|
||||
for (JsonElement element : json.getAsJsonArray()) {
|
||||
if (element.isJsonObject()) {
|
||||
JsonObject obj = element.getAsJsonObject();
|
||||
if (obj.has("url")) {
|
||||
sources.add(context.deserialize(obj, CollectionSkinUrl.class));
|
||||
} else if (obj.has("path")) {
|
||||
sources.add(context.deserialize(obj, CollectionSkinFile.class));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return sources;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
package net.lionarius.skinrestorer.config.provider.collection;
|
||||
|
||||
import net.lionarius.skinrestorer.SkinRestorer;
|
||||
import net.lionarius.skinrestorer.skin.SkinVariant;
|
||||
import net.lionarius.skinrestorer.util.gson.GsonPostProcessable;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.net.URI;
|
||||
|
||||
public final class CollectionSkinUrl implements CollectionSkinSource, GsonPostProcessable {
|
||||
private String url = "";
|
||||
private SkinVariant variant = SkinVariant.CLASSIC;
|
||||
|
||||
@Override
|
||||
public @Nullable URI uri() {
|
||||
try {
|
||||
if (this.url.isEmpty())
|
||||
return null;
|
||||
|
||||
return new URI(this.url);
|
||||
} catch (Exception e) {
|
||||
SkinRestorer.LOGGER.warn("Invalid URI: {}", this.url, e);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public SkinVariant variant() {
|
||||
return this.variant;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void gsonPostProcess() {
|
||||
if (this.url == null) {
|
||||
this.url = "";
|
||||
}
|
||||
if (this.variant == null) {
|
||||
this.variant = SkinVariant.CLASSIC;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
package net.lionarius.skinrestorer.exception;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class TransparentException extends RuntimeException {
|
||||
public TransparentException(@NotNull Throwable cause) {
|
||||
super(cause);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMessage() {
|
||||
return this.getCause().getMessage();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return this.getLocalizedMessage();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,190 @@
|
||||
package net.lionarius.skinrestorer.mineskin;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.google.gson.JsonParseException;
|
||||
import org.mineskin.MineSkinClientImpl;
|
||||
import org.mineskin.data.CodeAndMessage;
|
||||
import org.mineskin.exception.MineSkinRequestException;
|
||||
import org.mineskin.exception.MineskinException;
|
||||
import org.mineskin.request.RequestHandler;
|
||||
import org.mineskin.response.MineSkinResponse;
|
||||
import org.mineskin.response.ResponseConstructor;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.net.InetSocketAddress;
|
||||
import java.net.ProxySelector;
|
||||
import java.net.URI;
|
||||
import java.net.http.HttpClient;
|
||||
import java.net.http.HttpRequest;
|
||||
import java.net.http.HttpRequest.BodyPublishers;
|
||||
import java.net.http.HttpResponse;
|
||||
import java.net.http.HttpResponse.BodyHandlers;
|
||||
import java.util.Map;
|
||||
import java.util.logging.Level;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
// copy-pasted from https://github.com/InventivetalentDev/MineskinClient/blob/master/java11/src/main/java/org/mineskin/Java11RequestHandler.java
|
||||
// with some modifications to support proxy
|
||||
public class Java11RequestHandler extends RequestHandler {
|
||||
|
||||
private final Gson gson;
|
||||
private final HttpClient httpClient;
|
||||
|
||||
public Java11RequestHandler(String baseUrl, String userAgent, String apiKey, int timeout, Gson gson, InetSocketAddress proxy) {
|
||||
super(baseUrl, userAgent, apiKey, timeout, gson);
|
||||
this.gson = gson;
|
||||
|
||||
HttpClient.Builder clientBuilder = HttpClient.newBuilder()
|
||||
.connectTimeout(java.time.Duration.ofMillis(timeout));
|
||||
|
||||
if (userAgent != null) {
|
||||
clientBuilder.followRedirects(HttpClient.Redirect.NORMAL);
|
||||
}
|
||||
|
||||
if (proxy != null) {
|
||||
clientBuilder.proxy(ProxySelector.of(proxy));
|
||||
}
|
||||
|
||||
this.httpClient = clientBuilder.build();
|
||||
}
|
||||
|
||||
private <T, R extends MineSkinResponse<T>> R wrapResponse(HttpResponse<String> response, Class<T> clazz, ResponseConstructor<T, R> constructor)
|
||||
throws IOException {
|
||||
String rawBody = response.body();
|
||||
try {
|
||||
JsonObject jsonBody = gson.fromJson(rawBody, JsonObject.class);
|
||||
R wrapped = constructor.construct(
|
||||
response.statusCode(),
|
||||
lowercaseHeaders(response.headers().map()),
|
||||
jsonBody,
|
||||
gson, clazz
|
||||
);
|
||||
if (!wrapped.isSuccess()) {
|
||||
throw new MineSkinRequestException(
|
||||
wrapped.getFirstError().map(CodeAndMessage::code).orElse("request_failed"),
|
||||
wrapped.getFirstError().map(CodeAndMessage::message).orElse("Request Failed"),
|
||||
wrapped
|
||||
);
|
||||
}
|
||||
return wrapped;
|
||||
} catch (JsonParseException e) {
|
||||
MineSkinClientImpl.LOGGER.log(Level.WARNING, "Failed to parse response body: " + rawBody, e);
|
||||
throw new MineskinException("Failed to parse response", e);
|
||||
}
|
||||
}
|
||||
|
||||
private Map<String, String> lowercaseHeaders(Map<String, java.util.List<String>> headers) {
|
||||
return headers.entrySet().stream()
|
||||
.collect(Collectors.toMap(
|
||||
entry -> entry.getKey().toLowerCase(),
|
||||
entry -> String.join(", ", entry.getValue())
|
||||
));
|
||||
}
|
||||
|
||||
public <T, R extends MineSkinResponse<T>> R getJson(String url, Class<T> clazz, ResponseConstructor<T, R> constructor)
|
||||
throws IOException {
|
||||
url = this.baseUrl + url;
|
||||
MineSkinClientImpl.LOGGER.fine("GET " + url);
|
||||
|
||||
HttpRequest.Builder requestBuilder = HttpRequest.newBuilder()
|
||||
.uri(URI.create(url))
|
||||
.GET()
|
||||
.header("User-Agent", this.userAgent);
|
||||
HttpRequest request;
|
||||
if (apiKey != null) {
|
||||
request = requestBuilder
|
||||
.header("Authorization", "Bearer " + apiKey)
|
||||
.header("Accept", "application/json").build();
|
||||
} else {
|
||||
request = requestBuilder.build();
|
||||
}
|
||||
HttpResponse<String> response;
|
||||
try {
|
||||
response = this.httpClient.send(request, BodyHandlers.ofString());
|
||||
} catch (InterruptedException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
return wrapResponse(response, clazz, constructor);
|
||||
}
|
||||
|
||||
public <T, R extends MineSkinResponse<T>> R postJson(String url, JsonObject data, Class<T> clazz, ResponseConstructor<T, R> constructor)
|
||||
throws IOException {
|
||||
url = this.baseUrl + url;
|
||||
MineSkinClientImpl.LOGGER.fine("POST " + url);
|
||||
|
||||
HttpRequest.Builder requestBuilder = HttpRequest.newBuilder()
|
||||
.uri(URI.create(url))
|
||||
.POST(BodyPublishers.ofString(gson.toJson(data)))
|
||||
.header("Content-Type", "application/json")
|
||||
.header("User-Agent", this.userAgent);
|
||||
HttpRequest request;
|
||||
if (apiKey != null) {
|
||||
request = requestBuilder
|
||||
.header("Authorization", "Bearer " + apiKey)
|
||||
.header("Accept", "application/json").build();
|
||||
} else {
|
||||
request = requestBuilder.build();
|
||||
}
|
||||
|
||||
HttpResponse<String> response;
|
||||
try {
|
||||
response = this.httpClient.send(request, BodyHandlers.ofString());
|
||||
} catch (InterruptedException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
return wrapResponse(response, clazz, constructor);
|
||||
}
|
||||
|
||||
public <T, R extends MineSkinResponse<T>> R postFormDataFile(String url, String key, String filename, InputStream in, Map<String, String> data, Class<T> clazz, ResponseConstructor<T, R> constructor)
|
||||
throws IOException {
|
||||
url = this.baseUrl + url;
|
||||
MineSkinClientImpl.LOGGER.fine("POST " + url);
|
||||
|
||||
String boundary = "mineskin-" + System.currentTimeMillis();
|
||||
StringBuilder bodyBuilder = new StringBuilder();
|
||||
|
||||
// add form fields
|
||||
for (Map.Entry<String, String> entry : data.entrySet()) {
|
||||
bodyBuilder.append("--").append(boundary).append("\r\n")
|
||||
.append("Content-Disposition: form-data; name=\"").append(entry.getKey()).append("\"\r\n\r\n")
|
||||
.append(entry.getValue()).append("\r\n");
|
||||
}
|
||||
|
||||
// add file
|
||||
byte[] fileContent = in.readAllBytes();
|
||||
bodyBuilder.append("--").append(boundary).append("\r\n")
|
||||
.append("Content-Disposition: form-data; name=\"").append(key)
|
||||
.append("\"; filename=\"").append(filename).append("\"\r\n")
|
||||
.append("Content-Type: image/png\r\n\r\n");
|
||||
byte[] bodyStart = bodyBuilder.toString().getBytes();
|
||||
byte[] boundaryEnd = ("\r\n--" + boundary + "--\r\n").getBytes();
|
||||
byte[] bodyString = new byte[bodyStart.length + fileContent.length + boundaryEnd.length];
|
||||
System.arraycopy(bodyStart, 0, bodyString, 0, bodyStart.length);
|
||||
System.arraycopy(fileContent, 0, bodyString, bodyStart.length, fileContent.length);
|
||||
System.arraycopy(boundaryEnd, 0, bodyString, bodyStart.length + fileContent.length, boundaryEnd.length);
|
||||
|
||||
HttpRequest.Builder requestBuilder = HttpRequest.newBuilder()
|
||||
.uri(URI.create(url))
|
||||
.POST(HttpRequest.BodyPublishers.ofByteArray(bodyString))
|
||||
.header("Content-Type", "multipart/form-data; boundary=" + boundary)
|
||||
.header("User-Agent", this.userAgent);
|
||||
HttpRequest request;
|
||||
if (apiKey != null) {
|
||||
request = requestBuilder
|
||||
.header("Authorization", "Bearer " + apiKey)
|
||||
.header("Accept", "application/json").build();
|
||||
} else {
|
||||
request = requestBuilder.build();
|
||||
}
|
||||
|
||||
HttpResponse<String> response;
|
||||
try {
|
||||
response = this.httpClient.send(request, BodyHandlers.ofString());
|
||||
} catch (InterruptedException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
return wrapResponse(response, clazz, constructor);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package net.lionarius.skinrestorer.mixin;
|
||||
|
||||
import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
|
||||
import net.minecraft.server.level.ChunkMap;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.gen.Accessor;
|
||||
|
||||
@Mixin(ChunkMap.class)
|
||||
public interface ChunkMapAccessor {
|
||||
|
||||
@Accessor
|
||||
Int2ObjectMap<TrackedEntityAccessorInvoker> getEntityMap();
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package net.lionarius.skinrestorer.mixin;
|
||||
|
||||
import net.minecraft.server.players.GameProfileCache;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.gen.Accessor;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
@Mixin(GameProfileCache.class)
|
||||
public interface GameProfileCacheAccessor {
|
||||
|
||||
@Accessor
|
||||
Map<String, GameProfileCache.GameProfileInfo> getProfilesByName();
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
package net.lionarius.skinrestorer.mixin;
|
||||
|
||||
import net.lionarius.skinrestorer.SkinRestorer;
|
||||
import net.minecraft.network.Connection;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.server.network.CommonListenerCookie;
|
||||
import net.minecraft.server.players.PlayerList;
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
import org.spongepowered.asm.mixin.Unique;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
@Mixin(PlayerList.class)
|
||||
public abstract class PlayerListMixin {
|
||||
|
||||
@Shadow
|
||||
public abstract List<ServerPlayer> getPlayers();
|
||||
|
||||
@Shadow @Final
|
||||
private MinecraftServer server;
|
||||
|
||||
@Inject(method = "remove", at = @At("TAIL"))
|
||||
private void remove(ServerPlayer player, CallbackInfo ci) {
|
||||
SkinRestorer.Events.onPlayerDisconnect(player);
|
||||
}
|
||||
|
||||
@Inject(method = "removeAll", at = @At("HEAD"))
|
||||
private void removeAll(CallbackInfo ci) {
|
||||
for (var player : getPlayers()) {
|
||||
SkinRestorer.Events.onPlayerDisconnect(player);
|
||||
}
|
||||
}
|
||||
|
||||
@Inject(method = "placeNewPlayer", at = @At("HEAD"))
|
||||
private void placeNewPlayer(Connection connection, ServerPlayer player, CommonListenerCookie cookie, CallbackInfo ci) {
|
||||
var delay = SkinRestorer.getConfig().skinApplyDelayOnJoin();
|
||||
|
||||
if (delay <= 0) {
|
||||
skinrestorer$tryApplySkin(server, player);
|
||||
} else {
|
||||
var uuid = player.getUUID();
|
||||
SkinRestorer.getTickedScheduler().schedule(() -> {
|
||||
var actualPlayer = server.getPlayerList().getPlayer(uuid);
|
||||
if (actualPlayer != null)
|
||||
skinrestorer$tryApplySkin(server, actualPlayer);
|
||||
}, delay, uuid);
|
||||
}
|
||||
}
|
||||
|
||||
@Unique
|
||||
private static void skinrestorer$tryApplySkin(MinecraftServer server, ServerPlayer player) {
|
||||
if (SkinRestorer.getSkinStorage().hasSavedSkin(player.getUUID()))
|
||||
SkinRestorer.applySkin(server, Collections.singleton(player.getGameProfile()), SkinRestorer.getSkinStorage().getSkin(player.getUUID()));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,95 @@
|
||||
package net.lionarius.skinrestorer.mixin;
|
||||
|
||||
import com.mojang.authlib.GameProfile;
|
||||
import net.lionarius.skinrestorer.SkinRestorer;
|
||||
import net.lionarius.skinrestorer.config.FirstJoinSkinProvider;
|
||||
import net.lionarius.skinrestorer.skin.SkinValue;
|
||||
import net.lionarius.skinrestorer.skin.provider.SkinProviderContext;
|
||||
import net.lionarius.skinrestorer.util.PlayerUtils;
|
||||
import net.lionarius.skinrestorer.util.Result;
|
||||
import net.minecraft.server.network.ServerLoginPacketListenerImpl;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
import org.spongepowered.asm.mixin.Unique;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
@Mixin(ServerLoginPacketListenerImpl.class)
|
||||
public abstract class ServerLoginPacketListenerImplMixin {
|
||||
|
||||
@Shadow @Nullable
|
||||
private GameProfile authenticatedProfile;
|
||||
|
||||
@Unique
|
||||
private CompletableFuture<Void> skinrestorer$pendingSkin;
|
||||
|
||||
@Inject(method = "verifyLoginAndFinishConnectionSetup", at = @At(value = "INVOKE",
|
||||
target = "Lnet/minecraft/server/players/PlayerList;canPlayerLogin(Ljava/net/SocketAddress;Lcom/mojang/authlib/GameProfile;)Lnet/minecraft/network/chat/Component;"),
|
||||
cancellable = true)
|
||||
public void waitForSkin(CallbackInfo ci) {
|
||||
if (skinrestorer$pendingSkin == null) {
|
||||
skinrestorer$pendingSkin = CompletableFuture.supplyAsync(() -> {
|
||||
final var profile = authenticatedProfile;
|
||||
|
||||
assert profile != null;
|
||||
var originalSkin = PlayerUtils.getPlayerSkin(profile);
|
||||
|
||||
if (SkinRestorer.getSkinStorage().hasSavedSkin(profile.getId())) {
|
||||
if (originalSkin != null) { // update to the latest official skin
|
||||
var value = SkinRestorer.getSkinStorage().getSkin(profile.getId());
|
||||
SkinRestorer.getSkinStorage().setSkin(profile.getId(), value.setOriginalValue(originalSkin));
|
||||
}
|
||||
|
||||
if (SkinRestorer.getConfig().refreshSkinOnJoin()) {
|
||||
var currentSkin = SkinRestorer.getSkinStorage().getSkin(profile.getId());
|
||||
var context = currentSkin.toProviderContext();
|
||||
|
||||
skinrestorer$fetchSkin(profile, context);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
var config = SkinRestorer.getConfig();
|
||||
var provider = config.firstJoinSkinProvider();
|
||||
|
||||
var shouldFetch = (originalSkin == null && config.fetchSkinOnFirstJoin()) ||
|
||||
(originalSkin != null && config.forceFirstJoinSkinFetch() && provider != FirstJoinSkinProvider.MOJANG);
|
||||
|
||||
if (shouldFetch) {
|
||||
var context = new SkinProviderContext(
|
||||
provider.getName(),
|
||||
profile.getName(),
|
||||
null
|
||||
);
|
||||
skinrestorer$fetchSkin(profile, context);
|
||||
}
|
||||
|
||||
return null;
|
||||
});
|
||||
}
|
||||
|
||||
if (!skinrestorer$pendingSkin.isDone())
|
||||
ci.cancel();
|
||||
}
|
||||
|
||||
@Unique
|
||||
private static void skinrestorer$fetchSkin(GameProfile profile, SkinProviderContext context) {
|
||||
SkinRestorer.LOGGER.debug("Fetching {}'s skin", profile.getName());
|
||||
|
||||
var result = SkinRestorer.getProvider(context.name()).map(
|
||||
provider -> provider.fetchSkin(context.argument(), context.variant())
|
||||
).orElseGet(() -> Result.error(new IllegalArgumentException("Skin provider is not registered: " + context.name())));
|
||||
|
||||
if (!result.isError()) {
|
||||
var value = SkinValue.fromProviderContextWithValue(context, result.getSuccessValue().orElse(null));
|
||||
SkinRestorer.getSkinStorage().setSkin(profile.getId(), value);
|
||||
} else {
|
||||
SkinRestorer.LOGGER.warn("Failed to fetch skin '{}:{}'", context.name(), context.argument(), result.getErrorValue());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
package net.lionarius.skinrestorer.mixin;
|
||||
|
||||
import com.mojang.authlib.GameProfile;
|
||||
import net.lionarius.skinrestorer.SkinRestorer;
|
||||
import net.lionarius.skinrestorer.util.PlayerUtils;
|
||||
import net.minecraft.Util;
|
||||
import net.minecraft.server.Services;
|
||||
import net.minecraft.world.level.block.entity.SkullBlockEntity;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Unique;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
|
||||
import java.util.Locale;
|
||||
import java.util.Optional;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.function.BooleanSupplier;
|
||||
|
||||
@Mixin(SkullBlockEntity.class)
|
||||
public abstract class SkullBlockEntityMixin {
|
||||
|
||||
@Inject(method = "loadProfile", at = @At("HEAD"),
|
||||
cancellable = true)
|
||||
private static void fetchProfileByName(String name, Services services, BooleanSupplier hasCache, CallbackInfoReturnable<CompletableFuture<Optional<GameProfile>>> cir) {
|
||||
if (name == null)
|
||||
return;
|
||||
|
||||
var profileOpt = Optional.<GameProfile>empty();
|
||||
var gameProfileInfo = ((GameProfileCacheAccessor) services.profileCache()).getProfilesByName().get(name.toLowerCase(Locale.ROOT));
|
||||
|
||||
if (gameProfileInfo != null)
|
||||
profileOpt = Optional.of(gameProfileInfo.getProfile());
|
||||
|
||||
skinrestorer$replaceSkin(profileOpt, cir);
|
||||
}
|
||||
|
||||
@Unique
|
||||
private static void skinrestorer$replaceSkin(Optional<GameProfile> profileOpt, CallbackInfoReturnable<CompletableFuture<Optional<GameProfile>>> cir) {
|
||||
if (SkinRestorer.getMinecraftServer() == null)
|
||||
return;
|
||||
|
||||
if (profileOpt.isEmpty())
|
||||
return;
|
||||
|
||||
var profile = PlayerUtils.cloneGameProfile(profileOpt.get());
|
||||
|
||||
if (SkinRestorer.getSkinStorage().hasSavedSkin(profile.getId())) {
|
||||
cir.setReturnValue(CompletableFuture.supplyAsync(() -> {
|
||||
var skin = SkinRestorer.getSkinStorage().getSkin(profile.getId(), false);
|
||||
PlayerUtils.applyRestoredSkin(profile, skin.value());
|
||||
|
||||
return Optional.of(profile);
|
||||
}, Util.backgroundExecutor()));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
package net.lionarius.skinrestorer.mixin;
|
||||
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.server.network.ServerPlayerConnection;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.gen.Accessor;
|
||||
import org.spongepowered.asm.mixin.gen.Invoker;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
@Mixin(targets = "net.minecraft.server.level.ChunkMap$TrackedEntity")
|
||||
public interface TrackedEntityAccessorInvoker {
|
||||
|
||||
@Accessor
|
||||
Set<ServerPlayerConnection> getSeenBy();
|
||||
|
||||
@Invoker
|
||||
void invokeRemovePlayer(ServerPlayer player);
|
||||
|
||||
@Invoker
|
||||
void invokeUpdatePlayer(ServerPlayer player);
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
package net.lionarius.skinrestorer.platform;
|
||||
|
||||
import net.lionarius.skinrestorer.SkinRestorer;
|
||||
import net.lionarius.skinrestorer.platform.services.CompatibilityHelper;
|
||||
import net.lionarius.skinrestorer.platform.services.PlatformHelper;
|
||||
|
||||
import java.util.ServiceLoader;
|
||||
|
||||
public final class Services {
|
||||
|
||||
public final static PlatformHelper PLATFORM = load(PlatformHelper.class);
|
||||
public final static CompatibilityHelper COMPATIBILITY = load(CompatibilityHelper.class);
|
||||
|
||||
private Services() {}
|
||||
|
||||
private static <T> T load(Class<T> clazz) {
|
||||
final T loadedService = ServiceLoader.load(clazz)
|
||||
.findFirst()
|
||||
.orElseThrow(() -> new NullPointerException("Failed to load service for " + clazz.getName()));
|
||||
SkinRestorer.LOGGER.debug("Loaded {} for service {}", loadedService, clazz);
|
||||
return loadedService;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
package net.lionarius.skinrestorer.platform.services;
|
||||
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
|
||||
public interface CompatibilityHelper {
|
||||
|
||||
void skinShuffle_sendHandshake(ServerPlayer player);
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
package net.lionarius.skinrestorer.platform.services;
|
||||
|
||||
import java.nio.file.Path;
|
||||
|
||||
public interface PlatformHelper {
|
||||
|
||||
String getPlatformName();
|
||||
|
||||
boolean isModLoaded(String modId);
|
||||
|
||||
Path getConfigDirectory();
|
||||
}
|
||||
@@ -0,0 +1,85 @@
|
||||
package net.lionarius.skinrestorer.skin;
|
||||
|
||||
import com.mojang.authlib.properties.Property;
|
||||
import net.lionarius.skinrestorer.skin.provider.MineskinSkinProvider;
|
||||
import net.lionarius.skinrestorer.skin.provider.MojangSkinProvider;
|
||||
import net.lionarius.skinrestorer.util.FileUtils;
|
||||
import net.lionarius.skinrestorer.util.JsonUtils;
|
||||
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.util.Objects;
|
||||
import java.util.UUID;
|
||||
|
||||
public class SkinIO {
|
||||
|
||||
public static final String FILE_EXTENSION = ".json";
|
||||
|
||||
private final Path savePath;
|
||||
|
||||
public SkinIO(Path savePath) {
|
||||
this.savePath = savePath;
|
||||
}
|
||||
|
||||
public boolean skinExists(UUID uuid) {
|
||||
return Files.exists(savePath.resolve(SkinIO.uuidToFilename(uuid)));
|
||||
}
|
||||
|
||||
public SkinValue loadSkin(UUID uuid) {
|
||||
try {
|
||||
return SkinIO.loadSkin(savePath.resolve(SkinIO.uuidToFilename(uuid)));
|
||||
} catch (Exception e) {
|
||||
return SkinValue.EMPTY;
|
||||
}
|
||||
}
|
||||
|
||||
private static SkinValue loadSkin(Path file) {
|
||||
var json = FileUtils.readFile(file);
|
||||
try {
|
||||
return JsonUtils.fromJson(json, SkinValue.class);
|
||||
} catch (Exception e) {
|
||||
var property = JsonUtils.fromJson(json, Property.class);
|
||||
return SkinIO.convertFromOldFormat(property);
|
||||
}
|
||||
}
|
||||
|
||||
public void saveSkin(UUID uuid, SkinValue skin) {
|
||||
FileUtils.writeFile(savePath.resolve(SkinIO.uuidToFilename(uuid)), JsonUtils.toJson(skin));
|
||||
}
|
||||
|
||||
public void deleteSkin(UUID uuid) {
|
||||
FileUtils.deleteFile(savePath.resolve(SkinIO.uuidToFilename(uuid)));
|
||||
}
|
||||
|
||||
private static String uuidToFilename(UUID uuid) {
|
||||
return uuid + FILE_EXTENSION;
|
||||
}
|
||||
|
||||
private static SkinValue convertFromOldFormat(Property property) {
|
||||
try {
|
||||
var propertyJson = Objects.requireNonNull(JsonUtils.skinPropertyToJson(property));
|
||||
var textures = propertyJson.getAsJsonObject("textures");
|
||||
|
||||
var capeTexture = textures.getAsJsonObject("CAPE");
|
||||
if (capeTexture != null) {
|
||||
var profileName = propertyJson.get("profileName").getAsString();
|
||||
return new SkinValue(MojangSkinProvider.PROVIDER_NAME, profileName, null, property);
|
||||
}
|
||||
|
||||
var skinTexture = textures.getAsJsonObject("SKIN");
|
||||
var url = skinTexture.get("url").getAsString();
|
||||
|
||||
var variant = SkinVariant.CLASSIC;
|
||||
var metadata = skinTexture.getAsJsonObject("metadata");
|
||||
if (metadata != null) {
|
||||
var model = metadata.get("model");
|
||||
if (model != null && "slim".equals(model.getAsString()))
|
||||
variant = SkinVariant.SLIM;
|
||||
}
|
||||
|
||||
return new SkinValue(MineskinSkinProvider.PROVIDER_NAME, url, variant, property);
|
||||
} catch (Exception e) {
|
||||
return SkinValue.EMPTY;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
package net.lionarius.skinrestorer.skin;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
public class SkinStorage {
|
||||
|
||||
private final Map<UUID, SkinValue> skinMap = new ConcurrentHashMap<>();
|
||||
private final SkinIO skinIO;
|
||||
|
||||
public SkinStorage(SkinIO skinIO) {
|
||||
this.skinIO = skinIO;
|
||||
}
|
||||
|
||||
public boolean hasSavedSkin(UUID uuid) {
|
||||
return this.skinMap.containsKey(uuid) || this.skinIO.skinExists(uuid);
|
||||
}
|
||||
|
||||
public SkinValue getSkin(UUID uuid, boolean cache) {
|
||||
if (!skinMap.containsKey(uuid)) {
|
||||
var skin = skinIO.loadSkin(uuid);
|
||||
if (!cache)
|
||||
return skin;
|
||||
|
||||
setSkin(uuid, skin);
|
||||
}
|
||||
|
||||
return skinMap.get(uuid);
|
||||
}
|
||||
|
||||
public SkinValue getSkin(UUID uuid) {
|
||||
return this.getSkin(uuid, true);
|
||||
}
|
||||
|
||||
public void removeSkin(UUID uuid, boolean save) {
|
||||
var skin = skinMap.remove(uuid);
|
||||
if (skin != null && save)
|
||||
skinIO.saveSkin(uuid, skin);
|
||||
}
|
||||
|
||||
public void removeSkin(UUID uuid) {
|
||||
this.removeSkin(uuid, true);
|
||||
}
|
||||
|
||||
public void deleteSkin(UUID uuid) {
|
||||
this.removeSkin(uuid, false);
|
||||
this.skinIO.deleteSkin(uuid);
|
||||
}
|
||||
|
||||
public void setSkin(UUID uuid, SkinValue skin) {
|
||||
if (skin == null)
|
||||
skin = SkinValue.EMPTY;
|
||||
|
||||
if (skinMap.containsKey(uuid) && skin.originalValue() == null)
|
||||
skin = skin.setOriginalValue(skinMap.get(uuid).originalValue());
|
||||
|
||||
skinMap.put(uuid, skin);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
package net.lionarius.skinrestorer.skin;
|
||||
|
||||
import com.mojang.authlib.properties.Property;
|
||||
import net.lionarius.skinrestorer.skin.provider.EmptySkinProvider;
|
||||
import net.lionarius.skinrestorer.skin.provider.SkinProviderContext;
|
||||
import net.lionarius.skinrestorer.util.gson.GsonPostProcessable;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
public record SkinValue(@NotNull String provider, @Nullable String argument, @Nullable SkinVariant variant,
|
||||
@Nullable Property value, @Nullable Property originalValue) implements GsonPostProcessable {
|
||||
|
||||
public static final SkinValue EMPTY = new SkinValue(EmptySkinProvider.PROVIDER_NAME, null, null, null);
|
||||
|
||||
public SkinValue(String provider, String argument, SkinVariant variant, Property value) {
|
||||
this(provider, argument, variant, value, null);
|
||||
}
|
||||
|
||||
public static SkinValue fromProviderContextWithValue(SkinProviderContext context, Property value) {
|
||||
return new SkinValue(context.name(), context.argument(), context.variant(), value);
|
||||
}
|
||||
|
||||
public SkinProviderContext toProviderContext() {
|
||||
return new SkinProviderContext(this.provider, this.argument, this.variant);
|
||||
}
|
||||
|
||||
public SkinValue replaceValueWithOriginal() {
|
||||
return new SkinValue(this.provider, this.argument, this.variant, this.originalValue, this.originalValue);
|
||||
}
|
||||
|
||||
public SkinValue setOriginalValue(Property originalValue) {
|
||||
return new SkinValue(this.provider, this.argument, this.variant, this.value, originalValue);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void gsonPostProcess() {
|
||||
Objects.requireNonNull(this.provider);
|
||||
}
|
||||
}
|
||||
@@ -1,16 +1,19 @@
|
||||
package net.lionarius.skinrestorer.enums;
|
||||
package net.lionarius.skinrestorer.skin;
|
||||
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
|
||||
public enum SkinVariant {
|
||||
|
||||
@SerializedName(value = "classic", alternate = {"CLASSIC"})
|
||||
CLASSIC("classic"),
|
||||
@SerializedName(value = "slim", alternate = {"SLIM"})
|
||||
SLIM("slim");
|
||||
|
||||
|
||||
private final String name;
|
||||
|
||||
|
||||
SkinVariant(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return name;
|
||||
@@ -0,0 +1,91 @@
|
||||
package net.lionarius.skinrestorer.skin.provider;
|
||||
|
||||
import com.google.common.cache.CacheBuilder;
|
||||
import com.google.common.cache.CacheLoader;
|
||||
import com.google.common.cache.LoadingCache;
|
||||
import com.google.common.util.concurrent.UncheckedExecutionException;
|
||||
import com.mojang.authlib.properties.Property;
|
||||
import it.unimi.dsi.fastutil.Pair;
|
||||
import net.lionarius.skinrestorer.SkinRestorer;
|
||||
import net.lionarius.skinrestorer.config.provider.collection.CollectionSkinSource;
|
||||
import net.lionarius.skinrestorer.skin.SkinVariant;
|
||||
import net.lionarius.skinrestorer.util.Result;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.net.URI;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
public final class CollectionSkinProvider implements SkinProvider {
|
||||
|
||||
public static final String PROVIDER_NAME = "collection";
|
||||
|
||||
private static LoadingCache<Integer, Optional<Property>> SKIN_CACHE;
|
||||
|
||||
private static List<Pair<URI, SkinVariant>> COLLECTION_SKINS;
|
||||
|
||||
public static void reload() {
|
||||
COLLECTION_SKINS = loadCollectionSkins();
|
||||
|
||||
createCache();
|
||||
}
|
||||
|
||||
private static List<Pair<URI, SkinVariant>> loadCollectionSkins() {
|
||||
List<Pair<URI, SkinVariant>> skins = new ArrayList<>();
|
||||
|
||||
var config = SkinRestorer.getConfig().providersConfig().collection();
|
||||
|
||||
for (CollectionSkinSource source : config.sources()) {
|
||||
var uri = source.uri();
|
||||
if (uri != null) {
|
||||
skins.add(Pair.of(uri, source.variant()));
|
||||
}
|
||||
}
|
||||
|
||||
return skins;
|
||||
}
|
||||
|
||||
private static void createCache() {
|
||||
var config = SkinRestorer.getConfig().providersConfig().collection();
|
||||
var time = config.cache().enabled() ? config.cache().duration() : 0;
|
||||
|
||||
SKIN_CACHE = CacheBuilder.newBuilder()
|
||||
.expireAfterWrite(time, TimeUnit.SECONDS)
|
||||
.build(new CacheLoader<>() {
|
||||
@Override
|
||||
public @NotNull Optional<Property> load(@NotNull Integer key) throws Exception {
|
||||
var skinEntry = COLLECTION_SKINS.get(key);
|
||||
return MineskinSkinProvider.loadSkin(skinEntry.first(), skinEntry.second());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getArgumentName() {
|
||||
return "seed";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasVariantSupport() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result<Optional<Property>, Exception> fetchSkin(String argument, SkinVariant variant) {
|
||||
if (COLLECTION_SKINS.isEmpty()) {
|
||||
return Result.error(new IllegalStateException("No collection skins configured"));
|
||||
}
|
||||
|
||||
var skinIndex = Math.abs(argument.hashCode()) % COLLECTION_SKINS.size();
|
||||
|
||||
try {
|
||||
return Result.success(SKIN_CACHE.get(skinIndex));
|
||||
} catch (UncheckedExecutionException e) {
|
||||
return Result.error((Exception) e.getCause());
|
||||
} catch (Exception e) {
|
||||
return Result.error(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,107 @@
|
||||
package net.lionarius.skinrestorer.skin.provider;
|
||||
|
||||
import com.google.common.cache.CacheBuilder;
|
||||
import com.google.common.cache.CacheLoader;
|
||||
import com.google.common.cache.LoadingCache;
|
||||
import com.google.common.util.concurrent.UncheckedExecutionException;
|
||||
import com.mojang.authlib.GameProfile;
|
||||
import com.mojang.authlib.properties.Property;
|
||||
import com.mojang.authlib.yggdrasil.response.MinecraftProfilePropertiesResponse;
|
||||
import net.lionarius.skinrestorer.SkinRestorer;
|
||||
import net.lionarius.skinrestorer.skin.SkinVariant;
|
||||
import net.lionarius.skinrestorer.util.*;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
import java.net.http.HttpRequest;
|
||||
import java.util.Locale;
|
||||
import java.util.Optional;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
public final class ElyBySkinProvider implements SkinProvider {
|
||||
|
||||
public static final String PROVIDER_NAME = "ely.by";
|
||||
|
||||
private static final URI API_URI;
|
||||
|
||||
private static LoadingCache<String, Optional<Property>> SKIN_CACHE;
|
||||
|
||||
static {
|
||||
try {
|
||||
API_URI = new URI("http://skinsystem.ely.by");
|
||||
} catch (URISyntaxException e) {
|
||||
throw new IllegalArgumentException(e);
|
||||
}
|
||||
}
|
||||
|
||||
public static void reload() {
|
||||
createCache();
|
||||
}
|
||||
|
||||
private static void createCache() {
|
||||
var config = SkinRestorer.getConfig().providersConfig().ely_by();
|
||||
var time = config.cache().enabled() ? config.cache().duration() : 0;
|
||||
|
||||
SKIN_CACHE = CacheBuilder.newBuilder()
|
||||
.expireAfterWrite(time, TimeUnit.SECONDS)
|
||||
.build(new CacheLoader<>() {
|
||||
@Override
|
||||
public @NotNull Optional<Property> load(@NotNull String key) throws Exception {
|
||||
return ElyBySkinProvider.loadSkin(key);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getArgumentName() {
|
||||
return "username";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasVariantSupport() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result<Optional<Property>, Exception> fetchSkin(String username, SkinVariant variant) {
|
||||
try {
|
||||
if (!StringUtils.isValidPlayerName(username))
|
||||
throw new IllegalArgumentException("invalid username");
|
||||
|
||||
var usernameLowerCase = username.toLowerCase(Locale.ROOT);
|
||||
|
||||
return Result.success(SKIN_CACHE.get(usernameLowerCase));
|
||||
} catch (UncheckedExecutionException e) {
|
||||
return Result.error((Exception) e.getCause());
|
||||
} catch (Exception e) {
|
||||
return Result.error(e);
|
||||
}
|
||||
}
|
||||
|
||||
private static Optional<Property> loadSkin(String username) throws Exception {
|
||||
var profile = ElyBySkinProvider.getElyByProfile(username);
|
||||
var textures = PlayerUtils.getPlayerSkin(profile);
|
||||
|
||||
return Optional.ofNullable(textures);
|
||||
}
|
||||
|
||||
private static GameProfile getElyByProfile(String username) throws IOException {
|
||||
var request = HttpRequest.newBuilder()
|
||||
.uri(ElyBySkinProvider.API_URI
|
||||
.resolve("/textures/signed/")
|
||||
.resolve(username + "?unsigned=false")
|
||||
)
|
||||
.GET()
|
||||
.build();
|
||||
|
||||
var response = WebUtils.executeRequest(request);
|
||||
WebUtils.throwOnClientErrors(response);
|
||||
|
||||
if (response.statusCode() != 200)
|
||||
throw new IllegalArgumentException("no profile with name " + username);
|
||||
|
||||
return JsonUtils.fromJson(response.body(), MinecraftProfilePropertiesResponse.class).toProfile();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
package net.lionarius.skinrestorer.skin.provider;
|
||||
|
||||
import com.mojang.authlib.properties.Property;
|
||||
import net.lionarius.skinrestorer.skin.SkinVariant;
|
||||
import net.lionarius.skinrestorer.util.Result;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
public final class EmptySkinProvider implements SkinProvider {
|
||||
|
||||
public static final String PROVIDER_NAME = "empty";
|
||||
|
||||
@Override
|
||||
public String getArgumentName() {
|
||||
return "placeholder";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasVariantSupport() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result<Optional<Property>, Exception> fetchSkin(String argument, SkinVariant variant) {
|
||||
return this.fetchSkin();
|
||||
}
|
||||
|
||||
public Result<Optional<Property>, Exception> fetchSkin() {
|
||||
return Result.ofNullable(null);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,127 @@
|
||||
package net.lionarius.skinrestorer.skin.provider;
|
||||
|
||||
import com.google.common.cache.CacheBuilder;
|
||||
import com.google.common.cache.CacheLoader;
|
||||
import com.google.common.cache.LoadingCache;
|
||||
import com.google.common.util.concurrent.UncheckedExecutionException;
|
||||
import com.mojang.authlib.properties.Property;
|
||||
import it.unimi.dsi.fastutil.Pair;
|
||||
import net.lionarius.skinrestorer.SkinRestorer;
|
||||
import net.lionarius.skinrestorer.mineskin.Java11RequestHandler;
|
||||
import net.lionarius.skinrestorer.skin.SkinVariant;
|
||||
import net.lionarius.skinrestorer.util.JsonUtils;
|
||||
import net.lionarius.skinrestorer.util.PlayerUtils;
|
||||
import net.lionarius.skinrestorer.util.Result;
|
||||
import net.lionarius.skinrestorer.util.WebUtils;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.mineskin.MineSkinClient;
|
||||
import org.mineskin.data.Variant;
|
||||
import org.mineskin.data.Visibility;
|
||||
import org.mineskin.request.GenerateRequest;
|
||||
import org.mineskin.response.QueueResponse;
|
||||
|
||||
import java.net.InetSocketAddress;
|
||||
import java.net.URI;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.time.Duration;
|
||||
import java.util.Optional;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
public final class MineskinSkinProvider implements SkinProvider {
|
||||
|
||||
public static final String PROVIDER_NAME = "web";
|
||||
|
||||
private static MineSkinClient MINESKIN_CLIENT;
|
||||
|
||||
private static LoadingCache<Pair<URI, SkinVariant>, Optional<Property>> SKIN_CACHE;
|
||||
|
||||
public static void reload() {
|
||||
var config = SkinRestorer.getConfig();
|
||||
var configApiKey = config.providersConfig().mineskin().apiKey();
|
||||
|
||||
MINESKIN_CLIENT = MineSkinClient
|
||||
.builder()
|
||||
.userAgent(WebUtils.USER_AGENT)
|
||||
.gson(JsonUtils.GSON)
|
||||
.timeout((int) Duration.ofSeconds(config.requestTimeout()).toMillis())
|
||||
.requestHandler((baseUrl, userAgent, apiKey, timeout, gson) -> new Java11RequestHandler(
|
||||
baseUrl,
|
||||
userAgent,
|
||||
apiKey,
|
||||
timeout,
|
||||
gson,
|
||||
SkinRestorer.getConfig().proxy().map(proxy -> new InetSocketAddress(proxy.host(), proxy.port())).orElse(null)
|
||||
))
|
||||
.apiKey(configApiKey.isEmpty() ? null : configApiKey)
|
||||
.build();
|
||||
|
||||
createCache();
|
||||
}
|
||||
|
||||
private static void createCache() {
|
||||
var config = SkinRestorer.getConfig().providersConfig().mineskin();
|
||||
var time = config.cache().enabled() ? config.cache().duration() : 0;
|
||||
|
||||
SKIN_CACHE = CacheBuilder.newBuilder()
|
||||
.expireAfterWrite(time, TimeUnit.SECONDS)
|
||||
.build(new CacheLoader<>() {
|
||||
@Override
|
||||
public @NotNull Optional<Property> load(@NotNull Pair<URI, SkinVariant> key) throws Exception {
|
||||
return MineskinSkinProvider.loadSkin(key.first(), key.second());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getArgumentName() {
|
||||
return "url";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasVariantSupport() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result<Optional<Property>, Exception> fetchSkin(String url, SkinVariant variant) {
|
||||
try {
|
||||
var uri = new URI(url);
|
||||
|
||||
return Result.success(SKIN_CACHE.get(Pair.of(uri, variant)));
|
||||
} catch (UncheckedExecutionException e) {
|
||||
return Result.error((Exception) e.getCause());
|
||||
} catch (Exception e) {
|
||||
return Result.error(e);
|
||||
}
|
||||
}
|
||||
|
||||
static Optional<Property> loadSkin(URI uri, SkinVariant variant) throws Exception {
|
||||
var mineskinVariant = switch (variant) {
|
||||
case CLASSIC -> Variant.CLASSIC;
|
||||
case SLIM -> Variant.SLIM;
|
||||
};
|
||||
|
||||
var request = "file".equals(uri.getScheme())
|
||||
? GenerateRequest.upload(Files.newInputStream(Path.of(uri)))
|
||||
.variant(mineskinVariant)
|
||||
.name("skinrestorer-skin")
|
||||
.visibility(Visibility.UNLISTED)
|
||||
: GenerateRequest.url(uri)
|
||||
.variant(mineskinVariant)
|
||||
.name("skinrestorer-skin")
|
||||
.visibility(Visibility.UNLISTED);
|
||||
|
||||
var skin = MINESKIN_CLIENT.queue().submit(request)
|
||||
.thenApply(QueueResponse::getJob)
|
||||
.thenCompose(jobInfo -> jobInfo.waitForCompletion(MINESKIN_CLIENT))
|
||||
.thenCompose(jobReference -> jobReference.getOrLoadSkin(MINESKIN_CLIENT))
|
||||
.join();
|
||||
|
||||
return Optional.of(new Property(
|
||||
PlayerUtils.TEXTURES_KEY,
|
||||
skin.texture().data().value(),
|
||||
skin.texture().data().signature()
|
||||
));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,154 @@
|
||||
package net.lionarius.skinrestorer.skin.provider;
|
||||
|
||||
import com.google.common.cache.CacheBuilder;
|
||||
import com.google.common.cache.CacheLoader;
|
||||
import com.google.common.cache.LoadingCache;
|
||||
import com.google.common.util.concurrent.UncheckedExecutionException;
|
||||
import com.mojang.authlib.*;
|
||||
import com.mojang.authlib.properties.Property;
|
||||
import com.mojang.authlib.yggdrasil.YggdrasilEnvironment;
|
||||
import com.mojang.authlib.yggdrasil.response.MinecraftProfilePropertiesResponse;
|
||||
import com.mojang.util.UndashedUuid;
|
||||
import net.lionarius.skinrestorer.SkinRestorer;
|
||||
import net.lionarius.skinrestorer.exception.TransparentException;
|
||||
import net.lionarius.skinrestorer.skin.SkinVariant;
|
||||
import net.lionarius.skinrestorer.util.*;
|
||||
import net.minecraft.server.players.GameProfileCache;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
import java.net.http.HttpRequest;
|
||||
import java.util.Optional;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
public final class MojangSkinProvider implements SkinProvider {
|
||||
|
||||
public static final String PROVIDER_NAME = "mojang";
|
||||
|
||||
private static final Environment ENVIRONMENT;
|
||||
private static final URI SERVICES_SERVER_URI;
|
||||
private static final URI SESSION_SERVER_URI;
|
||||
|
||||
public static final String PROFILE_CACHE_FILENAME = "mojang_profile_cache.json";
|
||||
private static final GameProfileCache PROFILE_CACHE;
|
||||
|
||||
private static LoadingCache<UUID, Optional<Property>> SKIN_CACHE;
|
||||
|
||||
static {
|
||||
try {
|
||||
ENVIRONMENT = EnvironmentParser.getEnvironmentFromProperties().orElse(YggdrasilEnvironment.PROD.getEnvironment());
|
||||
|
||||
SERVICES_SERVER_URI = new URI(ENVIRONMENT.servicesHost());
|
||||
SESSION_SERVER_URI = new URI(ENVIRONMENT.sessionHost());
|
||||
} catch (URISyntaxException e) {
|
||||
throw new IllegalArgumentException(e);
|
||||
}
|
||||
|
||||
PROFILE_CACHE = new GameProfileCache((names, callback) -> {
|
||||
for (var name : names) {
|
||||
try {
|
||||
var profile = MojangSkinProvider.getProfile(name);
|
||||
callback.onProfileLookupSucceeded(profile);
|
||||
} catch (IOException e) {
|
||||
throw new TransparentException(e);
|
||||
}
|
||||
}
|
||||
}, SkinRestorer.getConfigDir().resolve(PROFILE_CACHE_FILENAME).toFile());
|
||||
}
|
||||
|
||||
public static void reload() {
|
||||
createCache();
|
||||
}
|
||||
|
||||
private static void createCache() {
|
||||
var config = SkinRestorer.getConfig().providersConfig().mojang();
|
||||
var time = config.cache().enabled() ? config.cache().duration() : 0;
|
||||
|
||||
SKIN_CACHE = CacheBuilder.newBuilder()
|
||||
.expireAfterWrite(time, TimeUnit.SECONDS)
|
||||
.build(new CacheLoader<>() {
|
||||
@Override
|
||||
public @NotNull Optional<Property> load(@NotNull UUID key) throws Exception {
|
||||
return MojangSkinProvider.loadSkin(key);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public static SkinProviderContext skinProviderContextFromProfile(GameProfile gameProfile) {
|
||||
return new SkinProviderContext(MojangSkinProvider.PROVIDER_NAME, gameProfile.getName(), null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getArgumentName() {
|
||||
return "username";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasVariantSupport() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result<Optional<Property>, Exception> fetchSkin(String username, SkinVariant variant) {
|
||||
try {
|
||||
if (!StringUtils.isValidPlayerName(username))
|
||||
throw new IllegalArgumentException("invalid username");
|
||||
|
||||
var cachedProfile = MojangSkinProvider.PROFILE_CACHE.get(username);
|
||||
if (cachedProfile.isEmpty())
|
||||
throw new IllegalArgumentException("no profile found for " + username);
|
||||
|
||||
return Result.success(SKIN_CACHE.get(cachedProfile.get().getId()));
|
||||
} catch (UncheckedExecutionException e) {
|
||||
return Result.error((Exception) e.getCause());
|
||||
} catch (Exception e) {
|
||||
return Result.error(e);
|
||||
}
|
||||
}
|
||||
|
||||
private static Optional<Property> loadSkin(UUID uuid) throws Exception {
|
||||
var profile = MojangSkinProvider.getProfileWithProperties(uuid);
|
||||
var textures = PlayerUtils.getPlayerSkin(profile);
|
||||
|
||||
return Optional.ofNullable(textures);
|
||||
}
|
||||
|
||||
private static GameProfile getProfile(final String name) throws IOException {
|
||||
var request = HttpRequest.newBuilder()
|
||||
.uri(MojangSkinProvider.SERVICES_SERVER_URI
|
||||
.resolve("/minecraft/profile/lookup/name/")
|
||||
.resolve(name)
|
||||
)
|
||||
.GET()
|
||||
.build();
|
||||
|
||||
var response = WebUtils.executeRequest(request);
|
||||
WebUtils.throwOnClientErrors(response);
|
||||
|
||||
if (response.statusCode() != 200)
|
||||
throw new IllegalArgumentException("no profile with name " + name);
|
||||
|
||||
return JsonUtils.fromJson(response.body(), GameProfile.class);
|
||||
}
|
||||
|
||||
private static GameProfile getProfileWithProperties(UUID uuid) throws IOException {
|
||||
var request = HttpRequest.newBuilder()
|
||||
.uri(MojangSkinProvider.SESSION_SERVER_URI
|
||||
.resolve("/session/minecraft/profile/")
|
||||
.resolve(UndashedUuid.toString(uuid) + "?unsigned=false")
|
||||
)
|
||||
.GET()
|
||||
.build();
|
||||
|
||||
var response = WebUtils.executeRequest(request);
|
||||
WebUtils.throwOnClientErrors(response);
|
||||
|
||||
if (response.statusCode() != 200)
|
||||
throw new IllegalArgumentException("no profile with uuid " + uuid);
|
||||
|
||||
return JsonUtils.fromJson(response.body(), MinecraftProfilePropertiesResponse.class).toProfile();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
package net.lionarius.skinrestorer.skin.provider;
|
||||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.mojang.authlib.properties.Property;
|
||||
import net.lionarius.skinrestorer.skin.SkinVariant;
|
||||
import net.lionarius.skinrestorer.util.Result;
|
||||
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
|
||||
public interface SkinProvider {
|
||||
EmptySkinProvider EMPTY = new EmptySkinProvider();
|
||||
MojangSkinProvider MOJANG = new MojangSkinProvider();
|
||||
ElyBySkinProvider ELY_BY = new ElyBySkinProvider();
|
||||
MineskinSkinProvider MINESKIN = new MineskinSkinProvider();
|
||||
CollectionSkinProvider COLLECTION = new CollectionSkinProvider();
|
||||
SkinShuffleSkinProvider SKIN_SHUFFLE = new SkinShuffleSkinProvider();
|
||||
|
||||
Set<String> BUILTIN_PROVIDER_NAMES = ImmutableSet.of(
|
||||
EmptySkinProvider.PROVIDER_NAME,
|
||||
MojangSkinProvider.PROVIDER_NAME,
|
||||
ElyBySkinProvider.PROVIDER_NAME,
|
||||
MineskinSkinProvider.PROVIDER_NAME,
|
||||
CollectionSkinProvider.PROVIDER_NAME,
|
||||
SkinShuffleSkinProvider.PROVIDER_NAME
|
||||
);
|
||||
|
||||
String getArgumentName();
|
||||
|
||||
boolean hasVariantSupport();
|
||||
|
||||
Result<Optional<Property>, Exception> fetchSkin(String argument, SkinVariant variant);
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
package net.lionarius.skinrestorer.skin.provider;
|
||||
|
||||
import net.lionarius.skinrestorer.skin.SkinVariant;
|
||||
|
||||
public record SkinProviderContext(String name, String argument, SkinVariant variant) {
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
package net.lionarius.skinrestorer.skin.provider;
|
||||
|
||||
import it.unimi.dsi.fastutil.Pair;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public final class SkinProviderRegistry {
|
||||
|
||||
private final Map<String, Entry> registry = new HashMap<>();
|
||||
|
||||
public SkinProvider get(String name) {
|
||||
var entry = this.registry.get(name);
|
||||
if (entry == null)
|
||||
return null;
|
||||
|
||||
return entry.provider;
|
||||
}
|
||||
|
||||
public Collection<Pair<String, SkinProvider>> getProviders() {
|
||||
return this.registry
|
||||
.entrySet()
|
||||
.stream()
|
||||
.map(entry -> Pair.of(entry.getKey(), entry.getValue().provider))
|
||||
.toList();
|
||||
}
|
||||
|
||||
public Collection<Pair<String, SkinProvider>> getPublicProviders() {
|
||||
return this.registry
|
||||
.entrySet()
|
||||
.stream()
|
||||
.filter(entry -> entry.getValue().isPublic)
|
||||
.map(entry -> Pair.of(entry.getKey(), entry.getValue().provider))
|
||||
.toList();
|
||||
}
|
||||
|
||||
public void register(@NotNull String name, @NotNull SkinProvider provider) {
|
||||
this.register(name, provider, true);
|
||||
}
|
||||
|
||||
public void register(@NotNull String name, @NotNull SkinProvider provider, boolean isPublic) {
|
||||
if (this.registry.containsKey(name))
|
||||
return;
|
||||
|
||||
this.registry.put(name, new Entry(provider, isPublic));
|
||||
}
|
||||
|
||||
private record Entry(SkinProvider provider, boolean isPublic) {
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
package net.lionarius.skinrestorer.skin.provider;
|
||||
|
||||
import com.mojang.authlib.properties.Property;
|
||||
import net.lionarius.skinrestorer.skin.SkinVariant;
|
||||
import net.lionarius.skinrestorer.util.Result;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
public final class SkinShuffleSkinProvider implements SkinProvider {
|
||||
|
||||
public static final String PROVIDER_NAME = "skinshuffle";
|
||||
|
||||
@Override
|
||||
public String getArgumentName() {
|
||||
return "unsupported";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasVariantSupport() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result<Optional<Property>, Exception> fetchSkin(String argument, SkinVariant variant) {
|
||||
return Result.error(new UnsupportedOperationException("SkinShuffle Provider does not support fetching skins"));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,69 @@
|
||||
package net.lionarius.skinrestorer.translation;
|
||||
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.google.common.reflect.TypeToken;
|
||||
import net.lionarius.skinrestorer.SkinRestorer;
|
||||
import net.lionarius.skinrestorer.util.FileUtils;
|
||||
import net.lionarius.skinrestorer.util.JsonUtils;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.network.chat.MutableComponent;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
|
||||
public final class Translation {
|
||||
public static final String LEGACY_TRANSLATION_FILENAME = "translation";
|
||||
|
||||
public static final String COMMAND_SKIN_AFFECTED_PLAYERS_KEY = "skinrestorer.command.skin.affected_players";
|
||||
public static final String COMMAND_SKIN_NO_CHANGES_KEY = "skinrestorer.command.skin.no_changes";
|
||||
public static final String COMMAND_SKIN_FAILED_KEY = "skinrestorer.command.skin.failed";
|
||||
public static final String COMMAND_SKIN_OK_KEY = "skinrestorer.command.skin.ok";
|
||||
public static final String COMMAND_SKIN_LOADING_KEY = "skinrestorer.command.skin.loading";
|
||||
public static final String COMMAND_SKIN_CONFIG_RELOADED_KEY = "skinrestorer.command.skin.config_reloaded";
|
||||
|
||||
private static Map<String, String> translations;
|
||||
private static final Map<String, String> fallback;
|
||||
|
||||
static {
|
||||
fallback = Translation.loadTranslationMap("en_us");
|
||||
}
|
||||
|
||||
private Translation() {}
|
||||
|
||||
public static String get(String key) {
|
||||
var value = translations.get(key);
|
||||
if (value == null)
|
||||
value = fallback.get(key);
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
public static MutableComponent translatableWithFallback(String key) {
|
||||
return Component.translatableWithFallback(key, Translation.get(key));
|
||||
}
|
||||
|
||||
public static MutableComponent translatableWithFallback(String key, Object... args) {
|
||||
return Component.translatableWithFallback(key, Translation.get(key), args);
|
||||
}
|
||||
|
||||
public static void reloadTranslations() {
|
||||
translations = Translation.loadTranslationMap(SkinRestorer.getConfig().language());
|
||||
}
|
||||
|
||||
private static ImmutableMap<String, String> loadTranslationMap(String lang) {
|
||||
var json = FileUtils.readResource(SkinRestorer.assetPath(String.format("lang/%s.json", lang)));
|
||||
|
||||
var type = new TypeToken<Map<String, String>>() {}.getType();
|
||||
Map<String, String> map = null;
|
||||
try {
|
||||
map = JsonUtils.fromJson(Objects.requireNonNull(json), type);
|
||||
} catch (Exception e) {
|
||||
SkinRestorer.LOGGER.error("Failed to load translation map", e);
|
||||
}
|
||||
|
||||
if (map == null)
|
||||
return ImmutableMap.<String, String>builder().build();
|
||||
|
||||
return ImmutableMap.copyOf(map);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,98 @@
|
||||
package net.lionarius.skinrestorer.util;
|
||||
|
||||
import net.lionarius.skinrestorer.SkinRestorer;
|
||||
import net.lionarius.skinrestorer.config.Config;
|
||||
import net.lionarius.skinrestorer.skin.SkinIO;
|
||||
import net.lionarius.skinrestorer.skin.provider.MojangSkinProvider;
|
||||
import net.lionarius.skinrestorer.translation.Translation;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.StandardCopyOption;
|
||||
|
||||
public final class FileUtils {
|
||||
|
||||
private FileUtils() {}
|
||||
|
||||
public static void tryMigrateOldSkinDirectory(Path oldDirectory, Path newDirectory) {
|
||||
try {
|
||||
try (var stream = Files.list(oldDirectory)) {
|
||||
var files = stream.filter(file -> {
|
||||
var name = file.getFileName().toString();
|
||||
return Files.isRegularFile(file)
|
||||
&& !name.startsWith(Translation.LEGACY_TRANSLATION_FILENAME)
|
||||
&& !name.startsWith(Config.CONFIG_FILENAME)
|
||||
&& !name.startsWith(MojangSkinProvider.PROFILE_CACHE_FILENAME)
|
||||
&& name.endsWith(SkinIO.FILE_EXTENSION);
|
||||
}).toList();
|
||||
|
||||
if (!files.isEmpty() && !Files.exists(newDirectory))
|
||||
Files.createDirectories(newDirectory);
|
||||
|
||||
for (var file : files) {
|
||||
var newFile = newDirectory.resolve(file.getFileName());
|
||||
if (!Files.exists(newFile))
|
||||
Files.move(file, newFile, StandardCopyOption.ATOMIC_MOVE);
|
||||
else
|
||||
Files.delete(file);
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
SkinRestorer.LOGGER.error("Could not migrate skin directory", e);
|
||||
}
|
||||
}
|
||||
|
||||
public static String readResource(String name) {
|
||||
try (var stream = SkinRestorer.class.getResourceAsStream(name)) {
|
||||
if (stream == null)
|
||||
return null;
|
||||
|
||||
try (var reader = new BufferedReader(new InputStreamReader(stream, StandardCharsets.UTF_8))) {
|
||||
return StringUtils.readString(reader);
|
||||
}
|
||||
} catch (IOException e) {
|
||||
SkinRestorer.LOGGER.error("Failed to read resource", e);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public static String readFile(Path file) {
|
||||
try {
|
||||
if (!Files.exists(file))
|
||||
return null;
|
||||
|
||||
return Files.readString(file);
|
||||
} catch (Exception e) {
|
||||
SkinRestorer.LOGGER.error("Failed to read file", e);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public static void writeFile(Path file, String content) {
|
||||
try {
|
||||
var parent = file.getParent();
|
||||
if (parent != null)
|
||||
Files.createDirectories(parent);
|
||||
|
||||
if (!Files.exists(file))
|
||||
Files.createFile(file);
|
||||
|
||||
Files.writeString(file, content);
|
||||
} catch (IOException e) {
|
||||
SkinRestorer.LOGGER.error("Failed to write file", e);
|
||||
}
|
||||
}
|
||||
|
||||
public static void deleteFile(Path file) {
|
||||
try {
|
||||
if (Files.exists(file))
|
||||
Files.delete(file);
|
||||
} catch (IOException e) {
|
||||
SkinRestorer.LOGGER.error("Failed to delete file", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
package net.lionarius.skinrestorer.util;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.GsonBuilder;
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.mojang.authlib.GameProfile;
|
||||
import com.mojang.authlib.properties.Property;
|
||||
import com.mojang.authlib.properties.PropertyMap;
|
||||
import com.mojang.util.UUIDTypeAdapter;
|
||||
import net.lionarius.skinrestorer.SkinRestorer;
|
||||
import net.lionarius.skinrestorer.util.gson.PostProcessingEnabler;
|
||||
|
||||
import java.lang.reflect.Type;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.Base64;
|
||||
import java.util.UUID;
|
||||
|
||||
public final class JsonUtils {
|
||||
|
||||
public static final Gson GSON = new GsonBuilder()
|
||||
.registerTypeAdapterFactory(new PostProcessingEnabler())
|
||||
.registerTypeAdapter(UUID.class, new UUIDTypeAdapter())
|
||||
.registerTypeAdapter(PropertyMap.class, new PropertyMap.Serializer())
|
||||
.registerTypeAdapter(GameProfile.class, new GameProfile.Serializer())
|
||||
.setPrettyPrinting()
|
||||
.create();
|
||||
|
||||
private JsonUtils() {}
|
||||
|
||||
public static <T> T fromJson(String json, Class<T> clazz) {
|
||||
return GSON.fromJson(json, clazz);
|
||||
}
|
||||
|
||||
public static <T> T fromJson(JsonElement json, Class<T> clazz) {
|
||||
return GSON.fromJson(json, clazz);
|
||||
}
|
||||
|
||||
public static <T> T fromJson(String json, Type type) {
|
||||
return GSON.fromJson(json, type);
|
||||
}
|
||||
|
||||
public static <T> String toJson(T obj) {
|
||||
return GSON.toJson(obj);
|
||||
}
|
||||
|
||||
public static JsonObject parseJson(String json) {
|
||||
return GSON.fromJson(json, JsonObject.class);
|
||||
}
|
||||
|
||||
public static JsonObject skinPropertyToJson(Property property) {
|
||||
try {
|
||||
JsonObject json = GSON.fromJson(new String(Base64.getDecoder().decode(property.value()), StandardCharsets.UTF_8), JsonObject.class);
|
||||
if (json != null)
|
||||
json.remove("timestamp");
|
||||
|
||||
return json;
|
||||
} catch (Exception e) {
|
||||
SkinRestorer.LOGGER.error("Could not parse skin property", e);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,140 @@
|
||||
package net.lionarius.skinrestorer.util;
|
||||
|
||||
import com.google.common.collect.Iterables;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.mojang.authlib.GameProfile;
|
||||
import com.mojang.authlib.properties.Property;
|
||||
import com.mojang.authlib.yggdrasil.response.MinecraftProfilePropertiesResponse;
|
||||
import net.lionarius.skinrestorer.mixin.ChunkMapAccessor;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.network.protocol.game.*;
|
||||
import net.minecraft.server.level.ChunkMap;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.server.players.PlayerList;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
public final class PlayerUtils {
|
||||
|
||||
public static final String TEXTURES_KEY = "textures";
|
||||
|
||||
private PlayerUtils() {}
|
||||
|
||||
public static Component createPlayerListComponent(Collection<ServerPlayer> players) {
|
||||
var component = Component.empty();
|
||||
int index = 0;
|
||||
for (var player : players) {
|
||||
component.append(Objects.requireNonNull(player.getDisplayName()));
|
||||
index++;
|
||||
if (index < players.size())
|
||||
component.append(", ");
|
||||
}
|
||||
return component;
|
||||
}
|
||||
|
||||
public static boolean isFakePlayer(ServerPlayer player) {
|
||||
return player.getClass() != ServerPlayer.class; // if the player isn't a server player entity, it must be someone's fake player
|
||||
}
|
||||
|
||||
public static void refreshPlayer(ServerPlayer player) {
|
||||
ServerLevel serverLevel = player.serverLevel();
|
||||
PlayerList playerList = serverLevel.getServer().getPlayerList();
|
||||
ChunkMap chunkMap = serverLevel.getChunkSource().chunkMap;
|
||||
|
||||
playerList.broadcastAll(new ClientboundBundlePacket(
|
||||
List.of(
|
||||
new ClientboundPlayerInfoRemovePacket(List.of(player.getUUID())),
|
||||
ClientboundPlayerInfoUpdatePacket.createPlayerInitializing(Collections.singleton(player))
|
||||
)
|
||||
));
|
||||
|
||||
var trackedEntity = ((ChunkMapAccessor) chunkMap).getEntityMap().get(player.getId());
|
||||
if (trackedEntity != null) {
|
||||
var seenBy = Set.copyOf(trackedEntity.getSeenBy());
|
||||
for (var observerConnection : seenBy) {
|
||||
var observer = observerConnection.getPlayer();
|
||||
trackedEntity.invokeRemovePlayer(observer);
|
||||
|
||||
var trackedObserverEntity = ((ChunkMapAccessor) chunkMap).getEntityMap().get(observer.getId());
|
||||
if (trackedObserverEntity != null) {
|
||||
trackedObserverEntity.invokeRemovePlayer(player);
|
||||
trackedObserverEntity.invokeUpdatePlayer(player);
|
||||
}
|
||||
trackedEntity.invokeUpdatePlayer(observer);
|
||||
}
|
||||
}
|
||||
|
||||
if (!player.isDeadOrDying()) {
|
||||
player.connection.send(new ClientboundBundlePacket(
|
||||
List.of(
|
||||
new ClientboundRespawnPacket(player.createCommonSpawnInfo(serverLevel), ClientboundRespawnPacket.KEEP_ALL_DATA),
|
||||
new ClientboundGameEventPacket(ClientboundGameEventPacket.LEVEL_CHUNKS_LOAD_START, 0)
|
||||
)
|
||||
));
|
||||
player.connection.teleport(player.getX(), player.getY(), player.getZ(), player.getYRot(), player.getXRot());
|
||||
player.connection.send(new ClientboundSetEntityMotionPacket(player));
|
||||
var vehicle = player.getVehicle();
|
||||
if (vehicle != null)
|
||||
player.connection.send(new ClientboundSetPassengersPacket(vehicle));
|
||||
if (!player.getPassengers().isEmpty())
|
||||
player.connection.send(new ClientboundSetPassengersPacket(player));
|
||||
|
||||
player.onUpdateAbilities();
|
||||
player.giveExperiencePoints(0);
|
||||
playerList.sendPlayerPermissionLevel(player);
|
||||
playerList.sendLevelInfo(player, serverLevel);
|
||||
playerList.sendAllPlayerInfo(player);
|
||||
PlayerUtils.sendActivePlayerEffects(player);
|
||||
}
|
||||
}
|
||||
|
||||
private static void sendActivePlayerEffects(ServerPlayer player) {
|
||||
for (var effect : player.getActiveEffects()) {
|
||||
player.connection.send(new ClientboundUpdateMobEffectPacket(player.getId(), effect));
|
||||
}
|
||||
}
|
||||
|
||||
public static GameProfile cloneGameProfile(GameProfile profile) {
|
||||
var newProfile = new GameProfile(profile.getId(), profile.getName());
|
||||
newProfile.getProperties().putAll(profile.getProperties());
|
||||
|
||||
return newProfile;
|
||||
}
|
||||
|
||||
public static Property getPlayerSkin(GameProfile profile) {
|
||||
return Iterables.getFirst(profile.getProperties().get(TEXTURES_KEY), null);
|
||||
}
|
||||
|
||||
public static void applyRestoredSkin(GameProfile profile, Property skin) {
|
||||
profile.getProperties().removeAll(TEXTURES_KEY);
|
||||
|
||||
if (skin != null)
|
||||
profile.getProperties().put(TEXTURES_KEY, skin);
|
||||
}
|
||||
|
||||
public static boolean areSkinPropertiesEquals(Property x, Property y) {
|
||||
if (x == y)
|
||||
return true;
|
||||
|
||||
if (x == null || y == null)
|
||||
return false;
|
||||
|
||||
if (x.equals(y))
|
||||
return true;
|
||||
|
||||
JsonObject xJson = JsonUtils.skinPropertyToJson(x);
|
||||
JsonObject yJson = JsonUtils.skinPropertyToJson(y);
|
||||
|
||||
if (xJson == null || yJson == null)
|
||||
return false;
|
||||
|
||||
return xJson.equals(yJson);
|
||||
}
|
||||
|
||||
public static GameProfile toProfile(MinecraftProfilePropertiesResponse response) {
|
||||
final GameProfile profile = new GameProfile(response.id(), response.name());
|
||||
profile.getProperties().putAll(response.properties());
|
||||
return profile;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,84 @@
|
||||
package net.lionarius.skinrestorer.util;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
import java.util.function.Function;
|
||||
|
||||
public class Result<S, E> {
|
||||
|
||||
private final S successValue;
|
||||
private final E errorValue;
|
||||
|
||||
private Result(S successValue, E errorValue) {
|
||||
if (successValue == null && errorValue == null)
|
||||
throw new IllegalArgumentException("Cannot create result of null values");
|
||||
|
||||
this.successValue = successValue;
|
||||
this.errorValue = errorValue;
|
||||
}
|
||||
|
||||
public static <S, E> Result<S, E> success(@NotNull S successValue) {
|
||||
return new Result<>(successValue, null);
|
||||
}
|
||||
|
||||
public static <S, E> Result<S, E> error(@NotNull E errorValue) {
|
||||
return new Result<>(null, errorValue);
|
||||
}
|
||||
|
||||
public static <S, E> Result<Optional<S>, E> ofNullable(S successValue) {
|
||||
return Result.success(Optional.ofNullable(successValue));
|
||||
}
|
||||
|
||||
public S getSuccessValue() {
|
||||
return successValue;
|
||||
}
|
||||
|
||||
public E getErrorValue() {
|
||||
return errorValue;
|
||||
}
|
||||
|
||||
public boolean isSuccess() {
|
||||
return successValue != null;
|
||||
}
|
||||
|
||||
public boolean isError() {
|
||||
return errorValue != null;
|
||||
}
|
||||
|
||||
public <N> Result<N, E> map(Function<S, N> mapper) {
|
||||
if (successValue == null)
|
||||
return new Result<>(null, errorValue);
|
||||
|
||||
return new Result<>(mapper.apply(successValue), errorValue);
|
||||
}
|
||||
|
||||
public <N> Result<S, N> mapError(Function<E, N> mapper) {
|
||||
if (errorValue == null)
|
||||
return new Result<>(successValue, null);
|
||||
|
||||
return new Result<>(successValue, mapper.apply(errorValue));
|
||||
}
|
||||
|
||||
public Optional<S> toOptional() {
|
||||
return Optional.ofNullable(successValue);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o)
|
||||
return true;
|
||||
|
||||
if (o == null || getClass() != o.getClass())
|
||||
return false;
|
||||
|
||||
Result<?, ?> result = (Result<?, ?>) o;
|
||||
return Objects.equals(successValue, result.successValue) && Objects.equals(errorValue, result.errorValue);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(successValue, errorValue);
|
||||
}
|
||||
}
|
||||
@@ -3,15 +3,22 @@ package net.lionarius.skinrestorer.util;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
|
||||
public class StringUtils {
|
||||
|
||||
public final class StringUtils {
|
||||
|
||||
private StringUtils() {}
|
||||
|
||||
public static String readString(BufferedReader reader) throws IOException {
|
||||
String inputLine;
|
||||
StringBuilder response = new StringBuilder();
|
||||
|
||||
|
||||
while ((inputLine = reader.readLine()) != null) {
|
||||
response.append(inputLine);
|
||||
}
|
||||
|
||||
return response.toString();
|
||||
}
|
||||
|
||||
public static boolean isValidPlayerName(String playerName) {
|
||||
return playerName.length() <= 16 && playerName.chars().filter(i -> i <= 32 || i >= 127).findAny().isEmpty();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
package net.lionarius.skinrestorer.util;
|
||||
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.Queue;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.PriorityBlockingQueue;
|
||||
|
||||
public class TickedScheduler implements Runnable {
|
||||
private final MinecraftServer server;
|
||||
private final Queue<TickTask> queue = new PriorityBlockingQueue<>();
|
||||
private final Map<Integer, Integer> idMap = new ConcurrentHashMap<>();
|
||||
|
||||
public TickedScheduler(MinecraftServer server) {
|
||||
this.server = server;
|
||||
}
|
||||
|
||||
public void schedule(Runnable task, int delay) {
|
||||
this.schedule(task, delay, task);
|
||||
}
|
||||
|
||||
public void schedule(Runnable task, int delay, Object id) {
|
||||
var taskId = id.hashCode();
|
||||
var serverTick = this.server.getTickCount();
|
||||
this.idMap.merge(taskId, serverTick, Integer::max);
|
||||
this.queue.add(new TickTask(serverTick, serverTick + delay, taskId, task));
|
||||
}
|
||||
|
||||
public void cancel(Object id) {
|
||||
var taskId = id.hashCode();
|
||||
this.idMap.remove(taskId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
TickTask nextTask;
|
||||
while ((nextTask = this.queue.peek()) != null) {
|
||||
if (nextTask.runOnTick() > this.server.getTickCount())
|
||||
break;
|
||||
|
||||
var tickTask = this.queue.remove();
|
||||
var lastTaskScheduledOnTick = this.idMap.get(tickTask.id());
|
||||
|
||||
if (lastTaskScheduledOnTick != null && lastTaskScheduledOnTick <= tickTask.scheduledOnTick()) {
|
||||
this.idMap.remove(tickTask.id());
|
||||
if (tickTask.task() != null)
|
||||
tickTask.task().run();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private record TickTask(int scheduledOnTick, int runOnTick, int id, Runnable task) implements Comparable<TickTask> {
|
||||
@Override
|
||||
public int compareTo(@NotNull TickedScheduler.TickTask other) {
|
||||
return Integer.compare(this.runOnTick, other.runOnTick);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,79 @@
|
||||
package net.lionarius.skinrestorer.util;
|
||||
|
||||
import net.lionarius.skinrestorer.SkinRestorer;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.InetSocketAddress;
|
||||
import java.net.ProxySelector;
|
||||
import java.net.http.HttpClient;
|
||||
import java.net.http.HttpRequest;
|
||||
import java.net.http.HttpResponse;
|
||||
import java.time.Duration;
|
||||
import java.time.temporal.ChronoUnit;
|
||||
|
||||
public final class WebUtils {
|
||||
|
||||
public static final String USER_AGENT;
|
||||
|
||||
private static HttpClient HTTP_CLIENT = null;
|
||||
|
||||
static {
|
||||
USER_AGENT = String.format("SkinRestorer/%d", System.currentTimeMillis() % 65535);
|
||||
}
|
||||
|
||||
private WebUtils() {}
|
||||
|
||||
public static void recreateHttpClient() {
|
||||
HTTP_CLIENT = WebUtils.buildClient();
|
||||
}
|
||||
|
||||
private static HttpClient buildClient() {
|
||||
var builder = HttpClient.newBuilder();
|
||||
|
||||
var proxy = SkinRestorer.getConfig().proxy();
|
||||
proxy.ifPresent(value -> builder.proxy(ProxySelector.of(InetSocketAddress.createUnresolved(value.host(), value.port()))));
|
||||
|
||||
try {
|
||||
builder.connectTimeout(Duration.of(SkinRestorer.getConfig().requestTimeout(), ChronoUnit.SECONDS));
|
||||
} catch (IllegalArgumentException e) {
|
||||
SkinRestorer.LOGGER.error("Failed to set request timeout", e);
|
||||
builder.connectTimeout(Duration.of(10, ChronoUnit.SECONDS));
|
||||
}
|
||||
|
||||
return builder.build();
|
||||
}
|
||||
|
||||
public static HttpResponse<String> executeRequest(HttpRequest request) throws IOException {
|
||||
try {
|
||||
var modifiedRequest = HttpRequest.newBuilder(request, (name, value) -> true)
|
||||
.header("User-Agent", WebUtils.USER_AGENT)
|
||||
.build();
|
||||
|
||||
final var response = WebUtils.HTTP_CLIENT.send(modifiedRequest, HttpResponse.BodyHandlers.ofString());
|
||||
|
||||
if (response.statusCode() >= 500)
|
||||
throw new IOException("server error " + response.statusCode());
|
||||
|
||||
return response;
|
||||
} catch (InterruptedException e) {
|
||||
Thread.currentThread().interrupt();
|
||||
throw new IOException(e);
|
||||
}
|
||||
}
|
||||
|
||||
public static void throwOnClientErrors(HttpResponse<?> response) {
|
||||
String message = switch (response.statusCode()) {
|
||||
case 400 -> "bad request";
|
||||
case 401 -> "unauthorized";
|
||||
case 403 -> "forbidden";
|
||||
case 404 -> "not found";
|
||||
case 405 -> "method not allowed";
|
||||
case 408 -> "request timeout";
|
||||
case 429 -> "too many requests";
|
||||
default -> null;
|
||||
};
|
||||
|
||||
if (message != null)
|
||||
throw new IllegalStateException(message);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
package net.lionarius.skinrestorer.util.gson;
|
||||
|
||||
public interface GsonPostProcessable {
|
||||
void gsonPostProcess();
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
package net.lionarius.skinrestorer.util.gson;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.TypeAdapter;
|
||||
import com.google.gson.TypeAdapterFactory;
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
import com.google.gson.stream.JsonReader;
|
||||
import com.google.gson.stream.JsonWriter;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
public class PostProcessingEnabler implements TypeAdapterFactory {
|
||||
@Override
|
||||
public <T> TypeAdapter<T> create(Gson gson, TypeToken<T> type) {
|
||||
var adapter = gson.getDelegateAdapter(this, type);
|
||||
|
||||
return new TypeAdapter<>() {
|
||||
@Override
|
||||
public void write(JsonWriter out, T value) throws IOException {
|
||||
adapter.write(out, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public T read(JsonReader in) throws IOException {
|
||||
var value = adapter.read(in);
|
||||
|
||||
if (value instanceof GsonPostProcessable postProcessable)
|
||||
postProcessable.gsonPostProcess();
|
||||
|
||||
return value;
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
1
common/src/main/resources/META-INF/accesstransformer.cfg
Normal file
1
common/src/main/resources/META-INF/accesstransformer.cfg
Normal file
@@ -0,0 +1 @@
|
||||
public net.minecraft.server.players.GameProfileCache$GameProfileInfo
|
||||
BIN
common/src/main/resources/assets/skinrestorer/icon.png
Normal file
BIN
common/src/main/resources/assets/skinrestorer/icon.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 12 KiB |
@@ -0,0 +1,8 @@
|
||||
{
|
||||
"skinrestorer.command.skin.affected_players": "Změny skinu použity pro %s",
|
||||
"skinrestorer.command.skin.no_changes": "Žádné změny skinu",
|
||||
"skinrestorer.command.skin.failed": "Nepodařilo se změnit skin: %s",
|
||||
"skinrestorer.command.skin.ok": "Skin změněn",
|
||||
"skinrestorer.command.skin.loading": "Načítání skinu...",
|
||||
"skinrestorer.command.skin.config_reloaded": "Konfigurace byla znovu načtena"
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
{
|
||||
"skinrestorer.command.skin.affected_players": "Skin änderungen für %s angewendet",
|
||||
"skinrestorer.command.skin.no_changes": "Keine Skinänderungen",
|
||||
"skinrestorer.command.skin.failed": "Skin konnte nicht geändert werden: %s",
|
||||
"skinrestorer.command.skin.ok": "Skin geändert",
|
||||
"skinrestorer.command.skin.loading": "Skin wird geladen...",
|
||||
"skinrestorer.command.skin.config_reloaded": "Konfiguration wurde neu geladen"
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
{
|
||||
"skinrestorer.command.skin.affected_players": "Applied skin changes for %s",
|
||||
"skinrestorer.command.skin.no_changes": "No skin changes",
|
||||
"skinrestorer.command.skin.failed": "Failed to change skin: %s",
|
||||
"skinrestorer.command.skin.ok": "Skin changed",
|
||||
"skinrestorer.command.skin.loading": "Loading skin...",
|
||||
"skinrestorer.command.skin.config_reloaded": "Config has been reloaded"
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
{
|
||||
"skinrestorer.command.skin.affected_players": "Cambios de skin aplicados para %s",
|
||||
"skinrestorer.command.skin.no_changes": "No hay cambios de skin",
|
||||
"skinrestorer.command.skin.failed": "Error al cambiar el skin: %s",
|
||||
"skinrestorer.command.skin.ok": "Skin cambiado",
|
||||
"skinrestorer.command.skin.loading": "Cargando skin...",
|
||||
"skinrestorer.command.skin.config_reloaded": "La configuración se ha recargado"
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
{
|
||||
"skinrestorer.command.skin.affected_players": "Cambios de skin aplicados para %s",
|
||||
"skinrestorer.command.skin.no_changes": "No hay cambios de skin",
|
||||
"skinrestorer.command.skin.failed": "Error al cambiar el skin: %s",
|
||||
"skinrestorer.command.skin.ok": "Skin cambiado",
|
||||
"skinrestorer.command.skin.loading": "Cargando skin...",
|
||||
"skinrestorer.command.skin.config_reloaded": "La configuración se ha recargado"
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
{
|
||||
"skinrestorer.command.skin.affected_players": "Cambios de skin aplicados para %s",
|
||||
"skinrestorer.command.skin.no_changes": "No hay cambios de skin",
|
||||
"skinrestorer.command.skin.failed": "Error al cambiar el skin: %s",
|
||||
"skinrestorer.command.skin.ok": "Skin cambiado",
|
||||
"skinrestorer.command.skin.loading": "Cargando skin...",
|
||||
"skinrestorer.command.skin.config_reloaded": "La configuración se ha recargado"
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
{
|
||||
"skinrestorer.command.skin.affected_players": "Na-apply ang pagbabago ng skin para kay %s",
|
||||
"skinrestorer.command.skin.no_changes": "Walang pagbabago sa skin",
|
||||
"skinrestorer.command.skin.failed": "Nabigo sa pagbabago ng skin: %s",
|
||||
"skinrestorer.command.skin.ok": "Nabago ang skin",
|
||||
"skinrestorer.command.skin.loading": "Naglo-load ng skin...",
|
||||
"skinrestorer.command.skin.config_reloaded": "Na-reload ang config"
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
{
|
||||
"skinrestorer.command.skin.affected_players": "Modifications de skin appliquées pour %s",
|
||||
"skinrestorer.command.skin.no_changes": "Aucun changement de skin",
|
||||
"skinrestorer.command.skin.failed": "Échec du changement de skin : %s",
|
||||
"skinrestorer.command.skin.ok": "Skin changé",
|
||||
"skinrestorer.command.skin.loading": "Chargement du skin...",
|
||||
"skinrestorer.command.skin.config_reloaded": "La configuration a été rechargée"
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
{
|
||||
"skinrestorer.command.skin.affected_players": "Modifications de skin appliquées pour %s",
|
||||
"skinrestorer.command.skin.no_changes": "Aucun changement de skin",
|
||||
"skinrestorer.command.skin.failed": "Échec du changement de skin : %s",
|
||||
"skinrestorer.command.skin.ok": "Skin changé",
|
||||
"skinrestorer.command.skin.loading": "Chargement du skin...",
|
||||
"skinrestorer.command.skin.config_reloaded": "La configuration a été rechargée"
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
{
|
||||
"skinrestorer.command.skin.affected_players": "त्वचा परिवर्तन %s के लिए लागू किए गए",
|
||||
"skinrestorer.command.skin.no_changes": "कोई त्वचा परिवर्तन नहीं",
|
||||
"skinrestorer.command.skin.failed": "त्वचा बदलने में विफल: %s",
|
||||
"skinrestorer.command.skin.ok": "त्वचा बदल दी गई",
|
||||
"skinrestorer.command.skin.loading": "त्वचा लोड हो रही है...",
|
||||
"skinrestorer.command.skin.config_reloaded": "कॉन्फ़िगरेशन फिर से लोड किया गया है"
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
{
|
||||
"skinrestorer.command.skin.affected_players": "Skin változások alkalmazva: %s",
|
||||
"skinrestorer.command.skin.no_changes": "Nincsenek skin változások",
|
||||
"skinrestorer.command.skin.failed": "Skin változtatás sikertelen: %s",
|
||||
"skinrestorer.command.skin.ok": "Skin megváltoztatva",
|
||||
"skinrestorer.command.skin.loading": "Skin betöltése...",
|
||||
"skinrestorer.command.skin.config_reloaded": "A konfiguráció újratöltve"
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
{
|
||||
"skinrestorer.command.skin.affected_players": "Perubahan skin diterapkan untuk %s",
|
||||
"skinrestorer.command.skin.no_changes": "Tidak ada perubahan skin",
|
||||
"skinrestorer.command.skin.failed": "Gagal mengubah skin: %s",
|
||||
"skinrestorer.command.skin.ok": "Skin diubah",
|
||||
"skinrestorer.command.skin.loading": "Memuat skin...",
|
||||
"skinrestorer.command.skin.config_reloaded": "Konfigurasi telah dimuat ulang"
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
{
|
||||
"skinrestorer.command.skin.affected_players": "Modifiche della skin applicate per %s",
|
||||
"skinrestorer.command.skin.no_changes": "Nessuna modifica alla skin",
|
||||
"skinrestorer.command.skin.failed": "Impossibile cambiare la skin: %s",
|
||||
"skinrestorer.command.skin.ok": "Skin cambiata",
|
||||
"skinrestorer.command.skin.loading": "Caricamento della skin...",
|
||||
"skinrestorer.command.skin.config_reloaded": "La configurazione è stata ricaricata"
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
{
|
||||
"skinrestorer.command.skin.affected_players": "Zastosowano zmiany skina dla %s",
|
||||
"skinrestorer.command.skin.no_changes": "Brak zmian skina",
|
||||
"skinrestorer.command.skin.failed": "Nie udało się zmienić skina: %s",
|
||||
"skinrestorer.command.skin.ok": "Skin zmieniony",
|
||||
"skinrestorer.command.skin.loading": "Ładowanie skina...",
|
||||
"skinrestorer.command.skin.config_reloaded": "Konfiguracja została przeładowana"
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
{
|
||||
"skinrestorer.command.skin.affected_players": "Alterações de skin aplicadas para %s",
|
||||
"skinrestorer.command.skin.no_changes": "Nenhuma alteração de skin",
|
||||
"skinrestorer.command.skin.failed": "Falha ao alterar a skin: %s",
|
||||
"skinrestorer.command.skin.ok": "Skin alterada",
|
||||
"skinrestorer.command.skin.loading": "Carregando skin...",
|
||||
"skinrestorer.command.skin.config_reloaded": "Configuração recarregada"
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
{
|
||||
"skinrestorer.command.skin.affected_players": "Alterações de skin aplicadas para %s",
|
||||
"skinrestorer.command.skin.no_changes": "Nenhuma alteração de skin",
|
||||
"skinrestorer.command.skin.failed": "Falha ao alterar a skin: %s",
|
||||
"skinrestorer.command.skin.ok": "Skin alterada",
|
||||
"skinrestorer.command.skin.loading": "Carregando skin...",
|
||||
"skinrestorer.command.skin.config_reloaded": "Configuração recarregada"
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
{
|
||||
"skinrestorer.command.skin.affected_players": "Применены изменения скина для %s",
|
||||
"skinrestorer.command.skin.no_changes": "Изменений скина нет",
|
||||
"skinrestorer.command.skin.failed": "Не удалось изменить скин: %s",
|
||||
"skinrestorer.command.skin.ok": "Скин изменён",
|
||||
"skinrestorer.command.skin.loading": "Загрузка скина...",
|
||||
"skinrestorer.command.skin.config_reloaded": "Конфигурация была перезагружена"
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
{
|
||||
"skinrestorer.command.skin.affected_players": "%s için skin değişiklikleri uygulandı",
|
||||
"skinrestorer.command.skin.no_changes": "Skin değişikliği yok",
|
||||
"skinrestorer.command.skin.failed": "Skin değiştirme başarısız: %s",
|
||||
"skinrestorer.command.skin.ok": "Skin değiştirildi",
|
||||
"skinrestorer.command.skin.loading": "Skin yükleniyor...",
|
||||
"skinrestorer.command.skin.config_reloaded": "Yapılandırma yeniden yüklendi"
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
{
|
||||
"skinrestorer.command.skin.affected_players": "Зміни скіна застосовані для %s",
|
||||
"skinrestorer.command.skin.no_changes": "Змін скіна немає",
|
||||
"skinrestorer.command.skin.failed": "Не вдалося змінити скіна: %s",
|
||||
"skinrestorer.command.skin.ok": "Скін змінено",
|
||||
"skinrestorer.command.skin.loading": "Завантаження скіна...",
|
||||
"skinrestorer.command.skin.config_reloaded": "Конфігурацію перезавантажено"
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
{
|
||||
"skinrestorer.command.skin.affected_players": "Áp dụng thay đổi skin cho %s",
|
||||
"skinrestorer.command.skin.no_changes": "Không có thay đổi skin",
|
||||
"skinrestorer.command.skin.failed": "Thay đổi skin thất bại: %s",
|
||||
"skinrestorer.command.skin.ok": "Đã thay đổi skin",
|
||||
"skinrestorer.command.skin.loading": "Đang tải skin...",
|
||||
"skinrestorer.command.skin.config_reloaded": "Cấu hình đã được tải lại"
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
{
|
||||
"skinrestorer.command.skin.affected_players": "应用的皮肤更改 %s",
|
||||
"skinrestorer.command.skin.no_changes": "没有皮肤更改",
|
||||
"skinrestorer.command.skin.failed": "更改皮肤失败:%s",
|
||||
"skinrestorer.command.skin.ok": "皮肤已更改",
|
||||
"skinrestorer.command.skin.loading": "正在加载皮肤...",
|
||||
"skinrestorer.command.skin.config_reloaded": "配置已重新加载"
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
{
|
||||
"skinrestorer.command.skin.affected_players": "已變更 %s 的外觀",
|
||||
"skinrestorer.command.skin.no_changes": "沒有外觀變更",
|
||||
"skinrestorer.command.skin.failed": "變更外觀失敗:%s",
|
||||
"skinrestorer.command.skin.ok": "已變更外觀",
|
||||
"skinrestorer.command.skin.loading": "正在載入外觀...",
|
||||
"skinrestorer.command.skin.config_reloaded": "配置已重新載入"
|
||||
}
|
||||
6
common/src/main/resources/pack.mcmeta
Normal file
6
common/src/main/resources/pack.mcmeta
Normal file
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"pack": {
|
||||
"description": "${mod_id}",
|
||||
"pack_format": 8
|
||||
}
|
||||
}
|
||||
3
common/src/main/resources/skinrestorer.accesswidener
Normal file
3
common/src/main/resources/skinrestorer.accesswidener
Normal file
@@ -0,0 +1,3 @@
|
||||
accessWidener v2 named
|
||||
|
||||
accessible class net/minecraft/server/players/GameProfileCache$GameProfileInfo
|
||||
19
common/src/main/resources/skinrestorer.mixins.json
Normal file
19
common/src/main/resources/skinrestorer.mixins.json
Normal file
@@ -0,0 +1,19 @@
|
||||
{
|
||||
"required": true,
|
||||
"minVersion": "0.8",
|
||||
"package": "net.lionarius.skinrestorer.mixin",
|
||||
"compatibilityLevel": "JAVA_17",
|
||||
"priority": 1100,
|
||||
"refmap": "${mod_id}.refmap.json",
|
||||
"mixins": [
|
||||
"ChunkMapAccessor",
|
||||
"PlayerListMixin",
|
||||
"ServerLoginPacketListenerImplMixin",
|
||||
"TrackedEntityAccessorInvoker",
|
||||
"SkullBlockEntityMixin",
|
||||
"GameProfileCacheAccessor"
|
||||
],
|
||||
"injectors": {
|
||||
"defaultRequire": 1
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user