mirror of
https://github.com/darksaid98/AntiCheatReloaded.git
synced 2026-12-01 22:14:49 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4d5b357c36 | ||
|
|
ffb7ea1ad4 | ||
|
|
c3fffbd68a | ||
|
|
3a48e8c602 | ||
|
|
031e7b145b | ||
|
|
5c85b8717b | ||
|
|
67e6f0df62 | ||
|
|
83d9705886 | ||
|
|
7842153e60 | ||
|
|
edf1d1c234 | ||
|
|
9bbb02a3a6 | ||
|
|
a3483dfc9b | ||
|
|
14ee2ebba0 | ||
|
|
279efba090 | ||
|
|
2d827e951c | ||
|
|
38e6a5a99c | ||
|
|
6aaaf883e5 | ||
|
|
f123e397b6 | ||
|
|
b27ffc9842 | ||
|
|
40985ac7d6 | ||
|
|
6fabd73432 | ||
|
|
64788fb1a0 | ||
|
|
5b33eb5b9d | ||
|
|
e71707a84c | ||
|
|
15ba2a09b0 | ||
|
|
c39d224ce9 | ||
|
|
f32efaedee | ||
|
|
9d97803d5c | ||
|
|
92b5a6e52b | ||
|
|
db642bfad7 | ||
|
|
ebfd8f69af | ||
|
|
84ddce8f1e | ||
|
|
de73349b7a | ||
|
|
ac170f5dde | ||
|
|
6af50e5a33 | ||
|
|
5c596f5e2f | ||
|
|
058cf788fd | ||
|
|
75f350f174 | ||
|
|
a7b8164828 | ||
|
|
78ae04a2a8 | ||
|
|
e2d0fbda18 | ||
|
|
9550cc1d09 | ||
|
|
5f1dc37679 | ||
|
|
a1f7a0cf7f | ||
|
|
71a9c9a9c7 | ||
|
|
0438c36cce | ||
|
|
a3ae0ab967 | ||
|
|
79e913c46c | ||
|
|
ed127276f0 | ||
|
|
7739eb9ca0 | ||
|
|
f637facbea | ||
|
|
33bc8bb7fa | ||
|
|
45712a8f62 | ||
|
|
0d50bc3b52 | ||
|
|
caffebe09d | ||
|
|
1b2afa5d0e | ||
|
|
366f25d433 | ||
|
|
6f5cd70ba3 | ||
|
|
7f9d3c1396 | ||
|
|
e5c8c5dc8a | ||
|
|
15c61fac67 | ||
|
|
7e1f0d83ce | ||
|
|
bd1db83a98 | ||
|
|
646e906ada | ||
|
|
9473781a26 | ||
|
|
6497891e43 | ||
|
|
0dc3a8053d | ||
|
|
1b5f2dcaa1 | ||
|
|
b232026644 | ||
|
|
0c91ec7ba4 | ||
|
|
abff433510 | ||
|
|
fad298086c | ||
|
|
8b413a382a | ||
|
|
1428b55591 | ||
|
|
a84b573fa8 | ||
|
|
9211003d6d | ||
|
|
01df416236 | ||
|
|
619c8efae1 | ||
|
|
ab2fcc5521 | ||
|
|
8843725ede | ||
|
|
0d9b8707dd | ||
|
|
6e2eae7d1e | ||
|
|
ef5b4069ce | ||
|
|
3b9b39c49a | ||
|
|
09c42905d0 | ||
|
|
8de7ae1c59 | ||
|
|
768331011e | ||
|
|
1f48785d1d | ||
|
|
7cd90cfb61 | ||
|
|
5f181c556e | ||
|
|
16c778c17f | ||
|
|
97534e5df0 | ||
|
|
e770d0e01c | ||
|
|
a59a4baf28 | ||
|
|
7caf7376ba | ||
|
|
a6a39e352a | ||
|
|
700c0145f3 | ||
|
|
c74fc92da9 | ||
|
|
3bc49141fc | ||
|
|
cffd6d07ae | ||
|
|
e9a99f0463 | ||
|
|
4deb8ae0fb | ||
|
|
07f957cf35 | ||
|
|
9850f48a4e | ||
|
|
656841b046 | ||
|
|
fc006c39f2 | ||
|
|
f4ca2ea8bf | ||
|
|
6966582e4c | ||
|
|
168c25e5d2 | ||
|
|
07f3c3abce | ||
|
|
128a668e6c | ||
|
|
ad618ffaf0 | ||
|
|
2086a01f80 | ||
|
|
add3fe5eae | ||
|
|
20635a2acb | ||
|
|
636f94b408 | ||
|
|
610d53550f | ||
|
|
db9aa97ca1 | ||
|
|
992c67d894 | ||
|
|
12c85b3939 | ||
|
|
37d580a4ba | ||
|
|
f94a430d41 | ||
|
|
918549bc11 | ||
|
|
c6e4ce091a | ||
|
|
7d13aae057 | ||
|
|
3538b8934c | ||
|
|
b2701fa057 | ||
|
|
8cf2702708 | ||
|
|
cd3184f17b | ||
|
|
9078846511 | ||
|
|
50247f28c9 | ||
|
|
cc51e9307f | ||
|
|
0288a9734a | ||
|
|
a7419e3968 | ||
|
|
df3c410436 | ||
|
|
27bb684736 | ||
|
|
aa9fa9b290 | ||
|
|
da4a61e228 | ||
|
|
9771387909 | ||
|
|
76c595e255 | ||
|
|
91f5fcd31c | ||
|
|
80b5e64924 | ||
|
|
67e824ef28 | ||
|
|
661718d001 | ||
|
|
7c9a05ff92 | ||
|
|
3af7bde9db | ||
|
|
7e37e8558b | ||
|
|
d41d08ccc6 | ||
|
|
f88c31051b | ||
|
|
6afe0049c5 | ||
|
|
f77d45a78d | ||
|
|
2ba98f9f9c | ||
|
|
e89a6cfd88 | ||
|
|
07bf56cc93 | ||
|
|
773900594d | ||
|
|
27ca12aec3 | ||
|
|
fec1286c8d | ||
|
|
acea36929b | ||
|
|
8da9d7f365 | ||
|
|
c9c3b2397f | ||
|
|
a140afe33e | ||
|
|
08c484bfb1 | ||
|
|
ae66b0ed3c | ||
|
|
0963458be5 | ||
|
|
d9639c81d9 | ||
|
|
0428c4796a | ||
|
|
8e92077bb6 | ||
|
|
9d32c8f2de | ||
|
|
d6917b81f7 | ||
|
|
1a64403223 | ||
|
|
7ae3f010a3 | ||
|
|
06c1eab2e6 | ||
|
|
f609758d28 | ||
|
|
2d064ee849 | ||
|
|
717b7acb67 | ||
|
|
2617aa1225 | ||
|
|
dd8c495ee6 |
No files matched your search
@@ -0,0 +1,12 @@
|
||||
# These are supported funding model platforms
|
||||
|
||||
github: [Rammelkast]
|
||||
patreon: # Replace with a single Patreon username
|
||||
open_collective: # Replace with a single Open Collective username
|
||||
ko_fi: # Replace with a single Ko-fi username
|
||||
tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
|
||||
community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
|
||||
liberapay: # Replace with a single Liberapay username
|
||||
issuehunt: # Replace with a single IssueHunt username
|
||||
otechie: # Replace with a single Otechie username
|
||||
custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2']
|
||||
@@ -0,0 +1,26 @@
|
||||
name: Maven Package
|
||||
|
||||
on: [push]
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
contents: read
|
||||
packages: write
|
||||
|
||||
steps:
|
||||
|
||||
- uses: actions/checkout@v1
|
||||
- name: Set up JDK 1.8
|
||||
uses: actions/setup-java@v1
|
||||
with:
|
||||
java-version: 1.8
|
||||
|
||||
- name: Build with Maven
|
||||
run: mvn -B package --file pom.xml
|
||||
|
||||
- name: Upload build artifacts
|
||||
uses: actions/[email protected]
|
||||
with:
|
||||
path: target/AntiCheatReloaded.jar
|
||||
@@ -1,165 +1,674 @@
|
||||
GNU LESSER GENERAL PUBLIC LICENSE
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
Version 3, 29 June 2007
|
||||
|
||||
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
|
||||
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
Preamble
|
||||
|
||||
This version of the GNU Lesser General Public License incorporates
|
||||
the terms and conditions of version 3 of the GNU General Public
|
||||
License, supplemented by the additional permissions listed below.
|
||||
The GNU General Public License is a free, copyleft license for
|
||||
software and other kinds of works.
|
||||
|
||||
0. Additional Definitions.
|
||||
The licenses for most software and other practical works are designed
|
||||
to take away your freedom to share and change the works. By contrast,
|
||||
the GNU General Public License is intended to guarantee your freedom to
|
||||
share and change all versions of a program--to make sure it remains free
|
||||
software for all its users. We, the Free Software Foundation, use the
|
||||
GNU General Public License for most of our software; it applies also to
|
||||
any other work released this way by its authors. You can apply it to
|
||||
your programs, too.
|
||||
|
||||
As used herein, "this License" refers to version 3 of the GNU Lesser
|
||||
General Public License, and the "GNU GPL" refers to version 3 of the GNU
|
||||
General Public License.
|
||||
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
|
||||
them 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.
|
||||
|
||||
"The Library" refers to a covered work governed by this License,
|
||||
other than an Application or a Combined Work as defined below.
|
||||
To protect your rights, we need to prevent others from denying you
|
||||
these rights or asking you to surrender the rights. Therefore, you have
|
||||
certain responsibilities if you distribute copies of the software, or if
|
||||
you modify it: responsibilities to respect the freedom of others.
|
||||
|
||||
An "Application" is any work that makes use of an interface provided
|
||||
by the Library, but which is not otherwise based on the Library.
|
||||
Defining a subclass of a class defined by the Library is deemed a mode
|
||||
of using an interface provided by the Library.
|
||||
For example, if you distribute copies of such a program, whether
|
||||
gratis or for a fee, you must pass on to the recipients the same
|
||||
freedoms that you received. 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.
|
||||
|
||||
A "Combined Work" is a work produced by combining or linking an
|
||||
Application with the Library. The particular version of the Library
|
||||
with which the Combined Work was made is also called the "Linked
|
||||
Version".
|
||||
Developers that use the GNU GPL protect your rights with two steps:
|
||||
(1) assert copyright on the software, and (2) offer you this License
|
||||
giving you legal permission to copy, distribute and/or modify it.
|
||||
|
||||
The "Minimal Corresponding Source" for a Combined Work means the
|
||||
Corresponding Source for the Combined Work, excluding any source code
|
||||
for portions of the Combined Work that, considered in isolation, are
|
||||
based on the Application, and not on the Linked Version.
|
||||
For the developers' and authors' protection, the GPL clearly explains
|
||||
that there is no warranty for this free software. For both users' and
|
||||
authors' sake, the GPL requires that modified versions be marked as
|
||||
changed, so that their problems will not be attributed erroneously to
|
||||
authors of previous versions.
|
||||
|
||||
The "Corresponding Application Code" for a Combined Work means the
|
||||
object code and/or source code for the Application, including any data
|
||||
and utility programs needed for reproducing the Combined Work from the
|
||||
Application, but excluding the System Libraries of the Combined Work.
|
||||
Some devices are designed to deny users access to install or run
|
||||
modified versions of the software inside them, although the manufacturer
|
||||
can do so. This is fundamentally incompatible with the aim of
|
||||
protecting users' freedom to change the software. The systematic
|
||||
pattern of such abuse occurs in the area of products for individuals to
|
||||
use, which is precisely where it is most unacceptable. Therefore, we
|
||||
have designed this version of the GPL to prohibit the practice for those
|
||||
products. If such problems arise substantially in other domains, we
|
||||
stand ready to extend this provision to those domains in future versions
|
||||
of the GPL, as needed to protect the freedom of users.
|
||||
|
||||
1. Exception to Section 3 of the GNU GPL.
|
||||
Finally, every program is threatened constantly by software patents.
|
||||
States should not allow patents to restrict development and use of
|
||||
software on general-purpose computers, but in those that do, we wish to
|
||||
avoid the special danger that patents applied to a free program could
|
||||
make it effectively proprietary. To prevent this, the GPL assures that
|
||||
patents cannot be used to render the program non-free.
|
||||
|
||||
You may convey a covered work under sections 3 and 4 of this License
|
||||
without being bound by section 3 of the GNU GPL.
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow.
|
||||
|
||||
2. Conveying Modified Versions.
|
||||
TERMS AND CONDITIONS
|
||||
|
||||
If you modify a copy of the Library, and, in your modifications, a
|
||||
facility refers to a function or data to be supplied by an Application
|
||||
that uses the facility (other than as an argument passed when the
|
||||
facility is invoked), then you may convey a copy of the modified
|
||||
version:
|
||||
0. Definitions.
|
||||
|
||||
a) under this License, provided that you make a good faith effort to
|
||||
ensure that, in the event an Application does not supply the
|
||||
function or data, the facility still operates, and performs
|
||||
whatever part of its purpose remains meaningful, or
|
||||
"This License" refers to version 3 of the GNU General Public License.
|
||||
|
||||
b) under the GNU GPL, with none of the additional permissions of
|
||||
this License applicable to that copy.
|
||||
"Copyright" also means copyright-like laws that apply to other kinds of
|
||||
works, such as semiconductor masks.
|
||||
|
||||
3. Object Code Incorporating Material from Library Header Files.
|
||||
"The Program" refers to any copyrightable work licensed under this
|
||||
License. Each licensee is addressed as "you". "Licensees" and
|
||||
"recipients" may be individuals or organizations.
|
||||
|
||||
The object code form of an Application may incorporate material from
|
||||
a header file that is part of the Library. You may convey such object
|
||||
code under terms of your choice, provided that, if the incorporated
|
||||
material is not limited to numerical parameters, data structure
|
||||
layouts and accessors, or small macros, inline functions and templates
|
||||
(ten or fewer lines in length), you do both of the following:
|
||||
To "modify" a work means to copy from or adapt all or part of the work
|
||||
in a fashion requiring copyright permission, other than the making of an
|
||||
exact copy. The resulting work is called a "modified version" of the
|
||||
earlier work or a work "based on" the earlier work.
|
||||
|
||||
a) Give prominent notice with each copy of the object code that the
|
||||
Library is used in it and that the Library and its use are
|
||||
covered by this License.
|
||||
A "covered work" means either the unmodified Program or a work based
|
||||
on the Program.
|
||||
|
||||
b) Accompany the object code with a copy of the GNU GPL and this license
|
||||
document.
|
||||
To "propagate" a work means to do anything with it that, without
|
||||
permission, would make you directly or secondarily liable for
|
||||
infringement under applicable copyright law, except executing it on a
|
||||
computer or modifying a private copy. Propagation includes copying,
|
||||
distribution (with or without modification), making available to the
|
||||
public, and in some countries other activities as well.
|
||||
|
||||
4. Combined Works.
|
||||
To "convey" a work means any kind of propagation that enables other
|
||||
parties to make or receive copies. Mere interaction with a user through
|
||||
a computer network, with no transfer of a copy, is not conveying.
|
||||
|
||||
You may convey a Combined Work under terms of your choice that,
|
||||
taken together, effectively do not restrict modification of the
|
||||
portions of the Library contained in the Combined Work and reverse
|
||||
engineering for debugging such modifications, if you also do each of
|
||||
the following:
|
||||
An interactive user interface displays "Appropriate Legal Notices"
|
||||
to the extent that it includes a convenient and prominently visible
|
||||
feature that (1) displays an appropriate copyright notice, and (2)
|
||||
tells the user that there is no warranty for the work (except to the
|
||||
extent that warranties are provided), that licensees may convey the
|
||||
work under this License, and how to view a copy of this License. If
|
||||
the interface presents a list of user commands or options, such as a
|
||||
menu, a prominent item in the list meets this criterion.
|
||||
|
||||
a) Give prominent notice with each copy of the Combined Work that
|
||||
the Library is used in it and that the Library and its use are
|
||||
covered by this License.
|
||||
1. Source Code.
|
||||
|
||||
b) Accompany the Combined Work with a copy of the GNU GPL and this license
|
||||
document.
|
||||
The "source code" for a work means the preferred form of the work
|
||||
for making modifications to it. "Object code" means any non-source
|
||||
form of a work.
|
||||
|
||||
c) For a Combined Work that displays copyright notices during
|
||||
execution, include the copyright notice for the Library among
|
||||
these notices, as well as a reference directing the user to the
|
||||
copies of the GNU GPL and this license document.
|
||||
A "Standard Interface" means an interface that either is an official
|
||||
standard defined by a recognized standards body, or, in the case of
|
||||
interfaces specified for a particular programming language, one that
|
||||
is widely used among developers working in that language.
|
||||
|
||||
d) Do one of the following:
|
||||
The "System Libraries" of an executable work include anything, other
|
||||
than the work as a whole, that (a) is included in the normal form of
|
||||
packaging a Major Component, but which is not part of that Major
|
||||
Component, and (b) serves only to enable use of the work with that
|
||||
Major Component, or to implement a Standard Interface for which an
|
||||
implementation is available to the public in source code form. A
|
||||
"Major Component", in this context, means a major essential component
|
||||
(kernel, window system, and so on) of the specific operating system
|
||||
(if any) on which the executable work runs, or a compiler used to
|
||||
produce the work, or an object code interpreter used to run it.
|
||||
|
||||
0) Convey the Minimal Corresponding Source under the terms of this
|
||||
License, and the Corresponding Application Code in a form
|
||||
suitable for, and under terms that permit, the user to
|
||||
recombine or relink the Application with a modified version of
|
||||
the Linked Version to produce a modified Combined Work, in the
|
||||
manner specified by section 6 of the GNU GPL for conveying
|
||||
Corresponding Source.
|
||||
The "Corresponding Source" for a work in object code form means all
|
||||
the source code needed to generate, install, and (for an executable
|
||||
work) run the object code and to modify the work, including scripts to
|
||||
control those activities. However, it does not include the work's
|
||||
System Libraries, or general-purpose tools or generally available free
|
||||
programs which are used unmodified in performing those activities but
|
||||
which are not part of the work. For example, Corresponding Source
|
||||
includes interface definition files associated with source files for
|
||||
the work, and the source code for shared libraries and dynamically
|
||||
linked subprograms that the work is specifically designed to require,
|
||||
such as by intimate data communication or control flow between those
|
||||
subprograms and other parts of the work.
|
||||
|
||||
1) Use a suitable shared library mechanism for linking with the
|
||||
Library. A suitable mechanism is one that (a) uses at run time
|
||||
a copy of the Library already present on the user's computer
|
||||
system, and (b) will operate properly with a modified version
|
||||
of the Library that is interface-compatible with the Linked
|
||||
Version.
|
||||
The Corresponding Source need not include anything that users
|
||||
can regenerate automatically from other parts of the Corresponding
|
||||
Source.
|
||||
|
||||
e) Provide Installation Information, but only if you would otherwise
|
||||
be required to provide such information under section 6 of the
|
||||
GNU GPL, and only to the extent that such information is
|
||||
necessary to install and execute a modified version of the
|
||||
Combined Work produced by recombining or relinking the
|
||||
Application with a modified version of the Linked Version. (If
|
||||
you use option 4d0, the Installation Information must accompany
|
||||
the Minimal Corresponding Source and Corresponding Application
|
||||
Code. If you use option 4d1, you must provide the Installation
|
||||
Information in the manner specified by section 6 of the GNU GPL
|
||||
for conveying Corresponding Source.)
|
||||
The Corresponding Source for a work in source code form is that
|
||||
same work.
|
||||
|
||||
5. Combined Libraries.
|
||||
2. Basic Permissions.
|
||||
|
||||
You may place library facilities that are a work based on the
|
||||
Library side by side in a single library together with other library
|
||||
facilities that are not Applications and are not covered by this
|
||||
License, and convey such a combined library under terms of your
|
||||
choice, if you do both of the following:
|
||||
All rights granted under this License are granted for the term of
|
||||
copyright on the Program, and are irrevocable provided the stated
|
||||
conditions are met. This License explicitly affirms your unlimited
|
||||
permission to run the unmodified Program. The output from running a
|
||||
covered work is covered by this License only if the output, given its
|
||||
content, constitutes a covered work. This License acknowledges your
|
||||
rights of fair use or other equivalent, as provided by copyright law.
|
||||
|
||||
a) Accompany the combined library with a copy of the same work based
|
||||
on the Library, uncombined with any other library facilities,
|
||||
conveyed under the terms of this License.
|
||||
You may make, run and propagate covered works that you do not
|
||||
convey, without conditions so long as your license otherwise remains
|
||||
in force. You may convey covered works to others for the sole purpose
|
||||
of having them make modifications exclusively for you, or provide you
|
||||
with facilities for running those works, provided that you comply with
|
||||
the terms of this License in conveying all material for which you do
|
||||
not control copyright. Those thus making or running the covered works
|
||||
for you must do so exclusively on your behalf, under your direction
|
||||
and control, on terms that prohibit them from making any copies of
|
||||
your copyrighted material outside their relationship with you.
|
||||
|
||||
b) Give prominent notice with the combined library that part of it
|
||||
is a work based on the Library, and explaining where to find the
|
||||
accompanying uncombined form of the same work.
|
||||
Conveying under any other circumstances is permitted solely under
|
||||
the conditions stated below. Sublicensing is not allowed; section 10
|
||||
makes it unnecessary.
|
||||
|
||||
6. Revised Versions of the GNU Lesser General Public License.
|
||||
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
|
||||
|
||||
The Free Software Foundation may publish revised and/or new versions
|
||||
of the GNU Lesser 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.
|
||||
No covered work shall be deemed part of an effective technological
|
||||
measure under any applicable law fulfilling obligations under article
|
||||
11 of the WIPO copyright treaty adopted on 20 December 1996, or
|
||||
similar laws prohibiting or restricting circumvention of such
|
||||
measures.
|
||||
|
||||
Each version is given a distinguishing version number. If the
|
||||
Library as you received it specifies that a certain numbered version
|
||||
of the GNU Lesser General Public License "or any later version"
|
||||
applies to it, you have the option of following the terms and
|
||||
conditions either of that published version or of any later version
|
||||
published by the Free Software Foundation. If the Library as you
|
||||
received it does not specify a version number of the GNU Lesser
|
||||
General Public License, you may choose any version of the GNU Lesser
|
||||
General Public License ever published by the Free Software Foundation.
|
||||
When you convey a covered work, you waive any legal power to forbid
|
||||
circumvention of technological measures to the extent such circumvention
|
||||
is effected by exercising rights under this License with respect to
|
||||
the covered work, and you disclaim any intention to limit operation or
|
||||
modification of the work as a means of enforcing, against the work's
|
||||
users, your or third parties' legal rights to forbid circumvention of
|
||||
technological measures.
|
||||
|
||||
If the Library as you received it specifies that a proxy can decide
|
||||
whether future versions of the GNU Lesser General Public License shall
|
||||
apply, that proxy's public statement of acceptance of any version is
|
||||
permanent authorization for you to choose that version for the
|
||||
Library.
|
||||
4. Conveying Verbatim Copies.
|
||||
|
||||
You may convey 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;
|
||||
keep intact all notices stating that this License and any
|
||||
non-permissive terms added in accord with section 7 apply to the code;
|
||||
keep intact all notices of the absence of any warranty; and give all
|
||||
recipients a copy of this License along with the Program.
|
||||
|
||||
You may charge any price or no price for each copy that you convey,
|
||||
and you may offer support or warranty protection for a fee.
|
||||
|
||||
5. Conveying Modified Source Versions.
|
||||
|
||||
You may convey a work based on the Program, or the modifications to
|
||||
produce it from the Program, in the form of source code under the
|
||||
terms of section 4, provided that you also meet all of these conditions:
|
||||
|
||||
a) The work must carry prominent notices stating that you modified
|
||||
it, and giving a relevant date.
|
||||
|
||||
b) The work must carry prominent notices stating that it is
|
||||
released under this License and any conditions added under section
|
||||
7. This requirement modifies the requirement in section 4 to
|
||||
"keep intact all notices".
|
||||
|
||||
c) You must license the entire work, as a whole, under this
|
||||
License to anyone who comes into possession of a copy. This
|
||||
License will therefore apply, along with any applicable section 7
|
||||
additional terms, to the whole of the work, and all its parts,
|
||||
regardless of how they are packaged. This License gives no
|
||||
permission to license the work in any other way, but it does not
|
||||
invalidate such permission if you have separately received it.
|
||||
|
||||
d) If the work has interactive user interfaces, each must display
|
||||
Appropriate Legal Notices; however, if the Program has interactive
|
||||
interfaces that do not display Appropriate Legal Notices, your
|
||||
work need not make them do so.
|
||||
|
||||
A compilation of a covered work with other separate and independent
|
||||
works, which are not by their nature extensions of the covered work,
|
||||
and which are not combined with it such as to form a larger program,
|
||||
in or on a volume of a storage or distribution medium, is called an
|
||||
"aggregate" if the compilation and its resulting copyright are not
|
||||
used to limit the access or legal rights of the compilation's users
|
||||
beyond what the individual works permit. Inclusion of a covered work
|
||||
in an aggregate does not cause this License to apply to the other
|
||||
parts of the aggregate.
|
||||
|
||||
6. Conveying Non-Source Forms.
|
||||
|
||||
You may convey a covered work in object code form under the terms
|
||||
of sections 4 and 5, provided that you also convey the
|
||||
machine-readable Corresponding Source under the terms of this License,
|
||||
in one of these ways:
|
||||
|
||||
a) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by the
|
||||
Corresponding Source fixed on a durable physical medium
|
||||
customarily used for software interchange.
|
||||
|
||||
b) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by a
|
||||
written offer, valid for at least three years and valid for as
|
||||
long as you offer spare parts or customer support for that product
|
||||
model, to give anyone who possesses the object code either (1) a
|
||||
copy of the Corresponding Source for all the software in the
|
||||
product that is covered by this License, on a durable physical
|
||||
medium customarily used for software interchange, for a price no
|
||||
more than your reasonable cost of physically performing this
|
||||
conveying of source, or (2) access to copy the
|
||||
Corresponding Source from a network server at no charge.
|
||||
|
||||
c) Convey individual copies of the object code with a copy of the
|
||||
written offer to provide the Corresponding Source. This
|
||||
alternative is allowed only occasionally and noncommercially, and
|
||||
only if you received the object code with such an offer, in accord
|
||||
with subsection 6b.
|
||||
|
||||
d) Convey the object code by offering access from a designated
|
||||
place (gratis or for a charge), and offer equivalent access to the
|
||||
Corresponding Source in the same way through the same place at no
|
||||
further charge. You need not require recipients to copy the
|
||||
Corresponding Source along with the object code. If the place to
|
||||
copy the object code is a network server, the Corresponding Source
|
||||
may be on a different server (operated by you or a third party)
|
||||
that supports equivalent copying facilities, provided you maintain
|
||||
clear directions next to the object code saying where to find the
|
||||
Corresponding Source. Regardless of what server hosts the
|
||||
Corresponding Source, you remain obligated to ensure that it is
|
||||
available for as long as needed to satisfy these requirements.
|
||||
|
||||
e) Convey the object code using peer-to-peer transmission, provided
|
||||
you inform other peers where the object code and Corresponding
|
||||
Source of the work are being offered to the general public at no
|
||||
charge under subsection 6d.
|
||||
|
||||
A separable portion of the object code, whose source code is excluded
|
||||
from the Corresponding Source as a System Library, need not be
|
||||
included in conveying the object code work.
|
||||
|
||||
A "User Product" is either (1) a "consumer product", which means any
|
||||
tangible personal property which is normally used for personal, family,
|
||||
or household purposes, or (2) anything designed or sold for incorporation
|
||||
into a dwelling. In determining whether a product is a consumer product,
|
||||
doubtful cases shall be resolved in favor of coverage. For a particular
|
||||
product received by a particular user, "normally used" refers to a
|
||||
typical or common use of that class of product, regardless of the status
|
||||
of the particular user or of the way in which the particular user
|
||||
actually uses, or expects or is expected to use, the product. A product
|
||||
is a consumer product regardless of whether the product has substantial
|
||||
commercial, industrial or non-consumer uses, unless such uses represent
|
||||
the only significant mode of use of the product.
|
||||
|
||||
"Installation Information" for a User Product means any methods,
|
||||
procedures, authorization keys, or other information required to install
|
||||
and execute modified versions of a covered work in that User Product from
|
||||
a modified version of its Corresponding Source. The information must
|
||||
suffice to ensure that the continued functioning of the modified object
|
||||
code is in no case prevented or interfered with solely because
|
||||
modification has been made.
|
||||
|
||||
If you convey an object code work under this section in, or with, or
|
||||
specifically for use in, a User Product, and the conveying occurs as
|
||||
part of a transaction in which the right of possession and use of the
|
||||
User Product is transferred to the recipient in perpetuity or for a
|
||||
fixed term (regardless of how the transaction is characterized), the
|
||||
Corresponding Source conveyed under this section must be accompanied
|
||||
by the Installation Information. But this requirement does not apply
|
||||
if neither you nor any third party retains the ability to install
|
||||
modified object code on the User Product (for example, the work has
|
||||
been installed in ROM).
|
||||
|
||||
The requirement to provide Installation Information does not include a
|
||||
requirement to continue to provide support service, warranty, or updates
|
||||
for a work that has been modified or installed by the recipient, or for
|
||||
the User Product in which it has been modified or installed. Access to a
|
||||
network may be denied when the modification itself materially and
|
||||
adversely affects the operation of the network or violates the rules and
|
||||
protocols for communication across the network.
|
||||
|
||||
Corresponding Source conveyed, and Installation Information provided,
|
||||
in accord with this section must be in a format that is publicly
|
||||
documented (and with an implementation available to the public in
|
||||
source code form), and must require no special password or key for
|
||||
unpacking, reading or copying.
|
||||
|
||||
7. Additional Terms.
|
||||
|
||||
"Additional permissions" are terms that supplement the terms of this
|
||||
License by making exceptions from one or more of its conditions.
|
||||
Additional permissions that are applicable to the entire Program shall
|
||||
be treated as though they were included in this License, to the extent
|
||||
that they are valid under applicable law. If additional permissions
|
||||
apply only to part of the Program, that part may be used separately
|
||||
under those permissions, but the entire Program remains governed by
|
||||
this License without regard to the additional permissions.
|
||||
|
||||
When you convey a copy of a covered work, you may at your option
|
||||
remove any additional permissions from that copy, or from any part of
|
||||
it. (Additional permissions may be written to require their own
|
||||
removal in certain cases when you modify the work.) You may place
|
||||
additional permissions on material, added by you to a covered work,
|
||||
for which you have or can give appropriate copyright permission.
|
||||
|
||||
Notwithstanding any other provision of this License, for material you
|
||||
add to a covered work, you may (if authorized by the copyright holders of
|
||||
that material) supplement the terms of this License with terms:
|
||||
|
||||
a) Disclaiming warranty or limiting liability differently from the
|
||||
terms of sections 15 and 16 of this License; or
|
||||
|
||||
b) Requiring preservation of specified reasonable legal notices or
|
||||
author attributions in that material or in the Appropriate Legal
|
||||
Notices displayed by works containing it; or
|
||||
|
||||
c) Prohibiting misrepresentation of the origin of that material, or
|
||||
requiring that modified versions of such material be marked in
|
||||
reasonable ways as different from the original version; or
|
||||
|
||||
d) Limiting the use for publicity purposes of names of licensors or
|
||||
authors of the material; or
|
||||
|
||||
e) Declining to grant rights under trademark law for use of some
|
||||
trade names, trademarks, or service marks; or
|
||||
|
||||
f) Requiring indemnification of licensors and authors of that
|
||||
material by anyone who conveys the material (or modified versions of
|
||||
it) with contractual assumptions of liability to the recipient, for
|
||||
any liability that these contractual assumptions directly impose on
|
||||
those licensors and authors.
|
||||
|
||||
All other non-permissive additional terms are considered "further
|
||||
restrictions" within the meaning of section 10. If the Program as you
|
||||
received it, or any part of it, contains a notice stating that it is
|
||||
governed by this License along with a term that is a further
|
||||
restriction, you may remove that term. If a license document contains
|
||||
a further restriction but permits relicensing or conveying under this
|
||||
License, you may add to a covered work material governed by the terms
|
||||
of that license document, provided that the further restriction does
|
||||
not survive such relicensing or conveying.
|
||||
|
||||
If you add terms to a covered work in accord with this section, you
|
||||
must place, in the relevant source files, a statement of the
|
||||
additional terms that apply to those files, or a notice indicating
|
||||
where to find the applicable terms.
|
||||
|
||||
Additional terms, permissive or non-permissive, may be stated in the
|
||||
form of a separately written license, or stated as exceptions;
|
||||
the above requirements apply either way.
|
||||
|
||||
8. Termination.
|
||||
|
||||
You may not propagate or modify a covered work except as expressly
|
||||
provided under this License. Any attempt otherwise to propagate or
|
||||
modify it is void, and will automatically terminate your rights under
|
||||
this License (including any patent licenses granted under the third
|
||||
paragraph of section 11).
|
||||
|
||||
However, if you cease all violation of this License, then your
|
||||
license from a particular copyright holder is reinstated (a)
|
||||
provisionally, unless and until the copyright holder explicitly and
|
||||
finally terminates your license, and (b) permanently, if the copyright
|
||||
holder fails to notify you of the violation by some reasonable means
|
||||
prior to 60 days after the cessation.
|
||||
|
||||
Moreover, your license from a particular copyright holder is
|
||||
reinstated permanently if the copyright holder notifies you of the
|
||||
violation by some reasonable means, this is the first time you have
|
||||
received notice of violation of this License (for any work) from that
|
||||
copyright holder, and you cure the violation prior to 30 days after
|
||||
your receipt of the notice.
|
||||
|
||||
Termination of your rights under this section does not terminate the
|
||||
licenses of parties who have received copies or rights from you under
|
||||
this License. If your rights have been terminated and not permanently
|
||||
reinstated, you do not qualify to receive new licenses for the same
|
||||
material under section 10.
|
||||
|
||||
9. Acceptance Not Required for Having Copies.
|
||||
|
||||
You are not required to accept this License in order to receive or
|
||||
run a copy of the Program. Ancillary propagation of a covered work
|
||||
occurring solely as a consequence of using peer-to-peer transmission
|
||||
to receive a copy likewise does not require acceptance. However,
|
||||
nothing other than this License grants you permission to propagate or
|
||||
modify any covered work. These actions infringe copyright if you do
|
||||
not accept this License. Therefore, by modifying or propagating a
|
||||
covered work, you indicate your acceptance of this License to do so.
|
||||
|
||||
10. Automatic Licensing of Downstream Recipients.
|
||||
|
||||
Each time you convey a covered work, the recipient automatically
|
||||
receives a license from the original licensors, to run, modify and
|
||||
propagate that work, subject to this License. You are not responsible
|
||||
for enforcing compliance by third parties with this License.
|
||||
|
||||
An "entity transaction" is a transaction transferring control of an
|
||||
organization, or substantially all assets of one, or subdividing an
|
||||
organization, or merging organizations. If propagation of a covered
|
||||
work results from an entity transaction, each party to that
|
||||
transaction who receives a copy of the work also receives whatever
|
||||
licenses to the work the party's predecessor in interest had or could
|
||||
give under the previous paragraph, plus a right to possession of the
|
||||
Corresponding Source of the work from the predecessor in interest, if
|
||||
the predecessor has it or can get it with reasonable efforts.
|
||||
|
||||
You may not impose any further restrictions on the exercise of the
|
||||
rights granted or affirmed under this License. For example, you may
|
||||
not impose a license fee, royalty, or other charge for exercise of
|
||||
rights granted under this License, and you may not initiate litigation
|
||||
(including a cross-claim or counterclaim in a lawsuit) alleging that
|
||||
any patent claim is infringed by making, using, selling, offering for
|
||||
sale, or importing the Program or any portion of it.
|
||||
|
||||
11. Patents.
|
||||
|
||||
A "contributor" is a copyright holder who authorizes use under this
|
||||
License of the Program or a work on which the Program is based. The
|
||||
work thus licensed is called the contributor's "contributor version".
|
||||
|
||||
A contributor's "essential patent claims" are all patent claims
|
||||
owned or controlled by the contributor, whether already acquired or
|
||||
hereafter acquired, that would be infringed by some manner, permitted
|
||||
by this License, of making, using, or selling its contributor version,
|
||||
but do not include claims that would be infringed only as a
|
||||
consequence of further modification of the contributor version. For
|
||||
purposes of this definition, "control" includes the right to grant
|
||||
patent sublicenses in a manner consistent with the requirements of
|
||||
this License.
|
||||
|
||||
Each contributor grants you a non-exclusive, worldwide, royalty-free
|
||||
patent license under the contributor's essential patent claims, to
|
||||
make, use, sell, offer for sale, import and otherwise run, modify and
|
||||
propagate the contents of its contributor version.
|
||||
|
||||
In the following three paragraphs, a "patent license" is any express
|
||||
agreement or commitment, however denominated, not to enforce a patent
|
||||
(such as an express permission to practice a patent or covenant not to
|
||||
sue for patent infringement). To "grant" such a patent license to a
|
||||
party means to make such an agreement or commitment not to enforce a
|
||||
patent against the party.
|
||||
|
||||
If you convey a covered work, knowingly relying on a patent license,
|
||||
and the Corresponding Source of the work is not available for anyone
|
||||
to copy, free of charge and under the terms of this License, through a
|
||||
publicly available network server or other readily accessible means,
|
||||
then you must either (1) cause the Corresponding Source to be so
|
||||
available, or (2) arrange to deprive yourself of the benefit of the
|
||||
patent license for this particular work, or (3) arrange, in a manner
|
||||
consistent with the requirements of this License, to extend the patent
|
||||
license to downstream recipients. "Knowingly relying" means you have
|
||||
actual knowledge that, but for the patent license, your conveying the
|
||||
covered work in a country, or your recipient's use of the covered work
|
||||
in a country, would infringe one or more identifiable patents in that
|
||||
country that you have reason to believe are valid.
|
||||
|
||||
If, pursuant to or in connection with a single transaction or
|
||||
arrangement, you convey, or propagate by procuring conveyance of, a
|
||||
covered work, and grant a patent license to some of the parties
|
||||
receiving the covered work authorizing them to use, propagate, modify
|
||||
or convey a specific copy of the covered work, then the patent license
|
||||
you grant is automatically extended to all recipients of the covered
|
||||
work and works based on it.
|
||||
|
||||
A patent license is "discriminatory" if it does not include within
|
||||
the scope of its coverage, prohibits the exercise of, or is
|
||||
conditioned on the non-exercise of one or more of the rights that are
|
||||
specifically granted under this License. You may not convey a covered
|
||||
work if you are a party to an arrangement with a third party that is
|
||||
in the business of distributing software, under which you make payment
|
||||
to the third party based on the extent of your activity of conveying
|
||||
the work, and under which the third party grants, to any of the
|
||||
parties who would receive the covered work from you, a discriminatory
|
||||
patent license (a) in connection with copies of the covered work
|
||||
conveyed by you (or copies made from those copies), or (b) primarily
|
||||
for and in connection with specific products or compilations that
|
||||
contain the covered work, unless you entered into that arrangement,
|
||||
or that patent license was granted, prior to 28 March 2007.
|
||||
|
||||
Nothing in this License shall be construed as excluding or limiting
|
||||
any implied license or other defenses to infringement that may
|
||||
otherwise be available to you under applicable patent law.
|
||||
|
||||
12. No Surrender of Others' Freedom.
|
||||
|
||||
If 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 convey a
|
||||
covered work so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you may
|
||||
not convey it at all. For example, if you agree to terms that obligate you
|
||||
to collect a royalty for further conveying from those to whom you convey
|
||||
the Program, the only way you could satisfy both those terms and this
|
||||
License would be to refrain entirely from conveying the Program.
|
||||
|
||||
13. Use with the GNU Affero General Public License.
|
||||
|
||||
Notwithstanding any other provision of this License, you have
|
||||
permission to link or combine any covered work with a work licensed
|
||||
under version 3 of the GNU Affero General Public License into a single
|
||||
combined work, and to convey the resulting work. The terms of this
|
||||
License will continue to apply to the part which is the covered work,
|
||||
but the special requirements of the GNU Affero General Public License,
|
||||
section 13, concerning interaction through a network will apply to the
|
||||
combination as such.
|
||||
|
||||
14. Revised Versions of this License.
|
||||
|
||||
The Free Software Foundation may publish revised and/or new versions of
|
||||
the GNU 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 that a certain numbered version of the GNU General
|
||||
Public License "or any later version" applies to it, you have the
|
||||
option of following the terms and conditions either of that numbered
|
||||
version or of any later version published by the Free Software
|
||||
Foundation. If the Program does not specify a version number of the
|
||||
GNU General Public License, you may choose any version ever published
|
||||
by the Free Software Foundation.
|
||||
|
||||
If the Program specifies that a proxy can decide which future
|
||||
versions of the GNU General Public License can be used, that proxy's
|
||||
public statement of acceptance of a version permanently authorizes you
|
||||
to choose that version for the Program.
|
||||
|
||||
Later license versions may give you additional or different
|
||||
permissions. However, no additional obligations are imposed on any
|
||||
author or copyright holder as a result of your choosing to follow a
|
||||
later version.
|
||||
|
||||
15. Disclaimer of Warranty.
|
||||
|
||||
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.
|
||||
|
||||
16. Limitation of Liability.
|
||||
|
||||
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
|
||||
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.
|
||||
|
||||
17. Interpretation of Sections 15 and 16.
|
||||
|
||||
If the disclaimer of warranty and limitation of liability provided
|
||||
above cannot be given local legal effect according to their terms,
|
||||
reviewing courts shall apply local law that most closely approximates
|
||||
an absolute waiver of all civil liability in connection with the
|
||||
Program, unless a warranty or assumption of liability accompanies a
|
||||
copy of the Program in return for a fee.
|
||||
|
||||
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
|
||||
state 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 3 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, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
If the program does terminal interaction, make it output a short
|
||||
notice like this when it starts in an interactive mode:
|
||||
|
||||
<program> Copyright (C) <year> <name of author>
|
||||
This program 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, your program's commands
|
||||
might be different; for a GUI interface, you would use an "about box".
|
||||
|
||||
You should also get your employer (if you work as a programmer) or school,
|
||||
if any, to sign a "copyright disclaimer" for the program, if necessary.
|
||||
For more information on this, and how to apply and follow the GNU GPL, see
|
||||
<https://www.gnu.org/licenses/>.
|
||||
|
||||
The GNU 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. But first, please read
|
||||
<https://www.gnu.org/licenses/why-not-lgpl.html>.
|
||||
@@ -1,11 +1,11 @@
|
||||
AntiCheatReloaded
|
||||
AntiCheatReloaded [](https://github.com/Rammelkast/AntiCheatReloaded/releases) [](https://github.com/Rammelkast/AntiCheatReloaded/releases) [](https://github.com/Rammelkast/AntiCheatReloaded/commits/master) [](https://ci.rammelkast.com/job/AntiCheatReloaded/lastBuild/)
|
||||
=============
|
||||
AntiCheatReloaded is a fork of the old 'AntiCheat' project.
|
||||
AntiCheat helps server admins easily identify and block malicious users by monitoring and analyzing the behaviour of their players.
|
||||
AntiCheatReloaded helps server admins combat the use of hacked clients and spambots. It analyses the behavior of players and can prevent malicious gameplay. The plugin offers a lot of customizability and can be connected across multiple servers in case it is used in a server network context. AntiCheatReloaded is based on gravitylow's AntiCheat and has been around since 2012.
|
||||
|
||||
###Want to help me out?
|
||||
First of all, i've put a lot of time and work in this project, so donations (especially in (m)BTC) are appreciated!
|
||||
My BTC address is 1JfyX6hvGUazHTtKVLaNcYaUxnyjR5HtMY
|
||||
Installation
|
||||
------------
|
||||
AntiCheatReloaded **requires** you to have ProtocolLib. You can download it [here](https://www.spigotmc.org/resources/protocollib.1997/).
|
||||
Simply drag and drop the AntiCheatReloaded and ProtocolLib jars in your plugin folder. You can now use AntiCheatReloaded, but be sure to have a look at the configuration files, which allow you to change every aspect of the plugin.
|
||||
|
||||
Bug Reporting
|
||||
------------
|
||||
@@ -13,36 +13,41 @@ Bug Reporting
|
||||
Issues should be filed by hitting the [issues](https://github.com/Rammelkast/AntiCheatReloaded/issues?state=open) tab above. Please make sure you search your issue before opening a new ticket.
|
||||
|
||||
Please include the following information with your issue, this allows me to fix it quicker;
|
||||
* The `/anticheat debug` log
|
||||
* Your AntiCheatReloaded version
|
||||
* Your server software (Bukkit/Spigot/Paper/Taco) and it's version
|
||||
* When using protocollib, your protocollib version
|
||||
* If you use protocolhacks (ViaVersion etc.)
|
||||
* Your server implementation (Bukkit/Spigot/Other) and it's version
|
||||
* Your ProtocolLib version
|
||||
* Whether or not you are using protocol hacks (ViaVersion etc.)
|
||||
* Any logs relating to the issue
|
||||
|
||||
Usage
|
||||
Hacks blocked
|
||||
-------
|
||||
Simply drag and drop the plugin and the ProtoclLib into your Plugins folder.
|
||||
|
||||
###Hacks blocked
|
||||
-------
|
||||
* Blink
|
||||
* Flight
|
||||
* Glide
|
||||
* Jesus
|
||||
* Step
|
||||
* Criticals
|
||||
* KillAura
|
||||
* Anti-Knockback
|
||||
* FastBow
|
||||
* FastDrop
|
||||
* Reach
|
||||
* Spider
|
||||
* Speed
|
||||
* NoFall
|
||||
* Sneak
|
||||
* vClip
|
||||
* Timer
|
||||
* Flight/Glide
|
||||
* ElytraFly
|
||||
* WaterWalk/Jesus
|
||||
* FastBreak
|
||||
* FastPlace
|
||||
* Spam
|
||||
* FastEat
|
||||
* Chat spam
|
||||
* Command spam
|
||||
* Sprint
|
||||
* (Packet)Sneak
|
||||
* Speed
|
||||
* Vclip
|
||||
* Spider
|
||||
* NoFall
|
||||
* FastBow
|
||||
* FastEat
|
||||
* FastHeal
|
||||
* KillAura
|
||||
* Aimbot
|
||||
* Reach
|
||||
* Unicode chat
|
||||
* FastProjectile
|
||||
* ItemSpam
|
||||
* FastInventory
|
||||
* Timer
|
||||
* Blink
|
||||
* Anti-Knockback
|
||||
* Scaffold
|
||||
* FastLadder
|
||||
* Strafe
|
||||
* NoSlow
|
||||
@@ -1,20 +1,36 @@
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>com.rammelkast.anticheatreloaded</groupId>
|
||||
<artifactId>AntiCheatReloaded</artifactId>
|
||||
<version>1.6.1-ALPHA</version>
|
||||
<version>1.11.0-PRE</version>
|
||||
<name>AntiCheatReloaded</name>
|
||||
<url>https://rammelkast.com</url>
|
||||
<url>https://www.spigotmc.org/resources/anticheatreloaded.23799/</url>
|
||||
<properties>
|
||||
<project.build.version>${project.version}</project.build.version>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<maven.compiler.source>1.8</maven.compiler.source>
|
||||
<maven.compiler.target>1.8</maven.compiler.target>
|
||||
</properties>
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>dmulloy2-repo</id>
|
||||
<url>http://repo.dmulloy2.net/content/groups/public/</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>dmulloy2-repo</id>
|
||||
<url>https://repo.dmulloy2.net/nexus/repository/public/</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>spigot-public-repo</id>
|
||||
<url>https://hub.spigotmc.org/nexus/content/repositories/public/</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>opencollab-snapshot-repo</id>
|
||||
<url>https://repo.opencollab.dev/maven-snapshots/</url>
|
||||
<releases>
|
||||
<enabled>false</enabled>
|
||||
</releases>
|
||||
<snapshots>
|
||||
<enabled>true</enabled>
|
||||
</snapshots>
|
||||
</repository>
|
||||
</repositories>
|
||||
<build>
|
||||
<sourceDirectory>${basedir}/src/main/java</sourceDirectory>
|
||||
@@ -22,31 +38,46 @@
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>3.1</version>
|
||||
<configuration>
|
||||
<source>1.7</source>
|
||||
<target>1.7</target>
|
||||
</configuration>
|
||||
<version>3.8.1</version>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-shade-plugin</artifactId>
|
||||
<version>1.3</version>
|
||||
<version>3.2.4</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>shade</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<minimizeJar>true</minimizeJar>
|
||||
<createDependencyReducedPom>false</createDependencyReducedPom>
|
||||
<relocations>
|
||||
<relocation>
|
||||
<pattern>org.bstats</pattern>
|
||||
<shadedPattern>com.rammelkast.anticheatreloaded.util</shadedPattern>
|
||||
</relocation>
|
||||
<relocation>
|
||||
<pattern>com.cryptomorin.xseries</pattern>
|
||||
<shadedPattern>com.rammelkast.anticheatreloaded.util</shadedPattern>
|
||||
</relocation>
|
||||
<relocation>
|
||||
<pattern>com.github.juliarn.npc</pattern>
|
||||
<shadedPattern>com.rammelkast.anticheatreloaded.util.npc</shadedPattern>
|
||||
</relocation>
|
||||
</relocations>
|
||||
<filters>
|
||||
<filter>
|
||||
<artifact>com.github.cryptomorin:*</artifact>
|
||||
<includes>
|
||||
<include>com/cryptomorin/xseries/XMaterial*</include>
|
||||
</includes>
|
||||
</filter>
|
||||
</filters>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
<configuration>
|
||||
<artifactSet>
|
||||
<includes>
|
||||
<include>com.rammelkast.*</include>
|
||||
</includes>
|
||||
</artifactSet>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
<finalName>AntiCheatReloaded</finalName>
|
||||
@@ -54,7 +85,7 @@
|
||||
<extension>
|
||||
<groupId>org.apache.maven.wagon</groupId>
|
||||
<artifactId>wagon-file</artifactId>
|
||||
<version>2.2</version>
|
||||
<version>3.4.3</version>
|
||||
</extension>
|
||||
</extensions>
|
||||
<resources>
|
||||
@@ -64,37 +95,42 @@
|
||||
</resource>
|
||||
</resources>
|
||||
</build>
|
||||
<profiles>
|
||||
<profile>
|
||||
<id>jenkins</id>
|
||||
<activation>
|
||||
<property>
|
||||
<name>env.BUILD_NUMBER</name>
|
||||
</property>
|
||||
</activation>
|
||||
<properties>
|
||||
<project.build.version>${project.version}-b${env.BUILD_NUMBER}</project.build.version>
|
||||
</properties>
|
||||
</profile>
|
||||
</profiles>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.comphenix.protocol</groupId>
|
||||
<artifactId>ProtocolLib</artifactId>
|
||||
<version>4.2.1-SNAPSHOT</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
<version>4.11</version>
|
||||
<type>jar</type>
|
||||
<scope>test</scope>
|
||||
<groupId>com.comphenix.protocol</groupId>
|
||||
<artifactId>ProtocolLib</artifactId>
|
||||
<version>4.8.0-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.spigotmc</groupId>
|
||||
<artifactId>spigot-api</artifactId>
|
||||
<version>1.18.1-R0.1-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
<version>1.18.22</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.geysermc.floodgate</groupId>
|
||||
<artifactId>api</artifactId>
|
||||
<version>2.0-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.bstats</groupId>
|
||||
<artifactId>bstats-bukkit</artifactId>
|
||||
<version>2.2.1</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.github.cryptomorin</groupId>
|
||||
<artifactId>XSeries</artifactId>
|
||||
<version>8.5.0.1</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.bukkit</groupId>
|
||||
<artifactId>craftbukkit</artifactId>
|
||||
<version>1.11.2-R0.1-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
</project>
|
||||
@@ -1,282 +0,0 @@
|
||||
/*
|
||||
* AntiCheat for Bukkit.
|
||||
* Copyright (C) 2012-2014 AntiCheat Team | http://gravitydevelopment.net
|
||||
*
|
||||
* 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 3 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, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.rammelkast.anticheatreloaded;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import com.comphenix.protocol.ProtocolLibrary;
|
||||
import com.comphenix.protocol.ProtocolManager;
|
||||
import com.rammelkast.anticheatreloaded.check.combat.KillAuraCheck;
|
||||
import com.rammelkast.anticheatreloaded.check.movement.BlinkCheck;
|
||||
import com.rammelkast.anticheatreloaded.command.CommandHandler;
|
||||
import com.rammelkast.anticheatreloaded.config.Configuration;
|
||||
import com.rammelkast.anticheatreloaded.event.BlockListener;
|
||||
import com.rammelkast.anticheatreloaded.event.EntityListener;
|
||||
import com.rammelkast.anticheatreloaded.event.InventoryListener;
|
||||
import com.rammelkast.anticheatreloaded.event.PlayerListener;
|
||||
import com.rammelkast.anticheatreloaded.event.VehicleListener;
|
||||
import com.rammelkast.anticheatreloaded.manage.AntiCheatManager;
|
||||
import com.rammelkast.anticheatreloaded.metrics.Metrics;
|
||||
import com.rammelkast.anticheatreloaded.util.User;
|
||||
import com.rammelkast.anticheatreloaded.util.VersionUtil;
|
||||
|
||||
public class AntiCheat extends JavaPlugin {
|
||||
|
||||
private static AntiCheatManager manager;
|
||||
private static AntiCheat plugin;
|
||||
private static List<Listener> eventList = new ArrayList<Listener>();
|
||||
private static Configuration config;
|
||||
private static boolean verbose;
|
||||
private static boolean developer;
|
||||
private static ProtocolManager protocolManager;
|
||||
private static boolean protocolLib = false;
|
||||
private static Long loadTime;
|
||||
|
||||
@Override
|
||||
public void onEnable() {
|
||||
plugin = this;
|
||||
loadTime = System.currentTimeMillis();
|
||||
manager = new AntiCheatManager(this, getLogger());
|
||||
eventList.add(new PlayerListener());
|
||||
eventList.add(new BlockListener());
|
||||
eventList.add(new EntityListener());
|
||||
eventList.add(new VehicleListener());
|
||||
eventList.add(new InventoryListener());
|
||||
// Order is important in some cases, don't screw with these unless
|
||||
// needed, especially config
|
||||
setupConfig();
|
||||
setupEvents();
|
||||
setupCommands();
|
||||
setupProtocol();
|
||||
// Enterprise must come before levels
|
||||
setupEnterprise();
|
||||
restoreLevels();
|
||||
|
||||
if (Bukkit.getPluginManager().getPlugin("ProtocolLib") != null) {
|
||||
getLogger().info("Found ProtocolLib, enabling checks that use ProtcolLib...");
|
||||
// Enable packetlisteners
|
||||
KillAuraCheck.listenPackets();
|
||||
BlinkCheck.startTimer();
|
||||
BlinkCheck.listenPackets();
|
||||
}
|
||||
|
||||
// Check if other AC's are installed
|
||||
Bukkit.getScheduler().runTaskLater(this, new Runnable() {
|
||||
public void run() {
|
||||
if (Bukkit.getPluginManager().getPlugin("NoCheatPlus") != null) {
|
||||
getLogger().severe("*----------------------------------------------*");
|
||||
getLogger().severe("You are also running NoCheatPlus!");
|
||||
getLogger().severe("Multiple anticheats create false cheat detections.");
|
||||
getLogger().severe("Please remove or disable NoCheatPlus to silence this warning.");
|
||||
getLogger().severe("*----------------------------------------------*");
|
||||
}
|
||||
if (Bukkit.getPluginManager().getPlugin("AAC") != null) {
|
||||
getLogger().severe("*----------------------------------------------*");
|
||||
getLogger().severe("You are also running AAC!");
|
||||
getLogger().severe("Multiple anticheats create false cheat detections.");
|
||||
getLogger().severe("Please remove or disable AAC to silence this warning.");
|
||||
getLogger().severe("*----------------------------------------------*");
|
||||
}
|
||||
if (Bukkit.getPluginManager().getPlugin("AntiCheat") != null) {
|
||||
getLogger().severe("*----------------------------------------------*");
|
||||
getLogger().severe("You are also running AntiCheat!");
|
||||
getLogger().severe("Multiple anticheats create false cheat detections.");
|
||||
getLogger().severe("Please remove or disable AntiCheat to silence this warning.");
|
||||
getLogger().severe("*----------------------------------------------*");
|
||||
}
|
||||
}
|
||||
}, 60L);
|
||||
|
||||
// End tests
|
||||
verboseLog("Finished loading.");
|
||||
getLogger().info("Running NMS version " + VersionUtil.getVersion() + "...");
|
||||
|
||||
// Metrics
|
||||
try {
|
||||
Metrics metrics = new Metrics(this);
|
||||
metrics.addCustomChart(new Metrics.SingleLineChart("cheaters_kicked") {
|
||||
@Override
|
||||
public int getValue() {
|
||||
return playersKicked;
|
||||
}
|
||||
});
|
||||
metrics.addCustomChart(new Metrics.SingleLineChart("killaura_violations") {
|
||||
@Override
|
||||
public int getValue() {
|
||||
return killauraViolations;
|
||||
}
|
||||
});
|
||||
metrics.addCustomChart(new Metrics.SingleLineChart("glide_violations") {
|
||||
@Override
|
||||
public int getValue() {
|
||||
return glideViolations;
|
||||
}
|
||||
});
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDisable() {
|
||||
verboseLog("Saving user levels...");
|
||||
config.getLevels().saveLevelsFromUsers(getManager().getUserManager().getUsers());
|
||||
|
||||
AntiCheatManager.close();
|
||||
getServer().getScheduler().cancelTasks(this);
|
||||
cleanup();
|
||||
}
|
||||
|
||||
private void setupProtocol() {
|
||||
if (Bukkit.getPluginManager().getPlugin("ProtocolLib") != null) {
|
||||
protocolLib = true;
|
||||
protocolManager = ProtocolLibrary.getProtocolManager();
|
||||
verboseLog("Hooked into ProtocolLib");
|
||||
}
|
||||
}
|
||||
|
||||
private void setupEvents() {
|
||||
for (Listener listener : eventList) {
|
||||
getServer().getPluginManager().registerEvents(listener, this);
|
||||
verboseLog("Registered events for ".concat(listener.toString().split("@")[0].split(".anticheat.")[1]));
|
||||
}
|
||||
}
|
||||
|
||||
private void setupCommands() {
|
||||
getCommand("anticheat").setExecutor(new CommandHandler());
|
||||
verboseLog("Registered commands.");
|
||||
}
|
||||
|
||||
private void setupConfig() {
|
||||
config = manager.getConfiguration();
|
||||
verboseLog("Setup the config.");
|
||||
}
|
||||
|
||||
private void setupEnterprise() {
|
||||
if (config.getConfig().enterprise.getValue()) {
|
||||
if (config.getEnterprise().loggingEnabled.getValue()) {
|
||||
config.getEnterprise().database.cleanEvents();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void restoreLevels() {
|
||||
for (Player player : getServer().getOnlinePlayers()) {
|
||||
UUID uuid = player.getUniqueId();
|
||||
|
||||
User user = new User(uuid);
|
||||
user.setIsWaitingOnLevelSync(true);
|
||||
config.getLevels().loadLevelToUser(user);
|
||||
|
||||
manager.getUserManager().addUser(user);
|
||||
verboseLog("Data for " + uuid + " loaded");
|
||||
}
|
||||
}
|
||||
|
||||
public static AntiCheat getPlugin() {
|
||||
return plugin;
|
||||
}
|
||||
|
||||
public static AntiCheatManager getManager() {
|
||||
return manager;
|
||||
}
|
||||
|
||||
public static String getVersion() {
|
||||
return manager.getPlugin().getDescription().getVersion();
|
||||
}
|
||||
|
||||
private void cleanup() {
|
||||
eventList = null;
|
||||
manager = null;
|
||||
config = null;
|
||||
}
|
||||
|
||||
public static boolean developerMode() {
|
||||
return developer;
|
||||
}
|
||||
|
||||
public static void setDeveloperMode(boolean b) {
|
||||
developer = b;
|
||||
}
|
||||
|
||||
public static boolean isUsingProtocolLib() {
|
||||
return protocolLib;
|
||||
}
|
||||
|
||||
public static void debugLog(final String string) {
|
||||
Bukkit.getScheduler().runTask(getPlugin(), new Runnable() {
|
||||
public void run() {
|
||||
if (developer) {
|
||||
manager.debugLog("[DEBUG] " + string);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void verboseLog(final String string) {
|
||||
if (verbose) {
|
||||
getLogger().info(string);
|
||||
}
|
||||
}
|
||||
|
||||
public void setVerbose(boolean b) {
|
||||
verbose = b;
|
||||
}
|
||||
|
||||
public Long getLoadTime() {
|
||||
return loadTime;
|
||||
}
|
||||
|
||||
public static ProtocolManager getProtocolManager() {
|
||||
return protocolManager;
|
||||
}
|
||||
|
||||
/**
|
||||
* Amount of players kicked since start
|
||||
*/
|
||||
private int playersKicked = 0;
|
||||
/**
|
||||
* Amount of killaura violations since start
|
||||
*/
|
||||
private int killauraViolations = 0;
|
||||
/**
|
||||
* Amount of glide violations since start
|
||||
*/
|
||||
private int glideViolations = 0;
|
||||
|
||||
public void onPlayerKicked() {
|
||||
this.playersKicked++;
|
||||
}
|
||||
|
||||
public void onKillAuraViolation() {
|
||||
this.killauraViolations++;
|
||||
}
|
||||
|
||||
public void onGlideViolation() {
|
||||
this.killauraViolations++;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,323 @@
|
||||
/*
|
||||
* AntiCheatReloaded for Bukkit and Spigot.
|
||||
* Copyright (c) 2012-2015 AntiCheat Team
|
||||
* Copyright (c) 2016-2022 Rammelkast
|
||||
*
|
||||
* 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 3 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, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.rammelkast.anticheatreloaded;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.Callable;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
||||
|
||||
import org.bstats.bukkit.Metrics;
|
||||
import org.bstats.charts.SimplePie;
|
||||
import org.bstats.charts.SingleLineChart;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
|
||||
import com.comphenix.protocol.ProtocolLibrary;
|
||||
import com.comphenix.protocol.ProtocolManager;
|
||||
import com.rammelkast.anticheatreloaded.command.CommandHandler;
|
||||
import com.rammelkast.anticheatreloaded.config.Configuration;
|
||||
import com.rammelkast.anticheatreloaded.event.BlockListener;
|
||||
import com.rammelkast.anticheatreloaded.event.EntityListener;
|
||||
import com.rammelkast.anticheatreloaded.event.InventoryListener;
|
||||
import com.rammelkast.anticheatreloaded.event.PacketListener;
|
||||
import com.rammelkast.anticheatreloaded.event.PlayerListener;
|
||||
import com.rammelkast.anticheatreloaded.event.VehicleListener;
|
||||
import com.rammelkast.anticheatreloaded.manage.AntiCheatManager;
|
||||
import com.rammelkast.anticheatreloaded.util.UpdateManager;
|
||||
import com.rammelkast.anticheatreloaded.util.User;
|
||||
import com.rammelkast.anticheatreloaded.util.VersionLib;
|
||||
|
||||
import lombok.Getter;
|
||||
|
||||
public final class AntiCheatReloaded extends JavaPlugin {
|
||||
|
||||
public static final String PREFIX = ChatColor.GOLD + "" + ChatColor.BOLD + "ACR " + ChatColor.DARK_GRAY + "> "
|
||||
+ ChatColor.GRAY;
|
||||
public static final List<UUID> MUTE_ENABLED_MODS = new ArrayList<UUID>();
|
||||
|
||||
@Getter
|
||||
private static AntiCheatReloaded plugin;
|
||||
@Getter
|
||||
private static AntiCheatManager manager;
|
||||
@Getter
|
||||
private static ExecutorService executor;
|
||||
@Getter
|
||||
private static ProtocolManager protocolManager;
|
||||
@Getter
|
||||
private static UpdateManager updateManager;
|
||||
@Getter
|
||||
private static boolean floodgateEnabled;
|
||||
private static List<Listener> eventList = new ArrayList<Listener>();
|
||||
private static Configuration config;
|
||||
private static boolean verbose;
|
||||
|
||||
private double tps = -1;
|
||||
|
||||
@Override
|
||||
public void onLoad() {
|
||||
plugin = this;
|
||||
|
||||
// Create executor service
|
||||
// Determine thread count based on available CPU cores/threads, max of 4
|
||||
final int threads = Math.max(Math.min(Runtime.getRuntime().availableProcessors() / 4, 4), 1);
|
||||
executor = Executors.newFixedThreadPool(threads);
|
||||
{
|
||||
Bukkit.getConsoleSender().sendMessage(PREFIX + ChatColor.GRAY + "Pool size is " + threads + " threads");
|
||||
}
|
||||
|
||||
// Check for ProtocolLib
|
||||
if (Bukkit.getPluginManager().getPlugin("ProtocolLib") == null) {
|
||||
Bukkit.getConsoleSender().sendMessage(PREFIX + ChatColor.RED
|
||||
+ "ProtocolLib not found! AntiCheatReloaded requires ProtocolLib to work, please download and install it.");
|
||||
Bukkit.getPluginManager().disablePlugin(this);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEnable() {
|
||||
manager = new AntiCheatManager(this, getLogger());
|
||||
|
||||
eventList.add(new PlayerListener());
|
||||
eventList.add(new BlockListener());
|
||||
eventList.add(new EntityListener());
|
||||
eventList.add(new VehicleListener());
|
||||
eventList.add(new InventoryListener());
|
||||
// Order is important in some cases, don't screw with these unless
|
||||
// needed, especially config
|
||||
setupConfig();
|
||||
setupEvents();
|
||||
setupCommands();
|
||||
// Enterprise must come before levels
|
||||
setupEnterprise();
|
||||
restoreLevels();
|
||||
// Setup ProtocolLib hooks
|
||||
setupProtocol();
|
||||
|
||||
Bukkit.getConsoleSender()
|
||||
.sendMessage(PREFIX + ChatColor.GRAY + "Running Minecraft version " + VersionLib.getVersion() + " "
|
||||
+ (VersionLib.isSupported() ? (ChatColor.GREEN + "(supported)")
|
||||
: (ChatColor.RED + "(NOT SUPPORTED!)")));
|
||||
|
||||
// Check for Floodgate
|
||||
if (Bukkit.getPluginManager().getPlugin("Floodgate") != null) {
|
||||
floodgateEnabled = true;
|
||||
Bukkit.getConsoleSender().sendMessage(PREFIX + ChatColor.WHITE + "Floodgate support enabled");
|
||||
}
|
||||
|
||||
// Create update manager
|
||||
updateManager = new UpdateManager();
|
||||
|
||||
// Launch TPS check
|
||||
new BukkitRunnable() {
|
||||
long second;
|
||||
long currentSecond;
|
||||
int ticks;
|
||||
|
||||
public void run() {
|
||||
second = (System.currentTimeMillis() / 1000L);
|
||||
if (currentSecond == second) {
|
||||
ticks += 1;
|
||||
} else {
|
||||
currentSecond = second;
|
||||
tps = (tps == 0.0D ? ticks : (tps + ticks) / 2.0D);
|
||||
ticks = 1;
|
||||
}
|
||||
|
||||
// Check for updates every 12 hours
|
||||
if (ticks % 864000 == 0) {
|
||||
updateManager.update();
|
||||
}
|
||||
}
|
||||
}.runTaskTimer(this, 40L, 1L);
|
||||
|
||||
// End tests
|
||||
verboseLog("Finished loading.");
|
||||
|
||||
// Metrics
|
||||
getServer().getScheduler().runTaskLater(this, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
final Metrics metrics = new Metrics(AntiCheatReloaded.this, 202);
|
||||
metrics.addCustomChart(new SingleLineChart("cheaters_kicked", new Callable<Integer>() {
|
||||
@Override
|
||||
public Integer call() throws Exception {
|
||||
final int kicked = playersKicked;
|
||||
// Reset so we don't keep sending the same value
|
||||
playersKicked = 0;
|
||||
return kicked;
|
||||
}
|
||||
}));
|
||||
metrics.addCustomChart(new SimplePie("protocollib_version", new Callable<String>() {
|
||||
@Override
|
||||
public String call() throws Exception {
|
||||
return Bukkit.getPluginManager().getPlugin("ProtocolLib").getDescription().getVersion();
|
||||
}
|
||||
}));
|
||||
metrics.addCustomChart(new SimplePie("nms_version", new Callable<String>() {
|
||||
@Override
|
||||
public String call() throws Exception {
|
||||
return VersionLib.getVersion();
|
||||
}
|
||||
}));
|
||||
metrics.addCustomChart(new SimplePie("floodgate_enabled", new Callable<String>() {
|
||||
@Override
|
||||
public String call() throws Exception {
|
||||
return floodgateEnabled ? "Yes" : "No";
|
||||
}
|
||||
}));
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}, 90L);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDisable() {
|
||||
// Cancel all running tasks
|
||||
getServer().getScheduler().cancelTasks(this);
|
||||
|
||||
// Shut down executor service
|
||||
executor.shutdown();
|
||||
|
||||
// Save user levels
|
||||
verboseLog("Saving user levels...");
|
||||
if (config != null) {
|
||||
config.getLevels().saveLevelsFromUsers(manager.getUserManager().getUsers());
|
||||
}
|
||||
|
||||
AntiCheatManager.close();
|
||||
cleanup();
|
||||
}
|
||||
|
||||
private void setupProtocol() {
|
||||
protocolManager = ProtocolLibrary.getProtocolManager();
|
||||
protocolManager.addPacketListener(new PacketListener(this));
|
||||
verboseLog("Hooked into ProtocolLib");
|
||||
}
|
||||
|
||||
private void setupEvents() {
|
||||
for (Listener listener : eventList) {
|
||||
getServer().getPluginManager().registerEvents(listener, this);
|
||||
verboseLog("Registered events for ".concat(listener.toString().split("@")[0].split(".anticheat.")[1]));
|
||||
}
|
||||
}
|
||||
|
||||
private void setupCommands() {
|
||||
getCommand("anticheat").setExecutor(new CommandHandler());
|
||||
verboseLog("Registered commands.");
|
||||
}
|
||||
|
||||
private void setupConfig() {
|
||||
config = manager.getConfiguration();
|
||||
verboseLog("Setup the config.");
|
||||
}
|
||||
|
||||
private void setupEnterprise() {
|
||||
if (config.getConfig().enterprise.getValue()) {
|
||||
if (config.getEnterprise().loggingEnabled.getValue()) {
|
||||
config.getEnterprise().database.cleanEvents();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void restoreLevels() {
|
||||
for (Player player : getServer().getOnlinePlayers()) {
|
||||
final UUID uuid = player.getUniqueId();
|
||||
|
||||
final User user = new User(uuid);
|
||||
user.setIsWaitingOnLevelSync(true);
|
||||
config.getLevels().loadLevelToUser(user);
|
||||
|
||||
manager.getUserManager().addUser(user);
|
||||
verboseLog("Data for " + uuid + " loaded");
|
||||
}
|
||||
}
|
||||
|
||||
public static String getVersion() {
|
||||
return manager.getPlugin().getDescription().getVersion();
|
||||
}
|
||||
|
||||
private void cleanup() {
|
||||
manager = null;
|
||||
plugin = null;
|
||||
eventList = null;
|
||||
config = null;
|
||||
protocolManager = null;
|
||||
updateManager = null;
|
||||
executor = null;
|
||||
}
|
||||
|
||||
public static void debugLog(final String string) {
|
||||
Bukkit.getScheduler().runTask(getPlugin(), new Runnable() {
|
||||
public void run() {
|
||||
if (getManager().getConfiguration().getConfig().debugMode.getValue()) {
|
||||
manager.debugLog("[DEBUG] " + string);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void verboseLog(final String string) {
|
||||
if (verbose) {
|
||||
getLogger().info(string);
|
||||
}
|
||||
}
|
||||
|
||||
public void setVerbose(boolean b) {
|
||||
verbose = b;
|
||||
}
|
||||
|
||||
/**
|
||||
* Amount of players kicked since start
|
||||
*/
|
||||
private int playersKicked = 0;
|
||||
|
||||
public void onPlayerKicked() {
|
||||
this.playersKicked++;
|
||||
}
|
||||
|
||||
public static void sendToMainThread(final Runnable runnable) {
|
||||
Bukkit.getScheduler().runTask(AntiCheatReloaded.getPlugin(), runnable);
|
||||
}
|
||||
|
||||
public void sendToStaff(final String message) {
|
||||
Bukkit.getOnlinePlayers().forEach(player -> {
|
||||
if (player.hasPermission("anticheat.system.alert")) {
|
||||
if (!MUTE_ENABLED_MODS.contains(player.getUniqueId())) {
|
||||
player.sendMessage(message);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public double getTPS() {
|
||||
return Math.min(Math.max(this.tps, 0.0D), 20.0D);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
/*
|
||||
* AntiCheat for Bukkit.
|
||||
* Copyright (C) 2012-2014 AntiCheat Team | http://gravitydevelopment.net
|
||||
* AntiCheatReloaded for Bukkit and Spigot.
|
||||
* Copyright (c) 2012-2015 AntiCheat Team
|
||||
* Copyright (c) 2016-2022 Rammelkast
|
||||
*
|
||||
* 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
|
||||
@@ -22,20 +23,17 @@ import java.util.List;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.rammelkast.anticheatreloaded.AntiCheat;
|
||||
import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
|
||||
import com.rammelkast.anticheatreloaded.check.CheckType;
|
||||
import com.rammelkast.anticheatreloaded.manage.AntiCheatManager;
|
||||
import com.rammelkast.anticheatreloaded.manage.CheckManager;
|
||||
import com.rammelkast.anticheatreloaded.manage.UserManager;
|
||||
import com.rammelkast.anticheatreloaded.util.Group;
|
||||
|
||||
/**
|
||||
* Developer's interface for all things AntiCheat.
|
||||
*/
|
||||
|
||||
public class AntiCheatAPI {
|
||||
private static CheckManager chk = AntiCheat.getManager().getCheckManager();
|
||||
private static UserManager umr = AntiCheat.getManager().getUserManager();
|
||||
public final class AntiCheatAPI {
|
||||
|
||||
private static final CheckManager CHECK_MANAGER = AntiCheatReloaded.getManager().getCheckManager();
|
||||
private static final UserManager USER_MANAGER = AntiCheatReloaded.getManager().getUserManager();
|
||||
|
||||
// CheckManager API
|
||||
|
||||
@@ -44,8 +42,8 @@ public class AntiCheatAPI {
|
||||
*
|
||||
* @param type Check to start watching for
|
||||
*/
|
||||
public static void activateCheck(CheckType type, Class caller) {
|
||||
chk.activateCheck(type, caller.getName());
|
||||
public static void activateCheck(final CheckType type, final Class<?> caller) {
|
||||
CHECK_MANAGER.activateCheck(type, caller.getName());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -53,8 +51,8 @@ public class AntiCheatAPI {
|
||||
*
|
||||
* @param type Check to stop watching for
|
||||
*/
|
||||
public static void deactivateCheck(CheckType type, Class caller) {
|
||||
chk.deactivateCheck(type, caller.getName());
|
||||
public static void deactivateCheck(final CheckType type, final Class<?> caller) {
|
||||
CHECK_MANAGER.deactivateCheck(type, caller.getName());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -63,8 +61,8 @@ public class AntiCheatAPI {
|
||||
* @param type Type to check
|
||||
* @return true if plugin is watching for this check
|
||||
*/
|
||||
public static boolean isActive(CheckType type) {
|
||||
return chk.isActive(type);
|
||||
public static boolean isActive(final CheckType type) {
|
||||
return CHECK_MANAGER.isActive(type);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -73,8 +71,8 @@ public class AntiCheatAPI {
|
||||
* @param player Player to stop watching
|
||||
* @param type Check to stop watching for
|
||||
*/
|
||||
public static void exemptPlayer(Player player, CheckType type, Class caller) {
|
||||
chk.exemptPlayer(player, type, caller.getName());
|
||||
public static void exemptPlayer(final Player player, final CheckType type, final Class<?> caller) {
|
||||
CHECK_MANAGER.exemptPlayer(player, type, caller.getName());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -83,8 +81,8 @@ public class AntiCheatAPI {
|
||||
* @param player Player to start watching
|
||||
* @param type Check to start watching for
|
||||
*/
|
||||
public static void unexemptPlayer(Player player, CheckType type, Class caller) {
|
||||
chk.unexemptPlayer(player, type, caller.getName());
|
||||
public static void unexemptPlayer(final Player player, final CheckType type, final Class<?> caller) {
|
||||
CHECK_MANAGER.unexemptPlayer(player, type, caller.getName());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -94,8 +92,8 @@ public class AntiCheatAPI {
|
||||
* @param type Type to check
|
||||
* @return true if plugin is ignoring this check on this player
|
||||
*/
|
||||
public static boolean isExempt(Player player, CheckType type) {
|
||||
return chk.isExempt(player, type);
|
||||
public static boolean isExempt(final Player player, final CheckType type) {
|
||||
return CHECK_MANAGER.isExempt(player, type);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -105,44 +103,19 @@ public class AntiCheatAPI {
|
||||
* @param type Type to check
|
||||
* @return true if plugin will check this player, and that all things allow it to happen.
|
||||
*/
|
||||
public boolean willCheck(Player player, CheckType type) {
|
||||
return chk.willCheck(player, type);
|
||||
public boolean willCheck(final Player player, final CheckType type) {
|
||||
return CHECK_MANAGER.willCheck(player, type);
|
||||
}
|
||||
|
||||
// PlayerManager API
|
||||
|
||||
/**
|
||||
* Get a player's integer hack level
|
||||
*
|
||||
* @param player Player to check
|
||||
* @return player's hack level
|
||||
* @deprecated see {@link #getGroup(org.bukkit.entity.Player)}
|
||||
*/
|
||||
@Deprecated
|
||||
public static int getLevel(Player player) {
|
||||
return umr.safeGetLevel(player.getUniqueId());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set a player's hack level
|
||||
*
|
||||
* @param player Player to set
|
||||
* @param level Group to set to
|
||||
* @deprecated see {@link #resetPlayer(org.bukkit.entity.Player)}
|
||||
*/
|
||||
@Deprecated
|
||||
public static void setLevel(Player player, int level) {
|
||||
umr.safeSetLevel(player.getUniqueId(), level);
|
||||
}
|
||||
|
||||
/**
|
||||
* Reset a player's hack level to 0
|
||||
*
|
||||
* @param player Player to reset
|
||||
*/
|
||||
public static void resetPlayer(Player player) {
|
||||
umr.getUser(player.getUniqueId()).resetLevel();
|
||||
public static void resetPlayer(final Player player) {
|
||||
USER_MANAGER.getUser(player.getUniqueId()).resetLevel();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -151,8 +124,8 @@ public class AntiCheatAPI {
|
||||
* @param player Player whose group to find
|
||||
* @return The player's group
|
||||
*/
|
||||
public static Group getGroup(Player player) {
|
||||
return umr.getUser(player.getUniqueId()).getGroup();
|
||||
public static Group getGroup(final Player player) {
|
||||
return USER_MANAGER.getUser(player.getUniqueId()).getGroup();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -173,8 +146,7 @@ public class AntiCheatAPI {
|
||||
* @return the AntiCheat Manager
|
||||
*/
|
||||
public static AntiCheatManager getManager() {
|
||||
return AntiCheat.getManager();
|
||||
return AntiCheatReloaded.getManager();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
+11
-7
@@ -1,6 +1,7 @@
|
||||
/*
|
||||
* AntiCheat for Bukkit.
|
||||
* Copyright (C) 2012-2014 AntiCheat Team | http://gravitydevelopment.net
|
||||
* AntiCheatReloaded for Bukkit and Spigot.
|
||||
* Copyright (c) 2012-2015 AntiCheat Team
|
||||
* Copyright (c) 2016-2022 Rammelkast
|
||||
*
|
||||
* 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
|
||||
@@ -16,7 +17,7 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.rammelkast.anticheatreloaded.api;
|
||||
package com.rammelkast.anticheatreloaded.api.event;
|
||||
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.HandlerList;
|
||||
@@ -25,17 +26,16 @@ import com.rammelkast.anticheatreloaded.check.CheckType;
|
||||
import com.rammelkast.anticheatreloaded.util.User;
|
||||
|
||||
/**
|
||||
* Fired when a player fails an AntiCheat check
|
||||
* Fired when a player fails an AntiCheatReloaded check
|
||||
*/
|
||||
|
||||
public class CheckFailEvent extends Event {
|
||||
public final class CheckFailEvent extends Event {
|
||||
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
|
||||
private final User user;
|
||||
private final CheckType type;
|
||||
|
||||
public CheckFailEvent(User user, CheckType type) {
|
||||
public CheckFailEvent(final User user, final CheckType type) {
|
||||
this.user = user;
|
||||
this.type = type;
|
||||
}
|
||||
@@ -61,5 +61,9 @@ public class CheckFailEvent extends Event {
|
||||
public HandlerList getHandlers() {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
public static HandlerList getHandlerList() {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,83 @@
|
||||
/*
|
||||
* AntiCheatReloaded for Bukkit and Spigot.
|
||||
* Copyright (c) 2012-2015 AntiCheat Team
|
||||
* Copyright (c) 2016-2022 Rammelkast
|
||||
*
|
||||
* 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 3 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, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.rammelkast.anticheatreloaded.api.event;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.event.Cancellable;
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.HandlerList;
|
||||
|
||||
import com.rammelkast.anticheatreloaded.util.User;
|
||||
|
||||
/**
|
||||
* Fired when a player is punished by AntiCheatReloaded
|
||||
*/
|
||||
public final class PlayerPunishEvent extends Event implements Cancellable {
|
||||
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
|
||||
private final User user;
|
||||
private final List<String> actions;
|
||||
|
||||
private boolean cancelled;
|
||||
|
||||
public PlayerPunishEvent(final User user, final List<String> actions) {
|
||||
this.user = user;
|
||||
this.actions = actions;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the {@link com.rammelkast.anticheatreloaded.util.User} who will be
|
||||
* punished
|
||||
*
|
||||
* @return a {@link com.rammelkast.anticheatreloaded.util.User}
|
||||
*/
|
||||
public User getUser() {
|
||||
return user;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the list of actions the punishment will perform
|
||||
*
|
||||
* @return a a list of punishment strings
|
||||
*/
|
||||
public List<String> getActions() {
|
||||
return actions;
|
||||
}
|
||||
|
||||
public HandlerList getHandlers() {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
public static HandlerList getHandlerList() {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCancelled() {
|
||||
return cancelled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCancelled(boolean cancel) {
|
||||
this.cancelled = cancel;
|
||||
}
|
||||
|
||||
}
|
||||
File diff suppressed because it is too large.
Load diff
@@ -1,6 +1,7 @@
|
||||
/*
|
||||
* AntiCheat for Bukkit.
|
||||
* Copyright (C) 2012-2014 AntiCheat Team | http://gravitydevelopment.net
|
||||
* AntiCheatReloaded for Bukkit and Spigot.
|
||||
* Copyright (c) 2012-2015 AntiCheat Team
|
||||
* Copyright (c) 2016-2022 Rammelkast
|
||||
*
|
||||
* 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
|
||||
@@ -25,6 +26,7 @@ public class CheckResult {
|
||||
}
|
||||
|
||||
private Result result;
|
||||
private String subCheck;
|
||||
private String message;
|
||||
private int data;
|
||||
|
||||
@@ -33,6 +35,12 @@ public class CheckResult {
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
public CheckResult(Result result, String subcheck, String message) {
|
||||
this(result);
|
||||
this.subCheck = subcheck;
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
public CheckResult(Result result, String message) {
|
||||
this(result);
|
||||
this.message = message;
|
||||
@@ -45,11 +53,15 @@ public class CheckResult {
|
||||
public boolean failed() {
|
||||
return result == Result.FAILED;
|
||||
}
|
||||
|
||||
public String getSubCheck() {
|
||||
return subCheck;
|
||||
}
|
||||
|
||||
public String getMessage() {
|
||||
return message;
|
||||
}
|
||||
|
||||
|
||||
public Result getResult() {
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
/*
|
||||
* AntiCheat for Bukkit.
|
||||
* Copyright (C) 2012-2014 AntiCheat Team | http://gravitydevelopment.net
|
||||
* AntiCheatReloaded for Bukkit and Spigot.
|
||||
* Copyright (c) 2012-2015 AntiCheat Team
|
||||
* Copyright (c) 2016-2022 Rammelkast
|
||||
*
|
||||
* 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
|
||||
@@ -18,63 +19,66 @@
|
||||
|
||||
package com.rammelkast.anticheatreloaded.check;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.rammelkast.anticheatreloaded.api.CheckFailEvent;
|
||||
import com.rammelkast.anticheatreloaded.util.Permission;
|
||||
import com.rammelkast.anticheatreloaded.util.User;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.rammelkast.anticheatreloaded.api.event.CheckFailEvent;
|
||||
import com.rammelkast.anticheatreloaded.util.Permission;
|
||||
import com.rammelkast.anticheatreloaded.util.User;
|
||||
|
||||
/**
|
||||
* <p/>
|
||||
* All the types of checks and their corresponding permission nodes.
|
||||
*/
|
||||
|
||||
public enum CheckType {
|
||||
ZOMBE_FLY(Permission.CHECK_ZOMBE_FLY),
|
||||
ZOMBE_NOCLIP(Permission.CHECK_ZOMBE_NOCLIP),
|
||||
ZOMBE_CHEAT(Permission.CHECK_ZOMBE_CHEAT),
|
||||
FLY(Permission.CHECK_FLY),
|
||||
WATER_WALK(Permission.CHECK_WATERWALK),
|
||||
NO_SWING(Permission.CHECK_NOSWING),
|
||||
FAST_BREAK(Permission.CHECK_FASTBREAK),
|
||||
FAST_PLACE(Permission.CHECK_FASTPLACE),
|
||||
CHAT_SPAM(Permission.CHECK_CHATSPAM),
|
||||
COMMAND_SPAM(Permission.CHECK_COMMANDSPAM),
|
||||
SPRINT(Permission.CHECK_SPRINT),
|
||||
SNEAK(Permission.CHECK_SNEAK),
|
||||
SPEED(Permission.CHECK_SPEED),
|
||||
VCLIP(Permission.CHECK_VCLIP),
|
||||
SPIDER(Permission.CHECK_SPIDER),
|
||||
NOFALL(Permission.CHECK_NOFALL),
|
||||
FAST_BOW(Permission.CHECK_FASTBOW),
|
||||
FAST_EAT(Permission.CHECK_FASTEAT),
|
||||
FAST_HEAL(Permission.CHECK_FASTHEAL),
|
||||
FORCEFIELD(Permission.CHECK_FORCEFIELD),
|
||||
LONG_REACH(Permission.CHECK_LONGREACH),
|
||||
FAST_PROJECTILE(Permission.CHECK_FASTPROJECTILE),
|
||||
ITEM_SPAM(Permission.CHECK_ITEMSPAM),
|
||||
FAST_INVENTORY(Permission.CHECK_FASTINVENTORY),
|
||||
AUTOTOOL(Permission.CHECK_AUTOTOOL),
|
||||
KILLAURA(Permission.CHECK_KILLAURA),
|
||||
BLINK(Permission.CHECK_BLINK),
|
||||
VELOCITY(Permission.VELOCITY),
|
||||
CRITICALS(Permission.CRITICALS);
|
||||
|
||||
FLIGHT(Permission.CHECK_FLIGHT, "Flight"),
|
||||
ELYTRAFLY(Permission.CHECK_ELYTRAFLY, "ElytraFly"),
|
||||
WATER_WALK(Permission.CHECK_WATERWALK, "WaterWalk"),
|
||||
FAST_PLACE(Permission.CHECK_FASTPLACE, "FastPlace"),
|
||||
CHAT_SPAM(Permission.CHECK_CHATSPAM, "ChatSpam"),
|
||||
COMMAND_SPAM(Permission.CHECK_COMMANDSPAM, "CommandSpam"),
|
||||
SPRINT(Permission.CHECK_SPRINT, "Sprint"),
|
||||
SNEAK(Permission.CHECK_SNEAK, "Sneak"),
|
||||
SPEED(Permission.CHECK_SPEED, "Speed"),
|
||||
VCLIP(Permission.CHECK_VCLIP, "vClip"),
|
||||
SPIDER(Permission.CHECK_SPIDER, "Spider"),
|
||||
NOFALL(Permission.CHECK_NOFALL, "NoFall"),
|
||||
FAST_BOW(Permission.CHECK_FASTBOW, "FastBow"),
|
||||
FAST_EAT(Permission.CHECK_FASTEAT, "FastEat"),
|
||||
FAST_HEAL(Permission.CHECK_FASTHEAL, "FastHeal"),
|
||||
KILLAURA(Permission.CHECK_KILLAURA, "KillAura"),
|
||||
FAST_PROJECTILE(Permission.CHECK_FASTPROJECTILE, "FastProjectile"),
|
||||
ITEM_SPAM(Permission.CHECK_ITEMSPAM, "ItemSpam"),
|
||||
FAST_INVENTORY(Permission.CHECK_FASTINVENTORY, "FastInventory"),
|
||||
MOREPACKETS(Permission.CHECK_MOREPACKETS, "MorePackets"),
|
||||
BADPACKETS(Permission.CHECK_BADPACKETS, "BadPackets"),
|
||||
VELOCITY(Permission.CHECK_VELOCITY, "Velocity"),
|
||||
CRITICALS(Permission.CHECK_CRITICALS, "Criticals"),
|
||||
CHAT_UNICODE(Permission.CHECK_UNICODE, "ChatUnicode"),
|
||||
ILLEGAL_INTERACT(Permission.CHECK_ILLEGALINTERACT, "IllegalInteract"),
|
||||
FASTLADDER(Permission.CHECK_FASTLADDER, "FastLadder"),
|
||||
AIMBOT(Permission.CHECK_AIMBOT, "Aimbot"),
|
||||
STRAFE(Permission.CHECK_STRAFE, "Strafe"),
|
||||
NOSLOW(Permission.CHECK_NOSLOW, "NoSlow"),
|
||||
BOATFLY(Permission.CHECK_BOATFLY, "BoatFly");
|
||||
|
||||
private final Permission permission;
|
||||
private final String displayName;
|
||||
private final Map<UUID, Integer> level = new HashMap<UUID, Integer>();
|
||||
|
||||
/**
|
||||
* Initialize a CheckType
|
||||
*
|
||||
* @param perm Permission that applies to this check
|
||||
* @param permission Permission that applies to this check
|
||||
* @peram displayName The chat display name
|
||||
*/
|
||||
private CheckType(Permission perm) {
|
||||
this.permission = perm;
|
||||
private CheckType(Permission permission, String displayName) {
|
||||
this.permission = permission;
|
||||
this.displayName = displayName;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -120,12 +124,9 @@ public enum CheckType {
|
||||
/**
|
||||
* Get the reference name of a check
|
||||
*
|
||||
* @param type Type of check
|
||||
* @return reference name
|
||||
*/
|
||||
public static String getName(CheckType type) {
|
||||
char[] chars = type.toString().replaceAll("_", " ").toLowerCase().toCharArray();
|
||||
chars[0] = Character.toUpperCase(chars[0]);
|
||||
return new String(chars);
|
||||
public String getName() {
|
||||
return this.displayName;
|
||||
}
|
||||
}
|
||||
@@ -1,3 +1,21 @@
|
||||
/*
|
||||
* AntiCheatReloaded for Bukkit and Spigot.
|
||||
* Copyright (c) 2012-2015 AntiCheat Team
|
||||
* Copyright (c) 2016-2022 Rammelkast
|
||||
*
|
||||
* 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 3 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, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.rammelkast.anticheatreloaded.check.combat;
|
||||
|
||||
import org.bukkit.Material;
|
||||
@@ -11,22 +29,31 @@ import com.rammelkast.anticheatreloaded.check.CheckType;
|
||||
import com.rammelkast.anticheatreloaded.event.EventListener;
|
||||
import com.rammelkast.anticheatreloaded.util.Utilities;
|
||||
|
||||
public class CriticalsCheck {
|
||||
public final class CriticalsCheck {
|
||||
|
||||
public static void doDamageEvent(EntityDamageByEntityEvent e, Player damager) {
|
||||
if (!(e.getDamager() instanceof Player) || e.getCause() != DamageCause.ENTITY_ATTACK)
|
||||
public static void doDamageEvent(final EntityDamageByEntityEvent event, final Player damager) {
|
||||
if (!(event.getDamager() instanceof Player) || event.getCause() != DamageCause.ENTITY_ATTACK) {
|
||||
return;
|
||||
Player p = (Player)e.getDamager();
|
||||
if (isCritical(p)) {
|
||||
if ((p.getLocation().getY() % 1.0 == 0 || p.getLocation().getY() % 0.5 == 0) && p.getLocation().clone().subtract(0, 1.0, 0).getBlock().getType().isSolid()) {
|
||||
e.setCancelled(true);
|
||||
EventListener.log(new CheckResult(CheckResult.Result.FAILED, p.getName() + " failed Criticals, tried to do a critical without needed conditions").getMessage(), p, CheckType.CRITICALS);
|
||||
}
|
||||
final Player player = (Player) event.getDamager();
|
||||
if (isCritical(player)) {
|
||||
if ((player.getLocation().getY() % 1.0 == 0 || player.getLocation().getY() % 0.5 == 0)
|
||||
&& player.getLocation().clone().subtract(0, 1.0, 0).getBlock().getType().isSolid()) {
|
||||
event.setCancelled(true);
|
||||
EventListener.log(
|
||||
new CheckResult(CheckResult.Result.FAILED, "tried to do a critical without needed conditions")
|
||||
.getMessage(),
|
||||
player, CheckType.CRITICALS, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean isCritical(Player player) {
|
||||
return player.getFallDistance() > 0.0f && !player.isOnGround() && !player.isInsideVehicle() && !player.hasPotionEffect(PotionEffectType.BLINDNESS) && !Utilities.isHoveringOverWater(player.getLocation()) && player.getEyeLocation().getBlock().getType() != Material.LADDER;
|
||||
@SuppressWarnings("deprecation")
|
||||
private static boolean isCritical(final Player player) {
|
||||
return player.getFallDistance() > 0.0f && !player.isOnGround() && !player.isInsideVehicle()
|
||||
&& !player.hasPotionEffect(PotionEffectType.BLINDNESS)
|
||||
&& !Utilities.isHoveringOverWater(player.getLocation())
|
||||
&& player.getEyeLocation().getBlock().getType() != Material.LADDER;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,90 +1,320 @@
|
||||
package com.rammelkast.anticheatreloaded.check.combat;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||
import org.bukkit.event.player.PlayerMoveEvent;
|
||||
|
||||
import com.comphenix.protocol.PacketType;
|
||||
import com.comphenix.protocol.events.ListenerPriority;
|
||||
import com.comphenix.protocol.events.PacketAdapter;
|
||||
import com.comphenix.protocol.events.PacketEvent;
|
||||
import com.rammelkast.anticheatreloaded.AntiCheat;
|
||||
import com.rammelkast.anticheatreloaded.check.CheckResult;
|
||||
import com.rammelkast.anticheatreloaded.check.CheckType;
|
||||
import com.rammelkast.anticheatreloaded.event.EventListener;
|
||||
import com.rammelkast.anticheatreloaded.util.NPC_1_11;
|
||||
import com.rammelkast.anticheatreloaded.util.VersionUtil;
|
||||
|
||||
/**
|
||||
* @author Rammelkast
|
||||
*/
|
||||
public class KillAuraCheck {
|
||||
|
||||
private static final Map<UUID, NPC_1_11> NPC_LIST = new HashMap<UUID, NPC_1_11>();
|
||||
private static final Map<UUID, Integer> VL_COUNT = new HashMap<UUID, Integer>();
|
||||
|
||||
public static void cleanPlayer(Player p) {
|
||||
if (!VersionUtil.getVersion().equals("v1_11_R1")) {
|
||||
return;
|
||||
}
|
||||
NPC_LIST.remove(p.getUniqueId());
|
||||
}
|
||||
|
||||
public static void listenPackets() {
|
||||
if (!VersionUtil.getVersion().equals("v1_11_R1")) {
|
||||
return;
|
||||
}
|
||||
AntiCheat.getProtocolManager().addPacketListener(new PacketAdapter(AntiCheat.getPlugin(), ListenerPriority.NORMAL, new PacketType[] {PacketType.Play.Client.USE_ENTITY}) {
|
||||
@Override
|
||||
public void onPacketReceiving(PacketEvent e) {
|
||||
Player p = e.getPlayer();
|
||||
if (!NPC_LIST.containsKey(p.getUniqueId()))
|
||||
return;
|
||||
int id = e.getPacket().getIntegers().read(0);
|
||||
if (NPC_LIST.containsKey(p.getUniqueId())) {
|
||||
if (NPC_LIST.get(p.getUniqueId()).getID() != id) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (!VL_COUNT.containsKey(p.getUniqueId())) {
|
||||
VL_COUNT.put(p.getUniqueId(), 1);
|
||||
NPC_LIST.get(p.getUniqueId()).damage();
|
||||
}else {
|
||||
VL_COUNT.put(p.getUniqueId(), VL_COUNT.get(p.getUniqueId()) + 1);
|
||||
if (VL_COUNT.get(p.getUniqueId()) >= 5) {
|
||||
EventListener.log(new CheckResult(CheckResult.Result.FAILED, p.getName() + " failed KillAura (botcheck), hit the bot " + VL_COUNT.get(p.getUniqueId()) + " times (max=5)").getMessage(), p, CheckType.KILLAURA);
|
||||
AntiCheat.getPlugin().onKillAuraViolation();
|
||||
VL_COUNT.remove(p.getUniqueId());
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public static void doDamageEvent(EntityDamageByEntityEvent e, Player p) {
|
||||
if (!VersionUtil.getVersion().equals("v1_11_R1")) {
|
||||
return;
|
||||
}
|
||||
if (NPC_LIST.containsKey(p.getUniqueId()))
|
||||
NPC_LIST.get(p.getUniqueId()).damage(e, p);
|
||||
else {
|
||||
NPC_1_11 npc = new NPC_1_11(p);
|
||||
NPC_LIST.put(p.getUniqueId(), npc);
|
||||
npc.spawn();
|
||||
}
|
||||
}
|
||||
|
||||
public static void doMove(PlayerMoveEvent e) {
|
||||
if (!VersionUtil.getVersion().equals("v1_11_R1")) {
|
||||
return;
|
||||
}
|
||||
if (NPC_LIST.containsKey(e.getPlayer().getUniqueId())) {
|
||||
NPC_LIST.get(e.getPlayer().getUniqueId()).move(e);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
/*
|
||||
* AntiCheatReloaded for Bukkit and Spigot.
|
||||
* Copyright (c) 2012-2015 AntiCheat Team
|
||||
* Copyright (c) 2016-2022 Rammelkast
|
||||
*
|
||||
* 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 3 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, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.rammelkast.anticheatreloaded.check.combat;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.bukkit.FluidCollisionMode;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.entity.EntityDamageEvent;
|
||||
import org.bukkit.util.RayTraceResult;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import com.google.common.collect.EvictingQueue;
|
||||
import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
|
||||
import com.rammelkast.anticheatreloaded.check.CheckResult;
|
||||
import com.rammelkast.anticheatreloaded.check.CheckResult.Result;
|
||||
import com.rammelkast.anticheatreloaded.check.CheckType;
|
||||
import com.rammelkast.anticheatreloaded.config.providers.Checks;
|
||||
import com.rammelkast.anticheatreloaded.util.MinecraftVersion;
|
||||
import com.rammelkast.anticheatreloaded.util.MovementManager;
|
||||
import com.rammelkast.anticheatreloaded.util.User;
|
||||
import com.rammelkast.anticheatreloaded.util.Utilities;
|
||||
import com.rammelkast.anticheatreloaded.util.VersionLib;
|
||||
|
||||
public final class KillAuraCheck {
|
||||
|
||||
// Angle check
|
||||
public static final Map<UUID, Integer> ANGLE_FLAGS = new HashMap<UUID, Integer>();
|
||||
|
||||
// PacketOrder check
|
||||
public static final Map<UUID, Integer> PACKETORDER_FLAGS = new HashMap<UUID, Integer>();
|
||||
|
||||
// ThroughWalls check
|
||||
public static final Map<UUID, Integer> THROUGHWALLS_FLAGS = new HashMap<UUID, Integer>();
|
||||
private static final double RAY_LENGTH = 4.5;
|
||||
|
||||
// Variance check
|
||||
public static final Map<UUID, EvictingQueue<Float>> FACTOR_MAP = new HashMap<UUID, EvictingQueue<Float>>();
|
||||
|
||||
private static final CheckResult PASS = new CheckResult(CheckResult.Result.PASSED);
|
||||
|
||||
public static CheckResult checkReach(final Player player, final Entity target) {
|
||||
if (!(target instanceof LivingEntity) || player.getVehicle() != null || target.getVehicle() != null) {
|
||||
return PASS;
|
||||
}
|
||||
|
||||
final User user = AntiCheatReloaded.getManager().getUserManager().getUser(player.getUniqueId());
|
||||
final Checks checksConfig = AntiCheatReloaded.getManager().getConfiguration().getChecks();
|
||||
|
||||
// Check if enabled
|
||||
if (!checksConfig.isSubcheckEnabled(CheckType.KILLAURA, "reach")) {
|
||||
return PASS;
|
||||
}
|
||||
|
||||
double allowedReach = target.getVelocity().length() < 0.08
|
||||
? checksConfig.getDouble(CheckType.KILLAURA, "reach", "baseMaxValue.normal")
|
||||
: checksConfig.getDouble(CheckType.KILLAURA, "reach", "baseMaxValue.velocitized");
|
||||
if (player.getGameMode() == GameMode.CREATIVE) {
|
||||
allowedReach += 1.5D;
|
||||
}
|
||||
// Lag compensation
|
||||
final double lagExtraReach = checksConfig.getDouble(CheckType.KILLAURA, "reach",
|
||||
"lagCompensation.lagExtraReach");
|
||||
final double pingCompensation = checksConfig.getDouble(CheckType.KILLAURA, "reach",
|
||||
"lagCompensation.pingCompensation");
|
||||
allowedReach += user.getPing() * pingCompensation;
|
||||
if (user.isLagging()) {
|
||||
allowedReach += lagExtraReach;
|
||||
}
|
||||
if (target instanceof Player) {
|
||||
final User targetUser = AntiCheatReloaded.getManager().getUserManager().getUser(target.getUniqueId());
|
||||
allowedReach += targetUser.getPing() * pingCompensation;
|
||||
if (targetUser.isLagging()) {
|
||||
allowedReach += lagExtraReach;
|
||||
}
|
||||
}
|
||||
// Velocity compensation
|
||||
final double velocityMultiplier = checksConfig.getDouble(CheckType.KILLAURA, "reach", "velocityMultiplier");
|
||||
allowedReach += Math.abs(target.getVelocity().length()) * velocityMultiplier;
|
||||
final double reachedDistance = Utilities.roundDouble(
|
||||
((LivingEntity) target).getLocation().toVector().distance(player.getLocation().toVector()), 2);
|
||||
if (reachedDistance > Utilities.roundDouble(allowedReach, 2)) {
|
||||
return new CheckResult(CheckResult.Result.FAILED, "Reach", "reached too far (distance=" + reachedDistance
|
||||
+ ", max=" + Utilities.roundDouble(allowedReach, 2) + ")");
|
||||
}
|
||||
return PASS;
|
||||
}
|
||||
|
||||
public static CheckResult checkAngle(final Player player, final EntityDamageEvent event) {
|
||||
final UUID uuid = player.getUniqueId();
|
||||
final Entity entity = event.getEntity();
|
||||
|
||||
// Do not check while in vehicles
|
||||
if (player.getVehicle() != null || entity.getVehicle() != null || VersionLib.isRiptiding(player)) {
|
||||
return PASS;
|
||||
}
|
||||
|
||||
final Checks checksConfig = AntiCheatReloaded.getManager().getConfiguration().getChecks();
|
||||
|
||||
// Check if enabled
|
||||
if (!checksConfig.isSubcheckEnabled(CheckType.KILLAURA, "angle")) {
|
||||
return PASS;
|
||||
}
|
||||
|
||||
if (entity instanceof LivingEntity) {
|
||||
final LivingEntity living = (LivingEntity) entity;
|
||||
final Location eyeLocation = player.getEyeLocation();
|
||||
|
||||
final double yawDifference = calculateYawDifference(eyeLocation, living.getLocation());
|
||||
final double playerYaw = player.getEyeLocation().getYaw();
|
||||
|
||||
final double angleDifference = Math.abs(180 - Math.abs(Math.abs(yawDifference - playerYaw) - 180));
|
||||
final int maxDifference = checksConfig.getInteger(CheckType.KILLAURA, "angle", "maxDifference");
|
||||
if (Math.round(angleDifference) > maxDifference) {
|
||||
if (!ANGLE_FLAGS.containsKey(uuid)) {
|
||||
ANGLE_FLAGS.put(uuid, 1);
|
||||
return PASS;
|
||||
}
|
||||
|
||||
int flags = ANGLE_FLAGS.get(uuid);
|
||||
int vlBeforeFlag = checksConfig.getInteger(CheckType.KILLAURA, "angle", "vlBeforeFlag");
|
||||
if (flags >= vlBeforeFlag) {
|
||||
ANGLE_FLAGS.remove(uuid);
|
||||
return new CheckResult(CheckResult.Result.FAILED, "Angle",
|
||||
"tried to attack from an illegal angle (angle=" + Math.round(angleDifference) + ")");
|
||||
}
|
||||
|
||||
ANGLE_FLAGS.put(uuid, flags + 1);
|
||||
}
|
||||
}
|
||||
return PASS;
|
||||
}
|
||||
|
||||
public static CheckResult checkPacketOrder(final Player player, final Entity entity) {
|
||||
final UUID uuid = player.getUniqueId();
|
||||
final User user = AntiCheatReloaded.getManager().getUserManager().getUser(uuid);
|
||||
final MovementManager movementManager = user.getMovementManager();
|
||||
final Checks checksConfig = AntiCheatReloaded.getManager().getConfiguration().getChecks();
|
||||
|
||||
// Check if enabled
|
||||
if (!checksConfig.isSubcheckEnabled(CheckType.KILLAURA, "packetOrder")) {
|
||||
return PASS;
|
||||
}
|
||||
|
||||
if (user.isLagging() || (System.currentTimeMillis() - movementManager.lastTeleport) <= 100 || AntiCheatReloaded
|
||||
.getPlugin().getTPS() < checksConfig.getDouble(CheckType.KILLAURA, "packetOrder", "minimumTps")) {
|
||||
return PASS;
|
||||
}
|
||||
|
||||
final long elapsed = System.currentTimeMillis() - movementManager.lastUpdate;
|
||||
if (elapsed < checksConfig.getInteger(CheckType.KILLAURA, "packetOrder", "minElapsedTime")) {
|
||||
if (!PACKETORDER_FLAGS.containsKey(uuid)) {
|
||||
PACKETORDER_FLAGS.put(uuid, 1);
|
||||
return PASS;
|
||||
}
|
||||
|
||||
int flags = PACKETORDER_FLAGS.get(uuid);
|
||||
int vlBeforeFlag = checksConfig.getInteger(CheckType.KILLAURA, "packetOrder", "vlBeforeFlag");
|
||||
if (flags >= vlBeforeFlag) {
|
||||
PACKETORDER_FLAGS.remove(uuid);
|
||||
return new CheckResult(Result.FAILED, "PacketOrder",
|
||||
"suspicious packet order (elapsed=" + elapsed + ")");
|
||||
}
|
||||
|
||||
PACKETORDER_FLAGS.put(uuid, flags + 1);
|
||||
}
|
||||
return PASS;
|
||||
}
|
||||
|
||||
public static CheckResult checkVariance(final Player player) {
|
||||
final UUID uuid = player.getUniqueId();
|
||||
final User user = AntiCheatReloaded.getManager().getUserManager().getUser(uuid);
|
||||
final MovementManager movementManager = user.getMovementManager();
|
||||
final Checks checksConfig = AntiCheatReloaded.getManager().getConfiguration().getChecks();
|
||||
|
||||
// Check if enabled
|
||||
if (!checksConfig.isSubcheckEnabled(CheckType.KILLAURA, "variance")) {
|
||||
return PASS;
|
||||
}
|
||||
|
||||
final int samples = checksConfig.getInteger(CheckType.KILLAURA, "variance", "samples");
|
||||
if (movementManager.deltaPitch > 0.0f && movementManager.lastDeltaPitch > 0.0f
|
||||
&& movementManager.deltaYaw > 5.0f) {
|
||||
final float factor = movementManager.deltaPitch % movementManager.lastDeltaPitch;
|
||||
final EvictingQueue<Float> queue = FACTOR_MAP.getOrDefault(uuid, EvictingQueue.create(samples));
|
||||
queue.add(factor);
|
||||
if (queue.size() >= samples) {
|
||||
final double variance = Utilities.getVariance(queue);
|
||||
if (variance < 0.25) {
|
||||
FACTOR_MAP.put(uuid, queue);
|
||||
return new CheckResult(Result.FAILED, "Variance",
|
||||
"had suspicous aim behaviour (variance: " + Utilities.roundDouble(variance, 3) + ")");
|
||||
}
|
||||
}
|
||||
FACTOR_MAP.put(uuid, queue);
|
||||
}
|
||||
|
||||
return PASS;
|
||||
}
|
||||
|
||||
public static CheckResult checkRepeatedAim(final Player player) {
|
||||
final UUID uuid = player.getUniqueId();
|
||||
final User user = AntiCheatReloaded.getManager().getUserManager().getUser(uuid);
|
||||
final MovementManager movementManager = user.getMovementManager();
|
||||
final Checks checksConfig = AntiCheatReloaded.getManager().getConfiguration().getChecks();
|
||||
|
||||
// Check if enabled
|
||||
if (!checksConfig.isSubcheckEnabled(CheckType.KILLAURA, "repeatedAim")) {
|
||||
return PASS;
|
||||
}
|
||||
|
||||
final float deltaYaw = movementManager.deltaYaw;
|
||||
final float lastDeltaYaw = movementManager.lastDeltaYaw;
|
||||
final float deltaPitch = movementManager.deltaPitch;
|
||||
final float lastDeltaPitch = movementManager.lastDeltaPitch;
|
||||
if (deltaYaw > 0.0f && Math.abs(deltaYaw - lastDeltaYaw) < 1e-5 && deltaPitch > 10.0f) {
|
||||
return new CheckResult(Result.FAILED, "RepeatedAim",
|
||||
"repeated aim pattern (type=yaw, deltaPitch=" + Utilities.roundFloat(deltaPitch, 1) + ")");
|
||||
} else if (deltaPitch > 0.0f && Math.abs(deltaPitch - lastDeltaPitch) < 1e-5 && deltaYaw > 12.0f) {
|
||||
return new CheckResult(Result.FAILED, "RepeatedAim",
|
||||
"repeated aim pattern (type=pitch, deltaYaw=" + Utilities.roundFloat(deltaYaw, 1) + ")");
|
||||
}
|
||||
return PASS;
|
||||
}
|
||||
|
||||
public static CheckResult checkThroughWalls(final Player player, final Entity target) {
|
||||
// TODO this does not work on 1.12.2
|
||||
// Either we finally drop 1.12.2 as well, or we create a workaround
|
||||
// For now we just skip if server version is 1.12.2
|
||||
if (MinecraftVersion.getCurrentVersion().getMinor() <= 12) {
|
||||
return PASS;
|
||||
}
|
||||
|
||||
final UUID uuid = player.getUniqueId();
|
||||
final User user = AntiCheatReloaded.getManager().getUserManager().getUser(uuid);
|
||||
final MovementManager movementManager = user.getMovementManager();
|
||||
final Checks checksConfig = AntiCheatReloaded.getManager().getConfiguration().getChecks();
|
||||
|
||||
// Check if enabled
|
||||
if (!checksConfig.isSubcheckEnabled(CheckType.KILLAURA, "throughWalls")) {
|
||||
return PASS;
|
||||
}
|
||||
|
||||
if ((user.isLagging() && checksConfig.getBoolean(CheckType.KILLAURA, "throughWalls", "disableForLagging"))
|
||||
|| (System.currentTimeMillis() - movementManager.lastTeleport) <= 100 || AntiCheatReloaded.getPlugin()
|
||||
.getTPS() < checksConfig.getDouble(CheckType.KILLAURA, "throughWalls", "minimumTps")) {
|
||||
return PASS;
|
||||
}
|
||||
|
||||
if (Math.abs(player.getLocation().getPitch()) > 30.0f) {
|
||||
return PASS;
|
||||
}
|
||||
|
||||
final Location eyes = player.getEyeLocation().clone();
|
||||
final World world = player.getWorld();
|
||||
final double expansion = checksConfig.getDouble(CheckType.KILLAURA, "throughWalls", "expand");
|
||||
final RayTraceResult result = world.rayTrace(eyes, eyes.getDirection(), RAY_LENGTH, FluidCollisionMode.NEVER,
|
||||
true, expansion, entity -> entity.equals(target));
|
||||
if (player.getLocation().toVector().clone().setY(0.0)
|
||||
.distance(target.getLocation().toVector().clone().setY(0)) <= expansion) {
|
||||
return PASS;
|
||||
}
|
||||
|
||||
if (result != null) {
|
||||
final Block block = result.getHitBlock();
|
||||
final Entity entity = result.getHitEntity();
|
||||
final double distance = result.getHitPosition().distance(eyes.toVector());
|
||||
if (entity == null && block != null && distance > 0.3) {
|
||||
final int flags = THROUGHWALLS_FLAGS.getOrDefault(uuid, 0) + 1;
|
||||
if (flags > checksConfig.getInteger(CheckType.KILLAURA, "throughWalls", "vlBeforeFlag")) {
|
||||
THROUGHWALLS_FLAGS.put(uuid, 0);
|
||||
return new CheckResult(Result.FAILED, "ThroughWalls",
|
||||
"hit through object (distance: " + Utilities.roundDouble(distance, 2) + ", block: "
|
||||
+ block.getType().name().toLowerCase() + ", pitch: "
|
||||
+ Utilities.roundFloat(player.getLocation().getPitch(), 1) + ")");
|
||||
}
|
||||
THROUGHWALLS_FLAGS.put(uuid, flags);
|
||||
} else {
|
||||
final int flags = THROUGHWALLS_FLAGS.getOrDefault(uuid, 1) - 1;
|
||||
THROUGHWALLS_FLAGS.put(uuid, flags);
|
||||
}
|
||||
} else {
|
||||
// TODO should be covered by angle & reach check, but maybe continue anyway?
|
||||
}
|
||||
return PASS;
|
||||
}
|
||||
|
||||
public static double calculateYawDifference(final Location from, final Location to) {
|
||||
final Location clonedFrom = from.clone();
|
||||
final Vector startVector = clonedFrom.toVector();
|
||||
final Vector targetVector = to.toVector();
|
||||
clonedFrom.setDirection(targetVector.subtract(startVector));
|
||||
return clonedFrom.getYaw();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,51 +1,71 @@
|
||||
/*
|
||||
* AntiCheatReloaded for Bukkit and Spigot.
|
||||
* Copyright (c) 2012-2015 AntiCheat Team
|
||||
* Copyright (c) 2016-2022 Rammelkast
|
||||
*
|
||||
* 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 3 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, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.rammelkast.anticheatreloaded.check.combat;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
|
||||
import com.rammelkast.anticheatreloaded.AntiCheat;
|
||||
import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
|
||||
import com.rammelkast.anticheatreloaded.check.CheckResult;
|
||||
import com.rammelkast.anticheatreloaded.check.CheckType;
|
||||
import com.rammelkast.anticheatreloaded.event.EventListener;
|
||||
import com.rammelkast.anticheatreloaded.check.CheckResult.Result;
|
||||
import com.rammelkast.anticheatreloaded.config.providers.Checks;
|
||||
import com.rammelkast.anticheatreloaded.util.Distance;
|
||||
import com.rammelkast.anticheatreloaded.util.MovementManager;
|
||||
import com.rammelkast.anticheatreloaded.util.User;
|
||||
import com.rammelkast.anticheatreloaded.util.Utilities;
|
||||
|
||||
public class VelocityCheck {
|
||||
public final class VelocityCheck {
|
||||
|
||||
private static final Map<UUID, Integer> VL_COUNT = new HashMap<UUID, Integer>();
|
||||
|
||||
public static void cleanPlayer(Player p) {
|
||||
VL_COUNT.remove(p.getUniqueId());
|
||||
}
|
||||
|
||||
public static void runCheck(EntityDamageByEntityEvent e, final Player p) {
|
||||
if (AntiCheat.getManager().getCheckManager().isOpExempt(p) || AntiCheat.getManager().getCheckManager().isExempt(p, CheckType.VELOCITY))
|
||||
return;
|
||||
final Location then = p.getLocation();
|
||||
new BukkitRunnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (!p.isOnline())
|
||||
return;
|
||||
if (then.distance(p.getLocation()) < 0.125) {
|
||||
if (!VL_COUNT.containsKey(p.getUniqueId()))
|
||||
VL_COUNT.put(p.getUniqueId(), 1);
|
||||
else {
|
||||
VL_COUNT.put(p.getUniqueId(), VL_COUNT.get(p.getUniqueId()) + 1);
|
||||
if (VL_COUNT.get(p.getUniqueId()) > AntiCheat.getManager().getBackend().getMagic().VELOCITY_AMT()) {
|
||||
EventListener.log(new CheckResult(CheckResult.Result.FAILED, p.getName() + " failed Velocity, had zero/low velocity " + VL_COUNT.get(p.getUniqueId()) + " times (max=" + AntiCheat.getManager().getBackend().getMagic().VELOCITY_AMT() + ", dist=" + then.distance(p.getLocation()) + ")").getMessage(), p, CheckType.VELOCITY);
|
||||
VL_COUNT.remove(p.getUniqueId());
|
||||
}
|
||||
}
|
||||
}else {
|
||||
VL_COUNT.remove(p.getUniqueId());
|
||||
}
|
||||
public static final Map<UUID, Integer> VIOLATIONS = new HashMap<UUID, Integer>();
|
||||
private static final CheckResult PASS = new CheckResult(CheckResult.Result.PASSED);
|
||||
|
||||
public static CheckResult runCheck(final Player player, final Distance distance) {
|
||||
final User user = AntiCheatReloaded.getManager().getUserManager().getUser(player.getUniqueId());
|
||||
final MovementManager movementManager = user.getMovementManager();
|
||||
final Checks checksConfig = AntiCheatReloaded.getManager().getConfiguration().getChecks();
|
||||
final int minimumPercentage = checksConfig.getInteger(CheckType.VELOCITY, "minimumPercentage");
|
||||
final int vlBeforeFlag = checksConfig.getInteger(CheckType.VELOCITY, "vlBeforeFlag");
|
||||
|
||||
if (movementManager.velocityExpectedMotionY > 0 && !movementManager.onGround) {
|
||||
double percentage = (movementManager.motionY / movementManager.velocityExpectedMotionY) * 100;
|
||||
if (percentage < 0) {
|
||||
percentage = 0;
|
||||
}
|
||||
}.runTaskLater(AntiCheat.getPlugin(), 4);
|
||||
// Reset expected Y motion
|
||||
movementManager.velocityExpectedMotionY = 0;
|
||||
if (percentage < minimumPercentage) {
|
||||
final int vl = VIOLATIONS.getOrDefault(player.getUniqueId(), 0) + 1;
|
||||
VIOLATIONS.put(player.getUniqueId(), vl);
|
||||
if (vl >= vlBeforeFlag) {
|
||||
return new CheckResult(Result.FAILED, "ignored server velocity (pct=" + Utilities.roundDouble(percentage, 2) + ")");
|
||||
}
|
||||
} else {
|
||||
VIOLATIONS.remove(player.getUniqueId());
|
||||
}
|
||||
} else if (movementManager.airTicks > 5 && movementManager.velocityExpectedMotionY > 0) {
|
||||
movementManager.velocityExpectedMotionY = 0;
|
||||
}
|
||||
return PASS;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,69 @@
|
||||
/*
|
||||
* AntiCheatReloaded for Bukkit and Spigot.
|
||||
* Copyright (c) 2012-2015 AntiCheat Team
|
||||
* Copyright (c) 2016-2022 Rammelkast
|
||||
*
|
||||
* 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 3 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, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.rammelkast.anticheatreloaded.check.movement;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||
|
||||
import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
|
||||
import com.rammelkast.anticheatreloaded.check.Backend;
|
||||
import com.rammelkast.anticheatreloaded.check.CheckResult;
|
||||
import com.rammelkast.anticheatreloaded.check.CheckType;
|
||||
import com.rammelkast.anticheatreloaded.config.providers.Checks;
|
||||
import com.rammelkast.anticheatreloaded.util.MovementManager;
|
||||
import com.rammelkast.anticheatreloaded.util.User;
|
||||
import com.rammelkast.anticheatreloaded.util.Utilities;
|
||||
|
||||
public final class AimbotCheck {
|
||||
|
||||
private static final double EXPANDER = Math.pow(2, 24);
|
||||
private static final CheckResult PASS = new CheckResult(CheckResult.Result.PASSED);
|
||||
|
||||
/**
|
||||
* This falses sometimes?
|
||||
* TODO we need to check yaw deltas
|
||||
*/
|
||||
public static CheckResult runCheck(final Player player, final EntityDamageByEntityEvent event) {
|
||||
final Backend backend = AntiCheatReloaded.getManager().getBackend();
|
||||
if (backend.isMovingExempt(player)) {
|
||||
return PASS;
|
||||
}
|
||||
|
||||
final User user = AntiCheatReloaded.getManager().getUserManager()
|
||||
.getUser(player.getUniqueId());
|
||||
final MovementManager movementManager = user.getMovementManager();
|
||||
final Checks checksConfig = AntiCheatReloaded.getManager().getConfiguration().getChecks();
|
||||
final float deltaPitch = movementManager.deltaPitch;
|
||||
final float pitchAcceleration = Math.abs(deltaPitch - movementManager.lastDeltaPitch);
|
||||
|
||||
final long gcd = Utilities.getGcd((long) (deltaPitch * EXPANDER),
|
||||
(long) (movementManager.lastDeltaPitch * EXPANDER));
|
||||
final double mod = Math.abs(player.getLocation().getPitch() % (gcd / EXPANDER));
|
||||
final double minAcceleration = checksConfig.getDouble(CheckType.AIMBOT, "minAcceleration");
|
||||
final double maxMod = checksConfig.getDouble(CheckType.AIMBOT, "maxMod");
|
||||
if ((gcd > 0L && gcd < 131072L) && mod <= maxMod && pitchAcceleration > minAcceleration && deltaPitch > 5.0f && deltaPitch < 20.0f) {
|
||||
return new CheckResult(CheckResult.Result.FAILED,
|
||||
"failed computational check (gcd=" + gcd + ", mod="
|
||||
+ Utilities.roundDouble(mod, 5) + ", accel=" + Utilities.roundDouble(pitchAcceleration, 3)
|
||||
+ ", delta=" + Utilities.roundDouble(deltaPitch, 1) + ")");
|
||||
}
|
||||
return PASS;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,59 +0,0 @@
|
||||
package com.rammelkast.anticheatreloaded.check.movement;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
|
||||
import com.comphenix.protocol.PacketType;
|
||||
import com.comphenix.protocol.events.ListenerPriority;
|
||||
import com.comphenix.protocol.events.PacketAdapter;
|
||||
import com.comphenix.protocol.events.PacketEvent;
|
||||
import com.rammelkast.anticheatreloaded.AntiCheat;
|
||||
import com.rammelkast.anticheatreloaded.check.CheckResult;
|
||||
import com.rammelkast.anticheatreloaded.check.CheckType;
|
||||
import com.rammelkast.anticheatreloaded.event.EventListener;
|
||||
|
||||
/**
|
||||
* @author Rammelkast
|
||||
*/
|
||||
public class BlinkCheck {
|
||||
|
||||
public static final Map<UUID, Integer> MOVE_COUNT = new HashMap<UUID, Integer>();
|
||||
|
||||
public static void startTimer() {
|
||||
new BukkitRunnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
MOVE_COUNT.clear();
|
||||
}
|
||||
}.runTaskTimer(AntiCheat.getPlugin(), 20, 20);
|
||||
}
|
||||
|
||||
public static void listenPackets() {
|
||||
AntiCheat.getProtocolManager().addPacketListener(new PacketAdapter(AntiCheat.getPlugin(), ListenerPriority.NORMAL, new PacketType[] {PacketType.Play.Client.POSITION, PacketType.Play.Client.POSITION_LOOK}) {
|
||||
@Override
|
||||
public void onPacketReceiving(PacketEvent e) {
|
||||
Player p = e.getPlayer();
|
||||
Location cur = e.getPlayer().getLocation();
|
||||
if (!MOVE_COUNT.containsKey(p.getUniqueId()))
|
||||
MOVE_COUNT.put(p.getUniqueId(), 1);
|
||||
else {
|
||||
MOVE_COUNT.put(p.getUniqueId(), MOVE_COUNT.get(p.getUniqueId()) + 1);
|
||||
if (AntiCheat.getManager().getCheckManager().checkInWorld(p) && !AntiCheat.getManager().getCheckManager().isOpExempt(p) && !AntiCheat.getManager().getCheckManager().isExempt(p, CheckType.BLINK)) {
|
||||
if (MOVE_COUNT.get(p.getUniqueId()) > AntiCheat.getManager().getBackend().getMagic().BLINK_PACKET()) {
|
||||
EventListener.log(new CheckResult(CheckResult.Result.FAILED, p.getName() + " failed Blink, sent " + MOVE_COUNT.get(p.getUniqueId()) + " packets in one second (max=" + AntiCheat.getManager().getBackend().getMagic().BLINK_PACKET() + ")").getMessage(), p, CheckType.BLINK);
|
||||
MOVE_COUNT.remove(p.getUniqueId());
|
||||
e.setCancelled(true);
|
||||
e.getPlayer().teleport(cur);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,71 @@
|
||||
/*
|
||||
* AntiCheatReloaded for Bukkit and Spigot.
|
||||
* Copyright (c) 2012-2015 AntiCheat Team
|
||||
* Copyright (c) 2016-2022 Rammelkast
|
||||
*
|
||||
* 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 3 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, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.rammelkast.anticheatreloaded.check.movement;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.cryptomorin.xseries.XMaterial;
|
||||
import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
|
||||
import com.rammelkast.anticheatreloaded.check.CheckResult;
|
||||
import com.rammelkast.anticheatreloaded.check.CheckType;
|
||||
import com.rammelkast.anticheatreloaded.check.CheckResult.Result;
|
||||
import com.rammelkast.anticheatreloaded.config.providers.Checks;
|
||||
import com.rammelkast.anticheatreloaded.util.MovementManager;
|
||||
import com.rammelkast.anticheatreloaded.util.Utilities;
|
||||
import com.rammelkast.anticheatreloaded.util.VersionLib;
|
||||
|
||||
public final class BoatFlyCheck {
|
||||
|
||||
public static final Map<UUID, Integer> VIOLATIONS = new HashMap<UUID, Integer>();
|
||||
private static final CheckResult PASS = new CheckResult(CheckResult.Result.PASSED);
|
||||
|
||||
public static CheckResult runCheck(final Player player, final MovementManager movementManager, final Location to) {
|
||||
if (movementManager.motionY <= 1E-3
|
||||
|| (System.currentTimeMillis() - movementManager.lastTeleport <= 150) || VersionLib.isFlying(player)
|
||||
|| !player.isInsideVehicle()) {
|
||||
return PASS;
|
||||
}
|
||||
|
||||
final UUID uuid = player.getUniqueId();
|
||||
final Checks checksConfig = AntiCheatReloaded.getManager().getConfiguration().getChecks();
|
||||
if (player.getVehicle().getType() == EntityType.BOAT) {
|
||||
final Block bottom = player.getWorld().getBlockAt(to.getBlockX(), to.getBlockY() - 1, to.getBlockZ());
|
||||
if (!Utilities.cantStandAt(bottom) || bottom.getType() == XMaterial.WATER.parseMaterial()) {
|
||||
return PASS;
|
||||
}
|
||||
|
||||
int violations = VIOLATIONS.getOrDefault(uuid, 1);
|
||||
if (violations++ >= checksConfig.getInteger(CheckType.BOATFLY, "vlBeforeFlag")) {
|
||||
violations = 0;
|
||||
return new CheckResult(Result.FAILED, "tried to fly in a boat (mY=" + movementManager.motionY
|
||||
+ ", bottom=" + bottom.getType().name().toLowerCase() + ")");
|
||||
}
|
||||
VIOLATIONS.put(uuid, violations);
|
||||
}
|
||||
return PASS;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,98 @@
|
||||
/*
|
||||
* AntiCheatReloaded for Bukkit and Spigot.
|
||||
* Copyright (c) 2012-2015 AntiCheat Team
|
||||
* Copyright (c) 2016-2022 Rammelkast
|
||||
*
|
||||
* 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 3 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, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.rammelkast.anticheatreloaded.check.movement;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.potion.PotionEffectType;
|
||||
|
||||
import com.cryptomorin.xseries.XMaterial;
|
||||
import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
|
||||
import com.rammelkast.anticheatreloaded.check.CheckResult;
|
||||
import com.rammelkast.anticheatreloaded.util.Distance;
|
||||
import com.rammelkast.anticheatreloaded.util.MinecraftVersion;
|
||||
import com.rammelkast.anticheatreloaded.util.Utilities;
|
||||
|
||||
public final class ElytraCheck {
|
||||
|
||||
public static final HashMap<UUID, Double> JUMP_Y_VALUE = new HashMap<UUID, Double>();
|
||||
private static final CheckResult PASS = new CheckResult(CheckResult.Result.PASSED);
|
||||
|
||||
public static CheckResult runCheck(final Player player, final Distance distance) {
|
||||
// Not relevant
|
||||
if (Utilities.isNearWater(player)) {
|
||||
return PASS;
|
||||
}
|
||||
|
||||
final UUID uuid = player.getUniqueId();
|
||||
if (distance.getYDifference() > AntiCheatReloaded.getManager().getBackend().getMagic().TELEPORT_MIN()
|
||||
|| System.currentTimeMillis() - AntiCheatReloaded.getManager().getUserManager().getUser(uuid)
|
||||
.getMovementManager().lastTeleport <= 500) {
|
||||
// This was a teleport, so skip check.
|
||||
JUMP_Y_VALUE.remove(uuid);
|
||||
return PASS;
|
||||
}
|
||||
|
||||
if (player.isFlying() || player.hasPotionEffect(PotionEffectType.LEVITATION) || !player.isGliding()) {
|
||||
JUMP_Y_VALUE.remove(uuid);
|
||||
return PASS;
|
||||
}
|
||||
|
||||
final double changeY = distance.toY() - distance.fromY();
|
||||
final boolean upwardMovement = changeY > 0;
|
||||
if (MinecraftVersion.getCurrentVersion().isAtLeast(MinecraftVersion.AQUATIC_UPDATE)) {
|
||||
// Tident added in 1.13
|
||||
if (player.getInventory().getItemInMainHand().getType() == XMaterial.TRIDENT.parseMaterial()) {
|
||||
if (upwardMovement) {
|
||||
JUMP_Y_VALUE.remove(uuid);
|
||||
return PASS;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!JUMP_Y_VALUE.containsKey(uuid)) {
|
||||
// Distance + player height
|
||||
JUMP_Y_VALUE.put(uuid, distance.toY() + 1.8D);
|
||||
return PASS;
|
||||
}
|
||||
|
||||
final double lastY = JUMP_Y_VALUE.get(uuid);
|
||||
if (changeY == 0.0D && lastY < 9999.99D) {
|
||||
return new CheckResult(CheckResult.Result.FAILED, "had no Y-axis dropoff when gliding with Elytra");
|
||||
}
|
||||
|
||||
if (lastY < distance.toY()) {
|
||||
final double diff = distance.toY() - lastY;
|
||||
if (diff > 0.7675) {
|
||||
if (!AntiCheatReloaded.getManager().getBackend().silentMode()) {
|
||||
Location to = player.getLocation();
|
||||
to.setY(to.getY() - diff);
|
||||
player.teleport(to);
|
||||
}
|
||||
return new CheckResult(CheckResult.Result.FAILED, "tried to glide above jump level");
|
||||
}
|
||||
}
|
||||
return PASS;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
package com.rammelkast.anticheatreloaded.check.movement;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.rammelkast.anticheatreloaded.check.CheckResult;
|
||||
import com.rammelkast.anticheatreloaded.util.Distance;
|
||||
|
||||
/**
|
||||
* TODO
|
||||
*/
|
||||
public class ElytraFly {
|
||||
|
||||
private static final CheckResult PASS = new CheckResult(CheckResult.Result.PASSED);
|
||||
|
||||
public static CheckResult runCheck(Player player, Distance distance) {
|
||||
return PASS;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,88 @@
|
||||
/*
|
||||
* AntiCheatReloaded for Bukkit and Spigot.
|
||||
* Copyright (c) 2012-2015 AntiCheat Team
|
||||
* Copyright (c) 2016-2022 Rammelkast
|
||||
*
|
||||
* 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 3 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, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.rammelkast.anticheatreloaded.check.movement;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
|
||||
import com.rammelkast.anticheatreloaded.check.CheckResult;
|
||||
import com.rammelkast.anticheatreloaded.check.CheckResult.Result;
|
||||
import com.rammelkast.anticheatreloaded.check.CheckType;
|
||||
import com.rammelkast.anticheatreloaded.config.providers.Checks;
|
||||
import com.rammelkast.anticheatreloaded.util.Utilities;
|
||||
import com.rammelkast.anticheatreloaded.util.VersionLib;
|
||||
|
||||
public final class FastLadderCheck {
|
||||
|
||||
public static final Map<UUID, Integer> VIOLATIONS = new HashMap<UUID, Integer>();
|
||||
private static final CheckResult PASS = new CheckResult(CheckResult.Result.PASSED);
|
||||
|
||||
public static CheckResult runCheck(Player player, double y) {
|
||||
// Only check if fully on ladder and not flying
|
||||
// Liquids are climbable blocks, so we have to add a seperate check
|
||||
if (!Utilities.isClimbableBlock(player.getLocation().getBlock())
|
||||
|| !Utilities.isClimbableBlock(player.getEyeLocation().getBlock())
|
||||
|| player.getLocation().getBlock().isLiquid() || VersionLib.isFlying(player)) {
|
||||
return PASS;
|
||||
}
|
||||
|
||||
int vlCount = VIOLATIONS.getOrDefault(player.getUniqueId(), 0);
|
||||
Checks checksConfig = AntiCheatReloaded.getManager().getConfiguration().getChecks();
|
||||
int vlBeforeFlag = checksConfig.getInteger(CheckType.FASTLADDER, "vlBeforeFlag");
|
||||
if (y > 0) {
|
||||
// Check moving up
|
||||
double max = checksConfig.getDouble(CheckType.FASTLADDER, "speedUpMax");
|
||||
// Check if going faster than max Y climbing speed
|
||||
if (y - max > 0) {
|
||||
if (vlCount++ > vlBeforeFlag) {
|
||||
vlCount = 0;
|
||||
return new CheckResult(Result.FAILED,
|
||||
"tried to climb up too fast (speed=" + y + ", max=" + max + ")");
|
||||
}
|
||||
} else {
|
||||
if (vlCount > 0)
|
||||
vlCount--;
|
||||
}
|
||||
} else if (y < 0) {
|
||||
// Check moving down
|
||||
double max = checksConfig.getDouble(CheckType.FASTLADDER, "speedDownMax");
|
||||
if (Math.abs(y) > max + 6E-9) {
|
||||
if (vlCount++ > vlBeforeFlag) {
|
||||
vlCount = 0;
|
||||
return new CheckResult(Result.FAILED, "tried to climb down too fast (speed=" + Math.abs(y)
|
||||
+ ", max=" + max + ")");
|
||||
}
|
||||
} else {
|
||||
if (vlCount > 0)
|
||||
vlCount--;
|
||||
}
|
||||
} else {
|
||||
if (vlCount > 0)
|
||||
vlCount--;
|
||||
}
|
||||
|
||||
VIOLATIONS.put(player.getUniqueId(), vlCount);
|
||||
return PASS;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,3 +1,21 @@
|
||||
/*
|
||||
* AntiCheatReloaded for Bukkit and Spigot.
|
||||
* Copyright (c) 2012-2015 AntiCheat Team
|
||||
* Copyright (c) 2016-2022 Rammelkast
|
||||
*
|
||||
* 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 3 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, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.rammelkast.anticheatreloaded.check.movement;
|
||||
|
||||
import java.util.HashMap;
|
||||
@@ -7,88 +25,241 @@ import java.util.UUID;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.potion.PotionEffectType;
|
||||
|
||||
import com.rammelkast.anticheatreloaded.AntiCheat;
|
||||
import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
|
||||
import com.rammelkast.anticheatreloaded.check.CheckResult;
|
||||
import com.rammelkast.anticheatreloaded.check.CheckType;
|
||||
import com.rammelkast.anticheatreloaded.config.providers.Checks;
|
||||
import com.rammelkast.anticheatreloaded.util.Distance;
|
||||
import com.rammelkast.anticheatreloaded.util.MovementManager;
|
||||
import com.rammelkast.anticheatreloaded.util.User;
|
||||
import com.rammelkast.anticheatreloaded.util.Utilities;
|
||||
import com.rammelkast.anticheatreloaded.util.VersionUtil;
|
||||
import com.rammelkast.anticheatreloaded.util.VelocityTracker;
|
||||
import com.rammelkast.anticheatreloaded.util.VersionLib;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Marco TODO rewrite this check
|
||||
* @author Rammelkast
|
||||
*/
|
||||
public class FlightCheck {
|
||||
public final class FlightCheck {
|
||||
|
||||
public static final Map<UUID, Long> MOVING_EXEMPT = new HashMap<UUID, Long>();
|
||||
public static final Map<UUID, Float> GRAVITY_VIOLATIONS = new HashMap<UUID, Float>();
|
||||
|
||||
private static final CheckResult PASS = new CheckResult(CheckResult.Result.PASSED);
|
||||
private static final double GRAVITY_FRICTION = 0.98f;
|
||||
|
||||
public static Map<UUID, Double> blocksOverFlight = new HashMap<UUID, Double>();
|
||||
public static Map<UUID, Long> movingExempt = new HashMap<UUID, Long>();
|
||||
|
||||
public static CheckResult runCheck(Player player, Distance distance) {
|
||||
if (distance.getYDifference() > AntiCheat.getManager().getBackend().getMagic().TELEPORT_MIN()
|
||||
|| VersionUtil.isFlying(player)) {
|
||||
// This was a teleport or user is flying/elyta'ing, so we don't care
|
||||
// about it.
|
||||
public static CheckResult runCheck(final Player player, final Distance distance) {
|
||||
if (distance.getYDifference() >= AntiCheatReloaded.getManager().getBackend().getMagic().TELEPORT_MIN()
|
||||
|| VersionLib.isFlying(player) || player.getVehicle() != null
|
||||
|| AntiCheatReloaded.getManager().getBackend().isMovingExempt(player)) {
|
||||
// This was a teleport or user is flying/using elytra/in a vehicle, so we don't
|
||||
// care about it.
|
||||
return PASS;
|
||||
}
|
||||
final UUID uuid = player.getUniqueId();
|
||||
final double y1 = distance.fromY();
|
||||
final double y2 = distance.toY();
|
||||
if (!isMovingExempt(player) && !Utilities.isHoveringOverWater(player.getLocation(), 1)
|
||||
&& Utilities.cantStandAtExp(player.getLocation())
|
||||
&& Utilities.blockIsnt(player.getLocation().getBlock().getRelative(BlockFace.DOWN),
|
||||
new Material[] { Material.FENCE, Material.FENCE_GATE, Material.COBBLE_WALL })) {
|
||||
|
||||
if (!blocksOverFlight.containsKey(uuid)) {
|
||||
blocksOverFlight.put(uuid, 0D);
|
||||
}
|
||||
final User user = AntiCheatReloaded.getManager().getUserManager().getUser(player.getUniqueId());
|
||||
final MovementManager movementManager = user.getMovementManager();
|
||||
final VelocityTracker velocityTracker = user.getVelocityTracker();
|
||||
final Checks checksConfig = AntiCheatReloaded.getManager().getConfiguration().getChecks();
|
||||
|
||||
blocksOverFlight.put(uuid, (blocksOverFlight.get(uuid) + distance.getXDifference()
|
||||
+ distance.getYDifference() + distance.getZDifference()));
|
||||
|
||||
if (y1 > y2) {
|
||||
blocksOverFlight.put(uuid, (blocksOverFlight.get(uuid) - distance.getYDifference()));
|
||||
}
|
||||
|
||||
if (blocksOverFlight.get(uuid) > AntiCheat.getManager().getBackend().getMagic().FLIGHT_BLOCK_LIMIT()
|
||||
&& (y1 <= y2)) {
|
||||
return new CheckResult(CheckResult.Result.FAILED,
|
||||
player.getName() + " flew over " + blocksOverFlight.get(uuid) + " blocks (max="
|
||||
+ AntiCheat.getManager().getBackend().getMagic().FLIGHT_BLOCK_LIMIT() + ")");
|
||||
}
|
||||
} else {
|
||||
blocksOverFlight.put(uuid, 0D);
|
||||
if (movementManager.nearLiquidTicks > 0 || movementManager.halfMovement || Utilities.isNearClimbable(player)
|
||||
|| movementManager.riptideTicks > 0) {
|
||||
return PASS;
|
||||
}
|
||||
|
||||
int minAirTicks = 13;
|
||||
if (player.hasPotionEffect(PotionEffectType.JUMP)) {
|
||||
minAirTicks += VersionLib.getPotionLevel(player, PotionEffectType.JUMP) * 3;
|
||||
}
|
||||
|
||||
if (movementManager.halfMovementHistoryCounter > 25) {
|
||||
minAirTicks += 5;
|
||||
}
|
||||
|
||||
// Start AirFlight
|
||||
if (checksConfig.isSubcheckEnabled(CheckType.FLIGHT, "airFlight") && movementManager.airTicks > minAirTicks
|
||||
&& movementManager.elytraEffectTicks <= 25) {
|
||||
// Config default base is 1200ms
|
||||
// Ping clamped to max. 1000 to prevent spoofing for an advantage
|
||||
int blockPlaceAccountingTime = (int) (checksConfig.getInteger(CheckType.FLIGHT, "airFlight",
|
||||
"accountForBlockPlacement") + (0.25 * (user.getPing() > 1000 ? 1000 : user.getPing())));
|
||||
// Config default account is 250ms
|
||||
if (AntiCheatReloaded.getPlugin().getTPS() < 18.0) {
|
||||
blockPlaceAccountingTime += checksConfig.getInteger(CheckType.FLIGHT, "airFlight",
|
||||
"accountForTpsDrops");
|
||||
}
|
||||
|
||||
final long lastPlacedBlock = AntiCheatReloaded.getManager().getBackend().placedBlock
|
||||
.containsKey(player.getUniqueId())
|
||||
? AntiCheatReloaded.getManager().getBackend().placedBlock.get(player.getUniqueId())
|
||||
: (blockPlaceAccountingTime + 1);
|
||||
double maxMotionY = System.currentTimeMillis() - lastPlacedBlock > blockPlaceAccountingTime ? 0 : 0.42;
|
||||
// Fixes snow false positive
|
||||
if (movementManager.motionY < 0.004 && Utilities
|
||||
.isNearHalfblock(distance.getFrom().getBlock().getRelative(BlockFace.DOWN).getLocation())) {
|
||||
maxMotionY += 0.004D;
|
||||
}
|
||||
|
||||
// Fixes water false positive
|
||||
if (Utilities.isNearWater(player)
|
||||
|| Utilities.isNearWater(distance.getFrom().clone().subtract(0, 0.51, 0))) {
|
||||
maxMotionY += 0.05;
|
||||
}
|
||||
|
||||
// Velocity adjustment
|
||||
maxMotionY += velocityTracker.getVertical();
|
||||
|
||||
if (movementManager.motionY > maxMotionY && movementManager.slimeInfluenceTicks <= 0
|
||||
&& !Utilities.isNearClimbable(distance.getTo().clone().subtract(0, 1.25, 0))
|
||||
&& !Utilities.isNearClimbable(distance.getTo().clone().subtract(0, 0.75, 0))
|
||||
&& (!Utilities.isNearWater(distance.getTo().clone().subtract(0, 1.5, 0))
|
||||
&& distance.getTo().clone().subtract(0, 0.5, 0).getBlock().getType() != Material.AIR)) {
|
||||
return new CheckResult(CheckResult.Result.FAILED, "AirFlight",
|
||||
"tried to fly on the Y-axis (mY=" + Utilities.roundDouble(movementManager.motionY, 4) + ", max=" + Utilities.roundDouble(maxMotionY, 4) + ")");
|
||||
}
|
||||
|
||||
// TODO falses when falling large distances
|
||||
if (Math.abs(movementManager.motionY
|
||||
- movementManager.lastMotionY) < (movementManager.airTicks >= 115 ? 1E-3 : 5E-3)
|
||||
&& !Utilities.couldBeOnBoat(player)
|
||||
&& (System.currentTimeMillis() - movementManager.lastTeleport >= checksConfig
|
||||
.getInteger(CheckType.FLIGHT, "airFlight", "accountForTeleports"))
|
||||
&& !VersionLib.isSlowFalling(player) && !Utilities.isNearWeb(player)
|
||||
&& movementManager.elytraEffectTicks <= 25
|
||||
&& !Utilities.isNearClimbable(distance.getFrom().clone().subtract(0, 0.51D, 0))
|
||||
&& !Utilities.isNearWater(player)
|
||||
&& !Utilities.isNearWater(distance.getFrom().clone().subtract(0, 0.51, 0))
|
||||
&& velocityTracker.getVertical() == 0.0) {
|
||||
return new CheckResult(CheckResult.Result.FAILED, "AirFlight", "had too little Y dropoff (diff="
|
||||
+ Utilities.roundDouble(Math.abs(movementManager.motionY - movementManager.lastMotionY), 4) + ")");
|
||||
}
|
||||
}
|
||||
// End AirFlight
|
||||
|
||||
// Start AirClimb
|
||||
if (checksConfig.isSubcheckEnabled(CheckType.FLIGHT, "airClimb") && movementManager.lastMotionY > 0
|
||||
&& movementManager.motionY > 0 && movementManager.airTicks == 2
|
||||
&& Math.round(movementManager.lastMotionY * 1000) != 420
|
||||
&& Math.round(movementManager.motionY * 1000) != 248
|
||||
&& !(Math.round(movementManager.motionY * 1000) == 333
|
||||
&& Math.round(movementManager.lastMotionY * 1000) != 333)
|
||||
&& !velocityTracker.isVelocitized() && !player.hasPotionEffect(PotionEffectType.JUMP)
|
||||
&& (System.currentTimeMillis() - movementManager.lastTeleport >= checksConfig
|
||||
.getInteger(CheckType.FLIGHT, "airClimb", "accountForTeleports"))
|
||||
&& (!Utilities.isNearBed(distance.getTo()) || ((Utilities.isNearBed(distance.getTo())
|
||||
|| Utilities.isNearBed(distance.getTo().clone().add(0, -0.51, 0)))
|
||||
&& movementManager.motionY > 0.15))
|
||||
&& movementManager.slimeInfluenceTicks == 0 && movementManager.elytraEffectTicks <= 25
|
||||
&& !Utilities.couldBeOnBoat(player, 0.8, false)) {
|
||||
return new CheckResult(CheckResult.Result.FAILED, "AirClimb",
|
||||
"tried to climb air (mY=" + Utilities.roundDouble(movementManager.motionY, 4) + ")");
|
||||
}
|
||||
|
||||
if (checksConfig.isSubcheckEnabled(CheckType.FLIGHT, "airClimb") && movementManager.motionY > 0.42
|
||||
&& movementManager.airTicks > 2 && !velocityTracker.isVelocitized()
|
||||
&& !player.hasPotionEffect(PotionEffectType.JUMP)
|
||||
&& !(Math.round(movementManager.motionY * 1000) == 425 && movementManager.airTicks == 11)
|
||||
&& (System.currentTimeMillis() - movementManager.lastTeleport >= checksConfig
|
||||
.getInteger(CheckType.FLIGHT, "airClimb", "accountForTeleports"))
|
||||
&& movementManager.slimeInfluenceTicks == 0 && movementManager.elytraEffectTicks <= 25) {
|
||||
return new CheckResult(CheckResult.Result.FAILED, "AirClimb",
|
||||
"tried to climb air (mY=" + Utilities.roundDouble(movementManager.motionY, 4) + ", at=" + movementManager.airTicks + ")");
|
||||
}
|
||||
|
||||
if (checksConfig.isSubcheckEnabled(CheckType.FLIGHT, "airClimb") && movementManager.airTicks >= minAirTicks
|
||||
&& movementManager.lastMotionY < 0 && movementManager.motionY > 0
|
||||
&& movementManager.motionY > velocityTracker.getVertical() && movementManager.elytraEffectTicks <= 25
|
||||
&& (System.currentTimeMillis() - movementManager.lastTeleport >= checksConfig
|
||||
.getInteger(CheckType.FLIGHT, "airClimb", "accountForTeleports"))
|
||||
&& !(Math.round(movementManager.motionY * 1000) == 396) && movementManager.airTicks == 15) {
|
||||
return new CheckResult(CheckResult.Result.FAILED, "AirClimb",
|
||||
"tried to climb air (mY=" + Utilities.roundDouble(movementManager.motionY, 4) + ", at=" + movementManager.airTicks + ")");
|
||||
}
|
||||
|
||||
if (checksConfig.isSubcheckEnabled(CheckType.FLIGHT, "airClimb") && movementManager.lastMotionY > 0.0
|
||||
&& movementManager.motionY > 0.0 && movementManager.airTicks > 3
|
||||
&& movementManager.motionY > movementManager.lastMotionY
|
||||
&& user.getVelocityTracker().getVertical() <= 0.0
|
||||
&& (System.currentTimeMillis() - movementManager.lastTeleport >= checksConfig
|
||||
.getInteger(CheckType.FLIGHT, "airClimb", "accountForTeleports"))) {
|
||||
return new CheckResult(CheckResult.Result.FAILED, "AirClimb",
|
||||
"tried to climb air (mY=" + Utilities.roundDouble(movementManager.motionY, 4) + ", at=" + movementManager.airTicks + ")");
|
||||
}
|
||||
|
||||
if (checksConfig.isSubcheckEnabled(CheckType.FLIGHT, "airClimb") && movementManager.airTicks >= minAirTicks
|
||||
&& !velocityTracker.isVelocitized() && movementManager.slimeInfluenceTicks <= 0
|
||||
&& movementManager.elytraEffectTicks <= 25
|
||||
&& (System.currentTimeMillis() - movementManager.lastTeleport >= checksConfig
|
||||
.getInteger(CheckType.FLIGHT, "airClimb", "accountForTeleports"))
|
||||
&& !Utilities.isNearClimbable(distance.getFrom(), 0.8)) {
|
||||
// Config default base is 1200ms
|
||||
// Ping clamped to max. 1000 to prevent spoofing for an advantage
|
||||
int blockPlaceAccountingTime = (int) (checksConfig.getInteger(CheckType.FLIGHT, "airFlight",
|
||||
"accountForBlockPlacement") + (0.25 * (user.getPing() > 1000 ? 1000 : user.getPing())));
|
||||
// Config default account is 250ms
|
||||
if (AntiCheatReloaded.getPlugin().getTPS() < 18.0) {
|
||||
blockPlaceAccountingTime += checksConfig.getInteger(CheckType.FLIGHT, "airFlight",
|
||||
"accountForTpsDrops");
|
||||
}
|
||||
|
||||
final long lastPlacedBlock = AntiCheatReloaded.getManager().getBackend().placedBlock
|
||||
.containsKey(player.getUniqueId())
|
||||
? AntiCheatReloaded.getManager().getBackend().placedBlock.get(player.getUniqueId())
|
||||
: (blockPlaceAccountingTime + 1);
|
||||
final double maxMotionY = System.currentTimeMillis() - lastPlacedBlock > blockPlaceAccountingTime ? 0
|
||||
: 0.42;
|
||||
if (movementManager.motionY > maxMotionY) {
|
||||
return new CheckResult(CheckResult.Result.FAILED, "AirClimb",
|
||||
"tried to climb air (mY=" + Utilities.roundDouble(movementManager.motionY, 4) + ", at=" + movementManager.airTicks + ")");
|
||||
}
|
||||
}
|
||||
// End AirClimb
|
||||
|
||||
// Start GroundFlight
|
||||
if (checksConfig.isSubcheckEnabled(CheckType.FLIGHT, "groundFlight") && movementManager.onGround
|
||||
&& Utilities.cantStandAt(distance.getTo().getBlock().getRelative(BlockFace.DOWN))
|
||||
&& Utilities.cantStandAt(distance.getFrom().getBlock().getRelative(BlockFace.DOWN))
|
||||
&& Utilities.cantStandAt(distance.getTo().getBlock())) {
|
||||
return new CheckResult(CheckResult.Result.FAILED, "GroundFlight",
|
||||
"faked ground to fly (mY=" + Utilities.roundDouble(movementManager.motionY, 4) + ", gt=" + movementManager.groundTicks + ")");
|
||||
}
|
||||
// End GroundFlight
|
||||
|
||||
// Start Gravity
|
||||
if (checksConfig.isSubcheckEnabled(CheckType.FLIGHT, "gravity") && !movementManager.onGround
|
||||
&& movementManager.motionY < 0 && Math.abs(movementManager.motionY) > velocityTracker.getVertical()
|
||||
&& (System.currentTimeMillis() - movementManager.lastTeleport >= checksConfig
|
||||
.getInteger(CheckType.FLIGHT, "gravity", "accountForTeleports"))
|
||||
&& !Utilities.isNearWeb(player) && movementManager.elytraEffectTicks <= 25
|
||||
&& !VersionLib.isSlowFalling(player)) {
|
||||
final double gravitatedY = (movementManager.lastMotionY - 0.08) * GRAVITY_FRICTION;
|
||||
final double offset = Math.abs(gravitatedY - movementManager.motionY);
|
||||
double maxOffset = checksConfig.getDouble(CheckType.FLIGHT, "gravity", "maxOffset");
|
||||
if (Utilities.isNearClimbable(distance.getFrom().clone().subtract(0, 0.51D, 0))
|
||||
|| Utilities.isNearClimbable(distance.getFrom()) || Utilities.isNearWater(player)
|
||||
|| (!Utilities.isNearWater(distance.getTo().clone().subtract(0, 1.5, 0))
|
||||
&& distance.getTo().clone().subtract(0, 0.5, 0).getBlock().getType() != Material.AIR))
|
||||
maxOffset += 0.15D;
|
||||
if (offset > maxOffset && movementManager.airTicks > 2) {
|
||||
float vl = GRAVITY_VIOLATIONS.getOrDefault(player.getUniqueId(), 0f) + 1;
|
||||
GRAVITY_VIOLATIONS.put(player.getUniqueId(), vl);
|
||||
int vlBeforeFlag = checksConfig.getInteger(CheckType.FLIGHT, "gravity", "vlBeforeFlag");
|
||||
if (vl >= vlBeforeFlag) {
|
||||
GRAVITY_VIOLATIONS.put(player.getUniqueId(), Math.max(0, vl - 2));
|
||||
return new CheckResult(CheckResult.Result.FAILED, "Gravity",
|
||||
"ignored gravity (offset=" + Utilities.roundDouble(offset, 4) + ", at=" + movementManager.airTicks + ")");
|
||||
}
|
||||
} else {
|
||||
if (GRAVITY_VIOLATIONS.containsKey(player.getUniqueId())) {
|
||||
final float vl = GRAVITY_VIOLATIONS.getOrDefault(player.getUniqueId(), 0f);
|
||||
GRAVITY_VIOLATIONS.put(player.getUniqueId(), Math.max(0, vl - 0.5f));
|
||||
}
|
||||
}
|
||||
}
|
||||
// End Gravity
|
||||
|
||||
return PASS;
|
||||
}
|
||||
|
||||
public static boolean isMovingExempt(Player player) {
|
||||
return isDoing(player, movingExempt, -1);
|
||||
}
|
||||
|
||||
private static boolean isDoing(Player player, Map<UUID, Long> map, double max) {
|
||||
if (map.containsKey(player.getUniqueId())) {
|
||||
if (max != -1) {
|
||||
if (((System.currentTimeMillis() - map.get(player.getUniqueId())) / 1000) > max) {
|
||||
map.remove(player.getUniqueId());
|
||||
return false;
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
// Termination time has already been calculated
|
||||
if (map.get(player.getUniqueId()) < System.currentTimeMillis()) {
|
||||
map.remove(player.getUniqueId());
|
||||
return false;
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,72 +0,0 @@
|
||||
package com.rammelkast.anticheatreloaded.check.movement;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.rammelkast.anticheatreloaded.AntiCheat;
|
||||
import com.rammelkast.anticheatreloaded.check.Backend;
|
||||
import com.rammelkast.anticheatreloaded.check.CheckResult;
|
||||
import com.rammelkast.anticheatreloaded.util.Distance;
|
||||
import com.rammelkast.anticheatreloaded.util.Utilities;
|
||||
import com.rammelkast.anticheatreloaded.util.VersionUtil;
|
||||
|
||||
public class GlideCheck {
|
||||
|
||||
private static final CheckResult PASS = new CheckResult(CheckResult.Result.PASSED);
|
||||
|
||||
public static Map<UUID, Double> lastDiff = new HashMap<UUID, Double>();
|
||||
public static Map<UUID, Float> lastFallDistance = new HashMap<UUID, Float>();
|
||||
public static Map<UUID, Integer> violations = new HashMap<UUID, Integer>();
|
||||
|
||||
public static CheckResult runCheck(Player player, Distance distance) {
|
||||
if (VersionUtil.isFlying(player)) {
|
||||
return PASS;
|
||||
}
|
||||
if (!lastDiff.containsKey(player.getUniqueId())) {
|
||||
lastDiff.put(player.getUniqueId(), distance.getYDifference());
|
||||
return PASS;
|
||||
}
|
||||
if (!lastFallDistance.containsKey(player.getUniqueId())) {
|
||||
lastFallDistance.put(player.getUniqueId(), player.getFallDistance());
|
||||
return PASS;
|
||||
}
|
||||
double yDiff = distance.getYDifference();
|
||||
float fallDistance = player.getFallDistance();
|
||||
if (yDiff == lastDiff.get(player.getUniqueId()) && fallDistance > lastFallDistance.get(player.getUniqueId())) {
|
||||
if (!violations.containsKey(player.getUniqueId())) {
|
||||
violations.put(player.getUniqueId(), 1);
|
||||
} else {
|
||||
if (violations.get(player.getUniqueId()) + 1 >= AntiCheat.getManager().getBackend().getMagic().GLIDE_LIMIT()) {
|
||||
violations.remove(player.getUniqueId());
|
||||
Location to = player.getLocation();
|
||||
to.setY(to.getY() - distanceToFall(to));
|
||||
player.teleport(to);
|
||||
return new CheckResult(CheckResult.Result.FAILED,
|
||||
player.getName() + " was set back for gliding (yDiff=" + new BigDecimal(yDiff).setScale(2, BigDecimal.ROUND_UP) + ")");
|
||||
} else {
|
||||
violations.put(player.getUniqueId(), violations.get(player.getUniqueId()) + 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
lastDiff.put(player.getUniqueId(), distance.getYDifference());
|
||||
lastFallDistance.put(player.getUniqueId(), player.getFallDistance());
|
||||
return PASS;
|
||||
}
|
||||
|
||||
private static double distanceToFall(Location location) {
|
||||
location = location.clone();
|
||||
double firstY = location.getY();
|
||||
while (location.clone().add(0, -0.1, 0).getBlock().getType() == Material.AIR)
|
||||
location.add(0, -0.1, 0);
|
||||
return firstY - location.getY();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,89 @@
|
||||
/*
|
||||
* AntiCheatReloaded for Bukkit and Spigot.
|
||||
* Copyright (c) 2012-2015 AntiCheat Team
|
||||
* Copyright (c) 2016-2022 Rammelkast
|
||||
*
|
||||
* 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 3 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, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.rammelkast.anticheatreloaded.check.movement;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.comphenix.protocol.events.PacketEvent;
|
||||
import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
|
||||
import com.rammelkast.anticheatreloaded.check.CheckResult;
|
||||
import com.rammelkast.anticheatreloaded.check.CheckType;
|
||||
import com.rammelkast.anticheatreloaded.config.providers.Checks;
|
||||
import com.rammelkast.anticheatreloaded.event.EventListener;
|
||||
import com.rammelkast.anticheatreloaded.util.MovementManager;
|
||||
import com.rammelkast.anticheatreloaded.util.User;
|
||||
|
||||
public final class NoSlowCheck {
|
||||
|
||||
public static final Map<UUID, Long> LAST_RELEASE = new HashMap<UUID, Long>();
|
||||
public static final Map<UUID, Integer> VIOLATIONS = new HashMap<UUID, Integer>();
|
||||
|
||||
public static void runCheck(final Player player, final PacketEvent event) {
|
||||
if (event.isCancelled()) {
|
||||
// Do not check if cancelled
|
||||
return;
|
||||
}
|
||||
|
||||
if (!AntiCheatReloaded.getManager().getCheckManager().willCheck(player, CheckType.NOSLOW)) {
|
||||
return;
|
||||
}
|
||||
|
||||
final UUID uuid = player.getUniqueId();
|
||||
final User user = AntiCheatReloaded.getManager().getUserManager().getUser(uuid);
|
||||
final MovementManager movementManager = user.getMovementManager();
|
||||
final Checks checksConfig = AntiCheatReloaded.getManager().getConfiguration().getChecks();
|
||||
final long time = System.currentTimeMillis();
|
||||
final long lastRelease = LAST_RELEASE.getOrDefault(uuid, 0L);
|
||||
LAST_RELEASE.put(uuid, time);
|
||||
if (lastRelease == 0L) {
|
||||
return;
|
||||
}
|
||||
|
||||
final long difference = time - lastRelease;
|
||||
final long minimumDifference = checksConfig.getInteger(CheckType.NOSLOW, "minimumDifference");
|
||||
if (difference < minimumDifference
|
||||
&& movementManager.distanceXZ >= checksConfig.getDouble(CheckType.NOSLOW, "minimumDistXZ")) {
|
||||
int violations = VIOLATIONS.getOrDefault(uuid, 1);
|
||||
if (violations++ >= checksConfig.getInteger(CheckType.NOSLOW, "vlBeforeFlag")) {
|
||||
violations = 0;
|
||||
flag(player, event,
|
||||
"toggled use item too fast (diff=" + difference + ", min=" + minimumDifference + ")");
|
||||
}
|
||||
VIOLATIONS.put(uuid, violations);
|
||||
}
|
||||
}
|
||||
|
||||
private static void flag(final Player player, final PacketEvent event, final String message) {
|
||||
event.setCancelled(true);
|
||||
// We are currently not in the main server thread, so switch
|
||||
AntiCheatReloaded.sendToMainThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
EventListener.log(new CheckResult(CheckResult.Result.FAILED, message).getMessage(), player,
|
||||
CheckType.NOSLOW, null);
|
||||
player.teleport(player.getLocation());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,79 +1,511 @@
|
||||
/*
|
||||
* AntiCheatReloaded for Bukkit and Spigot.
|
||||
* Copyright (c) 2012-2015 AntiCheat Team
|
||||
* Copyright (c) 2016-2022 Rammelkast
|
||||
*
|
||||
* 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 3 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, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.rammelkast.anticheatreloaded.check.movement;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.enchantments.Enchantment;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.potion.PotionEffectType;
|
||||
|
||||
import com.rammelkast.anticheatreloaded.AntiCheat;
|
||||
import com.cryptomorin.xseries.XMaterial;
|
||||
import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
|
||||
import com.rammelkast.anticheatreloaded.check.Backend;
|
||||
import com.rammelkast.anticheatreloaded.check.CheckResult;
|
||||
import com.rammelkast.anticheatreloaded.util.VersionUtil;
|
||||
import com.rammelkast.anticheatreloaded.check.CheckType;
|
||||
import com.rammelkast.anticheatreloaded.check.CheckResult.Result;
|
||||
import com.rammelkast.anticheatreloaded.config.providers.Checks;
|
||||
import com.rammelkast.anticheatreloaded.util.Distance;
|
||||
import com.rammelkast.anticheatreloaded.util.Friction;
|
||||
import com.rammelkast.anticheatreloaded.util.MovementManager;
|
||||
import com.rammelkast.anticheatreloaded.util.User;
|
||||
import com.rammelkast.anticheatreloaded.util.Utilities;
|
||||
import com.rammelkast.anticheatreloaded.util.VelocityTracker;
|
||||
import com.rammelkast.anticheatreloaded.util.VersionLib;
|
||||
|
||||
public class SpeedCheck {
|
||||
/**
|
||||
* @author Rammelkast TODO soulsand speed TODO buffer system for all
|
||||
*/
|
||||
public final class SpeedCheck {
|
||||
|
||||
public static final Map<UUID, Double> PREDICT_BUFFER = new HashMap<>();
|
||||
public static final Map<UUID, Double> AIRSPEED_BUFFER = new HashMap<>();
|
||||
public static final Map<UUID, Double> AIRACCELERATION_BUFFER = new HashMap<>();
|
||||
|
||||
private static final CheckResult PASS = new CheckResult(CheckResult.Result.PASSED);
|
||||
public static Map<UUID, Integer> speedViolation = new HashMap<UUID, Integer>();
|
||||
|
||||
public static boolean isSpeedExempt(Player player) {
|
||||
return AntiCheat.getManager().getBackend().isMovingExempt(player)
|
||||
|| AntiCheat.getManager().getBackend().justVelocity(player) || VersionUtil.isFlying(player);
|
||||
private static boolean isSpeedExempt(final Player player, final Backend backend) {
|
||||
return backend.isMovingExempt(player) || VersionLib.isFlying(player);
|
||||
}
|
||||
|
||||
public static CheckResult checkXZSpeed(Player player, double x, double z) {
|
||||
if (!isSpeedExempt(player) && player.getVehicle() == null) {
|
||||
String reason = "";
|
||||
double max = AntiCheat.getManager().getBackend().getMagic().XZ_SPEED_MAX();
|
||||
if (player.getLocation().getBlock().getType() == Material.SOUL_SAND) {
|
||||
if (player.isSprinting()) {
|
||||
reason = "on soulsand while sprinting ";
|
||||
max = AntiCheat.getManager().getBackend().getMagic().XZ_SPEED_MAX_SOULSAND_SPRINT();
|
||||
} else if (player.hasPotionEffect(PotionEffectType.SPEED)) {
|
||||
reason = "on soulsand with speed potion ";
|
||||
max = AntiCheat.getManager().getBackend().getMagic().XZ_SPEED_MAX_SOULSAND_POTION();
|
||||
} else {
|
||||
reason = "on soulsand ";
|
||||
max = AntiCheat.getManager().getBackend().getMagic().XZ_SPEED_MAX_SOULSAND();
|
||||
}
|
||||
} else if (VersionUtil.isFlying(player)) {
|
||||
reason = "while flying ";
|
||||
max = AntiCheat.getManager().getBackend().getMagic().XZ_SPEED_MAX_FLY();
|
||||
} else if (player.hasPotionEffect(PotionEffectType.SPEED)) {
|
||||
if (player.isSprinting()) {
|
||||
reason = "with speed potion while sprinting ";
|
||||
max = AntiCheat.getManager().getBackend().getMagic().XZ_SPEED_MAX_POTION_SPRINT();
|
||||
} else {
|
||||
reason = "with speed potion ";
|
||||
max = AntiCheat.getManager().getBackend().getMagic().XZ_SPEED_MAX_POTION();
|
||||
}
|
||||
} else if (player.isSprinting()) {
|
||||
reason = "while sprinting ";
|
||||
max = AntiCheat.getManager().getBackend().getMagic().XZ_SPEED_MAX_SPRINT();
|
||||
}
|
||||
|
||||
float speed = player.getWalkSpeed();
|
||||
max += speed > 0 ? player.getWalkSpeed() - 0.2f : 0;
|
||||
|
||||
if (x > max || z > max) {
|
||||
int num = AntiCheat.getManager().getBackend().increment(player, speedViolation,
|
||||
AntiCheat.getManager().getBackend().getMagic().SPEED_MAX());
|
||||
if (num >= AntiCheat.getManager().getBackend().getMagic().SPEED_MAX()) {
|
||||
return new CheckResult(CheckResult.Result.FAILED,
|
||||
player.getName() + "'s speed was too high " + reason + num + " times in a row (max="
|
||||
+ AntiCheat.getManager().getBackend().getMagic().SPEED_MAX() + ", speed="
|
||||
+ (x > z ? x : z) + ", max speed=" + max + ")");
|
||||
} else {
|
||||
return PASS;
|
||||
}
|
||||
} else {
|
||||
speedViolation.put(player.getUniqueId(), 0);
|
||||
return PASS;
|
||||
}
|
||||
} else {
|
||||
|
||||
/**
|
||||
* Largely based on Elevated's Frequency speed check
|
||||
* @see https://github.com/ElevatedDev/Frequency/blob/master/src/main/java/xyz/elevated/frequency/check/impl/speed/Speed.java
|
||||
*
|
||||
* TODO fix falses with entity collisions
|
||||
*/
|
||||
public static CheckResult checkPredict(final Player player, final Location movingTowards) {
|
||||
final Checks checksConfig = AntiCheatReloaded.getManager().getConfiguration().getChecks();
|
||||
if (!checksConfig.isSubcheckEnabled(CheckType.SPEED, "predict")) {
|
||||
return PASS;
|
||||
}
|
||||
|
||||
final Backend backend = AntiCheatReloaded.getManager().getBackend();
|
||||
if (isSpeedExempt(player, backend) || player.getVehicle() != null || Utilities.isInWater(player)
|
||||
|| Utilities.isInWeb(player)) {
|
||||
return PASS;
|
||||
}
|
||||
|
||||
final User user = AntiCheatReloaded.getManager().getUserManager().getUser(player.getUniqueId());
|
||||
final UUID uuid = player.getUniqueId();
|
||||
final MovementManager movementManager = user.getMovementManager();
|
||||
final VelocityTracker velocityTracker = user.getVelocityTracker();
|
||||
|
||||
final double motion = movementManager.distanceXZ;
|
||||
final boolean boxedIn = movementManager.topSolid && movementManager.bottomSolid;
|
||||
final boolean sprinting = true; // TODO do this using packets
|
||||
|
||||
double buffer = PREDICT_BUFFER.getOrDefault(uuid, 0.0);
|
||||
double movementSpeed = Utilities.getMovementSpeed(player);
|
||||
if (movementManager.wasOnGround) {
|
||||
if (sprinting) {
|
||||
movementSpeed *= 1.3f;
|
||||
}
|
||||
|
||||
movementSpeed *= 0.16277136 / Math.pow((movementManager.friction *= 0.91f), 3);
|
||||
if (!movementManager.onGround && (movementManager.motionY >= 0.42f || (boxedIn && movementManager.motionY > 0.0f)) && sprinting) {
|
||||
movementSpeed += 0.2f;
|
||||
}
|
||||
} else {
|
||||
movementSpeed = sprinting ? 0.026f : 0.02f;
|
||||
movementManager.friction = 0.91f;
|
||||
}
|
||||
|
||||
movementSpeed += velocityTracker.getHorizontal();
|
||||
|
||||
final double factor = (motion - movementManager.adjusted) / movementSpeed;
|
||||
final boolean exempted = Utilities.isCollisionPoint(movingTowards,
|
||||
material -> material == XMaterial.HONEY_BLOCK.parseMaterial());
|
||||
if (factor > 1.001 && !exempted) {
|
||||
if (buffer++ > 2.5) {
|
||||
buffer /= 2;
|
||||
PREDICT_BUFFER.put(uuid, buffer);
|
||||
return new CheckResult(Result.FAILED, "Predict", "moved unexpectedly (factor=" + Utilities.roundDouble(factor, 3) + ")");
|
||||
}
|
||||
} else {
|
||||
buffer = Math.max(buffer - 0.05, 0.0);
|
||||
}
|
||||
|
||||
PREDICT_BUFFER.put(uuid, buffer);
|
||||
|
||||
movementManager.adjusted = motion * movementManager.friction;
|
||||
movementManager.friction = Friction.getFactor(movingTowards.clone().subtract(0, 1, 0).getBlock());
|
||||
return PASS;
|
||||
}
|
||||
|
||||
public static CheckResult checkXZSpeed(final Player player, final Location movingTowards) {
|
||||
final Backend backend = AntiCheatReloaded.getManager().getBackend();
|
||||
if (isSpeedExempt(player, backend) || player.getVehicle() != null || Utilities.isInWater(player)) {
|
||||
return PASS;
|
||||
}
|
||||
|
||||
final User user = AntiCheatReloaded.getManager().getUserManager().getUser(player.getUniqueId());
|
||||
final UUID uuid = player.getUniqueId();
|
||||
final MovementManager movementManager = user.getMovementManager();
|
||||
final VelocityTracker velocityTracker = user.getVelocityTracker();
|
||||
|
||||
// Riptiding exemption
|
||||
if (movementManager.riptideTicks > 0) {
|
||||
return PASS;
|
||||
}
|
||||
|
||||
final Checks checksConfig = AntiCheatReloaded.getManager().getConfiguration().getChecks();
|
||||
final double distanceXZ = movementManager.distanceXZ;
|
||||
final boolean boxedIn = movementManager.topSolid && movementManager.bottomSolid;
|
||||
|
||||
// AirSpeed
|
||||
if (checksConfig.isSubcheckEnabled(CheckType.SPEED, "airSpeed") && movementManager.airTicks > 1
|
||||
&& movementManager.elytraEffectTicks <= 0 && !Utilities.isNearClimbable(player)) {
|
||||
double buffer = AIRSPEED_BUFFER.getOrDefault(uuid, 0.0);
|
||||
|
||||
final double multiplier = 0.985D;
|
||||
double predict = 0.36 * Math.pow(multiplier, movementManager.airTicks + 1);
|
||||
// Prevents false when falling from great heights
|
||||
if (movementManager.airTicks >= 115) {
|
||||
predict = Math.max(0.08, predict);
|
||||
}
|
||||
|
||||
double limit = checksConfig.getDouble(CheckType.SPEED, "airSpeed", "baseLimit"); // Default 0.03125
|
||||
// Adjust for ice
|
||||
if (movementManager.iceInfluenceTicks > 0) {
|
||||
double iceIncrement = 0.025 * Math.pow(1.038, movementManager.iceInfluenceTicks);
|
||||
// Clamp to max value
|
||||
if (iceIncrement > 0.18D) {
|
||||
iceIncrement = 0.18D;
|
||||
}
|
||||
|
||||
// Boxed in ice increment
|
||||
if (boxedIn) {
|
||||
iceIncrement += 0.45D;
|
||||
}
|
||||
|
||||
// Ice increment moving off ice
|
||||
if (!Utilities.couldBeOnIce(movingTowards)) {
|
||||
iceIncrement *= 2.5D;
|
||||
}
|
||||
|
||||
predict += iceIncrement;
|
||||
}
|
||||
|
||||
// Leniency when boxed in
|
||||
if (boxedIn && movementManager.airTicks < 3) {
|
||||
predict *= 1.2D;
|
||||
}
|
||||
|
||||
// Adjust for slime
|
||||
if (movementManager.slimeInfluenceTicks > 0) {
|
||||
double slimeIncrement = 0.022 * Math.pow(1.0375, movementManager.slimeInfluenceTicks);
|
||||
// Clamp to max value
|
||||
if (slimeIncrement > 0.12D) {
|
||||
slimeIncrement = 0.12D;
|
||||
}
|
||||
|
||||
predict += slimeIncrement;
|
||||
}
|
||||
|
||||
// Adjust for soul speed
|
||||
final ItemStack boots = player.getInventory().getBoots();
|
||||
if (boots != null && movementManager.soilInfluenceTicks > 0 && VersionLib.isSoulSpeed(boots)) {
|
||||
predict += boots.getEnchantmentLevel(Enchantment.SOUL_SPEED) * 0.05D;
|
||||
}
|
||||
|
||||
// Adjust for speed effects
|
||||
if (movementManager.hasSpeedEffect) {
|
||||
predict += VersionLib.getPotionLevel(player, PotionEffectType.SPEED) * 0.05D;
|
||||
}
|
||||
|
||||
// Adjust for speed effects ending
|
||||
if (movementManager.hadSpeedEffect && !movementManager.hasSpeedEffect) {
|
||||
limit *= 1.2D;
|
||||
}
|
||||
|
||||
// Adjust for jump boost effects
|
||||
if (player.hasPotionEffect(PotionEffectType.JUMP)) {
|
||||
predict += VersionLib.getPotionLevel(player, PotionEffectType.JUMP) * 0.05D;
|
||||
}
|
||||
|
||||
// Adjust for custom walking speed
|
||||
final double walkSpeedMultiplier = checksConfig.getDouble(CheckType.SPEED, "airSpeed",
|
||||
"walkSpeedMultiplier"); // Default 1.4
|
||||
predict += walkSpeedMultiplier * (Math.pow(1.1, ((player.getWalkSpeed() / 0.20) - 1)) - 1);
|
||||
|
||||
// Slabs sometimes allow for a slight boost after jump
|
||||
if (movementManager.halfMovementHistoryCounter > 0) {
|
||||
predict *= 2.125D;
|
||||
}
|
||||
if (Utilities.couldBeOnHalfblock(movingTowards) && movementManager.halfMovementHistoryCounter == 0) {
|
||||
predict *= 1.25D;
|
||||
}
|
||||
|
||||
// Boats sometimes give a false positive
|
||||
if (Utilities.couldBeOnBoat(player, 0.5, true)) {
|
||||
predict *= 1.25D;
|
||||
}
|
||||
|
||||
// Strafing in air when nearing terminal velocity gives false positives
|
||||
// This fixes the issue but gives hackers some leniency which means we need
|
||||
// another check for this
|
||||
final double deltaMotionY = movementManager.motionY - movementManager.lastMotionY;
|
||||
if ((deltaMotionY < 0 && deltaMotionY >= -0.08) || movementManager.airTicks >= 40
|
||||
&& (movingTowards.getBlockY() - player.getWorld().getHighestBlockYAt(movingTowards)) <= 1.5) {
|
||||
predict *= (movementManager.airTicks > 60 ? 4.0D : (movementManager.airTicks > 30 ? 3.0D : 2.0D));
|
||||
}
|
||||
|
||||
// Players can move faster in air with slow falling
|
||||
if (VersionLib.isSlowFalling(player)) {
|
||||
predict *= 1.25D;
|
||||
}
|
||||
|
||||
// Prevent NoSlow
|
||||
if (movementManager.blockingTicks > 3 && movementManager.airTicks > 2) {
|
||||
predict *= 0.8D;
|
||||
}
|
||||
if (movementManager.blockingTicks > 10 && movementManager.airTicks > 2) {
|
||||
predict *= 0.5D;
|
||||
}
|
||||
|
||||
// Fixes false positive when coming out of water
|
||||
if (movementManager.nearLiquidTicks >= 7 && movementManager.airTicks >= 14
|
||||
&& movementManager.motionY < -0.18 && movementManager.motionY > -0.182) {
|
||||
predict += Math.abs(movementManager.motionY);
|
||||
}
|
||||
|
||||
// Adjust for velocity
|
||||
limit += velocityTracker.getHorizontal();
|
||||
|
||||
if (distanceXZ - predict > limit) {
|
||||
if (buffer++ > 1.5) {
|
||||
buffer /= 2;
|
||||
AIRSPEED_BUFFER.put(uuid, buffer);
|
||||
return new CheckResult(CheckResult.Result.FAILED, "AirSpeed",
|
||||
"moved too fast in air (speed=" + Utilities.roundDouble(distanceXZ, 4) + ", limit="
|
||||
+ Utilities.roundDouble(predict, 4) + ", block=" + movementManager.blockingTicks
|
||||
+ ", box=" + boxedIn + ", at=" + movementManager.airTicks + ")");
|
||||
}
|
||||
} else {
|
||||
buffer = Math.max(buffer - 0.05, 0.0);
|
||||
}
|
||||
|
||||
AIRSPEED_BUFFER.put(uuid, buffer);
|
||||
}
|
||||
|
||||
// AirAcceleration
|
||||
if (checksConfig.isSubcheckEnabled(CheckType.SPEED, "airAcceleration") && movementManager.airTicks > 1
|
||||
&& movementManager.iceInfluenceTicks <= 0 && movementManager.slimeInfluenceTicks <= 0
|
||||
&& movementManager.elytraEffectTicks <= 0) {
|
||||
final double initialAcceleration = movementManager.acceleration;
|
||||
double buffer = AIRACCELERATION_BUFFER.getOrDefault(uuid, 0.0);
|
||||
double limit = checksConfig.getDouble(CheckType.SPEED, "airAcceleration", "baseLimit"); // Default 0.3725
|
||||
// Slight increase when boxed in
|
||||
if (boxedIn) {
|
||||
limit *= 1.08D;
|
||||
}
|
||||
|
||||
// Adjust for soul speed
|
||||
final ItemStack boots = player.getInventory().getBoots();
|
||||
if (boots != null && movementManager.soilInfluenceTicks > 0 && VersionLib.isSoulSpeed(boots)) {
|
||||
limit += boots.getEnchantmentLevel(Enchantment.SOUL_SPEED) * 0.025D;
|
||||
}
|
||||
|
||||
// Adjust for speed effects
|
||||
if (player.hasPotionEffect(PotionEffectType.SPEED)) {
|
||||
limit += VersionLib.getPotionLevel(player, PotionEffectType.SPEED) * 0.0225D;
|
||||
}
|
||||
|
||||
// Adjust for slabs
|
||||
if (movementManager.halfMovementHistoryCounter > 15) {
|
||||
limit *= 2.05D;
|
||||
}
|
||||
|
||||
// Adjust for custom walking speed
|
||||
final double walkSpeedMultiplier = checksConfig.getDouble(CheckType.SPEED, "airAcceleration",
|
||||
"walkSpeedMultiplier"); // Default 1.4
|
||||
limit += walkSpeedMultiplier * (Math.pow(1.1, ((player.getWalkSpeed() / 0.20) - 1)) - 1);
|
||||
|
||||
// Boats sometimes give a false positive
|
||||
if (Utilities.couldBeOnBoat(player)) {
|
||||
limit *= 1.25D;
|
||||
}
|
||||
|
||||
// Add velocity
|
||||
limit += velocityTracker.getHorizontal();
|
||||
|
||||
if (initialAcceleration > limit) {
|
||||
if (buffer++ > 1.5) {
|
||||
buffer /= 2;
|
||||
AIRACCELERATION_BUFFER.put(uuid, buffer);
|
||||
return new CheckResult(CheckResult.Result.FAILED, "AirAcceleration",
|
||||
"exceeded acceleration limits (acceleration=" + Utilities.roundDouble(initialAcceleration, 4)
|
||||
+ ", max=" + Utilities.roundDouble(limit, 4) + ")");
|
||||
}
|
||||
} else {
|
||||
buffer = Math.max(buffer - 0.05, 0.0);
|
||||
}
|
||||
|
||||
AIRACCELERATION_BUFFER.put(uuid, buffer);
|
||||
}
|
||||
|
||||
// JumpBehaviour
|
||||
// Works against YPorts and mini jumps
|
||||
if (checksConfig.isSubcheckEnabled(CheckType.SPEED, "jumpBehaviour") && movementManager.touchedGroundThisTick
|
||||
&& !boxedIn && movementManager.slimeInfluenceTicks <= 10 && !Utilities.isNearHalfblock(movingTowards)
|
||||
&& !Utilities.isNearHalfblock(movingTowards.clone().subtract(0, 0.51, 0))
|
||||
&& !Utilities.couldBeOnBoat(player, 0.8, false) && movementManager.elytraEffectTicks <= 0) {
|
||||
// This happens naturally
|
||||
if (movementManager.airTicksBeforeGrounded == movementManager.groundTicks) {
|
||||
final double minimumDistXZ = checksConfig.getDouble(CheckType.SPEED, "jumpBehaviour", "minimumDistXZ"); // Default
|
||||
if (distanceXZ >= minimumDistXZ || movementManager.lastDistanceXZ >= minimumDistXZ) {
|
||||
return new CheckResult(CheckResult.Result.FAILED, "JumpBehaviour",
|
||||
"had unexpected jumping behaviour (dXZ=" + Utilities.roundDouble(distanceXZ, 4) + ", lXZ="
|
||||
+ Utilities.roundDouble(movementManager.lastDistanceXZ, 4) + ")");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// GroundSpeed
|
||||
if (checksConfig.isSubcheckEnabled(CheckType.SPEED, "groundSpeed") && movementManager.groundTicks > 1
|
||||
&& movementManager.elytraEffectTicks < 10) {
|
||||
final double initialLimit = checksConfig.getDouble(CheckType.SPEED, "groundSpeed", "initialLimit"); // Default
|
||||
// 0.34
|
||||
double limit = initialLimit - 0.0055 * Math.min(9, movementManager.groundTicks);
|
||||
// Leniency when moving back on ground
|
||||
if (movementManager.groundTicks < 5) {
|
||||
limit += 0.1D;
|
||||
}
|
||||
|
||||
// Slab leniency
|
||||
if (movementManager.halfMovementHistoryCounter > 8) {
|
||||
limit += 0.2D;
|
||||
}
|
||||
|
||||
// LivingEntities can give players a small push boost
|
||||
if (!movingTowards.getWorld().getNearbyEntities(movingTowards, 0.3, 0.3, 0.3).isEmpty()) {
|
||||
limit += 0.2D;
|
||||
}
|
||||
|
||||
// Leniency when boxed in
|
||||
if (boxedIn) {
|
||||
limit *= 1.1D;
|
||||
}
|
||||
|
||||
// Adjust for speed effects
|
||||
if (movementManager.hasSpeedEffect) {
|
||||
limit += VersionLib.getPotionLevel(player, PotionEffectType.SPEED) * 0.06D;
|
||||
}
|
||||
if (movementManager.hasSpeedEffect && movementManager.groundTicks > 3) {
|
||||
limit *= 1.4D;
|
||||
}
|
||||
if (movementManager.hadSpeedEffect && !movementManager.hasSpeedEffect) {
|
||||
limit *= 1.2D;
|
||||
}
|
||||
|
||||
// Ice adjustments
|
||||
if (movementManager.iceInfluenceTicks >= 50) {
|
||||
// When moving off ice
|
||||
if (!Utilities.couldBeOnIce(movingTowards)) {
|
||||
limit *= 2.5D;
|
||||
} else {
|
||||
// When boxed in and spamming space for boost
|
||||
if (movementManager.topSolid && movementManager.bottomSolid) {
|
||||
limit *= 3.0D;
|
||||
} else {
|
||||
limit *= 1.25D;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Increased speed when stepping on/off half blocks
|
||||
if (Utilities.isNearBed(movingTowards) || Utilities.couldBeOnHalfblock(movingTowards)
|
||||
|| Utilities.isNearBed(movingTowards.clone().add(0, -0.5, 0))) {
|
||||
limit *= 2.0D;
|
||||
}
|
||||
|
||||
// Increased speed when stepping on/off boat
|
||||
if (Utilities.couldBeOnBoat(player)) {
|
||||
limit += 0.2D;
|
||||
}
|
||||
|
||||
// Adjust for custom walk speed
|
||||
limit += (player.getWalkSpeed() - 0.2) * 2.0D;
|
||||
|
||||
// Prevent NoSlow
|
||||
if (player.isBlocking() && movementManager.groundTicks > 2) {
|
||||
limit *= 0.45D;
|
||||
}
|
||||
|
||||
// Prevent NoWeb
|
||||
if (Utilities.isInWeb(player)) {
|
||||
limit *= 0.65D;
|
||||
}
|
||||
|
||||
// Sneak speed check
|
||||
if (movementManager.sneakingTicks > 1) {
|
||||
limit *= 0.68D;
|
||||
}
|
||||
|
||||
// Velocity adjustment
|
||||
limit += velocityTracker.getHorizontal();
|
||||
|
||||
if (distanceXZ - limit > 0) {
|
||||
return new CheckResult(CheckResult.Result.FAILED, "GroundSpeed",
|
||||
"moved too fast on ground (speed=" + Utilities.roundDouble(distanceXZ, 4) + ", limit="
|
||||
+ Utilities.roundDouble(limit, 4) + ", blocking=" + player.isBlocking() + ", gt="
|
||||
+ movementManager.groundTicks + ")");
|
||||
}
|
||||
}
|
||||
|
||||
return PASS;
|
||||
}
|
||||
|
||||
public static CheckResult checkVerticalSpeed(final Player player, final Distance distance) {
|
||||
final Backend backend = AntiCheatReloaded.getManager().getBackend();
|
||||
if (isSpeedExempt(player, backend) || player.getVehicle() != null || player.isSleeping()
|
||||
|| Utilities.isNearWater(player)) {
|
||||
return PASS;
|
||||
}
|
||||
|
||||
final User user = AntiCheatReloaded.getManager().getUserManager().getUser(player.getUniqueId());
|
||||
final MovementManager movementManager = user.getMovementManager();
|
||||
final VelocityTracker velocityTracker = user.getVelocityTracker();
|
||||
// Riptiding exemption
|
||||
if (movementManager.riptideTicks > 0) {
|
||||
return PASS;
|
||||
}
|
||||
|
||||
final Checks checksConfig = AntiCheatReloaded.getManager().getConfiguration().getChecks();
|
||||
if (!checksConfig.isSubcheckEnabled(CheckType.SPEED, "verticalSpeed")) {
|
||||
return PASS;
|
||||
}
|
||||
|
||||
double maxMotionY = getMaxAcceptableMotionY(player, Utilities.isNearBed(distance.getTo()),
|
||||
Utilities.couldBeOnBoat(player),
|
||||
Utilities.isClimbableBlock(distance.getFrom().getBlock())
|
||||
|| Utilities.isClimbableBlock(distance.getFrom().getBlock().getRelative(BlockFace.DOWN)),
|
||||
(movementManager.halfMovement || Utilities.isNearWall(distance.getFrom())), checksConfig);
|
||||
// Fix false positive with soulsand boost
|
||||
if (movementManager.nearLiquidTicks > 6) {
|
||||
maxMotionY *= 1.0525D;
|
||||
}
|
||||
|
||||
// Adjust for powdered snow
|
||||
if (distance.getFrom().getBlock().getType() == XMaterial.POWDER_SNOW.parseMaterial()) {
|
||||
maxMotionY += 0.17D;
|
||||
}
|
||||
|
||||
// Adjust for velocity
|
||||
maxMotionY += velocityTracker.getVertical();
|
||||
|
||||
if (movementManager.motionY > maxMotionY && movementManager.slimeInfluenceTicks <= 0) {
|
||||
return new CheckResult(CheckResult.Result.FAILED, "VerticalSpeed",
|
||||
"exceeded vertical speed limit (mY=" + Utilities.roundDouble(movementManager.motionY, 4) + ", max="
|
||||
+ Utilities.roundDouble(maxMotionY, 4) + ")");
|
||||
}
|
||||
return PASS;
|
||||
}
|
||||
|
||||
private static double getMaxAcceptableMotionY(final Player player, final boolean nearBed,
|
||||
final boolean couldBeOnBoat, final boolean fromClimbable, final boolean halfMovement,
|
||||
final Checks checksConfig) {
|
||||
double base = couldBeOnBoat ? 0.6f : (nearBed ? 0.5625f : ((halfMovement) ? 0.6f : 0.42f));
|
||||
if (fromClimbable) {
|
||||
base += checksConfig.getDouble(CheckType.SPEED, "verticalSpeed", "climbableCompensation"); // Default 0.04
|
||||
}
|
||||
|
||||
if (player.hasPotionEffect(PotionEffectType.JUMP)) {
|
||||
base += VersionLib.getPotionLevel(player, PotionEffectType.JUMP) * 0.2D;
|
||||
}
|
||||
return base;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,82 @@
|
||||
/*
|
||||
* AntiCheatReloaded for Bukkit and Spigot.
|
||||
* Copyright (c) 2012-2015 AntiCheat Team
|
||||
* Copyright (c) 2016-2022 Rammelkast
|
||||
*
|
||||
* 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 3 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, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.rammelkast.anticheatreloaded.check.movement;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
|
||||
import com.rammelkast.anticheatreloaded.check.CheckResult;
|
||||
import com.rammelkast.anticheatreloaded.check.CheckResult.Result;
|
||||
import com.rammelkast.anticheatreloaded.check.CheckType;
|
||||
import com.rammelkast.anticheatreloaded.config.providers.Checks;
|
||||
import com.rammelkast.anticheatreloaded.util.MovementManager;
|
||||
import com.rammelkast.anticheatreloaded.util.User;
|
||||
import com.rammelkast.anticheatreloaded.util.Utilities;
|
||||
import com.rammelkast.anticheatreloaded.util.VelocityTracker;
|
||||
import com.rammelkast.anticheatreloaded.util.VersionLib;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Rammelkast
|
||||
*
|
||||
*/
|
||||
public final class StrafeCheck {
|
||||
|
||||
private static final CheckResult PASS = new CheckResult(CheckResult.Result.PASSED);
|
||||
|
||||
public static CheckResult runCheck(final Player player, final double x, final double z, final Location from,
|
||||
final Location to) {
|
||||
if (!Utilities.cantStandAtExp(from) || !Utilities.cantStandAtExp(to) || Utilities.isNearWater(player)
|
||||
|| Utilities.isNearClimbable(player) || VersionLib.isFlying(player) || player.isDead()
|
||||
|| Utilities.isHalfblock(to.getBlock().getRelative(BlockFace.DOWN)) || Utilities.isNearHalfblock(to)) {
|
||||
return PASS;
|
||||
}
|
||||
|
||||
final User user = AntiCheatReloaded.getManager().getUserManager().getUser(player.getUniqueId());
|
||||
final MovementManager movementManager = user.getMovementManager();
|
||||
final VelocityTracker velocityTracker = user.getVelocityTracker();
|
||||
if (velocityTracker.isVelocitized()) {
|
||||
return PASS;
|
||||
}
|
||||
|
||||
final Checks checksConfig = AntiCheatReloaded.getManager().getConfiguration().getChecks();
|
||||
|
||||
if (System.currentTimeMillis() - movementManager.lastTeleport <= checksConfig.getInteger(CheckType.STRAFE,
|
||||
"accountForTeleports") || movementManager.elytraEffectTicks >= 20
|
||||
|| movementManager.halfMovementHistoryCounter >= 20 || Utilities.couldBeOnBoat(player, 0.5, false)) {
|
||||
return PASS;
|
||||
}
|
||||
|
||||
final Vector oldAcceleration = new Vector(movementManager.lastDistanceX, 0, movementManager.lastDistanceZ);
|
||||
final Vector newAcceleration = new Vector(x, 0, z);
|
||||
|
||||
final float angle = newAcceleration.angle(oldAcceleration);
|
||||
final double distance = newAcceleration.lengthSquared();
|
||||
if (angle > checksConfig.getDouble(CheckType.STRAFE, "maxAngleChange")
|
||||
&& distance > checksConfig.getDouble(CheckType.STRAFE, "minActivationDistance")
|
||||
&& Utilities.cantStandFar(to.getBlock())) {
|
||||
return new CheckResult(Result.FAILED, "switched angle in air (angle=" + angle + ", dist=" + distance + ")");
|
||||
}
|
||||
return PASS;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,104 +1,96 @@
|
||||
/*
|
||||
* AntiCheatReloaded for Bukkit and Spigot.
|
||||
* Copyright (c) 2012-2015 AntiCheat Team
|
||||
* Copyright (c) 2016-2022 Rammelkast
|
||||
*
|
||||
* 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 3 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, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.rammelkast.anticheatreloaded.check.movement;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.potion.PotionEffectType;
|
||||
|
||||
import com.rammelkast.anticheatreloaded.AntiCheat;
|
||||
import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
|
||||
import com.rammelkast.anticheatreloaded.check.CheckResult;
|
||||
import com.rammelkast.anticheatreloaded.check.CheckResult.Result;
|
||||
import com.rammelkast.anticheatreloaded.check.CheckType;
|
||||
import com.rammelkast.anticheatreloaded.config.providers.Checks;
|
||||
import com.rammelkast.anticheatreloaded.util.MovementManager;
|
||||
import com.rammelkast.anticheatreloaded.util.User;
|
||||
import com.rammelkast.anticheatreloaded.util.Utilities;
|
||||
import com.rammelkast.anticheatreloaded.util.VersionLib;
|
||||
|
||||
/**
|
||||
* This check seems to be broken/outdated
|
||||
*/
|
||||
public class WaterWalkCheck {
|
||||
public final class WaterWalkCheck {
|
||||
|
||||
private static final CheckResult PASS = new CheckResult(CheckResult.Result.PASSED);
|
||||
|
||||
public static List<UUID> isInWater = new ArrayList<UUID>();
|
||||
public static List<UUID> isInWaterCache = new ArrayList<UUID>();
|
||||
public static Map<UUID, Integer> waterSpeedViolation = new HashMap<UUID, Integer>();
|
||||
public static Map<UUID, Integer> waterAscensionViolation = new HashMap<UUID, Integer>();
|
||||
public static CheckResult runCheck(final Player player, final double x, final double y, final double z) {
|
||||
final UUID uuid = player.getUniqueId();
|
||||
final User user = AntiCheatReloaded.getManager().getUserManager().getUser(uuid);
|
||||
final MovementManager movementManager = user.getMovementManager();
|
||||
|
||||
/**
|
||||
* TODO check & fix for 1.11? (see #25)
|
||||
*/
|
||||
public static CheckResult runCheck(Player player, double x, double y, double z) {
|
||||
Block block = player.getLocation().getBlock();
|
||||
UUID uuid = player.getUniqueId();
|
||||
if (movementManager.distanceXZ <= 0 || player.getVehicle() != null || Utilities.isOnLilyPad(player) || Utilities.isOnCarpet(player)
|
||||
|| movementManager.riptideTicks > 0 || VersionLib.isSwimming(player) || VersionLib.isFlying(player) || user.getVelocityTracker().isVelocitized()) {
|
||||
return PASS;
|
||||
}
|
||||
|
||||
if (player.getVehicle() == null && !player.isFlying()) {
|
||||
if (block.isLiquid()) {
|
||||
if (isInWater.contains(uuid)) {
|
||||
if (isInWaterCache.contains(uuid)) {
|
||||
if (player.getNearbyEntities(1, 1, 1).isEmpty()) {
|
||||
boolean b;
|
||||
if (!Utilities.sprintFly(player)) {
|
||||
b = x > AntiCheat.getManager().getBackend().getMagic().XZ_SPEED_MAX_WATER()
|
||||
|| z > AntiCheat.getManager().getBackend().getMagic().XZ_SPEED_MAX_WATER();
|
||||
} else {
|
||||
b = x > AntiCheat.getManager().getBackend().getMagic().XZ_SPEED_MAX_WATER_SPRINT()
|
||||
|| z > AntiCheat.getManager().getBackend().getMagic()
|
||||
.XZ_SPEED_MAX_WATER_SPRINT();
|
||||
}
|
||||
if (!b && !Utilities.isFullyInWater(player.getLocation())
|
||||
&& Utilities.isHoveringOverWater(player.getLocation(), 1) && y == 0D
|
||||
&& !block.getType().equals(Material.WATER_LILY)) {
|
||||
b = true;
|
||||
}
|
||||
if (b) {
|
||||
if (waterSpeedViolation.containsKey(uuid)) {
|
||||
int v = waterSpeedViolation.get(uuid);
|
||||
if (v >= AntiCheat.getManager().getBackend().getMagic()
|
||||
.WATER_SPEED_VIOLATION_MAX()) {
|
||||
waterSpeedViolation.put(uuid, 0);
|
||||
return new CheckResult(CheckResult.Result.FAILED,
|
||||
player.getName() + " stood on water " + v + " times (can't stand on "
|
||||
+ block.getType() + " or "
|
||||
+ block.getRelative(BlockFace.DOWN).getType() + ")");
|
||||
} else {
|
||||
waterSpeedViolation.put(uuid, v + 1);
|
||||
}
|
||||
} else {
|
||||
waterSpeedViolation.put(uuid, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
isInWaterCache.add(uuid);
|
||||
return PASS;
|
||||
}
|
||||
} else {
|
||||
isInWater.add(uuid);
|
||||
return PASS;
|
||||
}
|
||||
} else if (block.getRelative(BlockFace.DOWN).isLiquid()
|
||||
&& !AntiCheat.getManager().getBackend().isAscending(player) && Utilities.cantStandAt(block)
|
||||
&& Utilities.cantStandAt(block.getRelative(BlockFace.DOWN))) {
|
||||
if (waterAscensionViolation.containsKey(uuid)) {
|
||||
int v = waterAscensionViolation.get(uuid);
|
||||
if (v >= AntiCheat.getManager().getBackend().getMagic().WATER_ASCENSION_VIOLATION_MAX()) {
|
||||
waterAscensionViolation.put(uuid, 0);
|
||||
return new CheckResult(CheckResult.Result.FAILED,
|
||||
player.getName() + " stood on water " + v + " times (can't stand on " + block.getType()
|
||||
+ " or " + block.getRelative(BlockFace.DOWN).getType() + ")");
|
||||
} else {
|
||||
waterAscensionViolation.put(uuid, v + 1);
|
||||
}
|
||||
} else {
|
||||
waterAscensionViolation.put(uuid, 1);
|
||||
}
|
||||
} else {
|
||||
isInWater.remove(uuid);
|
||||
isInWaterCache.remove(uuid);
|
||||
}
|
||||
final Checks checksConfig = AntiCheatReloaded.getManager().getConfiguration().getChecks();
|
||||
final Block blockBeneath = player.getLocation().clone().subtract(0, 0.1, 0).getBlock();
|
||||
if (checksConfig.isSubcheckEnabled(CheckType.WATER_WALK, "walk") && blockBeneath.isLiquid()
|
||||
&& Utilities.isSurroundedByWater(player)
|
||||
&& ((movementManager.motionY == 0 && movementManager.lastMotionY == 0)
|
||||
|| movementManager.motionY == Utilities.JUMP_MOTION_Y)
|
||||
&& movementManager.distanceXZ > checksConfig.getDouble(CheckType.WATER_WALK, "walk", "minimumDistXZ")
|
||||
&& !movementManager.topSolid && !Utilities.couldBeOnBoat(player, 3, false)) {
|
||||
return new CheckResult(Result.FAILED, "Walk",
|
||||
"tried to walk on water (xz=" + Utilities.roundDouble(movementManager.distanceXZ, 5) + ")");
|
||||
}
|
||||
|
||||
if (checksConfig.isSubcheckEnabled(CheckType.WATER_WALK, "hop") && blockBeneath.isLiquid()
|
||||
&& Utilities.isSurroundedByWater(player) && movementManager.onGround
|
||||
&& Math.abs(movementManager.motionY) < checksConfig.getDouble(CheckType.WATER_WALK, "hop", "maxMotionY")
|
||||
&& !Utilities.couldBeOnBoat(player, 0.3, false)) {
|
||||
return new CheckResult(Result.FAILED, "Hop",
|
||||
"tried to hop on water (mY=" + Utilities.roundDouble(movementManager.motionY, 5) + ")");
|
||||
}
|
||||
|
||||
final double minAbsMotionY = 0.12D + (VersionLib.getPotionLevel(player, PotionEffectType.SPEED) * 0.05D);
|
||||
if (checksConfig.isSubcheckEnabled(CheckType.WATER_WALK, "lunge") && blockBeneath.isLiquid()
|
||||
&& Utilities.isSurroundedByWater(player)
|
||||
&& Math.abs(movementManager.lastMotionY - movementManager.motionY) > minAbsMotionY
|
||||
&& movementManager.distanceXZ > checksConfig.getDouble(CheckType.WATER_WALK, "lunge", "minimumDistXZ")
|
||||
&& movementManager.lastMotionY > -0.25
|
||||
&& !Utilities.couldBeOnBoat(player, 0.3, false)) {
|
||||
return new CheckResult(Result.FAILED, "Lunge", "tried to lunge in water (xz="
|
||||
+ Utilities.roundDouble(movementManager.distanceXZ, 5) + ", absMotionY="
|
||||
+ Utilities.roundDouble(Math.abs(movementManager.lastMotionY - movementManager.motionY), 5) + ")");
|
||||
}
|
||||
|
||||
if (checksConfig.isSubcheckEnabled(CheckType.WATER_WALK, "lunge") && Utilities.isSurroundedByWater(player)
|
||||
&& movementManager.distanceXZ > 0.16 && movementManager.motionY > 0.0
|
||||
&& movementManager.lastMotionY < 0.0
|
||||
&& (Math.abs(movementManager.motionY) < 0.017 && Math.abs(movementManager.lastMotionY) < 0.02)
|
||||
&& Math.abs(movementManager.lastMotionY - 0.004) < 0.021
|
||||
&& user.getVelocityTracker().getHorizontal() < 0.04
|
||||
&& !Utilities.couldBeOnBoat(player, 0.3, false)) {
|
||||
return new CheckResult(Result.FAILED, "Lunge", "tried to lunge in water (xz="
|
||||
+ Utilities.roundDouble(movementManager.distanceXZ, 5) + ", motionY="
|
||||
+ Utilities.roundDouble(movementManager.motionY, 5) + ", lastMotionY="
|
||||
+ Utilities.roundDouble(movementManager.lastMotionY, 5) + ")");
|
||||
}
|
||||
return PASS;
|
||||
}
|
||||
|
||||
@@ -1,111 +0,0 @@
|
||||
package com.rammelkast.anticheatreloaded.check.movement;
|
||||
|
||||
import java.util.EnumSet;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.potion.PotionEffectType;
|
||||
|
||||
import com.rammelkast.anticheatreloaded.AntiCheat;
|
||||
import com.rammelkast.anticheatreloaded.check.CheckResult;
|
||||
import com.rammelkast.anticheatreloaded.util.Distance;
|
||||
import com.rammelkast.anticheatreloaded.util.Utilities;
|
||||
import com.rammelkast.anticheatreloaded.util.VersionUtil;
|
||||
|
||||
public class YAxisCheck {
|
||||
|
||||
private static final CheckResult PASS = new CheckResult(CheckResult.Result.PASSED);
|
||||
|
||||
public static Map<UUID, Double> lastYcoord = new HashMap<UUID, Double>();
|
||||
public static Map<UUID, Long> lastYtime = new HashMap<UUID, Long>();
|
||||
public static Map<UUID, Integer> yAxisViolations = new HashMap<UUID, Integer>();
|
||||
public static Map<UUID, Long> yAxisLastViolation = new HashMap<UUID, Long>();
|
||||
|
||||
private static boolean hasJumpPotion(Player player) {
|
||||
return player.hasPotionEffect(PotionEffectType.JUMP);
|
||||
}
|
||||
|
||||
public static CheckResult runCheck(Player player, Distance distance) {
|
||||
if (distance.getYDifference() > AntiCheat.getManager().getBackend().getMagic().TELEPORT_MIN()
|
||||
|| distance.getYDifference() < 0 || VersionUtil.isFlying(player)) {
|
||||
return PASS;
|
||||
}
|
||||
if (!FlightCheck.isMovingExempt(player) && !Utilities.isClimbableBlock(player.getLocation().getBlock())
|
||||
&& !Utilities.isClimbableBlock(player.getLocation().add(0, -1, 0).getBlock())
|
||||
&& !player.isInsideVehicle() && !Utilities.isInWater(player) && !hasJumpPotion(player)
|
||||
&& !isMoveUpBlock(player.getLocation().add(0, -1, 0).getBlock())
|
||||
&& !isMoveUpBlock(player.getLocation().add(0, -1.5, 0).getBlock())) {
|
||||
double y1 = player.getLocation().getY();
|
||||
UUID uuid = player.getUniqueId();
|
||||
// Fix Y axis spam.
|
||||
if (!lastYcoord.containsKey(uuid) || !lastYtime.containsKey(uuid)
|
||||
|| !yAxisLastViolation.containsKey(uuid)) {
|
||||
lastYcoord.put(uuid, y1);
|
||||
yAxisViolations.put(uuid, 0);
|
||||
yAxisLastViolation.put(uuid, 0L);
|
||||
lastYtime.put(uuid, System.currentTimeMillis());
|
||||
} else {
|
||||
if (y1 > lastYcoord.get(uuid)
|
||||
&& yAxisViolations.get(uuid) > AntiCheat.getManager().getBackend().getMagic().Y_MAXVIOLATIONS()
|
||||
&& (System.currentTimeMillis() - yAxisLastViolation.get(uuid)) < AntiCheat.getManager()
|
||||
.getBackend().getMagic().Y_MAXVIOTIME()) {
|
||||
Location g = player.getLocation();
|
||||
yAxisViolations.put(uuid, yAxisViolations.get(uuid) + 1);
|
||||
yAxisLastViolation.put(uuid, System.currentTimeMillis());
|
||||
if (!AntiCheat.getManager().getBackend().silentMode()) {
|
||||
g.setY(lastYcoord.get(uuid));
|
||||
if (g.getBlock().getType() == Material.AIR) {
|
||||
player.teleport(g);
|
||||
}
|
||||
}
|
||||
return new CheckResult(CheckResult.Result.FAILED,
|
||||
player.getName() + " tried to fly on y-axis " + yAxisViolations.get(uuid) + " times (max ="
|
||||
+ AntiCheat.getManager().getBackend().getMagic().Y_MAXVIOLATIONS() + ")");
|
||||
} else {
|
||||
if (yAxisViolations.get(uuid) > AntiCheat.getManager().getBackend().getMagic().Y_MAXVIOLATIONS()
|
||||
&& (System.currentTimeMillis() - yAxisLastViolation.get(uuid)) > AntiCheat.getManager()
|
||||
.getBackend().getMagic().Y_MAXVIOTIME()) {
|
||||
yAxisViolations.put(uuid, 0);
|
||||
yAxisLastViolation.put(uuid, 0L);
|
||||
}
|
||||
}
|
||||
long i = System.currentTimeMillis() - lastYtime.get(uuid);
|
||||
double diff = AntiCheat.getManager().getBackend().getMagic().Y_MAXDIFF()
|
||||
+ (Utilities.isStair(player.getLocation().add(0, -1, 0).getBlock()) ? 0.5 : 0.0);
|
||||
if ((y1 - lastYcoord.get(uuid)) > diff && i < AntiCheat.getManager().getBackend().getMagic().Y_TIME()) {
|
||||
Location g = player.getLocation();
|
||||
yAxisViolations.put(uuid, yAxisViolations.get(uuid) + 1);
|
||||
yAxisLastViolation.put(uuid, System.currentTimeMillis());
|
||||
if (!AntiCheat.getManager().getBackend().silentMode()) {
|
||||
g.setY(lastYcoord.get(uuid));
|
||||
if (g.getBlock().getType() == Material.AIR) {
|
||||
player.teleport(g);
|
||||
}
|
||||
}
|
||||
return new CheckResult(CheckResult.Result.FAILED, player.getName() + " tried to fly on y-axis in "
|
||||
+ i + " ms (min =" + AntiCheat.getManager().getBackend().getMagic().Y_TIME() + ")");
|
||||
} else {
|
||||
if ((y1 - lastYcoord.get(uuid)) > AntiCheat.getManager().getBackend().getMagic().Y_MAXDIFF() + 1
|
||||
|| (System.currentTimeMillis() - lastYtime.get(uuid)) > AntiCheat.getManager().getBackend()
|
||||
.getMagic().Y_TIME()) {
|
||||
lastYtime.put(uuid, System.currentTimeMillis());
|
||||
lastYcoord.put(uuid, y1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// Fix Y axis spam
|
||||
return PASS;
|
||||
}
|
||||
|
||||
public static boolean isMoveUpBlock(Block block) {
|
||||
return VersionUtil.getMoveUpBlocks().contains(block.getType());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,107 @@
|
||||
/*
|
||||
* AntiCheatReloaded for Bukkit and Spigot.
|
||||
* Copyright (c) 2012-2015 AntiCheat Team
|
||||
* Copyright (c) 2016-2022 Rammelkast
|
||||
*
|
||||
* 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 3 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, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.rammelkast.anticheatreloaded.check.packet;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.comphenix.protocol.events.PacketContainer;
|
||||
import com.comphenix.protocol.events.PacketEvent;
|
||||
import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
|
||||
import com.rammelkast.anticheatreloaded.check.Backend;
|
||||
import com.rammelkast.anticheatreloaded.check.CheckResult;
|
||||
import com.rammelkast.anticheatreloaded.check.CheckType;
|
||||
import com.rammelkast.anticheatreloaded.config.providers.Checks;
|
||||
import com.rammelkast.anticheatreloaded.event.EventListener;
|
||||
import com.rammelkast.anticheatreloaded.util.MovementManager;
|
||||
import com.rammelkast.anticheatreloaded.util.User;
|
||||
import com.rammelkast.anticheatreloaded.util.Utilities;
|
||||
|
||||
public final class BadPacketsCheck {
|
||||
|
||||
public static void runCheck(final Player player, final PacketEvent event) {
|
||||
if (event.isCancelled()) {
|
||||
// Do not check if cancelled
|
||||
return;
|
||||
}
|
||||
|
||||
final Backend backend = AntiCheatReloaded.getManager().getBackend();
|
||||
// Confirm if we should even check for BadPackets
|
||||
if (!AntiCheatReloaded.getManager().getCheckManager().willCheck(player, CheckType.BADPACKETS)
|
||||
|| backend.isMovingExempt(player) || player.isDead()) {
|
||||
return;
|
||||
}
|
||||
|
||||
final User user = AntiCheatReloaded.getManager().getUserManager().getUser(player.getUniqueId());
|
||||
final PacketContainer packet = event.getPacket();
|
||||
final float pitch = packet.getFloat().read(1);
|
||||
// Check for derp
|
||||
if (Math.abs(pitch) > 90) {
|
||||
flag(player, event, "had an illegal pitch", null);
|
||||
return;
|
||||
}
|
||||
|
||||
final Checks checksConfig = AntiCheatReloaded.getManager().getConfiguration().getChecks();
|
||||
final double tps = AntiCheatReloaded.getPlugin().getTPS();
|
||||
final MovementManager movementManager = AntiCheatReloaded.getManager().getUserManager()
|
||||
.getUser(player.getUniqueId()).getMovementManager();
|
||||
if (user.isLagging() || tps < checksConfig.getDouble(CheckType.BADPACKETS, "minimumTps")
|
||||
|| (System.currentTimeMillis() - movementManager.lastTeleport <= checksConfig
|
||||
.getInteger(CheckType.BADPACKETS, "teleportCompensation"))) {
|
||||
return;
|
||||
}
|
||||
|
||||
final double x = packet.getDoubles().read(0);
|
||||
final double y = packet.getDoubles().read(1);
|
||||
final double z = packet.getDoubles().read(2);
|
||||
final float yaw = packet.getFloat().read(0);
|
||||
// Create location from new data
|
||||
final Location previous = player.getLocation().clone();
|
||||
// Only take horizontal distance
|
||||
previous.setY(0);
|
||||
final Location current = new Location(previous.getWorld(), x, 0, z, yaw, pitch);
|
||||
final double distanceHorizontal = previous.distanceSquared(current);
|
||||
final double distanceVertical = y - player.getLocation().getY();
|
||||
final double maxDistanceHorizontal = checksConfig.getDouble(CheckType.BADPACKETS, "maxDistance")
|
||||
+ user.getVelocityTracker().getHorizontal();
|
||||
if (distanceHorizontal > maxDistanceHorizontal) {
|
||||
flag(player, event,
|
||||
"moved too far between packets (HT, distance=" + Utilities.roundDouble(distanceHorizontal, 1)
|
||||
+ ", max=" + Utilities.roundDouble(maxDistanceHorizontal, 1) + ")", user.getGoodLocation(previous));
|
||||
return;
|
||||
}
|
||||
|
||||
if (distanceVertical < -4.0D && user.getVelocityTracker().getVertical() == 0.0D) {
|
||||
flag(player, event, "moved too far between packets (VT, distance="
|
||||
+ Utilities.roundDouble(Math.abs(distanceVertical), 1) + ", max=4.0)", user.getGoodLocation(previous));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
private static void flag(final Player player, final PacketEvent event, final String message, final Location setback) {
|
||||
event.setCancelled(true);
|
||||
// We are currently not in the main server thread, so switch
|
||||
AntiCheatReloaded.sendToMainThread(() -> {
|
||||
EventListener.log(new CheckResult(CheckResult.Result.FAILED, message).getMessage(), player,
|
||||
CheckType.BADPACKETS, null);
|
||||
player.teleport(setback != null ? setback : player.getLocation());
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,110 @@
|
||||
/*
|
||||
* AntiCheatReloaded for Bukkit and Spigot.
|
||||
* Copyright (c) 2012-2015 AntiCheat Team
|
||||
* Copyright (c) 2016-2022 Rammelkast
|
||||
*
|
||||
* 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 3 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, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.rammelkast.anticheatreloaded.check.packet;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.comphenix.protocol.events.PacketEvent;
|
||||
import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
|
||||
import com.rammelkast.anticheatreloaded.check.CheckResult;
|
||||
import com.rammelkast.anticheatreloaded.check.CheckType;
|
||||
import com.rammelkast.anticheatreloaded.config.providers.Checks;
|
||||
import com.rammelkast.anticheatreloaded.event.EventListener;
|
||||
import com.rammelkast.anticheatreloaded.util.User;
|
||||
|
||||
/**
|
||||
* @author Rammelkast
|
||||
*/
|
||||
public final class MorePacketsCheck {
|
||||
|
||||
public static final Map<UUID, Long> LAST_PACKET_TIME = new HashMap<UUID, Long>();
|
||||
public static final Map<UUID, Long> EXEMPT_TIMINGS = new HashMap<UUID, Long>();
|
||||
public static final Map<UUID, Double> PACKET_BALANCE = new HashMap<UUID, Double>();
|
||||
|
||||
public static void runCheck(final Player player, final PacketEvent event) {
|
||||
if (event.isCancelled()) {
|
||||
// Do not check if cancelled
|
||||
return;
|
||||
}
|
||||
|
||||
// Confirm if we should even check for MorePackets
|
||||
final Checks checksConfig = AntiCheatReloaded.getManager().getConfiguration().getChecks();
|
||||
final double tps = AntiCheatReloaded.getPlugin().getTPS();
|
||||
if (!AntiCheatReloaded.getManager().getCheckManager().willCheck(player, CheckType.MOREPACKETS)
|
||||
|| tps < checksConfig.getDouble(CheckType.MOREPACKETS, "minimumTps")) {
|
||||
return;
|
||||
}
|
||||
|
||||
final UUID uuid = player.getUniqueId();
|
||||
final User user = AntiCheatReloaded.getManager().getUserManager().getUser(uuid);
|
||||
final int maxPing = checksConfig.getInteger(CheckType.MOREPACKETS, "maxPing");
|
||||
final boolean disableForLagging = checksConfig.getBoolean(CheckType.MOREPACKETS, "disableForLagging");
|
||||
if (AntiCheatReloaded.getManager().getBackend().isDoing(player, EXEMPT_TIMINGS, -1)
|
||||
|| (maxPing > 0 && user.getPing() > maxPing) || (disableForLagging && user.isLagging())) {
|
||||
return;
|
||||
}
|
||||
|
||||
final long packetTimeNow = System.currentTimeMillis();
|
||||
final long lastPacketTime = LAST_PACKET_TIME.getOrDefault(uuid, packetTimeNow - 50L);
|
||||
double packetBalance = PACKET_BALANCE.getOrDefault(uuid, 0D);
|
||||
|
||||
final long rate = packetTimeNow - lastPacketTime;
|
||||
packetBalance += 50;
|
||||
packetBalance -= rate;
|
||||
final int triggerBalance = checksConfig.getInteger(CheckType.MOREPACKETS, "triggerBalance");
|
||||
final int minimumClamp = checksConfig.getInteger(CheckType.MOREPACKETS, "minimumClamp");
|
||||
if (packetBalance >= triggerBalance) {
|
||||
final int ticks = (int) Math.round(packetBalance / 50);
|
||||
packetBalance = -1 * (triggerBalance / 2);
|
||||
flag(player, event, "overshot timer by " + ticks + " tick(s)");
|
||||
} else if (packetBalance < -1 * minimumClamp) {
|
||||
// Clamp minimum, 50ms=1tick of lag leniency
|
||||
packetBalance = -1 * minimumClamp;
|
||||
}
|
||||
|
||||
LAST_PACKET_TIME.put(uuid, packetTimeNow);
|
||||
PACKET_BALANCE.put(uuid, packetBalance);
|
||||
}
|
||||
|
||||
private static void flag(final Player player, final PacketEvent event, final String message) {
|
||||
event.setCancelled(true);
|
||||
// We are currently not in the main server thread, so switch
|
||||
AntiCheatReloaded.sendToMainThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
EventListener.log(new CheckResult(CheckResult.Result.FAILED, message).getMessage(), player,
|
||||
CheckType.MOREPACKETS, null);
|
||||
player.teleport(player.getLocation());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public static void compensate(final Player player) {
|
||||
final UUID uuid = player.getUniqueId();
|
||||
final Checks checksConfig = AntiCheatReloaded.getManager().getConfiguration().getChecks();
|
||||
final double packetBalance = PACKET_BALANCE.getOrDefault(uuid, 0D);
|
||||
PACKET_BALANCE.put(uuid, packetBalance - checksConfig.getInteger(CheckType.MOREPACKETS, "teleportCompensation"));
|
||||
}
|
||||
|
||||
}
|
||||
+134
@@ -0,0 +1,134 @@
|
||||
/*
|
||||
* AntiCheatReloaded for Bukkit and Spigot.
|
||||
* Copyright (c) 2012-2015 AntiCheat Team
|
||||
* Copyright (c) 2016-2022 Rammelkast
|
||||
*
|
||||
* 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 3 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, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.rammelkast.anticheatreloaded.check.player;
|
||||
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.block.BlockBreakEvent;
|
||||
import org.bukkit.event.block.BlockPlaceEvent;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
|
||||
import com.rammelkast.anticheatreloaded.check.CheckResult;
|
||||
import com.rammelkast.anticheatreloaded.check.CheckType;
|
||||
import com.rammelkast.anticheatreloaded.check.combat.KillAuraCheck;
|
||||
import com.rammelkast.anticheatreloaded.config.providers.Checks;
|
||||
import com.rammelkast.anticheatreloaded.util.User;
|
||||
import com.rammelkast.anticheatreloaded.util.Utilities;
|
||||
import com.rammelkast.anticheatreloaded.util.VersionLib;
|
||||
|
||||
public final class IllegalInteractCheck {
|
||||
|
||||
private static final CheckResult PASS = new CheckResult(CheckResult.Result.PASSED);
|
||||
|
||||
public static CheckResult runCheck(final Player player, final Event event) {
|
||||
final Checks checksConfig = AntiCheatReloaded.getManager().getConfiguration().getChecks();
|
||||
if (event instanceof BlockPlaceEvent && checksConfig.isSubcheckEnabled(CheckType.ILLEGAL_INTERACT, "place")) {
|
||||
return checkBlockPlace(player, (BlockPlaceEvent) event);
|
||||
} else if (event instanceof BlockBreakEvent
|
||||
&& checksConfig.isSubcheckEnabled(CheckType.ILLEGAL_INTERACT, "break")) {
|
||||
return checkBlockBreak(player, (BlockBreakEvent) event);
|
||||
} else if (event instanceof PlayerInteractEvent
|
||||
&& checksConfig.isSubcheckEnabled(CheckType.ILLEGAL_INTERACT, "interact")) {
|
||||
return checkInteract(player, (PlayerInteractEvent) event);
|
||||
}
|
||||
return PASS;
|
||||
}
|
||||
|
||||
private static CheckResult checkInteract(final Player player, final PlayerInteractEvent event) {
|
||||
final User user = AntiCheatReloaded.getManager().getUserManager().getUser(player.getUniqueId());
|
||||
final Checks checksConfig = AntiCheatReloaded.getManager().getConfiguration().getChecks();
|
||||
final double distance = player.getEyeLocation().toVector()
|
||||
.distance(event.getClickedBlock().getLocation().toVector());
|
||||
double maxDistance = player.getGameMode() == GameMode.CREATIVE
|
||||
? checksConfig.getDouble(CheckType.ILLEGAL_INTERACT, "interact", "creativeRange")
|
||||
: checksConfig.getDouble(CheckType.ILLEGAL_INTERACT, "interact", "survivalRange");
|
||||
|
||||
maxDistance += user.isLagging() ? 0.12 : 0;
|
||||
maxDistance += user.getPing()
|
||||
* checksConfig.getInteger(CheckType.ILLEGAL_INTERACT, "interact", "pingCompensation");
|
||||
maxDistance += player.getVelocity().length()
|
||||
* checksConfig.getDouble(CheckType.ILLEGAL_INTERACT, "interact", "velocityMultiplier");
|
||||
if (distance > maxDistance) {
|
||||
return new CheckResult(CheckResult.Result.FAILED, "Interact",
|
||||
"tried to interact out of range (dist=" + distance + ", max=" + maxDistance + ")");
|
||||
}
|
||||
return PASS;
|
||||
}
|
||||
|
||||
private static CheckResult checkBlockBreak(final Player player, final BlockBreakEvent event) {
|
||||
if (!isValidTarget(player, event.getBlock())) {
|
||||
return new CheckResult(CheckResult.Result.FAILED, "Break", "tried to break a block which was out of view");
|
||||
}
|
||||
return PASS;
|
||||
}
|
||||
|
||||
private static CheckResult checkBlockPlace(final Player player, final BlockPlaceEvent event) {
|
||||
final BlockFace face = event.getBlock().getFace(event.getBlockAgainst());
|
||||
if (face == null) {
|
||||
return PASS;
|
||||
}
|
||||
|
||||
final Vector vector = new Vector(face.getModX(), face.getModY(), face.getModZ());
|
||||
if (event.getBlock().getType().isSolid()
|
||||
&& player.getLocation().getDirection().angle(vector) > Math.toRadians(90)) {
|
||||
return new CheckResult(CheckResult.Result.FAILED, "Place",
|
||||
"tried to place a block out of their view (angle="
|
||||
+ Utilities.roundFloat(player.getLocation().getDirection().angle(vector), 1)
|
||||
+ ", max=90.0");
|
||||
}
|
||||
return PASS;
|
||||
}
|
||||
|
||||
private static boolean isValidTarget(final Player player, final Block block) {
|
||||
final Checks checksConfig = AntiCheatReloaded.getManager().getConfiguration().getChecks();
|
||||
final double distance = player.getGameMode() == GameMode.CREATIVE ? 6.0
|
||||
: player.getLocation().getDirection().getY() > 0.9 ? 6.0 : 5.5;
|
||||
final Block targetBlock = VersionLib.getTargetBlock(player, ((int) Math.ceil(distance)));
|
||||
if (targetBlock == null) {
|
||||
// TODO better check here
|
||||
return true;
|
||||
}
|
||||
|
||||
if (Utilities.isClimbableBlock(targetBlock)) {
|
||||
if (targetBlock.getLocation().distance(player.getLocation()) <= distance) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
if (targetBlock.equals(block)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
final Location eyeLocation = player.getEyeLocation();
|
||||
final double yawDifference = KillAuraCheck.calculateYawDifference(eyeLocation, block.getLocation());
|
||||
final double playerYaw = player.getEyeLocation().getYaw();
|
||||
final double angleDifference = Math.abs(180 - Math.abs(Math.abs(yawDifference - playerYaw) - 180));
|
||||
if (Math.round(angleDifference) > checksConfig.getInteger(CheckType.ILLEGAL_INTERACT, "maxAngleDifference")) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,80 @@
|
||||
/*
|
||||
* AntiCheatReloaded for Bukkit and Spigot.
|
||||
* Copyright (c) 2012-2015 AntiCheat Team
|
||||
* Copyright (c) 2016-2022 Rammelkast
|
||||
*
|
||||
* 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 3 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, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.rammelkast.anticheatreloaded.check.player;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
|
||||
import com.rammelkast.anticheatreloaded.check.Backend;
|
||||
import com.rammelkast.anticheatreloaded.check.CheckResult;
|
||||
import com.rammelkast.anticheatreloaded.check.CheckType;
|
||||
import com.rammelkast.anticheatreloaded.config.providers.Checks;
|
||||
import com.rammelkast.anticheatreloaded.util.Utilities;
|
||||
import com.rammelkast.anticheatreloaded.util.VersionLib;
|
||||
|
||||
public final class NoFallCheck {
|
||||
|
||||
public static final Map<UUID, Integer> VIOLATIONS = new HashMap<>();
|
||||
|
||||
private static final CheckResult PASS = new CheckResult(CheckResult.Result.PASSED);
|
||||
|
||||
public static CheckResult runCheck(final Player player, final double motionY) {
|
||||
final UUID uuid = player.getUniqueId();
|
||||
final Backend backend = AntiCheatReloaded.getManager().getBackend();
|
||||
final Checks checksConfig = AntiCheatReloaded.getManager().getConfiguration().getChecks();
|
||||
if (player.getGameMode() != GameMode.CREATIVE && !player.isInsideVehicle() && !player.isSleeping()
|
||||
&& !backend.isMovingExempt(player) && !backend.justPlaced(player) && !Utilities.isNearWater(player)
|
||||
&& !Utilities.isInWeb(player) && !player.getLocation().getBlock().getType().name().endsWith("TRAPDOOR")
|
||||
&& !VersionLib.isSlowFalling(player)
|
||||
&& !Utilities
|
||||
.isNearShulkerBox(player.getLocation().getBlock().getRelative(BlockFace.DOWN).getLocation())
|
||||
&& !Utilities.isNearClimbable(player)
|
||||
&& !Utilities.isNearWater(player.getLocation().clone().subtract(0, 1.5, 0))
|
||||
&& !Utilities.couldBeOnBoat(player, 0.35, false)) {
|
||||
if (player.getFallDistance() == 0.0) {
|
||||
if (VIOLATIONS.get(uuid) == null) {
|
||||
VIOLATIONS.put(uuid, 1);
|
||||
} else {
|
||||
VIOLATIONS.put(uuid, VIOLATIONS.get(player.getUniqueId()) + 1);
|
||||
}
|
||||
|
||||
final int violations = VIOLATIONS.get(uuid);
|
||||
final int vlBeforeFlag = checksConfig.getInteger(CheckType.NOFALL, "vlBeforeFlag");
|
||||
if (violations >= vlBeforeFlag) {
|
||||
VIOLATIONS.put(player.getUniqueId(), 1);
|
||||
return new CheckResult(CheckResult.Result.FAILED,
|
||||
"tried to avoid fall damage (" + violations + " times in a row, max=" + vlBeforeFlag + ")");
|
||||
} else {
|
||||
return PASS;
|
||||
}
|
||||
} else {
|
||||
VIOLATIONS.put(uuid, 0);
|
||||
return PASS;
|
||||
}
|
||||
}
|
||||
return PASS;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
/*
|
||||
* AntiCheat for Bukkit.
|
||||
* Copyright (C) 2012-2014 AntiCheat Team | http://gravitydevelopment.net
|
||||
* AntiCheatReloaded for Bukkit and Spigot.
|
||||
* Copyright (c) 2012-2015 AntiCheat Team
|
||||
* Copyright (c) 2016-2022 Rammelkast
|
||||
*
|
||||
* 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
|
||||
@@ -24,7 +25,7 @@ import org.bukkit.Server;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.rammelkast.anticheatreloaded.AntiCheat;
|
||||
import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
|
||||
import com.rammelkast.anticheatreloaded.config.Configuration;
|
||||
import com.rammelkast.anticheatreloaded.manage.CheckManager;
|
||||
import com.rammelkast.anticheatreloaded.manage.UserManager;
|
||||
@@ -32,9 +33,9 @@ import com.rammelkast.anticheatreloaded.util.Permission;
|
||||
|
||||
public class CommandBase {
|
||||
|
||||
public static final Configuration CONFIG = AntiCheat.getManager().getConfiguration();
|
||||
public static final UserManager USER_MANAGER = AntiCheat.getManager().getUserManager();
|
||||
public static final CheckManager CHECK_MANAGER = AntiCheat.getManager().getCheckManager();
|
||||
public static final Configuration CONFIG = AntiCheatReloaded.getManager().getConfiguration();
|
||||
public static final UserManager USER_MANAGER = AntiCheatReloaded.getManager().getUserManager();
|
||||
public static final CheckManager CHECK_MANAGER = AntiCheatReloaded.getManager().getCheckManager();
|
||||
public static final ChatColor RED = ChatColor.RED;
|
||||
public static final ChatColor YELLOW = ChatColor.YELLOW;
|
||||
public static final ChatColor GREEN = ChatColor.GREEN;
|
||||
@@ -44,7 +45,7 @@ public class CommandBase {
|
||||
public static final ChatColor AQUA = ChatColor.AQUA;
|
||||
public static final Server SERVER = Bukkit.getServer();
|
||||
public static final String PERMISSIONS_ERROR = RED + "You don't have the permissions to use this command.";
|
||||
public static final String MENU_END = "-----------------------------------------------------";
|
||||
public static final String MENU_END = GOLD + "-----------------------------------------------------";
|
||||
|
||||
private final String name;
|
||||
private final String command;
|
||||
@@ -63,19 +64,25 @@ public class CommandBase {
|
||||
public void run(CommandSender cs, String[] args) {
|
||||
if (permission.get(cs)) {
|
||||
execute(cs, args);
|
||||
} else {
|
||||
cs.sendMessage(PERMISSIONS_ERROR + " (" + WHITE + permission.toString() + RED + ")");
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (args == null) {
|
||||
cs.sendMessage(GOLD + "" + ChatColor.BOLD + "ACR" + ChatColor.DARK_GRAY + " > "
|
||||
+ ChatColor.GRAY + "Running " + GOLD + "AntiCheatReloaded " + GRAY + "version "
|
||||
+ GOLD + AntiCheatReloaded.getVersion());
|
||||
} else {
|
||||
cs.sendMessage(PERMISSIONS_ERROR + " (" + WHITE + permission.toString() + RED + ")");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected void execute(CommandSender cs, String[] args) {
|
||||
return; // Stub
|
||||
}
|
||||
|
||||
public void sendHelp(CommandSender cs) {
|
||||
cs.sendMessage(RED + "== " + GRAY + getName() + RED + " ==");
|
||||
cs.sendMessage(RED + "Usage: " + GRAY + (cs instanceof Player ? "/" : "") + getUsage());
|
||||
cs.sendMessage(RED + "Permission: " + GRAY + getPermission().toString());
|
||||
cs.sendMessage(GOLD + "" + ChatColor.BOLD + "AntiCheatReloaded" + ChatColor.DARK_GRAY + " > " + ChatColor.GRAY + "Help Menu");
|
||||
cs.sendMessage(GOLD + "Usage: " + GRAY + (cs instanceof Player ? "/" : "") + getUsage());
|
||||
cs.sendMessage(GOLD + "Permission: " + GRAY + getPermission().toString());
|
||||
for (String string : getHelp()) {
|
||||
cs.sendMessage(string);
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
/*
|
||||
* AntiCheat for Bukkit.
|
||||
* Copyright (C) 2012-2014 AntiCheat Team | http://gravitydevelopment.net
|
||||
* AntiCheatReloaded for Bukkit and Spigot.
|
||||
* Copyright (c) 2012-2015 AntiCheat Team
|
||||
* Copyright (c) 2016-2022 Rammelkast
|
||||
*
|
||||
* 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
|
||||
@@ -25,14 +26,14 @@ import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import com.rammelkast.anticheatreloaded.command.executors.CommandCheck;
|
||||
import com.rammelkast.anticheatreloaded.command.executors.CommandDebug;
|
||||
import com.rammelkast.anticheatreloaded.command.executors.CommandDeveloper;
|
||||
import com.rammelkast.anticheatreloaded.command.executors.CommandChecks;
|
||||
import com.rammelkast.anticheatreloaded.command.executors.CommandHelp;
|
||||
import com.rammelkast.anticheatreloaded.command.executors.CommandLog;
|
||||
import com.rammelkast.anticheatreloaded.command.executors.CommandMute;
|
||||
import com.rammelkast.anticheatreloaded.command.executors.CommandReload;
|
||||
import com.rammelkast.anticheatreloaded.command.executors.CommandReport;
|
||||
import com.rammelkast.anticheatreloaded.command.executors.CommandReset;
|
||||
import com.rammelkast.anticheatreloaded.command.executors.CommandVersion;
|
||||
|
||||
public class CommandHandler implements CommandExecutor {
|
||||
|
||||
@@ -40,13 +41,13 @@ public class CommandHandler implements CommandExecutor {
|
||||
|
||||
public CommandHandler() {
|
||||
commands.add(new CommandHelp());
|
||||
commands.add(new CommandCheck());
|
||||
commands.add(new CommandDebug());
|
||||
commands.add(new CommandDeveloper());
|
||||
commands.add(new CommandChecks());
|
||||
commands.add(new CommandLog());
|
||||
commands.add(new CommandReload());
|
||||
commands.add(new CommandReport());
|
||||
commands.add(new CommandMute());
|
||||
commands.add(new CommandReset());
|
||||
commands.add(new CommandVersion());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,97 +0,0 @@
|
||||
/*
|
||||
* AntiCheat for Bukkit.
|
||||
* Copyright (C) 2012-2014 AntiCheat Team | http://gravitydevelopment.net
|
||||
*
|
||||
* 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 3 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, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.rammelkast.anticheatreloaded.command.executors;
|
||||
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import com.rammelkast.anticheatreloaded.check.CheckType;
|
||||
import com.rammelkast.anticheatreloaded.command.CommandBase;
|
||||
import com.rammelkast.anticheatreloaded.util.Permission;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class CommandCheck extends CommandBase {
|
||||
|
||||
private static final String NAME = "AntiCheat Check Management";
|
||||
private static final String COMMAND = "check";
|
||||
private static final String USAGE = "anticheat check [check] [on/off]";
|
||||
private static final Permission PERMISSION = Permission.SYSTEM_CHECK;
|
||||
private static final String[] HELP = new String[3];
|
||||
|
||||
static {
|
||||
HELP[0] = GRAY + "Use: " + AQUA + "/anticheat check [check] on" + GRAY + " to enable a check";
|
||||
HELP[1] = GRAY + "Use: " + AQUA + "/anticheat check [check] off" + GRAY + " to disable a check";
|
||||
StringBuilder builder = new StringBuilder();
|
||||
builder.append(GRAY + "Checks: ");
|
||||
for (int i=0;i<CheckType.values().length;i++) {
|
||||
builder.append(CheckType.values()[i]);
|
||||
if (i<CheckType.values().length-1) {
|
||||
builder.append(", ");
|
||||
}
|
||||
}
|
||||
HELP[2] = builder.toString();
|
||||
}
|
||||
|
||||
public CommandCheck() {
|
||||
super(NAME, COMMAND, USAGE, HELP, PERMISSION);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void execute(CommandSender cs, String[] args) {
|
||||
if (args.length == 2) {
|
||||
for (CheckType type : CheckType.values()) {
|
||||
if (type.toString().equalsIgnoreCase(args[0]) || type.toString().replaceAll("_", "").equalsIgnoreCase(args[0])) {
|
||||
boolean value = CHECK_MANAGER.isActive(type);
|
||||
|
||||
boolean newValue;
|
||||
if (args[1].equalsIgnoreCase("on") || args[1].equalsIgnoreCase("enable")) {
|
||||
newValue = true;
|
||||
} else if (args[1].equalsIgnoreCase("off") || args[1].equalsIgnoreCase("disable")) {
|
||||
newValue = false;
|
||||
} else {
|
||||
sendHelp(cs);
|
||||
return;
|
||||
}
|
||||
|
||||
String strValue = (newValue ? " activated" : " deactivated");
|
||||
if (value == newValue) {
|
||||
cs.sendMessage(GREEN + type.toString() + " is already" + strValue + "!");
|
||||
} else {
|
||||
if (newValue) {
|
||||
CHECK_MANAGER.activateCheck(type, cs.getName());
|
||||
List<String> checks = CONFIG.getConfig().disabledChecks.getValue();
|
||||
if (checks.contains(type.toString())) {
|
||||
checks.remove(type.toString());
|
||||
CONFIG.getConfig().disabledChecks.setValue(checks);
|
||||
}
|
||||
} else {
|
||||
CHECK_MANAGER.deactivateCheck(type, cs.getName());
|
||||
List<String> checks = CONFIG.getConfig().disabledChecks.getValue();
|
||||
checks.add(type.toString());
|
||||
CONFIG.getConfig().disabledChecks.setValue(checks);
|
||||
}
|
||||
cs.sendMessage(GREEN + type.toString() + strValue + ".");
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
sendHelp(cs);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
/*
|
||||
* AntiCheatReloaded for Bukkit and Spigot.
|
||||
* Copyright (c) 2012-2015 AntiCheat Team
|
||||
* Copyright (c) 2016-2022 Rammelkast
|
||||
*
|
||||
* 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 3 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, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.rammelkast.anticheatreloaded.command.executors;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
|
||||
import com.rammelkast.anticheatreloaded.check.CheckType;
|
||||
import com.rammelkast.anticheatreloaded.command.CommandBase;
|
||||
import com.rammelkast.anticheatreloaded.manage.CheckManager;
|
||||
import com.rammelkast.anticheatreloaded.util.Permission;
|
||||
|
||||
public class CommandChecks extends CommandBase {
|
||||
|
||||
private static final String NAME = "AntiCheatReloaded Checks Management";
|
||||
private static final String COMMAND = "checks";
|
||||
private static final String USAGE = "anticheat checks";
|
||||
private static final Permission PERMISSION = Permission.SYSTEM_CHECK;
|
||||
private static final String[] HELP = new String[2];
|
||||
|
||||
static {
|
||||
HELP[0] = GRAY + "Use: " + AQUA + "/anticheat checks" + GRAY + " for a list of checks";
|
||||
StringBuilder builder = new StringBuilder();
|
||||
CheckManager checkManager = AntiCheatReloaded.getManager().getCheckManager();
|
||||
builder.append(GRAY + "Checks: ");
|
||||
for (int i = 0; i < CheckType.values().length; i++) {
|
||||
CheckType type = CheckType.values()[i];
|
||||
builder.append((checkManager.isActive(type) ? ChatColor.GREEN : ChatColor.RED) + type.getName());
|
||||
if (i < CheckType.values().length - 1) {
|
||||
builder.append(", ");
|
||||
}
|
||||
}
|
||||
HELP[1] = builder.toString();
|
||||
}
|
||||
|
||||
public CommandChecks() {
|
||||
super(NAME, COMMAND, USAGE, HELP, PERMISSION);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void execute(CommandSender cs, String[] args) {
|
||||
sendHelp(cs);
|
||||
}
|
||||
}
|
||||
@@ -1,60 +0,0 @@
|
||||
/*
|
||||
* AntiCheat for Bukkit.
|
||||
* Copyright (C) 2012-2014 AntiCheat Team | http://gravitydevelopment.net
|
||||
*
|
||||
* 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 3 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, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.rammelkast.anticheatreloaded.command.executors;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.rammelkast.anticheatreloaded.command.CommandBase;
|
||||
import com.rammelkast.anticheatreloaded.util.PastebinReport;
|
||||
import com.rammelkast.anticheatreloaded.util.Permission;
|
||||
|
||||
public class CommandDebug extends CommandBase {
|
||||
|
||||
private static final String NAME = "AntiCheat Debug Reporting";
|
||||
private static final String COMMAND = "debug";
|
||||
private static final String USAGE = "anticheat debug <user>";
|
||||
private static final Permission PERMISSION = Permission.SYSTEM_DEBUG;
|
||||
private static final String[] HELP = {
|
||||
GRAY + "Use: " + AQUA + "/anticheat debug" + GRAY + " to create a debug report",
|
||||
GRAY + "Use: " + AQUA + "/anticheat debug <user>" + GRAY + " to create a debug report for a user",
|
||||
};
|
||||
|
||||
public CommandDebug() {
|
||||
super(NAME, COMMAND, USAGE, HELP, PERMISSION);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void execute(CommandSender cs, String[] args) {
|
||||
Player player = null;
|
||||
if (args.length == 1) {
|
||||
player = Bukkit.getPlayer(args[0]);
|
||||
} else {
|
||||
if (cs instanceof Player) {
|
||||
player = (Player) cs;
|
||||
}
|
||||
}
|
||||
|
||||
cs.sendMessage(GRAY + "Please wait while I collect some data...");
|
||||
PastebinReport report = new PastebinReport(cs, player);
|
||||
cs.sendMessage(GREEN + "Debug information posted to: " + WHITE + report.getURL());
|
||||
cs.sendMessage(GREEN + "Please include this link when making bug reports.");
|
||||
}
|
||||
}
|
||||
-46
@@ -1,46 +0,0 @@
|
||||
/*
|
||||
* AntiCheat for Bukkit.
|
||||
* Copyright (C) 2012-2014 AntiCheat Team | http://gravitydevelopment.net
|
||||
*
|
||||
* 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 3 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, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.rammelkast.anticheatreloaded.command.executors;
|
||||
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import com.rammelkast.anticheatreloaded.AntiCheat;
|
||||
import com.rammelkast.anticheatreloaded.command.CommandBase;
|
||||
import com.rammelkast.anticheatreloaded.util.Permission;
|
||||
|
||||
public class CommandDeveloper extends CommandBase {
|
||||
|
||||
private static final String NAME = "AntiCheat Developer Mode";
|
||||
private static final String COMMAND = "developer";
|
||||
private static final String USAGE = "anticheat developer";
|
||||
private static final Permission PERMISSION = Permission.SYSTEM_DEBUG;
|
||||
private static final String[] HELP = {
|
||||
GRAY + "Use: " + AQUA + "/anticheat developer" + GRAY + " to turn on developer mode",
|
||||
};
|
||||
|
||||
public CommandDeveloper() {
|
||||
super(NAME, COMMAND, USAGE, HELP, PERMISSION);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void execute(CommandSender cs, String[] args) {
|
||||
AntiCheat.setDeveloperMode(!AntiCheat.developerMode());
|
||||
cs.sendMessage(GREEN + "Developer mode " + (AntiCheat.developerMode() ? "ON" : "OFF"));
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
/*
|
||||
* AntiCheat for Bukkit.
|
||||
* Copyright (C) 2012-2014 AntiCheat Team | http://gravitydevelopment.net
|
||||
* AntiCheatReloaded for Bukkit and Spigot.
|
||||
* Copyright (c) 2012-2015 AntiCheat Team
|
||||
* Copyright (c) 2016-2022 Rammelkast
|
||||
*
|
||||
* 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
|
||||
@@ -30,14 +31,14 @@ public class CommandHelp extends CommandBase {
|
||||
private static final String USAGE = "anticheat help";
|
||||
private static final Permission PERMISSION = Permission.SYSTEM_HELP;
|
||||
private static final String[] HELP = {
|
||||
RED + "/anti " + GRAY + "help",
|
||||
RED + "/anti " + GRAY + "reload",
|
||||
RED + "/anti " + GRAY + "update",
|
||||
RED + "/anti " + GRAY + "debug " + WHITE + "<user>",
|
||||
RED + "/anti " + GRAY + "check " + WHITE + "[check] [on/off]",
|
||||
RED + "/anti " + GRAY + "log " + WHITE + "[file/console] [on/off]",
|
||||
RED + "/anti " + GRAY + "report " + WHITE + "[group/user]",
|
||||
RED + "/anti " + GRAY + "reset " + WHITE + "[user]",
|
||||
GOLD + "/acr " + GRAY + "help",
|
||||
GOLD + "/acr " + GRAY + "reload",
|
||||
GOLD + "/acr " + GRAY + "version",
|
||||
GOLD + "/acr " + GRAY + "mute",
|
||||
GOLD + "/acr " + GRAY + "checks",
|
||||
GOLD + "/acr " + GRAY + "log " + WHITE + "[file/console] [on/off]",
|
||||
GOLD + "/acr " + GRAY + "report " + WHITE + "[group/user]",
|
||||
GOLD + "/acr " + GRAY + "reset " + WHITE + "[user]",
|
||||
};
|
||||
|
||||
public CommandHelp() {
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
/*
|
||||
* AntiCheat for Bukkit.
|
||||
* Copyright (C) 2012-2014 AntiCheat Team | http://gravitydevelopment.net
|
||||
* AntiCheatReloaded for Bukkit and Spigot.
|
||||
* Copyright (c) 2012-2015 AntiCheat Team
|
||||
* Copyright (c) 2016-2022 Rammelkast
|
||||
*
|
||||
* 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
|
||||
@@ -26,7 +27,7 @@ import com.rammelkast.anticheatreloaded.util.Permission;
|
||||
|
||||
public class CommandLog extends CommandBase {
|
||||
|
||||
private static final String NAME = "AntiCheat Logging";
|
||||
private static final String NAME = "AntiCheatReloaded Logging";
|
||||
private static final String COMMAND = "log";
|
||||
private static final String USAGE = "anticheat log [file/console] [on/off]";
|
||||
private static final Permission PERMISSION = Permission.SYSTEM_LOG;
|
||||
|
||||
@@ -0,0 +1,61 @@
|
||||
/*
|
||||
* AntiCheatReloaded for Bukkit and Spigot.
|
||||
* Copyright (c) 2012-2015 AntiCheat Team
|
||||
* Copyright (c) 2016-2022 Rammelkast
|
||||
*
|
||||
* 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 3 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, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.rammelkast.anticheatreloaded.command.executors;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
|
||||
import com.rammelkast.anticheatreloaded.command.CommandBase;
|
||||
import com.rammelkast.anticheatreloaded.util.Permission;
|
||||
|
||||
public class CommandMute extends CommandBase {
|
||||
|
||||
private static final String NAME = "AntiCheatReloaded Mute";
|
||||
private static final String COMMAND = "mute";
|
||||
private static final String USAGE = "anticheat mute";
|
||||
private static final Permission PERMISSION = Permission.SYSTEM_MUTE;
|
||||
private static final String[] HELP = {
|
||||
GRAY + "Use: " + AQUA + "/anticheat mute" + GRAY + " to mute all notifications", };
|
||||
|
||||
public CommandMute() {
|
||||
super(NAME, COMMAND, USAGE, HELP, PERMISSION);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void execute(CommandSender cs, String[] args) {
|
||||
if (!(cs instanceof Player)) {
|
||||
cs.sendMessage(ChatColor.BOLD + "" + GOLD + "ACR " + GRAY + "This command is only for players");
|
||||
return;
|
||||
}
|
||||
UUID uuid = ((Player) cs).getUniqueId();
|
||||
if (AntiCheatReloaded.MUTE_ENABLED_MODS.contains(uuid)) {
|
||||
cs.sendMessage(GOLD + "" + ChatColor.BOLD + "ACR " + GRAY + "Player alerts have been unmuted");
|
||||
AntiCheatReloaded.MUTE_ENABLED_MODS.remove(uuid);
|
||||
return;
|
||||
} else {
|
||||
cs.sendMessage(GOLD + "" + ChatColor.BOLD + "ACR " + GRAY + "Player alerts have been muted");
|
||||
AntiCheatReloaded.MUTE_ENABLED_MODS.add(uuid);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
/*
|
||||
* AntiCheat for Bukkit.
|
||||
* Copyright (C) 2012-2014 AntiCheat Team | http://gravitydevelopment.net
|
||||
* AntiCheatReloaded for Bukkit and Spigot.
|
||||
* Copyright (c) 2012-2015 AntiCheat Team
|
||||
* Copyright (c) 2016-2022 Rammelkast
|
||||
*
|
||||
* 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
|
||||
@@ -18,6 +19,7 @@
|
||||
|
||||
package com.rammelkast.anticheatreloaded.command.executors;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import com.rammelkast.anticheatreloaded.command.CommandBase;
|
||||
@@ -25,7 +27,7 @@ import com.rammelkast.anticheatreloaded.util.Permission;
|
||||
|
||||
public class CommandReload extends CommandBase {
|
||||
|
||||
private static final String NAME = "AntiCheat Reload";
|
||||
private static final String NAME = "AntiCheatReloaded Reload";
|
||||
private static final String COMMAND = "reload";
|
||||
private static final String USAGE = "anticheat reload";
|
||||
private static final Permission PERMISSION = Permission.SYSTEM_RELOAD;
|
||||
@@ -40,6 +42,7 @@ public class CommandReload extends CommandBase {
|
||||
@Override
|
||||
protected void execute(CommandSender cs, String[] args) {
|
||||
CONFIG.load();
|
||||
cs.sendMessage(GREEN + "AntiCheat configuration reloaded.");
|
||||
cs.sendMessage(ChatColor.GOLD + "" + ChatColor.BOLD + "ACR " + ChatColor.DARK_GRAY + "> "
|
||||
+ ChatColor.GRAY + "The configuration was reloaded");
|
||||
}
|
||||
}
|
||||
+158
-157
@@ -1,6 +1,7 @@
|
||||
/*
|
||||
* AntiCheat for Bukkit.
|
||||
* Copyright (C) 2012-2014 AntiCheat Team | http://gravitydevelopment.net
|
||||
* AntiCheatReloaded for Bukkit and Spigot.
|
||||
* Copyright (c) 2012-2015 AntiCheat Team
|
||||
* Copyright (c) 2016-2022 Rammelkast
|
||||
*
|
||||
* 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
|
||||
@@ -15,179 +16,179 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.rammelkast.anticheatreloaded.command.executors;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.rammelkast.anticheatreloaded.AntiCheat;
|
||||
import com.rammelkast.anticheatreloaded.check.CheckType;
|
||||
import com.rammelkast.anticheatreloaded.command.CommandBase;
|
||||
import com.rammelkast.anticheatreloaded.manage.CheckManager;
|
||||
import com.rammelkast.anticheatreloaded.util.*;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
|
||||
import com.rammelkast.anticheatreloaded.check.CheckType;
|
||||
import com.rammelkast.anticheatreloaded.command.CommandBase;
|
||||
import com.rammelkast.anticheatreloaded.util.Group;
|
||||
import com.rammelkast.anticheatreloaded.util.Permission;
|
||||
import com.rammelkast.anticheatreloaded.util.User;
|
||||
import com.rammelkast.anticheatreloaded.util.Utilities;
|
||||
|
||||
public class CommandReport extends CommandBase {
|
||||
|
||||
private static final String NAME = "AntiCheat Reports";
|
||||
private static final String COMMAND = "report";
|
||||
private static final String USAGE = "anticheat report [group/user]";
|
||||
private static final Permission PERMISSION = Permission.SYSTEM_REPORT;
|
||||
private static final String[] HELP = {
|
||||
GRAY + "Use: " + AQUA + "/anticheat report [group]" + GRAY + " to see all users in a given group",
|
||||
GRAY + "Use: " + AQUA + "/anticheat report [user]" + GRAY + " to see a single user's report",
|
||||
GRAY + "Use: " + AQUA + "/anticheat report [user/group] [num]" + GRAY + " to see pages of a report",
|
||||
};
|
||||
private static final String NAME = "AntiCheatReloaded Reports";
|
||||
private static final String COMMAND = "report";
|
||||
private static final String USAGE = "anticheat report [group/user]";
|
||||
private static final Permission PERMISSION = Permission.SYSTEM_REPORT;
|
||||
private static final String[] HELP = {
|
||||
GRAY + "Use: " + GOLD + "/anticheat report [group]" + GRAY + " to see all users in a given group",
|
||||
GRAY + "Use: " + GOLD + "/anticheat report [user]" + GRAY + " to see a single user's report",
|
||||
GRAY + "Use: " + GOLD + "/anticheat report [user/group] [num]" + GRAY + " to see pages of a report", };
|
||||
|
||||
public CommandReport() {
|
||||
super(NAME, COMMAND, USAGE, HELP, PERMISSION);
|
||||
}
|
||||
public CommandReport() {
|
||||
super(NAME, COMMAND, USAGE, HELP, PERMISSION);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void execute(CommandSender cs, String[] args) {
|
||||
if (args.length >= 1) {
|
||||
int page = 1;
|
||||
if (args.length == 2) {
|
||||
if (Utilities.isInt(args[1])) {
|
||||
page = Integer.parseInt(args[1]);
|
||||
} else {
|
||||
cs.sendMessage(RED + "Not a valid page number: " + WHITE + args[1]);
|
||||
}
|
||||
}
|
||||
@Override
|
||||
protected void execute(CommandSender cs, String[] args) {
|
||||
if (args.length >= 1) {
|
||||
int page = 1;
|
||||
if (args.length == 2) {
|
||||
if (Utilities.isInt(args[1])) {
|
||||
page = Integer.parseInt(args[1]);
|
||||
} else {
|
||||
cs.sendMessage(RED + "Not a valid page number: " + WHITE + args[1]);
|
||||
}
|
||||
}
|
||||
|
||||
if ("low".equalsIgnoreCase(args[0])) {
|
||||
groupReport(cs, null, page);
|
||||
}
|
||||
else if ("all".equalsIgnoreCase(args[0])) {
|
||||
cs.sendMessage(GREEN + "Low: " + WHITE + USER_MANAGER.getUsersInGroup(null).size() + " players");
|
||||
for (Group g : CONFIG.getGroups().getGroups()) {
|
||||
int numPlayers = USER_MANAGER.getUsersInGroup(g).size();
|
||||
cs.sendMessage(g.getColor() + g.getName() + WHITE + ": " + numPlayers + " players");
|
||||
}
|
||||
cs.sendMessage(GRAY + "Use " + AQUA + "/anticheat report [group]" + GRAY + " for a list of players in each group.");
|
||||
} else {
|
||||
// Test groups
|
||||
for (Group group : CONFIG.getGroups().getGroups()) {
|
||||
if (group.getName().equalsIgnoreCase(args[0]) || "low".equalsIgnoreCase(args[0]) || "all".equalsIgnoreCase(args[0])) {
|
||||
groupReport(cs, group, page);
|
||||
return;
|
||||
}
|
||||
}
|
||||
if ("low".equalsIgnoreCase(args[0])) {
|
||||
groupReport(cs, null, page);
|
||||
} else if ("all".equalsIgnoreCase(args[0])) {
|
||||
cs.sendMessage(GREEN + "Low: " + WHITE + USER_MANAGER.getUsersInGroup(null).size() + " players");
|
||||
for (Group g : CONFIG.getGroups().getGroups()) {
|
||||
int numPlayers = USER_MANAGER.getUsersInGroup(g).size();
|
||||
cs.sendMessage(g.getColor() + g.getName() + WHITE + ": " + numPlayers + " players");
|
||||
}
|
||||
cs.sendMessage(GRAY + "Use " + GOLD + "/anticheat report [group]" + GRAY
|
||||
+ " for a list of players in each group.");
|
||||
} else {
|
||||
// Test groups
|
||||
for (Group group : CONFIG.getGroups().getGroups()) {
|
||||
if (group.getName().equalsIgnoreCase(args[0]) || "low".equalsIgnoreCase(args[0])
|
||||
|| "all".equalsIgnoreCase(args[0])) {
|
||||
groupReport(cs, group, page);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// Test users
|
||||
for (Player player : Bukkit.getOnlinePlayers()) {
|
||||
if (player.getUniqueId().equals(Bukkit.getPlayer(args[0]).getUniqueId())) {
|
||||
User user = AntiCheat.getManager().getUserManager().getUser(player.getUniqueId());
|
||||
playerReport(cs, user, page);
|
||||
return;
|
||||
}
|
||||
}
|
||||
@SuppressWarnings("deprecation")
|
||||
OfflinePlayer targetPlayer = Bukkit.getOfflinePlayer(args[0]);
|
||||
if (targetPlayer == null) {
|
||||
cs.sendMessage(RED + "Not a valid group or user: " + WHITE + args[0]);
|
||||
return;
|
||||
}
|
||||
|
||||
// Neither of these
|
||||
cs.sendMessage(RED + "Not a valid group or user: " + WHITE + args[0]);
|
||||
}
|
||||
} else {
|
||||
sendHelp(cs);
|
||||
}
|
||||
}
|
||||
User user = AntiCheatReloaded.getManager().getUserManager().getUser(targetPlayer.getUniqueId());
|
||||
if (user != null) {
|
||||
playerReport(cs, user, page);
|
||||
return;
|
||||
}
|
||||
|
||||
private void groupReport(CommandSender cs, Group group, int page) {
|
||||
List<User> users = USER_MANAGER.getUsersInGroup(group);
|
||||
ChatColor color = group == null ? GREEN : group.getColor();
|
||||
String groupName = group == null ? "Low" : group.getName();
|
||||
int pages = (int) Math.ceil(((float) users.size()) / 7);
|
||||
if (page <= pages && page > 0) {
|
||||
cs.sendMessage("--------------------[" + GREEN + "REPORT[" + page + "/" + pages + "]" + WHITE + "]---------------------");
|
||||
cs.sendMessage(GRAY + "Group: " + color + groupName);
|
||||
for (int x = 0; x < 7; x++) {
|
||||
int index = ((page - 1) * 6) + (x + ((page - 1) * 1));
|
||||
if (index < users.size()) {
|
||||
String player = users.get(index).getName();
|
||||
cs.sendMessage(GRAY + player);
|
||||
}
|
||||
}
|
||||
cs.sendMessage(MENU_END);
|
||||
} else {
|
||||
if (pages == 0) {
|
||||
cs.sendMessage("--------------------[" + GREEN + "REPORT[1/1]" + WHITE + "]---------------------");
|
||||
cs.sendMessage(GRAY + "Group: " + color + groupName);
|
||||
cs.sendMessage(GRAY + "There are no users in this group.");
|
||||
cs.sendMessage(MENU_END);
|
||||
} else {
|
||||
cs.sendMessage(RED + "Page not found. Requested " + WHITE + page + RED + ", Max " + WHITE + pages);
|
||||
}
|
||||
}
|
||||
}
|
||||
cs.sendMessage(RED + "Not a valid group or user: " + WHITE + args[0]);
|
||||
}
|
||||
} else {
|
||||
sendHelp(cs);
|
||||
}
|
||||
}
|
||||
|
||||
private void playerReport(CommandSender cs, User user, int page) {
|
||||
List<CheckType> types = new ArrayList<CheckType>();
|
||||
for (CheckType type : CheckType.values()) {
|
||||
if (type.getUses(user.getUUID()) > 0) {
|
||||
types.add(type);
|
||||
}
|
||||
}
|
||||
private void groupReport(CommandSender cs, Group group, int page) {
|
||||
List<User> users = USER_MANAGER.getUsersInGroup(group);
|
||||
ChatColor color = group == null ? GREEN : group.getColor();
|
||||
String groupName = group == null ? "Low" : group.getName();
|
||||
int pages = (int) Math.ceil(((float) users.size()) / 7);
|
||||
if (page <= pages && page > 0) {
|
||||
cs.sendMessage(GOLD + "----------------------[" + WHITE + "Page " + page + "/" + pages + "" + GOLD
|
||||
+ "]----------------------");
|
||||
cs.sendMessage(GRAY + "Group: " + color + groupName);
|
||||
for (int x = 0; x < 7; x++) {
|
||||
int index = ((page - 1) * 6) + (x + ((page - 1) * 1));
|
||||
if (index < users.size()) {
|
||||
String player = users.get(index).getName();
|
||||
cs.sendMessage(GRAY + player);
|
||||
}
|
||||
}
|
||||
cs.sendMessage(MENU_END);
|
||||
} else {
|
||||
if (pages == 0) {
|
||||
cs.sendMessage(GOLD + "----------------------[" + WHITE + "Page 1/1" + GOLD + "]----------------------");
|
||||
cs.sendMessage(GRAY + "Group: " + color + groupName);
|
||||
cs.sendMessage(GRAY + "There are no users in this group.");
|
||||
cs.sendMessage(MENU_END);
|
||||
} else {
|
||||
cs.sendMessage(RED + "Page not found. Requested " + WHITE + page + RED + ", Max " + WHITE + pages);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
UUID uuid = user.getUUID();
|
||||
String name = user.getName();
|
||||
int pages = (int) Math.ceil(((float) types.size()) / 6);
|
||||
private void playerReport(CommandSender cs, User user, int page) {
|
||||
List<CheckType> types = new ArrayList<CheckType>();
|
||||
for (CheckType type : CheckType.values()) {
|
||||
if (type.getUses(user.getUUID()) > 0) {
|
||||
types.add(type);
|
||||
}
|
||||
}
|
||||
|
||||
Group group = user.getGroup();
|
||||
String groupString = GREEN + "Low";
|
||||
UUID uuid = user.getUUID();
|
||||
String name = user.getName();
|
||||
int pages = (int) Math.ceil(((float) types.size()) / 6);
|
||||
|
||||
if (group != null) {
|
||||
groupString = group.getColor() + group.getName();
|
||||
}
|
||||
groupString += " (" + user.getLevel() + ")";
|
||||
Group group = user.getGroup();
|
||||
String groupString = GREEN + "Low";
|
||||
|
||||
if (page <= pages && page > 0) {
|
||||
cs.sendMessage("--------------------[" + GREEN + "REPORT[" + page + "/" + pages + "]" + WHITE + "]---------------------");
|
||||
cs.sendMessage(GRAY + "Player: " + WHITE + name);
|
||||
cs.sendMessage(GRAY + "Group: " + groupString);
|
||||
for (int x = 0; x < 6; x++) {
|
||||
int index = ((page - 1) * 5) + (x + ((page - 1)));
|
||||
if (index < types.size()) {
|
||||
CheckType type = types.get(index);
|
||||
int use = type.getUses(uuid);
|
||||
ChatColor color = WHITE;
|
||||
if (use >= 20) {
|
||||
color = YELLOW;
|
||||
} else if (use > 50) {
|
||||
color = RED;
|
||||
}
|
||||
cs.sendMessage(GRAY + CheckType.getName(type) + ": " + color + use);
|
||||
}
|
||||
}
|
||||
cs.sendMessage(MENU_END);
|
||||
} else {
|
||||
if (pages == 0 && page == 1) {
|
||||
cs.sendMessage("--------------------[" + GREEN + "REPORT[1/1]" + WHITE + "]---------------------");
|
||||
cs.sendMessage(GRAY + "Player: " + WHITE + name);
|
||||
cs.sendMessage(GRAY + "Group: " + groupString);
|
||||
cs.sendMessage(GRAY + "This user has not failed any checks.");
|
||||
cs.sendMessage(MENU_END);
|
||||
} else {
|
||||
cs.sendMessage(RED + "Page not found. Requested " + WHITE + page + RED + ", Max " + WHITE + pages + 1);
|
||||
}
|
||||
}
|
||||
if (group != null) {
|
||||
groupString = group.getColor() + group.getName();
|
||||
}
|
||||
groupString += " (" + user.getLevel() + ")";
|
||||
|
||||
if (AntiCheat.developerMode()) {
|
||||
int permission = 0;
|
||||
int check = 0;
|
||||
for (Permission perm : Permission.values()) {
|
||||
if (perm.get(user.getPlayer())) permission++;
|
||||
}
|
||||
CheckManager manager = AntiCheat.getManager().getCheckManager();
|
||||
for (CheckType type : CheckType.values()) {
|
||||
if (manager.willCheck(user.getPlayer(), type)) check++;
|
||||
}
|
||||
cs.sendMessage(ChatColor.GOLD + "User has " + permission + "/" + Permission.values().length + " permissions");
|
||||
cs.sendMessage(ChatColor.GOLD + "User will be checked for " + check + "/" + CheckType.values().length + " checks");
|
||||
}
|
||||
}
|
||||
if (page <= pages && page > 0) {
|
||||
cs.sendMessage(GOLD + "----------------------[" + WHITE + "Page " + page + "/" + pages + "" + GOLD
|
||||
+ "]----------------------");
|
||||
cs.sendMessage(GRAY + "Player: " + WHITE + name);
|
||||
int ping = user.getPing();
|
||||
cs.sendMessage(GRAY + "Ping: " + ((ping == -1) ? (RED + "Offline")
|
||||
: (WHITE + "" + ping + "ms "
|
||||
+ (user.isLagging() ? ChatColor.RED + "(lagging)" : ChatColor.GREEN + "(not lagging)"))));
|
||||
cs.sendMessage(GRAY + "Group: " + groupString);
|
||||
for (int x = 0; x < 6; x++) {
|
||||
int index = ((page - 1) * 5) + (x + ((page - 1)));
|
||||
if (index < types.size()) {
|
||||
CheckType type = types.get(index);
|
||||
int use = type.getUses(uuid);
|
||||
ChatColor color = WHITE;
|
||||
if (use >= 20) {
|
||||
color = YELLOW;
|
||||
} else if (use > 50) {
|
||||
color = RED;
|
||||
}
|
||||
cs.sendMessage(GRAY + type.getName() + ": " + color + use);
|
||||
}
|
||||
}
|
||||
cs.sendMessage(MENU_END);
|
||||
} else {
|
||||
if (pages == 0 && page == 1) {
|
||||
cs.sendMessage(GOLD + "----------------------[" + WHITE + "Page 1/1" + GOLD + "]----------------------");
|
||||
cs.sendMessage(GRAY + "Player: " + WHITE + name);
|
||||
int ping = user.getPing();
|
||||
cs.sendMessage(GRAY + "Ping: " + ((ping == -1) ? (RED + "Offline")
|
||||
: (WHITE + "" + ping + "ms "
|
||||
+ (user.isLagging() ? ChatColor.RED + "(lagging)" : ChatColor.GREEN + "(not lagging)"))));
|
||||
cs.sendMessage(GRAY + "Group: " + groupString);
|
||||
cs.sendMessage(GRAY + "This user has not failed any checks.");
|
||||
cs.sendMessage(MENU_END);
|
||||
} else {
|
||||
cs.sendMessage(RED + "Page not found. Requested " + WHITE + page + RED + ", Max " + WHITE + pages + 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
/*
|
||||
* AntiCheat for Bukkit.
|
||||
* Copyright (C) 2012-2014 AntiCheat Team | http://gravitydevelopment.net
|
||||
* AntiCheatReloaded for Bukkit and Spigot.
|
||||
* Copyright (c) 2012-2015 AntiCheat Team
|
||||
* Copyright (c) 2016-2022 Rammelkast
|
||||
*
|
||||
* 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
|
||||
@@ -20,16 +21,15 @@ package com.rammelkast.anticheatreloaded.command.executors;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.rammelkast.anticheatreloaded.AntiCheat;
|
||||
import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
|
||||
import com.rammelkast.anticheatreloaded.command.CommandBase;
|
||||
import com.rammelkast.anticheatreloaded.util.Permission;
|
||||
import com.rammelkast.anticheatreloaded.util.User;
|
||||
|
||||
public class CommandReset extends CommandBase {
|
||||
|
||||
private static final String NAME = "AntiCheat Resetting";
|
||||
private static final String NAME = "AntiCheatReloaded Resetting";
|
||||
private static final String COMMAND = "reset";
|
||||
private static final String USAGE = "anticheat reset [user]";
|
||||
private static final Permission PERMISSION = Permission.SYSTEM_RESET;
|
||||
@@ -41,6 +41,7 @@ public class CommandReset extends CommandBase {
|
||||
super(NAME, COMMAND, USAGE, HELP, PERMISSION);
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
@Override
|
||||
protected void execute(CommandSender cs, String[] args) {
|
||||
User user;
|
||||
@@ -53,8 +54,8 @@ public class CommandReset extends CommandBase {
|
||||
if (user != null) {
|
||||
user.resetLevel();
|
||||
user.clearMessages();
|
||||
AntiCheat.getManager().getBackend().resetChatLevel(user);
|
||||
cs.sendMessage(args[0] + GREEN + " has been reset.");
|
||||
AntiCheatReloaded.getManager().getBackend().resetChatLevel(user);
|
||||
cs.sendMessage(GOLD + args[0] + GRAY + " has been reset.");
|
||||
} else {
|
||||
cs.sendMessage(RED + "Player: " +args[0] + " not found.");
|
||||
}
|
||||
|
||||
@@ -0,0 +1,58 @@
|
||||
/*
|
||||
* AntiCheatReloaded for Bukkit and Spigot.
|
||||
* Copyright (c) 2012-2015 AntiCheat Team
|
||||
* Copyright (c) 2016-2022 Rammelkast
|
||||
*
|
||||
* 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 3 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, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.rammelkast.anticheatreloaded.command.executors;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
|
||||
import com.rammelkast.anticheatreloaded.command.CommandBase;
|
||||
import com.rammelkast.anticheatreloaded.util.Permission;
|
||||
import com.rammelkast.anticheatreloaded.util.UpdateManager;
|
||||
|
||||
public class CommandVersion extends CommandBase {
|
||||
|
||||
private static final String NAME = "AntiCheatReloaded Version";
|
||||
private static final String COMMAND = "version";
|
||||
private static final String USAGE = "anticheat version";
|
||||
private static final Permission PERMISSION = Permission.SYSTEM_VERSION;
|
||||
private static final String[] HELP = {
|
||||
GRAY + "Use: " + AQUA + "/anticheat version" + GRAY + " to get update information", };
|
||||
|
||||
public CommandVersion() {
|
||||
super(NAME, COMMAND, USAGE, HELP, PERMISSION);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void execute(CommandSender cs, String[] args) {
|
||||
UpdateManager updateManager = AntiCheatReloaded.getUpdateManager();
|
||||
String status = RED + "behind";
|
||||
if (updateManager.isLatest()) {
|
||||
if (updateManager.isAhead()) {
|
||||
status = GREEN + "ahead";
|
||||
} else {
|
||||
status = GOLD + "up-to-date";
|
||||
}
|
||||
}
|
||||
cs.sendMessage(GOLD + "" + ChatColor.BOLD + "ACR " + GRAY + "You are running version " + GOLD
|
||||
+ updateManager.getCurrentVersion() + GRAY + ". The latest version is " + GOLD
|
||||
+ updateManager.getLatestVersion() + GRAY + ". This means you are " + status + GRAY + ".");
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
/*
|
||||
* AntiCheat for Bukkit.
|
||||
* Copyright (C) 2012-2014 AntiCheat Team | http://gravitydevelopment.net
|
||||
* AntiCheatReloaded for Bukkit and Spigot.
|
||||
* Copyright (c) 2012-2015 AntiCheat Team
|
||||
* Copyright (c) 2016-2022 Rammelkast
|
||||
*
|
||||
* 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
|
||||
@@ -18,21 +19,35 @@
|
||||
|
||||
package com.rammelkast.anticheatreloaded.config;
|
||||
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
|
||||
import com.rammelkast.anticheatreloaded.AntiCheat;
|
||||
import com.rammelkast.anticheatreloaded.config.files.Config;
|
||||
import com.rammelkast.anticheatreloaded.config.files.Enterprise;
|
||||
import com.rammelkast.anticheatreloaded.config.holders.mysql.*;
|
||||
import com.rammelkast.anticheatreloaded.config.holders.yaml.*;
|
||||
import com.rammelkast.anticheatreloaded.config.providers.*;
|
||||
import com.rammelkast.anticheatreloaded.manage.AntiCheatManager;
|
||||
|
||||
import java.io.File;
|
||||
import java.lang.reflect.InvocationHandler;
|
||||
import java.lang.reflect.Proxy;
|
||||
import java.util.ArrayList;
|
||||
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
|
||||
import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
|
||||
import com.rammelkast.anticheatreloaded.config.files.Config;
|
||||
import com.rammelkast.anticheatreloaded.config.files.Enterprise;
|
||||
import com.rammelkast.anticheatreloaded.config.holders.mysql.MySQLGroupsHolder;
|
||||
import com.rammelkast.anticheatreloaded.config.holders.mysql.MySQLLangHolder;
|
||||
import com.rammelkast.anticheatreloaded.config.holders.mysql.MySQLLevelsHolder;
|
||||
import com.rammelkast.anticheatreloaded.config.holders.mysql.MySQLMagicHolder;
|
||||
import com.rammelkast.anticheatreloaded.config.holders.mysql.MySQLRulesHolder;
|
||||
import com.rammelkast.anticheatreloaded.config.holders.yaml.YamlChecksHolder;
|
||||
import com.rammelkast.anticheatreloaded.config.holders.yaml.YamlGroupsHolder;
|
||||
import com.rammelkast.anticheatreloaded.config.holders.yaml.YamlLangHolder;
|
||||
import com.rammelkast.anticheatreloaded.config.holders.yaml.YamlLevelsHolder;
|
||||
import com.rammelkast.anticheatreloaded.config.holders.yaml.YamlMagicHolder;
|
||||
import com.rammelkast.anticheatreloaded.config.holders.yaml.YamlRulesHolder;
|
||||
import com.rammelkast.anticheatreloaded.config.providers.Checks;
|
||||
import com.rammelkast.anticheatreloaded.config.providers.Groups;
|
||||
import com.rammelkast.anticheatreloaded.config.providers.Lang;
|
||||
import com.rammelkast.anticheatreloaded.config.providers.Levels;
|
||||
import com.rammelkast.anticheatreloaded.config.providers.Magic;
|
||||
import com.rammelkast.anticheatreloaded.config.providers.Rules;
|
||||
import com.rammelkast.anticheatreloaded.manage.AntiCheatManager;
|
||||
|
||||
public class Configuration {
|
||||
|
||||
private AntiCheatManager manager;
|
||||
@@ -44,11 +59,12 @@ public class Configuration {
|
||||
private Groups groups;
|
||||
private Levels levels;
|
||||
private Rules rules;
|
||||
private Checks checks;
|
||||
|
||||
private ArrayList<ConfigurationFile> flatfiles;
|
||||
private ArrayList<ConfigurationTable> dbfiles;
|
||||
|
||||
public Configuration(AntiCheat plugin, AntiCheatManager manager) {
|
||||
public Configuration(AntiCheatReloaded plugin, AntiCheatManager manager) {
|
||||
removeOldFiles();
|
||||
this.manager = manager;
|
||||
config = new Config(plugin, this);
|
||||
@@ -56,10 +72,13 @@ public class Configuration {
|
||||
// Now load others
|
||||
enterprise = new Enterprise(plugin, this);
|
||||
|
||||
flatfiles = new ArrayList<ConfigurationFile>() {{
|
||||
add(config);
|
||||
add(enterprise);
|
||||
}};
|
||||
flatfiles = new ArrayList<ConfigurationFile>() {
|
||||
private static final long serialVersionUID = 4497798966909062852L;
|
||||
{
|
||||
add(config);
|
||||
add(enterprise);
|
||||
}
|
||||
};
|
||||
|
||||
dbfiles = new ArrayList<ConfigurationTable>();
|
||||
|
||||
@@ -79,6 +98,9 @@ public class Configuration {
|
||||
rules = new YamlRulesHolder(plugin, this);
|
||||
flatfiles.add((YamlRulesHolder) rules);
|
||||
}
|
||||
|
||||
checks = new YamlChecksHolder(plugin, this);
|
||||
flatfiles.add((YamlChecksHolder) checks);
|
||||
|
||||
InvocationHandler handler;
|
||||
if (config.enterprise.getValue() && enterprise.configMagic.getValue()) {
|
||||
@@ -129,12 +151,15 @@ public class Configuration {
|
||||
file.load();
|
||||
checkReload(file);
|
||||
}
|
||||
for (ConfigurationTable table : dbfiles) {
|
||||
|
||||
for (ConfigurationTable table : dbfiles)
|
||||
table.load();
|
||||
}
|
||||
if (manager.getBackend() != null) {
|
||||
|
||||
if (manager.getBackend() != null)
|
||||
manager.getBackend().updateConfig(this);
|
||||
}
|
||||
|
||||
if (manager.getCheckManager() != null)
|
||||
manager.getCheckManager().loadCheckIgnoreList(this);
|
||||
}
|
||||
|
||||
private void checkReload(ConfigurationFile file) {
|
||||
@@ -146,20 +171,20 @@ public class Configuration {
|
||||
|
||||
private void removeOldFiles() {
|
||||
ArrayList<String> removed = new ArrayList<String>();
|
||||
File configFile = new File(AntiCheat.getPlugin().getDataFolder(), "config.yml");
|
||||
File configFile = new File(AntiCheatReloaded.getPlugin().getDataFolder(), "config.yml");
|
||||
if (configFile.exists() && YamlConfiguration.loadConfiguration(configFile).getString("System.Auto update") != null) {
|
||||
configFile.renameTo(new File(AntiCheat.getPlugin().getDataFolder(), "config.old"));
|
||||
configFile.renameTo(new File(AntiCheatReloaded.getPlugin().getDataFolder(), "config.old"));
|
||||
removed.add("config.yml has been renamed to config.old and replaced with the new config.yml");
|
||||
}
|
||||
File eventsFile = new File(AntiCheat.getPlugin().getDataFolder(), "events.yml");
|
||||
File eventsFile = new File(AntiCheatReloaded.getPlugin().getDataFolder(), "events.yml");
|
||||
if (eventsFile.exists()) {
|
||||
eventsFile.renameTo(new File(AntiCheat.getPlugin().getDataFolder(), "events.old"));
|
||||
eventsFile.renameTo(new File(AntiCheatReloaded.getPlugin().getDataFolder(), "events.old"));
|
||||
removed.add("events.yml has been renamed to events.old and replaced with groups.yml and rules.yml");
|
||||
}
|
||||
if (removed.size() > 0) {
|
||||
AntiCheat.getPlugin().getLogger().info("You are upgrading from an old version of AntiCheat. Due to configuration changes, the following files have been modified:");
|
||||
AntiCheatReloaded.getPlugin().getLogger().info("You are upgrading from an old version of AntiCheat. Due to configuration changes, the following files have been modified:");
|
||||
for (String s : removed) {
|
||||
AntiCheat.getPlugin().getLogger().info(s);
|
||||
AntiCheatReloaded.getPlugin().getLogger().info(s);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -191,4 +216,8 @@ public class Configuration {
|
||||
public Magic getMagic() {
|
||||
return magic;
|
||||
}
|
||||
|
||||
public Checks getChecks() {
|
||||
return checks;
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
/*
|
||||
* AntiCheat for Bukkit.
|
||||
* Copyright (C) 2012-2014 AntiCheat Team | http://gravitydevelopment.net
|
||||
* AntiCheatReloaded for Bukkit and Spigot.
|
||||
* Copyright (c) 2012-2015 AntiCheat Team
|
||||
* Copyright (c) 2016-2022 Rammelkast
|
||||
*
|
||||
* 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
|
||||
@@ -21,11 +22,12 @@ package com.rammelkast.anticheatreloaded.config;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
|
||||
import com.rammelkast.anticheatreloaded.AntiCheat;
|
||||
import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
|
||||
import com.rammelkast.anticheatreloaded.config.yaml.CommentedConfiguration;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
|
||||
public class ConfigurationFile {
|
||||
|
||||
@@ -36,21 +38,21 @@ public class ConfigurationFile {
|
||||
private FileConfiguration defaultConfigFile;
|
||||
private Configuration config;
|
||||
|
||||
private AntiCheat plugin;
|
||||
private AntiCheatReloaded plugin;
|
||||
|
||||
private boolean saveDefault;
|
||||
|
||||
protected boolean needsReload;
|
||||
|
||||
public ConfigurationFile(AntiCheat plugin, Configuration config, String fileName) {
|
||||
public ConfigurationFile(AntiCheatReloaded plugin, Configuration config, String fileName) {
|
||||
this(plugin, config, fileName, true);
|
||||
}
|
||||
|
||||
public ConfigurationFile(AntiCheat plugin, Configuration config, String fileName, boolean saveDefault) {
|
||||
public ConfigurationFile(AntiCheatReloaded plugin, Configuration config, String fileName, boolean saveDefault) {
|
||||
this(plugin, config, fileName, saveDefault, new File(plugin.getDataFolder(), fileName));
|
||||
}
|
||||
|
||||
public ConfigurationFile(AntiCheat plugin, Configuration config, String fileName, boolean saveDefault, File rawFile) {
|
||||
public ConfigurationFile(AntiCheatReloaded plugin, Configuration config, String fileName, boolean saveDefault, File rawFile) {
|
||||
// Can't change with user editing
|
||||
this.plugin = plugin;
|
||||
this.config = config;
|
||||
@@ -59,7 +61,13 @@ public class ConfigurationFile {
|
||||
this.saveDefault = saveDefault;
|
||||
|
||||
if (saveDefault) {
|
||||
defaultConfigFile = YamlConfiguration.loadConfiguration(plugin.getResource(fileName));
|
||||
InputStreamReader reader = new InputStreamReader(plugin.getResource(fileName));
|
||||
defaultConfigFile = YamlConfiguration.loadConfiguration(reader);
|
||||
try {
|
||||
reader.close();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
load();
|
||||
}
|
||||
@@ -162,7 +170,8 @@ public class ConfigurationFile {
|
||||
return path;
|
||||
}
|
||||
|
||||
public T getValue() {
|
||||
@SuppressWarnings("unchecked")
|
||||
public T getValue() {
|
||||
return (T) value;
|
||||
}
|
||||
|
||||
@@ -172,7 +181,8 @@ public class ConfigurationFile {
|
||||
return value;
|
||||
}
|
||||
|
||||
public T getDefaultValue() {
|
||||
@SuppressWarnings("unchecked")
|
||||
public T getDefaultValue() {
|
||||
return (T) getDefaultConfigFile().get(path);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
/*
|
||||
* AntiCheat for Bukkit.
|
||||
* Copyright (C) 2012-2014 AntiCheat Team | http://gravitydevelopment.net
|
||||
* AntiCheatReloaded for Bukkit and Spigot.
|
||||
* Copyright (c) 2012-2015 AntiCheat Team
|
||||
* Copyright (c) 2016-2022 Rammelkast
|
||||
*
|
||||
* 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
|
||||
@@ -20,7 +21,7 @@ package com.rammelkast.anticheatreloaded.config;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
|
||||
import com.rammelkast.anticheatreloaded.AntiCheat;
|
||||
import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
|
||||
import com.rammelkast.anticheatreloaded.util.enterprise.Database;
|
||||
|
||||
import java.sql.Connection;
|
||||
@@ -59,7 +60,7 @@ public class ConfigurationTable {
|
||||
|
||||
public void reload() {
|
||||
// For after sql inserts have been made
|
||||
Bukkit.getScheduler().runTask(AntiCheat.getPlugin(), new Runnable() {
|
||||
Bukkit.getScheduler().runTask(AntiCheatReloaded.getPlugin(), new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
load();
|
||||
@@ -103,6 +104,7 @@ public class ConfigurationTable {
|
||||
return false;
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public void convertToUUID(String colName) {
|
||||
String sqlSelect = "SELECT " + colName + " FROM " + getFullTable();
|
||||
String sqlUpdate = "UPDATE " + getFullTable() + " SET " + colName + " = ? WHERE " + colName + " = ?";
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
/*
|
||||
* AntiCheat for Bukkit.
|
||||
* Copyright (C) 2012-2014 AntiCheat Team | http://gravitydevelopment.net
|
||||
* AntiCheatReloaded for Bukkit and Spigot.
|
||||
* Copyright (c) 2012-2015 AntiCheat Team
|
||||
* Copyright (c) 2016-2022 Rammelkast
|
||||
*
|
||||
* 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
|
||||
@@ -20,7 +21,7 @@ package com.rammelkast.anticheatreloaded.config.files;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.rammelkast.anticheatreloaded.AntiCheat;
|
||||
import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
|
||||
import com.rammelkast.anticheatreloaded.config.Configuration;
|
||||
import com.rammelkast.anticheatreloaded.config.ConfigurationFile;
|
||||
|
||||
@@ -29,13 +30,13 @@ public class Config extends ConfigurationFile {
|
||||
public static final String FILENAME = "config.yml";
|
||||
|
||||
public ConfigValue<Boolean> logToConsole;
|
||||
public ConfigValue<Boolean> autoUpdate;
|
||||
public ConfigValue<Boolean> verboseStartup;
|
||||
public ConfigValue<Boolean> silentMode;
|
||||
public ConfigValue<Boolean> exemptOp;
|
||||
|
||||
public ConfigValue<Boolean> eventChains;
|
||||
public ConfigValue<Boolean> enterprise;
|
||||
public ConfigValue<Boolean> debugMode;
|
||||
public ConfigValue<Boolean> disableBroadcast;
|
||||
|
||||
public ConfigValue<Boolean> blockChatSpamSpeed;
|
||||
public ConfigValue<Boolean> blockCommandSpamSpeed;
|
||||
@@ -49,9 +50,11 @@ public class Config extends ConfigurationFile {
|
||||
public ConfigValue<Boolean> logToFile;
|
||||
|
||||
public ConfigValue<List<String>> disabledWorlds;
|
||||
public ConfigValue<List<String>> disabledChecks;
|
||||
|
||||
public ConfigValue<Integer> notifyEveryVl;
|
||||
public ConfigValue<Integer> maxSetbackDistance;
|
||||
|
||||
public Config(AntiCheat plugin, Configuration config) {
|
||||
public Config(AntiCheatReloaded plugin, Configuration config) {
|
||||
super(plugin, config, FILENAME);
|
||||
}
|
||||
|
||||
@@ -59,12 +62,13 @@ public class Config extends ConfigurationFile {
|
||||
public void open() {
|
||||
logToConsole = new ConfigValue<Boolean>("system.log-to-console");
|
||||
|
||||
autoUpdate = new ConfigValue<Boolean>("system.auto-update");
|
||||
verboseStartup = new ConfigValue<Boolean>("system.verbose-startup");
|
||||
silentMode = new ConfigValue<Boolean>("system.silent-mode");
|
||||
exemptOp = new ConfigValue<Boolean>("system.exempt-op");
|
||||
eventChains = new ConfigValue<Boolean>("system.event-chains");
|
||||
enterprise = new ConfigValue<Boolean>("system.enterprise");
|
||||
debugMode = new ConfigValue<Boolean>("system.debug-mode");
|
||||
disableBroadcast = new ConfigValue<Boolean>("system.disable-broadcast");
|
||||
|
||||
blockChatSpamSpeed = new ConfigValue<Boolean>("spam.chat.block-speed");
|
||||
blockChatSpamRepetition = new ConfigValue<Boolean>("spam.chat.block-repetition");
|
||||
@@ -79,6 +83,14 @@ public class Config extends ConfigurationFile {
|
||||
logToFile = new ConfigValue<Boolean>("system.log-to-file");
|
||||
|
||||
disabledWorlds = new ConfigValue<List<String>>("disable-in");
|
||||
disabledChecks = new ConfigValue<List<String>>("disabled-checks");
|
||||
|
||||
notifyEveryVl = new ConfigValue<Integer>("system.notify-every-vl");
|
||||
if (notifyEveryVl.getValue() < 1) {
|
||||
notifyEveryVl.setValue(5);
|
||||
}
|
||||
maxSetbackDistance = new ConfigValue<Integer>("system.max-setback-distance");
|
||||
if (maxSetbackDistance.getValue() < 5) {
|
||||
maxSetbackDistance.setValue(50);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
/*
|
||||
* AntiCheat for Bukkit.
|
||||
* Copyright (C) 2012-2014 AntiCheat Team | http://gravitydevelopment.net
|
||||
* AntiCheatReloaded for Bukkit and Spigot.
|
||||
* Copyright (c) 2012-2015 AntiCheat Team
|
||||
* Copyright (c) 2016-2022 Rammelkast
|
||||
*
|
||||
* 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
|
||||
@@ -18,7 +19,7 @@
|
||||
|
||||
package com.rammelkast.anticheatreloaded.config.files;
|
||||
|
||||
import com.rammelkast.anticheatreloaded.AntiCheat;
|
||||
import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
|
||||
import com.rammelkast.anticheatreloaded.config.Configuration;
|
||||
import com.rammelkast.anticheatreloaded.config.ConfigurationFile;
|
||||
import com.rammelkast.anticheatreloaded.util.enterprise.Database;
|
||||
@@ -43,7 +44,7 @@ public class Enterprise extends ConfigurationFile {
|
||||
|
||||
public Database database;
|
||||
|
||||
public Enterprise(AntiCheat plugin, Configuration config) {
|
||||
public Enterprise(AntiCheatReloaded plugin, Configuration config) {
|
||||
super(plugin, config, FILENAME);
|
||||
}
|
||||
|
||||
|
||||
+3
-2
@@ -1,6 +1,7 @@
|
||||
/*
|
||||
* AntiCheat for Bukkit.
|
||||
* Copyright (C) 2012-2014 AntiCheat Team | http://gravitydevelopment.net
|
||||
* AntiCheatReloaded for Bukkit and Spigot.
|
||||
* Copyright (c) 2012-2015 AntiCheat Team
|
||||
* Copyright (c) 2016-2022 Rammelkast
|
||||
*
|
||||
* 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
|
||||
|
||||
+14
-5
@@ -1,6 +1,7 @@
|
||||
/*
|
||||
* AntiCheat for Bukkit.
|
||||
* Copyright (C) 2012-2014 AntiCheat Team | http://gravitydevelopment.net
|
||||
* AntiCheatReloaded for Bukkit and Spigot.
|
||||
* Copyright (c) 2012-2015 AntiCheat Team
|
||||
* Copyright (c) 2016-2022 Rammelkast
|
||||
*
|
||||
* 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
|
||||
@@ -21,11 +22,13 @@ package com.rammelkast.anticheatreloaded.config.holders.mysql;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
|
||||
import com.rammelkast.anticheatreloaded.AntiCheat;
|
||||
import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
|
||||
import com.rammelkast.anticheatreloaded.config.Configuration;
|
||||
import com.rammelkast.anticheatreloaded.config.ConfigurationTable;
|
||||
import com.rammelkast.anticheatreloaded.config.providers.Lang;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.lang.reflect.InvocationHandler;
|
||||
import java.lang.reflect.Method;
|
||||
import java.sql.PreparedStatement;
|
||||
@@ -50,7 +53,13 @@ public class MySQLLangHolder extends ConfigurationTable implements InvocationHan
|
||||
|
||||
@Override
|
||||
public void open() {
|
||||
defaults = YamlConfiguration.loadConfiguration(AntiCheat.getPlugin().getResource("lang.yml"));
|
||||
InputStreamReader reader = new InputStreamReader(AntiCheatReloaded.getPlugin().getResource("lang.yml"));
|
||||
defaults = YamlConfiguration.loadConfiguration(reader);
|
||||
try {
|
||||
reader.close();
|
||||
} catch (IOException e1) {
|
||||
e1.printStackTrace();
|
||||
}
|
||||
|
||||
stringValues = new HashMap<String, String>();
|
||||
listValues = new HashMap<String, List<String>>();
|
||||
@@ -142,7 +151,7 @@ public class MySQLLangHolder extends ConfigurationTable implements InvocationHan
|
||||
return value;
|
||||
}
|
||||
}
|
||||
AntiCheat.getPlugin().getLogger().severe("The lang value " + key + " couldn't be found.");
|
||||
AntiCheatReloaded.getPlugin().getLogger().severe("The lang value " + key + " couldn't be found.");
|
||||
return "Language error. See console for details.";
|
||||
}
|
||||
|
||||
|
||||
+11
-10
@@ -1,6 +1,7 @@
|
||||
/*
|
||||
* AntiCheat for Bukkit.
|
||||
* Copyright (C) 2012-2014 AntiCheat Team | http://gravitydevelopment.net
|
||||
* AntiCheatReloaded for Bukkit and Spigot.
|
||||
* Copyright (c) 2012-2015 AntiCheat Team
|
||||
* Copyright (c) 2016-2022 Rammelkast
|
||||
*
|
||||
* 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
|
||||
@@ -20,7 +21,7 @@ package com.rammelkast.anticheatreloaded.config.holders.mysql;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
|
||||
import com.rammelkast.anticheatreloaded.AntiCheat;
|
||||
import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
|
||||
import com.rammelkast.anticheatreloaded.config.Configuration;
|
||||
import com.rammelkast.anticheatreloaded.config.ConfigurationTable;
|
||||
import com.rammelkast.anticheatreloaded.config.providers.Levels;
|
||||
@@ -81,11 +82,11 @@ public class MySQLLevelsHolder extends ConfigurationTable implements Levels {
|
||||
|
||||
@Override
|
||||
public void saveLevelFromUser(final User user) {
|
||||
Bukkit.getScheduler().runTaskAsynchronously(AntiCheat.getPlugin(), new Runnable() {
|
||||
Bukkit.getScheduler().runTaskAsynchronously(AntiCheatReloaded.getPlugin(), new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (!user.isWaitingOnLevelSync()) {
|
||||
AntiCheat.debugLog("Saving level from " + user.getUUID() + ". Value: " + user.getLevel());
|
||||
AntiCheatReloaded.debugLog("Saving level from " + user.getUUID() + ". Value: " + user.getLevel());
|
||||
try {
|
||||
PreparedStatement statement = getConnection().prepareStatement(sqlSave);
|
||||
statement.setString(1, user.getUUID().toString());
|
||||
@@ -101,14 +102,14 @@ public class MySQLLevelsHolder extends ConfigurationTable implements Levels {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
AntiCheat.getManager().getUserManager().remove(user);
|
||||
AntiCheatReloaded.getManager().getUserManager().removeUser(user);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadLevelToUser(final User user) {
|
||||
Bukkit.getScheduler().runTaskAsynchronously(AntiCheat.getPlugin(), new Runnable() {
|
||||
Bukkit.getScheduler().runTaskAsynchronously(AntiCheatReloaded.getPlugin(), new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
@@ -120,7 +121,7 @@ public class MySQLLevelsHolder extends ConfigurationTable implements Levels {
|
||||
boolean has = false;
|
||||
while (set.next()) {
|
||||
has = true;
|
||||
AntiCheat.debugLog("Syncing level to " + user.getUUID() + ". Value: " + set.getInt("level"));
|
||||
AntiCheatReloaded.debugLog("Syncing level to " + user.getUUID() + ". Value: " + set.getInt("level"));
|
||||
user.setLevel(set.getInt("level"));
|
||||
user.setLevelSyncTimestamp(set.getTimestamp("last_update"));
|
||||
}
|
||||
@@ -162,7 +163,7 @@ public class MySQLLevelsHolder extends ConfigurationTable implements Levels {
|
||||
|
||||
@Override
|
||||
public void updateLevelToUser(final User user) {
|
||||
Bukkit.getScheduler().runTaskAsynchronously(AntiCheat.getPlugin(), new Runnable() {
|
||||
Bukkit.getScheduler().runTaskAsynchronously(AntiCheatReloaded.getPlugin(), new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
@@ -174,7 +175,7 @@ public class MySQLLevelsHolder extends ConfigurationTable implements Levels {
|
||||
ResultSet set = statement.executeQuery();
|
||||
|
||||
while (set.next()) {
|
||||
AntiCheat.debugLog("Syncing level to " + user.getUUID() + ". Value: " + set.getInt("level"));
|
||||
AntiCheatReloaded.debugLog("Syncing level to " + user.getUUID() + ". Value: " + set.getInt("level"));
|
||||
user.setLevel(set.getInt("level"));
|
||||
user.setLevelSyncTimestamp(set.getTimestamp("last_update"));
|
||||
}
|
||||
|
||||
+15
-6
@@ -1,6 +1,7 @@
|
||||
/*
|
||||
* AntiCheat for Bukkit.
|
||||
* Copyright (C) 2012-2014 AntiCheat Team | http://gravitydevelopment.net
|
||||
* AntiCheatReloaded for Bukkit and Spigot.
|
||||
* Copyright (c) 2012-2015 AntiCheat Team
|
||||
* Copyright (c) 2016-2022 Rammelkast
|
||||
*
|
||||
* 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
|
||||
@@ -21,11 +22,13 @@ package com.rammelkast.anticheatreloaded.config.holders.mysql;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
|
||||
import com.rammelkast.anticheatreloaded.AntiCheat;
|
||||
import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
|
||||
import com.rammelkast.anticheatreloaded.config.Configuration;
|
||||
import com.rammelkast.anticheatreloaded.config.ConfigurationTable;
|
||||
import com.rammelkast.anticheatreloaded.config.providers.Magic;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.lang.reflect.InvocationHandler;
|
||||
import java.lang.reflect.Method;
|
||||
import java.sql.ResultSet;
|
||||
@@ -47,7 +50,13 @@ public class MySQLMagicHolder extends ConfigurationTable implements InvocationHa
|
||||
|
||||
@Override
|
||||
public void open() {
|
||||
defaults = YamlConfiguration.loadConfiguration(AntiCheat.getPlugin().getResource("magic.yml"));
|
||||
InputStreamReader reader = new InputStreamReader(AntiCheatReloaded.getPlugin().getResource("magic.yml"));
|
||||
defaults = YamlConfiguration.loadConfiguration(reader);
|
||||
try {
|
||||
reader.close();
|
||||
} catch (IOException e1) {
|
||||
e1.printStackTrace();
|
||||
}
|
||||
|
||||
ints = new HashMap<String, Integer>();
|
||||
doubles = new HashMap<String, Double>();
|
||||
@@ -94,7 +103,7 @@ public class MySQLMagicHolder extends ConfigurationTable implements InvocationHa
|
||||
} else if (set.getObject("value_double") != null) {
|
||||
doubles.put(key, set.getDouble("value_double"));
|
||||
} else {
|
||||
AntiCheat.getPlugin().getLogger().severe("The magic value " + key + " loaded from the database did not have a value configured. Using the default value.");
|
||||
AntiCheatReloaded.getPlugin().getLogger().severe("The magic value " + key + " loaded from the database did not have a value configured. Using the default value.");
|
||||
for (int i=1;i<=methods.length;i++) {
|
||||
String name = methods[i-1].getName();
|
||||
if (name.equalsIgnoreCase(key)) {
|
||||
@@ -141,7 +150,7 @@ public class MySQLMagicHolder extends ConfigurationTable implements InvocationHa
|
||||
return value;
|
||||
}
|
||||
}
|
||||
AntiCheat.getPlugin().getLogger().severe("The magic value " + key + " couldn't be found.");
|
||||
AntiCheatReloaded.getPlugin().getLogger().severe("The magic value " + key + " couldn't be found.");
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
+5
-4
@@ -1,6 +1,7 @@
|
||||
/*
|
||||
* AntiCheat for Bukkit.
|
||||
* Copyright (C) 2012-2014 AntiCheat Team | http://gravitydevelopment.net
|
||||
* AntiCheatReloaded for Bukkit and Spigot.
|
||||
* Copyright (c) 2012-2015 AntiCheat Team
|
||||
* Copyright (c) 2016-2022 Rammelkast
|
||||
*
|
||||
* 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
|
||||
@@ -23,7 +24,7 @@ import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import com.rammelkast.anticheatreloaded.AntiCheat;
|
||||
import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
|
||||
import com.rammelkast.anticheatreloaded.config.Configuration;
|
||||
import com.rammelkast.anticheatreloaded.config.ConfigurationTable;
|
||||
import com.rammelkast.anticheatreloaded.config.providers.Rules;
|
||||
@@ -65,7 +66,7 @@ public class MySQLRulesHolder extends ConfigurationTable implements Rules {
|
||||
if (rule != null) {
|
||||
this.rules.add(rule);
|
||||
} else {
|
||||
AntiCheat.getPlugin().getLogger().warning("Couldn't load rule '" + string + "' from the database. Improper format used.");
|
||||
AntiCheatReloaded.getPlugin().getLogger().warning("Couldn't load rule '" + string + "' from the database. Improper format used.");
|
||||
}
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
|
||||
+121
@@ -0,0 +1,121 @@
|
||||
/*
|
||||
* AntiCheatReloaded for Bukkit and Spigot.
|
||||
* Copyright (c) 2012-2015 AntiCheat Team
|
||||
* Copyright (c) 2016-2022 Rammelkast
|
||||
*
|
||||
* 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 3 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, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.rammelkast.anticheatreloaded.config.holders.yaml;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
|
||||
import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
|
||||
import com.rammelkast.anticheatreloaded.check.CheckType;
|
||||
import com.rammelkast.anticheatreloaded.config.Configuration;
|
||||
import com.rammelkast.anticheatreloaded.config.ConfigurationFile;
|
||||
import com.rammelkast.anticheatreloaded.config.providers.Checks;
|
||||
|
||||
public class YamlChecksHolder extends ConfigurationFile implements Checks {
|
||||
|
||||
public static final String FILENAME = "checks.yml";
|
||||
|
||||
public YamlChecksHolder(AntiCheatReloaded plugin, Configuration config) {
|
||||
super(plugin, config, FILENAME);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void open() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getBoolean(CheckType checkType, String subcheck, String name) {
|
||||
final ConfigurationSection section = this.getConfigFile().getConfigurationSection(checkType.getName().toLowerCase()).getConfigurationSection(subcheck);
|
||||
if (!section.contains(name)) {
|
||||
AntiCheatReloaded.getPlugin().getLogger().warning("Configuration is missing option '" + section.getCurrentPath() + "." + name + "'");
|
||||
return false;
|
||||
}
|
||||
return section.getBoolean(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSubcheckEnabled(CheckType checkType, String subcheck) {
|
||||
return this.getBoolean(checkType, subcheck, "enabled");
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getDouble(CheckType checkType, String subcheck, String name) {
|
||||
final ConfigurationSection section = this.getConfigFile().getConfigurationSection(checkType.getName().toLowerCase()).getConfigurationSection(subcheck);
|
||||
if (!section.contains(name)) {
|
||||
AntiCheatReloaded.getPlugin().getLogger().warning("Configuration is missing option '" + section.getCurrentPath() + "." + name + "'");
|
||||
return 0.0D;
|
||||
}
|
||||
return section.getDouble(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getInteger(CheckType checkType, String subcheck, String name) {
|
||||
final ConfigurationSection section = this.getConfigFile().getConfigurationSection(checkType.getName().toLowerCase()).getConfigurationSection(subcheck);
|
||||
if (!section.contains(name)) {
|
||||
AntiCheatReloaded.getPlugin().getLogger().warning("Configuration is missing option '" + section.getCurrentPath() + "." + name + "'");
|
||||
return 0;
|
||||
}
|
||||
return section.getInt(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getBoolean(CheckType checkType, String name) {
|
||||
final ConfigurationSection section = this.getConfigFile().getConfigurationSection(checkType.getName().toLowerCase());
|
||||
if (!section.contains(name)) {
|
||||
AntiCheatReloaded.getPlugin().getLogger().warning("Configuration is missing option '" + section.getCurrentPath() + "." + name + "'");
|
||||
return false;
|
||||
}
|
||||
return section.getBoolean(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getDouble(CheckType checkType, String name) {
|
||||
final ConfigurationSection section = this.getConfigFile().getConfigurationSection(checkType.getName().toLowerCase());
|
||||
if (!section.contains(name)) {
|
||||
AntiCheatReloaded.getPlugin().getLogger().warning("Configuration is missing option '" + section.getCurrentPath() + "." + name + "'");
|
||||
return 0.0D;
|
||||
}
|
||||
return section.getDouble(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getInteger(CheckType checkType, String name) {
|
||||
final ConfigurationSection section = this.getConfigFile().getConfigurationSection(checkType.getName().toLowerCase());
|
||||
if (!section.contains(name)) {
|
||||
AntiCheatReloaded.getPlugin().getLogger().warning("Configuration is missing option '" + section.getCurrentPath() + "." + name + "'");
|
||||
return 0;
|
||||
}
|
||||
return section.getInt(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEnabled(CheckType checkType) {
|
||||
// If the root of a check has no enabled or disabled option, it has to be configured on a subcheck basis
|
||||
if (!this.getConfigFile().isConfigurationSection(checkType.getName().toLowerCase())) {
|
||||
Bukkit.getConsoleSender().sendMessage(ChatColor.GOLD + "" + ChatColor.BOLD + "ACR " + ChatColor.RED
|
||||
+ "Missing configuration settings for " + checkType.getName() + "!");
|
||||
return true;
|
||||
}
|
||||
if (!this.getConfigFile().getConfigurationSection(checkType.getName().toLowerCase()).contains("enabled"))
|
||||
return true;
|
||||
return this.getConfigFile().getConfigurationSection(checkType.getName().toLowerCase()).getBoolean("enabled");
|
||||
}
|
||||
}
|
||||
+5
-4
@@ -1,6 +1,7 @@
|
||||
/*
|
||||
* AntiCheat for Bukkit.
|
||||
* Copyright (C) 2012-2014 AntiCheat Team | http://gravitydevelopment.net
|
||||
* AntiCheatReloaded for Bukkit and Spigot.
|
||||
* Copyright (c) 2012-2015 AntiCheat Team
|
||||
* Copyright (c) 2016-2022 Rammelkast
|
||||
*
|
||||
* 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
|
||||
@@ -20,7 +21,7 @@ package com.rammelkast.anticheatreloaded.config.holders.yaml;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import com.rammelkast.anticheatreloaded.AntiCheat;
|
||||
import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
|
||||
import com.rammelkast.anticheatreloaded.config.Configuration;
|
||||
import com.rammelkast.anticheatreloaded.config.ConfigurationFile;
|
||||
import com.rammelkast.anticheatreloaded.config.providers.Groups;
|
||||
@@ -34,7 +35,7 @@ public class YamlGroupsHolder extends ConfigurationFile implements Groups {
|
||||
|
||||
private int highestLevel;
|
||||
|
||||
public YamlGroupsHolder(AntiCheat plugin, Configuration config) {
|
||||
public YamlGroupsHolder(AntiCheatReloaded plugin, Configuration config) {
|
||||
super(plugin, config, FILENAME);
|
||||
}
|
||||
|
||||
|
||||
+6
-5
@@ -1,6 +1,7 @@
|
||||
/*
|
||||
* AntiCheat for Bukkit.
|
||||
* Copyright (C) 2012-2014 AntiCheat Team | http://gravitydevelopment.net
|
||||
* AntiCheatReloaded for Bukkit and Spigot.
|
||||
* Copyright (c) 2012-2015 AntiCheat Team
|
||||
* Copyright (c) 2016-2022 Rammelkast
|
||||
*
|
||||
* 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
|
||||
@@ -22,7 +23,7 @@ import java.lang.reflect.InvocationHandler;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.List;
|
||||
|
||||
import com.rammelkast.anticheatreloaded.AntiCheat;
|
||||
import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
|
||||
import com.rammelkast.anticheatreloaded.config.Configuration;
|
||||
import com.rammelkast.anticheatreloaded.config.ConfigurationFile;
|
||||
|
||||
@@ -30,7 +31,7 @@ public class YamlLangHolder extends ConfigurationFile implements InvocationHandl
|
||||
|
||||
public static final String FILENAME = "lang.yml";
|
||||
|
||||
public YamlLangHolder(AntiCheat plugin, Configuration config) {
|
||||
public YamlLangHolder(AntiCheatReloaded plugin, Configuration config) {
|
||||
super(plugin, config, FILENAME);
|
||||
}
|
||||
|
||||
@@ -76,7 +77,7 @@ public class YamlLangHolder extends ConfigurationFile implements InvocationHandl
|
||||
return value.getValue();
|
||||
}
|
||||
}
|
||||
AntiCheat.getPlugin().getLogger().severe("The lang value " + key + " couldn't be found.");
|
||||
AntiCheatReloaded.getPlugin().getLogger().severe("The lang value " + key + " couldn't be found.");
|
||||
return "Language error. See console for details.";
|
||||
}
|
||||
}
|
||||
+7
-6
@@ -1,6 +1,7 @@
|
||||
/*
|
||||
* AntiCheat for Bukkit.
|
||||
* Copyright (C) 2012-2014 AntiCheat Team | http://gravitydevelopment.net
|
||||
* AntiCheatReloaded for Bukkit and Spigot.
|
||||
* Copyright (c) 2012-2015 AntiCheat Team
|
||||
* Copyright (c) 2016-2022 Rammelkast
|
||||
*
|
||||
* 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
|
||||
@@ -21,7 +22,7 @@ package com.rammelkast.anticheatreloaded.config.holders.yaml;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
import com.rammelkast.anticheatreloaded.AntiCheat;
|
||||
import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
|
||||
import com.rammelkast.anticheatreloaded.config.Configuration;
|
||||
import com.rammelkast.anticheatreloaded.config.ConfigurationFile;
|
||||
import com.rammelkast.anticheatreloaded.config.providers.Levels;
|
||||
@@ -31,7 +32,7 @@ public class YamlLevelsHolder extends ConfigurationFile implements Levels {
|
||||
|
||||
public static final String FILENAME = "data/levels.yml";
|
||||
|
||||
public YamlLevelsHolder(AntiCheat plugin, Configuration config) {
|
||||
public YamlLevelsHolder(AntiCheatReloaded plugin, Configuration config) {
|
||||
super(plugin, config, FILENAME, false);
|
||||
}
|
||||
|
||||
@@ -47,7 +48,7 @@ public class YamlLevelsHolder extends ConfigurationFile implements Levels {
|
||||
|
||||
private void saveLevelFromUser(User user, boolean remove) {
|
||||
saveLevel(user.getUUID(), user.getLevel());
|
||||
if (remove) AntiCheat.getManager().getUserManager().remove(user);
|
||||
if (remove) AntiCheatReloaded.getManager().getUserManager().removeUser(user);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -73,6 +74,6 @@ public class YamlLevelsHolder extends ConfigurationFile implements Levels {
|
||||
}
|
||||
|
||||
private void saveLevel(UUID uuid, int level) {
|
||||
new ConfigValue<Integer>(uuid.toString(), false).setValue(new Integer(level));
|
||||
new ConfigValue<Integer>(uuid.toString(), false).setValue(level);
|
||||
}
|
||||
}
|
||||
+6
-5
@@ -1,6 +1,7 @@
|
||||
/*
|
||||
* AntiCheat for Bukkit.
|
||||
* Copyright (C) 2012-2014 AntiCheat Team | http://gravitydevelopment.net
|
||||
* AntiCheatReloaded for Bukkit and Spigot.
|
||||
* Copyright (c) 2012-2015 AntiCheat Team
|
||||
* Copyright (c) 2016-2022 Rammelkast
|
||||
*
|
||||
* 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
|
||||
@@ -21,7 +22,7 @@ package com.rammelkast.anticheatreloaded.config.holders.yaml;
|
||||
import java.lang.reflect.InvocationHandler;
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
import com.rammelkast.anticheatreloaded.AntiCheat;
|
||||
import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
|
||||
import com.rammelkast.anticheatreloaded.config.Configuration;
|
||||
import com.rammelkast.anticheatreloaded.config.ConfigurationFile;
|
||||
|
||||
@@ -29,7 +30,7 @@ public class YamlMagicHolder extends ConfigurationFile implements InvocationHand
|
||||
|
||||
public static final String FILENAME = "magic.yml";
|
||||
|
||||
public YamlMagicHolder(AntiCheat plugin, Configuration config) {
|
||||
public YamlMagicHolder(AntiCheatReloaded plugin, Configuration config) {
|
||||
super(plugin, config, FILENAME);
|
||||
}
|
||||
|
||||
@@ -41,7 +42,7 @@ public class YamlMagicHolder extends ConfigurationFile implements InvocationHand
|
||||
} else if (method.getReturnType().getSimpleName().equals("double")) {
|
||||
return new ConfigValue<Double>(key).getValue();
|
||||
} else {
|
||||
AntiCheat.getPlugin().getLogger().severe("The magic value " + key + " couldn't be found.");
|
||||
AntiCheatReloaded.getPlugin().getLogger().severe("The magic value " + key + " couldn't be found.");
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
+6
-5
@@ -1,6 +1,7 @@
|
||||
/*
|
||||
* AntiCheat for Bukkit.
|
||||
* Copyright (C) 2012-2014 AntiCheat Team | http://gravitydevelopment.net
|
||||
* AntiCheatReloaded for Bukkit and Spigot.
|
||||
* Copyright (c) 2012-2015 AntiCheat Team
|
||||
* Copyright (c) 2016-2022 Rammelkast
|
||||
*
|
||||
* 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
|
||||
@@ -21,7 +22,7 @@ package com.rammelkast.anticheatreloaded.config.holders.yaml;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import com.rammelkast.anticheatreloaded.AntiCheat;
|
||||
import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
|
||||
import com.rammelkast.anticheatreloaded.config.Configuration;
|
||||
import com.rammelkast.anticheatreloaded.config.ConfigurationFile;
|
||||
import com.rammelkast.anticheatreloaded.config.providers.Rules;
|
||||
@@ -33,7 +34,7 @@ public class YamlRulesHolder extends ConfigurationFile implements Rules {
|
||||
|
||||
private List<Rule> rules;
|
||||
|
||||
public YamlRulesHolder(AntiCheat plugin, Configuration config) {
|
||||
public YamlRulesHolder(AntiCheatReloaded plugin, Configuration config) {
|
||||
super(plugin, config, FILENAME);
|
||||
}
|
||||
|
||||
@@ -61,7 +62,7 @@ public class YamlRulesHolder extends ConfigurationFile implements Rules {
|
||||
if (rule != null) {
|
||||
this.rules.add(rule);
|
||||
} else {
|
||||
AntiCheat.getPlugin().getLogger().warning("Couldn't load rule '" + string + "' from config. Improper format used.");
|
||||
AntiCheatReloaded.getPlugin().getLogger().warning("Couldn't load rule '" + string + "' from config. Improper format used.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
/*
|
||||
* AntiCheatReloaded for Bukkit and Spigot.
|
||||
* Copyright (c) 2012-2015 AntiCheat Team
|
||||
* Copyright (c) 2016-2022 Rammelkast
|
||||
*
|
||||
* 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 3 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, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.rammelkast.anticheatreloaded.config.providers;
|
||||
|
||||
import com.rammelkast.anticheatreloaded.check.CheckType;
|
||||
|
||||
public interface Checks {
|
||||
|
||||
public boolean getBoolean(CheckType checkType, String name);
|
||||
|
||||
public boolean getBoolean(CheckType checkType, String subcheck, String name);
|
||||
|
||||
public double getDouble(CheckType checkType, String name);
|
||||
|
||||
public double getDouble(CheckType checkType, String subcheck, String name);
|
||||
|
||||
public int getInteger(CheckType checkType, String name);
|
||||
|
||||
public int getInteger(CheckType checkType, String subcheck, String name);
|
||||
|
||||
public boolean isEnabled(CheckType checkType);
|
||||
|
||||
public boolean isSubcheckEnabled(CheckType checkType, String subcheck);
|
||||
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
/*
|
||||
* AntiCheat for Bukkit.
|
||||
* Copyright (C) 2012-2014 AntiCheat Team | http://gravitydevelopment.net
|
||||
* AntiCheatReloaded for Bukkit and Spigot.
|
||||
* Copyright (c) 2012-2015 AntiCheat Team
|
||||
* Copyright (c) 2016-2022 Rammelkast
|
||||
*
|
||||
* 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
|
||||
|
||||
@@ -1,3 +1,22 @@
|
||||
/*
|
||||
* AntiCheatReloaded for Bukkit and Spigot.
|
||||
* Copyright (c) 2012-2015 AntiCheat Team
|
||||
* Copyright (c) 2016-2022 Rammelkast
|
||||
*
|
||||
* 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 3 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, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.rammelkast.anticheatreloaded.config.providers;
|
||||
|
||||
import java.util.List;
|
||||
@@ -80,4 +99,12 @@ public interface Lang {
|
||||
* @return Kicking broadcast.
|
||||
*/
|
||||
public String KICK_BROADCAST();
|
||||
|
||||
|
||||
/**
|
||||
* Get the alert prefix for staff and debug.
|
||||
*
|
||||
* @return Alert prefix.
|
||||
*/
|
||||
public String ALERT_PREFIX();
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
/*
|
||||
* AntiCheat for Bukkit.
|
||||
* Copyright (C) 2012-2014 AntiCheat Team | http://gravitydevelopment.net
|
||||
* AntiCheatReloaded for Bukkit and Spigot.
|
||||
* Copyright (c) 2012-2015 AntiCheat Team
|
||||
* Copyright (c) 2016-2022 Rammelkast
|
||||
*
|
||||
* 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
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
/*
|
||||
* AntiCheat for Bukkit.
|
||||
* Copyright (C) 2012-2014 AntiCheat Team | http://gravitydevelopment.net
|
||||
* AntiCheatReloaded for Bukkit and Spigot.
|
||||
* Copyright (c) 2012-2015 AntiCheat Team
|
||||
* Copyright (c) 2016-2022 Rammelkast
|
||||
*
|
||||
* 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
|
||||
@@ -41,340 +42,24 @@ public interface Magic {
|
||||
* Time to exempt a player from moving because of entering/exiting a vehicle; Type=SYSTEM, Leniency=INCREASE.
|
||||
*/
|
||||
public int ENTERED_EXITED_TIME();
|
||||
/**
|
||||
* Time to exempt a player from moving because of entering/exiting sneak mode; Type=SYSTEM, Leniency=INCREASE.
|
||||
*/
|
||||
public int SNEAK_TIME();
|
||||
/**
|
||||
* Time to exempt a player from moving because of teleporting; Type=SYSTEM, Leniency=INCREASE.
|
||||
*/
|
||||
public int TELEPORT_TIME();
|
||||
/**
|
||||
* Time to exempt a player from moving because of exiting fly mode; Type=SYSTEM, Leniency=INCREASE.
|
||||
*/
|
||||
public int EXIT_FLY_TIME();
|
||||
/**
|
||||
* Time to exempt a player from moving because of joining the server; Type=SYSTEM, Leniency=INCREASE.
|
||||
*/
|
||||
public int JOIN_TIME();
|
||||
/**
|
||||
* Time to exempt a player from fastbreak check because of using instant break; Type=INTEGER, Leniency=INCREASE.
|
||||
*/
|
||||
public int INSTANT_BREAK_TIME();
|
||||
/**
|
||||
* Time to exempt a player from moving because of taking damage; Type=SYSTEM, Leniency=INCREASE.
|
||||
*/
|
||||
public int DAMAGE_TIME();
|
||||
/**
|
||||
* Time to exempt a player from moving because of taking damage with knockback effects; Type=SYSTEM, Leniency=INCREASE.
|
||||
*/
|
||||
public int KNOCKBACK_DAMAGE_TIME();
|
||||
/**
|
||||
* Time to exempt a player from moving because of taking damage from an explosion; Type=SYSTEM, Leniency=INCREASE.
|
||||
*/
|
||||
public int EXPLOSION_DAMAGE_TIME();
|
||||
/**
|
||||
* Minimum time it takes to fire X projectiles; Type=SYSTEM, Leniency=DECREASE.
|
||||
*/
|
||||
public int PROJECTILE_TIME_MIN();
|
||||
/**
|
||||
* Number of projectiles to wait for before checking how long they took to fire off; Type=INTEGER.
|
||||
*/
|
||||
public int PROJECTILE_CHECK();
|
||||
/**
|
||||
* Minimum time it takes to drop X items; Type=SYSTEM, Leniency=DECREASE.
|
||||
*/
|
||||
public int DROP_TIME_MIN();
|
||||
/**
|
||||
* Number of item drops to wait for before checking how long they took to drop; Type=INTEGER.
|
||||
*/
|
||||
public int DROP_CHECK();
|
||||
/**
|
||||
* Max number of blocks that can be broken in a given time; Type=INTEGER, Leniency=INCREASE.
|
||||
*/
|
||||
public int FASTBREAK_LIMIT();
|
||||
/**
|
||||
* Time to wait before checking block breaks; Type=SYSTEM, Leniency=INCREASE.
|
||||
*/
|
||||
public int FASTBREAK_TIMEMAX();
|
||||
/**
|
||||
* Time to wait before checking block breaks in creative mode; Type=SYSTEM, Leniency=INCREASE.
|
||||
*/
|
||||
public int FASTBREAK_TIMEMAX_CREATIVE();
|
||||
/**
|
||||
* Number of times fastbreak can be observed before taking action; Type=INTEGER, Leniency=INCREASE.
|
||||
*/
|
||||
public int FASTBREAK_MAXVIOLATIONS();
|
||||
/**
|
||||
* Number of times fastbreak can be observed before taking action in creative mode; Type=INTEGER, Leniency=INCREASE.
|
||||
*/
|
||||
public int FASTBREAK_MAXVIOLATIONS_CREATIVE();
|
||||
/**
|
||||
* Time a player is forced to wait after fastbreak has been detected; Type=SYSTEM, Leniency=DECREASE.
|
||||
*/
|
||||
public int FASTBREAK_MAXVIOLATIONTIME();
|
||||
/**
|
||||
* Number of blocks that can be broken without being hit before taking action; Type=INTEGER, Leniency=INCREASE.
|
||||
*/
|
||||
public int FASTPLACE_ZEROLIMIT();
|
||||
/**
|
||||
* Minimum time in between block places; Type=SYSTEM, Leniency=DECREASE.
|
||||
*/
|
||||
public int FASTPLACE_TIMEMIN();
|
||||
/**
|
||||
* Number of times fastplace can be observed before taking action; Type=INTEGER, Leniency=INCREASE.
|
||||
*/
|
||||
public int FASTPLACE_MAXVIOLATIONS();
|
||||
/**
|
||||
* Number of times fastplace can be observed before taking action in creative mode; Type=INTEGER, Leniency=INCREASE.
|
||||
*/
|
||||
public int FASTPLACE_MAXVIOLATIONS_CREATIVE();
|
||||
/**
|
||||
* Time a player is forced to wait after fastplace has been detected; Type=SYSTEM, Leniency=DECREASE.
|
||||
*/
|
||||
public int FASTPLACE_MAXVIOLATIONTIME();
|
||||
/**
|
||||
* Number of times required to punch a block before it breaks; Type=INTEGER, Leniency=DECREASE.
|
||||
*/
|
||||
public int BLOCK_PUNCH_MIN();
|
||||
/**
|
||||
* Number of command spam violations before action one is executed; Type=INTEGER, Leniency=INCREASE.
|
||||
*/
|
||||
public int COMMAND_ACTION_ONE_LEVEL();
|
||||
/**
|
||||
* Number of command spam violations before action two is executed; Type=INTEGER, Leniency=INCREASE.
|
||||
*/
|
||||
public int COMMAND_ACTION_TWO_LEVEL();
|
||||
/**
|
||||
* Number of chat spam violations before action one is executed; Type=INTEGER, Leniency=INCREASE.
|
||||
*/
|
||||
public int CHAT_ACTION_ONE_LEVEL();
|
||||
/**
|
||||
* Number of chat spam violations before action two is executed; Type=INTEGER, Leniency=INCREASE.
|
||||
*/
|
||||
public int CHAT_ACTION_TWO_LEVEL();
|
||||
/**
|
||||
* Number of times a player can be caught in-flight before action is taken; Type=INTEGER, Leniency=INCREASE.
|
||||
*/
|
||||
public int FLIGHT_LIMIT();
|
||||
/**
|
||||
* Number of times a player can be caught in-glide before action is taken; Type=INTEGER, Leniency=INCREASE.
|
||||
*/
|
||||
public int GLIDE_LIMIT();
|
||||
/**
|
||||
* How many blocks you can travel before action is taken; Type=INTEGER, Leniency=INCREASE.
|
||||
*/
|
||||
public double FLIGHT_BLOCK_LIMIT();
|
||||
/**
|
||||
* Maximum speed that a player can climb a waterfall; Type=DOUBLE, Leniency=INCREASE.
|
||||
*/
|
||||
public double WATER_CLIMB_MAX();
|
||||
/**
|
||||
* Number of times a player can fly on the y-axis before action is taken; Type=INTEGER, Leniency=INCREASE.
|
||||
*/
|
||||
public int Y_MAXVIOLATIONS();
|
||||
/**
|
||||
* Time a player is forced to wait after flying on the y-axis; Type=SYSTEM, Leniency=DECREASE.
|
||||
*/
|
||||
public int Y_MAXVIOTIME();
|
||||
/**
|
||||
* Number of times a player can fail a velocity check before action is taken; Type=INTEGER, Leniency=INCREASE.
|
||||
* Time a player is considered to have a change in velocity; Type=SYSTEM, Leniency=INCREASE.
|
||||
*/
|
||||
public int VELOCITY_TIME();
|
||||
/**
|
||||
* Time used to schedule increasing a players velocity count - probably not touching this would be good; Type=INTEGER.
|
||||
*/
|
||||
public int VELOCITY_SCHETIME();
|
||||
/**
|
||||
* Maximum time a player is considered to have a change in velocity; Type=SYSTEM, Leniency=INCREASE.
|
||||
*/
|
||||
public int VELOCITY_CHECKTIME();
|
||||
/**
|
||||
* Time to extend a player's velocity count by; Type=SYSTEM, Leniency=INCREASE.
|
||||
*/
|
||||
public int VELOCITY_PREVENT();
|
||||
/**
|
||||
* Number of times a player can fail the velocity check before action is taken; Type=INTEGER, Leniency=INCREASE.
|
||||
*/
|
||||
public int VELOCITY_MAXTIMES();
|
||||
/**
|
||||
* Number of times a player can fail the nofall check before action is taken; Type=INTEGER, Leniency=INCREASE.
|
||||
*/
|
||||
public int NOFALL_LIMIT();
|
||||
/**
|
||||
* Number of times a player can fail the ascension check before action is taken; Type=INTEGER, Leniency=INCREASE.
|
||||
*/
|
||||
public int ASCENSION_COUNT_MAX();
|
||||
/**
|
||||
* Number of times a player can fail the ascension check while in water before action is taken; Type=INTEGER, Leniency=INCREASE.
|
||||
*/
|
||||
public int WATER_ASCENSION_VIOLATION_MAX();
|
||||
/**
|
||||
* Number of times a player can be caught speeding in water before action is taken; Type=INTEGER, Leniency=INCREASE.
|
||||
*/
|
||||
public int WATER_SPEED_VIOLATION_MAX();
|
||||
/**
|
||||
* Number of times a player can sprint without proper food level before action is taken; Type=INTEGER, Leniency=INCREASE.
|
||||
*/
|
||||
public int SPRINT_FOOD_MIN();
|
||||
/**
|
||||
* Maximum times a player can interact between animations; Type=INTEGER, Leniency=INCREASE.
|
||||
*/
|
||||
public int ANIMATION_INTERACT_MAX();
|
||||
/**
|
||||
* Minimum time between animations; Type=SYSTEM, Leniency=INCREASE.
|
||||
*/
|
||||
public int ANIMATION_MIN();
|
||||
/**
|
||||
* Minimum time between commands; Type=SYSTEM, Leniency=DECREASE.
|
||||
*/
|
||||
public int COMMAND_MIN();
|
||||
/**
|
||||
* Minimum time before repeating a command is ignored; Type=SYSTEM, Leniency=DECREASE.
|
||||
*/
|
||||
public int COMMAND_REPEAT_MIN();
|
||||
/**
|
||||
* Minimum time between chats; Type=SYSTEM, Leniency=INCREASE.
|
||||
*/
|
||||
public int CHAT_MIN();
|
||||
/**
|
||||
* Time before repeating yourself in chat is ignored; Type=SYSTEM, Leniency=INCREASE.
|
||||
*/
|
||||
public int CHAT_REPEAT_MIN();
|
||||
/**
|
||||
* Maximum speed you can travel while sprinting; Type=DOUBLE, Leniency=INCREASE.
|
||||
*/
|
||||
public double SPRINT_MIN();
|
||||
/**
|
||||
* Minimum time in between block breaks; Type=INTEGER, Leniency=DECREASE.
|
||||
*/
|
||||
public double BLOCK_BREAK_MIN();
|
||||
/**
|
||||
* Minimum time in between block placing; Type=INTEGER, Leniency=DECREASE.
|
||||
*/
|
||||
public double BLOCK_PLACE_MIN();
|
||||
/**
|
||||
* Minimum time in between eating; Type=SYSTEM, Leniency=DECREASE.
|
||||
*/
|
||||
public int EAT_TIME_MIN();
|
||||
/**
|
||||
* Maximum percent error between predicted bow force and actual bow force; Type=DOUBLE, Leniency=INCREASE.
|
||||
*/
|
||||
public double BOW_ERROR();
|
||||
/**
|
||||
* Minimum distance a player can break a block from; Type=DOUBLE, Leniency=INCREASE.
|
||||
*/
|
||||
public double BLOCK_MAX_DISTANCE();
|
||||
/**
|
||||
* Minimum distance a player can break a block from in creative mode; Type=DOUBLE, Leniency=INCREASE.
|
||||
*/
|
||||
public double BLOCK_MAX_DISTANCE_CREATIVE();
|
||||
/**
|
||||
* Minimum distance a player can damage an entity from; Type=DOUBLE, Leniency=INCREASE.
|
||||
*/
|
||||
public double ENTITY_MAX_DISTANCE();
|
||||
/**
|
||||
* Minimum distance a player can damage an entity from in creative mode; Type=DOUBLE, Leniency=INCREASE.
|
||||
*/
|
||||
public double ENTITY_MAX_DISTANCE_CREATIVE();
|
||||
/**
|
||||
* Maximum speed a player on a ladder can travel; Type=DOUBLE, Leniency=INCREASE.
|
||||
*/
|
||||
public double LADDER_Y_MAX();
|
||||
/**
|
||||
* Minimum speed a player on a ladder can travel; Type=DOUBLE, Leniency=DECREASE.
|
||||
*/
|
||||
public double LADDER_Y_MIN();
|
||||
/**
|
||||
* Maximum speed a player can travel up; Type=DOUBLE, Leniency=INCREASE.
|
||||
*/
|
||||
public double Y_SPEED_MAX();
|
||||
/**
|
||||
* Maximum difference between the player's last 2 Y values when traveling up; Type=DOUBLE, Leniency=INCREASE.
|
||||
*/
|
||||
public double Y_MAXDIFF();
|
||||
/**
|
||||
* Time in between Y difference measures; Type=SYSTEM, Leniency=DECREASE.
|
||||
*/
|
||||
public int Y_TIME();
|
||||
/**
|
||||
* Maximum speed a player can travel forwards or backwards; Type=DOUBLE, Leniency=INCREASE.
|
||||
*/
|
||||
public double XZ_SPEED_MAX();
|
||||
/**
|
||||
* Maximum speed a player can travel forwards or backwards while sprinting; Type=DOUBLE, Leniency=INCREASE.
|
||||
*/
|
||||
public double XZ_SPEED_MAX_SPRINT();
|
||||
/**
|
||||
* Maximum speed a player can travel forwards or backwards while flying; Type=DOUBLE, Leniency=INCREASE.
|
||||
*/
|
||||
public double XZ_SPEED_MAX_FLY();
|
||||
/**
|
||||
* Maximum speed a player can travel forwards or backwards while under the influence; Type=DOUBLE, Leniency=INCREASE.
|
||||
*/
|
||||
public double XZ_SPEED_MAX_POTION();
|
||||
/**
|
||||
* Maximum speed a player can travel forwards or backwards while sprinting while under the influence; Type=DOUBLE, Leniency=INCREASE.
|
||||
*/
|
||||
public double XZ_SPEED_MAX_POTION_SPRINT();
|
||||
/**
|
||||
* Maximum speed a player can travel forwards or backwards while sneaking; Type=DOUBLE, Leniency=INCREASE.
|
||||
*/
|
||||
public double XZ_SPEED_MAX_SNEAK();
|
||||
/**
|
||||
* Maximum speed a player can travel forwards or backwards in water; Type=DOUBLE, Leniency=INCREASE.
|
||||
*/
|
||||
public double XZ_SPEED_MAX_WATER();
|
||||
/**
|
||||
* Maximum speed a player can travel forwards or backwards in water while sprinting; Type=DOUBLE, Leniency=INCREASE.
|
||||
*/
|
||||
public double XZ_SPEED_MAX_WATER_SPRINT();
|
||||
/**
|
||||
* Maximum speed a player can travel forwards or backwards on soul sand; Type=DOUBLE, Leniency=INCREASE.
|
||||
*/
|
||||
public double XZ_SPEED_MAX_SOULSAND();
|
||||
/**
|
||||
* Maximum speed a player can travel forwards or backwards on soul sand while sprinting; Type=DOUBLE, Leniency=INCREASE.
|
||||
*/
|
||||
public double XZ_SPEED_MAX_SOULSAND_SPRINT();
|
||||
/**
|
||||
* Maximum speed a player can travel forwards or backwards on soul sand while under the influence; Type=DOUBLE, Leniency=INCREASE.
|
||||
*/
|
||||
public double XZ_SPEED_MAX_SOULSAND_POTION();
|
||||
/**
|
||||
* Maximum times a player can fail the speed check before action is taken; Type=INTEGER, Leniency=INCREASE.
|
||||
*/
|
||||
public int SPEED_MAX();
|
||||
/**
|
||||
* The number of clicks we should wait before checking if the player has used fast inventory; Type=INTEGER; Leniency=INCREASE.
|
||||
*/
|
||||
public int INVENTORY_CHECK();
|
||||
/**
|
||||
* The minimum time it should have taken for the player to click X times; Type=INTEGER; Leniency=INCREASE.
|
||||
*/
|
||||
public int INVENTORY_TIMEMIN();
|
||||
/**
|
||||
* The number of steps we should wait before checking if the player has used timer cheating; Type=INTEGER; Leniency=INCREASE.
|
||||
*/
|
||||
public int TIMER_STEP_CHECK();
|
||||
/**
|
||||
* The minimum time it should have taken for the player to travel X steps; Type=SYSTEM; Leniency=DECREASE.
|
||||
*/
|
||||
public int TIMER_TIMEMIN();
|
||||
/**
|
||||
* Minimum travel distance for move to be considered a teleport and subsequently be ignored; Type=INTEGER, Leniency=INCREASE.
|
||||
*/
|
||||
public int TELEPORT_MIN();
|
||||
/**
|
||||
* Maximum amount of times a player can hit a killaura bot; Type=INTEGER, Leniency=INCREASE.
|
||||
* The change milliseconds between two keepalives before considering a player to be lagging; TYPE=INTEGER, Leniency=DECREASE
|
||||
*/
|
||||
public int KILLAURA_BOTHITS();
|
||||
/**
|
||||
* Maximum amount of packets a player can send in a second; Type=INTEGER, Leniency=INCREASE.
|
||||
*/
|
||||
public int BLINK_PACKET();
|
||||
/**
|
||||
* Maximum amount of low/zero velocity before flagging; Type=INTEGER, Leniency=INCREASE.
|
||||
*/
|
||||
public int VELOCITY_AMT();
|
||||
public int LAG_DETERMINATION();
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
/*
|
||||
* AntiCheat for Bukkit.
|
||||
* Copyright (C) 2012-2014 AntiCheat Team | http://gravitydevelopment.net
|
||||
* AntiCheatReloaded for Bukkit and Spigot.
|
||||
* Copyright (c) 2012-2015 AntiCheat Team
|
||||
* Copyright (c) 2016-2022 Rammelkast
|
||||
*
|
||||
* 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
|
||||
@@ -16,7 +17,6 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
package com.rammelkast.anticheatreloaded.config.providers;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
+32
-15
@@ -1,6 +1,7 @@
|
||||
/*
|
||||
* AntiCheat for Bukkit.
|
||||
* Copyright (C) 2012-2014 AntiCheat Team | http://gravitydevelopment.net
|
||||
* AntiCheatReloaded for Bukkit and Spigot.
|
||||
* Copyright (c) 2012-2015 AntiCheat Team
|
||||
* Copyright (c) 2016-2022 Rammelkast
|
||||
*
|
||||
* 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
|
||||
@@ -15,11 +16,21 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.rammelkast.anticheatreloaded.config.yaml;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.util.ArrayDeque;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import org.apache.commons.lang.Validate;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.configuration.InvalidConfigurationException;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.bukkit.configuration.file.YamlConstructor;
|
||||
@@ -29,15 +40,6 @@ import org.yaml.snakeyaml.Yaml;
|
||||
import org.yaml.snakeyaml.error.YAMLException;
|
||||
import org.yaml.snakeyaml.representer.Representer;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.ArrayDeque;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.logging.Level;
|
||||
|
||||
/**
|
||||
* An extension of {@link org.bukkit.configuration.file.YamlConfiguration} which preserves comments.
|
||||
* Note that this implementation is not synchronized.
|
||||
@@ -85,7 +87,7 @@ public class CommentedConfiguration extends YamlConfiguration {
|
||||
blank++;
|
||||
continue;
|
||||
}
|
||||
if (lines[i].contains(COMMENT_PREFIX)) {
|
||||
if (lines[i].contains("# ")) {
|
||||
comments.put(i - blank, lines[i]);
|
||||
}
|
||||
i++;
|
||||
@@ -102,7 +104,7 @@ public class CommentedConfiguration extends YamlConfiguration {
|
||||
// String header = buildHeader(); - CommentedConfiguration
|
||||
String dump = yaml.dump(getValues(false));
|
||||
|
||||
if (dump.equals(BLANK_CONFIG)) {
|
||||
if (dump.equals("{}\\n")) {
|
||||
dump = "";
|
||||
}
|
||||
|
||||
@@ -188,7 +190,9 @@ public class CommentedConfiguration extends YamlConfiguration {
|
||||
CommentedConfiguration config = new CommentedConfiguration();
|
||||
|
||||
try {
|
||||
config.load(stream);
|
||||
InputStreamReader reader = new InputStreamReader(stream);
|
||||
config.load(reader);
|
||||
reader.close();
|
||||
} catch (IOException ex) {
|
||||
Bukkit.getLogger().log(Level.SEVERE, "Cannot load configuration from stream", ex);
|
||||
} catch (InvalidConfigurationException ex) {
|
||||
@@ -197,4 +201,17 @@ public class CommentedConfiguration extends YamlConfiguration {
|
||||
|
||||
return config;
|
||||
}
|
||||
|
||||
private static void convertMapsToSections(Map<?, ?> input, ConfigurationSection section) {
|
||||
for (Map.Entry<?, ?> entry : input.entrySet()) {
|
||||
String key = entry.getKey().toString();
|
||||
Object value = entry.getValue();
|
||||
|
||||
if (value instanceof Map) {
|
||||
convertMapsToSections((Map<?, ?>) value, section.createSection(key));
|
||||
} else {
|
||||
section.set(key, value);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
/*
|
||||
* AntiCheat for Bukkit.
|
||||
* Copyright (C) 2012-2014 AntiCheat Team | http://gravitydevelopment.net
|
||||
* AntiCheatReloaded for Bukkit and Spigot.
|
||||
* Copyright (c) 2012-2015 AntiCheat Team
|
||||
* Copyright (c) 2016-2022 Rammelkast
|
||||
*
|
||||
* 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
|
||||
@@ -15,95 +16,59 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.rammelkast.anticheatreloaded.event;
|
||||
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.block.BlockBreakEvent;
|
||||
import org.bukkit.event.block.BlockDamageEvent;
|
||||
import org.bukkit.event.block.BlockPlaceEvent;
|
||||
|
||||
import com.rammelkast.anticheatreloaded.AntiCheat;
|
||||
import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
|
||||
import com.rammelkast.anticheatreloaded.check.CheckResult;
|
||||
import com.rammelkast.anticheatreloaded.check.CheckType;
|
||||
import com.rammelkast.anticheatreloaded.util.Distance;
|
||||
import com.rammelkast.anticheatreloaded.util.Utilities;
|
||||
import com.rammelkast.anticheatreloaded.check.player.IllegalInteractCheck;
|
||||
|
||||
public class BlockListener extends EventListener {
|
||||
public final class BlockListener extends EventListener {
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void onBlockDamage(BlockDamageEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
if (event.getInstaBreak() || Utilities.isInstantBreak(event.getBlock().getType())) {
|
||||
getBackend().logInstantBreak(player);
|
||||
}
|
||||
if (getCheckManager().willCheck(player, CheckType.AUTOTOOL)) {
|
||||
CheckResult result = getBackend().checkAutoTool(player);
|
||||
@EventHandler(priority = EventPriority.LOWEST)
|
||||
public void onBlockPlace(final BlockPlaceEvent event) {
|
||||
final Player player = event.getPlayer();
|
||||
if (getCheckManager().willCheck(player, CheckType.FAST_PLACE)) {
|
||||
final CheckResult result = getBackend().checkFastPlace(player);
|
||||
if (result.failed()) {
|
||||
event.setCancelled(!silentMode());
|
||||
log(result.getMessage(), player, CheckType.AUTOTOOL);
|
||||
}
|
||||
log(result.getMessage(), player, CheckType.FAST_PLACE, result.getSubCheck());
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
AntiCheat.getManager().addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners());
|
||||
}
|
||||
|
||||
@EventHandler(ignoreCancelled = true)
|
||||
public void onBlockPlace(BlockPlaceEvent event) {
|
||||
final Player player = event.getPlayer();
|
||||
if (player != null && getCheckManager().willCheck(player, CheckType.FAST_PLACE)) {
|
||||
CheckResult result = getBackend().checkFastPlace(player);
|
||||
|
||||
if (getCheckManager().willCheck(player, CheckType.ILLEGAL_INTERACT)) {
|
||||
final CheckResult result = IllegalInteractCheck.runCheck(player, event);
|
||||
if (result.failed()) {
|
||||
event.setCancelled(!silentMode());
|
||||
log(result.getMessage(), player, CheckType.FAST_PLACE);
|
||||
} else {
|
||||
decrease(player);
|
||||
getBackend().logBlockPlace(player);
|
||||
}
|
||||
log(result.getMessage(), player, CheckType.ILLEGAL_INTERACT, result.getSubCheck());
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
AntiCheat.getManager().addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners());
|
||||
|
||||
decrease(player);
|
||||
getBackend().logBlockPlace(player);
|
||||
AntiCheatReloaded.getManager().addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners());
|
||||
}
|
||||
|
||||
@EventHandler(ignoreCancelled = true)
|
||||
public void onBlockBreak(BlockBreakEvent event) {
|
||||
@EventHandler(priority = EventPriority.LOWEST)
|
||||
public void onBlockBreak(final BlockBreakEvent event) {
|
||||
final Player player = event.getPlayer();
|
||||
final Block block = event.getBlock();
|
||||
boolean noHack = true;
|
||||
if (player != null) {
|
||||
CheckResult result;
|
||||
if (getCheckManager().willCheck(player, CheckType.FAST_BREAK)) {
|
||||
result = getBackend().checkFastBreak(player, block);
|
||||
if (result.failed()) {
|
||||
event.setCancelled(!silentMode());
|
||||
log(result.getMessage(), player, CheckType.FAST_BREAK);
|
||||
noHack = false;
|
||||
}
|
||||
}
|
||||
if (getCheckManager().willCheck(player, CheckType.NO_SWING)) {
|
||||
result = getBackend().checkSwing(player, block);
|
||||
if (result.failed()) {
|
||||
event.setCancelled(!silentMode());
|
||||
log(result.getMessage(), player, CheckType.NO_SWING);
|
||||
noHack = false;
|
||||
}
|
||||
}
|
||||
if (getCheckManager().willCheck(player, CheckType.LONG_REACH)) {
|
||||
Distance distance = new Distance(player.getLocation(), block.getLocation());
|
||||
result = getBackend().checkLongReachBlock(player, distance.getXDifference(), distance.getYDifference(), distance.getZDifference());
|
||||
if (result.failed()) {
|
||||
event.setCancelled(!silentMode());
|
||||
log(result.getMessage(), player, CheckType.LONG_REACH);
|
||||
noHack = false;
|
||||
}
|
||||
if (getCheckManager().willCheck(player, CheckType.ILLEGAL_INTERACT)) {
|
||||
final CheckResult result = IllegalInteractCheck.runCheck(player, event);
|
||||
if (result.failed()) {
|
||||
event.setCancelled(!silentMode());
|
||||
log(result.getMessage(), player, CheckType.ILLEGAL_INTERACT, result.getSubCheck());
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (noHack) {
|
||||
decrease(player);
|
||||
}
|
||||
getBackend().logBlockBreak(player);
|
||||
|
||||
decrease(player);
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
/*
|
||||
* AntiCheat for Bukkit.
|
||||
* Copyright (C) 2012-2014 AntiCheat Team | http://gravitydevelopment.net
|
||||
* AntiCheatReloaded for Bukkit and Spigot.
|
||||
* Copyright (c) 2012-2015 AntiCheat Team
|
||||
* Copyright (c) 2016-2022 Rammelkast
|
||||
*
|
||||
* 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
|
||||
@@ -18,157 +19,158 @@
|
||||
|
||||
package com.rammelkast.anticheatreloaded.event;
|
||||
|
||||
import org.bukkit.enchantments.Enchantment;
|
||||
import org.bukkit.entity.Creeper;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.entity.TNTPrimed;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||
import org.bukkit.event.entity.EntityDamageEvent;
|
||||
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
|
||||
import org.bukkit.event.entity.EntityRegainHealthEvent;
|
||||
import org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason;
|
||||
import org.bukkit.event.entity.EntityShootBowEvent;
|
||||
import org.bukkit.event.entity.FoodLevelChangeEvent;
|
||||
|
||||
import com.rammelkast.anticheatreloaded.AntiCheat;
|
||||
import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
|
||||
import com.rammelkast.anticheatreloaded.check.CheckResult;
|
||||
import com.rammelkast.anticheatreloaded.check.CheckType;
|
||||
import com.rammelkast.anticheatreloaded.check.combat.CriticalsCheck;
|
||||
import com.rammelkast.anticheatreloaded.check.combat.KillAuraCheck;
|
||||
import com.rammelkast.anticheatreloaded.check.combat.VelocityCheck;
|
||||
import com.rammelkast.anticheatreloaded.util.Distance;
|
||||
|
||||
import org.bukkit.event.entity.EntityShootBowEvent;
|
||||
import org.bukkit.event.entity.FoodLevelChangeEvent;
|
||||
import com.rammelkast.anticheatreloaded.check.movement.AimbotCheck;
|
||||
|
||||
public class EntityListener extends EventListener {
|
||||
|
||||
@EventHandler
|
||||
public void onEntityShootBow(EntityShootBowEvent event) {
|
||||
if (event.getEntity() instanceof Player) {
|
||||
Player player = (Player) event.getEntity();
|
||||
if (getCheckManager().willCheck(player, CheckType.FAST_BOW)) {
|
||||
CheckResult result = getBackend().checkFastBow(player, event.getForce());
|
||||
if (result.failed()) {
|
||||
event.setCancelled(!silentMode());
|
||||
log(result.getMessage(), player, CheckType.FAST_BOW);
|
||||
} else {
|
||||
decrease(player);
|
||||
}
|
||||
}
|
||||
}
|
||||
@EventHandler
|
||||
public void onEntityShootBow(EntityShootBowEvent event) {
|
||||
if (event.getEntity() instanceof Player) {
|
||||
Player player = (Player) event.getEntity();
|
||||
if (getCheckManager().willCheck(player, CheckType.FAST_BOW)) {
|
||||
CheckResult result = getBackend().checkFastBow(player, event.getForce());
|
||||
if (result.failed()) {
|
||||
event.setCancelled(!silentMode());
|
||||
log(result.getMessage(), player, CheckType.FAST_BOW, result.getSubCheck());
|
||||
} else {
|
||||
decrease(player);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
AntiCheat.getManager().addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners());
|
||||
}
|
||||
AntiCheatReloaded.getManager().addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners());
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onEntityRegainHealth(EntityRegainHealthEvent event) {
|
||||
if (event.getEntity() instanceof Player && event.getRegainReason() == RegainReason.SATIATED) {
|
||||
Player player = (Player) event.getEntity();
|
||||
if (getCheckManager().willCheck(player, CheckType.FAST_HEAL)) {
|
||||
CheckResult result = getBackend().checkFastHeal(player);
|
||||
if (result.failed()) {
|
||||
event.setCancelled(!silentMode());
|
||||
log(result.getMessage(), player, CheckType.FAST_HEAL);
|
||||
} else {
|
||||
decrease(player);
|
||||
getBackend().logHeal(player);
|
||||
}
|
||||
}
|
||||
}
|
||||
@EventHandler
|
||||
public void onEntityRegainHealth(EntityRegainHealthEvent event) {
|
||||
if (event.getEntity() instanceof Player && event.getRegainReason() == RegainReason.SATIATED) {
|
||||
Player player = (Player) event.getEntity();
|
||||
if (getCheckManager().willCheck(player, CheckType.FAST_HEAL)) {
|
||||
CheckResult result = getBackend().checkFastHeal(player);
|
||||
if (result.failed()) {
|
||||
event.setCancelled(!silentMode());
|
||||
log(result.getMessage(), player, CheckType.FAST_HEAL, result.getSubCheck());
|
||||
} else {
|
||||
decrease(player);
|
||||
getBackend().logHeal(player);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
AntiCheat.getManager().addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners());
|
||||
}
|
||||
AntiCheatReloaded.getManager().addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners());
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onFoodLevelChange(FoodLevelChangeEvent event) {
|
||||
if (event.getEntity() instanceof Player) {
|
||||
Player player = (Player) event.getEntity();
|
||||
if (player.getFoodLevel() < event.getFoodLevel() && getCheckManager().willCheck(player, CheckType.FAST_EAT)) // Make sure it's them actually gaining a food level
|
||||
{
|
||||
CheckResult result = getBackend().checkFastEat(player);
|
||||
if (result.failed()) {
|
||||
event.setCancelled(!silentMode());
|
||||
log(result.getMessage(), player, CheckType.FAST_EAT);
|
||||
} else {
|
||||
decrease(player);
|
||||
}
|
||||
}
|
||||
}
|
||||
@EventHandler
|
||||
public void onFoodLevelChange(FoodLevelChangeEvent event) {
|
||||
if (event.getEntity() instanceof Player) {
|
||||
Player player = (Player) event.getEntity();
|
||||
if (player.getFoodLevel() < event.getFoodLevel()
|
||||
&& getCheckManager().willCheck(player, CheckType.FAST_EAT)) {
|
||||
CheckResult result = getBackend().checkFastEat(player);
|
||||
if (result.failed()) {
|
||||
event.setCancelled(!silentMode());
|
||||
log(result.getMessage(), player, CheckType.FAST_EAT, result.getSubCheck());
|
||||
} else {
|
||||
decrease(player);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
AntiCheat.getManager().addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners());
|
||||
}
|
||||
AntiCheatReloaded.getManager().addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners());
|
||||
}
|
||||
|
||||
@EventHandler(priority=EventPriority.HIGHEST, ignoreCancelled = true)
|
||||
public void onEntityDamage(EntityDamageEvent event) {
|
||||
boolean noHack = true;
|
||||
if (event instanceof EntityDamageByEntityEvent) {
|
||||
EntityDamageByEntityEvent e = (EntityDamageByEntityEvent) event;
|
||||
if (e.getDamager() instanceof Player) {
|
||||
if (getCheckManager().willCheck((Player)e.getDamager(), CheckType.KILLAURA)) {
|
||||
KillAuraCheck.doDamageEvent(e, (Player)e.getDamager());
|
||||
}
|
||||
if (getCheckManager().willCheck((Player)e.getDamager(), CheckType.CRITICALS)) {
|
||||
CriticalsCheck.doDamageEvent(e, (Player)e.getDamager());
|
||||
}
|
||||
}
|
||||
if (event.getEntity() instanceof Player) {
|
||||
Player player = (Player) event.getEntity();
|
||||
VelocityCheck.runCheck(e, player);
|
||||
if (e.getDamager() instanceof Player) {
|
||||
Player p = (Player) e.getDamager();
|
||||
getBackend().logDamage(p, 1);
|
||||
int value = p.getInventory().getItemInHand().containsEnchantment(Enchantment.KNOCKBACK) ? 2 : 1;
|
||||
getBackend().logDamage(player, value);
|
||||
if (getCheckManager().willCheck(p, CheckType.LONG_REACH)) {
|
||||
Distance distance = new Distance(player.getLocation(), p.getLocation());
|
||||
CheckResult result = getBackend().checkLongReachDamage(player, distance.getXDifference(), distance.getYDifference(), distance.getZDifference());
|
||||
if (result.failed()) {
|
||||
event.setCancelled(!silentMode());
|
||||
log(result.getMessage(), p, CheckType.LONG_REACH);
|
||||
noHack = false;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (e.getDamager() instanceof TNTPrimed || e.getDamager() instanceof Creeper) {
|
||||
getBackend().logDamage(player, 3);
|
||||
} else {
|
||||
getBackend().logDamage(player, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (e.getDamager() instanceof Player) {
|
||||
Player player = (Player) e.getDamager();
|
||||
getBackend().logDamage(player, 1);
|
||||
if (getCheckManager().willCheck(player, CheckType.AUTOTOOL)) {
|
||||
CheckResult result = getBackend().checkAutoTool(player);
|
||||
if (result.failed()) {
|
||||
event.setCancelled(!silentMode());
|
||||
log(result.getMessage(), player, CheckType.AUTOTOOL);
|
||||
noHack = false;
|
||||
}
|
||||
}
|
||||
if (getCheckManager().willCheck(player, CheckType.FORCEFIELD)) {
|
||||
CheckResult result = getBackend().checkSprintDamage(player);
|
||||
if (result.failed()) {
|
||||
event.setCancelled(!silentMode());
|
||||
log(result.getMessage(), player, CheckType.FORCEFIELD);
|
||||
noHack = false;
|
||||
}
|
||||
}
|
||||
if (getCheckManager().willCheck(player, CheckType.FORCEFIELD)) {
|
||||
CheckResult result = getBackend().checkSight(player, e.getEntity());
|
||||
if (result.failed()) {
|
||||
event.setCancelled(!silentMode());
|
||||
log(result.getMessage(), player, CheckType.FORCEFIELD);
|
||||
noHack = false;
|
||||
}
|
||||
}
|
||||
if (noHack) {
|
||||
decrease(player);
|
||||
}
|
||||
}
|
||||
}
|
||||
@EventHandler(priority = EventPriority.LOWEST)
|
||||
public void onEntityDamage(final EntityDamageEvent event) {
|
||||
if (event instanceof EntityDamageByEntityEvent) {
|
||||
final EntityDamageByEntityEvent e = (EntityDamageByEntityEvent) event;
|
||||
if (e.getDamager() instanceof Player) {
|
||||
if (getCheckManager().willCheck((Player) e.getDamager(), CheckType.CRITICALS)) {
|
||||
CriticalsCheck.doDamageEvent(e, (Player) e.getDamager());
|
||||
}
|
||||
if (getCheckManager().willCheckQuick((Player) e.getDamager(), CheckType.AIMBOT)) {
|
||||
final CheckResult result = AimbotCheck.runCheck((Player) e.getDamager(), e);
|
||||
if (result.failed()) {
|
||||
log(result.getMessage(), (Player) e.getDamager(), CheckType.AIMBOT, result.getSubCheck());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
AntiCheat.getManager().addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners());
|
||||
}
|
||||
if (e.getDamager() instanceof Player && event.getCause() == DamageCause.ENTITY_ATTACK) {
|
||||
final Player player = (Player) e.getDamager();
|
||||
if (getCheckManager().willCheck(player, CheckType.KILLAURA)) {
|
||||
final CheckResult result = KillAuraCheck.checkAngle(player, event);
|
||||
if (result.failed()) {
|
||||
event.setCancelled(!silentMode());
|
||||
log(result.getMessage(), player, CheckType.KILLAURA, result.getSubCheck());
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (getCheckManager().willCheck(player, CheckType.KILLAURA)) {
|
||||
final CheckResult result = KillAuraCheck.checkReach(player, event.getEntity());
|
||||
if (result.failed()) {
|
||||
event.setCancelled(!silentMode());
|
||||
log(result.getMessage(), player, CheckType.KILLAURA, result.getSubCheck());
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (getCheckManager().willCheck(player, CheckType.KILLAURA)) {
|
||||
final CheckResult result = KillAuraCheck.checkPacketOrder(player, event.getEntity());
|
||||
if (result.failed()) {
|
||||
event.setCancelled(!silentMode());
|
||||
log(result.getMessage(), player, CheckType.KILLAURA, result.getSubCheck());
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (getCheckManager().willCheck(player, CheckType.KILLAURA)) {
|
||||
final CheckResult result = KillAuraCheck.checkRepeatedAim(player);
|
||||
if (result.failed()) {
|
||||
event.setCancelled(!silentMode());
|
||||
log(result.getMessage(), player, CheckType.KILLAURA, result.getSubCheck());
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (getCheckManager().willCheck(player, CheckType.KILLAURA)) {
|
||||
final CheckResult result = KillAuraCheck.checkVariance(player);
|
||||
if (result.failed()) {
|
||||
event.setCancelled(!silentMode());
|
||||
log(result.getMessage(), player, CheckType.KILLAURA, result.getSubCheck());
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (getCheckManager().willCheck(player, CheckType.KILLAURA)) {
|
||||
final CheckResult result = KillAuraCheck.checkThroughWalls(player, event.getEntity());
|
||||
if (result.failed()) {
|
||||
event.setCancelled(!silentMode());
|
||||
log(result.getMessage(), player, CheckType.KILLAURA, result.getSubCheck());
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
decrease(player);
|
||||
}
|
||||
}
|
||||
|
||||
AntiCheatReloaded.getManager().addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners());
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
/*
|
||||
* AntiCheat for Bukkit.
|
||||
* Copyright (C) 2012-2014 AntiCheat Team | http://gravitydevelopment.net
|
||||
* AntiCheatReloaded for Bukkit and Spigot.
|
||||
* Copyright (c) 2012-2015 AntiCheat Team
|
||||
* Copyright (c) 2016-2022 Rammelkast
|
||||
*
|
||||
* 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
|
||||
@@ -15,127 +16,175 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.rammelkast.anticheatreloaded.event;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Listener;
|
||||
|
||||
import com.rammelkast.anticheatreloaded.AntiCheat;
|
||||
import com.rammelkast.anticheatreloaded.check.Backend;
|
||||
import com.rammelkast.anticheatreloaded.check.CheckType;
|
||||
import com.rammelkast.anticheatreloaded.config.Configuration;
|
||||
import com.rammelkast.anticheatreloaded.manage.*;
|
||||
import com.rammelkast.anticheatreloaded.util.User;
|
||||
|
||||
import java.text.DecimalFormat;
|
||||
import java.text.DecimalFormatSymbols;
|
||||
import java.util.EnumMap;
|
||||
import java.util.HashMap;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Listener;
|
||||
|
||||
import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
|
||||
import com.rammelkast.anticheatreloaded.check.Backend;
|
||||
import com.rammelkast.anticheatreloaded.check.CheckType;
|
||||
import com.rammelkast.anticheatreloaded.config.Configuration;
|
||||
import com.rammelkast.anticheatreloaded.manage.AntiCheatManager;
|
||||
import com.rammelkast.anticheatreloaded.manage.CheckManager;
|
||||
import com.rammelkast.anticheatreloaded.manage.UserManager;
|
||||
import com.rammelkast.anticheatreloaded.util.User;
|
||||
|
||||
public class EventListener implements Listener {
|
||||
private static final Map<CheckType, Integer> USAGE_LIST = new EnumMap<CheckType, Integer>(CheckType.class);
|
||||
private static final Map<UUID, Integer> DECREASE_LIST = new HashMap<UUID, Integer>();
|
||||
private static final CheckManager CHECK_MANAGER = AntiCheat.getManager().getCheckManager();
|
||||
private static final Backend BACKEND = AntiCheat.getManager().getBackend();
|
||||
private static final AntiCheat PLUGIN = AntiCheat.getManager().getPlugin();
|
||||
private static final UserManager USER_MANAGER = AntiCheat.getManager().getUserManager();
|
||||
private static final Configuration CONFIG = AntiCheat.getManager().getConfiguration();
|
||||
private static final Map<CheckType, Integer> USAGE_LIST = new EnumMap<CheckType, Integer>(CheckType.class);
|
||||
private static final Map<UUID, Integer> DECREASE_LIST = new HashMap<UUID, Integer>();
|
||||
private static final CheckManager CHECK_MANAGER = AntiCheatReloaded.getManager().getCheckManager();
|
||||
private static final Backend BACKEND = AntiCheatReloaded.getManager().getBackend();
|
||||
private static final AntiCheatReloaded PLUGIN = AntiCheatReloaded.getManager().getPlugin();
|
||||
private static final UserManager USER_MANAGER = AntiCheatReloaded.getManager().getUserManager();
|
||||
private static final Configuration CONFIG = AntiCheatReloaded.getManager().getConfiguration();
|
||||
private static final DecimalFormat TPS_FORMAT = new DecimalFormat("##.##");
|
||||
|
||||
static {
|
||||
// What the hell, Java..
|
||||
TPS_FORMAT.setDecimalFormatSymbols(DecimalFormatSymbols.getInstance(Locale.ENGLISH));
|
||||
}
|
||||
|
||||
public static void log(String message, Player player, CheckType type, String subcheck) {
|
||||
User user = getUserManager().getUser(player.getUniqueId());
|
||||
if (user == null)
|
||||
return;
|
||||
|
||||
boolean debugMode = CONFIG.getConfig().debugMode.getValue();
|
||||
int vlForType = type.getUses(player.getUniqueId()) + 1;
|
||||
int notifyEveryVl = CONFIG.getConfig().notifyEveryVl.getValue();
|
||||
String prefix = ChatColor.translateAlternateColorCodes('&', CONFIG.getLang().ALERT_PREFIX());
|
||||
if (message == null || message.equals("")) {
|
||||
if (debugMode) {
|
||||
message = prefix + player.getName() + " failed "
|
||||
+ type.getName() + (subcheck != null ? (" (" + subcheck + ")") : "");
|
||||
} else {
|
||||
message = prefix + player.getName() + " failed "
|
||||
+ type.getName() + (subcheck != null ? (" (" + subcheck + ")") : "") + ChatColor.GOLD + " (x" + vlForType + ")";
|
||||
}
|
||||
} else {
|
||||
if (debugMode) {
|
||||
message = prefix + player.getName() + " failed "
|
||||
+ type.getName() + (subcheck != null ? (" (" + subcheck + ")") : "") + ChatColor.DARK_GRAY + " | " + ChatColor.GRAY + message
|
||||
+ ChatColor.DARK_GRAY + " | " + ChatColor.GRAY + "ping: " + user.getPing() + "ms"
|
||||
+ ", tps: " + TPS_FORMAT.format(AntiCheatReloaded.getPlugin().getTPS());
|
||||
} else {
|
||||
message = prefix
|
||||
+ player.getName() + " failed " + type.getName() + ChatColor.GOLD + " (x" + vlForType + ")"
|
||||
+ ChatColor.DARK_GRAY + " | " + ChatColor.GRAY
|
||||
+ (subcheck != null ? ("type: " + subcheck.toLowerCase() + ", ") : "") + "ping: " + user.getPing() + "ms"
|
||||
+ ", tps: " + TPS_FORMAT.format(AntiCheatReloaded.getPlugin().getTPS());
|
||||
}
|
||||
}
|
||||
|
||||
logCheat(type, user);
|
||||
if (user.increaseLevel(type) && (!debugMode && vlForType % notifyEveryVl == 0)) {
|
||||
AntiCheatReloaded.getManager().log(message);
|
||||
}
|
||||
removeDecrease(user);
|
||||
|
||||
public static void log(String message, Player player, CheckType type) {
|
||||
User user = getUserManager().getUser(player.getUniqueId());
|
||||
if (user != null) { // npc
|
||||
logCheat(type, user);
|
||||
if (user.increaseLevel(type) && message != null) {
|
||||
AntiCheat.getManager().log(message);
|
||||
}
|
||||
removeDecrease(user);
|
||||
}
|
||||
}
|
||||
if (debugMode) {
|
||||
player.sendMessage(message);
|
||||
return;
|
||||
}
|
||||
|
||||
if (vlForType % notifyEveryVl == 0) {
|
||||
AntiCheatReloaded.getPlugin().sendToStaff(message);
|
||||
}
|
||||
}
|
||||
|
||||
private static void logCheat(CheckType type, User user) {
|
||||
USAGE_LIST.put(type, getCheats(type) + 1);
|
||||
// Ignore plugins that are creating NPCs with no names (why the hell)
|
||||
if (user != null && user.getUUID() != null) {
|
||||
type.logUse(user);
|
||||
if (CONFIG.getConfig().enterprise.getValue() && CONFIG.getEnterprise().loggingEnabled.getValue()) {
|
||||
CONFIG.getEnterprise().database.logEvent(user, type);
|
||||
}
|
||||
}
|
||||
}
|
||||
private static void logCheat(CheckType type, User user) {
|
||||
USAGE_LIST.put(type, getCheats(type) + 1);
|
||||
// Ignore plugins that are creating NPCs with no names (why the hell)
|
||||
if (user != null && user.getUUID() != null) {
|
||||
type.logUse(user);
|
||||
if (CONFIG.getConfig().enterprise.getValue() && CONFIG.getEnterprise().loggingEnabled.getValue()) {
|
||||
CONFIG.getEnterprise().database.logEvent(user, type);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void resetCheck(CheckType type) {
|
||||
USAGE_LIST.put(type, 0);
|
||||
}
|
||||
public void resetCheck(CheckType type) {
|
||||
USAGE_LIST.put(type, 0);
|
||||
}
|
||||
|
||||
public static int getCheats(CheckType type) {
|
||||
int x = 0;
|
||||
if (USAGE_LIST.get(type) != null) {
|
||||
x = USAGE_LIST.get(type);
|
||||
}
|
||||
return x;
|
||||
}
|
||||
public static int getCheats(CheckType type) {
|
||||
int x = 0;
|
||||
if (USAGE_LIST.get(type) != null) {
|
||||
x = USAGE_LIST.get(type);
|
||||
}
|
||||
return x;
|
||||
}
|
||||
|
||||
private static void removeDecrease(User user) {
|
||||
int x = 0;
|
||||
// Ignore plugins that are creating NPCs with no names
|
||||
if (user.getUUID() != null) {
|
||||
if (DECREASE_LIST.get(user.getUUID()) != null) {
|
||||
x = DECREASE_LIST.get(user.getUUID());
|
||||
x -= 2;
|
||||
if (x < 0) {
|
||||
x = 0;
|
||||
}
|
||||
}
|
||||
DECREASE_LIST.put(user.getUUID(), x);
|
||||
}
|
||||
}
|
||||
private static void removeDecrease(User user) {
|
||||
int x = 0;
|
||||
// Ignore plugins that are creating NPCs with no names
|
||||
if (user.getUUID() != null) {
|
||||
if (DECREASE_LIST.get(user.getUUID()) != null) {
|
||||
x = DECREASE_LIST.get(user.getUUID());
|
||||
x -= 2;
|
||||
if (x < 0) {
|
||||
x = 0;
|
||||
}
|
||||
}
|
||||
DECREASE_LIST.put(user.getUUID(), x);
|
||||
}
|
||||
}
|
||||
|
||||
public static void decrease(Player player) {
|
||||
User user = getUserManager().getUser(player.getUniqueId());
|
||||
// Ignore plugins that are creating NPCs with no names
|
||||
if (user.getUUID() != null) {
|
||||
int x = 0;
|
||||
public static void decrease(Player player) {
|
||||
User user = getUserManager().getUser(player.getUniqueId());
|
||||
// Ignore plugins that are creating NPCs with no names
|
||||
if (user.getUUID() != null) {
|
||||
int x = 0;
|
||||
|
||||
if (DECREASE_LIST.get(user.getUUID()) != null) {
|
||||
x = DECREASE_LIST.get(user.getUUID());
|
||||
}
|
||||
if (DECREASE_LIST.get(user.getUUID()) != null) {
|
||||
x = DECREASE_LIST.get(user.getUUID());
|
||||
}
|
||||
|
||||
x += 1;
|
||||
DECREASE_LIST.put(user.getUUID(), x);
|
||||
x += 1;
|
||||
DECREASE_LIST.put(user.getUUID(), x);
|
||||
|
||||
if (x >= 10) {
|
||||
user.decreaseLevel();
|
||||
DECREASE_LIST.put(user.getUUID(), 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (x >= 10) {
|
||||
user.decreaseLevel();
|
||||
DECREASE_LIST.put(user.getUUID(), 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static CheckManager getCheckManager() {
|
||||
return CHECK_MANAGER;
|
||||
}
|
||||
public static CheckManager getCheckManager() {
|
||||
return CHECK_MANAGER;
|
||||
}
|
||||
|
||||
public static AntiCheatManager getManager() {
|
||||
return AntiCheat.getManager();
|
||||
}
|
||||
public static AntiCheatManager getManager() {
|
||||
return AntiCheatReloaded.getManager();
|
||||
}
|
||||
|
||||
public static Backend getBackend() {
|
||||
return BACKEND;
|
||||
}
|
||||
public static Backend getBackend() {
|
||||
return BACKEND;
|
||||
}
|
||||
|
||||
public static UserManager getUserManager() {
|
||||
return USER_MANAGER;
|
||||
}
|
||||
public static UserManager getUserManager() {
|
||||
return USER_MANAGER;
|
||||
}
|
||||
|
||||
public static AntiCheat getPlugin() {
|
||||
return PLUGIN;
|
||||
}
|
||||
public static AntiCheatReloaded getPlugin() {
|
||||
return PLUGIN;
|
||||
}
|
||||
|
||||
public static Configuration getConfig() {
|
||||
return CONFIG;
|
||||
}
|
||||
public static Configuration getConfig() {
|
||||
return CONFIG;
|
||||
}
|
||||
|
||||
public static boolean silentMode() {
|
||||
return CONFIG.getConfig().silentMode.getValue();
|
||||
}
|
||||
public static boolean silentMode() {
|
||||
return CONFIG.getConfig().silentMode.getValue();
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
/*
|
||||
* AntiCheat for Bukkit.
|
||||
* Copyright (C) 2012-2014 AntiCheat Team | http://gravitydevelopment.net
|
||||
* AntiCheatReloaded for Bukkit and Spigot.
|
||||
* Copyright (c) 2012-2015 AntiCheat Team
|
||||
* Copyright (c) 2016-2022 Rammelkast
|
||||
*
|
||||
* 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
|
||||
@@ -21,14 +22,10 @@ package com.rammelkast.anticheatreloaded.event;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||
import org.bukkit.event.inventory.InventoryCloseEvent;
|
||||
import org.bukkit.event.inventory.InventoryOpenEvent;
|
||||
import org.bukkit.event.inventory.InventoryType;
|
||||
|
||||
import com.rammelkast.anticheatreloaded.AntiCheat;
|
||||
import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
|
||||
import com.rammelkast.anticheatreloaded.check.CheckResult;
|
||||
import com.rammelkast.anticheatreloaded.check.CheckType;
|
||||
import com.rammelkast.anticheatreloaded.util.User;
|
||||
|
||||
public class InventoryListener extends EventListener {
|
||||
|
||||
@@ -40,32 +37,16 @@ public class InventoryListener extends EventListener {
|
||||
CheckResult result = getBackend().checkInventoryClicks(player);
|
||||
if (result.failed()) {
|
||||
if (!silentMode()) {
|
||||
//getUserManager().getUser(player.getName()).restoreInventory(event.getInventory());
|
||||
player.getInventory().clear();
|
||||
event.setCancelled(true);
|
||||
}
|
||||
log(result.getMessage(), player, CheckType.FAST_INVENTORY);
|
||||
log(result.getMessage(), player, CheckType.FAST_INVENTORY, result.getSubCheck());
|
||||
} else {
|
||||
decrease(player);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
AntiCheat.getManager().addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners());
|
||||
AntiCheatReloaded.getManager().addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners());
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onInventoryOpen(InventoryOpenEvent event) {
|
||||
if (event.getInventory().getType() != InventoryType.BEACON) {
|
||||
getUserManager().getUser(event.getPlayer().getUniqueId()).setInventorySnapshot(event.getInventory().getContents());
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onInventoryClose(InventoryCloseEvent event) {
|
||||
User user = getUserManager().getUser(event.getPlayer().getUniqueId());
|
||||
if (user != null) {
|
||||
user.removeInventorySnapshot();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,93 @@
|
||||
/*
|
||||
* AntiCheatReloaded for Bukkit and Spigot.
|
||||
* Copyright (c) 2012-2015 AntiCheat Team
|
||||
* Copyright (c) 2016-2022 Rammelkast
|
||||
*
|
||||
* 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 3 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, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.rammelkast.anticheatreloaded.event;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
import com.comphenix.protocol.PacketType;
|
||||
import com.comphenix.protocol.events.ListenerPriority;
|
||||
import com.comphenix.protocol.events.PacketAdapter;
|
||||
import com.comphenix.protocol.events.PacketContainer;
|
||||
import com.comphenix.protocol.events.PacketEvent;
|
||||
import com.comphenix.protocol.injector.server.TemporaryPlayer;
|
||||
import com.comphenix.protocol.wrappers.EnumWrappers.PlayerDigType;
|
||||
import com.rammelkast.anticheatreloaded.check.movement.NoSlowCheck;
|
||||
import com.rammelkast.anticheatreloaded.check.packet.BadPacketsCheck;
|
||||
import com.rammelkast.anticheatreloaded.check.packet.MorePacketsCheck;
|
||||
|
||||
public final class PacketListener extends PacketAdapter {
|
||||
|
||||
public PacketListener(final Plugin plugin) {
|
||||
super(plugin, ListenerPriority.LOWEST, PacketType.Play.Client.POSITION, PacketType.Play.Client.POSITION_LOOK,
|
||||
PacketType.Play.Client.LOOK, PacketType.Play.Server.POSITION, PacketType.Play.Client.BLOCK_DIG);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPacketReceiving(final PacketEvent event) {
|
||||
final Player player = event.getPlayer();
|
||||
if (player == null || !player.isOnline()) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Check if we have an actual player object
|
||||
if (player instanceof TemporaryPlayer) {
|
||||
return;
|
||||
}
|
||||
|
||||
final PacketType type = event.getPacketType();
|
||||
final PacketContainer packet = event.getPacket();
|
||||
if (type == PacketType.Play.Client.POSITION || type == PacketType.Play.Client.POSITION_LOOK) {
|
||||
// Run MorePackets check
|
||||
MorePacketsCheck.runCheck(player, event);
|
||||
// Run BadPackets check
|
||||
BadPacketsCheck.runCheck(player, event);
|
||||
return;
|
||||
}
|
||||
|
||||
if (event.getPacketType() == PacketType.Play.Client.BLOCK_DIG) {
|
||||
if (packet.getPlayerDigTypes().read(0) == PlayerDigType.RELEASE_USE_ITEM) {
|
||||
// Run NoSlow check
|
||||
NoSlowCheck.runCheck(event.getPlayer(), event);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPacketSending(final PacketEvent event) {
|
||||
final Player player = event.getPlayer();
|
||||
if (player == null || !player.isOnline()) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Check if we have an actual player object
|
||||
if (player instanceof TemporaryPlayer) {
|
||||
return;
|
||||
}
|
||||
|
||||
final PacketType type = event.getPacketType();
|
||||
if (type == PacketType.Play.Server.POSITION) {
|
||||
// Compensate for teleport
|
||||
MorePacketsCheck.compensate(player);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
/*
|
||||
* AntiCheat for Bukkit.
|
||||
* Copyright (C) 2012-2014 AntiCheat Team | http://gravitydevelopment.net
|
||||
* AntiCheatReloaded for Bukkit and Spigot.
|
||||
* Copyright (c) 2012-2015 AntiCheat Team
|
||||
* Copyright (c) 2016-2022 Rammelkast
|
||||
*
|
||||
* 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
|
||||
@@ -18,20 +19,23 @@
|
||||
|
||||
package com.rammelkast.anticheatreloaded.event;
|
||||
|
||||
import java.util.concurrent.Callable;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.Arrow;
|
||||
import org.bukkit.entity.Boat;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.block.Action;
|
||||
import org.bukkit.event.entity.PlayerDeathEvent;
|
||||
import org.bukkit.event.entity.ProjectileLaunchEvent;
|
||||
import org.bukkit.event.player.AsyncPlayerChatEvent;
|
||||
import org.bukkit.event.player.PlayerAnimationEvent;
|
||||
import org.bukkit.event.player.PlayerBedEnterEvent;
|
||||
import org.bukkit.event.player.PlayerBedLeaveEvent;
|
||||
import org.bukkit.event.player.PlayerChangedWorldEvent;
|
||||
@@ -43,434 +47,524 @@ import org.bukkit.event.player.PlayerJoinEvent;
|
||||
import org.bukkit.event.player.PlayerKickEvent;
|
||||
import org.bukkit.event.player.PlayerMoveEvent;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
import org.bukkit.event.player.PlayerRespawnEvent;
|
||||
import org.bukkit.event.player.PlayerTeleportEvent;
|
||||
import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause;
|
||||
import org.bukkit.event.player.PlayerToggleFlightEvent;
|
||||
import org.bukkit.event.player.PlayerToggleSneakEvent;
|
||||
import org.bukkit.event.player.PlayerToggleSprintEvent;
|
||||
import org.bukkit.event.player.PlayerVelocityEvent;
|
||||
import org.bukkit.event.vehicle.VehicleEntityCollisionEvent;
|
||||
import org.bukkit.inventory.EquipmentSlot;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.PlayerInventory;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import com.rammelkast.anticheatreloaded.AntiCheat;
|
||||
import com.cryptomorin.xseries.XMaterial;
|
||||
import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
|
||||
import com.rammelkast.anticheatreloaded.check.CheckResult;
|
||||
import com.rammelkast.anticheatreloaded.check.CheckType;
|
||||
import com.rammelkast.anticheatreloaded.check.combat.KillAuraCheck;
|
||||
import com.rammelkast.anticheatreloaded.check.movement.ElytraFly;
|
||||
import com.rammelkast.anticheatreloaded.check.combat.VelocityCheck;
|
||||
import com.rammelkast.anticheatreloaded.check.movement.BoatFlyCheck;
|
||||
import com.rammelkast.anticheatreloaded.check.movement.ElytraCheck;
|
||||
import com.rammelkast.anticheatreloaded.check.movement.FastLadderCheck;
|
||||
import com.rammelkast.anticheatreloaded.check.movement.FlightCheck;
|
||||
import com.rammelkast.anticheatreloaded.check.movement.GlideCheck;
|
||||
import com.rammelkast.anticheatreloaded.check.movement.SpeedCheck;
|
||||
import com.rammelkast.anticheatreloaded.check.movement.StrafeCheck;
|
||||
import com.rammelkast.anticheatreloaded.check.movement.WaterWalkCheck;
|
||||
import com.rammelkast.anticheatreloaded.check.movement.YAxisCheck;
|
||||
import com.rammelkast.anticheatreloaded.check.player.IllegalInteractCheck;
|
||||
import com.rammelkast.anticheatreloaded.check.player.NoFallCheck;
|
||||
import com.rammelkast.anticheatreloaded.manage.AntiCheatManager;
|
||||
import com.rammelkast.anticheatreloaded.util.Distance;
|
||||
import com.rammelkast.anticheatreloaded.util.Permission;
|
||||
import com.rammelkast.anticheatreloaded.util.User;
|
||||
import com.rammelkast.anticheatreloaded.util.Utilities;
|
||||
import com.rammelkast.anticheatreloaded.util.VersionUtil;
|
||||
import com.rammelkast.anticheatreloaded.util.VersionLib;
|
||||
|
||||
public class PlayerListener extends EventListener {
|
||||
public final class PlayerListener extends EventListener {
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||
public void onPlayerCommandPreprocess(PlayerCommandPreprocessEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
if (getCheckManager().willCheck(player, CheckType.COMMAND_SPAM) && !Permission.getCommandExempt(player, event.getMessage().split(" ")[0])) {
|
||||
CheckResult result = getBackend().checkCommandSpam(player, event.getMessage());
|
||||
if (result.failed()) {
|
||||
event.setCancelled(!silentMode());
|
||||
if (!silentMode()) player.sendMessage(ChatColor.RED + result.getMessage());
|
||||
getBackend().processCommandSpammer(player);
|
||||
log(null, player, CheckType.COMMAND_SPAM);
|
||||
}
|
||||
}
|
||||
private static final AntiCheatManager MANAGER = AntiCheatReloaded.getManager();
|
||||
|
||||
AntiCheat.getManager().addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners());
|
||||
}
|
||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||
public void onPlayerCommandPreprocess(PlayerCommandPreprocessEvent event) {
|
||||
final Player player = event.getPlayer();
|
||||
if (getCheckManager().willCheck(player, CheckType.COMMAND_SPAM)
|
||||
&& !Permission.getCommandExempt(player, event.getMessage().split(" ")[0])) {
|
||||
final CheckResult result = getBackend().checkCommandSpam(player, event.getMessage());
|
||||
if (result.failed()) {
|
||||
event.setCancelled(!silentMode());
|
||||
if (!silentMode())
|
||||
player.sendMessage(ChatColor.translateAlternateColorCodes('&', result.getMessage()));
|
||||
getBackend().processCommandSpammer(player);
|
||||
log(null, player, CheckType.COMMAND_SPAM, result.getSubCheck());
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerToggleFlight(PlayerToggleFlightEvent event) {
|
||||
if (!event.isFlying()) {
|
||||
getBackend().logEnterExit(event.getPlayer());
|
||||
}
|
||||
MANAGER.addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners());
|
||||
}
|
||||
|
||||
AntiCheat.getManager().addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners());
|
||||
}
|
||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||
public void onPlayerToggleFlight(final PlayerToggleFlightEvent event) {
|
||||
if (!event.isFlying()) {
|
||||
getBackend().logEnterExit(event.getPlayer());
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerGameModeChange(PlayerGameModeChangeEvent event) {
|
||||
if (event.getNewGameMode() != GameMode.CREATIVE) {
|
||||
getBackend().logEnterExit(event.getPlayer());
|
||||
}
|
||||
MANAGER.addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners());
|
||||
}
|
||||
|
||||
AntiCheat.getManager().addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners());
|
||||
}
|
||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||
public void onPlayerGameModeChange(final PlayerGameModeChangeEvent event) {
|
||||
if (event.getNewGameMode() != GameMode.CREATIVE) {
|
||||
getBackend().logEnterExit(event.getPlayer());
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onProjectileLaunch(ProjectileLaunchEvent event) {
|
||||
if (event.getEntity().getShooter() instanceof Player) {
|
||||
Player player = (Player) event.getEntity().getShooter();
|
||||
MANAGER.addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners());
|
||||
}
|
||||
|
||||
if (event.getEntity() instanceof Arrow) {
|
||||
return;
|
||||
}
|
||||
@EventHandler(priority = EventPriority.HIGHEST)
|
||||
public void onProjectileLaunch(final ProjectileLaunchEvent event) {
|
||||
if (event.getEntity().getShooter() instanceof Player) {
|
||||
final Player player = (Player) event.getEntity().getShooter();
|
||||
|
||||
if (getCheckManager().willCheck(player, CheckType.FAST_PROJECTILE)) {
|
||||
CheckResult result = getBackend().checkProjectile(player);
|
||||
if (result.failed()) {
|
||||
event.setCancelled(!silentMode());
|
||||
log(result.getMessage(), player, CheckType.FAST_PROJECTILE);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (event.getEntity() instanceof Arrow) {
|
||||
return;
|
||||
}
|
||||
|
||||
AntiCheat.getManager().addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners());
|
||||
}
|
||||
if (getCheckManager().willCheck(player, CheckType.FAST_PROJECTILE)) {
|
||||
final CheckResult result = getBackend().checkProjectile(player);
|
||||
if (result.failed()) {
|
||||
event.setCancelled(!silentMode());
|
||||
log(result.getMessage(), player, CheckType.FAST_PROJECTILE, result.getSubCheck());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerTeleport(PlayerTeleportEvent event) {
|
||||
if (event.getCause() == TeleportCause.ENDER_PEARL || event.getCause() == TeleportCause.PLUGIN) {
|
||||
getBackend().logTeleport(event.getPlayer());
|
||||
}
|
||||
MANAGER.addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners());
|
||||
}
|
||||
|
||||
AntiCheat.getManager().addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners());
|
||||
}
|
||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||
public void onPlayerTeleport(final PlayerTeleportEvent event) {
|
||||
getBackend().logTeleport(event.getPlayer());
|
||||
MANAGER.addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners());
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerChangeWorlds(PlayerChangedWorldEvent event) {
|
||||
getBackend().logTeleport(event.getPlayer());
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void onPlayerChangeWorlds(final PlayerChangedWorldEvent event) {
|
||||
getBackend().logTeleport(event.getPlayer());
|
||||
|
||||
AntiCheat.getManager().addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners());
|
||||
}
|
||||
MANAGER.addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners());
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerToggleSneak(PlayerToggleSneakEvent event) {
|
||||
if (event.isSneaking()) {
|
||||
getBackend().logToggleSneak(event.getPlayer());
|
||||
}
|
||||
@EventHandler(priority = EventPriority.HIGHEST)
|
||||
public void onPlayerToggleSneak(final PlayerToggleSneakEvent event) {
|
||||
final Player player = event.getPlayer();
|
||||
if (event.isSneaking()) {
|
||||
if (getCheckManager().willCheck(player, CheckType.SNEAK)) {
|
||||
final CheckResult result = getBackend().checkSneakToggle(player);
|
||||
if (result.failed()) {
|
||||
event.setCancelled(!silentMode());
|
||||
log(result.getMessage(), player, CheckType.SNEAK, result.getSubCheck());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
AntiCheat.getManager().addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners());
|
||||
}
|
||||
MANAGER.addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners());
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerVelocity(PlayerVelocityEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
if (getCheckManager().willCheck(player, CheckType.FLY)) {
|
||||
if (getBackend().justVelocity(player) && getBackend().extendVelocityTime(player)) {
|
||||
event.setCancelled(!silentMode());
|
||||
return;
|
||||
}
|
||||
getBackend().logVelocity(player);
|
||||
}
|
||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||
public void onPlayerVelocity(final PlayerVelocityEvent event) {
|
||||
final Player player = event.getPlayer();
|
||||
final Vector velocity = event.getVelocity();
|
||||
final User user = MANAGER.getUserManager().getUser(player.getUniqueId());
|
||||
final boolean debugMode = MANAGER.getConfiguration().getConfig().debugMode.getValue();
|
||||
user.getVelocityTracker().registerVelocity(velocity);
|
||||
if (debugMode) {
|
||||
player.sendMessage(AntiCheatReloaded.PREFIX + "Registered velocity [" + velocity.toString() + "]");
|
||||
}
|
||||
|
||||
AntiCheat.getManager().addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners());
|
||||
}
|
||||
// Part of Velocity check
|
||||
if (!user.getMovementManager().onGround) {
|
||||
return;
|
||||
}
|
||||
|
||||
@EventHandler(ignoreCancelled = true)
|
||||
public void onPlayerChat(AsyncPlayerChatEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
final double motionY = velocity.getY();
|
||||
user.getMovementManager().velocityExpectedMotionY = motionY;
|
||||
// End part of Velocity check
|
||||
|
||||
if (getCheckManager().willCheck(player, CheckType.CHAT_SPAM)) {
|
||||
CheckResult result = getBackend().checkChatSpam(player, event.getMessage());
|
||||
if (result.failed()) {
|
||||
event.setCancelled(!silentMode());
|
||||
if (!result.getMessage().equals("") && !silentMode()) {
|
||||
player.sendMessage(ChatColor.RED + result.getMessage());
|
||||
}
|
||||
getBackend().processChatSpammer(player);
|
||||
log(null, player, CheckType.CHAT_SPAM);
|
||||
}
|
||||
}
|
||||
MANAGER.addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners());
|
||||
}
|
||||
|
||||
AntiCheat.getManager().addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners());
|
||||
}
|
||||
@EventHandler(priority = EventPriority.HIGHEST)
|
||||
public void onPlayerChat(final AsyncPlayerChatEvent event) {
|
||||
final Player player = event.getPlayer();
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerKick(PlayerKickEvent event) {
|
||||
getBackend().garbageClean(event.getPlayer());
|
||||
if (getCheckManager().willCheck(player, CheckType.CHAT_SPAM)) {
|
||||
final CheckResult result = getBackend().checkChatSpam(player, event.getMessage());
|
||||
if (result.failed()) {
|
||||
event.setCancelled(!silentMode());
|
||||
if (!result.getMessage().equals("") && !silentMode()) {
|
||||
player.sendMessage(ChatColor.translateAlternateColorCodes('&', result.getMessage()));
|
||||
}
|
||||
getBackend().processChatSpammer(player);
|
||||
AntiCheatReloaded.sendToMainThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
log(null, player, CheckType.CHAT_SPAM, result.getSubCheck());
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
AntiCheat.getManager().addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners());
|
||||
}
|
||||
if (getCheckManager().willCheck(player, CheckType.CHAT_UNICODE)) {
|
||||
final CheckResult result = getBackend().checkChatUnicode(player, event.getMessage());
|
||||
if (result.failed()) {
|
||||
event.setCancelled(true);
|
||||
player.sendMessage(ChatColor.translateAlternateColorCodes('&', result.getMessage()));
|
||||
AntiCheatReloaded.sendToMainThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
log(null, player, CheckType.CHAT_UNICODE, result.getSubCheck());
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerQuit(PlayerQuitEvent event) {
|
||||
getBackend().garbageClean(event.getPlayer());
|
||||
MANAGER.addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners());
|
||||
}
|
||||
|
||||
User user = getUserManager().getUser(event.getPlayer().getUniqueId());
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void onPlayerKick(PlayerKickEvent event) {
|
||||
getBackend().cleanup(event.getPlayer());
|
||||
|
||||
getConfig().getLevels().saveLevelFromUser(user);
|
||||
MANAGER.addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners());
|
||||
}
|
||||
|
||||
AntiCheat.getManager().addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners());
|
||||
}
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void onPlayerQuit(final PlayerQuitEvent event) {
|
||||
final Player player = event.getPlayer();
|
||||
try {
|
||||
final User user = AntiCheatReloaded.getExecutor().submit(new Callable<User>() {
|
||||
@Override
|
||||
public User call() throws Exception {
|
||||
getBackend().cleanup(player);
|
||||
final User user = getUserManager().getUser(player.getUniqueId());
|
||||
getConfig().getLevels().saveLevelFromUser(user);
|
||||
return user;
|
||||
}
|
||||
}).get();
|
||||
getUserManager().removeUser(user);
|
||||
} catch (final InterruptedException | ExecutionException exception) {
|
||||
AntiCheatReloaded.getPlugin().getLogger().log(Level.SEVERE, "Failed to destroy user object async",
|
||||
exception);
|
||||
return;
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerToggleSprint(PlayerToggleSprintEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
if (!event.isSprinting()) {
|
||||
getBackend().logEnterExit(player);
|
||||
}
|
||||
if (getCheckManager().willCheck(player, CheckType.SPRINT)) {
|
||||
CheckResult result = getBackend().checkSprintHungry(event);
|
||||
if (result.failed()) {
|
||||
event.setCancelled(!silentMode());
|
||||
log(result.getMessage(), player, CheckType.SPRINT);
|
||||
} else {
|
||||
decrease(player);
|
||||
}
|
||||
}
|
||||
MANAGER.addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners());
|
||||
}
|
||||
|
||||
AntiCheat.getManager().addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners());
|
||||
}
|
||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||
public void onPlayerVehicleCollide(final VehicleEntityCollisionEvent event) {
|
||||
if (!(event.getVehicle() instanceof Boat) || !(event.getEntity() instanceof Player)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerInteract(PlayerInteractEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
PlayerInventory inv = player.getInventory();
|
||||
if (event.getAction() == Action.RIGHT_CLICK_AIR || event.getAction() == Action.RIGHT_CLICK_BLOCK) {
|
||||
Material m = inv.getItemInHand().getType();
|
||||
if (m == Material.BOW) {
|
||||
getBackend().logBowWindUp(player);
|
||||
} else if (Utilities.isFood(m)) {
|
||||
getBackend().logEatingStart(player);
|
||||
}
|
||||
}
|
||||
Block block = event.getClickedBlock();
|
||||
final Player player = (Player) event.getEntity();
|
||||
getBackend().logBoatCollision(player);
|
||||
}
|
||||
|
||||
if (block != null) {
|
||||
Distance distance = new Distance(player.getLocation(), block.getLocation());
|
||||
getBackend().checkLongReachBlock(player, distance.getXDifference(), distance.getYDifference(), distance.getZDifference());
|
||||
}
|
||||
@EventHandler(priority = EventPriority.HIGHEST)
|
||||
public void onPlayerToggleSprint(PlayerToggleSprintEvent event) {
|
||||
final Player player = event.getPlayer();
|
||||
if (getCheckManager().willCheck(player, CheckType.SPRINT)) {
|
||||
final CheckResult result = getBackend().checkSprintHungry(event);
|
||||
if (result.failed()) {
|
||||
event.setCancelled(!silentMode());
|
||||
log(result.getMessage(), player, CheckType.SPRINT, result.getSubCheck());
|
||||
} else {
|
||||
decrease(player);
|
||||
}
|
||||
}
|
||||
|
||||
AntiCheat.getManager().addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners());
|
||||
}
|
||||
MANAGER.addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners());
|
||||
}
|
||||
|
||||
@EventHandler(ignoreCancelled = true)
|
||||
public void onPlayerDropItem(PlayerDropItemEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
if (getCheckManager().willCheck(player, CheckType.ITEM_SPAM)) {
|
||||
CheckResult result = getBackend().checkFastDrop(player);
|
||||
if (result.failed()) {
|
||||
event.setCancelled(!silentMode());
|
||||
log(result.getMessage(), player, CheckType.ITEM_SPAM);
|
||||
}
|
||||
}
|
||||
@EventHandler(priority = EventPriority.HIGHEST)
|
||||
public void onPlayerInteract(final PlayerInteractEvent event) {
|
||||
final Player player = event.getPlayer();
|
||||
final PlayerInventory inv = player.getInventory();
|
||||
if (event.getAction() == Action.RIGHT_CLICK_AIR || event.getAction() == Action.RIGHT_CLICK_BLOCK) {
|
||||
final ItemStack itemInHand = ((event.getHand() == EquipmentSlot.HAND) ? inv.getItemInMainHand()
|
||||
: inv.getItemInOffHand());
|
||||
|
||||
AntiCheat.getManager().addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners());
|
||||
}
|
||||
if (itemInHand.getType() == Material.BOW) {
|
||||
getBackend().logBowWindUp(player);
|
||||
} else if (Utilities.isFood(itemInHand.getType()) || Utilities.isFood(itemInHand.getType())) {
|
||||
getBackend().logEatingStart(player);
|
||||
}
|
||||
|
||||
@EventHandler(ignoreCancelled = true)
|
||||
public void onPlayerEnterBed(PlayerBedEnterEvent event) {
|
||||
if (event.getBed().getType() != Material.BED) return;
|
||||
getBackend().logEnterExit(event.getPlayer());
|
||||
if (itemInHand.getType() == XMaterial.FIREWORK_ROCKET.parseMaterial()) {
|
||||
ElytraCheck.JUMP_Y_VALUE.remove(player.getUniqueId());
|
||||
if (player.isGliding()) {
|
||||
ElytraCheck.JUMP_Y_VALUE.put(player.getUniqueId(), 9999.99D);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
AntiCheat.getManager().addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners());
|
||||
}
|
||||
final Block block = event.getClickedBlock();
|
||||
if (block != null
|
||||
&& (event.getAction() == Action.RIGHT_CLICK_BLOCK || event.getAction() == Action.LEFT_CLICK_BLOCK)) {
|
||||
if (getCheckManager().willCheck(player, CheckType.ILLEGAL_INTERACT)) {
|
||||
final CheckResult result = IllegalInteractCheck.runCheck(player, event);
|
||||
if (result.failed()) {
|
||||
event.setCancelled(!silentMode());
|
||||
log(result.getMessage(), player, CheckType.ILLEGAL_INTERACT, result.getSubCheck());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(ignoreCancelled = true)
|
||||
public void onPlayerExitBed(PlayerBedLeaveEvent event) {
|
||||
if (event.getBed().getType() != Material.BED) return;
|
||||
getBackend().logEnterExit(event.getPlayer());
|
||||
MANAGER.addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners());
|
||||
}
|
||||
|
||||
AntiCheat.getManager().addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners());
|
||||
}
|
||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||
public void onPlayerDropItem(PlayerDropItemEvent event) {
|
||||
final Player player = event.getPlayer();
|
||||
if (getCheckManager().willCheck(player, CheckType.ITEM_SPAM)) {
|
||||
CheckResult result = getBackend().checkFastDrop(player);
|
||||
if (result.failed()) {
|
||||
event.setCancelled(!silentMode());
|
||||
log(result.getMessage(), player, CheckType.ITEM_SPAM, result.getSubCheck());
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerAnimation(PlayerAnimationEvent event) {
|
||||
AntiCheat.getManager().addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners());
|
||||
}
|
||||
MANAGER.addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners());
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerJoin(PlayerJoinEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
String section = "\u00a7";
|
||||
if (getCheckManager().willCheck(player, CheckType.ZOMBE_FLY)) {
|
||||
player.sendMessage(section + "f " + section + "f " + section + "1 " + section + "0 " + section + "2 " + section + "4");
|
||||
}
|
||||
if (getCheckManager().willCheck(player, CheckType.ZOMBE_CHEAT)) {
|
||||
player.sendMessage(section + "f " + section + "f " + section + "2 " + section + "0 " + section + "4 " + section + "8");
|
||||
}
|
||||
if (getCheckManager().willCheck(player, CheckType.ZOMBE_NOCLIP)) {
|
||||
player.sendMessage(section + "f " + section + "f " + section + "4 " + section + "0 " + section + "9 " + section + "6");
|
||||
}
|
||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||
public void onPlayerEnterBed(PlayerBedEnterEvent event) {
|
||||
if (event.getBed().getType().name().endsWith("BED")) {
|
||||
return;
|
||||
}
|
||||
getBackend().logEnterExit(event.getPlayer());
|
||||
|
||||
getBackend().logJoin(player);
|
||||
MANAGER.addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners());
|
||||
}
|
||||
|
||||
User user = new User(player.getUniqueId());
|
||||
user.setIsWaitingOnLevelSync(true);
|
||||
getConfig().getLevels().loadLevelToUser(user);
|
||||
getUserManager().addUser(user);
|
||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||
public void onPlayerExitBed(PlayerBedLeaveEvent event) {
|
||||
if (event.getBed().getType().name().endsWith("BED")) {
|
||||
return;
|
||||
}
|
||||
getBackend().logEnterExit(event.getPlayer());
|
||||
|
||||
if (player.hasMetadata(Utilities.SPY_METADATA)) {
|
||||
for (Player p : player.getServer().getOnlinePlayers()) {
|
||||
if (!Permission.SYSTEM_SPY.get(p)) {
|
||||
p.hidePlayer(player);
|
||||
}
|
||||
}
|
||||
}
|
||||
MANAGER.addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners());
|
||||
}
|
||||
|
||||
AntiCheat.getManager().addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners());
|
||||
}
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void onPlayerJoin(final PlayerJoinEvent event) {
|
||||
final Player player = event.getPlayer();
|
||||
getBackend().logJoin(player);
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
|
||||
public void onPlayerMove(PlayerMoveEvent event) {
|
||||
final Player player = event.getPlayer();
|
||||
if (getCheckManager().checkInWorld(player) && !getCheckManager().isOpExempt(player)) {
|
||||
final Location from = event.getFrom();
|
||||
final Location to = event.getTo();
|
||||
try {
|
||||
final User user = AntiCheatReloaded.getExecutor().submit(new Callable<User>() {
|
||||
@Override
|
||||
public User call() throws Exception {
|
||||
final User user = new User(player.getUniqueId());
|
||||
user.setIsWaitingOnLevelSync(true);
|
||||
getConfig().getLevels().loadLevelToUser(user);
|
||||
return user;
|
||||
}
|
||||
}).get();
|
||||
getUserManager().addUser(user);
|
||||
} catch (final InterruptedException | ExecutionException exception) {
|
||||
AntiCheatReloaded.getPlugin().getLogger().log(Level.SEVERE, "Failed to create user object async",
|
||||
exception);
|
||||
return;
|
||||
}
|
||||
|
||||
final Distance distance = new Distance(from, to);
|
||||
final double y = distance.getYDifference();
|
||||
getBackend().logAscension(player, from.getY(), to.getY());
|
||||
MANAGER.addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners());
|
||||
|
||||
final User user = getUserManager().getUser(player.getUniqueId());
|
||||
user.setTo(to.getX(), to.getY(), to.getZ());
|
||||
|
||||
KillAuraCheck.doMove(event);
|
||||
|
||||
if (getCheckManager().willCheckQuick(player, CheckType.SPRINT)) {
|
||||
CheckResult result = getBackend().checkSprintStill(player, from, to);
|
||||
if (result.failed()) {
|
||||
event.setCancelled(!silentMode());
|
||||
log(result.getMessage(), player, CheckType.SPRINT);
|
||||
}
|
||||
}
|
||||
if (getCheckManager().willCheckQuick(player, CheckType.FLY) && !VersionUtil.isFlying(player)) {
|
||||
CheckResult result = FlightCheck.runCheck(player, distance);
|
||||
if (result.failed()) {
|
||||
if (!silentMode()) {
|
||||
event.setTo(user.getGoodLocation(from.clone()));
|
||||
}
|
||||
log(result.getMessage(), player, CheckType.FLY);
|
||||
}
|
||||
}
|
||||
if (getCheckManager().willCheckQuick(player, CheckType.FLY) && !VersionUtil.isFlying(player)) {
|
||||
CheckResult result = GlideCheck.runCheck(player, distance);
|
||||
if (result.failed()) {
|
||||
// NO TELEPORT NEEDED HERE, HANDLED BY CHECK ITSELF
|
||||
log(result.getMessage(), player, CheckType.FLY);
|
||||
}
|
||||
}
|
||||
if (getCheckManager().willCheckQuick(player, CheckType.FLY)) {
|
||||
CheckResult result = ElytraFly.runCheck(player, distance);
|
||||
if (result.failed()) {
|
||||
log(result.getMessage(), player, CheckType.FLY);
|
||||
}
|
||||
}
|
||||
if (getCheckManager().willCheckQuick(player, CheckType.VCLIP) && event.getFrom().getY() > event.getTo().getY()) {
|
||||
CheckResult result = getBackend().checkVClip(player, new Distance(event.getFrom(), event.getTo()));
|
||||
if (result.failed()) {
|
||||
if (!silentMode()) {
|
||||
int data = result.getData() > 3 ? 3 : result.getData();
|
||||
Location newloc = new Location(player.getWorld(), event.getFrom().getX(), event.getFrom().getY() + data, event.getFrom().getZ());
|
||||
if (newloc.getBlock().getType() == Material.AIR) {
|
||||
event.setTo(newloc);
|
||||
} else {
|
||||
event.setTo(user.getGoodLocation(from.clone()));
|
||||
}
|
||||
player.damage(3);
|
||||
}
|
||||
log(result.getMessage(), player, CheckType.VCLIP);
|
||||
}
|
||||
}
|
||||
if (getCheckManager().willCheckQuick(player, CheckType.NOFALL) && getCheckManager().willCheck(player, CheckType.FLY) && !Utilities.isClimbableBlock(player.getLocation().getBlock()) && event.getFrom().getY() > event.getTo().getY()) {
|
||||
CheckResult result = getBackend().checkNoFall(player, y);
|
||||
if (result.failed()) {
|
||||
if (!silentMode()) {
|
||||
event.setTo(user.getGoodLocation(from.clone()));
|
||||
/*TODO: player.damage(1); better system for this, too exploitable*/
|
||||
}
|
||||
log(result.getMessage(), player, CheckType.NOFALL);
|
||||
}
|
||||
}
|
||||
if (player.hasPermission("anticheat.admin") && !AntiCheatReloaded.getUpdateManager().isLatest()) {
|
||||
player.sendMessage(ChatColor.GOLD + "" + ChatColor.BOLD + "ACR " + ChatColor.GRAY
|
||||
+ "Your version of AntiCheatReloaded is outdated! You can download "
|
||||
+ AntiCheatReloaded.getUpdateManager().getLatestVersion()
|
||||
+ " from the Spigot forums or DevBukkit.");
|
||||
}
|
||||
}
|
||||
|
||||
boolean changed = false;
|
||||
if (event.getTo() != event.getFrom()) {
|
||||
double x = distance.getXDifference();
|
||||
double z = distance.getZDifference();
|
||||
if (getCheckManager().willCheckQuick(player, CheckType.SPEED) && getCheckManager().willCheck(player, CheckType.FLY)) {
|
||||
if (event.getFrom().getY() < event.getTo().getY()) {
|
||||
CheckResult result = getBackend().checkYSpeed(player, y);
|
||||
if (result.failed()) {
|
||||
if (!silentMode()) {
|
||||
event.setTo(user.getGoodLocation(from.clone()));
|
||||
}
|
||||
log(result.getMessage(), player, CheckType.SPEED);
|
||||
changed = true;
|
||||
}
|
||||
}
|
||||
CheckResult result = SpeedCheck.checkXZSpeed(player, x, z);
|
||||
if (result.failed()) {
|
||||
if (!silentMode()) {
|
||||
event.setTo(user.getGoodLocation(from.clone()));
|
||||
}
|
||||
log(result.getMessage(), player, CheckType.SPEED);
|
||||
changed = true;
|
||||
}
|
||||
}
|
||||
if (getCheckManager().willCheckQuick(player, CheckType.WATER_WALK)) {
|
||||
CheckResult result = WaterWalkCheck.runCheck(player, x, y, z);
|
||||
if (result.failed()) {
|
||||
if (!silentMode()) {
|
||||
player.teleport(user.getGoodLocation(player.getLocation().add(0, -1.5, 0)));
|
||||
}
|
||||
log(result.getMessage(), player, CheckType.WATER_WALK);
|
||||
changed = true;
|
||||
}
|
||||
}
|
||||
if (getCheckManager().willCheckQuick(player, CheckType.SNEAK)) {
|
||||
CheckResult result = getBackend().checkSneak(player, x, z);
|
||||
if (result.failed()) {
|
||||
if (!silentMode()) {
|
||||
event.setTo(user.getGoodLocation(from.clone()));
|
||||
player.setSneaking(false);
|
||||
}
|
||||
log(result.getMessage(), player, CheckType.SNEAK);
|
||||
changed = true;
|
||||
}
|
||||
}
|
||||
if (getCheckManager().willCheckQuick(player, CheckType.SPIDER)) {
|
||||
CheckResult result = getBackend().checkSpider(player, y);
|
||||
if (result.failed()) {
|
||||
if (!silentMode()) {
|
||||
event.setTo(user.getGoodLocation(from.clone()));
|
||||
}
|
||||
log(result.getMessage(), player, CheckType.SPIDER);
|
||||
changed = true;
|
||||
}
|
||||
}
|
||||
if (!changed) {
|
||||
user.setGoodLocation(event.getFrom());
|
||||
}
|
||||
}
|
||||
}
|
||||
AntiCheat.getManager().addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners());
|
||||
}
|
||||
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
|
||||
public void onPlayerMove(final PlayerMoveEvent event) {
|
||||
final Player player = event.getPlayer();
|
||||
if (getCheckManager().checkInWorld(player) && !getCheckManager().isOpExempt(player)) {
|
||||
final Location from = event.getFrom();
|
||||
final Location to = event.getTo();
|
||||
|
||||
@EventHandler(priority=EventPriority.HIGHEST)
|
||||
public void onDeath(PlayerDeathEvent e) {
|
||||
KillAuraCheck.cleanPlayer(e.getEntity()); // Remove bots on death to reduce lag
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||
public void checkFly(PlayerMoveEvent event) {
|
||||
// Check flight on highest to make sure other plugins have a chance to change the values first.
|
||||
final Player player = event.getPlayer();
|
||||
final User user = getUserManager().getUser(player.getUniqueId());
|
||||
final Location from = event.getFrom();
|
||||
final Location to = event.getTo();
|
||||
final Distance distance = new Distance(from, to);
|
||||
final double y = distance.getYDifference();
|
||||
|
||||
if (!user.checkTo(to.getX(), to.getY(), to.getZ())) {
|
||||
// The to value has been modified by another plugin
|
||||
return;
|
||||
}
|
||||
final User user = getUserManager().getUser(player.getUniqueId());
|
||||
user.setTo(to.getX(), to.getY(), to.getZ());
|
||||
user.getMovementManager().handle(player, from, to, distance);
|
||||
|
||||
if (getCheckManager().willCheckQuick(player, CheckType.FLIGHT) && !VersionLib.isFlying(player)) {
|
||||
final CheckResult result = FlightCheck.runCheck(player, distance);
|
||||
if (result.failed()) {
|
||||
if (!silentMode()) {
|
||||
event.setTo(user.getGoodLocation(from.clone()));
|
||||
}
|
||||
log(result.getMessage(), player, CheckType.FLIGHT, result.getSubCheck());
|
||||
}
|
||||
}
|
||||
if (getCheckManager().willCheckQuick(player, CheckType.ELYTRAFLY)) {
|
||||
final CheckResult result = ElytraCheck.runCheck(player, distance);
|
||||
if (result.failed()) {
|
||||
log(result.getMessage(), player, CheckType.ELYTRAFLY, result.getSubCheck());
|
||||
}
|
||||
}
|
||||
if (getCheckManager().willCheckQuick(player, CheckType.BOATFLY)) {
|
||||
final CheckResult result = BoatFlyCheck.runCheck(player, user.getMovementManager(), to);
|
||||
if (result.failed()) {
|
||||
if (!silentMode()) {
|
||||
player.eject();
|
||||
event.setTo(user.getGoodLocation(from.clone()));
|
||||
}
|
||||
log(result.getMessage(), player, CheckType.BOATFLY, result.getSubCheck());
|
||||
}
|
||||
}
|
||||
if (getCheckManager().willCheckQuick(player, CheckType.VCLIP)
|
||||
&& event.getFrom().getY() > event.getTo().getY()) {
|
||||
final CheckResult result = getBackend().checkVClip(player,
|
||||
new Distance(event.getFrom(), event.getTo()));
|
||||
if (result.failed()) {
|
||||
if (!silentMode()) {
|
||||
int data = result.getData() > 3 ? 3 : result.getData();
|
||||
Location newloc = new Location(player.getWorld(), event.getFrom().getX(),
|
||||
event.getFrom().getY() + data, event.getFrom().getZ());
|
||||
if (newloc.getBlock().getType() == Material.AIR) {
|
||||
event.setTo(newloc);
|
||||
} else {
|
||||
event.setTo(user.getGoodLocation(from.clone()));
|
||||
}
|
||||
player.damage(3);
|
||||
}
|
||||
log(result.getMessage(), player, CheckType.VCLIP, result.getSubCheck());
|
||||
}
|
||||
}
|
||||
if (getCheckManager().willCheckQuick(player, CheckType.NOFALL)
|
||||
&& getCheckManager().willCheck(player, CheckType.FLIGHT)
|
||||
&& !Utilities.isClimbableBlock(player.getLocation().getBlock())
|
||||
&& event.getFrom().getY() > event.getTo().getY()) {
|
||||
final CheckResult result = NoFallCheck.runCheck(player, y);
|
||||
if (result.failed()) {
|
||||
if (!silentMode()) {
|
||||
event.setTo(user.getGoodLocation(from.clone()));
|
||||
}
|
||||
log(result.getMessage(), player, CheckType.NOFALL, result.getSubCheck());
|
||||
}
|
||||
}
|
||||
|
||||
if (event.getTo() != event.getFrom()) {
|
||||
final double x = distance.getXDifference();
|
||||
final double z = distance.getZDifference();
|
||||
if (getCheckManager().willCheckQuick(player, CheckType.SPEED)) {
|
||||
final CheckResult result = SpeedCheck.checkPredict(player, event.getTo());
|
||||
if (result.failed()) {
|
||||
if (!silentMode()) {
|
||||
event.setTo(user.getGoodLocation(from.clone()));
|
||||
}
|
||||
|
||||
log(result.getMessage(), player, CheckType.SPEED, result.getSubCheck());
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (getCheckManager().willCheckQuick(player, CheckType.SPEED) && event.getFrom().getY() < event.getTo().getY()) {
|
||||
final CheckResult result = SpeedCheck.checkVerticalSpeed(player, distance);
|
||||
if (result.failed()) {
|
||||
if (!silentMode()) {
|
||||
event.setTo(user.getGoodLocation(from.clone()));
|
||||
}
|
||||
|
||||
log(result.getMessage(), player, CheckType.SPEED, result.getSubCheck());
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (getCheckManager().willCheckQuick(player, CheckType.SPEED)) {
|
||||
final CheckResult result = SpeedCheck.checkXZSpeed(player, event.getTo());
|
||||
if (result.failed()) {
|
||||
if (!silentMode()) {
|
||||
event.setTo(user.getGoodLocation(from.clone()));
|
||||
}
|
||||
|
||||
log(result.getMessage(), player, CheckType.SPEED, result.getSubCheck());
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (getCheckManager().willCheckQuick(player, CheckType.WATER_WALK)) {
|
||||
final CheckResult result = WaterWalkCheck.runCheck(player, x, y, z);
|
||||
if (result.failed()) {
|
||||
if (!silentMode()) {
|
||||
player.teleport(player.getLocation().clone().subtract(0, 0.42f, 0));
|
||||
}
|
||||
|
||||
log(result.getMessage(), player, CheckType.WATER_WALK, result.getSubCheck());
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (getCheckManager().willCheckQuick(player, CheckType.SPIDER)) {
|
||||
final CheckResult result = getBackend().checkSpider(player, y);
|
||||
if (result.failed()) {
|
||||
if (!silentMode()) {
|
||||
event.setTo(user.getGoodLocation(from.clone()));
|
||||
}
|
||||
|
||||
log(result.getMessage(), player, CheckType.SPIDER, result.getSubCheck());
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (getCheckManager().willCheckQuick(player, CheckType.FASTLADDER)) {
|
||||
// Does not use y value created before because that value is absolute
|
||||
final CheckResult result = FastLadderCheck.runCheck(player,
|
||||
event.getTo().getY() - event.getFrom().getY());
|
||||
if (result.failed()) {
|
||||
if (!silentMode()) {
|
||||
event.setTo(user.getGoodLocation(from.clone()));
|
||||
}
|
||||
|
||||
log(result.getMessage(), player, CheckType.FASTLADDER, result.getSubCheck());
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (getCheckManager().willCheckQuick(player, CheckType.STRAFE)) {
|
||||
final CheckResult result = StrafeCheck.runCheck(player, x, z, event.getFrom(), event.getTo());
|
||||
if (result.failed()) {
|
||||
if (!silentMode()) {
|
||||
event.setTo(user.getGoodLocation(from.clone()));
|
||||
}
|
||||
|
||||
log(result.getMessage(), player, CheckType.STRAFE, result.getSubCheck());
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (getCheckManager().willCheckQuick(player, CheckType.VELOCITY)) {
|
||||
final CheckResult result = VelocityCheck.runCheck(player, distance);
|
||||
if (result.failed()) {
|
||||
log(result.getMessage(), player, CheckType.VELOCITY, result.getSubCheck());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
MANAGER.addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners());
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void onRespawn(final PlayerRespawnEvent event) {
|
||||
getBackend().logTeleport(event.getPlayer());
|
||||
}
|
||||
|
||||
if (getCheckManager().willCheck(player, CheckType.FLY) && !player.isFlying()) {
|
||||
CheckResult result1 = YAxisCheck.runCheck(player, new Distance(from, to));
|
||||
CheckResult result2 = getBackend().checkAscension(player, from.getY(), to.getY());
|
||||
String log = result1.failed() ? result1.getMessage() : result2.failed() ? result2.getMessage() : "";
|
||||
if (!log.equals("")) {
|
||||
if (!silentMode()) {
|
||||
event.setTo(user.getGoodLocation(from.clone()));
|
||||
}
|
||||
log(log, player, CheckType.FLY);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
/*
|
||||
* AntiCheat for Bukkit.
|
||||
* Copyright (C) 2012-2014 AntiCheat Team | http://gravitydevelopment.net
|
||||
* AntiCheatReloaded for Bukkit and Spigot.
|
||||
* Copyright (c) 2012-2015 AntiCheat Team
|
||||
* Copyright (c) 2016-2022 Rammelkast
|
||||
*
|
||||
* 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
|
||||
@@ -18,41 +19,44 @@
|
||||
|
||||
package com.rammelkast.anticheatreloaded.event;
|
||||
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.vehicle.VehicleDestroyEvent;
|
||||
import org.bukkit.event.vehicle.VehicleEnterEvent;
|
||||
import org.bukkit.event.vehicle.VehicleExitEvent;
|
||||
|
||||
import com.rammelkast.anticheatreloaded.AntiCheat;
|
||||
import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
|
||||
|
||||
public class VehicleListener extends EventListener {
|
||||
|
||||
@EventHandler(ignoreCancelled = true)
|
||||
public void onVehicleEnter(VehicleEnterEvent event) {
|
||||
if (event.getEntered() instanceof Player) {
|
||||
getBackend().logEnterExit((Player) event.getEntered());
|
||||
}
|
||||
@EventHandler(ignoreCancelled = true)
|
||||
public void onVehicleEnter(VehicleEnterEvent event) {
|
||||
if (event.getEntered() instanceof Player) {
|
||||
getBackend().logEnterExit((Player) event.getEntered());
|
||||
}
|
||||
|
||||
AntiCheat.getManager().addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners());
|
||||
}
|
||||
AntiCheatReloaded.getManager().addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners());
|
||||
}
|
||||
|
||||
@EventHandler(ignoreCancelled = true)
|
||||
public void onVehicleExit(VehicleExitEvent event) {
|
||||
if (event.getExited() instanceof Player) {
|
||||
getBackend().logEnterExit((Player) event.getExited());
|
||||
}
|
||||
@EventHandler(ignoreCancelled = true)
|
||||
public void onVehicleExit(VehicleExitEvent event) {
|
||||
if (event.getExited() instanceof Player) {
|
||||
getBackend().logEnterExit((Player) event.getExited());
|
||||
}
|
||||
|
||||
AntiCheat.getManager().addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners());
|
||||
}
|
||||
AntiCheatReloaded.getManager().addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners());
|
||||
}
|
||||
|
||||
|
||||
@EventHandler(ignoreCancelled = true)
|
||||
public void onVehicleDestroy(VehicleDestroyEvent event) {
|
||||
if (event.getVehicle().getPassenger() != null && event.getVehicle().getPassenger() instanceof Player) {
|
||||
getBackend().logEnterExit((Player) event.getVehicle().getPassenger());
|
||||
}
|
||||
|
||||
AntiCheat.getManager().addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners());
|
||||
}
|
||||
@EventHandler(ignoreCancelled = true)
|
||||
public void onVehicleDestroy(VehicleDestroyEvent event) {
|
||||
if (!event.getVehicle().getPassengers().isEmpty()) {
|
||||
for (Entity entity : event.getVehicle().getPassengers()) {
|
||||
if (entity instanceof Player) {
|
||||
getBackend().logEnterExit((Player) entity);
|
||||
}
|
||||
}
|
||||
}
|
||||
AntiCheatReloaded.getManager().addEvent(event.getEventName(), event.getHandlers().getRegisteredListeners());
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
/*
|
||||
* AntiCheat for Bukkit.
|
||||
* Copyright (C) 2012-2014 AntiCheat Team | http://gravitydevelopment.net
|
||||
* AntiCheatReloaded for Bukkit and Spigot.
|
||||
* Copyright (c) 2012-2015 AntiCheat Team
|
||||
* Copyright (c) 2016-2022 Rammelkast
|
||||
*
|
||||
* 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
|
||||
@@ -10,12 +11,11 @@
|
||||
* 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.
|
||||
* 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, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.rammelkast.anticheatreloaded.manage;
|
||||
|
||||
import java.util.Map;
|
||||
@@ -25,25 +25,25 @@ import java.util.logging.Logger;
|
||||
|
||||
import org.bukkit.plugin.RegisteredListener;
|
||||
|
||||
import com.rammelkast.anticheatreloaded.AntiCheat;
|
||||
import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
|
||||
import com.rammelkast.anticheatreloaded.check.Backend;
|
||||
import com.rammelkast.anticheatreloaded.config.Configuration;
|
||||
|
||||
/**
|
||||
* The internal hub for all managers.
|
||||
*/
|
||||
|
||||
public class AntiCheatManager {
|
||||
private static AntiCheat plugin = null;
|
||||
public final class AntiCheatManager {
|
||||
|
||||
private static AntiCheatReloaded plugin;
|
||||
private static Configuration configuration;
|
||||
private static UserManager userManager = null;
|
||||
private static CheckManager checkManager = null;
|
||||
private static LoggingManager loggingManager = null;
|
||||
private static Backend backend = null;
|
||||
private static UserManager userManager;
|
||||
private static CheckManager checkManager;
|
||||
private static LoggingManager loggingManager;
|
||||
private static Backend backend;
|
||||
private static Map<String, RegisteredListener[]> eventchains = new ConcurrentHashMap<String, RegisteredListener[]>();
|
||||
private static Map<String, Long> eventcache = new ConcurrentHashMap<String, Long>();
|
||||
|
||||
public AntiCheatManager(AntiCheat instance, Logger logger) {
|
||||
public AntiCheatManager(final AntiCheatReloaded instance, final Logger logger) {
|
||||
plugin = instance;
|
||||
configuration = new Configuration(plugin, this);
|
||||
loggingManager = new LoggingManager(plugin, logger, configuration);
|
||||
@@ -104,7 +104,7 @@ public class AntiCheatManager {
|
||||
return gen;
|
||||
}
|
||||
|
||||
public AntiCheat getPlugin() {
|
||||
public AntiCheatReloaded getPlugin() {
|
||||
return plugin;
|
||||
}
|
||||
|
||||
@@ -134,5 +134,18 @@ public class AntiCheatManager {
|
||||
if (configuration.getConfig().enterprise.getValue()) {
|
||||
configuration.getEnterprise().database.shutdown();
|
||||
}
|
||||
|
||||
eventchains.clear();
|
||||
eventcache.clear();
|
||||
|
||||
// Nullify
|
||||
plugin = null;
|
||||
configuration = null;
|
||||
loggingManager = null;
|
||||
userManager = null;
|
||||
checkManager = null;
|
||||
backend = null;
|
||||
eventchains = null;
|
||||
eventcache = null;
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
/*
|
||||
* AntiCheat for Bukkit.
|
||||
* Copyright (C) 2012-2014 AntiCheat Team | http://gravitydevelopment.net
|
||||
* AntiCheatReloaded for Bukkit and Spigot.
|
||||
* Copyright (c) 2012-2015 AntiCheat Team
|
||||
* Copyright (c) 2016-2022 Rammelkast
|
||||
*
|
||||
* 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
|
||||
@@ -18,50 +19,60 @@
|
||||
|
||||
package com.rammelkast.anticheatreloaded.manage;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.rammelkast.anticheatreloaded.AntiCheat;
|
||||
import com.rammelkast.anticheatreloaded.check.CheckType;
|
||||
import com.rammelkast.anticheatreloaded.config.Configuration;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.geysermc.floodgate.api.FloodgateApi;
|
||||
|
||||
import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
|
||||
import com.rammelkast.anticheatreloaded.check.CheckType;
|
||||
import com.rammelkast.anticheatreloaded.config.Configuration;
|
||||
import com.rammelkast.anticheatreloaded.util.VersionLib;
|
||||
|
||||
/**
|
||||
* <p/>
|
||||
* The manager that AntiCheat will check with to see if it should watch certain checks and certain players.
|
||||
* The manager that AntiCheatReloaded will check with to see if it should watch
|
||||
* certain checks and certain players.
|
||||
*/
|
||||
public final class CheckManager {
|
||||
|
||||
private final AntiCheatManager manager;
|
||||
private final Configuration config;
|
||||
|
||||
private static final List<CheckType> checkIgnoreList = new ArrayList<CheckType>();
|
||||
private static final Map<UUID, List<CheckType>> exemptList = new HashMap<UUID, List<CheckType>>();
|
||||
|
||||
public class CheckManager {
|
||||
private AntiCheatManager manager = null;
|
||||
private Configuration config;
|
||||
private static List<CheckType> checkIgnoreList = new ArrayList<CheckType>();
|
||||
private static Map<UUID, List<CheckType>> exemptList = new HashMap<UUID, List<CheckType>>();
|
||||
|
||||
public CheckManager(AntiCheatManager manager) {
|
||||
public CheckManager(final AntiCheatManager manager) {
|
||||
this.manager = manager;
|
||||
this.config = manager.getConfiguration();
|
||||
|
||||
for (String string : config.getConfig().disabledChecks.getValue()) {
|
||||
for (CheckType type : CheckType.values()) {
|
||||
if (type.toString().equalsIgnoreCase(string)) {
|
||||
checkIgnoreList.add(type);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
loadCheckIgnoreList(this.config);
|
||||
}
|
||||
|
||||
public void loadCheckIgnoreList(final Configuration configuration) {
|
||||
checkIgnoreList.clear();
|
||||
for (final CheckType type : CheckType.values()) {
|
||||
if (!configuration.getChecks().isEnabled(type)) {
|
||||
checkIgnoreList.add(type);
|
||||
}
|
||||
}
|
||||
|
||||
if (!checkIgnoreList.isEmpty()) {
|
||||
Bukkit.getConsoleSender().sendMessage(ChatColor.GOLD + "" + ChatColor.BOLD + "ACR " + ChatColor.DARK_GRAY + "> " + ChatColor.GRAY
|
||||
+ checkIgnoreList.size() + " check(s) have been disabled");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Turn a check on
|
||||
*
|
||||
* @param type The CheckType to enable
|
||||
*/
|
||||
public void activateCheck(CheckType type, String className) {
|
||||
public void activateCheck(final CheckType type, final String className) {
|
||||
if (!isActive(type)) {
|
||||
manager.getLoggingManager().logFineInfo("The " + type.toString() + " check was activated by " + className + ".");
|
||||
checkIgnoreList.remove(type);
|
||||
@@ -73,7 +84,7 @@ public class CheckManager {
|
||||
*
|
||||
* @param type The CheckType to disable
|
||||
*/
|
||||
public void deactivateCheck(CheckType type, String className) {
|
||||
public void deactivateCheck(final CheckType type, final String className) {
|
||||
if (isActive(type)) {
|
||||
manager.getLoggingManager().logFineInfo("The " + type.toString() + " check was deactivated by " + className + ".");
|
||||
checkIgnoreList.add(type);
|
||||
@@ -86,7 +97,7 @@ public class CheckManager {
|
||||
* @param type The CheckType to check
|
||||
* @return true if the check is active
|
||||
*/
|
||||
public boolean isActive(CheckType type) {
|
||||
public boolean isActive(final CheckType type) {
|
||||
return !checkIgnoreList.contains(type);
|
||||
}
|
||||
|
||||
@@ -96,7 +107,7 @@ public class CheckManager {
|
||||
* @param player The player
|
||||
* @param type The check
|
||||
*/
|
||||
public void exemptPlayer(Player player, CheckType type, String className) {
|
||||
public void exemptPlayer(final Player player, final CheckType type, final String className) {
|
||||
if (!isExempt(player, type)) {
|
||||
if (!exemptList.containsKey(player.getUniqueId())) {
|
||||
exemptList.put(player.getUniqueId(), new ArrayList<CheckType>());
|
||||
@@ -112,7 +123,7 @@ public class CheckManager {
|
||||
* @param player The player
|
||||
* @param type The check
|
||||
*/
|
||||
public void unexemptPlayer(Player player, CheckType type, String className) {
|
||||
public void unexemptPlayer(final Player player, final CheckType type, final String className) {
|
||||
if (isExempt(player, type)) {
|
||||
manager.getLoggingManager().logFineInfo(player.getName() + " was unexempted from the " + type.toString() + " check by " + className + ".");
|
||||
exemptList.get(player.getUniqueId()).remove(type);
|
||||
@@ -125,7 +136,12 @@ public class CheckManager {
|
||||
* @param player The player
|
||||
* @param type The check
|
||||
*/
|
||||
public boolean isExempt(Player player, CheckType type) {
|
||||
public boolean isExempt(final Player player, final CheckType type) {
|
||||
if (AntiCheatReloaded.isFloodgateEnabled()) {
|
||||
if (FloodgateApi.getInstance().isFloodgatePlayer(player.getUniqueId())) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return exemptList.containsKey(player.getUniqueId()) ? exemptList.get(player.getUniqueId()).contains(type) : false;
|
||||
}
|
||||
|
||||
@@ -134,7 +150,7 @@ public class CheckManager {
|
||||
*
|
||||
* @param player The player
|
||||
*/
|
||||
public boolean isOpExempt(Player player) {
|
||||
public boolean isOpExempt(final Player player) {
|
||||
return (this.manager.getConfiguration().getConfig().exemptOp.getValue() && player.isOp());
|
||||
}
|
||||
|
||||
@@ -144,7 +160,7 @@ public class CheckManager {
|
||||
* @param player The player
|
||||
* @return true if the player's world is enabled
|
||||
*/
|
||||
public boolean checkInWorld(Player player) {
|
||||
public boolean checkInWorld(final Player player) {
|
||||
return !config.getConfig().disabledWorlds.getValue().contains(player.getWorld().getName());
|
||||
}
|
||||
|
||||
@@ -155,7 +171,7 @@ public class CheckManager {
|
||||
* @param type The check being run
|
||||
* @return true if the check should run
|
||||
*/
|
||||
public boolean willCheckQuick(Player player, CheckType type) {
|
||||
public boolean willCheckQuick(final Player player, final CheckType type) {
|
||||
return
|
||||
isActive(type)
|
||||
&& !isExempt(player, type)
|
||||
@@ -169,16 +185,15 @@ public class CheckManager {
|
||||
* @param type The check being run
|
||||
* @return true if the check should run
|
||||
*/
|
||||
public boolean willCheck(Player player, CheckType type) {
|
||||
boolean check = isActive(type)
|
||||
public boolean willCheck(final Player player, final CheckType type) {
|
||||
final boolean check = isActive(type)
|
||||
&& checkInWorld(player)
|
||||
&& !isExempt(player, type)
|
||||
&& !type.checkPermission(player)
|
||||
&& !isOpExempt(player);
|
||||
AntiCheat.debugLog("Check " + type + (check ? " run " : " not run ") + "on " + player.getName());
|
||||
// TODO temp fix
|
||||
if ((type == CheckType.FLY || type == CheckType.SPEED) && player.isFlying())
|
||||
if ((type == CheckType.FLIGHT || type == CheckType.SPEED) && VersionLib.isFlying(player)) {
|
||||
return false;
|
||||
}
|
||||
return check;
|
||||
}
|
||||
|
||||
@@ -188,10 +203,10 @@ public class CheckManager {
|
||||
* @param player Player to check
|
||||
* @return true if the player is a real person
|
||||
*/
|
||||
public boolean isOnline(Player player) {
|
||||
public boolean isOnline(final Player player) {
|
||||
// Check if the player is on the user list, e.g. is not an NPC
|
||||
for (Player p : Bukkit.getOnlinePlayers()) {
|
||||
if (p.getUniqueId().equals(player.getUniqueId())) {
|
||||
for (final Player iterated : Bukkit.getOnlinePlayers()) {
|
||||
if (iterated.getUniqueId().equals(player.getUniqueId())) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
/*
|
||||
* AntiCheat for Bukkit.
|
||||
* Copyright (C) 2012-2014 AntiCheat Team | http://gravitydevelopment.net
|
||||
* AntiCheatReloaded for Bukkit and Spigot.
|
||||
* Copyright (c) 2012-2015 AntiCheat Team
|
||||
* Copyright (c) 2016-2022 Rammelkast
|
||||
*
|
||||
* 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
|
||||
@@ -22,7 +23,7 @@ import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.rammelkast.anticheatreloaded.AntiCheat;
|
||||
import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
|
||||
import com.rammelkast.anticheatreloaded.config.Configuration;
|
||||
import com.rammelkast.anticheatreloaded.util.FileFormatter;
|
||||
import com.rammelkast.anticheatreloaded.util.Permission;
|
||||
@@ -42,8 +43,8 @@ public class LoggingManager {
|
||||
private static List<String> logs = new CopyOnWriteArrayList<String>();
|
||||
private final Configuration config;
|
||||
|
||||
public LoggingManager(AntiCheat plugin, Logger logger, Configuration config) {
|
||||
this.fileLogger = Logger.getLogger("net.gravitydevelopment.anticheat.AntiCheat");
|
||||
public LoggingManager(AntiCheatReloaded plugin, Logger logger, Configuration config) {
|
||||
this.fileLogger = Logger.getLogger("com.rammelkast.anticheatreloaded.AntiCheatReloaded");
|
||||
this.config = config;
|
||||
try {
|
||||
File file = new File(plugin.getDataFolder(), "log");
|
||||
@@ -70,12 +71,12 @@ public class LoggingManager {
|
||||
}
|
||||
|
||||
public void debugLog(String message) {
|
||||
Bukkit.getConsoleSender().sendMessage("[AntiCheat] " + ChatColor.GRAY + message);
|
||||
Bukkit.getConsoleSender().sendMessage(ChatColor.GOLD + "" + ChatColor.BOLD + "ACR " + ChatColor.GRAY + message);
|
||||
logToLogs(message);
|
||||
}
|
||||
|
||||
public void logToConsole(String message) {
|
||||
Bukkit.getConsoleSender().sendMessage("[AntiCheat] " + ChatColor.RED + message);
|
||||
Bukkit.getConsoleSender().sendMessage(message);
|
||||
}
|
||||
|
||||
public void logToFile(String message) {
|
||||
@@ -88,6 +89,7 @@ public class LoggingManager {
|
||||
}
|
||||
|
||||
public void logToPlayers(String message) {
|
||||
if(config.getConfig().disableBroadcast.getValue()) return;
|
||||
for(Player player : Bukkit.getOnlinePlayers()) {
|
||||
if (Permission.SYSTEM_NOTICE.get(player)) {
|
||||
player.sendMessage(message);
|
||||
@@ -95,7 +97,7 @@ public class LoggingManager {
|
||||
}
|
||||
}
|
||||
|
||||
private void logToLogs(String message) { // Yo dawg
|
||||
private void logToLogs(String message) {
|
||||
logs.add(ChatColor.stripColor(message));
|
||||
}
|
||||
|
||||
|
||||
@@ -1,37 +0,0 @@
|
||||
package com.rammelkast.anticheatreloaded.manage;
|
||||
|
||||
import com.comphenix.protocol.Packets;
|
||||
import com.comphenix.protocol.ProtocolManager;
|
||||
import com.comphenix.protocol.events.*;
|
||||
import com.rammelkast.anticheatreloaded.AntiCheat;
|
||||
|
||||
public class PacketManager {
|
||||
|
||||
private ProtocolManager protocolManager;
|
||||
private AntiCheat plugin;
|
||||
private AntiCheatManager manager;
|
||||
|
||||
public PacketManager(ProtocolManager protocolManager, AntiCheat plugin, AntiCheatManager manager) {
|
||||
this.protocolManager = protocolManager;
|
||||
this.plugin = plugin;
|
||||
this.manager = manager;
|
||||
addListeners();
|
||||
}
|
||||
|
||||
private void addListeners() {
|
||||
// Arm Animation
|
||||
protocolManager.addPacketListener(new PacketAdapter(plugin,
|
||||
ConnectionSide.CLIENT_SIDE,
|
||||
ListenerPriority.NORMAL,
|
||||
Packets.Client.ARM_ANIMATION) {
|
||||
|
||||
@Override
|
||||
public void onPacketReceiving(PacketEvent event) {
|
||||
if (event.getPacketID() == Packets.Client.ARM_ANIMATION) {
|
||||
PacketContainer packet = event.getPacket();
|
||||
//System.out.println("Arm animation from "+packet.getIntegers().read(0));
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
/*
|
||||
* AntiCheat for Bukkit.
|
||||
* Copyright (C) 2012-2014 AntiCheat Team | http://gravitydevelopment.net
|
||||
* AntiCheatReloaded for Bukkit and Spigot.
|
||||
* Copyright (c) 2012-2015 AntiCheat Team
|
||||
* Copyright (c) 2016-2022 Rammelkast
|
||||
*
|
||||
* 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
|
||||
@@ -18,244 +19,229 @@
|
||||
|
||||
package com.rammelkast.anticheatreloaded.manage;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.bukkit.BanList.Type;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
|
||||
import com.rammelkast.anticheatreloaded.AntiCheat;
|
||||
import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
|
||||
import com.rammelkast.anticheatreloaded.api.event.PlayerPunishEvent;
|
||||
import com.rammelkast.anticheatreloaded.check.CheckType;
|
||||
import com.rammelkast.anticheatreloaded.config.Configuration;
|
||||
import com.rammelkast.anticheatreloaded.util.Group;
|
||||
import com.rammelkast.anticheatreloaded.util.User;
|
||||
import com.rammelkast.anticheatreloaded.util.Utilities;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
public final class UserManager {
|
||||
private final List<User> users = new ArrayList<User>();
|
||||
private final AntiCheatManager manager;
|
||||
private final Configuration config;
|
||||
|
||||
public class UserManager {
|
||||
private List<User> users = new ArrayList<User>();
|
||||
private static AntiCheatManager manager;
|
||||
private static Configuration config;
|
||||
private static final ChatColor GRAY = ChatColor.GRAY;
|
||||
private static final ChatColor GOLD = ChatColor.GOLD;
|
||||
private static final ChatColor RED = ChatColor.RED;
|
||||
/**
|
||||
* Initialize the user manager
|
||||
*
|
||||
* @param manager The AntiCheat Manager
|
||||
*/
|
||||
public UserManager(final AntiCheatManager manager) {
|
||||
this.manager = manager;
|
||||
this.config = manager.getConfiguration();
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize the user manager
|
||||
*
|
||||
* @param manager The AntiCheat Manager
|
||||
*/
|
||||
public UserManager(AntiCheatManager manager) {
|
||||
this.manager = manager;
|
||||
this.config = manager.getConfiguration();
|
||||
}
|
||||
/**
|
||||
* Get a user with the given UUID
|
||||
*
|
||||
* @param uuid UUID
|
||||
* @return User with UUID
|
||||
*/
|
||||
public User getUser(final UUID uuid) {
|
||||
return this.users.parallelStream().filter(user -> user.getUUID().equals(uuid)).findFirst()
|
||||
.orElseGet(() -> new User(uuid));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a user with the given UUID
|
||||
*
|
||||
* @param uuid UUID
|
||||
* @return User with UUID
|
||||
*/
|
||||
public User getUser(UUID uuid) {
|
||||
for (User user : users) {
|
||||
if (user.getUUID().equals(uuid)) {
|
||||
return user;
|
||||
}
|
||||
}
|
||||
// Otherwise try to load them
|
||||
User user = new User(uuid);
|
||||
user.setIsWaitingOnLevelSync(true);
|
||||
config.getLevels().loadLevelToUser(user);
|
||||
return user;
|
||||
}
|
||||
/**
|
||||
* Get all users
|
||||
*
|
||||
* @return List of users
|
||||
*/
|
||||
public List<User> getUsers() {
|
||||
return users;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all users
|
||||
*
|
||||
* @return List of users
|
||||
*/
|
||||
public List<User> getUsers() {
|
||||
return users;
|
||||
}
|
||||
/**
|
||||
* Add a user to the list
|
||||
*
|
||||
* @param user User to add
|
||||
*/
|
||||
public void addUser(final User user) {
|
||||
users.add(user);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a user to the list
|
||||
*
|
||||
* @param user User to add
|
||||
*/
|
||||
public void addUser(User user) {
|
||||
users.add(user);
|
||||
}
|
||||
/**
|
||||
* Remove a user from the list
|
||||
*
|
||||
* @param user User to remove
|
||||
*/
|
||||
public void removeUser(final User user) {
|
||||
users.remove(user);
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove a user from the list
|
||||
*
|
||||
* @param user User to remove
|
||||
*/
|
||||
public void remove(User user) {
|
||||
users.remove(user);
|
||||
}
|
||||
/**
|
||||
* Save a user's level
|
||||
*
|
||||
* @param user User to save
|
||||
*/
|
||||
public void saveLevel(final User user) {
|
||||
config.getLevels().saveLevelFromUser(user);
|
||||
}
|
||||
|
||||
/**
|
||||
* Save a user's level
|
||||
*
|
||||
* @param user User to save
|
||||
*/
|
||||
public void saveLevel(User user) {
|
||||
config.getLevels().saveLevelFromUser(user);
|
||||
}
|
||||
/**
|
||||
* Get users in group
|
||||
*
|
||||
* @param group Group to find users of
|
||||
*/
|
||||
public List<User> getUsersInGroup(final Group group) {
|
||||
return this.users.parallelStream().filter(user -> user.getGroup() == group).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
/**
|
||||
* Get users in group
|
||||
*
|
||||
* @param group Group to find users of
|
||||
*/
|
||||
public List<User> getUsersInGroup(Group group) {
|
||||
List<User> list = new ArrayList<User>();
|
||||
for (User u : users) {
|
||||
if (u.getGroup() == group) {
|
||||
list.add(u);
|
||||
}
|
||||
}
|
||||
return list;
|
||||
}
|
||||
/**
|
||||
* Get a user's level, or 0 if the player isn't found
|
||||
*
|
||||
* @param uuid UUID of the player
|
||||
* @return player level
|
||||
*/
|
||||
public int safeGetLevel(final UUID uuid) {
|
||||
final User user = getUser(uuid);
|
||||
if (user == null) {
|
||||
return 0;
|
||||
} else {
|
||||
return user.getLevel();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a user's level, or 0 if the player isn't found
|
||||
*
|
||||
* @param uuid UUID of the player
|
||||
* @return player level
|
||||
*/
|
||||
public int safeGetLevel(UUID uuid) {
|
||||
User user = getUser(uuid);
|
||||
if (user == null) {
|
||||
return 0;
|
||||
} else {
|
||||
return user.getLevel();
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Set a user's level
|
||||
*
|
||||
* @param uuid UUID of the player
|
||||
* @param level Group to set
|
||||
*/
|
||||
public void safeSetLevel(final UUID uuid, final int level) {
|
||||
final User user = getUser(uuid);
|
||||
if (user != null) {
|
||||
user.setLevel(level);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set a user's level
|
||||
*
|
||||
* @param uuid UUID of the player
|
||||
* @param level Group to set
|
||||
*/
|
||||
public void safeSetLevel(UUID uuid, int level) {
|
||||
User user = getUser(uuid);
|
||||
if (user != null) {
|
||||
user.setLevel(level);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Reset a user
|
||||
*
|
||||
* @param uuid UUID of the user
|
||||
*/
|
||||
public void safeReset(final UUID uuid) {
|
||||
final User user = getUser(uuid);
|
||||
if (user != null) {
|
||||
user.resetLevel();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Reset a user
|
||||
*
|
||||
* @param uuid UUID of the user
|
||||
*/
|
||||
public void safeReset(UUID uuid) {
|
||||
User user = getUser(uuid);
|
||||
if (user != null) {
|
||||
user.resetLevel();
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Fire an alert
|
||||
*
|
||||
* @param user The user to alert
|
||||
* @param group The user's group
|
||||
* @param type The CheckType that triggered the alert
|
||||
*/
|
||||
public void alert(final User user, final Group group, final CheckType type) {
|
||||
execute(user, group.getActions(), type);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the alert to use for a check being failed
|
||||
*
|
||||
* @return check fail alert message
|
||||
*/
|
||||
public List<String> getAlert() {
|
||||
return config.getLang().ALERT();
|
||||
}
|
||||
/**
|
||||
* Execute configuration actions for an alert
|
||||
*
|
||||
* @param user The user
|
||||
* @param actions The list of actions to execute
|
||||
* @param type The CheckType that triggered the alert
|
||||
*/
|
||||
public void execute(final User user, final List<String> actions, final CheckType type) {
|
||||
execute(user, actions, type, config.getLang().KICK_REASON(), config.getLang().WARNING(),
|
||||
config.getLang().BAN_REASON());
|
||||
}
|
||||
|
||||
/**
|
||||
* Fire an alert
|
||||
*
|
||||
* @param user The user to alert
|
||||
* @param group The user's group
|
||||
* @param type The CheckType that triggered the alert
|
||||
*/
|
||||
public void alert(User user, Group group, CheckType type) {
|
||||
ArrayList<String> messageArray = new ArrayList<String>();
|
||||
List<String> alert = getAlert();
|
||||
for (int i = 0; i < alert.size(); i++) {
|
||||
String message = alert.get(i);
|
||||
if (!message.equals("")) {
|
||||
message = message.replaceAll("&player", GOLD + user.getName() + GRAY);
|
||||
message = message.replaceAll("&check", GOLD + CheckType.getName(type) + GRAY);
|
||||
message = message.replaceAll("&group", group.getColor() + group.getName() + GRAY);
|
||||
message = message.replaceAll("&level", "" + user.getLevel() + GRAY);
|
||||
messageArray.add(message);
|
||||
}
|
||||
}
|
||||
Utilities.alert(messageArray);
|
||||
execute(user, group.getActions(), type);
|
||||
}
|
||||
/**
|
||||
* Execute configuration actions for an alert
|
||||
*
|
||||
* @param user The user
|
||||
* @param actions The list of actions to execute
|
||||
* @param type The CheckType that triggered the alert
|
||||
* @param kickReason The config's kick reason
|
||||
* @param warning The config's warning format
|
||||
* @param banReason The config's ban reason
|
||||
*/
|
||||
public void execute(final User user, final List<String> actions, final CheckType type, final String kickReason,
|
||||
final List<String> warning, final String banReason) {
|
||||
// Execute synchronously for thread safety when called from AsyncPlayerChatEvent
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(AntiCheatReloaded.getPlugin(), new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (user.getPlayer() == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
final PlayerPunishEvent event = new PlayerPunishEvent(user, actions);
|
||||
{
|
||||
Bukkit.getServer().getPluginManager().callEvent(event);
|
||||
if (event.isCancelled()) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
final String name = user.getName();
|
||||
for (String action : actions) {
|
||||
action = action.replaceAll("%player%", name)
|
||||
.replaceAll("%world%", user.getPlayer().getWorld().getName())
|
||||
.replaceAll("%check%", type.name());
|
||||
|
||||
/**
|
||||
* Execute configuration actions for an alert
|
||||
*
|
||||
* @param user The user
|
||||
* @param actions The list of actions to execute
|
||||
* @param type The CheckType that triggered the alert
|
||||
*/
|
||||
public void execute(User user, List<String> actions, CheckType type) {
|
||||
execute(user, actions, type, config.getLang().KICK_REASON(), config.getLang().WARNING(), config.getLang().BAN_REASON());
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute configuration actions for an alert
|
||||
*
|
||||
* @param user The user
|
||||
* @param actions The list of actions to execute
|
||||
* @param type The CheckType that triggered the alert
|
||||
* @param kickReason The config's kick reason
|
||||
* @param warning The config's warning format
|
||||
* @param banReason The config's ban reason
|
||||
*/
|
||||
public void execute(final User user, final List<String> actions, final CheckType type, final String kickReason, final List<String> warning, final String banReason) {
|
||||
// Execute synchronously for thread safety when called from AsyncPlayerChatEvent
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(AntiCheat.getPlugin(), new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
final String name = user.getName();
|
||||
for (String event : actions) {
|
||||
event = event.replaceAll("&player", name).replaceAll("&world", user.getPlayer().getWorld().getName()).replaceAll("&check", type.name());
|
||||
|
||||
if (event.startsWith("COMMAND[")) {
|
||||
for (String cmd : Utilities.getCommands(event)) {
|
||||
Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(), cmd);
|
||||
}
|
||||
} else if (event.equalsIgnoreCase("KICK")) {
|
||||
user.getPlayer().kickPlayer(RED + kickReason);
|
||||
AntiCheat.getPlugin().onPlayerKicked();
|
||||
String msg = RED + config.getLang().KICK_BROADCAST().replaceAll("&player", name) + " (" + CheckType.getName(type) + ")";
|
||||
if (!msg.equals("")) {
|
||||
manager.log(msg);
|
||||
manager.playerLog(msg);
|
||||
}
|
||||
} else if (event.equalsIgnoreCase("WARN")) {
|
||||
List<String> message = warning;
|
||||
for (String string : message) {
|
||||
if (!string.equals("")) {
|
||||
user.getPlayer().sendMessage(RED + string);
|
||||
}
|
||||
}
|
||||
} else if (event.equalsIgnoreCase("BAN")) {
|
||||
user.getPlayer().setBanned(true);
|
||||
user.getPlayer().kickPlayer(RED + banReason);
|
||||
String msg = RED + config.getLang().BAN_BROADCAST().replaceAll("&player", name) + " (" + CheckType.getName(type) + ")";
|
||||
if (!msg.equals("")) {
|
||||
manager.log(msg);
|
||||
manager.playerLog(msg);
|
||||
}
|
||||
} else if (event.equalsIgnoreCase("RESET")) {
|
||||
user.resetLevel();
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
if (action.startsWith("COMMAND[")) {
|
||||
for (String cmd : Utilities.getCommands(action)) {
|
||||
Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(), cmd);
|
||||
}
|
||||
} else if (action.equalsIgnoreCase("KICK")) {
|
||||
user.getPlayer().kickPlayer(ChatColor.translateAlternateColorCodes('&', kickReason));
|
||||
AntiCheatReloaded.getPlugin().onPlayerKicked();
|
||||
String msg = ChatColor.translateAlternateColorCodes('&',
|
||||
config.getLang().KICK_BROADCAST().replaceAll("%player%", name) + " (" + type.getName()
|
||||
+ ")");
|
||||
if (!msg.equals("")) {
|
||||
manager.log(msg);
|
||||
manager.playerLog(msg);
|
||||
}
|
||||
} else if (action.equalsIgnoreCase("WARN")) {
|
||||
List<String> message = warning;
|
||||
for (String string : message) {
|
||||
if (!string.equals("")) {
|
||||
user.getPlayer().sendMessage(ChatColor.translateAlternateColorCodes('&', string));
|
||||
}
|
||||
}
|
||||
} else if (action.equalsIgnoreCase("BAN")) {
|
||||
Bukkit.getBanList(Type.NAME).addBan(user.getPlayer().getName(),
|
||||
ChatColor.translateAlternateColorCodes('&', banReason), null, null);
|
||||
user.getPlayer().kickPlayer(ChatColor.translateAlternateColorCodes('&', banReason));
|
||||
String msg = ChatColor.translateAlternateColorCodes('&',
|
||||
config.getLang().BAN_BROADCAST().replaceAll("%player%", name) + " (" + type.getName()
|
||||
+ ")");
|
||||
if (!msg.equals("")) {
|
||||
manager.log(msg);
|
||||
manager.playerLog(msg);
|
||||
}
|
||||
} else if (action.equalsIgnoreCase("RESET")) {
|
||||
user.resetLevel();
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
File diff suppressed because it is too large.
Load diff
@@ -1,225 +0,0 @@
|
||||
/*
|
||||
* AntiCheat for Bukkit.
|
||||
* Copyright (C) 2012-2014 AntiCheat Team | http://gravitydevelopment.net
|
||||
*
|
||||
* 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 3 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, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.rammelkast.anticheatreloaded.util;
|
||||
|
||||
import org.bukkit.Material;
|
||||
|
||||
public enum BlockHardness {
|
||||
STONE(1.50D),
|
||||
GRASS(0.60D),
|
||||
DIRT(0.50D),
|
||||
COBBLESTONE(2.00D),
|
||||
WOOD(2.00D),
|
||||
SAPLING(0.00D),
|
||||
WATER(100.00D),
|
||||
STATIONARY_WATER(100.00D),
|
||||
LAVA(0.00D),
|
||||
STATIONARY_LAVA(100.00D),
|
||||
SAND(0.50D),
|
||||
GRAVEL(0.60D),
|
||||
GOLD_ORE(3.00D),
|
||||
IRON_ORE(3.00D),
|
||||
COAL_ORE(3.00D),
|
||||
LOG(2.00D),
|
||||
LOG_2(2.00D),
|
||||
LEAVES(0.20D),
|
||||
LEAVES_2(0.20D),
|
||||
SPONGE(0.60D),
|
||||
GLASS(0.30D),
|
||||
LAPIS_ORE(3.00D),
|
||||
LAPIS_BLOCK(3.00D),
|
||||
DISPENSER(3.50D),
|
||||
DROPPER(3.50D),
|
||||
SANDSTONE(0.80D),
|
||||
NOTE_BLOCK(0.80D),
|
||||
BED(0.20D),
|
||||
RAILS(0.70D),
|
||||
DETECTOR_RAIL(0.70D),
|
||||
POWERED_RAIL(0.70D),
|
||||
ACTIVATOR_RAIL(0.70D),
|
||||
WEB(4.00D),
|
||||
LONG_GRASS(0.00D),
|
||||
DOUBLE_PLANT(0.00D),
|
||||
DEAD_BUSH(0.00D),
|
||||
WOOL(0.80D),
|
||||
YELLOW_FLOWER(0.00D),
|
||||
RED_ROSE(0.00D),
|
||||
BROWN_MUSHROOM(0.00D),
|
||||
RED_MUSHROOM(0.00D),
|
||||
GOLD_BLOCK(3.00D),
|
||||
IRON_BLOCK(5.00D),
|
||||
DOUBLE_STEP(2.00D),
|
||||
STEP(2.00D),
|
||||
BRICK(2.00D),
|
||||
TNT(0.00D),
|
||||
BOOKSHELF(1.50D),
|
||||
MOSSY_COBBLESTONE(2.00D),
|
||||
OBSIDIAN(50.00D),
|
||||
TORCH(0.00D),
|
||||
FIRE(0.00D),
|
||||
MOB_SPAWNER(5.00D),
|
||||
CHEST(2.50D),
|
||||
TRAPPED_CHEST(2.50D),
|
||||
REDSTONE_WIRE(0.00D),
|
||||
DIAMOND_ORE(3.00D),
|
||||
DIAMOND_BLOCK(5.00D),
|
||||
WORKBENCH(2.50D),
|
||||
SOIL(0.60D),
|
||||
FURNACE(3.50D),
|
||||
BURNING_FURNACE(3.50D),
|
||||
WOODEN_DOOR(3.00D),
|
||||
LADDER(0.40D),
|
||||
LEVER(0.50D),
|
||||
IRON_DOOR_BLOCK(5.00D),
|
||||
HOPPER(2.00D),
|
||||
STONE_PLATE(0.50D),
|
||||
WOOD_PLATE(0.50D),
|
||||
GOLD_PLATE(0.50D),
|
||||
IRON_PLATE(0.50D),
|
||||
QUARTZ_BLOCK(0.80D),
|
||||
QUARTZ_ORE(3.00D),
|
||||
REDSTONE_BLOCK(5.00D),
|
||||
REDSTONE_ORE(3.00D),
|
||||
GLOWING_REDSTONE_ORE(3.00D),
|
||||
REDSTONE_TORCH_OFF(0.00D),
|
||||
REDSTONE_TORCH_ON(0.00D),
|
||||
REDSTONE_COMPARATOR_OFF(0.00D),
|
||||
REDSTONE_COMPARATOR_ON(0.00D),
|
||||
DAYLIGHT_DETECTOR(0.20D),
|
||||
STONE_BUTTON(0.50D),
|
||||
SNOW(0.10D),
|
||||
ICE(0.50D),
|
||||
PACKED_ICE(0.50D),
|
||||
SNOW_BLOCK(0.20D),
|
||||
CACTUS(0.40D),
|
||||
CLAY(0.60D),
|
||||
HARD_CLAY(1.25D),
|
||||
STAINED_CLAY(1.25D),
|
||||
SUGAR_CANE_BLOCK(0.00D),
|
||||
JUKEBOX(2.00D),
|
||||
FENCE(2.00D),
|
||||
NETHERRACK(0.40D),
|
||||
SOUL_SAND(0.50D),
|
||||
GLOWSTONE(0.30D),
|
||||
PORTAL(-1.00D),
|
||||
CAKE_BLOCK(0.50D),
|
||||
LOCKED_CHEST(0.00D),
|
||||
TRAP_DOOR(3.00D),
|
||||
MONSTER_EGGS(0.750D),
|
||||
SMOOTH_BRICK(1.50D),
|
||||
IRON_FENCE(5.00D),
|
||||
THIN_GLASS(0.30D),
|
||||
STAINED_GLASS(0.30D),
|
||||
STAINED_GLASS_PANE(0.30D),
|
||||
PUMPKIN_STEM(0.00D),
|
||||
MELON_STEM(0.00D),
|
||||
VINE(0.20D),
|
||||
FENCE_GATE(2.00D),
|
||||
MYCEL(0.60D),
|
||||
WATER_LILY(0.00D),
|
||||
NETHER_BRICK(2.00D),
|
||||
NETHER_FENCE(2.00D),
|
||||
ENCHANTMENT_TABLE(5.00D),
|
||||
BREWING_STAND(0.50D),
|
||||
CAULDRON(2.00D),
|
||||
ENDER_PORTAL(-1.00D),
|
||||
ENDER_PORTAL_FRAME(-1.00D),
|
||||
DRAGON_EGG(3.00D),
|
||||
REDSTONE_LAMP_OFF(0.30D),
|
||||
REDSTONE_LAMP_ON(0.30D),
|
||||
WOOD_DOUBLE_STEP(2.00D),
|
||||
WOOD_STEP(2.00D),
|
||||
COCOA(0.20D),
|
||||
EMERALD_ORE(3.00D),
|
||||
ENDER_CHEST(22.50D),
|
||||
EMERALD_BLOCK(5.00D),
|
||||
FLOWER_POT(0.00D),
|
||||
WOOD_BUTTON(0.50D),
|
||||
ANVIL(5.00D),
|
||||
HUGE_MUSHROOM_1(0.20D),
|
||||
HUGE_MUSHROOM_2(0.20D),
|
||||
BED_BLOCK(0.20D),
|
||||
WOOD_STAIRS(2.00D),
|
||||
COBBLESTONE_STAIRS(2.00D),
|
||||
BRICK_STAIRS(2.00D),
|
||||
SMOOTH_STAIRS(1.50D),
|
||||
NETHER_BRICK_STAIRS(2.00D),
|
||||
SPRUCE_WOOD_STAIRS(2.00D),
|
||||
BIRCH_WOOD_STAIRS(2.00D),
|
||||
JUNGLE_WOOD_STAIRS(2.00D),
|
||||
DARK_OAK_STAIRS(2.00D),
|
||||
ACACIA_STAIRS(2.00D),
|
||||
QUARTZ_STAIRS(0.80D),
|
||||
SANDSTONE_STAIRS(0.80D),
|
||||
COMMAND(0.00D),
|
||||
BEACON(3.00D),
|
||||
COBBLE_WALL(2.00D),
|
||||
CROPS(0.00D),
|
||||
CARROT(0.00D),
|
||||
POTATO(0.00D),
|
||||
SKULL(1.00D),
|
||||
NETHER_WARTS(0.00D),
|
||||
SIGN_POST(1.00D),
|
||||
WALL_SIGN(1.00D),
|
||||
PUMPKIN(1.00D),
|
||||
JACK_O_LANTERN(1.00D),
|
||||
DIODE_BLOCK_ON(0.00D),
|
||||
DIODE_BLOCK_OFF(0.00D),
|
||||
MELON_BLOCK(1.00D),
|
||||
ENDER_STONE(3.00D),
|
||||
TRIPWIRE(0.00D),
|
||||
TRIPWIRE_HOOK(0.00D),
|
||||
HAY_BLOCK(0.50D),
|
||||
CARPET(0.10D),
|
||||
COAL_BLOCK(5.00D),
|
||||
PISTON_BASE(0.70D),
|
||||
PISTON_EXTENSION(0.70D),
|
||||
PISTON_MOVING_PIECE(0.70D),
|
||||
PISTON_STICKY_BASE(0.70D);
|
||||
|
||||
Material mat;
|
||||
double hardness;
|
||||
|
||||
BlockHardness(double hard) {
|
||||
mat = Material.getMaterial(name());
|
||||
hardness = hard;
|
||||
}
|
||||
|
||||
public static double getBlockHardness(Material m) {
|
||||
try {
|
||||
BlockHardness h = getHardness(m);
|
||||
return h == null ? 0D : h.hardness;
|
||||
}catch(Exception e) {
|
||||
return 0D;
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean hasBlockHardness(Material m) {
|
||||
return getHardness(m) != null;
|
||||
}
|
||||
|
||||
public static BlockHardness getHardness(Material m) {
|
||||
for (BlockHardness e : BlockHardness.values()) {
|
||||
if (e.mat.equals(m)) {
|
||||
return e;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
/*
|
||||
* AntiCheat for Bukkit.
|
||||
* Copyright (C) 2012-2014 AntiCheat Team | http://gravitydevelopment.net
|
||||
* AntiCheatReloaded for Bukkit and Spigot.
|
||||
* Copyright (c) 2012-2015 AntiCheat Team
|
||||
* Copyright (c) 2016-2022 Rammelkast
|
||||
*
|
||||
* 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
|
||||
@@ -21,39 +22,65 @@ package com.rammelkast.anticheatreloaded.util;
|
||||
import org.bukkit.Location;
|
||||
|
||||
public class Distance {
|
||||
private final double l1Y;
|
||||
private final double l2Y;
|
||||
private final double l1Y;
|
||||
private final double l2Y;
|
||||
|
||||
private final double XDiff;
|
||||
private final double YDiff;
|
||||
private final double ZDiff;
|
||||
private final double XDiff;
|
||||
private final double YDiff;
|
||||
private final double ZDiff;
|
||||
|
||||
private final Location from;
|
||||
private final Location to;
|
||||
|
||||
public Distance(Location from, Location to) {
|
||||
l1Y = to.getY();
|
||||
l2Y = from.getY();
|
||||
public Distance(Location from, Location to) {
|
||||
l1Y = to.getY();
|
||||
l2Y = from.getY();
|
||||
|
||||
XDiff = Math.abs(to.getX() - from.getX());
|
||||
ZDiff = Math.abs(to.getZ() - from.getZ());
|
||||
YDiff = Math.abs(l1Y - l2Y);
|
||||
}
|
||||
XDiff = Math.abs(to.getX() - from.getX());
|
||||
ZDiff = Math.abs(to.getZ() - from.getZ());
|
||||
YDiff = Math.abs(l1Y - l2Y);
|
||||
|
||||
this.from = from;
|
||||
this.to = to;
|
||||
}
|
||||
|
||||
public Distance() {
|
||||
l1Y = 0;
|
||||
l2Y = 0;
|
||||
|
||||
public double fromY() {
|
||||
return l2Y;
|
||||
}
|
||||
XDiff = 0;
|
||||
ZDiff = 0;
|
||||
YDiff = 0;
|
||||
|
||||
this.from = null;
|
||||
this.to = null;
|
||||
}
|
||||
|
||||
public double toY() {
|
||||
return l1Y;
|
||||
}
|
||||
public double fromY() {
|
||||
return l2Y;
|
||||
}
|
||||
|
||||
public double getXDifference() {
|
||||
return XDiff;
|
||||
}
|
||||
public double toY() {
|
||||
return l1Y;
|
||||
}
|
||||
|
||||
public double getZDifference() {
|
||||
return ZDiff;
|
||||
}
|
||||
public double getXDifference() {
|
||||
return XDiff;
|
||||
}
|
||||
|
||||
public double getYDifference() {
|
||||
return YDiff;
|
||||
}
|
||||
public double getZDifference() {
|
||||
return ZDiff;
|
||||
}
|
||||
|
||||
public double getYDifference() {
|
||||
return YDiff;
|
||||
}
|
||||
|
||||
public Location getFrom() {
|
||||
return this.from;
|
||||
}
|
||||
|
||||
public Location getTo() {
|
||||
return this.to;
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
/*
|
||||
* AntiCheat for Bukkit.
|
||||
* Copyright (C) 2012-2014 AntiCheat Team | http://gravitydevelopment.net
|
||||
* AntiCheatReloaded for Bukkit and Spigot.
|
||||
* Copyright (c) 2012-2015 AntiCheat Team
|
||||
* Copyright (c) 2016-2022 Rammelkast
|
||||
*
|
||||
* 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
|
||||
@@ -25,12 +26,14 @@ import java.util.logging.Formatter;
|
||||
import java.util.logging.LogRecord;
|
||||
|
||||
public class FileFormatter extends Formatter {
|
||||
private static final DateFormat FORMAT = new SimpleDateFormat("h:mm:ss");
|
||||
private static final String LINE_SEP = System.getProperty("line.separator");
|
||||
private static final DateFormat FORMAT = new SimpleDateFormat("h:mm:ss");
|
||||
private static final String LINE_SEP = System.getProperty("line.separator");
|
||||
|
||||
@Override
|
||||
public String format(LogRecord record) {
|
||||
StringBuilder output = new StringBuilder().append("[").append(record.getLevel()).append('|').append(FORMAT.format(new Date(record.getMillis()))).append("]: ").append(record.getMessage()).append(' ').append(LINE_SEP);
|
||||
return output.toString();
|
||||
}
|
||||
@Override
|
||||
public String format(LogRecord record) {
|
||||
StringBuilder output = new StringBuilder().append("[").append(record.getLevel()).append('|')
|
||||
.append(FORMAT.format(new Date(record.getMillis()))).append("]: ").append(record.getMessage())
|
||||
.append(' ').append(LINE_SEP);
|
||||
return output.toString();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
/*
|
||||
* AntiCheatReloaded for Bukkit and Spigot.
|
||||
* Copyright (c) 2012-2015 AntiCheat Team
|
||||
* Copyright (c) 2016-2022 Rammelkast
|
||||
*
|
||||
* 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 3 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, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.rammelkast.anticheatreloaded.util;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
|
||||
/**
|
||||
* Friction data library to prevent using Reflection or NMS
|
||||
*/
|
||||
public enum Friction {
|
||||
|
||||
DEFAULT(0.6f),
|
||||
ICE(0.98f),
|
||||
BLUE_ICE(0.989f),
|
||||
PACKED_ICE(0.98f),
|
||||
SLIME_BLOCK(0.8f),
|
||||
;
|
||||
|
||||
private final float factor;
|
||||
|
||||
Friction(final float factor) {
|
||||
this.factor = factor;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the friction factor
|
||||
*
|
||||
* @return the factor
|
||||
*/
|
||||
public float getFactor() {
|
||||
return this.factor;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the friction factor for the given block
|
||||
*
|
||||
* @param block The block
|
||||
* @return the friction factor
|
||||
*/
|
||||
public static float getFactor(final Block block) {
|
||||
final Material type = block.getType();
|
||||
try {
|
||||
return valueOf(type.name()).getFactor();
|
||||
} catch (final Exception exception) {
|
||||
return DEFAULT.getFactor();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
/*
|
||||
* AntiCheat for Bukkit.
|
||||
* Copyright (C) 2012-2014 AntiCheat Team | http://gravitydevelopment.net
|
||||
* AntiCheatReloaded for Bukkit and Spigot.
|
||||
* Copyright (c) 2012-2015 AntiCheat Team
|
||||
* Copyright (c) 2016-2022 Rammelkast
|
||||
*
|
||||
* 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
|
||||
@@ -20,7 +21,7 @@ package com.rammelkast.anticheatreloaded.util;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
|
||||
import com.rammelkast.anticheatreloaded.AntiCheat;
|
||||
import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
@@ -28,62 +29,67 @@ import java.util.List;
|
||||
|
||||
public class Group {
|
||||
|
||||
private String name;
|
||||
private int level;
|
||||
private ChatColor color = ChatColor.RED;
|
||||
private List<String> actions = new ArrayList<String>();
|
||||
private String name;
|
||||
private int level;
|
||||
private ChatColor color = ChatColor.RED;
|
||||
private List<String> actions = new ArrayList<String>();
|
||||
|
||||
public Group(String name, int level, String color, List<String> actions) {
|
||||
public Group(String name, int level, String color, List<String> actions) {
|
||||
|
||||
this.name = name;
|
||||
this.level = level;
|
||||
this.actions = actions;
|
||||
this.name = name;
|
||||
this.level = level;
|
||||
this.actions = actions;
|
||||
|
||||
ChatColor c = ChatColor.valueOf(color);
|
||||
if (c == null) {
|
||||
AntiCheat.getPlugin().getLogger().warning("Event '" + name + "' was initialized with the color '" + color + "' which is invalid.");
|
||||
AntiCheat.getPlugin().getLogger().warning("This event will not run properly. See http://jd.bukkit.org/apidocs/org/bukkit/ChatColor.html#enum_constant_summary for a list of valid colors");
|
||||
} else {
|
||||
this.color = c;
|
||||
}
|
||||
}
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
ChatColor c = ChatColor.valueOf(color);
|
||||
if (c == null) {
|
||||
AntiCheatReloaded.getPlugin().getLogger()
|
||||
.warning("Event '" + name + "' was initialized with the color '" + color + "' which is invalid.");
|
||||
AntiCheatReloaded.getPlugin().getLogger().warning(
|
||||
"This event will not run properly. See http://jd.bukkit.org/apidocs/org/bukkit/ChatColor.html#enum_constant_summary for a list of valid colors");
|
||||
} else {
|
||||
this.color = c;
|
||||
}
|
||||
}
|
||||
|
||||
public int getLevel() {
|
||||
return level;
|
||||
}
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public ChatColor getColor() {
|
||||
return color;
|
||||
}
|
||||
public int getLevel() {
|
||||
return level;
|
||||
}
|
||||
|
||||
public List<String> getActions() {
|
||||
return actions;
|
||||
}
|
||||
public ChatColor getColor() {
|
||||
return color;
|
||||
}
|
||||
|
||||
public static Group load(String string) {
|
||||
try {
|
||||
if (string.split(" : ").length == 4) {
|
||||
String name = string.split(" : ")[0];
|
||||
int level = Integer.parseInt(string.split(" : ")[1]);
|
||||
String color = string.split(" : ")[2];
|
||||
List<String> actions = Arrays.asList(string.split(" : ")[3].split(","));
|
||||
return new Group(name, level, color, actions);
|
||||
} else {
|
||||
throw new Exception();
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
AntiCheat.getPlugin().getLogger().warning("An event was initialized with an invalid string: '" + string + "'");
|
||||
AntiCheat.getPlugin().getLogger().warning("The proper format is: 'name : threshold : color : action' such as 'High : 50 : RED : KICK'");
|
||||
AntiCheat.getPlugin().getLogger().warning("This event will NOT run. (" + ex.getMessage() + ")");
|
||||
return null;
|
||||
}
|
||||
}
|
||||
public List<String> getActions() {
|
||||
return actions;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return name + " : " + level + " : " + color.name() + " : " + Utilities.listToCommaString(actions);
|
||||
}
|
||||
public static Group load(String string) {
|
||||
try {
|
||||
if (string.split(" : ").length == 4) {
|
||||
String name = string.split(" : ")[0];
|
||||
int level = Integer.parseInt(string.split(" : ")[1]);
|
||||
String color = string.split(" : ")[2];
|
||||
List<String> actions = Arrays.asList(string.split(" : ")[3].split(","));
|
||||
return new Group(name, level, color, actions);
|
||||
} else {
|
||||
throw new Exception();
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
AntiCheatReloaded.getPlugin().getLogger()
|
||||
.warning("An event was initialized with an invalid string: '" + string + "'");
|
||||
AntiCheatReloaded.getPlugin().getLogger().warning(
|
||||
"The proper format is: 'name : threshold : color : action' such as 'High : 50 : RED : KICK'");
|
||||
AntiCheatReloaded.getPlugin().getLogger().warning("This event will NOT run. (" + ex.getMessage() + ")");
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return name + " : " + level + " : " + color.name() + " : " + Utilities.listToCommaString(actions);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,402 @@
|
||||
/*
|
||||
* ProtocolLib - Bukkit server library that allows access to the Minecraft protocol.
|
||||
* Copyright (C) 2012 Kristian S. Stangeland
|
||||
*
|
||||
* 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., 59 Temple Place, Suite 330, Boston, MA
|
||||
* 02111-1307 USA
|
||||
*/
|
||||
package com.rammelkast.anticheatreloaded.util;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Locale;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Server;
|
||||
|
||||
import com.comphenix.protocol.ProtocolLibrary;
|
||||
import com.comphenix.protocol.utility.SnapshotVersion;
|
||||
import com.google.common.base.Objects;
|
||||
import com.google.common.collect.ComparisonChain;
|
||||
import com.google.common.collect.Ordering;
|
||||
|
||||
/**
|
||||
* Determine the current Minecraft version.
|
||||
*
|
||||
* @author Kristian
|
||||
*/
|
||||
public class MinecraftVersion implements Comparable<MinecraftVersion>, Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* Regular expression used to parse version strings.
|
||||
*/
|
||||
private static final Pattern VERSION_PATTERN = Pattern.compile(".*\\(.*MC.\\s*([a-zA-z0-9\\-.]+).*");
|
||||
|
||||
/**
|
||||
* Version 1.18 - caves and cliffs part 2
|
||||
*/
|
||||
public static final MinecraftVersion CAVES_CLIFFS_2 = new MinecraftVersion("1.18");
|
||||
|
||||
/**
|
||||
* Version 1.17 - caves and cliffs part 1
|
||||
*/
|
||||
public static final MinecraftVersion CAVES_CLIFFS_1 = new MinecraftVersion("1.17");
|
||||
|
||||
/**
|
||||
* Version 1.16.2 - breaking change to the nether update
|
||||
*/
|
||||
public static final MinecraftVersion NETHER_UPDATE_2 = new MinecraftVersion("1.16.2");
|
||||
|
||||
/**
|
||||
* Version 1.16.0 - the nether update
|
||||
*/
|
||||
public static final MinecraftVersion NETHER_UPDATE = new MinecraftVersion("1.16");
|
||||
|
||||
/**
|
||||
* Version 1.15 - the bee update
|
||||
*/
|
||||
public static final MinecraftVersion BEE_UPDATE = new MinecraftVersion("1.15");
|
||||
|
||||
/**
|
||||
* Version 1.14 - village and pillage update.
|
||||
*/
|
||||
public static final MinecraftVersion VILLAGE_UPDATE = new MinecraftVersion("1.14");
|
||||
|
||||
/**
|
||||
* Version 1.13 - update aquatic.
|
||||
*/
|
||||
public static final MinecraftVersion AQUATIC_UPDATE = new MinecraftVersion("1.13");
|
||||
|
||||
/**
|
||||
* Version 1.12 - the world of color update.
|
||||
*/
|
||||
public static final MinecraftVersion COLOR_UPDATE = new MinecraftVersion("1.12");
|
||||
|
||||
/**
|
||||
* Version 1.11 - the exploration update.
|
||||
*/
|
||||
public static final MinecraftVersion EXPLORATION_UPDATE = new MinecraftVersion("1.11");
|
||||
|
||||
/**
|
||||
* Version 1.10 - the frostburn update.
|
||||
*/
|
||||
public static final MinecraftVersion FROSTBURN_UPDATE = new MinecraftVersion("1.10");
|
||||
|
||||
/**
|
||||
* Version 1.9 - the combat update.
|
||||
*/
|
||||
public static final MinecraftVersion COMBAT_UPDATE = new MinecraftVersion("1.9");
|
||||
|
||||
/**
|
||||
* Version 1.8 - the "bountiful" update.
|
||||
*/
|
||||
public static final MinecraftVersion BOUNTIFUL_UPDATE = new MinecraftVersion("1.8");
|
||||
|
||||
/**
|
||||
* Version 1.7.8 - the update that changed the skin format (and distribution - R.I.P. player disguise)
|
||||
*/
|
||||
public static final MinecraftVersion SKIN_UPDATE = new MinecraftVersion("1.7.8");
|
||||
|
||||
/**
|
||||
* Version 1.7.2 - the update that changed the world.
|
||||
*/
|
||||
public static final MinecraftVersion WORLD_UPDATE = new MinecraftVersion("1.7.2");
|
||||
|
||||
/**
|
||||
* Version 1.6.1 - the horse update.
|
||||
*/
|
||||
public static final MinecraftVersion HORSE_UPDATE = new MinecraftVersion("1.6.1");
|
||||
|
||||
/**
|
||||
* Version 1.5.0 - the redstone update.
|
||||
*/
|
||||
public static final MinecraftVersion REDSTONE_UPDATE = new MinecraftVersion("1.5.0");
|
||||
|
||||
/**
|
||||
* Version 1.4.2 - the scary update (Wither Boss).
|
||||
*/
|
||||
public static final MinecraftVersion SCARY_UPDATE = new MinecraftVersion("1.4.2");
|
||||
|
||||
private final int major;
|
||||
private final int minor;
|
||||
private final int build;
|
||||
private Boolean atLeast;
|
||||
|
||||
// The development stage
|
||||
private final String development;
|
||||
|
||||
// Snapshot?
|
||||
private final SnapshotVersion snapshot;
|
||||
|
||||
/**
|
||||
* Determine the current Minecraft version.
|
||||
* @param server - the Bukkit server that will be used to examine the MC version.
|
||||
*/
|
||||
public MinecraftVersion(Server server) {
|
||||
this(extractVersion(server.getVersion()));
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct a version object from the format major.minor.build, or the snapshot format.
|
||||
* @param versionOnly - the version in text form.
|
||||
*/
|
||||
public MinecraftVersion(String versionOnly) {
|
||||
this(versionOnly, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct a version format from the standard release version or the snapshot verison.
|
||||
* @param versionOnly - the version.
|
||||
* @param parseSnapshot - TRUE to parse the snapshot, FALSE otherwise.
|
||||
*/
|
||||
private MinecraftVersion(String versionOnly, boolean parseSnapshot) {
|
||||
String[] section = versionOnly.split("-");
|
||||
SnapshotVersion snapshot = null;
|
||||
int[] numbers = new int[3];
|
||||
|
||||
try {
|
||||
numbers = parseVersion(section[0]);
|
||||
|
||||
} catch (NumberFormatException cause) {
|
||||
// Skip snapshot parsing
|
||||
if (!parseSnapshot)
|
||||
throw cause;
|
||||
|
||||
try {
|
||||
// Determine if the snapshot is newer than the current release version
|
||||
snapshot = new SnapshotVersion(section[0]);
|
||||
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd", Locale.US);
|
||||
|
||||
MinecraftVersion latest = new MinecraftVersion(ProtocolLibrary.MAXIMUM_MINECRAFT_VERSION, false);
|
||||
boolean newer = snapshot.getSnapshotDate().compareTo(
|
||||
format.parse(ProtocolLibrary.MINECRAFT_LAST_RELEASE_DATE)) > 0;
|
||||
|
||||
numbers[0] = latest.getMajor();
|
||||
numbers[1] = latest.getMinor() + (newer ? 1 : -1);
|
||||
numbers[2] = 0;
|
||||
} catch (Exception e) {
|
||||
throw new IllegalStateException("Cannot parse " + section[0], e);
|
||||
}
|
||||
}
|
||||
|
||||
this.major = numbers[0];
|
||||
this.minor = numbers[1];
|
||||
this.build = numbers[2];
|
||||
this.development = section.length > 1 ? section[1] : (snapshot != null ? "snapshot" : null);
|
||||
this.snapshot = snapshot;
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct a version object directly.
|
||||
* @param major - major version number.
|
||||
* @param minor - minor version number.
|
||||
* @param build - build version number.
|
||||
*/
|
||||
public MinecraftVersion(int major, int minor, int build) {
|
||||
this(major, minor, build, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct a version object directly.
|
||||
* @param major - major version number.
|
||||
* @param minor - minor version number.
|
||||
* @param build - build version number.
|
||||
* @param development - development stage.
|
||||
*/
|
||||
public MinecraftVersion(int major, int minor, int build, String development) {
|
||||
this.major = major;
|
||||
this.minor = minor;
|
||||
this.build = build;
|
||||
this.development = development;
|
||||
this.snapshot = null;
|
||||
}
|
||||
|
||||
private int[] parseVersion(String version) {
|
||||
String[] elements = version.split("\\.");
|
||||
int[] numbers = new int[3];
|
||||
|
||||
// Make sure it's even a valid version
|
||||
if (elements.length < 1)
|
||||
throw new IllegalStateException("Corrupt MC version: " + version);
|
||||
|
||||
// The String 1 or 1.2 is interpreted as 1.0.0 and 1.2.0 respectively.
|
||||
for (int i = 0; i < Math.min(numbers.length, elements.length); i++)
|
||||
numbers[i] = Integer.parseInt(elements[i].trim());
|
||||
return numbers;
|
||||
}
|
||||
|
||||
/**
|
||||
* Major version number
|
||||
* @return Current major version number.
|
||||
*/
|
||||
public int getMajor() {
|
||||
return major;
|
||||
}
|
||||
|
||||
/**
|
||||
* Minor version number
|
||||
* @return Current minor version number.
|
||||
*/
|
||||
public int getMinor() {
|
||||
return minor;
|
||||
}
|
||||
|
||||
/**
|
||||
* Build version number
|
||||
* @return Current build version number.
|
||||
*/
|
||||
public int getBuild() {
|
||||
return build;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve the development stage.
|
||||
* @return Development stage, or NULL if this is a release.
|
||||
*/
|
||||
public String getDevelopmentStage() {
|
||||
return development;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve the snapshot version, or NULL if this is a release.
|
||||
* @return The snapshot version.
|
||||
*/
|
||||
public SnapshotVersion getSnapshot() {
|
||||
return snapshot;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if this version is a snapshot.
|
||||
* @return The snapshot version.
|
||||
*/
|
||||
public boolean isSnapshot() {
|
||||
return snapshot != null;
|
||||
}
|
||||
|
||||
public boolean atOrAbove() {
|
||||
if (atLeast == null) {
|
||||
atLeast = MinecraftVersion.atOrAbove(this);
|
||||
}
|
||||
|
||||
return atLeast;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve the version String (major.minor.build) only.
|
||||
* @return A normal version string.
|
||||
*/
|
||||
public String getVersion() {
|
||||
if (getDevelopmentStage() == null)
|
||||
return String.format("%s.%s.%s", getMajor(), getMinor(), getBuild());
|
||||
else
|
||||
return String.format("%s.%s.%s-%s%s", getMajor(), getMinor(), getBuild(),
|
||||
getDevelopmentStage(), isSnapshot() ? snapshot : "");
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compareTo(MinecraftVersion o) {
|
||||
if (o == null)
|
||||
return 1;
|
||||
|
||||
return ComparisonChain.start().
|
||||
compare(getMajor(), o.getMajor()).
|
||||
compare(getMinor(), o.getMinor()).
|
||||
compare(getBuild(), o.getBuild()).
|
||||
// No development String means it's a release
|
||||
compare(getDevelopmentStage(), o.getDevelopmentStage(), Ordering.natural().nullsLast()).
|
||||
compare(getSnapshot(), o.getSnapshot(), Ordering.natural().nullsFirst()).
|
||||
result();
|
||||
}
|
||||
|
||||
public boolean isAtLeast(MinecraftVersion other) {
|
||||
if (other == null)
|
||||
return false;
|
||||
|
||||
return compareTo(other) >= 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (obj == null)
|
||||
return false;
|
||||
if (obj == this)
|
||||
return true;
|
||||
|
||||
if (obj instanceof MinecraftVersion) {
|
||||
MinecraftVersion other = (MinecraftVersion) obj;
|
||||
|
||||
return getMajor() == other.getMajor() &&
|
||||
getMinor() == other.getMinor() &&
|
||||
getBuild() == other.getBuild() &&
|
||||
Objects.equal(getDevelopmentStage(), other.getDevelopmentStage());
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hashCode(getMajor(), getMinor(), getBuild());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
// Convert to a String that we can parse back again
|
||||
return String.format("(MC: %s)", getVersion());
|
||||
}
|
||||
|
||||
/**
|
||||
* Extract the Minecraft version from CraftBukkit itself.
|
||||
* @param text - the server version in text form.
|
||||
* @return The underlying MC version.
|
||||
* @throws IllegalStateException If we could not parse the version string.
|
||||
*/
|
||||
public static String extractVersion(String text) {
|
||||
Matcher version = VERSION_PATTERN.matcher(text);
|
||||
|
||||
if (version.matches() && version.group(1) != null) {
|
||||
return version.group(1);
|
||||
} else {
|
||||
throw new IllegalStateException("Cannot parse version String '" + text + "'");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse the given server version into a Minecraft version.
|
||||
* @param serverVersion - the server version.
|
||||
* @return The resulting Minecraft version.
|
||||
*/
|
||||
public static MinecraftVersion fromServerVersion(String serverVersion) {
|
||||
return new MinecraftVersion(extractVersion(serverVersion));
|
||||
}
|
||||
|
||||
private static MinecraftVersion currentVersion;
|
||||
|
||||
public static void setCurrentVersion(MinecraftVersion version) {
|
||||
currentVersion = version;
|
||||
}
|
||||
|
||||
public static MinecraftVersion getCurrentVersion() {
|
||||
if (currentVersion == null) {
|
||||
currentVersion = fromServerVersion(Bukkit.getVersion());
|
||||
}
|
||||
|
||||
return currentVersion;
|
||||
}
|
||||
|
||||
public static boolean atOrAbove(MinecraftVersion version) {
|
||||
return getCurrentVersion().isAtLeast(version);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,276 @@
|
||||
/*
|
||||
* AntiCheatReloaded for Bukkit and Spigot.
|
||||
* Copyright (c) 2012-2015 AntiCheat Team
|
||||
* Copyright (c) 2016-2022 Rammelkast
|
||||
*
|
||||
* 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 3 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, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.rammelkast.anticheatreloaded.util;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.potion.PotionEffect;
|
||||
import org.bukkit.potion.PotionEffectType;
|
||||
|
||||
import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
|
||||
|
||||
public final class MovementManager {
|
||||
|
||||
// Ticks in air
|
||||
public int airTicks = 0;
|
||||
// Ticks on ground
|
||||
public int groundTicks = 0;
|
||||
// Ticks on ice
|
||||
public int iceTicks = 0;
|
||||
// Ticks on slime
|
||||
public int slimeTicks = 0;
|
||||
// Ticks in air before last grounded moment
|
||||
public int airTicksBeforeGrounded = 0;
|
||||
// Ticks influenced by ice
|
||||
public int iceInfluenceTicks = 0;
|
||||
// Ticks influenced by slime
|
||||
public int slimeInfluenceTicks = 0;
|
||||
// Ticks influenced by soil
|
||||
public int soilInfluenceTicks = 0;
|
||||
// Y motion of the movement
|
||||
public double motionY;
|
||||
// Previous Y motion of the movement
|
||||
public double lastMotionY;
|
||||
// Horizontal distance of movement
|
||||
public double distanceXZ;
|
||||
// Horizontal distance on x-axis of movement
|
||||
public double distanceX;
|
||||
// Horizontal distance on z-axis of movement
|
||||
public double distanceZ;
|
||||
// Previous horizontal distance of movement
|
||||
public double lastDistanceXZ;
|
||||
// Previous horizontal distance on x-axis of movement
|
||||
public double lastDistanceX;
|
||||
// Previous horizontal distance on z-axis of movement
|
||||
public double lastDistanceZ;
|
||||
// Delta pitch
|
||||
public float deltaPitch;
|
||||
// Delta yaw
|
||||
public float deltaYaw;
|
||||
// Previous delta pitch
|
||||
public float lastDeltaPitch;
|
||||
// Previous delta yaw
|
||||
public float lastDeltaYaw;
|
||||
// If the player touched the ground again this tick
|
||||
public boolean touchedGroundThisTick = false;
|
||||
// Last recorded distance
|
||||
public Distance lastDistance = new Distance();
|
||||
// Movement acceleration
|
||||
public double acceleration;
|
||||
// Last movement acceleration
|
||||
public double lastAcceleration;
|
||||
// Is the block above solid
|
||||
public boolean topSolid;
|
||||
// Is the block below solid
|
||||
public boolean bottomSolid;
|
||||
// If the current movement is up a slab or stair
|
||||
public boolean halfMovement;
|
||||
// If the player is on the ground (determined clientside!)
|
||||
public boolean onGround;
|
||||
// If the player was on the ground (determined clientside!)
|
||||
public boolean wasOnGround;
|
||||
// Ticks counter for last halfMovement
|
||||
public int halfMovementHistoryCounter = 0;
|
||||
// Time of last teleport
|
||||
public long lastTeleport;
|
||||
// Elytra effect ticks
|
||||
public int elytraEffectTicks;
|
||||
// Used by Velocity check, represents the currently expected Y motion
|
||||
public double velocityExpectedMotionY;
|
||||
// Used by Velocity check, represents the currently expected XZ motion
|
||||
public double velocityExpectedMotionXZ;
|
||||
// Amount of ticks a player is sneaking
|
||||
public int sneakingTicks;
|
||||
// Ticks counter after being near a liquid
|
||||
public int nearLiquidTicks;
|
||||
// Ticks of player blocking
|
||||
public int blockingTicks;
|
||||
// If the player has a speed effect
|
||||
public boolean hasSpeedEffect = false;
|
||||
// If the player had speed effect previous tick
|
||||
public boolean hadSpeedEffect = false;
|
||||
// Riptiding ticks
|
||||
public int riptideTicks;
|
||||
// Time of last update
|
||||
public long lastUpdate;
|
||||
// Last location
|
||||
public Location lastLocation;
|
||||
|
||||
/**
|
||||
* Used by prediction speed check
|
||||
*/
|
||||
public float friction;
|
||||
public double adjusted;
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public void handle(final Player player, final Location from, final Location to, final Distance distance) {
|
||||
this.wasOnGround = this.onGround;
|
||||
this.onGround = player.isOnGround();
|
||||
|
||||
this.lastLocation = from;
|
||||
|
||||
final double x = distance.getXDifference();
|
||||
final double z = distance.getZDifference();
|
||||
this.lastDistanceXZ = this.distanceXZ;
|
||||
this.lastDistanceX = this.distanceX;
|
||||
this.lastDistanceZ = this.distanceZ;
|
||||
this.distanceXZ = Math.sqrt(x * x + z * z);
|
||||
this.distanceX = x;
|
||||
this.distanceZ = z;
|
||||
|
||||
this.lastDeltaPitch = this.deltaPitch;
|
||||
this.lastDeltaYaw = this.deltaYaw;
|
||||
this.deltaPitch = Math.abs(to.getPitch() - from.getPitch());
|
||||
this.deltaYaw = Math.abs(Utilities.computeAngleDifference(to.getYaw(), from.getYaw()));
|
||||
|
||||
// Account for standing on boat
|
||||
if (Utilities.couldBeOnBoat(player, 0.25, true) && !Utilities.isSubmersed(player)) {
|
||||
this.onGround = true;
|
||||
}
|
||||
|
||||
// Handle 1.9+ potion effects
|
||||
if (MinecraftVersion.atOrAbove(MinecraftVersion.COMBAT_UPDATE)) {
|
||||
for (PotionEffect effect : player.getActivePotionEffects()) {
|
||||
if (!VersionLib.isLevitationEffect(effect)) {
|
||||
continue;
|
||||
}
|
||||
AntiCheatReloaded.getManager().getBackend().logLevitating(player, 1);
|
||||
}
|
||||
}
|
||||
|
||||
this.touchedGroundThisTick = false;
|
||||
this.halfMovement = false;
|
||||
if (!this.onGround) {
|
||||
this.groundTicks = 0;
|
||||
this.airTicks++;
|
||||
} else {
|
||||
if (this.airTicks > 0) {
|
||||
this.touchedGroundThisTick = true;
|
||||
}
|
||||
this.airTicksBeforeGrounded = this.airTicks;
|
||||
this.airTicks = 0;
|
||||
this.groundTicks++;
|
||||
}
|
||||
|
||||
if (Utilities.couldBeOnIce(to)) {
|
||||
this.iceTicks++;
|
||||
this.iceInfluenceTicks = 60;
|
||||
} else {
|
||||
this.iceTicks = 0;
|
||||
if (this.iceInfluenceTicks > 0) {
|
||||
this.iceInfluenceTicks--;
|
||||
}
|
||||
}
|
||||
|
||||
if (Utilities.couldBeOnSlime(to)) {
|
||||
this.slimeTicks++;
|
||||
this.slimeInfluenceTicks = 40;
|
||||
} else {
|
||||
this.slimeTicks = 0;
|
||||
if (this.slimeInfluenceTicks > 0) {
|
||||
this.slimeInfluenceTicks--;
|
||||
}
|
||||
}
|
||||
|
||||
if (Utilities.couldBeOnSoil(to)) {
|
||||
this.soilInfluenceTicks = 6;
|
||||
} else {
|
||||
if (this.soilInfluenceTicks > 0) {
|
||||
this.soilInfluenceTicks--;
|
||||
}
|
||||
}
|
||||
|
||||
if (VersionLib.isGliding(player)) {
|
||||
this.elytraEffectTicks = 30;
|
||||
} else {
|
||||
if (this.elytraEffectTicks > 0) {
|
||||
this.elytraEffectTicks--;
|
||||
}
|
||||
}
|
||||
|
||||
if (player.isSneaking()) {
|
||||
this.sneakingTicks++;
|
||||
} else {
|
||||
this.sneakingTicks = 0;
|
||||
}
|
||||
|
||||
if (player.isBlocking()) {
|
||||
this.blockingTicks++;
|
||||
} else {
|
||||
this.blockingTicks = 0;
|
||||
}
|
||||
|
||||
if (Utilities.isNearWater(player)) {
|
||||
this.nearLiquidTicks = 8;
|
||||
} else {
|
||||
if (this.nearLiquidTicks > 0) {
|
||||
this.nearLiquidTicks--;
|
||||
} else {
|
||||
this.nearLiquidTicks = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (VersionLib.isRiptiding(player)) {
|
||||
this.riptideTicks = 30;
|
||||
} else {
|
||||
if (this.riptideTicks > 0) {
|
||||
this.riptideTicks--;
|
||||
} else {
|
||||
this.riptideTicks = 0;
|
||||
}
|
||||
}
|
||||
|
||||
this.hadSpeedEffect = this.hasSpeedEffect;
|
||||
this.hasSpeedEffect = player.hasPotionEffect(PotionEffectType.SPEED);
|
||||
|
||||
final double lastDistanceSq = Math.sqrt(this.lastDistance.getXDifference() * this.lastDistance.getXDifference()
|
||||
+ this.lastDistance.getZDifference() * this.lastDistance.getZDifference());
|
||||
final double currentDistanceSq = Math.sqrt(distance.getXDifference() * distance.getXDifference()
|
||||
+ distance.getZDifference() * distance.getZDifference());
|
||||
this.lastAcceleration = this.acceleration;
|
||||
this.acceleration = currentDistanceSq - lastDistanceSq;
|
||||
|
||||
this.lastMotionY = this.motionY;
|
||||
this.motionY = to.getY() - from.getY();
|
||||
|
||||
final Location top = to.clone().add(0, 2, 0);
|
||||
this.topSolid = top.getBlock().getType().isSolid();
|
||||
final Location bottom = to.clone().add(0, -1, 0);
|
||||
this.bottomSolid = bottom.getBlock().getType().isSolid();
|
||||
|
||||
if ((this.motionY >= 0.42f && this.motionY <= 0.5625f)
|
||||
&& (Utilities.couldBeOnHalfblock(to) || Utilities.isNearBed(to))) {
|
||||
this.halfMovement = true;
|
||||
this.halfMovementHistoryCounter = 30;
|
||||
} else {
|
||||
if (this.halfMovementHistoryCounter > 0) {
|
||||
this.halfMovementHistoryCounter--;
|
||||
}
|
||||
}
|
||||
|
||||
this.lastUpdate = System.currentTimeMillis();
|
||||
|
||||
final User user = AntiCheatReloaded.getManager().getUserManager().getUser(player.getUniqueId());
|
||||
// Tick velocity tracker
|
||||
user.getVelocityTracker().tick();
|
||||
// Update "good location"
|
||||
user.setGoodLocation(from);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,18 +0,0 @@
|
||||
package com.rammelkast.anticheatreloaded.util;
|
||||
|
||||
import java.util.EnumSet;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.potion.PotionEffectType;
|
||||
|
||||
public class NMS_1_9_PLUS {
|
||||
|
||||
static final EnumSet<Material> MOVE_UP_BLOCKS_1_9 = EnumSet.of(Material.ACACIA_STAIRS,
|
||||
Material.BIRCH_WOOD_STAIRS, Material.BRICK_STAIRS, Material.COBBLESTONE_STAIRS, Material.DARK_OAK_STAIRS,
|
||||
Material.JUNGLE_WOOD_STAIRS, Material.NETHER_BRICK_STAIRS, Material.QUARTZ_STAIRS,
|
||||
Material.RED_SANDSTONE_STAIRS, Material.SANDSTONE_STAIRS, Material.SMOOTH_STAIRS,
|
||||
Material.SPRUCE_WOOD_STAIRS, Material.WOOD_STAIRS, Material.PURPUR_STAIRS);
|
||||
|
||||
static final PotionEffectType LEVITATION = PotionEffectType.LEVITATION;
|
||||
|
||||
}
|
||||
@@ -1,186 +0,0 @@
|
||||
package com.rammelkast.anticheatreloaded.util;
|
||||
|
||||
import java.util.Random;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.craftbukkit.v1_11_R1.CraftServer;
|
||||
import org.bukkit.craftbukkit.v1_11_R1.CraftWorld;
|
||||
import org.bukkit.craftbukkit.v1_11_R1.entity.CraftPlayer;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||
import org.bukkit.event.player.PlayerMoveEvent;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import com.mojang.authlib.GameProfile;
|
||||
import com.rammelkast.anticheatreloaded.AntiCheat;
|
||||
|
||||
import net.minecraft.server.v1_11_R1.EntityHuman;
|
||||
import net.minecraft.server.v1_11_R1.EntityPlayer;
|
||||
import net.minecraft.server.v1_11_R1.MinecraftServer;
|
||||
import net.minecraft.server.v1_11_R1.PacketPlayOutEntityMetadata;
|
||||
import net.minecraft.server.v1_11_R1.PacketPlayOutEntityTeleport;
|
||||
import net.minecraft.server.v1_11_R1.PacketPlayOutNamedEntitySpawn;
|
||||
import net.minecraft.server.v1_11_R1.PacketPlayOutPlayerInfo;
|
||||
import net.minecraft.server.v1_11_R1.PlayerConnection;
|
||||
import net.minecraft.server.v1_11_R1.PlayerInteractManager;
|
||||
import net.minecraft.server.v1_11_R1.World;
|
||||
import net.minecraft.server.v1_11_R1.WorldServer;
|
||||
|
||||
public class NPC_1_11 {
|
||||
|
||||
private final UUID owner;
|
||||
private final String name;
|
||||
private UUID uuid;
|
||||
private EntityPlayer npc;
|
||||
private int entityId;
|
||||
private Location location;
|
||||
|
||||
public int getID() {
|
||||
return this.entityId;
|
||||
}
|
||||
|
||||
public NPC_1_11(Player owner) {
|
||||
this.owner = owner.getUniqueId();
|
||||
this.name = NameGenerator.generateName();
|
||||
Location eyelocation = owner.getEyeLocation();
|
||||
Vector vec = owner.getLocation().getDirection();
|
||||
vec.setX(-3 * vec.getX());
|
||||
vec.setZ(-3 * vec.getZ());
|
||||
Location back = eyelocation.add(vec);
|
||||
this.location = back; // TODO
|
||||
}
|
||||
|
||||
public void spawn() {
|
||||
final MinecraftServer nmsServer = ((CraftServer) Bukkit.getServer()).getServer();
|
||||
final WorldServer nmsWorld = ((CraftWorld) this.getOwner().getWorld()).getHandle();
|
||||
this.uuid = UUID.randomUUID();
|
||||
(this.npc = new EntityPlayer(nmsServer, nmsWorld, new GameProfile(this.uuid, this.name),
|
||||
new PlayerInteractManager((World) nmsWorld))).setLocation(this.location.getX(), this.location.getY(),
|
||||
this.location.getZ(), 0.0f, 0.0f);
|
||||
this.npc.collides = false;
|
||||
this.npc.setInvisible(true);
|
||||
this.entityId = this.npc.getId();
|
||||
final PlayerConnection connection = ((CraftPlayer) this.getOwner()).getHandle().playerConnection;
|
||||
connection.sendPacket(new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.ADD_PLAYER,
|
||||
new EntityPlayer[] { this.npc }));
|
||||
connection.sendPacket(new PacketPlayOutNamedEntitySpawn((EntityHuman) this.npc));
|
||||
}
|
||||
|
||||
public boolean up = true;
|
||||
|
||||
public void move(PlayerMoveEvent e) {
|
||||
if (e.getTo().getPitch() <= -32.5) {
|
||||
if (e.getTo().getPitch() <= -82.5) {
|
||||
Location eyelocation = e.getPlayer().getEyeLocation();
|
||||
Vector vec = e.getPlayer().getLocation().getDirection();
|
||||
vec.setX(-3 * vec.getX());
|
||||
vec.setY(e.getPlayer().getLocation().getY() - 8.25);
|
||||
vec.setZ(-3 * vec.getZ());
|
||||
Location back = eyelocation.add(vec);
|
||||
this.location = back; // TODO
|
||||
this.npc.setPositionRotation(back.getX(), back.getY(), back.getZ(), (float)new Random().nextFloat() * 20, (float)new Random().nextFloat() * 20);
|
||||
((CraftPlayer) this.getOwner()).getHandle().playerConnection.sendPacket(new PacketPlayOutEntityTeleport(npc));
|
||||
if (new Random().nextInt(50) == 25 && this.npc.isInvisible()) {
|
||||
this.npc.setInvisible(false);
|
||||
((CraftPlayer) this.getOwner()).getHandle().playerConnection.sendPacket(new PacketPlayOutEntityMetadata(entityId, npc.getDataWatcher(), false));
|
||||
new BukkitRunnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
npc.setInvisible(true);
|
||||
((CraftPlayer) getOwner()).getHandle().playerConnection.sendPacket(new PacketPlayOutEntityMetadata(entityId, npc.getDataWatcher(), false));
|
||||
}
|
||||
}.runTaskLater(AntiCheat.getPlugin(), 4);
|
||||
}
|
||||
}else {
|
||||
Location eyelocation = e.getPlayer().getEyeLocation();
|
||||
Vector vec = e.getPlayer().getLocation().getDirection();
|
||||
vec.setX(-3 * vec.getX());
|
||||
vec.setY(e.getPlayer().getLocation().getY());
|
||||
vec.setZ(-3 * vec.getZ());
|
||||
Location back = eyelocation.add(vec);
|
||||
this.location = back; // TODO
|
||||
this.npc.setPositionRotation(back.getX(), back.getY(), back.getZ(), (float)new Random().nextFloat() * 20, (float)new Random().nextFloat() * 20);
|
||||
((CraftPlayer) this.getOwner()).getHandle().playerConnection.sendPacket(new PacketPlayOutEntityTeleport(npc));
|
||||
}
|
||||
} else if (e.getTo().getPitch() >= 22) {
|
||||
Location eyelocation = e.getPlayer().getEyeLocation();
|
||||
Vector vec = e.getPlayer().getLocation().getDirection();
|
||||
vec.setX(-3 * vec.getX());
|
||||
vec.setY(e.getPlayer().getLocation().getY() - 0.4);
|
||||
vec.setZ(-3 * vec.getZ());
|
||||
Location back = eyelocation.add(vec);
|
||||
this.location = back; // TODO
|
||||
this.npc.setPositionRotation(back.getX(), back.getY(), back.getZ(), (float)new Random().nextFloat() * 20, (float)new Random().nextFloat() * 20);
|
||||
((CraftPlayer) this.getOwner()).getHandle().playerConnection.sendPacket(new PacketPlayOutEntityTeleport(npc));
|
||||
} else {
|
||||
Location eyelocation = e.getPlayer().getEyeLocation();
|
||||
Vector vec = e.getPlayer().getLocation().getDirection();
|
||||
vec.setX(-1.95 * vec.getX());
|
||||
if (up)
|
||||
vec.setY(vec.getY() + 0.5);
|
||||
else
|
||||
vec.setY(vec.getY() - 0.25);
|
||||
if (new Random().nextInt(10) == 5)
|
||||
up = !up;
|
||||
vec.setZ(-1.95 * vec.getZ());
|
||||
Location back = eyelocation.add(vec);
|
||||
this.location = back; // TODO
|
||||
this.npc.setPositionRotation(back.getX(), back.getY(), back.getZ(), (float)new Random().nextFloat() * 20, (float)new Random().nextFloat() * 20);
|
||||
((CraftPlayer) this.getOwner()).getHandle().playerConnection
|
||||
.sendPacket(new PacketPlayOutEntityTeleport(npc));
|
||||
if (new Random().nextInt(1000) == 500 && this.npc.isInvisible()) {
|
||||
this.npc.setInvisible(false);
|
||||
((CraftPlayer) this.getOwner()).getHandle().playerConnection.sendPacket(new PacketPlayOutEntityMetadata(entityId, npc.getDataWatcher(), false));
|
||||
new BukkitRunnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
npc.setInvisible(true);
|
||||
((CraftPlayer) getOwner()).getHandle().playerConnection.sendPacket(new PacketPlayOutEntityMetadata(entityId, npc.getDataWatcher(), false));
|
||||
}
|
||||
}.runTaskLater(AntiCheat.getPlugin(), 6);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public Player getOwner() {
|
||||
return Bukkit.getPlayer(owner);
|
||||
}
|
||||
|
||||
public void damage(EntityDamageByEntityEvent e, Player p) {
|
||||
if (p != getOwner() || this.npc == null) {
|
||||
return;
|
||||
}
|
||||
if (new Random().nextBoolean() && this.npc.isInvisible()) {
|
||||
this.npc.setInvisible(false);
|
||||
((CraftPlayer) this.getOwner()).getHandle().playerConnection.sendPacket(new PacketPlayOutEntityMetadata(entityId, npc.getDataWatcher(), false));
|
||||
new BukkitRunnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
npc.setInvisible(true);
|
||||
((CraftPlayer) getOwner()).getHandle().playerConnection.sendPacket(new PacketPlayOutEntityMetadata(entityId, npc.getDataWatcher(), false));
|
||||
}
|
||||
}.runTaskLater(AntiCheat.getPlugin(), 6 + new Random().nextInt(7));
|
||||
}
|
||||
}
|
||||
|
||||
public void damage() {
|
||||
if (this.npc == null || this.getOwner() == null) {
|
||||
return;
|
||||
}
|
||||
if (new Random().nextBoolean() && this.npc.isInvisible()) {
|
||||
this.npc.setInvisible(false);
|
||||
((CraftPlayer) this.getOwner()).getHandle().playerConnection.sendPacket(new PacketPlayOutEntityMetadata(entityId, npc.getDataWatcher(), false));
|
||||
new BukkitRunnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
npc.setInvisible(true);
|
||||
((CraftPlayer) getOwner()).getHandle().playerConnection.sendPacket(new PacketPlayOutEntityMetadata(entityId, npc.getDataWatcher(), false));
|
||||
}
|
||||
}.runTaskLater(AntiCheat.getPlugin(), 6 + new Random().nextInt(8));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,45 +0,0 @@
|
||||
package com.rammelkast.anticheatreloaded.util;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
public class NameGenerator {
|
||||
|
||||
private static final List<String> BEGIN = Arrays.asList(new String[]{
|
||||
"Pixel",
|
||||
"Pro",
|
||||
"NoHax",
|
||||
"Just",
|
||||
"That",
|
||||
"New",
|
||||
"Ultra",
|
||||
"Killer",
|
||||
"Swift"
|
||||
});
|
||||
|
||||
private static final List<String> END = Arrays.asList(new String[]{
|
||||
"Gamer",
|
||||
"PvP",
|
||||
"JustYolo",
|
||||
"Gaming",
|
||||
"Minecraft",
|
||||
"Games",
|
||||
"Bawz",
|
||||
"1",
|
||||
"51",
|
||||
"99",
|
||||
"" + new Random().nextInt(100)
|
||||
});
|
||||
|
||||
public static String generateName() {
|
||||
Random r = new Random();
|
||||
String begin = BEGIN.get(r.nextInt(BEGIN.size() - 1));
|
||||
String end = END.get(r.nextInt(END.size() - 1));
|
||||
if (r.nextBoolean())
|
||||
return begin + end + r.nextInt(9);
|
||||
else
|
||||
return begin + end;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,37 +0,0 @@
|
||||
package com.rammelkast.anticheatreloaded.util;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
public class NameUtil {
|
||||
|
||||
private static String[] firstParts = new String[] {
|
||||
"Gamer",
|
||||
"Pixel",
|
||||
"Derp",
|
||||
"Random",
|
||||
"That",
|
||||
"NoHaxJust",
|
||||
"Derp",
|
||||
"Fun",
|
||||
"Luigi"
|
||||
};
|
||||
|
||||
private static String[] secondParts = new String[] {
|
||||
"01",
|
||||
"Boy",
|
||||
"Guy",
|
||||
"Mario",
|
||||
"Plain",
|
||||
"Simple",
|
||||
"NotHacking",
|
||||
"Random",
|
||||
"11",
|
||||
"06"
|
||||
};
|
||||
|
||||
private static Random theRandom = new Random();
|
||||
|
||||
public static String getRandomName() {
|
||||
return firstParts[theRandom.nextInt(firstParts.length - 1)] + secondParts[theRandom.nextInt(secondParts.length - 1)];
|
||||
}
|
||||
}
|
||||
@@ -1,228 +0,0 @@
|
||||
/*
|
||||
* AntiCheat for Bukkit.
|
||||
* Copyright (C) 2012-2014 AntiCheat Team | http://gravitydevelopment.net
|
||||
*
|
||||
* 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 3 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, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.rammelkast.anticheatreloaded.util;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.rammelkast.anticheatreloaded.AntiCheat;
|
||||
import com.rammelkast.anticheatreloaded.config.Configuration;
|
||||
import com.rammelkast.anticheatreloaded.config.providers.Magic;
|
||||
|
||||
import java.io.*;
|
||||
import java.lang.reflect.Field;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.URL;
|
||||
import java.net.URLEncoder;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
public class PastebinReport {
|
||||
private static final String DATE = new SimpleDateFormat("yyyy-MM-dd kk:mm Z").format(new Date());
|
||||
private static final String API_KEY = "d5ac92da966edb97a97860e6a052784f";
|
||||
|
||||
private StringBuilder report = new StringBuilder();
|
||||
private String url = "";
|
||||
|
||||
public PastebinReport(CommandSender cs) {
|
||||
Player player = null;
|
||||
if (cs instanceof Player) {
|
||||
player = (Player) cs;
|
||||
}
|
||||
createReport(player);
|
||||
try {
|
||||
writeReport();
|
||||
} catch (IOException e) {
|
||||
}
|
||||
postReport();
|
||||
}
|
||||
|
||||
public PastebinReport(CommandSender cs, Player tp) {
|
||||
createReport(tp);
|
||||
try {
|
||||
writeReport();
|
||||
} catch (IOException e) {
|
||||
}
|
||||
postReport();
|
||||
}
|
||||
|
||||
public String getURL() {
|
||||
return url;
|
||||
}
|
||||
|
||||
private void appendPermissionsTester(Player player) {
|
||||
if (player == null) {
|
||||
append("No player defined.");
|
||||
return;
|
||||
}
|
||||
|
||||
for (Permission node : Permission.values()) {
|
||||
report.append(player.getName() + ": " + node.toString() + " " + node.get(player));
|
||||
if (node.get(player) && !node.whichPermission(player).equals(node.toString())) {
|
||||
report.append(" (Applied by " + node.whichPermission(player) + ")");
|
||||
}
|
||||
report.append('\n');
|
||||
}
|
||||
}
|
||||
|
||||
private void createReport(Player player) {
|
||||
if (Bukkit.getPluginManager().getPlugin("NoCheatPlus") != null) {
|
||||
append("------------ WARNING! ------------");
|
||||
append("This report was run with NoCheatPlus enabled. Results may be inaccurate." + '\n');
|
||||
}
|
||||
append("------------ AntiCheat Report - " + DATE + " ------------");
|
||||
appendSystemInfo();
|
||||
append("------------Last 30 logs------------");
|
||||
appendLogs();
|
||||
append("------------Permission Tester------------");
|
||||
appendPermissionsTester(player);
|
||||
append("------------Event Chains------------");
|
||||
appendEventHandlers();
|
||||
append("------------Magic Diff------------");
|
||||
appendMagicDiff();
|
||||
append("-----------End Of Report------------");
|
||||
}
|
||||
|
||||
private void appendLogs() {
|
||||
List<String> logs = AntiCheat.getManager().getLoggingManager().getLastLogs();
|
||||
if (logs.size() == 0) {
|
||||
append("No recent logs.");
|
||||
return;
|
||||
}
|
||||
for (String log : logs) {
|
||||
append(log);
|
||||
}
|
||||
}
|
||||
|
||||
private void appendSystemInfo() {
|
||||
Runtime runtime = Runtime.getRuntime();
|
||||
Configuration config = AntiCheat.getManager().getConfiguration();
|
||||
append("AntiCheat Version: " + AntiCheat.getVersion());
|
||||
append("Server Version: " + Bukkit.getVersion());
|
||||
append("Server Implementation: " + Bukkit.getName());
|
||||
append("Server ID: " + Bukkit.getServerId());
|
||||
append("NMS Version: " + VersionUtil.getVersion());
|
||||
append("Java Version: " + System.getProperty("java.vendor") + " " + System.getProperty("java.version"));
|
||||
append("OS: " + System.getProperty("os.name") + " " + System.getProperty("os.version"));
|
||||
append("Free Memory: " + runtime.freeMemory() / 1024 / 1024 + "MB");
|
||||
append("Max Memory: " + runtime.maxMemory() / 1024 / 1024 + "MB");
|
||||
append("Total Memory: " + runtime.totalMemory() / 1024 / 1024 + "MB");
|
||||
append("Online Mode: " + Bukkit.getOnlineMode());
|
||||
append("Players: " + Bukkit.getOnlinePlayers().size() + "/" + Bukkit.getMaxPlayers());
|
||||
append("Plugin Count: " + Bukkit.getPluginManager().getPlugins().length);
|
||||
append("Plugin Uptime: " + ((System.currentTimeMillis() - AntiCheat.getPlugin().getLoadTime()) / 1000) / 60 + " minutes");
|
||||
append("Enterprise: " + config.getConfig().enterprise.getValue());
|
||||
if (config.getConfig().enterprise.getValue()) {
|
||||
append("- Server name: " + config.getEnterprise().serverName.getValue());
|
||||
append("- Database type: " + config.getEnterprise().database.getType());
|
||||
append("- Groups source: " + (config.getEnterprise().configGroups.getValue() ? "Database" : "Flatfile"));
|
||||
append("- Rules source: " + (config.getEnterprise().configRules.getValue() ? "Database" : "Flatfile"));
|
||||
append("- Levels source: " + (config.getEnterprise().syncLevels.getValue() ? "Database" : "Flatfile"));
|
||||
}
|
||||
}
|
||||
|
||||
private void appendMagicDiff() {
|
||||
// This is hacky, and I like it
|
||||
Magic magic = AntiCheat.getManager().getConfiguration().getMagic();
|
||||
FileConfiguration file = YamlConfiguration.loadConfiguration(new File(AntiCheat.getPlugin().getDataFolder(), "magic.yml"));
|
||||
boolean changed = false;
|
||||
for (Field field : Magic.class.getFields()) {
|
||||
Object defaultValue = file.get(field.getName());
|
||||
try {
|
||||
Field value = magic.getClass().getDeclaredField(field.getName());
|
||||
String s1 = value.get(magic).toString();
|
||||
String s2 = defaultValue.toString();
|
||||
if (!s1.equals(s2) && !s1.equals(s2 + ".0")) {
|
||||
changed = true;
|
||||
append(field.getName() + ": " + s1 + " (Default: " + s2 + ")");
|
||||
} else {
|
||||
}
|
||||
} catch (NoSuchFieldException ex) {
|
||||
|
||||
} catch (IllegalAccessException ex) {
|
||||
|
||||
}
|
||||
}
|
||||
if (!changed) {
|
||||
append("No changes from default.");
|
||||
}
|
||||
}
|
||||
|
||||
private void appendEventHandlers() {
|
||||
report.append(AntiCheat.getManager().getEventChainReport());
|
||||
}
|
||||
|
||||
private void writeReport() throws IOException {
|
||||
File f = new File(AntiCheat.getPlugin().getDataFolder() + "/report.txt");
|
||||
FileWriter r = new FileWriter(f);
|
||||
BufferedWriter writer = new BufferedWriter(r);
|
||||
writer.write(report.toString());
|
||||
writer.close();
|
||||
}
|
||||
|
||||
private void postReport() {
|
||||
try {
|
||||
URL urls = new URL("http://pastebin.com/api/api_post.php");
|
||||
HttpURLConnection conn = (HttpURLConnection) urls.openConnection();
|
||||
conn.setConnectTimeout(5000);
|
||||
conn.setReadTimeout(5000);
|
||||
conn.setRequestMethod("POST");
|
||||
conn.addRequestProperty("Content-type", "application/x-www-form-urlencoded");
|
||||
conn.setInstanceFollowRedirects(false);
|
||||
conn.setDoOutput(true);
|
||||
OutputStream out = conn.getOutputStream();
|
||||
|
||||
out.write(("api_option=paste" + "&api_dev_key=" + URLEncoder.encode(API_KEY, "utf-8") + "&api_paste_code=" + URLEncoder.encode(report.toString(), "utf-8") + "&api_paste_private=" + URLEncoder.encode("1", "utf-8") + "&api_paste_name=" + URLEncoder.encode("", "utf-8") + "&api_paste_expire_date=" + URLEncoder.encode("1M", "utf-8") + "&api_paste_format=" + URLEncoder.encode("text", "utf-8") + "&api_user_key=" + URLEncoder.encode("", "utf-8")).getBytes());
|
||||
out.flush();
|
||||
out.close();
|
||||
|
||||
if (conn.getResponseCode() == 200) {
|
||||
InputStream receive = conn.getInputStream();
|
||||
BufferedReader reader = new BufferedReader(new InputStreamReader(receive));
|
||||
String line;
|
||||
StringBuffer response = new StringBuffer();
|
||||
while ((line = reader.readLine()) != null) {
|
||||
response.append(line);
|
||||
response.append("\r\n");
|
||||
}
|
||||
reader.close();
|
||||
|
||||
String result = response.toString().trim();
|
||||
|
||||
if (!result.contains("http://")) {
|
||||
url = "Failed to post. Check report.txt";
|
||||
} else {
|
||||
url = result.trim();
|
||||
}
|
||||
} else {
|
||||
url = "Failed to post. Check report.txt";
|
||||
}
|
||||
} catch (Exception e) {
|
||||
url = "Failed to post. Check report.txt";
|
||||
}
|
||||
}
|
||||
|
||||
private void append(String s) {
|
||||
report.append(s + '\n');
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
/*
|
||||
* AntiCheat for Bukkit.
|
||||
* Copyright (C) 2012-2014 AntiCheat Team | http://gravitydevelopment.net
|
||||
* AntiCheatReloaded for Bukkit and Spigot.
|
||||
* Copyright (c) 2012-2015 AntiCheat Team
|
||||
* Copyright (c) 2016-2022 Rammelkast
|
||||
*
|
||||
* 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
|
||||
@@ -21,77 +22,47 @@ package com.rammelkast.anticheatreloaded.util;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
public enum Permission {
|
||||
/* Check Nodes */
|
||||
CHECK_ZOMBE_FLY,
|
||||
CHECK_ZOMBE_NOCLIP,
|
||||
CHECK_ZOMBE_CHEAT,
|
||||
CHECK_FLY,
|
||||
CHECK_WATERWALK,
|
||||
CHECK_NOSWING,
|
||||
CHECK_FASTBREAK,
|
||||
CHECK_FASTPLACE,
|
||||
CHECK_CHATSPAM,
|
||||
CHECK_COMMANDSPAM,
|
||||
CHECK_SPRINT,
|
||||
CHECK_SNEAK,
|
||||
CHECK_SPEED,
|
||||
CHECK_VCLIP,
|
||||
CHECK_SPIDER,
|
||||
CHECK_NOFALL,
|
||||
CHECK_FASTBOW,
|
||||
CHECK_FASTEAT,
|
||||
CHECK_FASTHEAL,
|
||||
CHECK_FORCEFIELD,
|
||||
CHECK_LONGREACH,
|
||||
CHECK_FASTPROJECTILE,
|
||||
CHECK_ITEMSPAM,
|
||||
CHECK_VISUAL,
|
||||
CHECK_FASTINVENTORY,
|
||||
CHECK_AUTOTOOL,
|
||||
/* Check Nodes */
|
||||
CHECK_FLIGHT, CHECK_ELYTRAFLY, CHECK_WATERWALK, CHECK_FASTPLACE, CHECK_CHATSPAM, CHECK_COMMANDSPAM, CHECK_SPRINT,
|
||||
CHECK_SNEAK, CHECK_SPEED, CHECK_VCLIP, CHECK_SPIDER, CHECK_NOFALL, CHECK_FASTBOW, CHECK_FASTEAT, CHECK_FASTHEAL,
|
||||
CHECK_KILLAURA, CHECK_UNICODE, CHECK_FASTPROJECTILE, CHECK_ITEMSPAM, CHECK_FASTINVENTORY,
|
||||
CHECK_MOREPACKETS, CHECK_BADPACKETS, CHECK_VELOCITY, CHECK_CRITICALS, CHECK_ILLEGALINTERACT, CHECK_FASTLADDER,
|
||||
CHECK_AIMBOT, CHECK_STRAFE, CHECK_NOSLOW, CHECK_BOATFLY,
|
||||
|
||||
/* System Nodes */
|
||||
SYSTEM_LOG,
|
||||
SYSTEM_RESET,
|
||||
SYSTEM_SPY,
|
||||
SYSTEM_HELP,
|
||||
SYSTEM_UPDATE,
|
||||
SYSTEM_REPORT,
|
||||
SYSTEM_ALERT,
|
||||
SYSTEM_NOTICE,
|
||||
SYSTEM_CALIBRATE,
|
||||
SYSTEM_CHECK,
|
||||
SYSTEM_DEBUG,
|
||||
SYSTEM_RELOAD, CHECK_KILLAURA, CHECK_BLINK, VELOCITY, CRITICALS;
|
||||
/* System Nodes */
|
||||
SYSTEM_LOG, SYSTEM_RESET, SYSTEM_HELP, SYSTEM_VERSION, SYSTEM_REPORT, SYSTEM_NOTICE, SYSTEM_CHECK, SYSTEM_RELOAD,
|
||||
SYSTEM_MUTE;
|
||||
|
||||
private static final String PERMISSION_ALL = "anticheat.*";
|
||||
private static final String PERMISSION_SPAM = "anticheat.check.spam";
|
||||
private static final String PERMISSION_ALL = "anticheat.*";
|
||||
private static final String PERMISSION_SPAM = "anticheat.check.spam";
|
||||
|
||||
public static boolean getCommandExempt(CommandSender cs, String commandLabel) {
|
||||
// Check permission, base, and all will have already been checked
|
||||
return cs.hasPermission(CHECK_COMMANDSPAM.toString() + commandLabel);
|
||||
}
|
||||
public static boolean getCommandExempt(CommandSender cs, String commandLabel) {
|
||||
// Check permission, base, and all will have already been checked
|
||||
return cs.hasPermission(CHECK_COMMANDSPAM.toString() + commandLabel);
|
||||
}
|
||||
|
||||
public boolean get(CommandSender cs) {
|
||||
if ((this == CHECK_CHATSPAM || this == CHECK_COMMANDSPAM) && cs.hasPermission(PERMISSION_SPAM)) return true;
|
||||
return cs.hasPermission(toString()) || cs.hasPermission(getBase()) || cs.hasPermission(PERMISSION_ALL);
|
||||
}
|
||||
public boolean get(CommandSender cs) {
|
||||
if ((this == CHECK_CHATSPAM || this == CHECK_COMMANDSPAM) && cs.hasPermission(PERMISSION_SPAM))
|
||||
return true;
|
||||
return cs.hasPermission(toString()) || cs.hasPermission(getBase()) || cs.hasPermission(PERMISSION_ALL);
|
||||
}
|
||||
|
||||
public String getBase() {
|
||||
return "anticheat." + this.name().toLowerCase().split("_")[0] + ".*";
|
||||
}
|
||||
public String getBase() {
|
||||
return "anticheat." + this.name().toLowerCase().split("_")[0] + ".*";
|
||||
}
|
||||
|
||||
public String whichPermission(CommandSender cs) {
|
||||
for (String s : new String[]{PERMISSION_ALL, getBase(), toString()}) {
|
||||
if (cs.hasPermission(s)) {
|
||||
return s;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
public String whichPermission(CommandSender cs) {
|
||||
for (String s : new String[] { PERMISSION_ALL, getBase(), toString() }) {
|
||||
if (cs.hasPermission(s)) {
|
||||
return s;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "anticheat." + this.name().toLowerCase().replace("_", ".");
|
||||
}
|
||||
@Override
|
||||
public String toString() {
|
||||
return "anticheat." + this.name().toLowerCase().replace("_", ".");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,48 +0,0 @@
|
||||
/*
|
||||
* AntiCheat for Bukkit.
|
||||
* Copyright (C) 2012-2014 AntiCheat Team | http://gravitydevelopment.net
|
||||
*
|
||||
* 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 3 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, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.rammelkast.anticheatreloaded.util;
|
||||
|
||||
import org.bukkit.Material;
|
||||
|
||||
public enum ToolHardness {
|
||||
|
||||
// NOTHING(null, 1.5)
|
||||
WOOD(0.75D),
|
||||
STONE(0.40D),
|
||||
IRON(0.25D),
|
||||
DIAMOND(0.20D),
|
||||
SHEARS(0.55D),
|
||||
GOLD(0.15D);
|
||||
|
||||
double hardness;
|
||||
|
||||
ToolHardness(double hard) {
|
||||
hardness = hard;
|
||||
}
|
||||
|
||||
public static double getToolHardness(Material tool) {
|
||||
for (ToolHardness e : ToolHardness.values()) {
|
||||
if (tool.name().contains(e.name())) {
|
||||
return e.hardness;
|
||||
}
|
||||
}
|
||||
|
||||
return 1.50D;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,176 @@
|
||||
/*
|
||||
* AntiCheatReloaded for Bukkit and Spigot.
|
||||
* Copyright (c) 2012-2015 AntiCheat Team
|
||||
* Copyright (c) 2016-2022 Rammelkast
|
||||
*
|
||||
* 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 3 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, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.rammelkast.anticheatreloaded.util;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.net.URL;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
|
||||
import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
|
||||
|
||||
public class UpdateManager {
|
||||
|
||||
public static final int RESOURCE_ID = 23799;
|
||||
public static final String SPIGOT_VERSION_URL = "https://api.spigotmc.org/legacy/update.php?resource="
|
||||
+ RESOURCE_ID;
|
||||
|
||||
private String latestVersion;
|
||||
private boolean isLatest;
|
||||
private boolean isAhead;
|
||||
|
||||
public UpdateManager() {
|
||||
update();
|
||||
}
|
||||
|
||||
public void update() {
|
||||
this.latestVersion = getOnlineData(SPIGOT_VERSION_URL);
|
||||
if (this.latestVersion == null) {
|
||||
this.isLatest = true;
|
||||
this.isAhead = false;
|
||||
return;
|
||||
}
|
||||
|
||||
int splitCompare = 0;
|
||||
try {
|
||||
VersionSplit currentSplit = new VersionSplit(AntiCheatReloaded.getVersion());
|
||||
VersionSplit newSplit = new VersionSplit(this.latestVersion);
|
||||
splitCompare = currentSplit.compareTo(newSplit);
|
||||
} catch (Exception e) {}
|
||||
this.isLatest = splitCompare >= 0;
|
||||
this.isAhead = splitCompare > 0;
|
||||
}
|
||||
|
||||
private String getOnlineData(final String url) {
|
||||
String data = null;
|
||||
InputStream stream = null;
|
||||
try {
|
||||
stream = new URL(url).openStream();
|
||||
final BufferedReader reader = new BufferedReader(new InputStreamReader(stream, StandardCharsets.UTF_8));
|
||||
final StringBuilder builder = new StringBuilder();
|
||||
int readChar;
|
||||
while ((readChar = reader.read()) != -1) {
|
||||
builder.append((char) readChar);
|
||||
}
|
||||
data = builder.toString();
|
||||
reader.close();
|
||||
} catch (final IOException exception) {}
|
||||
finally {
|
||||
if (stream != null) {
|
||||
try {
|
||||
stream.close();
|
||||
} catch (final IOException e) {}
|
||||
}
|
||||
}
|
||||
return data;
|
||||
}
|
||||
|
||||
public boolean isLatest() {
|
||||
return this.isLatest;
|
||||
}
|
||||
|
||||
public boolean isAhead() {
|
||||
return this.isAhead;
|
||||
}
|
||||
|
||||
public String getCurrentVersion() {
|
||||
return AntiCheatReloaded.getVersion();
|
||||
}
|
||||
|
||||
public String getLatestVersion() {
|
||||
return this.latestVersion;
|
||||
}
|
||||
|
||||
public class VersionSplit implements Comparable<VersionSplit> {
|
||||
private final int major, minor, build;
|
||||
private boolean prerelease = false;
|
||||
|
||||
public VersionSplit(String version) throws Exception {
|
||||
if (version.endsWith("-ALPHA")) {
|
||||
version = version.substring(0, version.length() - 6);
|
||||
} else if (version.endsWith("-PRE")) {
|
||||
this.prerelease = true;
|
||||
version = version.substring(0, version.length() - 4);
|
||||
}
|
||||
|
||||
final String[] versionSplit = version.split("\\.");
|
||||
if (versionSplit.length != 3) {
|
||||
// Illegal version
|
||||
throw new Exception("Version " + version + " is illegal!");
|
||||
}
|
||||
|
||||
try {
|
||||
final int major = Integer.parseInt(versionSplit[0]);
|
||||
final int minor = Integer.parseInt(versionSplit[1]);
|
||||
final int build = Integer.parseInt(versionSplit[2]);
|
||||
if (major <= 0) {
|
||||
throw new Exception("Illegal version!");
|
||||
}
|
||||
|
||||
this.major = major;
|
||||
this.minor = minor;
|
||||
this.build = build;
|
||||
} catch (Exception e) {
|
||||
throw new Exception("Illegal version!");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compareTo(final VersionSplit other) {
|
||||
if (other.major == this.major) {
|
||||
if (other.minor == this.minor) {
|
||||
if (other.build == this.build) {
|
||||
if (!this.prerelease) {
|
||||
return 0;
|
||||
} else {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
if (other.build > this.build) {
|
||||
return -1;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
if (other.minor > this.minor) {
|
||||
return -1;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
if (other.major > this.major) {
|
||||
return -1;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
public int getMajor() {
|
||||
return major;
|
||||
}
|
||||
|
||||
public int getMinor() {
|
||||
return minor;
|
||||
}
|
||||
|
||||
public int getBuild() {
|
||||
return build;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
/*
|
||||
* AntiCheat for Bukkit.
|
||||
* Copyright (C) 2012-2014 AntiCheat Team | http://gravitydevelopment.net
|
||||
* AntiCheatReloaded for Bukkit and Spigot.
|
||||
* Copyright (c) 2012-2015 AntiCheat Team
|
||||
* Copyright (c) 2016-2022 Rammelkast
|
||||
*
|
||||
* 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
|
||||
@@ -18,414 +19,412 @@
|
||||
|
||||
package com.rammelkast.anticheatreloaded.util;
|
||||
|
||||
import java.sql.Timestamp;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import com.rammelkast.anticheatreloaded.AntiCheat;
|
||||
import com.rammelkast.anticheatreloaded.AntiCheatReloaded;
|
||||
import com.rammelkast.anticheatreloaded.check.CheckType;
|
||||
import com.rammelkast.anticheatreloaded.config.Configuration;
|
||||
import com.rammelkast.anticheatreloaded.util.rule.Rule;
|
||||
|
||||
import java.sql.Timestamp;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import lombok.Getter;
|
||||
|
||||
public class User {
|
||||
private final UUID uuid;
|
||||
private final String name;
|
||||
private final int id;
|
||||
private int level = 0;
|
||||
private Location goodLocation;
|
||||
private List<ItemStack> inventorySnapshot = null;
|
||||
private Configuration config = AntiCheat.getManager().getConfiguration();
|
||||
private int toX, toY, toZ;
|
||||
private String[] messages = new String[2];
|
||||
private Long[] messageTimes = new Long[2];
|
||||
private String[] commands = new String[2];
|
||||
private Long[] commandTimes = new Long[2];
|
||||
public final class User {
|
||||
private final UUID uuid;
|
||||
private final String name;
|
||||
private final int id;
|
||||
private int level = 0;
|
||||
private Location goodLocation;
|
||||
private Configuration config = AntiCheatReloaded.getManager().getConfiguration();
|
||||
private int toX, toY, toZ;
|
||||
private String[] messages = new String[2];
|
||||
private Long[] messageTimes = new Long[2];
|
||||
private String[] commands = new String[2];
|
||||
private Long[] commandTimes = new Long[2];
|
||||
|
||||
private boolean isWaitingOnLevelSync;
|
||||
private Timestamp levelSyncTimestamp;
|
||||
private boolean isWaitingOnLevelSync;
|
||||
private Timestamp levelSyncTimestamp;
|
||||
|
||||
/**
|
||||
* Initialize an AntiCheat user
|
||||
*
|
||||
* @param uuid Player's UUID
|
||||
*/
|
||||
public User(UUID uuid) {
|
||||
this.uuid = uuid;
|
||||
this.name = getPlayer() != null && getPlayer().isOnline() ? getPlayer().getName() : "";
|
||||
this.id = getPlayer() != null && getPlayer().isOnline() ? getPlayer().getEntityId() : -1;
|
||||
}
|
||||
private int ping = -1;
|
||||
private int lastPing = -1;
|
||||
|
||||
/**
|
||||
* Initialize an AntiCheat user
|
||||
*
|
||||
* @param name Player's name
|
||||
*/
|
||||
/* public User(String name) {
|
||||
this.uuid = Bukkit.getPlayer(name).getUniqueId();
|
||||
this.name = name;
|
||||
this.id = getPlayer() != null && getPlayer().isOnline() ? getPlayer().getEntityId() : -1;
|
||||
}
|
||||
*/
|
||||
/**
|
||||
* Get the player's UUID
|
||||
*
|
||||
* @return Player UUID
|
||||
*/
|
||||
public UUID getUUID() {
|
||||
return uuid;
|
||||
}
|
||||
@Getter
|
||||
private final MovementManager movementManager;
|
||||
@Getter
|
||||
private final VelocityTracker velocityTracker;
|
||||
|
||||
/**
|
||||
* Get the player's name
|
||||
*
|
||||
* @return Player name
|
||||
*/
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
/**
|
||||
* Initialize an AntiCheat user
|
||||
*
|
||||
* @param uuid Player's UUID
|
||||
*/
|
||||
public User(final UUID uuid) {
|
||||
this.uuid = uuid;
|
||||
this.name = getPlayer() != null && getPlayer().isOnline() ? getPlayer().getName() : "";
|
||||
this.id = getPlayer() != null && getPlayer().isOnline() ? getPlayer().getEntityId() : -1;
|
||||
this.ping = getPlayer() != null && getPlayer().isOnline() ? VersionLib.getPlayerPing(getPlayer()) : -1;
|
||||
|
||||
this.movementManager = new MovementManager();
|
||||
this.velocityTracker = new VelocityTracker(this.config.getMagic().VELOCITY_TIME());
|
||||
|
||||
setIsWaitingOnLevelSync(true);
|
||||
config.getLevels().loadLevelToUser(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the player's entity ID
|
||||
*
|
||||
* @return Entity id
|
||||
*/
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
/**
|
||||
* Get the player's UUID
|
||||
*
|
||||
* @return Player UUID
|
||||
*/
|
||||
public UUID getUUID() {
|
||||
return uuid;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the Bukkit player
|
||||
*
|
||||
* @return Player
|
||||
*/
|
||||
public Player getPlayer() {
|
||||
return Bukkit.getPlayer(uuid);
|
||||
}
|
||||
/**
|
||||
* Get the player's name
|
||||
*
|
||||
* @return Player name
|
||||
*/
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the user's level value
|
||||
*
|
||||
* @return level
|
||||
*/
|
||||
public int getLevel() {
|
||||
return level;
|
||||
}
|
||||
/**
|
||||
* Get the player's entity ID
|
||||
*
|
||||
* @return Entity id
|
||||
*/
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the user's group
|
||||
*
|
||||
* @return group
|
||||
*/
|
||||
public Group getGroup() {
|
||||
List<Group> groups = config.getGroups().getGroups();
|
||||
for (int i = 0; i < groups.size(); i++) {
|
||||
if (i == 0 && level < groups.get(i).getLevel()) break;
|
||||
else if (i == groups.size() - 1) return groups.get(i);
|
||||
else if (level >= groups.get(i).getLevel() && level < groups.get(i + 1).getLevel()) return groups.get(i);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
/**
|
||||
* Get the Bukkit player
|
||||
*
|
||||
* @return Player
|
||||
*/
|
||||
public Player getPlayer() {
|
||||
return Bukkit.getPlayer(uuid);
|
||||
}
|
||||
|
||||
/**
|
||||
* Increase the player's level (from failing a check)
|
||||
*
|
||||
* @param type The check failed
|
||||
* @return true if the level was increased
|
||||
*/
|
||||
public boolean increaseLevel(CheckType type) {
|
||||
if (getPlayer() != null && getPlayer().isOnline()) {
|
||||
if (silentMode() && type.getUses(uuid) % 4 != 0) {
|
||||
// Prevent silent mode from increasing the level way too fast
|
||||
return false;
|
||||
} else {
|
||||
if (level < config.getGroups().getHighestLevel()) {
|
||||
level++;
|
||||
/**
|
||||
* Get the user's level value
|
||||
*
|
||||
* @return level
|
||||
*/
|
||||
public int getLevel() {
|
||||
return level;
|
||||
}
|
||||
|
||||
// Check levels
|
||||
for (Group l : getLevels()) {
|
||||
if (l.getLevel() == level) {
|
||||
AntiCheat.getManager().getUserManager().alert(this, l, type);
|
||||
if (l.getLevel() == config.getGroups().getHighestLevel()) {
|
||||
level = l.getLevel() - 10;
|
||||
}
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Get the user's group
|
||||
*
|
||||
* @return group
|
||||
*/
|
||||
public Group getGroup() {
|
||||
final List<Group> groups = config.getGroups().getGroups();
|
||||
for (int i = 0; i < groups.size(); i++) {
|
||||
if (i == 0 && level < groups.get(i).getLevel()) {
|
||||
break;
|
||||
} else if (i == groups.size() - 1) {
|
||||
return groups.get(i);
|
||||
} else if (level >= groups.get(i).getLevel() && level < groups.get(i + 1).getLevel()) {
|
||||
return groups.get(i);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
// Execute rules
|
||||
for (Rule rule : config.getRules().getRules()) {
|
||||
rule.check(this, type);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Increase the player's level (from failing a check)
|
||||
*
|
||||
* @param type The check failed
|
||||
* @return true if the level was increased
|
||||
*/
|
||||
public boolean increaseLevel(final CheckType type) {
|
||||
if (getPlayer() != null && getPlayer().isOnline()) {
|
||||
if (silentMode() && type.getUses(uuid) % 4 != 0) {
|
||||
// Prevent silent mode from increasing the level way too fast
|
||||
return false;
|
||||
} else {
|
||||
if (level < config.getGroups().getHighestLevel()) {
|
||||
level++;
|
||||
|
||||
/**
|
||||
* Decrease the player's level by one value
|
||||
*/
|
||||
public void decreaseLevel() {
|
||||
level = level != 0 ? level - 1 : 0;
|
||||
}
|
||||
// Check levels
|
||||
for (final Group group : getLevels()) {
|
||||
if (group.getLevel() == level) {
|
||||
AntiCheatReloaded.getManager().getUserManager().alert(this, group, type);
|
||||
if (group.getLevel() == config.getGroups().getHighestLevel()) {
|
||||
level = group.getLevel() - 10;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the users level to a specific value. Must be 0 < level < config-defined highest level
|
||||
*
|
||||
* @param level level to set
|
||||
* @return true if the level was valid and set properly
|
||||
*/
|
||||
public boolean setLevel(int level) {
|
||||
isWaitingOnLevelSync = false;
|
||||
if (level >= 0) {
|
||||
if (level <= config.getGroups().getHighestLevel()) {
|
||||
this.level = level;
|
||||
return true;
|
||||
} else {
|
||||
this.level = config.getGroups().getHighestLevel();
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
// Execute rules
|
||||
for (final Rule rule : config.getRules().getRules()) {
|
||||
rule.check(this, type);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Reset the user's level to zero and clear all check failures
|
||||
*/
|
||||
public void resetLevel() {
|
||||
level = 0;
|
||||
for (CheckType type : CheckType.values()) {
|
||||
type.clearUse(uuid);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Decrease the player's level by one value
|
||||
*/
|
||||
public void decreaseLevel() {
|
||||
level = level != 0 ? level - 1 : 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the last known valid location of the player for use in resetting
|
||||
*
|
||||
* @param location default value to be returned if no known good location exists
|
||||
* @return last known valid location
|
||||
*/
|
||||
public Location getGoodLocation(Location location) {
|
||||
if (goodLocation == null) {
|
||||
return location;
|
||||
}
|
||||
/**
|
||||
* Set the users level to a specific value. Must be 0 < level < config-defined
|
||||
* highest level
|
||||
*
|
||||
* @param level level to set
|
||||
* @return true if the level was valid and set properly
|
||||
*/
|
||||
public boolean setLevel(final int level) {
|
||||
isWaitingOnLevelSync = false;
|
||||
if (level >= 0) {
|
||||
if (level <= config.getGroups().getHighestLevel()) {
|
||||
this.level = level;
|
||||
return true;
|
||||
} else {
|
||||
this.level = config.getGroups().getHighestLevel();
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return goodLocation;
|
||||
}
|
||||
/**
|
||||
* Reset the user's level to zero and clear all check failures
|
||||
*/
|
||||
public void resetLevel() {
|
||||
level = 0;
|
||||
for (final CheckType type : CheckType.values()) {
|
||||
type.clearUse(uuid);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the last known valid location of the player
|
||||
*
|
||||
* @param location location to be set
|
||||
* @return true if the location was valid and set properly
|
||||
*/
|
||||
public boolean setGoodLocation(Location location) {
|
||||
if (Utilities.cantStandAtExp(location) || (location.getBlock().isLiquid() && !Utilities.isFullyInWater(location))) {
|
||||
return false;
|
||||
}
|
||||
/**
|
||||
* Get the last known valid location of the player for use in resetting
|
||||
*
|
||||
* @param location default value to be returned if no known good location exists
|
||||
* @return last known valid location
|
||||
*/
|
||||
public Location getGoodLocation(final Location location) {
|
||||
if (goodLocation == null || !location.getWorld().equals(goodLocation.getWorld())
|
||||
|| location.distance(goodLocation) > config.getConfig().maxSetbackDistance.getValue()) {
|
||||
return location;
|
||||
}
|
||||
|
||||
goodLocation = location;
|
||||
return true;
|
||||
}
|
||||
final Location moveTo = goodLocation;
|
||||
if (location != null) {
|
||||
moveTo.setPitch(location.getPitch());
|
||||
moveTo.setYaw(location.getYaw());
|
||||
}
|
||||
return moveTo;
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a copy of the player's inventory, for use in resetting
|
||||
*
|
||||
* @param is ItemStack list to store
|
||||
*/
|
||||
public void setInventorySnapshot(ItemStack[] is) {
|
||||
inventorySnapshot = new ArrayList<ItemStack>();
|
||||
for (int i = 0; i < is.length; i++) {
|
||||
if (is[i] != null) {
|
||||
inventorySnapshot.add(is[i].clone());
|
||||
}
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Set the last known valid location of the player
|
||||
*
|
||||
* @param location location to be set
|
||||
* @return true if the location was valid and set properly
|
||||
*/
|
||||
public boolean setGoodLocation(final Location location) {
|
||||
if (Utilities.cantStandAtExp(location)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the current inventory snapshot
|
||||
*/
|
||||
public void removeInventorySnapshot() {
|
||||
inventorySnapshot = null;
|
||||
}
|
||||
goodLocation = location;
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Restore the player's inventory with the current inventory snapshot
|
||||
*
|
||||
* @param inventory Player's inventory
|
||||
*/
|
||||
public void restoreInventory(Inventory inventory) {
|
||||
if (inventorySnapshot != null) {
|
||||
inventory.clear();
|
||||
for (ItemStack is : inventorySnapshot) {
|
||||
if (is != null) {
|
||||
inventory.addItem(is);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Set the player's to location
|
||||
*
|
||||
* @param x X value
|
||||
* @param y Y value
|
||||
* @param z Z value
|
||||
*/
|
||||
public void setTo(double x, double y, double z) {
|
||||
toX = (int) x;
|
||||
toY = (int) y;
|
||||
toZ = (int) z;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the player's to location
|
||||
*
|
||||
* @param x X value
|
||||
* @param y Y value
|
||||
* @param z Z value
|
||||
*/
|
||||
public void setTo(double x, double y, double z) {
|
||||
toX = (int) x;
|
||||
toY = (int) y;
|
||||
toZ = (int) z;
|
||||
}
|
||||
/**
|
||||
* Check if a given to value is the same as the stored value
|
||||
*
|
||||
* @param x X value
|
||||
* @param y Y value
|
||||
* @param z Z value
|
||||
* @return true if coordinates are all equal
|
||||
*/
|
||||
public boolean checkTo(double x, double y, double z) {
|
||||
return (int) x == toX && (int) y == toY && (int) z == toZ;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a given to value is the same as the stored value
|
||||
*
|
||||
* @param x X value
|
||||
* @param y Y value
|
||||
* @param z Z value
|
||||
* @return true if coordinates are all equal
|
||||
*/
|
||||
public boolean checkTo(double x, double y, double z) {
|
||||
return (int) x == toX && (int) y == toY && (int) z == toZ;
|
||||
}
|
||||
/**
|
||||
* Log a player's chat message
|
||||
*
|
||||
* @param message Message to log
|
||||
*/
|
||||
public void addMessage(String message) {
|
||||
addToSpamLog(message, messages, messageTimes);
|
||||
}
|
||||
|
||||
/**
|
||||
* Log a player's chat message
|
||||
*
|
||||
* @param message Message to log
|
||||
*/
|
||||
public void addMessage(String message) {
|
||||
addToSpamLog(message, messages, messageTimes);
|
||||
}
|
||||
/**
|
||||
* Log a player's command
|
||||
*
|
||||
* @param command Command to log
|
||||
*/
|
||||
public void addCommand(String command) {
|
||||
addToSpamLog(command, commands, commandTimes);
|
||||
}
|
||||
|
||||
/**
|
||||
* Log a player's command
|
||||
*
|
||||
* @param command Command to log
|
||||
*/
|
||||
public void addCommand(String command) {
|
||||
addToSpamLog(command, commands, commandTimes);
|
||||
}
|
||||
private void addToSpamLog(String string, String[] messages, Long[] times) {
|
||||
messages[1] = messages[0];
|
||||
messages[0] = string;
|
||||
|
||||
private void addToSpamLog(String string, String[] messages, Long[] times) {
|
||||
messages[1] = messages[0];
|
||||
messages[0] = string;
|
||||
times[1] = times[0];
|
||||
times[0] = System.currentTimeMillis();
|
||||
}
|
||||
|
||||
times[1] = times[0];
|
||||
times[0] = System.currentTimeMillis();
|
||||
}
|
||||
/**
|
||||
* Get a stored chat message
|
||||
*
|
||||
* @param index Index of the chat in storage
|
||||
* @return the message
|
||||
*/
|
||||
public String getMessage(int index) {
|
||||
return messages[index];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a stored chat message
|
||||
*
|
||||
* @param index Index of the chat in storage
|
||||
* @return the message
|
||||
*/
|
||||
public String getMessage(int index) {
|
||||
return messages[index];
|
||||
}
|
||||
/**
|
||||
* Get a stored command
|
||||
*
|
||||
* @param index Index of the command in storage
|
||||
* @return the command
|
||||
*/
|
||||
public String getCommand(int index) {
|
||||
return commands[index];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a stored command
|
||||
*
|
||||
* @param index Index of the command in storage
|
||||
* @return the command
|
||||
*/
|
||||
public String getCommand(int index) {
|
||||
return commands[index];
|
||||
}
|
||||
/**
|
||||
* Get the time a message in storage was sent
|
||||
*
|
||||
* @param index Index of the chat in storage
|
||||
* @return time the message was sent
|
||||
*/
|
||||
public Long getMessageTime(int index) {
|
||||
return messageTimes[index];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the time a message in storage was sent
|
||||
*
|
||||
* @param index Index of the chat in storage
|
||||
* @return time the message was sent
|
||||
*/
|
||||
public Long getMessageTime(int index) {
|
||||
return messageTimes[index];
|
||||
}
|
||||
/**
|
||||
* Get the time a command in storage was sent
|
||||
*
|
||||
* @param index Index of the command in storage
|
||||
* @return time the command was sent
|
||||
*/
|
||||
public Long getCommandTime(int index) {
|
||||
return commandTimes[index];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the time a command in storage was sent
|
||||
*
|
||||
* @param index Index of the command in storage
|
||||
* @return time the command was sent
|
||||
*/
|
||||
public Long getCommandTime(int index) {
|
||||
return commandTimes[index];
|
||||
}
|
||||
/**
|
||||
* Clear all stored messages
|
||||
*/
|
||||
public void clearMessages() {
|
||||
messages = new String[2];
|
||||
messageTimes = new Long[2];
|
||||
}
|
||||
|
||||
/**
|
||||
* Clear all stored messages
|
||||
*/
|
||||
public void clearMessages() {
|
||||
messages = new String[2];
|
||||
messageTimes = new Long[2];
|
||||
}
|
||||
/**
|
||||
* Clear all stored commands
|
||||
*/
|
||||
public void clearCommands() {
|
||||
commands = new String[2];
|
||||
commandTimes = new Long[2];
|
||||
}
|
||||
|
||||
/**
|
||||
* Clear all stored commands
|
||||
*/
|
||||
public void clearCommands() {
|
||||
commands = new String[2];
|
||||
commandTimes = new Long[2];
|
||||
}
|
||||
/**
|
||||
* Get the time the very last stored message was sent
|
||||
*
|
||||
* @return the last message's time
|
||||
*/
|
||||
public Long getLastMessageTime() {
|
||||
return getMessageTime(0) == null ? -1 : getMessageTime(0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the time the very last stored message was sent
|
||||
*
|
||||
* @return the last message's time
|
||||
*/
|
||||
public Long getLastMessageTime() {
|
||||
return getMessageTime(0) == null ? -1 : getMessageTime(0);
|
||||
}
|
||||
/**
|
||||
* Get the time the very last stored command was sent
|
||||
*
|
||||
* @return the last command's time
|
||||
*/
|
||||
public Long getLastCommandTime() {
|
||||
return getCommandTime(0) == null ? -1 : getCommandTime(0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the time the very last stored command was sent
|
||||
*
|
||||
* @return the last command's time
|
||||
*/
|
||||
public Long getLastCommandTime() {
|
||||
return getCommandTime(0) == null ? -1 : getCommandTime(0);
|
||||
}
|
||||
private List<Group> getLevels() {
|
||||
return config.getGroups().getGroups();
|
||||
}
|
||||
|
||||
private List<Group> getLevels() {
|
||||
return config.getGroups().getGroups();
|
||||
}
|
||||
private boolean silentMode() {
|
||||
return config.getConfig().silentMode.getValue();
|
||||
}
|
||||
|
||||
private boolean silentMode() {
|
||||
return config.getConfig().silentMode.getValue();
|
||||
}
|
||||
public void setIsWaitingOnLevelSync(boolean b) {
|
||||
this.isWaitingOnLevelSync = b;
|
||||
}
|
||||
|
||||
public void setIsWaitingOnLevelSync(boolean b) {
|
||||
this.isWaitingOnLevelSync = b;
|
||||
}
|
||||
public boolean isWaitingOnLevelSync() {
|
||||
return isWaitingOnLevelSync;
|
||||
}
|
||||
|
||||
public boolean isWaitingOnLevelSync() {
|
||||
return isWaitingOnLevelSync;
|
||||
}
|
||||
public void setLevelSyncTimestamp(Timestamp timestamp) {
|
||||
levelSyncTimestamp = timestamp;
|
||||
}
|
||||
|
||||
public void setLevelSyncTimestamp(Timestamp timestamp) {
|
||||
levelSyncTimestamp = timestamp;
|
||||
}
|
||||
public Timestamp getLevelSyncTimestamp() {
|
||||
return levelSyncTimestamp;
|
||||
}
|
||||
|
||||
public Timestamp getLevelSyncTimestamp() {
|
||||
return levelSyncTimestamp;
|
||||
}
|
||||
public int getPing() {
|
||||
final int ping = this.ping;
|
||||
if (ping < 0) {
|
||||
return VersionLib.getPlayerPing(getPlayer());
|
||||
}
|
||||
return ping;
|
||||
}
|
||||
|
||||
public int getLastPing() {
|
||||
final int lastPing = this.lastPing;
|
||||
if (lastPing < 0) {
|
||||
return this.getPing();
|
||||
}
|
||||
return lastPing;
|
||||
}
|
||||
|
||||
public boolean isLagging() {
|
||||
return Math.abs(this.ping - this.lastPing) > config.getMagic().LAG_DETERMINATION()
|
||||
&& this.ping > config.getMagic().LAG_DETERMINATION();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "User {name = " + getName() + ", level = " + level + "}";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "User {name = " + getName() + ", level = " + level + "}";
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,49 @@
|
||||
package com.rammelkast.anticheatreloaded.util;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
|
||||
@RequiredArgsConstructor
|
||||
public final class VelocityTracker {
|
||||
|
||||
private final long velocitizedTime;
|
||||
private final List<VelocityWrapper> velocities = new ArrayList<>();
|
||||
|
||||
public void registerVelocity(final Vector vector) {
|
||||
this.velocities.add(new VelocityWrapper(vector.getX(), vector.getY(), vector.getZ(),
|
||||
Math.hypot(vector.getX(), vector.getZ()), Math.abs(vector.getY()), System.currentTimeMillis()));
|
||||
}
|
||||
|
||||
public void tick() {
|
||||
this.velocities
|
||||
.removeIf(velocity -> (velocity.getTimestamp() + this.velocitizedTime < System.currentTimeMillis()));
|
||||
}
|
||||
|
||||
public double getHorizontal() {
|
||||
return Math
|
||||
.sqrt(this.velocities.parallelStream().mapToDouble(VelocityWrapper::getHorizontal).max().orElse(0.0D));
|
||||
}
|
||||
|
||||
public double getVertical() {
|
||||
return Math
|
||||
.sqrt(this.velocities.parallelStream().mapToDouble(VelocityWrapper::getVertical).max().orElse(0.0D));
|
||||
}
|
||||
|
||||
public boolean isVelocitized() {
|
||||
return this.velocities.size() != 0;
|
||||
}
|
||||
|
||||
@RequiredArgsConstructor
|
||||
@Getter
|
||||
private class VelocityWrapper {
|
||||
private final double motionX, motionY, motionZ;
|
||||
private final double horizontal, vertical;
|
||||
private final long timestamp;
|
||||
}
|
||||
|
||||
}
|
||||
Loaded 100 of 112 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user