diff --git a/.classpath b/.classpath deleted file mode 100644 index 22045f1..0000000 --- a/.classpath +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - - diff --git a/.gitignore b/.gitignore index f91ff2b..cf72b0d 100644 --- a/.gitignore +++ b/.gitignore @@ -1,216 +1,128 @@ -################# -## Eclipse -################# +# Java .gitignore from https://github.com/github/gitignore/blob/main/Java.gitignore +# Compiled class file +*.class -*.pydevproject +# Log file +*.log + +# BlueJ files +*.ctxt + +# Mobile Tools for Java (J2ME) +.mtj.tmp/ + +# Package Files # +*.jar +*.war +*.nar +*.ear +*.zip +*.tar.gz +*.rar + +# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml +hs_err_pid* +replay_pid* + +# Gradle .gitignore from https://github.com/github/gitignore/blob/main/Gradle.gitignore +.gradle +**/build/ +!src/**/build/ + +# Ignore Gradle GUI config +gradle-app.setting + +# Avoid ignoring Gradle wrapper jar file (.jar files are usually ignored) +!gradle-wrapper.jar + +# Avoid ignore Gradle wrappper properties +!gradle-wrapper.properties + +# Cache of project +.gradletasknamecache + +# Eclipse Gradle plugin generated files +# Eclipse Core .project -.metadata -bin/ -tmp/ -*.tmp -*.bak -*.swp -*~.nib -local.properties +# JDT-specific (Eclipse Java Development Tools) .classpath -.settings/ -.loadpath - -# External tool builders -.externalToolBuilders/ - -# Locally stored "Eclipse launch configurations" -*.launch - -# CDT-specific -.cproject - -# PDT-specific -.buildpath - - -################# -## Visual Studio -################# - -## Ignore Visual Studio temporary files, build results, and -## files generated by popular Visual Studio add-ons. - -# User-specific files -*.suo -*.user -*.sln.docstates - -# Build results - -[Dd]ebug/ -[Rr]elease/ -x64/ -build/ -[Bb]in/ -[Oo]bj/ - -# MSTest test Results -[Tt]est[Rr]esult*/ -[Bb]uild[Ll]og.* - -*_i.c -*_p.c -*.ilk -*.meta -*.obj -*.pch -*.pdb -*.pgc -*.pgd -*.rsp -*.sbr -*.tlb -*.tli -*.tlh -*.tmp -*.tmp_proj -*.log -*.vspscc -*.vssscc -.builds -*.pidb -*.log -*.scc - -# Visual C++ cache files -ipch/ -*.aps -*.ncb -*.opensdf -*.sdf -*.cachefile - -# Visual Studio profiler -*.psess -*.vsp -*.vspx - -# Guidance Automation Toolkit -*.gpState - -# ReSharper is a .NET coding add-in -_ReSharper*/ -*.[Rr]e[Ss]harper - -# TeamCity is a build add-in -_TeamCity* - -# DotCover is a Code Coverage Tool -*.dotCover - -# NCrunch -*.ncrunch* -.*crunch*.local.xml - -# Installshield output folder -[Ee]xpress/ - -# DocProject is a documentation generator add-in -DocProject/buildhelp/ -DocProject/Help/*.HxT -DocProject/Help/*.HxC -DocProject/Help/*.hhc -DocProject/Help/*.hhk -DocProject/Help/*.hhp -DocProject/Help/Html2 -DocProject/Help/html - -# Click-Once directory -publish/ - -# Publish Web Output -*.Publish.xml -*.pubxml -*.publishproj - -# NuGet Packages Directory -## TODO: If you have NuGet Package Restore enabled, uncomment the next line -#packages/ - -# Windows Azure Build Output -csx -*.build.csdef - -# Windows Store app package directory -AppPackages/ - -# Others -sql/ -*.Cache -ClientBin/ -[Ss]tyle[Cc]op.* -~$* -*~ -*.dbmdl -*.[Pp]ublish.xml -*.pfx -*.publishsettings - -# RIA/Silverlight projects -Generated_Code/ - -# Backup & report files from converting an old project file to a newer -# Visual Studio version. Backup files are not needed, because we have git ;-) -_UpgradeReport_Files/ -Backup*/ -UpgradeLog*.XML -UpgradeLog*.htm - -# SQL Server files -App_Data/*.mdf -App_Data/*.ldf - -############# -## Windows detritus -############# - -# Windows image file caches -Thumbs.db -ehthumbs.db - -# Folder config file -Desktop.ini - -# Recycle Bin used on file shares -$RECYCLE.BIN/ - -# Mac crap -.DS_Store - - -############# -## Python -############# - -*.py[cod] - -# Packages -*.egg -*.egg-info -dist/ -build/ -eggs/ -parts/ -var/ -sdist/ -develop-eggs/ -.installed.cfg - -# Installer logs -pip-log.txt - -# Unit test / coverage reports -.coverage -.tox - -#Translations -*.mo - -#Mr Developer -.mr.developer.cfg + +# JetBrains IDE .gitignore from https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore +# User-specific stuff +.idea/**/workspace.xml +.idea/**/tasks.xml +.idea/**/usage.statistics.xml +.idea/**/dictionaries +.idea/**/shelf +.idea/misc.xml +.idea/vcs.xml +.idea/.name +.idea/.gitignore + +# AWS User-specific +.idea/**/aws.xml + +# Generated files +.idea/**/contentModel.xml + +# Sensitive or high-churn files +.idea/**/dataSources/ +.idea/**/dataSources.ids +.idea/**/dataSources.local.xml +.idea/**/sqlDataSources.xml +.idea/**/dynamic.xml +.idea/**/uiDesigner.xml +.idea/**/dbnavigator.xml + +# Gradle +.idea/**/gradle.xml +.idea/**/libraries + +# Gradle and Maven with auto-import +# When using Gradle or Maven with auto-import, you should exclude module files, +# since they will be recreated, and may cause churn. Uncomment if using +# auto-import. +.idea/artifacts +.idea/compiler.xml +.idea/jarRepositories.xml +.idea/modules.xml +.idea/*.iml +.idea/modules +*.iml +*.ipr + +# CMake +cmake-build-*/ + +# Mongo Explorer plugin +.idea/**/mongoSettings.xml + +# File-based project format +*.iws + +# IntelliJ +out/ + +# mpeltonen/sbt-idea plugin +.idea_modules/ + +# JIRA plugin +atlassian-ide-plugin.xml + +# Cursive Clojure plugin +.idea/replstate.xml + +# SonarLint plugin +.idea/sonarlint/ + +# Crashlytics plugin (for Android Studio and IntelliJ) +com_crashlytics_export_strings.xml +crashlytics.properties +crashlytics-build.properties +fabric.properties + +# Editor-based Rest Client +.idea/httpRequests + +# Android studio 3.1+ serialized cache file +.idea/caches/build_file_checksums.ser diff --git a/.project b/.project deleted file mode 100644 index e71bce8..0000000 --- a/.project +++ /dev/null @@ -1,17 +0,0 @@ - - - ProjectKorraItems - - - - - - org.eclipse.jdt.core.javabuilder - - - - - - org.eclipse.jdt.core.javanature - - diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..f288702 --- /dev/null +++ b/LICENSE @@ -0,0 +1,674 @@ + GNU GENERAL PUBLIC LICENSE + Version 3, 29 June 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The GNU General Public License is a free, copyleft license for +software and other kinds of works. + + The licenses for most software and other practical works are designed +to take away your freedom to share and change the works. By contrast, +the GNU General Public License is intended to guarantee your freedom to +share and change all versions of a program--to make sure it remains free +software for all its users. We, the Free Software Foundation, use the +GNU General Public License for most of our software; it applies also to +any other work released this way by its authors. You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +them if you wish), that you receive source code or can get it if you +want it, that you can change the software or use pieces of it in new +free programs, and that you know you can do these things. + + To protect your rights, we need to prevent others from denying you +these rights or asking you to surrender the rights. Therefore, you have +certain responsibilities if you distribute copies of the software, or if +you modify it: responsibilities to respect the freedom of others. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must pass on to the recipients the same +freedoms that you received. You must make sure that they, too, receive +or can get the source code. And you must show them these terms so they +know their rights. + + Developers that use the GNU GPL protect your rights with two steps: +(1) assert copyright on the software, and (2) offer you this License +giving you legal permission to copy, distribute and/or modify it. + + For the developers' and authors' protection, the GPL clearly explains +that there is no warranty for this free software. For both users' and +authors' sake, the GPL requires that modified versions be marked as +changed, so that their problems will not be attributed erroneously to +authors of previous versions. + + Some devices are designed to deny users access to install or run +modified versions of the software inside them, although the manufacturer +can do so. This is fundamentally incompatible with the aim of +protecting users' freedom to change the software. The systematic +pattern of such abuse occurs in the area of products for individuals to +use, which is precisely where it is most unacceptable. Therefore, we +have designed this version of the GPL to prohibit the practice for those +products. If such problems arise substantially in other domains, we +stand ready to extend this provision to those domains in future versions +of the GPL, as needed to protect the freedom of users. + + Finally, every program is threatened constantly by software patents. +States should not allow patents to restrict development and use of +software on general-purpose computers, but in those that do, we wish to +avoid the special danger that patents applied to a free program could +make it effectively proprietary. To prevent this, the GPL assures that +patents cannot be used to render the program non-free. + + The precise terms and conditions for copying, distribution and +modification follow. + + TERMS AND CONDITIONS + + 0. Definitions. + + "This License" refers to version 3 of the GNU General Public License. + + "Copyright" also means copyright-like laws that apply to other kinds of +works, such as semiconductor masks. + + "The Program" refers to any copyrightable work licensed under this +License. Each licensee is addressed as "you". "Licensees" and +"recipients" may be individuals or organizations. + + To "modify" a work means to copy from or adapt all or part of the work +in a fashion requiring copyright permission, other than the making of an +exact copy. The resulting work is called a "modified version" of the +earlier work or a work "based on" the earlier work. + + A "covered work" means either the unmodified Program or a work based +on the Program. + + To "propagate" a work means to do anything with it that, without +permission, would make you directly or secondarily liable for +infringement under applicable copyright law, except executing it on a +computer or modifying a private copy. Propagation includes copying, +distribution (with or without modification), making available to the +public, and in some countries other activities as well. + + To "convey" a work means any kind of propagation that enables other +parties to make or receive copies. Mere interaction with a user through +a computer network, with no transfer of a copy, is not conveying. + + An interactive user interface displays "Appropriate Legal Notices" +to the extent that it includes a convenient and prominently visible +feature that (1) displays an appropriate copyright notice, and (2) +tells the user that there is no warranty for the work (except to the +extent that warranties are provided), that licensees may convey the +work under this License, and how to view a copy of this License. If +the interface presents a list of user commands or options, such as a +menu, a prominent item in the list meets this criterion. + + 1. Source Code. + + The "source code" for a work means the preferred form of the work +for making modifications to it. "Object code" means any non-source +form of a work. + + A "Standard Interface" means an interface that either is an official +standard defined by a recognized standards body, or, in the case of +interfaces specified for a particular programming language, one that +is widely used among developers working in that language. + + The "System Libraries" of an executable work include anything, other +than the work as a whole, that (a) is included in the normal form of +packaging a Major Component, but which is not part of that Major +Component, and (b) serves only to enable use of the work with that +Major Component, or to implement a Standard Interface for which an +implementation is available to the public in source code form. A +"Major Component", in this context, means a major essential component +(kernel, window system, and so on) of the specific operating system +(if any) on which the executable work runs, or a compiler used to +produce the work, or an object code interpreter used to run it. + + The "Corresponding Source" for a work in object code form means all +the source code needed to generate, install, and (for an executable +work) run the object code and to modify the work, including scripts to +control those activities. However, it does not include the work's +System Libraries, or general-purpose tools or generally available free +programs which are used unmodified in performing those activities but +which are not part of the work. For example, Corresponding Source +includes interface definition files associated with source files for +the work, and the source code for shared libraries and dynamically +linked subprograms that the work is specifically designed to require, +such as by intimate data communication or control flow between those +subprograms and other parts of the work. + + The Corresponding Source need not include anything that users +can regenerate automatically from other parts of the Corresponding +Source. + + The Corresponding Source for a work in source code form is that +same work. + + 2. Basic Permissions. + + All rights granted under this License are granted for the term of +copyright on the Program, and are irrevocable provided the stated +conditions are met. This License explicitly affirms your unlimited +permission to run the unmodified Program. The output from running a +covered work is covered by this License only if the output, given its +content, constitutes a covered work. This License acknowledges your +rights of fair use or other equivalent, as provided by copyright law. + + You may make, run and propagate covered works that you do not +convey, without conditions so long as your license otherwise remains +in force. You may convey covered works to others for the sole purpose +of having them make modifications exclusively for you, or provide you +with facilities for running those works, provided that you comply with +the terms of this License in conveying all material for which you do +not control copyright. Those thus making or running the covered works +for you must do so exclusively on your behalf, under your direction +and control, on terms that prohibit them from making any copies of +your copyrighted material outside their relationship with you. + + Conveying under any other circumstances is permitted solely under +the conditions stated below. Sublicensing is not allowed; section 10 +makes it unnecessary. + + 3. Protecting Users' Legal Rights From Anti-Circumvention Law. + + No covered work shall be deemed part of an effective technological +measure under any applicable law fulfilling obligations under article +11 of the WIPO copyright treaty adopted on 20 December 1996, or +similar laws prohibiting or restricting circumvention of such +measures. + + When you convey a covered work, you waive any legal power to forbid +circumvention of technological measures to the extent such circumvention +is effected by exercising rights under this License with respect to +the covered work, and you disclaim any intention to limit operation or +modification of the work as a means of enforcing, against the work's +users, your or third parties' legal rights to forbid circumvention of +technological measures. + + 4. Conveying Verbatim Copies. + + You may convey verbatim copies of the Program's source code as you +receive it, in any medium, provided that you conspicuously and +appropriately publish on each copy an appropriate copyright notice; +keep intact all notices stating that this License and any +non-permissive terms added in accord with section 7 apply to the code; +keep intact all notices of the absence of any warranty; and give all +recipients a copy of this License along with the Program. + + You may charge any price or no price for each copy that you convey, +and you may offer support or warranty protection for a fee. + + 5. Conveying Modified Source Versions. + + You may convey a work based on the Program, or the modifications to +produce it from the Program, in the form of source code under the +terms of section 4, provided that you also meet all of these conditions: + + a) The work must carry prominent notices stating that you modified + it, and giving a relevant date. + + b) The work must carry prominent notices stating that it is + released under this License and any conditions added under section + 7. This requirement modifies the requirement in section 4 to + "keep intact all notices". + + c) You must license the entire work, as a whole, under this + License to anyone who comes into possession of a copy. This + License will therefore apply, along with any applicable section 7 + additional terms, to the whole of the work, and all its parts, + regardless of how they are packaged. This License gives no + permission to license the work in any other way, but it does not + invalidate such permission if you have separately received it. + + d) If the work has interactive user interfaces, each must display + Appropriate Legal Notices; however, if the Program has interactive + interfaces that do not display Appropriate Legal Notices, your + work need not make them do so. + + A compilation of a covered work with other separate and independent +works, which are not by their nature extensions of the covered work, +and which are not combined with it such as to form a larger program, +in or on a volume of a storage or distribution medium, is called an +"aggregate" if the compilation and its resulting copyright are not +used to limit the access or legal rights of the compilation's users +beyond what the individual works permit. Inclusion of a covered work +in an aggregate does not cause this License to apply to the other +parts of the aggregate. + + 6. Conveying Non-Source Forms. + + You may convey a covered work in object code form under the terms +of sections 4 and 5, provided that you also convey the +machine-readable Corresponding Source under the terms of this License, +in one of these ways: + + a) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by the + Corresponding Source fixed on a durable physical medium + customarily used for software interchange. + + b) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by a + written offer, valid for at least three years and valid for as + long as you offer spare parts or customer support for that product + model, to give anyone who possesses the object code either (1) a + copy of the Corresponding Source for all the software in the + product that is covered by this License, on a durable physical + medium customarily used for software interchange, for a price no + more than your reasonable cost of physically performing this + conveying of source, or (2) access to copy the + Corresponding Source from a network server at no charge. + + c) Convey individual copies of the object code with a copy of the + written offer to provide the Corresponding Source. This + alternative is allowed only occasionally and noncommercially, and + only if you received the object code with such an offer, in accord + with subsection 6b. + + d) Convey the object code by offering access from a designated + place (gratis or for a charge), and offer equivalent access to the + Corresponding Source in the same way through the same place at no + further charge. You need not require recipients to copy the + Corresponding Source along with the object code. If the place to + copy the object code is a network server, the Corresponding Source + may be on a different server (operated by you or a third party) + that supports equivalent copying facilities, provided you maintain + clear directions next to the object code saying where to find the + Corresponding Source. Regardless of what server hosts the + Corresponding Source, you remain obligated to ensure that it is + available for as long as needed to satisfy these requirements. + + e) Convey the object code using peer-to-peer transmission, provided + you inform other peers where the object code and Corresponding + Source of the work are being offered to the general public at no + charge under subsection 6d. + + A separable portion of the object code, whose source code is excluded +from the Corresponding Source as a System Library, need not be +included in conveying the object code work. + + A "User Product" is either (1) a "consumer product", which means any +tangible personal property which is normally used for personal, family, +or household purposes, or (2) anything designed or sold for incorporation +into a dwelling. In determining whether a product is a consumer product, +doubtful cases shall be resolved in favor of coverage. For a particular +product received by a particular user, "normally used" refers to a +typical or common use of that class of product, regardless of the status +of the particular user or of the way in which the particular user +actually uses, or expects or is expected to use, the product. A product +is a consumer product regardless of whether the product has substantial +commercial, industrial or non-consumer uses, unless such uses represent +the only significant mode of use of the product. + + "Installation Information" for a User Product means any methods, +procedures, authorization keys, or other information required to install +and execute modified versions of a covered work in that User Product from +a modified version of its Corresponding Source. The information must +suffice to ensure that the continued functioning of the modified object +code is in no case prevented or interfered with solely because +modification has been made. + + If you convey an object code work under this section in, or with, or +specifically for use in, a User Product, and the conveying occurs as +part of a transaction in which the right of possession and use of the +User Product is transferred to the recipient in perpetuity or for a +fixed term (regardless of how the transaction is characterized), the +Corresponding Source conveyed under this section must be accompanied +by the Installation Information. But this requirement does not apply +if neither you nor any third party retains the ability to install +modified object code on the User Product (for example, the work has +been installed in ROM). + + The requirement to provide Installation Information does not include a +requirement to continue to provide support service, warranty, or updates +for a work that has been modified or installed by the recipient, or for +the User Product in which it has been modified or installed. Access to a +network may be denied when the modification itself materially and +adversely affects the operation of the network or violates the rules and +protocols for communication across the network. + + Corresponding Source conveyed, and Installation Information provided, +in accord with this section must be in a format that is publicly +documented (and with an implementation available to the public in +source code form), and must require no special password or key for +unpacking, reading or copying. + + 7. Additional Terms. + + "Additional permissions" are terms that supplement the terms of this +License by making exceptions from one or more of its conditions. +Additional permissions that are applicable to the entire Program shall +be treated as though they were included in this License, to the extent +that they are valid under applicable law. If additional permissions +apply only to part of the Program, that part may be used separately +under those permissions, but the entire Program remains governed by +this License without regard to the additional permissions. + + When you convey a copy of a covered work, you may at your option +remove any additional permissions from that copy, or from any part of +it. (Additional permissions may be written to require their own +removal in certain cases when you modify the work.) You may place +additional permissions on material, added by you to a covered work, +for which you have or can give appropriate copyright permission. + + Notwithstanding any other provision of this License, for material you +add to a covered work, you may (if authorized by the copyright holders of +that material) supplement the terms of this License with terms: + + a) Disclaiming warranty or limiting liability differently from the + terms of sections 15 and 16 of this License; or + + b) Requiring preservation of specified reasonable legal notices or + author attributions in that material or in the Appropriate Legal + Notices displayed by works containing it; or + + c) Prohibiting misrepresentation of the origin of that material, or + requiring that modified versions of such material be marked in + reasonable ways as different from the original version; or + + d) Limiting the use for publicity purposes of names of licensors or + authors of the material; or + + e) Declining to grant rights under trademark law for use of some + trade names, trademarks, or service marks; or + + f) Requiring indemnification of licensors and authors of that + material by anyone who conveys the material (or modified versions of + it) with contractual assumptions of liability to the recipient, for + any liability that these contractual assumptions directly impose on + those licensors and authors. + + All other non-permissive additional terms are considered "further +restrictions" within the meaning of section 10. If the Program as you +received it, or any part of it, contains a notice stating that it is +governed by this License along with a term that is a further +restriction, you may remove that term. If a license document contains +a further restriction but permits relicensing or conveying under this +License, you may add to a covered work material governed by the terms +of that license document, provided that the further restriction does +not survive such relicensing or conveying. + + If you add terms to a covered work in accord with this section, you +must place, in the relevant source files, a statement of the +additional terms that apply to those files, or a notice indicating +where to find the applicable terms. + + Additional terms, permissive or non-permissive, may be stated in the +form of a separately written license, or stated as exceptions; +the above requirements apply either way. + + 8. Termination. + + You may not propagate or modify a covered work except as expressly +provided under this License. Any attempt otherwise to propagate or +modify it is void, and will automatically terminate your rights under +this License (including any patent licenses granted under the third +paragraph of section 11). + + However, if you cease all violation of this License, then your +license from a particular copyright holder is reinstated (a) +provisionally, unless and until the copyright holder explicitly and +finally terminates your license, and (b) permanently, if the copyright +holder fails to notify you of the violation by some reasonable means +prior to 60 days after the cessation. + + Moreover, your license from a particular copyright holder is +reinstated permanently if the copyright holder notifies you of the +violation by some reasonable means, this is the first time you have +received notice of violation of this License (for any work) from that +copyright holder, and you cure the violation prior to 30 days after +your receipt of the notice. + + Termination of your rights under this section does not terminate the +licenses of parties who have received copies or rights from you under +this License. If your rights have been terminated and not permanently +reinstated, you do not qualify to receive new licenses for the same +material under section 10. + + 9. Acceptance Not Required for Having Copies. + + You are not required to accept this License in order to receive or +run a copy of the Program. Ancillary propagation of a covered work +occurring solely as a consequence of using peer-to-peer transmission +to receive a copy likewise does not require acceptance. However, +nothing other than this License grants you permission to propagate or +modify any covered work. These actions infringe copyright if you do +not accept this License. Therefore, by modifying or propagating a +covered work, you indicate your acceptance of this License to do so. + + 10. Automatic Licensing of Downstream Recipients. + + Each time you convey a covered work, the recipient automatically +receives a license from the original licensors, to run, modify and +propagate that work, subject to this License. You are not responsible +for enforcing compliance by third parties with this License. + + An "entity transaction" is a transaction transferring control of an +organization, or substantially all assets of one, or subdividing an +organization, or merging organizations. If propagation of a covered +work results from an entity transaction, each party to that +transaction who receives a copy of the work also receives whatever +licenses to the work the party's predecessor in interest had or could +give under the previous paragraph, plus a right to possession of the +Corresponding Source of the work from the predecessor in interest, if +the predecessor has it or can get it with reasonable efforts. + + You may not impose any further restrictions on the exercise of the +rights granted or affirmed under this License. For example, you may +not impose a license fee, royalty, or other charge for exercise of +rights granted under this License, and you may not initiate litigation +(including a cross-claim or counterclaim in a lawsuit) alleging that +any patent claim is infringed by making, using, selling, offering for +sale, or importing the Program or any portion of it. + + 11. Patents. + + A "contributor" is a copyright holder who authorizes use under this +License of the Program or a work on which the Program is based. The +work thus licensed is called the contributor's "contributor version". + + A contributor's "essential patent claims" are all patent claims +owned or controlled by the contributor, whether already acquired or +hereafter acquired, that would be infringed by some manner, permitted +by this License, of making, using, or selling its contributor version, +but do not include claims that would be infringed only as a +consequence of further modification of the contributor version. For +purposes of this definition, "control" includes the right to grant +patent sublicenses in a manner consistent with the requirements of +this License. + + Each contributor grants you a non-exclusive, worldwide, royalty-free +patent license under the contributor's essential patent claims, to +make, use, sell, offer for sale, import and otherwise run, modify and +propagate the contents of its contributor version. + + In the following three paragraphs, a "patent license" is any express +agreement or commitment, however denominated, not to enforce a patent +(such as an express permission to practice a patent or covenant not to +sue for patent infringement). To "grant" such a patent license to a +party means to make such an agreement or commitment not to enforce a +patent against the party. + + If you convey a covered work, knowingly relying on a patent license, +and the Corresponding Source of the work is not available for anyone +to copy, free of charge and under the terms of this License, through a +publicly available network server or other readily accessible means, +then you must either (1) cause the Corresponding Source to be so +available, or (2) arrange to deprive yourself of the benefit of the +patent license for this particular work, or (3) arrange, in a manner +consistent with the requirements of this License, to extend the patent +license to downstream recipients. "Knowingly relying" means you have +actual knowledge that, but for the patent license, your conveying the +covered work in a country, or your recipient's use of the covered work +in a country, would infringe one or more identifiable patents in that +country that you have reason to believe are valid. + + If, pursuant to or in connection with a single transaction or +arrangement, you convey, or propagate by procuring conveyance of, a +covered work, and grant a patent license to some of the parties +receiving the covered work authorizing them to use, propagate, modify +or convey a specific copy of the covered work, then the patent license +you grant is automatically extended to all recipients of the covered +work and works based on it. + + A patent license is "discriminatory" if it does not include within +the scope of its coverage, prohibits the exercise of, or is +conditioned on the non-exercise of one or more of the rights that are +specifically granted under this License. You may not convey a covered +work if you are a party to an arrangement with a third party that is +in the business of distributing software, under which you make payment +to the third party based on the extent of your activity of conveying +the work, and under which the third party grants, to any of the +parties who would receive the covered work from you, a discriminatory +patent license (a) in connection with copies of the covered work +conveyed by you (or copies made from those copies), or (b) primarily +for and in connection with specific products or compilations that +contain the covered work, unless you entered into that arrangement, +or that patent license was granted, prior to 28 March 2007. + + Nothing in this License shall be construed as excluding or limiting +any implied license or other defenses to infringement that may +otherwise be available to you under applicable patent law. + + 12. No Surrender of Others' Freedom. + + If conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot convey a +covered work so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you may +not convey it at all. For example, if you agree to terms that obligate you +to collect a royalty for further conveying from those to whom you convey +the Program, the only way you could satisfy both those terms and this +License would be to refrain entirely from conveying the Program. + + 13. Use with the GNU Affero General Public License. + + Notwithstanding any other provision of this License, you have +permission to link or combine any covered work with a work licensed +under version 3 of the GNU Affero General Public License into a single +combined work, and to convey the resulting work. The terms of this +License will continue to apply to the part which is the covered work, +but the special requirements of the GNU Affero General Public License, +section 13, concerning interaction through a network will apply to the +combination as such. + + 14. Revised Versions of this License. + + The Free Software Foundation may publish revised and/or new versions of +the GNU General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + + Each version is given a distinguishing version number. If the +Program specifies that a certain numbered version of the GNU General +Public License "or any later version" applies to it, you have the +option of following the terms and conditions either of that numbered +version or of any later version published by the Free Software +Foundation. If the Program does not specify a version number of the +GNU General Public License, you may choose any version ever published +by the Free Software Foundation. + + If the Program specifies that a proxy can decide which future +versions of the GNU General Public License can be used, that proxy's +public statement of acceptance of a version permanently authorizes you +to choose that version for the Program. + + Later license versions may give you additional or different +permissions. However, no additional obligations are imposed on any +author or copyright holder as a result of your choosing to follow a +later version. + + 15. Disclaimer of Warranty. + + THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY +APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT +HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY +OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, +THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM +IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF +ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. Limitation of Liability. + + IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS +THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY +GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE +USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF +DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD +PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), +EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF +SUCH DAMAGES. + + 17. Interpretation of Sections 15 and 16. + + If the disclaimer of warranty and limitation of liability provided +above cannot be given local legal effect according to their terms, +reviewing courts shall apply local law that most closely approximates +an absolute waiver of all civil liability in connection with the +Program, unless a warranty or assumption of liability accompanies a +copy of the Program in return for a fee. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +state the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . + +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: + + Copyright (C) + This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, your program's commands +might be different; for a GUI interface, you would use an "about box". + + You should also get your employer (if you work as a programmer) or school, +if any, to sign a "copyright disclaimer" for the program, if necessary. +For more information on this, and how to apply and follow the GNU GPL, see +. + + The GNU General Public License does not permit incorporating your program +into proprietary programs. If your program is a subroutine library, you +may consider it more useful to permit linking proprietary applications with +the library. If this is what you want to do, use the GNU Lesser General +Public License instead of this License. But first, please read +. diff --git a/README.md b/README.md new file mode 100644 index 0000000..ee4b665 --- /dev/null +++ b/README.md @@ -0,0 +1 @@ +Custom ProjectKorra items. diff --git a/build.gradle.kts b/build.gradle.kts new file mode 100644 index 0000000..5ecb7c4 --- /dev/null +++ b/build.gradle.kts @@ -0,0 +1,121 @@ +import com.github.spotbugs.snom.Confidence +import com.github.spotbugs.snom.Effort + +plugins { + `java-library` + alias(libs.plugins.shadowPlugin) + alias(libs.plugins.generatePOMPlugin) + alias(libs.plugins.spotBugsPlugin) + //alias(libs.plugins.userdevPlugin) // NMS +} + +group = "com.projectkorra" +version = "2.0.0-SNAPSHOT" +description = "Custom ProjectKorra items" +base.archivesName = gradle.extra["projectName"].toString() + +ext.set("projectName", base.archivesName) +maven.pom { + name = gradle.extra["projectName"].toString() +} + +java { + toolchain { + languageVersion = JavaLanguageVersion.of(21) + vendor = JvmVendorSpec.ORACLE + } +} + +repositories { + gradlePluginPortal { + content { + includeGroup("com.gradleup") + includeGroup("io.papermc.paperweight") + } + } + maven { + url = uri("https://repo.papermc.io/repository/maven-public/") + content { + includeGroup("io.papermc.paper") + includeGroup("com.mojang") + includeGroup("net.md-5") + } + } + maven { + url = uri("https://repo.oraxen.com/releases") + content { + includeGroup("io.th0rgal") + } + } + maven { + url = uri("https://jitpack.io") + content { + includeGroupByRegex("com\\.github\\..*") + } + } + mavenCentral() + // mavenLocal() +} + +dependencies { + //paperweight.paperDevBundle("1.21.1-R0.1-SNAPSHOT") // NMS + compileOnly(libs.papermc.paperapi) + compileOnly(libs.projectkorra.core) + compileOnly(libs.thorgal.oraxen) { + isTransitive = false + } +} + +tasks.withType { + options.encoding = "UTF-8" +} + +tasks.withType { + options.encoding = "UTF-8" +} + +tasks { + processResources { + filesMatching("**/plugin.yml") { + expand( project.properties ) + } + } + + spotbugsMain { + reports.create("html") { + required = true + outputLocation = file("${layout.buildDirectory.get()}/reports/spotbugs.html") + setStylesheet("fancy-hist.xsl") + } + } +} + +spotbugs { + ignoreFailures = false + showStackTraces = true + showProgress = true + effort = Effort.DEFAULT + reportLevel = Confidence.DEFAULT +} + +// 1) +// For >=1.20.5 when you don't care about supporting spigot +//paperweight.reobfArtifactConfiguration = io.papermc.paperweight.userdev.ReobfArtifactConfiguration.MOJANG_PRODUCTION + +// 2) +// For 1.20.4 or below, or when you care about supporting Spigot on >=1.20.5 +// Configure reobfJar to run when invoking the build task +//tasks.assemble { +// dependsOn(tasks.reobfJar) +//} + +// Configure plugin.yml generation +// - name, version, and description are inherited from the Gradle project. +/* +bukkitPluginYaml { + main = "io.papermc.paperweight.testplugin.TestPlugin" + load = BukkitPluginYaml.PluginLoadOrder.STARTUP + authors.add("Author") + apiVersion = "1.21" +} +*/ \ No newline at end of file diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml new file mode 100644 index 0000000..944bf1d --- /dev/null +++ b/gradle/libs.versions.toml @@ -0,0 +1,19 @@ +[plugins] +shadowPlugin = { id = "com.gradleup.shadow", version.ref = "shadowGradlePlugin" } +generatePOMPlugin = { id = "ru.vyarus.java-lib", version.ref = "generatePOMGradlePlugin" } +spotBugsPlugin = { id = "com.github.spotbugs", version.ref = "spotBugsGradlePlugin" } +userdevPlugin = { id = "io.papermc.paperweight.userdev", version.ref = "userdevGradlePlugin" } + +[versions] +shadowGradlePlugin = "8.3.0" +generatePOMGradlePlugin = "3.0.0" +spotBugsGradlePlugin = "6.0.20" +userdevGradlePlugin = "1.7.2" +bukkitAPI = "1.21.1-R0.1-SNAPSHOT" +oraxen = "1.182.0" +projectKorra = "master-SNAPSHOT" + +[libraries] +papermc-paperapi = { group = "io.papermc.paper", name = "paper-api", version.ref = "bukkitAPI" } +thorgal-oraxen = { group = "io.th0rgal", name = "oraxen", version.ref = "oraxen" } +projectkorra-core = { group = "com.github.Mowstyl.ProjectKorra", name = "core", version.ref = "projectKorra" } diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar new file mode 100644 index 0000000..249e583 Binary files /dev/null and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 0000000..9390b51 --- /dev/null +++ b/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,6 @@ +#Mon Oct 14 20:58:10 CEST 2024 +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-8.10.1-bin.zip +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists diff --git a/gradlew b/gradlew new file mode 100644 index 0000000..1b6c787 --- /dev/null +++ b/gradlew @@ -0,0 +1,234 @@ +#!/bin/sh + +# +# Copyright © 2015-2021 the original authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +############################################################################## +# +# Gradle start up script for POSIX generated by Gradle. +# +# Important for running: +# +# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is +# noncompliant, but you have some other compliant shell such as ksh or +# bash, then to run this script, type that shell name before the whole +# command line, like: +# +# ksh Gradle +# +# Busybox and similar reduced shells will NOT work, because this script +# requires all of these POSIX shell features: +# * functions; +# * expansions «$var», «${var}», «${var:-default}», «${var+SET}», +# «${var#prefix}», «${var%suffix}», and «$( cmd )»; +# * compound commands having a testable exit status, especially «case»; +# * various built-in commands including «command», «set», and «ulimit». +# +# Important for patching: +# +# (2) This script targets any POSIX shell, so it avoids extensions provided +# by Bash, Ksh, etc; in particular arrays are avoided. +# +# The "traditional" practice of packing multiple parameters into a +# space-separated string is a well documented source of bugs and security +# problems, so this is (mostly) avoided, by progressively accumulating +# options in "$@", and eventually passing that to Java. +# +# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS, +# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly; +# see the in-line comments for details. +# +# There are tweaks for specific operating systems such as AIX, CygWin, +# Darwin, MinGW, and NonStop. +# +# (3) This script is generated from the Groovy template +# https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# within the Gradle project. +# +# You can find Gradle at https://github.com/gradle/gradle/. +# +############################################################################## + +# Attempt to set APP_HOME + +# Resolve links: $0 may be a link +app_path=$0 + +# Need this for daisy-chained symlinks. +while + APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path + [ -h "$app_path" ] +do + ls=$( ls -ld "$app_path" ) + link=${ls#*' -> '} + case $link in #( + /*) app_path=$link ;; #( + *) app_path=$APP_HOME$link ;; + esac +done + +APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit + +APP_NAME="Gradle" +APP_BASE_NAME=${0##*/} + +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' + +# Use the maximum available, or set MAX_FD != -1 to use that value. +MAX_FD=maximum + +warn () { + echo "$*" +} >&2 + +die () { + echo + echo "$*" + echo + exit 1 +} >&2 + +# OS specific support (must be 'true' or 'false'). +cygwin=false +msys=false +darwin=false +nonstop=false +case "$( uname )" in #( + CYGWIN* ) cygwin=true ;; #( + Darwin* ) darwin=true ;; #( + MSYS* | MINGW* ) msys=true ;; #( + NONSTOP* ) nonstop=true ;; +esac + +CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar + + +# Determine the Java command to use to start the JVM. +if [ -n "$JAVA_HOME" ] ; then + if [ -x "$JAVA_HOME/jre/sh/java" ] ; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD=$JAVA_HOME/jre/sh/java + else + JAVACMD=$JAVA_HOME/bin/java + fi + if [ ! -x "$JAVACMD" ] ; then + die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." + fi +else + JAVACMD=java + which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." +fi + +# Increase the maximum file descriptors if we can. +if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then + case $MAX_FD in #( + max*) + MAX_FD=$( ulimit -H -n ) || + warn "Could not query maximum file descriptor limit" + esac + case $MAX_FD in #( + '' | soft) :;; #( + *) + ulimit -n "$MAX_FD" || + warn "Could not set maximum file descriptor limit to $MAX_FD" + esac +fi + +# Collect all arguments for the java command, stacking in reverse order: +# * args from the command line +# * the main class name +# * -classpath +# * -D...appname settings +# * --module-path (only if needed) +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables. + +# For Cygwin or MSYS, switch paths to Windows format before running java +if "$cygwin" || "$msys" ; then + APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) + CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) + + JAVACMD=$( cygpath --unix "$JAVACMD" ) + + # Now convert the arguments - kludge to limit ourselves to /bin/sh + for arg do + if + case $arg in #( + -*) false ;; # don't mess with options #( + /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath + [ -e "$t" ] ;; #( + *) false ;; + esac + then + arg=$( cygpath --path --ignore --mixed "$arg" ) + fi + # Roll the args list around exactly as many times as the number of + # args, so each arg winds up back in the position where it started, but + # possibly modified. + # + # NB: a `for` loop captures its iteration list before it begins, so + # changing the positional parameters here affects neither the number of + # iterations, nor the values presented in `arg`. + shift # remove old arg + set -- "$@" "$arg" # push replacement arg + done +fi + +# Collect all arguments for the java command; +# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of +# shell script including quotes and variable substitutions, so put them in +# double quotes to make sure that they get re-expanded; and +# * put everything else in single quotes, so that it's not re-expanded. + +set -- \ + "-Dorg.gradle.appname=$APP_BASE_NAME" \ + -classpath "$CLASSPATH" \ + org.gradle.wrapper.GradleWrapperMain \ + "$@" + +# Use "xargs" to parse quoted args. +# +# With -n1 it outputs one arg per line, with the quotes and backslashes removed. +# +# In Bash we could simply go: +# +# readarray ARGS < <( xargs -n1 <<<"$var" ) && +# set -- "${ARGS[@]}" "$@" +# +# but POSIX shell has neither arrays nor command substitution, so instead we +# post-process each arg (as a line of input to sed) to backslash-escape any +# character that might be a shell metacharacter, then use eval to reverse +# that process (while maintaining the separation between arguments), and wrap +# the whole thing up as a single "set" statement. +# +# This will of course break if any of these variables contains a newline or +# an unmatched quote. +# + +eval "set -- $( + printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" | + xargs -n1 | + sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' | + tr '\n' ' ' + )" '"$@"' + +exec "$JAVACMD" "$@" diff --git a/gradlew.bat b/gradlew.bat new file mode 100644 index 0000000..107acd3 --- /dev/null +++ b/gradlew.bat @@ -0,0 +1,89 @@ +@rem +@rem Copyright 2015 the original author or authors. +@rem +@rem Licensed under the Apache License, Version 2.0 (the "License"); +@rem you may not use this file except in compliance with the License. +@rem You may obtain a copy of the License at +@rem +@rem https://www.apache.org/licenses/LICENSE-2.0 +@rem +@rem Unless required by applicable law or agreed to in writing, software +@rem distributed under the License is distributed on an "AS IS" BASIS, +@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +@rem See the License for the specific language governing permissions and +@rem limitations under the License. +@rem + +@if "%DEBUG%" == "" @echo off +@rem ########################################################################## +@rem +@rem Gradle startup script for Windows +@rem +@rem ########################################################################## + +@rem Set local scope for the variables with windows NT shell +if "%OS%"=="Windows_NT" setlocal + +set DIRNAME=%~dp0 +if "%DIRNAME%" == "" set DIRNAME=. +set APP_BASE_NAME=%~n0 +set APP_HOME=%DIRNAME% + +@rem Resolve any "." and ".." in APP_HOME to make it shorter. +for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi + +@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" + +@rem Find java.exe +if defined JAVA_HOME goto findJavaFromJavaHome + +set JAVA_EXE=java.exe +%JAVA_EXE% -version >NUL 2>&1 +if "%ERRORLEVEL%" == "0" goto execute + +echo. +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:findJavaFromJavaHome +set JAVA_HOME=%JAVA_HOME:"=% +set JAVA_EXE=%JAVA_HOME%/bin/java.exe + +if exist "%JAVA_EXE%" goto execute + +echo. +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:execute +@rem Setup the command line + +set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar + + +@rem Execute Gradle +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* + +:end +@rem End local scope for the variables with windows NT shell +if "%ERRORLEVEL%"=="0" goto mainEnd + +:fail +rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of +rem the _cmd.exe /c_ return code! +if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 +exit /b 1 + +:mainEnd +if "%OS%"=="Windows_NT" endlocal + +:omega diff --git a/settings.gradle.kts b/settings.gradle.kts new file mode 100644 index 0000000..3accbe8 --- /dev/null +++ b/settings.gradle.kts @@ -0,0 +1,6 @@ +plugins { + id("org.gradle.toolchains.foojay-resolver-convention") version "0.8.0" +} + +gradle.extra["projectName"] = "ProjectKorraItems" +rootProject.name = "items" diff --git a/src/com/projectkorra/items/ConfigManager.java b/src/com/projectkorra/items/ConfigManager.java deleted file mode 100644 index d4db53c..0000000 --- a/src/com/projectkorra/items/ConfigManager.java +++ /dev/null @@ -1,190 +0,0 @@ -package com.projectkorra.items; - -import com.projectkorra.items.attribute.Attribute; -import com.projectkorra.items.customs.PKItem; - -import java.io.BufferedReader; -import java.io.FileNotFoundException; -import java.io.FileReader; -import java.io.IOException; -import java.util.Arrays; -import java.util.HashSet; -import java.util.Set; - -public class ConfigManager { - - public static final String PATH = ProjectKorraItems.plugin.getDataFolder() + "/config.yml"; - public static final String ITEM_PREF = "Item:"; - public static final String DNAME_PREF = "DisplayName:"; - public static final String NAME_PREF = "Name:"; - public static final String LORE_PREF = "Lore:"; - public static final String SHAPED_RECIPE_PREF = "ShapedRecipe:"; - public static final String UNSHAPED_RECIPE_PREF = "UnshapedRecipe:"; - public static final String MATERIAL_PREF = "Material:"; - public static final String DURA_PREF = "Durability:"; - public static final String AMT_PREF = "Amount:"; - public static final String ATTR_PREF = "Stats:"; - public static final String GLOW_PREF = "Glow:"; - public static final String[] PREFIXES = { ITEM_PREF, DNAME_PREF, NAME_PREF, LORE_PREF, SHAPED_RECIPE_PREF, UNSHAPED_RECIPE_PREF, MATERIAL_PREF, DURA_PREF, AMT_PREF, ATTR_PREF, GLOW_PREF }; - - public ConfigManager() { - PKItem.items.clear(); - PKItem.itemList.clear(); - ProjectKorraItems.plugin.saveDefaultConfig(); - String str = readConfig(); - Set customItemNames = getConfigItemNames(str); - analyzeConfig(str, customItemNames); - } - - /** - * Returns the entire config file as a String. - */ - public String readConfig() { - String configStr = ""; - BufferedReader br = null; - try { - br = new BufferedReader(new FileReader(PATH)); - } - catch (FileNotFoundException e) { - ProjectKorraItems.log.info(Messages.NO_CONFIG); - return configStr; - } - try { - StringBuilder sb = new StringBuilder(); - String line = br.readLine(); - - while (line != null) { - sb.append(line); - sb.append("\n"); - line = br.readLine(); - } - configStr = sb.toString(); - } - catch (IOException e) { - ProjectKorraItems.log.info(Messages.BAD_FILE); - return configStr; - } - finally { - try { - br.close(); - } - catch (IOException e) { - ProjectKorraItems.log.info(Messages.BAD_FILE); - return configStr; - } - } - return configStr; - } - - /** - * Uses a string that represents the configuration file to parse through all - * of the items and create instances of CustomItems. - * - * @param configStr a string version of the config.yml - * @param customItemNames a set containing the names of all the custom items - * that were defined in the config. - */ - public void analyzeConfig(String configStr, Set customItemNames) { - String[] configLines = configStr.split("\n"); - PKItem newItem = null; - boolean invalid = false; - - for (String line : configLines) { - line = line.trim(); - if (line.length() == 0) - continue; - if (line.toLowerCase().startsWith(ITEM_PREF.toLowerCase())) { - if (newItem != null && !invalid) { - newItem.build(); - } - invalid = false; - newItem = new PKItem(); - } else { - boolean prefFound = false; - for (String prefix : PREFIXES) { - if (line.toLowerCase().startsWith(prefix.toLowerCase())) { - prefFound = true; - String tmp = ""; - try { - tmp = line.substring(prefix.length(), line.length()); - tmp = tmp.trim(); - if (prefix.equalsIgnoreCase(NAME_PREF)) - newItem.updateName(tmp); - else if (prefix.equalsIgnoreCase(DNAME_PREF)) - newItem.updateDisplayName(tmp); - else if (prefix.equalsIgnoreCase(LORE_PREF)) - newItem.updateLore(tmp); - else if (prefix.equalsIgnoreCase(SHAPED_RECIPE_PREF)) { - newItem.updateRecipe(tmp, customItemNames); - newItem.setUnshapedRecipe(false); - } else if (prefix.equalsIgnoreCase(UNSHAPED_RECIPE_PREF)) { - newItem.updateRecipe(tmp, customItemNames); - newItem.setUnshapedRecipe(true); - } else if (prefix.equalsIgnoreCase(MATERIAL_PREF)) - newItem.updateMaterial(tmp); - else if (prefix.equalsIgnoreCase(DURA_PREF)) - newItem.updateDamage(tmp); - else if (prefix.equalsIgnoreCase(AMT_PREF)) - newItem.updateQuantity(tmp); - else if (prefix.equalsIgnoreCase(GLOW_PREF)) - newItem.updateGlow(tmp); - } - catch (Exception e) { - ProjectKorraItems.log.info(Messages.BAD_PREFIX + ": " + prefix); - invalid = false; - } - } - } - - /* Check if it is an attribute */ - if (!prefFound) { - try { - String prefix = line.substring(0, line.indexOf(":")); - String valueStr = line.substring(line.indexOf(":") + 1, line.length()).trim(); - valueStr = valueStr.replaceAll("(?i)true", "1"); - valueStr = valueStr.replaceAll("(?i)false", "0"); - String[] commaSplit = valueStr.split(","); - if (commaSplit.length == 0) { - ProjectKorraItems.log.info(Messages.MISSING_VALUES + ": " + line); - invalid = false; - } - Attribute att = Attribute.getAttribute(prefix); - Attribute newAtt = new Attribute(att.getName()); - newAtt.getValues().addAll(Arrays.asList(commaSplit)); - newItem.getAttributes().add(newAtt); - } - catch (Exception e) { - ProjectKorraItems.log.info(Messages.BAD_PREFIX + ": " + line); - invalid = false; - } - } - - } - } - if (newItem != null && !invalid) { - newItem.build(); - } - } - - /** - * Gathers the names of all of the custom items within the config file. - * - * @param config a String representation of the configuration file - * @return a set containing the item names - */ - public Set getConfigItemNames(String config) { - HashSet names = new HashSet<>(); - String[] lines = config.split("\n"); - String prefix = NAME_PREF; - - for (String line : lines) { - line = line.trim(); - if (line.toLowerCase().startsWith(prefix.toLowerCase())) { - String itemName = line.substring(prefix.length(), line.length()).trim(); - names.add(itemName); - } - } - - return names; - } -} diff --git a/src/com/projectkorra/items/abilityupdater/AirUpdater.java b/src/com/projectkorra/items/abilityupdater/AirUpdater.java deleted file mode 100644 index 8dd0695..0000000 --- a/src/com/projectkorra/items/abilityupdater/AirUpdater.java +++ /dev/null @@ -1,114 +0,0 @@ -package com.projectkorra.items.abilityupdater; - -import com.projectkorra.projectkorra.airbending.AirBlast; -import com.projectkorra.projectkorra.airbending.AirBubble; -import com.projectkorra.projectkorra.airbending.AirScooter; -import com.projectkorra.projectkorra.airbending.AirShield; -import com.projectkorra.projectkorra.airbending.AirSpout; -import com.projectkorra.projectkorra.airbending.AirSuction; -import com.projectkorra.projectkorra.airbending.AirSwipe; -import com.projectkorra.projectkorra.airbending.Tornado; - -import org.bukkit.entity.Player; - -import java.util.concurrent.ConcurrentHashMap; - -public class AirUpdater { - - /** - * updates the air abilities based on a players bending effect attributes - * - * @param player the player that has the effects - * @param ability an instance of a air ability - * @param attribs the map of the players effects - * @return if the ability was updated correctly - */ - - public static boolean updateAbilityDamage(Player player, Object ability, ConcurrentHashMapattribs) { - if (ability instanceof AirSwipe) { - AirSwipe abil = (AirSwipe) ability; - if (attribs.containsKey("AirSwipeDamage")) - abil.setDamage(abil.getDamage() + abil.getDamage() * attribs.get("AirSwipeDamage") / 100.0); - return true; - } - return false; - } - - public static boolean updateAbility(Player player, Object ability, ConcurrentHashMap attribs) { - if (ability instanceof AirBlast) { - AirBlast abil = (AirBlast) ability; - if (attribs.containsKey("AirBlastRange")) - abil.setRange(abil.getRange() + abil.getRange() * attribs.get("AirBlastRange") / 100.0); - if (attribs.containsKey("AirBlastForce")) - abil.setPushFactor(abil.getPushFactor() + abil.getPushFactor() * attribs.get("AirBlastForce") / 100.0); - return true; - } else if (ability instanceof AirSwipe) { - AirSwipe abil = (AirSwipe) ability; - if (attribs.containsKey("AirSwipeDamage")) - abil.setDamage(abil.getDamage() + abil.getDamage() * attribs.get("AirSwipeDamage") / 100.0); - if (attribs.containsKey("AirSwipeForce")) - abil.setPushFactor(abil.getPushFactor() + abil.getPushFactor() * attribs.get("AirSwipeForce") / 100.0); - if (attribs.containsKey("AirSwipeSpeed")) - abil.setSpeed(abil.getSpeed() + abil.getSpeed() * attribs.get("AirSwipeSpeed") / 100.0); - if (attribs.containsKey("AirSwipeRange")) - abil.setRange(abil.getRange() + abil.getRange() * attribs.get("AirSwipeRange") / 100.0); - if (attribs.containsKey("AirSwipeMaxCharge")) - abil.setMaxChargeFactor(abil.getMaxChargeFactor() + abil.getMaxChargeFactor() * attribs.get("AirSwipeMaxCharge") / 100.0); - if (attribs.containsKey("AirSwipeRadius")) - abil.setRadius(abil.getRadius() + abil.getRadius() * attribs.get("AirSwipeRadius") / 100.0); - if (attribs.containsKey("AirSwipeArc")) - abil.setArc((int) (abil.getArc() + abil.getArc() * attribs.get("AirSwipeArc") / 100.0)); - if (attribs.containsKey("AirSwipeChargeTime")) - abil.setMaxChargeTime((long) (abil.getMaxChargeTime() + abil.getMaxChargeTime() * attribs.get("AirSwipeChargeTime") / 100.0)); - return true; - } else if (ability instanceof AirShield) { - AirShield abil = (AirShield) ability; - if (attribs.containsKey("AirShieldRadius")) - abil.setMaxRadius(abil.getMaxRadius() + abil.getMaxRadius() * attribs.get("AirShieldRadius") / 100.0); - return true; - } else if (ability instanceof AirBubble) { - AirBubble abil = (AirBubble) ability; - if (attribs.containsKey("AirBubbleRadius")) - abil.setAirRadius(abil.getAirRadius() + abil.getAirRadius() * attribs.get("AirBubbleRadius") / 100.0); - if (attribs.containsKey("WaterBubbleRadius")) - abil.setWaterRadius(abil.getWaterRadius() + abil.getWaterRadius() * attribs.get("WaterBubbleRadius") / 100.0); - return true; - } else if (ability instanceof AirScooter) { - AirScooter abil = (AirScooter) ability; - if (attribs.containsKey("AirScooterSpeed")) - ((AirScooter) abil).setSpeed(abil.getSpeed() + abil.getSpeed() * attribs.get("AirScooterSpeed") / 100.0); - return true; - } else if (ability instanceof Tornado) { - Tornado abil = (Tornado) ability; - if (attribs.containsKey("TornadoMaxHeight")) - abil.setMaxHeight(abil.getMaxHeight() + abil.getMaxHeight() * attribs.get("TornadoMaxHeight") / 100.0); - if (attribs.containsKey("TornadoMaxRadius")) - abil.setRadius(abil.getRadius() + abil.getRadius() * attribs.get("TornadoMaxRadius") / 100.0); - if (attribs.containsKey("TornadoRange")) - abil.setRange(abil.getRange() + abil.getRange() * attribs.get("TornadoRange") / 100.0); - if (attribs.containsKey("TornadoPlayerPushFactor")) - abil.setPlayerPushFactor(abil.getPlayerPushFactor() + abil.getPlayerPushFactor() * attribs.get("TornadoPlayerPushFactor") / 100.0); - if (attribs.containsKey("TornadoNPCPushFactor")) - abil.setNpcPushFactor(abil.getNpcPushFactor() + abil.getNpcPushFactor() * attribs.get("TornadoNPCPushFactor") / 100.0); - return true; - } else if (ability instanceof AirSpout) { - AirSpout abil = (AirSpout) ability; - if (attribs.containsKey("AirSpoutHeight")) - abil.setHeight(abil.getHeight() + abil.getHeight() * attribs.get("AirSpoutHeight") / 100.0); - return true; - } else if (ability instanceof AirSuction) { - AirSuction abil = (AirSuction) ability; - if (attribs.containsKey("AirSuctionSpeed")) - abil.setSpeed(abil.getSpeed() + abil.getSpeed() * attribs.get("AirSuctionSpeed") / 100.0); - if (attribs.containsKey("AirSuctionRange")) - abil.setRange(abil.getRange() + abil.getRange() * attribs.get("AirSuctionRange") / 100.0); - if (attribs.containsKey("AirSuctionForce")) - abil.setPushFactor(abil.getPushFactor() + abil.getPushFactor() * attribs.get("AirSuctionForce") / 100.0); - if (attribs.containsKey("AirSuctionRadius")) - abil.setRadius(abil.getRadius() + abil.getRadius() * attribs.get("AirSuctionRadius") / 100.0); - return true; - } - - return false; - } -} diff --git a/src/com/projectkorra/items/abilityupdater/ChiUpdater.java b/src/com/projectkorra/items/abilityupdater/ChiUpdater.java deleted file mode 100644 index 557ac30..0000000 --- a/src/com/projectkorra/items/abilityupdater/ChiUpdater.java +++ /dev/null @@ -1,59 +0,0 @@ -package com.projectkorra.items.abilityupdater; - -import com.projectkorra.projectkorra.chiblocking.AcrobatStance; -import com.projectkorra.projectkorra.chiblocking.RapidPunch; -import com.projectkorra.projectkorra.chiblocking.WarriorStance; - -import org.bukkit.entity.Player; - -import java.util.concurrent.ConcurrentHashMap; - -public class ChiUpdater { - - /** - * updates the chi abilities based on a players bending effect attributes - * - * @param player the player that has the effects - * @param ability an instance of a chi ability - * @param attribs the map of the players effects - * @return if the ability was updated correctly - */ - - public static boolean updateAbilityDamage(Player player, Object ability, ConcurrentHashMap attribs) { - if (ability instanceof RapidPunch) { - RapidPunch abil = (RapidPunch) ability; - if (attribs.containsKey("RapidPunchDamage")) - abil.setDamage((int) (abil.getDamage() + abil.getDamage() * attribs.get("RapidPunchDamage") / 100.0)); - return true; - } - return false; - } - - public static boolean updateAbility(Player player, Object ability, ConcurrentHashMap attribs) { - if (ability instanceof AcrobatStance) { - AcrobatStance abil = (AcrobatStance) ability; - if (attribs.containsKey("AcrobatStanceJump")) - abil.setSpeed((int) (abil.getSpeed() + abil.getSpeed() * attribs.get("AcrobatStanceSpeed") / 100.0)); - if (attribs.containsKey("AcrobatStanceSpeed")) - abil.setJump((int) (abil.getJump() + abil.getJump() * attribs.get("AcrobatStanceSpeed") / 100.0)); - return true; - } else if (ability instanceof RapidPunch) { - RapidPunch abil = (RapidPunch) ability; - if (attribs.containsKey("RapidPunchHits")) - abil.setNumPunches((int) (abil.getNumPunches() + abil.getNumPunches() * attribs.get("RapidPunchHits") / 100.0)); - if (attribs.containsKey("RapidPunchDistance")) - abil.setDistance((int) (abil.getDistance() + abil.getDistance() * attribs.get("RapidPunchDistance") / 100.0)); - if (attribs.containsKey("RapidPunchCooldown")) - abil.setCooldown((long) (abil.getCooldown() + abil.getCooldown() * attribs.get("RapidPunchCooldown") / 100.0)); - return true; - } else if (ability instanceof WarriorStance) { - WarriorStance abil = (WarriorStance) ability; - if (attribs.containsKey("WarriorStanceStrength")) - abil.setStrength((int) (abil.getStrength() + abil.getStrength() * attribs.get("WarriorStanceStrength") / 100.0)); - if (attribs.containsKey("WarriorStanceResistance")) - abil.setResistance((int) (abil.getResistance() + abil.getResistance() * attribs.get("WarriorStanceResistance") / 100.0)); - return true; - } - return false; - } -} diff --git a/src/com/projectkorra/items/abilityupdater/EarthUpdater.java b/src/com/projectkorra/items/abilityupdater/EarthUpdater.java deleted file mode 100644 index b694f78..0000000 --- a/src/com/projectkorra/items/abilityupdater/EarthUpdater.java +++ /dev/null @@ -1,111 +0,0 @@ -package com.projectkorra.items.abilityupdater; - -import java.util.concurrent.ConcurrentHashMap; - -import org.bukkit.entity.Player; - -import com.projectkorra.projectkorra.earthbending.Catapult; -import com.projectkorra.projectkorra.earthbending.EarthArmor; -import com.projectkorra.projectkorra.earthbending.EarthBlast; -import com.projectkorra.projectkorra.earthbending.EarthSmash; -import com.projectkorra.projectkorra.earthbending.EarthTunnel; -import com.projectkorra.projectkorra.earthbending.Ripple; -import com.projectkorra.projectkorra.earthbending.Shockwave; - -public class EarthUpdater { - - /** - * updates the earth abilities based on a players bending effect attributes - * - * @param player the player that has the effects - * @param ability an instance of a earth ability - * @param attribs the map of the players effects - * @return if the ability was updated correctly - */ - - public static boolean updateAbilityDamage(Player player, Object ability, ConcurrentHashMap attribs) { - if (ability instanceof EarthSmash) { - EarthSmash abil = (EarthSmash) ability; - if (attribs.containsKey("EarthSmashDamage")) - abil.setDamage(abil.getDamage() + abil.getDamage() * attribs.get("EarthSmashDamage") / 100.0); - return true; - } else if (ability instanceof EarthBlast) { - EarthBlast abil = (EarthBlast) ability; - if (attribs.containsKey("EarthBlastDamage")) - abil.setDamage(abil.getDamage() + abil.getDamage() * attribs.get("EarthBlastDamage") / 100.0); - return true; - } else if (ability instanceof Ripple) { - Ripple abil = (Ripple) ability; - if (attribs.containsKey("ShockwaveDamage")) - abil.setDamage(abil.getDamage() + abil.getDamage() * attribs.get("ShockwaveDamage") / 100.0); - return true; - } - return false; - } - - public static boolean updateAbility(Player player, Object ability, ConcurrentHashMap attribs) { - if (ability instanceof EarthSmash) { - EarthSmash abil = (EarthSmash) ability; - if (attribs.containsKey("EarthSmashGrabRange")) - abil.setSelectRange((int) (abil.getSelectRange() + abil.getSelectRange() * attribs.get("EarthSmashGrabRange") / 100.0)); - if (attribs.containsKey("EarthSmashShootRange")) - abil.setShootRange(abil.getShootRange() + abil.getShootRange() * attribs.get("EarthSmashShootRange") / 100.0); - if (attribs.containsKey("EarthSmashChargeTime")) - abil.setChargeTime((long) (abil.getChargeTime() + abil.getChargeTime() * attribs.get("EarthSmashChargeTime") / 100.0)); - if (attribs.containsKey("EarthSmashCooldown")) - abil.setCooldown((long) (abil.getCooldown() + abil.getCooldown() * attribs.get("EarthSmashCooldown") / 100.0)); - if (attribs.containsKey("EarthSmashKnockback")) - abil.setKnockback(abil.getKnockback() + abil.getKnockback() * attribs.get("EarthSmashKnockback") / 100.0); - if (attribs.containsKey("EarthSmashKnockup")) - abil.setKnockup(abil.getKnockup() + abil.getKnockup() * attribs.get("EarthSmashKnockup") / 100.0); - if (attribs.containsKey("EarthSmashFlySpeed")) - abil.setFlightSpeed(abil.getFlightSpeed() + abil.getFlightSpeed() * attribs.get("EarthSmashFlySpeed") / 100.0); - if (attribs.containsKey("EarthSmashFlyDuration")) - abil.setFlightRemoveTimer((long) (abil.getFlightRemoveTimer() + abil.getFlightRemoveTimer() * attribs.get("EarthSmashFlyDuration") / 100.0)); - return true; - } else if (ability instanceof Catapult) { - Catapult abil = (Catapult) ability; - if (attribs.containsKey("CatapultLength")) - abil.setLength((int) (abil.getLength() + abil.getLength() * attribs.get("CatapultLength") / 100.0)); - if (attribs.containsKey("CatapultPush")) - abil.setPush(abil.getPush() + abil.getPush() * attribs.get("CatapultPush") / 100.0); - return true; - } else if (ability instanceof EarthArmor) { - EarthArmor abil = (EarthArmor) ability; - if (attribs.containsKey("EarthArmorStrength")) - abil.setStrength((int) (abil.getStrength() + abil.getStrength() * attribs.get("EarthArmorStrength") / 100.0)); - return true; - } else if (ability instanceof EarthBlast) { - EarthBlast abil = (EarthBlast) ability; - if (attribs.containsKey("EarthBlastRange")) - abil.setRange(abil.getRange() + abil.getRange() * attribs.get("EarthBlastRange") / 100.0); - if (attribs.containsKey("EarthBlastForce")) - abil.setPushFactor(abil.getPushFactor() + abil.getPushFactor() * attribs.get("EarthBlastForce") / 100.0); - return true; - } else if (ability instanceof EarthTunnel) { - EarthTunnel abil = (EarthTunnel) ability; - if (attribs.containsKey("EarthTunnelMaxRadius")) - abil.setMaxRadius(abil.getMaxRadius() + abil.getMaxRadius() * attribs.get("EarthTunnelMaxRadius") / 100.0); - if (attribs.containsKey("EarthTunnelRadius")) - abil.setRadiusIncrement(abil.getRadiusIncrement() + abil.getRadiusIncrement() * attribs.get("EarthTunnelRadius") / 100.0); - if (attribs.containsKey("EarthTunnelRange")) - abil.setRange(abil.getRange() + abil.getRange() * attribs.get("EarthTunnelRange") / 100.0); - if (attribs.containsKey("EarthTunnelInterval")) - abil.setInterval((long) (abil.getInterval() + abil.getInterval() * attribs.get("EarthTunnelInterval") / 100.0)); - return true; - } else if (ability instanceof Ripple) { - Ripple abil = (Ripple) ability; - if (attribs.containsKey("ShockwaveRadius")) - abil.setRange(abil.getRange() + abil.getRange() * attribs.get("ShockwaveRadius") / 100.0); - if (attribs.containsKey("ShockwaveKnockback")) - abil.setKnockback(abil.getKnockback() + abil.getKnockback() * attribs.get("ShockwaveKnockback") / 100.0); - return true; - } else if (ability instanceof Shockwave) { - Shockwave abil = (Shockwave) ability; - if (attribs.containsKey("ShockwaveChargeTime")) - abil.setChargeTime((long) (abil.getChargeTime() + abil.getChargeTime() * attribs.get("ShockwaveChargeTime") / 100.0)); - return true; - } - return false; - } -} diff --git a/src/com/projectkorra/items/abilityupdater/FireUpdater.java b/src/com/projectkorra/items/abilityupdater/FireUpdater.java deleted file mode 100644 index ff9bad7..0000000 --- a/src/com/projectkorra/items/abilityupdater/FireUpdater.java +++ /dev/null @@ -1,116 +0,0 @@ -package com.projectkorra.items.abilityupdater; - -import java.util.concurrent.ConcurrentHashMap; - -import org.bukkit.entity.Player; - -import com.projectkorra.projectkorra.firebending.FireBlast; -import com.projectkorra.projectkorra.firebending.FireJet; -import com.projectkorra.projectkorra.firebending.FireShield; -import com.projectkorra.projectkorra.firebending.HeatControlCook; -import com.projectkorra.projectkorra.firebending.Lightning; -import com.projectkorra.projectkorra.firebending.WallOfFire; - -public class FireUpdater { - - /** - * updates the fire abilities based on a players bending effect attributes - * - * @param player the player that has the effects - * @param ability an instance of a fire ability - * @param attribs the map of the players effects - * @return if the ability was updated correctly - */ - - public static boolean updateAbilityDamage(Player player, Object ability, ConcurrentHashMap attribs) { - if (ability instanceof Lightning) { - Lightning abil = (Lightning) ability; - if (attribs.containsKey("LightningDamage")) - abil.setDamage(abil.getDamage() + abil.getDamage() * attribs.get("LightningDamage") / 100.0); - return true; - } else if (ability instanceof FireBlast) { - FireBlast abil = (FireBlast) ability; - if (attribs.containsKey("FireBlastDamage")) - abil.setDamage(abil.getDamage() + abil.getDamage() * attribs.get("FireBlastDamage") / 100.0); - return true; - } else if (ability instanceof WallOfFire) { - WallOfFire abil = (WallOfFire) ability; - if (attribs.containsKey("WallOfFireDamage")) - abil.setDamage((int) (abil.getDamage() + abil.getDamage() * attribs.get("WallOfFireDamage") / 100.0)); - return true; - } - return false; - } - - public static boolean updateAbility(Player player, Object ability, ConcurrentHashMap attribs) { - if (ability instanceof Lightning) { - Lightning abil = (Lightning) ability; - if (attribs.containsKey("LightningRange")) - abil.setRange(abil.getRange() + abil.getRange() * attribs.get("LightningRange") / 100.0); - if (attribs.containsKey("LightningChargeTime")) - abil.setChargeTime(abil.getChargeTime() + abil.getChargeTime() * attribs.get("LightningChargeTime") / 100.0); - if (attribs.containsKey("LightningCooldown")) - abil.setCooldown((long) (abil.getCooldown() + abil.getCooldown() * attribs.get("LightningCooldown") / 100.0)); - if (attribs.containsKey("LightningSubArcChance")) - abil.setSubArcChance(abil.getSubArcChance() + abil.getSubArcChance() * attribs.get("LightningSubArcChance") / 100.0); - if (attribs.containsKey("LightningMaxChainArcs")) - abil.setMaxChainArcs(abil.getMaxChainArcs() + abil.getMaxChainArcs() * attribs.get("LightningMaxChainArcs") / 100.0); - if (attribs.containsKey("LightningChainRange")) - abil.setChainRange(abil.getChainRange() + abil.getChainRange() * attribs.get("LightningChainRange") / 100.0); - if (attribs.containsKey("LightningChainArcChance")) - abil.setChainArcChance(abil.getChainArcChance() + abil.getChainArcChance() * attribs.get("LightningChainArcChance") / 100.0); - if (attribs.containsKey("LightningWaterRange")) - abil.setRange(abil.getRange() + abil.getRange() * attribs.get("LightningWaterRange") / 100.0); - if (attribs.containsKey("LightningStunChance")) - abil.setStunChance(abil.getStunChance() + abil.getStunChance() * attribs.get("LightningStunChance") / 100.0); - if (attribs.containsKey("LightningStunDuration")) - abil.setStunDuration(abil.getStunDuration() + abil.getStunDuration() * attribs.get("LightningStunDuration") / 100.0); - return true; - } else if (ability instanceof HeatControlCook) { - HeatControlCook abil = (HeatControlCook) ability; - if (attribs.containsKey("HeatControlCookTime")) - abil.setCookTime((long) (abil.getCookTime() + abil.getCookTime() * attribs.get("HeatControlCookTime") / 100.0)); - return true; - } else if (ability instanceof FireBlast) { - FireBlast abil = (FireBlast) ability; - if (attribs.containsKey("FireBlastSpeed")) - abil.setSpeed(abil.getSpeed() + abil.getSpeed() * attribs.get("FireBlastSpeed") / 100.0); - if (attribs.containsKey("FireBlastForce")) - abil.setPushFactor(abil.getPushFactor() + abil.getPushFactor() * attribs.get("FireBlastForce") / 100.0); - if (attribs.containsKey("FireBlastRange")) - abil.setRange(abil.getRange() + abil.getRange() * attribs.get("FireBlastRange") / 100.0); - return true; - } else if (ability instanceof FireJet) { - FireJet abil = (FireJet) ability; - if (attribs.containsKey("FireJetDuration")) - abil.setDuration((long) (abil.getDuration() + abil.getDuration() * attribs.get("FireJetDuration") / 100.0)); - return true; - } else if (ability instanceof FireShield) { - FireShield abil = (FireShield) ability; - if (attribs.containsKey("FireShieldClickDuration")) - abil.setDuration((long) (abil.getDuration() + abil.getDuration() * attribs.get("FireShieldClickDuration") / 100.0)); - if (attribs.containsKey("FireShieldRadius")) - abil.setRadius(abil.getRadius() + abil.getRadius() * attribs.get("FireShieldRadius") / 100.0); - if (attribs.containsKey("FireShieldClickRadius")) - abil.setDiscRadius(abil.getDiscRadius() + abil.getDiscRadius() * attribs.get("FireShieldClickRadius") / 100.0); - return true; - } else if (ability instanceof WallOfFire) { - WallOfFire abil = (WallOfFire) ability; - if (attribs.containsKey("WallOfFireRange")) - abil.setRange((int) (abil.getRange() + abil.getRange() * attribs.get("WallOfFireRange") / 100.0)); - if (attribs.containsKey("WallOfFireHeight")) - abil.setHeight((int) (abil.getHeight() + abil.getHeight() * attribs.get("WallOfFireHeight") / 100.0)); - if (attribs.containsKey("WallOfFireWidth")) - abil.setWidth((int) (abil.getWidth() + abil.getWidth() * attribs.get("WallOfFireWidth") / 100.0)); - if (attribs.containsKey("WallOfFireDuration")) - abil.setDuration((long) (abil.getDuration() + abil.getDuration() * attribs.get("WallOfFireDuration") / 100.0)); - if (attribs.containsKey("WallOfFireDamageInterval")) - abil.setDamageInterval((long) (abil.getDamageInterval() + abil.getDamageInterval() * attribs.get("WallOfFireDamageInterval") / 100.0)); - if (attribs.containsKey("WallOfFireCooldown")) - abil.setCooldown((long) (abil.getCooldown() + abil.getCooldown() * attribs.get("WallOfFireCooldown") / 100.0)); - return true; - } - return false; - } - -} diff --git a/src/com/projectkorra/items/abilityupdater/WaterUpdater.java b/src/com/projectkorra/items/abilityupdater/WaterUpdater.java deleted file mode 100644 index 4090621..0000000 --- a/src/com/projectkorra/items/abilityupdater/WaterUpdater.java +++ /dev/null @@ -1,173 +0,0 @@ -package com.projectkorra.items.abilityupdater; - -import java.util.concurrent.ConcurrentHashMap; - -import org.bukkit.entity.Player; - -import com.projectkorra.projectkorra.waterbending.Bloodbending; -import com.projectkorra.projectkorra.waterbending.IceBlast; -import com.projectkorra.projectkorra.waterbending.IceSpikeBlast; -import com.projectkorra.projectkorra.waterbending.IceSpikePillar; -import com.projectkorra.projectkorra.waterbending.OctopusForm; -import com.projectkorra.projectkorra.waterbending.SurgeWall; -import com.projectkorra.projectkorra.waterbending.SurgeWave; -import com.projectkorra.projectkorra.waterbending.Torrent; -import com.projectkorra.projectkorra.waterbending.TorrentWave; -import com.projectkorra.projectkorra.waterbending.WaterManipulation; -import com.projectkorra.projectkorra.waterbending.WaterSpout; -import com.projectkorra.projectkorra.waterbending.WaterSpoutWave; - -public class WaterUpdater { - - /** - * updates the water abilities based on a players bending effect attributes - * - * @param player the player that has the effects - * @param ability an instance of a water ability - * @param attribs the map of the players effects - * @return if the ability was updated correctly - */ - - public static boolean updateAbilityDamage(Player player, Object ability, ConcurrentHashMap attribs) { - if (ability instanceof IceBlast) { - IceBlast abil = (IceBlast) ability; - if (attribs.containsKey("IceBlastDamage")) - abil.setDamage(abil.getDamage() + abil.getDamage() * attribs.get("IceBlastDamage") / 100.0); - return true; - } else if (ability instanceof IceSpikeBlast) { - IceSpikeBlast abil = (IceSpikeBlast) ability; - if (attribs.containsKey("IceSpikeDamage")) - abil.setDamage(abil.getDamage() + abil.getDamage() * attribs.get("IceSpikeDamage") / 100.0); - return true; - } else if (ability instanceof IceSpikePillar) { - IceSpikePillar abil = (IceSpikePillar) ability; - if (attribs.containsKey("IceSpikePillarDamage")) - abil.setDamage(abil.getDamage() + abil.getDamage() * attribs.get("IceSpikePillarDamage") / 100.0); - return true; - } else if (ability instanceof OctopusForm) { - OctopusForm abil = (OctopusForm) ability; - if (attribs.containsKey("OctopusFormDamage")) - abil.setDamage((int) (abil.getDamage() + abil.getDamage() * attribs.get("OctopusFormDamage") / 100.0)); - return true; - } else if (ability instanceof Torrent) { - Torrent abil = (Torrent) ability; - if (attribs.containsKey("TorrentDamage")) - abil.setDamage((int) (abil.getDamage() + abil.getDamage() * attribs.get("TorrentDamage") / 100.0)); - return true; - } else if (ability instanceof WaterManipulation) { - WaterManipulation abil = (WaterManipulation) ability; - if (attribs.containsKey("WaterManipulationDamage")) - abil.setDamage(abil.getDamage() + abil.getDamage() * attribs.get("WaterManipulationDamage") / 100.0); - return true; - } else if (ability instanceof WaterSpoutWave) { - WaterSpoutWave abil = (WaterSpoutWave) ability; - if (attribs.containsKey("IceWaveDamage")) - abil.setDamage(abil.getDamage() + abil.getDamage() * attribs.get("IceWaveDamage") / 100.0); - return true; - } - return false; - } - - public static boolean updateAbility(Player player, Object ability, ConcurrentHashMap attribs) { - if (ability instanceof Bloodbending) { - Bloodbending abil = (Bloodbending) ability; - if (attribs.containsKey("BloodbendingForce")) - abil.setThrowFactor(abil.getThrowFactor() + abil.getThrowFactor() * attribs.get("BloodbendingForce") / 100.0); - if (attribs.containsKey("BloodbendingRange")) - abil.setRange((int) (abil.getRange() + abil.getRange() * attribs.get("BloodbendingRange") / 100.0)); - if (attribs.containsKey("BloodbendingHoldTime")) - abil.setHoldTime((long) (abil.getHoldTime() + abil.getHoldTime() * attribs.get("BloodbendingHoldTime") / 100.0)); - if (attribs.containsKey("BloodbendingCooldown")) - abil.setCooldown((long) (abil.getCooldown() + abil.getCooldown() * attribs.get("BloodbendingCooldown") / 100.0)); - return true; - } else if (ability instanceof IceBlast) { - IceBlast abil = (IceBlast) ability; - if (attribs.containsKey("IceBlastRange")) - abil.setRange(abil.getRange() + abil.getRange() * attribs.get("IceBlastRange") / 100.0); - return true; - } else if (ability instanceof IceSpikeBlast) { - IceSpikeBlast abil = (IceSpikeBlast) ability; - if (attribs.containsKey("IceSpikeRange")) - abil.setRange(abil.getRange() + abil.getRange() * attribs.get("IceSpikeRange") / 100.0); - return true; - } else if (ability instanceof IceSpikePillar) { - IceSpikePillar abil = (IceSpikePillar) ability; - if (attribs.containsKey("IceSpikePillarRange")) - abil.setRange(abil.getRange() + abil.getRange() * attribs.get("IceSpikePillarRange") / 100.0); - return true; - } else if (ability instanceof OctopusForm) { - OctopusForm abil = (OctopusForm) ability; - if (attribs.containsKey("OctopusFormRange")) - abil.setAttackRange((int) (abil.getAttackRange() + abil.getAttackRange() * attribs.get("OctopusFormRange") / 100.0)); - if (attribs.containsKey("OctopusFormInterval")) - abil.setInterval((long) (abil.getInterval() + abil.getInterval() * attribs.get("OctopusFormInterval") / 100.0)); - if (attribs.containsKey("OctopusFormKnockback")) - abil.setKnockback(abil.getKnockback() + abil.getKnockback() * attribs.get("OctopusFormKnockback") / 100.0); - if (attribs.containsKey("OctopusFormRadius")) - abil.setRadius(abil.getRadius() + abil.getRadius() * attribs.get("OctopusFormRadius") / 100.0); - return true; - } else if (ability instanceof Torrent) { - Torrent abil = (Torrent) ability; - if (attribs.containsKey("TorrentRange")) - abil.setRange(abil.getRange() + abil.getRange() * attribs.get("TorrentRange") / 100.0); - if (attribs.containsKey("TorrentStreamingDamage")) - abil.setDeflectDamage((int) (abil.getDeflectDamage() + abil.getDeflectDamage() * attribs.get("TorrentStreamingDamage") / 100.0)); - return true; - } else if (ability instanceof TorrentWave) { - TorrentWave abil = (TorrentWave) ability; - if (attribs.containsKey("TorrentWaveRadius")) - abil.setMaxRadius(abil.getMaxRadius() + abil.getMaxRadius() * attribs.get("TorrentWaveRadius") / 100.0); - if (attribs.containsKey("TorrentWaveHeight")) - abil.setMaxHeight(abil.getMaxHeight() + abil.getMaxHeight() * attribs.get("TorrentWaveHeight") / 100.0); - return true; - } else if (ability instanceof WaterManipulation) { - WaterManipulation abil = (WaterManipulation) ability; - if (attribs.containsKey("WaterManipulationSelectRange")) - abil.setSelectRange(abil.getSelectRange() + abil.getSelectRange() * attribs.get("WaterManipulationSelectRange") / 100.0); - if (attribs.containsKey("WaterManipulationDispelRange")) - abil.setDispelRange((int) (abil.getDispelRange() + abil.getDispelRange() * attribs.get("WaterManipulationDispelRange") / 100.0)); - if (attribs.containsKey("WaterManipulationForce")) - abil.setPushFactor(abil.getPushFactor() + abil.getPushFactor() * attribs.get("WaterManipulationForce") / 100.0); - if (attribs.containsKey("WaterManipulationCooldown")) - abil.setCooldown((long) (abil.getCooldown() + abil.getCooldown() * attribs.get("WaterManipulationCooldown") / 100.0)); - return true; - } else if (ability instanceof WaterSpout) { - WaterSpout abil = (WaterSpout) ability; - if (attribs.containsKey("WaterSpoutHeight")) - abil.setHeight((int) (abil.getHeight() + abil.getHeight() * attribs.get("WaterSpoutHeight") / 100.0)); - return true; - } else if (ability instanceof WaterSpoutWave) { - WaterSpoutWave abil = (WaterSpoutWave) ability; - if (attribs.containsKey("WaterSpoutWaveRadius")) - abil.setWaveRadius(abil.getWaveRadius() + abil.getWaveRadius() * attribs.get("WaterSpoutWaveRadius") / 100.0); - if (attribs.containsKey("WaterSpoutWaveRange")) - abil.setRadius(abil.getRadius() + abil.getRadius() * attribs.get("WaterSpoutWaveRange") / 100.0); - if (attribs.containsKey("WaterSpoutWaveSpeed")) - abil.setSpeed(abil.getSpeed() + abil.getSpeed() * attribs.get("WaterSpoutWaveSpeed") / 100.0); - if (attribs.containsKey("WaterSpoutWaveChargeTime")) - abil.setChargeTime(abil.getChargeTime() + abil.getChargeTime() * attribs.get("WaterSpoutWaveChargeTime") / 100.0); - if (attribs.containsKey("WaterSpoutWaveFlightTime")) - abil.setFlightTime(abil.getFlightTime() + abil.getFlightTime() * attribs.get("WaterSpoutWaveFlightTime") / 100.0); - return true; - } else if (ability instanceof SurgeWall) { - SurgeWall abil = (SurgeWall) ability; - if (attribs.containsKey("SurgeWallRadius")) - abil.setRadius(abil.getRadius() + abil.getRadius() * attribs.get("SurgeWallRadius") / 100.0); - if (attribs.containsKey("SurgeWallRange")) - abil.setRange(abil.getRange() + abil.getRange() * attribs.get("SurgeWallRange") / 100.0); - return true; - } else if (ability instanceof SurgeWave) { - SurgeWave abil = (SurgeWave) ability; - if (attribs.containsKey("SurgeWaveRadius")) - abil.setMaxRadius(abil.getMaxRadius() + abil.getMaxRadius() * attribs.get("SurgeWaveRadius") / 100.0); - if (attribs.containsKey("SurgeWaveKnockback")) - abil.setPushFactor(abil.getPushFactor() + abil.getPushFactor() * attribs.get("SurgeWaveKnockback") / 100.0); - if (attribs.containsKey("SurgeWaveKnockup")) - abil.setVerticalFactor(abil.getVerticalFactor() + abil.getVerticalFactor() * attribs.get("SurgeWaveKnockup") / 100.0); - if (attribs.containsKey("SurgeWaveFreezeSize")) - abil.setMaxFreezeRadius(abil.getMaxFreezeRadius() + abil.getMaxFreezeRadius() * attribs.get("SurgeWaveFreezeSize") / 100.0); - return true; - } - return false; - } -} diff --git a/src/com/projectkorra/items/attribute/AttributeList.java b/src/com/projectkorra/items/attribute/AttributeList.java deleted file mode 100644 index 1ff3600..0000000 --- a/src/com/projectkorra/items/attribute/AttributeList.java +++ /dev/null @@ -1,227 +0,0 @@ -package com.projectkorra.items.attribute; - -import com.projectkorra.projectkorra.Element; - -import org.bukkit.ChatColor; - -import java.util.ArrayList; - -public class AttributeList { - public static final double AIR_GLIDE_SPEED = 0.6; - public static final double AIR_GLIDE_FALL = -0.12; - public static final String CHARGES_STR = ChatColor.GOLD + "Charges: "; - public static final String SNEAK_CHARGES_STR = ChatColor.GOLD + "SneakCharges: "; - public static final String CLICK_CHARGES_STR = ChatColor.GOLD + "ClickCharges: "; - - public static final ArrayList ATTRIBUTES = new ArrayList() { - private static final long serialVersionUID = 1L; - { - // MISC - //add(new Attribute("GrapplingHook", "Lets the user shoot out a grappling hook by left clicking. They can then left click to launch themselves toward the destination, or sneak to slowly move to the destination.")); - add(new Attribute("ParticleEffects", "Plays a particle effect around a player whenever they use an ability. " + "Uses the form 'ParticleEffect: NAME::::', " + "amount (1 - inf), radius (0 - 100), duration (1 - inf), and speed (0 - 100) are optional. " + "Click http://pastebin.com/Trbh34WG to see the list of available particles. " + "For example: 'ParticleEffects: flame:5:100:10:100")); - - add(new Attribute("AllowFromInventory", "This item will work from the players inventory, even if it is not being held or worn.")); - add(new Attribute("RequireElement", "The user must have one of these elements to use this item. Works with Air, Water, Earth, Fire, Chi, Flight, Spiritual, Blood, Healing, Ice, Plant, Metal, Sand, Lava, Combustion, and Lightning. For example: 'RequireElement: Fire, Air, Chi'")); - add(new Attribute("RequireWorld", "The user must be located in one of these specific worlds to use this item. For example: 'RequireWorld: bendingworld, bendingarena, bendingrpg'")); - add(new Attribute("RequirePermission", "The user must have one of these permissions to use this item. For example: 'RequirePermission: bending.admin.*, essentials.command.give'")); - - add(new Attribute("Air", "improves all Air stats")); - add(new Attribute("Water", "improves all Water stats")); - add(new Attribute("Earth", "improves all Earth stats")); - add(new Attribute("Fire", "improves all Fire stats")); - add(new Attribute("Chi", "improves all Chi stats")); - - add(new Attribute("WaterSource", "acts as a temporary water source for water abilities")); - - add(new Attribute("Effects", "adds potion and bending effects whenever the player clicks, sneaks, or consumes the item. For example: Effects: JUMP:1:30, BlazeRange:25:30 would add Jump 1 and increase Blaze range by 25% for 30 seconds.")); - add(new Attribute("ClickEffects", "adds potion and bending effects when the player clicks")); - add(new Attribute("SneakEffects", "adds potion and bending effects when the player sneaks")); - add(new Attribute("ConsumeEffects", "adds potion and bending effects when this item is consumed")); - - add(new Attribute("Charges", "the number of charges remaining, charges are decreased by both clicking and sneaking, and an item stops working if it runs out of charges")); - add(new Attribute("ClickCharges", "charges are only decreased by clicking")); - add(new Attribute("SneakCharges", "charges are only decreased by sneaking")); - add(new Attribute("DestroyAfterCharges", "the item will be destroyed when the charges run out")); - add(new Attribute("IgnoreDestroyMessage", "the player will not receive a message that the item was destroyed when the charges run out")); - - add(new Attribute("WearOnly", "the item will only work if it is being worn as armor")); - add(new Attribute("HoldOnly", "the item will only work if it is being held")); - add(new Attribute("LeatherColor", "gives leather armor a specific color, specified as R,G,B. For example, LeatherColor:255,0,0 would be red armor")); - - add(new Attribute("AirGlide", "(true/false) allows an Airbender to glide through the air by sneaking")); - add(new Attribute("AirGlideSpeed", "modifies the air gliding speed", Element.AIR)); - add(new Attribute("AirGlideFallSpeed", "modifies the air gliding fall speed", Element.AIR, -1)); - add(new Attribute("AirGlideAutomatic", "(true/false) gliding will start the moment that the user switches to the slot, they don't have to sneak")); - - // AIR - add(new Attribute("AirBlastRange", "range", Element.AIR)); - add(new Attribute("AirBlastForce", "force", Element.AIR)); - - add(new Attribute("AirSwipeDamage", "damage", Element.AIR)); - add(new Attribute("AirSwipeForce", "knockback force", Element.AIR)); - add(new Attribute("AirSwipeSpeed", "travel speed", Element.AIR)); - add(new Attribute("AirSwipeRange", "range", Element.AIR)); - add(new Attribute("AirSwipeMaxCharge", "maximum possible charge damage", Element.AIR)); - add(new Attribute("AirSwipeRadius", "radius, Warning! hitting too many monsters at a time with airswipe can overload your server", Element.AIR)); - add(new Attribute("AirSwipeArc", "arc width, Warning! hitting too many monsters at a time with airswipe can overload your server", Element.AIR)); - add(new Attribute("AirSwipeChargeTime", "maximum charge time, lower is stronger", Element.AIR, -1)); - - add(new Attribute("AirShieldRadius", "radius", Element.AIR)); - - add(new Attribute("AirBubbleRadius", "radius", Element.AIR)); - - add(new Attribute("AirScooterSpeed", "speed", Element.AIR)); - - add(new Attribute("TornadoMaxHeight", "height", Element.AIR)); - add(new Attribute("TornadoMaxRadius", "radius", Element.AIR)); - add(new Attribute("TornadoRange", "maximum targettable range", Element.AIR)); - add(new Attribute("TornadoPlayerPushFactor", "knockback force against players", Element.AIR)); - add(new Attribute("TornadoNPCPushFactor", "knockback force gainst mobs", Element.AIR)); - - add(new Attribute("AirSpoutHeight", "height", Element.AIR)); - - add(new Attribute("AirSuctionSpeed", "travel speed", Element.AIR)); - add(new Attribute("AirSuctionRange", "range", Element.AIR)); - add(new Attribute("AirSuctionForce", "knockback force", Element.AIR)); - add(new Attribute("AirSuctionRadius", "affecting radius", Element.AIR)); - - // WATER - add(new Attribute("BloodbendingForce", "throwing force", Element.WATER)); - add(new Attribute("BloodbendingRange", "grabbing range", Element.WATER)); - add(new Attribute("BloodbendingHoldTime", "maximum hold time, only works if a base hold time is enabled in config", Element.WATER)); - add(new Attribute("BloodbendingCooldown", "cooldown, only works if a base cooldown is enabled in config", Element.WATER, -1)); - - add(new Attribute("WaterBubbleRadius", "radius", Element.WATER)); - - add(new Attribute("IceBlastRange", "range", Element.WATER)); - add(new Attribute("IceBlastDamage", "damage", Element.WATER)); - - add(new Attribute("IceSpikeDamage", "projectile damage", Element.WATER)); - add(new Attribute("IceSpikeRange", "projectile range", Element.WATER)); - - add(new Attribute("IceSpikePillarDamage", "pillar damage", Element.WATER)); - add(new Attribute("IceSpikePillarRange", "maximum clickable range", Element.WATER)); - - add(new Attribute("OctopusFormRange", "hit range", Element.WATER)); - add(new Attribute("OctopusFormDamage", "damage", Element.WATER)); - add(new Attribute("OctopusFormInterval", "animation interval, a lower interval is faster", Element.WATER, -1)); - add(new Attribute("OctopusFormKnockback", "knockback force", Element.WATER)); - add(new Attribute("OctopusFormRadius", "radius", Element.WATER)); - - add(new Attribute("TorrentDamage", "Torrent Stream damage", Element.WATER)); - add(new Attribute("TorrentRange", "Torrent Stream range", Element.WATER)); - add(new Attribute("TorrentStreamingDamage", "damage caused by enemies hitting the torrent while it is being circled around the player", Element.WATER)); - - add(new Attribute("TorrentWaveRadius", "radius", Element.WATER)); - add(new Attribute("TorrentWaveForce", "knockback force", Element.WATER)); - //add(new Attribute("TorrentWaveHeight", "height")); - - add(new Attribute("WaterManipulationRange", "range, you must click while the ability is in motion to extend the range", Element.WATER)); - add(new Attribute("WaterManipulationForce", "knockback force", Element.WATER)); - add(new Attribute("WaterManipulationDamage", "damage", Element.WATER)); - add(new Attribute("WaterManipulationCooldown", "cooldown", Element.WATER, -1)); - - add(new Attribute("WaterSpoutHeight", "height", Element.WATER)); - - add(new Attribute("WaterSpoutWaveRadius", "size of the rideable wave", Element.WATER)); - add(new Attribute("WaterSpoutWaveRange", "maximum travel range", Element.WATER)); - add(new Attribute("WaterSpoutWaveSpeed", "travel speed", Element.WATER)); - add(new Attribute("WaterSpoutWaveChargeTime", "initial chargetime", Element.WATER, -1)); - add(new Attribute("WaterSpoutWaveFlightTime", "total flight time", Element.WATER)); - add(new Attribute("IceWaveDamage", "damage", Element.WATER)); - - add(new Attribute("SurgeWallRadius", "radius", Element.WATER)); - add(new Attribute("SurgeWallRange", "the distance that the wall is away from the player", Element.WATER)); - - add(new Attribute("SurgeWaveRadius", "size of the wave", Element.WATER)); - add(new Attribute("SurgeWaveKnockback", "knockback force", Element.WATER)); - add(new Attribute("SurgeWaveKnockup", "knockup force", Element.WATER)); - add(new Attribute("SurgeWaveFreezeSize", "the size of the iceberg that covers the enemy", Element.WATER)); - - // EARTH - //add(new Attribute("CatapultLength", "length of the catapult earth pillar")); - //add(new Attribute("CatapultPush", "initial push distance")); - - add(new Attribute("EarthArmorStrength", "resistance potion potency", Element.EARTH)); - - add(new Attribute("EarthBlastRange", "range", Element.EARTH)); - add(new Attribute("EarthBlastDamage", "damage", Element.EARTH)); - add(new Attribute("EarthBlastForce", "knockback force", Element.EARTH)); - - add(new Attribute("EarthTunnelMaxRadius", "radius", Element.EARTH)); - add(new Attribute("EarthTunnelRange", "range", Element.EARTH)); - add(new Attribute("EarthTunnelInterval", "block remove speed, negative is better", Element.EARTH, -1)); - - //add(new Attribute("ShockwaveRadius", "radius")); - add(new Attribute("ShockwaveDamage", "damage", Element.EARTH)); - add(new Attribute("ShockwaveKnockback", "knockback force", Element.EARTH)); - add(new Attribute("ShockwaveChargeTime", "initial charge up time, negative is better", Element.EARTH, -1)); - - add(new Attribute("EarthSmashDamage", "shooting damage", Element.EARTH)); - add(new Attribute("EarthSmashGrabRange", "initial spawning distance", Element.EARTH)); - add(new Attribute("EarthSmashShootRange", "shooting range", Element.EARTH)); - add(new Attribute("EarthSmashChargeTime", "initial charge up time", Element.EARTH, -1)); - add(new Attribute("EarthSmashCooldown", "cooldown between uses, the config must have an initial cooldown set for this to work", Element.EARTH, -1)); - add(new Attribute("EarthSmashKnockback", "knockback force", Element.EARTH)); - add(new Attribute("EarthSmashKnockup", "knockup force", Element.EARTH)); - add(new Attribute("EarthSmashFlySpeed", "flying speed, if this is too high the ability will get buggy", Element.EARTH)); - add(new Attribute("EarthSmashFlyDuration", "flying duration", Element.EARTH)); - - // FIRE - add(new Attribute("HeatControlCookTime", "the time it takes to cook an item, negative is better")); - - add(new Attribute("FireBlastChargedDamage", "damage", Element.FIRE)); - add(new Attribute("FireBlastChargedRange", "range", Element.FIRE)); - add(new Attribute("FireBlastChargedExplosionRadius", "explosion radius, (power is more important)", Element.FIRE)); - add(new Attribute("FireBlastChargedPower", "explosion power and size", Element.FIRE)); - add(new Attribute("FireBlastChargedChargeTime", "initial charge up time", Element.FIRE, -1)); - - add(new Attribute("FireBlastSpeed", "travel speed", Element.FIRE)); - add(new Attribute("FireBlastForce", "knockback force", Element.FIRE)); - add(new Attribute("FireBlastRange", "travel range", Element.FIRE)); - add(new Attribute("FireBlastDamage", "damage", Element.FIRE)); - - add(new Attribute("FireJetDuration", "duration", Element.FIRE)); - add(new Attribute("FireJetSpeed", "speed", Element.FIRE)); - - add(new Attribute("FireShieldClickDuration", "duration of a click shield", Element.FIRE)); - add(new Attribute("FireShieldRadius", "radius of shift shield", Element.FIRE)); - add(new Attribute("FireShieldClickRadius", "radius of click shield", Element.FIRE)); - - add(new Attribute("BlazeRange", "range", Element.FIRE)); - - //add(new Attribute("WallOfFireRange", "the distance from the player")); - //add(new Attribute("WallOfFireHeight", "height")); - //add(new Attribute("WallOfFireWidth", "width")); - add(new Attribute("WallOfFireDuration", "duration", Element.FIRE)); - add(new Attribute("WallOfFireDamage", "the damage per interval", Element.FIRE)); - add(new Attribute("WallOfFireDamageInterval", "the time between damages, negative is better", Element.FIRE, -1)); - add(new Attribute("WallOfFireCooldown", "cooldown", Element.FIRE, -1)); - - add(new Attribute("LightningDamage", "damage", Element.FIRE)); - add(new Attribute("LightningRange", "range", Element.FIRE)); - add(new Attribute("LightningChargeTime", "initial charge up time", Element.FIRE, -1)); - add(new Attribute("LightningCooldown", "cooldown", Element.FIRE, -1)); - add(new Attribute("LightningSubArcChance", "chance for the arcs to split", Element.FIRE)); - add(new Attribute("LightningMaxChainArcs", "maximum amount of times an arc can chain to more enemies", Element.FIRE)); - add(new Attribute("LightningChainRange", "seeking range of chain arcs", Element.FIRE)); - add(new Attribute("LightningChainArcChance", "chance to chain to more enemies", Element.FIRE)); - add(new Attribute("LightningWaterRange", "range of water arcs", Element.FIRE)); - add(new Attribute("LightningStunChance", "chance for stun", Element.FIRE)); - add(new Attribute("LightningStunDuration", "duration of stun", Element.FIRE)); - - // CHI - add(new Attribute("AcrobatStanceJump", "jump potion potency, you may have to increase this a lot to see a difference", Element.CHI)); - add(new Attribute("AcrobatStanceSpeed", "speed potion potency, you may have to increase this a lot to see a difference", Element.CHI)); - - add(new Attribute("RapidPunchDamage", "damage per hit", Element.CHI)); - add(new Attribute("RapidPunchHits", "total amount of hits", Element.CHI)); - add(new Attribute("RapidPunchDistance", "distance", Element.CHI)); - add(new Attribute("RapidPunchCooldown", "cooldown, negative is better", Element.CHI, -1)); - - add(new Attribute("WarriorStanceStrength", "strength potion potency, you may have to increase this a lot to see a difference", Element.CHI)); - add(new Attribute("WarriorStanceResistance", "resistance potion potency, you may have to increase this a lot to see a difference", Element.CHI)); - - } - }; -} diff --git a/src/com/projectkorra/items/command/GiveCommand.java b/src/com/projectkorra/items/command/GiveCommand.java deleted file mode 100644 index 618c992..0000000 --- a/src/com/projectkorra/items/command/GiveCommand.java +++ /dev/null @@ -1,79 +0,0 @@ -package com.projectkorra.items.command; - -import java.util.List; - -import org.bukkit.ChatColor; -import org.bukkit.command.CommandSender; -import org.bukkit.entity.Player; -import org.bukkit.inventory.ItemStack; - -import com.projectkorra.items.Messages; -import com.projectkorra.items.ProjectKorraItems; -import com.projectkorra.items.customs.PKItem; - -public class GiveCommand extends PKICommand { - - public GiveCommand() { - super("give", "/bending items give [Amount] [Player]", "This command gives you or another player a bending item.", Messages.GIVE_ALIAS); - } - - @Override - public void execute(CommandSender sender, List args) { - if (correctLength(sender, args.size(), 0, 3)) { - if (hasPermission(sender)) { - if (args.size() == 0) { - sender.sendMessage(ChatColor.YELLOW + " ---- " + ChatColor.GOLD + "Item Names " + ChatColor.YELLOW + "----"); - for (PKItem citem : PKItem.itemList) - sender.sendMessage(ChatColor.YELLOW + citem.getName()); - return; - } - if (isPlayer(sender)) { - Player player = (Player)sender; - - PKItem ci = null; - ItemStack i = null; - int q = 1; - - if (args.size() >= 1) { - ci = PKItem.getCustomItem(args.get(0)); - - if (ci == null) { - sender.sendMessage(Messages.ITEM_NOT_FOUND); - return; - } - i = ci.generateItem(); - - if (args.size() >= 2) { - try { - q = Integer.parseInt(args.get(1)); - } catch (Exception e) { - sender.sendMessage(Messages.NOT_INT); - return; - } - i.setAmount(q); - - if (args.size() == 3) { - Player target = (Player)ProjectKorraItems.plugin.getServer().getPlayer(args.get(2)); - - if (target == null) { - sender.sendMessage(Messages.INVALID_PLAYER); - return; - } - - target.getInventory().addItem(i); - return; - } - } - } - player.getInventory().addItem(i); - return; - } - sender.sendMessage(Messages.PLAYER_ONLY); - return; - } - sender.sendMessage(Messages.NO_PERM); - return; - } - } - -} diff --git a/src/com/projectkorra/items/command/StatsCommand.java b/src/com/projectkorra/items/command/StatsCommand.java deleted file mode 100644 index 5c0a5ee..0000000 --- a/src/com/projectkorra/items/command/StatsCommand.java +++ /dev/null @@ -1,77 +0,0 @@ -package com.projectkorra.items.command; - -import java.util.ArrayList; -import java.util.List; - -import org.bukkit.ChatColor; -import org.bukkit.command.CommandSender; - -import com.projectkorra.items.Messages; -import com.projectkorra.items.attribute.Attribute; -import com.projectkorra.items.attribute.AttributeList; - -public class StatsCommand extends PKICommand { - - public StatsCommand() { - super("stats", "/bending items stats", "This command lists all stats which can be applied to a bending item", Messages.STATS_ALIAS); - } - - @Override - public void execute(CommandSender sender, List args) { - if (correctLength(sender, args.size(), 0, 1)) { - if (args.size() >= 0) { - if (!hasPermission(sender)) { - sender.sendMessage(Messages.NO_PERM); - return; - } else if (args.size() >= 0) { - int page = 1; - String phrase = null; - if (args.size() == 1) { - try { - page = Integer.parseInt(args.get(0)); - } - catch (Exception e) { - phrase = args.get(0); - } - } else if (args.size() == 1) { - phrase = args.get(0); - try { - page = Integer.parseInt(args.get(0)); - } - catch (Exception e) { - } - } - - ArrayList attribs = new ArrayList(AttributeList.ATTRIBUTES); - if (phrase != null) { - for (int i = 0; i < attribs.size(); i++) { - Attribute att = attribs.get(i); - if (!att.getName().toLowerCase().contains(phrase.toLowerCase())) { - attribs.remove(i); - i--; - } - } - } - - int maxPage = (attribs.size() - 1) / Messages.LINES_PER_PAGE; - page -= 1; - page = page < 0 ? 0 : page; - page = page > maxPage ? maxPage : page; - int pageIndex = page * Messages.LINES_PER_PAGE; - sender.sendMessage(ChatColor.YELLOW + " ---- " + ChatColor.GOLD + "Stats " + ChatColor.YELLOW + "-- " + ChatColor.GOLD + "Page " + ChatColor.RED + (page + 1) + ChatColor.GOLD + "/" + ChatColor.RED + (maxPage + 1) + ChatColor.YELLOW + " ----"); - for (int i = pageIndex; i < pageIndex + Messages.LINES_PER_PAGE; i++) { - if (i >= 0 && i < attribs.size()) { - Attribute att = attribs.get(i); - sender.sendMessage(ChatColor.YELLOW + att.getName() + ": " + ChatColor.WHITE + att.getDesc()); - } else - break; - } - if (phrase != null) - sender.sendMessage(ChatColor.GOLD + "Phrase: " + ChatColor.RED + phrase); - return; - } - } - } - } - -} diff --git a/src/com/projectkorra/items/customs/EnchantGlow.java b/src/com/projectkorra/items/customs/EnchantGlow.java deleted file mode 100644 index 7183019..0000000 --- a/src/com/projectkorra/items/customs/EnchantGlow.java +++ /dev/null @@ -1,76 +0,0 @@ -package com.projectkorra.items.customs; - -import org.bukkit.enchantments.Enchantment; -import org.bukkit.enchantments.EnchantmentTarget; -import org.bukkit.enchantments.EnchantmentWrapper; -import org.bukkit.inventory.ItemStack; - -import java.lang.reflect.Field; - -public class EnchantGlow extends EnchantmentWrapper { - private static Enchantment glow; - - public EnchantGlow(int id) { - super(id); - } - - @Override - public boolean canEnchantItem(ItemStack item) { - return true; - } - - @Override - public boolean conflictsWith(Enchantment other) { - return false; - } - - @Override - public EnchantmentTarget getItemTarget() { - return null; - } - - @Override - public int getMaxLevel() { - return 10; - } - - @Override - public String getName() { - return "Glow"; - } - - @Override - public int getStartLevel() { - return 1; - } - - public static Enchantment getGlow() { - if (glow != null) { - return glow; - } - - try { - Field f = Enchantment.class.getDeclaredField("acceptingNew"); - f.setAccessible(true); - f.set(null, true); - } - catch (Exception e) { - e.printStackTrace(); - } - - glow = new EnchantGlow(255); - try { - Enchantment.registerEnchantment(glow); - } - catch (IllegalArgumentException e) { - } - - return glow; - } - - public static void addGlow(ItemStack item) { - Enchantment glow = getGlow(); - - item.addEnchantment(glow, 1); - } -} diff --git a/src/com/projectkorra/items/items/GrapplingHook.java b/src/com/projectkorra/items/items/GrapplingHook.java deleted file mode 100644 index 245aadc..0000000 --- a/src/com/projectkorra/items/items/GrapplingHook.java +++ /dev/null @@ -1,215 +0,0 @@ -package com.projectkorra.items.items; - -import com.projectkorra.items.ProjectKorraItems; -import com.projectkorra.items.attribute.Action; -import com.projectkorra.items.utils.ElementUtils; -import com.projectkorra.projectkorra.GeneralMethods; -import com.projectkorra.projectkorra.util.ParticleEffect; - -import org.bukkit.Location; -import org.bukkit.block.Block; -import org.bukkit.entity.Player; -import org.bukkit.scheduler.BukkitRunnable; -import org.bukkit.util.BlockIterator; -import org.bukkit.util.Vector; - -import java.util.concurrent.ConcurrentHashMap; - -/** - * Grappling Hooks let the player grab onto blocks and fling themselves toward a - * destination location. They can cause a fling to occur by left clicking, or - * they can hold sneak to slowly climb the Grappling Hook, causing them to - * slowly ascend to the destination. - * - * TODO: This class is unfinished due to some issues with making the particle - * animations realistic for a grappling hook. - */ -public class GrapplingHook { - - /** - * Represents the possible states that a GrapplingHook can be in. - */ - public static enum State { - START, SHOOTING, HOOKED, FLUNG, CLIMBING - } - - public static final ConcurrentHashMap INSTANCES = new ConcurrentHashMap(); - public static final double SPEED = 5; - public static final double RANGE = 30; - - private State state; - private Player player; - private GrapplingHookTask task; - private Location currentLoc; - private Vector direction; - private double speed; - private double range; - private double red, green, blue; - - /** - * Attempt to create a new Grappling Hook, fling a currently existing - * grappling hook, or retract a hook, all depending on the type of action. - * - * @param player the player that used a grappling hook - * @param action either Action.SHIFT, or Action.LEFTCLICK - */ - public GrapplingHook(Player player, Action action) { - if (INSTANCES.containsKey(player.getName())) { - GrapplingHook hook = INSTANCES.get(player.getName()); - if (hook.state == State.HOOKED) { - if (action == Action.LEFT_CLICK) { - - } else if (action == Action.RIGHT_CLICK) { - - } else if (action == Action.SHIFT) { - - } - } - return; - } - - this.state = State.START; - this.player = player; - this.speed = SPEED; - this.range = RANGE; - INSTANCES.put(player.getName(), this); - task = new GrapplingHookTask(this); - task.runTaskTimer(ProjectKorraItems.plugin, 0, 1); - } - - /** - * The GrapplingHookTask is the manipulates the specific instance of a - * GrapplingHook after it has been initially created. This task does its - * action based on the State of the GrapplingHook that created this task. If - * that variable is changed then this task will follow in turn. - */ - public class GrapplingHookTask extends BukkitRunnable { - GrapplingHook hook; - - public GrapplingHookTask(GrapplingHook hook) { - this.hook = hook; - } - - public void run() { - if (player == null || player.isDead() || !player.isOnline()) { - cancel(); - return; - } - if (currentLoc != null) { - if (!player.getWorld().equals(currentLoc.getWorld()) || currentLoc.distanceSquared(player.getEyeLocation()) > Math.pow(range, 2)) { - cancel(); - return; - } - } - - if (state == State.START) { - state = State.SHOOTING; - direction = player.getEyeLocation().toVector().normalize(); - currentLoc = player.getEyeLocation(); - } else if (state == State.SHOOTING) { - /* - * Use an iterator in case the speed value is too big, it would - * normally cause blocks to be skipped if we just jumped - * directly. - */ - playAnimation(player.getEyeLocation().add(0, -0.5, 0), currentLoc, 1, (float) 0.1, (float) red, (float) green, (float) blue); - BlockIterator iter = new BlockIterator(currentLoc.getWorld(), currentLoc.toVector(), direction, 0, (int) speed + 1); - currentLoc = currentLoc.add(direction.clone().multiply(speed)); - while (iter.hasNext()) { - Block block = iter.next(); - if (!ElementUtils.isTransparent(block.getType())) { - currentLoc = block.getLocation(); - state = State.HOOKED; - break; - } - } - } else if (state == State.HOOKED) { - playAnimation(player.getEyeLocation().add(0, -0.5, 0), currentLoc, 1, (float) 0.1, (float) red, (float) green, (float) blue); - } - - } - - public void cancel() { - super.cancel(); - hook.task = null; - hook.cancel(); - } - } - - /** - * Cancels and removes this instance of GrapplingHook. - */ - public void cancel() { - if (task != null) - task.cancel(); - INSTANCES.remove(player.getName()); - } - - /** - * Displays the GrapplingHook "Beam" animation. - * - * @param loc1 the starting location - * @param loc2 the ending location - * @param incr the spacing between each individual particle - * @param density the density of each particle - * @param r amount of red in the particle (0 - 255) - * @param g amount of green in the particle (0 - 255) - * @param b amount of blue in the particle (0 - 255) - */ - public static void playAnimation(Location loc1, Location loc2, double incr, float density, float r, float g, float b) { - Location iter = loc1.clone(); - Vector dir = GeneralMethods.getDirection(loc1, loc2).normalize(); - while (iter.distanceSquared(loc1) <= iter.distanceSquared(loc2)) { - ParticleEffect.RED_DUST.display(r, g, b, density, 0, iter, 256); - iter = iter.add(dir.clone().multiply(incr)); - } - } - - /** - * Displays the GrapplingHook "Beam" animation. - * - * @param loc1 the starting location - * @param loc2 the ending location - * @param incr the spacing between each individual particle - * @param density the density of each particle - */ - public static void playAnimation(Location loc1, Location loc2, double incr, float density) { - playAnimation(loc1, loc2, incr, density, 0F, 0F, 0F); - } - - public State getState() { - return state; - } - - public void setState(State state) { - this.state = state; - } - - public Player getPlayer() { - return player; - } - - public GrapplingHookTask getTask() { - return task; - } - - public void setTask(GrapplingHookTask task) { - this.task = task; - } - - public Location getCurrentLoc() { - return currentLoc; - } - - public void setCurrentLoc(Location currentLoc) { - this.currentLoc = currentLoc; - } - - public Vector getDirection() { - return direction; - } - - public void setDirection(Vector direction) { - this.direction = direction; - } -} diff --git a/src/main/java/com/projectkorra/items/ConfigManager.java b/src/main/java/com/projectkorra/items/ConfigManager.java new file mode 100644 index 0000000..bfb0fcf --- /dev/null +++ b/src/main/java/com/projectkorra/items/ConfigManager.java @@ -0,0 +1,137 @@ +package com.projectkorra.items; + +import com.projectkorra.items.attribute.Attribute; +import com.projectkorra.items.customs.PKItem; +import org.bukkit.configuration.ConfigurationSection; +import org.bukkit.configuration.file.FileConfiguration; +import org.checkerframework.checker.nullness.qual.NonNull; + +import java.util.*; + +public class ConfigManager { + public static final String DNAME_PREF = "displayname"; + public static final String LORE_PREF = "lore"; + public static final String SHAPED_RECIPE_PREF = "shapedrecipe"; + public static final String UNSHAPED_RECIPE_PREF = "unshapedrecipe"; + public static final String MATERIAL_PREF = "material"; + public static final String AMT_PREF = "amount"; + public static final String ATTR_PREF = "stats"; + public static final String GLOW_PREF = "glow"; + + + public ConfigManager() { + ProjectKorraItems.plugin.saveDefaultConfig(); + reloadConfig(); + } + + /** + * Reloads the config file. + */ + private void reloadConfig() { + PKItem.items.clear(); + PKItem.itemList.clear(); + try { + FileConfiguration config = ProjectKorraItems.plugin.getConfig(); + // if (config == null) { + // ProjectKorraItems.log.info(Messages.NO_CONFIG); + // } + Set itemNames = config.getKeys(false); + for (String itemName : itemNames) { + ConfigurationSection itemSection = config.getConfigurationSection(itemName); + if (itemSection == null) { + ProjectKorraItems.log.warning(Messages.BAD_ITEM + " " + itemName + ": " + Messages.BAD_VALUE); + continue; + } + try { + loadItem(itemName, itemNames, itemSection); + } + catch (Exception ex) { + ProjectKorraItems.log.warning(Messages.BAD_ITEM + " " + itemName); + ex.printStackTrace(); + } + } + } + catch (Exception ex) { + ProjectKorraItems.log.severe(Messages.BAD_FILE); + ex.printStackTrace(); + } + } + + private void loadItem(@NonNull String itemName, @NonNull Set customItemNames, @NonNull ConfigurationSection itemConfig) { + PKItem item = new PKItem(); + item.updateName(itemName); + Set keys = itemConfig.getKeys(false); + boolean hasRecipe = false; + for (String key : keys) { + switch(key.toLowerCase()) { + case DNAME_PREF: + item.updateDisplayName(itemConfig.getString(key)); + break; + case LORE_PREF: + item.updateLore(itemConfig.getString(key)); + break; + case SHAPED_RECIPE_PREF: + if (hasRecipe) { + ProjectKorraItems.log.warning(Messages.DUPLICATED_RECIPE + " (" + itemName + ")"); + return; + } + item.updateRecipe(itemConfig.getString(key), customItemNames); + item.setUnshapedRecipe(false); + hasRecipe = true; + break; + case UNSHAPED_RECIPE_PREF: + if (hasRecipe) { + ProjectKorraItems.log.warning(Messages.DUPLICATED_RECIPE + " (" + itemName + ")"); + return; + } + item.updateDisplayName(itemConfig.getString(key)); + item.setUnshapedRecipe(true); + hasRecipe = true; + break; + case MATERIAL_PREF: + item.updateMaterial(itemConfig.getString(key)); + break; + case AMT_PREF: + item.updateQuantity(itemConfig.getInt(key)); + break; + case ATTR_PREF: + updateAttributes(item, Objects.requireNonNull(itemConfig.getConfigurationSection(key))); + break; + case GLOW_PREF: + item.updateGlow(itemConfig.getBoolean(key)); + break; + } + } + item.build(); + } + + private void updateAttributes(@NonNull PKItem item, @NonNull ConfigurationSection cs) { + for (String attributeName : cs.getKeys(false)) { + Attribute att = Attribute.getAttribute(attributeName); + if (att == null) { + ProjectKorraItems.log.info(Messages.BAD_ATTRIBUTE + ": " + attributeName); + continue; + } + Attribute newAtt = new Attribute(att.getName()); + String valueStr = Objects.requireNonNull(cs.getString(attributeName)).trim(); + valueStr = valueStr.replaceAll("(?i)true", "1"); + valueStr = valueStr.replaceAll("(?i)false", "0"); + String[] commaSplit = valueStr.split(","); + if (commaSplit.length == 0) { + ProjectKorraItems.log.info(Messages.MISSING_VALUES + ": " + valueStr); + continue; + } + newAtt.getValues().addAll(Arrays.asList(commaSplit)); + item.getAttributes().add(newAtt); + } + } + + /** + * Gathers the names of all of the custom items within the config file. + * + * @return a set containing the item names + */ + public Set getConfigItemNames() { + return ProjectKorraItems.plugin.getConfig().getKeys(false); + } +} diff --git a/src/com/projectkorra/items/Messages.java b/src/main/java/com/projectkorra/items/Messages.java similarity index 96% rename from src/com/projectkorra/items/Messages.java rename to src/main/java/com/projectkorra/items/Messages.java index a7bf574..91812f4 100644 --- a/src/com/projectkorra/items/Messages.java +++ b/src/main/java/com/projectkorra/items/Messages.java @@ -2,6 +2,7 @@ import org.bukkit.ChatColor; +import java.util.Map; import java.util.concurrent.ConcurrentHashMap; public class Messages { @@ -9,7 +10,7 @@ public class Messages { * logDelay is used to store the times that a message was logged by * logTimedMessage. **/ - public static ConcurrentHashMap logDelay = new ConcurrentHashMap(); + public static Map logDelay = new ConcurrentHashMap<>(); /** The amount of stats that are displayed when calling /bi stats **/ public static final int LINES_PER_PAGE = 10; @@ -36,6 +37,7 @@ public class Messages { public static final String DUPLICATE_ITEM = "an item with this name already exists"; public static final String BAD_RECIPE_MAT = "invalid recipe material"; public static final String BAD_RECIPE = "an error occured while parsing the recipe"; + public static final String DUPLICATED_RECIPE = "duplicated recipe section"; public static final String BAD_DAMAGE = "invalid durability value"; public static final String BAD_QUANTITY = "invalid amount value"; public static final String BAD_LORE = "invalid lore"; @@ -43,6 +45,7 @@ public class Messages { public static final String BAD_DNAME = "invalid display name"; public static final String BAD_MATERIAL = "invalid material"; public static final String BAD_NAME = "invalid name"; + public static final String BAD_ATTRIBUTE = "invalid attribute"; public static final String BAD_CHARGES = "invalid charges value"; public static final String BAD_VALUE = "an issue occured with this value"; public static final String BAD_PARTICLE_EFFECT = "this particle effect could not be found"; @@ -88,7 +91,6 @@ public static void logTimedMessage(String msg, long delay) { * displayed again for a set amount of time. * * @param msg the message to log - * @param delay the delay between duplicating msg */ public static void logTimedMessage(String msg) { logTimedMessage(msg, Messages.LOG_DELAY); diff --git a/src/com/projectkorra/items/MetricsLite.java b/src/main/java/com/projectkorra/items/MetricsLite.java similarity index 96% rename from src/com/projectkorra/items/MetricsLite.java rename to src/main/java/com/projectkorra/items/MetricsLite.java index 3d988db..3443743 100644 --- a/src/com/projectkorra/items/MetricsLite.java +++ b/src/main/java/com/projectkorra/items/MetricsLite.java @@ -47,6 +47,7 @@ import java.net.URL; import java.net.URLConnection; import java.net.URLEncoder; +import java.nio.charset.StandardCharsets; import java.util.UUID; import java.util.logging.Level; import java.util.zip.GZIPOutputStream; @@ -203,13 +204,7 @@ public boolean isOptOut() { // Reload the metrics file configuration.load(getConfigFile()); } - catch (IOException ex) { - if (debug) { - Bukkit.getLogger().log(Level.INFO, "[Metrics] " + ex.getMessage()); - } - return true; - } - catch (InvalidConfigurationException ex) { + catch (IOException | InvalidConfigurationException ex) { if (debug) { Bukkit.getLogger().log(Level.INFO, "[Metrics] " + ex.getMessage()); } @@ -361,7 +356,7 @@ private void postPlugin(boolean isPing) throws IOException { connection.setDoOutput(true); if (debug) { - System.out.println("[Metrics] Prepared request for " + pluginName + " uncompressed=" + uncompressed.length + " compressed=" + compressed.length); + plugin.getLogger().info("[Metrics] Prepared request for " + pluginName + " uncompressed=" + uncompressed.length + " compressed=" + compressed.length); } // Write the data @@ -400,7 +395,7 @@ public static byte[] gzip(String input) { try { gzos = new GZIPOutputStream(baos); - gzos.write(input.getBytes("UTF-8")); + gzos.write(input.getBytes(StandardCharsets.UTF_8)); } catch (IOException e) { e.printStackTrace(); @@ -502,7 +497,7 @@ private static String escapeJSON(String text) { default: if (chr < ' ') { String t = "000" + Integer.toHexString(chr); - builder.append("\\u" + t.substring(t.length() - 4)); + builder.append("\\u").append(t.substring(t.length() - 4)); } else { builder.append(chr); } @@ -521,7 +516,7 @@ private static String escapeJSON(String text) { * @return the encoded text, as UTF-8 */ private static String urlEncode(final String text) throws UnsupportedEncodingException { - return URLEncoder.encode(text, "UTF-8"); + return URLEncoder.encode(text, StandardCharsets.UTF_8); } } diff --git a/src/com/projectkorra/items/ProjectKorraItems.java b/src/main/java/com/projectkorra/items/ProjectKorraItems.java similarity index 83% rename from src/com/projectkorra/items/ProjectKorraItems.java rename to src/main/java/com/projectkorra/items/ProjectKorraItems.java index 20b3e83..13bd640 100644 --- a/src/com/projectkorra/items/ProjectKorraItems.java +++ b/src/main/java/com/projectkorra/items/ProjectKorraItems.java @@ -4,13 +4,13 @@ import java.util.concurrent.ConcurrentHashMap; import java.util.logging.Logger; -import org.bukkit.entity.Player; +import com.projectkorra.items.listeners.PKIListener; import org.bukkit.plugin.PluginDescriptionFile; import org.bukkit.plugin.PluginManager; import org.bukkit.plugin.java.JavaPlugin; import com.projectkorra.items.abilityupdater.AbilityUpdater; -import com.projectkorra.items.attribute.AttributeListener; +import com.projectkorra.items.listeners.AttributeListener; import com.projectkorra.items.command.BaseCommand; import com.projectkorra.items.command.EquipCommand; import com.projectkorra.items.command.GiveCommand; @@ -22,6 +22,7 @@ public class ProjectKorraItems extends JavaPlugin { public static ProjectKorraItems plugin; public static Logger log; + private AttributeListener attrListener; @Override public void onEnable() { @@ -39,15 +40,18 @@ public void onEnable() { new StatsCommand(); new ConfigManager(); - PKIDisplay.displays = new ConcurrentHashMap(); + PKIDisplay.displays = new ConcurrentHashMap<>(); PluginManager pm = this.getServer().getPluginManager(); // pm.registerEvents(new PKIListener(), this); - pm.registerEvents(new AttributeListener(), this); + attrListener = new AttributeListener(this); + pm.registerEvents(attrListener, this); pm.registerEvents(new AbilityUpdater(), this); + + // ArmorEquipEvent.registerListener(this); // @@ -62,6 +66,7 @@ public void onEnable() { @Override public void onDisable() { + attrListener.stop(); PluginDescriptionFile pdfFile = this.getDescription(); log.info(pdfFile.getName() + " Has Been Disabled!"); diff --git a/src/com/projectkorra/items/abilityupdater/AbilityUpdater.java b/src/main/java/com/projectkorra/items/abilityupdater/AbilityUpdater.java similarity index 55% rename from src/com/projectkorra/items/abilityupdater/AbilityUpdater.java rename to src/main/java/com/projectkorra/items/abilityupdater/AbilityUpdater.java index 6fa5b4c..98b4fe0 100644 --- a/src/com/projectkorra/items/abilityupdater/AbilityUpdater.java +++ b/src/main/java/com/projectkorra/items/abilityupdater/AbilityUpdater.java @@ -1,10 +1,9 @@ package com.projectkorra.items.abilityupdater; -import java.util.ArrayList; -import java.util.concurrent.ConcurrentHashMap; - +import com.projectkorra.projectkorra.ability.Ability; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; import org.bukkit.event.Listener; import org.bukkit.inventory.ItemStack; import org.bukkit.scheduler.BukkitRunnable; @@ -19,18 +18,105 @@ import com.projectkorra.projectkorra.event.AbilityStartEvent; import com.projectkorra.projectkorra.util.ParticleEffect; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + public class AbilityUpdater implements Listener { - - @EventHandler - public void onDamage(AbilityDamageEntityEvent event) { - updateAbilityDamage(event.getAbility().getPlayer(), event.getAbility()); + private final Set abilityWithStart = new HashSet<>(); + + + /* + private boolean isSetDoubleType(Ability ability) { + boolean result = true; + + if (ability instanceof FireBurst) + result = false; + else if (ability instanceof WallOfFire) + result = false; + else if (ability instanceof OctopusForm) + result = false; + + return result; } - - @EventHandler - public void onStart(AbilityStartEvent event) { - updateAbility(event.getAbility().getPlayer(), event.getAbility()); + + private String getDamageMod(Ability ability) { + String methodMod = ""; + + if (ability instanceof WaterArmsWhip) + methodMod = "Punch"; + else if (ability instanceof WaterArmsSpear) + methodMod = "Spear"; + else if (ability instanceof Torrent) + methodMod = "Deflect"; + else if (ability instanceof WaterArmsFreeze) + methodMod = "Ice"; + + return methodMod; + } + + private Double getDamage(Ability ability, String methodMod) { + Double damage = null; + + if (!ability.isHarmlessAbility()) { + try { + Method getDamageMethod = ability.getClass().getMethod("get" + methodMod + "Damage"); + damage = (double) getDamageMethod.invoke(ability); + } catch (NoSuchMethodException | InvocationTargetException | IllegalAccessException e) { + // e.printStackTrace(); + } + } + + return damage; + } + + private void setDamage(Ability ability, String methodMod, Double damage) { + try { + Class setMethodType = double.class; + boolean isDouble = isSetDoubleType(ability); + if (!isDouble) + setMethodType = int.class; + Method setDamageMethod = ability.getClass().getMethod("set" + methodMod + "Damage", setMethodType); + if (isDouble) + setDamageMethod.invoke(ability, damage); + else + setDamageMethod.invoke(ability, damage.intValue()); + } catch (NoSuchMethodException | InvocationTargetException | IllegalAccessException e) { + // e.printStackTrace(); + } + } + */ + + + @EventHandler(priority = EventPriority.HIGH) + public void onAbilityStart(AbilityStartEvent ev) { + abilityWithStart.add(ev.getAbility().getName()); + updateDamageAttributes(ev.getAbility()); + } + + + private void updateDamageAttributes(Ability ability) { + Player player = ability.getPlayer(); + // String damageMod = getDamageMod(ability); + // Double damage = getDamage(ability, damageMod); + + if (!ability.isHarmlessAbility()) { + updateAbilityDamage(player, ability); + } + updateAbility(player, ability); } + + @EventHandler(priority = EventPriority.HIGH) + public void onDamage(AbilityDamageEntityEvent ev) { + Ability ability = ev.getAbility(); + if (!abilityWithStart.contains(ability.getName())) { + updateDamageAttributes(ability); + } + } + + /** * Attempts to update an ability based on the attribute effects of a * specific player. Also calls a method to handle any particle effects that @@ -46,7 +132,7 @@ public static void updateAbility(Player player, Object ability) { boolean abilityAdded = true; - ConcurrentHashMap attribs = AttributeUtils.getSimplePlayerAttributeMap(player); + Map attribs = AttributeUtils.getSimplePlayerAttributeMap(player); if (FireUpdater.updateAbility(player, ability, attribs)) { AttributeUtils.decreaseCharges(player, null); @@ -67,14 +153,14 @@ public static void updateAbility(Player player, Object ability) { } } - public static void updateAbilityDamage(Player player, Object ability) { + public static void updateAbilityDamage(Player player, Ability ability) { if (player == null) { return; } boolean abilityAdded = true; - ConcurrentHashMap attribs = AttributeUtils.getSimplePlayerAttributeMap(player); + Map attribs = AttributeUtils.getSimplePlayerAttributeMap(player); if (FireUpdater.updateAbilityDamage(player, ability, attribs)) { AttributeUtils.decreaseCharges(player, null); @@ -99,10 +185,10 @@ public static void updateAbilityDamage(Player player, Object ability) { * If the player has an item with the stat "ParticleEffects" then we will * parse the information and display a particle effect around the player. * - * @param player + * @param player the player to update */ private static void updatePlayerParticles(Player player) { - ArrayList equipment = ItemUtils.getPlayerValidEquipment(player); + List equipment = ItemUtils.getPlayerValidEquipment(player); for (ItemStack istack : equipment) { PKItem citem = PKItem.getCustomItem(istack); if (citem == null) @@ -112,15 +198,17 @@ private static void updatePlayerParticles(Player player) { if (attr == null) continue; - ArrayList values = attr.getValues(); + List values = attr.getValues(); for (String value : values) { String[] colonSplit = value.split(":"); if (colonSplit.length == 0) continue; String particleName = colonSplit[0]; - ParticleEffect effect = ParticleEffect.fromName(particleName.trim()); - if (effect == null) { + ParticleEffect effect; + try { + effect = ParticleEffect.valueOf(particleName.trim()); + } catch (IllegalArgumentException ex) { Messages.logTimedMessage(Messages.BAD_PARTICLE_EFFECT + ": " + particleName); continue; } @@ -139,8 +227,7 @@ private static void updatePlayerParticles(Player player) { if (colonSplit.length >= 5) speed = Double.parseDouble(colonSplit[4]); } - catch (NumberFormatException e) { - } + catch (NumberFormatException ignore) {} radius /= 100; speed /= 100; @@ -152,7 +239,7 @@ private static void updatePlayerParticles(Player player) { for (int i = 0; i < duration; i++) { new BukkitRunnable() { public void run() { - feffect.display(fplayer.getEyeLocation(), (float) fradius, (float) fradius, (float) fradius, (float) fspeed, (int) famount); + feffect.display(fplayer.getEyeLocation(), (int) famount, (float) fradius, (float) fradius, (float) fradius, (float) fspeed); } }.runTaskLater(ProjectKorraItems.plugin, i); } diff --git a/src/main/java/com/projectkorra/items/abilityupdater/AirUpdater.java b/src/main/java/com/projectkorra/items/abilityupdater/AirUpdater.java new file mode 100644 index 0000000..860d682 --- /dev/null +++ b/src/main/java/com/projectkorra/items/abilityupdater/AirUpdater.java @@ -0,0 +1,392 @@ +package com.projectkorra.items.abilityupdater; + +import com.projectkorra.projectkorra.airbending.AirBlast; +import com.projectkorra.projectkorra.airbending.AirBurst; +import com.projectkorra.projectkorra.airbending.AirScooter; +import com.projectkorra.projectkorra.airbending.AirShield; +import com.projectkorra.projectkorra.airbending.AirSpout; +import com.projectkorra.projectkorra.airbending.AirSuction; +import com.projectkorra.projectkorra.airbending.AirSwipe; +import com.projectkorra.projectkorra.airbending.Suffocate; +import com.projectkorra.projectkorra.airbending.Tornado; +import com.projectkorra.projectkorra.airbending.combo.AirStream; +import com.projectkorra.projectkorra.airbending.combo.AirSweep; +import com.projectkorra.projectkorra.airbending.combo.Twister; +import com.projectkorra.projectkorra.airbending.flight.FlightMultiAbility; + +import org.bukkit.entity.Player; + +import java.util.Map; + +public class AirUpdater { + + /** + * updates the air abilities based on a players bending effect attributes + * + * @param player the player that has the effects + * @param ability an instance of a air ability + * @param attribs the map of the players effects + * @return if the ability was updated correctly + */ + + public static boolean updateAbilityDamage(Player player, Object ability, Mapattribs) { + if (ability instanceof AirBlast) { + AirBlast abil = (AirBlast) ability; + + if (attribs.containsKey("AirBlastDamage")) + abil.setDamage(abil.getDamage() + abil.getDamage() * attribs.get("AirBlastDamage") / 100.0); + + return true; + } + else if (ability instanceof AirBurst) { + AirBurst abil = (AirBurst) ability; + + if (attribs.containsKey("AirBurstDamage")) + abil.setDamage(abil.getDamage() + abil.getDamage() * attribs.get("AirBurstDamage") / 100.0); + + return true; + } + else if (ability instanceof AirSweep) { + AirSweep abil = (AirSweep) ability; + + if (attribs.containsKey("AirSweepDamage")) + abil.setDamage(abil.getDamage() + abil.getDamage() * attribs.get("AirSweepDamage") / 100.0); + + return true; + } + else if (ability instanceof AirSwipe) { + AirSwipe abil = (AirSwipe) ability; + + if (attribs.containsKey("AirSwipeDamage")) + abil.setDamage(abil.getDamage() + abil.getDamage() * attribs.get("AirSwipeDamage") / 100.0); + + return true; + } + else if (ability instanceof Suffocate) { + Suffocate abil = (Suffocate) ability; + + if (attribs.containsKey("SuffocateDamage")) + abil.setDamage(abil.getDamage() + abil.getDamage() * attribs.get("SuffocateDamage") / 100.0); + + return true; + } + + return false; + } + + public static boolean updateAbility(Player player, Object ability, Map attribs) { + if (ability instanceof AirBlast) { + AirBlast abil = (AirBlast) ability; + + if (attribs.containsKey("AirBlastCooldown")) + abil.setCooldown((long) (abil.getCooldown() + abil.getCooldown() * attribs.get("AirBlastCooldown") / 100.0)); + + if (attribs.containsKey("AirBlastParticles")) + abil.setParticles((int) (abil.getParticles() + abil.getParticles() * attribs.get("AirBlastParticles") / 100.0)); + + if (attribs.containsKey("AirBlastPushFactor")) + abil.setPushFactor(abil.getPushFactor() + abil.getPushFactor() * attribs.get("AirBlastPushFactor") / 100.0); + + if (attribs.containsKey("AirBlastPushFactorForOthers")) + abil.setPushFactorForOthers(abil.getPushFactorForOthers() + abil.getPushFactorForOthers() * attribs.get("AirBlastPushFactorForOthers") / 100.0); + + if (attribs.containsKey("AirBlastRadius")) + abil.setRadius(abil.getRadius() + abil.getRadius() * attribs.get("AirBlastRadius") / 100.0); + + if (attribs.containsKey("AirBlastRange")) + abil.setRange(abil.getRange() + abil.getRange() * attribs.get("AirBlastRange") / 100.0); + + if (attribs.containsKey("AirBlastSpeed")) + abil.setSpeed(abil.getSpeed() + abil.getSpeed() * attribs.get("AirBlastSpeed") / 100.0); + + if (attribs.containsKey("AirBlastSpeedFactor")) + abil.setSpeedFactor(abil.getSpeedFactor() + abil.getSpeedFactor() * attribs.get("AirBlastSpeedFactor") / 100.0); + + //if (attribs.containsKey("AirBlastTicks")) + // abil.setTicks((int) (abil.getTicks() + abil.getTicks() * attribs.get("AirBlastTicks") / 100.0)); + + return true; + } + else if (ability instanceof AirBurst) { + AirBurst abil = (AirBurst) ability; + + if (attribs.containsKey("AirBurstBlastAnglePhi")) + abil.setBlastAnglePhi(abil.getBlastAnglePhi() + abil.getBlastAnglePhi() * attribs.get("AirBurstBlastAnglePhi") / 100.0); + + if (attribs.containsKey("AirBurstBlastAngleTheta")) + abil.setBlastAngleTheta(abil.getBlastAngleTheta() + abil.getBlastAngleTheta() * attribs.get("AirBurstBlastAngleTheta") / 100.0); + + if (attribs.containsKey("AirBurstChargeTime")) + abil.setChargeTime((long) (abil.getChargeTime() + abil.getChargeTime() * attribs.get("AirBurstChargeTime") / 100.0)); + + if (attribs.containsKey("AirBurstFallThreshold")) + abil.setFallThreshold(abil.getFallThreshold() + abil.getFallThreshold() * attribs.get("AirBurstFallThreshold") / 100.0); + + if (attribs.containsKey("AirBurstPushFactor")) + abil.setPushFactor(abil.getPushFactor() + abil.getPushFactor() * attribs.get("AirBurstPushFactor") / 100.0); + + return true; + } + else if (ability instanceof AirScooter) { + AirScooter abil = (AirScooter) ability; + + if (attribs.containsKey("AirScooterCooldown")) + abil.setCooldown((long) (abil.getCooldown() + abil.getCooldown() * attribs.get("AirScooterCooldown") / 100.0)); + + if (attribs.containsKey("AirScooterInterval")) + abil.setInterval(abil.getInterval() + abil.getInterval() * attribs.get("AirScooterInterval") / 100.0); + + if (attribs.containsKey("AirScooterMaxHeightFromGround")) + abil.setMaxHeightFromGround(abil.getMaxHeightFromGround() + abil.getMaxHeightFromGround() * attribs.get("AirScooterMaxHeightFromGround") / 100.0); + + if (attribs.containsKey("AirScooterRadius")) + abil.setRadius(abil.getRadius() + abil.getRadius() * attribs.get("AirScooterRadius") / 100.0); + + if (attribs.containsKey("AirScooterSpeed")) + abil.setSpeed(abil.getSpeed() + abil.getSpeed() * attribs.get("AirScooterSpeed") / 100.0); + + return true; + } + else if (ability instanceof AirShield) { + AirShield abil = (AirShield) ability; + + if (attribs.containsKey("AirShieldMaxRadius")) + abil.setMaxRadius(abil.getMaxRadius() + abil.getMaxRadius() * attribs.get("AirShieldMaxRadius") / 100.0); + + if (attribs.containsKey("AirShieldParticles")) + abil.setParticles((int) (abil.getParticles() + abil.getParticles() * attribs.get("AirShieldParticles") / 100.0)); + + if (attribs.containsKey("AirShieldRadius")) + abil.setRadius(abil.getRadius() + abil.getRadius() * attribs.get("AirShieldRadius") / 100.0); + + if (attribs.containsKey("AirShieldSpeed")) + abil.setSpeed(abil.getSpeed() + abil.getSpeed() * attribs.get("AirShieldSpeed") / 100.0); + + if (attribs.containsKey("AirShieldStreams")) + abil.setStreams((int) (abil.getStreams() + abil.getStreams() * attribs.get("AirShieldStreams") / 100.0)); + + return true; + } + else if (ability instanceof AirSpout) { + AirSpout abil = (AirSpout) ability; + + if (attribs.containsKey("AirSpoutAngle")) + abil.setAngle((int) (abil.getAngle() + abil.getAngle() * attribs.get("AirSpoutAngle") / 100.0)); + + if (attribs.containsKey("AirSpoutAnimTime")) + abil.setAnimTime((long) (abil.getAnimTime() + abil.getAnimTime() * attribs.get("AirSpoutAnimTime") / 100.0)); + + if (attribs.containsKey("AirSpoutCooldown")) + abil.setCooldown((long) (abil.getCooldown() + abil.getCooldown() * attribs.get("AirSpoutCooldown") / 100.0)); + + if (attribs.containsKey("AirSpoutHeight")) + abil.setHeight(abil.getHeight() + abil.getHeight() * attribs.get("AirSpoutHeight") / 100.0); + + if (attribs.containsKey("AirSpoutInterval")) + abil.setInterval((long) (abil.getInterval() + abil.getInterval() * attribs.get("AirSpoutInterval") / 100.0)); + + return true; + } + else if (ability instanceof AirSuction) { + AirSuction abil = (AirSuction) ability; + + if (attribs.containsKey("AirSuctionCooldown")) + abil.setCooldown((long) (abil.getCooldown() + abil.getCooldown() * attribs.get("AirSuctionCooldown") / 100.0)); + + //if (attribs.containsKey("AirSuctionParticleCount")) + // abil.setParticleCount((int) (abil.getParticleCount() + abil.getParticleCount() * attribs.get("AirSuctionParticleCount") / 100.0)); + + if (attribs.containsKey("AirSuctionPushFactor")) + abil.setPushFactor(abil.getPushFactor() + abil.getPushFactor() * attribs.get("AirSuctionPushFactor") / 100.0); + + if (attribs.containsKey("AirSuctionRadius")) + abil.setRadius(abil.getRadius() + abil.getRadius() * attribs.get("AirSuctionRadius") / 100.0); + + if (attribs.containsKey("AirSuctionRange")) + abil.setRange(abil.getRange() + abil.getRange() * attribs.get("AirSuctionRange") / 100.0); + + if (attribs.containsKey("AirSuctionSpeed")) + abil.setSpeed(abil.getSpeed() + abil.getSpeed() * attribs.get("AirSuctionSpeed") / 100.0); + + //if (attribs.containsKey("AirSuctionTicks")) + // abil.setTicks((int) (abil.getTicks() + abil.getTicks() * attribs.get("AirSuctionTicks") / 100.0)); + + return true; + } + else if (ability instanceof AirSwipe) { + AirSwipe abil = (AirSwipe) ability; + + if (attribs.containsKey("AirSwipeArc")) + abil.setArc((int) (abil.getArc() + abil.getArc() * attribs.get("AirSwipeArc") / 100.0)); + + if (attribs.containsKey("AirSwipeCooldown")) + abil.setCooldown((long) (abil.getCooldown() + abil.getCooldown() * attribs.get("AirSwipeCooldown") / 100.0)); + + if (attribs.containsKey("AirSwipeMaxChargeFactor")) + abil.setMaxChargeFactor(abil.getMaxChargeFactor() + abil.getMaxChargeFactor() * attribs.get("AirSwipeMaxChargeFactor") / 100.0); + + if (attribs.containsKey("AirSwipeMaxChargeTime")) + abil.setMaxChargeTime((long) (abil.getMaxChargeTime() + abil.getMaxChargeTime() * attribs.get("AirSwipeMaxChargeTime") / 100.0)); + + if (attribs.containsKey("AirSwipeParticles")) + abil.setParticles((int) (abil.getParticles() + abil.getParticles() * attribs.get("AirSwipeParticles") / 100.0)); + + if (attribs.containsKey("AirSwipePushFactor")) + abil.setPushFactor(abil.getPushFactor() + abil.getPushFactor() * attribs.get("AirSwipePushFactor") / 100.0); + + if (attribs.containsKey("AirSwipeRadius")) + abil.setRadius(abil.getRadius() + abil.getRadius() * attribs.get("AirSwipeRadius") / 100.0); + + if (attribs.containsKey("AirSwipeRange")) + abil.setRange(abil.getRange() + abil.getRange() * attribs.get("AirSwipeRange") / 100.0); + + if (attribs.containsKey("AirSwipeSpeed")) + abil.setSpeed(abil.getSpeed() + abil.getSpeed() * attribs.get("AirSwipeSpeed") / 100.0); + + //if (attribs.containsKey("AirSwipeStepSize")) + // abil.setStepSize((int) (abil.getStepSize() + abil.getStepSize() * attribs.get("AirSwipeStepSize") / 100.0)); + + return true; + } + else if (ability instanceof Suffocate) { + Suffocate abil = (Suffocate) ability; + + if (attribs.containsKey("SuffocateAnimationSpeed")) + abil.setAnimationSpeed(abil.getAnimationSpeed() + abil.getAnimationSpeed() * attribs.get("SuffocateAnimationSpeed") / 100.0); + + if (attribs.containsKey("SuffocateBlind")) + abil.setBlind(abil.getBlind() + abil.getBlind() * attribs.get("SuffocateBlind") / 100.0); + + if (attribs.containsKey("SuffocateBlindDelay")) + abil.setBlindDelay(abil.getBlindDelay() + abil.getBlindDelay() * attribs.get("SuffocateBlindDelay") / 100.0); + + if (attribs.containsKey("SuffocateBlindRepeat")) + abil.setBlindRepeat(abil.getBlindRepeat() + abil.getBlindRepeat() * attribs.get("SuffocateBlindRepeat") / 100.0); + + if (attribs.containsKey("SuffocateChargeTime")) + abil.setChargeTime((long) (abil.getChargeTime() + abil.getChargeTime() * attribs.get("SuffocateChargeTime") / 100.0)); + + if (attribs.containsKey("SuffocateConstantAimRadius")) + abil.setConstantAimRadius(abil.getConstantAimRadius() + abil.getConstantAimRadius() * attribs.get("SuffocateConstantAimRadius") / 100.0); + + if (attribs.containsKey("SuffocateCooldown")) + abil.setCooldown((long) (abil.getCooldown() + abil.getCooldown() * attribs.get("SuffocateCooldown") / 100.0)); + + if (attribs.containsKey("SuffocateDamageDelay")) + abil.setDamageDelay(abil.getDamageDelay() + abil.getDamageDelay() * attribs.get("SuffocateDamageDelay") / 100.0); + + if (attribs.containsKey("SuffocateDamageRepeat")) + abil.setDamageRepeat(abil.getDamageRepeat() + abil.getDamageRepeat() * attribs.get("SuffocateDamageRepeat") / 100.0); + + //if (attribs.containsKey("SuffocateParticleCount")) + // abil.setParticleCount((int) (abil.getParticleCount() + abil.getParticleCount() * attribs.get("SuffocateParticleCount") / 100.0)); + + if (attribs.containsKey("SuffocateRadius")) + abil.setRadius(abil.getRadius() + abil.getRadius() * attribs.get("SuffocateRadius") / 100.0); + + if (attribs.containsKey("SuffocateRange")) + abil.setRange(abil.getRange() + abil.getRange() * attribs.get("SuffocateRange") / 100.0); + + if (attribs.containsKey("SuffocateSlow")) + abil.setSlow(abil.getSlow() + abil.getSlow() * attribs.get("SuffocateSlow") / 100.0); + + if (attribs.containsKey("SuffocateSlowDelay")) + abil.setSlowDelay(abil.getSlowDelay() + abil.getSlowDelay() * attribs.get("SuffocateSlowDelay") / 100.0); + + if (attribs.containsKey("SuffocateSlowRepeat")) + abil.setSlowRepeat(abil.getSlowRepeat() + abil.getSlowRepeat() * attribs.get("SuffocateSlowRepeat") / 100.0); + + return true; + } + else if (ability instanceof Tornado) { + Tornado abil = (Tornado) ability; + + //if (attribs.containsKey("TornadoCurrentHeight")) + // abil.setCurrentHeight(abil.getCurrentHeight() + abil.getCurrentHeight() * attribs.get("TornadoCurrentHeight") / 100.0); + + //if (attribs.containsKey("TornadoCurrentRadius")) + // abil.setCurrentRadius(abil.getCurrentRadius() + abil.getCurrentRadius() * attribs.get("TornadoCurrentRadius") / 100.0); + + if (attribs.containsKey("TornadoMaxHeight")) + abil.setMaxHeight(abil.getMaxHeight() + abil.getMaxHeight() * attribs.get("TornadoMaxHeight") / 100.0); + + if (attribs.containsKey("TornadoNPCPushFactor")) + abil.setNpcPushFactor(abil.getNpcPushFactor() + abil.getNpcPushFactor() * attribs.get("TornadoNPCPushFactor") / 100.0); + + if (attribs.containsKey("TornadoNumberOfStreams")) + abil.setNumberOfStreams((int) (abil.getNumberOfStreams() + abil.getNumberOfStreams() * attribs.get("TornadoNumberOfStreams") / 100.0)); + + //if (attribs.containsKey("TornadoParticleCount")) + // abil.setParticleCount((int) (abil.getParticleCount() + abil.getParticleCount() * attribs.get("TornadoParticleCount") / 100.0)); + + if (attribs.containsKey("TornadoPlayerPushFactor")) + abil.setPlayerPushFactor(abil.getPlayerPushFactor() + abil.getPlayerPushFactor() * attribs.get("TornadoPlayerPushFactor") / 100.0); + + if (attribs.containsKey("TornadoRadius")) + abil.setRadius(abil.getRadius() + abil.getRadius() * attribs.get("TornadoRadius") / 100.0); + + if (attribs.containsKey("TornadoRange")) + abil.setRange(abil.getRange() + abil.getRange() * attribs.get("TornadoRange") / 100.0); + + if (attribs.containsKey("TornadoSpeed")) + abil.setSpeed(abil.getSpeed() + abil.getSpeed() * attribs.get("TornadoSpeed") / 100.0); + + return true; + } + else if (ability instanceof AirStream) { + AirStream abil = (AirStream) ability; + + if (attribs.containsKey("AirStreamCooldown")) + abil.setCooldown((long) (abil.getCooldown() + abil.getCooldown() * attribs.get("AirStreamCooldown") / 100.0)); + + if (attribs.containsKey("AirStreamEntityCarryDuration")) + abil.setAirStreamEntityCarryDuration(abil.getAirStreamEntityCarryDuration() + abil.getAirStreamEntityCarryDuration() * attribs.get("AirStreamEntityCarryDuration") / 100.0); + + if (attribs.containsKey("AirStreamMaxEntityHeight")) + abil.setAirStreamMaxEntityHeight(abil.getAirStreamMaxEntityHeight() + abil.getAirStreamMaxEntityHeight() * attribs.get("AirStreamMaxEntityHeight") / 100.0); + + if (attribs.containsKey("AirStreamRange")) + abil.setRange(abil.getRange() + abil.getRange() * attribs.get("AirStreamRange") / 100.0); + + if (attribs.containsKey("AirStreamSpeed")) + abil.setSpeed(abil.getSpeed() + abil.getSpeed() * attribs.get("AirStreamSpeed") / 100.0); + + //if (attribs.containsKey("AirStreamTime")) + // abil.setTime((long) (abil.getTime() + abil.getTime() * attribs.get("AirStreamTime") / 100.0)); + + return true; + } + else if (ability instanceof AirSweep) { + AirSweep abil = (AirSweep) ability; + + if (attribs.containsKey("AirSweepKnockback")) + abil.setKnockback(abil.getKnockback() + abil.getKnockback() * attribs.get("AirSweepKnockback") / 100.0); + + //if (attribs.containsKey("AirSweepProgressCounter")) + // abil.setProgressCounter((int) (abil.getProgressCounter() + abil.getProgressCounter() * attribs.get("AirSweepTime") / 100.0)); + + if (attribs.containsKey("AirSweepRange")) + abil.setRange(abil.getRange() + abil.getRange() * attribs.get("AirSweepRange") / 100.0); + + if (attribs.containsKey("AirSweepSpeed")) + abil.setSpeed(abil.getSpeed() + abil.getSpeed() * attribs.get("AirSweepSpeed") / 100.0); + + return true; + } + else if (ability instanceof Twister) { + Twister abil = (Twister) ability; + + if (attribs.containsKey("TwisterCooldown")) + abil.setCooldown((long) (abil.getCooldown() + abil.getCooldown() * attribs.get("TwisterCooldown") / 100.0)); + + return true; + } + else if (ability instanceof FlightMultiAbility) { + //FlightMultiAbility abil = (FlightMultiAbility) ability; + + return true; + } + + return false; + } +} diff --git a/src/main/java/com/projectkorra/items/abilityupdater/ChiUpdater.java b/src/main/java/com/projectkorra/items/abilityupdater/ChiUpdater.java new file mode 100644 index 0000000..b378f8a --- /dev/null +++ b/src/main/java/com/projectkorra/items/abilityupdater/ChiUpdater.java @@ -0,0 +1,157 @@ +package com.projectkorra.items.abilityupdater; + +import com.projectkorra.projectkorra.chiblocking.AcrobatStance; +import com.projectkorra.projectkorra.chiblocking.HighJump; +import com.projectkorra.projectkorra.chiblocking.Paralyze; +import com.projectkorra.projectkorra.chiblocking.QuickStrike; +import com.projectkorra.projectkorra.chiblocking.RapidPunch; +import com.projectkorra.projectkorra.chiblocking.Smokescreen; +import com.projectkorra.projectkorra.chiblocking.SwiftKick; +import com.projectkorra.projectkorra.chiblocking.WarriorStance; +import com.projectkorra.projectkorra.chiblocking.combo.Immobilize; + +import org.bukkit.entity.Player; + +import java.util.Map; + +public class ChiUpdater { + + /** + * updates the chi abilities based on a players bending effect attributes + * + * @param player the player that has the effects + * @param ability an instance of a chi ability + * @param attribs the map of the players effects + * @return if the ability was updated correctly + */ + + public static boolean updateAbilityDamage(Player player, Object ability, Map attribs) { + if (ability instanceof QuickStrike) { + QuickStrike abil = (QuickStrike) ability; + + if (attribs.containsKey("QuickStrikeDamage")) + abil.setDamage(abil.getDamage() + abil.getDamage() * attribs.get("QuickStrikeDamage") / 100.0); + + return true; + } + else if (ability instanceof RapidPunch) { + RapidPunch abil = (RapidPunch) ability; + + if (attribs.containsKey("RapidPunchDamage")) + abil.setDamage(abil.getDamage() + abil.getDamage() * attribs.get("RapidPunchDamage") / 100.0); + + return true; + } + else if (ability instanceof SwiftKick) { + SwiftKick abil = (SwiftKick) ability; + + if (attribs.containsKey("SwiftKickDamage")) + abil.setDamage(abil.getDamage() + abil.getDamage() * attribs.get("SwiftKickDamage") / 100.0); + + return true; + } + + return false; + } + + public static boolean updateAbility(Player player, Object ability, Map attribs) { + if (ability instanceof AcrobatStance) { + AcrobatStance abil = (AcrobatStance) ability; + + if (attribs.containsKey("AcrobatStanceJump")) + abil.setSpeed((int) (abil.getSpeed() + abil.getSpeed() * attribs.get("AcrobatStanceSpeed") / 100.0)); + + if (attribs.containsKey("AcrobatStanceSpeed")) + abil.setJump((int) (abil.getJump() + abil.getJump() * attribs.get("AcrobatStanceSpeed") / 100.0)); + + return true; + } + else if (ability instanceof HighJump) { + HighJump abil = (HighJump) ability; + + if (attribs.containsKey("HighJumpCooldown")) + abil.setCooldown((long) (abil.getCooldown() + abil.getCooldown() * attribs.get("HighJumpCooldown") / 100.0)); + + if (attribs.containsKey("HighJumpHeight")) + abil.setHeight((int) (abil.getHeight() + abil.getHeight() * attribs.get("HighJumpHeight") / 100.0)); + + return true; + } + else if (ability instanceof Paralyze) { + //Paralyze abil = (Paralyze) ability; + + return true; + } + else if (ability instanceof QuickStrike) { + QuickStrike abil = (QuickStrike) ability; + + if (attribs.containsKey("QuickStrikeBlockChance")) + abil.setBlockChance((int) (abil.getBlockChance() + abil.getBlockChance() * attribs.get("QuickStrikeBlockChance") / 100.0)); + + return true; + } + else if (ability instanceof RapidPunch) { + RapidPunch abil = (RapidPunch) ability; + + if (attribs.containsKey("RapidPunchHits")) + abil.setNumPunches((int) (abil.getNumPunches() + abil.getNumPunches() * attribs.get("RapidPunchHits") / 100.0)); + + //if (attribs.containsKey("RapidPunchDistance")) + // abil.setDistance((int) (abil.getDistance() + abil.getDistance() * attribs.get("RapidPunchDistance") / 100.0)); + + if (attribs.containsKey("RapidPunchCooldown")) + abil.setCooldown((long) (abil.getCooldown() + abil.getCooldown() * attribs.get("RapidPunchCooldown") / 100.0)); + + return true; + } + else if (ability instanceof Smokescreen) { + Smokescreen abil = (Smokescreen) ability; + + if (attribs.containsKey("SmokescreenCooldown")) + abil.setCooldown((long) (abil.getCooldown() + abil.getCooldown() * attribs.get("SmokescreenCooldown") / 100.0)); + + if (attribs.containsKey("SmokescreenDuration")) + abil.setDuration((int) (abil.getDuration() + abil.getDuration() * attribs.get("SmokescreenDuration") / 100.0)); + + if (attribs.containsKey("SmokescreenRadius")) + abil.setRadius(abil.getRadius() + abil.getRadius() * attribs.get("SmokescreenRadius") / 100.0); + + return true; + } + else if (ability instanceof SwiftKick) { + SwiftKick abil = (SwiftKick) ability; + + if (attribs.containsKey("SwiftKickBlockChance")) + abil.setBlockChance((int) (abil.getBlockChance() + abil.getBlockChance() * attribs.get("SwiftKickBlockChance") / 100.0)); + + if (attribs.containsKey("SwiftKickCooldown")) + abil.setCooldown((long) (abil.getCooldown() + abil.getCooldown() * attribs.get("SwiftKickCooldown") / 100.0)); + + return true; + } + else if (ability instanceof WarriorStance) { + WarriorStance abil = (WarriorStance) ability; + + if (attribs.containsKey("WarriorStanceStrength")) + abil.setStrength((int) (abil.getStrength() + abil.getStrength() * attribs.get("WarriorStanceStrength") / 100.0)); + + if (attribs.containsKey("WarriorStanceResistance")) + abil.setResistance((int) (abil.getResistance() + abil.getResistance() * attribs.get("WarriorStanceResistance") / 100.0)); + + return true; + } + else if (ability instanceof Immobilize) { + Immobilize abil = (Immobilize) ability; + + if (attribs.containsKey("ImmobilizeCooldown")) + abil.setCooldown((long) (abil.getCooldown() + abil.getCooldown() * attribs.get("ImmobilizeCooldown") / 100.0)); + + if (attribs.containsKey("ImmobilizeDuration")) + abil.setDuration((long) (abil.getDuration() + abil.getDuration() * attribs.get("ImmobilizeDuration") / 100.0)); + + return true; + } + + return false; + } +} diff --git a/src/main/java/com/projectkorra/items/abilityupdater/EarthUpdater.java b/src/main/java/com/projectkorra/items/abilityupdater/EarthUpdater.java new file mode 100644 index 0000000..eb99d46 --- /dev/null +++ b/src/main/java/com/projectkorra/items/abilityupdater/EarthUpdater.java @@ -0,0 +1,461 @@ +package com.projectkorra.items.abilityupdater; + +import java.util.Map; + +import org.bukkit.entity.Player; + +import com.projectkorra.projectkorra.earthbending.Catapult; +import com.projectkorra.projectkorra.earthbending.Collapse; +import com.projectkorra.projectkorra.earthbending.CollapseWall; +import com.projectkorra.projectkorra.earthbending.EarthArmor; +import com.projectkorra.projectkorra.earthbending.EarthBlast; +import com.projectkorra.projectkorra.earthbending.EarthDome; +import com.projectkorra.projectkorra.earthbending.EarthGrab; +import com.projectkorra.projectkorra.earthbending.EarthSmash; +import com.projectkorra.projectkorra.earthbending.EarthTunnel; +import com.projectkorra.projectkorra.earthbending.RaiseEarth; +import com.projectkorra.projectkorra.earthbending.RaiseEarthWall; +import com.projectkorra.projectkorra.earthbending.Ripple; +import com.projectkorra.projectkorra.earthbending.Shockwave; +import com.projectkorra.projectkorra.earthbending.Tremorsense; +import com.projectkorra.projectkorra.earthbending.combo.EarthDomeOthers; +import com.projectkorra.projectkorra.earthbending.combo.EarthDomeSelf; +import com.projectkorra.projectkorra.earthbending.combo.EarthPillars; +import com.projectkorra.projectkorra.earthbending.lava.LavaFlow; +import com.projectkorra.projectkorra.earthbending.lava.LavaSurge; +import com.projectkorra.projectkorra.earthbending.lava.LavaSurgeWall; +import com.projectkorra.projectkorra.earthbending.lava.LavaSurgeWave; +import com.projectkorra.projectkorra.earthbending.metal.Extraction; +import com.projectkorra.projectkorra.earthbending.metal.MetalClips; + +public class EarthUpdater { + + /** + * updates the earth abilities based on a players bending effect attributes + * + * @param player the player that has the effects + * @param ability an instance of a earth ability + * @param attribs the map of the players effects + * @return if the ability was updated correctly + */ + + public static boolean updateAbilityDamage(Player player, Object ability, Map attribs) { + if (ability instanceof EarthBlast) { + EarthBlast abil = (EarthBlast) ability; + + if (attribs.containsKey("EarthBlastDamage")) + abil.setDamage(abil.getDamage() + abil.getDamage() * attribs.get("EarthBlastDamage") / 100.0); + + return true; + } + else if (ability instanceof EarthSmash) { + EarthSmash abil = (EarthSmash) ability; + + if (attribs.containsKey("EarthSmashDamage")) { + abil.setMinDamage(abil.getMinDamage() + abil.getMinDamage() * attribs.get("EarthSmashDamage") / 100.0); + abil.setMaxDamage(abil.getMaxDamage() + abil.getMaxDamage() * attribs.get("EarthSmashDamage") / 100.0); + } + + return true; + } + else if (ability instanceof Ripple) { + Ripple abil = (Ripple) ability; + + if (attribs.containsKey("ShockwaveDamage")) + abil.setDamage(abil.getDamage() + abil.getDamage() * attribs.get("ShockwaveDamage") / 100.0); + + return true; + } + + return false; + } + + public static boolean updateAbility(Player player, Object ability, Map attribs) { + if (ability instanceof Catapult) { + Catapult abil = (Catapult) ability; + + if (attribs.containsKey("CatapultCooldown")) + abil.setCooldown((long) (abil.getCooldown() + abil.getCooldown() * attribs.get("CatapultCooldown") / 100.0)); + + //if (attribs.containsKey("CatapultLength")) // Removed + // abil.setLength((int) (abil.getLength() + abil.getLength() * attribs.get("CatapultLength") / 100.0)); + + //if (attribs.containsKey("CatapultPush")) // Removed + // abil.setPush(abil.getPush() + abil.getPush() * attribs.get("CatapultPush") / 100.0); + + return true; + } + else if (ability instanceof Collapse) { + Collapse abil = (Collapse) ability; + + if (attribs.containsKey("CollapseCooldown")) + abil.setCooldown((long) (abil.getCooldown() + abil.getCooldown() * attribs.get("CollapseCooldown") / 100.0)); + + if (attribs.containsKey("CollapseDistance")) + abil.setDistance((int) (abil.getDistance() + abil.getDistance() * attribs.get("CollapseDistance") / 100.0)); + + if (attribs.containsKey("CollapseHeight")) + abil.setHeight((int) (abil.getHeight() + abil.getHeight() * attribs.get("CollapseHeight") / 100.0)); + + if (attribs.containsKey("CollapseSelectRange")) + abil.setSelectRange(abil.getSelectRange() + abil.getSelectRange() * attribs.get("CollapseSelectRange") / 100.0); + + if (attribs.containsKey("CollapseSpeed")) + abil.setSpeed(abil.getSpeed() + abil.getSpeed() * attribs.get("CollapseSpeed") / 100.0); + + //if (attribs.containsKey("CollapseTime")) + // abil.setTime((long) (abil.getTime() + abil.getTime() * attribs.get("CollapseTime") / 100.0)); + + return true; + } + else if (ability instanceof CollapseWall) { + CollapseWall abil = (CollapseWall) ability; + + if (attribs.containsKey("CollapseWallCooldown")) + abil.setCooldown((long) (abil.getCooldown() + abil.getCooldown() * attribs.get("CollapseWallCooldown") / 100.0)); + + if (attribs.containsKey("CollapseWallHeight")) + abil.setHeight((int) (abil.getHeight() + abil.getHeight() * attribs.get("CollapseWallHeight") / 100.0)); + + if (attribs.containsKey("CollapseWallRadius")) + abil.setRadius(abil.getRadius() + abil.getRadius() * attribs.get("CollapseWallRadius") / 100.0); + + if (attribs.containsKey("CollapseWallSelectRange")) + abil.setSelectRange((int) (abil.getSelectRange() + abil.getSelectRange() * attribs.get("CollapseWallSelectRange") / 100.0)); + + return true; + } + else if (ability instanceof EarthArmor) { + EarthArmor abil = (EarthArmor) ability; + + if (attribs.containsKey("EarthArmorCooldown")) + abil.setCooldown((long) (abil.getCooldown() + abil.getCooldown() * attribs.get("EarthArmorCooldown") / 100.0)); + + //if (attribs.containsKey("EarthArmorGoldHearts")) + // abil.setGoldHearts((float) (abil.getGoldHearts() + abil.getGoldHearts() * attribs.get("EarthArmorGoldHearts") / 100.0)); + + if (attribs.containsKey("EarthArmorInterval")) + abil.setInterval((long) (abil.getInterval() + abil.getInterval() * attribs.get("EarthArmorInterval") / 100.0)); + + if (attribs.containsKey("EarthArmorMaxGoldHearts")) + abil.setMaxGoldHearts((int) (abil.getMaxGoldHearts() + abil.getMaxGoldHearts() * attribs.get("EarthArmorMaxGoldHearts") / 100.0)); + + if (attribs.containsKey("EarthArmorSelectRange")) + abil.setSelectRange(abil.getSelectRange() + abil.getSelectRange() * attribs.get("EarthArmorSelectRange") / 100.0); + + //if (attribs.containsKey("EarthArmorStrength")) // Removed + // abil.setStrength((int) (abil.getStrength() + abil.getStrength() * attribs.get("EarthArmorStrength") / 100.0)); + + return true; + } + else if (ability instanceof EarthBlast) { + EarthBlast abil = (EarthBlast) ability; + + if (attribs.containsKey("EarthBlastCollisionRadius")) + abil.setCollisionRadius(abil.getCollisionRadius() + abil.getCollisionRadius() * attribs.get("EarthBlastCollisionRadius") / 100.0); + + if (attribs.containsKey("EarthBlastCooldown")) + abil.setCooldown((long) (abil.getCooldown() + abil.getCooldown() * attribs.get("EarthBlastCooldown") / 100.0)); + + if (attribs.containsKey("EarthBlastDeflectRange")) + abil.setDeflectRange(abil.getDeflectRange() + abil.getDeflectRange() * attribs.get("EarthBlastDeflectRange") / 100.0); + + if (attribs.containsKey("EarthBlastInterval")) + abil.setInterval((long) (abil.getInterval() + abil.getInterval() * attribs.get("EarthBlastInterval") / 100.0)); + + if (attribs.containsKey("EarthBlastPushFactor")) + abil.setPushFactor(abil.getPushFactor() + abil.getPushFactor() * attribs.get("EarthBlastPushFactor") / 100.0); + + if (attribs.containsKey("EarthBlastRange")) + abil.setRange(abil.getRange() + abil.getRange() * attribs.get("EarthBlastRange") / 100.0); + + if (attribs.containsKey("EarthBlastSelectRange")) + abil.setSelectRange(abil.getSelectRange() + abil.getSelectRange() * attribs.get("EarthBlastSelectRange") / 100.0); + + if (attribs.containsKey("EarthBlastSpeed")) + abil.setSpeed(abil.getSpeed() + abil.getSpeed() * attribs.get("EarthBlastSpeed") / 100.0); + + //if (attribs.containsKey("EarthBlastTime")) + // abil.setTime((long) (abil.getTime() + abil.getTime() * attribs.get("EarthBlastTime") / 100.0)); + + return true; + } + else if (ability instanceof EarthDome) { + /* I accessors not properly set + EarthDome abil = (EarthDome) ability; + + if (attribs.containsKey("EarthDomeHeight")) + abil.height = (int) (abil.height + abil.height * attribs.get("EarthDomeHeight") / 100.0); + + if (attribs.containsKey("EarthDomeRadius")) + abil.radius = abil.radius + abil.radius * attribs.get("EarthDomeRadius") / 100.0; + */ + return true; + } + else if (ability instanceof EarthGrab) { + /* I accessors not properly set + EarthGrab abil = (EarthGrab) ability; + + if (attribs.containsKey("EarthGrabCooldown")) + abil.cooldown = (long) (abil.getCooldown() + abil.getCooldown() * attribs.get("EarthGrabCooldown") / 100.0); + + if (attribs.containsKey("EarthGrabDamageThreshold")) + abil.damageThreshold = abil.damageThreshold + abil.damageThreshold * attribs.get("EarthGrabDamageThreshold") / 100.0; + + if (attribs.containsKey("EarthGrabDragSpeed")) + abil.dragSpeed = abil.dragSpeed + abil.dragSpeed * attribs.get("EarthGrabDragSpeed") / 100.0; + */ + return true; + } + else if (ability instanceof EarthSmash) { + EarthSmash abil = (EarthSmash) ability; + + //if (attribs.containsKey("EarthSmashAnimationCounter")) + // abil.setAnimationCounter((int) (abil.getAnimationCounter() + abil.getAnimationCounter() * attribs.get("EarthSmashAnimationCounter") / 100.0)); + + if (attribs.containsKey("EarthSmashChargeTime")) + abil.setChargeTime((long) (abil.getChargeTime() + abil.getChargeTime() * attribs.get("EarthSmashChargeTime") / 100.0)); + + if (attribs.containsKey("EarthSmashCooldown")) + abil.setCooldown((long) (abil.getCooldown() + abil.getCooldown() * attribs.get("EarthSmashCooldown") / 100.0)); + + if (attribs.containsKey("EarthSmashDelay")) + abil.setDelay((long) (abil.getDelay() + abil.getDelay() * attribs.get("EarthSmashDelay") / 100.0)); + + if (attribs.containsKey("EarthSmashFlightAnimationInterval")) + abil.setFlightAnimationInterval((long) (abil.getFlightAnimationInterval() + abil.getFlightAnimationInterval() * attribs.get("EarthSmashFlightAnimationInterval") / 100.0)); + + if (attribs.containsKey("EarthSmashFlightDetectionRadius")) + abil.setFlightDetectionRadius(abil.getFlightDetectionRadius() + abil.getFlightDetectionRadius() * attribs.get("EarthSmashFlightDetectionRadius") / 100.0); + + if (attribs.containsKey("EarthSmashFlightDuration")) + abil.setFlightDuration((long) (abil.getFlightDuration() + abil.getFlightDuration() * attribs.get("EarthSmashFlightDuration") / 100.0)); + + //if (attribs.containsKey("EarthSmashFlightRemoveTimer")) + // abil.setFlightRemoveTimer((long) (abil.getFlightRemoveTimer() + abil.getFlightRemoveTimer() * attribs.get("EarthSmashFlightRemoveTimer") / 100.0)); + + if (attribs.containsKey("EarthSmashFlightSpeed")) + abil.setFlightSpeed(abil.getFlightSpeed() + abil.getFlightSpeed() * attribs.get("EarthSmashFlightSpeed") / 100.0); + + //if (attribs.containsKey("EarthSmashFlightStartTime")) + // abil.setFlightStartTime((long) (abil.getFlightStartTime() + abil.getFlightStartTime() * attribs.get("EarthSmashFlightStartTime") / 100.0)); + + //if (attribs.containsKey("EarthSmashGrabbedDistance")) + // abil.setGrabbedDistance(abil.getGrabbedDistance() + abil.getGrabbedDistance() * attribs.get("EarthSmashGrabbedDistance") / 100.0); + + if (attribs.containsKey("EarthSmashGrabDetectionRadius")) + abil.setGrabDetectionRadius(abil.getGrabDetectionRadius() + abil.getGrabDetectionRadius() * attribs.get("EarthSmashGrabDetectionRadius") / 100.0); + + if (attribs.containsKey("EarthSmashGrabRange")) + abil.setGrabRange(abil.getGrabRange() + abil.getGrabRange() * attribs.get("EarthSmashGrabRange") / 100.0); + + if (attribs.containsKey("EarthSmashKnockback")) + abil.setKnockback(abil.getKnockback() + abil.getKnockback() * attribs.get("EarthSmashKnockback") / 100.0); + + if (attribs.containsKey("EarthSmashKnockup")) + abil.setKnockup(abil.getKnockup() + abil.getKnockup() * attribs.get("EarthSmashKnockup") / 100.0); + + if (attribs.containsKey("EarthSmashLiftAnimationInterval")) + abil.setLiftAnimationInterval((long) (abil.getLiftAnimationInterval() + abil.getLiftAnimationInterval() * attribs.get("EarthSmashLiftAnimationInterval") / 100.0)); + + if (attribs.containsKey("EarthSmashMaxBlocksToPassThrough")) + abil.setMaxBlocksToPassThrough((int) (abil.getMaxBlocksToPassThrough() + abil.getMaxBlocksToPassThrough() * attribs.get("EarthSmashMaxBlocksToPassThrough") / 100.0)); + + //if (attribs.containsKey("EarthSmashProgressCounter")) + // abil.setProgressCounter((int) (abil.getProgressCounter() + abil.getProgressCounter() * attribs.get("EarthSmashProgressCounter") / 100.0)); + + //if (attribs.containsKey("EarthSmashRemoveTimer")) + // abil.setRemoveTimer((long) (abil.getRemoveTimer() + abil.getRemoveTimer() * attribs.get("EarthSmashRemoveTimer") / 100.0)); + + //if (attribs.containsKey("EarthSmashRequiredBendableBlocks")) + // abil.setRequiredBendableBlocks((int) (abil.getRequiredBendableBlocks() + abil.getRequiredBendableBlocks() * attribs.get("EarthSmashRequiredBendableBlocks") / 100.0)); + + if (attribs.containsKey("EarthSmashSelectRange")) + abil.setSelectRange((int) (abil.getSelectRange() + abil.getSelectRange() * attribs.get("EarthSmashSelectRange") / 100.0)); + + if (attribs.containsKey("EarthSmashShootAnimationInterval")) + abil.setShootAnimationInterval((long) (abil.getShootAnimationInterval() + abil.getShootAnimationInterval() * attribs.get("EarthSmashShootAnimationInterval") / 100.0)); + + if (attribs.containsKey("EarthSmashShootRange")) + abil.setShootRange(abil.getShootRange() + abil.getShootRange() * attribs.get("EarthSmashShootRange") / 100.0); + + return true; + } + else if (ability instanceof EarthTunnel) { + EarthTunnel abil = (EarthTunnel) ability; + + if (attribs.containsKey("EarthTunnelAngle")) + abil.setAngle(abil.getAngle() + abil.getAngle() * attribs.get("EarthTunnelAngle") / 100.0); + + if (attribs.containsKey("EarthTunnelDepth")) + abil.setDepth(abil.getDepth() + abil.getDepth() * attribs.get("EarthTunnelDepth") / 100.0); + + if (attribs.containsKey("EarthTunnelInterval")) + abil.setInterval((long) (abil.getInterval() + abil.getInterval() * attribs.get("EarthTunnelInterval") / 100.0)); + + if (attribs.containsKey("EarthTunnelMaxRadius")) + abil.setMaxRadius(abil.getMaxRadius() + abil.getMaxRadius() * attribs.get("EarthTunnelMaxRadius") / 100.0); + + //if (attribs.containsKey("EarthTunnelRadius")) + // abil.setRadius(abil.getRadius() + abil.getRadius() * attribs.get("EarthTunnelRadius") / 100.0); + + if (attribs.containsKey("EarthTunnelRadiusIncrement")) + abil.setRadiusIncrement(abil.getRadiusIncrement() + abil.getRadiusIncrement() * attribs.get("EarthTunnelRadiusIncrement") / 100.0); + + if (attribs.containsKey("EarthTunnelRange")) + abil.setRange(abil.getRange() + abil.getRange() * attribs.get("EarthTunnelRange") / 100.0); + + //if (attribs.containsKey("EarthTunnelTime")) + // abil.setTime((long) (abil.getTime() + abil.getTime() * attribs.get("EarthTunnelTime") / 100.0)); + + return true; + } + else if (ability instanceof RaiseEarth) { + RaiseEarth abil = (RaiseEarth) ability; + + if (attribs.containsKey("RaiseEarthCooldown")) + abil.setCooldown((long) (abil.getCooldown() + abil.getCooldown() * attribs.get("RaiseEarthCooldown") / 100.0)); + + if (attribs.containsKey("RaiseEarthDistance")) + abil.setDistance((int) (abil.getDistance() + abil.getDistance() * attribs.get("RaiseEarthDistance") / 100.0)); + + if (attribs.containsKey("RaiseEarthHeight")) + abil.setHeight((int) (abil.getHeight() + abil.getHeight() * attribs.get("RaiseEarthHeight") / 100.0)); + + if (attribs.containsKey("RaiseEarthInterval")) + abil.setInterval((long) (abil.getInterval() + abil.getInterval() * attribs.get("RaiseEarthInterval") / 100.0)); + + if (attribs.containsKey("RaiseEarthSelectRange")) + abil.setSelectRange(abil.getSelectRange() + abil.getSelectRange() * attribs.get("RaiseEarthSelectRange") / 100.0); + + if (attribs.containsKey("RaiseEarthSpeed")) + abil.setSpeed(abil.getSpeed() + abil.getSpeed() * attribs.get("RaiseEarthSpeed") / 100.0); + + //if (attribs.containsKey("RaiseEarthTime")) + // abil.setTime((long) (abil.getTime() + abil.getTime() * attribs.get("RaiseEarthTime") / 100.0)); + + return true; + } + else if (ability instanceof RaiseEarthWall) { + RaiseEarthWall abil = (RaiseEarthWall) ability; + + if (attribs.containsKey("RaiseEarthWallCooldown")) + abil.setCooldown((long) (abil.getCooldown() + abil.getCooldown() * attribs.get("RaiseEarthWallCooldown") / 100.0)); + + if (attribs.containsKey("RaiseEarthWallHeight")) + abil.setHeight((int) (abil.getHeight() + abil.getHeight() * attribs.get("RaiseEarthWallHeight") / 100.0)); + + if (attribs.containsKey("RaiseEarthWallRange")) + abil.setRange((int) (abil.getRange() + abil.getRange() * attribs.get("RaiseEarthWallRange") / 100.0)); + + if (attribs.containsKey("RaiseEarthWallSelectRange")) + abil.setSelectRange((int) (abil.getSelectRange() + abil.getSelectRange() * attribs.get("RaiseEarthWallSelectRange") / 100.0)); + + if (attribs.containsKey("RaiseEarthWallSpeed")) + abil.setWidth((int) (abil.getWidth() + abil.getWidth() * attribs.get("RaiseEarthWallWidth") / 100.0)); + + return true; + } + else if (ability instanceof Ripple) { + Ripple abil = (Ripple) ability; + + if (attribs.containsKey("RippleKnockback")) + abil.setKnockback(abil.getKnockback() + abil.getKnockback() * attribs.get("RippleKnockback") / 100.0); + + if (attribs.containsKey("RippleMaxStep")) + abil.setMaxStep((int) (abil.getMaxStep() + abil.getMaxStep() * attribs.get("RippleMaxStep") / 100.0)); + + if (attribs.containsKey("RippleRange")) + abil.setRange(abil.getRange() + abil.getRange() * attribs.get("RippleRange") / 100.0); + + //if (attribs.containsKey("RippleStep")) + // abil.setStep((int) (abil.getStep() + abil.getStep() * attribs.get("RippleStep") / 100.0)); + + return true; + } + else if (ability instanceof Shockwave) { + Shockwave abil = (Shockwave) ability; + + if (attribs.containsKey("ShockwaveAngle")) + abil.setAngle(abil.getAngle() + abil.getAngle() * attribs.get("ShockwaveAngle") / 100.0); + + if (attribs.containsKey("ShockwaveChargeTime")) + abil.setChargeTime((long) (abil.getChargeTime() + abil.getChargeTime() * attribs.get("ShockwaveChargeTime") / 100.0)); + + if (attribs.containsKey("ShockwaveCooldown")) + abil.setCooldown((long) (abil.getCooldown() + abil.getCooldown() * attribs.get("ShockwaveCooldown") / 100.0)); + + if (attribs.containsKey("ShockwaveRange")) + abil.setRange(abil.getRange() + abil.getRange() * attribs.get("ShockwaveRange") / 100.0); + + if (attribs.containsKey("ShockwaveThreshold")) + abil.setThreshold(abil.getThreshold() + abil.getThreshold() * attribs.get("ShockwaveThreshold") / 100.0); + + return true; + } + else if (ability instanceof Tremorsense) { + Tremorsense abil = (Tremorsense) ability; + + if (attribs.containsKey("TremorsenseCooldown")) + abil.setCooldown((long) (abil.getCooldown() + abil.getCooldown() * attribs.get("TremorsenseCooldown") / 100.0)); + + if (attribs.containsKey("TremorsenseLightThreshold")) + abil.setLightThreshold((byte) (abil.getLightThreshold() + abil.getLightThreshold() * attribs.get("TremorsenseLightThreshold") / 100.0)); + + if (attribs.containsKey("TremorsenseMaxDepth")) + abil.setMaxDepth((int) (abil.getMaxDepth() + abil.getMaxDepth() * attribs.get("TremorsenseMaxDepth") / 100.0)); + + if (attribs.containsKey("TremorsenseRadius")) + abil.setRadius((int) (abil.getRadius() + abil.getRadius() * attribs.get("TremorsenseRadius") / 100.0)); + + return true; + } + else if (ability instanceof EarthDomeOthers) { + //EarthDomeOthers abil = (EarthDomeOthers) ability; + + return true; + } + else if (ability instanceof EarthDomeSelf) { + //EarthDomeSelf abil = (EarthDomeSelf) ability; + + return true; + } + else if (ability instanceof EarthPillars) { + //EarthPillars abil = (EarthPillars) ability; + + return true; + } + else if (ability instanceof LavaFlow) { + //LavaFlow abil = (LavaFlow) ability; + + return true; + } + else if (ability instanceof LavaSurge) { + //LavaSurge abil = (LavaSurge) ability; + + return true; + } + else if (ability instanceof LavaSurgeWall) { + //LavaSurgeWall abil = (LavaSurgeWall) ability; + + return true; + } + else if (ability instanceof LavaSurgeWave) { + //LavaSurgeWave abil = (LavaSurgeWave) ability; + + return true; + } + else if (ability instanceof Extraction) { + //Extraction abil = (Extraction) ability; + + return true; + } + else if (ability instanceof MetalClips) { + //MetalClips abil = (MetalClips) ability; + + return true; + } + + return false; + } +} diff --git a/src/main/java/com/projectkorra/items/abilityupdater/FireUpdater.java b/src/main/java/com/projectkorra/items/abilityupdater/FireUpdater.java new file mode 100644 index 0000000..54e305d --- /dev/null +++ b/src/main/java/com/projectkorra/items/abilityupdater/FireUpdater.java @@ -0,0 +1,422 @@ +package com.projectkorra.items.abilityupdater; + +import org.bukkit.entity.Player; + +import com.projectkorra.projectkorra.firebending.Blaze; +import com.projectkorra.projectkorra.firebending.BlazeArc; +import com.projectkorra.projectkorra.firebending.BlazeRing; +import com.projectkorra.projectkorra.firebending.FireBlast; +import com.projectkorra.projectkorra.firebending.FireBlastCharged; +import com.projectkorra.projectkorra.firebending.FireBurst; +import com.projectkorra.projectkorra.firebending.FireJet; +import com.projectkorra.projectkorra.firebending.FireManipulation; +import com.projectkorra.projectkorra.firebending.FireShield; +import com.projectkorra.projectkorra.firebending.HeatControl; +import com.projectkorra.projectkorra.firebending.Illumination; +import com.projectkorra.projectkorra.firebending.WallOfFire; +import com.projectkorra.projectkorra.firebending.combo.FireComboStream; +import com.projectkorra.projectkorra.firebending.combo.FireKick; +import com.projectkorra.projectkorra.firebending.combo.FireSpin; +import com.projectkorra.projectkorra.firebending.combo.FireWheel; +import com.projectkorra.projectkorra.firebending.combo.JetBlast; +import com.projectkorra.projectkorra.firebending.combo.JetBlaze; +import com.projectkorra.projectkorra.firebending.combustion.Combustion; +import com.projectkorra.projectkorra.firebending.lightning.Lightning; + +import java.util.Map; + +public class FireUpdater { + + /** + * updates the fire abilities based on a players bending effect attributes + * + * @param player the player that has the effects + * @param ability an instance of a fire ability + * @param attribs the map of the players effects + * @return if the ability was updated correctly + */ + + public static boolean updateAbilityDamage(Player player, Object ability, Map attribs) { + if (ability instanceof FireBlast) { + FireBlast abil = (FireBlast) ability; + + if (attribs.containsKey("FireBlastDamage")) + abil.setDamage(abil.getDamage() + abil.getDamage() * attribs.get("FireBlastDamage") / 100.0); + + return true; + } + else if (ability instanceof FireBurst) { + FireBurst abil = (FireBurst) ability; + + if (attribs.containsKey("FireBurstDamage")) + abil.setDamage((int) (abil.getDamage() + abil.getDamage() * attribs.get("FireBurstDamage") / 100.0)); + + return true; + } + else if (ability instanceof WallOfFire) { + WallOfFire abil = (WallOfFire) ability; + + if (attribs.containsKey("WallOfFireDamage")) + abil.setDamage((int) (abil.getDamage() + abil.getDamage() * attribs.get("WallOfFireDamage") / 100.0)); + + return true; + } + else if (ability instanceof Combustion) { + Combustion abil = (Combustion) ability; + + if (attribs.containsKey("CombustionDamage")) + abil.setDamage(abil.getDamage() + abil.getDamage() * attribs.get("CombustionDamage") / 100.0); + + return true; + } + else if (ability instanceof Lightning) { + Lightning abil = (Lightning) ability; + + if (attribs.containsKey("LightningDamage")) + abil.setDamage(abil.getDamage() + abil.getDamage() * attribs.get("LightningDamage") / 100.0); + + return true; + } + + // Damage can be set for FireComboStream, but has no get method. + + return false; + } + + public static boolean updateAbility(Player player, Object ability, Map attribs) { + if (ability instanceof Blaze) { + // Blaze abil = (Blaze) ability; + + return true; + } + else if (ability instanceof BlazeArc) { + BlazeArc abil = (BlazeArc) ability; + + if (attribs.containsKey("BlazeArcInterval")) + abil.setInterval((long) (abil.getInterval() + abil.getInterval() * attribs.get("BlazeArcInterval") / 100.0)); + + if (attribs.containsKey("BlazeArcRange")) + abil.setRange(abil.getRange() + abil.getRange() * attribs.get("BlazeArcRange") / 100.0); + + if (attribs.containsKey("BlazeArcSpeed")) + abil.setSpeed(abil.getSpeed() + abil.getSpeed() * attribs.get("BlazeArcSpeed") / 100.0); + + //if (attribs.containsKey("BlazeArcTime")) + // abil.setTime((long) (abil.getTime() + abil.getTime() * attribs.get("BlazeArcTime") / 100.0)); + + return true; + } + else if (ability instanceof BlazeRing) { + BlazeRing abil = (BlazeRing) ability; + + if (attribs.containsKey("BlazeRingAngleIncrement")) + abil.setAngleIncrement(abil.getAngleIncrement() + abil.getAngleIncrement() * attribs.get("BlazeRingAngleIncrement") / 100.0); + + if (attribs.containsKey("BlazeRingCooldown")) + abil.setCooldown((long) (abil.getCooldown() + abil.getCooldown() * attribs.get("BlazeRingCooldown") / 100.0)); + + if (attribs.containsKey("BlazeRingRange")) + abil.setRange((int) (abil.getRange() + abil.getRange() * attribs.get("BlazeRingRange") / 100.0)); + + return true; + } + else if (ability instanceof FireBlast) { + FireBlast abil = (FireBlast) ability; + + if (attribs.containsKey("FireBlastCollisionRadius")) + abil.setCollisionRadius(abil.getCollisionRadius() + abil.getCollisionRadius() * attribs.get("FireBlastCollisionRadius") / 100.0); + + if (attribs.containsKey("FireBlastCooldown")) + abil.setCooldown((long) (abil.getCooldown() + abil.getCooldown() * attribs.get("FireBlastCooldown") / 100.0)); + + if (attribs.containsKey("FireBlastFireTicks")) + abil.setFireTicks(abil.getFireTicks() + abil.getFireTicks() * attribs.get("FireBlastFireTicks") / 100.0); + + if (attribs.containsKey("FireBlastPushFactor")) + abil.setPushFactor(abil.getPushFactor() + abil.getPushFactor() * attribs.get("FireBlastPushFactor") / 100.0); + + if (attribs.containsKey("FireBlastRange")) + abil.setRange(abil.getRange() + abil.getRange() * attribs.get("FireBlastRange") / 100.0); + + if (attribs.containsKey("FireBlastSpeed")) + abil.setSpeed(abil.getSpeed() + abil.getSpeed() * attribs.get("FireBlastSpeed") / 100.0); + + if (attribs.containsKey("FireBlastSpeedFactor")) + abil.setSpeedFactor(abil.getSpeedFactor() + abil.getSpeedFactor() * attribs.get("FireBlastSpeedFactor") / 100.0); + + return true; + } + else if (ability instanceof FireBlastCharged) { + FireBlastCharged abil = (FireBlastCharged) ability; + + if (attribs.containsKey("FireBlastChargedChargeTime")) + abil.setChargeTime((long) (abil.getChargeTime() + abil.getChargeTime() * attribs.get("FireBlastChargedChargeTime") / 100.0)); + + if (attribs.containsKey("FireBlastChargedCollisionRadius")) + abil.setCollisionRadius(abil.getCollisionRadius() + abil.getCollisionRadius() * attribs.get("FireBlastChargedCollisionRadius") / 100.0); + + if (attribs.containsKey("FireBlastChargedDamageRadius")) + abil.setDamageRadius(abil.getDamageRadius() + abil.getDamageRadius() * attribs.get("FireBlastChargedDamageRadius") / 100.0); + + if (attribs.containsKey("FireBlastChargedExplosionRadius")) + abil.setExplosionRadius(abil.getExplosionRadius() + abil.getExplosionRadius() * attribs.get("FireBlastChargedExplosionRadius") / 100.0); + + if (attribs.containsKey("FireBlastChargedFireTicks")) + abil.setFireTicks(abil.getFireTicks() + abil.getFireTicks() * attribs.get("FireBlastChargedFireTicks") / 100.0); + + if (attribs.containsKey("FireBlastChargedInnerRadius")) + abil.setInnerRadius(abil.getInnerRadius() + abil.getInnerRadius() * attribs.get("FireBlastChargedInnerRadius") / 100.0); + + if (attribs.containsKey("FireBlastChargedInterval")) + abil.setInterval((long)(abil.getInterval() + abil.getInterval() * attribs.get("FireBlastChargedInterval") / 100.0)); + + if (attribs.containsKey("FireBlastChargedMaxDamage")) + abil.setMaxDamage((int) (abil.getMaxDamage() + abil.getMaxDamage() * attribs.get("FireBlastChargedMaxDamage") / 100.0)); + + if (attribs.containsKey("FireBlastChargedRange")) + abil.setRange(abil.getRange() + abil.getRange() * attribs.get("FireBlastChargedRange") / 100.0); + + //if (attribs.containsKey("FireBlastChargedTime")) + // abil.setTime((long)(abil.getTime() + abil.getTime() * attribs.get("FireBlastChargedTime") / 100.0)); + + return true; + } + else if (ability instanceof FireBurst) { + FireBurst abil = (FireBurst) ability; + + if (attribs.containsKey("FireBurstAnglePhi")) + abil.setAnglePhi(abil.getAnglePhi() + abil.getAnglePhi() * attribs.get("FireBurstAnglePhi") / 100.0); + + if (attribs.containsKey("FireBurstAngleTheta")) + abil.setAngleTheta(abil.getAngleTheta() + abil.getAngleTheta() * attribs.get("FireBurstAngleTheta") / 100.0); + + if (attribs.containsKey("FireBurstChargeTime")) + abil.setChargeTime((long) (abil.getChargeTime() + abil.getChargeTime() * attribs.get("FireBurstChargeTime") / 100.0)); + + if (attribs.containsKey("FireBurstCooldown")) + abil.setCooldown((long) (abil.getCooldown() + abil.getCooldown() * attribs.get("FireBurstCooldown") / 100.0)); + + if (attribs.containsKey("FireBurstParticlesPercentage")) + abil.setParticlesPercentage(abil.getParticlesPercentage() + abil.getParticlesPercentage() * attribs.get("FireBurstParticlesPercentage") / 100.0); + + if (attribs.containsKey("FireBurstRange")) + abil.setRange((long) (abil.getRange() + abil.getRange() * attribs.get("FireBurstRange") / 100.0)); + + return true; + } + else if (ability instanceof FireJet) { + FireJet abil = (FireJet) ability; + + if (attribs.containsKey("FireJetCooldown")) + abil.setCooldown((long) (abil.getCooldown() + abil.getCooldown() * attribs.get("FireJetCooldown") / 100.0)); + + if (attribs.containsKey("FireJetDuration")) + abil.setDuration((long) (abil.getDuration() + abil.getDuration() * attribs.get("FireJetDuration") / 100.0)); + + if (attribs.containsKey("FireJetSpeed")) + abil.setSpeed(abil.getSpeed() + abil.getSpeed() * attribs.get("FireJetSpeed") / 100.0); + + //if (attribs.containsKey("FireJetTime")) + // abil.setTime((long) (abil.getTime() + abil.getTime() * attribs.get("FireJetTime") / 100.0)); + + return true; + } + else if (ability instanceof FireManipulation) { + //FireManipulation abil = (FireManipulation) ability; + + return true; + } + else if (ability instanceof FireShield) { + FireShield abil = (FireShield) ability; + + if (attribs.containsKey("FireShieldDiscCooldown")) + abil.setDiscCooldown((long) (abil.getCooldown() + abil.getCooldown() * attribs.get("FireShieldDiscCooldown") / 100.0)); // Shift + + if (attribs.containsKey("FireShieldDiscDuration")) + abil.setDiscDuration((long) (abil.getDuration() + abil.getDuration() * attribs.get("FireShieldDiscDuration") / 100.0)); // Shift + + if (attribs.containsKey("FireShieldDiscRadius")) + abil.setDiscRadius(abil.getDiscRadius() + abil.getDiscRadius() * attribs.get("FireShieldDiscRadius") / 100.0); // Shift + + //if (attribs.containsKey("FireShieldInterval")) + // abil.setInterval((long) (abil.getInterval() + abil.getInterval() * attribs.get("FireShieldInterval") / 100.0)); + + if (attribs.containsKey("FireShieldShieldRadius")) + abil.setShieldRadius(abil.getShieldRadius() + abil.getShieldRadius() * attribs.get("FireShieldShieldRadius") / 100.0); + + if (attribs.containsKey("FireShieldShieldCooldown")) + abil.setShieldCooldown((long) (abil.getCooldown() + abil.getCooldown() * attribs.get("FireShieldShieldCooldown") / 100.0)); // Click + + if (attribs.containsKey("FireShieldShieldDuration")) + abil.setShieldDuration((long) (abil.getDuration() + abil.getDuration() * attribs.get("FireShieldShieldDuration") / 100.0)); // Click + + return true; + } + else if (ability instanceof HeatControl) { // HeatControl has no attributes of type double to be set + //HeatControl abil = (HeatControl) ability; + //if (attribs.containsKey("HeatControlCookTime")) + //abil.setCookTime((long) (abil.getCookTime() + abil.getCookTime() * attribs.get("HeatControlCookTime") / 100.0)); + return true; + } + else if (ability instanceof Illumination) { + Illumination abil = (Illumination) ability; + + if (attribs.containsKey("IlluminationCooldown")) + abil.setCooldown((long) (abil.getCooldown() + abil.getCooldown() * attribs.get("IlluminationCooldown") / 100.0)); + + if (attribs.containsKey("IlluminationRange")) + abil.setRange(abil.getRange() + abil.getRange() * attribs.get("IlluminationRange") / 100.0); + + return true; + } + else if (ability instanceof WallOfFire) { + WallOfFire abil = (WallOfFire) ability; + + if (attribs.containsKey("WallOfFireCooldown")) + abil.setCooldown((long) (abil.getCooldown() + abil.getCooldown() * attribs.get("WallOfFireCooldown") / 100.0)); + + if (attribs.containsKey("WallOfFireDamageInterval")) + abil.setDamageInterval((long) (abil.getDamageInterval() + abil.getDamageInterval() * attribs.get("WallOfFireDamageInterval") / 100.0)); + + if (attribs.containsKey("WallOfFireDamageTick")) + abil.setDamageTick((int) (abil.getDamageTick() + abil.getDamageTick() * attribs.get("WallOfFireDamageTick") / 100.0)); + + if (attribs.containsKey("WallOfFireDuration")) + abil.setDuration((long) (abil.getDuration() + abil.getDuration() * attribs.get("WallOfFireDuration") / 100.0)); + + if (attribs.containsKey("WallOfFireFireTicks")) + abil.setFireTicks(abil.getFireTicks() + abil.getFireTicks() * attribs.get("WallOfFireFireTicks") / 100.0); + + if (attribs.containsKey("WallOfFireHeight")) + abil.setHeight((int) (abil.getHeight() + abil.getHeight() * attribs.get("WallOfFireHeight") / 100.0)); + + if (attribs.containsKey("WallOfFireInterval")) + abil.setInterval((long) (abil.getInterval() + abil.getInterval() * attribs.get("WallOfFireInterval") / 100.0)); + + if (attribs.containsKey("WallOfFireIntervalTick")) + abil.setIntervalTick((int) (abil.getIntervalTick() + abil.getIntervalTick() * attribs.get("WallOfFireIntervalTick") / 100.0)); + + if (attribs.containsKey("WallOfFireMaxAngle")) + abil.setMaxAngle(abil.getMaxAngle() + abil.getMaxAngle() * attribs.get("WallOfFireMaxAngle") / 100.0); + + if (attribs.containsKey("WallOfFireRange")) + abil.setRange((int) (abil.getRange() + abil.getRange() * attribs.get("WallOfFireRange") / 100.0)); + + //if (attribs.containsKey("WallOfFireTime")) + // abil.setTime((long) (abil.getTime() + abil.getTime() * attribs.get("WallOfFireTime") / 100.0)); + + if (attribs.containsKey("WallOfFireWidth")) + abil.setWidth((int) (abil.getWidth() + abil.getWidth() * attribs.get("WallOfFireWidth") / 100.0)); + + return true; + } + else if (ability instanceof Combustion) { + Combustion abil = (Combustion) ability; + + if (attribs.containsKey("CombustionCooldown")) + abil.setCooldown((long) (abil.getCooldown() + abil.getCooldown() * attribs.get("CombustionCooldown") / 100.0)); + + if (attribs.containsKey("CombustionExplosivePower")) + abil.setExplosivePower((float) (abil.getExplosivePower() + abil.getExplosivePower() * attribs.get("CombustionExplosivePower") / 100.0)); + + if (attribs.containsKey("CombustionRadius")) + abil.setRadius(abil.getRadius() + abil.getRadius() * attribs.get("CombustionRadius") / 100.0); + + if (attribs.containsKey("CombustionRange")) + abil.setRange(abil.getRange() + abil.getRange() * attribs.get("CombustionRange") / 100.0); + + if (attribs.containsKey("CombustionSpeed")) + abil.setSpeed(abil.getSpeed() + abil.getSpeed() * attribs.get("CombustionSpeed") / 100.0); + + if (attribs.containsKey("CombustionSpeedFactor")) + abil.setSpeedFactor(abil.getSpeedFactor() + abil.getSpeedFactor() * attribs.get("CombustionSpeedFactor") / 100.0); + + if (attribs.containsKey("CombustionTicks")) + abil.setTicks((int) (abil.getTicks() + abil.getTicks() * attribs.get("CombustionTicks") / 100.0)); + + return true; + } + else if (ability instanceof Lightning) { + Lightning abil = (Lightning) ability; + + if (attribs.containsKey("LightningChainArcChance")) + abil.setChainArcChance(abil.getChainArcChance() + abil.getChainArcChance() * attribs.get("LightningChainArcChance") / 100.0); + + if (attribs.containsKey("LightningChainRange")) + abil.setChainRange(abil.getChainRange() + abil.getChainRange() * attribs.get("LightningChainRange") / 100.0); + + if (attribs.containsKey("LightningChargeTime")) + abil.setChargeTime(abil.getChargeTime() + abil.getChargeTime() * attribs.get("LightningChargeTime") / 100.0); + + if (attribs.containsKey("LightningCooldown")) + abil.setCooldown((long) (abil.getCooldown() + abil.getCooldown() * attribs.get("LightningCooldown") / 100.0)); + + if (attribs.containsKey("LightningMaxArcAngle")) + abil.setMaxArcAngle(abil.getMaxArcAngle() + abil.getMaxArcAngle() * attribs.get("LightningMaxArcAngle") / 100.0); + + if (attribs.containsKey("LightningMaxChainArcs")) + abil.setMaxChainArcs(abil.getMaxChainArcs() + abil.getMaxChainArcs() * attribs.get("LightningMaxChainArcs") / 100.0); + + //if (attribs.containsKey("LightningParticleRotation")) + // abil.setParticleRotation(abil.getParticleRotation() + abil.getParticleRotation() * attribs.get("LightningParticleRotation") / 100.0); + + if (attribs.containsKey("LightningRange")) + abil.setRange(abil.getRange() + abil.getRange() * attribs.get("LightningRange") / 100.0); + + if (attribs.containsKey("LightningStunChance")) + abil.setStunChance(abil.getStunChance() + abil.getStunChance() * attribs.get("LightningStunChance") / 100.0); + + if (attribs.containsKey("LightningStunDuration")) + abil.setStunDuration(abil.getStunDuration() + abil.getStunDuration() * attribs.get("LightningStunDuration") / 100.0); + + if (attribs.containsKey("LightningSubArcChance")) + abil.setSubArcChance(abil.getSubArcChance() + abil.getSubArcChance() * attribs.get("LightningSubArcChance") / 100.0); + + //if (attribs.containsKey("LightningTime")) + // abil.setTime((long) (abil.getTime() + abil.getTime() * attribs.get("LightningTime") / 100.0)); + + if (attribs.containsKey("LightningWaterArcRange")) + abil.setWaterArcRange(abil.getWaterArcRange() + abil.getWaterArcRange() * attribs.get("LightningWaterArcRange") / 100.0); + + if (attribs.containsKey("LightningWaterArcs")) + abil.setWaterArcs((int) (abil.getWaterArcs() + abil.getWaterArcs() * attribs.get("LightningWaterArcs") / 100.0)); + + return true; + } + else if (ability instanceof FireComboStream) { + //FireComboStream abil = (FireComboStream) ability; + + // Has no getters + + return true; + } + else if (ability instanceof FireKick) { + //FireKick abil = (FireKick) ability; + + return true; + } + else if (ability instanceof FireSpin) { + //FireSpin abil = (FireSpin) ability; + + return true; + } + else if (ability instanceof FireWheel) { + //FireWheel abil = (FireWheel) ability; + + return true; + } + else if (ability instanceof JetBlast) { + //JetBlast abil = (JetBlast) ability; + + return true; + } + else if (ability instanceof JetBlaze) { + //JetBlaze abil = (JetBlaze) ability; + + return true; + } + + return false; + } + +} diff --git a/src/main/java/com/projectkorra/items/abilityupdater/WaterUpdater.java b/src/main/java/com/projectkorra/items/abilityupdater/WaterUpdater.java new file mode 100644 index 0000000..9e36935 --- /dev/null +++ b/src/main/java/com/projectkorra/items/abilityupdater/WaterUpdater.java @@ -0,0 +1,738 @@ +package com.projectkorra.items.abilityupdater; + +import java.util.Map; + +import org.bukkit.entity.Player; + +import com.projectkorra.projectkorra.waterbending.OctopusForm; +import com.projectkorra.projectkorra.waterbending.SurgeWall; +import com.projectkorra.projectkorra.waterbending.SurgeWave; +import com.projectkorra.projectkorra.waterbending.Torrent; +import com.projectkorra.projectkorra.waterbending.TorrentWave; +import com.projectkorra.projectkorra.waterbending.WaterBubble; +import com.projectkorra.projectkorra.waterbending.WaterManipulation; +import com.projectkorra.projectkorra.waterbending.WaterSpout; +import com.projectkorra.projectkorra.waterbending.WaterSpoutWave; +import com.projectkorra.projectkorra.waterbending.blood.Bloodbending; +import com.projectkorra.projectkorra.waterbending.combo.IceBullet; +import com.projectkorra.projectkorra.waterbending.combo.IceWave; +import com.projectkorra.projectkorra.waterbending.healing.HealingWaters; +import com.projectkorra.projectkorra.waterbending.ice.IceBlast; +import com.projectkorra.projectkorra.waterbending.ice.IceSpikeBlast; +import com.projectkorra.projectkorra.waterbending.ice.IceSpikePillar; +import com.projectkorra.projectkorra.waterbending.ice.IceSpikePillarField; +import com.projectkorra.projectkorra.waterbending.ice.PhaseChange; +import com.projectkorra.projectkorra.waterbending.multiabilities.WaterArms; +import com.projectkorra.projectkorra.waterbending.multiabilities.WaterArmsFreeze; +import com.projectkorra.projectkorra.waterbending.multiabilities.WaterArmsSpear; +import com.projectkorra.projectkorra.waterbending.multiabilities.WaterArmsWhip; +import com.projectkorra.projectkorra.waterbending.plant.PlantRegrowth; + +public class WaterUpdater { + + /** + * updates the water abilities based on a players bending effect attributes + * + * @param player the player that has the effects + * @param ability an instance of a water ability + * @param attribs the map of the players effects + * @return if the ability was updated correctly + */ + + public static boolean updateAbilityDamage(Player player, Object ability, Map attribs) { + if (ability instanceof OctopusForm) { + OctopusForm abil = (OctopusForm) ability; + if (attribs.containsKey("OctopusFormDamage")) + abil.setDamage((int) (abil.getDamage() + abil.getDamage() * attribs.get("OctopusFormDamage") / 100.0)); + return true; + } + else if (ability instanceof Torrent) { + Torrent abil = (Torrent) ability; + if (attribs.containsKey("TorrentDamage")) + abil.setDamage(abil.getDamage() + abil.getDamage() * attribs.get("TorrentDamage") / 100.0); + + if (attribs.containsKey("TorrentDeflectDamage")) + abil.setDeflectDamage(abil.getDeflectDamage() + abil.getDeflectDamage() * attribs.get("TorrentDeflectDamage") / 100.0); + return true; + } + else if (ability instanceof WaterManipulation) { + WaterManipulation abil = (WaterManipulation) ability; + if (attribs.containsKey("WaterManipulationDamage")) + abil.setDamage(abil.getDamage() + abil.getDamage() * attribs.get("WaterManipulationDamage") / 100.0); + return true; + } + else if (ability instanceof WaterSpoutWave) { + WaterSpoutWave abil = (WaterSpoutWave) ability; + if (attribs.containsKey("WaterSpoutWaveDamage")) + abil.setDamage(abil.getDamage() + abil.getDamage() * attribs.get("WaterSpoutWaveDamage") / 100.0); + return true; + } + else if (ability instanceof WaterArmsSpear) { + WaterArmsSpear abil = (WaterArmsSpear) ability; + if (attribs.containsKey("WaterArmsSpearSpearDamage")) + abil.setSpearDamage(abil.getSpearDamage() + abil.getSpearDamage() * attribs.get("WaterArmsSpearSpearDamage") / 100.0); + return true; + } + else if (ability instanceof WaterArmsWhip) { + WaterArmsWhip abil = (WaterArmsWhip) ability; + if (!abil.isHasDamaged() && attribs.containsKey("WaterArmsWhipPunchDamage")) + abil.setPunchDamage(abil.getPunchDamage() + abil.getPunchDamage() * attribs.get("WaterArmsWhipPunchDamage") / 100.0); + } + else if (ability instanceof IceBlast) { + IceBlast abil = (IceBlast) ability; + + if (attribs.containsKey("IceBlastDamage")) + abil.setDamage(abil.getDamage() + abil.getDamage() * attribs.get("IceBlastDamage") / 100.0); + + return true; + } + else if (ability instanceof IceSpikeBlast) { + IceSpikeBlast abil = (IceSpikeBlast) ability; + if (attribs.containsKey("IceSpikeDamage")) + abil.setDamage(abil.getDamage() + abil.getDamage() * attribs.get("IceSpikeDamage") / 100.0); + return true; + } + else if (ability instanceof IceSpikePillar) { + IceSpikePillar abil = (IceSpikePillar) ability; + if (attribs.containsKey("IceSpikePillarDamage")) + abil.setDamage(abil.getDamage() + abil.getDamage() * attribs.get("IceSpikePillarDamage") / 100.0); + return true; + } + else if (ability instanceof IceSpikePillarField) { + IceSpikePillarField abil = (IceSpikePillarField) ability; + if (attribs.containsKey("IceSpikePillarFieldDamage")) + abil.setDamage(abil.getDamage() + abil.getDamage() * attribs.get("IceSpikePillarFieldDamage") / 100.0); + return true; + } + else if (ability instanceof IceBullet) { + IceBullet abil = (IceBullet) ability; + if (attribs.containsKey("IceBulletDamage")) + abil.setDamage(abil.getDamage() + abil.getDamage() * attribs.get("IceBulletDamage") / 100.0); + return true; + } + WaterArmsFreeze f; + + return false; + } + + public static boolean updateAbility(Player player, Object ability, Map attribs) { + if (ability instanceof OctopusForm) { + OctopusForm abil = (OctopusForm) ability; + + //if (attribs.containsKey("OctopusFormAngle")) + // abil.setAngle(abil.getAngle() + abil.getAngle() * attribs.get("OctopusFormAngle") / 100.0); + + //if (attribs.containsKey("OctopusFormAngleIncrement")) + // abil.setAngleIncrement(abil.getAngleIncrement() + abil.getAngleIncrement() * attribs.get("OctopusFormAngleIncrement") / 100.0); + + if (attribs.containsKey("OctopusFormAttackRange")) + abil.setAttackRange(abil.getAttackRange() + abil.getAttackRange() * attribs.get("OctopusFormAttackRange") / 100.0); + + if (attribs.containsKey("OctopusFormCooldown")) + abil.setCooldown((long) (abil.getCooldown() + abil.getCooldown() * attribs.get("OctopusFormCooldown") / 100.0)); + + //if (attribs.containsKey("OctopusFormCurrentAnimationStep")) + // abil.setCurrentAnimationStep((int) (abil.getCurrentAnimationStep() + abil.getCurrentAnimationStep() * attribs.get("OctopusFormCurrentAnimationStep") / 100.0)); + + //if (attribs.containsKey("OctopusFormCurrentFormHeight")) + // abil.setCurrentFormHeight(abil.getCurrentFormHeight() + abil.getCurrentFormHeight() * attribs.get("OctopusFormCurrentFormHeight") / 100.0); + + if (attribs.containsKey("OctopusFormInterval")) + abil.setInterval((long) (abil.getInterval() + abil.getInterval() * attribs.get("OctopusFormInterval") / 100.0)); + + if (attribs.containsKey("OctopusFormKnockback")) + abil.setKnockback(abil.getKnockback() + abil.getKnockback() * attribs.get("OctopusFormKnockback") / 100.0); + + if (attribs.containsKey("OctopusFormRadius")) + abil.setRadius(abil.getRadius() + abil.getRadius() * attribs.get("OctopusFormRadius") / 100.0); + + if (attribs.containsKey("OctopusFormRange")) + abil.setRange((int) (abil.getRange() + abil.getRange() * attribs.get("OctopusFormRange") / 100.0)); + + //if (attribs.containsKey("OctopusFormStartAngle")) + // abil.setStartAngle(abil.getStartAngle() + abil.getStartAngle() * attribs.get("OctopusFormStartAngle") / 100.0); + + //if (attribs.containsKey("OctopusFormStepCounter")) + // abil.setStepCounter((int) (abil.getStepCounter() + abil.getStepCounter() * attribs.get("OctopusFormStepCounter") / 100.0)); + + //if (attribs.containsKey("OctopusFormTime")) + // abil.setTime((long) (abil.getTime() + abil.getTime() * attribs.get("OctopusFormTime") / 100.0)); + + //if (attribs.containsKey("OctopusFormTotalStepCount")) + // abil.setTotalStepCount((int) (abil.getTotalStepCount() + abil.getTotalStepCount() * attribs.get("OctopusFormTotalStepCount") / 100.0)); + + return true; + } + else if (ability instanceof SurgeWall) { + SurgeWall abil = (SurgeWall) ability; + + if (attribs.containsKey("SurgeWallCooldown")) + abil.setCooldown((long) (abil.getCooldown() + abil.getCooldown() * attribs.get("SurgeWallCooldown") / 100.0)); + + if (attribs.containsKey("SurgeWallInterval")) + abil.setInterval((long) (abil.getInterval() + abil.getInterval() * attribs.get("SurgeWallInterval") / 100.0)); + + if (attribs.containsKey("SurgeWallRadius")) + abil.setRadius(abil.getRadius() + abil.getRadius() * attribs.get("SurgeWallRadius") / 100.0); + + if (attribs.containsKey("SurgeWallRange")) + abil.setRange(abil.getRange() + abil.getRange() * attribs.get("SurgeWallRange") / 100.0); + + //if (attribs.containsKey("SurgeWallTime")) + // abil.setTime((long) (abil.getTime() + abil.getTime() * attribs.get("SurgeWallTime") / 100.0)); + + return true; + } + else if (ability instanceof SurgeWave) { + SurgeWave abil = (SurgeWave) ability; + + if (attribs.containsKey("SurgeWaveCooldown")) + abil.setCooldown((long) (abil.getCooldown() + abil.getCooldown() * attribs.get("SurgeWaveCooldown") / 100.0)); + + //if (attribs.containsKey("SurgeWaveCurrentRadius")) + // abil.setCurrentRadius(abil.getCurrentRadius() + abil.getCurrentRadius() * attribs.get("SurgeWaveCurrentRadius") / 100.0); + + if (attribs.containsKey("SurgeWaveInterval")) + abil.setInterval((long) (abil.getInterval() + abil.getInterval() * attribs.get("SurgeWaveInterval") / 100.0)); + + if (attribs.containsKey("SurgeWaveMaxFreezeRadius")) + abil.setMaxFreezeRadius(abil.getMaxFreezeRadius() + abil.getMaxFreezeRadius() * attribs.get("SurgeWaveMaxFreezeRadius") / 100.0); + + if (attribs.containsKey("SurgeWaveMaxRadius")) + abil.setMaxRadius(abil.getMaxRadius() + abil.getMaxRadius() * attribs.get("SurgeWaveMaxRadius") / 100.0); + + if (attribs.containsKey("SurgeWaveKnockback")) + abil.setKnockback(abil.getKnockback() + abil.getKnockback() * attribs.get("SurgeWaveKnockback") / 100.0); + + if (attribs.containsKey("SurgeWaveRange")) + abil.setRange(abil.getRange() + abil.getRange() * attribs.get("SurgeWaveRange") / 100.0); + + //if (attribs.containsKey("SurgeWaveTime")) + // abil.setTime((long) (abil.getTime() + abil.getTime() * attribs.get("SurgeWaveTime") / 100.0)); + + if (attribs.containsKey("SurgeWaveKnockup")) + abil.setKnockup(abil.getKnockup() + abil.getKnockup() * attribs.get("SurgeWaveKnockup") / 100.0); + + return true; + } + else if (ability instanceof Torrent) { + Torrent abil = (Torrent) ability; + + //if (attribs.containsKey("TorrentAngle")) + // abil.setAngle(abil.getAngle() + abil.getAngle() * attribs.get("TorrentAngle") / 100.0); + + if (attribs.containsKey("TorrentCooldown")) + abil.setCooldown((long) (abil.getCooldown() + abil.getCooldown() * attribs.get("TorrentCooldown") / 100.0)); + + if (attribs.containsKey("TorrentInterval")) + abil.setInterval((long) (abil.getInterval() + abil.getInterval() * attribs.get("TorrentInterval") / 100.0)); + + //if (attribs.containsKey("TorrentLayer")) + // abil.setLayer((int) (abil.getLayer() + abil.getLayer() * attribs.get("TorrentLayer") / 100.0)); + + if (attribs.containsKey("TorrentMaxLayer")) + abil.setMaxLayer((int) (abil.getMaxLayer() + abil.getMaxLayer() * attribs.get("TorrentMaxLayer") / 100.0)); + + if (attribs.containsKey("TorrentMaxUpwardForce")) + abil.setMaxUpwardForce(abil.getMaxUpwardForce() + abil.getMaxUpwardForce() * attribs.get("TorrentMaxUpwardForce") / 100.0); + + if (attribs.containsKey("TorrentPush")) + abil.setPush(abil.getPush() + abil.getPush() * attribs.get("TorrentPush") / 100.0); + + if (attribs.containsKey("TorrentRadius")) + abil.setRadius(abil.getRadius() + abil.getRadius() * attribs.get("TorrentRadius") / 100.0); + + if (attribs.containsKey("TorrentRange")) + abil.setRange(abil.getRange() + abil.getRange() * attribs.get("TorrentRange") / 100.0); + + if (attribs.containsKey("TorrentSelectRange")) + abil.setSelectRange(abil.getSelectRange() + abil.getSelectRange() * attribs.get("TorrentSelectRange") / 100.0); + + //if (attribs.containsKey("TorrentStartAngle")) + // abil.setStartAngle(abil.getStartAngle() + abil.getStartAngle() * attribs.get("TorrentStartAngle") / 100.0); + + //if (attribs.containsKey("TorrentTime")) + // abil.setTime((long) (abil.getTime() + abil.getTime() * attribs.get("TorrentTime") / 100.0)); + + return true; + } + else if (ability instanceof TorrentWave) { + TorrentWave abil = (TorrentWave) ability; + + if (attribs.containsKey("TorrentWaveCooldown")) + abil.setCooldown((long) (abil.getCooldown() + abil.getCooldown() * attribs.get("TorrentWaveCooldown") / 100.0)); + + if (attribs.containsKey("TorrentWaveGrowSpeed")) + abil.setGrowSpeed(abil.getGrowSpeed() + abil.getGrowSpeed() * attribs.get("TorrentWaveGrowSpeed") / 100.0); + + if (attribs.containsKey("TorrentWaveInterval")) + abil.setInterval((long) (abil.getInterval() + abil.getInterval() * attribs.get("TorrentWaveInterval") / 100.0)); + + if (attribs.containsKey("TorrentWaveKnockback")) + abil.setKnockback(abil.getKnockback() + abil.getKnockback() * attribs.get("TorrentWaveKnockback") / 100.0); + + if (attribs.containsKey("TorrentWaveMaxHeight")) + abil.setMaxHeight(abil.getMaxHeight() + abil.getMaxHeight() * attribs.get("TorrentWaveMaxHeight") / 100.0); + + if (attribs.containsKey("TorrentWaveMaxRadius")) + abil.setMaxRadius(abil.getMaxRadius() + abil.getMaxRadius() * attribs.get("TorrentWaveMaxRadius") / 100.0); + + //if (attribs.containsKey("TorrentWaveRadius")) + // abil.setRadius(abil.getRadius() + abil.getRadius() * attribs.get("TorrentWaveRadius") / 100.0); + + //if (attribs.containsKey("TorrentWaveTime")) + // abil.setTime((long) (abil.getTime() + abil.getTime() * attribs.get("TorrentWaveTime") / 100.0)); + + return true; + } + else if (ability instanceof WaterBubble) { + //WaterBubble abil = (WaterBubble) ability; + + return true; + } + else if (ability instanceof WaterManipulation) { + WaterManipulation abil = (WaterManipulation) ability; + + if (attribs.containsKey("WaterManipulationCollisionRadius")) + abil.setCollisionRadius(abil.getCollisionRadius() + abil.getCollisionRadius() * attribs.get("WaterManipulationCollisionRadius") / 100.0); + + if (attribs.containsKey("WaterManipulationCooldown")) + abil.setCooldown((long) (abil.getCooldown() + abil.getCooldown() * attribs.get("WaterManipulationCooldown") / 100.0)); + + if (attribs.containsKey("WaterManipulationDeflectRange")) + abil.setDeflectRange(abil.getDeflectRange() + abil.getDeflectRange() * attribs.get("WaterManipulationDeflectRange") / 100.0); + + if (attribs.containsKey("WaterManipulationDispelRange")) + abil.setDispelRange((int) (abil.getDispelRange() + abil.getDispelRange() * attribs.get("WaterManipulationDispelRange") / 100.0)); + + if (attribs.containsKey("WaterManipulationInterval")) + abil.setInterval((long) (abil.getInterval() + abil.getInterval() * attribs.get("WaterManipulationInterval") / 100.0)); + + if (attribs.containsKey("WaterManipulationPushFactor")) + abil.setPushFactor(abil.getPushFactor() + abil.getPushFactor() * attribs.get("WaterManipulationPushFactor") / 100.0); + + if (attribs.containsKey("WaterManipulationRange")) + abil.setRange(abil.getRange() + abil.getRange() * attribs.get("WaterManipulationRange") / 100.0); + + if (attribs.containsKey("WaterManipulationSelectRange")) + abil.setSelectRange(abil.getSelectRange() + abil.getSelectRange() * attribs.get("WaterManipulationSelectRange") / 100.0); + + if (attribs.containsKey("WaterManipulationSpeed")) + abil.setSpeed(abil.getSpeed() + abil.getSpeed() * attribs.get("WaterManipulationSpeed") / 100.0); + + //if (attribs.containsKey("WaterManipulationTime")) + // abil.setTime((long) (abil.getTime() + abil.getTime() * attribs.get("WaterManipulationTime") / 100.0)); + + return true; + } + else if (ability instanceof WaterSpout) { + WaterSpout abil = (WaterSpout) ability; + + //if (attribs.containsKey("WaterSpoutAngle")) + // abil.setAngle((int) (abil.getAngle() + abil.getAngle() * attribs.get("WaterSpoutAngle") / 100.0)); + + if (attribs.containsKey("WaterSpoutHeight")) + abil.setHeight((int) (abil.getHeight() + abil.getHeight() * attribs.get("WaterSpoutHeight") / 100.0)); + + if (attribs.containsKey("WaterSpoutInterval")) + abil.setInterval((long) (abil.getInterval() + abil.getInterval() * attribs.get("WaterSpoutInterval") / 100.0)); + + //if (attribs.containsKey("WaterSpoutRotation")) + // abil.setRotation(abil.getRotation() + abil.getRotation() * attribs.get("WaterSpoutRotation") / 100.0); + + //if (attribs.containsKey("WaterSpoutTime")) + // abil.setTime((long) (abil.getTime() + abil.getTime() * attribs.get("WaterSpoutTime") / 100.0)); + + return true; + } + else if (ability instanceof WaterSpoutWave) { + WaterSpoutWave abil = (WaterSpoutWave) ability; + + if (attribs.containsKey("WaterSpoutWaveAnimationSpeed")) + abil.setAnimationSpeed(abil.getAnimationSpeed() + abil.getAnimationSpeed() * attribs.get("WaterSpoutWaveAnimationSpeed") / 100.0); + + if (attribs.containsKey("WaterSpoutWaveChargeTime")) + abil.setChargeTime(abil.getChargeTime() + abil.getChargeTime() * attribs.get("WaterSpoutWaveChargeTime") / 100.0); + + if (attribs.containsKey("WaterSpoutWaveCooldown")) + abil.setCooldown((long) (abil.getCooldown() + abil.getCooldown() * attribs.get("WaterSpoutWaveCooldown") / 100.0)); + + if (attribs.containsKey("WaterSpoutWaveFlightDuration")) + abil.setFlightDuration(abil.getFlightDuration() + abil.getFlightDuration() * attribs.get("WaterSpoutWaveFlightDuration") / 100.0); + + //if (attribs.containsKey("WaterSpoutWaveProgressCounter")) + // abil.setProgressCounter((int) (abil.getProgressCounter() + abil.getProgressCounter() * attribs.get("WaterSpoutWaveProgressCounter") / 100.0)); + + if (attribs.containsKey("WaterSpoutWaveRadius")) + abil.setRadius(abil.getRadius() + abil.getRadius() * attribs.get("WaterSpoutWaveRadius") / 100.0); + + if (attribs.containsKey("WaterSpoutWaveSelectRange")) + abil.setSelectRange(abil.getSelectRange() + abil.getSelectRange() * attribs.get("WaterSpoutWaveSelectRange") / 100.0); + + if (attribs.containsKey("WaterSpoutWaveSpeed")) + abil.setSpeed(abil.getSpeed() + abil.getSpeed() * attribs.get("WaterSpoutWaveSpeed") / 100.0); + + //if (attribs.containsKey("WaterSpoutWaveTime")) + // abil.setTime((long) (abil.getTime() + abil.getTime() * attribs.get("WaterSpoutWaveTime") / 100.0)); + + if (attribs.containsKey("WaterSpoutWaveWaveRadius")) + abil.setWaveRadius(abil.getWaveRadius() + abil.getWaveRadius() * attribs.get("WaterSpoutWaveWaveRadius") / 100.0); + + return true; + } + else if (ability instanceof WaterArms) { + WaterArms abil = (WaterArms) ability; + + if (attribs.containsKey("WaterArmsCooldown")) + abil.setCooldown((long) (abil.getCooldown() + abil.getCooldown() * attribs.get("WaterArmsCooldown") / 100.0)); + + //if (attribs.containsKey("WaterArmsFreezeSlot")) + // abil.setFreezeSlot((int) (abil.getFreezeSlot() + abil.getFreezeSlot() * attribs.get("WaterArmsFreezeSlot") / 100.0)); + + //if (attribs.containsKey("WaterArmsInitLength")) + // abil.setInitLength((int) (abil.getInitLength() + abil.getInitLength() * attribs.get("WaterArmsInitLength") / 100.0)); + + //if (attribs.containsKey("WaterArmsLastClickTime")) + // abil.setLastClickTime((long) (abil.getLastClickTime() + abil.getLastClickTime() * attribs.get("WaterArmsLastClickTime") / 100.0)); + + if (attribs.containsKey("WaterArmsLengthReduction")) + abil.setLengthReduction((int) (abil.getLengthReduction() + abil.getLengthReduction() * attribs.get("WaterArmsLengthReduction") / 100.0)); + + if (attribs.containsKey("WaterArmsLightningDamage")) + abil.setLightningDamage(abil.getLightningDamage() + abil.getLightningDamage() * attribs.get("WaterArmsLightningDamage") / 100.0); + + if (attribs.containsKey("WaterArmsMaxIceBlasts")) + abil.setMaxIceBlasts((int) (abil.getMaxIceBlasts() + abil.getMaxIceBlasts() * attribs.get("WaterArmsMaxIceBlasts") / 100.0)); + + if (attribs.containsKey("WaterArmsMaxPunches")) + abil.setMaxPunches((int) (abil.getMaxPunches() + abil.getMaxPunches() * attribs.get("WaterArmsMaxPunches") / 100.0)); + + if (attribs.containsKey("WaterArmsMaxUses")) + abil.setMaxUses((int) (abil.getMaxUses() + abil.getMaxUses() * attribs.get("WaterArmsMaxUses") / 100.0)); + + //if (attribs.containsKey("WaterArmsSelectedSlot")) + // abil.setSelectedSlot((int) (abil.getSelectedSlot() + abil.getSelectedSlot() * attribs.get("WaterArmsSelectedSlot") / 100.0)); + + if (attribs.containsKey("WaterArmsSourceGrabRange")) + abil.setSourceGrabRange((int) (abil.getSourceGrabRange() + abil.getSourceGrabRange() * attribs.get("WaterArmsSourceGrabRange") / 100.0)); + + return true; + } + else if (ability instanceof WaterArmsFreeze) { + WaterArmsFreeze abil = (WaterArmsFreeze) ability; + + //if (attribs.containsKey("WaterArmsFreezeDistanceTravelled")) + // abil.setDistanceTravelled((int) (abil.getDistanceTravelled() + abil.getDistanceTravelled() * attribs.get("WaterArmsFreezeDistanceTravelled") / 100.0)); + + if (attribs.containsKey("WaterArmsFreezeIceDamage")) + abil.setIceDamage(abil.getIceDamage() + abil.getIceDamage() * attribs.get("WaterArmsFreezeIceDamage") / 100.0); + + if (attribs.containsKey("WaterArmsFreezeIceRange")) + abil.setIceRange((int) (abil.getIceRange() + abil.getIceRange() * attribs.get("WaterArmsFreezeIceRange") / 100.0)); + + if (attribs.containsKey("WaterArmsFreezeUsageCooldown")) + abil.setUsageCooldown((long) (abil.getUsageCooldown() + abil.getUsageCooldown() * attribs.get("WaterArmsFreezeUsageCooldown") / 100.0)); + + return true; + } + else if (ability instanceof WaterArmsSpear) { + WaterArmsSpear abil = (WaterArmsSpear) ability; + + //if (attribs.containsKey("WaterArmsSpearDistanceTravelled")) + // abil.setDistanceTravelled((int) (abil.getDistanceTravelled() + abil.getDistanceTravelled() * attribs.get("WaterArmsSpearDistanceTravelled") / 100.0)); + + if (attribs.containsKey("WaterArmsSpearDuration")) + abil.setSpearDuration((long) (abil.getSpearDuration() + abil.getSpearDuration() * attribs.get("WaterArmsSpearDuration") / 100.0)); + + if (attribs.containsKey("WaterArmsSpearDurationFullMoon")) + abil.setSpearDurationFullMoon((long) (abil.getSpearDurationFullMoon() + abil.getSpearDurationFullMoon() * attribs.get("WaterArmsSpearDurationFullMoon") / 100.0)); + + if (attribs.containsKey("WaterArmsSpearDurationNight")) + abil.setSpearDurationNight((long) (abil.getSpearDurationNight() + abil.getSpearDurationNight() * attribs.get("WaterArmsSpearDurationNight") / 100.0)); + + if (attribs.containsKey("WaterArmsSpearLength")) + abil.setSpearLength((int) (abil.getSpearLength() + abil.getSpearLength() * attribs.get("WaterArmsSpearLength") / 100.0)); + + if (attribs.containsKey("WaterArmsSpearRange")) + abil.setSpearRange((int) (abil.getSpearRange() + abil.getSpearRange() * attribs.get("WaterArmsSpearRange") / 100.0)); + + if (attribs.containsKey("WaterArmsSpearRangeFullMoon")) + abil.setSpearRangeFullMoon((int) (abil.getSpearRangeFullMoon() + abil.getSpearRangeFullMoon() * attribs.get("WaterArmsSpearRangeFullMoon") / 100.0)); + + if (attribs.containsKey("WaterArmsSpearRangeNight")) + abil.setSpearRangeNight((int) (abil.getSpearRangeNight() + abil.getSpearRangeNight() * attribs.get("WaterArmsSpearRangeNight") / 100.0)); + + if (attribs.containsKey("WaterArmsSpearSphere")) + abil.setSpearSphere((int) (abil.getSpearSphere() + abil.getSpearSphere() * attribs.get("WaterArmsSpearSphere") / 100.0)); + + if (attribs.containsKey("WaterArmsSpearSphereFullMoon")) + abil.setSpearSphereFullMoon((int) (abil.getSpearSphereFullMoon() + abil.getSpearSphereFullMoon() * attribs.get("WaterArmsSpearSphereFullMoon") / 100.0)); + + if (attribs.containsKey("WaterArmsSpearSphereNight")) + abil.setSpearSphereNight((int) (abil.getSpearSphereNight() + abil.getSpearSphereNight() * attribs.get("WaterArmsSpearSphereNight") / 100.0)); + + if (attribs.containsKey("WaterArmsSpearUsageCooldown")) + abil.setUsageCooldown((long) (abil.getUsageCooldown() + abil.getUsageCooldown() * attribs.get("WaterArmsSpearUsageCooldown") / 100.0)); + + return true; + } + else if (ability instanceof WaterArmsWhip) { + WaterArmsWhip abil = (WaterArmsWhip) ability; + + //if (attribs.containsKey("WaterArmsWhipActiveLength")) + // abil.setActiveLength((int) (abil.getActiveLength() + abil.getActiveLength() * attribs.get("WaterArmsWhipActiveLength") / 100.0)); + + if (attribs.containsKey("WaterArmsWhipGrabDuration")) + abil.setGrabDuration((long) (abil.getGrabDuration() + abil.getGrabDuration() * attribs.get("WaterArmsWhipGrabDuration") / 100.0)); + + // if (attribs.containsKey("WaterArmsWhipInitLength")) + // abil.setInitLength((int) (abil.getInitLength() + abil.getInitLength() * attribs.get("WaterArmsWhipInitLength") / 100.0)); + + //if (attribs.containsKey("WaterArmsWhipPlayerHealth")) + // abil.setPlayerHealth(abil.getPlayerHealth() + abil.getPlayerHealth() * attribs.get("WaterArmsWhipPlayerHealth") / 100.0); + + if (attribs.containsKey("WaterArmsWhipPullMultiplier")) + abil.setPullMultiplier(abil.getPullMultiplier() + abil.getPullMultiplier() * attribs.get("WaterArmsWhipPullMultiplier") / 100.0); + + if (attribs.containsKey("WaterArmsWhipPunchLength")) + abil.setPunchLength((int) (abil.getPunchLength() + abil.getPunchLength() * attribs.get("WaterArmsWhipPunchLength") / 100.0)); + + if (attribs.containsKey("WaterArmsWhipPunchLengthFullMoon")) + abil.setPunchLengthFullMoon((int) (abil.getPunchLengthFullMoon() + abil.getPunchLengthFullMoon() * attribs.get("WaterArmsWhipPunchLengthFullMoon") / 100.0)); + + if (attribs.containsKey("WaterArmsWhipPunchLengthNight")) + abil.setPunchLengthNight((int) (abil.getPunchLengthNight() + abil.getPunchLengthNight() * attribs.get("WaterArmsWhipPunchLengthNight") / 100.0)); + + //if (attribs.containsKey("WaterArmsWhipTime")) + // abil.setTime((long) (abil.getTime() + abil.getTime() * attribs.get("WaterArmsWhipTime") / 100.0)); + + if (attribs.containsKey("WaterArmsWhipUsageCooldown")) + abil.setUsageCooldown((long) (abil.getUsageCooldown() + abil.getUsageCooldown() * attribs.get("WaterArmsWhipUsageCooldown") / 100.0)); + + if (attribs.containsKey("WaterArmsWhipWhipLength")) + abil.setWhipLength((int) (abil.getWhipLength() + abil.getWhipLength() * attribs.get("WaterArmsWhipWhipLength") / 100.0)); + + if (attribs.containsKey("WaterArmsWhipWhipLengthFullMoon")) + abil.setWhipLengthFullMoon((int) (abil.getWhipLengthFullMoon() + abil.getWhipLengthFullMoon() * attribs.get("WaterArmsWhipWhipLengthFullMoon") / 100.0)); + + if (attribs.containsKey("WaterArmsWhipWhipLengthNight")) + abil.setWhipLengthNight((int) (abil.getWhipLengthNight() + abil.getWhipLengthNight() * attribs.get("WaterArmsWhipWhipLengthNight") / 100.0)); + + if (attribs.containsKey("WaterArmsWhipWhipLengthWeak")) + abil.setWhipLengthWeak((int) (abil.getWhipLengthWeak() + abil.getWhipLengthWeak() * attribs.get("WaterArmsWhipWhipLengthWeak") / 100.0)); + + if (attribs.containsKey("WaterArmsWhipWhipSpeed")) + abil.setWhipSpeed((int) (abil.getWhipSpeed() + abil.getWhipSpeed() * attribs.get("WaterArmsWhipWhipSpeed") / 100.0)); + + return true; + } + else if (ability instanceof Bloodbending) { + Bloodbending abil = (Bloodbending) ability; + + if (attribs.containsKey("BloodbendingCooldown")) + abil.setCooldown((long) (abil.getCooldown() + abil.getCooldown() * attribs.get("BloodbendingCooldown") / 100.0)); + + if (attribs.containsKey("BloodbendingDuration")) + abil.setDuration((long) (abil.getDuration() + abil.getDuration() * attribs.get("BloodbendingDuration") / 100.0)); + + if (attribs.containsKey("BloodbendingKnockback")) + abil.setKnockback(abil.getKnockback() + abil.getKnockback() * attribs.get("BloodbendingKnockback") / 100.0); + + if (attribs.containsKey("BloodbendingRange")) + abil.setRange((int) (abil.getRange() + abil.getRange() * attribs.get("BloodbendingRange") / 100.0)); + + //if (attribs.containsKey("BloodbendingTime")) + // abil.setTime((long) (abil.getTime() + abil.getTime() * attribs.get("BloodbendingTime") / 100.0)); + + return true; + } + else if (ability instanceof HealingWaters) { + //HealingWaters abil = (HealingWaters) ability; + + return true; + } + else if (ability instanceof IceBlast) { + IceBlast abil = (IceBlast) ability; + + if (attribs.containsKey("IceBlastCollisionRadius")) + abil.setCollisionRadius(abil.getCollisionRadius() + abil.getCollisionRadius() * attribs.get("IceBlastCollisionRadius") / 100.0); + + if (attribs.containsKey("IceBlastCooldown")) + abil.setCooldown((long) (abil.getCooldown() + abil.getCooldown() * attribs.get("IceBlastCooldown") / 100.0)); + + if (attribs.containsKey("IceBlastDeflectRange")) + abil.setDeflectRange(abil.getDeflectRange() + abil.getDeflectRange() * attribs.get("IceBlastDeflectRange") / 100.0); + + if (attribs.containsKey("IceBlastInterval")) + abil.setInterval((long) (abil.getInterval() + abil.getInterval() * attribs.get("IceBlastInterval") / 100.0)); + + if (attribs.containsKey("IceBlastRange")) + abil.setRange(abil.getRange() + abil.getRange() * attribs.get("IceBlastRange") / 100.0); + + //if (attribs.containsKey("IceBlastTime")) + // abil.setTime((long) (abil.getTime() + abil.getTime() * attribs.get("IceBlastTime") / 100.0)); + + return true; + } + else if (ability instanceof IceSpikeBlast) { + IceSpikeBlast abil = (IceSpikeBlast) ability; + + if (attribs.containsKey("IceSpikeCollisionRadius")) + abil.setCollisionRadius(abil.getCollisionRadius() + abil.getCollisionRadius() * attribs.get("IceSpikeCollisionRadius") / 100.0); + + if (attribs.containsKey("IceSpikeCooldown")) + abil.setCooldown((long) (abil.getCooldown() + abil.getCooldown() * attribs.get("IceSpikeCooldown") / 100.0)); + + if (attribs.containsKey("IceSpikeDeflectRange")) + abil.setDeflectRange(abil.getDeflectRange() + abil.getDeflectRange() * attribs.get("IceSpikeDeflectRange") / 100.0); + + if (attribs.containsKey("IceSpikeInterval")) + abil.setInterval((long) (abil.getInterval() + abil.getInterval() * attribs.get("IceSpikeInterval") / 100.0)); + + if (attribs.containsKey("IceSpikeRange")) + abil.setRange(abil.getRange() + abil.getRange() * attribs.get("IceSpikeRange") / 100.0); + + if (attribs.containsKey("IceSpikeSlowCooldown")) + abil.setSlowCooldown((long) (abil.getSlowCooldown() + abil.getSlowCooldown() * attribs.get("IceSpikeSlowCooldown") / 100.0)); + + if (attribs.containsKey("IceSpikeSlowDuration")) + abil.setSlowDuration((int) (abil.getSlowDuration() + abil.getSlowDuration() * attribs.get("IceSpikeSlowDuration") / 100.0)); + + if (attribs.containsKey("IceSpikeSlowPotency")) + abil.setSlowPotency((int) (abil.getSlowPotency() + abil.getSlowPotency() * attribs.get("IceSpikeSlowPotency") / 100.0)); + + //if (attribs.containsKey("IceSpikeTime")) + // abil.setTime((long) (abil.getTime() + abil.getTime() * attribs.get("IceSpikeTime") / 100.0)); + + return true; + } + else if (ability instanceof IceSpikePillar) { + IceSpikePillar abil = (IceSpikePillar) ability; + + if (attribs.containsKey("IceSpikePillarCooldown")) + abil.setCooldown((long) (abil.getCooldown() + abil.getCooldown() * attribs.get("IceSpikePillarCooldown") / 100.0)); + + if (attribs.containsKey("IceSpikePillarHeight")) + abil.setHeight((int) (abil.getHeight() + abil.getHeight() * attribs.get("IceSpikePillarHeight") / 100.0)); + + if (attribs.containsKey("IceSpikePillarInterval")) + abil.setInterval((long) (abil.getInterval() + abil.getInterval() * attribs.get("IceSpikePillarInterval") / 100.0)); + + //if (attribs.containsKey("IceSpikePillarProgress")) + // abil.setProgress((int) (abil.getProgress() + abil.getProgress() * attribs.get("IceSpikePillarProgress") / 100.0)); + + if (attribs.containsKey("IceSpikePillarRange")) + abil.setRange(abil.getRange() + abil.getRange() * attribs.get("IceSpikePillarRange") / 100.0); + + //if (attribs.containsKey("IceSpikePillarRemoveTimer")) + // abil.setRemoveTimer((long) (abil.getRemoveTimer() + abil.getRemoveTimer() * attribs.get("IceSpikePillarRemoveTimer") / 100.0)); + + //if (attribs.containsKey("IceSpikePillarRemoveTimestamp")) + // abil.setRemoveTimestamp((long) (abil.getRemoveTimestamp() + abil.getRemoveTimestamp() * attribs.get("IceSpikePillarRemoveTimestamp") / 100.0)); + + if (attribs.containsKey("IceSpikePillarSlowCooldown")) + abil.setSlowCooldown((long) (abil.getSlowCooldown() + abil.getSlowCooldown() * attribs.get("IceSpikePillarSlowCooldown") / 100.0)); + + if (attribs.containsKey("IceSpikePillarSlowDuration")) + abil.setSlowDuration((int) (abil.getSlowDuration() + abil.getSlowDuration() * attribs.get("IceSpikePillarSlowDuration") / 100.0)); + + if (attribs.containsKey("IceSpikePillarSlowPower")) + abil.setSlowPower((int) (abil.getSlowPower() + abil.getSlowPower() * attribs.get("IceSpikePillarSlowPower") / 100.0)); + + if (attribs.containsKey("IceSpikePillarSpeed")) + abil.setSpeed(abil.getSpeed() + abil.getSpeed() * attribs.get("IceSpikePillarSpeed") / 100.0); + + //if (attribs.containsKey("IceSpikePillarTime")) + // abil.setTime((long) (abil.getTime() + abil.getTime() * attribs.get("IceSpikePillarTime") / 100.0)); + + return true; + } + else if (ability instanceof IceSpikePillarField) { + IceSpikePillarField abil = (IceSpikePillarField) ability; + + if (attribs.containsKey("IceSpikePillarFieldCooldown")) + abil.setCooldown((long) (abil.getCooldown() + abil.getCooldown() * attribs.get("IceSpikePillarFieldCooldown") / 100.0)); + + if (attribs.containsKey("IceSpikePillarFieldNumberOfSpikes")) + abil.setNumberOfSpikes((int) (abil.getNumberOfSpikes() + abil.getNumberOfSpikes() * attribs.get("IceSpikePillarFieldNumberOfSpikes") / 100.0)); + + if (attribs.containsKey("IceSpikePillarFieldRadius")) + abil.setRadius(abil.getRadius() + abil.getRadius() * attribs.get("IceSpikePillarFieldRadius") / 100.0); + + return true; + } + else if (ability instanceof PhaseChange) { + PhaseChange abil = (PhaseChange) ability; + + if (attribs.containsKey("PhaseChangeDepth")) + abil.setDepth((int) (abil.getDepth() + abil.getDepth() * attribs.get("PhaseChangeDepth") / 100.0)); + + if (attribs.containsKey("PhaseChangeFreezeControlRadius")) + abil.setFreezeControlRadius((int) (abil.getFreezeControlRadius() + abil.getFreezeControlRadius() * attribs.get("PhaseChangeFreezeControlRadius") / 100.0)); + + if (attribs.containsKey("PhaseChangeSourceRange")) + abil.setSourceRange((int) (abil.getSourceRange() + abil.getSourceRange() * attribs.get("PhaseChangeSourceRange") / 100.0)); + + return true; + } + else if (ability instanceof PlantRegrowth) { + PlantRegrowth abil = (PlantRegrowth) ability; + + if (attribs.containsKey("PlantRegrowthRegrowTime")) + abil.setRegrowTime((long) (abil.getRegrowTime() + abil.getRegrowTime() * attribs.get("PlantRegrowthRegrowTime") / 100.0)); + + //if (attribs.containsKey("PlantRegrowthTime")) + // abil.setTime((long) (abil.getTime() + abil.getTime() * attribs.get("PlantRegrowthTime") / 100.0)); + + return true; + } + else if (ability instanceof IceBullet) { + IceBullet abil = (IceBullet) ability; + + if (attribs.containsKey("IceBulletAnimationSpeed")) + abil.setAnimationSpeed(abil.getAnimationSpeed() + abil.getAnimationSpeed() * attribs.get("IceBulletAnimationSpeed") / 100.0); + + if (attribs.containsKey("IceBulletCooldown")) + abil.setCooldown((long) (abil.getCooldown() + abil.getCooldown() * attribs.get("IceBulletCooldown") / 100.0)); + + //if (attribs.containsKey("IceBulletLeftClicks")) + // abil.setLeftClicks((int) (abil.getLeftClicks() + abil.getLeftClicks() * attribs.get("IceBulletLeftClicks") / 100.0)); + + if (attribs.containsKey("IceBulletMaxShots")) + abil.setMaxShots(abil.getMaxShots() + abil.getMaxShots() * attribs.get("IceBulletMaxShots") / 100.0); + + if (attribs.containsKey("IceBulletRadius")) + abil.setRadius(abil.getRadius() + abil.getRadius() * attribs.get("IceBulletRadius") / 100.0); + + if (attribs.containsKey("IceBulletRange")) + abil.setRange(abil.getRange() + abil.getRange() * attribs.get("IceBulletRange") / 100.0); + + //if (attribs.containsKey("IceBulletRightClicks")) + // abil.setRightClicks((int) (abil.getRightClicks() + abil.getRightClicks() * attribs.get("IceBulletRightClicks") / 100.0)); + + if (attribs.containsKey("IceBulletShootTime")) + abil.setShootTime(abil.getShootTime() + abil.getShootTime() * attribs.get("IceBulletShootTime") / 100.0); + + //if (attribs.containsKey("IceBulletShots")) + // abil.setShots(abil.getShots() + abil.getShots() * attribs.get("IceBulletShots") / 100.0); + + if (attribs.containsKey("IceBulletSpeed")) + abil.setSpeed(abil.getSpeed() + abil.getSpeed() * attribs.get("IceBulletSpeed") / 100.0); + + //if (attribs.containsKey("IceBulletTime")) + // abil.setTime((long) (abil.getTime() + abil.getTime() * attribs.get("IceBulletTime") / 100.0)); + + return true; + } + else if (ability instanceof IceWave) { + IceWave abil = (IceWave) ability; + + if (attribs.containsKey("IceWaveCooldown")) + abil.setCooldown((long) (abil.getCooldown() + abil.getCooldown() * attribs.get("IceWaveCooldown") / 100.0)); + + return true; + } + + return false; + } +} diff --git a/src/com/projectkorra/items/attribute/Action.java b/src/main/java/com/projectkorra/items/attribute/Action.java similarity index 100% rename from src/com/projectkorra/items/attribute/Action.java rename to src/main/java/com/projectkorra/items/attribute/Action.java diff --git a/src/com/projectkorra/items/attribute/Attribute.java b/src/main/java/com/projectkorra/items/attribute/Attribute.java similarity index 87% rename from src/com/projectkorra/items/attribute/Attribute.java rename to src/main/java/com/projectkorra/items/attribute/Attribute.java index 7246b87..d4e217d 100644 --- a/src/com/projectkorra/items/attribute/Attribute.java +++ b/src/main/java/com/projectkorra/items/attribute/Attribute.java @@ -3,12 +3,13 @@ import com.projectkorra.projectkorra.Element; import java.util.ArrayList; -import java.util.concurrent.ConcurrentHashMap; +import java.util.List; +import java.util.Map; public class Attribute { private String name; private String desc; - private ArrayList values; + private List values; private Element element; private double duration, time; private int benefit; @@ -31,7 +32,7 @@ public Attribute(String name, String desc, Element element, int benefit) { this.benefit = benefit; this.duration = 0; this.time = 0; - values = new ArrayList(); + values = new ArrayList<>(); } /** @@ -46,9 +47,7 @@ public Attribute(Attribute other) { this.duration = other.duration; this.element = other.element; this.benefit = other.benefit; - this.values = new ArrayList(); - for (String str : other.values) - this.values.add(new String(str)); + this.values = new ArrayList<>(other.values); } public Attribute(String name, String desc, Element element) { @@ -115,7 +114,7 @@ public void setDesc(String desc) { this.desc = desc; } - public ArrayList getValues() { + public List getValues() { return values; } @@ -135,7 +134,7 @@ public double getValueAsDouble() { } } - public void setValues(ArrayList values) { + public void setValues(List values) { this.values = values; } @@ -145,7 +144,7 @@ public void setValues(ArrayList values) { * @param val the value of the attribute */ public void setValues(double val) { - this.values = new ArrayList(); + this.values = new ArrayList<>(); values.add(val + ""); } @@ -181,11 +180,9 @@ public boolean getBooleanValue(String name) { if (!this.name.equalsIgnoreCase(name)) return false; try { - boolean val = Integer.parseInt(this.values.get(0)) != 0; - return val; - } - catch (Exception e) { + return Integer.parseInt(this.values.get(0)) != 0; } + catch (NumberFormatException ignored) {} return false; } @@ -197,14 +194,13 @@ public boolean getBooleanValue(String name) { * @param map containing attribute names and values * @return true if name is in map and it's value isn't 0 */ - public static boolean getBooleanValue(String name, ConcurrentHashMap map) { + public static boolean getBooleanValue(String name, Map map) { boolean val = map.containsKey(name); if (val) { try { val = map.get(name).intValue() != 0; } - catch (Exception e) { - } + catch (Exception ignored) {} } return val; } diff --git a/src/main/java/com/projectkorra/items/attribute/AttributeList.java b/src/main/java/com/projectkorra/items/attribute/AttributeList.java new file mode 100644 index 0000000..cea1027 --- /dev/null +++ b/src/main/java/com/projectkorra/items/attribute/AttributeList.java @@ -0,0 +1,587 @@ +package com.projectkorra.items.attribute; + +import com.projectkorra.projectkorra.Element; + +import org.bukkit.ChatColor; + +import java.util.ArrayList; + +public class AttributeList { + public static final double AIR_GLIDE_SPEED = 0.6; + public static final double AIR_GLIDE_FALL = -0.12; + public static final String CHARGES_STR = ChatColor.GOLD + "Charges: "; + public static final String SNEAK_CHARGES_STR = ChatColor.GOLD + "SneakCharges: "; + public static final String CLICK_CHARGES_STR = ChatColor.GOLD + "ClickCharges: "; + + public static final ArrayList ATTRIBUTES = new ArrayList() { + private static final long serialVersionUID = 1L; + { + // MISC + //add(new Attribute("GrapplingHook", "Lets the user shoot out a grappling hook by left clicking. They can then left click to launch themselves toward the destination, or sneak to slowly move to the destination.")); + add(new Attribute("ParticleEffects", "Plays a particle effect around a player whenever they use an ability. " + "Uses the form 'ParticleEffect: NAME::::', " + "amount (1 - inf), radius (0 - 100), duration (1 - inf), and speed (0 - 100) are optional. " + "Click http://pastebin.com/Trbh34WG to see the list of available particles. " + "For example: 'ParticleEffects: flame:5:100:10:100")); + + add(new Attribute("AllowFromInventory", "This item will work from the players inventory, even if it is not being held or worn.")); + add(new Attribute("RequireElement", "The user must have one of these elements to use this item. Works with Air, Water, Earth, Fire, Chi, Flight, Spiritual, Blood, Healing, Ice, Plant, Metal, Sand, Lava, Combustion, and Lightning. For example: 'RequireElement: Fire, Air, Chi'")); + add(new Attribute("RequireWorld", "The user must be located in one of these specific worlds to use this item. For example: 'RequireWorld: bendingworld, bendingarena, bendingrpg'")); + add(new Attribute("RequirePermission", "The user must have one of these permissions to use this item. For example: 'RequirePermission: bending.admin.*, essentials.command.give'")); + + add(new Attribute("Air", "improves all Air stats")); + add(new Attribute("Water", "improves all Water stats")); + add(new Attribute("Earth", "improves all Earth stats")); + add(new Attribute("Fire", "improves all Fire stats")); + add(new Attribute("Chi", "improves all Chi stats")); + + add(new Attribute("WaterSource", "acts as a temporary water source for water abilities")); + + add(new Attribute("Effects", "adds potion and bending effects whenever the player clicks, sneaks, or consumes the item. For example: Effects: JUMP:1:30, BlazeRange:25:30 would add Jump 1 and increase Blaze range by 25% for 30 seconds.")); + add(new Attribute("ClickEffects", "adds potion and bending effects when the player clicks")); + add(new Attribute("SneakEffects", "adds potion and bending effects when the player sneaks")); + add(new Attribute("ConsumeEffects", "adds potion and bending effects when this item is consumed")); + + add(new Attribute("Charges", "the number of charges remaining, charges are decreased by both clicking and sneaking, and an item stops working if it runs out of charges")); + add(new Attribute("ClickCharges", "charges are only decreased by clicking")); + add(new Attribute("SneakCharges", "charges are only decreased by sneaking")); + add(new Attribute("DestroyAfterCharges", "the item will be destroyed when the charges run out")); + add(new Attribute("IgnoreDestroyMessage", "the player will not receive a message that the item was destroyed when the charges run out")); + + add(new Attribute("WearOnly", "the item will only work if it is being worn as armor")); + add(new Attribute("HoldOnly", "the item will only work if it is being held")); + add(new Attribute("LeatherColor", "gives leather armor a specific color, specified as R,G,B. For example, LeatherColor:255,0,0 would be red armor")); + + add(new Attribute("AirGlide", "(true/false) allows an Airbender to glide through the air by sneaking")); + add(new Attribute("AirGlideSpeed", "modifies the air gliding speed", Element.AIR)); + add(new Attribute("AirGlideFallSpeed", "modifies the air gliding fall speed", Element.AIR, -1)); + add(new Attribute("AirGlideAutomatic", "(true/false) gliding will start the moment that the user switches to the slot, they don't have to sneak")); + + // AIR + // AirBlast + add(new Attribute("AirBlastCooldown", "cooldown", Element.AIR, -1)); + add(new Attribute("AirBlastDamage", "damage", Element.AIR)); + add(new Attribute("AirBlastParticles", "particles", Element.AIR)); + add(new Attribute("AirBlastPushFactor", "force", Element.AIR)); + add(new Attribute("AirBlastPushFactorForOthers", "force against others", Element.AIR)); + add(new Attribute("AirBlastRadius", "radius", Element.AIR)); + add(new Attribute("AirBlastRange", "range", Element.AIR)); + add(new Attribute("AirBlastSpeed", "speed", Element.AIR)); + add(new Attribute("AirBlastSpeedFactor", "speed factor", Element.AIR)); + + // AirBurst + add(new Attribute("AirBurstBlastAnglePhi", "phi angle", Element.AIR)); + add(new Attribute("AirBurstBlastAngleTheta", "theta angle", Element.AIR)); + add(new Attribute("AirBurstChargeTime", "charge time", Element.AIR)); + add(new Attribute("AirBurstDamage", "damage", Element.AIR)); + add(new Attribute("AirBurstFallThreshold", "fall threshold", Element.AIR)); + add(new Attribute("AirBurstPushFactor", "force", Element.AIR)); + + // AirBubble NOT EXISTS IN NEW VERSIONS OF PK + //add(new Attribute("AirBubbleRadius", "radius", Element.AIR)); + + // AirScooter + add(new Attribute("AirScooterCooldown", "cooldown", Element.AIR, -1)); + add(new Attribute("AirScooterInterval", "interval", Element.AIR)); + add(new Attribute("AirScooterMaxHeightFromGround", "max height", Element.AIR)); + add(new Attribute("AirScooterRadius", "radius", Element.AIR)); + add(new Attribute("AirScooterSpeed", "speed", Element.AIR)); + + // AirShield + add(new Attribute("AirShieldMaxRadius", "max radius", Element.AIR)); + add(new Attribute("AirShieldParticles", "particles", Element.AIR)); + add(new Attribute("AirShieldRadius", "radius", Element.AIR)); + add(new Attribute("AirShieldSpeed", "speed", Element.AIR)); + add(new Attribute("AirShieldStreams", "streams", Element.AIR)); + + // AirSpout + add(new Attribute("AirSpoutAngle", "angle", Element.AIR)); + add(new Attribute("AirSpoutAnimTime", "anim time", Element.AIR)); + add(new Attribute("AirSpoutCooldown", "cooldown", Element.AIR, -1)); + add(new Attribute("AirSpoutHeight", "height", Element.AIR)); + add(new Attribute("AirSpoutInterval", "interval", Element.AIR)); + + // AirSuction + add(new Attribute("AirSuctionCooldown", "cooldown", Element.AIR, -1)); + add(new Attribute("AirSuctionPushFactor", "knockback force", Element.AIR)); + add(new Attribute("AirSuctionRadius", "affecting radius", Element.AIR)); + add(new Attribute("AirSuctionRange", "range", Element.AIR)); + add(new Attribute("AirSuctionSpeed", "travel speed", Element.AIR)); + + // AirSwipe + add(new Attribute("AirSwipeArc", "arc width, Warning! hitting too many monsters at a time with airswipe can overload your server", Element.AIR)); + add(new Attribute("AirSwipeCooldown", "cooldown", Element.AIR, -1)); + add(new Attribute("AirSwipeDamage", "damage", Element.AIR)); + add(new Attribute("AirSwipeMaxChargeFactor", "maximum possible charge damage", Element.AIR)); + add(new Attribute("AirSwipeMaxChargeTime", "maximum charge time, lower is stronger", Element.AIR, -1)); + add(new Attribute("AirSwipeParticles", "particles", Element.AIR)); + add(new Attribute("AirSwipePushFactor", "knockback force", Element.AIR)); + add(new Attribute("AirSwipeRadius", "radius, Warning! hitting too many monsters at a time with airswipe can overload your server", Element.AIR)); + add(new Attribute("AirSwipeRange", "range", Element.AIR)); + add(new Attribute("AirSwipeSpeed", "travel speed", Element.AIR)); + //add(new Attribute("AirSwipeStepSize", "step size", Element.AIR)); + + // Suffocate + add(new Attribute("SuffocateAnimationSpeed", "animation speed", Element.AIR)); + add(new Attribute("SuffocateBlind", "blind", Element.AIR)); + add(new Attribute("SuffocateBlindDelay", "blind delay", Element.AIR)); + add(new Attribute("SuffocateBlindRepeat", "blind repeat", Element.AIR)); + add(new Attribute("SuffocateChargeTime", "charge time", Element.AIR)); + add(new Attribute("SuffocateConstantAimRadius", "aim radius", Element.AIR)); + add(new Attribute("SuffocateCooldown", "charge time", Element.AIR, -1)); + add(new Attribute("SuffocateDamage", "damage", Element.AIR)); + add(new Attribute("SuffocateDamageDelay", "damage delay", Element.AIR)); + add(new Attribute("SuffocateDamageRepeat", "damage repeat", Element.AIR)); + add(new Attribute("SuffocateRadius", "radius", Element.AIR)); + add(new Attribute("SuffocateRange", "range", Element.AIR)); + add(new Attribute("SuffocateSlow", "slow", Element.AIR)); + add(new Attribute("SuffocateSlowDelay", "slow delay", Element.AIR)); + add(new Attribute("SuffocateSlowRepeat", "slow repeat", Element.AIR)); + + // Tornado + add(new Attribute("TornadoMaxHeight", "height", Element.AIR)); + add(new Attribute("TornadoNPCPushFactor", "knockback force gainst mobs", Element.AIR)); + add(new Attribute("TornadoNumberOfStreams", "number of streams", Element.AIR)); + add(new Attribute("TornadoPlayerPushFactor", "knockback force against players", Element.AIR)); + add(new Attribute("TornadoRadius", "radius", Element.AIR)); + add(new Attribute("TornadoRange", "maximum targettable range", Element.AIR)); + add(new Attribute("TornadoSpeed", "speed", Element.AIR)); + + // AirStream + add(new Attribute("AirStreamCooldown", "cooldown", Element.AIR, -1)); + add(new Attribute("AirStreamEntityCarryDuration", "duration", Element.AIR)); + add(new Attribute("AirStreamMaxEntityHeight", "max height", Element.AIR)); + add(new Attribute("AirStreamRange", "range", Element.AIR)); + add(new Attribute("AirStreamSpeed", "speed", Element.AIR)); + + // AirSweep + add(new Attribute("AirSweepDamage", "damage", Element.AIR)); + add(new Attribute("AirSweepKnockback", "knockback", Element.AIR)); + add(new Attribute("AirSweepRange", "range", Element.AIR)); + add(new Attribute("AirSweepSpeed", "speed", Element.AIR)); + + // Twister + add(new Attribute("TwisterCooldown", "cooldown", Element.AIR, -1)); + + // WATER + // OctopusForm + add(new Attribute("OctopusFormAttackRange", "attack range", Element.WATER)); + add(new Attribute("OctopusFormCooldown", "cooldown", Element.WATER, -1)); + add(new Attribute("OctopusFormDamage", "damage", Element.WATER)); + add(new Attribute("OctopusFormInterval", "animation interval, a lower interval is faster", Element.WATER, -1)); + add(new Attribute("OctopusFormKnockback", "knockback force", Element.WATER)); + add(new Attribute("OctopusFormRadius", "radius", Element.WATER)); + add(new Attribute("OctopusFormRange", "range", Element.WATER)); + + // Surge + add(new Attribute("SurgeWallCooldown", "cooldown", Element.WATER, -1)); + add(new Attribute("SurgeWallInterval", "interval", Element.WATER)); + add(new Attribute("SurgeWallRadius", "radius", Element.WATER)); + add(new Attribute("SurgeWallRange", "the distance that the wall is away from the player", Element.WATER)); + + add(new Attribute("SurgeWaveCooldown", "cooldown", Element.WATER, -1)); + add(new Attribute("SurgeWaveInterval", "interval", Element.WATER)); + add(new Attribute("SurgeWaveMaxFreezeRadius", "the size of the iceberg that covers the enemy", Element.WATER)); + add(new Attribute("SurgeWaveMaxRadius", "size of the wave", Element.WATER)); + add(new Attribute("SurgeWaveKnockback", "knockback force", Element.WATER)); + add(new Attribute("SurgeWaveRange", "range", Element.WATER)); + add(new Attribute("SurgeWaveKnockup", "knockup force", Element.WATER)); + + // Torrent + add(new Attribute("TorrentCooldown", "Torrent cooldown", Element.WATER, -1)); + add(new Attribute("TorrentDeflectDamage", "damage caused by enemies hitting the torrent while it is being circled around the player", Element.WATER)); + add(new Attribute("TorrentDamage", "Torrent Stream damage", Element.WATER)); + add(new Attribute("TorrentInterval", "Torrent interval", Element.WATER)); + add(new Attribute("TorrentMaxLayer", "Torrent max layer", Element.WATER)); + add(new Attribute("TorrentMaxUpwardForce", "Torrent max upward force", Element.WATER)); + add(new Attribute("TorrentPush", "Torrent Push", Element.WATER)); + add(new Attribute("TorrentRadius", "Torrent radius", Element.WATER)); + add(new Attribute("TorrentRange", "Torrent Stream range", Element.WATER)); + add(new Attribute("TorrentSelectRange", "Torrent select range", Element.WATER)); + + add(new Attribute("TorrentWaveCooldown", "Torrent wave cooldown", Element.WATER, -1)); + add(new Attribute("TorrentWaveGrowSpeed", "Torrent wave grow speed", Element.WATER)); + add(new Attribute("TorrentWaveInterval", "Torrent wave interval", Element.WATER)); + add(new Attribute("TorrentWaveKnockback", "knockback force", Element.WATER)); + add(new Attribute("TorrentWaveMaxHeight", "max height", Element.WATER)); + add(new Attribute("TorrentWaveMaxRadius", "max radius", Element.WATER)); + //add(new Attribute("TorrentWaveHeight", "height")); + + // WaterBubble + //add(new Attribute("WaterBubbleRadius", "radius", Element.WATER)); + + // WaterManipulation + add(new Attribute("WaterManipulationCollisionRadius", "collision radius", Element.WATER)); + add(new Attribute("WaterManipulationCooldown", "cooldown", Element.WATER, -1)); + add(new Attribute("WaterManipulationDamage", "damage", Element.WATER)); + add(new Attribute("WaterManipulationDeflectRange", "deflect range", Element.WATER)); + add(new Attribute("WaterManipulationDispelRange", "dispel range", Element.WATER)); + add(new Attribute("WaterManipulationInterval", "interval", Element.WATER)); + add(new Attribute("WaterManipulationPushFactor", "knockback force", Element.WATER)); + add(new Attribute("WaterManipulationRange", "range, you must click while the ability is in motion to extend the range", Element.WATER)); + add(new Attribute("WaterManipulationSelectRange", "select range", Element.WATER)); + add(new Attribute("WaterManipulationSpeed", "speed", Element.WATER)); + + // WaterSpout + add(new Attribute("WaterSpoutHeight", "height", Element.WATER)); + add(new Attribute("WaterSpoutInterval", "interval", Element.WATER)); + + add(new Attribute("WaterSpoutWaveAnimationSpeed", "initial chargetime", Element.WATER)); + add(new Attribute("WaterSpoutWaveChargeTime", "initial chargetime", Element.WATER, -1)); + add(new Attribute("WaterSpoutWaveCooldown", "cooldown", Element.WATER, -1)); + add(new Attribute("WaterSpoutWaveDamage", "damage", Element.WATER)); + add(new Attribute("WaterSpoutWaveFlightDuration", "total flight duration", Element.WATER)); + add(new Attribute("WaterSpoutWaveRadius", "radius", Element.WATER)); + add(new Attribute("WaterSpoutWaveSelectRange", "range", Element.WATER)); + add(new Attribute("WaterSpoutWaveSpeed", "travel speed", Element.WATER)); + add(new Attribute("WaterSpoutWaveWaveRadius", "size of the rideable wave", Element.WATER)); + + // WATER - MULTIABILITY + // WaterArms + add(new Attribute("WaterArmsCooldown", "cooldown", Element.WATER, -1)); + add(new Attribute("WaterArmsLengthReduction", "lenght reduction", Element.WATER)); + add(new Attribute("WaterArmsLightningDamage", "damage received on lightning (?)", Element.WATER)); + add(new Attribute("WaterArmsMaxIceBlasts", "max ice blasts", Element.WATER)); + add(new Attribute("WaterArmsMaxPunches", "max punches", Element.WATER)); + add(new Attribute("WaterArmsMaxUses", "max uses", Element.WATER)); + add(new Attribute("WaterArmsSourceGrabRange", "source grab range", Element.WATER)); + + add(new Attribute("WaterArmsFreezeIceDamage", "ice damage on freeze", Element.WATER)); + add(new Attribute("WaterArmsFreezeIceRange", "ice radius on freeze", Element.WATER)); + add(new Attribute("WaterArmsFreezeUsageCooldown", "freeze cooldown", Element.WATER)); + + add(new Attribute("WaterArmsSpearSpearDamage", "spear damage", Element.WATER)); + add(new Attribute("WaterArmsSpearDuration", "spear duration", Element.WATER)); + add(new Attribute("WaterArmsSpearDurationFullMoon", "spear duration on full moon", Element.WATER)); + add(new Attribute("WaterArmsSpearDurationNight", "spear duration at night", Element.WATER)); + add(new Attribute("WaterArmsSpearLength", "spear length", Element.WATER)); + add(new Attribute("WaterArmsSpearRange", "spear range", Element.WATER)); + add(new Attribute("WaterArmsSpearRangeFullMoon", "spear range on full moon", Element.WATER)); + add(new Attribute("WaterArmsSpearRangeNight", "spear range at night", Element.WATER)); + add(new Attribute("WaterArmsSpearSphere", "spear sphere", Element.WATER)); + add(new Attribute("WaterArmsSpearSphereFullMoon", "spear sphere on full moon", Element.WATER)); + add(new Attribute("WaterArmsSpearSphereNight", "spear sphere at night", Element.WATER)); + add(new Attribute("WaterArmsSpearUsageCooldown", "spear cooldown", Element.WATER)); + + add(new Attribute("WaterArmsWhipGrabDuration", "whip hold time", Element.WATER)); + add(new Attribute("WaterArmsWhipPullMultiplier", "whip pull multiplier", Element.WATER)); + add(new Attribute("WaterArmsWhipPunchDamage", "whip punch damage", Element.WATER)); + add(new Attribute("WaterArmsWhipPunchLength", "whip punch length", Element.WATER)); + add(new Attribute("WaterArmsWhipPunchLengthFullMoon", "whip punch length on full moon", Element.WATER)); + add(new Attribute("WaterArmsWhipPunchLengthNight", "whip punch length at night", Element.WATER)); + add(new Attribute("WaterArmsWhipUsageCooldown", "whip cooldown", Element.WATER)); + add(new Attribute("WaterArmsWhipWhipLength", "whip length", Element.WATER)); + add(new Attribute("WaterArmsWhipWhipLengthFullMoon", "whip length on full moon", Element.WATER)); + add(new Attribute("WaterArmsWhipWhipLengthNight", "whip length at night", Element.WATER)); + add(new Attribute("WaterArmsWhipWhipLengthWeak", "whip length when weak", Element.WATER)); + add(new Attribute("WaterArmsWhipWhipSpeed", "whip speed", Element.WATER)); + + // WATER - BLOODBENDING + // Bloodbending + add(new Attribute("BloodbendingCooldown", "cooldown, only works if a base cooldown is enabled in config", Element.WATER, -1)); + add(new Attribute("BloodbendingDuration", "maximum hold time, only works if a base hold time is enabled in config", Element.WATER)); + add(new Attribute("BloodbendingKnockback", "throwing force", Element.WATER)); + add(new Attribute("BloodbendingRange", "grabbing range", Element.WATER)); + + // WATER - HEALING + // Not yet amigo + + // WATER - ICEBENDING + // IceBlast + add(new Attribute("IceBlastCollisionRadius", "collision radius", Element.WATER)); + add(new Attribute("IceBlastCooldown", "cooldown", Element.WATER, -1)); + add(new Attribute("IceBlastDamage", "damage", Element.WATER)); + add(new Attribute("IceBlastDeflectRange", "deflect range", Element.WATER)); + add(new Attribute("IceBlastInterval", "interval", Element.WATER)); + add(new Attribute("IceBlastRange", "range", Element.WATER)); + + // IceSpike + add(new Attribute("IceSpikeCollisionRadius", "collision radius", Element.WATER)); + add(new Attribute("IceSpikeCooldown", "cooldown", Element.WATER, -1)); + add(new Attribute("IceSpikeDamage", "projectile damage", Element.WATER)); + add(new Attribute("IceSpikeDeflectRange", "deflect range", Element.WATER)); + add(new Attribute("IceSpikeInterval", "interval", Element.WATER)); + add(new Attribute("IceSpikeRange", "projectile range", Element.WATER)); + add(new Attribute("IceSpikeSlowCooldown", "slow cooldown", Element.WATER)); + add(new Attribute("IceSpikeSlowDuration", "slow duration", Element.WATER)); + add(new Attribute("IceSpikeSlowPotency", "slow power", Element.WATER)); + + add(new Attribute("IceSpikePillarCooldown", "pillar cooldown", Element.WATER, -1)); + add(new Attribute("IceSpikePillarDamage", "pillar damage", Element.WATER)); + add(new Attribute("IceSpikePillarHeight", "pillar height", Element.WATER)); + add(new Attribute("IceSpikePillarInterval", "pillar interval", Element.WATER)); + add(new Attribute("IceSpikePillarRange", "maximum clickable range", Element.WATER)); + add(new Attribute("IceSpikePillarSlowCooldown", "slow cooldown", Element.WATER)); + add(new Attribute("IceSpikePillarSlowDuration", "slow duration", Element.WATER)); + add(new Attribute("IceSpikePillarSlowPower", "slow power", Element.WATER)); + add(new Attribute("IceSpikePillarSpeed", "pillar speed", Element.WATER)); + + add(new Attribute("IceSpikePillarFieldCooldown", "pillar field cooldown", Element.WATER, -1)); + add(new Attribute("IceSpikePillarFieldDamage", "pillar field damage", Element.WATER)); + add(new Attribute("IceSpikePillarFieldNumberOfSpikes", "number of spikes in pillar field", Element.WATER)); + add(new Attribute("IceSpikePillarFieldRadius", "pillar field radius", Element.WATER)); + + // PhaseChange + add(new Attribute("PhaseChangeDepth", "depth", Element.WATER)); + add(new Attribute("PhaseChangeFreezeControlRadius", "freeze control radius", Element.WATER)); + add(new Attribute("PhaseChangeSourceRange", "source range", Element.WATER)); + + // WATER - PLANT + // PlantRegrowth + add(new Attribute("PlantRegrowthRegrowTime", "regrow time", Element.WATER)); + + // WATER - COMBOS + // IceBullet + add(new Attribute("IceBulletAnimationSpeed", "damage", Element.WATER)); + add(new Attribute("IceBulletCooldown", "cooldown", Element.WATER, -1)); + add(new Attribute("IceBulletDamage", "damage", Element.WATER)); + add(new Attribute("IceBulletMaxShots", "max shots", Element.WATER)); + add(new Attribute("IceBulletRadius", "radius", Element.WATER)); + add(new Attribute("IceBulletRange", "range", Element.WATER)); + add(new Attribute("IceBulletShootTime", "shoot time", Element.WATER)); + add(new Attribute("IceBulletSpeed", "speed", Element.WATER)); + + // IceWave + add(new Attribute("IceWaveCooldown", "cooldown", Element.WATER, -1)); + + // EARTH + // Catapult + //add(new Attribute("CatapultLength", "length of the catapult earth pillar")); + //add(new Attribute("CatapultPush", "initial push distance")); + add(new Attribute("CatapultCooldown", "cooldown", Element.EARTH, -1)); + + // Collapse + add(new Attribute("CollapseCooldown", "cooldown", Element.EARTH, -1)); + add(new Attribute("CollapseDistance", "distance", Element.EARTH)); + add(new Attribute("CollapseHeight", "height", Element.EARTH)); + add(new Attribute("CollapseSelectRange", "select range", Element.EARTH)); + add(new Attribute("CollapseSpeed", "speed", Element.EARTH)); + + add(new Attribute("CollapseWallCooldown", "wall cooldown", Element.EARTH, -1)); + add(new Attribute("CollapseWallHeight", "wall height", Element.EARTH)); + add(new Attribute("CollapseWallRadius", "wall speed", Element.EARTH)); + add(new Attribute("CollapseWallSelectRange", "wall select range", Element.EARTH)); + + // EarthArmor + //add(new Attribute("EarthArmorStrength", "resistance potion potency", Element.EARTH)); + add(new Attribute("EarthArmorCooldown", "cooldown", Element.EARTH, -1)); + add(new Attribute("EarthArmorInterval", "interval", Element.EARTH)); + add(new Attribute("EarthArmorMaxGoldHearts", "max number of golden hearts", Element.EARTH)); + add(new Attribute("EarthArmorSelectRange", "select range", Element.EARTH)); + + // EarthBlast + add(new Attribute("EarthBlastCollisionRadius", "collision radius", Element.EARTH)); + add(new Attribute("EarthBlastCooldown", "cooldown", Element.EARTH, -1)); + add(new Attribute("EarthBlastDamage", "damage", Element.EARTH)); + add(new Attribute("EarthBlastDeflectRange", "deflect range", Element.EARTH)); + add(new Attribute("EarthBlastInterval", "interval", Element.EARTH)); + add(new Attribute("EarthBlastPushFactor", "knockback force", Element.EARTH)); + add(new Attribute("EarthBlastRange", "range", Element.EARTH)); + add(new Attribute("EarthBlastSelectRange", "select range", Element.EARTH)); + add(new Attribute("EarthBlastSpeed", "speed", Element.EARTH)); + + // EarthSmash + add(new Attribute("EarthSmashChargeTime", "initial charge up time", Element.EARTH, -1)); + add(new Attribute("EarthSmashCooldown", "cooldown between uses, the config must have an initial cooldown set for this to work", Element.EARTH, -1)); + add(new Attribute("EarthSmashDamage", "shooting damage", Element.EARTH)); + add(new Attribute("EarthSmashDelay", "delay", Element.EARTH)); + add(new Attribute("EarthSmashFlightAnimationInterval", "flight animation interval", Element.EARTH)); + add(new Attribute("EarthSmashFlightDetectionRadius", "flight detection radius", Element.EARTH)); + add(new Attribute("EarthSmashFlightDuration", "flying duration", Element.EARTH)); + add(new Attribute("EarthSmashFlightSpeed", "flying speed, if this is too high the ability will get buggy", Element.EARTH)); + add(new Attribute("EarthSmashGrabDetectionRadius", "grab detection radius", Element.EARTH)); + add(new Attribute("EarthSmashGrabRange", "initial spawning distance", Element.EARTH)); + add(new Attribute("EarthSmashKnockback", "knockback force", Element.EARTH)); + add(new Attribute("EarthSmashKnockup", "knockup force", Element.EARTH)); + add(new Attribute("EarthSmashLiftAnimationInterval", "lift animation interval", Element.EARTH)); + add(new Attribute("EarthSmashMaxBlocksToPassThrough", "max blocks to pass through", Element.EARTH)); + add(new Attribute("EarthSmashSelectRange", "select range", Element.EARTH)); + add(new Attribute("EarthSmashShootAnimationInterval", "shoot animation interval", Element.EARTH)); + add(new Attribute("EarthSmashShootRange", "shooting range", Element.EARTH)); + + // EarthTunnel + add(new Attribute("EarthTunnelAngle", "angle", Element.EARTH)); + add(new Attribute("EarthTunnelDepth", "depth", Element.EARTH)); + add(new Attribute("EarthTunnelInterval", "block remove speed, negative is better", Element.EARTH, -1)); + add(new Attribute("EarthTunnelMaxRadius", "radius", Element.EARTH)); + add(new Attribute("EarthTunnelRadiusIncrement", "radius increment", Element.EARTH)); + add(new Attribute("EarthTunnelRange", "range", Element.EARTH)); + + // RaiseEarth + add(new Attribute("RaiseEarthCooldown", "cooldown between uses, the config must have an initial cooldown set for this to work", Element.EARTH, -1)); + add(new Attribute("RaiseEarthDistance", "distance", Element.EARTH)); + add(new Attribute("RaiseEarthHeight", "height", Element.EARTH)); + add(new Attribute("RaiseEarthInterval", "interval", Element.EARTH)); + add(new Attribute("RaiseEarthSelectRange", "select range", Element.EARTH)); + add(new Attribute("RaiseEarthSpeed", "speed", Element.EARTH)); + + add(new Attribute("RaiseEarthWallCooldown", "wall cooldown between uses, the config must have an initial cooldown set for this to work", Element.EARTH, -1)); + add(new Attribute("RaiseEarthWallHeight", "wall height", Element.EARTH)); + add(new Attribute("RaiseEarthWallRange", "wall range", Element.EARTH)); + add(new Attribute("RaiseEarthWallSelectRange", "wall select range", Element.EARTH)); + add(new Attribute("RaiseEarthWallSpeed", "wall speed", Element.EARTH)); + + // Ripple + add(new Attribute("RippleKnockback", "knockback force", Element.EARTH)); + add(new Attribute("RippleMaxStep", "max step", Element.EARTH)); + add(new Attribute("RippleRange", "range", Element.EARTH)); + + // Shockwave + //add(new Attribute("ShockwaveRadius", "radius")); + add(new Attribute("ShockwaveAngle", "angle", Element.EARTH)); + add(new Attribute("ShockwaveChargeTime", "initial charge up time, negative is better", Element.EARTH, -1)); + add(new Attribute("ShockwaveCooldown", "cooldown", Element.EARTH, -1)); + add(new Attribute("ShockwaveDamage", "damage", Element.EARTH)); + //add(new Attribute("ShockwaveKnockback", "knockback force", Element.EARTH)); + add(new Attribute("ShockwaveRange", "range", Element.EARTH)); + add(new Attribute("ShockwaveThreshold", "threshold", Element.EARTH)); + + // Tremorsense + add(new Attribute("TremorsenseCooldown", "cooldown", Element.EARTH, -1)); + add(new Attribute("TremorsenseLightThreshold", "light threshold", Element.EARTH)); + add(new Attribute("TremorsenseMaxDepth", "max depth", Element.EARTH)); + add(new Attribute("TremorsenseRadius", "radius", Element.EARTH)); + + // FIRE + // Blaze + //add(new Attribute("BlazeRange", "range", Element.FIRE)); + add(new Attribute("BlazeArcInterval", "interval", Element.FIRE)); + add(new Attribute("BlazeArcRange", "range", Element.FIRE)); + add(new Attribute("BlazeArcSpeed", "speed", Element.FIRE)); + + add(new Attribute("BlazeRingAngleIncrement", "interval", Element.FIRE)); + add(new Attribute("BlazeRingCooldown", "speed", Element.FIRE, -1)); + add(new Attribute("BlazeRingRange", "range", Element.FIRE)); + + // FireBlast + add(new Attribute("FireBlastCollisionRadius", "collision radius", Element.FIRE)); + add(new Attribute("FireBlastCooldown", "cooldown", Element.FIRE, -1)); + add(new Attribute("FireBlastDamage", "damage", Element.FIRE)); + add(new Attribute("FireBlastFireTicks", "fire ticks", Element.FIRE)); + add(new Attribute("FireBlastPushFactor", "knockback force", Element.FIRE)); + add(new Attribute("FireBlastRange", "travel range", Element.FIRE)); + add(new Attribute("FireBlastSpeed", "travel speed", Element.FIRE)); + add(new Attribute("FireBlastSpeedFactor", "travel speed factor", Element.FIRE)); + + add(new Attribute("FireBlastChargedChargeTime", "initial charge up time", Element.FIRE, -1)); + add(new Attribute("FireBlastChargedCollisionRadius", "collision radius", Element.FIRE)); + add(new Attribute("FireBlastChargedDamageRadius", "damage radius", Element.FIRE)); + add(new Attribute("FireBlastChargedExplosionRadius", "explosion radius, (power is more important)", Element.FIRE)); + add(new Attribute("FireBlastChargedFireTicks", "fire ticks", Element.FIRE)); + add(new Attribute("FireBlastChargedInnerRadius", "inner radius", Element.FIRE)); + //add(new Attribute("FireBlastChargedPower", "explosion power and size", Element.FIRE)); + add(new Attribute("FireBlastChargedInterval", "interval", Element.FIRE)); + add(new Attribute("FireBlastChargedMaxDamage", "damage", Element.FIRE)); + add(new Attribute("FireBlastChargedRange", "range", Element.FIRE)); + + // FireBurst + add(new Attribute("FireBurstAnglePhi", "angle phi", Element.FIRE)); + add(new Attribute("FireBurstAngleTheta", "angle theta", Element.FIRE)); + add(new Attribute("FireBurstChargeTime", "initial charge up time", Element.FIRE, -1)); + add(new Attribute("FireBurstCooldown", "cooldown", Element.FIRE, -1)); + add(new Attribute("FireBurstDamage", "damage", Element.FIRE)); + add(new Attribute("FireBurstParticlesPercentage", "particles percentage", Element.FIRE)); + add(new Attribute("FireBurstRange", "range", Element.FIRE)); + + // FireJet + add(new Attribute("FireJetCooldown", "cooldown", Element.FIRE, -1)); + add(new Attribute("FireJetDuration", "duration", Element.FIRE)); + add(new Attribute("FireJetSpeed", "speed", Element.FIRE)); + + // FireShield + add(new Attribute("FireShieldDiscCooldown", "cooldown of click shield", Element.FIRE, -1)); + add(new Attribute("FireShieldDiscDuration", "duration of a click shield", Element.FIRE)); + add(new Attribute("FireShieldDiscRadius", "radius of click shield", Element.FIRE)); + //add(new Attribute("FireShieldInterval", "interval", Element.FIRE)); + add(new Attribute("FireShieldShieldRadius", "radius of shift shield", Element.FIRE)); + add(new Attribute("FireShieldShieldCooldown", "cooldown of shift shield", Element.FIRE, -1)); + add(new Attribute("FireShieldShieldDuration", "duration of a shift shield", Element.FIRE)); + + // HeatControl + //add(new Attribute("HeatControlCookTime", "the time it takes to cook an item, negative is better")); + + // Illumination + add(new Attribute("IlluminationCooldown", "cooldown", Element.FIRE, -1)); + add(new Attribute("IlluminationRange", "range", Element.FIRE)); + + // WallOfFire + add(new Attribute("WallOfFireCooldown", "cooldown", Element.FIRE, -1)); + add(new Attribute("WallOfFireDamage", "the damage per interval", Element.FIRE)); + add(new Attribute("WallOfFireDamageInterval", "the time between damages, negative is better", Element.FIRE, -1)); + add(new Attribute("WallOfFireDamageTick", "damage tick", Element.FIRE)); + add(new Attribute("WallOfFireDuration", "duration", Element.FIRE)); + add(new Attribute("WallOfFireFireTicks", "fire ticks", Element.FIRE)); + add(new Attribute("WallOfFireHeight", "height")); + add(new Attribute("WallOfFireInterval", "interval")); + add(new Attribute("WallOfFireIntervalTick", "interval tick")); + add(new Attribute("WallOfFireMaxAngle", "max angle")); + add(new Attribute("WallOfFireRange", "the distance from the player")); + add(new Attribute("WallOfFireWidth", "width")); + + // FIRE - COMBUSTION + // Combustion + add(new Attribute("CombustionCooldown", "cooldown", Element.FIRE, -1)); + add(new Attribute("CombustionDamage", "damage", Element.FIRE)); + add(new Attribute("CombustionExplosivePower", "explosive power", Element.FIRE)); + add(new Attribute("CombustionRadius", "radius", Element.FIRE)); + add(new Attribute("CombustionRange", "range", Element.FIRE)); + add(new Attribute("CombustionSpeed", "speed", Element.FIRE)); + add(new Attribute("CombustionSpeedFactor", "speed factor", Element.FIRE)); + add(new Attribute("CombustionTicks", "ticks", Element.FIRE)); + + //FIRE - LIGHTNING + // Lightning + add(new Attribute("LightningChainArcChance", "chance to chain to more enemies", Element.FIRE)); + add(new Attribute("LightningChainRange", "seeking range of chain arcs", Element.FIRE)); + add(new Attribute("LightningChargeTime", "initial charge up time", Element.FIRE, -1)); + add(new Attribute("LightningCooldown", "cooldown", Element.FIRE, -1)); + add(new Attribute("LightningDamage", "damage", Element.FIRE)); + add(new Attribute("LightningMaxArcAngle", "maximum arc angle", Element.FIRE)); + add(new Attribute("LightningMaxChainArcs", "maximum amount of times an arc can chain to more enemies", Element.FIRE)); + add(new Attribute("LightningRange", "range", Element.FIRE)); + add(new Attribute("LightningStunChance", "chance for stun", Element.FIRE)); + add(new Attribute("LightningStunDuration", "duration of stun", Element.FIRE)); + add(new Attribute("LightningSubArcChance", "chance for the arcs to split", Element.FIRE)); + add(new Attribute("LightningWaterArcRange", "range of water arcs", Element.FIRE)); + add(new Attribute("LightningWaterArcs", "number of water arcs", Element.FIRE)); + + // FIRE - COMBOS + // Nope + + // CHI + // AcrobatStance + add(new Attribute("AcrobatStanceJump", "jump potion potency, you may have to increase this a lot to see a difference", Element.CHI)); + add(new Attribute("AcrobatStanceSpeed", "speed potion potency, you may have to increase this a lot to see a difference", Element.CHI)); + + // HighJump + add(new Attribute("HighJumpCooldown", "cooldown, negative is better", Element.CHI, -1)); + add(new Attribute("HighJumpHeight", "height", Element.CHI)); + + // QuickStrike + add(new Attribute("QuickStrikeBlockChance", "block chance", Element.CHI)); + add(new Attribute("QuickStrikeDamage", "damage", Element.CHI)); + + // RapidPunch + add(new Attribute("RapidPunchDamage", "damage per hit", Element.CHI)); + add(new Attribute("RapidPunchHits", "total amount of hits", Element.CHI)); + //add(new Attribute("RapidPunchDistance", "distance", Element.CHI)); + add(new Attribute("RapidPunchCooldown", "cooldown, negative is better", Element.CHI, -1)); + + // Smokescreen + add(new Attribute("SmokescreenCooldown", "cooldown, negative is better", Element.CHI, -1)); + add(new Attribute("SmokescreenDuration", "duration", Element.CHI)); + add(new Attribute("SmokescreenRadius", "radius", Element.CHI)); + + // SwiftKick + add(new Attribute("SwiftKickBlockChance", "block chance", Element.CHI)); + add(new Attribute("SwiftKickCooldown", "cooldown, negative is better", Element.CHI, -1)); + add(new Attribute("SwiftKickDamage", "damage", Element.CHI)); + + // WariorStance + add(new Attribute("WarriorStanceStrength", "strength potion potency, you may have to increase this a lot to see a difference", Element.CHI)); + add(new Attribute("WarriorStanceResistance", "resistance potion potency, you may have to increase this a lot to see a difference", Element.CHI)); + + // CHI - COMBOS + // Immobilize + add(new Attribute("ImmobilizeCooldown", "cooldown, negative is better", Element.CHI, -1)); + add(new Attribute("ImmobilizeDuration", "duration", Element.CHI)); + + } + }; +} diff --git a/src/com/projectkorra/items/command/BaseCommand.java b/src/main/java/com/projectkorra/items/command/BaseCommand.java similarity index 99% rename from src/com/projectkorra/items/command/BaseCommand.java rename to src/main/java/com/projectkorra/items/command/BaseCommand.java index d82da20..ce68f8f 100644 --- a/src/com/projectkorra/items/command/BaseCommand.java +++ b/src/main/java/com/projectkorra/items/command/BaseCommand.java @@ -32,5 +32,4 @@ public void execute(CommandSender sender, List args) { } } } - } diff --git a/src/com/projectkorra/items/command/EquipCommand.java b/src/main/java/com/projectkorra/items/command/EquipCommand.java similarity index 61% rename from src/com/projectkorra/items/command/EquipCommand.java rename to src/main/java/com/projectkorra/items/command/EquipCommand.java index 2d25c10..3a03832 100644 --- a/src/com/projectkorra/items/command/EquipCommand.java +++ b/src/main/java/com/projectkorra/items/command/EquipCommand.java @@ -16,21 +16,18 @@ public EquipCommand() { @Override public void execute(CommandSender sender, List args) { - if (correctLength(sender, args.size(), 0, 0)) - if (args.size() == 0) { - if (!hasPermission(sender)) { - sender.sendMessage(Messages.NO_PERM); - return; - } else if (!isPlayer(sender)) { - sender.sendMessage(Messages.PLAYER_ONLY); - return; - } - - Player player = (Player)sender; - new PKIEquip(player); + if (!correctLength(sender, args.size(), 0, 0)) { + return; + } + if (!hasPermission(sender)) { + sender.sendMessage(Messages.NO_PERM); + return; + } else if (!isPlayer(sender)) { + sender.sendMessage(Messages.PLAYER_ONLY); return; } - - } + Player player = (Player)sender; + new PKIEquip(player); + } } diff --git a/src/main/java/com/projectkorra/items/command/GiveCommand.java b/src/main/java/com/projectkorra/items/command/GiveCommand.java new file mode 100644 index 0000000..00919b8 --- /dev/null +++ b/src/main/java/com/projectkorra/items/command/GiveCommand.java @@ -0,0 +1,78 @@ +package com.projectkorra.items.command; + +import java.util.List; + +import org.bukkit.ChatColor; +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; +import org.bukkit.inventory.ItemStack; + +import com.projectkorra.items.Messages; +import com.projectkorra.items.ProjectKorraItems; +import com.projectkorra.items.customs.PKItem; + +public class GiveCommand extends PKICommand { + + public GiveCommand() { + super("give", "/bending items give [Amount] [Player]", "This command gives you or another player a bending item.", Messages.GIVE_ALIAS); + } + + @Override + public void execute(CommandSender sender, List args) { + if (correctLength(sender, args.size(), 0, 3)) { + if (!hasPermission(sender)) { + sender.sendMessage(Messages.NO_PERM); + return; + } + if (args.size() == 0) { + sender.sendMessage(ChatColor.YELLOW + " ---- " + ChatColor.GOLD + "Item Names " + ChatColor.YELLOW + "----"); + for (PKItem citem : PKItem.itemList) + sender.sendMessage(ChatColor.YELLOW + citem.getName()); + return; + } + if (!isPlayer(sender)) { + sender.sendMessage(Messages.PLAYER_ONLY); + return; + } + + Player player = (Player)sender; + PKItem ci = null; + ItemStack i = null; + int q = 1; + + if (args.size() >= 1) { + ci = PKItem.getCustomItem(args.get(0)); + + if (ci == null) { + sender.sendMessage(Messages.ITEM_NOT_FOUND); + return; + } + i = ci.generateItem(); + + if (args.size() >= 2) { + try { + q = Integer.parseInt(args.get(1)); + } catch (Exception e) { + sender.sendMessage(Messages.NOT_INT); + return; + } + i.setAmount(q); + + if (args.size() == 3) { + Player target = ProjectKorraItems.plugin.getServer().getPlayer(args.get(2)); + + if (target == null) { + sender.sendMessage(Messages.INVALID_PLAYER); + return; + } + + target.getInventory().addItem(i); + return; + } + } + } + player.getInventory().addItem(i); + } + } + +} diff --git a/src/com/projectkorra/items/command/ListCommand.java b/src/main/java/com/projectkorra/items/command/ListCommand.java similarity index 77% rename from src/com/projectkorra/items/command/ListCommand.java rename to src/main/java/com/projectkorra/items/command/ListCommand.java index 7f79748..a2aa9fb 100644 --- a/src/com/projectkorra/items/command/ListCommand.java +++ b/src/main/java/com/projectkorra/items/command/ListCommand.java @@ -28,18 +28,17 @@ public void execute(CommandSender sender, List args) { Player player = (Player) sender; boolean show = false; - - if (args.size() >= 0) { - if (args.size() == 1) { - for (String s : Messages.STATS_ALIAS) { - if (args.get(0) == s) { - show = true; - } + + if (args.size() == 1) { + for (String s : Messages.STATS_ALIAS) { + if (args.get(0).equals(s)) { + show = true; + break; } } - PKIDisplay d = new PKIDisplay(player, show); - d.createInventory(); } + PKIDisplay d = new PKIDisplay(player, show); + d.createInventory(); } } } diff --git a/src/com/projectkorra/items/command/PKICommand.java b/src/main/java/com/projectkorra/items/command/PKICommand.java similarity index 89% rename from src/com/projectkorra/items/command/PKICommand.java rename to src/main/java/com/projectkorra/items/command/PKICommand.java index b93b5e2..dda3d55 100644 --- a/src/com/projectkorra/items/command/PKICommand.java +++ b/src/main/java/com/projectkorra/items/command/PKICommand.java @@ -1,6 +1,7 @@ package com.projectkorra.items.command; import java.util.HashMap; +import java.util.Map; import org.bukkit.ChatColor; import org.bukkit.command.CommandSender; @@ -10,7 +11,7 @@ import com.projectkorra.projectkorra.command.SubCommand; public abstract class PKICommand implements SubCommand { - public static HashMap instances = new HashMap<>(); + public static Map instances = new HashMap<>(); private String name; private String properUse; @@ -58,11 +59,7 @@ public void help(CommandSender sender, boolean description) { * @return True if they have permission, false otherwise */ protected boolean hasPermission(CommandSender sender) { - if (sender.hasPermission("bendingitems.command." + name)) { - return true; - } else { - return false; - } + return sender.hasPermission("bendingitems.command." + name); } /** @@ -75,11 +72,7 @@ protected boolean hasPermission(CommandSender sender) { * @return True if they have permission, false otherwise */ protected boolean hasPermission(CommandSender sender, String extra) { - if (sender.hasPermission("bendingitems.command." + name + "." + extra)) { - return true; - } else { - return false; - } + return sender.hasPermission("bendingitems.command." + name + "." + extra); } /** @@ -90,7 +83,7 @@ protected boolean hasPermission(CommandSender sender, String extra) { * @param size The length of the arguments list * @param min The minimum acceptable number of arguments * @param max The maximum acceptable number of arguments - * @return True if min < size < max, false otherwise + * @return True if min < size < max, false otherwise */ protected boolean correctLength(CommandSender sender, int size, int min, int max) { if (size < min || size > max) { diff --git a/src/com/projectkorra/items/command/ReloadCommand.java b/src/main/java/com/projectkorra/items/command/ReloadCommand.java similarity index 100% rename from src/com/projectkorra/items/command/ReloadCommand.java rename to src/main/java/com/projectkorra/items/command/ReloadCommand.java diff --git a/src/main/java/com/projectkorra/items/command/StatsCommand.java b/src/main/java/com/projectkorra/items/command/StatsCommand.java new file mode 100644 index 0000000..9ba34f6 --- /dev/null +++ b/src/main/java/com/projectkorra/items/command/StatsCommand.java @@ -0,0 +1,62 @@ +package com.projectkorra.items.command; + +import java.util.ArrayList; +import java.util.List; + +import org.bukkit.ChatColor; +import org.bukkit.command.CommandSender; + +import com.projectkorra.items.Messages; +import com.projectkorra.items.attribute.Attribute; +import com.projectkorra.items.attribute.AttributeList; + +public class StatsCommand extends PKICommand { + + public StatsCommand() { + super("stats", "/bending items stats", "This command lists all stats which can be applied to a bending item", Messages.STATS_ALIAS); + } + + @Override + public void execute(CommandSender sender, List args) { + if (correctLength(sender, args.size(), 0, 1)) { + if (!hasPermission(sender)) { + sender.sendMessage(Messages.NO_PERM); + return; + } + int page = 1; + String phrase = null; + try { + page = Integer.parseInt(args.get(0)); + } + catch (Exception e) { + phrase = args.get(0); + } + + List attribs = new ArrayList<>(AttributeList.ATTRIBUTES); + if (phrase != null) { + for (int i = 0; i < attribs.size(); i++) { + Attribute att = attribs.get(i); + if (!att.getName().toLowerCase().contains(phrase.toLowerCase())) { + attribs.remove(i); + i--; + } + } + } + + int maxPage = (attribs.size() - 1) / Messages.LINES_PER_PAGE; + page -= 1; + page = Math.min(Math.max(page, 0), maxPage); + int pageIndex = page * Messages.LINES_PER_PAGE; + sender.sendMessage(ChatColor.YELLOW + " ---- " + ChatColor.GOLD + "Stats " + ChatColor.YELLOW + "-- " + ChatColor.GOLD + "Page " + ChatColor.RED + (page + 1) + ChatColor.GOLD + "/" + ChatColor.RED + (maxPage + 1) + ChatColor.YELLOW + " ----"); + for (int i = pageIndex; i < pageIndex + Messages.LINES_PER_PAGE; i++) { + if (i < attribs.size()) { + Attribute att = attribs.get(i); + sender.sendMessage(ChatColor.YELLOW + att.getName() + ": " + ChatColor.WHITE + att.getDesc()); + } else + break; + } + if (phrase != null) + sender.sendMessage(ChatColor.GOLD + "Phrase: " + ChatColor.RED + phrase); + } + } +} diff --git a/src/com/projectkorra/items/customs/PKIDisplay.java b/src/main/java/com/projectkorra/items/customs/PKIDisplay.java similarity index 79% rename from src/com/projectkorra/items/customs/PKIDisplay.java rename to src/main/java/com/projectkorra/items/customs/PKIDisplay.java index 5223100..868dab4 100644 --- a/src/com/projectkorra/items/customs/PKIDisplay.java +++ b/src/main/java/com/projectkorra/items/customs/PKIDisplay.java @@ -12,7 +12,7 @@ import java.util.ArrayList; import java.util.List; -import java.util.concurrent.ConcurrentHashMap; +import java.util.Map; /** * ItemDisplays are used to display all of the previously created CustomItems @@ -20,9 +20,9 @@ * CustomItems becomes too large then the display must use multiple pages. */ public class PKIDisplay { - public static ConcurrentHashMap displays; - public static final ItemStack PREV_BUTTON = new ItemStack(Material.WOOL, 1, (short) 14); - public static final ItemStack NEXT_BUTTON = new ItemStack(Material.WOOL, 1, (short) 5); + public static Map displays; + public static final ItemStack PREV_BUTTON = new ItemStack(Material.RED_WOOL, 1); + public static final ItemStack NEXT_BUTTON = new ItemStack(Material.LIME_WOOL, 1); public static final int INV_SIZE = 27; public static final int INV_ITEM_QTY = INV_SIZE - 9; private Player player; @@ -44,12 +44,16 @@ public PKIDisplay(Player player, boolean showStats, int page) { this.showStats = showStats; this.page = page; ItemMeta meta1 = PREV_BUTTON.getItemMeta(); - meta1.setDisplayName(ChatColor.RED + "Prev"); - PREV_BUTTON.setItemMeta(meta1); + if (meta1 != null) { + meta1.setDisplayName(ChatColor.RED + "Prev"); + PREV_BUTTON.setItemMeta(meta1); + } ItemMeta meta2 = NEXT_BUTTON.getItemMeta(); - meta2.setDisplayName(ChatColor.GREEN + "Next"); - NEXT_BUTTON.setItemMeta(meta2); + if (meta2 != null) { + meta2.setDisplayName(ChatColor.GREEN + "Next"); + NEXT_BUTTON.setItemMeta(meta2); + } createInventory(); } @@ -92,35 +96,37 @@ public void createInventory() { } Inventory inv = Bukkit.createInventory(null, INV_SIZE, "Bending Items"); - ArrayList cistacks = new ArrayList(); + List cistacks = new ArrayList<>(); for (PKItem citem : PKItem.itemList) { ItemStack istack = citem.generateItem(); ItemMeta meta = istack.getItemMeta(); - if (showStats) { - ArrayList lore = new ArrayList(); - for (Attribute att : citem.getAttributes()) { - if (att.getValues().toString().length() < 40) - lore.add(new String(att.getName() + ":" + att.getValues())); + if (meta != null) { + if (showStats) { + List lore = new ArrayList<>(); + for (Attribute att : citem.getAttributes()) { + if (att.getValues().toString().length() < 40) + lore.add(att.getName() + ":" + att.getValues()); + else + lore.add(att.getName()); + } + meta.setLore(lore); + } else { + List lore = meta.getLore(); + if (lore == null) + lore = new ArrayList<>(); + + String s; + if (citem.getRecipe().size() == 0) + s = ChatColor.RED + "Uncraftable"; + else if (citem.isUnshapedRecipe()) + s = ChatColor.GREEN + "Craftable (unshaped)"; else - lore.add(new String(att.getName())); + s = ChatColor.GREEN + "Craftable (shaped)"; + lore.add(s); + meta.setLore(lore); } - meta.setLore(lore); - } else { - List lore = meta.getLore(); - if (lore == null) - lore = new ArrayList(); - - String s = ""; - if (citem.getRecipe().size() == 0) - s = ChatColor.RED + "Uncraftable"; - else if (citem.isUnshapedRecipe()) - s = ChatColor.GREEN + "Craftable (unshaped)"; - else - s = ChatColor.GREEN + "Craftable (shaped)"; - lore.add(s); - meta.setLore(lore); + istack.setItemMeta(meta); } - istack.setItemMeta(meta); cistacks.add(istack); } diff --git a/src/com/projectkorra/items/customs/PKIEquip.java b/src/main/java/com/projectkorra/items/customs/PKIEquip.java similarity index 91% rename from src/com/projectkorra/items/customs/PKIEquip.java rename to src/main/java/com/projectkorra/items/customs/PKIEquip.java index ce754f6..713fb17 100644 --- a/src/com/projectkorra/items/customs/PKIEquip.java +++ b/src/main/java/com/projectkorra/items/customs/PKIEquip.java @@ -9,6 +9,7 @@ import org.bukkit.inventory.PlayerInventory; import org.bukkit.scheduler.BukkitRunnable; +import java.util.Map; import java.util.concurrent.ConcurrentHashMap; /** @@ -20,7 +21,7 @@ * stop being followed. */ public class PKIEquip { - public static final ConcurrentHashMap INSTANCES = new ConcurrentHashMap(); + public static final Map INSTANCES = new ConcurrentHashMap<>(); private PKItem customItem; private ItemStack item; @@ -32,7 +33,6 @@ public class PKIEquip { * * @param player the player to add or remove an ItemEquip */ - @SuppressWarnings("deprecation") public PKIEquip(Player player) { String name = player.getName(); @@ -43,7 +43,7 @@ public PKIEquip(Player player) { return; } - ItemStack inhand = player.getItemInHand(); + ItemStack inhand = player.getInventory().getItemInMainHand(); PKItem citem = PKItem.getCustomItem(inhand); if (citem == null) { player.sendMessage(Messages.CANT_EQUIP); @@ -100,7 +100,7 @@ public void run() { inv.setItem(foundSlot, new ItemStack(Material.AIR)); return true; - } else if (prevSlotItem != null && prevSlotItem.hasItemMeta() && prevSlotItem.getItemMeta().hasDisplayName() && prevSlotItem.getItemMeta().getDisplayName().equals(itemEq.customItem.getDisplayName())) { + } else if (prevSlotItem != null && prevSlotItem.hasItemMeta() && prevSlotItem.getItemMeta() != null && prevSlotItem.getItemMeta().hasDisplayName() && prevSlotItem.getItemMeta().getDisplayName().equals(itemEq.customItem.getDisplayName())) { final ItemStack prevItem = inv.getItem(prevSlot); final PKIEquip fitemEq = itemEq; diff --git a/src/com/projectkorra/items/customs/PKItem.java b/src/main/java/com/projectkorra/items/customs/PKItem.java similarity index 55% rename from src/com/projectkorra/items/customs/PKItem.java rename to src/main/java/com/projectkorra/items/customs/PKItem.java index ea7f3f1..b2c968e 100644 --- a/src/com/projectkorra/items/customs/PKItem.java +++ b/src/main/java/com/projectkorra/items/customs/PKItem.java @@ -5,51 +5,62 @@ import com.projectkorra.items.attribute.Attribute; import com.projectkorra.items.attribute.AttributeList; +import io.th0rgal.oraxen.api.OraxenItems; import org.bukkit.ChatColor; import org.bukkit.Color; import org.bukkit.Material; +import org.bukkit.NamespacedKey; import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.meta.ItemMeta; import org.bukkit.inventory.meta.LeatherArmorMeta; +import org.bukkit.persistence.PersistentDataContainer; +import org.bukkit.persistence.PersistentDataType; +import org.bukkit.potion.PotionType; import java.util.ArrayList; import java.util.List; +import java.util.Map; import java.util.Set; import java.util.concurrent.ConcurrentHashMap; public class PKItem { - public static ConcurrentHashMap items = new ConcurrentHashMap(); - public static ArrayList itemList = new ArrayList(); + public static Map items = new ConcurrentHashMap<>(); + public static List itemList = new ArrayList<>(); + public static NamespacedKey PKI_KEY = new NamespacedKey(ProjectKorraItems.plugin, "name"); private String name; private String displayName; - private ArrayList lore; + private List lore; + private boolean isOraxen; + private String oraxenId; private Material material; private int quantity; - private short damage; - private ArrayList recipe; + // private short damage; + private List recipe; private boolean unshapedRecipe; private boolean valid; private boolean alreadyFinal; - private boolean glow; - private ArrayList attributes; + private Boolean glow; + private List attributes; public PKItem() { name = ""; displayName = ""; - lore = new ArrayList(); + lore = new ArrayList<>(); + isOraxen = false; + oraxenId = null; material = null; quantity = 1; - damage = (short) 0; - recipe = new ArrayList(); + // damage = (short) 0; + recipe = new ArrayList<>(); valid = true; unshapedRecipe = true; - attributes = new ArrayList(); - glow = false; + glow = null; + attributes = new ArrayList<>(); } public void updateName(String s) { - if (s == null || s.length() == 0 || s.contains(" ")) { + if (s == null || s.isEmpty() || s.contains(" ")) { valid = false; ProjectKorraItems.log.info(Messages.BAD_NAME + ": " + toString()); if (s != null) @@ -60,7 +71,7 @@ public void updateName(String s) { } public void updateDisplayName(String s) { - if (s == null || s.length() == 0) { + if (s == null || s.isEmpty()) { valid = false; ProjectKorraItems.log.info(Messages.BAD_DNAME + ": " + toString()); } else { @@ -71,7 +82,7 @@ public void updateDisplayName(String s) { } public void updateLore(String s) { - if (s == null || s.length() == 0) { + if (s == null || s.isEmpty()) { valid = false; ProjectKorraItems.log.info(Messages.BAD_LORE + ": " + toString()); } else { @@ -82,28 +93,36 @@ public void updateLore(String s) { } public void updateMaterial(String s) { - if (s == null || s.length() == 0) { + if (s == null || s.isEmpty()) { valid = false; - ProjectKorraItems.log.info(Messages.BAD_MATERIAL + ": " + toString()); + ProjectKorraItems.log.info(Messages.BAD_MATERIAL + "(95): " + toString()); } else { - material = Material.getMaterial(s); - if (material == null) { - valid = false; - ProjectKorraItems.log.info(Messages.BAD_MATERIAL + ": " + s); + if (s.toLowerCase().startsWith("oraxen:")) { + s = s.split(":")[1]; + if (OraxenItems.exists(s)) { + oraxenId = s; + isOraxen = true; + } + else { + valid = false; + ProjectKorraItems.log.info(Messages.BAD_MATERIAL + "(105): oraxen:" + s); + } + } + else { + material = Material.getMaterial(s); + if (material == null) { + valid = false; + ProjectKorraItems.log.info(Messages.BAD_MATERIAL + "(112): " + s); + } } } } - public void updateQuantity(String s) { - try { - quantity = Integer.parseInt(s); - } - catch (Exception e) { - valid = false; - ProjectKorraItems.log.info(Messages.BAD_QUANTITY + ": " + toString()); - } + public void updateQuantity(int qty) { + quantity = qty; } + /* public void updateDamage(String s) { try { damage = (short) Integer.parseInt(s); @@ -113,15 +132,10 @@ public void updateDamage(String s) { ProjectKorraItems.log.info(Messages.BAD_DAMAGE + ": " + toString()); } } + */ - public void updateGlow(String s) { - try { - glow = Boolean.parseBoolean(s); - } - catch (Exception e) { - valid = false; - ProjectKorraItems.log.info(Messages.BAD_GLOW + ": " + toString()); - } + public void updateGlow(Boolean glow) { + this.glow = glow; } /** @@ -130,44 +144,43 @@ public void updateGlow(String s) { * example: UnshapedRecipe: WOOL, WOOL:3:14, WOOL Recipe ingredients * can be both Material and other CustomItems. * - * @param s - * @param customItemNames + * @param recipeStr the string containing the recipe + * @param customItemNames the set with all custom item names */ - @SuppressWarnings("deprecation") - public void updateRecipe(String s, Set customItemNames) { + public void updateRecipe(String recipeStr, Set customItemNames) { try { - s = s.replaceAll(" ", ""); - String[] commas = s.split(","); + recipeStr = recipeStr.replaceAll(" ", ""); + String[] commas = recipeStr.split(","); for (String comma : commas) { String[] colons = comma.split(":"); Material mat = Material.getMaterial(colons[0]); - // Try to get the Material by id + // Try to get the Material by id, not anymore + /* if (mat == null) { try { mat = Material.getMaterial(Integer.parseInt(colons[0])); } catch (NumberFormatException e) { } - } + } */ int quantity = 1; - short damage = 0; + PotionType potionType = null; if (colons.length > 1) quantity = Integer.parseInt(colons[1]); if (colons.length > 2) - damage = (short) Integer.parseInt(colons[2]); + potionType = PotionType.valueOf(colons[2]); // The material is either invalid or it is a custom item name if (mat != null) { - recipe.add(new RecipeIngredient(mat, quantity, damage)); + recipe.add(new RecipeIngredient(mat, quantity, potionType)); } else if (customItemNames.contains(colons[0])) { - recipe.add(new RecipeIngredient(colons[0], quantity, damage)); + recipe.add(new RecipeIngredient(colons[0], quantity, potionType)); } else { ProjectKorraItems.log.info(Messages.BAD_RECIPE_MAT + ": " + colons[0]); valid = false; - continue; } } while (recipe.size() < 9) { @@ -175,7 +188,7 @@ public void updateRecipe(String s, Set customItemNames) { } } catch (Exception e) { - ProjectKorraItems.log.info(Messages.BAD_RECIPE + ": " + s); + ProjectKorraItems.log.info(Messages.BAD_RECIPE + ": " + recipeStr); valid = false; } } @@ -188,12 +201,13 @@ public void build() { ProjectKorraItems.log.info(Messages.BAD_ITEM + ": " + toString()); else if (items.containsKey(name.toLowerCase())) ProjectKorraItems.log.info(Messages.DUPLICATE_ITEM + ": " + toString()); - else if (name.length() == 0) + else if (name.isEmpty()) ProjectKorraItems.log.info(Messages.BAD_NAME + ": " + toString()); - else if (displayName.length() == 0) + else if (displayName.isEmpty()) ProjectKorraItems.log.info(Messages.BAD_DNAME + ": " + toString()); - else if (material == null) - ProjectKorraItems.log.info(Messages.BAD_MATERIAL + ": " + toString()); + else if ((!isOraxen && material == null) || (isOraxen && oraxenId == null)) { + ProjectKorraItems.log.info(Messages.BAD_MATERIAL + "(219): " + toString()); + } else { items.put(name.toLowerCase(), this); itemList.add(this); @@ -201,38 +215,50 @@ else if (material == null) } public ItemStack generateItem() { - ItemStack istack = new ItemStack(material, quantity, damage); + ItemStack istack; + if (!isOraxen) { + istack = new ItemStack(material, quantity); + } + else { + istack = OraxenItems.getItemById(oraxenId).setAmount(1).build(); + istack.setAmount(1); + } ItemMeta meta = istack.getItemMeta(); - List tempLore = new ArrayList(lore); - meta.setDisplayName(displayName); - - for (Attribute attr : attributes) { - try { - if (attr.getName().equalsIgnoreCase("Charges")) - tempLore.add(AttributeList.CHARGES_STR + Integer.parseInt(attr.getValues().get(0))); - else if (attr.getName().equalsIgnoreCase("ClickCharges")) - tempLore.add(AttributeList.CLICK_CHARGES_STR + Integer.parseInt(attr.getValues().get(0))); - else if (attr.getName().equalsIgnoreCase("SneakCharges")) - tempLore.add(AttributeList.SNEAK_CHARGES_STR + Integer.parseInt(attr.getValues().get(0))); + if (meta != null) { + meta.setDisplayName(displayName); + List tempLore = meta.hasLore() ? meta.getLore() : new ArrayList<>(); + if (tempLore == null) { + tempLore = new ArrayList<>(); } - catch (Exception e) { + tempLore.addAll(lore); + + for (Attribute attr : attributes) { + try { + if (attr.getName().equalsIgnoreCase("Charges")) + tempLore.add(AttributeList.CHARGES_STR + Integer.parseInt(attr.getValues().getFirst())); + else if (attr.getName().equalsIgnoreCase("ClickCharges")) + tempLore.add(AttributeList.CLICK_CHARGES_STR + Integer.parseInt(attr.getValues().getFirst())); + else if (attr.getName().equalsIgnoreCase("SneakCharges")) + tempLore.add(AttributeList.SNEAK_CHARGES_STR + Integer.parseInt(attr.getValues().getFirst())); + } catch (Exception ignored) { } + + try { + if (attr.getName().equalsIgnoreCase("LeatherColor")) { + LeatherArmorMeta lmeta = (LeatherArmorMeta) meta; + lmeta.setColor(Color.fromRGB(Integer.parseInt(attr.getValues().get(0).trim()), Integer.parseInt(attr.getValues().get(1).trim()), Integer.parseInt(attr.getValues().get(2).trim()))); + meta = lmeta; + } + } catch (Exception ignored) { } } - try { - if (attr.getName().equalsIgnoreCase("LeatherColor")) { - LeatherArmorMeta lmeta = (LeatherArmorMeta) meta; - lmeta.setColor(Color.fromRGB(Integer.parseInt(attr.getValues().get(0).trim()), Integer.parseInt(attr.getValues().get(1).trim()), Integer.parseInt(attr.getValues().get(2).trim()))); - meta = lmeta; - } - } - catch (Exception e) { - } - } + meta.setLore(tempLore); - meta.setLore(tempLore); - istack.setItemMeta(meta); - if (glow) - EnchantGlow.addGlow(istack); + PersistentDataContainer itemDC = meta.getPersistentDataContainer(); + itemDC.set(PKI_KEY, PersistentDataType.STRING, name); + + meta.setEnchantmentGlintOverride(glow); + istack.setItemMeta(meta); + } return istack; } @@ -240,7 +266,6 @@ else if (attr.getName().equalsIgnoreCase("SneakCharges")) /** * Checks if a CustomItem has a specific attribute, and also that the * attribute has a boolean value of true. - * * If the value is false, or it was not found, then this returns false. * * @param attrib the name of the attribute @@ -255,11 +280,11 @@ public boolean getBooleanAttributeValue(String attrib) { return false; } - public static ConcurrentHashMap getItems() { + public static Map getItems() { return items; } - public static void setItems(ConcurrentHashMap items) { + public static void setItems(Map items) { PKItem.items = items; } @@ -279,11 +304,11 @@ public void setDisplayName(String displayName) { this.displayName = displayName; } - public ArrayList getLore() { + public List getLore() { return lore; } - public void setLore(ArrayList lore) { + public void setLore(List lore) { this.lore = lore; } @@ -291,7 +316,7 @@ public Material getMaterial() { return material; } - public ArrayList getAttributes() { + public List getAttributes() { return attributes; } @@ -311,13 +336,15 @@ public Attribute getAttribute(String attrName) { return null; } - public void setAttributes(ArrayList attributes) { + public void setAttributes(List attributes) { this.attributes = attributes; } + /* public void setDamage(short damage) { this.damage = damage; } + */ public void setMaterial(Material material) { this.material = material; @@ -331,6 +358,7 @@ public void setQuantity(int quantity) { this.quantity = quantity; } + /* public short getDamage() { return damage; } @@ -338,12 +366,13 @@ public short getDamage() { public void setData(short damage) { this.damage = damage; } + */ - public ArrayList getRecipe() { + public List getRecipe() { return recipe; } - public void setRecipe(ArrayList recipe) { + public void setRecipe(List recipe) { this.recipe = recipe; } @@ -365,7 +394,8 @@ public void setValid(boolean valid) { @Override public String toString() { - return "CustomItem [name=" + name + ", displayName=" + displayName + ", lore=" + lore + ", material=" + material + ", quantity=" + quantity + ", damage=" + damage; + // return "CustomItem [name=" + name + ", displayName=" + displayName + ", lore=" + lore + ", material=" + material + ", quantity=" + quantity + ", damage=" + damage; + return "CustomItem [name=" + name + ", displayName=" + displayName + ", lore=" + lore + ", material=" + material + ", isOraxen=" + isOraxen + ", oraxenId=" + oraxenId + ", quantity=" + quantity + "]"; } public static String colorizeString(String s) { @@ -376,20 +406,21 @@ public static String colorizeString(String s) { } public static PKItem getCustomItem(ItemStack istack) { - - if (istack == null) + String name = getIdByItem(istack); + + if (name == null) return null; - - ItemMeta meta = istack.getItemMeta(); - - if (meta == null || meta.getDisplayName() == null) + + return getCustomItem(name); + } + + public static String getIdByItem(ItemStack istack) { + if (istack == null || istack.getItemMeta() == null) return null; - - for (PKItem citem : items.values()) { - if (meta.getDisplayName().equals(citem.getDisplayName())) - return citem; - } - return null; + + PersistentDataContainer itemDC = istack.getItemMeta().getPersistentDataContainer(); + + return itemDC.get(PKI_KEY, PersistentDataType.STRING); } public static PKItem getCustomItem(String itemName) { diff --git a/src/com/projectkorra/items/customs/RecipeIngredient.java b/src/main/java/com/projectkorra/items/customs/RecipeIngredient.java similarity index 61% rename from src/com/projectkorra/items/customs/RecipeIngredient.java rename to src/main/java/com/projectkorra/items/customs/RecipeIngredient.java index 69c72dd..72f5079 100644 --- a/src/com/projectkorra/items/customs/RecipeIngredient.java +++ b/src/main/java/com/projectkorra/items/customs/RecipeIngredient.java @@ -5,32 +5,34 @@ import org.bukkit.Material; import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.meta.PotionMeta; +import org.bukkit.potion.PotionType; public class RecipeIngredient { private String customItemName; private Material material; private int quantity; - private short damage; + private PotionType potionType; private boolean isCustomItem; - private RecipeIngredient(String customItemName, Material material, int quantity, short damage, boolean isCustomItem) { + private RecipeIngredient(String customItemName, Material material, int quantity, PotionType potionType, boolean isCustomItem) { this.customItemName = customItemName; this.material = material; this.quantity = quantity; - this.damage = damage; + this.potionType = potionType; this.isCustomItem = isCustomItem; } - public RecipeIngredient(Material material, int quantity, short damage) { - this(null, material, quantity, damage, false); + public RecipeIngredient(Material material, int quantity, PotionType potionType) { + this(null, material, quantity, potionType, false); } - public RecipeIngredient(String customItemName, int quantity, short damage) { - this(customItemName, null, quantity, damage, true); + public RecipeIngredient(String customItemName, int quantity, PotionType potionType) { + this(customItemName, null, quantity, potionType, true); } public RecipeIngredient(Material material, int quantity) { - this(material, quantity, (short) 0); + this(material, quantity, null); } public RecipeIngredient(Material mat) { @@ -61,12 +63,12 @@ public void setQuantity(int quantity) { this.quantity = quantity; } - public short getDamage() { - return damage; + public PotionType getPotionType() { + return potionType; } - public void setDamage(short damage) { - this.damage = damage; + public void setDamage(PotionType potionType) { + this.potionType = potionType; } public boolean isCustomItem() { @@ -89,13 +91,21 @@ public ItemStack getItemStack() { return new ItemStack(Material.AIR); } } else { - return new ItemStack(material, quantity, damage); + ItemStack istack = new ItemStack(material, quantity); + if (material == Material.POTION && potionType != null) { + PotionMeta pmeta = (PotionMeta) istack.getItemMeta(); + if (pmeta != null) { + pmeta.setBasePotionType(potionType); + istack.setItemMeta(pmeta); + } + } + return istack; } } @Override public String toString() { - return "RecipeIngredient [customItemName=" + customItemName + ", material=" + material + ", quantity=" + quantity + ", damage=" + damage + ", isCustomItem=" + isCustomItem + "]"; + return "RecipeIngredient [customItemName=" + customItemName + ", material=" + material + ", quantity=" + quantity + ", potionType=" + potionType + ", isCustomItem=" + isCustomItem + "]"; } } diff --git a/src/com/projectkorra/items/items/Glider.java b/src/main/java/com/projectkorra/items/items/Glider.java similarity index 89% rename from src/com/projectkorra/items/items/Glider.java rename to src/main/java/com/projectkorra/items/items/Glider.java index f6d1be5..e204bd2 100644 --- a/src/com/projectkorra/items/items/Glider.java +++ b/src/main/java/com/projectkorra/items/items/Glider.java @@ -1,6 +1,6 @@ package com.projectkorra.items.items; -import java.util.concurrent.ConcurrentHashMap; +import java.util.Map; import org.bukkit.Location; import org.bukkit.Material; @@ -25,10 +25,10 @@ public class Glider { * if the items that they are using have charges. Players must be Airbenders * to glide. * - * @param p the player that will glide + * @param player the player that will glide */ - public Glider(Player p) { - this(p, false); + public Glider(Player player) { + this(player, false); } /** @@ -38,11 +38,10 @@ public Glider(Player p) { * if the items that they are using have charges. Players must be Airbenders * to glide. * - * @param p the player that will glide + * @param player the player that will glide * @param auto if the gliding should start automatically without sneaking */ - public Glider(Player p, final boolean auto) { - final Player player = p; + public Glider(Player player, final boolean auto) { BendingPlayer bplayer = BendingPlayer.getBendingPlayer(player.getName()); if (player == null || bplayer == null) return; @@ -63,7 +62,7 @@ public void run() { return; } - ConcurrentHashMap attribs = AttributeUtils.getSimplePlayerAttributeMap(player); + Map attribs = AttributeUtils.getSimplePlayerAttributeMap(player); if ((!player.isSneaking() && !auto) || (player.isSneaking() && auto)) { this.cancel(); return; diff --git a/src/com/projectkorra/items/attribute/AttributeListener.java b/src/main/java/com/projectkorra/items/listeners/AttributeListener.java similarity index 58% rename from src/com/projectkorra/items/attribute/AttributeListener.java rename to src/main/java/com/projectkorra/items/listeners/AttributeListener.java index 344b1ab..406a7a6 100644 --- a/src/com/projectkorra/items/attribute/AttributeListener.java +++ b/src/main/java/com/projectkorra/items/listeners/AttributeListener.java @@ -1,27 +1,45 @@ -package com.projectkorra.items.attribute; +package com.projectkorra.items.listeners; +import java.util.List; +import java.util.Map; import java.util.concurrent.ConcurrentHashMap; -import org.bukkit.Material; +import com.projectkorra.items.attribute.Action; +import com.projectkorra.items.attribute.Attribute; +import com.projectkorra.items.customs.PKItem; +import com.projectkorra.items.processors.EquipmentProcessor; +import com.projectkorra.projectkorra.BendingPlayer; +import com.projectkorra.projectkorra.Element; +import org.bukkit.Bukkit; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; import org.bukkit.event.Listener; -import org.bukkit.event.player.PlayerAnimationEvent; -import org.bukkit.event.player.PlayerItemConsumeEvent; -import org.bukkit.event.player.PlayerItemHeldEvent; -import org.bukkit.event.player.PlayerToggleSneakEvent; -import org.bukkit.inventory.ItemStack; +import org.bukkit.event.player.*; import com.projectkorra.items.items.Glider; import com.projectkorra.items.utils.AttributeUtils; import com.projectkorra.items.utils.ItemUtils; +import org.bukkit.inventory.ItemStack; +import org.bukkit.plugin.Plugin; public class AttributeListener implements Listener { /** * A map of player names that holds their current bending potion effects. **/ - public static final ConcurrentHashMap> currentBendingEffects = new ConcurrentHashMap>(); + public static final Map> currentBendingEffects = new ConcurrentHashMap<>(); + private final EquipmentProcessor processor; + private final Plugin plugin; + + public AttributeListener(Plugin plugin) { + this.plugin = plugin; + processor = new EquipmentProcessor(plugin); + processor.start(); + } + + public void stop() { + processor.stop(); + } /** * When the player sneaks we should attempt to let them Glide. The Glider @@ -37,12 +55,10 @@ public void onPlayerSneak(PlayerToggleSneakEvent event) { Player player = event.getPlayer(); new Glider(player); - // new GrapplingHook(player, Action.SHIFT); // Handles the Charges, and ShiftCharges attribute if (!player.isSneaking()) { ItemUtils.updateOnActionEffects(player, Action.SHIFT); - ItemUtils.handleItemSource(player, "WaterSource", new ItemStack(Material.POTION)); } } @@ -58,9 +74,6 @@ public void onPlayerSwing(PlayerAnimationEvent event) { return; Player player = event.getPlayer(); ItemUtils.updateOnActionEffects(player, Action.LEFT_CLICK); - ItemUtils.handleItemSource(player, "WaterSource", new ItemStack(Material.POTION)); - - // new GrapplingHook(player, Action.LEFTCLICK); } /** @@ -88,9 +101,32 @@ public void onChangeItem(PlayerItemHeldEvent event) { return; Player player = event.getPlayer(); - ConcurrentHashMap attribs = AttributeUtils.getSimplePlayerAttributeMap(player); + Map attribs = AttributeUtils.getSimplePlayerAttributeMap(player); boolean auto = Attribute.getBooleanValue("AirGlideAutomatic", attribs); - if (auto) + if (auto) { new Glider(player, true); + } + } + + @EventHandler(priority = EventPriority.HIGH) + public void onPlayerJoin(PlayerJoinEvent event) { + Bukkit.getScheduler().runTaskLater(plugin, () -> { + BendingPlayer bendingPlayer = BendingPlayer.getBendingPlayer(event.getPlayer()); + if (bendingPlayer == null || !bendingPlayer.hasElement(Element.WATER)) { + return; + } + List equipment = ItemUtils.getPlayerValidEquipment(event.getPlayer()); + for (ItemStack istack : equipment) { + PKItem citem = PKItem.getCustomItem(istack); + if (citem == null) + continue; + for (Attribute attr : citem.getAttributes()) { + if (attr.getName().equals("WaterSource")) { + bendingPlayer.setWaterPouch(true); + return; + } + } + } + }, 20); } } diff --git a/src/com/projectkorra/items/PKIListener.java b/src/main/java/com/projectkorra/items/listeners/PKIListener.java similarity index 90% rename from src/com/projectkorra/items/PKIListener.java rename to src/main/java/com/projectkorra/items/listeners/PKIListener.java index 34a9e09..f3fe524 100644 --- a/src/com/projectkorra/items/PKIListener.java +++ b/src/main/java/com/projectkorra/items/listeners/PKIListener.java @@ -1,8 +1,8 @@ -package com.projectkorra.items; +package com.projectkorra.items.listeners; -import java.util.ArrayList; -import java.util.concurrent.ConcurrentHashMap; +import java.util.*; +import com.projectkorra.items.ProjectKorraItems; import org.bukkit.Bukkit; import org.bukkit.Material; import org.bukkit.entity.HumanEntity; @@ -18,9 +18,9 @@ import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.event.player.PlayerItemConsumeEvent; import org.bukkit.event.player.PlayerItemHeldEvent; -import org.bukkit.event.player.PlayerToggleSneakEvent; import org.bukkit.inventory.Inventory; import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.meta.PotionMeta; import org.bukkit.scheduler.BukkitRunnable; import com.projectkorra.items.attribute.Action; @@ -53,30 +53,27 @@ public void onCraftingPlace(InventoryClickEvent event) { return; new BukkitRunnable() { - @SuppressWarnings("unchecked") public void run() { - Player player = (Player) humEnt; + // Player player = (Player) humEnt; ItemStack[] tempInvItems = fevent.getInventory().getContents(); - ArrayList originalInvItems = new ArrayList(); - - for (ItemStack istack : tempInvItems) - originalInvItems.add(istack); + List originalInvItems = new ArrayList<>(Arrays.asList(tempInvItems)); /* * Remove the resultant slot because we don't wish to consider it for the purpose of * calculating the recipe. */ originalInvItems.remove(0); - ArrayList invItemsClone = (ArrayList) originalInvItems.clone(); + + List invItemsClone = new ArrayList<>(); for (PKItem citem : PKItem.items.values()) { if (citem.getRecipe().size() == 0) continue; - ArrayList recipeClone = (ArrayList) citem.getRecipe().clone(); + List recipeClone = new ArrayList<>(citem.getRecipe()); boolean validShape = true; int maxQuantity = Integer.MAX_VALUE; - invItemsClone = (ArrayList) originalInvItems.clone(); + invItemsClone = new ArrayList<>(originalInvItems); for (int i = 0; i < recipeClone.size(); i++) { RecipeIngredient ing = recipeClone.get(i); @@ -96,13 +93,14 @@ public void run() { recipeClone.remove(i); invItemsClone.remove(j); i--; - j--; break; } else if (item.getAmount() >= ing.getQuantity()) { // We don't actually care to check the damage value if the // ingredient is a custom item if (!ing.isCustomItem() && ing.getMaterial() == item.getType() - && item.getDurability() == ing.getDamage() + && ing.getMaterial() == Material.POTION + && item.getItemMeta() != null && item.getItemMeta() instanceof PotionMeta + && ing.getPotionType() == ((PotionMeta) item.getItemMeta()).getBasePotionData().getType() || (citemInSlot != null && citemInSlot.getName().equals(ing.getCustomItemName()))) { // Calculate the least possible maximum quantity that can result @@ -115,7 +113,6 @@ public void run() { recipeClone.remove(i); invItemsClone.remove(j); i--; - j--; break; } } @@ -132,7 +129,7 @@ public void run() { ItemStack newItem = citem.generateItem(); newItem.setAmount(maxQuantity * newItem.getAmount()); fevent.getInventory().setItem(0, newItem); - player.updateInventory(); + // player.updateInventory(); return; } } @@ -149,7 +146,6 @@ public void run() { * * @param event the click event */ - @SuppressWarnings("unchecked") @EventHandler(priority = EventPriority.NORMAL) public void onGrabResultItem(InventoryClickEvent event) { if (event.isCancelled() || event.getSlotType() != SlotType.RESULT || event.getSlot() != 0 @@ -176,11 +172,9 @@ public void onGrabResultItem(InventoryClickEvent event) { * will remain in the crafting bench. */ ItemStack[] tempInvItems = event.getInventory().getContents(); - ArrayList recipeClone = (ArrayList) citem.getRecipe().clone(); - ArrayList invItems = new ArrayList(); + List recipeClone = new ArrayList<>(citem.getRecipe()); - for (ItemStack istack : tempInvItems) - invItems.add(istack); + List invItems = new ArrayList<>(Arrays.asList(tempInvItems)); invItems.set(0, new ItemStack(Material.AIR)); @@ -193,7 +187,9 @@ public void onGrabResultItem(InventoryClickEvent event) { ItemStack istack = invItems.get(i); PKItem istackCustomItem = PKItem.getCustomItem(istack); - if (!ing.isCustomItem() && istack.getDurability() != ing.getDamage()) { + if (!ing.isCustomItem() && ing.getMaterial() == Material.POTION + && istack.getItemMeta() != null + && ing.getPotionType() != ((PotionMeta) istack.getItemMeta()).getBasePotionData().getType()) { continue; } else if (!ing.isCustomItem() && istack.getType() != ing.getMaterial()) { continue; @@ -210,7 +206,7 @@ public void onGrabResultItem(InventoryClickEvent event) { } else if (ingQuantity == itemQuantity) { invItems.set(i, new ItemStack(Material.AIR)); break; - } else if (ingQuantity < itemQuantity) { + } else { istack.setAmount(itemQuantity - ingQuantity); break; } @@ -221,9 +217,9 @@ public void onGrabResultItem(InventoryClickEvent event) { event.getInventory().clear(); player.setItemOnCursor(curItem); - final ItemStack[] finalItems = invItems.toArray(new ItemStack[invItems.size()]); + final ItemStack[] finalItems = invItems.toArray(new ItemStack[0]); final InventoryClickEvent fevent = event; - final Player fplayer = player; + //final Player fplayer = player; /* * Update the players inventory on a short delay so that they see the newly calculated @@ -232,7 +228,7 @@ public void onGrabResultItem(InventoryClickEvent event) { new BukkitRunnable() { public void run() { fevent.getInventory().setContents(finalItems); - fplayer.updateInventory(); + // fplayer.updateInventory(); // Not needed anymore } }.runTaskLater(ProjectKorraItems.plugin, 1); } @@ -361,6 +357,7 @@ public void onCloseDisplayInv(InventoryCloseEvent event) { * * @param event the click event */ + /* @EventHandler(priority = EventPriority.NORMAL) public void onAnvilItemPlace(InventoryClickEvent event) { if (event.isCancelled() || event.getInventory().getType() != InventoryType.ANVIL) @@ -374,13 +371,12 @@ public void onAnvilItemPlace(InventoryClickEvent event) { return; PKItem citem = PKItem.getCustomItem(cursorItem); - if (citem == null) - return; - else { + if (citem != null) { event.setCancelled(true); player.sendMessage(Messages.NO_ANVIL); } } + */ /** * When a player changes their currently held item, we need to check if the item was being @@ -399,6 +395,7 @@ public void onPlayerItemChange(PlayerItemHeldEvent event) { * * @param event a sneak event */ + /* DUPLICATED IN AttributeListener @EventHandler(priority = EventPriority.NORMAL) public void onPlayerSneak(PlayerToggleSneakEvent event) { if (event.isCancelled()) @@ -411,9 +408,10 @@ public void onPlayerSneak(PlayerToggleSneakEvent event) { // Handles the Charges, and ShiftCharges attribute if (!player.isSneaking()) { ItemUtils.updateOnActionEffects(player, Action.SHIFT); - ItemUtils.handleItemSource(player, "WaterSource", new ItemStack(Material.POTION)); + ItemUtils.handleItemSource(player, "WaterSource", ItemUtils.getWaterBottles(1)); } } + */ /** * Confirm if an ability was executed via clicking. Also handle specific stats that related to @@ -430,7 +428,7 @@ public void onPlayerInteract(PlayerInteractEvent event) { if (a == org.bukkit.event.block.Action.LEFT_CLICK_AIR || a == org.bukkit.event.block.Action.LEFT_CLICK_BLOCK) { ItemUtils.updateOnActionEffects(player, Action.LEFT_CLICK); - ItemUtils.handleItemSource(player, "WaterSource", new ItemStack(Material.POTION)); + // ItemUtils.handleItemSource(player, "WaterSource", ItemUtils.getWaterBottles(1)); } else if (a == org.bukkit.event.block.Action.RIGHT_CLICK_AIR || a == org.bukkit.event.block.Action.RIGHT_CLICK_BLOCK) { } @@ -462,7 +460,7 @@ public void onChangeItem(PlayerItemHeldEvent event) { return; Player player = event.getPlayer(); - ConcurrentHashMap attribs = AttributeUtils.getSimplePlayerAttributeMap(player); + Map attribs = AttributeUtils.getSimplePlayerAttributeMap(player); boolean auto = Attribute.getBooleanValue("AirGlideAutomatic", attribs); if (auto) new Glider(player, true); diff --git a/src/main/java/com/projectkorra/items/processors/EquipmentProcessor.java b/src/main/java/com/projectkorra/items/processors/EquipmentProcessor.java new file mode 100644 index 0000000..5c835a3 --- /dev/null +++ b/src/main/java/com/projectkorra/items/processors/EquipmentProcessor.java @@ -0,0 +1,60 @@ +package com.projectkorra.items.processors; + +import com.projectkorra.items.attribute.Attribute; +import com.projectkorra.items.customs.PKItem; +import com.projectkorra.projectkorra.BendingPlayer; +import org.bukkit.Bukkit; +import org.bukkit.entity.Player; +import org.bukkit.inventory.EntityEquipment; +import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.PlayerInventory; +import org.bukkit.plugin.Plugin; + +import java.util.*; + +public class EquipmentProcessor extends PoolProcessor { + + public EquipmentProcessor(Plugin plugin) { + super(plugin); + } + + public void add(UUID id){ + add(() -> process(id)); + } + + private boolean hasWaterPouchAttr(ItemStack itemStack) { + PKItem item = PKItem.getCustomItem(itemStack); + if (item == null) + return false; + for (Attribute attr : item.getAttributes()) { + if (attr.getName().equals("WaterSource")) + return true; + } + return false; + } + + private boolean hasWaterPouchAttr(ItemStack[] itemStacks) { + for (ItemStack stack : itemStacks) { + if (hasWaterPouchAttr(stack)) + return true; + } + return false; + } + + public void process(UUID playerId) { + Player player = Bukkit.getPlayer(playerId); + if (player == null) + return; + + BendingPlayer bendingPlayer = BendingPlayer.getBendingPlayer(player); + if (bendingPlayer == null) + return; + + PlayerInventory equipment = player.getInventory(); + + boolean hasWaterPouch = hasWaterPouchAttr(equipment.getArmorContents()) + || hasWaterPouchAttr(equipment.getStorageContents()) + || hasWaterPouchAttr(equipment.getExtraContents()); + bendingPlayer.setWaterPouch(hasWaterPouch); + } +} diff --git a/src/main/java/com/projectkorra/items/processors/PoolProcessor.java b/src/main/java/com/projectkorra/items/processors/PoolProcessor.java new file mode 100644 index 0000000..9a20bdb --- /dev/null +++ b/src/main/java/com/projectkorra/items/processors/PoolProcessor.java @@ -0,0 +1,66 @@ +// Extracted from Crazy-Crew/CrazyEnchantments project, under MIT license. +package com.projectkorra.items.processors; + +import com.projectkorra.items.schedulers.FoliaRunnable; +import io.papermc.paper.threadedregions.scheduler.ScheduledTask; +import org.bukkit.plugin.Plugin; +import java.util.concurrent.LinkedBlockingQueue; +import java.util.concurrent.ThreadPoolExecutor; +import java.util.concurrent.TimeUnit; + +public abstract class PoolProcessor { + + private final Plugin plugin; + + private ThreadPoolExecutor executor = null; + + private final int maxQueueSize = 10000; + + private ScheduledTask taskId; + + public PoolProcessor(Plugin plugin) { + this.plugin = plugin; + start(); + } + + /** + * Adds the task into the thread pool to be processed. + * @param process The {@link Runnable} to process. + */ + public void add(final Runnable process) { + executor.submit(process); + } + + /** + * Creates the thread pool used to process tasks. + */ + public void start() { + if (executor == null) executor = new ThreadPoolExecutor(1, 10, 60L, TimeUnit.SECONDS, new LinkedBlockingQueue<>(maxQueueSize)); + executor.allowCoreThreadTimeOut(true); + resizeChecker(); + } + + /** + * Terminates the thread pool. + */ + public void stop() { + taskId.cancel(); + executor.shutdown(); + executor = null; + } + + /** + * Used to increase the default workers in the thread pool. + * This should ensure that with a higher player count, that all tasks are processed. + */ + private void resizeChecker() { + taskId = new FoliaRunnable(this.plugin.getServer().getAsyncScheduler(), TimeUnit.SECONDS) { + @Override + public void run() { + if ((executor.getQueue().size() / executor.getCorePoolSize() > maxQueueSize / 5) && !(executor.getMaximumPoolSize() <= executor.getCorePoolSize() + 1)) { + executor.setCorePoolSize(executor.getCorePoolSize() + 1); + } + } + }.runAtFixedRate(plugin, 20, 100); + } +} diff --git a/src/main/java/com/projectkorra/items/schedulers/FoliaRunnable.java b/src/main/java/com/projectkorra/items/schedulers/FoliaRunnable.java new file mode 100644 index 0000000..0f60f1c --- /dev/null +++ b/src/main/java/com/projectkorra/items/schedulers/FoliaRunnable.java @@ -0,0 +1,179 @@ +// Extracted from Crazy-Crew/CrazyEnchantments project, under MIT license. +package com.projectkorra.items.schedulers; + +import io.papermc.paper.threadedregions.scheduler.*; +import org.bukkit.Location; +import org.bukkit.World; +import org.bukkit.plugin.Plugin; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +import java.util.concurrent.TimeUnit; + +public abstract class FoliaRunnable implements Runnable { + + private ScheduledTask task; + private @Nullable AsyncScheduler asyncScheduler; + private @Nullable TimeUnit timeUnit; + private @Nullable EntityScheduler entityScheduler; + private @Nullable Runnable entityRetired; + private @Nullable GlobalRegionScheduler globalRegionScheduler; + private @Nullable RegionScheduler regionScheduler; + private @Nullable Location location; + private @Nullable World world; + private int chunkX; + private int chunkZ; + + + public FoliaRunnable(@NotNull AsyncScheduler scheduler, @Nullable TimeUnit timeUnit) { + this.asyncScheduler = scheduler; + this.timeUnit = timeUnit; + } + + public FoliaRunnable(@NotNull EntityScheduler scheduler, @Nullable Runnable retired) { + this.entityScheduler = scheduler; + this.entityRetired = retired; + } + + public FoliaRunnable(@NotNull GlobalRegionScheduler scheduler) { + this.globalRegionScheduler = scheduler; + } + + public FoliaRunnable(@NotNull RegionScheduler scheduler, @Nullable Location location) { + this.regionScheduler = scheduler; + this.location = location; + } + + public FoliaRunnable(@NotNull RegionScheduler scheduler, @Nullable World world, int chunkX, int chunkZ) { + this.regionScheduler = scheduler; + this.world = world; + this.chunkX = chunkX; + this.chunkZ = chunkZ; + } + + public boolean isCancelled() throws IllegalStateException { + checkScheduled(); + return task.isCancelled(); + } + + public void cancel() throws IllegalStateException { + task.cancel(); + } + + @NotNull + public ScheduledTask run(@NotNull Plugin plugin) throws IllegalArgumentException, IllegalStateException { + checkNotYetScheduled(); + if (this.globalRegionScheduler != null) { + return setupTask(this.globalRegionScheduler.run(plugin, scheduledTask -> this.run())); + } else if (this.entityScheduler != null) { + return setupTask(this.entityScheduler.run(plugin, scheduledTask -> this.run(), entityRetired)); + } else if (this.regionScheduler != null) { + if (this.location != null) { + return setupTask(this.regionScheduler.run(plugin, location, scheduledTask -> this.run())); + } else if (world != null) { + return setupTask(this.regionScheduler.run(plugin, world, chunkX, chunkZ, scheduledTask -> this.run())); + } else { + throw new UnsupportedOperationException("The region type is not supported."); + } + } else if (this.asyncScheduler != null) { + return setupTask(this.asyncScheduler.runNow(plugin, scheduledTask -> this.run())); + } else { + throw new UnsupportedOperationException("The task type is not supported."); + } + } + + /** + * Schedules this to run after the specified number of server ticks. + * + * @param plugin the reference to the plugin scheduling task + * @param delay the ticks to wait before running the task + * @return a ScheduledTask that contains the id number + * @throws IllegalArgumentException if plugin is null + * @throws IllegalStateException if this was already scheduled + */ + @NotNull + public ScheduledTask runDelayed(@NotNull Plugin plugin, long delay) throws IllegalArgumentException, IllegalStateException { + checkNotYetScheduled(); + delay = Math.max(1, delay); + if (this.globalRegionScheduler != null) { + return setupTask(this.globalRegionScheduler.runDelayed(plugin, scheduledTask -> this.run(), delay)); + } else if (this.entityScheduler != null) { + return setupTask(this.entityScheduler.runDelayed(plugin, scheduledTask -> this.run(), entityRetired, delay)); + } else if (this.regionScheduler != null) { + if (this.location != null) { + return setupTask(this.regionScheduler.runDelayed(plugin, location, scheduledTask -> this.run(), delay)); + } else if (world != null) { + return setupTask(this.regionScheduler.runDelayed(plugin, world, chunkX, chunkZ, scheduledTask -> this.run(), delay)); + } else { + throw new UnsupportedOperationException("The region type is not supported."); + } + } else if (this.asyncScheduler != null && this.timeUnit != null) { + return setupTask(this.asyncScheduler.runDelayed(plugin, scheduledTask -> this.run(), delay, timeUnit)); + } else { + throw new UnsupportedOperationException("The task type is not supported."); + } + } + + /** + * Schedules this to repeatedly run until cancelled, starting after the + * specified number of server ticks. + * + * @param plugin the reference to the plugin scheduling task + * @param delay the ticks to wait before running the task + * @param period the ticks to wait between runs + * @return a ScheduledTask that contains the id number + * @throws IllegalArgumentException if plugin is null + * @throws IllegalStateException if this was already scheduled + */ + public ScheduledTask runAtFixedRate(@NotNull Plugin plugin, long delay, long period) throws IllegalArgumentException, IllegalStateException { + checkNotYetScheduled(); + delay = Math.max(1, delay); + period = Math.max(1, period); + if (this.globalRegionScheduler != null) { + return setupTask(this.globalRegionScheduler.runAtFixedRate(plugin, scheduledTask -> this.run(), delay, period)); + } else if (this.entityScheduler != null) { + return setupTask(this.entityScheduler.runAtFixedRate(plugin, scheduledTask -> this.run(), entityRetired, delay, period)); + } else if (this.regionScheduler != null) { + if (this.location != null) { + return setupTask(this.regionScheduler.runAtFixedRate(plugin, location, scheduledTask -> this.run(), delay, period)); + } else if (world != null) { + return setupTask(this.regionScheduler.runAtFixedRate(plugin, world, chunkX, chunkZ, scheduledTask -> this.run(), delay, period)); + } else { + throw new UnsupportedOperationException("The region type is not supported."); + } + } else if (this.asyncScheduler != null && this.timeUnit != null) { + return setupTask(this.asyncScheduler.runAtFixedRate(plugin, scheduledTask -> this.run(), delay, period, timeUnit)); + } else { + throw new UnsupportedOperationException("The task type is not supported."); + } + } + + /** + * Gets the task id for this runnable. + * + * @return the task id that this runnable was scheduled as + * @throws IllegalStateException if task was not scheduled yet + */ + public int getTaskId() throws IllegalStateException { + checkScheduled(); + return task.hashCode(); + } + + private void checkScheduled() { + if (task == null) { + throw new IllegalStateException("Not scheduled yet"); + } + } + + private void checkNotYetScheduled() { + if (task != null) { + throw new IllegalStateException("Already scheduled as " + task.hashCode()); + } + } + + @NotNull + private ScheduledTask setupTask(final ScheduledTask task) { + this.task = task; + return task; + } +} diff --git a/src/com/projectkorra/items/utils/AttributeUtils.java b/src/main/java/com/projectkorra/items/utils/AttributeUtils.java similarity index 78% rename from src/com/projectkorra/items/utils/AttributeUtils.java rename to src/main/java/com/projectkorra/items/utils/AttributeUtils.java index f645b77..4829eb0 100644 --- a/src/com/projectkorra/items/utils/AttributeUtils.java +++ b/src/main/java/com/projectkorra/items/utils/AttributeUtils.java @@ -2,6 +2,7 @@ import java.util.ArrayList; import java.util.List; +import java.util.Map; import java.util.concurrent.ConcurrentHashMap; import org.bukkit.Material; @@ -15,7 +16,7 @@ import com.projectkorra.items.attribute.Action; import com.projectkorra.items.attribute.Attribute; import com.projectkorra.items.attribute.AttributeList; -import com.projectkorra.items.attribute.AttributeListener; +import com.projectkorra.items.listeners.AttributeListener; import com.projectkorra.items.customs.PKItem; import com.projectkorra.projectkorra.Element; @@ -29,14 +30,14 @@ public class AttributeUtils { * @param player the player to create the effects of * @return a map containing attribute effects */ - public static ConcurrentHashMap getSimplePlayerAttributeMap(Player player) { - ArrayList equipment = ItemUtils.getPlayerValidEquipment(player); - ConcurrentHashMap attribMap = new ConcurrentHashMap(); - ArrayList totalAttribs = new ArrayList(); + public static Map getSimplePlayerAttributeMap(Player player) { + List equipment = ItemUtils.getPlayerValidEquipment(player); + Map attribMap = new ConcurrentHashMap<>(); + List totalAttribs = new ArrayList<>(); /* Handle any potion style bending effects that the player might have */ if (AttributeListener.currentBendingEffects.containsKey(player.getName())) { - ConcurrentHashMap effects = AttributeListener.currentBendingEffects.get(player.getName()); + Map effects = AttributeListener.currentBendingEffects.get(player.getName()); for (Attribute effect : effects.values()) { if (System.currentTimeMillis() - effect.getTime() < effect.getDuration()) { totalAttribs.add(effect); @@ -49,12 +50,11 @@ public static ConcurrentHashMap getSimplePlayerAttributeMap(Play PKItem citem = PKItem.getCustomItem(istack); if (citem == null) continue; - for (Attribute attr : citem.getAttributes()) - totalAttribs.add(attr); + totalAttribs.addAll(citem.getAttributes()); } /* Handles the "Air", "Water", "Earth", and "Fire" stats */ - ArrayList fullElementAttribs = new ArrayList(); + List fullElementAttribs = new ArrayList<>(); for (Attribute attr : totalAttribs) { fullElementAttribs.addAll(getFullElementAttributes(attr)); } @@ -80,22 +80,20 @@ public static ConcurrentHashMap getSimplePlayerAttributeMap(Play * @param attr the attribute to split * @return a list of the new PotionEffects */ - public static ArrayList parsePotionEffects(Attribute attr) { - ArrayList effects = new ArrayList(); + public static List parsePotionEffects(Attribute attr) { + List effects = new ArrayList<>(); if (attr.getValues() == null) return effects; for (String val : attr.getValues()) { String[] colSplit = val.split(":"); - try { - PotionEffectType type = PotionEffectType.getByName(colSplit[0].trim()); + PotionEffectType type = PotionEffectType.getByName(colSplit[0].trim()); + if (type != null) { int strength = Integer.parseInt(colSplit[1].trim()); double duration = Double.parseDouble(colSplit[2].trim()); PotionEffect pot = new PotionEffect(type, (int) (duration * 20), strength - 1); effects.add(pot); } - catch (Exception e) { - } } return effects; } @@ -109,8 +107,8 @@ public static ArrayList parsePotionEffects(Attribute attr) { * @param attr the attribute containing a list of bending effects as values * @return a list of new attributes representing the bending effects */ - public static ArrayList parseBendingEffects(Attribute attr) { - ArrayList effects = new ArrayList(); + public static List parseBendingEffects(Attribute attr) { + List effects = new ArrayList<>(); if (attr.getValues() == null) return effects; @@ -131,7 +129,7 @@ public static ArrayList parseBendingEffects(Attribute attr) { final String modifier = colSplit[1].trim(); double duration = Double.parseDouble(colSplit[2].trim()); Attribute newAttr = new Attribute(Attribute.getAttribute(name)); - ArrayList vals = new ArrayList(); + List vals = new ArrayList<>(); vals.add(modifier); newAttr.setValues(vals); newAttr.setDuration(duration * 1000); @@ -156,34 +154,32 @@ public static void decreaseCharges(Player player, Action type) { if (player == null) return; - ArrayList istacks = ItemUtils.getPlayerValidEquipment(player); + List istacks = ItemUtils.getPlayerValidEquipment(player); for (ItemStack istack : istacks) { PKItem citem = PKItem.getCustomItem(istack); if (citem == null) continue; ItemMeta meta = istack.getItemMeta(); + if (meta == null) + continue; List lore = meta.getLore(); if (lore == null) continue; boolean displayDestroyMsg = false; - List newLore = new ArrayList(); + List newLore = new ArrayList<>(); for (String line : lore) { String newLine = line; - try { - if (line.startsWith(AttributeList.CHARGES_STR) || (line.startsWith(AttributeList.CLICK_CHARGES_STR) && type == Action.LEFT_CLICK || type == Action.RIGHT_CLICK || type == null) || (line.startsWith(AttributeList.SNEAK_CHARGES_STR) && type == Action.SHIFT || type == null)) { - String start = line.substring(0, line.indexOf(": ")); - String end = line.substring(line.indexOf(": ") + 1, line.length()); - end = end.trim(); - int val = Integer.parseInt(end) - 1; - if (val == 0) - displayDestroyMsg = true; - if (val >= 0) - newLine = start + ": " + val; - } - } - catch (Exception e) { + if (line.startsWith(AttributeList.CHARGES_STR) || (line.startsWith(AttributeList.CLICK_CHARGES_STR) && (type == Action.LEFT_CLICK || type == Action.RIGHT_CLICK || type == null)) || (line.startsWith(AttributeList.SNEAK_CHARGES_STR) && (type == Action.SHIFT || type == null))) { + String start = line.substring(0, line.indexOf(": ")); + String end = line.substring(line.indexOf(": ") + 1); + end = end.trim(); + int val = Integer.parseInt(end) - 1; + if (val == 0) + displayDestroyMsg = true; + if (val >= 0) + newLine = start + ": " + val; } newLore.add(newLine); } @@ -200,20 +196,16 @@ public static void decreaseCharges(Player player, Action type) { boolean hasChargesLeft = true; for (String line : newLore) { - try { - if (line.startsWith(AttributeList.CHARGES_STR) || line.startsWith(AttributeList.CLICK_CHARGES_STR) || line.startsWith(AttributeList.SNEAK_CHARGES_STR)) { - String tmpStr = line.substring(line.indexOf(": ") + 1, line.length()).trim(); - int value = Integer.parseInt(tmpStr); - if (value <= 0) - hasChargesLeft = false; - else { - hasChargesLeft = true; - break; - } + if (line.startsWith(AttributeList.CHARGES_STR) || line.startsWith(AttributeList.CLICK_CHARGES_STR) || line.startsWith(AttributeList.SNEAK_CHARGES_STR)) { + String tmpStr = line.substring(line.indexOf(": ") + 1).trim(); + int value = Integer.parseInt(tmpStr); + if (value <= 0) + hasChargesLeft = false; + else { + hasChargesLeft = true; + break; } } - catch (Exception e) { - } } /* @@ -229,7 +221,11 @@ public static void decreaseCharges(Player player, Action type) { if (istack.getAmount() > 1) { istack.setAmount(istack.getAmount() - 1); ItemStack newStack = citem.generateItem(); - ItemUtils.setLore(istack, newStack.getItemMeta().getLore()); + List aux = null; + if (newStack.getItemMeta() != null) { + aux = newStack.getItemMeta().getLore(); + } + ItemUtils.setLore(istack, aux); } else player.getInventory().remove(istack); } else { @@ -239,7 +235,11 @@ public static void decreaseCharges(Player player, Action type) { if (istack.getAmount() > 1) { armor[i].setAmount(armor[i].getAmount() - 1); ItemStack newStack = citem.generateItem(); - ItemUtils.setLore(armor[i], newStack.getItemMeta().getLore()); + List aux = null; + if (newStack.getItemMeta() != null) { + aux = newStack.getItemMeta().getLore(); + } + ItemUtils.setLore(armor[i], aux); } else armor[i] = new ItemStack(Material.AIR); break; @@ -260,7 +260,7 @@ public static void decreaseCharges(Player player, Action type) { * @param attr an attribute with an element as a name * @return a list of attributes for that element */ - public static ArrayList getFullElementAttributes(Attribute attr) { + public static List getFullElementAttributes(Attribute attr) { return getFullElementAttributes(attr.getName(), attr.getValueAsDouble()); } @@ -273,8 +273,8 @@ public static ArrayList getFullElementAttributes(Attribute attr) { * @param value the amount of benefit to give * @return a list of attributes for that element */ - public static ArrayList getFullElementAttributes(String name, double value) { - ArrayList lst = new ArrayList(); + public static List getFullElementAttributes(String name, double value) { + List lst = new ArrayList<>(); if (name == null) { return lst; } diff --git a/src/com/projectkorra/items/utils/ElementUtils.java b/src/main/java/com/projectkorra/items/utils/ElementUtils.java similarity index 84% rename from src/com/projectkorra/items/utils/ElementUtils.java rename to src/main/java/com/projectkorra/items/utils/ElementUtils.java index fdb4a6d..0c6a955 100644 --- a/src/com/projectkorra/items/utils/ElementUtils.java +++ b/src/main/java/com/projectkorra/items/utils/ElementUtils.java @@ -6,7 +6,7 @@ import com.projectkorra.projectkorra.BendingPlayer; import com.projectkorra.projectkorra.Element; import com.projectkorra.projectkorra.Element.SubElement; -import com.projectkorra.projectkorra.ability.EarthAbility; +import com.projectkorra.projectkorra.ability.ElementalAbility; public class ElementUtils { @@ -41,12 +41,7 @@ public static boolean hasElement(Player player, String element) { * @param mat the material to check * @return true if it is transparent */ - @SuppressWarnings("deprecation") public static boolean isTransparent(Material mat) { - for (int m : EarthAbility.getTransparentMaterial()) { - if (mat.getId() == m) - return true; - } - return false; + return ElementalAbility.getTransparentMaterialSet().contains(mat); } } diff --git a/src/com/projectkorra/items/utils/ItemUtils.java b/src/main/java/com/projectkorra/items/utils/ItemUtils.java similarity index 63% rename from src/com/projectkorra/items/utils/ItemUtils.java rename to src/main/java/com/projectkorra/items/utils/ItemUtils.java index ab0f74e..da27bcf 100644 --- a/src/com/projectkorra/items/utils/ItemUtils.java +++ b/src/main/java/com/projectkorra/items/utils/ItemUtils.java @@ -1,6 +1,5 @@ package com.projectkorra.items.utils; -import com.projectkorra.items.ProjectKorraItems; import com.projectkorra.items.attribute.Action; import com.projectkorra.items.attribute.Attribute; import com.projectkorra.items.attribute.AttributeList; @@ -12,10 +11,11 @@ import org.bukkit.inventory.PlayerInventory; import org.bukkit.inventory.meta.ItemMeta; import org.bukkit.potion.PotionEffect; -import org.bukkit.scheduler.BukkitRunnable; import java.util.ArrayList; +import java.util.Arrays; import java.util.List; +import java.util.Map; import java.util.concurrent.ConcurrentHashMap; public class ItemUtils { @@ -23,7 +23,7 @@ public class ItemUtils { /** * A map of player names that holds their current bending potion effects. **/ - public static final ConcurrentHashMap> currentBendingEffects = new ConcurrentHashMap>(); + public static final Map> currentBendingEffects = new ConcurrentHashMap<>(); /** @@ -32,12 +32,9 @@ public class ItemUtils { * @param player the player with the items * @return a list of items */ - @SuppressWarnings("deprecation") - public static ArrayList getPlayerEquipment(Player player) { - ArrayList istacks = new ArrayList(); - for (ItemStack istack : player.getInventory().getArmorContents()) - istacks.add(istack); - istacks.add(player.getItemInHand()); + public static List getPlayerEquipment(Player player) { + List istacks = new ArrayList<>(Arrays.asList(player.getInventory().getArmorContents())); + istacks.add(player.getInventory().getItemInMainHand()); return istacks; } @@ -50,13 +47,12 @@ public static ArrayList getPlayerEquipment(Player player) { * @param player the player that has equipment * @return a list of the equipment */ - @SuppressWarnings("deprecation") - public static ArrayList getPlayerValidEquipment(Player player) { + public static List getPlayerValidEquipment(Player player) { if (player == null) { - return new ArrayList(); + return new ArrayList<>(); } - ArrayList equipment = getPlayerEquipment(player); + List equipment = getPlayerEquipment(player); /* * Get any inventory items that contain the "AllowFromInventory" stat. @@ -81,9 +77,9 @@ public static ArrayList getPlayerValidEquipment(Player player) { boolean keepItem = true; if (!hasValidCharges(istack)) { keepItem = false; - } else if (citem.getBooleanAttributeValue("HoldOnly") && !istack.equals(player.getItemInHand())) { + } else if (citem.getBooleanAttributeValue("HoldOnly") && !istack.equals(player.getInventory().getItemInMainHand())) { keepItem = false; - } else if (citem.getBooleanAttributeValue("WearOnly") && istack.equals(player.getItemInHand())) { + } else if (citem.getBooleanAttributeValue("WearOnly") && istack.equals(player.getInventory().getItemInMainHand())) { keepItem = false; } else if (!AttributeUtils.hasRequiredElement(player, citem)) { keepItem = false; @@ -96,7 +92,6 @@ public static ArrayList getPlayerValidEquipment(Player player) { if (!keepItem) { equipment.remove(i); i--; - continue; } } return equipment; @@ -111,22 +106,21 @@ public static ArrayList getPlayerValidEquipment(Player player) { */ public static boolean hasValidCharges(ItemStack item) { boolean validCharges = true; - try { - for (String line : item.getItemMeta().getLore()) { - if (line.startsWith(AttributeList.CHARGES_STR) || line.startsWith(AttributeList.CLICK_CHARGES_STR) || line.startsWith(AttributeList.SNEAK_CHARGES_STR)) { - String tmpStr = line.substring(line.indexOf(": ") + 1, line.length()).trim(); - int value = Integer.parseInt(tmpStr); - if (value <= 0) - validCharges = false; - else { - validCharges = true; - break; - } + if (item.getItemMeta() == null || item.getItemMeta().getLore() == null) { + return true; + } + for (String line : item.getItemMeta().getLore()) { + if (line.startsWith(AttributeList.CHARGES_STR) || line.startsWith(AttributeList.CLICK_CHARGES_STR) || line.startsWith(AttributeList.SNEAK_CHARGES_STR)) { + String tmpStr = line.substring(line.indexOf(": ") + 1, line.length()).trim(); + int value = Integer.parseInt(tmpStr); + if (value <= 0) + validCharges = false; + else { + validCharges = true; + break; } } } - catch (Exception e) { - } return validCharges; } @@ -159,7 +153,7 @@ public static void updateOnActionEffects(Player player, Action type) { if (player == null) return; - ArrayList istacks = ItemUtils.getPlayerValidEquipment(player); + List istacks = ItemUtils.getPlayerValidEquipment(player); String[] validAttribs = null; if (type == Action.LEFT_CLICK) validAttribs = new String[] { "Effects", "ClickEffects" }; @@ -181,8 +175,8 @@ else if (type == Action.CONSUME) for (Attribute att : citem.getAttributes()) for (String allowedEff : validAttribs) if (att.getName().equalsIgnoreCase(allowedEff)) { - ArrayList potEffects = AttributeUtils.parsePotionEffects(att); - ArrayList bendEffects = AttributeUtils.parseBendingEffects(att); + List potEffects = AttributeUtils.parsePotionEffects(att); + List bendEffects = AttributeUtils.parseBendingEffects(att); for (PotionEffect pot : potEffects) player.addPotionEffect(pot, true); @@ -192,7 +186,7 @@ else if (type == Action.CONSUME) if (!currentBendingEffects.containsKey(player.getName())) currentBendingEffects.put(player.getName(), new ConcurrentHashMap()); effect.setTime(System.currentTimeMillis()); - ConcurrentHashMap playerEffList = currentBendingEffects.get(player.getName()); + Map playerEffList = currentBendingEffects.get(player.getName()); playerEffList.put(effect.getName(), effect); } } @@ -202,38 +196,23 @@ else if (type == Action.CONSUME) } /** - * Handles the specific stat "WaterSource" and in the future "MetalSource". These stats cause - * specific temporary items to spawn inside of the players inventory. + * Returns the first slot index in a PlayerInventory, trying to avoid hotbar slots * - * @param player the player with the WaterSource stat - * @param attrib the name of the stat "WaterSource" or "MetalSource" - * @param istack the ItemStack that will temporarily spawn + * @param inventory the inventory to check + * @return The slot found, -1 if inventory full */ - public static void handleItemSource(Player player, String attrib, ItemStack istack) { - ConcurrentHashMap attribs = AttributeUtils.getSimplePlayerAttributeMap(player); - if (attribs.containsKey(attrib) && attribs.get(attrib) == 1) { - final PlayerInventory inv = player.getInventory(); - int slot = -1; - for (int i = 9; i < inv.getSize(); i++) { - if (inv.getItem(i) == null || inv.getItem(i).getType() == Material.AIR) { - slot = i; - break; - } + public static int firstAvoidHotbar(final PlayerInventory inventory) { + int slot = -1; + for (int i = 9; i < inventory.getSize(); i++) { + if (inventory.getItem(i) == null || inventory.getItem(i).getType() == Material.AIR) { + slot = i; + break; } - if (slot < 0) - slot = inv.first(Material.AIR); - if (slot >= 0) { - inv.setItem(slot, istack); - player.updateInventory(); - } else - return; - - final int fslot = slot; - new BukkitRunnable() { - public void run() { - inv.setItem(fslot, new ItemStack(Material.AIR)); - } - }.runTaskLater(ProjectKorraItems.plugin, 10); } + + if (slot < 0) + slot = inventory.firstEmpty(); + + return slot; } } diff --git a/src/config.yml b/src/main/resources/config.yml similarity index 78% rename from src/config.yml rename to src/main/resources/config.yml index ca6410a..2a86e8b 100644 --- a/src/config.yml +++ b/src/main/resources/config.yml @@ -1,44 +1,38 @@ -Item: - Name: example1 +example1: DisplayName: This is an Example Item Material: STICK Amount: 1 - Durability: 0 Lore: This is some lore!!!! Glow: true -Item: - Name: example2 +example2: DisplayName: <&4>Fire Wool - Material: WOOL + Material: RED_WOOL Amount: 3 - Durability: 14 Lore: <&c>This wool belongs to the Fire Nation<&c>Use with care! Glow: true - UnshapedRecipe: WOOL, WOOL:3:14, WOOL, example1:3 -Item: - Name: example3 + UnshapedRecipe: WHITE_WOOL, RED_WOOL:3, WHITE_WOOL, example1:3 +example3: DisplayName: <&2>Earth <&a>Walkers - Material: GOLD_BOOTS + Material: GOLDEN_BOOTS ShapedRecipe: GOLD_INGOT, AIR, GOLD_INGOT, GOLD_INGOT, DIRT:16, GOLD_INGOT Stats: - EarthSmashFlySpeed: 25 - EarthSmashFlyDuration: 25 + EarthSmashFlightSpeed: 25 + EarthSmashFlightDuration: 25 EarthSmashDamage: -15 WearOnly: true -Item: - Name: example4 +example4: DisplayName: <&4><&l>BLAZE ROD! Material: BLAZE_ROD UnshapedRecipe: BLAZE_ROD:3, BLAZE_POWDER:3 Stats: Charges: 20 - BlazeRange: 30 + BlazeArcRange: 30 + BlazeRingRange: 30 DestroyAfterCharges: true RequireElement: fire RequireWorld: world ParticleEffects: flame:5:100:10:100 -Item: - Name: example5 +example5: DisplayName: <&9>Azula Stone Material: REDSTONE Lore: <&c>Instantly charges Lightning @@ -49,8 +43,7 @@ Item: AllowFromInventory: true LightningChargeTime: -300 ParticleEffects: magiccrit:15:50:10:0 -Item: - Name: example6 +example6: DisplayName: <&2>Cactus Juice Material: POTION Lore: <&8>Makes you dizzy but increases <&8>your resistance to damage.<&8>Octopusform charges faster<&8>Airbenders can glide without a glider @@ -58,44 +51,41 @@ Item: DestroyAfterCharges: true IgnoreDestroyMessage: true ConsumeEffects: CONFUSION:3:15, DAMAGE_RESISTANCE:2:5, AirGlide:true:15, AirGlideSpeed:50:15, OctopusFormInterval:-100:15 -Item: - Name: example7 +example7: DisplayName: <&b>Water Leggings with Water Pouch Material: LEATHER_LEGGINGS Lore: <&8>Basic Leggings that come equipped with a Water Pouch.<&7>You must double tap your abilities to execute them. - ShapedRecipe: LEATHER, LEATHER, LEATHER, LEATHER, POTION, LEATHER, LEATHER, POTION, LEATHER + ShapedRecipe: LEATHER, LEATHER, LEATHER, LEATHER, POTION:1:WATER, LEATHER, LEATHER, POTION:1:WATER, LEATHER Glow: true Stats: Charges: 50 DestroyAfterCharges: false WaterSource: true -Item: - Name: glider +glider: DisplayName: <&f>Airbender Staff Lore: <&8>A versatile wooden staff used by <&f><&l>Air Nomads<&7>Press sneak while falling to glide<&7>Improves the knockback of<&f> AirBlast<&f> AirSwipe<&f> AirSuction Material: STICK - ShapedRecipe: WOOL:8, WOOL:8, WOOL:8, AIR, STICK:8, WOOL:8, FEATHER:8, AIR, WOOL:8 + ShapedRecipe: WHITE_WOOL:8, WHITE_WOOL:8, WHITE_WOOL:8, AIR, STICK:8, WHITE_WOOL:8, FEATHER:8, AIR, WHITE_WOOL:8 Glow: true Stats: Charges: 50 DestroyAfterCharges: true IgnoreDestroyMessage: false AirGlide: true - AirBlastForce: 20 - AirSwipeForce: 100 - AirSuctionForce: 20 -Item: - Name: badgermoletunic + AirBlastPushFactor: 20 + AirBlastPushFactorForOthers: 20 + AirSuctionPushFactor: 20 + AirSwipePushFactor: 100 +badgermoletunic: DisplayName: <&3>Badgermole Tunic Lore: <&8>The spirit of the badgermole lives on<&7>Focus your <&3>EarthTunnel <&7>into a smaller portion<&7>of earth, increasing the speed. Material: IRON_CHESTPLATE - UnshapedRecipe: COAL_BLOCK:3, IRON_ORE:3, GOLD_ORE:3, STONE:3, STAINED_CLAY:3:5, STAINED_CLAY:3:13 + UnshapedRecipe: COAL_BLOCK:3, IRON_ORE:3, GOLD_ORE:3, STONE:3, LIME_TERRACOTTA:3, GREEN_TERRACOTTA:3 Stats: WearOnly: true SneakCharges: 25 EarthTunnelMaxRadius: -60 -Item: - Name: northpolehelmet +northpolehelmet: DisplayName: <&b>Arctic Helmet of the North Lore: <&8>crafted in the northern water tribe<&7>Increases <&b>ice<&7> based abilities by <&e>20%<&7>Decreases <&9>water<&7> mobility abilities by <&e>20%. Material: LEATHER_HELMET @@ -107,27 +97,26 @@ Item: IceSpikeRange: 20 IceBlastRange: 20 IceBlastDamage: 20 + IceSpikeDamage: 20 IceSpikePillarRange: 20 - IceWaveDamage: 20 - SurgeWaveFreezeSize: 20 + IceSpikePillarDamage: 20 + IceSpikePillarFieldDamage: 20 + SurgeWaveMaxFreezeRadius: 20 WaterSpoutHeight: -20 - WaterSpoutWaveFlightTime: -20 + WaterSpoutWaveFlightDuration: -20 WaterSpoutWaveSpeed: -20 WaterSpoutWaveRadius: -20 -Item: - Name: flameo +flameo: DisplayName: <&c>Flameo Chef Hat Lore: <&8>Buy <&4>'Flameo Instant Noodles!'<&8>The Noodliest Noodles in the United Republic!<&7>Greatly increases <&c>HeatControl<&7> cooking speed. Material: LEATHER_HELMET - ShapedRecipe: WOOL:1:14, WOOL:1:14, WOOL:1:14, WOOL:1:14, COAL_BLOCK:3, WOOL:1:14 + ShapedRecipe: RED_WOOL:1, RED_WOOL:1, RED_WOOL:1, RED_WOOL:1, COAL_BLOCK:3, RED_WOOL:1 Glow: true Stats: LeatherColor: 255, 0, 0 SneakCharges: 15 DestroyAfterCharges: true - HeatControlCookTime: -100 -Item: - Name: waterchestplate +waterchestplate: DisplayName: <&9>Brutal Water Chestplate Lore: <&8>The toughest <&b>water<&8> benders <&8>specialize in close combat<&7>Increases <&9>OctopusForm<&7> by <&e>30%<&7>Increases <&9>Torrent<&7> damage by <&e>15%<&7>Decreases <&9>Torrent<&7> range by <&e>25% Material: LEATHER_CHESTPLATE @@ -143,13 +132,8 @@ Item: OctopusFormRadius: 15 OctopusFormInterval: 30 TorrentDamage: 15 - TorrentStreamingDamage: 15 TorrentRange: -25 -Item: - Name: antilag +antilag: DisplayName: <&c>Anti-Lag Machine Lore: <&8>Everyone loves you for using this item<&7>Decreases the radius of AirBubble<&7>and WaterBubble substantially! Material: DAYLIGHT_DETECTOR - Stats: - AirBubbleRadius: -60 - WaterBubbleRadius: -60 diff --git a/src/plugin.yml b/src/main/resources/plugin.yml similarity index 64% rename from src/plugin.yml rename to src/main/resources/plugin.yml index 6ad99e8..caf089e 100644 --- a/src/plugin.yml +++ b/src/main/resources/plugin.yml @@ -1,8 +1,10 @@ -name: ProjectKorraItems -author: ProjectKorraItems -version: 1.4.0 -main: com.projectkorra.items.ProjectKorraItems -softdepend: [ProjectKorra] +name: ${rootProject.projectName} +main: ${rootProject.group}.${rootProject.name}.${rootProject.projectName} +version: ${rootProject.version} +description: ${rootProject.description} +author: [ProjectKorraItems, Mowstyl] +depend: [ProjectKorra, Oraxen] +api-version: 1.13 permissions: bendingitems.admin: