Recoded EcoEnchants

This commit is contained in:
Auxilor 2022-08-29 22:37:00 +01:00
parent 5d1d02d977
commit a138aac13d
803 changed files with 3917 additions and 35626 deletions

View File

@ -1,36 +0,0 @@
# How to contribute to EcoEnchants
## Codestyle
1. The EcoEnchants checkstyle is in /config/checkstyle.xml
- The pull request must not have any checkstyle issues.
- Every method and field must have a javadoc attached.
2. Use lombok wherever possible.
- As of 6.0.0, EcoEnchants is now built with lombok.
- @Getter, @Setter, @ToString, @EqualsAndHashCode, @UtilityClass are the most important.
3. Use JetBrains annotations
- Every parameter should be annotated with @NotNull or @Nullable
- Use @NotNull over lombok @NonNull
4. Imports
- No group (*) imports.
- No static imports.
## Dependency Injection
- EcoEnchants uses Dependency Injection since 6.0.0.
- Any calls to AbstractEcoPlugin#getInstance are code smells and should never be used unless **absolutely necessary**.
- NamespacedKeys, FixedMetadataValues, Runnables, and Schedules should be managed using EcoEnchantsPlugin through DI.
- Any DI class should extend PluginDependent where possible. If the class extends another, then you **must** store the
plugin instance in a private final variable called **plugin** with a private or protected getter.
## Other
- All drops **must** be sent through a DropQueue - calls to World#dropItem will get your PR rejected.
- Any non-plugin-specific changes **must** be made to eco-util, or core-proxy, rather than core-plugin.

View File

@ -2,52 +2,71 @@
Version 3, 29 June 2007 Version 3, 29 June 2007
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/> Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble Preamble
The GNU General Public License is a free, copyleft license for software and other kinds of works. 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 The licenses for most software and other practical works are designed
works. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change all to take away your freedom to share and change the works. By contrast,
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 is intended to guarantee your freedom to
the GNU General Public License for most of our software; it applies also to any other work released this way by its share and change all versions of a program--to make sure it remains free
authors. You can apply it to your programs, too. 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 When we speak of free software, we are referring to freedom, not
sure that you have the freedom to distribute copies of free software (and charge for them if you wish), that you receive price. Our General Public Licenses are designed to make sure that you
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 have the freedom to distribute copies of free software (and charge for
that you know you can do these things. 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. To protect your rights, we need to prevent others from denying you
Therefore, you have certain responsibilities if you distribute copies of the software, or if you modify it: these rights or asking you to surrender the rights. Therefore, you have
responsibilities to respect the freedom of others. 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 For example, if you distribute copies of such a program, whether
the same freedoms that you received. You must make sure that they, too, receive or can get the source code. And you must gratis or for a fee, you must pass on to the recipients the same
show them these terms so they know their rights. 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: 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 (1) assert copyright on the software, and (2) offer you this License
and/or modify it. 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 the developers' and authors' protection, the GPL clearly explains
For both users' and authors' sake, the GPL requires that modified versions be marked as changed, so that their problems that there is no warranty for this free software. For both users' and
will not be attributed erroneously to authors of previous versions. 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 Some devices are designed to deny users access to install or run
the manufacturer can do so. This is fundamentally incompatible with the aim of protecting users' freedom to change the modified versions of the software inside them, although the manufacturer
software. The systematic pattern of such abuse occurs in the area of products for individuals to use, which is precisely can do so. This is fundamentally incompatible with the aim of
where it is most unacceptable. Therefore, we have designed this version of the GPL to prohibit the practice for those protecting users' freedom to change the software. The systematic
products. If such problems arise substantially in other domains, we stand ready to extend this provision to those pattern of such abuse occurs in the area of products for individuals to
domains in future versions of the GPL, as needed to protect the freedom of users. 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 Finally, every program is threatened constantly by software patents.
development and use of software on general-purpose computers, but in those that do, we wish to avoid the special danger States should not allow patents to restrict development and use of
that patents applied to a free program could make it effectively proprietary. To prevent this, the GPL assures that 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. patents cannot be used to render the program non-free.
The precise terms and conditions for copying, distribution and modification follow. The precise terms and conditions for copying, distribution and
modification follow.
TERMS AND CONDITIONS TERMS AND CONDITIONS
@ -55,106 +74,142 @@ The precise terms and conditions for copying, distribution and modification foll
"This License" refers to version 3 of the GNU General Public License. "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. "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". " "The Program" refers to any copyrightable work licensed under this
Licensees" and License. Each licensee is addressed as "you". "Licensees" and
"recipients" may be individuals or organizations. "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, To "modify" a work means to copy from or adapt all or part of the work
other than the making of an exact copy. The resulting work is called a "modified version" of the earlier work or a in a fashion requiring copyright permission, other than the making of an
work "based on" the earlier work. 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. 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 To "propagate" a work means to do anything with it that, without
liable for infringement under applicable copyright law, except executing it on a computer or modifying a private copy. permission, would make you directly or secondarily liable for
Propagation includes copying, distribution (with or without modification), making available to the public, and in some infringement under applicable copyright law, except executing it on a
countries other activities as well. 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 To "convey" a work means any kind of propagation that enables other
with a user through a computer network, with no transfer of a copy, is not conveying. 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" 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 to the extent that it includes a convenient and prominently visible
notice, and (2) 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 tells the user that there is no warranty for the work (except to the
licensees may convey the work under this License, and how to view a copy of this License. If the interface presents a extent that warranties are provided), that licensees may convey the
list of user commands or options, such as a menu, a prominent item in the list meets this criterion. 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. 1. Source Code.
The "source code" for a work means the preferred form of the work for making modifications to it. "Object code" means The "source code" for a work means the preferred form of the work
any non-source form of a 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, A "Standard Interface" means an interface that either is an official
or, in the case of interfaces specified for a particular programming language, one that is widely used among developers standard defined by a recognized standards body, or, in the case of
working in that language. 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 "System Libraries" of an executable work include anything, other
the normal form of packaging a Major Component, but which is not part of that Major Component, and (b) serves only to than the work as a whole, that (a) is included in the normal form of
enable use of the work with that Major Component, or to implement a Standard Interface for which an implementation is packaging a Major Component, but which is not part of that Major
available to the public in source code form. A 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 "Major Component", in this context, means a major essential component
(kernel, window system, and so on) of the specific operating system (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 (if any) on which the executable work runs, or a compiler used to
to run it. 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 ( The "Corresponding Source" for a work in object code form means all
for an executable work) run the object code and to modify the work, including scripts to control those activities. the source code needed to generate, install, and (for an executable
However, it does not include the work's System Libraries, or general-purpose tools or generally available free programs work) run the object code and to modify the work, including scripts to
which are used unmodified in performing those activities but which are not part of the work. For example, Corresponding control those activities. However, it does not include the work's
Source includes interface definition files associated with source files for the work, and the source code for shared System Libraries, or general-purpose tools or generally available free
libraries and dynamically linked subprograms that the work is specifically designed to require, such as by intimate data programs which are used unmodified in performing those activities but
communication or control flow between those subprograms and other parts of the work. 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 The Corresponding Source need not include anything that users
Corresponding Source. can regenerate automatically from other parts of the Corresponding
Source.
The Corresponding Source for a work in source code form is that same work. The Corresponding Source for a work in source code form is that
same work.
2. Basic Permissions. 2. Basic Permissions.
All rights granted under this License are granted for the term of copyright on the Program, and are irrevocable provided All rights granted under this License are granted for the term of
the stated conditions are met. This License explicitly affirms your unlimited permission to run the unmodified Program. copyright on the Program, and are irrevocable provided the stated
The output from running a covered work is covered by this License only if the output, given its content, constitutes a conditions are met. This License explicitly affirms your unlimited
covered work. This License acknowledges your rights of fair use or other equivalent, as provided by copyright law. 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 You may make, run and propagate covered works that you do not
otherwise remains in force. You may convey covered works to others for the sole purpose of having them make convey, without conditions so long as your license otherwise remains
modifications exclusively for you, or provide you with facilities for running those works, provided that you comply with in force. You may convey covered works to others for the sole purpose
the terms of this License in conveying all material for which you do not control copyright. Those thus making or running of having them make modifications exclusively for you, or provide you
the covered works for you must do so exclusively on your behalf, under your direction and control, on terms that with facilities for running those works, provided that you comply with
prohibit them from making any copies of your copyrighted material outside their relationship with you. 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 Conveying under any other circumstances is permitted solely under
allowed; section 10 makes it unnecessary. the conditions stated below. Sublicensing is not allowed; section 10
makes it unnecessary.
3. Protecting Users' Legal Rights From Anti-Circumvention Law. 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 No covered work shall be deemed part of an effective technological
obligations under article 11 of the WIPO copyright treaty adopted on 20 December 1996, or similar laws prohibiting or measure under any applicable law fulfilling obligations under article
restricting circumvention of such measures. 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 When you convey a covered work, you waive any legal power to forbid
extent such circumvention is effected by exercising rights under this License with respect to the covered work, and you circumvention of technological measures to the extent such circumvention
disclaim any intention to limit operation or modification of the work as a means of enforcing, against the work's users, is effected by exercising rights under this License with respect to
your or third parties' legal rights to forbid circumvention of technological measures. 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. 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 You may convey verbatim copies of the Program's source code as you
conspicuously and appropriately publish on each copy an appropriate copyright notice; keep intact all notices stating receive it, in any medium, provided that you conspicuously and
that this License and any non-permissive terms added in accord with section 7 apply to the code; keep intact all notices appropriately publish on each copy an appropriate copyright notice;
of the absence of any warranty; and give all recipients a copy of this License along with the Program. 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 You may charge any price or no price for each copy that you convey,
a fee. and you may offer support or warranty protection for a fee.
5. Conveying Modified Source Versions. 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 You may convey a work based on the Program, or the modifications to
code under the terms of section 4, provided that you also meet all of these conditions: 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 a) The work must carry prominent notices stating that you modified
it, and giving a relevant date. it, and giving a relevant date.
@ -177,17 +232,22 @@ code under the terms of section 4, provided that you also meet all of these cond
interfaces that do not display Appropriate Legal Notices, your interfaces that do not display Appropriate Legal Notices, your
work need not make them do so. 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 A compilation of a covered work with other separate and independent
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 works, which are not by their nature extensions of the covered work,
distribution medium, is called an and which are not combined with it such as to form a larger program,
"aggregate" if the compilation and its resulting copyright are not used to limit the access or legal rights of the in or on a volume of a storage or distribution medium, is called an
compilation's users beyond what the individual works permit. Inclusion of a covered work in an aggregate does not cause "aggregate" if the compilation and its resulting copyright are not
this License to apply to the other parts of the aggregate. 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. 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 You may convey a covered work in object code form under the terms
machine-readable Corresponding Source under the terms of this License, in one of these ways: 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 a) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by the (including a physical distribution medium), accompanied by the
@ -230,55 +290,77 @@ machine-readable Corresponding Source under the terms of this License, in one of
Source of the work are being offered to the general public at no Source of the work are being offered to the general public at no
charge under subsection 6d. charge under subsection 6d.
A separable portion of the object code, whose source code is excluded from the Corresponding Source as a System Library, A separable portion of the object code, whose source code is excluded
need not be included in conveying the object code work. 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 A "User Product" is either (1) a "consumer product", which means any
for personal, family, or household purposes, or (2) anything designed or sold for incorporation into a dwelling. In tangible personal property which is normally used for personal, family,
determining whether a product is a consumer product, doubtful cases shall be resolved in favor of coverage. For a or household purposes, or (2) anything designed or sold for incorporation
particular product received by a particular user, "normally used" refers to a typical or common use of that class of into a dwelling. In determining whether a product is a consumer product,
product, regardless of the status of the particular user or of the way in which the particular user actually uses, or doubtful cases shall be resolved in favor of coverage. For a particular
expects or is expected to use, the product. A product is a consumer product regardless of whether the product has product received by a particular user, "normally used" refers to a
substantial commercial, industrial or non-consumer uses, unless such uses represent the only significant mode of use of typical or common use of that class of product, regardless of the status
the product. 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 "Installation Information" for a User Product means any methods,
required to install and execute modified versions of a covered work in that User Product from a modified version of its procedures, authorization keys, or other information required to install
Corresponding Source. The information must suffice to ensure that the continued functioning of the modified object code and execute modified versions of a covered work in that User Product from
is in no case prevented or interfered with solely because modification has been made. 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 If you convey an object code work under this section in, or with, or
conveying occurs as part of a transaction in which the right of possession and use of the User Product is transferred to specifically for use in, a User Product, and the conveying occurs as
the recipient in perpetuity or for a fixed term (regardless of how the transaction is characterized), the Corresponding part of a transaction in which the right of possession and use of the
Source conveyed under this section must be accompanied by the Installation Information. But this requirement does not User Product is transferred to the recipient in perpetuity or for a
apply if neither you nor any third party retains the ability to install modified object code on the User Product (for fixed term (regardless of how the transaction is characterized), the
example, the work has been installed in ROM). 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 The requirement to provide Installation Information does not include a
service, warranty, or updates for a work that has been modified or installed by the recipient, or for the User Product requirement to continue to provide support service, warranty, or updates
in which it has been modified or installed. Access to a network may be denied when the modification itself materially for a work that has been modified or installed by the recipient, or for
and adversely affects the operation of the network or violates the rules and protocols for communication across the the User Product in which it has been modified or installed. Access to a
network. 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 Corresponding Source conveyed, and Installation Information provided,
that is publicly documented (and with an implementation available to the public in source code form), and must require in accord with this section must be in a format that is publicly
no special password or key for unpacking, reading or copying. 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. 7. Additional Terms.
"Additional permissions" are terms that supplement the terms of this License by making exceptions from one or more of "Additional permissions" are terms that supplement the terms of this
its conditions. Additional permissions that are applicable to the entire Program shall be treated as though they were License by making exceptions from one or more of its conditions.
included in this License, to the extent that they are valid under applicable law. If additional permissions apply only Additional permissions that are applicable to the entire Program shall
to part of the Program, that part may be used separately under those permissions, but the entire Program remains be treated as though they were included in this License, to the extent
governed by this License without regard to the additional permissions. 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 When you convey a copy of a covered work, you may at your option
from any part of it. (Additional permissions may be written to require their own removal in certain cases when you remove any additional permissions from that copy, or from any part of
modify the work.) You may place additional permissions on material, added by you to a covered work, for which you have it. (Additional permissions may be written to require their own
or can give appropriate copyright permission. 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 Notwithstanding any other provision of this License, for material you
the copyright holders of that material) supplement the terms of this License with terms: 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 a) Disclaiming warranty or limiting liability differently from the
terms of sections 15 and 16 of this License; or terms of sections 15 and 16 of this License; or
@ -303,182 +385,251 @@ the copyright holders of that material) supplement the terms of this License wit
any liability that these contractual assumptions directly impose on any liability that these contractual assumptions directly impose on
those licensors and authors. those licensors and authors.
All other non-permissive additional terms are considered "further restrictions" within the meaning of section 10. If the All other non-permissive additional terms are considered "further
Program as you received it, or any part of it, contains a notice stating that it is governed by this License along with restrictions" within the meaning of section 10. If the Program as you
a term that is a further restriction, you may remove that term. If a license document contains a further restriction but received it, or any part of it, contains a notice stating that it is
permits relicensing or conveying under this License, you may add to a covered work material governed by the terms of governed by this License along with a term that is a further
that license document, provided that the further restriction does not survive such relicensing or conveying. 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 If you add terms to a covered work in accord with this section, you
statement of the additional terms that apply to those files, or a notice indicating where to find the applicable terms. 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 Additional terms, permissive or non-permissive, may be stated in the
exceptions; the above requirements apply either way. form of a separately written license, or stated as exceptions;
the above requirements apply either way.
8. Termination. 8. Termination.
You may not propagate or modify a covered work except as expressly provided under this License. Any attempt otherwise to You may not propagate or modify a covered work except as expressly
propagate or modify it is void, and will automatically terminate your rights under this License (including any patent provided under this License. Any attempt otherwise to propagate or
licenses granted under the third paragraph of section 11). 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 However, if you cease all violation of this License, then your
reinstated (a) license from a particular copyright holder is reinstated (a)
provisionally, unless and until the copyright holder explicitly and finally terminates your license, and (b) provisionally, unless and until the copyright holder explicitly and
permanently, if the copyright holder fails to notify you of the violation by some reasonable means prior to 60 days finally terminates your license, and (b) permanently, if the copyright
after the cessation. 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 Moreover, your license from a particular copyright holder is
of the violation by some reasonable means, this is the first time you have received notice of violation of this reinstated permanently if the copyright holder notifies you of the
License (for any work) from that copyright holder, and you cure the violation prior to 30 days after your receipt of the violation by some reasonable means, this is the first time you have
notice. 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 Termination of your rights under this section does not terminate the
rights from you under this License. If your rights have been terminated and not permanently reinstated, you do not licenses of parties who have received copies or rights from you under
qualify to receive new licenses for the same material under section 10. 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. 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 You are not required to accept this License in order to receive or
covered work occurring solely as a consequence of using peer-to-peer transmission to receive a copy likewise does not run a copy of the Program. Ancillary propagation of a covered work
require acceptance. However, nothing other than this License grants you permission to propagate or modify any covered occurring solely as a consequence of using peer-to-peer transmission
work. These actions infringe copyright if you do not accept this License. Therefore, by modifying or propagating a 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. covered work, you indicate your acceptance of this License to do so.
10. Automatic Licensing of Downstream Recipients. 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, Each time you convey a covered work, the recipient automatically
modify and propagate that work, subject to this License. You are not responsible for enforcing compliance by third receives a license from the original licensors, to run, modify and
parties with this License. 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 An "entity transaction" is a transaction transferring control of an
subdividing an organization, or merging organizations. If propagation of a covered work results from an entity organization, or substantially all assets of one, or subdividing an
transaction, each party to that transaction who receives a copy of the work also receives whatever licenses to the work organization, or merging organizations. If propagation of a covered
the party's predecessor in interest had or could give under the previous paragraph, plus a right to possession of the work results from an entity transaction, each party to that
Corresponding Source of the work from the predecessor in interest, if the predecessor has it or can get it with transaction who receives a copy of the work also receives whatever
reasonable efforts. 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 You may not impose any further restrictions on the exercise of the
example, you may not impose a license fee, royalty, or other charge for exercise of rights granted under this License, rights granted or affirmed under this License. For example, you may
and you may not initiate litigation not impose a license fee, royalty, or other charge for exercise of
(including a cross-claim or counterclaim in a lawsuit) alleging that any patent claim is infringed by making, using, rights granted under this License, and you may not initiate litigation
selling, offering for sale, or importing the Program or any portion of it. (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. 11. Patents.
A "contributor" is a copyright holder who authorizes use under this License of the Program or a work on which the A "contributor" is a copyright holder who authorizes use under this
Program is based. The work thus licensed is called the contributor's "contributor version". 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 A contributor's "essential patent claims" are all patent claims
acquired or hereafter acquired, that would be infringed by some manner, permitted by this License, of making, using, or owned or controlled by the contributor, whether already acquired or
selling its contributor version, but do not include claims that would be infringed only as a consequence of further hereafter acquired, that would be infringed by some manner, permitted
modification of the contributor version. For purposes of this definition, "control" includes the right to grant patent by this License, of making, using, or selling its contributor version,
sublicenses in a manner consistent with the requirements of this License. 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 Each contributor grants you a non-exclusive, worldwide, royalty-free
patent claims, to make, use, sell, offer for sale, import and otherwise run, modify and propagate the contents of its patent license under the contributor's essential patent claims, to
contributor version. 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 In the following three paragraphs, a "patent license" is any express
to enforce a patent 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 (such as an express permission to practice a patent or covenant not to
patent license to a party means to make such an agreement or commitment not to enforce a patent against the party. 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 If you convey a covered work, knowingly relying on a patent license,
available for anyone to copy, free of charge and under the terms of this License, through a publicly available network and the Corresponding Source of the work is not available for anyone
server or other readily accessible means, then you must either (1) cause the Corresponding Source to be so available, to copy, free of charge and under the terms of this License, through a
or (2) arrange to deprive yourself of the benefit of the patent license for this particular work, or (3) arrange, in a publicly available network server or other readily accessible means,
manner consistent with the requirements of this License, to extend the patent license to downstream recipients. " then you must either (1) cause the Corresponding Source to be so
Knowingly relying" means you have actual knowledge that, but for the patent license, your conveying the covered work in available, or (2) arrange to deprive yourself of the benefit of the
a country, or your recipient's use of the covered work in a country, would infringe one or more identifiable patents in patent license for this particular work, or (3) arrange, in a manner
that country that you have reason to believe are valid. 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 If, pursuant to or in connection with a single transaction or
conveyance of, a covered work, and grant a patent license to some of the parties receiving the covered work authorizing arrangement, you convey, or propagate by procuring conveyance of, a
them to use, propagate, modify or convey a specific copy of the covered work, then the patent license you grant is covered work, and grant a patent license to some of the parties
automatically extended to all recipients of the covered work and works based on it. 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, A patent license is "discriminatory" if it does not include within
or is conditioned on the non-exercise of one or more of the rights that are specifically granted under this License. You the scope of its coverage, prohibits the exercise of, or is
may not convey a covered work if you are a party to an arrangement with a third party that is in the business of conditioned on the non-exercise of one or more of the rights that are
distributing software, under which you make payment to the third party based on the extent of your activity of conveying specifically granted under this License. You may not convey a covered
the work, and under which the third party grants, to any of the parties who would receive the covered work from you, a work if you are a party to an arrangement with a third party that is
discriminatory patent license (a) in connection with copies of the covered work conveyed by you (or copies made from in the business of distributing software, under which you make payment
those copies), or (b) primarily for and in connection with specific products or compilations that contain the covered to the third party based on the extent of your activity of conveying
work, unless you entered into that arrangement, or that patent license was granted, prior to 28 March 2007. 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 Nothing in this License shall be construed as excluding or limiting
infringement that may otherwise be available to you under applicable patent law. 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. 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 If conditions are imposed on you (whether by court order, agreement or
License, they do not excuse you from the conditions of this License. If you cannot convey a covered work so as to otherwise) that contradict the conditions of this License, they do not
satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence excuse you from the conditions of this License. If you cannot convey a
you may not convey it at all. For example, if you agree to terms that obligate you to collect a royalty for further covered work so as to satisfy simultaneously your obligations under this
conveying from those to whom you convey the Program, the only way you could satisfy both those terms and this License License and any other pertinent obligations, then as a consequence you may
would be to refrain entirely from conveying the Program. 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. 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 Notwithstanding any other provision of this License, you have
licensed under version 3 of the GNU Affero General Public License into a single combined work, and to convey the permission to link or combine any covered work with a work licensed
resulting work. The terms of this License will continue to apply to the part which is the covered work, but the special under version 3 of the GNU Affero General Public License into a single
requirements of the GNU Affero General Public License, section 13, concerning interaction through a network will apply combined work, and to convey the resulting work. The terms of this
to the combination as such. 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. 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 The Free Software Foundation may publish revised and/or new versions of
time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new the GNU General Public License from time to time. Such new versions will
problems or concerns. 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 Each version is given a distinguishing version number. If the
GNU General Public License "or any later version" applies to it, you have the option of following the terms and Program specifies that a certain numbered version of the GNU General
conditions either of that numbered version or of any later version published by the Free Software Foundation. If the Public License "or any later version" applies to it, you have the
Program does not specify a version number of the GNU General Public License, you may choose any version ever published 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. 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, If the Program specifies that a proxy can decide which future
that proxy's public statement of acceptance of a version permanently authorizes you to choose that version for the versions of the GNU General Public License can be used, that proxy's
Program. 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 Later license versions may give you additional or different
on any author or copyright holder as a result of your choosing to follow a later version. 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. 15. Disclaimer of Warranty.
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 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. 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 IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
MODIFIES AND/OR CONVEYS THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
DAMAGES. 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. 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 If the disclaimer of warranty and limitation of liability provided
their terms, reviewing courts shall apply local law that most closely approximates an absolute waiver of all civil above cannot be given local legal effect according to their terms,
liability in connection with the Program, unless a warranty or assumption of liability accompanies a copy of the Program reviewing courts shall apply local law that most closely approximates
in return for a fee. 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 END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs 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 If you develop a new program, and you want it to be of the greatest
this is to make it free software which everyone can redistribute and change under these terms. 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 To do so, attach the following notices to the program. It is safest
most effectively state the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to attach them to the start of each source file to most effectively
to where the full notice is found. 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.> <one line to give the program's name and a brief idea of what it does.>
Copyright (C) <year> <name of author> Copyright (C) <year> <name of author>
@ -498,21 +649,26 @@ to where the full notice is found.
Also add information on how to contact you by electronic and paper mail. 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: 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> <program> Copyright (C) <year> <name of author>
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details. 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 The hypothetical commands `show w' and `show c' should show the appropriate
course, your program's commands might be different; for a GUI interface, you would use an "about box". 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 You should also get your employer (if you work as a programmer) or school,
the program, if necessary. For more information on this, and how to apply and follow the GNU GPL, see 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/>. <https://www.gnu.org/licenses/>.
The GNU General Public License does not permit incorporating your program into proprietary programs. If your program is The GNU General Public License does not permit incorporating your program
a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If into proprietary programs. If your program is a subroutine library, you
this is what you want to do, use the GNU Lesser General Public License instead of this License. But first, please read 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>. <https://www.gnu.org/licenses/why-not-lgpl.html>.

View File

@ -1,9 +1,18 @@
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.7.10"
}
}
plugins { plugins {
id 'java-library' id 'java-library'
id 'com.github.johnrengelman.shadow' version '7.0.0' id 'com.github.johnrengelman.shadow' version '7.0.0'
id 'maven-publish' id 'maven-publish'
id 'java' id 'java'
id 'checkstyle'
} }
dependencies { dependencies {
@ -11,6 +20,7 @@ dependencies {
} }
allprojects { allprojects {
apply plugin: 'kotlin'
apply plugin: 'java' apply plugin: 'java'
apply plugin: 'maven-publish' apply plugin: 'maven-publish'
apply plugin: 'com.github.johnrengelman.shadow' apply plugin: 'com.github.johnrengelman.shadow'
@ -20,26 +30,8 @@ allprojects {
mavenLocal() mavenLocal()
maven { url 'https://jitpack.io' } maven { url 'https://jitpack.io' }
maven { url 'https://hub.spigotmc.org/nexus/content/repositories/snapshots/' } maven { url 'https://hub.spigotmc.org/nexus/content/repositories/snapshots/' }
maven { url 'https://repo.codemc.org/repository/nms/' }
maven { url 'https://repo.codemc.org/repository/maven-public' }
maven { url "https://oss.sonatype.org/content/repositories/snapshots" }
maven { url 'https://oss.sonatype.org/content/groups/public/' }
maven { url 'https://maven.enginehub.org/repo/' }
maven { url 'https://repo.essentialsx.net/releases/' }
maven { url 'https://ci.ender.zone/plugin/repository/project/' }
maven { url 'https://ci.ender.zone/plugin/repository/everything/' }
maven { url 'https://repo.md-5.net/content/repositories/snapshots/' }
maven { url 'https://repo.dmulloy2.net/nexus/repository/public/' }
maven { url 'https://papermc.io/repo/repository/maven-public/' } maven { url 'https://papermc.io/repo/repository/maven-public/' }
maven { url 'https://repo.maven.apache.org/maven2/' } maven { url 'https://repo.essentialsx.net/releases/' }
maven { url 'https://repo.dustplanet.de/artifactory/ext-release-local/' }
maven { url 'https://libraries.minecraft.net/' }
maven { url 'https://repo.spongepowered.org/maven/' }
maven { url 'https://org.kitteh.pastegg' }
maven { url 'https://repo.mikeprimm.com/' }
maven { url 'https://maven.enginehub.org/repo/' }
maven { url 'https://github.com/factions-site/repo/raw/public/' }
maven { url 'https://mvn.lumine.io/repository/maven-public/' }
} }
jar { jar {
@ -51,20 +43,15 @@ allprojects {
relocate('org.joml', 'com.willfp.ecoenchants.libreforge.joml') relocate('org.joml', 'com.willfp.ecoenchants.libreforge.joml')
} }
compileJava {
onlyIf { !sourceSets.main.allSource.files.isEmpty() }
}
dependencies { dependencies {
compileOnly 'com.willfp:eco:6.37.2' compileOnly 'com.willfp:eco:6.38.0'
implementation 'com.willfp:libreforge:3.90.0'
implementation 'org.joml:joml:1.10.4'
compileOnly 'org.jetbrains:annotations:22.0.0' compileOnly 'org.jetbrains:annotations:23.0.0'
compileOnly 'com.github.ben-manes.caffeine:caffeine:3.0.6'
compileOnly 'org.projectlombok:lombok:1.18.22' compileOnly 'org.jetbrains.kotlin:kotlin-stdlib:1.7.10'
annotationProcessor 'org.projectlombok:lombok:1.18.22'
testCompileOnly 'org.projectlombok:lombok:1.18.22'
testAnnotationProcessor 'org.projectlombok:lombok:1.18.22'
} }
tasks.withType(JavaCompile) { tasks.withType(JavaCompile) {
@ -73,11 +60,18 @@ allprojects {
} }
processResources { processResources {
filesNotMatching(["**/*.png", "**/models/**", "**/textures/**"]) { filesNotMatching(["**/*.png", "**/models/**", "**/textures/**", "**enchants.yml", "**lang.yml"]) {
expand projectVersion: project.version expand projectVersion: project.version
} }
} }
tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile) {
kotlinOptions {
jvmTarget = "17"
freeCompilerArgs += ["-Xjvm-default=all"]
}
}
java.sourceCompatibility = JavaVersion.VERSION_17 java.sourceCompatibility = JavaVersion.VERSION_17
java.targetCompatibility = JavaVersion.VERSION_17 java.targetCompatibility = JavaVersion.VERSION_17
@ -85,7 +79,6 @@ allprojects {
compileJava.dependsOn clean compileJava.dependsOn clean
build.dependsOn shadowJar build.dependsOn shadowJar
build.dependsOn check
} }
tasks.withType(Jar) { tasks.withType(Jar) {
@ -108,15 +101,7 @@ group = 'com.willfp'
archivesBaseName = project.name archivesBaseName = project.name
version = findProperty("version") version = findProperty("version")
compileJava.options.encoding = 'UTF-8' build.dependsOn shadowJar
publishing {
publications {
maven(MavenPublication) {
from(components.java)
}
}
}
task buyThePlugins { task buyThePlugins {
dependsOn subprojects.build dependsOn subprojects.build

View File

@ -5,27 +5,6 @@
"http://www.puppycrawl.com/dtds/suppressions_1_1.dtd"> "http://www.puppycrawl.com/dtds/suppressions_1_1.dtd">
<suppressions> <suppressions>
<!-- Enchantments don't need javadoc. -->
<suppress files="[\\/]enchantments[\\/]ecoenchants[\\/]" checks="MissingJavadocMethod"/>
<suppress files="[\\/]enchantments[\\/]ecoenchants[\\/]" checks="JavadocVariable"/>
<!-- Extensions don't need javadoc. -->
<suppress files="[\\/]eco-extensions[\\/]" checks="MissingJavadocMethod"/>
<suppress files="[\\/]eco-extensions[\\/]" checks="JavadocVariable"/>
<!-- NMS doesn't need javadoc. -->
<suppress files="[\\/]core-nms[\\/]" checks="MissingJavadocMethod"/>
<suppress files="[\\/]core-nms[\\/]" checks="JavadocVariable"/>
<!-- Fields don't need javadoc --> <!-- Fields don't need javadoc -->
<suppress files="EcoEnchants.java" checks="JavadocVariable"/> <suppress files="EcoEnchants.java" checks="JavadocVariable"/>
<!-- Modified version of library -->
<suppress files="ArmorEquipEvent.java" checks="JavadocVariable"/>
<suppress files="ArmorEquipEvent.java" checks="MissingJavadocMethod"/>
<suppress files="ArmorEquipEvent.java" checks="JavadocStyle"/>
<suppress files="ArmorListener.java" checks="JavadocVariable"/>
<suppress files="ArmorListener.java" checks="MissingJavadocMethod"/>
<suppress files="ArmorType.java" checks="JavadocVariable"/>
<suppress files="ArmorType.java" checks="MissingJavadocMethod"/>
</suppressions> </suppressions>

View File

@ -1,9 +1,2 @@
group 'com.willfp' group 'com.willfp'
version rootProject.version version rootProject.version
subprojects {
dependencies {
implementation 'com.willfp:libreforge:3.89.0'
implementation 'org.joml:joml:1.10.4'
}
}

View File

@ -1,9 +0,0 @@
group 'com.willfp'
version rootProject.version
subprojects {
dependencies {
compileOnly project(':eco-core:core-proxy')
compileOnly project(':eco-core:core-plugin')
}
}

View File

@ -1,6 +0,0 @@
group 'com.willfp'
version rootProject.version
dependencies {
compileOnly 'org.spigotmc:spigot:1.17-R0.1-SNAPSHOT'
}

View File

@ -1,25 +0,0 @@
package com.willfp.ecoenchants.proxy.v1_17_R1;
import com.willfp.ecoenchants.enchantments.support.vanilla.VanillaEnchantmentMetadata;
import com.willfp.ecoenchants.enchantments.support.vanilla.VanillaEnchantments;
import com.willfp.ecoenchants.proxy.proxies.EcoCraftEnchantmentManagerProxy;
import com.willfp.ecoenchants.proxy.v1_17_R1.enchants.EcoCraftEnchantment;
import net.minecraft.core.IRegistry;
import net.minecraft.world.item.enchantment.Enchantment;
import org.bukkit.NamespacedKey;
import org.bukkit.craftbukkit.v1_17_R1.util.CraftNamespacedKey;
import java.util.Map;
public final class EcoCraftEnchantmentManager implements EcoCraftEnchantmentManagerProxy {
@Override
public void registerNewCraftEnchantments() {
Map<org.bukkit.enchantments.Enchantment, VanillaEnchantmentMetadata> metadataMap = VanillaEnchantments.getMetadataMap();
for (Enchantment enchantment : IRegistry.X) {
NamespacedKey key = CraftNamespacedKey.fromMinecraft(IRegistry.X.getKey(enchantment));
VanillaEnchantmentMetadata metadata = metadataMap.get(org.bukkit.enchantments.Enchantment.getByKey(key));
new EcoCraftEnchantment(enchantment, metadata).register();
}
}
}

View File

@ -1,13 +0,0 @@
package com.willfp.ecoenchants.proxy.v1_17_R1;
import com.willfp.ecoenchants.proxy.proxies.OpenInventoryProxy;
import org.bukkit.craftbukkit.v1_17_R1.entity.CraftPlayer;
import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull;
public final class OpenInventory implements OpenInventoryProxy {
@Override
public Object getOpenInventory(@NotNull final Player player) {
return ((CraftPlayer) player).getHandle().bV;
}
}

View File

@ -1,36 +0,0 @@
package com.willfp.ecoenchants.proxy.v1_17_R1.enchants;
import com.willfp.ecoenchants.enchantments.EcoEnchant;
import com.willfp.ecoenchants.enchantments.support.vanilla.VanillaEnchantmentMetadata;
import com.willfp.ecoenchants.enchantments.util.EnchantmentUtils;
import net.minecraft.world.item.enchantment.Enchantment;
import org.bukkit.craftbukkit.v1_17_R1.enchantments.CraftEnchantment;
import org.jetbrains.annotations.NotNull;
public class EcoCraftEnchantment extends CraftEnchantment {
private final VanillaEnchantmentMetadata metadata;
public EcoCraftEnchantment(@NotNull final Enchantment target,
@NotNull final VanillaEnchantmentMetadata metadata) {
super(target);
this.metadata = metadata;
}
@Override
public int getMaxLevel() {
return metadata.maxLevel() == null ? this.getHandle().getMaxLevel() : metadata.maxLevel();
}
@Override
public boolean conflictsWith(@NotNull final org.bukkit.enchantments.Enchantment other) {
if (other instanceof EcoEnchant) {
return other.conflictsWith(this);
}
return metadata.conflicts() == null ? super.conflictsWith(other) : metadata.conflicts().contains(other.getKey());
}
public void register() {
EnchantmentUtils.register(this);
}
}

View File

@ -1,6 +0,0 @@
group 'com.willfp'
version rootProject.version
dependencies {
compileOnly 'org.spigotmc:spigot:1.18-R0.1-SNAPSHOT'
}

View File

@ -1,25 +0,0 @@
package com.willfp.ecoenchants.proxy.v1_18_R1;
import com.willfp.ecoenchants.enchantments.support.vanilla.VanillaEnchantmentMetadata;
import com.willfp.ecoenchants.enchantments.support.vanilla.VanillaEnchantments;
import com.willfp.ecoenchants.proxy.proxies.EcoCraftEnchantmentManagerProxy;
import com.willfp.ecoenchants.proxy.v1_18_R1.enchants.EcoCraftEnchantment;
import net.minecraft.core.IRegistry;
import net.minecraft.world.item.enchantment.Enchantment;
import org.bukkit.NamespacedKey;
import org.bukkit.craftbukkit.v1_18_R1.util.CraftNamespacedKey;
import java.util.Map;
public final class EcoCraftEnchantmentManager implements EcoCraftEnchantmentManagerProxy {
@Override
public void registerNewCraftEnchantments() {
Map<org.bukkit.enchantments.Enchantment, VanillaEnchantmentMetadata> metadataMap = VanillaEnchantments.getMetadataMap();
for (Enchantment enchantment : IRegistry.Y) {
NamespacedKey key = CraftNamespacedKey.fromMinecraft(IRegistry.Y.b(enchantment));
VanillaEnchantmentMetadata metadata = metadataMap.get(org.bukkit.enchantments.Enchantment.getByKey(key));
new EcoCraftEnchantment(enchantment, metadata).register();
}
}
}

View File

@ -1,13 +0,0 @@
package com.willfp.ecoenchants.proxy.v1_18_R1;
import com.willfp.ecoenchants.proxy.proxies.OpenInventoryProxy;
import org.bukkit.craftbukkit.v1_18_R1.entity.CraftPlayer;
import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull;
public final class OpenInventory implements OpenInventoryProxy {
@Override
public Object getOpenInventory(@NotNull final Player player) {
return ((CraftPlayer) player).getHandle().bW;
}
}

View File

@ -1,36 +0,0 @@
package com.willfp.ecoenchants.proxy.v1_18_R1.enchants;
import com.willfp.ecoenchants.enchantments.EcoEnchant;
import com.willfp.ecoenchants.enchantments.support.vanilla.VanillaEnchantmentMetadata;
import com.willfp.ecoenchants.enchantments.util.EnchantmentUtils;
import net.minecraft.world.item.enchantment.Enchantment;
import org.bukkit.craftbukkit.v1_18_R1.enchantments.CraftEnchantment;
import org.jetbrains.annotations.NotNull;
public class EcoCraftEnchantment extends CraftEnchantment {
private final VanillaEnchantmentMetadata metadata;
public EcoCraftEnchantment(@NotNull final Enchantment target,
@NotNull final VanillaEnchantmentMetadata metadata) {
super(target);
this.metadata = metadata;
}
@Override
public int getMaxLevel() {
return metadata.maxLevel() == null ? this.getHandle().a() : metadata.maxLevel();
}
@Override
public boolean conflictsWith(@NotNull final org.bukkit.enchantments.Enchantment other) {
if (other instanceof EcoEnchant) {
return other.conflictsWith(this);
}
return metadata.conflicts() == null ? super.conflictsWith(other) : metadata.conflicts().contains(other.getKey());
}
public void register() {
EnchantmentUtils.register(this);
}
}

View File

@ -1,6 +0,0 @@
group 'com.willfp'
version rootProject.version
dependencies {
compileOnly 'org.spigotmc:spigot:1.18.2-R0.1-SNAPSHOT'
}

View File

@ -1,25 +0,0 @@
package com.willfp.ecoenchants.proxy.v1_18_R2;
import com.willfp.ecoenchants.enchantments.support.vanilla.VanillaEnchantmentMetadata;
import com.willfp.ecoenchants.enchantments.support.vanilla.VanillaEnchantments;
import com.willfp.ecoenchants.proxy.proxies.EcoCraftEnchantmentManagerProxy;
import com.willfp.ecoenchants.proxy.v1_18_R2.enchants.EcoCraftEnchantment;
import net.minecraft.core.IRegistry;
import net.minecraft.world.item.enchantment.Enchantment;
import org.bukkit.NamespacedKey;
import org.bukkit.craftbukkit.v1_18_R2.util.CraftNamespacedKey;
import java.util.Map;
public final class EcoCraftEnchantmentManager implements EcoCraftEnchantmentManagerProxy {
@Override
public void registerNewCraftEnchantments() {
Map<org.bukkit.enchantments.Enchantment, VanillaEnchantmentMetadata> metadataMap = VanillaEnchantments.getMetadataMap();
for (Enchantment enchantment : IRegistry.V) {
NamespacedKey key = CraftNamespacedKey.fromMinecraft(IRegistry.V.b(enchantment));
VanillaEnchantmentMetadata metadata = metadataMap.get(org.bukkit.enchantments.Enchantment.getByKey(key));
new EcoCraftEnchantment(enchantment, metadata).register();
}
}
}

View File

@ -1,13 +0,0 @@
package com.willfp.ecoenchants.proxy.v1_18_R2;
import com.willfp.ecoenchants.proxy.proxies.OpenInventoryProxy;
import org.bukkit.craftbukkit.v1_18_R2.entity.CraftPlayer;
import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull;
public final class OpenInventory implements OpenInventoryProxy {
@Override
public Object getOpenInventory(@NotNull final Player player) {
return ((CraftPlayer) player).getHandle().bV;
}
}

View File

@ -1,36 +0,0 @@
package com.willfp.ecoenchants.proxy.v1_18_R2.enchants;
import com.willfp.ecoenchants.enchantments.EcoEnchant;
import com.willfp.ecoenchants.enchantments.support.vanilla.VanillaEnchantmentMetadata;
import com.willfp.ecoenchants.enchantments.util.EnchantmentUtils;
import net.minecraft.world.item.enchantment.Enchantment;
import org.bukkit.craftbukkit.v1_18_R2.enchantments.CraftEnchantment;
import org.jetbrains.annotations.NotNull;
public class EcoCraftEnchantment extends CraftEnchantment {
private final VanillaEnchantmentMetadata metadata;
public EcoCraftEnchantment(@NotNull final Enchantment target,
@NotNull final VanillaEnchantmentMetadata metadata) {
super(target);
this.metadata = metadata;
}
@Override
public int getMaxLevel() {
return metadata.maxLevel() == null ? this.getHandle().a() : metadata.maxLevel();
}
@Override
public boolean conflictsWith(@NotNull final org.bukkit.enchantments.Enchantment other) {
if (other instanceof EcoEnchant) {
return other.conflictsWith(this);
}
return metadata.conflicts() == null ? super.conflictsWith(other) : metadata.conflicts().contains(other.getKey());
}
public void register() {
EnchantmentUtils.register(this);
}
}

View File

@ -1,6 +0,0 @@
group 'com.willfp'
version rootProject.version
dependencies {
compileOnly 'org.spigotmc:spigot:1.19-R0.1-SNAPSHOT'
}

View File

@ -1,25 +0,0 @@
package com.willfp.ecoenchants.proxy.v1_19_R1;
import com.willfp.ecoenchants.enchantments.support.vanilla.VanillaEnchantmentMetadata;
import com.willfp.ecoenchants.enchantments.support.vanilla.VanillaEnchantments;
import com.willfp.ecoenchants.proxy.proxies.EcoCraftEnchantmentManagerProxy;
import com.willfp.ecoenchants.proxy.v1_19_R1.enchants.EcoCraftEnchantment;
import net.minecraft.core.IRegistry;
import net.minecraft.world.item.enchantment.Enchantment;
import org.bukkit.NamespacedKey;
import org.bukkit.craftbukkit.v1_19_R1.util.CraftNamespacedKey;
import java.util.Map;
public final class EcoCraftEnchantmentManager implements EcoCraftEnchantmentManagerProxy {
@Override
public void registerNewCraftEnchantments() {
Map<org.bukkit.enchantments.Enchantment, VanillaEnchantmentMetadata> metadataMap = VanillaEnchantments.getMetadataMap();
for (Enchantment enchantment : IRegistry.W) {
NamespacedKey key = CraftNamespacedKey.fromMinecraft(IRegistry.W.b(enchantment));
VanillaEnchantmentMetadata metadata = metadataMap.get(org.bukkit.enchantments.Enchantment.getByKey(key));
new EcoCraftEnchantment(enchantment, metadata).register();
}
}
}

View File

@ -1,13 +0,0 @@
package com.willfp.ecoenchants.proxy.v1_19_R1;
import com.willfp.ecoenchants.proxy.proxies.OpenInventoryProxy;
import org.bukkit.craftbukkit.v1_19_R1.entity.CraftPlayer;
import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull;
public final class OpenInventory implements OpenInventoryProxy {
@Override
public Object getOpenInventory(@NotNull final Player player) {
return ((CraftPlayer) player).getHandle().bU;
}
}

View File

@ -1,36 +0,0 @@
package com.willfp.ecoenchants.proxy.v1_19_R1.enchants;
import com.willfp.ecoenchants.enchantments.EcoEnchant;
import com.willfp.ecoenchants.enchantments.support.vanilla.VanillaEnchantmentMetadata;
import com.willfp.ecoenchants.enchantments.util.EnchantmentUtils;
import net.minecraft.world.item.enchantment.Enchantment;
import org.bukkit.craftbukkit.v1_19_R1.enchantments.CraftEnchantment;
import org.jetbrains.annotations.NotNull;
public class EcoCraftEnchantment extends CraftEnchantment {
private final VanillaEnchantmentMetadata metadata;
public EcoCraftEnchantment(@NotNull final Enchantment target,
@NotNull final VanillaEnchantmentMetadata metadata) {
super(target);
this.metadata = metadata;
}
@Override
public int getMaxLevel() {
return metadata.maxLevel() == null ? this.getHandle().a() : metadata.maxLevel();
}
@Override
public boolean conflictsWith(@NotNull final org.bukkit.enchantments.Enchantment other) {
if (other instanceof EcoEnchant) {
return other.conflictsWith(this);
}
return metadata.conflicts() == null ? super.conflictsWith(other) : metadata.conflicts().contains(other.getKey());
}
public void register() {
EnchantmentUtils.register(this);
}
}

View File

@ -2,14 +2,17 @@ group 'com.willfp'
version rootProject.version version rootProject.version
dependencies { dependencies {
compileOnly project(":eco-core:core-proxy")
compileOnly 'org.spigotmc:spigot-api:1.18.2-R0.1-SNAPSHOT'
compileOnly 'commons-io:commons-io:2.8.0'
compileOnly 'com.comphenix.protocol:ProtocolLib:4.6.0-SNAPSHOT'
compileOnly 'net.essentialsx:EssentialsX:2.19.0'
compileOnly 'io.papermc.paper:paper-api:1.17.1-R0.1-SNAPSHOT'
compileOnly 'com.sk89q.worldguard:worldguard-bukkit:7.0.4-SNAPSHOT'
compileOnly 'io.lumine:Mythic:5.0.1'
compileOnly 'com.github.ben-manes.caffeine:caffeine:3.0.5'
compileOnly fileTree(dir: '../../lib', include: ['*.jar']) compileOnly fileTree(dir: '../../lib', include: ['*.jar'])
compileOnly 'io.papermc.paper:paper-api:1.17.1-R0.1-SNAPSHOT'
compileOnly 'net.essentialsx:EssentialsX:2.19.0'
}
build.dependsOn publishToMavenLocal
publishing {
publications {
maven(MavenPublication) {
from(components.java)
}
}
} }

View File

@ -1,213 +0,0 @@
package com.willfp.ecoenchants;
import com.willfp.eco.core.command.impl.PluginCommand;
import com.willfp.eco.core.display.DisplayModule;
import com.willfp.eco.core.fast.FastItemStack;
import com.willfp.eco.core.integrations.IntegrationLoader;
import com.willfp.eco.util.TelekinesisUtils;
import com.willfp.ecoenchants.command.CommandEcoEnchants;
import com.willfp.ecoenchants.command.CommandEnchantinfo;
import com.willfp.ecoenchants.config.CustomEnchantsYml;
import com.willfp.ecoenchants.config.RarityYml;
import com.willfp.ecoenchants.config.TargetYml;
import com.willfp.ecoenchants.config.VanillaEnchantsYml;
import com.willfp.ecoenchants.display.EnchantDisplay;
import com.willfp.ecoenchants.enchantments.EcoEnchant;
import com.willfp.ecoenchants.enchantments.EcoEnchants;
import com.willfp.ecoenchants.enchantments.custom.CustomEcoEnchantRequirementListeners;
import com.willfp.ecoenchants.enchantments.custom.CustomEnchantEnableListeners;
import com.willfp.ecoenchants.enchantments.custom.CustomEnchantLookup;
import com.willfp.ecoenchants.enchantments.support.merging.anvil.AnvilListeners;
import com.willfp.ecoenchants.enchantments.support.merging.grindstone.GrindstoneListeners;
import com.willfp.ecoenchants.enchantments.support.obtaining.EnchantingListeners;
import com.willfp.ecoenchants.enchantments.support.obtaining.LootGenerateListeners;
import com.willfp.ecoenchants.enchantments.support.obtaining.VillagerListeners;
import com.willfp.ecoenchants.enchantments.util.ItemConversions;
import com.willfp.ecoenchants.enchantments.util.LazyHealthFixListener;
import com.willfp.ecoenchants.enchantments.util.TimedRunnable;
import com.willfp.ecoenchants.enchantments.util.WatcherTriggers;
import com.willfp.ecoenchants.integrations.mythicmobs.MythicMobsManager;
import com.willfp.ecoenchants.integrations.mythicmobs.plugins.IntegrationMythicMobs;
import com.willfp.ecoenchants.integrations.registration.RegistrationManager;
import com.willfp.ecoenchants.integrations.registration.plugins.IntegrationCMI;
import com.willfp.ecoenchants.integrations.registration.plugins.IntegrationEssentials;
import com.willfp.libreforge.LibReforgePlugin;
import org.bukkit.event.HandlerList;
import org.bukkit.event.Listener;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Objects;
@SuppressWarnings("unused")
public class EcoEnchantsPlugin extends LibReforgePlugin {
/**
* Instance of the plugin.
*/
private static EcoEnchantsPlugin instance;
/**
* Rarity.yml.
*/
private final RarityYml rarityYml;
/**
* Target.yml.
*/
private final TargetYml targetYml;
/**
* VanillaEnchants.yml.
*/
private final VanillaEnchantsYml vanillaEnchantsYml;
/**
* CustomEnchants.yml.
*/
private final CustomEnchantsYml customEnchantsYml;
/**
* Internal constructor called by bukkit on plugin load.
*/
public EcoEnchantsPlugin() {
instance = this;
rarityYml = new RarityYml(this);
targetYml = new TargetYml(this);
vanillaEnchantsYml = new VanillaEnchantsYml(this);
customEnchantsYml = new CustomEnchantsYml(this);
this.registerJavaHolderProvider(player -> new ArrayList<>(CustomEnchantLookup.provideLevels(player)));
}
@Override
public void handleEnableAdditional() {
this.getLogger().info(EcoEnchants.values().size() + " Enchantments Loaded");
TelekinesisUtils.registerTest(player -> FastItemStack.wrap(player.getInventory().getItemInMainHand()).getEnchantmentLevel(EcoEnchants.TELEKINESIS, false) > 0);
}
@Override
public void handleReloadAdditional() {
this.getDisplayModule().update();
for (EcoEnchant enchant : EcoEnchants.values()) {
HandlerList.unregisterAll(enchant);
this.getScheduler().runLater(() -> {
if (enchant.isEnabled()) {
this.getEventManager().registerListener(enchant);
if (enchant instanceof TimedRunnable) {
this.getScheduler().syncRepeating((TimedRunnable) enchant, 5, ((TimedRunnable) enchant).getTime());
}
}
}, 1);
}
this.getScheduler().runTimer(() -> {
for (EcoEnchant enchant : EcoEnchants.values()) {
enchant.clearCachedRequirements();
}
}, 300, 300);
}
@Override
@NotNull
public List<IntegrationLoader> loadAdditionalIntegrations() {
return Arrays.asList(
new IntegrationLoader("Essentials", () -> RegistrationManager.register(new IntegrationEssentials())),
new IntegrationLoader("CMI", () -> RegistrationManager.register(new IntegrationCMI())),
new IntegrationLoader("MythicMobs", () -> MythicMobsManager.register(new IntegrationMythicMobs()))
);
}
@Override
protected List<PluginCommand> loadPluginCommands() {
return Arrays.asList(
new CommandEnchantinfo(this),
new CommandEcoEnchants(this)
);
}
@Override
protected List<Listener> loadListeners() {
return Arrays.asList(
new EnchantingListeners(this),
new GrindstoneListeners(this),
new AnvilListeners(this),
new WatcherTriggers(this),
new VillagerListeners(this),
new ItemConversions(this),
new CustomEnchantEnableListeners(this),
new CustomEcoEnchantRequirementListeners(this),
new LazyHealthFixListener(this),
new LootGenerateListeners(this)
);
}
@Override
@Nullable
protected DisplayModule createDisplayModule() {
return new EnchantDisplay(this);
}
@Override
@NotNull
public EnchantDisplay getDisplayModule() {
return (EnchantDisplay) Objects.requireNonNull(super.getDisplayModule());
}
@NotNull
@Override
public String getMinimumEcoVersion() {
return "6.37.1";
}
/**
* Get the instance of EcoEnchants.
* <p>
* Bad practice to use this.
*
* @return The instance.
*/
public static EcoEnchantsPlugin getInstance() {
return instance;
}
/**
* Get rarity.yml.
*
* @return rarity.yml.
*/
public RarityYml getRarityYml() {
return this.rarityYml;
}
/**
* Get target.yml.
*
* @return target.yml.
*/
public TargetYml getTargetYml() {
return this.targetYml;
}
/**
* Get vanillaenchants.yml.
*
* @return vanillaenchants.yml.
*/
public VanillaEnchantsYml getVanillaEnchantsYml() {
return this.vanillaEnchantsYml;
}
/**
* Get customenchants.yml
*
* @return customenchants.yml.
*/
public CustomEnchantsYml getCustomEnchantsYml() {
return customEnchantsYml;
}
}

View File

@ -1,45 +0,0 @@
package com.willfp.ecoenchants.command;
import com.willfp.eco.core.command.impl.Subcommand;
import com.willfp.eco.core.fast.FastItemStack;
import com.willfp.ecoenchants.EcoEnchantsPlugin;
import org.bukkit.Bukkit;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.inventory.meta.ItemMeta;
import org.jetbrains.annotations.NotNull;
import java.util.ArrayList;
import java.util.List;
@SuppressWarnings("deprecation")
public class CommandDebug extends Subcommand {
/**
* Instantiate a new /ecoenchants debug command handler.
*
* @param plugin The plugin for the commands to listen for.
*/
public CommandDebug(@NotNull final EcoEnchantsPlugin plugin) {
super(plugin, "debug", "ecoenchants.command.debug", true);
}
@Override
public void onExecute(@NotNull final CommandSender sender,
@NotNull final List<String> args) {
Player player = (Player) sender;
player.sendMessage("Held Item: " + player.getInventory().getItemInMainHand());
player.sendMessage("Lore: ");
Bukkit.getLogger().info("");
Bukkit.getLogger().info("Held Item: " + player.getInventory().getItemInMainHand());
Bukkit.getLogger().info("Lore: ");
ItemMeta meta = player.getInventory().getItemInMainHand().getItemMeta();
if (meta != null) {
for (String s : new ArrayList<>(meta.hasLore() ? meta.getLore() : new ArrayList<>())) {
Bukkit.getLogger().info(s);
player.sendMessage(s);
}
}
Bukkit.getLogger().info("");
}
}

View File

@ -1,32 +0,0 @@
package com.willfp.ecoenchants.command;
import com.willfp.eco.core.command.impl.PluginCommand;
import com.willfp.ecoenchants.EcoEnchantsPlugin;
import org.bukkit.command.CommandSender;
import org.jetbrains.annotations.NotNull;
import java.util.List;
public class CommandEcoEnchants extends PluginCommand {
/**
* Instantiate a new /ecoenchants command handler.
*
* @param plugin The plugin for the commands to listen for.
*/
public CommandEcoEnchants(@NotNull final EcoEnchantsPlugin plugin) {
super(plugin, "ecoenchants", "ecoenchants.command.ecoenchants", false);
this.addSubcommand(new CommandDebug(plugin))
.addSubcommand(new CommandReload(plugin))
.addSubcommand(new CommandGiverandombook(plugin))
.addSubcommand(new CommandRandomenchant(plugin))
.addSubcommand(new CommandLocale(plugin))
.addSubcommand(new CommandToggleDescriptions(plugin));
}
@Override
public void onExecute(@NotNull final CommandSender sender,
@NotNull final List<String> args) {
sender.sendMessage(this.getPlugin().getLangYml().getMessage("invalid-command"));
}
}

View File

@ -1,167 +0,0 @@
package com.willfp.ecoenchants.command;
import com.willfp.eco.core.EcoPlugin;
import com.willfp.eco.core.command.impl.PluginCommand;
import com.willfp.eco.core.config.updating.ConfigUpdater;
import com.willfp.eco.util.StringUtils;
import com.willfp.ecoenchants.display.EnchantmentCache;
import com.willfp.ecoenchants.enchantments.EcoEnchant;
import com.willfp.ecoenchants.enchantments.EcoEnchants;
import com.willfp.ecoenchants.enchantments.meta.EnchantmentRarity;
import org.apache.commons.lang.WordUtils;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.command.CommandSender;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.util.StringUtil;
import org.jetbrains.annotations.NotNull;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;
public class CommandEnchantinfo extends PluginCommand {
/**
* Instantiate a new /enchantinfo command handler.
*
* @param plugin The plugin for the commands to listen for.
*/
public CommandEnchantinfo(@NotNull final EcoPlugin plugin) {
super(plugin, "enchantinfo", "ecoenchants.command.enchantinfo", false);
}
@Override
public void onExecute(@NotNull final CommandSender sender,
@NotNull final List<String> args) {
if (args.isEmpty()) {
sender.sendMessage(this.getPlugin().getLangYml().getMessage("missing-enchant"));
return;
}
StringBuilder nameBuilder = new StringBuilder();
args.forEach(arg -> nameBuilder.append(arg).append(" "));
String searchName = nameBuilder.toString();
searchName = searchName.substring(0, searchName.length() - 1);
EcoEnchant enchantment = EcoEnchants.getByName(searchName);
if (enchantment == null) {
String finalSearchName = searchName;
enchantment = EcoEnchants.values().stream().filter(ecoEnchant -> ChatColor.stripColor(ecoEnchant.getDisplayName()).equalsIgnoreCase(finalSearchName)).findFirst().orElse(null);
}
if (enchantment == null || !enchantment.isEnabled()) {
String message = this.getPlugin().getLangYml().getMessage("not-found").replace("%name%", searchName);
sender.sendMessage(message);
return;
}
Set<String> conflictNames = new HashSet<>();
Set<Enchantment> conflicts = enchantment.getConflicts();
new HashSet<>(conflicts).forEach(enchantment1 -> {
if (enchantment1 instanceof EcoEnchant ecoEnchant) {
if (!ecoEnchant.isEnabled()) {
conflicts.remove(enchantment1);
}
}
});
conflicts.forEach((enchantment1 -> {
if (enchantment1 instanceof EcoEnchant enchant) {
conflictNames.add(enchant.getDisplayName());
} else {
conflictNames.add(this.getPlugin().getLangYml().getFormattedString("enchantments." + enchantment1.getKey().getKey() + ".name"));
}
}));
StringBuilder conflictNamesBuilder = new StringBuilder();
conflictNames.forEach(name1 -> conflictNamesBuilder.append(name1).append(", "));
String allConflicts = conflictNamesBuilder.toString();
if (allConflicts.length() >= 2) {
allConflicts = allConflicts.substring(0, allConflicts.length() - 2);
} else {
allConflicts = this.getPlugin().getLangYml().getFormattedString("no-conflicts");
}
Set<Material> targets = enchantment.getTargetMaterials();
Set<String> applicableItemsSet = new HashSet<>();
if (this.getPlugin().getConfigYml().getBool("commands.enchantinfo.show-target-group")) {
enchantment.getTargets().forEach(target -> {
String targetName = target.getName();
targetName = targetName.toLowerCase();
targetName = targetName.replace("_", " ");
targetName = WordUtils.capitalize(targetName);
applicableItemsSet.add(targetName);
});
} else {
targets.forEach(material -> {
String matName = material.toString();
matName = matName.toLowerCase();
matName = matName.replace("_", " ");
matName = WordUtils.capitalize(matName);
applicableItemsSet.add(matName);
});
}
StringBuilder targetNamesBuilder = new StringBuilder();
applicableItemsSet.forEach(name1 -> targetNamesBuilder.append(name1).append(", "));
String allTargets = targetNamesBuilder.toString();
if (allTargets.length() >= 2) {
allTargets = allTargets.substring(0, allTargets.length() - 2);
} else {
allTargets = this.getPlugin().getLangYml().getFormattedString("no-targets");
}
String maxLevel = String.valueOf(enchantment.getMaxLevel());
final String finalName = EnchantmentCache.getEntry(enchantment).getName();
final String finalDescription = EnchantmentCache.getEntry(enchantment).getStringDescription(1);
final EnchantmentRarity finalRarity = enchantment.getEnchantmentRarity();
final String finalTargets = allTargets;
final String finalConflicts = allConflicts;
final String finalMaxLevel = maxLevel;
Arrays.asList(this.getPlugin().getLangYml().getMessage("enchantinfo").split("\\r?\\n")).forEach((string -> {
string = string.replace("%name%", finalName)
.replace("%description%", finalDescription)
.replace("%rarity%", finalRarity.getName())
.replace("%target%", finalTargets)
.replace("%conflicts%", finalConflicts)
.replace("%maxlevel%", finalMaxLevel);
sender.sendMessage(string);
}));
}
@Override
public List<String> tabComplete(@NotNull final CommandSender sender,
@NotNull final List<String> args) {
List<String> completions = new ArrayList<>();
List<String> names = EcoEnchants.values().stream().filter(EcoEnchant::isEnabled).map(EcoEnchant::getDisplayName).map(ChatColor::stripColor).toList();
if (args.isEmpty()) {
// Currently, this case is not ever reached
return names;
}
StringUtil.copyPartialMatches(String.join(" ", args), names, completions);
if (args.size() > 1) { // Remove all previous words from the candidate of completions
ArrayList<String> finishedArgs = new ArrayList<>(args);
finishedArgs.remove(args.size() - 1);
String prefix = String.join(" ", finishedArgs);
completions = completions.stream().map(enchantName -> StringUtils.removePrefix(enchantName, prefix).trim()).collect(Collectors.toList());
}
Collections.sort(completions);
return completions;
}
}

View File

@ -1,138 +0,0 @@
package com.willfp.ecoenchants.command;
import com.willfp.eco.core.EcoPlugin;
import com.willfp.eco.core.command.impl.Subcommand;
import com.willfp.eco.core.config.updating.ConfigUpdater;
import com.willfp.eco.core.items.builder.EnchantedBookBuilder;
import com.willfp.eco.util.NumberUtils;
import com.willfp.ecoenchants.display.EnchantmentCache;
import com.willfp.ecoenchants.enchantments.EcoEnchant;
import com.willfp.ecoenchants.enchantments.meta.EnchantmentRarity;
import com.willfp.ecoenchants.enchantments.meta.EnchantmentType;
import org.bukkit.Bukkit;
import org.bukkit.command.CommandSender;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.bukkit.util.StringUtil;
import org.jetbrains.annotations.NotNull;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.stream.Collectors;
public class CommandGiverandombook extends Subcommand {
/**
* The cached enchantment names.
*/
private static final List<String> RARITY_NAMES = EnchantmentRarity.values().stream().map(EnchantmentRarity::getName).collect(Collectors.toList());
/**
* The cached type names.
*/
private static final List<String> TYPE_NAMES = EnchantmentType.values().stream().map(EnchantmentType::getName).collect(Collectors.toList());
/**
* Instantiate a new command handler.
*
* @param plugin The plugin for the commands to listen for.
*/
public CommandGiverandombook(@NotNull final EcoPlugin plugin) {
super(plugin, "giverandombook", "ecoenchants.command.giverandombook", false);
}
/**
* Called on /reload.
*/
@ConfigUpdater
public static void reload() {
RARITY_NAMES.clear();
RARITY_NAMES.addAll(EnchantmentRarity.values().stream().map(EnchantmentRarity::getName).toList());
}
@Override
public void onExecute(@NotNull final CommandSender sender,
@NotNull final List<String> args) {
if (args.isEmpty()) {
sender.sendMessage(this.getPlugin().getLangYml().getMessage("requires-player"));
return;
}
Player player = Bukkit.getServer().getPlayer(args.get(0));
EnchantmentRarity rarity = args.size() >= 2 ? EnchantmentRarity.getByName(args.get(1).toLowerCase()) : null;
EnchantmentType type = rarity == null && args.size() >= 2 ? EnchantmentType.getByName(args.get(1).toLowerCase()) : null;
if (player == null) {
sender.sendMessage(this.getPlugin().getLangYml().getMessage("invalid-player"));
return;
}
List<Enchantment> allowed = Arrays.stream(Enchantment.values()).filter(enchantment -> {
if (enchantment instanceof EcoEnchant) {
return ((EcoEnchant) enchantment).isEnabled();
}
return true;
}).filter(enchantment -> {
if (rarity != null) {
if (!(enchantment instanceof EcoEnchant ecoEnchant)) {
return false;
}
return ecoEnchant.getEnchantmentRarity().equals(rarity);
} else if (type != null) {
if (!(enchantment instanceof EcoEnchant ecoEnchant)) {
return false;
}
return ecoEnchant.getType().equals(type);
}
return true;
}).toList();
Enchantment enchantment = allowed.get(NumberUtils.randInt(0, allowed.size() - 1));
int level = NumberUtils.randInt(1, enchantment.getMaxLevel());
ItemStack itemStack = new EnchantedBookBuilder()
.addStoredEnchantment(enchantment, level)
.build();
for (ItemStack stack : player.getInventory().addItem(itemStack).values()) {
player.getWorld().dropItem(player.getLocation(), stack);
}
String message = this.getPlugin().getLangYml().getMessage("gave-random-book");
message = message.replace("%enchantment%", EnchantmentCache.getEntry(enchantment).getName() + " " + NumberUtils.toNumeral(level) + "§r");
sender.sendMessage(message);
String message2 = this.getPlugin().getLangYml().getMessage("received-random-book");
message2 = message2.replace("%enchantment%", EnchantmentCache.getEntry(enchantment).getName() + " " + NumberUtils.toNumeral(level) + "§r");
player.sendMessage(message2);
}
@Override
public List<String> tabComplete(@NotNull final CommandSender sender,
@NotNull final List<String> args) {
List<String> completions = new ArrayList<>();
List<String> playerNames = Bukkit.getOnlinePlayers().stream().map(Player::getName).collect(Collectors.toList());
if (args.isEmpty()) {
// Currently, this case is not ever reached
return playerNames;
}
if (args.size() == 1) {
StringUtil.copyPartialMatches(String.join(" ", args.get(0)), playerNames, completions);
}
if (args.size() == 2) {
StringUtil.copyPartialMatches(String.join(" ", args.get(1)), RARITY_NAMES, completions);
StringUtil.copyPartialMatches(String.join(" ", args.get(1)), TYPE_NAMES, completions);
}
Collections.sort(completions);
return completions;
}
}

View File

@ -1,28 +0,0 @@
package com.willfp.ecoenchants.command;
import com.willfp.eco.core.command.impl.Subcommand;
import com.willfp.ecoenchants.EcoEnchantsPlugin;
import org.bukkit.command.CommandSender;
import org.jetbrains.annotations.NotNull;
import java.util.List;
public class CommandLocale extends Subcommand {
/**
* Instantiate a new /ecoenchants locale command handler.
*
* @param plugin The plugin for the commands to listen for.
*/
public CommandLocale(@NotNull final EcoEnchantsPlugin plugin) {
super(plugin, "locale", "ecoenchants.command.locale", false);
this.addSubcommand(new CommandLocaleExport(plugin))
.addSubcommand(new CommandLocaleDownload(plugin));
}
@Override
public void onExecute(@NotNull final CommandSender sender,
@NotNull final List<String> args) {
sender.sendMessage(this.getPlugin().getLangYml().getMessage("specify-locale-subcommand"));
}
}

View File

@ -1,61 +0,0 @@
package com.willfp.ecoenchants.command;
import com.willfp.eco.core.command.impl.Subcommand;
import com.willfp.eco.core.config.ConfigType;
import com.willfp.eco.core.config.TransientConfig;
import com.willfp.eco.core.config.interfaces.Config;
import com.willfp.eco.core.web.Paste;
import com.willfp.ecoenchants.EcoEnchantsPlugin;
import com.willfp.ecoenchants.enchantments.EcoEnchant;
import com.willfp.ecoenchants.enchantments.EcoEnchants;
import org.bukkit.command.CommandSender;
import org.jetbrains.annotations.NotNull;
import java.io.IOException;
import java.util.List;
public class CommandLocaleDownload extends Subcommand {
/**
* Instantiate a new /ecoenchants locale download command handler.
*
* @param plugin The plugin for the commands to listen for.
*/
public CommandLocaleDownload(@NotNull final EcoEnchantsPlugin plugin) {
super(plugin, "download", "ecoenchants.command.locale.download", false);
}
@Override
public void onExecute(@NotNull final CommandSender sender,
@NotNull final List<String> args) {
if (args.isEmpty()) {
sender.sendMessage(this.getPlugin().getLangYml().getMessage("invalid-locale"));
return;
}
Paste paste = Paste.getFromHastebin(args.get(0));
if (paste == null) {
sender.sendMessage(this.getPlugin().getLangYml().getMessage("invalid-locale"));
return;
}
String contents = paste.getContents();
Config configuration = new TransientConfig(contents, ConfigType.YAML);
for (String key : configuration.getKeys(true)) {
this.getPlugin().getLangYml().set(key, configuration.get(key));
}
try {
this.getPlugin().getLangYml().save();
for (EcoEnchant value : EcoEnchants.values()) {
value.getConfig().loadFromLang();
value.getConfig().save();
}
} catch (IOException e) {
e.printStackTrace();
}
sender.sendMessage(this.getPlugin().getLangYml().getMessage("downloaded-locale"));
}
}

View File

@ -1,50 +0,0 @@
package com.willfp.ecoenchants.command;
import com.willfp.eco.core.command.impl.Subcommand;
import com.willfp.eco.core.web.Paste;
import com.willfp.ecoenchants.EcoEnchantsPlugin;
import com.willfp.ecoenchants.enchantments.EcoEnchant;
import com.willfp.ecoenchants.enchantments.EcoEnchants;
import org.bukkit.command.CommandSender;
import org.bukkit.configuration.file.YamlConfiguration;
import org.jetbrains.annotations.NotNull;
import java.io.StringReader;
import java.util.List;
public class CommandLocaleExport extends Subcommand {
/**
* Instantiate a new /ecoenchants locale export command handler.
*
* @param plugin The plugin for the commands to listen for.
*/
public CommandLocaleExport(@NotNull final EcoEnchantsPlugin plugin) {
super(plugin, "export", "ecoenchants.command.locale.export", false);
}
@Override
public void onExecute(@NotNull final CommandSender sender,
@NotNull final List<String> args) {
YamlConfiguration configuration = YamlConfiguration.loadConfiguration(new StringReader(this.getPlugin().getLangYml().toPlaintext()));
for (EcoEnchant enchant : EcoEnchants.values()) {
configuration.set("enchantments." + enchant.getKey().getKey() + ".name", enchant.getConfig().getHandle().getString("name"));
configuration.set("enchantments." + enchant.getKey().getKey() + ".description", enchant.getConfig().getHandle().getString("description"));
}
Paste paste = new Paste(configuration.saveToString());
paste.getHastebinToken(token -> {
if (token.length() > 15) {
sender.sendMessage(
this.getPlugin().getLangYml().getMessage("export-failed")
);
} else {
sender.sendMessage(
this.getPlugin().getLangYml().getMessage("link-to-locale").replace(
"%token%", token
)
);
}
});
}
}

View File

@ -1,143 +0,0 @@
package com.willfp.ecoenchants.command;
import com.willfp.eco.core.EcoPlugin;
import com.willfp.eco.core.command.impl.Subcommand;
import com.willfp.ecoenchants.display.EnchantmentCache;
import com.willfp.ecoenchants.enchantments.EcoEnchant;
import com.willfp.ecoenchants.enchantments.EcoEnchants;
import com.willfp.ecoenchants.enchantments.meta.EnchantmentTarget;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.command.CommandSender;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.EnchantmentStorageMeta;
import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.util.StringUtil;
import org.jetbrains.annotations.NotNull;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.stream.Collectors;
public class CommandRandomenchant extends Subcommand {
/**
* Instantiate a new /ecoreload command handler.
*
* @param plugin The plugin for the commands to listen for.
*/
public CommandRandomenchant(@NotNull final EcoPlugin plugin) {
super(plugin, "randomenchant", "ecoenchants.command.randomenchant", false);
}
@Override
public void onExecute(@NotNull final CommandSender sender,
@NotNull final List<String> args) {
Player player;
if ((args.isEmpty() && sender instanceof Player) || !sender.hasPermission("ecoenchants.command.randomenchant.others")) {
player = (Player) sender;
} else if (!args.isEmpty()) {
player = Bukkit.getServer().getPlayer(args.get(0));
} else {
player = null;
}
if (player == null) {
sender.sendMessage(this.getPlugin().getLangYml().getMessage("invalid-player"));
return;
}
ItemStack itemStack = player.getInventory().getItemInMainHand();
ItemMeta meta = itemStack.getItemMeta();
if (itemStack.getType() == Material.AIR || meta == null || !EnchantmentTarget.ALL.getMaterials().contains(itemStack.getType())) {
if (player.equals(sender)) {
player.sendMessage(this.getPlugin().getLangYml().getMessage("must-hold-item"));
} else {
sender.sendMessage(this.getPlugin().getLangYml().getMessage("must-hold-item-other"));
}
return;
}
List<EcoEnchant> ecoEnchants = new ArrayList<>(EcoEnchants.values());
Collections.shuffle(ecoEnchants);
EcoEnchant enchant = null;
List<Enchantment> onItem = new ArrayList<>();
if (meta instanceof EnchantmentStorageMeta) {
onItem.addAll(((EnchantmentStorageMeta) meta).getStoredEnchants().keySet());
} else {
onItem.addAll(meta.getEnchants().keySet());
}
for (EcoEnchant ecoEnchant : ecoEnchants) {
if (ecoEnchant.canEnchantItem(itemStack)) {
if (!ecoEnchant.conflictsWithAny(onItem)) {
if (ecoEnchant.isEnabled()) {
if (onItem.stream().noneMatch(enchantment -> enchantment.conflictsWith(ecoEnchant))) {
if (!onItem.contains(ecoEnchant)) {
boolean conflicts = false;
for (Enchantment enchantment : onItem) {
if (enchantment instanceof EcoEnchant ecoEnchantOnItem) {
if (ecoEnchantOnItem.getType().equals(ecoEnchant.getType()) && ecoEnchantOnItem.getType().isSingular()) {
conflicts = true;
}
}
}
if (this.getPlugin().getConfigYml().getBool("anvil.hard-cap.enabled")
&& !player.hasPermission("ecoenchants.command.randomenchant.bypasshardcap")
&& onItem.size() >= this.getPlugin().getConfigYml().getInt("anvil.hard-cap.cap")) {
conflicts = true;
}
if (!conflicts) {
enchant = ecoEnchant;
}
}
}
}
}
}
}
if (enchant == null) {
player.sendMessage(this.getPlugin().getLangYml().getMessage("no-enchants-available"));
return;
}
if (meta instanceof EnchantmentStorageMeta) {
((EnchantmentStorageMeta) meta).addStoredEnchant(enchant, enchant.getMaxLevel(), true);
} else {
meta.addEnchant(enchant, enchant.getMaxLevel(), true);
}
itemStack.setItemMeta(meta);
String message = this.getPlugin().getLangYml().getMessage("applied-random-enchant");
message = message.replace("%enchantment%", EnchantmentCache.getEntry(enchant).getName() + "§r");
player.sendMessage(message);
}
@Override
public List<String> tabComplete(@NotNull final CommandSender sender,
@NotNull final List<String> args) {
List<String> completions = new ArrayList<>();
List<String> playerNames = Bukkit.getOnlinePlayers().stream().map(Player::getName).collect(Collectors.toList());
if (args.isEmpty() || !sender.hasPermission("ecoenchants.command.randomenchant.others")) {
// Currently, this case is not ever reached
return playerNames;
}
if (args.size() == 1) {
StringUtil.copyPartialMatches(String.join(" ", args), playerNames, completions);
Collections.sort(completions);
return completions;
}
return new ArrayList<>();
}
}

View File

@ -1,28 +0,0 @@
package com.willfp.ecoenchants.command;
import com.willfp.eco.core.command.impl.Subcommand;
import com.willfp.eco.util.NumberUtils;
import com.willfp.eco.util.StringUtils;
import com.willfp.ecoenchants.EcoEnchantsPlugin;
import org.bukkit.command.CommandSender;
import org.jetbrains.annotations.NotNull;
import java.util.List;
public class CommandReload extends Subcommand {
/**
* Instantiate a new command handler.
*
* @param plugin The plugin for the commands to listen for.
*/
public CommandReload(@NotNull final EcoEnchantsPlugin plugin) {
super(plugin, "reload", "ecoenchants.command.reload", false);
}
@Override
public void onExecute(@NotNull final CommandSender sender,
@NotNull final List<String> args) {
sender.sendMessage(this.getPlugin().getLangYml().getMessage("reloaded", StringUtils.FormatOption.WITHOUT_PLACEHOLDERS)
.replace("%time%", NumberUtils.format(this.getPlugin().reloadWithTime())));
}
}

View File

@ -1,52 +0,0 @@
package com.willfp.ecoenchants.command;
import com.willfp.eco.core.command.impl.Subcommand;
import com.willfp.eco.core.data.PlayerProfile;
import com.willfp.eco.core.data.keys.PersistentDataKey;
import com.willfp.eco.core.data.keys.PersistentDataKeyType;
import com.willfp.eco.util.NamespacedKeyUtils;
import com.willfp.ecoenchants.EcoEnchantsPlugin;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull;
import java.util.List;
public class CommandToggleDescriptions extends Subcommand {
/**
* Persistent data key for descriptions.
*/
public static final PersistentDataKey<Boolean> DESCRIPTIONS_KEY = new PersistentDataKey<>(
NamespacedKeyUtils.create("ecoenchants", "descriptions_enabled"),
PersistentDataKeyType.BOOLEAN,
true
).player();
/**
* Instantiate a new command handler.
*
* @param plugin The plugin for the commands to listen for.
*/
public CommandToggleDescriptions(@NotNull final EcoEnchantsPlugin plugin) {
super(plugin, "toggledescriptions", "ecoenchants.command.toggledescriptions", true);
}
@Override
public void onExecute(@NotNull final CommandSender sender,
@NotNull final List<String> args) {
if (!((EcoEnchantsPlugin) this.getPlugin()).getDisplayModule().getOptions().getDescriptionOptions().isEnabled()) {
sender.sendMessage(this.getPlugin().getLangYml().getMessage("descriptions-disabled"));
return;
}
Player player = (Player) sender;
PlayerProfile profile = PlayerProfile.load(player);
boolean currentStatus = profile.read(DESCRIPTIONS_KEY);
currentStatus = !currentStatus;
profile.write(DESCRIPTIONS_KEY, currentStatus);
if (currentStatus) {
player.sendMessage(this.getPlugin().getLangYml().getMessage("enabled-descriptions"));
} else {
player.sendMessage(this.getPlugin().getLangYml().getMessage("disabled-descriptions"));
}
}
}

View File

@ -1,17 +0,0 @@
package com.willfp.ecoenchants.config;
import com.willfp.eco.core.EcoPlugin;
import com.willfp.eco.core.config.BaseConfig;
import com.willfp.eco.core.config.ConfigType;
import org.jetbrains.annotations.NotNull;
public class CustomEnchantsYml extends BaseConfig {
/**
* Instantiate target.yml.
*
* @param plugin Instance of EcoEnchants.
*/
public CustomEnchantsYml(@NotNull final EcoPlugin plugin) {
super("customenchants", plugin, true, ConfigType.YAML);
}
}

View File

@ -1,28 +0,0 @@
package com.willfp.ecoenchants.config;
import com.willfp.eco.core.EcoPlugin;
import com.willfp.eco.core.config.BaseConfig;
import com.willfp.eco.core.config.ConfigType;
import org.jetbrains.annotations.NotNull;
import java.util.List;
public class RarityYml extends BaseConfig {
/**
* Instantiate rarity.yml.
*
* @param plugin Instance of EcoEnchants.
*/
public RarityYml(@NotNull final EcoPlugin plugin) {
super("rarity", plugin, false, ConfigType.YAML);
}
/**
* Get all rarity names.
*
* @return Set of all rarity names.
*/
public List<String> getRarities() {
return this.getSubsection("rarities").getKeys(false);
}
}

View File

@ -1,68 +0,0 @@
package com.willfp.ecoenchants.config;
import com.willfp.eco.core.EcoPlugin;
import com.willfp.eco.core.config.BaseConfig;
import com.willfp.eco.core.config.ConfigType;
import com.willfp.ecoenchants.enchantments.meta.EnchantmentTarget;
import org.bukkit.Material;
import org.jetbrains.annotations.NotNull;
import java.util.HashSet;
import java.util.List;
import java.util.Objects;
import java.util.Set;
public class TargetYml extends BaseConfig {
/**
* Instantiate target.yml.
*
* @param plugin Instance of EcoEnchants.
*/
public TargetYml(@NotNull final EcoPlugin plugin) {
super("target", plugin, false, ConfigType.YAML);
}
/**
* Get all target names.
*
* @return Set of all names.
*/
public List<String> getTargets() {
return this.getSubsection("targets").getKeys(false);
}
/**
* Get all materials from a target name.
*
* @param target The name of the target.
* @return All materials.
*/
public Set<Material> getTargetMaterials(@NotNull final String target) {
Set<Material> materials = new HashSet<>();
this.getStrings("targets." + target).forEach(materialName -> {
materials.add(Material.getMaterial(materialName.toUpperCase()));
});
materials.removeIf(Objects::isNull);
return materials;
}
/**
* Get the slot for a target name.
*
* @param target The target.
* @return The slot, or {@link com.willfp.ecoenchants.enchantments.meta.EnchantmentTarget.Slot#ANY}
*/
public EnchantmentTarget.Slot getSlot(@NotNull final String target) {
for (String str : this.getStrings("targets." + target)) {
if (str.startsWith("slot:")) {
return EnchantmentTarget.Slot.valueOf(
str.replace("slot:", "").toUpperCase()
);
}
}
return EnchantmentTarget.Slot.ANY;
}
}

View File

@ -1,17 +0,0 @@
package com.willfp.ecoenchants.config;
import com.willfp.eco.core.EcoPlugin;
import com.willfp.eco.core.config.BaseConfig;
import com.willfp.eco.core.config.ConfigType;
import org.jetbrains.annotations.NotNull;
public class VanillaEnchantsYml extends BaseConfig {
/**
* Instantiate target.yml.
*
* @param plugin Instance of EcoEnchants.
*/
public VanillaEnchantsYml(@NotNull final EcoPlugin plugin) {
super("vanillaenchants", plugin, true, ConfigType.YAML);
}
}

View File

@ -1,24 +0,0 @@
package com.willfp.ecoenchants.config.configs;
import com.willfp.eco.core.EcoPlugin;
import com.willfp.eco.core.config.ConfigType;
import com.willfp.eco.core.config.ExtendableConfig;
import com.willfp.ecoenchants.enchantments.EcoEnchant;
import org.jetbrains.annotations.NotNull;
public class BaseEnchantmentConfig extends ExtendableConfig {
/**
* Instantiate a new config for an enchantment.
*
* @param name The name of the config.
* @param source The class in the jar where the config is contained.
* @param plugin The provider of the enchantment.
* @param enchant The enchantment.
*/
public BaseEnchantmentConfig(@NotNull final String name,
@NotNull final Class<?> source,
@NotNull final EcoEnchant enchant,
@NotNull final EcoPlugin plugin) {
super(name, true, plugin, source, "enchants/" + enchant.getType().getName() + "/", ConfigType.YAML);
}
}

View File

@ -1,142 +0,0 @@
package com.willfp.ecoenchants.config.configs;
import com.willfp.eco.core.EcoPlugin;
import com.willfp.eco.core.config.interfaces.Config;
import com.willfp.eco.core.config.interfaces.LoadableConfig;
import com.willfp.eco.core.config.wrapper.ConfigWrapper;
import com.willfp.ecoenchants.enchantments.EcoEnchant;
import com.willfp.ecoenchants.enchantments.EcoEnchants;
import com.willfp.ecoenchants.enchantments.meta.EnchantmentRarity;
import com.willfp.ecoenchants.enchantments.meta.EnchantmentTarget;
import lombok.Getter;
import org.bukkit.Bukkit;
import org.bukkit.NamespacedKey;
import org.bukkit.enchantments.Enchantment;
import org.jetbrains.annotations.NotNull;
import java.io.IOException;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
public class EnchantmentConfig extends ConfigWrapper<Config> {
/**
* The name of the config.
*/
@Getter
private final String name;
/**
* The enchantment.
*/
@Getter
private final EcoEnchant enchant;
/**
* Instance of EcoEnchants.
*/
@Getter
private final EcoPlugin plugin;
/**
* Instantiate a new config for an enchantment.
*
* @param handle The handle.
* @param name The config name.
* @param enchant The enchant.
* @param plugin Instance of EcoEnchants.
*/
public EnchantmentConfig(@NotNull final Config handle,
@NotNull final String name,
@NotNull final EcoEnchant enchant,
@NotNull final EcoPlugin plugin) {
super(handle);
this.name = name;
this.enchant = enchant;
this.plugin = plugin;
}
/**
* Get a set of enchantments stored by key.
*
* @param path The location of the enchantments in the config.
* @return A set of all enchantments.
*/
public Set<Enchantment> getEnchantments(@NotNull final String path) {
Set<Enchantment> enchantments = new HashSet<>();
List<String> enchantmentKeys = this.getStrings(path);
for (String key : enchantmentKeys) {
if (Enchantment.getByKey(NamespacedKey.minecraft(key)) != null) {
enchantments.add(Enchantment.getByKey(NamespacedKey.minecraft(key)));
}
}
return enchantments;
}
/**
* Get the rarity of the enchantment.
*
* @return The rarity, or null if invalid.
*/
public EnchantmentRarity getRarity() {
String rarityName = this.getString("obtaining.rarity");
return EnchantmentRarity.getByName(rarityName);
}
/**
* Get all applicable targets.
*
* @return The targets.
*/
public Set<EnchantmentTarget> getTargets() {
List<String> targetNames = this.getStrings(EcoEnchants.GENERAL_LOCATION + "targets");
if (targetNames.isEmpty()) {
return new HashSet<>();
}
Set<EnchantmentTarget> targets = new HashSet<>();
targetNames.forEach((s -> {
if (EnchantmentTarget.getByName(s) == null) {
Bukkit.getLogger().warning("Target specified in " + name + " is invalid!");
return;
}
targets.add(EnchantmentTarget.getByName(s));
}));
return targets;
}
/**
* Load config values from lang.yml.
*/
public void loadFromLang() {
if (!this.getPlugin().getLangYml().has("enchantments." + this.getEnchant().getKey().getKey())) {
return;
}
this.set("name", this.getPlugin().getLangYml().getString("enchantments." + this.getEnchant().getKey().getKey() + ".name"));
this.set("description", this.getPlugin().getLangYml().getString("enchantments." + this.getEnchant().getKey().getKey() + ".description"));
this.getPlugin().getLangYml().set("enchantments." + this.getEnchant().getKey().getKey(), null);
try {
this.save();
this.getPlugin().getLangYml().save();
} catch (IOException e) {
e.printStackTrace();
}
}
/**
* Save if savable config.
*/
public void save() {
try {
if (this.getHandle() instanceof LoadableConfig loadableConfig) {
loadableConfig.save();
}
} catch (IOException e) {
e.printStackTrace();
}
}
}

View File

@ -1,275 +0,0 @@
package com.willfp.ecoenchants.display;
import com.google.common.collect.Lists;
import com.willfp.eco.core.EcoPlugin;
import com.willfp.eco.core.display.Display;
import com.willfp.eco.core.display.DisplayModule;
import com.willfp.eco.core.display.DisplayPriority;
import com.willfp.eco.core.fast.FastItemStack;
import com.willfp.eco.util.StringUtils;
import com.willfp.ecoenchants.display.options.DisplayOptions;
import com.willfp.ecoenchants.enchantments.EcoEnchant;
import com.willfp.ecoenchants.enchantments.custom.CustomEcoEnchant;
import com.willfp.ecoenchants.enchantments.meta.EnchantmentTarget;
import com.willfp.ecoenchants.enchantments.util.ItemConversionOptions;
import lombok.Getter;
import org.bukkit.Material;
import org.bukkit.NamespacedKey;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemFlag;
import org.bukkit.inventory.ItemStack;
import org.bukkit.persistence.PersistentDataContainer;
import org.bukkit.persistence.PersistentDataType;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
/**
* All methods and fields pertaining to showing players the enchantments on their items.
*/
@SuppressWarnings("DeprecatedIsStillUsed")
public class EnchantDisplay extends DisplayModule {
/**
* The meta key to hide enchantments in lore.
* <p>
* EcoEnchants packet lore implementation of HideEnchants.
*/
@Getter
private final NamespacedKey keySkip;
/**
* The legacy V key.
* <p>
* Exists for backwards compatibility.
*/
@Getter
@Deprecated
private final NamespacedKey legacyV;
/**
* The configurable options for displaying enchantments.
*/
@Getter
private final DisplayOptions options;
/**
* Create EcoEnchants display module.
*
* @param plugin Instance of EcoEnchants.
*/
public EnchantDisplay(@NotNull final EcoPlugin plugin) {
super(plugin, DisplayPriority.LOW);
keySkip = this.getPlugin().getNamespacedKeyFactory().create("ecoenchantlore-skip");
legacyV = this.getPlugin().getNamespacedKeyFactory().create("ecoenchantlore-v");
options = new DisplayOptions(this.getPlugin());
}
/**
* Update config values.
*/
public void update() {
options.update();
EnchantmentCache.update();
}
@Override
public void display(@NotNull final ItemStack itemStack,
@Nullable final Player player,
@NotNull final Object... args) {
if (options.isRequireTarget()) {
if (!EnchantmentTarget.ALL.getMaterials().contains(itemStack.getType())) {
return;
}
}
FastItemStack fastItemStack = FastItemStack.wrap(itemStack);
boolean hide = (boolean) args[0];
if (hide || fastItemStack.getPersistentDataContainer().has(keySkip, PersistentDataType.INTEGER)) {
fastItemStack.addItemFlags(ItemFlag.HIDE_ENCHANTS);
if (itemStack.getType() == Material.ENCHANTED_BOOK) {
fastItemStack.addItemFlags(ItemFlag.HIDE_POTION_EFFECTS);
}
fastItemStack.getPersistentDataContainer().set(keySkip, PersistentDataType.INTEGER, 1);
return;
}
List<String> itemLore = fastItemStack.getLore();
List<String> lore = new ArrayList<>();
List<String> requirementLore = new ArrayList<>();
LinkedHashMap<Enchantment, Integer> enchantments = new LinkedHashMap<>(fastItemStack.getEnchants(true));
enchantments.entrySet().removeIf(enchantmentIntegerEntry -> enchantmentIntegerEntry.getValue().equals(0));
List<Enchantment> unsorted = new ArrayList<>();
enchantments.forEach((enchantment, integer) -> unsorted.add(enchantment));
Map<Enchantment, Integer> tempEnchantments = new HashMap<>(enchantments);
options.getSorter().sortEnchantments(unsorted);
enchantments.clear();
unsorted.forEach(enchantment -> enchantments.put(enchantment, tempEnchantments.get(enchantment)));
enchantments.forEach((enchantment, level) -> {
if (enchantment instanceof EcoEnchant ecoEnchant && ecoEnchant.hasFlag("hide-in-lore")) {
return;
}
String name = player == null
? EnchantmentCache.getEntry(enchantment).getNameWithLevel(level)
: EnchantmentCache.getEntry(enchantment).getNameWithLevel(level, player);
lore.add(Display.PREFIX + name);
if (!options.getDescriptionOptions().isShowingAtBottom()) {
if (enchantments.size() <= options.getDescriptionOptions().getThreshold()
&& options.getDescriptionOptions().isEnabled()
&& options.getDescriptionOptions().enabledForPlayer(player)
) {
if (options.getDescriptionOptions().isOnlyOnBooks() && itemStack.getType() != Material.ENCHANTED_BOOK) {
return;
}
lore.addAll(EnchantmentCache.getEntry(enchantment).getDescription(level));
}
}
if (player != null && enchantment instanceof EcoEnchant ecoEnchant) {
if (ecoEnchant instanceof CustomEcoEnchant custom) {
requirementLore.addAll(custom.getLevel(level).getNotMetLines(player).stream().map(l -> Display.PREFIX + l).toList());
}
if (!ecoEnchant.areRequirementsMet(player)) {
requirementLore.addAll(StringUtils.formatList(EnchantmentCache.getEntry(enchantment).getRequirementLore(), player));
}
}
});
if (options.getShrinkOptions().isEnabled() && (enchantments.size() > options.getShrinkOptions().getThreshold())) {
List<List<String>> partitionedCombinedLoreList = Lists.partition(lore, options.getShrinkOptions().getShrinkPerLine());
List<String> newLore = new ArrayList<>();
partitionedCombinedLoreList.forEach(list -> {
StringBuilder builder = new StringBuilder();
for (String s : list) {
builder.append(s);
builder.append(", ");
}
String line = builder.toString();
line = line.substring(0, line.length() - 2);
newLore.add(line);
});
lore.clear();
lore.addAll(newLore);
}
if (options.getDescriptionOptions().isShowingAtBottom()) {
if (enchantments.size() <= options.getDescriptionOptions().getThreshold()
&& options.getDescriptionOptions().isEnabled()
&& options.getDescriptionOptions().enabledForPlayer(player)
) {
for (Map.Entry<Enchantment, Integer> entry : enchantments.entrySet()) {
lore.addAll(EnchantmentCache.getEntry(entry.getKey()).getDescription(entry.getValue()));
}
}
}
if (!(itemStack.getType() == Material.ENCHANTED_BOOK && !options.isPrefixOnBooks())) {
if (!enchantments.isEmpty()) {
lore.addAll(0, options.getLorePrefix());
lore.addAll(options.getLoreSuffix());
}
}
if (this.getOptions().isAboveLore()) {
lore.addAll(itemLore);
} else {
lore.addAll(0, itemLore);
}
lore.addAll(requirementLore);
if (!lore.isEmpty()) {
fastItemStack.setLore(lore);
}
if (itemStack.getType() == Material.ENCHANTED_BOOK) {
fastItemStack.addItemFlags(ItemFlag.HIDE_ENCHANTS, ItemFlag.HIDE_POTION_EFFECTS);
} else {
fastItemStack.addItemFlags(ItemFlag.HIDE_ENCHANTS);
}
if (itemStack.getType() == Material.ENCHANTED_BOOK) {
fastItemStack.addItemFlags(ItemFlag.HIDE_POTION_EFFECTS);
}
}
@Override
public void revert(@NotNull final ItemStack itemStack) {
if (options.isRequireTarget()) {
if (!EnchantmentTarget.ALL.getMaterials().contains(itemStack.getType())) {
return;
}
}
FastItemStack fastItemStack = FastItemStack.wrap(itemStack);
PersistentDataContainer pdc = fastItemStack.getPersistentDataContainer();
// Fixes weird bug. Apparently nullable.
//noinspection ConstantConditions
if (pdc == null) {
return;
}
pdc.remove(legacyV);
if (!pdc.has(keySkip, PersistentDataType.INTEGER)) {
fastItemStack.removeItemFlags(ItemFlag.HIDE_POTION_EFFECTS);
fastItemStack.removeItemFlags(ItemFlag.HIDE_ENCHANTS);
}
pdc.remove(keySkip);
}
@Override
public Object[] generateVarArgs(@NotNull final ItemStack itemStack) {
if (options.isRequireTarget()) {
if (!EnchantmentTarget.ALL.getMaterials().contains(itemStack.getType())) {
return new Object[]{false};
}
}
FastItemStack fastItemStack = FastItemStack.wrap(itemStack);
if (!itemStack.hasItemMeta()) {
return new Object[]{false};
}
boolean hideEnchants = fastItemStack.hasItemFlag(ItemFlag.HIDE_ENCHANTS) || fastItemStack.hasItemFlag(ItemFlag.HIDE_POTION_EFFECTS);
if (fastItemStack.getPersistentDataContainer().has(legacyV, PersistentDataType.INTEGER)) {
hideEnchants = false;
}
if (Display.isFinalized(itemStack)) {
hideEnchants = false;
}
if (ItemConversionOptions.isUsingExperimentalHideFixer() && ItemConversionOptions.isUsingForceHideFixer()) {
hideEnchants = false;
}
if (ItemConversionOptions.isUsingExperimentalHideFixer() && fastItemStack.hasItemFlag(ItemFlag.HIDE_ENCHANTS) && fastItemStack.hasItemFlag(ItemFlag.HIDE_POTION_EFFECTS)) {
hideEnchants = false;
}
return new Object[]{hideEnchants};
}
}

View File

@ -1,405 +0,0 @@
package com.willfp.ecoenchants.display;
import com.google.common.collect.ImmutableMap;
import com.willfp.eco.core.config.updating.ConfigUpdater;
import com.willfp.eco.core.display.Display;
import com.willfp.eco.util.NumberUtils;
import com.willfp.eco.util.StringUtils;
import com.willfp.ecoenchants.EcoEnchantsPlugin;
import com.willfp.ecoenchants.display.options.NumbersOptions;
import com.willfp.ecoenchants.enchantments.EcoEnchant;
import com.willfp.ecoenchants.enchantments.meta.EnchantmentRarity;
import com.willfp.ecoenchants.enchantments.meta.EnchantmentType;
import lombok.Getter;
import lombok.ToString;
import lombok.experimental.UtilityClass;
import org.apache.commons.lang.WordUtils;
import org.bukkit.Bukkit;
import org.bukkit.NamespacedKey;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.enchantments.EnchantmentWrapper;
import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import javax.swing.JProgressBar;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@UtilityClass
public class EnchantmentCache {
/**
* Instance of EcoEnchants.
*/
public static final EcoEnchantsPlugin PLUGIN = EcoEnchantsPlugin.getInstance();
/**
* The physical cache.
*/
private static final Map<NamespacedKey, CacheEntry> CACHE = new HashMap<>();
/**
* Get the {@link CacheEntry} for a specific enchantment.
* <p>
* Returns a default "broken" cache entry if not cached.
*
* @param enchantment The enchantment to query.
* @return The found cache entry.
*/
public static CacheEntry getEntry(@NotNull final Enchantment enchantment) {
CacheEntry matching = CACHE.get(enchantment.getKey());
if (matching != null) {
return matching;
} else {
updateEnchantment(enchantment);
Bukkit.getLogger().warning(enchantment.getKey() + " (from class " + enchantment.getClass() + ") was not cached! Trying to fix...");
return getEntry(enchantment);
}
}
/**
* Get the entire cache.
*
* @return An immutable map of the cache.
*/
public static Map<NamespacedKey, CacheEntry> getCache() {
return ImmutableMap.copyOf(CACHE);
}
/**
* Update the cache.
*/
@ConfigUpdater
public static void update() {
CACHE.clear();
Arrays.asList(Enchantment.values()).forEach(EnchantmentCache::updateEnchantment);
}
private static void updateEnchantment(@NotNull final Enchantment enchantment) {
CACHE.remove(enchantment.getKey());
if (enchantment instanceof EnchantmentWrapper) {
Bukkit.getLogger().severe("Found erroneous enchantment registration!");
Bukkit.getLogger().severe("Enchantment " + enchantment.getKey()
+ " (Found in class " + enchantment.getClass().getName() + ", Path: " + enchantment.getClass().getProtectionDomain().getCodeSource().getLocation().getPath() + ")"
);
Bukkit.getLogger().severe("Tell the author to lean how enchantments are stored internally.");
Bukkit.getLogger().severe("Hint: Extend Enchantment instead of EnchantmentWrapper.");
CACHE.put(enchantment.getKey(), new CacheEntry(
enchantment,
"&4INVALID ENCHANTMENT",
new HashMap<>(Map.of(1, Collections.singletonList(Display.PREFIX + "INVALID ENCHANTMENT: " + enchantment.getClass().getName()))),
EnchantmentType.NORMAL,
EnchantmentRarity.getByName(PLUGIN.getConfigYml().getString("rarity.vanilla-rarity")),
"&7"
));
return;
}
String name;
String color;
EnchantmentType type;
EnchantmentRarity rarity;
List<String> description;
if (enchantment instanceof EcoEnchant ecoEnchant) {
description = StringUtils.formatList(ecoEnchant.getWrappedDescription());
name = ecoEnchant.getDisplayName();
type = ecoEnchant.getType();
rarity = ecoEnchant.getEnchantmentRarity();
} else {
description = Arrays.asList(
WordUtils.wrap(
PLUGIN.getLangYml().getString("enchantments." + enchantment.getKey().getKey().toLowerCase() + ".description"),
PLUGIN.getConfigYml().getInt("lore.describe.wrap"),
"\n", false
).split("\\r?\\n")
);
name = PLUGIN.getLangYml().getString("enchantments." + enchantment.getKey().getKey().toLowerCase() + ".name");
type = enchantment.isCursed() ? EnchantmentType.CURSE : EnchantmentType.NORMAL;
if (enchantment.isTreasure()) {
rarity = EnchantmentRarity.getByName(PLUGIN.getConfigYml().getString("rarity.vanilla-treasure-rarity"));
} else {
rarity = EnchantmentRarity.getByName(PLUGIN.getConfigYml().getString("rarity.vanilla-rarity"));
}
}
color = type.getColor();
if (rarity == null) {
rarity = EnchantmentRarity.getByName(PLUGIN.getConfigYml().getString("rarity.vanilla-rarity"));
}
if (rarity.hasCustomColor() && type != EnchantmentType.CURSE) {
color = rarity.getCustomColor();
}
description.replaceAll(line -> line.replace("§r", "§r" + PLUGIN.getDisplayModule().getOptions().getDescriptionOptions().getColor()));
description.replaceAll(line -> line.replace("&r", "&r" + PLUGIN.getDisplayModule().getOptions().getDescriptionOptions().getColor()));
description.replaceAll(line -> Display.PREFIX + PLUGIN.getDisplayModule().getOptions().getDescriptionOptions().getColor() + line);
Map<Integer, List<String>> levelDescription = new HashMap<>();
if (enchantment instanceof EcoEnchant ecoEnchant) {
for (int i = 1; i <= ecoEnchant.getMaxLevel(); i++) {
List<String> levelDesc = new ArrayList<>();
for (String s : description) {
levelDesc.add(s.replace("%value%", ecoEnchant.getPlaceholder(i)));
}
levelDescription.put(
i,
levelDesc
);
}
} else {
for (int i = 1; i <= enchantment.getMaxLevel(); i++) {
levelDescription.put(i, description);
}
}
CACHE.put(enchantment.getKey(), new CacheEntry(enchantment, name, levelDescription, type, rarity, color));
}
@ToString
public static final class CacheEntry {
/**
* The enchantment that this cache is for.
*/
@Getter
private final Enchantment enchantment;
/**
* The name of the enchantment.
*/
private final String name;
/**
* The default color of the enchantment.
*/
@Getter
private final String color;
/**
* The description, line-wrapped.
*/
private final Map<Integer, List<String>> description;
/**
* The description, not line-wrapped or colorized.
*/
private final Map<Integer, String> stringDescription;
/**
* The type of the enchantment.
*/
@Getter
private final EnchantmentType type;
/**
* The requirement lore.
*/
@Getter
private final List<String> requirementLore;
/**
* The rarity of the enchantment.
*/
@Getter
private final EnchantmentRarity rarity;
private CacheEntry(@NotNull final Enchantment enchantment,
@NotNull final String name,
@NotNull final Map<Integer, List<String>> description,
@NotNull final EnchantmentType type,
@NotNull final EnchantmentRarity rarity,
@NotNull final String color) {
this.enchantment = enchantment;
this.name = name;
this.description = description;
this.type = type;
this.rarity = rarity;
this.color = color;
this.stringDescription = new HashMap<>();
this.requirementLore = new ArrayList<>();
if (enchantment instanceof EcoEnchant ecoEnchant) {
for (String s : ecoEnchant.getRequirementLore()) {
requirementLore.add(Display.PREFIX + s);
}
}
for (Integer level : description.keySet()) {
StringBuilder descriptionBuilder = new StringBuilder();
for (String s : description.get(level)) {
descriptionBuilder.append(s);
descriptionBuilder.append(" ");
}
String processedStringDescription = descriptionBuilder.toString();
processedStringDescription = processedStringDescription.replace(Display.PREFIX, "");
stringDescription.put(level, processedStringDescription.replaceAll(PLUGIN.getDisplayModule().getOptions().getDescriptionOptions().getColor(), ""));
}
}
/**
* Get the name with the level.
*
* @param level The level.
* @return The name with the level.
*/
public String getNameWithLevel(final int level) {
return getNameWithLevel(level, null);
}
/**
* Get enchantment with level.
*
* @param level The level.
* @param player The player.
* @return The name with the level.
*/
public String getNameWithLevel(final int level,
@Nullable final Player player) {
StringBuilder builder = new StringBuilder();
builder.append(name);
if (enchantment instanceof EcoEnchant enchant && player != null) {
if (!enchant.areRequirementsMet(player)) {
builder.insert(0, PLUGIN.getDisplayModule().getOptions().getRequirementsOptions().getRequirementColor());
}
}
if (!(enchantment.getMaxLevel() == 1 && level == 1) && level != 0) {
StringBuilder numberString = new StringBuilder();
numberString.append(" ");
NumbersOptions numbersOptions = PLUGIN.getDisplayModule().getOptions().getNumbersOptions();
if (numbersOptions.isUseNumerals() && level < numbersOptions.getThreshold()) {
numberString.append(NumberUtils.toNumeral(level));
} else {
numberString.append(level);
}
if (level > enchantment.getMaxLevel() && PLUGIN.getDisplayModule().getOptions().getMaxLevelOptions().isReformatAboveMaxLevel()) {
if (PLUGIN.getDisplayModule().getOptions().getMaxLevelOptions().isNumbersOnly()) {
String aboveMaxLevel = PLUGIN.getDisplayModule().getOptions().getMaxLevelOptions().getAboveMaxLevelFormat();
builder.append(aboveMaxLevel)
.append(numberString);
} else {
String aboveMaxLevel = PLUGIN.getDisplayModule().getOptions().getMaxLevelOptions().getAboveMaxLevelFormat();
builder.append(aboveMaxLevel)
.append(numberString);
}
} else {
builder.append(numberString);
}
}
builder.insert(0, color);
return StringUtils.format(builder.toString(), StringUtils.FormatOption.WITHOUT_PLACEHOLDERS);
}
/**
* Get the description of an enchantment at a certain level.
*
* @param level The level.
* @return The description, wrapped and formatted.
*/
public List<String> getDescription(final int level) {
List<String> description = this.description.get(level);
if (description == null) {
if (enchantment instanceof EcoEnchant enchant) {
List<String> levelDesc = new ArrayList<>();
List<String> defDesc = enchant.getWrappedDescription();
defDesc.replaceAll(line -> line.replace("&r", "&r" + PLUGIN.getDisplayModule().getOptions().getDescriptionOptions().getColor()));
defDesc.replaceAll(line -> Display.PREFIX + PLUGIN.getDisplayModule().getOptions().getDescriptionOptions().getColor() + line);
for (String s : defDesc) {
levelDesc.add(s.replace("%value%", enchant.getPlaceholder(level)));
}
this.description.put(
level,
StringUtils.formatList(levelDesc)
);
} else {
List<String> baseDesc = this.description.get(1);
this.description.put(level, baseDesc);
return baseDesc;
}
return getDescription(level);
} else {
return description;
}
}
/**
* Get the description of an enchantment at a certain level.
*
* @param level The level.
* @return The description, unwrapped and unformatted.
*/
public String getStringDescription(final int level) {
String stringDesc = this.stringDescription.get(level);
if (stringDesc == null) {
StringBuilder descriptionBuilder = new StringBuilder();
for (String s : description.get(level)) {
descriptionBuilder.append(s);
descriptionBuilder.append(" ");
}
String processedStringDescription = descriptionBuilder.toString();
processedStringDescription = processedStringDescription.replace(Display.PREFIX, "");
stringDescription.put(level, processedStringDescription.replaceAll(PLUGIN.getDisplayModule().getOptions().getDescriptionOptions().getColor(), ""));
return getStringDescription(level);
} else {
return stringDesc;
}
}
/**
* Get the description of an enchantment at level 1.
*
* @return The description, wrapped and formatted.
*/
@Deprecated
public List<String> getDescription() {
return getDescription(1);
}
/**
* Get the description of an enchantment at level 1.
*
* @return The description, unwrapped and unformatted.
*/
@Deprecated
public String getStringDescription() {
return getStringDescription(1);
}
/**
* Get the unformatted name of the enchantment.
*
* @return The raw name.
*/
public String getRawName() {
return name;
}
/**
* Get the formatted name of the enchantment.
*
* @return The name.
*/
public String getName() {
return getNameWithLevel(0);
}
}
}

View File

@ -1,76 +0,0 @@
package com.willfp.ecoenchants.display.options;
import com.willfp.eco.core.EcoPlugin;
import com.willfp.eco.core.PluginDependent;
import com.willfp.eco.core.data.PlayerProfile;
import com.willfp.ecoenchants.command.CommandToggleDescriptions;
import lombok.Getter;
import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
public class DescriptionOptions extends PluginDependent<EcoPlugin> {
/**
* The threshold below which to describe enchantments.
*/
@Getter
private int threshold;
/**
* If the options are enabled.
*/
@Getter
private boolean enabled;
/**
* The description lines color.
*/
@Getter
private String color;
/**
* If enchantment descriptions should be at the bottom of the enchantment lore rather than under each enchantment.
*/
@Getter
private boolean showingAtBottom;
/**
* If descriptions should only be shown on books.
*/
@Getter
private boolean onlyOnBooks;
/**
* Create new description options.
*
* @param plugin EcoEnchants.
*/
public DescriptionOptions(@NotNull final EcoPlugin plugin) {
super(plugin);
}
/**
* Update the options.
*/
public void update() {
threshold = this.getPlugin().getConfigYml().getInt("lore.describe.before-lines");
enabled = this.getPlugin().getConfigYml().getBool("lore.describe.enabled");
color = this.getPlugin().getLangYml().getFormattedString("description-color");
showingAtBottom = this.getPlugin().getConfigYml().getBool("lore.describe.at-bottom");
onlyOnBooks = this.getPlugin().getConfigYml().getBool("lore.describe.only-on-books");
}
/**
* Get if descriptions are enabled for a player.
*
* @param player The player.
* @return If enabled.
*/
public boolean enabledForPlayer(@Nullable final Player player) {
if (player == null) {
return true;
}
return PlayerProfile.load(player).read(CommandToggleDescriptions.DESCRIPTIONS_KEY);
}
}

View File

@ -1,150 +0,0 @@
package com.willfp.ecoenchants.display.options;
import com.willfp.eco.core.EcoPlugin;
import com.willfp.eco.core.PluginDependent;
import com.willfp.eco.core.display.Display;
import com.willfp.ecoenchants.display.options.sorting.EnchantmentSorter;
import com.willfp.ecoenchants.display.options.sorting.SortParameters;
import com.willfp.ecoenchants.display.options.sorting.SorterManager;
import com.willfp.ecoenchants.enchantments.meta.EnchantmentRarity;
import com.willfp.ecoenchants.enchantments.meta.EnchantmentType;
import lombok.Getter;
import org.jetbrains.annotations.ApiStatus;
import org.jetbrains.annotations.NotNull;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Objects;
import java.util.Set;
import java.util.stream.Collectors;
public class DisplayOptions extends PluginDependent<EcoPlugin> {
/**
* The description options being used.
*/
@Getter
private final DescriptionOptions descriptionOptions = new DescriptionOptions(this.getPlugin());
/**
* The enchantment level options being used.
*/
@Getter
private final NumbersOptions numbersOptions = new NumbersOptions(this.getPlugin());
/**
* The shrink options being used.
*/
@Getter
private final ShrinkOptions shrinkOptions = new ShrinkOptions(this.getPlugin());
/**
* The max level options being used.
*/
@Getter
private final MaxLevelOptions maxLevelOptions = new MaxLevelOptions(this.getPlugin());
/**
* The requirements options being used.
*/
@Getter
private final RequirementsOptions requirementsOptions = new RequirementsOptions(this.getPlugin());
/**
* The enchantment types, sorted according to config.
*/
@Getter
private final List<EnchantmentType> sortedTypes = new ArrayList<>();
/**
* The enchantment rarities, sorted according to config.
*/
@Getter
private final List<EnchantmentRarity> sortedRarities = new ArrayList<>();
/**
* The enchantment sorter being used.
*/
@Getter
private EnchantmentSorter sorter;
/**
* If item must be a target.
*/
@Getter
private boolean requireTarget = true;
/**
* If enchants should be displayed above lore.
*/
@Getter
private boolean aboveLore = true;
/**
* Lore prefix (above enchantments).
*/
@Getter
private List<String> lorePrefix;
/**
* Lore suffix (below enchantments).
*/
@Getter
private List<String> loreSuffix;
/**
* If prefix/suffix should show on books.
*/
@Getter
private boolean prefixOnBooks;
/**
* Instantiate new display options.
*
* @param plugin EcoEnchants.
*/
@ApiStatus.Internal
public DisplayOptions(@NotNull final EcoPlugin plugin) {
super(plugin);
update();
}
/**
* Update all options.
*/
public void update() {
descriptionOptions.update();
numbersOptions.update();
shrinkOptions.update();
maxLevelOptions.update();
requirementsOptions.update();
sortedTypes.clear();
sortedTypes.addAll(this.getPlugin().getConfigYml().getStrings("lore.type-ordering").stream()
.map(typeName -> EnchantmentType.values().stream().filter(type -> type.getName().equalsIgnoreCase(typeName)).findFirst().orElse(null))
.filter(Objects::nonNull).toList());
sortedTypes.addAll(EnchantmentType.values().stream().filter(enchantmentType -> !sortedTypes.contains(enchantmentType)).toList());
sortedRarities.clear();
sortedRarities.addAll(this.getPlugin().getConfigYml().getStrings("lore.rarity-ordering").stream()
.map(rarityName -> EnchantmentRarity.values().stream().filter(rarity -> rarity.getName().equalsIgnoreCase(rarityName)).findFirst().orElse(null))
.filter(Objects::nonNull).toList());
sortedRarities.addAll(EnchantmentRarity.values().stream().filter(enchantmentRarity -> !sortedRarities.contains(enchantmentRarity)).toList());
requireTarget = this.getPlugin().getConfigYml().getBool("lore.require-target");
aboveLore = this.getPlugin().getConfigYml().getBool("lore.above-other-lore");
lorePrefix = this.getPlugin().getConfigYml().getFormattedStrings("lore.prefix").stream().map(s -> Display.PREFIX + s).collect(Collectors.toList());
loreSuffix = this.getPlugin().getConfigYml().getFormattedStrings("lore.suffix").stream().map(s -> Display.PREFIX + s).collect(Collectors.toList());
prefixOnBooks = this.getPlugin().getConfigYml().getBool("lore.prefix-on-books");
boolean byType = this.getPlugin().getConfigYml().getBool("lore.sort-by-type");
boolean byLength = this.getPlugin().getConfigYml().getBool("lore.sort-by-length");
boolean byRarity = this.getPlugin().getConfigYml().getBool("lore.sort-by-rarity");
Set<SortParameters> params = new HashSet<>();
if (byType) {
params.add(SortParameters.TYPE);
}
if (byLength) {
params.add(SortParameters.LENGTH);
}
if (byRarity) {
params.add(SortParameters.RARITY);
}
sorter = SorterManager.getSorter(params.toArray(new SortParameters[]{}));
}
}

View File

@ -1,45 +0,0 @@
package com.willfp.ecoenchants.display.options;
import com.willfp.eco.core.EcoPlugin;
import com.willfp.eco.core.PluginDependent;
import lombok.Getter;
import org.jetbrains.annotations.NotNull;
public class MaxLevelOptions extends PluginDependent<EcoPlugin> {
/**
* If enchantments should have a different format above max level.
*/
@Getter
private boolean reformatAboveMaxLevel;
/**
* The above max level format.
*/
@Getter
private String aboveMaxLevelFormat;
/**
* If only the numbers should be formatted.
*/
@Getter
private boolean numbersOnly;
/**
* Create new description options.
*
* @param plugin EcoEnchants.
*/
public MaxLevelOptions(@NotNull final EcoPlugin plugin) {
super(plugin);
}
/**
* Update the options.
*/
public void update() {
reformatAboveMaxLevel = this.getPlugin().getConfigYml().getBool("lore.above-max-level.reformat");
numbersOnly = this.getPlugin().getConfigYml().getBool("lore.above-max-level.numbers-only");
aboveMaxLevelFormat = this.getPlugin().getLangYml().getString("above-max-level-color");
}
}

View File

@ -1,39 +0,0 @@
package com.willfp.ecoenchants.display.options;
import com.willfp.eco.core.EcoPlugin;
import com.willfp.eco.core.PluginDependent;
import lombok.Getter;
import org.jetbrains.annotations.NotNull;
public class NumbersOptions extends PluginDependent<EcoPlugin> {
/**
* If numerals should be used.
* <p>
* If false then numbers will be used instead.
*/
@Getter
private boolean useNumerals;
/**
* The threshold above which numbers will be used instead.
*/
@Getter
private int threshold;
/**
* Create new numbers options.
*
* @param plugin EcoEnchants.
*/
public NumbersOptions(@NotNull final EcoPlugin plugin) {
super(plugin);
}
/**
* Update the options.
*/
public void update() {
useNumerals = this.getPlugin().getConfigYml().getBool("lore.use-numerals");
threshold = this.getPlugin().getConfigYml().getInt("lore.use-numbers-above-threshold");
}
}

View File

@ -1,32 +0,0 @@
package com.willfp.ecoenchants.display.options;
import com.willfp.eco.core.EcoPlugin;
import com.willfp.eco.core.PluginDependent;
import lombok.Getter;
import org.jetbrains.annotations.NotNull;
public class RequirementsOptions extends PluginDependent<EcoPlugin> {
/**
* If numerals should be used.
* <p>
* If false then numbers will be used instead.
*/
@Getter
private String requirementColor;
/**
* Create new numbers options.
*
* @param plugin EcoEnchants.
*/
public RequirementsOptions(@NotNull final EcoPlugin plugin) {
super(plugin);
}
/**
* Update the options.
*/
public void update() {
requirementColor = this.getPlugin().getLangYml().getString("missing-requirements-format");
}
}

View File

@ -1,44 +0,0 @@
package com.willfp.ecoenchants.display.options;
import com.willfp.eco.core.EcoPlugin;
import com.willfp.eco.core.PluginDependent;
import lombok.Getter;
import org.jetbrains.annotations.NotNull;
public class ShrinkOptions extends PluginDependent<EcoPlugin> {
/**
* The threshold above which enchantments will be shrunk.
*/
@Getter
private int threshold;
/**
* If shrinking is enabled.
*/
@Getter
private boolean enabled;
/**
* The amount of enchantments to have per-line.
*/
@Getter
private int shrinkPerLine;
/**
* Create new shrink options.
*
* @param plugin EcoEnchants.
*/
public ShrinkOptions(@NotNull final EcoPlugin plugin) {
super(plugin);
}
/**
* Update the options.
*/
public void update() {
threshold = this.getPlugin().getConfigYml().getInt("lore.shrink.after-lines");
enabled = this.getPlugin().getConfigYml().getBool("lore.shrink.enabled");
shrinkPerLine = this.getPlugin().getConfigYml().getInt("lore.shrink.maximum-per-line");
}
}

View File

@ -1,24 +0,0 @@
package com.willfp.ecoenchants.display.options.sorting;
import org.bukkit.enchantments.Enchantment;
import org.jetbrains.annotations.NotNull;
import java.util.List;
public interface EnchantmentSorter {
/**
* Sort list of enchantments.
* <p>
* All implementations must treat enchantments as final or effectively final.
*
* @param toSort The enchantments to sort.
*/
void sortEnchantments(@NotNull List<Enchantment> toSort);
/**
* Get the parameters that the sorter fulfills.
*
* @return Array of all parameters.
*/
SortParameters[] getParameters();
}

View File

@ -1,18 +0,0 @@
package com.willfp.ecoenchants.display.options.sorting;
public enum SortParameters {
/**
* If the sorter should sort by type or if type should be ignored.
*/
TYPE,
/**
* If the sorter should sort by rarity or if rarity should be ignored.
*/
RARITY,
/**
* If the sorter should sort by length or alphabetically.
*/
LENGTH
}

View File

@ -1,52 +0,0 @@
package com.willfp.ecoenchants.display.options.sorting;
import com.willfp.ecoenchants.EcoEnchantsPlugin;
import com.willfp.ecoenchants.display.options.sorting.implementations.AlphabeticSorter;
import com.willfp.ecoenchants.display.options.sorting.implementations.LengthSorter;
import com.willfp.ecoenchants.display.options.sorting.implementations.RarityAlphabeticSorter;
import com.willfp.ecoenchants.display.options.sorting.implementations.RarityLengthSorter;
import com.willfp.ecoenchants.display.options.sorting.implementations.RarityTypeAlphabeticSorter;
import com.willfp.ecoenchants.display.options.sorting.implementations.RarityTypeLengthSorter;
import com.willfp.ecoenchants.display.options.sorting.implementations.TypeAlphabeticSorter;
import com.willfp.ecoenchants.display.options.sorting.implementations.TypeLengthSorter;
import lombok.experimental.UtilityClass;
import org.jetbrains.annotations.NotNull;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;
@UtilityClass
public class SorterManager {
/**
* All registered enchantment sorters.
*/
private static final Set<EnchantmentSorter> REGISTERED = new HashSet<>();
static {
EcoEnchantsPlugin instance = EcoEnchantsPlugin.getInstance(); // Really dirty and janky.
REGISTERED.add(new AlphabeticSorter(instance));
REGISTERED.add(new LengthSorter(instance));
REGISTERED.add(new TypeAlphabeticSorter(instance));
REGISTERED.add(new TypeLengthSorter(instance));
REGISTERED.add(new RarityAlphabeticSorter(instance));
REGISTERED.add(new RarityLengthSorter(instance));
REGISTERED.add(new RarityTypeAlphabeticSorter(instance));
REGISTERED.add(new RarityTypeLengthSorter(instance));
}
/**
* Get a sorter based off of parameters.
* <p>
* Any combination of parameters is valid.
*
* @param parameters The parameters to find a sorter from.
* @return The matching sorter.
*/
public static EnchantmentSorter getSorter(@NotNull final SortParameters... parameters) {
return REGISTERED.stream()
.filter(enchantmentSorter -> Arrays.asList(enchantmentSorter.getParameters()).containsAll(Arrays.asList(parameters)) && enchantmentSorter.getParameters().length == parameters.length)
.findFirst()
.orElse(new AlphabeticSorter(EcoEnchantsPlugin.getInstance()));
}
}

View File

@ -1,32 +0,0 @@
package com.willfp.ecoenchants.display.options.sorting.implementations;
import com.willfp.eco.core.PluginDependent;
import com.willfp.ecoenchants.EcoEnchantsPlugin;
import com.willfp.ecoenchants.display.EnchantmentCache;
import com.willfp.ecoenchants.display.options.sorting.EnchantmentSorter;
import com.willfp.ecoenchants.display.options.sorting.SortParameters;
import org.bukkit.enchantments.Enchantment;
import org.jetbrains.annotations.NotNull;
import java.util.List;
public class AlphabeticSorter extends PluginDependent<EcoEnchantsPlugin> implements EnchantmentSorter {
/**
* Instantiate sorter.
*
* @param plugin Instance of EcoEnchants.
*/
public AlphabeticSorter(@NotNull final EcoEnchantsPlugin plugin) {
super(plugin);
}
@Override
public void sortEnchantments(@NotNull final List<Enchantment> toSort) {
toSort.sort(((enchantment1, enchantment2) -> EnchantmentCache.getEntry(enchantment1).getRawName().compareToIgnoreCase(EnchantmentCache.getEntry(enchantment2).getRawName())));
}
@Override
public SortParameters[] getParameters() {
return new SortParameters[0];
}
}

View File

@ -1,33 +0,0 @@
package com.willfp.ecoenchants.display.options.sorting.implementations;
import com.willfp.eco.core.PluginDependent;
import com.willfp.ecoenchants.EcoEnchantsPlugin;
import com.willfp.ecoenchants.display.EnchantmentCache;
import com.willfp.ecoenchants.display.options.sorting.EnchantmentSorter;
import com.willfp.ecoenchants.display.options.sorting.SortParameters;
import org.bukkit.enchantments.Enchantment;
import org.jetbrains.annotations.NotNull;
import java.util.Comparator;
import java.util.List;
public class LengthSorter extends PluginDependent<EcoEnchantsPlugin> implements EnchantmentSorter {
/**
* Instantiate sorter.
*
* @param plugin Instance of EcoEnchants.
*/
public LengthSorter(@NotNull final EcoEnchantsPlugin plugin) {
super(plugin);
}
@Override
public void sortEnchantments(@NotNull final List<Enchantment> toSort) {
toSort.sort(Comparator.comparingInt(enchantment -> EnchantmentCache.getEntry(enchantment).getRawName().length()));
}
@Override
public SortParameters[] getParameters() {
return new SortParameters[]{SortParameters.LENGTH};
}
}

View File

@ -1,52 +0,0 @@
package com.willfp.ecoenchants.display.options.sorting.implementations;
import com.willfp.eco.core.PluginDependent;
import com.willfp.ecoenchants.EcoEnchantsPlugin;
import com.willfp.ecoenchants.display.EnchantmentCache;
import com.willfp.ecoenchants.display.options.sorting.EnchantmentSorter;
import com.willfp.ecoenchants.display.options.sorting.SortParameters;
import org.bukkit.enchantments.Enchantment;
import org.jetbrains.annotations.NotNull;
import java.util.ArrayList;
import java.util.List;
public class RarityAlphabeticSorter extends PluginDependent<EcoEnchantsPlugin> implements EnchantmentSorter {
/**
* Instantiate sorter.
*
* @param plugin Instance of EcoEnchants.
*/
public RarityAlphabeticSorter(@NotNull final EcoEnchantsPlugin plugin) {
super(plugin);
}
@Override
public void sortEnchantments(@NotNull final List<Enchantment> toSort) {
if (this.getPlugin().getDisplayModule().getOptions().getSortedRarities().isEmpty()
|| this.getPlugin().getDisplayModule().getOptions().getSortedTypes().isEmpty()) {
this.getPlugin().getDisplayModule().update();
}
List<Enchantment> sorted = new ArrayList<>();
this.getPlugin().getDisplayModule().getOptions().getSortedRarities().forEach(enchantmentRarity -> {
List<Enchantment> rarityEnchants = new ArrayList<>();
for (Enchantment enchantment : toSort) {
if (EnchantmentCache.getEntry(enchantment).getRarity().equals(enchantmentRarity)) {
rarityEnchants.add(enchantment);
}
}
rarityEnchants.sort((enchantment1, enchantment2) -> EnchantmentCache.getEntry(enchantment1).getRawName().compareToIgnoreCase(EnchantmentCache.getEntry(enchantment2).getRawName()));
sorted.addAll(rarityEnchants);
});
toSort.clear();
toSort.addAll(sorted);
}
@Override
public SortParameters[] getParameters() {
return new SortParameters[]{SortParameters.RARITY};
}
}

View File

@ -1,52 +0,0 @@
package com.willfp.ecoenchants.display.options.sorting.implementations;
import com.willfp.eco.core.PluginDependent;
import com.willfp.ecoenchants.EcoEnchantsPlugin;
import com.willfp.ecoenchants.display.EnchantmentCache;
import com.willfp.ecoenchants.display.options.sorting.EnchantmentSorter;
import com.willfp.ecoenchants.display.options.sorting.SortParameters;
import org.bukkit.enchantments.Enchantment;
import org.jetbrains.annotations.NotNull;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
public class RarityLengthSorter extends PluginDependent<EcoEnchantsPlugin> implements EnchantmentSorter {
/**
* Instantiate sorter.
*
* @param plugin Instance of EcoEnchants.
*/
public RarityLengthSorter(@NotNull final EcoEnchantsPlugin plugin) {
super(plugin);
}
@Override
public void sortEnchantments(@NotNull final List<Enchantment> toSort) {
if (this.getPlugin().getDisplayModule().getOptions().getSortedRarities().isEmpty()
|| this.getPlugin().getDisplayModule().getOptions().getSortedTypes().isEmpty()) {
this.getPlugin().getDisplayModule().update();
}
List<Enchantment> sorted = new ArrayList<>();
this.getPlugin().getDisplayModule().getOptions().getSortedRarities().forEach(enchantmentRarity -> {
List<Enchantment> rarityEnchants = new ArrayList<>();
for (Enchantment enchantment : toSort) {
if (EnchantmentCache.getEntry(enchantment).getRarity().equals(enchantmentRarity)) {
rarityEnchants.add(enchantment);
}
}
rarityEnchants.sort(Comparator.comparingInt(enchantment -> EnchantmentCache.getEntry(enchantment).getRawName().length()));
sorted.addAll(rarityEnchants);
});
toSort.clear();
toSort.addAll(sorted);
}
@Override
public SortParameters[] getParameters() {
return new SortParameters[]{SortParameters.RARITY, SortParameters.LENGTH};
}
}

View File

@ -1,61 +0,0 @@
package com.willfp.ecoenchants.display.options.sorting.implementations;
import com.willfp.eco.core.PluginDependent;
import com.willfp.ecoenchants.EcoEnchantsPlugin;
import com.willfp.ecoenchants.display.EnchantmentCache;
import com.willfp.ecoenchants.display.options.sorting.EnchantmentSorter;
import com.willfp.ecoenchants.display.options.sorting.SortParameters;
import org.bukkit.enchantments.Enchantment;
import org.jetbrains.annotations.NotNull;
import java.util.ArrayList;
import java.util.List;
public class RarityTypeAlphabeticSorter extends PluginDependent<EcoEnchantsPlugin> implements EnchantmentSorter {
/**
* Instantiate sorter.
*
* @param plugin Instance of EcoEnchants.
*/
public RarityTypeAlphabeticSorter(@NotNull final EcoEnchantsPlugin plugin) {
super(plugin);
}
@Override
public void sortEnchantments(@NotNull final List<Enchantment> toSort) {
if (this.getPlugin().getDisplayModule().getOptions().getSortedRarities().isEmpty()
|| this.getPlugin().getDisplayModule().getOptions().getSortedTypes().isEmpty()) {
this.getPlugin().getDisplayModule().update();
}
List<Enchantment> sorted = new ArrayList<>();
this.getPlugin().getDisplayModule().getOptions().getSortedTypes().forEach(enchantmentType -> {
List<Enchantment> typeEnchants = new ArrayList<>();
for (Enchantment enchantment : toSort) {
if (EnchantmentCache.getEntry(enchantment).getType().equals(enchantmentType)) {
typeEnchants.add(enchantment);
}
}
typeEnchants.sort((enchantment1, enchantment2) -> EnchantmentCache.getEntry(enchantment1).getRawName().compareToIgnoreCase(EnchantmentCache.getEntry(enchantment2).getRawName()));
this.getPlugin().getDisplayModule().getOptions().getSortedRarities().forEach(enchantmentRarity -> {
List<Enchantment> rarityEnchants = new ArrayList<>();
for (Enchantment enchantment : typeEnchants) {
if (EnchantmentCache.getEntry(enchantment).getRarity().equals(enchantmentRarity)) {
rarityEnchants.add(enchantment);
}
}
rarityEnchants.sort((enchantment1, enchantment2) -> EnchantmentCache.getEntry(enchantment1).getRawName().compareToIgnoreCase(EnchantmentCache.getEntry(enchantment2).getRawName()));
sorted.addAll(rarityEnchants);
});
});
toSort.clear();
toSort.addAll(sorted);
}
@Override
public SortParameters[] getParameters() {
return new SortParameters[]{SortParameters.RARITY, SortParameters.TYPE};
}
}

View File

@ -1,63 +0,0 @@
package com.willfp.ecoenchants.display.options.sorting.implementations;
import com.willfp.eco.core.PluginDependent;
import com.willfp.ecoenchants.EcoEnchantsPlugin;
import com.willfp.ecoenchants.display.EnchantmentCache;
import com.willfp.ecoenchants.display.options.sorting.EnchantmentSorter;
import com.willfp.ecoenchants.display.options.sorting.SortParameters;
import org.bukkit.enchantments.Enchantment;
import org.jetbrains.annotations.NotNull;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
public class RarityTypeLengthSorter extends PluginDependent<EcoEnchantsPlugin> implements EnchantmentSorter {
/**
* Instantiate sorter.
*
* @param plugin Instance of EcoEnchants.
*/
public RarityTypeLengthSorter(@NotNull final EcoEnchantsPlugin plugin) {
super(plugin);
}
@Override
public void sortEnchantments(@NotNull final List<Enchantment> toSort) {
if (this.getPlugin().getDisplayModule().getOptions().getSortedRarities().isEmpty()
|| this.getPlugin().getDisplayModule().getOptions().getSortedTypes().isEmpty()) {
this.getPlugin().getDisplayModule().update();
}
List<Enchantment> sorted = new ArrayList<>();
this.getPlugin().getDisplayModule().getOptions().getSortedTypes().forEach(enchantmentType -> {
List<Enchantment> typeEnchants = new ArrayList<>();
for (Enchantment enchantment : toSort) {
if (EnchantmentCache.getEntry(enchantment).getType().equals(enchantmentType)) {
typeEnchants.add(enchantment);
}
}
typeEnchants.sort(Comparator.comparingInt(enchantment -> EnchantmentCache.getEntry(enchantment).getRawName().length()));
this.getPlugin().getDisplayModule().getOptions().getSortedRarities().forEach(enchantmentRarity -> {
List<Enchantment> rarityEnchants = new ArrayList<>();
for (Enchantment enchantment : typeEnchants) {
if (EnchantmentCache.getEntry(enchantment).getRarity().equals(enchantmentRarity)) {
rarityEnchants.add(enchantment);
}
}
rarityEnchants.sort(Comparator.comparingInt(enchantment -> EnchantmentCache.getEntry(enchantment).getRawName().length()));
sorted.addAll(rarityEnchants);
});
});
toSort.clear();
toSort.addAll(sorted);
}
@Override
public SortParameters[] getParameters() {
return new SortParameters[]{SortParameters.RARITY, SortParameters.TYPE, SortParameters.LENGTH};
}
}

View File

@ -1,52 +0,0 @@
package com.willfp.ecoenchants.display.options.sorting.implementations;
import com.willfp.eco.core.PluginDependent;
import com.willfp.ecoenchants.EcoEnchantsPlugin;
import com.willfp.ecoenchants.display.EnchantmentCache;
import com.willfp.ecoenchants.display.options.sorting.EnchantmentSorter;
import com.willfp.ecoenchants.display.options.sorting.SortParameters;
import org.bukkit.enchantments.Enchantment;
import org.jetbrains.annotations.NotNull;
import java.util.ArrayList;
import java.util.List;
public class TypeAlphabeticSorter extends PluginDependent<EcoEnchantsPlugin> implements EnchantmentSorter {
/**
* Instantiate sorter.
*
* @param plugin Instance of EcoEnchants.
*/
public TypeAlphabeticSorter(@NotNull final EcoEnchantsPlugin plugin) {
super(plugin);
}
@Override
public void sortEnchantments(@NotNull final List<Enchantment> toSort) {
if (this.getPlugin().getDisplayModule().getOptions().getSortedRarities().isEmpty()
|| this.getPlugin().getDisplayModule().getOptions().getSortedTypes().isEmpty()) {
this.getPlugin().getDisplayModule().update();
}
List<Enchantment> sorted = new ArrayList<>();
this.getPlugin().getDisplayModule().getOptions().getSortedTypes().forEach(enchantmentType -> {
List<Enchantment> typeEnchants = new ArrayList<>();
for (Enchantment enchantment : toSort) {
if (EnchantmentCache.getEntry(enchantment).getType().equals(enchantmentType)) {
typeEnchants.add(enchantment);
}
}
typeEnchants.sort((enchantment1, enchantment2) -> EnchantmentCache.getEntry(enchantment1).getRawName().compareToIgnoreCase(EnchantmentCache.getEntry(enchantment2).getRawName()));
sorted.addAll(typeEnchants);
});
toSort.clear();
toSort.addAll(sorted);
}
@Override
public SortParameters[] getParameters() {
return new SortParameters[]{SortParameters.TYPE};
}
}

View File

@ -1,51 +0,0 @@
package com.willfp.ecoenchants.display.options.sorting.implementations;
import com.willfp.eco.core.PluginDependent;
import com.willfp.ecoenchants.EcoEnchantsPlugin;
import com.willfp.ecoenchants.display.EnchantmentCache;
import com.willfp.ecoenchants.display.options.sorting.EnchantmentSorter;
import com.willfp.ecoenchants.display.options.sorting.SortParameters;
import org.bukkit.enchantments.Enchantment;
import org.jetbrains.annotations.NotNull;
import java.util.ArrayList;
import java.util.List;
public class TypeLengthSorter extends PluginDependent<EcoEnchantsPlugin> implements EnchantmentSorter {
/**
* Instantiate sorter.
*
* @param plugin Instance of EcoEnchants.
*/
public TypeLengthSorter(@NotNull final EcoEnchantsPlugin plugin) {
super(plugin);
}
@Override
public void sortEnchantments(@NotNull final List<Enchantment> toSort) {
if (this.getPlugin().getDisplayModule().getOptions().getSortedRarities().isEmpty()
|| this.getPlugin().getDisplayModule().getOptions().getSortedTypes().isEmpty()) {
this.getPlugin().getDisplayModule().update();
}
List<Enchantment> sorted = new ArrayList<>();
this.getPlugin().getDisplayModule().getOptions().getSortedTypes().forEach(enchantmentType -> {
List<Enchantment> typeEnchants = new ArrayList<>();
for (Enchantment enchantment : toSort) {
if (EnchantmentCache.getEntry(enchantment).getType().equals(enchantmentType)) {
typeEnchants.add(enchantment);
}
}
sorted.addAll(typeEnchants);
});
toSort.clear();
toSort.addAll(sorted);
}
@Override
public SortParameters[] getParameters() {
return new SortParameters[]{SortParameters.TYPE, SortParameters.LENGTH};
}
}

View File

@ -1,597 +0,0 @@
package com.willfp.ecoenchants.enchantments;
import com.willfp.eco.core.Prerequisite;
import com.willfp.eco.core.config.interfaces.Config;
import com.willfp.eco.core.fast.FastItemStack;
import com.willfp.eco.util.StringUtils;
import com.willfp.ecoenchants.EcoEnchantsPlugin;
import com.willfp.ecoenchants.config.configs.BaseEnchantmentConfig;
import com.willfp.ecoenchants.config.configs.EnchantmentConfig;
import com.willfp.ecoenchants.display.EnchantmentCache;
import com.willfp.ecoenchants.enchantments.custom.CustomEcoEnchant;
import com.willfp.ecoenchants.enchantments.meta.EnchantmentRarity;
import com.willfp.ecoenchants.enchantments.meta.EnchantmentTarget;
import com.willfp.ecoenchants.enchantments.meta.EnchantmentType;
import com.willfp.ecoenchants.enchantments.util.EnchantmentUtils;
import com.willfp.ecoenchants.enchantments.util.Watcher;
import com.willfp.ecoenchants.enchantments.util.requirements.Requirement;
import com.willfp.ecoenchants.enchantments.util.requirements.Requirements;
import lombok.Getter;
import net.kyori.adventure.text.Component;
import org.apache.commons.lang.Validate;
import org.apache.commons.lang.WordUtils;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.NamespacedKey;
import org.bukkit.World;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.entity.EntityCategory;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.bukkit.event.Listener;
import org.bukkit.inventory.EquipmentSlot;
import org.bukkit.inventory.ItemStack;
import org.bukkit.permissions.Permission;
import org.bukkit.permissions.PermissionDefault;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Set;
import java.util.UUID;
@SuppressWarnings({"deprecation", "RedundantSuppression"})
public abstract class EcoEnchant extends Enchantment implements Listener, Watcher {
/**
* Instance of EcoEnchants for enchantments to be able to access.
*/
@Getter
private final EcoEnchantsPlugin plugin = EcoEnchantsPlugin.getInstance();
/**
* The permission/config name of the enchantment.
*/
@Getter
private final String permissionName;
/**
* The type of the enchantment.
*/
@Getter
private final EnchantmentType type;
/**
* The enchantment's config.
*/
@Getter
private final EnchantmentConfig config;
/**
* The targets of the enchantment.
*/
@Getter
private final Set<EnchantmentTarget> targets = new HashSet<>();
/**
* The materials of the targets.
*/
@Getter
private final Set<Material> targetMaterials = new HashSet<>();
/**
* The names of the worlds that this enchantment is disabled in.
*/
@Getter
private final Set<String> disabledWorldNames = new HashSet<>();
/**
* The worlds that this enchantment is disabled in.
*/
@Getter
private final List<World> disabledWorlds = new ArrayList<>();
/**
* The display name of the enchantment.
*/
@Getter
private String displayName;
/**
* The description of the enchantment.
*/
@Getter
private String description;
/**
* If the enchantment can be removed in a grindstone.
*/
@Getter
private boolean grindstoneable;
/**
* If the enchantment can be obtained from an enchanting table.
*/
@Getter
private boolean availableFromTable;
/**
* If the enchantment can be obtained from a villager.
*/
@Getter
private boolean availableFromVillager;
/**
* If the enchantment can be obtained from a loot chest.
*/
@Getter
private boolean availableFromLoot;
/**
* The maximum level for the enchantment to be obtained naturally.
*/
private int maxLevel;
/**
* The enchantments that conflict with this enchantment.
*/
@Getter
private Set<Enchantment> conflicts;
/**
* The rarity of the enchantment.
*/
@Getter
private EnchantmentRarity enchantmentRarity;
/**
* If the enchantment is enabled.
*/
private boolean enabled;
/**
* Custom option flags for the enchantment.
*/
private final List<String> flags = new ArrayList<>();
/**
* All the requirements needed in order to use the enchantment.
*/
private final Map<Requirement, List<String>> requirements = new HashMap<>();
/**
* Cached players to see if they meet requirements.
*/
private final Map<UUID, Boolean> cachedRequirements = new HashMap<>();
/**
* The requirement lore shown if the player doesn't meet the requirements.
*/
@Getter
private final List<String> requirementLore = new ArrayList<>();
protected EcoEnchant(@NotNull final String key,
@NotNull final EnchantmentType type,
@Nullable final Config overrideConfig,
@NotNull final Prerequisite... prerequisites) {
super(NamespacedKey.minecraft(key));
this.type = type;
this.permissionName = key.replace("_", "");
this.config = new EnchantmentConfig(
Objects.requireNonNullElseGet(overrideConfig, () -> new BaseEnchantmentConfig(
this.permissionName,
this.getClass(),
this,
this.getPlugin()
)),
this.permissionName,
this,
this.getPlugin()
);
if (Bukkit.getPluginManager().getPermission("ecoenchants.fromtable." + permissionName) == null) {
Permission permission = new Permission(
"ecoenchants.fromtable." + permissionName,
"Allows getting " + permissionName + " from an Enchanting Table",
PermissionDefault.TRUE
);
permission.addParent(Objects.requireNonNull(Bukkit.getPluginManager().getPermission("ecoenchants.fromtable.*")), true);
Bukkit.getPluginManager().addPermission(permission);
}
if (type.getRequiredToExtend() != null && !type.getRequiredToExtend().isInstance(this) && !(this instanceof CustomEcoEnchant)) {
return;
}
if (!Prerequisite.areMet(prerequisites)) {
return;
}
enabled = Objects.requireNonNullElse(config.getBoolOrNull("enabled"), true);
if (!this.isEnabled() && this.getPlugin().getConfigYml().getBool("advanced.hard-disable.enabled")) {
return;
}
this.update();
EcoEnchants.addNewEcoEnchant(this);
}
/**
* Create a new EcoEnchant.
*
* @param key The key name of the enchantment
* @param type The type of the enchantment
* @param prerequisites Optional {@link Prerequisite}s that must be met
*/
protected EcoEnchant(@NotNull final String key,
@NotNull final EnchantmentType type,
@NotNull final Prerequisite... prerequisites) {
this(key, type, null, prerequisites);
}
/**
* Update the enchantment based off config values.
* This can be overridden but may lead to unexpected behavior.
*/
public void update() {
config.loadFromLang();
enchantmentRarity = config.getRarity();
Validate.notNull(enchantmentRarity, "Rarity specified in " + this.permissionName + " is invalid!");
conflicts = config.getEnchantments(EcoEnchants.GENERAL_LOCATION + "conflicts");
grindstoneable = config.getBool(EcoEnchants.GENERAL_LOCATION + "grindstoneable");
availableFromTable = config.getBool(EcoEnchants.OBTAINING_LOCATION + "table");
availableFromVillager = config.getBool(EcoEnchants.OBTAINING_LOCATION + "villager");
availableFromLoot = config.getBool(EcoEnchants.OBTAINING_LOCATION + "loot");
maxLevel = config.getInt(EcoEnchants.GENERAL_LOCATION + "maximum-level", 1);
displayName = config.getFormattedString("name");
description = config.getString("description");
disabledWorldNames.clear();
disabledWorldNames.addAll(config.getStrings(EcoEnchants.GENERAL_LOCATION + "disabled-in-worlds"));
disabledWorlds.clear();
List<String> worldNames = new ArrayList<>();
for (World world : Bukkit.getWorlds()) {
worldNames.add(world.getName().toLowerCase());
}
List<String> disabledExistingWorldNames = disabledWorldNames.stream().filter(s -> worldNames.contains(s.toLowerCase())).toList();
disabledWorlds.addAll(Bukkit.getWorlds().stream().filter(world -> disabledExistingWorldNames.contains(world.getName().toLowerCase())).toList());
targets.clear();
targetMaterials.clear();
targets.addAll(config.getTargets());
targets.forEach(enchantmentTarget -> targetMaterials.addAll(enchantmentTarget.getMaterials()));
enabled = config.getBool("enabled");
flags.clear();
flags.addAll(config.getStrings(EcoEnchants.GENERAL_LOCATION + "flags"));
EnchantmentUtils.registerPlaceholders(this);
for (String req : config.getStrings(EcoEnchants.GENERAL_LOCATION + "requirements.list")) {
List<String> split = Arrays.asList(req.split(":"));
if (split.size() < 2) {
continue;
}
Requirement requirement = Requirements.getByID(split.get(0).toLowerCase());
this.requirements.put(requirement, split.subList(1, split.size()));
}
requirementLore.clear();
requirementLore.addAll(config.getStrings(EcoEnchants.GENERAL_LOCATION + "requirements.not-met-lore"));
postUpdate();
this.register();
this.clearCachedRequirements();
}
protected void postUpdate() {
// Unused as some enchantments may have postUpdate tasks, however most won't.
}
/**
* Register the enchantment with spigot.
* Only used internally.
*/
public void register() {
EnchantmentUtils.register(this);
}
/**
* Clear requirements cache.
*/
public void clearCachedRequirements() {
this.cachedRequirements.clear();
}
/**
* Format the %value% placeholder in description lore.
*
* @param level The level of the enchantment.
* @return The placeholder.
*/
public String getPlaceholder(final int level) {
return "unknown";
}
/**
* Does the player meet the requirements to use this enchantment.
*
* @param entity The entity.
* @return If the requirements are met.
*/
public boolean areRequirementsMet(@NotNull final LivingEntity entity) {
if (!(entity instanceof Player player)) {
return true;
}
if (cachedRequirements.containsKey(player.getUniqueId())) {
return cachedRequirements.get(player.getUniqueId());
}
for (Map.Entry<Requirement, List<String>> entry : requirements.entrySet()) {
if (!entry.getKey().isMetBy(player, entry.getValue())) {
cachedRequirements.put(player.getUniqueId(), false);
return false;
}
}
cachedRequirements.put(player.getUniqueId(), true);
return true;
}
/**
* Get description of enchantment line-wrapped.
*
* @return The description.
*/
public List<String> getWrappedDescription() {
return Arrays.asList(WordUtils.wrap(description, this.getPlugin().getConfigYml().getInt("lore.describe.wrap"), "\n", false).split("\\r?\\n"));
}
/**
* If enchantment conflicts with any enchantment in collection.
*
* @param enchantments The collection to test against.
* @return If there are any conflicts.
*/
public boolean conflictsWithAny(@NotNull final Collection<? extends Enchantment> enchantments) {
return conflicts.stream().anyMatch(enchantments::contains);
}
/**
* If enchantment has specified flag.
*
* @param flag The flag.
* @return If the enchantment has the flag.
*/
public boolean hasFlag(@NotNull final String flag) {
return this.flags.contains(flag);
}
/**
* If enchantment is enabled.
*
* @return If enabled.
*/
public boolean isEnabled() {
return enabled;
}
/**
* Get the internal name of the enchantment.
*
* @return The name.
* @deprecated Exists for parity.
*/
@NotNull
@Deprecated
public String getName() {
return this.getKey().getKey().toUpperCase();
}
/**
* Get max level of enchantment.
*
* @return The max level.
*/
@Override
public int getMaxLevel() {
return maxLevel;
}
/**
* @return 1
*/
@Override
public int getStartLevel() {
return 1;
}
/**
* Do not use this method.
* Only here for compatibility with {@link Enchantment}.
*
* @return Returns {@link EnchantmentTarget#ALL}. Do not use.
* @deprecated {@link EnchantmentTarget} is not supported due to its lack of flexibility. Use {@link EcoEnchant#getTargets()} instead.
*/
@Override
@Deprecated
public @NotNull org.bukkit.enchantments.EnchantmentTarget getItemTarget() {
return org.bukkit.enchantments.EnchantmentTarget.ALL;
}
/**
* Treasure enchantments do not exist in EcoEnchants.
*
* @return false.
* @see EnchantmentType#SPECIAL
* @deprecated Treasure enchantments do not exist. Use {@link EcoEnchant#getType()} instead.
*/
@Override
@Deprecated
public boolean isTreasure() {
return this.type.equals(EnchantmentType.SPECIAL);
}
/**
* While this method works, it is not recommended to use it.
*
* @return Returns if enchantment is cursed.
* @see EnchantmentType#CURSE
* @deprecated Use {@link EcoEnchant#getType()} instead.
*/
@Override
@Deprecated
public boolean isCursed() {
return this.type.equals(EnchantmentType.CURSE);
}
/**
* Get if enchantment conflicts with specified enchantment.
*
* @param enchantment The enchantment to test against.
* @return If conflicts.
*/
@Override
public boolean conflictsWith(@NotNull final Enchantment enchantment) {
if (enchantment instanceof EcoEnchant) {
return conflicts.contains(enchantment) || ((EcoEnchant) enchantment).conflicts.contains(this);
}
return conflicts.contains(enchantment);
}
/**
* If enchantment can be applied to item.
*
* @param itemStack The {@link ItemStack} to test against.
* @return If can be applied.
*/
@Override
public boolean canEnchantItem(@NotNull final ItemStack itemStack) {
if (this.type.isSingular() && EcoEnchants.hasAnyOfType(itemStack, this.type)) {
return FastItemStack.wrap(itemStack).getEnchantmentLevel(this, true) > 0;
}
if (itemStack.getType() == Material.BOOK || itemStack.getType() == Material.ENCHANTED_BOOK) {
return true;
}
return targetMaterials.contains(itemStack.getType());
}
/**
* Paper parity.
* <p>
* You should use EnchantmentCache instead.
*
* @param level The level.
* @return The display name.
* @deprecated Use {@link EnchantmentCache#getEntry(Enchantment)} instead.
*/
@Deprecated
@Override
public @NotNull Component displayName(final int level) {
return StringUtils.toComponent(EnchantmentCache.getEntry(this).getNameWithLevel(level));
}
/**
* Paper parity.
* <p>
* You should use {@link EcoEnchant#isAvailableFromVillager()} instead.
*
* @return If tradeable.
* @deprecated Use {@link EcoEnchant#isAvailableFromVillager()} instead.
*/
@Deprecated
@Override
public boolean isTradeable() {
return this.isAvailableFromVillager();
}
/**
* Paper parity.
* <p>
* You should use {@link EcoEnchant#isAvailableFromLoot()} instead.
*
* @return If discoverable.
* @deprecated Use {@link EcoEnchant#isAvailableFromLoot()} instead.
*/
@Deprecated
@Override
public boolean isDiscoverable() {
return this.isAvailableFromLoot();
}
/**
* Paper parity.
* <p>
* EcoEnchants has its own systems for everything like this. Will always return 0.
*
* @param level The level.
* @param entityCategory The category.
* @return 0
* @deprecated EcoEnchants has its own systems for this.
*/
@Deprecated
@Override
public float getDamageIncrease(final int level,
@NotNull final EntityCategory entityCategory) {
return 0;
}
/**
* Paper parity.
* <p>
* EcoEnchants has its own systems for targets.
* <p>
* Use {@link EcoEnchant#getTargets()} instead.
*
* @return An empty set.
* @deprecated Use {@link EcoEnchant#getTargets()}.
*/
@Deprecated
@Override
public @NotNull Set<EquipmentSlot> getActiveSlots() {
return new HashSet<>();
}
/**
* Paper parity.
* <p>
* eco / EcoEnchants recodes display entirely.
*
* @return A translation key.
* @deprecated Useless method, all items will be display differently using eco.
*/
@Deprecated
@Override
public @NotNull String translationKey() {
return "ecoenchants:enchantment." + this.getKey().getKey();
}
/**
* Paper parity.
* <p>
* EcoEnchants has its own systems for rarity.
* <p>
* Use {@link EcoEnchant#getEnchantmentRarity()} instead.
*
* @return {@link io.papermc.paper.enchantments.EnchantmentRarity#COMMON}.
* @deprecated Use {@link EcoEnchant#getEnchantmentRarity()}.
*/
@Deprecated
@Override
public @NotNull io.papermc.paper.enchantments.EnchantmentRarity getRarity() {
return io.papermc.paper.enchantments.EnchantmentRarity.COMMON;
}
@Override
public String toString() {
return "EcoEnchant{" + this.getKey() + "}";
}
}

View File

@ -1,609 +0,0 @@
package com.willfp.ecoenchants.enchantments;
import com.google.common.collect.BiMap;
import com.google.common.collect.HashBiMap;
import com.google.common.collect.ImmutableList;
import com.willfp.eco.core.config.interfaces.Config;
import com.willfp.eco.core.config.updating.ConfigUpdater;
import com.willfp.eco.core.fast.FastItemStack;
import com.willfp.ecoenchants.EcoEnchantsPlugin;
import com.willfp.ecoenchants.enchantments.custom.CustomEcoEnchants;
import com.willfp.ecoenchants.enchantments.ecoenchants.artifact.AngerArtifact;
import com.willfp.ecoenchants.enchantments.ecoenchants.artifact.AshArtifact;
import com.willfp.ecoenchants.enchantments.ecoenchants.artifact.CloudsArtifact;
import com.willfp.ecoenchants.enchantments.ecoenchants.artifact.CopperArtifact;
import com.willfp.ecoenchants.enchantments.ecoenchants.artifact.CrimsonArtifact;
import com.willfp.ecoenchants.enchantments.ecoenchants.artifact.DamageArtifact;
import com.willfp.ecoenchants.enchantments.ecoenchants.artifact.DragonArtifact;
import com.willfp.ecoenchants.enchantments.ecoenchants.artifact.DustArtifact;
import com.willfp.ecoenchants.enchantments.ecoenchants.artifact.EmeraldArtifact;
import com.willfp.ecoenchants.enchantments.ecoenchants.artifact.EnchantmentArtifact;
import com.willfp.ecoenchants.enchantments.ecoenchants.artifact.EndArtifact;
import com.willfp.ecoenchants.enchantments.ecoenchants.artifact.FireArtifact;
import com.willfp.ecoenchants.enchantments.ecoenchants.artifact.GlowArtifact;
import com.willfp.ecoenchants.enchantments.ecoenchants.artifact.HeartArtifact;
import com.willfp.ecoenchants.enchantments.ecoenchants.artifact.HoneyArtifact;
import com.willfp.ecoenchants.enchantments.ecoenchants.artifact.InkArtifact;
import com.willfp.ecoenchants.enchantments.ecoenchants.artifact.LavaArtifact;
import com.willfp.ecoenchants.enchantments.ecoenchants.artifact.LimeArtifact;
import com.willfp.ecoenchants.enchantments.ecoenchants.artifact.MagicArtifact;
import com.willfp.ecoenchants.enchantments.ecoenchants.artifact.MagmaArtifact;
import com.willfp.ecoenchants.enchantments.ecoenchants.artifact.MusicArtifact;
import com.willfp.ecoenchants.enchantments.ecoenchants.artifact.NautilusArtifact;
import com.willfp.ecoenchants.enchantments.ecoenchants.artifact.NetherArtifact;
import com.willfp.ecoenchants.enchantments.ecoenchants.artifact.RainArtifact;
import com.willfp.ecoenchants.enchantments.ecoenchants.artifact.RedstoneArtifact;
import com.willfp.ecoenchants.enchantments.ecoenchants.artifact.SlimeArtifact;
import com.willfp.ecoenchants.enchantments.ecoenchants.artifact.SmokeArtifact;
import com.willfp.ecoenchants.enchantments.ecoenchants.artifact.SnowArtifact;
import com.willfp.ecoenchants.enchantments.ecoenchants.artifact.SoulArtifact;
import com.willfp.ecoenchants.enchantments.ecoenchants.artifact.SoulFireArtifact;
import com.willfp.ecoenchants.enchantments.ecoenchants.artifact.SparkArtifact;
import com.willfp.ecoenchants.enchantments.ecoenchants.artifact.SparkleArtifact;
import com.willfp.ecoenchants.enchantments.ecoenchants.artifact.SporeArtifact;
import com.willfp.ecoenchants.enchantments.ecoenchants.artifact.SweepArtifact;
import com.willfp.ecoenchants.enchantments.ecoenchants.artifact.TearArtifact;
import com.willfp.ecoenchants.enchantments.ecoenchants.artifact.TotemArtifact;
import com.willfp.ecoenchants.enchantments.ecoenchants.artifact.VillagerArtifact;
import com.willfp.ecoenchants.enchantments.ecoenchants.artifact.WarpedArtifact;
import com.willfp.ecoenchants.enchantments.ecoenchants.artifact.WaterArtifact;
import com.willfp.ecoenchants.enchantments.ecoenchants.artifact.WaxArtifact;
import com.willfp.ecoenchants.enchantments.ecoenchants.artifact.WitchArtifact;
import com.willfp.ecoenchants.enchantments.ecoenchants.artifact.ZapArtifact;
import com.willfp.ecoenchants.enchantments.ecoenchants.curse.BreaklessnessCurse;
import com.willfp.ecoenchants.enchantments.ecoenchants.curse.CallingCurse;
import com.willfp.ecoenchants.enchantments.ecoenchants.curse.DecayCurse;
import com.willfp.ecoenchants.enchantments.ecoenchants.curse.FragilityCurse;
import com.willfp.ecoenchants.enchantments.ecoenchants.curse.HarmlessnessCurse;
import com.willfp.ecoenchants.enchantments.ecoenchants.curse.HungerCurse;
import com.willfp.ecoenchants.enchantments.ecoenchants.curse.InaccuracyCurse;
import com.willfp.ecoenchants.enchantments.ecoenchants.curse.MisfortuneCurse;
import com.willfp.ecoenchants.enchantments.ecoenchants.curse.PermanenceCurse;
import com.willfp.ecoenchants.enchantments.ecoenchants.normal.Abattoir;
import com.willfp.ecoenchants.enchantments.ecoenchants.normal.Abrasion;
import com.willfp.ecoenchants.enchantments.ecoenchants.normal.Aerial;
import com.willfp.ecoenchants.enchantments.ecoenchants.normal.Aquatic;
import com.willfp.ecoenchants.enchantments.ecoenchants.normal.Arachnid;
import com.willfp.ecoenchants.enchantments.ecoenchants.normal.Arborist;
import com.willfp.ecoenchants.enchantments.ecoenchants.normal.Arcanic;
import com.willfp.ecoenchants.enchantments.ecoenchants.normal.Atmospheric;
import com.willfp.ecoenchants.enchantments.ecoenchants.normal.Backstab;
import com.willfp.ecoenchants.enchantments.ecoenchants.normal.Beheading;
import com.willfp.ecoenchants.enchantments.ecoenchants.normal.BlastMining;
import com.willfp.ecoenchants.enchantments.ecoenchants.normal.Bleed;
import com.willfp.ecoenchants.enchantments.ecoenchants.normal.Blind;
import com.willfp.ecoenchants.enchantments.ecoenchants.normal.BlockBreather;
import com.willfp.ecoenchants.enchantments.ecoenchants.normal.BossHunter;
import com.willfp.ecoenchants.enchantments.ecoenchants.normal.Buckshot;
import com.willfp.ecoenchants.enchantments.ecoenchants.normal.Butchering;
import com.willfp.ecoenchants.enchantments.ecoenchants.normal.Cerebral;
import com.willfp.ecoenchants.enchantments.ecoenchants.normal.Chopless;
import com.willfp.ecoenchants.enchantments.ecoenchants.normal.Cleave;
import com.willfp.ecoenchants.enchantments.ecoenchants.normal.Collateral;
import com.willfp.ecoenchants.enchantments.ecoenchants.normal.Conclude;
import com.willfp.ecoenchants.enchantments.ecoenchants.normal.Corrosive;
import com.willfp.ecoenchants.enchantments.ecoenchants.normal.Cranial;
import com.willfp.ecoenchants.enchantments.ecoenchants.normal.Criticals;
import com.willfp.ecoenchants.enchantments.ecoenchants.normal.Cubism;
import com.willfp.ecoenchants.enchantments.ecoenchants.normal.Defender;
import com.willfp.ecoenchants.enchantments.ecoenchants.normal.Deflection;
import com.willfp.ecoenchants.enchantments.ecoenchants.normal.Defusion;
import com.willfp.ecoenchants.enchantments.ecoenchants.normal.Dexterous;
import com.willfp.ecoenchants.enchantments.ecoenchants.normal.Disable;
import com.willfp.ecoenchants.enchantments.ecoenchants.normal.Disappear;
import com.willfp.ecoenchants.enchantments.ecoenchants.normal.Diurnal;
import com.willfp.ecoenchants.enchantments.ecoenchants.normal.Diverse;
import com.willfp.ecoenchants.enchantments.ecoenchants.normal.Dousing;
import com.willfp.ecoenchants.enchantments.ecoenchants.normal.Drill;
import com.willfp.ecoenchants.enchantments.ecoenchants.normal.Dullness;
import com.willfp.ecoenchants.enchantments.ecoenchants.normal.Dweller;
import com.willfp.ecoenchants.enchantments.ecoenchants.normal.Economical;
import com.willfp.ecoenchants.enchantments.ecoenchants.normal.Electroshock;
import com.willfp.ecoenchants.enchantments.ecoenchants.normal.EndInfusion;
import com.willfp.ecoenchants.enchantments.ecoenchants.normal.EnderSlayer;
import com.willfp.ecoenchants.enchantments.ecoenchants.normal.Enderism;
import com.willfp.ecoenchants.enchantments.ecoenchants.normal.Evasion;
import com.willfp.ecoenchants.enchantments.ecoenchants.normal.Extinguishing;
import com.willfp.ecoenchants.enchantments.ecoenchants.normal.Extract;
import com.willfp.ecoenchants.enchantments.ecoenchants.normal.Famine;
import com.willfp.ecoenchants.enchantments.ecoenchants.normal.Farmhand;
import com.willfp.ecoenchants.enchantments.ecoenchants.normal.Fetching;
import com.willfp.ecoenchants.enchantments.ecoenchants.normal.Finality;
import com.willfp.ecoenchants.enchantments.ecoenchants.normal.Finishing;
import com.willfp.ecoenchants.enchantments.ecoenchants.normal.FireAffinity;
import com.willfp.ecoenchants.enchantments.ecoenchants.normal.FirstStrike;
import com.willfp.ecoenchants.enchantments.ecoenchants.normal.Flinch;
import com.willfp.ecoenchants.enchantments.ecoenchants.normal.Forcefield;
import com.willfp.ecoenchants.enchantments.ecoenchants.normal.Freerunner;
import com.willfp.ecoenchants.enchantments.ecoenchants.normal.Frozen;
import com.willfp.ecoenchants.enchantments.ecoenchants.normal.Fury;
import com.willfp.ecoenchants.enchantments.ecoenchants.normal.Goliath;
import com.willfp.ecoenchants.enchantments.ecoenchants.normal.Graceful;
import com.willfp.ecoenchants.enchantments.ecoenchants.normal.Grapple;
import com.willfp.ecoenchants.enchantments.ecoenchants.normal.GreenThumb;
import com.willfp.ecoenchants.enchantments.ecoenchants.normal.Grit;
import com.willfp.ecoenchants.enchantments.ecoenchants.normal.Hellish;
import com.willfp.ecoenchants.enchantments.ecoenchants.normal.Hook;
import com.willfp.ecoenchants.enchantments.ecoenchants.normal.Horde;
import com.willfp.ecoenchants.enchantments.ecoenchants.normal.IceShot;
import com.willfp.ecoenchants.enchantments.ecoenchants.normal.Identify;
import com.willfp.ecoenchants.enchantments.ecoenchants.normal.Ignite;
import com.willfp.ecoenchants.enchantments.ecoenchants.normal.IllusionAspect;
import com.willfp.ecoenchants.enchantments.ecoenchants.normal.Impact;
import com.willfp.ecoenchants.enchantments.ecoenchants.normal.Incandescence;
import com.willfp.ecoenchants.enchantments.ecoenchants.normal.InfernalTouch;
import com.willfp.ecoenchants.enchantments.ecoenchants.normal.Inferno;
import com.willfp.ecoenchants.enchantments.ecoenchants.normal.Infuriate;
import com.willfp.ecoenchants.enchantments.ecoenchants.normal.Insecticide;
import com.willfp.ecoenchants.enchantments.ecoenchants.normal.Instantaneous;
import com.willfp.ecoenchants.enchantments.ecoenchants.normal.Introversion;
import com.willfp.ecoenchants.enchantments.ecoenchants.normal.Invigoration;
import com.willfp.ecoenchants.enchantments.ecoenchants.normal.Kinetic;
import com.willfp.ecoenchants.enchantments.ecoenchants.normal.Launch;
import com.willfp.ecoenchants.enchantments.ecoenchants.normal.Leeching;
import com.willfp.ecoenchants.enchantments.ecoenchants.normal.Lesion;
import com.willfp.ecoenchants.enchantments.ecoenchants.normal.Levitate;
import com.willfp.ecoenchants.enchantments.ecoenchants.normal.LiquidShot;
import com.willfp.ecoenchants.enchantments.ecoenchants.normal.LuckyCatch;
import com.willfp.ecoenchants.enchantments.ecoenchants.normal.Lumberjack;
import com.willfp.ecoenchants.enchantments.ecoenchants.normal.Magnetic;
import com.willfp.ecoenchants.enchantments.ecoenchants.normal.Marking;
import com.willfp.ecoenchants.enchantments.ecoenchants.normal.Marksman;
import com.willfp.ecoenchants.enchantments.ecoenchants.normal.Necrotic;
import com.willfp.ecoenchants.enchantments.ecoenchants.normal.NetherInfusion;
import com.willfp.ecoenchants.enchantments.ecoenchants.normal.Netheric;
import com.willfp.ecoenchants.enchantments.ecoenchants.normal.Nocturnal;
import com.willfp.ecoenchants.enchantments.ecoenchants.normal.Optics;
import com.willfp.ecoenchants.enchantments.ecoenchants.normal.Oxygenate;
import com.willfp.ecoenchants.enchantments.ecoenchants.normal.Pacify;
import com.willfp.ecoenchants.enchantments.ecoenchants.normal.Paladin;
import com.willfp.ecoenchants.enchantments.ecoenchants.normal.Paralyze;
import com.willfp.ecoenchants.enchantments.ecoenchants.normal.Parasitic;
import com.willfp.ecoenchants.enchantments.ecoenchants.normal.Parry;
import com.willfp.ecoenchants.enchantments.ecoenchants.normal.Phantasm;
import com.willfp.ecoenchants.enchantments.ecoenchants.normal.Plasmic;
import com.willfp.ecoenchants.enchantments.ecoenchants.normal.Protector;
import com.willfp.ecoenchants.enchantments.ecoenchants.normal.Proximity;
import com.willfp.ecoenchants.enchantments.ecoenchants.normal.Puncture;
import com.willfp.ecoenchants.enchantments.ecoenchants.normal.Quadrilateralism;
import com.willfp.ecoenchants.enchantments.ecoenchants.normal.Radiance;
import com.willfp.ecoenchants.enchantments.ecoenchants.normal.Rage;
import com.willfp.ecoenchants.enchantments.ecoenchants.normal.Rapid;
import com.willfp.ecoenchants.enchantments.ecoenchants.normal.Reaper;
import com.willfp.ecoenchants.enchantments.ecoenchants.normal.Rebounding;
import com.willfp.ecoenchants.enchantments.ecoenchants.normal.Reel;
import com.willfp.ecoenchants.enchantments.ecoenchants.normal.Reinforcement;
import com.willfp.ecoenchants.enchantments.ecoenchants.normal.Rejuvenation;
import com.willfp.ecoenchants.enchantments.ecoenchants.normal.Replenish;
import com.willfp.ecoenchants.enchantments.ecoenchants.normal.Respirator;
import com.willfp.ecoenchants.enchantments.ecoenchants.normal.Revenant;
import com.willfp.ecoenchants.enchantments.ecoenchants.normal.Sating;
import com.willfp.ecoenchants.enchantments.ecoenchants.normal.Serrated;
import com.willfp.ecoenchants.enchantments.ecoenchants.normal.Settle;
import com.willfp.ecoenchants.enchantments.ecoenchants.normal.Shockwave;
import com.willfp.ecoenchants.enchantments.ecoenchants.normal.ShotAssist;
import com.willfp.ecoenchants.enchantments.ecoenchants.normal.Sickening;
import com.willfp.ecoenchants.enchantments.ecoenchants.normal.Slaughter;
import com.willfp.ecoenchants.enchantments.ecoenchants.normal.Slicing;
import com.willfp.ecoenchants.enchantments.ecoenchants.normal.Spearfishing;
import com.willfp.ecoenchants.enchantments.ecoenchants.normal.Spiked;
import com.willfp.ecoenchants.enchantments.ecoenchants.normal.Splash;
import com.willfp.ecoenchants.enchantments.ecoenchants.normal.Stab;
import com.willfp.ecoenchants.enchantments.ecoenchants.normal.Stalwart;
import com.willfp.ecoenchants.enchantments.ecoenchants.normal.Stamina;
import com.willfp.ecoenchants.enchantments.ecoenchants.normal.StoneSwitcher;
import com.willfp.ecoenchants.enchantments.ecoenchants.normal.StrayAspect;
import com.willfp.ecoenchants.enchantments.ecoenchants.normal.Succession;
import com.willfp.ecoenchants.enchantments.ecoenchants.normal.Supercritical;
import com.willfp.ecoenchants.enchantments.ecoenchants.normal.Sycophant;
import com.willfp.ecoenchants.enchantments.ecoenchants.normal.Tectonic;
import com.willfp.ecoenchants.enchantments.ecoenchants.normal.Telekinesis;
import com.willfp.ecoenchants.enchantments.ecoenchants.normal.Thor;
import com.willfp.ecoenchants.enchantments.ecoenchants.normal.Thrive;
import com.willfp.ecoenchants.enchantments.ecoenchants.normal.Tornado;
import com.willfp.ecoenchants.enchantments.ecoenchants.normal.Toxic;
import com.willfp.ecoenchants.enchantments.ecoenchants.normal.Transfuse;
import com.willfp.ecoenchants.enchantments.ecoenchants.normal.Tripleshot;
import com.willfp.ecoenchants.enchantments.ecoenchants.normal.VampireAspect;
import com.willfp.ecoenchants.enchantments.ecoenchants.normal.Vein;
import com.willfp.ecoenchants.enchantments.ecoenchants.normal.Venom;
import com.willfp.ecoenchants.enchantments.ecoenchants.normal.VoidAffinity;
import com.willfp.ecoenchants.enchantments.ecoenchants.normal.Voltage;
import com.willfp.ecoenchants.enchantments.ecoenchants.normal.WaterAffinity;
import com.willfp.ecoenchants.enchantments.ecoenchants.normal.WaterAspect;
import com.willfp.ecoenchants.enchantments.ecoenchants.normal.Weakening;
import com.willfp.ecoenchants.enchantments.ecoenchants.normal.Wisdom;
import com.willfp.ecoenchants.enchantments.ecoenchants.normal.WoodSwitcher;
import com.willfp.ecoenchants.enchantments.ecoenchants.normal.Wound;
import com.willfp.ecoenchants.enchantments.ecoenchants.normal.Zeus;
import com.willfp.ecoenchants.enchantments.ecoenchants.special.Aiming;
import com.willfp.ecoenchants.enchantments.ecoenchants.special.Annihilate;
import com.willfp.ecoenchants.enchantments.ecoenchants.special.Bladed;
import com.willfp.ecoenchants.enchantments.ecoenchants.special.Bolt;
import com.willfp.ecoenchants.enchantments.ecoenchants.special.Carve;
import com.willfp.ecoenchants.enchantments.ecoenchants.special.Confusion;
import com.willfp.ecoenchants.enchantments.ecoenchants.special.Energizing;
import com.willfp.ecoenchants.enchantments.ecoenchants.special.Force;
import com.willfp.ecoenchants.enchantments.ecoenchants.special.Frenzy;
import com.willfp.ecoenchants.enchantments.ecoenchants.special.Harpoon;
import com.willfp.ecoenchants.enchantments.ecoenchants.special.Indestructibility;
import com.willfp.ecoenchants.enchantments.ecoenchants.special.Instability;
import com.willfp.ecoenchants.enchantments.ecoenchants.special.Intellect;
import com.willfp.ecoenchants.enchantments.ecoenchants.special.LifeSteal;
import com.willfp.ecoenchants.enchantments.ecoenchants.special.Pentashot;
import com.willfp.ecoenchants.enchantments.ecoenchants.special.Preservation;
import com.willfp.ecoenchants.enchantments.ecoenchants.special.Prosperity;
import com.willfp.ecoenchants.enchantments.ecoenchants.special.Razor;
import com.willfp.ecoenchants.enchantments.ecoenchants.special.Repairing;
import com.willfp.ecoenchants.enchantments.ecoenchants.special.Soulbound;
import com.willfp.ecoenchants.enchantments.ecoenchants.special.Spring;
import com.willfp.ecoenchants.enchantments.ecoenchants.special.Streamlining;
import com.willfp.ecoenchants.enchantments.ecoenchants.special.Volatile;
import com.willfp.ecoenchants.enchantments.ecoenchants.spell.Ascend;
import com.willfp.ecoenchants.enchantments.ecoenchants.spell.Charge;
import com.willfp.ecoenchants.enchantments.ecoenchants.spell.Dynamite;
import com.willfp.ecoenchants.enchantments.ecoenchants.spell.Missile;
import com.willfp.ecoenchants.enchantments.ecoenchants.spell.Quake;
import com.willfp.ecoenchants.enchantments.ecoenchants.spell.Vitalize;
import com.willfp.ecoenchants.enchantments.meta.EnchantmentType;
import com.willfp.ecoenchants.enchantments.support.vanilla.VanillaEnchantments;
import com.willfp.ecoenchants.integrations.registration.RegistrationManager;
import com.willfp.libreforge.chains.EffectChains;
import lombok.experimental.UtilityClass;
import org.bukkit.NamespacedKey;
import org.bukkit.inventory.ItemStack;
import org.jetbrains.annotations.NotNull;
import java.util.HashSet;
import java.util.List;
import java.util.Optional;
@UtilityClass
@SuppressWarnings({"unused", "checkstyle:JavadocVariable"})
public class EcoEnchants {
public static final String CONFIG_LOCATION = "config.";
public static final String OBTAINING_LOCATION = "obtaining.";
public static final String GENERAL_LOCATION = "general-config.";
private static final BiMap<NamespacedKey, EcoEnchant> BY_KEY = HashBiMap.create();
private static final BiMap<String, EcoEnchant> BY_NAME = HashBiMap.create();
public static final EcoEnchant TELEKINESIS = new Telekinesis();
public static final EcoEnchant MARKSMAN = new Marksman();
public static final EcoEnchant INFERNAL_TOUCH = new InfernalTouch();
public static final EcoEnchant SPRING = new Spring();
public static final EcoEnchant STRAY_ASPECT = new StrayAspect();
public static final EcoEnchant ILLUSION_ASPECT = new IllusionAspect();
public static final EcoEnchant SLICING = new Slicing();
public static final EcoEnchant DEXTEROUS = new Dexterous();
public static final EcoEnchant BEHEADING = new Beheading();
public static final EcoEnchant NECROTIC = new Necrotic();
public static final EcoEnchant TECTONIC = new Tectonic();
public static final EcoEnchant EVASION = new Evasion();
public static final EcoEnchant SUCCESSION = new Succession();
public static final EcoEnchant FARMHAND = new Farmhand();
public static final EcoEnchant WISDOM = new Wisdom();
public static final EcoEnchant LEECHING = new Leeching();
public static final EcoEnchant VAMPIRE_ASPECT = new VampireAspect();
public static final EcoEnchant INSTABILITY = new Instability();
public static final EcoEnchant THRIVE = new Thrive();
public static final EcoEnchant DRILL = new Drill();
public static final EcoEnchant THOR = new Thor();
public static final EcoEnchant STREAMLINING = new Streamlining();
public static final EcoEnchant FIRST_STRIKE = new FirstStrike();
public static final EcoEnchant FINISHING = new Finishing();
public static final EcoEnchant CRITICALS = new Criticals();
public static final EcoEnchant INCANDESCENCE = new Incandescence();
public static final EcoEnchant SUPERCRITICAL = new Supercritical();
public static final EcoEnchant ABRASION = new Abrasion();
public static final EcoEnchant SPLASH = new Splash();
public static final EcoEnchant EXTINGUISHING = new Extinguishing();
public static final EcoEnchant GOLIATH = new Goliath();
public static final EcoEnchant OPTICS = new Optics();
public static final EcoEnchant DEFUSION = new Defusion();
public static final EcoEnchant CEREBRAL = new Cerebral();
public static final EcoEnchant GRIT = new Grit();
public static final EcoEnchant BOSS_HUNTER = new BossHunter();
public static final EcoEnchant INVIGORATION = new Invigoration();
public static final EcoEnchant REJUVENATION = new Rejuvenation();
public static final EcoEnchant FRAGILITY_CURSE = new FragilityCurse();
public static final EcoEnchant TRIPLESHOT = new Tripleshot();
public static final EcoEnchant RAPID = new Rapid();
public static final EcoEnchant SATING = new Sating();
public static final EcoEnchant REINFORCEMENT = new Reinforcement();
public static final EcoEnchant SOULBOUND = new Soulbound();
public static final EcoEnchant RAZOR = new Razor();
public static final EcoEnchant PROSPERITY = new Prosperity();
public static final EcoEnchant PRESERVATION = new Preservation();
public static final EcoEnchant FRENZY = new Frenzy();
public static final EcoEnchant BUTCHERING = new Butchering();
public static final EcoEnchant PROXIMITY = new Proximity();
public static final EcoEnchant ENDER_SLAYER = new EnderSlayer();
public static final EcoEnchant PROTECTOR = new Protector();
public static final EcoEnchant INDESTRUCTIBILITY = new Indestructibility();
public static final EcoEnchant ENERGIZING = new Energizing();
public static final EcoEnchant INTELLECT = new Intellect();
public static final EcoEnchant DEFLECTION = new Deflection();
public static final EcoEnchant LAUNCH = new Launch();
public static final EcoEnchant PERMANENCE_CURSE = new PermanenceCurse();
public static final EcoEnchant SPEARFISHING = new Spearfishing();
public static final EcoEnchant NETHER_INFUSION = new NetherInfusion();
public static final EcoEnchant REPLENISH = new Replenish();
public static final EcoEnchant FLINCH = new Flinch();
public static final EcoEnchant ELECTROSHOCK = new Electroshock();
public static final EcoEnchant NOCTURNAL = new Nocturnal();
public static final EcoEnchant CONFUSION = new Confusion();
public static final EcoEnchant ARCANIC = new Arcanic();
public static final EcoEnchant PENTASHOT = new Pentashot();
public static final EcoEnchant LUMBERJACK = new Lumberjack();
public static final EcoEnchant STONE_SWITCHER = new StoneSwitcher();
public static final EcoEnchant MAGNETIC = new Magnetic();
public static final EcoEnchant REPAIRING = new Repairing();
public static final EcoEnchant CALLING_CURSE = new CallingCurse();
public static final EcoEnchant BLAST_MINING = new BlastMining();
public static final EcoEnchant LIQUID_SHOT = new LiquidShot();
public static final EcoEnchant GRAPPLE = new Grapple();
public static final EcoEnchant HEART_ARTIFACT = new HeartArtifact();
public static final EcoEnchant SPARKLE_ARTIFACT = new SparkleArtifact();
public static final EcoEnchant LAVA_ARTIFACT = new LavaArtifact();
public static final EcoEnchant DRAGON_ARTIFACT = new DragonArtifact();
public static final EcoEnchant ENCHANTMENT_ARTIFACT = new EnchantmentArtifact();
public static final EcoEnchant SMOKE_ARTIFACT = new SmokeArtifact();
public static final EcoEnchant FIRE_ARTIFACT = new FireArtifact();
public static final EcoEnchant EMERALD_ARTIFACT = new EmeraldArtifact();
public static final EcoEnchant NETHER_ARTIFACT = new NetherArtifact();
public static final EcoEnchant END_ARTIFACT = new EndArtifact();
public static final EcoEnchant WATER_ARTIFACT = new WaterArtifact();
public static final EcoEnchant TOTEM_ARTIFACT = new TotemArtifact();
public static final EcoEnchant REDSTONE_ARTIFACT = new RedstoneArtifact();
public static final EcoEnchant ZAP_ARTIFACT = new ZapArtifact();
public static final EcoEnchant MUSIC_ARTIFACT = new MusicArtifact();
public static final EcoEnchant SNOW_ARTIFACT = new SnowArtifact();
public static final EcoEnchant WITCH_ARTIFACT = new WitchArtifact();
public static final EcoEnchant HONEY_ARTIFACT = new HoneyArtifact();
public static final EcoEnchant DAMAGE_ARTIFACT = new DamageArtifact();
public static final EcoEnchant CLOUDS_ARTIFACT = new CloudsArtifact();
public static final EcoEnchant MAGIC_ARTIFACT = new MagicArtifact();
public static final EcoEnchant DUST_ARTIFACT = new DustArtifact();
public static final EcoEnchant MAGMA_ARTIFACT = new MagmaArtifact();
public static final EcoEnchant INK_ARTIFACT = new InkArtifact();
public static final EcoEnchant ZEUS = new Zeus();
public static final EcoEnchant KINETIC = new Kinetic();
public static final EcoEnchant FIRE_AFFINITY = new FireAffinity();
public static final EcoEnchant PARASITIC = new Parasitic();
public static final EcoEnchant PARRY = new Parry();
public static final EcoEnchant AIMING = new Aiming();
public static final EcoEnchant HOOK = new Hook();
public static final EcoEnchant BLEED = new Bleed();
public static final EcoEnchant WEAKENING = new Weakening();
public static final EcoEnchant OXYGENATE = new Oxygenate();
public static final EcoEnchant WATER_ASPECT = new WaterAspect();
public static final EcoEnchant STAMINA = new Stamina();
public static final EcoEnchant COLLATERAL = new Collateral();
public static final EcoEnchant HUNGER_CURSE = new HungerCurse();
public static final EcoEnchant PALADIN = new Paladin();
public static final EcoEnchant SERRATED = new Serrated();
public static final EcoEnchant BLADED = new Bladed();
public static final EcoEnchant INFERNO = new Inferno();
public static final EcoEnchant STAB = new Stab();
public static final EcoEnchant TORNADO = new Tornado();
public static final EcoEnchant EXTRACT = new Extract();
public static final EcoEnchant AERIAL = new Aerial();
public static final EcoEnchant FAMINE = new Famine();
public static final EcoEnchant ANNIHILATE = new Annihilate();
public static final EcoEnchant RADIANCE = new Radiance();
public static final EcoEnchant HORDE = new Horde();
public static final EcoEnchant VEIN = new Vein();
public static final EcoEnchant ICE_SHOT = new IceShot();
public static final EcoEnchant PUNCTURE = new Puncture();
public static final EcoEnchant SHOCKWAVE = new Shockwave();
public static final EcoEnchant VOLATILE = new Volatile();
public static final EcoEnchant INSTANTANEOUS = new Instantaneous();
public static final EcoEnchant FREERUNNER = new Freerunner();
public static final EcoEnchant BOLT = new Bolt();
public static final EcoEnchant DULLNESS = new Dullness();
public static final EcoEnchant IGNITE = new Ignite();
public static final EcoEnchant CLEAVE = new Cleave();
public static final EcoEnchant CARVE = new Carve();
public static final EcoEnchant TOXIC = new Toxic();
public static final EcoEnchant WATER_AFFINITY = new WaterAffinity();
public static final EcoEnchant FORCEFIELD = new Forcefield();
public static final EcoEnchant SYCOPHANT = new Sycophant();
public static final EcoEnchant CHOPLESS = new Chopless();
public static final EcoEnchant GREEN_THUMB = new GreenThumb();
public static final EcoEnchant SPIKED = new Spiked();
public static final EcoEnchant HARPOON = new Harpoon();
public static final EcoEnchant REEL = new Reel();
public static final EcoEnchant SHOT_ASSIST = new ShotAssist();
public static final EcoEnchant FROZEN = new Frozen();
public static final EcoEnchant DISAPPEAR = new Disappear();
public static final EcoEnchant HARMLESSNESS_CURSE = new HarmlessnessCurse();
public static final EcoEnchant FURY = new Fury();
public static final EcoEnchant LEVITATE = new Levitate();
public static final EcoEnchant BREAKLESSNESS_CURSE = new BreaklessnessCurse();
public static final EcoEnchant DECAY_CURSE = new DecayCurse();
public static final EcoEnchant MISFORTUNE_CURSE = new MisfortuneCurse();
public static final EcoEnchant VENOM = new Venom();
public static final EcoEnchant CRANIAL = new Cranial();
public static final EcoEnchant AQUATIC = new Aquatic();
public static final EcoEnchant BUCKSHOT = new Buckshot();
public static final EcoEnchant DIVERSE = new Diverse();
public static final EcoEnchant LIFE_STEAL = new LifeSteal();
public static final EcoEnchant LIME_ARTIFACT = new LimeArtifact();
public static final EcoEnchant FORCE = new Force();
public static final EcoEnchant END_INFUSION = new EndInfusion();
public static final EcoEnchant DIURNAL = new Diurnal();
public static final EcoEnchant MARKING = new Marking();
public static final EcoEnchant CORROSIVE = new Corrosive();
public static final EcoEnchant WOUND = new Wound();
public static final EcoEnchant FINALITY = new Finality();
public static final EcoEnchant BLIND = new Blind();
public static final EcoEnchant SICKENING = new Sickening();
public static final EcoEnchant DEFENDER = new Defender();
public static final EcoEnchant NETHERIC = new Netheric();
public static final EcoEnchant ENDERISM = new Enderism();
public static final EcoEnchant RAGE = new Rage();
public static final EcoEnchant IMPACT = new Impact();
public static final EcoEnchant PARALYZE = new Paralyze();
public static final EcoEnchant IDENTIFY = new Identify();
public static final EcoEnchant INFURIATE = new Infuriate();
public static final EcoEnchant ATMOSPHERIC = new Atmospheric();
public static final EcoEnchant REVENANT = new Revenant();
public static final EcoEnchant INSECTICIDE = new Insecticide();
public static final EcoEnchant SLAUGHTER = new Slaughter();
public static final EcoEnchant SETTLE = new Settle();
public static final EcoEnchant PHANTASM = new Phantasm();
public static final EcoEnchant ARACHNID = new Arachnid();
public static final EcoEnchant PACIFY = new Pacify();
public static final EcoEnchant ABATTOIR = new Abattoir();
public static final EcoEnchant DISABLE = new Disable();
public static final EcoEnchant HELLISH = new Hellish();
public static final EcoEnchant VOID_AFFINITY = new VoidAffinity();
public static final EcoEnchant CUBISM = new Cubism();
public static final EcoEnchant QUADRILATERALISM = new Quadrilateralism();
public static final EcoEnchant LESION = new Lesion();
public static final EcoEnchant CONCLUDE = new Conclude();
public static final EcoEnchant GRACEFUL = new Graceful();
public static final EcoEnchant BLOCK_BREATHER = new BlockBreather();
public static final EcoEnchant VOLTAGE = new Voltage();
public static final EcoEnchant TRANSFUSE = new Transfuse();
public static final EcoEnchant INACCURACY_CURSE = new InaccuracyCurse();
public static final EcoEnchant RESPIRATOR = new Respirator();
public static final EcoEnchant FETCHING = new Fetching();
public static final EcoEnchant ECONOMICAL = new Economical();
public static final EcoEnchant SOUL_ARTIFACT = new SoulArtifact();
public static final EcoEnchant SOUL_FIRE_ARTIFACT = new SoulFireArtifact();
public static final EcoEnchant CRIMSON_ARTIFACT = new CrimsonArtifact();
public static final EcoEnchant ASH_ARTIFACT = new AshArtifact();
public static final EcoEnchant WARPED_ARTIFACT = new WarpedArtifact();
public static final EcoEnchant TEAR_ARTIFACT = new TearArtifact();
public static final EcoEnchant BACKSTAB = new Backstab();
public static final EcoEnchant DWELLER = new Dweller();
public static final EcoEnchant STALWART = new Stalwart();
public static final EcoEnchant PLASMIC = new Plasmic();
public static final EcoEnchant MISSILE = new Missile();
public static final EcoEnchant QUAKE = new Quake();
public static final EcoEnchant VITALIZE = new Vitalize();
public static final EcoEnchant DYNAMITE = new Dynamite();
public static final EcoEnchant CHARGE = new Charge();
public static final EcoEnchant ASCEND = new Ascend();
public static final EcoEnchant ARBORIST = new Arborist();
public static final EcoEnchant LUCKY_CATCH = new LuckyCatch();
public static final EcoEnchant INTROVERSION = new Introversion();
public static final EcoEnchant VILLAGER_ARTIFACT = new VillagerArtifact();
public static final EcoEnchant ANGER_ARTIFACT = new AngerArtifact();
public static final EcoEnchant NAUTILUS_ARTIFACT = new NautilusArtifact();
public static final EcoEnchant SWEEP_ARTIFACT = new SweepArtifact();
public static final EcoEnchant REAPER = new Reaper();
public static final EcoEnchant WOOD_SWITCHER = new WoodSwitcher();
public static final EcoEnchant REBOUNDING = new Rebounding();
public static final EcoEnchant COPPER_ARTIFACT = new CopperArtifact();
public static final EcoEnchant GLOW_ARTIFACT = new GlowArtifact();
public static final EcoEnchant SPARK_ARTIFACT = new SparkArtifact();
public static final EcoEnchant SPORE_ARTIFACT = new SporeArtifact();
public static final EcoEnchant WAX_ARTIFACT = new WaxArtifact();
public static final EcoEnchant RAIN_ARTIFACT = new RainArtifact();
public static final EcoEnchant SLIME_ARTIFACT = new SlimeArtifact();
public static final EcoEnchant DOUSING = new Dousing();
/**
* Get all registered {@link EcoEnchant}s.
*
* @return A list of all {@link EcoEnchant}s.
*/
public static List<EcoEnchant> values() {
return ImmutableList.copyOf(BY_KEY.values());
}
/**
* Get {@link EcoEnchant} matching display name.
*
* @param name The display name to search for.
* @return The matching {@link EcoEnchant}, or null if not found.
*/
public static EcoEnchant getByName(@NotNull final String name) {
return BY_NAME.get(name);
}
/**
* Get {@link EcoEnchant} matching permission name.
*
* @param permissionName The permission name to search for.
* @return The matching {@link EcoEnchant}, or null if not found.
*/
public static EcoEnchant getByPermission(@NotNull final String permissionName) {
Optional<EcoEnchant> matching = values().stream().filter(enchant -> enchant.getPermissionName().equalsIgnoreCase(permissionName)).findFirst();
return matching.orElse(null);
}
/**
* Get {@link EcoEnchant} matching key.
*
* @param key The NamespacedKey to search for.
* @return The matching {@link EcoEnchant}, or null if not found.
*/
public static EcoEnchant getByKey(@NotNull final NamespacedKey key) {
return BY_KEY.get(key);
}
/**
* Get if {@link ItemStack} has any {@link EcoEnchant} matching specified {@link EnchantmentType}.
*
* @param item The {@link ItemStack} to check.
* @param type The {@link EnchantmentType} to match.
* @return True if has, false if doesn't have.
*/
public static boolean hasAnyOfType(@NotNull final ItemStack item,
@NotNull final EnchantmentType type) {
return FastItemStack.wrap(item).getEnchants(true).keySet()
.stream()
.filter(enchantment -> enchantment instanceof EcoEnchant)
.map(enchantment -> (EcoEnchant) enchantment)
.anyMatch(ecoEnchant -> ecoEnchant.getType().equals(type));
}
/**
* Update all {@link EcoEnchant}s.
*
* @param plugin Instance of EcoEnchants.
*/
@ConfigUpdater
public static void update(@NotNull final EcoEnchantsPlugin plugin) {
for (Config config : plugin.getCustomEnchantsYml().getSubsections("chains")) {
EffectChains.compile(config, "Custom Enchant Chains");
}
CustomEcoEnchants.update(plugin);
for (EcoEnchant ecoEnchant : new HashSet<>(values())) {
ecoEnchant.update();
}
VanillaEnchantments.update(plugin);
RegistrationManager.registerEnchantments();
}
/**
* Add new {@link EcoEnchant} to EcoEnchants.
* <p>
* Only for internal use, enchantments are automatically added in the constructor.
*
* @param enchant The {@link EcoEnchant} to add.
*/
public static void addNewEcoEnchant(@NotNull final EcoEnchant enchant) {
BY_KEY.remove(enchant.getKey());
BY_NAME.inverse().remove(enchant);
BY_KEY.put(enchant.getKey(), enchant);
BY_NAME.put(enchant.getDisplayName(), enchant);
}
/**
* Remove {@link EcoEnchant} from EcoEnchants.
*
* @param enchant The {@link EcoEnchant} to remove.
*/
public static void removeEcoEnchant(@NotNull final EcoEnchant enchant) {
BY_KEY.remove(enchant.getKey());
BY_NAME.inverse().remove(enchant);
}
}

View File

@ -1,25 +0,0 @@
package com.willfp.ecoenchants.enchantments.custom;
import com.willfp.eco.core.config.interfaces.Config;
import com.willfp.ecoenchants.enchantments.EcoEnchant;
import com.willfp.ecoenchants.enchantments.EcoEnchants;
import com.willfp.libreforge.conditions.Condition;
import org.bukkit.NamespacedKey;
import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull;
public class ConditionHasEcoEnchantRequirements extends Condition {
/**
* Create new condition.
*/
public ConditionHasEcoEnchantRequirements() {
super("has_ecoenchant_requirements");
}
@Override
public boolean isConditionMet(@NotNull final Player player,
@NotNull final Config config) {
EcoEnchant ecoEnchant = EcoEnchants.getByKey(NamespacedKey.minecraft(config.getString("enchant")));
return ecoEnchant.areRequirementsMet(player);
}
}

View File

@ -1,26 +0,0 @@
package com.willfp.ecoenchants.enchantments.custom;
import com.willfp.eco.core.config.interfaces.Config;
import com.willfp.eco.util.ListUtils;
import com.willfp.ecoenchants.enchantments.EcoEnchant;
import com.willfp.ecoenchants.enchantments.EcoEnchants;
import com.willfp.libreforge.conditions.Condition;
import org.bukkit.NamespacedKey;
import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull;
public class ConditionInEcoEnchantWorld extends Condition {
/**
* Create new condition.
*/
public ConditionInEcoEnchantWorld() {
super("in_ecoenchant_world");
}
@Override
public boolean isConditionMet(@NotNull final Player player,
@NotNull final Config config) {
EcoEnchant ecoEnchant = EcoEnchants.getByKey(NamespacedKey.minecraft(config.getString("enchant")));
return !ListUtils.containsIgnoreCase(ecoEnchant.getDisabledWorldNames(), player.getWorld().getName());
}
}

View File

@ -1,101 +0,0 @@
package com.willfp.ecoenchants.enchantments.custom;
import com.willfp.eco.core.config.interfaces.Config;
import com.willfp.ecoenchants.enchantments.EcoEnchant;
import com.willfp.ecoenchants.enchantments.EcoEnchants;
import com.willfp.ecoenchants.enchantments.meta.EnchantmentTarget;
import com.willfp.ecoenchants.enchantments.meta.EnchantmentType;
import org.bukkit.Bukkit;
import org.jetbrains.annotations.NotNull;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import java.util.logging.Logger;
public class CustomEcoEnchant extends EcoEnchant {
/**
* The levels.
*/
private final Map<Integer, CustomEcoEnchantLevel> levels;
/**
* Create custom EcoEnchant.
*
* @param config The config.
*/
public CustomEcoEnchant(@NotNull final Config config) {
super(
config.getString("id"), EnchantmentType.getByName(config.getString("type").toUpperCase()), config
);
this.levels = new HashMap<>();
int i = 1;
for (Config levelConfig : config.getSubsections("levels")) {
levels.put(i, new CustomEcoEnchantLevel(this, levelConfig, i));
i++;
}
}
@Override
public String getPlaceholder(final int level) {
return this.getLevel(level).getValuePlaceholder();
}
@Override
protected void postUpdate() {
for (EnchantmentTarget target : this.getTargets()) {
if (target.getSlot() == null) {
Logger logger = this.getPlugin().getLogger();
logger.warning("");
logger.warning("Problem with target " + target.getName() + "!");
logger.warning("Go to target.yml and specify a slot for enchants to activate on!");
logger.warning("Example:");
logger.warning(target.getName() + ":");
logger.warning(" - slot:hands");
logger.warning(" - material1");
logger.warning(" - material2");
logger.warning("");
logger.warning("Read the wiki to see available slots!");
logger.warning("Custom Enchantment " + this.getKey().getKey() + " will not work until then");
logger.warning("");
}
}
}
/**
* Get the level.
*
* @param level The level.
* @return The level.
*/
public CustomEcoEnchantLevel getLevel(final int level) {
return levels.get(level);
}
/**
* Get the levels.
*
* @return The levels.
*/
public Set<CustomEcoEnchantLevel> getLevels() {
return new HashSet<>(levels.values());
}
@Override
public int getMaxLevel() {
return this.levels.size();
}
@Override
public boolean isEnabled() {
return true;
}
static {
new ConditionInEcoEnchantWorld();
new ConditionHasEcoEnchantRequirements();
}
}

View File

@ -1,151 +0,0 @@
package com.willfp.ecoenchants.enchantments.custom;
import com.github.benmanes.caffeine.cache.Cache;
import com.github.benmanes.caffeine.cache.Caffeine;
import com.willfp.eco.core.config.BuildableConfig;
import com.willfp.eco.core.config.interfaces.Config;
import com.willfp.eco.core.placeholder.StaticPlaceholder;
import com.willfp.ecoenchants.enchantments.EcoEnchant;
import com.willfp.libreforge.Holder;
import com.willfp.libreforge.conditions.Conditions;
import com.willfp.libreforge.conditions.ConfiguredCondition;
import com.willfp.libreforge.effects.ConfiguredEffect;
import com.willfp.libreforge.effects.Effects;
import lombok.Getter;
import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Objects;
import java.util.Set;
import java.util.UUID;
import java.util.concurrent.TimeUnit;
public class CustomEcoEnchantLevel implements Holder {
/**
* The parent EcoEnchant.
*/
@Getter
private final EcoEnchant parent;
/**
* The conditions.
*/
private final Set<ConfiguredCondition> conditions = new HashSet<>();
/**
* The effects.
*/
private final Set<ConfiguredEffect> effects = new HashSet<>();
/**
* The value placeholder.
*/
@Getter
private final String valuePlaceholder;
/**
* The level.
*/
private final int level;
/**
* Create custom EcoEnchant level.
*
* @param parent The parent.
* @param config The config.
* @param level The level.
*/
public CustomEcoEnchantLevel(@NotNull final EcoEnchant parent,
@NotNull final Config config,
final int level) {
this.parent = parent;
this.level = level;
config.injectPlaceholders(new StaticPlaceholder("level", () -> String.valueOf(level)));
for (Config cfg : config.getSubsections("effects")) {
effects.add(Effects.compile(cfg, "Custom EcoEnchant ID " + parent.getKey().getKey()));
}
for (Config cfg : config.getSubsections("conditions")) {
conditions.add(Conditions.compile(cfg, "Custom EcoEnchant ID " + parent.getKey().getKey()));
}
conditions.add(Conditions.compile(
new BuildableConfig()
.add("args.enchant", parent.getKey().getKey())
.add("id", "in_ecoenchant_world"),
"EcoEnchants Internals (world) - If you see this message, report it as a bug!"
));
conditions.add(Conditions.compile(
new BuildableConfig()
.add("args.enchant", parent.getKey().getKey())
.add("id", "has_ecoenchant_requirements"),
"EcoEnchants Internals (requirements) - If you see this message, report it as a bug!"
));
this.valuePlaceholder = config.getString("value-placeholder");
}
@NotNull
@Override
public Set<ConfiguredCondition> getConditions() {
return conditions;
}
@NotNull
@Override
public Set<ConfiguredEffect> getEffects() {
return effects;
}
@Override
public String toString() {
return "CustomEcoEnchantLevel{"
+ "parent=" + parent
+ ",level=" + level
+ '}';
}
@NotNull
@Override
public List<String> getNotMetLines(@NotNull final Player player) {
return NotMetLineCacheEntry.CACHE.get(new NotMetLineCacheEntry(player.getUniqueId(), this.getId()), (entry) -> {
List<String> lines = new ArrayList<>();
for (ConfiguredCondition condition : this.getConditions()) {
if (!condition.isMet(player)) {
lines.addAll(Objects.requireNonNullElse(condition.getNotMetLines(), new ArrayList<>()));
}
}
return lines;
});
}
@NotNull
@Override
public String getId() {
return this.parent.getKey().getKey() + "_" + this.level;
}
/**
* Cache for not met lines.
*
* @param uuid The UUID.
* @param holderID The holder ID.
*/
private record NotMetLineCacheEntry(@NotNull UUID uuid,
@NotNull String holderID) {
/**
* The cache.
*/
static final Cache<NotMetLineCacheEntry, List<String>> CACHE = Caffeine.newBuilder()
.expireAfterWrite(1, TimeUnit.SECONDS)
.build();
}
}

View File

@ -1,31 +0,0 @@
package com.willfp.ecoenchants.enchantments.custom;
import com.willfp.eco.core.EcoPlugin;
import com.willfp.eco.core.PluginDependent;
import com.willfp.ecoenchants.enchantments.EcoEnchant;
import com.willfp.libreforge.events.EffectActivateEvent;
import org.bukkit.event.Listener;
import org.jetbrains.annotations.NotNull;
public class CustomEcoEnchantRequirementListeners extends PluginDependent<EcoPlugin> implements Listener {
/**
* Initialize new listeners and link them to a plugin.
*
* @param plugin The plugin to link to.
*/
public CustomEcoEnchantRequirementListeners(@NotNull final EcoPlugin plugin) {
super(plugin);
}
public void onActivate(@NotNull final EffectActivateEvent event) {
if (!(event.getHolder() instanceof CustomEcoEnchantLevel level)) {
return;
}
EcoEnchant enchant = level.getParent();
if (!(enchant.areRequirementsMet(event.getPlayer()))) {
event.setCancelled(true);
}
}
}

View File

@ -1,38 +0,0 @@
package com.willfp.ecoenchants.enchantments.custom;
import com.willfp.eco.core.config.interfaces.Config;
import com.willfp.ecoenchants.EcoEnchantsPlugin;
import com.willfp.ecoenchants.enchantments.EcoEnchant;
import com.willfp.ecoenchants.enchantments.EcoEnchants;
import com.willfp.ecoenchants.enchantments.util.EnchantmentUtils;
import lombok.experimental.UtilityClass;
import org.jetbrains.annotations.NotNull;
import java.util.HashSet;
import java.util.Set;
@UtilityClass
public class CustomEcoEnchants {
/**
* Custom EcoEnchants.
*/
private static final Set<EcoEnchant> VALUES = new HashSet<>();
/**
* Update the map.
*
* @param plugin Instance of EcoEnchants.
*/
public static void update(@NotNull final EcoEnchantsPlugin plugin) {
for (EcoEnchant enchant : VALUES) {
EcoEnchants.removeEcoEnchant(enchant);
EnchantmentUtils.unregister(enchant);
}
VALUES.clear();
for (Config cfg : plugin.getCustomEnchantsYml().getSubsections("enchants")) {
VALUES.add(new CustomEcoEnchant(cfg));
}
}
}

View File

@ -1,147 +0,0 @@
package com.willfp.ecoenchants.enchantments.custom;
import com.willfp.eco.core.EcoPlugin;
import com.willfp.eco.core.PluginDependent;
import com.willfp.eco.core.events.ArmorChangeEvent;
import com.willfp.ecoenchants.enchantments.EcoEnchant;
import com.willfp.ecoenchants.enchantments.EcoEnchants;
import com.willfp.ecoenchants.enchantments.meta.EnchantmentTarget;
import com.willfp.libreforge.LibReforgeUtils;
import com.willfp.libreforge.effects.ConfiguredEffect;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.entity.EntityPickupItemEvent;
import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.event.player.PlayerDropItemEvent;
import org.bukkit.event.player.PlayerItemHeldEvent;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerQuitEvent;
import org.jetbrains.annotations.NotNull;
public class CustomEnchantEnableListeners extends PluginDependent<EcoPlugin> implements Listener {
/**
* Initialize new listeners and link them to a plugin.
*
* @param plugin The plugin to link to.
*/
public CustomEnchantEnableListeners(@NotNull final EcoPlugin plugin) {
super(plugin);
}
/**
* Called on item pickup.
*
* @param event The event to listen for.
*/
@EventHandler
public void onItemPickup(@NotNull final EntityPickupItemEvent event) {
if (!(event.getEntity() instanceof Player player)) {
return;
}
if (!EnchantmentTarget.ALL.getMaterials().contains(event.getItem().getItemStack().getType())) {
return;
}
refreshPlayer(player);
}
/**
* Called on player join.
*
* @param event The event to listen for.
*/
@EventHandler
public void onPlayerJoin(@NotNull final PlayerJoinEvent event) {
refresh();
}
/**
* Called on player leave.
*
* @param event The event to listen for.
*/
@EventHandler
public void onPlayerLeave(@NotNull final PlayerQuitEvent event) {
refresh();
Player player = event.getPlayer();
for (EcoEnchant value : EcoEnchants.values()) {
if (!(value instanceof CustomEcoEnchant enchant)) {
continue;
}
for (CustomEcoEnchantLevel level : enchant.getLevels()) {
for (ConfiguredEffect effect : level.getEffects()) {
effect.disableFor(player);
}
}
}
}
/**
* Called on item drop.
*
* @param event The event to listen for.
*/
@EventHandler
public void onInventoryDrop(@NotNull final PlayerDropItemEvent event) {
if (!EnchantmentTarget.ALL.getMaterials().contains(event.getItemDrop().getItemStack().getType())) {
return;
}
refreshPlayer(event.getPlayer());
}
/**
* Called on slot change.
*
* @param event The event to listen for.
*/
@EventHandler
public void onChangeSlot(@NotNull final PlayerItemHeldEvent event) {
refreshPlayer(event.getPlayer());
this.getPlugin().getScheduler().run(() -> refreshPlayer(event.getPlayer()));
}
/**
* Called on armor change.
*
* @param event The event to listen for.
*/
@EventHandler
public void onArmorChange(@NotNull final ArmorChangeEvent event) {
refreshPlayer(event.getPlayer());
}
/**
* Called on inventory click.
*
* @param event The event to listen for.
*/
@EventHandler
public void onInventoryClick(@NotNull final InventoryClickEvent event) {
if (!(event.getWhoClicked() instanceof Player)) {
return;
}
refreshPlayer((Player) event.getWhoClicked());
}
/**
* Force refresh all online players.
* <p>
* This is a very expensive method.
*/
public void refresh() {
this.getPlugin().getServer().getOnlinePlayers().forEach(this::refreshPlayer);
}
private void refreshPlayer(@NotNull final Player player) {
CustomEnchantLookup.clearCache(player);
LibReforgeUtils.updateEffects(player);
}
}

View File

@ -1,147 +0,0 @@
package com.willfp.ecoenchants.enchantments.custom;
import com.github.benmanes.caffeine.cache.Cache;
import com.github.benmanes.caffeine.cache.Caffeine;
import com.willfp.eco.core.EcoPlugin;
import com.willfp.ecoenchants.EcoEnchantsPlugin;
import com.willfp.ecoenchants.enchantments.EcoEnchant;
import com.willfp.ecoenchants.enchantments.meta.EnchantmentTarget;
import com.willfp.ecoenchants.enchantments.util.EnchantChecks;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.jetbrains.annotations.NotNull;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Set;
import java.util.concurrent.TimeUnit;
import java.util.function.Function;
public class CustomEnchantLookup {
/**
* All registered providers.
*/
private static final Set<Function<Player, Map<ItemStack, EnchantmentTarget.Slot>>> PROVIDERS = new HashSet<>();
/**
* Cached items.
*/
private static final Cache<Player, Map<ItemStack, EnchantmentTarget.Slot>> ITEM_CACHE = Caffeine.newBuilder()
.expireAfterWrite(2, TimeUnit.SECONDS)
.build();
/**
* Cached enchant levels.
*/
private static final Cache<Player, Collection<CustomEcoEnchantLevel>> ENCHANT_LEVELS_CACHE = Caffeine.newBuilder()
.expireAfterWrite(2, TimeUnit.SECONDS)
.build();
/**
* Instance of EcoEnchants.
*/
private static final EcoPlugin PLUGIN = EcoEnchantsPlugin.getInstance();
/**
* Register provider.
*
* @param provider The provider.
*/
public static void registerProvider(@NotNull final Function<Player, Map<ItemStack, EnchantmentTarget.Slot>> provider) {
PROVIDERS.add(provider);
}
/**
* Provide ItemStacks.
*
* @param p The player.
* @return The ItemStacks.
*/
public static Map<ItemStack, EnchantmentTarget.Slot> provide(@NotNull final Player p) {
return ITEM_CACHE.get(p, player -> {
Map<ItemStack, EnchantmentTarget.Slot> found = new HashMap<>();
for (Function<Player, Map<ItemStack, EnchantmentTarget.Slot>> provider : PROVIDERS) {
found.putAll(provider.apply(player));
}
found.keySet().removeIf(Objects::isNull);
return found;
});
}
/**
* Provide levels.
*
* @param p The player.
* @return The levels.
*/
public static List<CustomEcoEnchantLevel> provideLevels(@NotNull final Player p) {
return new ArrayList<>(ENCHANT_LEVELS_CACHE.get(p, player -> {
List<CustomEcoEnchantLevel> found = new ArrayList<>();
for (Map.Entry<ItemStack, EnchantmentTarget.Slot> entry : provide(player).entrySet()) {
ItemStack itemStack = entry.getKey();
EnchantmentTarget.Slot slot = entry.getValue();
if (itemStack == null) {
continue;
}
Map<EcoEnchant, Integer> enchants = EnchantChecks.getEnchantsOnItem(itemStack);
if (enchants.isEmpty()) {
continue;
}
for (Map.Entry<EcoEnchant, Integer> enchantEntry : enchants.entrySet()) {
if (!(enchantEntry.getKey() instanceof CustomEcoEnchant enchant)) {
continue;
}
if (slot != EnchantmentTarget.Slot.ANY) {
if (!enchant.getTargets().stream()
.map(EnchantmentTarget::getSlot).toList()
.contains(slot)) {
continue;
}
}
found.add(enchant.getLevel(enchantEntry.getValue()));
}
}
return found;
}));
}
/**
* Clear cache.
*
* @param player The player.
*/
public static void clearCache(@NotNull final Player player) {
ITEM_CACHE.invalidate(player);
ENCHANT_LEVELS_CACHE.invalidate(player);
}
static {
registerProvider(player -> Map.of(
player.getInventory().getItemInMainHand(),
EnchantmentTarget.Slot.HANDS
));
registerProvider(player -> Map.of(
player.getInventory().getItemInOffHand(),
EnchantmentTarget.Slot.HANDS
));
registerProvider(player -> {
Map<ItemStack, EnchantmentTarget.Slot> items = new HashMap<>();
for (ItemStack stack : player.getInventory().getArmorContents()) {
items.put(stack, EnchantmentTarget.Slot.ARMOR);
}
return items;
});
}
}

View File

@ -1,18 +0,0 @@
package com.willfp.ecoenchants.enchantments.ecoenchants.artifact;
import com.willfp.ecoenchants.enchantments.itemtypes.Artifact;
import org.bukkit.Particle;
import org.jetbrains.annotations.NotNull;
public class AngerArtifact extends Artifact {
public AngerArtifact() {
super(
"anger_artifact"
);
}
@Override
public @NotNull Particle getParticle() {
return Particle.VILLAGER_ANGRY;
}
}

View File

@ -1,18 +0,0 @@
package com.willfp.ecoenchants.enchantments.ecoenchants.artifact;
import com.willfp.ecoenchants.enchantments.itemtypes.Artifact;
import org.bukkit.Particle;
import org.jetbrains.annotations.NotNull;
public class AshArtifact extends Artifact {
public AshArtifact() {
super(
"ash_artifact"
);
}
@Override
public @NotNull Particle getParticle() {
return Particle.WHITE_ASH;
}
}

View File

@ -1,24 +0,0 @@
package com.willfp.ecoenchants.enchantments.ecoenchants.artifact;
import com.willfp.ecoenchants.enchantments.itemtypes.Artifact;
import org.bukkit.Color;
import org.bukkit.Particle;
import org.jetbrains.annotations.NotNull;
public class CloudsArtifact extends Artifact {
public CloudsArtifact() {
super(
"clouds_artifact"
);
}
@Override
public @NotNull Particle getParticle() {
return Particle.REDSTONE;
}
@Override
public Particle.DustOptions getDustOptions() {
return new Particle.DustOptions(Color.AQUA, 1.0f);
}
}

View File

@ -1,18 +0,0 @@
package com.willfp.ecoenchants.enchantments.ecoenchants.artifact;
import com.willfp.ecoenchants.enchantments.itemtypes.Artifact;
import org.bukkit.Particle;
import org.jetbrains.annotations.NotNull;
public class CopperArtifact extends Artifact {
public CopperArtifact() {
super(
"copper_artifact"
);
}
@Override
public @NotNull Particle getParticle() {
return Particle.WAX_ON;
}
}

View File

@ -1,18 +0,0 @@
package com.willfp.ecoenchants.enchantments.ecoenchants.artifact;
import com.willfp.ecoenchants.enchantments.itemtypes.Artifact;
import org.bukkit.Particle;
import org.jetbrains.annotations.NotNull;
public class CrimsonArtifact extends Artifact {
public CrimsonArtifact() {
super(
"crimson_artifact"
);
}
@Override
public @NotNull Particle getParticle() {
return Particle.CRIMSON_SPORE;
}
}

View File

@ -1,18 +0,0 @@
package com.willfp.ecoenchants.enchantments.ecoenchants.artifact;
import com.willfp.ecoenchants.enchantments.itemtypes.Artifact;
import org.bukkit.Particle;
import org.jetbrains.annotations.NotNull;
public class DamageArtifact extends Artifact {
public DamageArtifact() {
super(
"damage_artifact"
);
}
@Override
public @NotNull Particle getParticle() {
return Particle.DAMAGE_INDICATOR;
}
}

View File

@ -1,18 +0,0 @@
package com.willfp.ecoenchants.enchantments.ecoenchants.artifact;
import com.willfp.ecoenchants.enchantments.itemtypes.Artifact;
import org.bukkit.Particle;
import org.jetbrains.annotations.NotNull;
public class DragonArtifact extends Artifact {
public DragonArtifact() {
super(
"dragon_artifact"
);
}
@Override
public @NotNull Particle getParticle() {
return Particle.DRAGON_BREATH;
}
}

View File

@ -1,18 +0,0 @@
package com.willfp.ecoenchants.enchantments.ecoenchants.artifact;
import com.willfp.ecoenchants.enchantments.itemtypes.Artifact;
import org.bukkit.Particle;
import org.jetbrains.annotations.NotNull;
public class DustArtifact extends Artifact {
public DustArtifact() {
super(
"dust_artifact"
);
}
@Override
public @NotNull Particle getParticle() {
return Particle.CRIT;
}
}

View File

@ -1,18 +0,0 @@
package com.willfp.ecoenchants.enchantments.ecoenchants.artifact;
import com.willfp.ecoenchants.enchantments.itemtypes.Artifact;
import org.bukkit.Particle;
import org.jetbrains.annotations.NotNull;
public class EmeraldArtifact extends Artifact {
public EmeraldArtifact() {
super(
"emerald_artifact"
);
}
@Override
public @NotNull Particle getParticle() {
return Particle.COMPOSTER;
}
}

View File

@ -1,18 +0,0 @@
package com.willfp.ecoenchants.enchantments.ecoenchants.artifact;
import com.willfp.ecoenchants.enchantments.itemtypes.Artifact;
import org.bukkit.Particle;
import org.jetbrains.annotations.NotNull;
public class EnchantmentArtifact extends Artifact {
public EnchantmentArtifact() {
super(
"enchantment_artifact"
);
}
@Override
public @NotNull Particle getParticle() {
return Particle.ENCHANTMENT_TABLE;
}
}

View File

@ -1,18 +0,0 @@
package com.willfp.ecoenchants.enchantments.ecoenchants.artifact;
import com.willfp.ecoenchants.enchantments.itemtypes.Artifact;
import org.bukkit.Particle;
import org.jetbrains.annotations.NotNull;
public class EndArtifact extends Artifact {
public EndArtifact() {
super(
"end_artifact"
);
}
@Override
public @NotNull Particle getParticle() {
return Particle.END_ROD;
}
}

View File

@ -1,18 +0,0 @@
package com.willfp.ecoenchants.enchantments.ecoenchants.artifact;
import com.willfp.ecoenchants.enchantments.itemtypes.Artifact;
import org.bukkit.Particle;
import org.jetbrains.annotations.NotNull;
public class FireArtifact extends Artifact {
public FireArtifact() {
super(
"fire_artifact"
);
}
@Override
public @NotNull Particle getParticle() {
return Particle.FLAME;
}
}

View File

@ -1,18 +0,0 @@
package com.willfp.ecoenchants.enchantments.ecoenchants.artifact;
import com.willfp.ecoenchants.enchantments.itemtypes.Artifact;
import org.bukkit.Particle;
import org.jetbrains.annotations.NotNull;
public class GlowArtifact extends Artifact {
public GlowArtifact() {
super(
"glow_artifact"
);
}
@Override
public @NotNull Particle getParticle() {
return Particle.GLOW;
}
}

View File

@ -1,18 +0,0 @@
package com.willfp.ecoenchants.enchantments.ecoenchants.artifact;
import com.willfp.ecoenchants.enchantments.itemtypes.Artifact;
import org.bukkit.Particle;
import org.jetbrains.annotations.NotNull;
public class HeartArtifact extends Artifact {
public HeartArtifact() {
super(
"heart_artifact"
);
}
@Override
public @NotNull Particle getParticle() {
return Particle.HEART;
}
}

View File

@ -1,18 +0,0 @@
package com.willfp.ecoenchants.enchantments.ecoenchants.artifact;
import com.willfp.ecoenchants.enchantments.itemtypes.Artifact;
import org.bukkit.Particle;
import org.jetbrains.annotations.NotNull;
public class HoneyArtifact extends Artifact {
public HoneyArtifact() {
super(
"honey_artifact"
);
}
@Override
public @NotNull Particle getParticle() {
return Particle.FALLING_HONEY;
}
}

View File

@ -1,18 +0,0 @@
package com.willfp.ecoenchants.enchantments.ecoenchants.artifact;
import com.willfp.ecoenchants.enchantments.itemtypes.Artifact;
import org.bukkit.Particle;
import org.jetbrains.annotations.NotNull;
public class InkArtifact extends Artifact {
public InkArtifact() {
super(
"ink_artifact"
);
}
@Override
public @NotNull Particle getParticle() {
return Particle.SQUID_INK;
}
}

View File

@ -1,18 +0,0 @@
package com.willfp.ecoenchants.enchantments.ecoenchants.artifact;
import com.willfp.ecoenchants.enchantments.itemtypes.Artifact;
import org.bukkit.Particle;
import org.jetbrains.annotations.NotNull;
public class LavaArtifact extends Artifact {
public LavaArtifact() {
super(
"lava_artifact"
);
}
@Override
public @NotNull Particle getParticle() {
return Particle.DRIP_LAVA;
}
}

View File

@ -1,24 +0,0 @@
package com.willfp.ecoenchants.enchantments.ecoenchants.artifact;
import com.willfp.ecoenchants.enchantments.itemtypes.Artifact;
import org.bukkit.Color;
import org.bukkit.Particle;
import org.jetbrains.annotations.NotNull;
public class LimeArtifact extends Artifact {
public LimeArtifact() {
super(
"lime_artifact"
);
}
@Override
public @NotNull Particle getParticle() {
return Particle.REDSTONE;
}
@Override
public Particle.DustOptions getDustOptions() {
return new Particle.DustOptions(Color.fromRGB(3, 252, 140), 1.0f);
}
}

View File

@ -1,18 +0,0 @@
package com.willfp.ecoenchants.enchantments.ecoenchants.artifact;
import com.willfp.ecoenchants.enchantments.itemtypes.Artifact;
import org.bukkit.Particle;
import org.jetbrains.annotations.NotNull;
public class MagicArtifact extends Artifact {
public MagicArtifact() {
super(
"magic_artifact"
);
}
@Override
public @NotNull Particle getParticle() {
return Particle.CRIT_MAGIC;
}
}

View File

@ -1,18 +0,0 @@
package com.willfp.ecoenchants.enchantments.ecoenchants.artifact;
import com.willfp.ecoenchants.enchantments.itemtypes.Artifact;
import org.bukkit.Particle;
import org.jetbrains.annotations.NotNull;
public class MagmaArtifact extends Artifact {
public MagmaArtifact() {
super(
"magma_artifact"
);
}
@Override
public @NotNull Particle getParticle() {
return Particle.LAVA;
}
}

View File

@ -1,18 +0,0 @@
package com.willfp.ecoenchants.enchantments.ecoenchants.artifact;
import com.willfp.ecoenchants.enchantments.itemtypes.Artifact;
import org.bukkit.Particle;
import org.jetbrains.annotations.NotNull;
public class MusicArtifact extends Artifact {
public MusicArtifact() {
super(
"music_artifact"
);
}
@Override
public @NotNull Particle getParticle() {
return Particle.NOTE;
}
}

View File

@ -1,18 +0,0 @@
package com.willfp.ecoenchants.enchantments.ecoenchants.artifact;
import com.willfp.ecoenchants.enchantments.itemtypes.Artifact;
import org.bukkit.Particle;
import org.jetbrains.annotations.NotNull;
public class NautilusArtifact extends Artifact {
public NautilusArtifact() {
super(
"nautilus_artifact"
);
}
@Override
public @NotNull Particle getParticle() {
return Particle.NAUTILUS;
}
}

View File

@ -1,18 +0,0 @@
package com.willfp.ecoenchants.enchantments.ecoenchants.artifact;
import com.willfp.ecoenchants.enchantments.itemtypes.Artifact;
import org.bukkit.Particle;
import org.jetbrains.annotations.NotNull;
public class NetherArtifact extends Artifact {
public NetherArtifact() {
super(
"nether_artifact"
);
}
@Override
public @NotNull Particle getParticle() {
return Particle.PORTAL;
}
}

View File

@ -1,18 +0,0 @@
package com.willfp.ecoenchants.enchantments.ecoenchants.artifact;
import com.willfp.ecoenchants.enchantments.itemtypes.Artifact;
import org.bukkit.Particle;
import org.jetbrains.annotations.NotNull;
public class RainArtifact extends Artifact {
public RainArtifact() {
super(
"rain_artifact"
);
}
@Override
public @NotNull Particle getParticle() {
return Particle.WATER_SPLASH;
}
}

View File

@ -1,24 +0,0 @@
package com.willfp.ecoenchants.enchantments.ecoenchants.artifact;
import com.willfp.ecoenchants.enchantments.itemtypes.Artifact;
import org.bukkit.Color;
import org.bukkit.Particle;
import org.jetbrains.annotations.NotNull;
public class RedstoneArtifact extends Artifact {
public RedstoneArtifact() {
super(
"redstone_artifact"
);
}
@Override
public @NotNull Particle getParticle() {
return Particle.REDSTONE;
}
@Override
public Particle.DustOptions getDustOptions() {
return new Particle.DustOptions(Color.RED, 1.0f);
}
}

View File

@ -1,18 +0,0 @@
package com.willfp.ecoenchants.enchantments.ecoenchants.artifact;
import com.willfp.ecoenchants.enchantments.itemtypes.Artifact;
import org.bukkit.Particle;
import org.jetbrains.annotations.NotNull;
public class SlimeArtifact extends Artifact {
public SlimeArtifact() {
super(
"slime_artifact"
);
}
@Override
public @NotNull Particle getParticle() {
return Particle.SLIME;
}
}

View File

@ -1,18 +0,0 @@
package com.willfp.ecoenchants.enchantments.ecoenchants.artifact;
import com.willfp.ecoenchants.enchantments.itemtypes.Artifact;
import org.bukkit.Particle;
import org.jetbrains.annotations.NotNull;
public class SmokeArtifact extends Artifact {
public SmokeArtifact() {
super(
"smoke_artifact"
);
}
@Override
public @NotNull Particle getParticle() {
return Particle.CAMPFIRE_COSY_SMOKE;
}
}

View File

@ -1,18 +0,0 @@
package com.willfp.ecoenchants.enchantments.ecoenchants.artifact;
import com.willfp.ecoenchants.enchantments.itemtypes.Artifact;
import org.bukkit.Particle;
import org.jetbrains.annotations.NotNull;
public class SnowArtifact extends Artifact {
public SnowArtifact() {
super(
"snow_artifact"
);
}
@Override
public @NotNull Particle getParticle() {
return Particle.SNOWBALL;
}
}

View File

@ -1,18 +0,0 @@
package com.willfp.ecoenchants.enchantments.ecoenchants.artifact;
import com.willfp.ecoenchants.enchantments.itemtypes.Artifact;
import org.bukkit.Particle;
import org.jetbrains.annotations.NotNull;
public class SoulArtifact extends Artifact {
public SoulArtifact() {
super(
"soul_artifact"
);
}
@Override
public @NotNull Particle getParticle() {
return Particle.SOUL;
}
}

View File

@ -1,18 +0,0 @@
package com.willfp.ecoenchants.enchantments.ecoenchants.artifact;
import com.willfp.ecoenchants.enchantments.itemtypes.Artifact;
import org.bukkit.Particle;
import org.jetbrains.annotations.NotNull;
public class SoulFireArtifact extends Artifact {
public SoulFireArtifact() {
super(
"soul_fire_artifact"
);
}
@Override
public @NotNull Particle getParticle() {
return Particle.SOUL_FIRE_FLAME;
}
}

View File

@ -1,18 +0,0 @@
package com.willfp.ecoenchants.enchantments.ecoenchants.artifact;
import com.willfp.ecoenchants.enchantments.itemtypes.Artifact;
import org.bukkit.Particle;
import org.jetbrains.annotations.NotNull;
public class SparkArtifact extends Artifact {
public SparkArtifact() {
super(
"spark_artifact"
);
}
@Override
public @NotNull Particle getParticle() {
return Particle.ELECTRIC_SPARK;
}
}

Some files were not shown because too many files have changed in this diff Show More