Author SHA1 Message Date
NotCoded b59fc05b64 why did i have this stashed 2024-03-29 22:33:11 +01:00
259 changed files with 4864 additions and 10242 deletions

No files matched your search

+3 -3
View File
@@ -12,7 +12,7 @@ jobs:
matrix:
# Use these Java versions
java: [
21
17 # Minimum supported by Minecraft
]
# and run on both Linux and Windows
os: [ubuntu-20.04, windows-latest]
@@ -32,8 +32,8 @@ jobs:
- name: build
run: ./gradlew build
- name: capture build artifacts
if: ${{ runner.os == 'Linux' && matrix.java == '21' }} # Only upload artifacts built from latest java on one OS
if: ${{ runner.os == 'Linux' && matrix.java == '17' }} # Only upload artifacts built from latest java on one OS
uses: actions/upload-artifact@v3
with:
name: Artifacts
path: build/${{ github.ref_name }}/libs
path: build/dev/libs
-60
View File
@@ -1,63 +1,3 @@
### Linux ###
*~
# temporary files which can be created if a process still has a handle open of a deleted file
.fuse_hidden*
# .nfs files are created when an open file is removed but is still being accessed
.nfs*
### macOS ###
# General
.DS_Store
.AppleDouble
.LSOverride
# Thumbnails
._*
# Files that might appear in the root of a volume
.DocumentRevisions-V100
.fseventsd
.Spotlight-V100
.TemporaryItems
.Trashes
.VolumeIcon.icns
.com.apple.timemachine.donotpresent
# Directories potentially created on remote AFP share
.AppleDB
.AppleDesktop
Network Trash Folder
Temporary Items
.apdisk
### Windows ###
# Windows thumbnail cache files
Thumbs.db
Thumbs.db:encryptable
ehthumbs.db
ehthumbs_vista.db
# Dump file
*.stackdump
# Folder config file
[Dd]esktop.ini
# Recycle Bin used on file shares
$RECYCLE.BIN/
# Windows Installer files
*.cab
*.msi
*.msix
*.msm
*.msp
# Windows shortcuts
*.lnk
# gradle
.gradle
+121 -674
View File
@@ -1,674 +1,121 @@
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>.
Creative Commons Legal Code
CC0 1.0 Universal
CREATIVE COMMONS CORPORATION IS NOT A LAW FIRM AND DOES NOT PROVIDE
LEGAL SERVICES. DISTRIBUTION OF THIS DOCUMENT DOES NOT CREATE AN
ATTORNEY-CLIENT RELATIONSHIP. CREATIVE COMMONS PROVIDES THIS
INFORMATION ON AN "AS-IS" BASIS. CREATIVE COMMONS MAKES NO WARRANTIES
REGARDING THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS
PROVIDED HEREUNDER, AND DISCLAIMS LIABILITY FOR DAMAGES RESULTING FROM
THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS PROVIDED
HEREUNDER.
Statement of Purpose
The laws of most jurisdictions throughout the world automatically confer
exclusive Copyright and Related Rights (defined below) upon the creator
and subsequent owner(s) (each and all, an "owner") of an original work of
authorship and/or a database (each, a "Work").
Certain owners wish to permanently relinquish those rights to a Work for
the purpose of contributing to a commons of creative, cultural and
scientific works ("Commons") that the public can reliably and without fear
of later claims of infringement build upon, modify, incorporate in other
works, reuse and redistribute as freely as possible in any form whatsoever
and for any purposes, including without limitation commercial purposes.
These owners may contribute to the Commons to promote the ideal of a free
culture and the further production of creative, cultural and scientific
works, or to gain reputation or greater distribution for their Work in
part through the use and efforts of others.
For these and/or other purposes and motivations, and without any
expectation of additional consideration or compensation, the person
associating CC0 with a Work (the "Affirmer"), to the extent that he or she
is an owner of Copyright and Related Rights in the Work, voluntarily
elects to apply CC0 to the Work and publicly distribute the Work under its
terms, with knowledge of his or her Copyright and Related Rights in the
Work and the meaning and intended legal effect of CC0 on those rights.
1. Copyright and Related Rights. A Work made available under CC0 may be
protected by copyright and related or neighboring rights ("Copyright and
Related Rights"). Copyright and Related Rights include, but are not
limited to, the following:
i. the right to reproduce, adapt, distribute, perform, display,
communicate, and translate a Work;
ii. moral rights retained by the original author(s) and/or performer(s);
iii. publicity and privacy rights pertaining to a person's image or
likeness depicted in a Work;
iv. rights protecting against unfair competition in regards to a Work,
subject to the limitations in paragraph 4(a), below;
v. rights protecting the extraction, dissemination, use and reuse of data
in a Work;
vi. database rights (such as those arising under Directive 96/9/EC of the
European Parliament and of the Council of 11 March 1996 on the legal
protection of databases, and under any national implementation
thereof, including any amended or successor version of such
directive); and
vii. other similar, equivalent or corresponding rights throughout the
world based on applicable law or treaty, and any national
implementations thereof.
2. Waiver. To the greatest extent permitted by, but not in contravention
of, applicable law, Affirmer hereby overtly, fully, permanently,
irrevocably and unconditionally waives, abandons, and surrenders all of
Affirmer's Copyright and Related Rights and associated claims and causes
of action, whether now known or unknown (including existing as well as
future claims and causes of action), in the Work (i) in all territories
worldwide, (ii) for the maximum duration provided by applicable law or
treaty (including future time extensions), (iii) in any current or future
medium and for any number of copies, and (iv) for any purpose whatsoever,
including without limitation commercial, advertising or promotional
purposes (the "Waiver"). Affirmer makes the Waiver for the benefit of each
member of the public at large and to the detriment of Affirmer's heirs and
successors, fully intending that such Waiver shall not be subject to
revocation, rescission, cancellation, termination, or any other legal or
equitable action to disrupt the quiet enjoyment of the Work by the public
as contemplated by Affirmer's express Statement of Purpose.
3. Public License Fallback. Should any part of the Waiver for any reason
be judged legally invalid or ineffective under applicable law, then the
Waiver shall be preserved to the maximum extent permitted taking into
account Affirmer's express Statement of Purpose. In addition, to the
extent the Waiver is so judged Affirmer hereby grants to each affected
person a royalty-free, non transferable, non sublicensable, non exclusive,
irrevocable and unconditional license to exercise Affirmer's Copyright and
Related Rights in the Work (i) in all territories worldwide, (ii) for the
maximum duration provided by applicable law or treaty (including future
time extensions), (iii) in any current or future medium and for any number
of copies, and (iv) for any purpose whatsoever, including without
limitation commercial, advertising or promotional purposes (the
"License"). The License shall be deemed effective as of the date CC0 was
applied by Affirmer to the Work. Should any part of the License for any
reason be judged legally invalid or ineffective under applicable law, such
partial invalidity or ineffectiveness shall not invalidate the remainder
of the License, and in such case Affirmer hereby affirms that he or she
will not (i) exercise any of his or her remaining Copyright and Related
Rights in the Work or (ii) assert any associated claims and causes of
action with respect to the Work, in either case contrary to Affirmer's
express Statement of Purpose.
4. Limitations and Disclaimers.
a. No trademark or patent rights held by Affirmer are waived, abandoned,
surrendered, licensed or otherwise affected by this document.
b. Affirmer offers the Work as-is and makes no representations or
warranties of any kind concerning the Work, express, implied,
statutory or otherwise, including without limitation warranties of
title, merchantability, fitness for a particular purpose, non
infringement, or the absence of latent or other defects, accuracy, or
the present or absence of errors, whether or not discoverable, all to
the greatest extent permissible under applicable law.
c. Affirmer disclaims responsibility for clearing rights of other persons
that may apply to the Work or any use thereof, including without
limitation any person's Copyright and Related Rights in the Work.
Further, Affirmer disclaims responsibility for obtaining any necessary
consents, permissions or other rights required for any use of the
Work.
d. Affirmer understands and acknowledges that Creative Commons is not a
party to this document and has no duty or obligation with respect to
this CC0 or use of the Work.
+7 -19
View File
@@ -1,24 +1,12 @@
<div align="center">
# Nexia DEV
using Metis API
<img src="https://notcoded.needs.rest/r/nexia.png" height=150 alt="Nexia Logo"/>
<br>
Last Sync with [Main](https://github.com/nexia-cts/Nexia-Mod/tree/main):
# Nexia
[92e00caae78cb985bb7ae4297d7f7d04971b26a2](https://github.com/nexia-cts/Nexia-Mod/commit/92e00caae78cb985bb7ae4297d7f7d04971b26a2)
The mod for the Nexia CTS server.
</div>
*(may be 1 commit forward)*
### Requirements
- Java 21
- Gradle 8.7
### Documentation
- Read [documentation](https://github.com/nexia-cts/Nexia-Mod/tree/documentation)
### Build
- Clone the repository
- `git clone https://github.com/nexia-cts/Nexia-Mod`
- `git checkout 'main/dev'`
- Run `./gradlew build`
- Java 17
- Gradle 7.3
+69 -56
View File
@@ -1,11 +1,15 @@
import org.apache.commons.io.FileUtils;
import org.apache.commons.io.FileUtils
plugins {
id 'fabric-loom' version '1.6-SNAPSHOT'
id 'fabric-loom' version '0.13-SNAPSHOT'
id 'maven-publish'
}
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
String getGitCommit() {
ByteArrayOutputStream stdout = new ByteArrayOutputStream();
ByteArrayOutputStream stdout = new ByteArrayOutputStream()
exec {
commandLine("git", "rev-parse", "--short", "HEAD")
standardOutput = stdout
@@ -13,40 +17,26 @@ String getGitCommit() {
return stdout.toString().trim()
}
String getGitBranch() {
ByteArrayOutputStream stdout = new ByteArrayOutputStream();
exec {
commandLine("git", "rev-parse", "--abbrev-ref", "HEAD")
standardOutput = stdout
}
return stdout.toString().trim()
}
version = project.mod_version + "+" + getGitBranch() + "." + getGitCommit()
archivesBaseName = project.archives_base_name
version = project.mod_version + "." + getGitCommit()
group = project.maven_group
// Set Build Dir to main to differentiate
buildDir = new File(buildDir, getGitBranch())
// Set Build Dir to dev to differentiate with main
buildDir = new File(buildDir, "dev")
if(new File(buildDir, "libs").exists()) FileUtils.cleanDirectory(buildDir.toPath().resolve("libs").toFile())
base {
archivesName = project.archives_base_name
}
// Repo for CT intermediary mappings
repositories {
flatDir { dirs("libraries") }
maven { url 'https://github.com/not-coded/notcoded-maven/raw/fabric/' }
maven { url 'https://maven.nucleoid.xyz' }
//maven { url "https://maven.rizecookey.net/" }
flatDir { dirs 'metis' }
maven { url "https://maven.shedaniel.me/" }
maven { url "https://maven.gegy.dev/" }
maven { url "https://jitpack.io" }
maven { url "https://maven.terraformersmc.com/releases/" }
maven { url 'https://oss.sonatype.org/content/repositories/snapshots' }
maven { url 'https://github.com/ricksouth/serilum-forge-maven/raw/maven/' }
maven { url 'https://repo.minebench.de/' }
}
dependencies {
@@ -54,46 +44,40 @@ dependencies {
minecraft "com.mojang:minecraft:${project.minecraft_version}"
mappings loom.officialMojangMappings()
modImplementation "net.fabricmc:fabric-loader:${project.loader_version}"
modImplementation("com.combatreforged.factory:factory-api:${project.factory_version}-full")
modImplementation("com.combatreforged.factory:factory-builder:${project.factory_version}-1.16_combat-6")
include(implementation("com.google.code.gson:gson:${project.gson_version}"))
include(implementation(annotationProcessor("com.github.llamalad7.mixinextras:mixinextras-fabric:${project.mixin_extras_version}")))
modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}"
// Use Metis API.
modImplementation('com.combatreforged.metis:metis-api:0.1.13-full')
modImplementation('com.combatreforged.metis:metis-builder:0.1.13-1.16_combat-6-full')
include(implementation("com.google.code.gson:gson:2.10.1"))
include(implementation(annotationProcessor("com.github.llamalad7.mixinextras:mixinextras-fabric:${project.mixin_extras_version}")))
//include(modApi("eu.pb4:hologram-api:0.1.0") { exclude(group: "net.fabricmc.fabric-api") })
//include(modApi("eu.pb4:sidebar-api:0.0.2") { exclude(group: "net.fabricmc.fabric-api") })
modImplementation("com.natamus:saveandloadinventories_fabric:${project.saveandloadinventories_version}")
modApi("com.natamus.collective:collective-fabric:${project.collective_version}")
modApi("xyz.nucleoid:fantasy:${project.fantasy_version}") {exclude(group: "net.fabricmc.fabric-api") }
include(modApi("eu.pb4:sgui:${project.sgui_version}") { exclude(group: "net.fabricmc.fabric-api") })
include(modApi("me.sargunvohra.mcmods:autoconfig1u:${project.autoconfig1u_version}") { exclude(group: "net.fabricmc.fabric-api") })
modApi('xyz.nucleoid:fantasy:0.4.0') {exclude(group: "net.fabricmc.fabric-api") }
modApi('com.natamus.collective:collective-fabric:1.16.5-5.50')
// Do not include, modified version is on the server.
include(modApi('eu.pb4:sgui:0.5.0') { exclude(group: "net.fabricmc.fabric-api") })
include(modApi('me.sargunvohra.mcmods:autoconfig1u:3.3.1') { exclude(group: "net.fabricmc.fabric-api") })
//include(modApi("xyz.nucleoid:plasmid:${project.plasmid_version}"))
include(implementation("com.googlecode.json-simple:json-simple:${project.json_simple_version}"))
modApi("me.lucko:fabric-permissions-api:${project.fabric_permissions_api_version}")
include(implementation("com.googlecode.json-simple:json-simple:1.1.1"))
modApi('me.lucko:fabric-permissions-api:0.2-SNAPSHOT')
include(modApi('net.blumbo:blfscheduler:1.0.0-1.16_combat-6'))
modApi("com.nexia:gato-anticheat:${project.gato_anticheat_version}+${project.minecraft_version}")
include(modApi("net.blumbo:blfscheduler:${project.blfscheduler_version}"))
include(modApi("io.github.blumbo:inventory-merger:${project.inventory_merger_version}"))
include(modApi("net.notcoded:codelib:${project.codelib_version}+${project.minecraft_version}"))
include(implementation("net.kyori:adventure-text-minimessage:4.1.0-SNAPSHOT"))
include(implementation("net.kyori:adventure-text-serializer-gson:4.1.0-SNAPSHOT"))
include(compileOnly("de.themoep:minedown-adventure:1.7.3-SNAPSHOT"))
// discord shit
include(api("net.dv8tion:JDA:${project.jda_version}"))
include(api("club.minnced:discord-webhooks:${project.discord_webhooks_version}") { exclude(group: "org.json") })
include(api("org.json:json:${project.json_version}"))
include(api('club.minnced:discord-webhooks:0.8.2') { exclude(group: "org.json") })
include(api('org.json:json:20230227'))
// PSA: Some older mods, compiled on Loom 0.2.1, might have outdated Maven POMs.
// You may need to force-disable transitiveness on them.
@@ -103,7 +87,6 @@ dependencies {
loom {
accessWidenerPath = file("src/main/resources/nexia.accesswidener")
customMinecraftManifest = "https://gist.githubusercontent.com/rizecookey/4c6142baaccc3875f9b227fe22f2ace5/raw/c8ed74b19f7a5315813c9d4b199798b692a8f359/1.16_combat-6.json"
intermediaryUrl = "https://maven.rizecookey.net/net/fabricmc/intermediary/%1\$s/intermediary-%1\$s-v2.jar"
}
@@ -119,23 +102,53 @@ processResources {
// ensure that the encoding is set to UTF-8, no matter what the system default is
// this fixes some edge cases with special characters not displaying correctly
// see http://yodaconditions.net/blog/fix-for-java-file-encoding-problems-with-gradle.html
def targetJavaVersion = 21
def targetJavaVersion = 17
tasks.withType(JavaCompile).configureEach {
it.options.encoding = "UTF-8"
if (targetJavaVersion >= 10 || JavaVersion.current().isJava10Compatible()) {
it.options.release = targetJavaVersion
}
}
// Minecraft 1.18 (1.18-pre2) upwards uses Java 17.
it.options.release = targetJavaVersion
// Loom will automatically attach sourcesJar to a RemapSourcesJar task and to the "build" task
// if it is present.
// If you remove this task, sources will not be generated.
task sourcesJar(type: Jar, dependsOn: classes) {
classifier = "sources"
from sourceSets.main.allSource
}
java {
withSourcesJar()
sourceCompatibility = JavaVersion.VERSION_21
targetCompatibility = JavaVersion.VERSION_21
def javaVersion = JavaVersion.toVersion(targetJavaVersion)
if (JavaVersion.current() < javaVersion) {
toolchain.languageVersion = JavaLanguageVersion.of(targetJavaVersion)
}
archivesBaseName = project.archives_base_name
}
jar {
from("LICENSE") {
rename { "${it}_${project.archivesBaseName}" }
}
}
// configure the maven publication
publishing {
publications {
mavenJava(MavenPublication) {
// add all the jars that should be included when publishing to maven
artifact(remapJar) {
builtBy remapJar
}
artifact(sourcesJar) {
builtBy remapSourcesJar
}
}
}
// select the repositories you want to publish to
repositories {
// uncomment to publish to the local maven
// mavenLocal()
}
}
+11 -32
View File
@@ -1,41 +1,20 @@
# Done to increase the memory available to gradle.
org.gradle.jvmargs=-Xmx1G
org.gradle.parallel=true
# Fabric Properties
# check these on https://fabricmc.net/use
minecraft_version=1.16_combat-6
yarn_mappings=1.16_combat-6+build.2
loader_version=0.14.21
# check these on https://fabricmc.net/use
minecraft_version=1.16_combat-6
yarn_mappings=1.16_combat-6+build.2
loader_version=0.14.21
# 0.9.3+build.207
# Mod Properties
mod_version = 1.2.1
maven_group = com.nexia
archives_base_name = nexia
mod_version = 1.0.0+dev-metis-api
maven_group = com.nexia
archives_base_name = nexia
# Dependencies
fabric_version= 0.42.0+1.16
plasmid_version=0.4.0
jda_version=5.0.0-beta.20
mixin_extras_version=0.2.0-beta.9
factory_version=0.1.13
gson_version=2.10.1
saveandloadinventories_version=1.16.5-2.4
collective_version=1.16.5-5.50
fantasy_version=0.4.2
sgui_version=0.5.0
autoconfig1u_version=3.3.1
fabric_permissions_api_version=0.2-SNAPSHOT
blfscheduler_version=1.0.0-1.16_combat-6
inventory_merger_version=1.3.1-1.16_combat-6
codelib_version=1.0.3
gato_anticheat_version=1.0.4
# Useless dependencies
json_simple_version=1.1.1
discord_webhooks_version=0.8.4
json_version=20230227
fabric_version= 0.25.0+build.415-1.16
jda_version=5.0.0-beta.12
mixin_extras_version=0.2.0-beta.9
Binary file not shown.
+1 -1
View File
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-7.3-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Vendored
+104 -155
View File
@@ -1,7 +1,7 @@
#!/bin/sh
#!/usr/bin/env sh
#
# Copyright © 2015-2021 the original authors.
# Copyright 2015 the original author or authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -17,113 +17,78 @@
#
##############################################################################
#
# 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/.
#
##
## Gradle start up script for UN*X
##
##############################################################################
# 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
PRG="$0"
# Need this for relative symlinks.
while [ -h "$PRG" ] ; do
ls=`ls -ld "$PRG"`
link=`expr "$ls" : '.*-> \(.*\)$'`
if expr "$link" : '/.*' > /dev/null; then
PRG="$link"
else
PRG=`dirname "$PRG"`"/$link"
fi
done
APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit
SAVED="`pwd`"
cd "`dirname \"$PRG\"`/" >/dev/null
APP_HOME="`pwd -P`"
cd "$SAVED" >/dev/null
APP_NAME="Gradle"
APP_BASE_NAME=${0##*/}
APP_BASE_NAME=`basename "$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
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 ;;
case "`uname`" in
CYGWIN* )
cygwin=true
;;
Darwin* )
darwin=true
;;
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
JAVACMD="$JAVA_HOME/jre/sh/java"
else
JAVACMD=$JAVA_HOME/bin/java
JAVACMD="$JAVA_HOME/bin/java"
fi
if [ ! -x "$JAVACMD" ] ; then
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
@@ -132,7 +97,7 @@ Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
else
JAVACMD=java
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
@@ -140,95 +105,79 @@ 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
if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
MAX_FD_LIMIT=`ulimit -H -n`
if [ $? -eq 0 ] ; then
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
MAX_FD="$MAX_FD_LIMIT"
fi
ulimit -n $MAX_FD
if [ $? -ne 0 ] ; then
warn "Could not set maximum file descriptor limit: $MAX_FD"
fi
else
warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
fi
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 Darwin, add options to specify how the application appears in the dock
if $darwin; then
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
fi
# 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" )
if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
JAVACMD=`cygpath --unix "$JAVACMD"`
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
# We build the pattern for arguments to be converted via cygpath
ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
SEP=""
for dir in $ROOTDIRSRAW ; do
ROOTDIRS="$ROOTDIRS$SEP$dir"
SEP="|"
done
OURCYGPATTERN="(^($ROOTDIRS))"
# Add a user-defined pattern to the cygpath arguments
if [ "$GRADLE_CYGPATTERN" != "" ] ; then
OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
fi
# Now convert the arguments - kludge to limit ourselves to /bin/sh
i=0
for arg in "$@" ; do
CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
else
eval `echo args$i`="\"$arg\""
fi
i=`expr $i + 1`
done
case $i in
0) set -- ;;
1) set -- "$args0" ;;
2) set -- "$args0" "$args1" ;;
3) set -- "$args0" "$args1" "$args2" ;;
4) set -- "$args0" "$args1" "$args2" "$args3" ;;
5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
esac
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.
# Escape application args
save () {
for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
echo " "
}
APP_ARGS=`save "$@"`
set -- \
"-Dorg.gradle.appname=$APP_BASE_NAME" \
-classpath "$CLASSPATH" \
org.gradle.wrapper.GradleWrapperMain \
"$@"
# 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' ' '
)" '"$@"'
# Collect all arguments for the java command, following the shell quoting and substitution rules
eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
exec "$JAVACMD" "$@"
Vendored
+18 -4
View File
@@ -40,7 +40,7 @@ if defined JAVA_HOME goto findJavaFromJavaHome
set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if "%ERRORLEVEL%" == "0" goto execute
if "%ERRORLEVEL%" == "0" goto init
echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
@@ -54,7 +54,7 @@ goto fail
set JAVA_HOME=%JAVA_HOME:"=%
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
if exist "%JAVA_EXE%" goto execute
if exist "%JAVA_EXE%" goto init
echo.
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
@@ -64,14 +64,28 @@ echo location of your Java installation.
goto fail
:init
@rem Get command-line arguments, handling Windows variants
if not "%OS%" == "Windows_NT" goto win9xME_args
:win9xME_args
@rem Slurp the command line arguments.
set CMD_LINE_ARGS=
set _SKIP=2
:win9xME_args_slurp
if "x%~1" == "x" goto execute
set CMD_LINE_ARGS=%*
: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 %*
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
:end
@rem End local scope for the variables with windows NT shell
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
+1
View File
@@ -0,0 +1 @@
DO NOT REMOVE OR MODIFY
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
+17 -29
View File
@@ -1,69 +1,57 @@
package com.nexia.core;
import com.combatreforged.factory.api.FactoryAPI;
import com.combatreforged.factory.api.FactoryServer;
import com.combatreforged.factory.api.entrypoint.FactoryPlugin;
import com.combatreforged.metis.api.MetisAPI;
import com.combatreforged.metis.api.MetisServer;
import com.combatreforged.metis.api.entrypoint.MetisPlugin;
import com.nexia.core.config.ModConfig;
import com.nexia.core.listeners.ListenerHelper;
import com.nexia.core.listeners.*;
import com.nexia.core.loader.CommandLoader;
import com.nexia.core.networking.NetworkingHandler;
import com.nexia.core.utilities.misc.NxFileUtil;
import com.nexia.core.utilities.time.ServerTime;
import me.sargunvohra.mcmods.autoconfig1u.AutoConfig;
import me.sargunvohra.mcmods.autoconfig1u.serializer.GsonConfigSerializer;
import net.fabricmc.api.ModInitializer;
import net.fabricmc.loader.api.FabricLoader;
import net.minecraft.server.MinecraftServer;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
public class Main implements ModInitializer, FactoryPlugin {
public class Main implements ModInitializer, MetisPlugin {
public static MinecraftServer server;
public static ModConfig config;
public static final String MOD_NAME = "Nexia";
public static final String MOD_NAME_SHORT = "Nx";
public static Logger logger = LogManager.getLogger(MOD_NAME);
public static final String modConfigDir = NxFileUtil.makeDir(FabricLoader.getInstance().getConfigDir().toString() + "/nexia");
public NetworkingHandler networkingHandler;
@Override
public void onInitialize() {
AutoConfig.register(ModConfig.class, GsonConfigSerializer::new);
config = AutoConfig.getConfigHolder(ModConfig.class).getConfig();
logger.info("Loading mod...");
logger.info("Registering commands....");
CommandLoader.registerCommands();
logger.info("Registered commands.");
/*
PlayerDetectionEvent.REACH.register((player, entity) -> {
Punishment punishment = PlayerDataManager.get(player).punishment;
punishment.reachOffences++;
punishment.check((ServerPlayer) player);
});
PlayerDetectionEvent.NO_SWING.register((player, entity) -> {
Punishment punishment = PlayerDataManager.get(player).punishment;
punishment.noSwingOffences++;
punishment.check((ServerPlayer) player);
});
*/
networkingHandler = new NetworkingHandler();
}
@Override
@SuppressWarnings("FutureReturnValueIgnored")
public void onFactoryLoad(FactoryAPI api, FactoryServer server) {
Main.logger.info("Loading factory version...");
public void onMetisLoad(MetisAPI api, MetisServer server) {
Main.logger.info("Loading metis version...");
ServerTime.factoryServer = server;
ServerTime.factoryAPI = api;
ServerTime.metisServer = server;
ServerTime.metisAPI = api;
ServerTime.scheduler = api.getScheduler();
Main.logger.info("Registering listeners....");
ListenerHelper.registerListeners();
Main.logger.info("Registered listeners.");
Main.logger.info("Registering metis commands....");
CommandLoader.registerMetisCommands();
Main.logger.info("Registered commands.");
}
}
@@ -1,26 +1,24 @@
package com.nexia.core.commands.player;
import com.combatreforged.metis.api.command.CommandSourceInfo;
import com.combatreforged.metis.api.command.CommandUtils;
import com.mojang.brigadier.CommandDispatcher;
import com.mojang.brigadier.context.CommandContext;
import com.mojang.brigadier.exceptions.CommandSyntaxException;
import com.nexia.core.utilities.chat.ChatFormat;
import com.nexia.core.utilities.player.PlayerUtil;
import com.nexia.discord.Main;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.event.ClickEvent;
import net.kyori.adventure.text.event.HoverEvent;
import net.minecraft.commands.CommandSourceStack;
import net.minecraft.commands.Commands;
public class DiscordCommand {
public static void register(CommandDispatcher<CommandSourceStack> dispatcher, boolean bl) {
dispatcher.register(Commands.literal("discord").executes(DiscordCommand::run));
dispatcher.register(Commands.literal("dc").executes(DiscordCommand::run));
public static void register(CommandDispatcher<CommandSourceInfo> dispatcher) {
dispatcher.register(CommandUtils.literal("discord").executes(DiscordCommand::run));
dispatcher.register(CommandUtils.literal("dc").executes(DiscordCommand::run));
}
public static int run(CommandContext<CommandSourceStack> context) throws CommandSyntaxException {
PlayerUtil.getFactoryPlayer(context.getSource().getPlayerOrException()).sendMessage(
public static int run(CommandContext<CommandSourceInfo> context) throws CommandSyntaxException {
context.getSource().sendMessage(
ChatFormat.nexiaMessage
.append(Component.text("Link to discord: ").color(ChatFormat.normalColor).decoration(ChatFormat.bold, false)
.append(Component.text(com.nexia.discord.Main.config.discordLink).color(ChatFormat.brandColor2)
@@ -1,18 +1,17 @@
package com.nexia.core.commands.player;
import com.combatreforged.metis.api.command.CommandSourceInfo;
import com.combatreforged.metis.api.command.CommandUtils;
import com.mojang.brigadier.CommandDispatcher;
import com.mojang.brigadier.context.CommandContext;
import com.mojang.brigadier.exceptions.CommandSyntaxException;
import com.nexia.core.utilities.chat.ChatFormat;
import com.nexia.core.utilities.player.PlayerUtil;
import net.kyori.adventure.text.Component;
import net.minecraft.commands.CommandSourceStack;
import net.minecraft.commands.Commands;
public class HelpCommand {
public static void register(CommandDispatcher<CommandSourceStack> dispatcher, boolean bl) {
dispatcher.register(Commands.literal("help").executes(HelpCommand::run));
public static void register(CommandDispatcher<CommandSourceInfo> dispatcher) {
dispatcher.register(CommandUtils.literal("help").executes(HelpCommand::run));
}
static String commandSeparator = ": ";
@@ -28,17 +27,13 @@ public class HelpCommand {
"msg" + commandSeparator + "allows you to message other players",
"stats" + commandSeparator + "shows you your stats",
"duel" + commandSeparator + "duel a player that is in the hub (duels)",
"customduel" + commandSeparator + "duel a player that is in the hub, in a custom kit that you made (custom duels)",
"kitlayout" + commandSeparator + "edit your gamemode layout in duels",
"kiteditor" + commandSeparator + "create kits for custom duels",
"queue" + commandSeparator + "queue for a gamemode in duels",
"spectate" + commandSeparator + "spectate a player which is in duels (or ffa if you have supporter rank)",
"buy" + commandSeparator + "buy our ranks to support the server",
"shout" + commandSeparator + "shout a message to the whole server (supporter)",
"sprintfix" + commandSeparator + "toggle the sprint fix"
"shout" + commandSeparator + "shout a message to the whole server (supporter++)"
};
public static int run(CommandContext<CommandSourceStack> context) throws CommandSyntaxException {
public static int run(CommandContext<CommandSourceInfo> context) throws CommandSyntaxException {
Component message = ChatFormat.separatorLine("Commands");
@@ -52,13 +47,11 @@ public class HelpCommand {
.decoration(ChatFormat.strikeThrough, false)
.append(Component.text(" | ").color(ChatFormat.lineColor).decoration(ChatFormat.bold, false).decoration(ChatFormat.strikeThrough, false))
.append(Component.text(commandInfo[1]).color(ChatFormat.brandColor2).decoration(ChatFormat.bold, false).decoration(ChatFormat.strikeThrough, false)));
//message += "\n" + ChatFormat.brandColor1 + "/" + commandInfo[0] + ChatFormat.lineColor + " | " + ChatFormat.brandColor2 + commandInfo[1];
}
message = message.append(Component.text("\n").append(ChatFormat.separatorLine(null)));
PlayerUtil.getFactoryPlayer(context.getSource().getPlayerOrException()).sendMessage(message);
context.getSource().sendMessage(message);
return 1;
}
@@ -1,99 +1,99 @@
package com.nexia.core.commands.player;
import com.combatreforged.metis.api.command.CommandSourceInfo;
import com.combatreforged.metis.api.command.CommandUtils;
import com.combatreforged.metis.api.world.entity.player.Player;
import com.mojang.brigadier.CommandDispatcher;
import com.mojang.brigadier.arguments.StringArgumentType;
import com.mojang.brigadier.context.CommandContext;
import com.mojang.brigadier.exceptions.CommandSyntaxException;
import com.nexia.core.utilities.chat.ChatFormat;
import com.nexia.core.utilities.chat.LegacyChatFormat;
import com.nexia.core.utilities.chat.PlayerMutes;
import com.nexia.core.utilities.player.PlayerData;
import com.nexia.core.utilities.player.PlayerDataManager;
import com.nexia.core.utilities.player.PlayerUtil;
import net.kyori.adventure.text.Component;
import net.minecraft.Util;
import net.minecraft.commands.CommandSourceStack;
import net.minecraft.commands.Commands;
import net.minecraft.commands.arguments.EntityArgument;
import net.minecraft.server.level.ServerPlayer;
public class MessageCommand {
public static void registerMsg(CommandDispatcher<CommandSourceStack> commandDispatcher, boolean bl) {
registerMsg(commandDispatcher, "msg");
registerMsg(commandDispatcher, "message");
registerMsg(commandDispatcher, "tell");
registerMsg(commandDispatcher, "whisper");
}
public static void registerMsg(CommandDispatcher<CommandSourceStack> commandDispatcher, String string) {
commandDispatcher.register(Commands.literal(string)
.then(Commands.argument("player", EntityArgument.player())
.then(Commands.argument("message", StringArgumentType.greedyString())
public static void registerMsg(CommandDispatcher<CommandSourceInfo> commandDispatcher) {
commandDispatcher.register(CommandUtils.literal("msg")
.then(CommandUtils.argument("player", EntityArgument.player())
.then(CommandUtils.argument("message", StringArgumentType.greedyString())
.executes(MessageCommand::msgCommand)
)
));
commandDispatcher.register(CommandUtils.literal("message")
.then(CommandUtils.argument("player", EntityArgument.player())
.then(CommandUtils.argument("message", StringArgumentType.greedyString())
.executes(MessageCommand::msgCommand)
)
)
);
commandDispatcher.register(CommandUtils.literal("tell")
.then(CommandUtils.argument("player", EntityArgument.player())
.then(CommandUtils.argument("message", StringArgumentType.greedyString())
.executes(MessageCommand::msgCommand)
)
)
);
}
public static void registerReply(CommandDispatcher<CommandSourceStack> dispatcher, boolean bl) {
dispatcher.register(Commands.literal("r")
.then(Commands.argument("message", StringArgumentType.greedyString())
public static void registerReply(CommandDispatcher<CommandSourceInfo> dispatcher) {
dispatcher.register(CommandUtils.literal("r")
.then(CommandUtils.argument("message", StringArgumentType.greedyString())
.executes(MessageCommand::replyCommand)
));
dispatcher.register(Commands.literal("reply")
.then(Commands.argument("message", StringArgumentType.greedyString())
dispatcher.register(CommandUtils.literal("reply")
.then(CommandUtils.argument("message", StringArgumentType.greedyString())
.executes(MessageCommand::replyCommand)
)
);
}
private static int msgCommand(CommandContext<CommandSourceStack> context) throws CommandSyntaxException {
ServerPlayer sender = context.getSource().getPlayerOrException();
ServerPlayer receiver = EntityArgument.getPlayer(context, "player");
String message = StringArgumentType.getString(context, "message");
sendMessage(sender, receiver, message);
private static int msgCommand(CommandContext<CommandSourceInfo> context) {
if(!PlayerUtil.checkPlayerInCommand(context)) return 1;
sendMessage(PlayerUtil.getPlayer(context), PlayerUtil.getFactoryPlayer(context.getArgument("player", ServerPlayer.class)), StringArgumentType.getString(context, "message"));
return 1;
}
private static int replyCommand(CommandContext<CommandSourceStack> context) throws CommandSyntaxException {
ServerPlayer sender = context.getSource().getPlayerOrException();
PlayerData senderData = PlayerDataManager.get(sender);
ServerPlayer receiver = PlayerUtil.getFixedPlayer(senderData.lastMessageSender);
private static int replyCommand(CommandContext<CommandSourceInfo> context) {
if(!PlayerUtil.checkPlayerInCommand(context)) return 1;
Player player = PlayerUtil.getPlayer(context);
PlayerData senderData = PlayerDataManager.get(player);
Player receiver = senderData.lastMessageSender;
if (receiver == null) {
sender.sendMessage(LegacyChatFormat.format("{s}Nobody to reply to"), Util.NIL_UUID);
player.sendMessage(Component.text("No one to reply to.").color(ChatFormat.systemColor));
return 1;
}
String message = StringArgumentType.getString(context, "message");
sendMessage(sender, receiver, message);
sendMessage(PlayerUtil.getPlayer(context), receiver, message);
return 1;
}
private static void sendMessage(ServerPlayer sender, ServerPlayer receiver, String message) {
private static void sendMessage(Player sender, Player receiver, String message) {
if (PlayerMutes.muted(sender) || sender == receiver) return;
PlayerUtil.getFactoryPlayer(sender).sendMessage(
Component.text(String.format("To %s", receiver.getScoreboardName())).color(ChatFormat.brandColor2)
sender.sendMessage(
Component.text(String.format("To %s", receiver.getRawName())).color(ChatFormat.brandColor2)
.append(Component.text(" » ").color(ChatFormat.arrowColor)
.append(Component.text(message).color(ChatFormat.brandColor2))
));
PlayerUtil.getFactoryPlayer(receiver).sendMessage(
Component.text(String.format("From %s", sender.getScoreboardName())).color(ChatFormat.brandColor2)
sender.sendMessage(
Component.text(String.format("From %s", sender.getRawName())).color(ChatFormat.brandColor2)
.append(Component.text(" » ").color(ChatFormat.arrowColor)
.append(Component.text(message).color(ChatFormat.brandColor2))
));
PlayerDataManager.get(receiver).lastMessageSender = sender;
}
@@ -1,5 +1,8 @@
package com.nexia.core.commands.player;
import com.combatreforged.metis.api.command.CommandSourceInfo;
import com.combatreforged.metis.api.command.CommandUtils;
import com.combatreforged.metis.api.world.entity.player.Player;
import com.mojang.brigadier.CommandDispatcher;
import com.mojang.brigadier.context.CommandContext;
import com.mojang.brigadier.exceptions.CommandSyntaxException;
@@ -9,29 +12,28 @@ import com.nexia.core.utilities.player.PlayerUtil;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.format.NamedTextColor;
import net.minecraft.commands.CommandSourceStack;
import net.minecraft.commands.Commands;
import net.minecraft.commands.arguments.EntityArgument;
import net.minecraft.server.level.ServerPlayer;
public class PingCommand {
public static void register(CommandDispatcher<CommandSourceStack> dispatcher, boolean bl) {
dispatcher.register(Commands.literal("ping").executes(PingCommand::run)
.then(Commands.argument("player", EntityArgument.player())
.executes(context -> PingCommand.ping(context, EntityArgument.getPlayer(context, "player")))
public static void register(CommandDispatcher<CommandSourceInfo> dispatcher) {
dispatcher.register(CommandUtils.literal("ping").executes(PingCommand::run)
.then(CommandUtils.argument("player", EntityArgument.player())
.executes(context -> PingCommand.ping(context, context.getArgument("player", ServerPlayer.class)))
)
);
dispatcher.register(Commands.literal("latency").executes(PingCommand::run)
.then(Commands.argument("player", EntityArgument.player())
.executes(context -> PingCommand.ping(context, EntityArgument.getPlayer(context, "player")))
dispatcher.register(CommandUtils.literal("latency").executes(PingCommand::run)
.then(CommandUtils.argument("player", EntityArgument.player())
.executes(context -> PingCommand.ping(context, context.getArgument("player", ServerPlayer.class)))
)
);
}
public static int run(CommandContext<CommandSourceStack> context) throws CommandSyntaxException {
ServerPlayer executer = context.getSource().getPlayerOrException();
int ping = executer.latency;
public static int run(CommandContext<CommandSourceInfo> context) throws CommandSyntaxException {
if(!PlayerUtil.checkPlayerInCommand(context)) return 1;
int ping = PlayerUtil.getMinecraftPlayerFromName(((Player) context.getSource().getExecutingEntity()).getRawName()).latency;
PlayerUtil.getFactoryPlayer(executer).sendMessage(
context.getSource().sendMessage(
ChatFormat.nexiaMessage
.append(Component.text("Your ping is ").color(ChatFormat.normalColor).decoration(ChatFormat.bold, false)
.append(Component.text(ping + "ms").color(ChatFormat.brandColor2))
@@ -42,19 +44,10 @@ public class PingCommand {
return ping;
}
public static int ping(CommandContext<CommandSourceStack> context, ServerPlayer player) {
CommandSourceStack cmdExecutor = context.getSource();
ServerPlayer executor;
public static int ping(CommandContext<CommandSourceInfo> context, ServerPlayer player) {
int ping = player.latency;
try {
executor = cmdExecutor.getPlayerOrException();
} catch(Exception ignored){
cmdExecutor.sendSuccess(LegacyChatFormat.format("{b1}The ping of {} is {b2}{}ms{b1}.", player.getScoreboardName(), ping), false);
return ping;
}
PlayerUtil.getFactoryPlayer(executor).sendMessage(
context.getSource().sendMessage(
ChatFormat.nexiaMessage
.append(Component.text("The ping of ").color(ChatFormat.normalColor).decoration(ChatFormat.bold, false))
.append(Component.text(player.getScoreboardName()).color(ChatFormat.brandColor2).decoration(ChatFormat.bold, false))
@@ -12,45 +12,39 @@ import net.minecraft.server.level.ServerPlayer;
public class PlayCommand {
public static void register(CommandDispatcher<CommandSourceStack> dispatcher, boolean bl) {
register(dispatcher, "play");
register(dispatcher, "join");
dispatcher.register(Commands.literal("ffa").executes(PlayCommand::openFFAGui)
.then(Commands.literal("kits").executes(PlayCommand::playKitFFA))
.then(Commands.literal("sky").executes(PlayCommand::playSkyFFA))
.then(Commands.literal("uhc").executes(PlayCommand::playUhcFFA))
.then(Commands.literal("classic").executes(PlayCommand::playNormalFFA))
);
}
private static void register(CommandDispatcher<CommandSourceStack> dispatcher, String string) {
dispatcher.register(Commands.literal(string).executes(PlayCommand::openGUI)
.then(Commands.literal("ffa").executes(PlayCommand::openFFAGui)
dispatcher.register(Commands.literal("play").executes(PlayCommand::openGUI)
.then(Commands.literal("ffa").executes(PlayCommand::openGUI)
.then(Commands.literal("kits").executes(PlayCommand::playKitFFA))
.then(Commands.literal("sky").executes(PlayCommand::playSkyFFA))
.then(Commands.literal("pot").executes(PlayCommand::playPotFFA))
.then(Commands.literal("uhc").executes(PlayCommand::playUhcFFA))
.then(Commands.literal("classic").executes(PlayCommand::playNormalFFA)))
.then(Commands.literal("bedwars").executes(PlayCommand::playBedWars))
.then(Commands.literal("duels").executes(PlayCommand::playDuels))
.then(Commands.literal("skywars").executes(PlayCommand::playSkywars))
.then(Commands.literal("sw").executes(PlayCommand::playSkywars))
.then(Commands.literal("football").executes(PlayCommand::playFootball))
.then(Commands.literal("oitc").executes(PlayCommand::playOITC))
.then(Commands.literal("bw").executes(PlayCommand::playBedWars)));
dispatcher.register(Commands.literal("join").executes(PlayCommand::openGUI)
.then(Commands.literal("ffa").executes(PlayCommand::openGUI)
.then(Commands.literal("kits").executes(PlayCommand::playKitFFA))
.then(Commands.literal("pot").executes(PlayCommand::playPotFFA))
.then(Commands.literal("uhc").executes(PlayCommand::playUhcFFA))
.then(Commands.literal("classic").executes(PlayCommand::playNormalFFA)))
.then(Commands.literal("bedwars").executes(PlayCommand::playBedWars))
.then(Commands.literal("duels").executes(PlayCommand::playDuels))
.then(Commands.literal("skywars").executes(PlayCommand::playSkywars))
.then(Commands.literal("sw").executes(PlayCommand::playSkywars))
.then(Commands.literal("bw").executes(PlayCommand::playBedWars))
.then(Commands.literal("oitc").executes(PlayCommand::playOITC))
);
dispatcher.register(Commands.literal("ffa").executes(PlayCommand::playNormalFFA));
}
private static int openGUI(CommandContext<CommandSourceStack> context) throws CommandSyntaxException{
PlayGUI.openMainGUI(context.getSource().getPlayerOrException());
return 1;
}
private static int openFFAGui(CommandContext<CommandSourceStack> context) throws CommandSyntaxException{
PlayGUI.openMainGUI(context.getSource().getPlayerOrException()).setFFALayout();
return 1;
}
private static int playNormalFFA(CommandContext<CommandSourceStack> context) throws CommandSyntaxException {
ServerPlayer player = context.getSource().getPlayerOrException();
LobbyUtil.sendGame(player, "classic ffa", true, true);
@@ -69,9 +63,9 @@ public class PlayCommand {
return 1;
}
private static int playSkyFFA(CommandContext<CommandSourceStack> context) throws CommandSyntaxException {
private static int playPotFFA(CommandContext<CommandSourceStack> context) throws CommandSyntaxException {
ServerPlayer player = context.getSource().getPlayerOrException();
LobbyUtil.sendGame(player, "sky ffa", true, true);
LobbyUtil.sendGame(player, "pot ffa", true, true);
return 1;
}
@@ -93,12 +87,6 @@ public class PlayCommand {
return 1;
}
private static int playFootball(CommandContext<CommandSourceStack> context) throws CommandSyntaxException {
ServerPlayer player = context.getSource().getPlayerOrException();
LobbyUtil.sendGame(player, "football", true, true);
return 1;
}
private static int playSkywars(CommandContext<CommandSourceStack> context) throws CommandSyntaxException {
ServerPlayer player = context.getSource().getPlayerOrException();
LobbyUtil.sendGame(player, "skywars", true, true);
@@ -1,6 +1,6 @@
package com.nexia.core.commands.player;
import com.combatreforged.factory.api.world.entity.player.Player;
import com.combatreforged.metis.api.world.entity.player.Player;
import com.mojang.brigadier.CommandDispatcher;
import com.mojang.brigadier.arguments.StringArgumentType;
import com.mojang.brigadier.context.CommandContext;
@@ -10,7 +10,6 @@ import com.nexia.core.utilities.http.DiscordWebhook;
import com.nexia.core.utilities.player.PlayerDataManager;
import com.nexia.core.utilities.player.PlayerUtil;
import com.nexia.core.utilities.time.ServerTime;
import com.nexia.discord.Main;
import me.lucko.fabric.api.permissions.v0.Permissions;
import net.kyori.adventure.text.Component;
import net.minecraft.commands.CommandSourceStack;
@@ -19,11 +18,13 @@ import net.minecraft.commands.arguments.EntityArgument;
import net.minecraft.server.level.ServerPlayer;
import java.awt.*;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
public class ReportCommand {
private static boolean sendWebhook(String reporter, String victim, String reason){
DiscordWebhook webhook = new DiscordWebhook(Main.config.reportWebhook);
private static void sendWebhook(String reporter, String victim, String reason){
DiscordWebhook webhook = new DiscordWebhook("https://discord.com/api/webhooks/1076143579585593404/WAvzxt2x1hPOX2UHrklkiCumwVU7xBvUjZ91InBnHKCuuL0nnKPERaEiQxQvgkUxHnZ0");
webhook.addEmbed(new DiscordWebhook.EmbedObject()
.setAuthor((reporter + " reported " + victim), null, null)
.setColor(Color.RED)
@@ -33,13 +34,10 @@ public class ReportCommand {
.addField("Reported Player:", victim, true)
.setThumbnail("https://mc-heads.net/avatar/" + victim + "/64")
.addField("Reason:", reason, false)
);
.setFooter("Nexia • " + DateTimeFormatter.ofPattern("dd/MM/yyyy HH:mm:ss").format(LocalDateTime.now()), "https://notcoded.needs.rest/r/nexia.png"));
try {
webhook.execute();
return true;
} catch (Exception ignored) {
return false;
}
} catch (Exception ignored) { }
}
public static void register(CommandDispatcher<CommandSourceStack> dispatcher, boolean bl) {
dispatcher.register(Commands.literal("report")
@@ -56,7 +54,7 @@ public class ReportCommand {
ServerPlayer mcExecutor = context.getSource().getPlayerOrException();
Player executor = PlayerUtil.getFactoryPlayer(mcExecutor);
if(PlayerDataManager.get(mcExecutor).savedData.isReportBanned()) {
if(PlayerDataManager.get(mcExecutor).isReportBanned) {
executor.sendMessage(
ChatFormat.nexiaMessage
.append(Component.text("You are report banned!").color(ChatFormat.failColor).decoration(ChatFormat.bold, false)
@@ -66,7 +64,7 @@ public class ReportCommand {
return 1;
}
if(mcExecutor.equals(player)){
if(mcExecutor == player){
executor.sendMessage(
ChatFormat.nexiaMessage
.append(Component.text("You cannot report yourself!").color(ChatFormat.failColor).decoration(ChatFormat.bold, false))
@@ -83,22 +81,20 @@ public class ReportCommand {
.append(Component.text(reason).color(ChatFormat.brandColor2))
);
if(!sendWebhook(executor.getRawName(), player.getScoreboardName(), reason)) {
executor.sendMessage(
ChatFormat.nexiaMessage
.append(Component.text("Failed to send webhook! Don't worry, staff who are currently online will see your report!").decoration(ChatFormat.bold, false).color(ChatFormat.normalColor))
);
}
Component staffReportMessage = ChatFormat.nexiaMessage
.append(Component.text(executor.getRawName()).color(ChatFormat.brandColor2).decoration(ChatFormat.bold, false))
.append(Component.text(" has reported ").color(ChatFormat.normalColor).decoration(ChatFormat.bold, false))
.append(Component.text(player.getScoreboardName()).color(ChatFormat.brandColor2).decoration(ChatFormat.bold, false))
.append(Component.text(" for ").color(ChatFormat.normalColor).decoration(ChatFormat.bold, false))
.append(Component.text(reason).color(ChatFormat.brandColor2).decoration(ChatFormat.bold, false));
for (ServerPlayer staffPlayer : ServerTime.minecraftServer.getPlayerList().getPlayers()){
if(Permissions.check(staffPlayer, "nexia.staff.report", 1)) PlayerUtil.getFactoryPlayer(staffPlayer).sendMessage(staffReportMessage);
ServerPlayer staffPlayer;
sendWebhook(executor.getRawName(), player.getScoreboardName(), reason);
for (int i = 0; i != ServerTime.minecraftServer.getPlayerCount(); i++){
staffPlayer = PlayerUtil.getMinecraftPlayerFromName(ServerTime.minecraftServer.getPlayerNames()[i]);
if(Permissions.check(staffPlayer, "nexia.staff.report", 1)) {
PlayerUtil.getFactoryPlayer(staffPlayer).sendMessage(
ChatFormat.nexiaMessage
.append(Component.text(executor.getRawName()).color(ChatFormat.brandColor2).decoration(ChatFormat.bold, false))
.append(Component.text(" has reported ").color(ChatFormat.normalColor).decoration(ChatFormat.bold, false))
.append(Component.text(player.getScoreboardName()).color(ChatFormat.brandColor2).decoration(ChatFormat.bold, false))
.append(Component.text(" for ").color(ChatFormat.normalColor).decoration(ChatFormat.bold, false))
.append(Component.text(reason).color(ChatFormat.brandColor2).decoration(ChatFormat.bold, false))
);
}
}
return 1;
@@ -1,22 +1,31 @@
package com.nexia.core.commands.player;
import com.combatreforged.metis.api.command.CommandSourceInfo;
import com.combatreforged.metis.api.command.CommandUtils;
import com.mojang.brigadier.CommandDispatcher;
import com.mojang.brigadier.context.CommandContext;
import com.mojang.brigadier.exceptions.CommandSyntaxException;
import com.nexia.core.Main;
import com.nexia.core.utilities.chat.ChatFormat;
import com.nexia.core.utilities.player.PlayerUtil;
import net.kyori.adventure.text.Component;
import net.minecraft.commands.CommandSourceStack;
import net.minecraft.commands.Commands;
public class RulesCommand {
public static void register(CommandDispatcher<CommandSourceStack> dispatcher, boolean bl) {
dispatcher.register(Commands.literal("rules").executes(RulesCommand::run));
public static void register(CommandDispatcher<CommandSourceInfo> dispatcher) {
dispatcher.register(CommandUtils.literal("rules").executes(RulesCommand::run));
}
public static int run(CommandContext<CommandSourceStack> context) throws CommandSyntaxException {
private static final String[] rules = {
"No hacking, cheating, griefing or exploiting bugs.",
"Be respectful. No toxicity and/or annoying behaviour.",
"No advertising.",
"No encouraging of illegal activity.",
"No interrupting other player's fights.",
"No spamming/filling up chat.",
"No stalling/combat logging.",
"No bedrock bridging."
};
public static int run(CommandContext<CommandSourceInfo> context) throws CommandSyntaxException {
/*
Apparently this just doesn't work.....
@@ -32,7 +41,7 @@ public class RulesCommand {
.append(Component.text(" ]").color(ChatFormat.lineColor).decoration(ChatFormat.strikeThrough, false))
.append(Component.text(" ").color(ChatFormat.lineColor).decoration(ChatFormat.strikeThrough, true)));
for (int i = 0; i < Main.config.rules.length; i++) {
for (int i = 0; i < rules.length; i++) {
message = message.append(Component.text("\n" + (i+1) + ". ")
.color(ChatFormat.brandColor1)
@@ -42,7 +51,7 @@ public class RulesCommand {
.color(ChatFormat.arrowColor)
.decoration(ChatFormat.bold, false)
.decoration(ChatFormat.strikeThrough, false)
.append(Component.text(Main.config.rules[i])
.append(Component.text(rules[i])
.decoration(ChatFormat.bold, false)
.decoration(ChatFormat.strikeThrough, false)
.color(ChatFormat.normalColor)
@@ -52,7 +61,7 @@ public class RulesCommand {
message = message.append(Component.text("\n").append(ChatFormat.separatorLine(null)));
PlayerUtil.getFactoryPlayer(context.getSource().getPlayerOrException()).sendMessage(message);
context.getSource().sendMessage(message);
return 1;
}
@@ -1,12 +1,11 @@
package com.nexia.core.commands.player;
import com.combatreforged.factory.api.world.entity.player.Player;
import com.combatreforged.metis.api.world.entity.player.Player;
import com.mojang.brigadier.CommandDispatcher;
import com.mojang.brigadier.arguments.StringArgumentType;
import com.mojang.brigadier.context.CommandContext;
import com.mojang.brigadier.exceptions.CommandSyntaxException;
import com.nexia.core.utilities.chat.ChatFormat;
import com.nexia.core.utilities.chat.PlayerMutes;
import com.nexia.core.utilities.player.PlayerUtil;
import com.nexia.core.utilities.time.ServerTime;
import me.lucko.fabric.api.permissions.v0.Permissions;
@@ -47,9 +46,6 @@ public class ShoutCommand {
public static int shout(CommandContext<CommandSourceStack> context, String message) throws CommandSyntaxException {
ServerPlayer executor = context.getSource().getPlayerOrException();
if (PlayerMutes.muted(executor)) return 0;
Player factoryExecutor = PlayerUtil.getFactoryPlayer(executor);
if(ShoutCommand.cooldownTime.get(executor.getUUID()) == null) ShoutCommand.cooldownTime.put(executor.getUUID(), System.currentTimeMillis());
long longTime = ShoutCommand.cooldownTime.get(executor.getUUID());
@@ -68,7 +64,7 @@ public class ShoutCommand {
.append(Component.text( " shouts: " + message).color(ChatFormat.normalColor).decoration(ChatFormat.bold, false)
);
for(Player player : ServerTime.factoryServer.getPlayers()) {
for(Player player : ServerTime.metisServer.getPlayers()) {
player.sendMessage(cmessage);
}
@@ -1,11 +1,10 @@
package com.nexia.core.commands.player;
import com.combatreforged.factory.api.world.entity.player.Player;
import com.combatreforged.factory.api.world.types.Minecraft;
import com.combatreforged.metis.api.world.entity.player.Player;
import com.combatreforged.metis.api.world.types.Minecraft;
import com.mojang.brigadier.CommandDispatcher;
import com.mojang.brigadier.context.CommandContext;
import com.mojang.brigadier.exceptions.CommandSyntaxException;
import com.nexia.core.games.util.LobbyUtil;
import com.nexia.core.games.util.PlayerGameMode;
import com.nexia.core.utilities.chat.ChatFormat;
import com.nexia.core.utilities.player.PlayerData;
@@ -72,11 +71,9 @@ public class SpectateCommand {
);
}
if(LobbyUtil.checkGameModeBan(factoryExecutor, executor, "ffa")) {
return 0;
}
// Check if player is in combat (or full health), then put them in spectator.
if(Math.round(factoryExecutor.getHealth()) < 20) {
if(factoryExecutor.getHealth() < 20) {
factoryExecutor.sendMessage(ChatFormat.nexiaMessage.append(
Component.text("You must be fully healed to go into spectator!").color(ChatFormat.normalColor).decoration(ChatFormat.bold, false))
);
@@ -113,10 +110,6 @@ public class SpectateCommand {
);
}
if(LobbyUtil.checkGameModeBan(factoryExecutor, executor, "ffa")) {
return 0;
}
if(PlayerDataManager.get(executor).gameMode != PlayerGameMode.FFA) {
factoryExecutor.sendMessage(ChatFormat.nexiaMessage.append(
Component.text("This can only be used in FFA!").color(ChatFormat.normalColor).decoration(ChatFormat.bold, false)
@@ -135,7 +128,7 @@ public class SpectateCommand {
// Check if player is in combat (or full health), then put them in spectator.
if(Math.round(factoryExecutor.getHealth()) < 20) {
if(factoryExecutor.getHealth() < 20) {
factoryExecutor.sendMessage(ChatFormat.nexiaMessage.append(
Component.text("You must be fully healed to go into spectator!").color(ChatFormat.normalColor).decoration(ChatFormat.bold, false))
);
@@ -1,28 +0,0 @@
package com.nexia.core.commands.player;
import com.mojang.brigadier.CommandDispatcher;
import com.mojang.brigadier.context.CommandContext;
import com.mojang.brigadier.exceptions.CommandSyntaxException;
import com.nexia.core.utilities.chat.ChatFormat;
import com.nexia.core.utilities.player.PlayerDataManager;
import com.nexia.core.utilities.player.PlayerUtil;
import com.nexia.core.utilities.player.SavedPlayerData;
import net.kyori.adventure.text.Component;
import net.minecraft.commands.CommandSourceStack;
import net.minecraft.commands.Commands;
import net.minecraft.server.level.ServerPlayer;
public class SprintFixCommand {
public static void register(CommandDispatcher<CommandSourceStack> dispatcher, boolean bl) {
dispatcher.register(Commands.literal("sprintfix").executes(SprintFixCommand::run));
}
public static int run(CommandContext<CommandSourceStack> context) throws CommandSyntaxException {
ServerPlayer player = context.getSource().getPlayerOrException();
SavedPlayerData data = PlayerDataManager.get(player).savedData;
PlayerUtil.getFactoryPlayer(player).sendMessage(ChatFormat.nexiaMessage.append(Component.text((data.setSprintFix(!data.isSprintFix()) ? "Enabled" : "Disabled") + " Sprint Fix!").color(ChatFormat.normalColor).decoration(ChatFormat.bold, false)));
return 1;
}
}
@@ -1,6 +1,6 @@
package com.nexia.core.commands.player;
import com.combatreforged.factory.api.world.entity.player.Player;
import com.combatreforged.metis.api.world.entity.player.Player;
import com.mojang.brigadier.CommandDispatcher;
import com.mojang.brigadier.arguments.StringArgumentType;
import com.mojang.brigadier.context.CommandContext;
@@ -15,6 +15,7 @@ import com.nexia.ffa.classic.utilities.player.PlayerDataManager;
import com.nexia.ffa.classic.utilities.player.SavedPlayerData;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.format.NamedTextColor;
import net.kyori.adventure.text.format.TextColor;
import net.minecraft.commands.CommandSourceStack;
import net.minecraft.commands.Commands;
import net.minecraft.commands.SharedSuggestionProvider;
@@ -60,7 +61,6 @@ public class StatsCommand {
int deaths = data.deaths;
int killstreak = data.killstreak;
int bestKillstreak = data.bestKillstreak;
long rating = Math.round(data.rating * 100);
if(executerData.ffaGameMode == FfaGameMode.KITS) {
message = ChatFormat.separatorLine("Kit FFA Stats");
@@ -80,9 +80,9 @@ public class StatsCommand {
bestKillstreak = kData.bestKillstreak;
}
if(executerData.ffaGameMode == FfaGameMode.SKY) {
message = ChatFormat.separatorLine("Sky FFA Stats");
com.nexia.ffa.sky.utilities.player.SavedPlayerData kData = com.nexia.ffa.sky.utilities.player.PlayerDataManager.get(mcPlayer).savedData;
if(executerData.ffaGameMode == FfaGameMode.POT) {
message = ChatFormat.separatorLine("Pot FFA Stats");
com.nexia.ffa.pot.utilities.player.SavedPlayerData kData = com.nexia.ffa.pot.utilities.player.PlayerDataManager.get(mcPlayer).savedData;
kills = kData.kills;
deaths = kData.deaths;
killstreak = kData.killstreak;
@@ -107,17 +107,10 @@ public class StatsCommand {
player.sendMessage(start
.append(Component.text(" Killstreak: ").color(ChatFormat.brandColor2))
.append(Component.text(killstreak).color(ChatFormat.goldColor))
.append(Component.text(killstreak).color(TextColor.fromHexString("#f5bc42")))
.append(Component.text("/").color(ChatFormat.arrowColor))
.append(Component.text(bestKillstreak).color(ChatFormat.goldColor))
.append(Component.text(bestKillstreak).color(TextColor.fromHexString("#f5bc42")))
);
if (executerData.ffaGameMode == FfaGameMode.CLASSIC) {
player.sendMessage(start
.append(Component.text(" Rating: ").color(ChatFormat.brandColor2))
.append(Component.text(rating).color(ChatFormat.goldColor))
);
}
}
if(executerData.gameMode == PlayerGameMode.LOBBY){
@@ -175,26 +168,6 @@ public class StatsCommand {
);
}
if(executerData.gameMode == PlayerGameMode.FOOTBALL){
message = ChatFormat.separatorLine("Football Stats");
com.nexia.minigames.games.football.util.player.SavedPlayerData data = com.nexia.minigames.games.football.util.player.PlayerDataManager.get(mcPlayer).savedData;
player.sendMessage(message);
player.sendMessage(user);
player.sendMessage(start
.append(Component.text(" Wins: ").color(ChatFormat.brandColor2))
.append(Component.text(data.wins).color(ChatFormat.greenColor))
);
player.sendMessage(start
.append(Component.text(" Losses: ").color(ChatFormat.brandColor2))
.append(Component.text(data.loss).color(ChatFormat.failColor))
);
player.sendMessage(start
.append(Component.text(" Goals: ").color(ChatFormat.brandColor2))
.append(Component.text(data.goals).color(ChatFormat.failColor))
);
}
if(executerData.gameMode == PlayerGameMode.SKYWARS){
message = ChatFormat.separatorLine("SkyWars Stats");
com.nexia.minigames.games.skywars.util.player.SavedPlayerData data = com.nexia.minigames.games.skywars.util.player.PlayerDataManager.get(mcPlayer).savedData;
@@ -220,7 +193,7 @@ public class StatsCommand {
public static float calculateKDR(int kills, int deaths){
if(deaths <= 0 || kills <= 0) { return 0; }
if(deaths == 0 || kills == 0) { return 0; }
return Float.parseFloat(new DecimalFormat("#.##").format((float) kills / deaths));
}
@@ -239,7 +212,7 @@ public class StatsCommand {
Component message;
if(gamemode.equalsIgnoreCase("ffa classic") || gamemode.equalsIgnoreCase("kit ffa") || gamemode.equalsIgnoreCase("sky ffa") || gamemode.equalsIgnoreCase("uhc ffa")){
if(gamemode.equalsIgnoreCase("ffa classic") || gamemode.equalsIgnoreCase("kit ffa")){
message = ChatFormat.separatorLine("FFA Classic Stats");
SavedPlayerData data = PlayerDataManager.get(otherPlayer).savedData;
@@ -247,7 +220,6 @@ public class StatsCommand {
int deaths = data.deaths;
int killstreak = data.killstreak;
int bestKillstreak = data.bestKillstreak;
long rating = Math.round(data.rating * 100);
if(gamemode.equalsIgnoreCase("kit ffa")) {
message = ChatFormat.separatorLine("Kit FFA Stats");
@@ -258,9 +230,9 @@ public class StatsCommand {
bestKillstreak = kData.bestKillstreak;
}
if(gamemode.equalsIgnoreCase("sky ffa")) {
message = ChatFormat.separatorLine("Sky FFA Stats");
com.nexia.ffa.sky.utilities.player.SavedPlayerData kData = com.nexia.ffa.sky.utilities.player.PlayerDataManager.get(otherPlayer).savedData;
if(gamemode.equalsIgnoreCase("pot ffa")) {
message = ChatFormat.separatorLine("Pot FFA Stats");
com.nexia.ffa.pot.utilities.player.SavedPlayerData kData = com.nexia.ffa.pot.utilities.player.PlayerDataManager.get(otherPlayer).savedData;
kills = kData.kills;
deaths = kData.deaths;
killstreak = kData.killstreak;
@@ -294,17 +266,10 @@ public class StatsCommand {
player.sendMessage(start
.append(Component.text(" Killstreak: ").color(ChatFormat.brandColor2))
.append(Component.text(killstreak).color(ChatFormat.goldColor))
.append(Component.text(killstreak).color(TextColor.fromHexString("#f5bc42")))
.append(Component.text("/").color(ChatFormat.arrowColor))
.append(Component.text(bestKillstreak).color(ChatFormat.goldColor))
.append(Component.text(bestKillstreak).color(TextColor.fromHexString("#f5bc42")))
);
if(gamemode.equalsIgnoreCase("ffa classic")) {
player.sendMessage(start
.append(Component.text(" Rating: ").color(ChatFormat.brandColor2))
.append(Component.text(rating).color(ChatFormat.goldColor))
);
}
}
if(gamemode.equalsIgnoreCase("duels")){
@@ -362,26 +327,6 @@ public class StatsCommand {
);
}
if(gamemode.equalsIgnoreCase("football")){
message = ChatFormat.separatorLine("Football Stats");
com.nexia.minigames.games.football.util.player.SavedPlayerData data = com.nexia.minigames.games.football.util.player.PlayerDataManager.get(otherPlayer).savedData;
player.sendMessage(message);
player.sendMessage(user);
player.sendMessage(start
.append(Component.text(" Wins: ").color(ChatFormat.brandColor2))
.append(Component.text(data.wins).color(ChatFormat.greenColor))
);
player.sendMessage(start
.append(Component.text(" Losses: ").color(ChatFormat.brandColor2))
.append(Component.text(data.loss).color(ChatFormat.failColor))
);
player.sendMessage(start
.append(Component.text(" Goals: ").color(ChatFormat.brandColor2))
.append(Component.text(data.goals).color(ChatFormat.failColor))
);
}
if(gamemode.equalsIgnoreCase("skywars")){
message = ChatFormat.separatorLine("SkyWars Stats");
com.nexia.minigames.games.skywars.util.player.SavedPlayerData data = com.nexia.minigames.games.skywars.util.player.PlayerDataManager.get(otherPlayer).savedData;
@@ -1,26 +1,41 @@
package com.nexia.core.commands.player.duels;
import com.mojang.brigadier.CommandDispatcher;
import com.mojang.brigadier.arguments.StringArgumentType;
import com.mojang.brigadier.context.CommandContext;
import com.mojang.brigadier.exceptions.CommandSyntaxException;
import com.nexia.core.games.util.PlayerGameMode;
import com.nexia.core.gui.duels.DuelGUI;
import com.nexia.core.utilities.player.PlayerData;
import com.nexia.core.utilities.player.PlayerDataManager;
import com.nexia.minigames.Main;
import com.nexia.minigames.games.duels.DuelGameMode;
import com.nexia.minigames.games.duels.gamemodes.GamemodeHandler;
import net.minecraft.commands.CommandSourceStack;
import net.minecraft.commands.Commands;
import net.minecraft.commands.SharedSuggestionProvider;
import net.minecraft.commands.arguments.EntityArgument;
import net.minecraft.server.level.ServerPlayer;
import org.jetbrains.annotations.Nullable;
public class AcceptDuelCommand {
public static void register(CommandDispatcher<CommandSourceStack> dispatcher, boolean bl) {
register(dispatcher, "acceptduel");
register(dispatcher, "acceptchallenge");
}
dispatcher.register(Commands.literal("acceptduel")
.requires(commandSourceStack -> {
try {
com.nexia.minigames.games.duels.util.player.PlayerData playerData = com.nexia.minigames.games.duels.util.player.PlayerDataManager.get(commandSourceStack.getPlayerOrException());
PlayerData playerData1 = PlayerDataManager.get(commandSourceStack.getPlayerOrException());
return playerData.gameMode == DuelGameMode.LOBBY && playerData1.gameMode == PlayerGameMode.LOBBY;
} catch (Exception ignored) {
}
return false;
})
.then(Commands.argument("player", EntityArgument.player())
.executes(context -> AcceptDuelCommand.accept(context, EntityArgument.getPlayer(context, "player")))
)
);
public static void register(CommandDispatcher<CommandSourceStack> dispatcher, String string) {
dispatcher.register(Commands.literal(string)
dispatcher.register(Commands.literal("acceptchallenge")
.requires(commandSourceStack -> {
try {
com.nexia.minigames.games.duels.util.player.PlayerData playerData = com.nexia.minigames.games.duels.util.player.PlayerDataManager.get(commandSourceStack.getPlayerOrException());
@@ -36,7 +51,6 @@ public class AcceptDuelCommand {
);
}
public static int accept(CommandContext<CommandSourceStack> context, ServerPlayer player) throws CommandSyntaxException {
GamemodeHandler.acceptDuel(context.getSource().getPlayerOrException(), player);
return 1;
@@ -15,12 +15,22 @@ import net.minecraft.server.level.ServerPlayer;
public class DeclineDuelCommand {
public static void register(CommandDispatcher<CommandSourceStack> dispatcher, boolean bl) {
register(dispatcher, "declineduel");
register(dispatcher, "declinechallenge");
}
dispatcher.register(Commands.literal("declineduel")
.requires(commandSourceStack -> {
try {
com.nexia.minigames.games.duels.util.player.PlayerData playerData = com.nexia.minigames.games.duels.util.player.PlayerDataManager.get(commandSourceStack.getPlayerOrException());
PlayerData playerData1 = PlayerDataManager.get(commandSourceStack.getPlayerOrException());
return playerData.gameMode == DuelGameMode.LOBBY && playerData1.gameMode == PlayerGameMode.LOBBY;
} catch (Exception ignored) {
}
return false;
})
.then(Commands.argument("player", EntityArgument.player())
.executes(context -> DeclineDuelCommand.decline(context, EntityArgument.getPlayer(context, "player")))
)
);
public static void register(CommandDispatcher<CommandSourceStack> dispatcher, String string) {
dispatcher.register(Commands.literal(string)
dispatcher.register(Commands.literal("declinechallenge")
.requires(commandSourceStack -> {
try {
com.nexia.minigames.games.duels.util.player.PlayerData playerData = com.nexia.minigames.games.duels.util.player.PlayerDataManager.get(commandSourceStack.getPlayerOrException());
@@ -8,9 +8,10 @@ import com.nexia.core.games.util.PlayerGameMode;
import com.nexia.core.gui.duels.DuelGUI;
import com.nexia.core.utilities.player.PlayerData;
import com.nexia.core.utilities.player.PlayerDataManager;
import com.nexia.minigames.games.duels.DuelGameHandler;
import com.nexia.minigames.games.duels.DuelGameMode;
import com.nexia.minigames.games.duels.gamemodes.GamemodeHandler;
import com.nexia.minigames.games.duels.map.DuelsMap;
import com.nexia.minigames.games.duels.gamemodes.GamemodeHandler;
import net.minecraft.commands.CommandSourceStack;
import net.minecraft.commands.Commands;
import net.minecraft.commands.SharedSuggestionProvider;
@@ -19,14 +20,8 @@ import net.minecraft.server.level.ServerPlayer;
import org.jetbrains.annotations.Nullable;
public class DuelCommand {
public static void register(CommandDispatcher<CommandSourceStack> dispatcher, boolean bl) {
register(dispatcher, "duel");
register(dispatcher, "challenge");
}
public static void register(CommandDispatcher<CommandSourceStack> dispatcher, String string) {
dispatcher.register(Commands.literal(string)
dispatcher.register(Commands.literal("duel")
.requires(commandSourceStack -> {
try {
com.nexia.minigames.games.duels.util.player.PlayerData playerData = com.nexia.minigames.games.duels.util.player.PlayerDataManager.get(commandSourceStack.getPlayerOrException());
@@ -45,6 +40,24 @@ public class DuelCommand {
.suggests(((context, builder) -> SharedSuggestionProvider.suggest((DuelsMap.stringDuelsMaps), builder)))
.executes(context -> DuelCommand.challenge(context, EntityArgument.getPlayer(context, "player"), StringArgumentType.getString(context, "gamemode"), StringArgumentType.getString(context, "map")))
))));
dispatcher.register(Commands.literal("challenge")
.requires(commandSourceStack -> {
try {
com.nexia.minigames.games.duels.util.player.PlayerData playerData = com.nexia.minigames.games.duels.util.player.PlayerDataManager.get(commandSourceStack.getPlayerOrException());
PlayerData playerData1 = PlayerDataManager.get(commandSourceStack.getPlayerOrException());
return playerData.gameMode == DuelGameMode.LOBBY && playerData1.gameMode == PlayerGameMode.LOBBY;
} catch (Exception ignored) {}
return false;
})
.then(Commands.argument("player", EntityArgument.player())
.executes(context -> DuelGUI.openDuelGui(context.getSource().getPlayerOrException(), EntityArgument.getPlayer(context, "player")))
.then(Commands.argument("gamemode", StringArgumentType.string())
.suggests(((context, builder) -> SharedSuggestionProvider.suggest((DuelGameMode.stringDuelGameModes), builder)))
.executes(context -> DuelCommand.challenge(context, EntityArgument.getPlayer(context, "player"), StringArgumentType.getString(context, "gamemode"), null))
.then(Commands.argument("map", StringArgumentType.string())
.suggests(((context, builder) -> SharedSuggestionProvider.suggest((DuelsMap.stringDuelsMaps), builder)))
.executes(context -> DuelCommand.challenge(context, EntityArgument.getPlayer(context, "player"), StringArgumentType.getString(context, "gamemode"), StringArgumentType.getString(context, "map")))
))));
}
public static int challenge(CommandContext<CommandSourceStack> context, ServerPlayer player, String gameMode, @Nullable String map) throws CommandSyntaxException {
@@ -1,126 +0,0 @@
package com.nexia.core.commands.player.duels;
import com.mojang.brigadier.CommandDispatcher;
import com.mojang.brigadier.arguments.StringArgumentType;
import com.mojang.brigadier.context.CommandContext;
import com.mojang.brigadier.exceptions.CommandSyntaxException;
import com.nexia.core.games.util.PlayerGameMode;
import com.nexia.core.utilities.chat.LegacyChatFormat;
import com.nexia.core.utilities.item.InventoryUtil;
import com.nexia.core.utilities.player.PlayerData;
import com.nexia.core.utilities.player.PlayerDataManager;
import com.nexia.core.utilities.time.ServerTime;
import com.nexia.minigames.games.duels.DuelGameHandler;
import com.nexia.minigames.games.duels.DuelGameMode;
import io.github.blumbo.inventorymerger.saving.SavableInventory;
import net.minecraft.Util;
import net.minecraft.commands.CommandSourceStack;
import net.minecraft.commands.Commands;
import net.minecraft.commands.SharedSuggestionProvider;
import net.minecraft.server.level.ServerPlayer;
import org.jetbrains.annotations.NotNull;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
public class KitLayoutCommand {
public static void register(CommandDispatcher<CommandSourceStack> dispatcher, boolean bl) {
dispatcher.register((Commands.literal("kitlayout")
.requires(commandSourceStack -> {
try {
com.nexia.minigames.games.duels.util.player.PlayerData playerData = com.nexia.minigames.games.duels.util.player.PlayerDataManager.get(commandSourceStack.getPlayerOrException());
PlayerData playerData1 = PlayerDataManager.get(commandSourceStack.getPlayerOrException());
return playerData.gameMode == DuelGameMode.LOBBY && playerData1.gameMode == PlayerGameMode.LOBBY;
} catch (Exception ignored) {}
return false;
})
.then(Commands.argument("argument", StringArgumentType.string())
.suggests(((context, builder) -> SharedSuggestionProvider.suggest((new String[]{"save", "edit", "reset"}), builder)))
.executes(context -> run(context, StringArgumentType.getString(context, "argument"), ""))
.then(Commands.argument("inventory", StringArgumentType.string())
.suggests(((context, builder) -> SharedSuggestionProvider.suggest(InventoryUtil.getListOfInventories("duels"), builder)))
.executes(context -> run(context, StringArgumentType.getString(context, "argument"), StringArgumentType.getString(context, "inventory")))
)
)
)
);
}
private static int run(CommandContext<CommandSourceStack> context, @NotNull String argument, @NotNull String inventory) throws CommandSyntaxException {
ServerPlayer player = context.getSource().getPlayerOrException();
if((inventory.trim().isEmpty() || !InventoryUtil.getListOfInventories("duels").contains(inventory.toLowerCase())) && !argument.equalsIgnoreCase("save")) {
context.getSource().sendFailure(LegacyChatFormat.format("Invalid gamemode!"));
return 0;
}
if(argument.equalsIgnoreCase("save")) {
if(com.nexia.minigames.games.duels.util.player.PlayerDataManager.get(player).editingLayout.isEmpty()) {
context.getSource().sendFailure(LegacyChatFormat.format("You aren't editing a layout!"));
return 0;
}
inventory = com.nexia.minigames.games.duels.util.player.PlayerDataManager.get(player).editingLayout;
String path = InventoryUtil.dirpath + File.separator + "duels" + File.separator + "custom" + File.separator + player.getStringUUID() + File.separator + "layout";
Path playerPath = Path.of(path);
File playerDir = playerPath.toFile();
try {
if(!playerDir.exists()) Files.createDirectory(playerPath);
} catch (IOException ignored) { }
SavableInventory savableInventory = new SavableInventory(player.inventory);
String stringInventory = savableInventory.toSave();
try {
String file = path + File.separator + inventory + ".json";
FileWriter fileWriter = new FileWriter(file);
fileWriter.write(stringInventory);
fileWriter.close();
} catch (Exception var6) {
ServerTime.minecraftServer.getCommands().performCommand(player.createCommandSourceStack(), "/hub");
player.sendMessage(LegacyChatFormat.format("{f}Failed to save your inventory as '{}'. Please try again or contact a developer.", inventory), Util.NIL_UUID);
return 0;
}
context.getSource().sendSuccess(LegacyChatFormat.format("{b1}Successfully saved your inventory as '{}'.", inventory), false);
ServerTime.minecraftServer.getCommands().performCommand(player.createCommandSourceStack(), "/hub");
return 1;
}
if (argument.equalsIgnoreCase("edit")) {
if(!com.nexia.minigames.games.duels.util.player.PlayerDataManager.get(player).editingLayout.isEmpty()) {
context.getSource().sendFailure(LegacyChatFormat.format("You are still editing a layout! Save it or run /hub!"));
return 0;
}
DuelGameHandler.loadInventory(player, inventory);
com.nexia.minigames.games.duels.util.player.PlayerDataManager.get(player).editingLayout = inventory;
return 1;
}
if(argument.equalsIgnoreCase("reset")) {
File playerFile = new File(InventoryUtil.dirpath + File.separator + "duels" + File.separator + "custom" + File.separator + player.getStringUUID() + File.separator + "layout" + File.separator + inventory + ".json");
if(playerFile.exists() && playerFile.delete()) {
context.getSource().sendSuccess(LegacyChatFormat.format("{b1}Successfully reset saved layout '{}'!", inventory), false);
} else {
context.getSource().sendFailure(LegacyChatFormat.format("Saved Layout does not exist!"));
}
return 1;
}
context.getSource().sendFailure(LegacyChatFormat.format("Invalid argument!"));
return 1;
}
}
@@ -16,14 +16,9 @@ import net.minecraft.commands.Commands;
import net.minecraft.commands.arguments.EntityArgument;
import net.minecraft.server.level.ServerPlayer;
public class PartyCommand {
public class TeamCommand {
public static void register(CommandDispatcher<CommandSourceStack> dispatcher, boolean bl) {
register(dispatcher, "party");
register(dispatcher, "duelsteam");
}
public static void register(CommandDispatcher<CommandSourceStack> dispatcher, String string) {
dispatcher.register(Commands.literal(string)
dispatcher.register(Commands.literal("party")
.requires(commandSourceStack -> {
try {
com.nexia.minigames.games.duels.util.player.PlayerData playerData = com.nexia.minigames.games.duels.util.player.PlayerDataManager.get(commandSourceStack.getPlayerOrException());
@@ -34,24 +29,54 @@ public class PartyCommand {
return false;
})
.then(Commands.literal("invite")
.then(Commands.argument("player", EntityArgument.player()).executes(context -> PartyCommand.invitePlayer(context, EntityArgument.getPlayer(context, "player"))))
.then(Commands.argument("player", EntityArgument.player()).executes(context -> TeamCommand.invitePlayer(context, EntityArgument.getPlayer(context, "player"))))
)
.then(Commands.literal("promote")
.then(Commands.argument("player", EntityArgument.player()).executes(context -> PartyCommand.promotePlayer(context, EntityArgument.getPlayer(context, "player"))))
.then(Commands.argument("player", EntityArgument.player()).executes(context -> TeamCommand.promotePlayer(context, EntityArgument.getPlayer(context, "player"))))
)
.then(Commands.literal("join")
.then(Commands.argument("player", EntityArgument.player()).executes(context -> PartyCommand.joinTeam(context, EntityArgument.getPlayer(context, "player"))))
.then(Commands.argument("player", EntityArgument.player()).executes(context -> TeamCommand.joinTeam(context, EntityArgument.getPlayer(context, "player"))))
)
.then(Commands.literal("kick")
.then(Commands.argument("player", EntityArgument.player()).executes(context -> PartyCommand.kickPlayer(context, EntityArgument.getPlayer(context, "player"))))
.then(Commands.argument("player", EntityArgument.player()).executes(context -> TeamCommand.kickPlayer(context, EntityArgument.getPlayer(context, "player"))))
)
.then(Commands.literal("decline")
.then(Commands.argument("player", EntityArgument.player()).executes(context -> PartyCommand.declinePlayer(context, EntityArgument.getPlayer(context, "player"))))
.then(Commands.argument("player", EntityArgument.player()).executes(context -> TeamCommand.declinePlayer(context, EntityArgument.getPlayer(context, "player"))))
)
.then(Commands.literal("disband").executes(PartyCommand::disbandTeam))
.then(Commands.literal("create").executes(PartyCommand::createTeam))
.then(Commands.literal("list").executes(PartyCommand::listTeam))
.then(Commands.literal("leave").executes(PartyCommand::leaveTeam))
.then(Commands.literal("disband").executes(TeamCommand::disbandTeam))
.then(Commands.literal("create").executes(TeamCommand::createTeam))
.then(Commands.literal("list").executes(TeamCommand::listTeam))
.then(Commands.literal("leave").executes(TeamCommand::leaveTeam))
);
dispatcher.register(Commands.literal("duelsteam")
.requires(commandSourceStack -> {
try {
com.nexia.minigames.games.duels.util.player.PlayerData playerData = com.nexia.minigames.games.duels.util.player.PlayerDataManager.get(commandSourceStack.getPlayerOrException());
PlayerData playerData1 = PlayerDataManager.get(commandSourceStack.getPlayerOrException());
return playerData.gameMode == DuelGameMode.LOBBY && playerData1.gameMode == PlayerGameMode.LOBBY;
} catch (Exception ignored) {
}
return false;
})
.then(Commands.literal("invite")
.then(Commands.argument("player", EntityArgument.player()).executes(context -> TeamCommand.invitePlayer(context, EntityArgument.getPlayer(context, "player"))))
)
.then(Commands.literal("promote")
.then(Commands.argument("player", EntityArgument.player()).executes(context -> TeamCommand.promotePlayer(context, EntityArgument.getPlayer(context, "player"))))
)
.then(Commands.literal("join")
.then(Commands.argument("player", EntityArgument.player()).executes(context -> TeamCommand.joinTeam(context, EntityArgument.getPlayer(context, "player"))))
)
.then(Commands.literal("kick")
.then(Commands.argument("player", EntityArgument.player()).executes(context -> TeamCommand.kickPlayer(context, EntityArgument.getPlayer(context, "player"))))
)
.then(Commands.literal("decline")
.then(Commands.argument("player", EntityArgument.player()).executes(context -> TeamCommand.declinePlayer(context, EntityArgument.getPlayer(context, "player"))))
)
.then(Commands.literal("disband").executes(TeamCommand::disbandTeam))
.then(Commands.literal("create").executes(TeamCommand::createTeam))
.then(Commands.literal("list").executes(TeamCommand::listTeam))
.then(Commands.literal("leave").executes(TeamCommand::leaveTeam))
);
}
@@ -60,15 +85,15 @@ public class PartyCommand {
com.nexia.minigames.games.duels.util.player.PlayerData data = com.nexia.minigames.games.duels.util.player.PlayerDataManager.get(invitor);
if(data.duelOptions.duelsTeam == null) {
if(data.duelsTeam == null) {
DuelsTeam.createTeam(invitor, false);
}
data.duelOptions.duelsTeam.invitePlayer(invitor, player);
data.duelsTeam.invitePlayer(invitor, player);
return 1;
}
public static int joinTeam(CommandContext<CommandSourceStack> context, ServerPlayer player) throws CommandSyntaxException {
com.nexia.minigames.games.duels.util.player.PlayerDataManager.get(player).duelOptions.duelsTeam.joinTeam(context.getSource().getPlayerOrException());
com.nexia.minigames.games.duels.util.player.PlayerDataManager.get(player).duelsTeam.joinTeam(context.getSource().getPlayerOrException());
return 1;
}
@@ -77,17 +102,17 @@ public class PartyCommand {
com.nexia.minigames.games.duels.util.player.PlayerData data = com.nexia.minigames.games.duels.util.player.PlayerDataManager.get(executor);
if(data.duelOptions.duelsTeam == null) {
if(data.duelsTeam == null) {
PlayerUtil.getFactoryPlayer(executor).sendMessage(Component.text("You aren't in a team!").color(ChatFormat.failColor));
return 1;
}
data.duelOptions.duelsTeam.listTeam(executor);
data.duelsTeam.listTeam(executor);
return 1;
}
public static int declinePlayer(CommandContext<CommandSourceStack> context, ServerPlayer player) throws CommandSyntaxException {
com.nexia.minigames.games.duels.util.player.PlayerDataManager.get(player).duelOptions.duelsTeam.declineTeam(context.getSource().getPlayerOrException());
com.nexia.minigames.games.duels.util.player.PlayerDataManager.get(player).duelsTeam.declineTeam(context.getSource().getPlayerOrException());
return 1;
}
@@ -101,12 +126,12 @@ public class PartyCommand {
com.nexia.minigames.games.duels.util.player.PlayerData data = com.nexia.minigames.games.duels.util.player.PlayerDataManager.get(executor);
if(data.duelOptions.duelsTeam == null) {
if(data.duelsTeam == null) {
PlayerUtil.getFactoryPlayer(executor).sendMessage(Component.text("You aren't in a team!").color(ChatFormat.failColor));
return 1;
}
data.duelOptions.duelsTeam.replaceLeader(executor, player, true);
data.duelsTeam.replaceLeader(executor, player, true);
return 1;
}
@@ -115,12 +140,12 @@ public class PartyCommand {
com.nexia.minigames.games.duels.util.player.PlayerData data = com.nexia.minigames.games.duels.util.player.PlayerDataManager.get(executor);
if(data.duelOptions.duelsTeam == null) {
if(data.duelsTeam == null) {
PlayerUtil.getFactoryPlayer(executor).sendMessage(Component.text("You aren't in a team!").color(ChatFormat.failColor));
return 1;
}
data.duelOptions.duelsTeam.kickPlayer(executor, player);
data.duelsTeam.kickPlayer(executor, player);
return 1;
}
@@ -129,12 +154,12 @@ public class PartyCommand {
com.nexia.minigames.games.duels.util.player.PlayerData data = com.nexia.minigames.games.duels.util.player.PlayerDataManager.get(player);
if(data.duelOptions.duelsTeam == null) {
if(data.duelsTeam == null) {
PlayerUtil.getFactoryPlayer(player).sendMessage(Component.text("You aren't in a team!").color(ChatFormat.failColor));
return 1;
}
com.nexia.minigames.games.duels.util.player.PlayerDataManager.get(player).duelOptions.duelsTeam.disbandTeam(player, true);
com.nexia.minigames.games.duels.util.player.PlayerDataManager.get(player).duelsTeam.disbandTeam(player, true);
return 1;
}
public static int leaveTeam(CommandContext<CommandSourceStack> context) throws CommandSyntaxException {
@@ -142,12 +167,12 @@ public class PartyCommand {
com.nexia.minigames.games.duels.util.player.PlayerData data = com.nexia.minigames.games.duels.util.player.PlayerDataManager.get(player);
if(data.duelOptions.duelsTeam == null) {
if(data.duelsTeam == null) {
PlayerUtil.getFactoryPlayer(player).sendMessage(Component.text("You aren't in a team!").color(ChatFormat.failColor));
return 1;
}
com.nexia.minigames.games.duels.util.player.PlayerDataManager.get(player).duelOptions.duelsTeam.leaveTeam(player, true);
com.nexia.minigames.games.duels.util.player.PlayerDataManager.get(player).duelsTeam.leaveTeam(player, true);
return 1;
}
}
@@ -1,55 +0,0 @@
package com.nexia.core.commands.player.duels.custom;
import com.mojang.brigadier.CommandDispatcher;
import com.mojang.brigadier.arguments.StringArgumentType;
import com.mojang.brigadier.context.CommandContext;
import com.mojang.brigadier.exceptions.CommandSyntaxException;
import com.nexia.core.games.util.PlayerGameMode;
import com.nexia.core.gui.duels.CustomDuelGUI;
import com.nexia.core.utilities.item.InventoryUtil;
import com.nexia.core.utilities.player.PlayerData;
import com.nexia.core.utilities.player.PlayerDataManager;
import com.nexia.minigames.games.duels.DuelGameMode;
import com.nexia.minigames.games.duels.gamemodes.GamemodeHandler;
import com.nexia.minigames.games.duels.map.DuelsMap;
import net.minecraft.commands.CommandSourceStack;
import net.minecraft.commands.Commands;
import net.minecraft.commands.SharedSuggestionProvider;
import net.minecraft.commands.arguments.EntityArgument;
import net.minecraft.server.level.ServerPlayer;
import org.jetbrains.annotations.Nullable;
public class CustomDuelCommand {
public static void register(CommandDispatcher<CommandSourceStack> dispatcher, boolean bl) {
register(dispatcher, "customduel");
register(dispatcher, "customchallenge");
}
public static void register(CommandDispatcher<CommandSourceStack> dispatcher, String string) {
dispatcher.register(Commands.literal(string)
.requires(commandSourceStack -> {
try {
com.nexia.minigames.games.duels.util.player.PlayerData playerData = com.nexia.minigames.games.duels.util.player.PlayerDataManager.get(commandSourceStack.getPlayerOrException());
PlayerData playerData1 = PlayerDataManager.get(commandSourceStack.getPlayerOrException());
return playerData.gameMode == DuelGameMode.LOBBY && playerData1.gameMode == PlayerGameMode.LOBBY;
} catch (Exception ignored) {
}
return false;
})
.then(Commands.argument("player", EntityArgument.player())
.executes(context -> CustomDuelGUI.openDuelGui(context.getSource().getPlayerOrException(), EntityArgument.getPlayer(context, "player")))
.then(Commands.argument("kit", StringArgumentType.string())
.suggests(((context, builder) -> SharedSuggestionProvider.suggest((InventoryUtil.getListOfInventories("duels/custom/" + context.getSource().getPlayerOrException().getStringUUID())), builder)))
.executes(context -> CustomDuelCommand.challenge(context, EntityArgument.getPlayer(context, "player"), StringArgumentType.getString(context, "kit"), null))
.then(Commands.argument("map", StringArgumentType.string())
.suggests(((context, builder) -> SharedSuggestionProvider.suggest((DuelsMap.stringDuelsMaps), builder)))
.executes(context -> CustomDuelCommand.challenge(context, EntityArgument.getPlayer(context, "player"), StringArgumentType.getString(context, "kit"), StringArgumentType.getString(context, "map")))
))));
}
public static int challenge(CommandContext<CommandSourceStack> context, ServerPlayer player, String kit, @Nullable String map) throws CommandSyntaxException {
ServerPlayer executor = context.getSource().getPlayerOrException();
GamemodeHandler.customChallengePlayer(executor, player, kit, DuelsMap.identifyMap(map));
return 1;
}
}
@@ -1,165 +0,0 @@
package com.nexia.core.commands.player.duels.custom;
import com.mojang.brigadier.CommandDispatcher;
import com.mojang.brigadier.arguments.StringArgumentType;
import com.mojang.brigadier.context.CommandContext;
import com.mojang.brigadier.exceptions.CommandSyntaxException;
import com.natamus.collective_fabric.functions.PlayerFunctions;
import com.natamus.collective_fabric.functions.StringFunctions;
import com.nexia.core.games.util.PlayerGameMode;
import com.nexia.core.utilities.chat.LegacyChatFormat;
import com.nexia.core.utilities.item.InventoryUtil;
import com.nexia.core.utilities.player.PlayerData;
import com.nexia.core.utilities.player.PlayerDataManager;
import com.nexia.core.utilities.time.ServerTime;
import com.nexia.minigames.games.duels.DuelGameMode;
import com.nexia.minigames.games.duels.custom.kitroom.kitrooms.CustomKitRoom;
import com.nexia.minigames.games.duels.custom.kitroom.kitrooms.KitRoom;
import com.nexia.minigames.games.duels.custom.kitroom.kitrooms.SmpKitRoom;
import com.nexia.minigames.games.duels.custom.kitroom.kitrooms.VanillaKitRoom;
import net.minecraft.Util;
import net.minecraft.commands.CommandSourceStack;
import net.minecraft.commands.Commands;
import net.minecraft.commands.SharedSuggestionProvider;
import net.minecraft.server.level.ServerPlayer;
import org.apache.commons.lang3.StringUtils;
import org.jetbrains.annotations.NotNull;
import java.io.File;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.Arrays;
import java.util.List;
public class KitEditorCommand {
private static final List<String> slots = Arrays.asList("1", "2", "3", "smp", "vanilla");
public static void register(CommandDispatcher<CommandSourceStack> dispatcher, boolean bl) {
dispatcher.register((Commands.literal("kiteditor")
.requires(commandSourceStack -> {
try {
com.nexia.minigames.games.duels.util.player.PlayerData playerData = com.nexia.minigames.games.duels.util.player.PlayerDataManager.get(commandSourceStack.getPlayerOrException());
PlayerData playerData1 = PlayerDataManager.get(commandSourceStack.getPlayerOrException());
return playerData.gameMode == DuelGameMode.LOBBY && playerData1.gameMode == PlayerGameMode.LOBBY;
} catch (Exception ignored) {}
return false;
})
.then(Commands.argument("argument", StringArgumentType.string())
.suggests(((context, builder) -> SharedSuggestionProvider.suggest((new String[]{"save", "edit", "delete"}), builder)))
.executes(context -> run(context, StringArgumentType.getString(context, "argument"), ""))
.then(Commands.argument("slot", StringArgumentType.string())
.suggests(((context, builder) -> SharedSuggestionProvider.suggest(slots, builder)))
.executes(context -> run(context, StringArgumentType.getString(context, "argument"), StringArgumentType.getString(context, "slot")))
)
)
)
);
}
private static int run(CommandContext<CommandSourceStack> context, @NotNull String argument, String slot) throws CommandSyntaxException {
ServerPlayer player = context.getSource().getPlayerOrException();
if (!slots.contains(slot) && !argument.equalsIgnoreCase("save")) {
context.getSource().sendFailure(LegacyChatFormat.format("Invalid slot!"));
return 0;
}
String inventory = StringUtils.isNumeric(slot) ? "custom_" + slot : slot;
if(argument.equalsIgnoreCase("save")) {
com.nexia.minigames.games.duels.util.player.PlayerData playerData = com.nexia.minigames.games.duels.util.player.PlayerDataManager.get(player);
if(playerData.editingKit.isEmpty() || playerData.kitRoom == null) {
context.getSource().sendFailure(LegacyChatFormat.format("You aren't editing a kit!"));
return 0;
}
inventory = com.nexia.minigames.games.duels.util.player.PlayerDataManager.get(player).editingKit;
String gearstring = PlayerFunctions.getPlayerGearString(player);
Path playerPath = Path.of(InventoryUtil.dirpath + File.separator + "duels" + File.separator + "custom" + File.separator + player.getStringUUID());
File playerDir = playerPath.toFile();
try {
if(!playerDir.exists()) Files.createDirectory(playerPath);
} catch (IOException ignored) { }
KitRoom kitRoom = playerData.kitRoom;
if (StringFunctions.sequenceCount(gearstring, "\n") < 40 || !playerDir.exists()) {
context.getSource().sendFailure(LegacyChatFormat.format("Something went wrong while generating the save file content for your inventory."));
kitRoom.leave();
ServerTime.minecraftServer.getCommands().performCommand(player.createCommandSourceStack(), "/hub");
return 0;
} else if (!InventoryUtil.writeGearStringToFile("duels/custom/" + player.getStringUUID(), inventory, gearstring)) {
context.getSource().sendFailure(LegacyChatFormat.format("Something went wrong while saving the content of your inventory as '{}'.", inventory));
kitRoom.leave();
ServerTime.minecraftServer.getCommands().performCommand(player.createCommandSourceStack(), "/hub");
return 0;
} else {
context.getSource().sendSuccess(LegacyChatFormat.format("{b1}Successfully saved your inventory as '{}'.", inventory),false);
kitRoom.leave();
ServerTime.minecraftServer.getCommands().performCommand(player.createCommandSourceStack(), "/hub");
return 1;
}
}
if (argument.equalsIgnoreCase("edit")) {
if(!com.nexia.minigames.games.duels.util.player.PlayerDataManager.get(player).editingKit.isEmpty()) {
context.getSource().sendFailure(LegacyChatFormat.format("You are still editing a kit! Save it or run /hub!"));
return 0;
}
KitRoom kitRoom;
com.nexia.minigames.games.duels.util.player.PlayerData playerData = com.nexia.minigames.games.duels.util.player.PlayerDataManager.get(player);
switch (slot) {
case "1", "2", "3" -> kitRoom = new CustomKitRoom(player);
case "vanilla" -> kitRoom = new VanillaKitRoom(player);
case "smp" -> kitRoom = new SmpKitRoom(player);
default -> {
player.sendMessage(LegacyChatFormat.formatFail("Something went wrong whilst creating your kit room."), Util.NIL_UUID);
ServerTime.minecraftServer.getCommands().performCommand(player.createCommandSourceStack(), "/hub");
return 0;
}
}
playerData.editingKit = inventory;
playerData.kitRoom = kitRoom;
if(kitRoom.generate()) kitRoom.teleport();
File playerFile = new File(InventoryUtil.dirpath + File.separator + "duels" + File.separator + "custom" + File.separator + player.getStringUUID(), inventory + ".txt");
if(playerFile.exists()) {
InventoryUtil.loadInventory(player, "duels/custom/" + player.getStringUUID(), inventory.toLowerCase());
}
return 1;
}
if(argument.equalsIgnoreCase("delete")) {
File playerFile = new File(InventoryUtil.dirpath + File.separator + "duels" + File.separator + "custom" + File.separator + player.getStringUUID(), inventory + ".txt");
if(playerFile.exists() && playerFile.delete()) {
context.getSource().sendSuccess(LegacyChatFormat.format("{b1}Successfully deleted slot '{}'!", slot), false);
} else {
context.getSource().sendFailure(LegacyChatFormat.format("The saved kit for that slot ({}) does not exist!", slot));
}
return 1;
}
context.getSource().sendFailure(LegacyChatFormat.format("Invalid argument!"));
return 1;
}
}
@@ -0,0 +1,80 @@
package com.nexia.core.commands.player.ffa;
import com.mojang.brigadier.CommandDispatcher;
import com.mojang.brigadier.arguments.StringArgumentType;
import com.mojang.brigadier.context.CommandContext;
import com.mojang.brigadier.exceptions.CommandSyntaxException;
import com.nexia.core.games.util.LobbyUtil;
import com.nexia.core.gui.ffa.SpawnGUI;
import com.nexia.core.utilities.chat.ChatFormat;
import com.nexia.core.utilities.player.PlayerUtil;
import com.nexia.ffa.classic.utilities.FfaClassicUtil;
import net.kyori.adventure.text.Component;
import net.minecraft.commands.CommandSourceStack;
import net.minecraft.commands.Commands;
import net.minecraft.commands.SharedSuggestionProvider;
import net.minecraft.server.level.ServerPlayer;
public class BiomeCommand {
public static void register(CommandDispatcher<CommandSourceStack> dispatcher, boolean bl) {
dispatcher.register(Commands.literal("biome")
.executes(context -> {
ServerPlayer player = context.getSource().getPlayerOrException();
if(!FfaClassicUtil.canGoToSpawn(player)) {
PlayerUtil.getFactoryPlayer(player).sendMessage(Component.text("You must be fully healed to change biomes!").color(ChatFormat.failColor));
return 1;
}
LobbyUtil.sendGame(player, "classic ffa", false, true);
run(context);
return 1;
})
.then(Commands.argument("biome", StringArgumentType.greedyString())
.suggests(((context, builder) -> SharedSuggestionProvider.suggest(SpawnGUI.mapLocations.keySet(), builder)))
.executes(context -> {
ServerPlayer player = context.getSource().getPlayerOrException();
if(!FfaClassicUtil.canGoToSpawn(player)) {
PlayerUtil.getFactoryPlayer(player).sendMessage(Component.text("You must be fully healed to change biomes!").color(ChatFormat.failColor));
return 1;
}
LobbyUtil.sendGame(player, "classic ffa", false, true);
selectedMap(context);
return 1;
})
)
);
dispatcher.register(Commands.literal("spawn")
.executes(context -> {
ServerPlayer player = context.getSource().getPlayerOrException();
if(!FfaClassicUtil.canGoToSpawn(player)) {
PlayerUtil.getFactoryPlayer(player).sendMessage(Component.text("You must be fully healed to change biomes!").color(ChatFormat.failColor));
return 1;
}
LobbyUtil.sendGame(player, "classic ffa", false, true);
run(context);
return 1;
})
.then(Commands.argument("biome", StringArgumentType.string())
.suggests(((context, builder) -> SharedSuggestionProvider.suggest(SpawnGUI.mapLocations.keySet(), builder)))
.executes(context -> {
ServerPlayer player = context.getSource().getPlayerOrException();
if(!FfaClassicUtil.canGoToSpawn(player)) {
PlayerUtil.getFactoryPlayer(player).sendMessage(Component.text("You must be fully healed to change biomes!").color(ChatFormat.failColor));
return 1;
}
LobbyUtil.sendGame(player, "classic ffa", false, true);
selectedMap(context);
return 1;
})
)
);
}
public static void run(CommandContext<CommandSourceStack> context) throws CommandSyntaxException {
ServerPlayer executer = context.getSource().getPlayerOrException();
SpawnGUI.openSpawnGUI(executer);
}
public static void selectedMap(CommandContext<CommandSourceStack> context) throws CommandSyntaxException {
SpawnGUI.teleportPlayer(context.getSource().getPlayerOrException(), StringArgumentType.getString(context, "biome"));
}
}
@@ -6,8 +6,10 @@ import com.mojang.brigadier.context.CommandContext;
import com.mojang.brigadier.exceptions.CommandSyntaxException;
import com.nexia.core.games.util.LobbyUtil;
import com.nexia.core.gui.ffa.KitGUI;
import com.nexia.core.gui.ffa.SpawnGUI;
import com.nexia.core.utilities.chat.ChatFormat;
import com.nexia.core.utilities.player.PlayerUtil;
import com.nexia.ffa.classic.utilities.FfaClassicUtil;
import com.nexia.ffa.kits.FfaKit;
import com.nexia.ffa.kits.utilities.FfaKitsUtil;
import net.kyori.adventure.text.Component;
@@ -3,11 +3,12 @@ package com.nexia.core.commands.staff;
import com.mojang.authlib.GameProfile;
import com.mojang.brigadier.CommandDispatcher;
import com.mojang.brigadier.arguments.StringArgumentType;
import com.mojang.brigadier.exceptions.CommandSyntaxException;
import com.nexia.core.Main;
import com.nexia.core.utilities.chat.ChatFormat;
import com.nexia.core.utilities.chat.LegacyChatFormat;
import com.nexia.core.utilities.player.PlayerUtil;
import com.nexia.core.utilities.time.ServerTime;
import me.lucko.fabric.api.permissions.v0.Permissions;
import net.kyori.adventure.text.Component;
import net.minecraft.commands.CommandSourceStack;
import net.minecraft.commands.Commands;
@@ -19,11 +20,12 @@ import net.minecraft.server.players.UserBanList;
import net.minecraft.server.players.UserBanListEntry;
import java.util.Collection;
import java.util.Date;
public class BanCommand {
public static void register(CommandDispatcher<CommandSourceStack> dispatcher, boolean bl) {
dispatcher.register(Commands.literal("ban")
.requires(commandSourceStack -> Permissions.check(commandSourceStack, "nexia.staff.ban", 3))
.requires(commandSourceStack -> PlayerUtil.hasPermission(commandSourceStack, "nexia.staff.ban", 3))
.then(Commands.argument("player", GameProfileArgument.gameProfile())
.executes(context -> BanCommand.ban(context.getSource(), GameProfileArgument.getGameProfiles(context, "player"), "No reason specified."))
.then(Commands.argument("reason", StringArgumentType.greedyString())
@@ -46,7 +48,7 @@ public class BanCommand {
if (!userBanList.isBanned(gameProfile)) {
ServerPlayer serverPlayer = ServerTime.minecraftServer.getPlayerList().getPlayer(gameProfile.getId());
UserBanListEntry userBanListEntry = new UserBanListEntry(gameProfile, null, context.getTextName(), null, reason);
UserBanListEntry userBanListEntry = new UserBanListEntry(gameProfile, (Date) null, context.getTextName(), (Date) null, reason);
userBanList.add(userBanListEntry);
++i;
if(player != null){
@@ -1,52 +0,0 @@
package com.nexia.core.commands.staff;
import com.mojang.brigadier.CommandDispatcher;
import com.mojang.brigadier.context.CommandContext;
import com.mojang.brigadier.exceptions.CommandSyntaxException;
import com.nexia.core.utilities.time.ServerTime;
import me.lucko.fabric.api.permissions.v0.Permissions;
import net.minecraft.commands.CommandSourceStack;
import net.minecraft.commands.Commands;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.phys.Vec3;
import java.util.List;
import java.util.concurrent.atomic.AtomicReference;
public class DetectCommand {
public static final boolean enabled = false;
public static void register(CommandDispatcher<CommandSourceStack> dispatcher, boolean bl) {
if(!enabled) return;
dispatcher.register(Commands.literal("detect")
.requires(commandSourceStack -> Permissions.check(commandSourceStack, "nexia.dev.detect", 4))
.executes(DetectCommand::run)
);
}
public static int run(CommandContext<CommandSourceStack> context) throws CommandSyntaxException {
if(!enabled) return 0;
detect(context.getSource().getPlayerOrException());
return 1;
}
public static void detect(ServerPlayer attacker) {
String botName = ".bot";
List<Player> playersNearby = attacker.level.getEntitiesOfClass(ServerPlayer.class, attacker.getBoundingBox().inflate(12, 0.25, 12));
Vec3 eyePos = attacker.getEyePosition(1);
AtomicReference<Vec3> nearestPosition = new AtomicReference<>();
playersNearby.forEach(player -> {
Vec3 currentPos = player.getBoundingBox().getNearestPointTo(eyePos);
if(nearestPosition.get() == null || nearestPosition.get().distanceToSqr(eyePos) > currentPos.distanceToSqr(eyePos))
nearestPosition.set(currentPos);
});
if(nearestPosition.get() != null) {
Vec3 nearestPos = nearestPosition.get();
ServerTime.factoryServer.runCommand("/player " + botName + " look at " + nearestPos.x + " " + nearestPos.y + " " + nearestPos.z, 4, false);
}
}
}
@@ -1,83 +0,0 @@
package com.nexia.core.commands.staff;
import com.combatreforged.factory.api.world.entity.player.Player;
import com.mojang.brigadier.CommandDispatcher;
import com.mojang.brigadier.arguments.StringArgumentType;
import com.nexia.core.games.util.PlayerGameMode;
import com.nexia.core.utilities.chat.ChatFormat;
import com.nexia.core.utilities.chat.LegacyChatFormat;
import com.nexia.core.utilities.player.BanHandler;
import com.nexia.core.utilities.player.GamemodeBanHandler;
import com.nexia.core.utilities.player.PlayerUtil;
import me.lucko.fabric.api.permissions.v0.Permissions;
import net.kyori.adventure.text.Component;
import net.minecraft.commands.CommandSourceStack;
import net.minecraft.commands.Commands;
import net.minecraft.commands.SharedSuggestionProvider;
import net.minecraft.commands.arguments.EntityArgument;
import net.minecraft.server.level.ServerPlayer;
public class GamemodeBanCommand {
public static void register(CommandDispatcher<CommandSourceStack> dispatcher, boolean bl) {
dispatcher.register(Commands.literal("gamemodeban")
.requires(commandSourceStack -> Permissions.check(commandSourceStack, "nexia.staff.ban", 3))
.then(Commands.argument("player", EntityArgument.player())
.then(Commands.argument("gamemode", StringArgumentType.string())
.suggests(((context, builder) -> SharedSuggestionProvider.suggest((PlayerGameMode.stringPlayerGameModes), builder)))
.then(Commands.argument("duration", StringArgumentType.word())
.then(Commands.argument("reason", StringArgumentType.greedyString())
.executes(context -> GamemodeBanCommand.ban(context.getSource(), EntityArgument.getPlayer(context, "player"), StringArgumentType.getString(context, "gamemode"), StringArgumentType.getString(context, "reason"), StringArgumentType.getString(context, "duration"))))
)
)
));
}
public static int ban(CommandSourceStack sender, ServerPlayer player, String stringGameMode, String reason, String durationArg) {
ServerPlayer mcExecutor = null;
Player executor = null;
try {
mcExecutor = sender.getPlayerOrException();
} catch (Exception ignored){ }
if(mcExecutor != null) {
executor = PlayerUtil.getFactoryPlayer(mcExecutor);
}
PlayerGameMode gameMode = PlayerGameMode.identifyGamemode(stringGameMode);
if(gameMode == null) {
if(executor != null) {
executor.sendMessage(
ChatFormat.nexiaMessage
.append(Component.text("Invalid gamemode!").color(ChatFormat.normalColor).decoration(ChatFormat.bold, false))
);
} else {
sender.sendFailure(LegacyChatFormat.format("{f}Invalid gamemode!"));
}
return 1;
}
int durationInSeconds;
try {
durationInSeconds = BanHandler.parseTimeArg(durationArg);
} catch (Exception e) {
if (executor != null) {
executor.sendMessage(
ChatFormat.nexiaMessage
.append(Component.text("Invalid duration. Examples: ").color(ChatFormat.normalColor).decoration(ChatFormat.bold, false))
.append(Component.text("1s / 2m / 3h / 4d / 5w").color(ChatFormat.failColor).decoration(ChatFormat.bold, false))
);
} else {
sender.sendFailure(LegacyChatFormat.format("{f}Invalid duration. Examples: 1s / 2m / 3h / 4d / 5w"));
}
return 1;
}
GamemodeBanHandler.tryGamemodeBan(sender, player, gameMode, durationInSeconds, reason);
return 1;
}
}
@@ -6,7 +6,6 @@ import com.mojang.brigadier.exceptions.CommandSyntaxException;
import com.nexia.core.utilities.chat.ChatFormat;
import com.nexia.core.utilities.chat.LegacyChatFormat;
import com.nexia.core.utilities.player.PlayerUtil;
import me.lucko.fabric.api.permissions.v0.Permissions;
import net.kyori.adventure.text.Component;
import net.minecraft.commands.CommandSourceStack;
import net.minecraft.commands.Commands;
@@ -16,7 +15,7 @@ import net.minecraft.server.level.ServerPlayer;
public class HealCommand {
public static void register(CommandDispatcher<CommandSourceStack> dispatcher, boolean bl) {
dispatcher.register(Commands.literal("heal").executes(HealCommand::run)
.requires(commandSourceStack -> Permissions.check(commandSourceStack, "nexia.staff.heal", 1))
.requires(commandSourceStack -> PlayerUtil.hasPermission(commandSourceStack, "nexia.staff.heal", 1))
.then(Commands.argument("player", EntityArgument.player())
.executes(context -> HealCommand.heal(context, EntityArgument.getPlayer(context, "player")))
)
@@ -1,46 +0,0 @@
package com.nexia.core.commands.staff;
import com.mojang.brigadier.CommandDispatcher;
import com.mojang.brigadier.arguments.StringArgumentType;
import com.mojang.brigadier.context.CommandContext;
import com.nexia.core.utilities.chat.LegacyChatFormat;
import com.nexia.core.utilities.item.InventoryUtil;
import me.lucko.fabric.api.permissions.v0.Permissions;
import net.minecraft.commands.CommandSourceStack;
import net.minecraft.commands.Commands;
import net.minecraft.commands.SharedSuggestionProvider;
import java.io.File;
import java.util.Objects;
public class ListInventoriesCommand {
public static void register(CommandDispatcher<CommandSourceStack> dispatcher, boolean bl) {
dispatcher.register((Commands.literal("listinventories")
.requires(commandSourceStack -> {
try {
return Permissions.check(commandSourceStack, "nexia.inventory.list", 4);
} catch (Exception ignored) {
return false;
}
})
.then(Commands.argument("type", StringArgumentType.string())
.suggests(((context, builder) -> SharedSuggestionProvider.suggest((Objects.requireNonNull(new File(InventoryUtil.dirpath).list())), builder)))
.executes(ListInventoriesCommand::run)
)
));
}
private static int run(CommandContext<CommandSourceStack> context){
String type = StringArgumentType.getString(context, "type");
if(type.trim().isEmpty()) {
context.getSource().sendFailure(LegacyChatFormat.format("Empty type!"));
return 0;
}
context.getSource().sendSuccess(LegacyChatFormat.format("{b1}Saved inventories: {b2}{}{b1}.", InventoryUtil.getListOfInventoriesString(type)), false);
return 1;
}
}
@@ -1,13 +1,13 @@
package com.nexia.core.commands.staff;
import com.combatreforged.factory.api.world.entity.player.Player;
import com.combatreforged.metis.api.world.entity.player.Player;
import com.mojang.brigadier.CommandDispatcher;
import com.mojang.brigadier.arguments.StringArgumentType;
import com.mojang.brigadier.context.CommandContext;
import com.nexia.core.utilities.chat.ChatFormat;
import com.nexia.core.utilities.player.PlayerUtil;
import com.nexia.core.utilities.time.ServerTime;
import me.lucko.fabric.api.permissions.v0.Permissions;
import com.nexia.ffa.classic.utilities.FfaAreas;
import net.kyori.adventure.text.Component;
import net.minecraft.commands.CommandSourceStack;
import net.minecraft.commands.Commands;
@@ -19,21 +19,17 @@ import net.minecraft.server.level.ServerLevel;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.world.Difficulty;
import net.minecraft.world.level.GameRules;
import net.minecraft.world.level.biome.Biomes;
import net.minecraft.world.level.dimension.DimensionType;
import org.apache.commons.io.FileUtils;
import xyz.nucleoid.fantasy.RuntimeWorldConfig;
import java.io.File;
import static com.nexia.core.utilities.world.WorldUtil.getChunkGenerator;
public class MapCommand {
public static void register(CommandDispatcher<CommandSourceStack> dispatcher, boolean bl) {
dispatcher.register((Commands.literal("map")
.requires(commandSourceStack -> {
try {
return Permissions.check(commandSourceStack, "nexia.staff.map", 2);
return PlayerUtil.hasPermission(commandSourceStack, "nexia.staff.map", 2);
} catch (Exception ignored) {
return false;
}
@@ -60,7 +56,7 @@ public class MapCommand {
String type = StringArgumentType.getString(context, "type");
String map = StringArgumentType.getString(context, "map");
if(map.trim().isEmpty() || type.trim().isEmpty()) {
if(ChatFormat.hasWhiteSpacesOrSpaces(map) || ChatFormat.hasWhiteSpacesOrSpaces(type)) {
if(player != null) {
player.sendMessage(
ChatFormat.nexiaMessage
@@ -78,8 +74,8 @@ public class MapCommand {
ServerLevel level = ServerTime.fantasy.getOrOpenPersistentWorld(ResourceKey.create(Registry.DIMENSION_REGISTRY, new ResourceLocation(mapname[0], mapname[1])).location(), (
new RuntimeWorldConfig()
.setDimensionType(DimensionType.OVERWORLD_LOCATION)
.setGenerator(getChunkGenerator(Biomes.THE_VOID))
.setDimensionType(FfaAreas.ffaWorld.dimensionType())
.setGenerator(FfaAreas.ffaWorld.getChunkSource().getGenerator())
.setDifficulty(Difficulty.HARD)
.setGameRule(GameRules.RULE_KEEPINVENTORY, false)
.setGameRule(GameRules.RULE_MOBGRIEFING, false)
@@ -9,7 +9,6 @@ import com.nexia.core.utilities.chat.ChatFormat;
import com.nexia.core.utilities.chat.LegacyChatFormat;
import com.nexia.core.utilities.chat.PlayerMutes;
import com.nexia.core.utilities.player.PlayerUtil;
import me.lucko.fabric.api.permissions.v0.Permissions;
import net.kyori.adventure.text.Component;
import net.minecraft.commands.CommandSourceStack;
import net.minecraft.commands.Commands;
@@ -22,7 +21,7 @@ public class MuteCommand {
public static void register(CommandDispatcher<CommandSourceStack> dispatcher, boolean bl) {
dispatcher.register(Commands.literal("mute")
.requires(commandSourceStack -> Permissions.check(commandSourceStack, "nexia.staff.mute", 1))
.requires(commandSourceStack -> PlayerUtil.hasPermission(commandSourceStack, "nexia.staff.mute", 1))
.then(Commands.argument("player", EntityArgument.player())
.then(Commands.argument("duration", StringArgumentType.word())
.executes(context -> MuteCommand.mute(context, StringArgumentType.getString(context, "duration"), "No reason specified."))
@@ -42,20 +41,27 @@ public class MuteCommand {
CommandSourceStack sender = context.getSource();
ServerPlayer muted = EntityArgument.getPlayer(context, "player");
ServerPlayer player;
int durationInSeconds;
try {
durationInSeconds = parseTimeArg(durationArg);
} catch (Exception e) {
PlayerUtil.safeSendMessage(sender, LegacyChatFormat.format("{f}Invalid duration. Examples: 1s / 2m / 3h / 4d / 5w"),
ChatFormat.nexiaMessage
.append(Component.text("Invalid duration. Examples: ").color(ChatFormat.normalColor).decoration(ChatFormat.bold, false))
.append(Component.text("1s / 2m / 3h / 4d / 5w").color(ChatFormat.failColor).decoration(ChatFormat.bold, false)),false);
try {
player = sender.getPlayerOrException();
PlayerUtil.getFactoryPlayer(player).sendMessage(
ChatFormat.nexiaMessage
.append(Component.text("Invalid duration. Examples: ").color(ChatFormat.normalColor).decoration(ChatFormat.bold, false))
.append(Component.text("1s / 2m / 3h").color(ChatFormat.failColor).decoration(ChatFormat.bold, false))
);
} catch(Exception ignored) {
sender.sendFailure(LegacyChatFormat.format("{f}Invalid duration. Examples: 1s / 2m / 3h"));
}
return 1;
}
PlayerMutes.mute(sender, muted, durationInSeconds, reason);
PlayerMutes.mute(sender, muted, durationInSeconds * 1000, reason);
return 1;
}
@@ -78,8 +84,6 @@ public class MuteCommand {
units.put("s", 1);
units.put("m", 60);
units.put("h", 3600);
units.put("d", 86400);
units.put("w", 604800);
}
}
@@ -1,14 +1,15 @@
package com.nexia.core.commands.staff;
import com.combatreforged.factory.api.world.entity.player.Player;
import com.combatreforged.metis.api.world.entity.player.Player;
import com.mojang.brigadier.Command;
import com.mojang.brigadier.CommandDispatcher;
import com.mojang.brigadier.arguments.StringArgumentType;
import com.mojang.brigadier.context.CommandContext;
import com.nexia.core.Main;
import com.nexia.core.utilities.chat.ChatFormat;
import com.nexia.core.utilities.chat.LegacyChatFormat;
import com.nexia.core.utilities.player.PlayerUtil;
import com.nexia.core.utilities.ranks.NexiaRank;
import me.lucko.fabric.api.permissions.v0.Permissions;
import com.nexia.core.utilities.time.ServerTime;
import net.kyori.adventure.text.Component;
import net.minecraft.commands.CommandSourceStack;
import net.minecraft.commands.Commands;
@@ -16,68 +17,68 @@ import net.minecraft.commands.SharedSuggestionProvider;
import net.minecraft.commands.arguments.EntityArgument;
import net.minecraft.server.level.ServerPlayer;
import java.util.ArrayList;
public class RankCommand {
public static void register(CommandDispatcher<CommandSourceStack> dispatcher, boolean bl) {
ArrayList<String> arrayListRank = new ArrayList<>();
NexiaRank.ranks.forEach(rank -> arrayListRank.add(rank.id));
dispatcher.register(Commands.literal("rank")
.requires(commandSourceStack -> Permissions.check(commandSourceStack, "nexia.staff.rank"))
.requires(commandSourceStack -> PlayerUtil.hasPermission(commandSourceStack, "nexia.staff.rank", 4))
.then(Commands.argument("player", EntityArgument.player())
.then(Commands.argument("rank", StringArgumentType.string())
.suggests(((context, builder) -> SharedSuggestionProvider.suggest((arrayListRank), builder)))
.suggests(((context, builder) -> SharedSuggestionProvider.suggest((Main.config.ranks), builder)))
.executes(context -> RankCommand.give(context, EntityArgument.getPlayer(context, "player"), StringArgumentType.getString(context, "rank")))))
);
}
public static int give(CommandContext<CommandSourceStack> context, ServerPlayer player, String rank) {
CommandSourceStack executor = context.getSource();
CommandSourceStack executer = context.getSource();
Player factoryExecutor = null;
Player otherFactoryPlayer = PlayerUtil.getFactoryPlayer(player);
try {
factoryExecutor = PlayerUtil.getFactoryPlayer(context.getSource().getPlayerOrException());
} catch(Exception ignored) { }
NexiaRank nexiaRank = NexiaRank.identifyRank(rank);
if(nexiaRank == null) {
if(factoryExecutor != null){
factoryExecutor.sendMessage(
for(int i = 0; i < 10; i++){
if(rank.equalsIgnoreCase(Main.config.ranks[i])){
if(factoryExecutor != null){
factoryExecutor.sendMessage(
ChatFormat.nexiaMessage
.append(Component.text("You have set the rank of ").color(ChatFormat.normalColor).decoration(ChatFormat.bold, false))
.append(Component.text(otherFactoryPlayer.getRawName()).color(ChatFormat.brandColor2).decoration(ChatFormat.bold, false))
.append(Component.text(" to ").color(ChatFormat.normalColor).decoration(ChatFormat.bold, false))
.append(Component.text(Main.config.ranks[i]).color(ChatFormat.brandColor2).decoration(ChatFormat.bold, true).decoration(ChatFormat.bold, false))
.append(Component.text(".").color(ChatFormat.brandColor2).decoration(ChatFormat.bold, false).decoration(ChatFormat.bold, false))
);
} else {
executer.sendSuccess(LegacyChatFormat.format("{b1}You have set the rank of {b2}{} {b1}to: {b2}{b}{}{b1}.", otherFactoryPlayer.getRawName(), Main.config.ranks[i]), false);
}
if(rank.equalsIgnoreCase("pro") || rank.equalsIgnoreCase("god")){
ServerTime.metisServer.runCommand("/staffprefix add " + otherFactoryPlayer.getRawName() + " " + rank, 3, true);
ServerTime.metisServer.runCommand("/staffprefix set " + otherFactoryPlayer.getRawName() + " " + rank, 3, true);
return Command.SINGLE_SUCCESS;
}
otherFactoryPlayer.sendMessage(
ChatFormat.nexiaMessage
.append(Component.text("Invalid rank!").color(ChatFormat.normalColor).decoration(ChatFormat.bold, false))
.append(Component.text("Your rank has been set to: ").color(ChatFormat.normalColor).decoration(ChatFormat.bold, false))
.append(Component.text(Main.config.ranks[i]).color(ChatFormat.brandColor2).decoration(ChatFormat.bold, true))
.append(Component.text(".").color(ChatFormat.normalColor).decoration(ChatFormat.bold, false))
);
} else {
executor.sendSuccess(LegacyChatFormat.format("{b1}Invalid rank!"), false);
for (int i2 = 0; i2 < 9; i2++) {
otherFactoryPlayer.removeTag(Main.config.ranks[i2]);
}
ServerTime.metisServer.runCommand(String.format("/lp user %s parent set %s", otherFactoryPlayer.getRawName(), Main.config.ranks[i]));
otherFactoryPlayer.addTag(Main.config.ranks[i]);
}
return 0;
}
if(factoryExecutor != null){
factoryExecutor.sendMessage(
ChatFormat.nexiaMessage
.append(Component.text("You have set the rank of ").color(ChatFormat.normalColor).decoration(ChatFormat.bold, false))
.append(Component.text(otherFactoryPlayer.getRawName()).color(ChatFormat.brandColor2).decoration(ChatFormat.bold, false))
.append(Component.text(" to ").color(ChatFormat.normalColor).decoration(ChatFormat.bold, false))
.append(Component.text(nexiaRank.name).color(ChatFormat.brandColor2).decoration(ChatFormat.bold, true).decoration(ChatFormat.bold, false))
.append(Component.text(".").color(ChatFormat.brandColor2).decoration(ChatFormat.bold, false).decoration(ChatFormat.bold, false))
);
} else {
executor.sendSuccess(LegacyChatFormat.format("{b1}You have set the rank of {b2}{} {b1}to: {b2}{b}{}{b1}.", otherFactoryPlayer.getRawName(), nexiaRank.name), false);
}
otherFactoryPlayer.sendMessage(
ChatFormat.nexiaMessage
.append(Component.text("Your rank has been set to: ").color(ChatFormat.normalColor).decoration(ChatFormat.bold, false))
.append(Component.text(nexiaRank.name).color(ChatFormat.brandColor2).decoration(ChatFormat.bold, true))
.append(Component.text(".").color(ChatFormat.normalColor).decoration(ChatFormat.bold, false))
);
NexiaRank.setRank(nexiaRank, player);
return 1;
}
}
}
@@ -1,14 +1,14 @@
package com.nexia.core.commands.staff;
import com.combatreforged.factory.api.world.entity.player.Player;
import com.combatreforged.metis.api.world.entity.player.Player;
import com.mojang.brigadier.Command;
import com.mojang.brigadier.CommandDispatcher;
import com.mojang.brigadier.arguments.StringArgumentType;
import com.nexia.core.Main;
import com.nexia.core.utilities.chat.ChatFormat;
import com.nexia.core.utilities.chat.LegacyChatFormat;
import com.nexia.core.utilities.player.PlayerUtil;
import com.nexia.core.utilities.ranks.NexiaRank;
import me.lucko.fabric.api.permissions.v0.Permissions;
import com.nexia.core.utilities.time.ServerTime;
import net.kyori.adventure.text.Component;
import net.minecraft.commands.CommandSourceStack;
import net.minecraft.commands.Commands;
@@ -16,21 +16,16 @@ import net.minecraft.commands.SharedSuggestionProvider;
import net.minecraft.commands.arguments.EntityArgument;
import net.minecraft.server.level.ServerPlayer;
import java.util.ArrayList;
public class StaffPrefixCommand {
public static void register(CommandDispatcher<CommandSourceStack> dispatcher, boolean bl) {
ArrayList<String> ranks = new ArrayList<>();
NexiaRank.ranks.forEach(rank -> ranks.add(rank.id));
dispatcher.register(Commands.literal("staffprefix")
.requires(commandSourceStack -> Permissions.check(commandSourceStack, "nexia.staff.prefix"))
.requires(commandSourceStack -> PlayerUtil.hasPermission(commandSourceStack, "nexia.staff.prefix", 3))
.then(Commands.argument("type", StringArgumentType.string())
.suggests(((context, builder) -> SharedSuggestionProvider.suggest((new String[]{"set", "add", "remove"}), builder)))
.then(Commands.argument("player", EntityArgument.player())
.then(Commands.argument("prefix", StringArgumentType.string())
.suggests(((context, builder) -> SharedSuggestionProvider.suggest((ranks), builder)))
.suggests(((context, builder) -> SharedSuggestionProvider.suggest((Main.config.ranks), builder)))
.executes(context -> {
CommandSourceStack executor = context.getSource();
@@ -38,7 +33,7 @@ public class StaffPrefixCommand {
String type = StringArgumentType.getString(context, "type");
ServerPlayer mcOtherPlayer = EntityArgument.getPlayer(context, "player");
Player otherPlayer = PlayerUtil.getFactoryPlayer(mcOtherPlayer);
NexiaRank rank = NexiaRank.identifyRank(StringArgumentType.getString(context, "prefix"));
String prefix = StringArgumentType.getString(context, "prefix");
ServerPlayer mcExecutor;
Player factoryExecutor = null;
@@ -49,74 +44,82 @@ public class StaffPrefixCommand {
} catch(Exception ignored){ }
if(rank == null) {
if(factoryExecutor != null){
factoryExecutor.sendMessage(
ChatFormat.nexiaMessage
.append(Component.text("Invalid rank!").color(ChatFormat.normalColor).decoration(ChatFormat.bold, false))
);
} else {
executor.sendSuccess(LegacyChatFormat.format("{b1}Invalid rank!"), false);
}
return 0;
}
if(type.equalsIgnoreCase("set")){
if(factoryExecutor != null){
factoryExecutor.sendMessage(
ChatFormat.nexiaMessage
.append(Component.text("You have set the prefix of ").color(ChatFormat.normalColor).decoration(ChatFormat.bold, false))
.append(Component.text(otherPlayer.getRawName()).color(ChatFormat.brandColor2))
.append(Component.text(" to: ").color(ChatFormat.normalColor).decoration(ChatFormat.bold, false))
.append(Component.text(rank.name).color(ChatFormat.brandColor2).decoration(ChatFormat.bold, true))
.append(Component.text(".").color(ChatFormat.normalColor).decoration(ChatFormat.bold,false).decoration(ChatFormat.bold, false))
);
} else {
executor.sendSuccess(LegacyChatFormat.format("{b1}You have set the prefix of {b2}{} {b1}to: {b2}{b}{}{b1}.", otherPlayer.getRawName(), rank.name), false);
for(int i = 0; i < 10; i++){
if(prefix.equalsIgnoreCase(Main.config.ranks[i])){
if(factoryExecutor != null){
factoryExecutor.sendMessage(
ChatFormat.nexiaMessage
.append(Component.text("You have set the prefix of ").color(ChatFormat.normalColor).decoration(ChatFormat.bold, false))
.append(Component.text(otherPlayer.getRawName()).color(ChatFormat.brandColor2))
.append(Component.text(" to: ").color(ChatFormat.normalColor).decoration(ChatFormat.bold, false))
.append(Component.text(Main.config.ranks[i]).color(ChatFormat.brandColor2).decoration(ChatFormat.bold, true))
.append(Component.text(".").color(ChatFormat.normalColor).decoration(ChatFormat.bold,false).decoration(ChatFormat.bold, false))
);
} else {
executor.sendSuccess(LegacyChatFormat.format("{b1}You have set the prefix of {b2}{} {b1}to: {b2}{b}{}{b1}.", otherPlayer.getRawName(), Main.config.ranks[i]), false);
}
otherPlayer.sendMessage(
ChatFormat.nexiaMessage
.append(Component.text("Your prefix has been set to: ").color(ChatFormat.normalColor).decoration(ChatFormat.bold, false))
.append(Component.text(Main.config.ranks[i]).color(ChatFormat.brandColor2).decoration(ChatFormat.bold, true))
.append(Component.text(".").color(ChatFormat.normalColor).decoration(ChatFormat.bold, false))
);
for (int i2 = 0; i2 < 10; i2++) {
otherPlayer.removeTag(Main.config.ranks[i2]);
}
otherPlayer.addTag(Main.config.ranks[i]);
}
}
otherPlayer.sendMessage(
ChatFormat.nexiaMessage
.append(Component.text("Your prefix has been set to: ").color(ChatFormat.normalColor).decoration(ChatFormat.bold, false))
.append(Component.text(rank.name).color(ChatFormat.brandColor2).decoration(ChatFormat.bold, true))
.append(Component.text(".").color(ChatFormat.normalColor).decoration(ChatFormat.bold, false))
);
NexiaRank.setPrefix(rank, mcOtherPlayer);
}
if(type.equalsIgnoreCase("remove")){
if(factoryExecutor != null){
factoryExecutor.sendMessage(
ChatFormat.nexiaMessage
.append(Component.text("You have removed the prefix ").color(ChatFormat.normalColor).decoration(ChatFormat.bold, false))
.append(Component.text(rank.name).color(ChatFormat.brandColor2).decoration(ChatFormat.bold, true).decoration(ChatFormat.bold, false))
.append(Component.text(" from: ").color(ChatFormat.normalColor).decoration(ChatFormat.bold, false))
.append(Component.text(otherPlayer.getRawName()).color(ChatFormat.brandColor2).decoration(ChatFormat.bold, false))
.append(Component.text(".").color(ChatFormat.normalColor).decoration(ChatFormat.bold,false))
);
} else {
executor.sendSuccess(LegacyChatFormat.format("{b1}You have removed the prefix {b2}{b}{} {b1}from {b2}{}{b1}.", rank.name, otherPlayer.getRawName()), false);
}
for(int i = 0; i < 10; i++){
if(prefix.equalsIgnoreCase(Main.config.ranks[i])){
NexiaRank.removePrefix(rank, mcOtherPlayer);
if(factoryExecutor != null){
factoryExecutor.sendMessage(
ChatFormat.nexiaMessage
.append(Component.text("You have removed the prefix ").color(ChatFormat.normalColor).decoration(ChatFormat.bold, false))
.append(Component.text(Main.config.ranks[i]).color(ChatFormat.brandColor2).decoration(ChatFormat.bold, true).decoration(ChatFormat.bold, false))
.append(Component.text(" from: ").color(ChatFormat.normalColor).decoration(ChatFormat.bold, false))
.append(Component.text(otherPlayer.getRawName()).color(ChatFormat.brandColor2).decoration(ChatFormat.bold, false))
.append(Component.text(".").color(ChatFormat.normalColor).decoration(ChatFormat.bold,false))
);
} else {
executor.sendSuccess(LegacyChatFormat.format("{b1}You have removed the prefix {b2}{b}{} {b1}from {b2}{}{b1}.", Main.config.ranks[i], otherPlayer.getRawName()), false);
}
ServerTime.metisServer.runCommand(String.format("/lp user %s permission unset nexia.prefix.%s", otherPlayer.getRawName(), Main.config.ranks[i]));
}
}
}
if(type.equalsIgnoreCase("add")){
if(factoryExecutor != null){
factoryExecutor.sendMessage(
ChatFormat.nexiaMessage
.append(Component.text("You have added the prefix ").color(ChatFormat.normalColor).decoration(ChatFormat.bold, false))
.append(Component.text(rank.name).color(ChatFormat.brandColor2).decoration(ChatFormat.bold, true))
.append(Component.text(" to: ").color(ChatFormat.normalColor).decoration(ChatFormat.bold, false))
.append(Component.text(otherPlayer.getRawName()).color(ChatFormat.brandColor2).decoration(ChatFormat.bold, false))
.append(Component.text(".").color(ChatFormat.normalColor).decoration(ChatFormat.bold,false))
);
} else {
executor.sendSuccess(LegacyChatFormat.format("{b1}You have added the prefix {b2}{b}{} {b1}to {b2}{}{b1}.", rank.name, otherPlayer.getRawName()), false);
}
for(int i = 0; i < 10; i++){
if(prefix.equalsIgnoreCase(Main.config.ranks[i])){
if(factoryExecutor != null){
factoryExecutor.sendMessage(
ChatFormat.nexiaMessage
.append(Component.text("You have added the prefix ").color(ChatFormat.normalColor).decoration(ChatFormat.bold, false))
.append(Component.text(Main.config.ranks[i]).color(ChatFormat.brandColor2).decoration(ChatFormat.bold, true))
.append(Component.text(" to: ").color(ChatFormat.normalColor).decoration(ChatFormat.bold, false))
.append(Component.text(otherPlayer.getRawName()).color(ChatFormat.brandColor2).decoration(ChatFormat.bold, false))
.append(Component.text(".").color(ChatFormat.normalColor).decoration(ChatFormat.bold,false))
);
} else {
executor.sendSuccess(LegacyChatFormat.format("{b1}You have added the prefix {b2}{b}{} {b1}to {b2}{}{b1}.", Main.config.ranks[i], otherPlayer.getRawName()), false);
}
NexiaRank.addPrefix(rank, mcOtherPlayer, false);
ServerTime.metisServer.runCommand(String.format("/lp user %s permission set nexia.prefix.%s true", otherPlayer.getRawName(), Main.config.ranks[i]));
}
}
}
return Command.SINGLE_SUCCESS;
@@ -125,4 +128,4 @@ public class StaffPrefixCommand {
));
}
}
}
@@ -1,6 +1,6 @@
package com.nexia.core.commands.staff;
import com.combatreforged.factory.api.world.entity.player.Player;
import com.combatreforged.metis.api.world.entity.player.Player;
import com.mojang.brigadier.Command;
import com.mojang.brigadier.CommandDispatcher;
import com.mojang.brigadier.arguments.StringArgumentType;
@@ -9,7 +9,6 @@ import com.nexia.core.utilities.chat.LegacyChatFormat;
import com.nexia.core.utilities.player.PlayerData;
import com.nexia.core.utilities.player.PlayerDataManager;
import com.nexia.core.utilities.player.PlayerUtil;
import me.lucko.fabric.api.permissions.v0.Permissions;
import net.kyori.adventure.text.Component;
import net.minecraft.commands.CommandSourceStack;
import net.minecraft.commands.Commands;
@@ -22,7 +21,7 @@ public class StaffReportCommand {
public static void register(CommandDispatcher<CommandSourceStack> dispatcher, boolean bl) {
dispatcher.register(Commands.literal("staffreport")
.requires(commandSourceStack -> Permissions.check(commandSourceStack, "nexia.staff.report", 1))
.requires(commandSourceStack -> PlayerUtil.hasPermission(commandSourceStack, "nexia.staff.report", 1))
.then(Commands.argument("type", StringArgumentType.string())
.suggests(((context, builder) -> SharedSuggestionProvider.suggest((new String[]{"ban", "unban"}), builder)))
.then(Commands.argument("player", EntityArgument.player())
@@ -44,7 +43,7 @@ public class StaffReportCommand {
PlayerData data = PlayerDataManager.get(mcOtherPlayer);
if(type.equalsIgnoreCase("ban")) {
if(data.savedData.isReportBanned()) {
if(data.isReportBanned) {
if(factoryExecutor != null) {
factoryExecutor.sendMessage(Component.text("That player is already report banned!").color(ChatFormat.failColor).decoration(ChatFormat.bold, false));
} else {
@@ -52,7 +51,7 @@ public class StaffReportCommand {
}
return 0;
}
data.savedData.setReportBanned(true);
data.isReportBanned = true;
if(factoryExecutor != null) {
factoryExecutor.sendMessage(
ChatFormat.nexiaMessage
@@ -68,7 +67,7 @@ public class StaffReportCommand {
}
if(type.equalsIgnoreCase("unban") || type.equalsIgnoreCase("pardon")) {
if(!data.savedData.isReportBanned()) {
if(!data.isReportBanned) {
if(factoryExecutor != null) {
factoryExecutor.sendMessage(Component.text("That player is not report banned!").color(ChatFormat.failColor).decoration(ChatFormat.bold, false));
} else {
@@ -76,7 +75,7 @@ public class StaffReportCommand {
}
return 0;
}
data.savedData.setReportBanned(false);
data.isReportBanned = false;
if(factoryExecutor != null) {
factoryExecutor.sendMessage(
ChatFormat.nexiaMessage
@@ -1,5 +1,6 @@
package com.nexia.core.commands.staff;
import com.combatreforged.metis.api.world.entity.player.Player;
import com.mojang.authlib.GameProfile;
import com.mojang.brigadier.CommandDispatcher;
import com.mojang.brigadier.arguments.StringArgumentType;
@@ -7,18 +8,18 @@ import com.nexia.core.utilities.chat.ChatFormat;
import com.nexia.core.utilities.chat.LegacyChatFormat;
import com.nexia.core.utilities.player.BanHandler;
import com.nexia.core.utilities.player.PlayerUtil;
import me.lucko.fabric.api.permissions.v0.Permissions;
import net.kyori.adventure.text.Component;
import net.minecraft.commands.CommandSourceStack;
import net.minecraft.commands.Commands;
import net.minecraft.commands.arguments.GameProfileArgument;
import net.minecraft.server.level.ServerPlayer;
import java.util.Collection;
public class TempBanCommand {
public static void register(CommandDispatcher<CommandSourceStack> dispatcher, boolean bl) {
dispatcher.register(Commands.literal("tempban")
.requires(commandSourceStack -> Permissions.check(commandSourceStack, "nexia.staff.ban", 3))
.requires(commandSourceStack -> PlayerUtil.hasPermission(commandSourceStack, "nexia.staff.ban", 3))
.then(Commands.argument("player", GameProfileArgument.gameProfile())
.then(Commands.argument("duration", StringArgumentType.word())
.then(Commands.argument("reason", StringArgumentType.greedyString())
@@ -29,18 +30,34 @@ public class TempBanCommand {
public static int ban(CommandSourceStack sender, Collection<GameProfile> collection, String reason, String durationArg) {
ServerPlayer mcPlayer = null;
Player player = null;
try {
mcPlayer = sender.getPlayerOrException();
} catch (Exception ignored){ }
if(mcPlayer != null) {
player = PlayerUtil.getFactoryPlayer(mcPlayer);
}
int durationInSeconds;
try {
durationInSeconds = BanHandler.parseTimeArg(durationArg);
} catch (Exception e) {
PlayerUtil.safeSendMessage(sender, LegacyChatFormat.format("{f}Invalid duration. Examples: 1s / 2m / 3h / 4d / 5w"), ChatFormat.nexiaMessage
.append(Component.text("Invalid duration. Examples: ").color(ChatFormat.normalColor).decoration(ChatFormat.bold, false))
.append(Component.text("1s / 2m / 3h / 4d / 5w").color(ChatFormat.failColor).decoration(ChatFormat.bold, false)), false);
if (player != null) {
player.sendMessage(
ChatFormat.nexiaMessage
.append(Component.text("Invalid duration. Examples: ").color(ChatFormat.normalColor).decoration(ChatFormat.bold, false))
.append(Component.text("1s / 2m / 3h").color(ChatFormat.failColor).decoration(ChatFormat.bold, false))
);
} else {
sender.sendFailure(LegacyChatFormat.format("{f}Invalid duration. Examples: 1s / 2m / 3h"));
}
return 1;
}
BanHandler.tryBan(sender, collection, durationInSeconds, reason);
BanHandler.tryBan(sender, collection, durationInSeconds * 1000, reason);
return 1;
}
@@ -2,11 +2,11 @@ package com.nexia.core.commands.staff;
import com.mojang.authlib.GameProfile;
import com.mojang.brigadier.CommandDispatcher;
import com.nexia.core.Main;
import com.nexia.core.utilities.chat.ChatFormat;
import com.nexia.core.utilities.chat.LegacyChatFormat;
import com.nexia.core.utilities.player.PlayerUtil;
import com.nexia.core.utilities.time.ServerTime;
import me.lucko.fabric.api.permissions.v0.Permissions;
import net.kyori.adventure.text.Component;
import net.minecraft.commands.CommandSourceStack;
import net.minecraft.commands.Commands;
@@ -20,14 +20,14 @@ import java.util.Collection;
public class UnBanCommand {
public static void register(CommandDispatcher<CommandSourceStack> dispatcher, boolean bl) {
dispatcher.register(Commands.literal("unban")
.requires(commandSourceStack -> Permissions.check(commandSourceStack, "nexia.staff.ban", 3))
.requires(commandSourceStack -> PlayerUtil.hasPermission(commandSourceStack, "nexia.staff.ban", 3))
.then(Commands.argument("player", GameProfileArgument.gameProfile())
.suggests(((context, builder) -> SharedSuggestionProvider.suggest((context.getSource()).getServer().getPlayerList().getBans().getUserList(), builder)))
.executes(context -> UnBanCommand.unban(context.getSource(), GameProfileArgument.getGameProfiles(context, "player")))
)
);
dispatcher.register(Commands.literal("pardon")
.requires(commandSourceStack -> Permissions.check(commandSourceStack, "nexia.staff.ban", 3))
.requires(commandSourceStack -> PlayerUtil.hasPermission(commandSourceStack, "nexia.staff.ban", 3))
.then(Commands.argument("player", GameProfileArgument.gameProfile())
.suggests(((context, builder) -> SharedSuggestionProvider.suggest((context.getSource()).getServer().getPlayerList().getBans().getUserList(), builder)))
.executes(context -> UnBanCommand.unban(context.getSource(), GameProfileArgument.getGameProfiles(context, "player")))
@@ -1,68 +0,0 @@
package com.nexia.core.commands.staff;
import com.combatreforged.factory.api.world.entity.player.Player;
import com.mojang.brigadier.CommandDispatcher;
import com.mojang.brigadier.arguments.StringArgumentType;
import com.mojang.brigadier.context.CommandContext;
import com.mojang.brigadier.exceptions.CommandSyntaxException;
import com.nexia.core.games.util.PlayerGameMode;
import com.nexia.core.utilities.chat.ChatFormat;
import com.nexia.core.utilities.chat.LegacyChatFormat;
import com.nexia.core.utilities.player.GamemodeBanHandler;
import com.nexia.core.utilities.player.PlayerUtil;
import me.lucko.fabric.api.permissions.v0.Permissions;
import net.kyori.adventure.text.Component;
import net.minecraft.commands.CommandSourceStack;
import net.minecraft.commands.Commands;
import net.minecraft.commands.SharedSuggestionProvider;
import net.minecraft.commands.arguments.EntityArgument;
import net.minecraft.server.level.ServerPlayer;
public class UnGamemodeBanCommand {
public static void register(CommandDispatcher<CommandSourceStack> dispatcher, boolean bl) {
dispatcher.register(Commands.literal("ungamemodeban")
.requires(commandSourceStack -> Permissions.check(commandSourceStack, "nexia.staff.ban", 3))
.then(Commands.argument("player", EntityArgument.player())
.then(Commands.argument("gamemode", StringArgumentType.string())
.suggests(((context, builder) -> SharedSuggestionProvider.suggest((PlayerGameMode.stringPlayerGameModes), builder)))
.executes(UnGamemodeBanCommand::unBan)
)
)
);
}
public static int unBan(CommandContext<CommandSourceStack> context) throws CommandSyntaxException {
CommandSourceStack sender = context.getSource();
ServerPlayer mcExecutor = null;
Player executor = null;
try {
mcExecutor = sender.getPlayerOrException();
} catch (Exception ignored){ }
if(mcExecutor != null) {
executor = PlayerUtil.getFactoryPlayer(mcExecutor);
}
PlayerGameMode gameMode = PlayerGameMode.identifyGamemode(StringArgumentType.getString(context, "gamemode"));
if(gameMode == null) {
if(executor != null) {
executor.sendMessage(
ChatFormat.nexiaMessage
.append(Component.text("Invalid gamemode!").color(ChatFormat.normalColor).decoration(ChatFormat.bold, false))
);
} else {
sender.sendFailure(LegacyChatFormat.format("{f}Invalid gamemode!"));
}
return 1;
}
GamemodeBanHandler.tryUnGamemodeBan(sender, EntityArgument.getPlayer(context, "player"), gameMode);
return 1;
}
}
@@ -4,7 +4,7 @@ import com.mojang.brigadier.CommandDispatcher;
import com.mojang.brigadier.context.CommandContext;
import com.mojang.brigadier.exceptions.CommandSyntaxException;
import com.nexia.core.utilities.chat.PlayerMutes;
import me.lucko.fabric.api.permissions.v0.Permissions;
import com.nexia.core.utilities.player.PlayerUtil;
import net.minecraft.commands.CommandSourceStack;
import net.minecraft.commands.Commands;
import net.minecraft.commands.arguments.EntityArgument;
@@ -14,7 +14,7 @@ public class UnMuteCommand {
public static void register(CommandDispatcher<CommandSourceStack> dispatcher, boolean bl) {
dispatcher.register(Commands.literal("unmute")
.requires(commandSourceStack -> Permissions.check(commandSourceStack, "nexia.staff.mute", 1))
.requires(commandSourceStack -> PlayerUtil.hasPermission(commandSourceStack, "nexia.staff.mute", 1))
.then(Commands.argument("player", EntityArgument.player())
.executes(UnMuteCommand::unMute)
@@ -3,17 +3,21 @@ package com.nexia.core.commands.staff;
import com.mojang.brigadier.CommandDispatcher;
import com.mojang.brigadier.context.CommandContext;
import com.mojang.brigadier.exceptions.CommandSyntaxException;
import com.nexia.core.Main;
import com.nexia.core.utilities.chat.PlayerMutes;
import com.nexia.core.utilities.player.BanHandler;
import me.lucko.fabric.api.permissions.v0.Permissions;
import com.nexia.core.utilities.player.PlayerUtil;
import net.minecraft.commands.CommandSourceStack;
import net.minecraft.commands.Commands;
import net.minecraft.commands.arguments.EntityArgument;
import net.minecraft.commands.arguments.GameProfileArgument;
import net.minecraft.server.level.ServerPlayer;
public class UnTempBanCommand {
public static void register(CommandDispatcher<CommandSourceStack> dispatcher, boolean bl) {
dispatcher.register(Commands.literal("untempban")
.requires(commandSourceStack -> Permissions.check(commandSourceStack, "nexia.staff.ban", 3))
.requires(commandSourceStack -> PlayerUtil.hasPermission(commandSourceStack, "nexia.staff.ban", 3))
.then(Commands.argument("player", GameProfileArgument.gameProfile())
.executes(UnTempBanCommand::unBan)
@@ -3,9 +3,10 @@ package com.nexia.core.commands.staff.dev;
import com.mojang.brigadier.CommandDispatcher;
import com.mojang.brigadier.context.CommandContext;
import com.mojang.brigadier.exceptions.CommandSyntaxException;
import com.nexia.core.utilities.chat.ChatFormat;
import com.nexia.core.utilities.chat.LegacyChatFormat;
import com.nexia.core.utilities.player.PlayerUtil;
import com.nexia.minigames.games.bedwars.shop.BwLoadShop;
import me.lucko.fabric.api.permissions.v0.Permissions;
import net.minecraft.commands.CommandSourceStack;
import net.minecraft.commands.Commands;
import net.minecraft.network.chat.TextComponent;
@@ -14,12 +15,13 @@ public class BwReloadShopCommand {
public static void register(CommandDispatcher<CommandSourceStack> dispatcher, boolean bl) {
dispatcher.register(Commands.literal("bwreloadshop").executes(BwReloadShopCommand::run)
.requires(commandSourceStack -> Permissions.check(commandSourceStack, "nexia.dev.bwreloadshop", 3)));
.requires(commandSourceStack -> PlayerUtil.hasPermission(commandSourceStack, "nexia.dev.bwreloadshop", 3)));
}
public static int run(CommandContext<CommandSourceStack> context) throws CommandSyntaxException {
boolean success = BwLoadShop.loadBedWarsShop(false);
boolean success = BwLoadShop.loadBedWarsShop(false) &&
BwLoadShop.loadBedWarsShop(false);
if (success) {
String message = LegacyChatFormat.brandColor1 + "Reloaded Bedwars shop successfully!";
@@ -3,8 +3,8 @@ package com.nexia.core.commands.staff.dev;
import com.mojang.brigadier.CommandDispatcher;
import com.mojang.brigadier.context.CommandContext;
import com.mojang.brigadier.exceptions.CommandSyntaxException;
import com.nexia.core.utilities.player.PlayerUtil;
import com.nexia.minigames.games.bedwars.players.BwTeam;
import me.lucko.fabric.api.permissions.v0.Permissions;
import net.minecraft.commands.CommandSourceStack;
import net.minecraft.commands.Commands;
import net.minecraft.server.level.ServerPlayer;
@@ -13,7 +13,7 @@ public class BwReloadTeamColorsCommand {
public static void register(CommandDispatcher<CommandSourceStack> dispatcher, boolean bl) {
dispatcher.register(Commands.literal("bwreloadteamcolors").executes(BwReloadTeamColorsCommand::run)
.requires(commandSourceStack -> Permissions.check(commandSourceStack, "nexia.dev.bwreloadteamcolors", 3)));
.requires(commandSourceStack -> PlayerUtil.hasPermission(commandSourceStack, "nexia.dev.bwreloadteamcolors", 3)));
}
public static int run(CommandContext<CommandSourceStack> context) throws CommandSyntaxException {
@@ -0,0 +1,35 @@
package com.nexia.core.commands.staff.dev;
import com.mojang.brigadier.CommandDispatcher;
import com.mojang.brigadier.context.CommandContext;
import com.mojang.brigadier.exceptions.CommandSyntaxException;
import com.nexia.core.utilities.player.PlayerUtil;
import com.nexia.minigames.games.bedwars.util.BwUtil;
import net.minecraft.Util;
import net.minecraft.commands.CommandSourceStack;
import net.minecraft.commands.Commands;
import net.minecraft.network.chat.TextComponent;
import net.minecraft.server.level.ServerPlayer;
public class BwSkipQueueCommand {
public static void register(CommandDispatcher<CommandSourceStack> dispatcher, boolean bl) {
dispatcher.register((Commands.literal("bwskipqueue")
.requires(commandSourceStack -> PlayerUtil.hasPermission(commandSourceStack, "nexia.staff.bwskipqueue", 1)))
.executes(BwSkipQueueCommand::run)
);
}
private static int run(CommandContext<CommandSourceStack> context) throws CommandSyntaxException {
ServerPlayer player = context.getSource().getPlayerOrException();
if (BwUtil.skipQueue()) {
player.sendMessage(new TextComponent("Skipped queue"), Util.NIL_UUID);
} else {
player.sendMessage(new TextComponent("Epic queue skip failure"), Util.NIL_UUID);
}
return 1;
}
}
@@ -1,72 +0,0 @@
package com.nexia.core.commands.staff.dev;
import com.mojang.brigadier.CommandDispatcher;
import com.mojang.brigadier.arguments.StringArgumentType;
import com.mojang.brigadier.context.CommandContext;
import com.nexia.core.utilities.chat.LegacyChatFormat;
import com.nexia.core.utilities.item.InventoryUtil;
import me.lucko.fabric.api.permissions.v0.Permissions;
import net.minecraft.commands.CommandSourceStack;
import net.minecraft.commands.Commands;
import net.minecraft.commands.SharedSuggestionProvider;
import org.jetbrains.annotations.NotNull;
import java.io.File;
import java.util.ArrayList;
import java.util.Objects;
public class DeleteInventoryCommand {
public static void register(CommandDispatcher<CommandSourceStack> dispatcher, boolean bl) {
dispatcher.register((Commands.literal("deleteinventory")
.requires(commandSourceStack -> {
try {
return Permissions.check(commandSourceStack, "nexia.inventory.delete", 4);
} catch (Exception ignored) {
return false;
}
})
.then(Commands.argument("type", StringArgumentType.string())
.suggests(((context, builder) -> SharedSuggestionProvider.suggest((Objects.requireNonNull(new File(InventoryUtil.dirpath).list())), builder)))
.then(Commands.argument("inventory", StringArgumentType.string())
.suggests(((context, builder) -> {
ArrayList<String> inventoryList = new ArrayList<>();
try {
inventoryList = InventoryUtil.getListOfInventories(StringArgumentType.getString(context, "type"));
} catch (Exception ignored) {
inventoryList.add("Unable to get inventories!");
}
return SharedSuggestionProvider.suggest(inventoryList, builder);
}))
.executes(context -> run(context, StringArgumentType.getString(context, "type"), StringArgumentType.getString(context, "inventory")))
)
)
)
);
}
private static int run(CommandContext<CommandSourceStack> context, @NotNull String type, @NotNull String inventory) {
if(inventory.trim().isEmpty()) {
context.getSource().sendFailure(LegacyChatFormat.format("Empty inventory name!"));
return 0;
}
if(type.trim().isEmpty()) {
context.getSource().sendFailure(LegacyChatFormat.format("Empty type!"));
return 0;
}
File file = new File(InventoryUtil.dirpath + File.separator + type, inventory + ".txt");
if(file.isDirectory() || !file.exists()) {
context.getSource().sendFailure(LegacyChatFormat.format("The inventory with the name '{}' in '{}' does not exist!", inventory, type));
return 0;
}
file.delete();
context.getSource().sendSuccess(LegacyChatFormat.format("{b1}Successfully deleted inventory '{}' in '{}'.", inventory, type), true);
return 1;
}
}
@@ -4,48 +4,36 @@ import com.mojang.brigadier.CommandDispatcher;
import com.mojang.brigadier.arguments.StringArgumentType;
import com.mojang.brigadier.context.CommandContext;
import com.mojang.brigadier.exceptions.CommandSyntaxException;
import com.nexia.core.utilities.chat.LegacyChatFormat;
import com.nexia.core.utilities.misc.RandomUtil;
import com.nexia.core.games.util.LobbyUtil;
import com.nexia.core.utilities.time.ServerTime;
import com.nexia.ffa.uhc.utilities.FfaAreas;
import com.nexia.minigames.games.oitc.OitcGame;
import com.nexia.minigames.games.skywars.SkywarsGame;
import com.nexia.minigames.games.skywars.SkywarsMap;
import io.github.blumbo.inventorymerger.saving.SavableInventory;
import me.lucko.fabric.api.permissions.v0.Permissions;
import net.fabricmc.loader.api.FabricLoader;
import net.minecraft.Util;
import net.minecraft.commands.CommandSourceStack;
import net.minecraft.commands.Commands;
import net.minecraft.commands.SharedSuggestionProvider;
import net.minecraft.core.Registry;
import net.minecraft.network.chat.TextComponent;
import net.minecraft.resources.ResourceKey;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.world.Difficulty;
import net.minecraft.world.level.GameRules;
import net.minecraft.world.level.biome.Biomes;
import net.minecraft.world.level.dimension.DimensionType;
import xyz.nucleoid.fantasy.RuntimeWorldConfig;
import java.io.FileWriter;
import static com.nexia.core.utilities.world.WorldUtil.getChunkGenerator;
public class DevExperimentalCommandsCommand {
public class DevExperimentalMapCommand {
public static void register(CommandDispatcher<CommandSourceStack> dispatcher, boolean bl) {
dispatcher.register((Commands.literal("devexperimentalcmds")
dispatcher.register((Commands.literal("devexperimentalmap")
.requires(commandSourceStack -> {
try {
return Permissions.check(commandSourceStack, "nexia.dev.experimentalcmds");
return Permissions.check(commandSourceStack, "nexia.dev.experimentalmap");
} catch (Exception ignored) {
return false;
}
})
.then(Commands.argument("argument", StringArgumentType.string())
.suggests(((context, builder) -> SharedSuggestionProvider.suggest((new String[]{"cffa", "rluhc", "swmap", "saveinventory"}), builder)))
.executes(DevExperimentalCommandsCommand::run))
.suggests(((context, builder) -> SharedSuggestionProvider.suggest((new String[]{"cffa"}), builder)))
.executes(DevExperimentalMapCommand::run))
)
);
}
@@ -54,14 +42,13 @@ public class DevExperimentalCommandsCommand {
ServerPlayer player = context.getSource().getPlayerOrException();
String argument = StringArgumentType.getString(context, "argument");
String name = argument;
if(name.contains("-")) name = name.split("-")[1];
String name = argument.split("-")[1];
if(argument.contains("cffa")){
ServerLevel level = ServerTime.fantasy.getOrOpenPersistentWorld(ResourceKey.create(Registry.DIMENSION_REGISTRY, new ResourceLocation("ffa", name)).location(), (
new RuntimeWorldConfig()
.setDimensionType(DimensionType.OVERWORLD_LOCATION)
.setGenerator(getChunkGenerator(Biomes.PLAINS))
.setDimensionType(SkywarsGame.world.dimensionType())
.setGenerator(SkywarsGame.world.getChunkSource().getGenerator())
.setDifficulty(Difficulty.HARD)
.setGameRule(GameRules.RULE_KEEPINVENTORY, true)
.setGameRule(GameRules.RULE_MOBGRIEFING, false)
@@ -76,38 +63,10 @@ public class DevExperimentalCommandsCommand {
.setGameRule(GameRules.RULE_SPAWN_RADIUS, 0))).asWorld();
player.teleportTo(level, 0, 80, 0, 0, 0);
} else if(argument.equalsIgnoreCase("rluhc")) {
FfaAreas.resetMap(true);
player.sendMessage(LegacyChatFormat.format("Reloaded UHC Map."), Util.NIL_UUID);
} else if(argument.contains("swmap")) {
SkywarsMap map = SkywarsMap.identifyMap(name);
if(map != null) {
SkywarsGame.map = map;
player.sendMessage(LegacyChatFormat.format("Map set to " + map.id), Util.NIL_UUID);
} else {
player.sendMessage(LegacyChatFormat.format("Invalid map!"), Util.NIL_UUID);
}
} else if(argument.equalsIgnoreCase("saveinventory")) {
SavableInventory savableInventory = new SavableInventory(player.inventory);
String stringInventory = savableInventory.toSave();
try {
String fileName = player.getScoreboardName() + "_devinventory-" + RandomUtil.randomInt(0, 100);
String directory = FabricLoader.getInstance().getConfigDir().toString() + "/nexia";
FileWriter fileWriter = new FileWriter(directory + "/" + fileName + ".json");
fileWriter.write(stringInventory);
fileWriter.close();
player.sendMessage(LegacyChatFormat.format("Saved Inventory in /config/nexia/{}.json", fileName), Util.NIL_UUID);
} catch (Exception var6) {
player.sendMessage(LegacyChatFormat.format("Failed to save inventory!"), Util.NIL_UUID);
player.sendMessage(new TextComponent(var6.getMessage()), Util.NIL_UUID);
}
}
return 1;
}
}
@@ -1,48 +0,0 @@
package com.nexia.core.commands.staff.dev;
import com.mojang.brigadier.CommandDispatcher;
import com.mojang.brigadier.arguments.StringArgumentType;
import com.mojang.brigadier.context.CommandContext;
import com.nexia.minigames.games.bedwars.BwGame;
import com.nexia.minigames.games.football.FootballGame;
import com.nexia.minigames.games.oitc.OitcGame;
import com.nexia.minigames.games.skywars.SkywarsGame;
import me.lucko.fabric.api.permissions.v0.Permissions;
import net.minecraft.commands.CommandSourceStack;
import net.minecraft.commands.Commands;
import net.minecraft.commands.SharedSuggestionProvider;
import net.minecraft.network.chat.TextComponent;
public class ForceGameEndCommand {
public static void register(CommandDispatcher<CommandSourceStack> dispatcher, boolean bl) {
dispatcher.register((Commands.literal("forcegameend")
.requires(commandSourceStack -> {
try {
return Permissions.check(commandSourceStack, "nexia.dev.forcegameend");
} catch (Exception ignored) {
return false;
}
})
.then(Commands.argument("game", StringArgumentType.string())
.suggests(((context, builder) -> SharedSuggestionProvider.suggest((new String[]{"football", "oitc", "skywars", "bedwars"}), builder)))
.executes(ForceGameEndCommand::run))
)
);
}
private static int run(CommandContext<CommandSourceStack> context) {
String argument = StringArgumentType.getString(context, "game");
switch (argument) {
case "football" -> FootballGame.endGame(null);
case "oitc" -> OitcGame.endGame(null);
case "skywars" -> SkywarsGame.winNearestCenter();
case "bedwars" -> BwGame.endBedwars();
default -> context.getSource().sendFailure(new TextComponent("Invalid game!"));
}
context.getSource().sendSuccess(new TextComponent("Game ended (if valid)."), false);
return 1;
}
}
@@ -1,88 +0,0 @@
package com.nexia.core.commands.staff.dev;
import com.mojang.brigadier.CommandDispatcher;
import com.mojang.brigadier.arguments.StringArgumentType;
import com.mojang.brigadier.context.CommandContext;
import com.mojang.brigadier.exceptions.CommandSyntaxException;
import com.nexia.core.utilities.chat.LegacyChatFormat;
import com.nexia.core.utilities.item.InventoryUtil;
import me.lucko.fabric.api.permissions.v0.Permissions;
import net.minecraft.Util;
import net.minecraft.commands.CommandSourceStack;
import net.minecraft.commands.Commands;
import net.minecraft.commands.SharedSuggestionProvider;
import net.minecraft.commands.arguments.EntityArgument;
import net.minecraft.server.level.ServerPlayer;
import org.jetbrains.annotations.NotNull;
import java.io.File;
import java.util.ArrayList;
import java.util.Objects;
public class LoadInventoryCommand {
public static void register(CommandDispatcher<CommandSourceStack> dispatcher, boolean bl) {
dispatcher.register((Commands.literal("loadinventory")
.requires(commandSourceStack -> {
try {
return Permissions.check(commandSourceStack, "nexia.inventory.load", 4);
} catch (Exception ignored) {
return false;
}
})
.then(Commands.argument("type", StringArgumentType.string())
.suggests(((context, builder) -> SharedSuggestionProvider.suggest((Objects.requireNonNull(new File(InventoryUtil.dirpath).list())), builder)))
.then(Commands.argument("inventory", StringArgumentType.string())
.suggests(((context, builder) -> {
ArrayList<String> inventoryList = new ArrayList<>();
try {
inventoryList = InventoryUtil.getListOfInventories(StringArgumentType.getString(context, "type"));
} catch (Exception ignored) {
inventoryList.add("Unable to get inventories!");
}
return SharedSuggestionProvider.suggest(inventoryList, builder);
}))
.executes(context -> run(context, StringArgumentType.getString(context, "type"), StringArgumentType.getString(context, "inventory"), context.getSource().getPlayerOrException()))
.then(Commands.argument("player", EntityArgument.player())
.executes(context -> run(context, StringArgumentType.getString(context, "type"), StringArgumentType.getString(context, "inventory"), EntityArgument.getPlayer(context, "player")))
)
)
)
)
);
}
private static int run(CommandContext<CommandSourceStack> context, @NotNull String type, @NotNull String inventory, @NotNull ServerPlayer player) {
if(inventory.trim().isEmpty()) {
context.getSource().sendFailure(LegacyChatFormat.format("Empty inventory name!"));
return 0;
}
if(type.trim().isEmpty()) {
context.getSource().sendFailure(LegacyChatFormat.format("Empty type!"));
return 0;
}
boolean isContextPlayer;
try {
isContextPlayer = context.getSource().getPlayerOrException().equals(player);
} catch (CommandSyntaxException ignored) {
isContextPlayer = false;
}
String gearString = InventoryUtil.getGearStringFromFile(type, inventory);
if(gearString.isEmpty()) {
context.getSource().sendFailure(LegacyChatFormat.format("Unable to load the content of the inventory with the name '{}' in '{}'.", inventory, type));
return 0;
} else {
InventoryUtil.loadInventory(player, type, inventory);
context.getSource().sendSuccess(LegacyChatFormat.format("{b1}Successfully loaded '{}' in '{}' to " + ((isContextPlayer) ? "your inventory" : "the inventory of " + player.getScoreboardName()) + ".", inventory, type), false);
if(!isContextPlayer){
player.sendMessage(LegacyChatFormat.format("{b1}Your inventory has been replaced with '{}'.", inventory), Util.NIL_UUID);
}
}
return 1;
}
}
@@ -3,8 +3,9 @@ package com.nexia.core.commands.staff.dev;
import com.mojang.brigadier.CommandDispatcher;
import com.mojang.brigadier.context.CommandContext;
import com.mojang.brigadier.exceptions.CommandSyntaxException;
import com.nexia.core.utilities.player.PlayerUtil;
import com.nexia.ffa.uhc.utilities.FfaAreas;
import com.nexia.minigames.games.bedwars.areas.BwAreas;
import me.lucko.fabric.api.permissions.v0.Permissions;
import net.minecraft.commands.CommandSourceStack;
import net.minecraft.commands.Commands;
import net.minecraft.server.level.ServerPlayer;
@@ -13,11 +14,11 @@ public class ProtectionMapCommand {
public static void register(CommandDispatcher<CommandSourceStack> dispatcher, boolean bl) {
dispatcher.register(Commands.literal("protectionmap")
.requires(commandSourceStack -> Permissions.check(commandSourceStack, "nexia.dev.protectionmap", 4))
.requires(commandSourceStack -> PlayerUtil.hasPermission(commandSourceStack, "nexia.dev.protectionmap", 4))
.then(Commands.literal("bedwars").executes(ProtectionMapCommand::bedwars))
.then(Commands.literal("ffa")
.then(Commands.literal("sky").executes(ProtectionMapCommand::ffa_sky))
.then(Commands.literal("uhc").executes(ProtectionMapCommand::ffa_uhc))
)
);
}
@@ -28,9 +29,10 @@ public class ProtectionMapCommand {
return 1;
}
public static int ffa_sky(CommandContext<CommandSourceStack> context) throws CommandSyntaxException {
public static int ffa_uhc(CommandContext<CommandSourceStack> context) throws CommandSyntaxException {
ServerPlayer player = context.getSource().getPlayerOrException();
com.nexia.ffa.sky.utilities.FfaAreas.createProtectionMap(player);
FfaAreas.createProtectionMap(player);
return 1;
}
}
@@ -4,7 +4,7 @@ import com.mojang.brigadier.CommandDispatcher;
import com.mojang.brigadier.arguments.IntegerArgumentType;
import com.mojang.brigadier.context.CommandContext;
import com.nexia.core.utilities.misc.RandomUtil;
import me.lucko.fabric.api.permissions.v0.Permissions;
import com.nexia.core.utilities.player.PlayerUtil;
import net.minecraft.commands.CommandSourceStack;
import net.minecraft.commands.Commands;
import net.minecraft.network.chat.TextComponent;
@@ -12,7 +12,7 @@ import net.minecraft.network.chat.TextComponent;
public class RandomCommand {
public static void register(CommandDispatcher<CommandSourceStack> dispatcher, boolean bl) {
dispatcher.register(Commands.literal("random")
.requires(commandSourceStack -> Permissions.check(commandSourceStack, "nexia.staff.random", 1))
.requires(commandSourceStack -> PlayerUtil.hasPermission(commandSourceStack, "nexia.staff.random", 1))
.then(Commands.argument("minimum", IntegerArgumentType.integer())
.then(Commands.argument("maximum", IntegerArgumentType.integer())
.executes(context -> RandomCommand.calculate(context, IntegerArgumentType.getInteger(context, "minimum"), IntegerArgumentType.getInteger(context, "maximum")))))
@@ -1,67 +0,0 @@
package com.nexia.core.commands.staff.dev;
import com.mojang.brigadier.CommandDispatcher;
import com.mojang.brigadier.arguments.StringArgumentType;
import com.mojang.brigadier.context.CommandContext;
import com.mojang.brigadier.exceptions.CommandSyntaxException;
import com.natamus.collective_fabric.functions.PlayerFunctions;
import com.natamus.collective_fabric.functions.StringFunctions;
import com.nexia.core.utilities.chat.LegacyChatFormat;
import com.nexia.core.utilities.item.InventoryUtil;
import me.lucko.fabric.api.permissions.v0.Permissions;
import net.minecraft.commands.CommandSourceStack;
import net.minecraft.commands.Commands;
import net.minecraft.commands.SharedSuggestionProvider;
import net.minecraft.server.level.ServerPlayer;
import org.jetbrains.annotations.NotNull;
import java.io.File;
import java.util.Objects;
public class SaveInventoryCommand {
public static void register(CommandDispatcher<CommandSourceStack> dispatcher, boolean bl) {
dispatcher.register((Commands.literal("saveinventory")
.requires(commandSourceStack -> {
try {
return Permissions.check(commandSourceStack, "nexia.inventory.save", 4);
} catch (Exception ignored) {
return false;
}
})
.then(Commands.argument("type", StringArgumentType.string())
.suggests(((context, builder) -> SharedSuggestionProvider.suggest((Objects.requireNonNull(new File(InventoryUtil.dirpath).list())), builder)))
.then(Commands.argument("name", StringArgumentType.string())
.executes(context -> run(context, StringArgumentType.getString(context, "type"), StringArgumentType.getString(context, "name")))
)
)
)
);
}
private static int run(CommandContext<CommandSourceStack> context, @NotNull String type, @NotNull String inventory) throws CommandSyntaxException {
ServerPlayer player = context.getSource().getPlayerOrException();
if(inventory.trim().isEmpty()) {
context.getSource().sendFailure(LegacyChatFormat.format("Empty inventory name!"));
return 0;
}
if(type.trim().isEmpty()) {
context.getSource().sendFailure(LegacyChatFormat.format("Empty type!"));
return 0;
}
String gearstring = PlayerFunctions.getPlayerGearString(player);
if (StringFunctions.sequenceCount(gearstring, "\n") < 40) {
context.getSource().sendFailure(LegacyChatFormat.format("Something went wrong while generating the save file content for your inventory."));
return 0;
} else if (!InventoryUtil.writeGearStringToFile(type, inventory, gearstring)) {
context.getSource().sendFailure(LegacyChatFormat.format("Something went wrong while saving the content of your inventory as '{}' in '{}'.", inventory, type));
return 0;
} else {
context.getSource().sendFailure(LegacyChatFormat.format("Successfully saved your inventory as '{}' in '{}'.", inventory, type));
context.getSource().sendFailure(LegacyChatFormat.format("{b1}You can load it with the command '/loadinventory {} {}'.", type, inventory));
return 1;
}
}
}
@@ -1,97 +0,0 @@
package com.nexia.core.commands.staff.dev;
import com.mojang.brigadier.CommandDispatcher;
import com.mojang.brigadier.context.CommandContext;
import com.mojang.brigadier.exceptions.CommandSyntaxException;
import com.nexia.core.games.util.PlayerGameMode;
import com.nexia.core.utilities.chat.LegacyChatFormat;
import com.nexia.core.utilities.player.PlayerDataManager;
import com.nexia.minigames.games.bedwars.util.BwUtil;
import com.nexia.minigames.games.football.FootballGame;
import com.nexia.minigames.games.oitc.OitcGame;
import com.nexia.minigames.games.skywars.SkywarsGame;
import me.lucko.fabric.api.permissions.v0.Permissions;
import net.minecraft.Util;
import net.minecraft.commands.CommandSourceStack;
import net.minecraft.commands.Commands;
import net.minecraft.network.chat.TextComponent;
import net.minecraft.server.level.ServerPlayer;
public class SkipQueueCommand {
public static void register(CommandDispatcher<CommandSourceStack> dispatcher, boolean bl) {
dispatcher.register((Commands.literal("skipqueue")
.requires(commandSourceStack -> Permissions.check(commandSourceStack, "nexia.staff.skipqueue", 1)))
.executes(SkipQueueCommand::currentGamemode)
.then(Commands.literal("oitc").executes(SkipQueueCommand::oitc))
.then(Commands.literal("sw").executes(SkipQueueCommand::skywars))
.then(Commands.literal("bw").executes(SkipQueueCommand::bedwars))
.then(Commands.literal("football").executes(SkipQueueCommand::football))
);
}
private static int currentGamemode(CommandContext<CommandSourceStack> context) throws CommandSyntaxException {
ServerPlayer player = context.getSource().getPlayerOrException();
PlayerGameMode gameMode = PlayerDataManager.get(player).gameMode;
if(gameMode.equals(PlayerGameMode.SKYWARS)) return skywars(context);
if(gameMode.equals(PlayerGameMode.BEDWARS)) return bedwars(context);
if(gameMode.equals(PlayerGameMode.OITC)) return oitc(context);
if(gameMode.equals(PlayerGameMode.FOOTBALL)) return football(context);
player.sendMessage(LegacyChatFormat.formatFail("No gamemode found!"), Util.NIL_UUID);
return 0;
}
private static int skywars(CommandContext<CommandSourceStack> context) throws CommandSyntaxException {
ServerPlayer player = context.getSource().getPlayerOrException();
if (SkywarsGame.isStarted || SkywarsGame.queueTime <= 1) {
player.sendMessage(new TextComponent("Epic queue skip failure"), Util.NIL_UUID);
} else {
SkywarsGame.queueTime = 1;
player.sendMessage(new TextComponent("Skipped queue"), Util.NIL_UUID);
}
return 1;
}
private static int football(CommandContext<CommandSourceStack> context) throws CommandSyntaxException {
ServerPlayer player = context.getSource().getPlayerOrException();
if (FootballGame.isStarted || FootballGame.queueTime <= 1) {
player.sendMessage(new TextComponent("Epic queue skip failure"), Util.NIL_UUID);
} else {
FootballGame.queueTime = 1;
player.sendMessage(new TextComponent("Skipped queue"), Util.NIL_UUID);
}
return 1;
}
private static int oitc(CommandContext<CommandSourceStack> context) throws CommandSyntaxException {
ServerPlayer player = context.getSource().getPlayerOrException();
if (OitcGame.isStarted || OitcGame.queueTime <= 1) {
player.sendMessage(new TextComponent("Epic queue skip failure"), Util.NIL_UUID);
} else {
OitcGame.queueTime = 1;
player.sendMessage(new TextComponent("Skipped queue"), Util.NIL_UUID);
}
return 1;
}
private static int bedwars(CommandContext<CommandSourceStack> context) throws CommandSyntaxException {
ServerPlayer player = context.getSource().getPlayerOrException();
if (BwUtil.skipQueue()) {
player.sendMessage(new TextComponent("Skipped queue"), Util.NIL_UUID);
} else {
player.sendMessage(new TextComponent("Epic queue skip failure"), Util.NIL_UUID);
}
return 1;
}
}
@@ -0,0 +1,37 @@
package com.nexia.core.commands.staff.dev;
import com.mojang.brigadier.CommandDispatcher;
import com.mojang.brigadier.context.CommandContext;
import com.mojang.brigadier.exceptions.CommandSyntaxException;
import com.nexia.core.utilities.player.PlayerUtil;
import com.nexia.minigames.games.bedwars.util.BwUtil;
import com.nexia.minigames.games.skywars.SkywarsGame;
import net.minecraft.Util;
import net.minecraft.commands.CommandSourceStack;
import net.minecraft.commands.Commands;
import net.minecraft.network.chat.TextComponent;
import net.minecraft.server.level.ServerPlayer;
public class SwSkipQueueCommand {
public static void register(CommandDispatcher<CommandSourceStack> dispatcher, boolean bl) {
dispatcher.register((Commands.literal("swskipqueue")
.requires(commandSourceStack -> PlayerUtil.hasPermission(commandSourceStack, "nexia.staff.swskipqueue", 1)))
.executes(SwSkipQueueCommand::run)
);
}
private static int run(CommandContext<CommandSourceStack> context) throws CommandSyntaxException {
ServerPlayer player = context.getSource().getPlayerOrException();
if (SkywarsGame.isStarted || SkywarsGame.queueTime <= 1) {
player.sendMessage(new TextComponent("Epic queue skip failure"), Util.NIL_UUID);
} else {
SkywarsGame.queueTime = 1;
player.sendMessage(new TextComponent("Skipped queue"), Util.NIL_UUID);
}
return 1;
}
}
@@ -2,13 +2,29 @@ package com.nexia.core.config;
import me.sargunvohra.mcmods.autoconfig1u.ConfigData;
import me.sargunvohra.mcmods.autoconfig1u.annotation.Config;
import me.sargunvohra.mcmods.autoconfig1u.shadowed.blue.endless.jankson.Comment;
@Config(name = "nexia-core")
public class ModConfig implements ConfigData {
public String[] rules = {""};
@Comment("List of ranks.")
public String[] ranks = {""};
public double[] lobbyPos = {
0.5,
65.0,
0.5,
};
public String serverType = "";
public boolean debugMode = false;
public Enhancements enhancements = new Enhancements();
public static class Enhancements {
@Comment("Toggles if the better shields are enabled.")
public boolean betterShields = false;
@Comment("Modifies the pearl cooldown in ticks (20 ticks = 1 second).")
public int enderpearlCooldown = 20;
@Comment("Remove Projectiles going through players [EXPERIMENTAL]")
public boolean projectilePatch = false;
}
}
@@ -1,11 +1,10 @@
package com.nexia.core.games.util;
import com.combatreforged.factory.api.world.entity.player.Player;
import com.combatreforged.metis.api.world.entity.player.Player;
import com.nexia.core.Main;
import com.nexia.core.utilities.chat.ChatFormat;
import com.nexia.core.utilities.item.ItemDisplayUtil;
import com.nexia.core.utilities.item.ItemStackUtil;
import com.nexia.core.utilities.player.BanHandler;
import com.nexia.core.utilities.player.GamemodeBanHandler;
import com.nexia.core.utilities.player.PlayerDataManager;
import com.nexia.core.utilities.player.PlayerUtil;
import com.nexia.core.utilities.pos.EntityPos;
@@ -15,45 +14,31 @@ import com.nexia.ffa.FfaUtil;
import com.nexia.ffa.classic.utilities.FfaAreas;
import com.nexia.ffa.classic.utilities.FfaClassicUtil;
import com.nexia.ffa.kits.utilities.FfaKitsUtil;
import com.nexia.ffa.sky.utilities.FfaSkyUtil;
import com.nexia.ffa.uhc.utilities.FfaUhcUtil;
import com.nexia.minigames.games.bedwars.players.BwPlayerEvents;
import com.nexia.minigames.games.bedwars.util.BwScoreboard;
import com.nexia.minigames.games.bedwars.util.BwUtil;
import com.nexia.minigames.games.duels.DuelGameHandler;
import com.nexia.minigames.games.football.FootballGame;
import com.nexia.minigames.games.football.FootballGameMode;
import com.nexia.minigames.games.oitc.OitcGame;
import com.nexia.minigames.games.oitc.OitcGameMode;
import com.nexia.minigames.games.skywars.SkywarsGame;
import com.nexia.minigames.games.skywars.SkywarsGameMode;
import me.lucko.fabric.api.permissions.v0.Permissions;
import net.kyori.adventure.text.Component;
import net.minecraft.network.chat.TextComponent;
import net.minecraft.network.protocol.game.ClientboundStopSoundPacket;
import net.minecraft.server.MinecraftServer;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.world.entity.EquipmentSlot;
import net.minecraft.world.entity.ai.attributes.Attributes;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.Items;
import net.minecraft.world.level.GameType;
import net.minecraft.world.level.Level;
import org.json.simple.JSONObject;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.Objects;
import static com.nexia.core.utilities.player.BanHandler.getBanTime;
public class LobbyUtil {
public static String[] statsGameModes = {"FFA CLASSIC", "SKY FFA", "UHC FFA", "KIT FFA", "BEDWARS", "OITC", "DUELS", "SKYWARS", "FOOTBALL"};
public static String[] statsGameModes = {"FFA CLASSIC", "KIT FFA", "BEDWARS", "OITC", "DUELS", "SKYWARS"};
public static ServerLevel lobbyWorld = null;
public static EntityPos lobbySpawn = new EntityPos(0, 65, 0, 0, 0);
public static EntityPos lobbySpawn = new EntityPos(Main.config.lobbyPos[0], Main.config.lobbyPos[1], Main.config.lobbyPos[2], 0, 0);
public static boolean isLobbyWorld(Level level) {
return level.dimension() == Level.OVERWORLD;
@@ -77,20 +62,14 @@ public class LobbyUtil {
public static final String NO_SATURATION_TAG = "no_saturation";
public static String[] removedTags = {
PlayerGameMode.BEDWARS.tag,
"bedwars",
PlayerGameMode.FFA.tag,
"in_bedwars",
"ffa",
"ffa_classic",
"ffa_kits",
"ffa_sky",
"ffa_uhc",
PlayerGameMode.FOOTBALL.tag,
"in_football_game",
"duels",
PlayerGameMode.SKYWARS.tag,
PlayerGameMode.OITC.tag,
"skywars",
"oitc",
"in_oitc_game",
"in_kitroom",
NO_RANK_DISPLAY_TAG,
NO_SATURATION_TAG,
NO_FALL_DAMAGE_TAG
@@ -113,17 +92,15 @@ public class LobbyUtil {
else if (PlayerDataManager.get(minecraftPlayer).gameMode == PlayerGameMode.SKYWARS) {
SkywarsGame.leave(minecraftPlayer);
}
else if (PlayerDataManager.get(minecraftPlayer).gameMode == PlayerGameMode.FOOTBALL) {
FootballGame.leave(minecraftPlayer);
}
PlayerUtil.sendBossbar(SkywarsGame.BOSSBAR, minecraftPlayer, true);
BwScoreboard.removeScoreboardFor(minecraftPlayer);
minecraftPlayer.setGlowing(false);
minecraftPlayer.setGameMode(GameType.ADVENTURE);
for(String tag : LobbyUtil.removedTags) {
if(player.hasTag(tag)) player.removeTag(tag);
for(int i = 0; i < LobbyUtil.removedTags.length; i++){
if(player.hasTag(LobbyUtil.removedTags[i])){
player.removeTag(LobbyUtil.removedTags[i]);
}
}
returnToLobby(minecraftPlayer, tp);
@@ -131,15 +108,16 @@ public class LobbyUtil {
public static void returnToLobby(ServerPlayer minecraftPlayer, boolean tp) {
Player player = PlayerUtil.getFactoryPlayer(minecraftPlayer);
for(String tag : LobbyUtil.removedTags) {
if(player.hasTag(tag)) player.removeTag(tag);
for(int i = 0; i < LobbyUtil.removedTags.length; i++){
if(player.hasTag(LobbyUtil.removedTags[i])){
player.removeTag(LobbyUtil.removedTags[i]);
}
}
minecraftPlayer.setInvulnerable(false);
minecraftPlayer.abilities.mayfly = false;
minecraftPlayer.abilities.flying = false;
Objects.requireNonNull(minecraftPlayer.getAttribute(Attributes.KNOCKBACK_RESISTANCE)).setBaseValue(0.0);
minecraftPlayer.onUpdateAbilities();
minecraftPlayer.setGlowing(false);
@@ -150,7 +128,6 @@ public class LobbyUtil {
minecraftPlayer.inventory.setCarried(ItemStack.EMPTY);
minecraftPlayer.getEnderChestInventory().clearContent();
minecraftPlayer.setExperiencePoints(0);
minecraftPlayer.setExperienceLevels(0);
// Duels shit
player.addTag("duels");
@@ -160,11 +137,6 @@ public class LobbyUtil {
minecraftPlayer.setRespawnPosition(lobbyWorld.dimension(), lobbySpawn.toBlockPos(), lobbySpawn.yaw, true, false);
minecraftPlayer.teleportTo(lobbyWorld, lobbySpawn.x, lobbySpawn.y, lobbySpawn.z, lobbySpawn.pitch, lobbySpawn.yaw);
if(Permissions.check(minecraftPlayer, "nexia.prefix.supporter")) {
minecraftPlayer.abilities.mayfly = true;
minecraftPlayer.onUpdateAbilities();
}
LobbyUtil.giveItems(minecraftPlayer);
}
@@ -189,7 +161,7 @@ public class LobbyUtil {
ItemDisplayUtil.addLore(nameTag, "§eRight click §7to open the menu.", 0);
ItemStack queueSword = new ItemStack(Items.IRON_SWORD);
queueSword.setHoverName(new TextComponent("§eDuel Sword"));
queueSword.setHoverName(new TextComponent("§eQueue Sword"));
ItemDisplayUtil.addGlint(queueSword);
ItemDisplayUtil.addLore(queueSword, "§eRight click §7to queue menu.", 0);
ItemDisplayUtil.addLore(queueSword, "§eHit a player §7to duel them.", 1);
@@ -200,23 +172,6 @@ public class LobbyUtil {
ItemDisplayUtil.addLore(teamSword, "§eRight click §7to list the team.", 0);
ItemDisplayUtil.addLore(teamSword, "§eHit a player §7to invite them to your team.", 1);
ItemStack customDuelSword = new ItemStack(Items.DIAMOND_SWORD);
customDuelSword.setHoverName(new TextComponent("§eCustom Duel Sword"));
ItemDisplayUtil.addGlint(customDuelSword);
ItemDisplayUtil.addLore(customDuelSword, "§eHit a player §7to duel them in your custom kit.", 0);
if(Permissions.check(minecraftPlayer, "nexia.prefix.supporter")) {
ItemStack elytra = new ItemStack(Items.ELYTRA);
elytra.setHoverName(new TextComponent("§5§lSupporter Elytra"));
ItemDisplayUtil.addGlint(elytra);
elytra.getOrCreateTag().putBoolean("Unbreakable", true);
ItemDisplayUtil.addLore(elytra, "§7Thanks for supporting the server!", 0);
elytra.hideTooltipPart(ItemStack.TooltipPart.UNBREAKABLE);
minecraftPlayer.setItemSlot(EquipmentSlot.CHEST, elytra);
}
minecraftPlayer.setSlot(0, customDuelSword); // 1st slot
minecraftPlayer.setSlot(4, compass); //middle slot
minecraftPlayer.setSlot(3, nameTag); //left
minecraftPlayer.setSlot(5, queueSword); //right
@@ -224,73 +179,19 @@ public class LobbyUtil {
ItemStackUtil.sendInventoryRefreshPacket(minecraftPlayer);
}
public static boolean checkGameModeBan(Player factoryPlayer, ServerPlayer player, String game) {
ArrayList<PlayerGameMode> bannedGameModes = GamemodeBanHandler.getBannedGameModes(player);
if(bannedGameModes.isEmpty()) {
return false;
}
for(PlayerGameMode gameMode : bannedGameModes) {
if(game.toLowerCase().contains(gameMode.id.toLowerCase())) {
JSONObject banJSON = GamemodeBanHandler.getBanList(player.getStringUUID(), gameMode);
if (banJSON != null) {
LocalDateTime banTime = getBanTime((String) banJSON.get("duration"));
if(LocalDateTime.now().isAfter(banTime)) {
GamemodeBanHandler.removeBanFromList(player.getStringUUID(), gameMode);
return false;
} else {
factoryPlayer.sendMessage(
ChatFormat.nexiaMessage
.append(Component.text("You are gamemode (" + gameMode.name + ") banned for ").decoration(ChatFormat.bold, false))
.append(Component.text(BanHandler.banTimeToText(banTime)).color(ChatFormat.brandColor2).decoration(ChatFormat.bold, false))
.append(Component.text(".\nReason: ").decoration(ChatFormat.bold, false))
.append(Component.text((String) banJSON.get("reason")).color(ChatFormat.brandColor2).decoration(ChatFormat.bold, false))
);
return true;
}
} else {
factoryPlayer.sendMessage(
ChatFormat.nexiaMessage
.append(Component.text("You are gamemode (" + gameMode.name + ") banned!"))
);
}
factoryPlayer.runCommand("/hub");
return true;
}
}
return false;
}
public static void sendGame(ServerPlayer minecraftPlayer, String game, boolean message, boolean tp){
Player player = PlayerUtil.getFactoryPlayer(minecraftPlayer);
if(checkGameModeBan(player, minecraftPlayer, game)) {
return;
}
minecraftPlayer.setInvulnerable(false);
minecraftPlayer.abilities.mayfly = false;
minecraftPlayer.onUpdateAbilities();
if((game.equalsIgnoreCase("classic ffa") && !FfaClassicUtil.canGoToSpawn(minecraftPlayer)) ||
(game.equalsIgnoreCase("kits ffa") && !FfaKitsUtil.canGoToSpawn(minecraftPlayer) ||
(game.equalsIgnoreCase("sky ffa") && !FfaSkyUtil.canGoToSpawn(minecraftPlayer) ||
(game.equalsIgnoreCase("uhc ffa") && !FfaUhcUtil.canGoToSpawn(minecraftPlayer))))) {
if((game.equalsIgnoreCase("classic ffa") && !FfaClassicUtil.canGoToSpawn(minecraftPlayer)) || (game.equalsIgnoreCase("kits ffa") && !FfaKitsUtil.canGoToSpawn(minecraftPlayer))) {
player.sendMessage(Component.text("You must be fully healed to go to spawn!").color(ChatFormat.failColor));
return;
}
if(player.hasTag("duels")) {
player.removeTag("duels");
DuelGameHandler.leave(minecraftPlayer, true);
}
DuelGameHandler.leave(minecraftPlayer, true);
if (!LobbyUtil.isLobbyWorld(minecraftPlayer.getLevel())) {
LobbyUtil.leaveAllGames(minecraftPlayer, false);
@@ -310,11 +211,8 @@ public class LobbyUtil {
player.removeTag(LobbyUtil.NO_SATURATION_TAG);
}
if(game.equalsIgnoreCase("classic ffa") ||
game.equalsIgnoreCase("kits ffa") ||
game.equalsIgnoreCase("sky ffa") ||
game.equalsIgnoreCase("uhc ffa")) {
player.addTag(FfaUtil.FFA_TAG);
if(game.equalsIgnoreCase("classic ffa") || game.equalsIgnoreCase("kits ffa")) {
player.addTag("ffa");
PlayerDataManager.get(minecraftPlayer).gameMode = PlayerGameMode.FFA;
if(message){ player.sendActionBarMessage(Component.text("You have joined §8🗡 §7§lFFA §b🔱")); }
}
@@ -332,31 +230,6 @@ public class LobbyUtil {
FfaClassicUtil.setInventory(minecraftPlayer);
}
if(game.equalsIgnoreCase("sky ffa")){
player.addTag("ffa_sky");
FfaSkyUtil.wasInSpawn.add(player.getUUID());
PlayerDataManager.get(minecraftPlayer).ffaGameMode = FfaGameMode.SKY;
if(tp){
FfaSkyUtil.sendToSpawn(minecraftPlayer);
minecraftPlayer.setRespawnPosition(com.nexia.ffa.sky.utilities.FfaAreas.ffaWorld.dimension(), com.nexia.ffa.sky.utilities.FfaAreas.spawn.toBlockPos(), com.nexia.ffa.sky.utilities.FfaAreas.spawn.yaw, true, false);
}
FfaSkyUtil.joinOrRespawn(minecraftPlayer);
}
if(game.equalsIgnoreCase("uhc ffa")){
player.addTag("ffa_uhc");
FfaUhcUtil.wasInSpawn.add(player.getUUID());
PlayerDataManager.get(minecraftPlayer).ffaGameMode = FfaGameMode.UHC;
if(tp){
FfaUhcUtil.sendToSpawn(minecraftPlayer);
minecraftPlayer.setRespawnPosition(com.nexia.ffa.uhc.utilities.FfaAreas.ffaWorld.dimension(), com.nexia.ffa.uhc.utilities.FfaAreas.spawn.toBlockPos(), com.nexia.ffa.uhc.utilities.FfaAreas.spawn.yaw, true, false);
}
FfaUhcUtil.clearArrows(minecraftPlayer);
FfaUhcUtil.clearTrident(minecraftPlayer);
}
if(game.equalsIgnoreCase("kits ffa")){
player.addTag("ffa_kits");
FfaKitsUtil.wasInSpawn.add(player.getUUID());
@@ -368,7 +241,6 @@ public class LobbyUtil {
FfaKitsUtil.clearThrownTridents(minecraftPlayer);
FfaKitsUtil.clearArrows(minecraftPlayer);
FfaKitsUtil.clearSpectralArrows(minecraftPlayer);
}
if(game.equalsIgnoreCase("bedwars")){
@@ -389,7 +261,7 @@ public class LobbyUtil {
}
if(game.equalsIgnoreCase("oitc")){
player.addTag(OitcGame.OITC_TAG);
player.addTag("oitc");
PlayerDataManager.get(minecraftPlayer).gameMode = PlayerGameMode.OITC;
OitcGame.death(minecraftPlayer, minecraftPlayer.getLastDamageSource());
@@ -400,19 +272,8 @@ public class LobbyUtil {
if(message){player.sendActionBarMessage(Component.text("You have joined §7\uD83D\uDDE1 §f§lOITC §7\uD83C\uDFF9"));}
}
if(game.equalsIgnoreCase("football")){
player.addTag(FootballGame.FOOTBALL_TAG);
PlayerDataManager.get(minecraftPlayer).gameMode = PlayerGameMode.FOOTBALL;
com.nexia.minigames.games.football.util.player.PlayerDataManager.get(minecraftPlayer).gameMode = FootballGameMode.LOBBY;
FootballGame.joinQueue(minecraftPlayer);
if(message){player.sendActionBarMessage(Component.text("You have joined §7○ §7§lFootball §7\uD83D\uDDE1"));}
}
if(game.equalsIgnoreCase("skywars")){
player.addTag(PlayerGameMode.SKYWARS.tag);
player.addTag("skywars");
PlayerDataManager.get(minecraftPlayer).gameMode = PlayerGameMode.SKYWARS;
SkywarsGame.death(minecraftPlayer, minecraftPlayer.getLastDamageSource());
@@ -1,53 +1,19 @@
package com.nexia.core.games.util;
import com.nexia.ffa.FfaUtil;
import com.nexia.minigames.games.bedwars.players.BwPlayers;
import com.nexia.minigames.games.football.FootballGame;
import com.nexia.minigames.games.oitc.OitcGame;
import com.nexia.minigames.games.skywars.SkywarsGame;
import org.jetbrains.annotations.NotNull;
import java.util.ArrayList;
public class PlayerGameMode {
public static ArrayList<PlayerGameMode> playerGameModes = new ArrayList<>();
String id;
public static ArrayList<String> stringPlayerGameModes = new ArrayList<>();
public static final PlayerGameMode LOBBY = new PlayerGameMode("lobby");
public static final PlayerGameMode BEDWARS = new PlayerGameMode("bedwars");
public String id;
public String name;
public String tag;
public static final PlayerGameMode LOBBY = new PlayerGameMode("lobby", "Hub", LobbyUtil.NO_DAMAGE_TAG);
public static final PlayerGameMode BEDWARS = new PlayerGameMode("bedwars", "Bedwars", BwPlayers.BED_WARS_IN_GAME_TAG);
public static final PlayerGameMode SKYWARS = new PlayerGameMode("skywars", "Skywars", SkywarsGame.SKYWARS_TAG);
public static final PlayerGameMode OITC = new PlayerGameMode("oitc", "OITC", OitcGame.OITC_TAG);
public static final PlayerGameMode FFA = new PlayerGameMode("ffa", "FFA", FfaUtil.FFA_TAG);
public static final PlayerGameMode FOOTBALL = new PlayerGameMode("football", "Football", FootballGame.FOOTBALL_TAG);
public static final PlayerGameMode SKYWARS = new PlayerGameMode("skywars");
public static final PlayerGameMode OITC = new PlayerGameMode("oitc");
public static final PlayerGameMode FFA = new PlayerGameMode("ffa");
//public static final PlayerGameMode DUELS = new PlayerGameMode("duels");
PlayerGameMode(String id, String name, String tag) {
PlayerGameMode(String id) {
this.id = id;
this.name = name;
this.tag = tag;
if(id.equals("lobby")) return;
PlayerGameMode.playerGameModes.add(this);
PlayerGameMode.stringPlayerGameModes.add(id);
}
public static PlayerGameMode identifyGamemode(@NotNull String gameMode) {
for(PlayerGameMode playerGameMode : PlayerGameMode.playerGameModes) {
if(playerGameMode.id.equalsIgnoreCase(gameMode)) return playerGameMode;
}
return null;
}
}
+21 -54
View File
@@ -7,7 +7,6 @@ import com.nexia.ffa.classic.utilities.FfaAreas;
import com.nexia.minigames.games.bedwars.areas.BwAreas;
import com.nexia.minigames.games.duels.DuelGameMode;
import com.nexia.minigames.games.duels.util.player.PlayerDataManager;
import com.nexia.minigames.games.football.FootballGame;
import com.nexia.minigames.games.oitc.OitcGame;
import com.nexia.minigames.games.skywars.SkywarsGame;
import eu.pb4.sgui.api.ClickType;
@@ -36,8 +35,6 @@ public class PlayGUI extends SimpleGui {
int players = FfaAreas.ffaWorld.players().size();
players = players + com.nexia.ffa.kits.utilities.FfaAreas.ffaWorld.players().size();
players = players + com.nexia.ffa.sky.utilities.FfaAreas.ffaWorld.players().size();
players = players + com.nexia.ffa.uhc.utilities.FfaAreas.ffaWorld.players().size();
ItemStack ffa = new ItemStack(Items.NETHERITE_SWORD, 1);
ffa.setHoverName(new TextComponent("§3FFA"));
@@ -108,55 +105,54 @@ public class PlayGUI extends SimpleGui {
this.setSlot(8, bedwars);
}
public void setFFALayout(){
ItemStack classic = new ItemStack(Items.DIAMOND_SWORD, 1);
classic.setHoverName(new TextComponent("§bClassic FFA"));
private void setFFALayout(){
ItemStack classic = new ItemStack(Items.NETHERITE_SWORD, 1);
classic.setHoverName(new TextComponent("§cClassic FFA"));
ItemDisplayUtil.addGlint(classic);
classic.hideTooltipPart(ItemStack.TooltipPart.MODIFIERS);
ItemDisplayUtil.addLore(classic, "§b", 0);
ItemDisplayUtil.addLore(classic, "§5", 0);
ItemDisplayUtil.addLore(classic, "§7The classic snapshot", 1);
ItemDisplayUtil.addLore(classic, "§7Free For All gamemode.", 2);
ItemDisplayUtil.addLore(classic, "§f", 3);
ItemDisplayUtil.addLore(classic, "§b◆ There are " + FfaAreas.ffaWorld.players().size() + " people playing this gamemode.", 4);
ItemDisplayUtil.addLore(classic, "§c◆ There are " + FfaAreas.ffaWorld.players().size() + " people playing this gamemode.", 4);
ItemStack kit = new ItemStack(Items.CROSSBOW, 1);
kit.setHoverName(new TextComponent("§fKit FFA"));
ItemDisplayUtil.addGlint(kit);
ItemStack kit = new ItemStack(Items.DIAMOND_SWORD, 1);
kit.setHoverName(new TextComponent("§bKit FFA"));
ItemDisplayUtil.addGlint(classic);
kit.hideTooltipPart(ItemStack.TooltipPart.MODIFIERS);
ItemDisplayUtil.addLore(kit, "§5", 0);
ItemDisplayUtil.addLore(kit, "§7Fight against players", 1);
ItemDisplayUtil.addLore(kit, "§7with various kits!", 2);
ItemDisplayUtil.addLore(kit, "§f", 3);
ItemDisplayUtil.addLore(kit, "§f◆ There are " + com.nexia.ffa.kits.utilities.FfaAreas.ffaWorld.players().size() + " people playing this gamemode.", 4);
ItemDisplayUtil.addLore(kit, "§b◆ There are " + com.nexia.ffa.kits.utilities.FfaAreas.ffaWorld.players().size() + " people playing this gamemode.", 4);
ItemStack pot = new ItemStack(Items.POTION, 1);
pot.setHoverName(new TextComponent("§eSky FFA"));
pot.getOrCreateTag().putInt("CustomPotionColor", 16771584);
pot.setHoverName(new TextComponent("§dPot FFA"));
ItemDisplayUtil.addGlint(pot);
pot.hideTooltipPart(ItemStack.TooltipPart.MODIFIERS);
ItemDisplayUtil.addLore(pot, "§5", 0);
ItemDisplayUtil.addLore(pot, "§7Fight people on sky islands", 1);
ItemDisplayUtil.addLore(pot, "§7and drink Piss Juice™ to survive!", 2);
ItemDisplayUtil.addLore(pot, "§7The classic snapshot", 1);
ItemDisplayUtil.addLore(pot, "§7Free For All gamemodes.", 2);
ItemDisplayUtil.addLore(pot, "§5", 3);
ItemDisplayUtil.addLore(pot, "§e◆ There are " + com.nexia.ffa.sky.utilities.FfaAreas.ffaWorld.players().size() + " people playing this gamemode.", 4);
ItemDisplayUtil.addLore(pot, "§d◆ There are " + com.nexia.ffa.kits.utilities.FfaAreas.ffaWorld.players().size() + " people playing this gamemode.", 4);
ItemStack uhc = new ItemStack(Items.GOLDEN_APPLE, 1);
uhc.setHoverName(new TextComponent("§6UHC FFA"));
ItemDisplayUtil.addGlint(uhc);
ItemDisplayUtil.addGlint(classic);
uhc.hideTooltipPart(ItemStack.TooltipPart.MODIFIERS);
ItemDisplayUtil.addLore(uhc, "§5", 0);
ItemDisplayUtil.addLore(uhc, "§7An FFA to practice pvp", 1);
ItemDisplayUtil.addLore(uhc, "§7for the UHC gamemode.", 2);
ItemDisplayUtil.addLore(uhc, "§7The classic snapshot", 1);
ItemDisplayUtil.addLore(uhc, "§7Free For All gamemodes.", 2);
ItemDisplayUtil.addLore(uhc, "§f", 3);
ItemDisplayUtil.addLore(uhc, "§6◆ There are " + com.nexia.ffa.uhc.utilities.FfaAreas.ffaWorld.players().size() + " people playing this gamemode.", 4);
ItemDisplayUtil.addLore(uhc, "§6◆ There are " + com.nexia.ffa.kits.utilities.FfaAreas.ffaWorld.players().size() + " people playing this gamemode.", 4);
@@ -197,23 +193,11 @@ public class PlayGUI extends SimpleGui {
ItemStack emptySlot = new ItemStack(Items.BLACK_STAINED_GLASS_PANE, 1);
emptySlot.setHoverName(new TextComponent(""));
ItemStack football = new ItemStack(Items.ARMOR_STAND, 1);
football.setHoverName(new TextComponent("§fFootball"));
ItemDisplayUtil.addGlint(football);
football.hideTooltipPart(ItemStack.TooltipPart.MODIFIERS);
ItemDisplayUtil.addLore(football, "§f", 0);
ItemDisplayUtil.addLore(football, "§7Also known as soccer.", 1);
ItemDisplayUtil.addLore(football, "§7You kick a ball into a goal", 2);
ItemDisplayUtil.addLore(football, "§7to achieve victory!", 3);
ItemDisplayUtil.addLore(football, "§f", 4);
ItemDisplayUtil.addLore(football, "§f◆ There are " + FootballGame.world.players().size() + " people playing this gamemode.", 5);
fillEmptySlots(emptySlot);
this.setSlot(2, oitc);
this.setSlot(4, back);
this.setSlot(6, football);
this.setSlot(6, unknown);
this.setSlot(0, unknown);
this.setSlot(8, unknown);
}
@@ -223,26 +207,16 @@ public class PlayGUI extends SimpleGui {
if(element != null && clickType != ClickType.MOUSE_DOUBLE_CLICK) {
ItemStack itemStack = element.getItemStack();
Component name = itemStack.getHoverName();
if(name.getString().equalsIgnoreCase("§bClassic FFA")){
if(name.getString().equalsIgnoreCase("§cClassic FFA")){
LobbyUtil.sendGame(this.player, "classic ffa", true, true);
this.close();
}
if(name.getString().equalsIgnoreCase("§fKit FFA")){
if(name.getString().equalsIgnoreCase("§bKit FFA")){
LobbyUtil.sendGame(this.player, "kits ffa", true, true);
this.close();
}
if(name.getString().equalsIgnoreCase("§eSky FFA")){
LobbyUtil.sendGame(this.player, "sky ffa", true, true);
this.close();
}
if(name.getString().equalsIgnoreCase("§6UHC FFA")){
LobbyUtil.sendGame(this.player, "uhc ffa", true, true);
this.close();
}
if(name.getString().equalsIgnoreCase("§3FFA")){
this.setFFALayout();
}
@@ -262,11 +236,6 @@ public class PlayGUI extends SimpleGui {
this.close();
}
if(name.getString().equalsIgnoreCase("§fFootball")){
LobbyUtil.sendGame(this.player, "football", true, true);
this.close();
}
if(name.getString().equalsIgnoreCase("§9Duels")){
LobbyUtil.sendGame(this.player, "duels", true, true);
this.close();
@@ -286,12 +255,10 @@ public class PlayGUI extends SimpleGui {
}
return super.click(index, clickType, action);
}
public static PlayGUI openMainGUI(ServerPlayer player) {
public static void openMainGUI(ServerPlayer player) {
PlayGUI shop = new PlayGUI(MenuType.GENERIC_9x1, player, false);
shop.setTitle(title);
shop.setMainLayout();
shop.open();
return shop;
}
}
+22 -27
View File
@@ -1,22 +1,19 @@
package com.nexia.core.gui;
import com.combatreforged.factory.api.world.entity.player.Player;
import com.combatreforged.factory.builder.implementation.util.ObjectMappings;
import com.combatreforged.metis.api.world.entity.player.Player;
import com.nexia.core.Main;
import com.nexia.core.utilities.chat.ChatFormat;
import com.nexia.core.utilities.item.ItemDisplayUtil;
import com.nexia.core.utilities.player.PlayerUtil;
import com.nexia.core.utilities.ranks.NexiaRank;
import eu.pb4.sgui.api.ClickType;
import eu.pb4.sgui.api.elements.GuiElementInterface;
import eu.pb4.sgui.api.gui.SimpleGui;
import me.lucko.fabric.api.permissions.v0.Permissions;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.format.NamedTextColor;
import net.minecraft.ChatFormatting;
import net.minecraft.network.chat.TextComponent;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.world.inventory.MenuType;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.Items;
import net.minecraft.world.item.enchantment.Enchantments;
public class PrefixGUI extends SimpleGui {
static final TextComponent title = new TextComponent("Prefix Menu");
@@ -49,28 +46,28 @@ public class PrefixGUI extends SimpleGui {
this.setSlot(airSlots, new ItemStack(Items.AIR));
airSlots++;
}
for(NexiaRank rank : NexiaRank.ranks){
for(int i = 0; i < 10; i++){
if(slot == 17) {
slot = 19;
}
if(Permissions.check(player, "nexia.prefix." + rank.id) && player.getTags().contains(rank.id)){
if(PlayerUtil.hasPermission(player.createCommandSourceStack(), "nexia.prefix." + Main.config.ranks[i], 4) && player.getTags().contains(Main.config.ranks[i])){
ItemStack enchantedItem = new ItemStack(Items.NAME_TAG, 1);
ItemDisplayUtil.addGlint(enchantedItem);
enchantedItem.setHoverName(ObjectMappings.convertComponent(Component.text(rank.name, ChatFormat.brandColor2).decoration(ChatFormat.italic, false).decoration(ChatFormat.bold, true)));
enchantedItem.enchant(Enchantments.SHARPNESS, 1);
enchantedItem.hideTooltipPart(ItemStack.TooltipPart.ENCHANTMENTS);
enchantedItem.setHoverName(new TextComponent("§d§l" + Main.config.ranks[i]));
this.setSlot(slot, enchantedItem);
slot++;
} else if(Permissions.check(player, "nexia.prefix." + rank.id)){
} else if(PlayerUtil.hasPermission(player.createCommandSourceStack(), "nexia.prefix." + Main.config.ranks[i], 4)){
ItemStack changedItem = new ItemStack(Items.NAME_TAG, 1);
changedItem.setHoverName(ObjectMappings.convertComponent(Component.text(rank.name, NamedTextColor.WHITE).decoration(ChatFormat.italic, false).decoration(ChatFormat.bold, true)));
changedItem.setHoverName(new TextComponent("§f" + Main.config.ranks[i]));
this.setSlot(slot, changedItem);
slot++;
} else if(player.getTags().contains(rank.id)) {
} else if(player.getTags().contains(Main.config.ranks[i])) {
ItemStack enchantedItem = new ItemStack(Items.NAME_TAG, 1);
ItemDisplayUtil.addGlint(enchantedItem);
enchantedItem.setHoverName(ObjectMappings.convertComponent(Component.text(rank.name, ChatFormat.brandColor2).decoration(ChatFormat.italic, false).decoration(ChatFormat.bold, true)));
enchantedItem.enchant(Enchantments.SHARPNESS, 1);
enchantedItem.hideTooltipPart(ItemStack.TooltipPart.ENCHANTMENTS);
enchantedItem.setHoverName(new TextComponent(Main.config.ranks[i]).withStyle(ChatFormatting.BOLD, ChatFormatting.LIGHT_PURPLE));
this.setSlot(slot, enchantedItem);
slot++;
}
@@ -81,7 +78,7 @@ public class PrefixGUI extends SimpleGui {
GuiElementInterface element = this.getSlot(index);
if(element != null && clickType != ClickType.MOUSE_DOUBLE_CLICK) {
ItemStack itemStack = element.getItemStack();
String name = itemStack.getHoverName().getString();
String name = itemStack.getHoverName().getString().substring(2).replaceAll("§l", "");
if(itemStack.getItem() != Items.BLACK_STAINED_GLASS_PANE && itemStack.getItem() != Items.AIR){
@@ -89,17 +86,15 @@ public class PrefixGUI extends SimpleGui {
player.sendMessage(
ChatFormat.nexiaMessage
.append(net.kyori.adventure.text.Component.text("Your prefix has been set to: ").color(ChatFormat.normalColor).decoration(ChatFormat.bold, false))
.append(net.kyori.adventure.text.Component.text(name).color(ChatFormat.brandColor2).decoration(ChatFormat.bold, false))
.append(net.kyori.adventure.text.Component.text(".").decoration(ChatFormat.bold, false))
.append(net.kyori.adventure.text.Component.text("Your prefix has been set to: ").color(ChatFormat.normalColor).decoration(ChatFormat.bold, false))
.append(net.kyori.adventure.text.Component.text(name).color(ChatFormat.brandColor2).decoration(ChatFormat.bold, false))
.append(net.kyori.adventure.text.Component.text(".").decoration(ChatFormat.bold, false))
);
for(NexiaRank rank : NexiaRank.ranks){
player.removeTag(rank.id);
for(int i = 0; i < 10; i++){
player.removeTag(Main.config.ranks[i]);
}
if(name.equalsIgnoreCase("player")) name = "default";
player.addTag(name.toLowerCase());
this.setMainLayout(this.player);
}
@@ -113,4 +108,4 @@ public class PrefixGUI extends SimpleGui {
shop.setMainLayout(player);
shop.open();
}
}
}
@@ -1,6 +1,6 @@
package com.nexia.core.gui;
import com.combatreforged.factory.api.world.entity.player.Player;
import com.combatreforged.metis.api.world.entity.player.Player;
import com.nexia.core.utilities.chat.ChatFormat;
import com.nexia.core.utilities.item.ItemDisplayUtil;
import com.nexia.core.utilities.player.PlayerUtil;
@@ -1,168 +0,0 @@
package com.nexia.core.gui.duels;
import com.nexia.core.utilities.item.InventoryUtil;
import com.nexia.core.utilities.item.ItemDisplayUtil;
import com.nexia.core.utilities.player.PlayerUtil;
import com.nexia.minigames.games.duels.gamemodes.GamemodeHandler;
import com.nexia.minigames.games.duels.map.DuelsMap;
import eu.pb4.sgui.api.ClickType;
import eu.pb4.sgui.api.elements.GuiElementInterface;
import eu.pb4.sgui.api.gui.SimpleGui;
import net.minecraft.ChatFormatting;
import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.TextComponent;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.world.inventory.MenuType;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.Items;
import java.util.ArrayList;
public class CustomDuelGUI extends SimpleGui {
static final TextComponent title = new TextComponent("Custom Duel Menu");
ServerPlayer other;
String kit;
public CustomDuelGUI(MenuType<?> type, ServerPlayer player, boolean includePlayer) {
super(type, player, includePlayer);
this.other = null;
this.kit = "";
}
private void fillEmptySlots(ItemStack itemStack){
for(int i = 0; i < 45; i++){
this.setSlot(i, itemStack);
}
}
private void setMapLayout(){
ItemStack emptySlot = new ItemStack(Items.BLACK_STAINED_GLASS_PANE, 1);
emptySlot.setHoverName(new TextComponent(""));
fillEmptySlots(emptySlot);
int slot = 10;
int airSlots = 10;
for(int air = 0; air < 21; air++){
if(airSlots == 17) {
airSlots = 19;
}
if(airSlots == 26) {
airSlots = 28;
}
this.setSlot(airSlots, new ItemStack(Items.AIR));
airSlots++;
}
for(DuelsMap map : DuelsMap.duelsMaps){
this.setSlot(slot, map.item.setHoverName(new TextComponent("§f" + map.id)));
slot++;
}
}
private void setMainLayout(ServerPlayer otherp){
ItemStack emptySlot = new ItemStack(Items.BLACK_STAINED_GLASS_PANE, 1);
emptySlot.setHoverName(new TextComponent(""));
this.other = otherp;
fillEmptySlots(emptySlot);
int slot = 10;
int airSlots = 10;
for(int air = 0; air < 21; air++){
if(airSlots == 17) {
airSlots = 19;
}
if(airSlots == 26) {
airSlots = 28;
}
this.setSlot(airSlots, new ItemStack(Items.AIR));
airSlots++;
}
//this.setSlot(4, HeadFunctions.getPlayerHead(otherp.getScoreboardName(), 1));
ItemStack playerHead = PlayerUtil.getPlayerHead(otherp.getUUID());
playerHead.setHoverName(new TextComponent(otherp.getScoreboardName()).withStyle(ChatFormatting.BOLD));
this.setSlot(4, playerHead);
ArrayList<String> inventories = InventoryUtil.getListOfInventories("duels/custom/" + this.player.getStringUUID());
ItemStack item;
if(inventories.isEmpty()) {
item = new ItemStack(Items.COMMAND_BLOCK);
ItemDisplayUtil.removeLore(item, 0);
ItemDisplayUtil.removeLore(item, 1);
ItemDisplayUtil.addLore(item, "§eUse §e§l/kiteditor edit §eto edit/create a custom kit!", 0);
ItemDisplayUtil.addGlint(item);
item.setHoverName(new TextComponent("§fNo kits!"));
this.setSlot(slot, item);
return;
}
for(String inventory : inventories){
if(slot == 17) {
slot = 19;
}
if(slot == 26) {
slot = 28;
}
item = new ItemStack(Items.BARRIER);
ItemDisplayUtil.removeLore(item, 0);
ItemDisplayUtil.removeLore(item, 1);
if(inventory.equalsIgnoreCase("vanilla")) {
item = new ItemStack(Items.RESPAWN_ANCHOR);
ItemDisplayUtil.addLore(item, "§e§lINFO: §eThis kit is a §e§lper-custom §ekit.", 0);
}
else if(inventory.equalsIgnoreCase("smp")) {
item = new ItemStack(Items.DIAMOND_CHESTPLATE);
ItemDisplayUtil.addLore(item, "§e§lINFO: §eThis kit is a §e§lper-custom §ekit.", 0);
}
ItemDisplayUtil.addGlint(item);
item.setHoverName(new TextComponent("§f" + inventory.toUpperCase().replaceAll("_", " ")));
this.setSlot(slot, item);
slot++;
}
}
public boolean click(int index, ClickType clickType, net.minecraft.world.inventory.ClickType action){
GuiElementInterface element = this.getSlot(index);
if(element != null && clickType != ClickType.MOUSE_DOUBLE_CLICK) {
ItemStack itemStack = element.getItemStack();
Component name = itemStack.getHoverName();
if(itemStack.getItem() != Items.BLACK_STAINED_GLASS_PANE && itemStack.getItem() != Items.AIR && itemStack.getItem() != Items.PLAYER_HEAD && itemStack.getItem() != Items.COMMAND_BLOCK){
if(InventoryUtil.getListOfInventories("duels/custom/" + this.player.getStringUUID()).contains(name.getString().toLowerCase().substring(2).replaceAll(" ", "_"))){
this.kit = name.getString().toLowerCase().substring(2).replaceAll(" ", "_");
setMapLayout();
} else {
GamemodeHandler.customChallengePlayer(this.player, this.other, this.kit, DuelsMap.identifyMap(name.getString().substring(2)));
this.close();
}
}
}
return super.click(index, clickType, action);
}
public static int openDuelGui(ServerPlayer player, ServerPlayer other) {
CustomDuelGUI shop = new CustomDuelGUI(MenuType.GENERIC_9x5, player, false);
shop.setTitle(title);
shop.setMainLayout(other);
shop.open();
return 1;
}
}
@@ -1,14 +1,12 @@
package com.nexia.core.gui.duels;
import com.nexia.core.utilities.item.ItemDisplayUtil;
import com.nexia.core.utilities.player.PlayerUtil;
import com.nexia.minigames.games.duels.DuelGameMode;
import com.nexia.minigames.games.duels.gamemodes.GamemodeHandler;
import com.nexia.minigames.games.duels.map.DuelsMap;
import com.nexia.minigames.games.duels.gamemodes.GamemodeHandler;
import eu.pb4.sgui.api.ClickType;
import eu.pb4.sgui.api.elements.GuiElementInterface;
import eu.pb4.sgui.api.gui.SimpleGui;
import net.minecraft.ChatFormatting;
import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.TextComponent;
import net.minecraft.server.level.ServerPlayer;
@@ -17,6 +15,8 @@ import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.Items;
import net.minecraft.world.level.GameType;
import java.util.Arrays;
public class DuelGUI extends SimpleGui {
static final TextComponent title = new TextComponent("Duel Menu");
@@ -53,7 +53,7 @@ public class DuelGUI extends SimpleGui {
airSlots++;
}
for(DuelsMap map : DuelsMap.duelsMaps){
if(gameMode.gameMode == GameType.ADVENTURE && !map.isAdventureSupported) continue;
if(gameMode.gameMode == GameType.ADVENTURE && !map.isAdventureSupported) return;
this.setSlot(slot, map.item.setHoverName(new TextComponent("§f" + map.id)));
slot++;
}
@@ -78,14 +78,7 @@ public class DuelGUI extends SimpleGui {
this.setSlot(airSlots, new ItemStack(Items.AIR));
airSlots++;
}
//this.setSlot(4, HeadFunctions.getPlayerHead(otherp.getScoreboardName(), 1));
ItemStack playerHead = PlayerUtil.getPlayerHead(otherp.getUUID());
playerHead.setHoverName(new TextComponent(otherp.getScoreboardName()).withStyle(ChatFormatting.BOLD));
this.setSlot(4, playerHead);
int i1 = 0;
ItemStack item;
for(String duel : DuelGameMode.stringDuelGameModes){
@@ -98,7 +91,6 @@ public class DuelGUI extends SimpleGui {
item = DuelGameMode.duelsItems.get(i1).setHoverName(new TextComponent("§f" + duel.toUpperCase().replaceAll("_", " ")));
ItemDisplayUtil.removeLore(item, 0);
ItemDisplayUtil.removeLore(item, 1);
this.setSlot(slot, item);
slot++;
i1++;
@@ -111,7 +103,7 @@ public class DuelGUI extends SimpleGui {
ItemStack itemStack = element.getItemStack();
Component name = itemStack.getHoverName();
if(itemStack.getItem() != Items.BLACK_STAINED_GLASS_PANE && itemStack.getItem() != Items.AIR && itemStack.getItem() != Items.PLAYER_HEAD){
if(itemStack.getItem() != Items.BLACK_STAINED_GLASS_PANE && itemStack.getItem() != Items.AIR){
if(DuelGameMode.stringDuelGameModes.contains(name.getString().substring(2).replaceAll(" ", "_"))){
this.kit = name.getString().substring(2).replaceAll(" ", "_");
setMapLayout(GamemodeHandler.identifyGamemode(this.kit));
@@ -2,6 +2,8 @@ package com.nexia.core.gui.duels;
import com.nexia.core.games.util.LobbyUtil;
import com.nexia.core.utilities.item.ItemDisplayUtil;
import com.nexia.core.utilities.item.ItemStackUtil;
import com.nexia.core.utilities.player.PlayerUtil;
import com.nexia.minigames.games.duels.DuelGameMode;
import com.nexia.minigames.games.duels.gamemodes.GamemodeHandler;
import eu.pb4.sgui.api.ClickType;
@@ -13,6 +15,7 @@ import net.minecraft.server.level.ServerPlayer;
import net.minecraft.world.inventory.MenuType;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.Items;
import org.apache.commons.lang3.StringUtils;
public class QueueGUI extends SimpleGui {
static final TextComponent title = new TextComponent("Queue Menu");
@@ -1,6 +1,6 @@
package com.nexia.core.gui.ffa;
import com.combatreforged.factory.api.world.entity.player.Player;
import com.combatreforged.metis.api.world.entity.player.Player;
import com.nexia.core.utilities.chat.ChatFormat;
import com.nexia.core.utilities.player.PlayerUtil;
import com.nexia.ffa.kits.FfaKit;
@@ -1,6 +1,6 @@
package com.nexia.core.gui.ffa;
import com.combatreforged.factory.api.world.entity.player.Player;
import com.combatreforged.metis.api.world.entity.player.Player;
import com.nexia.core.utilities.chat.ChatFormat;
import com.nexia.core.utilities.item.ItemDisplayUtil;
import com.nexia.core.utilities.player.PlayerUtil;
@@ -1,6 +1,6 @@
package com.nexia.core.listeners;
import com.nexia.core.listeners.factory.*;
import com.nexia.core.listeners.metis.*;
public class ListenerHelper {
public static void registerListeners() {
@@ -9,6 +9,8 @@ public class ListenerHelper {
PlayerLeaveListener.registerListener();
UseItemListener.registerListener();
PlayerDropItemListener.registerListener();
PlayerFoodLevelsChangeListener.registerListener();
PlayerInteractBlockListener.registerListener();
PlayerRespawnListener.registerListener();
}
}
@@ -1,24 +0,0 @@
package com.nexia.core.listeners.factory;
import com.combatreforged.factory.api.event.player.PlayerHotbarDropItemEvent;
import com.combatreforged.factory.api.world.entity.player.Player;
import com.nexia.core.utilities.item.ItemStackUtil;
import com.nexia.core.utilities.misc.EventUtil;
import com.nexia.core.utilities.player.PlayerUtil;
import net.minecraft.server.level.ServerPlayer;
public class PlayerDropItemListener {
public static void registerListener(){
PlayerHotbarDropItemEvent.BACKEND.register(playerDropItemEvent -> {
Player player = playerDropItemEvent.getPlayer();
ServerPlayer minecraftPlayer = PlayerUtil.getMinecraftPlayer(player);
if (!EventUtil.dropItem(minecraftPlayer, playerDropItemEvent.getItemStack())) {
playerDropItemEvent.setCancelled(true);
ItemStackUtil.sendInventoryRefreshPacket(minecraftPlayer);
return;
}
});
}
}
@@ -1,140 +0,0 @@
package com.nexia.core.listeners.factory;
import com.combatreforged.factory.api.event.player.PlayerRespawnEvent;
import com.combatreforged.factory.api.util.Identifier;
import com.combatreforged.factory.api.world.entity.player.Player;
import com.combatreforged.factory.api.world.types.Minecraft;
import com.combatreforged.factory.api.world.util.Location;
import com.nexia.core.games.util.LobbyUtil;
import com.nexia.core.games.util.PlayerGameMode;
import com.nexia.core.utilities.player.PlayerUtil;
import com.nexia.core.utilities.time.ServerTime;
import com.nexia.minigames.games.duels.DuelsGame;
import com.nexia.minigames.games.duels.custom.CustomDuelsGame;
import com.nexia.minigames.games.duels.custom.team.CustomTeamDuelsGame;
import com.nexia.minigames.games.duels.team.TeamDuelsGame;
import com.nexia.minigames.games.duels.util.player.PlayerData;
import com.nexia.minigames.games.duels.util.player.PlayerDataManager;
import com.nexia.minigames.games.skywars.SkywarsGame;
import com.nexia.minigames.games.skywars.SkywarsGameMode;
import com.nexia.core.utilities.world.WorldUtil;
import net.minecraft.server.level.ServerPlayer;
import java.util.Random;
public class PlayerRespawnListener {
public static void registerListener(){
PlayerRespawnEvent.BACKEND.register((respawnEvent) -> {
Player factoryPlayer = respawnEvent.getPlayer();
if(factoryPlayer == null && respawnEvent.getEntity() instanceof Player) {
factoryPlayer = (Player) respawnEvent.getEntity();
}
if(factoryPlayer == null) return;
ServerPlayer player = ServerTime.minecraftServer.getPlayerList().getPlayer(factoryPlayer.getUUID());
if(player == null) return;
PlayerData duelsData = PlayerDataManager.get(player);
com.nexia.core.utilities.player.PlayerData data = com.nexia.core.utilities.player.PlayerDataManager.get(player);
if(duelsData.gameOptions == null) return;
DuelsGame duelsGame = duelsData.gameOptions.duelsGame;
TeamDuelsGame teamDuelsGame = duelsData.gameOptions.teamDuelsGame;
CustomDuelsGame customDuelsGame = duelsData.gameOptions.customDuelsGame;
CustomTeamDuelsGame customTeamDuelsGame = duelsData.gameOptions.customTeamDuelsGame;
if(data.gameMode == PlayerGameMode.SKYWARS) {
Location respawn = new Location(0,100, 0, WorldUtil.getWorld(SkywarsGame.world));
boolean isPlaying = com.nexia.minigames.games.skywars.util.player.PlayerDataManager.get(player).gameMode == SkywarsGameMode.PLAYING;
ServerPlayer serverPlayer = PlayerUtil.getPlayerAttacker(player);
if(serverPlayer != null && serverPlayer != player && isPlaying) {
respawn.setX(serverPlayer.getX());
respawn.setY(serverPlayer.getY());
respawn.setZ(serverPlayer.getZ());
}
respawnEvent.setRespawnMode(Minecraft.GameMode.SPECTATOR);
respawnEvent.setSpawnpoint(respawn);
return;
}
if(duelsGame != null && duelsGame.isEnding && duelsGame.winner != null) {
factoryPlayer.getInventory().clear();
LobbyUtil.giveItems(player);
respawnEvent.setRespawnMode(Minecraft.GameMode.SPECTATOR);
respawnEvent.setSpawnpoint(new Location(duelsGame.winner.getX(), duelsGame.winner.getY(), duelsGame.winner.getZ(), ServerTime.factoryServer.getWorld(new Identifier("duels", WorldUtil.getIdentifierWorldName(duelsGame.level).getId()))));
} else if(teamDuelsGame != null && duelsData.duelOptions.duelsTeam != null) {
factoryPlayer.getInventory().clear();
LobbyUtil.giveItems(player);
respawnEvent.setRespawnMode(Minecraft.GameMode.SPECTATOR);
Location respawn = new Location(0,80, 0, ServerTime.factoryServer.getWorld(new Identifier("duels", WorldUtil.getIdentifierWorldName(teamDuelsGame.level).getId())));
ServerPlayer player1 = null;
if(duelsData.duelOptions.duelsTeam.alive.isEmpty()) {
if(teamDuelsGame.team1 == duelsData.duelOptions.duelsTeam && !teamDuelsGame.team2.alive.isEmpty()) {
player1 = teamDuelsGame.team2.alive.get(new Random().nextInt(teamDuelsGame.team2.alive.size()));
} else if(teamDuelsGame.team2 == duelsData.duelOptions.duelsTeam && !teamDuelsGame.team1.alive.isEmpty()){
player1 = teamDuelsGame.team1.alive.get(new Random().nextInt(teamDuelsGame.team1.alive.size()));
}
if(player1 != null) {
respawn.setX(player1.getX());
respawn.setY(player1.getY());
respawn.setZ(player1.getZ());
}
} else {
player1 = duelsData.duelOptions.duelsTeam.alive.get(new Random().nextInt(duelsData.duelOptions.duelsTeam.alive.size()));
}
respawnEvent.setSpawnpoint(respawn);
//player.teleportTo(duelsGame.level, duelsGame.winner.getX(), duelsGame.winner.getY(), duelsGame.winner.getZ(), 0, 0);
} else if(customDuelsGame != null && customDuelsGame.isEnding && customDuelsGame.winner != null) {
factoryPlayer.getInventory().clear();
LobbyUtil.giveItems(player);
respawnEvent.setRespawnMode(Minecraft.GameMode.SPECTATOR);
respawnEvent.setSpawnpoint(new Location(customDuelsGame.winner.getX(), customDuelsGame.winner.getY(), customDuelsGame.winner.getZ(), ServerTime.factoryServer.getWorld(new Identifier("duels", WorldUtil.getIdentifierWorldName(customDuelsGame.level).getId()))));
//player.teleportTo(duelsGame.level, duelsGame.winner.getX(), duelsGame.winner.getY(), duelsGame.winner.getZ(), 0, 0);
} else if(customTeamDuelsGame != null && duelsData.duelOptions.duelsTeam != null) {
factoryPlayer.getInventory().clear();
LobbyUtil.giveItems(player);
respawnEvent.setRespawnMode(Minecraft.GameMode.SPECTATOR);
Location respawn = new Location(0,80, 0, ServerTime.factoryServer.getWorld(new Identifier("duels", WorldUtil.getIdentifierWorldName(customTeamDuelsGame.level).getId())));
ServerPlayer player1 = null;
if(duelsData.duelOptions.duelsTeam.alive.isEmpty()) {
if(customTeamDuelsGame.team1 == duelsData.duelOptions.duelsTeam && !customTeamDuelsGame.team2.alive.isEmpty()) {
player1 = customTeamDuelsGame.team2.alive.get(new Random().nextInt(customTeamDuelsGame.team2.alive.size()));
} else if (customTeamDuelsGame.team2 == duelsData.duelOptions.duelsTeam && !customTeamDuelsGame.team1.alive.isEmpty()) {
player1 = customTeamDuelsGame.team1.alive.get(new Random().nextInt(customTeamDuelsGame.team1.alive.size()));
}
if(player1 != null) {
respawn.setX(player1.getX());
respawn.setY(player1.getY());
respawn.setZ(player1.getZ());
}
} else {
player1 = duelsData.duelOptions.duelsTeam.alive.get(new Random().nextInt(duelsData.duelOptions.duelsTeam.alive.size()));
}
respawnEvent.setSpawnpoint(respawn);
}
});
}
}
@@ -1,52 +0,0 @@
package com.nexia.core.listeners.factory;
import com.combatreforged.factory.api.event.player.PlayerUseItemEvent;
import com.combatreforged.factory.api.world.entity.player.Player;
import com.combatreforged.factory.api.world.item.ItemStack;
import com.nexia.core.games.util.PlayerGameMode;
import com.nexia.core.utilities.player.PlayerDataManager;
import com.nexia.core.utilities.player.PlayerUtil;
import net.kyori.adventure.text.Component;
import net.minecraft.server.level.ServerPlayer;
public class UseItemListener {
public static void registerListener() {
PlayerUseItemEvent.BACKEND.register(playerUseItemEvent -> {
Player player = playerUseItemEvent.getPlayer();
ServerPlayer minecraftPlayer = PlayerUtil.getMinecraftPlayer(player);
ItemStack itemStack = playerUseItemEvent.getItemStack();
Component name = itemStack.getDisplayName();
PlayerGameMode gameMode = PlayerDataManager.get(minecraftPlayer).gameMode;
String sName = name.toString().toLowerCase();
if(gameMode == PlayerGameMode.LOBBY) {
if(sName.contains("gamemode selector")){
//PlayGUI.openMainGUI(minecraftPlayer);
player.runCommand("/play", 0, false);
return;
}
if(sName.contains("prefix selector")){
//PrefixGUI.openRankGUI(minecraftPlayer);
player.runCommand("/prefix", 0, false);
return;
}
if(sName.contains("duel sword") && !sName.contains("custom duel sword")) {
//QueueGUI.openQueueGUI(minecraftPlayer);
player.runCommand("/queue", 0, false);
return;
}
if(sName.contains("team axe")) {
player.runCommand("/party list");
}
}
});
}
}
@@ -0,0 +1,43 @@
package com.nexia.core.listeners.metis;
import com.combatreforged.metis.api.event.player.PlayerHotbarDropItemEvent;
import com.combatreforged.metis.api.world.entity.player.Player;
import com.nexia.core.games.util.LobbyUtil;
import com.nexia.core.utilities.item.ItemStackUtil;
import com.nexia.core.utilities.player.PlayerUtil;
import com.nexia.ffa.FfaUtil;
import com.nexia.minigames.games.bedwars.util.BwUtil;
import com.nexia.minigames.games.oitc.OitcGame;
import net.minecraft.server.level.ServerPlayer;
public class PlayerDropItemListener {
public static void registerListener(){
PlayerHotbarDropItemEvent.BACKEND.register(playerDropItemEvent -> {
Player player = playerDropItemEvent.getPlayer();
ServerPlayer minecraftPlayer = PlayerUtil.getMinecraftPlayer(player);
if (FfaUtil.isFfaPlayer(minecraftPlayer)) {
playerDropItemEvent.setCancelled(true);
return;
}
if(LobbyUtil.isLobbyWorld(minecraftPlayer.getLevel())){
playerDropItemEvent.setCancelled(true);
return;
}
if (BwUtil.isBedWarsPlayer(minecraftPlayer)) {
if (!BwUtil.canDropItem(playerDropItemEvent.getItemStack())) {
ItemStackUtil.sendInventoryRefreshPacket(minecraftPlayer);
playerDropItemEvent.setCancelled(true);
return;
}
}
if(OitcGame.isOITCPlayer(minecraftPlayer)){
playerDropItemEvent.setCancelled(true);
}
});
}
}
@@ -0,0 +1,23 @@
package com.nexia.core.listeners.metis;
import com.combatreforged.metis.api.event.player.PlayerFoodLevelsChangeEvent;
import com.combatreforged.metis.api.world.entity.player.Player;
import com.nexia.core.games.util.PlayerGameMode;
import com.nexia.minigames.games.duels.DuelGameMode;
import com.nexia.minigames.games.duels.util.player.PlayerDataManager;
public class PlayerFoodLevelsChangeListener {
public static void registerListener(){
PlayerFoodLevelsChangeEvent.BACKEND.register(playerFoodLevelsChangeEvent -> {
Player player = playerFoodLevelsChangeEvent.getPlayer();
// Duels
DuelGameMode duelGameMode = PlayerDataManager.get(player).gameMode;
PlayerGameMode gameMode = com.nexia.core.utilities.player.PlayerDataManager.get(player).gameMode;
if(gameMode.equals(PlayerGameMode.LOBBY) && !duelGameMode.hasSaturation) return;
playerFoodLevelsChangeEvent.setCancelled(true);
});
}
}
@@ -0,0 +1,14 @@
package com.nexia.core.listeners.metis;
import com.combatreforged.metis.api.event.player.PlayerInteractBlockEvent;
import com.combatreforged.metis.api.world.entity.player.Player;
import com.nexia.ffa.classic.utilities.FfaClassicUtil;
public class PlayerInteractBlockListener {
public static void registerListener(){
PlayerInteractBlockEvent.BACKEND.register(playerInteractBlockEvent -> {
Player player = playerInteractBlockEvent.getPlayer();
if(FfaClassicUtil.isFfaPlayer(player)) playerInteractBlockEvent.setCancelled(true);
});
}
}
@@ -1,16 +1,14 @@
package com.nexia.core.listeners.factory;
package com.nexia.core.listeners.metis;
import com.combatreforged.factory.api.event.player.PlayerJoinEvent;
import com.combatreforged.factory.api.world.entity.player.Player;
import com.combatreforged.metis.api.event.player.PlayerJoinEvent;
import com.combatreforged.metis.api.world.entity.player.Player;
import com.nexia.core.games.util.LobbyUtil;
import com.nexia.core.utilities.chat.ChatFormat;
import com.nexia.core.utilities.player.PlayerDataManager;
import com.nexia.core.utilities.player.PlayerUtil;
import com.nexia.core.utilities.ranks.NexiaRank;
import com.nexia.core.utilities.time.ServerTime;
import com.nexia.discord.Main;
import com.nexia.discord.utilities.player.PlayerData;
import com.nexia.ffa.classic.utilities.RatingUtil;
import me.lucko.fabric.api.permissions.v0.Permissions;
import net.dv8tion.jda.api.entities.Member;
import net.dv8tion.jda.api.entities.Role;
@@ -20,8 +18,6 @@ import net.kyori.adventure.text.event.HoverEvent;
import net.kyori.adventure.text.format.TextColor;
import net.minecraft.server.level.ServerPlayer;
import java.util.Objects;
import static com.nexia.discord.Main.jda;
public class PlayerJoinListener {
@@ -34,8 +30,24 @@ public class PlayerJoinListener {
processJoin(player, minecraftPlayer);
/*
if(minecraftPlayer.getStats().getValue(Stats.CUSTOM.get(Stats.LEAVE_GAME)) <= 1) {
playerJoinEvent.setJoinMessage(
Component.text("[").color(ChatFormat.lineColor)
.append(Component.text("!").color(TextColor.fromHexString("#ff9940")))
.append(Component.text("] ").color(ChatFormat.lineColor))
.append(Component.text(player.getRawName()).color(TextColor.fromHexString("#ff9940")))
);
} else {
playerJoinEvent.setJoinMessage(
Component.text("[").color(ChatFormat.lineColor)
.append(Component.text("+").color(ChatFormat.greenColor))
.append(Component.text("] ").color(ChatFormat.lineColor))
.append(Component.text(player.getRawName()).color(ChatFormat.greenColor))
);
}
*/
});
}
@@ -56,7 +68,7 @@ public class PlayerJoinListener {
.append(Component.text("Players online: ").color(ChatFormat.normalColor))
.append(Component.text(ServerTime.minecraftServer.getPlayerCount()).color(ChatFormat.brandColor2))
.append(Component.text("/").color(ChatFormat.lineColor))
.append(Component.text(ServerTime.factoryServer.getMaxPlayerCount()).color(ChatFormat.brandColor2))
.append(Component.text(ServerTime.metisServer.getMaxPlayerCount()).color(ChatFormat.brandColor2))
);
player.sendMessage(
Component.text(" » ").color(ChatFormat.brandColor2)
@@ -82,16 +94,17 @@ public class PlayerJoinListener {
Member discordUser = null;
try {
discordUser = Objects.requireNonNull(jda.getGuildById(Main.config.guildID)).retrieveMemberById(playerData.savedData.discordID).complete(true);
discordUser = jda.getGuildById(com.nexia.discord.Main.config.guildID).retrieveMemberById(playerData.savedData.discordID).complete(true);
} catch (Exception ignored) { }
if(discordUser == null) {
if(Permissions.check(player, "nexia.prefix.supporter")) {
if(Permissions.check(player, "nexia.rank")) {
NexiaRank.removePrefix(NexiaRank.SUPPORTER, player);
ServerTime.metisServer.runCommand("/staffprefix set " + player.getScoreboardName() + " default");
ServerTime.metisServer.runCommand("/staffprefix remove " + player.getScoreboardName() + " supporter");
return;
}
NexiaRank.setRank(NexiaRank.DEFAULT, player);
ServerTime.metisServer.runCommand("/rank " + player.getScoreboardName() + " default", 4, false);
}
return;
}
@@ -102,37 +115,35 @@ public class PlayerJoinListener {
if(hasRole && !hasSupporterPrefix) {
if(Permissions.check(player, "nexia.rank")) {
NexiaRank.addPrefix(NexiaRank.SUPPORTER, player, true);
ServerTime.metisServer.runCommand("/staffprefix add " + player.getScoreboardName() + " supporter", 4, false);
return;
}
NexiaRank.setRank(NexiaRank.SUPPORTER, player);
ServerTime.metisServer.runCommand("/rank " + player.getScoreboardName() + " supporter", 4, false);
} else if(!hasRole && hasSupporterPrefix) {
if(Permissions.check(player, "nexia.rank")) {
NexiaRank.removePrefix(NexiaRank.SUPPORTER, player);
ServerTime.metisServer.runCommand("/staffprefix remove " + player.getScoreboardName() + " supporter", 4, false);
ServerTime.metisServer.runCommand("/staffprefix set " + player.getScoreboardName() + " default", 4, false);
return;
}
NexiaRank.setRank(NexiaRank.DEFAULT, player);
ServerTime.metisServer.runCommand("/rank " + player.getScoreboardName() + " default", 4, false);
}
}
private static void processJoin(Player player, ServerPlayer minecraftPlayer) {
if(PlayerDataManager.get(player).clientType.equals(com.nexia.core.utilities.player.PlayerData.ClientType.VIAFABRICPLUS)) return;
PlayerDataManager.addPlayerData(minecraftPlayer);
com.nexia.ffa.classic.utilities.player.PlayerDataManager.addPlayerData(minecraftPlayer);
com.nexia.ffa.kits.utilities.player.PlayerDataManager.addPlayerData(minecraftPlayer);
com.nexia.ffa.uhc.utilities.player.PlayerDataManager.addPlayerData(minecraftPlayer);
com.nexia.ffa.sky.utilities.player.PlayerDataManager.addPlayerData(minecraftPlayer);
com.nexia.ffa.pot.utilities.player.PlayerDataManager.addPlayerData(minecraftPlayer);
com.nexia.discord.utilities.player.PlayerDataManager.addPlayerData(minecraftPlayer.getUUID());
com.nexia.minigames.games.duels.util.player.PlayerDataManager.addPlayerData(minecraftPlayer);
com.nexia.minigames.games.bedwars.util.player.PlayerDataManager.addPlayerData(minecraftPlayer);
com.nexia.minigames.games.oitc.util.player.PlayerDataManager.addPlayerData(minecraftPlayer);
com.nexia.minigames.games.football.util.player.PlayerDataManager.addPlayerData(minecraftPlayer);
com.nexia.minigames.games.skywars.util.player.PlayerDataManager.addPlayerData(minecraftPlayer);
LobbyUtil.leaveAllGames(minecraftPlayer, true);
checkBooster(minecraftPlayer);
RatingUtil.checkRatingRank(minecraftPlayer);
sendJoinMessage(player);
}
}
@@ -1,15 +1,15 @@
package com.nexia.core.listeners.factory;
package com.nexia.core.listeners.metis;
import com.combatreforged.factory.api.event.player.PlayerDisconnectEvent;
import com.combatreforged.factory.api.world.entity.player.Player;
import com.combatreforged.metis.api.event.player.PlayerDisconnectEvent;
import com.combatreforged.metis.api.world.entity.player.Player;
import com.nexia.core.games.util.PlayerGameMode;
import com.nexia.core.utilities.player.PlayerDataManager;
import com.nexia.core.utilities.player.PlayerUtil;
import com.nexia.ffa.FfaUtil;
import com.nexia.ffa.classic.utilities.FfaClassicUtil;
import com.nexia.minigames.games.bedwars.players.BwPlayerEvents;
import com.nexia.minigames.games.bedwars.util.BwUtil;
import com.nexia.minigames.games.duels.DuelGameHandler;
import com.nexia.minigames.games.football.FootballGame;
import com.nexia.minigames.games.oitc.OitcGame;
import com.nexia.minigames.games.skywars.SkywarsGame;
import net.minecraft.server.level.ServerPlayer;
@@ -22,6 +22,18 @@ public class PlayerLeaveListener {
ServerPlayer minecraftPlayer = PlayerUtil.getMinecraftPlayer(player);
processDisconnect(player, minecraftPlayer);
/*
if(Main.config.events.statusMessages){
playerDisconnectEvent.setLeaveMessage(
Component.text("[").color(ChatFormat.lineColor)
.append(Component.text("-").color(ChatFormat.failColor)
.append(Component.text("] ").color(ChatFormat.lineColor))
.append(Component.text(player.getRawName()).color(ChatFormat.failColor)))
);
}
*/
});
}
@@ -30,29 +42,27 @@ public class PlayerLeaveListener {
private static void processDisconnect(Player player, ServerPlayer minecraftPlayer){
if (BwUtil.isInBedWars(minecraftPlayer)) BwPlayerEvents.leaveInBedWars(minecraftPlayer);
else if (FfaUtil.isFfaPlayer(minecraftPlayer)) {
FfaUtil.leaveOrDie(minecraftPlayer, minecraftPlayer.getLastDamageSource(), true);
else if (FfaClassicUtil.isFfaPlayer(minecraftPlayer)) {
FfaClassicUtil.leaveOrDie(minecraftPlayer, minecraftPlayer.getLastDamageSource(), true);
}
else if (PlayerDataManager.get(minecraftPlayer).gameMode == PlayerGameMode.LOBBY) DuelGameHandler.leave(minecraftPlayer, true);
else if (PlayerDataManager.get(minecraftPlayer).gameMode == PlayerGameMode.SKYWARS) SkywarsGame.leave(minecraftPlayer);
else if (PlayerDataManager.get(minecraftPlayer).gameMode == PlayerGameMode.OITC) OitcGame.leave(minecraftPlayer);
else if (PlayerDataManager.get(minecraftPlayer).gameMode == PlayerGameMode.FOOTBALL) FootballGame.leave(minecraftPlayer);
PlayerDataManager.removePlayerData(minecraftPlayer);
com.nexia.ffa.classic.utilities.player.PlayerDataManager.removePlayerData(minecraftPlayer);
com.nexia.ffa.kits.utilities.player.PlayerDataManager.removePlayerData(minecraftPlayer);
com.nexia.ffa.uhc.utilities.player.PlayerDataManager.removePlayerData(minecraftPlayer);
com.nexia.ffa.sky.utilities.player.PlayerDataManager.removePlayerData(minecraftPlayer);
com.nexia.ffa.pot.utilities.player.PlayerDataManager.removePlayerData(minecraftPlayer);
com.nexia.discord.utilities.player.PlayerDataManager.removePlayerData(minecraftPlayer.getUUID());
com.nexia.minigames.games.duels.util.player.PlayerDataManager.removePlayerData(minecraftPlayer);
com.nexia.minigames.games.oitc.util.player.PlayerDataManager.removePlayerData(minecraftPlayer);
com.nexia.minigames.games.football.util.player.PlayerDataManager.removePlayerData(minecraftPlayer);
com.nexia.minigames.games.bedwars.util.player.PlayerDataManager.removePlayerData(minecraftPlayer);
com.nexia.minigames.games.skywars.util.player.PlayerDataManager.removePlayerData(minecraftPlayer);
//LobbyUtil.leaveAllGames(minecraftPlayer, true);
PlayerDataManager.removePlayerData(minecraftPlayer);
}
}
@@ -0,0 +1,113 @@
package com.nexia.core.listeners.metis;
import com.combatreforged.metis.api.event.player.PlayerRespawnEvent;
import com.combatreforged.metis.api.util.Identifier;
import com.combatreforged.metis.api.world.entity.player.Player;
import com.combatreforged.metis.api.world.types.Minecraft;
import com.combatreforged.metis.api.world.util.Location;
import com.nexia.core.games.util.LobbyUtil;
import com.nexia.core.games.util.PlayerGameMode;
import com.nexia.core.utilities.player.PlayerUtil;
import com.nexia.core.utilities.time.ServerTime;
import com.nexia.minigames.GameHandler;
import com.nexia.minigames.games.duels.DuelsGame;
import com.nexia.minigames.games.duels.team.TeamDuelsGame;
import com.nexia.minigames.games.duels.util.player.PlayerData;
import com.nexia.minigames.games.duels.util.player.PlayerDataManager;
import com.nexia.minigames.games.oitc.OitcGame;
import com.nexia.minigames.games.oitc.OitcGameMode;
import com.nexia.minigames.games.skywars.SkywarsGame;
import com.nexia.minigames.games.skywars.SkywarsGameMode;
import com.nexia.world.WorldUtil;
import net.minecraft.server.level.ServerPlayer;
import java.util.Random;
public class PlayerRespawnListener {
public static void registerListener(){
PlayerRespawnEvent.BACKEND.register((respawnEvent) -> {
Player factoryPlayer = respawnEvent.getPlayer();
if(factoryPlayer == null && respawnEvent.getEntity() instanceof Player) {
factoryPlayer = (Player) respawnEvent.getEntity();
}
if(factoryPlayer == null) return;
ServerPlayer player = ServerTime.minecraftServer.getPlayerList().getPlayer(factoryPlayer.getUUID());
if(player == null) return;
PlayerData duelsData = PlayerDataManager.get(player);
com.nexia.core.utilities.player.PlayerData data = com.nexia.core.utilities.player.PlayerDataManager.get(player);
DuelsGame duelsGame = duelsData.duelsGame;
TeamDuelsGame teamDuelsGame = duelsData.teamDuelsGame;
if(data.gameMode == PlayerGameMode.OITC) {
double[] respawn = {0, 100, 0};
boolean isPlaying = com.nexia.minigames.games.oitc.util.player.PlayerDataManager.get(player).gameMode == OitcGameMode.PLAYING;
if(player.getLastDamageSource() != null && PlayerUtil.getPlayerAttacker(player.getLastDamageSource().getEntity()) != null) {
ServerPlayer serverPlayer = PlayerUtil.getPlayerAttacker(player.getLastDamageSource().getEntity());
if(isPlaying) {
respawn[0] = serverPlayer.getX();
respawn[1] = serverPlayer.getY();
respawn[2] = serverPlayer.getZ();
}
}
if(isPlaying) {
GameHandler.showCountdown(player, 5);
}
respawnEvent.setRespawnMode(Minecraft.GameMode.SPECTATOR);
respawnEvent.setSpawnpoint(new Location(respawn[0], respawn[1], respawn[2], ServerTime.metisServer.getWorld(new Identifier("oitc", OitcGame.world.dimension().toString().replaceAll("]", "").split(":")[2]))));
return;
}
if(data.gameMode == PlayerGameMode.SKYWARS) {
double[] respawn = {0, 100, 0};
boolean isPlaying = com.nexia.minigames.games.skywars.util.player.PlayerDataManager.get(player).gameMode == SkywarsGameMode.PLAYING;
if(player.getLastDamageSource() != null && PlayerUtil.getPlayerAttacker(player.getLastDamageSource().getEntity()) != null) {
ServerPlayer serverPlayer = PlayerUtil.getPlayerAttacker(player.getLastDamageSource().getEntity());
if(isPlaying) {
respawn[0] = serverPlayer.getX();
respawn[1] = serverPlayer.getY();
respawn[2] = serverPlayer.getZ();
}
}
respawnEvent.setRespawnMode(Minecraft.GameMode.SPECTATOR);
respawnEvent.setSpawnpoint(new Location(respawn[0], respawn[1], respawn[2], WorldUtil.getWorld(SkywarsGame.world)));
}
if(duelsGame != null && duelsGame.isEnding && duelsGame.winner != null) {
factoryPlayer.getInventory().clear();
LobbyUtil.giveItems(player);
respawnEvent.setRespawnMode(Minecraft.GameMode.SPECTATOR);
respawnEvent.setSpawnpoint(new Location(duelsGame.winner.getX(), duelsGame.winner.getY(), duelsGame.winner.getZ(), ServerTime.metisServer.getWorld(new Identifier("duels", duelsGame.level.dimension().toString().replaceAll("]", "").split(":")[2]))));
//player.teleportTo(duelsGame.level, duelsGame.winner.getX(), duelsGame.winner.getY(), duelsGame.winner.getZ(), 0, 0);
} else if(teamDuelsGame != null && duelsData.duelsTeam != null) {
factoryPlayer.getInventory().clear();
LobbyUtil.giveItems(player);
respawnEvent.setRespawnMode(Minecraft.GameMode.SPECTATOR);
// duelsTeam.alive.get(new Random().nextInt(teamDuelsGame.winner.alive.size()))
ServerPlayer player1;
if(duelsData.duelsTeam.alive.isEmpty()) {
if(teamDuelsGame.team1 == duelsData.duelsTeam) {
player1 = teamDuelsGame.team2.alive.get(new Random().nextInt(teamDuelsGame.team2.alive.size()));
} else {
player1 = teamDuelsGame.team1.alive.get(new Random().nextInt(teamDuelsGame.team1.alive.size()));
}
} else {
player1 = duelsData.duelsTeam.alive.get(new Random().nextInt(duelsData.duelsTeam.alive.size()));
}
respawnEvent.setSpawnpoint(new Location(player1.getX(), player1.getY(), player1.getZ(), ServerTime.metisServer.getWorld(new Identifier("duels", teamDuelsGame.level.dimension().toString().replaceAll("]", "").split(":")[2]))));
//player.teleportTo(duelsGame.level, duelsGame.winner.getX(), duelsGame.winner.getY(), duelsGame.winner.getZ(), 0, 0);
}
});
}
}
@@ -0,0 +1,47 @@
package com.nexia.core.listeners.metis;
import com.combatreforged.metis.api.event.player.PlayerUseItemEvent;
import com.combatreforged.metis.api.world.entity.player.Player;
import com.combatreforged.metis.api.world.item.ItemStack;
import com.nexia.core.games.util.PlayerGameMode;
import com.nexia.core.utilities.player.PlayerDataManager;
import com.nexia.core.utilities.player.PlayerUtil;
import net.kyori.adventure.text.Component;
import net.minecraft.server.level.ServerPlayer;
public class UseItemListener {
public static void registerListener() {
PlayerUseItemEvent.BACKEND.register(playerUseItemEvent -> {
Player player = playerUseItemEvent.getPlayer();
ServerPlayer minecraftPlayer = PlayerUtil.getMinecraftPlayer(player);
ItemStack itemStack = playerUseItemEvent.getItemStack();
Component name = itemStack.getDisplayName();
PlayerGameMode gameMode = PlayerDataManager.get(minecraftPlayer).gameMode;
String sName = name.toString().toLowerCase();
if(sName.contains("gamemode selector") && gameMode == PlayerGameMode.LOBBY){
//PlayGUI.openMainGUI(minecraftPlayer);
player.runCommand("/play", 0, false);
}
if(sName.contains("prefix selector") && gameMode == PlayerGameMode.LOBBY){
//PrefixGUI.openRankGUI(minecraftPlayer);
player.runCommand("/prefix", 0, false);
}
if(sName.contains("queue sword") && gameMode == PlayerGameMode.LOBBY) {
//QueueGUI.openQueueGUI(minecraftPlayer);
player.runCommand("/queue", 0, false);
}
if(sName.contains("team axe") && gameMode == PlayerGameMode.LOBBY) {
player.runCommand("/party list");
}
});
}
}
@@ -1,71 +1,83 @@
package com.nexia.core.loader;
import com.combatreforged.metis.api.command.CommandSourceInfo;
import com.mojang.brigadier.CommandDispatcher;
import com.nexia.core.Main;
import com.nexia.core.commands.player.*;
import com.nexia.core.commands.player.duels.*;
import com.nexia.core.commands.player.duels.custom.CustomDuelCommand;
import com.nexia.core.commands.player.duels.custom.KitEditorCommand;
import com.nexia.core.commands.player.ffa.KitCommand;
import com.nexia.core.commands.player.ffa.*;
import com.nexia.core.commands.staff.*;
import com.nexia.core.commands.staff.dev.*;
import com.nexia.discord.commands.minecraft.LinkCommand;
import com.nexia.discord.commands.minecraft.UnLinkCommand;
import com.nexia.core.utilities.time.ServerTime;
import com.nexia.discord.commands.minecraft.*;
import net.fabricmc.fabric.api.command.v1.CommandRegistrationCallback;
import net.fabricmc.fabric.api.event.Event;
public class CommandLoader {
public static void registerCommands() {
Event<CommandRegistrationCallback> callbackEvent = CommandRegistrationCallback.EVENT;
public static void registerMetisCommands() {
Main.logger.info("Registering metis commands....");
CommandDispatcher<CommandSourceInfo> commandDispatcher = ServerTime.metisServer.getCommandDispatcher();
callbackEvent.register(SprintFixCommand::register);
callbackEvent.register(DiscordCommand::register);
callbackEvent.register(LeaveCommand::register);
callbackEvent.register(ProtectionMapCommand::register);
callbackEvent.register(PrefixCommand::register);
callbackEvent.register(RankCommand::register);
callbackEvent.register(LinkCommand::register);
callbackEvent.register(PingCommand::register);
callbackEvent.register(ForceGameEndCommand::register);
callbackEvent.register(SpectateCommand::register);
callbackEvent.register(PartyCommand::register);
callbackEvent.register(TempBanCommand::register);
callbackEvent.register(ShoutCommand::register);
callbackEvent.register(RanksCommand::register);
callbackEvent.register(UnTempBanCommand::register);
callbackEvent.register(UnLinkCommand::register);
callbackEvent.register(GamemodeBanCommand::register);
callbackEvent.register(UnGamemodeBanCommand::register);
callbackEvent.register(AcceptDuelCommand::register);
callbackEvent.register(DeclineDuelCommand::register);
callbackEvent.register(StaffPrefixCommand::register);
callbackEvent.register(DevExperimentalCommandsCommand::register);
callbackEvent.register(LoadInventoryCommand::register);
callbackEvent.register(SaveInventoryCommand::register);
callbackEvent.register(ListInventoriesCommand::register);
callbackEvent.register(DeleteInventoryCommand::register);
callbackEvent.register(KitEditorCommand::register);
callbackEvent.register(KitLayoutCommand::register);
callbackEvent.register(CustomDuelCommand::register);
callbackEvent.register(StaffReportCommand::register);
callbackEvent.register(DuelCommand::register);
callbackEvent.register(QueueCommand::register);
callbackEvent.register(MapCommand::register);
callbackEvent.register(MuteCommand::register);
callbackEvent.register(UnMuteCommand::register);
callbackEvent.register(PlayCommand::register);
callbackEvent.register(KitCommand::register);
callbackEvent.register(BanCommand::register);
callbackEvent.register(UnBanCommand::register);
callbackEvent.register(StatsCommand::register);
callbackEvent.register(RulesCommand::register);
callbackEvent.register(HelpCommand::register);
callbackEvent.register(ReportCommand::register);
callbackEvent.register(MessageCommand::registerMsg);
callbackEvent.register(MessageCommand::registerReply);
callbackEvent.register(RandomCommand::register);
callbackEvent.register(HealCommand::register);
callbackEvent.register(BwReloadShopCommand::register);
callbackEvent.register(BwReloadTeamColorsCommand::register);
callbackEvent.register(SkipQueueCommand::register);
DiscordCommand.register(commandDispatcher);
RulesCommand.register(commandDispatcher);
HelpCommand.register(commandDispatcher);
MessageCommand.registerMsg(commandDispatcher);
MessageCommand.registerReply(commandDispatcher);
PingCommand.register(commandDispatcher);
Main.logger.info("Registered commands.");
}
public static void registerCommands() {
CommandRegistrationCallback.EVENT.register(LeaveCommand::register);
CommandRegistrationCallback.EVENT.register(ProtectionMapCommand::register);
CommandRegistrationCallback.EVENT.register(PrefixCommand::register);
CommandRegistrationCallback.EVENT.register(RankCommand::register);
CommandRegistrationCallback.EVENT.register(LinkCommand::register);
CommandRegistrationCallback.EVENT.register(SpectateCommand::register);
CommandRegistrationCallback.EVENT.register(TeamCommand::register);
CommandRegistrationCallback.EVENT.register(TempBanCommand::register);
CommandRegistrationCallback.EVENT.register(ShoutCommand::register);
CommandRegistrationCallback.EVENT.register(RanksCommand::register);
CommandRegistrationCallback.EVENT.register(UnTempBanCommand::register);
CommandRegistrationCallback.EVENT.register(UnLinkCommand::register);
CommandRegistrationCallback.EVENT.register(AcceptDuelCommand::register);
CommandRegistrationCallback.EVENT.register(DeclineDuelCommand::register);
CommandRegistrationCallback.EVENT.register(StaffPrefixCommand::register);
CommandRegistrationCallback.EVENT.register(DevExperimentalMapCommand::register);
CommandRegistrationCallback.EVENT.register(StaffReportCommand::register);
CommandRegistrationCallback.EVENT.register(DuelCommand::register);
CommandRegistrationCallback.EVENT.register(QueueCommand::register);
CommandRegistrationCallback.EVENT.register(MapCommand::register);
CommandRegistrationCallback.EVENT.register(BiomeCommand::register);
CommandRegistrationCallback.EVENT.register(MuteCommand::register);
CommandRegistrationCallback.EVENT.register(UnMuteCommand::register);
CommandRegistrationCallback.EVENT.register(PlayCommand::register);
CommandRegistrationCallback.EVENT.register(KitCommand::register);
CommandRegistrationCallback.EVENT.register(BanCommand::register);
CommandRegistrationCallback.EVENT.register(UnBanCommand::register);
CommandRegistrationCallback.EVENT.register(StatsCommand::register);
CommandRegistrationCallback.EVENT.register(ReportCommand::register);
CommandRegistrationCallback.EVENT.register(RandomCommand::register);
CommandRegistrationCallback.EVENT.register(HealCommand::register);
CommandRegistrationCallback.EVENT.register(BwReloadShopCommand::register);
CommandRegistrationCallback.EVENT.register(BwReloadTeamColorsCommand::register);
CommandRegistrationCallback.EVENT.register(BwSkipQueueCommand::register);
CommandRegistrationCallback.EVENT.register(SwSkipQueueCommand::register);
}
}
@@ -2,6 +2,7 @@ package com.nexia.core.mixin.block;
import com.nexia.core.games.util.LobbyUtil;
import com.nexia.ffa.FfaUtil;
import com.nexia.ffa.classic.utilities.FfaAreas;
import com.nexia.minigames.games.bedwars.util.BwUtil;
import com.nexia.minigames.games.duels.util.player.PlayerData;
import com.nexia.minigames.games.duels.util.player.PlayerDataManager;
@@ -24,10 +25,11 @@ public class AnvilBlockMixin {
@Inject(method = "use", cancellable = true, at = @At("HEAD"))
private void use(BlockState blockState, Level level, BlockPos blockPos, Player player, InteractionHand interactionHand, BlockHitResult blockHitResult, CallbackInfoReturnable<InteractionResult> cir) {
if (!(player instanceof ServerPlayer serverPlayer)) return;
if (!(player instanceof ServerPlayer)) return;
ServerPlayer serverPlayer = (ServerPlayer) player;
PlayerData playerData = PlayerDataManager.get(serverPlayer);
if (BwUtil.isInBedWars(serverPlayer) || (playerData.gameOptions != null && (playerData.gameOptions.duelsGame != null || playerData.gameOptions.teamDuelsGame != null || playerData.gameOptions.customDuelsGame != null || playerData.gameOptions.customTeamDuelsGame != null)) || LobbyUtil.isLobbyWorld(serverPlayer.getLevel()) || (FfaUtil.isFfaPlayer(player) && !serverPlayer.isCreative())) {
if (BwUtil.isInBedWars(serverPlayer) || (playerData.duelsGame != null || playerData.teamDuelsGame != null) || LobbyUtil.isLobbyWorld(serverPlayer.getLevel()) || (FfaUtil.isFfaPlayer(player) && !serverPlayer.isCreative())) {
cir.setReturnValue(InteractionResult.FAIL);
return;
}
@@ -1,7 +1,7 @@
package com.nexia.core.mixin.block;
import com.nexia.core.games.util.LobbyUtil;
import com.nexia.ffa.FfaUtil;
import com.nexia.ffa.classic.utilities.FfaClassicUtil;
import net.minecraft.core.BlockPos;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.world.InteractionHand;
@@ -23,7 +23,7 @@ public class BeaconBlockMixin {
if(!(player instanceof ServerPlayer))
return;
if((FfaUtil.isFfaPlayer(player) || LobbyUtil.isLobbyWorld(player.level)) && !player.isCreative()) {
if(FfaUtil.isFfaPlayer(player) && !player.isCreative()) {
cir.setReturnValue(InteractionResult.FAIL);
}
}
@@ -1,6 +1,5 @@
package com.nexia.core.mixin.block;
import com.nexia.ffa.sky.utilities.FfaAreas;
import com.nexia.minigames.games.bedwars.areas.BwAreas;
import com.nexia.minigames.games.bedwars.util.BwUtil;
import net.minecraft.core.BlockPos;
@@ -25,9 +24,11 @@ public class BlockMixin {
private static void dropResources(BlockState blockState, Level level, BlockPos blockPos, BlockEntity blockEntity, Entity breakerEntity, ItemStack tool, CallbackInfo ci) {
if (!(level instanceof ServerLevel serverLevel)) return;
if ((BwAreas.isBedWarsWorld(serverLevel) && !(BwUtil.dropResources(blockState))) || FfaAreas.isFfaWorld(serverLevel)) {
if (BwAreas.isBedWarsWorld(serverLevel) && !(BwUtil.dropResources(blockState))) {
ci.cancel();
}
}
}
@@ -1,58 +0,0 @@
package com.nexia.core.mixin.block;
import com.nexia.minigames.games.duels.custom.kitroom.kitrooms.KitRoom;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.sounds.SoundEvent;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.level.block.ChestBlock;
import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.level.block.entity.BlockEntityType;
import net.minecraft.world.level.block.entity.ChestBlockEntity;
import net.minecraft.world.level.block.state.BlockState;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.Unique;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import java.util.HashMap;
import java.util.UUID;
@Mixin(ChestBlockEntity.class)
public abstract class ChestBlockEntityMixin extends BlockEntity {
@Unique private HashMap<UUID, CompoundTag> nbtList = new HashMap<>();
@Shadow public abstract CompoundTag save(CompoundTag compoundTag);
@Shadow public abstract void load(BlockState blockState, CompoundTag compoundTag);
public ChestBlockEntityMixin(BlockEntityType<?> blockEntityType) {
super(blockEntityType);
}
@Inject(method = "startOpen", at = @At("HEAD"))
public void onOpen(Player player, CallbackInfo ci) {
if (KitRoom.isInKitRoom(player)) {
nbtList.put(player.getUUID(), new CompoundTag());
this.save(nbtList.get(player.getUUID()));
}
}
@Inject(method = "stopOpen", at = @At("HEAD"))
public void onClose(Player player, CallbackInfo ci) {
if (KitRoom.isInKitRoom(player)) {
BlockState blockState = this.getBlockState();
if(blockState.getBlock() instanceof ChestBlock) {
this.load(blockState, nbtList.get(player.getUUID()));
nbtList.remove(player.getUUID());
}
}
}
@Inject(method = "playSound", at = @At("HEAD"), cancellable = true)
private void fixCrash(SoundEvent soundEvent, CallbackInfo ci) {
if(!(this.getBlockState().getBlock() instanceof ChestBlock)) ci.cancel();
}
}
@@ -1,25 +0,0 @@
package com.nexia.core.mixin.block;
import com.llamalad7.mixinextras.injector.ModifyExpressionValue;
import me.lucko.fabric.api.permissions.v0.Permissions;
import net.minecraft.core.BlockPos;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.CommandBlock;
import net.minecraft.world.level.block.state.BlockState;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
@Mixin(CommandBlock.class)
public class CommandBlockMixin {
@ModifyExpressionValue(
method = "use",
at = @At(
value = "INVOKE",
target = "Lnet/minecraft/world/entity/player/Player;canUseGameMasterBlocks()Z"
)
)
public boolean canUseCommandBlock(boolean original, BlockState blockState, Level level, BlockPos blockPos, Player player) {
return Permissions.check(player, "nexia.dev.commandblock");
}
}
@@ -1,6 +1,5 @@
package com.nexia.core.mixin.block;
import com.nexia.core.games.util.LobbyUtil;
import com.nexia.ffa.FfaUtil;
import net.minecraft.core.BlockPos;
import net.minecraft.server.level.ServerPlayer;
@@ -23,7 +22,7 @@ public class CraftingTableMixin {
if(!(player instanceof ServerPlayer))
return;
if((FfaUtil.isFfaPlayer(player) || LobbyUtil.isLobbyWorld(player.level)) && !player.isCreative()) {
if(FfaUtil.isFfaPlayer(player) && !player.isCreative()) {
cir.setReturnValue(InteractionResult.FAIL);
}
}
@@ -1,12 +1,14 @@
package com.nexia.core.mixin.block;
import com.nexia.core.games.util.LobbyUtil;
import com.nexia.ffa.FfaUtil;
import com.nexia.ffa.classic.utilities.FfaClassicUtil;
import com.nexia.ffa.kits.utilities.FfaKitsUtil;
import net.minecraft.core.BlockPos;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.world.InteractionHand;
import net.minecraft.world.InteractionResult;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.level.GameType;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.DispenserBlock;
import net.minecraft.world.level.block.state.BlockState;
@@ -23,6 +25,6 @@ public class DispenserBlockMixin {
if(!(player instanceof ServerPlayer))
return;
if((FfaUtil.isFfaPlayer(player) || LobbyUtil.isLobbyWorld(player.level)) && !player.isCreative()) { cir.setReturnValue(InteractionResult.FAIL); }
if(FfaUtil.isFfaPlayer(player) && ((ServerPlayer) player).gameMode.getGameModeForPlayer() == GameType.ADVENTURE) { cir.setReturnValue(InteractionResult.FAIL); }
}
}
Loaded 100 of 259 files, more files were not shown because too many files have changed in this diff. Show more