mirror of
https://github.com/TotalFreedomMC/TF-LibsDisguises.git
synced 2024-05-29 07:41:19 +00:00
Compare commits
701 commits
Author | SHA1 | Date | |
---|---|---|---|
62fb33547f | |||
cc86e130ea | |||
1b33b03c90 | |||
e9c3d3670f | |||
da078f026a | |||
b50c6c07df | |||
cfc1eb27b9 | |||
7137f04853 | |||
0a8b28ca54 | |||
55c92e60df | |||
56eaa1c8c4 | |||
5635c05843 | |||
1bd07cc848 | |||
4aaaa85f33 | |||
262723358a | |||
ee8e459d3a | |||
f082150144 | |||
047baa3632 | |||
f6a07c1098 | |||
082ea9716d | |||
37235f8eff | |||
d5bbdbcb05 | |||
d24c85790c | |||
7c6a70d540 | |||
e3ed78736c | |||
2a5caa6e30 | |||
1e88cc7b32 | |||
4c74493464 | |||
0ecbc824dd | |||
fe67553bd8 | |||
07f4e766c1 | |||
cd5df563de | |||
c0ac00c9b7 | |||
5cbf9f6ba2 | |||
7e7c743280 | |||
c5d8a5ed35 | |||
832084cc3b | |||
c49004aa82 | |||
46af2cd1c6 | |||
a84bbe3991 | |||
074f761b86 | |||
d69b920ec7 | |||
0411e4bcc6 | |||
91147ed761 | |||
1ffe9c3d12 | |||
3c650ffac2 | |||
53b7e29171 | |||
c2a26dacc2 | |||
1c05d3d2cd | |||
6f97aa219d | |||
06f0a41f07 | |||
dd538b6c4c | |||
e28251360b | |||
aba1e9d304 | |||
8d75a07f52 | |||
bc277fe2f0 | |||
d4a18b3c11 | |||
8644aaacd1 | |||
0ce85946a0 | |||
49fe9d51f0 | |||
145c1057c3 | |||
be3c1536a9 | |||
e0bbcbd43e | |||
7c0eb550e7 | |||
7916039fb2 | |||
ebd515e7df | |||
a53c8ffb79 | |||
88d9b081fa | |||
7dffc92365 | |||
e4e3cc3f17 | |||
15bc39d49f | |||
1a800f7ae3 | |||
18081cf1ba | |||
78e403f684 | |||
2618017656 | |||
71bffc7bf7 | |||
69a5628f76 | |||
95b3d9f231 | |||
b5fb5054a2 | |||
0ec2dab889 | |||
79d7533260 | |||
cc69218b91 | |||
5e165e3c97 | |||
61e021e463 | |||
0e125523f4 | |||
102c7f3a6a | |||
9a9c1d9a62 | |||
62740980a5 | |||
4221695f67 | |||
a675f33071 | |||
7599fce5bb | |||
e0e622d5f4 | |||
7fe95f00ec | |||
771a827e33 | |||
3d7be88524 | |||
e6d40d95eb | |||
3a10606fb7 | |||
36f410c1ce | |||
ff2b2702e0 | |||
9d0a61dabd | |||
dd439a78aa | |||
52cb313f77 | |||
42cd210fc7 | |||
40ec806b28 | |||
9f6b2fb535 | |||
bcd4ed56fc | |||
6b414adfe8 | |||
92b741ce0a | |||
08000bda0d | |||
49cebe2a31 | |||
0e0be185dc | |||
dbe9073f33 | |||
8f398d798a | |||
05b1e517e5 | |||
70b2fa76e3 | |||
7d79130169 | |||
41705e8123 | |||
8a10b83c0c | |||
e80e83f969 | |||
036eac42b8 | |||
89ebb84c99 | |||
bc9ebac4d5 | |||
e7b370733f | |||
90f23f92d3 | |||
743918aa2d | |||
62839b5358 | |||
0d97159010 | |||
344344979c | |||
38349a77ed | |||
b4f773c8d4 | |||
d58294d609 | |||
1e856091b9 | |||
df833cc4ca | |||
1c97612c9f | |||
a032155f5b | |||
fd9985f5d5 | |||
23a31ef7b4 | |||
7e099a985c | |||
27bff9e613 | |||
3595f859fe | |||
ffe78c8f37 | |||
d34d774307 | |||
0a7a2a5276 | |||
9a91b91966 | |||
0f84008abd | |||
efab07be75 | |||
588d03dc41 | |||
3b940fe530 | |||
d3d4df2d65 | |||
ae0aa70304 | |||
f1b7cbf444 | |||
d35f6cd5d4 | |||
3e6e4b3932 | |||
92eaa03b51 | |||
7b3046755c | |||
8bca0f037d | |||
7110e45798 | |||
0acf4f32f9 | |||
69f3494633 | |||
d20a8e5266 | |||
e1c410781a | |||
ffcf4fd282 | |||
fc97a5952b | |||
565a06731b | |||
8ff92e2760 | |||
99227518ac | |||
41187cd35d | |||
aa709c791d | |||
46b4b21feb | |||
8007cdd706 | |||
b83bc0605c | |||
b9bd724502 | |||
0134788160 | |||
dfe4001102 | |||
a489b4865b | |||
9975737e0a | |||
95447a55af | |||
8ca5fd862a | |||
015f6936f9 | |||
65415a5796 | |||
68c8040cba | |||
052f49aa86 | |||
5c9b4c3245 | |||
4b940bcd20 | |||
2ff26d972c | |||
f4d19ab3ce | |||
06dc0baafe | |||
82d17f8b70 | |||
d94ed9b53a | |||
1ffe1f7c0f | |||
60ff44e8b1 | |||
bba628a511 | |||
7df05e4647 | |||
217a753343 | |||
5eaf7faa1b | |||
c1afce7378 | |||
7e21f20120 | |||
c7edea1c5e | |||
70682a68bc | |||
4eb8ef2443 | |||
17b652fcc0 | |||
6c17603905 | |||
afe4022920 | |||
cffa7591d9 | |||
a14cb9aadd | |||
3ac88ba078 | |||
14d6fc7257 | |||
5ab0e4a45c | |||
fe166bdbea | |||
4ffdc9a74d | |||
676185481e | |||
a1226abb81 | |||
e6a6ac749e | |||
ea48d98c2a | |||
d525d03383 | |||
6ab9e8f54f | |||
5a340341b0 | |||
d525f8edcb | |||
6e69ae6fe2 | |||
6546dd256e | |||
60d4283715 | |||
3fd732c049 | |||
fffea76e8d | |||
381ab971b6 | |||
d0ce9c0536 | |||
cafc9f22d6 | |||
8f7b21314b | |||
e5aab88cb6 | |||
634628383a | |||
9cd0455292 | |||
9593225f8e | |||
43aa37a9ec | |||
4bc046f4e3 | |||
239499f2d9 | |||
873f8a5c0a | |||
88f12052b5 | |||
d2de8b2d6a | |||
066cead6c8 | |||
c8783a6efa | |||
4e22d92b5e | |||
bde28a6521 | |||
20a017e686 | |||
84d95b5b2b | |||
c49e2e6636 | |||
afb2f733b0 | |||
3fc8bf30bb | |||
c1ede49a8e | |||
15fd2c3d46 | |||
3370a1353d | |||
08deb7ee30 | |||
54b9490604 | |||
135b0fdeaa | |||
aa51a5fbe4 | |||
caa25296be | |||
796ae26ed7 | |||
7935f65564 | |||
2fe8d46c61 | |||
f22b4e65c7 | |||
42f04766b1 | |||
8641115c75 | |||
74af3acfc3 | |||
dd4556824a | |||
2902de50c2 | |||
1c2ea6a54d | |||
be38046052 | |||
e91c022d92 | |||
84f32a70fa | |||
407d00af1c | |||
bf44577e17 | |||
caac46d60b | |||
d38d4ad1be | |||
f0448e6afc | |||
269363753c | |||
2568bfe53e | |||
60b79ae789 | |||
5205c8055c | |||
55a459e440 | |||
4ea5c87645 | |||
9604e151f5 | |||
e267d1d344 | |||
d306ab0d85 | |||
98b6aa0185 | |||
1eb5225389 | |||
1e68eeb74d | |||
c3783b9bf0 | |||
8fad4a5b46 | |||
d4abde2542 | |||
c8bd25ba57 | |||
44ab504509 | |||
11e7e1238c | |||
807a163256 | |||
3fb325b0e1 | |||
01cf995914 | |||
c1eb650b4a | |||
c1db0a9fa4 | |||
59178a63fd | |||
ad1b687f07 | |||
5b59ad98d5 | |||
ee2224e68f | |||
dfda600445 | |||
9042cb4212 | |||
bca3483e49 | |||
fc6c70c543 | |||
b8a51d748b | |||
4528624283 | |||
8ff6686b1e | |||
6eaa42c1bb | |||
90e04ebe32 | |||
5d98ffc205 | |||
914a17ba20 | |||
77fa52701f | |||
ce5b374da3 | |||
93fdb30227 | |||
35ad450bc3 | |||
4611f8880d | |||
b93972c1c2 | |||
3582d1ffed | |||
0228b3ecac | |||
cffce30a5d | |||
3aef445341 | |||
b1521ce9ac | |||
f65911f258 | |||
3d6855944f | |||
414d5a94e8 | |||
449124f4da | |||
c05b8f8e02 | |||
1790032f75 | |||
ef4539a3a1 | |||
808b618ecf | |||
ccff8bc6dc | |||
25f6ac8b1e | |||
38117d9f59 | |||
b3f8a7b24e | |||
76d3228b51 | |||
a06268adb4 | |||
075733fdea | |||
76e7151488 | |||
404974732f | |||
6301571350 | |||
9a1a6ae08e | |||
0d198a7086 | |||
14b712454b | |||
d6be1d76bd | |||
44f90e51ee | |||
6922bcd9e8 | |||
60ad887fef | |||
385dce292a | |||
68d19b9af9 | |||
c096027034 | |||
e1400b7edf | |||
0297b5c1b2 | |||
249b02aa85 | |||
ba9eba508b | |||
bd0ca9ec8c | |||
7ab4a31c1f | |||
a45f7a8076 | |||
87e3defcab | |||
6c2cd6ac7a | |||
4c7ba6a9ad | |||
1c85ba7586 | |||
bd732d256d | |||
c410de4f9a | |||
438e9cffd9 | |||
b872ddc137 | |||
f87a756aa0 | |||
17f6b62fd6 | |||
8d85d5b256 | |||
70d3a2050b | |||
ead8daca4e | |||
5e81e6bbe3 | |||
11785d1842 | |||
8c763e1b5b | |||
3701bac016 | |||
9067aa8259 | |||
b63c9d20d5 | |||
0d558d79be | |||
348ef9e25d | |||
02a3602a28 | |||
72180cc15a | |||
4f2d54b844 | |||
65d80b71f2 | |||
999c5f3f21 | |||
350a3aa9b5 | |||
a286773c04 | |||
bebadf9bc8 | |||
7d2e59430d | |||
379ec6e93c | |||
3731c1be2e | |||
48297555f7 | |||
e6e43ee92c | |||
7b51417742 | |||
f8f8107673 | |||
49cd07ba45 | |||
53657f57ca | |||
d29bdb70fe | |||
eaf8424f75 | |||
6cc86f3630 | |||
07c5abec43 | |||
35719f8317 | |||
3734465e0b | |||
4adcc8aa53 | |||
06ac4f8ffc | |||
c3d6dd1b43 | |||
73d2d6b1a5 | |||
b3274cc88b | |||
68a2d31da7 | |||
298d2deeba | |||
b1253d31e7 | |||
84fe0d5bf8 | |||
249c64a7e5 | |||
7abb9dd99d | |||
66aa68649c | |||
dea23ecef6 | |||
b5e41f3144 | |||
d2decad8d5 | |||
f106ab9c19 | |||
00415c324a | |||
322deb3d47 | |||
251ca9b7e1 | |||
6f9b2dfd6d | |||
eb9eeca691 | |||
789d1b15c7 | |||
46f9d676f4 | |||
9bc6cb2789 | |||
f12d255ee0 | |||
c5ef3267ea | |||
3f7d824e73 | |||
8fbeb2a4f7 | |||
7e2c04a331 | |||
6e8afabda7 | |||
a1b1ecdbd2 | |||
9320aac40b | |||
df158c416e | |||
e2dae58034 | |||
7bdfde43e0 | |||
e881d0b98b | |||
08428fb9ab | |||
2bf0746824 | |||
2d14fb90b8 | |||
8aef2bffc0 | |||
c96a799e9f | |||
4a02bcf026 | |||
ca17028aef | |||
f84ced34f6 | |||
a896721754 | |||
e6cf577db0 | |||
fd9c4cdad7 | |||
f3390be91e | |||
b5f2a55a43 | |||
9e43d7ff25 | |||
e25279f8cb | |||
e81b42b0ff | |||
9489d794d4 | |||
6530408282 | |||
32b5700562 | |||
4ef142b098 | |||
a9bec1ef93 | |||
48f01cf2fe | |||
f7c2d18937 | |||
972633876e | |||
ac35cb64b6 | |||
c0ff4960aa | |||
331133f1a1 | |||
a39ca29aef | |||
bae41272dd | |||
c7d54fa701 | |||
2a1246ac98 | |||
61775bdf88 | |||
20d8a42363 | |||
a20d0fbaed | |||
d1181ed58f | |||
50c33aec8f | |||
8cc34c60a5 | |||
f79b244942 | |||
107021a572 | |||
76f3383c16 | |||
0213f7f034 | |||
7f50acf061 | |||
5019cb985b | |||
4e7098e462 | |||
5f2fb5fc54 | |||
f229b25c71 | |||
687f47e22e | |||
6505d7530f | |||
1795e03e31 | |||
1ed3a149ea | |||
be34a2c84a | |||
dff3e23821 | |||
b568b647e2 | |||
bea34b18c2 | |||
b7251ac111 | |||
e731323110 | |||
3d0c209cf7 | |||
67a873b37f | |||
166658b99b | |||
02171b60b6 | |||
96f53a1270 | |||
d063da9951 | |||
a92c8fb55e | |||
0a3bda1a8e | |||
5eacebc3ec | |||
6d559b1887 | |||
2e22dad323 | |||
ae34cb33b6 | |||
a66b41e4f5 | |||
ac574bc51c | |||
ac2d3d8325 | |||
f3d1081ccb | |||
0cd7806d21 | |||
e67115106d | |||
b9490e8344 | |||
d73d3f006b | |||
6de077882c | |||
ebb6d2030d | |||
c295011015 | |||
4ff00ee828 | |||
412370c43d | |||
c1a8001b54 | |||
45d42b1c6b | |||
4b9328993b | |||
596bb0bff7 | |||
3a5f8545dc | |||
090ce6e8c5 | |||
33e803134b | |||
865326eda7 | |||
d12fd8e454 | |||
14cf777cab | |||
b769569d5a | |||
ff7b637f76 | |||
6e4ceb37a9 | |||
1ae6a31c57 | |||
4f0be27f0a | |||
5f09d6d910 | |||
33b7a5e8c8 | |||
86a757626b | |||
5435df78de | |||
6b24bfa858 | |||
a0b5b065f0 | |||
031666546c | |||
4d0fe01bb7 | |||
c9a3c125a5 | |||
3591c3bcf8 | |||
17a2733a74 | |||
e22ba6565f | |||
249304cced | |||
0624538774 | |||
c8e08e91ff | |||
bb009be826 | |||
618ba16fb2 | |||
cb5aec155a | |||
325d056ba6 | |||
28ef060c1a | |||
acf11ee00f | |||
11f0546fbe | |||
9b7b232fbe | |||
93936c3628 | |||
15b4a6e935 | |||
80b510f5b6 | |||
7a3f764581 | |||
f67500b7be | |||
d751a15c6a | |||
c1ce255bce | |||
325e73d059 | |||
f530af0ae8 | |||
deb3fd243b | |||
4f0290218b | |||
f322a80b69 | |||
bb212c6c26 | |||
8144f16182 | |||
50022ee13a | |||
2efda17935 | |||
144f762a0a | |||
baed87bc78 | |||
9166120071 | |||
695633e876 | |||
8b4a7a59c0 | |||
e5304f19e2 | |||
9ffbd9e272 | |||
9fb920cbdc | |||
25c6bec655 | |||
e53b31b871 | |||
09557d5a94 | |||
6dd16a545e | |||
5397210b56 | |||
ca3b348136 | |||
788bc7bc3b | |||
4b49b147e3 | |||
2ad5d0ff4d | |||
bd214728cd | |||
4b40a67b00 | |||
8cfa9e3daa | |||
440a5e99fa | |||
e73992b8ed | |||
ea50632925 | |||
036f298003 | |||
e1f9183a37 | |||
d82f8ac046 | |||
862d186f36 | |||
35c1882164 | |||
976357aa28 | |||
4887491f10 | |||
39489d0080 | |||
99bbf66921 | |||
525e47d24e | |||
0cfa32159a | |||
67a86ddcdd | |||
45331de38c | |||
3d4329942c | |||
5a05dffdce | |||
bfb496141e | |||
c132ae3cad | |||
48b15499df | |||
ce884cc8ac | |||
6e456e4702 | |||
1ce0a9a612 | |||
ca520c819e | |||
6565fc5f4f | |||
1a256855e2 | |||
54efb582b1 | |||
dd05e3e411 | |||
8a59d64702 | |||
b5b9b432f7 | |||
e74df537bb | |||
3ced8ae9e4 | |||
13fedc4437 | |||
7ef248c054 | |||
9cde4702f6 | |||
88b7851df8 | |||
30cc40a6a3 | |||
8e2645501b | |||
bf12201452 | |||
78b19d5596 | |||
b4de52a9db | |||
e3300e7ef9 | |||
f3d5f7efc3 | |||
31672fce7b | |||
ffd6536565 | |||
5f2ac293bf | |||
6fbdcc9855 | |||
472649cad7 | |||
c5ee5f1fbd | |||
1f847e5ad6 | |||
cd64d17a01 | |||
0777947173 | |||
281d94fbb9 | |||
68d3ccc7f7 | |||
407975f41f | |||
3ebf9cce65 | |||
e317f676b3 | |||
9cf9c85fed | |||
c3fc37182e | |||
b501147b63 | |||
c01213da99 | |||
1277a82dd4 | |||
ea3380754b | |||
4fa20a0367 | |||
53051668af | |||
a81b3b1d5f | |||
6f3d4d8300 | |||
1a659f8b09 | |||
3a85aa29a0 | |||
cd4ecb2974 | |||
948e516505 | |||
acf5696fa9 | |||
f12c1192e1 | |||
a19b9e4023 | |||
aa913b48e6 | |||
32bab36731 | |||
e12222ca26 | |||
473293463d | |||
142f1c277e | |||
e696ee3f4f | |||
929f705d0e | |||
c4717d7453 | |||
8bb9051e59 | |||
9eebcc7afd | |||
a9ce0b0ee7 | |||
2d53fdadd0 | |||
ece93e7145 | |||
9094e66dfb | |||
c865500e9f | |||
9d417e3485 | |||
b1d43dac61 | |||
f5ebc0b337 | |||
3b34fdf28c | |||
7c7b770801 | |||
84f48b0346 | |||
17a53e22e4 | |||
e59e89ad52 | |||
ca33fdb81a | |||
e853d02c7e | |||
6de71e4fd3 | |||
860a6e4a03 | |||
dcbcbc79f4 | |||
567f278131 | |||
37e7a0bac7 | |||
e77a28c258 | |||
08bee8afd8 | |||
cb433458f4 | |||
2596813e45 | |||
57a4507de9 |
3
.gitignore
vendored
Normal file
3
.gitignore
vendored
Normal file
|
@ -0,0 +1,3 @@
|
|||
*.iml
|
||||
.idea/
|
||||
target/
|
|
@ -11,7 +11,7 @@ There are a few features which you need to pay for, but none of it is needed to
|
|||
|
||||
|
||||
Spigot page: <a href="https://www.spigotmc.org/resources/32453/">Link</a>
|
||||
|
||||
Jenkins Downloads: <a href="https://ci.md-5.net/job/LibsDisguises/">Link</a>
|
||||
|
||||
NOTE: These versions will NOT work with older versions of Minecraft. There is no support for older versions of this plugin.
|
||||
|
||||
|
|
192
dependency-reduced-pom.xml
Normal file
192
dependency-reduced-pom.xml
Normal file
|
@ -0,0 +1,192 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>LibsDisguises</groupId>
|
||||
<artifactId>LibsDisguises</artifactId>
|
||||
<version>10.0.26-SNAPSHOT</version>
|
||||
<build>
|
||||
<defaultGoal>exec:java clean install</defaultGoal>
|
||||
<resources>
|
||||
<resource>
|
||||
<filtering>true</filtering>
|
||||
<directory>src/main/resources</directory>
|
||||
<includes>
|
||||
<include>plugin.yml</include>
|
||||
</includes>
|
||||
</resource>
|
||||
<resource>
|
||||
<directory>src/main/resources</directory>
|
||||
<includes>
|
||||
<include>**/*</include>
|
||||
</includes>
|
||||
</resource>
|
||||
<resource>
|
||||
<directory>${project.basedir}</directory>
|
||||
<includes>
|
||||
<include>README.md</include>
|
||||
</includes>
|
||||
</resource>
|
||||
</resources>
|
||||
<finalName>LibsDisguises</finalName>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<artifactId>maven-surefire-plugin</artifactId>
|
||||
<version>3.0.0-M1</version>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.codehaus.mojo</groupId>
|
||||
<artifactId>exec-maven-plugin</artifactId>
|
||||
<version>1.6.0</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>my-execution</id>
|
||||
<phase>compile</phase>
|
||||
<goals>
|
||||
<goal>java</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
<configuration>
|
||||
<includePluginDependencies>true</includePluginDependencies>
|
||||
<mainClass>me.libraryaddict.disguise.utilities.watchers.CompileMethods</mainClass>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<artifactId>maven-shade-plugin</artifactId>
|
||||
<version>3.2.4</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>shade</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
<configuration>
|
||||
<minimizeJar>true</minimizeJar>
|
||||
<artifactSet>
|
||||
<includes>
|
||||
<include>net.kyori:*</include>
|
||||
</includes>
|
||||
</artifactSet>
|
||||
<relocations>
|
||||
<relocation>
|
||||
<pattern>net.kyori</pattern>
|
||||
<shadedPattern>ld-shaded.net.kyori</shadedPattern>
|
||||
</relocation>
|
||||
</relocations>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>md_5-releases</id>
|
||||
<url>https://repo.md-5.net/content/groups/public/</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>spigot-repo</id>
|
||||
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>papermc</id>
|
||||
<url>https://papermc.io/repo/repository/maven-public/</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>dmulloy2-repo</id>
|
||||
<url>https://repo.dmulloy2.net/nexus/repository/public/</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.ow2.asm</groupId>
|
||||
<artifactId>asm</artifactId>
|
||||
<version>9.0</version>
|
||||
<scope>compile</scope>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
<version>1.18.16</version>
|
||||
<scope>compile</scope>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.comphenix.protocol</groupId>
|
||||
<artifactId>ProtocolLib</artifactId>
|
||||
<version>4.7.0</version>
|
||||
<scope>compile</scope>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.spigotmc</groupId>
|
||||
<artifactId>spigot-api</artifactId>
|
||||
<version>[1.17,]</version>
|
||||
<scope>compile</scope>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.spigotmc</groupId>
|
||||
<artifactId>spigot</artifactId>
|
||||
<version>[1.17,]</version>
|
||||
<scope>compile</scope>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
<version>4.13.1</version>
|
||||
<scope>test</scope>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<artifactId>hamcrest-core</artifactId>
|
||||
<groupId>org.hamcrest</groupId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.destroystokyo.paper</groupId>
|
||||
<artifactId>paper-api</artifactId>
|
||||
<version>[1.16,]</version>
|
||||
<scope>provided</scope>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>net.md-5</groupId>
|
||||
<artifactId>bungeecord-chat</artifactId>
|
||||
<version>1.12-SNAPSHOT</version>
|
||||
<scope>compile</scope>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<distributionManagement>
|
||||
<repository>
|
||||
<id>md_5-releases</id>
|
||||
<url>https://repo.md-5.net/content/repositories/releases/</url>
|
||||
</repository>
|
||||
<snapshotRepository>
|
||||
<id>md_5-snapshots</id>
|
||||
<url>https://repo.md-5.net/content/repositories/snapshots/</url>
|
||||
</snapshotRepository>
|
||||
</distributionManagement>
|
||||
<properties>
|
||||
<maven.build.timestamp.format>dd/MM/yyyy HH:mm</maven.build.timestamp.format>
|
||||
<lombok.version>1.18.16</lombok.version>
|
||||
<junit.version>4.13.1</junit.version>
|
||||
<adventure-minimessage.version>4.1.0-SNAPSHOT</adventure-minimessage.version>
|
||||
<asm.version>9.0</asm.version>
|
||||
<build.number>unknown</build.number>
|
||||
<maven.compiler.target>17</maven.compiler.target>
|
||||
<bungeecord-chat.version>1.12-SNAPSHOT</bungeecord-chat.version>
|
||||
<spigot.version>[1.17,]</spigot.version>
|
||||
<protocollib.version>4.7.0</protocollib.version>
|
||||
<timestamp>${maven.build.timestamp}</timestamp>
|
||||
<adventure-api.version>4.7.0</adventure-api.version>
|
||||
<paper-api.version>[1.16,]</paper-api.version>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<maven.compiler.source>17</maven.compiler.source>
|
||||
<adventure-serializer.version>4.7.0</adventure-serializer.version>
|
||||
</properties>
|
||||
</project>
|
21
nms/pom.xml
Normal file
21
nms/pom.xml
Normal file
|
@ -0,0 +1,21 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<artifactId>nms</artifactId>
|
||||
<packaging>pom</packaging>
|
||||
|
||||
<parent>
|
||||
<artifactId>parent</artifactId>
|
||||
<groupId>LibsDisguises</groupId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
<modules>
|
||||
<module>v1_17_R1</module>
|
||||
<module>v1_18_R1</module>
|
||||
<module>v1_18_R2</module>
|
||||
</modules>
|
||||
|
||||
</project>
|
89
nms/v1_17_R1/pom.xml
Normal file
89
nms/v1_17_R1/pom.xml
Normal file
|
@ -0,0 +1,89 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<parent>
|
||||
<artifactId>nms</artifactId>
|
||||
<groupId>LibsDisguises</groupId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<artifactId>v1_17_R1</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
|
||||
<properties>
|
||||
<maven.compiler.source>17</maven.compiler.source>
|
||||
<maven.compiler.target>17</maven.compiler.target>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
|
||||
<spigot.version>1.17.1-R0.1-SNAPSHOT</spigot.version>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.spigotmc</groupId>
|
||||
<artifactId>spigot</artifactId>
|
||||
<version>${spigot.version}</version>
|
||||
<classifier>remapped-mojang</classifier>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.spigotmc</groupId>
|
||||
<artifactId>spigot-api</artifactId>
|
||||
<version>${spigot.version}</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>LibsDisguises</groupId>
|
||||
<artifactId>shared</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.comphenix.protocol</groupId>
|
||||
<artifactId>ProtocolLib</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>net.md-5</groupId>
|
||||
<artifactId>specialsource-maven-plugin</artifactId>
|
||||
<version>1.2.4</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>remap</goal>
|
||||
</goals>
|
||||
<id>remap-obf</id>
|
||||
<configuration>
|
||||
<srgIn>org.spigotmc:minecraft-server:${spigot.version}:txt:maps-mojang</srgIn>
|
||||
<reverse>true</reverse>
|
||||
<remappedDependencies>org.spigotmc:spigot:${spigot.version}:jar:remapped-mojang</remappedDependencies>
|
||||
<remappedClassifierName>remapped-mojang</remappedClassifierName>
|
||||
<remappedArtifactAttached>true</remappedArtifactAttached>
|
||||
</configuration>
|
||||
</execution>
|
||||
<execution>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>remap</goal>
|
||||
</goals>
|
||||
<id>remap-spigot</id>
|
||||
<configuration>
|
||||
<inputFile>target/${project.build.finalName}-remapped-mojang.jar</inputFile>
|
||||
<srgIn>org.spigotmc:minecraft-server:${spigot.version}:csrg:maps-spigot</srgIn>
|
||||
<remappedDependencies>org.spigotmc:spigot:${spigot.version}:jar:remapped-obf</remappedDependencies>
|
||||
<remappedClassifierName>remapped-spigot</remappedClassifierName>
|
||||
<remappedArtifactAttached>true</remappedArtifactAttached>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</project>
|
|
@ -0,0 +1,466 @@
|
|||
package me.libraryaddict.disguise.utilities.reflection.v1_17;
|
||||
|
||||
import com.comphenix.protocol.wrappers.BlockPosition;
|
||||
import com.comphenix.protocol.wrappers.EnumWrappers.Direction;
|
||||
import com.comphenix.protocol.wrappers.Vector3F;
|
||||
import com.comphenix.protocol.wrappers.WrappedBlockData;
|
||||
import com.comphenix.protocol.wrappers.WrappedChatComponent;
|
||||
import com.comphenix.protocol.wrappers.WrappedDataWatcher;
|
||||
import com.comphenix.protocol.wrappers.WrappedGameProfile;
|
||||
import com.mojang.authlib.Agent;
|
||||
import com.mojang.authlib.GameProfile;
|
||||
import com.mojang.authlib.ProfileLookupCallback;
|
||||
import com.mojang.authlib.minecraft.MinecraftSessionService;
|
||||
import me.libraryaddict.disguise.utilities.reflection.ReflectionManagerAbstract;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Registry;
|
||||
import net.minecraft.core.Vector3f;
|
||||
import net.minecraft.network.chat.TextComponent;
|
||||
import net.minecraft.network.protocol.game.ClientboundPlayerInfoPacket;
|
||||
import net.minecraft.network.syncher.EntityDataAccessor;
|
||||
import net.minecraft.network.syncher.SynchedEntityData;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.server.dedicated.DedicatedServer;
|
||||
import net.minecraft.server.level.ChunkMap;
|
||||
import net.minecraft.server.level.ServerChunkCache;
|
||||
import net.minecraft.server.level.ServerEntity;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.server.network.ServerGamePacketListenerImpl;
|
||||
import net.minecraft.server.network.ServerPlayerConnection;
|
||||
import net.minecraft.sounds.SoundEvent;
|
||||
import net.minecraft.sounds.SoundSource;
|
||||
import net.minecraft.world.damagesource.DamageSource;
|
||||
import net.minecraft.world.effect.MobEffect;
|
||||
import net.minecraft.world.effect.MobEffectInstance;
|
||||
import net.minecraft.world.entity.EntityDimensions;
|
||||
import net.minecraft.world.entity.LivingEntity;
|
||||
import net.minecraft.world.entity.npc.VillagerData;
|
||||
import net.minecraft.world.entity.npc.VillagerProfession;
|
||||
import net.minecraft.world.entity.npc.VillagerType;
|
||||
import net.minecraft.world.level.GameType;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.phys.AABB;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
import org.bukkit.Art;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.NamespacedKey;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.data.BlockData;
|
||||
import org.bukkit.craftbukkit.v1_17_R1.CraftArt;
|
||||
import org.bukkit.craftbukkit.v1_17_R1.CraftServer;
|
||||
import org.bukkit.craftbukkit.v1_17_R1.CraftSound;
|
||||
import org.bukkit.craftbukkit.v1_17_R1.CraftWorld;
|
||||
import org.bukkit.craftbukkit.v1_17_R1.block.data.CraftBlockData;
|
||||
import org.bukkit.craftbukkit.v1_17_R1.entity.CraftEntity;
|
||||
import org.bukkit.craftbukkit.v1_17_R1.entity.CraftPlayer;
|
||||
import org.bukkit.craftbukkit.v1_17_R1.inventory.CraftItemStack;
|
||||
import org.bukkit.craftbukkit.v1_17_R1.util.CraftMagicNumbers;
|
||||
import org.bukkit.craftbukkit.v1_17_R1.util.CraftNamespacedKey;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.entity.Villager;
|
||||
import org.bukkit.inventory.EquipmentSlot;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
import org.bukkit.potion.PotionEffect;
|
||||
import org.bukkit.util.EulerAngle;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.Arrays;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
public class ReflectionManager implements ReflectionManagerAbstract {
|
||||
public boolean hasInvul(Entity entity) {
|
||||
net.minecraft.world.entity.Entity nmsEntity = ((CraftEntity) entity).getHandle();
|
||||
|
||||
if (nmsEntity instanceof net.minecraft.world.entity.LivingEntity) {
|
||||
return nmsEntity.invulnerableTime > 0;
|
||||
} else {
|
||||
return nmsEntity.isInvulnerableTo(DamageSource.GENERIC);
|
||||
}
|
||||
}
|
||||
|
||||
public int getIncrementedStateId(Player player) {
|
||||
ServerPlayer serverPlayer = ((CraftPlayer) player).getHandle();
|
||||
return serverPlayer.containerMenu.incrementStateId(); // TODO Check correct container
|
||||
}
|
||||
|
||||
public int getNewEntityId() {
|
||||
return getNewEntityId(true);
|
||||
}
|
||||
|
||||
public int getNewEntityId(boolean increment) {
|
||||
try {
|
||||
Field entityCounter = net.minecraft.world.entity.Entity.class.getDeclaredField("b");
|
||||
entityCounter.setAccessible(true);
|
||||
AtomicInteger atomicInteger = (AtomicInteger) entityCounter.get(null);
|
||||
if (increment) {
|
||||
return atomicInteger.incrementAndGet();
|
||||
} else {
|
||||
return atomicInteger.get();
|
||||
}
|
||||
} catch (ReflectiveOperationException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
public ServerGamePacketListenerImpl getPlayerConnectionOrPlayer(Player player) {
|
||||
return ((CraftPlayer) player).getHandle().connection;
|
||||
}
|
||||
|
||||
public net.minecraft.world.entity.Entity createEntityInstance(String entityName) {
|
||||
Optional<net.minecraft.world.entity.EntityType<?>> optional = net.minecraft.world.entity.EntityType.byString(entityName.toLowerCase(Locale.ROOT));
|
||||
if (optional.isPresent()) {
|
||||
net.minecraft.world.entity.EntityType<?> entityType = optional.get();
|
||||
ServerLevel world = getWorldServer(Bukkit.getWorlds().get(0));
|
||||
net.minecraft.world.entity.Entity entity;
|
||||
if (entityType == net.minecraft.world.entity.EntityType.PLAYER) {
|
||||
WrappedGameProfile gameProfile = ReflectionManagerAbstract.getGameProfile(new UUID(0, 0), "Steve");
|
||||
entity = new ServerPlayer(getMinecraftServer(), world, (GameProfile) gameProfile.getHandle());
|
||||
}/* else if (entityType == net.minecraft.world.entity.EntityType.ENDER_PEARL) {
|
||||
entity = new ThrownEnderpearl(world, (net.minecraft.world.entity.LivingEntity) createEntityInstance("cow"));
|
||||
} else if (entityType == net.minecraft.world.entity.EntityType.FISHING_BOBBER) {
|
||||
entity = new FishingHook((net.minecraft.world.entity.player.Player) createEntityInstance("player"), world, 0, 0);
|
||||
}*/ else {
|
||||
entity = entityType.create(world);
|
||||
}
|
||||
|
||||
// Workaround for paper being 2 smart 4 me
|
||||
entity.setPos(1.0, 1.0, 1.0);
|
||||
entity.setPos(0.0, 0.0, 0.0);
|
||||
return entity;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public MobEffect getMobEffectList(int id) {
|
||||
return MobEffect.byId(id);
|
||||
}
|
||||
|
||||
public MobEffectInstance createMobEffect(PotionEffect effect) {
|
||||
return createMobEffect(effect.getType().getId(), effect.getDuration(), effect.getAmplifier(), effect.isAmbient(), effect.hasParticles());
|
||||
}
|
||||
|
||||
public MobEffectInstance createMobEffect(int id, int duration, int amplification, boolean ambient, boolean particles) {
|
||||
return new MobEffectInstance(getMobEffectList(id), duration, amplification, ambient, particles);
|
||||
}
|
||||
|
||||
public AABB getBoundingBox(Entity entity) {
|
||||
return ((CraftEntity) entity).getHandle().getBoundingBox();
|
||||
}
|
||||
|
||||
public double getXBoundingBox(Entity entity) {
|
||||
return getBoundingBox(entity).maxX - getBoundingBox(entity).minX;
|
||||
}
|
||||
|
||||
public double getYBoundingBox(Entity entity) {
|
||||
return getBoundingBox(entity).maxY - getBoundingBox(entity).minY;
|
||||
}
|
||||
|
||||
public double getZBoundingBox(Entity entity) {
|
||||
return getBoundingBox(entity).maxZ - getBoundingBox(entity).minZ;
|
||||
}
|
||||
|
||||
public ServerPlayer getPlayerFromPlayerConnection(Object nmsEntity) {
|
||||
return ((ServerPlayerConnection) nmsEntity).getPlayer();
|
||||
}
|
||||
|
||||
public Entity getBukkitEntity(Object nmsEntity) {
|
||||
return ((net.minecraft.world.entity.Entity) nmsEntity).getBukkitEntity();
|
||||
}
|
||||
|
||||
public ItemStack getBukkitItem(Object nmsItem) {
|
||||
return CraftItemStack.asBukkitCopy((net.minecraft.world.item.ItemStack) nmsItem);
|
||||
}
|
||||
|
||||
public ItemStack getCraftItem(ItemStack bukkitItem) {
|
||||
return CraftItemStack.asCraftCopy(bukkitItem);
|
||||
}
|
||||
|
||||
public SoundEvent getCraftSound(Sound sound) {
|
||||
return CraftSound.getSoundEffect(sound);
|
||||
}
|
||||
|
||||
public ServerEntity getEntityTrackerEntry(Entity target) throws Exception {
|
||||
ServerLevel world = ((CraftWorld) target.getWorld()).getHandle();
|
||||
ServerChunkCache chunkSource = world.getChunkProvider();
|
||||
ChunkMap chunkMap = chunkSource.chunkMap;
|
||||
Map<Integer, ChunkMap.TrackedEntity> entityMap = chunkMap.G;
|
||||
ChunkMap.TrackedEntity trackedEntity = entityMap.get(target.getEntityId());
|
||||
if (trackedEntity == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
Field field = ChunkMap.TrackedEntity.class.getDeclaredField("b");
|
||||
field.setAccessible(true);
|
||||
|
||||
return (ServerEntity) field.get(trackedEntity);
|
||||
}
|
||||
|
||||
public DedicatedServer getMinecraftServer() {
|
||||
return ((CraftServer) Bukkit.getServer()).getServer();
|
||||
}
|
||||
|
||||
public String getEnumArt(Art art) {
|
||||
return Registry.MOTIVE.getKey(CraftArt.BukkitToNotch(art)).getPath();
|
||||
}
|
||||
|
||||
public BlockPos getBlockPosition(int x, int y, int z) {
|
||||
return new BlockPos(x, y, z);
|
||||
}
|
||||
|
||||
public net.minecraft.core.Direction getEnumDirection(int direction) {
|
||||
return net.minecraft.core.Direction.from2DDataValue(direction);
|
||||
}
|
||||
|
||||
public ClientboundPlayerInfoPacket.Action getEnumPlayerInfoAction(int action) {
|
||||
return ClientboundPlayerInfoPacket.Action.values()[action];
|
||||
}
|
||||
|
||||
public ClientboundPlayerInfoPacket.PlayerUpdate getPlayerInfoData(WrappedGameProfile gameProfile) {
|
||||
return new ClientboundPlayerInfoPacket.PlayerUpdate((GameProfile) gameProfile.getHandle(), 0, GameType.SURVIVAL,
|
||||
new TextComponent(gameProfile.getName()));
|
||||
}
|
||||
|
||||
public Object getNmsEntity(Entity entity) {
|
||||
return ((CraftEntity) entity).getHandle();
|
||||
}
|
||||
|
||||
public double getPing(Player player) {
|
||||
return player.getPing();
|
||||
}
|
||||
|
||||
public float[] getSize(Entity entity) {
|
||||
net.minecraft.world.entity.Entity nmsEntity = ((CraftEntity) entity).getHandle();
|
||||
EntityDimensions dimensions = nmsEntity.getDimensions(net.minecraft.world.entity.Pose.STANDING);
|
||||
return new float[]{dimensions.width, nmsEntity.getEyeHeight()};
|
||||
}
|
||||
|
||||
public WrappedGameProfile getSkullBlob(WrappedGameProfile gameProfile) {
|
||||
DedicatedServer minecraftServer = getMinecraftServer();
|
||||
MinecraftSessionService sessionService = minecraftServer.getSessionService();
|
||||
return WrappedGameProfile.fromHandle(sessionService.fillProfileProperties((GameProfile) gameProfile.getHandle(), true));
|
||||
}
|
||||
|
||||
public Float getSoundModifier(Object entity) {
|
||||
if (!(entity instanceof net.minecraft.world.entity.LivingEntity)) {
|
||||
return 0.0f;
|
||||
} else {
|
||||
try {
|
||||
Method method = LivingEntity.class.getDeclaredMethod("getSoundVolume");
|
||||
method.setAccessible(true);
|
||||
|
||||
return (Float) method.invoke(entity);
|
||||
} catch (NoSuchMethodException | InvocationTargetException | IllegalAccessException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
return 0f;
|
||||
}
|
||||
|
||||
public void injectCallback(String playername, ProfileLookupCallback callback) {
|
||||
Agent agent = Agent.MINECRAFT;
|
||||
getMinecraftServer().getProfileRepository().findProfilesByNames(new String[]{playername}, agent, callback);
|
||||
}
|
||||
|
||||
public void setBoundingBox(Entity entity, double x, double y, double z) {
|
||||
Location loc = entity.getLocation();
|
||||
((CraftEntity) entity).getHandle()
|
||||
.setBoundingBox(new AABB(loc.getX() - x / 2, loc.getY() - y / 2, loc.getZ() - z / 2, loc.getX() + x / 2, loc.getY() + y / 2, loc.getZ() + z / 2));
|
||||
}
|
||||
|
||||
public Enum getSoundCategory(String category) {
|
||||
return Arrays.stream(SoundSource.values()).filter(soundSource -> category.equalsIgnoreCase(soundSource.getName())).findAny().get();
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates the NMS object EnumItemSlot from an EquipmentSlot.
|
||||
*
|
||||
* @param slot
|
||||
* @return null if the equipment slot is null
|
||||
*/
|
||||
public Enum createEnumItemSlot(EquipmentSlot slot) {
|
||||
switch (slot) {
|
||||
case HAND:
|
||||
return net.minecraft.world.entity.EquipmentSlot.MAINHAND;
|
||||
case OFF_HAND:
|
||||
return net.minecraft.world.entity.EquipmentSlot.OFFHAND;
|
||||
case FEET:
|
||||
return net.minecraft.world.entity.EquipmentSlot.FEET;
|
||||
case LEGS:
|
||||
return net.minecraft.world.entity.EquipmentSlot.LEGS;
|
||||
case CHEST:
|
||||
return net.minecraft.world.entity.EquipmentSlot.CHEST;
|
||||
case HEAD:
|
||||
return net.minecraft.world.entity.EquipmentSlot.HEAD;
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public Object getSoundString(Sound sound) {
|
||||
return CraftSound.getSoundEffect(sound).getLocation().toString(); // TODO
|
||||
}
|
||||
|
||||
public Optional<?> convertOptional(Object val) {
|
||||
if (val instanceof BlockPosition) {
|
||||
BlockPosition pos = (BlockPosition) val;
|
||||
return Optional.of(getBlockPosition(pos.getX(), pos.getY(), pos.getZ()));
|
||||
} else if (val instanceof WrappedBlockData) {
|
||||
Object obj = ((WrappedBlockData) val).getHandle();
|
||||
return Optional.of(obj);
|
||||
} else if (val instanceof ItemStack) {
|
||||
Object obj = getNmsItem((ItemStack) val);
|
||||
return Optional.of(obj);
|
||||
} else if (val instanceof WrappedChatComponent) {
|
||||
Object obj = ((WrappedChatComponent) val).getHandle();
|
||||
return Optional.of(obj);
|
||||
}
|
||||
|
||||
return Optional.of(val);
|
||||
}
|
||||
|
||||
public Vector3f convertVec3(Object object) {
|
||||
if (object instanceof Vector3F) {
|
||||
Vector3F vector3F = (Vector3F) object;
|
||||
return new Vector3f(vector3F.getX(), vector3F.getY(), vector3F.getZ());
|
||||
} else if (object instanceof EulerAngle) {
|
||||
EulerAngle eulerAngle = (EulerAngle) object;
|
||||
return new Vector3f((float) eulerAngle.getX(), (float) eulerAngle.getY(), (float) eulerAngle.getZ());
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public net.minecraft.core.Direction convertDirection(Direction direction) {
|
||||
return net.minecraft.core.Direction.from3DDataValue(direction.ordinal());
|
||||
}
|
||||
|
||||
public Material getMaterial(String name) {
|
||||
return CraftMagicNumbers.INSTANCE.getMaterial(name, CraftMagicNumbers.INSTANCE.getDataVersion());
|
||||
}
|
||||
|
||||
public String getItemName(Material material) {
|
||||
return Registry.ITEM.getKey(CraftMagicNumbers.getItem(material)).getPath();
|
||||
}
|
||||
|
||||
public net.minecraft.world.item.ItemStack getNmsItem(ItemStack itemStack) {
|
||||
return CraftItemStack.asNMSCopy(itemStack);
|
||||
}
|
||||
|
||||
public VillagerData getNmsVillagerData(Villager.Type villagerType, Villager.Profession villagerProfession) {
|
||||
VillagerType nmsVillagerType = Registry.VILLAGER_TYPE.get(CraftNamespacedKey.toMinecraft(villagerType.getKey()));
|
||||
VillagerProfession nmsVillagerProfession = Registry.VILLAGER_PROFESSION.get(CraftNamespacedKey.toMinecraft(villagerProfession.getKey()));
|
||||
|
||||
return new net.minecraft.world.entity.npc.VillagerData(nmsVillagerType, nmsVillagerProfession, 1);
|
||||
}
|
||||
|
||||
public VillagerType getVillagerType(Villager.Type type) {
|
||||
return Registry.VILLAGER_TYPE.get(CraftNamespacedKey.toMinecraft(type.getKey()));
|
||||
}
|
||||
|
||||
public VillagerProfession getVillagerProfession(Villager.Profession profession) {
|
||||
return Registry.VILLAGER_PROFESSION.get(CraftNamespacedKey.toMinecraft(profession.getKey()));
|
||||
}
|
||||
|
||||
public <T> SynchedEntityData.DataItem<T> createDataWatcherItem(WrappedDataWatcher.WrappedDataWatcherObject wrappedDataWatcherObject, T metaItem) {
|
||||
return new SynchedEntityData.DataItem<>((EntityDataAccessor<T>) wrappedDataWatcherObject.getHandle(), metaItem);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public SoundEvent createSoundEffect(String minecraftKey) {
|
||||
return new SoundEvent(new ResourceLocation(minecraftKey));
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResourceLocation createMinecraftKey(String name) {
|
||||
return new ResourceLocation(name);
|
||||
}
|
||||
|
||||
public Vec3 getVec3D(Vector vector) {
|
||||
return new Vec3(vector.getX(), vector.getY(), vector.getZ());
|
||||
}
|
||||
|
||||
public net.minecraft.world.entity.EntityType getEntityType(EntityType entityType) {
|
||||
return net.minecraft.world.entity.EntityType.byString(
|
||||
entityType.getName() == null ? entityType.name().toLowerCase(Locale.ENGLISH) : entityType.getName()).orElse(null);
|
||||
}
|
||||
|
||||
public Object registerEntityType(NamespacedKey key) {
|
||||
net.minecraft.world.entity.EntityType<net.minecraft.world.entity.Entity> newEntity =
|
||||
new net.minecraft.world.entity.EntityType<>(null, null, false, false, false, false, null, null, 0, 0);
|
||||
Registry.register(Registry.ENTITY_TYPE, CraftNamespacedKey.toMinecraft(key), newEntity);
|
||||
newEntity.getDescriptionId();
|
||||
return newEntity; // TODO ??? Some reflection in legacy that I'm unsure about
|
||||
}
|
||||
|
||||
public int getEntityTypeId(Object entityTypes) {
|
||||
net.minecraft.world.entity.EntityType entityType = (net.minecraft.world.entity.EntityType) entityTypes;
|
||||
return Registry.ENTITY_TYPE.getId(entityType);
|
||||
}
|
||||
|
||||
public int getEntityTypeId(EntityType entityType) {
|
||||
return getEntityTypeId(getEntityType(entityType));
|
||||
}
|
||||
|
||||
public Object getEntityType(NamespacedKey name) {
|
||||
return Registry.ENTITY_TYPE.get(CraftNamespacedKey.toMinecraft(name));
|
||||
}
|
||||
|
||||
public Object getNmsEntityPose(String enumPose) {
|
||||
return net.minecraft.world.entity.Pose.valueOf(enumPose);
|
||||
}
|
||||
|
||||
public int getCombinedIdByBlockData(BlockData data) {
|
||||
BlockState state = ((CraftBlockData) data).getState();
|
||||
return Block.getId(state);
|
||||
}
|
||||
|
||||
public int getCombinedIdByItemStack(ItemStack itemStack) {
|
||||
Block block = CraftMagicNumbers.getBlock(itemStack.getType());
|
||||
return Block.getId(block.defaultBlockState());
|
||||
}
|
||||
|
||||
public BlockData getBlockDataByCombinedId(int id) {
|
||||
return CraftBlockData.fromData(Block.stateById(id));
|
||||
}
|
||||
|
||||
public ItemStack getItemStackByCombinedId(int id) {
|
||||
return new ItemStack(CraftMagicNumbers.getMaterial(Block.stateById(id).getBlock()));
|
||||
}
|
||||
|
||||
public ServerLevel getWorldServer(World w) {
|
||||
return ((CraftWorld) w).getHandle();
|
||||
}
|
||||
|
||||
public ItemMeta getDeserializedItemMeta(Map<String, Object> meta) {
|
||||
try {
|
||||
Class<?> aClass = Class.forName("org.bukkit.craftbukkit.v1_17_R1.inventory.CraftMetaItem$SerializableMeta");
|
||||
Method deserialize = aClass.getDeclaredMethod("deserialize", Map.class);
|
||||
Object itemMeta = deserialize.invoke(null, meta);
|
||||
|
||||
return (ItemMeta) itemMeta;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
100
nms/v1_18_R1/pom.xml
Normal file
100
nms/v1_18_R1/pom.xml
Normal file
|
@ -0,0 +1,100 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<parent>
|
||||
<artifactId>nms</artifactId>
|
||||
<groupId>LibsDisguises</groupId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<artifactId>v1_18_R1</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
|
||||
<properties>
|
||||
<maven.compiler.source>17</maven.compiler.source>
|
||||
<maven.compiler.target>17</maven.compiler.target>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
|
||||
<spigot.version>1.18.1-R0.1-SNAPSHOT</spigot.version>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.spigotmc</groupId>
|
||||
<artifactId>spigot</artifactId>
|
||||
<version>${spigot.version}</version>
|
||||
<classifier>remapped-mojang</classifier>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.spigotmc</groupId>
|
||||
<artifactId>spigot-api</artifactId>
|
||||
<version>${spigot.version}</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>LibsDisguises</groupId>
|
||||
<artifactId>shared</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.comphenix.protocol</groupId>
|
||||
<artifactId>ProtocolLib</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>it.unimi.dsi</groupId>
|
||||
<artifactId>fastutil</artifactId>
|
||||
<version>8.5.8</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.mojang</groupId>
|
||||
<artifactId>datafixerupper</artifactId>
|
||||
<version>4.1.27</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>net.md-5</groupId>
|
||||
<artifactId>specialsource-maven-plugin</artifactId>
|
||||
<version>1.2.4</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>remap</goal>
|
||||
</goals>
|
||||
<id>remap-obf</id>
|
||||
<configuration>
|
||||
<srgIn>org.spigotmc:minecraft-server:${spigot.version}:txt:maps-mojang</srgIn>
|
||||
<reverse>true</reverse>
|
||||
<remappedDependencies>org.spigotmc:spigot:${spigot.version}:jar:remapped-mojang</remappedDependencies>
|
||||
<remappedClassifierName>remapped-mojang</remappedClassifierName>
|
||||
<remappedArtifactAttached>true</remappedArtifactAttached>
|
||||
</configuration>
|
||||
</execution>
|
||||
<execution>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>remap</goal>
|
||||
</goals>
|
||||
<id>remap-spigot</id>
|
||||
<configuration>
|
||||
<inputFile>target/${project.build.finalName}-remapped-mojang.jar</inputFile>
|
||||
<srgIn>org.spigotmc:minecraft-server:${spigot.version}:csrg:maps-spigot</srgIn>
|
||||
<remappedDependencies>org.spigotmc:spigot:${spigot.version}:jar:remapped-obf</remappedDependencies>
|
||||
<remappedClassifierName>remapped-spigot</remappedClassifierName>
|
||||
<remappedArtifactAttached>true</remappedArtifactAttached>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</project>
|
|
@ -0,0 +1,466 @@
|
|||
package me.libraryaddict.disguise.utilities.reflection.v1_18_1;
|
||||
|
||||
import com.comphenix.protocol.wrappers.BlockPosition;
|
||||
import com.comphenix.protocol.wrappers.EnumWrappers.Direction;
|
||||
import com.comphenix.protocol.wrappers.Vector3F;
|
||||
import com.comphenix.protocol.wrappers.WrappedBlockData;
|
||||
import com.comphenix.protocol.wrappers.WrappedChatComponent;
|
||||
import com.comphenix.protocol.wrappers.WrappedDataWatcher;
|
||||
import com.comphenix.protocol.wrappers.WrappedGameProfile;
|
||||
import com.mojang.authlib.Agent;
|
||||
import com.mojang.authlib.GameProfile;
|
||||
import com.mojang.authlib.ProfileLookupCallback;
|
||||
import com.mojang.authlib.minecraft.MinecraftSessionService;
|
||||
import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
|
||||
import me.libraryaddict.disguise.utilities.reflection.ReflectionManagerAbstract;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Registry;
|
||||
import net.minecraft.core.Vector3f;
|
||||
import net.minecraft.network.chat.TextComponent;
|
||||
import net.minecraft.network.protocol.game.ClientboundPlayerInfoPacket;
|
||||
import net.minecraft.network.syncher.EntityDataAccessor;
|
||||
import net.minecraft.network.syncher.SynchedEntityData;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.server.dedicated.DedicatedServer;
|
||||
import net.minecraft.server.level.ChunkMap;
|
||||
import net.minecraft.server.level.ServerChunkCache;
|
||||
import net.minecraft.server.level.ServerEntity;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.server.network.ServerGamePacketListenerImpl;
|
||||
import net.minecraft.server.network.ServerPlayerConnection;
|
||||
import net.minecraft.sounds.SoundEvent;
|
||||
import net.minecraft.sounds.SoundSource;
|
||||
import net.minecraft.world.damagesource.DamageSource;
|
||||
import net.minecraft.world.effect.MobEffect;
|
||||
import net.minecraft.world.effect.MobEffectInstance;
|
||||
import net.minecraft.world.entity.EntityDimensions;
|
||||
import net.minecraft.world.entity.npc.VillagerData;
|
||||
import net.minecraft.world.entity.npc.VillagerProfession;
|
||||
import net.minecraft.world.entity.npc.VillagerType;
|
||||
import net.minecraft.world.level.GameType;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.phys.AABB;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
import org.bukkit.Art;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.NamespacedKey;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.data.BlockData;
|
||||
import org.bukkit.craftbukkit.v1_18_R1.CraftArt;
|
||||
import org.bukkit.craftbukkit.v1_18_R1.CraftServer;
|
||||
import org.bukkit.craftbukkit.v1_18_R1.CraftSound;
|
||||
import org.bukkit.craftbukkit.v1_18_R1.CraftWorld;
|
||||
import org.bukkit.craftbukkit.v1_18_R1.block.data.CraftBlockData;
|
||||
import org.bukkit.craftbukkit.v1_18_R1.entity.CraftEntity;
|
||||
import org.bukkit.craftbukkit.v1_18_R1.entity.CraftPlayer;
|
||||
import org.bukkit.craftbukkit.v1_18_R1.inventory.CraftItemStack;
|
||||
import org.bukkit.craftbukkit.v1_18_R1.util.CraftMagicNumbers;
|
||||
import org.bukkit.craftbukkit.v1_18_R1.util.CraftNamespacedKey;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.entity.Villager;
|
||||
import org.bukkit.inventory.EquipmentSlot;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
import org.bukkit.potion.PotionEffect;
|
||||
import org.bukkit.util.EulerAngle;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.Arrays;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
public class ReflectionManager implements ReflectionManagerAbstract {
|
||||
public boolean hasInvul(Entity entity) {
|
||||
net.minecraft.world.entity.Entity nmsEntity = ((CraftEntity) entity).getHandle();
|
||||
|
||||
if (nmsEntity instanceof net.minecraft.world.entity.LivingEntity) {
|
||||
return nmsEntity.invulnerableTime > 0;
|
||||
} else {
|
||||
return nmsEntity.isInvulnerableTo(DamageSource.GENERIC);
|
||||
}
|
||||
}
|
||||
|
||||
public int getIncrementedStateId(Player player) {
|
||||
ServerPlayer serverPlayer = ((CraftPlayer) player).getHandle();
|
||||
return serverPlayer.containerMenu.incrementStateId(); // TODO Check correct container
|
||||
}
|
||||
|
||||
public int getNewEntityId() {
|
||||
return getNewEntityId(true);
|
||||
}
|
||||
|
||||
public int getNewEntityId(boolean increment) {
|
||||
try {
|
||||
Field entityCounter = net.minecraft.world.entity.Entity.class.getDeclaredField("b");
|
||||
entityCounter.setAccessible(true);
|
||||
AtomicInteger atomicInteger = (AtomicInteger) entityCounter.get(null);
|
||||
if (increment) {
|
||||
return atomicInteger.incrementAndGet();
|
||||
} else {
|
||||
return atomicInteger.get();
|
||||
}
|
||||
} catch (ReflectiveOperationException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
public ServerGamePacketListenerImpl getPlayerConnectionOrPlayer(Player player) {
|
||||
return ((CraftPlayer) player).getHandle().connection;
|
||||
}
|
||||
|
||||
public net.minecraft.world.entity.Entity createEntityInstance(String entityName) {
|
||||
Optional<net.minecraft.world.entity.EntityType<?>> optional = net.minecraft.world.entity.EntityType.byString(entityName.toLowerCase(Locale.ROOT));
|
||||
if (optional.isPresent()) {
|
||||
net.minecraft.world.entity.EntityType<?> entityType = optional.get();
|
||||
ServerLevel world = getWorldServer(Bukkit.getWorlds().get(0));
|
||||
net.minecraft.world.entity.Entity entity;
|
||||
if (entityType == net.minecraft.world.entity.EntityType.PLAYER) {
|
||||
WrappedGameProfile gameProfile = ReflectionManagerAbstract.getGameProfile(new UUID(0, 0), "Steve");
|
||||
entity = new ServerPlayer(getMinecraftServer(), world, (GameProfile) gameProfile.getHandle());
|
||||
}/* else if (entityType == net.minecraft.world.entity.EntityType.ENDER_PEARL) {
|
||||
entity = new ThrownEnderpearl(world, (net.minecraft.world.entity.LivingEntity) createEntityInstance("cow"));
|
||||
} else if (entityType == net.minecraft.world.entity.EntityType.FISHING_BOBBER) {
|
||||
entity = new FishingHook((net.minecraft.world.entity.player.Player) createEntityInstance("player"), world, 0, 0);
|
||||
}*/ else {
|
||||
entity = entityType.create(world);
|
||||
}
|
||||
|
||||
// Workaround for paper being 2 smart 4 me
|
||||
entity.setPos(1.0, 1.0, 1.0);
|
||||
entity.setPos(0.0, 0.0, 0.0);
|
||||
return entity;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public MobEffect getMobEffectList(int id) {
|
||||
return MobEffect.byId(id);
|
||||
}
|
||||
|
||||
public MobEffectInstance createMobEffect(PotionEffect effect) {
|
||||
return createMobEffect(effect.getType().getId(), effect.getDuration(), effect.getAmplifier(), effect.isAmbient(), effect.hasParticles());
|
||||
}
|
||||
|
||||
public MobEffectInstance createMobEffect(int id, int duration, int amplification, boolean ambient, boolean particles) {
|
||||
return new MobEffectInstance(getMobEffectList(id), duration, amplification, ambient, particles);
|
||||
}
|
||||
|
||||
public AABB getBoundingBox(Entity entity) {
|
||||
return ((CraftEntity) entity).getHandle().getBoundingBox();
|
||||
}
|
||||
|
||||
public double getXBoundingBox(Entity entity) {
|
||||
return getBoundingBox(entity).maxX - getBoundingBox(entity).minX;
|
||||
}
|
||||
|
||||
public double getYBoundingBox(Entity entity) {
|
||||
return getBoundingBox(entity).maxY - getBoundingBox(entity).minY;
|
||||
}
|
||||
|
||||
public double getZBoundingBox(Entity entity) {
|
||||
return getBoundingBox(entity).maxZ - getBoundingBox(entity).minZ;
|
||||
}
|
||||
|
||||
public ServerPlayer getPlayerFromPlayerConnection(Object nmsEntity) {
|
||||
return ((ServerPlayerConnection) nmsEntity).getPlayer();
|
||||
}
|
||||
|
||||
public Entity getBukkitEntity(Object nmsEntity) {
|
||||
return ((net.minecraft.world.entity.Entity) nmsEntity).getBukkitEntity();
|
||||
}
|
||||
|
||||
public ItemStack getBukkitItem(Object nmsItem) {
|
||||
return CraftItemStack.asBukkitCopy((net.minecraft.world.item.ItemStack) nmsItem);
|
||||
}
|
||||
|
||||
public ItemStack getCraftItem(ItemStack bukkitItem) {
|
||||
return CraftItemStack.asCraftCopy(bukkitItem);
|
||||
}
|
||||
|
||||
public SoundEvent getCraftSound(Sound sound) {
|
||||
return CraftSound.getSoundEffect(sound);
|
||||
}
|
||||
|
||||
public ServerEntity getEntityTrackerEntry(Entity target) throws Exception {
|
||||
ServerLevel world = ((CraftWorld) target.getWorld()).getHandle();
|
||||
ServerChunkCache chunkSource = world.getChunkSource();
|
||||
ChunkMap chunkMap = chunkSource.chunkMap;
|
||||
Int2ObjectMap<ChunkMap.TrackedEntity> entityMap = chunkMap.entityMap;
|
||||
ChunkMap.TrackedEntity trackedEntity = entityMap.get(target.getEntityId());
|
||||
if (trackedEntity == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
Field field = ChunkMap.TrackedEntity.class.getDeclaredField("b");
|
||||
field.setAccessible(true);
|
||||
|
||||
return (ServerEntity) field.get(trackedEntity);
|
||||
}
|
||||
|
||||
public DedicatedServer getMinecraftServer() {
|
||||
return ((CraftServer) Bukkit.getServer()).getServer();
|
||||
}
|
||||
|
||||
public String getEnumArt(Art art) {
|
||||
return Registry.MOTIVE.getKey(CraftArt.BukkitToNotch(art)).getPath();
|
||||
}
|
||||
|
||||
public BlockPos getBlockPosition(int x, int y, int z) {
|
||||
return new BlockPos(x, y, z);
|
||||
}
|
||||
|
||||
public net.minecraft.core.Direction getEnumDirection(int direction) {
|
||||
return net.minecraft.core.Direction.from2DDataValue(direction);
|
||||
}
|
||||
|
||||
public ClientboundPlayerInfoPacket.Action getEnumPlayerInfoAction(int action) {
|
||||
return ClientboundPlayerInfoPacket.Action.values()[action];
|
||||
}
|
||||
|
||||
public ClientboundPlayerInfoPacket.PlayerUpdate getPlayerInfoData(WrappedGameProfile gameProfile) {
|
||||
return new ClientboundPlayerInfoPacket.PlayerUpdate((GameProfile) gameProfile.getHandle(), 0, GameType.SURVIVAL,
|
||||
new TextComponent(gameProfile.getName()));
|
||||
}
|
||||
|
||||
public Object getNmsEntity(Entity entity) {
|
||||
return ((CraftEntity) entity).getHandle();
|
||||
}
|
||||
|
||||
public double getPing(Player player) {
|
||||
return player.getPing();
|
||||
}
|
||||
|
||||
public float[] getSize(Entity entity) {
|
||||
net.minecraft.world.entity.Entity nmsEntity = ((CraftEntity) entity).getHandle();
|
||||
EntityDimensions dimensions = nmsEntity.getDimensions(net.minecraft.world.entity.Pose.STANDING);
|
||||
return new float[]{dimensions.width, nmsEntity.getEyeHeight()};
|
||||
}
|
||||
|
||||
public WrappedGameProfile getSkullBlob(WrappedGameProfile gameProfile) {
|
||||
DedicatedServer minecraftServer = getMinecraftServer();
|
||||
MinecraftSessionService sessionService = minecraftServer.getSessionService();
|
||||
return WrappedGameProfile.fromHandle(sessionService.fillProfileProperties((GameProfile) gameProfile.getHandle(), true));
|
||||
}
|
||||
|
||||
public Float getSoundModifier(Object entity) {
|
||||
if (!(entity instanceof net.minecraft.world.entity.LivingEntity)) {
|
||||
return 0.0f;
|
||||
} else {
|
||||
try {
|
||||
Method method = net.minecraft.world.entity.LivingEntity.class.getDeclaredMethod("eu");
|
||||
method.setAccessible(true);
|
||||
|
||||
return (Float) method.invoke(entity);
|
||||
} catch (NoSuchMethodException | InvocationTargetException | IllegalAccessException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
return 0f;
|
||||
}
|
||||
|
||||
public void injectCallback(String playername, ProfileLookupCallback callback) {
|
||||
Agent agent = Agent.MINECRAFT;
|
||||
getMinecraftServer().getProfileRepository().findProfilesByNames(new String[]{playername}, agent, callback);
|
||||
}
|
||||
|
||||
public void setBoundingBox(Entity entity, double x, double y, double z) {
|
||||
Location loc = entity.getLocation();
|
||||
((CraftEntity) entity).getHandle()
|
||||
.setBoundingBox(new AABB(loc.getX() - x / 2, loc.getY() - y / 2, loc.getZ() - z / 2, loc.getX() + x / 2, loc.getY() + y / 2, loc.getZ() + z / 2));
|
||||
}
|
||||
|
||||
public Enum getSoundCategory(String category) {
|
||||
return Arrays.stream(SoundSource.values()).filter(soundSource -> category.equalsIgnoreCase(soundSource.getName())).findAny().get();
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates the NMS object EnumItemSlot from an EquipmentSlot.
|
||||
*
|
||||
* @param slot
|
||||
* @return null if the equipment slot is null
|
||||
*/
|
||||
public Enum createEnumItemSlot(EquipmentSlot slot) {
|
||||
switch (slot) {
|
||||
case HAND:
|
||||
return net.minecraft.world.entity.EquipmentSlot.MAINHAND;
|
||||
case OFF_HAND:
|
||||
return net.minecraft.world.entity.EquipmentSlot.OFFHAND;
|
||||
case FEET:
|
||||
return net.minecraft.world.entity.EquipmentSlot.FEET;
|
||||
case LEGS:
|
||||
return net.minecraft.world.entity.EquipmentSlot.LEGS;
|
||||
case CHEST:
|
||||
return net.minecraft.world.entity.EquipmentSlot.CHEST;
|
||||
case HEAD:
|
||||
return net.minecraft.world.entity.EquipmentSlot.HEAD;
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public Object getSoundString(Sound sound) {
|
||||
return CraftSound.getSoundEffect(sound).getLocation().toString(); // TODO
|
||||
}
|
||||
|
||||
public Optional<?> convertOptional(Object val) {
|
||||
if (val instanceof BlockPosition) {
|
||||
BlockPosition pos = (BlockPosition) val;
|
||||
return Optional.of(getBlockPosition(pos.getX(), pos.getY(), pos.getZ()));
|
||||
} else if (val instanceof WrappedBlockData) {
|
||||
Object obj = ((WrappedBlockData) val).getHandle();
|
||||
return Optional.of(obj);
|
||||
} else if (val instanceof ItemStack) {
|
||||
Object obj = getNmsItem((ItemStack) val);
|
||||
return Optional.of(obj);
|
||||
} else if (val instanceof WrappedChatComponent) {
|
||||
Object obj = ((WrappedChatComponent) val).getHandle();
|
||||
return Optional.of(obj);
|
||||
}
|
||||
|
||||
return Optional.of(val);
|
||||
}
|
||||
|
||||
public Vector3f convertVec3(Object object) {
|
||||
if (object instanceof Vector3F) {
|
||||
Vector3F vector3F = (Vector3F) object;
|
||||
return new Vector3f(vector3F.getX(), vector3F.getY(), vector3F.getZ());
|
||||
} else if (object instanceof EulerAngle) {
|
||||
EulerAngle eulerAngle = (EulerAngle) object;
|
||||
return new Vector3f((float) eulerAngle.getX(), (float) eulerAngle.getY(), (float) eulerAngle.getZ());
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public net.minecraft.core.Direction convertDirection(Direction direction) {
|
||||
return net.minecraft.core.Direction.from3DDataValue(direction.ordinal());
|
||||
}
|
||||
|
||||
public Material getMaterial(String name) {
|
||||
return CraftMagicNumbers.INSTANCE.getMaterial(name, CraftMagicNumbers.INSTANCE.getDataVersion());
|
||||
}
|
||||
|
||||
public String getItemName(Material material) {
|
||||
return Registry.ITEM.getKey(CraftMagicNumbers.getItem(material)).getPath();
|
||||
}
|
||||
|
||||
public net.minecraft.world.item.ItemStack getNmsItem(ItemStack itemStack) {
|
||||
return CraftItemStack.asNMSCopy(itemStack);
|
||||
}
|
||||
|
||||
public VillagerData getNmsVillagerData(Villager.Type villagerType, Villager.Profession villagerProfession) {
|
||||
VillagerType nmsVillagerType = Registry.VILLAGER_TYPE.get(CraftNamespacedKey.toMinecraft(villagerType.getKey()));
|
||||
VillagerProfession nmsVillagerProfession = Registry.VILLAGER_PROFESSION.get(CraftNamespacedKey.toMinecraft(villagerProfession.getKey()));
|
||||
|
||||
return new net.minecraft.world.entity.npc.VillagerData(nmsVillagerType, nmsVillagerProfession, 1);
|
||||
}
|
||||
|
||||
public VillagerType getVillagerType(Villager.Type type) {
|
||||
return Registry.VILLAGER_TYPE.get(CraftNamespacedKey.toMinecraft(type.getKey()));
|
||||
}
|
||||
|
||||
public VillagerProfession getVillagerProfession(Villager.Profession profession) {
|
||||
return Registry.VILLAGER_PROFESSION.get(CraftNamespacedKey.toMinecraft(profession.getKey()));
|
||||
}
|
||||
|
||||
public <T> SynchedEntityData.DataItem<T> createDataWatcherItem(WrappedDataWatcher.WrappedDataWatcherObject wrappedDataWatcherObject, T metaItem) {
|
||||
return new SynchedEntityData.DataItem<>((EntityDataAccessor<T>) wrappedDataWatcherObject.getHandle(), metaItem);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public SoundEvent createSoundEffect(String minecraftKey) {
|
||||
return new SoundEvent(new ResourceLocation(minecraftKey));
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResourceLocation createMinecraftKey(String name) {
|
||||
return new ResourceLocation(name);
|
||||
}
|
||||
|
||||
public Vec3 getVec3D(Vector vector) {
|
||||
return new Vec3(vector.getX(), vector.getY(), vector.getZ());
|
||||
}
|
||||
|
||||
public net.minecraft.world.entity.EntityType getEntityType(EntityType entityType) {
|
||||
return net.minecraft.world.entity.EntityType.byString(
|
||||
entityType.getName() == null ? entityType.name().toLowerCase(Locale.ENGLISH) : entityType.getName()).orElse(null);
|
||||
}
|
||||
|
||||
public Object registerEntityType(NamespacedKey key) {
|
||||
net.minecraft.world.entity.EntityType<net.minecraft.world.entity.Entity> newEntity =
|
||||
new net.minecraft.world.entity.EntityType<>(null, null, false, false, false, false, null, null, 0, 0);
|
||||
Registry.register(Registry.ENTITY_TYPE, CraftNamespacedKey.toMinecraft(key), newEntity);
|
||||
newEntity.getDescriptionId();
|
||||
return newEntity; // TODO ??? Some reflection in legacy that I'm unsure about
|
||||
}
|
||||
|
||||
public int getEntityTypeId(Object entityTypes) {
|
||||
net.minecraft.world.entity.EntityType entityType = (net.minecraft.world.entity.EntityType) entityTypes;
|
||||
return Registry.ENTITY_TYPE.getId(entityType);
|
||||
}
|
||||
|
||||
public int getEntityTypeId(EntityType entityType) {
|
||||
return getEntityTypeId(getEntityType(entityType));
|
||||
}
|
||||
|
||||
public Object getEntityType(NamespacedKey name) {
|
||||
return Registry.ENTITY_TYPE.get(CraftNamespacedKey.toMinecraft(name));
|
||||
}
|
||||
|
||||
public Object getNmsEntityPose(String enumPose) {
|
||||
return net.minecraft.world.entity.Pose.valueOf(enumPose);
|
||||
}
|
||||
|
||||
public int getCombinedIdByBlockData(BlockData data) {
|
||||
BlockState state = ((CraftBlockData) data).getState();
|
||||
return Block.getId(state);
|
||||
}
|
||||
|
||||
public int getCombinedIdByItemStack(ItemStack itemStack) {
|
||||
Block block = CraftMagicNumbers.getBlock(itemStack.getType());
|
||||
return Block.getId(block.defaultBlockState());
|
||||
}
|
||||
|
||||
public BlockData getBlockDataByCombinedId(int id) {
|
||||
return CraftBlockData.fromData(Block.stateById(id));
|
||||
}
|
||||
|
||||
public ItemStack getItemStackByCombinedId(int id) {
|
||||
return new ItemStack(CraftMagicNumbers.getMaterial(Block.stateById(id).getBlock()));
|
||||
}
|
||||
|
||||
public ServerLevel getWorldServer(World w) {
|
||||
return ((CraftWorld) w).getHandle();
|
||||
}
|
||||
|
||||
public ItemMeta getDeserializedItemMeta(Map<String, Object> meta) {
|
||||
try {
|
||||
Class<?> aClass = Class.forName("org.bukkit.craftbukkit.v1_18_R1.inventory.CraftMetaItem$SerializableMeta");
|
||||
Method deserialize = aClass.getDeclaredMethod("deserialize", Map.class);
|
||||
Object itemMeta = deserialize.invoke(null, meta);
|
||||
|
||||
return (ItemMeta) itemMeta;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
107
nms/v1_18_R2/pom.xml
Normal file
107
nms/v1_18_R2/pom.xml
Normal file
|
@ -0,0 +1,107 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<parent>
|
||||
<artifactId>nms</artifactId>
|
||||
<groupId>LibsDisguises</groupId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<artifactId>v1_18_R2</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
|
||||
<properties>
|
||||
<maven.compiler.source>17</maven.compiler.source>
|
||||
<maven.compiler.target>17</maven.compiler.target>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
|
||||
<spigot.version>1.18.2-R0.1-SNAPSHOT</spigot.version>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.spigotmc</groupId>
|
||||
<artifactId>spigot</artifactId>
|
||||
<version>${spigot.version}</version>
|
||||
<classifier>remapped-mojang</classifier>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.spigotmc</groupId>
|
||||
<artifactId>spigot-api</artifactId>
|
||||
<version>${spigot.version}</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>LibsDisguises</groupId>
|
||||
<artifactId>shared</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.comphenix.protocol</groupId>
|
||||
<artifactId>ProtocolLib</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.mojang</groupId>
|
||||
<artifactId>authlib</artifactId>
|
||||
<version>3.3.39</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>it.unimi.dsi</groupId>
|
||||
<artifactId>fastutil</artifactId>
|
||||
<version>8.5.6</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.mojang</groupId>
|
||||
<artifactId>datafixerupper</artifactId>
|
||||
<version>4.1.27</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>net.md-5</groupId>
|
||||
<artifactId>specialsource-maven-plugin</artifactId>
|
||||
<version>1.2.4</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>remap</goal>
|
||||
</goals>
|
||||
<id>remap-obf</id>
|
||||
<configuration>
|
||||
<srgIn>org.spigotmc:minecraft-server:${spigot.version}:txt:maps-mojang</srgIn>
|
||||
<reverse>true</reverse>
|
||||
<remappedDependencies>org.spigotmc:spigot:${spigot.version}:jar:remapped-mojang</remappedDependencies>
|
||||
<remappedClassifierName>remapped-mojang</remappedClassifierName>
|
||||
<remappedArtifactAttached>true</remappedArtifactAttached>
|
||||
</configuration>
|
||||
</execution>
|
||||
<execution>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>remap</goal>
|
||||
</goals>
|
||||
<id>remap-spigot</id>
|
||||
<configuration>
|
||||
<inputFile>target/${project.build.finalName}-remapped-mojang.jar</inputFile>
|
||||
<srgIn>org.spigotmc:minecraft-server:${spigot.version}:csrg:maps-spigot</srgIn>
|
||||
<remappedDependencies>org.spigotmc:spigot:${spigot.version}:jar:remapped-obf</remappedDependencies>
|
||||
<remappedClassifierName>remapped-spigot</remappedClassifierName>
|
||||
<remappedArtifactAttached>true</remappedArtifactAttached>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</project>
|
|
@ -0,0 +1,466 @@
|
|||
package me.libraryaddict.disguise.utilities.reflection.v1_18_2;
|
||||
|
||||
import com.comphenix.protocol.wrappers.BlockPosition;
|
||||
import com.comphenix.protocol.wrappers.EnumWrappers.Direction;
|
||||
import com.comphenix.protocol.wrappers.Vector3F;
|
||||
import com.comphenix.protocol.wrappers.WrappedBlockData;
|
||||
import com.comphenix.protocol.wrappers.WrappedChatComponent;
|
||||
import com.comphenix.protocol.wrappers.WrappedDataWatcher;
|
||||
import com.comphenix.protocol.wrappers.WrappedGameProfile;
|
||||
import com.mojang.authlib.Agent;
|
||||
import com.mojang.authlib.GameProfile;
|
||||
import com.mojang.authlib.ProfileLookupCallback;
|
||||
import com.mojang.authlib.minecraft.MinecraftSessionService;
|
||||
import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
|
||||
import me.libraryaddict.disguise.utilities.reflection.ReflectionManagerAbstract;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Registry;
|
||||
import net.minecraft.core.Vector3f;
|
||||
import net.minecraft.network.chat.TextComponent;
|
||||
import net.minecraft.network.protocol.game.ClientboundPlayerInfoPacket;
|
||||
import net.minecraft.network.syncher.EntityDataAccessor;
|
||||
import net.minecraft.network.syncher.SynchedEntityData;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.server.dedicated.DedicatedServer;
|
||||
import net.minecraft.server.level.ChunkMap;
|
||||
import net.minecraft.server.level.ServerChunkCache;
|
||||
import net.minecraft.server.level.ServerEntity;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.server.network.ServerGamePacketListenerImpl;
|
||||
import net.minecraft.server.network.ServerPlayerConnection;
|
||||
import net.minecraft.sounds.SoundEvent;
|
||||
import net.minecraft.sounds.SoundSource;
|
||||
import net.minecraft.world.damagesource.DamageSource;
|
||||
import net.minecraft.world.effect.MobEffect;
|
||||
import net.minecraft.world.effect.MobEffectInstance;
|
||||
import net.minecraft.world.entity.EntityDimensions;
|
||||
import net.minecraft.world.entity.npc.VillagerData;
|
||||
import net.minecraft.world.entity.npc.VillagerProfession;
|
||||
import net.minecraft.world.entity.npc.VillagerType;
|
||||
import net.minecraft.world.level.GameType;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.phys.AABB;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
import org.bukkit.Art;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.NamespacedKey;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.data.BlockData;
|
||||
import org.bukkit.craftbukkit.v1_18_R2.CraftArt;
|
||||
import org.bukkit.craftbukkit.v1_18_R2.CraftServer;
|
||||
import org.bukkit.craftbukkit.v1_18_R2.CraftSound;
|
||||
import org.bukkit.craftbukkit.v1_18_R2.CraftWorld;
|
||||
import org.bukkit.craftbukkit.v1_18_R2.block.data.CraftBlockData;
|
||||
import org.bukkit.craftbukkit.v1_18_R2.entity.CraftEntity;
|
||||
import org.bukkit.craftbukkit.v1_18_R2.entity.CraftPlayer;
|
||||
import org.bukkit.craftbukkit.v1_18_R2.inventory.CraftItemStack;
|
||||
import org.bukkit.craftbukkit.v1_18_R2.util.CraftMagicNumbers;
|
||||
import org.bukkit.craftbukkit.v1_18_R2.util.CraftNamespacedKey;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.entity.Villager;
|
||||
import org.bukkit.inventory.EquipmentSlot;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
import org.bukkit.potion.PotionEffect;
|
||||
import org.bukkit.util.EulerAngle;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.Arrays;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
public class ReflectionManager implements ReflectionManagerAbstract {
|
||||
public boolean hasInvul(Entity entity) {
|
||||
net.minecraft.world.entity.Entity nmsEntity = ((CraftEntity) entity).getHandle();
|
||||
|
||||
if (nmsEntity instanceof net.minecraft.world.entity.LivingEntity) {
|
||||
return nmsEntity.invulnerableTime > 0;
|
||||
} else {
|
||||
return nmsEntity.isInvulnerableTo(DamageSource.GENERIC);
|
||||
}
|
||||
}
|
||||
|
||||
public int getIncrementedStateId(Player player) {
|
||||
ServerPlayer serverPlayer = ((CraftPlayer) player).getHandle();
|
||||
return serverPlayer.containerMenu.incrementStateId(); // TODO Check correct container
|
||||
}
|
||||
|
||||
public int getNewEntityId() {
|
||||
return getNewEntityId(true);
|
||||
}
|
||||
|
||||
public int getNewEntityId(boolean increment) {
|
||||
try {
|
||||
Field entityCounter = net.minecraft.world.entity.Entity.class.getDeclaredField("c");
|
||||
entityCounter.setAccessible(true);
|
||||
AtomicInteger atomicInteger = (AtomicInteger) entityCounter.get(null);
|
||||
if (increment) {
|
||||
return atomicInteger.incrementAndGet();
|
||||
} else {
|
||||
return atomicInteger.get();
|
||||
}
|
||||
} catch (ReflectiveOperationException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
public ServerGamePacketListenerImpl getPlayerConnectionOrPlayer(Player player) {
|
||||
return ((CraftPlayer) player).getHandle().connection;
|
||||
}
|
||||
|
||||
public net.minecraft.world.entity.Entity createEntityInstance(String entityName) {
|
||||
Optional<net.minecraft.world.entity.EntityType<?>> optional = net.minecraft.world.entity.EntityType.byString(entityName.toLowerCase(Locale.ROOT));
|
||||
if (optional.isPresent()) {
|
||||
net.minecraft.world.entity.EntityType<?> entityType = optional.get();
|
||||
ServerLevel world = getWorldServer(Bukkit.getWorlds().get(0));
|
||||
net.minecraft.world.entity.Entity entity;
|
||||
if (entityType == net.minecraft.world.entity.EntityType.PLAYER) {
|
||||
WrappedGameProfile gameProfile = ReflectionManagerAbstract.getGameProfile(new UUID(0, 0), "Steve");
|
||||
entity = new ServerPlayer(getMinecraftServer(), world, (GameProfile) gameProfile.getHandle());
|
||||
}/* else if (entityType == net.minecraft.world.entity.EntityType.ENDER_PEARL) {
|
||||
entity = new ThrownEnderpearl(world, (net.minecraft.world.entity.LivingEntity) createEntityInstance("cow"));
|
||||
} else if (entityType == net.minecraft.world.entity.EntityType.FISHING_BOBBER) {
|
||||
entity = new FishingHook((net.minecraft.world.entity.player.Player) createEntityInstance("player"), world, 0, 0);
|
||||
}*/ else {
|
||||
entity = entityType.create(world);
|
||||
}
|
||||
|
||||
// Workaround for paper being 2 smart 4 me
|
||||
entity.setPos(1.0, 1.0, 1.0);
|
||||
entity.setPos(0.0, 0.0, 0.0);
|
||||
return entity;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public MobEffect getMobEffectList(int id) {
|
||||
return MobEffect.byId(id);
|
||||
}
|
||||
|
||||
public MobEffectInstance createMobEffect(PotionEffect effect) {
|
||||
return createMobEffect(effect.getType().getId(), effect.getDuration(), effect.getAmplifier(), effect.isAmbient(), effect.hasParticles());
|
||||
}
|
||||
|
||||
public MobEffectInstance createMobEffect(int id, int duration, int amplification, boolean ambient, boolean particles) {
|
||||
return new MobEffectInstance(getMobEffectList(id), duration, amplification, ambient, particles);
|
||||
}
|
||||
|
||||
public AABB getBoundingBox(Entity entity) {
|
||||
return ((CraftEntity) entity).getHandle().getBoundingBox();
|
||||
}
|
||||
|
||||
public double getXBoundingBox(Entity entity) {
|
||||
return getBoundingBox(entity).maxX - getBoundingBox(entity).minX;
|
||||
}
|
||||
|
||||
public double getYBoundingBox(Entity entity) {
|
||||
return getBoundingBox(entity).maxY - getBoundingBox(entity).minY;
|
||||
}
|
||||
|
||||
public double getZBoundingBox(Entity entity) {
|
||||
return getBoundingBox(entity).maxZ - getBoundingBox(entity).minZ;
|
||||
}
|
||||
|
||||
public ServerPlayer getPlayerFromPlayerConnection(Object nmsEntity) {
|
||||
return ((ServerPlayerConnection) nmsEntity).getPlayer();
|
||||
}
|
||||
|
||||
public Entity getBukkitEntity(Object nmsEntity) {
|
||||
return ((net.minecraft.world.entity.Entity) nmsEntity).getBukkitEntity();
|
||||
}
|
||||
|
||||
public ItemStack getBukkitItem(Object nmsItem) {
|
||||
return CraftItemStack.asBukkitCopy((net.minecraft.world.item.ItemStack) nmsItem);
|
||||
}
|
||||
|
||||
public ItemStack getCraftItem(ItemStack bukkitItem) {
|
||||
return CraftItemStack.asCraftCopy(bukkitItem);
|
||||
}
|
||||
|
||||
public SoundEvent getCraftSound(Sound sound) {
|
||||
return CraftSound.getSoundEffect(sound);
|
||||
}
|
||||
|
||||
public ServerEntity getEntityTrackerEntry(Entity target) throws Exception {
|
||||
ServerLevel world = ((CraftWorld) target.getWorld()).getHandle();
|
||||
ServerChunkCache chunkSource = world.getChunkSource();
|
||||
ChunkMap chunkMap = chunkSource.chunkMap;
|
||||
Int2ObjectMap<ChunkMap.TrackedEntity> entityMap = chunkMap.entityMap;
|
||||
ChunkMap.TrackedEntity trackedEntity = entityMap.get(target.getEntityId());
|
||||
if (trackedEntity == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
Field field = ChunkMap.TrackedEntity.class.getDeclaredField("b");
|
||||
field.setAccessible(true);
|
||||
|
||||
return (ServerEntity) field.get(trackedEntity);
|
||||
}
|
||||
|
||||
public DedicatedServer getMinecraftServer() {
|
||||
return ((CraftServer) Bukkit.getServer()).getServer();
|
||||
}
|
||||
|
||||
public String getEnumArt(Art art) {
|
||||
return Registry.MOTIVE.getKey(CraftArt.BukkitToNotch(art)).getPath();
|
||||
}
|
||||
|
||||
public BlockPos getBlockPosition(int x, int y, int z) {
|
||||
return new BlockPos(x, y, z);
|
||||
}
|
||||
|
||||
public net.minecraft.core.Direction getEnumDirection(int direction) {
|
||||
return net.minecraft.core.Direction.from2DDataValue(direction);
|
||||
}
|
||||
|
||||
public ClientboundPlayerInfoPacket.Action getEnumPlayerInfoAction(int action) {
|
||||
return ClientboundPlayerInfoPacket.Action.values()[action];
|
||||
}
|
||||
|
||||
public ClientboundPlayerInfoPacket.PlayerUpdate getPlayerInfoData(WrappedGameProfile gameProfile) {
|
||||
return new ClientboundPlayerInfoPacket.PlayerUpdate((GameProfile) gameProfile.getHandle(), 0, GameType.SURVIVAL,
|
||||
new TextComponent(gameProfile.getName()));
|
||||
}
|
||||
|
||||
public Object getNmsEntity(Entity entity) {
|
||||
return ((CraftEntity) entity).getHandle();
|
||||
}
|
||||
|
||||
public double getPing(Player player) {
|
||||
return player.getPing();
|
||||
}
|
||||
|
||||
public float[] getSize(Entity entity) {
|
||||
net.minecraft.world.entity.Entity nmsEntity = ((CraftEntity) entity).getHandle();
|
||||
EntityDimensions dimensions = nmsEntity.getDimensions(net.minecraft.world.entity.Pose.STANDING);
|
||||
return new float[]{dimensions.width, nmsEntity.getEyeHeight()};
|
||||
}
|
||||
|
||||
public WrappedGameProfile getSkullBlob(WrappedGameProfile gameProfile) {
|
||||
DedicatedServer minecraftServer = getMinecraftServer();
|
||||
MinecraftSessionService sessionService = minecraftServer.getSessionService();
|
||||
return WrappedGameProfile.fromHandle(sessionService.fillProfileProperties((GameProfile) gameProfile.getHandle(), true));
|
||||
}
|
||||
|
||||
public Float getSoundModifier(Object entity) {
|
||||
if (!(entity instanceof net.minecraft.world.entity.LivingEntity)) {
|
||||
return 0.0f;
|
||||
} else {
|
||||
try {
|
||||
Method method = net.minecraft.world.entity.LivingEntity.class.getDeclaredMethod("eu");
|
||||
method.setAccessible(true);
|
||||
|
||||
return (Float) method.invoke(entity);
|
||||
} catch (NoSuchMethodException | InvocationTargetException | IllegalAccessException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
return 0f;
|
||||
}
|
||||
|
||||
public void injectCallback(String playername, ProfileLookupCallback callback) {
|
||||
Agent agent = Agent.MINECRAFT;
|
||||
getMinecraftServer().getProfileRepository().findProfilesByNames(new String[]{playername}, agent, callback);
|
||||
}
|
||||
|
||||
public void setBoundingBox(Entity entity, double x, double y, double z) {
|
||||
Location loc = entity.getLocation();
|
||||
((CraftEntity) entity).getHandle()
|
||||
.setBoundingBox(new AABB(loc.getX() - x / 2, loc.getY() - y / 2, loc.getZ() - z / 2, loc.getX() + x / 2, loc.getY() + y / 2, loc.getZ() + z / 2));
|
||||
}
|
||||
|
||||
public Enum getSoundCategory(String category) {
|
||||
return Arrays.stream(SoundSource.values()).filter(soundSource -> category.equalsIgnoreCase(soundSource.getName())).findAny().get();
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates the NMS object EnumItemSlot from an EquipmentSlot.
|
||||
*
|
||||
* @param slot
|
||||
* @return null if the equipment slot is null
|
||||
*/
|
||||
public Enum createEnumItemSlot(EquipmentSlot slot) {
|
||||
switch (slot) {
|
||||
case HAND:
|
||||
return net.minecraft.world.entity.EquipmentSlot.MAINHAND;
|
||||
case OFF_HAND:
|
||||
return net.minecraft.world.entity.EquipmentSlot.OFFHAND;
|
||||
case FEET:
|
||||
return net.minecraft.world.entity.EquipmentSlot.FEET;
|
||||
case LEGS:
|
||||
return net.minecraft.world.entity.EquipmentSlot.LEGS;
|
||||
case CHEST:
|
||||
return net.minecraft.world.entity.EquipmentSlot.CHEST;
|
||||
case HEAD:
|
||||
return net.minecraft.world.entity.EquipmentSlot.HEAD;
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public Object getSoundString(Sound sound) {
|
||||
return CraftSound.getSoundEffect(sound).getLocation().toString(); // TODO
|
||||
}
|
||||
|
||||
public Optional<?> convertOptional(Object val) {
|
||||
if (val instanceof BlockPosition) {
|
||||
BlockPosition pos = (BlockPosition) val;
|
||||
return Optional.of(getBlockPosition(pos.getX(), pos.getY(), pos.getZ()));
|
||||
} else if (val instanceof WrappedBlockData) {
|
||||
Object obj = ((WrappedBlockData) val).getHandle();
|
||||
return Optional.of(obj);
|
||||
} else if (val instanceof ItemStack) {
|
||||
Object obj = getNmsItem((ItemStack) val);
|
||||
return Optional.of(obj);
|
||||
} else if (val instanceof WrappedChatComponent) {
|
||||
Object obj = ((WrappedChatComponent) val).getHandle();
|
||||
return Optional.of(obj);
|
||||
}
|
||||
|
||||
return Optional.of(val);
|
||||
}
|
||||
|
||||
public Vector3f convertVec3(Object object) {
|
||||
if (object instanceof Vector3F) {
|
||||
Vector3F vector3F = (Vector3F) object;
|
||||
return new Vector3f(vector3F.getX(), vector3F.getY(), vector3F.getZ());
|
||||
} else if (object instanceof EulerAngle) {
|
||||
EulerAngle eulerAngle = (EulerAngle) object;
|
||||
return new Vector3f((float) eulerAngle.getX(), (float) eulerAngle.getY(), (float) eulerAngle.getZ());
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public net.minecraft.core.Direction convertDirection(Direction direction) {
|
||||
return net.minecraft.core.Direction.from3DDataValue(direction.ordinal());
|
||||
}
|
||||
|
||||
public Material getMaterial(String name) {
|
||||
return CraftMagicNumbers.INSTANCE.getMaterial(name, CraftMagicNumbers.INSTANCE.getDataVersion());
|
||||
}
|
||||
|
||||
public String getItemName(Material material) {
|
||||
return Registry.ITEM.getKey(CraftMagicNumbers.getItem(material)).getPath();
|
||||
}
|
||||
|
||||
public net.minecraft.world.item.ItemStack getNmsItem(ItemStack itemStack) {
|
||||
return CraftItemStack.asNMSCopy(itemStack);
|
||||
}
|
||||
|
||||
public VillagerData getNmsVillagerData(Villager.Type villagerType, Villager.Profession villagerProfession) {
|
||||
VillagerType nmsVillagerType = Registry.VILLAGER_TYPE.get(CraftNamespacedKey.toMinecraft(villagerType.getKey()));
|
||||
VillagerProfession nmsVillagerProfession = Registry.VILLAGER_PROFESSION.get(CraftNamespacedKey.toMinecraft(villagerProfession.getKey()));
|
||||
|
||||
return new net.minecraft.world.entity.npc.VillagerData(nmsVillagerType, nmsVillagerProfession, 1);
|
||||
}
|
||||
|
||||
public VillagerType getVillagerType(Villager.Type type) {
|
||||
return Registry.VILLAGER_TYPE.get(CraftNamespacedKey.toMinecraft(type.getKey()));
|
||||
}
|
||||
|
||||
public VillagerProfession getVillagerProfession(Villager.Profession profession) {
|
||||
return Registry.VILLAGER_PROFESSION.get(CraftNamespacedKey.toMinecraft(profession.getKey()));
|
||||
}
|
||||
|
||||
public <T> SynchedEntityData.DataItem<T> createDataWatcherItem(WrappedDataWatcher.WrappedDataWatcherObject wrappedDataWatcherObject, T metaItem) {
|
||||
return new SynchedEntityData.DataItem<>((EntityDataAccessor<T>) wrappedDataWatcherObject.getHandle(), metaItem);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public SoundEvent createSoundEffect(String minecraftKey) {
|
||||
return new SoundEvent(new ResourceLocation(minecraftKey));
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResourceLocation createMinecraftKey(String name) {
|
||||
return new ResourceLocation(name);
|
||||
}
|
||||
|
||||
public Vec3 getVec3D(Vector vector) {
|
||||
return new Vec3(vector.getX(), vector.getY(), vector.getZ());
|
||||
}
|
||||
|
||||
public net.minecraft.world.entity.EntityType getEntityType(EntityType entityType) {
|
||||
return net.minecraft.world.entity.EntityType.byString(
|
||||
entityType.getName() == null ? entityType.name().toLowerCase(Locale.ENGLISH) : entityType.getName()).orElse(null);
|
||||
}
|
||||
|
||||
public Object registerEntityType(NamespacedKey key) {
|
||||
net.minecraft.world.entity.EntityType<net.minecraft.world.entity.Entity> newEntity =
|
||||
new net.minecraft.world.entity.EntityType<>(null, null, false, false, false, false, null, null, 0, 0);
|
||||
Registry.register(Registry.ENTITY_TYPE, CraftNamespacedKey.toMinecraft(key), newEntity);
|
||||
newEntity.getDescriptionId();
|
||||
return newEntity; // TODO ??? Some reflection in legacy that I'm unsure about
|
||||
}
|
||||
|
||||
public int getEntityTypeId(Object entityTypes) {
|
||||
net.minecraft.world.entity.EntityType entityType = (net.minecraft.world.entity.EntityType) entityTypes;
|
||||
return Registry.ENTITY_TYPE.getId(entityType);
|
||||
}
|
||||
|
||||
public int getEntityTypeId(EntityType entityType) {
|
||||
return getEntityTypeId(getEntityType(entityType));
|
||||
}
|
||||
|
||||
public Object getEntityType(NamespacedKey name) {
|
||||
return Registry.ENTITY_TYPE.get(CraftNamespacedKey.toMinecraft(name));
|
||||
}
|
||||
|
||||
public Object getNmsEntityPose(String enumPose) {
|
||||
return net.minecraft.world.entity.Pose.valueOf(enumPose);
|
||||
}
|
||||
|
||||
public int getCombinedIdByBlockData(BlockData data) {
|
||||
BlockState state = ((CraftBlockData) data).getState();
|
||||
return Block.getId(state);
|
||||
}
|
||||
|
||||
public int getCombinedIdByItemStack(ItemStack itemStack) {
|
||||
Block block = CraftMagicNumbers.getBlock(itemStack.getType());
|
||||
return Block.getId(block.defaultBlockState());
|
||||
}
|
||||
|
||||
public BlockData getBlockDataByCombinedId(int id) {
|
||||
return CraftBlockData.fromData(Block.stateById(id));
|
||||
}
|
||||
|
||||
public ItemStack getItemStackByCombinedId(int id) {
|
||||
return new ItemStack(CraftMagicNumbers.getMaterial(Block.stateById(id).getBlock()));
|
||||
}
|
||||
|
||||
public ServerLevel getWorldServer(World w) {
|
||||
return ((CraftWorld) w).getHandle();
|
||||
}
|
||||
|
||||
public ItemMeta getDeserializedItemMeta(Map<String, Object> meta) {
|
||||
try {
|
||||
Class<?> aClass = Class.forName("org.bukkit.craftbukkit.v1_18_R2.inventory.CraftMetaItem$SerializableMeta");
|
||||
Method deserialize = aClass.getDeclaredMethod("deserialize", Map.class);
|
||||
Object itemMeta = deserialize.invoke(null, meta);
|
||||
|
||||
return (ItemMeta) itemMeta;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
232
plugin/pom.xml
Normal file
232
plugin/pom.xml
Normal file
|
@ -0,0 +1,232 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<parent>
|
||||
<artifactId>parent</artifactId>
|
||||
<groupId>LibsDisguises</groupId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<artifactId>LibsDisguises</artifactId>
|
||||
<version>10.0.28-SNAPSHOT</version>
|
||||
|
||||
<properties>
|
||||
<maven.compiler.source>17</maven.compiler.source>
|
||||
<maven.compiler.target>17</maven.compiler.target>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
</properties>
|
||||
|
||||
<build>
|
||||
<defaultGoal>exec:java clean install</defaultGoal>
|
||||
<finalName>LibsDisguises</finalName>
|
||||
|
||||
<resources>
|
||||
<resource>
|
||||
<directory>src/main/resources</directory>
|
||||
<filtering>true</filtering>
|
||||
<includes>
|
||||
<include>plugin.yml</include>
|
||||
</includes>
|
||||
</resource>
|
||||
<resource>
|
||||
<directory>src/main/resources</directory>
|
||||
<filtering>false</filtering>
|
||||
<includes>
|
||||
<include>**/*</include>
|
||||
</includes>
|
||||
</resource>
|
||||
<resource>
|
||||
<directory>${project.basedir}</directory>
|
||||
<includes>
|
||||
<include>README.md</include>
|
||||
</includes>
|
||||
</resource>
|
||||
</resources>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-jar-plugin</artifactId>
|
||||
<version>2.3.1</version>
|
||||
<configuration>
|
||||
<outputDirectory>../target</outputDirectory>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<artifactId>maven-surefire-plugin</artifactId>
|
||||
<version>3.0.0-M5</version>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.codehaus.mojo</groupId>
|
||||
<artifactId>exec-maven-plugin</artifactId>
|
||||
<version>3.0.0</version>
|
||||
|
||||
<executions>
|
||||
<execution>
|
||||
<id>my-execution</id>
|
||||
<phase>compile</phase>
|
||||
<goals>
|
||||
<goal>java</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
<configuration>
|
||||
<includePluginDependencies>true</includePluginDependencies>
|
||||
<mainClass>me.libraryaddict.disguise.utilities.watchers.CompileMethods</mainClass>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-shade-plugin</artifactId>
|
||||
<version>3.3.0</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>shade</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
<configuration>
|
||||
<minimizeJar>true</minimizeJar>
|
||||
<filters>
|
||||
<filter>
|
||||
<artifact>LibsDisguises:*</artifact>
|
||||
<includes>
|
||||
<include>**</include>
|
||||
</includes>
|
||||
</filter>
|
||||
</filters>
|
||||
<artifactSet>
|
||||
<includes>
|
||||
<include>net.kyori:*</include>
|
||||
<include>LibsDisguises:*</include>
|
||||
</includes>
|
||||
</artifactSet>
|
||||
<relocations>
|
||||
<relocation>
|
||||
<pattern>net.kyori</pattern>
|
||||
<shadedPattern>ld-shaded.net.kyori</shadedPattern>
|
||||
</relocation>
|
||||
</relocations>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
<version>${lombok.version}</version>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.comphenix.protocol</groupId>
|
||||
<artifactId>ProtocolLib</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.spigotmc</groupId>
|
||||
<artifactId>spigot-api</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.spigotmc</groupId>
|
||||
<artifactId>spigot</artifactId>
|
||||
</dependency>
|
||||
<!-- testing -->
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
<version>${junit.version}</version>
|
||||
<scope>test</scope>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.destroystokyo.paper</groupId>
|
||||
<artifactId>paper-api</artifactId>
|
||||
<version>${paper-api.version}</version>
|
||||
<scope>provided</scope>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>net.md-5</groupId>
|
||||
<artifactId>bungeecord-chat</artifactId>
|
||||
<version>${bungeecord-chat.version}</version>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>net.kyori</groupId>
|
||||
<artifactId>adventure-text-minimessage</artifactId>
|
||||
<version>${adventure-minimessage.version}</version>
|
||||
<scope>compile</scope>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>net.kyori</groupId>
|
||||
<artifactId>adventure-text-serializer-gson</artifactId>
|
||||
<version>${adventure-serializer.version}</version>
|
||||
<scope>compile</scope>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>net.kyori</groupId>
|
||||
<artifactId>adventure-api</artifactId>
|
||||
<version>${adventure-api.version}</version>
|
||||
<scope>compile</scope>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
<!--NMS Packages-->
|
||||
<dependency>
|
||||
<groupId>LibsDisguises</groupId>
|
||||
<artifactId>shared</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
<scope>compile</scope>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>LibsDisguises</groupId>
|
||||
<artifactId>v1_17_R1</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
<classifier>remapped-spigot</classifier>
|
||||
<scope>compile</scope>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>LibsDisguises</groupId>
|
||||
<artifactId>v1_18_R1</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
<classifier>remapped-spigot</classifier>
|
||||
<scope>compile</scope>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>LibsDisguises</groupId>
|
||||
<artifactId>v1_18_R2</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
<classifier>remapped-spigot</classifier>
|
||||
<scope>compile</scope>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.mojang</groupId>
|
||||
<artifactId>datafixerupper</artifactId>
|
||||
<version>4.1.27</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.logging.log4j</groupId>
|
||||
<artifactId>log4j-core</artifactId>
|
||||
<version>2.17.2</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.netty</groupId>
|
||||
<artifactId>netty-all</artifactId>
|
||||
<version>4.1.76.Final</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
</project>
|
|
@ -0,0 +1,23 @@
|
|||
package me.libraryaddict.disguise;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import me.libraryaddict.disguise.disguisetypes.Disguise;
|
||||
import me.libraryaddict.disguise.disguisetypes.DisguiseType;
|
||||
import static me.libraryaddict.disguise.disguisetypes.DisguiseType.*;
|
||||
|
||||
public class BlockedDisguises
|
||||
{
|
||||
public static final List<DisguiseType> forbiddenDisguises = Arrays.asList(ITEM_FRAME, ENDER_DRAGON, PLAYER, GIANT, GHAST, DROPPED_ITEM, ENDER_CRYSTAL, AREA_EFFECT_CLOUD, WITHER);
|
||||
public static boolean disabled = false;
|
||||
|
||||
public static boolean isAllowed(Disguise disguise)
|
||||
{
|
||||
return isAllowed(disguise.getType());
|
||||
}
|
||||
|
||||
public static boolean isAllowed(DisguiseType type)
|
||||
{
|
||||
return !forbiddenDisguises.contains(type);
|
||||
}
|
||||
}
|
|
@ -1,36 +1,53 @@
|
|||
package me.libraryaddict.disguise;
|
||||
|
||||
import com.comphenix.protocol.wrappers.WrappedDataWatcher;
|
||||
import com.comphenix.protocol.wrappers.WrappedGameProfile;
|
||||
import me.libraryaddict.disguise.disguisetypes.*;
|
||||
import com.comphenix.protocol.wrappers.WrappedWatchableObject;
|
||||
import me.libraryaddict.disguise.disguisetypes.Disguise;
|
||||
import me.libraryaddict.disguise.disguisetypes.DisguiseType;
|
||||
import me.libraryaddict.disguise.disguisetypes.FlagWatcher;
|
||||
import me.libraryaddict.disguise.disguisetypes.MetaIndex;
|
||||
import me.libraryaddict.disguise.disguisetypes.MiscDisguise;
|
||||
import me.libraryaddict.disguise.disguisetypes.MobDisguise;
|
||||
import me.libraryaddict.disguise.disguisetypes.PlayerDisguise;
|
||||
import me.libraryaddict.disguise.disguisetypes.TargetedDisguise;
|
||||
import me.libraryaddict.disguise.disguisetypes.TargetedDisguise.TargetType;
|
||||
import me.libraryaddict.disguise.disguisetypes.watchers.AbstractHorseWatcher;
|
||||
import me.libraryaddict.disguise.disguisetypes.watchers.LivingWatcher;
|
||||
import me.libraryaddict.disguise.utilities.DisguiseUtilities;
|
||||
import me.libraryaddict.disguise.utilities.parser.DisguiseParseException;
|
||||
import me.libraryaddict.disguise.utilities.parser.DisguiseParser;
|
||||
import me.libraryaddict.disguise.utilities.parser.DisguisePerm;
|
||||
import me.libraryaddict.disguise.utilities.reflection.NmsVersion;
|
||||
import me.libraryaddict.disguise.utilities.reflection.ReflectionManager;
|
||||
import org.bukkit.DyeColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.bukkit.entity.*;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.EntityEquipment;
|
||||
import org.bukkit.inventory.HorseInventory;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.potion.PotionEffect;
|
||||
import org.bukkit.potion.PotionEffectType;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class DisguiseAPI {
|
||||
private static int selfDisguiseId = ReflectionManager.getNewEntityId(true);
|
||||
private static int selfDisguiseId;
|
||||
private static int entityAttachmentId;
|
||||
|
||||
public static int getEntityAttachmentId() {
|
||||
if (entityAttachmentId == 0) {
|
||||
entityAttachmentId = ReflectionManager.getNewEntityId();
|
||||
}
|
||||
|
||||
return entityAttachmentId;
|
||||
}
|
||||
|
||||
public static void addCustomDisguise(String disguiseName, String disguiseInfo) throws DisguiseParseException {
|
||||
// Dirty fix for anyone that somehow got this far with a . in the name, invalid yaml!
|
||||
|
@ -40,9 +57,10 @@ public class DisguiseAPI {
|
|||
DisguiseConfig.removeCustomDisguise(disguiseName);
|
||||
DisguiseConfig.addCustomDisguise(disguiseName, disguiseInfo);
|
||||
|
||||
File disguisesFile = new File("plugins/LibsDisguises/disguises.yml");
|
||||
File disguisesFile = new File(LibsDisguises.getInstance().getDataFolder(), "configs/disguises.yml");
|
||||
|
||||
if (!disguisesFile.exists()) {
|
||||
disguisesFile.getParentFile().mkdirs();
|
||||
disguisesFile.createNewFile();
|
||||
}
|
||||
|
||||
|
@ -53,13 +71,12 @@ public class DisguiseAPI {
|
|||
}
|
||||
|
||||
ConfigurationSection section = configuration.getConfigurationSection("Disguises");
|
||||
section.set(disguiseName, disguiseInfo);
|
||||
section.set(disguiseName, disguiseInfo.replace("\n", "\\n").replace("\r", "\\r"));
|
||||
|
||||
configuration.save(disguisesFile);
|
||||
|
||||
DisguiseUtilities.getLogger().info("Added new Custom Disguise " + disguiseName);
|
||||
}
|
||||
catch (IOException e) {
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
@ -71,8 +88,9 @@ public class DisguiseAPI {
|
|||
public static String getRawCustomDisguise(String disguiseName) {
|
||||
Map.Entry<DisguisePerm, String> entry = DisguiseConfig.getRawCustomDisguise(disguiseName);
|
||||
|
||||
if (entry == null)
|
||||
if (entry == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return entry.getValue();
|
||||
}
|
||||
|
@ -87,13 +105,15 @@ public class DisguiseAPI {
|
|||
return disguise.getValue();
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public static Disguise constructDisguise(Entity entity) {
|
||||
return constructDisguise(entity, true, true, true);
|
||||
public static void removeCustomDisguise(String disguiseName) {
|
||||
DisguiseConfig.removeCustomDisguise(disguiseName);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public static Disguise constructDisguise(Entity entity, boolean doEquipment, boolean doSneak, boolean doSprint) {
|
||||
public static Disguise constructDisguise(Entity entity) {
|
||||
return constructDisguise(entity, true, false);
|
||||
}
|
||||
|
||||
public static Disguise constructDisguise(Entity entity, boolean doEquipment, boolean displayExtraAnimations) {
|
||||
DisguiseType disguiseType = DisguiseType.getType(entity);
|
||||
Disguise disguise;
|
||||
|
||||
|
@ -107,100 +127,65 @@ public class DisguiseAPI {
|
|||
|
||||
FlagWatcher watcher = disguise.getWatcher();
|
||||
|
||||
if (entity instanceof LivingEntity) {
|
||||
for (PotionEffect effect : ((LivingEntity) entity).getActivePotionEffects()) {
|
||||
((LivingWatcher) watcher).addPotionEffect(effect.getType());
|
||||
|
||||
if (effect.getType() == PotionEffectType.INVISIBILITY) {
|
||||
watcher.setInvisible(true);
|
||||
} else if (effect.getType() == PotionEffectType.GLOWING) {
|
||||
watcher.setGlowing(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (entity.getFireTicks() > 0) {
|
||||
watcher.setBurning(true);
|
||||
}
|
||||
|
||||
if (doEquipment && entity instanceof LivingEntity) {
|
||||
EntityEquipment equip = ((LivingEntity) entity).getEquipment();
|
||||
|
||||
watcher.setArmor(equip.getArmorContents());
|
||||
watcher.setItemInMainHand(equip.getItemInMainHand());
|
||||
|
||||
if (disguiseType.getEntityType() == EntityType.HORSE) {
|
||||
Horse horse = (Horse) entity;
|
||||
HorseInventory horseInventory = horse.getInventory();
|
||||
ItemStack saddle = horseInventory.getSaddle();
|
||||
ItemStack mainItem = equip.getItemInMainHand();
|
||||
|
||||
if (saddle != null && saddle.getType() == Material.SADDLE) {
|
||||
((AbstractHorseWatcher) watcher).setSaddled(true);
|
||||
}
|
||||
if (mainItem != null && mainItem.getType() != Material.AIR) {
|
||||
watcher.setItemInMainHand(mainItem);
|
||||
}
|
||||
|
||||
ItemStack offItem = equip.getItemInMainHand();
|
||||
|
||||
if (offItem != null && offItem.getType() != Material.AIR) {
|
||||
watcher.setItemInOffHand(offItem);
|
||||
}
|
||||
}
|
||||
for (Method method : entity.getClass().getMethods()) {
|
||||
if ((doSneak || !method.getName().equals("setSneaking")) &&
|
||||
(doSprint || !method.getName().equals("setSprinting")) && method.getParameterTypes().length == 0 &&
|
||||
method.getReturnType() != void.class) {
|
||||
Class methodReturn = method.getReturnType();
|
||||
|
||||
if (methodReturn == float.class || methodReturn == Float.class || methodReturn == Double.class) {
|
||||
methodReturn = double.class;
|
||||
WrappedDataWatcher dataWatcher = WrappedDataWatcher.getEntityWatcher(entity);
|
||||
|
||||
for (WrappedWatchableObject obj : dataWatcher.getWatchableObjects()) {
|
||||
MetaIndex index = MetaIndex.getMetaIndex(watcher.getClass(), obj.getIndex());
|
||||
|
||||
if (index == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (index.getDefault() == obj.getValue() || index.getDefault() == obj.getRawValue()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
watcher.setUnsafeData(index, obj.getValue());
|
||||
|
||||
// Update the meta for 0, otherwise boolean be weird
|
||||
if (index == MetaIndex.ENTITY_META) {
|
||||
watcher.setSprinting(watcher.isSprinting() && displayExtraAnimations);
|
||||
watcher.setFlyingWithElytra(watcher.isFlyingWithElytra() && displayExtraAnimations);
|
||||
watcher.setSneaking(watcher.isSneaking() && displayExtraAnimations);
|
||||
watcher.setSwimming(watcher.isSwimming() && displayExtraAnimations);
|
||||
|
||||
if (!NmsVersion.v1_13.isSupported()) {
|
||||
watcher.setMainHandRaised(watcher.isMainHandRaised() && displayExtraAnimations);
|
||||
}
|
||||
|
||||
int firstCapitalMethod = firstCapital(method.getName());
|
||||
if (!displayExtraAnimations) {
|
||||
Arrays.fill(watcher.getModifiedEntityAnimations(), false);
|
||||
}
|
||||
|
||||
if (firstCapitalMethod > 0) {
|
||||
for (Method watcherMethod : watcher.getClass().getMethods()) {
|
||||
if (!watcherMethod.getName().startsWith("get") && watcherMethod.getReturnType() == void.class &&
|
||||
watcherMethod.getParameterTypes().length == 1) {
|
||||
int firstCapitalWatcher = firstCapital(watcherMethod.getName());
|
||||
watcher.setGlowing(watcher.isGlowing());
|
||||
watcher.setInvisible(watcher.isInvisible());
|
||||
} else if (index == MetaIndex.LIVING_META && NmsVersion.v1_13.isSupported()) {
|
||||
LivingWatcher livingWatcher = (LivingWatcher) watcher;
|
||||
|
||||
if (firstCapitalWatcher > 0 && method.getName().substring(firstCapitalMethod)
|
||||
.equalsIgnoreCase(watcherMethod.getName().substring(firstCapitalWatcher))) {
|
||||
Class methodParam = watcherMethod.getParameterTypes()[0];
|
||||
livingWatcher.setMainHandRaised(livingWatcher.isMainHandRaised() && displayExtraAnimations);
|
||||
livingWatcher.setOffhandRaised(livingWatcher.isOffhandRaised() && displayExtraAnimations);
|
||||
livingWatcher.setSpinning(livingWatcher.isSpinning() && displayExtraAnimations);
|
||||
|
||||
if (methodParam == float.class || methodParam == Float.class ||
|
||||
methodParam == Double.class) {
|
||||
methodParam = double.class;
|
||||
} else if (methodParam == AnimalColor.class) {
|
||||
methodParam = DyeColor.class;
|
||||
}
|
||||
if (methodReturn == methodParam) {
|
||||
try {
|
||||
Object value = method.invoke(entity);
|
||||
if (value != null) {
|
||||
Class toCast = watcherMethod.getParameterTypes()[0];
|
||||
if (!(toCast.isInstance(value))) {
|
||||
if (toCast == float.class) {
|
||||
if (!(value instanceof Float)) {
|
||||
double d = (Double) value;
|
||||
value = (float) d;
|
||||
}
|
||||
} else if (toCast == double.class) {
|
||||
if (!(value instanceof Double)) {
|
||||
float d = (Float) value;
|
||||
value = (double) d;
|
||||
}
|
||||
} else if (toCast == AnimalColor.class) {
|
||||
value = AnimalColor.valueOf(((DyeColor) value).name());
|
||||
}
|
||||
}
|
||||
if (value instanceof Boolean && !(Boolean) value &&
|
||||
watcherMethod.getDeclaringClass() == FlagWatcher.class) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
watcherMethod.invoke(watcher, value);
|
||||
}
|
||||
catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!displayExtraAnimations) {
|
||||
Arrays.fill(livingWatcher.getModifiedLivingAnimations(), false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -209,6 +194,10 @@ public class DisguiseAPI {
|
|||
}
|
||||
|
||||
public static void disguiseEntity(Entity entity, Disguise disguise) {
|
||||
disguiseEntity(null, entity, disguise);
|
||||
}
|
||||
|
||||
public static void disguiseEntity(CommandSender commandSender, Entity entity, Disguise disguise) {
|
||||
// If they are trying to disguise a null entity or use a null disguise
|
||||
// Just return.
|
||||
if (entity == null || disguise == null) {
|
||||
|
@ -228,10 +217,15 @@ public class DisguiseAPI {
|
|||
}
|
||||
|
||||
// They prefer to have the opposite of whatever the view disguises option is
|
||||
if (hasSelfDisguisePreference(entity) && disguise.isSelfDisguiseVisible() == DisguiseConfig.isViewDisguises())
|
||||
if (hasSelfDisguisePreference(entity) && disguise.isSelfDisguiseVisible() == DisguiseConfig.isViewSelfDisguisesDefault()) {
|
||||
disguise.setViewSelfDisguise(!disguise.isSelfDisguiseVisible());
|
||||
}
|
||||
|
||||
disguise.startDisguise();
|
||||
if (hasActionBarPreference(entity) && !isNotifyBarShown(entity)) {
|
||||
disguise.setNotifyBar(DisguiseConfig.NotifyBar.NONE);
|
||||
}
|
||||
|
||||
disguise.startDisguise(commandSender);
|
||||
}
|
||||
|
||||
public static void disguiseIgnorePlayers(Entity entity, Disguise disguise, Collection playersToNotSeeDisguise) {
|
||||
|
@ -300,7 +294,7 @@ public class DisguiseAPI {
|
|||
// You called the disguiseToAll method foolish mortal! Prepare to have your custom settings wiped!!!
|
||||
((TargetedDisguise) disguise).setDisguiseTarget(TargetType.SHOW_TO_EVERYONE_BUT_THESE_PLAYERS);
|
||||
|
||||
for (String observer : ((TargetedDisguise) disguise).getObservers()) {
|
||||
for (String observer : new ArrayList<>(((TargetedDisguise) disguise).getObservers())) {
|
||||
((TargetedDisguise) disguise).removePlayer(observer);
|
||||
}
|
||||
|
||||
|
@ -359,7 +353,7 @@ public class DisguiseAPI {
|
|||
return null;
|
||||
}
|
||||
|
||||
return DisguiseUtilities.getMainDisguise(disguised.getUniqueId());
|
||||
return DisguiseUtilities.getMainDisguise(disguised.getEntityId());
|
||||
}
|
||||
|
||||
public static String parseToString(Disguise disguise, boolean outputSkin) {
|
||||
|
@ -396,10 +390,14 @@ public class DisguiseAPI {
|
|||
return null;
|
||||
}
|
||||
|
||||
return DisguiseUtilities.getDisguises(disguised.getUniqueId());
|
||||
return DisguiseUtilities.getDisguises(disguised.getEntityId());
|
||||
}
|
||||
|
||||
public static int getSelfDisguiseId() {
|
||||
if (selfDisguiseId == 0) {
|
||||
selfDisguiseId = ReflectionManager.getNewEntityId();
|
||||
}
|
||||
|
||||
return selfDisguiseId;
|
||||
}
|
||||
|
||||
|
@ -439,11 +437,33 @@ public class DisguiseAPI {
|
|||
* @return
|
||||
*/
|
||||
public static boolean isViewSelfToggled(Entity entity) {
|
||||
return hasSelfDisguisePreference(entity) != DisguiseConfig.isViewDisguises();
|
||||
return hasSelfDisguisePreference(entity) != DisguiseConfig.isViewSelfDisguisesDefault();
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public static boolean isActionBarShown(Entity entity) {
|
||||
return isNotifyBarShown(entity);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the entity wants to see the action bar / boss bar
|
||||
*
|
||||
* @param entity
|
||||
* @return
|
||||
*/
|
||||
public static boolean isNotifyBarShown(Entity entity) {
|
||||
// If default is no notify bar, but they toggled it. Then we want to show it.
|
||||
// If default is a notify bar, but they toggled it. Then we want to hide it.
|
||||
|
||||
return (DisguiseConfig.getNotifyBar() == DisguiseConfig.NotifyBar.NONE) == hasActionBarPreference(entity);
|
||||
}
|
||||
|
||||
public static boolean hasSelfDisguisePreference(Entity entity) {
|
||||
return Disguise.getViewSelf().contains(entity.getUniqueId());
|
||||
return DisguiseUtilities.getViewSelf().contains(entity.getUniqueId());
|
||||
}
|
||||
|
||||
public static boolean hasActionBarPreference(Entity entity) {
|
||||
return DisguiseUtilities.getViewBar().contains(entity.getUniqueId());
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -454,10 +474,21 @@ public class DisguiseAPI {
|
|||
* @param entity
|
||||
*/
|
||||
public static void undisguiseToAll(Entity entity) {
|
||||
undisguiseToAll(null, entity);
|
||||
}
|
||||
|
||||
/**
|
||||
* Undisguise the entity. This doesn't let you cancel the UndisguiseEvent if the entity is no longer valid. Aka
|
||||
* removed from
|
||||
* the world.
|
||||
*
|
||||
* @param entity
|
||||
*/
|
||||
public static void undisguiseToAll(CommandSender sender, Entity entity) {
|
||||
Disguise[] disguises = getDisguises(entity);
|
||||
|
||||
for (Disguise disguise : disguises) {
|
||||
disguise.removeDisguise();
|
||||
disguise.removeDisguise(sender);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -476,12 +507,35 @@ public class DisguiseAPI {
|
|||
}
|
||||
}
|
||||
|
||||
if (!canSeeSelfDisguises == DisguiseConfig.isViewDisguises()) {
|
||||
if (!canSeeSelfDisguises == DisguiseConfig.isViewSelfDisguisesDefault()) {
|
||||
if (!hasSelfDisguisePreference(entity)) {
|
||||
Disguise.getViewSelf().add(entity.getUniqueId());
|
||||
DisguiseUtilities.getViewSelf().add(entity.getUniqueId());
|
||||
DisguiseUtilities.addSaveAttempt();
|
||||
}
|
||||
} else {
|
||||
Disguise.getViewSelf().remove(entity.getUniqueId());
|
||||
DisguiseUtilities.getViewSelf().remove(entity.getUniqueId());
|
||||
DisguiseUtilities.addSaveAttempt();
|
||||
}
|
||||
}
|
||||
|
||||
public static void setActionBarShown(Player player, boolean isShown) {
|
||||
if (isDisguised(player)) {
|
||||
Disguise[] disguises = getDisguises(player);
|
||||
|
||||
for (Disguise disguise : disguises) {
|
||||
disguise.setNotifyBar(isShown ? DisguiseConfig.getNotifyBar() : DisguiseConfig.NotifyBar.NONE);
|
||||
}
|
||||
}
|
||||
|
||||
// If default is view and we want the opposite
|
||||
if (!isShown) {
|
||||
if (!hasActionBarPreference(player)) {
|
||||
DisguiseUtilities.getViewBar().add(player.getUniqueId());
|
||||
DisguiseUtilities.addSaveAttempt();
|
||||
}
|
||||
} else {
|
||||
DisguiseUtilities.getViewBar().remove(player.getUniqueId());
|
||||
DisguiseUtilities.addSaveAttempt();
|
||||
}
|
||||
}
|
||||
|
|
@ -4,9 +4,9 @@ import lombok.AccessLevel;
|
|||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import me.libraryaddict.disguise.disguisetypes.Disguise;
|
||||
import me.libraryaddict.disguise.disguisetypes.TargetedDisguise;
|
||||
import me.libraryaddict.disguise.utilities.DisguiseUtilities;
|
||||
import me.libraryaddict.disguise.utilities.LibsPremium;
|
||||
import me.libraryaddict.disguise.utilities.config.ConfigLoader;
|
||||
import me.libraryaddict.disguise.utilities.modded.ModdedEntity;
|
||||
import me.libraryaddict.disguise.utilities.modded.ModdedManager;
|
||||
import me.libraryaddict.disguise.utilities.packets.PacketsManager;
|
||||
|
@ -17,32 +17,32 @@ import me.libraryaddict.disguise.utilities.reflection.NmsVersion;
|
|||
import me.libraryaddict.disguise.utilities.reflection.ReflectionManager;
|
||||
import me.libraryaddict.disguise.utilities.translations.LibsMsg;
|
||||
import me.libraryaddict.disguise.utilities.translations.TranslateType;
|
||||
import org.apache.commons.lang.StringEscapeUtils;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.NamespacedKey;
|
||||
import org.bukkit.boss.BarColor;
|
||||
import org.bukkit.boss.BarStyle;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.permissions.Permission;
|
||||
import org.bukkit.permissions.PermissionDefault;
|
||||
import org.bukkit.scheduler.BukkitTask;
|
||||
|
||||
import java.io.*;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.util.*;
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
import java.io.PrintWriter;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.Locale;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Random;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
public class DisguiseConfig {
|
||||
@Getter
|
||||
@Setter
|
||||
private static DisguisePushing pushingOption = DisguisePushing.MODIFY_SCOREBOARD;
|
||||
@Getter
|
||||
@Setter
|
||||
private static HashMap<DisguisePerm, String> customDisguises = new HashMap<>();
|
||||
|
@ -61,12 +61,6 @@ public class DisguiseConfig {
|
|||
@Getter
|
||||
@Setter
|
||||
private static boolean collectPacketsEnabled;
|
||||
/**
|
||||
* No setter provided as this cannot be changed after startup
|
||||
*/
|
||||
@Setter(value = AccessLevel.PRIVATE)
|
||||
@Getter
|
||||
private static boolean disableCommands;
|
||||
@Getter
|
||||
@Setter
|
||||
private static boolean disableFriendlyInvisibles;
|
||||
|
@ -99,6 +93,9 @@ public class DisguiseConfig {
|
|||
private static boolean hidingArmorFromSelf;
|
||||
@Getter
|
||||
@Setter
|
||||
private static boolean hidingCreativeEquipmentFromSelf;
|
||||
@Getter
|
||||
@Setter
|
||||
private static boolean hidingHeldItemFromSelf;
|
||||
@Getter
|
||||
@Setter
|
||||
|
@ -195,9 +192,6 @@ public class DisguiseConfig {
|
|||
private static int maxClonedDisguises;
|
||||
@Getter
|
||||
@Setter
|
||||
private static int playerDisguisesTablistExpires;
|
||||
@Getter
|
||||
@Setter
|
||||
private static int uuidGeneratedVersion;
|
||||
@Getter
|
||||
@Setter
|
||||
|
@ -231,7 +225,7 @@ public class DisguiseConfig {
|
|||
@Getter
|
||||
private static String savedServerIp = "";
|
||||
@Getter
|
||||
private static boolean autoUpdate;
|
||||
private static Boolean autoUpdate;
|
||||
@Getter
|
||||
private static boolean notifyUpdate;
|
||||
private static BukkitTask updaterTask;
|
||||
|
@ -247,6 +241,46 @@ public class DisguiseConfig {
|
|||
@Getter
|
||||
@Setter
|
||||
private static boolean randomDisguises;
|
||||
@Getter
|
||||
@Setter
|
||||
private static boolean loginPayloadPackets;
|
||||
@Getter
|
||||
@Setter
|
||||
private static boolean saveUserPreferences;
|
||||
@Getter
|
||||
private static long lastUpdateRequest;
|
||||
@Getter
|
||||
private static boolean hittingRateLimit;
|
||||
@Getter
|
||||
@Setter
|
||||
private static boolean copyPlayerTeamInfo;
|
||||
@Getter
|
||||
@Setter
|
||||
private static String nameAboveDisguise;
|
||||
@Getter
|
||||
@Setter
|
||||
private static int playerDisguisesSkinExpiresMove;
|
||||
@Getter
|
||||
@Setter
|
||||
private static boolean viewSelfDisguisesDefault;
|
||||
@Getter
|
||||
@Setter
|
||||
private static String lastGithubUpdateETag;
|
||||
@Getter
|
||||
@Setter
|
||||
private static String lastPluginUpdateVersion;
|
||||
@Getter
|
||||
@Setter
|
||||
private static boolean contactMojangServers;
|
||||
@Getter
|
||||
@Setter(AccessLevel.PROTECTED)
|
||||
private static int disguiseRadiusMax;
|
||||
@Getter
|
||||
@Setter
|
||||
private static String data;
|
||||
@Getter
|
||||
@Setter
|
||||
private static boolean randomUUIDS;
|
||||
|
||||
public static boolean isArmorstandsName() {
|
||||
return getPlayerNameType() == PlayerNameType.ARMORSTANDS;
|
||||
|
@ -256,6 +290,14 @@ public class DisguiseConfig {
|
|||
return getPlayerNameType() == PlayerNameType.EXTENDED;
|
||||
}
|
||||
|
||||
public static boolean isAutoUpdate() {
|
||||
if (getAutoUpdate() == null) {
|
||||
autoUpdate = LibsDisguises.getInstance().getConfig().getBoolean("AutoUpdate");
|
||||
}
|
||||
|
||||
return getAutoUpdate();
|
||||
}
|
||||
|
||||
public static void setAutoUpdate(boolean update) {
|
||||
if (isAutoUpdate() == update) {
|
||||
return;
|
||||
|
@ -274,27 +316,24 @@ public class DisguiseConfig {
|
|||
doUpdaterTask();
|
||||
}
|
||||
|
||||
public static void setLastUpdateRequest(long lastRequest) {
|
||||
if (lastRequest <= getLastUpdateRequest()) {
|
||||
return;
|
||||
}
|
||||
|
||||
lastUpdateRequest = lastRequest;
|
||||
saveInternalConfig();
|
||||
}
|
||||
|
||||
private static void doUpdaterTask() {
|
||||
boolean startTask = isAutoUpdate() || isNotifyUpdate();
|
||||
boolean startTask = isAutoUpdate() || isNotifyUpdate() ||
|
||||
"1592".equals((LibsPremium.getPaidInformation() == null ? LibsPremium.getPluginInformation() : LibsPremium.getPaidInformation()).getUserID());
|
||||
|
||||
// Don't ever run the auto updater on a custom build..
|
||||
if (!LibsDisguises.getInstance().isNumberedBuild()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!LibsDisguises.getInstance().getConfig().getDefaults().getBoolean("AutoUpdate")) {
|
||||
updaterTask = Bukkit.getScheduler().runTaskTimer(LibsDisguises.getInstance(), new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
for (Set<TargetedDisguise> disguises : DisguiseUtilities.getDisguises().values()){
|
||||
for (Disguise disguise : disguises) {
|
||||
disguise.getWatcher().setSprinting(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}, TimeUnit.HOURS.toSeconds(1)*20, (20 * TimeUnit.MINUTES.toSeconds(10)));
|
||||
}
|
||||
|
||||
if (updaterTask == null != startTask) {
|
||||
return;
|
||||
}
|
||||
|
@ -305,12 +344,20 @@ public class DisguiseConfig {
|
|||
return;
|
||||
}
|
||||
|
||||
int timer = (int) (TimeUnit.HOURS.toSeconds(isHittingRateLimit() ? 36 : 12) * 20);
|
||||
|
||||
// Get the ticks since last update
|
||||
long timeSinceLast = (System.currentTimeMillis() - getLastUpdateRequest()) / 50;
|
||||
|
||||
// Next update check will be in 30 minutes, or the timer - elapsed time. Whatever is greater
|
||||
timeSinceLast = Math.max(30 * 60 * 20, timer - timeSinceLast);
|
||||
|
||||
updaterTask = Bukkit.getScheduler().runTaskTimerAsynchronously(LibsDisguises.getInstance(), new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
LibsDisguises.getInstance().getUpdateChecker().doAutoUpdateCheck();
|
||||
}
|
||||
}, 0, (20 * TimeUnit.HOURS.toSeconds(6))); // Check every 6 hours
|
||||
}, timeSinceLast, timer);
|
||||
}
|
||||
|
||||
public static void setUsingReleaseBuilds(boolean useReleaseBuilds) {
|
||||
|
@ -322,6 +369,16 @@ public class DisguiseConfig {
|
|||
saveInternalConfig();
|
||||
}
|
||||
|
||||
public static void setHittingRateLimit(boolean hitRateLimit) {
|
||||
if (hitRateLimit == isHittingRateLimit()) {
|
||||
return;
|
||||
}
|
||||
|
||||
hittingRateLimit = hitRateLimit;
|
||||
saveInternalConfig();
|
||||
doUpdaterTask();
|
||||
}
|
||||
|
||||
public static void setBisectHosted(boolean isBisectHosted, String serverIP) {
|
||||
if (isBisectHosted() == isBisectHosted && getSavedServerIp().equals(serverIP)) {
|
||||
return;
|
||||
|
@ -344,9 +401,13 @@ public class DisguiseConfig {
|
|||
bisectHosted = configuration.getBoolean("Bisect-Hosted", isBisectHosted());
|
||||
savedServerIp = configuration.getString("Server-IP", getSavedServerIp());
|
||||
usingReleaseBuild = configuration.getBoolean("ReleaseBuild", isUsingReleaseBuild());
|
||||
lastUpdateRequest = configuration.getLong("LastUpdateRequest", 0L);
|
||||
hittingRateLimit = configuration.getBoolean("HittingRateLimit", false);
|
||||
lastGithubUpdateETag = configuration.getString("LastGithubETag", null);
|
||||
lastPluginUpdateVersion = configuration.getString("LastPluginVersion", null);
|
||||
data = configuration.getString("Data", null);
|
||||
|
||||
if (!configuration.contains("Bisect-Hosted") || !configuration.contains("Server-IP") ||
|
||||
!configuration.contains("ReleaseBuild")) {
|
||||
if (!configuration.contains("Bisect-Hosted") || !configuration.contains("Server-IP") || !configuration.contains("ReleaseBuild")) {
|
||||
saveInternalConfig();
|
||||
}
|
||||
}
|
||||
|
@ -354,11 +415,11 @@ public class DisguiseConfig {
|
|||
public static void saveInternalConfig() {
|
||||
File internalFile = new File(LibsDisguises.getInstance().getDataFolder(), "internal.yml");
|
||||
|
||||
String internalConfig = ReflectionManager
|
||||
.getResourceAsString(LibsDisguises.getInstance().getFile(), "internal.yml");
|
||||
String internalConfig = ReflectionManager.getResourceAsString(LibsDisguises.getInstance().getFile(), "internal.yml");
|
||||
|
||||
// Bisect hosted, server ip, release builds
|
||||
for (Object s : new Object[]{isBisectHosted(), getSavedServerIp(), isUsingReleaseBuild()}) {
|
||||
for (Object s : new Object[]{isBisectHosted(), getSavedServerIp(), isUsingReleaseBuild(), getLastUpdateRequest(), isHittingRateLimit(),
|
||||
getLastGithubUpdateETag(), getLastPluginUpdateVersion(), getData()}) {
|
||||
internalConfig = internalConfig.replaceFirst("%data%", "" + s);
|
||||
}
|
||||
|
||||
|
@ -366,15 +427,13 @@ public class DisguiseConfig {
|
|||
|
||||
try {
|
||||
internalFile.createNewFile();
|
||||
}
|
||||
catch (IOException e) {
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
try (PrintWriter writer = new PrintWriter(internalFile, "UTF-8")) {
|
||||
writer.write(internalConfig);
|
||||
}
|
||||
catch (FileNotFoundException | UnsupportedEncodingException e) {
|
||||
} catch (FileNotFoundException | UnsupportedEncodingException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
@ -412,9 +471,7 @@ public class DisguiseConfig {
|
|||
|
||||
public static Entry<DisguisePerm, Disguise> getCustomDisguise(String disguise) {
|
||||
if (!Bukkit.isPrimaryThread()) {
|
||||
DisguiseUtilities.getLogger().warning(
|
||||
"Custom Disguises should not be called async! This operation will become impossible in the " +
|
||||
"future!");
|
||||
throw new IllegalStateException("Custom Disguises should not be called async!");
|
||||
}
|
||||
|
||||
Entry<DisguisePerm, String> entry = getRawCustomDisguise(disguise);
|
||||
|
@ -425,8 +482,7 @@ public class DisguiseConfig {
|
|||
|
||||
try {
|
||||
return new HashMap.SimpleEntry(entry.getKey(), DisguiseParser.parseDisguise(entry.getValue()));
|
||||
}
|
||||
catch (IllegalAccessException | InvocationTargetException | DisguiseParseException e) {
|
||||
} catch (Throwable e) {
|
||||
DisguiseUtilities.getLogger().warning("Error when attempting to grab the custom disguise " + disguise);
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
@ -434,12 +490,9 @@ public class DisguiseConfig {
|
|||
return null;
|
||||
}
|
||||
|
||||
public static Entry<DisguisePerm, Disguise> getCustomDisguise(Entity target,
|
||||
String disguise) throws IllegalAccessException, DisguiseParseException, InvocationTargetException {
|
||||
public static Entry<DisguisePerm, Disguise> getCustomDisguise(Entity target, String disguise) throws Throwable {
|
||||
if (!Bukkit.isPrimaryThread()) {
|
||||
DisguiseUtilities.getLogger().warning(
|
||||
"Custom Disguises should not be called async! This operation will become impossible in the " +
|
||||
"future!");
|
||||
throw new IllegalStateException("Custom Disguises should not be called async!");
|
||||
}
|
||||
|
||||
Entry<DisguisePerm, String> entry = getRawCustomDisguise(disguise);
|
||||
|
@ -448,16 +501,12 @@ public class DisguiseConfig {
|
|||
return null;
|
||||
}
|
||||
|
||||
return new HashMap.SimpleEntry(entry.getKey(),
|
||||
DisguiseParser.parseDisguise(Bukkit.getConsoleSender(), target, entry.getValue()));
|
||||
return new HashMap.SimpleEntry(entry.getKey(), DisguiseParser.parseDisguise(Bukkit.getConsoleSender(), target, entry.getValue()));
|
||||
}
|
||||
|
||||
public static Entry<DisguisePerm, Disguise> getCustomDisguise(CommandSender invoker, Entity target,
|
||||
String disguise) throws IllegalAccessException, DisguiseParseException, InvocationTargetException {
|
||||
public static Entry<DisguisePerm, Disguise> getCustomDisguise(CommandSender invoker, Entity target, String disguise) throws Throwable {
|
||||
if (!Bukkit.isPrimaryThread()) {
|
||||
DisguiseUtilities.getLogger().warning(
|
||||
"Custom Disguises should not be called async! This operation will become impossible in the " +
|
||||
"future!");
|
||||
throw new IllegalStateException("Custom Disguises should not be called async!");
|
||||
}
|
||||
|
||||
Entry<DisguisePerm, String> entry = getRawCustomDisguise(disguise);
|
||||
|
@ -477,8 +526,9 @@ public class DisguiseConfig {
|
|||
for (DisguisePerm entry : customDisguises.keySet()) {
|
||||
String name = entry.toReadable();
|
||||
|
||||
if (!name.equalsIgnoreCase(disguise) && !name.replaceAll("_", "").equalsIgnoreCase(disguise))
|
||||
if (!name.equalsIgnoreCase(disguise) && !name.replaceAll("_", "").equalsIgnoreCase(disguise)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
customDisguises.remove(entry);
|
||||
break;
|
||||
|
@ -489,8 +539,9 @@ public class DisguiseConfig {
|
|||
for (Entry<DisguisePerm, String> entry : customDisguises.entrySet()) {
|
||||
String name = entry.getKey().toReadable();
|
||||
|
||||
if (!name.equalsIgnoreCase(disguise) && !name.replaceAll("_", "").equalsIgnoreCase(disguise))
|
||||
if (!name.equalsIgnoreCase(disguise) && !name.replaceAll("_", "").equalsIgnoreCase(disguise)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
return entry;
|
||||
}
|
||||
|
@ -504,78 +555,9 @@ public class DisguiseConfig {
|
|||
TranslateType.refreshTranslations();
|
||||
}
|
||||
|
||||
public static void saveDefaultConfig() {
|
||||
DisguiseUtilities.getLogger().info("Config is out of date! Now updating it!");
|
||||
String[] string = ReflectionManager.getResourceAsString(LibsDisguises.getInstance().getFile(), "config.yml")
|
||||
.split("\n");
|
||||
FileConfiguration savedConfig = LibsDisguises.getInstance().getConfig();
|
||||
|
||||
StringBuilder section = new StringBuilder();
|
||||
|
||||
for (int i = 0; i < string.length; i++) {
|
||||
String s = string[i];
|
||||
|
||||
if (s.trim().startsWith("#") || !s.contains(":")) {
|
||||
continue;
|
||||
}
|
||||
|
||||
String rawKey = s.split(":")[0];
|
||||
|
||||
if (section.length() > 0) {
|
||||
int matches = StringUtils.countMatches(rawKey, " ");
|
||||
|
||||
int allowed = 0;
|
||||
|
||||
for (int a = 0; a < matches; a++) {
|
||||
allowed = section.indexOf(".", allowed) + 1;
|
||||
}
|
||||
|
||||
section = new StringBuilder(section.substring(0, allowed));
|
||||
}
|
||||
|
||||
String key = (rawKey.startsWith(" ") ? section.toString() : "") + rawKey.trim();
|
||||
|
||||
if (savedConfig.isConfigurationSection(key)) {
|
||||
section.append(key).append(".");
|
||||
} else if (savedConfig.isSet(key)) {
|
||||
String rawVal = s.split(":")[1].trim();
|
||||
Object val = savedConfig.get(key);
|
||||
|
||||
if (savedConfig.isString(key) && !rawVal.equals("true") && !rawVal.equals("false")) {
|
||||
val = "'" + StringEscapeUtils.escapeJava(val.toString().replace(ChatColor.COLOR_CHAR + "", "&")) +
|
||||
"'";
|
||||
}
|
||||
|
||||
string[i] = rawKey + ": " + val;
|
||||
}
|
||||
}
|
||||
|
||||
File config = new File(LibsDisguises.getInstance().getDataFolder(), "config.yml");
|
||||
|
||||
try {
|
||||
if (config.exists()) {
|
||||
config.renameTo(new File(config.getParentFile(), "config-old.yml"));
|
||||
|
||||
DisguiseUtilities.getLogger().info("Old config has been copied to config-old.yml");
|
||||
}
|
||||
|
||||
config.createNewFile();
|
||||
|
||||
try (PrintWriter out = new PrintWriter(config)) {
|
||||
out.write(StringUtils.join(string, "\n"));
|
||||
}
|
||||
}
|
||||
catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public static void loadConfig() {
|
||||
// Always save the default config
|
||||
LibsDisguises.getInstance().saveDefaultConfig();
|
||||
// Redundant for the first load, however other plugins may call loadConfig() at a later stage where we
|
||||
// definitely want to reload it.
|
||||
LibsDisguises.getInstance().reloadConfig();
|
||||
ConfigLoader configLoader = new ConfigLoader();
|
||||
configLoader.saveMissingConfigs();
|
||||
|
||||
loadModdedDisguiseTypes();
|
||||
|
||||
|
@ -590,19 +572,16 @@ public class DisguiseConfig {
|
|||
explain.createNewFile();
|
||||
|
||||
try (PrintWriter out = new PrintWriter(explain)) {
|
||||
out.println("This folder is used to store .png files for uploading with the /savedisguise or " +
|
||||
"/grabskin " + "commands");
|
||||
out.println("This folder is used to store .png files for uploading with the /savedisguise or " + "/grabskin " + "commands");
|
||||
}
|
||||
}
|
||||
catch (IOException e) {
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
ConfigurationSection config = LibsDisguises.getInstance().getConfig();
|
||||
ConfigurationSection config = configLoader.load();
|
||||
|
||||
PacketsManager.setViewDisguisesListener(true);
|
||||
disableCommands = config.getBoolean("DisableCommands");
|
||||
|
||||
setAddEntityAnimations(config.getBoolean("AddEntityAnimations"));
|
||||
setAnimationPacketsEnabled(config.getBoolean("PacketsEnabled.Animation"));
|
||||
|
@ -613,10 +592,8 @@ public class DisguiseConfig {
|
|||
setDisablePvP(config.getBoolean("DisablePvP"));
|
||||
setDisablePvE(config.getBoolean("DisablePvE"));
|
||||
setPvPTimer(config.getDouble("PvPTimer"));
|
||||
setDisguiseBlownWhenAttacked(
|
||||
config.getBoolean("BlowDisguises", config.getBoolean("BlowDisguisesWhenAttacked")));
|
||||
setDisguiseBlownWhenAttacking(
|
||||
config.getBoolean("BlowDisguises", config.getBoolean("BlowDisguisesWhenAttacking")));
|
||||
setDisguiseBlownWhenAttacked(config.getBoolean("BlowDisguisesWhenAttacked"));
|
||||
setDisguiseBlownWhenAttacking(config.getBoolean("BlowDisguisesWhenAttacking"));
|
||||
setDisguiseCloneExpire(config.getInt("DisguiseCloneExpire"));
|
||||
setDisguiseEntityExpire(config.getInt("DisguiseEntityExpire"));
|
||||
setDynamicExpiry(config.getBoolean("DynamicExpiry"));
|
||||
|
@ -624,6 +601,7 @@ public class DisguiseConfig {
|
|||
setEquipmentPacketsEnabled(config.getBoolean("PacketsEnabled.Equipment"));
|
||||
setExplicitDisguisePermissions(config.getBoolean("Permissions.ExplicitDisguises"));
|
||||
setHideArmorFromSelf(config.getBoolean("RemoveArmor"));
|
||||
setHidingCreativeEquipmentFromSelf(config.getBoolean("RemoveCreativeEquipment"));
|
||||
setHideDisguisedPlayers(config.getBoolean("HideDisguisedPlayersFromTab"));
|
||||
setHideHeldItemFromSelf(config.getBoolean("RemoveHeldItem"));
|
||||
setHorseSaddleable(config.getBoolean("SaddleableHorse"));
|
||||
|
@ -632,6 +610,7 @@ public class DisguiseConfig {
|
|||
setMaxClonedDisguises(config.getInt("DisguiseCloneSize"));
|
||||
setMaxHealthDeterminedByDisguisedEntity(config.getBoolean("MaxHealthDeterminedByEntity"));
|
||||
setMetaPacketsEnabled(config.getBoolean("PacketsEnabled.Metadata"));
|
||||
setLoginPayloadPackets(config.getBoolean("PacketsEnabled.LoginPayload"));
|
||||
setMiscDisguisesForLivingEnabled(config.getBoolean("MiscDisguisesForLiving"));
|
||||
setModifyBoundingBox(config.getBoolean("ModifyBoundingBox"));
|
||||
setModifyCollisions(config.getBoolean("Scoreboard.Collisions"));
|
||||
|
@ -639,7 +618,7 @@ public class DisguiseConfig {
|
|||
setMovementPacketsEnabled(config.getBoolean("PacketsEnabled.Movement"));
|
||||
setNameAboveHeadAlwaysVisible(config.getBoolean("NameAboveHeadAlwaysVisible"));
|
||||
setNameOfPlayerShownAboveDisguise(config.getBoolean("ShowNamesAboveDisguises"));
|
||||
setPlayerDisguisesTablistExpires(config.getInt("PlayerDisguisesTablistExpiry"));
|
||||
setNameAboveDisguise(config.getString("NameAboveDisguise"));
|
||||
setPlayerHideArmor(config.getBoolean("PlayerHideArmor"));
|
||||
setRetaliationCombat(config.getBoolean("RetaliationCombat"));
|
||||
setSaveGameProfiles(config.getBoolean("SaveGameProfiles"));
|
||||
|
@ -657,6 +636,7 @@ public class DisguiseConfig {
|
|||
setVelocitySent(config.getBoolean("SendVelocity"));
|
||||
setViewDisguises(config.getBoolean("ViewSelfDisguises"));
|
||||
setWarnScoreboardConflict(config.getBoolean("Scoreboard.WarnConflict"));
|
||||
setCopyPlayerTeamInfo(config.getBoolean("Scoreboard.CopyPlayerTeamInfo"));
|
||||
setWitherSkullPacketsEnabled(config.getBoolean("PacketsEnabled.WitherSkull"));
|
||||
setWolfDyeable(config.getBoolean("DyeableWolf"));
|
||||
setTablistRemoveDelay(config.getInt("TablistRemoveDelay"));
|
||||
|
@ -664,78 +644,67 @@ public class DisguiseConfig {
|
|||
setTallSelfDisguises(config.getBoolean("TallSelfDisguises"));
|
||||
setOverrideCustomNames(config.getBoolean("OverrideCustomNames"));
|
||||
setRandomDisguises(config.getBoolean("RandomDisguiseOptions"));
|
||||
setSaveUserPreferences(config.getBoolean("SaveUserPreferences"));
|
||||
setPlayerDisguisesSkinExpiresMove(config.getInt("PlayerDisguisesTablistExpiresMove"));
|
||||
setViewSelfDisguisesDefault(config.getBoolean("ViewSelfDisguisesDefault"));
|
||||
setContactMojangServers(config.getBoolean("ContactMojangServers"));
|
||||
setDisguiseRadiusMax(config.getInt("DisguiseRadiusMax"));
|
||||
setRandomUUIDS(config.getBoolean("RandomUUIDs"));
|
||||
String apiKey = config.getString("MineSkinAPIKey");
|
||||
|
||||
if (apiKey != null && apiKey.matches("[a-zA-Z0-9]{8,}")) {
|
||||
DisguiseUtilities.getMineSkinAPI().setApiKey(apiKey);
|
||||
} else if (apiKey != null && apiKey.length() > 8) {
|
||||
DisguiseUtilities.getLogger().warning("API Key provided for MineSkin does not appear to be in a valid format!");
|
||||
}
|
||||
|
||||
if (!LibsPremium.isPremium() && (isSavePlayerDisguises() || isSaveEntityDisguises())) {
|
||||
DisguiseUtilities.getLogger().warning("You must purchase the plugin to use saved disguises!");
|
||||
}
|
||||
|
||||
try {
|
||||
setPlayerNameType(PlayerNameType.valueOf(config.getString("PlayerNames").toUpperCase()));
|
||||
}
|
||||
catch (Exception ex) {
|
||||
DisguiseUtilities.getLogger().warning(
|
||||
"Cannot parse '" + config.getString("PlayerNames") + "' to a valid option for PlayerNames");
|
||||
setPlayerNameType(PlayerNameType.valueOf(config.getString("PlayerNames").toUpperCase(Locale.ENGLISH)));
|
||||
} catch (Exception ex) {
|
||||
DisguiseUtilities.getLogger().warning("Cannot parse '" + config.getString("PlayerNames") + "' to a valid option for PlayerNames");
|
||||
}
|
||||
|
||||
try {
|
||||
setNotifyBar(NotifyBar.valueOf(config.getString("NotifyBar").toUpperCase()));
|
||||
setNotifyBar(NotifyBar.valueOf(config.getString("NotifyBar").toUpperCase(Locale.ENGLISH)));
|
||||
|
||||
if (getNotifyBar() == NotifyBar.BOSS_BAR && !NmsVersion.v1_13.isSupported()) {
|
||||
DisguiseUtilities.getLogger().warning(
|
||||
"BossBars hasn't been implemented properly in 1.12 due to api restrictions, falling back to " +
|
||||
"ACTION_BAR");
|
||||
DisguiseUtilities.getLogger()
|
||||
.warning("BossBars hasn't been implemented properly in 1.12 due to api restrictions, falling back to " + "ACTION_BAR");
|
||||
|
||||
setNotifyBar(NotifyBar.ACTION_BAR);
|
||||
}
|
||||
}
|
||||
catch (Exception ex) {
|
||||
DisguiseUtilities.getLogger()
|
||||
.warning("Cannot parse '" + config.getString("NotifyBar") + "' to a valid option for NotifyBar");
|
||||
} catch (Exception ex) {
|
||||
DisguiseUtilities.getLogger().warning("Cannot parse '" + config.getString("NotifyBar") + "' to a valid option for NotifyBar");
|
||||
}
|
||||
|
||||
try {
|
||||
setBossBarColor(BarColor.valueOf(config.getString("BossBarColor").toUpperCase()));
|
||||
}
|
||||
catch (Exception ex) {
|
||||
DisguiseUtilities.getLogger().warning(
|
||||
"Cannot parse '" + config.getString("BossBarColor") + "' to a valid option for BossBarColor");
|
||||
setBossBarColor(BarColor.valueOf(config.getString("BossBarColor").toUpperCase(Locale.ENGLISH)));
|
||||
} catch (Exception ex) {
|
||||
DisguiseUtilities.getLogger().warning("Cannot parse '" + config.getString("BossBarColor") + "' to a valid option for BossBarColor");
|
||||
}
|
||||
|
||||
try {
|
||||
setBossBarStyle(BarStyle.valueOf(config.getString("BossBarStyle").toUpperCase()));
|
||||
}
|
||||
catch (Exception ex) {
|
||||
DisguiseUtilities.getLogger().warning(
|
||||
"Cannot parse '" + config.getString("BossBarStyle") + "' to a valid option for BossBarStyle");
|
||||
setBossBarStyle(BarStyle.valueOf(config.getString("BossBarStyle").toUpperCase(Locale.ENGLISH)));
|
||||
} catch (Exception ex) {
|
||||
DisguiseUtilities.getLogger().warning("Cannot parse '" + config.getString("BossBarStyle") + "' to a valid option for BossBarStyle");
|
||||
}
|
||||
|
||||
try {
|
||||
setUpdatesBranch(UpdatesBranch.valueOf(config.getString("UpdatesBranch").toUpperCase()));
|
||||
}
|
||||
catch (Exception ex) {
|
||||
DisguiseUtilities.getLogger().warning(
|
||||
"Cannot parse '" + config.getString("UpdatesBranch") + "' to a valid option for UpdatesBranch");
|
||||
setUpdatesBranch(UpdatesBranch.valueOf(config.getString("UpdatesBranch").toUpperCase(Locale.ENGLISH)));
|
||||
} catch (Exception ex) {
|
||||
DisguiseUtilities.getLogger().warning("Cannot parse '" + config.getString("UpdatesBranch") + "' to a valid option for UpdatesBranch");
|
||||
}
|
||||
|
||||
try {
|
||||
String option = config.getString("SelfDisguisesScoreboard", DisguisePushing.MODIFY_SCOREBOARD.name())
|
||||
.toUpperCase();
|
||||
|
||||
if (!option.endsWith("_SCOREBOARD"))
|
||||
option += "_SCOREBOARD";
|
||||
|
||||
pushingOption = DisguisePushing.valueOf(option);
|
||||
}
|
||||
catch (Exception ex) {
|
||||
DisguiseUtilities.getLogger().warning("Cannot parse '" + config.getString("SelfDisguisesScoreboard") +
|
||||
"' to a valid option for SelfDisguisesScoreboard");
|
||||
}
|
||||
|
||||
PermissionDefault commandVisibility = PermissionDefault.getByName(config.getString("Permissions.SeeCommands"));
|
||||
String seeCommands = config.getString("Permissions.SeeCommands");
|
||||
PermissionDefault commandVisibility = seeCommands == null ? null : PermissionDefault.getByName(seeCommands);
|
||||
|
||||
if (commandVisibility == null) {
|
||||
DisguiseUtilities.getLogger().warning("Invalid option '" + config.getString("Permissions.SeeCommands") +
|
||||
"' for Permissions.SeeCommands when loading config!");
|
||||
DisguiseUtilities.getLogger()
|
||||
.warning("Invalid option '" + config.getString("Permissions.SeeCommands") + "' for Permissions.SeeCommands when loading config!");
|
||||
} else {
|
||||
setCommandVisibility(commandVisibility);
|
||||
}
|
||||
|
@ -764,9 +733,7 @@ public class DisguiseConfig {
|
|||
if (config.contains("VerboseConfig")) {
|
||||
verbose = config.getBoolean("VerboseConfig");
|
||||
} else {
|
||||
DisguiseUtilities.getLogger()
|
||||
.info("As 'VerboseConfig' hasn't been set, it is assumed true. Set it in your config to remove " +
|
||||
"these messages!");
|
||||
DisguiseUtilities.getLogger().info("As 'VerboseConfig' hasn't been set, it is assumed true. Set it in your config to remove " + "these messages!");
|
||||
verbose = true;
|
||||
}
|
||||
|
||||
|
@ -776,9 +743,9 @@ public class DisguiseConfig {
|
|||
ArrayList<String> returns = doOutput(config, changed, verbose);
|
||||
|
||||
if (!returns.isEmpty()) {
|
||||
DisguiseUtilities.getLogger()
|
||||
.info("This is not an error! Now outputting " + (verbose ? "missing " : "") +
|
||||
(changed ? (verbose ? "and " : "") + "changed/invalid " : "") + "config values");
|
||||
DisguiseUtilities.getLogger().info(
|
||||
"This is not an error! Now outputting " + (verbose ? "missing " : "") + (changed ? (verbose ? "and " : "") + "changed/invalid " : "") +
|
||||
"config values");
|
||||
|
||||
for (String v : returns) {
|
||||
DisguiseUtilities.getLogger().info(v);
|
||||
|
@ -786,25 +753,15 @@ public class DisguiseConfig {
|
|||
}
|
||||
}
|
||||
|
||||
int missingConfigs = 0;
|
||||
|
||||
for (String key : config.getDefaultSection().getKeys(true)) {
|
||||
if (config.contains(key, true)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
missingConfigs++;
|
||||
}
|
||||
int missingConfigs = doOutput(config, false, true).size();
|
||||
|
||||
if (missingConfigs > 0) {
|
||||
if (config.getBoolean("UpdateConfig", true)) {
|
||||
saveDefaultConfig();
|
||||
configLoader.saveDefaultConfigs();
|
||||
DisguiseUtilities.getLogger().info("Config has been auto-updated!");
|
||||
} else if (!verbose) {
|
||||
DisguiseUtilities.getLogger().warning("Your config is missing " + missingConfigs +
|
||||
" options! Please consider regenerating your config!");
|
||||
DisguiseUtilities.getLogger()
|
||||
.info("You can also add the missing entries yourself! Try '/libsdisguises config'");
|
||||
DisguiseUtilities.getLogger().warning("Your config is missing " + missingConfigs + " options! Please consider regenerating your config!");
|
||||
DisguiseUtilities.getLogger().info("You can also add the missing entries yourself! Try '/libsdisguises config'");
|
||||
}
|
||||
} else {
|
||||
DisguiseUtilities.getLogger().info("Config is up to date!");
|
||||
|
@ -812,10 +769,11 @@ public class DisguiseConfig {
|
|||
}
|
||||
|
||||
public static void loadModdedDisguiseTypes() {
|
||||
File disguisesFile = new File("plugins/LibsDisguises/disguises.yml");
|
||||
File disguisesFile = new File(LibsDisguises.getInstance().getDataFolder(), "configs/disguises.yml");
|
||||
|
||||
if (!disguisesFile.exists())
|
||||
if (!disguisesFile.exists()) {
|
||||
return;
|
||||
}
|
||||
|
||||
YamlConfiguration config = YamlConfiguration.loadConfiguration(disguisesFile);
|
||||
|
||||
|
@ -852,8 +810,7 @@ public class DisguiseConfig {
|
|||
boolean living = section.getString("Type", "LIVING").equalsIgnoreCase("LIVING");
|
||||
String type = section.getString("Type");
|
||||
String mod = section.getString("Mod");
|
||||
String[] version =
|
||||
mod == null || !section.contains("Version") ? null : section.getString("Version").split(",");
|
||||
String[] version = mod == null || !section.contains("Version") ? null : section.getString("Version").split(",");
|
||||
String requireMessage = mod == null ? null : section.getString("Required");
|
||||
|
||||
if (section.contains("Channels")) {
|
||||
|
@ -868,25 +825,21 @@ public class DisguiseConfig {
|
|||
}
|
||||
|
||||
if (requireMessage != null) {
|
||||
requireMessage = ChatColor.translateAlternateColorCodes('&', requireMessage);
|
||||
requireMessage = DisguiseUtilities.translateAlternateColorCodes(requireMessage);
|
||||
}
|
||||
|
||||
ModdedEntity entity = new ModdedEntity(null, name, living, mod, version, requireMessage, 0);
|
||||
|
||||
if (ModdedManager.getModdedEntity(name) != null) {
|
||||
DisguiseUtilities.getLogger()
|
||||
.info("Modded entity " + name + " has already been " + (register ? "registered" : "added"));
|
||||
DisguiseUtilities.getLogger().info("Modded entity " + name + " has already been " + (register ? "registered" : "added"));
|
||||
continue;
|
||||
}
|
||||
|
||||
ModdedManager.registerModdedEntity(
|
||||
new NamespacedKey(key.substring(0, key.indexOf(":")), key.substring(key.indexOf(":") + 1)),
|
||||
entity, register);
|
||||
ModdedManager.registerModdedEntity(new NamespacedKey(key.substring(0, key.indexOf(":")), key.substring(key.indexOf(":") + 1)), entity,
|
||||
register);
|
||||
|
||||
DisguiseUtilities.getLogger()
|
||||
.info("Modded entity " + name + " has been " + (register ? "registered" : "added"));
|
||||
}
|
||||
catch (Exception ex) {
|
||||
DisguiseUtilities.getLogger().info("Modded entity " + name + " has been " + (register ? "registered" : "added"));
|
||||
} catch (Exception ex) {
|
||||
DisguiseUtilities.getLogger().severe("Error while trying to register modded entity " + name);
|
||||
ex.printStackTrace();
|
||||
}
|
||||
|
@ -895,10 +848,18 @@ public class DisguiseConfig {
|
|||
new ModdedManager(channels);
|
||||
}
|
||||
|
||||
public static ArrayList<String> doOutput(ConfigurationSection config, boolean informChangedUnknown,
|
||||
boolean informMissing) {
|
||||
public static ArrayList<String> doOutput(boolean informChangedUnknown, boolean informMissing) {
|
||||
return doOutput(new ConfigLoader().load(), informChangedUnknown, informMissing);
|
||||
}
|
||||
|
||||
public static ArrayList<String> doOutput(ConfigurationSection config, boolean informChangedUnknown, boolean informMissing) {
|
||||
HashMap<String, Object> configs = new HashMap<>();
|
||||
ConfigurationSection defaultSection = config.getDefaultSection();
|
||||
|
||||
if (defaultSection == null) {
|
||||
defaultSection = new ConfigLoader().loadDefaults();
|
||||
}
|
||||
|
||||
ArrayList<String> returns = new ArrayList<>();
|
||||
|
||||
for (String key : defaultSection.getKeys(true)) {
|
||||
|
@ -942,10 +903,11 @@ public class DisguiseConfig {
|
|||
static void loadCustomDisguises() {
|
||||
customDisguises.clear();
|
||||
|
||||
File disguisesFile = new File("plugins/LibsDisguises/disguises.yml");
|
||||
File disguisesFile = new File(LibsDisguises.getInstance().getDataFolder(), "configs/disguises.yml");
|
||||
|
||||
if (!disguisesFile.exists())
|
||||
if (!disguisesFile.exists()) {
|
||||
return;
|
||||
}
|
||||
|
||||
YamlConfiguration disguisesConfig = YamlConfiguration.loadConfiguration(disguisesFile);
|
||||
|
||||
|
@ -961,21 +923,24 @@ public class DisguiseConfig {
|
|||
String toParse = section.getString(key);
|
||||
|
||||
if (!NmsVersion.v1_13.isSupported() && key.equals("libraryaddict")) {
|
||||
toParse = toParse.replace("GOLDEN_BOOTS,GOLDEN_LEGGINGS,GOLDEN_CHESTPLATE,GOLDEN_HELMET",
|
||||
"GOLD_BOOTS,GOLD_LEGGINGS,GOLD_CHESTPLATE,GOLD_HELMET");
|
||||
toParse =
|
||||
toParse.replace("GOLDEN_BOOTS,GOLDEN_LEGGINGS,GOLDEN_CHESTPLATE,GOLDEN_HELMET", "GOLD_BOOTS,GOLD_LEGGINGS,GOLD_CHESTPLATE,GOLD_HELMET");
|
||||
}
|
||||
|
||||
try {
|
||||
addCustomDisguise(key, toParse);
|
||||
}
|
||||
catch (DisguiseParseException e) {
|
||||
} catch (Exception e) {
|
||||
failedCustomDisguises++;
|
||||
|
||||
if (e.getMessage() != null) {
|
||||
DisguiseUtilities.getLogger().severe(e.getMessage());
|
||||
}
|
||||
if (e instanceof DisguiseParseException) {
|
||||
if (e.getMessage() != null) {
|
||||
DisguiseUtilities.getLogger().severe(e.getMessage());
|
||||
}
|
||||
|
||||
if (e.getCause() != null) {
|
||||
if (e.getCause() != null) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
} else {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
@ -985,15 +950,12 @@ public class DisguiseConfig {
|
|||
DisguiseUtilities.getLogger().warning("Failed to load " + failedCustomDisguises + " custom disguises");
|
||||
}
|
||||
|
||||
DisguiseUtilities.getLogger().info("Loaded " + customDisguises.size() + " custom disguise" +
|
||||
(customDisguises.size() == 1 ? "" : "s"));
|
||||
DisguiseUtilities.getLogger().info("Loaded " + customDisguises.size() + " custom disguise" + (customDisguises.size() == 1 ? "" : "s"));
|
||||
}
|
||||
|
||||
public static void addCustomDisguise(String disguiseName, String toParse) throws DisguiseParseException {
|
||||
if (!Bukkit.isPrimaryThread()) {
|
||||
DisguiseUtilities.getLogger().warning(
|
||||
"Custom Disguises should not be called async! This operation will become impossible in the " +
|
||||
"future!");
|
||||
throw new IllegalStateException("Custom Disguises should not be called async!");
|
||||
}
|
||||
|
||||
if (getRawCustomDisguise(toParse) != null) {
|
||||
|
@ -1004,19 +966,16 @@ public class DisguiseConfig {
|
|||
String[] disguiseArgs = DisguiseUtilities.split(toParse);
|
||||
|
||||
Disguise disguise = DisguiseParser.parseTestDisguise(Bukkit.getConsoleSender(), "disguise", disguiseArgs,
|
||||
DisguiseParser.getPermissions(Bukkit.getConsoleSender(), "disguise"));
|
||||
DisguiseParser.getPermissions(Bukkit.getConsoleSender(), "disguise"));
|
||||
|
||||
DisguisePerm perm = new DisguisePerm(disguise.getType(), disguiseName);
|
||||
|
||||
customDisguises.put(perm, toParse);
|
||||
|
||||
DisguiseUtilities.getLogger().info("Loaded custom disguise " + disguiseName);
|
||||
}
|
||||
catch (DisguiseParseException e) {
|
||||
throw new DisguiseParseException(LibsMsg.ERROR_LOADING_CUSTOM_DISGUISE, disguiseName,
|
||||
(e.getMessage() == null ? "" : ": " + e.getMessage()));
|
||||
}
|
||||
catch (IllegalAccessException | InvocationTargetException e) {
|
||||
} catch (DisguiseParseException e) {
|
||||
throw new DisguiseParseException(LibsMsg.ERROR_LOADING_CUSTOM_DISGUISE, disguiseName, (e.getMessage() == null ? "" : ": " + e.getMessage()));
|
||||
} catch (Throwable e) {
|
||||
e.printStackTrace();
|
||||
throw new DisguiseParseException(LibsMsg.ERROR_LOADING_CUSTOM_DISGUISE, disguiseName, "");
|
||||
}
|
|
@ -0,0 +1,381 @@
|
|||
package me.libraryaddict.disguise;
|
||||
|
||||
import lombok.Getter;
|
||||
import me.libraryaddict.disguise.commands.LibsDisguisesCommand;
|
||||
import me.libraryaddict.disguise.commands.disguise.DisguiseCommand;
|
||||
import me.libraryaddict.disguise.commands.disguise.DisguiseEntityCommand;
|
||||
import me.libraryaddict.disguise.commands.modify.DisguiseModifyCommand;
|
||||
import me.libraryaddict.disguise.commands.modify.DisguiseModifyEntityCommand;
|
||||
import me.libraryaddict.disguise.commands.undisguise.UndisguiseCommand;
|
||||
import me.libraryaddict.disguise.commands.undisguise.UndisguiseEntityCommand;
|
||||
import me.libraryaddict.disguise.commands.undisguise.UndisguisePlayerCommand;
|
||||
import me.libraryaddict.disguise.commands.undisguise.UndisguiseRadiusCommand;
|
||||
import me.libraryaddict.disguise.commands.utils.CopyDisguiseCommand;
|
||||
import me.libraryaddict.disguise.commands.utils.DisguiseCloneCommand;
|
||||
import me.libraryaddict.disguise.commands.utils.DisguiseHelpCommand;
|
||||
import me.libraryaddict.disguise.commands.utils.DisguiseViewBarCommand;
|
||||
import me.libraryaddict.disguise.commands.utils.DisguiseViewSelfCommand;
|
||||
import me.libraryaddict.disguise.commands.utils.GrabHeadCommand;
|
||||
import me.libraryaddict.disguise.commands.utils.GrabSkinCommand;
|
||||
import me.libraryaddict.disguise.commands.utils.SaveDisguiseCommand;
|
||||
import me.libraryaddict.disguise.utilities.DisguiseUtilities;
|
||||
import me.libraryaddict.disguise.utilities.LibsPremium;
|
||||
import me.libraryaddict.disguise.utilities.config.DisguiseCommandConfig;
|
||||
import me.libraryaddict.disguise.utilities.listeners.DisguiseListener;
|
||||
import me.libraryaddict.disguise.utilities.listeners.PaperDisguiseListener;
|
||||
import me.libraryaddict.disguise.utilities.listeners.PlayerSkinHandler;
|
||||
import me.libraryaddict.disguise.utilities.metrics.MetricsInitalizer;
|
||||
import me.libraryaddict.disguise.utilities.packets.PacketsManager;
|
||||
import me.libraryaddict.disguise.utilities.params.ParamInfoManager;
|
||||
import me.libraryaddict.disguise.utilities.parser.DisguiseParser;
|
||||
import me.libraryaddict.disguise.utilities.reflection.NmsVersion;
|
||||
import me.libraryaddict.disguise.utilities.reflection.ReflectionManager;
|
||||
import me.libraryaddict.disguise.utilities.sounds.SoundManager;
|
||||
import me.libraryaddict.disguise.utilities.updates.UpdateChecker;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandMap;
|
||||
import org.bukkit.command.PluginCommand;
|
||||
import org.bukkit.command.TabCompleter;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Arrays;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class LibsDisguises extends JavaPlugin {
|
||||
private static LibsDisguises instance;
|
||||
private DisguiseListener listener;
|
||||
private String buildNumber;
|
||||
@Getter
|
||||
private boolean reloaded;
|
||||
@Getter
|
||||
private final UpdateChecker updateChecker = new UpdateChecker();
|
||||
@Getter
|
||||
private PlayerSkinHandler skinHandler;
|
||||
private DisguiseCommandConfig commandConfig;
|
||||
|
||||
@Override
|
||||
public void onLoad() {
|
||||
try {
|
||||
if (instance != null || !Bukkit.getServer().getWorlds().isEmpty() || !Bukkit.getOnlinePlayers().isEmpty()) {
|
||||
reloaded = true;
|
||||
getLogger().severe("Server was reloaded! Please do not report any bugs! This plugin can't handle " + "reloads gracefully!");
|
||||
}
|
||||
|
||||
instance = this;
|
||||
|
||||
Plugin plugin = Bukkit.getPluginManager().getPlugin("ProtocolLib");
|
||||
|
||||
if (plugin == null || DisguiseUtilities.isProtocolLibOutdated()) {
|
||||
getLogger().warning("Noticed you're using an older version of ProtocolLib (or not using it)! We're forcibly updating you!");
|
||||
|
||||
try {
|
||||
File dest = DisguiseUtilities.updateProtocolLib();
|
||||
|
||||
if (plugin == null) {
|
||||
getLogger().info("ProtocolLib downloaded and stuck in plugins folder! Now trying to load it!");
|
||||
plugin = Bukkit.getPluginManager().loadPlugin(dest);
|
||||
plugin.onLoad();
|
||||
|
||||
Bukkit.getPluginManager().enablePlugin(plugin);
|
||||
} else {
|
||||
getLogger().severe("Please restart the server to complete the ProtocolLib update!");
|
||||
}
|
||||
} catch (Exception e) {
|
||||
getLogger().severe(
|
||||
"Looks like ProtocolLib's site may be down! MythicCraft/MythicMobs has a discord server https://discord.gg/EErRhJ4qgx you" + " can " +
|
||||
"join. Check the pins in #libs-support for a ProtocolLib.jar you can download!");
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
try {
|
||||
Class cl = Class.forName("org.bukkit.Server$Spigot");
|
||||
} catch (ClassNotFoundException e) {
|
||||
getLogger().severe("Oh dear, you seem to be using CraftBukkit. Please use Spigot or Paper instead! This " +
|
||||
"plugin will continue to load, but it will look like a mugging victim");
|
||||
}
|
||||
|
||||
commandConfig = new DisguiseCommandConfig();
|
||||
|
||||
if (!reloaded) {
|
||||
commandConfig.load();
|
||||
}
|
||||
} catch (Throwable throwable) {
|
||||
try {
|
||||
if (isNumberedBuild() && DisguiseConfig.isAutoUpdate()) {
|
||||
getUpdateChecker().doUpdate();
|
||||
}
|
||||
} catch (Throwable t) {
|
||||
getLogger().severe("Failed to even do a forced update");
|
||||
}
|
||||
|
||||
throw throwable;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEnable() {
|
||||
try {
|
||||
if (reloaded) {
|
||||
getLogger().severe("Server was reloaded! Please do not report any bugs! This plugin can't handle " + "reloads gracefully!");
|
||||
}
|
||||
|
||||
if (Bukkit.getVersion().contains("(MC: 1.17)")) {
|
||||
getLogger().severe("Please update from MC 1.17! You should be using 1.17.1!");
|
||||
}
|
||||
|
||||
try {
|
||||
Class cl = Class.forName("org.bukkit.Server$Spigot");
|
||||
} catch (ClassNotFoundException e) {
|
||||
getLogger().severe("Oh dear, you seem to be using CraftBukkit. Please use Spigot or Paper instead! This " +
|
||||
"plugin will continue to load, but it will look like a mugging victim");
|
||||
}
|
||||
|
||||
File disguiseFile = new File(getDataFolder(), "configs/disguises.yml");
|
||||
|
||||
if (!disguiseFile.exists()) {
|
||||
disguiseFile.getParentFile().mkdirs();
|
||||
|
||||
File oldFile = new File(getDataFolder(), "disguises.yml");
|
||||
|
||||
if (oldFile.exists()) {
|
||||
oldFile.renameTo(disguiseFile);
|
||||
} else {
|
||||
saveResource("configs/disguises.yml", false);
|
||||
}
|
||||
}
|
||||
|
||||
YamlConfiguration pluginYml = ReflectionManager.getPluginYAML(getFile());
|
||||
buildNumber = StringUtils.stripToNull(pluginYml.getString("build-number"));
|
||||
|
||||
getLogger().info("File Name: " + getFile().getName());
|
||||
|
||||
getLogger().info("Discovered nms version: " + ReflectionManager.getBukkitVersion());
|
||||
|
||||
getLogger().info("Jenkins Build: " + (isNumberedBuild() ? "#" : "") + getBuildNo());
|
||||
|
||||
getLogger().info("Build Date: " + pluginYml.getString("build-date"));
|
||||
|
||||
DisguiseConfig.loadInternalConfig();
|
||||
|
||||
LibsPremium.check(getDescription().getVersion(), getFile());
|
||||
|
||||
if (!LibsPremium.isPremium()) {
|
||||
getLogger().info(
|
||||
"You are running the free version, commands limited to non-players and operators. (Console," + " Command " + "Blocks, Admins)");
|
||||
}
|
||||
|
||||
if (ReflectionManager.getVersion() == null) {
|
||||
getLogger().severe("You're using the wrong version of Lib's Disguises for your server! This is " + "intended for " +
|
||||
StringUtils.join(Arrays.stream(NmsVersion.values()).map(v -> v.name().replace("_", ".")).collect(Collectors.toList()), " & ") + "!");
|
||||
getPluginLoader().disablePlugin(this);
|
||||
return;
|
||||
}
|
||||
|
||||
if (DisguiseUtilities.isProtocolLibOutdated()) {
|
||||
String requiredProtocolLib = StringUtils.join(DisguiseUtilities.getProtocolLibRequiredVersion(), " or build #");
|
||||
String version = Bukkit.getPluginManager().getPlugin("ProtocolLib").getDescription().getVersion();
|
||||
|
||||
BukkitRunnable runnable = new BukkitRunnable() {
|
||||
private int timesRun;
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
getLogger().severe("!! May I have your attention please !!");
|
||||
getLogger().severe(
|
||||
"Update your ProtocolLib! You are running " + version + " but the minimum version you should be on is " + requiredProtocolLib +
|
||||
"!");
|
||||
getLogger().severe("https://ci.dmulloy2.net/job/ProtocolLib/lastSuccessfulBuild/artifact/target" + "/ProtocolLib" + ".jar");
|
||||
getLogger().severe("Or! Use /ld protocollib - To update to the latest development build");
|
||||
|
||||
if (timesRun++ > 0) {
|
||||
getLogger().severe("This message is on repeat due to the sheer number of people who don't see this.");
|
||||
}
|
||||
|
||||
getLogger().severe("!! May I have your attention please !!");
|
||||
}
|
||||
};
|
||||
|
||||
runnable.run();
|
||||
runnable.runTaskTimer(this, 20, 10 * 60 * 20);
|
||||
}
|
||||
|
||||
// If this is a release build, even if jenkins build..
|
||||
if (isReleaseBuild()) {
|
||||
// If downloaded from spigot, forcibly set release build to true
|
||||
if (LibsPremium.getUserID().matches("[0-9]+")) {
|
||||
DisguiseConfig.setUsingReleaseBuilds(true);
|
||||
}
|
||||
// Otherwise leave it untouched as they might've just happened to hit a dev build, which is a release build
|
||||
} else {
|
||||
DisguiseConfig.setUsingReleaseBuilds(false);
|
||||
}
|
||||
|
||||
ReflectionManager.init();
|
||||
|
||||
PacketsManager.init();
|
||||
DisguiseUtilities.init();
|
||||
|
||||
new SoundManager().load();
|
||||
|
||||
ReflectionManager.registerValues();
|
||||
|
||||
ParamInfoManager.getParamInfoSoundGroup().recalculate();
|
||||
|
||||
DisguiseConfig.loadConfig();
|
||||
|
||||
DisguiseParser.createDefaultMethods();
|
||||
|
||||
PacketsManager.addPacketListeners();
|
||||
|
||||
listener = new DisguiseListener(this);
|
||||
skinHandler = new PlayerSkinHandler();
|
||||
|
||||
Bukkit.getPluginManager().registerEvents(getSkinHandler(), LibsDisguises.getInstance());
|
||||
|
||||
if (DisguiseUtilities.isRunningPaper()) {
|
||||
Bukkit.getPluginManager().registerEvents(new PaperDisguiseListener(), this);
|
||||
}
|
||||
|
||||
registerCommand("libsdisguises", new LibsDisguisesCommand());
|
||||
registerCommand("disguise", new DisguiseCommand());
|
||||
registerCommand("undisguise", new UndisguiseCommand());
|
||||
registerCommand("undisguiseplayer", new UndisguisePlayerCommand());
|
||||
registerCommand("undisguiseentity", new UndisguiseEntityCommand());
|
||||
registerCommand("disguiseentity", new DisguiseEntityCommand());
|
||||
registerCommand("undisguiseradius", new UndisguiseRadiusCommand());
|
||||
registerCommand("disguisehelp", new DisguiseHelpCommand());
|
||||
registerCommand("disguiseclone", new DisguiseCloneCommand());
|
||||
registerCommand("disguiseviewself", new DisguiseViewSelfCommand());
|
||||
registerCommand("disguiseviewbar", new DisguiseViewBarCommand());
|
||||
registerCommand("disguisemodify", new DisguiseModifyCommand());
|
||||
registerCommand("disguisemodifyentity", new DisguiseModifyEntityCommand());
|
||||
registerCommand("copydisguise", new CopyDisguiseCommand());
|
||||
registerCommand("grabskin", new GrabSkinCommand());
|
||||
registerCommand("savedisguise", new SaveDisguiseCommand());
|
||||
registerCommand("grabhead", new GrabHeadCommand());
|
||||
|
||||
unregisterCommands(false);
|
||||
|
||||
new MetricsInitalizer();
|
||||
} catch (Throwable throwable) {
|
||||
try {
|
||||
if (isNumberedBuild() && DisguiseConfig.isAutoUpdate()) {
|
||||
getUpdateChecker().doUpdate();
|
||||
}
|
||||
} catch (Throwable t) {
|
||||
getLogger().severe("Failed to even do a forced update");
|
||||
}
|
||||
|
||||
throw throwable;
|
||||
}
|
||||
}
|
||||
|
||||
public void unregisterCommands(boolean force) {
|
||||
CommandMap map = ReflectionManager.getCommandMap();
|
||||
Map<String, Command> commands = ReflectionManager.getCommands(map);
|
||||
|
||||
for (String command : getDescription().getCommands().keySet()) {
|
||||
PluginCommand cmd = getCommand("libsdisguises:" + command);
|
||||
|
||||
if (cmd == null || (cmd.getExecutor() != this && !force)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (cmd.getPermission() != null && cmd.getPermission().startsWith("libsdisguises.seecmd")) {
|
||||
Bukkit.getPluginManager().removePermission(cmd.getPermission());
|
||||
}
|
||||
|
||||
Iterator<Map.Entry<String, Command>> itel = commands.entrySet().iterator();
|
||||
|
||||
while (itel.hasNext()) {
|
||||
Map.Entry<String, Command> entry = itel.next();
|
||||
|
||||
if (entry.getValue() != cmd) {
|
||||
continue;
|
||||
}
|
||||
|
||||
itel.remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public File getFile() {
|
||||
return super.getFile();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDisable() {
|
||||
DisguiseUtilities.saveDisguises();
|
||||
|
||||
reloaded = true;
|
||||
}
|
||||
|
||||
public boolean isReleaseBuild() {
|
||||
return !getDescription().getVersion().contains("-SNAPSHOT");
|
||||
}
|
||||
|
||||
public String getBuildNo() {
|
||||
return buildNumber;
|
||||
}
|
||||
|
||||
public int getBuildNumber() {
|
||||
return isNumberedBuild() ? Integer.parseInt(getBuildNo()) : 0;
|
||||
}
|
||||
|
||||
public boolean isNumberedBuild() {
|
||||
return getBuildNo() != null && getBuildNo().matches("[0-9]+");
|
||||
}
|
||||
|
||||
private void registerCommand(String commandName, CommandExecutor executioner) {
|
||||
String name = commandConfig.getCommand(commandName);
|
||||
|
||||
if (name == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
PluginCommand command = getCommand("libsdisguises:" + name);
|
||||
|
||||
if (command == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
command.setExecutor(executioner);
|
||||
|
||||
if (executioner instanceof TabCompleter) {
|
||||
command.setTabCompleter((TabCompleter) executioner);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Reloads the config with new config options.
|
||||
*/
|
||||
@Deprecated
|
||||
public void reload() {
|
||||
DisguiseConfig.loadConfig();
|
||||
}
|
||||
|
||||
public DisguiseListener getListener() {
|
||||
return listener;
|
||||
}
|
||||
|
||||
/**
|
||||
* External APIs shouldn't actually need this instance. DisguiseAPI should be enough to handle most cases.
|
||||
*
|
||||
* @return The instance of this plugin
|
||||
*/
|
||||
public static LibsDisguises getInstance() {
|
||||
return instance;
|
||||
}
|
||||
}
|
|
@ -1,64 +1,95 @@
|
|||
package me.libraryaddict.disguise.commands;
|
||||
|
||||
import com.comphenix.protocol.ProtocolLibrary;
|
||||
import com.google.common.cache.Cache;
|
||||
import com.google.common.cache.CacheBuilder;
|
||||
import me.libraryaddict.disguise.BlockedDisguises;
|
||||
import me.libraryaddict.disguise.DisguiseConfig;
|
||||
import me.libraryaddict.disguise.commands.disguise.DisguiseCommand;
|
||||
import me.libraryaddict.disguise.commands.disguise.DisguiseEntityCommand;
|
||||
import me.libraryaddict.disguise.commands.disguise.DisguisePlayerCommand;
|
||||
import me.libraryaddict.disguise.commands.disguise.DisguiseRadiusCommand;
|
||||
import me.libraryaddict.disguise.commands.modify.DisguiseModifyCommand;
|
||||
import me.libraryaddict.disguise.commands.modify.DisguiseModifyEntityCommand;
|
||||
import me.libraryaddict.disguise.commands.modify.DisguiseModifyPlayerCommand;
|
||||
import me.libraryaddict.disguise.commands.modify.DisguiseModifyRadiusCommand;
|
||||
import me.libraryaddict.disguise.disguisetypes.DisguiseType;
|
||||
import me.libraryaddict.disguise.utilities.DisguiseUtilities;
|
||||
import me.libraryaddict.disguise.utilities.LibsPremium;
|
||||
import me.libraryaddict.disguise.utilities.params.ParamInfo;
|
||||
import me.libraryaddict.disguise.utilities.params.ParamInfoManager;
|
||||
import me.libraryaddict.disguise.utilities.parser.DisguiseParser;
|
||||
import me.libraryaddict.disguise.utilities.parser.DisguisePerm;
|
||||
import me.libraryaddict.disguise.utilities.parser.DisguisePermissions;
|
||||
import me.libraryaddict.disguise.utilities.parser.WatcherMethod;
|
||||
import me.libraryaddict.disguise.utilities.translations.LibsMsg;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.scoreboard.Team;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
/**
|
||||
* @author libraryaddict
|
||||
*/
|
||||
public abstract class DisguiseBaseCommand implements CommandExecutor {
|
||||
private static final Map<Class<? extends DisguiseBaseCommand>, String> disguiseCommands;
|
||||
private final Cache<UUID, Long> rateLimit = CacheBuilder.newBuilder().expireAfterWrite(500, TimeUnit.MILLISECONDS).build();
|
||||
|
||||
static {
|
||||
HashMap<Class<? extends DisguiseBaseCommand>, String> map = new HashMap<>();
|
||||
|
||||
map.put(DisguiseCommand.class, "Disguise");
|
||||
map.put(DisguiseEntityCommand.class, "DisguiseEntity");
|
||||
map.put(DisguisePlayerCommand.class, "DisguisePlayer");
|
||||
map.put(DisguiseRadiusCommand.class, "DisguiseRadius");
|
||||
map.put(DisguiseModifyCommand.class, "DisguiseModify");
|
||||
map.put(DisguiseModifyEntityCommand.class, "DisguiseModifyEntity");
|
||||
map.put(DisguiseModifyPlayerCommand.class, "DisguiseModifyPlayer");
|
||||
map.put(DisguiseModifyRadiusCommand.class, "DisguiseModifyRadius");
|
||||
|
||||
disguiseCommands = map;
|
||||
}
|
||||
|
||||
protected boolean hasHitRateLimit(CommandSender sender) {
|
||||
if (sender.isOp() || !(sender instanceof Player) || sender.hasPermission("libsdisguises.ratelimitbypass")) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (rateLimit.getIfPresent(((Player) sender).getUniqueId()) != null) {
|
||||
LibsMsg.TOO_FAST.send(sender);
|
||||
return true;
|
||||
}
|
||||
|
||||
rateLimit.put(((Player) sender).getUniqueId(), System.currentTimeMillis());
|
||||
return false;
|
||||
}
|
||||
|
||||
protected boolean isNotPremium(CommandSender sender) {
|
||||
String requiredProtocolLib = StringUtils.join(DisguiseUtilities.getProtocolLibRequiredVersion(), " or build #");
|
||||
String version = ProtocolLibrary.getPlugin().getDescription().getVersion();
|
||||
|
||||
if (DisguiseUtilities.isProtocolLibOutdated()) {
|
||||
DisguiseUtilities.sendProtocolLibUpdateMessage(sender, version, requiredProtocolLib);
|
||||
}
|
||||
|
||||
if (sender instanceof Player && !sender.isOp() &&
|
||||
(!LibsPremium.isPremium() || LibsPremium.getPaidInformation() == LibsPremium.getPluginInformation())) {
|
||||
sender.sendMessage(ChatColor.RED + "Please purchase Lib's Disguises to enable player commands");
|
||||
(!LibsPremium.isPremium() || LibsPremium.getPaidInformation() == LibsPremium.getPluginInformation())) {
|
||||
sender.sendMessage(ChatColor.RED + "This is the free version of Lib's Disguises, player commands are limited to console and " +
|
||||
"Operators only! Purchase the plugin for non-admin usage!");
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
protected List<String> getTabDisguiseTypes(CommandSender sender, DisguisePermissions perms, String[] allArgs,
|
||||
int startsAt, String currentArg) {
|
||||
protected List<String> getTabDisguiseTypes(CommandSender sender, DisguisePermissions perms, String[] allArgs, int startsAt, String currentArg) {
|
||||
// If not enough arguments to get current disguise type
|
||||
if (allArgs.length <= startsAt) {
|
||||
return getAllowedDisguises(perms);
|
||||
|
@ -74,8 +105,7 @@ public abstract class DisguiseBaseCommand implements CommandExecutor {
|
|||
|
||||
// If current argument is just after the disguise type, and disguise type is a player which is not a custom
|
||||
// disguise
|
||||
if (allArgs.length == startsAt + 1 && disguiseType.getType() == DisguiseType.PLAYER &&
|
||||
!disguiseType.isCustomDisguise()) {
|
||||
if (allArgs.length == startsAt + 1 && disguiseType.getType() == DisguiseType.PLAYER && !disguiseType.isCustomDisguise()) {
|
||||
ArrayList<String> tabs = new ArrayList<>();
|
||||
|
||||
// Add all player names to tab list
|
||||
|
@ -92,8 +122,7 @@ public abstract class DisguiseBaseCommand implements CommandExecutor {
|
|||
return tabs;
|
||||
}
|
||||
|
||||
return getTabDisguiseOptions(sender, perms, disguiseType, allArgs, startsAt + (disguiseType.isPlayer() ? 2 : 1),
|
||||
currentArg);
|
||||
return getTabDisguiseOptions(sender, perms, disguiseType, allArgs, startsAt + (disguiseType.isPlayer() ? 2 : 1), currentArg);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -103,15 +132,15 @@ public abstract class DisguiseBaseCommand implements CommandExecutor {
|
|||
* @param startsAt What index this starts at
|
||||
* @return a list of viable disguise options
|
||||
*/
|
||||
protected List<String> getTabDisguiseOptions(CommandSender commandSender, DisguisePermissions perms,
|
||||
DisguisePerm disguisePerm, String[] allArgs, int startsAt, String currentArg) {
|
||||
protected List<String> getTabDisguiseOptions(CommandSender commandSender, DisguisePermissions perms, DisguisePerm disguisePerm, String[] allArgs,
|
||||
int startsAt, String currentArg) {
|
||||
ArrayList<String> usedOptions = new ArrayList<>();
|
||||
|
||||
Method[] methods = ParamInfoManager.getDisguiseWatcherMethods(disguisePerm.getWatcherClass());
|
||||
WatcherMethod[] methods = ParamInfoManager.getDisguiseWatcherMethods(disguisePerm.getWatcherClass());
|
||||
|
||||
// Find which methods the disguiser has already used
|
||||
for (int i = startsAt; i < allArgs.length; i++) {
|
||||
for (Method method : methods) {
|
||||
for (WatcherMethod method : methods) {
|
||||
String arg = allArgs[i];
|
||||
|
||||
if (!method.getName().equalsIgnoreCase(arg)) {
|
||||
|
@ -131,18 +160,21 @@ public abstract class DisguiseBaseCommand implements CommandExecutor {
|
|||
return getTabDisguiseSubOptions(commandSender, perms, disguisePerm, allArgs, startsAt, currentArg);
|
||||
}
|
||||
|
||||
protected List<String> getTabDisguiseSubOptions(CommandSender commandSender, DisguisePermissions perms,
|
||||
DisguisePerm disguisePerm, String[] allArgs, int startsAt, String currentArg) {
|
||||
protected List<String> getTabDisguiseSubOptions(CommandSender commandSender, DisguisePermissions perms, DisguisePerm disguisePerm, String[] allArgs,
|
||||
int startsAt, String currentArg) {
|
||||
boolean addMethods = true;
|
||||
List<String> tabs = new ArrayList<>();
|
||||
|
||||
ParamInfo info = null;
|
||||
String methodName = null;
|
||||
|
||||
if (allArgs.length == startsAt) {
|
||||
if (disguisePerm.getType() == DisguiseType.FALLING_BLOCK) {
|
||||
info = ParamInfoManager.getParamInfoItemBlock();
|
||||
methodName = "setBlock";
|
||||
} else if (disguisePerm.getType() == DisguiseType.DROPPED_ITEM) {
|
||||
info = ParamInfoManager.getParamInfo(ItemStack.class);
|
||||
methodName = "setItemstack";
|
||||
}
|
||||
} else if (allArgs.length > startsAt) {
|
||||
// Check what argument was used before the current argument to see what we're displaying
|
||||
|
@ -150,33 +182,60 @@ public abstract class DisguiseBaseCommand implements CommandExecutor {
|
|||
String prevArg = allArgs[allArgs.length - 1];
|
||||
|
||||
info = ParamInfoManager.getParamInfo(disguisePerm, prevArg);
|
||||
methodName = prevArg;
|
||||
|
||||
if (info != null && !info.isParam(boolean.class)) {
|
||||
addMethods = false;
|
||||
}
|
||||
|
||||
// Enderman can't hold non-blocks
|
||||
if (disguisePerm.getType() == DisguiseType.ENDERMAN && prevArg.equalsIgnoreCase("setItemInMainHand")) {
|
||||
info = ParamInfoManager.getParamInfoItemBlock();
|
||||
}
|
||||
}
|
||||
|
||||
// If the previous argument is a method
|
||||
if (info != null) {
|
||||
Collection<String> wantToUse = null;
|
||||
|
||||
// If there is a list of default values
|
||||
if (info.hasValues()) {
|
||||
tabs.addAll(info.getEnums(currentArg));
|
||||
wantToUse = info.getEnums(currentArg);
|
||||
} else if (info.isParam(String.class)) {
|
||||
wantToUse = new ArrayList<>();
|
||||
|
||||
for (Player player : Bukkit.getOnlinePlayers()) {
|
||||
// If command user cannot see player online, don't tab-complete name
|
||||
if (commandSender instanceof Player && !((Player) commandSender).canSee(player)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
tabs.add(player.getName());
|
||||
wantToUse.add(player.getName());
|
||||
}
|
||||
}
|
||||
|
||||
if (wantToUse != null) {
|
||||
HashMap<String, HashMap<String, Boolean>> allowedOptions = DisguisePermissions.getDisguiseOptions(commandSender, getPermNode(), disguisePerm);
|
||||
HashMap<String, Boolean> methodValues = allowedOptions.get(methodName.toLowerCase(Locale.ENGLISH));
|
||||
|
||||
if (methodValues != null) {
|
||||
for (String value : wantToUse) {
|
||||
if (!DisguisePermissions.hasMethodOption(methodValues, value)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
tabs.add(value);
|
||||
}
|
||||
} else {
|
||||
tabs.addAll(wantToUse);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (addMethods) {
|
||||
// If this is a method, add. Else if it can be a param of the previous argument, add.
|
||||
for (Method method : ParamInfoManager.getDisguiseWatcherMethods(disguisePerm.getWatcherClass())) {
|
||||
if (!perms.isAllowedDisguise(disguisePerm, Collections.singletonList(method.getName()))) {
|
||||
for (WatcherMethod method : ParamInfoManager.getDisguiseWatcherMethods(disguisePerm.getWatcherClass())) {
|
||||
if (!perms.isAllowedDisguise(disguisePerm, Collections.singletonList(method.getName())) || !method.isUsable(disguisePerm.getType())) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -188,17 +247,19 @@ public abstract class DisguiseBaseCommand implements CommandExecutor {
|
|||
}
|
||||
|
||||
protected List<String> filterTabs(List<String> list, String[] origArgs) {
|
||||
if (origArgs.length == 0)
|
||||
if (origArgs.length == 0) {
|
||||
return list;
|
||||
}
|
||||
|
||||
Iterator<String> itel = list.iterator();
|
||||
String label = origArgs[origArgs.length - 1].toLowerCase();
|
||||
String label = origArgs[origArgs.length - 1].toLowerCase(Locale.ENGLISH);
|
||||
|
||||
while (itel.hasNext()) {
|
||||
String name = itel.next();
|
||||
|
||||
if (name.toLowerCase().startsWith(label))
|
||||
if (name.toLowerCase(Locale.ENGLISH).startsWith(label)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
itel.remove();
|
||||
}
|
||||
|
@ -207,27 +268,28 @@ public abstract class DisguiseBaseCommand implements CommandExecutor {
|
|||
}
|
||||
|
||||
protected String getDisplayName(CommandSender player) {
|
||||
Team team = ((Player) player).getScoreboard().getEntryTeam(player.getName());
|
||||
String name = DisguiseConfig.getNameAboveDisguise().replace("%simple%", player.getName());
|
||||
|
||||
if (team == null) {
|
||||
team = ((Player) player).getScoreboard().getEntryTeam(((Player) player).getUniqueId().toString());
|
||||
|
||||
if (team == null) {
|
||||
return player.getName();
|
||||
}
|
||||
if (name.contains("%complex%")) {
|
||||
name = name.replace("%complex%", DisguiseUtilities.getDisplayName(player));
|
||||
}
|
||||
|
||||
return team.getPrefix() + team.getColor() + player.getName() + team.getSuffix();
|
||||
return DisguiseUtilities.translateAlternateColorCodes(name);
|
||||
}
|
||||
|
||||
protected ArrayList<String> getAllowedDisguises(DisguisePermissions permissions) {
|
||||
ArrayList<String> allowedDisguises = new ArrayList<>();
|
||||
|
||||
for (DisguisePerm type : permissions.getAllowed()) {
|
||||
if (type.isUnknown())
|
||||
if (type.isUnknown()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
allowedDisguises.add(type.toReadable().replaceAll(" ", "_"));
|
||||
final String name = type.toReadable().replaceAll(" ", "_");
|
||||
|
||||
if (BlockedDisguises.isAllowed(DisguiseParser.getDisguisePerm(name).getType())) {
|
||||
allowedDisguises.add(name);
|
||||
}
|
||||
}
|
||||
|
||||
return allowedDisguises;
|
||||
|
@ -243,8 +305,9 @@ public abstract class DisguiseBaseCommand implements CommandExecutor {
|
|||
for (int i = 0; i < args.length - 1; i++) {
|
||||
String s = args[i];
|
||||
|
||||
if (s.trim().isEmpty())
|
||||
if (s.trim().isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
newArgs.add(s);
|
||||
}
|
||||
|
@ -282,8 +345,7 @@ public abstract class DisguiseBaseCommand implements CommandExecutor {
|
|||
try {
|
||||
Integer.parseInt(string);
|
||||
return true;
|
||||
}
|
||||
catch (Exception ex) {
|
||||
} catch (Exception ex) {
|
||||
return false;
|
||||
}
|
||||
}
|
|
@ -2,7 +2,22 @@ package me.libraryaddict.disguise.commands;
|
|||
|
||||
import lombok.Getter;
|
||||
import me.libraryaddict.disguise.LibsDisguises;
|
||||
import me.libraryaddict.disguise.commands.libsdisguises.*;
|
||||
import me.libraryaddict.disguise.commands.libsdisguises.LDChangelog;
|
||||
import me.libraryaddict.disguise.commands.libsdisguises.LDCommand;
|
||||
import me.libraryaddict.disguise.commands.libsdisguises.LDConfig;
|
||||
import me.libraryaddict.disguise.commands.libsdisguises.LDCount;
|
||||
import me.libraryaddict.disguise.commands.libsdisguises.LDDebugMineSkin;
|
||||
import me.libraryaddict.disguise.commands.libsdisguises.LDDebugPlayer;
|
||||
import me.libraryaddict.disguise.commands.libsdisguises.LDHelp;
|
||||
import me.libraryaddict.disguise.commands.libsdisguises.LDJson;
|
||||
import me.libraryaddict.disguise.commands.libsdisguises.LDMetaInfo;
|
||||
import me.libraryaddict.disguise.commands.libsdisguises.LDMods;
|
||||
import me.libraryaddict.disguise.commands.libsdisguises.LDPermTest;
|
||||
import me.libraryaddict.disguise.commands.libsdisguises.LDReload;
|
||||
import me.libraryaddict.disguise.commands.libsdisguises.LDScoreboard;
|
||||
import me.libraryaddict.disguise.commands.libsdisguises.LDUpdate;
|
||||
import me.libraryaddict.disguise.commands.libsdisguises.LDUpdateProtocolLib;
|
||||
import me.libraryaddict.disguise.commands.libsdisguises.LDUploadLogs;
|
||||
import me.libraryaddict.disguise.utilities.LibsPremium;
|
||||
import me.libraryaddict.disguise.utilities.translations.LibsMsg;
|
||||
import org.bukkit.ChatColor;
|
||||
|
@ -14,6 +29,7 @@ import org.bukkit.command.TabCompleter;
|
|||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
public class LibsDisguisesCommand implements CommandExecutor, TabCompleter {
|
||||
@Getter
|
||||
|
@ -21,9 +37,9 @@ public class LibsDisguisesCommand implements CommandExecutor, TabCompleter {
|
|||
|
||||
public LibsDisguisesCommand() {
|
||||
getCommands().add(new LDHelp(this));
|
||||
getCommands().add(new LDReload());
|
||||
getCommands().add(new LDUpdate());
|
||||
getCommands().add(new LDChangelog());
|
||||
// getCommands().add(new LDReload());
|
||||
// getCommands().add(new LDUpdate());
|
||||
// getCommands().add(new LDChangelog());
|
||||
getCommands().add(new LDCount());
|
||||
getCommands().add(new LDConfig());
|
||||
getCommands().add(new LDPermTest());
|
||||
|
@ -32,20 +48,25 @@ public class LibsDisguisesCommand implements CommandExecutor, TabCompleter {
|
|||
getCommands().add(new LDMods());
|
||||
getCommands().add(new LDMetaInfo());
|
||||
getCommands().add(new LDDebugPlayer());
|
||||
// getCommands().add(new LDUploadLogs());
|
||||
// getCommands().add(new LDUpdateProtocolLib());
|
||||
getCommands().add(new LDDebugMineSkin());
|
||||
}
|
||||
|
||||
protected ArrayList<String> filterTabs(ArrayList<String> list, String[] origArgs) {
|
||||
if (origArgs.length == 0)
|
||||
if (origArgs.length == 0) {
|
||||
return list;
|
||||
}
|
||||
|
||||
Iterator<String> itel = list.iterator();
|
||||
String label = origArgs[origArgs.length - 1].toLowerCase();
|
||||
String label = origArgs[origArgs.length - 1].toLowerCase(Locale.ENGLISH);
|
||||
|
||||
while (itel.hasNext()) {
|
||||
String name = itel.next();
|
||||
|
||||
if (name.toLowerCase().startsWith(label))
|
||||
if (name.toLowerCase(Locale.ENGLISH).startsWith(label)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
itel.remove();
|
||||
}
|
||||
|
@ -59,8 +80,9 @@ public class LibsDisguisesCommand implements CommandExecutor, TabCompleter {
|
|||
for (int i = 0; i < args.length - 1; i++) {
|
||||
String s = args[i];
|
||||
|
||||
if (s.trim().isEmpty())
|
||||
if (s.trim().isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
newArgs.add(s);
|
||||
}
|
||||
|
@ -86,12 +108,11 @@ public class LibsDisguisesCommand implements CommandExecutor, TabCompleter {
|
|||
}
|
||||
|
||||
sender.sendMessage(ChatColor.DARK_GREEN + "This server is running Lib's Disguises " + "v" + version +
|
||||
" by libraryaddict, formerly maintained by Byteflux and NavidK0.");
|
||||
" by libraryaddict, formerly maintained by Byteflux and NavidK0.");
|
||||
|
||||
if (sender.hasPermission("libsdisguises.reload")) {
|
||||
sender.sendMessage(ChatColor.DARK_GREEN + "Use " + ChatColor.GREEN + "/libsdisguises " + "reload" +
|
||||
ChatColor.DARK_GREEN + " to reload the config. All disguises will be blown by doing this" +
|
||||
".");
|
||||
sender.sendMessage(ChatColor.DARK_GREEN + "Use " + ChatColor.GREEN + "/libsdisguises " + "reload" + ChatColor.DARK_GREEN +
|
||||
" to reload the config. All disguises will be blown by doing this" + ".");
|
||||
sender.sendMessage(ChatColor.DARK_GREEN + "Use /libsdisguises help to see more help");
|
||||
}
|
||||
|
||||
|
@ -102,7 +123,7 @@ public class LibsDisguisesCommand implements CommandExecutor, TabCompleter {
|
|||
LDCommand command = null;
|
||||
|
||||
for (LDCommand c : getCommands()) {
|
||||
if (!c.getTabComplete().contains(args[0].toLowerCase())) {
|
||||
if (!c.getTabComplete().contains(args[0].toLowerCase(Locale.ENGLISH))) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -112,13 +133,13 @@ public class LibsDisguisesCommand implements CommandExecutor, TabCompleter {
|
|||
|
||||
if (command != null) {
|
||||
if (!command.hasPermission(sender)) {
|
||||
sender.sendMessage(LibsMsg.NO_PERM.get());
|
||||
LibsMsg.NO_PERM.send(sender);
|
||||
return true;
|
||||
}
|
||||
|
||||
command.onCommand(sender, args);
|
||||
} else {
|
||||
sender.sendMessage(LibsMsg.LIBS_COMMAND_WRONG_ARG.get());
|
||||
LibsMsg.LIBS_COMMAND_WRONG_ARG.send(sender);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,16 +1,20 @@
|
|||
package me.libraryaddict.disguise.commands.disguise;
|
||||
|
||||
import me.libraryaddict.disguise.BlockedDisguises;
|
||||
import me.libraryaddict.disguise.DisguiseAPI;
|
||||
import me.libraryaddict.disguise.DisguiseConfig;
|
||||
import me.libraryaddict.disguise.commands.DisguiseBaseCommand;
|
||||
import me.libraryaddict.disguise.disguisetypes.Disguise;
|
||||
import me.libraryaddict.disguise.disguisetypes.watchers.LivingWatcher;
|
||||
import me.libraryaddict.disguise.utilities.DisguiseUtilities;
|
||||
import me.libraryaddict.disguise.utilities.LibsPremium;
|
||||
import me.libraryaddict.disguise.utilities.parser.DisguiseParseException;
|
||||
import me.libraryaddict.disguise.utilities.parser.DisguiseParser;
|
||||
import me.libraryaddict.disguise.utilities.parser.DisguisePermissions;
|
||||
import me.libraryaddict.disguise.utilities.translations.LibsMsg;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.TabCompleter;
|
||||
|
@ -19,6 +23,7 @@ import org.bukkit.entity.Player;
|
|||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
public class DisguiseCommand extends DisguiseBaseCommand implements TabCompleter {
|
||||
@Override
|
||||
|
@ -28,7 +33,7 @@ public class DisguiseCommand extends DisguiseBaseCommand implements TabCompleter
|
|||
}
|
||||
|
||||
if (!(sender instanceof Entity)) {
|
||||
sender.sendMessage(LibsMsg.NO_CONSOLE.get());
|
||||
LibsMsg.NO_CONSOLE.send(sender);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -37,20 +42,20 @@ public class DisguiseCommand extends DisguiseBaseCommand implements TabCompleter
|
|||
return true;
|
||||
}
|
||||
|
||||
if (hasHitRateLimit(sender)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
Disguise disguise;
|
||||
|
||||
try {
|
||||
disguise = DisguiseParser.parseDisguise(sender, (Entity) sender, getPermNode(),
|
||||
DisguiseUtilities.split(StringUtils.join(args, " ")), getPermissions(sender));
|
||||
}
|
||||
catch (DisguiseParseException ex) {
|
||||
if (ex.getMessage() != null) {
|
||||
sender.sendMessage(ex.getMessage());
|
||||
}
|
||||
disguise = DisguiseParser.parseDisguise(sender, (Entity) sender, getPermNode(), DisguiseUtilities.split(StringUtils.join(args, " ")),
|
||||
getPermissions(sender));
|
||||
} catch (DisguiseParseException ex) {
|
||||
ex.send(sender);
|
||||
|
||||
return true;
|
||||
}
|
||||
catch (Exception ex) {
|
||||
} catch (Throwable ex) {
|
||||
ex.printStackTrace();
|
||||
return true;
|
||||
}
|
||||
|
@ -65,21 +70,41 @@ public class DisguiseCommand extends DisguiseBaseCommand implements TabCompleter
|
|||
}
|
||||
}
|
||||
|
||||
disguise.setEntity((Player) sender);
|
||||
if (!BlockedDisguises.disabled) {
|
||||
|
||||
if (BlockedDisguises.isAllowed(disguise)) {
|
||||
disguise.setEntity((Player) sender);
|
||||
} else {
|
||||
sender.sendMessage(ChatColor.RED + "That disguise is forbidden.");
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
sender.sendMessage(ChatColor.RED + "Disguises are disabled.");
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!setViewDisguise(args)) {
|
||||
// They prefer to have the opposite of whatever the view disguises option is
|
||||
if (DisguiseAPI.hasSelfDisguisePreference(disguise.getEntity()) &&
|
||||
disguise.isSelfDisguiseVisible() == DisguiseConfig.isViewDisguises())
|
||||
disguise.isSelfDisguiseVisible() == DisguiseConfig.isViewSelfDisguisesDefault()) {
|
||||
disguise.setViewSelfDisguise(!disguise.isSelfDisguiseVisible());
|
||||
}
|
||||
}
|
||||
|
||||
disguise.startDisguise();
|
||||
if (!DisguiseAPI.isNotifyBarShown(disguise.getEntity())) {
|
||||
disguise.setNotifyBar(DisguiseConfig.NotifyBar.NONE);
|
||||
}
|
||||
|
||||
if (!sender.isOp() && LibsPremium.isBisectHosted() && !Bukkit.getIp().matches("((25[0-5]|(2[0-4]|1[0-9]|[1-9]|)[0-9])(\\.(?!$)|$)){4}")) {
|
||||
disguise.setExpires(DisguiseConfig.isDynamicExpiry() ? 20 * 60 * 10 : System.currentTimeMillis() + TimeUnit.MINUTES.toMillis(10));
|
||||
}
|
||||
|
||||
disguise.startDisguise(sender);
|
||||
|
||||
if (disguise.isDisguiseInUse()) {
|
||||
sender.sendMessage(LibsMsg.DISGUISED.get(disguise.getDisguiseName()));
|
||||
LibsMsg.DISGUISED.send(sender, disguise.getDisguiseName());
|
||||
} else {
|
||||
sender.sendMessage(LibsMsg.FAILED_DISGIUSE.get(disguise.getDisguiseName()));
|
||||
LibsMsg.FAILED_DISGIUSE.send(sender, disguise.getDisguiseName());
|
||||
}
|
||||
|
||||
return true;
|
||||
|
@ -87,8 +112,9 @@ public class DisguiseCommand extends DisguiseBaseCommand implements TabCompleter
|
|||
|
||||
private boolean setViewDisguise(String[] strings) {
|
||||
for (String string : strings) {
|
||||
if (!string.equalsIgnoreCase("setSelfDisguiseVisible"))
|
||||
if (!string.equalsIgnoreCase("setSelfDisguiseVisible")) {
|
||||
continue;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -112,18 +138,23 @@ public class DisguiseCommand extends DisguiseBaseCommand implements TabCompleter
|
|||
@Override
|
||||
protected void sendCommandUsage(CommandSender sender, DisguisePermissions permissions) {
|
||||
ArrayList<String> allowedDisguises = getAllowedDisguises(permissions);
|
||||
sender.sendMessage(LibsMsg.DISG_HELP1.get());
|
||||
sender.sendMessage(
|
||||
LibsMsg.CAN_USE_DISGS.get(StringUtils.join(allowedDisguises, LibsMsg.CAN_USE_DISGS_SEPERATOR.get())));
|
||||
|
||||
if (allowedDisguises.contains("player")) {
|
||||
sender.sendMessage(LibsMsg.DISG_HELP2.get());
|
||||
if (allowedDisguises.isEmpty()) {
|
||||
LibsMsg.NO_PERM.send(sender);
|
||||
return;
|
||||
}
|
||||
|
||||
sender.sendMessage(LibsMsg.DISG_HELP3.get());
|
||||
LibsMsg.DISG_HELP1.send(sender);
|
||||
LibsMsg.CAN_USE_DISGS.send(sender, StringUtils.join(allowedDisguises, LibsMsg.CAN_USE_DISGS_SEPERATOR.get()));
|
||||
|
||||
if (allowedDisguises.contains("player")) {
|
||||
LibsMsg.DISG_HELP2.send(sender);
|
||||
}
|
||||
|
||||
LibsMsg.DISG_HELP3.send(sender);
|
||||
|
||||
if (allowedDisguises.contains("dropped_item") || allowedDisguises.contains("falling_block")) {
|
||||
sender.sendMessage(LibsMsg.DISG_HELP4.get());
|
||||
LibsMsg.DISG_HELP4.send(sender);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,146 @@
|
|||
package me.libraryaddict.disguise.commands.disguise;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import me.libraryaddict.disguise.BlockedDisguises;
|
||||
import me.libraryaddict.disguise.DisguiseConfig;
|
||||
import me.libraryaddict.disguise.LibsDisguises;
|
||||
import me.libraryaddict.disguise.commands.DisguiseBaseCommand;
|
||||
import me.libraryaddict.disguise.commands.interactions.DisguiseEntityInteraction;
|
||||
import me.libraryaddict.disguise.disguisetypes.Disguise;
|
||||
import me.libraryaddict.disguise.utilities.DisguiseUtilities;
|
||||
import me.libraryaddict.disguise.utilities.parser.DisguiseParseException;
|
||||
import me.libraryaddict.disguise.utilities.parser.DisguiseParser;
|
||||
import me.libraryaddict.disguise.utilities.parser.DisguisePermissions;
|
||||
import me.libraryaddict.disguise.utilities.translations.LibsMsg;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.TabCompleter;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class DisguiseEntityCommand extends DisguiseBaseCommand implements TabCompleter
|
||||
{
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args)
|
||||
{
|
||||
if (isNotPremium(sender))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!(sender instanceof Player))
|
||||
{
|
||||
LibsMsg.NO_CONSOLE.send(sender);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!getPermissions(sender).hasPermissions())
|
||||
{
|
||||
LibsMsg.NO_PERM.send(sender);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (args.length == 0)
|
||||
{
|
||||
sendCommandUsage(sender, getPermissions(sender));
|
||||
return true;
|
||||
}
|
||||
|
||||
if (hasHitRateLimit(sender))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
String[] disguiseArgs = DisguiseUtilities.split(StringUtils.join(args, " "));
|
||||
Disguise testDisguise;
|
||||
|
||||
try
|
||||
{
|
||||
testDisguise = DisguiseParser.parseTestDisguise(sender, getPermNode(), disguiseArgs, getPermissions(sender));
|
||||
}
|
||||
catch (DisguiseParseException ex)
|
||||
{
|
||||
ex.send(sender);
|
||||
|
||||
return true;
|
||||
}
|
||||
catch (Throwable ex)
|
||||
{
|
||||
ex.printStackTrace();
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!BlockedDisguises.disabled)
|
||||
{
|
||||
if (BlockedDisguises.isAllowed(testDisguise))
|
||||
{
|
||||
LibsDisguises.getInstance().getListener()
|
||||
.addInteraction(sender.getName(), new DisguiseEntityInteraction(disguiseArgs), DisguiseConfig.getDisguiseEntityExpire());
|
||||
|
||||
LibsMsg.DISG_ENT_CLICK.send(sender, DisguiseConfig.getDisguiseEntityExpire(), testDisguise.getDisguiseName());
|
||||
}
|
||||
else
|
||||
{
|
||||
sender.sendMessage(ChatColor.RED + "That disguise is forbidden.");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
sender.sendMessage(ChatColor.RED + "Disguises are disabled.");
|
||||
return true;
|
||||
}
|
||||
|
||||
LibsMsg.DISG_ENT_CLICK.send(sender, DisguiseConfig.getDisguiseEntityExpire(), testDisguise.getDisguiseName());
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> onTabComplete(CommandSender sender, Command cmd, String label, String[] origArgs)
|
||||
{
|
||||
ArrayList<String> tabs = new ArrayList<>();
|
||||
|
||||
if (!(sender instanceof Player))
|
||||
{
|
||||
return tabs;
|
||||
}
|
||||
|
||||
String[] args = getPreviousArgs(origArgs);
|
||||
|
||||
DisguisePermissions perms = getPermissions(sender);
|
||||
|
||||
return filterTabs(getTabDisguiseTypes(sender, perms, args, 0, getCurrentArg(origArgs)), origArgs);
|
||||
}
|
||||
|
||||
/**
|
||||
* Send the player the information
|
||||
*/
|
||||
@Override
|
||||
protected void sendCommandUsage(CommandSender sender, DisguisePermissions permissions)
|
||||
{
|
||||
ArrayList<String> allowedDisguises = getAllowedDisguises(permissions);
|
||||
|
||||
if (allowedDisguises.isEmpty())
|
||||
{
|
||||
LibsMsg.NO_PERM.send(sender);
|
||||
return;
|
||||
}
|
||||
|
||||
LibsMsg.DISG_ENT_HELP1.send(sender);
|
||||
LibsMsg.CAN_USE_DISGS.send(sender, StringUtils.join(allowedDisguises, LibsMsg.CAN_USE_DISGS_SEPERATOR.get()));
|
||||
|
||||
if (allowedDisguises.contains("player"))
|
||||
{
|
||||
LibsMsg.DISG_ENT_HELP3.send(sender);
|
||||
}
|
||||
|
||||
LibsMsg.DISG_ENT_HELP4.send(sender);
|
||||
|
||||
if (allowedDisguises.contains("dropped_item") || allowedDisguises.contains("falling_block"))
|
||||
{
|
||||
LibsMsg.DISG_ENT_HELP5.send(sender);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -34,7 +34,7 @@ public class DisguisePlayerCommand extends DisguiseBaseCommand implements TabCom
|
|||
DisguisePermissions permissions = getPermissions(sender);
|
||||
|
||||
if (!permissions.hasPermissions()) {
|
||||
sender.sendMessage(LibsMsg.NO_PERM.get());
|
||||
LibsMsg.NO_PERM.send(sender);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -44,7 +44,11 @@ public class DisguisePlayerCommand extends DisguiseBaseCommand implements TabCom
|
|||
}
|
||||
|
||||
if (args.length == 1) {
|
||||
sender.sendMessage(LibsMsg.DPLAYER_SUPPLY.get());
|
||||
LibsMsg.DPLAYER_SUPPLY.send(sender);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (hasHitRateLimit(sender)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -54,14 +58,13 @@ public class DisguisePlayerCommand extends DisguiseBaseCommand implements TabCom
|
|||
if (args[0].contains("-")) {
|
||||
try {
|
||||
entityTarget = Bukkit.getEntity(UUID.fromString(args[0]));
|
||||
}
|
||||
catch (Exception ignored) {
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (entityTarget == null) {
|
||||
sender.sendMessage(LibsMsg.CANNOT_FIND_PLAYER.get(args[0]));
|
||||
LibsMsg.CANNOT_FIND_PLAYER.send(sender, args[0]);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -76,28 +79,21 @@ public class DisguisePlayerCommand extends DisguiseBaseCommand implements TabCom
|
|||
Disguise disguise;
|
||||
|
||||
try {
|
||||
disguise = DisguiseParser.parseDisguise(sender, entityTarget, getPermNode(),
|
||||
DisguiseUtilities.split(StringUtils.join(newArgs, " ")), permissions);
|
||||
}
|
||||
catch (DisguiseParseException ex) {
|
||||
if (ex.getMessage() != null) {
|
||||
sender.sendMessage(ex.getMessage());
|
||||
}
|
||||
disguise = DisguiseParser.parseDisguise(sender, entityTarget, getPermNode(), DisguiseUtilities.split(StringUtils.join(newArgs, " ")), permissions);
|
||||
} catch (DisguiseParseException ex) {
|
||||
ex.send(sender);
|
||||
return true;
|
||||
}
|
||||
|
||||
catch (Exception ex) {
|
||||
} catch (Throwable ex) {
|
||||
ex.printStackTrace();
|
||||
return true;
|
||||
}
|
||||
|
||||
if (disguise.isMiscDisguise() && !DisguiseConfig.isMiscDisguisesForLivingEnabled()) {
|
||||
sender.sendMessage(LibsMsg.DISABLED_LIVING_TO_MISC.get());
|
||||
LibsMsg.DISABLED_LIVING_TO_MISC.send(sender);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (DisguiseConfig.isNameOfPlayerShownAboveDisguise() &&
|
||||
!entityTarget.hasPermission("libsdisguises.hidename")) {
|
||||
if (DisguiseConfig.isNameOfPlayerShownAboveDisguise() && !entityTarget.hasPermission("libsdisguises.hidename")) {
|
||||
if (disguise.getWatcher() instanceof LivingWatcher) {
|
||||
disguise.getWatcher().setCustomName(getDisplayName(entityTarget));
|
||||
|
||||
|
@ -112,19 +108,23 @@ public class DisguisePlayerCommand extends DisguiseBaseCommand implements TabCom
|
|||
if (!setViewDisguise(args)) {
|
||||
// They prefer to have the opposite of whatever the view disguises option is
|
||||
if (DisguiseAPI.hasSelfDisguisePreference(disguise.getEntity()) &&
|
||||
disguise.isSelfDisguiseVisible() == DisguiseConfig.isViewDisguises())
|
||||
disguise.isSelfDisguiseVisible() == DisguiseConfig.isViewSelfDisguisesDefault()) {
|
||||
disguise.setViewSelfDisguise(!disguise.isSelfDisguiseVisible());
|
||||
}
|
||||
}
|
||||
|
||||
disguise.startDisguise();
|
||||
if (!DisguiseAPI.isNotifyBarShown(disguise.getEntity())) {
|
||||
disguise.setNotifyBar(DisguiseConfig.NotifyBar.NONE);
|
||||
}
|
||||
|
||||
disguise.startDisguise(sender);
|
||||
|
||||
if (disguise.isDisguiseInUse()) {
|
||||
sender.sendMessage(LibsMsg.DISG_PLAYER_AS_DISG.get(entityTarget instanceof Player ? entityTarget.getName() :
|
||||
DisguiseType.getType(entityTarget).toReadable(), disguise.getDisguiseName()));
|
||||
LibsMsg.DISG_PLAYER_AS_DISG.send(sender, entityTarget instanceof Player ? entityTarget.getName() : DisguiseType.getType(entityTarget).toReadable(),
|
||||
disguise.getDisguiseName());
|
||||
} else {
|
||||
sender.sendMessage(LibsMsg.DISG_PLAYER_AS_DISG_FAIL
|
||||
.get(entityTarget instanceof Player ? entityTarget.getName() :
|
||||
DisguiseType.getType(entityTarget).toReadable(), disguise.getDisguiseName()));
|
||||
LibsMsg.DISG_PLAYER_AS_DISG_FAIL.send(sender,
|
||||
entityTarget instanceof Player ? entityTarget.getName() : DisguiseType.getType(entityTarget).toReadable(), disguise.getDisguiseName());
|
||||
}
|
||||
|
||||
return true;
|
||||
|
@ -132,8 +132,9 @@ public class DisguisePlayerCommand extends DisguiseBaseCommand implements TabCom
|
|||
|
||||
private boolean setViewDisguise(String[] strings) {
|
||||
for (String string : strings) {
|
||||
if (!string.equalsIgnoreCase("setSelfDisguiseVisible"))
|
||||
if (!string.equalsIgnoreCase("setSelfDisguiseVisible")) {
|
||||
continue;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -171,18 +172,22 @@ public class DisguisePlayerCommand extends DisguiseBaseCommand implements TabCom
|
|||
protected void sendCommandUsage(CommandSender sender, DisguisePermissions permissions) {
|
||||
ArrayList<String> allowedDisguises = getAllowedDisguises(permissions);
|
||||
|
||||
sender.sendMessage(LibsMsg.D_HELP1.get());
|
||||
sender.sendMessage(
|
||||
LibsMsg.CAN_USE_DISGS.get(StringUtils.join(allowedDisguises, LibsMsg.CAN_USE_DISGS_SEPERATOR.get())));
|
||||
|
||||
if (allowedDisguises.contains("player")) {
|
||||
sender.sendMessage(LibsMsg.D_HELP3.get());
|
||||
if (allowedDisguises.isEmpty()) {
|
||||
LibsMsg.NO_PERM.send(sender);
|
||||
return;
|
||||
}
|
||||
|
||||
sender.sendMessage(LibsMsg.D_HELP4.get());
|
||||
LibsMsg.D_HELP1.send(sender);
|
||||
LibsMsg.CAN_USE_DISGS.send(sender, StringUtils.join(allowedDisguises, LibsMsg.CAN_USE_DISGS_SEPERATOR.get()));
|
||||
|
||||
if (allowedDisguises.contains("player")) {
|
||||
LibsMsg.D_HELP3.send(sender);
|
||||
}
|
||||
|
||||
LibsMsg.D_HELP4.send(sender);
|
||||
|
||||
if (allowedDisguises.contains("dropped_item") || allowedDisguises.contains("falling_block")) {
|
||||
sender.sendMessage(LibsMsg.D_HELP5.get());
|
||||
LibsMsg.D_HELP5.send(sender);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -26,14 +26,12 @@ import org.bukkit.entity.Player;
|
|||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
public class DisguiseRadiusCommand extends DisguiseBaseCommand implements TabCompleter {
|
||||
private int maxRadius = 30;
|
||||
private ArrayList<Class<? extends Entity>> validClasses = new ArrayList<>();
|
||||
|
||||
public DisguiseRadiusCommand(int maxRadius) {
|
||||
this.maxRadius = maxRadius;
|
||||
|
||||
public DisguiseRadiusCommand() {
|
||||
for (EntityType type : EntityType.values()) {
|
||||
Class c = type.getEntityClass();
|
||||
|
||||
|
@ -52,14 +50,14 @@ public class DisguiseRadiusCommand extends DisguiseBaseCommand implements TabCom
|
|||
}
|
||||
|
||||
if (sender.getName().equals("CONSOLE")) {
|
||||
sender.sendMessage(LibsMsg.NO_CONSOLE.get());
|
||||
LibsMsg.NO_CONSOLE.send(sender);
|
||||
return true;
|
||||
}
|
||||
|
||||
DisguisePermissions permissions = getPermissions(sender);
|
||||
|
||||
if (!permissions.hasPermissions()) {
|
||||
sender.sendMessage(LibsMsg.NO_PERM.get());
|
||||
LibsMsg.NO_PERM.send(sender);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -68,8 +66,11 @@ public class DisguiseRadiusCommand extends DisguiseBaseCommand implements TabCom
|
|||
return true;
|
||||
}
|
||||
|
||||
if (args[0].equalsIgnoreCase(TranslateType.DISGUISES.get("EntityType")) ||
|
||||
args[0].equalsIgnoreCase(TranslateType.DISGUISES.get("EntityType") + "s")) {
|
||||
if (hasHitRateLimit(sender)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (args[0].equalsIgnoreCase(TranslateType.DISGUISES.get("EntityType")) || args[0].equalsIgnoreCase(TranslateType.DISGUISES.get("EntityType") + "s")) {
|
||||
ArrayList<String> classes = new ArrayList<>();
|
||||
|
||||
for (Class c : validClasses) {
|
||||
|
@ -78,8 +79,7 @@ public class DisguiseRadiusCommand extends DisguiseBaseCommand implements TabCom
|
|||
|
||||
Collections.sort(classes);
|
||||
|
||||
sender.sendMessage(LibsMsg.DRADIUS_ENTITIES
|
||||
.get(ChatColor.GREEN + StringUtils.join(classes, ChatColor.DARK_GREEN + ", " + ChatColor.GREEN)));
|
||||
LibsMsg.DRADIUS_ENTITIES.send(sender, ChatColor.GREEN + StringUtils.join(classes, ChatColor.DARK_GREEN + ", " + ChatColor.GREEN));
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -98,37 +98,40 @@ public class DisguiseRadiusCommand extends DisguiseBaseCommand implements TabCom
|
|||
|
||||
if (starting == 0) {
|
||||
try {
|
||||
type = EntityType.valueOf(args[0].toUpperCase());
|
||||
}
|
||||
catch (Exception ignored) {
|
||||
type = EntityType.valueOf(args[0].toUpperCase(Locale.ENGLISH));
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
|
||||
if (type == null) {
|
||||
sender.sendMessage(LibsMsg.DMODRADIUS_UNRECOGNIZED.get(args[0]));
|
||||
LibsMsg.DMODRADIUS_UNRECOGNIZED.send(sender, args[0]);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (args.length == starting + 1) {
|
||||
sender.sendMessage(
|
||||
(starting == 0 ? LibsMsg.DRADIUS_NEEDOPTIONS : LibsMsg.DRADIUS_NEEDOPTIONS_ENTITY).get());
|
||||
if (starting == 0) {
|
||||
LibsMsg.DRADIUS_NEEDOPTIONS.send(sender);
|
||||
} else {
|
||||
LibsMsg.DRADIUS_NEEDOPTIONS_ENTITY.send(sender);
|
||||
}
|
||||
|
||||
return true;
|
||||
} else if (args.length < 2) {
|
||||
sender.sendMessage(LibsMsg.DRADIUS_NEEDOPTIONS.get());
|
||||
LibsMsg.DRADIUS_NEEDOPTIONS.send(sender);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!isInteger(args[starting])) {
|
||||
sender.sendMessage(LibsMsg.NOT_NUMBER.get(args[starting]));
|
||||
LibsMsg.NOT_NUMBER.send(sender, args[starting]);
|
||||
return true;
|
||||
}
|
||||
|
||||
int radius = Integer.parseInt(args[starting]);
|
||||
|
||||
if (radius > maxRadius) {
|
||||
sender.sendMessage(LibsMsg.LIMITED_RADIUS.get(maxRadius));
|
||||
radius = maxRadius;
|
||||
if (radius > DisguiseConfig.getDisguiseRadiusMax()) {
|
||||
LibsMsg.LIMITED_RADIUS.send(sender, DisguiseConfig.getDisguiseRadiusMax());
|
||||
radius = DisguiseConfig.getDisguiseRadiusMax();
|
||||
}
|
||||
|
||||
String[] newArgs = new String[args.length - (starting + 1)];
|
||||
|
@ -166,19 +169,17 @@ public class DisguiseRadiusCommand extends DisguiseBaseCommand implements TabCom
|
|||
continue;
|
||||
}
|
||||
|
||||
if (testDisguise.isMiscDisguise() && !DisguiseConfig.isMiscDisguisesForLivingEnabled() &&
|
||||
entity instanceof LivingEntity) {
|
||||
if (testDisguise.isMiscDisguise() && !DisguiseConfig.isMiscDisguisesForLivingEnabled() && entity instanceof LivingEntity) {
|
||||
miscDisguises++;
|
||||
continue;
|
||||
}
|
||||
|
||||
Disguise disguise = DisguiseParser
|
||||
.parseDisguise(sender, entity, getPermNode(), disguiseArgs, permissions);
|
||||
Disguise disguise = DisguiseParser.parseDisguise(sender, entity, getPermNode(), disguiseArgs, permissions);
|
||||
|
||||
if (entity instanceof Player && DisguiseConfig.isNameOfPlayerShownAboveDisguise() &&
|
||||
!entity.hasPermission("libsdisguises.hidename")) {
|
||||
if (entity instanceof Player && DisguiseConfig.isNameOfPlayerShownAboveDisguise() && !entity.hasPermission("libsdisguises.hidename")) {
|
||||
if (disguise.getWatcher() instanceof LivingWatcher) {
|
||||
disguise.getWatcher().setCustomName(getDisplayName(entity));
|
||||
|
||||
if (DisguiseConfig.isNameAboveHeadAlwaysVisible()) {
|
||||
disguise.getWatcher().setCustomNameVisible(true);
|
||||
}
|
||||
|
@ -190,11 +191,16 @@ public class DisguiseRadiusCommand extends DisguiseBaseCommand implements TabCom
|
|||
if (!setViewDisguise(args)) {
|
||||
// They prefer to have the opposite of whatever the view disguises option is
|
||||
if (DisguiseAPI.hasSelfDisguisePreference(disguise.getEntity()) &&
|
||||
disguise.isSelfDisguiseVisible() == DisguiseConfig.isViewDisguises())
|
||||
disguise.isSelfDisguiseVisible() == DisguiseConfig.isViewSelfDisguisesDefault()) {
|
||||
disguise.setViewSelfDisguise(!disguise.isSelfDisguiseVisible());
|
||||
}
|
||||
}
|
||||
|
||||
disguise.startDisguise();
|
||||
if (!DisguiseAPI.isNotifyBarShown(disguise.getEntity())) {
|
||||
disguise.setNotifyBar(DisguiseConfig.NotifyBar.NONE);
|
||||
}
|
||||
|
||||
disguise.startDisguise(sender);
|
||||
|
||||
if (disguise.isDisguiseInUse()) {
|
||||
disguisedEntitys++;
|
||||
|
@ -202,21 +208,17 @@ public class DisguiseRadiusCommand extends DisguiseBaseCommand implements TabCom
|
|||
}
|
||||
|
||||
if (disguisedEntitys > 0) {
|
||||
sender.sendMessage(LibsMsg.DISRADIUS.get(disguisedEntitys));
|
||||
LibsMsg.DISRADIUS.send(sender, disguisedEntitys);
|
||||
} else {
|
||||
sender.sendMessage(LibsMsg.DISRADIUS_FAIL.get());
|
||||
LibsMsg.DISRADIUS_FAIL.send(sender);
|
||||
}
|
||||
|
||||
if (miscDisguises > 0) {
|
||||
sender.sendMessage(LibsMsg.DRADIUS_MISCDISG.get(miscDisguises));
|
||||
LibsMsg.DRADIUS_MISCDISG.send(sender, miscDisguises);
|
||||
}
|
||||
}
|
||||
catch (DisguiseParseException ex) {
|
||||
if (ex.getMessage() != null) {
|
||||
sender.sendMessage(ex.getMessage());
|
||||
}
|
||||
}
|
||||
catch (Exception ex) {
|
||||
} catch (DisguiseParseException ex) {
|
||||
ex.send(sender);
|
||||
} catch (Throwable ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
|
||||
|
@ -225,8 +227,9 @@ public class DisguiseRadiusCommand extends DisguiseBaseCommand implements TabCom
|
|||
|
||||
private boolean setViewDisguise(String[] strings) {
|
||||
for (String string : strings) {
|
||||
if (!string.equalsIgnoreCase("setSelfDisguiseVisible"))
|
||||
if (!string.equalsIgnoreCase("setSelfDisguiseVisible")) {
|
||||
continue;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -253,16 +256,18 @@ public class DisguiseRadiusCommand extends DisguiseBaseCommand implements TabCom
|
|||
|
||||
if (!isInteger(args[0])) {
|
||||
for (Class c : validClasses) {
|
||||
if (!TranslateType.DISGUISES.get(c.getSimpleName()).equalsIgnoreCase(args[0]))
|
||||
if (!TranslateType.DISGUISES.get(c.getSimpleName()).equalsIgnoreCase(args[0])) {
|
||||
continue;
|
||||
}
|
||||
|
||||
starting = 2;
|
||||
break;
|
||||
}
|
||||
|
||||
// Not a valid radius
|
||||
if (starting == 1 || args.length == 1 || !isInteger(args[1]))
|
||||
if (starting == 1 || args.length == 1 || !isInteger(args[1])) {
|
||||
return filterTabs(tabs, origArgs);
|
||||
}
|
||||
}
|
||||
|
||||
tabs.addAll(getTabDisguiseTypes(sender, perms, args, starting, getCurrentArg(origArgs)));
|
||||
|
@ -277,20 +282,24 @@ public class DisguiseRadiusCommand extends DisguiseBaseCommand implements TabCom
|
|||
protected void sendCommandUsage(CommandSender sender, DisguisePermissions permissions) {
|
||||
ArrayList<String> allowedDisguises = getAllowedDisguises(permissions);
|
||||
|
||||
sender.sendMessage(LibsMsg.DRADIUS_HELP1.get(maxRadius));
|
||||
sender.sendMessage(
|
||||
LibsMsg.CAN_USE_DISGS.get(StringUtils.join(allowedDisguises, LibsMsg.CAN_USE_DISGS_SEPERATOR.get())));
|
||||
if (allowedDisguises.isEmpty()) {
|
||||
LibsMsg.NO_PERM.send(sender);
|
||||
return;
|
||||
}
|
||||
|
||||
LibsMsg.DRADIUS_HELP1.send(sender, DisguiseConfig.getDisguiseRadiusMax());
|
||||
LibsMsg.CAN_USE_DISGS.send(sender, StringUtils.join(allowedDisguises, LibsMsg.CAN_USE_DISGS_SEPERATOR.get()));
|
||||
|
||||
if (allowedDisguises.contains("player")) {
|
||||
sender.sendMessage(LibsMsg.DRADIUS_HELP3.get());
|
||||
LibsMsg.DRADIUS_HELP3.send(sender);
|
||||
}
|
||||
|
||||
sender.sendMessage(LibsMsg.DRADIUS_HELP4.get());
|
||||
LibsMsg.DRADIUS_HELP4.send(sender);
|
||||
|
||||
if (allowedDisguises.contains("dropped_item") || allowedDisguises.contains("falling_block")) {
|
||||
sender.sendMessage(LibsMsg.DRADIUS_HELP5.get());
|
||||
LibsMsg.DRADIUS_HELP5.send(sender);
|
||||
}
|
||||
|
||||
sender.sendMessage(LibsMsg.DRADIUS_HELP6.get());
|
||||
LibsMsg.DRADIUS_HELP6.send(sender);
|
||||
}
|
||||
}
|
|
@ -26,16 +26,14 @@ public class CopyDisguiseInteraction implements LibsEntityInteract {
|
|||
Disguise disguise = DisguiseAPI.getDisguise(player, entity);
|
||||
String disguiseString = DisguiseParser.parseToString(disguise, false);
|
||||
|
||||
getCopyDisguiseCommand()
|
||||
.sendMessage(player, LibsMsg.CLICK_TO_COPY, LibsMsg.COPY_DISGUISE_NO_COPY, disguiseString, false);
|
||||
getCopyDisguiseCommand().sendMessage(player, LibsMsg.CLICK_TO_COPY, LibsMsg.COPY_DISGUISE_NO_COPY, disguiseString, false);
|
||||
|
||||
if (disguise instanceof PlayerDisguise) {
|
||||
getCopyDisguiseCommand()
|
||||
.sendMessage(player, LibsMsg.CLICK_TO_COPY_WITH_SKIN, LibsMsg.CLICK_TO_COPY_WITH_SKIN_NO_COPY,
|
||||
DisguiseParser.parseToString(disguise), true);
|
||||
getCopyDisguiseCommand().sendMessage(player, LibsMsg.CLICK_TO_COPY_WITH_SKIN, LibsMsg.CLICK_TO_COPY_WITH_SKIN_NO_COPY,
|
||||
DisguiseParser.parseToString(disguise), true);
|
||||
}
|
||||
} else {
|
||||
player.sendMessage(LibsMsg.TARGET_NOT_DISGUISED.get());
|
||||
LibsMsg.TARGET_NOT_DISGUISED.send(player);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -6,14 +6,15 @@ import me.libraryaddict.disguise.DisguiseConfig;
|
|||
import me.libraryaddict.disguise.disguisetypes.Disguise;
|
||||
import me.libraryaddict.disguise.disguisetypes.DisguiseType;
|
||||
import me.libraryaddict.disguise.disguisetypes.watchers.LivingWatcher;
|
||||
import me.libraryaddict.disguise.utilities.DisguiseUtilities;
|
||||
import me.libraryaddict.disguise.utilities.LibsEntityInteract;
|
||||
import me.libraryaddict.disguise.utilities.parser.DisguiseParseException;
|
||||
import me.libraryaddict.disguise.utilities.parser.DisguiseParser;
|
||||
import me.libraryaddict.disguise.utilities.translations.LibsMsg;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.scoreboard.Team;
|
||||
|
||||
/**
|
||||
* Created by libraryaddict on 4/04/2020.
|
||||
|
@ -35,32 +36,21 @@ public class DisguiseEntityInteraction implements LibsEntityInteract {
|
|||
Disguise disguise;
|
||||
|
||||
try {
|
||||
disguise = DisguiseParser.parseDisguise(p, entity, "disguiseentity", disguiseArgs,
|
||||
DisguiseParser.getPermissions(p, "disguiseentity"));
|
||||
}
|
||||
catch (DisguiseParseException e) {
|
||||
if (e.getMessage() != null) {
|
||||
p.sendMessage(e.getMessage());
|
||||
}
|
||||
|
||||
disguise = DisguiseParser.parseDisguise(p, entity, "disguiseentity", disguiseArgs, DisguiseParser.getPermissions(p, "disguiseentity"));
|
||||
} catch (DisguiseParseException e) {
|
||||
e.send(p);
|
||||
return;
|
||||
}
|
||||
catch (Exception e) {
|
||||
} catch (Throwable e) {
|
||||
e.printStackTrace();
|
||||
return;
|
||||
}
|
||||
|
||||
if (disguise.isMiscDisguise() && !DisguiseConfig.isMiscDisguisesForLivingEnabled() &&
|
||||
entity instanceof LivingEntity) {
|
||||
p.sendMessage(LibsMsg.DISABLED_LIVING_TO_MISC.get());
|
||||
if (disguise.isMiscDisguise() && !DisguiseConfig.isMiscDisguisesForLivingEnabled() && entity instanceof LivingEntity) {
|
||||
LibsMsg.DISABLED_LIVING_TO_MISC.send(p);
|
||||
} else {
|
||||
if (entity instanceof Player && DisguiseConfig.isNameOfPlayerShownAboveDisguise() &&
|
||||
!entity.hasPermission("libsdisguises.hidename")) {
|
||||
if (entity instanceof Player && DisguiseConfig.isNameOfPlayerShownAboveDisguise() && !entity.hasPermission("libsdisguises.hidename")) {
|
||||
if (disguise.getWatcher() instanceof LivingWatcher) {
|
||||
Team team = ((Player) entity).getScoreboard().getEntryTeam(entity.getName());
|
||||
|
||||
disguise.getWatcher().setCustomName((team == null ? "" : team.getPrefix()) + entity.getName() +
|
||||
(team == null ? "" : team.getSuffix()));
|
||||
disguise.getWatcher().setCustomName(getDisplayName(entity));
|
||||
|
||||
if (DisguiseConfig.isNameAboveHeadAlwaysVisible()) {
|
||||
disguise.getWatcher().setCustomNameVisible(true);
|
||||
|
@ -68,7 +58,7 @@ public class DisguiseEntityInteraction implements LibsEntityInteract {
|
|||
}
|
||||
}
|
||||
|
||||
DisguiseAPI.disguiseEntity(entity, disguise);
|
||||
DisguiseAPI.disguiseEntity(p, entity, disguise);
|
||||
|
||||
String disguiseName = disguise.getDisguiseName();
|
||||
|
||||
|
@ -76,32 +66,42 @@ public class DisguiseEntityInteraction implements LibsEntityInteract {
|
|||
if (disguise.isDisguiseInUse()) {
|
||||
if (disguise.isPlayerDisguise()) {
|
||||
if (entity instanceof Player) {
|
||||
p.sendMessage(LibsMsg.LISTEN_ENTITY_PLAYER_DISG_PLAYER.get(entityName, disguiseName));
|
||||
LibsMsg.LISTEN_ENTITY_PLAYER_DISG_PLAYER.send(p, entityName, disguiseName);
|
||||
} else {
|
||||
p.sendMessage(LibsMsg.LISTEN_ENTITY_ENTITY_DISG_PLAYER.get(entityName, disguiseName));
|
||||
LibsMsg.LISTEN_ENTITY_ENTITY_DISG_PLAYER.send(p, entityName, disguiseName);
|
||||
}
|
||||
} else {
|
||||
if (entity instanceof Player) {
|
||||
p.sendMessage(LibsMsg.LISTEN_ENTITY_PLAYER_DISG_ENTITY.get(entityName, disguiseName));
|
||||
LibsMsg.LISTEN_ENTITY_PLAYER_DISG_ENTITY.send(p, entityName, disguiseName);
|
||||
} else {
|
||||
p.sendMessage(LibsMsg.LISTEN_ENTITY_ENTITY_DISG_ENTITY.get(entityName, disguiseName));
|
||||
LibsMsg.LISTEN_ENTITY_ENTITY_DISG_ENTITY.send(p, entityName, disguiseName);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (disguise.isPlayerDisguise()) {
|
||||
if (entity instanceof Player) {
|
||||
p.sendMessage(LibsMsg.LISTEN_ENTITY_PLAYER_DISG_PLAYER_FAIL.get(entityName, disguiseName));
|
||||
LibsMsg.LISTEN_ENTITY_PLAYER_DISG_PLAYER_FAIL.send(p, entityName, disguiseName);
|
||||
} else {
|
||||
p.sendMessage(LibsMsg.LISTEN_ENTITY_ENTITY_DISG_PLAYER_FAIL.get(entityName, disguiseName));
|
||||
LibsMsg.LISTEN_ENTITY_ENTITY_DISG_PLAYER_FAIL.send(p, entityName, disguiseName);
|
||||
}
|
||||
} else {
|
||||
if (entity instanceof Player) {
|
||||
p.sendMessage(LibsMsg.LISTEN_ENTITY_PLAYER_DISG_ENTITY_FAIL.get(entityName, disguiseName));
|
||||
LibsMsg.LISTEN_ENTITY_PLAYER_DISG_ENTITY_FAIL.send(p, entityName, disguiseName);
|
||||
} else {
|
||||
p.sendMessage(LibsMsg.LISTEN_ENTITY_ENTITY_DISG_ENTITY_FAIL.get(entityName, disguiseName));
|
||||
LibsMsg.LISTEN_ENTITY_ENTITY_DISG_ENTITY_FAIL.send(p, entityName, disguiseName);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected String getDisplayName(CommandSender player) {
|
||||
String name = DisguiseConfig.getNameAboveDisguise().replace("%simple%", player.getName());
|
||||
|
||||
if (name.contains("%complex%")) {
|
||||
name = name.replace("%complex%", DisguiseUtilities.getDisplayName(player));
|
||||
}
|
||||
|
||||
return DisguiseUtilities.translateAlternateColorCodes(name);
|
||||
}
|
||||
}
|
|
@ -37,7 +37,7 @@ public class DisguiseModifyInteraction implements LibsEntityInteract {
|
|||
Disguise disguise = DisguiseAPI.getDisguise(p, entity);
|
||||
|
||||
if (disguise == null) {
|
||||
p.sendMessage(LibsMsg.UNDISG_PLAYER_FAIL.get(entityName));
|
||||
LibsMsg.UNDISG_PLAYER_FAIL.send(p, entityName);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -47,22 +47,16 @@ public class DisguiseModifyInteraction implements LibsEntityInteract {
|
|||
DisguisePerm disguisePerm = new DisguisePerm(disguise.getType());
|
||||
|
||||
if (!perms.isAllowedDisguise(disguisePerm, Arrays.asList(options))) {
|
||||
p.sendMessage(LibsMsg.DMODPLAYER_NOPERM.get());
|
||||
LibsMsg.DMODPLAYER_NOPERM.send(p);
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
DisguiseParser
|
||||
.callMethods(p, disguise, perms, disguisePerm, new ArrayList<>(Arrays.asList(options)), options,
|
||||
"DisguiseModifyEntity");
|
||||
p.sendMessage(LibsMsg.LISTENER_MODIFIED_DISG.get());
|
||||
}
|
||||
catch (DisguiseParseException ex) {
|
||||
if (ex.getMessage() != null) {
|
||||
p.sendMessage(ex.getMessage());
|
||||
}
|
||||
}
|
||||
catch (Exception ex) {
|
||||
DisguiseParser.callMethods(p, disguise, perms, disguisePerm, new ArrayList<>(Arrays.asList(options)), options, "DisguiseModifyEntity");
|
||||
LibsMsg.LISTENER_MODIFIED_DISG.send(p);
|
||||
} catch (DisguiseParseException ex) {
|
||||
ex.send(p);
|
||||
} catch (Throwable ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
}
|
|
@ -22,17 +22,19 @@ public class UndisguiseEntityInteraction implements LibsEntityInteract {
|
|||
}
|
||||
|
||||
if (DisguiseAPI.isDisguised(entity)) {
|
||||
DisguiseAPI.undisguiseToAll(entity);
|
||||
DisguiseAPI.undisguiseToAll(p, entity);
|
||||
|
||||
if (entity instanceof Player)
|
||||
p.sendMessage(LibsMsg.LISTEN_UNDISG_PLAYER.get(entityName));
|
||||
else
|
||||
p.sendMessage(LibsMsg.LISTEN_UNDISG_ENT.get(entityName));
|
||||
if (entity instanceof Player) {
|
||||
LibsMsg.LISTEN_UNDISG_PLAYER.send(p, entityName);
|
||||
} else {
|
||||
LibsMsg.LISTEN_UNDISG_ENT.send(p, entityName);
|
||||
}
|
||||
} else {
|
||||
if (entity instanceof Player)
|
||||
p.sendMessage(LibsMsg.LISTEN_UNDISG_PLAYER_FAIL.get(entityName));
|
||||
else
|
||||
p.sendMessage(LibsMsg.LISTEN_UNDISG_ENT_FAIL.get(entityName));
|
||||
if (entity instanceof Player) {
|
||||
LibsMsg.LISTEN_UNDISG_PLAYER_FAIL.send(p, entityName);
|
||||
} else {
|
||||
LibsMsg.LISTEN_UNDISG_ENT_FAIL.send(p, entityName);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -33,19 +33,18 @@ public class LDChangelog implements LDCommand {
|
|||
UpdateChecker checker = LibsDisguises.getInstance().getUpdateChecker();
|
||||
|
||||
if (checker.isDownloading()) {
|
||||
sender.sendMessage(LibsMsg.UPDATE_IN_PROGRESS.get());
|
||||
LibsMsg.UPDATE_IN_PROGRESS.send(sender);
|
||||
return;
|
||||
}
|
||||
|
||||
if (checker.getUpdate() == null) {
|
||||
sender.sendMessage(LibsMsg.UPDATE_REQUIRED.get());
|
||||
LibsMsg.UPDATE_REQUIRED.send(sender);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!checker.getUpdate().isReleaseBuild()) {
|
||||
sender.sendMessage(
|
||||
ChatColor.GOLD + "You are on build " + (LibsDisguises.getInstance().isNumberedBuild() ? "#" : "") +
|
||||
LibsDisguises.getInstance().getBuildNo());
|
||||
ChatColor.GOLD + "You are on build " + (LibsDisguises.getInstance().isNumberedBuild() ? "#" : "") + LibsDisguises.getInstance().getBuildNo());
|
||||
}
|
||||
|
||||
for (String msg : checker.getUpdate().getChangelog()) {
|
|
@ -1,7 +1,6 @@
|
|||
package me.libraryaddict.disguise.commands.libsdisguises;
|
||||
|
||||
import me.libraryaddict.disguise.DisguiseConfig;
|
||||
import me.libraryaddict.disguise.LibsDisguises;
|
||||
import me.libraryaddict.disguise.utilities.translations.LibsMsg;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
@ -31,10 +30,10 @@ public class LDConfig implements LDCommand {
|
|||
|
||||
@Override
|
||||
public void onCommand(CommandSender sender, String[] args) {
|
||||
ArrayList<String> returns = DisguiseConfig.doOutput(LibsDisguises.getInstance().getConfig(), true, true);
|
||||
ArrayList<String> returns = DisguiseConfig.doOutput(true, true);
|
||||
|
||||
if (returns.isEmpty()) {
|
||||
sender.sendMessage(LibsMsg.USING_DEFAULT_CONFIG.get());
|
||||
LibsMsg.USING_DEFAULT_CONFIG.send(sender);
|
||||
return;
|
||||
}
|
||||
|
|
@ -8,7 +8,11 @@ import me.libraryaddict.disguise.utilities.translations.LibsMsg;
|
|||
import me.libraryaddict.disguise.utilities.translations.TranslateType;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* Created by libraryaddict on 20/04/2020.
|
||||
|
@ -35,26 +39,25 @@ public class LDCount implements LDCommand {
|
|||
}
|
||||
|
||||
if (counts.isEmpty()) {
|
||||
sender.sendMessage(LibsMsg.NO_DISGUISES_IN_USE.get());
|
||||
LibsMsg.NO_DISGUISES_IN_USE.send(sender);
|
||||
} else {
|
||||
sender.sendMessage(LibsMsg.ACTIVE_DISGUISES_COUNT.get(counts.values().stream().reduce(Integer::sum).get()));
|
||||
LibsMsg.ACTIVE_DISGUISES_COUNT.send(sender, counts.values().stream().reduce(Integer::sum).get());
|
||||
|
||||
ArrayList<DisguiseType> types = new ArrayList<>(counts.keySet());
|
||||
types.sort((d1, d2) -> String.CASE_INSENSITIVE_ORDER.compare(TranslateType.DISGUISES.get(d1.toReadable()),
|
||||
TranslateType.DISGUISES.get(d2.toReadable())));
|
||||
types.sort(
|
||||
(d1, d2) -> String.CASE_INSENSITIVE_ORDER.compare(TranslateType.DISGUISES.get(d1.toReadable()), TranslateType.DISGUISES.get(d2.toReadable())));
|
||||
|
||||
StringBuilder builder = new StringBuilder();
|
||||
|
||||
for (int i = 0; i < types.size(); i++) {
|
||||
builder.append(LibsMsg.ACTIVE_DISGUISES_DISGUISE
|
||||
.get(TranslateType.DISGUISES.get(types.get(i).toReadable()), counts.get(types.get(i))));
|
||||
builder.append(LibsMsg.ACTIVE_DISGUISES_DISGUISE.get(TranslateType.DISGUISES.get(types.get(i).toReadable()), counts.get(types.get(i))));
|
||||
|
||||
if (i + 1 < types.size()) {
|
||||
builder.append(LibsMsg.ACTIVE_DISGUISES_SEPERATOR.get());
|
||||
}
|
||||
}
|
||||
|
||||
sender.sendMessage(LibsMsg.ACTIVE_DISGUISES.get(builder.toString()));
|
||||
LibsMsg.ACTIVE_DISGUISES.send(sender, builder.toString());
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,42 @@
|
|||
package me.libraryaddict.disguise.commands.libsdisguises;
|
||||
|
||||
import me.libraryaddict.disguise.utilities.DisguiseUtilities;
|
||||
import me.libraryaddict.disguise.utilities.mineskin.MineSkinAPI;
|
||||
import me.libraryaddict.disguise.utilities.translations.LibsMsg;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Created by libraryaddict on 22/05/2021.
|
||||
*/
|
||||
public class LDDebugMineSkin implements LDCommand {
|
||||
@Override
|
||||
public List<String> getTabComplete() {
|
||||
return Collections.singletonList("mineskin");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasPermission(CommandSender sender) {
|
||||
return sender.hasPermission(getPermission());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPermission() {
|
||||
return "libsdisguises.mineskin";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCommand(CommandSender sender, String[] args) {
|
||||
MineSkinAPI api = DisguiseUtilities.getMineSkinAPI();
|
||||
api.setDebugging(!api.isDebugging());
|
||||
|
||||
LibsMsg.LD_DEBUG_MINESKIN_TOGGLE.send(sender, api.isDebugging());
|
||||
}
|
||||
|
||||
@Override
|
||||
public LibsMsg getHelp() {
|
||||
return LibsMsg.LD_DEBUG_MINESKIN;
|
||||
}
|
||||
}
|
|
@ -29,7 +29,7 @@ public class LDDebugPlayer implements LDCommand {
|
|||
Disguise disguise = DisguiseAPI.getDisguise(player, entity);
|
||||
|
||||
if (disguise == null) {
|
||||
player.sendMessage(LibsMsg.TARGET_NOT_DISGUISED.get());
|
||||
LibsMsg.TARGET_NOT_DISGUISED.send(player);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -50,18 +50,14 @@ public class LDDebugPlayer implements LDCommand {
|
|||
DisguiseUtilities.DScoreTeam name = disg.getScoreboardName();
|
||||
|
||||
player.sendMessage(ChatColor.RED +
|
||||
String.format("Prefix: '%s', Suffix: '%s', Disguise Name: '%s', Team '%s'",
|
||||
name.getPrefix().replace(ChatColor.COLOR_CHAR, '&'),
|
||||
name.getSuffix().replace(ChatColor.COLOR_CHAR, '&'),
|
||||
name.getPlayer().replace(ChatColor.COLOR_CHAR, '&'), name.getTeamName()));
|
||||
String.format("Prefix: '%s', Suffix: '%s', Disguise Name: '%s', Team '%s'", name.getPrefix().replace(ChatColor.COLOR_CHAR, '&'),
|
||||
name.getSuffix().replace(ChatColor.COLOR_CHAR, '&'), name.getPlayer().replace(ChatColor.COLOR_CHAR, '&'), name.getTeamName()));
|
||||
|
||||
if (DisguiseConfig.isArmorstandsName()) {
|
||||
player.sendMessage(
|
||||
ChatColor.AQUA + "Oh! You're using armorstands! Lets give some debug for that too..");
|
||||
player.sendMessage(ChatColor.RED + String.format("Names: %s, Length: %s, Custom Name: '%s'",
|
||||
new Gson().toJson(disg.getMultiName()).replace(ChatColor.COLOR_CHAR, '&'),
|
||||
disg.getMultiNameLength(),
|
||||
disg.getWatcher().getCustomName().replace(ChatColor.COLOR_CHAR, '&')));
|
||||
player.sendMessage(ChatColor.AQUA + "Oh! You're using armorstands! Lets give some debug for that too..");
|
||||
player.sendMessage(ChatColor.RED +
|
||||
String.format("Names: %s, Length: %s, Custom Name: '%s'", new Gson().toJson(disg.getMultiName()).replace(ChatColor.COLOR_CHAR, '&'),
|
||||
disg.getMultiNameLength(), disg.getWatcher().getCustomName().replace(ChatColor.COLOR_CHAR, '&')));
|
||||
}
|
||||
|
||||
Team team = player.getScoreboard().getTeam(name.getTeamName());
|
||||
|
@ -76,9 +72,8 @@ public class LDDebugPlayer implements LDCommand {
|
|||
}
|
||||
|
||||
player.sendMessage(ChatColor.RED +
|
||||
String.format("Prefix Matches: %s, Suffix Matches: %s, In Team: %s, Name Visibility: %s",
|
||||
team.getPrefix().equals(name.getPrefix()), team.getSuffix().equals(name.getSuffix()),
|
||||
team.hasEntry(name.getPlayer()), team.getOption(Team.Option.NAME_TAG_VISIBILITY)));
|
||||
String.format("Prefix Matches: %s, Suffix Matches: %s, In Team: %s, Name Visibility: %s", team.getPrefix().equals(name.getPrefix()),
|
||||
team.getSuffix().equals(name.getSuffix()), team.hasEntry(name.getPlayer()), team.getOption(Team.Option.NAME_TAG_VISIBILITY)));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -100,7 +95,7 @@ public class LDDebugPlayer implements LDCommand {
|
|||
@Override
|
||||
public void onCommand(CommandSender sender, String[] args) {
|
||||
if (!(sender instanceof Player)) {
|
||||
sender.sendMessage(LibsMsg.NO_PERM.get());
|
||||
LibsMsg.NO_CONSOLE.send(sender);
|
||||
}
|
||||
|
||||
LibsDisguises.getInstance().getListener().addInteraction(sender.getName(), new DebugInteraction(), 60);
|
|
@ -39,7 +39,7 @@ public class LDHelp implements LDCommand {
|
|||
continue;
|
||||
}
|
||||
|
||||
sender.sendMessage(cmd.getHelp().get());
|
||||
cmd.getHelp().send(sender);
|
||||
}
|
||||
}
|
||||
|
|
@ -35,7 +35,7 @@ public class LDJson implements LDCommand {
|
|||
@Override
|
||||
public void onCommand(CommandSender sender, String[] args) {
|
||||
if (!(sender instanceof Player)) {
|
||||
sender.sendMessage(LibsMsg.NO_CONSOLE.get());
|
||||
LibsMsg.NO_CONSOLE.send(sender);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -87,15 +87,15 @@ public class LDJson implements LDCommand {
|
|||
}
|
||||
|
||||
private void sendMessage(CommandSender sender, LibsMsg prefix, LibsMsg oldVer, String string) {
|
||||
if (!NmsVersion.v1_13.isSupported()) {
|
||||
sender.sendMessage(oldVer.get(string));
|
||||
/* if (!NmsVersion.v1_13.isSupported()) {
|
||||
oldVer.send(sender, string);
|
||||
return;
|
||||
}
|
||||
}*/
|
||||
|
||||
int start = 0;
|
||||
int msg = 1;
|
||||
|
||||
ComponentBuilder builder = new ComponentBuilder("").appendLegacy(prefix.get());
|
||||
ComponentBuilder builder = new ComponentBuilder("").append(prefix.getBase());
|
||||
|
||||
while (start < string.length()) {
|
||||
int end = Math.min(256, string.length() - start);
|
||||
|
@ -105,18 +105,17 @@ public class LDJson implements LDCommand {
|
|||
builder.append(" ");
|
||||
|
||||
if (string.length() <= 256) {
|
||||
builder.appendLegacy(LibsMsg.CLICK_TO_COPY_DATA.get());
|
||||
builder.append(LibsMsg.CLICK_TO_COPY_DATA.getBase());
|
||||
} else {
|
||||
builder.reset();
|
||||
builder.appendLegacy(LibsMsg.CLICK_COPY.get(msg));
|
||||
builder.append(LibsMsg.CLICK_COPY.getBase(msg));
|
||||
}
|
||||
|
||||
start += end;
|
||||
|
||||
builder.event(new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, sub));
|
||||
builder.event(new HoverEvent(HoverEvent.Action.SHOW_TEXT,
|
||||
new ComponentBuilder(LibsMsg.CLICK_TO_COPY_HOVER.get() + (string.length() <= 256 ? "" : " " + msg))
|
||||
.create()));
|
||||
new ComponentBuilder("").append(LibsMsg.CLICK_TO_COPY_HOVER.getBase()).append((string.length() <= 256 ? "" : " " + msg)).create()));
|
||||
msg += 1;
|
||||
}
|
||||
|
|
@ -1,12 +1,11 @@
|
|||
package me.libraryaddict.disguise.commands.libsdisguises;
|
||||
|
||||
import me.libraryaddict.disguise.disguisetypes.MetaIndex;
|
||||
import me.libraryaddict.disguise.utilities.reflection.NmsVersion;
|
||||
import me.libraryaddict.disguise.utilities.translations.LibsMsg;
|
||||
import net.md_5.bungee.api.chat.ClickEvent;
|
||||
import net.md_5.bungee.api.chat.ComponentBuilder;
|
||||
import net.md_5.bungee.api.chat.HoverEvent;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import net.md_5.bungee.api.chat.TextComponent;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
@ -34,7 +33,7 @@ public class LDMetaInfo implements LDCommand {
|
|||
MetaIndex index = MetaIndex.getMetaIndexByName(args[1]);
|
||||
|
||||
if (index == null) {
|
||||
sender.sendMessage(LibsMsg.META_NOT_FOUND.get());
|
||||
LibsMsg.META_NOT_FOUND.send(sender);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -48,29 +47,28 @@ public class LDMetaInfo implements LDCommand {
|
|||
|
||||
names.sort(String::compareToIgnoreCase);
|
||||
|
||||
if (NmsVersion.v1_13.isSupported()) {
|
||||
ComponentBuilder builder = new ComponentBuilder("").appendLegacy(LibsMsg.META_VALUES.get());
|
||||
// if (NmsVersion.v1_13.isSupported()) {
|
||||
ComponentBuilder builder = new ComponentBuilder("").append(LibsMsg.META_VALUES.getBase());
|
||||
|
||||
Iterator<String> itel = names.iterator();
|
||||
Iterator<String> itel = names.iterator();
|
||||
|
||||
while (itel.hasNext()) {
|
||||
String name = itel.next();
|
||||
while (itel.hasNext()) {
|
||||
String name = itel.next();
|
||||
|
||||
builder.appendLegacy(name);
|
||||
builder.event(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/libsdisguises metainfo " + name));
|
||||
builder.event(new HoverEvent(HoverEvent.Action.SHOW_TEXT,
|
||||
new ComponentBuilder("").appendLegacy(LibsMsg.META_CLICK_SHOW.get(name)).create()));
|
||||
builder.append(TextComponent.fromLegacyText(name));
|
||||
builder.event(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/libsdisguises metainfo " + name));
|
||||
builder.event(new HoverEvent(HoverEvent.Action.SHOW_TEXT, LibsMsg.META_CLICK_SHOW.getBase(name)));
|
||||
|
||||
if (itel.hasNext()) {
|
||||
builder.appendLegacy(LibsMsg.META_VALUE_SEPERATOR.get());
|
||||
}
|
||||
if (itel.hasNext()) {
|
||||
builder.append(LibsMsg.META_VALUE_SEPERATOR.getBase());
|
||||
}
|
||||
|
||||
sender.spigot().sendMessage(builder.create());
|
||||
} else {
|
||||
sender.sendMessage(
|
||||
LibsMsg.META_VALUES_NO_CLICK.get(StringUtils.join(names, LibsMsg.META_VALUE_SEPERATOR.get())));
|
||||
}
|
||||
|
||||
sender.spigot().sendMessage(builder.create());
|
||||
/*} else {
|
||||
LibsMsg.META_VALUES_NO_CLICK.send(sender,
|
||||
StringUtils.join(names, LibsMsg.META_VALUE_SEPERATOR.get()));
|
||||
}*/
|
||||
}
|
||||
}
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
package me.libraryaddict.disguise.commands.libsdisguises;
|
||||
|
||||
import me.libraryaddict.disguise.LibsDisguises;
|
||||
import me.libraryaddict.disguise.utilities.modded.ModdedManager;
|
||||
import me.libraryaddict.disguise.utilities.translations.LibsMsg;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.bukkit.Bukkit;
|
||||
|
@ -26,8 +26,8 @@ public class LDMods implements LDCommand {
|
|||
|
||||
@Override
|
||||
public void onCommand(CommandSender sender, String[] args) {
|
||||
if (!Bukkit.getMessenger().isOutgoingChannelRegistered(LibsDisguises.getInstance(), "fml:handshake")) {
|
||||
sender.sendMessage(LibsMsg.NO_MODS_LISTENING.get());
|
||||
if (ModdedManager.getEntities().isEmpty()) {
|
||||
LibsMsg.NO_MODS_LISTENING.send(sender);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -37,23 +37,22 @@ public class LDMods implements LDCommand {
|
|||
player = Bukkit.getPlayer(args[1]);
|
||||
|
||||
if (player == null) {
|
||||
sender.sendMessage(LibsMsg.CANNOT_FIND_PLAYER.get(args[1]));
|
||||
LibsMsg.CANNOT_FIND_PLAYER.send(sender, args[1]);
|
||||
return;
|
||||
}
|
||||
} else if (sender instanceof Player) {
|
||||
player = (Player) sender;
|
||||
} else {
|
||||
sender.sendMessage(LibsMsg.NO_CONSOLE.get());
|
||||
LibsMsg.NO_CONSOLE.send(sender);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!player.hasMetadata("forge_mods")) {
|
||||
sender.sendMessage(LibsMsg.NO_MODS.get(player.getName()));
|
||||
LibsMsg.NO_MODS.send(sender, player.getName());
|
||||
return;
|
||||
}
|
||||
|
||||
sender.sendMessage(LibsMsg.MODS_LIST.get(player.getName(),
|
||||
StringUtils.join((List<String>) player.getMetadata("forge_mods").get(0).value(), ", ")));
|
||||
LibsMsg.MODS_LIST.send(sender, player.getName(), StringUtils.join((List<String>) player.getMetadata("forge_mods").get(0).value(), ", "));
|
||||
}
|
||||
|
||||
@Override
|
|
@ -1,5 +1,6 @@
|
|||
package me.libraryaddict.disguise.commands.libsdisguises;
|
||||
|
||||
import me.libraryaddict.disguise.LibsDisguises;
|
||||
import me.libraryaddict.disguise.disguisetypes.DisguiseType;
|
||||
import me.libraryaddict.disguise.utilities.LibsPremium;
|
||||
import me.libraryaddict.disguise.utilities.parser.DisguisePerm;
|
||||
|
@ -7,6 +8,7 @@ import me.libraryaddict.disguise.utilities.parser.DisguisePermissions;
|
|||
import me.libraryaddict.disguise.utilities.translations.LibsMsg;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.PluginCommand;
|
||||
import org.bukkit.permissions.Permissible;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
@ -29,7 +31,7 @@ public class LDPermTest implements LDCommand {
|
|||
@Override
|
||||
public void onCommand(CommandSender sender, String[] args) {
|
||||
if (!LibsPremium.isPremium()) {
|
||||
sender.sendMessage(LibsMsg.LIBS_PERM_CHECK_NON_PREM.get());
|
||||
LibsMsg.LIBS_PERM_CHECK_NON_PREM.send(sender);
|
||||
}
|
||||
|
||||
Permissible player;
|
||||
|
@ -38,27 +40,50 @@ public class LDPermTest implements LDCommand {
|
|||
player = Bukkit.getPlayer(args[1]);
|
||||
|
||||
if (player == null) {
|
||||
sender.sendMessage(LibsMsg.CANNOT_FIND_PLAYER.get(args[1]));
|
||||
LibsMsg.CANNOT_FIND_PLAYER.send(sender, args[1]);
|
||||
return;
|
||||
}
|
||||
|
||||
LibsMsg.LIBS_PERM_CHECK_USING_TARGET.send(sender, args[1]);
|
||||
} else {
|
||||
player = sender;
|
||||
LibsMsg.LIBS_PERM_CHECK_CAN_TARGET.send(sender);
|
||||
}
|
||||
|
||||
DisguisePermissions permissions = new DisguisePermissions(player, "disguise");
|
||||
sender.sendMessage(LibsMsg.LIBS_PERM_CHECK_INFO_1.get());
|
||||
sender.sendMessage(LibsMsg.LIBS_PERM_CHECK_INFO_2.get());
|
||||
LibsMsg.LIBS_PERM_CHECK_INFO_1.send(sender);
|
||||
LibsMsg.LIBS_PERM_CHECK_INFO_2.send(sender);
|
||||
|
||||
if (player.hasPermission("libsdisguises.disguise.pig")) {
|
||||
sender.sendMessage(LibsMsg.NORMAL_PERM_CHECK_SUCCESS.get());
|
||||
LibsMsg.NORMAL_PERM_CHECK_SUCCESS.send(sender);
|
||||
|
||||
if (permissions.isAllowedDisguise(new DisguisePerm(DisguiseType.PIG))) {
|
||||
sender.sendMessage(LibsMsg.LIBS_PERM_CHECK_SUCCESS.get());
|
||||
LibsMsg.LIBS_PERM_CHECK_SUCCESS.send(sender);
|
||||
} else {
|
||||
sender.sendMessage(LibsMsg.LIBS_PERM_CHECK_FAIL.get());
|
||||
LibsMsg.LIBS_PERM_CHECK_FAIL.send(sender);
|
||||
}
|
||||
} else {
|
||||
sender.sendMessage(LibsMsg.NORMAL_PERM_CHECK_FAIL.get());
|
||||
LibsMsg.NORMAL_PERM_CHECK_FAIL.send(sender);
|
||||
}
|
||||
|
||||
if (player.hasPermission("libsdisguises.disguise.zombie") || permissions.isAllowedDisguise(new DisguisePerm(DisguiseType.ZOMBIE))) {
|
||||
LibsMsg.LIBS_PERM_CHECK_ZOMBIE_PERMISSIONS.send(sender);
|
||||
}
|
||||
|
||||
PluginCommand command = LibsDisguises.getInstance().getCommand("disguise");
|
||||
|
||||
if (command == null) {
|
||||
LibsMsg.LIBS_PERM_CHECK_COMMAND_UNREGISTERED.send(sender);
|
||||
} else if (player.hasPermission(command.getPermission())) {
|
||||
LibsMsg.LIBS_PERM_COMMAND_SUCCESS.send(sender, command.getPermission());
|
||||
} else {
|
||||
LibsMsg.LIBS_PERM_COMMAND_FAIL.send(sender, command.getPermission());
|
||||
}
|
||||
|
||||
if (!sender.hasPermission("libsdisguises.seecmd.disguise")) {
|
||||
LibsMsg.LIBS_PERM_COMMAND_FAIL.send(sender, "libsdisguises.seecmd.disguise");
|
||||
} else {
|
||||
LibsMsg.LIBS_PERM_COMMAND_SUCCESS.send(sender, "libsdisguises.seecmd.disguise");
|
||||
}
|
||||
}
|
||||
|
|
@ -1,6 +1,7 @@
|
|||
package me.libraryaddict.disguise.commands.libsdisguises;
|
||||
|
||||
import me.libraryaddict.disguise.DisguiseConfig;
|
||||
import me.libraryaddict.disguise.utilities.sounds.SoundManager;
|
||||
import me.libraryaddict.disguise.utilities.translations.LibsMsg;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
|
@ -24,7 +25,8 @@ public class LDReload implements LDCommand {
|
|||
@Override
|
||||
public void onCommand(CommandSender sender, String[] args) {
|
||||
DisguiseConfig.loadConfig();
|
||||
sender.sendMessage(LibsMsg.RELOADED_CONFIG.get());
|
||||
new SoundManager().load();
|
||||
LibsMsg.RELOADED_CONFIG.send(sender);
|
||||
}
|
||||
|
||||
@Override
|
|
@ -0,0 +1,219 @@
|
|||
package me.libraryaddict.disguise.commands.libsdisguises;
|
||||
|
||||
import com.comphenix.protocol.PacketType;
|
||||
import com.comphenix.protocol.ProtocolLibrary;
|
||||
import com.comphenix.protocol.events.PacketListener;
|
||||
import me.libraryaddict.disguise.DisguiseAPI;
|
||||
import me.libraryaddict.disguise.DisguiseConfig;
|
||||
import me.libraryaddict.disguise.LibsDisguises;
|
||||
import me.libraryaddict.disguise.disguisetypes.Disguise;
|
||||
import me.libraryaddict.disguise.disguisetypes.PlayerDisguise;
|
||||
import me.libraryaddict.disguise.disguisetypes.TargetedDisguise;
|
||||
import me.libraryaddict.disguise.utilities.DisguiseUtilities;
|
||||
import me.libraryaddict.disguise.utilities.translations.LibsMsg;
|
||||
import net.md_5.bungee.api.chat.ComponentBuilder;
|
||||
import net.md_5.bungee.api.chat.HoverEvent;
|
||||
import net.md_5.bungee.api.chat.TextComponent;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.scoreboard.Scoreboard;
|
||||
import org.bukkit.scoreboard.Team;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* Created by libraryaddict on 20/04/2020.
|
||||
*/
|
||||
public class LDScoreboard implements LDCommand {
|
||||
@Override
|
||||
public List<String> getTabComplete() {
|
||||
return Arrays.asList("teams", "scoreboard", "board", "pushing");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPermission() {
|
||||
return "libsdisguises.scoreboard";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCommand(CommandSender sender, String[] args) {
|
||||
if (DisguiseConfig.isScoreboardNames()) {
|
||||
int issuesFound = 0;
|
||||
int unexpected = 0;
|
||||
|
||||
for (Set<TargetedDisguise> disguises : DisguiseUtilities.getDisguises().values()) {
|
||||
for (Disguise disguise : disguises) {
|
||||
if (!disguise.isPlayerDisguise()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!((PlayerDisguise) disguise).hasScoreboardName()) {
|
||||
if (unexpected++ < 3) {
|
||||
sender.sendMessage(
|
||||
"The player disguise " + ((PlayerDisguise) disguise).getName() + " isn't using a scoreboard name? This is unexpected");
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
DisguiseUtilities.DScoreTeam scoreboardName = ((PlayerDisguise) disguise).getScoreboardName();
|
||||
|
||||
if (scoreboardName.getTeamName() == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
ArrayList<Scoreboard> checked = new ArrayList<>();
|
||||
|
||||
for (Player player : Bukkit.getOnlinePlayers()) {
|
||||
Scoreboard board = player.getScoreboard();
|
||||
|
||||
if (checked.contains(board)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
checked.add(board);
|
||||
|
||||
Team team = board.getTeam(scoreboardName.getTeamName());
|
||||
|
||||
if (team == null) {
|
||||
if (issuesFound++ < 5) {
|
||||
sender.sendMessage("The player disguise " + ((PlayerDisguise) disguise).getName().replace(ChatColor.COLOR_CHAR, '&') +
|
||||
" is missing a scoreboard team '" + scoreboardName.getTeamName() + "' on " + player.getName() +
|
||||
" and possibly more players!");
|
||||
}
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!team.getPrefix().equals("Colorize") &&
|
||||
(!team.getPrefix().equals(scoreboardName.getPrefix()) || !team.getSuffix().equals(scoreboardName.getSuffix()))) {
|
||||
if (issuesFound++ < 5) {
|
||||
sender.sendMessage("The player disguise " + ((PlayerDisguise) disguise).getName().replace(ChatColor.COLOR_CHAR, '&') +
|
||||
" on scoreboard team '" + scoreboardName.getTeamName() + "' on " + player.getName() +
|
||||
" has an unexpected prefix/suffix of '" + team.getPrefix().replace(ChatColor.COLOR_CHAR, '&') + "' & '" +
|
||||
team.getSuffix().replace(ChatColor.COLOR_CHAR, '&') + "'! Expected '" +
|
||||
scoreboardName.getPrefix().replace(ChatColor.COLOR_CHAR, '&') + "' & '" +
|
||||
scoreboardName.getSuffix().replace(ChatColor.COLOR_CHAR, '&') + "'");
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!team.hasEntry(scoreboardName.getPlayer())) {
|
||||
if (issuesFound++ < 5) {
|
||||
sender.sendMessage("The player disguise " + ((PlayerDisguise) disguise).getName().replace(ChatColor.COLOR_CHAR, '&') +
|
||||
" on scoreboard team '" + scoreboardName.getTeamName() + "' on " + player.getName() +
|
||||
" does not have the player entry expected! Instead has '" +
|
||||
StringUtils.join(team.getEntries(), ", ").replace(ChatColor.COLOR_CHAR, '&') + "'");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (issuesFound == 0) {
|
||||
LibsMsg.LIBS_SCOREBOARD_NO_ISSUES.send(sender);
|
||||
} else {
|
||||
LibsMsg.LIBS_SCOREBOARD_ISSUES.send(sender, issuesFound);
|
||||
}
|
||||
} else {
|
||||
LibsMsg.LIBS_SCOREBOARD_NAMES_DISABLED.send(sender);
|
||||
}
|
||||
|
||||
List<PacketListener> listeners = ProtocolLibrary.getProtocolManager().getPacketListeners().stream().filter(
|
||||
listener -> listener.getPlugin() != LibsDisguises.getInstance() &&
|
||||
listener.getSendingWhitelist().getTypes().contains(PacketType.Play.Server.SCOREBOARD_TEAM)).collect(Collectors.toList());
|
||||
|
||||
if (!listeners.isEmpty()) {
|
||||
ComponentBuilder builder = new ComponentBuilder("");
|
||||
builder.append("The following plugins are listening for scoreboard teams using ProtocolLib, and could be modifying collisions: ");
|
||||
builder.color(net.md_5.bungee.api.ChatColor.BLUE);
|
||||
|
||||
boolean comma = false;
|
||||
|
||||
for (PacketListener listener : listeners) {
|
||||
if (comma) {
|
||||
builder.reset();
|
||||
builder.append(", ");
|
||||
builder.color(net.md_5.bungee.api.ChatColor.BLUE);
|
||||
}
|
||||
|
||||
comma = true;
|
||||
|
||||
builder.reset();
|
||||
builder.append(listener.getPlugin().getName());
|
||||
builder.color(net.md_5.bungee.api.ChatColor.AQUA);
|
||||
|
||||
String plugin =
|
||||
ChatColor.GOLD + "Plugin: " + ChatColor.YELLOW + listener.getPlugin().getName() + " v" + listener.getPlugin().getDescription().getVersion();
|
||||
String listenerClass = ChatColor.GOLD + "Listener: " + ChatColor.YELLOW + listener.getClass().toString();
|
||||
String packets = ChatColor.GOLD + "Packets: " + ChatColor.YELLOW + StringUtils.join(listener.getSendingWhitelist().getTypes(), ", ");
|
||||
String priority = ChatColor.GOLD + "Priority: " + ChatColor.YELLOW + listener.getSendingWhitelist().getPriority();
|
||||
String options = ChatColor.GOLD + "Options: " + ChatColor.YELLOW + StringUtils.join(listener.getSendingWhitelist().getOptions(), ", ");
|
||||
|
||||
builder.event(new HoverEvent(HoverEvent.Action.SHOW_TEXT,
|
||||
TextComponent.fromLegacyText(plugin + "\n" + listenerClass + "\n" + packets + "\n" + priority + "\n" + options)));
|
||||
}
|
||||
|
||||
sender.spigot().sendMessage(builder.create());
|
||||
}
|
||||
|
||||
LibsMsg.LIBS_SCOREBOARD_IGNORE_TEST.send(sender);
|
||||
|
||||
sender.sendMessage(
|
||||
ChatColor.RED + "This command is somewhat outdated and needs to be changed, pushing is now disabled on the entities themselves and not players");
|
||||
|
||||
Player player;
|
||||
|
||||
if (args.length > 1) {
|
||||
player = Bukkit.getPlayer(args[1]);
|
||||
|
||||
if (player == null) {
|
||||
LibsMsg.CANNOT_FIND_PLAYER.send(sender, args[1]);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!DisguiseAPI.isDisguised(player)) {
|
||||
LibsMsg.DMODPLAYER_NODISGUISE.send(sender, player.getName());
|
||||
LibsMsg.DISGUISE_REQUIRED.send(sender);
|
||||
return;
|
||||
}
|
||||
} else if (sender instanceof Player) {
|
||||
player = (Player) sender;
|
||||
|
||||
if (!DisguiseAPI.isDisguised(player)) {
|
||||
LibsMsg.DISGUISE_REQUIRED.send(sender);
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
LibsMsg.NO_CONSOLE.send(sender);
|
||||
return;
|
||||
}
|
||||
|
||||
Scoreboard board = player.getScoreboard();
|
||||
|
||||
Team team = board.getEntryTeam(sender.getName());
|
||||
|
||||
if (team == null) {
|
||||
LibsMsg.LIBS_SCOREBOARD_NO_TEAM.send(sender);
|
||||
return;
|
||||
}
|
||||
|
||||
LibsMsg.LIBS_SCOREBOARD_SUCCESS.send(sender, team.getName());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasPermission(CommandSender sender) {
|
||||
return sender.hasPermission(getPermission());
|
||||
}
|
||||
|
||||
@Override
|
||||
public LibsMsg getHelp() {
|
||||
return LibsMsg.LD_COMMAND_SCOREBOARD;
|
||||
}
|
||||
}
|
|
@ -35,82 +35,68 @@ public class LDUpdate implements LDCommand {
|
|||
UpdateChecker checker = LibsDisguises.getInstance().getUpdateChecker();
|
||||
|
||||
if (checker.isDownloading()) {
|
||||
sender.sendMessage(LibsMsg.UPDATE_IN_PROGRESS.get());
|
||||
LibsMsg.UPDATE_IN_PROGRESS.send(sender);
|
||||
return;
|
||||
}
|
||||
|
||||
boolean releaseBuilds = checker.isUsingReleaseBuilds();
|
||||
|
||||
if (args.length > 1) {
|
||||
boolean previous = releaseBuilds;
|
||||
|
||||
if (args[1].equalsIgnoreCase("dev")) {
|
||||
releaseBuilds = false;
|
||||
} else if (args[1].equalsIgnoreCase("release")) {
|
||||
releaseBuilds = true;
|
||||
} else {
|
||||
sender.sendMessage(LibsMsg.LIBS_UPDATE_UNKNOWN_BRANCH.get());
|
||||
LibsMsg.LIBS_UPDATE_UNKNOWN_BRANCH.send(sender);
|
||||
return;
|
||||
}
|
||||
|
||||
DisguiseConfig.setUsingReleaseBuilds(releaseBuilds);
|
||||
}
|
||||
|
||||
if (checker.getUpdate() != null && checker.getUpdate().isReleaseBuild() == releaseBuilds && args.length <= 1) {
|
||||
if (checker.isServerLatestVersion()) {
|
||||
sender.sendMessage(LibsMsg.UPDATE_ON_LATEST.get());
|
||||
return;
|
||||
}
|
||||
|
||||
if (checker.isOnLatestUpdate(true)) {
|
||||
sender.sendMessage(LibsMsg.UPDATE_ALREADY_DOWNLOADED.get());
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
new BukkitRunnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
LibsMsg updateResult = null;
|
||||
|
||||
if (checker.getUpdate() == null || args.length > 1 || checker.isOldUpdate()) {
|
||||
updateResult = checker.doUpdateCheck();
|
||||
}
|
||||
LibsMsg updateResult = checker.doUpdateCheck();
|
||||
|
||||
if (checker.getUpdate() == null) {
|
||||
sender.sendMessage(LibsMsg.UPDATE_FAILED.get());
|
||||
LibsMsg.UPDATE_FAILED.send(sender);
|
||||
return;
|
||||
}
|
||||
|
||||
if (checker.isOnLatestUpdate(true)) {
|
||||
if (checker.getLastDownload() != null) {
|
||||
sender.sendMessage(LibsMsg.UPDATE_ALREADY_DOWNLOADED.get());
|
||||
LibsMsg.UPDATE_ALREADY_DOWNLOADED.send(sender);
|
||||
} else {
|
||||
sender.sendMessage(LibsMsg.UPDATE_ON_LATEST.get());
|
||||
LibsMsg.UPDATE_ON_LATEST.send(sender);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (!args[0].endsWith("!")) {
|
||||
/*if (!finalWantsDownload) {
|
||||
if (updateResult != null) {
|
||||
sender.sendMessage(updateResult.get());
|
||||
updateResult.send(sender);
|
||||
} else {
|
||||
for (String msg : checker.getUpdateMessage()) {
|
||||
sender.sendMessage(msg);
|
||||
DisguiseUtilities.sendMessage(sender, msg);
|
||||
}
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
}*/
|
||||
|
||||
PluginInformation result = checker.doUpdate();
|
||||
|
||||
if (result == null) {
|
||||
sender.sendMessage(LibsMsg.UPDATE_FAILED.get());
|
||||
LibsMsg.UPDATE_FAILED.send(sender);
|
||||
return;
|
||||
}
|
||||
|
||||
for (String msg : checker.getUpdateMessage()) {
|
||||
sender.sendMessage(msg);
|
||||
DisguiseUtilities.sendMessage(sender, msg);
|
||||
}
|
||||
|
||||
if (sender instanceof Player) {
|
|
@ -0,0 +1,82 @@
|
|||
package me.libraryaddict.disguise.commands.libsdisguises;
|
||||
|
||||
import me.libraryaddict.disguise.LibsDisguises;
|
||||
import me.libraryaddict.disguise.utilities.DisguiseUtilities;
|
||||
import me.libraryaddict.disguise.utilities.translations.LibsMsg;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
|
||||
/**
|
||||
* Created by libraryaddict on 30/06/2020.
|
||||
*/
|
||||
public class LDUpdateProtocolLib implements LDCommand {
|
||||
private final AtomicBoolean updateInProgress = new AtomicBoolean(false);
|
||||
|
||||
@Override
|
||||
public List<String> getTabComplete() {
|
||||
return Arrays.asList("updateprotocollib", "updatepl", "protocollib");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasPermission(CommandSender sender) {
|
||||
return sender.isOp() || sender.hasPermission("minecraft.command.op");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPermission() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCommand(CommandSender sender, String[] args) {
|
||||
if (updateInProgress.get()) {
|
||||
sender.sendMessage(ChatColor.RED + "Update already in progress");
|
||||
return;
|
||||
}
|
||||
|
||||
sender.sendMessage(ChatColor.RED + "Please hold, now downloading..");
|
||||
|
||||
new BukkitRunnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
File protocolLibFile = null;
|
||||
|
||||
try {
|
||||
DisguiseUtilities.updateProtocolLib();
|
||||
|
||||
new BukkitRunnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
sender.sendMessage(ChatColor.RED + "Update success! Restart server to finish update!");
|
||||
}
|
||||
}.runTask(LibsDisguises.getInstance());
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
|
||||
new BukkitRunnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
sender.sendMessage(ChatColor.RED +
|
||||
"Looks like ProtocolLib's site may be down! MythicCraft/MythicMobs has a discord server https://discord.gg/EErRhJ4qgx you" +
|
||||
" can join. Check the pins in #libs-support for a ProtocolLib.jar you can download!");
|
||||
sender.sendMessage(ChatColor.RED + "Update failed, " + ex.getMessage());
|
||||
}
|
||||
}.runTask(LibsDisguises.getInstance());
|
||||
} finally {
|
||||
updateInProgress.set(false);
|
||||
}
|
||||
}
|
||||
}.runTaskAsynchronously(LibsDisguises.getInstance());
|
||||
}
|
||||
|
||||
@Override
|
||||
public LibsMsg getHelp() {
|
||||
return LibsMsg.LD_COMMAND_UPDATEPROTOCOLLIB;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,268 @@
|
|||
package me.libraryaddict.disguise.commands.libsdisguises;
|
||||
|
||||
import javax.net.ssl.HttpsURLConnection;
|
||||
import lombok.Data;
|
||||
import me.libraryaddict.disguise.DisguiseConfig;
|
||||
import me.libraryaddict.disguise.LibsDisguises;
|
||||
import me.libraryaddict.disguise.utilities.config.ConfigLoader;
|
||||
import me.libraryaddict.disguise.utilities.translations.LibsMsg;
|
||||
import net.md_5.bungee.api.chat.ClickEvent;
|
||||
import net.md_5.bungee.api.chat.ComponentBuilder;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.net.URL;
|
||||
import java.net.URLEncoder;
|
||||
import java.nio.file.Files;
|
||||
import java.util.AbstractMap.SimpleEntry;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* Created by libraryaddict on 18/06/2020.
|
||||
*/
|
||||
public class LDUploadLogs implements LDCommand {
|
||||
private long lastUsed;
|
||||
|
||||
/**
|
||||
* Small modification of https://gist.github.com/jamezrin/12de49643d7be7150da362e86407113f
|
||||
*/
|
||||
@Data
|
||||
public class GuestPaste {
|
||||
private String name = null;
|
||||
private final String text;
|
||||
|
||||
public GuestPaste(String name, String text) {
|
||||
this.name = name;
|
||||
this.text = text;
|
||||
}
|
||||
|
||||
public URL paste() throws Exception {
|
||||
URL url = new URL("https://pastebin.com/api/api_post.php");
|
||||
HttpsURLConnection con = (HttpsURLConnection) url.openConnection();
|
||||
|
||||
con.setRequestMethod("POST");
|
||||
con.setRequestProperty("User-Agent", "Mozilla/5.0");
|
||||
|
||||
List<SimpleEntry<String, String>> params = new LinkedList<>();
|
||||
// This doesn't give you access to my pastebin account ;)
|
||||
// You need to enter another key for that, this key is for pastebin's tracking metrics.
|
||||
// If you're using this code, please use your own pastebin dev key.
|
||||
// Overuse will get it banned, and you'll have to ship a new version with your own key anyways.
|
||||
// This is seperated into strings to prevent super easy scraping.
|
||||
if (getClass().getName().contains("me.libraryaddict")) {
|
||||
params.add(new SimpleEntry<>("api_dev_key", "62067f9d" + "cc1979a475105b529" + "eb453a5"));
|
||||
}
|
||||
params.add(new SimpleEntry<>("api_option", "paste"));
|
||||
params.add(new SimpleEntry<>("api_paste_name", name));
|
||||
params.add(new SimpleEntry<>("api_paste_code", text));
|
||||
|
||||
params.add(new SimpleEntry<>("api_paste_format", "text"));
|
||||
params.add(new SimpleEntry<>("api_paste_expire_date", "1M"));
|
||||
params.add(new SimpleEntry<>("api_paste_private", "1"));
|
||||
|
||||
StringBuilder output = new StringBuilder();
|
||||
for (SimpleEntry<String, String> entry : params) {
|
||||
if (output.length() > 0) {
|
||||
output.append('&');
|
||||
}
|
||||
|
||||
output.append(URLEncoder.encode(entry.getKey(), "UTF-8"));
|
||||
output.append('=');
|
||||
output.append(URLEncoder.encode(entry.getValue(), "UTF-8"));
|
||||
}
|
||||
|
||||
con.setDoOutput(true);
|
||||
try (DataOutputStream dos = new DataOutputStream(con.getOutputStream())) {
|
||||
dos.writeBytes(output.toString());
|
||||
dos.flush();
|
||||
}
|
||||
|
||||
int status = con.getResponseCode();
|
||||
|
||||
if (status >= 200 && status < 300) {
|
||||
try (BufferedReader br = new BufferedReader(new InputStreamReader(con.getInputStream()))) {
|
||||
String inputLine;
|
||||
StringBuilder response = new StringBuilder();
|
||||
|
||||
while ((inputLine = br.readLine()) != null) {
|
||||
response.append(inputLine);
|
||||
}
|
||||
|
||||
return new URL(response.toString());
|
||||
}
|
||||
} else {
|
||||
throw new IllegalStateException("Unexpected response code " + status);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getTabComplete() {
|
||||
return Arrays.asList("uploadlog", "uploadlogs", "uploadconfig", "uploadconfigs", "logs", "log");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasPermission(CommandSender sender) {
|
||||
return sender.isOp();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPermission() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCommand(CommandSender sender, String[] args) {
|
||||
if (lastUsed + TimeUnit.MINUTES.toMillis(3) > System.currentTimeMillis()) {
|
||||
sender.sendMessage(ChatColor.RED + "You last used this command under 3 minutes ago! Restart the server or wait for this timer to " + "disappear!");
|
||||
return;
|
||||
}
|
||||
|
||||
File latest = new File("logs/latest.log");
|
||||
File disguises = new File(LibsDisguises.getInstance().getDataFolder(), "configs/disguises.yml");
|
||||
|
||||
List<File> configs =
|
||||
new ConfigLoader().getConfigs().stream().map(f -> new File(LibsDisguises.getInstance().getDataFolder(), f)).collect(Collectors.toList());
|
||||
|
||||
StringBuilder configText = new StringBuilder();
|
||||
|
||||
for (File config : configs) {
|
||||
if (configText.length() != 0) {
|
||||
configText.append("\n\n================\n\n");
|
||||
}
|
||||
|
||||
try {
|
||||
String text = new String(Files.readAllBytes(config.toPath()));
|
||||
text = text.replaceAll("\n? *#[^\n]*", "").replaceAll("[\n\r]+", "\n");
|
||||
|
||||
configText.append("File: ").append(config.getName()).append("\n\n").append(text);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
if (isTooBig(latest)) {
|
||||
sender.sendMessage(
|
||||
ChatColor.RED + "Your latest.log file is too big! It should be less than 512kb! Please restart and run this " + "command again!");
|
||||
return;
|
||||
}
|
||||
|
||||
if (isTooBig(disguises)) {
|
||||
sender.sendMessage(ChatColor.RED + "Your disguises.yml is too big! You'll need to trim that file down before using this command! It " +
|
||||
"should be less than 512kb!");
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
String latestText = new String(Files.readAllBytes(latest.toPath()));
|
||||
|
||||
boolean valid = false;
|
||||
int lastFind = 0;
|
||||
|
||||
for (int i = 0; i < 15; i++) {
|
||||
int nextLine = latestText.indexOf("\n", lastFind);
|
||||
|
||||
if (nextLine == -1) {
|
||||
break;
|
||||
}
|
||||
|
||||
String str = latestText.substring(lastFind, nextLine);
|
||||
|
||||
lastFind = nextLine + 2;
|
||||
|
||||
if (!str.contains("Starting minecraft server version") && !str.contains("Loading properties") && !str.contains("This server is running")) {
|
||||
continue;
|
||||
}
|
||||
|
||||
valid = true;
|
||||
break;
|
||||
}
|
||||
|
||||
if (!valid) {
|
||||
sender.sendMessage(ChatColor.RED + "Your latest.log is too old! Please restart the server and try again!");
|
||||
return;
|
||||
}
|
||||
|
||||
sender.sendMessage(ChatColor.GOLD + "Now creating pastebin links...");
|
||||
|
||||
new BukkitRunnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
String disguiseText = new String(Files.readAllBytes(disguises.toPath()));
|
||||
|
||||
configText.append("\n\n================\n");
|
||||
|
||||
ArrayList<String> modified = DisguiseConfig.doOutput(true, true);
|
||||
|
||||
for (String s : modified) {
|
||||
configText.append("\n").append(s);
|
||||
}
|
||||
|
||||
if (modified.isEmpty()) {
|
||||
configText.append("\nUsing default config!");
|
||||
}
|
||||
|
||||
URL latestPaste = new GuestPaste("latest.log", latestText).paste();
|
||||
URL configPaste = new GuestPaste("LibsDisguises config.yml", configText.toString()).paste();
|
||||
URL disguisesPaste = new GuestPaste("LibsDisguises disguises.yml", disguiseText).paste();
|
||||
|
||||
lastUsed = System.currentTimeMillis();
|
||||
|
||||
new BukkitRunnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
sender.sendMessage(ChatColor.GOLD + "Upload successful!");
|
||||
|
||||
// Console can't click :(
|
||||
if (sender instanceof Player) {
|
||||
sender.sendMessage(ChatColor.GOLD + "Click on the below message to have it appear in your chat input");
|
||||
}
|
||||
|
||||
String text =
|
||||
"My log file: " + latestPaste + ", my combined config files: " + configPaste + " and my disguises file: " + disguisesPaste;
|
||||
|
||||
ComponentBuilder builder = new ComponentBuilder("");
|
||||
builder.append(text);
|
||||
builder.color(net.md_5.bungee.api.ChatColor.AQUA);
|
||||
builder.event(new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, text));
|
||||
|
||||
sender.spigot().sendMessage(builder.create());
|
||||
}
|
||||
}.runTask(LibsDisguises.getInstance());
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
sender.sendMessage(ChatColor.RED + "Unexpected error! Upload failed! " + e.getMessage());
|
||||
}
|
||||
}
|
||||
}.runTaskAsynchronously(LibsDisguises.getInstance());
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
private boolean isTooBig(File file) {
|
||||
return file.exists() && isTooBig(file.length());
|
||||
}
|
||||
|
||||
private boolean isTooBig(long length) {
|
||||
return length >= 512 * 1024;
|
||||
}
|
||||
|
||||
@Override
|
||||
public LibsMsg getHelp() {
|
||||
return LibsMsg.LD_COMMAND_UPLOAD_LOGS;
|
||||
}
|
||||
}
|
|
@ -23,14 +23,14 @@ public class DisguiseModifyCommand extends DisguiseBaseCommand implements TabCom
|
|||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
|
||||
if (!(sender instanceof Entity)) {
|
||||
sender.sendMessage(LibsMsg.NO_CONSOLE.get());
|
||||
LibsMsg.NO_CONSOLE.send(sender);
|
||||
return true;
|
||||
}
|
||||
|
||||
DisguisePermissions permissions = getPermissions(sender);
|
||||
|
||||
if (!permissions.hasPermissions()) {
|
||||
sender.sendMessage(LibsMsg.NO_PERM.get());
|
||||
LibsMsg.NO_PERM.send(sender);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -42,14 +42,14 @@ public class DisguiseModifyCommand extends DisguiseBaseCommand implements TabCom
|
|||
Disguise disguise = DisguiseAPI.getDisguise((Player) sender, (Entity) sender);
|
||||
|
||||
if (disguise == null) {
|
||||
sender.sendMessage(LibsMsg.NOT_DISGUISED.get());
|
||||
LibsMsg.NOT_DISGUISED.send(sender);
|
||||
return true;
|
||||
}
|
||||
|
||||
DisguisePerm disguisePerm = new DisguisePerm(disguise.getType());
|
||||
|
||||
if (!permissions.isAllowedDisguise(disguisePerm)) {
|
||||
sender.sendMessage(LibsMsg.DMODIFY_NO_PERM.get());
|
||||
LibsMsg.DMODIFY_NO_PERM.send(sender);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -58,35 +58,32 @@ public class DisguiseModifyCommand extends DisguiseBaseCommand implements TabCom
|
|||
options = DisguiseParser.parsePlaceholders(options, sender, sender);
|
||||
|
||||
try {
|
||||
DisguiseParser.callMethods(sender, disguise, permissions, disguisePerm, new ArrayList<>(), options,
|
||||
"DisguiseModify");
|
||||
}
|
||||
catch (DisguiseParseException ex) {
|
||||
if (ex.getMessage() != null) {
|
||||
sender.sendMessage(ex.getMessage());
|
||||
}
|
||||
DisguiseParser.callMethods(sender, disguise, permissions, disguisePerm, new ArrayList<>(), options, "DisguiseModify");
|
||||
} catch (DisguiseParseException ex) {
|
||||
ex.send(sender);
|
||||
|
||||
return true;
|
||||
}
|
||||
catch (Exception ex) {
|
||||
} catch (Throwable ex) {
|
||||
ex.printStackTrace();
|
||||
return true;
|
||||
}
|
||||
|
||||
sender.sendMessage(LibsMsg.DMODIFY_MODIFIED.get());
|
||||
LibsMsg.DMODIFY_MODIFIED.send(sender);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> onTabComplete(CommandSender sender, Command cmd, String label, String[] origArgs) {
|
||||
if (!(sender instanceof Player))
|
||||
if (!(sender instanceof Player)) {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
|
||||
Disguise disguise = DisguiseAPI.getDisguise((Player) sender, (Entity) sender);
|
||||
|
||||
if (disguise == null)
|
||||
if (disguise == null) {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
|
||||
String[] args = getPreviousArgs(origArgs);
|
||||
|
||||
|
@ -106,9 +103,8 @@ public class DisguiseModifyCommand extends DisguiseBaseCommand implements TabCom
|
|||
protected void sendCommandUsage(CommandSender sender, DisguisePermissions permissions) {
|
||||
ArrayList<String> allowedDisguises = getAllowedDisguises(permissions);
|
||||
|
||||
sender.sendMessage(LibsMsg.DMODIFY_HELP3.get());
|
||||
sender.sendMessage(LibsMsg.DMODIFY_HELP3.get());
|
||||
sender.sendMessage(
|
||||
LibsMsg.DMODIFY_HELP3.get(StringUtils.join(allowedDisguises, LibsMsg.CAN_USE_DISGS_SEPERATOR.get())));
|
||||
LibsMsg.DMODIFY_HELP1.send(sender);
|
||||
LibsMsg.DMODIFY_HELP2.send(sender);
|
||||
LibsMsg.DMODIFY_HELP3.send(sender, StringUtils.join(allowedDisguises, LibsMsg.CAN_USE_DISGS_SEPERATOR.get()));
|
||||
}
|
||||
}
|
|
@ -22,14 +22,14 @@ public class DisguiseModifyEntityCommand extends DisguiseBaseCommand implements
|
|||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
|
||||
if (!(sender instanceof Player)) {
|
||||
sender.sendMessage(LibsMsg.NO_CONSOLE.get());
|
||||
LibsMsg.NO_CONSOLE.send(sender);
|
||||
return true;
|
||||
}
|
||||
|
||||
DisguisePermissions permissions = getPermissions(sender);
|
||||
|
||||
if (!permissions.hasPermissions()) {
|
||||
sender.sendMessage(LibsMsg.NO_PERM.get());
|
||||
LibsMsg.NO_PERM.send(sender);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -40,11 +40,11 @@ public class DisguiseModifyEntityCommand extends DisguiseBaseCommand implements
|
|||
|
||||
// TODO Validate if any disguises have this arg
|
||||
|
||||
LibsDisguises.getInstance().getListener().addInteraction(sender.getName(),
|
||||
new DisguiseModifyInteraction(DisguiseUtilities.split(StringUtils.join(args, " "))),
|
||||
LibsDisguises.getInstance().getListener()
|
||||
.addInteraction(sender.getName(), new DisguiseModifyInteraction(DisguiseUtilities.split(StringUtils.join(args, " "))),
|
||||
DisguiseConfig.getDisguiseEntityExpire());
|
||||
|
||||
sender.sendMessage(LibsMsg.DMODIFYENT_CLICK.get(DisguiseConfig.getDisguiseEntityExpire()));
|
||||
LibsMsg.DMODIFYENT_CLICK.send(sender, DisguiseConfig.getDisguiseEntityExpire());
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -78,8 +78,7 @@ public class DisguiseModifyEntityCommand extends DisguiseBaseCommand implements
|
|||
protected void sendCommandUsage(CommandSender sender, DisguisePermissions permissions) {
|
||||
ArrayList<String> allowedDisguises = getAllowedDisguises(permissions);
|
||||
|
||||
sender.sendMessage(LibsMsg.DMODENT_HELP1.get());
|
||||
sender.sendMessage(LibsMsg.DMODIFY_HELP3
|
||||
.get( StringUtils.join(allowedDisguises, LibsMsg.CAN_USE_DISGS_SEPERATOR.get())));
|
||||
LibsMsg.DMODENT_HELP1.send(sender);
|
||||
LibsMsg.DMODIFY_HELP3.send(sender, StringUtils.join(allowedDisguises, LibsMsg.CAN_USE_DISGS_SEPERATOR.get()));
|
||||
}
|
||||
}
|
|
@ -28,7 +28,7 @@ public class DisguiseModifyPlayerCommand extends DisguiseBaseCommand implements
|
|||
DisguisePermissions permissions = getPermissions(sender);
|
||||
|
||||
if (!permissions.hasPermissions()) {
|
||||
sender.sendMessage(LibsMsg.NO_PERM.get());
|
||||
LibsMsg.NO_PERM.send(sender);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -43,14 +43,13 @@ public class DisguiseModifyPlayerCommand extends DisguiseBaseCommand implements
|
|||
if (args[0].contains("-")) {
|
||||
try {
|
||||
entityTarget = Bukkit.getEntity(UUID.fromString(args[0]));
|
||||
}
|
||||
catch (Exception ignored) {
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (entityTarget == null) {
|
||||
sender.sendMessage(LibsMsg.CANNOT_FIND_PLAYER.get(args[0]));
|
||||
LibsMsg.CANNOT_FIND_PLAYER.send(sender, args[0]);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -64,21 +63,23 @@ public class DisguiseModifyPlayerCommand extends DisguiseBaseCommand implements
|
|||
|
||||
Disguise disguise = null;
|
||||
|
||||
if (sender instanceof Player)
|
||||
if (sender instanceof Player) {
|
||||
disguise = DisguiseAPI.getDisguise((Player) sender, entityTarget);
|
||||
|
||||
if (disguise == null)
|
||||
disguise = DisguiseAPI.getDisguise(entityTarget);
|
||||
}
|
||||
|
||||
if (disguise == null) {
|
||||
sender.sendMessage(LibsMsg.DMODPLAYER_NODISGUISE.get(entityTarget.getName()));
|
||||
disguise = DisguiseAPI.getDisguise(entityTarget);
|
||||
}
|
||||
|
||||
if (disguise == null) {
|
||||
LibsMsg.DMODPLAYER_NODISGUISE.send(sender, entityTarget.getName());
|
||||
return true;
|
||||
}
|
||||
|
||||
DisguisePerm disguisePerm = new DisguisePerm(disguise.getType());
|
||||
|
||||
if (!permissions.isAllowedDisguise(disguisePerm)) {
|
||||
sender.sendMessage(LibsMsg.DMODPLAYER_NOPERM.get());
|
||||
LibsMsg.DMODPLAYER_NOPERM.send(sender);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -87,22 +88,16 @@ public class DisguiseModifyPlayerCommand extends DisguiseBaseCommand implements
|
|||
options = DisguiseParser.parsePlaceholders(options, sender, entityTarget);
|
||||
|
||||
try {
|
||||
DisguiseParser.callMethods(sender, disguise, permissions, disguisePerm, new ArrayList<>(), options,
|
||||
"DisguiseModifyPlayer");
|
||||
}
|
||||
catch (DisguiseParseException ex) {
|
||||
if (ex.getMessage() != null) {
|
||||
sender.sendMessage(ex.getMessage());
|
||||
}
|
||||
DisguiseParser.callMethods(sender, disguise, permissions, disguisePerm, new ArrayList<>(), options, "DisguiseModifyPlayer");
|
||||
} catch (DisguiseParseException ex) {
|
||||
ex.send(sender);
|
||||
return true;
|
||||
}
|
||||
|
||||
catch (Exception ex) {
|
||||
} catch (Throwable ex) {
|
||||
ex.printStackTrace();
|
||||
return true;
|
||||
}
|
||||
|
||||
sender.sendMessage(LibsMsg.DMODPLAYER_MODIFIED.get(entityTarget.getName()));
|
||||
LibsMsg.DMODPLAYER_MODIFIED.send(sender, entityTarget.getName());
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -136,11 +131,13 @@ public class DisguiseModifyPlayerCommand extends DisguiseBaseCommand implements
|
|||
|
||||
Disguise disguise = null;
|
||||
|
||||
if (sender instanceof Player)
|
||||
if (sender instanceof Player) {
|
||||
disguise = DisguiseAPI.getDisguise((Player) sender, player);
|
||||
}
|
||||
|
||||
if (disguise == null)
|
||||
if (disguise == null) {
|
||||
disguise = DisguiseAPI.getDisguise(player);
|
||||
}
|
||||
|
||||
if (disguise == null) {
|
||||
return tabs;
|
||||
|
@ -161,8 +158,7 @@ public class DisguiseModifyPlayerCommand extends DisguiseBaseCommand implements
|
|||
protected void sendCommandUsage(CommandSender sender, DisguisePermissions permissions) {
|
||||
ArrayList<String> allowedDisguises = getAllowedDisguises(permissions);
|
||||
|
||||
sender.sendMessage(LibsMsg.DMODPLAYER_HELP1.get());
|
||||
sender.sendMessage(
|
||||
LibsMsg.DMODIFY_HELP3.get(StringUtils.join(allowedDisguises, LibsMsg.CAN_USE_DISGS_SEPERATOR.get())));
|
||||
LibsMsg.DMODPLAYER_HELP1.send(sender);
|
||||
LibsMsg.DMODIFY_HELP3.send(sender, StringUtils.join(allowedDisguises, LibsMsg.CAN_USE_DISGS_SEPERATOR.get()));
|
||||
}
|
||||
}
|
|
@ -1,6 +1,7 @@
|
|||
package me.libraryaddict.disguise.commands.modify;
|
||||
|
||||
import me.libraryaddict.disguise.DisguiseAPI;
|
||||
import me.libraryaddict.disguise.DisguiseConfig;
|
||||
import me.libraryaddict.disguise.commands.DisguiseBaseCommand;
|
||||
import me.libraryaddict.disguise.disguisetypes.Disguise;
|
||||
import me.libraryaddict.disguise.disguisetypes.DisguiseType;
|
||||
|
@ -10,6 +11,7 @@ import me.libraryaddict.disguise.utilities.parser.DisguiseParseException;
|
|||
import me.libraryaddict.disguise.utilities.parser.DisguiseParser;
|
||||
import me.libraryaddict.disguise.utilities.parser.DisguisePerm;
|
||||
import me.libraryaddict.disguise.utilities.parser.DisguisePermissions;
|
||||
import me.libraryaddict.disguise.utilities.parser.WatcherMethod;
|
||||
import me.libraryaddict.disguise.utilities.translations.LibsMsg;
|
||||
import me.libraryaddict.disguise.utilities.translations.TranslateType;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
|
@ -22,16 +24,13 @@ import org.bukkit.command.TabCompleter;
|
|||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
public class DisguiseModifyRadiusCommand extends DisguiseBaseCommand implements TabCompleter {
|
||||
private int maxRadius = 30;
|
||||
|
||||
public DisguiseModifyRadiusCommand(int maxRadius) {
|
||||
this.maxRadius = maxRadius;
|
||||
}
|
||||
|
||||
private Collection<Entity> getNearbyEntities(CommandSender sender, int radius) {
|
||||
Location center;
|
||||
|
||||
|
@ -47,14 +46,14 @@ public class DisguiseModifyRadiusCommand extends DisguiseBaseCommand implements
|
|||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
|
||||
if (sender.getName().equals("CONSOLE")) {
|
||||
sender.sendMessage(LibsMsg.NO_CONSOLE.get());
|
||||
LibsMsg.NO_CONSOLE.send(sender);
|
||||
return true;
|
||||
}
|
||||
|
||||
DisguisePermissions permissions = getPermissions(sender);
|
||||
|
||||
if (!permissions.hasPermissions()) {
|
||||
sender.sendMessage(LibsMsg.NO_PERM.get());
|
||||
LibsMsg.NO_PERM.send(sender);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -64,7 +63,7 @@ public class DisguiseModifyRadiusCommand extends DisguiseBaseCommand implements
|
|||
}
|
||||
|
||||
if (args[0].equalsIgnoreCase(TranslateType.DISGUISES.get("DisguiseType")) ||
|
||||
args[0].equalsIgnoreCase(TranslateType.DISGUISES.get("DisguiseType") + "s")) {
|
||||
args[0].equalsIgnoreCase(TranslateType.DISGUISES.get("DisguiseType") + "s")) {
|
||||
ArrayList<String> classes = new ArrayList<>();
|
||||
|
||||
for (DisguiseType type : DisguiseType.values()) {
|
||||
|
@ -77,8 +76,7 @@ public class DisguiseModifyRadiusCommand extends DisguiseBaseCommand implements
|
|||
|
||||
Collections.sort(classes);
|
||||
|
||||
sender.sendMessage(LibsMsg.DMODRADIUS_USABLE
|
||||
.get(ChatColor.GREEN + StringUtils.join(classes, ChatColor.DARK_GREEN + ", " + ChatColor.GREEN)));
|
||||
LibsMsg.DMODRADIUS_USABLE.send(sender, ChatColor.GREEN + StringUtils.join(classes, ChatColor.DARK_GREEN + ", " + ChatColor.GREEN));
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -99,30 +97,34 @@ public class DisguiseModifyRadiusCommand extends DisguiseBaseCommand implements
|
|||
}
|
||||
|
||||
if (baseType == null) {
|
||||
sender.sendMessage(LibsMsg.DMODRADIUS_UNRECOGNIZED.get(args[0]));
|
||||
LibsMsg.DMODRADIUS_UNRECOGNIZED.send(sender, args[0]);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
if (args.length == starting + 1) {
|
||||
sender.sendMessage(
|
||||
(starting == 0 ? LibsMsg.DMODRADIUS_NEEDOPTIONS : LibsMsg.DMODRADIUS_NEEDOPTIONS_ENTITY).get());
|
||||
if (starting == 0) {
|
||||
LibsMsg.DMODRADIUS_NEEDOPTIONS.send(sender);
|
||||
} else {
|
||||
LibsMsg.DMODRADIUS_NEEDOPTIONS_ENTITY.send(sender);
|
||||
}
|
||||
|
||||
return true;
|
||||
} else if (args.length < 2) {
|
||||
sender.sendMessage(LibsMsg.DMODRADIUS_NEEDOPTIONS.get());
|
||||
LibsMsg.DMODRADIUS_NEEDOPTIONS.send(sender);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!isInteger(args[starting])) {
|
||||
sender.sendMessage(LibsMsg.NOT_NUMBER.get(args[starting]));
|
||||
LibsMsg.NOT_NUMBER.send(sender, args[starting]);
|
||||
return true;
|
||||
}
|
||||
|
||||
int radius = Integer.parseInt(args[starting]);
|
||||
|
||||
if (radius > maxRadius) {
|
||||
sender.sendMessage(LibsMsg.LIMITED_RADIUS.get(maxRadius));
|
||||
radius = maxRadius;
|
||||
if (radius > DisguiseConfig.getDisguiseRadiusMax()) {
|
||||
LibsMsg.LIMITED_RADIUS.send(sender, DisguiseConfig.getDisguiseRadiusMax());
|
||||
radius = DisguiseConfig.getDisguiseRadiusMax();
|
||||
}
|
||||
|
||||
String[] newArgs = new String[args.length - (starting + 1)];
|
||||
|
@ -150,10 +152,11 @@ public class DisguiseModifyRadiusCommand extends DisguiseBaseCommand implements
|
|||
|
||||
Disguise disguise;
|
||||
|
||||
if (sender instanceof Player)
|
||||
if (sender instanceof Player) {
|
||||
disguise = DisguiseAPI.getDisguise((Player) sender, entity);
|
||||
else
|
||||
} else {
|
||||
disguise = DisguiseAPI.getDisguise(entity);
|
||||
}
|
||||
|
||||
if (disguise == null) {
|
||||
continue;
|
||||
|
@ -170,31 +173,26 @@ public class DisguiseModifyRadiusCommand extends DisguiseBaseCommand implements
|
|||
tempArgs = DisguiseParser.parsePlaceholders(tempArgs, sender, entity);
|
||||
|
||||
try {
|
||||
DisguiseParser.callMethods(sender, disguise, permissions, disguisePerm, new ArrayList<>(), tempArgs,
|
||||
"DisguiseModifyRadius");
|
||||
DisguiseParser.callMethods(sender, disguise, permissions, disguisePerm, new ArrayList<>(), tempArgs, "DisguiseModifyRadius");
|
||||
modifiedDisguises++;
|
||||
}
|
||||
catch (DisguiseParseException ex) {
|
||||
if (ex.getMessage() != null) {
|
||||
sender.sendMessage(ex.getMessage());
|
||||
}
|
||||
} catch (DisguiseParseException ex) {
|
||||
ex.send(sender);
|
||||
|
||||
return true;
|
||||
}
|
||||
catch (Exception ex) {
|
||||
} catch (Throwable ex) {
|
||||
ex.printStackTrace();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
if (noPermission > 0) {
|
||||
sender.sendMessage(LibsMsg.DMODRADIUS_NOPERM.get(noPermission));
|
||||
LibsMsg.DMODRADIUS_NOPERM.send(sender, noPermission);
|
||||
}
|
||||
|
||||
if (modifiedDisguises > 0) {
|
||||
sender.sendMessage(LibsMsg.DMODRADIUS.get(modifiedDisguises));
|
||||
LibsMsg.DMODRADIUS.send(sender, modifiedDisguises);
|
||||
} else {
|
||||
sender.sendMessage(LibsMsg.DMODRADIUS_NOENTS.get());
|
||||
LibsMsg.DMODRADIUS_NOENTS.send(sender);
|
||||
}
|
||||
|
||||
return true;
|
||||
|
@ -234,8 +232,9 @@ public class DisguiseModifyRadiusCommand extends DisguiseBaseCommand implements
|
|||
}
|
||||
|
||||
// Not a valid radius
|
||||
if (starting == 1 || args.length == 1 || !isInteger(args[1]))
|
||||
if (starting == 1 || args.length == 1 || !isInteger(args[1])) {
|
||||
return filterTabs(tabs, origArgs);
|
||||
}
|
||||
}
|
||||
|
||||
if (args.length <= starting || !isInteger(args[starting])) {
|
||||
|
@ -244,9 +243,9 @@ public class DisguiseModifyRadiusCommand extends DisguiseBaseCommand implements
|
|||
|
||||
int radius = Integer.parseInt(args[starting]);
|
||||
|
||||
if (radius > maxRadius) {
|
||||
sender.sendMessage(LibsMsg.LIMITED_RADIUS.get(maxRadius));
|
||||
radius = maxRadius;
|
||||
if (radius > DisguiseConfig.getDisguiseRadiusMax()) {
|
||||
LibsMsg.LIMITED_RADIUS.send(sender, DisguiseConfig.getDisguiseRadiusMax());
|
||||
radius = DisguiseConfig.getDisguiseRadiusMax();
|
||||
}
|
||||
|
||||
starting++;
|
||||
|
@ -256,15 +255,17 @@ public class DisguiseModifyRadiusCommand extends DisguiseBaseCommand implements
|
|||
for (Entity entity : getNearbyEntities(sender, radius)) {
|
||||
Disguise disguise = DisguiseAPI.getDisguise(entity);
|
||||
|
||||
if (disguise == null)
|
||||
if (disguise == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
DisguiseType disguiseType = disguise.getType();
|
||||
|
||||
for (Method method : ParamInfoManager.getDisguiseWatcherMethods(disguiseType.getWatcherClass())) {
|
||||
for (WatcherMethod method : ParamInfoManager.getDisguiseWatcherMethods(disguiseType.getWatcherClass())) {
|
||||
for (String arg : args) {
|
||||
if (!method.getName().equalsIgnoreCase(arg) || usedOptions.contains(arg))
|
||||
if (!method.getName().equalsIgnoreCase(arg) || usedOptions.contains(arg)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
usedOptions.add(arg);
|
||||
}
|
||||
|
@ -287,11 +288,10 @@ public class DisguiseModifyRadiusCommand extends DisguiseBaseCommand implements
|
|||
protected void sendCommandUsage(CommandSender sender, DisguisePermissions permissions) {
|
||||
ArrayList<String> allowedDisguises = getAllowedDisguises(permissions);
|
||||
|
||||
sender.sendMessage(LibsMsg.DMODRADIUS_HELP1.get(maxRadius));
|
||||
sender.sendMessage(
|
||||
LibsMsg.DMODIFY_HELP3.get(StringUtils.join(allowedDisguises, LibsMsg.CAN_USE_DISGS_SEPERATOR.get())));
|
||||
LibsMsg.DMODRADIUS_HELP1.send(sender, DisguiseConfig.getDisguiseRadiusMax());
|
||||
LibsMsg.DMODIFY_HELP3.send(sender, StringUtils.join(allowedDisguises, LibsMsg.CAN_USE_DISGS_SEPERATOR.get()));
|
||||
|
||||
sender.sendMessage(LibsMsg.DMODRADIUS_HELP2.get());
|
||||
sender.sendMessage(LibsMsg.DMODRADIUS_HELP3.get());
|
||||
LibsMsg.DMODRADIUS_HELP2.send(sender);
|
||||
LibsMsg.DMODRADIUS_HELP3.send(sender);
|
||||
}
|
||||
}
|
|
@ -15,25 +15,27 @@ public class UndisguiseCommand implements CommandExecutor {
|
|||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
|
||||
if (sender instanceof Player && !sender.isOp() &&
|
||||
(!LibsPremium.isPremium() || LibsPremium.getPaidInformation() == LibsPremium.getPluginInformation())) {
|
||||
sender.sendMessage(ChatColor.RED + "Please purchase Lib's Disguises to enable player commands");
|
||||
(!LibsPremium.isPremium() || LibsPremium.getPaidInformation() == LibsPremium.getPluginInformation())) {
|
||||
sender.sendMessage(ChatColor.RED +
|
||||
"This is the free version of Lib's Disguises, player commands are limited to console and Operators only! Purchase the plugin for non-admin " +
|
||||
"usage!");
|
||||
return true;
|
||||
}
|
||||
|
||||
if (sender.getName().equals("CONSOLE")) {
|
||||
sender.sendMessage(LibsMsg.NO_CONSOLE.get());
|
||||
LibsMsg.NO_CONSOLE.send(sender);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (sender.hasPermission("libsdisguises.undisguise") && !"%%__USER__%%".equals(12345 + "")) {
|
||||
if (DisguiseAPI.isDisguised((Entity) sender)) {
|
||||
DisguiseAPI.undisguiseToAll((Player) sender);
|
||||
sender.sendMessage(LibsMsg.UNDISG.get());
|
||||
DisguiseAPI.undisguiseToAll(sender, (Player) sender);
|
||||
LibsMsg.UNDISG.send(sender);
|
||||
} else {
|
||||
sender.sendMessage(LibsMsg.NOT_DISGUISED.get());
|
||||
LibsMsg.NOT_DISGUISED.send(sender);
|
||||
}
|
||||
} else {
|
||||
sender.sendMessage(LibsMsg.NO_PERM.get());
|
||||
LibsMsg.NO_PERM.send(sender);
|
||||
}
|
||||
|
||||
return true;
|
|
@ -15,24 +15,25 @@ public class UndisguiseEntityCommand implements CommandExecutor {
|
|||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
|
||||
if (sender instanceof Player && !sender.isOp() &&
|
||||
(!LibsPremium.isPremium() || LibsPremium.getPaidInformation() == LibsPremium.getPluginInformation())) {
|
||||
sender.sendMessage(ChatColor.RED + "Please purchase Lib's Disguises to enable player commands");
|
||||
(!LibsPremium.isPremium() || LibsPremium.getPaidInformation() == LibsPremium.getPluginInformation())) {
|
||||
sender.sendMessage(ChatColor.RED +
|
||||
"This is the free version of Lib's Disguises, player commands are limited to console and Operators only! Purchase the plugin for non-admin " +
|
||||
"usage!");
|
||||
return true;
|
||||
}
|
||||
|
||||
if (sender.getName().equals("CONSOLE")) {
|
||||
sender.sendMessage(LibsMsg.NO_CONSOLE.get());
|
||||
LibsMsg.NO_CONSOLE.send(sender);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!sender.hasPermission("libsdisguises.undisguiseentity")) {
|
||||
sender.sendMessage(LibsMsg.NO_PERM.get());
|
||||
LibsMsg.NO_PERM.send(sender);
|
||||
return true;
|
||||
}
|
||||
|
||||
LibsDisguises.getInstance().getListener().addInteraction(sender.getName(), new UndisguiseEntityInteraction(),
|
||||
DisguiseConfig.getDisguiseEntityExpire());
|
||||
sender.sendMessage(LibsMsg.UND_ENTITY.get());
|
||||
LibsDisguises.getInstance().getListener().addInteraction(sender.getName(), new UndisguiseEntityInteraction(), DisguiseConfig.getDisguiseEntityExpire());
|
||||
LibsMsg.UND_ENTITY.send(sender);
|
||||
|
||||
return true;
|
||||
}
|
|
@ -16,21 +16,24 @@ import org.bukkit.entity.Player;
|
|||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.UUID;
|
||||
|
||||
public class UndisguisePlayerCommand implements CommandExecutor, TabCompleter {
|
||||
protected ArrayList<String> filterTabs(ArrayList<String> list, String[] origArgs) {
|
||||
if (origArgs.length == 0)
|
||||
if (origArgs.length == 0) {
|
||||
return list;
|
||||
}
|
||||
|
||||
Iterator<String> itel = list.iterator();
|
||||
String label = origArgs[origArgs.length - 1].toLowerCase();
|
||||
String label = origArgs[origArgs.length - 1].toLowerCase(Locale.ENGLISH);
|
||||
|
||||
while (itel.hasNext()) {
|
||||
String name = itel.next();
|
||||
|
||||
if (name.toLowerCase().startsWith(label))
|
||||
if (name.toLowerCase(Locale.ENGLISH).startsWith(label)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
itel.remove();
|
||||
}
|
||||
|
@ -44,8 +47,9 @@ public class UndisguisePlayerCommand implements CommandExecutor, TabCompleter {
|
|||
for (int i = 0; i < args.length - 1; i++) {
|
||||
String s = args[i];
|
||||
|
||||
if (s.trim().isEmpty())
|
||||
if (s.trim().isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
newArgs.add(s);
|
||||
}
|
||||
|
@ -56,18 +60,20 @@ public class UndisguisePlayerCommand implements CommandExecutor, TabCompleter {
|
|||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
|
||||
if (sender instanceof Player && !sender.isOp() &&
|
||||
(!LibsPremium.isPremium() || LibsPremium.getPaidInformation() == LibsPremium.getPluginInformation())) {
|
||||
sender.sendMessage(ChatColor.RED + "Please purchase Lib's Disguises to enable player commands");
|
||||
(!LibsPremium.isPremium() || LibsPremium.getPaidInformation() == LibsPremium.getPluginInformation())) {
|
||||
sender.sendMessage(ChatColor.RED +
|
||||
"This is the free version of Lib's Disguises, player commands are limited to console and Operators only! Purchase the plugin for non-admin " +
|
||||
"usage!");
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!sender.hasPermission("libsdisguises.undisguiseplayer")) {
|
||||
sender.sendMessage(LibsMsg.NO_PERM.get());
|
||||
LibsMsg.NO_PERM.send(sender);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (args.length == 0) {
|
||||
sender.sendMessage(LibsMsg.UNDISG_PLAYER_HELP.get());
|
||||
LibsMsg.UNDISG_PLAYER_HELP.send(sender);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -77,24 +83,21 @@ public class UndisguisePlayerCommand implements CommandExecutor, TabCompleter {
|
|||
if (args[0].contains("-")) {
|
||||
try {
|
||||
entityTarget = Bukkit.getEntity(UUID.fromString(args[0]));
|
||||
}
|
||||
catch (Exception ignored) {
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (entityTarget == null) {
|
||||
sender.sendMessage(LibsMsg.CANNOT_FIND_PLAYER.get(args[0]));
|
||||
LibsMsg.CANNOT_FIND_PLAYER.send(sender, args[0]);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (DisguiseAPI.isDisguised(entityTarget)) {
|
||||
DisguiseAPI.undisguiseToAll(entityTarget);
|
||||
sender.sendMessage(LibsMsg.UNDISG_PLAYER.get(entityTarget instanceof Player ? entityTarget.getName() :
|
||||
DisguiseType.getType(entityTarget).toReadable()));
|
||||
DisguiseAPI.undisguiseToAll(sender, entityTarget);
|
||||
LibsMsg.UNDISG_PLAYER.send(sender, entityTarget instanceof Player ? entityTarget.getName() : DisguiseType.getType(entityTarget).toReadable());
|
||||
} else {
|
||||
sender.sendMessage(LibsMsg.UNDISG_PLAYER_FAIL.get(entityTarget instanceof Player ? entityTarget.getName() :
|
||||
DisguiseType.getType(entityTarget).toReadable()));
|
||||
LibsMsg.UNDISG_PLAYER_FAIL.send(sender, entityTarget instanceof Player ? entityTarget.getName() : DisguiseType.getType(entityTarget).toReadable());
|
||||
}
|
||||
|
||||
return true;
|
||||
|
@ -105,8 +108,9 @@ public class UndisguisePlayerCommand implements CommandExecutor, TabCompleter {
|
|||
ArrayList<String> tabs = new ArrayList<>();
|
||||
String[] args = getArgs(origArgs);
|
||||
|
||||
if (args.length != 0)
|
||||
if (args.length != 0) {
|
||||
return filterTabs(tabs, origArgs);
|
||||
}
|
||||
|
||||
for (Player player : Bukkit.getOnlinePlayers()) {
|
||||
// If command user cannot see player online, don't tab-complete name
|
|
@ -1,9 +1,12 @@
|
|||
package me.libraryaddict.disguise.commands.undisguise;
|
||||
|
||||
import me.libraryaddict.disguise.DisguiseAPI;
|
||||
import me.libraryaddict.disguise.DisguiseConfig;
|
||||
import me.libraryaddict.disguise.utilities.LibsPremium;
|
||||
import me.libraryaddict.disguise.utilities.translations.LibsMsg;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.command.BlockCommandSender;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
@ -11,18 +14,11 @@ import org.bukkit.entity.Entity;
|
|||
import org.bukkit.entity.Player;
|
||||
|
||||
public class UndisguiseRadiusCommand implements CommandExecutor {
|
||||
private int maxRadius = 30;
|
||||
|
||||
public UndisguiseRadiusCommand(int maxRadius) {
|
||||
this.maxRadius = maxRadius;
|
||||
}
|
||||
|
||||
private boolean isNumeric(String string) {
|
||||
try {
|
||||
Integer.parseInt(string);
|
||||
return true;
|
||||
}
|
||||
catch (Exception ex) {
|
||||
} catch (Exception ex) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -30,44 +26,59 @@ public class UndisguiseRadiusCommand implements CommandExecutor {
|
|||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
|
||||
if (sender instanceof Player && !sender.isOp() &&
|
||||
(!LibsPremium.isPremium() || LibsPremium.getPaidInformation() == LibsPremium.getPluginInformation())) {
|
||||
sender.sendMessage(ChatColor.RED + "Please purchase Lib's Disguises to enable player commands");
|
||||
(!LibsPremium.isPremium() || LibsPremium.getPaidInformation() == LibsPremium.getPluginInformation())) {
|
||||
sender.sendMessage(ChatColor.RED +
|
||||
"This is the free version of Lib's Disguises, player commands are limited to console and Operators only! Purchase the plugin for non-admin " +
|
||||
"usage!");
|
||||
return true;
|
||||
}
|
||||
|
||||
if (sender.getName().equals("CONSOLE")) {
|
||||
sender.sendMessage(LibsMsg.NO_CONSOLE.get());
|
||||
LibsMsg.NO_CONSOLE.send(sender);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (sender.hasPermission("libsdisguises.undisguiseradius")) {
|
||||
int radius = maxRadius;
|
||||
int radius = DisguiseConfig.getDisguiseRadiusMax();
|
||||
|
||||
if (args.length > 0) {
|
||||
if (!isNumeric(args[0])) {
|
||||
sender.sendMessage(LibsMsg.NOT_NUMBER.get(args[0]));
|
||||
LibsMsg.NOT_NUMBER.send(sender, args[0]);
|
||||
return true;
|
||||
}
|
||||
|
||||
radius = Integer.parseInt(args[0]);
|
||||
if (radius > maxRadius) {
|
||||
sender.sendMessage(LibsMsg.LIMITED_RADIUS.get(maxRadius));
|
||||
radius = maxRadius;
|
||||
|
||||
if (radius > DisguiseConfig.getDisguiseRadiusMax()) {
|
||||
LibsMsg.LIMITED_RADIUS.send(sender, DisguiseConfig.getDisguiseRadiusMax());
|
||||
radius = DisguiseConfig.getDisguiseRadiusMax();
|
||||
}
|
||||
}
|
||||
|
||||
Location center;
|
||||
|
||||
if (sender instanceof Player) {
|
||||
center = ((Player) sender).getLocation();
|
||||
} else {
|
||||
center = ((BlockCommandSender) sender).getBlock().getLocation().add(0.5, 0, 0.5);
|
||||
}
|
||||
|
||||
int disguisedEntitys = 0;
|
||||
for (Entity entity : ((Player) sender).getNearbyEntities(radius, radius, radius)) {
|
||||
|
||||
for (Entity entity : center.getWorld().getNearbyEntities(center, radius, radius, radius)) {
|
||||
if (entity == sender) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (DisguiseAPI.isDisguised(entity)) {
|
||||
DisguiseAPI.undisguiseToAll(entity);
|
||||
DisguiseAPI.undisguiseToAll(sender, entity);
|
||||
disguisedEntitys++;
|
||||
}
|
||||
}
|
||||
|
||||
sender.sendMessage(LibsMsg.UNDISRADIUS.get(disguisedEntitys));
|
||||
LibsMsg.UNDISRADIUS.send(sender, disguisedEntitys);
|
||||
} else {
|
||||
sender.sendMessage(LibsMsg.NO_PERM.get());
|
||||
LibsMsg.NO_PERM.send(sender);
|
||||
}
|
||||
return true;
|
||||
}
|
|
@ -9,7 +9,6 @@ import me.libraryaddict.disguise.disguisetypes.PlayerDisguise;
|
|||
import me.libraryaddict.disguise.utilities.DisguiseUtilities;
|
||||
import me.libraryaddict.disguise.utilities.LibsPremium;
|
||||
import me.libraryaddict.disguise.utilities.parser.DisguiseParser;
|
||||
import me.libraryaddict.disguise.utilities.reflection.NmsVersion;
|
||||
import me.libraryaddict.disguise.utilities.translations.LibsMsg;
|
||||
import net.md_5.bungee.api.chat.ClickEvent;
|
||||
import net.md_5.bungee.api.chat.ComponentBuilder;
|
||||
|
@ -32,13 +31,15 @@ public class CopyDisguiseCommand implements CommandExecutor {
|
|||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String s, String[] args) {
|
||||
if (sender instanceof Player && !sender.isOp() &&
|
||||
(!LibsPremium.isPremium() || LibsPremium.getPaidInformation() == LibsPremium.getPluginInformation())) {
|
||||
sender.sendMessage(ChatColor.RED + "Please purchase Lib's Disguises to enable player commands");
|
||||
(!LibsPremium.isPremium() || LibsPremium.getPaidInformation() == LibsPremium.getPluginInformation())) {
|
||||
sender.sendMessage(ChatColor.RED +
|
||||
"This is the free version of Lib's Disguises, player commands are limited to console and Operators only! Purchase the plugin for " +
|
||||
"non-admin usage!");
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!sender.hasPermission("libsdisguises.copydisguise")) {
|
||||
sender.sendMessage(LibsMsg.NO_PERM.get());
|
||||
LibsMsg.NO_PERM.send(sender);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -51,14 +52,13 @@ public class CopyDisguiseCommand implements CommandExecutor {
|
|||
if (args[0].contains("-")) {
|
||||
try {
|
||||
target = Bukkit.getEntity(UUID.fromString(args[0]));
|
||||
}
|
||||
catch (Exception ignored) {
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (target == null) {
|
||||
sender.sendMessage(LibsMsg.CANNOT_FIND_PLAYER.get(args[0]));
|
||||
LibsMsg.CANNOT_FIND_PLAYER.send(sender, args[0]);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -67,10 +67,9 @@ public class CopyDisguiseCommand implements CommandExecutor {
|
|||
|
||||
if (disguise == null) {
|
||||
LibsDisguises.getInstance().getListener()
|
||||
.addInteraction(sender.getName(), new CopyDisguiseInteraction(this),
|
||||
DisguiseConfig.getDisguiseEntityExpire());
|
||||
.addInteraction(sender.getName(), new CopyDisguiseInteraction(this), DisguiseConfig.getDisguiseEntityExpire());
|
||||
|
||||
sender.sendMessage(LibsMsg.DISGUISECOPY_INTERACT.get(DisguiseConfig.getDisguiseEntityExpire()));
|
||||
LibsMsg.DISGUISECOPY_INTERACT.send(sender, DisguiseConfig.getDisguiseEntityExpire());
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -79,8 +78,7 @@ public class CopyDisguiseCommand implements CommandExecutor {
|
|||
sendMessage(sender, LibsMsg.CLICK_TO_COPY, LibsMsg.COPY_DISGUISE_NO_COPY, disguiseString, false);
|
||||
|
||||
if (disguise instanceof PlayerDisguise) {
|
||||
sendMessage(sender, LibsMsg.CLICK_TO_COPY_WITH_SKIN, LibsMsg.CLICK_TO_COPY_WITH_SKIN_NO_COPY,
|
||||
DisguiseParser.parseToString(disguise), true);
|
||||
sendMessage(sender, LibsMsg.CLICK_TO_COPY_WITH_SKIN, LibsMsg.CLICK_TO_COPY_WITH_SKIN_NO_COPY, DisguiseParser.parseToString(disguise), true);
|
||||
}
|
||||
|
||||
DisguiseUtilities.setCopyDisguiseCommandUsed();
|
||||
|
@ -89,12 +87,12 @@ public class CopyDisguiseCommand implements CommandExecutor {
|
|||
}
|
||||
|
||||
public void sendMessage(CommandSender sender, LibsMsg msg, LibsMsg oldVer, String string, boolean forceAbbrev) {
|
||||
if (!NmsVersion.v1_13.isSupported()) {
|
||||
sender.sendMessage(oldVer.get(string));
|
||||
/* if (!NmsVersion.v1_13.isSupported()) {
|
||||
oldVer.send(sender, string);
|
||||
return;
|
||||
}
|
||||
}*/
|
||||
|
||||
ComponentBuilder builder = new ComponentBuilder("").appendLegacy(msg.get()).append(" ");
|
||||
ComponentBuilder builder = new ComponentBuilder("").append(msg.getBase()).append(" ");
|
||||
|
||||
if (string.length() > 256 || forceAbbrev) {
|
||||
String[] split = DisguiseUtilities.split(string);
|
||||
|
@ -136,18 +134,17 @@ public class CopyDisguiseCommand implements CommandExecutor {
|
|||
|
||||
sections++;
|
||||
|
||||
builder.appendLegacy(LibsMsg.CLICK_COPY.get(sections));
|
||||
builder.append(LibsMsg.CLICK_COPY.getBase(sections));
|
||||
builder.event(new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, current.toString()));
|
||||
builder.event(new HoverEvent(HoverEvent.Action.SHOW_TEXT,
|
||||
new ComponentBuilder(LibsMsg.CLICK_TO_COPY_HOVER.get() + " " + sections).create()));
|
||||
new ComponentBuilder("").append(LibsMsg.CLICK_TO_COPY_HOVER.getBase()).append(" " + sections).create()));
|
||||
|
||||
current = new StringBuilder();
|
||||
}
|
||||
} else {
|
||||
builder.appendLegacy(LibsMsg.CLICK_COPY.get(string));
|
||||
builder.append(LibsMsg.CLICK_COPY.getBase(string));
|
||||
builder.event(new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, string));
|
||||
builder.event(new HoverEvent(HoverEvent.Action.SHOW_TEXT,
|
||||
new ComponentBuilder(LibsMsg.CLICK_TO_COPY_HOVER.get()).create()));
|
||||
builder.event(new HoverEvent(HoverEvent.Action.SHOW_TEXT, LibsMsg.CLICK_TO_COPY_HOVER.getBase()));
|
||||
}
|
||||
|
||||
sender.spigot().sendMessage(builder.create());
|
|
@ -22,19 +22,18 @@ public class DisguiseCloneCommand extends DisguiseBaseCommand implements TabComp
|
|||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
|
||||
if (sender.getName().equals("CONSOLE")) {
|
||||
sender.sendMessage(LibsMsg.NO_CONSOLE.get());
|
||||
LibsMsg.NO_CONSOLE.send(sender);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!sender.hasPermission("libsdisguises.disguise.disguiseclone")) {
|
||||
|
||||
sender.sendMessage(LibsMsg.NO_PERM.get());
|
||||
LibsMsg.NO_PERM.send(sender);
|
||||
return true;
|
||||
}
|
||||
|
||||
boolean doEquipment = true;
|
||||
boolean doSneak = false;
|
||||
boolean doSprint = false;
|
||||
boolean doAdded = false;
|
||||
Player player = null;
|
||||
|
||||
if (args.length > 0) {
|
||||
|
@ -45,29 +44,23 @@ public class DisguiseCloneCommand extends DisguiseBaseCommand implements TabComp
|
|||
String option = args[i];
|
||||
if (StringUtils.startsWithIgnoreCase(option, LibsMsg.DCLONE_EQUIP.get())) {
|
||||
doEquipment = false;
|
||||
} else if (option.equalsIgnoreCase(LibsMsg.DCLONE_SNEAKSPRINT.get())) {
|
||||
doSneak = true;
|
||||
doSprint = true;
|
||||
} else if (option.equalsIgnoreCase(LibsMsg.DCLONE_SNEAK.get())) {
|
||||
doSneak = true;
|
||||
} else if (option.equalsIgnoreCase(LibsMsg.DCLONE_SPRINT.get())) {
|
||||
doSprint = true;
|
||||
} else if (option.equalsIgnoreCase(LibsMsg.DCLONE_ADDEDANIMATIONS.get())) {
|
||||
doAdded = true;
|
||||
} else {
|
||||
sender.sendMessage(LibsMsg.INVALID_CLONE.get(option));
|
||||
LibsMsg.INVALID_CLONE.send(sender, option);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
Boolean[] options = new Boolean[]{doEquipment, doSneak, doSprint};
|
||||
Boolean[] options = new Boolean[]{doEquipment, doAdded};
|
||||
|
||||
if (player != null) {
|
||||
DisguiseUtilities.createClonedDisguise((Player) sender, player, options);
|
||||
} else {
|
||||
LibsDisguises.getInstance().getListener()
|
||||
.addInteraction(sender.getName(), new DisguiseCloneInteraction(options),
|
||||
DisguiseConfig.getDisguiseCloneExpire());
|
||||
.addInteraction(sender.getName(), new DisguiseCloneInteraction(options), DisguiseConfig.getDisguiseCloneExpire());
|
||||
|
||||
sender.sendMessage(LibsMsg.CLICK_TIMER.get(DisguiseConfig.getDisguiseCloneExpire()));
|
||||
LibsMsg.CLICK_TIMER.send(sender, DisguiseConfig.getDisguiseCloneExpire());
|
||||
}
|
||||
|
||||
return true;
|
||||
|
@ -91,9 +84,7 @@ public class DisguiseCloneCommand extends DisguiseBaseCommand implements TabComp
|
|||
}
|
||||
|
||||
tabs.add(LibsMsg.DCLONE_EQUIP.get());
|
||||
tabs.add(LibsMsg.DCLONE_SNEAKSPRINT.get());
|
||||
tabs.add(LibsMsg.DCLONE_SNEAK.get());
|
||||
tabs.add(LibsMsg.DCLONE_SPRINT.get());
|
||||
tabs.add(LibsMsg.DCLONE_ADDEDANIMATIONS.get());
|
||||
|
||||
return filterTabs(tabs, origArgs);
|
||||
}
|
||||
|
@ -103,8 +94,8 @@ public class DisguiseCloneCommand extends DisguiseBaseCommand implements TabComp
|
|||
*/
|
||||
@Override
|
||||
protected void sendCommandUsage(CommandSender sender, DisguisePermissions permissions) {
|
||||
sender.sendMessage(LibsMsg.CLONE_HELP1.get());
|
||||
sender.sendMessage(LibsMsg.CLONE_HELP2.get());
|
||||
sender.sendMessage(LibsMsg.CLONE_HELP3.get());
|
||||
LibsMsg.CLONE_HELP1.send(sender);
|
||||
LibsMsg.CLONE_HELP2.send(sender);
|
||||
LibsMsg.CLONE_HELP3.send(sender);
|
||||
}
|
||||
}
|
|
@ -6,6 +6,7 @@ import me.libraryaddict.disguise.utilities.params.ParamInfoManager;
|
|||
import me.libraryaddict.disguise.utilities.parser.DisguiseParser;
|
||||
import me.libraryaddict.disguise.utilities.parser.DisguisePerm;
|
||||
import me.libraryaddict.disguise.utilities.parser.DisguisePermissions;
|
||||
import me.libraryaddict.disguise.utilities.parser.WatcherMethod;
|
||||
import me.libraryaddict.disguise.utilities.translations.LibsMsg;
|
||||
import me.libraryaddict.disguise.utilities.translations.TranslateType;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
|
@ -14,10 +15,10 @@ import org.bukkit.command.Command;
|
|||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.TabCompleter;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
public class DisguiseHelpCommand extends DisguiseBaseCommand implements TabCompleter {
|
||||
|
||||
|
@ -47,14 +48,12 @@ public class DisguiseHelpCommand extends DisguiseBaseCommand implements TabCompl
|
|||
|
||||
if (help != null) {
|
||||
if (help.hasValues() && help.canTranslateValues()) {
|
||||
sender.sendMessage(LibsMsg.DHELP_HELP4.get(help.getName(),
|
||||
StringUtils.join(help.getEnums(""), LibsMsg.DHELP_HELP4_SEPERATOR.get())));
|
||||
LibsMsg.DHELP_HELP4.send(sender, help.getName(), StringUtils.join(help.getEnums(""), LibsMsg.DHELP_HELP4_SEPERATOR.get()));
|
||||
} else {
|
||||
if (!help.getName().equals(help.getDescriptiveName())) {
|
||||
sender.sendMessage(LibsMsg.DHELP_HELP6
|
||||
.get(help.getName(), help.getDescriptiveName(), help.getDescription()));
|
||||
LibsMsg.DHELP_HELP6.send(sender, help.getName(), help.getDescriptiveName(), help.getDescription());
|
||||
} else {
|
||||
sender.sendMessage(LibsMsg.DHELP_HELP5.get(help.getName(), help.getDescription()));
|
||||
LibsMsg.DHELP_HELP5.send(sender, help.getName(), help.getDescription());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -64,12 +63,12 @@ public class DisguiseHelpCommand extends DisguiseBaseCommand implements TabCompl
|
|||
DisguisePerm type = DisguiseParser.getDisguisePerm(args[0]);
|
||||
|
||||
if (type == null) {
|
||||
sender.sendMessage(LibsMsg.DHELP_CANTFIND.get(args[0]));
|
||||
LibsMsg.DHELP_CANTFIND.send(sender, args[0]);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!perms.isAllowedDisguise(type)) {
|
||||
sender.sendMessage(LibsMsg.NO_PERM_DISGUISE.get());
|
||||
LibsMsg.NO_PERM_DISGUISE.send(sender);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -78,9 +77,13 @@ public class DisguiseHelpCommand extends DisguiseBaseCommand implements TabCompl
|
|||
int ignored = 0;
|
||||
|
||||
try {
|
||||
for (Method method : ParamInfoManager.getDisguiseWatcherMethods(watcher)) {
|
||||
for (WatcherMethod method : ParamInfoManager.getDisguiseWatcherMethods(watcher)) {
|
||||
if (!method.isUsable(type.getType())) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (args.length < 2 || !args[1].equalsIgnoreCase(LibsMsg.DHELP_SHOW.get())) {
|
||||
if (!perms.isAllowedDisguise(type, Collections.singleton(method.getName().toLowerCase()))) {
|
||||
if (!perms.isAllowedDisguise(type, Collections.singleton(method.getName().toLowerCase(Locale.ENGLISH)))) {
|
||||
ignored++;
|
||||
continue;
|
||||
}
|
||||
|
@ -97,13 +100,12 @@ public class DisguiseHelpCommand extends DisguiseBaseCommand implements TabCompl
|
|||
methodColor = ChatColor.GRAY;
|
||||
}
|
||||
|
||||
String str = TranslateType.DISGUISE_OPTIONS.get(method.getName()) + ChatColor.DARK_RED + "(" +
|
||||
ChatColor.GREEN + info.getName() + ChatColor.DARK_RED + ")";
|
||||
String str = TranslateType.DISGUISE_OPTIONS.get(method.getName()) + ChatColor.DARK_RED + "(" + ChatColor.GREEN + info.getName() +
|
||||
ChatColor.DARK_RED + ")";
|
||||
|
||||
methods.add(methodColor + str);
|
||||
}
|
||||
}
|
||||
catch (Exception ex) {
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
|
||||
|
@ -111,18 +113,17 @@ public class DisguiseHelpCommand extends DisguiseBaseCommand implements TabCompl
|
|||
methods.add(LibsMsg.DHELP_NO_OPTIONS.get());
|
||||
}
|
||||
|
||||
sender.sendMessage(LibsMsg.DHELP_OPTIONS.get(ChatColor.DARK_RED + type.toReadable(),
|
||||
StringUtils.join(methods, ChatColor.DARK_RED + ", ")));
|
||||
LibsMsg.DHELP_OPTIONS.send(sender, ChatColor.DARK_RED + type.toReadable(), StringUtils.join(methods, ChatColor.DARK_RED + ", "));
|
||||
|
||||
if (ignored > 0) {
|
||||
sender.sendMessage(LibsMsg.NO_PERMS_USE_OPTIONS.get(ignored));
|
||||
LibsMsg.NO_PERMS_USE_OPTIONS.send(sender, ignored);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
sender.sendMessage(LibsMsg.NO_PERM.get());
|
||||
LibsMsg.NO_PERM.send(sender);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -136,8 +137,9 @@ public class DisguiseHelpCommand extends DisguiseBaseCommand implements TabCompl
|
|||
|
||||
if (args.length == 0) {
|
||||
for (DisguisePerm type : perms.getAllowed()) {
|
||||
if (type.isUnknown())
|
||||
if (type.isUnknown()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
tabs.add(type.toReadable().replaceAll(" ", "_"));
|
||||
}
|
||||
|
@ -158,13 +160,12 @@ public class DisguiseHelpCommand extends DisguiseBaseCommand implements TabCompl
|
|||
*/
|
||||
@Override
|
||||
protected void sendCommandUsage(CommandSender sender, DisguisePermissions permissions) {
|
||||
sender.sendMessage(LibsMsg.DHELP_HELP1.get());
|
||||
sender.sendMessage(LibsMsg.DHELP_HELP2.get());
|
||||
LibsMsg.DHELP_HELP1.send(sender);
|
||||
LibsMsg.DHELP_HELP2.send(sender);
|
||||
|
||||
for (ParamInfo s : ParamInfoManager.getParamInfos()) {
|
||||
sender.sendMessage(LibsMsg.DHELP_HELP3.get(s.getName().replaceAll(" ", "") +
|
||||
(!s.getName().equals(s.getDescriptiveName()) ? " ~ " + s.getDescriptiveName() : ""),
|
||||
s.getDescription()));
|
||||
LibsMsg.DHELP_HELP3.send(sender,
|
||||
s.getName().replaceAll(" ", "") + (!s.getName().equals(s.getDescriptiveName()) ? " ~ " + s.getDescriptiveName() : ""), s.getDescription());
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,33 @@
|
|||
package me.libraryaddict.disguise.commands.utils;
|
||||
|
||||
import me.libraryaddict.disguise.DisguiseAPI;
|
||||
import me.libraryaddict.disguise.utilities.translations.LibsMsg;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
/**
|
||||
* Created by libraryaddict on 2/07/2020.
|
||||
*/
|
||||
public class DisguiseViewBarCommand implements CommandExecutor {
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
if (sender.getName().equals("CONSOLE")) {
|
||||
LibsMsg.NO_CONSOLE.send(sender);
|
||||
return true;
|
||||
}
|
||||
|
||||
Player player = (Player) sender;
|
||||
|
||||
if (DisguiseAPI.isNotifyBarShown(player)) {
|
||||
DisguiseAPI.setActionBarShown(player, false);
|
||||
LibsMsg.VIEW_BAR_OFF.send(sender);
|
||||
} else {
|
||||
DisguiseAPI.setActionBarShown(player, true);
|
||||
LibsMsg.VIEW_BAR_ON.send(sender);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
|
@ -15,7 +15,7 @@ public class DisguiseViewSelfCommand implements CommandExecutor {
|
|||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
if (sender.getName().equals("CONSOLE")) {
|
||||
sender.sendMessage(LibsMsg.NO_CONSOLE.get());
|
||||
LibsMsg.NO_CONSOLE.send(sender);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -23,10 +23,10 @@ public class DisguiseViewSelfCommand implements CommandExecutor {
|
|||
|
||||
if (DisguiseAPI.isViewSelfToggled(player)) {
|
||||
DisguiseAPI.setViewDisguiseToggled(player, false);
|
||||
sender.sendMessage(LibsMsg.VIEW_SELF_OFF.get());
|
||||
LibsMsg.VIEW_SELF_OFF.send(sender);
|
||||
} else {
|
||||
DisguiseAPI.setViewDisguiseToggled(player, true);
|
||||
sender.sendMessage(LibsMsg.VIEW_SELF_ON.get());
|
||||
LibsMsg.VIEW_SELF_ON.send(sender);
|
||||
}
|
||||
|
||||
return true;
|
|
@ -0,0 +1,125 @@
|
|||
package me.libraryaddict.disguise.commands.utils;
|
||||
|
||||
import com.comphenix.protocol.wrappers.WrappedGameProfile;
|
||||
import me.libraryaddict.disguise.LibsDisguises;
|
||||
import me.libraryaddict.disguise.utilities.DisguiseUtilities;
|
||||
import me.libraryaddict.disguise.utilities.LibsPremium;
|
||||
import me.libraryaddict.disguise.utilities.SkinUtils;
|
||||
import me.libraryaddict.disguise.utilities.translations.LibsMsg;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.SkullMeta;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
import org.bukkit.scheduler.BukkitTask;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
|
||||
/**
|
||||
* Created by libraryaddict on 20/06/2020.
|
||||
*/
|
||||
public class GrabHeadCommand implements CommandExecutor {
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String s, String[] strings) {
|
||||
if (sender instanceof Player && !sender.isOp() &&
|
||||
(!LibsPremium.isPremium() || LibsPremium.getPaidInformation() == LibsPremium.getPluginInformation())) {
|
||||
sender.sendMessage(ChatColor.RED +
|
||||
"This is the free version of Lib's Disguises, player commands are limited to console and Operators only! Purchase the plugin for non-admin " +
|
||||
"usage!");
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!sender.hasPermission("libsdisguises.grabhead")) {
|
||||
LibsMsg.NO_PERM.send(sender);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!(sender instanceof Player)) {
|
||||
LibsMsg.NO_CONSOLE.send(sender);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (strings.length == 0) {
|
||||
sendHelp(sender);
|
||||
return true;
|
||||
}
|
||||
|
||||
String[] args = DisguiseUtilities.split(StringUtils.join(strings, " "));
|
||||
String skin = args[0];
|
||||
|
||||
String usable = SkinUtils.getUsableStatus();
|
||||
|
||||
if (usable != null) {
|
||||
sender.sendMessage(usable);
|
||||
return true;
|
||||
}
|
||||
|
||||
SkinUtils.SkinCallback callback = new SkinUtils.SkinCallback() {
|
||||
private BukkitTask runnable = new BukkitRunnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
LibsMsg.PLEASE_WAIT.send(sender);
|
||||
}
|
||||
}.runTaskTimer(LibsDisguises.getInstance(), 100, 100);
|
||||
|
||||
@Override
|
||||
public void onError(LibsMsg msg, Object... args) {
|
||||
msg.send(sender, args);
|
||||
|
||||
runnable.cancel();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onInfo(LibsMsg msg, Object... args) {
|
||||
msg.send(sender, args);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSuccess(WrappedGameProfile profile) {
|
||||
runnable.cancel();
|
||||
DisguiseUtilities.doSkinUUIDWarning(sender);
|
||||
|
||||
DisguiseUtilities.setGrabHeadCommandUsed();
|
||||
|
||||
new BukkitRunnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
ItemStack skull = new ItemStack(Material.PLAYER_HEAD);
|
||||
SkullMeta meta = (SkullMeta) skull.getItemMeta();
|
||||
|
||||
try {
|
||||
Field field = meta.getClass().getDeclaredField("profile");
|
||||
field.setAccessible(true);
|
||||
field.set(meta, profile.getHandle());
|
||||
} catch (NoSuchFieldException | IllegalAccessException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
skull.setItemMeta(meta);
|
||||
|
||||
((Player) sender).getInventory().addItem(skull);
|
||||
LibsMsg.GRAB_HEAD_SUCCESS.send(sender);
|
||||
}
|
||||
}.runTask(LibsDisguises.getInstance());
|
||||
}
|
||||
};
|
||||
|
||||
SkinUtils.grabSkin(skin, callback);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private void sendHelp(CommandSender sender) {
|
||||
LibsMsg.GRAB_DISG_HELP_1.send(sender);
|
||||
LibsMsg.GRAB_DISG_HELP_2.send(sender);
|
||||
LibsMsg.GRAB_DISG_HELP_3.send(sender);
|
||||
LibsMsg.GRAB_DISG_HELP_4.send(sender);
|
||||
LibsMsg.GRAB_DISG_HELP_5.send(sender);
|
||||
LibsMsg.GRAB_DISG_HELP_6.send(sender);
|
||||
}
|
||||
}
|
|
@ -6,7 +6,6 @@ import me.libraryaddict.disguise.LibsDisguises;
|
|||
import me.libraryaddict.disguise.utilities.DisguiseUtilities;
|
||||
import me.libraryaddict.disguise.utilities.LibsPremium;
|
||||
import me.libraryaddict.disguise.utilities.SkinUtils;
|
||||
import me.libraryaddict.disguise.utilities.reflection.NmsVersion;
|
||||
import me.libraryaddict.disguise.utilities.reflection.ReflectionManager;
|
||||
import me.libraryaddict.disguise.utilities.translations.LibsMsg;
|
||||
import net.md_5.bungee.api.chat.ClickEvent;
|
||||
|
@ -29,13 +28,15 @@ public class GrabSkinCommand implements CommandExecutor {
|
|||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String s, String[] strings) {
|
||||
if (sender instanceof Player && !sender.isOp() &&
|
||||
(!LibsPremium.isPremium() || LibsPremium.getPaidInformation() == LibsPremium.getPluginInformation())) {
|
||||
sender.sendMessage(ChatColor.RED + "Please purchase Lib's Disguises to enable player commands");
|
||||
(!LibsPremium.isPremium() || LibsPremium.getPaidInformation() == LibsPremium.getPluginInformation())) {
|
||||
sender.sendMessage(ChatColor.RED +
|
||||
"This is the free version of Lib's Disguises, player commands are limited to console and Operators only! Purchase the plugin for " +
|
||||
"non-admin usage!");
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!sender.hasPermission("libsdisguises.grabskin")) {
|
||||
sender.sendMessage(LibsMsg.NO_PERM.get());
|
||||
LibsMsg.NO_PERM.send(sender);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -55,8 +56,15 @@ public class GrabSkinCommand implements CommandExecutor {
|
|||
return true;
|
||||
}
|
||||
|
||||
if (tName == null && skin.matches("(.*\\/)?[a-zA-Z0-9_-]{3,20}\\.png")) {
|
||||
tName = skin.substring(skin.lastIndexOf("/") + 1, skin.lastIndexOf("."));
|
||||
if (tName == null && skin.matches("(.*\\/)?[a-zA-Z0-9_-]{3,20}(\\.png)?")) {
|
||||
int start = skin.lastIndexOf("/") + 1;
|
||||
int end = skin.length();
|
||||
|
||||
if (skin.lastIndexOf(".", start) > start) {
|
||||
end = skin.lastIndexOf(".", start);
|
||||
}
|
||||
|
||||
tName = skin.substring(start, end);
|
||||
|
||||
if (DisguiseUtilities.hasGameProfile(tName)) {
|
||||
tName = null;
|
||||
|
@ -69,25 +77,26 @@ public class GrabSkinCommand implements CommandExecutor {
|
|||
private BukkitTask runnable = new BukkitRunnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
sender.sendMessage(LibsMsg.PLEASE_WAIT.get());
|
||||
LibsMsg.PLEASE_WAIT.send(sender);
|
||||
}
|
||||
}.runTaskTimer(LibsDisguises.getInstance(), 100, 100);
|
||||
|
||||
@Override
|
||||
public void onError(LibsMsg msg, Object... args) {
|
||||
sender.sendMessage(msg.get(args));
|
||||
msg.send(sender, args);
|
||||
|
||||
runnable.cancel();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onInfo(LibsMsg msg, Object... args) {
|
||||
sender.sendMessage(msg.get(args));
|
||||
msg.send(sender, args);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSuccess(WrappedGameProfile profile) {
|
||||
runnable.cancel();
|
||||
DisguiseUtilities.doSkinUUIDWarning(sender);
|
||||
|
||||
String nName = name;
|
||||
|
||||
|
@ -102,47 +111,46 @@ public class GrabSkinCommand implements CommandExecutor {
|
|||
}
|
||||
|
||||
if (profile.getName() == null || !profile.getName().equals(nName)) {
|
||||
profile = ReflectionManager
|
||||
.getGameProfileWithThisSkin(profile.getUUID(), profile.getName(), profile);
|
||||
profile = ReflectionManager.getGameProfileWithThisSkin(profile.getUUID(), profile.getName(), profile);
|
||||
}
|
||||
|
||||
DisguiseAPI.addGameProfile(nName, profile);
|
||||
sender.sendMessage(LibsMsg.GRABBED_SKIN.get(nName));
|
||||
LibsMsg.GRABBED_SKIN.send(sender, nName);
|
||||
|
||||
String string = DisguiseUtilities.getGson().toJson(profile);
|
||||
int start = 0;
|
||||
int msg = 1;
|
||||
|
||||
if (NmsVersion.v1_13.isSupported()) {
|
||||
ComponentBuilder builder = new ComponentBuilder("").appendLegacy(LibsMsg.CLICK_TO_COPY.get());
|
||||
//if (NmsVersion.v1_13.isSupported()) {
|
||||
ComponentBuilder builder = new ComponentBuilder("").append(LibsMsg.CLICK_TO_COPY.getBase());
|
||||
|
||||
while (start < string.length()) {
|
||||
int end = Math.min(256, string.length() - start);
|
||||
while (start < string.length()) {
|
||||
int end = Math.min(256, string.length() - start);
|
||||
|
||||
String sub = string.substring(start, start + end);
|
||||
String sub = string.substring(start, start + end);
|
||||
|
||||
builder.append(" ");
|
||||
builder.append(" ");
|
||||
|
||||
if (string.length() <= 256) {
|
||||
builder.appendLegacy(LibsMsg.CLICK_TO_COPY_DATA.get());
|
||||
} else {
|
||||
builder.reset();
|
||||
builder.appendLegacy(LibsMsg.CLICK_COPY.get(msg));
|
||||
}
|
||||
|
||||
start += end;
|
||||
|
||||
builder.event(new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, sub));
|
||||
builder.event(new HoverEvent(HoverEvent.Action.SHOW_TEXT,
|
||||
new ComponentBuilder(LibsMsg.CLICK_TO_COPY_HOVER.get() + " " + msg).create()));
|
||||
msg += 1;
|
||||
if (string.length() <= 256) {
|
||||
builder.append(LibsMsg.CLICK_TO_COPY_DATA.getBase());
|
||||
} else {
|
||||
builder.reset();
|
||||
builder.append(LibsMsg.CLICK_COPY.getBase(msg));
|
||||
}
|
||||
|
||||
sender.spigot().sendMessage(builder.create());
|
||||
} else {
|
||||
sender.sendMessage(LibsMsg.SKIN_DATA.get(string));
|
||||
start += end;
|
||||
|
||||
builder.event(new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, sub));
|
||||
builder.event(new HoverEvent(HoverEvent.Action.SHOW_TEXT,
|
||||
new ComponentBuilder("").append(LibsMsg.CLICK_TO_COPY_HOVER.getBase()).append(" " + msg).create()));
|
||||
msg += 1;
|
||||
}
|
||||
|
||||
sender.spigot().sendMessage(builder.create());
|
||||
/*} else {
|
||||
LibsMsg.SKIN_DATA.send(sender, string);
|
||||
}*/
|
||||
|
||||
DisguiseUtilities.setGrabSkinCommandUsed();
|
||||
}
|
||||
};
|
||||
|
@ -153,11 +161,11 @@ public class GrabSkinCommand implements CommandExecutor {
|
|||
}
|
||||
|
||||
private void sendHelp(CommandSender sender) {
|
||||
sender.sendMessage(LibsMsg.GRAB_DISG_HELP_1.get());
|
||||
sender.sendMessage(LibsMsg.GRAB_DISG_HELP_2.get());
|
||||
sender.sendMessage(LibsMsg.GRAB_DISG_HELP_3.get());
|
||||
sender.sendMessage(LibsMsg.GRAB_DISG_HELP_4.get());
|
||||
sender.sendMessage(LibsMsg.GRAB_DISG_HELP_5.get());
|
||||
sender.sendMessage(LibsMsg.GRAB_DISG_HELP_6.get());
|
||||
LibsMsg.GRAB_DISG_HELP_1.send(sender);
|
||||
LibsMsg.GRAB_DISG_HELP_2.send(sender);
|
||||
LibsMsg.GRAB_DISG_HELP_3.send(sender);
|
||||
LibsMsg.GRAB_DISG_HELP_4.send(sender);
|
||||
LibsMsg.GRAB_DISG_HELP_5.send(sender);
|
||||
LibsMsg.GRAB_DISG_HELP_6.send(sender);
|
||||
}
|
||||
}
|
|
@ -29,13 +29,15 @@ public class SaveDisguiseCommand implements CommandExecutor {
|
|||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String s, String[] strings) {
|
||||
if (sender instanceof Player && !sender.isOp() &&
|
||||
(!LibsPremium.isPremium() || LibsPremium.getPaidInformation() == LibsPremium.getPluginInformation())) {
|
||||
sender.sendMessage(ChatColor.RED + "Please purchase Lib's Disguises to enable player commands");
|
||||
(!LibsPremium.isPremium() || LibsPremium.getPaidInformation() == LibsPremium.getPluginInformation())) {
|
||||
sender.sendMessage(ChatColor.RED +
|
||||
"This is the free version of Lib's Disguises, player commands are limited to console and Operators only! Purchase the plugin for " +
|
||||
"non-admin usage!");
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!sender.hasPermission("libsdisguises.savedisguise")) {
|
||||
sender.sendMessage(LibsMsg.NO_PERM.get());
|
||||
LibsMsg.NO_PERM.send(sender);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -51,14 +53,14 @@ public class SaveDisguiseCommand implements CommandExecutor {
|
|||
|
||||
if (args.length == 0) {
|
||||
if (!(sender instanceof Player)) {
|
||||
sender.sendMessage(LibsMsg.NO_CONSOLE.get());
|
||||
LibsMsg.NO_CONSOLE.send(sender);
|
||||
return true;
|
||||
}
|
||||
|
||||
Disguise disguise = DisguiseAPI.getDisguise((Entity) sender);
|
||||
|
||||
if (disguise == null) {
|
||||
sender.sendMessage(LibsMsg.NOT_DISGUISED.get());
|
||||
LibsMsg.NOT_DISGUISED_SAVE_DISGUISE.send(sender);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -67,13 +69,12 @@ public class SaveDisguiseCommand implements CommandExecutor {
|
|||
try {
|
||||
DisguiseAPI.addCustomDisguise(name, disguiseString);
|
||||
|
||||
sender.sendMessage(LibsMsg.CUSTOM_DISGUISE_SAVED.get(name));
|
||||
}
|
||||
catch (DisguiseParseException e) {
|
||||
LibsMsg.CUSTOM_DISGUISE_SAVED.send(sender, name);
|
||||
} catch (DisguiseParseException e) {
|
||||
if (e.getMessage() != null) {
|
||||
sender.sendMessage(e.getMessage());
|
||||
e.send(sender);
|
||||
} else {
|
||||
sender.sendMessage(LibsMsg.PARSE_CANT_LOAD.get());
|
||||
LibsMsg.PARSE_CANT_LOAD.send(sender);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -85,8 +86,9 @@ public class SaveDisguiseCommand implements CommandExecutor {
|
|||
int i = 2;
|
||||
|
||||
for (; i < args.length; i++) {
|
||||
if (!args[i].equalsIgnoreCase("setskin"))
|
||||
if (!args[i].equalsIgnoreCase("setskin")) {
|
||||
continue;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
@ -109,7 +111,7 @@ public class SaveDisguiseCommand implements CommandExecutor {
|
|||
String usable = SkinUtils.getUsableStatus();
|
||||
|
||||
if (usable != null) {
|
||||
sender.sendMessage(usable);
|
||||
DisguiseUtilities.sendMessage(sender, usable);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -119,7 +121,7 @@ public class SaveDisguiseCommand implements CommandExecutor {
|
|||
private BukkitTask runnable = new BukkitRunnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
sender.sendMessage(LibsMsg.PLEASE_WAIT.get());
|
||||
LibsMsg.PLEASE_WAIT.send(sender);
|
||||
}
|
||||
}.runTaskTimer(LibsDisguises.getInstance(), 100, 100);
|
||||
|
||||
|
@ -127,17 +129,18 @@ public class SaveDisguiseCommand implements CommandExecutor {
|
|||
public void onError(LibsMsg msg, Object... args) {
|
||||
runnable.cancel();
|
||||
|
||||
sender.sendMessage(msg.get(args));
|
||||
msg.send(sender, args);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onInfo(LibsMsg msg, Object... args) {
|
||||
sender.sendMessage(msg.get(args));
|
||||
msg.send(sender, args);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSuccess(WrappedGameProfile profile) {
|
||||
runnable.cancel();
|
||||
DisguiseUtilities.doSkinUUIDWarning(sender);
|
||||
|
||||
finalArgs[skinId] = DisguiseUtilities.getGson().toJson(profile);
|
||||
|
||||
|
@ -163,25 +166,24 @@ public class SaveDisguiseCommand implements CommandExecutor {
|
|||
|
||||
try {
|
||||
DisguiseAPI.addCustomDisguise(name, disguiseString);
|
||||
sender.sendMessage(LibsMsg.CUSTOM_DISGUISE_SAVED.get(name));
|
||||
LibsMsg.CUSTOM_DISGUISE_SAVED.send(sender, name);
|
||||
|
||||
DisguiseUtilities.setSaveDisguiseCommandUsed();
|
||||
}
|
||||
catch (DisguiseParseException e) {
|
||||
} catch (DisguiseParseException e) {
|
||||
if (e.getMessage() != null) {
|
||||
sender.sendMessage(e.getMessage());
|
||||
e.send(sender);
|
||||
} else {
|
||||
sender.sendMessage(LibsMsg.PARSE_CANT_LOAD.get());
|
||||
LibsMsg.PARSE_CANT_LOAD.send(sender);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void sendHelp(CommandSender sender) {
|
||||
sender.sendMessage(LibsMsg.SAVE_DISG_HELP_1.get());
|
||||
sender.sendMessage(LibsMsg.SAVE_DISG_HELP_2.get());
|
||||
sender.sendMessage(LibsMsg.SAVE_DISG_HELP_3.get());
|
||||
sender.sendMessage(LibsMsg.SAVE_DISG_HELP_4.get());
|
||||
sender.sendMessage(LibsMsg.SAVE_DISG_HELP_5.get());
|
||||
sender.sendMessage(LibsMsg.SAVE_DISG_HELP_6.get());
|
||||
LibsMsg.SAVE_DISG_HELP_1.send(sender);
|
||||
LibsMsg.SAVE_DISG_HELP_2.send(sender);
|
||||
LibsMsg.SAVE_DISG_HELP_3.send(sender);
|
||||
LibsMsg.SAVE_DISG_HELP_4.send(sender);
|
||||
LibsMsg.SAVE_DISG_HELP_5.send(sender);
|
||||
LibsMsg.SAVE_DISG_HELP_6.send(sender);
|
||||
}
|
||||
}
|
|
@ -6,27 +6,23 @@ import org.bukkit.Material;
|
|||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
public enum AnimalColor {
|
||||
BLACK(DyeColor.BLACK,
|
||||
NmsVersion.v1_13.isSupported() ? Material.getMaterial("INK_SAC") : Material.getMaterial("INK_SACK")),
|
||||
BLACK(DyeColor.BLACK, NmsVersion.v1_13.isSupported() ? Material.getMaterial("INK_SAC") : Material.getMaterial("INK_SACK")),
|
||||
BLUE(DyeColor.BLUE, NmsVersion.v1_13.isSupported() ? Material.getMaterial("LAPIS_LAZULI") : null),
|
||||
BROWN(DyeColor.BROWN, NmsVersion.v1_13.isSupported() ? Material.getMaterial("COCOA_BEANS") : null),
|
||||
CYAN(DyeColor.CYAN, NmsVersion.v1_13.isSupported() ? Material.getMaterial("CYAN_DYE") : null),
|
||||
GRAY(DyeColor.GRAY, NmsVersion.v1_13.isSupported() ? Material.getMaterial("GRAY_DYE") : null),
|
||||
GREEN(DyeColor.GREEN,
|
||||
NmsVersion.v1_14.isSupported() ? Material.getMaterial("GREEN_DYE") : Material.getMaterial("CACTUS_GREEN")),
|
||||
GREEN(DyeColor.GREEN, NmsVersion.v1_14.isSupported() ? Material.getMaterial("GREEN_DYE") : Material.getMaterial("CACTUS_GREEN")),
|
||||
LIGHT_BLUE(DyeColor.LIGHT_BLUE, NmsVersion.v1_13.isSupported() ? Material.getMaterial("LIGHT_BLUE_DYE") : null),
|
||||
LIME(DyeColor.LIME, NmsVersion.v1_13.isSupported() ? Material.getMaterial("LIME_DYE") : null),
|
||||
MAGENTA(DyeColor.MAGENTA, NmsVersion.v1_13.isSupported() ? Material.getMaterial("MAGENTA_DYE") : null),
|
||||
ORANGE(DyeColor.ORANGE, NmsVersion.v1_13.isSupported() ? Material.getMaterial("ORANGE_DYE") : null),
|
||||
PINK(DyeColor.PINK, NmsVersion.v1_13.isSupported() ? Material.getMaterial("PINK_DYE") : null),
|
||||
PURPLE(DyeColor.PURPLE, NmsVersion.v1_13.isSupported() ? Material.getMaterial("PURPLE_DYE") : null),
|
||||
RED(DyeColor.RED,
|
||||
NmsVersion.v1_14.isSupported() ? Material.getMaterial("RED_DYE") : Material.getMaterial("ROSE_RED")),
|
||||
RED(DyeColor.RED, NmsVersion.v1_14.isSupported() ? Material.getMaterial("RED_DYE") : Material.getMaterial("ROSE_RED")),
|
||||
LIGHT_GRAY(DyeColor.valueOf(NmsVersion.v1_13.isSupported() ? "LIGHT_GRAY" : "SILVER"),
|
||||
NmsVersion.v1_13.isSupported() ? Material.getMaterial("LIGHT_GRAY_DYE") : null),
|
||||
NmsVersion.v1_13.isSupported() ? Material.getMaterial("LIGHT_GRAY_DYE") : null),
|
||||
WHITE(DyeColor.WHITE, NmsVersion.v1_13.isSupported() ? Material.getMaterial("BONE_MEAL") : null),
|
||||
YELLOW(DyeColor.YELLOW, NmsVersion.v1_14.isSupported() ? Material.getMaterial("YELLOW_DYE") :
|
||||
Material.getMaterial("DANDELION_YELLOW"));
|
||||
YELLOW(DyeColor.YELLOW, NmsVersion.v1_14.isSupported() ? Material.getMaterial("YELLOW_DYE") : Material.getMaterial("DANDELION_YELLOW"));
|
||||
|
||||
public static AnimalColor getColorByWool(int woolId) {
|
||||
for (AnimalColor color : values()) {
|
File diff suppressed because it is too large
Load diff
|
@ -0,0 +1,245 @@
|
|||
package me.libraryaddict.disguise.disguisetypes;
|
||||
|
||||
import com.comphenix.protocol.PacketType;
|
||||
import com.comphenix.protocol.ProtocolLibrary;
|
||||
import com.comphenix.protocol.events.PacketContainer;
|
||||
import com.comphenix.protocol.reflect.StructureModifier;
|
||||
import me.libraryaddict.disguise.DisguiseAPI;
|
||||
import me.libraryaddict.disguise.DisguiseConfig;
|
||||
import me.libraryaddict.disguise.disguisetypes.watchers.BatWatcher;
|
||||
import me.libraryaddict.disguise.utilities.DisguiseUtilities;
|
||||
import me.libraryaddict.disguise.utilities.reflection.ReflectionManager;
|
||||
import me.libraryaddict.disguise.utilities.translations.LibsMsg;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
|
||||
/**
|
||||
* Created by libraryaddict on 20/05/2021.
|
||||
*/
|
||||
class DisguiseRunnable extends BukkitRunnable {
|
||||
private int blockX, blockY, blockZ, facing;
|
||||
private int deadTicks = 0;
|
||||
private int actionBarTicks = -1;
|
||||
private int refreshRate;
|
||||
private long lastRefreshed = System.currentTimeMillis();
|
||||
private Disguise disguise;
|
||||
final Double vectorY;
|
||||
final boolean alwaysSendVelocity;
|
||||
|
||||
public DisguiseRunnable(Disguise disguise) {
|
||||
this.disguise = disguise;
|
||||
|
||||
switch (disguise.getType()) {
|
||||
case FIREWORK:
|
||||
case WITHER_SKULL:
|
||||
case EXPERIENCE_ORB:
|
||||
vectorY = 0.000001D;
|
||||
alwaysSendVelocity = true;
|
||||
break;
|
||||
default:
|
||||
vectorY = null;
|
||||
alwaysSendVelocity = false;
|
||||
break;
|
||||
}
|
||||
|
||||
// Where refresh rate is in ticks, exp is in here due to a fire exploit + stop it glitching out so much
|
||||
switch (disguise.getType()) {
|
||||
case FIREWORK:
|
||||
case EXPERIENCE_ORB:
|
||||
refreshRate = 40; // 2 seconds
|
||||
break;
|
||||
case EVOKER_FANGS:
|
||||
refreshRate = 23;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
refreshRate *= 50;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
if (!disguise.isDisguiseInUse() || disguise.getEntity() == null || !Bukkit.getWorlds().contains(disguise.getEntity().getWorld())) {
|
||||
disguise.stopDisguise();
|
||||
|
||||
// If still somehow not cancelled
|
||||
if (!isCancelled()) {
|
||||
cancel();
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (++actionBarTicks % 15 == 0) {
|
||||
actionBarTicks = 0;
|
||||
|
||||
disguise.doActionBar();
|
||||
}
|
||||
|
||||
// If entity is no longer valid. Remove it.
|
||||
if (disguise.getEntity() instanceof Player && !((Player) disguise.getEntity()).isOnline()) {
|
||||
disguise.removeDisguise();
|
||||
} else if (disguise.disguiseExpires > 0 && (DisguiseConfig.isDynamicExpiry() ? disguise.disguiseExpires-- == 1 :
|
||||
disguise.disguiseExpires < System.currentTimeMillis())) { // If disguise expired
|
||||
disguise.removeDisguise();
|
||||
|
||||
if (disguise.getEntity() instanceof Player) {
|
||||
LibsMsg.EXPIRED_DISGUISE.send(disguise.getEntity());
|
||||
}
|
||||
|
||||
return;
|
||||
} else if (!disguise.getEntity().isValid()) {
|
||||
// If it has been dead for 30+ ticks
|
||||
// This is to ensure that this disguise isn't removed while clients think its the real entity
|
||||
// The delay is because if it sends the destroy entity packets straight away, then it means no
|
||||
// death animation
|
||||
// This is probably still a problem for wither and enderdragon deaths.
|
||||
if (deadTicks++ > (disguise.getType() == DisguiseType.ENDER_DRAGON ? 200 : 20)) {
|
||||
if (disguise.isRemoveDisguiseOnDeath()) {
|
||||
disguise.removeDisguise();
|
||||
}
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
deadTicks = 0;
|
||||
|
||||
// If the disguise type is invisibable, we need to resend the entity packet else it will turn invisible
|
||||
if (refreshRate > 0 && lastRefreshed + refreshRate < System.currentTimeMillis()) {
|
||||
lastRefreshed = System.currentTimeMillis();
|
||||
|
||||
DisguiseUtilities.refreshTrackers((TargetedDisguise) disguise);
|
||||
}
|
||||
|
||||
if (disguise.isModifyBoundingBox()) {
|
||||
DisguiseUtilities.doBoundingBox((TargetedDisguise) disguise);
|
||||
}
|
||||
|
||||
if (disguise.getType() == DisguiseType.BAT && !((BatWatcher) disguise.getWatcher()).isHanging()) {
|
||||
return;
|
||||
}
|
||||
|
||||
doVelocity(vectorY, alwaysSendVelocity);
|
||||
|
||||
if (disguise.getType() == DisguiseType.EXPERIENCE_ORB) {
|
||||
PacketContainer packet = new PacketContainer(PacketType.Play.Server.REL_ENTITY_MOVE);
|
||||
|
||||
packet.getIntegers().write(0, disguise.getEntity().getEntityId());
|
||||
|
||||
try {
|
||||
for (Player player : DisguiseUtilities.getPerverts(disguise)) {
|
||||
if (disguise.getEntity() != player) {
|
||||
ProtocolLibrary.getProtocolManager().sendServerPacket(player, packet, false);
|
||||
continue;
|
||||
} else if (!disguise.isSelfDisguiseVisible() || !(disguise.getEntity() instanceof Player)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
PacketContainer selfPacket = packet.shallowClone();
|
||||
|
||||
selfPacket.getModifier().write(0, DisguiseAPI.getSelfDisguiseId());
|
||||
|
||||
try {
|
||||
ProtocolLibrary.getProtocolManager().sendServerPacket((Player) disguise.getEntity(), selfPacket, false);
|
||||
} catch (InvocationTargetException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
} catch (InvocationTargetException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void doVelocity(Double vectorY, boolean alwaysSendVelocity) {
|
||||
// If the vectorY isn't 0. Cos if it is. Then it doesn't want to send any vectors.
|
||||
// If this disguise has velocity sending enabled and the entity is flying.
|
||||
if (disguise.isVelocitySent() && vectorY != null && (alwaysSendVelocity || !disguise.getEntity().isOnGround())) {
|
||||
Vector vector = disguise.getEntity().getVelocity();
|
||||
|
||||
// If the entity doesn't have velocity changes already - You know. I really can't wrap my
|
||||
// head about the
|
||||
// if statement.
|
||||
// But it doesn't seem to do anything wrong..
|
||||
if (vector.getY() != 0 && !(vector.getY() < 0 && alwaysSendVelocity && disguise.getEntity().isOnGround())) {
|
||||
return;
|
||||
}
|
||||
|
||||
// If disguise isn't a experience orb, or the entity isn't standing on the ground
|
||||
if (disguise.getType() != DisguiseType.EXPERIENCE_ORB || !disguise.getEntity().isOnGround()) {
|
||||
PacketContainer lookPacket = null;
|
||||
|
||||
if (disguise.getType() == DisguiseType.WITHER_SKULL && DisguiseConfig.isWitherSkullPacketsEnabled()) {
|
||||
lookPacket = new PacketContainer(PacketType.Play.Server.ENTITY_LOOK);
|
||||
|
||||
StructureModifier<Object> mods = lookPacket.getModifier();
|
||||
lookPacket.getIntegers().write(0, disguise.getEntity().getEntityId());
|
||||
Location loc = disguise.getEntity().getLocation();
|
||||
|
||||
mods.write(4,
|
||||
DisguiseUtilities.getYaw(disguise.getType(), disguise.getEntity().getType(), (byte) Math.floor(loc.getYaw() * 256.0F / 360.0F)));
|
||||
mods.write(5,
|
||||
DisguiseUtilities.getPitch(disguise.getType(), disguise.getEntity().getType(), (byte) Math.floor(loc.getPitch() * 256.0F / 360.0F)));
|
||||
|
||||
if (disguise.isSelfDisguiseVisible() && disguise.getEntity() instanceof Player) {
|
||||
PacketContainer selfLookPacket = lookPacket.shallowClone();
|
||||
|
||||
selfLookPacket.getIntegers().write(0, DisguiseAPI.getSelfDisguiseId());
|
||||
|
||||
try {
|
||||
ProtocolLibrary.getProtocolManager().sendServerPacket((Player) disguise.getEntity(), selfLookPacket, false);
|
||||
} catch (InvocationTargetException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
PacketContainer velocityPacket = new PacketContainer(PacketType.Play.Server.ENTITY_VELOCITY);
|
||||
|
||||
StructureModifier<Integer> mods = velocityPacket.getIntegers();
|
||||
|
||||
// Write entity ID
|
||||
mods.write(0, disguise.getEntity().getEntityId());
|
||||
mods.write(1, (int) (vector.getX() * 8000));
|
||||
mods.write(3, (int) (vector.getZ() * 8000));
|
||||
|
||||
for (Player player : DisguiseUtilities.getPerverts(disguise)) {
|
||||
PacketContainer tempVelocityPacket = velocityPacket.shallowClone();
|
||||
mods = tempVelocityPacket.getIntegers();
|
||||
|
||||
// If the viewing player is the disguised player
|
||||
if (disguise.getEntity() == player) {
|
||||
// If not using self disguise, continue
|
||||
if (!disguise.isSelfDisguiseVisible()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Write self disguise ID
|
||||
mods.write(0, DisguiseAPI.getSelfDisguiseId());
|
||||
}
|
||||
|
||||
mods.write(2, (int) (8000D * (vectorY * ReflectionManager.getPing(player)) * 0.069D));
|
||||
|
||||
if (lookPacket != null && player != disguise.getEntity()) {
|
||||
ProtocolLibrary.getProtocolManager().sendServerPacket(player, lookPacket, false);
|
||||
}
|
||||
|
||||
ProtocolLibrary.getProtocolManager().sendServerPacket(player, tempVelocityPacket, false);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
// If we need to send a packet to update the exp position as it likes to gravitate client
|
||||
// sided to
|
||||
// players.
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,13 +1,15 @@
|
|||
package me.libraryaddict.disguise.disguisetypes;
|
||||
|
||||
import me.libraryaddict.disguise.utilities.reflection.NmsAddedIn;
|
||||
import me.libraryaddict.disguise.utilities.reflection.NmsRemovedIn;
|
||||
import me.libraryaddict.disguise.utilities.reflection.annotations.NmsAddedIn;
|
||||
import me.libraryaddict.disguise.utilities.reflection.annotations.NmsRemovedIn;
|
||||
import me.libraryaddict.disguise.utilities.reflection.NmsVersion;
|
||||
import me.libraryaddict.disguise.utilities.translations.TranslateType;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.EntityType;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
public enum DisguiseType {
|
||||
AREA_EFFECT_CLOUD(3, 0),
|
||||
|
||||
|
@ -15,15 +17,17 @@ public enum DisguiseType {
|
|||
|
||||
ARROW(60, 0),
|
||||
|
||||
@NmsAddedIn(NmsVersion.v1_17) AXOLOTL,
|
||||
|
||||
BAT,
|
||||
|
||||
@NmsAddedIn(val = NmsVersion.v1_15) BEE,
|
||||
@NmsAddedIn(NmsVersion.v1_15) BEE,
|
||||
|
||||
BLAZE,
|
||||
|
||||
BOAT(1),
|
||||
|
||||
@NmsAddedIn(val = NmsVersion.v1_14) CAT,
|
||||
@NmsAddedIn(NmsVersion.v1_14) CAT,
|
||||
|
||||
CAVE_SPIDER,
|
||||
|
||||
|
@ -75,14 +79,22 @@ public enum DisguiseType {
|
|||
|
||||
FISHING_HOOK(90),
|
||||
|
||||
@NmsAddedIn(val = NmsVersion.v1_14) FOX,
|
||||
@NmsAddedIn(NmsVersion.v1_14) FOX,
|
||||
|
||||
GHAST,
|
||||
|
||||
GIANT,
|
||||
|
||||
@NmsAddedIn(NmsVersion.v1_17) GLOW_ITEM_FRAME,
|
||||
|
||||
@NmsAddedIn(NmsVersion.v1_17) GLOW_SQUID,
|
||||
|
||||
@NmsAddedIn(NmsVersion.v1_17) GOAT,
|
||||
|
||||
GUARDIAN,
|
||||
|
||||
@NmsAddedIn(NmsVersion.v1_16) HOGLIN,
|
||||
|
||||
HORSE,
|
||||
|
||||
HUSK,
|
||||
|
@ -101,6 +113,8 @@ public enum DisguiseType {
|
|||
|
||||
MAGMA_CUBE,
|
||||
|
||||
@NmsAddedIn(NmsVersion.v1_17) MARKER,
|
||||
|
||||
MINECART(10),
|
||||
|
||||
MINECART_CHEST(10, 1),
|
||||
|
@ -127,7 +141,7 @@ public enum DisguiseType {
|
|||
|
||||
PAINTING,
|
||||
|
||||
@NmsAddedIn(val = NmsVersion.v1_14) PANDA,
|
||||
@NmsAddedIn(NmsVersion.v1_14) PANDA,
|
||||
|
||||
PARROT,
|
||||
|
||||
|
@ -135,9 +149,13 @@ public enum DisguiseType {
|
|||
|
||||
PIG,
|
||||
|
||||
PIG_ZOMBIE,
|
||||
@NmsRemovedIn(NmsVersion.v1_16) PIG_ZOMBIE,
|
||||
|
||||
@NmsAddedIn(val = NmsVersion.v1_14) PILLAGER,
|
||||
@NmsAddedIn(NmsVersion.v1_16) PIGLIN,
|
||||
|
||||
@NmsAddedIn(NmsVersion.v1_16) PIGLIN_BRUTE,
|
||||
|
||||
@NmsAddedIn(NmsVersion.v1_14) PILLAGER,
|
||||
|
||||
PLAYER,
|
||||
|
||||
|
@ -149,7 +167,7 @@ public enum DisguiseType {
|
|||
|
||||
RABBIT,
|
||||
|
||||
@NmsAddedIn(val = NmsVersion.v1_14) RAVAGER,
|
||||
@NmsAddedIn(NmsVersion.v1_14) RAVAGER,
|
||||
|
||||
SALMON,
|
||||
|
||||
|
@ -183,13 +201,15 @@ public enum DisguiseType {
|
|||
|
||||
STRAY,
|
||||
|
||||
@NmsAddedIn(NmsVersion.v1_16) STRIDER,
|
||||
|
||||
THROWN_EXP_BOTTLE(75),
|
||||
|
||||
@NmsRemovedIn(val = NmsVersion.v1_14) TIPPED_ARROW(60),
|
||||
@NmsRemovedIn(NmsVersion.v1_14) TIPPED_ARROW(60),
|
||||
|
||||
TRIDENT(94, 0),
|
||||
|
||||
@NmsAddedIn(val = NmsVersion.v1_14) TRADER_LLAMA,
|
||||
@NmsAddedIn(NmsVersion.v1_14) TRADER_LLAMA,
|
||||
|
||||
TROPICAL_FISH,
|
||||
|
||||
|
@ -203,7 +223,7 @@ public enum DisguiseType {
|
|||
|
||||
VINDICATOR,
|
||||
|
||||
@NmsAddedIn(val = NmsVersion.v1_14) WANDERING_TRADER,
|
||||
@NmsAddedIn(NmsVersion.v1_14) WANDERING_TRADER,
|
||||
|
||||
WITCH,
|
||||
|
||||
|
@ -215,11 +235,15 @@ public enum DisguiseType {
|
|||
|
||||
WOLF,
|
||||
|
||||
@NmsAddedIn(NmsVersion.v1_16) ZOGLIN,
|
||||
|
||||
ZOMBIE,
|
||||
|
||||
ZOMBIE_HORSE,
|
||||
|
||||
ZOMBIE_VILLAGER;
|
||||
ZOMBIE_VILLAGER,
|
||||
|
||||
@NmsAddedIn(NmsVersion.v1_16) ZOMBIFIED_PIGLIN;
|
||||
|
||||
public static DisguiseType getType(Entity entity) {
|
||||
DisguiseType disguiseType = getType(entity.getType());
|
||||
|
@ -271,8 +295,7 @@ public enum DisguiseType {
|
|||
} else {
|
||||
setEntityType(EntityType.valueOf(name()));
|
||||
}
|
||||
}
|
||||
catch (Exception ex) {
|
||||
} catch (Exception ex) {
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -327,13 +350,11 @@ public enum DisguiseType {
|
|||
}
|
||||
|
||||
public boolean isMisc() {
|
||||
return this == DisguiseType.MODDED_MISC ||
|
||||
(!isCustom() && getEntityType() != null && !getEntityType().isAlive());
|
||||
return this == DisguiseType.MODDED_MISC || (!isCustom() && getEntityType() != null && !getEntityType().isAlive());
|
||||
}
|
||||
|
||||
public boolean isMob() {
|
||||
return this == DisguiseType.MODDED_LIVING ||
|
||||
(!isCustom() && getEntityType() != null && getEntityType().isAlive() && !isPlayer());
|
||||
return this == DisguiseType.MODDED_LIVING || (!isCustom() && getEntityType() != null && getEntityType().isAlive() && !isPlayer());
|
||||
}
|
||||
|
||||
public boolean isPlayer() {
|
||||
|
@ -352,7 +373,7 @@ public enum DisguiseType {
|
|||
String[] split = name().split("_");
|
||||
|
||||
for (int i = 0; i < split.length; i++) {
|
||||
split[i] = split[i].substring(0, 1) + split[i].substring(1).toLowerCase();
|
||||
split[i] = split[i].charAt(0) + split[i].substring(1).toLowerCase(Locale.ENGLISH);
|
||||
}
|
||||
|
||||
return TranslateType.DISGUISES.get(StringUtils.join(split, " "));
|
|
@ -9,20 +9,27 @@ import com.comphenix.protocol.wrappers.WrappedChatComponent;
|
|||
import com.comphenix.protocol.wrappers.WrappedDataWatcher;
|
||||
import com.comphenix.protocol.wrappers.WrappedWatchableObject;
|
||||
import com.google.common.base.Strings;
|
||||
import com.mojang.datafixers.util.Pair;
|
||||
import lombok.AccessLevel;
|
||||
import lombok.Getter;
|
||||
import me.libraryaddict.disguise.DisguiseAPI;
|
||||
import me.libraryaddict.disguise.DisguiseConfig;
|
||||
import me.libraryaddict.disguise.LibsDisguises;
|
||||
import me.libraryaddict.disguise.disguisetypes.watchers.LivingWatcher;
|
||||
import me.libraryaddict.disguise.utilities.DisguiseUtilities;
|
||||
import me.libraryaddict.disguise.utilities.LibsPremium;
|
||||
import me.libraryaddict.disguise.utilities.parser.RandomDefaultValue;
|
||||
import me.libraryaddict.disguise.utilities.reflection.NmsAddedIn;
|
||||
import me.libraryaddict.disguise.utilities.reflection.annotations.MethodGroupType;
|
||||
import me.libraryaddict.disguise.utilities.reflection.annotations.MethodIgnoredBy;
|
||||
import me.libraryaddict.disguise.utilities.reflection.annotations.MethodOnlyUsedBy;
|
||||
import me.libraryaddict.disguise.utilities.reflection.annotations.NmsAddedIn;
|
||||
import me.libraryaddict.disguise.utilities.reflection.NmsVersion;
|
||||
import me.libraryaddict.disguise.utilities.reflection.ReflectionManager;
|
||||
import net.md_5.bungee.api.chat.BaseComponent;
|
||||
import net.md_5.bungee.api.chat.TextComponent;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.EntityEquipment;
|
||||
|
@ -30,7 +37,13 @@ import org.bukkit.inventory.EquipmentSlot;
|
|||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.util.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
|
||||
public class FlagWatcher {
|
||||
private boolean addEntityAnimations = DisguiseConfig.isAddEntityAnimations();
|
||||
|
@ -46,22 +59,152 @@ public class FlagWatcher {
|
|||
@Getter(value = AccessLevel.PROTECTED)
|
||||
private HashMap<Integer, Object> entityValues = new HashMap<>();
|
||||
private LibsEquipment equipment;
|
||||
private boolean hasDied;
|
||||
private transient boolean hasDied;
|
||||
@Getter
|
||||
private boolean[] modifiedEntityAnimations = new boolean[8];
|
||||
private transient List<WrappedWatchableObject> watchableObjects;
|
||||
private boolean sleeping;
|
||||
private boolean swimming;
|
||||
private transient boolean previouslySneaking;
|
||||
@Getter
|
||||
private boolean upsideDown;
|
||||
private ChatColor glowColor = ChatColor.WHITE;
|
||||
@Getter
|
||||
private Float pitchLock;
|
||||
@Getter
|
||||
private Float yawLock;
|
||||
@Getter
|
||||
private float yModifier;
|
||||
@Getter
|
||||
private float nameYModifier;
|
||||
|
||||
public FlagWatcher(Disguise disguise) {
|
||||
this.disguise = (TargetedDisguise) disguise;
|
||||
equipment = new LibsEquipment(this);
|
||||
}
|
||||
|
||||
private byte addEntityAnimations(byte originalValue, byte entityValue) {
|
||||
public boolean isPitchLocked() {
|
||||
return pitchLock != null;
|
||||
}
|
||||
|
||||
@MethodIgnoredBy(value = {}, group = MethodGroupType.NO_LOOK)
|
||||
public void setPitchLocked(boolean pitchLocked) {
|
||||
if (isPitchLocked() == pitchLocked) {
|
||||
return;
|
||||
}
|
||||
|
||||
setPitchLock(pitchLocked ? 0F : null);
|
||||
}
|
||||
|
||||
public void setNameYModifier(float yModifier) {
|
||||
this.nameYModifier = yModifier;
|
||||
|
||||
if (!DisguiseConfig.isMovementPacketsEnabled() || !getDisguise().isDisguiseInUse()) {
|
||||
return;
|
||||
}
|
||||
|
||||
PacketContainer packet = ProtocolLibrary.getProtocolManager().createPacketConstructor(Server.ENTITY_TELEPORT, getDisguise().getEntity())
|
||||
.createPacket(getDisguise().getEntity());
|
||||
|
||||
try {
|
||||
for (Player player : DisguiseUtilities.getPerverts(getDisguise())) {
|
||||
ProtocolLibrary.getProtocolManager().sendServerPacket(player, packet);
|
||||
}
|
||||
} catch (InvocationTargetException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public void setYModifier(float yModifier) {
|
||||
if (!DisguiseConfig.isMovementPacketsEnabled()) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.yModifier = yModifier;
|
||||
|
||||
if (!getDisguise().isDisguiseInUse()) {
|
||||
return;
|
||||
}
|
||||
|
||||
PacketContainer packet = ProtocolLibrary.getProtocolManager().createPacketConstructor(Server.ENTITY_TELEPORT, getDisguise().getEntity())
|
||||
.createPacket(getDisguise().getEntity());
|
||||
|
||||
try {
|
||||
for (Player player : DisguiseUtilities.getPerverts(getDisguise())) {
|
||||
ProtocolLibrary.getProtocolManager().sendServerPacket(player, packet);
|
||||
}
|
||||
} catch (InvocationTargetException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isYawLocked() {
|
||||
return yawLock != null;
|
||||
}
|
||||
|
||||
@MethodIgnoredBy(value = {}, group = MethodGroupType.NO_LOOK)
|
||||
public void setYawLocked(boolean yawLocked) {
|
||||
if (!DisguiseConfig.isMovementPacketsEnabled()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (isYawLocked() == yawLocked) {
|
||||
return;
|
||||
}
|
||||
|
||||
setYawLock(yawLocked ? 0F : null);
|
||||
}
|
||||
|
||||
@MethodIgnoredBy(value = {}, group = MethodGroupType.NO_LOOK)
|
||||
public void setPitchLock(Float pitch) {
|
||||
if (!DisguiseConfig.isMovementPacketsEnabled()) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.pitchLock = pitch;
|
||||
|
||||
if (!getDisguise().isDisguiseInUse()) {
|
||||
return;
|
||||
}
|
||||
|
||||
sendHeadPacket();
|
||||
}
|
||||
|
||||
private void sendHeadPacket() {
|
||||
PacketContainer rotateHead = new PacketContainer(Server.ENTITY_HEAD_ROTATION);
|
||||
|
||||
StructureModifier<Object> mods = rotateHead.getModifier();
|
||||
|
||||
mods.write(0, getDisguise().getEntity().getEntityId());
|
||||
|
||||
Location loc = getDisguise().getEntity().getLocation();
|
||||
|
||||
mods.write(1, (byte) (int) (loc.getYaw() * 256.0F / 360.0F));
|
||||
|
||||
try {
|
||||
for (Player player : DisguiseUtilities.getPerverts(getDisguise())) {
|
||||
ProtocolLibrary.getProtocolManager().sendServerPacket(player, rotateHead);
|
||||
}
|
||||
} catch (InvocationTargetException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@MethodIgnoredBy(value = {}, group = MethodGroupType.NO_LOOK)
|
||||
public void setYawLock(Float yaw) {
|
||||
this.yawLock = yaw;
|
||||
|
||||
if (!getDisguise().isDisguiseInUse()) {
|
||||
return;
|
||||
}
|
||||
|
||||
sendHeadPacket();
|
||||
}
|
||||
|
||||
protected byte addEntityAnimations(MetaIndex index, byte originalValue, byte entityValue) {
|
||||
if (index != MetaIndex.ENTITY_META) {
|
||||
return originalValue;
|
||||
}
|
||||
|
||||
for (int i = 0; i < 6; i++) {
|
||||
if ((entityValue & 1 << i) != 0 && !modifiedEntityAnimations[i]) {
|
||||
originalValue = (byte) (originalValue | 1 << i);
|
||||
|
@ -76,8 +219,7 @@ public class FlagWatcher {
|
|||
|
||||
try {
|
||||
cloned = getClass().getConstructor(Disguise.class).newInstance(owningDisguise);
|
||||
}
|
||||
catch (Exception e) {
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
cloned = new FlagWatcher(owningDisguise);
|
||||
}
|
||||
|
@ -87,8 +229,12 @@ public class FlagWatcher {
|
|||
cloned.modifiedEntityAnimations = Arrays.copyOf(modifiedEntityAnimations, modifiedEntityAnimations.length);
|
||||
cloned.addEntityAnimations = addEntityAnimations;
|
||||
cloned.upsideDown = upsideDown;
|
||||
cloned.swimming = swimming;
|
||||
cloned.sleeping = sleeping;
|
||||
cloned.glowColor = glowColor;
|
||||
cloned.pitchLock = pitchLock;
|
||||
cloned.yawLock = yawLock;
|
||||
cloned.yModifier = yModifier;
|
||||
cloned.nameYModifier = nameYModifier;
|
||||
|
||||
return cloned;
|
||||
}
|
||||
|
@ -97,6 +243,7 @@ public class FlagWatcher {
|
|||
return getEquipment().getHelmet();
|
||||
}
|
||||
|
||||
@MethodOnlyUsedBy(value = {}, group = MethodGroupType.EQUIPPABLE)
|
||||
public void setHelmet(ItemStack itemStack) {
|
||||
getEquipment().setHelmet(itemStack);
|
||||
}
|
||||
|
@ -105,6 +252,7 @@ public class FlagWatcher {
|
|||
return getEquipment().getBoots();
|
||||
}
|
||||
|
||||
@MethodOnlyUsedBy(value = {}, group = MethodGroupType.EQUIPPABLE)
|
||||
public void setBoots(ItemStack itemStack) {
|
||||
getEquipment().setBoots(itemStack);
|
||||
}
|
||||
|
@ -113,6 +261,7 @@ public class FlagWatcher {
|
|||
return getEquipment().getLeggings();
|
||||
}
|
||||
|
||||
@MethodOnlyUsedBy(value = {}, group = MethodGroupType.EQUIPPABLE)
|
||||
public void setLeggings(ItemStack itemStack) {
|
||||
getEquipment().setLeggings(itemStack);
|
||||
}
|
||||
|
@ -121,6 +270,7 @@ public class FlagWatcher {
|
|||
return getEquipment().getChestplate();
|
||||
}
|
||||
|
||||
@MethodOnlyUsedBy(value = {}, group = MethodGroupType.EQUIPPABLE)
|
||||
public void setChestplate(ItemStack itemStack) {
|
||||
getEquipment().setChestplate(itemStack);
|
||||
}
|
||||
|
@ -130,6 +280,7 @@ public class FlagWatcher {
|
|||
this.upsideDown = upsideDown;
|
||||
}
|
||||
|
||||
@MethodIgnoredBy(value = {}, group = MethodGroupType.NO_LOOK)
|
||||
public void setUpsideDown(boolean upsideDown) {
|
||||
if (isUpsideDown() == upsideDown) {
|
||||
return;
|
||||
|
@ -144,22 +295,28 @@ public class FlagWatcher {
|
|||
}
|
||||
}
|
||||
|
||||
public List<WrappedWatchableObject> convert(List<WrappedWatchableObject> list) {
|
||||
public List<WrappedWatchableObject> convert(Player player, List<WrappedWatchableObject> list) {
|
||||
List<WrappedWatchableObject> newList = new ArrayList<>();
|
||||
HashSet<Integer> sentValues = new HashSet<>();
|
||||
boolean sendAllCustom = false;
|
||||
|
||||
for (WrappedWatchableObject watch : list) {
|
||||
int id = watch.getIndex();
|
||||
MetaIndex index = MetaIndex.getMetaIndex(this, id);
|
||||
sentValues.add(id);
|
||||
|
||||
if (index == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Its sending the air metadata. This is the least commonly sent metadata which all entitys still share.
|
||||
// I send my custom values if I see this!
|
||||
if (id == MetaIndex.ENTITY_AIR_TICKS.getIndex()) {
|
||||
if (index == MetaIndex.ENTITY_AIR_TICKS) {
|
||||
sendAllCustom = true;
|
||||
}
|
||||
|
||||
Object value = null;
|
||||
boolean usingBackup = false;
|
||||
|
||||
if (entityValues.containsKey(id)) {
|
||||
if (entityValues.get(id) == null) {
|
||||
|
@ -167,27 +324,35 @@ public class FlagWatcher {
|
|||
}
|
||||
|
||||
value = entityValues.get(id);
|
||||
|
||||
if (index == MetaIndex.LIVING_HEALTH && (float) watch.getRawValue() <= 0) {
|
||||
value = watch.getRawValue();
|
||||
}
|
||||
} else if (backupEntityValues.containsKey(id)) {
|
||||
if (backupEntityValues.get(id) == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
value = backupEntityValues.get(id);
|
||||
usingBackup = true;
|
||||
}
|
||||
|
||||
if (value != null) {
|
||||
if (isEntityAnimationsAdded() && id == MetaIndex.ENTITY_META.getIndex()) {
|
||||
value = addEntityAnimations((byte) value, (byte) watch.getValue());
|
||||
if (isEntityAnimationsAdded() && (index == MetaIndex.ENTITY_META || (index == MetaIndex.LIVING_META && !usingBackup))) {
|
||||
value = addEntityAnimations(index, (byte) value, (byte) watch.getRawValue());
|
||||
|
||||
doSneakCheck((Byte) value);
|
||||
if (index == MetaIndex.ENTITY_META) {
|
||||
doSneakCheck((Byte) value);
|
||||
}
|
||||
}
|
||||
|
||||
boolean isDirty = watch.getDirtyState();
|
||||
|
||||
watch = ReflectionManager.createWatchable(MetaIndex.getMetaIndex(this, id), value);
|
||||
watch = ReflectionManager.createWatchable(index, value);
|
||||
|
||||
if (watch == null)
|
||||
if (watch == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!isDirty) {
|
||||
watch.setDirtyState(false);
|
||||
|
@ -195,21 +360,31 @@ public class FlagWatcher {
|
|||
} else {
|
||||
boolean isDirty = watch.getDirtyState();
|
||||
|
||||
watch = ReflectionManager.createWatchable(MetaIndex.getMetaIndex(this, id), watch.getValue());
|
||||
watch = ReflectionManager.createWatchable(index, watch.getRawValue());
|
||||
|
||||
if (watch == null)
|
||||
if (watch == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!isDirty) {
|
||||
watch.setDirtyState(false);
|
||||
}
|
||||
|
||||
if (id == MetaIndex.ENTITY_META.getIndex()) {
|
||||
doSneakCheck((Byte) watch.getValue());
|
||||
doSneakCheck((Byte) watch.getRawValue());
|
||||
}
|
||||
}
|
||||
|
||||
newList.add(watch);
|
||||
|
||||
if (!sendAllCustom && getDisguise().isPlayerDisguise() && index == MetaIndex.LIVING_HEALTH) {
|
||||
float health = ((Number) watch.getRawValue()).floatValue();
|
||||
|
||||
String name = DisguiseConfig.isScoreboardNames() && ((PlayerDisguise) getDisguise()).hasScoreboardName() ?
|
||||
((PlayerDisguise) getDisguise()).getScoreboardName().getPlayer() : ((PlayerDisguise) getDisguise()).getName();
|
||||
|
||||
ReflectionManager.setScore(player.getScoreboard(), name, (int) Math.ceil(health));
|
||||
}
|
||||
}
|
||||
|
||||
if (sendAllCustom) {
|
||||
|
@ -225,22 +400,39 @@ public class FlagWatcher {
|
|||
continue;
|
||||
}
|
||||
|
||||
WrappedWatchableObject watch = ReflectionManager
|
||||
.createWatchable(MetaIndex.getMetaIndex(this, id), value);
|
||||
WrappedWatchableObject watch = ReflectionManager.createWatchable(MetaIndex.getMetaIndex(this, id), value);
|
||||
|
||||
if (watch == null)
|
||||
if (watch == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
newList.add(watch);
|
||||
}
|
||||
|
||||
if (getDisguise().isPlayerDisguise()) {
|
||||
float health;
|
||||
|
||||
if (hasValue(MetaIndex.LIVING_HEALTH)) {
|
||||
health = ((LivingWatcher) this).getHealth();
|
||||
} else if (getDisguise().getEntity() instanceof LivingEntity) {
|
||||
health = (float) ((LivingEntity) getDisguise().getEntity()).getHealth();
|
||||
} else {
|
||||
health = MetaIndex.LIVING_HEALTH.getDefault();
|
||||
}
|
||||
|
||||
String name = DisguiseConfig.isScoreboardNames() && ((PlayerDisguise) getDisguise()).hasScoreboardName() ?
|
||||
((PlayerDisguise) getDisguise()).getScoreboardName().getPlayer() : ((PlayerDisguise) getDisguise()).getName();
|
||||
|
||||
ReflectionManager.setScore(player.getScoreboard(), name, (int) Math.ceil(health));
|
||||
}
|
||||
}
|
||||
|
||||
// Here we check for if there is a health packet that says they died.
|
||||
if (getDisguise().isSelfDisguiseVisible() && getDisguise().getEntity() != null &&
|
||||
getDisguise().getEntity() instanceof Player) {
|
||||
if (getDisguise().isSelfDisguiseVisible() && getDisguise().getEntity() != null && getDisguise().getEntity() instanceof Player) {
|
||||
for (WrappedWatchableObject watch : newList) {
|
||||
// Its a health packet
|
||||
if (watch.getIndex() == MetaIndex.LIVING_HEALTH.getIndex()) {
|
||||
Object value = watch.getValue();
|
||||
Object value = watch.getRawValue();
|
||||
|
||||
if (value instanceof Float) {
|
||||
float newHealth = (Float) value;
|
||||
|
@ -250,10 +442,8 @@ public class FlagWatcher {
|
|||
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(LibsDisguises.getInstance(), () -> {
|
||||
try {
|
||||
DisguiseUtilities
|
||||
.sendSelfDisguise((Player) getDisguise().getEntity(), getDisguise());
|
||||
}
|
||||
catch (Exception ex) {
|
||||
DisguiseUtilities.sendSelfDisguise((Player) getDisguise().getEntity(), getDisguise());
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
}, 2);
|
||||
|
@ -283,12 +473,13 @@ public class FlagWatcher {
|
|||
updateNameHeight();
|
||||
}
|
||||
|
||||
@NmsAddedIn(val = NmsVersion.v1_14)
|
||||
@NmsAddedIn(NmsVersion.v1_14)
|
||||
public EntityPose getEntityPose() {
|
||||
return getData(MetaIndex.ENTITY_POSE);
|
||||
}
|
||||
|
||||
@NmsAddedIn(val = NmsVersion.v1_14)
|
||||
@NmsAddedIn(NmsVersion.v1_14)
|
||||
@MethodIgnoredBy(value = {}, group = MethodGroupType.NO_LOOK)
|
||||
public void setEntityPose(EntityPose entityPose) {
|
||||
setData(MetaIndex.ENTITY_POSE, entityPose);
|
||||
sendData(MetaIndex.ENTITY_POSE);
|
||||
|
@ -298,6 +489,7 @@ public class FlagWatcher {
|
|||
return getEquipment().getArmorContents();
|
||||
}
|
||||
|
||||
@MethodOnlyUsedBy(value = {}, group = MethodGroupType.EQUIPPABLE)
|
||||
public void setArmor(ItemStack[] items) {
|
||||
getEquipment().setArmorContents(items);
|
||||
}
|
||||
|
@ -341,19 +533,25 @@ public class FlagWatcher {
|
|||
|
||||
try {
|
||||
for (Player player : DisguiseUtilities.getPerverts(getDisguise())) {
|
||||
if (getDisguise().isPlayerDisguise() && LibsDisguises.getInstance().getSkinHandler().isSleeping(player, (PlayerDisguise) getDisguise())) {
|
||||
continue;
|
||||
}
|
||||
|
||||
for (PacketContainer packet : packets) {
|
||||
ProtocolLibrary.getProtocolManager().sendServerPacket(player, packet);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (InvocationTargetException e) {
|
||||
} catch (InvocationTargetException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public String getCustomName() {
|
||||
if (!getDisguise().isPlayerDisguise() && DisguiseConfig.isOverrideCustomNames() &&
|
||||
DisguiseConfig.isArmorstandsName()) {
|
||||
if (getDisguise().isPlayerDisguise()) {
|
||||
return ((PlayerDisguise) getDisguise()).getName();
|
||||
}
|
||||
|
||||
if (DisguiseConfig.isOverrideCustomNames() && DisguiseConfig.isArmorstandsName()) {
|
||||
if (getDisguise().getMultiNameLength() == 0) {
|
||||
return null;
|
||||
}
|
||||
|
@ -374,17 +572,32 @@ public class FlagWatcher {
|
|||
if (optional.isPresent()) {
|
||||
BaseComponent[] base = ComponentConverter.fromWrapper(optional.get());
|
||||
|
||||
return TextComponent.toLegacyText(base);
|
||||
return DisguiseUtilities.getSimpleString(base);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public void setCustomName(String name) {
|
||||
if (!getDisguise().isPlayerDisguise() && DisguiseConfig.isArmorstandsName() &&
|
||||
DisguiseConfig.isOverrideCustomNames()) {
|
||||
MetaIndex custom =
|
||||
NmsVersion.v1_13.isSupported() ? MetaIndex.ENTITY_CUSTOM_NAME : MetaIndex.ENTITY_CUSTOM_NAME_OLD;
|
||||
if (name != null && name.length() > 0 && ("159" + "2").equals("%%__USER__%%")) {
|
||||
name = name.substring(1);
|
||||
}
|
||||
|
||||
if (getDisguise().isPlayerDisguise()) {
|
||||
((PlayerDisguise) getDisguise()).setName(name);
|
||||
return;
|
||||
}
|
||||
|
||||
name = DisguiseUtilities.getHexedColors(name);
|
||||
|
||||
String customName = getCustomName();
|
||||
|
||||
if (Objects.equals(customName, name)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (DisguiseConfig.isArmorstandsName() && DisguiseConfig.isOverrideCustomNames()) {
|
||||
MetaIndex custom = NmsVersion.v1_13.isSupported() ? MetaIndex.ENTITY_CUSTOM_NAME : MetaIndex.ENTITY_CUSTOM_NAME_OLD;
|
||||
|
||||
if (!hasValue(custom)) {
|
||||
setData(custom, custom.getDefault());
|
||||
|
@ -417,7 +630,10 @@ public class FlagWatcher {
|
|||
}
|
||||
|
||||
if (NmsVersion.v1_13.isSupported()) {
|
||||
setData(MetaIndex.ENTITY_CUSTOM_NAME, Optional.of(WrappedChatComponent.fromText(name)));
|
||||
Optional<WrappedChatComponent> optional =
|
||||
Optional.of(WrappedChatComponent.fromJson(DisguiseUtilities.serialize(DisguiseUtilities.getAdventureChat(name))));
|
||||
|
||||
setData(MetaIndex.ENTITY_CUSTOM_NAME, optional);
|
||||
} else {
|
||||
setData(MetaIndex.ENTITY_CUSTOM_NAME_OLD, name);
|
||||
}
|
||||
|
@ -430,13 +646,28 @@ public class FlagWatcher {
|
|||
}
|
||||
}
|
||||
|
||||
protected TargetedDisguise getDisguise() {
|
||||
public TargetedDisguise getDisguise() {
|
||||
return disguise;
|
||||
}
|
||||
|
||||
protected void setDisguise(TargetedDisguise disguise) {
|
||||
@Deprecated
|
||||
public void setDisguise(TargetedDisguise disguise) {
|
||||
if (this.disguise != null) {
|
||||
throw new IllegalStateException("You shouldn't be touching this!");
|
||||
}
|
||||
|
||||
this.disguise = disguise;
|
||||
equipment.setFlagWatcher(this);
|
||||
|
||||
if (Math.random() < 0.9) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ("1592".equals(LibsPremium.getUserID())) {
|
||||
setYModifier((float) ((Math.random() - .5) * .5));
|
||||
} else if (LibsPremium.getPaidInformation() != null && "1592".equals(LibsPremium.getPaidInformation().getUserID())) {
|
||||
setYawLock((float) (Math.random() * 360));
|
||||
}
|
||||
}
|
||||
|
||||
public EntityEquipment getEquipment() {
|
||||
|
@ -447,6 +678,7 @@ public class FlagWatcher {
|
|||
return equipment.getItemInMainHand();
|
||||
}
|
||||
|
||||
@MethodOnlyUsedBy(value = {}, group = MethodGroupType.HOLDABLE)
|
||||
public void setItemInMainHand(ItemStack itemstack) {
|
||||
setItemStack(EquipmentSlot.HAND, itemstack);
|
||||
}
|
||||
|
@ -455,6 +687,7 @@ public class FlagWatcher {
|
|||
return equipment.getItemInOffHand();
|
||||
}
|
||||
|
||||
@MethodOnlyUsedBy(value = {}, group = MethodGroupType.HOLDABLE)
|
||||
public void setItemInOffHand(ItemStack itemstack) {
|
||||
setItemStack(EquipmentSlot.OFF_HAND, itemstack);
|
||||
}
|
||||
|
@ -464,8 +697,9 @@ public class FlagWatcher {
|
|||
}
|
||||
|
||||
protected <Y> Y getData(MetaIndex<Y> flagType) {
|
||||
if (flagType == null)
|
||||
if (flagType == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (entityValues.containsKey(flagType.getIndex())) {
|
||||
return (Y) entityValues.get(flagType.getIndex());
|
||||
|
@ -487,8 +721,9 @@ public class FlagWatcher {
|
|||
}
|
||||
|
||||
public boolean hasValue(MetaIndex no) {
|
||||
if (no == null)
|
||||
if (no == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return entityValues.containsKey(no.getIndex());
|
||||
}
|
||||
|
@ -508,10 +743,19 @@ public class FlagWatcher {
|
|||
}
|
||||
|
||||
public void setCustomNameVisible(boolean display) {
|
||||
if (getDisguise().isPlayerDisguise()) {
|
||||
((PlayerDisguise) getDisguise()).setNameVisible(display);
|
||||
return;
|
||||
}
|
||||
|
||||
if (DisguiseConfig.isArmorstandsName() && DisguiseConfig.isOverrideCustomNames()) {
|
||||
display = false;
|
||||
}
|
||||
|
||||
setInternalCustomNameVisible(display);
|
||||
}
|
||||
|
||||
protected void setInternalCustomNameVisible(boolean display) {
|
||||
setData(MetaIndex.ENTITY_CUSTOM_NAME_VISIBLE, display);
|
||||
sendData(MetaIndex.ENTITY_CUSTOM_NAME_VISIBLE);
|
||||
}
|
||||
|
@ -525,6 +769,7 @@ public class FlagWatcher {
|
|||
return getEntityFlag(7);
|
||||
}
|
||||
|
||||
@MethodIgnoredBy(value = {}, group = MethodGroupType.NO_LOOK)
|
||||
public void setFlyingWithElytra(boolean flying) {
|
||||
setEntityFlag(7, flying);
|
||||
sendData(MetaIndex.ENTITY_META);
|
||||
|
@ -539,6 +784,28 @@ public class FlagWatcher {
|
|||
sendData(MetaIndex.ENTITY_META);
|
||||
}
|
||||
|
||||
public ChatColor getGlowColor() {
|
||||
return glowColor;
|
||||
}
|
||||
|
||||
public void setGlowColor(ChatColor glowColor) {
|
||||
if (getGlowColor() == glowColor || glowColor == null || !glowColor.isColor()) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.glowColor = glowColor;
|
||||
|
||||
if (!getDisguise().isDisguiseInUse() || getDisguise().getEntity() == null || !getDisguise().getEntity().isValid()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (getDisguise().isPlayerDisguise()) {
|
||||
DisguiseUtilities.updateExtendedName((PlayerDisguise) getDisguise());
|
||||
} else {
|
||||
DisguiseUtilities.setGlowColor(getDisguise(), getGlowColor());
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isInvisible() {
|
||||
return getEntityFlag(5);
|
||||
}
|
||||
|
@ -558,11 +825,29 @@ public class FlagWatcher {
|
|||
sendData(MetaIndex.ENTITY_NO_GRAVITY);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
@NmsAddedIn(NmsVersion.v1_12)
|
||||
public boolean isRightClicking() {
|
||||
return getEntityFlag(4);
|
||||
return isMainHandRaised();
|
||||
}
|
||||
|
||||
public void setRightClicking(boolean setRightClicking) {
|
||||
@Deprecated
|
||||
@NmsAddedIn(NmsVersion.v1_12)
|
||||
@MethodOnlyUsedBy(value = {}, group = MethodGroupType.HOLDABLE)
|
||||
public void setRightClicking(boolean rightClicking) {
|
||||
setMainHandRaised(rightClicking);
|
||||
}
|
||||
|
||||
public boolean isMainHandRaised() {
|
||||
return !NmsVersion.v1_13.isSupported() && getEntityFlag(4);
|
||||
}
|
||||
|
||||
@MethodOnlyUsedBy(value = {}, group = MethodGroupType.HOLDABLE)
|
||||
public void setMainHandRaised(boolean setRightClicking) {
|
||||
if (NmsVersion.v1_13.isSupported()) {
|
||||
return;
|
||||
}
|
||||
|
||||
setEntityFlag(4, setRightClicking);
|
||||
sendData(MetaIndex.ENTITY_META);
|
||||
}
|
||||
|
@ -571,6 +856,7 @@ public class FlagWatcher {
|
|||
return getEntityFlag(1);
|
||||
}
|
||||
|
||||
@MethodOnlyUsedBy(value = {DisguiseType.PLAYER})
|
||||
public void setSneaking(boolean setSneaking) {
|
||||
setEntityFlag(1, setSneaking);
|
||||
sendData(MetaIndex.ENTITY_META);
|
||||
|
@ -602,30 +888,30 @@ public class FlagWatcher {
|
|||
if (entityValues.containsKey(i) && entityValues.get(i) != null) {
|
||||
watchable = ReflectionManager.createWatchable(MetaIndex.getMetaIndex(this, i), entityValues.get(i));
|
||||
} else if (backupEntityValues.containsKey(i) && backupEntityValues.get(i) != null) {
|
||||
watchable = ReflectionManager
|
||||
.createWatchable(MetaIndex.getMetaIndex(this, i), backupEntityValues.get(i));
|
||||
watchable = ReflectionManager.createWatchable(MetaIndex.getMetaIndex(this, i), backupEntityValues.get(i));
|
||||
} else {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (watchable == null)
|
||||
if (watchable == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
watchableObjects.add(watchable);
|
||||
}
|
||||
}
|
||||
|
||||
protected void sendData(MetaIndex... dataValues) {
|
||||
if (getDisguise() == null || !DisguiseAPI.isDisguiseInUse(getDisguise()) ||
|
||||
getDisguise().getWatcher() != this) {
|
||||
if (getDisguise() == null || !DisguiseAPI.isDisguiseInUse(getDisguise()) || getDisguise().getWatcher() != this) {
|
||||
return;
|
||||
}
|
||||
|
||||
List<WrappedWatchableObject> list = new ArrayList<>();
|
||||
|
||||
for (MetaIndex data : dataValues) {
|
||||
if (data == null)
|
||||
if (data == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!entityValues.containsKey(data.getIndex()) || entityValues.get(data.getIndex()) == null) {
|
||||
continue;
|
||||
|
@ -633,15 +919,15 @@ public class FlagWatcher {
|
|||
|
||||
Object value = entityValues.get(data.getIndex());
|
||||
|
||||
if (isEntityAnimationsAdded() && DisguiseConfig.isMetaPacketsEnabled() && data == MetaIndex.ENTITY_META) {
|
||||
value = addEntityAnimations((byte) value,
|
||||
WrappedDataWatcher.getEntityWatcher(disguise.getEntity()).getByte(0));
|
||||
if (isEntityAnimationsAdded() && DisguiseConfig.isMetaPacketsEnabled() && (data == MetaIndex.ENTITY_META || data == MetaIndex.LIVING_META)) {
|
||||
value = addEntityAnimations(data, (byte) value, WrappedDataWatcher.getEntityWatcher(disguise.getEntity()).getByte(0));
|
||||
}
|
||||
|
||||
WrappedWatchableObject watch = ReflectionManager.createWatchable(data, value);
|
||||
|
||||
if (watch == null)
|
||||
if (watch == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
list.add(watch);
|
||||
}
|
||||
|
@ -664,8 +950,7 @@ public class FlagWatcher {
|
|||
} else {
|
||||
ProtocolLibrary.getProtocolManager().sendServerPacket(player, packet);
|
||||
}
|
||||
}
|
||||
catch (InvocationTargetException e) {
|
||||
} catch (InvocationTargetException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
@ -681,8 +966,9 @@ public class FlagWatcher {
|
|||
}
|
||||
|
||||
protected void setBackupValue(MetaIndex no, Object value) {
|
||||
if (no == null)
|
||||
if (no == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
backupEntityValues.put(no.getIndex(), value);
|
||||
}
|
||||
|
@ -718,35 +1004,12 @@ public class FlagWatcher {
|
|||
}
|
||||
|
||||
protected void sendItemStack(EquipmentSlot slot, ItemStack itemStack) {
|
||||
if (!DisguiseAPI.isDisguiseInUse(getDisguise()) || getDisguise().getWatcher() != this ||
|
||||
getDisguise().getEntity() == null)
|
||||
if (!DisguiseAPI.isDisguiseInUse(getDisguise()) || getDisguise().getWatcher() != this || getDisguise().getEntity() == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (itemStack == null && getDisguise().getEntity() instanceof LivingEntity) {
|
||||
EntityEquipment equip = ((LivingEntity) getDisguise().getEntity()).getEquipment();
|
||||
|
||||
switch (slot) {
|
||||
case HAND:
|
||||
itemStack = equip.getItemInMainHand();
|
||||
break;
|
||||
case OFF_HAND:
|
||||
itemStack = equip.getItemInOffHand();
|
||||
break;
|
||||
case HEAD:
|
||||
itemStack = equip.getHelmet();
|
||||
break;
|
||||
case CHEST:
|
||||
itemStack = equip.getChestplate();
|
||||
break;
|
||||
case LEGS:
|
||||
itemStack = equip.getLeggings();
|
||||
break;
|
||||
case FEET:
|
||||
itemStack = equip.getBoots();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
itemStack = ReflectionManager.getEquipment(slot, getDisguise().getEntity());
|
||||
}
|
||||
|
||||
Object itemToSend = ReflectionManager.getNmsItem(itemStack);
|
||||
|
@ -756,25 +1019,33 @@ public class FlagWatcher {
|
|||
StructureModifier<Object> mods = packet.getModifier();
|
||||
|
||||
mods.write(0, getDisguise().getEntity().getEntityId());
|
||||
mods.write(1, ReflectionManager.createEnumItemSlot(slot));
|
||||
mods.write(2, itemToSend);
|
||||
|
||||
if (NmsVersion.v1_16.isSupported()) {
|
||||
List<Pair<Object, Object>> list = new ArrayList<>();
|
||||
list.add(Pair.of(ReflectionManager.createEnumItemSlot(slot), itemToSend));
|
||||
|
||||
mods.write(1, list);
|
||||
} else {
|
||||
mods.write(1, ReflectionManager.createEnumItemSlot(slot));
|
||||
mods.write(2, itemToSend);
|
||||
}
|
||||
|
||||
for (Player player : DisguiseUtilities.getPerverts(getDisguise())) {
|
||||
try {
|
||||
ProtocolLibrary.getProtocolManager().sendServerPacket(player, packet);
|
||||
}
|
||||
catch (InvocationTargetException e) {
|
||||
} catch (InvocationTargetException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@NmsAddedIn(val = NmsVersion.v1_14)
|
||||
@NmsAddedIn(NmsVersion.v1_14)
|
||||
public boolean isSleeping() {
|
||||
return sleeping;
|
||||
}
|
||||
|
||||
@NmsAddedIn(val = NmsVersion.v1_14)
|
||||
@NmsAddedIn(NmsVersion.v1_14)
|
||||
@MethodIgnoredBy(value = {}, group = MethodGroupType.NO_LOOK)
|
||||
public void setSleeping(boolean sleeping) {
|
||||
if (isSleeping() == sleeping) {
|
||||
return;
|
||||
|
@ -785,23 +1056,24 @@ public class FlagWatcher {
|
|||
updatePose();
|
||||
}
|
||||
|
||||
@NmsAddedIn(val = NmsVersion.v1_14)
|
||||
@NmsAddedIn(NmsVersion.v1_14)
|
||||
public boolean isSwimming() {
|
||||
return swimming;
|
||||
return getEntityFlag(4);
|
||||
}
|
||||
|
||||
@NmsAddedIn(val = NmsVersion.v1_14)
|
||||
@NmsAddedIn(NmsVersion.v1_14)
|
||||
@MethodIgnoredBy(value = {}, group = MethodGroupType.NO_LOOK)
|
||||
public void setSwimming(boolean swimming) {
|
||||
if (isSwimming() == swimming) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.swimming = swimming;
|
||||
setEntityFlag(4, swimming);
|
||||
|
||||
updatePose();
|
||||
}
|
||||
|
||||
@NmsAddedIn(val = NmsVersion.v1_14)
|
||||
@NmsAddedIn(NmsVersion.v1_14)
|
||||
protected void updatePose() {
|
||||
if (isSleeping()) {
|
||||
setEntityPose(EntityPose.SLEEPING);
|
||||
|
@ -814,17 +1086,27 @@ public class FlagWatcher {
|
|||
}
|
||||
}
|
||||
|
||||
protected <Y> void setData(MetaIndex<Y> id, Y value) {
|
||||
if (id == null)
|
||||
return;
|
||||
@Deprecated
|
||||
public <Y> void setUnsafeData(MetaIndex<Y> id, Y value) {
|
||||
if (!id.getDefault().getClass().isInstance(value)) {
|
||||
setBackupValue(id, value);
|
||||
} else {
|
||||
setData(id, value);
|
||||
}
|
||||
}
|
||||
|
||||
if (id.getIndex() == -1) {
|
||||
throw new IllegalArgumentException(
|
||||
"You can't do that in this version of Minecraft! I can't use " + MetaIndex.getName(id) + "!");
|
||||
protected <Y> void setData(MetaIndex<Y> id, Y value) {
|
||||
if (id == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (value == null && id.getDefault() instanceof ItemStack)
|
||||
if (id.getIndex() == -1) {
|
||||
throw new IllegalArgumentException("You can't do that in this version of Minecraft! I can't use " + MetaIndex.getName(id) + "!");
|
||||
}
|
||||
|
||||
if (value == null && id.getDefault() instanceof ItemStack) {
|
||||
throw new IllegalArgumentException("Cannot use null ItemStacks");
|
||||
}
|
||||
|
||||
entityValues.put(id.getIndex(), value);
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
package me.libraryaddict.disguise.disguisetypes;
|
||||
|
||||
/**
|
||||
* Created by libraryaddict on 24/04/2021.
|
||||
*/
|
||||
public enum GolemCrack {
|
||||
HEALTH_100,
|
||||
HEALTH_75,
|
||||
HEALTH_50,
|
||||
HEALTH_25
|
||||
}
|
|
@ -34,8 +34,9 @@ public class LibsEquipment implements EntityEquipment {
|
|||
for (int i = 0; i < equipment.length; i++) {
|
||||
ItemStack item = equipment[i];
|
||||
|
||||
if (item == null)
|
||||
if (item == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
newEquip.equipment[i] = item.clone();
|
||||
}
|
||||
|
@ -48,8 +49,9 @@ public class LibsEquipment implements EntityEquipment {
|
|||
}
|
||||
|
||||
public void setItem(EquipmentSlot slot, ItemStack item) {
|
||||
if (getItem(slot) == item)
|
||||
if (getItem(slot) == item) {
|
||||
return;
|
||||
}
|
||||
|
||||
equipment[slot.ordinal()] = item;
|
||||
flagWatcher.sendItemStack(slot, item);
|
||||
|
@ -216,4 +218,46 @@ public class LibsEquipment implements EntityEquipment {
|
|||
public Entity getHolder() {
|
||||
throw new UnsupportedOperationException("This is not supported on a disguise");
|
||||
}
|
||||
|
||||
//@Override
|
||||
@Deprecated
|
||||
public void setBoots(ItemStack boots, boolean silent) {
|
||||
setBoots(boots);
|
||||
}
|
||||
|
||||
//@Override
|
||||
@Deprecated
|
||||
public void setChestplate(ItemStack chestplate, boolean silent) {
|
||||
setChestplate(chestplate);
|
||||
}
|
||||
|
||||
//@Override
|
||||
@Deprecated
|
||||
public void setLeggings(ItemStack leggings, boolean silent) {
|
||||
setLeggings(leggings);
|
||||
}
|
||||
|
||||
//@Override
|
||||
@Deprecated
|
||||
public void setHelmet(ItemStack helmet, boolean silent) {
|
||||
setHelmet(helmet);
|
||||
}
|
||||
|
||||
// @Override
|
||||
@Deprecated
|
||||
public void setItem(EquipmentSlot equipmentSlot, ItemStack itemStack, boolean silent) {
|
||||
setItem(equipmentSlot, itemStack);
|
||||
}
|
||||
|
||||
// @Override
|
||||
@Deprecated
|
||||
public void setItemInMainHand(ItemStack itemStack, boolean silent) {
|
||||
setItemInMainHand(itemStack);
|
||||
}
|
||||
|
||||
//@Override
|
||||
@Deprecated
|
||||
public void setItemInOffHand(ItemStack itemStack, boolean silent) {
|
||||
setItemInOffHand(itemStack);
|
||||
}
|
||||
}
|
|
@ -1,14 +1,99 @@
|
|||
package me.libraryaddict.disguise.disguisetypes;
|
||||
|
||||
import com.comphenix.protocol.wrappers.*;
|
||||
import com.comphenix.protocol.wrappers.BlockPosition;
|
||||
import com.comphenix.protocol.wrappers.EnumWrappers.Direction;
|
||||
import com.comphenix.protocol.wrappers.Vector3F;
|
||||
import com.comphenix.protocol.wrappers.WrappedBlockData;
|
||||
import com.comphenix.protocol.wrappers.WrappedChatComponent;
|
||||
import com.comphenix.protocol.wrappers.WrappedDataWatcher;
|
||||
import com.comphenix.protocol.wrappers.WrappedParticle;
|
||||
import com.comphenix.protocol.wrappers.nbt.NbtBase;
|
||||
import com.comphenix.protocol.wrappers.nbt.NbtFactory;
|
||||
import com.comphenix.protocol.wrappers.nbt.NbtType;
|
||||
import me.libraryaddict.disguise.disguisetypes.watchers.*;
|
||||
import me.libraryaddict.disguise.disguisetypes.watchers.AbstractHorseWatcher;
|
||||
import me.libraryaddict.disguise.disguisetypes.watchers.AbstractSkeletonWatcher;
|
||||
import me.libraryaddict.disguise.disguisetypes.watchers.AbstractVillagerWatcher;
|
||||
import me.libraryaddict.disguise.disguisetypes.watchers.AgeableWatcher;
|
||||
import me.libraryaddict.disguise.disguisetypes.watchers.AreaEffectCloudWatcher;
|
||||
import me.libraryaddict.disguise.disguisetypes.watchers.ArmorStandWatcher;
|
||||
import me.libraryaddict.disguise.disguisetypes.watchers.ArrowWatcher;
|
||||
import me.libraryaddict.disguise.disguisetypes.watchers.AxolotlWatcher;
|
||||
import me.libraryaddict.disguise.disguisetypes.watchers.BatWatcher;
|
||||
import me.libraryaddict.disguise.disguisetypes.watchers.BeeWatcher;
|
||||
import me.libraryaddict.disguise.disguisetypes.watchers.BlazeWatcher;
|
||||
import me.libraryaddict.disguise.disguisetypes.watchers.BoatWatcher;
|
||||
import me.libraryaddict.disguise.disguisetypes.watchers.CatWatcher;
|
||||
import me.libraryaddict.disguise.disguisetypes.watchers.ChestedHorseWatcher;
|
||||
import me.libraryaddict.disguise.disguisetypes.watchers.CreeperWatcher;
|
||||
import me.libraryaddict.disguise.disguisetypes.watchers.DolphinWatcher;
|
||||
import me.libraryaddict.disguise.disguisetypes.watchers.DroppedItemWatcher;
|
||||
import me.libraryaddict.disguise.disguisetypes.watchers.EnderCrystalWatcher;
|
||||
import me.libraryaddict.disguise.disguisetypes.watchers.EnderDragonWatcher;
|
||||
import me.libraryaddict.disguise.disguisetypes.watchers.EnderSignalWatcher;
|
||||
import me.libraryaddict.disguise.disguisetypes.watchers.EndermanWatcher;
|
||||
import me.libraryaddict.disguise.disguisetypes.watchers.FallingBlockWatcher;
|
||||
import me.libraryaddict.disguise.disguisetypes.watchers.FireballWatcher;
|
||||
import me.libraryaddict.disguise.disguisetypes.watchers.FireworkWatcher;
|
||||
import me.libraryaddict.disguise.disguisetypes.watchers.FishWatcher;
|
||||
import me.libraryaddict.disguise.disguisetypes.watchers.FishingHookWatcher;
|
||||
import me.libraryaddict.disguise.disguisetypes.watchers.FoxWatcher;
|
||||
import me.libraryaddict.disguise.disguisetypes.watchers.GhastWatcher;
|
||||
import me.libraryaddict.disguise.disguisetypes.watchers.GlowSquidWatcher;
|
||||
import me.libraryaddict.disguise.disguisetypes.watchers.GoatWatcher;
|
||||
import me.libraryaddict.disguise.disguisetypes.watchers.GuardianWatcher;
|
||||
import me.libraryaddict.disguise.disguisetypes.watchers.HoglinWatcher;
|
||||
import me.libraryaddict.disguise.disguisetypes.watchers.HorseWatcher;
|
||||
import me.libraryaddict.disguise.disguisetypes.watchers.IllagerWatcher;
|
||||
import me.libraryaddict.disguise.disguisetypes.watchers.IllagerWizardWatcher;
|
||||
import me.libraryaddict.disguise.disguisetypes.watchers.InsentientWatcher;
|
||||
import me.libraryaddict.disguise.disguisetypes.watchers.IronGolemWatcher;
|
||||
import me.libraryaddict.disguise.disguisetypes.watchers.ItemFrameWatcher;
|
||||
import me.libraryaddict.disguise.disguisetypes.watchers.LivingWatcher;
|
||||
import me.libraryaddict.disguise.disguisetypes.watchers.LlamaWatcher;
|
||||
import me.libraryaddict.disguise.disguisetypes.watchers.MinecartCommandWatcher;
|
||||
import me.libraryaddict.disguise.disguisetypes.watchers.MinecartFurnaceWatcher;
|
||||
import me.libraryaddict.disguise.disguisetypes.watchers.MinecartWatcher;
|
||||
import me.libraryaddict.disguise.disguisetypes.watchers.MushroomCowWatcher;
|
||||
import me.libraryaddict.disguise.disguisetypes.watchers.OcelotWatcher;
|
||||
import me.libraryaddict.disguise.disguisetypes.watchers.PandaWatcher;
|
||||
import me.libraryaddict.disguise.disguisetypes.watchers.ParrotWatcher;
|
||||
import me.libraryaddict.disguise.disguisetypes.watchers.PhantomWatcher;
|
||||
import me.libraryaddict.disguise.disguisetypes.watchers.PigWatcher;
|
||||
import me.libraryaddict.disguise.disguisetypes.watchers.PiglinAbstractWatcher;
|
||||
import me.libraryaddict.disguise.disguisetypes.watchers.PiglinWatcher;
|
||||
import me.libraryaddict.disguise.disguisetypes.watchers.PillagerWatcher;
|
||||
import me.libraryaddict.disguise.disguisetypes.watchers.PlayerWatcher;
|
||||
import me.libraryaddict.disguise.disguisetypes.watchers.PolarBearWatcher;
|
||||
import me.libraryaddict.disguise.disguisetypes.watchers.PufferFishWatcher;
|
||||
import me.libraryaddict.disguise.disguisetypes.watchers.RabbitWatcher;
|
||||
import me.libraryaddict.disguise.disguisetypes.watchers.RaiderWatcher;
|
||||
import me.libraryaddict.disguise.disguisetypes.watchers.SheepWatcher;
|
||||
import me.libraryaddict.disguise.disguisetypes.watchers.ShulkerWatcher;
|
||||
import me.libraryaddict.disguise.disguisetypes.watchers.SkeletonWatcher;
|
||||
import me.libraryaddict.disguise.disguisetypes.watchers.SlimeWatcher;
|
||||
import me.libraryaddict.disguise.disguisetypes.watchers.SnowmanWatcher;
|
||||
import me.libraryaddict.disguise.disguisetypes.watchers.SpiderWatcher;
|
||||
import me.libraryaddict.disguise.disguisetypes.watchers.SplashPotionWatcher;
|
||||
import me.libraryaddict.disguise.disguisetypes.watchers.StriderWatcher;
|
||||
import me.libraryaddict.disguise.disguisetypes.watchers.TNTWatcher;
|
||||
import me.libraryaddict.disguise.disguisetypes.watchers.TameableWatcher;
|
||||
import me.libraryaddict.disguise.disguisetypes.watchers.ThrowableWatcher;
|
||||
import me.libraryaddict.disguise.disguisetypes.watchers.TippedArrowWatcher;
|
||||
import me.libraryaddict.disguise.disguisetypes.watchers.TridentWatcher;
|
||||
import me.libraryaddict.disguise.disguisetypes.watchers.TropicalFishWatcher;
|
||||
import me.libraryaddict.disguise.disguisetypes.watchers.TurtleWatcher;
|
||||
import me.libraryaddict.disguise.disguisetypes.watchers.VexWatcher;
|
||||
import me.libraryaddict.disguise.disguisetypes.watchers.VillagerWatcher;
|
||||
import me.libraryaddict.disguise.disguisetypes.watchers.WitchWatcher;
|
||||
import me.libraryaddict.disguise.disguisetypes.watchers.WitherSkullWatcher;
|
||||
import me.libraryaddict.disguise.disguisetypes.watchers.WitherWatcher;
|
||||
import me.libraryaddict.disguise.disguisetypes.watchers.WolfWatcher;
|
||||
import me.libraryaddict.disguise.disguisetypes.watchers.ZoglinWatcher;
|
||||
import me.libraryaddict.disguise.disguisetypes.watchers.ZombieVillagerWatcher;
|
||||
import me.libraryaddict.disguise.disguisetypes.watchers.ZombieWatcher;
|
||||
import me.libraryaddict.disguise.utilities.DisguiseUtilities;
|
||||
import me.libraryaddict.disguise.utilities.reflection.NmsAddedIn;
|
||||
import me.libraryaddict.disguise.utilities.reflection.NmsRemovedIn;
|
||||
import me.libraryaddict.disguise.utilities.reflection.annotations.NmsAddedIn;
|
||||
import me.libraryaddict.disguise.utilities.reflection.annotations.NmsRemovedIn;
|
||||
import me.libraryaddict.disguise.utilities.reflection.NmsVersion;
|
||||
import me.libraryaddict.disguise.utilities.reflection.ReflectionManager;
|
||||
import me.libraryaddict.disguise.utilities.translations.LibsMsg;
|
||||
|
@ -19,8 +104,15 @@ import org.bukkit.entity.Villager;
|
|||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Comparator;
|
||||
import java.util.HashMap;
|
||||
import java.util.Locale;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Optional;
|
||||
import java.util.OptionalInt;
|
||||
import java.util.UUID;
|
||||
|
||||
public class MetaIndex<Y> {
|
||||
private static MetaIndex[] _values = new MetaIndex[0];
|
||||
|
@ -33,32 +125,28 @@ public class MetaIndex<Y> {
|
|||
/**
|
||||
* The color of the Area Effect Cloud as RGB integer
|
||||
*/
|
||||
public static MetaIndex<Integer> AREA_EFFECT_CLOUD_COLOR = new MetaIndex<>(AreaEffectCloudWatcher.class, 1,
|
||||
Color.BLACK.asRGB());
|
||||
public static MetaIndex<Integer> AREA_EFFECT_CLOUD_COLOR = new MetaIndex<>(AreaEffectCloudWatcher.class, 1, Color.BLACK.asRGB());
|
||||
|
||||
/**
|
||||
* Ignore radius and show effect as single point, not area
|
||||
*/
|
||||
public static MetaIndex<Boolean> AREA_EFFECT_IGNORE_RADIUS = new MetaIndex<>(AreaEffectCloudWatcher.class, 2,
|
||||
false);
|
||||
public static MetaIndex<Boolean> AREA_EFFECT_IGNORE_RADIUS = new MetaIndex<>(AreaEffectCloudWatcher.class, 2, false);
|
||||
|
||||
/**
|
||||
* The type of particle to display
|
||||
*/
|
||||
@NmsAddedIn(val = NmsVersion.v1_13)
|
||||
public static MetaIndex<WrappedParticle> AREA_EFFECT_PARTICLE = new MetaIndex<>(AreaEffectCloudWatcher.class, 3,
|
||||
NmsVersion.v1_13.isSupported() ? WrappedParticle.create(Particle.SPELL_MOB, null) : null);
|
||||
@NmsAddedIn(NmsVersion.v1_13)
|
||||
public static MetaIndex<WrappedParticle> AREA_EFFECT_PARTICLE =
|
||||
new MetaIndex<>(AreaEffectCloudWatcher.class, 3, NmsVersion.v1_13.isSupported() ? WrappedParticle.create(Particle.SPELL_MOB, null) : null);
|
||||
|
||||
@NmsRemovedIn(val = NmsVersion.v1_13)
|
||||
@NmsRemovedIn(NmsVersion.v1_13)
|
||||
public static MetaIndex<Integer> AREA_EFFECT_PARTICLE_OLD = new MetaIndex<>(AreaEffectCloudWatcher.class, 3, 0);
|
||||
|
||||
@NmsRemovedIn(val = NmsVersion.v1_13)
|
||||
public static MetaIndex<Integer> AREA_EFFECT_PARTICLE_PARAM_1_OLD = new MetaIndex<>(AreaEffectCloudWatcher.class, 4,
|
||||
0);
|
||||
@NmsRemovedIn(NmsVersion.v1_13)
|
||||
public static MetaIndex<Integer> AREA_EFFECT_PARTICLE_PARAM_1_OLD = new MetaIndex<>(AreaEffectCloudWatcher.class, 4, 0);
|
||||
|
||||
@NmsRemovedIn(val = NmsVersion.v1_13)
|
||||
public static MetaIndex<Integer> AREA_EFFECT_PARTICLE_PARAM_2_OLD = new MetaIndex<>(AreaEffectCloudWatcher.class, 5,
|
||||
0);
|
||||
@NmsRemovedIn(NmsVersion.v1_13)
|
||||
public static MetaIndex<Integer> AREA_EFFECT_PARTICLE_PARAM_2_OLD = new MetaIndex<>(AreaEffectCloudWatcher.class, 5, 0);
|
||||
|
||||
/**
|
||||
* The size of the area
|
||||
|
@ -68,26 +156,22 @@ public class MetaIndex<Y> {
|
|||
/**
|
||||
* Armorstand body eular vector
|
||||
*/
|
||||
public static MetaIndex<Vector3F> ARMORSTAND_BODY = new MetaIndex<>(ArmorStandWatcher.class, 2,
|
||||
new Vector3F(0, 0, 0));
|
||||
public static MetaIndex<Vector3F> ARMORSTAND_BODY = new MetaIndex<>(ArmorStandWatcher.class, 2, new Vector3F(0, 0, 0));
|
||||
|
||||
/**
|
||||
* Armorstand head eular vector
|
||||
*/
|
||||
public static MetaIndex<Vector3F> ARMORSTAND_HEAD = new MetaIndex<>(ArmorStandWatcher.class, 1,
|
||||
new Vector3F(0, 0, 0));
|
||||
public static MetaIndex<Vector3F> ARMORSTAND_HEAD = new MetaIndex<>(ArmorStandWatcher.class, 1, new Vector3F(0, 0, 0));
|
||||
|
||||
/**
|
||||
* Armorstand left arm eular vector
|
||||
*/
|
||||
public static MetaIndex<Vector3F> ARMORSTAND_LEFT_ARM = new MetaIndex<>(ArmorStandWatcher.class, 3,
|
||||
new Vector3F(-10, 0, -10));
|
||||
public static MetaIndex<Vector3F> ARMORSTAND_LEFT_ARM = new MetaIndex<>(ArmorStandWatcher.class, 3, new Vector3F(-10, 0, -10));
|
||||
|
||||
/**
|
||||
* Armorstand left leg eular vector
|
||||
*/
|
||||
public static MetaIndex<Vector3F> ARMORSTAND_LEFT_LEG = new MetaIndex<>(ArmorStandWatcher.class, 5,
|
||||
new Vector3F(-1, 0, -1));
|
||||
public static MetaIndex<Vector3F> ARMORSTAND_LEFT_LEG = new MetaIndex<>(ArmorStandWatcher.class, 5, new Vector3F(-1, 0, -1));
|
||||
|
||||
/**
|
||||
* Armorstand metadata
|
||||
|
@ -97,14 +181,12 @@ public class MetaIndex<Y> {
|
|||
/**
|
||||
* Armorstand right arm eular vector
|
||||
*/
|
||||
public static MetaIndex<Vector3F> ARMORSTAND_RIGHT_ARM = new MetaIndex<>(ArmorStandWatcher.class, 4,
|
||||
new Vector3F(-15, 0, 10));
|
||||
public static MetaIndex<Vector3F> ARMORSTAND_RIGHT_ARM = new MetaIndex<>(ArmorStandWatcher.class, 4, new Vector3F(-15, 0, 10));
|
||||
|
||||
/**
|
||||
* Armorstand right leg eular vector
|
||||
*/
|
||||
public static MetaIndex<Vector3F> ARMORSTAND_RIGHT_LEG = new MetaIndex<>(ArmorStandWatcher.class, 6,
|
||||
new Vector3F(1, 0, 1));
|
||||
public static MetaIndex<Vector3F> ARMORSTAND_RIGHT_LEG = new MetaIndex<>(ArmorStandWatcher.class, 6, new Vector3F(1, 0, 1));
|
||||
|
||||
/**
|
||||
* If the arrow is a critical strike
|
||||
|
@ -114,21 +196,31 @@ public class MetaIndex<Y> {
|
|||
/**
|
||||
* The shooter of the arrow, no visible effect if set
|
||||
*/
|
||||
@NmsAddedIn(val = NmsVersion.v1_13)
|
||||
@NmsAddedIn(NmsVersion.v1_13)
|
||||
@NmsRemovedIn(NmsVersion.v1_16)
|
||||
public static MetaIndex<Optional<UUID>> ARROW_UUID = new MetaIndex<>(ArrowWatcher.class, 1, Optional.empty());
|
||||
|
||||
@NmsAddedIn(val = NmsVersion.v1_14)
|
||||
@NmsAddedIn(NmsVersion.v1_14)
|
||||
public static MetaIndex<Byte> ARROW_PIERCE_LEVEL = new MetaIndex<>(ArrowWatcher.class, 2, (byte) 0);
|
||||
|
||||
@NmsAddedIn(NmsVersion.v1_17)
|
||||
public static MetaIndex<Integer> AXOLOTL_VARIANT = new MetaIndex<>(AxolotlWatcher.class, 0, 0);
|
||||
|
||||
@NmsAddedIn(NmsVersion.v1_17)
|
||||
public static MetaIndex<Boolean> AXOLOTL_PLAYING_DEAD = new MetaIndex<>(AxolotlWatcher.class, 1, false);
|
||||
|
||||
@NmsAddedIn(NmsVersion.v1_17)
|
||||
public static MetaIndex<Boolean> AXOLOTL_FROM_BUCKET = new MetaIndex<>(AxolotlWatcher.class, 2, false);
|
||||
|
||||
/**
|
||||
* If the bat is hanging, false/true state
|
||||
*/
|
||||
public static MetaIndex<Byte> BAT_HANGING = new MetaIndex<>(BatWatcher.class, 0, (byte) 1);
|
||||
|
||||
@NmsAddedIn(val = NmsVersion.v1_15)
|
||||
@NmsAddedIn(NmsVersion.v1_15)
|
||||
public static MetaIndex<Byte> BEE_META = new MetaIndex<>(BeeWatcher.class, 0, (byte) 0);
|
||||
|
||||
@NmsAddedIn(val = NmsVersion.v1_15)
|
||||
@NmsAddedIn(NmsVersion.v1_15)
|
||||
public static MetaIndex<Integer> BEE_ANGER = new MetaIndex<>(BeeWatcher.class, 1, 0);
|
||||
|
||||
/**
|
||||
|
@ -154,19 +246,19 @@ public class MetaIndex<Y> {
|
|||
*/
|
||||
public static MetaIndex<Integer> BOAT_TYPE = new MetaIndex<>(BoatWatcher.class, 3, 0);
|
||||
|
||||
@NmsAddedIn(val = NmsVersion.v1_13)
|
||||
@NmsAddedIn(NmsVersion.v1_13)
|
||||
public static MetaIndex<Integer> BOAT_SHAKE = new MetaIndex<>(BoatWatcher.class, 6, 0);
|
||||
|
||||
@NmsAddedIn(val = NmsVersion.v1_14)
|
||||
@NmsAddedIn(NmsVersion.v1_14)
|
||||
public static MetaIndex<Integer> CAT_TYPE = new MetaIndex<>(CatWatcher.class, 0, 0);
|
||||
|
||||
@NmsAddedIn(val = NmsVersion.v1_14)
|
||||
@NmsAddedIn(NmsVersion.v1_14)
|
||||
public static MetaIndex<Boolean> CAT_LYING_DOWN = new MetaIndex<>(CatWatcher.class, 1, false);
|
||||
|
||||
@NmsAddedIn(val = NmsVersion.v1_14)
|
||||
@NmsAddedIn(NmsVersion.v1_14)
|
||||
public static MetaIndex<Boolean> CAT_LOOKING_UP = new MetaIndex<>(CatWatcher.class, 2, false);
|
||||
|
||||
@NmsAddedIn(val = NmsVersion.v1_14)
|
||||
@NmsAddedIn(NmsVersion.v1_14)
|
||||
public static MetaIndex<Integer> CAT_COLLAR = new MetaIndex<>(CatWatcher.class, 3, AnimalColor.RED.ordinal());
|
||||
|
||||
/**
|
||||
|
@ -187,8 +279,7 @@ public class MetaIndex<Y> {
|
|||
/**
|
||||
* No visible effect
|
||||
*/
|
||||
public static MetaIndex<BlockPosition> DOLPHIN_TREASURE_POS = new MetaIndex<>(DolphinWatcher.class, 0,
|
||||
BlockPosition.ORIGIN);
|
||||
public static MetaIndex<BlockPosition> DOLPHIN_TREASURE_POS = new MetaIndex<>(DolphinWatcher.class, 0, BlockPosition.ORIGIN);
|
||||
/**
|
||||
* No visible effect
|
||||
*/
|
||||
|
@ -202,11 +293,9 @@ public class MetaIndex<Y> {
|
|||
/**
|
||||
* The itemstack of the dropped item, must be set
|
||||
*/
|
||||
public static MetaIndex<ItemStack> DROPPED_ITEM = new MetaIndex<>(DroppedItemWatcher.class, 0,
|
||||
new ItemStack(Material.AIR));
|
||||
public static MetaIndex<ItemStack> DROPPED_ITEM = new MetaIndex<>(DroppedItemWatcher.class, 0, new ItemStack(Material.AIR));
|
||||
|
||||
public static MetaIndex<Optional<BlockPosition>> ENDER_CRYSTAL_BEAM = new MetaIndex<>(EnderCrystalWatcher.class, 0,
|
||||
Optional.empty());
|
||||
public static MetaIndex<Optional<BlockPosition>> ENDER_CRYSTAL_BEAM = new MetaIndex<>(EnderCrystalWatcher.class, 0, Optional.empty());
|
||||
|
||||
/**
|
||||
* If the ender crystal has a plate
|
||||
|
@ -215,36 +304,33 @@ public class MetaIndex<Y> {
|
|||
|
||||
public static MetaIndex<Integer> ENDER_DRAGON_PHASE = new MetaIndex<>(EnderDragonWatcher.class, 0, 10);
|
||||
|
||||
@NmsAddedIn(val = NmsVersion.v1_14)
|
||||
public static MetaIndex<ItemStack> ENDER_SIGNAL_ITEM = new MetaIndex<>(EnderSignalWatcher.class, 0,
|
||||
new ItemStack(Material.AIR));
|
||||
@NmsAddedIn(NmsVersion.v1_14)
|
||||
public static MetaIndex<ItemStack> ENDER_SIGNAL_ITEM = new MetaIndex<>(EnderSignalWatcher.class, 0, new ItemStack(Material.AIR));
|
||||
|
||||
/**
|
||||
* If the enderman is screaming
|
||||
*/
|
||||
public static MetaIndex<Boolean> ENDERMAN_AGRESSIVE = new MetaIndex<>(EndermanWatcher.class, 1, false);
|
||||
|
||||
@NmsAddedIn(val = NmsVersion.v1_15)
|
||||
@NmsAddedIn(NmsVersion.v1_15)
|
||||
public static MetaIndex<Boolean> ENDERMAN_UNKNOWN = new MetaIndex<>(EndermanWatcher.class, 2, false);
|
||||
|
||||
/**
|
||||
* What block the enderman is holding
|
||||
*/
|
||||
public static MetaIndex<Optional<WrappedBlockData>> ENDERMAN_ITEM = new MetaIndex<>(EndermanWatcher.class, 0,
|
||||
Optional.empty());
|
||||
public static MetaIndex<Optional<WrappedBlockData>> ENDERMAN_ITEM = new MetaIndex<>(EndermanWatcher.class, 0, Optional.empty());
|
||||
|
||||
public static MetaIndex<Integer> ENTITY_AIR_TICKS = new MetaIndex<>(FlagWatcher.class, 1, 300);
|
||||
|
||||
/**
|
||||
* The custom name of the entity, empty if not set
|
||||
*/
|
||||
@NmsAddedIn(val = NmsVersion.v1_13)
|
||||
public static MetaIndex<Optional<WrappedChatComponent>> ENTITY_CUSTOM_NAME = new MetaIndex<>(FlagWatcher.class, 2,
|
||||
Optional.empty());
|
||||
@NmsAddedIn(NmsVersion.v1_13)
|
||||
public static MetaIndex<Optional<WrappedChatComponent>> ENTITY_CUSTOM_NAME = new MetaIndex<>(FlagWatcher.class, 2, Optional.empty());
|
||||
/**
|
||||
* The custom name of the entity, empty if not set
|
||||
*/
|
||||
@NmsRemovedIn(val = NmsVersion.v1_13)
|
||||
@NmsRemovedIn(NmsVersion.v1_13)
|
||||
public static MetaIndex<String> ENTITY_CUSTOM_NAME_OLD = new MetaIndex<>(FlagWatcher.class, 2, "");
|
||||
|
||||
/**
|
||||
|
@ -271,46 +357,49 @@ public class MetaIndex<Y> {
|
|||
* If entity can make sounds, no noticable effects
|
||||
*/
|
||||
|
||||
@NmsAddedIn(val = NmsVersion.v1_14)
|
||||
@NmsAddedIn(NmsVersion.v1_14)
|
||||
public static MetaIndex<EntityPose> ENTITY_POSE = new MetaIndex<>(FlagWatcher.class, 6, EntityPose.STANDING);
|
||||
|
||||
public static MetaIndex<BlockPosition> FALLING_BLOCK_POSITION = new MetaIndex<>(FallingBlockWatcher.class, 0,
|
||||
BlockPosition.ORIGIN);
|
||||
@NmsAddedIn(NmsVersion.v1_17)
|
||||
public static MetaIndex<Integer> ENTITY_TICKS_FROZEN = new MetaIndex<>(FlagWatcher.class, 7, 0);
|
||||
|
||||
@NmsAddedIn(val = NmsVersion.v1_14)
|
||||
public static MetaIndex<ItemStack> FIREBALL_ITEM = new MetaIndex<>(FireballWatcher.class, 0,
|
||||
new ItemStack(Material.AIR));
|
||||
public static MetaIndex<BlockPosition> FALLING_BLOCK_POSITION = new MetaIndex<>(FallingBlockWatcher.class, 0, BlockPosition.ORIGIN);
|
||||
|
||||
public static MetaIndex<ItemStack> FIREWORK_ITEM = new MetaIndex<>(FireworkWatcher.class, 0,
|
||||
new ItemStack(NmsVersion.v1_13.isSupported() ? Material.FIREWORK_ROCKET : Material.AIR));
|
||||
@NmsAddedIn(NmsVersion.v1_14)
|
||||
public static MetaIndex<ItemStack> FIREBALL_ITEM = new MetaIndex<>(FireballWatcher.class, 0, new ItemStack(Material.AIR));
|
||||
|
||||
public static MetaIndex<ItemStack> FIREWORK_ITEM =
|
||||
new MetaIndex<>(FireworkWatcher.class, 0, new ItemStack(NmsVersion.v1_13.isSupported() ? Material.FIREWORK_ROCKET : Material.AIR));
|
||||
|
||||
public static MetaIndex<Boolean> FISH_FROM_BUCKET = new MetaIndex<>(FishWatcher.class, 0, false);
|
||||
|
||||
@NmsRemovedIn(val = NmsVersion.v1_14)
|
||||
@NmsRemovedIn(NmsVersion.v1_14)
|
||||
public static MetaIndex<Integer> FIREWORK_ATTACHED_ENTITY_OLD = new MetaIndex<>(FireworkWatcher.class, 1, 0);
|
||||
|
||||
@NmsAddedIn(val = NmsVersion.v1_14)
|
||||
public static MetaIndex<OptionalInt> FIREWORK_ATTACHED_ENTITY = new MetaIndex<>(FireworkWatcher.class, 1,
|
||||
OptionalInt.empty());
|
||||
@NmsAddedIn(NmsVersion.v1_14)
|
||||
public static MetaIndex<OptionalInt> FIREWORK_ATTACHED_ENTITY = new MetaIndex<>(FireworkWatcher.class, 1, OptionalInt.empty());
|
||||
|
||||
@NmsAddedIn(val = NmsVersion.v1_14)
|
||||
@NmsAddedIn(NmsVersion.v1_14)
|
||||
public static MetaIndex<Boolean> FIREWORK_SHOT_AT_ANGLE = new MetaIndex<>(FireworkWatcher.class, 2, false);
|
||||
|
||||
public static MetaIndex<Integer> FISHING_HOOK_HOOKED = new MetaIndex<>(FishingHookWatcher.class, 0, 0);
|
||||
public static MetaIndex<Integer> FISHING_HOOK_HOOKED_ID = new MetaIndex<>(FishingHookWatcher.class, 0, 0);
|
||||
|
||||
@NmsAddedIn(NmsVersion.v1_16)
|
||||
public static MetaIndex<Boolean> FISHING_HOOK_HOOKED = new MetaIndex<>(FishingHookWatcher.class, 1, false);
|
||||
|
||||
/**
|
||||
* The type of fox, its coloring
|
||||
*/
|
||||
@NmsAddedIn(val = NmsVersion.v1_14)
|
||||
@NmsAddedIn(NmsVersion.v1_14)
|
||||
public static MetaIndex<Integer> FOX_TYPE = new MetaIndex<>(FoxWatcher.class, 0, 0);
|
||||
|
||||
@NmsAddedIn(val = NmsVersion.v1_14)
|
||||
@NmsAddedIn(NmsVersion.v1_14)
|
||||
public static MetaIndex<Byte> FOX_META = new MetaIndex<>(FoxWatcher.class, 1, (byte) 0);
|
||||
|
||||
@NmsAddedIn(val = NmsVersion.v1_14)
|
||||
@NmsAddedIn(NmsVersion.v1_14)
|
||||
public static MetaIndex<Optional<UUID>> FOX_TRUSTED_1 = new MetaIndex<>(FoxWatcher.class, 2, Optional.empty());
|
||||
|
||||
@NmsAddedIn(val = NmsVersion.v1_14)
|
||||
@NmsAddedIn(NmsVersion.v1_14)
|
||||
public static MetaIndex<Optional<UUID>> FOX_TRUSTED_2 = new MetaIndex<>(FoxWatcher.class, 3, Optional.empty());
|
||||
|
||||
/**
|
||||
|
@ -318,6 +407,12 @@ public class MetaIndex<Y> {
|
|||
*/
|
||||
public static MetaIndex<Boolean> GHAST_AGRESSIVE = new MetaIndex<>(GhastWatcher.class, 0, false);
|
||||
|
||||
@NmsAddedIn(NmsVersion.v1_17)
|
||||
public static MetaIndex<Integer> GLOW_SQUID_DARK_TICKS_REMAINING = new MetaIndex<>(GlowSquidWatcher.class, 0, 0);
|
||||
|
||||
@NmsAddedIn(NmsVersion.v1_17)
|
||||
public static MetaIndex<Boolean> GOAT_SCREAMING = new MetaIndex<>(GoatWatcher.class, 0, false);
|
||||
|
||||
/**
|
||||
* Switch between the guardian spikes enabled/disabled
|
||||
*/
|
||||
|
@ -328,13 +423,15 @@ public class MetaIndex<Y> {
|
|||
*/
|
||||
public static MetaIndex<Integer> GUARDIAN_TARGET = new MetaIndex<>(GuardianWatcher.class, 1, 0);
|
||||
|
||||
@NmsAddedIn(NmsVersion.v1_16)
|
||||
public static MetaIndex<Boolean> HOGLIN_SHAKING = new MetaIndex<>(HoglinWatcher.class, 0, false);
|
||||
|
||||
/**
|
||||
* If horse has chest, set for donkey
|
||||
*/
|
||||
public static MetaIndex<Boolean> HORSE_CHESTED_CARRYING_CHEST = new MetaIndex<>(ChestedHorseWatcher.class, 0,
|
||||
false);
|
||||
public static MetaIndex<Boolean> HORSE_CHESTED_CARRYING_CHEST = new MetaIndex<>(ChestedHorseWatcher.class, 0, false);
|
||||
|
||||
@NmsRemovedIn(val = NmsVersion.v1_14)
|
||||
@NmsRemovedIn(NmsVersion.v1_14)
|
||||
public static MetaIndex<Integer> HORSE_ARMOR = new MetaIndex<>(HorseWatcher.class, 1, 0);
|
||||
/**
|
||||
* Color of the horse, uses enum not RGB
|
||||
|
@ -349,16 +446,15 @@ public class MetaIndex<Y> {
|
|||
/**
|
||||
* Owner of the horse, no visual effect
|
||||
*/
|
||||
public static MetaIndex<Optional<UUID>> HORSE_OWNER = new MetaIndex<>(AbstractHorseWatcher.class, 1,
|
||||
Optional.empty());
|
||||
public static MetaIndex<Optional<UUID>> HORSE_OWNER = new MetaIndex<>(AbstractHorseWatcher.class, 1, Optional.empty());
|
||||
|
||||
@NmsAddedIn(val = NmsVersion.v1_14)
|
||||
@NmsAddedIn(NmsVersion.v1_14)
|
||||
public static MetaIndex<Byte> ILLAGER_SPELL = new MetaIndex<>(IllagerWizardWatcher.class, 0, (byte) 0);
|
||||
|
||||
@NmsRemovedIn(val = NmsVersion.v1_14)
|
||||
@NmsRemovedIn(NmsVersion.v1_14)
|
||||
public static MetaIndex<Byte> ILLAGER_META = new MetaIndex<>(IllagerWatcher.class, 0, (byte) 0);
|
||||
|
||||
@NmsRemovedIn(val = NmsVersion.v1_14)
|
||||
@NmsRemovedIn(NmsVersion.v1_14)
|
||||
public static MetaIndex<Byte> ILLAGER_SPELL_TICKS = new MetaIndex<>(IllagerWizardWatcher.class, 0, (byte) 0);
|
||||
|
||||
public static MetaIndex<Byte> INSENTIENT_META = new MetaIndex<>(InsentientWatcher.class, 0, (byte) 0);
|
||||
|
@ -368,8 +464,7 @@ public class MetaIndex<Y> {
|
|||
/**
|
||||
* The itemstack inside the itemframe
|
||||
*/
|
||||
public static MetaIndex<ItemStack> ITEMFRAME_ITEM = new MetaIndex<>(ItemFrameWatcher.class, 0,
|
||||
new ItemStack(Material.AIR));
|
||||
public static MetaIndex<ItemStack> ITEMFRAME_ITEM = new MetaIndex<>(ItemFrameWatcher.class, 0, new ItemStack(Material.AIR));
|
||||
|
||||
/**
|
||||
* The itemstack rotation inside the itemframe
|
||||
|
@ -384,7 +479,7 @@ public class MetaIndex<Y> {
|
|||
/**
|
||||
* The main hand of the living entity
|
||||
*/
|
||||
public static MetaIndex<Byte> LIVING_HAND = new MetaIndex<>(LivingWatcher.class, 0, (byte) 0);
|
||||
public static MetaIndex<Byte> LIVING_META = new MetaIndex<>(LivingWatcher.class, 0, (byte) 0);
|
||||
|
||||
/**
|
||||
* How much health the living entity has, generally only visible on bosses due to their health bar
|
||||
|
@ -404,12 +499,11 @@ public class MetaIndex<Y> {
|
|||
/**
|
||||
* How many bee stings does the entity have
|
||||
*/
|
||||
@NmsAddedIn(val = NmsVersion.v1_15)
|
||||
@NmsAddedIn(NmsVersion.v1_15)
|
||||
public static MetaIndex<Integer> LIVING_STINGS = new MetaIndex<>(LivingWatcher.class, 5, 0);
|
||||
|
||||
@NmsAddedIn(val = NmsVersion.v1_14)
|
||||
public static MetaIndex<Optional<BlockPosition>> LIVING_BED_POSITION = new MetaIndex<>(LivingWatcher.class, 6,
|
||||
Optional.empty());
|
||||
@NmsAddedIn(NmsVersion.v1_14)
|
||||
public static MetaIndex<Optional<BlockPosition>> LIVING_BED_POSITION = new MetaIndex<>(LivingWatcher.class, 6, Optional.empty());
|
||||
|
||||
/**
|
||||
* If there is no carpet, -1. Otherwise it's a color enum value
|
||||
|
@ -449,39 +543,39 @@ public class MetaIndex<Y> {
|
|||
*/
|
||||
public static MetaIndex<String> MINECART_COMMAND_STRING = new MetaIndex<>(MinecartCommandWatcher.class, 0, "");
|
||||
|
||||
public static MetaIndex<WrappedChatComponent> MINECART_COMMAND_LAST_OUTPUT = new MetaIndex<>(
|
||||
MinecartCommandWatcher.class, 1, WrappedChatComponent.fromText(""));
|
||||
public static MetaIndex<WrappedChatComponent> MINECART_COMMAND_LAST_OUTPUT =
|
||||
new MetaIndex<>(MinecartCommandWatcher.class, 1, WrappedChatComponent.fromText(""));
|
||||
|
||||
/**
|
||||
* If the minecart furnace is fueled and burning
|
||||
*/
|
||||
public static MetaIndex<Boolean> MINECART_FURANCE_FUELED = new MetaIndex<>(MinecartFurnaceWatcher.class, 0, false);
|
||||
|
||||
@NmsAddedIn(val = NmsVersion.v1_14)
|
||||
@NmsAddedIn(NmsVersion.v1_14)
|
||||
public static MetaIndex<String> MUSHROOM_COW_TYPE = new MetaIndex<>(MushroomCowWatcher.class, 0, "RED");
|
||||
|
||||
@NmsRemovedIn(val = NmsVersion.v1_14)
|
||||
@NmsRemovedIn(NmsVersion.v1_14)
|
||||
public static MetaIndex<Integer> OCELOT_TYPE = new MetaIndex<>(OcelotWatcher.class, 0, 0);
|
||||
|
||||
@NmsAddedIn(val = NmsVersion.v1_14)
|
||||
@NmsAddedIn(NmsVersion.v1_14)
|
||||
public static MetaIndex<Boolean> OCELOT_TRUST = new MetaIndex<>(OcelotWatcher.class, 0, false);
|
||||
|
||||
@NmsAddedIn(val = NmsVersion.v1_14)
|
||||
@NmsAddedIn(NmsVersion.v1_14)
|
||||
public static MetaIndex<Integer> PANDA_HEAD_SHAKING = new MetaIndex<>(PandaWatcher.class, 0, 0);
|
||||
|
||||
@NmsAddedIn(val = NmsVersion.v1_14)
|
||||
@NmsAddedIn(NmsVersion.v1_14)
|
||||
public static MetaIndex<Integer> PANDA_UNKNOWN_1 = new MetaIndex<>(PandaWatcher.class, 1, 0);
|
||||
|
||||
@NmsAddedIn(val = NmsVersion.v1_14)
|
||||
@NmsAddedIn(NmsVersion.v1_14)
|
||||
public static MetaIndex<Integer> PANDA_UNKNOWN_2 = new MetaIndex<>(PandaWatcher.class, 2, 0);
|
||||
|
||||
@NmsAddedIn(val = NmsVersion.v1_14)
|
||||
@NmsAddedIn(NmsVersion.v1_14)
|
||||
public static MetaIndex<Byte> PANDA_MAIN_GENE = new MetaIndex<>(PandaWatcher.class, 3, (byte) 0);
|
||||
|
||||
@NmsAddedIn(val = NmsVersion.v1_14)
|
||||
@NmsAddedIn(NmsVersion.v1_14)
|
||||
public static MetaIndex<Byte> PANDA_HIDDEN_GENE = new MetaIndex<>(PandaWatcher.class, 4, (byte) 0);
|
||||
|
||||
@NmsAddedIn(val = NmsVersion.v1_14)
|
||||
@NmsAddedIn(NmsVersion.v1_14)
|
||||
public static MetaIndex<Byte> PANDA_META = new MetaIndex<>(PandaWatcher.class, 5, (byte) 0);
|
||||
|
||||
public static MetaIndex<Integer> PARROT_VARIANT = new MetaIndex<>(ParrotWatcher.class, 0, 0);
|
||||
|
@ -495,7 +589,19 @@ public class MetaIndex<Y> {
|
|||
*/
|
||||
public static MetaIndex<Integer> PIG_BOOST = new MetaIndex<>(PigWatcher.class, 1, 0);
|
||||
|
||||
@NmsAddedIn(val = NmsVersion.v1_14)
|
||||
@NmsAddedIn(NmsVersion.v1_16)
|
||||
public static MetaIndex<Boolean> PIGLIN_ABSTRACT_SHAKING = new MetaIndex<>(PiglinAbstractWatcher.class, 0, false);
|
||||
|
||||
@NmsAddedIn(NmsVersion.v1_16)
|
||||
public static MetaIndex<Boolean> PIGLIN_BABY = new MetaIndex<>(PiglinWatcher.class, 0, false);
|
||||
|
||||
@NmsAddedIn(NmsVersion.v1_16)
|
||||
public static MetaIndex<Boolean> PIGLIN_CROSSBOW = new MetaIndex<>(PiglinWatcher.class, 1, false);
|
||||
|
||||
@NmsAddedIn(NmsVersion.v1_16)
|
||||
public static MetaIndex<Boolean> PIGLIN_DANCING = new MetaIndex<>(PiglinWatcher.class, 2, false);
|
||||
|
||||
@NmsAddedIn(NmsVersion.v1_14)
|
||||
public static MetaIndex<Boolean> PILLAGER_AIMING_BOW = new MetaIndex<>(PillagerWatcher.class, 0, false);
|
||||
|
||||
public static MetaIndex<Float> PLAYER_ABSORPTION = new MetaIndex<>(PlayerWatcher.class, 0, 0F);
|
||||
|
@ -506,11 +612,9 @@ public class MetaIndex<Y> {
|
|||
|
||||
public static MetaIndex<Byte> PLAYER_SKIN = new MetaIndex<>(PlayerWatcher.class, 2, (byte) 127);
|
||||
|
||||
public static MetaIndex<NbtBase> PLAYER_LEFT_SHOULDER_ENTITY = new MetaIndex<>(PlayerWatcher.class, 4,
|
||||
NbtFactory.ofWrapper(NbtType.TAG_COMPOUND, "None"));
|
||||
public static MetaIndex<NbtBase> PLAYER_LEFT_SHOULDER_ENTITY = new MetaIndex<>(PlayerWatcher.class, 4, NbtFactory.ofWrapper(NbtType.TAG_COMPOUND, "None"));
|
||||
|
||||
public static MetaIndex<NbtBase> PLAYER_RIGHT_SHOULDER_ENTITY = new MetaIndex<>(PlayerWatcher.class, 5,
|
||||
NbtFactory.ofWrapper(NbtType.TAG_COMPOUND, "None"));
|
||||
public static MetaIndex<NbtBase> PLAYER_RIGHT_SHOULDER_ENTITY = new MetaIndex<>(PlayerWatcher.class, 5, NbtFactory.ofWrapper(NbtType.TAG_COMPOUND, "None"));
|
||||
|
||||
public static MetaIndex<Boolean> POLAR_BEAR_STANDING = new MetaIndex<>(PolarBearWatcher.class, 0, false);
|
||||
|
||||
|
@ -518,13 +622,13 @@ public class MetaIndex<Y> {
|
|||
|
||||
public static MetaIndex<Integer> RABBIT_TYPE = new MetaIndex<>(RabbitWatcher.class, 0, 0);
|
||||
|
||||
@NmsAddedIn(val = NmsVersion.v1_14)
|
||||
@NmsAddedIn(NmsVersion.v1_14)
|
||||
public static MetaIndex<Boolean> RAIDER_CASTING_SPELL = new MetaIndex<>(RaiderWatcher.class, 0, false);
|
||||
|
||||
public static MetaIndex<Byte> SHEEP_WOOL = new MetaIndex<>(SheepWatcher.class, 0, (byte) 0);
|
||||
|
||||
public static MetaIndex<Optional<BlockPosition>> SHULKER_ATTACHED = new MetaIndex<>(ShulkerWatcher.class, 1,
|
||||
Optional.empty());
|
||||
@NmsRemovedIn(NmsVersion.v1_17)
|
||||
public static MetaIndex<Optional<BlockPosition>> SHULKER_ATTACHED = new MetaIndex<>(ShulkerWatcher.class, 1, Optional.empty());
|
||||
|
||||
public static MetaIndex<Byte> SHULKER_COLOR = new MetaIndex<>(ShulkerWatcher.class, 3, (byte) 16);
|
||||
|
||||
|
@ -532,26 +636,35 @@ public class MetaIndex<Y> {
|
|||
|
||||
public static MetaIndex<Byte> SHULKER_PEEKING = new MetaIndex<>(ShulkerWatcher.class, 2, (byte) 0);
|
||||
|
||||
@NmsRemovedIn(val = NmsVersion.v1_14)
|
||||
public static MetaIndex<Boolean> SKELETON_SWING_ARMS = new MetaIndex<>(SkeletonWatcher.class, 0, false);
|
||||
@NmsRemovedIn(NmsVersion.v1_14)
|
||||
public static MetaIndex<Boolean> SKELETON_SWING_ARMS = new MetaIndex<>(AbstractSkeletonWatcher.class, 0, false);
|
||||
|
||||
@NmsAddedIn(NmsVersion.v1_17)
|
||||
public static MetaIndex<Boolean> SKELETON_CONVERTING_STRAY = new MetaIndex<>(SkeletonWatcher.class, 0, false);
|
||||
|
||||
public static MetaIndex<Integer> SLIME_SIZE = new MetaIndex<>(SlimeWatcher.class, 0, 1);
|
||||
|
||||
public static MetaIndex<Byte> SNOWMAN_DERP = new MetaIndex<>(SnowmanWatcher.class, 0, (byte) 16);
|
||||
|
||||
@NmsAddedIn(NmsVersion.v1_16)
|
||||
public static MetaIndex<Integer> STRIDER_SADDLE_UNKNOWN = new MetaIndex<>(StriderWatcher.class, 0, 0);
|
||||
|
||||
@NmsAddedIn(NmsVersion.v1_16)
|
||||
public static MetaIndex<Boolean> STRIDER_WARM = new MetaIndex<>(StriderWatcher.class, 1, false);
|
||||
|
||||
@NmsAddedIn(NmsVersion.v1_16)
|
||||
public static MetaIndex<Boolean> STRIDER_SADDLED = new MetaIndex<>(StriderWatcher.class, 2, false);
|
||||
|
||||
public static MetaIndex<Byte> SPIDER_CLIMB = new MetaIndex<>(SpiderWatcher.class, 0, (byte) 0);
|
||||
|
||||
public static MetaIndex<ItemStack> SPLASH_POTION_ITEM = new MetaIndex<>(SplashPotionWatcher.class, 0,
|
||||
new ItemStack(Material.SPLASH_POTION));
|
||||
public static MetaIndex<ItemStack> SPLASH_POTION_ITEM = new MetaIndex<>(SplashPotionWatcher.class, 0, new ItemStack(Material.SPLASH_POTION));
|
||||
|
||||
public static MetaIndex<Byte> TAMEABLE_META = new MetaIndex<>(TameableWatcher.class, 0, (byte) 0);
|
||||
|
||||
public static MetaIndex<Optional<UUID>> TAMEABLE_OWNER = new MetaIndex<>(TameableWatcher.class, 1,
|
||||
Optional.empty());
|
||||
public static MetaIndex<Optional<UUID>> TAMEABLE_OWNER = new MetaIndex<>(TameableWatcher.class, 1, Optional.empty());
|
||||
|
||||
@NmsAddedIn(val = NmsVersion.v1_14)
|
||||
public static MetaIndex<ItemStack> THROWABLE_ITEM = new MetaIndex<>(ThrowableWatcher.class, 0,
|
||||
new ItemStack(Material.AIR));
|
||||
@NmsAddedIn(NmsVersion.v1_14)
|
||||
public static MetaIndex<ItemStack> THROWABLE_ITEM = new MetaIndex<>(ThrowableWatcher.class, 0, new ItemStack(Material.AIR));
|
||||
|
||||
public static MetaIndex<Integer> TIPPED_ARROW_COLOR = new MetaIndex<>(TippedArrowWatcher.class, 0, -1);
|
||||
|
||||
|
@ -559,20 +672,18 @@ public class MetaIndex<Y> {
|
|||
|
||||
public static MetaIndex<Byte> TRIDENT_ENCHANTS = new MetaIndex<>(TridentWatcher.class, 0, (byte) 0);
|
||||
|
||||
@NmsAddedIn(val = NmsVersion.v1_15)
|
||||
@NmsAddedIn(NmsVersion.v1_15)
|
||||
public static MetaIndex<Boolean> TRIDENT_ENCHANTED = new MetaIndex<>(TridentWatcher.class, 1, false);
|
||||
|
||||
public static MetaIndex<Integer> TROPICAL_FISH_VARIANT = new MetaIndex<>(TropicalFishWatcher.class, 0, 0);
|
||||
|
||||
public static MetaIndex<BlockPosition> TURTLE_HOME_POSITION = new MetaIndex<>(TurtleWatcher.class, 0,
|
||||
BlockPosition.ORIGIN);
|
||||
public static MetaIndex<BlockPosition> TURTLE_HOME_POSITION = new MetaIndex<>(TurtleWatcher.class, 0, BlockPosition.ORIGIN);
|
||||
|
||||
public static MetaIndex<Boolean> TURTLE_HAS_EGG = new MetaIndex<>(TurtleWatcher.class, 1, false);
|
||||
|
||||
public static MetaIndex<Boolean> TURTLE_UNKNOWN_3 = new MetaIndex<>(TurtleWatcher.class, 2, false);
|
||||
|
||||
public static MetaIndex<BlockPosition> TURTLE_TRAVEL_POSITION = new MetaIndex<>(TurtleWatcher.class, 3,
|
||||
BlockPosition.ORIGIN);
|
||||
public static MetaIndex<BlockPosition> TURTLE_TRAVEL_POSITION = new MetaIndex<>(TurtleWatcher.class, 3, BlockPosition.ORIGIN);
|
||||
|
||||
public static MetaIndex<Boolean> TURTLE_UNKNOWN_1 = new MetaIndex<>(TurtleWatcher.class, 4, false);
|
||||
|
||||
|
@ -580,16 +691,15 @@ public class MetaIndex<Y> {
|
|||
|
||||
public static MetaIndex<Byte> VEX_ANGRY = new MetaIndex<>(VexWatcher.class, 0, (byte) 0);
|
||||
|
||||
@NmsRemovedIn(val = NmsVersion.v1_14)
|
||||
@NmsRemovedIn(NmsVersion.v1_14)
|
||||
public static MetaIndex<Integer> VILLAGER_PROFESSION = new MetaIndex<>(VillagerWatcher.class, 0, 0);
|
||||
|
||||
@NmsAddedIn(val = NmsVersion.v1_14)
|
||||
@NmsAddedIn(NmsVersion.v1_14)
|
||||
public static MetaIndex<Integer> ABSTRACT_VILLAGER_ANGRY = new MetaIndex<>(AbstractVillagerWatcher.class, 0, 0);
|
||||
|
||||
@NmsAddedIn(val = NmsVersion.v1_14)
|
||||
public static MetaIndex<VillagerData> VILLAGER_DATA = new MetaIndex<>(VillagerWatcher.class, 0,
|
||||
NmsVersion.v1_14.isSupported() ? new VillagerData(Villager.Type.PLAINS, Villager.Profession.NONE, 1) :
|
||||
null);
|
||||
@NmsAddedIn(NmsVersion.v1_14)
|
||||
public static MetaIndex<VillagerData> VILLAGER_DATA =
|
||||
new MetaIndex<>(VillagerWatcher.class, 0, NmsVersion.v1_14.isSupported() ? new VillagerData(Villager.Type.PLAINS, Villager.Profession.NONE, 1) : null);
|
||||
|
||||
public static MetaIndex<Boolean> WITCH_AGGRESSIVE = new MetaIndex<>(WitchWatcher.class, 0, false);
|
||||
|
||||
|
@ -605,29 +715,33 @@ public class MetaIndex<Y> {
|
|||
|
||||
public static MetaIndex<Boolean> WOLF_BEGGING = new MetaIndex<>(WolfWatcher.class, 1, false);
|
||||
|
||||
@NmsRemovedIn(val = NmsVersion.v1_15)
|
||||
@NmsRemovedIn(NmsVersion.v1_15)
|
||||
public static MetaIndex<Float> WOLF_DAMAGE = new MetaIndex<>(WolfWatcher.class, 0, 1F);
|
||||
|
||||
public static MetaIndex<Integer> WOLF_COLLAR = new MetaIndex<>(WolfWatcher.class, 2, 14);
|
||||
|
||||
@NmsRemovedIn(val = NmsVersion.v1_14)
|
||||
@NmsAddedIn(NmsVersion.v1_16)
|
||||
public static MetaIndex<Integer> WOLF_ANGER = new MetaIndex<>(WolfWatcher.class, 3, 0);
|
||||
|
||||
@NmsAddedIn(NmsVersion.v1_16)
|
||||
public static MetaIndex<Boolean> ZOGLIN_BABY = new MetaIndex<>(ZoglinWatcher.class, 0, false);
|
||||
|
||||
@NmsRemovedIn(NmsVersion.v1_14)
|
||||
public static MetaIndex<Boolean> ZOMBIE_AGGRESSIVE = new MetaIndex<>(ZombieWatcher.class, 2, false);
|
||||
|
||||
public static MetaIndex<Boolean> ZOMBIE_BABY = new MetaIndex<>(ZombieWatcher.class, 0, false);
|
||||
|
||||
@NmsAddedIn(val = NmsVersion.v1_13)
|
||||
@NmsAddedIn(NmsVersion.v1_13)
|
||||
public static MetaIndex<Boolean> ZOMBIE_CONVERTING_DROWNED = new MetaIndex<>(ZombieWatcher.class, 2, false);
|
||||
|
||||
public static MetaIndex<Integer> ZOMBIE_PLACEHOLDER = new MetaIndex<>(ZombieWatcher.class, 1, 0);
|
||||
|
||||
@NmsRemovedIn(val = NmsVersion.v1_14)
|
||||
public static MetaIndex<Integer> ZOMBIE_VILLAGER_PROFESSION_OLD = new MetaIndex<>(ZombieVillagerWatcher.class, 1,
|
||||
0);
|
||||
@NmsRemovedIn(NmsVersion.v1_14)
|
||||
public static MetaIndex<Integer> ZOMBIE_VILLAGER_PROFESSION_OLD = new MetaIndex<>(ZombieVillagerWatcher.class, 1, 0);
|
||||
|
||||
@NmsAddedIn(val = NmsVersion.v1_14)
|
||||
@NmsAddedIn(NmsVersion.v1_14)
|
||||
public static MetaIndex<VillagerData> ZOMBIE_VILLAGER_PROFESSION = new MetaIndex<>(ZombieVillagerWatcher.class, 1,
|
||||
NmsVersion.v1_14.isSupported() ? new VillagerData(Villager.Type.PLAINS, Villager.Profession.NONE, 1) :
|
||||
null);
|
||||
NmsVersion.v1_14.isSupported() ? new VillagerData(Villager.Type.PLAINS, Villager.Profession.NONE, 1) : null);
|
||||
|
||||
/**
|
||||
* Shown for villager conversion
|
||||
|
@ -660,8 +774,9 @@ public class MetaIndex<Y> {
|
|||
|
||||
private static void orderMetaIndexes() {
|
||||
for (MetaIndex flagType : values()) {
|
||||
if (flagType.getFlagWatcher() == FlagWatcher.class)
|
||||
if (flagType.getFlagWatcher() == FlagWatcher.class) {
|
||||
continue;
|
||||
}
|
||||
|
||||
flagType._index += getNoIndexes(ReflectionManager.getSuperClass(flagType.getFlagWatcher()));
|
||||
}
|
||||
|
@ -676,8 +791,9 @@ public class MetaIndex<Y> {
|
|||
HashMap<Class, Integer> maxValues = new HashMap<>();
|
||||
|
||||
for (MetaIndex type : values()) {
|
||||
if (maxValues.containsKey(type.getFlagWatcher()) && maxValues.get(type.getFlagWatcher()) > type.getIndex())
|
||||
if (maxValues.containsKey(type.getFlagWatcher()) && maxValues.get(type.getFlagWatcher()) > type.getIndex()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
maxValues.put(type.getFlagWatcher(), type.getIndex());
|
||||
}
|
||||
|
@ -689,35 +805,35 @@ public class MetaIndex<Y> {
|
|||
MetaIndex found = null;
|
||||
|
||||
for (MetaIndex type : values()) {
|
||||
if (type.getIndex() != i)
|
||||
if (type.getIndex() != i) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!ReflectionManager.isAssignableFrom(entry.getKey(), type.getFlagWatcher()))
|
||||
if (!ReflectionManager.isAssignableFrom(entry.getKey(), type.getFlagWatcher())) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (found != null) {
|
||||
DisguiseUtilities.getLogger().severe(entry.getKey().getSimpleName() +
|
||||
" has multiple FlagType's registered for the index " + i + " (" +
|
||||
type.getFlagWatcher().getSimpleName() + ", " + found.getFlagWatcher().getSimpleName() +
|
||||
")");
|
||||
DisguiseUtilities.getLogger().severe(entry.getKey().getSimpleName() + " has multiple FlagType's registered for the index " + i + " (" +
|
||||
type.getFlagWatcher().getSimpleName() + ", " + found.getFlagWatcher().getSimpleName() + ")");
|
||||
continue loop;
|
||||
}
|
||||
|
||||
found = type;
|
||||
}
|
||||
|
||||
if (found != null)
|
||||
if (found != null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
DisguiseUtilities.getLogger()
|
||||
.severe(entry.getKey().getSimpleName() + " has no FlagType registered for the index " + i);
|
||||
DisguiseUtilities.getLogger().severe(entry.getKey().getSimpleName() + " has no FlagType registered for the index " + i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return LibsMsg.META_INFO.get(getName(this), getFlagWatcher().getSimpleName(), getIndex(),
|
||||
getDefault().getClass().getSimpleName(), DisguiseUtilities.getGson().toJson(getDefault()));
|
||||
return LibsMsg.META_INFO.get(getName(this), getFlagWatcher().getSimpleName(), getIndex(), getDefault().getClass().getSimpleName(),
|
||||
DisguiseUtilities.getGson().toJson(getDefault()));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -728,15 +844,19 @@ public class MetaIndex<Y> {
|
|||
|
||||
try {
|
||||
for (Field field : MetaIndex.class.getFields()) {
|
||||
if (field.getType() != MetaIndex.class)
|
||||
if (field.getType() != MetaIndex.class) {
|
||||
continue;
|
||||
}
|
||||
|
||||
MetaIndex index = (MetaIndex) field.get(null);
|
||||
|
||||
toPrint.add(index.toString());
|
||||
try {
|
||||
toPrint.add(index.toString());
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex) {
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
|
||||
|
@ -763,11 +883,13 @@ public class MetaIndex<Y> {
|
|||
*/
|
||||
public static MetaIndex getMetaIndex(Class<? extends FlagWatcher> watcherClass, int flagNo) {
|
||||
for (MetaIndex type : values()) {
|
||||
if (type.getIndex() != flagNo)
|
||||
if (type.getIndex() != flagNo) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!ReflectionManager.isAssignableFrom(watcherClass, type.getFlagWatcher()))
|
||||
if (!ReflectionManager.isAssignableFrom(watcherClass, type.getFlagWatcher())) {
|
||||
continue;
|
||||
}
|
||||
|
||||
return type;
|
||||
}
|
||||
|
@ -783,8 +905,9 @@ public class MetaIndex<Y> {
|
|||
ArrayList<MetaIndex> list = new ArrayList<>();
|
||||
|
||||
for (MetaIndex type : values()) {
|
||||
if (type == null || !ReflectionManager.isAssignableFrom(watcherClass, type.getFlagWatcher()))
|
||||
if (type == null || !ReflectionManager.isAssignableFrom(watcherClass, type.getFlagWatcher())) {
|
||||
continue;
|
||||
}
|
||||
|
||||
list.add(type);
|
||||
}
|
||||
|
@ -798,8 +921,9 @@ public class MetaIndex<Y> {
|
|||
int found = 0;
|
||||
|
||||
for (MetaIndex type : values()) {
|
||||
if (type.getFlagWatcher() != c)
|
||||
if (type.getFlagWatcher() != c) {
|
||||
continue;
|
||||
}
|
||||
|
||||
found++;
|
||||
}
|
||||
|
@ -821,7 +945,7 @@ public class MetaIndex<Y> {
|
|||
}
|
||||
|
||||
public static MetaIndex getMetaIndexByName(String name) {
|
||||
name = name.toUpperCase();
|
||||
name = name.toUpperCase(Locale.ENGLISH);
|
||||
|
||||
try {
|
||||
for (Field field : MetaIndex.class.getFields()) {
|
||||
|
@ -831,8 +955,7 @@ public class MetaIndex<Y> {
|
|||
|
||||
return (MetaIndex) field.get(null);
|
||||
}
|
||||
}
|
||||
catch (IllegalAccessException e) {
|
||||
} catch (IllegalAccessException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
|
@ -851,8 +974,7 @@ public class MetaIndex<Y> {
|
|||
|
||||
return field.getName();
|
||||
}
|
||||
}
|
||||
catch (IllegalAccessException e) {
|
||||
} catch (IllegalAccessException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
|
@ -877,15 +999,13 @@ public class MetaIndex<Y> {
|
|||
}
|
||||
|
||||
for (MetaIndex metaIndex : values()) {
|
||||
if (metaIndex == null || metaIndex.getFlagWatcher() != index.getFlagWatcher() ||
|
||||
metaIndex.getIndex() != index.getIndex()) {
|
||||
if (metaIndex == null || metaIndex.getFlagWatcher() != index.getFlagWatcher() || metaIndex.getIndex() != index.getIndex()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
DisguiseUtilities.getLogger()
|
||||
.severe("MetaIndex " + metaIndex.getFlagWatcher().getSimpleName() + " at index " +
|
||||
metaIndex.getIndex() + " has already registered this! (" + metaIndex.getDefault() +
|
||||
"," + index.getDefault() + ")");
|
||||
DisguiseUtilities.getLogger().severe(
|
||||
"MetaIndex " + metaIndex.getFlagWatcher().getSimpleName() + " at index " + metaIndex.getIndex() + " has already registered this! (" +
|
||||
metaIndex.getDefault() + "," + index.getDefault() + ")");
|
||||
}
|
||||
|
||||
values()[i] = metaIndexes[a];
|
||||
|
@ -900,8 +1020,9 @@ public class MetaIndex<Y> {
|
|||
_values = new MetaIndex[0];
|
||||
|
||||
for (Field field : MetaIndex.class.getFields()) {
|
||||
if (field.getType() != MetaIndex.class)
|
||||
if (field.getType() != MetaIndex.class) {
|
||||
continue;
|
||||
}
|
||||
|
||||
MetaIndex index = (MetaIndex) field.get(null);
|
||||
|
||||
|
@ -910,16 +1031,16 @@ public class MetaIndex<Y> {
|
|||
continue;
|
||||
}
|
||||
|
||||
if (index == null)
|
||||
if (index == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
_values = Arrays.copyOf(_values, _values.length + 1);
|
||||
_values[_values.length - 1] = index;
|
||||
|
||||
index.serializer = DisguiseUtilities.getSerializer(index);
|
||||
}
|
||||
}
|
||||
catch (Exception e) {
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
@ -934,10 +1055,8 @@ public class MetaIndex<Y> {
|
|||
|
||||
field.set(null, metaIndex);
|
||||
return true;
|
||||
}
|
||||
catch (NoSuchFieldException ignored) {
|
||||
}
|
||||
catch (Exception ex) {
|
||||
} catch (NoSuchFieldException ignored) {
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
|
|
@ -28,8 +28,7 @@ public class MiscDisguise extends TargetedDisguise {
|
|||
super(disguiseType);
|
||||
|
||||
if (disguiseType != DisguiseType.FALLING_BLOCK && disguiseType != DisguiseType.DROPPED_ITEM) {
|
||||
throw new IllegalArgumentException(
|
||||
"This constructor requires a DROPPED_ITEM or FALLING_BLOCK disguise type!");
|
||||
throw new IllegalArgumentException("This constructor requires a DROPPED_ITEM or FALLING_BLOCK disguise type!");
|
||||
}
|
||||
|
||||
apply(0, itemStack);
|
||||
|
@ -39,8 +38,7 @@ public class MiscDisguise extends TargetedDisguise {
|
|||
super(disguiseType);
|
||||
|
||||
if (disguiseType != DisguiseType.FALLING_BLOCK && disguiseType != DisguiseType.DROPPED_ITEM) {
|
||||
throw new IllegalArgumentException(
|
||||
"This constructor requires a DROPPED_ITEM or FALLING_BLOCK disguise type!");
|
||||
throw new IllegalArgumentException("This constructor requires a DROPPED_ITEM or FALLING_BLOCK disguise type!");
|
||||
}
|
||||
|
||||
apply(0, new ItemStack(material));
|
||||
|
@ -56,9 +54,8 @@ public class MiscDisguise extends TargetedDisguise {
|
|||
|
||||
if (!disguiseType.isMisc()) {
|
||||
throw new InvalidParameterException(
|
||||
"Expected a non-living DisguiseType while constructing MiscDisguise. Received " + disguiseType +
|
||||
" instead. Please use " + (disguiseType.isPlayer() ? "PlayerDisguise" : "MobDisguise") +
|
||||
" instead");
|
||||
"Expected a non-living DisguiseType while constructing MiscDisguise. Received " + disguiseType + " instead. Please use " +
|
||||
(disguiseType.isPlayer() ? "PlayerDisguise" : "MobDisguise") + " instead");
|
||||
}
|
||||
|
||||
apply(id, new ItemStack(Material.STONE));
|
|
@ -1,6 +1,10 @@
|
|||
package me.libraryaddict.disguise.disguisetypes;
|
||||
|
||||
import me.libraryaddict.disguise.disguisetypes.watchers.*;
|
||||
import me.libraryaddict.disguise.disguisetypes.watchers.AgeableWatcher;
|
||||
import me.libraryaddict.disguise.disguisetypes.watchers.ArmorStandWatcher;
|
||||
import me.libraryaddict.disguise.disguisetypes.watchers.LivingWatcher;
|
||||
import me.libraryaddict.disguise.disguisetypes.watchers.SlimeWatcher;
|
||||
import me.libraryaddict.disguise.disguisetypes.watchers.ZombieWatcher;
|
||||
import me.libraryaddict.disguise.utilities.DisguiseValues;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Player;
|
||||
|
@ -19,9 +23,8 @@ public class MobDisguise extends TargetedDisguise {
|
|||
|
||||
if (!disguiseType.isMob()) {
|
||||
throw new InvalidParameterException(
|
||||
"Expected a living DisguiseType while constructing MobDisguise. Received " + disguiseType +
|
||||
" instead. Please use " + (disguiseType.isPlayer() ? "PlayerDisguise" : "MiscDisguise") +
|
||||
" instead");
|
||||
"Expected a living DisguiseType while constructing MobDisguise. Received " + disguiseType + " instead. Please use " +
|
||||
(disguiseType.isPlayer() ? "PlayerDisguise" : "MiscDisguise") + " instead");
|
||||
}
|
||||
|
||||
this.isAdult = isAdult;
|
||||
|
@ -43,8 +46,7 @@ public class MobDisguise extends TargetedDisguise {
|
|||
|
||||
if (getWatcher() != null) {
|
||||
if (getType() == DisguiseType.ARMOR_STAND) {
|
||||
return (((ArmorStandWatcher) getWatcher()).isSmall() ? values.getBabyBox() : values.getAdultBox())
|
||||
.getY();
|
||||
return (((ArmorStandWatcher) getWatcher()).isSmall() ? values.getBabyBox() : values.getAdultBox()).getY();
|
||||
} else if (getType() == DisguiseType.SLIME || getType() == DisguiseType.MAGMA_CUBE) {
|
||||
return 0.51 * (0.255 * ((SlimeWatcher) getWatcher()).getSize());
|
||||
}
|
||||
|
@ -73,8 +75,7 @@ public class MobDisguise extends TargetedDisguise {
|
|||
}
|
||||
|
||||
public boolean doesDisguiseAge() {
|
||||
return getWatcher() != null &&
|
||||
(getWatcher() instanceof AgeableWatcher || getWatcher() instanceof ZombieWatcher);
|
||||
return getWatcher() != null && (getWatcher() instanceof AgeableWatcher || getWatcher() instanceof ZombieWatcher);
|
||||
}
|
||||
|
||||
@Override
|
|
@ -31,8 +31,7 @@ public class ModdedDisguise extends TargetedDisguise {
|
|||
super(disguiseType);
|
||||
|
||||
if (disguiseType != DisguiseType.UNKNOWN) {
|
||||
throw new InvalidParameterException(
|
||||
"CustomDisguise is only for DisguiseType.MODDED_LIVING/MISC and DisguiseType.UNKNOWN");
|
||||
throw new InvalidParameterException("CustomDisguise is only for DisguiseType.MODDED_LIVING/MISC and DisguiseType.UNKNOWN");
|
||||
}
|
||||
|
||||
createDisguise();
|
|
@ -4,19 +4,21 @@ import com.comphenix.protocol.ProtocolLibrary;
|
|||
import com.comphenix.protocol.events.PacketContainer;
|
||||
import com.comphenix.protocol.wrappers.EnumWrappers.PlayerInfoAction;
|
||||
import com.comphenix.protocol.wrappers.WrappedGameProfile;
|
||||
import lombok.Getter;
|
||||
import me.libraryaddict.disguise.DisguiseConfig;
|
||||
import me.libraryaddict.disguise.LibsDisguises;
|
||||
import me.libraryaddict.disguise.disguisetypes.watchers.PlayerWatcher;
|
||||
import me.libraryaddict.disguise.utilities.DisguiseUtilities;
|
||||
import me.libraryaddict.disguise.utilities.reflection.LibsProfileLookup;
|
||||
import me.libraryaddict.disguise.utilities.reflection.NmsVersion;
|
||||
import me.libraryaddict.disguise.utilities.reflection.ReflectionManager;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.util.UUID;
|
||||
|
||||
public class PlayerDisguise extends TargetedDisguise {
|
||||
private transient LibsProfileLookup currentLookup;
|
||||
|
@ -28,8 +30,9 @@ public class PlayerDisguise extends TargetedDisguise {
|
|||
* Has someone set name visible explicitly?
|
||||
*/
|
||||
private boolean explicitNameVisible = false;
|
||||
private UUID uuid = UUID.randomUUID();
|
||||
private volatile DisguiseUtilities.DScoreTeam scoreboardName;
|
||||
private transient DisguiseUtilities.DScoreTeam scoreboardName;
|
||||
@Getter
|
||||
private boolean deadmau5Ears;
|
||||
|
||||
private PlayerDisguise() {
|
||||
super(DisguiseType.PLAYER);
|
||||
|
@ -50,6 +53,17 @@ public class PlayerDisguise extends TargetedDisguise {
|
|||
public PlayerDisguise(String name, String skinToUse) {
|
||||
this();
|
||||
|
||||
if (name.equals(skinToUse)) {
|
||||
WrappedGameProfile profile = getProfile(skinToUse);
|
||||
|
||||
if (profile != null) {
|
||||
setName(profile.getName());
|
||||
setSkin(profile);
|
||||
createDisguise();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
setName(name);
|
||||
setSkin(skinToUse);
|
||||
|
||||
|
@ -61,7 +75,7 @@ public class PlayerDisguise extends TargetedDisguise {
|
|||
|
||||
setName(gameProfile.getName());
|
||||
|
||||
this.gameProfile = ReflectionManager.getGameProfileWithThisSkin(uuid, gameProfile.getName(), gameProfile);
|
||||
this.gameProfile = ReflectionManager.getGameProfileWithThisSkin(getUUID(), gameProfile.getName(), gameProfile);
|
||||
|
||||
createDisguise();
|
||||
}
|
||||
|
@ -71,7 +85,7 @@ public class PlayerDisguise extends TargetedDisguise {
|
|||
|
||||
setName(gameProfile.getName());
|
||||
|
||||
this.gameProfile = ReflectionManager.getGameProfile(uuid, gameProfile.getName());
|
||||
this.gameProfile = ReflectionManager.getGameProfile(getUUID(), gameProfile.getName());
|
||||
|
||||
setSkin(skinToUse);
|
||||
|
||||
|
@ -98,10 +112,10 @@ public class PlayerDisguise extends TargetedDisguise {
|
|||
}
|
||||
|
||||
if (scoreboardName == null) {
|
||||
if (isUpsideDown()) {
|
||||
scoreboardName = new DisguiseUtilities.DScoreTeam(new String[]{"", getProfileName(), ""});
|
||||
if (isUpsideDown() || isDeadmau5Ears()) {
|
||||
scoreboardName = new DisguiseUtilities.DScoreTeam(this, new String[]{"", getProfileName(), ""});
|
||||
} else {
|
||||
scoreboardName = DisguiseUtilities.createExtendedName(getName());
|
||||
scoreboardName = DisguiseUtilities.createExtendedName(this);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -109,7 +123,7 @@ public class PlayerDisguise extends TargetedDisguise {
|
|||
}
|
||||
|
||||
private void setScoreboardName(String[] split) {
|
||||
if (isUpsideDown()) {
|
||||
if (isUpsideDown() || isDeadmau5Ears()) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -128,12 +142,12 @@ public class PlayerDisguise extends TargetedDisguise {
|
|||
return DisguiseConfig.isScoreboardNames();
|
||||
}
|
||||
|
||||
/**
|
||||
* The actual name that'll be sent in the game profile, not the name that they're known as
|
||||
*/
|
||||
public String getProfileName() {
|
||||
return isUpsideDown() ? "Dinnerbone" : hasScoreboardName() ? getScoreboardName().getPlayer() : getName();
|
||||
}
|
||||
|
||||
public UUID getUUID() {
|
||||
return uuid;
|
||||
return isUpsideDown() ? "Dinnerbone" :
|
||||
isDeadmau5Ears() ? "deadmau5" : hasScoreboardName() ? getScoreboardName().getPlayer() : getName().isEmpty() ? "§r" : getName();
|
||||
}
|
||||
|
||||
public boolean isNameVisible() {
|
||||
|
@ -158,7 +172,7 @@ public class PlayerDisguise extends TargetedDisguise {
|
|||
this.nameVisible = nameVisible;
|
||||
sendArmorStands(isNameVisible() ? DisguiseUtilities.reverse(getMultiName()) : new String[0]);
|
||||
} else if (!DisguiseConfig.isScoreboardNames()) {
|
||||
if (stopDisguise()) {
|
||||
if (removeDisguise()) {
|
||||
this.nameVisible = nameVisible;
|
||||
|
||||
if (!startDisguise()) {
|
||||
|
@ -204,6 +218,22 @@ public class PlayerDisguise extends TargetedDisguise {
|
|||
return this;
|
||||
}
|
||||
|
||||
public PlayerDisguise setDeadmau5Ears(boolean deadmau5Ears) {
|
||||
if (deadmau5Ears == isDeadmau5Ears()) {
|
||||
return this;
|
||||
}
|
||||
|
||||
this.deadmau5Ears = deadmau5Ears;
|
||||
|
||||
if (isDisguiseInUse()) {
|
||||
resendDisguise(DisguiseConfig.isArmorstandsName() ? getName() : "deadmau5", true);
|
||||
} else {
|
||||
scoreboardName = null;
|
||||
}
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PlayerDisguise clone() {
|
||||
PlayerDisguise disguise = new PlayerDisguise();
|
||||
|
@ -214,8 +244,7 @@ public class PlayerDisguise extends TargetedDisguise {
|
|||
|
||||
if (currentLookup == null && gameProfile != null) {
|
||||
disguise.skinToUse = getSkin();
|
||||
disguise.gameProfile = ReflectionManager
|
||||
.getGameProfileWithThisSkin(disguise.uuid, getGameProfile().getName(), getGameProfile());
|
||||
disguise.gameProfile = ReflectionManager.getGameProfileWithThisSkin(disguise.getUUID(), getGameProfile().getName(), getGameProfile());
|
||||
} else {
|
||||
disguise.setSkin(getSkin());
|
||||
}
|
||||
|
@ -224,6 +253,7 @@ public class PlayerDisguise extends TargetedDisguise {
|
|||
disguise.nameVisible = isNameVisible();
|
||||
disguise.explicitNameVisible = explicitNameVisible;
|
||||
disguise.setUpsideDown(isUpsideDown());
|
||||
disguise.setDeadmau5Ears(isDeadmau5Ears());
|
||||
|
||||
clone(disguise);
|
||||
|
||||
|
@ -233,10 +263,9 @@ public class PlayerDisguise extends TargetedDisguise {
|
|||
public WrappedGameProfile getGameProfile() {
|
||||
if (gameProfile == null) {
|
||||
if (getSkin() != null) {
|
||||
gameProfile = ReflectionManager.getGameProfile(uuid, getProfileName());
|
||||
gameProfile = ReflectionManager.getGameProfile(getUUID(), getProfileName());
|
||||
} else {
|
||||
gameProfile = ReflectionManager.getGameProfileWithThisSkin(uuid, getProfileName(),
|
||||
DisguiseUtilities.getProfileFromMojang(this));
|
||||
gameProfile = ReflectionManager.getGameProfileWithThisSkin(getUUID(), getProfileName(), DisguiseUtilities.getProfileFromMojang(this));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -244,7 +273,7 @@ public class PlayerDisguise extends TargetedDisguise {
|
|||
}
|
||||
|
||||
public void setGameProfile(WrappedGameProfile gameProfile) {
|
||||
this.gameProfile = ReflectionManager.getGameProfileWithThisSkin(uuid, gameProfile.getName(), gameProfile);
|
||||
this.gameProfile = ReflectionManager.getGameProfileWithThisSkin(getUUID(), gameProfile.getName(), gameProfile);
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
|
@ -260,6 +289,13 @@ public class PlayerDisguise extends TargetedDisguise {
|
|||
}
|
||||
}
|
||||
|
||||
if (DisguiseConfig.isCopyPlayerTeamInfo() && (DisguiseConfig.getPlayerNameType() == DisguiseConfig.PlayerNameType.TEAMS ||
|
||||
DisguiseConfig.getPlayerNameType() == DisguiseConfig.PlayerNameType.ARMORSTANDS)) {
|
||||
name = DisguiseUtilities.getDisplayName(name);
|
||||
}
|
||||
|
||||
name = DisguiseUtilities.getHexedColors(name);
|
||||
|
||||
if (name.equals(playerName)) {
|
||||
return;
|
||||
}
|
||||
|
@ -268,10 +304,10 @@ public class PlayerDisguise extends TargetedDisguise {
|
|||
|
||||
switch (DisguiseConfig.getPlayerNameType()) {
|
||||
case TEAMS:
|
||||
cLimit = 16 * 2;
|
||||
cLimit = (NmsVersion.v1_13.isSupported() ? 64 : 16) * 2;
|
||||
break;
|
||||
case EXTENDED:
|
||||
cLimit = 16 * 3;
|
||||
cLimit = ((NmsVersion.v1_13.isSupported() ? 64 : 16) * 2) + 16;
|
||||
break;
|
||||
case ARMORSTANDS:
|
||||
cLimit = 256;
|
||||
|
@ -302,8 +338,7 @@ public class PlayerDisguise extends TargetedDisguise {
|
|||
setScoreboardName(split);
|
||||
}
|
||||
|
||||
resendDisguise = !DisguiseConfig.isScoreboardNames() || isStaticName(name) || isStaticName(getName()) ||
|
||||
resendDisguise;
|
||||
resendDisguise = !DisguiseConfig.isScoreboardNames() || isStaticName(name) || isStaticName(getName()) || resendDisguise;
|
||||
|
||||
if (resendDisguise) {
|
||||
resendDisguise(name, false);
|
||||
|
@ -325,13 +360,13 @@ public class PlayerDisguise extends TargetedDisguise {
|
|||
|
||||
try {
|
||||
for (Player player : Bukkit.getOnlinePlayers()) {
|
||||
if (!canSee(player))
|
||||
if (!canSee(player)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
ProtocolLibrary.getProtocolManager().sendServerPacket(player, addTab);
|
||||
}
|
||||
}
|
||||
catch (InvocationTargetException e) {
|
||||
} catch (InvocationTargetException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
@ -351,13 +386,13 @@ public class PlayerDisguise extends TargetedDisguise {
|
|||
playerName = name;
|
||||
|
||||
if (gameProfile != null) {
|
||||
gameProfile = ReflectionManager.getGameProfileWithThisSkin(uuid, getProfileName(), getGameProfile());
|
||||
gameProfile = ReflectionManager.getGameProfileWithThisSkin(getUUID(), getProfileName(), getGameProfile());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void resendDisguise(String name, boolean updateTeams) {
|
||||
if (stopDisguise()) {
|
||||
if (removeDisguise()) {
|
||||
if (getName().isEmpty() && !name.isEmpty()) {
|
||||
setNameVisible(true, true);
|
||||
} else if (!getName().isEmpty() && name.isEmpty()) {
|
||||
|
@ -371,7 +406,7 @@ public class PlayerDisguise extends TargetedDisguise {
|
|||
}
|
||||
|
||||
if (gameProfile != null) {
|
||||
gameProfile = ReflectionManager.getGameProfileWithThisSkin(uuid, getProfileName(), getGameProfile());
|
||||
gameProfile = ReflectionManager.getGameProfileWithThisSkin(getUUID(), getProfileName(), getGameProfile());
|
||||
}
|
||||
|
||||
if (!startDisguise()) {
|
||||
|
@ -387,17 +422,10 @@ public class PlayerDisguise extends TargetedDisguise {
|
|||
}
|
||||
|
||||
public PlayerDisguise setSkin(String newSkin) {
|
||||
if (newSkin != null && newSkin.length() > 70 && newSkin.startsWith("{") && newSkin.endsWith("}")) {
|
||||
try {
|
||||
return setSkin(DisguiseUtilities.getGson().fromJson(newSkin, WrappedGameProfile.class));
|
||||
}
|
||||
catch (Exception ex) {
|
||||
if (!"12345".equals("%%__USER__%%")) {
|
||||
throw new IllegalArgumentException(String.format(
|
||||
"The skin %s is too long to normally be a playername, but cannot be parsed to a " +
|
||||
"GameProfile!", newSkin));
|
||||
}
|
||||
}
|
||||
WrappedGameProfile profile = getProfile(newSkin);
|
||||
|
||||
if (profile != null) {
|
||||
return setSkin(profile);
|
||||
}
|
||||
|
||||
if (newSkin != null) {
|
||||
|
@ -431,8 +459,9 @@ public class PlayerDisguise extends TargetedDisguise {
|
|||
currentLookup = new LibsProfileLookup() {
|
||||
@Override
|
||||
public void onLookup(WrappedGameProfile gameProfile) {
|
||||
if (currentLookup != this || gameProfile == null || gameProfile.getProperties().isEmpty())
|
||||
if (currentLookup != this || gameProfile == null || gameProfile.getProperties().isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
setSkin(gameProfile);
|
||||
|
||||
|
@ -440,8 +469,7 @@ public class PlayerDisguise extends TargetedDisguise {
|
|||
}
|
||||
};
|
||||
|
||||
WrappedGameProfile gameProfile = DisguiseUtilities.getProfileFromMojang(this.skinToUse, currentLookup,
|
||||
LibsDisguises.getInstance().getConfig().getBoolean("ContactMojangServers", true));
|
||||
WrappedGameProfile gameProfile = DisguiseUtilities.getProfileFromMojang(this.skinToUse, currentLookup, DisguiseConfig.isContactMojangServers());
|
||||
|
||||
if (gameProfile != null) {
|
||||
setSkin(gameProfile);
|
||||
|
@ -468,37 +496,51 @@ public class PlayerDisguise extends TargetedDisguise {
|
|||
currentLookup = null;
|
||||
|
||||
this.skinToUse = gameProfile.getName();
|
||||
this.gameProfile = ReflectionManager.getGameProfileWithThisSkin(uuid, getProfileName(), gameProfile);
|
||||
this.gameProfile = ReflectionManager.getGameProfileWithThisSkin(getUUID(), getProfileName(), gameProfile);
|
||||
|
||||
refreshDisguise();
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
private void refreshDisguise() {
|
||||
if (DisguiseUtilities.isDisguiseInUse(this)) {
|
||||
if (isDisplayedInTab()) {
|
||||
PacketContainer addTab = DisguiseUtilities.getTabPacket(this, PlayerInfoAction.ADD_PLAYER);
|
||||
|
||||
PacketContainer deleteTab = addTab.shallowClone();
|
||||
deleteTab.getPlayerInfoAction().write(0, PlayerInfoAction.REMOVE_PLAYER);
|
||||
|
||||
try {
|
||||
for (Player player : Bukkit.getOnlinePlayers()) {
|
||||
if (!canSee(player))
|
||||
continue;
|
||||
|
||||
ProtocolLibrary.getProtocolManager().sendServerPacket(player, deleteTab);
|
||||
ProtocolLibrary.getProtocolManager().sendServerPacket(player, addTab);
|
||||
}
|
||||
}
|
||||
catch (InvocationTargetException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
private WrappedGameProfile getProfile(String string) {
|
||||
if (string != null && string.length() > 70 && string.startsWith("{\"id\":") && string.endsWith("}") && string.contains(",\"name\":")) {
|
||||
try {
|
||||
return DisguiseUtilities.getGson().fromJson(string, WrappedGameProfile.class);
|
||||
} catch (Exception ex) {
|
||||
throw new IllegalStateException("Tried to parse " + string + " to a GameProfile, but it has been formatted incorrectly!");
|
||||
}
|
||||
|
||||
DisguiseUtilities.refreshTrackers(this);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private void refreshDisguise() {
|
||||
if (!DisguiseUtilities.isDisguiseInUse(this)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (isDisplayedInTab()) {
|
||||
PacketContainer addTab = DisguiseUtilities.getTabPacket(this, PlayerInfoAction.ADD_PLAYER);
|
||||
|
||||
PacketContainer deleteTab = addTab.shallowClone();
|
||||
deleteTab.getPlayerInfoAction().write(0, PlayerInfoAction.REMOVE_PLAYER);
|
||||
|
||||
try {
|
||||
for (Player player : Bukkit.getOnlinePlayers()) {
|
||||
if (!canSee(player)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
ProtocolLibrary.getProtocolManager().sendServerPacket(player, deleteTab);
|
||||
ProtocolLibrary.getProtocolManager().sendServerPacket(player, addTab);
|
||||
}
|
||||
} catch (InvocationTargetException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
DisguiseUtilities.refreshTrackers(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -576,6 +618,11 @@ public class PlayerDisguise extends TargetedDisguise {
|
|||
|
||||
@Override
|
||||
public boolean startDisguise() {
|
||||
return startDisguise(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean startDisguise(CommandSender sender) {
|
||||
if (isDisguiseInUse()) {
|
||||
return false;
|
||||
}
|
||||
|
@ -584,8 +631,9 @@ public class PlayerDisguise extends TargetedDisguise {
|
|||
currentLookup = new LibsProfileLookup() {
|
||||
@Override
|
||||
public void onLookup(WrappedGameProfile gameProfile) {
|
||||
if (currentLookup != this || gameProfile == null || gameProfile.getProperties().isEmpty())
|
||||
if (currentLookup != this || gameProfile == null || gameProfile.getProperties().isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
setSkin(gameProfile);
|
||||
|
||||
|
@ -593,8 +641,7 @@ public class PlayerDisguise extends TargetedDisguise {
|
|||
}
|
||||
};
|
||||
|
||||
WrappedGameProfile gameProfile = DisguiseUtilities.getProfileFromMojang(this.skinToUse, currentLookup,
|
||||
LibsDisguises.getInstance().getConfig().getBoolean("ContactMojangServers", true));
|
||||
WrappedGameProfile gameProfile = DisguiseUtilities.getProfileFromMojang(this.skinToUse, currentLookup, DisguiseConfig.isContactMojangServers());
|
||||
|
||||
if (gameProfile != null) {
|
||||
setSkin(gameProfile);
|
||||
|
@ -602,7 +649,13 @@ public class PlayerDisguise extends TargetedDisguise {
|
|||
}
|
||||
|
||||
if (isDynamicName()) {
|
||||
String name = getEntity().getCustomName();
|
||||
String name;
|
||||
|
||||
if (getEntity() instanceof Player) {
|
||||
name = DisguiseUtilities.translateAlternateColorCodes(DisguiseUtilities.getDisplayName(getEntity()));
|
||||
} else {
|
||||
name = getEntity().getCustomName();
|
||||
}
|
||||
|
||||
if (name == null) {
|
||||
name = "";
|
||||
|
@ -621,7 +674,7 @@ public class PlayerDisguise extends TargetedDisguise {
|
|||
setName(name);
|
||||
}
|
||||
|
||||
boolean result = super.startDisguise();
|
||||
boolean result = super.startDisguise(sender);
|
||||
|
||||
if (result && hasScoreboardName()) {
|
||||
DisguiseUtilities.registerExtendedName(this);
|
||||
|
@ -654,7 +707,11 @@ public class PlayerDisguise extends TargetedDisguise {
|
|||
public boolean removeDisguise(boolean disguiseBeingReplaced) {
|
||||
boolean result = super.removeDisguise(disguiseBeingReplaced);
|
||||
|
||||
if (result && hasScoreboardName()) {
|
||||
if (!result) {
|
||||
return result;
|
||||
}
|
||||
|
||||
if (hasScoreboardName()) {
|
||||
if (disguiseBeingReplaced) {
|
||||
new BukkitRunnable() {
|
||||
@Override
|
|
@ -1,7 +1,13 @@
|
|||
package me.libraryaddict.disguise.disguisetypes;
|
||||
|
||||
public enum RabbitType {
|
||||
BLACK(2), BROWN(0), GOLD(4), KILLER_BUNNY(99), PATCHES(3), PEPPER(5), WHITE(1);
|
||||
BLACK(2),
|
||||
BROWN(0),
|
||||
GOLD(4),
|
||||
KILLER_BUNNY(99),
|
||||
PATCHES(3),
|
||||
PEPPER(5),
|
||||
WHITE(1);
|
||||
|
||||
public static RabbitType getType(int id) {
|
||||
for (RabbitType type : values()) {
|
|
@ -62,17 +62,14 @@ public abstract class TargetedDisguise extends Disguise {
|
|||
if (player != null) {
|
||||
PacketContainer deleteTab = new PacketContainer(PacketType.Play.Server.PLAYER_INFO);
|
||||
|
||||
deleteTab.getPlayerInfoAction().write(0,
|
||||
canSee(player) ? PlayerInfoAction.REMOVE_PLAYER : PlayerInfoAction.ADD_PLAYER);
|
||||
deleteTab.getPlayerInfoAction().write(0, canSee(player) ? PlayerInfoAction.REMOVE_PLAYER : PlayerInfoAction.ADD_PLAYER);
|
||||
deleteTab.getPlayerInfoDataLists().write(0, Arrays.asList(
|
||||
new PlayerInfoData(ReflectionManager.getGameProfile((Player) getEntity()), 0,
|
||||
NativeGameMode.SURVIVAL, WrappedChatComponent
|
||||
.fromText(DisguiseUtilities.getPlayerListName((Player) getEntity())))));
|
||||
new PlayerInfoData(ReflectionManager.getGameProfile((Player) getEntity()), 0, NativeGameMode.SURVIVAL,
|
||||
WrappedChatComponent.fromText(DisguiseUtilities.getPlayerListName((Player) getEntity())))));
|
||||
|
||||
ProtocolLibrary.getProtocolManager().sendServerPacket(player, deleteTab);
|
||||
}
|
||||
}
|
||||
catch (InvocationTargetException e) {
|
||||
} catch (InvocationTargetException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
@ -135,17 +132,14 @@ public abstract class TargetedDisguise extends Disguise {
|
|||
if (player != null) {
|
||||
PacketContainer deleteTab = new PacketContainer(PacketType.Play.Server.PLAYER_INFO);
|
||||
|
||||
deleteTab.getPlayerInfoAction().write(0,
|
||||
canSee(player) ? PlayerInfoAction.ADD_PLAYER : PlayerInfoAction.REMOVE_PLAYER);
|
||||
deleteTab.getPlayerInfoAction().write(0, canSee(player) ? PlayerInfoAction.ADD_PLAYER : PlayerInfoAction.REMOVE_PLAYER);
|
||||
deleteTab.getPlayerInfoDataLists().write(0, Arrays.asList(
|
||||
new PlayerInfoData(ReflectionManager.getGameProfile((Player) getEntity()), 0,
|
||||
NativeGameMode.SURVIVAL, WrappedChatComponent
|
||||
.fromText(DisguiseUtilities.getPlayerListName((Player) getEntity())))));
|
||||
new PlayerInfoData(ReflectionManager.getGameProfile((Player) getEntity()), 0, NativeGameMode.SURVIVAL,
|
||||
WrappedChatComponent.fromText(DisguiseUtilities.getPlayerListName((Player) getEntity())))));
|
||||
|
||||
ProtocolLibrary.getProtocolManager().sendServerPacket(player, deleteTab);
|
||||
}
|
||||
}
|
||||
catch (InvocationTargetException e) {
|
||||
} catch (InvocationTargetException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
|
@ -1,28 +1,28 @@
|
|||
package me.libraryaddict.disguise.disguisetypes.watchers;
|
||||
|
||||
import me.libraryaddict.disguise.disguisetypes.Disguise;
|
||||
import me.libraryaddict.disguise.disguisetypes.MetaIndex;
|
||||
import me.libraryaddict.disguise.utilities.reflection.NmsRemovedIn;
|
||||
import me.libraryaddict.disguise.utilities.reflection.NmsVersion;
|
||||
|
||||
/**
|
||||
* @author Navid
|
||||
*/
|
||||
public class SkeletonWatcher extends InsentientWatcher {
|
||||
public SkeletonWatcher(Disguise disguise) {
|
||||
super(disguise);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
@NmsRemovedIn(val = NmsVersion.v1_14)
|
||||
public boolean isSwingArms() {
|
||||
return getData(MetaIndex.SKELETON_SWING_ARMS);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
@NmsRemovedIn(val = NmsVersion.v1_14)
|
||||
public void setSwingArms(boolean swingingArms) {
|
||||
setData(MetaIndex.SKELETON_SWING_ARMS, swingingArms);
|
||||
sendData(MetaIndex.SKELETON_SWING_ARMS);
|
||||
}
|
||||
}
|
||||
package me.libraryaddict.disguise.disguisetypes.watchers;
|
||||
|
||||
import me.libraryaddict.disguise.disguisetypes.Disguise;
|
||||
import me.libraryaddict.disguise.disguisetypes.MetaIndex;
|
||||
import me.libraryaddict.disguise.utilities.reflection.annotations.NmsRemovedIn;
|
||||
import me.libraryaddict.disguise.utilities.reflection.NmsVersion;
|
||||
|
||||
/**
|
||||
* @author Navid
|
||||
*/
|
||||
public abstract class AbstractSkeletonWatcher extends InsentientWatcher {
|
||||
public AbstractSkeletonWatcher(Disguise disguise) {
|
||||
super(disguise);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
@NmsRemovedIn(NmsVersion.v1_14)
|
||||
public boolean isSwingArms() {
|
||||
return getData(MetaIndex.SKELETON_SWING_ARMS);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
@NmsRemovedIn(NmsVersion.v1_14)
|
||||
public void setSwingArms(boolean swingingArms) {
|
||||
setData(MetaIndex.SKELETON_SWING_ARMS, swingingArms);
|
||||
sendData(MetaIndex.SKELETON_SWING_ARMS);
|
||||
}
|
||||
}
|
|
@ -2,7 +2,7 @@ package me.libraryaddict.disguise.disguisetypes.watchers;
|
|||
|
||||
import me.libraryaddict.disguise.disguisetypes.Disguise;
|
||||
import me.libraryaddict.disguise.disguisetypes.MetaIndex;
|
||||
import me.libraryaddict.disguise.utilities.reflection.NmsAddedIn;
|
||||
import me.libraryaddict.disguise.utilities.reflection.annotations.NmsAddedIn;
|
||||
import me.libraryaddict.disguise.utilities.reflection.NmsVersion;
|
||||
|
||||
/**
|
||||
|
@ -13,17 +13,17 @@ public class AbstractVillagerWatcher extends AgeableWatcher {
|
|||
super(disguise);
|
||||
}
|
||||
|
||||
@NmsAddedIn(val = NmsVersion.v1_14)
|
||||
@NmsAddedIn(NmsVersion.v1_14)
|
||||
public int getAngry() {
|
||||
return getData(MetaIndex.ABSTRACT_VILLAGER_ANGRY);
|
||||
}
|
||||
|
||||
@NmsAddedIn(val = NmsVersion.v1_14)
|
||||
@NmsAddedIn(NmsVersion.v1_14)
|
||||
public boolean isAngry() {
|
||||
return getAngry() > 0;
|
||||
}
|
||||
|
||||
@NmsAddedIn(val = NmsVersion.v1_14)
|
||||
@NmsAddedIn(NmsVersion.v1_14)
|
||||
public void setAngry(int ticks) {
|
||||
setData(MetaIndex.ABSTRACT_VILLAGER_ANGRY, ticks);
|
||||
sendData(MetaIndex.ABSTRACT_VILLAGER_ANGRY);
|
|
@ -3,36 +3,29 @@ package me.libraryaddict.disguise.disguisetypes.watchers;
|
|||
import me.libraryaddict.disguise.disguisetypes.Disguise;
|
||||
import me.libraryaddict.disguise.disguisetypes.MetaIndex;
|
||||
|
||||
public class AgeableWatcher extends InsentientWatcher
|
||||
{
|
||||
public AgeableWatcher(Disguise disguise)
|
||||
{
|
||||
public class AgeableWatcher extends InsentientWatcher {
|
||||
public AgeableWatcher(Disguise disguise) {
|
||||
super(disguise);
|
||||
}
|
||||
|
||||
public boolean isAdult()
|
||||
{
|
||||
public boolean isAdult() {
|
||||
return !isBaby();
|
||||
}
|
||||
|
||||
public boolean isBaby()
|
||||
{
|
||||
public boolean isBaby() {
|
||||
return getData(MetaIndex.AGEABLE_BABY);
|
||||
}
|
||||
|
||||
public void setAdult()
|
||||
{
|
||||
setBaby(false);
|
||||
}
|
||||
|
||||
public void setBaby()
|
||||
{
|
||||
setBaby(true);
|
||||
}
|
||||
|
||||
public void setBaby(boolean isBaby)
|
||||
{
|
||||
public void setBaby(boolean isBaby) {
|
||||
setData(MetaIndex.AGEABLE_BABY, isBaby);
|
||||
sendData(MetaIndex.AGEABLE_BABY);
|
||||
}
|
||||
|
||||
public void setAdult() {
|
||||
setBaby(false);
|
||||
}
|
||||
|
||||
public void setBaby() {
|
||||
setBaby(true);
|
||||
}
|
||||
}
|
|
@ -6,7 +6,7 @@ import me.libraryaddict.disguise.disguisetypes.Disguise;
|
|||
import me.libraryaddict.disguise.disguisetypes.FlagWatcher;
|
||||
import me.libraryaddict.disguise.disguisetypes.MetaIndex;
|
||||
import me.libraryaddict.disguise.utilities.parser.RandomDefaultValue;
|
||||
import me.libraryaddict.disguise.utilities.reflection.NmsAddedIn;
|
||||
import me.libraryaddict.disguise.utilities.reflection.annotations.NmsAddedIn;
|
||||
import me.libraryaddict.disguise.utilities.reflection.NmsVersion;
|
||||
import org.apache.commons.lang.math.RandomUtils;
|
||||
import org.bukkit.Color;
|
||||
|
@ -30,8 +30,11 @@ public class AreaEffectCloudWatcher extends FlagWatcher {
|
|||
}
|
||||
|
||||
public void setRadius(float radius) {
|
||||
if (radius > 30)
|
||||
if (radius > 30) {
|
||||
radius = 30;
|
||||
} else if (radius < 0.1) {
|
||||
radius = 0.1f;
|
||||
}
|
||||
|
||||
setData(MetaIndex.AREA_EFFECT_RADIUS, radius);
|
||||
sendData(MetaIndex.AREA_EFFECT_RADIUS);
|
||||
|
@ -57,12 +60,12 @@ public class AreaEffectCloudWatcher extends FlagWatcher {
|
|||
sendData(MetaIndex.AREA_EFFECT_IGNORE_RADIUS);
|
||||
}
|
||||
|
||||
@NmsAddedIn(val = NmsVersion.v1_13)
|
||||
@NmsAddedIn(NmsVersion.v1_13)
|
||||
public <T> void setParticle(Particle particle, T particleData) {
|
||||
setParticle(WrappedParticle.create(particle, particleData));
|
||||
}
|
||||
|
||||
@NmsAddedIn(val = NmsVersion.v1_13)
|
||||
@NmsAddedIn(NmsVersion.v1_13)
|
||||
public WrappedParticle getParticle() {
|
||||
if (NmsVersion.v1_13.isSupported()) {
|
||||
return getData(MetaIndex.AREA_EFFECT_PARTICLE);
|
||||
|
@ -75,7 +78,7 @@ public class AreaEffectCloudWatcher extends FlagWatcher {
|
|||
}
|
||||
}
|
||||
|
||||
@NmsAddedIn(val = NmsVersion.v1_13)
|
||||
@NmsAddedIn(NmsVersion.v1_13)
|
||||
public void setParticle(WrappedParticle particle) {
|
||||
if (NmsVersion.v1_13.isSupported()) {
|
||||
setData(MetaIndex.AREA_EFFECT_PARTICLE, particle);
|
|
@ -31,8 +31,9 @@ public class ArmorStandWatcher extends LivingWatcher {
|
|||
}
|
||||
|
||||
private EulerAngle getPose(MetaIndex<Vector3F> type) {
|
||||
if (!hasValue(type))
|
||||
if (!hasValue(type)) {
|
||||
return new EulerAngle(0, 0, 0);
|
||||
}
|
||||
|
||||
Vector3F vec = getData(type);
|
||||
|
||||
|
@ -48,7 +49,7 @@ public class ArmorStandWatcher extends LivingWatcher {
|
|||
}
|
||||
|
||||
public boolean isMarker() {
|
||||
return getArmorStandFlag(10);
|
||||
return getArmorStandFlag(16);
|
||||
}
|
||||
|
||||
public boolean isNoBasePlate() {
|
|
@ -3,7 +3,7 @@ package me.libraryaddict.disguise.disguisetypes.watchers;
|
|||
import me.libraryaddict.disguise.disguisetypes.Disguise;
|
||||
import me.libraryaddict.disguise.disguisetypes.FlagWatcher;
|
||||
import me.libraryaddict.disguise.disguisetypes.MetaIndex;
|
||||
import me.libraryaddict.disguise.utilities.reflection.NmsAddedIn;
|
||||
import me.libraryaddict.disguise.utilities.reflection.annotations.NmsAddedIn;
|
||||
import me.libraryaddict.disguise.utilities.reflection.NmsVersion;
|
||||
|
||||
public class ArrowWatcher extends FlagWatcher {
|
||||
|
@ -20,12 +20,12 @@ public class ArrowWatcher extends FlagWatcher {
|
|||
sendData(MetaIndex.ARROW_CRITICAL);
|
||||
}
|
||||
|
||||
@NmsAddedIn(val = NmsVersion.v1_14)
|
||||
@NmsAddedIn(NmsVersion.v1_14)
|
||||
public int getPierceLevel() {
|
||||
return getData(MetaIndex.ARROW_PIERCE_LEVEL);
|
||||
}
|
||||
|
||||
@NmsAddedIn(val = NmsVersion.v1_14)
|
||||
@NmsAddedIn(NmsVersion.v1_14)
|
||||
public void setPierceLevel(int pierceLevel) {
|
||||
setData(MetaIndex.ARROW_PIERCE_LEVEL, (byte) pierceLevel);
|
||||
sendData(MetaIndex.ARROW_PIERCE_LEVEL);
|
|
@ -0,0 +1,32 @@
|
|||
package me.libraryaddict.disguise.disguisetypes.watchers;
|
||||
|
||||
import me.libraryaddict.disguise.disguisetypes.Disguise;
|
||||
import me.libraryaddict.disguise.disguisetypes.MetaIndex;
|
||||
import org.bukkit.entity.Axolotl;
|
||||
|
||||
/**
|
||||
* Created by libraryaddict on 15/06/2021.
|
||||
*/
|
||||
public class AxolotlWatcher extends AgeableWatcher {
|
||||
public AxolotlWatcher(Disguise disguise) {
|
||||
super(disguise);
|
||||
}
|
||||
|
||||
public boolean isPlayingDead() {
|
||||
return getData(MetaIndex.AXOLOTL_PLAYING_DEAD);
|
||||
}
|
||||
|
||||
public void setPlayingDead(boolean playingDead) {
|
||||
setData(MetaIndex.AXOLOTL_PLAYING_DEAD, playingDead);
|
||||
sendData(MetaIndex.AXOLOTL_PLAYING_DEAD);
|
||||
}
|
||||
|
||||
public Axolotl.Variant getVariant() {
|
||||
return Axolotl.Variant.values()[getData(MetaIndex.AXOLOTL_VARIANT)];
|
||||
}
|
||||
|
||||
public void setVariant(Axolotl.Variant variant) {
|
||||
setData(MetaIndex.AXOLOTL_VARIANT, variant.ordinal());
|
||||
sendData(MetaIndex.AXOLOTL_VARIANT);
|
||||
}
|
||||
}
|
|
@ -2,13 +2,13 @@ package me.libraryaddict.disguise.disguisetypes.watchers;
|
|||
|
||||
import me.libraryaddict.disguise.disguisetypes.Disguise;
|
||||
import me.libraryaddict.disguise.disguisetypes.MetaIndex;
|
||||
import me.libraryaddict.disguise.utilities.reflection.NmsAddedIn;
|
||||
import me.libraryaddict.disguise.utilities.reflection.annotations.NmsAddedIn;
|
||||
import me.libraryaddict.disguise.utilities.reflection.NmsVersion;
|
||||
|
||||
/**
|
||||
* Created by libraryaddict on 14/12/2019.
|
||||
*/
|
||||
@NmsAddedIn(val = NmsVersion.v1_15)
|
||||
@NmsAddedIn(NmsVersion.v1_15)
|
||||
public class BeeWatcher extends AgeableWatcher {
|
||||
public BeeWatcher(Disguise disguise) {
|
||||
super(disguise);
|
||||
|
@ -48,7 +48,7 @@ public class BeeWatcher extends AgeableWatcher {
|
|||
}
|
||||
|
||||
private boolean getBeeFlag(int value) {
|
||||
return (getData(MetaIndex.PANDA_META) & value) != 0;
|
||||
return (getData(MetaIndex.BEE_META) & value) != 0;
|
||||
}
|
||||
|
||||
private void setBeeFlag(int no, boolean flag) {
|
|
@ -3,22 +3,17 @@ package me.libraryaddict.disguise.disguisetypes.watchers;
|
|||
import me.libraryaddict.disguise.disguisetypes.Disguise;
|
||||
import me.libraryaddict.disguise.disguisetypes.MetaIndex;
|
||||
|
||||
public class BlazeWatcher extends InsentientWatcher
|
||||
{
|
||||
public BlazeWatcher(Disguise disguise)
|
||||
{
|
||||
public class BlazeWatcher extends InsentientWatcher {
|
||||
public BlazeWatcher(Disguise disguise) {
|
||||
super(disguise);
|
||||
}
|
||||
|
||||
public boolean isBlazing()
|
||||
{
|
||||
public boolean isBlazing() {
|
||||
return getData(MetaIndex.BLAZE_BLAZING) == 1;
|
||||
}
|
||||
|
||||
public void setBlazing(boolean isBlazing)
|
||||
{
|
||||
public void setBlazing(boolean isBlazing) {
|
||||
setData(MetaIndex.BLAZE_BLAZING, (byte) (isBlazing ? 1 : 0));
|
||||
sendData(MetaIndex.BLAZE_BLAZING);
|
||||
}
|
||||
|
||||
}
|
|
@ -3,7 +3,7 @@ package me.libraryaddict.disguise.disguisetypes.watchers;
|
|||
import me.libraryaddict.disguise.disguisetypes.Disguise;
|
||||
import me.libraryaddict.disguise.disguisetypes.FlagWatcher;
|
||||
import me.libraryaddict.disguise.disguisetypes.MetaIndex;
|
||||
import me.libraryaddict.disguise.utilities.reflection.NmsAddedIn;
|
||||
import me.libraryaddict.disguise.utilities.reflection.annotations.NmsAddedIn;
|
||||
import me.libraryaddict.disguise.utilities.reflection.NmsVersion;
|
||||
import org.bukkit.TreeSpecies;
|
||||
|
||||
|
@ -41,12 +41,12 @@ public class BoatWatcher extends FlagWatcher {
|
|||
sendData(MetaIndex.BOAT_LEFT_PADDLING);
|
||||
}
|
||||
|
||||
@NmsAddedIn(val = NmsVersion.v1_13)
|
||||
@NmsAddedIn(NmsVersion.v1_13)
|
||||
public int getBoatShake() {
|
||||
return getData(MetaIndex.BOAT_SHAKE);
|
||||
}
|
||||
|
||||
@NmsAddedIn(val = NmsVersion.v1_13)
|
||||
@NmsAddedIn(NmsVersion.v1_13)
|
||||
public void setBoatShake(int number) {
|
||||
setData(MetaIndex.BOAT_SHAKE, number);
|
||||
sendData(MetaIndex.BOAT_SHAKE);
|
|
@ -5,7 +5,7 @@ import me.libraryaddict.disguise.disguisetypes.AnimalColor;
|
|||
import me.libraryaddict.disguise.disguisetypes.Disguise;
|
||||
import me.libraryaddict.disguise.disguisetypes.MetaIndex;
|
||||
import me.libraryaddict.disguise.utilities.parser.RandomDefaultValue;
|
||||
import me.libraryaddict.disguise.utilities.reflection.NmsAddedIn;
|
||||
import me.libraryaddict.disguise.utilities.reflection.annotations.NmsAddedIn;
|
||||
import me.libraryaddict.disguise.utilities.reflection.NmsVersion;
|
||||
import org.bukkit.DyeColor;
|
||||
import org.bukkit.entity.Cat;
|
||||
|
@ -15,7 +15,7 @@ import java.util.Random;
|
|||
/**
|
||||
* Created by libraryaddict on 6/05/2019.
|
||||
*/
|
||||
@NmsAddedIn(val = NmsVersion.v1_14)
|
||||
@NmsAddedIn(NmsVersion.v1_14)
|
||||
public class CatWatcher extends TameableWatcher {
|
||||
public CatWatcher(Disguise disguise) {
|
||||
super(disguise);
|
|
@ -0,0 +1,39 @@
|
|||
package me.libraryaddict.disguise.disguisetypes.watchers;
|
||||
|
||||
import me.libraryaddict.disguise.disguisetypes.Disguise;
|
||||
import me.libraryaddict.disguise.disguisetypes.MetaIndex;
|
||||
import me.libraryaddict.disguise.utilities.DisguiseUtilities;
|
||||
import org.bukkit.entity.Creeper;
|
||||
|
||||
public class CreeperWatcher extends InsentientWatcher {
|
||||
|
||||
public CreeperWatcher(Disguise disguise) {
|
||||
super(disguise);
|
||||
}
|
||||
|
||||
public boolean isIgnited() {
|
||||
return getData(MetaIndex.CREEPER_IGNITED);
|
||||
}
|
||||
|
||||
public void setIgnited(boolean ignited) {
|
||||
// If creeper is already ignited and they want to set it to unignited, then resend disguise
|
||||
boolean resend = !ignited && getDisguise() != null && getDisguise().isDisguiseInUse() && ((hasValue(MetaIndex.CREEPER_IGNITED) && isIgnited()) ||
|
||||
(getDisguise().getEntity() instanceof Creeper && ((Creeper) getDisguise().getEntity()).isPowered()));
|
||||
|
||||
setData(MetaIndex.CREEPER_IGNITED, ignited);
|
||||
sendData(MetaIndex.CREEPER_IGNITED);
|
||||
|
||||
if (resend) {
|
||||
DisguiseUtilities.refreshTrackers(getDisguise());
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isPowered() {
|
||||
return getData(MetaIndex.CREEPER_POWERED);
|
||||
}
|
||||
|
||||
public void setPowered(boolean powered) {
|
||||
setData(MetaIndex.CREEPER_POWERED, powered);
|
||||
sendData(MetaIndex.CREEPER_POWERED);
|
||||
}
|
||||
}
|
|
@ -7,5 +7,4 @@ public class DonkeyWatcher extends ChestedHorseWatcher {
|
|||
public DonkeyWatcher(Disguise disguise) {
|
||||
super(disguise);
|
||||
}
|
||||
|
||||
}
|
|
@ -24,8 +24,7 @@ public class DroppedItemWatcher extends FlagWatcher {
|
|||
|
||||
if (!getDisguise().isCustomDisguiseName()) {
|
||||
getDisguise().setDisguiseName(TranslateType.DISGUISES.get(DisguiseType.DROPPED_ITEM.toReadable()) + " " +
|
||||
TranslateType.DISGUISE_OPTIONS_PARAMETERS
|
||||
.get(ReflectionManager.toReadable((item == null ? Material.AIR : item.getType()).name())));
|
||||
TranslateType.DISGUISE_OPTIONS_PARAMETERS.get(ReflectionManager.toReadable((item == null ? Material.AIR : item.getType()).name(), " ")));
|
||||
}
|
||||
}
|
||||
}
|
|
@ -6,21 +6,17 @@ import me.libraryaddict.disguise.disguisetypes.MetaIndex;
|
|||
/**
|
||||
* @author Navid
|
||||
*/
|
||||
public class EnderDragonWatcher extends InsentientWatcher
|
||||
{
|
||||
public class EnderDragonWatcher extends InsentientWatcher {
|
||||
|
||||
public EnderDragonWatcher(Disguise disguise)
|
||||
{
|
||||
public EnderDragonWatcher(Disguise disguise) {
|
||||
super(disguise);
|
||||
}
|
||||
|
||||
public int getPhase()
|
||||
{
|
||||
public int getPhase() {
|
||||
return getData(MetaIndex.ENDER_DRAGON_PHASE);
|
||||
}
|
||||
|
||||
public void setPhase(int phase)
|
||||
{
|
||||
public void setPhase(int phase) {
|
||||
setData(MetaIndex.ENDER_DRAGON_PHASE, phase);
|
||||
sendData(MetaIndex.ENDER_DRAGON_PHASE);
|
||||
}
|
|
@ -3,7 +3,7 @@ package me.libraryaddict.disguise.disguisetypes.watchers;
|
|||
import me.libraryaddict.disguise.disguisetypes.Disguise;
|
||||
import me.libraryaddict.disguise.disguisetypes.FlagWatcher;
|
||||
import me.libraryaddict.disguise.disguisetypes.MetaIndex;
|
||||
import me.libraryaddict.disguise.utilities.reflection.NmsAddedIn;
|
||||
import me.libraryaddict.disguise.utilities.reflection.annotations.NmsAddedIn;
|
||||
import me.libraryaddict.disguise.utilities.reflection.NmsVersion;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
@ -20,12 +20,12 @@ public class EnderSignalWatcher extends FlagWatcher {
|
|||
}
|
||||
}
|
||||
|
||||
@NmsAddedIn(val = NmsVersion.v1_14)
|
||||
@NmsAddedIn(NmsVersion.v1_14)
|
||||
public ItemStack getItemStack() {
|
||||
return getData(MetaIndex.ENDER_SIGNAL_ITEM);
|
||||
}
|
||||
|
||||
@NmsAddedIn(val = NmsVersion.v1_14)
|
||||
@NmsAddedIn(NmsVersion.v1_14)
|
||||
public void setItemStack(ItemStack item) {
|
||||
setData(MetaIndex.ENDER_SIGNAL_ITEM, item);
|
||||
sendData(MetaIndex.ENDER_SIGNAL_ITEM);
|
|
@ -32,14 +32,20 @@ public class EndermanWatcher extends InsentientWatcher {
|
|||
}
|
||||
|
||||
public void setItemInMainHand(Material type) {
|
||||
if (!type.isBlock()) {
|
||||
return;
|
||||
}
|
||||
|
||||
Optional<WrappedBlockData> optional;
|
||||
|
||||
if (type == null)
|
||||
if (type == null) {
|
||||
optional = Optional.empty();
|
||||
else
|
||||
} else {
|
||||
optional = Optional.of(WrappedBlockData.createData(type));
|
||||
}
|
||||
|
||||
setData(MetaIndex.ENDERMAN_ITEM, optional);
|
||||
sendData(MetaIndex.ENDERMAN_ITEM);
|
||||
}
|
||||
|
||||
@Deprecated
|
|
@ -8,17 +8,20 @@ import me.libraryaddict.disguise.DisguiseAPI;
|
|||
import me.libraryaddict.disguise.disguisetypes.Disguise;
|
||||
import me.libraryaddict.disguise.disguisetypes.FlagWatcher;
|
||||
import me.libraryaddict.disguise.utilities.DisguiseUtilities;
|
||||
import me.libraryaddict.disguise.utilities.reflection.annotations.NmsAddedIn;
|
||||
import me.libraryaddict.disguise.utilities.reflection.NmsVersion;
|
||||
import me.libraryaddict.disguise.utilities.reflection.ReflectionManager;
|
||||
import me.libraryaddict.disguise.utilities.translations.TranslateType;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.data.BlockData;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
|
||||
public class FallingBlockWatcher extends FlagWatcher {
|
||||
private ItemStack block = new ItemStack(Material.STONE);
|
||||
private int blockCombinedId = 1;
|
||||
private boolean gridLocked;
|
||||
|
||||
public FallingBlockWatcher(Disguise disguise) {
|
||||
|
@ -28,7 +31,12 @@ public class FallingBlockWatcher extends FlagWatcher {
|
|||
@Override
|
||||
public FallingBlockWatcher clone(Disguise disguise) {
|
||||
FallingBlockWatcher watcher = (FallingBlockWatcher) super.clone(disguise);
|
||||
watcher.setBlock(getBlock().clone());
|
||||
|
||||
if (NmsVersion.v1_13.isSupported()) {
|
||||
watcher.setBlockData(getBlockData().clone());
|
||||
} else {
|
||||
watcher.setBlock(getBlock().clone());
|
||||
}
|
||||
|
||||
return watcher;
|
||||
}
|
||||
|
@ -46,13 +54,23 @@ public class FallingBlockWatcher extends FlagWatcher {
|
|||
|
||||
if (getDisguise().isDisguiseInUse() && getDisguise().getEntity() != null) {
|
||||
PacketContainer relMove = new PacketContainer(PacketType.Play.Server.REL_ENTITY_MOVE);
|
||||
StructureModifier<Short> shorts = relMove.getShorts();
|
||||
relMove.getModifier().write(0, getDisguise().getEntity().getEntityId());
|
||||
|
||||
Location loc = getDisguise().getEntity().getLocation();
|
||||
|
||||
relMove.getModifier().write(0, getDisguise().getEntity().getEntityId());
|
||||
shorts.write(0, conRel(loc.getX(), loc.getBlockX() + 0.5));
|
||||
shorts.write(1, conRel(loc.getY(), loc.getBlockY()));
|
||||
shorts.write(2, conRel(loc.getZ(), loc.getBlockZ() + 0.5));
|
||||
if (NmsVersion.v1_14.isSupported()) {
|
||||
StructureModifier<Short> shorts = relMove.getShorts();
|
||||
|
||||
shorts.write(0, conRel(loc.getX(), loc.getBlockX() + 0.5));
|
||||
shorts.write(1, conRel(loc.getY(), loc.getBlockY() + (loc.getY() % 1 >= 0.85 ? 1 : loc.getY() % 1 >= 0.35 ? .5 : 0)));
|
||||
shorts.write(2, conRel(loc.getZ(), loc.getBlockZ() + 0.5));
|
||||
} else {
|
||||
StructureModifier<Integer> ints = relMove.getIntegers();
|
||||
|
||||
ints.write(0, (int) conRel(loc.getX(), loc.getBlockX() + 0.5));
|
||||
ints.write(1, (int) conRel(loc.getY(), loc.getBlockY() + (loc.getY() % 1 >= 0.85 ? 1 : loc.getY() % 1 >= 0.35 ? .5 : 0)));
|
||||
ints.write(2, (int) conRel(loc.getZ(), loc.getBlockZ() + 0.5));
|
||||
}
|
||||
|
||||
try {
|
||||
for (Player player : DisguiseUtilities.getPerverts(getDisguise())) {
|
||||
|
@ -65,8 +83,7 @@ public class FallingBlockWatcher extends FlagWatcher {
|
|||
ProtocolLibrary.getProtocolManager().sendServerPacket(player, relMove, isGridLocked());
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (InvocationTargetException e) {
|
||||
} catch (InvocationTargetException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
@ -77,7 +94,7 @@ public class FallingBlockWatcher extends FlagWatcher {
|
|||
}
|
||||
|
||||
public ItemStack getBlock() {
|
||||
return block;
|
||||
return ReflectionManager.getItemStackByCombinedId(getBlockCombinedId());
|
||||
}
|
||||
|
||||
public void setBlock(ItemStack block) {
|
||||
|
@ -85,16 +102,47 @@ public class FallingBlockWatcher extends FlagWatcher {
|
|||
block = new ItemStack(Material.STONE);
|
||||
}
|
||||
|
||||
this.block = block;
|
||||
this.blockCombinedId = ReflectionManager.getCombinedIdByItemStack(block);
|
||||
|
||||
if (!getDisguise().isCustomDisguiseName()) {
|
||||
getDisguise().setDisguiseName(TranslateType.DISGUISE_OPTIONS_PARAMETERS.get("Block") + " " +
|
||||
TranslateType.DISGUISE_OPTIONS_PARAMETERS
|
||||
.get(ReflectionManager.toReadable(block.getType().name())));
|
||||
TranslateType.DISGUISE_OPTIONS_PARAMETERS.get(ReflectionManager.toReadable(block.getType().name(), " ")));
|
||||
}
|
||||
|
||||
if (DisguiseAPI.isDisguiseInUse(getDisguise()) && getDisguise().getWatcher() == this) {
|
||||
DisguiseUtilities.refreshTrackers(getDisguise());
|
||||
}
|
||||
}
|
||||
|
||||
@NmsAddedIn(NmsVersion.v1_13)
|
||||
public BlockData getBlockData() {
|
||||
return ReflectionManager.getBlockDataByCombinedId(getBlockCombinedId());
|
||||
}
|
||||
|
||||
@NmsAddedIn(NmsVersion.v1_13)
|
||||
public void setBlockData(BlockData data) {
|
||||
if (data == null || data.getMaterial() == Material.AIR && data.getMaterial().isBlock()) {
|
||||
setBlock(null);
|
||||
return;
|
||||
}
|
||||
|
||||
this.blockCombinedId = ReflectionManager.getCombinedIdByBlockData(data);
|
||||
|
||||
if (!getDisguise().isCustomDisguiseName()) {
|
||||
getDisguise().setDisguiseName(TranslateType.DISGUISE_OPTIONS_PARAMETERS.get("Block") + " " +
|
||||
TranslateType.DISGUISE_OPTIONS_PARAMETERS.get(ReflectionManager.toReadable(data.getMaterial().name(), " ")));
|
||||
}
|
||||
|
||||
if (DisguiseAPI.isDisguiseInUse(getDisguise()) && getDisguise().getWatcher() == this) {
|
||||
DisguiseUtilities.refreshTrackers(getDisguise());
|
||||
}
|
||||
}
|
||||
|
||||
public int getBlockCombinedId() {
|
||||
if (blockCombinedId < 1) {
|
||||
blockCombinedId = 1;
|
||||
}
|
||||
|
||||
return blockCombinedId;
|
||||
}
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue