mirror of
https://github.com/RayzsYT/ProAntiTab.git
synced 2026-11-06 17:42:34 -05:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
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 |
No files matched your search
@@ -1,21 +1,339 @@
|
||||
MIT License
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
Version 2, June 1991
|
||||
|
||||
Copyright (c) 2025 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 after some time. This feature here allows you to make it more interesting by faking a /plugins message with, 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.1.2</version>
|
||||
<version>2.2.0</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>
|
||||
@@ -192,7 +192,7 @@
|
||||
<dependency>
|
||||
<groupId>com.velocitypowered</groupId>
|
||||
<artifactId>velocity-api</artifactId>
|
||||
<version>3.1.1-SNAPSHOT</version>
|
||||
<version>3.3.0-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
@@ -241,21 +241,21 @@
|
||||
<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>
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -18,7 +18,7 @@ public class BackendUpdater {
|
||||
}
|
||||
|
||||
public static void start() {
|
||||
if(isRunning()) return;
|
||||
if(isRunning() || !Storage.ConfigSections.Settings.HANDLE_THROUGH_PROXY.ENABLED) return;
|
||||
|
||||
TASK = PATScheduler.createScheduler(() -> {
|
||||
if (shouldRun())
|
||||
|
||||
@@ -150,7 +150,7 @@ public class Communicator {
|
||||
}
|
||||
|
||||
public static void syncData(String serverId) {
|
||||
if (Storage.ConfigSections.Settings.DISABLE_SYNC.DISABLED)
|
||||
if (!Reflection.isProxyServer() || Storage.ConfigSections.Settings.DISABLE_SYNC.DISABLED)
|
||||
return;
|
||||
|
||||
LAST_DATA_UPDATE = System.currentTimeMillis();
|
||||
|
||||
@@ -2,6 +2,8 @@ package de.rayzs.pat.api.communication.client.impl;
|
||||
|
||||
import de.rayzs.pat.api.communication.client.ClientInfo;
|
||||
import de.rayzs.pat.api.communication.Client;
|
||||
import de.rayzs.pat.plugin.BungeeLoader;
|
||||
import de.rayzs.pat.plugin.logger.Logger;
|
||||
import net.md_5.bungee.api.ProxyServer;
|
||||
|
||||
public class BungeeClientInfo extends ClientInfo {
|
||||
@@ -16,11 +18,18 @@ public class BungeeClientInfo extends ClientInfo {
|
||||
|
||||
@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)
|
||||
);
|
||||
try {
|
||||
ProxyServer server = BungeeLoader.getPlugin().getProxy();
|
||||
|
||||
server.getServers().entrySet().stream().filter(entry ->
|
||||
entry.getKey().equalsIgnoreCase(getName())
|
||||
).forEach(entry ->
|
||||
entry.getValue().sendData(Client.CHANNEL_NAME, bytes)
|
||||
);
|
||||
|
||||
} catch (NoClassDefFoundError exception) {
|
||||
Logger.warning("Failed to send data to backend servers! :c");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package de.rayzs.pat.api.communication.impl;
|
||||
|
||||
import de.rayzs.pat.api.storage.Storage;
|
||||
import de.rayzs.pat.utils.scheduler.PATScheduler;
|
||||
import org.bukkit.plugin.messaging.PluginMessageListener;
|
||||
import de.rayzs.pat.utils.CommunicationPackets;
|
||||
@@ -13,6 +14,11 @@ public class BukkitClient implements Client, PluginMessageListener {
|
||||
private static final Server SERVER = Bukkit.getServer();
|
||||
|
||||
public BukkitClient() {
|
||||
|
||||
if (!Storage.ConfigSections.Settings.HANDLE_THROUGH_PROXY.ENABLED) {
|
||||
return;
|
||||
}
|
||||
|
||||
SERVER.getMessenger().registerIncomingPluginChannel(BukkitLoader.getPlugin(), CHANNEL_NAME, this);
|
||||
SERVER.getMessenger().registerOutgoingPluginChannel(BukkitLoader.getPlugin(), CHANNEL_NAME);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package de.rayzs.pat.api.communication.impl;
|
||||
|
||||
import de.rayzs.pat.api.storage.Storage;
|
||||
import net.md_5.bungee.api.event.PluginMessageEvent;
|
||||
import de.rayzs.pat.utils.CommunicationPackets;
|
||||
import net.md_5.bungee.api.connection.Server;
|
||||
@@ -15,6 +16,11 @@ public class BungeeClient implements Client, Listener {
|
||||
private static final ProxyServer SERVER = ProxyServer.getInstance();
|
||||
|
||||
public BungeeClient() {
|
||||
|
||||
if (Storage.ConfigSections.Settings.DISABLE_SYNC.DISABLED) {
|
||||
return;
|
||||
}
|
||||
|
||||
SERVER.registerChannel(CHANNEL_NAME);
|
||||
SERVER.getPluginManager().registerListener(BungeeLoader.getPlugin(), this);
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ 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.api.storage.Storage;
|
||||
import de.rayzs.pat.utils.CommunicationPackets;
|
||||
import com.velocitypowered.api.event.Subscribe;
|
||||
import de.rayzs.pat.plugin.VelocityLoader;
|
||||
@@ -15,6 +16,11 @@ public class VelocityClient implements Client {
|
||||
private static final MinecraftChannelIdentifier IDENTIFIER = MinecraftChannelIdentifier.from(CHANNEL_NAME);
|
||||
|
||||
public VelocityClient() {
|
||||
|
||||
if (Storage.ConfigSections.Settings.DISABLE_SYNC.DISABLED) {
|
||||
return;
|
||||
}
|
||||
|
||||
SERVER.getChannelRegistrar().register(IDENTIFIER);
|
||||
SERVER.getEventManager().register(VelocityLoader.getInstance(), this);
|
||||
}
|
||||
|
||||
@@ -8,6 +8,9 @@ import de.rayzs.pat.api.storage.Storage;
|
||||
import de.rayzs.pat.utils.ExpireCache;
|
||||
import de.rayzs.pat.utils.Reflection;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import de.rayzs.pat.utils.sender.CommandSender;
|
||||
import de.rayzs.pat.utils.sender.CommandSenderHandler;
|
||||
import org.bukkit.entity.Player;
|
||||
import io.netty.channel.*;
|
||||
import org.bukkit.Bukkit;
|
||||
@@ -19,7 +22,10 @@ public class BukkitPacketAnalyzer {
|
||||
private static final ExpireCache<UUID, Object> SENT_PACKET = new ExpireCache<>(2, TimeUnit.SECONDS);
|
||||
|
||||
private static final String HANDLER_NAME = "pat-bukkit-handler", PIPELINE_NAME = "packet_handler";
|
||||
|
||||
private static final BukkitPacketHandler PACKET_HANDLER = Reflection.getMinor() >= 16 ? new ModernPacketHandler() : new LegacyPacketHandler();
|
||||
private static final BukkitPacketHandler COMMANDS_NODE_HANDLER = new ModernCommandsNodeHandler();
|
||||
|
||||
private static final HashMap<Player, String> PLAYER_INPUT_CACHE = new HashMap<>();
|
||||
|
||||
public static void injectAll() {
|
||||
@@ -42,7 +48,7 @@ public class BukkitPacketAnalyzer {
|
||||
}
|
||||
|
||||
public static boolean inject(Player player) {
|
||||
if (Storage.USE_VELOCITY)
|
||||
if (Storage.ConfigSections.Settings.HANDLE_THROUGH_PROXY.ENABLED)
|
||||
return true;
|
||||
|
||||
try {
|
||||
@@ -81,7 +87,7 @@ public class BukkitPacketAnalyzer {
|
||||
}
|
||||
|
||||
public static void uninject(UUID uuid) {
|
||||
if (Storage.USE_VELOCITY)
|
||||
if (Storage.SEND_CONSOLE_NOTIFICATION)
|
||||
return;
|
||||
|
||||
if (BukkitPacketAnalyzer.INJECTED_PLAYERS.containsKey(uuid)) {
|
||||
@@ -91,7 +97,7 @@ public class BukkitPacketAnalyzer {
|
||||
}
|
||||
|
||||
public static void uninject(Channel channel) {
|
||||
if (Storage.USE_VELOCITY)
|
||||
if (Storage.ConfigSections.Settings.HANDLE_THROUGH_PROXY.ENABLED)
|
||||
return;
|
||||
|
||||
if (channel != null) {
|
||||
@@ -117,29 +123,35 @@ public class BukkitPacketAnalyzer {
|
||||
private static class PacketDecoder extends ChannelDuplexHandler {
|
||||
|
||||
private final Player player;
|
||||
private final CommandSender sender;
|
||||
|
||||
private PacketDecoder(Player player) {
|
||||
this.player = player;
|
||||
this.sender = CommandSenderHandler.from(player);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void channelRead(ChannelHandlerContext channel, Object packetObj) {
|
||||
try {
|
||||
if (packetObj.getClass() != null) {
|
||||
String packetName = packetObj.getClass().getSimpleName();
|
||||
|
||||
if (!packetName.equals("PacketPlayInTabComplete") && !packetName.equals("ServerboundCommandSuggestionPacket")) {
|
||||
super.channelRead(channel, packetObj);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!PermissionUtil.hasBypassPermission(player)) {
|
||||
|
||||
if (!PACKET_HANDLER.handleIncomingPacket(player, packetObj))
|
||||
return;
|
||||
|
||||
}
|
||||
if (packetObj.getClass() == null || Storage.ConfigSections.Settings.HANDLE_THROUGH_PROXY.ENABLED) {
|
||||
super.channelRead(channel, packetObj);
|
||||
return;
|
||||
}
|
||||
|
||||
String packetName = packetObj.getClass().getSimpleName();
|
||||
|
||||
if (!packetName.equals("PacketPlayInTabComplete") && !packetName.equals("ServerboundCommandSuggestionPacket")) {
|
||||
super.channelRead(channel, packetObj);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!PermissionUtil.hasBypassPermission(sender)) {
|
||||
|
||||
if (!PACKET_HANDLER.handleIncomingPacket(player, sender, packetObj))
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
super.channelRead(channel, packetObj);
|
||||
} catch (Throwable exception) { exception.printStackTrace(); }
|
||||
}
|
||||
@@ -148,32 +160,41 @@ public class BukkitPacketAnalyzer {
|
||||
public void write(ChannelHandlerContext channel, Object packetObj, ChannelPromise promise) {
|
||||
try {
|
||||
|
||||
if(packetObj.getClass() != null) {
|
||||
String packetName = packetObj.getClass().getSimpleName();
|
||||
if(packetObj.getClass() == null || Storage.ConfigSections.Settings.HANDLE_THROUGH_PROXY.ENABLED) {
|
||||
super.write(channel, packetObj, promise);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!packetName.equals("PacketPlayOutTabComplete") && !packetName.equals("ClientboundCommandSuggestionsPacket")) {
|
||||
super.write(channel, packetObj, promise);
|
||||
final String packetName = packetObj.getClass().getSimpleName();
|
||||
final boolean isCommandsPacket = packetName.equals("ClientboundCommandsPacket");
|
||||
final boolean isTabCompletePacket = packetName.equals("PacketPlayOutTabComplete") || packetName.equals("ClientboundCommandSuggestionsPacket");
|
||||
|
||||
if (!isCommandsPacket && !isTabCompletePacket || PermissionUtil.hasBypassPermission(sender)) {
|
||||
super.write(channel, packetObj, promise);
|
||||
return;
|
||||
}
|
||||
|
||||
if (isCommandsPacket) {
|
||||
COMMANDS_NODE_HANDLER.handleOutgoingPacket(player, sender, packetObj);
|
||||
|
||||
super.write(channel, packetObj, promise);
|
||||
return;
|
||||
}
|
||||
|
||||
UUID uuid = player.getUniqueId();
|
||||
Object sentPacketObj = SENT_PACKET.get(uuid);
|
||||
|
||||
if (sentPacketObj != null) {
|
||||
if (sentPacketObj == packetObj) {
|
||||
SENT_PACKET.remove(uuid);
|
||||
super.write(channel, sentPacketObj, promise);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!PermissionUtil.hasBypassPermission(player)) {
|
||||
|
||||
UUID uuid = player.getUniqueId();
|
||||
Object sentPacketObj = SENT_PACKET.get(uuid);
|
||||
|
||||
if (sentPacketObj != null) {
|
||||
if (sentPacketObj == packetObj) {
|
||||
SENT_PACKET.remove(uuid);
|
||||
super.write(channel, sentPacketObj, promise);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (!PACKET_HANDLER.handleOutgoingPacket(player, packetObj))
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (!PACKET_HANDLER.handleOutgoingPacket(player, sender, packetObj))
|
||||
return;
|
||||
|
||||
super.write(channel, packetObj, promise);
|
||||
|
||||
} catch (Throwable exception) {
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
package de.rayzs.pat.api.netty.bukkit;
|
||||
|
||||
import de.rayzs.pat.utils.sender.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public interface BukkitPacketHandler {
|
||||
boolean handleIncomingPacket(Player player, Object packetObj) throws Exception;
|
||||
boolean handleOutgoingPacket(Player player, Object packetObj) throws Exception;
|
||||
boolean handleIncomingPacket(Player player, CommandSender sender, Object packetObj) throws Exception;
|
||||
boolean handleOutgoingPacket(Player player, CommandSender sender, Object packetObj) throws Exception;
|
||||
}
|
||||
@@ -6,6 +6,9 @@ import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
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 org.bukkit.entity.Player;
|
||||
|
||||
import de.rayzs.pat.api.event.PATEventHandler;
|
||||
@@ -19,7 +22,7 @@ import de.rayzs.pat.utils.Reflection;
|
||||
public class LegacyPacketHandler implements BukkitPacketHandler {
|
||||
|
||||
@Override
|
||||
public boolean handleIncomingPacket(Player player, Object packetObj) throws Exception {
|
||||
public boolean handleIncomingPacket(Player player, CommandSender sender, Object packetObj) throws Exception {
|
||||
Field stringField = Reflection.getFirstFieldByType(packetObj.getClass(), "String", Reflection.SearchOption.ENDS);
|
||||
if(stringField == null) {
|
||||
Logger.warning("Failed PacketAnalyze process! (#1)");
|
||||
@@ -32,11 +35,14 @@ public class LegacyPacketHandler implements BukkitPacketHandler {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean handleOutgoingPacket(Player player, Object packetObj) throws Exception {
|
||||
public boolean handleOutgoingPacket(Player player, CommandSender sender, Object packetObj) throws Exception {
|
||||
final String rawInput = BukkitPacketAnalyzer.getPlayerInput(player);
|
||||
|
||||
if(rawInput == null)
|
||||
if(rawInput == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
final List<Group> groups = GroupManager.getPlayerGroups(sender);
|
||||
|
||||
String input = rawInput;
|
||||
boolean cancelsBeforeHand = false;
|
||||
@@ -47,7 +53,7 @@ public class LegacyPacketHandler implements BukkitPacketHandler {
|
||||
|
||||
input = input.substring(1);
|
||||
|
||||
final boolean doesBypassNamespace = Storage.ConfigSections.Settings.BLOCK_NAMESPACE_COMMANDS.doesBypass(player);
|
||||
final boolean doesBypassNamespace = Storage.ConfigSections.Settings.BLOCK_NAMESPACE_COMMANDS.doesBypass(sender);
|
||||
final boolean spaces = input.contains(" ");
|
||||
|
||||
if (Storage.ConfigSections.Settings.BLOCK_NAMESPACE_COMMANDS.isCommand(input) && !doesBypassNamespace) {
|
||||
@@ -55,7 +61,7 @@ public class LegacyPacketHandler implements BukkitPacketHandler {
|
||||
}
|
||||
|
||||
if (!cancelsBeforeHand && !input.isEmpty()) {
|
||||
cancelsBeforeHand = !Storage.Blacklist.canPlayerAccessTab(player, StringUtils.getFirstArg(input));
|
||||
cancelsBeforeHand = !Storage.Blacklist.canPlayerAccessTab(sender, groups, StringUtils.getFirstArg(input));
|
||||
}
|
||||
|
||||
if (!cancelsBeforeHand) {
|
||||
@@ -100,7 +106,7 @@ public class LegacyPacketHandler implements BukkitPacketHandler {
|
||||
return false;
|
||||
}
|
||||
|
||||
return !Storage.Blacklist.canPlayerAccessTab(player, cpy);
|
||||
return !Storage.Blacklist.canPlayerAccessTab(sender, groups, cpy);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
package de.rayzs.pat.api.netty.bukkit.handlers;
|
||||
|
||||
import de.rayzs.pat.api.netty.bukkit.BukkitPacketHandler;
|
||||
import de.rayzs.pat.plugin.subarguments.SubArguments;
|
||||
import de.rayzs.pat.utils.node.BukkitCommandNodeHelper;
|
||||
import de.rayzs.pat.utils.sender.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
public class ModernCommandsNodeHandler implements BukkitPacketHandler {
|
||||
|
||||
public boolean handleIncomingPacket(Player player, CommandSender sender, Object packetObj) throws Exception {
|
||||
// Ignored
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean handleOutgoingPacket(Player player, CommandSender sender, Object packetObj) throws Exception {
|
||||
final BukkitCommandNodeHelper helper = new BukkitCommandNodeHelper(packetObj);
|
||||
|
||||
SubArguments.handleCommandNode(player.getUniqueId(), helper);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -5,6 +5,9 @@ import java.lang.reflect.Method;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import de.rayzs.pat.utils.group.Group;
|
||||
import de.rayzs.pat.utils.group.GroupManager;
|
||||
import de.rayzs.pat.utils.sender.CommandSender;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@@ -28,7 +31,7 @@ public class ModernPacketHandler implements BukkitPacketHandler {
|
||||
private static boolean modifiable = true;
|
||||
|
||||
@Override
|
||||
public boolean handleIncomingPacket(Player player, Object packetObj) throws Exception {
|
||||
public boolean handleIncomingPacket(Player player, CommandSender sender, Object packetObj) throws Exception {
|
||||
Field stringField = Reflection.getFirstFieldByType(packetObj.getClass(), "String", Reflection.SearchOption.ENDS);
|
||||
|
||||
if(stringField == null) {
|
||||
@@ -57,13 +60,15 @@ public class ModernPacketHandler implements BukkitPacketHandler {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean handleOutgoingPacket(Player player, Object packetObj) throws Exception {
|
||||
public boolean handleOutgoingPacket(Player player, CommandSender sender, Object packetObj) throws Exception {
|
||||
Object suggestionObj;
|
||||
String rawInput = BukkitPacketAnalyzer.getPlayerInput(player), input = rawInput;
|
||||
|
||||
if(input == null)
|
||||
if(input == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
final List<Group> groups = GroupManager.getPlayerGroups(sender);
|
||||
|
||||
boolean is121Packet = packetObj.getClass().getSimpleName().equals("ClientboundCommandSuggestionsPacket"),
|
||||
cancelsBeforeHand = false;
|
||||
@@ -77,7 +82,7 @@ public class ModernPacketHandler implements BukkitPacketHandler {
|
||||
if(spaces > 0) input = split[0];
|
||||
}
|
||||
|
||||
cancelsBeforeHand = !Storage.Blacklist.canPlayerAccessTab(player, input);
|
||||
cancelsBeforeHand = !Storage.Blacklist.canPlayerAccessTab(sender, groups, input);
|
||||
|
||||
if (!cancelsBeforeHand)
|
||||
cancelsBeforeHand = Storage.ConfigSections.Settings.CUSTOM_VERSION.isTabCompletable(input) || Storage.ConfigSections.Settings.CUSTOM_PLUGIN.isTabCompletable(input);
|
||||
@@ -106,7 +111,7 @@ public class ModernPacketHandler implements BukkitPacketHandler {
|
||||
if (spaces == 0) {
|
||||
suggestions.removeIf(suggestion -> {
|
||||
String command = getSuggestionFromEntry(suggestion);
|
||||
return !Storage.Blacklist.canPlayerAccessTab(player, command);
|
||||
return !Storage.Blacklist.canPlayerAccessTab(sender, groups, command);
|
||||
});
|
||||
|
||||
return true;
|
||||
@@ -180,7 +185,7 @@ public class ModernPacketHandler implements BukkitPacketHandler {
|
||||
|
||||
suggestions.getList().removeIf(suggestion -> {
|
||||
String command = suggestion.getText();
|
||||
return !Storage.Blacklist.canPlayerAccessTab(player, command);
|
||||
return !Storage.Blacklist.canPlayerAccessTab(sender, groups, command);
|
||||
});
|
||||
|
||||
return true;
|
||||
|
||||
@@ -3,37 +3,34 @@ package de.rayzs.pat.api.netty.proxy;
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
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.plugin.subarguments.SubArguments;
|
||||
import de.rayzs.pat.utils.CommandsCache;
|
||||
import de.rayzs.pat.utils.node.CommandNodeHelper;
|
||||
import de.rayzs.pat.utils.ExpireCache;
|
||||
import de.rayzs.pat.utils.group.Group;
|
||||
import de.rayzs.pat.utils.group.GroupManager;
|
||||
import de.rayzs.pat.utils.node.ProxyCommandNodeHelper;
|
||||
import de.rayzs.pat.utils.Reflection;
|
||||
import de.rayzs.pat.utils.StringUtils;
|
||||
import de.rayzs.pat.utils.permission.PermissionUtil;
|
||||
import de.rayzs.pat.utils.sender.CommandSender;
|
||||
import de.rayzs.pat.utils.sender.CommandSenderHandler;
|
||||
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 {
|
||||
|
||||
@@ -41,7 +38,7 @@ public class BungeePacketAnalyzer {
|
||||
|
||||
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 ExpireCache<UUID, String> PLAYER_INPUT_CACHE = new ExpireCache<>(5, TimeUnit.SECONDS);
|
||||
|
||||
private static final List<String> PLUGIN_COMMANDS = new ArrayList<>();
|
||||
|
||||
@@ -50,7 +47,7 @@ public class BungeePacketAnalyzer {
|
||||
private static List<String> PROXY_COMMANDS;
|
||||
|
||||
static {
|
||||
CommandNodeHelper.setDefaultSuggestionProvider(Commands.SuggestionRegistry.ASK_SERVER);
|
||||
ProxyCommandNodeHelper.setDefaultSuggestionProvider(Commands.SuggestionRegistry.ASK_SERVER);
|
||||
loadProxyCommands();
|
||||
}
|
||||
|
||||
@@ -115,7 +112,7 @@ public class BungeePacketAnalyzer {
|
||||
}
|
||||
|
||||
public static void uninject(ProxiedPlayer player) {
|
||||
BungeePacketAnalyzer.PLAYER_INPUT_CACHE.remove(player);
|
||||
BungeePacketAnalyzer.PLAYER_INPUT_CACHE.remove(player.getUniqueId());
|
||||
BungeePacketAnalyzer.PLAYER_MODIFIED.remove(player);
|
||||
|
||||
if(BungeePacketAnalyzer.INJECTED_PLAYERS.containsKey(player)) {
|
||||
@@ -132,46 +129,54 @@ public class BungeePacketAnalyzer {
|
||||
}
|
||||
}
|
||||
|
||||
public static void setPlayerInput(ProxiedPlayer player, String input) {
|
||||
PLAYER_INPUT_CACHE.putIgnoreIfContains(player.getUniqueId(), input);
|
||||
}
|
||||
|
||||
public static String getPlayerInput(ProxiedPlayer player) {
|
||||
String input = PLAYER_INPUT_CACHE.get(player);
|
||||
PLAYER_INPUT_CACHE.remove(player);
|
||||
String input = PLAYER_INPUT_CACHE.get(player.getUniqueId());
|
||||
PLAYER_INPUT_CACHE.remove(player.getUniqueId());
|
||||
return input;
|
||||
}
|
||||
|
||||
private static void modifyCommands(ProxiedPlayer player, Commands commands) {
|
||||
if (PermissionUtil.hasBypassPermission(player))
|
||||
return;
|
||||
private static void modifyCommands(ProxiedPlayer player, CommandSender sender, Commands commands) {
|
||||
String serverName = sender.getServerName();
|
||||
|
||||
ServerInfo serverInfo = player.getServer().getInfo();
|
||||
String serverName = serverInfo.getName();
|
||||
final boolean ignore = PermissionUtil.hasBypassPermission(sender) || Storage.Blacklist.isDisabledServer(serverName);
|
||||
|
||||
if (Storage.Blacklist.isDisabledServer(serverName))
|
||||
return;
|
||||
|
||||
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);
|
||||
ProxyCommandNodeHelper helper = new ProxyCommandNodeHelper<CommandNode>(commands.getRoot());
|
||||
|
||||
List<String> commandsAsString = new ArrayList<>(PROXY_COMMANDS);
|
||||
commandsAsString.addAll(helper.getChildrenNames());
|
||||
|
||||
commandsCache.handleCommands(commandsAsString, serverName);
|
||||
List<String> playerCommands = new ArrayList<>();
|
||||
|
||||
List<String> playerCommands = commandsCache.getPlayerCommands(commandsAsString, player, serverName);
|
||||
if (!ignore) {
|
||||
final List<Group> groups = GroupManager.getPlayerGroups(sender);
|
||||
|
||||
helper.removeIf(str -> !playerCommands.contains(str));
|
||||
final Map<String, CommandsCache> cache = Storage.getLoader().getCommandsCacheMap();
|
||||
if (!cache.containsKey(serverName)) {
|
||||
cache.put(serverName, new CommandsCache());
|
||||
}
|
||||
|
||||
if (Storage.ConfigSections.Settings.CUSTOM_VERSION.ALWAYS_TAB_COMPLETABLE) {
|
||||
Storage.ConfigSections.Settings.CUSTOM_VERSION.COMMANDS.getLines().forEach(input -> helper.add(input, false));
|
||||
}
|
||||
final CommandsCache commandsCache = cache.get(serverName);
|
||||
commandsCache.handleCommands(commandsAsString, serverName);
|
||||
|
||||
if (Storage.ConfigSections.Settings.CUSTOM_PLUGIN.ALWAYS_TAB_COMPLETABLE) {
|
||||
Storage.ConfigSections.Settings.CUSTOM_PLUGIN.COMMANDS.getLines().forEach(input -> helper.add(input, false));
|
||||
final List<String> tmpPlayerCommands = commandsCache.getPlayerCommands(commandsAsString, sender, groups, serverName);
|
||||
|
||||
if (commands.getRoot().getChildren().size() != 0) {
|
||||
helper.removeIf(str -> !tmpPlayerCommands.contains(str));
|
||||
}
|
||||
|
||||
if (Storage.ConfigSections.Settings.CUSTOM_VERSION.ALWAYS_TAB_COMPLETABLE) {
|
||||
Storage.ConfigSections.Settings.CUSTOM_VERSION.COMMANDS.getLines().forEach(input -> helper.add(input, false));
|
||||
}
|
||||
|
||||
if (Storage.ConfigSections.Settings.CUSTOM_PLUGIN.ALWAYS_TAB_COMPLETABLE) {
|
||||
Storage.ConfigSections.Settings.CUSTOM_PLUGIN.COMMANDS.getLines().forEach(input -> helper.add(input, false));
|
||||
}
|
||||
|
||||
playerCommands = tmpPlayerCommands;
|
||||
}
|
||||
|
||||
for (Map.Entry<String, Command> command : ProxyServer.getInstance().getPluginManager().getCommands()) {
|
||||
@@ -189,28 +194,42 @@ public class BungeePacketAnalyzer {
|
||||
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 (!ignore) {
|
||||
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;
|
||||
if (!tabablePluginCommand && !tabableVersionCommand && !playerCommands.contains(commandName)) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
CommandNode dummy = CommandNodeHelper.createDummyCommandNode(command.getKey());
|
||||
CommandNode dummy = ProxyCommandNodeHelper.createDummyCommandNode(command.getKey());
|
||||
commands.getRoot().addChild(dummy);
|
||||
}
|
||||
|
||||
|
||||
PROXY_COMMANDS.stream().filter(playerCommands::contains).forEach(input -> helper.add(input, true));
|
||||
SubArgsModule.handleCommandNode(player.getUniqueId(), helper);
|
||||
for (String command : PROXY_COMMANDS) {
|
||||
if (ignore || playerCommands.contains(command)) {
|
||||
helper.add(command, true);
|
||||
}
|
||||
}
|
||||
|
||||
if (!ignore) {
|
||||
SubArguments.handleCommandNode(player.getUniqueId(), helper);
|
||||
}
|
||||
}
|
||||
|
||||
public static void sendCommandsPacket() {
|
||||
for (ProxiedPlayer player : ProxyServer.getInstance().getPlayers()) {
|
||||
if (player.getPendingConnection().getVersion() < 754)
|
||||
continue;
|
||||
|
||||
final CommandSender sender = CommandSenderHandler.from(player);
|
||||
|
||||
RootCommandNode root = new RootCommandNode();
|
||||
Commands packet = new Commands(root);
|
||||
|
||||
modifyCommands(player, packet);
|
||||
modifyCommands(player, sender, packet);
|
||||
player.unsafe().sendPacket(packet);
|
||||
}
|
||||
}
|
||||
@@ -218,9 +237,11 @@ public class BungeePacketAnalyzer {
|
||||
private static class PacketDecoder extends MessageToMessageDecoder<PacketWrapper> {
|
||||
|
||||
private final ProxiedPlayer player;
|
||||
private final CommandSender sender;
|
||||
|
||||
private PacketDecoder(ProxiedPlayer player) {
|
||||
this.player = player;
|
||||
this.sender = CommandSenderHandler.from(player);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -230,37 +251,44 @@ public class BungeePacketAnalyzer {
|
||||
return;
|
||||
}
|
||||
|
||||
if(wrapper.packet instanceof PluginMessage) {
|
||||
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);
|
||||
modifyCommands(player, sender, response);
|
||||
|
||||
player.unsafe().sendPacket(response);
|
||||
return;
|
||||
|
||||
/*
|
||||
} else if (wrapper.packet instanceof TabCompleteResponse) {
|
||||
TabCompleteResponse response = (TabCompleteResponse) wrapper.packet;
|
||||
String serverName = player.getServer().getInfo().getName();
|
||||
|
||||
System.out.println("damn");
|
||||
|
||||
if (!Storage.Blacklist.isDisabledServer(serverName) && player.getPendingConnection().getVersion() < 754) {
|
||||
if (!PermissionUtil.hasBypassPermission(player)) {
|
||||
|
||||
ClientInfo clientInfo = Communicator.getClientByName(player.getServer().getInfo().getName());
|
||||
if (clientInfo == null || !PLAYER_INPUT_CACHE.containsKey(player))
|
||||
System.out.println("Further!");
|
||||
System.out.println("Got: " + PLAYER_INPUT_CACHE.get(player.getUniqueId()));
|
||||
|
||||
if (!PLAYER_INPUT_CACHE.contains(player.getUniqueId()))
|
||||
return;
|
||||
|
||||
boolean cancelsBeforeHand = false;
|
||||
|
||||
String rawPlayerInput = getPlayerInput(player);
|
||||
String rawPlayerInput = PLAYER_INPUT_CACHE.get(player.getUniqueId());
|
||||
int spaces = rawPlayerInput.contains(" ") ? rawPlayerInput.split(" ").length : 0;
|
||||
|
||||
String playerInput = StringUtils.getFirstArg(rawPlayerInput),
|
||||
server = player.getServer().getInfo().getName();
|
||||
|
||||
System.out.println("NETTY -> " + playerInput);
|
||||
|
||||
if (!playerInput.equals("/")) {
|
||||
cancelsBeforeHand = !Storage.Blacklist.canPlayerAccessTab(player, StringUtils.replaceFirst(playerInput, "/", ""), server);
|
||||
|
||||
@@ -318,7 +346,7 @@ public class BungeePacketAnalyzer {
|
||||
player.unsafe().sendPacket(new TabCompleteResponse(response.getCommands()));
|
||||
}
|
||||
}
|
||||
}
|
||||
}*/
|
||||
}
|
||||
|
||||
list.add(wrapper);
|
||||
|
||||
@@ -4,6 +4,8 @@ import java.lang.reflect.Field;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import com.mojang.brigadier.suggestion.SuggestionProvider;
|
||||
import com.velocitypowered.api.command.CommandSource;
|
||||
import com.velocitypowered.api.proxy.Player;
|
||||
import com.velocitypowered.proxy.protocol.MinecraftPacket;
|
||||
import com.velocitypowered.proxy.protocol.packet.AvailableCommandsPacket;
|
||||
@@ -19,12 +21,18 @@ import de.rayzs.pat.api.storage.Storage;
|
||||
import de.rayzs.pat.plugin.VelocityLoader;
|
||||
import de.rayzs.pat.plugin.listeners.velocity.VelocityBlockCommandListener;
|
||||
import de.rayzs.pat.plugin.logger.Logger;
|
||||
import de.rayzs.pat.plugin.subarguments.SubArguments;
|
||||
import de.rayzs.pat.utils.CommandsCache;
|
||||
import de.rayzs.pat.utils.PacketUtils;
|
||||
import de.rayzs.pat.utils.Reflection;
|
||||
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.message.MessageTranslator;
|
||||
import de.rayzs.pat.utils.node.ProxyCommandNodeHelper;
|
||||
import de.rayzs.pat.utils.permission.PermissionUtil;
|
||||
import de.rayzs.pat.utils.sender.CommandSender;
|
||||
import de.rayzs.pat.utils.sender.CommandSenderHandler;
|
||||
import io.netty.channel.Channel;
|
||||
import io.netty.channel.ChannelDuplexHandler;
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
@@ -34,6 +42,31 @@ import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
|
||||
|
||||
public class VelocityPacketAnalyzer {
|
||||
|
||||
private static boolean FAILED = false;
|
||||
|
||||
static {
|
||||
try {
|
||||
final String name = "minecraft:ask_server";
|
||||
|
||||
final Object availableCommandsPacket = AvailableCommandsPacket.class.newInstance();
|
||||
final Class<?> packetInstanceObjClass = availableCommandsPacket.getClass();
|
||||
|
||||
for (Class<?> clazz : packetInstanceObjClass.getClasses()) {
|
||||
if (clazz.getSimpleName().equals("ProtocolSuggestionProvider")) {
|
||||
final Object suggestionProviderObj = clazz.getConstructor(String.class).newInstance(name);
|
||||
final SuggestionProvider<?> suggestionProvider = (SuggestionProvider<?>) suggestionProviderObj;
|
||||
|
||||
ProxyCommandNodeHelper.setDefaultSuggestionProvider(suggestionProvider);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
} catch (Exception exception) {
|
||||
exception.printStackTrace();
|
||||
FAILED = true;
|
||||
}
|
||||
}
|
||||
|
||||
public static final ConcurrentHashMap<Player, Channel> INJECTED_PLAYERS = new ConcurrentHashMap<>();
|
||||
|
||||
private static final String PIPELINE_NAME = "pat-velocity-handler", HANDLER_NAME = "handler";
|
||||
@@ -118,12 +151,67 @@ public class VelocityPacketAnalyzer {
|
||||
PLAYER_INPUT_CACHE.put(player, text.toLowerCase());
|
||||
}
|
||||
|
||||
private static void modifyCommands(Player player, CommandSender sender, AvailableCommandsPacket commands) {
|
||||
|
||||
if (commands.getRootNode().getChildren().size() == 1
|
||||
&& player.getProtocolVersion().getProtocol() > 340
|
||||
&& commands.getRootNode().getChild("args") != null
|
||||
&& commands.getRootNode().getChild("args").getChildren().isEmpty()) {
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
String serverName = sender.getServerName();
|
||||
|
||||
final boolean ignore = PermissionUtil.hasBypassPermission(sender) || Storage.Blacklist.isDisabledServer(serverName);
|
||||
final ProxyCommandNodeHelper<CommandSource> helper = new ProxyCommandNodeHelper<>(commands.getRootNode());
|
||||
|
||||
final List<String> commandsAsString = new ArrayList<>();
|
||||
commandsAsString.addAll(helper.getChildrenNames());
|
||||
|
||||
if (ignore) {
|
||||
return;
|
||||
}
|
||||
|
||||
final List<Group> groups = GroupManager.getPlayerGroups(sender);
|
||||
|
||||
final Map<String, CommandsCache> cache = Storage.getLoader().getCommandsCacheMap();
|
||||
if (!cache.containsKey(serverName)) {
|
||||
cache.put(serverName, new CommandsCache());
|
||||
}
|
||||
|
||||
final CommandsCache commandsCache = cache.get(serverName);
|
||||
commandsCache.handleCommands(commandsAsString, serverName);
|
||||
|
||||
final List<String> playerCommands = commandsCache.getPlayerCommands(commandsAsString, sender, groups, serverName);
|
||||
helper.removeIf(str -> {
|
||||
if (str.equals("args")) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return !playerCommands.contains(str);
|
||||
});
|
||||
|
||||
if (Storage.ConfigSections.Settings.CUSTOM_VERSION.ALWAYS_TAB_COMPLETABLE) {
|
||||
Storage.ConfigSections.Settings.CUSTOM_VERSION.COMMANDS.getLines().forEach(input -> helper.add(input, false));
|
||||
}
|
||||
|
||||
if (Storage.ConfigSections.Settings.CUSTOM_PLUGIN.ALWAYS_TAB_COMPLETABLE) {
|
||||
Storage.ConfigSections.Settings.CUSTOM_PLUGIN.COMMANDS.getLines().forEach(input -> helper.add(input, false));
|
||||
}
|
||||
|
||||
SubArguments.handleCommandNode(player.getUniqueId(), helper);
|
||||
}
|
||||
|
||||
private static class PacketDecoder extends ChannelDuplexHandler {
|
||||
|
||||
private final Player player;
|
||||
private final CommandSender sender;
|
||||
|
||||
private PacketDecoder(Player player) {
|
||||
this.player = player;
|
||||
this.sender = CommandSenderHandler.from(player);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -153,15 +241,12 @@ public class VelocityPacketAnalyzer {
|
||||
}
|
||||
}
|
||||
|
||||
if (packet instanceof UnsignedPlayerCommandPacket) {
|
||||
|
||||
UnsignedPlayerCommandPacket unsignedPlayerCommandPacket = (UnsignedPlayerCommandPacket) packet;
|
||||
if (packet instanceof UnsignedPlayerCommandPacket unsignedPlayerCommandPacket) {
|
||||
if (!VelocityBlockCommandListener.handleCommand(player, unsignedPlayerCommandPacket.getCommand()).getResult().isAllowed())
|
||||
return;
|
||||
}
|
||||
|
||||
if (packet instanceof TabCompleteRequestPacket) {
|
||||
TabCompleteRequestPacket request = (TabCompleteRequestPacket) msg;
|
||||
if (packet instanceof TabCompleteRequestPacket request) {
|
||||
if (request.getCommand() != null) {
|
||||
|
||||
if (Storage.ConfigSections.Settings.PATCH_EXPLOITS.isMalicious(request.getCommand())) {
|
||||
@@ -184,15 +269,14 @@ public class VelocityPacketAnalyzer {
|
||||
|
||||
MinecraftPacket packet = (MinecraftPacket) msg;
|
||||
|
||||
if (packet instanceof PluginMessagePacket) {
|
||||
PluginMessagePacket pluginMessagePacket = (PluginMessagePacket) packet;
|
||||
if (packet instanceof PluginMessagePacket pluginMessagePacket) {
|
||||
if(CustomServerBrand.isEnabled() && CustomServerBrand.isBrandTag(pluginMessagePacket.getChannel()) && !player.getCurrentServer().isPresent()) {
|
||||
PacketUtils.BrandManipulate brandManipulatePacket = CustomServerBrand.createBrandPacket(player);
|
||||
super.write(ctx, new PluginMessagePacket(pluginMessagePacket.getChannel(), brandManipulatePacket.getByteBuf()), promise);
|
||||
return;
|
||||
}
|
||||
|
||||
} else if (packet instanceof TabCompleteResponsePacket) {
|
||||
} else if (packet instanceof TabCompleteResponsePacket response) {
|
||||
|
||||
String serverName = player.getCurrentServer().get().getServer().getServerInfo().getName();
|
||||
|
||||
@@ -201,23 +285,23 @@ public class VelocityPacketAnalyzer {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!PermissionUtil.hasBypassPermission(player) && player.getCurrentServer().isPresent()) {
|
||||
TabCompleteResponsePacket response = (TabCompleteResponsePacket) packet;
|
||||
if (!PermissionUtil.hasBypassPermission(sender) && player.getCurrentServer().isPresent()) {
|
||||
final List<Group> groups = GroupManager.getPlayerGroups(sender);
|
||||
|
||||
boolean cancelsBeforeHand = false;
|
||||
String playerInput = getPlayerInput(player), rawPlayerInput = playerInput, server = player.getCurrentServer().get().getServerInfo().getName();
|
||||
int spaces = 0;
|
||||
|
||||
if(playerInput.contains(" ")) {
|
||||
if (playerInput.contains(" ")) {
|
||||
String[] split = playerInput.split(" ");
|
||||
spaces = split.length;
|
||||
if(spaces > 0) playerInput = split[0];
|
||||
if (spaces > 0) playerInput = split[0];
|
||||
}
|
||||
|
||||
if(!playerInput.equals("/")) {
|
||||
cancelsBeforeHand = !Storage.Blacklist.canPlayerAccessTab(player, StringUtils.replaceFirst(playerInput, "/", ""), server);
|
||||
if (!playerInput.equals("/")) {
|
||||
cancelsBeforeHand = !Storage.Blacklist.canPlayerAccessTab(sender, groups, StringUtils.replaceFirst(playerInput, "/", ""), server);
|
||||
|
||||
if(!cancelsBeforeHand)
|
||||
if (!cancelsBeforeHand)
|
||||
cancelsBeforeHand = Storage.ConfigSections.Settings.CUSTOM_VERSION.isTabCompletable(StringUtils.replaceFirst(playerInput, "/", "")) || Storage.ConfigSections.Settings.CUSTOM_PLUGIN.isTabCompletable(StringUtils.replaceFirst(playerInput, "/", ""));
|
||||
}
|
||||
|
||||
@@ -237,7 +321,7 @@ public class VelocityPacketAnalyzer {
|
||||
return false;
|
||||
}
|
||||
|
||||
return !Storage.Blacklist.canPlayerAccessTab(player, command, player.getCurrentServer().get().getServerInfo().getName());
|
||||
return !Storage.Blacklist.canPlayerAccessTab(sender, groups, command, player.getCurrentServer().get().getServerInfo().getName());
|
||||
});
|
||||
} else {
|
||||
if (cancelsBeforeHand) return;
|
||||
@@ -258,18 +342,31 @@ public class VelocityPacketAnalyzer {
|
||||
}
|
||||
}
|
||||
|
||||
} else if (packet instanceof AvailableCommandsPacket) {
|
||||
} else if (packet instanceof AvailableCommandsPacket commands) {
|
||||
|
||||
if (player.getCurrentServer().isPresent()) {
|
||||
|
||||
if (!FAILED) {
|
||||
modifyCommands(player, sender, commands);
|
||||
super.write(ctx, msg, promise);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!PermissionUtil.hasBypassPermission(player)) {
|
||||
super.write(ctx, msg, promise);
|
||||
return;
|
||||
}
|
||||
|
||||
final String serverName = player.getCurrentServer().get().getServer().getServerInfo().getName();
|
||||
|
||||
if (!PermissionUtil.hasBypassPermission(player) && player.getCurrentServer().isPresent()) {
|
||||
|
||||
String serverName = player.getCurrentServer().get().getServer().getServerInfo().getName();
|
||||
|
||||
if (Storage.Blacklist.isDisabledServer(serverName)) {
|
||||
super.write(ctx, msg, promise);
|
||||
return;
|
||||
}
|
||||
|
||||
AvailableCommandsPacket commands = (AvailableCommandsPacket) packet;
|
||||
final List<Group> groups = GroupManager.getPlayerGroups(sender);
|
||||
|
||||
if(!commands.getRootNode().getChildren().isEmpty()) {
|
||||
Map<String, CommandsCache> cache = Storage.getLoader().getCommandsCacheMap();
|
||||
@@ -286,7 +383,7 @@ public class VelocityPacketAnalyzer {
|
||||
if (PermissionUtil.hasBypassPermission(player)) return;
|
||||
|
||||
final boolean newer = player.getProtocolVersion().getProtocol() > 340;
|
||||
final List<String> playerCommands = commandsCache.getPlayerCommands(commandsAsString, player, serverName);
|
||||
final List<String> playerCommands = commandsCache.getPlayerCommands(commandsAsString, sender, groups, serverName);
|
||||
|
||||
if (commands.getRootNode().getChildren().size() == 1 && newer
|
||||
&& commands.getRootNode().getChild("args") != null
|
||||
@@ -296,16 +393,16 @@ public class VelocityPacketAnalyzer {
|
||||
return;
|
||||
}
|
||||
|
||||
commands.getRootNode().getChildren().removeIf(command -> {
|
||||
commands.getRootNode().getChildren().removeIf(command -> {
|
||||
if (command == null || command.getName() == null)
|
||||
return true;
|
||||
|
||||
if (command.getName().equals("args"))
|
||||
return false;
|
||||
|
||||
if (Storage.ConfigSections.Settings.CUSTOM_PLUGIN.isTabCompletable(command.getName()) || Storage.ConfigSections.Settings.CUSTOM_VERSION.isTabCompletable(command.getName())) {
|
||||
return false;
|
||||
}
|
||||
if (Storage.ConfigSections.Settings.CUSTOM_PLUGIN.isTabCompletable(command.getName()) || Storage.ConfigSections.Settings.CUSTOM_VERSION.isTabCompletable(command.getName())) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return !playerCommands.contains(command.getName());
|
||||
});
|
||||
|
||||
@@ -11,9 +11,11 @@ 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.subarguments.SubArguments;
|
||||
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.sender.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import de.rayzs.pat.api.event.PATEventHandler;
|
||||
@@ -85,7 +87,7 @@ public class Storage {
|
||||
}
|
||||
|
||||
Logger.warning("No known permissions plugin found, so some features may be disabled.");
|
||||
Logger.warning("Read more about it here: http://rayzs.de/products/proantitab/nkppf");
|
||||
Logger.warning("Read more about it here: https://rayzs.de/products/proantitab/nkppf");
|
||||
}
|
||||
|
||||
public static PermissionPlugin getPermissionPlugin() {
|
||||
@@ -108,6 +110,7 @@ public class Storage {
|
||||
}
|
||||
|
||||
public static void loadToken() {
|
||||
Files.TOKEN.reload();
|
||||
|
||||
boolean invalidEnv = false;
|
||||
|
||||
@@ -216,11 +219,11 @@ public class Storage {
|
||||
|
||||
associatedServers.forEach(s -> {
|
||||
List<UUID> playerIds = Storage.getLoader().getPlayerIdsByServer(s);
|
||||
List<String> commands = new ArrayList<>(SubArgsModule.getServerCommands(s));
|
||||
List<String> commands = new ArrayList<>(SubArguments.getServerCommands(s));
|
||||
|
||||
playerIds.forEach(playerId -> {
|
||||
List<String> playerCommands = new ArrayList<>(commands);
|
||||
playerCommands.addAll(SubArgsModule.getGroupCommands(playerId, s));
|
||||
playerCommands.addAll(SubArguments.getGroupCommands(playerId, s));
|
||||
|
||||
PATEventHandler.callUpdatePlayerCommandsEvents(playerId, playerCommands, true);
|
||||
});
|
||||
@@ -236,8 +239,8 @@ public class Storage {
|
||||
List<UUID> playerIds = Storage.getLoader().getPlayerIds();
|
||||
|
||||
playerIds.forEach(playerId -> {
|
||||
List<String> playerCommands = new ArrayList<>(SubArgsModule.getServerCommands(playerId));
|
||||
playerCommands.addAll(SubArgsModule.getGroupCommands(playerId));
|
||||
List<String> playerCommands = new ArrayList<>(SubArguments.getServerCommands(playerId));
|
||||
playerCommands.addAll(SubArguments.getGroupCommands(playerId));
|
||||
|
||||
PATEventHandler.callUpdatePlayerCommandsEvents(playerId, playerCommands, false);
|
||||
});
|
||||
@@ -267,7 +270,7 @@ public class Storage {
|
||||
|
||||
playerIds.forEach(playerId -> {
|
||||
List<String> playerCommands = new ArrayList<>(commands);
|
||||
playerCommands.addAll(SubArgsModule.getGroupCommands(playerId));
|
||||
playerCommands.addAll(SubArguments.getGroupCommands(playerId));
|
||||
|
||||
PATEventHandler.callUpdatePlayerCommandsEvents(playerId, playerCommands, true);
|
||||
});
|
||||
@@ -278,8 +281,8 @@ public class Storage {
|
||||
|
||||
// Quickly updates all player subarguments.
|
||||
public static void quickSubArgumentUpdate(UUID uuid) {
|
||||
List<String> playerCommands = new ArrayList<>(SubArgsModule.getServerCommands(uuid));
|
||||
playerCommands.addAll(SubArgsModule.getGroupCommands(uuid));
|
||||
List<String> playerCommands = new ArrayList<>(SubArguments.getServerCommands(uuid));
|
||||
playerCommands.addAll(SubArguments.getGroupCommands(uuid));
|
||||
|
||||
PATEventHandler.callUpdatePlayerCommandsEvents(uuid, playerCommands, false);
|
||||
}
|
||||
@@ -340,6 +343,7 @@ public class Storage {
|
||||
|
||||
public static class Settings {
|
||||
|
||||
public static AllowGroupOverrulingSection ALLOW_GROUP_OVERRULING = new AllowGroupOverrulingSection();
|
||||
public static AutoLowercaseCommandsSection AUTO_LOWERCASE_COMMANDS = new AutoLowercaseCommandsSection();
|
||||
public static BlockNamespaceCommandsSection BLOCK_NAMESPACE_COMMANDS = new BlockNamespaceCommandsSection();
|
||||
public static HandleThroughProxySection HANDLE_THROUGH_PROXY = new HandleThroughProxySection();
|
||||
@@ -555,41 +559,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 (Storage.getPermissionPlugin() != PermissionPlugin.NONE) {
|
||||
if (PermissionUtil.hasBypassPermission(player, command)) {
|
||||
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) {
|
||||
@@ -617,34 +642,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; // Shorter version of above's code
|
||||
|
||||
}
|
||||
|
||||
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, false/*!turn*/);
|
||||
listed = BLACKLIST.isListed(command, false);
|
||||
}
|
||||
|
||||
if (server == null) {
|
||||
@@ -661,11 +687,11 @@ public class Storage {
|
||||
blacklists.add(BLACKLIST);
|
||||
|
||||
for (GeneralBlacklist blacklist : blacklists) {
|
||||
if (listed/* && turn*/) {
|
||||
if (listed) {
|
||||
break;
|
||||
}
|
||||
|
||||
listed = blacklist.isListed(command, false/*turn*/);
|
||||
listed = blacklist.isListed(command, false);
|
||||
}
|
||||
|
||||
if (!listed && type != BlockType.BOTH) {
|
||||
@@ -677,6 +703,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()))
|
||||
@@ -700,6 +739,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);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -23,7 +23,7 @@ public class ExtractSection extends ConfigStorage {
|
||||
return;
|
||||
}
|
||||
|
||||
USAGE = new ConfigSectionHelper<String>(this, "usage", "&7Usage: &f/pat extract [plugin] <use-colon> &7or &f<group> <use-colon>").getOrSet();
|
||||
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();
|
||||
|
||||
|
||||
+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();
|
||||
}
|
||||
}
|
||||
-5
@@ -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 {
|
||||
|
||||
@@ -29,8 +28,4 @@ public class AutoLowercaseCommandsSection extends ConfigStorage {
|
||||
|
||||
return !StringUtils.isLowercased(command);
|
||||
}
|
||||
|
||||
public boolean doesBypass(Object targetObj) {
|
||||
return !ENABLED || PermissionUtil.hasPermission(targetObj, "auto-lowercase");
|
||||
}
|
||||
}
|
||||
+13
-7
@@ -1,14 +1,13 @@
|
||||
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 +17,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 || sender.hasPermission("namespace");
|
||||
}
|
||||
}
|
||||
@@ -9,13 +9,14 @@ 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, false/*!Storage.ConfigSections.Settings.TURN_BLACKLIST_TO_WHITELIST.ENABLED*/);
|
||||
return isListed(command, false);
|
||||
}
|
||||
|
||||
public boolean isListed(String command, boolean ignoreColons) {
|
||||
@@ -25,11 +26,13 @@ public class BlacklistStorage extends StorageTemplate implements Serializable {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!isNegated(command) && commands.contains("*")) {
|
||||
return true;
|
||||
boolean isNegated = Storage.Blacklist.BlockTypeFetcher.isNegated(command);
|
||||
|
||||
if (!isNegated) {
|
||||
command = StringUtils.getFirstArg(command);
|
||||
}
|
||||
|
||||
for (String listedCommand : commands) {
|
||||
for (String listedCommand : hiddenCommands) {
|
||||
if (listedCommand == null)
|
||||
continue;
|
||||
|
||||
@@ -40,14 +43,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) {
|
||||
listedCommand = StringUtils.getFirstArg(listedCommand);
|
||||
}
|
||||
|
||||
if (caseSensitive && listedCommand.equals(command)) {
|
||||
return true;
|
||||
} else if (!caseSensitive && listedCommand.equalsIgnoreCase(command)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -59,14 +62,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;
|
||||
}
|
||||
|
||||
@@ -79,6 +85,10 @@ public class BlacklistStorage extends StorageTemplate implements Serializable {
|
||||
return commands;
|
||||
}
|
||||
|
||||
public List<String> getHiddenCommands() {
|
||||
return hiddenCommands;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void save() {
|
||||
getConfig().setAndSave(getNavigatePath(), commands);
|
||||
@@ -87,19 +97,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;
|
||||
}
|
||||
}
|
||||
@@ -2,7 +2,7 @@ package de.rayzs.pat.plugin;
|
||||
|
||||
import de.rayzs.pat.api.brand.CustomServerBrand;
|
||||
import de.rayzs.pat.plugin.converter.StorageConverter;
|
||||
import de.rayzs.pat.plugin.modules.SubArgsModule;
|
||||
import de.rayzs.pat.plugin.subarguments.SubArguments;
|
||||
import de.rayzs.pat.plugin.process.CommandProcess;
|
||||
import de.rayzs.pat.api.netty.bukkit.BukkitPacketAnalyzer;
|
||||
import de.rayzs.pat.api.communication.BackendUpdater;
|
||||
@@ -23,8 +23,6 @@ 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.action.ActionHandler;
|
||||
import de.rayzs.pat.utils.sender.CommandSender;
|
||||
import de.rayzs.pat.utils.sender.CommandSenderHandler;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
@@ -135,11 +133,14 @@ public class BukkitLoader extends JavaPlugin implements PluginLoader {
|
||||
ConfigUpdater.broadcastMissingParts();
|
||||
|
||||
ActionHandler.initialize();
|
||||
SubArgsModule.initialize();
|
||||
SubArguments.initialize();
|
||||
|
||||
StorageConverter.initialize();
|
||||
|
||||
PATScheduler.createScheduler(this::loadAllCommands);
|
||||
PATScheduler.createScheduler(() -> {
|
||||
Storage.reload();
|
||||
loadAllCommands();
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -287,7 +288,7 @@ public class BukkitLoader extends JavaPlugin implements PluginLoader {
|
||||
}
|
||||
|
||||
Player player = Bukkit.getPlayer(packet.getTargetUUID());
|
||||
if (player != null) {
|
||||
if (player != null && Reflection.getMinor() >= 13) {
|
||||
player.updateCommands();
|
||||
}
|
||||
}
|
||||
@@ -353,10 +354,6 @@ public class BukkitLoader extends JavaPlugin implements PluginLoader {
|
||||
|
||||
if (!loaded) {
|
||||
loaded = true;
|
||||
Bukkit.getOnlinePlayers().forEach(player -> {
|
||||
CommandSender sender = CommandSenderHandler.from(player);
|
||||
sender.updateGroups();
|
||||
});
|
||||
}
|
||||
|
||||
if (Reflection.getMinor() >= 13 && updatedList) {
|
||||
@@ -394,6 +391,48 @@ public class BukkitLoader extends JavaPlugin implements PluginLoader {
|
||||
return pluginNames;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getAllCommands(boolean useColons) {
|
||||
List<String> commands = new ArrayList<>();
|
||||
|
||||
for (Map.Entry<String, Command> entry : BukkitLoader.getCommandsMap().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 : BukkitLoader.getCommandsMap().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) {
|
||||
|
||||
@@ -4,7 +4,7 @@ package de.rayzs.pat.plugin;
|
||||
import de.rayzs.pat.api.brand.CustomServerBrand;
|
||||
import de.rayzs.pat.plugin.converter.StorageConverter;
|
||||
import de.rayzs.pat.plugin.process.CommandProcess;
|
||||
import de.rayzs.pat.plugin.modules.SubArgsModule;
|
||||
import de.rayzs.pat.plugin.subarguments.SubArguments;
|
||||
import de.rayzs.pat.api.netty.proxy.BungeePacketAnalyzer;
|
||||
import de.rayzs.pat.utils.configuration.Configurator;
|
||||
import de.rayzs.pat.utils.configuration.updater.ConfigUpdater;
|
||||
@@ -101,7 +101,7 @@ public class BungeeLoader extends Plugin implements PluginLoader {
|
||||
ConfigUpdater.broadcastMissingParts();
|
||||
|
||||
ActionHandler.initialize();
|
||||
SubArgsModule.initialize();
|
||||
SubArguments.initialize();
|
||||
|
||||
StorageConverter.initialize();
|
||||
|
||||
@@ -109,6 +109,8 @@ public class BungeeLoader extends Plugin implements PluginLoader {
|
||||
for (int i : new Integer[] { 1, 5, 15 }) {
|
||||
ProxyServer.getInstance().getScheduler().schedule(this, BungeePacketAnalyzer::loadProxyCommands, i, TimeUnit.SECONDS);
|
||||
}
|
||||
|
||||
BungeePacketAnalyzer.injectAll();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -144,6 +146,11 @@ public class BungeeLoader extends Plugin implements PluginLoader {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getAllCommands(boolean useColons) {
|
||||
return List.of();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getConsoleSender() {
|
||||
return ProxyServer.getInstance().getConsole();
|
||||
@@ -272,6 +279,11 @@ public class BungeeLoader extends Plugin implements PluginLoader {
|
||||
return pluginNames;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getPluginCommands(String pluginName, boolean useColons) {
|
||||
return List.of();
|
||||
}
|
||||
|
||||
public void startUpdaterTask() {
|
||||
if (!Storage.ConfigSections.Settings.UPDATE.ENABLED)
|
||||
return;
|
||||
|
||||
@@ -41,6 +41,9 @@ public interface PluginLoader {
|
||||
List<String> getOnlinePlayerNames();
|
||||
List<String> getOfflinePlayerNames();
|
||||
|
||||
List<String> getAllCommands(boolean useColons);
|
||||
List<String> getPluginCommands(String pluginName, boolean useColons);
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* %n = Plugin name
|
||||
|
||||
@@ -6,8 +6,9 @@ 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.api.netty.proxy.VelocityPacketAnalyzer;
|
||||
import de.rayzs.pat.plugin.converter.StorageConverter;
|
||||
import de.rayzs.pat.plugin.modules.SubArgsModule;
|
||||
import de.rayzs.pat.plugin.subarguments.SubArguments;
|
||||
import de.rayzs.pat.plugin.process.CommandProcess;
|
||||
import de.rayzs.pat.utils.CommandsCache;
|
||||
import de.rayzs.pat.plugin.metrics.impl.VelocityMetrics;
|
||||
@@ -38,9 +39,9 @@ import java.util.*;
|
||||
|
||||
@Plugin(name = "ProAntiTab",
|
||||
id = "proantitab",
|
||||
version = "2.1.2",
|
||||
version = "2.2.1",
|
||||
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),
|
||||
@@ -102,7 +103,7 @@ public class VelocityLoader implements PluginLoader {
|
||||
startUpdaterTask();
|
||||
|
||||
if (!Storage.ConfigSections.Settings.DISABLE_SYNC.DISABLED)
|
||||
server.getScheduler().buildTask(this, Communicator::syncData).delay(5, TimeUnit.SECONDS).schedule();
|
||||
server.getScheduler().buildTask(this, () -> Communicator.syncData()).delay(5, TimeUnit.SECONDS).schedule();
|
||||
|
||||
Storage.PLUGIN_OBJECT = this;
|
||||
|
||||
@@ -114,16 +115,18 @@ public class VelocityLoader implements PluginLoader {
|
||||
Logger.info("Successfully hooked into PAPIProxyBridge!");
|
||||
}
|
||||
|
||||
if(Storage.USE_SIMPLECLOUD)
|
||||
if (Storage.USE_SIMPLECLOUD)
|
||||
Logger.warning("Detected SimpleCloud and therefore MiniMessages by Kyori are disabled!");
|
||||
|
||||
Storage.broadcastPermissionsPluginNotice();
|
||||
ConfigUpdater.broadcastMissingParts();
|
||||
|
||||
ActionHandler.initialize();
|
||||
SubArgsModule.initialize();
|
||||
SubArguments.initialize();
|
||||
|
||||
StorageConverter.initialize();
|
||||
|
||||
VelocityPacketAnalyzer.injectAll();
|
||||
}
|
||||
|
||||
public static org.slf4j.Logger getPluginLogger() {
|
||||
@@ -141,9 +144,9 @@ public class VelocityLoader implements PluginLoader {
|
||||
public static void delayedPlayerReload(UUID uuid) {
|
||||
server.getScheduler().buildTask(VelocityLoader.instance, () -> {
|
||||
String serverName = Storage.getLoader().getPlayerServerName(uuid);
|
||||
List<String> commands = new ArrayList<>(SubArgsModule.getServerCommands(serverName));
|
||||
List<String> commands = new ArrayList<>(SubArguments.getServerCommands(serverName));
|
||||
|
||||
commands.addAll(SubArgsModule.getGroupCommands(uuid, serverName));
|
||||
commands.addAll(SubArguments.getGroupCommands(uuid, serverName));
|
||||
|
||||
PATEventHandler.callUpdatePlayerCommandsEvents(uuid, commands, true);
|
||||
}).delay(1, TimeUnit.SECONDS).schedule();
|
||||
@@ -157,6 +160,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();
|
||||
@@ -297,6 +305,11 @@ public class VelocityLoader implements PluginLoader {
|
||||
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,8 @@
|
||||
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.sender.CommandSender;
|
||||
import de.rayzs.pat.utils.sender.CommandSenderHandler;
|
||||
import org.bukkit.event.player.PlayerCommandSendEvent;
|
||||
@@ -23,6 +25,7 @@ public class BukkitAntiTabListener implements Listener {
|
||||
@EventHandler (priority = EventPriority.LOWEST)
|
||||
public void onPlayerCommandSend(PlayerCommandSendEvent event) {
|
||||
final Player player = event.getPlayer();
|
||||
final CommandSender sender = CommandSenderHandler.from(player);
|
||||
final UUID uuid = player.getUniqueId();
|
||||
|
||||
|
||||
@@ -56,16 +59,15 @@ public class BukkitAntiTabListener implements Listener {
|
||||
|
||||
if (!player.isOp() && knownOperators.contains(uuid)) {
|
||||
knownOperators.remove(uuid);
|
||||
|
||||
CommandSender sender = CommandSenderHandler.getSenderFromUUID(uuid);
|
||||
PermissionUtil.reloadPermissions(sender);
|
||||
PermissionUtil.reloadPermissions(player.getUniqueId());
|
||||
}
|
||||
|
||||
if (PermissionUtil.hasBypassPermission(player)) {
|
||||
if (PermissionUtil.hasBypassPermission(sender)) {
|
||||
return;
|
||||
}
|
||||
|
||||
final List<String> playerCommands = COMMANDS_CACHE.getPlayerCommands(new ArrayList<>(event.getCommands()), player);
|
||||
final List<Group> groups = GroupManager.getPlayerGroups(sender);
|
||||
final List<String> playerCommands = COMMANDS_CACHE.getPlayerCommands(new ArrayList<>(event.getCommands()), sender, groups);
|
||||
final FilteredSuggestionEvent filteredSuggestionEvent = PATEventHandler.callFilteredSuggestionEvents(player, playerCommands);
|
||||
|
||||
event.getCommands().clear();
|
||||
|
||||
+37
-14
@@ -2,6 +2,10 @@ package de.rayzs.pat.plugin.listeners.bukkit;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
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.sender.CommandSenderHandler;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.entity.Player;
|
||||
@@ -22,15 +26,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 = CommandSenderHandler.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 +50,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 = CommandSenderHandler.from(player);
|
||||
|
||||
final String commandFirstArg = StringUtils.getFirstArg(event.getMessage());
|
||||
|
||||
if (Storage.ConfigSections.Settings.AUTO_LOWERCASE_COMMANDS.isCommand(commandFirstArg)) {
|
||||
@@ -71,6 +78,14 @@ public class BukkitBlockCommandListener implements Listener {
|
||||
command = command.substring(1);
|
||||
command = StringUtils.getFirstArg(command);
|
||||
|
||||
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(
|
||||
@@ -79,10 +94,6 @@ public class BukkitBlockCommandListener implements Listener {
|
||||
"%command%", displayCommand,
|
||||
"%world%", worldName);
|
||||
|
||||
if (PermissionUtil.hasBypassPermission(player, command)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (Storage.ConfigSections.Settings.CUSTOM_PLUGIN.isCommand(command)) {
|
||||
|
||||
MessageTranslator.send(
|
||||
@@ -127,13 +138,25 @@ public class BukkitBlockCommandListener implements Listener {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!Storage.ConfigSections.Settings.CANCEL_COMMAND.ENABLED)
|
||||
return;
|
||||
|
||||
if (Storage.ConfigSections.Settings.HANDLE_THROUGH_PROXY.ENABLED)
|
||||
return;
|
||||
final boolean cancelBlockedCommand = Storage.ConfigSections.Settings.CANCEL_COMMAND.ENABLED;
|
||||
final List<Group> groups = GroupManager.getPlayerGroups(sender);
|
||||
|
||||
if (!Storage.Blacklist.canPlayerAccessChat(player, command)) {
|
||||
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(
|
||||
player,
|
||||
event.getMessage(),
|
||||
|
||||
@@ -6,7 +6,6 @@ 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.logger.Logger;
|
||||
import de.rayzs.pat.plugin.modules.SubArgsModule;
|
||||
import de.rayzs.pat.utils.Reflection;
|
||||
import de.rayzs.pat.utils.message.MessageTranslator;
|
||||
import de.rayzs.pat.utils.permission.PermissionPlugin;
|
||||
@@ -18,9 +17,6 @@ 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 {
|
||||
@@ -53,8 +49,6 @@ public class BukkitPlayerListener implements Listener {
|
||||
|
||||
if (Storage.getPermissionPlugin() == PermissionPlugin.GROUPMANAGER) {
|
||||
PermissionUtil.reloadPermissions(sender);
|
||||
} else {
|
||||
sender.updateGroups();
|
||||
}
|
||||
|
||||
if (Reflection.getMinor() >= 13) {
|
||||
@@ -81,7 +75,7 @@ public class BukkitPlayerListener implements Listener {
|
||||
Storage.quickSubArgumentUpdate(uuid);
|
||||
}
|
||||
|
||||
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());
|
||||
|
||||
@@ -39,7 +39,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) {
|
||||
|
||||
@@ -2,27 +2,48 @@ 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.api.netty.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 de.rayzs.pat.utils.sender.CommandSenderHandler;
|
||||
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 = CommandSenderHandler.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 +51,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(player.getUniqueId(), 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());
|
||||
}
|
||||
}
|
||||
@@ -1,8 +1,12 @@
|
||||
package de.rayzs.pat.plugin.listeners.bungee;
|
||||
|
||||
import de.rayzs.pat.api.event.events.ExecuteCommandEvent;
|
||||
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.sender.CommandSender;
|
||||
import de.rayzs.pat.utils.sender.CommandSenderHandler;
|
||||
import net.md_5.bungee.api.event.ChatEvent;
|
||||
import net.md_5.bungee.api.plugin.Listener;
|
||||
import de.rayzs.pat.plugin.logger.Logger;
|
||||
@@ -20,15 +24,17 @@ 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 = CommandSenderHandler.from(player);
|
||||
final String serverName = player.getServer().getInfo().getName();
|
||||
|
||||
String command = event.getMessage();
|
||||
|
||||
if (PermissionUtil.hasBypassPermission(player, command) || Storage.Blacklist.isDisabledServer(serverName))
|
||||
if (PermissionUtil.hasBypassPermission(sender, command) || Storage.Blacklist.isDisabledServer(serverName))
|
||||
return;
|
||||
|
||||
command = command.startsWith("/") ? command.substring(1) : command;
|
||||
@@ -37,7 +43,7 @@ public class BungeeBlockCommandListener implements Listener {
|
||||
final String displayCommand = StringUtils.replaceTriggers(command, "", "\\", "<", ">", "&");
|
||||
|
||||
|
||||
List<String> notificationMessage = MessageTranslator.replaceMessageList(
|
||||
final List<String> notificationMessage = MessageTranslator.replaceMessageList(
|
||||
Storage.ConfigSections.Messages.NOTIFICATION.ALERT,
|
||||
"%player%", player.getName(),
|
||||
"%command%", displayCommand,
|
||||
@@ -87,10 +93,25 @@ public class BungeeBlockCommandListener implements Listener {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!Storage.ConfigSections.Settings.CANCEL_COMMAND.ENABLED)
|
||||
return;
|
||||
final List<Group> groups = GroupManager.getPlayerGroups(sender);
|
||||
final boolean cancelBlockedCommand = Storage.ConfigSections.Settings.CANCEL_COMMAND.ENABLED;
|
||||
|
||||
if (!Storage.Blacklist.canPlayerAccessChat(player, command, serverName)) {
|
||||
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(
|
||||
player,
|
||||
event.getMessage(),
|
||||
|
||||
+1
-2
@@ -33,9 +33,8 @@ public class BungeePlayerConnectionListener implements Listener {
|
||||
}, 500, TimeUnit.MILLISECONDS);
|
||||
|
||||
PermissionUtil.setPlayerPermissions(sender);
|
||||
sender.updateGroups();
|
||||
|
||||
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());
|
||||
|
||||
@@ -9,7 +9,11 @@ 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 de.rayzs.pat.utils.sender.CommandSenderHandler;
|
||||
import io.github.waterfallmc.waterfall.event.ProxyDefineCommandsEvent;
|
||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||
import net.md_5.bungee.api.plugin.Command;
|
||||
@@ -21,27 +25,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) || PermissionUtil.hasBypassPermission(player))
|
||||
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 = CommandSenderHandler.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().getCommandsCacheMap();
|
||||
|
||||
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);
|
||||
|
||||
List<String> playerCommands = commandsCache.getPlayerCommands(commandsAsString, player, 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())) {
|
||||
|
||||
@@ -16,7 +16,11 @@ 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;
|
||||
import de.rayzs.pat.utils.sender.CommandSenderHandler;
|
||||
|
||||
public class VelocityAntiTabListener {
|
||||
|
||||
@@ -28,25 +32,32 @@ public class VelocityAntiTabListener {
|
||||
|
||||
@Subscribe (order = PostOrder.LAST)
|
||||
public void onTabComplete(TabCompleteEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
final Player player = event.getPlayer();
|
||||
|
||||
if (!event.getPartialMessage().startsWith("/")) {
|
||||
return;
|
||||
}
|
||||
|
||||
String serverName = player.getCurrentServer().isPresent() ? player.getCurrentServer().get().getServerInfo().getName() : "unknown";
|
||||
final String serverName = player.getCurrentServer().isPresent() ? player.getCurrentServer().get().getServerInfo().getName() : "unknown";
|
||||
|
||||
if (Storage.Blacklist.isDisabledServer(serverName))
|
||||
if (Storage.Blacklist.isDisabledServer(serverName)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (PermissionUtil.hasBypassPermission(player) || event.getSuggestions().isEmpty() || !player.getCurrentServer().isPresent()) return;
|
||||
final CommandSender sender = CommandSenderHandler.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());
|
||||
@@ -56,17 +67,19 @@ public class VelocityAntiTabListener {
|
||||
@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;
|
||||
}
|
||||
|
||||
if (PermissionUtil.hasBypassPermission(player)) {
|
||||
final CommandSender sender = CommandSenderHandler.from(player);
|
||||
|
||||
if (PermissionUtil.hasBypassPermission(sender)) {
|
||||
return;
|
||||
}
|
||||
|
||||
String serverName = player.getCurrentServer().get().getServer().getServerInfo().getName();
|
||||
final String serverName = player.getCurrentServer().get().getServer().getServerInfo().getName();
|
||||
|
||||
if (Storage.Blacklist.isDisabledServer(serverName)) {
|
||||
return;
|
||||
@@ -78,14 +91,18 @@ public class VelocityAntiTabListener {
|
||||
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);
|
||||
|
||||
final boolean newer = player.getProtocolVersion().getProtocol() > 340, argsChildrenExist = event.getRootNode().getChild("args") != null;
|
||||
final List<String> playerCommands = commandsCache.getPlayerCommands(commandsAsString, player, serverName);
|
||||
final List<String> playerCommands = commandsCache.getPlayerCommands(commandsAsString, sender, groups, serverName);
|
||||
|
||||
if (event.getRootNode().getChildren().size() == 1
|
||||
&& newer && argsChildrenExist
|
||||
|
||||
+42
-14
@@ -4,12 +4,17 @@ import com.velocitypowered.api.event.Subscribe;
|
||||
import com.velocitypowered.api.event.command.CommandExecuteEvent;
|
||||
import com.velocitypowered.api.command.CommandSource;
|
||||
import de.rayzs.pat.api.event.events.ExecuteCommandEvent;
|
||||
import de.rayzs.pat.utils.group.Group;
|
||||
import de.rayzs.pat.utils.group.GroupManager;
|
||||
import de.rayzs.pat.utils.message.MessageTranslator;
|
||||
import de.rayzs.pat.utils.permission.PermissionUtil;
|
||||
import com.velocitypowered.api.proxy.Player;
|
||||
import de.rayzs.pat.api.storage.Storage;
|
||||
import de.rayzs.pat.utils.StringUtils;
|
||||
import de.rayzs.pat.api.event.*;
|
||||
import de.rayzs.pat.utils.sender.CommandSender;
|
||||
import de.rayzs.pat.utils.sender.CommandSenderHandler;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class VelocityBlockCommandListener {
|
||||
@@ -24,29 +29,31 @@ public class VelocityBlockCommandListener {
|
||||
}
|
||||
|
||||
public static CommandExecuteEvent handleCommand(CommandExecuteEvent event) {
|
||||
if(!event.getResult().isAllowed())
|
||||
if (!event.getResult().isAllowed()) {
|
||||
return event;
|
||||
}
|
||||
|
||||
CommandSource commandSource = event.getCommandSource();
|
||||
Object consoleSender = Storage.getLoader().getConsoleSender();
|
||||
final CommandSource commandSource = event.getCommandSource();
|
||||
final Object consoleSender = Storage.getLoader().getConsoleSender();
|
||||
|
||||
if(! (commandSource instanceof Player))
|
||||
return event;
|
||||
|
||||
Player player = (Player) commandSource;
|
||||
String command = StringUtils.getFirstArg(event.getCommand());
|
||||
|
||||
String serverName = player.getCurrentServer().isPresent()
|
||||
final Player player = (Player) commandSource;
|
||||
final CommandSender sender = CommandSenderHandler.from(player);
|
||||
final String serverName = player.getCurrentServer().isPresent()
|
||||
? player.getCurrentServer().get().getServerInfo().getName()
|
||||
: "unknown";
|
||||
|
||||
if (PermissionUtil.hasBypassPermission(player, command) || Storage.Blacklist.isDisabledServer(serverName))
|
||||
final String command = StringUtils.getFirstArg(event.getCommand());
|
||||
|
||||
if (PermissionUtil.hasBypassPermission(sender, command) || Storage.Blacklist.isDisabledServer(serverName))
|
||||
return event;
|
||||
|
||||
final String displayCommand = StringUtils.replaceTriggers(command, "", "\\", "<", ">", "&");
|
||||
|
||||
|
||||
List<String> notificationMessage = MessageTranslator.replaceMessageList(
|
||||
final List<String> notificationMessage = MessageTranslator.replaceMessageList(
|
||||
Storage.ConfigSections.Messages.NOTIFICATION.ALERT,
|
||||
"%player%", player.getUsername(),
|
||||
"%command%", displayCommand,
|
||||
@@ -97,10 +104,28 @@ public class VelocityBlockCommandListener {
|
||||
return event;
|
||||
}
|
||||
|
||||
if (!Storage.ConfigSections.Settings.CANCEL_COMMAND.ENABLED)
|
||||
return event;
|
||||
final boolean cancelBlockedCommand = Storage.ConfigSections.Settings.CANCEL_COMMAND.ENABLED;
|
||||
final List<Group> groups = GroupManager.getPlayerGroups(sender);
|
||||
|
||||
if (!Storage.Blacklist.canPlayerAccessChat(player, command, serverName)) {
|
||||
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 event;
|
||||
}
|
||||
|
||||
|
||||
if (!allowed) {
|
||||
ExecuteCommandEvent executeCommandEvent = PATEventHandler.callExecuteCommandEvents(
|
||||
player,
|
||||
event.getCommand(),
|
||||
@@ -128,9 +153,12 @@ public class VelocityBlockCommandListener {
|
||||
return event;
|
||||
}
|
||||
|
||||
ExecuteCommandEvent executeCommandEvent = PATEventHandler.callExecuteCommandEvents(player, event.getCommand(), false, false);
|
||||
if (executeCommandEvent.isBlocked())
|
||||
|
||||
final ExecuteCommandEvent executeCommandEvent = PATEventHandler.callExecuteCommandEvents(player, event.getCommand(), false, false);
|
||||
|
||||
if (executeCommandEvent.isBlocked()) {
|
||||
event.setResult(CommandExecuteEvent.CommandResult.denied());
|
||||
}
|
||||
|
||||
return event;
|
||||
}
|
||||
|
||||
+1
-2
@@ -43,9 +43,8 @@ public class VelocityConnectionListener {
|
||||
}).delay(500, TimeUnit.MILLISECONDS).schedule();
|
||||
|
||||
PermissionUtil.setPlayerPermissions(sender);
|
||||
sender.updateGroups();
|
||||
|
||||
if(Storage.OUTDATED && PermissionUtil.hasPermission(player, "joinupdate")) {
|
||||
if (Storage.OUTDATED && PermissionUtil.hasPermission(sender, "joinupdate")) {
|
||||
server.getScheduler().buildTask(loader, () -> {
|
||||
if (player.isActive())
|
||||
MessageTranslator.send(player, Storage.ConfigSections.Settings.UPDATE.OUTDATED, "%player%", player.getUsername());
|
||||
|
||||
@@ -90,13 +90,15 @@ public class Logger {
|
||||
.append(Storage.ConfigSections.Settings.TURN_BLACKLIST_TO_WHITELIST.ENABLED ? "WHITELIST" : "BLACKLIST")
|
||||
.append("\n");
|
||||
|
||||
builder.append("Detected Software-API: ")
|
||||
.append(Reflection.isProxyServer()
|
||||
? Reflection.isPaper() ? "Waterfall" :
|
||||
Reflection.isVelocityServer() ? "Velocity" : "Bungeecord"
|
||||
: Reflection.isFoliaServer() ? "Folia"
|
||||
: Reflection.isPaper() ? "Paper" : "Spigot")
|
||||
.append("\n");
|
||||
builder.append("Detected Software-API: ");
|
||||
|
||||
if (Reflection.isProxyServer()) {
|
||||
builder.append(Reflection.isPaper() ? "Waterfall" : Reflection.isVelocityServer() ? "Velocity" : "Bungeecord");
|
||||
} else {
|
||||
builder.append(Reflection.isFoliaServer() ? "Folia" : Reflection.isPaper() ? "Paper" : "Spigot");
|
||||
}
|
||||
|
||||
builder.append("\n");
|
||||
|
||||
builder.append("Installed plugins: \n ")
|
||||
.append(String.join("\n ", Storage.getLoader().getPluginNames("%n (%v)")))
|
||||
@@ -129,7 +131,7 @@ public class Logger {
|
||||
.append("\n");
|
||||
|
||||
builder.append("last-received-sync: ")
|
||||
.append(Storage.ConfigSections.Settings.HANDLE_THROUGH_PROXY.ENABLED ? Storage.LAST_SYNC : "Deactivated")
|
||||
.append(Storage.ConfigSections.Settings.HANDLE_THROUGH_PROXY.ENABLED ? TimeConverter.calcAndGetTime(Storage.LAST_SYNC) : "Deactivated")
|
||||
.append("\n");
|
||||
}
|
||||
|
||||
@@ -143,7 +145,7 @@ public class Logger {
|
||||
.append("\n");
|
||||
|
||||
builder.append("last-sent-sync: ")
|
||||
.append(Storage.ConfigSections.Settings.DISABLE_SYNC.DISABLED ? "Deactivated" : (System.currentTimeMillis() - Storage.LAST_SYNC))
|
||||
.append(Storage.ConfigSections.Settings.DISABLE_SYNC.DISABLED ? "Deactivated" : (TimeConverter.calcAndGetTime(Storage.LAST_SYNC)))
|
||||
.append("\n\n");
|
||||
|
||||
for (ClientInfo client : Communicator.CLIENTS) {
|
||||
|
||||
@@ -58,6 +58,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 +68,8 @@ public class AddCommand extends ProCommand {
|
||||
|
||||
if (!exist) {
|
||||
Storage.Blacklist.getBlacklist().add(command).save();
|
||||
if (loadBlacklist) Storage.Blacklist.getBlacklist().load();
|
||||
|
||||
Storage.handleChange();
|
||||
}
|
||||
|
||||
|
||||
@@ -34,6 +34,7 @@ public class ClearCommand extends ProCommand {
|
||||
}
|
||||
|
||||
Storage.Blacklist.getBlacklist().clear().save();
|
||||
Storage.Blacklist.getBlacklist().load();
|
||||
Storage.handleChange();
|
||||
|
||||
CONFIRMATION.remove(sender.getUniqueId());
|
||||
|
||||
@@ -3,18 +3,10 @@ package de.rayzs.pat.plugin.process.impl.local.modify;
|
||||
import de.rayzs.pat.api.command.ProCommand;
|
||||
import de.rayzs.pat.api.storage.Storage;
|
||||
import de.rayzs.pat.api.storage.storages.BlacklistStorage;
|
||||
import de.rayzs.pat.plugin.BukkitLoader;
|
||||
import de.rayzs.pat.plugin.converter.Converter;
|
||||
import de.rayzs.pat.plugin.converter.StorageConverter;
|
||||
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 org.bukkit.Bukkit;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
import org.bukkit.plugin.PluginManager;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
public class ExtractCommand extends ProCommand {
|
||||
@@ -26,6 +18,37 @@ public class ExtractCommand extends ProCommand {
|
||||
);
|
||||
}
|
||||
|
||||
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) {
|
||||
|
||||
@@ -34,40 +57,29 @@ public class ExtractCommand extends ProCommand {
|
||||
return true;
|
||||
}
|
||||
|
||||
Mode mode = Mode.NON_COLON;
|
||||
|
||||
String pluginName = args[0].toLowerCase();
|
||||
boolean failed = false, useColons = false;
|
||||
boolean failed = false;
|
||||
Group group = null;
|
||||
|
||||
|
||||
if (args.length == 2) {
|
||||
|
||||
group = GroupManager.getGroupByName(args[1]);
|
||||
|
||||
if (group == null) {
|
||||
useColons = Boolean.parseBoolean(args[1]);
|
||||
|
||||
if (!useColons && !args[1].equalsIgnoreCase("false")) {
|
||||
failed = true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
try {
|
||||
useColons = Boolean.parseBoolean(args[1]);
|
||||
} catch (Exception exception) {
|
||||
group = GroupManager.getGroupByName(args[1]);
|
||||
failed = group == null;
|
||||
mode = Mode.getMode(args[1]);
|
||||
failed = mode == null;
|
||||
}
|
||||
|
||||
} else if (args.length == 3) {
|
||||
group = GroupManager.getGroupByName(args[1]);
|
||||
|
||||
if (group == null) {
|
||||
group = GroupManager.getGroupByName(args[1]);
|
||||
mode = Mode.getMode(args[2]);
|
||||
|
||||
if (group == null || mode == null) {
|
||||
failed = true;
|
||||
} else {
|
||||
try {
|
||||
useColons = Boolean.parseBoolean(args[2]);
|
||||
} catch (Exception exception) {
|
||||
failed = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -77,7 +89,7 @@ public class ExtractCommand extends ProCommand {
|
||||
}
|
||||
|
||||
List<String> pluginNames = Storage.getLoader().getPluginNames("%n");
|
||||
boolean pluginFound = false;
|
||||
boolean pluginFound = false, all = pluginName.equalsIgnoreCase("*");
|
||||
|
||||
for (String name : pluginNames) {
|
||||
if (name.equalsIgnoreCase(pluginName)) {
|
||||
@@ -86,7 +98,7 @@ public class ExtractCommand extends ProCommand {
|
||||
}
|
||||
}
|
||||
|
||||
if (!pluginFound) {
|
||||
if (!all && !pluginFound) {
|
||||
sender.sendMessage(StringUtils.replace(Storage.ConfigSections.Messages.EXTRACT.PLUGIN_NOT_FOUND,
|
||||
"%plugin%", pluginName)
|
||||
);
|
||||
@@ -94,16 +106,12 @@ public class ExtractCommand extends ProCommand {
|
||||
return true;
|
||||
}
|
||||
|
||||
List<String> commands = new ArrayList<>();
|
||||
for (Map.Entry<String, Command> entry : BukkitLoader.getCommandsMap().entrySet()) {
|
||||
if (entry.getKey().toLowerCase().startsWith(pluginName + ":")) {
|
||||
String command = entry.getKey().substring(args[0].length() + 1);
|
||||
commands.add(command);
|
||||
List<String> commands = all
|
||||
? Storage.getLoader().getAllCommands(mode.doesIncludesColons())
|
||||
: Storage.getLoader().getPluginCommands(args[0], mode.doesIncludesColons());
|
||||
|
||||
if (useColons) {
|
||||
commands.add(entry.getKey());
|
||||
}
|
||||
}
|
||||
if (mode == Mode.ONLY_COLON) {
|
||||
commands = commands.stream().filter(command -> command.contains(":")).toList();
|
||||
}
|
||||
|
||||
BlacklistStorage storage = group == null
|
||||
@@ -128,14 +136,16 @@ public class ExtractCommand extends ProCommand {
|
||||
final int length = args.length;
|
||||
|
||||
if (length <= 1) {
|
||||
return Storage.getLoader().getPluginNames("%n");
|
||||
final List<String> suggestions = Storage.getLoader().getPluginNames("%n");
|
||||
suggestions.add("*");
|
||||
|
||||
return suggestions;
|
||||
}
|
||||
|
||||
List<String> result = new ArrayList<>();
|
||||
|
||||
if (length == 2 || length == 3 && GroupManager.getGroupByName(args[1]) != null) {
|
||||
result.add("true");
|
||||
result.add("false");
|
||||
result.addAll(Arrays.stream(Mode.values()).map(Mode::getName).toList());
|
||||
}
|
||||
|
||||
if (length == 2) {
|
||||
|
||||
@@ -57,6 +57,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 +65,8 @@ public class RemoveCommand extends ProCommand {
|
||||
|
||||
if (exist) {
|
||||
Storage.Blacklist.getBlacklist().remove(command).save();
|
||||
if (loadBlacklist) Storage.Blacklist.getBlacklist().load();
|
||||
|
||||
Storage.handleChange();
|
||||
}
|
||||
|
||||
|
||||
@@ -22,8 +22,6 @@ 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);
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@ package de.rayzs.pat.plugin.process.impl.server;
|
||||
|
||||
import de.rayzs.pat.api.command.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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
+71
-11
@@ -1,10 +1,11 @@
|
||||
package de.rayzs.pat.plugin.modules;
|
||||
package de.rayzs.pat.plugin.subarguments;
|
||||
|
||||
import de.rayzs.pat.api.storage.blacklist.impl.GeneralBlacklist;
|
||||
import de.rayzs.pat.plugin.modules.events.ExecuteCommand;
|
||||
import de.rayzs.pat.plugin.modules.events.TabCompletion;
|
||||
import de.rayzs.pat.plugin.modules.events.UpdateList;
|
||||
import de.rayzs.pat.utils.node.CommandNodeHelper;
|
||||
import de.rayzs.pat.plugin.subarguments.events.ExecuteCommand;
|
||||
import de.rayzs.pat.plugin.subarguments.events.TabCompletion;
|
||||
import de.rayzs.pat.plugin.subarguments.events.UpdateList;
|
||||
import de.rayzs.pat.utils.node.BukkitCommandNodeHelper;
|
||||
import de.rayzs.pat.utils.node.ProxyCommandNodeHelper;
|
||||
import de.rayzs.pat.utils.permission.PermissionPlugin;
|
||||
import de.rayzs.pat.utils.response.ResponseHandler;
|
||||
import de.rayzs.pat.api.event.PATEventHandler;
|
||||
@@ -17,7 +18,7 @@ import de.rayzs.pat.utils.group.*;
|
||||
import de.rayzs.pat.utils.*;
|
||||
import java.util.*;
|
||||
|
||||
public class SubArgsModule {
|
||||
public class SubArguments {
|
||||
|
||||
public static List<String> GENERAL_LIST, BLOCKED_MESSAGE, PLAYER_NAMES, ONLINE_PLAYERS;
|
||||
public static HashMap<UUID, Arguments> PLAYER_COMMANDS = new HashMap<>();
|
||||
@@ -55,7 +56,7 @@ public class SubArgsModule {
|
||||
Arguments.ARGUMENTS.clearArguments();
|
||||
|
||||
GENERAL_LIST.forEach(command -> Arguments.ARGUMENTS.buildArgumentStacks(command));
|
||||
SubArgsModule.PLAYER_COMMANDS = new HashMap<>();
|
||||
SubArguments.PLAYER_COMMANDS = new HashMap<>();
|
||||
}
|
||||
|
||||
public static void updateMessages() {
|
||||
@@ -63,7 +64,7 @@ public class SubArgsModule {
|
||||
ResponseHandler.update();
|
||||
}
|
||||
|
||||
public static void handleCommandNode(UUID uuid, CommandNodeHelper helper) {
|
||||
public static void handleCommandNode(UUID uuid, ProxyCommandNodeHelper helper) {
|
||||
if (!Storage.ConfigSections.Settings.TURN_BLACKLIST_TO_WHITELIST.ENABLED)
|
||||
return;
|
||||
|
||||
@@ -73,13 +74,72 @@ public class SubArgsModule {
|
||||
}
|
||||
|
||||
ArgumentSource source = arguments.TAB_ARGUMENTS;
|
||||
if (source == null) return;
|
||||
if (source == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
List<String> inputs = source.getAllInputs();
|
||||
List<String> allEntries = inputs.stream().map(StringUtils::getFirstArg).toList();
|
||||
|
||||
helper.removeIf(allEntries::contains);
|
||||
inputs.forEach(input -> helper.add(input, true));
|
||||
|
||||
for (String input : inputs) {
|
||||
final boolean negated = Storage.Blacklist.BlockTypeFetcher.isNegated(input);
|
||||
|
||||
if (!negated) {
|
||||
helper.add(input, true);
|
||||
continue;
|
||||
}
|
||||
|
||||
final Storage.Blacklist.BlockType type = Storage.Blacklist.BlockTypeFetcher.getType(input);
|
||||
if (type != Storage.Blacklist.BlockType.BOTH && type != Storage.Blacklist.BlockType.TAB) {
|
||||
continue;
|
||||
}
|
||||
|
||||
input = Storage.Blacklist.BlockTypeFetcher.cleanse(input);
|
||||
helper.removeSubArguments(input);
|
||||
}
|
||||
}
|
||||
|
||||
public static void handleCommandNode(UUID uuid, BukkitCommandNodeHelper helper) throws Exception {
|
||||
if (!Storage.ConfigSections.Settings.TURN_BLACKLIST_TO_WHITELIST.ENABLED)
|
||||
return;
|
||||
|
||||
Arguments arguments = PLAYER_COMMANDS.get(uuid);
|
||||
if (arguments == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
ArgumentSource source = arguments.TAB_ARGUMENTS;
|
||||
if (source == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
List<String> inputs = source.getAllInputs();
|
||||
List<String> argumentsList = new ArrayList<>();
|
||||
|
||||
for (String input : inputs) {
|
||||
final Storage.Blacklist.BlockType type = Storage.Blacklist.BlockTypeFetcher.getType(input);
|
||||
if (type == Storage.Blacklist.BlockType.CHAT) {
|
||||
continue;
|
||||
}
|
||||
|
||||
final boolean negated = Storage.Blacklist.BlockTypeFetcher.isNegated(input);
|
||||
input = Storage.Blacklist.BlockTypeFetcher.cleanse(input);
|
||||
|
||||
if (!negated) {
|
||||
argumentsList.add(input);
|
||||
continue;
|
||||
}
|
||||
|
||||
helper.removeSubArguments(input);
|
||||
}
|
||||
|
||||
if (argumentsList.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
helper.spareRecursively(argumentsList);
|
||||
}
|
||||
|
||||
public static List<String> getServerCommands(UUID uuid) {
|
||||
@@ -110,7 +170,7 @@ public class SubArgsModule {
|
||||
List<Group> groups;
|
||||
|
||||
if (Storage.getPermissionPlugin() == PermissionPlugin.NONE) {
|
||||
CommandSender sender = CommandSenderHandler.getSenderFromUUID(uuid);
|
||||
CommandSender sender = CommandSenderHandler.from(uuid);
|
||||
groups = GroupManager.getPlayerGroups(sender);
|
||||
} else {
|
||||
groups = GroupManager.getPlayerGroups(uuid);
|
||||
+4
-4
@@ -1,7 +1,7 @@
|
||||
package de.rayzs.pat.plugin.modules.events;
|
||||
package de.rayzs.pat.plugin.subarguments.events;
|
||||
|
||||
import de.rayzs.pat.api.event.events.ExecuteCommandEvent;
|
||||
import de.rayzs.pat.plugin.modules.SubArgsModule;
|
||||
import de.rayzs.pat.plugin.subarguments.SubArguments;
|
||||
import de.rayzs.pat.utils.message.MessageTranslator;
|
||||
import de.rayzs.pat.utils.response.ResponseHandler;
|
||||
import de.rayzs.pat.api.storage.Storage;
|
||||
@@ -60,7 +60,7 @@ public class ExecuteCommand extends ExecuteCommandEvent {
|
||||
}
|
||||
|
||||
private boolean isBlocked(CommandSender sender, String command) {
|
||||
final Arguments arguments = SubArgsModule.PLAYER_COMMANDS.getOrDefault(sender.getUniqueId(), Arguments.ARGUMENTS);
|
||||
final Arguments arguments = SubArguments.PLAYER_COMMANDS.getOrDefault(sender.getUniqueId(), Arguments.ARGUMENTS);
|
||||
final List<String> commands = new ArrayList<>(arguments.CHAT_ARGUMENTS.getGeneralArgument().getInputs());
|
||||
final String firstArgument = StringUtils.getFirstArg(command);
|
||||
|
||||
@@ -119,7 +119,7 @@ public class ExecuteCommand extends ExecuteCommandEvent {
|
||||
).toList();
|
||||
|
||||
if (!placeholderCommands.isEmpty()) {
|
||||
command = SubArgsModule.replacePlaceholders(command);
|
||||
command = SubArguments.replacePlaceholders(command);
|
||||
}
|
||||
|
||||
String cpyCommand;
|
||||
+10
-10
@@ -1,7 +1,7 @@
|
||||
package de.rayzs.pat.plugin.modules.events;
|
||||
package de.rayzs.pat.plugin.subarguments.events;
|
||||
|
||||
import de.rayzs.pat.api.event.events.FilteredTabCompletionEvent;
|
||||
import de.rayzs.pat.plugin.modules.SubArgsModule;
|
||||
import de.rayzs.pat.plugin.subarguments.SubArguments;
|
||||
import de.rayzs.pat.api.storage.Storage;
|
||||
import de.rayzs.pat.utils.*;
|
||||
import de.rayzs.pat.utils.sender.CommandSenderHandler;
|
||||
@@ -22,7 +22,7 @@ public class TabCompletion extends FilteredTabCompletionEvent {
|
||||
? (UUID) event.getSenderObj()
|
||||
: CommandSenderHandler.from(event.getSenderObj()).getUniqueId();
|
||||
|
||||
final Arguments arguments = SubArgsModule.PLAYER_COMMANDS.getOrDefault(uuid, Arguments.ARGUMENTS);
|
||||
final Arguments arguments = SubArguments.PLAYER_COMMANDS.getOrDefault(uuid, Arguments.ARGUMENTS);
|
||||
|
||||
List<String> possibilities = event.getCompletion(), result = new ArrayList<>(arguments.getResultTab(cursor));
|
||||
final List<String> negated = new ArrayList<>(arguments.getResultTab("!" + cursor));
|
||||
@@ -67,19 +67,19 @@ public class TabCompletion extends FilteredTabCompletionEvent {
|
||||
|
||||
if (result.contains("%players%")) {
|
||||
possibilities.remove("%players%");
|
||||
possibilities.addAll(SubArgsModule.getPlayerNames());
|
||||
possibilities.addAll(SubArguments.getPlayerNames());
|
||||
}
|
||||
|
||||
if (result.contains("%online_players%")) {
|
||||
possibilities.remove("%online_players%");
|
||||
possibilities.addAll(SubArgsModule.getOnlinePlayerNames());
|
||||
possibilities.addAll(SubArguments.getOnlinePlayerNames());
|
||||
}
|
||||
|
||||
if (result.contains("%hidden_players%")) {
|
||||
possibilities.remove("%hidden_players%");
|
||||
|
||||
possibilities.addAll(event.getCompletion().stream().filter(completion -> {
|
||||
if (SubArgsModule.getPlayerNames().contains(completion))
|
||||
if (SubArguments.getPlayerNames().contains(completion))
|
||||
return false;
|
||||
|
||||
return result.contains(completion);
|
||||
@@ -94,7 +94,7 @@ public class TabCompletion extends FilteredTabCompletionEvent {
|
||||
possibilities.remove("%hidden_online_players%");
|
||||
|
||||
possibilities.addAll(event.getCompletion().stream().filter(completion -> {
|
||||
if (SubArgsModule.getOnlinePlayerNames().contains(completion))
|
||||
if (SubArguments.getOnlinePlayerNames().contains(completion))
|
||||
return false;
|
||||
|
||||
return result.contains(completion);
|
||||
@@ -109,10 +109,10 @@ public class TabCompletion extends FilteredTabCompletionEvent {
|
||||
possibilities.removeIf(NumberUtils::isDigit);
|
||||
|
||||
if (result.contains("%players%"))
|
||||
possibilities.removeIf(possibility -> SubArgsModule.getPlayerNames().contains(possibility));
|
||||
possibilities.removeIf(possibility -> SubArguments.getPlayerNames().contains(possibility));
|
||||
|
||||
if (result.contains("%online_players%"))
|
||||
possibilities.removeIf(possibility -> SubArgsModule.getOnlinePlayerNames().contains(possibility));
|
||||
possibilities.removeIf(possibility -> SubArguments.getOnlinePlayerNames().contains(possibility));
|
||||
|
||||
|
||||
possibilities.removeIf(s -> {
|
||||
@@ -125,7 +125,7 @@ public class TabCompletion extends FilteredTabCompletionEvent {
|
||||
}
|
||||
|
||||
String firstCursorArg = StringUtils.getFirstArg(cursor.toLowerCase());
|
||||
if (possibilities.isEmpty() && !SubArgsModule.GENERAL_LIST.contains(firstCursorArg)) {
|
||||
if (possibilities.isEmpty() && !SubArguments.GENERAL_LIST.contains(firstCursorArg)) {
|
||||
return;
|
||||
}
|
||||
|
||||
+17
-13
@@ -1,6 +1,6 @@
|
||||
package de.rayzs.pat.plugin.modules.events;
|
||||
package de.rayzs.pat.plugin.subarguments.events;
|
||||
|
||||
import de.rayzs.pat.plugin.modules.SubArgsModule;
|
||||
import de.rayzs.pat.plugin.subarguments.SubArguments;
|
||||
import de.rayzs.pat.api.storage.Storage;
|
||||
import de.rayzs.pat.utils.sender.CommandSenderHandler;
|
||||
import de.rayzs.pat.api.event.events.*;
|
||||
@@ -13,22 +13,22 @@ public class UpdateList {
|
||||
public static UpdatePluginEvent UPDATE_PLUGIN_EVENT = new UpdatePluginEvent() {
|
||||
@Override
|
||||
public void handle(UpdatePluginEvent event) {
|
||||
SubArgsModule.updateMessages();
|
||||
SubArgsModule.updateList();
|
||||
SubArguments.updateMessages();
|
||||
SubArguments.updateList();
|
||||
}
|
||||
};
|
||||
|
||||
public static ServerPlayersChangeEvent SERVER_PLAYERS_CHANGE_EVENT = new ServerPlayersChangeEvent() {
|
||||
@Override
|
||||
public void handle(ServerPlayersChangeEvent event) {
|
||||
SubArgsModule.updatePlayerNames();
|
||||
SubArguments.updatePlayerNames();
|
||||
}
|
||||
};
|
||||
|
||||
public static ReceiveSyncEvent RECEIVE_SYNC_EVENT = new ReceiveSyncEvent() {
|
||||
@Override
|
||||
public void handle(ReceiveSyncEvent event) {
|
||||
SubArgsModule.updateList();
|
||||
SubArguments.updateList();
|
||||
}
|
||||
};
|
||||
|
||||
@@ -39,7 +39,7 @@ public class UpdateList {
|
||||
? (UUID) event.getSenderObj()
|
||||
: CommandSenderHandler.from(event.getSenderObj()).getUniqueId();
|
||||
|
||||
final Arguments argument = SubArgsModule.PLAYER_COMMANDS.getOrDefault(uuid, new Arguments());
|
||||
final Arguments argument = SubArguments.PLAYER_COMMANDS.getOrDefault(uuid, new Arguments());
|
||||
final String serverName = Storage.getLoader().getPlayerServerName(uuid);
|
||||
|
||||
argument.clearArguments();
|
||||
@@ -51,32 +51,36 @@ public class UpdateList {
|
||||
final List<String> chatInputs = new ArrayList<>(argument.CHAT_ARGUMENTS.getGeneralArgument().getInputs());
|
||||
final List<String> tabInput = new ArrayList<>(argument.TAB_ARGUMENTS.getGeneralArgument().getInputs());
|
||||
|
||||
|
||||
for (String command : chatInputs) {
|
||||
Storage.Blacklist.BlockType type = Storage.Blacklist.BlockTypeFetcher.getType(command);
|
||||
|
||||
if (type != Storage.Blacklist.BlockType.NEGATE)
|
||||
if (type != Storage.Blacklist.BlockType.NEGATE) {
|
||||
command = Storage.Blacklist.BlockTypeFetcher.modify(command, type);
|
||||
}
|
||||
|
||||
argument.CHAT_ARGUMENTS.buildArguments(Storage.Blacklist.BlockTypeFetcher.modify(command));
|
||||
argument.CHAT_ARGUMENTS.buildArguments(command);
|
||||
}
|
||||
|
||||
for (String command : tabInput) {
|
||||
Storage.Blacklist.BlockType type = Storage.Blacklist.BlockTypeFetcher.getType(command);
|
||||
|
||||
|
||||
if (type != Storage.Blacklist.BlockType.NEGATE)
|
||||
command = Storage.Blacklist.BlockTypeFetcher.modify(command, type);
|
||||
|
||||
argument.TAB_ARGUMENTS.buildArguments(command);
|
||||
}
|
||||
|
||||
for (String command : SubArgsModule.getGroupCommands(uuid, serverName))
|
||||
for (String command : SubArguments.getGroupCommands(uuid, serverName))
|
||||
argument.buildArgumentStacks(command);
|
||||
|
||||
for (String command : SubArgsModule.getServerCommands(uuid))
|
||||
for (String command : SubArguments.getServerCommands(uuid)) {
|
||||
argument.buildArgumentStacks(command);
|
||||
}
|
||||
|
||||
} else {
|
||||
List<String> groupCommands = SubArgsModule.getGroupCommands(uuid, serverName);
|
||||
List<String> groupCommands = SubArguments.getGroupCommands(uuid, serverName);
|
||||
|
||||
for (String command : argument.CHAT_ARGUMENTS.getGeneralArgument().getInputs()) {
|
||||
if (groupCommands.contains(command)) continue;
|
||||
@@ -91,7 +95,7 @@ public class UpdateList {
|
||||
}
|
||||
}
|
||||
|
||||
SubArgsModule.PLAYER_COMMANDS.putIfAbsent(uuid, argument);
|
||||
SubArguments.PLAYER_COMMANDS.putIfAbsent(uuid, argument);
|
||||
}
|
||||
};
|
||||
}
|
||||
@@ -5,10 +5,20 @@ import java.util.*;
|
||||
import de.rayzs.pat.api.event.PATEventHandler;
|
||||
import de.rayzs.pat.api.storage.Storage;
|
||||
import de.rayzs.pat.plugin.logger.Logger;
|
||||
import de.rayzs.pat.utils.group.Group;
|
||||
import de.rayzs.pat.utils.permission.PermissionUtil;
|
||||
import de.rayzs.pat.utils.sender.CommandSender;
|
||||
|
||||
public class CommandsCache {
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* RECODE PLANNED
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
private List<String> filteredCommands = null, allCommands = null;
|
||||
private boolean change = false;
|
||||
|
||||
@@ -46,7 +56,7 @@ public class CommandsCache {
|
||||
return;
|
||||
|
||||
LinkedList<String> tmpFilteredCommands = new LinkedList<>();
|
||||
List<String> tmpAllCommands = Collections.unmodifiableList(commands);
|
||||
List<String> tmpAllCommands = new ArrayList<>(commands);
|
||||
allCommands = tmpAllCommands;
|
||||
|
||||
final int length = allCommands.size();
|
||||
@@ -72,11 +82,11 @@ public class CommandsCache {
|
||||
filteredCommands = tmpFilteredCommands;
|
||||
}
|
||||
|
||||
public List<String> getPlayerCommands(Collection<String> unfilteredCommands, Object targetObj) {
|
||||
return getPlayerCommands(unfilteredCommands, targetObj, null);
|
||||
public List<String> getPlayerCommands(Collection<String> unfilteredCommands, CommandSender sender, List<Group> groups) {
|
||||
return getPlayerCommands(unfilteredCommands, sender, groups, null);
|
||||
}
|
||||
|
||||
public List<String> getPlayerCommands(Collection<String> unfilteredCommands, Object targetObj, String serverName) {
|
||||
public List<String> getPlayerCommands(Collection<String> unfilteredCommands, CommandSender sender, List<Group> groups, String serverName) {
|
||||
List<String> playerCommands = new LinkedList<>(unfilteredCommands);
|
||||
List<String> localFilteredCommands = filteredCommands == null ? null : new LinkedList<>();
|
||||
|
||||
@@ -96,8 +106,8 @@ public class CommandsCache {
|
||||
}
|
||||
|
||||
|
||||
if (!PermissionUtil.hasBypassPermission(targetObj)) {
|
||||
boolean hasNamespaceBypass = Storage.ConfigSections.Settings.BLOCK_NAMESPACE_COMMANDS.doesBypass(targetObj);
|
||||
if (!PermissionUtil.hasBypassPermission(sender)) {
|
||||
boolean hasNamespaceBypass = Storage.ConfigSections.Settings.BLOCK_NAMESPACE_COMMANDS.doesBypass(sender);
|
||||
|
||||
playerCommands.removeIf(command -> {
|
||||
if (!hasNamespaceBypass && Storage.ConfigSections.Settings.BLOCK_NAMESPACE_COMMANDS.isCommand(command)) {
|
||||
@@ -108,12 +118,12 @@ public class CommandsCache {
|
||||
return false;
|
||||
}
|
||||
|
||||
return !Storage.Blacklist.canPlayerAccessTab(targetObj, command, serverName);
|
||||
return !Storage.Blacklist.canPlayerAccessTab(sender, groups, command, serverName);
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
PATEventHandler.callUpdatePlayerCommandsEvents(targetObj, playerCommands, serverName != null);
|
||||
PATEventHandler.callUpdatePlayerCommandsEvents(sender, playerCommands, serverName != null);
|
||||
|
||||
return playerCommands.stream().map(command -> {
|
||||
command = StringUtils.getFirstArg(command);
|
||||
@@ -137,7 +147,7 @@ public class CommandsCache {
|
||||
|
||||
public void reset() {
|
||||
// Removed to reset the change state. Experimental change though
|
||||
//if(change) return;
|
||||
// if(change) return;
|
||||
// Prob. gonna change it to: if (CONNECTED_TO_BUNGEE && change) return;
|
||||
updateChangeState();
|
||||
filteredCommands = null;
|
||||
|
||||
@@ -50,7 +50,7 @@ public class VersionComparer {
|
||||
if (shouldAnnounce) {
|
||||
shouldAnnounce = false;
|
||||
|
||||
Logger.info("§8[§fPAT | Bukkit§8] §7Please be aware that you are currently using a §bdeveloper §7version of ProAntiTab. Bugs, errors and a lot of debug messages might be included.");
|
||||
Logger.info("§8[§fPAT | " + (Reflection.isProxyServer() ? "Proxy" : "Bukkit") + "§8] §7Please be aware that you are currently using a §bdeveloper §7version of ProAntiTab. Bugs, errors and a lot of debug messages might be included.");
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
@@ -11,6 +11,7 @@ import de.rayzs.pat.utils.ExpireCache;
|
||||
import de.rayzs.pat.utils.Reflection;
|
||||
import de.rayzs.pat.utils.configuration.ConfigurationBuilder;
|
||||
import de.rayzs.pat.utils.permission.PermissionUtil;
|
||||
import de.rayzs.pat.utils.sender.CommandSender;
|
||||
|
||||
public class Group implements Serializable {
|
||||
|
||||
@@ -108,6 +109,10 @@ public class Group implements Serializable {
|
||||
|
||||
public void add(String command) {
|
||||
this.generalGroupBlacklist.add(command).save();
|
||||
|
||||
if (command.startsWith("plugin=") || command.startsWith("!")) {
|
||||
this.generalGroupBlacklist.load();
|
||||
}
|
||||
}
|
||||
|
||||
public void add(String command, String server) {
|
||||
@@ -118,6 +123,10 @@ public class Group implements Serializable {
|
||||
|
||||
public void remove(String command) {
|
||||
this.generalGroupBlacklist.remove(command).save();
|
||||
|
||||
if (command.startsWith("plugin=") || command.startsWith("!")) {
|
||||
this.generalGroupBlacklist.load();
|
||||
}
|
||||
}
|
||||
|
||||
public void remove(String command, String server) {
|
||||
@@ -128,6 +137,7 @@ public class Group implements Serializable {
|
||||
|
||||
public void clear() {
|
||||
this.generalGroupBlacklist.clear().save();
|
||||
this.generalGroupBlacklist.load();
|
||||
}
|
||||
|
||||
public void clear(String server) {
|
||||
@@ -146,8 +156,12 @@ public class Group implements Serializable {
|
||||
this.priority = priority;
|
||||
}
|
||||
|
||||
public boolean hasPermission(Object targetObj) {
|
||||
return PermissionUtil.hasPermission(targetObj, "group." + this.groupName);
|
||||
public boolean hasPermission(CommandSender sender) {
|
||||
return PermissionUtil.hasPermission(sender, "group." + this.groupName);
|
||||
}
|
||||
|
||||
public boolean hasPermission(UUID uuid) {
|
||||
return PermissionUtil.hasPermission(uuid, "group." + this.groupName);
|
||||
}
|
||||
|
||||
public boolean contains(String command) {
|
||||
|
||||
@@ -9,76 +9,89 @@ import de.rayzs.pat.api.storage.blacklist.impl.GroupBlacklist;
|
||||
import de.rayzs.pat.plugin.logger.Logger;
|
||||
import de.rayzs.pat.utils.Reflection;
|
||||
import de.rayzs.pat.utils.sender.CommandSender;
|
||||
import de.rayzs.pat.utils.sender.CommandSenderHandler;
|
||||
|
||||
public class GroupManager {
|
||||
|
||||
private static final List<Group> GROUPS = new LinkedList<>();
|
||||
private static final int INVALID_GROUP_PRIORITY = Integer.MAX_VALUE -1;
|
||||
|
||||
public static void initialize() {
|
||||
|
||||
Object obj = Storage.Files.STORAGE.get("groups");
|
||||
|
||||
if (obj == null) {
|
||||
Logger.info("No groups found. Skipping...");
|
||||
return;
|
||||
}
|
||||
|
||||
Storage.Files.STORAGE.getKeys("groups", false).forEach(GroupManager::registerGroup);
|
||||
if(!Reflection.isProxyServer()) return;
|
||||
|
||||
if (!Reflection.isProxyServer()) {
|
||||
return;
|
||||
}
|
||||
|
||||
getGroups().forEach(group -> {
|
||||
|
||||
Object objServ = Storage.Files.STORAGE.get("groups." + group.getGroupName() + ".servers");
|
||||
|
||||
if (objServ == null) {
|
||||
//Logger.info("Group " + group.getGroupName() + " has no servers. Skipping...");
|
||||
return;
|
||||
}
|
||||
|
||||
Storage.Files.STORAGE.getKeys("groups." + group.getGroupName() + ".servers", false).forEach(key -> {
|
||||
group.getOrCreateGroupBlacklist(key, true);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
public static List<Group> getPlayerGroups(Object player) {
|
||||
final int invalidPriority = Integer.MAX_VALUE -1;
|
||||
|
||||
List<Group> playerGroups = new ArrayList<>(GroupManager.getGroups().stream().filter(group -> group.hasPermission(player)).toList());
|
||||
|
||||
int priority = playerGroups.stream()
|
||||
.mapToInt(Group::getPriority)
|
||||
.filter(group -> group <= invalidPriority)
|
||||
.min().orElse(invalidPriority);
|
||||
|
||||
playerGroups.removeIf(group -> group.getPriority() > priority);
|
||||
|
||||
return playerGroups;
|
||||
}
|
||||
|
||||
public static List<Group> getPlayerGroups(UUID uuid) {
|
||||
final int invalidPriority = Integer.MAX_VALUE -1;
|
||||
|
||||
List<Group> playerGroups = new ArrayList<>(GroupManager.getGroups().stream().filter(group -> group.hasPermission(uuid)).toList());
|
||||
|
||||
int priority = playerGroups.stream()
|
||||
.mapToInt(Group::getPriority)
|
||||
.filter(group -> group <= invalidPriority)
|
||||
.min().orElse(invalidPriority);
|
||||
.filter(group -> group <= INVALID_GROUP_PRIORITY)
|
||||
.min().orElse(INVALID_GROUP_PRIORITY);
|
||||
|
||||
playerGroups.removeIf(group -> group.getPriority() > priority);
|
||||
|
||||
return playerGroups;
|
||||
}
|
||||
|
||||
public static boolean canAccessCommand(Object targetObj, String unmodifiedCommand, Storage.Blacklist.BlockType type) {
|
||||
return canAccessCommand(targetObj, unmodifiedCommand, type, null);
|
||||
public static List<Group> getPlayerGroups(CommandSender sender) {
|
||||
List<Group> playerGroups = new ArrayList<>(GroupManager.getGroups().stream().filter(group -> group.hasPermission(sender)).toList());
|
||||
|
||||
int priority = playerGroups.stream()
|
||||
.mapToInt(Group::getPriority)
|
||||
.filter(group -> group <= INVALID_GROUP_PRIORITY)
|
||||
.min().orElse(INVALID_GROUP_PRIORITY);
|
||||
|
||||
playerGroups.removeIf(group -> group.getPriority() > priority);
|
||||
return playerGroups;
|
||||
}
|
||||
|
||||
public static boolean canAccessCommand(Object targetObj, String unmodifiedCommand, Storage.Blacklist.BlockType type, String server) {
|
||||
final CommandSender sender = CommandSenderHandler.from(targetObj);
|
||||
public static AccessResult canAccessCommand(List<Group> groups, String unmodifiedCommand, Storage.Blacklist.BlockType type) {
|
||||
return canAccessCommand(groups, unmodifiedCommand, type, null);
|
||||
}
|
||||
|
||||
if (sender == null) {
|
||||
Logger.warning("Failed to load player! (GroupManager#62)");
|
||||
return false;
|
||||
public static AccessResult canAccessCommand(List<Group> groups, String unmodifiedCommand, Storage.Blacklist.BlockType type, String server) {
|
||||
if (groups == null || groups.isEmpty()) {
|
||||
return AccessResult.NO_GROUPS;
|
||||
}
|
||||
|
||||
final List<Group> playerGroups = sender.getGroups();
|
||||
|
||||
if (playerGroups == null || playerGroups.isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
String command = type.toString() + unmodifiedCommand;
|
||||
String allCommand = type + "*";
|
||||
String negatedCommand = type.toString() + BlockType.NEGATE + unmodifiedCommand;
|
||||
|
||||
boolean permitted = false;
|
||||
for (Group group : playerGroups) {
|
||||
boolean all = false,
|
||||
permitted = false,
|
||||
negated = false;
|
||||
|
||||
for (Group group : groups) {
|
||||
|
||||
all = group.contains(allCommand);
|
||||
permitted = group.contains(command);
|
||||
negated = group.contains(negatedCommand);
|
||||
|
||||
if (permitted) {
|
||||
break;
|
||||
@@ -90,21 +103,38 @@ public class GroupManager {
|
||||
|
||||
for (String s : servers) {
|
||||
|
||||
if (group.contains(command, s)) {
|
||||
permitted = true;
|
||||
break;
|
||||
if (!all) {
|
||||
all = group.contains(allCommand, s);
|
||||
}
|
||||
|
||||
if (!permitted) {
|
||||
permitted = group.contains(command, s);
|
||||
}
|
||||
|
||||
if (!negated) {
|
||||
negated = group.contains(negatedCommand, s);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (permitted) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (negated) {
|
||||
return AccessResult.NEGATED;
|
||||
}
|
||||
|
||||
if (all) {
|
||||
return AccessResult.ALLOWED;
|
||||
}
|
||||
|
||||
if (!permitted && type != BlockType.BOTH)
|
||||
return canAccessCommand(targetObj, unmodifiedCommand, Storage.Blacklist.BlockType.BOTH, server);
|
||||
|
||||
return permitted;
|
||||
return canAccessCommand(groups, unmodifiedCommand, Storage.Blacklist.BlockType.BOTH, server);
|
||||
|
||||
return permitted ? AccessResult.ALLOWED : AccessResult.NOT_LISTED;
|
||||
}
|
||||
|
||||
public static void setGroup(String groupName, List<String> commands) {
|
||||
@@ -251,4 +281,19 @@ public class GroupManager {
|
||||
public static boolean isGroupRegistered(String groupName) {
|
||||
return getGroupByName(groupName) != null;
|
||||
}
|
||||
|
||||
public enum AccessResult {
|
||||
ALLOWED(true), NEGATED(false),
|
||||
NO_GROUPS(false), NOT_LISTED(false),
|
||||
UNKNOWN(false);
|
||||
|
||||
private final boolean bool;
|
||||
AccessResult(boolean bool) {
|
||||
this.bool = bool;
|
||||
}
|
||||
|
||||
public boolean asBoolean() {
|
||||
return this.bool;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -148,10 +148,6 @@ public class MessageTranslator {
|
||||
return PlaceholderReplacer.replace(targetObj, text);
|
||||
}
|
||||
|
||||
public static String replaceMessageString(String rawText, String... replacements) {
|
||||
return replaceMessage(StringUtils.replace(rawText, replacements));
|
||||
}
|
||||
|
||||
public static String replaceMessageString(Object targetObj, String rawText, String... replacements) {
|
||||
return replaceMessage(targetObj, StringUtils.replace(rawText, replacements));
|
||||
}
|
||||
@@ -189,8 +185,16 @@ public class MessageTranslator {
|
||||
return result;
|
||||
}
|
||||
|
||||
public static String translateIntoMiniMessage(String text) {
|
||||
return translator.translate(replaceMessage(text));
|
||||
public static void sendActionbar(Object targetObj, String message) {
|
||||
translator.sendActionbar(targetObj, message);
|
||||
}
|
||||
|
||||
public static void sendTitle(Object targetObj, String title, String subtitle, int fadeIn, int stay, int fadeOut) {
|
||||
translator.sendTitle(targetObj, title, subtitle, fadeIn, stay, fadeOut);
|
||||
}
|
||||
|
||||
public static void playSound(Object targetObj, String soundKey, float volume, float pitch) throws Exception {
|
||||
translator.playSound(targetObj, soundKey, volume, pitch);
|
||||
}
|
||||
|
||||
public static void closeAudiences() {
|
||||
|
||||
@@ -1,8 +1,32 @@
|
||||
package de.rayzs.pat.utils.message;
|
||||
|
||||
import de.rayzs.pat.utils.StringUtils;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.minimessage.MiniMessage;
|
||||
import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
|
||||
|
||||
public interface Translator {
|
||||
|
||||
MiniMessage miniMessage = MiniMessage.miniMessage();
|
||||
|
||||
String translate(String text);
|
||||
|
||||
void send(Object target, String text);
|
||||
|
||||
void sendActionbar(Object target, String text);
|
||||
|
||||
void sendTitle(Object target, String title, String subtitle, int fadeIn, int stay, int fadeOut);
|
||||
|
||||
void playSound(Object target, String soundKey, float volume, float pitch) throws Exception;
|
||||
|
||||
default Component toComponent(String text) {
|
||||
text = StringUtils.replace(text, "§", "&");
|
||||
|
||||
Component legacy = LegacyComponentSerializer.legacyAmpersand().deserialize(text);
|
||||
text = StringUtils.replace(miniMessage.serialize(legacy), "\\", "");
|
||||
|
||||
return miniMessage.deserialize(text);
|
||||
}
|
||||
|
||||
void close();
|
||||
}
|
||||
@@ -1,18 +1,19 @@
|
||||
package de.rayzs.pat.utils.message.translators;
|
||||
|
||||
import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
|
||||
import net.kyori.adventure.platform.bukkit.BukkitAudiences;
|
||||
import net.kyori.adventure.text.minimessage.MiniMessage;
|
||||
import net.kyori.adventure.audience.Audience;
|
||||
import de.rayzs.pat.plugin.BukkitLoader;
|
||||
import net.kyori.adventure.title.Title;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import de.rayzs.pat.utils.message.*;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.time.Duration;
|
||||
|
||||
public class BukkitMessageTranslator implements Translator {
|
||||
|
||||
private BukkitAudiences audiences;
|
||||
private final MiniMessage miniMessage = MiniMessage.miniMessage();
|
||||
|
||||
public BukkitMessageTranslator() {
|
||||
audiences = BukkitAudiences.create(BukkitLoader.getPlugin());
|
||||
@@ -26,9 +27,34 @@ public class BukkitMessageTranslator implements Translator {
|
||||
@Override
|
||||
public void send(Object target, String text) {
|
||||
Audience audience = target instanceof Player ? audiences.player((Player) target) : audiences.sender((CommandSender) target);
|
||||
text = this.miniMessage.serialize(LegacyComponentSerializer.legacyAmpersand().deserialize(text.replace("§", "&")));
|
||||
if(text.contains("\\")) text = text.replace("\\", "");
|
||||
audience.sendMessage(this.miniMessage.deserialize(text));
|
||||
|
||||
audience.sendMessage(toComponent(text));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendActionbar(Object target, String text) {
|
||||
Audience audience = target instanceof Player ? audiences.player((Player) target) : audiences.sender((CommandSender) target);
|
||||
|
||||
audience.sendActionBar(toComponent(text));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendTitle(Object target, String titleStr, String subtitleStr, int fadeIn, int stay, int fadeOut) {
|
||||
Audience audience = target instanceof Player ? audiences.player((Player) target) : audiences.sender((CommandSender) target);
|
||||
|
||||
Title.Times times = Title.Times.times(Duration.ofMillis(fadeIn), Duration.ofMillis(stay), Duration.ofMillis(fadeOut));
|
||||
Title title = Title.title(toComponent(titleStr), toComponent(subtitleStr), times);
|
||||
|
||||
audience.showTitle(title);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void playSound(Object target, String soundKey, float volume, float pitch) throws Exception {
|
||||
if (target instanceof Player player) {
|
||||
Sound sound = Sound.valueOf(soundKey);
|
||||
|
||||
player.playSound(player.getLocation(), sound, volume, pitch);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,8 +1,11 @@
|
||||
package de.rayzs.pat.utils.message.translators;
|
||||
|
||||
import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
|
||||
import de.rayzs.pat.utils.StringUtils;
|
||||
import net.kyori.adventure.key.Key;
|
||||
import net.kyori.adventure.sound.Sound;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.platform.bungeecord.BungeeAudiences;
|
||||
import net.kyori.adventure.text.minimessage.MiniMessage;
|
||||
import net.kyori.adventure.title.Title;
|
||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||
import de.rayzs.pat.utils.message.MessageTranslator;
|
||||
import net.kyori.adventure.audience.Audience;
|
||||
@@ -10,10 +13,11 @@ import de.rayzs.pat.utils.message.Translator;
|
||||
import net.md_5.bungee.api.CommandSender;
|
||||
import de.rayzs.pat.plugin.BungeeLoader;
|
||||
|
||||
import java.time.Duration;
|
||||
|
||||
public class BungeeMessageTranslator implements Translator {
|
||||
|
||||
private BungeeAudiences audiences;
|
||||
private final MiniMessage miniMessage = MiniMessage.miniMessage();
|
||||
|
||||
public BungeeMessageTranslator() {
|
||||
audiences = BungeeAudiences.create(BungeeLoader.getPlugin());
|
||||
@@ -27,9 +31,33 @@ public class BungeeMessageTranslator implements Translator {
|
||||
@Override
|
||||
public void send(Object target, String text) {
|
||||
Audience audience = target instanceof ProxiedPlayer ? audiences.player((ProxiedPlayer) target) : audiences.sender((CommandSender) target);
|
||||
text = this.miniMessage.serialize(LegacyComponentSerializer.legacyAmpersand().deserialize(text.replace("§", "&")));
|
||||
if(text.contains("\\")) text = text.replace("\\", "");
|
||||
audience.sendMessage(this.miniMessage.deserialize(text));
|
||||
|
||||
audience.sendMessage(toComponent(text));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendActionbar(Object target, String text) {
|
||||
Audience audience = target instanceof ProxiedPlayer ? audiences.player((ProxiedPlayer) target) : audiences.sender((CommandSender) target);
|
||||
|
||||
audience.sendActionBar(toComponent(text));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendTitle(Object target, String titleStr, String subtitleStr, int fadeIn, int stay, int fadeOut) {
|
||||
Audience audience = target instanceof ProxiedPlayer ? audiences.player((ProxiedPlayer) target) : audiences.sender((CommandSender) target);
|
||||
|
||||
Title.Times times = Title.Times.times(Duration.ofMillis(fadeIn), Duration.ofMillis(stay), Duration.ofMillis(fadeOut));
|
||||
Title title = Title.title(toComponent(titleStr), toComponent(subtitleStr), times);
|
||||
|
||||
audience.showTitle(title);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void playSound(Object target, String soundKey, float volume, float pitch) throws Exception {
|
||||
Audience audience = target instanceof ProxiedPlayer ? audiences.player((ProxiedPlayer) target) : audiences.sender((CommandSender) target);
|
||||
Sound sound = Sound.sound(Key.key(soundKey), Sound.Source.MASTER, 1f, 1f);
|
||||
|
||||
audience.playSound(sound, Sound.Emitter.self());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+34
-15
@@ -1,33 +1,52 @@
|
||||
package de.rayzs.pat.utils.message.translators;
|
||||
|
||||
import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
|
||||
import net.kyori.adventure.key.Key;
|
||||
import net.kyori.adventure.sound.Sound;
|
||||
import net.kyori.adventure.text.minimessage.MiniMessage;
|
||||
import com.velocitypowered.api.command.CommandSource;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import com.velocitypowered.api.proxy.*;
|
||||
import de.rayzs.pat.utils.message.*;
|
||||
import net.kyori.adventure.title.Title;
|
||||
|
||||
import java.time.Duration;
|
||||
|
||||
public class VelocityMessageTranslator implements Translator {
|
||||
|
||||
private final MiniMessage miniMessage = MiniMessage.miniMessage();
|
||||
|
||||
@Override
|
||||
public String translate(String text) {
|
||||
return miniMessage.serialize(miniMessage.deserialize(MessageTranslator.translateLegacy(text)));
|
||||
return MiniMessage.miniMessage().serialize(miniMessage.deserialize(MessageTranslator.translateLegacy(text)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void send(Object target, String text) {
|
||||
text = this.miniMessage.serialize(LegacyComponentSerializer.legacyAmpersand().deserialize(text.replace("§", "&")));
|
||||
if(text.contains("\\")) text = text.replace("\\", "");
|
||||
final Component component = this.miniMessage.deserialize(text);
|
||||
if (target instanceof CommandSource source) {
|
||||
source.sendMessage(toComponent(text));
|
||||
}
|
||||
}
|
||||
|
||||
if(target instanceof Player)
|
||||
((Player) target).sendMessage(component);
|
||||
else if(target instanceof CommandSource)
|
||||
((ConsoleCommandSource) target).sendMessage(component);
|
||||
else if(target instanceof ConsoleCommandSource)
|
||||
((ConsoleCommandSource) target).sendMessage(component);
|
||||
@Override
|
||||
public void sendActionbar(Object target, String text) {
|
||||
if (target instanceof CommandSource source) {
|
||||
source.sendActionBar(toComponent(text));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendTitle(Object target, String titleStr, String subtitleStr, int fadeIn, int stay, int fadeOut) {
|
||||
Title.Times times = Title.Times.times(Duration.ofMillis(fadeIn), Duration.ofMillis(stay), Duration.ofMillis(fadeOut));
|
||||
Title title = Title.title(toComponent(titleStr), toComponent(subtitleStr), times);
|
||||
|
||||
if (target instanceof CommandSource source) {
|
||||
source.showTitle(title);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void playSound(Object target, String soundKey, float volume, float pitch) throws Exception {
|
||||
if (target instanceof CommandSource source) {
|
||||
Sound sound = Sound.sound(Key.key(soundKey), Sound.Source.MASTER, 1f, 1f);
|
||||
|
||||
source.playSound(sound, Sound.Emitter.self());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -0,0 +1,301 @@
|
||||
package de.rayzs.pat.utils.node;
|
||||
|
||||
import de.rayzs.pat.utils.StringUtils;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.lang.reflect.Constructor;
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.*;
|
||||
|
||||
public class BukkitCommandNodeHelper {
|
||||
|
||||
private final List<SimpleNode> nodeList = new ArrayList<>();
|
||||
private final Object packetObj;
|
||||
private final List entries;
|
||||
private final Node root;
|
||||
|
||||
public BukkitCommandNodeHelper(Object packetObj) throws Exception {
|
||||
this.packetObj = packetObj;
|
||||
|
||||
final Class<?> commandsPacketClazz = packetObj.getClass();
|
||||
final Field rootIndexField = commandsPacketClazz.getDeclaredField("rootIndex");
|
||||
rootIndexField.setAccessible(true);
|
||||
|
||||
final int rootIndex = rootIndexField.getInt(packetObj);
|
||||
rootIndexField.setAccessible(false);
|
||||
|
||||
|
||||
final Field entriesField = commandsPacketClazz.getDeclaredField("entries");
|
||||
entriesField.setAccessible(true);
|
||||
|
||||
entries = (List) entriesField.get(packetObj);
|
||||
for (int i = 0; i < entries.size(); i++) {
|
||||
final Object nodeObj = entries.get(i);
|
||||
final Class<?> entryClass = nodeObj.getClass();
|
||||
final Field nodeChildrenField = entryClass.getDeclaredField("children");
|
||||
nodeChildrenField.setAccessible(true);
|
||||
|
||||
|
||||
int[] children = (int[]) nodeChildrenField.get(nodeObj);
|
||||
nodeChildrenField.setAccessible(false);
|
||||
|
||||
|
||||
final Field stubField = entryClass.getDeclaredField("stub");
|
||||
stubField.setAccessible(true);
|
||||
|
||||
String name = null;
|
||||
|
||||
final Object stubObj = stubField.get(nodeObj);
|
||||
if (stubObj != null) {
|
||||
final Class<?> stubClass = stubObj.getClass();
|
||||
final Field idField = stubClass.getDeclaredField("id");
|
||||
idField.setAccessible(true);
|
||||
|
||||
name = idField.get(stubObj).toString();
|
||||
|
||||
idField.setAccessible(false);
|
||||
}
|
||||
|
||||
stubField.setAccessible(false);
|
||||
|
||||
final SimpleNode simpleNode = new SimpleNode(rootIndex, i, children, name);
|
||||
nodeList.add(simpleNode);
|
||||
}
|
||||
|
||||
root = createRootNode(this, rootIndex, nodeList.toArray(new SimpleNode[0]));
|
||||
}
|
||||
|
||||
public void removeSubArguments(String command) throws Exception {
|
||||
final String[] args = command.split(" ");
|
||||
final Node child = getRoot().getChild(args[0]);
|
||||
|
||||
removeSubArguments(child, 0, args);
|
||||
}
|
||||
|
||||
public void spareRecursively(List<String> spares) throws Exception {
|
||||
spareRecursively("", root, spares);
|
||||
}
|
||||
|
||||
private void spareRecursively(String str, Node parent, List<String> spares) throws Exception {
|
||||
final List<Node> children = new ArrayList<>(parent.getChildren());
|
||||
|
||||
if (!parent.isRoot() && children.size() == 1) {
|
||||
final Node firstChild = children.get(0);
|
||||
|
||||
if (firstChild.getName() != null && firstChild.getName().equalsIgnoreCase("args")) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
for (final Node child : children) {
|
||||
|
||||
if (parent.isRoot()) {
|
||||
spareRecursively(child.getName(), child, spares);
|
||||
continue;
|
||||
}
|
||||
|
||||
final String command = str + " " + child.getName();
|
||||
final String[] commandArgs = command.split(" ");
|
||||
|
||||
boolean found = false;
|
||||
for (String spare : spares) {
|
||||
final String[] spareArgs = spare.split(" ");
|
||||
|
||||
if (!spareArgs[0].equals(commandArgs[0])) {
|
||||
continue;
|
||||
}
|
||||
|
||||
boolean match = true;
|
||||
for (int i = 1; i < spareArgs.length; i++) {
|
||||
final String s = spareArgs[i];
|
||||
|
||||
if (commandArgs.length - 1 < i) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (commandArgs.length - 1 == i && s.equals("_-")) {
|
||||
match = false;
|
||||
break;
|
||||
}
|
||||
|
||||
if (s.startsWith("%") && s.endsWith("%")) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!s.equals(commandArgs[i])) {
|
||||
match = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (match) {
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!found) {
|
||||
parent.removeChild(child);
|
||||
} else {
|
||||
spareRecursively(command, child, spares);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void removeSubArguments(Node parent, int index, String[] args) throws Exception {
|
||||
final int max = args.length - 1;
|
||||
final int nextIndex = index + 1;
|
||||
|
||||
if (index > max || nextIndex > max) {
|
||||
return;
|
||||
}
|
||||
|
||||
final String nextPart = args[nextIndex];
|
||||
|
||||
if (nextIndex == max) {
|
||||
parent.removeChild(nextPart);
|
||||
return;
|
||||
}
|
||||
|
||||
final Node nextParent = parent.getChild(nextPart);
|
||||
if (nextParent == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
removeSubArguments(nextParent, nextIndex + 1, args);
|
||||
}
|
||||
|
||||
public Node getRoot() {
|
||||
return root;
|
||||
}
|
||||
|
||||
private Object createEmptyEntry() throws Exception {
|
||||
final String path = packetObj.getClass().getPackage().getName() + "." + packetObj.getClass().getSimpleName();
|
||||
|
||||
final String literalNodeStubPath = path + "$LiteralNodeStub";
|
||||
final String entryPath = path + "$Entry";
|
||||
final String nodeStubPath = path + "$NodeStub";
|
||||
|
||||
final int[] children = {};
|
||||
|
||||
final Class<?> nodeStubClazz = Class.forName(nodeStubPath);
|
||||
|
||||
final Class<?> literalNodeClazz = Class.forName(literalNodeStubPath);
|
||||
final Constructor<?> literalNodeConstructor = literalNodeClazz.getDeclaredConstructor(String.class);
|
||||
literalNodeConstructor.setAccessible(true);
|
||||
|
||||
final Object literalNodeObj = literalNodeConstructor.newInstance("");
|
||||
|
||||
final Class<?> entryClazz = Class.forName(entryPath);
|
||||
final Constructor<?> entryConstructor = entryClazz.getDeclaredConstructor(nodeStubClazz, int.class, int.class, int[].class);
|
||||
entryConstructor.setAccessible(true);
|
||||
|
||||
final Object entryObj = entryConstructor.newInstance(literalNodeObj, 1, 0, children);
|
||||
|
||||
|
||||
literalNodeConstructor.setAccessible(false);
|
||||
entryConstructor.setAccessible(false);
|
||||
|
||||
|
||||
return entryObj;
|
||||
}
|
||||
|
||||
private Node createRootNode(BukkitCommandNodeHelper process, int rootIndex, final SimpleNode[] nodes) {
|
||||
return new Node(process, nodes[rootIndex], nodes);
|
||||
}
|
||||
|
||||
private static class Node {
|
||||
|
||||
private final int rootIndex, index;
|
||||
private final List<Node> children;
|
||||
private final SimpleNode simpleNode;
|
||||
private final BukkitCommandNodeHelper process;
|
||||
|
||||
@Nullable
|
||||
private final String name;
|
||||
|
||||
public Node(BukkitCommandNodeHelper process, SimpleNode node, final SimpleNode[] nodes) {
|
||||
this.process = process;
|
||||
this.simpleNode = node;
|
||||
|
||||
this.rootIndex = node.rootIndex;
|
||||
this.index = node.index;
|
||||
|
||||
this.name = node.name;
|
||||
this.children = new ArrayList<>();
|
||||
|
||||
if (!node.isRoot() && name == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (int childIndex : node.children()) {
|
||||
final Node child = new Node(process, nodes[childIndex], nodes);
|
||||
this.children.add(child);
|
||||
}
|
||||
}
|
||||
|
||||
public void removeChild(int childIndex) throws Exception {
|
||||
final Node child = getChild(childIndex);
|
||||
|
||||
if (child != null) {
|
||||
this.children.remove(child);
|
||||
this.process.entries.set(child.index, this.process.createEmptyEntry());
|
||||
}
|
||||
}
|
||||
|
||||
public void removeChild(Node child) throws Exception {
|
||||
if (child != null) {
|
||||
this.children.remove(child);
|
||||
this.process.entries.set(child.index, this.process.createEmptyEntry());
|
||||
}
|
||||
}
|
||||
|
||||
public void removeChild(String childName) throws Exception {
|
||||
final Node child = getChild(childName);
|
||||
|
||||
if (child != null) {
|
||||
this.children.remove(child);
|
||||
this.process.entries.set(child.index, this.process.createEmptyEntry());
|
||||
}
|
||||
}
|
||||
|
||||
public SimpleNode getSimpleNode() {
|
||||
return simpleNode;
|
||||
}
|
||||
|
||||
public int getRootIndex() {
|
||||
return rootIndex;
|
||||
}
|
||||
|
||||
public int getIndex() {
|
||||
return index;
|
||||
}
|
||||
|
||||
public boolean isRoot() {
|
||||
return index == rootIndex;
|
||||
}
|
||||
|
||||
public List<Node> getChildren() {
|
||||
return children;
|
||||
}
|
||||
|
||||
public Node getChild(int index) {
|
||||
return children.get(index);
|
||||
}
|
||||
|
||||
public Node getChild(String name) {
|
||||
return this.children.stream().filter(n -> n.getName() != null && n.getName().equals(name)).findFirst().orElse(null);
|
||||
}
|
||||
|
||||
public @Nullable String getName() {
|
||||
return name;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private record SimpleNode(int rootIndex, int index, int[] children, @Nullable String name) {
|
||||
public boolean isRoot() {
|
||||
return index == rootIndex;
|
||||
}
|
||||
}
|
||||
}
|
||||
+55
-23
@@ -7,15 +7,16 @@ import com.mojang.brigadier.builder.LiteralArgumentBuilder;
|
||||
import com.mojang.brigadier.builder.RequiredArgumentBuilder;
|
||||
import com.mojang.brigadier.suggestion.SuggestionProvider;
|
||||
import com.mojang.brigadier.tree.*;
|
||||
import net.md_5.bungee.protocol.packet.Commands;
|
||||
import de.rayzs.pat.api.storage.Storage;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.function.Predicate;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class CommandNodeHelper<T> {
|
||||
public class ProxyCommandNodeHelper<T> {
|
||||
|
||||
private static final Command DUMMY_COMMAND = (context) -> 0;
|
||||
|
||||
private static SuggestionProvider DEFAULT_SUGGESTION_PROVIDER;
|
||||
|
||||
public static void setDefaultSuggestionProvider(SuggestionProvider<?> suggestionProvider) {
|
||||
@@ -45,7 +46,7 @@ public class CommandNodeHelper<T> {
|
||||
|
||||
private final RootCommandNode<T> rootNode;
|
||||
|
||||
public CommandNodeHelper(RootCommandNode<T> rootNode) {
|
||||
public ProxyCommandNodeHelper(RootCommandNode<T> rootNode) {
|
||||
this.rootNode = rootNode;
|
||||
}
|
||||
|
||||
@@ -53,7 +54,7 @@ public class CommandNodeHelper<T> {
|
||||
return rootNode.getChildren().stream().map(CommandNode::getName).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
public CommandNodeHelper<T> removeIf(CommandNode<T> node, Predicate<String> predicate) {
|
||||
public ProxyCommandNodeHelper<T> removeIf(CommandNode<T> node, Predicate<String> predicate) {
|
||||
if (node != null && node.getRedirect() != null)
|
||||
node = node.getRedirect();
|
||||
|
||||
@@ -64,6 +65,7 @@ public class CommandNodeHelper<T> {
|
||||
continue;
|
||||
|
||||
String name = n.getName();
|
||||
|
||||
if (predicate.test(name)) {
|
||||
objs.add(n);
|
||||
}
|
||||
@@ -76,21 +78,21 @@ public class CommandNodeHelper<T> {
|
||||
return this;
|
||||
}
|
||||
|
||||
public CommandNodeHelper<T> removeIf(String childName, Predicate<String> predicate) {
|
||||
public ProxyCommandNodeHelper<T> removeIf(String childName, Predicate<String> predicate) {
|
||||
CommandNode<T> node = rootNode.getChild(childName);
|
||||
return removeIf(node, predicate);
|
||||
}
|
||||
|
||||
public CommandNodeHelper<T> removeIf(Predicate<String> predicate) {
|
||||
public ProxyCommandNodeHelper<T> removeIf(Predicate<String> predicate) {
|
||||
return removeIf(rootNode, predicate);
|
||||
}
|
||||
|
||||
public CommandNodeHelper<T> clear() {
|
||||
public ProxyCommandNodeHelper<T> clear() {
|
||||
rootNode.getChildren().clear();
|
||||
return this;
|
||||
}
|
||||
|
||||
public CommandNodeHelper<T> clear(String childName) {
|
||||
public ProxyCommandNodeHelper<T> clear(String childName) {
|
||||
CommandNode child = rootNode.getChild(childName);
|
||||
|
||||
if (child != null) {
|
||||
@@ -101,39 +103,69 @@ public class CommandNodeHelper<T> {
|
||||
}
|
||||
|
||||
|
||||
public CommandNodeHelper<T> remove(Object obj) {
|
||||
public ProxyCommandNodeHelper<T> remove(Object obj) {
|
||||
rootNode.getChildren().remove(obj);
|
||||
return this;
|
||||
}
|
||||
|
||||
public CommandNodeHelper<T> remove(CommandNode node, Object obj) {
|
||||
public ProxyCommandNodeHelper<T> remove(CommandNode node, Object obj) {
|
||||
node.getChildren().remove(obj);
|
||||
return this;
|
||||
}
|
||||
|
||||
public CommandNodeHelper<T> add(String commandPath, boolean autoSuggestions) {
|
||||
String[] args = commandPath.split(" ");
|
||||
add(rootNode, args, 0, autoSuggestions);
|
||||
public ProxyCommandNodeHelper<T> add(String original, boolean autoSuggestions) {
|
||||
String[] args = original.split(" ");
|
||||
add(original, rootNode, args, 0, autoSuggestions);
|
||||
return this;
|
||||
}
|
||||
|
||||
private void add(CommandNode<T> parent, String[] args, int index, boolean autoSuggestions) {
|
||||
public ProxyCommandNodeHelper<T> removeSubArguments(String original) {
|
||||
String[] args = original.split(" ");
|
||||
removeSubArguments(rootNode, args, 0);
|
||||
return this;
|
||||
}
|
||||
|
||||
private void removeSubArguments(CommandNode<T> parent, String[] args, int index) {
|
||||
if (index >= args.length) return;
|
||||
|
||||
if (parent == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
String part = args[index];
|
||||
CommandNode<T> childNode = parent.getChild(part);
|
||||
|
||||
if (index == (args.length - 1)) {
|
||||
parent.getChildren().remove(childNode);
|
||||
return;
|
||||
}
|
||||
|
||||
removeSubArguments(childNode, args, index + 1);
|
||||
}
|
||||
|
||||
private void add(final String original, CommandNode<T> parent, String[] args, int index, boolean autoSuggestions) {
|
||||
if (index >= args.length) {
|
||||
return;
|
||||
}
|
||||
|
||||
String part = args[index];
|
||||
|
||||
if (index == 0)
|
||||
part = Storage.Blacklist.BlockTypeFetcher.modify(Storage.Blacklist.BlockTypeFetcher.modify(part));
|
||||
|
||||
String next = index + 1 >= args.length ? null : args[index + 1];
|
||||
CommandNode<T> childNode = parent.getChild(part);
|
||||
|
||||
if (original.charAt(0) == '!' && index == (args.length - 1)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (childNode == null) {
|
||||
LiteralCommandNode newNode;
|
||||
|
||||
boolean cancel = next != null && (next.equals("_-"));
|
||||
boolean stop = next != null && next.startsWith("%") && next.endsWith("%");
|
||||
boolean skip = part.equals("-_");
|
||||
|
||||
if (index == 0 && part.charAt(0) == '!' && part.length() > 1) {
|
||||
return;
|
||||
}
|
||||
final boolean cancel = next != null && (next.equals("_-"));
|
||||
final boolean stop = next != null && next.startsWith("%") && next.endsWith("%");
|
||||
final boolean skip = part.equals("-_");
|
||||
|
||||
if (skip) {
|
||||
return;
|
||||
@@ -148,7 +180,7 @@ public class CommandNodeHelper<T> {
|
||||
newNode = LiteralArgumentBuilder.literal(part)
|
||||
.then(RequiredArgumentBuilder
|
||||
.argument("args", (ArgumentType) StringArgumentType.greedyString())
|
||||
.suggests(Commands.SuggestionRegistry.ASK_SERVER))
|
||||
.suggests(DEFAULT_SUGGESTION_PROVIDER))
|
||||
.build();
|
||||
}
|
||||
|
||||
@@ -161,6 +193,6 @@ public class CommandNodeHelper<T> {
|
||||
childNode = newNode;
|
||||
}
|
||||
|
||||
add(childNode, args, index + 1, autoSuggestions);
|
||||
add(original, childNode, args, index + 1, autoSuggestions);
|
||||
}
|
||||
}
|
||||
@@ -31,17 +31,11 @@ public class PermissionUtil {
|
||||
|
||||
resetPermissions(uuid);
|
||||
setPlayerPermissions(uuid);
|
||||
|
||||
CommandSender sender = CommandSenderHandler.getSenderFromUUID(uuid);
|
||||
if (sender != null) {
|
||||
sender.updateGroups();
|
||||
}
|
||||
}
|
||||
|
||||
public static void reloadPermissions(CommandSender sender) {
|
||||
resetPermissions(sender.getUniqueId());
|
||||
setPlayerPermissions(sender);
|
||||
sender.updateGroups();
|
||||
}
|
||||
|
||||
public static String getPermissionsAsString(UUID uuid) {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package de.rayzs.pat.utils.response;
|
||||
|
||||
import de.rayzs.pat.plugin.modules.SubArgsModule;
|
||||
import de.rayzs.pat.plugin.subarguments.SubArguments;
|
||||
import de.rayzs.pat.plugin.logger.Logger;
|
||||
import de.rayzs.pat.api.storage.Storage;
|
||||
import de.rayzs.pat.utils.*;
|
||||
@@ -25,56 +25,85 @@ public class ResponseHandler {
|
||||
}
|
||||
|
||||
public static String replaceArgsVariables(String input, String command) {
|
||||
final String[] commandSplit = command.contains(" ") ? command.split(" ") : new String[] { command };
|
||||
final String[] inputSplit = input.contains(" ") ? input.split(" ") : new String[] { input };
|
||||
try {
|
||||
final char[] chars = input.toCharArray();
|
||||
final String placeholder = "%args[";
|
||||
|
||||
final StringBuilder output = new StringBuilder();
|
||||
final int commandLength = commandSplit.length;
|
||||
int index = -1;
|
||||
int found = 0;
|
||||
|
||||
for (int i = 0; i < inputSplit.length; i++) {
|
||||
String part = inputSplit[i];
|
||||
for (int i = 0; i < chars.length; i++) {
|
||||
final char c = chars[i];
|
||||
|
||||
if (i > 0) {
|
||||
output.append(" ");
|
||||
}
|
||||
if (c != placeholder.charAt(found)) {
|
||||
if (found > 0) {
|
||||
i--;
|
||||
}
|
||||
|
||||
if (! (part.startsWith("%args[") && part.endsWith("]%"))) {
|
||||
output.append(part);
|
||||
continue;
|
||||
}
|
||||
|
||||
part = part.substring(part.indexOf('[') + 1, part.lastIndexOf(']'));
|
||||
|
||||
int fromIndex, toIndex;
|
||||
|
||||
try {
|
||||
if (part.contains("-")) {
|
||||
final String[] partSplit = part.split("-");
|
||||
fromIndex = Integer.parseInt(partSplit[0]);
|
||||
toIndex = Integer.parseInt(partSplit[1]);
|
||||
} else if (part.startsWith("_")) {
|
||||
final String[] partSplit = part.split("_");
|
||||
fromIndex = 0;
|
||||
toIndex = Integer.parseInt(partSplit[1]);
|
||||
} else if (part.endsWith("_")) {
|
||||
final String[] partSplit = part.split("_");
|
||||
fromIndex = Integer.parseInt(partSplit[0]);
|
||||
toIndex = commandLength + 1;
|
||||
} else {
|
||||
fromIndex = Integer.parseInt(part);
|
||||
toIndex = fromIndex;
|
||||
found = 0;
|
||||
continue;
|
||||
}
|
||||
|
||||
fromIndex = Math.max(0, fromIndex - 1);
|
||||
toIndex = Math.min(commandLength, toIndex);
|
||||
found++;
|
||||
|
||||
output.append(String.join(" ", Arrays.copyOfRange(commandSplit, fromIndex, toIndex)));
|
||||
} catch (NumberFormatException exception) {
|
||||
Logger.warning("Failed to convert number! (" + part + ")");
|
||||
if (found == placeholder.length()) {
|
||||
index = i - placeholder.length() + 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (index == -1) {
|
||||
return input;
|
||||
}
|
||||
|
||||
String argument = input.substring(index);
|
||||
final int endIndex = argument.substring(2).indexOf(']');
|
||||
|
||||
if (endIndex != -1) {
|
||||
argument = argument.substring(0, endIndex + 4);
|
||||
|
||||
String[] commandSplit = command.split(" ");
|
||||
|
||||
final String argumentInsides = argument.substring(6, argument.length() - 2);
|
||||
int leftNum = -1, rightNum = -1;
|
||||
|
||||
if (argumentInsides.contains("-")) {
|
||||
final String[] numSplit = argumentInsides.split("-");
|
||||
|
||||
leftNum = Integer.parseInt(numSplit[0]);
|
||||
rightNum = Integer.parseInt(numSplit[1]);
|
||||
} else if (argumentInsides.startsWith("_")) {
|
||||
leftNum = 0;
|
||||
rightNum = Integer.parseInt(argumentInsides.replace("_", ""));
|
||||
} else if (argumentInsides.endsWith("_")) {
|
||||
leftNum = Integer.parseInt(argumentInsides.replace("_", ""));
|
||||
rightNum = commandSplit.length;
|
||||
}
|
||||
|
||||
final StringBuilder replacementCommand = new StringBuilder();
|
||||
|
||||
if (leftNum == -1 && rightNum == -1) {
|
||||
final int i = Integer.parseInt(argumentInsides) - 1;
|
||||
replacementCommand.append(commandSplit[Math.min(commandSplit.length - 1, i)]);
|
||||
} else {
|
||||
final int min = Math.max(0, leftNum + -1);
|
||||
final int max = Math.min(rightNum, commandSplit.length);
|
||||
|
||||
for (int i = min; i < max; i++) {
|
||||
if (i != min) replacementCommand.append(" ");
|
||||
replacementCommand.append(commandSplit[i]);
|
||||
}
|
||||
}
|
||||
|
||||
input = input.substring(0, index) + replacementCommand + input.substring(index + endIndex + 4);
|
||||
}
|
||||
} catch (Exception exception) {
|
||||
Logger.warning("Failed to parse and replace %args[...]% parts. Please make sure that the format is correct and that befitting the written numbers.");
|
||||
Logger.warning("Check examples from the custom-responses.yml file for comparison.");
|
||||
return input;
|
||||
}
|
||||
|
||||
return output.toString();
|
||||
return replaceArgsVariables(input, command);
|
||||
}
|
||||
|
||||
public static List<String> getResponse(UUID uuid, String input) {
|
||||
@@ -111,7 +140,7 @@ public class ResponseHandler {
|
||||
|
||||
public Response(final String key) {
|
||||
this.triggers = (List<String>) Storage.Files.CUSTOM_RESPONSES.get(key + ".triggers");
|
||||
this.message = (List<String>) Storage.Files.CUSTOM_RESPONSES.getOrSet(key + ".message", SubArgsModule.BLOCKED_MESSAGE);
|
||||
this.message = (List<String>) Storage.Files.CUSTOM_RESPONSES.getOrSet(key + ".message", SubArguments.BLOCKED_MESSAGE);
|
||||
this.actions = (List<String>) Storage.Files.CUSTOM_RESPONSES.getOrSet(key + ".actions", new ArrayList<>());
|
||||
}
|
||||
|
||||
@@ -205,19 +234,12 @@ public class ResponseHandler {
|
||||
continue;
|
||||
|
||||
case "sound":
|
||||
|
||||
if (Reflection.isProxyServer()) {
|
||||
Logger.warning("! Failed to read action: " + action);
|
||||
Logger.warning(" > Sounds cannot be played on the proxy side!");
|
||||
continue;
|
||||
}
|
||||
|
||||
if (split.length != 4) {
|
||||
Logger.warning("! Failed to read action: " + action);
|
||||
Logger.warning(" > Action requires 4 arguments but only has " + split.length);
|
||||
Logger.warning(" > Here's an example to compare with:");
|
||||
Logger.warning(" > sound::soundName::volume::pitch");
|
||||
Logger.warning(" > e.g: sound::ENTITY_ENDER_DRAGON_GROWL::1.0::1.0");
|
||||
Logger.warning(" > e.g: sound::" + (Reflection.isProxyServer() ? "entity.ender_dragon.growl:" : "ENTITY_ENDER_DRAGON_GROWL") + "::1.0::1.0");
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -225,6 +247,13 @@ public class ResponseHandler {
|
||||
|
||||
try {
|
||||
volume = Float.parseFloat(split[2]);
|
||||
|
||||
if (volume < 0 || volume > 10) {
|
||||
Logger.warning("! Failed to read action: " + action);
|
||||
Logger.warning(" > Your volume (" + split[2].toUpperCase() + ") must be between 0.0 and 10.0! (e.g: 1.0)");
|
||||
continue;
|
||||
}
|
||||
|
||||
} catch (Exception exception) {
|
||||
Logger.warning("! Failed to read action: " + action);
|
||||
Logger.warning(" > Volume " + split[2].toUpperCase() + " is not a valid float! (e.g: 1.0f)");
|
||||
@@ -233,13 +262,26 @@ public class ResponseHandler {
|
||||
|
||||
try {
|
||||
pitch = Float.parseFloat(split[3]);
|
||||
|
||||
if (pitch < 0 || pitch > 10) {
|
||||
Logger.warning("! Failed to read action: " + action);
|
||||
Logger.warning(" > Your pitch (" + split[2].toUpperCase() + ") must be between 0.0 and 2.0! (e.g: 1.0)");
|
||||
continue;
|
||||
}
|
||||
} catch (Exception exception) {
|
||||
Logger.warning("! Failed to read action: " + action);
|
||||
Logger.warning(" > Pitch " + split[3].toUpperCase() + " is not a valid float! (e.g: 1.0f)");
|
||||
Logger.warning(" > Pitch " + split[3].toUpperCase() + " is not a valid float! (e.g: 1.0)");
|
||||
continue;
|
||||
}
|
||||
|
||||
ActionHandler.playSound(action, uuid, split[1].toUpperCase(), volume, pitch);
|
||||
ActionHandler.playSound(
|
||||
action,
|
||||
uuid,
|
||||
Reflection.isProxyServer() ? split[1].toLowerCase() : split[1].toUpperCase(),
|
||||
volume,
|
||||
pitch
|
||||
);
|
||||
|
||||
continue;
|
||||
|
||||
case "console":
|
||||
|
||||
@@ -2,12 +2,10 @@ package de.rayzs.pat.utils.response.action.impl;
|
||||
|
||||
import de.rayzs.pat.plugin.logger.Logger;
|
||||
import de.rayzs.pat.utils.StringUtils;
|
||||
import de.rayzs.pat.utils.message.MessageTranslator;
|
||||
import de.rayzs.pat.utils.response.ResponseHandler;
|
||||
import de.rayzs.pat.utils.response.action.Action;
|
||||
import net.md_5.bungee.api.ChatMessageType;
|
||||
import net.md_5.bungee.api.ProxyServer;
|
||||
import net.md_5.bungee.api.Title;
|
||||
import net.md_5.bungee.api.chat.TextComponent;
|
||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||
|
||||
import java.util.UUID;
|
||||
@@ -19,8 +17,9 @@ public class BungeeAction implements Action {
|
||||
ProxiedPlayer player = ProxyServer.getInstance().getPlayer(uuid);
|
||||
message = ResponseHandler.replaceArgsVariables(message, command);
|
||||
|
||||
if (player != null)
|
||||
if (player != null) {
|
||||
message = message.replace("%player%", player.getName());
|
||||
}
|
||||
|
||||
ProxyServer.getInstance().getPluginManager().dispatchCommand(ProxyServer.getInstance().getConsole(), message);
|
||||
}
|
||||
@@ -28,10 +27,13 @@ public class BungeeAction implements Action {
|
||||
@Override
|
||||
public void executePlayerCommand(String action, UUID uuid, String command, String message) {
|
||||
ProxiedPlayer player = ProxyServer.getInstance().getPlayer(uuid);
|
||||
message = ResponseHandler.replaceArgsVariables(message, command);
|
||||
|
||||
if (player != null)
|
||||
message = command.replace("%player%", player.getName());
|
||||
if (player == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
message = StringUtils.replace(message, "%player%", player.getName());
|
||||
message = ResponseHandler.replaceArgsVariables(message, command);
|
||||
|
||||
ProxyServer.getInstance().getPluginManager().dispatchCommand(player, message);
|
||||
}
|
||||
@@ -39,19 +41,18 @@ public class BungeeAction implements Action {
|
||||
@Override
|
||||
public void sendTitle(String action, UUID uuid, String command, String title, String subTitle, int fadeIn, int stay, int fadeOut) {
|
||||
ProxiedPlayer player = ProxyServer.getInstance().getPlayer(uuid);
|
||||
|
||||
if (player == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
title = ResponseHandler.replaceArgsVariables(title, command);
|
||||
subTitle = ResponseHandler.replaceArgsVariables(subTitle, command);
|
||||
|
||||
if (player == null)
|
||||
return;
|
||||
title = StringUtils.replace(title, "%player%", player.getName());
|
||||
subTitle = StringUtils.replace(subTitle, "%player%", player.getName());
|
||||
|
||||
Title titleObj = ProxyServer.getInstance().createTitle();
|
||||
titleObj.title(TextComponent.fromLegacyText(StringUtils.replace(title, "&", "§", "%player%", player.getName())));
|
||||
titleObj.subTitle(TextComponent.fromLegacyText(StringUtils.replace(subTitle, "&", "§", "%player%", player.getName())));
|
||||
titleObj.fadeIn(fadeIn);
|
||||
titleObj.stay(stay);
|
||||
titleObj.fadeOut(fadeOut);
|
||||
player.sendTitle(titleObj);
|
||||
MessageTranslator.sendTitle(player, title, subTitle, fadeIn, stay, fadeOut);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -60,16 +61,32 @@ public class BungeeAction implements Action {
|
||||
|
||||
@Override
|
||||
public void playSound(String action, UUID uuid, String soundName, float volume, float pitch) {
|
||||
ProxiedPlayer player = ProxyServer.getInstance().getPlayer(uuid);
|
||||
|
||||
if (player == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
MessageTranslator.playSound(player, soundName, volume, pitch);
|
||||
} catch (Exception exception) {
|
||||
Logger.warning("! Failed to read action: " + action);
|
||||
Logger.warning(" > The sound \"" + soundName + "\" could not be found!");
|
||||
Logger.warning(" > Here's an example of an existing sound effect:");
|
||||
Logger.warning(" > entity.ender_dragon.growl");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendActionbar(String action, UUID uuid, String command, String message) {
|
||||
ProxiedPlayer player = ProxyServer.getInstance().getPlayer(uuid);
|
||||
message = ResponseHandler.replaceArgsVariables(message, command);
|
||||
|
||||
if (player == null)
|
||||
if (player == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
player.sendMessage(ChatMessageType.ACTION_BAR, new TextComponent(StringUtils.replace(message, "%player%", player.getName())));
|
||||
message = StringUtils.replace(message, "%player%", player.getName());
|
||||
message = ResponseHandler.replaceArgsVariables(message, command);
|
||||
MessageTranslator.sendActionbar(player, message);
|
||||
}
|
||||
}
|
||||
@@ -2,13 +2,11 @@ package de.rayzs.pat.utils.response.action.impl;
|
||||
|
||||
import de.rayzs.pat.plugin.logger.Logger;
|
||||
import de.rayzs.pat.utils.StringUtils;
|
||||
import de.rayzs.pat.utils.message.MessageTranslator;
|
||||
import de.rayzs.pat.utils.message.replacer.PlaceholderReplacer;
|
||||
import de.rayzs.pat.utils.response.ResponseHandler;
|
||||
import de.rayzs.pat.utils.response.action.Action;
|
||||
import net.md_5.bungee.api.ChatMessageType;
|
||||
import net.md_5.bungee.api.chat.TextComponent;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.potion.PotionEffect;
|
||||
import org.bukkit.potion.PotionEffectType;
|
||||
@@ -22,11 +20,13 @@ public class ModernBukkitAction implements Action {
|
||||
Player player = Bukkit.getPlayer(uuid);
|
||||
message = ResponseHandler.replaceArgsVariables(message, command);
|
||||
|
||||
if (player != null)
|
||||
message = message.replace("%player%", player.getName());
|
||||
if (player != null) {
|
||||
message = StringUtils.replace(message, "%player%", player.getName());
|
||||
}
|
||||
|
||||
if (message.contains("%"))
|
||||
if (message.contains("%")) {
|
||||
message = PlaceholderReplacer.replace(player, message);
|
||||
}
|
||||
|
||||
Bukkit.dispatchCommand(Bukkit.getConsoleSender(), message);
|
||||
}
|
||||
@@ -34,39 +34,45 @@ public class ModernBukkitAction implements Action {
|
||||
@Override
|
||||
public void executePlayerCommand(String action, UUID uuid, String command, String message) {
|
||||
Player player = Bukkit.getPlayer(uuid);
|
||||
|
||||
if (player == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
message = StringUtils.replace(message, "%player%", player.getName());
|
||||
message = ResponseHandler.replaceArgsVariables(message, command);
|
||||
|
||||
if(player != null)
|
||||
message = message.replace("%player%", player.getName());
|
||||
|
||||
if (message.contains("%"))
|
||||
if (message.contains("%")) {
|
||||
message = PlaceholderReplacer.replace(player, message);
|
||||
}
|
||||
|
||||
if (player != null)
|
||||
Bukkit.dispatchCommand(player, message);
|
||||
Bukkit.dispatchCommand(player, message);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendTitle(String action, UUID uuid, String command, String title, String subTitle, int fadeIn, int stay, int fadeOut) {
|
||||
Player player = Bukkit.getPlayer(uuid);
|
||||
|
||||
if (player == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
title = ResponseHandler.replaceArgsVariables(title, command);
|
||||
subTitle = ResponseHandler.replaceArgsVariables(subTitle, command);
|
||||
|
||||
if (player == null)
|
||||
return;
|
||||
title = StringUtils.replace(title, "&", "§", "%player%", player.getName());
|
||||
subTitle = StringUtils.replace(subTitle, "&", "§", "%player%", player.getName());
|
||||
|
||||
title = PlaceholderReplacer.replace(player, StringUtils.replace(title, "&", "§", "%player%", player.getName()));
|
||||
subTitle = PlaceholderReplacer.replace(player, StringUtils.replace(subTitle, "&", "§", "%player%", player.getName()));
|
||||
|
||||
player.sendTitle(title, subTitle, fadeIn, stay, fadeOut);
|
||||
MessageTranslator.sendTitle(player, title, subTitle, fadeIn, stay, fadeOut);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addPotionEffect(String action, UUID uuid, String potionEffectTypeName, int duration, int amplifier) {
|
||||
Player player = Bukkit.getPlayer(uuid);
|
||||
|
||||
if (player == null)
|
||||
if (player == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
PotionEffectType potionEffectType = null;
|
||||
try {
|
||||
@@ -88,12 +94,12 @@ public class ModernBukkitAction implements Action {
|
||||
public void playSound(String action, UUID uuid, String soundName, float volume, float pitch) {
|
||||
Player player = Bukkit.getPlayer(uuid);
|
||||
|
||||
if (player == null)
|
||||
if (player == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
Sound sound = Sound.valueOf(soundName);
|
||||
player.playSound(player.getLocation(), sound, volume, pitch);
|
||||
MessageTranslator.playSound(player, soundName, volume, pitch);
|
||||
} catch (Exception exception) {
|
||||
Logger.warning("! Failed to read action: " + action);
|
||||
Logger.warning(" > The sound \"" + soundName + "\" could not be found!");
|
||||
@@ -105,13 +111,14 @@ public class ModernBukkitAction implements Action {
|
||||
@Override
|
||||
public void sendActionbar(String action, UUID uuid, String command, String message) {
|
||||
Player player = Bukkit.getPlayer(uuid);
|
||||
|
||||
if (player == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
message = StringUtils.replace(message, "%player%", player.getName());
|
||||
message = ResponseHandler.replaceArgsVariables(message, command);
|
||||
|
||||
if (player == null)
|
||||
return;
|
||||
|
||||
message = PlaceholderReplacer.replace(player, StringUtils.replace(message, "&", "§", "%player%", player.getName()));
|
||||
|
||||
player.spigot().sendMessage(ChatMessageType.ACTION_BAR, new TextComponent(message));
|
||||
MessageTranslator.sendActionbar(player, message);
|
||||
}
|
||||
}
|
||||
@@ -26,11 +26,13 @@ public class OldBukkitAction implements Action {
|
||||
Player player = Bukkit.getPlayer(uuid);
|
||||
message = ResponseHandler.replaceArgsVariables(message, command);
|
||||
|
||||
if(player != null)
|
||||
message = message.replace("%player%", player.getName());
|
||||
if(player != null) {
|
||||
message = StringUtils.replace(message, "%player%", player.getName());
|
||||
}
|
||||
|
||||
if (message.contains("%"))
|
||||
if (message.contains("%")) {
|
||||
message = PlaceholderReplacer.replace(player, message);
|
||||
}
|
||||
|
||||
Bukkit.dispatchCommand(Bukkit.getConsoleSender(), message);
|
||||
}
|
||||
@@ -38,28 +40,37 @@ public class OldBukkitAction implements Action {
|
||||
@Override
|
||||
public void executePlayerCommand(String action, UUID uuid, String command, String message) {
|
||||
Player player = Bukkit.getPlayer(uuid);
|
||||
|
||||
if (player == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
message = ResponseHandler.replaceArgsVariables(message, command);
|
||||
message = StringUtils.replace(message, "%player%", player.getName());
|
||||
|
||||
if (player != null)
|
||||
message = message.replace("%player%", player.getName());
|
||||
|
||||
if (message.contains("%"))
|
||||
if (message.contains("%")) {
|
||||
message = PlaceholderReplacer.replace(player, message);
|
||||
}
|
||||
|
||||
if (player != null)
|
||||
Bukkit.dispatchCommand(player, message);
|
||||
Bukkit.dispatchCommand(player, message);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendTitle(String action, UUID uuid, String command, String title, String subTitle, int fadeIn, int stay, int fadeOut) {
|
||||
Player player = Bukkit.getPlayer(uuid);
|
||||
|
||||
if (player == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
title = StringUtils.replace(title, "&", "§", "%player%", player.getName());
|
||||
subTitle = StringUtils.replace(title, "&", "§", "%player%", player.getName());
|
||||
|
||||
title = ResponseHandler.replaceArgsVariables(title, command);
|
||||
subTitle = ResponseHandler.replaceArgsVariables(subTitle, command);
|
||||
|
||||
if (player == null) return;
|
||||
|
||||
title = PlaceholderReplacer.replace(player, StringUtils.replace(title, "&", "§", "%player%", player.getName()));
|
||||
subTitle = PlaceholderReplacer.replace(player, StringUtils.replace(subTitle, "&", "§", "%player%", player.getName()));
|
||||
title = PlaceholderReplacer.replace(player, title);
|
||||
subTitle = PlaceholderReplacer.replace(player, subTitle);
|
||||
|
||||
player.sendTitle(title, subTitle);
|
||||
}
|
||||
@@ -68,8 +79,9 @@ public class OldBukkitAction implements Action {
|
||||
public void addPotionEffect(String action, UUID uuid, String potionEffectTypeName, int duration, int amplifier) {
|
||||
Player player = Bukkit.getPlayer(uuid);
|
||||
|
||||
if (player == null)
|
||||
if (player == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
PotionEffectType potionEffectType = null;
|
||||
try {
|
||||
@@ -91,8 +103,9 @@ public class OldBukkitAction implements Action {
|
||||
public void playSound(String action, UUID uuid, String soundName, float volume, float pitch) {
|
||||
Player player = Bukkit.getPlayer(uuid);
|
||||
|
||||
if(player == null)
|
||||
if(player == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
Sound sound = Sound.valueOf(soundName);
|
||||
@@ -108,16 +121,19 @@ public class OldBukkitAction implements Action {
|
||||
@Override
|
||||
public void sendActionbar(String action, UUID uuid, String command, String message) {
|
||||
Player player = Bukkit.getPlayer(uuid);
|
||||
message = ResponseHandler.replaceArgsVariables(message, command);
|
||||
|
||||
if (player == null)
|
||||
if (player == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
message = PlaceholderReplacer.replace(player, StringUtils.replace(message, "&", "§", "%player%", player.getName()));
|
||||
message = ResponseHandler.replaceArgsVariables(message, command);
|
||||
message = StringUtils.replace(message, "&", "§", "%player%", player.getName());
|
||||
message = PlaceholderReplacer.replace(player, message);
|
||||
|
||||
try {
|
||||
if (versionPackage == null)
|
||||
if (versionPackage == null) {
|
||||
versionPackage = Reflection.getVersionPackageName();
|
||||
}
|
||||
|
||||
Object entityPlayer = player.getClass().getMethod("getHandle").invoke(player);
|
||||
Constructor<?> constructor = (Objects.<Class<?>>requireNonNull(Class.forName("net.minecraft.server." + versionPackage + ".PacketPlayOutChat"))).getConstructor(Class.forName("net.minecraft.server." + versionPackage + ".IChatBaseComponent"), byte.class);
|
||||
|
||||
@@ -3,14 +3,12 @@ package de.rayzs.pat.utils.response.action.impl;
|
||||
import de.rayzs.pat.plugin.logger.Logger;
|
||||
import de.rayzs.pat.utils.message.MessageTranslator;
|
||||
import de.rayzs.pat.utils.response.ResponseHandler;
|
||||
import net.kyori.adventure.text.minimessage.MiniMessage;
|
||||
import de.rayzs.pat.utils.response.action.Action;
|
||||
import com.velocitypowered.api.proxy.Player;
|
||||
import de.rayzs.pat.plugin.VelocityLoader;
|
||||
import net.kyori.adventure.title.Title;
|
||||
import de.rayzs.pat.utils.StringUtils;
|
||||
|
||||
import java.util.*;
|
||||
import java.time.*;
|
||||
|
||||
public class VelocityAction implements Action {
|
||||
|
||||
@@ -19,8 +17,9 @@ public class VelocityAction implements Action {
|
||||
Optional<Player> optPlayer = VelocityLoader.getServer().getPlayer(uuid);
|
||||
message = ResponseHandler.replaceArgsVariables(message, command);
|
||||
|
||||
if (optPlayer.isPresent())
|
||||
if (optPlayer.isPresent()) {
|
||||
message = message.replace("%player%", optPlayer.get().getUsername());
|
||||
}
|
||||
|
||||
VelocityLoader.getServer().getCommandManager().executeAsync(VelocityLoader.getServer().getConsoleCommandSource(), message);
|
||||
}
|
||||
@@ -28,30 +27,36 @@ public class VelocityAction implements Action {
|
||||
@Override
|
||||
public void executePlayerCommand(String action, UUID uuid, String command, String message) {
|
||||
Optional<Player> optPlayer = VelocityLoader.getServer().getPlayer(uuid);
|
||||
|
||||
if (optPlayer.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
Player player = optPlayer.get();
|
||||
|
||||
message = message.replace("%player%", player.getUsername());
|
||||
message = ResponseHandler.replaceArgsVariables(message, command);
|
||||
|
||||
if (optPlayer.isPresent())
|
||||
message = command.replace("%player%", optPlayer.get().getUsername());
|
||||
|
||||
VelocityLoader.getServer().getCommandManager().executeAsync(optPlayer.get(), message);
|
||||
VelocityLoader.getServer().getCommandManager().executeAsync(player, message);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendTitle(String action, UUID uuid, String command, String title, String subTitle, int fadeIn, int stay, int fadeOut) {
|
||||
Optional<Player> optPlayer = VelocityLoader.getServer().getPlayer(uuid);
|
||||
|
||||
if (optPlayer.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
Player player = optPlayer.get();
|
||||
|
||||
title = ResponseHandler.replaceArgsVariables(title, command);
|
||||
subTitle = ResponseHandler.replaceArgsVariables(subTitle, command);
|
||||
|
||||
if (!optPlayer.isPresent()) return;
|
||||
title = StringUtils.replace(title, "%player%", player.getUsername());
|
||||
subTitle = StringUtils.replace(subTitle, "%player%", player.getUsername());
|
||||
|
||||
Player player = optPlayer.get();
|
||||
Title titleObj = Title.title(
|
||||
MiniMessage.miniMessage().deserialize(MessageTranslator.replaceMessage(StringUtils.replace(title, "%player%", player.getUsername()))),
|
||||
MiniMessage.miniMessage().deserialize(MessageTranslator.replaceMessage(StringUtils.replace(subTitle, "%player%", player.getUsername()))),
|
||||
Title.Times.times(Duration.ofMillis(fadeIn), Duration.ofMillis(stay), Duration.ofMillis(fadeOut))
|
||||
);
|
||||
|
||||
player.showTitle(titleObj);
|
||||
MessageTranslator.sendTitle(player, title, subTitle, fadeIn, stay, fadeOut);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -60,17 +65,37 @@ public class VelocityAction implements Action {
|
||||
|
||||
@Override
|
||||
public void playSound(String action, UUID uuid, String soundName, float volume, float pitch) {
|
||||
Optional<Player> optPlayer = VelocityLoader.getServer().getPlayer(uuid);
|
||||
|
||||
if (optPlayer.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
Player player = optPlayer.get();
|
||||
|
||||
try {
|
||||
MessageTranslator.playSound(player, soundName, volume, pitch);
|
||||
} catch (Exception exception) {
|
||||
Logger.warning("! Failed to read action: " + action);
|
||||
Logger.warning(" > The sound \"" + soundName + "\" could not be found!");
|
||||
Logger.warning(" > Here's an example of an existing sound effect:");
|
||||
Logger.warning(" > entity.ender_dragon.growl");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendActionbar(String action, UUID uuid, String command, String message) {
|
||||
Optional<Player> optPlayer = VelocityLoader.getServer().getPlayer(uuid);
|
||||
message = ResponseHandler.replaceArgsVariables(message, command);
|
||||
|
||||
if (!optPlayer.isPresent())
|
||||
if (optPlayer.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
Player player = optPlayer.get();
|
||||
player.sendActionBar(MiniMessage.miniMessage().deserialize(MessageTranslator.replaceMessage(StringUtils.replace(message, "%player%", player.getUsername()))));
|
||||
|
||||
message = ResponseHandler.replaceArgsVariables(message, command);
|
||||
message = StringUtils.replace(message, "%player%", player.getUsername());
|
||||
|
||||
MessageTranslator.sendActionbar(player, message);
|
||||
}
|
||||
}
|
||||
@@ -1,8 +1,5 @@
|
||||
package de.rayzs.pat.utils.sender;
|
||||
|
||||
import de.rayzs.pat.utils.group.Group;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
public interface CommandSender {
|
||||
@@ -21,8 +18,5 @@ public interface CommandSender {
|
||||
String getName();
|
||||
String getServerName();
|
||||
|
||||
List<Group> getGroups();
|
||||
void updateGroups();
|
||||
|
||||
void sendMessage(String message);
|
||||
}
|
||||
@@ -1,17 +1,7 @@
|
||||
package de.rayzs.pat.utils.sender;
|
||||
|
||||
import de.rayzs.pat.utils.ExpireCache;
|
||||
import de.rayzs.pat.utils.group.Group;
|
||||
import de.rayzs.pat.utils.group.GroupManager;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
public abstract class CommandSenderAbstract implements CommandSender {
|
||||
|
||||
private static final byte KEY = (byte) 0;
|
||||
|
||||
private final ExpireCache<Byte, List<Group>> groups = new ExpireCache<>(1, TimeUnit.HOURS);
|
||||
private Object senderObj;
|
||||
|
||||
public CommandSenderAbstract(Object senderObj) {
|
||||
@@ -27,19 +17,4 @@ public abstract class CommandSenderAbstract implements CommandSender {
|
||||
public Object getSenderObject() {
|
||||
return senderObj;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Group> getGroups() {
|
||||
final List<Group> groupList = groups.get(KEY);
|
||||
|
||||
if (groupList == null) {
|
||||
return groups.putAndGet(KEY, GroupManager.getPlayerGroups(getSenderObject()));
|
||||
}
|
||||
|
||||
return groupList;
|
||||
}
|
||||
|
||||
protected void setGroups(List<Group> groups) {
|
||||
this.groups.putIgnoreIfContains(KEY, groups);
|
||||
}
|
||||
}
|
||||
@@ -1,32 +1,20 @@
|
||||
package de.rayzs.pat.utils.sender;
|
||||
|
||||
import de.rayzs.pat.utils.ExpireCache;
|
||||
import de.rayzs.pat.utils.Reflection;
|
||||
import de.rayzs.pat.utils.sender.impl.*;
|
||||
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
public class CommandSenderHandler {
|
||||
|
||||
public static final UUID CONSOLE_UUID = UUID.randomUUID();
|
||||
|
||||
private static final ExpireCache<UUID, CommandSender> CACHE = new ExpireCache<>(1, TimeUnit.HOURS);
|
||||
|
||||
|
||||
public static CommandSender getSenderFromUUID(UUID uuid) {
|
||||
return CACHE.get(uuid);
|
||||
}
|
||||
|
||||
public static CommandSender from(Object senderObj) {
|
||||
UUID uuid = extractUUID(senderObj);
|
||||
|
||||
if (CACHE.contains(uuid)) {
|
||||
return CACHE.get(uuid);
|
||||
}
|
||||
|
||||
CommandSender sender;
|
||||
|
||||
if (senderObj instanceof CommandSender finalSender) {
|
||||
return finalSender;
|
||||
}
|
||||
|
||||
if (Reflection.isProxyServer()) {
|
||||
sender = Reflection.isVelocityServer()
|
||||
? new VelocitySender(senderObj)
|
||||
@@ -39,29 +27,6 @@ public class CommandSenderHandler {
|
||||
return null;
|
||||
}
|
||||
|
||||
return CACHE.putAndGet(uuid, sender);
|
||||
}
|
||||
|
||||
private static UUID extractUUID(Object targetObj) {
|
||||
|
||||
if (Reflection.isProxyServer()) {
|
||||
|
||||
if (Reflection.isVelocityServer()) {
|
||||
return targetObj instanceof com.velocitypowered.api.proxy.Player
|
||||
? ((com.velocitypowered.api.proxy.Player) targetObj).getUniqueId()
|
||||
: CONSOLE_UUID;
|
||||
}
|
||||
|
||||
return targetObj instanceof net.md_5.bungee.api.connection.ProxiedPlayer
|
||||
? ((net.md_5.bungee.api.connection.ProxiedPlayer) targetObj).getUniqueId()
|
||||
: CONSOLE_UUID;
|
||||
|
||||
}
|
||||
|
||||
if (targetObj instanceof org.bukkit.entity.Player) {
|
||||
return ((org.bukkit.entity.Player) targetObj).getUniqueId();
|
||||
}
|
||||
|
||||
return CONSOLE_UUID;
|
||||
return sender;
|
||||
}
|
||||
}
|
||||
@@ -1,10 +1,10 @@
|
||||
package de.rayzs.pat.utils.sender.impl;
|
||||
|
||||
import de.rayzs.pat.api.storage.Storage;
|
||||
import de.rayzs.pat.utils.group.GroupManager;
|
||||
import de.rayzs.pat.utils.message.MessageTranslator;
|
||||
import de.rayzs.pat.utils.sender.CommandSenderAbstract;
|
||||
import de.rayzs.pat.utils.sender.CommandSenderHandler;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@@ -21,6 +21,17 @@ public class BukkitSender extends CommandSenderAbstract {
|
||||
public BukkitSender(Object senderObj) {
|
||||
super(senderObj);
|
||||
|
||||
if (senderObj instanceof UUID uuid) {
|
||||
final Player player = Bukkit.getPlayer(uuid);
|
||||
|
||||
this.uuid = uuid;
|
||||
this.console = false;
|
||||
|
||||
this.sender = player;
|
||||
this.name = player.getName();
|
||||
return;
|
||||
}
|
||||
|
||||
if (senderObj instanceof Player player) {
|
||||
this.sender = player;
|
||||
|
||||
@@ -28,7 +39,6 @@ public class BukkitSender extends CommandSenderAbstract {
|
||||
this.uuid = player.getUniqueId();
|
||||
this.console = false;
|
||||
|
||||
//updateGroups();
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -100,9 +110,4 @@ public class BukkitSender extends CommandSenderAbstract {
|
||||
|
||||
sender.sendMessage(MessageTranslator.replaceMessage(sender, message));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateGroups() {
|
||||
setGroups(GroupManager.getPlayerGroups(getSenderObject()));
|
||||
}
|
||||
}
|
||||
@@ -1,11 +1,11 @@
|
||||
package de.rayzs.pat.utils.sender.impl;
|
||||
|
||||
import de.rayzs.pat.api.storage.Storage;
|
||||
import de.rayzs.pat.utils.group.GroupManager;
|
||||
import de.rayzs.pat.utils.message.MessageTranslator;
|
||||
import de.rayzs.pat.utils.sender.CommandSenderAbstract;
|
||||
import de.rayzs.pat.utils.sender.CommandSenderHandler;
|
||||
import net.md_5.bungee.api.CommandSender;
|
||||
import net.md_5.bungee.api.ProxyServer;
|
||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||
|
||||
import java.util.UUID;
|
||||
@@ -22,6 +22,16 @@ public class BungeeSender extends CommandSenderAbstract {
|
||||
public BungeeSender(Object senderObj) {
|
||||
super(senderObj);
|
||||
|
||||
if (senderObj instanceof UUID uuid) {
|
||||
final ProxiedPlayer proxiedPlayer = ProxyServer.getInstance().getPlayer(uuid);
|
||||
this.uuid = uuid;
|
||||
this.console = false;
|
||||
|
||||
this.sender = proxiedPlayer;
|
||||
this.name = proxiedPlayer.getName();
|
||||
return;
|
||||
}
|
||||
|
||||
if (senderObj instanceof ProxiedPlayer player) {
|
||||
this.sender = player;
|
||||
|
||||
@@ -101,9 +111,4 @@ public class BungeeSender extends CommandSenderAbstract {
|
||||
|
||||
sender.sendMessage(MessageTranslator.replaceMessage(sender, message));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateGroups() {
|
||||
setGroups(GroupManager.getPlayerGroups(getSenderObject()));
|
||||
}
|
||||
}
|
||||
@@ -3,7 +3,7 @@ package de.rayzs.pat.utils.sender.impl;
|
||||
import com.velocitypowered.api.command.CommandSource;
|
||||
import com.velocitypowered.api.proxy.Player;
|
||||
import de.rayzs.pat.api.storage.Storage;
|
||||
import de.rayzs.pat.utils.group.GroupManager;
|
||||
import de.rayzs.pat.plugin.VelocityLoader;
|
||||
import de.rayzs.pat.utils.message.MessageTranslator;
|
||||
import de.rayzs.pat.utils.sender.CommandSenderAbstract;
|
||||
import de.rayzs.pat.utils.sender.CommandSenderHandler;
|
||||
@@ -22,6 +22,17 @@ public class VelocitySender extends CommandSenderAbstract {
|
||||
public VelocitySender(Object senderObj) {
|
||||
super(senderObj);
|
||||
|
||||
if (senderObj instanceof UUID uuid) {
|
||||
final Player player = VelocityLoader.getServer().getPlayer(uuid).get();
|
||||
|
||||
this.uuid = uuid;
|
||||
this.console = false;
|
||||
|
||||
this.sender = player;
|
||||
this.name = player.getUsername();
|
||||
return;
|
||||
}
|
||||
|
||||
if (senderObj instanceof Player player) {
|
||||
this.sender = player;
|
||||
|
||||
@@ -96,9 +107,4 @@ public class VelocitySender extends CommandSenderAbstract {
|
||||
public void sendMessage(String message) {
|
||||
MessageTranslator.send(sender, message);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateGroups() {
|
||||
setGroups(GroupManager.getPlayerGroups(getSenderObject()));
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
package de.rayzs.pat.utils.subargs;
|
||||
|
||||
import de.rayzs.pat.plugin.modules.SubArgsModule;
|
||||
import de.rayzs.pat.plugin.subarguments.SubArguments;
|
||||
import de.rayzs.pat.utils.StringUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@@ -19,9 +19,9 @@ public class ArgumentStack {
|
||||
current = input.split(" ")[0];
|
||||
|
||||
if (suggestions.contains("%online_players%"))
|
||||
current = StringUtils.replaceElementsFromString(current, SubArgsModule.getPlayerNames(), "%online_players%");
|
||||
current = StringUtils.replaceElementsFromString(current, SubArguments.getPlayerNames(), "%online_players%");
|
||||
if (suggestions.contains("%hidden_online_players%"))
|
||||
current = StringUtils.replaceElementsFromString(current, SubArgsModule.getPlayerNames(), "%hidden_online_players%");
|
||||
current = StringUtils.replaceElementsFromString(current, SubArguments.getPlayerNames(), "%hidden_online_players%");
|
||||
|
||||
input = StringUtils.replaceFirst(input, current, "");
|
||||
input = input.startsWith(" ") ? StringUtils.replaceFirst(input, " ", "") : input;
|
||||
@@ -30,9 +30,9 @@ public class ArgumentStack {
|
||||
if (!entry.getKey().startsWith(current)) continue;
|
||||
|
||||
if (entry.getKey().contains("%online_players%"))
|
||||
input = StringUtils.replaceElementsFromString(input, SubArgsModule.getPlayerNames(), "%online_players%");
|
||||
input = StringUtils.replaceElementsFromString(input, SubArguments.getPlayerNames(), "%online_players%");
|
||||
if (entry.getKey().contains("%hidden_online_players%"))
|
||||
input = StringUtils.replaceElementsFromString(input, SubArgsModule.getPlayerNames(), "%hidden_online_players%");
|
||||
input = StringUtils.replaceElementsFromString(input, SubArguments.getPlayerNames(), "%hidden_online_players%");
|
||||
|
||||
return entry.getValue().getResult(input);
|
||||
}
|
||||
|
||||
@@ -2,9 +2,7 @@ package de.rayzs.pat.utils.subargs;
|
||||
|
||||
import de.rayzs.pat.api.storage.Storage;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class Arguments {
|
||||
|
||||
@@ -23,6 +21,7 @@ public class Arguments {
|
||||
|
||||
public void buildArgumentStacks(String input) {
|
||||
Storage.Blacklist.BlockType type = Storage.Blacklist.BlockTypeFetcher.getType(input);
|
||||
|
||||
if (type != Storage.Blacklist.BlockType.NEGATE) {
|
||||
input = Storage.Blacklist.BlockTypeFetcher.modify(input, type);
|
||||
}
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
name: ProAntiTab
|
||||
description: Hide more than just your plugins. Hide almost everything!
|
||||
description: Hides more than just your plugins.
|
||||
website: https://www.rayzs.de/products/proantitab/page
|
||||
|
||||
author: Rayzs_YT
|
||||
version: 2.1.2
|
||||
version: 2.2.1
|
||||
main: de.rayzs.pat.plugin.BungeeLoader
|
||||
|
||||
softDepends: [LuckPerms, PAPIProxyBridge]
|
||||
@@ -64,6 +64,15 @@ turn-blacklist-to-whitelist: true
|
||||
# Pro tip: You can also just use auto-lowercase-commands feature instead. ^^
|
||||
base-command-case-sensitive: true
|
||||
|
||||
# (!) Warning:
|
||||
# Enabling this could lead to performance issues depending on
|
||||
# the amount of players and commands. (> 1100)
|
||||
#
|
||||
# This allows PAT groups to block commands, which have been allowed
|
||||
# inside the global section. This can be achieved by negating commands
|
||||
# inside a PAT group.
|
||||
allow-group-overruling: false
|
||||
|
||||
# (!) Warning:
|
||||
# Enabling this could lead to performance issues if many players
|
||||
# change worlds frequently in a short amount of time.
|
||||
@@ -178,6 +187,9 @@ custom-version:
|
||||
# You can bypass this restriction with the proantitab.namespace permission.
|
||||
block-namespace-commands:
|
||||
enabled: false
|
||||
# Basically blocks the command execution no matter if
|
||||
# 'cancel-blocked-commands' is enabled or not.
|
||||
always-block-command: true
|
||||
|
||||
#>> HTP (Overwritten)
|
||||
# Auto lowercase all commands when being executed,
|
||||
@@ -272,7 +284,7 @@ perms-check:
|
||||
player-not-online: "&c%player% is not online!"
|
||||
|
||||
extract:
|
||||
usage: '&7Usage: &f/pat extract [plugin] <use-colon> &7or &f<group> <use-colon>'
|
||||
usage: '&7Usage: &f/pat extract (plugin) <option> &7or &f(group) <option>'
|
||||
plugin-not-found: '&cPlugin %plugin% not found!'
|
||||
success: '&aSuccessfully extracted &e%amount% &anew commands from %plugin%!'
|
||||
|
||||
|
||||
@@ -10,6 +10,9 @@
|
||||
# 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:
|
||||
@@ -25,7 +28,7 @@
|
||||
# Send title:
|
||||
# Syntax: title::title::subtitle::5::20::5
|
||||
# Example: title::&aTest title::&cHello %player%!
|
||||
# Play sound:
|
||||
# Play sound: (Available sounds: https://hub.spigotmc.org/javadocs/spigot/org/bukkit/Sound.html)
|
||||
# Syntax: sound::soundName::volume::pitch
|
||||
# Example: sound::ENTITY_ENDER_DRAGON_GROWL::1.0::1.0
|
||||
# Give potion effect:
|
||||
@@ -64,6 +67,7 @@
|
||||
# - "&cI'm blocked"
|
||||
# actions:
|
||||
# - "actionbar::&cSorry %player%, but this command is blocked."
|
||||
# - "sound::ENTITY_ENDER_DRAGON_GROWL::1.0::1.0"
|
||||
|
||||
# Example with kits.
|
||||
# In here we only trigger the given message, if the player would type "/kit ...".
|
||||
|
||||
@@ -32,7 +32,6 @@ updater:
|
||||
# In other words, the backend servers won't receive any updates from the proxy about the storage.yml.
|
||||
# It's here to prevent any unnecessary communication between the proxy and the backend servers, if PAT is being used on the proxy alone.
|
||||
# For why this can be the case, read the following: https://github.com/RayzsYT/ProAntiTab/wiki/FAQ#can-i-install-pat-just-on-my-proxy-server
|
||||
# It is NOT recommended to enable this option, unless you know what you are doing.
|
||||
disable-sync: false
|
||||
|
||||
# This is a very necessary feature if you have way too many commands to block and instead decide
|
||||
@@ -48,6 +47,15 @@ turn-blacklist-to-whitelist: true
|
||||
# /HelP --> Allowed
|
||||
base-command-case-sensitive: true
|
||||
|
||||
# (!) Warning:
|
||||
# Enabling this could lead to performance issues depending on
|
||||
# the amount of players and commands. (> 1100)
|
||||
#
|
||||
# This allows PAT groups to block commands, which have been allowed
|
||||
# inside the global section. This can be achieved by negating commands
|
||||
# inside a PAT group.
|
||||
allow-group-overruling: false
|
||||
|
||||
# Here you can customize the server version that is displayed on a ping. (The text at the player-count)
|
||||
custom-protocol-ping:
|
||||
enabled: true
|
||||
@@ -145,6 +153,9 @@ custom-version:
|
||||
# You can bypass this restriction with the proantitab.namespace permission.
|
||||
block-namespace-commands:
|
||||
enabled: false
|
||||
# Basically blocks the command execution no matter if
|
||||
# 'cancel-blocked-commands' is enabled or not.
|
||||
always-block-command: true
|
||||
|
||||
# Patches a small exploit which causes the server to lag.
|
||||
# Due to the fact that PAT interacts directly with Tab-Completions and their packets,
|
||||
|
||||
@@ -10,6 +10,9 @@
|
||||
# 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:
|
||||
@@ -25,6 +28,9 @@
|
||||
# Send title:
|
||||
# Syntax: title::title::subtitle::5::20::5
|
||||
# Example: title::&aTest title::&cHello %player%!
|
||||
# Play sound: (Available sounds: https://www.digminecraft.com/lists/sound_list_pc.php)
|
||||
# Syntax: sound::soundName::volume::pitch
|
||||
# Example: sound::entity.ender_dragon.growl::1.0::1.0
|
||||
|
||||
# Possible variable:
|
||||
# %args[from-to]% to get the command arguments
|
||||
@@ -58,6 +64,7 @@
|
||||
# - "&cI'm blocked"
|
||||
# actions:
|
||||
# - "actionbar::&cSorry %player%, but this command is blocked."
|
||||
# - "sound::entity.ender_dragon.growl::1.0::1.0"
|
||||
|
||||
# Example with kits.
|
||||
# In here we only trigger the given message, if the player would type "/kit ...".
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
name: ProAntiTab
|
||||
description: Hide more than just your plugins. Hide almost everything!
|
||||
description: Hides more than just your plugins.
|
||||
website: https://www.rayzs.de/products/proantitab/page
|
||||
|
||||
author: Rayzs_YT
|
||||
version: 2.1.2
|
||||
version: 2.2.1
|
||||
api-version: 1.13
|
||||
folia-supported: true
|
||||
main: de.rayzs.pat.plugin.BukkitLoader
|
||||
|
||||
softdepend: [PlaceholderAPI, LuckPerms, Skript, ViaVersion, ViaBackwards, ViaRewind]
|
||||
softdepend: [PlaceholderAPI, LuckPerms, GroupManager, Skript, ViaVersion, ViaBackwards, ViaRewind]
|
||||
|
||||
commands:
|
||||
proantitab:
|
||||
|
||||
Reference in new issue
Block a user