Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8eb4015cab | ||
|
|
3ec44f72da | ||
|
|
3797c45d98 | ||
|
|
94b7523774 | ||
|
|
6f0de9f01c | ||
|
|
16cc63447f | ||
|
|
bb6661b4eb | ||
|
|
63a5005257 | ||
|
|
8b4fdd4773 | ||
|
|
333bea795f | ||
|
|
3ee972a4ff | ||
|
|
94a1f67975 | ||
|
|
e00b55842d | ||
|
|
ba1a4afa79 | ||
|
|
d2925592fc | ||
|
|
d97c1a03ee | ||
|
|
a1d48d3b20 | ||
|
|
4ce0463465 | ||
|
|
6725caad36 | ||
|
|
17e9d667a8 | ||
|
|
92d85822f3 | ||
|
|
bdeb421ca3 | ||
|
|
b5a5aa4748 | ||
|
|
096d8ab807 | ||
|
|
da7d2c7929 | ||
|
|
ead6156bfa | ||
|
|
4220b2d7b3 | ||
|
|
e7c598d29e | ||
|
|
1677383049 | ||
|
|
23ec389798 | ||
|
|
0ceaf9a3b2 | ||
|
|
5fbb775ab4 | ||
|
|
8914842e71 | ||
|
|
3e912f5282 | ||
|
|
360562e80e | ||
|
|
8ffc8836d6 | ||
|
|
2f629ac77f | ||
|
|
f1ead98a46 | ||
|
|
c3747cfebd | ||
|
|
21d6970b0d | ||
|
|
d9072d54d0 | ||
|
|
a963980f9d | ||
|
|
45f8ce1a44 | ||
|
|
eb981ef06a | ||
|
|
56030945e9 | ||
|
|
d4e52967ca | ||
|
|
4b3a998ae2 | ||
|
|
b0dd3dae9b | ||
|
|
372a802c98 | ||
|
|
16f2f29bf2 | ||
|
|
e0aba994b6 | ||
|
|
6aea77cdbc | ||
|
|
07d96cd486 | ||
|
|
9b21a4d07a | ||
|
|
dea483d362 | ||
|
|
636e246c70 | ||
|
|
0d5c7b5250 | ||
|
|
1b5f066eb0 | ||
|
|
ffe224c4bf | ||
|
|
792fe16124 | ||
|
|
3c92108c44 | ||
|
|
3b71327245 | ||
|
|
6d70978285 | ||
|
|
953ad680ee | ||
|
|
765f2fad92 | ||
|
|
bede734af7 | ||
|
|
31853376d6 | ||
|
|
3a100ce325 | ||
|
|
bbb2ef0668 | ||
|
|
9f697673c0 | ||
|
|
b1deb8629b | ||
|
|
70d0400c67 | ||
|
|
b0c08ce813 | ||
|
|
3af91fcac9 | ||
|
|
d1c2fe4169 | ||
|
|
1900d37c94 | ||
|
|
5d17a2a613 | ||
|
|
4a93603614 | ||
|
|
9a1a59f15f | ||
|
|
0c350a3f27 | ||
|
|
c3d75f1e8d | ||
|
|
b847e53221 | ||
|
|
c9570b0ad7 | ||
|
|
ee5caaa81c |
No files matched your search
@@ -1,674 +1,21 @@
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
Version 3, 29 June 2007
|
||||
|
||||
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
|
||||
|
||||
The GNU General Public License is a free, copyleft license for
|
||||
software and other kinds of works.
|
||||
|
||||
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.
|
||||
|
||||
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.
|
||||
|
||||
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.
|
||||
|
||||
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.
|
||||
|
||||
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.
|
||||
|
||||
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.
|
||||
|
||||
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.
|
||||
|
||||
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.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow.
|
||||
|
||||
TERMS AND CONDITIONS
|
||||
|
||||
0. Definitions.
|
||||
|
||||
"This License" refers to version 3 of the GNU General Public License.
|
||||
|
||||
"Copyright" also means copyright-like laws that apply to other kinds of
|
||||
works, such as semiconductor masks.
|
||||
|
||||
"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.
|
||||
|
||||
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 "covered work" means either the unmodified Program or a work based
|
||||
on the Program.
|
||||
|
||||
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.
|
||||
|
||||
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.
|
||||
|
||||
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.
|
||||
|
||||
1. Source Code.
|
||||
|
||||
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.
|
||||
|
||||
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.
|
||||
|
||||
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.
|
||||
|
||||
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.
|
||||
|
||||
The Corresponding Source need not include anything that users
|
||||
can regenerate automatically from other parts of the Corresponding
|
||||
Source.
|
||||
|
||||
The Corresponding Source for a work in source code form is that
|
||||
same work.
|
||||
|
||||
2. Basic Permissions.
|
||||
|
||||
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.
|
||||
|
||||
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.
|
||||
|
||||
Conveying under any other circumstances is permitted solely under
|
||||
the conditions stated below. Sublicensing is not allowed; section 10
|
||||
makes it unnecessary.
|
||||
|
||||
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
|
||||
|
||||
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.
|
||||
|
||||
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.
|
||||
|
||||
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>.
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2020 retrooper
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
@@ -8,16 +8,13 @@ This packetlistener is **only** supported on spigot servers and has been tested
|
||||
|
||||
* No dependencies
|
||||
|
||||
* Licensed under the GPL3 license.
|
||||
* Licensed under the MIT license
|
||||
|
||||
[](https://www.gnu.org/licenses/gpl-3.0)
|
||||
[](https://opensource.org/licenses/MIT)
|
||||
|
||||
Join my discord server(to talk to me): https://discord.gg/ZWTkg4v
|
||||
Our discord server: https://discord.me/packetevents
|
||||
|
||||
[](https://jitpack.io/#retrooper/packetevents)
|
||||
|
||||
[](https://jitci.com/gh/retrooper/packetevents)
|
||||
|
||||
To learn how to setup this API please click on the link below
|
||||
[Setup Guide](https://github.com/retrooper/packetevents/wiki/PacketEvents-Setup-Guide)
|
||||
(or just paste this into your browser: https://github.com/retrooper/packetevents/wiki/PacketEvents-Setup-Guide)
|
||||
@@ -1,44 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module org.jetbrains.idea.maven.project.MavenProjectsManager.isMavenModule="true" type="JAVA_MODULE" version="4">
|
||||
<component name="FacetManager">
|
||||
<facet type="minecraft" name="Minecraft">
|
||||
<configuration>
|
||||
<autoDetectTypes>
|
||||
<platformType>SPIGOT</platformType>
|
||||
</autoDetectTypes>
|
||||
</configuration>
|
||||
</facet>
|
||||
</component>
|
||||
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_8">
|
||||
<output url="file://$MODULE_DIR$/target/classes" />
|
||||
<output-test url="file://$MODULE_DIR$/target/test-classes" />
|
||||
<content url="file://$MODULE_DIR$">
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/main/resources" type="java-resource" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/target" />
|
||||
</content>
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: org.github.spigot:1.7.10:1.7.10" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: org.github.spigot:1.8.8:1.8.8" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: com.comphenix.protocol:ProtocolLib:4.5.0" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: cglib:cglib-nodep:3.2.5" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: com.comphenix.executors:BukkitExecutors:1.1-SNAPSHOT" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: us.myles:viaversion:3.0.1" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: us.myles:viaversion-common:3.0.1" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: org.yaml:snakeyaml:1.18" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: us.myles:viaversion-bukkit:3.0.1" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: us.myles:viaversion-bukkit-legacy:3.0.1" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: us.myles:viaversion-bungee:3.0.1" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: us.myles:viaversion-fabric:3.0.1" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: us.myles:viaversion-sponge:3.0.1" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: us.myles:viaversion-sponge-legacy:3.0.1" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: us.myles:viaversion-velocity:3.0.1" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: net.md-5:bungeecord-chat:1.15-SNAPSHOT" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: com.google.guava:guava:21.0" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: com.github.ProtocolSupport:ProtocolSupport:4fdd683" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: org.apache.commons:commons-lang3:3.8.1" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: it.unimi.dsi:fastutil:8.2.2" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: com.google.code.gson:gson:2.8.5" level="project" />
|
||||
</component>
|
||||
</module>
|
||||
@@ -6,7 +6,29 @@
|
||||
|
||||
<groupId>io.github.retrooper</groupId>
|
||||
<artifactId>packetevents</artifactId>
|
||||
<version>1.5</version>
|
||||
<version>1.6</version>
|
||||
|
||||
<!-- You can build the project with this: "mvn clean compile assembly:single" -->
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<artifactId>maven-assembly-plugin</artifactId>
|
||||
<configuration>
|
||||
<descriptorRefs>
|
||||
<descriptorRef>jar-with-dependencies</descriptorRef>
|
||||
</descriptorRefs>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<configuration>
|
||||
<source>8</source>
|
||||
<target>8</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
<packaging>jar</packaging>
|
||||
<name>packetevents</name>
|
||||
|
||||
@@ -15,35 +37,6 @@
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
</properties>
|
||||
|
||||
<build>
|
||||
<defaultGoal>clean package</defaultGoal>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>3.7.0</version>
|
||||
<configuration>
|
||||
<source>1.8</source>
|
||||
<target>1.8</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>3.7.0</version>
|
||||
<configuration>
|
||||
<source>${java.version}</source>
|
||||
<target>${java.version}</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
<resources>
|
||||
<resource>
|
||||
<directory>src/main/resources</directory>
|
||||
<filtering>true</filtering>
|
||||
</resource>
|
||||
</resources>
|
||||
</build>
|
||||
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>spigot-repo</id>
|
||||
@@ -69,6 +62,13 @@
|
||||
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.github.spigot</groupId>
|
||||
<artifactId>1.8.8</artifactId>
|
||||
<version>1.8.8</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.github.spigot</groupId>
|
||||
<artifactId>1.7.10</artifactId>
|
||||
@@ -76,19 +76,13 @@
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.github.spigot</groupId>
|
||||
<artifactId>1.8.8</artifactId>
|
||||
<version>1.8.8</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.comphenix.protocol</groupId>
|
||||
<artifactId>ProtocolLib</artifactId>
|
||||
<version>4.5.0</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<!-- ViaVersion API-->
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>us.myles</groupId>
|
||||
<artifactId>viaversion</artifactId>
|
||||
@@ -96,7 +90,6 @@
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<!-- ProtocolSupport API-->
|
||||
<dependency>
|
||||
<groupId>com.github.ProtocolSupport</groupId>
|
||||
<artifactId>ProtocolSupport</artifactId>
|
||||
@@ -104,6 +97,13 @@
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.spigotmc</groupId>
|
||||
<artifactId>spigot-api</artifactId>
|
||||
<version>1.8.8-R0.1-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.bukkit</groupId>
|
||||
<artifactId>bukkit</artifactId>
|
||||
|
||||
@@ -1,13 +1,20 @@
|
||||
/**
|
||||
* Copyright (c) 2020 retrooper
|
||||
*/
|
||||
package io.github.retrooper.packetevents;
|
||||
|
||||
import io.github.retrooper.packetevents.annotations.PacketHandler;
|
||||
import io.github.retrooper.packetevents.api.PacketEventsAPI;
|
||||
import io.github.retrooper.packetevents.enums.ClientVersion;
|
||||
import io.github.retrooper.packetevents.enums.ServerVersion;
|
||||
import io.github.retrooper.packetevents.event.PacketEvent;
|
||||
import io.github.retrooper.packetevents.event.PacketListener;
|
||||
import io.github.retrooper.packetevents.event.impl.BukkitMoveEvent;
|
||||
import io.github.retrooper.packetevents.event.impl.PacketReceiveEvent;
|
||||
import io.github.retrooper.packetevents.event.impl.PlayerInjectEvent;
|
||||
import io.github.retrooper.packetevents.packet.PacketType;
|
||||
import io.github.retrooper.packetevents.packet.PacketTypeClasses;
|
||||
import io.github.retrooper.packetevents.settings.Settings;
|
||||
import io.github.retrooper.packetevents.packetwrappers.api.WrappedPacket;
|
||||
import io.github.retrooper.packetevents.settings.PacketEventsSettings;
|
||||
import io.github.retrooper.packetevents.utils.nms_entityfinder.EntityFinderUtils;
|
||||
import io.github.retrooper.packetevents.utils.versionlookup.VersionLookupUtils;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
@@ -17,96 +24,109 @@ import org.bukkit.event.player.PlayerMoveEvent;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
public final class PacketEvents implements PacketListener, Listener {
|
||||
public static HashMap<Plugin, Integer> plugins = new HashMap<Plugin, Integer>();
|
||||
public PacketEvents(final Plugin plugin) {
|
||||
this.plugin = plugin;
|
||||
plugins.put(plugin, plugins.size());
|
||||
}
|
||||
private final Plugin plugin;
|
||||
private final PacketEventsAPI packetEventsAPI = new PacketEventsAPI();
|
||||
private static boolean hasLoaded;
|
||||
private static final Settings settings = new Settings();
|
||||
private static final PacketEventsAPI packetEventsAPI = new PacketEventsAPI();
|
||||
private static final PacketEvents instance = new PacketEvents();
|
||||
private static final PacketEventsSettings settings = new PacketEventsSettings();
|
||||
private static Plugin plugin;
|
||||
private static boolean hasLoaded, hasStarted;
|
||||
|
||||
/**
|
||||
* Call this before start()
|
||||
*/
|
||||
public static void load() {
|
||||
//SERVER VERSION LOADING
|
||||
|
||||
//Server Version reversed values caching
|
||||
ServerVersion.reversedValues = ServerVersion.reverse(ServerVersion.values());
|
||||
|
||||
PacketTypeClasses.Client.load();
|
||||
PacketTypeClasses.Server.load();
|
||||
ServerVersion version= ServerVersion.getVersion();
|
||||
WrappedPacket.version = version;
|
||||
PacketEvent.version = version;
|
||||
EntityFinderUtils.version = version;
|
||||
WrappedPacket.loadAllWrappers();
|
||||
ClientVersion.prepareLookUp();
|
||||
hasLoaded = true;
|
||||
}
|
||||
|
||||
/**
|
||||
*Loads PacketEvents if you haven't already, Sets everything up, injects all players
|
||||
* Loads PacketEvents if you haven't already, Sets everything up, injects all players
|
||||
*/
|
||||
public void start() {
|
||||
public static void start(final Plugin pl) {
|
||||
if (!hasLoaded) {
|
||||
load();
|
||||
}
|
||||
if (!hasStarted) {
|
||||
plugin = pl;
|
||||
//Register Bukkit and PacketListener
|
||||
getAPI().getEventManager().registerListener(this);
|
||||
getAPI().getEventManager().registerListener(instance);
|
||||
|
||||
Bukkit.getPluginManager().registerEvents(this, plugin);
|
||||
Bukkit.getPluginManager().registerEvents(instance, plugin);
|
||||
|
||||
for(final Player p : Bukkit.getServer().getOnlinePlayers()) {
|
||||
getAPI().getPlayerUtilities().injectPlayer(p, this);
|
||||
for (final Player p : Bukkit.getOnlinePlayers()) {
|
||||
getAPI().getPlayerUtils().injectPlayer(p);
|
||||
}
|
||||
|
||||
hasStarted = true;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Stop all tasks and unregisters all PacketEvents' listeners
|
||||
*/
|
||||
public void stop() {
|
||||
getAPI().getEventManager().unregisterAllListeners();
|
||||
public static void stop() {
|
||||
if (hasStarted) {
|
||||
for (final Player p : Bukkit.getOnlinePlayers()) {
|
||||
getAPI().getPlayerUtils().uninjectPlayer(p);
|
||||
}
|
||||
getAPI().getEventManager().unregisterAllListeners();
|
||||
|
||||
PacketType.Client.packetIds.clear();
|
||||
PacketType.Server.packetIds.clear();
|
||||
for(final Player p : Bukkit.getServer().getOnlinePlayers()) {
|
||||
getAPI().getPlayerUtilities().uninjectPlayer(p, this);
|
||||
PacketType.Client.packetIds.clear();
|
||||
PacketType.Server.packetIds.clear();
|
||||
}
|
||||
}
|
||||
|
||||
public PacketEventsAPI getAPI() {
|
||||
public static boolean hasLoaded() {
|
||||
return hasLoaded;
|
||||
}
|
||||
|
||||
public static boolean hasStarted() {
|
||||
return hasStarted;
|
||||
}
|
||||
|
||||
public static PacketEventsAPI getAPI() {
|
||||
return packetEventsAPI;
|
||||
}
|
||||
|
||||
public Plugin getPlugin() {
|
||||
public static Plugin getPlugin() {
|
||||
return plugin;
|
||||
}
|
||||
|
||||
public String getHandlerName() {
|
||||
return "packetevents_" + plugins.get(plugin);
|
||||
public static String getHandlerName(final String name) {
|
||||
return "pe-" + getSettings().getIdentifier() + "-" + name;
|
||||
}
|
||||
public static Settings getSettings() {
|
||||
|
||||
public static PacketEventsSettings getSettings() {
|
||||
return settings;
|
||||
}
|
||||
|
||||
@PacketHandler
|
||||
public void onInject(final PlayerInjectEvent e) {
|
||||
getAPI().getPlayerUtilities().setClientVersion(e.getPlayer(), e.getClientVersion());
|
||||
}
|
||||
|
||||
@PacketHandler
|
||||
public void onReceive(final PacketReceiveEvent e) {
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onJoin(final PlayerJoinEvent e) {
|
||||
getAPI().getPlayerUtilities().injectPlayer(e.getPlayer(), this);
|
||||
getAPI().getPlayerUtils().injectPlayer(e.getPlayer());
|
||||
getAPI().getPlayerUtils().setClientVersion(e.getPlayer(), ClientVersion.fromProtocolVersion(VersionLookupUtils.getProtocolVersion(e.getPlayer())));
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onQuit(final PlayerQuitEvent e) {
|
||||
getAPI().getPlayerUtilities().clearClientVersion(e.getPlayer());
|
||||
getAPI().getPlayerUtilities().uninjectPlayer(e.getPlayer(), this);
|
||||
getAPI().getPlayerUtils().clearClientVersion(e.getPlayer());
|
||||
getAPI().getPlayerUtils().uninjectPlayer(e.getPlayer());
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onMove(final PlayerMoveEvent e) {
|
||||
getAPI().getEventManager().callEvent(new BukkitMoveEvent(e), getPlugin());
|
||||
BukkitMoveEvent moveEvent = new BukkitMoveEvent(e);
|
||||
getAPI().getEventManager().callEvent(moveEvent);
|
||||
e.setCancelled(moveEvent.isCancelled());
|
||||
}
|
||||
}
|
||||
@@ -1,3 +1,6 @@
|
||||
/**
|
||||
* Copyright (c) 2020 retrooper
|
||||
*/
|
||||
package io.github.retrooper.packetevents.annotations;
|
||||
|
||||
|
||||
|
||||
@@ -1,3 +1,6 @@
|
||||
/**
|
||||
* Copyright (c) 2020 retrooper
|
||||
*/
|
||||
package io.github.retrooper.packetevents.annotations;
|
||||
|
||||
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
/**
|
||||
* Copyright (c) 2020 retrooper
|
||||
*/
|
||||
package io.github.retrooper.packetevents.annotations;
|
||||
|
||||
import io.github.retrooper.packetevents.annotations.data.EventSynchronization;
|
||||
import io.github.retrooper.packetevents.enums.EventSynchronization;
|
||||
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
|
||||
-5
@@ -1,5 +0,0 @@
|
||||
package io.github.retrooper.packetevents.annotations.data;
|
||||
|
||||
public enum EventSynchronization {
|
||||
FORCE_SYNC, FORCE_ASYNC, NORMAL
|
||||
}
|
||||
+8
-7
@@ -1,15 +1,16 @@
|
||||
package io.github.retrooper.packetevents;
|
||||
/**
|
||||
* Copyright (c) 2020 retrooper
|
||||
*/
|
||||
package io.github.retrooper.packetevents.api;
|
||||
|
||||
import io.github.retrooper.packetevents.event.manager.EventManager;
|
||||
import io.github.retrooper.packetevents.settings.Settings;
|
||||
import io.github.retrooper.packetevents.utils.api.PlayerUtils;
|
||||
import io.github.retrooper.packetevents.utils.api.ServerUtils;
|
||||
import org.bukkit.scheduler.BukkitTask;
|
||||
|
||||
public final class PacketEventsAPI {
|
||||
private final EventManager eventManager = new EventManager();
|
||||
private final PlayerUtils playerUtils = new PlayerUtils();
|
||||
private final ServerUtils serverUtils = new ServerUtils();;
|
||||
private final ServerUtils serverUtils = new ServerUtils();
|
||||
|
||||
/**
|
||||
* Not thread safe
|
||||
@@ -40,7 +41,7 @@ public final class PacketEventsAPI {
|
||||
*
|
||||
* @return Player Utilities
|
||||
*/
|
||||
public PlayerUtils getPlayerUtilities() {
|
||||
public PlayerUtils getPlayerUtils() {
|
||||
return playerUtils;
|
||||
}
|
||||
|
||||
@@ -49,10 +50,11 @@ public final class PacketEventsAPI {
|
||||
*
|
||||
* @return Server Utilities
|
||||
*/
|
||||
public ServerUtils getServerUtilities() {
|
||||
public ServerUtils getServerUtils() {
|
||||
return serverUtils;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the event manager
|
||||
* Used to call events, register and unregister listeners
|
||||
@@ -64,5 +66,4 @@ public final class PacketEventsAPI {
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -1,74 +1,79 @@
|
||||
/**
|
||||
* Copyright (c) 2020 retrooper
|
||||
*/
|
||||
package io.github.retrooper.packetevents.enums;
|
||||
|
||||
import io.github.retrooper.packetevents.PacketEvents;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public enum ClientVersion {
|
||||
LESS_THAN_V_1_7_10, v_1_7_10, v_1_8, v_1_9, v_1_9_1, v_1_9_2, v_1_9_3, v_1_10, v_1_11, v_1_11_1, v_1_12, v_1_12_1, v_1_12_2,
|
||||
v_1_13, v_1_13_1, v_1_13_2, v_1_14, v_1_14_1, v_1_14_2, v_1_14_3, v_1_14_4, v_1_15, v_1_15_1, v_1_15_2, v_1_16, v_1_16_1, HIGHER_THAN_V_1_16_1, INVALID, ACCESS_FAILURE;
|
||||
v_1_13, v_1_13_1, v_1_13_2, v_1_14, v_1_14_1, v_1_14_2, v_1_14_3, v_1_14_4, v_1_15_PRE_1, v_1_15_PRE_2, v_1_15_PRE_3, v_1_15_PRE_4, v_1_15_PRE_5, v_1_15_PRE_6, v_1_15_PRE_7,
|
||||
v_1_15, v_1_15_1, v_1_15_2, v_1_16, v_1_16_PRE_1, v_1_16_PRE_2, v_1_16_PRE_3, v_1_16_PRE_4, v_1_16_PRE_5, v_1_16_PRE_6, v_1_16_PRE_7, v_1_16_PRE_8, v_1_16_RC_1, v_1_16_1, v_1_16_2, HIGHER_THAN_V_1_16_2, INVALID, ACCESS_FAILURE;
|
||||
|
||||
public static ClientVersion fromProtocolVersion(final int protocolVersion) {
|
||||
int remainder = -1;
|
||||
switch (protocolVersion) {
|
||||
case -1:
|
||||
return ACCESS_FAILURE;
|
||||
case 1:
|
||||
case 2:
|
||||
case 3:
|
||||
case 4:
|
||||
return LESS_THAN_V_1_7_10;
|
||||
case 47://ranging from 1.8->1.8.9
|
||||
return v_1_8;
|
||||
case 107:
|
||||
return v_1_9;
|
||||
case 108:
|
||||
return v_1_9_1;
|
||||
case 109:
|
||||
return v_1_9_2;
|
||||
case 110:
|
||||
return v_1_9_3; //can be 1.9.3 or 1.9.4
|
||||
case 210:
|
||||
return v_1_10; //could be 1.10,1.10.1, 1.10.2
|
||||
case 315:
|
||||
return v_1_11;
|
||||
case 316: //could be 11.1 or 11.2
|
||||
return v_1_11_1;
|
||||
case 335:
|
||||
return v_1_12;
|
||||
case 338:
|
||||
return v_1_12_1;
|
||||
case 340:
|
||||
return v_1_12_2;
|
||||
case 393:
|
||||
return v_1_13;
|
||||
case 401:
|
||||
return v_1_13_1;
|
||||
case 404:
|
||||
return v_1_13_2;
|
||||
case 477:
|
||||
return v_1_14;
|
||||
case 480:
|
||||
return v_1_14_1;
|
||||
case 485:
|
||||
return v_1_14_2;
|
||||
case 490:
|
||||
return v_1_14_3;
|
||||
case 498:
|
||||
return v_1_14_4;
|
||||
case 573:
|
||||
return v_1_15;
|
||||
case 575:
|
||||
return v_1_15_1;
|
||||
case 578:
|
||||
return v_1_15_2;
|
||||
case 735:
|
||||
return v_1_16;
|
||||
case 736:
|
||||
return v_1_16_1;
|
||||
default:
|
||||
remainder = protocolVersion;
|
||||
private static final Map<Integer, ClientVersion> VERSION_LOOKUP = new HashMap<Integer, ClientVersion>();
|
||||
|
||||
public static void prepareLookUp() {
|
||||
VERSION_LOOKUP.put(-1, ACCESS_FAILURE);
|
||||
VERSION_LOOKUP.put(1, LESS_THAN_V_1_7_10);
|
||||
VERSION_LOOKUP.put(2, LESS_THAN_V_1_7_10);
|
||||
VERSION_LOOKUP.put(3, LESS_THAN_V_1_7_10);
|
||||
VERSION_LOOKUP.put(4, LESS_THAN_V_1_7_10);
|
||||
VERSION_LOOKUP.put(5, v_1_7_10);
|
||||
VERSION_LOOKUP.put(47, v_1_8);
|
||||
VERSION_LOOKUP.put(107, v_1_9);
|
||||
VERSION_LOOKUP.put(108, v_1_9_1);
|
||||
VERSION_LOOKUP.put(109, v_1_9_2);
|
||||
VERSION_LOOKUP.put(110, v_1_9_3);
|
||||
VERSION_LOOKUP.put(210, v_1_10);
|
||||
VERSION_LOOKUP.put(315, v_1_11);
|
||||
VERSION_LOOKUP.put(316, v_1_11_1);
|
||||
VERSION_LOOKUP.put(335, v_1_12);
|
||||
VERSION_LOOKUP.put(338, v_1_12_1);
|
||||
VERSION_LOOKUP.put(340, v_1_12_2);
|
||||
VERSION_LOOKUP.put(393, v_1_13);
|
||||
VERSION_LOOKUP.put(401, v_1_13_1);
|
||||
VERSION_LOOKUP.put(404, v_1_13_2);
|
||||
VERSION_LOOKUP.put(477, v_1_14);
|
||||
VERSION_LOOKUP.put(480, v_1_14_1);
|
||||
VERSION_LOOKUP.put(485, v_1_14_2);
|
||||
VERSION_LOOKUP.put(490, v_1_14_3);
|
||||
VERSION_LOOKUP.put(498, v_1_14_4);
|
||||
VERSION_LOOKUP.put(565, v_1_15_PRE_1);
|
||||
VERSION_LOOKUP.put(566, v_1_15_PRE_2);
|
||||
VERSION_LOOKUP.put(567, v_1_15_PRE_3);
|
||||
VERSION_LOOKUP.put(569, v_1_15_PRE_4);
|
||||
VERSION_LOOKUP.put(570, v_1_15_PRE_5);
|
||||
VERSION_LOOKUP.put(571, v_1_15_PRE_6);
|
||||
VERSION_LOOKUP.put(572, v_1_15_PRE_7);
|
||||
VERSION_LOOKUP.put(573, v_1_15);
|
||||
VERSION_LOOKUP.put(575, v_1_15_1);
|
||||
VERSION_LOOKUP.put(578, v_1_15_2);
|
||||
VERSION_LOOKUP.put(721, v_1_16_PRE_1);
|
||||
VERSION_LOOKUP.put(722, v_1_16_PRE_2);
|
||||
VERSION_LOOKUP.put(725, v_1_16_PRE_3);
|
||||
VERSION_LOOKUP.put(727, v_1_16_PRE_4);
|
||||
VERSION_LOOKUP.put(729, v_1_16_PRE_5);
|
||||
VERSION_LOOKUP.put(730, v_1_16_PRE_6);
|
||||
VERSION_LOOKUP.put(732, v_1_16_PRE_7);
|
||||
VERSION_LOOKUP.put(733, v_1_16_PRE_8);
|
||||
VERSION_LOOKUP.put(734, v_1_16_RC_1);
|
||||
VERSION_LOOKUP.put(735, v_1_16);
|
||||
VERSION_LOOKUP.put(736, v_1_16_1);
|
||||
VERSION_LOOKUP.put(737, v_1_16_2);
|
||||
}
|
||||
|
||||
public static ClientVersion fromProtocolVersion(int protocolVersion) {
|
||||
if (protocolVersion == -1 && PacketEvents.getSettings().doAutoResolveClientProtocolVersion()) {
|
||||
protocolVersion = ServerVersion.getVersion().toProtocolVersion();
|
||||
}
|
||||
if (remainder > 578) {
|
||||
return HIGHER_THAN_V_1_16_1;
|
||||
final ClientVersion lookedUp = VERSION_LOOKUP.get(protocolVersion);
|
||||
if (lookedUp != null) {
|
||||
return lookedUp;
|
||||
}
|
||||
return INVALID;
|
||||
return protocolVersion > 737 ? HIGHER_THAN_V_1_16_2 : INVALID;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -89,10 +94,10 @@ public enum ClientVersion {
|
||||
* @return
|
||||
*/
|
||||
public boolean isLowerThan(final ClientVersion version) {
|
||||
if (version == this) return false;
|
||||
final int len = values().length;
|
||||
if (this == version) return false;
|
||||
final int len = ClientVersion.values().length;
|
||||
for (byte i = 0; i < len; i++) {
|
||||
final ClientVersion v = values()[i];
|
||||
final ClientVersion v = ClientVersion.values()[i];
|
||||
if (v == this) {
|
||||
return true;
|
||||
} else if (v == version) {
|
||||
|
||||
@@ -1,3 +1,6 @@
|
||||
/**
|
||||
* Copyright (c) 2020 retrooper
|
||||
*/
|
||||
package io.github.retrooper.packetevents.enums;
|
||||
|
||||
public enum Direction {
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
/**
|
||||
* Copyright (c) 2020 retrooper
|
||||
*/
|
||||
package io.github.retrooper.packetevents.enums;
|
||||
|
||||
public enum EventSynchronization {
|
||||
NORMAL, FORCE_SYNC, FORCE_ASYNC
|
||||
}
|
||||
@@ -1,3 +1,6 @@
|
||||
/**
|
||||
* Copyright (c) 2020 retrooper
|
||||
*/
|
||||
package io.github.retrooper.packetevents.enums;
|
||||
|
||||
import io.github.retrooper.packetevents.PacketEvents;
|
||||
@@ -7,24 +10,19 @@ import org.bukkit.Bukkit;
|
||||
* @author retrooper
|
||||
*/
|
||||
public enum ServerVersion {
|
||||
v_1_7_10, v_1_8, v_1_8_3, v_1_8_8, v_1_9, v_1_9_4, v_1_10, v_1_11, v_1_12, v_1_13, v_1_13_2, v_1_14, v_1_15, v_1_16_1,
|
||||
v_1_7_10, v_1_8, v_1_8_3, v_1_8_8, v_1_9, v_1_9_4, v_1_10, v_1_11, v_1_12, v_1_13, v_1_13_2, v_1_14, v_1_15, v_1_16, v_1_16_1, v_1_16_2,
|
||||
ERROR, EMPTY;
|
||||
|
||||
private static final ServerVersion[] reversedValues;
|
||||
private static final String nmsVersionSuffix = Bukkit.getServer().getClass().getPackage().getName().replace(".", ",").split(",")[3];
|
||||
public static ServerVersion[] reversedValues;
|
||||
private static ServerVersion cachedVersion;
|
||||
|
||||
static {
|
||||
reversedValues = reverse(values());
|
||||
}
|
||||
|
||||
private static ServerVersion getVers() {
|
||||
for (final ServerVersion val : reversedValues) {
|
||||
String valName = val.name().substring(2).replace("_", ".");
|
||||
if (Bukkit.getBukkitVersion().contains(valName)) {
|
||||
return val;
|
||||
}
|
||||
else if(PacketEvents.getSettings().getDefaultServerVersion() != null) {
|
||||
} else if (PacketEvents.getSettings().getDefaultServerVersion() != null) {
|
||||
return PacketEvents.getSettings().getDefaultServerVersion();
|
||||
}
|
||||
}
|
||||
@@ -39,7 +37,7 @@ public enum ServerVersion {
|
||||
}
|
||||
|
||||
|
||||
private static ServerVersion[] reverse(final ServerVersion[] arr) {
|
||||
public static ServerVersion[] reverse(final ServerVersion[] arr) {
|
||||
ServerVersion[] array = arr.clone();
|
||||
if (array == null) {
|
||||
return null;
|
||||
@@ -87,10 +85,10 @@ public enum ServerVersion {
|
||||
* @return
|
||||
*/
|
||||
public boolean isLowerThan(final ServerVersion version) {
|
||||
if (version == this) return false;
|
||||
final int len = values().length;
|
||||
if (this == version) return false;
|
||||
final int len = ServerVersion.values().length;
|
||||
for (byte i = 0; i < len; i++) {
|
||||
final ServerVersion v = values()[i];
|
||||
final ServerVersion v = ServerVersion.values()[i];
|
||||
if (v == this) {
|
||||
return true;
|
||||
} else if (v == version) {
|
||||
@@ -100,4 +98,49 @@ public enum ServerVersion {
|
||||
return false;
|
||||
}
|
||||
|
||||
public int toProtocolVersion() {
|
||||
if (this.equals(ServerVersion.v_1_7_10)) {
|
||||
return 5;
|
||||
}
|
||||
if (this.name().startsWith("v_1_8")) {
|
||||
return 47;
|
||||
}
|
||||
if (this.equals(ServerVersion.v_1_9)) {
|
||||
return 107;
|
||||
}
|
||||
if (this.equals(ServerVersion.v_1_9_4)) {
|
||||
return 110;
|
||||
}
|
||||
if (this.equals(ServerVersion.v_1_10)) {
|
||||
return 210;
|
||||
}
|
||||
if (this.equals(ServerVersion.v_1_11)) {
|
||||
return 315;
|
||||
}
|
||||
if (this.equals(ServerVersion.v_1_12)) {
|
||||
return 335;
|
||||
}
|
||||
if (this.equals(ServerVersion.v_1_13)) {
|
||||
return 393;
|
||||
}
|
||||
if (this.equals(ServerVersion.v_1_13_2)) {
|
||||
return 404;
|
||||
}
|
||||
if (this.equals(ServerVersion.v_1_14)) {
|
||||
return 477;
|
||||
}
|
||||
if (this.equals(ServerVersion.v_1_15)) {
|
||||
return 573;
|
||||
}
|
||||
if (this.equals(ServerVersion.v_1_16)) {
|
||||
return 735;
|
||||
}
|
||||
if (this.equals(ServerVersion.v_1_16_1)) {
|
||||
return 736;
|
||||
}
|
||||
if (this.equals(ServerVersion.v_1_16_2)) {
|
||||
return 737;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
@@ -1,3 +1,6 @@
|
||||
/**
|
||||
* Copyright (c) 2020 retrooper
|
||||
*/
|
||||
package io.github.retrooper.packetevents.enums;
|
||||
|
||||
public enum SystemOS {
|
||||
|
||||
-19
@@ -1,19 +0,0 @@
|
||||
package io.github.retrooper.packetevents.enums.minecraft;
|
||||
|
||||
public enum EntityAnimationType {
|
||||
SWING_MAIN_ARM, DAMAGE, LEAVE_BED, SWING_OFFHAND, CRITICAL_EFFECT, MAGIC_CRITICAL_EFFECT;
|
||||
|
||||
public static final EntityAnimationType get(final int i) {
|
||||
return values()[i];
|
||||
}
|
||||
|
||||
public final int getIndex() {
|
||||
for (int i = 0; i < values().length; i++) {
|
||||
final EntityAnimationType curType = values()[0];
|
||||
if (curType == this) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
package io.github.retrooper.packetevents.enums.minecraft;
|
||||
|
||||
public enum EntityUseAction {
|
||||
INTERACT, INTERACT_AT, ATTACK, INVALID;
|
||||
|
||||
public static EntityUseAction get(final int i) {
|
||||
return values()[i];
|
||||
}
|
||||
}
|
||||
@@ -1,6 +0,0 @@
|
||||
package io.github.retrooper.packetevents.enums.minecraft;
|
||||
|
||||
public enum Hand {
|
||||
MAIN_HAND,
|
||||
OFF_HAND
|
||||
}
|
||||
@@ -1,59 +0,0 @@
|
||||
package io.github.retrooper.packetevents.enums.minecraft;
|
||||
|
||||
public enum PlayerAction {
|
||||
START_SNEAKING,
|
||||
|
||||
STOP_SNEAKING,
|
||||
|
||||
STOP_SLEEPING,
|
||||
|
||||
START_SPRINTING,
|
||||
|
||||
STOP_SPRINTING,
|
||||
|
||||
START_RIDING_JUMP,
|
||||
|
||||
STOP_RIDING_JUMP,
|
||||
|
||||
OPEN_INVENTORY,
|
||||
|
||||
START_FALL_FLYING;
|
||||
|
||||
public static PlayerAction get(final int i) {
|
||||
return values()[i];
|
||||
}
|
||||
|
||||
public int getIndex() {
|
||||
for (int i = 0; i < values().length; i++) {
|
||||
final PlayerAction action = values()[i];
|
||||
if (action == this) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
public enum UpdatedPlayerAction {
|
||||
PRESS_SHIFT_KEY, RELEASE_SHIFT_KEY, STOP_SLEEPING, START_SPRINTING, STOP_SPRINTING, START_RIDING_JUMP, STOP_RIDING_JUMP, OPEN_INVENTORY, START_FALL_FLYING;
|
||||
|
||||
public static UpdatedPlayerAction get(final int index) {
|
||||
for (int i = 0; i < index + 1; i++) {
|
||||
final UpdatedPlayerAction action = values()[i];
|
||||
if (i == index) {
|
||||
return action;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public int getIndex() {
|
||||
for (int i = 0; i < values().length; i++) {
|
||||
final UpdatedPlayerAction action = values()[i];
|
||||
if (action == this) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,26 +0,0 @@
|
||||
package io.github.retrooper.packetevents.enums.minecraft;
|
||||
|
||||
public enum PlayerDigType {
|
||||
|
||||
START_DESTROY_BLOCK,
|
||||
|
||||
ABORT_DESTROY_BLOCK,
|
||||
|
||||
STOP_DESTROY_BLOCK,
|
||||
|
||||
DROP_ALL_ITEMS,
|
||||
|
||||
DROP_ITEM,
|
||||
|
||||
RELEASE_USE_ITEM,
|
||||
|
||||
SWAP_HELD_ITEMS,
|
||||
|
||||
SWAP_ITEM_WITH_OFFHAND,
|
||||
|
||||
WRONG_PACKET;
|
||||
|
||||
public static PlayerDigType get(final int i) {
|
||||
return values()[i];
|
||||
}
|
||||
}
|
||||
@@ -1,11 +1,13 @@
|
||||
/**
|
||||
* Copyright (c) 2020 retrooper
|
||||
*/
|
||||
package io.github.retrooper.packetevents.event;
|
||||
|
||||
|
||||
import io.github.retrooper.packetevents.PacketEvents;
|
||||
import io.github.retrooper.packetevents.enums.ServerVersion;
|
||||
|
||||
public class PacketEvent {
|
||||
protected static ServerVersion version = ServerVersion.getVersion();
|
||||
public abstract class PacketEvent {
|
||||
public static ServerVersion version;
|
||||
private long timestamp = System.currentTimeMillis();
|
||||
|
||||
/**
|
||||
@@ -20,4 +22,6 @@ public class PacketEvent {
|
||||
public void setTimestamp(long timestamp) {
|
||||
this.timestamp = timestamp;
|
||||
}
|
||||
|
||||
public abstract boolean isAsyncByDefault();
|
||||
}
|
||||
@@ -1,3 +1,6 @@
|
||||
/**
|
||||
* Copyright (c) 2020 retrooper
|
||||
*/
|
||||
package io.github.retrooper.packetevents.event;
|
||||
|
||||
public interface PacketListener {
|
||||
|
||||
@@ -1,3 +1,6 @@
|
||||
/**
|
||||
* Copyright (c) 2020 retrooper
|
||||
*/
|
||||
package io.github.retrooper.packetevents.event.impl;
|
||||
|
||||
import io.github.retrooper.packetevents.event.PacketEvent;
|
||||
@@ -8,6 +11,7 @@ import org.bukkit.event.player.PlayerMoveEvent;
|
||||
public final class BukkitMoveEvent extends PacketEvent {
|
||||
private final Player player;
|
||||
private final Location to, from;
|
||||
private boolean cancelled;
|
||||
|
||||
public BukkitMoveEvent(final Player player, final Location to, final Location from) {
|
||||
this.player = player;
|
||||
@@ -32,4 +36,21 @@ public final class BukkitMoveEvent extends PacketEvent {
|
||||
public Location getTo() {
|
||||
return to;
|
||||
}
|
||||
|
||||
public boolean isCancelled() {
|
||||
return cancelled;
|
||||
}
|
||||
|
||||
public void setCancelled(final boolean val) {
|
||||
this.cancelled = val;
|
||||
}
|
||||
|
||||
public void cancel() {
|
||||
setCancelled(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAsyncByDefault() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -1,3 +1,6 @@
|
||||
/**
|
||||
* Copyright (c) 2020 retrooper
|
||||
*/
|
||||
package io.github.retrooper.packetevents.event.impl;
|
||||
|
||||
import io.github.retrooper.packetevents.event.PacketEvent;
|
||||
@@ -6,13 +9,11 @@ import org.bukkit.entity.Player;
|
||||
|
||||
public final class PacketReceiveEvent extends PacketEvent {
|
||||
private final Player player;
|
||||
private final String name;
|
||||
private final Object packet;
|
||||
private boolean cancelled;
|
||||
|
||||
public PacketReceiveEvent(final Player player, final String packetName, final Object packet) {
|
||||
public PacketReceiveEvent(final Player player, final Object packet) {
|
||||
this.player = player;
|
||||
this.name = packetName;
|
||||
this.packet = packet;
|
||||
}
|
||||
|
||||
@@ -26,12 +27,12 @@ public final class PacketReceiveEvent extends PacketEvent {
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the packet's name (NMS packet class simple name)
|
||||
*
|
||||
* @return
|
||||
* Get the packet's name (NMS packet class simple name).
|
||||
* Deprecated, it is recommended not to use this for performance reasons.
|
||||
*/
|
||||
@Deprecated
|
||||
public String getPacketName() {
|
||||
return this.name;
|
||||
return this.packet.getClass().getSimpleName();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -45,11 +46,13 @@ public final class PacketReceiveEvent extends PacketEvent {
|
||||
|
||||
/**
|
||||
* Get the class of the NMS packet object
|
||||
* Deprecated, as it is useless, rather use getNMSPacket().getClass()
|
||||
*
|
||||
* @return packet object class
|
||||
*/
|
||||
@Deprecated
|
||||
public Class<?> getNMSPacketClass() {
|
||||
return getNMSPacket().getClass();
|
||||
return packet.getClass();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -58,11 +61,7 @@ public final class PacketReceiveEvent extends PacketEvent {
|
||||
* @return packet id
|
||||
*/
|
||||
public byte getPacketId() {
|
||||
Byte id = PacketType.Client.packetIds.get(getNMSPacketClass());
|
||||
if (id == null) {
|
||||
return -1;
|
||||
}
|
||||
return id;
|
||||
return PacketType.Client.packetIds.getOrDefault(packet.getClass(), (byte) -1);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -82,4 +81,9 @@ public final class PacketReceiveEvent extends PacketEvent {
|
||||
public void setCancelled(boolean cancelled) {
|
||||
this.cancelled = cancelled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAsyncByDefault() {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -1,3 +1,6 @@
|
||||
/**
|
||||
* Copyright (c) 2020 retrooper
|
||||
*/
|
||||
package io.github.retrooper.packetevents.event.impl;
|
||||
|
||||
import io.github.retrooper.packetevents.event.PacketEvent;
|
||||
@@ -7,13 +10,11 @@ import org.bukkit.entity.Player;
|
||||
|
||||
public final class PacketSendEvent extends PacketEvent {
|
||||
private final Player player;
|
||||
private final String name;
|
||||
private final Object packet;
|
||||
private boolean cancelled;
|
||||
|
||||
public PacketSendEvent(final Player player, final String packetName, final Object packet) {
|
||||
public PacketSendEvent(final Player player, final Object packet) {
|
||||
this.player = player;
|
||||
this.name = packetName;
|
||||
this.packet = packet;
|
||||
this.cancelled = false;
|
||||
}
|
||||
@@ -23,8 +24,13 @@ public final class PacketSendEvent extends PacketEvent {
|
||||
return this.player;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the packet's name (NMS packet class simple name)
|
||||
* Deprecated, it is recommended not to use this for performance reasons.
|
||||
*/
|
||||
@Deprecated
|
||||
public String getPacketName() {
|
||||
return this.name;
|
||||
return this.packet.getClass().getSimpleName();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -33,12 +39,7 @@ public final class PacketSendEvent extends PacketEvent {
|
||||
* @return packet id
|
||||
*/
|
||||
public byte getPacketId() {
|
||||
Byte id =
|
||||
PacketType.Server.packetIds.get(getNMSPacketClass());
|
||||
if (id == null) {
|
||||
return -1;
|
||||
}
|
||||
return id;
|
||||
return PacketType.Server.packetIds.getOrDefault(packet.getClass(), (byte) -1);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -51,12 +52,14 @@ public final class PacketSendEvent extends PacketEvent {
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the class of the NMS packet object
|
||||
* Get the class of the NMS packet object.
|
||||
* Deprecated because it is useless, rather use getNMSPacket().getClass().
|
||||
*
|
||||
* @return packet object class
|
||||
*/
|
||||
@Deprecated
|
||||
public Class<?> getNMSPacketClass() {
|
||||
return getNMSPacket().getClass();
|
||||
return packet.getClass();
|
||||
}
|
||||
|
||||
public boolean isCancelled() {
|
||||
@@ -66,5 +69,10 @@ public final class PacketSendEvent extends PacketEvent {
|
||||
public void setCancelled(boolean cancelled) {
|
||||
this.cancelled = cancelled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAsyncByDefault() {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,18 +1,17 @@
|
||||
/**
|
||||
* Copyright (c) 2020 retrooper
|
||||
*/
|
||||
package io.github.retrooper.packetevents.event.impl;
|
||||
|
||||
import io.github.retrooper.packetevents.enums.ClientVersion;
|
||||
import io.github.retrooper.packetevents.event.PacketEvent;
|
||||
import io.github.retrooper.packetevents.utils.versionlookup.VersionLookupUtils;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public final class PlayerInjectEvent extends PacketEvent {
|
||||
private final Player player;
|
||||
private final ClientVersion clientVersion;
|
||||
private boolean cancelled;
|
||||
|
||||
public PlayerInjectEvent(final Player player) {
|
||||
this.player = player;
|
||||
this.clientVersion = ClientVersion.fromProtocolVersion(VersionLookupUtils.getProtocolVersion(player));
|
||||
}
|
||||
|
||||
public boolean isCancelled() {
|
||||
@@ -27,11 +26,12 @@ public final class PlayerInjectEvent extends PacketEvent {
|
||||
setCancelled(true);
|
||||
}
|
||||
|
||||
public ClientVersion getClientVersion() {
|
||||
return clientVersion;
|
||||
}
|
||||
|
||||
public Player getPlayer() {
|
||||
return player;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAsyncByDefault() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -1,3 +1,6 @@
|
||||
/**
|
||||
* Copyright (c) 2020 retrooper
|
||||
*/
|
||||
package io.github.retrooper.packetevents.event.impl;
|
||||
|
||||
import io.github.retrooper.packetevents.event.PacketEvent;
|
||||
@@ -5,10 +8,18 @@ import org.bukkit.entity.Player;
|
||||
|
||||
public final class PlayerUninjectEvent extends PacketEvent {
|
||||
private final Player player;
|
||||
private final boolean sync;
|
||||
private boolean cancelled;
|
||||
|
||||
@Deprecated
|
||||
public PlayerUninjectEvent(final Player player, @Deprecated final boolean sync) {
|
||||
this.player = player;
|
||||
this.sync = sync;
|
||||
}
|
||||
|
||||
public PlayerUninjectEvent(final Player player) {
|
||||
this.player = player;
|
||||
this.sync = true;
|
||||
}
|
||||
|
||||
public void cancel() {
|
||||
@@ -23,7 +34,25 @@ public final class PlayerUninjectEvent extends PacketEvent {
|
||||
this.cancelled = val;
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether the uninjection was called synchronously or asynchronously.
|
||||
* The event is still called synchronously.
|
||||
* By default all uninjections are called aynchronously in this build.
|
||||
*
|
||||
* @return If the uninjection was done async or sync
|
||||
* @deprecated because it is unneeded
|
||||
*/
|
||||
@Deprecated
|
||||
public boolean isSync() {
|
||||
return sync;
|
||||
}
|
||||
|
||||
public Player getPlayer() {
|
||||
return player;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAsyncByDefault() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -1,34 +1,24 @@
|
||||
/**
|
||||
* Copyright (c) 2020 retrooper
|
||||
*/
|
||||
package io.github.retrooper.packetevents.event.manager;
|
||||
|
||||
import io.github.retrooper.packetevents.PacketEvents;
|
||||
import io.github.retrooper.packetevents.annotations.PacketHandler;
|
||||
import io.github.retrooper.packetevents.annotations.data.EventSynchronization;
|
||||
import io.github.retrooper.packetevents.event.PacketEvent;
|
||||
import io.github.retrooper.packetevents.event.PacketListener;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
||||
|
||||
public final class EventManager {
|
||||
private final ExecutorService executorService;
|
||||
private final HashMap<PacketListener, List<Method>> registeredMethods = new HashMap<PacketListener, List<Method>>();
|
||||
|
||||
public EventManager(final int threadCount) {
|
||||
executorService = Executors.newFixedThreadPool(threadCount);
|
||||
}
|
||||
|
||||
public EventManager() {
|
||||
this(Runtime.getRuntime().availableProcessors());
|
||||
}
|
||||
|
||||
public void callEvent(final PacketEvent e, final Plugin plugin) {
|
||||
public void callEvent(final PacketEvent e) {
|
||||
for (final PacketListener listener : registeredMethods.keySet()) {
|
||||
//Annotated methods
|
||||
final List<Method> methods = registeredMethods.get(listener);
|
||||
@@ -47,12 +37,21 @@ public final class EventManager {
|
||||
}
|
||||
}
|
||||
};
|
||||
if (annotation.synchronization() == EventSynchronization.FORCE_ASYNC) {
|
||||
executorService.execute(invokeMethod);
|
||||
} else if (annotation.synchronization() == EventSynchronization.FORCE_SYNC) {
|
||||
Bukkit.getScheduler().runTask(plugin, invokeMethod);
|
||||
} else {
|
||||
invokeMethod.run();
|
||||
|
||||
switch (annotation.synchronization()) {
|
||||
case FORCE_ASYNC:
|
||||
Bukkit.getScheduler().runTaskAsynchronously(PacketEvents.getPlugin(), invokeMethod);
|
||||
break;
|
||||
case FORCE_SYNC:
|
||||
Bukkit.getScheduler().runTask(PacketEvents.getPlugin(), invokeMethod);
|
||||
break;
|
||||
default:
|
||||
try {
|
||||
method.invoke(listener, e);
|
||||
} catch (IllegalAccessException | InvocationTargetException ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,13 +1,15 @@
|
||||
/**
|
||||
* Copyright (c) 2020 retrooper
|
||||
*/
|
||||
package io.github.retrooper.packetevents.example;
|
||||
|
||||
import io.github.retrooper.packetevents.PacketEvents;
|
||||
import io.github.retrooper.packetevents.annotations.PacketHandler;
|
||||
import io.github.retrooper.packetevents.enums.ServerVersion;
|
||||
import io.github.retrooper.packetevents.event.PacketListener;
|
||||
import io.github.retrooper.packetevents.event.impl.PlayerInjectEvent;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
public class MainExample extends JavaPlugin implements PacketListener {
|
||||
private final PacketEvents pe = new PacketEvents(this);
|
||||
|
||||
@Override
|
||||
public void onLoad() {
|
||||
PacketEvents.load();
|
||||
@@ -15,21 +17,16 @@ public class MainExample extends JavaPlugin implements PacketListener {
|
||||
|
||||
@Override
|
||||
public void onEnable() {
|
||||
pe.start();
|
||||
//If packetevents cannot detect your server version, it will use the recommended version
|
||||
// getAPI().getSettings().setDefaultServerVersion(ServerVersion.v_1_7_10);
|
||||
PacketEvents.getSettings().setIdentifier("packetevents_api");
|
||||
|
||||
pe.getAPI().getEventManager().registerListeners(this);
|
||||
PacketEvents.getSettings().setDefaultServerVersion(ServerVersion.v_1_7_10);
|
||||
|
||||
PacketEvents.start(this);
|
||||
//PacketEvents.getAPI().getEventManager().registerListener(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDisable() {
|
||||
pe.stop();
|
||||
}
|
||||
|
||||
@PacketHandler
|
||||
public void onInject(PlayerInjectEvent e) {
|
||||
e.getPlayer().sendMessage("you have been injected");
|
||||
System.out.println("he has been injected");
|
||||
PacketEvents.stop();
|
||||
}
|
||||
}
|
||||
@@ -1,3 +1,6 @@
|
||||
/**
|
||||
* Copyright (c) 2020 retrooper
|
||||
*/
|
||||
package io.github.retrooper.packetevents.handler;
|
||||
|
||||
import io.github.retrooper.packetevents.PacketEvents;
|
||||
@@ -10,7 +13,6 @@ import org.bukkit.entity.Player;
|
||||
import java.util.concurrent.Future;
|
||||
|
||||
public class NettyPacketHandler {
|
||||
public static final String handlerName = "packet_handler";
|
||||
private static boolean v1_7_nettyMode = false;
|
||||
|
||||
static {
|
||||
@@ -21,45 +23,46 @@ public class NettyPacketHandler {
|
||||
}
|
||||
}
|
||||
|
||||
public static void injectPlayer(final Player player, PacketEvents pe) {
|
||||
public static void injectPlayer(final Player player) {
|
||||
final PlayerInjectEvent injectEvent = new PlayerInjectEvent(player);
|
||||
pe.getAPI().getEventManager().callEvent(injectEvent, pe.getPlugin());
|
||||
PacketEvents.getAPI().getEventManager().callEvent(injectEvent);
|
||||
if (!injectEvent.isCancelled()) {
|
||||
if (v1_7_nettyMode) {
|
||||
NettyPacketHandler_7.injectPlayer(player, pe);
|
||||
NettyPacketHandler_7.injectPlayer(player);
|
||||
} else {
|
||||
NettyPacketHandler_8.injectPlayer(player, pe);
|
||||
NettyPacketHandler_8.injectPlayer(player);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static Future<?> uninjectPlayer(final Player player, PacketEvents pe) {
|
||||
final PlayerUninjectEvent uninjectEvent = new PlayerUninjectEvent(player);
|
||||
pe.getAPI().getEventManager().callEvent(uninjectEvent, pe.getPlugin());
|
||||
if (!uninjectEvent.isCancelled()) {
|
||||
if (v1_7_nettyMode) {
|
||||
return NettyPacketHandler_7.uninjectPlayer(player);
|
||||
} else {
|
||||
return NettyPacketHandler_8.uninjectPlayer(player);
|
||||
public static void uninjectPlayer(final Player player) {
|
||||
try {
|
||||
final PlayerUninjectEvent uninjectEvent = new PlayerUninjectEvent(player);
|
||||
PacketEvents.getAPI().getEventManager().callEvent(uninjectEvent);
|
||||
if (!uninjectEvent.isCancelled()) {
|
||||
if (v1_7_nettyMode) {
|
||||
NettyPacketHandler_7.uninjectPlayer(player);
|
||||
} else {
|
||||
NettyPacketHandler_8.uninjectPlayer(player);
|
||||
}
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
//Failed, but that is alright
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static Object write(final Player sender, final Object packet, PacketEvents pe) {
|
||||
final String packetName = packet.getClass().getSimpleName();
|
||||
final PacketSendEvent packetSendEvent = new PacketSendEvent(sender, packetName, packet);
|
||||
pe.getAPI().getEventManager().callEvent(packetSendEvent, pe.getPlugin());
|
||||
public static Object write(final Player sender, final Object packet) {
|
||||
final PacketSendEvent packetSendEvent = new PacketSendEvent(sender, packet);
|
||||
PacketEvents.getAPI().getEventManager().callEvent(packetSendEvent);
|
||||
if (!packetSendEvent.isCancelled()) {
|
||||
return packet;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static Object read(final Player receiver, final Object packet, PacketEvents pe) {
|
||||
final String packetName = packet.getClass().getSimpleName();
|
||||
final PacketReceiveEvent packetReceiveEvent = new PacketReceiveEvent(receiver, packetName, packet);
|
||||
pe.getAPI().getEventManager().callEvent(packetReceiveEvent, pe.getPlugin());
|
||||
public static Object read(final Player receiver, final Object packet) {
|
||||
final PacketReceiveEvent packetReceiveEvent = new PacketReceiveEvent(receiver, packet);
|
||||
PacketEvents.getAPI().getEventManager().callEvent(packetReceiveEvent);
|
||||
if (!packetReceiveEvent.isCancelled()) {
|
||||
return packet;
|
||||
}
|
||||
|
||||
@@ -1,3 +1,6 @@
|
||||
/**
|
||||
* Copyright (c) 2020 retrooper
|
||||
*/
|
||||
package io.github.retrooper.packetevents.handler;
|
||||
|
||||
import io.github.retrooper.packetevents.PacketEvents;
|
||||
@@ -9,11 +12,11 @@ import java.util.concurrent.Future;
|
||||
|
||||
final class NettyPacketHandler_7 {
|
||||
|
||||
public static void injectPlayer(final Player player, final PacketEvents pe) {
|
||||
public static void injectPlayer(final Player player) {
|
||||
final ChannelDuplexHandler channelDuplexHandler = new ChannelDuplexHandler() {
|
||||
@Override
|
||||
public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception {
|
||||
Object packet = NettyPacketHandler.read(player, msg, pe);
|
||||
Object packet = NettyPacketHandler.read(player, msg);
|
||||
if (packet == null) {
|
||||
return;
|
||||
}
|
||||
@@ -22,7 +25,7 @@ final class NettyPacketHandler_7 {
|
||||
|
||||
@Override
|
||||
public void write(ChannelHandlerContext ctx, Object msg, ChannelPromise promise) throws Exception {
|
||||
Object packet = NettyPacketHandler.write(player, msg, pe);
|
||||
Object packet = NettyPacketHandler.write(player, msg);
|
||||
if (packet == null) {
|
||||
return;
|
||||
}
|
||||
@@ -30,16 +33,12 @@ final class NettyPacketHandler_7 {
|
||||
}
|
||||
};
|
||||
final ChannelPipeline pipeline = ((Channel) NMSUtils.getChannel(player)).pipeline();
|
||||
pipeline.addBefore(pe.getHandlerName(), player.getName(), channelDuplexHandler);
|
||||
pipeline.addBefore("packet_handler", PacketEvents.getHandlerName(player.getName()), channelDuplexHandler);
|
||||
}
|
||||
|
||||
public static Future<?> uninjectPlayer(final Player player) {
|
||||
public static void uninjectPlayer(final Player player) {
|
||||
final Channel channel = (Channel) NMSUtils.getChannel(player);
|
||||
return channel.eventLoop().submit(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
channel.pipeline().remove(player.getName());
|
||||
}
|
||||
});
|
||||
channel.pipeline().remove(PacketEvents.getHandlerName(player.getName()));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,7 +1,9 @@
|
||||
/**
|
||||
* Copyright (c) 2020 retrooper
|
||||
*/
|
||||
package io.github.retrooper.packetevents.handler;
|
||||
|
||||
import io.github.retrooper.packetevents.PacketEvents;
|
||||
import io.github.retrooper.packetevents.enums.ServerVersion;
|
||||
import io.github.retrooper.packetevents.utils.NMSUtils;
|
||||
import io.netty.channel.*;
|
||||
import org.bukkit.entity.Player;
|
||||
@@ -10,11 +12,11 @@ import java.util.concurrent.Future;
|
||||
|
||||
final class NettyPacketHandler_8 {
|
||||
|
||||
public static void injectPlayer(final Player player, final PacketEvents pe) {
|
||||
public static void injectPlayer(final Player player) {
|
||||
final ChannelDuplexHandler channelDuplexHandler = new ChannelDuplexHandler() {
|
||||
@Override
|
||||
public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception {
|
||||
Object packet = NettyPacketHandler.read(player, msg, pe);
|
||||
Object packet = NettyPacketHandler.read(player, msg);
|
||||
if (packet == null) {
|
||||
return;
|
||||
}
|
||||
@@ -23,7 +25,7 @@ final class NettyPacketHandler_8 {
|
||||
|
||||
@Override
|
||||
public void write(ChannelHandlerContext ctx, Object msg, ChannelPromise promise) throws Exception {
|
||||
Object packet = NettyPacketHandler.write(player, msg, pe);
|
||||
Object packet = NettyPacketHandler.write(player, msg);
|
||||
if (packet == null) {
|
||||
return;
|
||||
}
|
||||
@@ -31,16 +33,11 @@ final class NettyPacketHandler_8 {
|
||||
}
|
||||
};
|
||||
final ChannelPipeline pipeline = ((Channel) NMSUtils.getChannel(player)).pipeline();
|
||||
pipeline.addBefore(pe.getHandlerName(), player.getName(), channelDuplexHandler);
|
||||
pipeline.addBefore("packet_handler", PacketEvents.getHandlerName(player.getName()), channelDuplexHandler);
|
||||
}
|
||||
|
||||
public static Future<?> uninjectPlayer(final Player player) {
|
||||
public static void uninjectPlayer(final Player player) {
|
||||
final Channel channel = (Channel) NMSUtils.getChannel(player);
|
||||
return channel.eventLoop().submit(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
channel.pipeline().remove(player.getName());
|
||||
}
|
||||
});
|
||||
channel.pipeline().remove(PacketEvents.getHandlerName(player.getName()));
|
||||
}
|
||||
}
|
||||
@@ -1,3 +1,6 @@
|
||||
/**
|
||||
* Copyright (c) 2020 retrooper
|
||||
*/
|
||||
package io.github.retrooper.packetevents.packet;
|
||||
|
||||
import java.util.HashMap;
|
||||
@@ -5,19 +8,8 @@ import java.util.Map;
|
||||
|
||||
public class PacketType {
|
||||
|
||||
|
||||
public static class Client {
|
||||
public static class Util {
|
||||
public static boolean isInstanceOfFlying(final byte packetId) {
|
||||
return packetId == FLYING
|
||||
|| packetId == POSITION
|
||||
|| packetId == POSITION_LOOK
|
||||
|| packetId == LOOK;
|
||||
}
|
||||
}
|
||||
|
||||
public static final Map<Class<?>, Byte> packetIds = new HashMap<Class<?>, Byte>();
|
||||
|
||||
public static final byte TELEPORT_ACCEPT = 0,
|
||||
TILE_NBT_QUERY = 1, DIFFICULTY_CHANGE = 2, CHAT = 3, CLIENT_COMMAND = 4,
|
||||
SETTINGS = 5, TAB_COMPLETE = 6, TRANSACTION = 7, ENCHANT_ITEM = 8,
|
||||
@@ -81,6 +73,15 @@ public class PacketType {
|
||||
packetIds.put(PacketTypeClasses.Client.USE_ITEM, USE_ITEM);
|
||||
packetIds.put(PacketTypeClasses.Client.BLOCK_PLACE, BLOCK_PLACE);
|
||||
}
|
||||
|
||||
public static class Util {
|
||||
public static boolean isInstanceOfFlying(final byte packetId) {
|
||||
return packetId == FLYING
|
||||
|| packetId == POSITION
|
||||
|| packetId == POSITION_LOOK
|
||||
|| packetId == LOOK;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static class Server {
|
||||
@@ -205,6 +206,13 @@ public class PacketType {
|
||||
packetIds.put(PacketTypeClasses.Server.TAGS, TAGS);
|
||||
packetIds.put(PacketTypeClasses.Server.MAP_CHUNK_BULK, MAP_CHUNK_BULK);
|
||||
}
|
||||
|
||||
public static class Util {
|
||||
public static boolean isInstanceOfEntity(final byte packetId) {
|
||||
return packetId == ENTITY || packetId == REL_ENTITY_MOVE ||
|
||||
packetId == REL_ENTITY_MOVE_LOOK || packetId == ENTITY_LOOK;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1,3 +1,6 @@
|
||||
/**
|
||||
* Copyright (c) 2020 retrooper
|
||||
*/
|
||||
package io.github.retrooper.packetevents.packet;
|
||||
|
||||
import io.github.retrooper.packetevents.annotations.Nullable;
|
||||
@@ -6,6 +9,10 @@ import io.github.retrooper.packetevents.utils.NMSUtils;
|
||||
|
||||
public class PacketTypeClasses {
|
||||
public static class Client {
|
||||
private static final String c = "PacketPlayIn";
|
||||
@Nullable
|
||||
public static Class<?> FLYING;
|
||||
|
||||
public static Class<?> POSITION, POSITION_LOOK, LOOK, CLIENT_COMMAND,
|
||||
TRANSACTION, BLOCK_DIG, ENTITY_ACTION, USE_ENTITY,
|
||||
WINDOW_CLICK, STEER_VEHICLE, CUSTOM_PAYLOAD, ARM_ANIMATION,
|
||||
@@ -17,11 +24,9 @@ public class PacketTypeClasses {
|
||||
AUTO_RECIPE, RECIPE_DISPLAYED, ITEM_NAME, RESOURCE_PACK_STATUS,
|
||||
ADVANCEMENTS, TR_SEL, BEACON, SET_COMMAND_BLOCK,
|
||||
SET_COMMAND_MINECART, SET_JIGSAW, STRUCT, UPDATE_SIGN, SPECTATE;
|
||||
private static final String c = "PacketPlayIn";
|
||||
@Nullable
|
||||
public static final Class<?> FLYING = NMSUtils.getNMSClassWithoutException(c + "Flying");
|
||||
|
||||
public static void load() {
|
||||
FLYING = NMSUtils.getNMSClassWithoutException(c + "Flying");
|
||||
try {
|
||||
POSITION = NMSUtils.getNMSClass(c + "Position");
|
||||
POSITION_LOOK = NMSUtils.getNMSClass(c + "PositionLook");
|
||||
@@ -94,10 +99,8 @@ public class PacketTypeClasses {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
PacketType.Client.init();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static class Server {
|
||||
|
||||
@@ -1,3 +1,6 @@
|
||||
/**
|
||||
* Copyright (c) 2020 retrooper
|
||||
*/
|
||||
package io.github.retrooper.packetevents.packetwrappers;
|
||||
|
||||
public interface Sendable {
|
||||
|
||||
+67
-1
@@ -1,13 +1,47 @@
|
||||
/**
|
||||
* Copyright (c) 2020 retrooper
|
||||
*/
|
||||
package io.github.retrooper.packetevents.packetwrappers.api;
|
||||
|
||||
import io.github.retrooper.packetevents.enums.ServerVersion;
|
||||
import io.github.retrooper.packetevents.packetwrappers.in.abilities.WrappedPacketInAbilities;
|
||||
import io.github.retrooper.packetevents.packetwrappers.in.armanimation.WrappedPacketInArmAnimation;
|
||||
import io.github.retrooper.packetevents.packetwrappers.in.blockdig.WrappedPacketInBlockDig;
|
||||
import io.github.retrooper.packetevents.packetwrappers.in.blockplace.WrappedPacketInBlockPlace;
|
||||
import io.github.retrooper.packetevents.packetwrappers.in.chat.WrappedPacketInChat;
|
||||
import io.github.retrooper.packetevents.packetwrappers.in.clientcommand.WrappedPacketInClientCommand;
|
||||
import io.github.retrooper.packetevents.packetwrappers.in.custompayload.WrappedPacketInCustomPayload;
|
||||
import io.github.retrooper.packetevents.packetwrappers.in.entityaction.WrappedPacketInEntityAction;
|
||||
import io.github.retrooper.packetevents.packetwrappers.in.flying.WrappedPacketInFlying;
|
||||
import io.github.retrooper.packetevents.packetwrappers.in.helditemslot.WrappedPacketInHeldItemSlot;
|
||||
import io.github.retrooper.packetevents.packetwrappers.in.keepalive.WrappedPacketInKeepAlive;
|
||||
import io.github.retrooper.packetevents.packetwrappers.in.settings.WrappedPacketInSettings;
|
||||
import io.github.retrooper.packetevents.packetwrappers.in.steervehicle.WrappedPacketInSteerVehicle;
|
||||
import io.github.retrooper.packetevents.packetwrappers.in.transaction.WrappedPacketInTransaction;
|
||||
import io.github.retrooper.packetevents.packetwrappers.in.useentity.WrappedPacketInUseEntity;
|
||||
import io.github.retrooper.packetevents.packetwrappers.in.windowclick.WrappedPacketInWindowClick;
|
||||
import io.github.retrooper.packetevents.packetwrappers.out.abilities.WrappedPacketOutAbilities;
|
||||
import io.github.retrooper.packetevents.packetwrappers.out.animation.WrappedPacketOutAnimation;
|
||||
import io.github.retrooper.packetevents.packetwrappers.out.chat.WrappedPacketOutChat;
|
||||
import io.github.retrooper.packetevents.packetwrappers.out.entity.WrappedPacketOutEntity;
|
||||
import io.github.retrooper.packetevents.packetwrappers.out.entityvelocity.WrappedPacketOutEntityVelocity;
|
||||
import io.github.retrooper.packetevents.packetwrappers.out.keepalive.WrappedPacketOutKeepAlive;
|
||||
import io.github.retrooper.packetevents.packetwrappers.out.kickdisconnect.WrappedPacketOutKickDisconnect;
|
||||
import io.github.retrooper.packetevents.packetwrappers.out.position.WrappedPacketOutPosition;
|
||||
import io.github.retrooper.packetevents.packetwrappers.out.transaction.WrappedPacketOutTransaction;
|
||||
import io.github.retrooper.packetevents.packetwrappers.out.updatehealth.WrappedPacketOutUpdateHealth;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class WrappedPacket {
|
||||
protected static ServerVersion version = ServerVersion.getVersion();
|
||||
public static ServerVersion version = null;
|
||||
protected final Player player;
|
||||
protected Object packet;
|
||||
|
||||
public WrappedPacket() {
|
||||
this.player = null;
|
||||
this.packet = null;
|
||||
}
|
||||
|
||||
public WrappedPacket(final Object packet) {
|
||||
this.player = null;
|
||||
if (packet == null) return;
|
||||
@@ -30,6 +64,38 @@ public class WrappedPacket {
|
||||
}
|
||||
}
|
||||
|
||||
public static void loadAllWrappers() {
|
||||
//SERVER BOUND
|
||||
WrappedPacketInAbilities.load();
|
||||
WrappedPacketInArmAnimation.load();
|
||||
WrappedPacketInBlockDig.load();
|
||||
WrappedPacketInBlockPlace.load();
|
||||
WrappedPacketInChat.load();
|
||||
WrappedPacketInClientCommand.load();
|
||||
WrappedPacketInCustomPayload.load();
|
||||
WrappedPacketInEntityAction.load();
|
||||
WrappedPacketInFlying.load();
|
||||
WrappedPacketInHeldItemSlot.load();
|
||||
WrappedPacketInKeepAlive.load();
|
||||
WrappedPacketInSettings.load();
|
||||
WrappedPacketInSteerVehicle.load();
|
||||
WrappedPacketInTransaction.load();
|
||||
WrappedPacketInUseEntity.load();
|
||||
WrappedPacketInWindowClick.load();
|
||||
|
||||
//CLIENTBOUND
|
||||
WrappedPacketOutAbilities.load();
|
||||
WrappedPacketOutAnimation.load();
|
||||
WrappedPacketOutChat.load();
|
||||
WrappedPacketOutEntity.load();
|
||||
WrappedPacketOutEntityVelocity.load();
|
||||
WrappedPacketOutKeepAlive.load();
|
||||
WrappedPacketOutKickDisconnect.load();
|
||||
WrappedPacketOutPosition.load();
|
||||
WrappedPacketOutTransaction.load();
|
||||
WrappedPacketOutUpdateHealth.load();
|
||||
}
|
||||
|
||||
protected void setup() {
|
||||
|
||||
}
|
||||
|
||||
+51
-23
@@ -1,47 +1,55 @@
|
||||
/**
|
||||
* Copyright (c) 2020 retrooper
|
||||
*/
|
||||
package io.github.retrooper.packetevents.packetwrappers.in.abilities;
|
||||
|
||||
import io.github.retrooper.packetevents.annotations.Nullable;
|
||||
import io.github.retrooper.packetevents.packet.PacketTypeClasses;
|
||||
import io.github.retrooper.packetevents.packetwrappers.api.WrappedPacket;
|
||||
import io.github.retrooper.packetevents.reflectionutils.Reflection;
|
||||
import io.github.retrooper.packetevents.utils.NMSUtils;
|
||||
|
||||
public final class WrappedPacketInAbilities extends WrappedPacket {
|
||||
private static Class<?> abilitiesClass;
|
||||
|
||||
static {
|
||||
|
||||
try {
|
||||
abilitiesClass = NMSUtils.getNMSClass("PacketPlayInAbilities");
|
||||
} catch (ClassNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean isMoreThanOneBoolPresent;
|
||||
private boolean isVulnerable;
|
||||
private boolean isFlying;
|
||||
private boolean allowFly;
|
||||
private boolean instantBuild;
|
||||
private float flySpeed;
|
||||
private float walkSpeed;
|
||||
|
||||
public WrappedPacketInAbilities(Object packet) {
|
||||
super(packet);
|
||||
}
|
||||
|
||||
public static void load() {
|
||||
abilitiesClass = PacketTypeClasses.Client.ABILITIES;
|
||||
isMoreThanOneBoolPresent = Reflection.getField(abilitiesClass, boolean.class, 1) != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setup() {
|
||||
try {
|
||||
this.isVulnerable = Reflection.getField(abilitiesClass, boolean.class, 0).getBoolean(packet);
|
||||
this.isFlying = Reflection.getField(abilitiesClass, boolean.class, 1).getBoolean(packet);
|
||||
this.allowFly = Reflection.getField(abilitiesClass, boolean.class, 2).getBoolean(packet);
|
||||
this.instantBuild = Reflection.getField(abilitiesClass, boolean.class, 3).getBoolean(packet);
|
||||
this.flySpeed = Reflection.getField(abilitiesClass, float.class, 0).getFloat(packet);
|
||||
this.walkSpeed = Reflection.getField(abilitiesClass, float.class, 1).getFloat(packet);
|
||||
if (isMoreThanOneBoolPresent) {
|
||||
this.isVulnerable = Reflection.getField(abilitiesClass, boolean.class, 0).getBoolean(packet);
|
||||
this.isFlying = Reflection.getField(abilitiesClass, boolean.class, 1).getBoolean(packet);
|
||||
this.allowFly = Reflection.getField(abilitiesClass, boolean.class, 2).getBoolean(packet);
|
||||
this.instantBuild = Reflection.getField(abilitiesClass, boolean.class, 3).getBoolean(packet);
|
||||
this.flySpeed = Reflection.getField(abilitiesClass, float.class, 0).getFloat(packet);
|
||||
this.walkSpeed = Reflection.getField(abilitiesClass, float.class, 1).getFloat(packet);
|
||||
} else {
|
||||
this.isFlying = Reflection.getField(abilitiesClass, boolean.class, 0).getBoolean(packet);
|
||||
}
|
||||
} catch (IllegalAccessException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isVulnerable() {
|
||||
/**
|
||||
* This will return null if the server version is not available in 1.16.x and above
|
||||
*/
|
||||
@Deprecated
|
||||
@Nullable
|
||||
public Boolean isVulnerable() {
|
||||
return isVulnerable;
|
||||
}
|
||||
|
||||
@@ -49,19 +57,39 @@ public final class WrappedPacketInAbilities extends WrappedPacket {
|
||||
return isFlying;
|
||||
}
|
||||
|
||||
public boolean isFlightAllowed() {
|
||||
/**
|
||||
* This will return null if the server version is not available in 1.16.x and above
|
||||
*/
|
||||
@Deprecated
|
||||
@Nullable
|
||||
public Boolean isFlightAllowed() {
|
||||
return allowFly;
|
||||
}
|
||||
|
||||
public boolean canInstantlyBuild() {
|
||||
/**
|
||||
* This will return null if the server version is not available in 1.16.x and above
|
||||
*/
|
||||
@Deprecated
|
||||
@Nullable
|
||||
public Boolean canInstantlyBuild() {
|
||||
return instantBuild;
|
||||
}
|
||||
|
||||
public float getFlySpeed() {
|
||||
/**
|
||||
* This will return null if the server version is not available in 1.16.x and above
|
||||
*/
|
||||
@Deprecated
|
||||
@Nullable
|
||||
public Float getFlySpeed() {
|
||||
return flySpeed;
|
||||
}
|
||||
|
||||
public float getWalkSpeed() {
|
||||
/**
|
||||
* This will return null if the server version is not available in 1.16.x and above
|
||||
*/
|
||||
@Deprecated
|
||||
@Nullable
|
||||
public Float getWalkSpeed() {
|
||||
return walkSpeed;
|
||||
}
|
||||
}
|
||||
+26
@@ -0,0 +1,26 @@
|
||||
/**
|
||||
* Copyright (c) 2020 retrooper
|
||||
*/
|
||||
package io.github.retrooper.packetevents.packetwrappers.in.armanimation;
|
||||
|
||||
import io.github.retrooper.packetevents.packet.PacketTypeClasses;
|
||||
import io.github.retrooper.packetevents.packetwrappers.api.WrappedPacket;
|
||||
|
||||
@Deprecated
|
||||
public final class WrappedPacketInArmAnimation extends WrappedPacket {
|
||||
private static Class<?> packetClass;
|
||||
|
||||
public WrappedPacketInArmAnimation(Object packet) {
|
||||
super(packet);
|
||||
}
|
||||
|
||||
public static void load() {
|
||||
packetClass = PacketTypeClasses.Client.ARM_ANIMATION;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setup() {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
+58
-31
@@ -1,8 +1,11 @@
|
||||
/**
|
||||
* Copyright (c) 2020 retrooper
|
||||
*/
|
||||
package io.github.retrooper.packetevents.packetwrappers.in.blockdig;
|
||||
|
||||
import io.github.retrooper.packetevents.enums.Direction;
|
||||
import io.github.retrooper.packetevents.enums.ServerVersion;
|
||||
import io.github.retrooper.packetevents.enums.minecraft.PlayerDigType;
|
||||
import io.github.retrooper.packetevents.packet.PacketTypeClasses;
|
||||
import io.github.retrooper.packetevents.packetwrappers.api.WrappedPacket;
|
||||
import io.github.retrooper.packetevents.reflectionutils.Reflection;
|
||||
import io.github.retrooper.packetevents.utils.NMSUtils;
|
||||
@@ -10,11 +13,17 @@ import io.github.retrooper.packetevents.utils.vector.Vector3i;
|
||||
|
||||
public final class WrappedPacketInBlockDig extends WrappedPacket {
|
||||
private static Class<?> blockDigClass, blockPositionClass, enumDirectionClass, digTypeClass;
|
||||
private static boolean isVersionLowerThan_v_1_8;
|
||||
private Vector3i blockPosition;
|
||||
private Direction direction;
|
||||
private PlayerDigType digType;
|
||||
public WrappedPacketInBlockDig(Object packet) {
|
||||
super(packet);
|
||||
}
|
||||
|
||||
static {
|
||||
|
||||
public static void load() {
|
||||
blockDigClass = PacketTypeClasses.Client.BLOCK_DIG;
|
||||
try {
|
||||
blockDigClass = NMSUtils.getNMSClass("PacketPlayInBlockDig");
|
||||
if (version.isHigherThan(ServerVersion.v_1_7_10)) {
|
||||
blockPositionClass = NMSUtils.getNMSClass("BlockPosition");
|
||||
enumDirectionClass = NMSUtils.getNMSClass("EnumDirection");
|
||||
@@ -22,33 +31,31 @@ public final class WrappedPacketInBlockDig extends WrappedPacket {
|
||||
} catch (ClassNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
isVersionLowerThan_v_1_8 = version.isLowerThan(ServerVersion.v_1_8);
|
||||
|
||||
try {
|
||||
digTypeClass = NMSUtils.getNMSClass("EnumPlayerDigType");
|
||||
} catch (ClassNotFoundException e) {
|
||||
//It is probably a subclass
|
||||
digTypeClass = Reflection.getSubClass(blockDigClass, "EnumPlayerDigType");
|
||||
if (version != ServerVersion.v_1_7_10) {
|
||||
try {
|
||||
digTypeClass = NMSUtils.getNMSClass("EnumPlayerDigType");
|
||||
} catch (ClassNotFoundException e) {
|
||||
//It is probably a subclass
|
||||
digTypeClass = Reflection.getSubClass(blockDigClass, "EnumPlayerDigType");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private Vector3i blockPosition;
|
||||
private Direction direction;
|
||||
private PlayerDigType digType;
|
||||
|
||||
public WrappedPacketInBlockDig(Object packet) {
|
||||
super(packet);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setup() {
|
||||
Direction enumDirection = null;
|
||||
PlayerDigType enumDigType = null;
|
||||
int x = 0, y = 0, z = 0;
|
||||
//1.7.10
|
||||
try {
|
||||
if (version.isLowerThan(ServerVersion.v_1_8)) {
|
||||
setupCoordinates(blockDigClass, packet);
|
||||
enumDirection = Direction.get(Reflection.getField(digTypeClass, int.class, 3).getInt(packet));
|
||||
enumDigType = PlayerDigType.get(Reflection.getField(digTypeClass, int.class, 4).getInt(packet));
|
||||
if (isVersionLowerThan_v_1_8) {
|
||||
enumDigType = PlayerDigType.values()[(Reflection.getField(blockDigClass, int.class, 4).getInt(packet))];
|
||||
x = Reflection.getField(blockDigClass, int.class, 0).getInt(packet);
|
||||
y = Reflection.getField(blockDigClass, int.class, 1).getInt(packet);
|
||||
z = Reflection.getField(blockDigClass, int.class, 2).getInt(packet);
|
||||
enumDirection = null;
|
||||
} else {
|
||||
//1.8+
|
||||
final Object blockPosObj = Reflection.getField(blockDigClass, blockPositionClass, 0).get(packet);
|
||||
@@ -56,7 +63,9 @@ public final class WrappedPacketInBlockDig extends WrappedPacket {
|
||||
final Object digTypeObj = Reflection.getField(blockDigClass, digTypeClass, 0).get(packet);
|
||||
|
||||
Class<?> blockPosSuper = blockPositionClass;
|
||||
setupCoordinates(blockPosSuper, blockPosObj);
|
||||
x = Reflection.getField(blockPosSuper, int.class, 0).getInt(blockPosObj);
|
||||
y = Reflection.getField(blockPosSuper, int.class, 1).getInt(blockPosObj);
|
||||
z = Reflection.getField(blockPosSuper, int.class, 2).getInt(blockPosObj);
|
||||
|
||||
enumDirection = Direction.valueOf(((Enum) enumDirectionObj).name());
|
||||
enumDigType = PlayerDigType.valueOf(((Enum) digTypeObj).name());
|
||||
@@ -64,16 +73,13 @@ public final class WrappedPacketInBlockDig extends WrappedPacket {
|
||||
} catch (IllegalAccessException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
this.direction = enumDirection;
|
||||
this.digType = enumDigType;
|
||||
}
|
||||
|
||||
private void setupCoordinates(final Class<?> cls, final Object object) throws IllegalAccessException {
|
||||
final int x = Reflection.getField(cls, int.class, 0).getInt(object);
|
||||
final int y = Reflection.getField(cls, int.class, 1).getInt(object);
|
||||
final int z = Reflection.getField(cls, int.class, 2).getInt(object);
|
||||
|
||||
this.blockPosition = new Vector3i(x, y, z);
|
||||
if (enumDirection == null) {
|
||||
this.direction = Direction.NULL;
|
||||
} else {
|
||||
this.direction = enumDirection;
|
||||
}
|
||||
this.digType = enumDigType;
|
||||
}
|
||||
|
||||
public Vector3i getBlockPosition() {
|
||||
@@ -88,5 +94,26 @@ public final class WrappedPacketInBlockDig extends WrappedPacket {
|
||||
return digType;
|
||||
}
|
||||
|
||||
public enum PlayerDigType {
|
||||
|
||||
START_DESTROY_BLOCK,
|
||||
|
||||
ABORT_DESTROY_BLOCK,
|
||||
|
||||
STOP_DESTROY_BLOCK,
|
||||
|
||||
DROP_ALL_ITEMS,
|
||||
|
||||
DROP_ITEM,
|
||||
|
||||
RELEASE_USE_ITEM,
|
||||
|
||||
SWAP_HELD_ITEMS,
|
||||
|
||||
SWAP_ITEM_WITH_OFFHAND,
|
||||
|
||||
WRONG_PACKET
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
+17
-10
@@ -1,5 +1,9 @@
|
||||
/**
|
||||
* Copyright (c) 2020 retrooper
|
||||
*/
|
||||
package io.github.retrooper.packetevents.packetwrappers.in.blockplace;
|
||||
|
||||
import io.github.retrooper.packetevents.annotations.Nullable;
|
||||
import io.github.retrooper.packetevents.enums.ServerVersion;
|
||||
import io.github.retrooper.packetevents.packetwrappers.api.WrappedPacket;
|
||||
import io.github.retrooper.packetevents.utils.vector.Vector3i;
|
||||
@@ -9,38 +13,40 @@ import org.bukkit.inventory.ItemStack;
|
||||
|
||||
|
||||
public final class WrappedPacketInBlockPlace extends WrappedPacket {
|
||||
static {
|
||||
if (version.isHigherThan(ServerVersion.v_1_7_10)) {
|
||||
WrappedPacketInBlockPlace_1_8.initStatic();
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean isHigherThan_v_1_8_8, isHigherThan_v_1_7_10;
|
||||
private Vector3i blockPosition;
|
||||
private ItemStack itemStack;
|
||||
|
||||
public WrappedPacketInBlockPlace(final Player player, final Object packet) {
|
||||
super(player, packet);
|
||||
}
|
||||
|
||||
public static void load() {
|
||||
isHigherThan_v_1_8_8 = version.isHigherThan(ServerVersion.v_1_8_8);
|
||||
isHigherThan_v_1_7_10 = version.isHigherThan(ServerVersion.v_1_7_10);
|
||||
if (isHigherThan_v_1_7_10) {
|
||||
WrappedPacketInBlockPlace_1_8.load();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setup() {
|
||||
//1.7.10
|
||||
Vector3i position = null;
|
||||
ItemStack itemStack = null;
|
||||
try {
|
||||
if (version.isHigherThan(ServerVersion.v_1_8_8)) {
|
||||
if (isHigherThan_v_1_8_8) {
|
||||
final WrappedPacketInBlockPlace_1_9 blockPlace_1_9 = new WrappedPacketInBlockPlace_1_9(getPlayer(), packet);
|
||||
final Block block = blockPlace_1_9.getBlock();
|
||||
position = new Vector3i(block.getX(), block.getY(), block.getZ());
|
||||
itemStack = new ItemStack(block.getType());
|
||||
} else if (version.isHigherThan(ServerVersion.v_1_7_10)) {
|
||||
} else if (isHigherThan_v_1_7_10) {
|
||||
final WrappedPacketInBlockPlace_1_8 blockPlace_1_8 = new WrappedPacketInBlockPlace_1_8(packet);
|
||||
position = blockPlace_1_8.getBlockPosition();
|
||||
itemStack = blockPlace_1_8.getItemStack();
|
||||
} else {
|
||||
final WrappedPacketInBlockPlace_1_7_10 blockPlace_1_7_10 = new WrappedPacketInBlockPlace_1_7_10(getPlayer(), packet);
|
||||
position = blockPlace_1_7_10.getBlockPosition();
|
||||
this.itemStack = blockPlace_1_7_10.getItemStack();
|
||||
itemStack = blockPlace_1_7_10.getItemStack();
|
||||
}
|
||||
} catch (IllegalArgumentException e) {
|
||||
e.printStackTrace();
|
||||
@@ -57,6 +63,7 @@ public final class WrappedPacketInBlockPlace extends WrappedPacket {
|
||||
return blockPosition;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public ItemStack getItemStack() {
|
||||
return itemStack;
|
||||
}
|
||||
|
||||
+3
@@ -1,3 +1,6 @@
|
||||
/**
|
||||
* Copyright (c) 2020 retrooper
|
||||
*/
|
||||
package io.github.retrooper.packetevents.packetwrappers.in.blockplace;
|
||||
|
||||
import io.github.retrooper.packetevents.packetwrappers.api.WrappedPacket;
|
||||
|
||||
+25
-11
@@ -1,5 +1,9 @@
|
||||
/**
|
||||
* Copyright (c) 2020 retrooper
|
||||
*/
|
||||
package io.github.retrooper.packetevents.packetwrappers.in.blockplace;
|
||||
|
||||
import io.github.retrooper.packetevents.packet.PacketTypeClasses;
|
||||
import io.github.retrooper.packetevents.packetwrappers.api.WrappedPacket;
|
||||
import io.github.retrooper.packetevents.reflectionutils.Reflection;
|
||||
import io.github.retrooper.packetevents.utils.NMSUtils;
|
||||
@@ -9,7 +13,7 @@ import org.bukkit.inventory.ItemStack;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
|
||||
final class WrappedPacketInBlockPlace_1_8 extends WrappedPacket {
|
||||
private static Class<?> blockPlaceClass, blockPositionClass;
|
||||
private static Class<?> blockPlaceClass, blockPositionClass, blockPositionSuperClass;
|
||||
private Vector3i blockPosition;
|
||||
private ItemStack itemStack;
|
||||
|
||||
@@ -17,28 +21,25 @@ final class WrappedPacketInBlockPlace_1_8 extends WrappedPacket {
|
||||
super(packet);
|
||||
}
|
||||
|
||||
protected static void initStatic() {
|
||||
protected static void load() {
|
||||
blockPlaceClass = PacketTypeClasses.Client.BLOCK_PLACE;
|
||||
try {
|
||||
blockPlaceClass = NMSUtils.getNMSClass("PacketPlayInBlockPlace");
|
||||
|
||||
blockPositionClass = NMSUtils.getNMSClass("BlockPosition");
|
||||
} catch (ClassNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
blockPositionSuperClass = blockPositionClass.getSuperclass();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setup() {
|
||||
try {
|
||||
Object nmsBlockPos = Reflection.getField(blockPlaceClass, blockPositionClass, 1).get(packet);
|
||||
this.blockPosition = new Vector3i(0, 0, 0);
|
||||
this.blockPosition.x = (int) Reflection.getMethod(blockPositionSuperClass, "getX", 0).invoke(nmsBlockPos);
|
||||
this.blockPosition.y = (int) Reflection.getMethod(blockPositionSuperClass, "getY", 0).invoke(nmsBlockPos);
|
||||
this.blockPosition.z = (int) Reflection.getMethod(blockPositionSuperClass, "getZ", 0).invoke(nmsBlockPos);
|
||||
|
||||
final int[] coords = new int[3];
|
||||
for (int i = 0; i < 3; i++) {
|
||||
final String s = "get" + (i == 0 ? "X" : i == 1 ? "Y" : "Z");
|
||||
coords[i] = (int) Reflection.getMethod(blockPositionClass.getSuperclass(), s, 0).invoke(nmsBlockPos);
|
||||
}
|
||||
|
||||
this.blockPosition = new Vector3i(coords[0], coords[1], coords[2]);
|
||||
|
||||
this.itemStack = NMSUtils.toBukkitItemStack(Reflection.getField(blockPlaceClass, NMSUtils.nmsItemStackClass, 0).get(packet));
|
||||
} catch (IllegalAccessException | InvocationTargetException e) {
|
||||
@@ -46,10 +47,23 @@ final class WrappedPacketInBlockPlace_1_8 extends WrappedPacket {
|
||||
}
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public Vector3i getBlockPosition() {
|
||||
return blockPosition;
|
||||
}
|
||||
|
||||
public int getBlockPositionX() {
|
||||
return blockPosition.x;
|
||||
}
|
||||
|
||||
public int getBlockPositionY() {
|
||||
return blockPosition.y;
|
||||
}
|
||||
|
||||
public int getBlockPositionZ() {
|
||||
return blockPosition.z;
|
||||
}
|
||||
|
||||
public ItemStack getItemStack() {
|
||||
return itemStack;
|
||||
}
|
||||
|
||||
+3
@@ -1,3 +1,6 @@
|
||||
/**
|
||||
* Copyright (c) 2020 retrooper
|
||||
*/
|
||||
package io.github.retrooper.packetevents.packetwrappers.in.blockplace;
|
||||
|
||||
|
||||
|
||||
+7
-10
@@ -1,26 +1,23 @@
|
||||
/**
|
||||
* Copyright (c) 2020 retrooper
|
||||
*/
|
||||
package io.github.retrooper.packetevents.packetwrappers.in.chat;
|
||||
|
||||
import io.github.retrooper.packetevents.packet.PacketTypeClasses;
|
||||
import io.github.retrooper.packetevents.packetwrappers.api.WrappedPacket;
|
||||
import io.github.retrooper.packetevents.reflectionutils.Reflection;
|
||||
import io.github.retrooper.packetevents.utils.NMSUtils;
|
||||
|
||||
public final class WrappedPacketInChat extends WrappedPacket {
|
||||
private static Class<?> chatPacketClass;
|
||||
|
||||
static {
|
||||
try {
|
||||
chatPacketClass = NMSUtils.getNMSClass("PacketPlayInChat");
|
||||
} catch (ClassNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
private String message;
|
||||
|
||||
public WrappedPacketInChat(Object packet) {
|
||||
super(packet);
|
||||
}
|
||||
|
||||
public static void load() {
|
||||
chatPacketClass = PacketTypeClasses.Client.CHAT;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setup() {
|
||||
|
||||
+61
@@ -0,0 +1,61 @@
|
||||
/**
|
||||
* Copyright (c) 2020 retrooper
|
||||
*/
|
||||
package io.github.retrooper.packetevents.packetwrappers.in.clientcommand;
|
||||
|
||||
import io.github.retrooper.packetevents.annotations.Nullable;
|
||||
import io.github.retrooper.packetevents.enums.ServerVersion;
|
||||
import io.github.retrooper.packetevents.packet.PacketTypeClasses;
|
||||
import io.github.retrooper.packetevents.packetwrappers.api.WrappedPacket;
|
||||
import io.github.retrooper.packetevents.reflectionutils.Reflection;
|
||||
import io.github.retrooper.packetevents.utils.NMSUtils;
|
||||
|
||||
//TODO: Test on 1.9, 1.10, 1.11, 1.13, 1.14
|
||||
public final class WrappedPacketInClientCommand extends WrappedPacket {
|
||||
private static Class<?> packetClass;
|
||||
@Nullable
|
||||
private static Class<?> enumClientCommandClass;
|
||||
|
||||
private static boolean isLowerThan_v_1_8;
|
||||
private ClientCommand clientCommand;
|
||||
|
||||
public WrappedPacketInClientCommand(Object packet) {
|
||||
super(packet);
|
||||
}
|
||||
|
||||
public static void load() {
|
||||
packetClass = PacketTypeClasses.Client.CLIENT_COMMAND;
|
||||
|
||||
isLowerThan_v_1_8 = version.isLowerThan(ServerVersion.v_1_8);
|
||||
try {
|
||||
if (version.isHigherThan(ServerVersion.v_1_7_10)) {
|
||||
enumClientCommandClass = Reflection.getSubClass(packetClass, "EnumClientCommand");
|
||||
} else {
|
||||
enumClientCommandClass = NMSUtils.getNMSClass("EnumClientCommand");
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setup() {
|
||||
try {
|
||||
Object enumObj = Reflection.getField(packetClass, enumClientCommandClass, 0).get(packet);
|
||||
this.clientCommand = ClientCommand.valueOf(enumObj.toString());
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public ClientCommand getClientCommand() {
|
||||
return clientCommand;
|
||||
}
|
||||
|
||||
public enum ClientCommand {
|
||||
PERFORM_RESPAWN,
|
||||
REQUEST_STATS,
|
||||
OPEN_INVENTORY_ACHIEVEMENT
|
||||
}
|
||||
|
||||
}
|
||||
+77
@@ -0,0 +1,77 @@
|
||||
/**
|
||||
* Copyright (c) 2020 retrooper
|
||||
*/
|
||||
package io.github.retrooper.packetevents.packetwrappers.in.custompayload;
|
||||
|
||||
import io.github.retrooper.packetevents.annotations.Nullable;
|
||||
import io.github.retrooper.packetevents.packet.PacketTypeClasses;
|
||||
import io.github.retrooper.packetevents.packetwrappers.api.WrappedPacket;
|
||||
import io.github.retrooper.packetevents.reflectionutils.Reflection;
|
||||
import io.github.retrooper.packetevents.utils.NMSUtils;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
|
||||
public final class WrappedPacketInCustomPayload extends WrappedPacket {
|
||||
private static Class<?> packetClass, nmsMinecraftKey, nmsPacketDataSerializer;
|
||||
|
||||
private static boolean strPresentInIndex0;
|
||||
private String data;
|
||||
private Object minecraftKey, dataSerializer;
|
||||
public WrappedPacketInCustomPayload(Object packet) {
|
||||
super(packet);
|
||||
}
|
||||
|
||||
public static void load() {
|
||||
packetClass = PacketTypeClasses.Client.CUSTOM_PAYLOAD;
|
||||
strPresentInIndex0 = Reflection.getField(packetClass, String.class, 0) != null;
|
||||
try {
|
||||
nmsPacketDataSerializer = NMSUtils.getNMSClass("PacketDataSerializer");
|
||||
} catch (ClassNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
try {
|
||||
//Only on 1.13+
|
||||
nmsMinecraftKey = NMSUtils.getNMSClass("MinecraftKey");
|
||||
} catch (ClassNotFoundException e) {
|
||||
//Its okay, this means they are on versions 1.7.10 ~ 1.12.2
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setup() {
|
||||
if (!strPresentInIndex0) {
|
||||
try {
|
||||
this.minecraftKey = Reflection.getField(packetClass, nmsMinecraftKey, 0).get(packet);
|
||||
this.dataSerializer = Reflection.getField(packetClass, nmsPacketDataSerializer, 0).get(packet);
|
||||
} catch (IllegalAccessException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
} else {
|
||||
Field dataSerializerField = Reflection.getField(packetClass, nmsPacketDataSerializer, 0);
|
||||
try {
|
||||
this.data = (String) Reflection.getField(packetClass, String.class, 0).get(packet);
|
||||
if (dataSerializerField != null) {
|
||||
this.dataSerializer = dataSerializerField.get(packet);
|
||||
}
|
||||
|
||||
} catch (IllegalAccessException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public String getData() {
|
||||
return data;
|
||||
}
|
||||
|
||||
public Object getMinecraftKey() {
|
||||
return minecraftKey;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public Object getDataSerializer() {
|
||||
return dataSerializer;
|
||||
}
|
||||
}
|
||||
+44
-35
@@ -1,51 +1,54 @@
|
||||
/**
|
||||
* Copyright (c) 2020 retrooper
|
||||
*/
|
||||
package io.github.retrooper.packetevents.packetwrappers.in.entityaction;
|
||||
|
||||
import io.github.retrooper.packetevents.annotations.Nullable;
|
||||
import io.github.retrooper.packetevents.enums.ServerVersion;
|
||||
import io.github.retrooper.packetevents.enums.minecraft.PlayerAction;
|
||||
import io.github.retrooper.packetevents.packet.PacketTypeClasses;
|
||||
import io.github.retrooper.packetevents.packetwrappers.api.WrappedPacket;
|
||||
import io.github.retrooper.packetevents.reflectionutils.Reflection;
|
||||
import io.github.retrooper.packetevents.utils.NMSUtils;
|
||||
import org.bukkit.entity.Entity;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
public final class WrappedPacketInEntityAction extends WrappedPacket {
|
||||
private static final HashMap<String, PlayerAction> cachedPlayerActionNames = new HashMap<String, PlayerAction>();
|
||||
private static Class<?> entityActionClass;
|
||||
@Nullable
|
||||
private static Class<?> enumPlayerActionClass;
|
||||
|
||||
static {
|
||||
try {
|
||||
entityActionClass = NMSUtils.getNMSClass("PacketPlayInEntityAction");
|
||||
if (version.isHigherThan(ServerVersion.v_1_7_10)) {
|
||||
for (final Class<?> sub : entityActionClass.getDeclaredClasses()) {
|
||||
if (sub.getSimpleName().equals("EnumPlayerAction")) {
|
||||
enumPlayerActionClass = sub;
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
enumPlayerActionClass = NMSUtils.getNMSClass("EnumPlayerAction");
|
||||
}
|
||||
} catch (ClassNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean isLowerThan_v_1_8;
|
||||
private Entity entity;
|
||||
private int entityId;
|
||||
private PlayerAction action;
|
||||
private int jumpBoost;
|
||||
|
||||
public WrappedPacketInEntityAction(final Object packet) {
|
||||
super(packet);
|
||||
}
|
||||
|
||||
public static void load() {
|
||||
entityActionClass = PacketTypeClasses.Client.ENTITY_ACTION;
|
||||
isLowerThan_v_1_8 = version.isLowerThan(ServerVersion.v_1_8);
|
||||
if (version.isHigherThan(ServerVersion.v_1_7_10)) {
|
||||
enumPlayerActionClass = Reflection.getSubClass(entityActionClass, "EnumPlayerAction");
|
||||
}
|
||||
//All the already existing values
|
||||
for (PlayerAction val : PlayerAction.values()) {
|
||||
cachedPlayerActionNames.put(val.name(), val);
|
||||
}
|
||||
|
||||
cachedPlayerActionNames.put("PRESS_SHIFT_KEY", PlayerAction.START_SNEAKING);
|
||||
cachedPlayerActionNames.put("RELEASE_SHIFT_KEY", PlayerAction.STOP_SNEAKING);
|
||||
cachedPlayerActionNames.put("RIDING_JUMP", PlayerAction.START_RIDING_JUMP);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setup() {
|
||||
try {
|
||||
final int entityId = Reflection.getField(entityActionClass, int.class, 0).getInt(packet);
|
||||
final int jumpBoost;
|
||||
if (version.isLowerThan(ServerVersion.v_1_8)) {
|
||||
if (isLowerThan_v_1_8) {
|
||||
jumpBoost = Reflection.getField(entityActionClass, int.class, 2).getInt(packet);
|
||||
} else {
|
||||
jumpBoost = Reflection.getField(entityActionClass, int.class, 1).getInt(packet);
|
||||
@@ -54,34 +57,27 @@ public final class WrappedPacketInEntityAction extends WrappedPacket {
|
||||
int animationIndex = -1;
|
||||
|
||||
//1.7.10
|
||||
if (version.isLowerThan(ServerVersion.v_1_8)) {
|
||||
animationIndex = Reflection.getField(entityActionClass, int.class, 1).getInt(packet);
|
||||
if (isLowerThan_v_1_8) {
|
||||
animationIndex = Reflection.getField(entityActionClass, int.class, 1).getInt(packet); // TODO: += if packetdataserializer.version < 16
|
||||
} else {
|
||||
final Object enumObj = Reflection.getField(entityActionClass, enumPlayerActionClass, 0).get(packet);
|
||||
final String enumValue = enumObj.toString();
|
||||
try {
|
||||
this.action = PlayerAction.valueOf(enumValue);
|
||||
} catch (IllegalArgumentException e) {
|
||||
//They aren't on a legacy version and the enum has changed
|
||||
final PlayerAction.UpdatedPlayerAction updatedPlayerAction = PlayerAction.UpdatedPlayerAction.valueOf(enumValue);
|
||||
this.action = PlayerAction.get(updatedPlayerAction.getIndex());
|
||||
}
|
||||
final String enumName = enumObj.toString();
|
||||
|
||||
}
|
||||
|
||||
|
||||
this.entityId = entityId;
|
||||
this.jumpBoost = jumpBoost;
|
||||
if (animationIndex != -1) {
|
||||
this.action = PlayerAction.get(animationIndex);
|
||||
this.action = PlayerAction.values()[animationIndex];
|
||||
}
|
||||
this.entity = NMSUtils.getEntityById(this.entityId);
|
||||
} catch (IllegalAccessException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public Entity getEntity() {
|
||||
return entity;
|
||||
return NMSUtils.getEntityById(this.entityId);
|
||||
}
|
||||
|
||||
public int getEntityId() {
|
||||
@@ -95,4 +91,17 @@ public final class WrappedPacketInEntityAction extends WrappedPacket {
|
||||
public int getJumpBoost() {
|
||||
return jumpBoost;
|
||||
}
|
||||
|
||||
public enum PlayerAction {
|
||||
START_SNEAKING,
|
||||
STOP_SNEAKING,
|
||||
STOP_SLEEPING,
|
||||
START_SPRINTING,
|
||||
STOP_SPRINTING,
|
||||
START_RIDING_JUMP,
|
||||
STOP_RIDING_JUMP,
|
||||
OPEN_INVENTORY,
|
||||
START_FALL_FLYING
|
||||
}
|
||||
|
||||
}
|
||||
+53
-58
@@ -1,35 +1,31 @@
|
||||
/**
|
||||
* Copyright (c) 2020 retrooper
|
||||
*/
|
||||
package io.github.retrooper.packetevents.packetwrappers.in.flying;
|
||||
|
||||
|
||||
import io.github.retrooper.packetevents.packet.PacketTypeClasses;
|
||||
import io.github.retrooper.packetevents.packetwrappers.api.WrappedPacket;
|
||||
import io.github.retrooper.packetevents.reflectionutils.Reflection;
|
||||
import io.github.retrooper.packetevents.utils.NMSUtils;
|
||||
|
||||
public class WrappedPacketInFlying extends WrappedPacket {
|
||||
private static Class<?> flyingClass;
|
||||
|
||||
static {
|
||||
|
||||
try {
|
||||
flyingClass = NMSUtils.getNMSClass("PacketPlayInFlying");
|
||||
} catch (ClassNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
private double x;
|
||||
private double y;
|
||||
private double z;
|
||||
private float yaw;
|
||||
private float pitch;
|
||||
private boolean onGround;
|
||||
private boolean isPosition;
|
||||
private boolean isLook;
|
||||
|
||||
protected double x;
|
||||
protected double y;
|
||||
protected double z;
|
||||
protected float yaw;
|
||||
protected float pitch;
|
||||
protected boolean onGround;
|
||||
protected boolean isPosition;
|
||||
protected boolean isLook;
|
||||
public WrappedPacketInFlying(Object packet) {
|
||||
super(packet);
|
||||
}
|
||||
|
||||
public static void load() {
|
||||
flyingClass = PacketTypeClasses.Client.FLYING;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setup() {
|
||||
try {
|
||||
@@ -74,63 +70,63 @@ public class WrappedPacketInFlying extends WrappedPacket {
|
||||
return onGround;
|
||||
}
|
||||
|
||||
public boolean isPosition() {
|
||||
public final boolean isPosition() {
|
||||
return isPosition;
|
||||
}
|
||||
|
||||
public boolean isLook() {
|
||||
public final boolean isLook() {
|
||||
return isLook;
|
||||
}
|
||||
|
||||
public static class WrappedPacketInPosition extends WrappedPacketInFlying {
|
||||
|
||||
public WrappedPacketInPosition(Object packet) {
|
||||
super(packet);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPosition() {
|
||||
protected void setup() {
|
||||
try {
|
||||
return Reflection.getField(flyingClass, boolean.class, 1).getBoolean(packet);
|
||||
} catch (IllegalAccessException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
this.x = Reflection.getField(flyingClass, double.class, 0).getDouble(packet);
|
||||
this.y = Reflection.getField(flyingClass, double.class, 1).getDouble(packet);
|
||||
this.z = Reflection.getField(flyingClass, double.class, 2).getDouble(packet);
|
||||
|
||||
@Override
|
||||
public boolean isLook() {
|
||||
try {
|
||||
return Reflection.getField(flyingClass, boolean.class, 2).getBoolean(packet);
|
||||
this.yaw = Reflection.getField(flyingClass, float.class, 0).getFloat(packet);
|
||||
this.pitch = Reflection.getField(flyingClass, float.class, 1).getFloat(packet);
|
||||
|
||||
this.onGround = Reflection.getField(flyingClass, boolean.class, 0).getBoolean(packet);
|
||||
|
||||
this.isPosition = Reflection.getField(flyingClass, boolean.class, 1).getBoolean(packet);
|
||||
this.isLook = Reflection.getField(flyingClass, boolean.class, 2).getBoolean(packet);
|
||||
} catch (IllegalAccessException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public static class WrappedPacketInPosition_Look extends WrappedPacketInFlying {
|
||||
|
||||
public WrappedPacketInPosition_Look(Object packet) {
|
||||
super(packet);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPosition() {
|
||||
protected void setup() {
|
||||
try {
|
||||
return Reflection.getField(flyingClass, boolean.class, 1).getBoolean(packet);
|
||||
} catch (IllegalAccessException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
this.x = Reflection.getField(flyingClass, double.class, 0).getDouble(packet);
|
||||
this.y = Reflection.getField(flyingClass, double.class, 1).getDouble(packet);
|
||||
this.z = Reflection.getField(flyingClass, double.class, 2).getDouble(packet);
|
||||
|
||||
@Override
|
||||
public boolean isLook() {
|
||||
try {
|
||||
return Reflection.getField(flyingClass, boolean.class, 2).getBoolean(packet);
|
||||
this.yaw = Reflection.getField(flyingClass, float.class, 0).getFloat(packet);
|
||||
this.pitch = Reflection.getField(flyingClass, float.class, 1).getFloat(packet);
|
||||
|
||||
this.onGround = Reflection.getField(flyingClass, boolean.class, 0).getBoolean(packet);
|
||||
|
||||
this.isPosition = Reflection.getField(flyingClass, boolean.class, 1).getBoolean(packet);
|
||||
this.isLook = Reflection.getField(flyingClass, boolean.class, 2).getBoolean(packet);
|
||||
} catch (IllegalAccessException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -141,23 +137,22 @@ public class WrappedPacketInFlying extends WrappedPacket {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPosition() {
|
||||
protected void setup() {
|
||||
try {
|
||||
return Reflection.getField(flyingClass, boolean.class, 1).getBoolean(packet);
|
||||
} catch (IllegalAccessException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
this.x = Reflection.getField(flyingClass, double.class, 0).getDouble(packet);
|
||||
this.y = Reflection.getField(flyingClass, double.class, 1).getDouble(packet);
|
||||
this.z = Reflection.getField(flyingClass, double.class, 2).getDouble(packet);
|
||||
|
||||
@Override
|
||||
public boolean isLook() {
|
||||
try {
|
||||
return Reflection.getField(flyingClass, boolean.class, 2).getBoolean(packet);
|
||||
this.yaw = Reflection.getField(flyingClass, float.class, 0).getFloat(packet);
|
||||
this.pitch = Reflection.getField(flyingClass, float.class, 1).getFloat(packet);
|
||||
|
||||
this.onGround = Reflection.getField(flyingClass, boolean.class, 0).getBoolean(packet);
|
||||
|
||||
this.isPosition = Reflection.getField(flyingClass, boolean.class, 1).getBoolean(packet);
|
||||
this.isLook = Reflection.getField(flyingClass, boolean.class, 2).getBoolean(packet);
|
||||
} catch (IllegalAccessException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+35
@@ -0,0 +1,35 @@
|
||||
/**
|
||||
* Copyright (c) 2020 retrooper
|
||||
*/
|
||||
package io.github.retrooper.packetevents.packetwrappers.in.helditemslot;
|
||||
|
||||
import io.github.retrooper.packetevents.packet.PacketTypeClasses;
|
||||
import io.github.retrooper.packetevents.packetwrappers.api.WrappedPacket;
|
||||
import io.github.retrooper.packetevents.reflectionutils.Reflection;
|
||||
|
||||
public final class WrappedPacketInHeldItemSlot extends WrappedPacket {
|
||||
private static Class<?> packetClass;
|
||||
private int itemInHandIndex;
|
||||
|
||||
public WrappedPacketInHeldItemSlot(Object packet) {
|
||||
super(packet);
|
||||
}
|
||||
|
||||
public static void load() {
|
||||
packetClass = PacketTypeClasses.Client.HELD_ITEM_SLOT;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setup() {
|
||||
try {
|
||||
itemInHandIndex = Reflection.getField(packetClass, int.class, 0).getInt(packet);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public int getItemInHandIndex() {
|
||||
return itemInHandIndex;
|
||||
}
|
||||
|
||||
}
|
||||
+25
-22
@@ -1,45 +1,48 @@
|
||||
/**
|
||||
* Copyright (c) 2020 retrooper
|
||||
*/
|
||||
package io.github.retrooper.packetevents.packetwrappers.in.keepalive;
|
||||
|
||||
import io.github.retrooper.packetevents.enums.ServerVersion;
|
||||
import io.github.retrooper.packetevents.packet.PacketTypeClasses;
|
||||
import io.github.retrooper.packetevents.packetwrappers.api.WrappedPacket;
|
||||
import io.github.retrooper.packetevents.reflectionutils.Reflection;
|
||||
import io.github.retrooper.packetevents.utils.NMSUtils;
|
||||
|
||||
public final class WrappedPacketInKeepAlive extends WrappedPacket {
|
||||
private static Class<?> keepAliveClass;
|
||||
|
||||
static {
|
||||
try {
|
||||
keepAliveClass = NMSUtils.getNMSClass("PacketPlayInKeepAlive");
|
||||
} catch (ClassNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
private static Class<?> packetClass;
|
||||
private static boolean integerPresentInIndex0;
|
||||
private long id;
|
||||
|
||||
public WrappedPacketInKeepAlive(final Object packet) {
|
||||
super(packet);
|
||||
}
|
||||
|
||||
public static void load() {
|
||||
packetClass = PacketTypeClasses.Client.KEEP_ALIVE;
|
||||
integerPresentInIndex0 = Reflection.getField(packetClass, int.class, 0) != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setup() {
|
||||
try {
|
||||
if (version.isHigherThan(ServerVersion.v_1_12)) {
|
||||
this.id = Reflection.getField(keepAliveClass, long.class, 0).getLong(packet);
|
||||
} else {
|
||||
this.id = Reflection.getField(keepAliveClass, int.class, 0).getInt(packet);
|
||||
if (!integerPresentInIndex0) {
|
||||
try {
|
||||
this.id = Reflection.getField(packetClass, long.class, 0).getLong(packet);
|
||||
} catch (IllegalAccessException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
} else {
|
||||
try {
|
||||
this.id = Reflection.getField(packetClass, int.class, 0).getInt(packet);
|
||||
} catch (IllegalAccessException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
} catch (IllegalAccessException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Cast this long to an integer if you are using 1.7.10->1.12.2!
|
||||
* In 1.13.2->1.15.2 a long is sent
|
||||
* Optionally Cast this long to an integer if you are using 1.7.10->1.12.2!
|
||||
* In 1.13.2->1.16.1 a long is sent
|
||||
*
|
||||
* @return
|
||||
* @return response is
|
||||
*/
|
||||
public long getId() {
|
||||
return id;
|
||||
|
||||
+142
@@ -0,0 +1,142 @@
|
||||
/**
|
||||
* Copyright (c) 2020 retrooper
|
||||
*/
|
||||
package io.github.retrooper.packetevents.packetwrappers.in.settings;
|
||||
|
||||
import io.github.retrooper.packetevents.annotations.Nullable;
|
||||
import io.github.retrooper.packetevents.enums.ServerVersion;
|
||||
import io.github.retrooper.packetevents.packet.PacketTypeClasses;
|
||||
import io.github.retrooper.packetevents.packetwrappers.api.WrappedPacket;
|
||||
import io.github.retrooper.packetevents.reflectionutils.Reflection;
|
||||
import io.github.retrooper.packetevents.utils.NMSUtils;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
public class WrappedPacketInSettings extends WrappedPacket {
|
||||
private static Class<?> packetClass;
|
||||
private static Class<?> chatVisibilityEnumClass;
|
||||
|
||||
private static boolean isLowerThan_v_1_8;
|
||||
private String locale;
|
||||
private byte viewDistance;
|
||||
private ChatVisibility chatVisibility;
|
||||
private boolean chatColors;
|
||||
private HashMap<DisplayedSkinPart, Boolean> displayedSkinParts;
|
||||
public WrappedPacketInSettings(final Object packet) {
|
||||
super(packet);
|
||||
}
|
||||
|
||||
public static void load() {
|
||||
packetClass = PacketTypeClasses.Client.SETTINGS;
|
||||
|
||||
isLowerThan_v_1_8 = version.isLowerThan(ServerVersion.v_1_8);
|
||||
|
||||
try {
|
||||
chatVisibilityEnumClass = NMSUtils.getNMSClass("EnumChatVisibility");
|
||||
} catch (ClassNotFoundException e) {
|
||||
Class<?> entityHumanClass = NMSUtils.getNMSClassWithoutException("EntityHuman");
|
||||
//They are just on an outdated version
|
||||
chatVisibilityEnumClass = Reflection.getSubClass(entityHumanClass, "EnumChatVisibility");
|
||||
}
|
||||
}
|
||||
|
||||
public static Class<?> getChatVisibilityEnumClass() {
|
||||
return chatVisibilityEnumClass;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setup() {
|
||||
try {
|
||||
//LOCALE
|
||||
this.locale = Reflection.getField(packetClass, String.class, 0).get(packet).toString();
|
||||
//VIEW DISTANCE
|
||||
this.viewDistance = (byte) Reflection.getField(packetClass, int.class, 0).getInt(packet);
|
||||
|
||||
//CHAT VISIBILITY
|
||||
Object chatVisibilityEnumObject = Reflection.getField(packetClass, chatVisibilityEnumClass, 0).get(packet);
|
||||
String enumValueAsString = chatVisibilityEnumObject.toString();
|
||||
if (enumValueAsString.equals("FULL")) {
|
||||
chatVisibility = ChatVisibility.ENABLED;
|
||||
} else if (enumValueAsString.equals("SYSTEM")) {
|
||||
chatVisibility = ChatVisibility.COMMANDS_ONLY;
|
||||
} else {
|
||||
chatVisibility = ChatVisibility.HIDDEN;
|
||||
}
|
||||
|
||||
//CHAT COLORS
|
||||
this.chatColors = Reflection.getField(packetClass, boolean.class, 0).getBoolean(packet);
|
||||
|
||||
//DISPLAYED SKIN PARTS
|
||||
this.displayedSkinParts = new HashMap<DisplayedSkinPart, Boolean>();
|
||||
|
||||
if (isLowerThan_v_1_8) {
|
||||
//in 1.7.10 only the cape display skin part is sent
|
||||
boolean capeEnabled = Reflection.getField(packetClass, boolean.class, 1).getBoolean(packet);
|
||||
displayedSkinParts.put(DisplayedSkinPart.CAPE, capeEnabled);
|
||||
} else {
|
||||
//in 1.8, all the skin parts are sent
|
||||
int skinPartFlags = Reflection.getField(packetClass, int.class, 1).getInt(packet);
|
||||
displayedSkinParts.put(DisplayedSkinPart.CAPE, (skinPartFlags & 0x01) != 0);
|
||||
displayedSkinParts.put(DisplayedSkinPart.JACKET, (skinPartFlags & 0x02) != 0);
|
||||
displayedSkinParts.put(DisplayedSkinPart.LEFT_SLEEVE, (skinPartFlags & 0x04) != 0);
|
||||
displayedSkinParts.put(DisplayedSkinPart.RIGHT_SLEEVE, (skinPartFlags & 0x08) != 0);
|
||||
displayedSkinParts.put(DisplayedSkinPart.LEFT_PANTS, (skinPartFlags & 0x10) != 0);
|
||||
displayedSkinParts.put(DisplayedSkinPart.RIGHT_PANTS, (skinPartFlags & 0x20) != 0);
|
||||
displayedSkinParts.put(DisplayedSkinPart.HAT, (skinPartFlags & 0x40) != 0);
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public String getLocale() {
|
||||
return locale;
|
||||
}
|
||||
|
||||
public byte getViewDistance() {
|
||||
return viewDistance;
|
||||
}
|
||||
|
||||
public ChatVisibility getChatVisibility() {
|
||||
return chatVisibility;
|
||||
}
|
||||
|
||||
public boolean isChatColors() {
|
||||
return chatColors;
|
||||
}
|
||||
|
||||
/**
|
||||
* It is possible for some keys to not exist.
|
||||
* If that is the case, the server version is 1.7.10.
|
||||
* 1.7.10 only sends the cape skin part.
|
||||
*/
|
||||
@Nullable
|
||||
public HashMap<DisplayedSkinPart, Boolean> getDisplayedSkinPartsMap() {
|
||||
return displayedSkinParts;
|
||||
}
|
||||
|
||||
/**
|
||||
* On 1.7.10, some skin parts will default to 'false' as 1.7.10
|
||||
* only sends the 'cape' skin part.
|
||||
*
|
||||
* @param part
|
||||
* @return
|
||||
*/
|
||||
public boolean isDisplaySkinPartEnabled(DisplayedSkinPart part) {
|
||||
//1.7.10, we will default the other skin parts to return false.
|
||||
if (!displayedSkinParts.containsKey(part)) {
|
||||
return false;
|
||||
}
|
||||
return displayedSkinParts.get(part);
|
||||
}
|
||||
|
||||
public enum ChatVisibility {
|
||||
ENABLED, COMMANDS_ONLY, HIDDEN
|
||||
}
|
||||
|
||||
public enum DisplayedSkinPart {
|
||||
CAPE, JACKET, LEFT_SLEEVE, RIGHT_SLEEVE, LEFT_PANTS, RIGHT_PANTS, HAT
|
||||
}
|
||||
}
|
||||
+8
-11
@@ -1,27 +1,24 @@
|
||||
/**
|
||||
* Copyright (c) 2020 retrooper
|
||||
*/
|
||||
package io.github.retrooper.packetevents.packetwrappers.in.steervehicle;
|
||||
|
||||
import io.github.retrooper.packetevents.packet.PacketTypeClasses;
|
||||
import io.github.retrooper.packetevents.packetwrappers.api.WrappedPacket;
|
||||
import io.github.retrooper.packetevents.reflectionutils.Reflection;
|
||||
import io.github.retrooper.packetevents.utils.NMSUtils;
|
||||
|
||||
public class WrappedPacketInSteerVehicle extends WrappedPacket {
|
||||
private static Class<?> packetClass;
|
||||
|
||||
static {
|
||||
try {
|
||||
packetClass = NMSUtils.getNMSClass("PacketPlayInSteerVehicle");
|
||||
} catch (ClassNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
private float side, forward;
|
||||
private boolean jump, unmount;
|
||||
|
||||
public WrappedPacketInSteerVehicle(Object packet) {
|
||||
super(packet);
|
||||
}
|
||||
|
||||
public static void load() {
|
||||
packetClass = PacketTypeClasses.Client.STEER_VEHICLE;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setup() {
|
||||
try {
|
||||
|
||||
+8
-11
@@ -1,28 +1,25 @@
|
||||
/**
|
||||
* Copyright (c) 2020 retrooper
|
||||
*/
|
||||
package io.github.retrooper.packetevents.packetwrappers.in.transaction;
|
||||
|
||||
import io.github.retrooper.packetevents.packet.PacketTypeClasses;
|
||||
import io.github.retrooper.packetevents.packetwrappers.api.WrappedPacket;
|
||||
import io.github.retrooper.packetevents.reflectionutils.Reflection;
|
||||
import io.github.retrooper.packetevents.utils.NMSUtils;
|
||||
|
||||
public final class WrappedPacketInTransaction extends WrappedPacket {
|
||||
private static Class<?> packetClass;
|
||||
|
||||
static {
|
||||
try {
|
||||
packetClass = NMSUtils.getNMSClass("PacketPlayInTransaction");
|
||||
} catch (ClassNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
private int windowId;
|
||||
private short actionNumber;
|
||||
private boolean accepted;
|
||||
|
||||
public WrappedPacketInTransaction(final Object packet) {
|
||||
super(packet);
|
||||
}
|
||||
|
||||
public static void load() {
|
||||
packetClass = PacketTypeClasses.Client.TRANSACTION;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setup() {
|
||||
try {
|
||||
|
||||
+19
-26
@@ -1,49 +1,38 @@
|
||||
/**
|
||||
* Copyright (c) 2020 retrooper
|
||||
*/
|
||||
package io.github.retrooper.packetevents.packetwrappers.in.useentity;
|
||||
|
||||
import io.github.retrooper.packetevents.enums.minecraft.EntityUseAction;
|
||||
import io.github.retrooper.packetevents.packet.PacketTypeClasses;
|
||||
import io.github.retrooper.packetevents.packetwrappers.api.WrappedPacket;
|
||||
import io.github.retrooper.packetevents.reflectionutils.Reflection;
|
||||
import io.github.retrooper.packetevents.utils.NMSUtils;
|
||||
import org.bukkit.entity.Entity;
|
||||
|
||||
public final class WrappedPacketInUseEntity extends WrappedPacket {
|
||||
private static Class<?> useEntityClass, entityClass, enumEntityUseActionClass;
|
||||
private static Class<?> useEntityClass;
|
||||
private static Class<?> enumEntityUseActionClass;
|
||||
private int entityId;
|
||||
private EntityUseAction action;
|
||||
public WrappedPacketInUseEntity(final Object packet) {
|
||||
super(packet);
|
||||
}
|
||||
|
||||
static {
|
||||
|
||||
try {
|
||||
useEntityClass = NMSUtils.getNMSClass("PacketPlayInUseEntity");
|
||||
entityClass = NMSUtils.getNMSClass("Entity");
|
||||
} catch (ClassNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
public static void load() {
|
||||
useEntityClass = PacketTypeClasses.Client.USE_ENTITY;
|
||||
|
||||
try {
|
||||
enumEntityUseActionClass = NMSUtils.getNMSClass("EnumEntityUseAction");
|
||||
} catch (ClassNotFoundException e) {
|
||||
//That is fine, it is probably a subclass
|
||||
for (final Class<?> sub : useEntityClass.getDeclaredClasses()) {
|
||||
if (sub.getSimpleName().equals("EnumEntityUseAction")) {
|
||||
enumEntityUseActionClass = sub;
|
||||
break;
|
||||
}
|
||||
}
|
||||
enumEntityUseActionClass = Reflection.getSubClass(useEntityClass, "EnumEntityUseAction");
|
||||
}
|
||||
}
|
||||
|
||||
private int entityId;
|
||||
private Entity entity;
|
||||
private EntityUseAction action;
|
||||
|
||||
public WrappedPacketInUseEntity(final Object packet) {
|
||||
super(packet);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setup() {
|
||||
try {
|
||||
this.entityId = Reflection.getField(useEntityClass, int.class, 0).getInt(packet);
|
||||
this.entity = NMSUtils.getEntityById(this.entityId);
|
||||
final Object useActionEnum = Reflection.getField(useEntityClass, enumEntityUseActionClass, 0).get(packet);
|
||||
this.action = EntityUseAction.valueOf(useActionEnum.toString());
|
||||
} catch (IllegalAccessException e) {
|
||||
@@ -52,7 +41,7 @@ public final class WrappedPacketInUseEntity extends WrappedPacket {
|
||||
}
|
||||
|
||||
public Entity getEntity() {
|
||||
return entity;
|
||||
return NMSUtils.getEntityById(this.entityId);
|
||||
}
|
||||
|
||||
public int getEntityId() {
|
||||
@@ -62,4 +51,8 @@ public final class WrappedPacketInUseEntity extends WrappedPacket {
|
||||
public EntityUseAction getAction() {
|
||||
return action;
|
||||
}
|
||||
|
||||
public enum EntityUseAction {
|
||||
INTERACT, INTERACT_AT, ATTACK, INVALID
|
||||
}
|
||||
}
|
||||
+188
@@ -0,0 +1,188 @@
|
||||
/**
|
||||
* Copyright (c) 2020 retrooper
|
||||
*/
|
||||
package io.github.retrooper.packetevents.packetwrappers.in.windowclick;
|
||||
|
||||
import io.github.retrooper.packetevents.annotations.Nullable;
|
||||
import io.github.retrooper.packetevents.packet.PacketTypeClasses;
|
||||
import io.github.retrooper.packetevents.packetwrappers.api.WrappedPacket;
|
||||
import io.github.retrooper.packetevents.reflectionutils.Reflection;
|
||||
import io.github.retrooper.packetevents.utils.NMSUtils;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
|
||||
public class WrappedPacketInWindowClick extends WrappedPacket {
|
||||
private static final HashMap<String, Integer> invClickTypeMapCache = new HashMap<String, Integer>();
|
||||
private static final HashMap<Integer, ArrayList<WindowClickType>> windowClickTypeCache = new HashMap<Integer, ArrayList<WindowClickType>>();
|
||||
private static Class<?> packetClass, invClickTypeClass;
|
||||
private static boolean isClickModePrimitive = false;
|
||||
private int id;
|
||||
private int slot;
|
||||
private int button;
|
||||
private short actionNumber;
|
||||
private int mode;
|
||||
private ItemStack clickedItem;
|
||||
|
||||
public WrappedPacketInWindowClick(Object packet) {
|
||||
super(packet);
|
||||
}
|
||||
|
||||
public static void load() {
|
||||
packetClass = PacketTypeClasses.Client.WINDOW_CLICK;
|
||||
invClickTypeClass = NMSUtils.getNMSClassWithoutException("InventoryClickType");
|
||||
|
||||
invClickTypeMapCache.put("PICKUP", 0);
|
||||
invClickTypeMapCache.put("QUICK_MOVE", 1);
|
||||
invClickTypeMapCache.put("SWAP", 2);
|
||||
invClickTypeMapCache.put("CLONE", 3);
|
||||
invClickTypeMapCache.put("THROW", 4);
|
||||
invClickTypeMapCache.put("QUICK_CRAFT", 5);
|
||||
invClickTypeMapCache.put("PICKUP_ALL", 6);
|
||||
|
||||
//MODE 0
|
||||
windowClickTypeCache.put(0, getArrayListOfWindowClickTypes(WindowClickType.LEFT_MOUSE_CLICK,
|
||||
WindowClickType.RIGHT_MOUSE_CLICK));
|
||||
|
||||
//MODE 1
|
||||
windowClickTypeCache.put(1, getArrayListOfWindowClickTypes(WindowClickType.SHIFT_LEFT_MOUSE_CLICK,
|
||||
WindowClickType.SHIFT_RIGHT_MOUSE_CLICK));
|
||||
|
||||
//MODE 2
|
||||
windowClickTypeCache.put(2, getArrayListOfWindowClickTypes(
|
||||
WindowClickType.KEY_NUMBER1,
|
||||
WindowClickType.KEY_NUMBER2,
|
||||
WindowClickType.KEY_NUMBER3,
|
||||
WindowClickType.KEY_NUMBER4,
|
||||
WindowClickType.KEY_NUMBER5,
|
||||
WindowClickType.KEY_NUMBER6,
|
||||
WindowClickType.KEY_NUMBER7,
|
||||
WindowClickType.KEY_NUMBER8,
|
||||
WindowClickType.KEY_NUMBER9));
|
||||
|
||||
//MODE 3
|
||||
windowClickTypeCache.put(3, getArrayListOfWindowClickTypes(WindowClickType.UNKNOWN, WindowClickType.UNKNOWN, WindowClickType.CREATIVE_MIDDLE_CLICK));
|
||||
|
||||
//MODE 4
|
||||
windowClickTypeCache.put(4, getArrayListOfWindowClickTypes(WindowClickType.KEY_DROP,
|
||||
WindowClickType.KEY_DROP_STACK));
|
||||
|
||||
//MODE 5
|
||||
windowClickTypeCache.put(5, getArrayListOfWindowClickTypes(
|
||||
WindowClickType.STARTING_LEFT_MOUSE_DRAG,
|
||||
WindowClickType.ADD_SLOT_LEFT_MOUSE_DRAG,
|
||||
WindowClickType.ENDING_LEFT_MOUSE_DRAG,
|
||||
WindowClickType.UNKNOWN,
|
||||
WindowClickType.STARTING_RIGHT_MOUSE_DRAG,
|
||||
WindowClickType.ADD_SLOT_RIGHT_MOUSE_DRAG,
|
||||
WindowClickType.CREATIVE_STARTING_MIDDLE_MOUSE_DRAG,
|
||||
WindowClickType.ADD_SLOT_MIDDLE_MOUSE_DRAG,
|
||||
WindowClickType.ENDING_MIDDLE_MOUSE_DRAG));
|
||||
|
||||
windowClickTypeCache.put(6, getArrayListOfWindowClickTypes(WindowClickType.DOUBLE_CLICK));
|
||||
isClickModePrimitive = Reflection.getField(packetClass, int.class, 3) != null;
|
||||
}
|
||||
|
||||
private static ArrayList<WindowClickType> getArrayListOfWindowClickTypes(WindowClickType... types) {
|
||||
ArrayList<WindowClickType> arrayList = new ArrayList<WindowClickType>(types.length);
|
||||
arrayList.addAll(Arrays.asList(types));
|
||||
return arrayList;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setup() {
|
||||
try {
|
||||
this.id = Reflection.getField(packetClass, int.class, 0).getInt(packet);
|
||||
this.slot = Reflection.getField(packetClass, int.class, 1).getInt(packet);
|
||||
this.button = Reflection.getField(packetClass, int.class, 2).getInt(packet);
|
||||
this.actionNumber = Reflection.getField(packetClass, short.class, 0).getShort(packet);
|
||||
Object nmsItemStack = Reflection.getField(packetClass, NMSUtils.nmsItemStackClass, 0).get(packet);
|
||||
this.clickedItem = NMSUtils.toBukkitItemStack(nmsItemStack);
|
||||
Object clickMode = Reflection.getField(packetClass, 5).get(packet);
|
||||
|
||||
if (isClickModePrimitive) {
|
||||
mode = (int) clickMode;
|
||||
} else {
|
||||
mode = invClickTypeMapCache.get(clickMode.toString());
|
||||
}
|
||||
} catch (IllegalAccessException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public int getWindowID() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public int getWindowSlot() {
|
||||
return slot;
|
||||
}
|
||||
|
||||
public int getWindowButton() {
|
||||
return button;
|
||||
}
|
||||
|
||||
public short getActionNumber() {
|
||||
return actionNumber;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public WindowClickType getWindowClickType() {
|
||||
if (windowClickTypeCache.get(mode) == null) {
|
||||
return WindowClickType.UNKNOWN;
|
||||
}
|
||||
if (button + 1 > windowClickTypeCache.size()) {
|
||||
return WindowClickType.UNKNOWN;
|
||||
}
|
||||
|
||||
if (mode == 4) {
|
||||
if (slot == -999) {
|
||||
if (button == 0) {
|
||||
return WindowClickType.LEFT_CLICK_OUTSIDE_WINDOW_HOLDING_NOTHING;
|
||||
} else if (button == 1) {
|
||||
return WindowClickType.RIGHT_CLICK_OUTSIDE_WINDOW_HOLDING_NOTHING;
|
||||
}
|
||||
}
|
||||
}
|
||||
return windowClickTypeCache.get(mode).get(button);
|
||||
}
|
||||
|
||||
public int getMode() {
|
||||
return mode;
|
||||
}
|
||||
|
||||
public ItemStack getClickedItem() {
|
||||
return clickedItem;
|
||||
}
|
||||
|
||||
public enum WindowClickType {
|
||||
LEFT_MOUSE_CLICK, RIGHT_MOUSE_CLICK,
|
||||
SHIFT_LEFT_MOUSE_CLICK, SHIFT_RIGHT_MOUSE_CLICK,
|
||||
|
||||
CREATIVE_MIDDLE_CLICK, CREATIVE_STARTING_MIDDLE_MOUSE_DRAG,
|
||||
|
||||
KEY_NUMBER1, KEY_NUMBER2, KEY_NUMBER3, KEY_NUMBER4,
|
||||
KEY_NUMBER5, KEY_NUMBER6, KEY_NUMBER7, KEY_NUMBER8,
|
||||
KEY_NUMBER9, KEY_DROP, KEY_DROP_STACK,
|
||||
|
||||
LEFT_CLICK_OUTSIDE_WINDOW_HOLDING_NOTHING,
|
||||
RIGHT_CLICK_OUTSIDE_WINDOW_HOLDING_NOTHING,
|
||||
|
||||
STARTING_LEFT_MOUSE_DRAG,
|
||||
STARTING_RIGHT_MOUSE_DRAG,
|
||||
|
||||
ADD_SLOT_LEFT_MOUSE_DRAG,
|
||||
ADD_SLOT_RIGHT_MOUSE_DRAG,
|
||||
ADD_SLOT_MIDDLE_MOUSE_DRAG,
|
||||
|
||||
ENDING_LEFT_MOUSE_DRAG,
|
||||
ENDING_RIGHT_MOUSE_DRAG,
|
||||
ENDING_MIDDLE_MOUSE_DRAG,
|
||||
|
||||
DOUBLE_CLICK,
|
||||
|
||||
UNKNOWN
|
||||
}
|
||||
}
|
||||
+3
@@ -1,3 +1,6 @@
|
||||
/**
|
||||
* Copyright (c) 2020 retrooper
|
||||
*/
|
||||
package io.github.retrooper.packetevents.packetwrappers.out.abilities;
|
||||
|
||||
import io.github.retrooper.packetevents.reflectionutils.Reflection;
|
||||
|
||||
+15
-18
@@ -1,9 +1,12 @@
|
||||
/**
|
||||
* Copyright (c) 2020 retrooper
|
||||
*/
|
||||
package io.github.retrooper.packetevents.packetwrappers.out.abilities;
|
||||
|
||||
import io.github.retrooper.packetevents.packet.PacketTypeClasses;
|
||||
import io.github.retrooper.packetevents.packetwrappers.Sendable;
|
||||
import io.github.retrooper.packetevents.packetwrappers.api.WrappedPacket;
|
||||
import io.github.retrooper.packetevents.reflectionutils.Reflection;
|
||||
import io.github.retrooper.packetevents.utils.NMSUtils;
|
||||
|
||||
import java.lang.reflect.Constructor;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
@@ -11,31 +14,15 @@ import java.lang.reflect.InvocationTargetException;
|
||||
public final class WrappedPacketOutAbilities extends WrappedPacket implements Sendable {
|
||||
private static Class<?> packetClass;
|
||||
private static Constructor<?> packetConstructor;
|
||||
|
||||
static {
|
||||
try {
|
||||
packetClass = NMSUtils.getNMSClass("PacketPlayOutAbilities");
|
||||
} catch (ClassNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
try {
|
||||
packetConstructor = packetClass.getConstructor(PlayerAbilitiesUtils.playerAbilitiesClass);
|
||||
} catch (NoSuchMethodException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
private boolean vulnerable, flying, allowFlight, instantBuild;
|
||||
private float flySpeed, walkSpeed;
|
||||
|
||||
public WrappedPacketOutAbilities(final Object packet) {
|
||||
super(packet);
|
||||
}
|
||||
|
||||
public WrappedPacketOutAbilities(final boolean isVulnerable, final boolean isFlying, final boolean allowFlight, final boolean canBuildInstantly,
|
||||
final float flySpeed, final float walkSpeed) {
|
||||
super(null);
|
||||
super();
|
||||
this.vulnerable = isVulnerable;
|
||||
this.flying = isFlying;
|
||||
this.allowFlight = allowFlight;
|
||||
@@ -44,6 +31,16 @@ public final class WrappedPacketOutAbilities extends WrappedPacket implements Se
|
||||
this.walkSpeed = walkSpeed;
|
||||
}
|
||||
|
||||
public static void load() {
|
||||
packetClass = PacketTypeClasses.Server.ABILITIES;
|
||||
|
||||
try {
|
||||
packetConstructor = packetClass.getConstructor(PlayerAbilitiesUtils.playerAbilitiesClass);
|
||||
} catch (NoSuchMethodException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setup() {
|
||||
try {
|
||||
|
||||
+43
-21
@@ -1,6 +1,9 @@
|
||||
/**
|
||||
* Copyright (c) 2020 retrooper
|
||||
*/
|
||||
package io.github.retrooper.packetevents.packetwrappers.out.animation;
|
||||
|
||||
import io.github.retrooper.packetevents.enums.minecraft.EntityAnimationType;
|
||||
import io.github.retrooper.packetevents.packet.PacketTypeClasses;
|
||||
import io.github.retrooper.packetevents.packetwrappers.Sendable;
|
||||
import io.github.retrooper.packetevents.packetwrappers.api.WrappedPacket;
|
||||
import io.github.retrooper.packetevents.reflectionutils.Reflection;
|
||||
@@ -9,14 +12,31 @@ import org.bukkit.entity.Entity;
|
||||
|
||||
import java.lang.reflect.Constructor;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.util.HashMap;
|
||||
|
||||
public final class WrappedPacketOutAnimation extends WrappedPacket implements Sendable {
|
||||
private static Class<?> animationClass, nmsEntityClass;
|
||||
private static Constructor<?> animationConstructor;
|
||||
|
||||
static {
|
||||
private static final HashMap<Integer, EntityAnimationType> cachedAnimationIDS = new HashMap<Integer, EntityAnimationType>();
|
||||
private static final HashMap<EntityAnimationType, Integer> cachedAnimations = new HashMap<EntityAnimationType, Integer>();
|
||||
private Entity entity;
|
||||
private int entityID;
|
||||
private EntityAnimationType type;
|
||||
public WrappedPacketOutAnimation(final Object packet) {
|
||||
super(packet);
|
||||
}
|
||||
|
||||
public WrappedPacketOutAnimation(final Entity target, final EntityAnimationType type) {
|
||||
super();
|
||||
this.entityID = target.getEntityId();
|
||||
this.entity = target;
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public static void load() {
|
||||
animationClass = PacketTypeClasses.Server.ANIMATION;
|
||||
try {
|
||||
animationClass = NMSUtils.getNMSClass("PacketPlayOutAnimation");
|
||||
nmsEntityClass = NMSUtils.getNMSClass("Entity");
|
||||
} catch (ClassNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
@@ -27,21 +47,19 @@ public final class WrappedPacketOutAnimation extends WrappedPacket implements Se
|
||||
} catch (NoSuchMethodException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
cachedAnimationIDS.put(0, EntityAnimationType.SWING_MAIN_ARM);
|
||||
cachedAnimationIDS.put(1, EntityAnimationType.TAKE_DAMAGE);
|
||||
cachedAnimationIDS.put(2, EntityAnimationType.LEAVE_BED);
|
||||
cachedAnimationIDS.put(3, EntityAnimationType.SWING_OFFHAND);
|
||||
cachedAnimationIDS.put(4, EntityAnimationType.CRITICAL_EFFECT);
|
||||
cachedAnimationIDS.put(5, EntityAnimationType.MAGIC_CRITICAL_EFFECT);
|
||||
|
||||
private Entity entity;
|
||||
private int entityID;
|
||||
private EntityAnimationType type;
|
||||
|
||||
public WrappedPacketOutAnimation(final Object packet) {
|
||||
super(packet);
|
||||
}
|
||||
|
||||
public WrappedPacketOutAnimation(final Entity target, final EntityAnimationType type) {
|
||||
super(null);
|
||||
this.entityID = target.getEntityId();
|
||||
this.entity = target;
|
||||
this.type = type;
|
||||
cachedAnimations.put(EntityAnimationType.SWING_MAIN_ARM, 0);
|
||||
cachedAnimations.put(EntityAnimationType.TAKE_DAMAGE, 1);
|
||||
cachedAnimations.put(EntityAnimationType.LEAVE_BED, 2);
|
||||
cachedAnimations.put(EntityAnimationType.SWING_OFFHAND, 3);
|
||||
cachedAnimations.put(EntityAnimationType.CRITICAL_EFFECT, 4);
|
||||
cachedAnimations.put(EntityAnimationType.MAGIC_CRITICAL_EFFECT, 5);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -50,8 +68,8 @@ public final class WrappedPacketOutAnimation extends WrappedPacket implements Se
|
||||
//a - ID
|
||||
//b - TYPE
|
||||
this.entityID = Reflection.getField(animationClass, int.class, 0).getInt(packet);
|
||||
this.entity = NMSUtils.getEntityById(this.entityID);
|
||||
this.type = EntityAnimationType.get(Reflection.getField(animationClass, int.class, 1).getInt(packet));
|
||||
int animationID = Reflection.getField(animationClass, int.class, 1).getInt(packet);
|
||||
this.type = cachedAnimationIDS.get(animationID);
|
||||
} catch (IllegalAccessException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
@@ -59,7 +77,7 @@ public final class WrappedPacketOutAnimation extends WrappedPacket implements Se
|
||||
}
|
||||
|
||||
public Entity getEntity() {
|
||||
return this.entity;
|
||||
return NMSUtils.getEntityById(this.entityID);
|
||||
}
|
||||
|
||||
public int getEntityId() {
|
||||
@@ -73,7 +91,7 @@ public final class WrappedPacketOutAnimation extends WrappedPacket implements Se
|
||||
@Override
|
||||
public Object asNMSPacket() {
|
||||
final Object nmsEntity = NMSUtils.getNMSEntity(this.entity);
|
||||
final int index = type.getIndex();
|
||||
final int index = cachedAnimations.get(type);
|
||||
try {
|
||||
return animationConstructor.newInstance(nmsEntity, index);
|
||||
} catch (InstantiationException | IllegalAccessException | InvocationTargetException e) {
|
||||
@@ -81,4 +99,8 @@ public final class WrappedPacketOutAnimation extends WrappedPacket implements Se
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public enum EntityAnimationType {
|
||||
SWING_MAIN_ARM, TAKE_DAMAGE, LEAVE_BED, SWING_OFFHAND, CRITICAL_EFFECT, MAGIC_CRITICAL_EFFECT
|
||||
}
|
||||
}
|
||||
+19
-16
@@ -1,5 +1,9 @@
|
||||
/**
|
||||
* Copyright (c) 2020 retrooper
|
||||
*/
|
||||
package io.github.retrooper.packetevents.packetwrappers.out.chat;
|
||||
|
||||
import io.github.retrooper.packetevents.packet.PacketTypeClasses;
|
||||
import io.github.retrooper.packetevents.packetwrappers.Sendable;
|
||||
import io.github.retrooper.packetevents.packetwrappers.api.WrappedPacket;
|
||||
import io.github.retrooper.packetevents.reflectionutils.Reflection;
|
||||
@@ -10,11 +14,21 @@ import java.lang.reflect.InvocationTargetException;
|
||||
|
||||
public final class WrappedPacketOutChat extends WrappedPacket implements Sendable {
|
||||
private static Constructor<?> chatClassConstructor;
|
||||
private static Class<?> chatClass, iChatBaseComponentClass, chatSerializerClass;
|
||||
private static Class<?> packetClass, iChatBaseComponentClass, chatSerializerClass;
|
||||
private String message;
|
||||
|
||||
static {
|
||||
public WrappedPacketOutChat(final Object packet) {
|
||||
super(packet);
|
||||
}
|
||||
|
||||
public WrappedPacketOutChat(final String message) {
|
||||
super();
|
||||
this.message = "{\"text\": \"" + message + "\"}";
|
||||
}
|
||||
|
||||
public static void load() {
|
||||
try {
|
||||
chatClass = NMSUtils.getNMSClass("PacketPlayOutChat");
|
||||
packetClass = PacketTypeClasses.Server.CHAT;
|
||||
iChatBaseComponentClass = NMSUtils.getNMSClass("IChatBaseComponent");
|
||||
} catch (ClassNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
@@ -29,7 +43,7 @@ public final class WrappedPacketOutChat extends WrappedPacket implements Sendabl
|
||||
}
|
||||
|
||||
try {
|
||||
chatClassConstructor = chatClass.getConstructor(iChatBaseComponentClass);
|
||||
chatClassConstructor = packetClass.getConstructor(iChatBaseComponentClass);
|
||||
} catch (NoSuchMethodException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
@@ -37,17 +51,6 @@ public final class WrappedPacketOutChat extends WrappedPacket implements Sendabl
|
||||
|
||||
}
|
||||
|
||||
private String message;
|
||||
|
||||
public WrappedPacketOutChat(final Object packet) {
|
||||
super(packet);
|
||||
}
|
||||
|
||||
public WrappedPacketOutChat(final String message) {
|
||||
super(null);
|
||||
this.message = "{\"text\": \"" + message + "\"}";
|
||||
}
|
||||
|
||||
public static String toStringFromIChatBaseComponent(Object obj) {
|
||||
try {
|
||||
return Reflection.getMethod(iChatBaseComponentClass, String.class, 0).invoke(obj).toString();
|
||||
@@ -70,7 +73,7 @@ public final class WrappedPacketOutChat extends WrappedPacket implements Sendabl
|
||||
@Override
|
||||
protected void setup() {
|
||||
try {
|
||||
final Object iChatBaseObj = Reflection.getField(chatClass, iChatBaseComponentClass, 0).get(packet);
|
||||
final Object iChatBaseObj = Reflection.getField(packetClass, iChatBaseComponentClass, 0).get(packet);
|
||||
|
||||
final Object contentString = Reflection.getMethod(iChatBaseComponentClass, String.class, 0).invoke(iChatBaseObj);
|
||||
|
||||
|
||||
+65
-39
@@ -1,55 +1,87 @@
|
||||
/**
|
||||
* Copyright (c) 2020 retrooper
|
||||
*/
|
||||
package io.github.retrooper.packetevents.packetwrappers.out.entity;
|
||||
|
||||
import io.github.retrooper.packetevents.enums.ServerVersion;
|
||||
import io.github.retrooper.packetevents.packet.PacketTypeClasses;
|
||||
import io.github.retrooper.packetevents.packetwrappers.api.WrappedPacket;
|
||||
import io.github.retrooper.packetevents.reflectionutils.Reflection;
|
||||
import io.github.retrooper.packetevents.utils.NMSUtils;
|
||||
import org.bukkit.entity.Entity;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
|
||||
public class WrappedPacketOutEntity extends WrappedPacket {
|
||||
private int entityId;
|
||||
private static Class<?> packetClass;
|
||||
//Byte = 1.7.10->1.8.8, Int = 1.9->1.15.x, Short = 1.16.x
|
||||
private static byte mode = 0; //byte = 0, int = 1, short = 2
|
||||
private static double dXYZDivisor = 0.0;
|
||||
private int entityID;
|
||||
private double deltaX, deltaY, deltaZ;
|
||||
private byte yaw, pitch;
|
||||
private boolean onGround;
|
||||
|
||||
public WrappedPacketOutEntity(Object packet) {
|
||||
super(packet);
|
||||
}
|
||||
|
||||
public static void load() {
|
||||
packetClass = PacketTypeClasses.Server.ENTITY;
|
||||
|
||||
Field dxField = Reflection.getField(packetClass, 1);
|
||||
assert dxField != null;
|
||||
if (dxField.equals(Reflection.getField(packetClass, byte.class, 0))) {
|
||||
mode = 0;
|
||||
} else if (dxField.equals(Reflection.getField(packetClass, int.class, 1))) {
|
||||
mode = 1;
|
||||
} else if (dxField.equals(Reflection.getField(packetClass, short.class, 0))) {
|
||||
mode = 2;
|
||||
}
|
||||
|
||||
if (mode == 0) {
|
||||
dXYZDivisor = 32.0;
|
||||
} else {
|
||||
dXYZDivisor = 4096.0;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setup() {
|
||||
try {
|
||||
this.entityId = Reflection.getField(packetClass, int.class, 0).getInt(packet);
|
||||
this.entityID = Reflection.getField(packetClass, int.class, 0).getInt(packet);
|
||||
this.onGround = Reflection.getField(packetClass, boolean.class, 0).getBoolean(packet);
|
||||
if (version.isLowerThan(ServerVersion.v_1_9)) {
|
||||
byte dX = Reflection.getField(packetClass, byte.class, 0).getByte(packet);
|
||||
byte dY = Reflection.getField(packetClass, byte.class, 1).getByte(packet);
|
||||
byte dZ = Reflection.getField(packetClass, byte.class, 2).getByte(packet);
|
||||
|
||||
this.deltaX = dX / 32.0;
|
||||
this.deltaY = dY / 32.0;
|
||||
this.deltaZ = dZ / 32.0;
|
||||
|
||||
this.yaw = Reflection.getField(packetClass, byte.class, 3).getByte(packet);
|
||||
this.pitch = Reflection.getField(packetClass, byte.class, 4).getByte(packet);
|
||||
} else {
|
||||
short dX = Reflection.getField(packetClass, short.class, 0).getShort(packet);
|
||||
short dY = Reflection.getField(packetClass, short.class, 1).getShort(packet);
|
||||
short dZ = Reflection.getField(packetClass, short.class, 2).getShort(packet);
|
||||
|
||||
this.deltaX = dX / 4096.0;
|
||||
this.deltaY = dY / 4096.0;
|
||||
this.deltaZ = dZ / 4096.0;
|
||||
|
||||
this.yaw = Reflection.getField(packetClass, byte.class, 0).getByte(packet);
|
||||
this.pitch = Reflection.getField(packetClass, byte.class, 1).getByte(packet);
|
||||
int dX = 1, dY = 1, dZ = 1;
|
||||
switch (mode) {
|
||||
case 0:
|
||||
dX = Reflection.getField(packetClass, byte.class, 0).getByte(packet);
|
||||
dY = Reflection.getField(packetClass, byte.class, 1).getByte(packet);
|
||||
dZ = Reflection.getField(packetClass, byte.class, 2).getByte(packet);
|
||||
this.yaw = Reflection.getField(packetClass, byte.class, 3).getByte(packet);
|
||||
this.pitch = Reflection.getField(packetClass, byte.class, 4).getByte(packet);
|
||||
break;
|
||||
case 1:
|
||||
dX = Reflection.getField(packetClass, int.class, 1).getInt(packet);
|
||||
dY = Reflection.getField(packetClass, int.class, 2).getInt(packet);
|
||||
dZ = Reflection.getField(packetClass, int.class, 3).getInt(packet);
|
||||
this.yaw = Reflection.getField(packetClass, byte.class, 0).getByte(packet);
|
||||
this.pitch = Reflection.getField(packetClass, byte.class, 1).getByte(packet);
|
||||
break;
|
||||
case 2:
|
||||
dX = Reflection.getField(packetClass, short.class, 0).getShort(packet);
|
||||
dY = Reflection.getField(packetClass, short.class, 1).getShort(packet);
|
||||
dZ = Reflection.getField(packetClass, short.class, 2).getShort(packet);
|
||||
this.yaw = Reflection.getField(packetClass, byte.class, 0).getByte(packet);
|
||||
this.pitch = Reflection.getField(packetClass, byte.class, 1).getByte(packet);
|
||||
break;
|
||||
}
|
||||
this.deltaX = dX / dXYZDivisor;
|
||||
this.deltaY = dY / dXYZDivisor;
|
||||
this.deltaZ = dZ / dXYZDivisor;
|
||||
} catch (IllegalAccessException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
public byte getPitch() {
|
||||
return pitch;
|
||||
}
|
||||
@@ -70,21 +102,15 @@ public class WrappedPacketOutEntity extends WrappedPacket {
|
||||
return deltaX;
|
||||
}
|
||||
|
||||
public Entity getEntity() {
|
||||
return NMSUtils.getEntityById(entityID);
|
||||
}
|
||||
|
||||
public int getEntityId() {
|
||||
return entityId;
|
||||
return entityID;
|
||||
}
|
||||
|
||||
public boolean isOnGround() {
|
||||
return onGround;
|
||||
}
|
||||
|
||||
private static Class<?> packetClass;
|
||||
|
||||
static {
|
||||
try {
|
||||
packetClass = NMSUtils.getNMSClass("PacketPlayOutEntity");
|
||||
} catch (ClassNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
+39
-34
@@ -1,6 +1,10 @@
|
||||
/**
|
||||
* Copyright (c) 2020 retrooper
|
||||
*/
|
||||
package io.github.retrooper.packetevents.packetwrappers.out.entityvelocity;
|
||||
|
||||
import io.github.retrooper.packetevents.enums.ServerVersion;
|
||||
import io.github.retrooper.packetevents.packet.PacketTypeClasses;
|
||||
import io.github.retrooper.packetevents.packetwrappers.Sendable;
|
||||
import io.github.retrooper.packetevents.packetwrappers.api.WrappedPacket;
|
||||
import io.github.retrooper.packetevents.reflectionutils.Reflection;
|
||||
@@ -13,21 +17,36 @@ import java.lang.reflect.InvocationTargetException;
|
||||
public final class WrappedPacketOutEntityVelocity extends WrappedPacket implements Sendable {
|
||||
private static Constructor<?> velocityConstructor, vec3dConstructor;
|
||||
private static Class<?> velocityClass, vec3dClass;
|
||||
private static boolean isVec3dPresent;
|
||||
private int entityId;
|
||||
private double velocityX, velocityY, velocityZ;
|
||||
private Entity entity;
|
||||
public WrappedPacketOutEntityVelocity(final Object packet) {
|
||||
super(packet);
|
||||
}
|
||||
|
||||
public WrappedPacketOutEntityVelocity(final Entity entity, final double velocityX, final double velocityY, final double velocityZ) {
|
||||
super();
|
||||
this.entityId = entity.getEntityId();
|
||||
this.entity = entity;
|
||||
this.velocityX = velocityX;
|
||||
this.velocityY = velocityY;
|
||||
this.velocityZ = velocityZ;
|
||||
}
|
||||
|
||||
/**
|
||||
* Velocity Constructor parameter types:
|
||||
* 1.7.10->1.13.2 use int, double, double, double style,
|
||||
* 1.14+ use int, Vec3D style
|
||||
*/
|
||||
static {
|
||||
try {
|
||||
|
||||
velocityClass = NMSUtils.getNMSClass("PacketPlayOutEntityVelocity");
|
||||
if (version.isHigherThan(ServerVersion.v_1_13_2)) {
|
||||
public static void load() {
|
||||
velocityClass = PacketTypeClasses.Server.ENTITY_VELOCITY;
|
||||
if (version.isHigherThan(ServerVersion.v_1_13_2)) {
|
||||
try {
|
||||
vec3dClass = NMSUtils.getNMSClass("Vec3D");
|
||||
} catch (ClassNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
} catch (ClassNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
try {
|
||||
@@ -36,6 +55,7 @@ public final class WrappedPacketOutEntityVelocity extends WrappedPacket implemen
|
||||
//That is fine, just a newer version
|
||||
try {
|
||||
velocityConstructor = velocityClass.getConstructor(int.class, vec3dClass);
|
||||
isVec3dPresent = true;
|
||||
//vec3d constructor
|
||||
vec3dConstructor = vec3dClass.getConstructor(double.class, double.class, double.class);
|
||||
} catch (NoSuchMethodException e2) {
|
||||
@@ -45,36 +65,17 @@ public final class WrappedPacketOutEntityVelocity extends WrappedPacket implemen
|
||||
}
|
||||
}
|
||||
|
||||
private Entity entity;
|
||||
private int entityId;
|
||||
private double velocityX, velocityY, velocityZ;
|
||||
|
||||
public WrappedPacketOutEntityVelocity(final Object packet) {
|
||||
super(packet);
|
||||
}
|
||||
|
||||
public WrappedPacketOutEntityVelocity(final Entity entity, final double velocityX, final double velocityY, final double velocityZ) {
|
||||
super(null);
|
||||
this.entityId = entity.getEntityId();
|
||||
this.entity = entity;
|
||||
this.velocityX = velocityX;
|
||||
this.velocityY = velocityY;
|
||||
this.velocityZ = velocityZ;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setup() {
|
||||
try {
|
||||
int i = 0;
|
||||
final int entityId = Reflection.getField(velocityClass, int.class, 0).getInt(packet);
|
||||
//ENTITY ID
|
||||
this.entityId = Reflection.getField(velocityClass, int.class, 0).getInt(packet);
|
||||
|
||||
final int x = Reflection.getField(velocityClass, int.class, 1).getInt(packet);
|
||||
final int y = Reflection.getField(velocityClass, int.class, 2).getInt(packet);
|
||||
final int z = Reflection.getField(velocityClass, int.class, 3).getInt(packet);
|
||||
|
||||
this.entityId = entityId;
|
||||
this.entity = NMSUtils.getEntityById(this.entityId);
|
||||
int x = Reflection.getField(velocityClass, int.class, 1).getInt(packet);
|
||||
int y = Reflection.getField(velocityClass, int.class, 2).getInt(packet);
|
||||
int z = Reflection.getField(velocityClass, int.class, 3).getInt(packet);
|
||||
|
||||
//VELOCITY XYZ
|
||||
this.velocityX = x / 8000.0D;
|
||||
this.velocityY = y / 8000.0D;
|
||||
this.velocityZ = z / 8000.0D;
|
||||
@@ -88,7 +89,11 @@ public final class WrappedPacketOutEntityVelocity extends WrappedPacket implemen
|
||||
}
|
||||
|
||||
public Entity getEntity() {
|
||||
return entity;
|
||||
if (entity == null) {
|
||||
return NMSUtils.getEntityById(this.entityId);
|
||||
} else {
|
||||
return entity;
|
||||
}
|
||||
}
|
||||
|
||||
public double getVelocityX() {
|
||||
@@ -105,7 +110,7 @@ public final class WrappedPacketOutEntityVelocity extends WrappedPacket implemen
|
||||
|
||||
@Override
|
||||
public Object asNMSPacket() {
|
||||
if (version.isLowerThan(ServerVersion.v_1_14)) {
|
||||
if (!isVec3dPresent) {
|
||||
try {
|
||||
return velocityConstructor.newInstance(entityId, velocityX, velocityY, velocityZ);
|
||||
} catch (InstantiationException | IllegalAccessException | InvocationTargetException e) {
|
||||
|
||||
+91
@@ -0,0 +1,91 @@
|
||||
/**
|
||||
* Copyright (c) 2020 retrooper
|
||||
*/
|
||||
package io.github.retrooper.packetevents.packetwrappers.out.keepalive;
|
||||
|
||||
import io.github.retrooper.packetevents.packet.PacketTypeClasses;
|
||||
import io.github.retrooper.packetevents.packetwrappers.Sendable;
|
||||
import io.github.retrooper.packetevents.packetwrappers.api.WrappedPacket;
|
||||
import io.github.retrooper.packetevents.reflectionutils.Reflection;
|
||||
|
||||
import java.lang.reflect.Constructor;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
|
||||
public class WrappedPacketOutKeepAlive extends WrappedPacket implements Sendable {
|
||||
private static Class<?> packetClass;
|
||||
private static Constructor<?> keepAliveConstructor;
|
||||
private static boolean integerMode;
|
||||
private long id;
|
||||
|
||||
public WrappedPacketOutKeepAlive(Object packet) {
|
||||
super(packet);
|
||||
}
|
||||
|
||||
public WrappedPacketOutKeepAlive(long id) {
|
||||
super();
|
||||
}
|
||||
|
||||
public static void load() {
|
||||
packetClass = PacketTypeClasses.Server.KEEP_ALIVE;
|
||||
integerMode = Reflection.getField(packetClass, int.class, 0) != null;
|
||||
|
||||
if (integerMode) {
|
||||
try {
|
||||
keepAliveConstructor = packetClass.getConstructor(int.class);
|
||||
} catch (NoSuchMethodException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
} else {
|
||||
try {
|
||||
keepAliveConstructor = packetClass.getConstructor(long.class);
|
||||
} catch (NoSuchMethodException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setup() {
|
||||
if (!integerMode) {
|
||||
try {
|
||||
this.id = Reflection.getField(packetClass, long.class, 0).getLong(packet);
|
||||
} catch (IllegalAccessException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
} else {
|
||||
try {
|
||||
this.id = Reflection.getField(packetClass, int.class, 0).getInt(packet);
|
||||
} catch (IllegalAccessException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* You can cast this long to an integer if you are using 1.7.10->1.12.2!
|
||||
* In 1.13.2->1.16.2 a long is sent
|
||||
*
|
||||
* @return Keep Alive ID
|
||||
*/
|
||||
public long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object asNMSPacket() {
|
||||
if (integerMode) {
|
||||
try {
|
||||
return keepAliveConstructor.newInstance((int) id);
|
||||
} catch (InstantiationException | IllegalAccessException | InvocationTargetException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
} else {
|
||||
try {
|
||||
return keepAliveConstructor.newInstance(id);
|
||||
} catch (InstantiationException | IllegalAccessException | InvocationTargetException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
+16
-13
@@ -1,5 +1,9 @@
|
||||
/**
|
||||
* Copyright (c) 2020 retrooper
|
||||
*/
|
||||
package io.github.retrooper.packetevents.packetwrappers.out.kickdisconnect;
|
||||
|
||||
import io.github.retrooper.packetevents.packet.PacketTypeClasses;
|
||||
import io.github.retrooper.packetevents.packetwrappers.Sendable;
|
||||
import io.github.retrooper.packetevents.packetwrappers.api.WrappedPacket;
|
||||
import io.github.retrooper.packetevents.packetwrappers.out.chat.WrappedPacketOutChat;
|
||||
@@ -12,10 +16,20 @@ import java.lang.reflect.InvocationTargetException;
|
||||
public final class WrappedPacketOutKickDisconnect extends WrappedPacket implements Sendable {
|
||||
private static Class<?> packetClass, iChatBaseComponentClass;
|
||||
private static Constructor<?> kickDisconnectConstructor;
|
||||
private String kickMessage;
|
||||
|
||||
static {
|
||||
public WrappedPacketOutKickDisconnect(final Object packet) {
|
||||
super(packet);
|
||||
}
|
||||
|
||||
public WrappedPacketOutKickDisconnect(final String kickMessage) {
|
||||
super();
|
||||
this.kickMessage = kickMessage;
|
||||
}
|
||||
|
||||
public static void load() {
|
||||
packetClass = PacketTypeClasses.Server.KICK_DISCONNECT;
|
||||
try {
|
||||
packetClass = NMSUtils.getNMSClass("PacketPlayOutKickDisconnect");
|
||||
iChatBaseComponentClass = NMSUtils.getNMSClass("IChatBaseComponent");
|
||||
} catch (ClassNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
@@ -28,17 +42,6 @@ public final class WrappedPacketOutKickDisconnect extends WrappedPacket implemen
|
||||
}
|
||||
}
|
||||
|
||||
private String kickMessage;
|
||||
|
||||
public WrappedPacketOutKickDisconnect(final Object packet) {
|
||||
super(packet);
|
||||
}
|
||||
|
||||
public WrappedPacketOutKickDisconnect(final String kickMessage) {
|
||||
super(null);
|
||||
this.kickMessage = kickMessage;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setup() {
|
||||
try {
|
||||
|
||||
+60
@@ -0,0 +1,60 @@
|
||||
/**
|
||||
* Copyright (c) 2020 retrooper
|
||||
*/
|
||||
package io.github.retrooper.packetevents.packetwrappers.out.position;
|
||||
|
||||
import io.github.retrooper.packetevents.packet.PacketTypeClasses;
|
||||
import io.github.retrooper.packetevents.packetwrappers.api.WrappedPacket;
|
||||
import io.github.retrooper.packetevents.reflectionutils.Reflection;
|
||||
|
||||
public final class WrappedPacketOutPosition extends WrappedPacket {
|
||||
private static Class<?> packetClass;
|
||||
private double x;
|
||||
private double y;
|
||||
private double z;
|
||||
private float yaw;
|
||||
private float pitch;
|
||||
|
||||
public WrappedPacketOutPosition(Object packet) {
|
||||
super(packet);
|
||||
}
|
||||
|
||||
public static void load() {
|
||||
packetClass = PacketTypeClasses.Server.POSITION;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setup() {
|
||||
//TODO boolean onGround and flags
|
||||
try {
|
||||
this.x = Reflection.getField(packetClass, double.class, 0).getDouble(packet);
|
||||
this.y = Reflection.getField(packetClass, double.class, 1).getDouble(packet);
|
||||
this.z = Reflection.getField(packetClass, double.class, 2).getDouble(packet);
|
||||
|
||||
this.yaw = Reflection.getField(packetClass, float.class, 0).getFloat(packet);
|
||||
this.pitch = Reflection.getField(packetClass, float.class, 1).getFloat(packet);
|
||||
} catch (IllegalAccessException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public double getX() {
|
||||
return x;
|
||||
}
|
||||
|
||||
public double getY() {
|
||||
return y;
|
||||
}
|
||||
|
||||
public double getZ() {
|
||||
return z;
|
||||
}
|
||||
|
||||
public float getYaw() {
|
||||
return yaw;
|
||||
}
|
||||
|
||||
public float getPitch() {
|
||||
return pitch;
|
||||
}
|
||||
}
|
||||
+19
-22
@@ -1,9 +1,12 @@
|
||||
/**
|
||||
* Copyright (c) 2020 retrooper
|
||||
*/
|
||||
package io.github.retrooper.packetevents.packetwrappers.out.transaction;
|
||||
|
||||
import io.github.retrooper.packetevents.packet.PacketTypeClasses;
|
||||
import io.github.retrooper.packetevents.packetwrappers.Sendable;
|
||||
import io.github.retrooper.packetevents.packetwrappers.api.WrappedPacket;
|
||||
import io.github.retrooper.packetevents.reflectionutils.Reflection;
|
||||
import io.github.retrooper.packetevents.utils.NMSUtils;
|
||||
|
||||
import java.lang.reflect.Constructor;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
@@ -11,13 +14,22 @@ import java.lang.reflect.InvocationTargetException;
|
||||
public class WrappedPacketOutTransaction extends WrappedPacket implements Sendable {
|
||||
private static Class<?> packetClass;
|
||||
private static Constructor<?> packetConstructor;
|
||||
private int windowId;
|
||||
private short actionNumber;
|
||||
private boolean accepted;
|
||||
public WrappedPacketOutTransaction(final Object packet) {
|
||||
super(packet);
|
||||
}
|
||||
|
||||
static {
|
||||
try {
|
||||
packetClass = NMSUtils.getNMSClass("PacketPlayOutTransaction");
|
||||
} catch (ClassNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
public WrappedPacketOutTransaction(final int windowId, final short actionNumber, final boolean accepted) {
|
||||
super();
|
||||
this.windowId = windowId;
|
||||
this.actionNumber = actionNumber;
|
||||
this.accepted = accepted;
|
||||
}
|
||||
|
||||
public static void load() {
|
||||
packetClass = PacketTypeClasses.Server.TRANSACTION;
|
||||
|
||||
try {
|
||||
packetConstructor = packetClass.getConstructor(int.class, short.class, boolean.class);
|
||||
@@ -26,21 +38,6 @@ public class WrappedPacketOutTransaction extends WrappedPacket implements Sendab
|
||||
}
|
||||
}
|
||||
|
||||
private int windowId;
|
||||
private short actionNumber;
|
||||
private boolean accepted;
|
||||
|
||||
public WrappedPacketOutTransaction(final Object packet) {
|
||||
super(packet);
|
||||
}
|
||||
|
||||
public WrappedPacketOutTransaction(final int windowId, final short actionNumber, final boolean accepted) {
|
||||
super(null);
|
||||
this.windowId = windowId;
|
||||
this.actionNumber = actionNumber;
|
||||
this.accepted = accepted;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setup() {
|
||||
try {
|
||||
|
||||
+15
-18
@@ -1,9 +1,12 @@
|
||||
/**
|
||||
* Copyright (c) 2020 retrooper
|
||||
*/
|
||||
package io.github.retrooper.packetevents.packetwrappers.out.updatehealth;
|
||||
|
||||
import io.github.retrooper.packetevents.packet.PacketTypeClasses;
|
||||
import io.github.retrooper.packetevents.packetwrappers.Sendable;
|
||||
import io.github.retrooper.packetevents.packetwrappers.api.WrappedPacket;
|
||||
import io.github.retrooper.packetevents.reflectionutils.Reflection;
|
||||
import io.github.retrooper.packetevents.utils.NMSUtils;
|
||||
|
||||
import java.lang.reflect.Constructor;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
@@ -11,24 +14,8 @@ import java.lang.reflect.InvocationTargetException;
|
||||
public final class WrappedPacketOutUpdateHealth extends WrappedPacket implements Sendable {
|
||||
private static Class<?> packetClass;
|
||||
private static Constructor<?> packetConstructor;
|
||||
|
||||
static {
|
||||
try {
|
||||
packetClass = NMSUtils.getNMSClass("PacketPlayOutUpdateHealth");
|
||||
} catch (ClassNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
try {
|
||||
packetConstructor = packetClass.getConstructor(float.class, int.class, float.class);
|
||||
} catch (NoSuchMethodException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
private float health, foodSaturation;
|
||||
private int food;
|
||||
|
||||
public WrappedPacketOutUpdateHealth(final Object packet) {
|
||||
super(packet);
|
||||
}
|
||||
@@ -41,12 +28,22 @@ public final class WrappedPacketOutUpdateHealth extends WrappedPacket implements
|
||||
* @param foodSaturation
|
||||
*/
|
||||
public WrappedPacketOutUpdateHealth(final float health, final int food, final float foodSaturation) {
|
||||
super(null);
|
||||
super();
|
||||
this.health = health;
|
||||
this.food = food;
|
||||
this.foodSaturation = foodSaturation;
|
||||
}
|
||||
|
||||
public static void load() {
|
||||
packetClass = PacketTypeClasses.Server.UPDATE_HEALTH;
|
||||
|
||||
try {
|
||||
packetConstructor = packetClass.getConstructor(float.class, int.class, float.class);
|
||||
} catch (NoSuchMethodException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setup() {
|
||||
try {
|
||||
|
||||
@@ -1,3 +1,6 @@
|
||||
/**
|
||||
* Copyright (c) 2020 retrooper
|
||||
*/
|
||||
package io.github.retrooper.packetevents.reflectionutils;
|
||||
|
||||
|
||||
@@ -75,17 +78,16 @@ public final class Reflection {
|
||||
public static Field getField(final Class<?> cls, final int index) {
|
||||
final FieldWithIndex fwi = new FieldWithIndex(cls, index);
|
||||
if (!fieldWithIndexHashMap.containsKey(fwi)) {
|
||||
int i = 0;
|
||||
for (final Field f : getFields(cls)) {
|
||||
if (index == i++) {
|
||||
fieldWithIndexHashMap.put(fwi, f);
|
||||
return f;
|
||||
}
|
||||
final Field[] fields = getFields(cls);
|
||||
if (fields.length <= index) {
|
||||
return null;
|
||||
}
|
||||
final Field field = fields[index];
|
||||
fieldWithIndexHashMap.put(fwi, field);
|
||||
return field;
|
||||
} else {
|
||||
return fieldWithIndexHashMap.get(fwi);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
//METHODS
|
||||
@@ -187,4 +189,4 @@ public final class Reflection {
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
+20
@@ -1,5 +1,10 @@
|
||||
/**
|
||||
* Copyright (c) 2020 retrooper
|
||||
*/
|
||||
package io.github.retrooper.packetevents.reflectionutils.fielddata;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
public class FieldWithIndex {
|
||||
private final Class<?> cls;
|
||||
private final int index;
|
||||
@@ -16,4 +21,19 @@ public class FieldWithIndex {
|
||||
public int getIndex() {
|
||||
return index;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
FieldWithIndex that = (FieldWithIndex) o;
|
||||
return index == that.index &&
|
||||
Objects.equals(cls, that.cls);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(cls, index);
|
||||
}
|
||||
|
||||
}
|
||||
+20
@@ -1,5 +1,10 @@
|
||||
/**
|
||||
* Copyright (c) 2020 retrooper
|
||||
*/
|
||||
package io.github.retrooper.packetevents.reflectionutils.fielddata;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
public class FieldWithName {
|
||||
|
||||
private final Class<?> cls;
|
||||
@@ -17,4 +22,19 @@ public class FieldWithName {
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
FieldWithName that = (FieldWithName) o;
|
||||
return name.equals(that.name) &&
|
||||
Objects.equals(cls, that.cls);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(cls, name);
|
||||
}
|
||||
|
||||
}
|
||||
+21
@@ -1,5 +1,10 @@
|
||||
/**
|
||||
* Copyright (c) 2020 retrooper
|
||||
*/
|
||||
package io.github.retrooper.packetevents.reflectionutils.fielddata;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
public class FieldWithTypeAndIndex {
|
||||
private final Class<?> cls, type;
|
||||
private final int index;
|
||||
@@ -21,4 +26,20 @@ public class FieldWithTypeAndIndex {
|
||||
public int getIndex() {
|
||||
return index;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
FieldWithTypeAndIndex that = (FieldWithTypeAndIndex) o;
|
||||
return index == that.index &&
|
||||
Objects.equals(cls, that.cls) &&
|
||||
Objects.equals(type, that.type);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(cls, type, index);
|
||||
}
|
||||
|
||||
}
|
||||
+21
@@ -1,5 +1,10 @@
|
||||
/**
|
||||
* Copyright (c) 2020 retrooper
|
||||
*/
|
||||
package io.github.retrooper.packetevents.reflectionutils.methoddata;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
public class MethodWithIndexAndParams {
|
||||
private final Class<?> cls;
|
||||
private final int index;
|
||||
@@ -22,4 +27,20 @@ public class MethodWithIndexAndParams {
|
||||
public Class<?>[] getParams() {
|
||||
return params;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
MethodWithIndexAndParams that = (MethodWithIndexAndParams) o;
|
||||
return index == that.index &&
|
||||
Objects.equals(cls, that.cls) &&
|
||||
Objects.equals(params, that.params);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(cls, params, index);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
/**
|
||||
* Copyright (c) 2020 retrooper
|
||||
*/
|
||||
package io.github.retrooper.packetevents.settings;
|
||||
|
||||
import io.github.retrooper.packetevents.enums.ServerVersion;
|
||||
|
||||
public class PacketEventsSettings {
|
||||
private ServerVersion defaultServerVersion;
|
||||
private String identifier = "";
|
||||
private boolean autoResolveClientProtocolVersion;
|
||||
|
||||
/**
|
||||
* If PacketEvents fails to detect your server version, it will use the recommended version
|
||||
*
|
||||
* @return Recommended version
|
||||
*/
|
||||
public ServerVersion getDefaultServerVersion() {
|
||||
return defaultServerVersion;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the default version
|
||||
*
|
||||
* @param version
|
||||
*/
|
||||
public void setDefaultServerVersion(final ServerVersion version) {
|
||||
defaultServerVersion = version;
|
||||
}
|
||||
|
||||
public String getIdentifier() {
|
||||
return identifier;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set a unique Identifier (Usually something that represents your plugin, For example: MyPluginPacketHandler)
|
||||
* If another present plugin uses the same Identifier, It might cause incompatibilities
|
||||
*
|
||||
* @param identifier
|
||||
*/
|
||||
public void setIdentifier(final String identifier) {
|
||||
this.identifier = identifier;
|
||||
}
|
||||
|
||||
public boolean doAutoResolveClientProtocolVersion() {
|
||||
return autoResolveClientProtocolVersion;
|
||||
}
|
||||
|
||||
/**
|
||||
* If PacketEvents fails to detect a client's version
|
||||
* Should it assume that the client is using the same version that the server is?
|
||||
* Returns ACCESS_FAILURE if false
|
||||
*
|
||||
* @param autoResolveClientProtocolVersion
|
||||
*/
|
||||
public void setDoAutoResolveClientProtocolVersion(boolean autoResolveClientProtocolVersion) {
|
||||
this.autoResolveClientProtocolVersion = autoResolveClientProtocolVersion;
|
||||
}
|
||||
}
|
||||
@@ -1,25 +0,0 @@
|
||||
package io.github.retrooper.packetevents.settings;
|
||||
|
||||
import io.github.retrooper.packetevents.enums.ServerVersion;
|
||||
|
||||
public class Settings {
|
||||
private ServerVersion defaultServerVersion;
|
||||
|
||||
/**
|
||||
* If PacketEvents fails to detect your server version, it will use the recommended version
|
||||
*
|
||||
* @return Recommended version
|
||||
*/
|
||||
public ServerVersion getDefaultServerVersion() {
|
||||
return defaultServerVersion;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the recommended version
|
||||
*
|
||||
* @param version
|
||||
*/
|
||||
public void setDefaultServerVersion(final ServerVersion version) {
|
||||
defaultServerVersion = version;
|
||||
}
|
||||
}
|
||||
@@ -1,3 +1,6 @@
|
||||
/**
|
||||
* Copyright (c) 2020 retrooper
|
||||
*/
|
||||
package io.github.retrooper.packetevents.utils;
|
||||
|
||||
import org.bukkit.Location;
|
||||
@@ -15,4 +18,4 @@ public class BlockIteratorUtils {
|
||||
}
|
||||
return block;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,8 @@
|
||||
/**
|
||||
* Copyright (c) 2020 retrooper
|
||||
*/
|
||||
package io.github.retrooper.packetevents.utils;
|
||||
|
||||
import io.github.retrooper.packetevents.PacketEvents;
|
||||
import io.github.retrooper.packetevents.annotations.Nullable;
|
||||
import io.github.retrooper.packetevents.enums.ServerVersion;
|
||||
import io.github.retrooper.packetevents.packetwrappers.Sendable;
|
||||
@@ -16,10 +18,10 @@ import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
public final class NMSUtils {
|
||||
private static final ServerVersion version =ServerVersion.getVersion();
|
||||
public static String nettyPrefix;
|
||||
private static final ServerVersion version = ServerVersion.getVersion();
|
||||
private static final String nmsDir = ServerVersion.getNMSDirectory();
|
||||
private static final String obcDir = ServerVersion.getOBCDirectory();
|
||||
public static String nettyPrefix;
|
||||
public static Class<?> minecraftServerClass, craftWorldsClass,
|
||||
packetClass, entityPlayerClass, playerConnectionClass,
|
||||
craftPlayerClass, serverConnectionClass, craftEntityClass,
|
||||
@@ -102,7 +104,7 @@ public final class NMSUtils {
|
||||
return Class.forName(nettyPrefix + "." + name);
|
||||
}
|
||||
|
||||
public static final String getChannelFutureListFieldName() {
|
||||
public static String getChannelFutureListFieldName() {
|
||||
if (version.isLowerThan(ServerVersion.v_1_8))
|
||||
return "e";
|
||||
if (version.isLowerThan(ServerVersion.v_1_13))
|
||||
@@ -135,7 +137,6 @@ public final class NMSUtils {
|
||||
}
|
||||
|
||||
public static Object getEntityPlayer(final Player player) {
|
||||
Object entityPlayer = null;
|
||||
try {
|
||||
return getCraftPlayerHandle.invoke(getCraftPlayer(player));
|
||||
} catch (IllegalAccessException | InvocationTargetException e) {
|
||||
@@ -184,9 +185,7 @@ public final class NMSUtils {
|
||||
public static ItemStack toBukkitItemStack(final Object nmsItemstack) {
|
||||
try {
|
||||
return (ItemStack) asBukkitCopy.invoke(null, nmsItemstack);
|
||||
} catch (IllegalAccessException e) {
|
||||
e.printStackTrace();
|
||||
} catch (InvocationTargetException e) {
|
||||
} catch (IllegalAccessException | InvocationTargetException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
/**
|
||||
* Copyright (c) 2020 retrooper
|
||||
*/
|
||||
package io.github.retrooper.packetevents.utils.api;
|
||||
|
||||
import io.github.retrooper.packetevents.PacketEvents;
|
||||
import io.github.retrooper.packetevents.enums.ClientVersion;
|
||||
import io.github.retrooper.packetevents.handler.NettyPacketHandler;
|
||||
import io.github.retrooper.packetevents.packetwrappers.Sendable;
|
||||
@@ -41,17 +43,15 @@ public final class PlayerUtils {
|
||||
clearClientVersion(player.getUniqueId());
|
||||
}
|
||||
|
||||
public void injectPlayer(final Player player, final PacketEvents pe) {
|
||||
NettyPacketHandler.injectPlayer(player,pe);
|
||||
public void injectPlayer(final Player player) {
|
||||
NettyPacketHandler.injectPlayer(player);
|
||||
}
|
||||
|
||||
public void uninjectPlayer(final Player player, final PacketEvents pe) {
|
||||
NettyPacketHandler.uninjectPlayer(player, pe);
|
||||
public void uninjectPlayer(final Player player) {
|
||||
NettyPacketHandler.uninjectPlayer(player);
|
||||
}
|
||||
|
||||
public void sendPacket(final Player player, final Sendable sendable) {
|
||||
NMSUtils.sendSendableWrapper(player, sendable);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -1,3 +1,6 @@
|
||||
/**
|
||||
* Copyright (c) 2020 retrooper
|
||||
*/
|
||||
package io.github.retrooper.packetevents.utils.api;
|
||||
|
||||
import io.github.retrooper.packetevents.enums.ServerVersion;
|
||||
@@ -7,18 +10,6 @@ import io.github.retrooper.packetevents.utils.NMSUtils;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
|
||||
public final class ServerUtils {
|
||||
@Deprecated
|
||||
public ServerVersion getServerVersion() {
|
||||
return getVersion();
|
||||
}
|
||||
@Deprecated
|
||||
public double[] getRecentServerTPS() {
|
||||
return getRecentTPS();
|
||||
}
|
||||
@Deprecated
|
||||
public double getCurrentServerTPS() {
|
||||
return getCurrentTPS();
|
||||
}
|
||||
|
||||
public ServerVersion getVersion() {
|
||||
return ServerVersion.getVersion();
|
||||
|
||||
+16
-6
@@ -1,6 +1,8 @@
|
||||
/**
|
||||
* Copyright (c) 2020 retrooper
|
||||
*/
|
||||
package io.github.retrooper.packetevents.utils.nms_entityfinder;
|
||||
|
||||
import io.github.retrooper.packetevents.PacketEvents;
|
||||
import io.github.retrooper.packetevents.annotations.Nullable;
|
||||
import io.github.retrooper.packetevents.enums.ServerVersion;
|
||||
import io.github.retrooper.packetevents.utils.NMSUtils;
|
||||
@@ -13,7 +15,7 @@ import java.lang.reflect.Method;
|
||||
|
||||
public final class EntityFinderUtils {
|
||||
@Nullable
|
||||
private static final ServerVersion version =ServerVersion.getVersion();
|
||||
public static ServerVersion version;
|
||||
private static Class<?> worldServerClass;
|
||||
private static Class<?> craftWorldClass;
|
||||
private static Class<?> entityClass;
|
||||
@@ -21,7 +23,10 @@ public final class EntityFinderUtils {
|
||||
private static Method craftWorldGetHandle;
|
||||
private static Method getBukkitEntity;
|
||||
|
||||
static {
|
||||
private static boolean isServerVersion_v_1_8_x;
|
||||
|
||||
public static void load() {
|
||||
isServerVersion_v_1_8_x = version.isHigherThan(ServerVersion.v_1_7_10) && version.isLowerThan(ServerVersion.v_1_9);
|
||||
try {
|
||||
worldServerClass = NMSUtils.getNMSClass("WorldServer");
|
||||
craftWorldClass = NMSUtils.getOBCClass("CraftWorld");
|
||||
@@ -31,7 +36,7 @@ public final class EntityFinderUtils {
|
||||
}
|
||||
|
||||
try {
|
||||
getEntityByIdMethod = worldServerClass.getMethod(getEntityByNameMethodName(), int.class);
|
||||
getEntityByIdMethod = worldServerClass.getMethod(getEntityByIDMethodName(), int.class);
|
||||
craftWorldGetHandle = craftWorldClass.getMethod("getHandle");
|
||||
getBukkitEntity = entityClass.getMethod("getBukkitEntity");
|
||||
} catch (NoSuchMethodException e) {
|
||||
@@ -80,8 +85,13 @@ public final class EntityFinderUtils {
|
||||
return null;
|
||||
}
|
||||
|
||||
public static String getEntityByNameMethodName() {
|
||||
if (version.isHigherThan(ServerVersion.v_1_7_10) && version.isLowerThan(ServerVersion.v_1_9)) {
|
||||
/**
|
||||
* This is the name of the method that returns the NMS entity when you pass in its ID.
|
||||
* On 1.8->1.8.8 the name is called 'a', on 1.7.10 & 1.9+ the name is called 'getEntity'.
|
||||
* @return entity by ID method name
|
||||
*/
|
||||
public static String getEntityByIDMethodName() {
|
||||
if (isServerVersion_v_1_8_x) {
|
||||
return "a";
|
||||
}
|
||||
return "getEntity";
|
||||
|
||||
@@ -1,3 +1,6 @@
|
||||
/**
|
||||
* Copyright (c) 2020 retrooper
|
||||
*/
|
||||
package io.github.retrooper.packetevents.utils.vector;
|
||||
|
||||
public final class Vector3d {
|
||||
|
||||
@@ -1,3 +1,6 @@
|
||||
/**
|
||||
* Copyright (c) 2020 retrooper
|
||||
*/
|
||||
package io.github.retrooper.packetevents.utils.vector;
|
||||
|
||||
public final class Vector3f {
|
||||
|
||||
@@ -1,3 +1,6 @@
|
||||
/**
|
||||
* Copyright (c) 2020 retrooper
|
||||
*/
|
||||
package io.github.retrooper.packetevents.utils.vector;
|
||||
|
||||
public final class Vector3i {
|
||||
|
||||
+3
@@ -1,3 +1,6 @@
|
||||
/**
|
||||
* Copyright (c) 2020 retrooper
|
||||
*/
|
||||
package io.github.retrooper.packetevents.utils.versionlookup;
|
||||
|
||||
import com.comphenix.protocol.ProtocolLibrary;
|
||||
|
||||
+3
@@ -1,3 +1,6 @@
|
||||
/**
|
||||
* Copyright (c) 2020 retrooper
|
||||
*/
|
||||
package io.github.retrooper.packetevents.utils.versionlookup;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
|
||||
+3
@@ -1,3 +1,6 @@
|
||||
/**
|
||||
* Copyright (c) 2020 retrooper
|
||||
*/
|
||||
package io.github.retrooper.packetevents.utils.versionlookup;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
+3
@@ -1,3 +1,6 @@
|
||||
/**
|
||||
* Copyright (c) 2020 retrooper
|
||||
*/
|
||||
package io.github.retrooper.packetevents.utils.versionlookup;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
|
||||
+3
@@ -1,3 +1,6 @@
|
||||
/**
|
||||
* Copyright (c) 2020 retrooper
|
||||
*/
|
||||
package io.github.retrooper.packetevents.utils.versionlookup;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@@ -1,3 +1,6 @@
|
||||
/**
|
||||
* Copyright (c) 2020 retrooper
|
||||
*/
|
||||
package io.github.retrooper.packetevents.utils.versionlookup;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@@ -1,3 +1,6 @@
|
||||
/**
|
||||
* Copyright (c) 2020 retrooper
|
||||
*/
|
||||
package io.github.retrooper.packetevents.utils.versionlookup;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
|
||||
Reference in new issue
Block a user