Compare commits
346
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
737bc51d8f | ||
|
|
37bee3750c | ||
|
|
3f7a2687e6 | ||
|
|
cd195d7e21 | ||
|
|
daae025e9b | ||
|
|
52e53a377a | ||
|
|
423c9c1519 | ||
|
|
b09e81143c | ||
|
|
df27433ee3 | ||
|
|
76b95ecd84 | ||
|
|
f182ff4449 | ||
|
|
d5cb2c4f8e | ||
|
|
3f8442b50c | ||
|
|
45c4ca512b | ||
|
|
7a9e854bf1 | ||
|
|
9a5247b0fe | ||
|
|
2b904200aa | ||
|
|
04063e092e | ||
|
|
940c4c79bd | ||
|
|
4241db903c | ||
|
|
09236cdcb7 | ||
|
|
67c7b29827 | ||
|
|
72db0706b9 | ||
|
|
8a47cdacc7 | ||
|
|
91a45d99a9 | ||
|
|
f9c62ad123 | ||
|
|
22a8e11a11 | ||
|
|
24c1ca4273 | ||
|
|
93fd59e3d0 | ||
|
|
e40750297e | ||
|
|
100aee8e27 | ||
|
|
d79a6a46da | ||
|
|
37c563cacb | ||
|
|
3d3263bd3a | ||
|
|
e5017c051b | ||
|
|
dd2d5b574e | ||
|
|
67091db586 | ||
|
|
7cb72f89ee | ||
|
|
03925fe529 | ||
|
|
868c92bc42 | ||
|
|
9ee7d85805 | ||
|
|
4e3c245fb1 | ||
|
|
5beebc2273 | ||
|
|
6c7f078270 | ||
|
|
836e192f4b | ||
|
|
f447cf69d3 | ||
|
|
d06b723adc | ||
|
|
f8617cf1b9 | ||
|
|
8630a6f74c | ||
|
|
424d892091 | ||
|
|
9aaef6e297 | ||
|
|
e749760136 | ||
|
|
7f2f3c54ba | ||
|
|
24f2c867c6 | ||
|
|
e7f3288fb7 | ||
|
|
2221062e98 | ||
|
|
430f5ee9e6 | ||
|
|
cd1a7cf312 | ||
|
|
002cdc64ef | ||
|
|
3d59686ba4 | ||
|
|
f6c72b9d0e | ||
|
|
d72d419044 | ||
|
|
c71a3a4002 | ||
|
|
02b70ed324 | ||
|
|
01d0a53049 | ||
|
|
c700ca6abb | ||
|
|
d9cba6c010 | ||
|
|
a6ed66cf1e | ||
|
|
4f5b7ad3fb | ||
|
|
962ea8b719 | ||
|
|
35e4d0b5aa | ||
|
|
497fe5ef98 | ||
|
|
0508387db1 | ||
|
|
1ff7c419ef | ||
|
|
612eda685c | ||
|
|
7fc7b571a3 | ||
|
|
5cce86bf8d | ||
|
|
7621d815ac | ||
|
|
81495e3478 | ||
|
|
5c591d3a5b | ||
|
|
f1c225b718 | ||
|
|
ca7a098cfa | ||
|
|
b2fbba8455 | ||
|
|
ae6300c43c | ||
|
|
cb62734da5 | ||
|
|
04a2e4ea54 | ||
|
|
2969469605 | ||
|
|
25a0f7a742 | ||
|
|
d2f6c3336e | ||
|
|
d2c7e00639 | ||
|
|
e23fb19c98 | ||
|
|
1f8d5b78a7 | ||
|
|
fee0362c69 | ||
|
|
428d944933 | ||
|
|
180d23fb1a | ||
|
|
f54dc0f028 | ||
|
|
ef141a6e7f | ||
|
|
55b0b5df75 | ||
|
|
bc78304e97 | ||
|
|
42d8ea3526 | ||
|
|
dfc0066c17 | ||
|
|
9e3e61e9a2 | ||
|
|
6551bffcdb | ||
|
|
44f3b4d6d5 | ||
|
|
c672eaaf81 | ||
|
|
460013d22a | ||
|
|
af89f082aa | ||
|
|
e0c3c8a343 | ||
|
|
83480db4c6 | ||
|
|
04d441cfd6 | ||
|
|
842c2654c6 | ||
|
|
01d825da86 | ||
|
|
d61dd872eb | ||
|
|
3c417c6a8e | ||
|
|
f0772a0969 | ||
|
|
2a83c1c548 | ||
|
|
12114c63bf | ||
|
|
8123ff2f27 | ||
|
|
b56ebb3fcb | ||
|
|
7adcce2361 | ||
|
|
6444ec153c | ||
|
|
841253708d | ||
|
|
467308be62 | ||
|
|
d2f8305727 | ||
|
|
1a19435b96 | ||
|
|
eb4b2b1e17 | ||
|
|
8bca4bc091 | ||
|
|
dfef20fb87 | ||
|
|
f4e1dbf385 | ||
|
|
93a84f668a | ||
|
|
f8463c9927 | ||
|
|
34b5cd89e5 | ||
|
|
6aae96ab87 | ||
|
|
3f9978e3c1 | ||
|
|
f43d32ca41 | ||
|
|
f6c5777865 | ||
|
|
cdd79b76a5 | ||
|
|
5fa152f118 | ||
|
|
7a233e6e3d | ||
|
|
0697a7e903 | ||
|
|
5abf3603cf | ||
|
|
1576d4a5a6 | ||
|
|
78579f33dc | ||
|
|
3d94eac961 | ||
|
|
c31ac308f6 | ||
|
|
e201591d14 | ||
|
|
e86a8b29ae | ||
|
|
9992885f03 | ||
|
|
44ae1e58bf | ||
|
|
5550853c7d | ||
|
|
1c70555d1c | ||
|
|
9dcc11c9f4 | ||
|
|
8d942d0f2e | ||
|
|
d556290a19 | ||
|
|
bf91c80e07 | ||
|
|
d5d8a43cb5 | ||
|
|
31cc490a55 | ||
|
|
3c0f870c22 | ||
|
|
4271d31d24 | ||
|
|
0f35426dbc | ||
|
|
c19276134d | ||
|
|
a93ab63e33 | ||
|
|
e41ab428b7 | ||
|
|
a3efda4b5c | ||
|
|
e7357b1b9c | ||
|
|
d9c8485358 | ||
|
|
84b7899b29 | ||
|
|
85e6de958c | ||
|
|
9658e9dfe4 | ||
|
|
d0efa0cb26 | ||
|
|
558d0cc7fc | ||
|
|
96558955aa | ||
|
|
383e7db013 | ||
|
|
bdd53e6003 | ||
|
|
04d48403bc | ||
|
|
bb0bd8fb84 | ||
|
|
27d63ad1c5 | ||
|
|
26581fb288 | ||
|
|
db6e106eb9 | ||
|
|
fce4a52abe | ||
|
|
81d6200c51 | ||
|
|
e9b6c45113 | ||
|
|
ae1120f311 | ||
|
|
71bf486cc6 | ||
|
|
7f8e0e90d5 | ||
|
|
bc702d76ca | ||
|
|
ea0d6e4544 | ||
|
|
2838486184 | ||
|
|
6d5c127571 | ||
|
|
7bc32a196d | ||
|
|
c8ccd8f2b4 | ||
|
|
a84d932050 | ||
|
|
57774c4122 | ||
|
|
b6bade9452 | ||
|
|
be8c5e6f76 | ||
|
|
d95af1e597 | ||
|
|
589a8c320e | ||
|
|
6d23722b69 | ||
|
|
b9d0865c26 | ||
|
|
87b440c8d7 | ||
|
|
726f19de2a | ||
|
|
406b3900cd | ||
|
|
3ce05f794a | ||
|
|
06752076ff | ||
|
|
19d1ebb773 | ||
|
|
e66f5f47f3 | ||
|
|
2c56e80f57 | ||
|
|
5cb6bed49d | ||
|
|
7cc95e2060 | ||
|
|
1873997348 | ||
|
|
559e84765b | ||
|
|
6df476096d | ||
|
|
7c064e70fd | ||
|
|
55e6058b70 | ||
|
|
8a03a4faec | ||
|
|
30eb102bbc | ||
|
|
09ce792bd2 | ||
|
|
0fc23712e4 | ||
|
|
6b9c717ec4 | ||
|
|
0c3e82c01e | ||
|
|
8e6e544b60 | ||
|
|
a4196fc118 | ||
|
|
d5a9b99a7a | ||
|
|
6d850f9f07 | ||
|
|
c4987b7c5e | ||
|
|
3880738ed9 | ||
|
|
68c00b843b | ||
|
|
dc352275b6 | ||
|
|
b3362987e5 | ||
|
|
fb3ec45059 | ||
|
|
5100b4a852 | ||
|
|
e9ec801dc5 | ||
|
|
70c31b8597 | ||
|
|
a078de1fc3 | ||
|
|
a1d759451c | ||
|
|
8a9373963c | ||
|
|
d964d5b859 | ||
|
|
b468865041 | ||
|
|
d6fec721ad | ||
|
|
9256398fa2 | ||
|
|
4fed08a8f9 | ||
|
|
b650156e57 | ||
|
|
4737d15be5 | ||
|
|
aca6dd7e1d | ||
|
|
5aa0d000dd | ||
|
|
e2b238fb81 | ||
|
|
ebdb3edbc1 | ||
|
|
b9f4e46d65 | ||
|
|
287ebd4e9c | ||
|
|
befdc3de6a | ||
|
|
55d00876a7 | ||
|
|
be0ee15448 | ||
|
|
7f91b85d6e | ||
|
|
80beacaef9 | ||
|
|
9f0521f9de | ||
|
|
3e1fffcfbb | ||
|
|
c0e77efad6 | ||
|
|
490f6f420b | ||
|
|
228185291d | ||
|
|
ab17861e7c | ||
|
|
567ca5192c | ||
|
|
442a0797a2 | ||
|
|
c1be977abd | ||
|
|
a6f670dcfb | ||
|
|
1d3e72aae2 | ||
|
|
513fce2059 | ||
|
|
6247aee871 | ||
|
|
fc0e230ca5 | ||
|
|
d2972f602f | ||
|
|
0f3b858a75 | ||
|
|
70b449e83d | ||
|
|
2a58b6644e | ||
|
|
96f4386f7a | ||
|
|
3e9de4e859 | ||
|
|
dad2db500c | ||
|
|
9bd33477b1 | ||
|
|
01c680b69a | ||
|
|
d20c3c2820 | ||
|
|
dcb73b1672 | ||
|
|
389f006d02 | ||
|
|
0266a6c5f9 | ||
|
|
9b53123e92 | ||
|
|
9e21110011 | ||
|
|
5377c67614 | ||
|
|
32f8c61d43 | ||
|
|
2a16db32ba | ||
|
|
735c3764db | ||
|
|
c160feb422 | ||
|
|
21ed81d9ce | ||
|
|
6c25c8570d | ||
|
|
560c9c3c8b | ||
|
|
095f4d6179 | ||
|
|
4d389a3e3b | ||
|
|
7f6a5aeba4 | ||
|
|
3006ffac30 | ||
|
|
d0a256a281 | ||
|
|
fceab89bc7 | ||
|
|
6c11525879 | ||
|
|
3decc0453b | ||
|
|
b4f9aec084 | ||
|
|
4cd1901e48 | ||
|
|
2aca1d42b0 | ||
|
|
23050b6788 | ||
|
|
07bd37bc51 | ||
|
|
de2ffe910f | ||
|
|
e3f33e0df4 | ||
|
|
d919bee580 | ||
|
|
ab10f02e3e | ||
|
|
647a4ed2b4 | ||
|
|
5b11e09ece | ||
|
|
5c006b3ba7 | ||
|
|
ba970a2ae4 | ||
|
|
2a51caba40 | ||
|
|
5b9035b766 | ||
|
|
41365e07f6 | ||
|
|
9fbaf9c628 | ||
|
|
730fe64eeb | ||
|
|
266fc497d8 | ||
|
|
871443b643 | ||
|
|
4094ee0211 | ||
|
|
0bcd099dcd | ||
|
|
04b603569d | ||
|
|
5a4951aec2 | ||
|
|
a16aa53561 | ||
|
|
a4bbcd5f99 | ||
|
|
75263af008 | ||
|
|
6c74c6f1d1 | ||
|
|
1ba064db1b | ||
|
|
e10c55a35b | ||
|
|
29a234d94d | ||
|
|
ccf97cca20 | ||
|
|
4ee5908c96 | ||
|
|
53128a49bb | ||
|
|
6092960af5 | ||
|
|
c9e4c9f077 | ||
|
|
d00a44de53 | ||
|
|
adfff4c520 | ||
|
|
fb0dac4e3b | ||
|
|
71a43bd431 | ||
|
|
339f0490cf | ||
|
|
3e9e71812a | ||
|
|
fd0e7c6f7f | ||
|
|
07a61712ea | ||
|
|
33080da0b1 | ||
|
|
02f48525e2 | ||
|
|
c2aacd1b0c |
No files matched your search
+42
@@ -0,0 +1,42 @@
|
||||
# Compiled class file
|
||||
*.class
|
||||
bin/
|
||||
target/
|
||||
|
||||
# Log file
|
||||
*.log
|
||||
|
||||
# BlueJ files
|
||||
*.ctxt
|
||||
|
||||
# Mobile Tools for Java (J2ME)
|
||||
.mtj.tmp/
|
||||
|
||||
# Package Files #
|
||||
*.jar
|
||||
*.war
|
||||
*.nar
|
||||
*.ear
|
||||
*.zip
|
||||
*.tar.gz
|
||||
*.rar
|
||||
|
||||
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
|
||||
hs_err_pid*
|
||||
|
||||
# eclipse
|
||||
.settings
|
||||
.classpath
|
||||
.project
|
||||
|
||||
# intellij
|
||||
.idea/
|
||||
|
||||
# other
|
||||
*.iml
|
||||
run/
|
||||
|
||||
# Gradle
|
||||
.gradle/
|
||||
build/
|
||||
!gradle/wrapper/gradle-wrapper.jar
|
||||
@@ -1,21 +1,339 @@
|
||||
MIT License
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
Version 2, June 1991
|
||||
|
||||
Copyright (c) 2024 Alihan
|
||||
Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
Preamble
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
The licenses for most software are designed to take away your
|
||||
freedom to share and change it. By contrast, the GNU General Public
|
||||
License is intended to guarantee your freedom to share and change free
|
||||
software--to make sure the software is free for all its users. This
|
||||
General Public License applies to most of the Free Software
|
||||
Foundation's software and to any other program whose authors commit to
|
||||
using it. (Some other Free Software Foundation software is covered by
|
||||
the GNU Lesser General Public License instead.) You can apply it to
|
||||
your programs, too.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
When we speak of free software, we are referring to freedom, not
|
||||
price. Our General Public Licenses are designed to make sure that you
|
||||
have the freedom to distribute copies of free software (and charge for
|
||||
this service if you wish), that you receive source code or can get it
|
||||
if you want it, that you can change the software or use pieces of it
|
||||
in new free programs; and that you know you can do these things.
|
||||
|
||||
To protect your rights, we need to make restrictions that forbid
|
||||
anyone to deny you these rights or to ask you to surrender the rights.
|
||||
These restrictions translate to certain responsibilities for you if you
|
||||
distribute copies of the software, or if you modify it.
|
||||
|
||||
For example, if you distribute copies of such a program, whether
|
||||
gratis or for a fee, you must give the recipients all the rights that
|
||||
you have. You must make sure that they, too, receive or can get the
|
||||
source code. And you must show them these terms so they know their
|
||||
rights.
|
||||
|
||||
We protect your rights with two steps: (1) copyright the software, and
|
||||
(2) offer you this license which gives you legal permission to copy,
|
||||
distribute and/or modify the software.
|
||||
|
||||
Also, for each author's protection and ours, we want to make certain
|
||||
that everyone understands that there is no warranty for this free
|
||||
software. If the software is modified by someone else and passed on, we
|
||||
want its recipients to know that what they have is not the original, so
|
||||
that any problems introduced by others will not reflect on the original
|
||||
authors' reputations.
|
||||
|
||||
Finally, any free program is threatened constantly by software
|
||||
patents. We wish to avoid the danger that redistributors of a free
|
||||
program will individually obtain patent licenses, in effect making the
|
||||
program proprietary. To prevent this, we have made it clear that any
|
||||
patent must be licensed for everyone's free use or not licensed at all.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow.
|
||||
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
||||
|
||||
0. This License applies to any program or other work which contains
|
||||
a notice placed by the copyright holder saying it may be distributed
|
||||
under the terms of this General Public License. The "Program", below,
|
||||
refers to any such program or work, and a "work based on the Program"
|
||||
means either the Program or any derivative work under copyright law:
|
||||
that is to say, a work containing the Program or a portion of it,
|
||||
either verbatim or with modifications and/or translated into another
|
||||
language. (Hereinafter, translation is included without limitation in
|
||||
the term "modification".) Each licensee is addressed as "you".
|
||||
|
||||
Activities other than copying, distribution and modification are not
|
||||
covered by this License; they are outside its scope. The act of
|
||||
running the Program is not restricted, and the output from the Program
|
||||
is covered only if its contents constitute a work based on the
|
||||
Program (independent of having been made by running the Program).
|
||||
Whether that is true depends on what the Program does.
|
||||
|
||||
1. You may copy and distribute verbatim copies of the Program's
|
||||
source code as you receive it, in any medium, provided that you
|
||||
conspicuously and appropriately publish on each copy an appropriate
|
||||
copyright notice and disclaimer of warranty; keep intact all the
|
||||
notices that refer to this License and to the absence of any warranty;
|
||||
and give any other recipients of the Program a copy of this License
|
||||
along with the Program.
|
||||
|
||||
You may charge a fee for the physical act of transferring a copy, and
|
||||
you may at your option offer warranty protection in exchange for a fee.
|
||||
|
||||
2. You may modify your copy or copies of the Program or any portion
|
||||
of it, thus forming a work based on the Program, and copy and
|
||||
distribute such modifications or work under the terms of Section 1
|
||||
above, provided that you also meet all of these conditions:
|
||||
|
||||
a) You must cause the modified files to carry prominent notices
|
||||
stating that you changed the files and the date of any change.
|
||||
|
||||
b) You must cause any work that you distribute or publish, that in
|
||||
whole or in part contains or is derived from the Program or any
|
||||
part thereof, to be licensed as a whole at no charge to all third
|
||||
parties under the terms of this License.
|
||||
|
||||
c) If the modified program normally reads commands interactively
|
||||
when run, you must cause it, when started running for such
|
||||
interactive use in the most ordinary way, to print or display an
|
||||
announcement including an appropriate copyright notice and a
|
||||
notice that there is no warranty (or else, saying that you provide
|
||||
a warranty) and that users may redistribute the program under
|
||||
these conditions, and telling the user how to view a copy of this
|
||||
License. (Exception: if the Program itself is interactive but
|
||||
does not normally print such an announcement, your work based on
|
||||
the Program is not required to print an announcement.)
|
||||
|
||||
These requirements apply to the modified work as a whole. If
|
||||
identifiable sections of that work are not derived from the Program,
|
||||
and can be reasonably considered independent and separate works in
|
||||
themselves, then this License, and its terms, do not apply to those
|
||||
sections when you distribute them as separate works. But when you
|
||||
distribute the same sections as part of a whole which is a work based
|
||||
on the Program, the distribution of the whole must be on the terms of
|
||||
this License, whose permissions for other licensees extend to the
|
||||
entire whole, and thus to each and every part regardless of who wrote it.
|
||||
|
||||
Thus, it is not the intent of this section to claim rights or contest
|
||||
your rights to work written entirely by you; rather, the intent is to
|
||||
exercise the right to control the distribution of derivative or
|
||||
collective works based on the Program.
|
||||
|
||||
In addition, mere aggregation of another work not based on the Program
|
||||
with the Program (or with a work based on the Program) on a volume of
|
||||
a storage or distribution medium does not bring the other work under
|
||||
the scope of this License.
|
||||
|
||||
3. You may copy and distribute the Program (or a work based on it,
|
||||
under Section 2) in object code or executable form under the terms of
|
||||
Sections 1 and 2 above provided that you also do one of the following:
|
||||
|
||||
a) Accompany it with the complete corresponding machine-readable
|
||||
source code, which must be distributed under the terms of Sections
|
||||
1 and 2 above on a medium customarily used for software interchange; or,
|
||||
|
||||
b) Accompany it with a written offer, valid for at least three
|
||||
years, to give any third party, for a charge no more than your
|
||||
cost of physically performing source distribution, a complete
|
||||
machine-readable copy of the corresponding source code, to be
|
||||
distributed under the terms of Sections 1 and 2 above on a medium
|
||||
customarily used for software interchange; or,
|
||||
|
||||
c) Accompany it with the information you received as to the offer
|
||||
to distribute corresponding source code. (This alternative is
|
||||
allowed only for noncommercial distribution and only if you
|
||||
received the program in object code or executable form with such
|
||||
an offer, in accord with Subsection b above.)
|
||||
|
||||
The source code for a work means the preferred form of the work for
|
||||
making modifications to it. For an executable work, complete source
|
||||
code means all the source code for all modules it contains, plus any
|
||||
associated interface definition files, plus the scripts used to
|
||||
control compilation and installation of the executable. However, as a
|
||||
special exception, the source code distributed need not include
|
||||
anything that is normally distributed (in either source or binary
|
||||
form) with the major components (compiler, kernel, and so on) of the
|
||||
operating system on which the executable runs, unless that component
|
||||
itself accompanies the executable.
|
||||
|
||||
If distribution of executable or object code is made by offering
|
||||
access to copy from a designated place, then offering equivalent
|
||||
access to copy the source code from the same place counts as
|
||||
distribution of the source code, even though third parties are not
|
||||
compelled to copy the source along with the object code.
|
||||
|
||||
4. You may not copy, modify, sublicense, or distribute the Program
|
||||
except as expressly provided under this License. Any attempt
|
||||
otherwise to copy, modify, sublicense or distribute the Program is
|
||||
void, and will automatically terminate your rights under this License.
|
||||
However, parties who have received copies, or rights, from you under
|
||||
this License will not have their licenses terminated so long as such
|
||||
parties remain in full compliance.
|
||||
|
||||
5. You are not required to accept this License, since you have not
|
||||
signed it. However, nothing else grants you permission to modify or
|
||||
distribute the Program or its derivative works. These actions are
|
||||
prohibited by law if you do not accept this License. Therefore, by
|
||||
modifying or distributing the Program (or any work based on the
|
||||
Program), you indicate your acceptance of this License to do so, and
|
||||
all its terms and conditions for copying, distributing or modifying
|
||||
the Program or works based on it.
|
||||
|
||||
6. Each time you redistribute the Program (or any work based on the
|
||||
Program), the recipient automatically receives a license from the
|
||||
original licensor to copy, distribute or modify the Program subject to
|
||||
these terms and conditions. You may not impose any further
|
||||
restrictions on the recipients' exercise of the rights granted herein.
|
||||
You are not responsible for enforcing compliance by third parties to
|
||||
this License.
|
||||
|
||||
7. If, as a consequence of a court judgment or allegation of patent
|
||||
infringement or for any other reason (not limited to patent issues),
|
||||
conditions are imposed on you (whether by court order, agreement or
|
||||
otherwise) that contradict the conditions of this License, they do not
|
||||
excuse you from the conditions of this License. If you cannot
|
||||
distribute so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you
|
||||
may not distribute the Program at all. For example, if a patent
|
||||
license would not permit royalty-free redistribution of the Program by
|
||||
all those who receive copies directly or indirectly through you, then
|
||||
the only way you could satisfy both it and this License would be to
|
||||
refrain entirely from distribution of the Program.
|
||||
|
||||
If any portion of this section is held invalid or unenforceable under
|
||||
any particular circumstance, the balance of the section is intended to
|
||||
apply and the section as a whole is intended to apply in other
|
||||
circumstances.
|
||||
|
||||
It is not the purpose of this section to induce you to infringe any
|
||||
patents or other property right claims or to contest validity of any
|
||||
such claims; this section has the sole purpose of protecting the
|
||||
integrity of the free software distribution system, which is
|
||||
implemented by public license practices. Many people have made
|
||||
generous contributions to the wide range of software distributed
|
||||
through that system in reliance on consistent application of that
|
||||
system; it is up to the author/donor to decide if he or she is willing
|
||||
to distribute software through any other system and a licensee cannot
|
||||
impose that choice.
|
||||
|
||||
This section is intended to make thoroughly clear what is believed to
|
||||
be a consequence of the rest of this License.
|
||||
|
||||
8. If the distribution and/or use of the Program is restricted in
|
||||
certain countries either by patents or by copyrighted interfaces, the
|
||||
original copyright holder who places the Program under this License
|
||||
may add an explicit geographical distribution limitation excluding
|
||||
those countries, so that distribution is permitted only in or among
|
||||
countries not thus excluded. In such case, this License incorporates
|
||||
the limitation as if written in the body of this License.
|
||||
|
||||
9. The Free Software Foundation may publish revised and/or new versions
|
||||
of the General Public License from time to time. Such new versions will
|
||||
be similar in spirit to the present version, but may differ in detail to
|
||||
address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the Program
|
||||
specifies a version number of this License which applies to it and "any
|
||||
later version", you have the option of following the terms and conditions
|
||||
either of that version or of any later version published by the Free
|
||||
Software Foundation. If the Program does not specify a version number of
|
||||
this License, you may choose any version ever published by the Free Software
|
||||
Foundation.
|
||||
|
||||
10. If you wish to incorporate parts of the Program into other free
|
||||
programs whose distribution conditions are different, write to the author
|
||||
to ask for permission. For software which is copyrighted by the Free
|
||||
Software Foundation, write to the Free Software Foundation; we sometimes
|
||||
make exceptions for this. Our decision will be guided by the two goals
|
||||
of preserving the free status of all derivatives of our free software and
|
||||
of promoting the sharing and reuse of software generally.
|
||||
|
||||
NO WARRANTY
|
||||
|
||||
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
|
||||
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
|
||||
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
|
||||
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
|
||||
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
|
||||
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
|
||||
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
|
||||
REPAIR OR CORRECTION.
|
||||
|
||||
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
|
||||
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
|
||||
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
|
||||
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
|
||||
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
|
||||
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
|
||||
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGES.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
How to Apply These Terms to Your New Programs
|
||||
|
||||
If you develop a new program, and you want it to be of the greatest
|
||||
possible use to the public, the best way to achieve this is to make it
|
||||
free software which everyone can redistribute and change under these terms.
|
||||
|
||||
To do so, attach the following notices to the program. It is safest
|
||||
to attach them to the start of each source file to most effectively
|
||||
convey the exclusion of warranty; and each file should have at least
|
||||
the "copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
<one line to give the program's name and a brief idea of what it does.>
|
||||
Copyright (C) <year> <name of author>
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License along
|
||||
with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
If the program is interactive, make it output a short notice like this
|
||||
when it starts in an interactive mode:
|
||||
|
||||
Gnomovision version 69, Copyright (C) year name of author
|
||||
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||
This is free software, and you are welcome to redistribute it
|
||||
under certain conditions; type `show c' for details.
|
||||
|
||||
The hypothetical commands `show w' and `show c' should show the appropriate
|
||||
parts of the General Public License. Of course, the commands you use may
|
||||
be called something other than `show w' and `show c'; they could even be
|
||||
mouse-clicks or menu items--whatever suits your program.
|
||||
|
||||
You should also get your employer (if you work as a programmer) or your
|
||||
school, if any, to sign a "copyright disclaimer" for the program, if
|
||||
necessary. Here is a sample; alter the names:
|
||||
|
||||
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
|
||||
`Gnomovision' (which makes passes at compilers) written by James Hacker.
|
||||
|
||||
<signature of Ty Coon>, 1 April 1989
|
||||
Ty Coon, President of Vice
|
||||
|
||||
This General Public License does not permit incorporating your program into
|
||||
proprietary programs. If your program is a subroutine library, you may
|
||||
consider it more useful to permit linking proprietary applications with the
|
||||
library. If this is what you want to do, use the GNU Lesser General
|
||||
Public License instead of this License.
|
||||
@@ -1,8 +1,564 @@
|
||||
# ProAntiTab
|
||||
# **A**BOUT
|
||||
ProAntiTab is an advanced **plugin hider** with **many features** and a very simple to understand system. It prevents your server from **plugin spoofers** used by hack clients, manipulates the **tab-completion**, blocks unwanted **suggestions** and much more!
|
||||
#####
|
||||
|
||||
### About
|
||||
ProAntiTab is a Spigot/Bungeecord Minecraft plugin that helps you to hide unwanted commands from your players.
|
||||
# **I**N ACTION
|
||||

|
||||
|
||||
### Support versions
|
||||
Spigot (+ Forks): 1.8x - 1.20x (latest)
|
||||
Bungeecord (+ Forks) | Waterfall recommended
|
||||
######
|
||||
# **C**USTOM SERVER BRAND (F3)
|
||||
Create your own animated custom server brand on your Spigot, Bungeecord and Velocity server!
|
||||
**
|
||||
<details>
|
||||
<summary>open config.yml section</summary>
|
||||
|
||||
|
||||
```yaml
|
||||
# This feature allows you to customize your server-brand you see when you press F3.
|
||||
# Normally there stands something like 'Purpur', or 'Spigot'.
|
||||
# With this feature you are able to change and even animate it! ^^
|
||||
custom-server-brand:
|
||||
enabled: false
|
||||
|
||||
# Determines the speed in that the animation goes
|
||||
repeat-delay: 3
|
||||
|
||||
# This here is the list of the animation
|
||||
# Possible placeholders:
|
||||
# %player% - name of the player
|
||||
# %displayname% - displayname of the player
|
||||
# %world% - name of world where the player is
|
||||
# and the other placeholders from PlaceholderAPI
|
||||
brands:
|
||||
- '&f&lP&froAntiTab |'
|
||||
- '&fP&lr&foAntiTab /'
|
||||
- '&fPr&lo&fAntiTab -'
|
||||
- '&fPro&lA&fntiTab |'
|
||||
- '&fProA&ln&ftiTab \'
|
||||
- '&fProAn<&fiTab |'
|
||||
- '&fProAnt&li&fTab /'
|
||||
- '&fProAnti&lT&fab -'
|
||||
- '&fProAnti&lT&fab \'
|
||||
- '&fProAntiT&la&fb |'
|
||||
- '&fProAntiTa&lb&f /'
|
||||
- '&fProAntiTab -'
|
||||
- '&fProAntiTab \'
|
||||
```
|
||||
</details>
|
||||
|
||||
######
|
||||
# **U**SE BLACKLIST AS WHITELIST
|
||||
You have way too many commands to block? Don't worry.
|
||||
There's a section in the config.yml located pretty much high that allows you to turn the blacklist into a whitelist instead. This will block every command on your server except for those that are listed.
|
||||
<details>
|
||||
<summary>section in config.yml</summary>
|
||||
|
||||
|
||||
```yaml
|
||||
# This is a very necessary feature if you have way too many commands to block and instead decide
|
||||
# to whitelist specific commands.
|
||||
# Enabling this will disable ALL commands except for those that are in the (group-)list.
|
||||
turn-blacklist-to-whitelist: false
|
||||
```
|
||||
</details>
|
||||
|
||||
######
|
||||
# **A**NTI PLUGIN SPOOFING
|
||||
##### ProAntiTab is able to detect and block plugin spoofing attempts used by hack clients.
|
||||
**
|
||||
|
||||
######
|
||||
# **B**LOCK SUB ARGUMENTS
|
||||
We all know the problem when players should be able to use some of the commands but should not see literally EVERY sub-argument in a command. Well, then just blend them out? ProAntiTab can do this for you and it's very easy to setup as well! (See some examples below)
|
||||
|
||||

|
||||
<details>
|
||||
<summary>example</summary>
|
||||
|
||||
|
||||
```yaml
|
||||
# Let's say you just want to allow "/help Minecraft" only and not "/help apple".
|
||||
# It will also automatically allow everything after "/help Minecraft ..."
|
||||
- help Minecraft
|
||||
|
||||
# [CMD] = Allow the execution of the command
|
||||
# [TAB] = Allow the tab-completion of the command
|
||||
- "[CMD]cmi tpa" # Only executable. Not tab-completable
|
||||
- tpa # Executable & Tab-Completable
|
||||
|
||||
# %hidden_online_players% = Online players (Removed from tab-completion)
|
||||
# %online_players% = Online players
|
||||
# %hidden_players% = Registered players (Removed from tab-completion)
|
||||
# %players% = Registered players
|
||||
# %numbers% = Numbers, such as 1000 or 1.000
|
||||
# _- = Block everything after
|
||||
- "tpa %online_players%"
|
||||
- "sell %numbers%"
|
||||
|
||||
# Using the operator _- at the end cancels every argument afterwards and blocks it.
|
||||
# This will allow the player to use "/help Minecraft" but not "/help Minecraft xyz"
|
||||
- help Minecraft _-
|
||||
```
|
||||
</details>
|
||||
|
||||
######
|
||||
# **B**LOCK COLLON COMMANDS
|
||||
It's annyoing after some time to block all commands including collons like essentials:spawn. With this option you can disable them entirely for good! Only people with the proantitab.namespace permission can see these commands again.
|
||||
|
||||

|
||||
<details>
|
||||
<summary>open config.yml section</summary>
|
||||
|
||||
|
||||
```yaml
|
||||
#>> HTP (Overwritten)
|
||||
# Here you can disable all namespace commands.
|
||||
# Namespace commands are commands like plugin:command (e.g: essentials:warp)
|
||||
# You can bypass this restriction with the proantitab.namespace permission.
|
||||
block-namespace-commands:
|
||||
enabled: false
|
||||
```
|
||||
</details>
|
||||
|
||||
######
|
||||
# **C**USTOM PLUGINS LIST
|
||||
Just blocking the /plugins command is pretty boring. This feature here allows you to make it more interesting by displaying for example fake plugins.
|
||||
|
||||

|
||||
<details>
|
||||
<summary>open config.yml section</summary>
|
||||
|
||||
|
||||
```yaml
|
||||
#>> HTP (Overwritten)
|
||||
# Here you can customize your own fake '/plugins' command.
|
||||
custom-plugins:
|
||||
enabled: true
|
||||
commands:
|
||||
- pl
|
||||
- plugins
|
||||
- bukkit:pl
|
||||
- bukkit:plugins
|
||||
message:
|
||||
- '&fPlugins (0):'
|
||||
```
|
||||
</details>
|
||||
|
||||
######
|
||||
# **C**USTOM VERSION COMMAND
|
||||
Who wouldn't like to pretend to own a custom server-jar? Have fun customizing your very own /version command to your personal liking.
|
||||
|
||||

|
||||
<details>
|
||||
<summary>open config.yml section</summary>
|
||||
|
||||
|
||||
```yaml
|
||||
#>> HTP (Overwritten)
|
||||
# Here you can customize your own fake '/version' command.
|
||||
custom-version:
|
||||
enabled: true
|
||||
commands:
|
||||
- version
|
||||
- ver
|
||||
- icanhasbukkit
|
||||
- bukkit:ver
|
||||
- bukkit:version
|
||||
message:
|
||||
- '&fThis server is running CraftBukkit version git-NasaSpigot-294 (MC: X)'
|
||||
```
|
||||
</details>
|
||||
|
||||
######
|
||||
# **C**USTOM UNKNOWN COMMAND MESSAGE
|
||||
The Bukkit/Spigot version of ProAntiTab gives your the possibility to create your own unknown-command message to align it with the blocked-command message for example.
|
||||
|
||||

|
||||
<details>
|
||||
<summary>open config.yml section</summary>
|
||||
|
||||
|
||||
```yaml
|
||||
# Now there we come to the good stuff! ^^
|
||||
# If ProAntiTab is loaded on a Spigot server, you will see this option right here.
|
||||
# With that you can also customize your own "Unknown Command"-message.
|
||||
custom-unknown-command:
|
||||
enabled: true
|
||||
message:
|
||||
- '&cThis command does not exist!'
|
||||
```
|
||||
</details>
|
||||
|
||||
|
||||
######
|
||||
# **C**USTOM PROTOCOL PING
|
||||
Do you know the red text message at the players count when you ping a server with the wrong version? Exactly this holds the information of what kind of server your proxy server is running at. This feature hides the version of the proxy with a custom made one. It's enabled by default but doesn't show the text. The text can be seen when someone pings the server with the wrong version or uses a resolver. This picture shows you what someone with the wrong version would see, unless the "always-show" is enabled. If this option is enabled, this text will always appear.
|
||||
|
||||
 <details>
|
||||
<summary>open config.yml section</summary>
|
||||
|
||||
|
||||
```yaml
|
||||
# Change the protocol for the version name when the server is being pinged
|
||||
# (!) Warning: It's required to use Paper or Purpur to use this feature!
|
||||
# (!) Supported server versions: 1.12.2 - latest
|
||||
custom-protocol-ping:
|
||||
enabled: false
|
||||
|
||||
# Normally it would only display when someone pings the server with the wrong version.
|
||||
# Enabling this will always display the protocol and replace it with the normal player count.
|
||||
always-show: false
|
||||
|
||||
# This number here determines the outcome for the %online_extended% placeholder.
|
||||
# It's the current amount of players increased by this number.
|
||||
# For example: 5/20 becomes 6/20
|
||||
extend-online-count: 1
|
||||
# true: Use new calculated online-count (%online_extended%) as max-players count.
|
||||
# false: Use the default max-players count.
|
||||
use-as-maxplayers: false
|
||||
|
||||
# Enabling this option hides the list of players on your server,
|
||||
# when you hover over the player count.
|
||||
hide-players: true
|
||||
|
||||
# The displayed protocol message
|
||||
# Available placeholders:
|
||||
# %online% - current online player count
|
||||
# %online_extended% - manipulated online player count
|
||||
# %max% - max player count
|
||||
protocol: '&f&lProAntiTab &7(&a%online%&7/&c%max%&7)'
|
||||
```
|
||||
</details>
|
||||
|
||||
######
|
||||
# **C**USTOM RESPONSE ACTIONS
|
||||
For some, it's important to determine how the response message should be or what should happen. You can customize that factor to your personal liking and use different actions to have full control over your blocked commands.
|
||||
|
||||

|
||||
|
||||

|
||||
<details>
|
||||
<summary>Bukkit/Spigot examples</summary>
|
||||
|
||||
|
||||
```yaml
|
||||
# ____ ___ __ _ ______ __
|
||||
# / __ \_________ / | ____ / /_(_)_ __/___ _/ /_
|
||||
# / /_/ / ___/ __ \/ /| | / __ \/ __/ / / / / __ `/ __ \
|
||||
# / ____/ / / /_/ / ___ |/ / / / /_/ / / / / /_/ / /_/ /
|
||||
# /_/ /_/ \____/_/ |_/_/ /_/\__/_/ /_/ \__,_/_.___/
|
||||
# custom-responses.yml
|
||||
#
|
||||
# Here you can configure a few of the blocked commands a bit further.
|
||||
# But what exactly is this here? Every command that would normally respond with the typical "command is blocked" message, can be configured in here!
|
||||
# And how does it work? It's simple. You just provide the a trigger of the command that would be normally blocked.
|
||||
# Commands that would normally work won't send the messages you have set here.
|
||||
# This way PAT can offer you full control over certain commands and their normal responses.
|
||||
# What are these action section at each block?
|
||||
# This is an additional feature to make your responses much more alive.
|
||||
# Example actions that can be used are the following:
|
||||
# Execute console command:
|
||||
# Syntax: console::command
|
||||
# Example: console::say %player% is an evil player
|
||||
# Execute player command:
|
||||
# Syntax: execute::command
|
||||
# Example: execute::help
|
||||
# Send actionbar:
|
||||
# Syntax: actionbar::text
|
||||
# Example: actionbar::&cThis is not cool %player%!
|
||||
# Send title:
|
||||
# Syntax: title::title::subtitle::5::20::5
|
||||
# Example: title::&aTest title::&cHello %player%!
|
||||
# Play sound:
|
||||
# Syntax: sound::soundName::volume::pitch
|
||||
# Example: sound::ENTITY_ENDER_DRAGON_GROWL::1.0::1.0
|
||||
# Give potion effect:
|
||||
# Syntax: effect::potionEffect::duration::amplifier
|
||||
# Example: effect::BLINDNESS::45::1
|
||||
|
||||
# Here are a few examples:
|
||||
|
||||
# Example with kits.
|
||||
# In here we only trigger the given message, if the player would type "/kit ...".
|
||||
# If this command would work through sub-arguments, then the player would only able to execute the command with the
|
||||
# listed sub-arguments assigned to it. Everything else will result with the set message in there.
|
||||
# --
|
||||
#example-with-kits:
|
||||
# triggers:
|
||||
# - "kit *"
|
||||
# message:
|
||||
# - "&cThis kit does not exist!"
|
||||
# actions:
|
||||
# - "actionbar::&cSorry %player%, but this kit does not exist!"
|
||||
|
||||
# Here another example with an auctionhouse plugin.
|
||||
# In here we only trigger the given message, if the player would type "/ah plugin".
|
||||
# Normally it would print out the "command is blocked" message, because PAT would have blocked it in our case.
|
||||
# Therefore, we can also assign a custom response message to it.
|
||||
# ---
|
||||
#example-with-auctionhouse:
|
||||
# triggers:
|
||||
# - "ah plugin"
|
||||
# message:
|
||||
# - "&cThis sub-command does not exist. Please type: &e/ah help"
|
||||
# actions:
|
||||
# - "console::say That's not nice %player%!"
|
||||
# - "effect::BLINDNESS::45::1"
|
||||
# - "sound::ENTITY_ENDER_DRAGON_GROWL::1.0::1.0"
|
||||
# - "title::&cHey!::&cYou can't do that %player%!::5::20::5"
|
||||
# - "actionbar::&cNop, sorry %player%"
|
||||
```
|
||||
</details>
|
||||
|
||||
<details>
|
||||
<summary>Proxy examples</summary>
|
||||
|
||||
|
||||
```yaml
|
||||
# ____ ___ __ _ ______ __
|
||||
# / __ \_________ / | ____ / /_(_)_ __/___ _/ /_
|
||||
# / /_/ / ___/ __ \/ /| | / __ \/ __/ / / / / __ `/ __ \
|
||||
# / ____/ / / /_/ / ___ |/ / / / /_/ / / / / /_/ / /_/ /
|
||||
# /_/ /_/ \____/_/ |_/_/ /_/\__/_/ /_/ \__,_/_.___/
|
||||
# custom-responses.yml
|
||||
#
|
||||
# Here you can configure a few of the blocked commands a bit further.
|
||||
# But what exactly is this here? Every command that would normally respond with the typical "command is blocked" message, can be configured in here!
|
||||
# And how does it work? It's simple. You just provide the a trigger of the command that would be normally blocked.
|
||||
# Commands that would normally work won't send the messages you have set here.
|
||||
# This way PAT can offer you full control over certain commands and their normal responses.
|
||||
# What are these action section at each block?
|
||||
# This is an additional feature to make your responses much more alive.
|
||||
# Example actions that can be used are the following:
|
||||
# Execute console command:
|
||||
# Syntax: console::command
|
||||
# Example: console::send %player% fallback
|
||||
# Execute player command:
|
||||
# Syntax: execute::command
|
||||
# Example: execute::help
|
||||
# Send actionbar:
|
||||
# Syntax: actionbar::text
|
||||
# Example: actionbar::&cThis is not cool %player%!
|
||||
# Send title:
|
||||
# Syntax: title::title::subtitle::5::20::5
|
||||
# Example: title::&aTest title::&cHello %player%!
|
||||
|
||||
# Here are a few examples:
|
||||
|
||||
# Example with kits.
|
||||
# In here we only trigger the given message, if the player would type "/kit ...".
|
||||
# If this command would work through sub-arguments, then the player would only able to execute the command with the
|
||||
# listed sub-arguments assigned to it. Everything else will result with the set message in there.
|
||||
# --
|
||||
#example-with-kits:
|
||||
# triggers:
|
||||
# - "kit *"
|
||||
# message:
|
||||
# - "&cThis kit does not exist!"
|
||||
# actions:
|
||||
# - "actionbar::&cSorry %player%, but this kit does not exist!"
|
||||
|
||||
# Here another example with an auctionhouse plugin.
|
||||
# In here we only trigger the given message, if the player would type "/ah plugin".
|
||||
# Normally it would print out the "command is blocked" message, because PAT would have blocked it in our case.
|
||||
# Therefore, we can also assign a custom response message to it.
|
||||
# ---
|
||||
#example-with-auctionhouse:
|
||||
# triggers:
|
||||
# - "ah plugin"
|
||||
# message:
|
||||
# - "&cThis sub-command does not exist. Please type: &e/ah help"
|
||||
# actions:
|
||||
# - "console::say That's not nice %player%!"
|
||||
# - "title::Hey!::You can't do that %player%!::30::3000::30"
|
||||
# - "actionbar::Nop, sorry %player%"
|
||||
```
|
||||
</details>
|
||||
|
||||
#####
|
||||
# **N**EGATE COMMANDS
|
||||
It's not a must to write each and every possible sub-argument by hand. The same goes for commands in general.
|
||||
You can negate them with the help of the negation operator (``!``).
|
||||
|
||||
**
|
||||
|
||||
<details>
|
||||
<summary>example</summary>
|
||||
|
||||
```yaml
|
||||
# Allows /gamemode and all of its sub-arguments
|
||||
# except "/gamemode creative"
|
||||
- "gamemode"
|
||||
- "!gamemode creative"
|
||||
- '!gamemode toggle'
|
||||
```
|
||||
|
||||
```yaml
|
||||
# Allows all commands, except /anvil
|
||||
- "*"
|
||||
- "!anvil"
|
||||
```
|
||||
</details>
|
||||
|
||||
#####
|
||||
# **A**UTO-ADD ALL PLUGIN COMMANDS
|
||||
Sometimes it's so annoying to add all commands from a certain plugin by hand. That's why ProAntiTab offers the possebility to simply add all commands from a certain plugin with a simple shortcut.
|
||||
|
||||
You can simply add ``plugin=<plugin-name>`` to add all commands from a plugin automatically.
|
||||
**Only works for standalone Spigot (+Forks) servers**
|
||||
|
||||
<details>
|
||||
<summary>example</summary>
|
||||
|
||||
```yaml
|
||||
# Allows all Essentials commands except /anvil.
|
||||
# /gamemode is limited to only two sub-arguments
|
||||
- "plugin=essentials"
|
||||
- "!anvil"
|
||||
- "gamemode creative"
|
||||
- "gamemode survival"
|
||||
```
|
||||
</details>
|
||||
|
||||
######
|
||||
# **B**LOCK ON SPECIFIC SERVERS
|
||||
If you use ProAntiTab on a network, you can pretty easily manage on what servers what commands should exist. Everything can be handled via the proxy and does not require additional maintenance on the backend servers.
|
||||
|
||||
For this, just follow the official [setup](https://github.com/RayzsYT/ProAntiTab/wiki/How-to-setup#proxy--spigot-eg-bungeecord--spigot) and [how-to](https://github.com/RayzsYT/ProAntiTab/wiki/How-to#introduction) guide, which can be both found on the [Github wiki](https://github.com/RayzsYT/ProAntiTab/wiki).
|
||||
|
||||
######
|
||||
# **G**ROUP SYSYTEM
|
||||
The PAT group system allows you to allow certain commands only for a certain group of people. PAT group commands are mainly for **whitelisting** commands, can merge with other groups, and so on.
|
||||
|
||||
They can also be used to blacklist commands by negating the commands inside there. But for this to work, the option `allow-group-overruling` inside the `config.yml` needs to be enabled.
|
||||
|
||||
How to use the PAT group system in general can be seen on the [Github wiki](https://github.com/RayzsYT/ProAntiTab/wiki/How-to#use-the-group-system).
|
||||
|
||||
######
|
||||
# **P**LACEHOLDERAPI & PAPIPROXYBRIDGE SUPPORT
|
||||
Customization and uniqueness is an important factor for many server owners. That's why PAT offers you the possebility to edit and use many of its placeholders with the widely spreaded plugin [PlaceholderAPI](https://www.spigotmc.org/resources/6245/). Accessing those placeholders on the proxy isn't a problem either. With the support of the addtional plugin [PAPIProxyBridge](https://www.spigotmc.org/resources/108415/), PAT's placeholders are even accessable on your proxy server.
|
||||
<details>
|
||||
<summary>Available placeholders</summary>
|
||||
|
||||
```yaml
|
||||
# Some general Placeholders to work with:
|
||||
# %pat_general_user% = Get the name of the user who receives this message.
|
||||
# %pat_general_version_current% = Get current version name of PAT.
|
||||
# %pat_general_version_newest% = Get newest version name of PAT.
|
||||
|
||||
# Placeholders of some of the messages in the config.yml:
|
||||
# %pat_message_unknowncommand% = Get the "unknown command"-message from the config.yml of PAT. [cancel-blocked-command]
|
||||
# %pat_message_blocked% = Get the "command blocked"-message from the config.yml of PAT. [custom-unknown-command]
|
||||
|
||||
# Placeholders to list all commands:
|
||||
# %pat_list_size_commands% = Get the amount of all listed commands.
|
||||
# %pat_list_commands% = Get all listed commands.
|
||||
# %pat_list_sorted_commands% = Get all listed commands in alphabetic order. (A-Z)
|
||||
# %pat_list_reversed_groups% = Get all listed commands in reversed alphabetic order. (Z-A)
|
||||
|
||||
# Placeholders to list all commands of a group: (replace 'xxx' with the group-name)
|
||||
# %pat_list_size_commands_group_xxx% = Get the amount of all commands of a group.
|
||||
# %pat_list_commands_group_xxx% = Get all commands of a group.
|
||||
# %pat_list_sorted_commands_group_xxx% = Get all commands of a group in alphabetic order. (A-Z)
|
||||
# %pat_list_reversed_commands_group_xxx% = Get all commands of a group in reversed alphabetic order. (Z-A)
|
||||
|
||||
# Placeholders to list all groups:
|
||||
# %pat_list_size_groups% = Get the amount of all available groups.
|
||||
# %pat_list_groups% = Get all groups.
|
||||
# %pat_list_sorted_groups% = Get all groups in alphabetic order. (A-Z)
|
||||
# %pat_list_reversed_groups% = Get all groups in reversed alphabetic order. (Z-A)
|
||||
```
|
||||
</details>
|
||||
|
||||
###
|
||||
|
||||
# **M**INIMESSAGE SUPPORT
|
||||
## 
|
||||
##### You want to design your messages more unique? We got you covered! *(works on 1.17 server and above)*
|
||||
*([Click here to see the documentation for the format](https://docs.advntr.dev/minimessage/format.html#)*)
|
||||
|
||||
Look at those few examples to see what kind of possibilities awaits you:
|
||||
<details>
|
||||
<summary>example 1</summary>
|
||||
|
||||
|
||||
```yaml
|
||||
cancel-blocked-commands:
|
||||
enabled: true
|
||||
message: '<hover:show_text:"&cBlocked command: &4&o%command%">&cThis command is &4&lBLOCKED&c!'
|
||||
```
|
||||
|
||||
|
||||

|
||||
|
||||
</details>
|
||||
|
||||
<details>
|
||||
<summary>example 2</summary>
|
||||
|
||||
|
||||
```yaml
|
||||
cancel-blocked-commands:
|
||||
enabled: true
|
||||
message: '&cThis command is blocked! <click:suggest_command:/help>&7Click here to get a view of all available commands instead.'
|
||||
```
|
||||
|
||||
|
||||

|
||||
|
||||
</details>
|
||||
|
||||
|
||||
######
|
||||
# **H**OW TO SETUP?
|
||||
Despite of the fact that ProAntiTab is pretty easy to use, the setup is slidely different for each server engine.
|
||||
It normally is already enough to simply load ProAntiTab on the certain server you wanna use it, but in order to use ProAntiTab with all its features, its recommended to follow the [official setup guide on the Github wiki](https://github.com/RayzsYT/ProAntiTab/wiki/How-to-setup).
|
||||
|
||||
**Please feel free to join the [Discord](https://www.rayzs.de/discord) server to request for help if the instruction is unclear or too complicated. ^^**
|
||||
|
||||
|
||||
#
|
||||
# **H**OW TO ALLOW COMMANDS?
|
||||
[Please check out the wiki to get an idea on how PAT works and can be used.](https://github.com/RayzsYT/ProAntiTab/wiki/How-to)
|
||||
|
||||
If you want to bypass all blocked commands, simply give yourself the following permission: **proantitab.bypass**
|
||||
|
||||
Following permission is required to execute all listed commands within a certain group: **proantitab.group.<command>**
|
||||
|
||||
######
|
||||
# **C**OMMANDS & PERMISSIONS
|
||||
All commands and their permissions are listed on the [documentation](https://www.spigotmc.org/resources/113172/field?field=documentation) page at the very buttom.
|
||||
|
||||
######
|
||||
# **C**ONFIGURATION FILE
|
||||
|
||||
<details>
|
||||
<summary>Bukkit/Spigot</summary>
|
||||
|
||||
[config.yml](https://github.com/RayzsYT/ProAntiTab/blob/v2.0.1/src/main/resources/files/bukkit-config.yml)
|
||||
<br>
|
||||
[storage.yml](https://github.com/RayzsYT/ProAntiTab/blob/v2.0.1/src/main/resources/files/bukkit-storage.yml)
|
||||
|
||||
</details>
|
||||
|
||||
|
||||
<details>
|
||||
<summary>Proxy (Bungeecord/Velocity)</summary>
|
||||
|
||||
[config.yml](https://github.com/RayzsYT/ProAntiTab/blob/v2.0.1/src/main/resources/files/proxy-config.yml)
|
||||
<br>
|
||||
[storage.yml](https://github.com/RayzsYT/ProAntiTab/blob/v2.0.1/src/main/resources/files/proxy-storage.yml)
|
||||
|
||||
</details>
|
||||
|
||||
######
|
||||
## **bStats**
|
||||
[](https://bstats.org/plugin/bukkit/proantitab%20-%20spigot/20089)
|
||||
|
||||
[](https://bstats.org/plugin/bungeecord/proantitab%20-%20bungeecord/20090)
|
||||
|
||||
[](https://bstats.org/plugin/velocity/proantitab%20-%20velocity/21638)
|
||||
|
||||
<center>
|
||||
|
||||
[](https://www.rayzs.de/discord)
|
||||
@@ -6,11 +6,11 @@
|
||||
|
||||
<groupId>de.rayzs.pat</groupId>
|
||||
<artifactId>ProAntiTab</artifactId>
|
||||
<version>2.0.21</version>
|
||||
<version>2.3.4</version>
|
||||
|
||||
<properties>
|
||||
<maven.compiler.source>8</maven.compiler.source>
|
||||
<maven.compiler.target>8</maven.compiler.target>
|
||||
<maven.compiler.source>17</maven.compiler.source>
|
||||
<maven.compiler.target>17</maven.compiler.target>
|
||||
</properties>
|
||||
|
||||
<repositories>
|
||||
@@ -34,6 +34,11 @@
|
||||
<url>https://jitpack.io</url>
|
||||
</repository>
|
||||
|
||||
<repository>
|
||||
<id>placeholderapi</id>
|
||||
<url>https://repo.helpch.at/releases/</url>
|
||||
</repository>
|
||||
|
||||
<repository>
|
||||
<id>velocity</id>
|
||||
<url>https://repo.velocitypowered.com/snapshots/</url>
|
||||
@@ -50,11 +55,6 @@
|
||||
<url>https://oss.sonatype.org/content/repositories/snapshots</url>
|
||||
</repository>
|
||||
|
||||
<repository>
|
||||
<id>placeholderapi</id>
|
||||
<url>https://repo.extendedclip.com/content/repositories/placeholderapi/</url>
|
||||
</repository>
|
||||
|
||||
<repository>
|
||||
<id>viaversion-repo</id>
|
||||
<url>https://repo.viaversion.com</url>
|
||||
@@ -100,7 +100,7 @@
|
||||
<dependency>
|
||||
<groupId>net.md-5</groupId>
|
||||
<artifactId>bungeecord-api</artifactId>
|
||||
<version>1.20-R0.3-SNAPSHOT</version>
|
||||
<version>1.21-R0.5-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
@@ -192,14 +192,14 @@
|
||||
<dependency>
|
||||
<groupId>com.velocitypowered</groupId>
|
||||
<artifactId>velocity-api</artifactId>
|
||||
<version>3.1.1-SNAPSHOT</version>
|
||||
<version>3.5.0-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.velocitypowered</groupId>
|
||||
<artifactId>velocity-proxy</artifactId>
|
||||
<version>3.3.0-SNAPSHOT</version>
|
||||
<version>3.5.0-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
@@ -227,42 +227,42 @@
|
||||
<dependency>
|
||||
<groupId>net.kyori</groupId>
|
||||
<artifactId>adventure-text-minimessage</artifactId>
|
||||
<version>4.25.0</version>
|
||||
<version>4.26.1</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>net.kyori</groupId>
|
||||
<artifactId>adventure-api</artifactId>
|
||||
<version>4.25.0</version>
|
||||
<version>4.26.1</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>net.kyori</groupId>
|
||||
<artifactId>adventure-platform-api</artifactId>
|
||||
<version>4.3.3</version>
|
||||
<version>4.4.1</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>net.kyori</groupId>
|
||||
<artifactId>adventure-platform-bungeecord</artifactId>
|
||||
<version>4.3.4</version>
|
||||
<version>4.4.1</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>net.kyori</groupId>
|
||||
<artifactId>adventure-platform-bukkit</artifactId>
|
||||
<version>4.3.4</version>
|
||||
<version>4.4.1</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>me.clip</groupId>
|
||||
<artifactId>placeholderapi</artifactId>
|
||||
<version>2.11.5</version>
|
||||
<version>2.12.2</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
@@ -276,7 +276,7 @@
|
||||
<dependency>
|
||||
<groupId>com.viaversion</groupId>
|
||||
<artifactId>viaversion-api</artifactId>
|
||||
<version>LATEST</version>
|
||||
<version>5.7.0-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
@@ -291,6 +291,16 @@
|
||||
|
||||
<build>
|
||||
<finalName>IgnoreThisJar</finalName>
|
||||
|
||||
<resources>
|
||||
<resource>
|
||||
<directory>src/main/resources</directory>
|
||||
<excludes>
|
||||
<exclude>*.txt</exclude>
|
||||
</excludes>
|
||||
</resource>
|
||||
</resources>
|
||||
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
@@ -317,8 +327,8 @@
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<configuration>
|
||||
<source>16</source>
|
||||
<target>16</target>
|
||||
<source>17</source>
|
||||
<target>17</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
|
||||
@@ -1,24 +0,0 @@
|
||||
package de.rayzs.pat.api.brand;
|
||||
|
||||
import de.rayzs.pat.api.brand.impl.*;
|
||||
import de.rayzs.pat.api.storage.Storage;
|
||||
import de.rayzs.pat.utils.PacketUtils;
|
||||
import de.rayzs.pat.utils.Reflection;
|
||||
|
||||
public class CustomServerBrand {
|
||||
|
||||
public static final String CHANNEL_NAME = Reflection.getMinor() < 13 ? "MC|Brand" : "minecraft:brand";
|
||||
private static final ServerBrand SERVER_BRAND = Reflection.isVelocityServer() ? new VelocityServerBrand() : Reflection.isProxyServer() ? new BungeeServerBrand() : new BukkitServerBrand();
|
||||
|
||||
public static void initialize() { refreshTask(); }
|
||||
public static void refreshTask() { SERVER_BRAND.initializeTask(); }
|
||||
public static void preparePlayer(Object playerObj) { SERVER_BRAND.preparePlayer(playerObj); }
|
||||
public static void sendBrandToPlayer(Object playerObj) { SERVER_BRAND.send(playerObj); }
|
||||
|
||||
public static PacketUtils.BrandManipulate createBrandPacket(Object playerObj) { return SERVER_BRAND.createPacket(playerObj); }
|
||||
public static boolean isEnabled() { return Storage.ConfigSections.Settings.CUSTOM_BRAND.ENABLED; }
|
||||
|
||||
public static boolean isBrandTag(String tag) {
|
||||
return tag.equals("MC|Brand") || tag.equals("minecraft:brand");
|
||||
}
|
||||
}
|
||||
@@ -1,133 +0,0 @@
|
||||
package de.rayzs.pat.api.brand.impl;
|
||||
|
||||
import de.rayzs.pat.api.brand.CustomServerBrand;
|
||||
import de.rayzs.pat.api.netty.bukkit.BukkitPacketAnalyzer;
|
||||
import de.rayzs.pat.api.brand.ServerBrand;
|
||||
import de.rayzs.pat.utils.message.MessageTranslator;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
import de.rayzs.pat.api.storage.Storage;
|
||||
import de.rayzs.pat.plugin.BukkitLoader;
|
||||
import de.rayzs.pat.utils.scheduler.PATScheduler;
|
||||
import de.rayzs.pat.utils.scheduler.PATSchedulerTask;
|
||||
import io.netty.channel.Channel;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
import de.rayzs.pat.utils.*;
|
||||
import java.lang.reflect.*;
|
||||
import org.bukkit.*;
|
||||
import java.util.*;
|
||||
|
||||
public class BukkitServerBrand implements ServerBrand {
|
||||
|
||||
private static final Server SERVER = Bukkit.getServer();
|
||||
private static String BRAND = Storage.ConfigSections.Settings.CUSTOM_BRAND.BRANDS.getLines().get(0);
|
||||
private static PATSchedulerTask TASK;
|
||||
private static boolean INITIALIZED = false, NO_PREP_CHANNELS = false;
|
||||
private static Class<?> brandPayloadClass, clientBoundCustomPacketPayloadPacketClass, customPacketPayloadPacketClass;
|
||||
|
||||
@Override
|
||||
public void initializeTask() {
|
||||
|
||||
if (Reflection.isWeird()) {
|
||||
|
||||
NO_PREP_CHANNELS = Reflection.getMinor() >= 22 || (Reflection.getMinor() == 21 && Reflection.getRelease() >= 7);
|
||||
|
||||
if (brandPayloadClass == null)
|
||||
brandPayloadClass = Reflection.getClass("net.minecraft.network.protocol.common.custom.BrandPayload");
|
||||
|
||||
if (clientBoundCustomPacketPayloadPacketClass == null)
|
||||
clientBoundCustomPacketPayloadPacketClass = Reflection.getClass("net.minecraft.network.protocol.common.ClientboundCustomPayloadPacket");
|
||||
|
||||
if (customPacketPayloadPacketClass == null)
|
||||
customPacketPayloadPacketClass = Reflection.getClass("net.minecraft.network.protocol.common.custom.CustomPacketPayload");
|
||||
}
|
||||
|
||||
Bukkit.getOnlinePlayers().forEach(this::preparePlayer);
|
||||
if (!INITIALIZED)
|
||||
try {
|
||||
Method method = Reflection.getMethodsByParameterAndName(SERVER.getMessenger(), "addToOutgoing", Plugin.class, String.class).get(0);
|
||||
Reflection.invokeMethode(method, SERVER.getMessenger(), BukkitLoader.getPlugin(), CustomServerBrand.CHANNEL_NAME);
|
||||
SERVER.getMessenger().registerOutgoingPluginChannel(BukkitLoader.getPlugin(), CustomServerBrand.CHANNEL_NAME);
|
||||
INITIALIZED = true;
|
||||
} catch (Exception exception) {
|
||||
exception.printStackTrace();
|
||||
}
|
||||
|
||||
if(TASK != null && TASK.isActive()) {
|
||||
TASK.cancelTask();
|
||||
TASK = null;
|
||||
}
|
||||
|
||||
if(!Storage.ConfigSections.Settings.CUSTOM_BRAND.ENABLED) return;
|
||||
|
||||
if(Storage.ConfigSections.Settings.CUSTOM_BRAND.REPEAT_DELAY == -1) {
|
||||
BRAND = Storage.ConfigSections.Settings.CUSTOM_BRAND.BRANDS.getLines().get(0) + "§r";
|
||||
|
||||
PATScheduler.createAsyncScheduler(() -> {
|
||||
Bukkit.getOnlinePlayers().forEach(this::send);
|
||||
}, 1, 1);
|
||||
|
||||
} else {
|
||||
AtomicInteger animationState = new AtomicInteger(0);
|
||||
TASK = PATScheduler.createAsyncScheduler(() -> {
|
||||
if (animationState.getAndIncrement() >= Storage.ConfigSections.Settings.CUSTOM_BRAND.BRANDS.getLines().size() - 1)
|
||||
animationState.set(0);
|
||||
BRAND = Storage.ConfigSections.Settings.CUSTOM_BRAND.BRANDS.getLines().get(animationState.get()) + "§r";
|
||||
Bukkit.getOnlinePlayers().forEach(this::send);
|
||||
}, 1, Storage.ConfigSections.Settings.CUSTOM_BRAND.REPEAT_DELAY);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void preparePlayer(Object playerObj) {
|
||||
if(!(playerObj instanceof Player) || !Storage.ConfigSections.Settings.CUSTOM_BRAND.ENABLED) return;
|
||||
Player player = (Player) playerObj;
|
||||
|
||||
if (NO_PREP_CHANNELS) {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
Field channelsField = Reflection.getFieldByName(player.getClass(), "channels");
|
||||
Set<String> channels = (Set<String>) channelsField.get(player);
|
||||
channels.add(CustomServerBrand.CHANNEL_NAME);
|
||||
Reflection.closeAccess(channelsField);
|
||||
|
||||
} catch (Exception exception) {
|
||||
exception.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void send(Object playerObj) {
|
||||
if(!(playerObj instanceof Player) || !Storage.ConfigSections.Settings.CUSTOM_BRAND.ENABLED) return;
|
||||
Player player = (Player) playerObj;
|
||||
String playerName = player.getName(), displayName = player.getDisplayName(), worldName = player.getWorld().getName(),
|
||||
customBrand = BRAND.replace("%player%", playerName).replace("%displayname%", displayName).replace("%world%", worldName);
|
||||
|
||||
if(!Reflection.isWeird()) {
|
||||
PacketUtils.BrandManipulate serverBrand = new PacketUtils.BrandManipulate(MessageTranslator.replaceMessage(player, customBrand));
|
||||
player.sendPluginMessage(BukkitLoader.getPlugin(), CustomServerBrand.CHANNEL_NAME, serverBrand.getBytes());
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
Channel channel = BukkitPacketAnalyzer.INJECTED_PLAYERS.get(player.getUniqueId());
|
||||
if(channel == null) return;
|
||||
|
||||
Object brandPayloadObj = brandPayloadClass.getDeclaredConstructor(String.class).newInstance(MessageTranslator.replaceMessage(player, customBrand)),
|
||||
customPacketPayloadPacket = clientBoundCustomPacketPayloadPacketClass.getDeclaredConstructor(customPacketPayloadPacketClass).newInstance(brandPayloadObj);
|
||||
|
||||
channel.pipeline().writeAndFlush(customPacketPayloadPacket);
|
||||
|
||||
} catch (Exception exception) {
|
||||
exception.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public PacketUtils.BrandManipulate createPacket(Object playerObj) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -1,73 +0,0 @@
|
||||
package de.rayzs.pat.api.brand.impl;
|
||||
|
||||
import de.rayzs.pat.utils.message.MessageTranslator;
|
||||
import net.md_5.bungee.api.scheduler.ScheduledTask;
|
||||
import net.md_5.bungee.protocol.ProtocolConstants;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
import de.rayzs.pat.api.brand.ServerBrand;
|
||||
import net.md_5.bungee.api.connection.*;
|
||||
import de.rayzs.pat.api.storage.Storage;
|
||||
import de.rayzs.pat.plugin.BungeeLoader;
|
||||
import net.md_5.bungee.api.ProxyServer;
|
||||
import de.rayzs.pat.utils.PacketUtils;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
public class BungeeServerBrand implements ServerBrand {
|
||||
|
||||
private static final ProxyServer SERVER = BungeeLoader.getPlugin().getProxy();
|
||||
private static ScheduledTask TASK;
|
||||
private static String BRAND = Storage.ConfigSections.Settings.CUSTOM_BRAND.BRANDS.getLines().get(0);
|
||||
|
||||
public BungeeServerBrand() { }
|
||||
|
||||
@Override
|
||||
public void initializeTask() {
|
||||
if(TASK != null) TASK.cancel();
|
||||
|
||||
if(!Storage.ConfigSections.Settings.CUSTOM_BRAND.ENABLED) return;
|
||||
|
||||
if(Storage.ConfigSections.Settings.CUSTOM_BRAND.REPEAT_DELAY == -1) {
|
||||
BRAND = MessageTranslator.replaceMessage(Storage.ConfigSections.Settings.CUSTOM_BRAND.BRANDS.getLines().get(0)) + "§r";
|
||||
SERVER.getPlayers().forEach(this::send);
|
||||
} else {
|
||||
AtomicInteger animationState = new AtomicInteger(0);
|
||||
TASK = SERVER.getScheduler().schedule(BungeeLoader.getPlugin(), () -> {
|
||||
if (animationState.getAndIncrement() >= Storage.ConfigSections.Settings.CUSTOM_BRAND.BRANDS.getLines().size() - 1)
|
||||
animationState.set(0);
|
||||
BRAND = MessageTranslator.replaceMessage(Storage.ConfigSections.Settings.CUSTOM_BRAND.BRANDS.getLines().get(animationState.get())) + "§r";
|
||||
SERVER.getPlayers().forEach(this::send);
|
||||
}, 1, Storage.ConfigSections.Settings.CUSTOM_BRAND.REPEAT_DELAY, TimeUnit.MILLISECONDS);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void preparePlayer(Object playerObj) { }
|
||||
|
||||
@Override
|
||||
public void send(Object playerObj) {
|
||||
if (!(playerObj instanceof ProxiedPlayer) || !Storage.ConfigSections.Settings.CUSTOM_BRAND.ENABLED) return;
|
||||
ProxiedPlayer player = (ProxiedPlayer) playerObj;
|
||||
|
||||
String serverName = "", playerName = player.getName(), customBrand;
|
||||
Server server = player.getServer();
|
||||
if(server != null) serverName = server.getInfo().getName();
|
||||
customBrand = BRAND.replace("%player%", playerName).replace("%server%", serverName);
|
||||
|
||||
PacketUtils.BrandManipulate serverBrand = new PacketUtils.BrandManipulate(customBrand);
|
||||
String brand = player.getPendingConnection().getVersion() >= ProtocolConstants.MINECRAFT_1_13 ? "minecraft:brand" : "MC|Brand";
|
||||
player.sendData(brand, serverBrand.getBytes());
|
||||
}
|
||||
|
||||
@Override
|
||||
public PacketUtils.BrandManipulate createPacket(Object playerObj) {
|
||||
if (!(playerObj instanceof ProxiedPlayer) || !Storage.ConfigSections.Settings.CUSTOM_BRAND.ENABLED) return null;
|
||||
ProxiedPlayer player = (ProxiedPlayer) playerObj;
|
||||
|
||||
String serverName = "", playerName = player.getName(), customBrand;
|
||||
Server server = player.getServer();
|
||||
if(server != null) serverName = server.getInfo().getName();
|
||||
customBrand = BRAND.replace("%player%", playerName).replace("%server%", serverName);
|
||||
|
||||
return new PacketUtils.BrandManipulate(customBrand);
|
||||
}
|
||||
}
|
||||
@@ -1,104 +0,0 @@
|
||||
package de.rayzs.pat.api.brand.impl;
|
||||
|
||||
import com.velocitypowered.api.scheduler.ScheduledTask;
|
||||
import de.rayzs.pat.utils.message.MessageTranslator;
|
||||
import net.md_5.bungee.protocol.ProtocolConstants;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
import de.rayzs.pat.api.brand.ServerBrand;
|
||||
import de.rayzs.pat.plugin.VelocityLoader;
|
||||
import de.rayzs.pat.api.storage.Storage;
|
||||
import com.velocitypowered.api.proxy.*;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.lang.reflect.Method;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import de.rayzs.pat.utils.*;
|
||||
import java.util.Optional;
|
||||
|
||||
public class VelocityServerBrand implements ServerBrand {
|
||||
|
||||
private static final ProxyServer SERVER = VelocityLoader.getServer();
|
||||
private static Class<?> pluginMessagePacketClass, minecraftConnectionClass, connectedPlayerConnectionClass;
|
||||
private static Method connectionMethod;
|
||||
private static ScheduledTask TASK;
|
||||
private static String BRAND = Storage.ConfigSections.Settings.CUSTOM_BRAND.BRANDS.getLines().get(0);
|
||||
|
||||
@Override
|
||||
public void initializeTask() {
|
||||
if(TASK != null) TASK.cancel();
|
||||
|
||||
if(!Storage.ConfigSections.Settings.CUSTOM_BRAND.ENABLED) return;
|
||||
|
||||
if(pluginMessagePacketClass == null)
|
||||
pluginMessagePacketClass = Reflection.getClass("com.velocitypowered.proxy.protocol.packet.PluginMessagePacket");
|
||||
|
||||
if(minecraftConnectionClass == null)
|
||||
minecraftConnectionClass = Reflection.getClass("com.velocitypowered.proxy.connection.MinecraftConnection");
|
||||
|
||||
if(connectedPlayerConnectionClass == null)
|
||||
connectedPlayerConnectionClass = Reflection.getClass("com.velocitypowered.proxy.connection.client.ConnectedPlayer");
|
||||
|
||||
if(connectionMethod == null)
|
||||
connectionMethod = Reflection.getMethodByName(connectedPlayerConnectionClass, "getConnection");
|
||||
|
||||
if(Storage.ConfigSections.Settings.CUSTOM_BRAND.REPEAT_DELAY == -1) {
|
||||
BRAND = MessageTranslator.replaceMessage(Storage.ConfigSections.Settings.CUSTOM_BRAND.BRANDS.getLines().get(0)) + "§r";
|
||||
SERVER.getAllPlayers().forEach(this::send);
|
||||
} else {
|
||||
AtomicInteger animationState = new AtomicInteger(0);
|
||||
TASK = SERVER.getScheduler().buildTask(VelocityLoader.getInstance(), () -> {
|
||||
if (animationState.getAndIncrement() >= Storage.ConfigSections.Settings.CUSTOM_BRAND.BRANDS.getLines().size() - 1)
|
||||
animationState.set(0);
|
||||
BRAND = MessageTranslator.replaceMessage(Storage.ConfigSections.Settings.CUSTOM_BRAND.BRANDS.getLines().get(animationState.get())) + "§r";
|
||||
SERVER.getAllPlayers().forEach(this::send);
|
||||
}).repeat(Storage.ConfigSections.Settings.CUSTOM_BRAND.REPEAT_DELAY, TimeUnit.MILLISECONDS).schedule();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void preparePlayer(Object playerObj) { }
|
||||
|
||||
@Override
|
||||
public void send(Object playerObj) {
|
||||
if (!(playerObj instanceof Player) || !Storage.ConfigSections.Settings.CUSTOM_BRAND.ENABLED) return;
|
||||
|
||||
try {
|
||||
Player player = (Player) playerObj;
|
||||
Object connectedPlayerObj = connectedPlayerConnectionClass.cast(player),
|
||||
minecraftConnectionObj = connectionMethod.invoke(connectedPlayerObj);
|
||||
|
||||
String serverName = "", playerName = player.getUsername(), customBrand;
|
||||
Optional<ServerConnection> serverConnection = player.getCurrentServer();
|
||||
if(serverConnection.isPresent()) serverName = serverConnection.get().getServerInfo().getName();
|
||||
customBrand = BRAND.replace("%player%", playerName).replace("%server%", serverName).replace("%ping%", String.valueOf(player.getPing()));
|
||||
|
||||
PacketUtils.BrandManipulate serverBrand = new PacketUtils.BrandManipulate(customBrand, false);
|
||||
String brand = player.getProtocolVersion().getProtocol() >= ProtocolConstants.MINECRAFT_1_13 ? "minecraft:brand" : "MC|Brand";
|
||||
Object pluginMessagePacket = pluginMessagePacketClass.getConstructor(String.class, ByteBuf.class).newInstance(brand, serverBrand.getByteBuf());
|
||||
Reflection.getMethodsByParameterAndName(minecraftConnectionObj, "write", Object.class).get(0).invoke(minecraftConnectionObj, pluginMessagePacket);
|
||||
} catch (Exception exception) {
|
||||
exception.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public PacketUtils.BrandManipulate createPacket(Object playerObj) {
|
||||
if (!(playerObj instanceof Player) || !Storage.ConfigSections.Settings.CUSTOM_BRAND.ENABLED) return null;
|
||||
|
||||
try {
|
||||
Player player = (Player) playerObj;
|
||||
|
||||
String serverName = "", playerName = player.getUsername(), customBrand;
|
||||
Optional<ServerConnection> serverConnection = player.getCurrentServer();
|
||||
|
||||
if(serverConnection.isPresent()) serverName = serverConnection.get().getServerInfo().getName();
|
||||
customBrand = BRAND.replace("%player%", playerName).replace("%server%", serverName).replace("%ping%", String.valueOf(player.getPing()));
|
||||
|
||||
return new PacketUtils.BrandManipulate(customBrand, false);
|
||||
} catch (Exception exception) {
|
||||
exception.printStackTrace();
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -1,41 +0,0 @@
|
||||
package de.rayzs.pat.api.communication;
|
||||
|
||||
import de.rayzs.pat.api.storage.Storage;
|
||||
import de.rayzs.pat.utils.scheduler.*;
|
||||
import org.bukkit.Bukkit;
|
||||
|
||||
public class BackendUpdater {
|
||||
|
||||
private static PATSchedulerTask TASK;
|
||||
|
||||
public static void handle() {
|
||||
if(isRunning() || !shouldRun() || !Storage.ConfigSections.Settings.HANDLE_THROUGH_PROXY.ENABLED) return;
|
||||
start();
|
||||
}
|
||||
|
||||
public static boolean isRunning() {
|
||||
return TASK != null && TASK.isActive();
|
||||
}
|
||||
|
||||
public static void start() {
|
||||
if(isRunning()) return;
|
||||
|
||||
TASK = PATScheduler.createScheduler(() -> {
|
||||
if (shouldRun())
|
||||
Communicator.sendRequest();
|
||||
else
|
||||
stop();
|
||||
}, 5, 20);
|
||||
}
|
||||
|
||||
public static void stop() {
|
||||
if(TASK == null || !TASK.isActive()) return;
|
||||
TASK.cancelTask();
|
||||
TASK = null;
|
||||
}
|
||||
|
||||
private static boolean shouldRun() {
|
||||
int onlinePlayerSize = Bukkit.getOnlinePlayers().size();
|
||||
return onlinePlayerSize >= 1;
|
||||
}
|
||||
}
|
||||
@@ -1,6 +0,0 @@
|
||||
package de.rayzs.pat.api.communication;
|
||||
|
||||
public interface Client {
|
||||
String CHANNEL_NAME = "pat:channel";
|
||||
void send(Object packet);
|
||||
}
|
||||
@@ -1,237 +0,0 @@
|
||||
package de.rayzs.pat.api.communication;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
import de.rayzs.pat.api.communication.client.ClientInfo;
|
||||
import de.rayzs.pat.api.communication.client.impl.BungeeClientInfo;
|
||||
import de.rayzs.pat.api.communication.client.impl.VelocityClientInfo;
|
||||
import de.rayzs.pat.api.communication.impl.BukkitClient;
|
||||
import de.rayzs.pat.api.communication.impl.BungeeClient;
|
||||
import de.rayzs.pat.api.communication.impl.VelocityClient;
|
||||
import de.rayzs.pat.api.event.PATEventHandler;
|
||||
import de.rayzs.pat.api.storage.Storage;
|
||||
import de.rayzs.pat.api.storage.blacklist.impl.GeneralBlacklist;
|
||||
import de.rayzs.pat.api.storage.blacklist.impl.GroupBlacklist;
|
||||
import de.rayzs.pat.plugin.BukkitLoader;
|
||||
import de.rayzs.pat.utils.CommunicationPackets;
|
||||
import de.rayzs.pat.utils.Reflection;
|
||||
import de.rayzs.pat.utils.group.Group;
|
||||
import de.rayzs.pat.utils.group.GroupManager;
|
||||
import de.rayzs.pat.utils.group.TinyGroup;
|
||||
import de.rayzs.pat.utils.permission.PermissionUtil;
|
||||
|
||||
public class Communicator {
|
||||
|
||||
private static final Client CLIENT =
|
||||
Reflection.isVelocityServer() ? new VelocityClient()
|
||||
: Reflection.isProxyServer() ? new BungeeClient()
|
||||
: new BukkitClient();
|
||||
|
||||
private static final UUID SERVER_ID = UUID.randomUUID();
|
||||
|
||||
public static final List<ClientInfo> CLIENTS = new ArrayList<>();
|
||||
|
||||
public static int SERVER_DATA_SYNC_COUNT = 0;
|
||||
public static long LAST_DATA_UPDATE = System.currentTimeMillis(),
|
||||
LAST_SENT_REQUEST = 0,
|
||||
LAST_BUKKIT_SYNC = System.currentTimeMillis();
|
||||
|
||||
public static void sendPacket(Object packet) {
|
||||
CLIENT.send(packet);
|
||||
}
|
||||
|
||||
public static void sendPacket(ClientInfo clientInfo, Object packet) {
|
||||
clientInfo.sendBytes(CommunicationPackets.convertToBytes(packet));
|
||||
}
|
||||
|
||||
public static void receiveInformation(String serverName, Object packet) {
|
||||
ClientInfo client = getClientByName(serverName);
|
||||
|
||||
if (packet instanceof CommunicationPackets.RequestPacket) {
|
||||
|
||||
CommunicationPackets.RequestPacket requestPacket = (CommunicationPackets.RequestPacket) packet;
|
||||
|
||||
if (!requestPacket.isToken(Storage.TOKEN))
|
||||
return;
|
||||
|
||||
if (client == null) {
|
||||
client = Reflection.isVelocityServer()
|
||||
? new VelocityClientInfo(requestPacket.getServerId(), serverName)
|
||||
: new BungeeClientInfo(requestPacket.getServerId(), serverName);
|
||||
|
||||
CLIENTS.add(client);
|
||||
}
|
||||
|
||||
if (!client.compareId(requestPacket.getServerId()))
|
||||
client.setId(requestPacket.getServerId());
|
||||
|
||||
syncData(client.getId());
|
||||
return;
|
||||
}
|
||||
|
||||
if (packet instanceof CommunicationPackets.ForcePermissionResetPacket) {
|
||||
if (Reflection.isProxyServer())
|
||||
return;
|
||||
|
||||
CommunicationPackets.ForcePermissionResetPacket permissionResetPacket = (CommunicationPackets.ForcePermissionResetPacket) packet;
|
||||
if (!permissionResetPacket.isToken(Storage.TOKEN))
|
||||
return;
|
||||
|
||||
if (permissionResetPacket.hasTarget())
|
||||
PermissionUtil.setPlayerPermissions(permissionResetPacket.getTargetUUID());
|
||||
else
|
||||
PermissionUtil.reloadPermissions();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (packet instanceof CommunicationPackets.BackendDataPacket) {
|
||||
CommunicationPackets.BackendDataPacket backendDataPacket = (CommunicationPackets.BackendDataPacket) packet;
|
||||
if (!backendDataPacket.isToken(Storage.TOKEN))
|
||||
return;
|
||||
|
||||
Storage.SERVER_NAME = backendDataPacket.getServerName();
|
||||
return;
|
||||
}
|
||||
|
||||
if (packet instanceof CommunicationPackets.FeedbackPacket) {
|
||||
CommunicationPackets.FeedbackPacket feedbackPacket = (CommunicationPackets.FeedbackPacket) packet;
|
||||
if (!feedbackPacket.isToken(Storage.TOKEN))
|
||||
return;
|
||||
|
||||
String serverId = feedbackPacket.getServerId();
|
||||
|
||||
if (client == null) {
|
||||
client = Reflection.isVelocityServer()
|
||||
? new VelocityClientInfo(feedbackPacket.getServerId(), serverName)
|
||||
: new BungeeClientInfo(feedbackPacket.getServerId(), serverName);
|
||||
|
||||
CLIENTS.add(client);
|
||||
}
|
||||
|
||||
if (!client.compareId(feedbackPacket.getServerId()))
|
||||
client.setId(feedbackPacket.getServerId());
|
||||
|
||||
if (client.hasSentFeedback())
|
||||
return;
|
||||
|
||||
client.setFeedback(true);
|
||||
client.syncTime();
|
||||
SERVER_DATA_SYNC_COUNT++;
|
||||
|
||||
CommunicationPackets.BackendDataPacket backendDataPacket = new CommunicationPackets.BackendDataPacket(Storage.TOKEN, serverId, serverName);
|
||||
sendPacket(client, backendDataPacket);
|
||||
return;
|
||||
}
|
||||
|
||||
if (packet instanceof CommunicationPackets.PacketBundle) {
|
||||
CommunicationPackets.PacketBundle packetBundle = (CommunicationPackets.PacketBundle) packet;
|
||||
if (!packetBundle.isToken(Storage.TOKEN) || !packetBundle.isId(SERVER_ID.toString()))
|
||||
return;
|
||||
|
||||
Storage.USE_VELOCITY = packetBundle.isVelocity();
|
||||
LAST_BUKKIT_SYNC = System.currentTimeMillis();
|
||||
BukkitLoader.synchronize(packetBundle);
|
||||
}
|
||||
}
|
||||
|
||||
public static void syncData() {
|
||||
syncData(null);
|
||||
}
|
||||
|
||||
public static void syncData(String serverId) {
|
||||
if (Storage.ConfigSections.Settings.DISABLE_SYNC.DISABLED)
|
||||
return;
|
||||
|
||||
LAST_DATA_UPDATE = System.currentTimeMillis();
|
||||
ClientInfo clientInfo;
|
||||
|
||||
if(serverId == null) {
|
||||
SERVER_DATA_SYNC_COUNT = 0;
|
||||
CLIENTS.forEach(currentClient -> syncData(currentClient.getId()));
|
||||
return;
|
||||
|
||||
} else {
|
||||
clientInfo = getClientById(serverId);
|
||||
|
||||
if (clientInfo != null)
|
||||
clientInfo.setFeedback(false);
|
||||
|
||||
SERVER_DATA_SYNC_COUNT = Math.max(0, SERVER_DATA_SYNC_COUNT -1);
|
||||
}
|
||||
|
||||
CommunicationPackets.CommandsPacket commandsPacket = new CommunicationPackets.CommandsPacket();
|
||||
CommunicationPackets.GroupsPacket groupsPacket;
|
||||
CommunicationPackets.PacketBundle bundle;
|
||||
List<String> commands = new ArrayList<>();
|
||||
String tempServerName = "";
|
||||
|
||||
if (clientInfo != null && clientInfo.getName() != null) {
|
||||
tempServerName = clientInfo.getName();
|
||||
|
||||
if (!Storage.Blacklist.isIgnoredServer(tempServerName))
|
||||
commands.addAll(Storage.Blacklist.getBlacklist().getCommands());
|
||||
|
||||
List<GeneralBlacklist> serverBlacklists = Storage.Blacklist.getServerBlacklists(clientInfo.getName());
|
||||
serverBlacklists.stream().filter(serverBlacklist ->
|
||||
serverBlacklist != null && serverBlacklist.getCommands() != null
|
||||
).forEach(serverBlacklist ->
|
||||
commands.addAll(serverBlacklist.getCommands())
|
||||
);
|
||||
}
|
||||
|
||||
final String serverName = tempServerName;
|
||||
List<TinyGroup> groups = new ArrayList<>();
|
||||
|
||||
TinyGroup tinyGroup;
|
||||
for (Group group : GroupManager.getGroups()) {
|
||||
if (groups.stream().anyMatch(cTG -> cTG.getGroupName().equals(group.getGroupName())))
|
||||
continue;
|
||||
|
||||
tinyGroup = new TinyGroup(group.getGroupName(), group.getPriority(), group.getAllCommands(serverName));
|
||||
for (GroupBlacklist groupBlacklist : group.getAllServerGroupBlacklist(serverName))
|
||||
tinyGroup.addAll(groupBlacklist.getCommands());
|
||||
|
||||
groups.add(tinyGroup);
|
||||
}
|
||||
|
||||
groupsPacket = new CommunicationPackets.GroupsPacket(groups);
|
||||
commandsPacket.setTurnBlacklistToWhitelist(Storage.ConfigSections.Settings.TURN_BLACKLIST_TO_WHITELIST.ENABLED);
|
||||
commandsPacket.setCommands(commands);
|
||||
|
||||
bundle = new CommunicationPackets.PacketBundle(Storage.TOKEN, serverId, commandsPacket, groupsPacket);
|
||||
clientInfo.sendBytes(CommunicationPackets.convertToBytes(bundle));
|
||||
|
||||
PATEventHandler.callSentSyncEvents(bundle, serverName);
|
||||
}
|
||||
|
||||
public static void sendRequest() {
|
||||
if(System.currentTimeMillis() - LAST_SENT_REQUEST >= 5000) {
|
||||
LAST_SENT_REQUEST = System.currentTimeMillis();
|
||||
sendPacket(new CommunicationPackets.RequestPacket(Storage.TOKEN, SERVER_ID.toString()));
|
||||
}
|
||||
}
|
||||
|
||||
public static void sendPermissionReset() {
|
||||
if(Reflection.isProxyServer())
|
||||
sendPacket(new CommunicationPackets.ForcePermissionResetPacket(Storage.TOKEN));
|
||||
}
|
||||
|
||||
public static void sendFeedback() {
|
||||
sendPacket(new CommunicationPackets.FeedbackPacket(Storage.TOKEN, SERVER_ID.toString()));
|
||||
}
|
||||
|
||||
public static Client getClient() {
|
||||
return CLIENT;
|
||||
}
|
||||
|
||||
public static ClientInfo getClientById(String id) {
|
||||
return CLIENTS.isEmpty() ? null : CLIENTS.stream().filter(client -> client != null && client.compareId(id)).findFirst().orElse(null);
|
||||
}
|
||||
|
||||
public static ClientInfo getClientByName(String name) {
|
||||
return CLIENTS.isEmpty() ? null : CLIENTS.stream().filter(client -> client != null && client.getName().equalsIgnoreCase(name)).findFirst().orElse(null);
|
||||
}
|
||||
}
|
||||
@@ -1,58 +0,0 @@
|
||||
package de.rayzs.pat.api.communication.client;
|
||||
|
||||
import de.rayzs.pat.utils.TimeConverter;
|
||||
|
||||
public abstract class ClientInfo {
|
||||
|
||||
private String id, name;
|
||||
|
||||
private boolean sentFeedback = false;
|
||||
private long syncTime = System.currentTimeMillis();
|
||||
|
||||
public ClientInfo(String serverId) {
|
||||
this.id = serverId;
|
||||
}
|
||||
|
||||
public ClientInfo(String serverId, String name) {
|
||||
this.id = serverId;
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public abstract void sendBytes(byte[] bytes);
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public void setId(String serverId) {
|
||||
this.id = serverId;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public boolean compareId(String id) {
|
||||
return this.id.equals(id);
|
||||
}
|
||||
|
||||
public void syncTime() {
|
||||
syncTime = System.currentTimeMillis();
|
||||
}
|
||||
|
||||
public String getSyncTime() {
|
||||
return TimeConverter.calcAndGetTime(syncTime);
|
||||
}
|
||||
|
||||
public void setFeedback(boolean state) {
|
||||
this.sentFeedback = state;
|
||||
}
|
||||
|
||||
public boolean hasSentFeedback() {
|
||||
return sentFeedback;
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
}
|
||||
@@ -1,26 +0,0 @@
|
||||
package de.rayzs.pat.api.communication.client.impl;
|
||||
|
||||
import de.rayzs.pat.api.communication.client.ClientInfo;
|
||||
import de.rayzs.pat.api.communication.Client;
|
||||
import net.md_5.bungee.api.ProxyServer;
|
||||
|
||||
public class BungeeClientInfo extends ClientInfo {
|
||||
|
||||
public BungeeClientInfo(String serverId) {
|
||||
super(serverId);
|
||||
}
|
||||
|
||||
public BungeeClientInfo(String serverId, String name) {
|
||||
super(serverId, name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendBytes(byte[] bytes) {
|
||||
ProxyServer.getInstance().getServers().entrySet().stream().filter(entry ->
|
||||
entry.getKey().equalsIgnoreCase(getName())
|
||||
).forEach(entry ->
|
||||
entry.getValue().sendData(Client.CHANNEL_NAME, bytes)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,25 +0,0 @@
|
||||
package de.rayzs.pat.api.communication.client.impl;
|
||||
|
||||
import de.rayzs.pat.api.communication.impl.VelocityClient;
|
||||
import de.rayzs.pat.api.communication.client.ClientInfo;
|
||||
import de.rayzs.pat.plugin.VelocityLoader;
|
||||
|
||||
public class VelocityClientInfo extends ClientInfo {
|
||||
|
||||
public VelocityClientInfo(String serverId) {
|
||||
super(serverId);
|
||||
}
|
||||
|
||||
public VelocityClientInfo(String serverId, String name) {
|
||||
super(serverId, name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendBytes(byte[] bytes) {
|
||||
VelocityLoader.getServer().getAllServers().stream().filter(server ->
|
||||
server.getServerInfo().getName().equalsIgnoreCase(getName())
|
||||
).forEach(server ->
|
||||
server.sendPluginMessage(VelocityClient.getIdentifier(), bytes)
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1,49 +0,0 @@
|
||||
package de.rayzs.pat.api.communication.impl;
|
||||
|
||||
import de.rayzs.pat.utils.scheduler.PATScheduler;
|
||||
import org.bukkit.plugin.messaging.PluginMessageListener;
|
||||
import de.rayzs.pat.utils.CommunicationPackets;
|
||||
import de.rayzs.pat.plugin.BukkitLoader;
|
||||
import de.rayzs.pat.api.communication.*;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.*;
|
||||
|
||||
public class BukkitClient implements Client, PluginMessageListener {
|
||||
|
||||
private static final Server SERVER = Bukkit.getServer();
|
||||
|
||||
public BukkitClient() {
|
||||
SERVER.getMessenger().registerIncomingPluginChannel(BukkitLoader.getPlugin(), CHANNEL_NAME, this);
|
||||
SERVER.getMessenger().registerOutgoingPluginChannel(BukkitLoader.getPlugin(), CHANNEL_NAME);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void send(Object packet) {
|
||||
try {
|
||||
|
||||
SERVER.sendPluginMessage(BukkitLoader.getPlugin(), CHANNEL_NAME, CommunicationPackets.convertToBytes(packet));
|
||||
|
||||
} catch (Throwable throwable) {
|
||||
throwable.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPluginMessageReceived(String channel, Player player, byte[] bytes) {
|
||||
|
||||
if (!channel.equals(CHANNEL_NAME))
|
||||
return;
|
||||
|
||||
try {
|
||||
Object packetObj = CommunicationPackets.buildFromBytes(bytes);
|
||||
|
||||
if (!CommunicationPackets.isPacket(packetObj))
|
||||
return;
|
||||
|
||||
PATScheduler.createScheduler(() -> Communicator.receiveInformation("proxy", packetObj));
|
||||
|
||||
} catch (Throwable throwable) {
|
||||
throwable.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,57 +0,0 @@
|
||||
package de.rayzs.pat.api.communication.impl;
|
||||
|
||||
import net.md_5.bungee.api.event.PluginMessageEvent;
|
||||
import de.rayzs.pat.utils.CommunicationPackets;
|
||||
import net.md_5.bungee.api.connection.Server;
|
||||
import net.md_5.bungee.api.config.ServerInfo;
|
||||
import net.md_5.bungee.api.plugin.Listener;
|
||||
import net.md_5.bungee.event.EventHandler;
|
||||
import de.rayzs.pat.plugin.BungeeLoader;
|
||||
import de.rayzs.pat.api.communication.*;
|
||||
import net.md_5.bungee.api.ProxyServer;
|
||||
|
||||
public class BungeeClient implements Client, Listener {
|
||||
|
||||
private static final ProxyServer SERVER = ProxyServer.getInstance();
|
||||
|
||||
public BungeeClient() {
|
||||
SERVER.registerChannel(CHANNEL_NAME);
|
||||
SERVER.getPluginManager().registerListener(BungeeLoader.getPlugin(), this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void send(Object packet) {
|
||||
for (ServerInfo serverInfo : ProxyServer.getInstance().getServers().values()) {
|
||||
|
||||
try {
|
||||
|
||||
serverInfo.sendData(CHANNEL_NAME, CommunicationPackets.convertToBytes(packet));
|
||||
|
||||
} catch (Throwable throwable) {
|
||||
throwable.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onQueryReceive(PluginMessageEvent event) {
|
||||
if (!event.getTag().equalsIgnoreCase(CHANNEL_NAME))
|
||||
return;
|
||||
|
||||
try {
|
||||
|
||||
Object packetObj = CommunicationPackets.buildFromBytes(event.getData());
|
||||
|
||||
if (!CommunicationPackets.isPacket(packetObj))
|
||||
return;
|
||||
|
||||
Server server = (Server) event.getSender();
|
||||
Communicator.receiveInformation(server.getInfo().getName(), packetObj);
|
||||
|
||||
} catch (Throwable throwable) {
|
||||
throwable.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,54 +0,0 @@
|
||||
package de.rayzs.pat.api.communication.impl;
|
||||
|
||||
import com.velocitypowered.api.proxy.messages.MinecraftChannelIdentifier;
|
||||
import com.velocitypowered.api.event.connection.PluginMessageEvent;
|
||||
import com.velocitypowered.api.proxy.server.RegisteredServer;
|
||||
import de.rayzs.pat.utils.CommunicationPackets;
|
||||
import com.velocitypowered.api.event.Subscribe;
|
||||
import de.rayzs.pat.plugin.VelocityLoader;
|
||||
import de.rayzs.pat.api.communication.*;
|
||||
import com.velocitypowered.api.proxy.*;
|
||||
|
||||
public class VelocityClient implements Client {
|
||||
|
||||
private static final ProxyServer SERVER = VelocityLoader.getServer();
|
||||
private static final MinecraftChannelIdentifier IDENTIFIER = MinecraftChannelIdentifier.from(CHANNEL_NAME);
|
||||
|
||||
public VelocityClient() {
|
||||
SERVER.getChannelRegistrar().register(IDENTIFIER);
|
||||
SERVER.getEventManager().register(VelocityLoader.getInstance(), this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void send(Object packet) {
|
||||
for (RegisteredServer registeredServer : SERVER.getAllServers()) {
|
||||
|
||||
try {
|
||||
|
||||
registeredServer.sendPluginMessage(IDENTIFIER, CommunicationPackets.convertToBytes(packet));
|
||||
|
||||
} catch (Throwable throwable) {
|
||||
throwable.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
public void onQueryReceive(PluginMessageEvent event) {
|
||||
if (event.getIdentifier() != IDENTIFIER)
|
||||
return;
|
||||
|
||||
Object packetObj = CommunicationPackets.buildFromBytes(event.getData());
|
||||
|
||||
if (!CommunicationPackets.isPacket(packetObj))
|
||||
return;
|
||||
|
||||
ServerConnection server = (ServerConnection) event.getSource();
|
||||
Communicator.receiveInformation(server.getServerInfo().getName(), packetObj);
|
||||
}
|
||||
|
||||
public static MinecraftChannelIdentifier getIdentifier() {
|
||||
return IDENTIFIER;
|
||||
}
|
||||
}
|
||||
@@ -1,12 +1,14 @@
|
||||
package de.rayzs.pat.api.event;
|
||||
|
||||
import de.rayzs.pat.utils.sender.CommandSender;
|
||||
|
||||
public abstract class PATEvent<T> {
|
||||
|
||||
private final Object senderObj;
|
||||
private final CommandSender player;
|
||||
private boolean cancelled = false;
|
||||
|
||||
public PATEvent(Object senderObj) {
|
||||
this.senderObj = senderObj;
|
||||
public PATEvent(CommandSender player) {
|
||||
this.player = player;
|
||||
}
|
||||
|
||||
public abstract void handle(T t);
|
||||
@@ -14,8 +16,8 @@ public abstract class PATEvent<T> {
|
||||
public void setCancelled(boolean cancelled) {
|
||||
this.cancelled = cancelled;
|
||||
}
|
||||
public Object getSenderObj() {
|
||||
return senderObj;
|
||||
public CommandSender getPlayer() {
|
||||
return player;
|
||||
}
|
||||
|
||||
public boolean isCancelled() {
|
||||
|
||||
@@ -2,7 +2,7 @@ package de.rayzs.pat.api.event;
|
||||
|
||||
import de.rayzs.pat.api.event.events.*;
|
||||
import de.rayzs.pat.utils.CommunicationPackets;
|
||||
import de.rayzs.pat.utils.Reflection;
|
||||
import de.rayzs.pat.utils.sender.CommandSender;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
@@ -10,12 +10,11 @@ public class PATEventHandler {
|
||||
|
||||
private static List<PATEvent> EVENTS = new ArrayList<>();
|
||||
|
||||
public static ExecuteCommandEvent callExecuteCommandEvents(Object senderObj, String command, boolean blocked, boolean notify) {
|
||||
ExecuteCommandEvent event = EmptyEvent.createEmptyExecuteCommandEvent(senderObj, command, blocked, notify);
|
||||
public static ExecuteCommandEvent callExecuteCommandEvents(CommandSender player, String command, boolean blocked, boolean notify) {
|
||||
ExecuteCommandEvent event = EmptyEvent.createEmptyExecuteCommandEvent(player, command, blocked, notify);
|
||||
|
||||
for (PATEvent patEvent : EVENTS) {
|
||||
if(patEvent instanceof ExecuteCommandEvent) {
|
||||
ExecuteCommandEvent executeCommandEvent = (ExecuteCommandEvent) patEvent;
|
||||
if (patEvent instanceof ExecuteCommandEvent executeCommandEvent) {
|
||||
executeCommandEvent.handle(event);
|
||||
}
|
||||
}
|
||||
@@ -23,38 +22,35 @@ public class PATEventHandler {
|
||||
return event;
|
||||
}
|
||||
|
||||
public static FilteredSuggestionEvent callFilteredSuggestionEvents(Object senderObj, List<String> suggestions) {
|
||||
FilteredSuggestionEvent event = EmptyEvent.createEmptyFilteredSuggestionEvent(senderObj, suggestions);
|
||||
public static FilteredSuggestionEvent callFilteredSuggestionEvents(CommandSender player, List<String> suggestions) {
|
||||
FilteredSuggestionEvent event = EmptyEvent.createEmptyFilteredSuggestionEvent(player, suggestions);
|
||||
|
||||
for (PATEvent patEvent : EVENTS) {
|
||||
if(patEvent instanceof FilteredSuggestionEvent) {
|
||||
FilteredSuggestionEvent filteredSuggestion = (FilteredSuggestionEvent) patEvent;
|
||||
filteredSuggestion.handle(event);
|
||||
if (patEvent instanceof FilteredSuggestionEvent filteredSuggestionEvent) {
|
||||
filteredSuggestionEvent.handle(event);
|
||||
}
|
||||
}
|
||||
|
||||
return event;
|
||||
}
|
||||
|
||||
public static FilteredTabCompletionEvent callFilteredTabCompletionEvents(Object senderObj, String cursor, List<String> completion) {
|
||||
FilteredTabCompletionEvent event = EmptyEvent.createEmptyFilteredTabCompletion(senderObj, cursor, completion);
|
||||
public static FilteredTabCompletionEvent callFilteredTabCompletionEvents(CommandSender player, String cursor, List<String> completion) {
|
||||
FilteredTabCompletionEvent event = EmptyEvent.createEmptyFilteredTabCompletion(player, cursor, completion);
|
||||
|
||||
for (PATEvent patEvent : EVENTS) {
|
||||
if(patEvent instanceof FilteredTabCompletionEvent) {
|
||||
FilteredTabCompletionEvent filteredTabCompletion = (FilteredTabCompletionEvent) patEvent;
|
||||
filteredTabCompletion.handle(event);
|
||||
if (patEvent instanceof FilteredTabCompletionEvent filteredTabCompletionEvent) {
|
||||
filteredTabCompletionEvent.handle(event);
|
||||
}
|
||||
}
|
||||
|
||||
return event;
|
||||
}
|
||||
|
||||
public static ServerPlayersChangeEvent callServerPlayersChangeEvents(Object senderObj, ServerPlayersChangeEvent.Type type) {
|
||||
ServerPlayersChangeEvent event = EmptyEvent.createEmptyServerPlayersChangeEvent(senderObj, type);
|
||||
public static ServerPlayersChangeEvent callServerPlayersChangeEvents(CommandSender player, ServerPlayersChangeEvent.Type type) {
|
||||
ServerPlayersChangeEvent event = EmptyEvent.createEmptyServerPlayersChangeEvent(player, type);
|
||||
|
||||
for (PATEvent patEvent : EVENTS) {
|
||||
if(patEvent instanceof ServerPlayersChangeEvent) {
|
||||
ServerPlayersChangeEvent serverPlayersChangeEvent = (ServerPlayersChangeEvent) patEvent;
|
||||
if (patEvent instanceof ServerPlayersChangeEvent serverPlayersChangeEvent) {
|
||||
serverPlayersChangeEvent.handle(event);
|
||||
}
|
||||
}
|
||||
@@ -66,8 +62,7 @@ public class PATEventHandler {
|
||||
UpdatePluginEvent event = EmptyEvent.createEmptyUpdatePluginEvent();
|
||||
|
||||
for (PATEvent patEvent : EVENTS) {
|
||||
if(patEvent instanceof UpdatePluginEvent) {
|
||||
UpdatePluginEvent updatePluginEvent = (UpdatePluginEvent) patEvent;
|
||||
if (patEvent instanceof UpdatePluginEvent updatePluginEvent) {
|
||||
updatePluginEvent.handle(event);
|
||||
}
|
||||
}
|
||||
@@ -75,12 +70,11 @@ public class PATEventHandler {
|
||||
return event;
|
||||
}
|
||||
|
||||
public static UpdatePlayerCommandsEvent callUpdatePlayerCommandsEvents(Object playerObj, List<String> commands, boolean serverBased) {
|
||||
UpdatePlayerCommandsEvent event = EmptyEvent.createEmptyUpdatePlayerCommandsEvent(playerObj, commands, serverBased);
|
||||
public static UpdatePlayerCommandsEvent callUpdatePlayerCommandsEvents(CommandSender player, List<String> commands, boolean serverBased) {
|
||||
UpdatePlayerCommandsEvent event = EmptyEvent.createEmptyUpdatePlayerCommandsEvent(player, commands, serverBased);
|
||||
|
||||
for (PATEvent patEvent : EVENTS) {
|
||||
if(patEvent instanceof UpdatePlayerCommandsEvent) {
|
||||
UpdatePlayerCommandsEvent updatePlayerCommandsEvent = (UpdatePlayerCommandsEvent) patEvent;
|
||||
if (patEvent instanceof UpdatePlayerCommandsEvent updatePlayerCommandsEvent) {
|
||||
updatePlayerCommandsEvent.handle(event);
|
||||
}
|
||||
}
|
||||
@@ -88,12 +82,11 @@ public class PATEventHandler {
|
||||
return event;
|
||||
}
|
||||
|
||||
public static SentSyncEvent callSentSyncEvents(CommunicationPackets.PacketBundle packetBundle, String serverName) {
|
||||
SentSyncEvent event = EmptyEvent.createEmptySentSyncEvent(packetBundle, serverName);
|
||||
public static SentSyncEvent callSentSyncEvents(CommunicationPackets.Proxy2Backend.DataSyncPacket dataSyncPacket, String serverName) {
|
||||
SentSyncEvent event = EmptyEvent.createEmptySentSyncEvent(dataSyncPacket, serverName);
|
||||
|
||||
for (PATEvent patEvent : EVENTS) {
|
||||
if(patEvent instanceof SentSyncEvent) {
|
||||
SentSyncEvent sentSyncEvent = (SentSyncEvent) patEvent;
|
||||
if (patEvent instanceof SentSyncEvent sentSyncEvent) {
|
||||
sentSyncEvent.handle(event);
|
||||
}
|
||||
}
|
||||
@@ -101,13 +94,12 @@ public class PATEventHandler {
|
||||
return event;
|
||||
}
|
||||
|
||||
public static ReceiveSyncEvent callReceiveSyncEvents(CommunicationPackets.PacketBundle packetBundle) {
|
||||
ReceiveSyncEvent event = EmptyEvent.createEmptyReceiveSyncEvent(packetBundle);
|
||||
public static ReceiveSyncEvent callReceiveSyncEvents(CommunicationPackets.Proxy2Backend.DataSyncPacket dataSyncPacket) {
|
||||
ReceiveSyncEvent event = EmptyEvent.createEmptyReceiveSyncEvent(dataSyncPacket);
|
||||
|
||||
for (PATEvent patEvent : EVENTS) {
|
||||
if(patEvent instanceof ReceiveSyncEvent) {
|
||||
ReceiveSyncEvent proxySyncEvent = (ReceiveSyncEvent) patEvent;
|
||||
proxySyncEvent.handle(event);
|
||||
if (patEvent instanceof ReceiveSyncEvent receiveSyncEvent) {
|
||||
receiveSyncEvent.handle(event);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -124,8 +116,8 @@ public class PATEventHandler {
|
||||
|
||||
public static class EmptyEvent {
|
||||
|
||||
public static ServerPlayersChangeEvent createEmptyServerPlayersChangeEvent(Object senderObj, ServerPlayersChangeEvent.Type type) {
|
||||
return new ServerPlayersChangeEvent(senderObj, type) {
|
||||
public static ServerPlayersChangeEvent createEmptyServerPlayersChangeEvent(CommandSender player, ServerPlayersChangeEvent.Type type) {
|
||||
return new ServerPlayersChangeEvent(player, type) {
|
||||
@Override
|
||||
public void handle(ServerPlayersChangeEvent event) {
|
||||
|
||||
@@ -133,8 +125,8 @@ public class PATEventHandler {
|
||||
};
|
||||
}
|
||||
|
||||
public static SentSyncEvent createEmptySentSyncEvent(CommunicationPackets.PacketBundle packetBundle, String serverName) {
|
||||
return new SentSyncEvent(null, packetBundle, serverName) {
|
||||
public static SentSyncEvent createEmptySentSyncEvent(CommunicationPackets.Proxy2Backend.DataSyncPacket dataSyncPacket, String serverName) {
|
||||
return new SentSyncEvent(null, dataSyncPacket, serverName) {
|
||||
@Override
|
||||
public void handle(SentSyncEvent event) {
|
||||
|
||||
@@ -142,8 +134,8 @@ public class PATEventHandler {
|
||||
};
|
||||
}
|
||||
|
||||
public static ReceiveSyncEvent createEmptyReceiveSyncEvent(CommunicationPackets.PacketBundle packetBundle) {
|
||||
return new ReceiveSyncEvent(null, packetBundle) {
|
||||
public static ReceiveSyncEvent createEmptyReceiveSyncEvent(CommunicationPackets.Proxy2Backend.DataSyncPacket dataSyncPacket) {
|
||||
return new ReceiveSyncEvent(null, dataSyncPacket) {
|
||||
@Override
|
||||
public void handle(ReceiveSyncEvent event) {
|
||||
|
||||
@@ -151,8 +143,8 @@ public class PATEventHandler {
|
||||
};
|
||||
}
|
||||
|
||||
public static UpdatePlayerCommandsEvent createEmptyUpdatePlayerCommandsEvent(Object playerObj, List<String> commands, boolean serverBased) {
|
||||
return new UpdatePlayerCommandsEvent(playerObj, commands, serverBased) {
|
||||
public static UpdatePlayerCommandsEvent createEmptyUpdatePlayerCommandsEvent(CommandSender player, List<String> commands, boolean serverBased) {
|
||||
return new UpdatePlayerCommandsEvent(player, commands, serverBased) {
|
||||
@Override
|
||||
public void handle(UpdatePlayerCommandsEvent event) {
|
||||
|
||||
@@ -169,8 +161,8 @@ public class PATEventHandler {
|
||||
};
|
||||
}
|
||||
|
||||
public static ExecuteCommandEvent createEmptyExecuteCommandEvent(Object senderObj, String command, boolean blocked, boolean notify) {
|
||||
return new ExecuteCommandEvent(senderObj, command, blocked, notify) {
|
||||
public static ExecuteCommandEvent createEmptyExecuteCommandEvent(CommandSender player, String command, boolean blocked, boolean notify) {
|
||||
return new ExecuteCommandEvent(player, command, blocked, notify) {
|
||||
@Override
|
||||
public void handle(ExecuteCommandEvent event) {
|
||||
|
||||
@@ -178,8 +170,8 @@ public class PATEventHandler {
|
||||
};
|
||||
}
|
||||
|
||||
public static FilteredSuggestionEvent createEmptyFilteredSuggestionEvent(Object senderObj, List<String> suggestions) {
|
||||
return new FilteredSuggestionEvent(senderObj, suggestions) {
|
||||
public static FilteredSuggestionEvent createEmptyFilteredSuggestionEvent(CommandSender player, List<String> suggestions) {
|
||||
return new FilteredSuggestionEvent(player, suggestions) {
|
||||
@Override
|
||||
public void handle(FilteredSuggestionEvent event) {
|
||||
|
||||
@@ -187,8 +179,8 @@ public class PATEventHandler {
|
||||
};
|
||||
}
|
||||
|
||||
public static FilteredTabCompletionEvent createEmptyFilteredTabCompletion(Object senderObj, String cursor, List<String> completion) {
|
||||
return new FilteredTabCompletionEvent(senderObj, cursor, completion) {
|
||||
public static FilteredTabCompletionEvent createEmptyFilteredTabCompletion(CommandSender player, String cursor, List<String> completion) {
|
||||
return new FilteredTabCompletionEvent(player, cursor, completion) {
|
||||
@Override
|
||||
public void handle(FilteredTabCompletionEvent event) {
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package de.rayzs.pat.api.event.events;
|
||||
|
||||
import de.rayzs.pat.api.event.PATEvent;
|
||||
import de.rayzs.pat.utils.sender.CommandSender;
|
||||
|
||||
public abstract class ExecuteCommandEvent extends PATEvent<ExecuteCommandEvent> {
|
||||
|
||||
@@ -9,13 +10,15 @@ public abstract class ExecuteCommandEvent extends PATEvent<ExecuteCommandEvent>
|
||||
|
||||
public ExecuteCommandEvent() {
|
||||
super(null);
|
||||
|
||||
this.blocked = false;
|
||||
this.notify = false;
|
||||
this.command = null;
|
||||
}
|
||||
|
||||
public ExecuteCommandEvent(Object senderObj, String command, boolean blocked, boolean notify) {
|
||||
super(senderObj);
|
||||
public ExecuteCommandEvent(CommandSender player, String command, boolean blocked, boolean notify) {
|
||||
super(player);
|
||||
|
||||
this.blocked = blocked;
|
||||
this.command = command;
|
||||
this.notify = notify;
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
package de.rayzs.pat.api.event.events;
|
||||
|
||||
import de.rayzs.pat.api.event.PATEvent;
|
||||
import de.rayzs.pat.utils.sender.CommandSender;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
public abstract class FilteredSuggestionEvent extends PATEvent<FilteredSuggestionEvent> {
|
||||
@@ -12,8 +14,9 @@ public abstract class FilteredSuggestionEvent extends PATEvent<FilteredSuggestio
|
||||
this.suggestions = null;
|
||||
}
|
||||
|
||||
public FilteredSuggestionEvent(Object senderObj, List<String> suggestions) {
|
||||
super(senderObj);
|
||||
public FilteredSuggestionEvent(CommandSender player, List<String> suggestions) {
|
||||
super(player);
|
||||
|
||||
this.suggestions = suggestions;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
package de.rayzs.pat.api.event.events;
|
||||
|
||||
import de.rayzs.pat.api.event.PATEvent;
|
||||
import de.rayzs.pat.utils.sender.CommandSender;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
public abstract class FilteredTabCompletionEvent extends PATEvent<FilteredTabCompletionEvent> {
|
||||
@@ -10,12 +12,14 @@ public abstract class FilteredTabCompletionEvent extends PATEvent<FilteredTabCom
|
||||
|
||||
public FilteredTabCompletionEvent() {
|
||||
super(null);
|
||||
|
||||
this.cursor = null;
|
||||
this.completion = null;
|
||||
}
|
||||
|
||||
public FilteredTabCompletionEvent(Object senderObj, String cursor, List<String> completion) {
|
||||
super(senderObj);
|
||||
public FilteredTabCompletionEvent(CommandSender player, String cursor, List<String> completion) {
|
||||
super(player);
|
||||
|
||||
this.cursor = cursor;
|
||||
this.completion = completion;
|
||||
}
|
||||
|
||||
@@ -2,22 +2,24 @@ package de.rayzs.pat.api.event.events;
|
||||
|
||||
import de.rayzs.pat.utils.CommunicationPackets;
|
||||
import de.rayzs.pat.api.event.PATEvent;
|
||||
import de.rayzs.pat.utils.sender.CommandSender;
|
||||
|
||||
public abstract class ReceiveSyncEvent extends PATEvent<ReceiveSyncEvent> {
|
||||
|
||||
private final CommunicationPackets.PacketBundle packetBundle;
|
||||
private final CommunicationPackets.Proxy2Backend.DataSyncPacket dataSyncPacket;
|
||||
|
||||
public ReceiveSyncEvent() {
|
||||
super(null);
|
||||
this.packetBundle = null;
|
||||
this.dataSyncPacket = null;
|
||||
}
|
||||
|
||||
public ReceiveSyncEvent(Object senderObj, CommunicationPackets.PacketBundle packetBundle) {
|
||||
super(senderObj);
|
||||
this.packetBundle = packetBundle;
|
||||
public ReceiveSyncEvent(CommandSender player, CommunicationPackets.Proxy2Backend.DataSyncPacket dataSyncPacket) {
|
||||
super(player);
|
||||
|
||||
this.dataSyncPacket = dataSyncPacket;
|
||||
}
|
||||
|
||||
public CommunicationPackets.PacketBundle getPacketBundle() {
|
||||
return packetBundle;
|
||||
public CommunicationPackets.Proxy2Backend.DataSyncPacket getDataSyncPacket() {
|
||||
return dataSyncPacket;
|
||||
}
|
||||
}
|
||||
@@ -2,21 +2,24 @@ package de.rayzs.pat.api.event.events;
|
||||
|
||||
import de.rayzs.pat.utils.CommunicationPackets;
|
||||
import de.rayzs.pat.api.event.PATEvent;
|
||||
import de.rayzs.pat.utils.sender.CommandSender;
|
||||
|
||||
public abstract class SentSyncEvent extends PATEvent<SentSyncEvent> {
|
||||
|
||||
private final CommunicationPackets.PacketBundle packetBundle;
|
||||
private final CommunicationPackets.Proxy2Backend.DataSyncPacket dataSyncPacket;
|
||||
private final String serverName;
|
||||
|
||||
public SentSyncEvent() {
|
||||
super(null);
|
||||
this.packetBundle = null;
|
||||
|
||||
this.dataSyncPacket = null;
|
||||
this.serverName = null;
|
||||
}
|
||||
|
||||
public SentSyncEvent(Object senderObj, CommunicationPackets.PacketBundle packetBundle, String serverName) {
|
||||
super(senderObj);
|
||||
this.packetBundle = packetBundle;
|
||||
public SentSyncEvent(CommandSender player, CommunicationPackets.Proxy2Backend.DataSyncPacket dataSyncPacket, String serverName) {
|
||||
super(player);
|
||||
|
||||
this.dataSyncPacket = dataSyncPacket;
|
||||
this.serverName = serverName;
|
||||
}
|
||||
|
||||
@@ -24,7 +27,7 @@ public abstract class SentSyncEvent extends PATEvent<SentSyncEvent> {
|
||||
return serverName;
|
||||
}
|
||||
|
||||
public CommunicationPackets.PacketBundle getPacketBundle() {
|
||||
return packetBundle;
|
||||
public CommunicationPackets.Proxy2Backend.DataSyncPacket getDataSyncPacket() {
|
||||
return dataSyncPacket;
|
||||
}
|
||||
}
|
||||
@@ -1,13 +1,15 @@
|
||||
package de.rayzs.pat.api.event.events;
|
||||
|
||||
import de.rayzs.pat.api.event.PATEvent;
|
||||
import de.rayzs.pat.utils.sender.CommandSender;
|
||||
|
||||
public abstract class ServerPlayersChangeEvent extends PATEvent<ServerPlayersChangeEvent> {
|
||||
|
||||
private final Type type;
|
||||
|
||||
public ServerPlayersChangeEvent(Object senderObj, Type type) {
|
||||
super(senderObj);
|
||||
public ServerPlayersChangeEvent(CommandSender player, Type type) {
|
||||
super(player);
|
||||
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
package de.rayzs.pat.api.event.events;
|
||||
|
||||
import de.rayzs.pat.api.event.PATEvent;
|
||||
import de.rayzs.pat.utils.sender.CommandSender;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public abstract class UpdatePlayerCommandsEvent extends PATEvent<UpdatePlayerCommandsEvent> {
|
||||
@@ -12,8 +14,9 @@ public abstract class UpdatePlayerCommandsEvent extends PATEvent<UpdatePlayerCom
|
||||
super(null);;
|
||||
}
|
||||
|
||||
public UpdatePlayerCommandsEvent(Object senderObj, List<String> commands, boolean serverBased) {
|
||||
super(senderObj);
|
||||
public UpdatePlayerCommandsEvent(CommandSender player, List<String> commands, boolean serverBased) {
|
||||
super(player);
|
||||
|
||||
this.commands = commands;
|
||||
this.serverBased = serverBased;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package de.rayzs.pat.api.event.events;
|
||||
|
||||
import de.rayzs.pat.api.event.PATEvent;
|
||||
import de.rayzs.pat.utils.sender.CommandSender;
|
||||
|
||||
public abstract class UpdatePluginEvent extends PATEvent<UpdatePluginEvent> {
|
||||
|
||||
@@ -8,7 +9,7 @@ public abstract class UpdatePluginEvent extends PATEvent<UpdatePluginEvent> {
|
||||
super(null);;
|
||||
}
|
||||
|
||||
public UpdatePluginEvent(Object senderObj) {
|
||||
super(senderObj);
|
||||
public UpdatePluginEvent(CommandSender player) {
|
||||
super(player);
|
||||
}
|
||||
}
|
||||
@@ -1,43 +0,0 @@
|
||||
package de.rayzs.pat.api.event.events.bukkit;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Cancellable;
|
||||
import org.bukkit.event.Event;
|
||||
|
||||
public abstract class ExecuteCommandEvent extends Event implements Cancellable {
|
||||
|
||||
private final String command;
|
||||
private boolean blocked;
|
||||
|
||||
public ExecuteCommandEvent() {
|
||||
this.blocked = false;
|
||||
this.command = null;
|
||||
}
|
||||
|
||||
public ExecuteCommandEvent(Player player, String command, boolean blocked) {
|
||||
this.blocked = blocked;
|
||||
this.command = command;
|
||||
}
|
||||
|
||||
public String getCommand() {
|
||||
return command;
|
||||
}
|
||||
|
||||
public boolean isBlocked() {
|
||||
return blocked;
|
||||
}
|
||||
|
||||
public void setBlocked(boolean blocked) {
|
||||
this.blocked = blocked;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCancelled() {
|
||||
return blocked;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCancelled(boolean cancel) {
|
||||
this.blocked = cancel;
|
||||
}
|
||||
}
|
||||
@@ -1,26 +0,0 @@
|
||||
package de.rayzs.pat.api.event.events.bukkit;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Event;
|
||||
import java.util.List;
|
||||
|
||||
public abstract class FilteredSuggestionEvent extends Event {
|
||||
|
||||
private List<String> suggestions;
|
||||
|
||||
public FilteredSuggestionEvent() {
|
||||
this.suggestions = null;
|
||||
}
|
||||
|
||||
public FilteredSuggestionEvent(Player player, List<String> suggestions) {
|
||||
this.suggestions = suggestions;
|
||||
}
|
||||
|
||||
public List<String> getSuggestions() {
|
||||
return suggestions;
|
||||
}
|
||||
|
||||
public void setSuggestions(List<String> suggestions) {
|
||||
this.suggestions = suggestions;
|
||||
}
|
||||
}
|
||||
@@ -1,35 +0,0 @@
|
||||
package de.rayzs.pat.api.event.events.bukkit;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Event;
|
||||
import java.util.List;
|
||||
|
||||
public abstract class FilteredTabCompletionEvent extends Event {
|
||||
|
||||
private String cursor;
|
||||
private List<String> completion;
|
||||
|
||||
public FilteredTabCompletionEvent() {
|
||||
this.cursor = null;
|
||||
this.completion = null;
|
||||
}
|
||||
|
||||
public FilteredTabCompletionEvent(Player player, String cursor, List<String> completion) {
|
||||
this.cursor = cursor;
|
||||
this.completion = completion;
|
||||
}
|
||||
|
||||
public abstract void handle(FilteredTabCompletionEvent event);
|
||||
|
||||
public String getCursor() {
|
||||
return cursor;
|
||||
}
|
||||
|
||||
public List<String> getCompletion() {
|
||||
return completion;
|
||||
}
|
||||
|
||||
public void setCompletion(List<String> completion) {
|
||||
this.completion = completion;
|
||||
}
|
||||
}
|
||||
@@ -1,8 +0,0 @@
|
||||
package de.rayzs.pat.api.netty.bukkit;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public interface BukkitPacketHandler {
|
||||
boolean handleIncomingPacket(Player player, Object packetObj) throws Exception;
|
||||
boolean handleOutgoingPacket(Player player, Object packetObj) throws Exception;
|
||||
}
|
||||
@@ -1,321 +0,0 @@
|
||||
package de.rayzs.pat.api.netty.proxy;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import com.mojang.brigadier.arguments.ArgumentType;
|
||||
import com.mojang.brigadier.arguments.StringArgumentType;
|
||||
import com.mojang.brigadier.builder.LiteralArgumentBuilder;
|
||||
import com.mojang.brigadier.builder.RequiredArgumentBuilder;
|
||||
import com.mojang.brigadier.tree.CommandNode;
|
||||
|
||||
import com.mojang.brigadier.tree.RootCommandNode;
|
||||
import de.rayzs.pat.api.brand.CustomServerBrand;
|
||||
import de.rayzs.pat.api.communication.Communicator;
|
||||
import de.rayzs.pat.api.communication.client.ClientInfo;
|
||||
import de.rayzs.pat.api.storage.Storage;
|
||||
import de.rayzs.pat.plugin.logger.Logger;
|
||||
import de.rayzs.pat.plugin.modules.SubArgsModule;
|
||||
import de.rayzs.pat.utils.CommandsCache;
|
||||
import de.rayzs.pat.utils.node.CommandNodeHelper;
|
||||
import de.rayzs.pat.utils.Reflection;
|
||||
import de.rayzs.pat.utils.StringUtils;
|
||||
import de.rayzs.pat.utils.permission.PermissionUtil;
|
||||
import io.netty.channel.Channel;
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
import io.netty.channel.ChannelPipeline;
|
||||
import io.netty.handler.codec.MessageToMessageDecoder;
|
||||
import net.md_5.bungee.api.ProxyServer;
|
||||
import net.md_5.bungee.api.config.ServerInfo;
|
||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||
import net.md_5.bungee.api.plugin.Command;
|
||||
import net.md_5.bungee.protocol.PacketWrapper;
|
||||
import net.md_5.bungee.protocol.packet.Commands;
|
||||
import net.md_5.bungee.protocol.packet.PluginMessage;
|
||||
import net.md_5.bungee.protocol.packet.TabCompleteResponse;
|
||||
|
||||
public class BungeePacketAnalyzer {
|
||||
|
||||
public static final ConcurrentHashMap<ProxiedPlayer, Channel> INJECTED_PLAYERS = new ConcurrentHashMap<>();
|
||||
|
||||
private static final String HANDLER_NAME = "pat-bungee-handler", PIPELINE_NAME = "packet-decoder";
|
||||
private static final HashMap<ProxiedPlayer, Boolean> PLAYER_MODIFIED = new HashMap<>();
|
||||
private static final HashMap<ProxiedPlayer, String> PLAYER_INPUT_CACHE = new HashMap<>();
|
||||
|
||||
private static final List<String> PLUGIN_COMMANDS = new ArrayList<>();
|
||||
|
||||
private static Class<?> channelWrapperClass, serverConnectionClass;
|
||||
|
||||
private static List<String> PROXY_COMMANDS;
|
||||
|
||||
static {
|
||||
CommandNodeHelper.setDefaultSuggestionProvider(Commands.SuggestionRegistry.ASK_SERVER);
|
||||
loadProxyCommands();
|
||||
}
|
||||
|
||||
public static void loadProxyCommands() {
|
||||
PROXY_COMMANDS = ProxyServer.getInstance().getPluginManager().getCommands().stream().map(entry -> {
|
||||
String key = entry.getKey();
|
||||
return key.startsWith("/") ? key.substring(1) : key;
|
||||
}).toList();
|
||||
}
|
||||
|
||||
public static void injectAll() {
|
||||
ProxyServer.getInstance().getPlayers().forEach(BungeePacketAnalyzer::inject);
|
||||
}
|
||||
|
||||
public static void uninjectAll() {
|
||||
BungeePacketAnalyzer.INJECTED_PLAYERS.keySet().forEach(BungeePacketAnalyzer::uninject);
|
||||
BungeePacketAnalyzer.INJECTED_PLAYERS.clear();
|
||||
}
|
||||
|
||||
public static void setPluginCommands() {
|
||||
if(!PLUGIN_COMMANDS.isEmpty()) return;
|
||||
ProxyServer.getInstance().getPluginManager().getCommands().stream().filter(entry -> !PLUGIN_COMMANDS.contains(entry.getKey())).forEach(entry -> PLUGIN_COMMANDS.add(entry.getKey()));
|
||||
}
|
||||
|
||||
public static boolean inject(ProxiedPlayer player) {
|
||||
|
||||
if(channelWrapperClass == null)
|
||||
channelWrapperClass = Reflection.getClass("net.md_5.bungee.netty.ChannelWrapper");
|
||||
|
||||
if(serverConnectionClass == null)
|
||||
serverConnectionClass = Reflection.getClass("net.md_5.bungee.ServerConnection");
|
||||
|
||||
Object channelWrapperObj;
|
||||
Field channelField;
|
||||
Channel channel;
|
||||
|
||||
try {
|
||||
channelField = Reflection.getFieldByName(serverConnectionClass, "ch");
|
||||
channelWrapperObj = channelField.get(player.getServer());
|
||||
channel = (Channel) Reflection.getFieldsByType(channelWrapperClass, "Channel", Reflection.SearchOption.ENDS).get(0).get(channelWrapperObj);
|
||||
|
||||
if(channel == null) {
|
||||
Logger.warning("Failed to inject " + player.getName() + "! Channel is null.");
|
||||
return false;
|
||||
}
|
||||
|
||||
channelField.setAccessible(false);
|
||||
|
||||
if (channel.pipeline().names().contains(BungeePacketAnalyzer.HANDLER_NAME))
|
||||
uninject(player);
|
||||
|
||||
channel.pipeline().addAfter(BungeePacketAnalyzer.PIPELINE_NAME, BungeePacketAnalyzer.HANDLER_NAME, new PacketDecoder(player));
|
||||
BungeePacketAnalyzer.INJECTED_PLAYERS.put(player, channel);
|
||||
|
||||
} catch (Throwable throwable) {
|
||||
throwable.printStackTrace();
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public static void uninject(ProxiedPlayer player) {
|
||||
BungeePacketAnalyzer.PLAYER_INPUT_CACHE.remove(player);
|
||||
BungeePacketAnalyzer.PLAYER_MODIFIED.remove(player);
|
||||
|
||||
if(BungeePacketAnalyzer.INJECTED_PLAYERS.containsKey(player)) {
|
||||
Channel channel = BungeePacketAnalyzer.INJECTED_PLAYERS.get(player);
|
||||
if(channel != null) {
|
||||
BungeePacketAnalyzer.INJECTED_PLAYERS.remove(player);
|
||||
channel.eventLoop().submit(() -> {
|
||||
ChannelPipeline pipeline = channel.pipeline();
|
||||
|
||||
if (pipeline.names().contains(BungeePacketAnalyzer.HANDLER_NAME))
|
||||
pipeline.remove(BungeePacketAnalyzer.HANDLER_NAME);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static String getPlayerInput(ProxiedPlayer player) {
|
||||
String input = PLAYER_INPUT_CACHE.get(player);
|
||||
PLAYER_INPUT_CACHE.remove(player);
|
||||
return input;
|
||||
}
|
||||
|
||||
private static void modifyCommands(ProxiedPlayer player, Commands commands) {
|
||||
ServerInfo serverInfo = player.getServer().getInfo();
|
||||
String serverName = serverInfo.getName();
|
||||
|
||||
CommandNodeHelper helper = new CommandNodeHelper<CommandNode>(commands.getRoot());
|
||||
|
||||
Map<String, CommandsCache> cache = Storage.getLoader().getCommandsCacheMap();
|
||||
|
||||
if (!cache.containsKey(serverName))
|
||||
cache.put(serverName, new CommandsCache());
|
||||
|
||||
CommandsCache commandsCache = cache.get(serverName);
|
||||
|
||||
List<String> commandsAsString = new ArrayList<>(PROXY_COMMANDS);
|
||||
commandsAsString.addAll(helper.getChildrenNames());
|
||||
|
||||
commandsCache.handleCommands(commandsAsString, serverName);
|
||||
|
||||
List<String> playerCommands = commandsCache.getPlayerCommands(commandsAsString, player, player.getUniqueId(), serverName);
|
||||
boolean bypassPermissions = PermissionUtil.hasBypassPermission(player.getUniqueId());
|
||||
|
||||
helper.removeIf(str -> !playerCommands.contains(str));
|
||||
|
||||
if (Storage.ConfigSections.Settings.CUSTOM_VERSION.ALWAYS_TAB_COMPLETABLE && !bypassPermissions) {
|
||||
Storage.ConfigSections.Settings.CUSTOM_VERSION.COMMANDS.getLines().forEach(input -> helper.add(input, false));
|
||||
}
|
||||
|
||||
if (Storage.ConfigSections.Settings.CUSTOM_PLUGIN.ALWAYS_TAB_COMPLETABLE && !bypassPermissions) {
|
||||
Storage.ConfigSections.Settings.CUSTOM_PLUGIN.COMMANDS.getLines().forEach(input -> helper.add(input, false));
|
||||
}
|
||||
|
||||
for (Map.Entry<String, Command> command : ProxyServer.getInstance().getPluginManager().getCommands()) {
|
||||
|
||||
if (ProxyServer.getInstance().getDisabledCommands().contains(command.getKey()))
|
||||
continue;
|
||||
|
||||
if (commands.getRoot().getChild(command.getKey()) != null)
|
||||
continue;
|
||||
|
||||
if (!command.getValue().hasPermission(player)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
String commandName = command.getKey();
|
||||
commandName = commandName.startsWith("/") ? commandName.substring(1) : commandName;
|
||||
|
||||
boolean tabablePluginCommand = Storage.ConfigSections.Settings.CUSTOM_PLUGIN.isTabCompletable(commandName);
|
||||
boolean tabableVersionCommand = Storage.ConfigSections.Settings.CUSTOM_VERSION.isTabCompletable(commandName);
|
||||
|
||||
if (!tabablePluginCommand && !tabableVersionCommand && !playerCommands.contains(commandName)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
CommandNode dummy = CommandNodeHelper.createDummyCommandNode(command.getKey());
|
||||
commands.getRoot().addChild(dummy);
|
||||
}
|
||||
|
||||
|
||||
PROXY_COMMANDS.stream().filter(playerCommands::contains).forEach(input -> helper.add(input, true));
|
||||
SubArgsModule.handleCommandNode(player.getUniqueId(), helper);
|
||||
}
|
||||
|
||||
public static void sendCommandsPacket() {
|
||||
for (ProxiedPlayer player : ProxyServer.getInstance().getPlayers()) {
|
||||
RootCommandNode root = new RootCommandNode();
|
||||
Commands packet = new Commands(root);
|
||||
|
||||
modifyCommands(player, packet);
|
||||
player.unsafe().sendPacket(packet);
|
||||
}
|
||||
}
|
||||
|
||||
private static class PacketDecoder extends MessageToMessageDecoder<PacketWrapper> {
|
||||
|
||||
private final ProxiedPlayer player;
|
||||
|
||||
private PacketDecoder(ProxiedPlayer player) {
|
||||
this.player = player;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void decode(ChannelHandlerContext channelHandlerContext, PacketWrapper wrapper, List<Object> list) {
|
||||
if (wrapper.packet == null) {
|
||||
list.add(wrapper);
|
||||
return;
|
||||
}
|
||||
|
||||
if(wrapper.packet instanceof PluginMessage) {
|
||||
PluginMessage pluginMessage = (PluginMessage) wrapper.packet;
|
||||
if(CustomServerBrand.isEnabled() && CustomServerBrand.isBrandTag(pluginMessage.getTag()))
|
||||
return;
|
||||
|
||||
} else if (wrapper.packet instanceof Commands) {
|
||||
Commands response = (Commands) wrapper.packet;
|
||||
modifyCommands(player, response);
|
||||
|
||||
player.unsafe().sendPacket(response);
|
||||
return;
|
||||
|
||||
} else if (wrapper.packet instanceof TabCompleteResponse) {
|
||||
TabCompleteResponse response = (TabCompleteResponse) wrapper.packet;
|
||||
|
||||
if(player.getPendingConnection().getVersion() < 754) {
|
||||
if(!PermissionUtil.hasBypassPermission(player)) {
|
||||
|
||||
ClientInfo clientInfo = Communicator.getClientByName(player.getServer().getInfo().getName());
|
||||
if (clientInfo == null || !PLAYER_INPUT_CACHE.containsKey(player))
|
||||
return;
|
||||
|
||||
boolean cancelsBeforeHand = false;
|
||||
|
||||
String rawPlayerInput = getPlayerInput(player);
|
||||
int spaces = rawPlayerInput.contains(" ") ? rawPlayerInput.split(" ").length : 0;
|
||||
|
||||
String playerInput = StringUtils.getFirstArg(rawPlayerInput),
|
||||
server = player.getServer().getInfo().getName();
|
||||
|
||||
if (!playerInput.equals("/")) {
|
||||
cancelsBeforeHand = !Storage.Blacklist.canPlayerAccessTab(player, StringUtils.replaceFirst(playerInput, "/", ""), server);
|
||||
|
||||
if (!cancelsBeforeHand)
|
||||
cancelsBeforeHand = !Storage.ConfigSections.Settings.CUSTOM_VERSION.isTabCompletable(StringUtils.replaceFirst(playerInput, "/", "")) || Storage.ConfigSections.Settings.CUSTOM_PLUGIN.isTabCompletable(StringUtils.replaceFirst(playerInput, "/", ""));
|
||||
}
|
||||
|
||||
final String cursor = playerInput;
|
||||
|
||||
if (cursor.startsWith("/")) {
|
||||
if (spaces == 0) {
|
||||
List<String> suggestions = new ArrayList<>(response.getCommands());
|
||||
|
||||
if (Storage.ConfigSections.Settings.TURN_BLACKLIST_TO_WHITELIST.ENABLED) {
|
||||
setPluginCommands();
|
||||
|
||||
Storage.Blacklist.getServerBlacklists(server).forEach(blacklist -> blacklist.getCommands().stream().filter(command -> !suggestions.contains("/" + command)).forEach(command -> {
|
||||
if (BungeePacketAnalyzer.PLUGIN_COMMANDS.contains(command))
|
||||
suggestions.add("/" + command);
|
||||
}));
|
||||
|
||||
BungeePacketAnalyzer.PLUGIN_COMMANDS.stream().filter(command -> !suggestions.contains(command)).forEach(command -> {
|
||||
if (command.startsWith("/"))
|
||||
command = StringUtils.replaceFirst(command, "/", "");
|
||||
|
||||
if (Storage.Blacklist.canPlayerAccessTab(player, command, server)) {
|
||||
suggestions.add("/" + command);
|
||||
}
|
||||
});
|
||||
|
||||
suggestions.stream().filter(suggestion -> suggestion.startsWith(cursor) && !response.getCommands().contains(suggestion)).forEach(command -> response.getCommands().add(command));
|
||||
|
||||
} else {
|
||||
BungeePacketAnalyzer.PLUGIN_COMMANDS.stream().filter(command -> !suggestions.contains(command)).forEach(suggestions::add);
|
||||
|
||||
suggestions.removeIf(command -> {
|
||||
if (command.startsWith("/"))
|
||||
command = StringUtils.replaceFirst(command, "/", "");
|
||||
|
||||
return !Storage.Blacklist.canPlayerAccessTab(player, command, server);
|
||||
});
|
||||
|
||||
response.getCommands().clear();
|
||||
suggestions.forEach(command -> response.getCommands().add(command));
|
||||
}
|
||||
|
||||
if (response.getCommands().isEmpty())
|
||||
return;
|
||||
|
||||
} else {
|
||||
if (cancelsBeforeHand)
|
||||
return;
|
||||
}
|
||||
|
||||
player.unsafe().sendPacket(new TabCompleteResponse(response.getCommands()));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
list.add(wrapper);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3,33 +3,25 @@ package de.rayzs.pat.api.storage;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import de.rayzs.pat.api.communication.Communicator;
|
||||
import de.rayzs.pat.api.netty.proxy.BungeePacketAnalyzer;
|
||||
import de.rayzs.pat.plugin.system.serverbrand.CustomServerBrand;
|
||||
import de.rayzs.pat.plugin.system.communication.BackendUpdater;
|
||||
import de.rayzs.pat.plugin.system.communication.Communicator;
|
||||
import de.rayzs.pat.plugin.packetanalyzer.proxy.BungeePacketAnalyzer;
|
||||
import de.rayzs.pat.api.storage.config.messages.*;
|
||||
import de.rayzs.pat.api.storage.config.settings.*;
|
||||
import de.rayzs.pat.plugin.listeners.bukkit.BukkitAntiTabListener;
|
||||
import de.rayzs.pat.plugin.logger.Logger;
|
||||
import de.rayzs.pat.plugin.modules.SubArgsModule;
|
||||
import de.rayzs.pat.plugin.system.subargument.SubArgument;
|
||||
import de.rayzs.pat.utils.configuration.updater.ConfigUpdater;
|
||||
import de.rayzs.pat.utils.group.Group;
|
||||
import de.rayzs.pat.utils.permission.PermissionPlugin;
|
||||
import de.rayzs.pat.utils.response.ResponseHandler;
|
||||
import de.rayzs.pat.utils.sender.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import de.rayzs.pat.api.event.PATEventHandler;
|
||||
import de.rayzs.pat.api.storage.blacklist.BlacklistCreator;
|
||||
import de.rayzs.pat.api.storage.blacklist.impl.GeneralBlacklist;
|
||||
import de.rayzs.pat.api.storage.blacklist.impl.GeneralIgnoredServers;
|
||||
import de.rayzs.pat.api.storage.config.messages.BlacklistSection;
|
||||
import de.rayzs.pat.api.storage.config.messages.CommandFailedSection;
|
||||
import de.rayzs.pat.api.storage.config.messages.GroupSection;
|
||||
import de.rayzs.pat.api.storage.config.messages.HelpSection;
|
||||
import de.rayzs.pat.api.storage.config.messages.InfoSection;
|
||||
import de.rayzs.pat.api.storage.config.messages.NoPermissionSection;
|
||||
import de.rayzs.pat.api.storage.config.messages.NotificationSection;
|
||||
import de.rayzs.pat.api.storage.config.messages.OnlyForProxySection;
|
||||
import de.rayzs.pat.api.storage.config.messages.PermsCheckSection;
|
||||
import de.rayzs.pat.api.storage.config.messages.PostDebugSection;
|
||||
import de.rayzs.pat.api.storage.config.messages.PrefixSection;
|
||||
import de.rayzs.pat.api.storage.config.messages.ReloadSection;
|
||||
import de.rayzs.pat.api.storage.config.messages.ServerListSection;
|
||||
import de.rayzs.pat.api.storage.config.messages.StatsSection;
|
||||
import de.rayzs.pat.api.storage.config.messages.UpdatePermissionsSection;
|
||||
import de.rayzs.pat.api.storage.placeholders.commands.general.ListCommandsPlaceholder;
|
||||
import de.rayzs.pat.api.storage.placeholders.commands.general.ListReversedCommandsPlaceholder;
|
||||
import de.rayzs.pat.api.storage.placeholders.commands.general.ListSizeCommandsPlaceholder;
|
||||
@@ -68,25 +60,48 @@ public class Storage {
|
||||
|
||||
public static final List<UUID> NOTIFY_PLAYERS = new ArrayList<>();
|
||||
|
||||
public static String TOKEN = "", SERVER_NAME = null, CURRENT_VERSION = "", NEWER_VERSION = "";
|
||||
public static String TOKEN = "", CENSORED_TOKEN = "", SERVER_NAME = null, CURRENT_VERSION = "", NEWER_VERSION = "";
|
||||
public static boolean OUTDATED = false, SEND_CONSOLE_NOTIFICATION = true;
|
||||
public static Object PLUGIN_OBJECT;
|
||||
public static boolean USE_LUCKPERMS = false, USE_GROUPMANAGER = false, USE_PLACEHOLDERAPI = false, USE_PAPIPROXYBRIDGE = false, USE_VIAVERSION = false, USE_VELOCITY = false, USE_SIMPLECLOUD;
|
||||
public static long LAST_SYNC = System.currentTimeMillis();
|
||||
public static boolean USE_PLACEHOLDERAPI = false, USE_PAPIPROXYBRIDGE = false, USE_VIAVERSION = false;
|
||||
|
||||
private final static ExpireCache<UUID, String> TEMP_PLAYER_SERVER_CACHE = new ExpireCache<>(1, TimeUnit.SECONDS);
|
||||
private static PermissionPlugin PERMISSION_PLUGIN = PermissionPlugin.NONE;
|
||||
|
||||
public static void initialize(PluginLoader loader, String currentVersion) {
|
||||
LOADER = loader;
|
||||
CURRENT_VERSION = currentVersion;
|
||||
}
|
||||
|
||||
public static void setPermissionPlugin(PermissionPlugin permissionPlugin) {
|
||||
if (PERMISSION_PLUGIN == PermissionPlugin.LUCKPERMS) {
|
||||
return;
|
||||
}
|
||||
|
||||
PERMISSION_PLUGIN = permissionPlugin;
|
||||
}
|
||||
|
||||
|
||||
public static void broadcastPermissionsPluginNotice() {
|
||||
if (Storage.getPermissionPlugin() != PermissionPlugin.NONE) {
|
||||
return;
|
||||
}
|
||||
|
||||
Logger.warning("No known permissions plugin found, so some features may be disabled.");
|
||||
Logger.warning("Read more about it here: https://rayzs.de/products/proantitab/nkppf");
|
||||
}
|
||||
|
||||
public static PermissionPlugin getPermissionPlugin() {
|
||||
return PERMISSION_PLUGIN;
|
||||
}
|
||||
|
||||
public static void loadAll(boolean loadBlacklist) {
|
||||
loadConfig();
|
||||
loadToken();
|
||||
|
||||
if (TOKEN != null && !TOKEN.isEmpty()) {
|
||||
int tokenLength = TOKEN.length(), cutIndex = Math.max(1, tokenLength - 3);
|
||||
String censoredTokenDisplay = "*".repeat(cutIndex) + TOKEN.substring(cutIndex);
|
||||
Logger.info("Token found! (" + censoredTokenDisplay + ")");
|
||||
int tokenLength = TOKEN.length(), cutIndex = Math.max(1, tokenLength - 2);
|
||||
CENSORED_TOKEN = TOKEN.charAt(0) + "*".repeat(cutIndex) + TOKEN.substring(cutIndex);
|
||||
Logger.info("Token found! (" + CENSORED_TOKEN + ")");
|
||||
}
|
||||
|
||||
if (loadBlacklist) Blacklist.loadAll();
|
||||
@@ -95,6 +110,7 @@ public class Storage {
|
||||
}
|
||||
|
||||
public static void loadToken() {
|
||||
Files.TOKEN.reload();
|
||||
|
||||
boolean invalidEnv = false;
|
||||
|
||||
@@ -150,6 +166,38 @@ public class Storage {
|
||||
ConfigSections.PLACEHOLDERS.forEach(PlaceholderStorage::load);
|
||||
}
|
||||
|
||||
public static void reload() {
|
||||
boolean proxy = Reflection.isProxyServer();
|
||||
boolean backend = Storage.ConfigSections.Settings.HANDLE_THROUGH_PROXY.ENABLED && !proxy;
|
||||
|
||||
ConfigUpdater.initialize();
|
||||
Storage.loadAll(Reflection.isProxyServer() || !backend);
|
||||
|
||||
CustomServerBrand.get().refreshTask();
|
||||
|
||||
GroupManager.clearAllGroups();
|
||||
GroupManager.initialize();
|
||||
|
||||
if (!proxy) {
|
||||
Communicator.get().reload();
|
||||
BackendUpdater.get().restart();
|
||||
}
|
||||
|
||||
if (!backend) {
|
||||
Storage.handleChange();
|
||||
}
|
||||
|
||||
if (proxy) {
|
||||
Communicator.Proxy2Backend.sendDataSync();
|
||||
}
|
||||
|
||||
Storage.Files.CUSTOM_RESPONSES.reload();
|
||||
ResponseHandler.update();
|
||||
|
||||
ConfigUpdater.broadcastMissingParts();
|
||||
Storage.getLoader().handleReload();
|
||||
}
|
||||
|
||||
public static void handleChange() {
|
||||
handleChange(null);
|
||||
}
|
||||
@@ -158,14 +206,12 @@ public class Storage {
|
||||
|
||||
if (Reflection.isProxyServer()) {
|
||||
|
||||
boolean isVelocity = Reflection.isVelocityServer();
|
||||
|
||||
if (server != null) {
|
||||
|
||||
Storage.Blacklist.clearServerBlacklists(server);
|
||||
Storage.Blacklist.loadCachedServerBlacklists(server);
|
||||
|
||||
List<String> associatedServers = getServers()
|
||||
final List<String> associatedServers = getServers()
|
||||
.stream()
|
||||
.filter(s -> !s.equals(server) && isServer(server, s))
|
||||
.toList();
|
||||
@@ -175,68 +221,71 @@ public class Storage {
|
||||
Storage.Blacklist.loadCachedServerBlacklists(s);
|
||||
});
|
||||
|
||||
if (isVelocity) {
|
||||
associatedServers.forEach(serverName -> {
|
||||
final List<UUID> playerIds = Storage.getLoader().getPlayerIdsByServer(serverName);
|
||||
final List<String> commands = Blacklist.Collector.collectAllServerCommands(serverName);
|
||||
|
||||
associatedServers.forEach(s -> {
|
||||
List<UUID> playerIds = Storage.getLoader().getPlayerIdsByServer(s);
|
||||
List<String> commands = new ArrayList<>(SubArgsModule.getServerCommands(s));
|
||||
playerIds.forEach(playerId -> {
|
||||
final CommandSender sender = CommandSender.from(playerId);
|
||||
|
||||
playerIds.forEach(playerId -> {
|
||||
List<String> playerCommands = new ArrayList<>(commands);
|
||||
playerCommands.addAll(SubArgsModule.getGroupCommands(playerId, s));
|
||||
final List<String> playerCommands = new ArrayList<>(commands);
|
||||
final List<String> groupCommands = Blacklist.Collector.collectAllPlayerGroupCommands(sender, serverName);
|
||||
|
||||
PATEventHandler.callUpdatePlayerCommandsEvents(playerId, playerCommands, true);
|
||||
});
|
||||
playerCommands.addAll(groupCommands);
|
||||
|
||||
SubArgument.get().getUpdateArgumentsHandler().updatePlayerArguments(sender, playerCommands, commands, groupCommands);
|
||||
PATEventHandler.callUpdatePlayerCommandsEvents(sender, playerCommands, true);
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
} else {
|
||||
|
||||
Storage.Blacklist.Experimental.forceCacheReset();
|
||||
final List<UUID> playerIds = Storage.getLoader().getPlayerIds();
|
||||
|
||||
if (isVelocity) {
|
||||
List<UUID> playerIds = Storage.getLoader().getPlayerIds();
|
||||
playerIds.forEach(playerId -> {
|
||||
final CommandSender sender = CommandSender.from(playerId);
|
||||
|
||||
playerIds.forEach(playerId -> {
|
||||
List<String> playerCommands = new ArrayList<>(SubArgsModule.getServerCommands(playerId));
|
||||
playerCommands.addAll(SubArgsModule.getGroupCommands(playerId));
|
||||
final List<String> serverCommands = Storage.Blacklist.Collector.collectAllServerCommands(sender.getServerName());
|
||||
final List<String> playerCommands = new ArrayList<>(serverCommands);
|
||||
final List<String> groupCommands = Storage.Blacklist.Collector.collectAllPlayerGroupCommands(sender, sender.getServerName());
|
||||
|
||||
PATEventHandler.callUpdatePlayerCommandsEvents(playerId, playerCommands, false);
|
||||
});
|
||||
}
|
||||
playerCommands.addAll(groupCommands);
|
||||
|
||||
SubArgument.get().getUpdateArgumentsHandler().updatePlayerArguments(sender, playerCommands, serverCommands, groupCommands);
|
||||
PATEventHandler.callUpdatePlayerCommandsEvents(sender, playerCommands, false);
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
GroupManager.clearServerGroupBlacklists();
|
||||
Communicator.syncData();
|
||||
|
||||
Storage.getLoader().updateCommandCache();
|
||||
Communicator.sendPermissionReset();
|
||||
Storage.getLoader().resetCommandsCache();
|
||||
|
||||
if (!Reflection.isVelocityServer()) {
|
||||
BungeePacketAnalyzer.sendCommandsPacket();
|
||||
}
|
||||
|
||||
Communicator.Proxy2Backend.sendUpdateCommand();
|
||||
return;
|
||||
}
|
||||
|
||||
getLoader().handleReload();
|
||||
PermissionUtil.reloadPermissions();
|
||||
|
||||
if (Reflection.getMinor() < 13) {
|
||||
final List<UUID> playerIds = Storage.getLoader().getPlayerIds();
|
||||
final List<String> commands = new ArrayList<>(Blacklist.BLACKLIST.getCommands());
|
||||
Storage.getLoader().resetCommandsCache();
|
||||
Storage.getLoader().updateCommands();
|
||||
}
|
||||
|
||||
playerIds.forEach(playerId -> {
|
||||
List<String> playerCommands = new ArrayList<>(commands);
|
||||
playerCommands.addAll(SubArgsModule.getGroupCommands(playerId));
|
||||
public static void tempCachePlayerToServer(UUID playerId, String server) {
|
||||
TEMP_PLAYER_SERVER_CACHE.put(playerId, server);
|
||||
}
|
||||
|
||||
PATEventHandler.callUpdatePlayerCommandsEvents(playerId, playerCommands, true);
|
||||
});
|
||||
} else {
|
||||
BukkitAntiTabListener.handleTabCompletion();
|
||||
}
|
||||
public static String getTempCachedPlayerToServer(UUID playerId, String server) {
|
||||
return TEMP_PLAYER_SERVER_CACHE.get(playerId);
|
||||
}
|
||||
|
||||
public static String getCachedPlayerServername(UUID playerId) {
|
||||
return TEMP_PLAYER_SERVER_CACHE.get(playerId);
|
||||
}
|
||||
|
||||
public static PluginLoader getLoader() {
|
||||
@@ -295,20 +344,25 @@ public class Storage {
|
||||
|
||||
public static class Settings {
|
||||
|
||||
public static AutoLowercaseCommandsSection AUTO_LOWERCASE_COMMANDS = new AutoLowercaseCommandsSection();
|
||||
public static BlockNamespaceCommandsSection BLOCK_NAMESPACE_COMMANDS = new BlockNamespaceCommandsSection();
|
||||
public static HandleThroughProxySection HANDLE_THROUGH_PROXY = new HandleThroughProxySection();
|
||||
public static PatchExploitSection PATCH_EXPLOITS = new PatchExploitSection();
|
||||
public static CustomBrandSection CUSTOM_BRAND = new CustomBrandSection();
|
||||
public static CancelCommandSection CANCEL_COMMAND = new CancelCommandSection();
|
||||
public static CustomPluginsSection CUSTOM_PLUGIN = new CustomPluginsSection();
|
||||
public static CustomVersionSection CUSTOM_VERSION = new CustomVersionSection();
|
||||
public static DisableSyncSection DISABLE_SYNC = new DisableSyncSection();
|
||||
public static CustomProtocolPingSection CUSTOM_PROTOCOL_PING = new CustomProtocolPingSection();
|
||||
public static CustomUnknownCommandSection CUSTOM_UNKNOWN_COMMAND = new CustomUnknownCommandSection();
|
||||
public static TurnBlacklistToWhitelistSection TURN_BLACKLIST_TO_WHITELIST = new TurnBlacklistToWhitelistSection();
|
||||
public static BaseCommandCaseSensitiveSection BASE_COMMAND_CASE_SENSITIVE = new BaseCommandCaseSensitiveSection();
|
||||
public static UpdateCommandsPerWorldSection UPDATE_COMMANDS_PER_WORLD = new UpdateCommandsPerWorldSection();
|
||||
public static final AllowGroupOverrulingSection ALLOW_GROUP_OVERRULING = new AllowGroupOverrulingSection();
|
||||
public static final AutoLowercaseCommandsSection AUTO_LOWERCASE_COMMANDS = new AutoLowercaseCommandsSection();
|
||||
public static final BlockNamespaceCommandsSection BLOCK_NAMESPACE_COMMANDS = new BlockNamespaceCommandsSection();
|
||||
public static final HandleThroughProxySection HANDLE_THROUGH_PROXY = new HandleThroughProxySection();
|
||||
public static final InjectionFailedSection INJECTION_FAILED = new InjectionFailedSection();
|
||||
public static final PatchExploitSection PATCH_EXPLOITS = new PatchExploitSection();
|
||||
public static final CustomBrandSection CUSTOM_BRAND = new CustomBrandSection();
|
||||
public static final CancelCommandSection CANCEL_COMMAND = new CancelCommandSection();
|
||||
public static final CustomPluginsSection CUSTOM_PLUGIN = new CustomPluginsSection();
|
||||
public static final CustomVersionSection CUSTOM_VERSION = new CustomVersionSection();
|
||||
public static final DisableSyncSection DISABLE_SYNC = new DisableSyncSection();
|
||||
public static final ForwardConsoleNotificationAlertsSection FORWARD_CONSOLE_NOTIFICATIONS = new ForwardConsoleNotificationAlertsSection();
|
||||
public static final CustomProtocolPingSection CUSTOM_PROTOCOL_PING = new CustomProtocolPingSection();
|
||||
public static final CustomUnknownCommandSection CUSTOM_UNKNOWN_COMMAND = new CustomUnknownCommandSection();
|
||||
public static final TurnBlacklistToWhitelistSection TURN_BLACKLIST_TO_WHITELIST = new TurnBlacklistToWhitelistSection();
|
||||
public static final BaseCommandCaseSensitiveSection BASE_COMMAND_CASE_SENSITIVE = new BaseCommandCaseSensitiveSection();
|
||||
public static final UpdateGroupsPerWorldSection UPDATE_GROUPS_PER_WORLD = new UpdateGroupsPerWorldSection();
|
||||
public static final UpdateGroupsPerServerSection UPDATE_GROUPS_PER_SERVER = new UpdateGroupsPerServerSection();
|
||||
|
||||
public static UpdateSection UPDATE = new UpdateSection();
|
||||
|
||||
public static void initialize() {}
|
||||
@@ -319,6 +373,8 @@ public class Storage {
|
||||
public static PrefixSection PREFIX = new PrefixSection();
|
||||
public static BlacklistSection BLACKLIST = new BlacklistSection();
|
||||
public static CommandFailedSection COMMAND_FAILED = new CommandFailedSection();
|
||||
public static ConvertSection CONVERT = new ConvertSection();
|
||||
public static ExtractSection EXTRACT = new ExtractSection();
|
||||
public static GroupSection GROUP = new GroupSection();
|
||||
public static HelpSection HELP = new HelpSection();
|
||||
public static InfoSection INFO = new InfoSection();
|
||||
@@ -393,7 +449,62 @@ public class Storage {
|
||||
|
||||
public static class Blacklist {
|
||||
|
||||
public static class Experimental {
|
||||
public static class Collector {
|
||||
|
||||
|
||||
/**
|
||||
* Collects all commands from the global section and
|
||||
* that certain server.
|
||||
*
|
||||
* @param serverName Target server name.
|
||||
* @return List of collected commands.
|
||||
*/
|
||||
public static List<String> collectAllServerCommands(String serverName) {
|
||||
List<String> commands = new ArrayList<>(Storage.Blacklist.getBlacklist().getCommands());
|
||||
if (!Reflection.isProxyServer())
|
||||
return commands;
|
||||
|
||||
if (serverName == null)
|
||||
return commands;
|
||||
|
||||
List<GeneralBlacklist> blacklists = Storage.Blacklist.getServerBlacklists(serverName);
|
||||
for (GeneralBlacklist blacklist : blacklists)
|
||||
commands.addAll(blacklist.getCommands());
|
||||
|
||||
return commands;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a list of all available commands for a player
|
||||
* based on the PAT groups the player is in.
|
||||
*
|
||||
* @param sender Target player.
|
||||
* @param serverName Target server name.
|
||||
* @return List of collected commands.
|
||||
*/
|
||||
public static List<String> collectAllPlayerGroupCommands(CommandSender sender, String serverName) {
|
||||
final List<String> commands = new ArrayList<>();
|
||||
final List<Group> groups = GroupManager.getPlayerGroups(sender);
|
||||
|
||||
if (serverName == null) {
|
||||
groups.forEach(group -> commands.addAll(group.getCommands()));
|
||||
return commands;
|
||||
}
|
||||
|
||||
groups.forEach(group -> {
|
||||
commands.addAll(group.getCommands());
|
||||
|
||||
group.getBlacklistServerNames(serverName).forEach(s -> {
|
||||
commands.addAll(group.getCommands(s));
|
||||
});
|
||||
});
|
||||
|
||||
return commands;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private static class Experimental {
|
||||
|
||||
public static void forceCacheReset() {
|
||||
for (Object o : CACHED_SERVER_BLACKLIST.getCache().asMap().keySet()) {
|
||||
@@ -436,7 +547,7 @@ public class Storage {
|
||||
// Temporary list for all servers (e.g: server-1)
|
||||
private static final ExpireCache<String, List<GeneralBlacklist>> CACHED_SERVER_BLACKLIST = new ExpireCache<>(1, TimeUnit.HOURS);
|
||||
|
||||
public static void loadAll() {
|
||||
private static void loadAll() {
|
||||
CACHED_SERVER_BLACKLIST.clear();
|
||||
SERVER_BLACKLISTS.clear();
|
||||
BLACKLIST.load();
|
||||
@@ -506,39 +617,62 @@ public class Storage {
|
||||
return IGNORED_SERVERS.isListed(server);
|
||||
}
|
||||
|
||||
public static boolean canPlayerAccess(Object player, String command, BlockType type) {
|
||||
return canPlayerAccess(player, command, type, null);
|
||||
public static boolean canPlayerAccess(CommandSender sender, List<Group> groups, String command, BlockType type) {
|
||||
return canPlayerAccess(sender, groups, command, type, null);
|
||||
}
|
||||
|
||||
public static boolean canPlayerAccessChat(Object player, String command) {
|
||||
return canPlayerAccess(player, command, BlockType.CHAT, null);
|
||||
public static boolean canPlayerAccessChat(CommandSender sender, List<Group> groups, String command) {
|
||||
return canPlayerAccess(sender, groups, command, BlockType.CHAT, null);
|
||||
}
|
||||
|
||||
|
||||
public static boolean canPlayerAccessChat(Object player, String command, String server) {
|
||||
return canPlayerAccess(player, command, BlockType.CHAT, server);
|
||||
public static boolean canPlayerAccessChat(CommandSender sender, List<Group> groups, String command, String server) {
|
||||
return canPlayerAccess(sender, groups, command, BlockType.CHAT, server);
|
||||
}
|
||||
|
||||
public static boolean canPlayerAccessTab(Object player, String command) {
|
||||
return canPlayerAccess(player, command, BlockType.TAB, null);
|
||||
public static boolean canPlayerAccessTab(CommandSender sender, List<Group> groups, String command) {
|
||||
return canPlayerAccess(sender, groups, command, BlockType.TAB, null);
|
||||
}
|
||||
|
||||
public static boolean canPlayerAccessTab(Object player, String command, String server) {
|
||||
return canPlayerAccess(player, command, BlockType.TAB, server);
|
||||
public static boolean canPlayerAccessTab(CommandSender sender, List<Group> groups, String command, String server) {
|
||||
return canPlayerAccess(sender, groups, command, BlockType.TAB, server);
|
||||
}
|
||||
|
||||
public static boolean canPlayerAccess(Object player, String command, BlockType type, String server) {
|
||||
boolean blocked = isBlocked(command, type, server);
|
||||
public static boolean canPlayerAccess(CommandSender sender, List<Group> groups, String command, BlockType type, String server) {
|
||||
final boolean allowGroupOverruling = ConfigSections.Settings.ALLOW_GROUP_OVERRULING.ENABLED;
|
||||
final boolean blocked = isBlocked(command, type, server);
|
||||
|
||||
if (allowGroupOverruling) {
|
||||
GroupManager.AccessResult groupResult = GroupManager.canAccessCommand(groups, command, type, server);
|
||||
if (groupResult == GroupManager.AccessResult.NEGATED) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!blocked) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (Storage.getPermissionPlugin() != PermissionPlugin.NONE) {
|
||||
if (PermissionUtil.hasBypassPermission(sender, command)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return groupResult.asBoolean();
|
||||
}
|
||||
|
||||
|
||||
if (!blocked) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (PermissionUtil.hasBypassPermission(player, command)) {
|
||||
return true;
|
||||
if (Storage.getPermissionPlugin() != PermissionPlugin.NONE) {
|
||||
if (PermissionUtil.hasBypassPermission(sender, command)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return GroupManager.canAccessCommand(player, command, type, server);
|
||||
return GroupManager.canAccessCommand(groups, command, type, server).asBoolean();
|
||||
}
|
||||
|
||||
public static boolean isBlockedChat(String command) {
|
||||
@@ -566,34 +700,35 @@ public class Storage {
|
||||
BlockType negation = BlockType.NEGATE;
|
||||
String negatedCommand = negation + command;
|
||||
|
||||
boolean listed = isListed(command, type, server),
|
||||
boolean all = isListed("*", type, server),
|
||||
listed = isListed(command, type, server),
|
||||
negatedListed = isListed(negatedCommand, type, server),
|
||||
turn = ConfigSections.Settings.TURN_BLACKLIST_TO_WHITELIST.ENABLED;
|
||||
|
||||
if (all) {
|
||||
// Only listens to negated commands
|
||||
if (negatedListed) {
|
||||
return turn;
|
||||
}
|
||||
|
||||
if (!turn && negatedListed) {
|
||||
listed = !listed;
|
||||
return !turn;
|
||||
}
|
||||
|
||||
if (turn) {
|
||||
return !listed;
|
||||
} else {
|
||||
return listed;
|
||||
}
|
||||
return turn != listed;
|
||||
|
||||
}
|
||||
|
||||
private static boolean isListed(String unmodifiedCommand, BlockType type, String server) {
|
||||
if (server != null && isDisabledServer(server))
|
||||
if (server != null && isDisabledServer(server)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
boolean turn = Storage.ConfigSections.Settings.TURN_BLACKLIST_TO_WHITELIST.ENABLED;
|
||||
boolean listed = false;
|
||||
|
||||
String command = type.toString() + unmodifiedCommand;
|
||||
|
||||
if (server == null || !isIgnoredServer(server)) {
|
||||
listed = BLACKLIST.isListed(command, !turn);
|
||||
listed = BLACKLIST.isListed(command, false);
|
||||
}
|
||||
|
||||
if (server == null) {
|
||||
@@ -610,11 +745,11 @@ public class Storage {
|
||||
blacklists.add(BLACKLIST);
|
||||
|
||||
for (GeneralBlacklist blacklist : blacklists) {
|
||||
if (listed/* && turn*/) {
|
||||
if (listed) {
|
||||
break;
|
||||
}
|
||||
|
||||
listed = blacklist.isListed(command, turn);
|
||||
listed = blacklist.isListed(command, false);
|
||||
}
|
||||
|
||||
if (!listed && type != BlockType.BOTH) {
|
||||
@@ -626,6 +761,19 @@ public class Storage {
|
||||
|
||||
public static class BlockTypeFetcher {
|
||||
|
||||
public static boolean isNegated(String command) {
|
||||
if (command.isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
boolean negated = command.charAt(0) == '!';
|
||||
|
||||
if (!negated && command.length() > 5)
|
||||
negated = command.charAt(5) == '!';
|
||||
|
||||
return negated;
|
||||
}
|
||||
|
||||
public static BlockType getType(String command) {
|
||||
for (BlockType blockType : BLOCK_TYPES) {
|
||||
if (!command.startsWith(blockType.toString()))
|
||||
@@ -649,6 +797,17 @@ public class Storage {
|
||||
return command.substring(type.toString().length());
|
||||
}
|
||||
|
||||
// Remove all BlockType elements from String
|
||||
public static String cleanse(String command) {
|
||||
BlockType type = getType(command);
|
||||
|
||||
if (type == null || type == BlockType.BOTH) {
|
||||
return command;
|
||||
}
|
||||
|
||||
return modify(command, type);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
package de.rayzs.pat.api.storage.config.messages;
|
||||
|
||||
import de.rayzs.pat.api.storage.storages.ConfigStorage;
|
||||
import de.rayzs.pat.utils.configuration.helper.ConfigSectionHelper;
|
||||
import de.rayzs.pat.utils.configuration.helper.MultipleMessagesHelper;
|
||||
|
||||
public class ConvertSection extends ConfigStorage {
|
||||
|
||||
public MultipleMessagesHelper MESSAGE;
|
||||
|
||||
public ConvertSection() {
|
||||
super("convert");
|
||||
}
|
||||
|
||||
public String INVALID_CONVERTER, SUCCESS;
|
||||
|
||||
@Override
|
||||
public void load() {
|
||||
super.load();
|
||||
|
||||
INVALID_CONVERTER = new ConfigSectionHelper<String>(this, "converter-not-found", "&cConverter or necessary files could not be found!").getOrSet();
|
||||
SUCCESS = new ConfigSectionHelper<String>(this, "success", "&aSuccessfully converted &e%converter% &ainto the PAT storage.yml!").getOrSet();
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
package de.rayzs.pat.api.storage.config.messages;
|
||||
|
||||
import de.rayzs.pat.api.storage.storages.ConfigStorage;
|
||||
import de.rayzs.pat.utils.Reflection;
|
||||
import de.rayzs.pat.utils.configuration.helper.ConfigSectionHelper;
|
||||
import de.rayzs.pat.utils.configuration.helper.MultipleMessagesHelper;
|
||||
|
||||
public class ExtractSection extends ConfigStorage {
|
||||
|
||||
public MultipleMessagesHelper MESSAGE;
|
||||
|
||||
public ExtractSection() {
|
||||
super("extract");
|
||||
}
|
||||
|
||||
public String USAGE, PLUGIN_NOT_FOUND, SUCCESS;
|
||||
|
||||
@Override
|
||||
public void load() {
|
||||
super.load();
|
||||
|
||||
if (Reflection.isProxyServer()) {
|
||||
return;
|
||||
}
|
||||
|
||||
USAGE = new ConfigSectionHelper<String>(this, "usage", "&7Usage: &f/pat extract (plugin) <option> &7or &f(group) <option>").getOrSet();
|
||||
PLUGIN_NOT_FOUND = new ConfigSectionHelper<String>(this, "plugin-not-found", "&cPlugin %plugin% not found!").getOrSet();
|
||||
SUCCESS = new ConfigSectionHelper<String>(this, "success", "&aSuccessfully extracted &e%amount% &anew commands from %plugin%!").getOrSet();
|
||||
|
||||
}
|
||||
}
|
||||
@@ -16,6 +16,7 @@ public class HelpSection extends ConfigStorage {
|
||||
@Override
|
||||
public void load() {
|
||||
super.load();
|
||||
|
||||
MESSAGE = new MultipleMessagesHelper(this, null, Reflection.isProxyServer() ?
|
||||
Arrays.asList(
|
||||
"&7Available commands are: &f/%label%&7..."
|
||||
@@ -26,6 +27,8 @@ public class HelpSection extends ConfigStorage {
|
||||
, "&f postdebug &7to post the PAT logs"
|
||||
, "&f update <player> &7to update player(s) permissions"
|
||||
, "&f perms <player> &7to check a player's permissions"
|
||||
, "&f extract (plugin) &7to extract all plugin commands"
|
||||
, "&f convert (plugin) &7converts into a PAT storage.yml"
|
||||
, "&f creategroup (group) &7Create a group"
|
||||
, "&f deletegroup (group) &7Delete a group"
|
||||
, "&f setpriority (group) (priority) &7to set the priority"
|
||||
@@ -44,6 +47,7 @@ public class HelpSection extends ConfigStorage {
|
||||
, "&f postdebug &7to post the PAT logs"
|
||||
, "&f update <player> &7to update player(s) permissions"
|
||||
, "&f perms <player> &7to check a player's permissions"
|
||||
, "&f extract (plugin) &7to extract all plugin commands"
|
||||
, "&f creategroup (group) &7Create a group"
|
||||
, "&f deletegroup (group) &7Delete a group"
|
||||
, "&f setpriority (group) (priority) &7to set the priority"
|
||||
|
||||
@@ -1,12 +1,13 @@
|
||||
package de.rayzs.pat.api.storage.config.messages;
|
||||
|
||||
import de.rayzs.pat.api.storage.storages.ConfigStorage;
|
||||
import de.rayzs.pat.utils.Reflection;
|
||||
import de.rayzs.pat.utils.configuration.helper.*;
|
||||
import java.util.Arrays;
|
||||
|
||||
public class InfoSection extends ConfigStorage {
|
||||
|
||||
public String VERSION_OUTDATED, VERSION_UPDATED, SYNC_TIME, SYNC_DISABLED;
|
||||
public String VERSION_OUTDATED, VERSION_UPDATED, SYNC_TIME, SYNC_DISABLED, SYNC_WAITING;
|
||||
public MultipleMessagesHelper MESSAGE;
|
||||
|
||||
public InfoSection() {
|
||||
@@ -20,6 +21,11 @@ public class InfoSection extends ConfigStorage {
|
||||
VERSION_UPDATED = new ConfigSectionHelper<String>(this, "version.updated", "&aLatest version").getOrSet();
|
||||
VERSION_OUTDATED = new ConfigSectionHelper<String>(this, "version.outdated", "&cOutdated (%newest_version%)").getOrSet();
|
||||
SYNC_TIME = new ConfigSectionHelper<String>(this, "proxy-sync.time", "&e%time%").getOrSet();
|
||||
|
||||
if (!Reflection.isProxyServer()) {
|
||||
SYNC_WAITING = new ConfigSectionHelper<String>(this, "proxy-sync.waiting", "&cWaiting to establish connection...").getOrSet();
|
||||
}
|
||||
|
||||
SYNC_DISABLED = new ConfigSectionHelper<String>(this, "proxy-sync.disabled", "&cDisabled").getOrSet();
|
||||
|
||||
MESSAGE = new MultipleMessagesHelper(this, "message",
|
||||
@@ -28,6 +34,7 @@ public class InfoSection extends ConfigStorage {
|
||||
, "&7 Version: &e%current_version%"
|
||||
, "&7 Status: %version_status%"
|
||||
, "&7 Last sync with proxy: &e%sync_time%"
|
||||
, "&7 Last received alive packet: %last_alive_response%"
|
||||
, "&7 Proxy sync-token: &e%token%"
|
||||
, "&7 Proxy-received server name: &e%sync_server_name%"
|
||||
)
|
||||
|
||||
@@ -18,12 +18,17 @@ public class StatsSection extends ConfigStorage {
|
||||
@Override
|
||||
public void load() {
|
||||
super.load();
|
||||
if(!Reflection.isProxyServer()) return;
|
||||
|
||||
if (!Reflection.isProxyServer()) {
|
||||
return;
|
||||
}
|
||||
|
||||
NO_SERVER = new ConfigSectionHelper<String>(this, "no-server", "&cNone!").getOrSet();
|
||||
SPLITTER = new ConfigSectionHelper<String>(this, "message.splitter", "&7, ").getOrSet();
|
||||
SERVER = new ConfigSectionHelper<String>(this, "message.server", "&f%servername% &8(%updated%)").getOrSet();
|
||||
SERVER = new ConfigSectionHelper<String>(this, "message.server", "&f%servername% &8(&a%last_alive_response% &8/ &2%updated%&8)").getOrSet();
|
||||
STATISTIC = new MultipleMessagesHelper(this, "message.statistic", Arrays.asList(
|
||||
"&7Last sync sent to &f%server_count% &7servers. &8&o(%last_sync_time% ago)",
|
||||
"&7Format: &eserver (last alive packet / last sync packet)",
|
||||
"&7Last sync sent to &f%server_count% &7server(s) &e%last_sync_time% &7ago:",
|
||||
"&7Sent to servers: &f%servers%"
|
||||
));
|
||||
}
|
||||
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
package de.rayzs.pat.api.storage.config.settings;
|
||||
|
||||
import de.rayzs.pat.api.storage.storages.ConfigStorage;
|
||||
import de.rayzs.pat.utils.configuration.helper.ConfigSectionHelper;
|
||||
|
||||
public class AllowGroupOverrulingSection extends ConfigStorage {
|
||||
|
||||
public boolean ENABLED;
|
||||
|
||||
public AllowGroupOverrulingSection() {
|
||||
super("allow-group-overruling");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void load() {
|
||||
super.load();
|
||||
ENABLED = new ConfigSectionHelper<Boolean>(this, null, false).getOrSet();
|
||||
}
|
||||
}
|
||||
-8
@@ -4,7 +4,6 @@ import de.rayzs.pat.api.storage.storages.ConfigStorage;
|
||||
import de.rayzs.pat.utils.Reflection;
|
||||
import de.rayzs.pat.utils.StringUtils;
|
||||
import de.rayzs.pat.utils.configuration.helper.ConfigSectionHelper;
|
||||
import de.rayzs.pat.utils.permission.PermissionUtil;
|
||||
|
||||
public class AutoLowercaseCommandsSection extends ConfigStorage {
|
||||
|
||||
@@ -18,9 +17,6 @@ public class AutoLowercaseCommandsSection extends ConfigStorage {
|
||||
public void load() {
|
||||
super.load();
|
||||
|
||||
if (Reflection.isProxyServer())
|
||||
return;
|
||||
|
||||
ENABLED = new ConfigSectionHelper<Boolean>(this, "enabled", true).getOrSet();
|
||||
}
|
||||
|
||||
@@ -29,8 +25,4 @@ public class AutoLowercaseCommandsSection extends ConfigStorage {
|
||||
|
||||
return !StringUtils.isLowercased(command);
|
||||
}
|
||||
|
||||
public boolean doesBypass(Object targetObj) {
|
||||
return !ENABLED || PermissionUtil.hasPermission(targetObj, "auto-lowercase");
|
||||
}
|
||||
}
|
||||
+13
-6
@@ -1,14 +1,14 @@
|
||||
package de.rayzs.pat.api.storage.config.settings;
|
||||
|
||||
import de.rayzs.pat.api.storage.Storage;
|
||||
import de.rayzs.pat.api.storage.storages.ConfigStorage;
|
||||
import de.rayzs.pat.utils.StringUtils;
|
||||
import de.rayzs.pat.utils.configuration.helper.ConfigSectionHelper;
|
||||
import de.rayzs.pat.utils.permission.PermissionUtil;
|
||||
import de.rayzs.pat.utils.sender.CommandSender;
|
||||
|
||||
public class BlockNamespaceCommandsSection extends ConfigStorage {
|
||||
|
||||
public boolean ENABLED;
|
||||
public boolean ENABLED, ALWAYS_BLOCK_COMMAND;
|
||||
|
||||
public BlockNamespaceCommandsSection() {
|
||||
super("block-namespace-commands");
|
||||
@@ -18,15 +18,22 @@ public class BlockNamespaceCommandsSection extends ConfigStorage {
|
||||
public void load() {
|
||||
super.load();
|
||||
ENABLED = new ConfigSectionHelper<Boolean>(this, "enabled", true).getOrSet();
|
||||
ALWAYS_BLOCK_COMMAND = new ConfigSectionHelper<Boolean>(this, "always-block-command", true).getOrSet();
|
||||
}
|
||||
|
||||
public boolean doesAlwaysBlock(String command) {
|
||||
return ALWAYS_BLOCK_COMMAND && isCommand(command);
|
||||
}
|
||||
|
||||
public boolean isCommand(String command) {
|
||||
if(!ENABLED || Storage.ConfigSections.Settings.TURN_BLACKLIST_TO_WHITELIST.ENABLED) return false;
|
||||
if (!ENABLED) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return StringUtils.getFirstArg(command).contains(":");
|
||||
}
|
||||
|
||||
public boolean doesBypass(Object targetObj) {
|
||||
|
||||
return !ENABLED || PermissionUtil.hasPermission(targetObj, "namespace");
|
||||
public boolean doesBypass(CommandSender sender) {
|
||||
return !ENABLED || PermissionUtil.hasPermission(sender, "namespace");
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
package de.rayzs.pat.api.storage.config.settings;
|
||||
|
||||
import de.rayzs.pat.api.storage.storages.ConfigStorage;
|
||||
import de.rayzs.pat.utils.StringUtils;
|
||||
import de.rayzs.pat.utils.configuration.helper.*;
|
||||
import java.util.*;
|
||||
|
||||
@@ -31,13 +32,8 @@ public class CustomPluginsSection extends ConfigStorage {
|
||||
|
||||
public boolean isCommand(String command) {
|
||||
if(!ENABLED) return false;
|
||||
command = StringUtils.getFirstArg(command);
|
||||
|
||||
if (command.contains(" ")) {
|
||||
String[] split = command.split(" ");
|
||||
if (split.length > 0)
|
||||
command = split[0];
|
||||
command = command.split(" ")[0];
|
||||
}
|
||||
for (String currentCommand : COMMANDS.getLines()) {
|
||||
if (currentCommand.equalsIgnoreCase(command))
|
||||
return true;
|
||||
|
||||
+3
-2
@@ -10,7 +10,7 @@ import java.util.Arrays;
|
||||
|
||||
public class CustomProtocolPingSection extends ConfigStorage {
|
||||
|
||||
public boolean ENABLED, ALWAYS_SHOW, HIDE_PLAYERS, USE_EXTEND_AS_MAX_COUNT, USE_CUSTOM_PLAYERLIST;
|
||||
public boolean ENABLED, ALWAYS_SHOW, HIDE_PLAYERS, USE_EXTEND_AS_MAX_COUNT, USE_CUSTOM_PLAYERLIST, USE_CENTER_VARIABLE;
|
||||
public String PROTOCOL;
|
||||
|
||||
public MultipleMessagesHelper PLAYERLIST;
|
||||
@@ -25,7 +25,7 @@ public class CustomProtocolPingSection extends ConfigStorage {
|
||||
public void load() {
|
||||
super.load();
|
||||
|
||||
if (!Reflection.isProxyServer() && (!Reflection.isPaper() || Reflection.getMinor() < 12))
|
||||
if (!Reflection.isProxyServer() && (!Reflection.isPaper() || Reflection.isBefore(1, 12)))
|
||||
return;
|
||||
|
||||
ENABLED = new ConfigSectionHelper<Boolean>(this, "enabled", true).getOrSet();
|
||||
@@ -42,6 +42,7 @@ public class CustomProtocolPingSection extends ConfigStorage {
|
||||
"&8> &7Using &fProAntiTab"
|
||||
));
|
||||
|
||||
USE_CENTER_VARIABLE = PLAYERLIST.getLines().stream().anyMatch(l -> l.startsWith("%center%"));
|
||||
|
||||
|
||||
if (HIDE_PLAYERS && USE_CUSTOM_PLAYERLIST) {
|
||||
|
||||
@@ -6,7 +6,7 @@ import de.rayzs.pat.utils.configuration.helper.ConfigSectionHelper;
|
||||
|
||||
public class DisableSyncSection extends ConfigStorage {
|
||||
|
||||
public boolean DISABLED;
|
||||
public boolean ENABLED;
|
||||
|
||||
public DisableSyncSection() {
|
||||
super("disable-sync");
|
||||
@@ -16,7 +16,11 @@ public class DisableSyncSection extends ConfigStorage {
|
||||
public void load() {
|
||||
super.load();
|
||||
|
||||
if(!Reflection.isProxyServer()) return;
|
||||
DISABLED = new ConfigSectionHelper<Boolean>(this, null, false).getOrSet();
|
||||
|
||||
if (!Reflection.isProxyServer()) {
|
||||
return;
|
||||
}
|
||||
|
||||
ENABLED = new ConfigSectionHelper<Boolean>(this, null, false).getOrSet();
|
||||
}
|
||||
}
|
||||
+22
@@ -0,0 +1,22 @@
|
||||
package de.rayzs.pat.api.storage.config.settings;
|
||||
|
||||
import de.rayzs.pat.api.storage.storages.ConfigStorage;
|
||||
import de.rayzs.pat.utils.Reflection;
|
||||
import de.rayzs.pat.utils.configuration.helper.ConfigSectionHelper;
|
||||
|
||||
public class ForwardConsoleNotificationAlertsSection extends ConfigStorage {
|
||||
|
||||
public boolean ENABLED;
|
||||
|
||||
public ForwardConsoleNotificationAlertsSection() {
|
||||
super("forward-console-notification-alerts");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void load() {
|
||||
super.load();
|
||||
|
||||
if(!Reflection.isProxyServer()) return;
|
||||
ENABLED = new ConfigSectionHelper<Boolean>(this, null, false).getOrSet();
|
||||
}
|
||||
}
|
||||
+5
-3
@@ -6,7 +6,7 @@ import de.rayzs.pat.utils.Reflection;
|
||||
|
||||
public class HandleThroughProxySection extends ConfigStorage {
|
||||
|
||||
public boolean ENABLED;
|
||||
public boolean ENABLED, ALLOW_P2B_ACTIONS;
|
||||
|
||||
public boolean LOAD_FROM_ENV;
|
||||
public String ENV_NAME;
|
||||
@@ -20,12 +20,14 @@ public class HandleThroughProxySection extends ConfigStorage {
|
||||
@Override
|
||||
public void load() {
|
||||
super.load();
|
||||
if(Reflection.isProxyServer()) return;
|
||||
if (Reflection.isProxyServer()) return;
|
||||
|
||||
ENABLED = new ConfigSectionHelper<Boolean>(this, "enabled", false).getOrSet();
|
||||
TOKEN = new ConfigSectionHelper<String>(this, "token", "insert-token-of-proxy-here").getOrSet();
|
||||
|
||||
ALLOW_P2B_ACTIONS = new ConfigSectionHelper<Boolean>(this, "allow-p2b-actions", false).getOrSet();
|
||||
|
||||
LOAD_FROM_ENV = new ConfigSectionHelper<Boolean>(this, "load-from-env.enabled", false).getOrSet();
|
||||
ENV_NAME = new ConfigSectionHelper<String>(this, "load-from-env.name", false).getOrSet();
|
||||
ENV_NAME = new ConfigSectionHelper<String>(this, "load-from-env.name", "PAT_TOKEN").getOrSet();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
package de.rayzs.pat.api.storage.config.settings;
|
||||
|
||||
import de.rayzs.pat.api.storage.storages.ConfigStorage;
|
||||
import de.rayzs.pat.utils.configuration.helper.ConfigSectionHelper;
|
||||
|
||||
public class InjectionFailedSection extends ConfigStorage {
|
||||
|
||||
public boolean ENABLED, SUPPRESS_EXCEPTIONS;
|
||||
public String KICK_MESSAGE, CONSOLE_MESSAGE;
|
||||
|
||||
public InjectionFailedSection() {
|
||||
super("injection-failed");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void load() {
|
||||
super.load();
|
||||
ENABLED = new ConfigSectionHelper<Boolean>(this, "kick-on-failure", true).getOrSet();
|
||||
SUPPRESS_EXCEPTIONS = new ConfigSectionHelper<Boolean>(this, "suppress-exceptions", false).getOrSet();
|
||||
KICK_MESSAGE = new ConfigSectionHelper<String>(this, "kick-message", "&cInjection process failed! Please reconnect.").getOrSet();
|
||||
CONSOLE_MESSAGE = new ConfigSectionHelper<String>(this, "console-message", "&cInjection process failed! (%player%)").getOrSet();
|
||||
}
|
||||
}
|
||||
+24
@@ -0,0 +1,24 @@
|
||||
package de.rayzs.pat.api.storage.config.settings;
|
||||
|
||||
import de.rayzs.pat.api.storage.storages.ConfigStorage;
|
||||
import de.rayzs.pat.utils.Reflection;
|
||||
import de.rayzs.pat.utils.configuration.helper.ConfigSectionHelper;
|
||||
|
||||
public class UpdateGroupsPerServerSection extends ConfigStorage {
|
||||
|
||||
public boolean ENABLED = false;
|
||||
|
||||
public UpdateGroupsPerServerSection() {
|
||||
super("update-groups-per-server");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void load() {
|
||||
super.load();
|
||||
|
||||
if (!Reflection.isProxyServer())
|
||||
return;
|
||||
|
||||
ENABLED = new ConfigSectionHelper<Boolean>(this, null, false).getOrSet();
|
||||
}
|
||||
}
|
||||
+3
-3
@@ -4,12 +4,12 @@ import de.rayzs.pat.api.storage.storages.ConfigStorage;
|
||||
import de.rayzs.pat.utils.Reflection;
|
||||
import de.rayzs.pat.utils.configuration.helper.ConfigSectionHelper;
|
||||
|
||||
public class UpdateCommandsPerWorldSection extends ConfigStorage {
|
||||
public class UpdateGroupsPerWorldSection extends ConfigStorage {
|
||||
|
||||
public boolean ENABLED;
|
||||
|
||||
public UpdateCommandsPerWorldSection() {
|
||||
super("update-commands-per-world");
|
||||
public UpdateGroupsPerWorldSection() {
|
||||
super("update-groups-per-world");
|
||||
}
|
||||
|
||||
@Override
|
||||
-1
@@ -4,7 +4,6 @@ import de.rayzs.pat.utils.configuration.helper.ConfigSectionHelper;
|
||||
import de.rayzs.pat.api.storage.storages.PlaceholderStorage;
|
||||
import de.rayzs.pat.api.storage.Storage;
|
||||
import de.rayzs.pat.utils.StringUtils;
|
||||
import de.rayzs.pat.utils.group.GroupManager;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class ListCommandsPlaceholder extends PlaceholderStorage {
|
||||
|
||||
+2
-1
@@ -1,9 +1,10 @@
|
||||
package de.rayzs.pat.api.storage.placeholders.commands.group;
|
||||
|
||||
import de.rayzs.pat.utils.group.Group;
|
||||
import de.rayzs.pat.utils.group.GroupManager;
|
||||
import de.rayzs.pat.utils.configuration.helper.ConfigSectionHelper;
|
||||
import de.rayzs.pat.api.storage.storages.PlaceholderStorage;
|
||||
import de.rayzs.pat.utils.StringUtils;
|
||||
import de.rayzs.pat.utils.group.*;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class ListGroupCommandsPlaceholder extends PlaceholderStorage {
|
||||
|
||||
+2
-1
@@ -1,9 +1,10 @@
|
||||
package de.rayzs.pat.api.storage.placeholders.commands.group;
|
||||
|
||||
import de.rayzs.pat.utils.group.Group;
|
||||
import de.rayzs.pat.utils.group.GroupManager;
|
||||
import de.rayzs.pat.utils.configuration.helper.ConfigSectionHelper;
|
||||
import de.rayzs.pat.api.storage.storages.PlaceholderStorage;
|
||||
import de.rayzs.pat.utils.StringUtils;
|
||||
import de.rayzs.pat.utils.group.*;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class ListGroupReversedCommandsPlaceholder extends PlaceholderStorage {
|
||||
|
||||
+2
-1
@@ -1,7 +1,8 @@
|
||||
package de.rayzs.pat.api.storage.placeholders.commands.group;
|
||||
|
||||
import de.rayzs.pat.api.storage.storages.PlaceholderStorage;
|
||||
import de.rayzs.pat.utils.group.*;
|
||||
import de.rayzs.pat.utils.group.Group;
|
||||
import de.rayzs.pat.utils.group.GroupManager;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class ListGroupSizeCommandsPlaceholder extends PlaceholderStorage {
|
||||
|
||||
+2
-1
@@ -1,9 +1,10 @@
|
||||
package de.rayzs.pat.api.storage.placeholders.commands.group;
|
||||
|
||||
import de.rayzs.pat.utils.group.Group;
|
||||
import de.rayzs.pat.utils.group.GroupManager;
|
||||
import de.rayzs.pat.utils.configuration.helper.ConfigSectionHelper;
|
||||
import de.rayzs.pat.api.storage.storages.PlaceholderStorage;
|
||||
import de.rayzs.pat.utils.StringUtils;
|
||||
import de.rayzs.pat.utils.group.*;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class ListGroupSortedCommandsPlaceholder extends PlaceholderStorage {
|
||||
|
||||
+1
-1
@@ -1,9 +1,9 @@
|
||||
package de.rayzs.pat.api.storage.placeholders.groups;
|
||||
|
||||
import de.rayzs.pat.utils.group.GroupManager;
|
||||
import de.rayzs.pat.utils.configuration.helper.ConfigSectionHelper;
|
||||
import de.rayzs.pat.api.storage.storages.PlaceholderStorage;
|
||||
import de.rayzs.pat.utils.StringUtils;
|
||||
import de.rayzs.pat.utils.group.*;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class ListGroupsPlaceholder extends PlaceholderStorage {
|
||||
|
||||
+1
-1
@@ -1,9 +1,9 @@
|
||||
package de.rayzs.pat.api.storage.placeholders.groups;
|
||||
|
||||
import de.rayzs.pat.utils.group.GroupManager;
|
||||
import de.rayzs.pat.utils.configuration.helper.ConfigSectionHelper;
|
||||
import de.rayzs.pat.api.storage.storages.PlaceholderStorage;
|
||||
import de.rayzs.pat.utils.StringUtils;
|
||||
import de.rayzs.pat.utils.group.*;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class ListGroupsReversedPlaceholder extends PlaceholderStorage {
|
||||
|
||||
+1
-1
@@ -1,9 +1,9 @@
|
||||
package de.rayzs.pat.api.storage.placeholders.groups;
|
||||
|
||||
import de.rayzs.pat.utils.group.GroupManager;
|
||||
import de.rayzs.pat.utils.configuration.helper.ConfigSectionHelper;
|
||||
import de.rayzs.pat.api.storage.storages.PlaceholderStorage;
|
||||
import de.rayzs.pat.utils.StringUtils;
|
||||
import de.rayzs.pat.utils.group.*;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class ListGroupsSortedPlaceholder extends PlaceholderStorage {
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
package de.rayzs.pat.api.storage.storages;
|
||||
|
||||
import de.rayzs.pat.utils.StringUtils;
|
||||
import de.rayzs.pat.utils.permission.PermissionUtil;
|
||||
import de.rayzs.pat.plugin.logger.Logger;
|
||||
import de.rayzs.pat.api.storage.*;
|
||||
|
||||
import java.io.Serializable;
|
||||
@@ -11,27 +9,31 @@ import java.util.*;
|
||||
public class BlacklistStorage extends StorageTemplate implements Serializable {
|
||||
|
||||
private List<String> commands = new ArrayList<>();
|
||||
private List<String> hiddenCommands = new ArrayList<>();
|
||||
|
||||
public BlacklistStorage(String navigatePath) {
|
||||
super(Storage.Files.STORAGE, navigatePath);
|
||||
}
|
||||
|
||||
public boolean isListed(String command) {
|
||||
return isListed(command, !Storage.ConfigSections.Settings.TURN_BLACKLIST_TO_WHITELIST.ENABLED);
|
||||
return isListed(command, false);
|
||||
}
|
||||
|
||||
public boolean isListed(String command, boolean ignoreColons) {
|
||||
final boolean caseSensitive = Storage.ConfigSections.Settings.BASE_COMMAND_CASE_SENSITIVE.ENABLED;
|
||||
final boolean turn = Storage.ConfigSections.Settings.TURN_BLACKLIST_TO_WHITELIST.ENABLED;
|
||||
|
||||
if (commands == null || command.isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!isNegated(command) && commands.contains("*")) {
|
||||
return true;
|
||||
boolean isNegated = Storage.Blacklist.BlockTypeFetcher.isNegated(command);
|
||||
|
||||
if (!isNegated == turn) {
|
||||
command = StringUtils.getFirstArg(command);
|
||||
}
|
||||
|
||||
for (String listedCommand : commands) {
|
||||
for (String listedCommand : hiddenCommands) {
|
||||
if (listedCommand == null)
|
||||
continue;
|
||||
|
||||
@@ -42,14 +44,14 @@ public class BlacklistStorage extends StorageTemplate implements Serializable {
|
||||
command = command.substring(command.indexOf(':'));
|
||||
}
|
||||
|
||||
if (caseSensitive) {
|
||||
if (StringUtils.getFirstArg(listedCommand).equals(StringUtils.getFirstArg(command))) {
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
if (StringUtils.getFirstArg(listedCommand).equalsIgnoreCase(StringUtils.getFirstArg(command))) {
|
||||
return true;
|
||||
}
|
||||
if (!isNegated == turn) {
|
||||
listedCommand = StringUtils.getFirstArg(listedCommand);
|
||||
}
|
||||
|
||||
if (caseSensitive && listedCommand.equals(command)) {
|
||||
return true;
|
||||
} else if (!caseSensitive && listedCommand.equalsIgnoreCase(command)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -61,14 +63,17 @@ public class BlacklistStorage extends StorageTemplate implements Serializable {
|
||||
}
|
||||
|
||||
public BlacklistStorage add(String command) {
|
||||
if (!commands.contains(command))
|
||||
if (!commands.contains(command)) {
|
||||
commands.add(command);
|
||||
hiddenCommands.add(command);
|
||||
}
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
public BlacklistStorage remove(String command) {
|
||||
commands.remove(command);
|
||||
hiddenCommands.remove(command);
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -81,6 +86,10 @@ public class BlacklistStorage extends StorageTemplate implements Serializable {
|
||||
return commands;
|
||||
}
|
||||
|
||||
public List<String> getHiddenCommands() {
|
||||
return hiddenCommands;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void save() {
|
||||
getConfig().setAndSave(getNavigatePath(), commands);
|
||||
@@ -89,19 +98,54 @@ public class BlacklistStorage extends StorageTemplate implements Serializable {
|
||||
@Override
|
||||
public void load() {
|
||||
getConfig().reload();
|
||||
commands = (ArrayList<String>) getConfig().getOrSet(getNavigatePath(), commands);
|
||||
}
|
||||
|
||||
private boolean isNegated(String command) {
|
||||
if (command.isEmpty()) {
|
||||
return false;
|
||||
commands = (ArrayList<String>) getConfig().getOrSet(getNavigatePath(), commands);
|
||||
|
||||
final List<String> tmpCommands = commands != null ? new ArrayList<>(commands) : new ArrayList<>();
|
||||
final Set<String> pluginListCommands = new HashSet<>(), negatedPluginListCommands = new HashSet<>();
|
||||
|
||||
final String pluginCommandPrefix = "plugin=";
|
||||
final String negatedPluginCommandPrefix = Storage.Blacklist.BlockType.NEGATE + pluginCommandPrefix;
|
||||
|
||||
for (String command : tmpCommands) {
|
||||
if (command.startsWith(pluginCommandPrefix)) {
|
||||
pluginListCommands.add(command);
|
||||
}
|
||||
|
||||
if (command.startsWith(negatedPluginCommandPrefix)) {
|
||||
negatedPluginListCommands.add(command);
|
||||
}
|
||||
}
|
||||
|
||||
boolean negated = command.charAt(0) == '!';
|
||||
tmpCommands.removeAll(pluginListCommands);
|
||||
tmpCommands.removeAll(negatedPluginListCommands);
|
||||
|
||||
if (!negated && command.length() > 5)
|
||||
negated = command.charAt(5) == '!';
|
||||
for (String negatedPluginCommand : negatedPluginListCommands) {
|
||||
negatedPluginCommand = negatedPluginCommand.substring(negatedPluginCommandPrefix.length());
|
||||
|
||||
return negated;
|
||||
List<String> pluginCommands = Storage.getLoader().getPluginCommands(negatedPluginCommand, false);
|
||||
|
||||
for (String pluginCommand : pluginCommands) {
|
||||
tmpCommands.remove(pluginCommand);
|
||||
|
||||
tmpCommands.add(Storage.Blacklist.BlockType.NEGATE + pluginCommand);
|
||||
}
|
||||
}
|
||||
|
||||
for (String pluginListCommand : pluginListCommands) {
|
||||
pluginListCommand = pluginListCommand.substring(pluginCommandPrefix.length());
|
||||
|
||||
List<String> pluginCommands = Storage.getLoader().getPluginCommands(pluginListCommand, false);
|
||||
|
||||
for (String pluginCommand : pluginCommands) {
|
||||
final String negated = Storage.Blacklist.BlockType.NEGATE + pluginCommand;
|
||||
|
||||
if (!commands.contains(negated) && !tmpCommands.contains(negated)) {
|
||||
tmpCommands.add(pluginCommand);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
hiddenCommands = tmpCommands;
|
||||
}
|
||||
}
|
||||
@@ -17,8 +17,11 @@ public class DisabledServersStorage extends StorageTemplate {
|
||||
|
||||
public DisabledServersStorage add(String server) {
|
||||
server = server.toLowerCase();
|
||||
if(!servers.contains(server))
|
||||
|
||||
if (!servers.contains(server)) {
|
||||
servers.add(server);
|
||||
}
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -29,7 +32,10 @@ public class DisabledServersStorage extends StorageTemplate {
|
||||
}
|
||||
|
||||
public boolean isListed(String server) {
|
||||
if(servers.isEmpty()) return false;
|
||||
if (servers.isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return Storage.isServer(server, servers);
|
||||
}
|
||||
|
||||
@@ -42,7 +48,11 @@ public class DisabledServersStorage extends StorageTemplate {
|
||||
|
||||
@Override
|
||||
public void load() {
|
||||
if(!Reflection.isProxyServer()) return;
|
||||
|
||||
if (!Reflection.isProxyServer()) {
|
||||
return;
|
||||
}
|
||||
|
||||
getConfig().reload();
|
||||
servers = (ArrayList<String>) getConfig().getOrSet(getNavigatePath(), servers);
|
||||
}
|
||||
|
||||
@@ -1,29 +1,36 @@
|
||||
package de.rayzs.pat.plugin;
|
||||
|
||||
import de.rayzs.pat.api.brand.CustomServerBrand;
|
||||
import de.rayzs.pat.plugin.modules.SubArgsModule;
|
||||
import de.rayzs.pat.plugin.process.CommandProcess;
|
||||
import de.rayzs.pat.api.netty.bukkit.BukkitPacketAnalyzer;
|
||||
import de.rayzs.pat.api.communication.BackendUpdater;
|
||||
import de.rayzs.pat.utils.adapter.GroupManagerAdapter;
|
||||
import de.rayzs.pat.plugin.command.commands.ProCommand;
|
||||
import de.rayzs.pat.plugin.system.communication.cph.impl.BukkitCommunicationHandler;
|
||||
import de.rayzs.pat.plugin.system.serverbrand.CustomServerBrand;
|
||||
import de.rayzs.pat.plugin.system.communication.pmc.impl.BukkitPluginMessageClient;
|
||||
import de.rayzs.pat.plugin.system.converter.StorageConverter;
|
||||
import de.rayzs.pat.plugin.system.serverbrand.impl.BukkitServerBrand;
|
||||
import de.rayzs.pat.plugin.command.CommandProcess;
|
||||
import de.rayzs.pat.plugin.packetanalyzer.bukkit.BukkitPacketAnalyzer;
|
||||
import de.rayzs.pat.plugin.system.communication.BackendUpdater;
|
||||
import de.rayzs.pat.plugin.system.subargument.SubArgument;
|
||||
import de.rayzs.pat.utils.group.Group;
|
||||
import de.rayzs.pat.utils.hooks.GroupManagerHook;
|
||||
import de.rayzs.pat.utils.configuration.Configurator;
|
||||
import de.rayzs.pat.utils.configuration.updater.ConfigUpdater;
|
||||
import de.rayzs.pat.utils.group.TinyGroup;
|
||||
import de.rayzs.pat.utils.message.MessageTranslator;
|
||||
import de.rayzs.pat.utils.permission.PermissionUtil;
|
||||
import de.rayzs.pat.utils.adapter.ViaVersionAdapter;
|
||||
import de.rayzs.pat.api.communication.Communicator;
|
||||
import de.rayzs.pat.utils.adapter.LuckPermsAdapter;
|
||||
import de.rayzs.pat.plugin.commands.BukkitCommand;
|
||||
import de.rayzs.pat.utils.hooks.ViaVersionHook;
|
||||
import de.rayzs.pat.plugin.system.communication.Communicator;
|
||||
import de.rayzs.pat.utils.hooks.LuckPermsHook;
|
||||
import de.rayzs.pat.plugin.command.impl.BukkitCommand;
|
||||
import de.rayzs.pat.utils.hooks.PlaceholderHook;
|
||||
import de.rayzs.pat.plugin.listeners.bukkit.*;
|
||||
import de.rayzs.pat.api.event.PATEventHandler;
|
||||
import de.rayzs.pat.utils.group.GroupManager;
|
||||
import de.rayzs.pat.plugin.metrics.bStats;
|
||||
import de.rayzs.pat.plugin.logger.Logger;
|
||||
import de.rayzs.pat.utils.response.ResponseHandler;
|
||||
import de.rayzs.pat.utils.response.action.ActionHandler;
|
||||
import de.rayzs.pat.utils.sender.CommandSender;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.permissions.Permission;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
import de.rayzs.pat.api.storage.Storage;
|
||||
import de.rayzs.pat.utils.scheduler.*;
|
||||
@@ -44,11 +51,15 @@ public class BukkitLoader extends JavaPlugin implements PluginLoader {
|
||||
|
||||
private static Plugin plugin;
|
||||
private static java.util.logging.Logger logger;
|
||||
private static boolean loaded = false, suggestions = false;
|
||||
private static Map<String, Command> commandsMap = null;
|
||||
private PATSchedulerTask updaterTask;
|
||||
|
||||
private final CommandsCache commandsCache = new CommandsCache();
|
||||
private final List<String> offlinePlayerNames = new ArrayList<>();
|
||||
|
||||
private Map<String, Command> commandsMap = null;
|
||||
|
||||
private BukkitAntiTabListener bukkitAntiTabListener = null;
|
||||
|
||||
private PATSchedulerTask updaterTask;
|
||||
private long lastCommandsLoad = -1;
|
||||
|
||||
@Override
|
||||
@@ -70,8 +81,9 @@ public class BukkitLoader extends JavaPlugin implements PluginLoader {
|
||||
|
||||
loadCommandMap();
|
||||
|
||||
CommandProcess.initialize();
|
||||
Reflection.initialize(getServer());
|
||||
|
||||
CommandProcess.initialize();
|
||||
ConfigUpdater.initialize();
|
||||
|
||||
Storage.initialize(this, getDescription().getVersion());
|
||||
@@ -83,61 +95,97 @@ public class BukkitLoader extends JavaPlugin implements PluginLoader {
|
||||
new PlaceholderHook().register();
|
||||
|
||||
MessageTranslator.initialize();
|
||||
CustomServerBrand.initialize();
|
||||
|
||||
Communicator.initialize(new BukkitPluginMessageClient(), new BukkitCommunicationHandler());
|
||||
BackendUpdater.initialize();
|
||||
|
||||
bStats.initialize(this);
|
||||
|
||||
PluginManager manager = getServer().getPluginManager();
|
||||
|
||||
if (!Storage.ConfigSections.Settings.HANDLE_THROUGH_PROXY.ENABLED) {
|
||||
loaded = true;
|
||||
GroupManager.initialize();
|
||||
BukkitPacketAnalyzer.injectAll();
|
||||
} else BackendUpdater.handle();
|
||||
} else BackendUpdater.get().handle();
|
||||
|
||||
manager.registerEvents(new BukkitPlayerListener(), this);
|
||||
manager.registerEvents(new BukkitBlockCommandListener(), this);
|
||||
|
||||
if (Reflection.getMinor() >= 13) {
|
||||
suggestions = true;
|
||||
manager.registerEvents(new BukkitAntiTabListener(), this);
|
||||
if (Reflection.isAtLeast(1, 13)) {
|
||||
bukkitAntiTabListener = new BukkitAntiTabListener();
|
||||
manager.registerEvents(bukkitAntiTabListener, this);
|
||||
}
|
||||
|
||||
if (Reflection.isPaper() && Reflection.getMinor() >= 12)
|
||||
if (Reflection.isPaper() && Reflection.isAtLeast(1, 12)) {
|
||||
manager.registerEvents(new PaperServerListPing(), this);
|
||||
}
|
||||
|
||||
registerCommand("proantitab", "pat");
|
||||
startUpdaterTask();
|
||||
|
||||
Storage.PLUGIN_OBJECT = this;
|
||||
|
||||
if (getServer().getPluginManager().getPlugin("LuckPerms") != null) {
|
||||
LuckPermsAdapter.initialize();
|
||||
LuckPermsHook.initialize();
|
||||
Bukkit.getOnlinePlayers().forEach(player -> PermissionUtil.setPlayerPermissions(player.getUniqueId()));
|
||||
} else {
|
||||
final Plugin groupManagerPlugin = getServer().getPluginManager().getPlugin("GroupManager");
|
||||
if (groupManagerPlugin != null) {
|
||||
GroupManagerHook.initialize(groupManagerPlugin);
|
||||
Bukkit.getOnlinePlayers().forEach(player -> PermissionUtil.setPlayerPermissions(player.getUniqueId()));
|
||||
}
|
||||
}
|
||||
|
||||
final Plugin groupManagerPlugin = getServer().getPluginManager().getPlugin("GroupManager");
|
||||
if (groupManagerPlugin != null) {
|
||||
GroupManagerAdapter.initialize(groupManagerPlugin);
|
||||
Bukkit.getOnlinePlayers().forEach(player -> PermissionUtil.setPlayerPermissions(player.getUniqueId()));
|
||||
}
|
||||
|
||||
if (getServer().getPluginManager().getPlugin("ViaVersion") != null)
|
||||
ViaVersionAdapter.initialize();
|
||||
|
||||
if (Storage.USE_SIMPLECLOUD) {
|
||||
Logger.warning("Detected SimpleCloud. Therefore, MiniMessages are disabled!");
|
||||
if (getServer().getPluginManager().getPlugin("ViaVersion") != null) {
|
||||
ViaVersionHook.initialize();
|
||||
}
|
||||
|
||||
Storage.broadcastPermissionsPluginNotice();
|
||||
ConfigUpdater.broadcastMissingParts();
|
||||
ActionHandler.initialize();
|
||||
SubArgsModule.initialize();
|
||||
|
||||
PATScheduler.createScheduler(this::loadAllCommands);
|
||||
ActionHandler.initialize();
|
||||
SubArgument.initialize();
|
||||
|
||||
ResponseHandler.update();
|
||||
|
||||
StorageConverter.initialize();
|
||||
|
||||
CustomServerBrand.initialize(new BukkitServerBrand());
|
||||
|
||||
PATScheduler.createScheduler(() -> {
|
||||
Storage.reload();
|
||||
loadAllCommands();
|
||||
});
|
||||
|
||||
|
||||
for (final ProCommand command : CommandProcess.getCommands()) {
|
||||
addPermission(command.getName());
|
||||
}
|
||||
|
||||
for (final Group group : GroupManager.getGroups()) {
|
||||
addPermission("group." + group.getGroupName());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addPermission(String permission) {
|
||||
permission = "proantitab." + permission;
|
||||
|
||||
final PluginManager manager = getServer().getPluginManager();
|
||||
if (manager.getPermission(permission) == null) {
|
||||
manager.addPermission(new Permission(permission));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removePermission(String permission) {
|
||||
final PluginManager manager = getServer().getPluginManager();
|
||||
final Permission perm = manager.getPermission("proantitab." + permission);
|
||||
|
||||
if (perm != null) manager.removePermission(perm);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDisable() {
|
||||
BackendUpdater.stop();
|
||||
BackendUpdater.get().stop();
|
||||
BukkitPacketAnalyzer.uninjectAll();
|
||||
MessageTranslator.closeAudiences();
|
||||
}
|
||||
@@ -151,6 +199,30 @@ public class BukkitLoader extends JavaPlugin implements PluginLoader {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getPluginObj() {
|
||||
return plugin;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateCommands() {
|
||||
if (bukkitAntiTabListener == null) return;
|
||||
|
||||
Bukkit.getOnlinePlayers().forEach(player -> {
|
||||
bukkitAntiTabListener.updateCommands(player);
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateCommands(CommandSender sender) {
|
||||
final Player player = Bukkit.getPlayer(sender.getUniqueId());
|
||||
|
||||
if (bukkitAntiTabListener != null) {
|
||||
assert player != null;
|
||||
bukkitAntiTabListener.updateCommands(player);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleReload() {
|
||||
loadAllCommands();
|
||||
@@ -182,13 +254,20 @@ public class BukkitLoader extends JavaPlugin implements PluginLoader {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateCommandCache() {}
|
||||
public void resetCommandsCache() {
|
||||
commandsCache.reset();
|
||||
}
|
||||
|
||||
@Override
|
||||
public HashMap<String, CommandsCache> getCommandsCacheMap() {
|
||||
public HashMap<String, CommandsCache> getPerServerCommandsCacheMap() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommandsCache getBukkitCommandsCacheMap() {
|
||||
return commandsCache;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPlayerOnline(String playerName) {
|
||||
return Bukkit.getPlayer(playerName) != null;
|
||||
@@ -201,7 +280,10 @@ public class BukkitLoader extends JavaPlugin implements PluginLoader {
|
||||
|
||||
@Override
|
||||
public String getPlayerServerName(UUID uuid) {
|
||||
return null;
|
||||
final Player player = Bukkit.getPlayer(uuid);
|
||||
if (player == null) { return null; }
|
||||
|
||||
return player.getWorld().getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -255,12 +337,16 @@ public class BukkitLoader extends JavaPlugin implements PluginLoader {
|
||||
return List.of();
|
||||
}
|
||||
|
||||
public static void delayedPermissionsReload() {
|
||||
@Override
|
||||
public void delayedPermissionsReload() {
|
||||
PATScheduler.createScheduler(PermissionUtil::reloadPermissions, 40);
|
||||
}
|
||||
|
||||
public static void userPermissionsReload(UUID uuid) {
|
||||
Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(BukkitLoader.getPlugin(), () -> PermissionUtil.reloadPermissions(uuid));
|
||||
@Override
|
||||
public void delayedPermissionsReload(CommandSender sender) {
|
||||
PATScheduler.createScheduler(() -> {
|
||||
PermissionUtil.reloadPermissions(sender);
|
||||
}, 40);
|
||||
}
|
||||
|
||||
public void startUpdaterTask() {
|
||||
@@ -275,75 +361,6 @@ public class BukkitLoader extends JavaPlugin implements PluginLoader {
|
||||
}, 20L, 20L * Storage.ConfigSections.Settings.UPDATE.PERIOD);
|
||||
}
|
||||
|
||||
public static void synchronize(CommunicationPackets.PacketBundle packetBundle) {
|
||||
Storage.LAST_SYNC = System.currentTimeMillis();
|
||||
Communicator.sendFeedback();
|
||||
|
||||
CommunicationPackets.UnknownCommandPacket unknownCommandPacket = packetBundle.getUnknownCommandPacket();
|
||||
CommunicationPackets.CommandsPacket commandsPacket = packetBundle.getCommandsPacket();
|
||||
CommunicationPackets.GroupsPacket groupsPacket = packetBundle.getGroupsPacket();
|
||||
CommunicationPackets.NamespaceCommandsPacket namespaceCommandsPacket = packetBundle.getNamespaceCommandsPacket();
|
||||
CommunicationPackets.MessagePacket messagePacket = packetBundle.getMessagePacket();
|
||||
|
||||
boolean updatedList = false;
|
||||
|
||||
if (!messagePacket.getBaseBlockedMessage().getLines().isEmpty())
|
||||
Storage.ConfigSections.Settings.CANCEL_COMMAND.BASE_COMMAND_RESPONSE = messagePacket.getBaseBlockedMessage();
|
||||
|
||||
if (!messagePacket.getSubBlockedMessage().getLines().isEmpty())
|
||||
Storage.ConfigSections.Settings.CANCEL_COMMAND.SUB_COMMAND_RESPONSE = messagePacket.getSubBlockedMessage();
|
||||
|
||||
if (!messagePacket.getPrefix().isEmpty())
|
||||
Storage.ConfigSections.Messages.PREFIX.PREFIX = messagePacket.getPrefix();
|
||||
|
||||
if (Storage.ConfigSections.Settings.BLOCK_NAMESPACE_COMMANDS.ENABLED != namespaceCommandsPacket.isEnabled())
|
||||
Storage.ConfigSections.Settings.BLOCK_NAMESPACE_COMMANDS.ENABLED = namespaceCommandsPacket.isEnabled();
|
||||
|
||||
if (commandsPacket.getCommands() == null || commandsPacket.getCommands().isEmpty())
|
||||
Storage.Blacklist.getBlacklist().setList(new ArrayList<>());
|
||||
|
||||
else if (!ArrayUtils.compareStringArrays(Storage.Blacklist.getBlacklist().getCommands(), commandsPacket.getCommands())) {
|
||||
updatedList = true;
|
||||
Storage.Blacklist.getBlacklist().setList(commandsPacket.getCommands());
|
||||
}
|
||||
|
||||
if (Storage.ConfigSections.Settings.TURN_BLACKLIST_TO_WHITELIST.ENABLED != commandsPacket.turnBlacklistToWhitelistEnabled())
|
||||
Storage.ConfigSections.Settings.TURN_BLACKLIST_TO_WHITELIST.ENABLED = commandsPacket.turnBlacklistToWhitelistEnabled();
|
||||
|
||||
Map<String, List<String>> cpyCache = new HashMap<>();
|
||||
GroupManager.getGroups().forEach(group -> {
|
||||
cpyCache.put(group.getGroupName(), group.getCommands());
|
||||
});
|
||||
|
||||
GroupManager.clearAllGroups();
|
||||
|
||||
for (TinyGroup group : groupsPacket.getGroups()) {
|
||||
List<String> currentExistingList = cpyCache.get(group.getGroupName());
|
||||
if (
|
||||
!updatedList
|
||||
&& currentExistingList != null
|
||||
&& !ArrayUtils.compareStringArrays(currentExistingList, group.getCommands())
|
||||
) {
|
||||
updatedList = true;
|
||||
}
|
||||
|
||||
GroupManager.setGroup(group.getGroupName(), group.getPriority(), group.getCommands());
|
||||
}
|
||||
|
||||
Storage.ConfigSections.Settings.CUSTOM_UNKNOWN_COMMAND.MESSAGE = unknownCommandPacket.getMessage();
|
||||
if (Storage.ConfigSections.Settings.CUSTOM_UNKNOWN_COMMAND.ENABLED != unknownCommandPacket.isEnabled())
|
||||
Storage.ConfigSections.Settings.CUSTOM_UNKNOWN_COMMAND.ENABLED = unknownCommandPacket.isEnabled();
|
||||
|
||||
if (!loaded)
|
||||
loaded = true;
|
||||
|
||||
if (Reflection.getMinor() >= 13 && updatedList) {
|
||||
BukkitAntiTabListener.updateCommands();
|
||||
}
|
||||
|
||||
PATEventHandler.callReceiveSyncEvents(packetBundle);
|
||||
}
|
||||
|
||||
public static List<String> getAllCommands() {
|
||||
return new ArrayList<>(commands);
|
||||
}
|
||||
@@ -357,17 +374,63 @@ public class BukkitLoader extends JavaPlugin implements PluginLoader {
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getPluginNames() {
|
||||
public List<String> getFormattedPluginNames(String format) {
|
||||
List<String> pluginNames = new ArrayList<>();
|
||||
|
||||
for (Plugin plugin : Bukkit.getPluginManager().getPlugins()) {
|
||||
PluginDescriptionFile description = plugin.getDescription();
|
||||
pluginNames.add(description.getName() + " (" + description.getVersion() + ")");
|
||||
|
||||
pluginNames.add(
|
||||
format.replace("%n", description.getName())
|
||||
.replace("%v", description.getVersion())
|
||||
);
|
||||
}
|
||||
|
||||
return pluginNames;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getAllCommands(boolean useColons) {
|
||||
List<String> commands = new ArrayList<>();
|
||||
|
||||
for (Map.Entry<String, Command> entry : commandsMap.entrySet()) {
|
||||
if (entry.getKey().toLowerCase().contains(":")) {
|
||||
String command = entry.getKey().substring(entry.getKey().lastIndexOf(":") + 1);
|
||||
|
||||
commands.add(command);
|
||||
|
||||
if (useColons) {
|
||||
commands.add(entry.getKey());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return commands;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getPluginCommands(String pluginName, boolean useColons) {
|
||||
List<String> commands = new ArrayList<>();
|
||||
|
||||
if (pluginName.isBlank()) return commands;
|
||||
|
||||
pluginName = pluginName.toLowerCase();
|
||||
|
||||
for (Map.Entry<String, Command> entry : commandsMap.entrySet()) {
|
||||
if (entry.getKey().toLowerCase().startsWith(pluginName + ":")) {
|
||||
String command = entry.getKey().substring(pluginName.length() + 1);
|
||||
|
||||
commands.add(command);
|
||||
|
||||
if (useColons) {
|
||||
commands.add(entry.getKey());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return commands;
|
||||
}
|
||||
|
||||
private void loadCommandMap() {
|
||||
try {
|
||||
if (Bukkit.getPluginManager() instanceof SimplePluginManager) {
|
||||
@@ -432,10 +495,6 @@ public class BukkitLoader extends JavaPlugin implements PluginLoader {
|
||||
BukkitLoader.disallowedCommands = commands.stream().filter(command -> !allowedCommands.contains(command)).toList();
|
||||
}
|
||||
|
||||
public static boolean useSuggestions() {
|
||||
return suggestions;
|
||||
}
|
||||
|
||||
public static Plugin getPlugin() {
|
||||
return plugin;
|
||||
}
|
||||
@@ -443,8 +502,4 @@ public class BukkitLoader extends JavaPlugin implements PluginLoader {
|
||||
public static java.util.logging.Logger getPluginLogger() {
|
||||
return logger;
|
||||
}
|
||||
|
||||
public static boolean isLoaded() {
|
||||
return loaded;
|
||||
}
|
||||
}
|
||||
@@ -1,18 +1,25 @@
|
||||
package de.rayzs.pat.plugin;
|
||||
|
||||
|
||||
import de.rayzs.pat.api.brand.CustomServerBrand;
|
||||
import de.rayzs.pat.plugin.process.CommandProcess;
|
||||
import de.rayzs.pat.plugin.modules.SubArgsModule;
|
||||
import de.rayzs.pat.api.netty.proxy.BungeePacketAnalyzer;
|
||||
import de.rayzs.pat.plugin.system.communication.cph.impl.BungeeCommunicationHandler;
|
||||
import de.rayzs.pat.plugin.system.serverbrand.CustomServerBrand;
|
||||
import de.rayzs.pat.plugin.system.communication.pmc.impl.BungeePluginMessageClient;
|
||||
import de.rayzs.pat.plugin.system.converter.StorageConverter;
|
||||
import de.rayzs.pat.plugin.command.CommandProcess;
|
||||
import de.rayzs.pat.plugin.system.serverbrand.impl.BungeeServerBrand;
|
||||
import de.rayzs.pat.plugin.packetanalyzer.proxy.BungeePacketAnalyzer;
|
||||
import de.rayzs.pat.plugin.system.subargument.SubArgument;
|
||||
import de.rayzs.pat.utils.configuration.Configurator;
|
||||
import de.rayzs.pat.utils.configuration.updater.ConfigUpdater;
|
||||
import de.rayzs.pat.utils.message.MessageTranslator;
|
||||
import de.rayzs.pat.utils.adapter.LuckPermsAdapter;
|
||||
import de.rayzs.pat.api.communication.Communicator;
|
||||
import de.rayzs.pat.utils.hooks.LuckPermsHook;
|
||||
import de.rayzs.pat.plugin.system.communication.Communicator;
|
||||
import de.rayzs.pat.utils.permission.PermissionUtil;
|
||||
import de.rayzs.pat.utils.response.ResponseHandler;
|
||||
import de.rayzs.pat.utils.response.action.ActionHandler;
|
||||
import de.rayzs.pat.utils.sender.CommandSender;
|
||||
import net.md_5.bungee.api.scheduler.ScheduledTask;
|
||||
import de.rayzs.pat.plugin.commands.BungeeCommand;
|
||||
import de.rayzs.pat.plugin.command.impl.BungeeCommand;
|
||||
import de.rayzs.pat.plugin.listeners.bungee.*;
|
||||
import de.rayzs.pat.utils.group.GroupManager;
|
||||
import net.md_5.bungee.api.config.ServerInfo;
|
||||
@@ -48,11 +55,10 @@ public class BungeeLoader extends Plugin implements PluginLoader {
|
||||
plugin = this;
|
||||
logger = getLogger();
|
||||
|
||||
CommandProcess.initialize();
|
||||
Reflection.initialize(getProxy());
|
||||
ConfigUpdater.initialize();
|
||||
|
||||
Storage.USE_SIMPLECLOUD = Reflection.doesClassExist("eu.thesimplecloud.plugin.startup.CloudPlugin");
|
||||
CommandProcess.initialize();
|
||||
ConfigUpdater.initialize();
|
||||
|
||||
Storage.initialize(this, getDescription().getVersion());
|
||||
VersionComparer.get().setCurrentVersion(Storage.CURRENT_VERSION);
|
||||
@@ -60,8 +66,8 @@ public class BungeeLoader extends Plugin implements PluginLoader {
|
||||
Storage.loadAll(true);
|
||||
|
||||
MessageTranslator.initialize();
|
||||
CustomServerBrand.initialize();
|
||||
GroupManager.initialize();
|
||||
|
||||
bStats.initialize(this);
|
||||
PluginManager manager = ProxyServer.getInstance().getPluginManager();
|
||||
|
||||
@@ -77,31 +83,35 @@ public class BungeeLoader extends Plugin implements PluginLoader {
|
||||
|
||||
startUpdaterTask();
|
||||
|
||||
if (!Storage.ConfigSections.Settings.DISABLE_SYNC.DISABLED)
|
||||
ProxyServer.getInstance().getScheduler().schedule(this, Communicator::syncData, 5, TimeUnit.SECONDS);
|
||||
|
||||
Storage.PLUGIN_OBJECT = this;
|
||||
|
||||
if (manager.getPlugin("LuckPerms") != null)
|
||||
LuckPermsAdapter.initialize();
|
||||
LuckPermsHook.initialize();
|
||||
|
||||
if(manager.getPlugin("PAPIProxyBridge") != null) {
|
||||
Storage.USE_PAPIPROXYBRIDGE = true;
|
||||
Logger.info("Successfully hooked into PAPIProxyBridge!");
|
||||
}
|
||||
|
||||
if(Storage.USE_SIMPLECLOUD)
|
||||
Logger.warning("Detected SimpleCloud and therefore MiniMessages by Kyori are disabled!");
|
||||
|
||||
BungeePacketAnalyzer.injectAll();
|
||||
|
||||
Storage.broadcastPermissionsPluginNotice();
|
||||
ConfigUpdater.broadcastMissingParts();
|
||||
|
||||
ActionHandler.initialize();
|
||||
SubArgsModule.initialize();
|
||||
SubArgument.initialize();
|
||||
|
||||
ResponseHandler.update();
|
||||
|
||||
StorageConverter.initialize();
|
||||
|
||||
CustomServerBrand.initialize(new BungeeServerBrand());
|
||||
Communicator.initialize(new BungeePluginMessageClient(), new BungeeCommunicationHandler());
|
||||
|
||||
// Reload proxy commands after 1, 5, and 15 seconds.
|
||||
for (int i : new Integer[] { 1, 5, 15 }) {
|
||||
ProxyServer.getInstance().getScheduler().schedule(this, BungeePacketAnalyzer::loadProxyCommands, i, TimeUnit.SECONDS);
|
||||
}
|
||||
|
||||
BungeePacketAnalyzer.injectAll();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -117,16 +127,60 @@ public class BungeeLoader extends Plugin implements PluginLoader {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addPermission(String permission) {}
|
||||
|
||||
@Override
|
||||
public void removePermission(String permission) {}
|
||||
|
||||
@Override
|
||||
public Object getPluginObj() {
|
||||
return plugin;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateCommands() {
|
||||
Communicator.Proxy2Backend.sendUpdateCommand();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateCommands(CommandSender sender) {
|
||||
Communicator.Proxy2Backend.sendUpdateCommand(sender.getUniqueId(), sender.getServerName());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleReload() {
|
||||
BungeePacketAnalyzer.loadProxyCommands();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void delayedPermissionsReload() {
|
||||
getProxy().getScheduler().schedule(this, () -> {
|
||||
PermissionUtil.reloadPermissions();
|
||||
Storage.getLoader().resetCommandsCache();
|
||||
|
||||
Communicator.Proxy2Backend.sendUpdateCommand();
|
||||
}, 1, TimeUnit.SECONDS);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void delayedPermissionsReload(CommandSender sender) {
|
||||
getProxy().getScheduler().schedule(this, () -> {
|
||||
PermissionUtil.reloadPermissions(sender.getUniqueId());
|
||||
Communicator.Proxy2Backend.sendUpdateCommand(sender.getUniqueId(), sender.getServerName());
|
||||
}, 1, TimeUnit.SECONDS);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean doesCommandExist(String command) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getAllCommands(boolean useColons) {
|
||||
return List.of();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getConsoleSender() {
|
||||
return ProxyServer.getInstance().getConsole();
|
||||
@@ -143,21 +197,32 @@ public class BungeeLoader extends Plugin implements PluginLoader {
|
||||
}
|
||||
|
||||
@Override
|
||||
public HashMap<String, CommandsCache> getCommandsCacheMap() {
|
||||
public HashMap<String, CommandsCache> getPerServerCommandsCacheMap() {
|
||||
return commandsCacheMap;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateCommandCache() {
|
||||
public CommandsCache getBukkitCommandsCacheMap() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void resetCommandsCache() {
|
||||
new ArrayList<>(commandsCacheMap.values()).forEach(CommandsCache::reset);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPlayerServerName(UUID uuid) {
|
||||
final String cachedServerName = Storage.getCachedPlayerServername(uuid);
|
||||
if (cachedServerName != null) {
|
||||
return cachedServerName;
|
||||
}
|
||||
|
||||
ProxiedPlayer player = ProxyServer.getInstance().getPlayer(uuid);
|
||||
|
||||
if (player == null || player.getServer() == null || player.getServer().getInfo() == null)
|
||||
if (player == null || player.getServer() == null || player.getServer().getInfo() == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return player.getServer().getInfo().getName();
|
||||
}
|
||||
@@ -240,17 +305,26 @@ public class BungeeLoader extends Plugin implements PluginLoader {
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getPluginNames() {
|
||||
public List<String> getFormattedPluginNames(String format) {
|
||||
List<String> pluginNames = new ArrayList<>();
|
||||
|
||||
for (Plugin plugin : ProxyServer.getInstance().getPluginManager().getPlugins()) {
|
||||
PluginDescription description = plugin.getDescription();
|
||||
pluginNames.add(description.getName() + " (" + description.getVersion() + ")");
|
||||
|
||||
pluginNames.add(
|
||||
format.replace("%n", description.getName())
|
||||
.replace("%v", description.getVersion())
|
||||
);
|
||||
}
|
||||
|
||||
return pluginNames;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getPluginCommands(String pluginName, boolean useColons) {
|
||||
return List.of();
|
||||
}
|
||||
|
||||
public void startUpdaterTask() {
|
||||
if (!Storage.ConfigSections.Settings.UPDATE.ENABLED)
|
||||
return;
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package de.rayzs.pat.plugin;
|
||||
|
||||
import de.rayzs.pat.utils.CommandsCache;
|
||||
import de.rayzs.pat.utils.sender.CommandSender;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
@@ -8,12 +9,36 @@ import java.util.UUID;
|
||||
|
||||
public interface PluginLoader {
|
||||
|
||||
void addPermission(String permission);
|
||||
void removePermission(String permission);
|
||||
|
||||
Object getPluginObj();
|
||||
|
||||
void handleReload();
|
||||
boolean doesCommandExist(String command);
|
||||
|
||||
HashMap<String, CommandsCache> getCommandsCacheMap();
|
||||
/**
|
||||
* Updates commands for all players.
|
||||
* Requires PAT sync on proxy for it to work!
|
||||
* Non-proxy servers do not require anything additionally.
|
||||
*/
|
||||
void updateCommands();
|
||||
|
||||
void updateCommandCache();
|
||||
/**
|
||||
* Updates commands for a certain player.
|
||||
* Requires PAT sync on proxy for it to work!
|
||||
* Non-proxy servers do not require anything additionally.
|
||||
*/
|
||||
void updateCommands(CommandSender sender);
|
||||
|
||||
HashMap<String, CommandsCache> getPerServerCommandsCacheMap();
|
||||
CommandsCache getBukkitCommandsCacheMap();
|
||||
|
||||
void delayedPermissionsReload();
|
||||
|
||||
void delayedPermissionsReload(CommandSender sender);
|
||||
|
||||
void resetCommandsCache();
|
||||
|
||||
List<String> getServerNames();
|
||||
|
||||
@@ -39,5 +64,14 @@ public interface PluginLoader {
|
||||
List<String> getOnlinePlayerNames();
|
||||
List<String> getOfflinePlayerNames();
|
||||
|
||||
List<String> getPluginNames();
|
||||
List<String> getAllCommands(boolean useColons);
|
||||
List<String> getPluginCommands(String pluginName, boolean useColons);
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* %n = Plugin name
|
||||
* %v = Plugin version
|
||||
* </pre>
|
||||
*/
|
||||
List<String> getFormattedPluginNames(String format);
|
||||
}
|
||||
@@ -4,20 +4,24 @@ import com.velocitypowered.api.event.proxy.ProxyInitializeEvent;
|
||||
import com.velocitypowered.api.proxy.Player;
|
||||
import com.velocitypowered.api.proxy.ServerConnection;
|
||||
import com.velocitypowered.api.proxy.server.RegisteredServer;
|
||||
import de.rayzs.pat.api.brand.CustomServerBrand;
|
||||
import de.rayzs.pat.api.event.PATEventHandler;
|
||||
import de.rayzs.pat.plugin.modules.SubArgsModule;
|
||||
import de.rayzs.pat.plugin.process.CommandProcess;
|
||||
import de.rayzs.pat.plugin.system.communication.cph.impl.VelocityCommunicationHandler;
|
||||
import de.rayzs.pat.plugin.system.serverbrand.CustomServerBrand;
|
||||
import de.rayzs.pat.plugin.system.communication.pmc.impl.VelocityPluginMessageClient;
|
||||
import de.rayzs.pat.plugin.packetanalyzer.proxy.VelocityPacketAnalyzer;
|
||||
import de.rayzs.pat.plugin.system.converter.StorageConverter;
|
||||
import de.rayzs.pat.plugin.system.serverbrand.impl.VelocityServerBrand;
|
||||
import de.rayzs.pat.plugin.command.CommandProcess;
|
||||
import de.rayzs.pat.plugin.system.subargument.SubArgument;
|
||||
import de.rayzs.pat.utils.CommandsCache;
|
||||
import de.rayzs.pat.plugin.metrics.impl.VelocityMetrics;
|
||||
import com.velocitypowered.api.scheduler.ScheduledTask;
|
||||
import de.rayzs.pat.utils.configuration.Configurator;
|
||||
import de.rayzs.pat.utils.configuration.updater.ConfigUpdater;
|
||||
import de.rayzs.pat.utils.permission.PermissionUtil;
|
||||
import de.rayzs.pat.plugin.commands.VelocityCommand;
|
||||
import de.rayzs.pat.plugin.command.impl.VelocityCommand;
|
||||
import de.rayzs.pat.utils.message.MessageTranslator;
|
||||
import de.rayzs.pat.api.communication.Communicator;
|
||||
import de.rayzs.pat.utils.adapter.LuckPermsAdapter;
|
||||
import de.rayzs.pat.plugin.system.communication.Communicator;
|
||||
import de.rayzs.pat.utils.hooks.LuckPermsHook;
|
||||
import com.velocitypowered.api.proxy.ProxyServer;
|
||||
import de.rayzs.pat.plugin.listeners.velocity.*;
|
||||
import de.rayzs.pat.utils.group.GroupManager;
|
||||
@@ -31,15 +35,17 @@ import java.util.concurrent.TimeUnit;
|
||||
|
||||
|
||||
import com.google.inject.Inject;
|
||||
import de.rayzs.pat.utils.response.ResponseHandler;
|
||||
import de.rayzs.pat.utils.response.action.ActionHandler;
|
||||
import de.rayzs.pat.utils.sender.CommandSender;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
@Plugin(name = "ProAntiTab",
|
||||
id = "proantitab",
|
||||
version = "2.0.21",
|
||||
version = "2.3.4",
|
||||
authors = "Rayzs_YT",
|
||||
description = "Hide more than just your plugins. Hide almost everything!",
|
||||
description = "Hides more than just your plugins.",
|
||||
url = "https://www.rayzs.de/products/proantitab/page",
|
||||
dependencies = {
|
||||
@Dependency(id = "luckperms", optional = true),
|
||||
@@ -77,17 +83,16 @@ public class VelocityLoader implements PluginLoader {
|
||||
Configurator.createResourcedFile("files\\proxy-placeholders.yml", "placeholders.yml", false);
|
||||
Configurator.createResourcedFile("files\\proxy-custom-responses.yml", "custom-responses.yml", false);
|
||||
|
||||
CommandProcess.initialize();
|
||||
Reflection.initialize(server);
|
||||
|
||||
CommandProcess.initialize();
|
||||
ConfigUpdater.initialize();
|
||||
|
||||
Storage.USE_SIMPLECLOUD = Reflection.doesClassExist("eu.thesimplecloud.plugin.startup.CloudPlugin");
|
||||
Storage.initialize(this, pluginContainer.getDescription().getVersion().get());
|
||||
VersionComparer.get().setCurrentVersion(Storage.CURRENT_VERSION);
|
||||
|
||||
Storage.loadAll(true);
|
||||
MessageTranslator.initialize();
|
||||
CustomServerBrand.initialize();
|
||||
GroupManager.initialize();
|
||||
|
||||
metricsFactory.make(this, 21638);
|
||||
@@ -100,46 +105,71 @@ public class VelocityLoader implements PluginLoader {
|
||||
|
||||
startUpdaterTask();
|
||||
|
||||
if (!Storage.ConfigSections.Settings.DISABLE_SYNC.DISABLED)
|
||||
server.getScheduler().buildTask(this, Communicator::syncData).delay(5, TimeUnit.SECONDS).schedule();
|
||||
|
||||
Storage.PLUGIN_OBJECT = this;
|
||||
|
||||
if (server.getPluginManager().getPlugin("luckperms").isPresent())
|
||||
LuckPermsAdapter.initialize();
|
||||
LuckPermsHook.initialize();
|
||||
|
||||
if (server.getPluginManager().getPlugin("papiproxybridge").isPresent()) {
|
||||
Storage.USE_PAPIPROXYBRIDGE = true;
|
||||
Logger.info("Successfully hooked into PAPIProxyBridge!");
|
||||
}
|
||||
|
||||
if(Storage.USE_SIMPLECLOUD)
|
||||
Logger.warning("Detected SimpleCloud and therefore MiniMessages by Kyori are disabled!");
|
||||
|
||||
Storage.broadcastPermissionsPluginNotice();
|
||||
ConfigUpdater.broadcastMissingParts();
|
||||
|
||||
ActionHandler.initialize();
|
||||
SubArgsModule.initialize();
|
||||
SubArgument.initialize();
|
||||
|
||||
ResponseHandler.update();
|
||||
|
||||
StorageConverter.initialize();
|
||||
CustomServerBrand.initialize(new VelocityServerBrand());
|
||||
|
||||
Communicator.initialize(new VelocityPluginMessageClient(), new VelocityCommunicationHandler());
|
||||
|
||||
VelocityPacketAnalyzer.injectAll();
|
||||
}
|
||||
|
||||
public static org.slf4j.Logger getPluginLogger() {
|
||||
return logger;
|
||||
}
|
||||
|
||||
public static void delayedPermissionsReload() {
|
||||
@Override
|
||||
public void addPermission(String permission) {}
|
||||
|
||||
@Override
|
||||
public void removePermission(String permission) {}
|
||||
|
||||
@Override
|
||||
public Object getPluginObj() {
|
||||
return instance;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateCommands() {
|
||||
Communicator.Proxy2Backend.sendUpdateCommand();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateCommands(CommandSender sender) {
|
||||
Communicator.Proxy2Backend.sendUpdateCommand(sender.getUniqueId(), sender.getServerName());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void delayedPermissionsReload() {
|
||||
server.getScheduler().buildTask(VelocityLoader.instance, () -> {
|
||||
PermissionUtil.reloadPermissions();
|
||||
Storage.getLoader().updateCommandCache();
|
||||
resetCommandsCache();
|
||||
|
||||
Communicator.Proxy2Backend.sendUpdateCommand();
|
||||
}).delay(1, TimeUnit.SECONDS).schedule();
|
||||
}
|
||||
|
||||
public static void delayedPlayerReload(UUID uuid) {
|
||||
@Override
|
||||
public void delayedPermissionsReload(CommandSender sender) {
|
||||
server.getScheduler().buildTask(VelocityLoader.instance, () -> {
|
||||
String serverName = Storage.getLoader().getPlayerServerName(uuid);
|
||||
List<String> commands = new ArrayList<>(SubArgsModule.getServerCommands(serverName));
|
||||
PermissionUtil.reloadPermissions(sender);
|
||||
|
||||
commands.addAll(SubArgsModule.getGroupCommands(uuid, serverName));
|
||||
|
||||
PATEventHandler.callUpdatePlayerCommandsEvents(uuid, commands, true);
|
||||
Communicator.Proxy2Backend.sendUpdateCommand(sender.getUniqueId(), sender.getServerName());
|
||||
}).delay(1, TimeUnit.SECONDS).schedule();
|
||||
}
|
||||
|
||||
@@ -151,6 +181,11 @@ public class VelocityLoader implements PluginLoader {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getAllCommands(boolean useColons) {
|
||||
return List.of();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getConsoleSender() {
|
||||
return server.getConsoleCommandSource();
|
||||
@@ -167,15 +202,20 @@ public class VelocityLoader implements PluginLoader {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateCommandCache() {
|
||||
public void resetCommandsCache() {
|
||||
new ArrayList<>(commandsCacheMap.values()).forEach(CommandsCache::reset);
|
||||
}
|
||||
|
||||
@Override
|
||||
public HashMap<String, CommandsCache> getCommandsCacheMap() {
|
||||
public HashMap<String, CommandsCache> getPerServerCommandsCacheMap() {
|
||||
return commandsCacheMap;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommandsCache getBukkitCommandsCacheMap() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPlayerOnline(String playerName) {
|
||||
return server.getPlayer(playerName).isPresent();
|
||||
@@ -207,6 +247,11 @@ public class VelocityLoader implements PluginLoader {
|
||||
|
||||
@Override
|
||||
public String getPlayerServerName(UUID uuid) {
|
||||
final String cachedServerName = Storage.getCachedPlayerServername(uuid);
|
||||
if (cachedServerName != null) {
|
||||
return cachedServerName;
|
||||
}
|
||||
|
||||
Optional<Player> optPlayer = server.getPlayer(uuid);
|
||||
|
||||
if (optPlayer.isEmpty())
|
||||
@@ -215,8 +260,9 @@ public class VelocityLoader implements PluginLoader {
|
||||
Player player = optPlayer.get();
|
||||
Optional<ServerConnection> optConnection = player.getCurrentServer();
|
||||
|
||||
if (optConnection.isEmpty())
|
||||
if (optConnection.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
ServerConnection connection = optConnection.get();
|
||||
return connection.getServer().getServerInfo().getName();
|
||||
@@ -274,7 +320,7 @@ public class VelocityLoader implements PluginLoader {
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getPluginNames() {
|
||||
public List<String> getFormattedPluginNames(String format) {
|
||||
List<String> pluginNames = new ArrayList<>();
|
||||
for (PluginContainer plugin : server.getPluginManager().getPlugins()) {
|
||||
PluginDescription description = plugin.getDescription();
|
||||
@@ -282,12 +328,20 @@ public class VelocityLoader implements PluginLoader {
|
||||
String pluginName = description.getName().orElse("/");
|
||||
String version = description.getVersion().orElse("/");
|
||||
|
||||
pluginNames.add(pluginName + " (" + version + ")");
|
||||
pluginNames.add(
|
||||
format.replace("%n", pluginName)
|
||||
.replace("%v", version)
|
||||
);
|
||||
}
|
||||
|
||||
return pluginNames;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getPluginCommands(String pluginName, boolean useColons) {
|
||||
return List.of();
|
||||
}
|
||||
|
||||
public void startUpdaterTask() {
|
||||
if (!Storage.ConfigSections.Settings.UPDATE.ENABLED) return;
|
||||
|
||||
|
||||
+261
-250
@@ -1,250 +1,261 @@
|
||||
package de.rayzs.pat.plugin.process;
|
||||
|
||||
import de.rayzs.pat.api.command.ProCommand;
|
||||
import de.rayzs.pat.plugin.process.impl.local.info.*;
|
||||
import de.rayzs.pat.plugin.process.impl.local.modify.*;
|
||||
import de.rayzs.pat.plugin.process.impl.local.modify.list.ListCommand;
|
||||
import de.rayzs.pat.plugin.process.impl.local.modify.list.ListGroupsCommand;
|
||||
import de.rayzs.pat.plugin.process.impl.local.modify.list.ListPrioritiesCommand;
|
||||
import de.rayzs.pat.plugin.process.impl.local.system.NotifyCommand;
|
||||
import de.rayzs.pat.plugin.process.impl.local.system.PostDebugCommand;
|
||||
import de.rayzs.pat.plugin.process.impl.local.system.ReloadCommand;
|
||||
import de.rayzs.pat.plugin.process.impl.local.system.UpdateCommand;
|
||||
import de.rayzs.pat.plugin.process.impl.server.ServAddCommand;
|
||||
import de.rayzs.pat.plugin.process.impl.server.ServClearCommand;
|
||||
import de.rayzs.pat.plugin.process.impl.server.ServRemoveCommand;
|
||||
import de.rayzs.pat.plugin.process.impl.server.list.ServListCommand;
|
||||
import de.rayzs.pat.utils.permission.PermissionUtil;
|
||||
import de.rayzs.pat.api.storage.Storage;
|
||||
|
||||
import de.rayzs.pat.utils.*;
|
||||
import de.rayzs.pat.utils.sender.CommandSender;
|
||||
import de.rayzs.pat.utils.sender.CommandSenderHandler;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
public class CommandProcess {
|
||||
|
||||
private static final List<ProCommand> COMMANDS = new ArrayList<>();
|
||||
|
||||
public static void initialize() {
|
||||
COMMANDS.add(new SetPriorityCommand());
|
||||
COMMANDS.add(new NotifyCommand());
|
||||
|
||||
COMMANDS.add(new AddCommand());
|
||||
COMMANDS.add(new RemoveCommand());
|
||||
COMMANDS.add(new ClearCommand());
|
||||
|
||||
COMMANDS.add(new CreateGroupCommand());
|
||||
COMMANDS.add(new DeleteGroupCommand());
|
||||
|
||||
COMMANDS.add(new ListCommand());
|
||||
COMMANDS.add(new ListGroupsCommand());
|
||||
COMMANDS.add(new ListPrioritiesCommand());
|
||||
|
||||
COMMANDS.add(new StatsCommand());
|
||||
COMMANDS.add(new InfoCommand());
|
||||
COMMANDS.add(new PermsCommand());
|
||||
|
||||
COMMANDS.add(new PostDebugCommand());
|
||||
COMMANDS.add(new UpdateCommand());
|
||||
COMMANDS.add(new ReloadCommand());
|
||||
|
||||
// PROXY
|
||||
COMMANDS.add(new ServListCommand());
|
||||
|
||||
COMMANDS.add(new ServAddCommand());
|
||||
COMMANDS.add(new ServRemoveCommand());
|
||||
COMMANDS.add(new ServClearCommand());
|
||||
}
|
||||
|
||||
public static void handleCommand(Object senderObj, String[] args, String label) {
|
||||
CommandSender sender = CommandSenderHandler.from(senderObj);
|
||||
|
||||
if (!PermissionUtil.hasPermissionWithResponse(sender, "use"))
|
||||
return;
|
||||
|
||||
if (args.length == 0) {
|
||||
|
||||
Storage.ConfigSections.Messages.HELP.MESSAGE.getLines().forEach(line -> {
|
||||
sender.sendMessage(line.replace("%label%", label));
|
||||
});
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
String commandName = args[0];
|
||||
String[] commandArgs = new String[] {};
|
||||
|
||||
if (commandName.equals("serv") || commandName.equals("server")) {
|
||||
|
||||
if (args.length < 2) {
|
||||
sender.sendMessage(Storage.ConfigSections.Messages.COMMAND_FAILED.MESSAGE);
|
||||
return;
|
||||
}
|
||||
|
||||
String servCommandName = StringUtils.getFirstArg(args[1]);
|
||||
|
||||
if (args.length > 2) {
|
||||
commandArgs = Arrays.copyOfRange(args, 2, args.length);
|
||||
}
|
||||
|
||||
Optional<ProCommand> optCommand = COMMANDS.stream().filter(cmd -> {
|
||||
if (Reflection.isProxyServer() && cmd.isServerCommand())
|
||||
return cmd.isCommand(servCommandName);
|
||||
|
||||
return false;
|
||||
}).findFirst();
|
||||
|
||||
if (optCommand.isEmpty()) {
|
||||
sender.sendMessage(Storage.ConfigSections.Messages.COMMAND_FAILED.MESSAGE);
|
||||
return;
|
||||
}
|
||||
|
||||
ProCommand command = optCommand.get();
|
||||
if (!PermissionUtil.hasPermissionWithResponse(sender, command.getName()))
|
||||
return;
|
||||
|
||||
if (!command.execute(sender, commandArgs)) {
|
||||
sender.sendMessage(Storage.ConfigSections.Messages.COMMAND_FAILED.MESSAGE);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (args.length > 1) {
|
||||
commandArgs = Arrays.copyOfRange(args, 1, args.length);
|
||||
}
|
||||
|
||||
Optional<ProCommand> optCommand = COMMANDS.stream().filter(cmd -> {
|
||||
|
||||
if (!Reflection.isProxyServer() && !cmd.isProxyOnly() || Reflection.isProxyServer() && !cmd.isServerCommand())
|
||||
return cmd.isCommand(commandName);
|
||||
|
||||
return false;
|
||||
}).findFirst();
|
||||
|
||||
if (optCommand.isEmpty()) {
|
||||
sender.sendMessage(Storage.ConfigSections.Messages.COMMAND_FAILED.MESSAGE);
|
||||
return;
|
||||
}
|
||||
|
||||
ProCommand command = optCommand.get();
|
||||
if (!PermissionUtil.hasPermissionWithResponse(sender, command.getName()))
|
||||
return;
|
||||
|
||||
if (!command.execute(sender, commandArgs)) {
|
||||
sender.sendMessage(Storage.ConfigSections.Messages.COMMAND_FAILED.MESSAGE);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static List<String> handleTabComplete(Object senderObj, String[] args) {
|
||||
CommandSender sender = CommandSenderHandler.from(senderObj);
|
||||
List<String> result = new ArrayList<>();
|
||||
|
||||
if (!PermissionUtil.hasPermission(sender, "use"))
|
||||
return result;
|
||||
|
||||
if (args.length <= 1) {
|
||||
|
||||
if (Reflection.isProxyServer())
|
||||
result.addAll(Arrays.asList("serv", "server"));
|
||||
|
||||
COMMANDS.stream()
|
||||
.filter(cmd -> {
|
||||
|
||||
if (!Reflection.isProxyServer() && cmd.isProxyOnly())
|
||||
return false;
|
||||
|
||||
return PermissionUtil.hasPermission(sender, cmd.getName());
|
||||
})
|
||||
.forEach(cmd -> {
|
||||
result.add(cmd.getName());
|
||||
result.addAll(cmd.getAliases());
|
||||
});
|
||||
|
||||
} else {
|
||||
|
||||
String commandName = StringUtils.getFirstArg(args[0]);
|
||||
String[] commandArgs;
|
||||
Optional<ProCommand> optCommand;
|
||||
|
||||
if (commandName.equals("serv") || commandName.equals("server")) {
|
||||
|
||||
if (args.length == 2) {
|
||||
|
||||
COMMANDS.stream()
|
||||
.filter(cmd -> {
|
||||
|
||||
if (Reflection.isProxyServer() && cmd.isServerCommand())
|
||||
return PermissionUtil.hasPermission(sender, cmd.getName());
|
||||
|
||||
return false;
|
||||
})
|
||||
.forEach(cmd -> {
|
||||
result.add(cmd.getName());
|
||||
result.addAll(cmd.getAliases());
|
||||
});
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
String servCommandName = StringUtils.getFirstArg(args[1]);
|
||||
commandArgs = Arrays.copyOfRange(args, 2, args.length);
|
||||
|
||||
if (commandArgs.length == 1 && commandArgs[0].isBlank())
|
||||
commandArgs = new String[] {};
|
||||
|
||||
optCommand = COMMANDS.stream().filter(cmd -> {
|
||||
|
||||
if (Reflection.isProxyServer() && cmd.isServerCommand()) {
|
||||
return cmd.isCommand(servCommandName) && PermissionUtil.hasPermission(sender, cmd.getName());
|
||||
}
|
||||
|
||||
return false;
|
||||
}).findFirst();
|
||||
|
||||
} else {
|
||||
|
||||
commandArgs = Arrays.copyOfRange(args, 1, args.length);
|
||||
|
||||
if (commandArgs.length == 1 && commandArgs[0].isBlank())
|
||||
commandArgs = new String[]{};
|
||||
|
||||
optCommand = COMMANDS.stream().filter(cmd -> {
|
||||
if (!Reflection.isProxyServer() && cmd.isProxyOnly() || cmd.isServerCommand()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return cmd.isCommand(commandName);
|
||||
}).findFirst();
|
||||
}
|
||||
|
||||
if (optCommand.isPresent()) {
|
||||
ProCommand command = optCommand.get();
|
||||
|
||||
if (PermissionUtil.hasPermission(sender, command.getName())) {
|
||||
List<String> cmdCompletions = command.tabComplete(sender, commandArgs);
|
||||
result.addAll(cmdCompletions != null ? cmdCompletions : List.of());
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
return result.stream().filter(suggestion -> {
|
||||
|
||||
if (args.length == 0)
|
||||
return true;
|
||||
|
||||
String command = args[Math.max(0, args.length-1)].toLowerCase();
|
||||
suggestion = suggestion.toLowerCase();
|
||||
|
||||
if (command.startsWith("\"")) {
|
||||
command = command.length() == 1 ? "" : command.substring(1);
|
||||
}
|
||||
|
||||
return suggestion.startsWith(command);
|
||||
}).toList();
|
||||
}
|
||||
}
|
||||
package de.rayzs.pat.plugin.command;
|
||||
|
||||
import de.rayzs.pat.plugin.command.commands.ProCommand;
|
||||
import de.rayzs.pat.plugin.command.commands.local.info.InfoCommand;
|
||||
import de.rayzs.pat.plugin.command.commands.local.info.PermsCommand;
|
||||
import de.rayzs.pat.plugin.command.commands.local.info.StatsCommand;
|
||||
import de.rayzs.pat.plugin.command.commands.local.modify.*;
|
||||
import de.rayzs.pat.plugin.command.commands.local.modify.list.ListCommand;
|
||||
import de.rayzs.pat.plugin.command.commands.local.modify.list.ListGroupsCommand;
|
||||
import de.rayzs.pat.plugin.command.commands.local.modify.list.ListPrioritiesCommand;
|
||||
import de.rayzs.pat.plugin.command.commands.local.system.NotifyCommand;
|
||||
import de.rayzs.pat.plugin.command.commands.local.system.PostDebugCommand;
|
||||
import de.rayzs.pat.plugin.command.commands.local.system.ReloadCommand;
|
||||
import de.rayzs.pat.plugin.command.commands.local.system.UpdateCommand;
|
||||
import de.rayzs.pat.plugin.command.commands.server.ServAddCommand;
|
||||
import de.rayzs.pat.plugin.command.commands.server.ServClearCommand;
|
||||
import de.rayzs.pat.plugin.command.commands.server.ServRemoveCommand;
|
||||
import de.rayzs.pat.plugin.command.commands.server.list.ServListCommand;
|
||||
import de.rayzs.pat.utils.permission.PermissionUtil;
|
||||
import de.rayzs.pat.api.storage.Storage;
|
||||
|
||||
import de.rayzs.pat.utils.*;
|
||||
import de.rayzs.pat.utils.sender.CommandSender;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
public class CommandProcess {
|
||||
|
||||
private static final List<ProCommand> COMMANDS = new ArrayList<>();
|
||||
|
||||
public static void initialize() {
|
||||
COMMANDS.add(new SetPriorityCommand());
|
||||
COMMANDS.add(new NotifyCommand());
|
||||
|
||||
COMMANDS.add(new AddCommand());
|
||||
COMMANDS.add(new RemoveCommand());
|
||||
COMMANDS.add(new ClearCommand());
|
||||
|
||||
COMMANDS.add(new ConvertCommand());
|
||||
|
||||
if (!Reflection.isProxyServer()) {
|
||||
COMMANDS.add(new ExtractCommand());
|
||||
}
|
||||
|
||||
COMMANDS.add(new CreateGroupCommand());
|
||||
COMMANDS.add(new DeleteGroupCommand());
|
||||
|
||||
COMMANDS.add(new ListCommand());
|
||||
COMMANDS.add(new ListGroupsCommand());
|
||||
COMMANDS.add(new ListPrioritiesCommand());
|
||||
|
||||
COMMANDS.add(new StatsCommand());
|
||||
COMMANDS.add(new InfoCommand());
|
||||
COMMANDS.add(new PermsCommand());
|
||||
|
||||
COMMANDS.add(new PostDebugCommand());
|
||||
COMMANDS.add(new UpdateCommand());
|
||||
COMMANDS.add(new ReloadCommand());
|
||||
|
||||
// PROXY
|
||||
COMMANDS.add(new ServListCommand());
|
||||
|
||||
COMMANDS.add(new ServAddCommand());
|
||||
COMMANDS.add(new ServRemoveCommand());
|
||||
COMMANDS.add(new ServClearCommand());
|
||||
}
|
||||
|
||||
public static void handleCommand(Object senderObj, String[] args, String label) {
|
||||
CommandSender sender = CommandSender.from(senderObj);
|
||||
|
||||
if (!PermissionUtil.hasPermissionWithResponse(sender, "use"))
|
||||
return;
|
||||
|
||||
if (args.length == 0) {
|
||||
|
||||
Storage.ConfigSections.Messages.HELP.MESSAGE.getLines().forEach(line -> {
|
||||
sender.sendMessage(line.replace("%label%", label));
|
||||
});
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
String commandName = args[0];
|
||||
String[] commandArgs = new String[] {};
|
||||
|
||||
if (commandName.equals("serv") || commandName.equals("server")) {
|
||||
|
||||
if (args.length < 2) {
|
||||
sender.sendMessage(Storage.ConfigSections.Messages.COMMAND_FAILED.MESSAGE);
|
||||
return;
|
||||
}
|
||||
|
||||
String servCommandName = StringUtils.getFirstArg(args[1]);
|
||||
|
||||
if (args.length > 2) {
|
||||
commandArgs = Arrays.copyOfRange(args, 2, args.length);
|
||||
}
|
||||
|
||||
Optional<ProCommand> optCommand = COMMANDS.stream().filter(cmd -> {
|
||||
if (Reflection.isProxyServer() && cmd.isServerCommand())
|
||||
return cmd.isCommand(servCommandName);
|
||||
|
||||
return false;
|
||||
}).findFirst();
|
||||
|
||||
if (optCommand.isEmpty()) {
|
||||
sender.sendMessage(Storage.ConfigSections.Messages.COMMAND_FAILED.MESSAGE);
|
||||
return;
|
||||
}
|
||||
|
||||
ProCommand command = optCommand.get();
|
||||
if (!PermissionUtil.hasPermissionWithResponse(sender, command.getName()))
|
||||
return;
|
||||
|
||||
if (!command.execute(sender, commandArgs)) {
|
||||
sender.sendMessage(Storage.ConfigSections.Messages.COMMAND_FAILED.MESSAGE);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (args.length > 1) {
|
||||
commandArgs = Arrays.copyOfRange(args, 1, args.length);
|
||||
}
|
||||
|
||||
Optional<ProCommand> optCommand = COMMANDS.stream().filter(cmd -> {
|
||||
|
||||
if (!Reflection.isProxyServer() && !cmd.isProxyOnly() || Reflection.isProxyServer() && !cmd.isServerCommand())
|
||||
return cmd.isCommand(commandName);
|
||||
|
||||
return false;
|
||||
}).findFirst();
|
||||
|
||||
if (optCommand.isEmpty()) {
|
||||
sender.sendMessage(Storage.ConfigSections.Messages.COMMAND_FAILED.MESSAGE);
|
||||
return;
|
||||
}
|
||||
|
||||
ProCommand command = optCommand.get();
|
||||
if (!PermissionUtil.hasPermissionWithResponse(sender, command.getName()))
|
||||
return;
|
||||
|
||||
if (!command.execute(sender, commandArgs)) {
|
||||
sender.sendMessage(Storage.ConfigSections.Messages.COMMAND_FAILED.MESSAGE);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static List<String> handleTabComplete(Object senderObj, String[] args) {
|
||||
CommandSender sender = CommandSender.from(senderObj);
|
||||
List<String> result = new ArrayList<>();
|
||||
|
||||
if (!PermissionUtil.hasPermission(sender, "use"))
|
||||
return result;
|
||||
|
||||
if (args.length <= 1) {
|
||||
|
||||
if (Reflection.isProxyServer())
|
||||
result.addAll(Arrays.asList("serv", "server"));
|
||||
|
||||
COMMANDS.stream()
|
||||
.filter(cmd -> {
|
||||
|
||||
if (!Reflection.isProxyServer() && cmd.isProxyOnly())
|
||||
return false;
|
||||
|
||||
return PermissionUtil.hasPermission(sender, cmd.getName());
|
||||
})
|
||||
.forEach(cmd -> {
|
||||
result.add(cmd.getName());
|
||||
result.addAll(cmd.getAliases());
|
||||
});
|
||||
|
||||
} else {
|
||||
|
||||
String commandName = StringUtils.getFirstArg(args[0]);
|
||||
String[] commandArgs;
|
||||
Optional<ProCommand> optCommand;
|
||||
|
||||
if (commandName.equals("serv") || commandName.equals("server")) {
|
||||
|
||||
if (args.length == 2) {
|
||||
|
||||
COMMANDS.stream()
|
||||
.filter(cmd -> {
|
||||
|
||||
if (Reflection.isProxyServer() && cmd.isServerCommand())
|
||||
return PermissionUtil.hasPermission(sender, cmd.getName());
|
||||
|
||||
return false;
|
||||
})
|
||||
.forEach(cmd -> {
|
||||
result.add(cmd.getName());
|
||||
result.addAll(cmd.getAliases());
|
||||
});
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
String servCommandName = StringUtils.getFirstArg(args[1]);
|
||||
commandArgs = Arrays.copyOfRange(args, 2, args.length);
|
||||
|
||||
if (commandArgs.length == 1 && commandArgs[0].isBlank())
|
||||
commandArgs = new String[] {};
|
||||
|
||||
optCommand = COMMANDS.stream().filter(cmd -> {
|
||||
|
||||
if (Reflection.isProxyServer() && cmd.isServerCommand()) {
|
||||
return cmd.isCommand(servCommandName) && PermissionUtil.hasPermission(sender, cmd.getName());
|
||||
}
|
||||
|
||||
return false;
|
||||
}).findFirst();
|
||||
|
||||
} else {
|
||||
|
||||
commandArgs = Arrays.copyOfRange(args, 1, args.length);
|
||||
|
||||
if (commandArgs.length == 1 && commandArgs[0].isBlank())
|
||||
commandArgs = new String[]{};
|
||||
|
||||
optCommand = COMMANDS.stream().filter(cmd -> {
|
||||
if (!Reflection.isProxyServer() && cmd.isProxyOnly() || cmd.isServerCommand()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return cmd.isCommand(commandName);
|
||||
}).findFirst();
|
||||
}
|
||||
|
||||
if (optCommand.isPresent()) {
|
||||
ProCommand command = optCommand.get();
|
||||
|
||||
if (PermissionUtil.hasPermission(sender, command.getName())) {
|
||||
List<String> cmdCompletions = command.tabComplete(sender, commandArgs);
|
||||
result.addAll(cmdCompletions != null ? cmdCompletions : List.of());
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
return result.stream().filter(suggestion -> {
|
||||
|
||||
if (args.length == 0)
|
||||
return true;
|
||||
|
||||
String command = args[Math.max(0, args.length-1)].toLowerCase();
|
||||
suggestion = suggestion.toLowerCase();
|
||||
|
||||
if (command.startsWith("\"")) {
|
||||
command = command.length() == 1 ? "" : command.substring(1);
|
||||
}
|
||||
|
||||
return suggestion.startsWith(command);
|
||||
}).toList();
|
||||
}
|
||||
|
||||
public static List<ProCommand> getCommands() {
|
||||
return COMMANDS;
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package de.rayzs.pat.api.command;
|
||||
package de.rayzs.pat.plugin.command.commands;
|
||||
|
||||
import de.rayzs.pat.utils.*;
|
||||
import de.rayzs.pat.utils.sender.CommandSender;
|
||||
@@ -0,0 +1,64 @@
|
||||
package de.rayzs.pat.plugin.command.commands.local.info;
|
||||
|
||||
import de.rayzs.pat.plugin.system.communication.BackendUpdater;
|
||||
import de.rayzs.pat.plugin.system.communication.Communicator;
|
||||
import de.rayzs.pat.plugin.command.commands.ProCommand;
|
||||
import de.rayzs.pat.api.storage.Storage;
|
||||
import de.rayzs.pat.utils.*;
|
||||
import de.rayzs.pat.utils.sender.CommandSender;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class InfoCommand extends ProCommand {
|
||||
|
||||
public InfoCommand() {
|
||||
super(
|
||||
"info",
|
||||
""
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean execute(CommandSender sender, String[] args) {
|
||||
|
||||
String message = StringUtils.getStringList(Storage.ConfigSections.Messages.INFO.MESSAGE.getLines(), "\n");
|
||||
|
||||
String syncTime = Storage.ConfigSections.Settings.HANDLE_THROUGH_PROXY.ENABLED ||
|
||||
Reflection.isProxyServer()
|
||||
? Storage.ConfigSections.Messages.INFO.SYNC_TIME.replace("%time%", TimeConverter.calcAndGetTime(Communicator.get().getLastSync()))
|
||||
: Storage.ConfigSections.Messages.INFO.SYNC_DISABLED;
|
||||
|
||||
String lastAlivePacketTime = Storage.ConfigSections.Settings.HANDLE_THROUGH_PROXY.ENABLED ||
|
||||
Reflection.isProxyServer()
|
||||
? Storage.ConfigSections.Messages.INFO.SYNC_TIME.replace("%time%", TimeConverter.calcAndGetTime(Communicator.get().getLastReceivedKeepAliveResponse()))
|
||||
: Storage.ConfigSections.Messages.INFO.SYNC_DISABLED;
|
||||
|
||||
|
||||
if (!Reflection.isProxyServer()
|
||||
&& !BackendUpdater.get().isConnected()
|
||||
&& Storage.ConfigSections.Settings.HANDLE_THROUGH_PROXY.ENABLED)
|
||||
{
|
||||
syncTime = Storage.ConfigSections.Messages.INFO.SYNC_WAITING;
|
||||
lastAlivePacketTime = Storage.ConfigSections.Messages.INFO.SYNC_WAITING;
|
||||
}
|
||||
|
||||
|
||||
final String versionStatus = Storage.OUTDATED
|
||||
? Storage.ConfigSections.Messages.INFO.VERSION_OUTDATED
|
||||
: Storage.ConfigSections.Messages.INFO.VERSION_UPDATED;
|
||||
|
||||
message = StringUtils.replace(message,
|
||||
"%sync_time%", syncTime,
|
||||
"%last_alive_response%", lastAlivePacketTime,
|
||||
"%version_status%", versionStatus
|
||||
);
|
||||
|
||||
sender.sendMessage(message);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> tabComplete(CommandSender sender, String[] args) {
|
||||
return List.of();
|
||||
}
|
||||
}
|
||||
+2
-2
@@ -1,7 +1,7 @@
|
||||
package de.rayzs.pat.plugin.process.impl.local.info;
|
||||
package de.rayzs.pat.plugin.command.commands.local.info;
|
||||
|
||||
import de.rayzs.pat.utils.permission.PermissionUtil;
|
||||
import de.rayzs.pat.api.command.ProCommand;
|
||||
import de.rayzs.pat.plugin.command.commands.ProCommand;
|
||||
import de.rayzs.pat.api.storage.Storage;
|
||||
import de.rayzs.pat.utils.sender.CommandSender;
|
||||
import java.util.*;
|
||||
+21
-16
@@ -1,13 +1,15 @@
|
||||
package de.rayzs.pat.plugin.process.impl.local.info;
|
||||
package de.rayzs.pat.plugin.command.commands.local.info;
|
||||
|
||||
import de.rayzs.pat.api.communication.client.ClientInfo;
|
||||
import de.rayzs.pat.api.communication.Communicator;
|
||||
import de.rayzs.pat.api.command.ProCommand;
|
||||
import de.rayzs.pat.plugin.system.communication.client.Client;
|
||||
import de.rayzs.pat.plugin.system.communication.Communicator;
|
||||
import de.rayzs.pat.plugin.command.commands.ProCommand;
|
||||
import de.rayzs.pat.api.storage.Storage;
|
||||
import de.rayzs.pat.utils.*;
|
||||
import de.rayzs.pat.utils.sender.CommandSender;
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
public class StatsCommand extends ProCommand {
|
||||
|
||||
@@ -29,26 +31,28 @@ public class StatsCommand extends ProCommand {
|
||||
return true;
|
||||
}
|
||||
|
||||
final int length = Communicator.CLIENTS.size() - 1;
|
||||
boolean tmpFound = false;
|
||||
final Set<Client> clients = Communicator.get().getClients();
|
||||
final Iterator<Client> iterator = clients.iterator();
|
||||
|
||||
boolean tmpFound = false;
|
||||
StringBuilder statsBuilder = new StringBuilder();
|
||||
|
||||
for (int i = 0; i < Communicator.CLIENTS.size(); i++) {
|
||||
ClientInfo client = Communicator.CLIENTS.get(i);
|
||||
while (iterator.hasNext()) {
|
||||
Client client = iterator.next();
|
||||
|
||||
if (!client.hasSentFeedback())
|
||||
continue;
|
||||
|
||||
if (!tmpFound)
|
||||
if (!tmpFound) {
|
||||
tmpFound = true;
|
||||
}
|
||||
|
||||
statsBuilder.append(StringUtils.replace(Storage.ConfigSections.Messages.STATS.SERVER,
|
||||
"%updated%", client.getSyncTime(), "%servername%", client.getName()
|
||||
"%updated%", client.getFormattedSyncTime(),
|
||||
"%servername%", client.getServerName(),
|
||||
"%last_alive_response%", client.getFormattedLastReceivedKeepAlivePacketTime()
|
||||
));
|
||||
|
||||
if (i <= length)
|
||||
if (iterator.hasNext()) {
|
||||
statsBuilder.append(Storage.ConfigSections.Messages.STATS.SPLITTER);
|
||||
}
|
||||
}
|
||||
|
||||
final boolean found = tmpFound;
|
||||
@@ -56,8 +60,9 @@ public class StatsCommand extends ProCommand {
|
||||
Storage.ConfigSections.Messages.STATS.STATISTIC.getLines().forEach(message -> {
|
||||
|
||||
message = StringUtils.replace(message,
|
||||
"%server_count%", String.valueOf(Communicator.SERVER_DATA_SYNC_COUNT),
|
||||
"%last_sync_time%", TimeConverter.calcAndGetTime(Communicator.LAST_DATA_UPDATE),
|
||||
"%server_count%", String.valueOf(Communicator.get().getClients().size()),
|
||||
"%last_sync_time%", TimeConverter.calcAndGetTime(Communicator.get().getLastSync()),
|
||||
"%last_alive_response_time%", TimeConverter.calcAndGetTime(Communicator.get().getLastReceivedKeepAliveResponse()),
|
||||
"%servers%", found ? statsBuilder.toString() : Storage.ConfigSections.Messages.STATS.NO_SERVER
|
||||
);
|
||||
|
||||
+10
-4
@@ -1,10 +1,11 @@
|
||||
package de.rayzs.pat.plugin.process.impl.local.modify;
|
||||
package de.rayzs.pat.plugin.command.commands.local.modify;
|
||||
|
||||
import de.rayzs.pat.api.command.ProCommand;
|
||||
import de.rayzs.pat.plugin.command.commands.ProCommand;
|
||||
import de.rayzs.pat.api.storage.Storage;
|
||||
import de.rayzs.pat.api.storage.blacklist.impl.GroupBlacklist;
|
||||
import de.rayzs.pat.plugin.BukkitLoader;
|
||||
import de.rayzs.pat.utils.group.*;
|
||||
import de.rayzs.pat.utils.group.Group;
|
||||
import de.rayzs.pat.utils.group.GroupManager;
|
||||
import de.rayzs.pat.utils.*;
|
||||
import de.rayzs.pat.utils.sender.CommandSender;
|
||||
|
||||
@@ -58,6 +59,7 @@ public class AddCommand extends ProCommand {
|
||||
if (command.isEmpty())
|
||||
return false;
|
||||
|
||||
final boolean loadBlacklist = command.startsWith("plugin=") || command.startsWith("!");
|
||||
final int length = args.length;
|
||||
|
||||
if (length == 1) {
|
||||
@@ -67,6 +69,8 @@ public class AddCommand extends ProCommand {
|
||||
|
||||
if (!exist) {
|
||||
Storage.Blacklist.getBlacklist().add(command).save();
|
||||
if (loadBlacklist) Storage.Blacklist.getBlacklist().load();
|
||||
|
||||
Storage.handleChange();
|
||||
}
|
||||
|
||||
@@ -107,7 +111,9 @@ public class AddCommand extends ProCommand {
|
||||
if (Reflection.isProxyServer())
|
||||
return null;
|
||||
|
||||
return BukkitLoader.getDisallowedCommands();
|
||||
return Storage.ConfigSections.Settings.TURN_BLACKLIST_TO_WHITELIST.ENABLED
|
||||
? BukkitLoader.getDisallowedCommands()
|
||||
: BukkitLoader.getAllowedCommands();
|
||||
}
|
||||
|
||||
String fullString = String.join(" ", args);
|
||||
+6
-3
@@ -1,9 +1,11 @@
|
||||
package de.rayzs.pat.plugin.process.impl.local.modify;
|
||||
package de.rayzs.pat.plugin.command.commands.local.modify;
|
||||
|
||||
import de.rayzs.pat.api.command.ProCommand;
|
||||
import de.rayzs.pat.plugin.command.commands.ProCommand;
|
||||
import de.rayzs.pat.api.storage.Storage;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import de.rayzs.pat.utils.group.*;
|
||||
|
||||
import de.rayzs.pat.utils.group.Group;
|
||||
import de.rayzs.pat.utils.group.GroupManager;
|
||||
import de.rayzs.pat.utils.*;
|
||||
import de.rayzs.pat.utils.sender.CommandSender;
|
||||
|
||||
@@ -34,6 +36,7 @@ public class ClearCommand extends ProCommand {
|
||||
}
|
||||
|
||||
Storage.Blacklist.getBlacklist().clear().save();
|
||||
Storage.Blacklist.getBlacklist().load();
|
||||
Storage.handleChange();
|
||||
|
||||
CONFIRMATION.remove(sender.getUniqueId());
|
||||
@@ -0,0 +1,51 @@
|
||||
package de.rayzs.pat.plugin.command.commands.local.modify;
|
||||
|
||||
import de.rayzs.pat.plugin.command.commands.ProCommand;
|
||||
import de.rayzs.pat.api.storage.Storage;
|
||||
import de.rayzs.pat.plugin.system.converter.Converter;
|
||||
import de.rayzs.pat.plugin.system.converter.StorageConverter;
|
||||
import de.rayzs.pat.utils.StringUtils;
|
||||
import de.rayzs.pat.utils.sender.CommandSender;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class ConvertCommand extends ProCommand {
|
||||
|
||||
public ConvertCommand() {
|
||||
super(
|
||||
"convert",
|
||||
""
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean execute(CommandSender sender, String[] args) {
|
||||
|
||||
if (args.length != 1)
|
||||
return false;
|
||||
|
||||
String converterName = args[0];
|
||||
Converter converter = StorageConverter.get().getConverter(converterName);
|
||||
if (converter == null) {
|
||||
sender.sendMessage(StringUtils.replace(Storage.ConfigSections.Messages.CONVERT.INVALID_CONVERTER,
|
||||
"%converter%", converterName)
|
||||
);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
converterName = converter.getPluginName();
|
||||
sender.sendMessage(StringUtils.replace(Storage.ConfigSections.Messages.CONVERT.SUCCESS,
|
||||
"%converter%", converterName)
|
||||
);
|
||||
|
||||
converter.apply(sender);
|
||||
Storage.reload();
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> tabComplete(CommandSender sender, String[] args) {
|
||||
return StorageConverter.get().getConverters().stream().toList();
|
||||
}
|
||||
}
|
||||
+6
-4
@@ -1,6 +1,6 @@
|
||||
package de.rayzs.pat.plugin.process.impl.local.modify;
|
||||
package de.rayzs.pat.plugin.command.commands.local.modify;
|
||||
|
||||
import de.rayzs.pat.api.command.ProCommand;
|
||||
import de.rayzs.pat.plugin.command.commands.ProCommand;
|
||||
import de.rayzs.pat.api.storage.Storage;
|
||||
import de.rayzs.pat.utils.sender.CommandSender;
|
||||
import de.rayzs.pat.utils.Reflection;
|
||||
@@ -8,6 +8,7 @@ import de.rayzs.pat.utils.StringUtils;
|
||||
import de.rayzs.pat.utils.group.Group;
|
||||
import de.rayzs.pat.utils.group.GroupManager;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
public class CreateGroupCommand extends ProCommand {
|
||||
@@ -33,12 +34,13 @@ public class CreateGroupCommand extends ProCommand {
|
||||
return true;
|
||||
}
|
||||
|
||||
String groupName = args[0];
|
||||
String groupName = args[0].toLowerCase();
|
||||
Group group = GroupManager.getGroupByName(groupName);
|
||||
boolean registered = group != null;
|
||||
|
||||
if (!registered) {
|
||||
GroupManager.registerGroup(groupName);
|
||||
Storage.getLoader().addPermission("group." + groupName);
|
||||
} else groupName = group.getGroupName();
|
||||
|
||||
String message = registered ? Storage.ConfigSections.Messages.GROUP.ALREADY_EXIST : Storage.ConfigSections.Messages.GROUP.CREATE;
|
||||
@@ -50,6 +52,6 @@ public class CreateGroupCommand extends ProCommand {
|
||||
|
||||
@Override
|
||||
public List<String> tabComplete(CommandSender sender, String[] args) {
|
||||
return args.length < 2 ? GroupManager.getGroupNames() : null;
|
||||
return Collections.emptyList();
|
||||
}
|
||||
}
|
||||
+3
-2
@@ -1,6 +1,6 @@
|
||||
package de.rayzs.pat.plugin.process.impl.local.modify;
|
||||
package de.rayzs.pat.plugin.command.commands.local.modify;
|
||||
|
||||
import de.rayzs.pat.api.command.ProCommand;
|
||||
import de.rayzs.pat.plugin.command.commands.ProCommand;
|
||||
import de.rayzs.pat.api.storage.Storage;
|
||||
import de.rayzs.pat.utils.sender.CommandSender;
|
||||
import de.rayzs.pat.utils.ExpireCache;
|
||||
@@ -58,6 +58,7 @@ public class DeleteGroupCommand extends ProCommand {
|
||||
}
|
||||
|
||||
GroupManager.unregisterGroup(groupName);
|
||||
Storage.getLoader().removePermission("group." + group.getGroupName());
|
||||
CONFIRMATION.remove(sender.getUniqueId());
|
||||
|
||||
String message = registered ? Storage.ConfigSections.Messages.GROUP.DELETE : Storage.ConfigSections.Messages.GROUP.DOES_NOT_EXIST;
|
||||
@@ -0,0 +1,157 @@
|
||||
package de.rayzs.pat.plugin.command.commands.local.modify;
|
||||
|
||||
import de.rayzs.pat.plugin.command.commands.ProCommand;
|
||||
import de.rayzs.pat.api.storage.Storage;
|
||||
import de.rayzs.pat.api.storage.storages.BlacklistStorage;
|
||||
import de.rayzs.pat.utils.StringUtils;
|
||||
import de.rayzs.pat.utils.group.Group;
|
||||
import de.rayzs.pat.utils.group.GroupManager;
|
||||
import de.rayzs.pat.utils.sender.CommandSender;
|
||||
import java.util.*;
|
||||
|
||||
public class ExtractCommand extends ProCommand {
|
||||
|
||||
public ExtractCommand() {
|
||||
super(
|
||||
"extract",
|
||||
""
|
||||
);
|
||||
}
|
||||
|
||||
private enum Mode {
|
||||
|
||||
BOTH("both", true), ONLY_COLON("only-colon", true), NON_COLON("non-colon", false);
|
||||
|
||||
private static Mode getMode(final String name) {
|
||||
for (final Mode mode : Mode.values()) {
|
||||
if (mode.getName().equalsIgnoreCase(name)) {
|
||||
return mode;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public boolean doesIncludesColons() {
|
||||
return includesColons;
|
||||
}
|
||||
|
||||
private final String name;
|
||||
private final boolean includesColons;
|
||||
|
||||
Mode(final String name, final boolean includesColons) {
|
||||
this.name = name;
|
||||
this.includesColons = includesColons;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean execute(CommandSender sender, String[] args) {
|
||||
|
||||
if (args.length < 1) {
|
||||
sender.sendMessage(Storage.ConfigSections.Messages.EXTRACT.USAGE);
|
||||
return true;
|
||||
}
|
||||
|
||||
Mode mode = Mode.NON_COLON;
|
||||
|
||||
String pluginName = args[0].toLowerCase();
|
||||
boolean failed = false;
|
||||
Group group = null;
|
||||
|
||||
|
||||
if (args.length == 2) {
|
||||
|
||||
group = GroupManager.getGroupByName(args[1]);
|
||||
|
||||
if (group == null) {
|
||||
mode = Mode.getMode(args[1]);
|
||||
failed = mode == null;
|
||||
}
|
||||
|
||||
} else if (args.length == 3) {
|
||||
|
||||
group = GroupManager.getGroupByName(args[1]);
|
||||
mode = Mode.getMode(args[2]);
|
||||
|
||||
if (group == null || mode == null) {
|
||||
failed = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (failed) {
|
||||
sender.sendMessage(Storage.ConfigSections.Messages.EXTRACT.USAGE);
|
||||
return true;
|
||||
}
|
||||
|
||||
List<String> pluginNames = Storage.getLoader().getFormattedPluginNames("%n");
|
||||
boolean pluginFound = false, all = pluginName.equalsIgnoreCase("*");
|
||||
|
||||
for (String name : pluginNames) {
|
||||
if (name.equalsIgnoreCase(pluginName)) {
|
||||
pluginFound = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!all && !pluginFound) {
|
||||
sender.sendMessage(StringUtils.replace(Storage.ConfigSections.Messages.EXTRACT.PLUGIN_NOT_FOUND,
|
||||
"%plugin%", pluginName)
|
||||
);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
List<String> commands = all
|
||||
? Storage.getLoader().getAllCommands(mode.doesIncludesColons())
|
||||
: Storage.getLoader().getPluginCommands(args[0], mode.doesIncludesColons());
|
||||
|
||||
if (mode == Mode.ONLY_COLON) {
|
||||
commands = commands.stream().filter(command -> command.contains(":")).toList();
|
||||
}
|
||||
|
||||
BlacklistStorage storage = group == null
|
||||
? Storage.Blacklist.getBlacklist()
|
||||
: group.getGeneralGroupBlacklist();
|
||||
|
||||
commands = commands.stream().filter(command -> !storage.isListed(command)).toList();
|
||||
commands.forEach(storage::add);
|
||||
|
||||
storage.save();
|
||||
|
||||
sender.sendMessage(StringUtils.replace(Storage.ConfigSections.Messages.EXTRACT.SUCCESS,
|
||||
"%amount%", String.valueOf(commands.size()),
|
||||
"%plugin%", pluginName
|
||||
));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> tabComplete(CommandSender sender, String[] args) {
|
||||
final int length = args.length;
|
||||
|
||||
if (length <= 1) {
|
||||
final List<String> suggestions = Storage.getLoader().getFormattedPluginNames("%n");
|
||||
suggestions.add("*");
|
||||
|
||||
return suggestions;
|
||||
}
|
||||
|
||||
List<String> result = new ArrayList<>();
|
||||
|
||||
if (length == 2 || length == 3 && GroupManager.getGroupByName(args[1]) != null) {
|
||||
result.addAll(Arrays.stream(Mode.values()).map(Mode::getName).toList());
|
||||
}
|
||||
|
||||
if (length == 2) {
|
||||
result.addAll(GroupManager.getGroupNames());
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
+7
-3
@@ -1,9 +1,10 @@
|
||||
package de.rayzs.pat.plugin.process.impl.local.modify;
|
||||
package de.rayzs.pat.plugin.command.commands.local.modify;
|
||||
|
||||
import de.rayzs.pat.api.command.ProCommand;
|
||||
import de.rayzs.pat.plugin.command.commands.ProCommand;
|
||||
import de.rayzs.pat.api.storage.Storage;
|
||||
import de.rayzs.pat.api.storage.blacklist.impl.GroupBlacklist;
|
||||
import de.rayzs.pat.utils.group.*;
|
||||
import de.rayzs.pat.utils.group.Group;
|
||||
import de.rayzs.pat.utils.group.GroupManager;
|
||||
import de.rayzs.pat.utils.*;
|
||||
import de.rayzs.pat.utils.sender.CommandSender;
|
||||
|
||||
@@ -57,6 +58,7 @@ public class RemoveCommand extends ProCommand {
|
||||
if (command.isEmpty())
|
||||
return false;
|
||||
|
||||
final boolean loadBlacklist = command.startsWith("plugin=") || command.startsWith("!");
|
||||
final int length = args.length;
|
||||
|
||||
if (length == 1) {
|
||||
@@ -64,6 +66,8 @@ public class RemoveCommand extends ProCommand {
|
||||
|
||||
if (exist) {
|
||||
Storage.Blacklist.getBlacklist().remove(command).save();
|
||||
if (loadBlacklist) Storage.Blacklist.getBlacklist().load();
|
||||
|
||||
Storage.handleChange();
|
||||
}
|
||||
|
||||
+2
-2
@@ -1,6 +1,6 @@
|
||||
package de.rayzs.pat.plugin.process.impl.local.modify;
|
||||
package de.rayzs.pat.plugin.command.commands.local.modify;
|
||||
|
||||
import de.rayzs.pat.api.command.ProCommand;
|
||||
import de.rayzs.pat.plugin.command.commands.ProCommand;
|
||||
import de.rayzs.pat.api.storage.Storage;
|
||||
import de.rayzs.pat.utils.sender.CommandSender;
|
||||
import de.rayzs.pat.utils.Reflection;
|
||||
+6
-4
@@ -1,10 +1,12 @@
|
||||
package de.rayzs.pat.plugin.process.impl.local.modify.list;
|
||||
package de.rayzs.pat.plugin.command.commands.local.modify.list;
|
||||
|
||||
import de.rayzs.pat.api.command.ProCommand;
|
||||
import de.rayzs.pat.plugin.command.commands.ProCommand;
|
||||
import de.rayzs.pat.api.storage.Storage;
|
||||
import de.rayzs.pat.utils.group.Group;
|
||||
import de.rayzs.pat.utils.group.GroupManager;
|
||||
import de.rayzs.pat.utils.sender.CommandSender;
|
||||
import de.rayzs.pat.utils.StringUtils;
|
||||
import de.rayzs.pat.utils.group.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class ListCommand extends ProCommand {
|
||||
@@ -51,7 +53,7 @@ public class ListCommand extends ProCommand {
|
||||
String message = Storage.ConfigSections.Messages.GROUP.LIST_MESSAGE;
|
||||
message = StringUtils.replace(message,
|
||||
"%group%", groupName,
|
||||
"%size%", String.valueOf(Storage.Blacklist.getBlacklist().getCommands().size()),
|
||||
"%size%", String.valueOf(group.getCommands().size()),
|
||||
"%commands%", commandsListMessage
|
||||
);
|
||||
|
||||
+3
-3
@@ -1,7 +1,7 @@
|
||||
package de.rayzs.pat.plugin.process.impl.local.modify.list;
|
||||
package de.rayzs.pat.plugin.command.commands.local.modify.list;
|
||||
|
||||
import de.rayzs.pat.utils.group.GroupManager;
|
||||
import de.rayzs.pat.api.command.ProCommand;
|
||||
import de.rayzs.pat.plugin.command.commands.ProCommand;
|
||||
import de.rayzs.pat.api.storage.Storage;
|
||||
import de.rayzs.pat.utils.*;
|
||||
import de.rayzs.pat.utils.sender.CommandSender;
|
||||
@@ -26,7 +26,7 @@ public class ListGroupsCommand extends ProCommand {
|
||||
|
||||
String message = Storage.ConfigSections.Messages.GROUP.LIST_GROUP_MESSAGE;
|
||||
message = StringUtils.replace(message,
|
||||
"%size%", String.valueOf(Storage.Blacklist.getBlacklist().getCommands().size()),
|
||||
"%size%", String.valueOf(GroupManager.getGroups().size()),
|
||||
"%groups%", groupsListMessage
|
||||
);
|
||||
|
||||
+2
-2
@@ -1,6 +1,6 @@
|
||||
package de.rayzs.pat.plugin.process.impl.local.modify.list;
|
||||
package de.rayzs.pat.plugin.command.commands.local.modify.list;
|
||||
|
||||
import de.rayzs.pat.api.command.ProCommand;
|
||||
import de.rayzs.pat.plugin.command.commands.ProCommand;
|
||||
import de.rayzs.pat.api.storage.Storage;
|
||||
import de.rayzs.pat.utils.sender.CommandSender;
|
||||
import de.rayzs.pat.utils.StringUtils;
|
||||
+11
-11
@@ -1,6 +1,6 @@
|
||||
package de.rayzs.pat.plugin.process.impl.local.system;
|
||||
package de.rayzs.pat.plugin.command.commands.local.system;
|
||||
|
||||
import de.rayzs.pat.api.command.ProCommand;
|
||||
import de.rayzs.pat.plugin.command.commands.ProCommand;
|
||||
import de.rayzs.pat.api.storage.Storage;
|
||||
import de.rayzs.pat.utils.sender.CommandSender;
|
||||
import de.rayzs.pat.utils.Reflection;
|
||||
@@ -18,20 +18,20 @@ public class NotifyCommand extends ProCommand {
|
||||
|
||||
@Override
|
||||
public boolean execute(CommandSender sender, String[] args) {
|
||||
|
||||
boolean backend = Storage.ConfigSections.Settings.HANDLE_THROUGH_PROXY.ENABLED && !Reflection.isProxyServer();
|
||||
|
||||
if (backend) {
|
||||
sender.sendMessage(Storage.ConfigSections.Messages.NO_PROXY.MESSAGE);
|
||||
return true;
|
||||
}
|
||||
|
||||
boolean enabled = false;
|
||||
boolean enabled;
|
||||
|
||||
if (sender.isConsole()) {
|
||||
enabled = Storage.SEND_CONSOLE_NOTIFICATION;
|
||||
Storage.SEND_CONSOLE_NOTIFICATION = !Storage.SEND_CONSOLE_NOTIFICATION;
|
||||
} else {
|
||||
|
||||
boolean backend = Storage.ConfigSections.Settings.HANDLE_THROUGH_PROXY.ENABLED && !Reflection.isProxyServer();
|
||||
|
||||
if (backend) {
|
||||
sender.sendMessage(Storage.ConfigSections.Messages.NO_PROXY.MESSAGE);
|
||||
return true;
|
||||
}
|
||||
|
||||
enabled = Storage.NOTIFY_PLAYERS.contains(sender.getUniqueId());
|
||||
|
||||
if (enabled)
|
||||
+2
-2
@@ -1,6 +1,6 @@
|
||||
package de.rayzs.pat.plugin.process.impl.local.system;
|
||||
package de.rayzs.pat.plugin.command.commands.local.system;
|
||||
|
||||
import de.rayzs.pat.api.command.ProCommand;
|
||||
import de.rayzs.pat.plugin.command.commands.ProCommand;
|
||||
import de.rayzs.pat.plugin.logger.Logger;
|
||||
import de.rayzs.pat.utils.sender.CommandSender;
|
||||
import de.rayzs.pat.api.storage.Storage;
|
||||
@@ -0,0 +1,31 @@
|
||||
package de.rayzs.pat.plugin.command.commands.local.system;
|
||||
|
||||
import de.rayzs.pat.plugin.command.commands.ProCommand;
|
||||
import de.rayzs.pat.api.storage.Storage;
|
||||
import de.rayzs.pat.utils.sender.CommandSender;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class ReloadCommand extends ProCommand {
|
||||
|
||||
public ReloadCommand() {
|
||||
super(
|
||||
"reload",
|
||||
"rl"
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean execute(CommandSender sender, String[] args) {
|
||||
sender.sendMessage(Storage.ConfigSections.Messages.RELOAD.LOADING);
|
||||
Storage.reload();
|
||||
sender.sendMessage(Storage.ConfigSections.Messages.RELOAD.DONE);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> tabComplete(CommandSender sender, String[] args) {
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
+6
-18
@@ -1,12 +1,9 @@
|
||||
package de.rayzs.pat.plugin.process.impl.local.system;
|
||||
package de.rayzs.pat.plugin.command.commands.local.system;
|
||||
|
||||
import de.rayzs.pat.plugin.listeners.bukkit.BukkitAntiTabListener;
|
||||
import de.rayzs.pat.utils.Reflection;
|
||||
import de.rayzs.pat.utils.permission.PermissionUtil;
|
||||
import de.rayzs.pat.api.command.ProCommand;
|
||||
import de.rayzs.pat.plugin.command.commands.ProCommand;
|
||||
import de.rayzs.pat.api.storage.Storage;
|
||||
import de.rayzs.pat.utils.sender.CommandSender;
|
||||
import de.rayzs.pat.utils.sender.CommandSenderHandler;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
@@ -22,22 +19,18 @@ public class UpdateCommand extends ProCommand {
|
||||
@Override
|
||||
public boolean execute(CommandSender sender, String[] args) {
|
||||
if (args.length == 0) {
|
||||
PermissionUtil.reloadPermissions();
|
||||
|
||||
Storage.getLoader().getOnlinePlayerNames().forEach(name -> {
|
||||
Object playerObj = Storage.getLoader().getPlayerObjByName(name);
|
||||
|
||||
if (playerObj != null) {
|
||||
CommandSender s = CommandSenderHandler.from(playerObj);
|
||||
CommandSender s = CommandSender.from(playerObj);
|
||||
|
||||
assert s != null;
|
||||
PermissionUtil.reloadPermissions(s);
|
||||
}
|
||||
});
|
||||
|
||||
if (!Reflection.isProxyServer() && Reflection.getMinor() >= 13) {
|
||||
BukkitAntiTabListener.handleTabCompletion();
|
||||
}
|
||||
Storage.getLoader().updateCommands();
|
||||
|
||||
sender.sendMessage(Storage.ConfigSections.Messages.UPDATE_PERMISSIONS.UPDATE_ALL);
|
||||
return true;
|
||||
@@ -46,7 +39,7 @@ public class UpdateCommand extends ProCommand {
|
||||
String name = args[0];
|
||||
UUID uuid = Storage.getLoader().getUUIDByName(name);
|
||||
Object playerObj = Storage.getLoader().getPlayerObjByUUID(uuid);
|
||||
CommandSender targetSender = CommandSenderHandler.from(playerObj);
|
||||
CommandSender targetSender = CommandSender.from(playerObj);
|
||||
|
||||
boolean exist = targetSender != null;
|
||||
|
||||
@@ -61,13 +54,8 @@ public class UpdateCommand extends ProCommand {
|
||||
message = message.replace("%target%", name);
|
||||
|
||||
if (exist) {
|
||||
|
||||
PermissionUtil.reloadPermissions(targetSender);
|
||||
|
||||
if (!Reflection.isProxyServer() && Reflection.getMinor() >= 13) {
|
||||
BukkitAntiTabListener.handleTabCompletion(uuid);
|
||||
}
|
||||
|
||||
Storage.getLoader().updateCommands(targetSender);
|
||||
}
|
||||
|
||||
sender.sendMessage(message);
|
||||
+11
-3
@@ -1,6 +1,6 @@
|
||||
package de.rayzs.pat.plugin.process.impl.server;
|
||||
package de.rayzs.pat.plugin.command.commands.server;
|
||||
|
||||
import de.rayzs.pat.api.command.ProCommand;
|
||||
import de.rayzs.pat.plugin.command.commands.ProCommand;
|
||||
import de.rayzs.pat.api.storage.Storage;
|
||||
import de.rayzs.pat.api.storage.blacklist.impl.GeneralBlacklist;
|
||||
import de.rayzs.pat.api.storage.blacklist.impl.GroupBlacklist;
|
||||
@@ -90,7 +90,15 @@ public class ServAddCommand extends ProCommand {
|
||||
Group group = GroupManager.getGroupByName(groupName);
|
||||
|
||||
if (group == null) {
|
||||
sender.sendMessage(Storage.ConfigSections.Messages.GROUP.DOES_NOT_EXIST_SERVER.replace("%group%", groupName));
|
||||
|
||||
String message = Storage.ConfigSections.Messages.GROUP.DOES_NOT_EXIST_SERVER;
|
||||
|
||||
message = StringUtils.replace(message,
|
||||
"%group%", groupName,
|
||||
"%server%", serverName
|
||||
);
|
||||
|
||||
sender.sendMessage(message);
|
||||
return true;
|
||||
}
|
||||
|
||||
+9
-6
@@ -1,7 +1,8 @@
|
||||
package de.rayzs.pat.plugin.process.impl.server;
|
||||
package de.rayzs.pat.plugin.command.commands.server;
|
||||
|
||||
import de.rayzs.pat.api.command.ProCommand;
|
||||
import de.rayzs.pat.plugin.command.commands.ProCommand;
|
||||
import de.rayzs.pat.api.storage.Storage;
|
||||
import de.rayzs.pat.utils.StringUtils;
|
||||
import de.rayzs.pat.utils.sender.CommandSender;
|
||||
import de.rayzs.pat.utils.ExpireCache;
|
||||
import de.rayzs.pat.utils.group.Group;
|
||||
@@ -66,12 +67,14 @@ public class ServClearCommand extends ProCommand {
|
||||
|
||||
if (group == null) {
|
||||
|
||||
sender.sendMessage(
|
||||
Storage.ConfigSections.Messages.GROUP.DOES_NOT_EXIST_SERVER
|
||||
.replace("%group%", groupName)
|
||||
.replace("%server%", serverName)
|
||||
String message = Storage.ConfigSections.Messages.GROUP.DOES_NOT_EXIST_SERVER;
|
||||
|
||||
message = StringUtils.replace(message,
|
||||
"%group%", groupName,
|
||||
"%server%", serverName
|
||||
);
|
||||
|
||||
sender.sendMessage(message);
|
||||
return true;
|
||||
}
|
||||
|
||||
+8
-6
@@ -1,6 +1,6 @@
|
||||
package de.rayzs.pat.plugin.process.impl.server;
|
||||
package de.rayzs.pat.plugin.command.commands.server;
|
||||
|
||||
import de.rayzs.pat.api.command.ProCommand;
|
||||
import de.rayzs.pat.plugin.command.commands.ProCommand;
|
||||
import de.rayzs.pat.api.storage.Storage;
|
||||
import de.rayzs.pat.api.storage.blacklist.impl.GeneralBlacklist;
|
||||
import de.rayzs.pat.api.storage.blacklist.impl.GroupBlacklist;
|
||||
@@ -95,12 +95,14 @@ public class ServRemoveCommand extends ProCommand {
|
||||
|
||||
if (group == null) {
|
||||
|
||||
sender.sendMessage(
|
||||
Storage.ConfigSections.Messages.GROUP.DOES_NOT_EXIST_SERVER
|
||||
.replace("%group%", groupName)
|
||||
.replace("%server%", serverName)
|
||||
String message = Storage.ConfigSections.Messages.GROUP.DOES_NOT_EXIST_SERVER;
|
||||
|
||||
message = StringUtils.replace(message,
|
||||
"%group%", groupName,
|
||||
"%server%", serverName
|
||||
);
|
||||
|
||||
sender.sendMessage(message);
|
||||
return true;
|
||||
}
|
||||
|
||||
+12
-3
@@ -1,6 +1,6 @@
|
||||
package de.rayzs.pat.plugin.process.impl.server.list;
|
||||
package de.rayzs.pat.plugin.command.commands.server.list;
|
||||
|
||||
import de.rayzs.pat.api.command.ProCommand;
|
||||
import de.rayzs.pat.plugin.command.commands.ProCommand;
|
||||
import de.rayzs.pat.api.storage.Storage;
|
||||
import de.rayzs.pat.api.storage.blacklist.impl.GeneralBlacklist;
|
||||
import de.rayzs.pat.utils.sender.CommandSender;
|
||||
@@ -43,6 +43,7 @@ public class ServListCommand extends ProCommand {
|
||||
);
|
||||
|
||||
String message = Storage.ConfigSections.Messages.BLACKLIST.LIST_SERVER_MESSAGE;
|
||||
|
||||
message = StringUtils.replace(message,
|
||||
"%size%", String.valueOf(blacklist.getCommands().size()),
|
||||
"%commands%", commandsListMessage,
|
||||
@@ -57,7 +58,15 @@ public class ServListCommand extends ProCommand {
|
||||
Group group = GroupManager.getGroupByName(groupName);
|
||||
|
||||
if (group == null) {
|
||||
sender.sendMessage(Storage.ConfigSections.Messages.GROUP.DOES_NOT_EXIST_SERVER.replace("%group%", groupName));
|
||||
|
||||
String message = Storage.ConfigSections.Messages.GROUP.DOES_NOT_EXIST_SERVER;
|
||||
|
||||
message = StringUtils.replace(message,
|
||||
"%group%", groupName,
|
||||
"%server%", serverName
|
||||
);
|
||||
|
||||
sender.sendMessage(message);
|
||||
return true;
|
||||
}
|
||||
|
||||
+27
-27
@@ -1,27 +1,27 @@
|
||||
package de.rayzs.pat.plugin.commands;
|
||||
|
||||
import de.rayzs.pat.plugin.process.CommandProcess;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.command.*;
|
||||
import java.util.List;
|
||||
|
||||
public class BukkitCommand implements CommandExecutor, TabCompleter {
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender commandSender, Command command, String label, String[] strings) {
|
||||
if(commandSender instanceof Player) {
|
||||
Player player = (Player) commandSender;
|
||||
|
||||
CommandProcess.handleCommand(player, strings, label);
|
||||
return true;
|
||||
}
|
||||
|
||||
CommandProcess.handleCommand(commandSender, strings, label);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> onTabComplete(CommandSender commandSender, Command command, String label, String[] strings) {
|
||||
return CommandProcess.handleTabComplete(commandSender, strings);
|
||||
}
|
||||
}
|
||||
package de.rayzs.pat.plugin.command.impl;
|
||||
|
||||
import de.rayzs.pat.plugin.command.CommandProcess;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.command.*;
|
||||
import java.util.List;
|
||||
|
||||
public class BukkitCommand implements CommandExecutor, TabCompleter {
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender commandSender, Command command, String label, String[] strings) {
|
||||
if (commandSender instanceof Player) {
|
||||
Player player = (Player) commandSender;
|
||||
|
||||
CommandProcess.handleCommand(player, strings, label);
|
||||
return true;
|
||||
}
|
||||
|
||||
CommandProcess.handleCommand(commandSender, strings, label);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> onTabComplete(CommandSender commandSender, Command command, String label, String[] strings) {
|
||||
return CommandProcess.handleTabComplete(commandSender, strings);
|
||||
}
|
||||
}
|
||||
+22
-22
@@ -1,22 +1,22 @@
|
||||
package de.rayzs.pat.plugin.commands;
|
||||
|
||||
import de.rayzs.pat.plugin.process.CommandProcess;
|
||||
import net.md_5.bungee.api.CommandSender;
|
||||
import net.md_5.bungee.api.plugin.*;
|
||||
|
||||
public class BungeeCommand extends Command implements TabExecutor {
|
||||
|
||||
public BungeeCommand(String name) {
|
||||
super(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(CommandSender commandSender, String[] strings) {
|
||||
CommandProcess.handleCommand(commandSender, strings, "bpat");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterable<String> onTabComplete(CommandSender commandSender, String[] strings) {
|
||||
return CommandProcess.handleTabComplete(commandSender, strings);
|
||||
}
|
||||
}
|
||||
package de.rayzs.pat.plugin.command.impl;
|
||||
|
||||
import de.rayzs.pat.plugin.command.CommandProcess;
|
||||
import net.md_5.bungee.api.CommandSender;
|
||||
import net.md_5.bungee.api.plugin.*;
|
||||
|
||||
public class BungeeCommand extends Command implements TabExecutor {
|
||||
|
||||
public BungeeCommand(String name) {
|
||||
super(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(CommandSender commandSender, String[] strings) {
|
||||
CommandProcess.handleCommand(commandSender, strings, "bpat");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterable<String> onTabComplete(CommandSender commandSender, String[] strings) {
|
||||
return CommandProcess.handleTabComplete(commandSender, strings);
|
||||
}
|
||||
}
|
||||
+18
-18
@@ -1,18 +1,18 @@
|
||||
package de.rayzs.pat.plugin.commands;
|
||||
|
||||
import com.velocitypowered.api.command.SimpleCommand;
|
||||
import de.rayzs.pat.plugin.process.CommandProcess;
|
||||
import java.util.List;
|
||||
|
||||
public class VelocityCommand implements SimpleCommand {
|
||||
|
||||
@Override
|
||||
public void execute(Invocation invocation) {
|
||||
CommandProcess.handleCommand(invocation.source(), invocation.arguments(), "bpat");
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> suggest(Invocation invocation) {
|
||||
return CommandProcess.handleTabComplete(invocation.source(), invocation.arguments());
|
||||
}
|
||||
}
|
||||
package de.rayzs.pat.plugin.command.impl;
|
||||
|
||||
import com.velocitypowered.api.command.SimpleCommand;
|
||||
import de.rayzs.pat.plugin.command.CommandProcess;
|
||||
import java.util.List;
|
||||
|
||||
public class VelocityCommand implements SimpleCommand {
|
||||
|
||||
@Override
|
||||
public void execute(Invocation invocation) {
|
||||
CommandProcess.handleCommand(invocation.source(), invocation.arguments(), "bpat");
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> suggest(Invocation invocation) {
|
||||
return CommandProcess.handleTabComplete(invocation.source(), invocation.arguments());
|
||||
}
|
||||
}
|
||||
@@ -1,9 +1,13 @@
|
||||
package de.rayzs.pat.plugin.listeners.bukkit;
|
||||
|
||||
import de.rayzs.pat.api.event.events.FilteredSuggestionEvent;
|
||||
import de.rayzs.pat.utils.group.Group;
|
||||
import de.rayzs.pat.utils.group.GroupManager;
|
||||
import de.rayzs.pat.utils.scheduler.PATScheduler;
|
||||
import de.rayzs.pat.utils.sender.CommandSender;
|
||||
import org.bukkit.event.player.PlayerCommandSendEvent;
|
||||
import de.rayzs.pat.utils.permission.PermissionUtil;
|
||||
import de.rayzs.pat.utils.adapter.ViaVersionAdapter;
|
||||
import de.rayzs.pat.utils.hooks.ViaVersionHook;
|
||||
import de.rayzs.pat.api.event.PATEventHandler;
|
||||
import de.rayzs.pat.api.storage.Storage;
|
||||
import de.rayzs.pat.plugin.BukkitLoader;
|
||||
@@ -15,58 +19,56 @@ import java.util.*;
|
||||
|
||||
public class BukkitAntiTabListener implements Listener {
|
||||
|
||||
private static final CommandsCache COMMANDS_CACHE = new CommandsCache();
|
||||
private static final List<UUID> knownOperators = new ArrayList<>();
|
||||
private final List<UUID> knownOperators = new ArrayList<>();
|
||||
|
||||
|
||||
@EventHandler (priority = EventPriority.LOWEST)
|
||||
public void onPlayerCommandSend(PlayerCommandSendEvent event) {
|
||||
final Player player = event.getPlayer();
|
||||
final CommandSender sender = CommandSender.from(player);
|
||||
final UUID uuid = player.getUniqueId();
|
||||
|
||||
final boolean noPermissionsPlugin = !Storage.USE_LUCKPERMS && !Storage.USE_GROUPMANAGER;
|
||||
|
||||
|
||||
if (Storage.USE_VELOCITY) {
|
||||
if (Storage.ConfigSections.Settings.HANDLE_THROUGH_PROXY.ENABLED) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (player.isOp()) {
|
||||
|
||||
if (noPermissionsPlugin && !knownOperators.contains(uuid)) {
|
||||
if (!knownOperators.contains(uuid)) {
|
||||
knownOperators.add(uuid);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (!BukkitLoader.isLoaded()) {
|
||||
event.getCommands().clear();
|
||||
return;
|
||||
}
|
||||
|
||||
if (Storage.ConfigSections.Settings.HANDLE_THROUGH_PROXY.ENABLED)
|
||||
return;
|
||||
|
||||
if (event.getCommands().isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
List<String> allCommands = getCommands();
|
||||
COMMANDS_CACHE.handleCommands(allCommands);
|
||||
|
||||
if (PermissionUtil.hasBypassPermission(player)) {
|
||||
|
||||
if (noPermissionsPlugin && knownOperators.contains(uuid)) {
|
||||
PermissionUtil.reloadPermissions(uuid);
|
||||
knownOperators.remove(uuid);
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
Storage.getLoader().getBukkitCommandsCacheMap().handleCommands(Storage.ConfigSections.Settings.TURN_BLACKLIST_TO_WHITELIST.ENABLED
|
||||
? Storage.Blacklist.getBlacklist().getCommands()
|
||||
: BukkitLoader.getAllCommands()
|
||||
);
|
||||
|
||||
if (!player.isOp() && knownOperators.contains(uuid)) {
|
||||
knownOperators.remove(uuid);
|
||||
PermissionUtil.reloadPermissions(sender);
|
||||
}
|
||||
|
||||
final List<String> playerCommands = COMMANDS_CACHE.getPlayerCommands(new ArrayList<>(event.getCommands()), player, player.getUniqueId());
|
||||
FilteredSuggestionEvent filteredSuggestionEvent = PATEventHandler.callFilteredSuggestionEvents(player, playerCommands);
|
||||
if (PermissionUtil.hasBypassPermission(sender)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (Reflection.isCraftbukkit() && !Bukkit.getOnlinePlayers().contains(player)) {
|
||||
event.getCommands().clear();
|
||||
|
||||
PATScheduler.createScheduler(player::updateCommands, 10);
|
||||
return;
|
||||
}
|
||||
|
||||
final List<Group> groups = GroupManager.getPlayerGroups(sender);
|
||||
final List<String> playerCommands = Storage.getLoader().getBukkitCommandsCacheMap().getPlayerCommands(new ArrayList<>(event.getCommands()), sender, groups);
|
||||
final FilteredSuggestionEvent filteredSuggestionEvent = PATEventHandler.callFilteredSuggestionEvents(sender, playerCommands);
|
||||
|
||||
event.getCommands().clear();
|
||||
|
||||
@@ -85,55 +87,12 @@ public class BukkitAntiTabListener implements Listener {
|
||||
}
|
||||
}
|
||||
|
||||
public static List<String> getCommands() {
|
||||
return Storage.ConfigSections.Settings.TURN_BLACKLIST_TO_WHITELIST.ENABLED
|
||||
? Storage.Blacklist.getBlacklist().getCommands() : BukkitLoader.getAllCommands();
|
||||
}
|
||||
|
||||
private static boolean notUpdatablePlayer(UUID uuid) {
|
||||
return Storage.USE_VIAVERSION && Reflection.getMinor() >= 16 && ViaVersionAdapter.getPlayerProtocol(uuid) < 754;
|
||||
return Storage.USE_VIAVERSION && Reflection.isAtLeast(1, 16) && ViaVersionHook.getPlayerProtocol(uuid) < 754;
|
||||
}
|
||||
|
||||
|
||||
// --------------- LUCKPERMS SECTIONS --------------- //
|
||||
|
||||
public static void updateCommands() {
|
||||
Bukkit.getOnlinePlayers().forEach(BukkitAntiTabListener::updateCommands);
|
||||
}
|
||||
|
||||
public static void updateCommands(Player player) {
|
||||
if (Reflection.getMinor() >= 13 && !notUpdatablePlayer(player.getUniqueId()))
|
||||
public void updateCommands(Player player) {
|
||||
if (!notUpdatablePlayer(player.getUniqueId()))
|
||||
player.updateCommands();
|
||||
}
|
||||
|
||||
|
||||
// --------------- UPDATE SECTIONS --------------- //
|
||||
|
||||
public static void handleTabCompletion() {
|
||||
COMMANDS_CACHE.reset();
|
||||
Bukkit.getOnlinePlayers().forEach(BukkitAntiTabListener::handleTabCompletion);
|
||||
}
|
||||
|
||||
public static void handleTabCompletion(UUID uuid) {
|
||||
Player player = Bukkit.getPlayer(uuid);
|
||||
if (player == null)
|
||||
return;
|
||||
|
||||
handleTabCompletion(player);
|
||||
}
|
||||
|
||||
public static void handleTabCompletion(Player player) {
|
||||
handleTabCompletion(player, getCommands());
|
||||
}
|
||||
|
||||
public static void handleTabCompletion(Player player, List<String> commands) {
|
||||
if (notUpdatablePlayer(player.getUniqueId()))
|
||||
return;
|
||||
|
||||
List<String> dummy = new ArrayList<>(commands);
|
||||
PlayerCommandSendEvent event = new PlayerCommandSendEvent(player, dummy);
|
||||
Bukkit.getPluginManager().callEvent(event);
|
||||
updateCommands(player);
|
||||
}
|
||||
|
||||
}
|
||||
+122
-21
@@ -2,6 +2,11 @@ package de.rayzs.pat.plugin.listeners.bukkit;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import de.rayzs.pat.plugin.system.subargument.SubArgument;
|
||||
import de.rayzs.pat.utils.group.Group;
|
||||
import de.rayzs.pat.utils.group.GroupManager;
|
||||
import de.rayzs.pat.utils.response.ResponseHandler;
|
||||
import de.rayzs.pat.utils.sender.CommandSender;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.entity.Player;
|
||||
@@ -22,15 +27,16 @@ public class BukkitBlockCommandListener implements Listener {
|
||||
|
||||
@EventHandler (priority = EventPriority.HIGHEST)
|
||||
public void onUnknownCommandRecognition(PlayerCommandPreprocessEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
World world = player.getWorld();
|
||||
final Player player = event.getPlayer();
|
||||
final CommandSender sender = CommandSender.from(player);
|
||||
final World world = player.getWorld();
|
||||
|
||||
String rawCommand = StringUtils.getFirstArg(event.getMessage()),
|
||||
command = rawCommand.substring(1);
|
||||
|
||||
if (!Storage.ConfigSections.Settings.CUSTOM_UNKNOWN_COMMAND.ENABLED || event.isCancelled()) return;
|
||||
|
||||
if (PermissionUtil.hasBypassPermission(player))
|
||||
if (PermissionUtil.hasBypassPermission(sender))
|
||||
return;
|
||||
|
||||
if (Storage.getLoader().doesCommandExist(command))
|
||||
@@ -45,7 +51,9 @@ public class BukkitBlockCommandListener implements Listener {
|
||||
|
||||
@EventHandler (priority = EventPriority.LOWEST)
|
||||
public void onPlayerCommandProcess(PlayerCommandPreprocessEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
final Player player = event.getPlayer();
|
||||
final CommandSender sender = CommandSender.from(player);
|
||||
|
||||
final String commandFirstArg = StringUtils.getFirstArg(event.getMessage());
|
||||
|
||||
if (Storage.ConfigSections.Settings.AUTO_LOWERCASE_COMMANDS.isCommand(commandFirstArg)) {
|
||||
@@ -68,32 +76,92 @@ public class BukkitBlockCommandListener implements Listener {
|
||||
String command = event.getMessage(),
|
||||
worldName = world.getName();
|
||||
|
||||
boolean bypassPermission = PermissionUtil.hasBypassPermission(player, command);
|
||||
|
||||
command = command.substring(1);
|
||||
final String commandWithArguments = command;
|
||||
|
||||
command = StringUtils.getFirstArg(command);
|
||||
|
||||
final String displayName = StringUtils.replaceTriggers(command, "", "\\", "<", ">", "&");
|
||||
//command = command.toLowerCase();
|
||||
if (Storage.ConfigSections.Settings.HANDLE_THROUGH_PROXY.ENABLED) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (PermissionUtil.hasBypassPermission(sender, command)) {
|
||||
return;
|
||||
}
|
||||
|
||||
final String displayCommand = StringUtils.replaceTriggers(command, "", "\\", "<", ">", "&");
|
||||
|
||||
List<String> notificationMessage = MessageTranslator.replaceMessageList(
|
||||
Storage.ConfigSections.Messages.NOTIFICATION.ALERT,
|
||||
"%player%", player.getName(),
|
||||
"%command%", displayName,
|
||||
"%command%", displayCommand,
|
||||
"%world%", worldName);
|
||||
|
||||
if (bypassPermission)
|
||||
return;
|
||||
if (Storage.ConfigSections.Settings.CUSTOM_PLUGIN.isCommand(command)) {
|
||||
|
||||
if (!Storage.ConfigSections.Settings.CANCEL_COMMAND.ENABLED)
|
||||
return;
|
||||
|
||||
if (Storage.ConfigSections.Settings.HANDLE_THROUGH_PROXY.ENABLED)
|
||||
return;
|
||||
|
||||
if (!Storage.Blacklist.canPlayerAccessChat(player, command)) {
|
||||
ExecuteCommandEvent executeCommandEvent = PATEventHandler.callExecuteCommandEvents(
|
||||
MessageTranslator.send(
|
||||
player,
|
||||
Storage.ConfigSections.Settings.CUSTOM_PLUGIN.MESSAGE,
|
||||
"%command%", StringUtils.getFirstArg(displayCommand)
|
||||
);
|
||||
|
||||
if (Storage.SEND_CONSOLE_NOTIFICATION)
|
||||
Logger.info(notificationMessage);
|
||||
|
||||
Storage.NOTIFY_PLAYERS.forEach(uuid -> {
|
||||
Object p = Storage.getLoader().getPlayerObjByUUID(uuid);
|
||||
if (p != null) {
|
||||
MessageTranslator.send(p, notificationMessage);
|
||||
}
|
||||
});
|
||||
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
|
||||
if (Storage.ConfigSections.Settings.CUSTOM_VERSION.isCommand(command)) {
|
||||
|
||||
MessageTranslator.send(
|
||||
player,
|
||||
Storage.ConfigSections.Settings.CUSTOM_VERSION.MESSAGE,
|
||||
"%command%", StringUtils.getFirstArg(displayCommand)
|
||||
);
|
||||
|
||||
if (Storage.SEND_CONSOLE_NOTIFICATION)
|
||||
Logger.info(notificationMessage);
|
||||
|
||||
Storage.NOTIFY_PLAYERS.forEach(uuid -> {
|
||||
Object p = Storage.getLoader().getPlayerObjByUUID(uuid);
|
||||
if (p != null) {
|
||||
MessageTranslator.send(p, notificationMessage);
|
||||
}
|
||||
});
|
||||
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
|
||||
final boolean cancelBlockedCommand = Storage.ConfigSections.Settings.CANCEL_COMMAND.ENABLED;
|
||||
final List<Group> groups = GroupManager.getPlayerGroups(sender);
|
||||
|
||||
boolean allowed = Storage.Blacklist.canPlayerAccessChat(sender, groups, command);
|
||||
boolean blockedNamespace = false;
|
||||
|
||||
if (!Storage.ConfigSections.Settings.BLOCK_NAMESPACE_COMMANDS.doesBypass(sender)) {
|
||||
blockedNamespace = cancelBlockedCommand
|
||||
? Storage.ConfigSections.Settings.BLOCK_NAMESPACE_COMMANDS.isCommand(command)
|
||||
: Storage.ConfigSections.Settings.BLOCK_NAMESPACE_COMMANDS.doesAlwaysBlock(command);
|
||||
|
||||
if (blockedNamespace) allowed = false;
|
||||
}
|
||||
|
||||
if (!Storage.ConfigSections.Settings.CANCEL_COMMAND.ENABLED && !blockedNamespace) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!allowed) {
|
||||
ExecuteCommandEvent executeCommandEvent = PATEventHandler.callExecuteCommandEvents(
|
||||
sender,
|
||||
event.getMessage(),
|
||||
true,
|
||||
!Storage.ConfigSections.Settings.TURN_BLACKLIST_TO_WHITELIST.ENABLED
|
||||
@@ -102,6 +170,17 @@ public class BukkitBlockCommandListener implements Listener {
|
||||
if (executeCommandEvent.isBlocked()) {
|
||||
event.setCancelled(true);
|
||||
|
||||
MessageTranslator.send(
|
||||
sender,
|
||||
ResponseHandler.getResponse(
|
||||
sender.getUniqueId(),
|
||||
sender.getName(),
|
||||
sender.getServerName(),
|
||||
event.getMessage(),
|
||||
Storage.ConfigSections.Settings.CANCEL_COMMAND.BASE_COMMAND_RESPONSE.getLines()
|
||||
), "%command%", StringUtils.getFirstArg(displayCommand)
|
||||
);
|
||||
|
||||
if (!executeCommandEvent.doesNotify())
|
||||
return;
|
||||
|
||||
@@ -119,8 +198,30 @@ public class BukkitBlockCommandListener implements Listener {
|
||||
return;
|
||||
}
|
||||
|
||||
ExecuteCommandEvent executeCommandEvent = PATEventHandler.callExecuteCommandEvents(player, event.getMessage(), false, false);
|
||||
if (executeCommandEvent.isBlocked())
|
||||
ExecuteCommandEvent executeCommandEvent = PATEventHandler.callExecuteCommandEvents(
|
||||
sender,
|
||||
event.getMessage(),
|
||||
SubArgument.get().getExecuteHandler().handleCommandExecution(sender, event.getMessage()),
|
||||
false
|
||||
);
|
||||
|
||||
if (executeCommandEvent.isBlocked()) {
|
||||
event.setCancelled(true);
|
||||
|
||||
MessageTranslator.send(
|
||||
sender,
|
||||
ResponseHandler.getResponse(
|
||||
sender.getUniqueId(),
|
||||
sender.getName(),
|
||||
sender.getServerName(),
|
||||
event.getMessage()
|
||||
),
|
||||
"%command%",
|
||||
StringUtils.replaceTriggers(
|
||||
commandWithArguments, "",
|
||||
"\\", "<", ">", "&"
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,79 +1,82 @@
|
||||
package de.rayzs.pat.plugin.listeners.bukkit;
|
||||
|
||||
import de.rayzs.pat.api.brand.CustomServerBrand;
|
||||
import de.rayzs.pat.plugin.system.serverbrand.CustomServerBrand;
|
||||
import de.rayzs.pat.api.event.PATEventHandler;
|
||||
import de.rayzs.pat.api.event.events.ServerPlayersChangeEvent;
|
||||
import de.rayzs.pat.api.netty.bukkit.BukkitPacketAnalyzer;
|
||||
import de.rayzs.pat.api.communication.BackendUpdater;
|
||||
import de.rayzs.pat.plugin.packetanalyzer.bukkit.BukkitPacketAnalyzer;
|
||||
import de.rayzs.pat.plugin.system.communication.BackendUpdater;
|
||||
import de.rayzs.pat.plugin.logger.Logger;
|
||||
import de.rayzs.pat.plugin.modules.SubArgsModule;
|
||||
import de.rayzs.pat.utils.Reflection;
|
||||
import de.rayzs.pat.plugin.system.subargument.SubArgument;
|
||||
import de.rayzs.pat.utils.message.MessageTranslator;
|
||||
import de.rayzs.pat.utils.permission.PermissionPlugin;
|
||||
import de.rayzs.pat.utils.permission.PermissionUtil;
|
||||
import de.rayzs.pat.api.storage.Storage;
|
||||
import de.rayzs.pat.utils.scheduler.PATScheduler;
|
||||
import de.rayzs.pat.utils.sender.CommandSender;
|
||||
import de.rayzs.pat.utils.sender.CommandSenderHandler;
|
||||
import org.bukkit.event.player.*;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.*;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
public class BukkitPlayerListener implements Listener {
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerJoin(PlayerJoinEvent event) {
|
||||
final Player player = event.getPlayer();
|
||||
final UUID uuid = player.getUniqueId();
|
||||
final CommandSender sender = CommandSender.from(player);
|
||||
|
||||
PATEventHandler.callServerPlayersChangeEvents(player, ServerPlayersChangeEvent.Type.JOINED);
|
||||
PATEventHandler.callServerPlayersChangeEvents(sender, ServerPlayersChangeEvent.Type.JOINED);
|
||||
SubArgument.get().updateCachedPlayerNames();
|
||||
|
||||
if (Storage.ConfigSections.Settings.HANDLE_THROUGH_PROXY.ENABLED) {
|
||||
BackendUpdater.handle();
|
||||
BackendUpdater.get().handle();
|
||||
}
|
||||
|
||||
PermissionUtil.setPlayerPermissions(player.getUniqueId());
|
||||
CustomServerBrand.preparePlayer(player);
|
||||
CustomServerBrand.get().preparePlayer(player);
|
||||
PermissionUtil.reloadPermissions(sender);
|
||||
|
||||
if (CustomServerBrand.isEnabled()) {
|
||||
CustomServerBrand.sendBrandToPlayer(player);
|
||||
if (CustomServerBrand.get().isEnabled()) {
|
||||
CustomServerBrand.get().sendBrandToPlayer(player);
|
||||
}
|
||||
|
||||
if (!Storage.USE_LUCKPERMS && !Storage.ConfigSections.Settings.HANDLE_THROUGH_PROXY.ENABLED) {
|
||||
PATScheduler.createScheduler(() -> {
|
||||
CommandSender sender = CommandSenderHandler.from(player);
|
||||
if (!Storage.ConfigSections.Settings.HANDLE_THROUGH_PROXY.ENABLED) {
|
||||
if (Storage.getPermissionPlugin() != PermissionPlugin.LUCKPERMS) {
|
||||
|
||||
assert sender != null;
|
||||
PermissionUtil.reloadPermissions(sender);
|
||||
PATScheduler.createScheduler(() -> {
|
||||
|
||||
if (Reflection.getMinor() >= 13) {
|
||||
BukkitAntiTabListener.handleTabCompletion(player.getUniqueId());
|
||||
}
|
||||
}, 20);
|
||||
if (Storage.getPermissionPlugin() == PermissionPlugin.GROUPMANAGER) {
|
||||
PermissionUtil.reloadPermissions(sender);
|
||||
}
|
||||
|
||||
Storage.getLoader().updateCommands(sender);
|
||||
}, 20);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
if (!BukkitPacketAnalyzer.inject(player)) {
|
||||
PATScheduler.createScheduler(() -> {
|
||||
if (player.isOnline()) {
|
||||
if (!BukkitPacketAnalyzer.inject(player)) {
|
||||
Logger.warning("Failed to inject into player! (" + player.getName() + ")" );
|
||||
player.kickPlayer("Failed to inject player!");
|
||||
|
||||
if (Storage.ConfigSections.Settings.INJECTION_FAILED.ENABLED) {
|
||||
|
||||
Logger.info(MessageTranslator.replaceMessage(
|
||||
sender,
|
||||
Storage.ConfigSections.Settings.INJECTION_FAILED.CONSOLE_MESSAGE
|
||||
));
|
||||
|
||||
player.kickPlayer(MessageTranslator.replaceMessage(
|
||||
sender,
|
||||
Storage.ConfigSections.Settings.INJECTION_FAILED.KICK_MESSAGE
|
||||
));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}, 10);
|
||||
}
|
||||
|
||||
if (Reflection.getMinor() < 13) {
|
||||
List<String> playerCommands = new ArrayList<>(SubArgsModule.getServerCommands(uuid));
|
||||
playerCommands.addAll(SubArgsModule.getGroupCommands(uuid));
|
||||
|
||||
PATEventHandler.callUpdatePlayerCommandsEvents(uuid, playerCommands, false);
|
||||
}
|
||||
|
||||
if (Storage.OUTDATED && PermissionUtil.hasPermission(player, "joinupdate")) {
|
||||
if (Storage.OUTDATED && PermissionUtil.hasPermission(sender, "joinupdate")) {
|
||||
PATScheduler.createScheduler(() -> {
|
||||
if (player.isOnline()) {
|
||||
MessageTranslator.send(player, Storage.ConfigSections.Settings.UPDATE.OUTDATED.getLines());
|
||||
@@ -84,8 +87,11 @@ public class BukkitPlayerListener implements Listener {
|
||||
|
||||
@EventHandler (priority = EventPriority.LOWEST)
|
||||
public void onPlayerQuit(PlayerQuitEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
PATEventHandler.callServerPlayersChangeEvents(player, ServerPlayersChangeEvent.Type.LEFT);
|
||||
final Player player = event.getPlayer();
|
||||
final CommandSender sender = CommandSender.from(player);
|
||||
|
||||
PATEventHandler.callServerPlayersChangeEvents(sender, ServerPlayersChangeEvent.Type.LEFT);
|
||||
SubArgument.get().updateCachedPlayerNames();
|
||||
|
||||
BukkitPacketAnalyzer.uninject(player.getUniqueId());
|
||||
PermissionUtil.resetPermissions(player.getUniqueId());
|
||||
@@ -96,18 +102,15 @@ public class BukkitPlayerListener implements Listener {
|
||||
Player player = event.getPlayer();
|
||||
|
||||
if (Storage.ConfigSections.Settings.CUSTOM_BRAND.REPEAT_DELAY == -1) {
|
||||
CustomServerBrand.sendBrandToPlayer(player);
|
||||
CustomServerBrand.get().sendBrandToPlayer(player);
|
||||
}
|
||||
|
||||
if (Storage.ConfigSections.Settings.UPDATE_COMMANDS_PER_WORLD.ENABLED) {
|
||||
CommandSender sender = CommandSenderHandler.from(player);
|
||||
if (Storage.ConfigSections.Settings.UPDATE_GROUPS_PER_WORLD.ENABLED) {
|
||||
CommandSender sender = CommandSender.from(player);
|
||||
|
||||
assert sender != null;
|
||||
PermissionUtil.reloadPermissions(sender);
|
||||
|
||||
if (Reflection.getMinor() >= 13) {
|
||||
BukkitAntiTabListener.handleTabCompletion(player);
|
||||
}
|
||||
Storage.getLoader().updateCommands(sender);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -13,7 +13,6 @@ import org.bukkit.profile.PlayerTextures;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import javax.swing.plaf.BorderUIResource;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
@@ -39,7 +38,6 @@ public class PaperServerListPing implements Listener {
|
||||
String versionName = Storage.ConfigSections.Settings.CUSTOM_PROTOCOL_PING.PROTOCOL.replace("%online_extended%", String.valueOf(onlineExtend)).replace("%online%", String.valueOf(online)).replace("%max%", String.valueOf(max));
|
||||
if (Storage.ConfigSections.Settings.CUSTOM_PROTOCOL_PING.HIDE_PLAYERS) {
|
||||
event.getPlayerSample().clear();
|
||||
event.setHidePlayers(true);
|
||||
}
|
||||
|
||||
else if (Storage.ConfigSections.Settings.CUSTOM_PROTOCOL_PING.USE_CUSTOM_PLAYERLIST) {
|
||||
@@ -53,8 +51,9 @@ public class PaperServerListPing implements Listener {
|
||||
|
||||
} else {
|
||||
|
||||
Storage.ConfigSections.Settings.CUSTOM_PROTOCOL_PING.PLAYERLIST.getLines().forEach(line -> {
|
||||
final List<String> lines = new ArrayList<>();
|
||||
|
||||
for (String line : Storage.ConfigSections.Settings.CUSTOM_PROTOCOL_PING.PLAYERLIST.getLines()) {
|
||||
if (line.contains("%players%")) {
|
||||
List<String> playerNames = Storage.getLoader().getOnlinePlayerNames();
|
||||
|
||||
@@ -67,7 +66,7 @@ public class PaperServerListPing implements Listener {
|
||||
"%players%", currentPlayerName, "&", "§"
|
||||
);
|
||||
|
||||
event.getPlayerSample().add(new ProtocolHoverLine(playerName, RANDOM_UUID));
|
||||
lines.add(playerName);
|
||||
}
|
||||
|
||||
} else {
|
||||
@@ -79,14 +78,47 @@ public class PaperServerListPing implements Listener {
|
||||
? Arrays.copyOfRange(nameSplit, 0, 30)
|
||||
: nameSplit;
|
||||
|
||||
for (String name : nameSplit) {
|
||||
event.getPlayerSample().add(new ProtocolHoverLine(name, RANDOM_UUID));
|
||||
}
|
||||
|
||||
lines.addAll(Arrays.asList(nameSplit));
|
||||
} else {
|
||||
event.getPlayerSample().add(new ProtocolHoverLine(playerName, RANDOM_UUID));
|
||||
lines.add(playerName);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (Storage.ConfigSections.Settings.CUSTOM_PROTOCOL_PING.USE_CENTER_VARIABLE) {
|
||||
|
||||
int biggestLine = 0;
|
||||
for (int i = 0; i < lines.size(); i++) {
|
||||
String line = replaceString(lines.get(i), online, onlineExtend, max);
|
||||
lines.set(i, line);
|
||||
|
||||
if (line.startsWith("%center%")) {
|
||||
biggestLine = Math.max(biggestLine, Math.max(0, line.length() - 8));
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < lines.size(); i++) {
|
||||
String line = lines.get(i);
|
||||
|
||||
if (line.startsWith("%center%")) {
|
||||
int length = Math.max(0, line.length() - 8);
|
||||
int diff = biggestLine - length;
|
||||
|
||||
int left = diff / 2;
|
||||
int right = diff - left;
|
||||
|
||||
line = " ".repeat(left)
|
||||
+ line.substring(8)
|
||||
+ " ".repeat(right);
|
||||
|
||||
lines.set(i, line);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
lines.forEach(line -> {
|
||||
event.getPlayerSample().add(new ProtocolHoverLine(line, RANDOM_UUID));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,27 +2,47 @@ package de.rayzs.pat.plugin.listeners.bungee;
|
||||
|
||||
import de.rayzs.pat.api.event.PATEventHandler;
|
||||
import de.rayzs.pat.api.event.events.FilteredTabCompletionEvent;
|
||||
import de.rayzs.pat.plugin.packetanalyzer.proxy.BungeePacketAnalyzer;
|
||||
import de.rayzs.pat.api.storage.Storage;
|
||||
import de.rayzs.pat.utils.StringUtils;
|
||||
import de.rayzs.pat.utils.group.Group;
|
||||
import de.rayzs.pat.utils.group.GroupManager;
|
||||
import de.rayzs.pat.utils.permission.PermissionUtil;
|
||||
import de.rayzs.pat.utils.sender.CommandSender;
|
||||
import net.md_5.bungee.api.config.ServerInfo;
|
||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||
import net.md_5.bungee.api.event.TabCompleteEvent;
|
||||
import net.md_5.bungee.api.event.TabCompleteResponseEvent;
|
||||
import net.md_5.bungee.api.plugin.Listener;
|
||||
import net.md_5.bungee.event.EventHandler;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class BungeeAntiTabListener implements Listener {
|
||||
|
||||
@EventHandler
|
||||
public void onTabComplete(TabCompleteEvent event) {
|
||||
if(!(event.getSender() instanceof ProxiedPlayer)) return;
|
||||
public void onTabCompleteResponse(TabCompleteResponseEvent event) {
|
||||
|
||||
ProxiedPlayer player = (ProxiedPlayer) event.getSender();
|
||||
if(!(event.getReceiver() instanceof ProxiedPlayer)) return;
|
||||
|
||||
ProxiedPlayer player = (ProxiedPlayer) event.getReceiver();
|
||||
CommandSender sender = CommandSender.from(player);
|
||||
|
||||
ServerInfo serverInfo = player.getServer().getInfo();
|
||||
String serverName = serverInfo.getName();
|
||||
String cursor = event.getCursor().substring(1);
|
||||
|
||||
String rawCursor = BungeePacketAnalyzer.getPlayerInput(player);
|
||||
|
||||
if (rawCursor == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!rawCursor.startsWith("/")) {
|
||||
return;
|
||||
}
|
||||
|
||||
String cursor = rawCursor.substring(1);
|
||||
|
||||
if (event.getSuggestions().isEmpty())
|
||||
return;
|
||||
@@ -30,19 +50,63 @@ public class BungeeAntiTabListener implements Listener {
|
||||
if (Storage.Blacklist.isDisabledServer(serverName))
|
||||
return;
|
||||
|
||||
if (PermissionUtil.hasBypassPermission(player))
|
||||
if (PermissionUtil.hasBypassPermission(sender))
|
||||
return;
|
||||
|
||||
FilteredTabCompletionEvent filteredTabCompletionEvent = PATEventHandler.callFilteredTabCompletionEvents(player, cursor, event.getSuggestions());
|
||||
List<String> suggestions = filteredTabCompletionEvent.getCompletion();
|
||||
|
||||
event.getSuggestions().removeIf(suggestion -> {
|
||||
|
||||
if (Storage.ConfigSections.Settings.CUSTOM_PLUGIN.isTabCompletable(suggestion) || Storage.ConfigSections.Settings.CUSTOM_VERSION.isTabCompletable(suggestion)) {
|
||||
final List<Group> groups = GroupManager.getPlayerGroups(sender);
|
||||
final boolean doesBypassNamespace = Storage.ConfigSections.Settings.BLOCK_NAMESPACE_COMMANDS.doesBypass(sender);
|
||||
final boolean spaces = cursor.contains(" ");
|
||||
|
||||
boolean cancelsBeforeHand = false;
|
||||
|
||||
if (Storage.ConfigSections.Settings.BLOCK_NAMESPACE_COMMANDS.isCommand(cursor) && !doesBypassNamespace) {
|
||||
cancelsBeforeHand = true;
|
||||
}
|
||||
|
||||
if (!cancelsBeforeHand && !cursor.isEmpty()) {
|
||||
cancelsBeforeHand = !Storage.Blacklist.canPlayerAccessTab(sender, groups, StringUtils.getFirstArg(cursor), serverName);
|
||||
}
|
||||
|
||||
if (!cancelsBeforeHand) {
|
||||
cancelsBeforeHand = Storage.ConfigSections.Settings.CUSTOM_PLUGIN.isCommand(cursor) || Storage.ConfigSections.Settings.CUSTOM_VERSION.isCommand(cursor);
|
||||
}
|
||||
|
||||
if (spaces) {
|
||||
if (cancelsBeforeHand) {
|
||||
event.getSuggestions().clear();
|
||||
return;
|
||||
}
|
||||
|
||||
FilteredTabCompletionEvent filteredTabCompletionEvent = PATEventHandler.callFilteredTabCompletionEvents(sender, rawCursor, new ArrayList<>(event.getSuggestions()));
|
||||
|
||||
if (filteredTabCompletionEvent.isCancelled()) {
|
||||
event.getSuggestions().clear();
|
||||
} else {
|
||||
event.getSuggestions().removeIf(s -> !filteredTabCompletionEvent.getCompletion().contains(s));
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
event.getSuggestions().removeIf(s -> {
|
||||
String cpy = s;
|
||||
if (cpy.startsWith("/")) {
|
||||
cpy = cpy.substring(1);
|
||||
}
|
||||
|
||||
if (Storage.ConfigSections.Settings.CUSTOM_PLUGIN.isTabCompletable(cpy) || Storage.ConfigSections.Settings.CUSTOM_VERSION.isTabCompletable(cpy)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return !suggestions.contains(suggestion);
|
||||
return !Storage.Blacklist.canPlayerAccessTab(sender, groups, cpy, serverName);
|
||||
});
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onTabComplete(TabCompleteEvent event) {
|
||||
ProxiedPlayer player = (ProxiedPlayer) event.getSender();
|
||||
BungeePacketAnalyzer.setPlayerInput(player, event.getCursor());
|
||||
}
|
||||
}
|
||||
+122
-14
@@ -1,8 +1,14 @@
|
||||
package de.rayzs.pat.plugin.listeners.bungee;
|
||||
|
||||
import de.rayzs.pat.plugin.system.communication.Communicator;
|
||||
import de.rayzs.pat.api.event.events.ExecuteCommandEvent;
|
||||
import de.rayzs.pat.plugin.system.subargument.SubArgument;
|
||||
import de.rayzs.pat.utils.group.Group;
|
||||
import de.rayzs.pat.utils.group.GroupManager;
|
||||
import de.rayzs.pat.utils.permission.PermissionUtil;
|
||||
import de.rayzs.pat.utils.message.MessageTranslator;
|
||||
import de.rayzs.pat.utils.response.ResponseHandler;
|
||||
import de.rayzs.pat.utils.sender.CommandSender;
|
||||
import net.md_5.bungee.api.event.ChatEvent;
|
||||
import net.md_5.bungee.api.plugin.Listener;
|
||||
import de.rayzs.pat.plugin.logger.Logger;
|
||||
@@ -20,38 +26,105 @@ public class BungeeBlockCommandListener implements Listener {
|
||||
public void onChat(ChatEvent event) {
|
||||
if (event.isCancelled()) return;
|
||||
|
||||
Connection connection = event.getSender();
|
||||
final Connection connection = event.getSender();
|
||||
if (! (connection instanceof ProxiedPlayer) || !event.getMessage().startsWith("/"))
|
||||
return;
|
||||
|
||||
ProxiedPlayer player = (ProxiedPlayer) connection;
|
||||
String serverName = player.getServer().getInfo().getName();
|
||||
final ProxiedPlayer player = (ProxiedPlayer) connection;
|
||||
final CommandSender sender = CommandSender.from(player);
|
||||
final String serverName = player.getServer().getInfo().getName();
|
||||
|
||||
String command = event.getMessage();
|
||||
|
||||
boolean bypassPermission = PermissionUtil.hasBypassPermission(player, command);
|
||||
|
||||
if (bypassPermission)
|
||||
if (PermissionUtil.hasBypassPermission(sender, command) || Storage.Blacklist.isDisabledServer(serverName))
|
||||
return;
|
||||
|
||||
command = command.startsWith("/") ? command.substring(1) : command;
|
||||
final String commandWithArguments = command;
|
||||
command = StringUtils.getFirstArg(command);
|
||||
|
||||
if (Communicator.get().hasConnectedClients() && Storage.ConfigSections.Settings.AUTO_LOWERCASE_COMMANDS.isCommand(command)) {
|
||||
command = command.toLowerCase();
|
||||
}
|
||||
|
||||
final String displayCommand = StringUtils.replaceTriggers(command, "", "\\", "<", ">", "&");
|
||||
|
||||
//command = command.toLowerCase();
|
||||
|
||||
List<String> notificationMessage = MessageTranslator.replaceMessageList(
|
||||
final List<String> notificationMessage = MessageTranslator.replaceMessageList(
|
||||
Storage.ConfigSections.Messages.NOTIFICATION.ALERT,
|
||||
"%player%", player.getName(),
|
||||
"%command%", displayCommand,
|
||||
"%server%", serverName);
|
||||
|
||||
if (!Storage.ConfigSections.Settings.CANCEL_COMMAND.ENABLED)
|
||||
return;
|
||||
if (Storage.ConfigSections.Settings.CUSTOM_PLUGIN.isCommand(command)) {
|
||||
|
||||
if (!Storage.Blacklist.canPlayerAccessChat(player, command, serverName)) {
|
||||
ExecuteCommandEvent executeCommandEvent = PATEventHandler.callExecuteCommandEvents(
|
||||
Communicator.Proxy2Backend.sendNotification(player.getUniqueId(), serverName, displayCommand);
|
||||
|
||||
MessageTranslator.send(
|
||||
player,
|
||||
Storage.ConfigSections.Settings.CUSTOM_PLUGIN.MESSAGE,
|
||||
"%command%", StringUtils.getFirstArg(displayCommand)
|
||||
);
|
||||
|
||||
if (Storage.SEND_CONSOLE_NOTIFICATION)
|
||||
Logger.info(notificationMessage);
|
||||
|
||||
Storage.NOTIFY_PLAYERS.stream().forEach(uuid -> {
|
||||
Object p = Storage.getLoader().getPlayerObjByUUID(uuid);
|
||||
if (p != null) {
|
||||
MessageTranslator.send(p, notificationMessage);
|
||||
}
|
||||
});
|
||||
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
|
||||
if (Storage.ConfigSections.Settings.CUSTOM_VERSION.isCommand(command)) {
|
||||
|
||||
Communicator.Proxy2Backend.sendNotification(player.getUniqueId(), serverName, displayCommand);
|
||||
|
||||
MessageTranslator.send(
|
||||
player,
|
||||
Storage.ConfigSections.Settings.CUSTOM_VERSION.MESSAGE,
|
||||
"%command%", StringUtils.getFirstArg(displayCommand)
|
||||
);
|
||||
|
||||
if (Storage.SEND_CONSOLE_NOTIFICATION)
|
||||
Logger.info(notificationMessage);
|
||||
|
||||
Storage.NOTIFY_PLAYERS.forEach(uuid -> {
|
||||
Object p = Storage.getLoader().getPlayerObjByUUID(uuid);
|
||||
if (p != null) {
|
||||
MessageTranslator.send(p, notificationMessage);
|
||||
}
|
||||
});
|
||||
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
|
||||
final List<Group> groups = GroupManager.getPlayerGroups(sender);
|
||||
final boolean cancelBlockedCommand = Storage.ConfigSections.Settings.CANCEL_COMMAND.ENABLED;
|
||||
|
||||
boolean allowed = Storage.Blacklist.canPlayerAccessChat(sender, groups, command, serverName);
|
||||
boolean blockedNamespace = false;
|
||||
|
||||
if (!Storage.ConfigSections.Settings.BLOCK_NAMESPACE_COMMANDS.doesBypass(sender)) {
|
||||
blockedNamespace = cancelBlockedCommand
|
||||
? Storage.ConfigSections.Settings.BLOCK_NAMESPACE_COMMANDS.isCommand(command)
|
||||
: Storage.ConfigSections.Settings.BLOCK_NAMESPACE_COMMANDS.doesAlwaysBlock(command);
|
||||
|
||||
if (blockedNamespace) allowed = false;
|
||||
}
|
||||
|
||||
if (!Storage.ConfigSections.Settings.CANCEL_COMMAND.ENABLED && !blockedNamespace) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!allowed) {
|
||||
ExecuteCommandEvent executeCommandEvent = PATEventHandler.callExecuteCommandEvents(
|
||||
sender,
|
||||
event.getMessage(),
|
||||
true,
|
||||
!Storage.ConfigSections.Settings.TURN_BLACKLIST_TO_WHITELIST.ENABLED
|
||||
@@ -60,9 +133,22 @@ public class BungeeBlockCommandListener implements Listener {
|
||||
if (executeCommandEvent.isBlocked()) {
|
||||
event.setCancelled(true);
|
||||
|
||||
MessageTranslator.send(
|
||||
sender,
|
||||
ResponseHandler.getResponse(
|
||||
sender.getUniqueId(),
|
||||
sender.getName(),
|
||||
serverName,
|
||||
event.getMessage(),
|
||||
Storage.ConfigSections.Settings.CANCEL_COMMAND.BASE_COMMAND_RESPONSE.getLines()
|
||||
), "%command%", StringUtils.getFirstArg(displayCommand)
|
||||
);
|
||||
|
||||
if (!executeCommandEvent.doesNotify())
|
||||
return;
|
||||
|
||||
Communicator.Proxy2Backend.sendNotification(player.getUniqueId(), serverName, displayCommand);
|
||||
|
||||
if (Storage.SEND_CONSOLE_NOTIFICATION)
|
||||
Logger.info(notificationMessage);
|
||||
|
||||
@@ -80,8 +166,30 @@ public class BungeeBlockCommandListener implements Listener {
|
||||
return;
|
||||
}
|
||||
|
||||
ExecuteCommandEvent executeCommandEvent = PATEventHandler.callExecuteCommandEvents(player, event.getMessage(), false, false);
|
||||
if (executeCommandEvent.isBlocked())
|
||||
ExecuteCommandEvent executeCommandEvent = PATEventHandler.callExecuteCommandEvents(
|
||||
sender,
|
||||
event.getMessage(),
|
||||
SubArgument.get().getExecuteHandler().handleCommandExecution(sender, event.getMessage()),
|
||||
false
|
||||
);
|
||||
|
||||
if (executeCommandEvent.isBlocked()) {
|
||||
event.setCancelled(true);
|
||||
|
||||
MessageTranslator.send(
|
||||
sender,
|
||||
ResponseHandler.getResponse(
|
||||
sender.getUniqueId(),
|
||||
sender.getName(),
|
||||
serverName,
|
||||
event.getMessage()
|
||||
),
|
||||
"%command%",
|
||||
StringUtils.replaceTriggers(
|
||||
commandWithArguments, "",
|
||||
"\\", "<", ">", "&"
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -8,6 +8,7 @@ import de.rayzs.pat.plugin.*;
|
||||
import net.md_5.bungee.event.*;
|
||||
import net.md_5.bungee.api.*;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class BungeePingListener implements Listener {
|
||||
@@ -44,8 +45,43 @@ public class BungeePingListener implements Listener {
|
||||
List<String> lines = Storage.ConfigSections.Settings.CUSTOM_PROTOCOL_PING.PLAYERLIST.getLines();
|
||||
ServerPing.PlayerInfo[] playerInfos = new ServerPing.PlayerInfo[lines.size()];
|
||||
|
||||
for (int i = 0; i < lines.size(); i++) {
|
||||
playerInfos[i] = new ServerPing.PlayerInfo(replaceString(lines.get(i), online, onlineExtend, max), "");
|
||||
if (!Storage.ConfigSections.Settings.CUSTOM_PROTOCOL_PING.USE_CENTER_VARIABLE) {
|
||||
|
||||
for (int i = 0; i < lines.size(); i++) {
|
||||
String line = replaceString(lines.get(i), online, onlineExtend, max);
|
||||
playerInfos[i] = new ServerPing.PlayerInfo(line, "");
|
||||
}
|
||||
|
||||
} else {
|
||||
List<String> cpyLines = new ArrayList<>(Storage.ConfigSections.Settings.CUSTOM_PROTOCOL_PING.PLAYERLIST.getLines());
|
||||
|
||||
int biggestLine = 0;
|
||||
for (int i = 0; i < cpyLines.size(); i++) {
|
||||
String line = replaceString(cpyLines.get(i), online, onlineExtend, max);
|
||||
cpyLines.set(i, line);
|
||||
|
||||
if (line.startsWith("%center%")) {
|
||||
biggestLine = Math.max(biggestLine, Math.max(0, line.length() - 8));
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < cpyLines.size(); i++) {
|
||||
String line = cpyLines.get(i);
|
||||
|
||||
if (line.startsWith("%center%")) {
|
||||
int length = Math.max(0, line.length() - 8);
|
||||
int diff = biggestLine - length;
|
||||
|
||||
int left = diff / 2;
|
||||
int right = diff - left;
|
||||
|
||||
line = " ".repeat(left)
|
||||
+ line.substring(8)
|
||||
+ " ".repeat(right);
|
||||
}
|
||||
|
||||
playerInfos[i] = new ServerPing.PlayerInfo(line, "");
|
||||
}
|
||||
}
|
||||
|
||||
serverPing.getPlayers().setSample(playerInfos);
|
||||
|
||||
+32
-15
@@ -1,11 +1,13 @@
|
||||
package de.rayzs.pat.plugin.listeners.bungee;
|
||||
|
||||
import de.rayzs.pat.api.brand.CustomServerBrand;
|
||||
import de.rayzs.pat.plugin.system.serverbrand.CustomServerBrand;
|
||||
import de.rayzs.pat.api.event.PATEventHandler;
|
||||
import de.rayzs.pat.api.event.events.ServerPlayersChangeEvent;
|
||||
import de.rayzs.pat.api.netty.proxy.BungeePacketAnalyzer;
|
||||
import de.rayzs.pat.plugin.packetanalyzer.proxy.BungeePacketAnalyzer;
|
||||
import de.rayzs.pat.plugin.system.subargument.SubArgument;
|
||||
import de.rayzs.pat.utils.permission.PermissionUtil;
|
||||
import de.rayzs.pat.utils.message.MessageTranslator;
|
||||
import de.rayzs.pat.utils.sender.CommandSender;
|
||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||
import net.md_5.bungee.api.plugin.Listener;
|
||||
import de.rayzs.pat.api.storage.Storage;
|
||||
@@ -19,17 +21,20 @@ public class BungeePlayerConnectionListener implements Listener {
|
||||
|
||||
@EventHandler (priority = EventPriority.LOWEST)
|
||||
public void onPostLogin(PostLoginEvent event) {
|
||||
ProxiedPlayer player = event.getPlayer();
|
||||
PATEventHandler.callServerPlayersChangeEvents(player, ServerPlayersChangeEvent.Type.JOINED);
|
||||
final ProxiedPlayer player = event.getPlayer();
|
||||
final CommandSender sender = CommandSender.from(player);
|
||||
|
||||
if(CustomServerBrand.isEnabled())
|
||||
PATEventHandler.callServerPlayersChangeEvents(sender, ServerPlayersChangeEvent.Type.JOINED);
|
||||
SubArgument.get().updateCachedPlayerNames();
|
||||
|
||||
if(CustomServerBrand.get().isEnabled())
|
||||
ProxyServer.getInstance().getScheduler().schedule(BungeeLoader.getPlugin(), () -> {
|
||||
if (player.isConnected()) CustomServerBrand.sendBrandToPlayer(player);
|
||||
if (player.isConnected()) CustomServerBrand.get().sendBrandToPlayer(player);
|
||||
}, 500, TimeUnit.MILLISECONDS);
|
||||
|
||||
PermissionUtil.setPlayerPermissions(player.getUniqueId());
|
||||
PermissionUtil.setPlayerPermissions(sender);
|
||||
|
||||
if(Storage.OUTDATED && PermissionUtil.hasPermission(player, "joinupdate")) {
|
||||
if (Storage.OUTDATED && PermissionUtil.hasPermission(sender, "joinupdate")) {
|
||||
ProxyServer.getInstance().getScheduler().schedule(BungeeLoader.getPlugin(), () -> {
|
||||
if (player.isConnected()) {
|
||||
MessageTranslator.send(player, Storage.ConfigSections.Settings.UPDATE.OUTDATED, "%player%", player.getName());
|
||||
@@ -44,23 +49,35 @@ public class BungeePlayerConnectionListener implements Listener {
|
||||
|
||||
BungeePacketAnalyzer.inject(player);
|
||||
|
||||
if (Storage.ConfigSections.Settings.CUSTOM_BRAND.REPEAT_DELAY != -1)
|
||||
return;
|
||||
if (Storage.ConfigSections.Settings.UPDATE_GROUPS_PER_SERVER.ENABLED) {
|
||||
CommandSender sender = CommandSender.from(player);
|
||||
|
||||
CustomServerBrand.sendBrandToPlayer(player);
|
||||
assert sender != null;
|
||||
PermissionUtil.reloadPermissions(sender);
|
||||
}
|
||||
|
||||
if (Storage.ConfigSections.Settings.CUSTOM_BRAND.REPEAT_DELAY != -1) {
|
||||
return;
|
||||
}
|
||||
|
||||
CustomServerBrand.get().sendBrandToPlayer(player);
|
||||
}
|
||||
|
||||
@EventHandler (priority = EventPriority.LOWEST)
|
||||
public void onPlayerDisconnectEvent(PlayerDisconnectEvent event) {
|
||||
ProxiedPlayer player = event.getPlayer();
|
||||
PATEventHandler.callServerPlayersChangeEvents(player, ServerPlayersChangeEvent.Type.LEFT);
|
||||
final ProxiedPlayer player = event.getPlayer();
|
||||
final CommandSender sender = CommandSender.from(player);
|
||||
|
||||
PATEventHandler.callServerPlayersChangeEvents(sender, ServerPlayersChangeEvent.Type.LEFT);
|
||||
SubArgument.get().updateCachedPlayerNames();
|
||||
|
||||
PermissionUtil.resetPermissions(player.getUniqueId());
|
||||
BungeePacketAnalyzer.uninject(player);
|
||||
|
||||
if (Storage.ConfigSections.Settings.CUSTOM_BRAND.REPEAT_DELAY != -1)
|
||||
if (Storage.ConfigSections.Settings.CUSTOM_BRAND.REPEAT_DELAY != -1) {
|
||||
return;
|
||||
}
|
||||
|
||||
CustomServerBrand.sendBrandToPlayer(player);
|
||||
CustomServerBrand.get().sendBrandToPlayer(player);
|
||||
}
|
||||
}
|
||||
@@ -9,7 +9,10 @@ import de.rayzs.pat.api.event.PATEventHandler;
|
||||
import de.rayzs.pat.api.event.events.FilteredSuggestionEvent;
|
||||
import de.rayzs.pat.api.storage.Storage;
|
||||
import de.rayzs.pat.utils.CommandsCache;
|
||||
import de.rayzs.pat.utils.group.Group;
|
||||
import de.rayzs.pat.utils.group.GroupManager;
|
||||
import de.rayzs.pat.utils.permission.PermissionUtil;
|
||||
import de.rayzs.pat.utils.sender.CommandSender;
|
||||
import io.github.waterfallmc.waterfall.event.ProxyDefineCommandsEvent;
|
||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||
import net.md_5.bungee.api.plugin.Command;
|
||||
@@ -21,29 +24,33 @@ public class WaterfallAntiTabListener implements Listener {
|
||||
|
||||
@EventHandler(priority = EventPriority.LOWEST)
|
||||
public void onProxyDefineCommands(ProxyDefineCommandsEvent event) {
|
||||
if(!(event.getReceiver() instanceof ProxiedPlayer) || event.getCommands().isEmpty()) return;
|
||||
|
||||
ProxiedPlayer player = (ProxiedPlayer) event.getReceiver();
|
||||
String serverName = player.getServer().getInfo().getName();
|
||||
|
||||
if (Storage.Blacklist.isDisabledServer(serverName))
|
||||
if (!(event.getReceiver() instanceof ProxiedPlayer) || event.getCommands().isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
Map<String, CommandsCache> cache = Storage.getLoader().getCommandsCacheMap();
|
||||
final ProxiedPlayer player = (ProxiedPlayer) event.getReceiver();
|
||||
final CommandSender sender = CommandSender.from(player);
|
||||
final String serverName = player.getServer().getInfo().getName();
|
||||
|
||||
if(!cache.containsKey(serverName))
|
||||
if (Storage.Blacklist.isDisabledServer(serverName) || PermissionUtil.hasBypassPermission(sender)) {
|
||||
return;
|
||||
}
|
||||
|
||||
final List<Group> groups = GroupManager.getPlayerGroups(sender);
|
||||
final Map<String, CommandsCache> cache = Storage.getLoader().getPerServerCommandsCacheMap();
|
||||
|
||||
if (!cache.containsKey(serverName)) {
|
||||
cache.put(serverName, new CommandsCache());
|
||||
}
|
||||
|
||||
CommandsCache commandsCache = cache.get(serverName);
|
||||
List<String> commandsAsString = new ArrayList<>();
|
||||
HashMap<String, Command> commandsMap = new HashMap<>(event.getCommands());
|
||||
final CommandsCache commandsCache = cache.get(serverName);
|
||||
final List<String> commandsAsString = new ArrayList<>();
|
||||
final HashMap<String, Command> commandsMap = new HashMap<>(event.getCommands());
|
||||
|
||||
event.getCommands().forEach((key, value) -> commandsAsString.add(key));
|
||||
commandsCache.handleCommands(commandsAsString, serverName);
|
||||
|
||||
if (PermissionUtil.hasBypassPermission(player)) return;
|
||||
|
||||
List<String> playerCommands = commandsCache.getPlayerCommands(commandsAsString, player, player.getUniqueId(), serverName);
|
||||
List<String> playerCommands = commandsCache.getPlayerCommands(commandsAsString, sender, groups, serverName);
|
||||
event.getCommands().entrySet().removeIf(command -> {
|
||||
|
||||
if (Storage.ConfigSections.Settings.CUSTOM_PLUGIN.isTabCompletable(command.getKey()) || Storage.ConfigSections.Settings.CUSTOM_VERSION.isTabCompletable(command.getKey())) {
|
||||
@@ -53,7 +60,7 @@ public class WaterfallAntiTabListener implements Listener {
|
||||
return playerCommands.contains(command.getKey());
|
||||
});
|
||||
|
||||
FilteredSuggestionEvent filteredSuggestionEvent = PATEventHandler.callFilteredSuggestionEvents(player, new ArrayList<>(event.getCommands().keySet()));
|
||||
FilteredSuggestionEvent filteredSuggestionEvent = PATEventHandler.callFilteredSuggestionEvents(sender, new ArrayList<>(event.getCommands().keySet()));
|
||||
if (filteredSuggestionEvent.isCancelled()) event.getCommands().clear();
|
||||
|
||||
for (String commandName : filteredSuggestionEvent.getSuggestions()) {
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package de.rayzs.pat.plugin.listeners.velocity;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@@ -15,8 +14,12 @@ import com.velocitypowered.api.proxy.ProxyServer;
|
||||
import de.rayzs.pat.api.event.PATEventHandler;
|
||||
import de.rayzs.pat.api.event.events.FilteredSuggestionEvent;
|
||||
import de.rayzs.pat.api.storage.Storage;
|
||||
import de.rayzs.pat.plugin.logger.Logger;
|
||||
import de.rayzs.pat.utils.CommandsCache;
|
||||
import de.rayzs.pat.utils.group.Group;
|
||||
import de.rayzs.pat.utils.group.GroupManager;
|
||||
import de.rayzs.pat.utils.permission.PermissionUtil;
|
||||
import de.rayzs.pat.utils.sender.CommandSender;
|
||||
|
||||
public class VelocityAntiTabListener {
|
||||
|
||||
@@ -28,55 +31,77 @@ public class VelocityAntiTabListener {
|
||||
|
||||
@Subscribe (order = PostOrder.LAST)
|
||||
public void onTabComplete(TabCompleteEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
String serverName = player.getCurrentServer().isPresent() ? player.getCurrentServer().get().getServerInfo().getName() : "unknown";
|
||||
final Player player = event.getPlayer();
|
||||
|
||||
if (Storage.Blacklist.isDisabledServer(serverName))
|
||||
if (!event.getPartialMessage().startsWith("/")) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (PermissionUtil.hasBypassPermission(player) || event.getSuggestions().isEmpty() || !player.getCurrentServer().isPresent()) return;
|
||||
final String serverName = player.getCurrentServer().isPresent() ? player.getCurrentServer().get().getServerInfo().getName() : "unknown";
|
||||
|
||||
if (Storage.Blacklist.isDisabledServer(serverName)) {
|
||||
return;
|
||||
}
|
||||
|
||||
final CommandSender sender = CommandSender.from(player);
|
||||
|
||||
if (PermissionUtil.hasBypassPermission(sender) || event.getSuggestions().isEmpty() || player.getCurrentServer().isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
final List<Group> groups = GroupManager.getPlayerGroups(sender);
|
||||
|
||||
event.getSuggestions().removeIf(command -> {
|
||||
if (Storage.ConfigSections.Settings.CUSTOM_PLUGIN.isTabCompletable(command) || Storage.ConfigSections.Settings.CUSTOM_VERSION.isTabCompletable(command)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return !Storage.Blacklist.canPlayerAccessTab(player, command, serverName);
|
||||
return !Storage.Blacklist.canPlayerAccessTab(sender, groups, command, serverName);
|
||||
});
|
||||
|
||||
FilteredSuggestionEvent filteredSuggestionEvent = PATEventHandler.callFilteredSuggestionEvents(player, event.getSuggestions());
|
||||
FilteredSuggestionEvent filteredSuggestionEvent = PATEventHandler.callFilteredSuggestionEvents(sender, event.getSuggestions());
|
||||
if(filteredSuggestionEvent.isCancelled()) event.getSuggestions().clear();
|
||||
}
|
||||
|
||||
@Subscribe (order = PostOrder.LAST)
|
||||
public void onPlayerAvailableCommands(PlayerAvailableCommandsEvent event) {
|
||||
try {
|
||||
Player player = event.getPlayer();
|
||||
final Player player = event.getPlayer();
|
||||
|
||||
if (event.getRootNode().getChildren().isEmpty() || !player.getCurrentServer().isPresent()) {
|
||||
return;
|
||||
}
|
||||
|
||||
String serverName = player.getCurrentServer().get().getServer().getServerInfo().getName();
|
||||
final CommandSender sender = CommandSender.from(player);
|
||||
|
||||
Map<String, CommandsCache> cache = Storage.getLoader().getCommandsCacheMap();
|
||||
if (PermissionUtil.hasBypassPermission(sender)) {
|
||||
return;
|
||||
}
|
||||
|
||||
final String serverName = player.getCurrentServer().get().getServer().getServerInfo().getName();
|
||||
|
||||
if (Storage.Blacklist.isDisabledServer(serverName)) {
|
||||
return;
|
||||
}
|
||||
|
||||
Map<String, CommandsCache> cache = Storage.getLoader().getPerServerCommandsCacheMap();
|
||||
|
||||
if (!cache.containsKey(serverName)) {
|
||||
cache.put(serverName, new CommandsCache());
|
||||
}
|
||||
|
||||
CommandsCache commandsCache = cache.get(serverName);
|
||||
final CommandsCache commandsCache = cache.get(serverName);
|
||||
final List<Group> groups = GroupManager.getPlayerGroups(sender);
|
||||
final List<String> commandsAsString = new ArrayList<>();
|
||||
|
||||
event.getRootNode().getChildren().stream()
|
||||
.filter(command -> command != null && command.getName() != null)
|
||||
.forEach(command -> commandsAsString.add(command.getName()));
|
||||
|
||||
List<String> commandsAsString = new ArrayList<>();
|
||||
event.getRootNode().getChildren().stream().filter(command -> command != null && command.getName() != null).forEach(command -> commandsAsString.add(command.getName()));
|
||||
commandsCache.handleCommands(commandsAsString, serverName);
|
||||
|
||||
if (PermissionUtil.hasBypassPermission(player)) {
|
||||
return;
|
||||
}
|
||||
|
||||
final boolean newer = player.getProtocolVersion().getProtocol() > 340, argsChildrenExist = event.getRootNode().getChild("args") != null;
|
||||
final List<String> playerCommands = commandsCache.getPlayerCommands(commandsAsString, player, player.getUniqueId(), serverName);
|
||||
final List<String> playerCommands = commandsCache.getPlayerCommands(commandsAsString, sender, groups, serverName);
|
||||
|
||||
if (event.getRootNode().getChildren().size() == 1
|
||||
&& newer && argsChildrenExist
|
||||
@@ -102,7 +127,7 @@ public class VelocityAntiTabListener {
|
||||
return !playerCommands.contains(command.getName());
|
||||
});
|
||||
} catch (Exception exception) {
|
||||
System.out.println("An error occurred while processing commands in PAT: " + exception.getMessage());
|
||||
Logger.warning("An error occurred while processing commands in PAT: " + exception.getMessage());
|
||||
exception.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
Loaded 100 of 204 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user