initial commit

This commit is contained in:
NotCoded committed 2024-06-14 19:02:45 +02:00
commit deb3006a4c
262 files changed
+18949

No files matched your search

+34
View File
@@ -0,0 +1,34 @@
# gradle
.gradle/
factory-builder/.gradle/
factory-api/.gradle
factory-test/.gradle
build/
out/
classes/
# eclipse
*.launch
# idea
.idea/
*.iml
*.ipr
*.iws
# vscode
.settings/
.vscode/
bin/
.classpath
.project
# fabric
run/
maven.properties
+674
View File
@@ -0,0 +1,674 @@
GNU GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The GNU General Public License is a free, copyleft license for
software and other kinds of works.
The licenses for most software and other practical works are designed
to take away your freedom to share and change the works. By contrast,
the GNU General Public License is intended to guarantee your freedom to
share and change all versions of a program--to make sure it remains free
software for all its users. We, the Free Software Foundation, use the
GNU General Public License for most of our software; it applies also to
any other work released this way by its authors. You can apply it to
your programs, too.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
them if you wish), that you receive source code or can get it if you
want it, that you can change the software or use pieces of it in new
free programs, and that you know you can do these things.
To protect your rights, we need to prevent others from denying you
these rights or asking you to surrender the rights. Therefore, you have
certain responsibilities if you distribute copies of the software, or if
you modify it: responsibilities to respect the freedom of others.
For example, if you distribute copies of such a program, whether
gratis or for a fee, you must pass on to the recipients the same
freedoms that you received. You must make sure that they, too, receive
or can get the source code. And you must show them these terms so they
know their rights.
Developers that use the GNU GPL protect your rights with two steps:
(1) assert copyright on the software, and (2) offer you this License
giving you legal permission to copy, distribute and/or modify it.
For the developers' and authors' protection, the GPL clearly explains
that there is no warranty for this free software. For both users' and
authors' sake, the GPL requires that modified versions be marked as
changed, so that their problems will not be attributed erroneously to
authors of previous versions.
Some devices are designed to deny users access to install or run
modified versions of the software inside them, although the manufacturer
can do so. This is fundamentally incompatible with the aim of
protecting users' freedom to change the software. The systematic
pattern of such abuse occurs in the area of products for individuals to
use, which is precisely where it is most unacceptable. Therefore, we
have designed this version of the GPL to prohibit the practice for those
products. If such problems arise substantially in other domains, we
stand ready to extend this provision to those domains in future versions
of the GPL, as needed to protect the freedom of users.
Finally, every program is threatened constantly by software patents.
States should not allow patents to restrict development and use of
software on general-purpose computers, but in those that do, we wish to
avoid the special danger that patents applied to a free program could
make it effectively proprietary. To prevent this, the GPL assures that
patents cannot be used to render the program non-free.
The precise terms and conditions for copying, distribution and
modification follow.
TERMS AND CONDITIONS
0. Definitions.
"This License" refers to version 3 of the GNU General Public License.
"Copyright" also means copyright-like laws that apply to other kinds of
works, such as semiconductor masks.
"The Program" refers to any copyrightable work licensed under this
License. Each licensee is addressed as "you". "Licensees" and
"recipients" may be individuals or organizations.
To "modify" a work means to copy from or adapt all or part of the work
in a fashion requiring copyright permission, other than the making of an
exact copy. The resulting work is called a "modified version" of the
earlier work or a work "based on" the earlier work.
A "covered work" means either the unmodified Program or a work based
on the Program.
To "propagate" a work means to do anything with it that, without
permission, would make you directly or secondarily liable for
infringement under applicable copyright law, except executing it on a
computer or modifying a private copy. Propagation includes copying,
distribution (with or without modification), making available to the
public, and in some countries other activities as well.
To "convey" a work means any kind of propagation that enables other
parties to make or receive copies. Mere interaction with a user through
a computer network, with no transfer of a copy, is not conveying.
An interactive user interface displays "Appropriate Legal Notices"
to the extent that it includes a convenient and prominently visible
feature that (1) displays an appropriate copyright notice, and (2)
tells the user that there is no warranty for the work (except to the
extent that warranties are provided), that licensees may convey the
work under this License, and how to view a copy of this License. If
the interface presents a list of user commands or options, such as a
menu, a prominent item in the list meets this criterion.
1. Source Code.
The "source code" for a work means the preferred form of the work
for making modifications to it. "Object code" means any non-source
form of a work.
A "Standard Interface" means an interface that either is an official
standard defined by a recognized standards body, or, in the case of
interfaces specified for a particular programming language, one that
is widely used among developers working in that language.
The "System Libraries" of an executable work include anything, other
than the work as a whole, that (a) is included in the normal form of
packaging a Major Component, but which is not part of that Major
Component, and (b) serves only to enable use of the work with that
Major Component, or to implement a Standard Interface for which an
implementation is available to the public in source code form. A
"Major Component", in this context, means a major essential component
(kernel, window system, and so on) of the specific operating system
(if any) on which the executable work runs, or a compiler used to
produce the work, or an object code interpreter used to run it.
The "Corresponding Source" for a work in object code form means all
the source code needed to generate, install, and (for an executable
work) run the object code and to modify the work, including scripts to
control those activities. However, it does not include the work's
System Libraries, or general-purpose tools or generally available free
programs which are used unmodified in performing those activities but
which are not part of the work. For example, Corresponding Source
includes interface definition files associated with source files for
the work, and the source code for shared libraries and dynamically
linked subprograms that the work is specifically designed to require,
such as by intimate data communication or control flow between those
subprograms and other parts of the work.
The Corresponding Source need not include anything that users
can regenerate automatically from other parts of the Corresponding
Source.
The Corresponding Source for a work in source code form is that
same work.
2. Basic Permissions.
All rights granted under this License are granted for the term of
copyright on the Program, and are irrevocable provided the stated
conditions are met. This License explicitly affirms your unlimited
permission to run the unmodified Program. The output from running a
covered work is covered by this License only if the output, given its
content, constitutes a covered work. This License acknowledges your
rights of fair use or other equivalent, as provided by copyright law.
You may make, run and propagate covered works that you do not
convey, without conditions so long as your license otherwise remains
in force. You may convey covered works to others for the sole purpose
of having them make modifications exclusively for you, or provide you
with facilities for running those works, provided that you comply with
the terms of this License in conveying all material for which you do
not control copyright. Those thus making or running the covered works
for you must do so exclusively on your behalf, under your direction
and control, on terms that prohibit them from making any copies of
your copyrighted material outside their relationship with you.
Conveying under any other circumstances is permitted solely under
the conditions stated below. Sublicensing is not allowed; section 10
makes it unnecessary.
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
No covered work shall be deemed part of an effective technological
measure under any applicable law fulfilling obligations under article
11 of the WIPO copyright treaty adopted on 20 December 1996, or
similar laws prohibiting or restricting circumvention of such
measures.
When you convey a covered work, you waive any legal power to forbid
circumvention of technological measures to the extent such circumvention
is effected by exercising rights under this License with respect to
the covered work, and you disclaim any intention to limit operation or
modification of the work as a means of enforcing, against the work's
users, your or third parties' legal rights to forbid circumvention of
technological measures.
4. Conveying Verbatim Copies.
You may convey verbatim copies of the Program's source code as you
receive it, in any medium, provided that you conspicuously and
appropriately publish on each copy an appropriate copyright notice;
keep intact all notices stating that this License and any
non-permissive terms added in accord with section 7 apply to the code;
keep intact all notices of the absence of any warranty; and give all
recipients a copy of this License along with the Program.
You may charge any price or no price for each copy that you convey,
and you may offer support or warranty protection for a fee.
5. Conveying Modified Source Versions.
You may convey a work based on the Program, or the modifications to
produce it from the Program, in the form of source code under the
terms of section 4, provided that you also meet all of these conditions:
a) The work must carry prominent notices stating that you modified
it, and giving a relevant date.
b) The work must carry prominent notices stating that it is
released under this License and any conditions added under section
7. This requirement modifies the requirement in section 4 to
"keep intact all notices".
c) You must license the entire work, as a whole, under this
License to anyone who comes into possession of a copy. This
License will therefore apply, along with any applicable section 7
additional terms, to the whole of the work, and all its parts,
regardless of how they are packaged. This License gives no
permission to license the work in any other way, but it does not
invalidate such permission if you have separately received it.
d) If the work has interactive user interfaces, each must display
Appropriate Legal Notices; however, if the Program has interactive
interfaces that do not display Appropriate Legal Notices, your
work need not make them do so.
A compilation of a covered work with other separate and independent
works, which are not by their nature extensions of the covered work,
and which are not combined with it such as to form a larger program,
in or on a volume of a storage or distribution medium, is called an
"aggregate" if the compilation and its resulting copyright are not
used to limit the access or legal rights of the compilation's users
beyond what the individual works permit. Inclusion of a covered work
in an aggregate does not cause this License to apply to the other
parts of the aggregate.
6. Conveying Non-Source Forms.
You may convey a covered work in object code form under the terms
of sections 4 and 5, provided that you also convey the
machine-readable Corresponding Source under the terms of this License,
in one of these ways:
a) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by the
Corresponding Source fixed on a durable physical medium
customarily used for software interchange.
b) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by a
written offer, valid for at least three years and valid for as
long as you offer spare parts or customer support for that product
model, to give anyone who possesses the object code either (1) a
copy of the Corresponding Source for all the software in the
product that is covered by this License, on a durable physical
medium customarily used for software interchange, for a price no
more than your reasonable cost of physically performing this
conveying of source, or (2) access to copy the
Corresponding Source from a network server at no charge.
c) Convey individual copies of the object code with a copy of the
written offer to provide the Corresponding Source. This
alternative is allowed only occasionally and noncommercially, and
only if you received the object code with such an offer, in accord
with subsection 6b.
d) Convey the object code by offering access from a designated
place (gratis or for a charge), and offer equivalent access to the
Corresponding Source in the same way through the same place at no
further charge. You need not require recipients to copy the
Corresponding Source along with the object code. If the place to
copy the object code is a network server, the Corresponding Source
may be on a different server (operated by you or a third party)
that supports equivalent copying facilities, provided you maintain
clear directions next to the object code saying where to find the
Corresponding Source. Regardless of what server hosts the
Corresponding Source, you remain obligated to ensure that it is
available for as long as needed to satisfy these requirements.
e) Convey the object code using peer-to-peer transmission, provided
you inform other peers where the object code and Corresponding
Source of the work are being offered to the general public at no
charge under subsection 6d.
A separable portion of the object code, whose source code is excluded
from the Corresponding Source as a System Library, need not be
included in conveying the object code work.
A "User Product" is either (1) a "consumer product", which means any
tangible personal property which is normally used for personal, family,
or household purposes, or (2) anything designed or sold for incorporation
into a dwelling. In determining whether a product is a consumer product,
doubtful cases shall be resolved in favor of coverage. For a particular
product received by a particular user, "normally used" refers to a
typical or common use of that class of product, regardless of the status
of the particular user or of the way in which the particular user
actually uses, or expects or is expected to use, the product. A product
is a consumer product regardless of whether the product has substantial
commercial, industrial or non-consumer uses, unless such uses represent
the only significant mode of use of the product.
"Installation Information" for a User Product means any methods,
procedures, authorization keys, or other information required to install
and execute modified versions of a covered work in that User Product from
a modified version of its Corresponding Source. The information must
suffice to ensure that the continued functioning of the modified object
code is in no case prevented or interfered with solely because
modification has been made.
If you convey an object code work under this section in, or with, or
specifically for use in, a User Product, and the conveying occurs as
part of a transaction in which the right of possession and use of the
User Product is transferred to the recipient in perpetuity or for a
fixed term (regardless of how the transaction is characterized), the
Corresponding Source conveyed under this section must be accompanied
by the Installation Information. But this requirement does not apply
if neither you nor any third party retains the ability to install
modified object code on the User Product (for example, the work has
been installed in ROM).
The requirement to provide Installation Information does not include a
requirement to continue to provide support service, warranty, or updates
for a work that has been modified or installed by the recipient, or for
the User Product in which it has been modified or installed. Access to a
network may be denied when the modification itself materially and
adversely affects the operation of the network or violates the rules and
protocols for communication across the network.
Corresponding Source conveyed, and Installation Information provided,
in accord with this section must be in a format that is publicly
documented (and with an implementation available to the public in
source code form), and must require no special password or key for
unpacking, reading or copying.
7. Additional Terms.
"Additional permissions" are terms that supplement the terms of this
License by making exceptions from one or more of its conditions.
Additional permissions that are applicable to the entire Program shall
be treated as though they were included in this License, to the extent
that they are valid under applicable law. If additional permissions
apply only to part of the Program, that part may be used separately
under those permissions, but the entire Program remains governed by
this License without regard to the additional permissions.
When you convey a copy of a covered work, you may at your option
remove any additional permissions from that copy, or from any part of
it. (Additional permissions may be written to require their own
removal in certain cases when you modify the work.) You may place
additional permissions on material, added by you to a covered work,
for which you have or can give appropriate copyright permission.
Notwithstanding any other provision of this License, for material you
add to a covered work, you may (if authorized by the copyright holders of
that material) supplement the terms of this License with terms:
a) Disclaiming warranty or limiting liability differently from the
terms of sections 15 and 16 of this License; or
b) Requiring preservation of specified reasonable legal notices or
author attributions in that material or in the Appropriate Legal
Notices displayed by works containing it; or
c) Prohibiting misrepresentation of the origin of that material, or
requiring that modified versions of such material be marked in
reasonable ways as different from the original version; or
d) Limiting the use for publicity purposes of names of licensors or
authors of the material; or
e) Declining to grant rights under trademark law for use of some
trade names, trademarks, or service marks; or
f) Requiring indemnification of licensors and authors of that
material by anyone who conveys the material (or modified versions of
it) with contractual assumptions of liability to the recipient, for
any liability that these contractual assumptions directly impose on
those licensors and authors.
All other non-permissive additional terms are considered "further
restrictions" within the meaning of section 10. If the Program as you
received it, or any part of it, contains a notice stating that it is
governed by this License along with a term that is a further
restriction, you may remove that term. If a license document contains
a further restriction but permits relicensing or conveying under this
License, you may add to a covered work material governed by the terms
of that license document, provided that the further restriction does
not survive such relicensing or conveying.
If you add terms to a covered work in accord with this section, you
must place, in the relevant source files, a statement of the
additional terms that apply to those files, or a notice indicating
where to find the applicable terms.
Additional terms, permissive or non-permissive, may be stated in the
form of a separately written license, or stated as exceptions;
the above requirements apply either way.
8. Termination.
You may not propagate or modify a covered work except as expressly
provided under this License. Any attempt otherwise to propagate or
modify it is void, and will automatically terminate your rights under
this License (including any patent licenses granted under the third
paragraph of section 11).
However, if you cease all violation of this License, then your
license from a particular copyright holder is reinstated (a)
provisionally, unless and until the copyright holder explicitly and
finally terminates your license, and (b) permanently, if the copyright
holder fails to notify you of the violation by some reasonable means
prior to 60 days after the cessation.
Moreover, your license from a particular copyright holder is
reinstated permanently if the copyright holder notifies you of the
violation by some reasonable means, this is the first time you have
received notice of violation of this License (for any work) from that
copyright holder, and you cure the violation prior to 30 days after
your receipt of the notice.
Termination of your rights under this section does not terminate the
licenses of parties who have received copies or rights from you under
this License. If your rights have been terminated and not permanently
reinstated, you do not qualify to receive new licenses for the same
material under section 10.
9. Acceptance Not Required for Having Copies.
You are not required to accept this License in order to receive or
run a copy of the Program. Ancillary propagation of a covered work
occurring solely as a consequence of using peer-to-peer transmission
to receive a copy likewise does not require acceptance. However,
nothing other than this License grants you permission to propagate or
modify any covered work. These actions infringe copyright if you do
not accept this License. Therefore, by modifying or propagating a
covered work, you indicate your acceptance of this License to do so.
10. Automatic Licensing of Downstream Recipients.
Each time you convey a covered work, the recipient automatically
receives a license from the original licensors, to run, modify and
propagate that work, subject to this License. You are not responsible
for enforcing compliance by third parties with this License.
An "entity transaction" is a transaction transferring control of an
organization, or substantially all assets of one, or subdividing an
organization, or merging organizations. If propagation of a covered
work results from an entity transaction, each party to that
transaction who receives a copy of the work also receives whatever
licenses to the work the party's predecessor in interest had or could
give under the previous paragraph, plus a right to possession of the
Corresponding Source of the work from the predecessor in interest, if
the predecessor has it or can get it with reasonable efforts.
You may not impose any further restrictions on the exercise of the
rights granted or affirmed under this License. For example, you may
not impose a license fee, royalty, or other charge for exercise of
rights granted under this License, and you may not initiate litigation
(including a cross-claim or counterclaim in a lawsuit) alleging that
any patent claim is infringed by making, using, selling, offering for
sale, or importing the Program or any portion of it.
11. Patents.
A "contributor" is a copyright holder who authorizes use under this
License of the Program or a work on which the Program is based. The
work thus licensed is called the contributor's "contributor version".
A contributor's "essential patent claims" are all patent claims
owned or controlled by the contributor, whether already acquired or
hereafter acquired, that would be infringed by some manner, permitted
by this License, of making, using, or selling its contributor version,
but do not include claims that would be infringed only as a
consequence of further modification of the contributor version. For
purposes of this definition, "control" includes the right to grant
patent sublicenses in a manner consistent with the requirements of
this License.
Each contributor grants you a non-exclusive, worldwide, royalty-free
patent license under the contributor's essential patent claims, to
make, use, sell, offer for sale, import and otherwise run, modify and
propagate the contents of its contributor version.
In the following three paragraphs, a "patent license" is any express
agreement or commitment, however denominated, not to enforce a patent
(such as an express permission to practice a patent or covenant not to
sue for patent infringement). To "grant" such a patent license to a
party means to make such an agreement or commitment not to enforce a
patent against the party.
If you convey a covered work, knowingly relying on a patent license,
and the Corresponding Source of the work is not available for anyone
to copy, free of charge and under the terms of this License, through a
publicly available network server or other readily accessible means,
then you must either (1) cause the Corresponding Source to be so
available, or (2) arrange to deprive yourself of the benefit of the
patent license for this particular work, or (3) arrange, in a manner
consistent with the requirements of this License, to extend the patent
license to downstream recipients. "Knowingly relying" means you have
actual knowledge that, but for the patent license, your conveying the
covered work in a country, or your recipient's use of the covered work
in a country, would infringe one or more identifiable patents in that
country that you have reason to believe are valid.
If, pursuant to or in connection with a single transaction or
arrangement, you convey, or propagate by procuring conveyance of, a
covered work, and grant a patent license to some of the parties
receiving the covered work authorizing them to use, propagate, modify
or convey a specific copy of the covered work, then the patent license
you grant is automatically extended to all recipients of the covered
work and works based on it.
A patent license is "discriminatory" if it does not include within
the scope of its coverage, prohibits the exercise of, or is
conditioned on the non-exercise of one or more of the rights that are
specifically granted under this License. You may not convey a covered
work if you are a party to an arrangement with a third party that is
in the business of distributing software, under which you make payment
to the third party based on the extent of your activity of conveying
the work, and under which the third party grants, to any of the
parties who would receive the covered work from you, a discriminatory
patent license (a) in connection with copies of the covered work
conveyed by you (or copies made from those copies), or (b) primarily
for and in connection with specific products or compilations that
contain the covered work, unless you entered into that arrangement,
or that patent license was granted, prior to 28 March 2007.
Nothing in this License shall be construed as excluding or limiting
any implied license or other defenses to infringement that may
otherwise be available to you under applicable patent law.
12. No Surrender of Others' Freedom.
If conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot convey a
covered work so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you may
not convey it at all. For example, if you agree to terms that obligate you
to collect a royalty for further conveying from those to whom you convey
the Program, the only way you could satisfy both those terms and this
License would be to refrain entirely from conveying the Program.
13. Use with the GNU Affero General Public License.
Notwithstanding any other provision of this License, you have
permission to link or combine any covered work with a work licensed
under version 3 of the GNU Affero General Public License into a single
combined work, and to convey the resulting work. The terms of this
License will continue to apply to the part which is the covered work,
but the special requirements of the GNU Affero General Public License,
section 13, concerning interaction through a network will apply to the
combination as such.
14. Revised Versions of this License.
The Free Software Foundation may publish revised and/or new versions of
the GNU General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the
Program specifies that a certain numbered version of the GNU General
Public License "or any later version" applies to it, you have the
option of following the terms and conditions either of that numbered
version or of any later version published by the Free Software
Foundation. If the Program does not specify a version number of the
GNU General Public License, you may choose any version ever published
by the Free Software Foundation.
If the Program specifies that a proxy can decide which future
versions of the GNU General Public License can be used, that proxy's
public statement of acceptance of a version permanently authorizes you
to choose that version for the Program.
Later license versions may give you additional or different
permissions. However, no additional obligations are imposed on any
author or copyright holder as a result of your choosing to follow a
later version.
15. Disclaimer of Warranty.
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
16. Limitation of Liability.
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
SUCH DAMAGES.
17. Interpretation of Sections 15 and 16.
If the disclaimer of warranty and limitation of liability provided
above cannot be given local legal effect according to their terms,
reviewing courts shall apply local law that most closely approximates
an absolute waiver of all civil liability in connection with the
Program, unless a warranty or assumption of liability accompanies a
copy of the Program in return for a fee.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
state the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
<one line to give the program's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
Also add information on how to contact you by electronic and paper mail.
If the program does terminal interaction, make it output a short
notice like this when it starts in an interactive mode:
<program> Copyright (C) <year> <name of author>
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License. Of course, your program's commands
might be different; for a GUI interface, you would use an "about box".
You should also get your employer (if you work as a programmer) or school,
if any, to sign a "copyright disclaimer" for the program, if necessary.
For more information on this, and how to apply and follow the GNU GPL, see
<https://www.gnu.org/licenses/>.
The GNU General Public License does not permit incorporating your program
into proprietary programs. If your program is a subroutine library, you
may consider it more useful to permit linking proprietary applications with
the library. If this is what you want to do, use the GNU Lesser General
Public License instead of this License. But first, please read
<https://www.gnu.org/licenses/why-not-lgpl.html>.
+4
View File
@@ -0,0 +1,4 @@
# Factory
Factory API, a Minecraft-abstracted API for Fabric
Currently for Combat Tests only.
+58
View File
@@ -0,0 +1,58 @@
plugins {
id 'java'
id 'net.ltgt.errorprone' version "2.0.2"
id 'maven-publish'
}
group 'com.combatreforged.factory'
version '0.1.13'
def props = new Properties()
def file = file("maven.properties")
if (file.exists()) {
System.out.println("Publishing enabled")
file.withInputStream { props.load(it) }
}
allprojects {
apply plugin: 'java'
apply plugin: 'net.ltgt.errorprone'
apply plugin: 'maven-publish'
version rootProject.version
repositories {
mavenCentral()
maven {
name = 'sonatype-oss'
url = 'https://oss.sonatype.org/content/repositories/snapshots/'
}
maven {
name = "minecraft"
url = 'https://libraries.minecraft.net/'
}
}
dependencies {
errorprone implementation('com.google.errorprone:error_prone_core:2.10.0')
}
compileJava {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}
publishing {
repositories {
if (props.containsKey("maven.url")) {
maven {
url props.get("maven.url")
credentials {
username props.get("maven.username")
password props.get("maven.password")
}
}
}
}
}
}
+126
View File
@@ -0,0 +1,126 @@
plugins {
id 'java-library'
id 'maven-publish'
}
group 'com.combatreforged.factory'
repositories {
mavenCentral()
maven {
url 'https://libraries.minecraft.net'
}
}
configurations {
apiParts
mcProvided
api.extendsFrom apiParts, mcProvided
include.extendsFrom api
full {
canBeConsumed = true
canBeResolved = false
extendsFrom api
}
fullNoDuplicates {
canBeConsumed = true
canBeResolved = false
extendsFrom apiParts
}
}
dependencies {
// make sure to use the correct versions of mcProvided artifacts for the Minecraft version (look into the version manifest)
mcProvided 'org.apache.logging.log4j:log4j-api:2.8.1'
mcProvided 'org.apache.logging.log4j:log4j-core:2.8.1'
apiParts 'net.kyori:adventure-api:4.9.3'
apiParts 'net.kyori:adventure-text-serializer-gson:4.9.3'
mcProvided 'com.mojang:brigadier:1.0.17'
apiParts 'org.jetbrains:annotations:22.0.0'
}
processResources {
inputs.property "version", project.version
filesMatching("fabric.mod.json") {
expand "version": project.version
}
}
task fullJar(type: Jar) {
group = "build"
archiveClassifier = "full"
from (configurations.include.filter { it.exists() }.collect { it.isDirectory() ? it : zipTree(it) }) {
exclude "META-INF/**"
}
with jar
}
task fullNoDuplicatesJar(type: Jar) {
archiveClassifier = "full-no-duplicates"
from (configurations.apiParts.filter { it.exists() }.collect { it.isDirectory() ? it : zipTree(it) }) {
exclude "META-INF/**"
}
with jar
}
java {
withJavadocJar()
withSourcesJar()
}
javadoc {
if (JavaVersion.current().isJava9Compatible()) {
options.addBooleanOption('html5', true)
}
}
artifacts {
archives fullJar
full fullJar
fullNoDuplicates fullNoDuplicatesJar
}
test {
useJUnitPlatform()
}
publishing {
publications {
mavenJava(MavenPublication) {
artifactId = this.archivesBaseName
from components.java
versionMapping {
usage('java-api') {
fromResolutionOf('runtimeClasspath')
}
usage('java-runtime') {
fromResolutionResult()
}
}
pom {
name = 'Factory API'
description = 'Factory API, a Minecraft-abstracted API for Fabric.'
url = 'https://github.com/CombatReforged/factory'
developers {
developer {
id = 'rizecookey'
}
}
}
artifact fullJar
}
}
}
@@ -0,0 +1,51 @@
package com.combatreforged.factory.api;
import com.combatreforged.factory.api.builder.Builder;
import com.combatreforged.factory.api.event.server.ServerTickEvent;
import com.combatreforged.factory.api.scheduler.TaskScheduler;
import com.combatreforged.factory.api.scheduler.TickFunction;
import com.combatreforged.factory.api.util.ImplementationUtils;
import com.combatreforged.factory.api.world.util.Pair;
public class FactoryAPI {
private static FactoryAPI INSTANCE = null;
private final Builder builder;
private final ImplementationUtils implementationUtils;
private final FactoryServer server;
private final TaskScheduler scheduler;
private final TickFunction tickFunction;
public FactoryAPI(FactoryServer server, Builder builder) {
this.builder = builder;
this.implementationUtils = builder.createImplementationUtils();
this.server = server;
Pair<TaskScheduler, TickFunction> sched = TaskScheduler.create();
this.scheduler = sched.a();
this.tickFunction = sched.b();
ServerTickEvent.BACKEND.register(event -> event.runAfterwards(tickFunction::tick));
INSTANCE = this;
}
public Builder getBuilder() {
return builder;
}
public FactoryServer getServer() {
return server;
}
public ImplementationUtils getImplementationUtils() {
return implementationUtils;
}
public static FactoryAPI getInstance() {
return INSTANCE;
}
public TaskScheduler getScheduler() {
return scheduler;
}
}
@@ -0,0 +1,35 @@
package com.combatreforged.factory.api;
import com.combatreforged.factory.api.command.CommandSender;
import com.combatreforged.factory.api.command.CommandSourceInfo;
import com.combatreforged.factory.api.util.Identifier;
import com.combatreforged.factory.api.world.World;
import com.combatreforged.factory.api.world.entity.player.Player;
import com.combatreforged.factory.api.world.scoreboard.Scoreboard;
import com.mojang.brigadier.CommandDispatcher;
import java.io.IOException;
import java.nio.file.Path;
import java.util.Collection;
import java.util.UUID;
import java.util.concurrent.CompletableFuture;
public interface FactoryServer extends CommandSender {
int getMaxPlayerCount();
Collection<Player> getPlayers();
Player getPlayer(String name);
Player getPlayer(UUID uuid);
Collection<World> getWorlds();
World getWorld(Identifier identifier);
Scoreboard getServerScoreboard();
CommandDispatcher<CommandSourceInfo> getCommandDispatcher();
boolean hasWorld(String name);
void loadWorld(Path path);
void loadWorld(Path path, String name);
CompletableFuture<Void> loadWorldAsync(Path path);
CompletableFuture<Void> loadWorldAsync(Path path, String name);
void saveWorld(String name);
void unloadWorld(String name) throws IOException;
void unloadWorld(String name, boolean save) throws IOException;
}
@@ -0,0 +1,76 @@
package com.combatreforged.factory.api.builder;
import com.combatreforged.factory.api.FactoryAPI;
import com.combatreforged.factory.api.FactoryServer;
import com.combatreforged.factory.api.command.CommandSender;
import com.combatreforged.factory.api.command.CommandSourceInfo;
import com.combatreforged.factory.api.util.ImplementationUtils;
import com.combatreforged.factory.api.world.World;
import com.combatreforged.factory.api.world.block.Block;
import com.combatreforged.factory.api.world.block.BlockState;
import com.combatreforged.factory.api.world.block.BlockType;
import com.combatreforged.factory.api.world.damage.DamageData;
import com.combatreforged.factory.api.world.effect.StatusEffect;
import com.combatreforged.factory.api.world.effect.StatusEffectInstance;
import com.combatreforged.factory.api.world.entity.Entity;
import com.combatreforged.factory.api.world.entity.EntityType;
import com.combatreforged.factory.api.world.entity.player.Player;
import com.combatreforged.factory.api.world.item.ItemStack;
import com.combatreforged.factory.api.world.item.ItemType;
import com.combatreforged.factory.api.world.nbt.NBTList;
import com.combatreforged.factory.api.world.nbt.NBTObject;
import com.combatreforged.factory.api.world.nbt.NBTValue;
import com.combatreforged.factory.api.world.scoreboard.Scoreboard;
import com.combatreforged.factory.api.world.util.Location;
import com.mojang.brigadier.CommandDispatcher;
import net.kyori.adventure.nbt.api.BinaryTagHolder;
import org.jetbrains.annotations.Nullable;
import java.util.List;
import java.util.Map;
import java.util.UUID;
public interface Builder {
ImplementationUtils createImplementationUtils();
Entity createEntity(EntityType type, World world);
Player createNPCPlayer(World world, UUID uuid, String name);
NBTObject createNBTObject(@Nullable Map<String, NBTValue> values);
NBTObject createNBTObjectFromString(String string);
NBTList createNBTList(List<NBTValue> values);
NBTValue createNBTValue(short s);
NBTValue createNBTValue(double d);
NBTValue createNBTValue(float f);
NBTValue createNBTValue(byte b);
NBTValue createNBTValue(int i);
NBTValue createNBTValue(long l);
NBTValue createNBTValue(long[] arr);
NBTValue createNBTValue(byte[] arr);
NBTValue createNBTValue(int[] arr);
NBTValue createNBTValue(String string);
StatusEffectInstance createStatusEffectInstance(StatusEffect statusEffect, int duration,
int amplifier, boolean ambient);
DamageData createDamageData(DamageData.Type type, Entity entityCause, boolean isIndirect);
@Deprecated ItemStack createItemStack(ItemType itemType, int count, int damage, BinaryTagHolder tag);
ItemStack createItemStack(ItemType itemType, int count, int damage, NBTObject nbt);
Scoreboard createScoreboard();
BlockState createBlockState(BlockType type, Location location);
BlockState blockStateOfBlock(Block block);
CommandSourceInfo createCommandSourceInfo(CommandSender sender, @Nullable Entity executingEntity, Location location, FactoryServer server);
CommandDispatcher<CommandSourceInfo> getCommandDispatcher();
static Builder getInstance() {
return FactoryAPI.getInstance().getBuilder();
}
}
@@ -0,0 +1,22 @@
package com.combatreforged.factory.api.command;
import com.combatreforged.factory.api.FactoryServer;
import net.kyori.adventure.text.Component;
public interface CommandSender {
default int runCommand(String command) {
return runCommand(command, getPermissionLevel(), true);
}
default int runCommand(String command, int permissionLevel) {
return runCommand(command, permissionLevel, true);
}
int runCommand(String command, int permissionLevel, boolean giveFeedback);
void sendMessage(Component message);
int getPermissionLevel();
FactoryServer getServer();
}
@@ -0,0 +1,56 @@
package com.combatreforged.factory.api.command;
import com.combatreforged.factory.api.FactoryServer;
import com.combatreforged.factory.api.world.entity.Entity;
import com.combatreforged.factory.api.world.util.Location;
import net.kyori.adventure.text.Component;
import org.jetbrains.annotations.Nullable;
public interface CommandSourceInfo {
CommandSender getSender();
@Nullable Entity getExecutingEntity();
Location getLocation();
FactoryServer getServer();
void sendMessage(Component message);
static Builder builder() {
return new Builder();
}
class Builder {
private CommandSender source;
@Nullable private Entity executingEntity;
private Location location;
private FactoryServer server;
Builder() {}
public Builder source(CommandSender source) {
this.source = source;
return this;
}
public Builder executingEntity(Entity entity) {
this.executingEntity = entity;
return this;
}
public Builder location(Location location) {
this.location = location;
return this;
}
public Builder server(FactoryServer server) {
this.server = server;
return this;
}
public CommandSourceInfo build() {
return com.combatreforged.factory.api.builder.Builder.getInstance().createCommandSourceInfo(source, executingEntity, location, server);
}
}
}
@@ -0,0 +1,17 @@
package com.combatreforged.factory.api.command;
import com.mojang.brigadier.arguments.ArgumentType;
import com.mojang.brigadier.builder.LiteralArgumentBuilder;
import com.mojang.brigadier.builder.RequiredArgumentBuilder;
public final class CommandUtils {
private CommandUtils() {}
public static LiteralArgumentBuilder<CommandSourceInfo> literal(String literal) {
return LiteralArgumentBuilder.literal(literal);
}
public static <T> RequiredArgumentBuilder<CommandSourceInfo, T> argument(String name, ArgumentType<T> argumentType) {
return RequiredArgumentBuilder.argument(name, argumentType);
}
}
@@ -0,0 +1,8 @@
package com.combatreforged.factory.api.entrypoint;
import com.combatreforged.factory.api.FactoryAPI;
import com.combatreforged.factory.api.FactoryServer;
public interface FactoryPlugin {
void onFactoryLoad(FactoryAPI api, FactoryServer server);
}
@@ -0,0 +1,6 @@
package com.combatreforged.factory.api.event;
public interface Cancellable {
void setCancelled(boolean cancelled);
boolean isCancelled();
}
@@ -0,0 +1,16 @@
package com.combatreforged.factory.api.event;
import java.util.ArrayList;
import java.util.List;
public class Event {
private final List<Runnable> runAfterwards = new ArrayList<>();
public void runAfterwards(Runnable runAfterwards) {
this.runAfterwards.add(runAfterwards);
}
public List<Runnable> getAfterEventFunctions() {
return this.runAfterwards;
}
}
@@ -0,0 +1,100 @@
package com.combatreforged.factory.api.event;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.function.Predicate;
public class EventBackend<T extends Event> {
public static final Logger LOGGER = LogManager.getLogger("EventBackend");
private final Map<Listener<T>, Integer> priorityMap;
private final List<Listener<T>> listeners;
private EventBackend() {
priorityMap = new HashMap<>();
listeners = new ArrayList<>();
}
public void register(final Listener<T> listener) {
register(listener, 0);
}
public void register(final Listener<T> listener, int priority) {
if (priority < -100 || priority > 100) {
LOGGER.error("Listener " + listener.toString() + " tried to register with an invalid priority of " + priority + " (has to be between -100 and 100)!");
}
else if (!listeners.contains(listener)) {
int index;
for (index = 0; index < listeners.size(); index++) {
if (!priorityMap.containsKey(listeners.get(index))) {
LOGGER.error("Priority map doesn't contain entry for registered listener " + listener.toString() + "!");
}
else if (priorityMap.get(listeners.get(index)) < priority) {
break;
}
}
priorityMap.put(listener, priority);
listeners.add(index, listener);
}
else if (listeners.contains(listener)) {
LOGGER.warn("Listener " + listener.toString() + " is already registered!");
}
}
public void register(final Listener<T> listener, Predicate<T> filter) {
this.register(listener, filter, 0);
}
public void register(final Listener<T> listener, final Predicate<T> filter, int priority) {
this.register((event) -> {
if (filter.test(event)) {
listener.onEvent(event);
}
}, priority);
}
public void unregister(Listener<T> listener) {
listeners.remove(listener);
priorityMap.remove(listener);
}
public void invoke(T event) {
for (Listener<T> listener : listeners) {
try { listener.onEvent(event); }
catch (Exception e) {
LOGGER.error("An error occurred while executing event " + event.getClass().getSimpleName() + " in listener " + listener.toString() + ": ", e);
}
}
}
public void invokeEndFunctions(T event) {
for (Runnable runnable : event.getAfterEventFunctions()) {
try {
runnable.run();
} catch (Exception e) {
LOGGER.error("An error occurred while executing after event functions for event " + event.getClass().getSimpleName() + " in runnable " + runnable.toString() + ": ", e);
}
}
}
public static <T extends Event> EventBackend<T> create(Class<T> eventClass) {
return new EventBackend<>();
}
public static final class Priority {
public static final int HIGHEST = 100;
public static final int VERY_HIGH = 75;
public static final int HIGH = 50;
public static final int HIGHER = 25;
public static final int DEFAULT = 0;
public static final int LOWER = -25;
public static final int LOW = -50;
public static final int VERY_LOW = -75;
public static final int LOWEST = -100;
}
}
@@ -0,0 +1,6 @@
package com.combatreforged.factory.api.event;
@FunctionalInterface
public interface Listener<T extends Event> {
void onEvent(T event);
}
@@ -0,0 +1,16 @@
package com.combatreforged.factory.api.event.entity;
import com.combatreforged.factory.api.event.Event;
import com.combatreforged.factory.api.world.entity.Entity;
public abstract class EntityEvent extends Event {
private final Entity entity;
public EntityEvent(Entity entity) {
this.entity = entity;
}
public Entity getEntity() {
return entity;
}
}
@@ -0,0 +1,49 @@
package com.combatreforged.factory.api.event.entity;
import com.combatreforged.factory.api.event.Cancellable;
import com.combatreforged.factory.api.event.EventBackend;
import com.combatreforged.factory.api.world.damage.DamageData;
import com.combatreforged.factory.api.world.entity.LivingEntity;
public class LivingEntityDamageEvent extends LivingEntityEvent implements Cancellable {
public static final EventBackend<LivingEntityDamageEvent> BACKEND = EventBackend.create(LivingEntityDamageEvent.class);
private boolean cancelled;
private DamageData cause;
private float damage;
public LivingEntityDamageEvent(LivingEntity entity, DamageData cause, float damage) {
super(entity);
this.cause = cause;
this.damage = damage;
this.cancelled = false;
}
public DamageData getCause() {
return cause;
}
public void setCause(DamageData cause) {
this.cause = cause;
}
public float getDamage() {
return damage;
}
public void setDamage(float damage) {
this.damage = damage;
}
@Override
public void setCancelled(boolean cancelled) {
this.cancelled = cancelled;
}
@Override
public boolean isCancelled() {
return cancelled;
}
}
@@ -0,0 +1,54 @@
package com.combatreforged.factory.api.event.entity;
import com.combatreforged.factory.api.event.EventBackend;
import com.combatreforged.factory.api.world.damage.DamageData;
import com.combatreforged.factory.api.world.entity.LivingEntity;
public class LivingEntityDeathEvent extends LivingEntityEvent {
public static final EventBackend<LivingEntityDeathEvent> BACKEND = EventBackend.create(LivingEntityDeathEvent.class);
private DamageData cause;
private boolean dropLoot;
private boolean dropEquipment;
private boolean dropExperience;
public LivingEntityDeathEvent(LivingEntity entity, DamageData cause, boolean dropLoot, boolean dropEquipment, boolean dropExperience) {
super(entity);
this.cause = cause;
this.dropLoot = dropLoot;
this.dropEquipment = dropEquipment;
this.dropExperience = dropExperience;
}
public DamageData getCause() {
return cause;
}
public void setCause(DamageData cause) {
this.cause = cause;
}
public boolean isDropLoot() {
return dropLoot;
}
public void setDropLoot(boolean dropLoot) {
this.dropLoot = dropLoot;
}
public boolean isDropEquipment() {
return dropEquipment;
}
public void setDropEquipment(boolean dropEquipment) {
this.dropEquipment = dropEquipment;
}
public boolean isDropExperience() {
return dropExperience;
}
public void setDropExperience(boolean dropExperience) {
this.dropExperience = dropExperience;
}
}
@@ -0,0 +1,16 @@
package com.combatreforged.factory.api.event.entity;
import com.combatreforged.factory.api.world.entity.LivingEntity;
public abstract class LivingEntityEvent extends EntityEvent {
private final LivingEntity entity;
public LivingEntityEvent(LivingEntity entity) {
super(entity);
this.entity = entity;
}
public LivingEntity getLivingEntity() {
return entity;
}
}
@@ -0,0 +1,79 @@
package com.combatreforged.factory.api.event.entity;
import com.combatreforged.factory.api.event.Cancellable;
import com.combatreforged.factory.api.event.EventBackend;
import com.combatreforged.factory.api.world.effect.StatusEffect;
import com.combatreforged.factory.api.world.entity.LivingEntity;
import org.jetbrains.annotations.Nullable;
import java.util.Objects;
public class LivingEntityHealEvent extends LivingEntityEvent implements Cancellable {
public static final EventBackend<LivingEntityHealEvent> BACKEND = EventBackend.create(LivingEntityHealEvent.class);
private boolean cancelled;
private float amount;
private final HealCause cause;
public LivingEntityHealEvent(LivingEntity entity, float amount, HealCause cause) {
super(entity);
this.amount = amount;
this.cause = cause;
}
public float getAmount() {
return amount;
}
public void setAmount(float amount) {
this.amount = amount;
}
public HealCause getCause() {
return cause;
}
@Override
public void setCancelled(boolean cancelled) {
this.cancelled = cancelled;
}
@Override
public boolean isCancelled() {
return cancelled;
}
public static class HealCause {
public static final HealCause NATURAL_REGENERATION = new HealCause();
public static HealCause effect(StatusEffect effect) {
return new HealCause(effect);
}
private final @Nullable StatusEffect effect;
private HealCause() {
this.effect = null;
}
private HealCause(@Nullable StatusEffect effect) {
this.effect = effect;
}
public @Nullable StatusEffect getEffect() {
return effect;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (!(o instanceof HealCause)) return false;
HealCause healCause = (HealCause) o;
return Objects.equals(effect, healCause.effect);
}
@Override
public int hashCode() {
return Objects.hash(effect);
}
}
}
@@ -0,0 +1,62 @@
package com.combatreforged.factory.api.event.player;
import com.combatreforged.factory.api.event.Cancellable;
import com.combatreforged.factory.api.event.EventBackend;
import com.combatreforged.factory.api.world.World;
import com.combatreforged.factory.api.world.block.Block;
import com.combatreforged.factory.api.world.entity.player.Player;
import com.combatreforged.factory.api.world.item.ItemStack;
import com.combatreforged.factory.api.world.util.Location;
public class PlayerBreakBlockEvent extends PlayerEvent implements Cancellable {
public static final EventBackend<PlayerBreakBlockEvent> BACKEND = EventBackend.create(PlayerBreakBlockEvent.class);
private boolean cancelled;
private final Block block;
private final Location location;
private final ItemStack miningStack;
private boolean dropBlock;
public PlayerBreakBlockEvent(Player player, Block block, Location location, ItemStack miningStack, boolean dropBlock) {
super(player);
this.block = block;
this.location = location;
this.miningStack = miningStack;
this.dropBlock = dropBlock;
}
public ItemStack getMiningStack() {
return miningStack;
}
public Block getBlock() {
return block;
}
public Location getLocation() {
return location;
}
public World getWorld() {
return location.getWorld();
}
public boolean isDropBlock() {
return dropBlock;
}
public void setDropBlock(boolean dropBlock) {
this.dropBlock = dropBlock;
}
@Override
public boolean isCancelled() {
return cancelled;
}
@Override
public void setCancelled(boolean cancelled) {
this.cancelled = cancelled;
}
}
@@ -0,0 +1,61 @@
package com.combatreforged.factory.api.event.player;
import com.combatreforged.factory.api.event.Cancellable;
import com.combatreforged.factory.api.event.EventBackend;
import com.combatreforged.factory.api.world.block.Block;
import com.combatreforged.factory.api.world.block.BlockState;
import com.combatreforged.factory.api.world.entity.player.Player;
import com.combatreforged.factory.api.world.util.Location;
public class PlayerChangeBlockStateEvent extends PlayerEvent implements Cancellable {
public static final EventBackend<PlayerChangeBlockStateEvent> BACKEND = EventBackend.create(PlayerChangeBlockStateEvent.class);
private boolean cancelled;
private final Location location;
private final Block currentBlockState;
private BlockState newBlockState;
private final Action action;
public PlayerChangeBlockStateEvent(Player player, Location location, Block currentBlockState, BlockState newBlockState, Action action) {
super(player);
this.location = location;
this.currentBlockState = currentBlockState;
this.newBlockState = newBlockState;
this.action = action;
}
public Location getLocation() {
return location;
}
public Block getCurrentBlockState() {
return currentBlockState;
}
public BlockState getNewBlockState() {
return newBlockState;
}
public void setNewBlockState(BlockState newBlockState) {
this.newBlockState = newBlockState;
}
public Action getAction() {
return action;
}
@Override
public void setCancelled(boolean cancelled) {
this.cancelled = cancelled;
}
@Override
public boolean isCancelled() {
return cancelled;
}
public enum Action {
OPEN_CLOSE, STRIP_BLOCK, PULL_LEVER, PRESS_BUTTON, TRAMPLE_ON_FARMLAND
}
}
@@ -0,0 +1,67 @@
package com.combatreforged.factory.api.event.player;
import com.combatreforged.factory.api.event.Cancellable;
import com.combatreforged.factory.api.event.EventBackend;
import com.combatreforged.factory.api.world.entity.player.Player;
import java.util.function.BiConsumer;
import java.util.function.Function;
public class PlayerChangeMovementStateEvent extends PlayerEvent implements Cancellable {
public static final EventBackend<PlayerChangeMovementStateEvent> BACKEND = EventBackend.create(PlayerChangeMovementStateEvent.class);
private boolean cancelled;
private final ChangedState changedState;
private boolean changedValue;
private final boolean previousValue;
public PlayerChangeMovementStateEvent(Player player, ChangedState changedState, boolean changedValue) {
super(player);
this.changedState = changedState;
this.changedValue = changedValue;
this.previousValue = changedState.playerGetter.apply(player);
}
public ChangedState getChangedState() {
return changedState;
}
public boolean getChangedValue() {
return changedValue;
}
public void setChangedValue(boolean changedValue) {
this.changedValue = changedValue;
}
public boolean getPreviousValue() {
return previousValue;
}
@Override
public void setCancelled(boolean cancelled) {
this.cancelled = cancelled;
}
@Override
public boolean isCancelled() {
return cancelled;
}
@SuppressWarnings("ImmutableEnumChecker")
public enum ChangedState {
SPRINTING(Player::isSprinting, Player::setSprinting),
SWIMMING(Player::isSwimming, Player::setSwimming),
SNEAKING(Player::isSneaking, Player::setSneaking),
FALL_FLYING(Player::isFallFlying, Player::setFallFlying),
FLYING(Player::isFlying, Player::setFlying);
public final Function<Player, Boolean> playerGetter;
public final BiConsumer<Player, Boolean> playerSetter;
ChangedState(Function<Player, Boolean> playerGetter, BiConsumer<Player, Boolean> playerSetter) {
this.playerGetter = playerGetter;
this.playerSetter = playerSetter;
}
}
}
@@ -0,0 +1,32 @@
package com.combatreforged.factory.api.event.player;
import com.combatreforged.factory.api.event.Cancellable;
import com.combatreforged.factory.api.event.EventBackend;
import com.combatreforged.factory.api.world.entity.player.Player;
import com.combatreforged.factory.api.world.item.container.menu.ContainerMenu;
public class PlayerCloseContainerEvent extends PlayerEvent implements Cancellable {
public static EventBackend<PlayerCloseContainerEvent> BACKEND = EventBackend.create(PlayerCloseContainerEvent.class);
private boolean cancelled;
private final ContainerMenu closedContainer;
public PlayerCloseContainerEvent(Player player, ContainerMenu closedContainer) {
super(player);
this.closedContainer = closedContainer;
}
public ContainerMenu getClosedContainer() {
return closedContainer;
}
@Override
public void setCancelled(boolean cancelled) {
this.cancelled = cancelled;
}
@Override
public boolean isCancelled() {
return cancelled;
}
}
@@ -0,0 +1,68 @@
package com.combatreforged.factory.api.event.player;
import com.combatreforged.factory.api.event.Cancellable;
import com.combatreforged.factory.api.event.EventBackend;
import com.combatreforged.factory.api.world.entity.player.Player;
import com.combatreforged.factory.api.world.item.ItemStack;
import com.combatreforged.factory.api.world.item.container.menu.Button;
import com.combatreforged.factory.api.world.item.container.menu.ContainerMenu;
import com.combatreforged.factory.api.world.item.container.menu.SlotClickType;
import org.jetbrains.annotations.Nullable;
public class PlayerContainerClickEvent extends PlayerEvent implements Cancellable {
public static final EventBackend<PlayerContainerClickEvent> BACKEND = EventBackend.create(PlayerContainerClickEvent.class);
private boolean cancelled;
private final ContainerMenu menu;
private final int targetSlot; // -1 for Button.DROP, -999 if no slot is selected (depends on type)
private final SlotClickType slotClickType;
private final Button button;
@Nullable private final ItemStack targetStack;
@Nullable private final ItemStack cursorStack;
public PlayerContainerClickEvent(Player player, ContainerMenu menu, int targetSlot, SlotClickType slotClickType, Button button, @Nullable ItemStack targetStack, @Nullable ItemStack cursorStack) {
super(player);
this.menu = menu;
this.targetSlot = targetSlot;
this.slotClickType = slotClickType;
this.button = button;
this.targetStack = targetStack;
this.cursorStack = cursorStack;
}
public ContainerMenu getMenu() {
return menu;
}
public int getTargetSlot() {
return targetSlot;
}
public SlotClickType getClickType() {
return slotClickType;
}
public Button getButton() {
return button;
}
@Nullable public ItemStack getTargetStack() {
return targetStack;
}
@Nullable public ItemStack getCursorStack() {
return cursorStack;
}
@Override
public void setCancelled(boolean cancelled) {
this.cancelled = cancelled;
}
@Override
public boolean isCancelled() {
return cancelled;
}
}
@@ -0,0 +1,43 @@
package com.combatreforged.factory.api.event.player;
import com.combatreforged.factory.api.event.EventBackend;
import com.combatreforged.factory.api.event.entity.LivingEntityDeathEvent;
import com.combatreforged.factory.api.world.damage.DamageData;
import com.combatreforged.factory.api.world.entity.player.Player;
import com.combatreforged.factory.api.world.scoreboard.ScoreboardTeam;
import net.kyori.adventure.text.Component;
public class PlayerDeathEvent extends LivingEntityDeathEvent {
public static final EventBackend<PlayerDeathEvent> BACKEND = EventBackend.create(PlayerDeathEvent.class);
private final Player player;
private Component deathMessage;
private ScoreboardTeam.VisibleFor visibleFor;
public PlayerDeathEvent(Player player, DamageData cause, boolean dropLoot, boolean dropEquipment, boolean dropExperience, Component deathMessage, ScoreboardTeam.VisibleFor visibleFor) {
super(player, cause, dropLoot, dropEquipment, dropExperience);
this.player = player;
this.deathMessage = deathMessage;
this.visibleFor = visibleFor;
}
public Player getPlayer() {
return player;
}
public Component getDeathMessage() {
return deathMessage;
}
public void setDeathMessage(Component deathMessage) {
this.deathMessage = deathMessage;
}
public ScoreboardTeam.VisibleFor getVisibleFor() {
return visibleFor;
}
public void setVisibleFor(ScoreboardTeam.VisibleFor visibleFor) {
this.visibleFor = visibleFor;
}
}
@@ -0,0 +1,30 @@
package com.combatreforged.factory.api.event.player;
import com.combatreforged.factory.api.event.EventBackend;
import com.combatreforged.factory.api.world.entity.player.Player;
import net.kyori.adventure.text.Component;
public class PlayerDisconnectEvent extends PlayerEvent {
public static final EventBackend<PlayerDisconnectEvent> BACKEND = EventBackend.create(PlayerDisconnectEvent.class);
private final Component disconnectReason;
private Component leaveMessage;
public PlayerDisconnectEvent(Player player, Component disconnectReason, Component leaveMessage) {
super(player);
this.disconnectReason = disconnectReason;
this.leaveMessage = leaveMessage;
}
public Component getDisconnectReason() {
return disconnectReason;
}
public Component getLeaveMessage() {
return leaveMessage;
}
public void setLeaveMessage(Component leaveMessage) {
this.leaveMessage = leaveMessage;
}
}
@@ -0,0 +1,17 @@
package com.combatreforged.factory.api.event.player;
import com.combatreforged.factory.api.event.entity.LivingEntityEvent;
import com.combatreforged.factory.api.world.entity.player.Player;
public abstract class PlayerEvent extends LivingEntityEvent {
private final Player player;
public PlayerEvent(Player player) {
super(player);
this.player = player;
}
public Player getPlayer() {
return player;
}
}
@@ -0,0 +1,46 @@
package com.combatreforged.factory.api.event.player;
import com.combatreforged.factory.api.event.Cancellable;
import com.combatreforged.factory.api.event.EventBackend;
import com.combatreforged.factory.api.world.entity.player.Player;
public class PlayerFoodLevelsChangeEvent extends PlayerEvent implements Cancellable {
public static final EventBackend<PlayerFoodLevelsChangeEvent> BACKEND = EventBackend.create(PlayerFoodLevelsChangeEvent.class);
private boolean cancelled;
private float saturation;
private int foodLevel;
public PlayerFoodLevelsChangeEvent(Player player, float saturation, int foodLevel) {
super(player);
this.saturation = saturation;
this.foodLevel = foodLevel;
}
public float getSaturation() {
return saturation;
}
public void setSaturation(float saturation) {
this.saturation = saturation;
}
public int getFoodLevel() {
return foodLevel;
}
public void setFoodLevel(int foodLevel) {
this.foodLevel = foodLevel;
}
@Override
public void setCancelled(boolean cancelled) {
this.cancelled = cancelled;
}
@Override
public boolean isCancelled() {
return cancelled;
}
}
@@ -0,0 +1,45 @@
package com.combatreforged.factory.api.event.player;
import com.combatreforged.factory.api.event.Cancellable;
import com.combatreforged.factory.api.event.EventBackend;
import com.combatreforged.factory.api.world.entity.player.Player;
import com.combatreforged.factory.api.world.item.ItemStack;
public class PlayerHotbarDropItemEvent extends PlayerEvent implements Cancellable {
public static final EventBackend<PlayerHotbarDropItemEvent> BACKEND = EventBackend.create(PlayerHotbarDropItemEvent.class);
private boolean cancelled;
private final ItemStack itemStack;
private final boolean dropEntireStack;
private final int hotbarSlot;
public PlayerHotbarDropItemEvent(Player player, ItemStack itemStack, boolean dropEntireStack, int hotbarSlot) {
super(player);
this.itemStack = itemStack;
this.dropEntireStack = dropEntireStack;
this.hotbarSlot = hotbarSlot;
}
public ItemStack getItemStack() {
return itemStack;
}
public boolean isDropEntireStack() {
return dropEntireStack;
}
public int getHotbarSlot() {
return hotbarSlot;
}
@Override
public void setCancelled(boolean cancelled) {
this.cancelled = cancelled;
}
@Override
public boolean isCancelled() {
return cancelled;
}
}
@@ -0,0 +1,28 @@
package com.combatreforged.factory.api.event.player;
import com.combatreforged.factory.api.event.EventBackend;
import com.combatreforged.factory.api.world.entity.Entity;
import com.combatreforged.factory.api.world.entity.equipment.HandSlot;
import com.combatreforged.factory.api.world.entity.player.Player;
import com.combatreforged.factory.api.world.util.Location;
public class PlayerInteractAtEntityEvent extends PlayerInteractEntityEvent {
public static final EventBackend<PlayerInteractAtEntityEvent> BACKEND = EventBackend.create(PlayerInteractAtEntityEvent.class);
private final Location interactionLocation;
private final HandSlot hand;
public PlayerInteractAtEntityEvent(Player player, Entity entity, Location interactionLocation, HandSlot hand) {
super(player, entity);
this.interactionLocation = interactionLocation;
this.hand = hand;
}
public Location getInteractionLocation() {
return interactionLocation;
}
public HandSlot getHand() {
return hand;
}
}
@@ -0,0 +1,54 @@
package com.combatreforged.factory.api.event.player;
import com.combatreforged.factory.api.event.Cancellable;
import com.combatreforged.factory.api.event.EventBackend;
import com.combatreforged.factory.api.world.block.Block;
import com.combatreforged.factory.api.world.entity.equipment.HandSlot;
import com.combatreforged.factory.api.world.entity.player.Player;
import com.combatreforged.factory.api.world.item.ItemStack;
import com.combatreforged.factory.api.world.util.Location;
public class PlayerInteractBlockEvent extends PlayerEvent implements Cancellable {
public static final EventBackend<PlayerInteractBlockEvent> BACKEND = EventBackend.create(PlayerInteractBlockEvent.class);
private boolean cancelled;
private final Block block;
private final Location location;
private final HandSlot hand;
private final ItemStack itemStack;
public PlayerInteractBlockEvent(Player player, Block block, Location location, HandSlot hand, ItemStack itemStack) {
super(player);
this.block = block;
this.location = location;
this.hand = hand;
this.itemStack = itemStack;
}
public Block getBlock() {
return block;
}
public Location getLocation() {
return location;
}
public HandSlot getHand() {
return hand;
}
public ItemStack getItemStack() {
return itemStack;
}
@Override
public void setCancelled(boolean cancelled) {
this.cancelled = cancelled;
}
@Override
public boolean isCancelled() {
return cancelled;
}
}
@@ -0,0 +1,33 @@
package com.combatreforged.factory.api.event.player;
import com.combatreforged.factory.api.event.Cancellable;
import com.combatreforged.factory.api.event.EventBackend;
import com.combatreforged.factory.api.world.entity.Entity;
import com.combatreforged.factory.api.world.entity.player.Player;
public class PlayerInteractEntityEvent extends PlayerEvent implements Cancellable {
public static final EventBackend<PlayerInteractEntityEvent> BACKEND = EventBackend.create(PlayerInteractEntityEvent.class);
private boolean cancelled;
private final Entity entity;
public PlayerInteractEntityEvent(Player player, Entity entity) {
super(player);
this.entity = entity;
}
@Override
public Entity getEntity() {
return entity;
}
@Override
public void setCancelled(boolean cancelled) {
this.cancelled = cancelled;
}
@Override
public boolean isCancelled() {
return cancelled;
}
}
@@ -0,0 +1,24 @@
package com.combatreforged.factory.api.event.player;
import com.combatreforged.factory.api.event.EventBackend;
import com.combatreforged.factory.api.world.entity.player.Player;
import net.kyori.adventure.text.Component;
public class PlayerJoinEvent extends PlayerEvent {
public static final EventBackend<PlayerJoinEvent> BACKEND = EventBackend.create(PlayerJoinEvent.class);
private Component joinMessage;
public PlayerJoinEvent(Player player, Component joinMessage) {
super(player);
this.joinMessage = joinMessage;
}
public Component getJoinMessage() {
return joinMessage;
}
public void setJoinMessage(Component joinMessage) {
this.joinMessage = joinMessage;
}
}
@@ -0,0 +1,43 @@
package com.combatreforged.factory.api.event.player;
import com.combatreforged.factory.api.event.Cancellable;
import com.combatreforged.factory.api.event.EventBackend;
import com.combatreforged.factory.api.world.entity.player.Player;
import com.combatreforged.factory.api.world.util.Location;
public class PlayerMoveEvent extends PlayerEvent implements Cancellable {
public static final EventBackend<PlayerMoveEvent> BACKEND = EventBackend.create(PlayerMoveEvent.class);
private final Location oldPosition;
private Location newPosition;
private boolean cancelled;
public PlayerMoveEvent(Player player, Location oldPosition, Location newPosition, boolean cancelled) {
super(player);
this.oldPosition = oldPosition;
this.newPosition = newPosition;
this.cancelled = cancelled;
}
@Override
public void setCancelled(boolean cancelled) {
this.cancelled = cancelled;
}
@Override
public boolean isCancelled() {
return cancelled;
}
public Location getOldPosition() {
return oldPosition;
}
public Location getNewPosition() {
return newPosition;
}
public void setNewPosition(Location newPosition) {
this.newPosition = newPosition;
}
}
@@ -0,0 +1,33 @@
package com.combatreforged.factory.api.event.player;
import com.combatreforged.factory.api.event.Cancellable;
import com.combatreforged.factory.api.event.EventBackend;
import com.combatreforged.factory.api.world.entity.player.Player;
import com.combatreforged.factory.api.world.item.container.menu.ContainerMenu;
import org.jetbrains.annotations.Nullable;
public class PlayerOpenContainerEvent extends PlayerEvent implements Cancellable {
public static final EventBackend<PlayerOpenContainerEvent> BACKEND = EventBackend.create(PlayerOpenContainerEvent.class);
private boolean cancelled;
private final @Nullable ContainerMenu newMenu;
public PlayerOpenContainerEvent(Player player, @Nullable ContainerMenu newMenu) {
super(player);
this.newMenu = newMenu;
}
public @Nullable ContainerMenu getNewMenu() {
return newMenu;
}
@Override
public void setCancelled(boolean cancelled) {
this.cancelled = cancelled;
}
@Override
public boolean isCancelled() {
return cancelled;
}
}
@@ -0,0 +1,71 @@
package com.combatreforged.factory.api.event.player;
import com.combatreforged.factory.api.event.Cancellable;
import com.combatreforged.factory.api.event.EventBackend;
import com.combatreforged.factory.api.world.World;
import com.combatreforged.factory.api.world.block.Block;
import com.combatreforged.factory.api.world.block.BlockState;
import com.combatreforged.factory.api.world.entity.equipment.HandSlot;
import com.combatreforged.factory.api.world.entity.player.Player;
import com.combatreforged.factory.api.world.item.ItemStack;
import com.combatreforged.factory.api.world.util.Location;
import org.jetbrains.annotations.Nullable;
public class PlayerPlaceBlockEvent extends PlayerEvent implements Cancellable {
public static final EventBackend<PlayerPlaceBlockEvent> BACKEND = EventBackend.create(PlayerPlaceBlockEvent.class);
private boolean cancelled;
private final Location location;
private final @Nullable Block currentBlockState;
private @Nullable BlockState newBlockState;
private final ItemStack blockStack;
private final HandSlot placingHand;
public PlayerPlaceBlockEvent(Player player, Location location, @Nullable Block currentBlockState, @Nullable BlockState newBlockState, ItemStack blockStack, HandSlot placingHand) {
super(player);
this.location = location;
this.currentBlockState = currentBlockState;
this.newBlockState = newBlockState;
this.blockStack = blockStack;
this.placingHand = placingHand;
}
public Location getLocation() {
return location;
}
public World getWorld() {
return location.getWorld();
}
public @Nullable Block getCurrentBlockState() {
return currentBlockState;
}
public @Nullable BlockState getNewBlockState() {
return newBlockState;
}
public void setNewBlockState(@Nullable BlockState newBlockState) {
this.newBlockState = newBlockState;
}
public ItemStack getBlockStack() {
return blockStack;
}
public HandSlot getPlacingHand() {
return placingHand;
}
@Override
public void setCancelled(boolean cancelled) {
this.cancelled = cancelled;
}
@Override
public boolean isCancelled() {
return cancelled;
}
}
@@ -0,0 +1,47 @@
package com.combatreforged.factory.api.event.player;
import com.combatreforged.factory.api.event.EventBackend;
import com.combatreforged.factory.api.world.entity.player.GameModeType;
import com.combatreforged.factory.api.world.entity.player.Player;
import com.combatreforged.factory.api.world.util.Location;
import org.jetbrains.annotations.Nullable;
public class PlayerRespawnEvent extends PlayerEvent {
public static final EventBackend<PlayerRespawnEvent> BACKEND = EventBackend.create(PlayerRespawnEvent.class);
@Nullable private Location spawnpoint;
private boolean spawnpointForced;
private GameModeType respawnMode;
public PlayerRespawnEvent(Player player, @Nullable Location spawnpoint, boolean spawnpointForced, GameModeType respawnMode) {
super(player);
this.spawnpoint = spawnpoint;
this.spawnpointForced = spawnpointForced;
this.respawnMode = respawnMode;
}
@Nullable
public Location getSpawnpoint() {
return spawnpoint;
}
public void setSpawnpoint(@Nullable Location spawnpoint) {
this.spawnpoint = spawnpoint;
}
public boolean isSpawnpointForced() {
return spawnpointForced;
}
public void setSpawnpointForced(boolean spawnpointForced) {
this.spawnpointForced = spawnpointForced;
}
public GameModeType getRespawnMode() {
return respawnMode;
}
public void setRespawnMode(GameModeType respawnMode) {
this.respawnMode = respawnMode;
}
}
@@ -0,0 +1,38 @@
package com.combatreforged.factory.api.event.player;
import com.combatreforged.factory.api.event.Cancellable;
import com.combatreforged.factory.api.event.EventBackend;
import com.combatreforged.factory.api.world.entity.player.Player;
public class PlayerSwitchActiveSlotEvent extends PlayerEvent implements Cancellable {
public static final EventBackend<PlayerSwitchActiveSlotEvent> BACKEND = EventBackend.create(PlayerSwitchActiveSlotEvent.class);
private boolean cancelled;
private int newSlot;
public PlayerSwitchActiveSlotEvent(Player player, int newSlot) {
super(player);
this.newSlot = newSlot;
}
public int getNewSlot() {
return newSlot;
}
public void setNewSlot(int newSlot) {
if (newSlot < 0 || newSlot > 8) {
throw new IllegalArgumentException("New slot must be between 0-8");
}
this.newSlot = newSlot;
}
@Override
public void setCancelled(boolean cancelled) {
this.cancelled = cancelled;
}
@Override
public boolean isCancelled() {
return cancelled;
}
}
@@ -0,0 +1,39 @@
package com.combatreforged.factory.api.event.player;
import com.combatreforged.factory.api.event.Cancellable;
import com.combatreforged.factory.api.event.EventBackend;
import com.combatreforged.factory.api.world.entity.equipment.HandSlot;
import com.combatreforged.factory.api.world.entity.player.Player;
import com.combatreforged.factory.api.world.item.ItemStack;
public class PlayerUseItemEvent extends PlayerEvent implements Cancellable {
public static final EventBackend<PlayerUseItemEvent> BACKEND = EventBackend.create(PlayerUseItemEvent.class);
private boolean cancelled;
private final ItemStack itemStack;
private final HandSlot hand;
public PlayerUseItemEvent(Player player, ItemStack itemStack, HandSlot hand) {
super(player);
this.itemStack = itemStack;
this.hand = hand;
}
public ItemStack getItemStack() {
return itemStack;
}
public HandSlot getHand() {
return hand;
}
@Override
public void setCancelled(boolean cancelled) {
this.cancelled = cancelled;
}
@Override
public boolean isCancelled() {
return cancelled;
}
}
@@ -0,0 +1,18 @@
package com.combatreforged.factory.api.event.server;
import com.combatreforged.factory.api.FactoryServer;
import com.combatreforged.factory.api.event.Event;
import com.combatreforged.factory.api.event.EventBackend;
public class ServerStartupFinishEvent extends Event {
public static final EventBackend<ServerStartupFinishEvent> BACKEND = EventBackend.create(ServerStartupFinishEvent.class);
private final FactoryServer server;
public ServerStartupFinishEvent(FactoryServer server) {
this.server = server;
}
public FactoryServer getServer() {
return server;
}
}
@@ -0,0 +1,18 @@
package com.combatreforged.factory.api.event.server;
import com.combatreforged.factory.api.FactoryServer;
import com.combatreforged.factory.api.event.Event;
import com.combatreforged.factory.api.event.EventBackend;
public class ServerStopEvent extends Event {
public static final EventBackend<ServerStopEvent> BACKEND = EventBackend.create(ServerStopEvent.class);
private final FactoryServer server;
public ServerStopEvent(FactoryServer server) {
this.server = server;
}
public FactoryServer getServer() {
return server;
}
}
@@ -0,0 +1,25 @@
package com.combatreforged.factory.api.event.server;
import com.combatreforged.factory.api.FactoryServer;
import com.combatreforged.factory.api.event.Event;
import com.combatreforged.factory.api.event.EventBackend;
public class ServerTickEvent extends Event {
public static final EventBackend<ServerTickEvent> BACKEND = EventBackend.create(ServerTickEvent.class);
private final FactoryServer server;
private final int tickID;
public ServerTickEvent(FactoryServer server, int tickID) {
this.server = server;
this.tickID = tickID;
}
public FactoryServer getServer() {
return server;
}
public int getTickID() {
return tickID;
}
}
@@ -0,0 +1,16 @@
package com.combatreforged.factory.api.event.world;
import com.combatreforged.factory.api.event.Event;
import com.combatreforged.factory.api.world.World;
public abstract class WorldEvent extends Event {
private final World world;
public WorldEvent(World world) {
this.world = world;
}
public World getWorld() {
return world;
}
}
@@ -0,0 +1,44 @@
package com.combatreforged.factory.api.event.world;
import com.combatreforged.factory.api.event.Cancellable;
import com.combatreforged.factory.api.event.EventBackend;
import com.combatreforged.factory.api.world.World;
import com.combatreforged.factory.api.world.entity.Entity;
import com.combatreforged.factory.api.world.util.Location;
public class WorldSpawnEntityEvent extends WorldEvent implements Cancellable {
public static final EventBackend<WorldSpawnEntityEvent> BACKEND = EventBackend.create(WorldSpawnEntityEvent.class);
private boolean cancelled;
private final Entity entity;
private Location spawnLocation;
public WorldSpawnEntityEvent(World world, Entity entity, Location spawnLocation) {
super(world);
this.entity = entity;
this.spawnLocation = spawnLocation;
}
public Entity getEntity() {
return entity;
}
public Location getSpawnLocation() {
return spawnLocation;
}
public void setSpawnLocation(Location spawnLocation) {
this.spawnLocation = spawnLocation;
}
@Override
public void setCancelled(boolean cancelled) {
this.cancelled = cancelled;
}
@Override
public boolean isCancelled() {
return cancelled;
}
}
@@ -0,0 +1,11 @@
package com.combatreforged.factory.api.exception;
public class FactoryPluginException extends RuntimeException {
public FactoryPluginException(String message) {
super(message);
}
public FactoryPluginException(String message, Throwable cause) {
super(message, cause);
}
}
@@ -0,0 +1,7 @@
package com.combatreforged.factory.api.exception;
public class UnassignableTypeException extends RuntimeException {
public UnassignableTypeException(String message) {
super(message);
}
}
@@ -0,0 +1,12 @@
package com.combatreforged.factory.api.interfaces;
import net.kyori.adventure.text.Component;
public interface MessageReceiver {
void sendMessage(Component component);
void sendMessage(Component component, Type type);
enum Type {
CHAT, SYSTEM, ACTION_BAR
}
}
@@ -0,0 +1,10 @@
package com.combatreforged.factory.api.interfaces;
import com.combatreforged.factory.api.util.Identifier;
import com.combatreforged.factory.api.util.ImplementationUtils;
public interface Namespaced {
default Identifier getNamespaceId() {
return ImplementationUtils.getInstance().getIdentifier(this);
}
}
@@ -0,0 +1,4 @@
package com.combatreforged.factory.api.interfaces;
public interface ObjectMapped {
}
@@ -0,0 +1,5 @@
package com.combatreforged.factory.api.interfaces;
public interface StringIdentified {
String getId();
}
@@ -0,0 +1,19 @@
package com.combatreforged.factory.api.scheduler;
public class ScheduledRepeatingTask extends ScheduledTask {
private final int repeatingDelay;
protected ScheduledRepeatingTask(TaskScheduler scheduler, Runnable task, int delay, int repeatingDelay) {
super(scheduler, task, delay);
this.repeatingDelay = repeatingDelay;
}
public int getRepeatingDelay() {
return repeatingDelay;
}
@Override
public void afterRun() {
this.tick = repeatingDelay;
}
}
@@ -0,0 +1,32 @@
package com.combatreforged.factory.api.scheduler;
public class ScheduledTask extends Task {
int tick;
private final int delay;
protected ScheduledTask(TaskScheduler scheduler, Runnable task, int delay) {
super(scheduler, task);
this.delay = delay;
this.tick = delay;
}
public int getDelay() {
return delay;
}
@Override
public void tick() {
if (this.isActive()) {
if (tick > 0) {
tick--;
} else {
this.run();
this.afterRun();
}
}
}
public void afterRun() {
this.cancel();
}
}
@@ -0,0 +1,38 @@
package com.combatreforged.factory.api.scheduler;
public abstract class Task {
private final TaskScheduler scheduler;
private final Runnable task;
private boolean inactive;
private TaskPointer<?> pointer;
public Task(TaskScheduler scheduler, Runnable task) {
this.scheduler = scheduler;
this.task = task;
this.inactive = false;
}
public void run() {
this.task.run();
}
protected synchronized void markInactive() {
this.inactive = true;
}
public synchronized boolean isActive() {
return !this.inactive;
}
protected synchronized void setPointer(TaskPointer<?> pointer) {
this.pointer = pointer;
}
public abstract void tick();
public synchronized void cancel() {
this.scheduler.cancelTask(pointer);
}
}
@@ -0,0 +1,34 @@
package com.combatreforged.factory.api.scheduler;
import org.jetbrains.annotations.Nullable;
public class TaskPointer<T extends Task> {
private T task;
protected TaskPointer(T task) {
this.task = task;
}
protected synchronized void deleteReference() {
this.task = null;
}
public synchronized void cancel() {
if (task != null && this.task.isActive()) {
task.cancel();
}
}
@Nullable
public synchronized T get() {
if (task != null && task.isActive()) {
return task;
} else {
return null;
}
}
public synchronized boolean isPresent() {
return this.task != null && this.task.isActive();
}
}
@@ -0,0 +1,87 @@
package com.combatreforged.factory.api.scheduler;
import com.combatreforged.factory.api.world.util.Pair;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.jetbrains.annotations.Nullable;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.atomic.AtomicBoolean;
public class TaskScheduler {
public static final Logger LOGGER = LogManager.getLogger("TaskScheduler");
private final AtomicBoolean ticking = new AtomicBoolean(false);
private final Map<TaskPointer<? extends Task>, Task> tasks;
private final List<Runnable> updates;
private TaskScheduler() {
tasks = new HashMap<>();
updates = new ArrayList<>();
}
public static Pair<TaskScheduler, TickFunction> create() {
final TaskScheduler scheduler = new TaskScheduler();
return new Pair<>(scheduler, scheduler::tick);
}
public synchronized TaskPointer<ScheduledTask> schedule(Runnable task, int delay) {
ScheduledTask scheduledTask = new ScheduledTask(this, task, delay);
return this.registerTask(scheduledTask);
}
public synchronized TaskPointer<ScheduledRepeatingTask> scheduleRepeating(Runnable task, int delay, int repeatDelay) {
ScheduledRepeatingTask repeatingTask = new ScheduledRepeatingTask(this, task, delay, repeatDelay);
return this.registerTask(repeatingTask);
}
public synchronized <T extends Task> TaskPointer<T> registerTask(T task) {
TaskPointer<T> pointer = new TaskPointer<>(task);
if (this.ticking.get()) {
this.updates.add(() -> tasks.put(pointer, task));
} else {
this.tasks.put(pointer, task);
}
task.setPointer(pointer);
return pointer;
}
public synchronized <T extends Task> void cancelTask(TaskPointer<T> task) {
if (this.ticking.get()) {
this.updates.add(() -> tasks.remove(task));
} else {
this.tasks.remove(task);
}
task.deleteReference();
}
@Nullable
public synchronized <T extends Task> Task getTask(TaskPointer<T> pointer) {
return pointer.get();
}
private void tick() {
this.ticking.set(true);
for (Task task : tasks.values()) {
try {
if (task.isActive()) {
task.tick();
}
} catch (Exception e) {
LOGGER.error("An error occurred while executing task " + task.toString() + ": ", e);
task.cancel();
}
}
this.ticking.set(false);
synchronized (this) {
for (Runnable run : this.updates) {
run.run();
}
updates.clear();
}
}
}
@@ -0,0 +1,6 @@
package com.combatreforged.factory.api.scheduler;
@FunctionalInterface
public interface TickFunction {
void tick();
}
@@ -0,0 +1,4 @@
package com.combatreforged.factory.api.util;
public @interface Future {
}
@@ -0,0 +1,32 @@
package com.combatreforged.factory.api.util;
public class Identifier {
private final String namespace;
private final String id;
public Identifier(String id) {
this("minecraft", id);
}
public Identifier(String namespace, String id) {
this.namespace = namespace;
this.id = id;
}
public String getNamespace() {
return namespace;
}
public String getId() {
return id;
}
public String pure() {
return namespace + ":" + id;
}
@Override
public String toString() {
return "Identifier[" + namespace + ":" + id + "]";
}
}
@@ -0,0 +1,35 @@
package com.combatreforged.factory.api.util;
import com.combatreforged.factory.api.FactoryAPI;
import com.combatreforged.factory.api.interfaces.Namespaced;
import com.combatreforged.factory.api.world.block.BlockType;
import com.combatreforged.factory.api.world.effect.StatusEffect;
import com.combatreforged.factory.api.world.item.Enchantment;
import com.combatreforged.factory.api.world.item.ItemStack;
import com.combatreforged.factory.api.world.item.ItemType;
import com.combatreforged.factory.api.world.item.container.menu.ContainerMenuType;
import com.combatreforged.factory.api.world.item.container.menu.MenuHolder;
import net.kyori.adventure.text.Component;
public interface ImplementationUtils {
int getMaxLevel(Enchantment enchantment);
boolean isCurse(Enchantment enchantment);
boolean canApply(Enchantment enchantment, ItemStack itemStack);
StatusEffect.Type getType(StatusEffect effect);
boolean isBlockItem(ItemType item);
BlockType getBlock(ItemType item);
int getMaxStackSize(ItemType item);
int getMaxDamage(ItemType item);
Identifier getIdentifier(Namespaced namespaced);
<T extends Namespaced> T getByIdentifier(Identifier identifier, Class<T> type);
MenuHolder createMenu(ContainerMenuType type, Component title);
static ImplementationUtils getInstance() {
return FactoryAPI.getInstance().getImplementationUtils();
}
}
@@ -0,0 +1,5 @@
package com.combatreforged.factory.api.world;
public enum Weather {
CLEAR, RAIN, THUNDER
}
@@ -0,0 +1,62 @@
package com.combatreforged.factory.api.world;
import com.combatreforged.factory.api.FactoryServer;
import com.combatreforged.factory.api.util.Identifier;
import com.combatreforged.factory.api.world.block.Block;
import com.combatreforged.factory.api.world.block.BlockEntity;
import com.combatreforged.factory.api.world.block.BlockState;
import com.combatreforged.factory.api.world.border.WorldBorder;
import com.combatreforged.factory.api.world.entity.Entity;
import com.combatreforged.factory.api.world.entity.player.GameModeType;
import com.combatreforged.factory.api.world.util.BoundingBox;
import com.combatreforged.factory.api.world.util.Location;
import java.util.List;
import java.util.UUID;
import java.util.function.Predicate;
public interface World {
Identifier getIdentifier();
Block getBlockAt(Location location);
void setBlockAt(Location location, BlockState state);
default boolean isBlockEntity(Location location) {
return getBlockEntity(location) != null;
}
BlockEntity getBlockEntity(Location location);
List<Entity> getEntities();
default List<Entity> getEntities(BoundingBox area) {
return getEntities(area, (entity) -> true);
}
List<Entity> getEntities(BoundingBox area, Predicate<Entity> filter);
boolean spawn(Entity entity);
Entity getEntity(UUID uuid);
FactoryServer getServer();
boolean isSubWorld();
default boolean isRaining() {
return getWeather() == Weather.RAIN;
}
default boolean isThundering() {
return getWeather() == Weather.THUNDER;
}
Weather getWeather();
void setWeather(Weather weather);
void setWeather(Weather weather, int duration);
WorldBorder getWorldBorder();
long getDayTime();
void setDayTime(long time);
long getGameTime();
void setGameTime(long time);
GameModeType getDefaultGameMode();
void setDefaultGameMode(GameModeType gameMode);
}
@@ -0,0 +1,320 @@
package com.combatreforged.factory.api.world.block;
import com.combatreforged.factory.api.interfaces.ObjectMapped;
import com.combatreforged.factory.api.world.item.ItemType;
import com.combatreforged.factory.api.world.util.Location;
import java.util.List;
import java.util.function.Predicate;
public interface Block {
BlockType getType();
Location getLocation();
boolean isAir();
ItemType getDrop();
List<StateProperty<?>> getProperties();
boolean hasPropertyValue(StateProperty<?> stateProperty);
<T> T getPropertyValue(StateProperty<T> stateProperty);
<T> void setPropertyValue(StateProperty<T> stateProperty, T value);
class StateProperty<T> implements ObjectMapped {
public static final StateProperty<Boolean>
ATTACHED = new StateProperty<>(Boolean.class),
BOTTOM = new StateProperty<>(Boolean.class),
CONDITIONAL = new StateProperty<>(Boolean.class),
DISARMED = new StateProperty<>(Boolean.class),
DRAG = new StateProperty<>(Boolean.class),
ENABLED = new StateProperty<>(Boolean.class),
EXTENDED = new StateProperty<>(Boolean.class),
EYE = new StateProperty<>(Boolean.class),
FALLING = new StateProperty<>(Boolean.class),
HANGING = new StateProperty<>(Boolean.class),
HAS_BOTTLE_0 = new StateProperty<>(Boolean.class),
HAS_BOTTLE_1 = new StateProperty<>(Boolean.class),
HAS_BOTTLE_2 = new StateProperty<>(Boolean.class),
HAS_RECORD = new StateProperty<>(Boolean.class),
HAS_BOOK = new StateProperty<>(Boolean.class),
INVERTED = new StateProperty<>(Boolean.class),
IN_WALL = new StateProperty<>(Boolean.class),
LIT = new StateProperty<>(Boolean.class),
LOCKED = new StateProperty<>(Boolean.class),
OCCUPIED = new StateProperty<>(Boolean.class),
OPEN = new StateProperty<>(Boolean.class),
PERSISTENT = new StateProperty<>(Boolean.class),
POWERED = new StateProperty<>(Boolean.class),
SHORT = new StateProperty<>(Boolean.class),
SIGNAL_FIRE = new StateProperty<>(Boolean.class),
SNOWY = new StateProperty<>(Boolean.class),
TRIGGERED = new StateProperty<>(Boolean.class),
UNSTABLE = new StateProperty<>(Boolean.class),
WATERLOGGED = new StateProperty<>(Boolean.class),
VINE_END = new StateProperty<>(Boolean.class),
UP = new StateProperty<>(Boolean.class),
DOWN = new StateProperty<>(Boolean.class),
NORTH = new StateProperty<>(Boolean.class),
EAST = new StateProperty<>(Boolean.class),
SOUTH = new StateProperty<>(Boolean.class),
WEST = new StateProperty<>(Boolean.class);
public static final StateProperty<Integer>
AGE_1 = new StateProperty<>(Integer.class),
AGE_2 = new StateProperty<>(Integer.class),
AGE_3 = new StateProperty<>(Integer.class),
AGE_5 = new StateProperty<>(Integer.class),
AGE_7 = new StateProperty<>(Integer.class),
AGE_15 = new StateProperty<>(Integer.class),
AGE_25 = new StateProperty<>(Integer.class),
BITES = new StateProperty<>(Integer.class),
DELAY = new StateProperty<>(Integer.class),
DISTANCE = new StateProperty<>(Integer.class),
EGGS = new StateProperty<>(Integer.class),
HATCH = new StateProperty<>(Integer.class),
LAYERS = new StateProperty<>(Integer.class),
LEVEL_CAULDRON = new StateProperty<>(Integer.class),
LEVEL_COMPOSTER = new StateProperty<>(Integer.class),
LEVEL_FLOWING = new StateProperty<>(Integer.class),
LEVEL_HONEY = new StateProperty<>(Integer.class),
LEVEL = new StateProperty<>(Integer.class),
MOISTURE = new StateProperty<>(Integer.class),
NOTE = new StateProperty<>(Integer.class),
PICKLES = new StateProperty<>(Integer.class),
POWER = new StateProperty<>(Integer.class),
STAGE = new StateProperty<>(Integer.class),
STABILITY_DISTANCE = new StateProperty<>(Integer.class),
RESPAWN_ANCHOR_CHARGES = new StateProperty<>(Integer.class),
ROTATION_16 = new StateProperty<>(Integer.class);
public static final StateProperty<Axis>
HORIZONTAL_AXIS = new StateProperty<>(Axis.class, Axis::isHorizontal),
AXIS = new StateProperty<>(Axis.class);
public static final StateProperty<Direction>
FACING = new StateProperty<>(Direction.class),
FACING_HOPPER = new StateProperty<>(Direction.class, direction -> direction != Direction.UP),
HORIZONTAL_FACING = new StateProperty<>(Direction.class, Direction::isHorizontal);
public static final StateProperty<FrontAndTop> ORIENTATION = new StateProperty<>(FrontAndTop.class);
public static final StateProperty<AttachFace> ATTACH_FACE = new StateProperty<>(AttachFace.class);
public static final StateProperty<BellAttachType> BELL_ATTACHMENT = new StateProperty<>(BellAttachType.class);
public static final StateProperty<WallSide>
EAST_WALL = new StateProperty<>(WallSide.class),
NORTH_WALL = new StateProperty<>(WallSide.class),
SOUTH_WALL = new StateProperty<>(WallSide.class),
WEST_WALL = new StateProperty<>(WallSide.class);
public static final StateProperty<RedstoneSide>
EAST_REDSTONE = new StateProperty<>(RedstoneSide.class),
NORTH_REDSTONE = new StateProperty<>(RedstoneSide.class),
SOUTH_REDSTONE = new StateProperty<>(RedstoneSide.class),
WEST_REDSTONE = new StateProperty<>(RedstoneSide.class);
public static final StateProperty<DoubleBlockHalf> DOUBLE_BLOCK_HALF = new StateProperty<>(DoubleBlockHalf.class);
public static final StateProperty<Half> HALF = new StateProperty<>(Half.class);
public static final StateProperty<RailShape>
RAIL_SHAPE = new StateProperty<>(RailShape.class),
RAIL_SHAPE_STRAIGHT = new StateProperty<>(RailShape.class);
public static final StateProperty<BedPart> BED_PART = new StateProperty<>(BedPart.class);
public static final StateProperty<ChestType> CHEST_TYPE = new StateProperty<>(ChestType.class);
public static final StateProperty<ComparatorMode> MODE_COMPARATOR = new StateProperty<>(ComparatorMode.class);
public static final StateProperty<DoorHingeSide> DOOR_HINGE = new StateProperty<>(DoorHingeSide.class);
public static final StateProperty<NoteBlockInstrument> NOTEBLOCK_INSTRUMENT = new StateProperty<>(NoteBlockInstrument.class);
public static final StateProperty<PistonType> PISTON_TYPE = new StateProperty<>(PistonType.class);
public static final StateProperty<SlabType> SLAB_TYPE = new StateProperty<>(SlabType.class);
public static final StateProperty<StairsShape> STAIRS_SHAPE = new StateProperty<>(StairsShape.class);
public static final StateProperty<StructureMode> STRUCTUREBLOCK_MODE = new StateProperty<>(StructureMode.class);
public static final StateProperty<BambooLeaves> BAMBOO_LEAVES = new StateProperty<>(BambooLeaves.class);
private final Class<T> valueType;
private final Predicate<T> allowedCheck;
StateProperty(Class<T> valueType) {
this(valueType, value -> true);
}
StateProperty(Class<T> valueType, Predicate<T> allowedCheck) {
this.valueType = valueType;
this.allowedCheck = allowedCheck;
}
public Class<?> getValueType() {
return valueType;
}
public boolean isAllowed(T value) {
return allowedCheck.test(value);
}
public interface StatePropertyEnum extends ObjectMapped {
}
public enum Direction implements StatePropertyEnum {
NORTH(true),
EAST(true),
SOUTH(true),
WEST(true),
UP(false),
DOWN(false);
private final boolean horizontal;
Direction(boolean horizontal) {
this.horizontal = horizontal;
}
public boolean isHorizontal() {
return this.horizontal;
}
}
public enum Axis implements StatePropertyEnum {
X(true), Y(false), Z(true);
private final boolean horizontal;
Axis(boolean horizontal) {
this.horizontal = horizontal;
}
public boolean isHorizontal() {
return this.horizontal;
}
}
public enum FrontAndTop implements StatePropertyEnum {
DOWN_EAST(Direction.DOWN, Direction.EAST),
DOWN_NORTH(Direction.DOWN, Direction.NORTH),
DOWN_SOUTH(Direction.DOWN, Direction.SOUTH),
DOWN_WEST(Direction.DOWN, Direction.WEST),
UP_EAST(Direction.UP, Direction.EAST),
UP_NORTH(Direction.UP, Direction.NORTH),
UP_SOUTH(Direction.UP, Direction.SOUTH),
UP_WEST(Direction.UP, Direction.WEST),
WEST_UP(Direction.WEST, Direction.UP),
EAST_UP(Direction.EAST, Direction.UP),
NORTH_UP(Direction.NORTH, Direction.UP),
SOUTH_UP(Direction.SOUTH, Direction.UP);
private final Direction front;
private final Direction top;
FrontAndTop(Direction front, Direction top) {
this.front = front;
this.top = top;
}
public Direction getFront() {
return front;
}
public Direction getTop() {
return top;
}
}
public enum AttachFace implements StatePropertyEnum {
FLOOR, WALL, CEILING
}
public enum BellAttachType implements StatePropertyEnum {
FLOOR, CEILING, SINGLE_WALL, DOUBLE_WALL
}
public enum WallSide implements StatePropertyEnum {
NONE, LOW, TALL
}
public enum BedPart implements StatePropertyEnum {
HEAD, FOOT
}
public enum ChestType implements StatePropertyEnum {
SINGLE, LEFT, RIGHT
}
public enum ComparatorMode implements StatePropertyEnum {
COMPARE, SUBTRACT
}
public enum DoorHingeSide implements StatePropertyEnum {
LEFT, RIGHT
}
public enum NoteBlockInstrument implements StatePropertyEnum {
HARP,
BASEDRUM,
SNARE,
HAT,
BASS,
FLUTE,
BELL,
GUITAR,
CHIME,
XYLOPHONE,
IRON_XYLOPHONE,
COW_BELL,
DIDGERIDOO,
BIT,
BANJO,
PLING
}
public enum PistonType implements StatePropertyEnum {
NORMAL, STICKY
}
public enum SlabType implements StatePropertyEnum {
TOP, BOTTOM, DOUBLE
}
public enum StairsShape implements StatePropertyEnum {
STRAIGHT,
INNER_LEFT,
INNER_RIGHT,
OUTER_LEFT,
OUTER_RIGHT
}
public enum StructureMode implements StatePropertyEnum {
LOAD, SAVE, CORNER, DATA
}
public enum RedstoneSide implements StatePropertyEnum {
UP, SIDE, NONE
}
public enum DoubleBlockHalf implements StatePropertyEnum {
UPPER, LOWER
}
public enum Half implements StatePropertyEnum {
TOP, BOTTOM
}
public enum RailShape implements StatePropertyEnum {
NORTH_SOUTH,
EAST_WEST,
ASCENDING_EAST,
ASCENDING_WEST,
ASCENDING_NORTH,
ASCENDING_SOUTH,
SOUTH_EAST,
SOUTH_WEST,
NORTH_WEST,
NORTH_EAST
}
public enum BambooLeaves implements StatePropertyEnum {
NONE, SMALL, LARGE
}
}
}
@@ -0,0 +1,13 @@
package com.combatreforged.factory.api.world.block;
import com.combatreforged.factory.api.world.nbt.NBTObject;
import net.kyori.adventure.nbt.api.BinaryTagHolder;
public interface BlockEntity {
Block getBlock();
@Deprecated BinaryTagHolder getBlockData();
@Deprecated void setBlockData(BinaryTagHolder tag);
NBTObject getBlockNBT();
void setBlockNBT(NBTObject nbt);
}
@@ -0,0 +1,14 @@
package com.combatreforged.factory.api.world.block;
import com.combatreforged.factory.api.builder.Builder;
import com.combatreforged.factory.api.world.util.Location;
public interface BlockState extends Block {
static BlockState create(BlockType type, Location location) {
return Builder.getInstance().createBlockState(type, location);
}
static BlockState of(Block block) {
return Builder.getInstance().blockStateOfBlock(block);
}
}
@@ -0,0 +1,13 @@
package com.combatreforged.factory.api.world.block;
import com.combatreforged.factory.api.interfaces.Namespaced;
import com.combatreforged.factory.api.interfaces.ObjectMapped;
import com.combatreforged.factory.api.interfaces.StringIdentified;
import com.google.errorprone.annotations.Immutable;
@Immutable
public interface BlockType extends ObjectMapped, Namespaced {
@Immutable
abstract class Other implements BlockType, StringIdentified {
}
}
@@ -0,0 +1,13 @@
package com.combatreforged.factory.api.world.block.container;
import com.combatreforged.factory.api.world.entity.player.Player;
import com.combatreforged.factory.api.world.item.container.Container;
import com.combatreforged.factory.api.world.item.container.menu.ContainerMenu;
import net.kyori.adventure.text.Component;
public interface BlockEntityContainer extends Container {
Component getName();
void setName(Component component);
ContainerMenu openToPlayer(Player player);
}
@@ -0,0 +1,29 @@
package com.combatreforged.factory.api.world.border;
public interface WorldBorder {
void setCenter(double x, double z);
double getSize();
default void addSize(double add) {
addSize(add, 0L);
}
default void addSize(double add, long time) {
setSize(getSize() + add, time);
}
default void setSize(double size) {
setSize(size, 0L);
}
void setSize(double size, long time);
double getDamageBuffer();
void setDamageBuffer(double distance);
double getDamagePerBlockPerSec();
void setDamagePerBlockPerSec(double damage);
int getWarningDistance();
void setWarningDistance(int warningDistance);
int getWarningTime();
void setWarningTime(int time);
}
@@ -0,0 +1,35 @@
package com.combatreforged.factory.api.world.damage;
import com.combatreforged.factory.api.builder.Builder;
import com.combatreforged.factory.api.interfaces.ObjectMapped;
import com.combatreforged.factory.api.world.entity.Entity;
import com.combatreforged.factory.api.world.entity.projectile.Projectile;
public interface DamageData {
Type getType();
default Projectile getProjectile() {
return this::getDamagingEntity;
}
Entity getDamagingEntity();
default boolean hasIndirectCause() {
return getType() == Type.MAGIC
|| (getType() == Type.PROJECTILE && getProjectile().getOwner() != null)
|| getType() == Type.DRAGON_BREATH || getType() == Type.ENTITY_ATTACK;
}
enum Type implements ObjectMapped {
IN_FIRE, ON_FIRE, LIGHTNING, LAVA, MAGMA, SUFFOCATION, CRAMMING, DROWNING,
STARVING, CACTUS, FALLING, CRASHING, VOID, GENERIC, MAGIC, WITHERING,
FALLING_ANVIL, FALLING_BLOCK, DRAGON_BREATH, DRY_OUT, SWEET_BERRY_BUSH,
EXPLOSION, ENTITY_ATTACK, PROJECTILE
}
static DamageData create(Type type, Entity cause, boolean isIndirect) {
return Builder.getInstance().createDamageData(type, cause, isIndirect);
}
static DamageData create(Type type) {
return Builder.getInstance().createDamageData(type, null, false);
}
}
@@ -0,0 +1,16 @@
package com.combatreforged.factory.api.world.effect;
import com.combatreforged.factory.api.interfaces.Namespaced;
import com.combatreforged.factory.api.interfaces.ObjectMapped;
import com.combatreforged.factory.api.interfaces.StringIdentified;
public interface StatusEffect extends ObjectMapped, Namespaced {
Type getType();
enum Type {
BENEFICIAL, HARMFUL, NEUTRAL
}
abstract class Other implements StatusEffect, StringIdentified {
}
}
@@ -0,0 +1,27 @@
package com.combatreforged.factory.api.world.effect;
import com.combatreforged.factory.api.builder.Builder;
public interface StatusEffectInstance {
StatusEffect getStatusEffect();
int getTicksLeft();
default int getSecondsLeft() {
return getTicksLeft() / 20;
}
int getAmplifier();
boolean isAmbient();
StatusEffectInstance copy();
static StatusEffectInstance create(StatusEffect statusEffect, int duration, int amplifier,
boolean ambient) {
return Builder.getInstance()
.createStatusEffectInstance(statusEffect, duration, amplifier, ambient);
}
static StatusEffectInstance create(StatusEffect statusEffect, int duration, int amplifier) {
return create(statusEffect, duration, amplifier, true);
}
static StatusEffectInstance create(StatusEffect statusEffect, int duration) {
return create(statusEffect, duration, 0, true);
}
}
@@ -0,0 +1,10 @@
package com.combatreforged.factory.api.world.entity;
public interface Ageable extends Mob {
int getAge();
void setAge(int age);
boolean isBreedable();
boolean isBaby();
void setBaby(boolean baby);
}
@@ -0,0 +1,96 @@
package com.combatreforged.factory.api.world.entity;
import com.combatreforged.factory.api.builder.Builder;
import com.combatreforged.factory.api.command.CommandSender;
import com.combatreforged.factory.api.command.CommandSourceInfo;
import com.combatreforged.factory.api.exception.UnassignableTypeException;
import com.combatreforged.factory.api.world.World;
import com.combatreforged.factory.api.world.nbt.NBTObject;
import com.combatreforged.factory.api.world.util.Location;
import com.combatreforged.factory.api.world.util.Vector3D;
import net.kyori.adventure.nbt.api.BinaryTagHolder;
import net.kyori.adventure.text.Component;
import org.jetbrains.annotations.Nullable;
import java.util.List;
import java.util.Set;
public interface Entity extends CommandSender {
int getEntityId();
EntityType getEntityType();
Component getName();
@Nullable
Component getCustomName();
void setCustomName(Component customName);
Location getLocation();
World getWorld();
void teleport(Location location, boolean ignoreDirection);
default void teleport(Location location) { teleport(location, false); }
void kill();
boolean isOnFire();
int getRemainingFireTicks();
void setRemainingFireTicks(int ticks);
Vector3D getVelocity();
void setVelocity(Vector3D velocity);
default void addVelocity(Vector3D velocity) {
setVelocity(getVelocity().add(velocity));
}
List<Entity> getPassengers();
void removePassenger(Entity entity);
void addPassenger(Entity entity);
void startRiding(Entity entity);
void stopRiding();
Set<String> getTags();
boolean addTag(String tag);
void removeTag(String tag);
boolean hasTag(String tag);
@Deprecated BinaryTagHolder getEntityData();
@Deprecated void setEntityData(BinaryTagHolder tag);
NBTObject getEntityNBT();
void setEntityNBT(NBTObject nbt);
boolean isOnGround();
CommandSourceInfo createCommandInfo();
static Entity create(EntityType type, World world) {
return Builder.getInstance().createEntity(type, world);
}
@SuppressWarnings("unchecked")
static <T extends Entity> T create(EntityType type, World world, Class<T> clazz) {
try {
return ((T) create(type, world));
} catch (ClassCastException e) {
throw new UnassignableTypeException(clazz.getName() + " can not be assigned to entity type " + type.toString());
}
}
}
@@ -0,0 +1,14 @@
package com.combatreforged.factory.api.world.entity;
import com.combatreforged.factory.api.interfaces.Namespaced;
import com.combatreforged.factory.api.interfaces.ObjectMapped;
import com.combatreforged.factory.api.interfaces.StringIdentified;
public interface EntityType extends ObjectMapped, Namespaced {
abstract class Other implements EntityType, StringIdentified {
@Override
public String toString() {
return this.getId();
}
}
}
@@ -0,0 +1,40 @@
package com.combatreforged.factory.api.world.entity;
import com.combatreforged.factory.api.world.effect.StatusEffect;
import com.combatreforged.factory.api.world.effect.StatusEffectInstance;
import com.combatreforged.factory.api.world.entity.equipment.EquipmentSlot;
import com.combatreforged.factory.api.world.item.ItemStack;
import java.util.List;
public interface LivingEntity extends Entity {
ItemStack getEquipmentStack(EquipmentSlot slot);
void setEquipmentStack(EquipmentSlot slot, ItemStack itemStack);
float getHealth();
void setHealth(float health);
boolean isDead();
int getInvulnerabilityTime();
void setInvulnerabilityTime(int ticks);
void damage(float amount);
List<StatusEffectInstance> getActiveEffects();
void addEffectInstance(StatusEffectInstance effectInstance);
void removeEffect(StatusEffect statusEffect);
void clearEffects();
boolean isSprinting();
void setSprinting(boolean sprinting);
boolean isSneaking();
void setSneaking(boolean sneaking);
boolean isSwimming();
void setSwimming(boolean swimming);
}
@@ -0,0 +1,6 @@
package com.combatreforged.factory.api.world.entity;
public interface Mob extends LivingEntity {
LivingEntity getTargetEntity();
void setTargetEntity(LivingEntity target);
}
@@ -0,0 +1,11 @@
package com.combatreforged.factory.api.world.entity.animal;
public interface Animal {
boolean isInLove();
int getLoveTime();
void setLoveTime(int loveTime);
void resetLove();
boolean canMateWith(Animal animal);
}
@@ -0,0 +1,5 @@
package com.combatreforged.factory.api.world.entity.equipment;
public enum ArmorSlot implements EquipmentSlot {
HEAD, CHEST, LEGS, FEET
}
@@ -0,0 +1,6 @@
package com.combatreforged.factory.api.world.entity.equipment;
import com.combatreforged.factory.api.interfaces.ObjectMapped;
public interface EquipmentSlot extends ObjectMapped {
}
@@ -0,0 +1,5 @@
package com.combatreforged.factory.api.world.entity.equipment;
public enum HandSlot implements EquipmentSlot {
MAIN_HAND, OFF_HAND
}
@@ -0,0 +1,6 @@
package com.combatreforged.factory.api.world.entity.monster;
import com.combatreforged.factory.api.world.entity.Mob;
public interface Monster extends Mob {
}
@@ -0,0 +1,13 @@
package com.combatreforged.factory.api.world.entity.player;
import com.combatreforged.factory.api.interfaces.ObjectMapped;
import com.combatreforged.factory.api.interfaces.StringIdentified;
public interface GameModeType extends ObjectMapped {
abstract class Other implements GameModeType, StringIdentified {
@Override
public String toString() {
return this.getId();
}
}
}
@@ -0,0 +1,69 @@
package com.combatreforged.factory.api.world.entity.player;
import com.combatreforged.factory.api.builder.Builder;
import com.combatreforged.factory.api.interfaces.MessageReceiver;
import com.combatreforged.factory.api.world.World;
import com.combatreforged.factory.api.world.entity.LivingEntity;
import com.combatreforged.factory.api.world.item.container.PlayerInventory;
import com.combatreforged.factory.api.world.item.container.menu.ContainerMenu;
import com.combatreforged.factory.api.world.item.container.menu.MenuHolder;
import com.combatreforged.factory.api.world.scoreboard.Scoreboard;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.title.Title;
import org.jetbrains.annotations.Nullable;
import java.util.List;
import java.util.UUID;
public interface Player extends LivingEntity, MessageReceiver {
int getFoodLevel();
void setFoodLevel(int level);
float getSaturation();
void setSaturation(float saturation);
float getExhaustion();
void setExhaustion(float exhaustion);
PlayerInventory getInventory();
int getSelectedSlot();
boolean isFlying();
void setFlying(boolean flying);
boolean isAbleToFly();
void setAbleToFly(boolean ableToFly);
boolean isFallFlying();
void setFallFlying(boolean fallFlying);
void setExperienceLevel(int level);
void setExperiencePoints(int points);
int getExperienceLevel();
int getExperiencePoints();
void sendTitle(Title title);
void clearTitle();
void resetTitle();
void sendActionBarMessage(Component component);
void openMenu(MenuHolder creator);
void closeMenu();
@Nullable ContainerMenu getOpenMenu();
GameModeType getGameMode();
void setGameMode(GameModeType gameMode);
String getRawName();
UUID getUUID();
Scoreboard getScoreboard();
void setScoreboard(Scoreboard scoreboard);
void setServerScoreboard();
Component getDisplayName();
void respawn();
void showPlayerInTabList(Player player, boolean show);
List<Player> getShownInTabList();
static Player createNPCPlayer(World world, UUID uuid, String name) {
return Builder.getInstance().createNPCPlayer(world, uuid, name);
}
}
@@ -0,0 +1,7 @@
package com.combatreforged.factory.api.world.entity.projectile;
import com.combatreforged.factory.api.world.entity.Entity;
public interface Projectile {
Entity getOwner();
}
@@ -0,0 +1,16 @@
package com.combatreforged.factory.api.world.item;
import com.combatreforged.factory.api.interfaces.Namespaced;
import com.combatreforged.factory.api.interfaces.ObjectMapped;
import com.combatreforged.factory.api.interfaces.StringIdentified;
public interface Enchantment extends Namespaced, ObjectMapped {
boolean isCurse();
int getMaxLevel();
boolean canBeAppliedTo(ItemStack itemStack);
abstract class Other implements Enchantment, StringIdentified {
}
}
@@ -0,0 +1,61 @@
package com.combatreforged.factory.api.world.item;
import com.combatreforged.factory.api.builder.Builder;
import com.combatreforged.factory.api.world.nbt.NBTObject;
import net.kyori.adventure.nbt.api.BinaryTagHolder;
import net.kyori.adventure.text.Component;
import org.jetbrains.annotations.Nullable;
import java.util.List;
public interface ItemStack {
int getCount();
void setCount(int count);
int getDamage();
void setDamage(int damage);
ItemType getItem();
boolean isFull();
void decrementCount();
int getRepairCost();
void setRepairCost(int cost);
Component getDisplayName();
void setDisplayName(Component displayName);
List<Component> getLore();
void setLore(Component... lore);
void setLore(List<Component> lore);
boolean hasEnchantment(Enchantment enchantment);
int getLevel(Enchantment enchantment);
void enchant(Enchantment enchantment, int level);
void removeEnchantment(Enchantment enchantment);
List<Enchantment> getEnchantments();
@Deprecated @Nullable BinaryTagHolder getItemData();
@Deprecated void setItemData(@Nullable BinaryTagHolder tag);
@Nullable NBTObject getItemNBT();
void setItemNBT(@Nullable NBTObject nbt);
static ItemStack create(ItemType itemType) {
return create(itemType, 1, 0, (NBTObject) null);
}
static ItemStack create(ItemType itemType, int count) {
return create(itemType, count, 0, (NBTObject) null);
}
static ItemStack create(ItemType itemType, int count, int damage) {
return create(itemType, count, damage, (NBTObject) null);
}
@Deprecated static ItemStack create(ItemType itemType, int count, int damage, BinaryTagHolder tag) {
return Builder.getInstance().createItemStack(itemType, count, damage, tag);
}
static ItemStack create(ItemType itemType, int count, int damage, @Nullable NBTObject nbt) {
return Builder.getInstance().createItemStack(itemType, count, damage, nbt);
}
ItemStack copy();
}
@@ -0,0 +1,15 @@
package com.combatreforged.factory.api.world.item;
import com.combatreforged.factory.api.interfaces.Namespaced;
import com.combatreforged.factory.api.interfaces.ObjectMapped;
import com.combatreforged.factory.api.interfaces.StringIdentified;
import com.combatreforged.factory.api.world.block.BlockType;
public interface ItemType extends ObjectMapped, Namespaced {
boolean isBlockItem();
BlockType getBlock();
int getMaxStackSize();
int getMaxDamage();
abstract class Other implements ItemType, StringIdentified {}
}
@@ -0,0 +1,23 @@
package com.combatreforged.factory.api.world.item.container;
import com.combatreforged.factory.api.world.item.ItemStack;
import com.combatreforged.factory.api.world.item.ItemType;
import org.jetbrains.annotations.Nullable;
import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
public interface Container {
int getSize();
@Nullable ItemStack getItemStack(int slot);
void setItemStack(int slot, @Nullable ItemStack itemStack);
void clear();
int count(ItemType itemType);
default boolean contains(ItemType[] itemTypes) {
return contains(new HashSet<>(Arrays.asList(itemTypes)));
}
boolean contains(Set<ItemType> itemTypes);
List<Integer> getAvailableSlots();
}
@@ -0,0 +1,22 @@
package com.combatreforged.factory.api.world.item.container;
import com.combatreforged.factory.api.world.entity.equipment.ArmorSlot;
import com.combatreforged.factory.api.world.entity.equipment.EquipmentSlot;
import com.combatreforged.factory.api.world.item.ItemStack;
import org.jetbrains.annotations.Nullable;
import java.util.Map;
public interface PlayerInventory extends Container {
boolean addItemStack(ItemStack itemStack);
boolean hasSpaceFor(ItemStack itemStack);
void removeItemStack(ItemStack itemStack);
void setItemStack(EquipmentSlot slot, ItemStack itemStack);
ItemStack getItemStack(EquipmentSlot slot);
Map<Integer, ItemStack> getInventoryContents();
Map<ArmorSlot, ItemStack> getArmorContents();
ItemStack getOffhand();
@Nullable ItemStack getCursorStack();
void setCursorStack(@Nullable ItemStack stack);
}
@@ -0,0 +1,63 @@
package com.combatreforged.factory.api.world.item.container.menu;
import java.util.Objects;
public class Button {
public static final Button
LEFT_CLICK = new Button("LEFT_CLICK"),
RIGHT_CLICK = new Button("RIGHT_CLICK"),
MIDDLE_CLICK = new Button("MIDDLE_CLICK"),
DROP = new Button("DROP"),
NONE = new Button("NONE");
private final String id;
private final boolean isHotkey;
private final int hotkeyTarget;
public static Button hotkey(int hotkeyTarget) {
return new Button(hotkeyTarget);
}
private Button(String id) {
this.id = id;
this.isHotkey = false;
this.hotkeyTarget = -1;
}
private Button(int hotkey) {
this.isHotkey = true;
this.hotkeyTarget = hotkey;
this.id = "HOTKEY_" + hotkey;
}
public boolean isHotkey() {
return isHotkey;
}
public int getHotkeyTarget() {
return hotkeyTarget;
}
@Override
public boolean equals(Object obj) {
if (!(obj instanceof Button)) {
return false;
}
Button button = (Button) obj;
return button.isHotkey && this.isHotkey
? button.hotkeyTarget == this.hotkeyTarget
: super.equals(obj);
}
@Override
public int hashCode() {
return this.isHotkey
? Objects.hash(this.hotkeyTarget, true)
: Objects.hash(super.hashCode(), false);
}
@Override
public String toString() {
return id;
}
}
@@ -0,0 +1,20 @@
package com.combatreforged.factory.api.world.item.container.menu;
import com.combatreforged.factory.api.world.item.ItemStack;
import org.jetbrains.annotations.Nullable;
import java.util.Map;
public interface ContainerMenu {
ContainerMenuType getType();
int getSlotCount();
int getDataSlotCount();
int getContainerID();
Map<Integer, ItemStack> getItems();
Map<Integer, Integer> getDataSlots();
@Nullable ItemStack getItem(int slot);
void setItem(int slot, @Nullable ItemStack itemStack);
int getData(int dataSlot);
void setData(int dataSlot, int data);
boolean isEmpty(int slot);
}
@@ -0,0 +1,8 @@
package com.combatreforged.factory.api.world.item.container.menu;
import com.combatreforged.factory.api.interfaces.ObjectMapped;
import net.kyori.adventure.text.Component;
public interface ContainerMenuType extends ObjectMapped {
MenuHolder createMenu(Component title);
}
@@ -0,0 +1,4 @@
package com.combatreforged.factory.api.world.item.container.menu;
public interface MenuHolder {
}
@@ -0,0 +1,5 @@
package com.combatreforged.factory.api.world.item.container.menu;
public enum SlotClickType {
CLICK, SHIFT_CLICK, DOUBLE_CLICK, DRAG_START, DRAG_CONTINUE, DRAG_STOP, NONE
}
@@ -0,0 +1,33 @@
package com.combatreforged.factory.api.world.nbt;
import com.combatreforged.factory.api.builder.Builder;
import java.util.List;
public interface NBTList extends Iterable<NBTValue>, NBTValue {
default void add(NBTValue value) {
add(size(), value);
}
default void addAll(List<NBTValue> values) {
for (NBTValue value : values) {
add(value);
}
}
void add(int index, NBTValue value);
void set(int index, NBTValue value);
void remove(int index);
NBTValue get(int index);
int size();
static NBTList create() {
return create(null);
}
static NBTList create(List<NBTValue> values) {
return Builder.getInstance().createNBTList(values);
}
}
@@ -0,0 +1,43 @@
package com.combatreforged.factory.api.world.nbt;
import com.combatreforged.factory.api.builder.Builder;
import org.jetbrains.annotations.Nullable;
import java.util.Map;
import java.util.Set;
public interface NBTObject extends NBTValue {
void set(String id, NBTValue value);
default void setAll(Map<String, NBTValue> values) {
for (String key : values.keySet()) {
set(key, values.get(key));
}
}
@Nullable NBTValue get(String id);
boolean has(String id);
int size();
Set<String> keys();
default NBTValue.Type getValueType(String id) {
NBTValue value;
if ((value = get(id)) == null) return null;
return value.getType();
}
@Override String toString();
NBTObject copy();
static NBTObject create() {
return create(null);
}
static NBTObject create(Map<String, NBTValue> values) {
return Builder.getInstance().createNBTObject(values);
}
static NBTObject of(String nbtString) {
return Builder.getInstance().createNBTObjectFromString(nbtString);
}
}
@@ -0,0 +1,73 @@
package com.combatreforged.factory.api.world.nbt;
import com.combatreforged.factory.api.builder.Builder;
import com.combatreforged.factory.api.interfaces.ObjectMapped;
public interface NBTValue {
short asShort();
double asDouble();
float asFloat();
byte asByte();
int asInt();
long asLong();
long[] asLongArray();
byte[] asByteArray();
int[] asIntArray();
String asString();
NBTObject asObject();
NBTList asList();
Type getType();
enum Type implements ObjectMapped {
SHORT, DOUBLE, FLOAT, BYTE, INT, LONG, LONG_ARRAY, BYTE_ARRAY, INT_ARRAY, STRING, OBJECT, LIST
}
static Builder builder() {
return Builder.getInstance();
}
static NBTValue of(short s) {
return builder().createNBTValue(s);
}
static NBTValue of(double d) {
return builder().createNBTValue(d);
}
static NBTValue of(float f) {
return builder().createNBTValue(f);
}
static NBTValue of(byte b) {
return builder().createNBTValue(b);
}
static NBTValue of(int i) {
return builder().createNBTValue(i);
}
static NBTValue of(long l) {
return builder().createNBTValue(l);
}
static NBTValue of(long[] arr) {
return builder().createNBTValue(arr);
}
static NBTValue of(byte[] arr) {
return builder().createNBTValue(arr);
}
static NBTValue of(int[] arr) {
return builder().createNBTValue(arr);
}
static NBTValue of(String string) {
return builder().createNBTValue(string);
}
}
@@ -0,0 +1,47 @@
package com.combatreforged.factory.api.world.scoreboard;
import com.combatreforged.factory.api.builder.Builder;
import org.jetbrains.annotations.Nullable;
import java.util.List;
public interface Scoreboard {
List<ScoreboardObjective> getAllObjectives();
List<ScoreboardTeam> getAllTeams();
List<ScoreboardScore> getAllScores(String name);
List<ScoreboardScore> getAllScores(ScoreboardObjective objective);
boolean hasObjective(String name);
@Nullable ScoreboardObjective getObjective(String name);
default ScoreboardObjective addObjective(String name) {
return addObjective(name, "dummy");
}
ScoreboardObjective addObjective(String name, String criteria);
void removeObjective(String name);
void removeObjective(ScoreboardObjective objective);
@Nullable ScoreboardObjective getDisplayedObjective(String slot);
void setDisplayedObjective(String objectiveName, String slot);
void setDisplayedObjective(@Nullable ScoreboardObjective objective, String slot);
void clearDisplay(String slot);
boolean hasScore(String name, ScoreboardObjective objective);
ScoreboardScore getOrCreateScore(String name, ScoreboardObjective objective);
void resetScore(String name, ScoreboardObjective objective);
boolean hasTeam(String name);
@Nullable ScoreboardTeam getTeam(String name);
ScoreboardTeam addTeam(String name);
void removeTeam(String name);
void removeTeam(ScoreboardTeam team);
void setTeam(String name, @Nullable ScoreboardTeam team);
default void leaveTeam(String name) {
setTeam(name, null);
}
static Scoreboard create() {
return Builder.getInstance().createScoreboard();
}
}
@@ -0,0 +1,27 @@
package com.combatreforged.factory.api.world.scoreboard;
import net.kyori.adventure.text.Component;
public interface ScoreboardObjective {
String getName();
Scoreboard getScoreboard();
String getCriteria();
Component getDisplayName();
void setDisplayName(Component displayName);
RenderType getRenderType();
void setRenderType(RenderType type);
default boolean hasScore(String name) {
return this.getScoreboard().hasScore(name, this);
}
default ScoreboardScore getOrCreateScore(String name) {
return this.getScoreboard().getOrCreateScore(name, this);
}
default void resetScore(String name) {
this.getScoreboard().resetScore(name, this);
}
enum RenderType {
HEARTS, NUMBER
}
}
Loaded 100 of 262 files, more files were not shown because too many files have changed in this diff. Show more