Merge pull request #50 from 4drian3d/v3
Version 3.0.0: - Improved Javadocs - Implement proper API - Update to Java 17 - Migrated to Gradle Kotlin DSL - Implement new configuration options: - Implemented SendMode to control the server selection mode - Implemented ignoreSignedPlayer to workaround 1.19.1+ issues with valid signed players - Migrated to Configurate-HOCON - Implemented Paper/Velocity Debug Mode - Added support for Java 9 Modules - Implemented LoginByProxyEvent (Paper event)
This commit is contained in:
commit
ed50af2fef
26
.github/dependabot.yml
vendored
26
.github/dependabot.yml
vendored
@ -5,18 +5,30 @@
|
|||||||
|
|
||||||
version: 2
|
version: 2
|
||||||
updates:
|
updates:
|
||||||
- package-ecosystem: "maven"
|
- package-ecosystem: "gradle"
|
||||||
directory: "/"
|
directory: "/"
|
||||||
schedule:
|
schedule:
|
||||||
interval: "weekly"
|
interval: "weekly"
|
||||||
- package-ecosystem: "maven"
|
- package-ecosystem: "gradle"
|
||||||
directory: "/proxy"
|
directory: "/api/paper"
|
||||||
schedule:
|
schedule:
|
||||||
interval: "daily"
|
interval: "weekly"
|
||||||
- package-ecosystem: "maven"
|
- package-ecosystem: "gradle"
|
||||||
directory: "/spigot"
|
directory: "/api/velocity"
|
||||||
schedule:
|
schedule:
|
||||||
interval: "daily"
|
interval: "weekly"
|
||||||
|
- package-ecosystem: "gradle"
|
||||||
|
directory: "/velocity"
|
||||||
|
schedule:
|
||||||
|
interval: "weekly"
|
||||||
|
- package-ecosystem: "gradle"
|
||||||
|
directory: "/paper"
|
||||||
|
schedule:
|
||||||
|
interval: "weekly"
|
||||||
|
- package-ecosystem: "gradle"
|
||||||
|
directory: "/common"
|
||||||
|
schedule:
|
||||||
|
interval: "weekly"
|
||||||
- package-ecosystem: "github-actions"
|
- package-ecosystem: "github-actions"
|
||||||
directory: "/"
|
directory: "/"
|
||||||
schedule:
|
schedule:
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
name: Maven Build
|
name: Gradle Build
|
||||||
|
|
||||||
on: [push, pull_request]
|
on: [push, pull_request]
|
||||||
|
|
||||||
@ -15,19 +15,17 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
java-version: 17
|
java-version: 17
|
||||||
distribution: 'temurin'
|
distribution: 'temurin'
|
||||||
cache: 'maven'
|
cache: 'gradle'
|
||||||
|
|
||||||
- name: Build with Maven
|
- name: Build with Gradle
|
||||||
uses: nick-invision/retry@v2
|
uses: nick-invision/retry@v2
|
||||||
with:
|
with:
|
||||||
timeout_minutes: 5
|
timeout_minutes: 5
|
||||||
max_attempts: 2
|
max_attempts: 2
|
||||||
command: mvn -B package --file pom.xml
|
command: gradle clean build
|
||||||
|
|
||||||
- name: Upload artifact
|
- name: Upload artifact
|
||||||
uses: actions/upload-artifact@v3
|
uses: actions/upload-artifact@v3
|
||||||
with:
|
with:
|
||||||
name: AuthmeVelocity
|
name: AuthMeVelocity
|
||||||
path: |
|
path: build/libs/AuthMeVelocity.jar
|
||||||
proxy/target/AuthMeVelocity-proxy.jar
|
|
||||||
spigot/target/AuthMeVelocity-spigot.jar
|
|
10
.gitignore
vendored
10
.gitignore
vendored
@ -1,4 +1,9 @@
|
|||||||
|
|
||||||
|
.gradle/
|
||||||
|
/.idea/
|
||||||
|
build/
|
||||||
|
bin/
|
||||||
|
|
||||||
target/
|
target/
|
||||||
pom.xml.tag
|
pom.xml.tag
|
||||||
pom.xml.releaseBackup
|
pom.xml.releaseBackup
|
||||||
@ -18,4 +23,5 @@ buildNumber.properties
|
|||||||
.project
|
.project
|
||||||
.vscode/
|
.vscode/
|
||||||
|
|
||||||
*.class
|
*.class
|
||||||
|
.gitpod.yml
|
674
LICENSE
Normal file
674
LICENSE
Normal file
@ -0,0 +1,674 @@
|
|||||||
|
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>.
|
39
api/paper/build.gradle.kts
Normal file
39
api/paper/build.gradle.kts
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
plugins {
|
||||||
|
`maven-publish`
|
||||||
|
}
|
||||||
|
|
||||||
|
java {
|
||||||
|
withSourcesJar()
|
||||||
|
withJavadocJar()
|
||||||
|
toolchain.languageVersion.set(JavaLanguageVersion.of(17))
|
||||||
|
}
|
||||||
|
|
||||||
|
dependencies {
|
||||||
|
compileOnly("io.papermc.paper:paper-api:1.19.1-R0.1-SNAPSHOT")
|
||||||
|
}
|
||||||
|
|
||||||
|
tasks {
|
||||||
|
compileJava {
|
||||||
|
options.encoding = Charsets.UTF_8.name()
|
||||||
|
options.release.set(17)
|
||||||
|
}
|
||||||
|
javadoc {
|
||||||
|
options.encoding = Charsets.UTF_8.name()
|
||||||
|
(options as StandardJavadocDocletOptions).links(
|
||||||
|
"https://jd.adventure.kyori.net/api/4.11.0/",
|
||||||
|
"https://jd.adventure.kyori.net/text-minimessage/4.11.0/",
|
||||||
|
"https://jd.papermc.io/paper/1.19/"
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
publishing {
|
||||||
|
publications {
|
||||||
|
create<MavenPublication>("maven") {
|
||||||
|
groupId = project.group as String
|
||||||
|
artifactId = project.name
|
||||||
|
version = project.version as String
|
||||||
|
from(components["java"])
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,31 @@
|
|||||||
|
package me.adrianed.authmevelocity.api.paper.event;
|
||||||
|
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.HandlerList;
|
||||||
|
import org.bukkit.event.player.PlayerEvent;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Event to be executed in case a player who has already logged
|
||||||
|
* into a previously configured server enters the server.
|
||||||
|
*
|
||||||
|
* <p>AuthMeVelocity will automatically login this player.</p>
|
||||||
|
*/
|
||||||
|
public final class LoginByProxyEvent extends PlayerEvent {
|
||||||
|
private static final HandlerList HANDLER_LIST = new HandlerList();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new LoginByProxyEvent
|
||||||
|
* @param who the player to be logged in
|
||||||
|
*/
|
||||||
|
public LoginByProxyEvent(@NotNull Player who) {
|
||||||
|
super(who, !Bukkit.isPrimaryThread());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public @NotNull HandlerList getHandlers() {
|
||||||
|
return HANDLER_LIST;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -1,4 +1,4 @@
|
|||||||
package com.glyart.authmevelocity.spigot.events;
|
package me.adrianed.authmevelocity.api.paper.event;
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
@ -7,10 +7,18 @@ import org.bukkit.event.HandlerList;
|
|||||||
import org.bukkit.event.player.PlayerEvent;
|
import org.bukkit.event.player.PlayerEvent;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
public class PreSendLoginEvent extends PlayerEvent implements Cancellable {
|
/**
|
||||||
|
* Event executed before a player is sent to another server after being logged in
|
||||||
|
* <p>Here you have the possibility to cancel the player's sending</p>
|
||||||
|
*/
|
||||||
|
public final class PreSendLoginEvent extends PlayerEvent implements Cancellable {
|
||||||
private static final HandlerList HANDLERS = new HandlerList();
|
private static final HandlerList HANDLERS = new HandlerList();
|
||||||
private boolean isCancelled = false;
|
private boolean isCancelled = false;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new PreSendLoginEvent
|
||||||
|
* @param player the player to be sended
|
||||||
|
*/
|
||||||
public PreSendLoginEvent(@NotNull Player player) {
|
public PreSendLoginEvent(@NotNull Player player) {
|
||||||
super(player, !Bukkit.isPrimaryThread());
|
super(player, !Bukkit.isPrimaryThread());
|
||||||
}
|
}
|
||||||
@ -30,6 +38,10 @@ public class PreSendLoginEvent extends PlayerEvent implements Cancellable {
|
|||||||
return HANDLERS;
|
return HANDLERS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Obtain the handlerlist of this event
|
||||||
|
* @return the handlerlist
|
||||||
|
*/
|
||||||
public static HandlerList getHandlerList() {
|
public static HandlerList getHandlerList() {
|
||||||
return HANDLERS;
|
return HANDLERS;
|
||||||
}
|
}
|
@ -0,0 +1,2 @@
|
|||||||
|
/** AuthMeVelocity Paper API Events */
|
||||||
|
package me.adrianed.authmevelocity.api.paper.event;
|
7
api/paper/src/main/java/module-info.java
Normal file
7
api/paper/src/main/java/module-info.java
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
/**AuthMeVelocity Paper API Module */
|
||||||
|
@SuppressWarnings({"requires-automatic", "requires-transitive-automatic"})
|
||||||
|
module me.adrianed.authmevelocity.api.paper {
|
||||||
|
requires transitive org.bukkit;
|
||||||
|
requires static org.jetbrains.annotations;
|
||||||
|
exports me.adrianed.authmevelocity.api.paper.event;
|
||||||
|
}
|
40
api/velocity/build.gradle.kts
Normal file
40
api/velocity/build.gradle.kts
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
plugins {
|
||||||
|
`maven-publish`
|
||||||
|
}
|
||||||
|
|
||||||
|
dependencies {
|
||||||
|
compileOnly("com.velocitypowered:velocity-api:3.1.2-SNAPSHOT")
|
||||||
|
}
|
||||||
|
|
||||||
|
java {
|
||||||
|
withSourcesJar()
|
||||||
|
withJavadocJar()
|
||||||
|
toolchain.languageVersion.set(JavaLanguageVersion.of(17))
|
||||||
|
}
|
||||||
|
|
||||||
|
tasks {
|
||||||
|
compileJava {
|
||||||
|
options.encoding = Charsets.UTF_8.name()
|
||||||
|
|
||||||
|
options.release.set(17)
|
||||||
|
}
|
||||||
|
javadoc {
|
||||||
|
options.encoding = Charsets.UTF_8.name()
|
||||||
|
(options as StandardJavadocDocletOptions).links(
|
||||||
|
"https://jd.adventure.kyori.net/api/4.11.0/",
|
||||||
|
"https://jd.adventure.kyori.net/text-minimessage/4.11.0/",
|
||||||
|
"https://jd.papermc.io/velocity/3.0.0/"
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
publishing {
|
||||||
|
publications {
|
||||||
|
create<MavenPublication>("maven") {
|
||||||
|
groupId = project.group as String
|
||||||
|
artifactId = project.name
|
||||||
|
version = project.version as String
|
||||||
|
from(components["java"])
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -1,8 +1,7 @@
|
|||||||
package com.glyart.authmevelocity.proxy;
|
package me.adrianed.authmevelocity.api.velocity;
|
||||||
|
|
||||||
import java.util.function.Predicate;
|
import java.util.function.Predicate;
|
||||||
|
|
||||||
import com.glyart.authmevelocity.proxy.config.AuthMeConfig;
|
|
||||||
import com.velocitypowered.api.proxy.Player;
|
import com.velocitypowered.api.proxy.Player;
|
||||||
import com.velocitypowered.api.proxy.ServerConnection;
|
import com.velocitypowered.api.proxy.ServerConnection;
|
||||||
import com.velocitypowered.api.proxy.server.RegisteredServer;
|
import com.velocitypowered.api.proxy.server.RegisteredServer;
|
||||||
@ -12,91 +11,67 @@ import org.jetbrains.annotations.NotNull;
|
|||||||
/**
|
/**
|
||||||
* API provided to interact with logged players
|
* API provided to interact with logged players
|
||||||
*/
|
*/
|
||||||
public final class AuthmeVelocityAPI {
|
public interface AuthMeVelocityAPI {
|
||||||
private final AuthMeVelocityPlugin plugin;
|
|
||||||
private final AuthMeConfig config;
|
|
||||||
AuthmeVelocityAPI(AuthMeVelocityPlugin plugin, AuthMeConfig config){
|
|
||||||
this.plugin = plugin;
|
|
||||||
this.config = config;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check if the player is logged in or not
|
* Check if the player is logged in or not
|
||||||
* @param player the player
|
* @param player the player
|
||||||
* @return if the player is logged in or not
|
* @return if the player is logged in or not
|
||||||
*/
|
*/
|
||||||
public boolean isLogged(@NotNull Player player){
|
boolean isLogged(@NotNull Player player);
|
||||||
return plugin.loggedPlayers.contains(player.getUniqueId());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check if the player is not logged
|
* Check if the player is not logged
|
||||||
* @param player the player
|
* @param player the player
|
||||||
* @return if the player is not logged
|
* @return if the player is not logged
|
||||||
*/
|
*/
|
||||||
public boolean isNotLogged(@NotNull Player player){
|
boolean isNotLogged(@NotNull Player player);
|
||||||
return !plugin.loggedPlayers.contains(player.getUniqueId());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds a player to the list of logged in players
|
* Adds a player to the list of logged in players
|
||||||
* @param player the new logged player
|
* @param player the new logged player
|
||||||
* @return if the player was succesfully added
|
* @return if the player was succesfully added
|
||||||
*/
|
*/
|
||||||
public boolean addPlayer(@NotNull Player player){
|
boolean addPlayer(@NotNull Player player);
|
||||||
return plugin.loggedPlayers.add(player.getUniqueId());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Removes a player from the list of logged-in players
|
* Removes a player from the list of logged-in players
|
||||||
* @param player the unlogged player
|
* @param player the unlogged player
|
||||||
* @return if the player was succesfully removed
|
* @return if the player was succesfully removed
|
||||||
*/
|
*/
|
||||||
public boolean removePlayer(@NotNull Player player){
|
boolean removePlayer(@NotNull Player player);
|
||||||
return plugin.loggedPlayers.remove(player.getUniqueId());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Removes players who meet the established condition
|
* Removes players who meet the established condition
|
||||||
* @param predicate the condition
|
* @param predicate the condition
|
||||||
*/
|
*/
|
||||||
public void removePlayerIf(@NotNull Predicate<Player> predicate){
|
void removePlayerIf(@NotNull Predicate<Player> predicate);
|
||||||
plugin.loggedPlayers.removeIf(uuid -> predicate.test(plugin.getProxy().getPlayer(uuid).orElse(null)));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check if the player is on a login server
|
* Check if the player is on a login server
|
||||||
* @param player the player
|
* @param player the player
|
||||||
* @return if the player is on a login server
|
* @return if the player is on a login server
|
||||||
*/
|
*/
|
||||||
public boolean isInAuthServer(@NotNull Player player){
|
boolean isInAuthServer(@NotNull Player player);
|
||||||
return player.getCurrentServer().map(this::isAuthServer).orElse(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check if a server is intended to be a logging server
|
* Check if a server is intended to be a logging server
|
||||||
* @param server the server
|
* @param server the server
|
||||||
* @return if the server is a login server
|
* @return if the server is a login server
|
||||||
*/
|
*/
|
||||||
public boolean isAuthServer(@NotNull RegisteredServer server){
|
boolean isAuthServer(@NotNull RegisteredServer server);
|
||||||
return config.getAuthServers().contains(server.getServerInfo().getName());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks if a connection is made from a login server
|
* Checks if a connection is made from a login server
|
||||||
* @param connection the connection
|
* @param connection the connection
|
||||||
* @return if the connection is made from a login server
|
* @return if the connection is made from a login server
|
||||||
*/
|
*/
|
||||||
public boolean isAuthServer(@NotNull ServerConnection connection){
|
boolean isAuthServer(@NotNull ServerConnection connection);
|
||||||
return config.getAuthServers().contains(connection.getServerInfo().getName());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks if a string is an name of an auth server
|
* Checks if a string is an name of an auth server
|
||||||
* @param server the server name
|
* @param server the server name
|
||||||
* @return if the server is an auth serverr
|
* @return if the server is an auth serverr
|
||||||
*/
|
*/
|
||||||
public boolean isAuthServer(@NotNull String server){
|
boolean isAuthServer(@NotNull String server);
|
||||||
return config.getAuthServers().contains(server);
|
|
||||||
}
|
|
||||||
}
|
}
|
@ -1,9 +1,9 @@
|
|||||||
package com.glyart.authmevelocity.proxy.event;
|
package me.adrianed.authmevelocity.api.velocity.event;
|
||||||
|
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
||||||
import com.velocitypowered.api.event.ResultedEvent;
|
import com.velocitypowered.api.event.ResultedEvent;
|
||||||
import com.velocitypowered.api.event.ResultedEvent.GenericResult;
|
import com.velocitypowered.api.event.annotation.AwaitingEvent;
|
||||||
import com.velocitypowered.api.proxy.Player;
|
import com.velocitypowered.api.proxy.Player;
|
||||||
import com.velocitypowered.api.proxy.server.RegisteredServer;
|
import com.velocitypowered.api.proxy.server.RegisteredServer;
|
||||||
|
|
||||||
@ -11,14 +11,16 @@ import org.jetbrains.annotations.NotNull;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Event to be executed just before sending a player to another server after login/registration.
|
* Event to be executed just before sending a player to another server after login/registration.
|
||||||
* Here you have the ability to deny the event.
|
*
|
||||||
|
* <p>AuthMeVelocity will wait for the execution of this event to perform the given action,
|
||||||
|
* which means that you can modify the server to which the player will connect
|
||||||
|
* or if the player should not be sent to any server after being logged in</p>
|
||||||
*/
|
*/
|
||||||
public final class PreSendOnLoginEvent implements ResultedEvent<GenericResult> {
|
@AwaitingEvent
|
||||||
|
public final class PreSendOnLoginEvent implements ResultedEvent<ServerResult> {
|
||||||
private GenericResult result = GenericResult.allowed();
|
private ServerResult result;
|
||||||
private final Player player;
|
private final Player player;
|
||||||
private final RegisteredServer actualserver;
|
private final RegisteredServer actualserver;
|
||||||
private final RegisteredServer serverToSend;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new PreSendOnLoginEvent
|
* Create a new PreSendOnLoginEvent
|
||||||
@ -29,14 +31,14 @@ public final class PreSendOnLoginEvent implements ResultedEvent<GenericResult> {
|
|||||||
public PreSendOnLoginEvent(@NotNull Player player, @NotNull RegisteredServer actualServer, @NotNull RegisteredServer serverToSend){
|
public PreSendOnLoginEvent(@NotNull Player player, @NotNull RegisteredServer actualServer, @NotNull RegisteredServer serverToSend){
|
||||||
this.player = player;
|
this.player = player;
|
||||||
this.actualserver = actualServer;
|
this.actualserver = actualServer;
|
||||||
this.serverToSend = serverToSend;
|
result = ServerResult.allowed(serverToSend);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Obtain the logged player
|
* Obtain the logged player
|
||||||
* @return the player
|
* @return the player
|
||||||
*/
|
*/
|
||||||
public @NotNull Player getPlayer(){
|
public @NotNull Player player(){
|
||||||
return this.player;
|
return this.player;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -44,32 +46,17 @@ public final class PreSendOnLoginEvent implements ResultedEvent<GenericResult> {
|
|||||||
* Obtain the server on which the player is located
|
* Obtain the server on which the player is located
|
||||||
* @return the actual server of the player
|
* @return the actual server of the player
|
||||||
*/
|
*/
|
||||||
public @NotNull RegisteredServer getActualServer(){
|
public @NotNull RegisteredServer actualServer(){
|
||||||
return this.actualserver;
|
return this.actualserver;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Obtain the server to which the player will be sent
|
|
||||||
* @return the server to send the player
|
|
||||||
*/
|
|
||||||
public @NotNull RegisteredServer getSendServer(){
|
|
||||||
return this.serverToSend;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the result of the event
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public @NotNull GenericResult getResult() {
|
public @NotNull ServerResult getResult() {
|
||||||
return this.result;
|
return this.result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Set the result of the event
|
|
||||||
* @param newresult the new result
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public void setResult(@NotNull GenericResult newresult) {
|
public void setResult(@NotNull ServerResult newResult) {
|
||||||
this.result = Objects.requireNonNull(newresult);
|
this.result = Objects.requireNonNull(newResult);
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -0,0 +1,8 @@
|
|||||||
|
package me.adrianed.authmevelocity.api.velocity.event;
|
||||||
|
|
||||||
|
import com.velocitypowered.api.proxy.Player;
|
||||||
|
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
|
/**Event executed in case a player is forced unregister by a server operator*/
|
||||||
|
public record ProxyForcedUnregisterEvent(@Nullable Player player) {}
|
@ -0,0 +1,10 @@
|
|||||||
|
package me.adrianed.authmevelocity.api.velocity.event;
|
||||||
|
|
||||||
|
import com.velocitypowered.api.proxy.Player;
|
||||||
|
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Event executed in case the player is successfully logged in
|
||||||
|
*/
|
||||||
|
public record ProxyLoginEvent(@NotNull Player player) {}
|
@ -0,0 +1,8 @@
|
|||||||
|
package me.adrianed.authmevelocity.api.velocity.event;
|
||||||
|
|
||||||
|
import com.velocitypowered.api.proxy.Player;
|
||||||
|
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
/**Event executed in case the player has logout from the network */
|
||||||
|
public record ProxyLogoutEvent(@NotNull Player player) {}
|
@ -0,0 +1,8 @@
|
|||||||
|
package me.adrianed.authmevelocity.api.velocity.event;
|
||||||
|
|
||||||
|
import com.velocitypowered.api.proxy.Player;
|
||||||
|
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
/**Event executed in case the player has register itself*/
|
||||||
|
public record ProxyRegisterEvent(@NotNull Player player) {}
|
@ -0,0 +1,8 @@
|
|||||||
|
package me.adrianed.authmevelocity.api.velocity.event;
|
||||||
|
|
||||||
|
import com.velocitypowered.api.proxy.Player;
|
||||||
|
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
/**Event executed in case the player has unregister itself*/
|
||||||
|
public record ProxyUnregisterEvent(@NotNull Player player) {}
|
@ -0,0 +1,46 @@
|
|||||||
|
package me.adrianed.authmevelocity.api.velocity.event;
|
||||||
|
|
||||||
|
import com.velocitypowered.api.event.ResultedEvent.Result;
|
||||||
|
import com.velocitypowered.api.proxy.server.RegisteredServer;
|
||||||
|
|
||||||
|
/**A result that produces a resulting server */
|
||||||
|
public final class ServerResult implements Result {
|
||||||
|
private static final ServerResult DENIED = new ServerResult(null);
|
||||||
|
|
||||||
|
private final RegisteredServer server;
|
||||||
|
private ServerResult(RegisteredServer server) {
|
||||||
|
this.server = server;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isAllowed() {
|
||||||
|
return this.server != null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Obtain the resulted server
|
||||||
|
* @return the resulted server if is allowed, else null
|
||||||
|
*/
|
||||||
|
public RegisteredServer getServer() {
|
||||||
|
return this.server;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Allowed ServerResult
|
||||||
|
* @param server the resulted server
|
||||||
|
* @return A ServerResult with allowed result and custom server result
|
||||||
|
*/
|
||||||
|
public static final ServerResult allowed(RegisteredServer server) {
|
||||||
|
return new ServerResult(server);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Denied ServerResult
|
||||||
|
*
|
||||||
|
* @return A ServerResult with denied result and null server
|
||||||
|
*/
|
||||||
|
public static final ServerResult denied() {
|
||||||
|
return DENIED;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,2 @@
|
|||||||
|
/** AuthMeVelocity Velocity API Events */
|
||||||
|
package me.adrianed.authmevelocity.api.velocity.event;
|
@ -0,0 +1,2 @@
|
|||||||
|
/** Main AuthMeVelocity Velocity API package */
|
||||||
|
package me.adrianed.authmevelocity.api.velocity;
|
8
api/velocity/src/main/java/module-info.java
Normal file
8
api/velocity/src/main/java/module-info.java
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
/**AuthMeVelocity Velocity API Module */
|
||||||
|
@SuppressWarnings({"requires-automatic", "requires-transitive-automatic"})
|
||||||
|
module me.adrianed.authmevelocity.api.velocity {
|
||||||
|
requires transitive com.velocitypowered.api;
|
||||||
|
requires static org.jetbrains.annotations;
|
||||||
|
exports me.adrianed.authmevelocity.api.velocity;
|
||||||
|
exports me.adrianed.authmevelocity.api.velocity.event;
|
||||||
|
}
|
48
build.gradle.kts
Normal file
48
build.gradle.kts
Normal file
@ -0,0 +1,48 @@
|
|||||||
|
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
|
||||||
|
|
||||||
|
plugins {
|
||||||
|
java
|
||||||
|
id("com.github.johnrengelman.shadow") version "7.1.2"
|
||||||
|
}
|
||||||
|
|
||||||
|
repositories {
|
||||||
|
maven("https://repo.alessiodp.com/releases/")
|
||||||
|
}
|
||||||
|
|
||||||
|
allprojects {
|
||||||
|
apply<JavaPlugin>()
|
||||||
|
repositories {
|
||||||
|
mavenCentral()
|
||||||
|
maven("https://repo.papermc.io/repository/maven-public/")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
dependencies {
|
||||||
|
shadow(project(":authmevelocity-common", "shadow"))
|
||||||
|
shadow(project(":authmevelocity-api-paper"))
|
||||||
|
shadow(project(":authmevelocity-api-velocity"))
|
||||||
|
shadow(project(":authmevelocity-velocity", "shadow"))
|
||||||
|
shadow(project(":authmevelocity-paper", "shadow"))
|
||||||
|
}
|
||||||
|
|
||||||
|
tasks {
|
||||||
|
shadowJar {
|
||||||
|
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
|
||||||
|
archiveFileName.set("AuthMeVelocity.jar")
|
||||||
|
configurations = listOf(project.configurations.shadow.get())
|
||||||
|
exclude("net/byteflux/libby/**/")
|
||||||
|
exclude("org/bstats/**/")
|
||||||
|
}
|
||||||
|
|
||||||
|
build {
|
||||||
|
dependsOn(shadowJar)
|
||||||
|
}
|
||||||
|
|
||||||
|
compileJava {
|
||||||
|
options.encoding = Charsets.UTF_8.name()
|
||||||
|
|
||||||
|
options.release.set(17)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
java.toolchain.languageVersion.set(JavaLanguageVersion.of(17))
|
36
common/build.gradle.kts
Normal file
36
common/build.gradle.kts
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
plugins {
|
||||||
|
id("net.kyori.blossom") version "1.3.1"
|
||||||
|
id("com.github.johnrengelman.shadow") version "7.1.2"
|
||||||
|
}
|
||||||
|
|
||||||
|
repositories {
|
||||||
|
maven("https://repo.alessiodp.com/releases/")
|
||||||
|
}
|
||||||
|
|
||||||
|
dependencies {
|
||||||
|
compileOnly("org.spongepowered:configurate-hocon:4.1.2")
|
||||||
|
compileOnly("org.slf4j:slf4j-api:1.7.36")
|
||||||
|
compileOnly("net.byteflux:libby-core:1.1.5")
|
||||||
|
compileOnly("net.kyori:adventure-api:4.11.0")
|
||||||
|
}
|
||||||
|
|
||||||
|
tasks {
|
||||||
|
shadowJar {
|
||||||
|
relocate("net.byteflux.libby", "me.adrianed.authmevelocity.libs.libby")
|
||||||
|
relocate("org.spongepowered", "me.adrianed.authmevelocity.libs.sponge")
|
||||||
|
relocate("io.leangen.geantyref", "me.adrianed.authmevelocity.libs.geantyref")
|
||||||
|
}
|
||||||
|
compileJava {
|
||||||
|
options.encoding = Charsets.UTF_8.name()
|
||||||
|
|
||||||
|
options.release.set(17)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
java.toolchain.languageVersion.set(JavaLanguageVersion.of(17))
|
||||||
|
|
||||||
|
blossom {
|
||||||
|
replaceTokenIn("src/main/java/me/adrianed/authmevelocity/common/Constants.java")
|
||||||
|
replaceToken("{version}", project.version)
|
||||||
|
replaceToken("{description}", project.description)
|
||||||
|
}
|
@ -0,0 +1,10 @@
|
|||||||
|
package me.adrianed.authmevelocity.common;
|
||||||
|
|
||||||
|
public final class Constants {
|
||||||
|
private Constants() {}
|
||||||
|
|
||||||
|
public static final String VERSION = "{version}";
|
||||||
|
public static final String DESCRIPTION = "{description}";
|
||||||
|
public static final String CONFIGURATE = "4.1.2";
|
||||||
|
public static final String GEANTYREF = "1.3.13";
|
||||||
|
}
|
@ -0,0 +1,49 @@
|
|||||||
|
package me.adrianed.authmevelocity.common;
|
||||||
|
|
||||||
|
import net.byteflux.libby.Library;
|
||||||
|
import net.byteflux.libby.LibraryManager;
|
||||||
|
import net.byteflux.libby.relocation.Relocation;
|
||||||
|
|
||||||
|
|
||||||
|
public final class LibsManager {
|
||||||
|
private final LibraryManager manager;
|
||||||
|
|
||||||
|
public LibsManager(LibraryManager manager) {
|
||||||
|
this.manager = manager;
|
||||||
|
manager.addMavenCentral();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void loadLibraries() {
|
||||||
|
final Relocation configurateRelocation
|
||||||
|
= new Relocation("org{}spongepowered", "me.adrianed.authmevelocity.libs.sponge");
|
||||||
|
final Relocation geantyrefRelocation =
|
||||||
|
new Relocation("io{}leangen{}geantyref", "me.adrianed.authmevelocity.libs.geantyref");
|
||||||
|
final Library hocon = Library.builder()
|
||||||
|
.groupId("org{}spongepowered")
|
||||||
|
.artifactId("configurate-hocon")
|
||||||
|
.version(Constants.CONFIGURATE)
|
||||||
|
.id("configurate-hocon")
|
||||||
|
.relocate(configurateRelocation)
|
||||||
|
.relocate(geantyrefRelocation)
|
||||||
|
.build();
|
||||||
|
final Library confCore = Library.builder()
|
||||||
|
.groupId("org{}spongepowered")
|
||||||
|
.artifactId("configurate-core")
|
||||||
|
.version(Constants.CONFIGURATE)
|
||||||
|
.id("configurate-core")
|
||||||
|
.relocate(configurateRelocation)
|
||||||
|
.relocate(geantyrefRelocation)
|
||||||
|
.build();
|
||||||
|
final Library geantyref = Library.builder()
|
||||||
|
.groupId("io{}leangen{}geantyref")
|
||||||
|
.artifactId("geantyref")
|
||||||
|
.version(Constants.GEANTYREF)
|
||||||
|
.id("geantyref")
|
||||||
|
.relocate(geantyrefRelocation)
|
||||||
|
.build();
|
||||||
|
|
||||||
|
manager.loadLibrary(confCore);
|
||||||
|
manager.loadLibrary(hocon);
|
||||||
|
manager.loadLibrary(geantyref);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,11 @@
|
|||||||
|
package me.adrianed.authmevelocity.common;
|
||||||
|
|
||||||
|
import net.kyori.adventure.util.Index;
|
||||||
|
|
||||||
|
public enum MessageType {
|
||||||
|
LOGIN, REGISTER, LOGOUT, FORCE_UNREGISTER, UNREGISTER;
|
||||||
|
|
||||||
|
// Enum#values is a heavy operation, so... cached MessageType members
|
||||||
|
public static final Index<String, MessageType> INDEX
|
||||||
|
= Index.create(MessageType::toString, MessageType.values());
|
||||||
|
}
|
@ -0,0 +1,61 @@
|
|||||||
|
package me.adrianed.authmevelocity.common.configuration;
|
||||||
|
|
||||||
|
import java.util.concurrent.CompletableFuture;
|
||||||
|
import java.util.function.Consumer;
|
||||||
|
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.spongepowered.configurate.CommentedConfigurationNode;
|
||||||
|
import org.spongepowered.configurate.ConfigurateException;
|
||||||
|
import org.spongepowered.configurate.hocon.HoconConfigurationLoader;
|
||||||
|
|
||||||
|
public class ConfigurationContainer<C> {
|
||||||
|
private C config;
|
||||||
|
private final HoconConfigurationLoader loader;
|
||||||
|
private final Class<C> clazz;
|
||||||
|
private final Logger logger;
|
||||||
|
|
||||||
|
public ConfigurationContainer(
|
||||||
|
final C config,
|
||||||
|
final Class<C> clazz,
|
||||||
|
final HoconConfigurationLoader loader,
|
||||||
|
final Logger logger
|
||||||
|
) {
|
||||||
|
this.config = config;
|
||||||
|
this.loader = loader;
|
||||||
|
this.clazz = clazz;
|
||||||
|
this.logger = logger;
|
||||||
|
}
|
||||||
|
|
||||||
|
public CompletableFuture<Boolean> reload() {
|
||||||
|
return this.safeReload();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setValues(Consumer<C> consumer) {
|
||||||
|
consumer.accept(this.config);
|
||||||
|
this.safeReload();
|
||||||
|
}
|
||||||
|
|
||||||
|
public C get() {
|
||||||
|
return this.config;
|
||||||
|
}
|
||||||
|
|
||||||
|
private final CompletableFuture<Boolean> safeReload() {
|
||||||
|
return CompletableFuture.supplyAsync(() -> {
|
||||||
|
C newConfig = null;
|
||||||
|
try {
|
||||||
|
final CommentedConfigurationNode node = loader.load();
|
||||||
|
newConfig = node.get(clazz);
|
||||||
|
node.set(clazz, config);
|
||||||
|
loader.save(node);
|
||||||
|
return true;
|
||||||
|
} catch (ConfigurateException exception) {
|
||||||
|
logger.error("Could not load config.conf file", exception);
|
||||||
|
return false;
|
||||||
|
} finally {
|
||||||
|
if (newConfig != null) {
|
||||||
|
config = newConfig;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,35 @@
|
|||||||
|
package me.adrianed.authmevelocity.common.configuration;
|
||||||
|
|
||||||
|
import java.nio.file.Path;
|
||||||
|
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
|
||||||
|
import org.spongepowered.configurate.CommentedConfigurationNode;
|
||||||
|
import org.spongepowered.configurate.ConfigurateException;
|
||||||
|
import org.spongepowered.configurate.hocon.HoconConfigurationLoader;
|
||||||
|
|
||||||
|
|
||||||
|
public final class Loader {
|
||||||
|
private Loader() {}
|
||||||
|
public static <C> ConfigurationContainer<C> loadMainConfig(final Path path, Class<C> clazz, Logger logger){
|
||||||
|
final HoconConfigurationLoader loader = HoconConfigurationLoader.builder()
|
||||||
|
.defaultOptions(opts -> opts
|
||||||
|
.shouldCopyDefaults(true)
|
||||||
|
.header("AuthMeVelocity | by Glyart & 4drian3d\n")
|
||||||
|
)
|
||||||
|
.path(path.resolve("config.conf"))
|
||||||
|
.build();
|
||||||
|
|
||||||
|
final C config;
|
||||||
|
try {
|
||||||
|
final CommentedConfigurationNode node = loader.load();
|
||||||
|
config = node.get(clazz);
|
||||||
|
node.set(clazz, config);
|
||||||
|
loader.save(node);
|
||||||
|
} catch (ConfigurateException exception){
|
||||||
|
logger.error("Could not load config.conf file", exception);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return new ConfigurationContainer<>(config, clazz, loader, logger);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,13 @@
|
|||||||
|
package me.adrianed.authmevelocity.common.configuration;
|
||||||
|
|
||||||
|
import org.spongepowered.configurate.objectmapping.ConfigSerializable;
|
||||||
|
import org.spongepowered.configurate.objectmapping.meta.Comment;
|
||||||
|
|
||||||
|
@ConfigSerializable
|
||||||
|
public class PaperConfiguration {
|
||||||
|
@Comment("Enable Debug Mode")
|
||||||
|
private boolean debug = false;
|
||||||
|
public boolean debug() {
|
||||||
|
return this.debug;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,128 @@
|
|||||||
|
package me.adrianed.authmevelocity.common.configuration;
|
||||||
|
|
||||||
|
import org.spongepowered.configurate.objectmapping.ConfigSerializable;
|
||||||
|
import org.spongepowered.configurate.objectmapping.meta.Comment;
|
||||||
|
|
||||||
|
import me.adrianed.authmevelocity.common.enums.SendMode;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@ConfigSerializable
|
||||||
|
public class ProxyConfiguration {
|
||||||
|
@Comment("List of login/registration servers")
|
||||||
|
private List<String> authServers = List.of("auth1", "auth2");
|
||||||
|
public List<String> authServers() {
|
||||||
|
return this.authServers;
|
||||||
|
}
|
||||||
|
|
||||||
|
private SendOnLogin sendOnLogin = new SendOnLogin();
|
||||||
|
public SendOnLogin sendOnLogin() {
|
||||||
|
return this.sendOnLogin;
|
||||||
|
}
|
||||||
|
|
||||||
|
private Commands commands = new Commands();
|
||||||
|
public Commands commands() {
|
||||||
|
return this.commands;
|
||||||
|
}
|
||||||
|
|
||||||
|
private EnsureAuthServer ensureAuthServer = new EnsureAuthServer();
|
||||||
|
public EnsureAuthServer ensureAuthServer() {
|
||||||
|
return this.ensureAuthServer;
|
||||||
|
}
|
||||||
|
|
||||||
|
private Advanced advanced = new Advanced();
|
||||||
|
public Advanced advanced() {
|
||||||
|
return this.advanced;
|
||||||
|
}
|
||||||
|
|
||||||
|
@ConfigSerializable
|
||||||
|
public static class EnsureAuthServer {
|
||||||
|
@Comment("Ensure that the first server to which players connect is an auth server")
|
||||||
|
private boolean ensureAuthServer = false;
|
||||||
|
public boolean ensureFirstServerIsAuthServer() {
|
||||||
|
return this.ensureAuthServer;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Comment("""
|
||||||
|
Selection Mode of the player's initial server
|
||||||
|
TO_FIRST | Send to the first valid server configured
|
||||||
|
TO_EMPTIEST_SERVER | Send to the server with the lowest number of players
|
||||||
|
RANDOM | Send to a random server""")
|
||||||
|
private SendMode sendMode = SendMode.RANDOM;
|
||||||
|
public SendMode sendMode() {
|
||||||
|
return this.sendMode;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@ConfigSerializable
|
||||||
|
public static class SendOnLogin {
|
||||||
|
@Comment("Send logged in players to another server?")
|
||||||
|
private boolean sendOnLogin = false;
|
||||||
|
public boolean sendToServerOnLogin() {
|
||||||
|
return this.sendOnLogin;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Comment("""
|
||||||
|
List of servers to send
|
||||||
|
One of these servers will be chosen at random""")
|
||||||
|
private List<String> teleportServers = List.of("lobby1", "lobby2");
|
||||||
|
public List<String> teleportServers() {
|
||||||
|
return this.teleportServers;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Comment("""
|
||||||
|
Selection Mode of the server to which the player will be sent
|
||||||
|
TO_FIRST | Send to the first valid server configured
|
||||||
|
TO_EMPTIEST_SERVER | Send to the server with the lowest number of players
|
||||||
|
RANDOM | Send to a random server""")
|
||||||
|
private SendMode sendMode = SendMode.RANDOM;
|
||||||
|
public SendMode sendMode() {
|
||||||
|
return this.sendMode;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@ConfigSerializable
|
||||||
|
public static class Commands {
|
||||||
|
@Comment("Sets the commands that users who have not yet logged in can execute")
|
||||||
|
private List<String> allowedCommands = List.of("login", "register", "l", "reg", "email", "captcha");
|
||||||
|
public List<String> allowedCommands() {
|
||||||
|
return this.allowedCommands;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Comment("""
|
||||||
|
Sets the message to send in case a non-logged-in player executes an unauthorized command
|
||||||
|
To deactivate the message, leave it empty""")
|
||||||
|
private String blockedMessage = "<red>You cannot execute commands if you are not logged in yet";
|
||||||
|
public String blockedCommandMessage() {
|
||||||
|
return this.blockedMessage;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@ConfigSerializable
|
||||||
|
public static class Advanced {
|
||||||
|
@Comment("Enable debug mode")
|
||||||
|
private boolean debug = false;
|
||||||
|
public boolean debug() {
|
||||||
|
return this.debug;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Comment("Attempts to get a valid server in SendMode Random")
|
||||||
|
private int randomAttempts = 5;
|
||||||
|
public int randomAttempts() {
|
||||||
|
return this.randomAttempts;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Comment("""
|
||||||
|
Ignore blocking of commands and chat messages to 1.19.1 clients with a valid signed key
|
||||||
|
When trying to block these executions, the proxy will kick the player out.
|
||||||
|
This option allows you to prevent the plugin from trying to block these executions,
|
||||||
|
avoiding the player to be kicked out""")
|
||||||
|
private boolean ignoreSignedPlayers = false;
|
||||||
|
public boolean ignoreSignedPlayers() {
|
||||||
|
return this.ignoreSignedPlayers;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,7 @@
|
|||||||
|
package me.adrianed.authmevelocity.common.enums;
|
||||||
|
|
||||||
|
public enum SendMode {
|
||||||
|
TO_FIRST,
|
||||||
|
TO_EMPTIEST_SERVER,
|
||||||
|
RANDOM;
|
||||||
|
}
|
9
gradle.properties
Normal file
9
gradle.properties
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
group = me.adrianed.authmevelocity
|
||||||
|
version = 3.0.0-SNAPSHOT
|
||||||
|
description = AuthMeReloaded Support for Velocity
|
||||||
|
url = https://github.com/4drian3d/AuthMeVelocity
|
||||||
|
id = authmevelocity
|
||||||
|
|
||||||
|
caffeine-version = 3.1.1
|
||||||
|
configurate-version = 4.1.2
|
||||||
|
geantyref-version = 1.3.13
|
BIN
gradle/wrapper/gradle-wrapper.jar
vendored
Normal file
BIN
gradle/wrapper/gradle-wrapper.jar
vendored
Normal file
Binary file not shown.
5
gradle/wrapper/gradle-wrapper.properties
vendored
Normal file
5
gradle/wrapper/gradle-wrapper.properties
vendored
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
distributionBase=GRADLE_USER_HOME
|
||||||
|
distributionPath=wrapper/dists
|
||||||
|
distributionUrl=https\://services.gradle.org/distributions/gradle-7.5.1-bin.zip
|
||||||
|
zipStoreBase=GRADLE_USER_HOME
|
||||||
|
zipStorePath=wrapper/dists
|
240
gradlew
vendored
Executable file
240
gradlew
vendored
Executable file
@ -0,0 +1,240 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
#
|
||||||
|
# Copyright © 2015-2021 the original authors.
|
||||||
|
#
|
||||||
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
# you may not use this file except in compliance with the License.
|
||||||
|
# You may obtain a copy of the License at
|
||||||
|
#
|
||||||
|
# https://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
#
|
||||||
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
# See the License for the specific language governing permissions and
|
||||||
|
# limitations under the License.
|
||||||
|
#
|
||||||
|
|
||||||
|
##############################################################################
|
||||||
|
#
|
||||||
|
# Gradle start up script for POSIX generated by Gradle.
|
||||||
|
#
|
||||||
|
# Important for running:
|
||||||
|
#
|
||||||
|
# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is
|
||||||
|
# noncompliant, but you have some other compliant shell such as ksh or
|
||||||
|
# bash, then to run this script, type that shell name before the whole
|
||||||
|
# command line, like:
|
||||||
|
#
|
||||||
|
# ksh Gradle
|
||||||
|
#
|
||||||
|
# Busybox and similar reduced shells will NOT work, because this script
|
||||||
|
# requires all of these POSIX shell features:
|
||||||
|
# * functions;
|
||||||
|
# * expansions «$var», «${var}», «${var:-default}», «${var+SET}»,
|
||||||
|
# «${var#prefix}», «${var%suffix}», and «$( cmd )»;
|
||||||
|
# * compound commands having a testable exit status, especially «case»;
|
||||||
|
# * various built-in commands including «command», «set», and «ulimit».
|
||||||
|
#
|
||||||
|
# Important for patching:
|
||||||
|
#
|
||||||
|
# (2) This script targets any POSIX shell, so it avoids extensions provided
|
||||||
|
# by Bash, Ksh, etc; in particular arrays are avoided.
|
||||||
|
#
|
||||||
|
# The "traditional" practice of packing multiple parameters into a
|
||||||
|
# space-separated string is a well documented source of bugs and security
|
||||||
|
# problems, so this is (mostly) avoided, by progressively accumulating
|
||||||
|
# options in "$@", and eventually passing that to Java.
|
||||||
|
#
|
||||||
|
# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS,
|
||||||
|
# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly;
|
||||||
|
# see the in-line comments for details.
|
||||||
|
#
|
||||||
|
# There are tweaks for specific operating systems such as AIX, CygWin,
|
||||||
|
# Darwin, MinGW, and NonStop.
|
||||||
|
#
|
||||||
|
# (3) This script is generated from the Groovy template
|
||||||
|
# https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
|
||||||
|
# within the Gradle project.
|
||||||
|
#
|
||||||
|
# You can find Gradle at https://github.com/gradle/gradle/.
|
||||||
|
#
|
||||||
|
##############################################################################
|
||||||
|
|
||||||
|
# Attempt to set APP_HOME
|
||||||
|
|
||||||
|
# Resolve links: $0 may be a link
|
||||||
|
app_path=$0
|
||||||
|
|
||||||
|
# Need this for daisy-chained symlinks.
|
||||||
|
while
|
||||||
|
APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path
|
||||||
|
[ -h "$app_path" ]
|
||||||
|
do
|
||||||
|
ls=$( ls -ld "$app_path" )
|
||||||
|
link=${ls#*' -> '}
|
||||||
|
case $link in #(
|
||||||
|
/*) app_path=$link ;; #(
|
||||||
|
*) app_path=$APP_HOME$link ;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
|
APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit
|
||||||
|
|
||||||
|
APP_NAME="Gradle"
|
||||||
|
APP_BASE_NAME=${0##*/}
|
||||||
|
|
||||||
|
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||||
|
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
|
||||||
|
|
||||||
|
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
||||||
|
MAX_FD=maximum
|
||||||
|
|
||||||
|
warn () {
|
||||||
|
echo "$*"
|
||||||
|
} >&2
|
||||||
|
|
||||||
|
die () {
|
||||||
|
echo
|
||||||
|
echo "$*"
|
||||||
|
echo
|
||||||
|
exit 1
|
||||||
|
} >&2
|
||||||
|
|
||||||
|
# OS specific support (must be 'true' or 'false').
|
||||||
|
cygwin=false
|
||||||
|
msys=false
|
||||||
|
darwin=false
|
||||||
|
nonstop=false
|
||||||
|
case "$( uname )" in #(
|
||||||
|
CYGWIN* ) cygwin=true ;; #(
|
||||||
|
Darwin* ) darwin=true ;; #(
|
||||||
|
MSYS* | MINGW* ) msys=true ;; #(
|
||||||
|
NONSTOP* ) nonstop=true ;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
|
||||||
|
|
||||||
|
|
||||||
|
# Determine the Java command to use to start the JVM.
|
||||||
|
if [ -n "$JAVA_HOME" ] ; then
|
||||||
|
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
|
||||||
|
# IBM's JDK on AIX uses strange locations for the executables
|
||||||
|
JAVACMD=$JAVA_HOME/jre/sh/java
|
||||||
|
else
|
||||||
|
JAVACMD=$JAVA_HOME/bin/java
|
||||||
|
fi
|
||||||
|
if [ ! -x "$JAVACMD" ] ; then
|
||||||
|
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
|
||||||
|
|
||||||
|
Please set the JAVA_HOME variable in your environment to match the
|
||||||
|
location of your Java installation."
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
JAVACMD=java
|
||||||
|
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||||
|
|
||||||
|
Please set the JAVA_HOME variable in your environment to match the
|
||||||
|
location of your Java installation."
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Increase the maximum file descriptors if we can.
|
||||||
|
if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
|
||||||
|
case $MAX_FD in #(
|
||||||
|
max*)
|
||||||
|
MAX_FD=$( ulimit -H -n ) ||
|
||||||
|
warn "Could not query maximum file descriptor limit"
|
||||||
|
esac
|
||||||
|
case $MAX_FD in #(
|
||||||
|
'' | soft) :;; #(
|
||||||
|
*)
|
||||||
|
ulimit -n "$MAX_FD" ||
|
||||||
|
warn "Could not set maximum file descriptor limit to $MAX_FD"
|
||||||
|
esac
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Collect all arguments for the java command, stacking in reverse order:
|
||||||
|
# * args from the command line
|
||||||
|
# * the main class name
|
||||||
|
# * -classpath
|
||||||
|
# * -D...appname settings
|
||||||
|
# * --module-path (only if needed)
|
||||||
|
# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables.
|
||||||
|
|
||||||
|
# For Cygwin or MSYS, switch paths to Windows format before running java
|
||||||
|
if "$cygwin" || "$msys" ; then
|
||||||
|
APP_HOME=$( cygpath --path --mixed "$APP_HOME" )
|
||||||
|
CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" )
|
||||||
|
|
||||||
|
JAVACMD=$( cygpath --unix "$JAVACMD" )
|
||||||
|
|
||||||
|
# Now convert the arguments - kludge to limit ourselves to /bin/sh
|
||||||
|
for arg do
|
||||||
|
if
|
||||||
|
case $arg in #(
|
||||||
|
-*) false ;; # don't mess with options #(
|
||||||
|
/?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath
|
||||||
|
[ -e "$t" ] ;; #(
|
||||||
|
*) false ;;
|
||||||
|
esac
|
||||||
|
then
|
||||||
|
arg=$( cygpath --path --ignore --mixed "$arg" )
|
||||||
|
fi
|
||||||
|
# Roll the args list around exactly as many times as the number of
|
||||||
|
# args, so each arg winds up back in the position where it started, but
|
||||||
|
# possibly modified.
|
||||||
|
#
|
||||||
|
# NB: a `for` loop captures its iteration list before it begins, so
|
||||||
|
# changing the positional parameters here affects neither the number of
|
||||||
|
# iterations, nor the values presented in `arg`.
|
||||||
|
shift # remove old arg
|
||||||
|
set -- "$@" "$arg" # push replacement arg
|
||||||
|
done
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Collect all arguments for the java command;
|
||||||
|
# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of
|
||||||
|
# shell script including quotes and variable substitutions, so put them in
|
||||||
|
# double quotes to make sure that they get re-expanded; and
|
||||||
|
# * put everything else in single quotes, so that it's not re-expanded.
|
||||||
|
|
||||||
|
set -- \
|
||||||
|
"-Dorg.gradle.appname=$APP_BASE_NAME" \
|
||||||
|
-classpath "$CLASSPATH" \
|
||||||
|
org.gradle.wrapper.GradleWrapperMain \
|
||||||
|
"$@"
|
||||||
|
|
||||||
|
# Stop when "xargs" is not available.
|
||||||
|
if ! command -v xargs >/dev/null 2>&1
|
||||||
|
then
|
||||||
|
die "xargs is not available"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Use "xargs" to parse quoted args.
|
||||||
|
#
|
||||||
|
# With -n1 it outputs one arg per line, with the quotes and backslashes removed.
|
||||||
|
#
|
||||||
|
# In Bash we could simply go:
|
||||||
|
#
|
||||||
|
# readarray ARGS < <( xargs -n1 <<<"$var" ) &&
|
||||||
|
# set -- "${ARGS[@]}" "$@"
|
||||||
|
#
|
||||||
|
# but POSIX shell has neither arrays nor command substitution, so instead we
|
||||||
|
# post-process each arg (as a line of input to sed) to backslash-escape any
|
||||||
|
# character that might be a shell metacharacter, then use eval to reverse
|
||||||
|
# that process (while maintaining the separation between arguments), and wrap
|
||||||
|
# the whole thing up as a single "set" statement.
|
||||||
|
#
|
||||||
|
# This will of course break if any of these variables contains a newline or
|
||||||
|
# an unmatched quote.
|
||||||
|
#
|
||||||
|
|
||||||
|
eval "set -- $(
|
||||||
|
printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" |
|
||||||
|
xargs -n1 |
|
||||||
|
sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' |
|
||||||
|
tr '\n' ' '
|
||||||
|
)" '"$@"'
|
||||||
|
|
||||||
|
exec "$JAVACMD" "$@"
|
91
gradlew.bat
vendored
Normal file
91
gradlew.bat
vendored
Normal file
@ -0,0 +1,91 @@
|
|||||||
|
@rem
|
||||||
|
@rem Copyright 2015 the original author or authors.
|
||||||
|
@rem
|
||||||
|
@rem Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
@rem you may not use this file except in compliance with the License.
|
||||||
|
@rem You may obtain a copy of the License at
|
||||||
|
@rem
|
||||||
|
@rem https://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
@rem
|
||||||
|
@rem Unless required by applicable law or agreed to in writing, software
|
||||||
|
@rem distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
@rem See the License for the specific language governing permissions and
|
||||||
|
@rem limitations under the License.
|
||||||
|
@rem
|
||||||
|
|
||||||
|
@if "%DEBUG%"=="" @echo off
|
||||||
|
@rem ##########################################################################
|
||||||
|
@rem
|
||||||
|
@rem Gradle startup script for Windows
|
||||||
|
@rem
|
||||||
|
@rem ##########################################################################
|
||||||
|
|
||||||
|
@rem Set local scope for the variables with windows NT shell
|
||||||
|
if "%OS%"=="Windows_NT" setlocal
|
||||||
|
|
||||||
|
set DIRNAME=%~dp0
|
||||||
|
if "%DIRNAME%"=="" set DIRNAME=.
|
||||||
|
set APP_BASE_NAME=%~n0
|
||||||
|
set APP_HOME=%DIRNAME%
|
||||||
|
|
||||||
|
@rem Resolve any "." and ".." in APP_HOME to make it shorter.
|
||||||
|
for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
|
||||||
|
|
||||||
|
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||||
|
set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
|
||||||
|
|
||||||
|
@rem Find java.exe
|
||||||
|
if defined JAVA_HOME goto findJavaFromJavaHome
|
||||||
|
|
||||||
|
set JAVA_EXE=java.exe
|
||||||
|
%JAVA_EXE% -version >NUL 2>&1
|
||||||
|
if %ERRORLEVEL% equ 0 goto execute
|
||||||
|
|
||||||
|
echo.
|
||||||
|
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||||
|
echo.
|
||||||
|
echo Please set the JAVA_HOME variable in your environment to match the
|
||||||
|
echo location of your Java installation.
|
||||||
|
|
||||||
|
goto fail
|
||||||
|
|
||||||
|
:findJavaFromJavaHome
|
||||||
|
set JAVA_HOME=%JAVA_HOME:"=%
|
||||||
|
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
|
||||||
|
|
||||||
|
if exist "%JAVA_EXE%" goto execute
|
||||||
|
|
||||||
|
echo.
|
||||||
|
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
|
||||||
|
echo.
|
||||||
|
echo Please set the JAVA_HOME variable in your environment to match the
|
||||||
|
echo location of your Java installation.
|
||||||
|
|
||||||
|
goto fail
|
||||||
|
|
||||||
|
:execute
|
||||||
|
@rem Setup the command line
|
||||||
|
|
||||||
|
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
|
||||||
|
|
||||||
|
|
||||||
|
@rem Execute Gradle
|
||||||
|
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
|
||||||
|
|
||||||
|
:end
|
||||||
|
@rem End local scope for the variables with windows NT shell
|
||||||
|
if %ERRORLEVEL% equ 0 goto mainEnd
|
||||||
|
|
||||||
|
:fail
|
||||||
|
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
|
||||||
|
rem the _cmd.exe /c_ return code!
|
||||||
|
set EXIT_CODE=%ERRORLEVEL%
|
||||||
|
if %EXIT_CODE% equ 0 set EXIT_CODE=1
|
||||||
|
if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE%
|
||||||
|
exit /b %EXIT_CODE%
|
||||||
|
|
||||||
|
:mainEnd
|
||||||
|
if "%OS%"=="Windows_NT" endlocal
|
||||||
|
|
||||||
|
:omega
|
@ -1,3 +1,5 @@
|
|||||||
|
jdk:
|
||||||
|
- openjdk17
|
||||||
before_install:
|
before_install:
|
||||||
- source "$HOME/.sdkman/bin/sdkman-init.sh"
|
- source "$HOME/.sdkman/bin/sdkman-init.sh"
|
||||||
- sdk update
|
- sdk update
|
||||||
|
49
paper/build.gradle.kts
Normal file
49
paper/build.gradle.kts
Normal file
@ -0,0 +1,49 @@
|
|||||||
|
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
|
||||||
|
|
||||||
|
plugins {
|
||||||
|
id("net.minecrell.plugin-yml.bukkit") version "0.5.2"
|
||||||
|
id("com.github.johnrengelman.shadow") version "7.1.2"
|
||||||
|
}
|
||||||
|
|
||||||
|
repositories {
|
||||||
|
maven("https://jitpack.io")
|
||||||
|
maven("https://repo.codemc.org/repository/maven-public/")
|
||||||
|
maven("https://repo.alessiodp.com/releases/")
|
||||||
|
}
|
||||||
|
|
||||||
|
dependencies {
|
||||||
|
compileOnly(project(":authmevelocity-common"))
|
||||||
|
compileOnly(project(":authmevelocity-api-paper"))
|
||||||
|
compileOnly("io.papermc.paper:paper-api:1.19.1-R0.1-SNAPSHOT")
|
||||||
|
compileOnly("fr.xephi:authme:5.6.0-SNAPSHOT")
|
||||||
|
compileOnly("com.github.4drian3d:MiniPlaceholders:1.1.1")
|
||||||
|
shadow("net.byteflux:libby-bukkit:1.1.5")
|
||||||
|
}
|
||||||
|
|
||||||
|
bukkit {
|
||||||
|
name = "AuthMeVelocity"
|
||||||
|
main = "me.adrianed.authmevelocity.paper.AuthMeVelocityPaper"
|
||||||
|
apiVersion = "1.13"
|
||||||
|
website = "https://github.com/4drian3d/AuthMeVelocity"
|
||||||
|
description = project.description as String
|
||||||
|
authors = listOf("xQuickGlare", "4drian3d")
|
||||||
|
softDepend = listOf("MiniPlaceholders")
|
||||||
|
depend = listOf("AuthMe")
|
||||||
|
version = project.version as String
|
||||||
|
}
|
||||||
|
|
||||||
|
tasks {
|
||||||
|
shadowJar {
|
||||||
|
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
|
||||||
|
relocate("net.byteflux.libby", "me.adrianed.authmevelocity.libs.libby")
|
||||||
|
configurations = listOf(project.configurations.shadow.get())
|
||||||
|
}
|
||||||
|
|
||||||
|
compileJava {
|
||||||
|
options.encoding = Charsets.UTF_8.name()
|
||||||
|
|
||||||
|
options.release.set(17)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
java.toolchain.languageVersion.set(JavaLanguageVersion.of(17))
|
@ -1,7 +1,12 @@
|
|||||||
package com.glyart.authmevelocity.spigot;
|
package me.adrianed.authmevelocity.paper;
|
||||||
|
|
||||||
import com.glyart.authmevelocity.spigot.listeners.AuthMeListener;
|
import me.adrianed.authmevelocity.paper.listeners.AuthMeListener;
|
||||||
import com.glyart.authmevelocity.spigot.listeners.MessageListener;
|
import me.adrianed.authmevelocity.paper.listeners.MessageListener;
|
||||||
|
import me.adrianed.authmevelocity.common.configuration.ConfigurationContainer;
|
||||||
|
import me.adrianed.authmevelocity.common.configuration.Loader;
|
||||||
|
import me.adrianed.authmevelocity.common.configuration.PaperConfiguration;
|
||||||
|
import me.adrianed.authmevelocity.common.MessageType;
|
||||||
|
import me.adrianed.authmevelocity.common.LibsManager;
|
||||||
import com.google.common.io.ByteArrayDataOutput;
|
import com.google.common.io.ByteArrayDataOutput;
|
||||||
import com.google.common.io.ByteStreams;
|
import com.google.common.io.ByteStreams;
|
||||||
|
|
||||||
@ -10,13 +15,23 @@ import org.bukkit.entity.Player;
|
|||||||
import org.bukkit.plugin.java.JavaPlugin;
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
public class AuthMeVelocityPlugin extends JavaPlugin {
|
import net.byteflux.libby.BukkitLibraryManager;
|
||||||
|
|
||||||
|
public final class AuthMeVelocityPlugin extends JavaPlugin {
|
||||||
private static final String CHANNEL = "authmevelocity:main";
|
private static final String CHANNEL = "authmevelocity:main";
|
||||||
|
|
||||||
|
private ConfigurationContainer<PaperConfiguration> config;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onEnable() {
|
public void onEnable() {
|
||||||
|
final LibsManager libraries
|
||||||
|
= new LibsManager(new BukkitLibraryManager(this));
|
||||||
|
libraries.loadLibraries();
|
||||||
|
|
||||||
|
this.config = Loader.loadMainConfig(getDataFolder().toPath(), PaperConfiguration.class, getSLF4JLogger());
|
||||||
|
|
||||||
this.getServer().getMessenger().registerOutgoingPluginChannel(this, CHANNEL);
|
this.getServer().getMessenger().registerOutgoingPluginChannel(this, CHANNEL);
|
||||||
this.getServer().getMessenger().registerIncomingPluginChannel(this, CHANNEL, new MessageListener());
|
this.getServer().getMessenger().registerIncomingPluginChannel(this, CHANNEL, new MessageListener(this));
|
||||||
this.getServer().getPluginManager().registerEvents(new AuthMeListener(this), this);
|
this.getServer().getPluginManager().registerEvents(new AuthMeListener(this), this);
|
||||||
|
|
||||||
if (this.getServer().getPluginManager().isPluginEnabled("MiniPlaceholders")) {
|
if (this.getServer().getPluginManager().isPluginEnabled("MiniPlaceholders")) {
|
||||||
@ -40,9 +55,21 @@ public class AuthMeVelocityPlugin extends JavaPlugin {
|
|||||||
out.writeUTF(playername);
|
out.writeUTF(playername);
|
||||||
|
|
||||||
if (player == null) {
|
if (player == null) {
|
||||||
|
logDebug("MessageToProxy | Null Player, Player Name: "+playername);
|
||||||
Bukkit.getServer().sendPluginMessage(this, CHANNEL, out.toByteArray());
|
Bukkit.getServer().sendPluginMessage(this, CHANNEL, out.toByteArray());
|
||||||
} else {
|
} else {
|
||||||
|
logDebug("MessageToProxy | Player Present: "+player.getName()+", Player Name: "+playername);
|
||||||
player.sendPluginMessage(this, CHANNEL, out.toByteArray());
|
player.sendPluginMessage(this, CHANNEL, out.toByteArray());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ConfigurationContainer<PaperConfiguration> config() {
|
||||||
|
return this.config;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void logDebug(String debug) {
|
||||||
|
if (config.get().debug()) {
|
||||||
|
getSLF4JLogger().info("[DEBUG] {}", debug);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
@ -1,4 +1,4 @@
|
|||||||
package com.glyart.authmevelocity.spigot;
|
package me.adrianed.authmevelocity.paper;
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
@ -10,7 +10,7 @@ import net.kyori.adventure.text.minimessage.tag.Tag;
|
|||||||
import static me.dreamerzero.miniplaceholders.api.utils.Components.*;
|
import static me.dreamerzero.miniplaceholders.api.utils.Components.*;
|
||||||
|
|
||||||
final class AuthmePlaceholders {
|
final class AuthmePlaceholders {
|
||||||
private AuthmePlaceholders(){}
|
private AuthmePlaceholders() {}
|
||||||
|
|
||||||
static Expansion getExpansion(){
|
static Expansion getExpansion(){
|
||||||
return Expansion.builder("authme")
|
return Expansion.builder("authme")
|
||||||
@ -23,7 +23,7 @@ final class AuthmePlaceholders {
|
|||||||
.globalPlaceholder("is_player_logged", (queue, ctx) -> {
|
.globalPlaceholder("is_player_logged", (queue, ctx) -> {
|
||||||
String playerName = queue.popOr("you need to provide a player name").value();
|
String playerName = queue.popOr("you need to provide a player name").value();
|
||||||
Player player = Bukkit.getPlayer(playerName);
|
Player player = Bukkit.getPlayer(playerName);
|
||||||
if(player == null) return Tag.selfClosingInserting(FALSE_COMPONENT);
|
if (player == null) return Tag.selfClosingInserting(FALSE_COMPONENT);
|
||||||
return Tag.selfClosingInserting(AuthMeApi.getInstance().isAuthenticated(player)
|
return Tag.selfClosingInserting(AuthMeApi.getInstance().isAuthenticated(player)
|
||||||
? TRUE_COMPONENT
|
? TRUE_COMPONENT
|
||||||
: FALSE_COMPONENT);
|
: FALSE_COMPONENT);
|
@ -1,8 +1,8 @@
|
|||||||
package com.glyart.authmevelocity.spigot.listeners;
|
package me.adrianed.authmevelocity.paper.listeners;
|
||||||
|
|
||||||
import com.glyart.authmevelocity.spigot.AuthMeVelocityPlugin;
|
import me.adrianed.authmevelocity.paper.AuthMeVelocityPlugin;
|
||||||
import com.glyart.authmevelocity.spigot.MessageType;
|
import me.adrianed.authmevelocity.common.MessageType;
|
||||||
import com.glyart.authmevelocity.spigot.events.PreSendLoginEvent;
|
import me.adrianed.authmevelocity.api.paper.event.PreSendLoginEvent;
|
||||||
|
|
||||||
import fr.xephi.authme.events.LoginEvent;
|
import fr.xephi.authme.events.LoginEvent;
|
||||||
import fr.xephi.authme.events.LogoutEvent;
|
import fr.xephi.authme.events.LogoutEvent;
|
||||||
@ -25,29 +25,35 @@ public final class AuthMeListener implements Listener {
|
|||||||
@EventHandler(priority = EventPriority.HIGHEST)
|
@EventHandler(priority = EventPriority.HIGHEST)
|
||||||
public void onLogin(LoginEvent event) {
|
public void onLogin(LoginEvent event) {
|
||||||
final Player player = event.getPlayer();
|
final Player player = event.getPlayer();
|
||||||
|
plugin.logDebug("LoginEvent | Start");
|
||||||
|
|
||||||
if (new PreSendLoginEvent(player).callEvent()) {
|
if (new PreSendLoginEvent(player).callEvent()) {
|
||||||
plugin.sendMessageToProxy(player, MessageType.LOGIN, player.getName());
|
plugin.sendMessageToProxy(player, MessageType.LOGIN, player.getName());
|
||||||
|
plugin.getSLF4JLogger().info("LoginEvent | PreSendLoginEvent allowed");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onRegister(RegisterEvent event){
|
public void onRegister(RegisterEvent event) {
|
||||||
|
plugin.logDebug("RegisterEvent | Executed");
|
||||||
plugin.sendMessageToProxy(event.getPlayer(), MessageType.REGISTER, event.getPlayer().getName());
|
plugin.sendMessageToProxy(event.getPlayer(), MessageType.REGISTER, event.getPlayer().getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onLogout(LogoutEvent event){
|
public void onLogout(LogoutEvent event) {
|
||||||
|
plugin.logDebug("LogoutEvent | Executed");
|
||||||
plugin.sendMessageToProxy(event.getPlayer(), MessageType.LOGOUT, event.getPlayer().getName());
|
plugin.sendMessageToProxy(event.getPlayer(), MessageType.LOGOUT, event.getPlayer().getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onUnRegister(UnregisterByPlayerEvent event){
|
public void onUnRegister(UnregisterByPlayerEvent event) {
|
||||||
|
plugin.logDebug("UnregisterByPlayerEvent | Executed");
|
||||||
plugin.sendMessageToProxy(event.getPlayer(), MessageType.UNREGISTER, event.getPlayer().getName());
|
plugin.sendMessageToProxy(event.getPlayer(), MessageType.UNREGISTER, event.getPlayer().getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onAdminUnRegister(UnregisterByAdminEvent event){
|
public void onAdminUnRegister(UnregisterByAdminEvent event) {
|
||||||
|
plugin.logDebug("UnregisterByAdminEvent | Executed");
|
||||||
plugin.sendMessageToProxy(event.getPlayer(), MessageType.FORCE_UNREGISTER, event.getPlayerName());
|
plugin.sendMessageToProxy(event.getPlayer(), MessageType.FORCE_UNREGISTER, event.getPlayerName());
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -0,0 +1,44 @@
|
|||||||
|
package me.adrianed.authmevelocity.paper.listeners;
|
||||||
|
|
||||||
|
import com.google.common.io.ByteArrayDataInput;
|
||||||
|
import com.google.common.io.ByteStreams;
|
||||||
|
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.plugin.messaging.PluginMessageListener;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
import me.adrianed.authmevelocity.api.paper.event.LoginByProxyEvent;
|
||||||
|
import me.adrianed.authmevelocity.paper.AuthMeVelocityPlugin;
|
||||||
|
|
||||||
|
import fr.xephi.authme.api.v3.AuthMeApi;
|
||||||
|
|
||||||
|
public class MessageListener implements PluginMessageListener {
|
||||||
|
private final AuthMeVelocityPlugin plugin;
|
||||||
|
|
||||||
|
public MessageListener(AuthMeVelocityPlugin plugin) {
|
||||||
|
this.plugin = plugin;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onPluginMessageReceived(@NotNull String identifier, @NotNull Player player, @NotNull byte[] bytes) {
|
||||||
|
if (!identifier.equals("authmevelocity")) {
|
||||||
|
plugin.logDebug("PluginMessage | Not AuthMeVelocity identifier");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
plugin.logDebug("PluginMessage | AuthMeVelocity identifier");
|
||||||
|
|
||||||
|
final ByteArrayDataInput input = ByteStreams.newDataInput(bytes);
|
||||||
|
final String subchannel = input.readUTF();
|
||||||
|
|
||||||
|
if ("main".equals(subchannel)) {
|
||||||
|
plugin.logDebug("PluginMessage | Main Subchannel");
|
||||||
|
final String msg = input.readUTF();
|
||||||
|
if ("LOGIN".equals(msg)) {
|
||||||
|
plugin.logDebug("PluginMessage | Login Message");
|
||||||
|
new LoginByProxyEvent(player).callEvent();
|
||||||
|
AuthMeApi.getInstance().forceLogin(player);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
49
pom.xml
49
pom.xml
@ -1,49 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
|
||||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
|
||||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
|
||||||
<modelVersion>4.0.0</modelVersion>
|
|
||||||
|
|
||||||
<groupId>com.glyart.authmevelocity</groupId>
|
|
||||||
<artifactId>parent</artifactId>
|
|
||||||
<packaging>pom</packaging>
|
|
||||||
<version>2.2.3</version>
|
|
||||||
|
|
||||||
<properties>
|
|
||||||
<maven.compiler.source>11</maven.compiler.source>
|
|
||||||
<maven.compiler.target>11</maven.compiler.target>
|
|
||||||
</properties>
|
|
||||||
|
|
||||||
<pluginRepositories>
|
|
||||||
<pluginRepository>
|
|
||||||
<id>apache.snapshots</id>
|
|
||||||
<url>https://repository.apache.org/snapshots/</url>
|
|
||||||
</pluginRepository>
|
|
||||||
</pluginRepositories>
|
|
||||||
|
|
||||||
<modules>
|
|
||||||
<module>spigot</module>
|
|
||||||
<module>proxy</module>
|
|
||||||
</modules>
|
|
||||||
|
|
||||||
<build>
|
|
||||||
<finalName>AuthMeVelocity-${project.name}</finalName>
|
|
||||||
<plugins>
|
|
||||||
<plugin>
|
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
|
||||||
<artifactId>maven-compiler-plugin</artifactId>
|
|
||||||
<version>3.10.1</version>
|
|
||||||
<configuration>
|
|
||||||
<source>11</source>
|
|
||||||
<target>11</target>
|
|
||||||
</configuration>
|
|
||||||
</plugin>
|
|
||||||
</plugins>
|
|
||||||
<resources>
|
|
||||||
<resource>
|
|
||||||
<directory>src/main/resources</directory>
|
|
||||||
<filtering>true</filtering>
|
|
||||||
</resource>
|
|
||||||
</resources>
|
|
||||||
</build>
|
|
||||||
</project>
|
|
@ -1,63 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
|
||||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
|
||||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
|
||||||
<parent>
|
|
||||||
<artifactId>parent</artifactId>
|
|
||||||
<groupId>com.glyart.authmevelocity</groupId>
|
|
||||||
<version>2.2.3</version>
|
|
||||||
</parent>
|
|
||||||
<modelVersion>4.0.0</modelVersion>
|
|
||||||
|
|
||||||
<properties>
|
|
||||||
<maven.compiler.source>11</maven.compiler.source>
|
|
||||||
<maven.compiler.target>11</maven.compiler.target>
|
|
||||||
</properties>
|
|
||||||
|
|
||||||
<artifactId>proxy</artifactId>
|
|
||||||
|
|
||||||
<repositories>
|
|
||||||
<repository>
|
|
||||||
<id>papermc</id>
|
|
||||||
<url>https://repo.papermc.io/repository/maven-public/</url>
|
|
||||||
</repository>
|
|
||||||
<repository>
|
|
||||||
<id>codemc-snapshots</id>
|
|
||||||
<url>https://repo.codemc.io/repository/maven-snapshots/</url>
|
|
||||||
</repository>
|
|
||||||
<repository>
|
|
||||||
<id>jitpack.io</id>
|
|
||||||
<url>https://jitpack.io</url>
|
|
||||||
</repository>
|
|
||||||
</repositories>
|
|
||||||
|
|
||||||
<dependencies>
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.velocitypowered</groupId>
|
|
||||||
<artifactId>velocity-api</artifactId>
|
|
||||||
<version>3.1.2-SNAPSHOT</version>
|
|
||||||
<scope>provided</scope>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.github.games647</groupId>
|
|
||||||
<artifactId>fastlogin.velocity</artifactId>
|
|
||||||
<version>1.11-SNAPSHOT</version>
|
|
||||||
<scope>provided</scope>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.github.4drian3d</groupId>
|
|
||||||
<artifactId>MiniPlaceholders</artifactId>
|
|
||||||
<version>1.1.1</version>
|
|
||||||
</dependency>
|
|
||||||
</dependencies>
|
|
||||||
|
|
||||||
<build>
|
|
||||||
<plugins>
|
|
||||||
<plugin>
|
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
|
||||||
<artifactId>maven-jar-plugin</artifactId>
|
|
||||||
<version>3.2.2</version>
|
|
||||||
</plugin>
|
|
||||||
</plugins>
|
|
||||||
</build>
|
|
||||||
</project>
|
|
@ -1,138 +0,0 @@
|
|||||||
package com.glyart.authmevelocity.proxy;
|
|
||||||
|
|
||||||
import com.glyart.authmevelocity.proxy.commands.AuthmeCommand;
|
|
||||||
import com.glyart.authmevelocity.proxy.config.AuthMeConfig;
|
|
||||||
import com.glyart.authmevelocity.proxy.listener.ConnectListener;
|
|
||||||
import com.glyart.authmevelocity.proxy.listener.FastLoginListener;
|
|
||||||
import com.glyart.authmevelocity.proxy.listener.PluginMessageListener;
|
|
||||||
import com.glyart.authmevelocity.proxy.listener.ProxyListener;
|
|
||||||
import com.google.inject.Inject;
|
|
||||||
import com.moandjiezana.toml.Toml;
|
|
||||||
import com.velocitypowered.api.command.CommandSource;
|
|
||||||
import com.velocitypowered.api.event.Subscribe;
|
|
||||||
import com.velocitypowered.api.event.proxy.ProxyInitializeEvent;
|
|
||||||
import com.velocitypowered.api.plugin.annotation.DataDirectory;
|
|
||||||
import com.velocitypowered.api.proxy.ProxyServer;
|
|
||||||
import com.velocitypowered.api.proxy.messages.ChannelIdentifier;
|
|
||||||
import com.velocitypowered.api.proxy.messages.MinecraftChannelIdentifier;
|
|
||||||
|
|
||||||
import net.kyori.adventure.text.minimessage.MiniMessage;
|
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.InputStream;
|
|
||||||
import java.nio.file.Files;
|
|
||||||
import java.nio.file.Path;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Objects;
|
|
||||||
import java.util.Set;
|
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
public class AuthMeVelocityPlugin {
|
|
||||||
public static final ChannelIdentifier AUTHMEVELOCITY_CHANNEL
|
|
||||||
= MinecraftChannelIdentifier.create("authmevelocity", "main");
|
|
||||||
private final ProxyServer proxy;
|
|
||||||
private final Logger logger;
|
|
||||||
private final Path pluginDirectory;
|
|
||||||
private AuthmeVelocityAPI api;
|
|
||||||
private AuthMeConfig config;
|
|
||||||
|
|
||||||
private final List<Object> listeners = new ArrayList<>(3);
|
|
||||||
protected final Set<UUID> loggedPlayers = Collections.synchronizedSet(new HashSet<>());
|
|
||||||
|
|
||||||
@Inject
|
|
||||||
public AuthMeVelocityPlugin(ProxyServer proxy, Logger logger, @DataDirectory Path dataDirectory) {
|
|
||||||
this.proxy = proxy;
|
|
||||||
this.logger = logger;
|
|
||||||
this.pluginDirectory = dataDirectory;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Subscribe
|
|
||||||
public void onProxyInitialization(ProxyInitializeEvent event) {
|
|
||||||
if (!this.reload()) {
|
|
||||||
logger.warn("Failed to load config.toml. Shutting down.");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
proxy.getChannelRegistrar().register(AUTHMEVELOCITY_CHANNEL);
|
|
||||||
|
|
||||||
if (proxy.getPluginManager().isLoaded("miniplaceholders")) {
|
|
||||||
AuthmePlaceholders.getExpansion(this).register();
|
|
||||||
}
|
|
||||||
|
|
||||||
AuthmeCommand.register(this, proxy.getCommandManager());
|
|
||||||
|
|
||||||
this.sendInfoMessage();
|
|
||||||
}
|
|
||||||
|
|
||||||
protected ProxyServer getProxy(){
|
|
||||||
return this.proxy;
|
|
||||||
}
|
|
||||||
|
|
||||||
public AuthmeVelocityAPI getAPI(){
|
|
||||||
return this.api;
|
|
||||||
}
|
|
||||||
|
|
||||||
private Toml loadConfig(Path path){
|
|
||||||
try {
|
|
||||||
if (Files.notExists(path)) {
|
|
||||||
Files.createDirectory(path);
|
|
||||||
}
|
|
||||||
|
|
||||||
Path configPath = path.resolve("config.toml");
|
|
||||||
if (Files.notExists(configPath)) {
|
|
||||||
try (InputStream in = this.getClass().getClassLoader().getResourceAsStream("config.toml")) {
|
|
||||||
Files.copy(Objects.requireNonNull(in, "The configuration does not exists"), configPath);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return new Toml().read(Files.newInputStream(configPath));
|
|
||||||
} catch (IOException ex) {
|
|
||||||
logger.error("An error ocurred on configuration initialization", ex);
|
|
||||||
return null;
|
|
||||||
} catch(IllegalStateException ex) {
|
|
||||||
logger.error("Invalid configuration provided", ex);
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean reload() {
|
|
||||||
Toml toml = this.loadConfig(pluginDirectory);
|
|
||||||
if (toml == null) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
this.config = new AuthMeConfig(toml);
|
|
||||||
this.api = new AuthmeVelocityAPI(this, config);
|
|
||||||
|
|
||||||
listeners.forEach(listener -> proxy.getEventManager().unregisterListener(this, listener));
|
|
||||||
listeners.clear();
|
|
||||||
|
|
||||||
listeners.add(new ProxyListener(config, api));
|
|
||||||
listeners.add(new ConnectListener(config, api, proxy, logger));
|
|
||||||
listeners.add(new PluginMessageListener(proxy, logger, config, api));
|
|
||||||
|
|
||||||
if (proxy.getPluginManager().isLoaded("fastlogin")) {
|
|
||||||
listeners.add(new FastLoginListener(proxy, api));
|
|
||||||
}
|
|
||||||
|
|
||||||
listeners.forEach(listener -> proxy.getEventManager().register(this, listener));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void sendInfoMessage() {
|
|
||||||
CommandSource source = proxy.getConsoleCommandSource();
|
|
||||||
source.sendMessage(MiniMessage.miniMessage().deserialize(
|
|
||||||
" <gray>--- <aqua>AuthMeVelocity</aqua> ---"));
|
|
||||||
source.sendMessage(MiniMessage.miniMessage().deserialize(
|
|
||||||
"<gray>AuthServers: <green>" + config.getAuthServers()));
|
|
||||||
if (config.getToServerOptions().sendToServer()) {
|
|
||||||
source.sendMessage(MiniMessage.miniMessage().deserialize(
|
|
||||||
"<gray>LobbyServers: <green>" + config.getToServerOptions().getTeleportServers()));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,91 +0,0 @@
|
|||||||
package com.glyart.authmevelocity.proxy.config;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
import com.moandjiezana.toml.Toml;
|
|
||||||
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
|
||||||
|
|
||||||
public final class AuthMeConfig {
|
|
||||||
private final List<String> authServers;
|
|
||||||
private final ServerOnLogin serverOnLogin;
|
|
||||||
private final Commands commands;
|
|
||||||
private final EnsureAuthServer ensure;
|
|
||||||
|
|
||||||
public AuthMeConfig(@NotNull Toml toml){
|
|
||||||
this.authServers = ConfigUtils.listOrElse(toml, "authServers",
|
|
||||||
() -> List.of("auth1", "auth2"));
|
|
||||||
this.serverOnLogin = ConfigUtils.getObjectOrElse(toml, "SendOnLogin", ServerOnLogin.class,
|
|
||||||
() -> new ServerOnLogin(false, List.of("lobby1", "lobby2")));
|
|
||||||
this.commands = ConfigUtils.getObjectOrElse(toml, "Commands", Commands.class,
|
|
||||||
() -> new Commands(Set.of("login", "register", "l", "reg", "email", "captcha"), "<red>You cannot execute commands if you are not logged in yet"));
|
|
||||||
this.ensure = ConfigUtils.getObjectOrElse(toml, "EnsureAuthServer", EnsureAuthServer.class,
|
|
||||||
() -> new EnsureAuthServer(false));
|
|
||||||
}
|
|
||||||
|
|
||||||
public static class ServerOnLogin {
|
|
||||||
private final boolean sendToServerOnLogin;
|
|
||||||
private final List<String> teleportServers;
|
|
||||||
|
|
||||||
public ServerOnLogin(boolean sendToServerOnLogin, List<String> teleportServers){
|
|
||||||
this.sendToServerOnLogin = sendToServerOnLogin;
|
|
||||||
this.teleportServers = teleportServers;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean sendToServer(){
|
|
||||||
return this.sendToServerOnLogin;
|
|
||||||
}
|
|
||||||
|
|
||||||
public @NotNull List<String> getTeleportServers(){
|
|
||||||
return this.teleportServers;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static class Commands {
|
|
||||||
private final Set<String> allowedCommands;
|
|
||||||
private final String blockedCommandMessage;
|
|
||||||
|
|
||||||
public Commands(Set<String> allowedCommands, String blockedCommandMessage){
|
|
||||||
this.allowedCommands = allowedCommands;
|
|
||||||
this.blockedCommandMessage = blockedCommandMessage;
|
|
||||||
}
|
|
||||||
|
|
||||||
public @NotNull Set<String> getAllowedCommands(){
|
|
||||||
return this.allowedCommands;
|
|
||||||
}
|
|
||||||
|
|
||||||
public @NotNull String getBlockedMessage() {
|
|
||||||
return this.blockedCommandMessage;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static class EnsureAuthServer {
|
|
||||||
private final boolean ensureFirstServerIsAuthServer;
|
|
||||||
|
|
||||||
public EnsureAuthServer(boolean ensureFirstServerIsAuthServer){
|
|
||||||
this.ensureFirstServerIsAuthServer = ensureFirstServerIsAuthServer;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean ensureAuthServer(){
|
|
||||||
return this.ensureFirstServerIsAuthServer;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public @NotNull Commands getCommandsConfig(){
|
|
||||||
return this.commands;
|
|
||||||
}
|
|
||||||
|
|
||||||
public @NotNull ServerOnLogin getToServerOptions(){
|
|
||||||
return this.serverOnLogin;
|
|
||||||
}
|
|
||||||
|
|
||||||
public @NotNull EnsureAuthServer getEnsureOptions(){
|
|
||||||
return this.ensure;
|
|
||||||
}
|
|
||||||
|
|
||||||
public @NotNull List<String> getAuthServers(){
|
|
||||||
return this.authServers;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,40 +0,0 @@
|
|||||||
package com.glyart.authmevelocity.proxy.config;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.function.Supplier;
|
|
||||||
|
|
||||||
import java.lang.reflect.ParameterizedType;
|
|
||||||
|
|
||||||
import com.moandjiezana.toml.Toml;
|
|
||||||
import com.velocitypowered.api.proxy.Player;
|
|
||||||
|
|
||||||
import net.kyori.adventure.text.minimessage.MiniMessage;
|
|
||||||
|
|
||||||
public final class ConfigUtils {
|
|
||||||
public static final MiniMessage MINIMESSAGE = MiniMessage.miniMessage();
|
|
||||||
|
|
||||||
public static void sendBlockedMessage(Player player, AuthMeConfig config){
|
|
||||||
String blockedMessage = config.getCommandsConfig().getBlockedMessage();
|
|
||||||
if(!blockedMessage.isBlank()){
|
|
||||||
player.sendMessage(MINIMESSAGE.deserialize(blockedMessage));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
static <T>T getObjectOrElse(Toml config, String key, Supplier<T> defaultValue){
|
|
||||||
Toml configTable = config.getTable(key);
|
|
||||||
return configTable == null ? defaultValue.get() : (T)configTable.to((Class<T>)((ParameterizedType)defaultValue.getClass()
|
|
||||||
.getGenericInterfaces()[0]).getActualTypeArguments()[0]);
|
|
||||||
}
|
|
||||||
|
|
||||||
static <T>T getObjectOrElse(Toml config, String key, Class<T> clazz, Supplier<T> defaultValue){
|
|
||||||
Toml configTable = config.getTable(key);
|
|
||||||
return configTable == null ? defaultValue.get() : configTable.to(clazz);
|
|
||||||
}
|
|
||||||
|
|
||||||
static List<String> listOrElse(Toml config, String key, Supplier<List<String>> defaultList){
|
|
||||||
List<String> list = config.getList(key);
|
|
||||||
return list != null ? list : defaultList.get();
|
|
||||||
}
|
|
||||||
private ConfigUtils(){}
|
|
||||||
}
|
|
@ -1,17 +0,0 @@
|
|||||||
package com.glyart.authmevelocity.proxy.event;
|
|
||||||
|
|
||||||
import com.velocitypowered.api.proxy.Player;
|
|
||||||
|
|
||||||
import org.jetbrains.annotations.Nullable;
|
|
||||||
|
|
||||||
public class ProxyForcedUnregisterEvent {
|
|
||||||
private final Player player;
|
|
||||||
|
|
||||||
public ProxyForcedUnregisterEvent(@Nullable Player player){
|
|
||||||
this.player = player;
|
|
||||||
}
|
|
||||||
|
|
||||||
public @Nullable Player getPlayer(){
|
|
||||||
return this.player;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,20 +0,0 @@
|
|||||||
package com.glyart.authmevelocity.proxy.event;
|
|
||||||
|
|
||||||
import com.velocitypowered.api.proxy.Player;
|
|
||||||
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Event executed in case the player is successfully logged in
|
|
||||||
*/
|
|
||||||
public final class ProxyLoginEvent {
|
|
||||||
private final Player player;
|
|
||||||
|
|
||||||
public ProxyLoginEvent(@NotNull Player player){
|
|
||||||
this.player = player;
|
|
||||||
}
|
|
||||||
|
|
||||||
public @NotNull Player getPlayer(){
|
|
||||||
return this.player;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,17 +0,0 @@
|
|||||||
package com.glyart.authmevelocity.proxy.event;
|
|
||||||
|
|
||||||
import com.velocitypowered.api.proxy.Player;
|
|
||||||
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
|
||||||
|
|
||||||
public final class ProxyLogoutEvent {
|
|
||||||
private final Player player;
|
|
||||||
|
|
||||||
public ProxyLogoutEvent(@NotNull Player player){
|
|
||||||
this.player = player;
|
|
||||||
}
|
|
||||||
|
|
||||||
public @NotNull Player getPlayer(){
|
|
||||||
return this.player;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,17 +0,0 @@
|
|||||||
package com.glyart.authmevelocity.proxy.event;
|
|
||||||
|
|
||||||
import com.velocitypowered.api.proxy.Player;
|
|
||||||
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
|
||||||
|
|
||||||
public final class ProxyRegisterEvent {
|
|
||||||
private final Player player;
|
|
||||||
|
|
||||||
public ProxyRegisterEvent(@NotNull Player player){
|
|
||||||
this.player = player;
|
|
||||||
}
|
|
||||||
|
|
||||||
public @NotNull Player getPlayer(){
|
|
||||||
return this.player;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,17 +0,0 @@
|
|||||||
package com.glyart.authmevelocity.proxy.event;
|
|
||||||
|
|
||||||
import com.velocitypowered.api.proxy.Player;
|
|
||||||
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
|
||||||
|
|
||||||
public class ProxyUnregisterEvent {
|
|
||||||
private final Player player;
|
|
||||||
|
|
||||||
public ProxyUnregisterEvent(@NotNull Player player){
|
|
||||||
this.player = player;
|
|
||||||
}
|
|
||||||
|
|
||||||
public @NotNull Player getPlayer(){
|
|
||||||
return this.player;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,19 +0,0 @@
|
|||||||
package com.glyart.authmevelocity.proxy.listener;
|
|
||||||
|
|
||||||
import com.github.games647.fastlogin.velocity.event.VelocityFastLoginAutoLoginEvent;
|
|
||||||
import com.glyart.authmevelocity.proxy.AuthmeVelocityAPI;
|
|
||||||
import com.velocitypowered.api.event.Subscribe;
|
|
||||||
import com.velocitypowered.api.proxy.ProxyServer;
|
|
||||||
|
|
||||||
public class FastLoginListener {
|
|
||||||
private final ProxyServer server;
|
|
||||||
private final AuthmeVelocityAPI api;
|
|
||||||
public FastLoginListener(ProxyServer server, AuthmeVelocityAPI api){
|
|
||||||
this.server = server;
|
|
||||||
this.api = api;
|
|
||||||
}
|
|
||||||
@Subscribe
|
|
||||||
public void onAutoLogin(VelocityFastLoginAutoLoginEvent event){
|
|
||||||
server.getPlayer(event.getProfile().getName()).ifPresent(api::addPlayer);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,124 +0,0 @@
|
|||||||
package com.glyart.authmevelocity.proxy.listener;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Random;
|
|
||||||
|
|
||||||
import com.glyart.authmevelocity.proxy.AuthMeVelocityPlugin;
|
|
||||||
import com.glyart.authmevelocity.proxy.AuthmeVelocityAPI;
|
|
||||||
import com.glyart.authmevelocity.proxy.config.AuthMeConfig;
|
|
||||||
import com.glyart.authmevelocity.proxy.event.PreSendOnLoginEvent;
|
|
||||||
import com.glyart.authmevelocity.proxy.event.ProxyForcedUnregisterEvent;
|
|
||||||
import com.glyart.authmevelocity.proxy.event.ProxyLoginEvent;
|
|
||||||
import com.glyart.authmevelocity.proxy.event.ProxyLogoutEvent;
|
|
||||||
import com.glyart.authmevelocity.proxy.event.ProxyRegisterEvent;
|
|
||||||
import com.glyart.authmevelocity.proxy.event.ProxyUnregisterEvent;
|
|
||||||
import com.google.common.io.ByteArrayDataInput;
|
|
||||||
import com.velocitypowered.api.event.Continuation;
|
|
||||||
import com.velocitypowered.api.event.Subscribe;
|
|
||||||
import com.velocitypowered.api.event.ResultedEvent.GenericResult;
|
|
||||||
import com.velocitypowered.api.proxy.ConnectionRequestBuilder.Result;
|
|
||||||
import com.velocitypowered.api.event.connection.PluginMessageEvent;
|
|
||||||
import com.velocitypowered.api.proxy.Player;
|
|
||||||
import com.velocitypowered.api.proxy.ProxyServer;
|
|
||||||
import com.velocitypowered.api.proxy.ServerConnection;
|
|
||||||
import com.velocitypowered.api.proxy.server.RegisteredServer;
|
|
||||||
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
|
||||||
import org.jetbrains.annotations.Nullable;
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
|
|
||||||
public class PluginMessageListener {
|
|
||||||
private final ProxyServer proxy;
|
|
||||||
private final Logger logger;
|
|
||||||
private final Random rm;
|
|
||||||
private final AuthMeConfig config;
|
|
||||||
private final AuthmeVelocityAPI api;
|
|
||||||
|
|
||||||
public PluginMessageListener(@NotNull ProxyServer proxy, @NotNull Logger logger, @NotNull AuthMeConfig config, AuthmeVelocityAPI api) {
|
|
||||||
this.proxy = proxy;
|
|
||||||
this.logger = logger;
|
|
||||||
this.rm = new Random();
|
|
||||||
this.config = config;
|
|
||||||
this.api = api;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Subscribe
|
|
||||||
public void onPluginMessage(final PluginMessageEvent event, Continuation continuation) {
|
|
||||||
final boolean cancelled = !(event.getSource() instanceof ServerConnection)
|
|
||||||
|| !event.getIdentifier().equals(AuthMeVelocityPlugin.AUTHMEVELOCITY_CHANNEL);
|
|
||||||
if (cancelled) {
|
|
||||||
continuation.resume();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
ServerConnection connection = ((ServerConnection)event.getSource());
|
|
||||||
|
|
||||||
event.setResult(PluginMessageEvent.ForwardResult.handled());
|
|
||||||
|
|
||||||
final ByteArrayDataInput input = event.dataAsDataStream();
|
|
||||||
final String sChannel = input.readUTF();
|
|
||||||
final String playername = input.readUTF();
|
|
||||||
final @Nullable Player loggedPlayer = proxy.getPlayer(playername).orElse(null);
|
|
||||||
switch (sChannel) {
|
|
||||||
case "LOGIN" :
|
|
||||||
if (loggedPlayer != null && api.addPlayer(loggedPlayer)){
|
|
||||||
proxy.getEventManager().fireAndForget(new ProxyLoginEvent(loggedPlayer));
|
|
||||||
this.createServerConnectionRequest(loggedPlayer, connection);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case "LOGOUT":
|
|
||||||
if (loggedPlayer != null && api.removePlayer(loggedPlayer)){
|
|
||||||
proxy.getEventManager().fireAndForget(new ProxyLogoutEvent(loggedPlayer));
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case "REGISTER":
|
|
||||||
if (loggedPlayer != null)
|
|
||||||
proxy.getEventManager().fireAndForget(new ProxyRegisterEvent(loggedPlayer));
|
|
||||||
break;
|
|
||||||
case "UNREGISTER":
|
|
||||||
if(loggedPlayer != null)
|
|
||||||
proxy.getEventManager().fireAndForget(new ProxyUnregisterEvent(loggedPlayer));
|
|
||||||
break;
|
|
||||||
case "FORCE_UNREGISTER":
|
|
||||||
proxy.getEventManager().fireAndForget(new ProxyForcedUnregisterEvent(loggedPlayer));
|
|
||||||
break;
|
|
||||||
default: break;
|
|
||||||
}
|
|
||||||
continuation.resume();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void createServerConnectionRequest(Player player, ServerConnection connection){
|
|
||||||
if (!config.getToServerOptions().sendToServer()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
final RegisteredServer loginServer = player.getCurrentServer().orElse(connection).getServer();
|
|
||||||
final String randomServer = this.getRandomServer();
|
|
||||||
|
|
||||||
proxy.getServer(randomServer).ifPresentOrElse(server ->
|
|
||||||
proxy.getEventManager().fire(new PreSendOnLoginEvent(player, loginServer, server))
|
|
||||||
.thenApply(PreSendOnLoginEvent::getResult)
|
|
||||||
.thenApply(GenericResult::isAllowed)
|
|
||||||
.thenAcceptAsync(allowed -> {
|
|
||||||
if (!allowed) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
player.createConnectionRequest(server)
|
|
||||||
.connect()
|
|
||||||
.thenApply(Result::isSuccessful)
|
|
||||||
.thenAcceptAsync(result -> {
|
|
||||||
if(!result) {
|
|
||||||
logger.info("Unable to connect the player {} to the server {}",
|
|
||||||
player.getUsername(),
|
|
||||||
server.getServerInfo().getName());
|
|
||||||
}
|
|
||||||
});
|
|
||||||
})
|
|
||||||
, () -> logger.warn("The server {} does not exist", randomServer));
|
|
||||||
}
|
|
||||||
|
|
||||||
private String getRandomServer() {
|
|
||||||
final List<String> serverList = config.getToServerOptions().getTeleportServers();
|
|
||||||
return serverList.get(rm.nextInt(serverList.size()));
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,83 +0,0 @@
|
|||||||
package com.glyart.authmevelocity.proxy.listener;
|
|
||||||
|
|
||||||
import com.glyart.authmevelocity.proxy.AuthmeVelocityAPI;
|
|
||||||
import com.glyart.authmevelocity.proxy.config.AuthMeConfig;
|
|
||||||
import com.glyart.authmevelocity.proxy.config.ConfigUtils;
|
|
||||||
import com.glyart.authmevelocity.proxy.utils.AuthmeUtils;
|
|
||||||
import com.velocitypowered.api.event.Continuation;
|
|
||||||
import com.velocitypowered.api.event.EventTask;
|
|
||||||
import com.velocitypowered.api.event.PostOrder;
|
|
||||||
import com.velocitypowered.api.event.Subscribe;
|
|
||||||
import com.velocitypowered.api.event.command.CommandExecuteEvent;
|
|
||||||
import com.velocitypowered.api.event.connection.DisconnectEvent;
|
|
||||||
import com.velocitypowered.api.event.player.PlayerChatEvent;
|
|
||||||
import com.velocitypowered.api.event.player.TabCompleteEvent;
|
|
||||||
import com.velocitypowered.api.proxy.Player;
|
|
||||||
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
|
||||||
|
|
||||||
public final class ProxyListener {
|
|
||||||
private final AuthMeConfig config;
|
|
||||||
private final AuthmeVelocityAPI api;
|
|
||||||
|
|
||||||
public ProxyListener(@NotNull AuthMeConfig config, AuthmeVelocityAPI api) {
|
|
||||||
this.config = config;
|
|
||||||
this.api = api;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Subscribe
|
|
||||||
public EventTask onDisconnect(final DisconnectEvent event) {
|
|
||||||
return EventTask.async(() -> api.removePlayer(event.getPlayer()));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Subscribe(order = PostOrder.FIRST)
|
|
||||||
public void onCommandExecute(final CommandExecuteEvent event, Continuation continuation) {
|
|
||||||
if (!(event.getCommandSource() instanceof Player)){
|
|
||||||
continuation.resume();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
Player player = (Player)event.getCommandSource();
|
|
||||||
|
|
||||||
if (api.isLogged(player)) {
|
|
||||||
continuation.resume();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (api.isInAuthServer(player)) {
|
|
||||||
String command = AuthmeUtils.getFirstArgument(event.getCommand());
|
|
||||||
if (!config.getCommandsConfig().getAllowedCommands().contains(command)) {
|
|
||||||
ConfigUtils.sendBlockedMessage(player, config);
|
|
||||||
event.setResult(CommandExecuteEvent.CommandResult.denied());
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
ConfigUtils.sendBlockedMessage(player, config);
|
|
||||||
event.setResult(CommandExecuteEvent.CommandResult.denied());
|
|
||||||
}
|
|
||||||
continuation.resume();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Subscribe(order = PostOrder.FIRST)
|
|
||||||
public void onPlayerChat(final PlayerChatEvent event) {
|
|
||||||
if (api.isNotLogged(event.getPlayer())) {
|
|
||||||
event.setResult(PlayerChatEvent.ChatResult.denied());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Subscribe(order = PostOrder.FIRST)
|
|
||||||
public void onTabComplete(TabCompleteEvent event){
|
|
||||||
if (api.isLogged(event.getPlayer())) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
final String command = event.getPartialMessage();
|
|
||||||
for (final String allowed : config.getCommandsConfig().getAllowedCommands()) {
|
|
||||||
if (allowed.startsWith(command)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
event.getSuggestions().clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,22 +0,0 @@
|
|||||||
package com.glyart.authmevelocity.proxy.utils;
|
|
||||||
|
|
||||||
import java.util.Objects;
|
|
||||||
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
|
||||||
|
|
||||||
public class AuthmeUtils {
|
|
||||||
//Origin: https://github.com/4drian3d/ChatRegulator/blob/main/src/main/java/me/dreamerzero/chatregulator/utils/CommandUtils.java#L71
|
|
||||||
/**
|
|
||||||
* Get the first argument of a string
|
|
||||||
* @param string the string
|
|
||||||
* @return the first argument
|
|
||||||
*/
|
|
||||||
public static @NotNull String getFirstArgument(@NotNull String string){
|
|
||||||
int index = Objects.requireNonNull(string).indexOf(" ");
|
|
||||||
if (index == -1) {
|
|
||||||
return string;
|
|
||||||
}
|
|
||||||
return string.substring(0, index);
|
|
||||||
}
|
|
||||||
private AuthmeUtils(){}
|
|
||||||
}
|
|
@ -1,26 +0,0 @@
|
|||||||
# AuthmeVelocity Proxy
|
|
||||||
# Original Developer: xQuickGlare
|
|
||||||
# Actual Developer: 4drian3d
|
|
||||||
|
|
||||||
# List of login/registration servers
|
|
||||||
authServers = ["auth1", "auth2"]
|
|
||||||
|
|
||||||
[SendOnLogin]
|
|
||||||
# Send logged in players to another server?
|
|
||||||
sendToServerOnLogin = false
|
|
||||||
|
|
||||||
# List of servers to send
|
|
||||||
# One of these servers will be chosen at random
|
|
||||||
teleportServers = ["lobby1", "lobby2"]
|
|
||||||
|
|
||||||
[Commands]
|
|
||||||
# Sets the commands that users who have not yet logged in can execute
|
|
||||||
allowedCommands = ["login", "register", "l", "reg", "email", "captcha"]
|
|
||||||
|
|
||||||
# Sets the message to send in case a non-logged-in player executes an unauthorized command
|
|
||||||
# To deactivate the message, leave it empty
|
|
||||||
blockedCommandMessage = "<red>You cannot execute commands if you are not logged in yet"
|
|
||||||
|
|
||||||
[EnsureAuthServer]
|
|
||||||
# Ensure that the first server to which players connect is an auth server
|
|
||||||
ensureFirstServerIsAuthServer = false
|
|
@ -1,19 +0,0 @@
|
|||||||
{
|
|
||||||
"id":"authmevelocity",
|
|
||||||
"name":"AuthMeVelocity",
|
|
||||||
"version":"${project.version}",
|
|
||||||
"url":"https://github.com/4drian3d/AuthMeVelocity",
|
|
||||||
"description":"This plugin adds the support for AuthMeReloaded to Velocity.",
|
|
||||||
"authors":["xQuickGlare", "4drian3d"],
|
|
||||||
"dependencies":[
|
|
||||||
{
|
|
||||||
"id":"fastlogin",
|
|
||||||
"optional":true
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id":"miniplaceholders",
|
|
||||||
"optional":true
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"main":"com.glyart.authmevelocity.proxy.AuthMeVelocityPlugin"
|
|
||||||
}
|
|
11
settings.gradle.kts
Normal file
11
settings.gradle.kts
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
rootProject.name = "authmevelocity-parent"
|
||||||
|
|
||||||
|
listOf("common", "paper", "velocity").forEach {
|
||||||
|
include("authmevelocity-$it")
|
||||||
|
project(":authmevelocity-$it").projectDir = file(it)
|
||||||
|
}
|
||||||
|
|
||||||
|
listOf("paper", "velocity").forEach {
|
||||||
|
include("authmevelocity-api-$it")
|
||||||
|
project(":authmevelocity-api-$it").projectDir = file("api/$it")
|
||||||
|
}
|
@ -1,66 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
|
||||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
|
||||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
|
||||||
<parent>
|
|
||||||
<artifactId>parent</artifactId>
|
|
||||||
<groupId>com.glyart.authmevelocity</groupId>
|
|
||||||
<version>2.2.3</version>
|
|
||||||
</parent>
|
|
||||||
<modelVersion>4.0.0</modelVersion>
|
|
||||||
|
|
||||||
<artifactId>spigot</artifactId>
|
|
||||||
|
|
||||||
<properties>
|
|
||||||
<maven.compiler.source>11</maven.compiler.source>
|
|
||||||
<maven.compiler.target>11</maven.compiler.target>
|
|
||||||
</properties>
|
|
||||||
|
|
||||||
<repositories>
|
|
||||||
<repository>
|
|
||||||
<id>papermc</id>
|
|
||||||
<url>https://repo.papermc.io/repository/maven-public/</url>
|
|
||||||
</repository>
|
|
||||||
|
|
||||||
<repository>
|
|
||||||
<id>codemc-repo</id>
|
|
||||||
<url>https://repo.codemc.org/repository/maven-public/</url>
|
|
||||||
</repository>
|
|
||||||
|
|
||||||
<repository>
|
|
||||||
<id>jitpack.io</id>
|
|
||||||
<url>https://jitpack.io</url>
|
|
||||||
</repository>
|
|
||||||
</repositories>
|
|
||||||
|
|
||||||
<dependencies>
|
|
||||||
<dependency>
|
|
||||||
<groupId>io.papermc.paper</groupId>
|
|
||||||
<artifactId>paper-api</artifactId>
|
|
||||||
<version>1.18.2-R0.1-SNAPSHOT</version>
|
|
||||||
<scope>provided</scope>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>fr.xephi</groupId>
|
|
||||||
<artifactId>authme</artifactId>
|
|
||||||
<version>5.6.0-SNAPSHOT</version>
|
|
||||||
<scope>provided</scope>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.github.4drian3d</groupId>
|
|
||||||
<artifactId>MiniPlaceholders</artifactId>
|
|
||||||
<version>1.1.1</version>
|
|
||||||
</dependency>
|
|
||||||
</dependencies>
|
|
||||||
|
|
||||||
<build>
|
|
||||||
<plugins>
|
|
||||||
<plugin>
|
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
|
||||||
<artifactId>maven-jar-plugin</artifactId>
|
|
||||||
<version>3.2.2</version>
|
|
||||||
</plugin>
|
|
||||||
</plugins>
|
|
||||||
</build>
|
|
||||||
</project>
|
|
@ -1,5 +0,0 @@
|
|||||||
package com.glyart.authmevelocity.spigot;
|
|
||||||
|
|
||||||
public enum MessageType {
|
|
||||||
LOGIN, REGISTER, LOGOUT, FORCE_UNREGISTER, UNREGISTER;
|
|
||||||
}
|
|
@ -1,29 +0,0 @@
|
|||||||
package com.glyart.authmevelocity.spigot.listeners;
|
|
||||||
|
|
||||||
import com.google.common.io.ByteArrayDataInput;
|
|
||||||
import com.google.common.io.ByteStreams;
|
|
||||||
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
import org.bukkit.plugin.messaging.PluginMessageListener;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
|
||||||
|
|
||||||
import fr.xephi.authme.api.v3.AuthMeApi;
|
|
||||||
|
|
||||||
public class MessageListener implements PluginMessageListener {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onPluginMessageReceived(@NotNull String identifier, @NotNull Player player, @NotNull byte[] bytes) {
|
|
||||||
if (!identifier.equals("authmevelocity")) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
ByteArrayDataInput input = ByteStreams.newDataInput(bytes);
|
|
||||||
String subchannel = input.readUTF();
|
|
||||||
if ("main".equals(subchannel)) {
|
|
||||||
String msg = input.readUTF();
|
|
||||||
if ("LOGIN".equals(msg)) {
|
|
||||||
AuthMeApi.getInstance().forceLogin(player);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,8 +0,0 @@
|
|||||||
name: AuthMeVelocity
|
|
||||||
authors: [xQuickGlare, 4drian3d]
|
|
||||||
version: ${project.version}
|
|
||||||
main: com.glyart.authmevelocity.spigot.AuthMeVelocityPlugin
|
|
||||||
depend: [AuthMe]
|
|
||||||
soft-depend: [MiniPlaceholders]
|
|
||||||
# pls, dont use outdated versions, use 1.16.5+
|
|
||||||
api-version: 1.13
|
|
37
velocity/build.gradle.kts
Normal file
37
velocity/build.gradle.kts
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
plugins {
|
||||||
|
id("com.github.johnrengelman.shadow") version "7.1.2"
|
||||||
|
}
|
||||||
|
|
||||||
|
repositories {
|
||||||
|
maven("https://repo.alessiodp.com/releases/")
|
||||||
|
maven("https://jitpack.io")
|
||||||
|
maven("https://repo.codemc.org/repository/maven-public/")
|
||||||
|
}
|
||||||
|
|
||||||
|
dependencies {
|
||||||
|
compileOnly("com.velocitypowered:velocity-api:3.1.2-SNAPSHOT")
|
||||||
|
annotationProcessor("com.velocitypowered:velocity-api:3.1.2-SNAPSHOT")
|
||||||
|
compileOnly("com.github.4drian3d:MiniPlaceholders:1.1.1")
|
||||||
|
compileOnly("com.github.games647:fastlogin.velocity:1.11-SNAPSHOT")
|
||||||
|
shadow("net.byteflux:libby-velocity:1.1.5")
|
||||||
|
shadow("org.bstats:bstats-velocity:3.0.0")
|
||||||
|
compileOnly(project(":authmevelocity-common"))
|
||||||
|
compileOnly(project(":authmevelocity-api-velocity"))
|
||||||
|
}
|
||||||
|
|
||||||
|
tasks {
|
||||||
|
compileJava {
|
||||||
|
options.encoding = Charsets.UTF_8.name()
|
||||||
|
|
||||||
|
options.release.set(17)
|
||||||
|
}
|
||||||
|
|
||||||
|
shadowJar {
|
||||||
|
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
|
||||||
|
relocate("net.byteflux.libby", "me.adrianed.authmevelocity.libs.libby")
|
||||||
|
relocate("org.bstats", "me.adrianed.authmevelocity.libs.bstats")
|
||||||
|
configurations = listOf(project.configurations.shadow.get())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
java.toolchain.languageVersion.set(JavaLanguageVersion.of(17))
|
@ -1,4 +1,4 @@
|
|||||||
package com.glyart.authmevelocity.proxy;
|
package me.adrianed.authmevelocity.velocity;
|
||||||
|
|
||||||
import com.velocitypowered.api.proxy.Player;
|
import com.velocitypowered.api.proxy.Player;
|
||||||
|
|
||||||
@ -7,31 +7,31 @@ import net.kyori.adventure.text.minimessage.tag.Tag;
|
|||||||
|
|
||||||
import static me.dreamerzero.miniplaceholders.api.utils.Components.*;
|
import static me.dreamerzero.miniplaceholders.api.utils.Components.*;
|
||||||
|
|
||||||
final class AuthmePlaceholders {
|
final class AuthMePlaceholders {
|
||||||
private AuthmePlaceholders(){}
|
private AuthMePlaceholders() {}
|
||||||
|
|
||||||
static Expansion getExpansion(AuthMeVelocityPlugin plugin){
|
static Expansion getExpansion(AuthMeVelocityPlugin plugin){
|
||||||
return Expansion.builder("authme")
|
return Expansion.builder("authme")
|
||||||
.filter(Player.class)
|
.filter(Player.class)
|
||||||
// Logged Placeholders
|
// Logged Placeholders
|
||||||
.audiencePlaceholder("is_logged", (aud, queue, ctx) ->
|
.audiencePlaceholder("is_logged", (aud, queue, ctx) ->
|
||||||
Tag.selfClosingInserting(plugin.getAPI().isLogged((Player)aud) ? TRUE_COMPONENT : FALSE_COMPONENT))
|
Tag.selfClosingInserting(plugin.isLogged((Player)aud) ? TRUE_COMPONENT : FALSE_COMPONENT))
|
||||||
.globalPlaceholder("is_player_logged", (queue, ctx) -> {
|
.globalPlaceholder("is_player_logged", (queue, ctx) -> {
|
||||||
String playerName = queue.popOr(() -> "you need to provide a player").value();
|
String playerName = queue.popOr(() -> "you need to provide a player").value();
|
||||||
return Tag.selfClosingInserting(
|
return Tag.selfClosingInserting(
|
||||||
plugin.getProxy().getPlayer(playerName)
|
plugin.getProxy().getPlayer(playerName)
|
||||||
.map(plugin.getAPI()::isLogged)
|
.map(plugin::isLogged)
|
||||||
.orElse(false) ? TRUE_COMPONENT : FALSE_COMPONENT
|
.orElse(false) ? TRUE_COMPONENT : FALSE_COMPONENT
|
||||||
);
|
);
|
||||||
})
|
})
|
||||||
// In Auth Server placeholders
|
// In Auth Server placeholders
|
||||||
.audiencePlaceholder("in_auth_server", (aud, queue, ctx) ->
|
.audiencePlaceholder("in_auth_server", (aud, queue, ctx) ->
|
||||||
Tag.selfClosingInserting(plugin.getAPI().isInAuthServer((Player)aud) ? TRUE_COMPONENT : FALSE_COMPONENT))
|
Tag.selfClosingInserting(plugin.isInAuthServer((Player)aud) ? TRUE_COMPONENT : FALSE_COMPONENT))
|
||||||
.globalPlaceholder("player_in_auth_server", (queue, ctx) -> {
|
.globalPlaceholder("player_in_auth_server", (queue, ctx) -> {
|
||||||
String playerName = queue.popOr(() -> "you need to provide a player").value();
|
String playerName = queue.popOr(() -> "you need to provide a player").value();
|
||||||
return Tag.selfClosingInserting(
|
return Tag.selfClosingInserting(
|
||||||
plugin.getProxy().getPlayer(playerName)
|
plugin.getProxy().getPlayer(playerName)
|
||||||
.map(plugin.getAPI()::isInAuthServer)
|
.map(plugin::isInAuthServer)
|
||||||
.orElse(false) ? TRUE_COMPONENT : FALSE_COMPONENT
|
.orElse(false) ? TRUE_COMPONENT : FALSE_COMPONENT
|
||||||
);
|
);
|
||||||
})
|
})
|
@ -0,0 +1,196 @@
|
|||||||
|
package me.adrianed.authmevelocity.velocity;
|
||||||
|
|
||||||
|
import me.adrianed.authmevelocity.velocity.commands.AuthmeCommand;
|
||||||
|
import me.adrianed.authmevelocity.velocity.listener.ConnectListener;
|
||||||
|
import me.adrianed.authmevelocity.velocity.listener.FastLoginListener;
|
||||||
|
import me.adrianed.authmevelocity.velocity.listener.PluginMessageListener;
|
||||||
|
import me.adrianed.authmevelocity.velocity.listener.ProxyListener;
|
||||||
|
import me.adrianed.authmevelocity.api.velocity.AuthMeVelocityAPI;
|
||||||
|
import me.adrianed.authmevelocity.common.Constants;
|
||||||
|
import me.adrianed.authmevelocity.common.LibsManager;
|
||||||
|
import me.adrianed.authmevelocity.common.configuration.ConfigurationContainer;
|
||||||
|
import me.adrianed.authmevelocity.common.configuration.Loader;
|
||||||
|
import me.adrianed.authmevelocity.common.configuration.ProxyConfiguration;
|
||||||
|
import com.google.inject.Inject;
|
||||||
|
import com.velocitypowered.api.command.CommandSource;
|
||||||
|
import com.velocitypowered.api.event.Subscribe;
|
||||||
|
import com.velocitypowered.api.event.proxy.ProxyInitializeEvent;
|
||||||
|
import com.velocitypowered.api.plugin.annotation.DataDirectory;
|
||||||
|
import com.velocitypowered.api.plugin.Plugin;
|
||||||
|
import com.velocitypowered.api.plugin.Dependency;
|
||||||
|
import com.velocitypowered.api.proxy.ProxyServer;
|
||||||
|
import com.velocitypowered.api.proxy.Player;
|
||||||
|
import com.velocitypowered.api.proxy.ServerConnection;
|
||||||
|
import com.velocitypowered.api.proxy.server.RegisteredServer;
|
||||||
|
import com.velocitypowered.api.proxy.messages.ChannelIdentifier;
|
||||||
|
import com.velocitypowered.api.proxy.messages.MinecraftChannelIdentifier;
|
||||||
|
|
||||||
|
import net.byteflux.libby.VelocityLibraryManager;
|
||||||
|
import net.kyori.adventure.text.minimessage.MiniMessage;
|
||||||
|
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.bstats.charts.SimplePie;
|
||||||
|
import org.bstats.velocity.Metrics;
|
||||||
|
|
||||||
|
import java.util.function.Predicate;
|
||||||
|
import java.nio.file.Path;
|
||||||
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
@Plugin(
|
||||||
|
id = "authmevelocity",
|
||||||
|
name = "AuthMeVelocity",
|
||||||
|
url = "https://github.com/4drian3d/AuthMeVelocity",
|
||||||
|
description = Constants.DESCRIPTION,
|
||||||
|
version = Constants.VERSION,
|
||||||
|
authors = {"xQuickGlare", "4drian3d"},
|
||||||
|
dependencies = {
|
||||||
|
@Dependency(
|
||||||
|
id = "miniplaceholders",
|
||||||
|
optional = true
|
||||||
|
),
|
||||||
|
@Dependency(
|
||||||
|
id = "fastlogin",
|
||||||
|
optional = true
|
||||||
|
)
|
||||||
|
}
|
||||||
|
)
|
||||||
|
public final class AuthMeVelocityPlugin implements AuthMeVelocityAPI {
|
||||||
|
public static final ChannelIdentifier AUTHMEVELOCITY_CHANNEL
|
||||||
|
= MinecraftChannelIdentifier.create("authmevelocity", "main");
|
||||||
|
private final ProxyServer proxy;
|
||||||
|
private final Logger logger;
|
||||||
|
private final Path pluginDirectory;
|
||||||
|
private final Metrics.Factory metricsFactory;
|
||||||
|
private ConfigurationContainer<ProxyConfiguration> config;
|
||||||
|
|
||||||
|
protected final Set<UUID> loggedPlayers = ConcurrentHashMap.newKeySet();
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
public AuthMeVelocityPlugin(
|
||||||
|
ProxyServer proxy,
|
||||||
|
Logger logger,
|
||||||
|
@DataDirectory Path dataDirectory,
|
||||||
|
Metrics.Factory factory
|
||||||
|
) {
|
||||||
|
this.proxy = proxy;
|
||||||
|
this.logger = logger;
|
||||||
|
this.pluginDirectory = dataDirectory;
|
||||||
|
this.metricsFactory = factory;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Subscribe
|
||||||
|
public void onProxyInitialization(ProxyInitializeEvent event) {
|
||||||
|
final LibsManager libraries
|
||||||
|
= new LibsManager(
|
||||||
|
new VelocityLibraryManager<>(
|
||||||
|
logger, pluginDirectory, proxy.getPluginManager(), this));
|
||||||
|
libraries.loadLibraries();
|
||||||
|
|
||||||
|
this.config = Loader.loadMainConfig(pluginDirectory, ProxyConfiguration.class, logger);
|
||||||
|
logDebug("Loaded plugin libraries");
|
||||||
|
|
||||||
|
final int pluginId = 16128;
|
||||||
|
Metrics metrics = metricsFactory.make(this, pluginId);
|
||||||
|
|
||||||
|
proxy.getChannelRegistrar().register(AUTHMEVELOCITY_CHANNEL);
|
||||||
|
|
||||||
|
List.of(
|
||||||
|
new ProxyListener(this),
|
||||||
|
new ConnectListener(this, proxy, logger),
|
||||||
|
new PluginMessageListener(proxy, logger, this)
|
||||||
|
).forEach(listener ->
|
||||||
|
proxy.getEventManager().register(this, listener));
|
||||||
|
|
||||||
|
boolean fastlogin = proxy.getPluginManager().isLoaded("fastlogin");
|
||||||
|
metrics.addCustomChart(new SimplePie("fastlogin_compatibility", () -> Boolean.toString(fastlogin)));
|
||||||
|
if (fastlogin) {
|
||||||
|
logDebug("Register FastLogin compatibility");
|
||||||
|
proxy.getEventManager().register(this, new FastLoginListener(proxy, this));
|
||||||
|
}
|
||||||
|
|
||||||
|
boolean miniplaceholders = proxy.getPluginManager().isLoaded("miniplaceholders");
|
||||||
|
metrics.addCustomChart(new SimplePie("miniplaceholders_compatibility", () -> Boolean.toString(miniplaceholders)));
|
||||||
|
if (miniplaceholders) {
|
||||||
|
logDebug("Register MiniPlaceholders compatibility");
|
||||||
|
AuthMePlaceholders.getExpansion(this).register();
|
||||||
|
}
|
||||||
|
|
||||||
|
AuthmeCommand.register(this, proxy.getCommandManager());
|
||||||
|
|
||||||
|
this.sendInfoMessage();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected ProxyServer getProxy(){
|
||||||
|
return this.proxy;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void sendInfoMessage() {
|
||||||
|
CommandSource source = proxy.getConsoleCommandSource();
|
||||||
|
source.sendMessage(MiniMessage.miniMessage().deserialize(
|
||||||
|
" <gray>--- <aqua>AuthMeVelocity</aqua> ---"));
|
||||||
|
source.sendMessage(MiniMessage.miniMessage().deserialize(
|
||||||
|
"<gray>AuthServers: <green>" + config.get().authServers()));
|
||||||
|
if (config.get().sendOnLogin().sendToServerOnLogin()) {
|
||||||
|
source.sendMessage(MiniMessage.miniMessage().deserialize(
|
||||||
|
"<gray>LobbyServers: <green>" + config.get().sendOnLogin().teleportServers()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public ConfigurationContainer<ProxyConfiguration> config() {
|
||||||
|
return this.config;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isLogged(Player player){
|
||||||
|
return loggedPlayers.contains(player.getUniqueId());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isNotLogged(Player player){
|
||||||
|
return !loggedPlayers.contains(player.getUniqueId());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean addPlayer(Player player){
|
||||||
|
return loggedPlayers.add(player.getUniqueId());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean removePlayer(Player player){
|
||||||
|
return loggedPlayers.remove(player.getUniqueId());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void removePlayerIf(Predicate<Player> predicate){
|
||||||
|
loggedPlayers.removeIf(uuid -> predicate.test(getProxy().getPlayer(uuid).orElse(null)));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isInAuthServer(Player player){
|
||||||
|
return player.getCurrentServer().map(this::isAuthServer).orElse(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isAuthServer(RegisteredServer server){
|
||||||
|
return config.get().authServers().contains(server.getServerInfo().getName());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isAuthServer(ServerConnection connection){
|
||||||
|
return config.get().authServers().contains(connection.getServerInfo().getName());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isAuthServer(String server){
|
||||||
|
return config.get().authServers().contains(server);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void logDebug(String msg) {
|
||||||
|
if (config.get().advanced().debug()) {
|
||||||
|
logger.info("[DEBUG] {}", msg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -1,6 +1,5 @@
|
|||||||
package com.glyart.authmevelocity.proxy.commands;
|
package me.adrianed.authmevelocity.velocity.commands;
|
||||||
|
|
||||||
import com.glyart.authmevelocity.proxy.AuthMeVelocityPlugin;
|
|
||||||
import com.mojang.brigadier.Command;
|
import com.mojang.brigadier.Command;
|
||||||
import com.mojang.brigadier.builder.LiteralArgumentBuilder;
|
import com.mojang.brigadier.builder.LiteralArgumentBuilder;
|
||||||
import com.mojang.brigadier.tree.LiteralCommandNode;
|
import com.mojang.brigadier.tree.LiteralCommandNode;
|
||||||
@ -9,6 +8,7 @@ import com.velocitypowered.api.command.CommandManager;
|
|||||||
import com.velocitypowered.api.command.CommandMeta;
|
import com.velocitypowered.api.command.CommandMeta;
|
||||||
import com.velocitypowered.api.command.CommandSource;
|
import com.velocitypowered.api.command.CommandSource;
|
||||||
|
|
||||||
|
import me.adrianed.authmevelocity.velocity.AuthMeVelocityPlugin;
|
||||||
import net.kyori.adventure.text.minimessage.MiniMessage;
|
import net.kyori.adventure.text.minimessage.MiniMessage;
|
||||||
|
|
||||||
public class AuthmeCommand {
|
public class AuthmeCommand {
|
||||||
@ -20,14 +20,16 @@ public class AuthmeCommand {
|
|||||||
.then(LiteralArgumentBuilder.<CommandSource>literal("reload")
|
.then(LiteralArgumentBuilder.<CommandSource>literal("reload")
|
||||||
.executes(cmd -> {
|
.executes(cmd -> {
|
||||||
CommandSource source = cmd.getSource();
|
CommandSource source = cmd.getSource();
|
||||||
if (plugin.reload()) {
|
plugin.config().reload().thenAcceptAsync(result -> {
|
||||||
plugin.sendInfoMessage();
|
if(result) {
|
||||||
source.sendMessage(MiniMessage.miniMessage().deserialize(
|
plugin.sendInfoMessage();
|
||||||
"<aqua>AuthmeVelocity <green>has been successfully reloaded"));
|
source.sendMessage(MiniMessage.miniMessage().deserialize(
|
||||||
} else {
|
"<aqua>AuthmeVelocity <green>has been successfully reloaded"));
|
||||||
source.sendMessage(MiniMessage.miniMessage().deserialize(
|
} else {
|
||||||
"<dark_red>There was an error while reloading the configuration. <red>Check the server console"));
|
source.sendMessage(MiniMessage.miniMessage().deserialize(
|
||||||
}
|
"<dark_red>There was an error while reloading the configuration. <red>Check the server console"));
|
||||||
|
}
|
||||||
|
});
|
||||||
return Command.SINGLE_SUCCESS;
|
return Command.SINGLE_SUCCESS;
|
||||||
})
|
})
|
||||||
).build();
|
).build();
|
@ -1,13 +1,9 @@
|
|||||||
package com.glyart.authmevelocity.proxy.listener;
|
package me.adrianed.authmevelocity.velocity.listener;
|
||||||
|
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
|
||||||
import org.jetbrains.annotations.Nullable;
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
|
|
||||||
import com.glyart.authmevelocity.proxy.AuthMeVelocityPlugin;
|
|
||||||
import com.glyart.authmevelocity.proxy.AuthmeVelocityAPI;
|
|
||||||
import com.glyart.authmevelocity.proxy.config.AuthMeConfig;
|
|
||||||
import com.google.common.io.ByteArrayDataOutput;
|
import com.google.common.io.ByteArrayDataOutput;
|
||||||
import com.google.common.io.ByteStreams;
|
import com.google.common.io.ByteStreams;
|
||||||
import com.velocitypowered.api.event.Continuation;
|
import com.velocitypowered.api.event.Continuation;
|
||||||
@ -20,50 +16,58 @@ import com.velocitypowered.api.proxy.Player;
|
|||||||
import com.velocitypowered.api.proxy.ProxyServer;
|
import com.velocitypowered.api.proxy.ProxyServer;
|
||||||
import com.velocitypowered.api.proxy.server.RegisteredServer;
|
import com.velocitypowered.api.proxy.server.RegisteredServer;
|
||||||
|
|
||||||
|
import me.adrianed.authmevelocity.velocity.AuthMeVelocityPlugin;
|
||||||
|
import me.adrianed.authmevelocity.velocity.utils.AuthmeUtils;
|
||||||
|
|
||||||
public class ConnectListener {
|
public class ConnectListener {
|
||||||
private final ProxyServer proxy;
|
private final ProxyServer proxy;
|
||||||
private final Logger logger;
|
private final Logger logger;
|
||||||
private final AuthMeConfig config;
|
private final AuthMeVelocityPlugin plugin;
|
||||||
private final AuthmeVelocityAPI api;
|
|
||||||
|
|
||||||
public ConnectListener(AuthMeConfig config, AuthmeVelocityAPI api, ProxyServer proxy, Logger logger) {
|
public ConnectListener(AuthMeVelocityPlugin plugin, ProxyServer proxy, Logger logger) {
|
||||||
this.config = config;
|
this.plugin = plugin;
|
||||||
this.api = api;
|
|
||||||
this.logger = logger;
|
this.logger = logger;
|
||||||
this.proxy = proxy;
|
this.proxy = proxy;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Subscribe(order = PostOrder.LATE)
|
@Subscribe(order = PostOrder.LATE)
|
||||||
public void onInitialServer(PlayerChooseInitialServerEvent event, Continuation continuation){
|
public void onInitialServer(PlayerChooseInitialServerEvent event, Continuation continuation){
|
||||||
if(!config.getEnsureOptions().ensureAuthServer()) {
|
if(!plugin.config().get().ensureAuthServer().ensureFirstServerIsAuthServer()) {
|
||||||
continuation.resume();
|
continuation.resume();
|
||||||
|
plugin.logDebug("PlayerChooseInitialServerEvent | Not enabled");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Optional<RegisteredServer> optionalSV = event.getInitialServer();
|
Optional<RegisteredServer> optionalSV = event.getInitialServer();
|
||||||
if(optionalSV.isPresent() && api.isAuthServer(optionalSV.get())){
|
if(optionalSV.isPresent() && plugin.isAuthServer(optionalSV.get())){
|
||||||
continuation.resume();
|
continuation.resume();
|
||||||
|
plugin.logDebug("PlayerChooseInitialServerEvent | Player is in auth server");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
var config = plugin.config().get();
|
||||||
|
var server = AuthmeUtils.serverToSend(
|
||||||
|
config.ensureAuthServer().sendMode(), proxy, config.authServers(), config.advanced().randomAttempts());
|
||||||
|
|
||||||
@Nullable RegisteredServer server = getAvailableServer();
|
|
||||||
// Velocity takes over in case the initial server is not present
|
// Velocity takes over in case the initial server is not present
|
||||||
event.setInitialServer(server);
|
event.setInitialServer(server.object());
|
||||||
continuation.resume();
|
continuation.resume();
|
||||||
if (server == null) {
|
if (server.isEmpty()) {
|
||||||
|
plugin.logDebug("PlayerChooseInitialServerEvent | Null server");
|
||||||
logger.error("Cannot send the player {} to an auth server", event.getPlayer().getUsername());
|
logger.error("Cannot send the player {} to an auth server", event.getPlayer().getUsername());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Subscribe
|
@Subscribe
|
||||||
public void onServerPreConnect(ServerPreConnectEvent event, Continuation continuation) {
|
public void onServerPreConnect(ServerPreConnectEvent event, Continuation continuation) {
|
||||||
if (!event.getResult().isAllowed() || api.isLogged(event.getPlayer())) {
|
if (!event.getResult().isAllowed() || plugin.isLogged(event.getPlayer())) {
|
||||||
|
plugin.logDebug("ServerPreConnectEvent | Not allowed or player not logged");
|
||||||
continuation.resume();
|
continuation.resume();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// this should be present, "event.getResult().isAllowed()" is the "isPresent" check
|
// this should be present, "event.getResult().isAllowed()" is the "isPresent" check
|
||||||
if(!api.isAuthServer(event.getResult().getServer().get())) {
|
if(!plugin.isAuthServer(event.getResult().getServer().orElse(null))) {
|
||||||
|
plugin.logDebug("ServerPreConnectEvent | Server is not an auth server");
|
||||||
event.setResult(ServerPreConnectEvent.ServerResult.denied());
|
event.setResult(ServerPreConnectEvent.ServerResult.denied());
|
||||||
}
|
}
|
||||||
continuation.resume();
|
continuation.resume();
|
||||||
@ -72,20 +76,12 @@ public class ConnectListener {
|
|||||||
@Subscribe
|
@Subscribe
|
||||||
public void onServerPostConnect(ServerPostConnectEvent event) {
|
public void onServerPostConnect(ServerPostConnectEvent event) {
|
||||||
final Player player = event.getPlayer();
|
final Player player = event.getPlayer();
|
||||||
if (api.isLogged(player) && api.isInAuthServer(player)) {
|
if (plugin.isLogged(player) && plugin.isInAuthServer(player)) {
|
||||||
ByteArrayDataOutput buf = ByteStreams.newDataOutput();
|
plugin.logDebug("ServerPostConnectEvent | Already logged player and connected to an Auth server");
|
||||||
|
final ByteArrayDataOutput buf = ByteStreams.newDataOutput();
|
||||||
buf.writeUTF("LOGIN");
|
buf.writeUTF("LOGIN");
|
||||||
player.getCurrentServer().ifPresent(sv ->
|
player.getCurrentServer().ifPresent(sv ->
|
||||||
sv.sendPluginMessage(AuthMeVelocityPlugin.AUTHMEVELOCITY_CHANNEL, buf.toByteArray()));
|
sv.sendPluginMessage(AuthMeVelocityPlugin.AUTHMEVELOCITY_CHANNEL, buf.toByteArray()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Implement #40
|
|
||||||
private @Nullable RegisteredServer getAvailableServer() {
|
|
||||||
for(String sv : config.getAuthServers()){
|
|
||||||
Optional<RegisteredServer> opt = proxy.getServer(sv);
|
|
||||||
if (opt.isPresent()) return opt.get();
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
}
|
@ -0,0 +1,21 @@
|
|||||||
|
package me.adrianed.authmevelocity.velocity.listener;
|
||||||
|
|
||||||
|
import com.github.games647.fastlogin.velocity.event.VelocityFastLoginAutoLoginEvent;
|
||||||
|
import com.velocitypowered.api.event.Subscribe;
|
||||||
|
import com.velocitypowered.api.proxy.ProxyServer;
|
||||||
|
|
||||||
|
import me.adrianed.authmevelocity.velocity.AuthMeVelocityPlugin;
|
||||||
|
|
||||||
|
public class FastLoginListener {
|
||||||
|
private final ProxyServer proxy;
|
||||||
|
private final AuthMeVelocityPlugin plugin;
|
||||||
|
public FastLoginListener(ProxyServer proxy, AuthMeVelocityPlugin plugin){
|
||||||
|
this.proxy = proxy;
|
||||||
|
this.plugin = plugin;
|
||||||
|
}
|
||||||
|
@Subscribe
|
||||||
|
public void onAutoLogin(VelocityFastLoginAutoLoginEvent event){
|
||||||
|
plugin.logDebug("VelocityFastLoginAutoLoginEvent | Attempt to auto register player");
|
||||||
|
proxy.getPlayer(event.getProfile().getName()).ifPresent(plugin::addPlayer);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,137 @@
|
|||||||
|
package me.adrianed.authmevelocity.velocity.listener;
|
||||||
|
|
||||||
|
import java.util.Locale;
|
||||||
|
|
||||||
|
import me.adrianed.authmevelocity.api.velocity.event.PreSendOnLoginEvent;
|
||||||
|
import me.adrianed.authmevelocity.api.velocity.event.ProxyForcedUnregisterEvent;
|
||||||
|
import me.adrianed.authmevelocity.api.velocity.event.ProxyLoginEvent;
|
||||||
|
import me.adrianed.authmevelocity.api.velocity.event.ProxyLogoutEvent;
|
||||||
|
import me.adrianed.authmevelocity.api.velocity.event.ProxyRegisterEvent;
|
||||||
|
import me.adrianed.authmevelocity.api.velocity.event.ProxyUnregisterEvent;
|
||||||
|
import me.adrianed.authmevelocity.common.MessageType;
|
||||||
|
import com.google.common.io.ByteArrayDataInput;
|
||||||
|
import com.velocitypowered.api.event.Continuation;
|
||||||
|
import com.velocitypowered.api.event.Subscribe;
|
||||||
|
import com.velocitypowered.api.event.connection.PluginMessageEvent;
|
||||||
|
import com.velocitypowered.api.proxy.Player;
|
||||||
|
import com.velocitypowered.api.proxy.ProxyServer;
|
||||||
|
import com.velocitypowered.api.proxy.ServerConnection;
|
||||||
|
import com.velocitypowered.api.proxy.server.RegisteredServer;
|
||||||
|
|
||||||
|
import me.adrianed.authmevelocity.velocity.AuthMeVelocityPlugin;
|
||||||
|
import me.adrianed.authmevelocity.velocity.utils.AuthmeUtils;
|
||||||
|
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
|
||||||
|
public class PluginMessageListener {
|
||||||
|
private final ProxyServer proxy;
|
||||||
|
private final Logger logger;
|
||||||
|
private final AuthMeVelocityPlugin plugin;
|
||||||
|
|
||||||
|
public PluginMessageListener(@NotNull ProxyServer proxy, @NotNull Logger logger, AuthMeVelocityPlugin plugin) {
|
||||||
|
this.proxy = proxy;
|
||||||
|
this.logger = logger;
|
||||||
|
this.plugin = plugin;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Subscribe
|
||||||
|
public void onPluginMessage(final PluginMessageEvent event, Continuation continuation) {
|
||||||
|
final boolean cancelled = !event.getResult().isAllowed()
|
||||||
|
|| !(event.getSource() instanceof ServerConnection)
|
||||||
|
|| !event.getIdentifier().equals(AuthMeVelocityPlugin.AUTHMEVELOCITY_CHANNEL);
|
||||||
|
if (cancelled) {
|
||||||
|
continuation.resume();
|
||||||
|
plugin.logDebug("PluginMessageEvent | Not allowed");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
final ServerConnection connection = (ServerConnection) event.getSource();
|
||||||
|
|
||||||
|
event.setResult(PluginMessageEvent.ForwardResult.handled());
|
||||||
|
|
||||||
|
final ByteArrayDataInput input = event.dataAsDataStream();
|
||||||
|
final String message = input.readUTF();
|
||||||
|
final MessageType type = MessageType.INDEX.value(
|
||||||
|
message.toUpperCase(Locale.ROOT));
|
||||||
|
final String name = input.readUTF();
|
||||||
|
final @Nullable Player player = proxy.getPlayer(name).orElse(null);
|
||||||
|
|
||||||
|
switch (type) {
|
||||||
|
case LOGIN -> {
|
||||||
|
plugin.logDebug("PluginMessageEvent | Login type");
|
||||||
|
if (player != null && plugin.addPlayer(player)) {
|
||||||
|
proxy.getEventManager().fireAndForget(new ProxyLoginEvent(player));
|
||||||
|
this.createServerConnectionRequest(player, connection);
|
||||||
|
plugin.logDebug("PluginMessageEvent | Player not null");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
case LOGOUT -> {
|
||||||
|
plugin.logDebug("PluginMessageEvent | Logout type");
|
||||||
|
if (player != null && plugin.removePlayer(player)){
|
||||||
|
proxy.getEventManager().fireAndForget(new ProxyLogoutEvent(player));
|
||||||
|
plugin.logDebug("PluginMessageEvent | Player not null");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
case REGISTER -> {
|
||||||
|
plugin.logDebug("PluginMessageEvent | Register");
|
||||||
|
if (player != null) {
|
||||||
|
proxy.getEventManager().fireAndForget(new ProxyRegisterEvent(player));
|
||||||
|
plugin.logDebug("PluginMessageEvent | Player not null");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
case UNREGISTER -> {
|
||||||
|
plugin.logDebug("PluginMessageEvent | Unregister type");
|
||||||
|
if (player != null) {
|
||||||
|
plugin.logDebug("PluginMessageEvent | Player not null");
|
||||||
|
proxy.getEventManager().fireAndForget(new ProxyUnregisterEvent(player));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
case FORCE_UNREGISTER -> {
|
||||||
|
proxy.getEventManager().fireAndForget(new ProxyForcedUnregisterEvent(player));
|
||||||
|
plugin.logDebug("PluginMessageEvent | Forced Unregister type");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
continuation.resume();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void createServerConnectionRequest(Player player, ServerConnection connection){
|
||||||
|
if (!plugin.config().get().sendOnLogin().sendToServerOnLogin()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
final RegisteredServer loginServer = player.getCurrentServer().orElse(connection).getServer();
|
||||||
|
|
||||||
|
var config = plugin.config().get();
|
||||||
|
|
||||||
|
var toSend = AuthmeUtils.serverToSend(
|
||||||
|
config.sendOnLogin().sendMode(), proxy, config.authServers(), config.advanced().randomAttempts());
|
||||||
|
|
||||||
|
if (toSend.isEmpty()) {
|
||||||
|
if (toSend.string() != null) {
|
||||||
|
logger.warn("The server {} does not exist", toSend.string());
|
||||||
|
} else {
|
||||||
|
logger.warn("There is not valid server to send");
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
proxy.getEventManager().fire(new PreSendOnLoginEvent(player, loginServer, toSend.object()))
|
||||||
|
.thenAccept(event -> {
|
||||||
|
if (!event.getResult().isAllowed()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
player.createConnectionRequest(event.getResult().getServer())
|
||||||
|
.connect()
|
||||||
|
.thenAcceptAsync(result -> {
|
||||||
|
if (!result.isSuccessful()) {
|
||||||
|
logger.info("Unable to connect the player {} to the server {}",
|
||||||
|
player.getUsername(),
|
||||||
|
result.getAttemptedConnection().getServerInfo().getName());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,117 @@
|
|||||||
|
package me.adrianed.authmevelocity.velocity.listener;
|
||||||
|
|
||||||
|
import me.adrianed.authmevelocity.velocity.utils.AuthmeUtils;
|
||||||
|
import me.adrianed.authmevelocity.velocity.AuthMeVelocityPlugin;
|
||||||
|
import com.velocitypowered.api.event.Continuation;
|
||||||
|
import com.velocitypowered.api.event.EventTask;
|
||||||
|
import com.velocitypowered.api.event.PostOrder;
|
||||||
|
import com.velocitypowered.api.event.Subscribe;
|
||||||
|
import com.velocitypowered.api.event.command.CommandExecuteEvent;
|
||||||
|
import com.velocitypowered.api.event.connection.DisconnectEvent;
|
||||||
|
import com.velocitypowered.api.event.player.PlayerChatEvent;
|
||||||
|
import com.velocitypowered.api.event.player.TabCompleteEvent;
|
||||||
|
import com.velocitypowered.api.network.ProtocolVersion;
|
||||||
|
import com.velocitypowered.api.proxy.Player;
|
||||||
|
|
||||||
|
import net.kyori.adventure.text.minimessage.MiniMessage;
|
||||||
|
|
||||||
|
public final class ProxyListener {
|
||||||
|
private final AuthMeVelocityPlugin plugin;
|
||||||
|
|
||||||
|
public ProxyListener(AuthMeVelocityPlugin plugin) {
|
||||||
|
this.plugin = plugin;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Subscribe
|
||||||
|
public EventTask onDisconnect(final DisconnectEvent event) {
|
||||||
|
return EventTask.async(() -> plugin.removePlayer(event.getPlayer()));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Subscribe(order = PostOrder.FIRST)
|
||||||
|
public void onCommandExecute(final CommandExecuteEvent event, Continuation continuation) {
|
||||||
|
if (!(event.getCommandSource() instanceof final Player player)){
|
||||||
|
plugin.logDebug("CommandExecuteEvent | CommandSource is not a player");
|
||||||
|
continuation.resume();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (plugin.isLogged(player)) {
|
||||||
|
plugin.logDebug("CommandExecuteEvent | Player is already logged");
|
||||||
|
continuation.resume();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (canBeIgnored(player)) {
|
||||||
|
plugin.logDebug("CommandexecuteEvent | Ignored signed player");
|
||||||
|
continuation.resume();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (plugin.isInAuthServer(player)) {
|
||||||
|
plugin.logDebug("CommandExecuteEvent | Player is in Auth Server");
|
||||||
|
String command = AuthmeUtils.getFirstArgument(event.getCommand());
|
||||||
|
if (!plugin.config().get().commands().allowedCommands().contains(command)) {
|
||||||
|
plugin.logDebug("CommandExecuteEvent | Player executed an blocked command");
|
||||||
|
sendBlockedMessage(player);
|
||||||
|
event.setResult(CommandExecuteEvent.CommandResult.denied());
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
plugin.logDebug("CommandExecuteEven | Player is not in auth server");
|
||||||
|
sendBlockedMessage(player);
|
||||||
|
event.setResult(CommandExecuteEvent.CommandResult.denied());
|
||||||
|
}
|
||||||
|
continuation.resume();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Subscribe(order = PostOrder.FIRST)
|
||||||
|
public void onPlayerChat(final PlayerChatEvent event, Continuation continuation) {
|
||||||
|
if (plugin.isLogged(event.getPlayer())) {
|
||||||
|
plugin.logDebug("PlayerChatEvent | Player is already logged");
|
||||||
|
continuation.resume();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
plugin.logDebug("PlayerChatEvent | Player is not logged");
|
||||||
|
|
||||||
|
if (canBeIgnored(event.getPlayer())) {
|
||||||
|
plugin.logDebug("PlayerChatEvent | Ignored signed player");
|
||||||
|
continuation.resume();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
event.setResult(PlayerChatEvent.ChatResult.denied());
|
||||||
|
continuation.resume();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Subscribe(order = PostOrder.FIRST)
|
||||||
|
public void onTabComplete(TabCompleteEvent event){
|
||||||
|
if (plugin.isLogged(event.getPlayer())) {
|
||||||
|
plugin.logDebug("TabCompleteEvent | Player is already logged");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
final String command = event.getPartialMessage();
|
||||||
|
for (final String allowed : plugin.config().get().commands().allowedCommands()) {
|
||||||
|
if (allowed.startsWith(command)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
plugin.logDebug("TabCompleteEvent | Not allowed tabcompletion");
|
||||||
|
event.getSuggestions().clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
void sendBlockedMessage(Player player){
|
||||||
|
String blockedMessage = plugin.config().get().commands().blockedCommandMessage();
|
||||||
|
if (!blockedMessage.isBlank()){
|
||||||
|
player.sendMessage(MiniMessage.miniMessage().deserialize(blockedMessage));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
boolean canBeIgnored(Player player) {
|
||||||
|
return player.getIdentifiedKey() != null
|
||||||
|
&& player.getProtocolVersion().compareTo(ProtocolVersion.MINECRAFT_1_19_1) >= 0
|
||||||
|
&& plugin.config().get().advanced().ignoreSignedPlayers();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,81 @@
|
|||||||
|
package me.adrianed.authmevelocity.velocity.utils;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Objects;
|
||||||
|
import java.util.Optional;
|
||||||
|
import java.util.Random;
|
||||||
|
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
import com.velocitypowered.api.proxy.ProxyServer;
|
||||||
|
import com.velocitypowered.api.proxy.server.RegisteredServer;
|
||||||
|
|
||||||
|
import me.adrianed.authmevelocity.common.enums.SendMode;
|
||||||
|
|
||||||
|
public class AuthmeUtils {
|
||||||
|
//Origin: https://github.com/4drian3d/ChatRegulator/blob/main/src/main/java/me/dreamerzero/chatregulator/utils/CommandUtils.java#L71
|
||||||
|
/**
|
||||||
|
* Get the first argument of a string
|
||||||
|
* @param string the string
|
||||||
|
* @return the first argument
|
||||||
|
*/
|
||||||
|
public static @NotNull String getFirstArgument(final @NotNull String string){
|
||||||
|
final int index = Objects.requireNonNull(string).indexOf(' ');
|
||||||
|
if (index == -1) {
|
||||||
|
return string;
|
||||||
|
}
|
||||||
|
return string.substring(0, index);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static final Random RANDOM = new Random();
|
||||||
|
|
||||||
|
public static Pair<RegisteredServer> serverToSend(SendMode sendMode, ProxyServer proxy, List<String> servers, int attempts) {
|
||||||
|
return switch(sendMode) {
|
||||||
|
case TO_FIRST -> {
|
||||||
|
Optional<RegisteredServer> sv;
|
||||||
|
for (final String st : servers) {
|
||||||
|
sv = proxy.getServer(st);
|
||||||
|
if (sv.isPresent()) yield Pair.of(st, sv.get());
|
||||||
|
}
|
||||||
|
yield Pair.of(null, null);
|
||||||
|
}
|
||||||
|
case TO_EMPTIEST_SERVER -> {
|
||||||
|
RegisteredServer emptiest = null;
|
||||||
|
Optional<RegisteredServer> optional = Optional.empty();
|
||||||
|
for (final String st : servers) {
|
||||||
|
optional = proxy.getServer(st);
|
||||||
|
if (optional.isPresent()) {
|
||||||
|
RegisteredServer actualsv = optional.get();
|
||||||
|
int actualConnected = actualsv.getPlayersConnected().size();
|
||||||
|
if (actualConnected == 0) {
|
||||||
|
yield Pair.of(st, actualsv);
|
||||||
|
}
|
||||||
|
if (emptiest == null || actualConnected < emptiest.getPlayersConnected().size()) {
|
||||||
|
emptiest = actualsv;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
yield Pair.of(optional.map(sv -> sv.getServerInfo().getName()).orElse(null), emptiest);
|
||||||
|
}
|
||||||
|
case RANDOM -> {
|
||||||
|
Optional<RegisteredServer> server;
|
||||||
|
if (servers.size() == 1) {
|
||||||
|
server = proxy.getServer(servers.get(0));
|
||||||
|
// It is nonsense to make so many attempts if there are a single server
|
||||||
|
yield Pair.of(
|
||||||
|
server.map(sv -> sv.getServerInfo().getName()).orElse(null),
|
||||||
|
server.orElse(null));
|
||||||
|
}
|
||||||
|
for (int i = 0; i < attempts; i++) {
|
||||||
|
int value = RANDOM.nextInt(servers.size());
|
||||||
|
server = proxy.getServer(servers.get(value));
|
||||||
|
if (server.isPresent()) {
|
||||||
|
yield Pair.of(server.get().getServerInfo().getName(), server.get());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
yield Pair.of(null, null);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
private AuthmeUtils() {}
|
||||||
|
}
|
@ -0,0 +1,15 @@
|
|||||||
|
package me.adrianed.authmevelocity.velocity.utils;
|
||||||
|
|
||||||
|
public record Pair<O>(String string, O object) {
|
||||||
|
public boolean isPresent() {
|
||||||
|
return this.object != null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isEmpty() {
|
||||||
|
return object == null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static <O> Pair<O> of(String string, O object) {
|
||||||
|
return new Pair<>(string, object);
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user