├── .github └── workflows │ └── maven.yml ├── .gitignore ├── LICENSE ├── README.md ├── lib └── achievements_v1.0-SNAPSHOT.jar ├── pom.xml └── src └── main ├── java └── tip │ ├── Main.java │ ├── bossbar │ └── BossBarApi.java │ ├── commands │ ├── TipsCommand.java │ ├── base │ │ ├── BaseCommand.java │ │ └── BaseSubCommand.java │ └── sub │ │ ├── AchAllSubCommand.java │ │ ├── DefaultSubCommand.java │ │ ├── ReloadSubCommand.java │ │ ├── SendSubCommand.java │ │ └── ThemeSubCommand.java │ ├── lib │ └── viewcompass │ │ └── ViewCompassVariable.java │ ├── messages │ ├── BaseMessage.java │ ├── BossBarMessage.java │ ├── BroadcastMessage.java │ ├── ChatMessage.java │ ├── NameTagMessage.java │ ├── ScoreBoardMessage.java │ ├── TipMessage.java │ └── defaults │ │ ├── BossBarMessage.java │ │ ├── BroadcastMessage.java │ │ ├── ChatMessage.java │ │ ├── MessageManager.java │ │ ├── NameTagMessage.java │ │ ├── ScoreBoardMessage.java │ │ └── TipMessage.java │ ├── tasks │ ├── AbstractPlayerAsyncTask.java │ ├── AddPlayerTask.java │ ├── BaseTipsRunnable.java │ ├── BossBarAllPlayerTask.java │ ├── BossBarTask.java │ ├── BroadCastPlayerTask.java │ ├── BroadCastTask.java │ ├── MotdTask.java │ ├── NameTagTask.java │ ├── ScoreBoardTask.java │ └── TipTask.java │ ├── utils │ ├── Api.java │ ├── BossMessageBuilder.java │ ├── GameCoreDownload.java │ ├── OnListener.java │ ├── PlayerConfig.java │ ├── SendPlayerClass.java │ ├── ThemeManager.java │ └── variables │ │ ├── ASMTemplateCompiler.java │ │ ├── BaseVariable.java │ │ ├── VariableManager.java │ │ └── defaults │ │ └── DefaultVariables.java │ └── windows │ ├── CreateWindow.java │ └── ListenerWindow.java └── resources ├── Tips变量.txt ├── config.yml ├── levelMessage.yml ├── plugin.yml └── theme ├── default.yml └── easy.yml /.github/workflows/maven.yml: -------------------------------------------------------------------------------- 1 | # This workflow will build a Java project with Maven, and cache/restore any dependencies to improve the workflow execution time 2 | # For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-java-with-maven 3 | 4 | # This workflow uses actions that are not certified by GitHub. 5 | # They are provided by a third-party and are governed by 6 | # separate terms of service, privacy policy, and support 7 | # documentation. 8 | 9 | name: Java CI with Maven 10 | 11 | on: 12 | push: 13 | branches: [ "master" ] 14 | pull_request: 15 | branches: [ "master" ] 16 | 17 | jobs: 18 | build: 19 | 20 | runs-on: ubuntu-latest 21 | 22 | steps: 23 | - uses: actions/checkout@v4 24 | - name: Set up JDK 8 25 | uses: actions/setup-java@v4 26 | with: 27 | java-version: 8 28 | distribution: 'temurin' 29 | - name: Cache Maven packages 30 | uses: actions/cache@v4 31 | with: 32 | path: ~/.m2 33 | key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }} 34 | restore-keys: ${{ runner.os }}-m2 35 | - name: Build projects 36 | run: mvn -B package --file pom.xml 37 | - run: mkdir staging && cp target/*.jar staging 38 | - uses: actions/upload-artifact@v4 39 | with: 40 | name: Tips 41 | path: staging 42 | # 生成信息 43 | - name: Get Short SHA 44 | id: vars 45 | run: echo "sha_short=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT 46 | - name: Format ChangeLog 47 | id: get-changelog 48 | if: success() && github.event_name == 'push' && github.repository == 'MemoriesOfTime/Tips' && contains(github.ref_name, 'master') 49 | run: echo "changelog=${{ github.event.commits[0].message }}" >> $GITHUB_OUTPUT 50 | - name: Get Time 51 | id: time 52 | uses: nanzm/get-time-action@v1.1 53 | if: github.repository == 'MemoriesOfTime/Tips' && contains(github.ref_name, 'master') 54 | with: 55 | timeZone: 8 56 | format: 'YYYY/MM/DD-HH:mm:ss' 57 | # 推送到minebbs 58 | - name: Update MineBBS infomation 59 | uses: fjogeleit/http-request-action@v1 60 | if: success() && github.event_name == 'push' && github.repository == 'MemoriesOfTime/Tips' && contains(github.ref_name, 'master') 61 | with: 62 | url: 'https://api.minebbs.com/api/openapi/v1/resources/796/update' 63 | method: 'POST' 64 | customHeaders: '{"Authorization": "Bearer ${{ secrets.MINEBBS_API_KEY }}"}' 65 | contentType: 'application/json' 66 | data: '{"title": "${{ github.ref_name }}-${{ steps.vars.outputs.sha_short }}", "description": "${{ steps.get-changelog.outputs.changelog }}", "new_version": "${{ steps.time.outputs.time }}", "file_url": "https://motci.cn/job/Tips/"}' 67 | escapeData: 'true' 68 | preventFailureOnNoResponse: 'true' 69 | ignoreStatusCodes: '400,404,401,403,500,502,503,504' 70 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | /target/ 2 | /.idea/ 3 | .DS_Store 4 | */.DS_Store 5 | *.py 6 | *.iml -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 3, 29 June 2007 3 | 4 | Copyright © 2007 Free Software Foundation, Inc. 5 | 6 | Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. 7 | 8 | Preamble 9 | The GNU General Public License is a free, copyleft license for software and other kinds of works. 10 | 11 | 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. 12 | 13 | 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. 14 | 15 | 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. 16 | 17 | 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. 18 | 19 | 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. 20 | 21 | 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. 22 | 23 | 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. 24 | 25 | 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. 26 | 27 | The precise terms and conditions for copying, distribution and modification follow. 28 | 29 | TERMS AND CONDITIONS 30 | 0. Definitions. 31 | “This License” refers to version 3 of the GNU General Public License. 32 | 33 | “Copyright” also means copyright-like laws that apply to other kinds of works, such as semiconductor masks. 34 | 35 | “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. 36 | 37 | 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. 38 | 39 | A “covered work” means either the unmodified Program or a work based on the Program. 40 | 41 | 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. 42 | 43 | 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. 44 | 45 | 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. 46 | 47 | 1. Source Code. 48 | 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. 49 | 50 | 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. 51 | 52 | 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. 53 | 54 | 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. 55 | 56 | The Corresponding Source need not include anything that users can regenerate automatically from other parts of the Corresponding Source. 57 | 58 | The Corresponding Source for a work in source code form is that same work. 59 | 60 | 2. Basic Permissions. 61 | 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. 62 | 63 | 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. 64 | 65 | Conveying under any other circumstances is permitted solely under the conditions stated below. Sublicensing is not allowed; section 10 makes it unnecessary. 66 | 67 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 68 | 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. 69 | 70 | 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. 71 | 72 | 4. Conveying Verbatim Copies. 73 | 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. 74 | 75 | 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. 76 | 77 | 5. Conveying Modified Source Versions. 78 | 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: 79 | 80 | a) The work must carry prominent notices stating that you modified it, and giving a relevant date. 81 | 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”. 82 | 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. 83 | 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. 84 | 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. 85 | 86 | 6. Conveying Non-Source Forms. 87 | 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: 88 | 89 | 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. 90 | 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. 91 | 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. 92 | 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. 93 | 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. 94 | 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. 95 | 96 | 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. 97 | 98 | “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. 99 | 100 | 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). 101 | 102 | 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. 103 | 104 | 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. 105 | 106 | 7. Additional Terms. 107 | “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. 108 | 109 | 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. 110 | 111 | 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: 112 | 113 | a) Disclaiming warranty or limiting liability differently from the terms of sections 15 and 16 of this License; or 114 | 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 115 | 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 116 | d) Limiting the use for publicity purposes of names of licensors or authors of the material; or 117 | e) Declining to grant rights under trademark law for use of some trade names, trademarks, or service marks; or 118 | 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. 119 | 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. 120 | 121 | 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. 122 | 123 | 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. 124 | 125 | 8. Termination. 126 | 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). 127 | 128 | 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. 129 | 130 | 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. 131 | 132 | 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. 133 | 134 | 9. Acceptance Not Required for Having Copies. 135 | 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. 136 | 137 | 10. Automatic Licensing of Downstream Recipients. 138 | 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. 139 | 140 | 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. 141 | 142 | 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. 143 | 144 | 11. Patents. 145 | 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”. 146 | 147 | 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. 148 | 149 | 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. 150 | 151 | 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. 152 | 153 | 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. 154 | 155 | 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. 156 | 157 | 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. 158 | 159 | 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. 160 | 161 | 12. No Surrender of Others' Freedom. 162 | 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. 163 | 164 | 13. Use with the GNU Affero General Public License. 165 | 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. 166 | 167 | 14. Revised Versions of this License. 168 | 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. 169 | 170 | 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. 171 | 172 | 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. 173 | 174 | 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. 175 | 176 | 15. Disclaimer of Warranty. 177 | 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. 178 | 179 | 16. Limitation of Liability. 180 | 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. 181 | 182 | 17. Interpretation of Sections 15 and 16. 183 | 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. 184 | 185 | END OF TERMS AND CONDITIONS 186 | 187 | How to Apply These Terms to Your New Programs 188 | 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. 189 | 190 | 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. 191 | 192 | 193 | Copyright (C) 194 | 195 | This program is free software: you can redistribute it and/or modify 196 | it under the terms of the GNU General Public License as published by 197 | the Free Software Foundation, either version 3 of the License, or 198 | (at your option) any later version. 199 | 200 | This program is distributed in the hope that it will be useful, 201 | but WITHOUT ANY WARRANTY; without even the implied warranty of 202 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 203 | GNU General Public License for more details. 204 | 205 | You should have received a copy of the GNU General Public License 206 | along with this program. If not, see . 207 | Also add information on how to contact you by electronic and paper mail. 208 | 209 | If the program does terminal interaction, make it output a short notice like this when it starts in an interactive mode: 210 | 211 | Copyright (C) 212 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 213 | This is free software, and you are welcome to redistribute it 214 | under certain conditions; type `show c' for details. 215 | 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”. 216 | 217 | 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 . 218 | 219 | 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 . -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | 2 | Latest release 3 | 4 | 5 | # **Tips** 6 | 一款多功能显示插件 7 | 8 | #### 使用说明 9 | - 用户: 10 | 1. 将本插件安装到` plugins`文件夹 11 | 2. 安装前置插件 参考 **`Tips变量.txt`** 文件 12 | 3. 修改` config.yml` 配置 13 | 14 | > (小贴士) config内的 default 为全地图通用显示 15 | 若想实现每个 地图 不同的内容 只需要复制粘贴 16 | delfault 内容即可 然后将 default 替换成 17 | 那个地图的名称 18 | 19 | 开发者 20 | > 注册变量 21 | >> 创建一个类继承 `BaseVariable ` 22 | 调用`BaseVariable `类里的` addStrReplaceString`方法 23 | 传入 key(变量名称) value(显示内容) 24 | 然后在 插件的 onEnable 里增加 25 | ```java 26 | Api.registerVariables("插件名",class); 27 | ``` 28 | >添加单一变量 29 | ```java 30 | Api.addVariable("变量字符","值"); 31 | ``` 32 | 33 | 修改内容 34 | > 调用Api类内的方法 修改 35 | 36 | 37 | -------------------------------------------------------------------------------- /lib/achievements_v1.0-SNAPSHOT.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MemoriesOfTime/Tips/d17f2b42262ac025ac9c2cdfb4d4bb4fbaa3a169/lib/achievements_v1.0-SNAPSHOT.jar -------------------------------------------------------------------------------- /pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 4.0.0 6 | 7 | com.smallaswater.tips 8 | Tips 9 | 2.2.2 10 | 11 | 12 | 13 | UTF-8 14 | UTF-8 15 | 1.8 16 | 1.8 17 | UTF-8 18 | 1.6.9 19 | 20 | 21 | 22 | 23 | repo-lanink-cn 24 | https://repo.lanink.cn/repository/maven-snapshots/ 25 | 26 | 27 | repo-lanink-cn 28 | https://repo.lanink.cn/repository/maven-releases/ 29 | 30 | 31 | 32 | 33 | 34 | repo-lanink-cn 35 | https://repo.lanink.cn/repository/maven-public/ 36 | 37 | 38 | opencollab-repo-release 39 | https://repo.opencollab.dev/maven-releases/ 40 | 41 | true 42 | 43 | 44 | false 45 | 46 | 47 | 48 | opencollab-repo-snapshot 49 | https://repo.opencollab.dev/maven-snapshots/ 50 | 51 | false 52 | 53 | 54 | true 55 | 56 | 57 | 58 | 59 | 60 | 61 | org.jetbrains 62 | annotations 63 | 24.1.0 64 | provided 65 | 66 | 67 | 68 | cn.nukkit 69 | nukkit 70 | 1.0-SNAPSHOT 71 | provided 72 | 73 | 74 | 75 | org.ow2.asm 76 | asm 77 | 9.7 78 | compile 79 | 80 | 81 | 82 | cn.lanink 83 | MemoriesOfTime-GameCore 84 | ${lib.GameCore.version} 85 | provided 86 | 87 | 88 | 89 | com.smallaswater.ServerInfo 90 | ServerInfo 91 | 1.0.10 92 | provided 93 | 94 | 95 | 96 | me.onebone 97 | economyapi 98 | 2.0.2 99 | provided 100 | 101 | 102 | 103 | com.smallaswater.autoupdata 104 | AutoUpData 105 | 1.3.0 106 | provided 107 | 108 | 109 | 110 | smallaswater.achievement 111 | achievements 112 | 1.0-SNAPSHOT 113 | system 114 | ${project.basedir}/lib/achievements_v1.0-SNAPSHOT.jar 115 | 116 | 117 | 118 | 119 | 120 | 121 | org.apache.maven.plugins 122 | maven-compiler-plugin 123 | 3.8.1 124 | 125 | ${maven.compiler.source} 126 | ${maven.compiler.target} 127 | ${maven.compiler.encoding} 128 | 129 | 130 | 131 | com.google.code.maven-replacer-plugin 132 | replacer 133 | 1.5.3 134 | 135 | 136 | add-version 137 | process-sources 138 | 139 | replace 140 | 141 | 142 | 143 | ${project.basedir}/src/main/resources/plugin.yml 144 | ${project.basedir}/src/main/java/tip/utils/GameCoreDownload.java 145 | 146 | 147 | 148 | version: ".*" 149 | version: "${project.version}" 150 | 151 | 152 | MINIMUM_GAME_CORE_VERSION = ".*" 153 | MINIMUM_GAME_CORE_VERSION = "${lib.GameCore.version}" 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | org.apache.maven.plugins 162 | maven-shade-plugin 163 | 3.2.4 164 | 165 | 166 | package 167 | 168 | shade 169 | 170 | 171 | false 172 | 173 | 174 | org.ow2.asm:asm 175 | 176 | 177 | 178 | 179 | 180 | 181 | 182 | 183 | 184 | 185 | -------------------------------------------------------------------------------- /src/main/java/tip/Main.java: -------------------------------------------------------------------------------- 1 | package tip; 2 | 3 | 4 | import cn.nukkit.Player; 5 | import cn.nukkit.Server; 6 | import cn.nukkit.plugin.PluginBase; 7 | import cn.nukkit.utils.BossBarColor; 8 | import cn.nukkit.utils.Config; 9 | import com.google.common.cache.Cache; 10 | import com.google.common.cache.CacheBuilder; 11 | import com.google.common.util.concurrent.ThreadFactoryBuilder; 12 | import tip.bossbar.BossBarApi; 13 | import tip.commands.TipsCommand; 14 | import tip.lib.viewcompass.ViewCompassVariable; 15 | import tip.messages.BaseMessage; 16 | import tip.messages.defaults.*; 17 | import tip.tasks.AddPlayerTask; 18 | import tip.tasks.BossBarTask; 19 | import tip.tasks.MotdTask; 20 | import tip.tasks.TipTask; 21 | import tip.utils.*; 22 | import tip.utils.variables.VariableManager; 23 | import tip.utils.variables.defaults.DefaultVariables; 24 | import tip.windows.ListenerWindow; 25 | import updata.AutoData; 26 | 27 | import java.io.File; 28 | import java.util.*; 29 | import java.util.concurrent.ExecutorService; 30 | import java.util.concurrent.Executors; 31 | import java.util.concurrent.TimeUnit; 32 | 33 | /** 34 | * @author 若水 35 | 36 | */ 37 | public class Main extends PluginBase { 38 | 39 | 40 | private static Main instance; 41 | 42 | private String theme; 43 | 44 | private boolean scoreboard = false; 45 | 46 | private String motd; 47 | 48 | 49 | private VariableManager varManager; 50 | public Set scoreboards = new HashSet<>(); 51 | 52 | public Cache tasks = CacheBuilder.newBuilder() 53 | .expireAfterAccess(60, TimeUnit.MINUTES) 54 | .build(); 55 | 56 | public final LinkedHashMap apis = new LinkedHashMap<>(); 57 | 58 | private MessageManager showMessages = new MessageManager(); 59 | 60 | private final ThemeManager themeManager = new ThemeManager(); 61 | 62 | private LinkedList playerConfigs = new LinkedList<>(); 63 | 64 | public static ExecutorService executor = null; 65 | 66 | 67 | @Override 68 | public void onLoad() { 69 | instance = this; 70 | Api.registerVariables("default", DefaultVariables.class); 71 | Api.registerVariables("ViewCompass", ViewCompassVariable.class); 72 | } 73 | 74 | @Override 75 | public void onEnable() { 76 | if (executor != null) { 77 | executor.shutdown(); 78 | } 79 | executor = Executors.newCachedThreadPool(new ThreadFactoryBuilder().setNameFormat("Tips-Thread-%d").build()); 80 | 81 | try { 82 | if (Server.getInstance().getPluginManager().getPlugin("AutoUpData") != null) { 83 | if (AutoData.defaultUpDataByMaven(this, this.getFile(), "com.smallaswater.tips", "Tips", null)) { 84 | return; 85 | } 86 | } 87 | } catch (Throwable e) { 88 | this.getLogger().warning("插件自动更新失败!请检查AutoUpData前置插件!"); 89 | } 90 | init(); 91 | 92 | motd = getConfig().getString("自定义MOTD.内容","&l{color}在线 -{online}/{maxplayer}\n {version}"); 93 | if(getConfig().getBoolean("自定义MOTD.是否启用",false)){ 94 | executor.execute(new MotdTask(this)); 95 | } 96 | this.getServer().getCommandMap().register("tips", new TipsCommand(getConfig().getString("自定义指令.name","tips"))); 97 | this.getServer().getPluginManager().registerEvents(new OnListener(),this); 98 | this.getServer().getPluginManager().registerEvents(new ListenerWindow(),this); 99 | 100 | if (GameCoreDownload.checkAndDownload() == 1) { 101 | this.getLogger().error("MemoriesOfTime-GameCore依赖 下载失败,无法使用计分板功能!"); 102 | } else { 103 | Main.getInstance().getLogger().info("检测到 MemoriesOfTime-GameCore 成功开启计分板功能"); 104 | scoreboard = true; 105 | } 106 | AddPlayerTask.add(new TipTask(Main.getInstance(),Main.getInstance().getConfig().getInt("自定义刷新刻度.底部",20))); 107 | 108 | this.getLogger().info("插件加载完成~"); 109 | } 110 | 111 | public String getMotd() { 112 | return motd; 113 | } 114 | 115 | public boolean isScoreboard() { 116 | return scoreboard; 117 | } 118 | 119 | public String getTheme() { 120 | return theme; 121 | } 122 | 123 | public ThemeManager getThemeManager() { 124 | return themeManager; 125 | } 126 | 127 | private Config getLevelMessage() { 128 | return themeManager.getConfig(theme); 129 | } 130 | 131 | public void init(){ 132 | this.saveDefaultConfig(); 133 | this.reloadConfig(); 134 | showMessages = new MessageManager(); 135 | 136 | this.saveResource("Tips变量.txt","/Tips变量.txt",true); //每次加载时写入,保证是最新的 137 | 138 | if(!new File(this.getDataFolder()+"/theme").exists()){ 139 | if(!new File(this.getDataFolder()+"/theme").mkdirs()){ 140 | getLogger().error("创建 theme 文件夹失败"); 141 | } 142 | if(!new File(this.getDataFolder()+"/theme/easy.yml").exists()){ 143 | this.saveResource("theme/easy.yml","/theme/easy.yml",false); 144 | } 145 | } 146 | 147 | if(!new File(this.getDataFolder()+"/theme/default.yml").exists()){ 148 | this.saveResource("theme/default.yml","/theme/default.yml",false); 149 | } 150 | 151 | if(!new File(this.getDataFolder()+"/Players").exists()){ 152 | if(!new File(this.getDataFolder()+"/Players").mkdirs()){ 153 | this.getLogger().error("玩家文件夹创建失败"); 154 | } 155 | } 156 | //加载风格 157 | loadTheme(); 158 | theme = getConfig().getString("默认样式","default"); 159 | getLogger().info("当前样式已设置为: "+theme); 160 | 161 | showMessages.addAll(getManagerByConfig(getLevelMessage())); 162 | //开始加载Message 163 | playerConfigs = new LinkedList<>(); 164 | } 165 | 166 | public void loadPlayerConfig(Player player){ 167 | if(new File(Main.getInstance().getDataFolder()+"/Players/"+player.getName()+".yml").exists()){ 168 | Config config = new Config(Main.getInstance().getDataFolder()+"/Players/"+player.getName()+".yml",2); 169 | PlayerConfig playerConfig = new PlayerConfig(player.getName(),Main.getInstance().getManagerByConfig(config),config.getString("样式",null)); 170 | Main.getInstance().getPlayerConfigs().add(playerConfig); 171 | 172 | } 173 | } 174 | 175 | private MessageManager getManagerByConfig(Config config){ 176 | MessageManager messages = new MessageManager(); 177 | if(config == null){ 178 | return messages; 179 | } 180 | for(BaseMessage.BaseTypes types: BaseMessage.BaseTypes.values()){ 181 | if(config.exists(types.getConfigName())) { 182 | LinkedList messages1 = addShowMessageByMap((Map) config.get(types.getConfigName()), types.getType()); 183 | if (messages1.size() > 0) { 184 | messages.addAll(messages1); 185 | } 186 | } 187 | } 188 | return messages; 189 | } 190 | 191 | private void loadTheme(){ 192 | String[] strings = getFileNames("theme"); 193 | if(strings.length > 0){ 194 | for(String file:strings){ 195 | Config config = new Config(this.getDataFolder()+"/theme/"+file+".yml",2); 196 | themeManager.put(file,getManagerByConfig(config),config); 197 | getLogger().info("加载样式: "+file); 198 | } 199 | }else{ 200 | getLogger().info("未加载任何样式"); 201 | } 202 | } 203 | 204 | 205 | public LinkedList getPlayerConfigs() { 206 | return playerConfigs; 207 | } 208 | 209 | public VariableManager getVarManager() { 210 | return varManager; 211 | } 212 | 213 | public void setVarManager(VariableManager varManager) { 214 | this.varManager = varManager; 215 | } 216 | 217 | public PlayerConfig getPlayerConfig(String playerName) { 218 | for(PlayerConfig config:playerConfigs) { 219 | if(config.getPlayerName().equalsIgnoreCase(playerName)) { 220 | return config; 221 | } 222 | } 223 | return null; 224 | } 225 | 226 | public PlayerConfig getPlayerConfigInit(String playerName){ 227 | PlayerConfig config = new PlayerConfig(playerName,new MessageManager(),null); 228 | if(!playerConfigs.contains(config)){ 229 | playerConfigs.add(config); 230 | } 231 | return playerConfigs.get(playerConfigs.indexOf(config)); 232 | } 233 | 234 | public MessageManager getShowMessages() { 235 | return showMessages; 236 | } 237 | 238 | public MessageManager addShowMessageByMap(Map map1, int type){ 239 | MessageManager messages = new MessageManager(); 240 | if(map1 != null && map1.size() > 0) { 241 | switch (type) { 242 | case BaseMessage.BOSS_BAR_TYPE: 243 | for (Object o : map1.keySet()) { 244 | Map map = (Map) map1.get(o); 245 | BossBarMessage message = new BossBarMessage(o.toString(), 246 | (boolean) map.get("是否开启"), 247 | (int) map.get("间隔时间"), 248 | (boolean) map.get("是否根据玩家血量变化"), 249 | getList((List) map.get("消息轮播"))); 250 | if (map.containsKey("显示颜色")) { 251 | try { 252 | message.setBossBarColor(BossBarColor.valueOf((String) map.get("显示颜色"))); 253 | } catch (Exception e) { 254 | getLogger().error("错误: 无法识别的BossBar颜色: " + map.get("显示颜色"), e); 255 | } 256 | } 257 | messages.add(message); 258 | } 259 | break; 260 | case BaseMessage.CHAT_MESSAGE_TYPE: 261 | for (Object o : map1.keySet()) { 262 | Map map = (Map) map1.get(o); 263 | messages.add(new ChatMessage(o.toString(), (boolean) map.get("是否开启"), (String) map.get("显示"), (boolean) map.get("是否仅在世界内有效"))); 264 | } 265 | break; 266 | case BaseMessage.NAME_TAG_TYPE: 267 | for (Object o : map1.keySet()) { 268 | Map map = (Map) map1.get(o); 269 | messages.add(new NameTagMessage(o.toString(), (boolean) map.get("是否开启"), (String) map.get("显示"))); 270 | } 271 | break; 272 | case BaseMessage.SCOREBOARD_TYPE: 273 | for (Object o : map1.keySet()) { 274 | Map map = (Map) map1.get(o); 275 | messages.add(new ScoreBoardMessage(o.toString(), 276 | (boolean) map.get("是否开启"), 277 | (String) map.get("Title"), 278 | getList((List) map.get("Line")))); 279 | } 280 | break; 281 | case BaseMessage.TIP_MESSAGE_TYPE: 282 | for (Object o : map1.keySet()) { 283 | Map map = (Map) map1.get(o); 284 | messages.add(new TipMessage(o.toString(), 285 | (boolean) map.get("是否开启"), (int) map.get("显示类型"), 286 | (String) map.get("显示"))); 287 | } 288 | break; 289 | case BaseMessage.BROAD_CAST_TYPE: 290 | for (Object o : map1.keySet()) { 291 | Map map = (Map) map1.get(o); 292 | messages.add(new BroadcastMessage(o.toString(), 293 | (boolean) map.get("是否开启"), 294 | (int) map.get("间隔时间"), getList((List) map.get("消息轮播")))); 295 | } 296 | break; 297 | default: 298 | break; 299 | } 300 | } 301 | return messages; 302 | } 303 | 304 | private LinkedList getList(List list){ 305 | LinkedList strings = new LinkedList<>(); 306 | for(Object o:list){ 307 | strings.add(o.toString()); 308 | } 309 | return strings; 310 | } 311 | 312 | public void setShowMessages(MessageManager showMessages) { 313 | this.showMessages = showMessages; 314 | } 315 | 316 | 317 | 318 | public static Main getInstance() { 319 | return instance; 320 | } 321 | 322 | private String[] getFileNames(String fileName) { 323 | List names = new ArrayList<>(); 324 | File files = new File(getDataFolder()+ "/"+fileName); 325 | if(files.isDirectory()){ 326 | File[] filesArray = files.listFiles(); 327 | if(filesArray != null){ 328 | if(filesArray.length>0){ 329 | for(File file : filesArray){ 330 | names.add( file.getName().substring(0, file.getName().lastIndexOf("."))); 331 | } 332 | } 333 | } 334 | } 335 | return names.toArray(new String[0]); 336 | } 337 | 338 | private String[] getPlayerFiles() { 339 | return getFileNames("Players"); 340 | } 341 | 342 | @Override 343 | public void onDisable() { 344 | //保存配置文件 345 | for(PlayerConfig config:playerConfigs){ 346 | config.save(); 347 | } 348 | LinkedHashMap> configs = new LinkedHashMap<>(); 349 | for(BaseMessage message: getShowMessages()){ 350 | BaseMessage.BaseTypes type = BaseMessage.getBaseTypeByInteger(message.getType()); 351 | if(type != null){ 352 | if(configs.containsKey(type.getConfigName())){ 353 | LinkedHashMap map = configs.get(type.getConfigName()); 354 | map.putAll(message.getConfig()); 355 | }else { 356 | configs.put(type.getConfigName(), message.getConfig()); 357 | } 358 | } 359 | } 360 | Config config = getLevelMessage(); 361 | if(config != null) { 362 | for (String name : configs.keySet()) { 363 | config.set(name, configs.get(name)); 364 | } 365 | config.save(); 366 | } 367 | //关闭不再使用的消息 368 | if (executor != null) { 369 | executor.shutdown(); 370 | executor = null; 371 | } 372 | 373 | tasks.invalidateAll(); 374 | for (Player player : new HashSet<>(this.apis.keySet())) { 375 | BossBarApi.removeBossBar(player); 376 | } 377 | } 378 | 379 | 380 | } 381 | -------------------------------------------------------------------------------- /src/main/java/tip/bossbar/BossBarApi.java: -------------------------------------------------------------------------------- 1 | package tip.bossbar; 2 | 3 | import cn.nukkit.Player; 4 | import cn.nukkit.utils.DummyBossBar; 5 | import tip.Main; 6 | import tip.utils.BossMessageBuilder; 7 | 8 | 9 | /** 10 | * @author SmallasWater 11 | */ 12 | public class BossBarApi extends DummyBossBar.Builder{ 13 | 14 | public long bossId; 15 | 16 | private BossBarApi(Player player){ 17 | super(player); 18 | } 19 | 20 | 21 | public static void createBossBar(Player player){ 22 | if(!Main.getInstance().apis.containsKey(player)) { 23 | BossBarApi bossBar = new BossBarApi(player); 24 | bossBar.length(0); 25 | bossBar.text("加载中"); 26 | Main.getInstance().apis.put(player, bossBar); 27 | bossBar.bossId = player.createBossBar(Main.getInstance().apis.get(player).build()); 28 | } 29 | } 30 | 31 | 32 | public static void removeBossBar(Player player){ 33 | if(Main.getInstance().apis.containsKey(player)){ 34 | if(player.getDummyBossBar(Main.getInstance().apis.get(player).bossId) != null) { 35 | player.removeBossBar(Main.getInstance().apis.get(player).bossId); 36 | } 37 | } 38 | } 39 | 40 | 41 | public static void showBoss(Player player, String text, BossMessageBuilder builder, int time){ 42 | if(Main.getInstance().apis.get(player) != null){ 43 | if(player.getDummyBossBar(Main.getInstance().apis.get(player).bossId) == null){ 44 | Main.getInstance().apis.remove(player); 45 | return; 46 | } 47 | DummyBossBar bossBar = player.getDummyBossBar(Main.getInstance().apis.get(player).bossId); 48 | bossBar.setText(text); 49 | if(builder.isHealth()){ 50 | bossBar.setLength((float)Math.round(player.getHealth() / (float)player.getMaxHealth() * 100.0F)); 51 | }else{ 52 | float m; 53 | if(time < 0){ 54 | m = 0; 55 | }else{ 56 | m = (float)Math.round(time / (float)builder.getTime() * 100.0F); 57 | } 58 | bossBar.setLength(m); 59 | } 60 | try { 61 | Class.forName("cn.nukkit.utils.BossBarColor"); 62 | bossBar.setColor(builder.getBossBarColor()); 63 | }catch (Exception ignore){} 64 | player.createBossBar(bossBar); 65 | 66 | } 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /src/main/java/tip/commands/TipsCommand.java: -------------------------------------------------------------------------------- 1 | package tip.commands; 2 | 3 | import cn.nukkit.Player; 4 | import cn.nukkit.command.CommandSender; 5 | import tip.Main; 6 | import tip.commands.base.BaseCommand; 7 | import tip.commands.sub.*; 8 | import tip.windows.CreateWindow; 9 | import tip.windows.ListenerWindow; 10 | 11 | /** 12 | * @author SmallasWater 13 | */ 14 | public class TipsCommand extends BaseCommand { 15 | 16 | public TipsCommand(String name) { 17 | super(name, ""); 18 | this.setPermission("tips.ts"); 19 | this.setAliases(Main.getInstance().getConfig().getStringList("自定义指令.aliases").toArray(new String[0])); 20 | this.description = Main.getInstance().getConfig().getString("自定义指令.description", "自定义玩家提示"); 21 | 22 | this.addSubCommand(new DefaultSubCommand("default")); 23 | this.addSubCommand(new SendSubCommand("send")); 24 | this.addSubCommand(new ReloadSubCommand("reload")); 25 | 26 | this.addSubCommand(new AchAllSubCommand("achAll")); 27 | this.addSubCommand(new ThemeSubCommand("theme")); 28 | 29 | this.loadCommandBase(); 30 | } 31 | 32 | @Override 33 | public boolean hasPermission(CommandSender sender) { 34 | return true; 35 | } 36 | 37 | @Override 38 | public boolean execute(CommandSender sender, String s, String[] args) { 39 | if (hasPermission(sender)) { 40 | if (sender.isOp()) { 41 | if (args.length == 0) { 42 | if (sender instanceof Player) { 43 | ListenerWindow.CHOSE_TYPE.put(sender.getName(), 0); 44 | CreateWindow.sendSetting((Player) sender); 45 | return true; 46 | } else { 47 | sender.sendMessage("请不要用控制台执行.."); 48 | return false; 49 | } 50 | } 51 | } else { 52 | if (args.length == 0) { 53 | this.sendHelp(sender); 54 | return false; 55 | } 56 | } 57 | } else { 58 | if (args.length == 0) { 59 | this.sendHelp(sender); 60 | return false; 61 | } 62 | } 63 | return super.execute(sender, s, args); 64 | } 65 | 66 | @Override 67 | public void sendHelp(CommandSender sender) { 68 | sender.sendMessage("§a===================="); 69 | if (sender.isOp()) { 70 | sender.sendMessage("§e/" + getName() + " §e打开设置玩家显示GUI"); 71 | sender.sendMessage("§e/" + getName() + " §7default §e打开设置默认显示GUI"); 72 | sender.sendMessage("§e/" + getName() + " §7send <玩家> <类型> <信息>§e给玩家发送消息\n§r类型: tip,popup,action,title,msg"); 73 | sender.sendMessage("§e/" + getName() + " §7reload §e重新读取配置"); 74 | } 75 | sender.sendMessage("§e/" + getName() + " §7achAll §e打开成就GUI"); 76 | sender.sendMessage("§e/" + getName() + " §7theme §e打开设置样式GUI"); 77 | sender.sendMessage("§a===================="); 78 | } 79 | } 80 | -------------------------------------------------------------------------------- /src/main/java/tip/commands/base/BaseCommand.java: -------------------------------------------------------------------------------- 1 | package tip.commands.base; 2 | 3 | import cn.nukkit.Player; 4 | import cn.nukkit.command.Command; 5 | import cn.nukkit.command.CommandSender; 6 | import cn.nukkit.command.data.CommandParameter; 7 | 8 | import java.util.ArrayList; 9 | import java.util.Arrays; 10 | import java.util.LinkedList; 11 | import java.util.concurrent.ConcurrentHashMap; 12 | 13 | /** 14 | * @author SmallasWater 15 | */ 16 | public abstract class BaseCommand extends Command { 17 | 18 | private final ArrayList subCommand = new ArrayList<>(); 19 | 20 | private final ConcurrentHashMap subCommands = new ConcurrentHashMap<>(); 21 | 22 | public BaseCommand(String name, String description) { 23 | super(name,description); 24 | } 25 | 26 | /** 27 | * 获取权限 28 | * @param sender 玩家 29 | * @return 是否拥有权限 30 | */ 31 | abstract public boolean hasPermission(CommandSender sender); 32 | 33 | 34 | @Override 35 | public boolean execute(CommandSender sender, String s, String[] args) { 36 | if(hasPermission(sender)) { 37 | String subCommand = args[0].toLowerCase(); 38 | if (subCommands.containsKey(subCommand)) { 39 | BaseSubCommand command = this.subCommand.get(subCommands.get(subCommand)); 40 | boolean canUse = command.hasPermission(sender); 41 | if (canUse) { 42 | return command.execute(sender,s, args); 43 | } else if (sender instanceof Player) { 44 | sender.sendMessage("你没有权限使用这个指令"); 45 | return true; 46 | } else { 47 | sender.sendMessage("请不要在控制台执行此指令"); 48 | } 49 | } else { 50 | sendHelp(sender); 51 | return true; 52 | } 53 | } 54 | return true; 55 | } 56 | 57 | /** 58 | * 发送帮助 59 | * @param sender 玩家 60 | * */ 61 | abstract public void sendHelp(CommandSender sender); 62 | 63 | protected void addSubCommand(BaseSubCommand cmd) { 64 | subCommand.add(cmd); 65 | int commandId = (subCommand.size()) - 1; 66 | subCommands.put(cmd.getName().toLowerCase(), commandId); 67 | for (String alias : cmd.getAliases()) { 68 | subCommands.put(alias.toLowerCase(), commandId); 69 | } 70 | } 71 | 72 | protected void loadCommandBase(){ 73 | this.commandParameters.clear(); 74 | for(BaseSubCommand subCommand:subCommand){ 75 | LinkedList parameters = new LinkedList<>(); 76 | parameters.add(new CommandParameter(subCommand.getName(), new String[]{subCommand.getName()})); 77 | parameters.addAll(Arrays.asList(subCommand.getParameters())); 78 | this.commandParameters.put(subCommand.getName(),parameters.toArray(new CommandParameter[0])); 79 | } 80 | 81 | } 82 | } 83 | -------------------------------------------------------------------------------- /src/main/java/tip/commands/base/BaseSubCommand.java: -------------------------------------------------------------------------------- 1 | package tip.commands.base; 2 | 3 | import cn.nukkit.command.CommandSender; 4 | import cn.nukkit.command.data.CommandParameter; 5 | 6 | /** 7 | * @author SmallasWater 8 | */ 9 | public abstract class BaseSubCommand { 10 | 11 | private final String name; 12 | 13 | protected BaseSubCommand(String name) { 14 | this.name = name.toLowerCase(); 15 | } 16 | 17 | /** 18 | * 获取名称 19 | * @return string 20 | */ 21 | public String getName(){ 22 | return name; 23 | } 24 | /** 25 | * 获取别名 26 | * @return string[] 27 | */ 28 | public abstract String[] getAliases(); 29 | 30 | /** 31 | * 命令响应 32 | * @param sender the sender - CommandSender 33 | * @param args The arrugements - String[] 34 | * @param label label.. 35 | * @return true if true 36 | */ 37 | public abstract boolean execute(CommandSender sender,String label, String[] args); 38 | 39 | 40 | public boolean hasPermission(CommandSender sender){ 41 | return true; 42 | } 43 | /** 44 | * 指令参数. 45 | * @return 提示参数 46 | * */ 47 | abstract public CommandParameter[] getParameters(); 48 | } 49 | -------------------------------------------------------------------------------- /src/main/java/tip/commands/sub/AchAllSubCommand.java: -------------------------------------------------------------------------------- 1 | package tip.commands.sub; 2 | 3 | import cn.nukkit.Achievement; 4 | import cn.nukkit.Player; 5 | import cn.nukkit.Server; 6 | import cn.nukkit.command.CommandSender; 7 | import cn.nukkit.command.data.CommandParameter; 8 | import cn.nukkit.form.window.FormWindowSimple; 9 | import com.smallaswater.achievement.Achievements; 10 | import tip.commands.base.BaseSubCommand; 11 | 12 | /** 13 | * @author SmallasWater 14 | */ 15 | public class AchAllSubCommand extends BaseSubCommand { 16 | 17 | public AchAllSubCommand(String name) { 18 | super(name); 19 | } 20 | 21 | @Override 22 | public String[] getAliases() { 23 | return new String[0]; 24 | } 25 | 26 | @Override 27 | public boolean execute(CommandSender sender, String label, String[] args) { 28 | if(sender instanceof Player) { 29 | FormWindowSimple simple = new FormWindowSimple("§e§l成就系统", ""); 30 | StringBuilder builder = new StringBuilder(); 31 | builder.append("§7成就进度: §2").append(((Player) sender).achievements.size()).append("§r/§7").append(Achievement.achievements.size()).append("§r\n"); 32 | for (String s1 : Achievement.achievements.keySet()) { 33 | String msg = Achievement.achievements.get(s1).message; 34 | if (Server.getInstance().getPluginManager().getPlugin("Achievements") != null) { 35 | String a1 = Achievements.getString(msg); 36 | if (!"".equals(a1)) { 37 | msg = a1; 38 | } else { 39 | a1 = Achievements.getString(s1); 40 | if (!"".equals(a1)) { 41 | msg = a1; 42 | } 43 | } 44 | } 45 | builder.append(msg).append("§e: —— "); 46 | if (!((Player) sender).hasAchievement(s1)) { 47 | builder.append("§c§l✘§r\n\n"); 48 | } else { 49 | builder.append("§a§l√§r\n\n"); 50 | } 51 | } 52 | 53 | simple.setContent(builder.toString()); 54 | ((Player) sender).showFormWindow(simple); 55 | } 56 | return true; 57 | } 58 | 59 | @Override 60 | public boolean hasPermission(CommandSender sender) { 61 | return sender.hasPermission("tips.achall"); 62 | } 63 | 64 | @Override 65 | public CommandParameter[] getParameters() { 66 | return new CommandParameter[0]; 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /src/main/java/tip/commands/sub/DefaultSubCommand.java: -------------------------------------------------------------------------------- 1 | package tip.commands.sub; 2 | 3 | import cn.nukkit.Player; 4 | import cn.nukkit.command.CommandSender; 5 | import cn.nukkit.command.data.CommandParameter; 6 | import tip.commands.base.BaseSubCommand; 7 | import tip.windows.CreateWindow; 8 | import tip.windows.ListenerWindow; 9 | 10 | /** 11 | * @author SmallasWater 12 | */ 13 | public class DefaultSubCommand extends BaseSubCommand { 14 | public DefaultSubCommand(String name) { 15 | super(name); 16 | } 17 | 18 | @Override 19 | public String[] getAliases() { 20 | return new String[0]; 21 | } 22 | 23 | @Override 24 | public boolean execute(CommandSender sender, String label, String[] args) { 25 | if (sender instanceof Player) { 26 | ListenerWindow.CHOSE_TYPE.put(sender.getName(),1); 27 | CreateWindow.sendSettingType((Player) sender); 28 | return true; 29 | } else { 30 | sender.sendMessage("请不要用控制台执行.."); 31 | return false; 32 | } 33 | } 34 | 35 | @Override 36 | public boolean hasPermission(CommandSender sender) { 37 | return sender.hasPermission("tips.default"); 38 | } 39 | 40 | @Override 41 | public CommandParameter[] getParameters() { 42 | return new CommandParameter[0]; 43 | } 44 | 45 | 46 | } 47 | -------------------------------------------------------------------------------- /src/main/java/tip/commands/sub/ReloadSubCommand.java: -------------------------------------------------------------------------------- 1 | package tip.commands.sub; 2 | 3 | import cn.nukkit.Player; 4 | import cn.nukkit.Server; 5 | import cn.nukkit.command.CommandSender; 6 | import cn.nukkit.command.data.CommandParameter; 7 | import cn.nukkit.utils.TextFormat; 8 | import tip.Main; 9 | import tip.commands.base.BaseSubCommand; 10 | 11 | /** 12 | * @author SmallasWater 13 | */ 14 | public class ReloadSubCommand extends BaseSubCommand { 15 | public ReloadSubCommand(String name) { 16 | super(name); 17 | } 18 | 19 | @Override 20 | public String[] getAliases() { 21 | return new String[0]; 22 | } 23 | 24 | @Override 25 | public boolean execute(CommandSender sender, String label, String[] args) { 26 | Main.getInstance().init(); 27 | for(Player player: Server.getInstance().getOnlinePlayers().values()){ 28 | Main.getInstance().loadPlayerConfig(player); 29 | } 30 | sender.sendMessage(TextFormat.YELLOW+"配置文件重新读取完成"); 31 | return true; 32 | } 33 | 34 | @Override 35 | public CommandParameter[] getParameters() { 36 | return new CommandParameter[0]; 37 | } 38 | 39 | @Override 40 | public boolean hasPermission(CommandSender sender) { 41 | return sender.hasPermission("tips.reload"); 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /src/main/java/tip/commands/sub/SendSubCommand.java: -------------------------------------------------------------------------------- 1 | package tip.commands.sub; 2 | 3 | import cn.nukkit.Player; 4 | import cn.nukkit.Server; 5 | import cn.nukkit.command.CommandSender; 6 | import cn.nukkit.command.data.CommandParamType; 7 | import cn.nukkit.command.data.CommandParameter; 8 | import tip.commands.base.BaseSubCommand; 9 | 10 | import java.util.Arrays; 11 | 12 | /** 13 | * @author SmallasWater 14 | */ 15 | public class SendSubCommand extends BaseSubCommand { 16 | public SendSubCommand(String name) { 17 | super(name); 18 | } 19 | 20 | @Override 21 | public String[] getAliases() { 22 | return new String[0]; 23 | } 24 | 25 | private final static String[] TYPES = new String[]{"tip","popup","action","title","msg"}; 26 | @Override 27 | public boolean execute(CommandSender sender, String label, String[] args) { 28 | if(args.length > 2){ 29 | String playerName = args[1]; 30 | Player player = Server.getInstance().getPlayer(playerName); 31 | if(player != null){ 32 | String type = args[2].toLowerCase(); 33 | if(Arrays.asList(TYPES).contains(type)){ 34 | String msg = args[3]; 35 | switch (type){ 36 | case "tip": 37 | player.sendTip(msg); 38 | break; 39 | case "action": 40 | player.sendActionBar(msg); 41 | break; 42 | case "popup": 43 | player.sendPopup(msg); 44 | break; 45 | case "title": 46 | String[] strings = msg.split("&"); 47 | String title = strings[0]; 48 | StringBuilder s = new StringBuilder(); 49 | if(strings.length > 1){ 50 | for(int i = 1;i < strings.length;i++){ 51 | s.append(strings[i]).append("\n"); 52 | } 53 | } 54 | player.sendTitle(title, s.toString()); 55 | break; 56 | case "msg": 57 | player.sendMessage(msg); 58 | break; 59 | default:break; 60 | } 61 | sender.sendMessage("发送成功"); 62 | return true; 63 | }else{ 64 | sender.sendMessage("请使用支持的类型: "+Arrays.asList(TYPES)); 65 | } 66 | 67 | }else{ 68 | sender.sendMessage("玩家 "+playerName+"不在线"); 69 | return true; 70 | } 71 | } 72 | return false; 73 | } 74 | 75 | @Override 76 | public CommandParameter[] getParameters() { 77 | return new CommandParameter[]{ 78 | new CommandParameter("player", CommandParamType.TARGET,true), 79 | new CommandParameter("type", TYPES), 80 | new CommandParameter("message",CommandParamType.TEXT,true) 81 | }; 82 | } 83 | 84 | @Override 85 | public boolean hasPermission(CommandSender sender) { 86 | return sender.hasPermission("tips.send"); 87 | } 88 | } 89 | -------------------------------------------------------------------------------- /src/main/java/tip/commands/sub/ThemeSubCommand.java: -------------------------------------------------------------------------------- 1 | package tip.commands.sub; 2 | 3 | import cn.nukkit.Player; 4 | import cn.nukkit.command.CommandSender; 5 | import cn.nukkit.command.data.CommandParameter; 6 | import tip.commands.base.BaseSubCommand; 7 | import tip.windows.CreateWindow; 8 | 9 | 10 | /** 11 | * @author SmallasWater 12 | * 13 | */ 14 | public class ThemeSubCommand extends BaseSubCommand { 15 | 16 | public ThemeSubCommand(String name) { 17 | super(name); 18 | 19 | } 20 | 21 | @Override 22 | public String[] getAliases() { 23 | return new String[0]; 24 | } 25 | 26 | @Override 27 | public boolean execute(CommandSender sender, String label, String[] args) { 28 | if(sender.isPlayer()){ 29 | CreateWindow.sendChoseTheme((Player) sender); 30 | return true; 31 | } 32 | return false; 33 | } 34 | 35 | @Override 36 | public boolean hasPermission(CommandSender sender) { 37 | return sender.hasPermission("tips.theme"); 38 | } 39 | 40 | @Override 41 | public CommandParameter[] getParameters() { 42 | return new CommandParameter[0]; 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /src/main/java/tip/lib/viewcompass/ViewCompassVariable.java: -------------------------------------------------------------------------------- 1 | package tip.lib.viewcompass; 2 | 3 | import cn.nukkit.Player; 4 | import tip.utils.variables.BaseVariable; 5 | 6 | /** 7 | * 本类引用 @PetteriM1 作者 的ViewCompass 方法 8 | * 9 | * @author from PetteriM1 10 | */ 11 | public class ViewCompassVariable extends BaseVariable { 12 | 13 | private static final String[] COMPASS = new String[36]; 14 | 15 | public ViewCompassVariable(Player player) { 16 | super(player); 17 | init(); 18 | } 19 | 20 | private void init() { 21 | COMPASS[0] = "\u00A77| | | | | \u00A7l\u00A71南\u00A7r\u00A77 | | | | |"; 22 | COMPASS[1] = "\u00A77| | | | \u00A7l\u00A71南\u00A7r\u00A77 | | | | | |"; 23 | COMPASS[2] = "\u00A77| | | \u00A7l\u00A71南\u00A7r\u00A77 | | | | \u00A7l\u00A7f西南\u00A7r\u00A77 | |"; 24 | COMPASS[3] = "\u00A77| | | | | | \u00A7l\u00A7f西南\u00A7r\u00A77 | | | |"; 25 | COMPASS[4] = "\u00A77| | | | | \u00A7l\u00A7f西南\u00A7r\u00A77 | | | | |"; 26 | COMPASS[5] = "\u00A77| | | | \u00A7l\u00A7f西南\u00A7r\u00A77 | | | | | |"; 27 | COMPASS[6] = "\u00A77| | \u00A7l\u00A7f西南\u00A7r\u00A77 | | | | \u00A7l\u00A7a西\u00A7r\u00A77 | | |"; 28 | COMPASS[7] = "\u00A77| | | | | | \u00A7l\u00A7a西\u00A7r\u00A77 | | | |"; 29 | COMPASS[8] = "\u00A77| | | | | \u00A7l\u00A7a西\u00A7r\u00A77 | | | | |"; 30 | COMPASS[9] = "\u00A77| | | | | \u00A7l\u00A7a西\u00A7r\u00A77 | | | | |"; 31 | COMPASS[10] = "\u00A77| | | | \u00A7l\u00A7a西\u00A7r\u00A77 | | | | | |"; 32 | COMPASS[11] = "\u00A77| | | \u00A7l\u00A7a西\u00A7r\u00A77 | | | | \u00A7l\u00A7f西北\u00A7r\u00A77 | |"; 33 | COMPASS[12] = "\u00A77| | | | | | \u00A7l\u00A7f西北\u00A7r\u00A77 | | | |"; 34 | COMPASS[13] = "\u00A77| | | | | \u00A7l\u00A7f西北\u00A7r\u00A77 | | | | |"; 35 | COMPASS[14] = "\u00A77| | | | \u00A7l\u00A7f西北\u00A7r\u00A77 | | | | | |"; 36 | COMPASS[15] = "\u00A77| | \u00A7l\u00A7f西北\u00A7r\u00A77 | | | | \u00A7l\u00A7c北\u00A7r\u00A77 | | |"; 37 | COMPASS[16] = "\u00A77| | | | | | \u00A7l\u00A7c北\u00A7r\u00A77 | | | |"; 38 | COMPASS[17] = "\u00A77| | | | | \u00A7l\u00A7c北\u00A7r\u00A77 | | | | |"; 39 | COMPASS[18] = "\u00A77| | | | | \u00A7l\u00A7c北\u00A7r\u00A77 | | | | |"; 40 | COMPASS[19] = "\u00A77| | | | \u00A7l\u00A7c北\u00A7r\u00A77 | | | | | |"; 41 | COMPASS[20] = "\u00A77| | | \u00A7l\u00A7c北\u00A7r\u00A77 | | | | \u00A7l\u00A7f东北\u00A7r\u00A77 | |"; 42 | COMPASS[21] = "\u00A77| | | | | | \u00A7l\u00A7f东北\u00A7r\u00A77 | | | |"; 43 | COMPASS[22] = "\u00A77| | | | | \u00A7l\u00A7f东北\u00A7r\u00A77 | | | | |"; 44 | COMPASS[23] = "\u00A77| | | | \u00A7l\u00A7f东北\u00A7r\u00A77 | | | | | |"; 45 | COMPASS[24] = "\u00A77| | \u00A7l\u00A7f东北\u00A7r\u00A77 | | | | \u00A7l\u00A7e东\u00A7r\u00A77 | | |"; 46 | COMPASS[25] = "\u00A77| | | | | | | \u00A7l\u00A7e东\u00A7r\u00A77 | | |"; 47 | COMPASS[26] = "\u00A77| | | | | | \u00A7l\u00A7e东\u00A7r\u00A77 | | | |"; 48 | COMPASS[27] = "\u00A77| | | | | \u00A7l\u00A7e东\u00A7r\u00A77 | | | | |"; 49 | COMPASS[28] = "\u00A77| | | | \u00A7l\u00A7e东\u00A7r\u00A77 | | | | | |"; 50 | COMPASS[29] = "\u00A77| | | \u00A7l\u00A7e东\u00A7r\u00A77 | | | | \u00A7l\u00A7f东南\u00A7r\u00A77 | |"; 51 | COMPASS[30] = "\u00A77| | | | | | \u00A7l\u00A7f东南\u00A7r\u00A77 | | | |"; 52 | COMPASS[31] = "\u00A77| | | | | \u00A7l\u00A7f东南\u00A7r\u00A77 | | | | |"; 53 | COMPASS[32] = "\u00A77| | | | \u00A7l\u00A7f东南\u00A7r\u00A77 | | | | | |"; 54 | COMPASS[33] = "\u00A77| | \u00A7l\u00A7f东南\u00A7r\u00A77 | | | | \u00A7l\u00A71南\u00A7r\u00A77 | | |"; 55 | COMPASS[34] = "\u00A77| | | | | | | \u00A7l\u00A71南\u00A7r\u00A77 | | |"; 56 | COMPASS[35] = "\u00A77| | | | | | \u00A7l\u00A71南\u00A7r\u00A77 | | | |"; 57 | } 58 | 59 | private String getCompass(double direction) { 60 | direction = direction + Math.ceil(-direction / 360) * 360; 61 | direction = direction * 2 / 10 / 2; 62 | return COMPASS[Math.round((long) direction)]; 63 | } 64 | 65 | @Override 66 | public void strReplace() { 67 | if (player == null || !player.isOnline()) { 68 | return; 69 | } 70 | addStrReplaceString("{view}", getCompass(player.getYaw())); 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /src/main/java/tip/messages/BaseMessage.java: -------------------------------------------------------------------------------- 1 | package tip.messages; 2 | 3 | 4 | import tip.utils.variables.BaseVariable; 5 | 6 | import java.util.LinkedHashMap; 7 | 8 | /** 9 | * @author SmallasWater 10 | */ 11 | public abstract class BaseMessage implements Cloneable{ 12 | 13 | public static final int BOSS_BAR_TYPE = 0; 14 | 15 | public static final int CHAT_MESSAGE_TYPE = 1; 16 | 17 | public static final int NAME_TAG_TYPE = 2; 18 | 19 | public static final int SCOREBOARD_TYPE = 3; 20 | 21 | public static final int TIP_MESSAGE_TYPE = 4; 22 | 23 | public static final int BROAD_CAST_TYPE = 5; 24 | 25 | private String worldName; 26 | 27 | 28 | private boolean open; 29 | 30 | public BaseMessage(String worldName, boolean open){ 31 | this.worldName = worldName; 32 | this.open = open; 33 | } 34 | 35 | public int getType(){ 36 | return -1; 37 | } 38 | 39 | 40 | @Override 41 | public int hashCode() { 42 | return worldName.hashCode() + getType(); 43 | } 44 | 45 | public void setWorldName(String worldName) { 46 | this.worldName = worldName; 47 | } 48 | 49 | public String getWorldName() { 50 | return worldName; 51 | } 52 | 53 | public boolean isOpen() { 54 | return open; 55 | } 56 | 57 | 58 | public void setOpen(boolean open) { 59 | this.open = open; 60 | } 61 | 62 | 63 | 64 | /** 65 | * 保存在配置的.. 66 | * @return 配置内容 67 | * */ 68 | abstract public LinkedHashMap getConfig(); 69 | 70 | @Override 71 | public boolean equals(Object obj) { 72 | if(obj instanceof BaseMessage){ 73 | return ((BaseMessage) obj).getWorldName().equalsIgnoreCase(getWorldName()) 74 | && ((BaseMessage) obj).getType() == getType(); 75 | } 76 | return false; 77 | } 78 | 79 | public static BaseTypes getBaseTypeByInteger(int type){ 80 | for(BaseTypes types:BaseTypes.values()){ 81 | if(types.getType() == type){ 82 | return types; 83 | } 84 | } 85 | return null; 86 | } 87 | 88 | public static BaseTypes getTypeByName(String name){ 89 | for(BaseTypes types:BaseTypes.values()){ 90 | if(types.getConfigName().equalsIgnoreCase(name)){ 91 | return types; 92 | } 93 | } 94 | return null; 95 | } 96 | 97 | 98 | 99 | 100 | public enum BaseTypes{ 101 | /**显示类型*/ 102 | BOSS_BAR(0,"Boss血条"), 103 | CHAT_MESSAGE(1,"聊天"), 104 | NAME_TAG(2,"头部"), 105 | SCORE_BOARD(3,"计分板"), 106 | TIP(4,"底部"), 107 | BROADCAST(5,"聊天栏公告"); 108 | protected int type; 109 | protected String configName; 110 | BaseTypes(int type,String configName){ 111 | this.type = type; 112 | this.configName = configName; 113 | } 114 | 115 | public String getConfigName() { 116 | return configName; 117 | } 118 | 119 | public int getType() { 120 | return type; 121 | } 122 | } 123 | 124 | @Override 125 | public BaseMessage clone() { 126 | try { 127 | return (BaseMessage) super.clone(); 128 | } catch (CloneNotSupportedException e) { 129 | e.printStackTrace(); 130 | } 131 | return null; 132 | } 133 | } 134 | -------------------------------------------------------------------------------- /src/main/java/tip/messages/BossBarMessage.java: -------------------------------------------------------------------------------- 1 | package tip.messages; 2 | 3 | import tip.utils.BossMessageBuilder; 4 | 5 | import java.util.LinkedHashMap; 6 | import java.util.LinkedList; 7 | 8 | /** 9 | * @author SmallasWater 10 | */ 11 | @Deprecated 12 | public class BossBarMessage extends tip.messages.defaults.BossBarMessage { 13 | 14 | 15 | public BossBarMessage(String worldName, boolean open, int time, boolean size, LinkedList message) { 16 | super(worldName, open, time, size, message); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/main/java/tip/messages/BroadcastMessage.java: -------------------------------------------------------------------------------- 1 | package tip.messages; 2 | 3 | import java.util.LinkedHashMap; 4 | import java.util.LinkedList; 5 | 6 | /** 7 | * @author SmallasWater 8 | */ 9 | @Deprecated 10 | public class BroadcastMessage extends tip.messages.defaults.BroadcastMessage { 11 | 12 | 13 | public BroadcastMessage(String worldName, boolean open, int time, LinkedList message) { 14 | super(worldName, open, time, message); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/main/java/tip/messages/ChatMessage.java: -------------------------------------------------------------------------------- 1 | package tip.messages; 2 | 3 | import java.util.LinkedHashMap; 4 | 5 | /** 6 | * @author SmallasWater 7 | */ 8 | @Deprecated 9 | public class ChatMessage extends tip.messages.defaults.ChatMessage { 10 | 11 | 12 | public ChatMessage(String worldName, boolean open, String message, boolean inWorld) { 13 | super(worldName, open, message, inWorld); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /src/main/java/tip/messages/NameTagMessage.java: -------------------------------------------------------------------------------- 1 | package tip.messages; 2 | 3 | 4 | /** 5 | * @author SmallasWater 6 | */ 7 | @Deprecated 8 | public class NameTagMessage extends tip.messages.defaults.NameTagMessage { 9 | 10 | public NameTagMessage(String worldName, boolean open, String message) { 11 | super(worldName, open, message); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /src/main/java/tip/messages/ScoreBoardMessage.java: -------------------------------------------------------------------------------- 1 | package tip.messages; 2 | 3 | 4 | import java.util.LinkedList; 5 | 6 | /** 7 | * @author SmallasWater 8 | */ 9 | @Deprecated 10 | public class ScoreBoardMessage extends tip.messages.defaults.ScoreBoardMessage { 11 | 12 | public ScoreBoardMessage(String worldName, boolean open, String title, LinkedList message) { 13 | super(worldName, open, title, message); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /src/main/java/tip/messages/TipMessage.java: -------------------------------------------------------------------------------- 1 | package tip.messages; 2 | 3 | 4 | /** 5 | * 适配旧版本的 6 | * @author SmallasWater 7 | */ 8 | @Deprecated 9 | public class TipMessage extends tip.messages.defaults.TipMessage { 10 | 11 | public TipMessage(String worldName, boolean open, int type, String message) { 12 | super(worldName, open, type, message); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /src/main/java/tip/messages/defaults/BossBarMessage.java: -------------------------------------------------------------------------------- 1 | package tip.messages.defaults; 2 | 3 | import cn.nukkit.utils.BossBarColor; 4 | import tip.messages.BaseMessage; 5 | import tip.utils.BossMessageBuilder; 6 | 7 | 8 | import java.util.LinkedHashMap; 9 | import java.util.LinkedList; 10 | 11 | /** 12 | * @author SmallasWater 13 | */ 14 | public class BossBarMessage extends BaseMessage { 15 | 16 | 17 | private int time; 18 | 19 | private LinkedList messages; 20 | 21 | private BossBarColor bossBarColor; 22 | 23 | private boolean size; 24 | 25 | public BossBarMessage(String worldName, boolean open,int time,boolean size,LinkedList message) { 26 | this(worldName, open, time, BossBarColor.RED, size, message); 27 | } 28 | 29 | public BossBarMessage(String worldName, boolean open, int time, BossBarColor bossBarColor, boolean size, LinkedList message) { 30 | super(worldName, open); 31 | this.time = time; 32 | this.messages = message; 33 | this.bossBarColor = bossBarColor; 34 | this.size = size; 35 | } 36 | 37 | public BossMessageBuilder getBuilder(){ 38 | return new BossMessageBuilder(messages,time,size,bossBarColor); 39 | } 40 | 41 | @Override 42 | public int getType() { 43 | return BOSS_BAR_TYPE; 44 | } 45 | 46 | public int getTime() { 47 | return time; 48 | } 49 | 50 | public void setTime(int time) { 51 | this.time = time; 52 | } 53 | 54 | public boolean isSize() { 55 | return size; 56 | } 57 | 58 | public void setSize(boolean size) { 59 | this.size = size; 60 | } 61 | 62 | public BossBarColor getBossBarColor() { 63 | return bossBarColor; 64 | } 65 | 66 | public void setBossBarColor(BossBarColor bossBarColor) { 67 | this.bossBarColor = bossBarColor; 68 | } 69 | 70 | public LinkedList getMessages() { 71 | return messages; 72 | } 73 | 74 | public void setMessages(LinkedList messages) { 75 | this.messages = messages; 76 | } 77 | 78 | @Override 79 | public LinkedHashMap getConfig(){ 80 | LinkedHashMap objectLinkedHashMap = new LinkedHashMap<>(); 81 | LinkedHashMap sub = new LinkedHashMap<>(); 82 | sub.put("是否开启",isOpen()); 83 | sub.put("间隔时间",getTime()); 84 | sub.put("显示颜色",getBossBarColor().name()); 85 | sub.put("是否根据玩家血量变化",isSize()); 86 | sub.put("消息轮播",getMessages()); 87 | objectLinkedHashMap.put(getWorldName(),sub); 88 | return objectLinkedHashMap; 89 | } 90 | 91 | 92 | } 93 | -------------------------------------------------------------------------------- /src/main/java/tip/messages/defaults/BroadcastMessage.java: -------------------------------------------------------------------------------- 1 | package tip.messages.defaults; 2 | 3 | import tip.messages.BaseMessage; 4 | 5 | import java.util.LinkedHashMap; 6 | import java.util.LinkedList; 7 | 8 | /** 9 | * @author SmallasWater 10 | */ 11 | public class BroadcastMessage extends BaseMessage { 12 | 13 | private int time; 14 | 15 | private LinkedList messages; 16 | public BroadcastMessage(String worldName, boolean open, int time, LinkedList message) { 17 | super(worldName, open); 18 | this.time = time; 19 | this.messages = message; 20 | } 21 | 22 | @Override 23 | public int getType() { 24 | return BROAD_CAST_TYPE; 25 | } 26 | 27 | public LinkedList getMessages() { 28 | return messages; 29 | } 30 | 31 | public void setMessages(LinkedList message) { 32 | this.messages = message; 33 | } 34 | 35 | public int getTime() { 36 | return time; 37 | } 38 | 39 | public void setTime(int time) { 40 | this.time = time; 41 | } 42 | 43 | @Override 44 | public LinkedHashMap getConfig() { 45 | LinkedHashMap objectLinkedHashMap = new LinkedHashMap<>(); 46 | LinkedHashMap sub = new LinkedHashMap<>(); 47 | sub.put("是否开启",isOpen()); 48 | sub.put("间隔时间",getTime()); 49 | sub.put("消息轮播",getMessages()); 50 | objectLinkedHashMap.put(getWorldName(),sub); 51 | return objectLinkedHashMap; 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /src/main/java/tip/messages/defaults/ChatMessage.java: -------------------------------------------------------------------------------- 1 | package tip.messages.defaults; 2 | 3 | import tip.messages.BaseMessage; 4 | 5 | import java.util.LinkedHashMap; 6 | 7 | /** 8 | * @author SmallasWater 9 | */ 10 | public class ChatMessage extends BaseMessage { 11 | 12 | private String message; 13 | 14 | private boolean inWorld; 15 | 16 | public ChatMessage(String worldName, boolean open, String message, boolean inWorld) { 17 | super(worldName, open); 18 | this.message = message; 19 | this.inWorld = inWorld; 20 | } 21 | 22 | public String getMessage() { 23 | return message; 24 | } 25 | 26 | @Override 27 | public int getType() { 28 | return CHAT_MESSAGE_TYPE; 29 | } 30 | 31 | public boolean isInWorld() { 32 | return inWorld; 33 | } 34 | 35 | public void setInWorld(boolean inWorld) { 36 | this.inWorld = inWorld; 37 | } 38 | 39 | public void setMessage(String message) { 40 | this.message = message; 41 | } 42 | 43 | @Override 44 | public LinkedHashMap getConfig(){ 45 | LinkedHashMap objectLinkedHashMap = new LinkedHashMap<>(); 46 | LinkedHashMap sub = new LinkedHashMap<>(); 47 | sub.put("是否开启",isOpen()); 48 | sub.put("显示",getMessage()); 49 | sub.put("是否仅在世界内有效",isInWorld()); 50 | objectLinkedHashMap.put(getWorldName(),sub); 51 | return objectLinkedHashMap; 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /src/main/java/tip/messages/defaults/MessageManager.java: -------------------------------------------------------------------------------- 1 | package tip.messages.defaults; 2 | 3 | 4 | import tip.messages.BaseMessage; 5 | 6 | import java.util.Arrays; 7 | import java.util.LinkedHashMap; 8 | import java.util.LinkedList; 9 | 10 | /** 11 | * @author SmallasWater 12 | */ 13 | public class MessageManager extends LinkedList { 14 | 15 | public boolean hasExistsType(BaseMessage.BaseTypes types){ 16 | for(BaseMessage message:this){ 17 | if(message.getType() == types.getType()){ 18 | return true; 19 | } 20 | } 21 | return false; 22 | } 23 | 24 | public void setMessage(BaseMessage message){ 25 | BaseMessage message1 = getMessageByTypeAndWorld(message.getWorldName(),message.getType()); 26 | if(message1 == null){ 27 | this.add(message); 28 | }else{ 29 | int i = this.indexOf(message1); 30 | if(i != -1) { 31 | this.set(i, message); 32 | } 33 | } 34 | } 35 | 36 | public BaseMessage getMessageByTypeAndWorld(String worldName,int type){ 37 | BaseMessage baseMessage = null; 38 | for(BaseMessage message: this){ 39 | if(message.getWorldName().split("&").length > 1){ 40 | if(Arrays.asList(message.getWorldName().split("&")) 41 | .contains(worldName) && type == message.getType()){ 42 | baseMessage = message; 43 | } 44 | } 45 | if("default".equalsIgnoreCase(message.getWorldName()) && message.getType() == type){ 46 | baseMessage = message; 47 | } 48 | if(worldName.equalsIgnoreCase(message.getWorldName()) && type == message.getType()){ 49 | baseMessage = message; 50 | } 51 | } 52 | return baseMessage; 53 | } 54 | 55 | public LinkedHashMap saveConfig(){ 56 | LinkedHashMap config = new LinkedHashMap<>(); 57 | for(BaseMessage message:this){ 58 | BaseMessage.BaseTypes types = BaseMessage.getBaseTypeByInteger(message.getType()); 59 | if(types != null){ 60 | config.put(types.getConfigName(),message.getConfig()); 61 | } 62 | } 63 | return config; 64 | 65 | } 66 | 67 | 68 | 69 | } 70 | -------------------------------------------------------------------------------- /src/main/java/tip/messages/defaults/NameTagMessage.java: -------------------------------------------------------------------------------- 1 | package tip.messages.defaults; 2 | 3 | import tip.messages.BaseMessage; 4 | 5 | import java.util.LinkedHashMap; 6 | 7 | /** 8 | * @author SmallasWater 9 | */ 10 | public class NameTagMessage extends BaseMessage { 11 | 12 | private String message; 13 | 14 | public NameTagMessage(String worldName, boolean open,String message) { 15 | super(worldName, open); 16 | this.message = message; 17 | } 18 | 19 | @Override 20 | public int getType() { 21 | return NAME_TAG_TYPE; 22 | } 23 | 24 | public String getMessage() { 25 | return message; 26 | } 27 | 28 | public void setMessage(String message) { 29 | this.message = message; 30 | } 31 | 32 | @Override 33 | public LinkedHashMap getConfig(){ 34 | LinkedHashMap objectLinkedHashMap = new LinkedHashMap<>(); 35 | LinkedHashMap sub = new LinkedHashMap<>(); 36 | sub.put("是否开启",isOpen()); 37 | sub.put("显示",getMessage()); 38 | objectLinkedHashMap.put(getWorldName(),sub); 39 | return objectLinkedHashMap; 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/main/java/tip/messages/defaults/ScoreBoardMessage.java: -------------------------------------------------------------------------------- 1 | package tip.messages.defaults; 2 | 3 | 4 | import tip.messages.BaseMessage; 5 | 6 | import java.util.LinkedHashMap; 7 | import java.util.LinkedList; 8 | 9 | /** 10 | * @author SmallasWater 11 | */ 12 | public class ScoreBoardMessage extends BaseMessage { 13 | 14 | private String title; 15 | 16 | private LinkedList messages; 17 | 18 | public ScoreBoardMessage(String worldName, boolean open,String title,LinkedList message) { 19 | super(worldName, open); 20 | this.title = title; 21 | this.messages = message; 22 | } 23 | 24 | @Override 25 | public int getType() { 26 | return SCOREBOARD_TYPE; 27 | } 28 | 29 | public String getTitle() { 30 | return title; 31 | } 32 | 33 | public LinkedList getMessages() { 34 | return messages; 35 | } 36 | 37 | public void setMessages(LinkedList messages) { 38 | this.messages = messages; 39 | } 40 | 41 | @Override 42 | public LinkedHashMap getConfig(){ 43 | LinkedHashMap objectLinkedHashMap = new LinkedHashMap<>(); 44 | LinkedHashMap sub = new LinkedHashMap<>(); 45 | sub.put("是否开启",isOpen()); 46 | sub.put("Title",getTitle()); 47 | sub.put("Line",getMessages()); 48 | objectLinkedHashMap.put(getWorldName(),sub); 49 | return objectLinkedHashMap; 50 | } 51 | 52 | public void setTitle(String title) { 53 | this.title = title; 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /src/main/java/tip/messages/defaults/TipMessage.java: -------------------------------------------------------------------------------- 1 | package tip.messages.defaults; 2 | 3 | import tip.messages.BaseMessage; 4 | 5 | import java.util.LinkedHashMap; 6 | 7 | /** 8 | * @author SmallasWater 9 | */ 10 | public class TipMessage extends BaseMessage { 11 | 12 | public static final int TIP = 0; 13 | 14 | public static final int POPUP = 1; 15 | 16 | public static final int ACTION = 2; 17 | 18 | 19 | private int type; 20 | 21 | private String message; 22 | 23 | public TipMessage(String worldName, boolean open,int type,String message) { 24 | super(worldName, open); 25 | this.message = message; 26 | this.type = type; 27 | } 28 | 29 | public void setType(int type) { 30 | this.type = type; 31 | } 32 | 33 | public String getMessage() { 34 | return message; 35 | } 36 | 37 | @Override 38 | public int getType() { 39 | return TIP_MESSAGE_TYPE; 40 | } 41 | 42 | public int getShowType() { 43 | return type; 44 | } 45 | 46 | public void setMessage(String message) { 47 | this.message = message; 48 | } 49 | 50 | @Override 51 | public LinkedHashMap getConfig(){ 52 | LinkedHashMap objectLinkedHashMap = new LinkedHashMap<>(); 53 | LinkedHashMap sub = new LinkedHashMap<>(); 54 | sub.put("是否开启",isOpen()); 55 | sub.put("显示类型",getShowType()); 56 | sub.put("显示",getMessage()); 57 | objectLinkedHashMap.put(getWorldName(),sub); 58 | return objectLinkedHashMap; 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /src/main/java/tip/tasks/AbstractPlayerAsyncTask.java: -------------------------------------------------------------------------------- 1 | package tip.tasks; 2 | 3 | import cn.nukkit.Player; 4 | import cn.nukkit.scheduler.AsyncTask; 5 | 6 | /** 7 | * @author SmallasWater 8 | */ 9 | public abstract class AbstractPlayerAsyncTask extends AsyncTask { 10 | 11 | private Player player; 12 | AbstractPlayerAsyncTask(Player player){ 13 | this.player = player; 14 | } 15 | 16 | public Player getPlayer() { 17 | return player; 18 | } 19 | 20 | 21 | } 22 | -------------------------------------------------------------------------------- /src/main/java/tip/tasks/AddPlayerTask.java: -------------------------------------------------------------------------------- 1 | package tip.tasks; 2 | 3 | 4 | import tip.Main; 5 | 6 | 7 | /** 8 | * @author SmallasWater 9 | */ 10 | public class AddPlayerTask { 11 | 12 | public static void add(BaseTipsRunnable task){ 13 | Main.executor.execute(task); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /src/main/java/tip/tasks/BaseTipsRunnable.java: -------------------------------------------------------------------------------- 1 | package tip.tasks; 2 | 3 | import tip.Main; 4 | 5 | /** 6 | * @author SmallasWater 7 | * Create on 2021/2/26 14:47 8 | * Package tip.tasks 9 | */ 10 | public abstract class BaseTipsRunnable implements Runnable { 11 | 12 | public Main owner; 13 | 14 | public BaseTipsRunnable(Main owner){ 15 | this.owner = owner; 16 | } 17 | 18 | public Main getOwner() { 19 | return owner; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/main/java/tip/tasks/BossBarAllPlayerTask.java: -------------------------------------------------------------------------------- 1 | package tip.tasks; 2 | 3 | import cn.nukkit.Player; 4 | import tip.Main; 5 | import tip.bossbar.BossBarApi; 6 | 7 | 8 | /** 9 | * @author SmallasWater 10 | */ 11 | public class BossBarAllPlayerTask { 12 | 13 | 14 | private Player player; 15 | 16 | public BossBarAllPlayerTask(Player player) { 17 | this.player = player; 18 | } 19 | 20 | public void onRun() { 21 | if (player == null || !player.isOnline()) { 22 | return; 23 | } 24 | BossBarApi.createBossBar(player); 25 | BossBarTask task = Main.getInstance().tasks.getIfPresent(player); 26 | if (task == null) { 27 | task = new BossBarTask(); 28 | Main.getInstance().tasks.put(player, task); 29 | } 30 | task.onRun(player); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /src/main/java/tip/tasks/BossBarTask.java: -------------------------------------------------------------------------------- 1 | package tip.tasks; 2 | 3 | import cn.nukkit.Player; 4 | import tip.Main; 5 | import tip.bossbar.BossBarApi; 6 | import tip.messages.BaseMessage; 7 | import tip.messages.defaults.BossBarMessage; 8 | import tip.utils.Api; 9 | import tip.utils.BossMessageBuilder; 10 | 11 | import java.util.LinkedHashMap; 12 | 13 | /** 14 | * @author 若水 15 | */ 16 | public class BossBarTask { 17 | 18 | private final LinkedHashMap type = new LinkedHashMap<>(); 19 | 20 | void onRun(Player player) { 21 | if (player == null) { 22 | return; 23 | } 24 | if (player.isOnline()) { 25 | if (!Main.getInstance().apis.containsKey(player)) { 26 | return; 27 | } 28 | BossBarMessage message = (BossBarMessage) Api.getSendPlayerMessage(player.getName(), player.getLevel().getFolderName(), BaseMessage.BaseTypes.BOSS_BAR); 29 | if (message != null) { 30 | if (message.isOpen()) { 31 | if (!type.containsKey(player.getLevel().getFolderName())) { 32 | type.put(player.getLevel().getFolderName(), new MessageType()); 33 | } 34 | MessageType m = type.get(player.getLevel().getFolderName()); 35 | BossMessageBuilder bossMessageBuilder = message.getBuilder(); 36 | if (m.time == -2) { 37 | m.time = bossMessageBuilder.getTime(); 38 | } 39 | if (m.time <= 0) { 40 | m.time = bossMessageBuilder.getTime(); 41 | ++m.i; 42 | } 43 | if (m.i >= bossMessageBuilder.getStrings().size()) { 44 | m.i = 0; 45 | } 46 | String text = bossMessageBuilder.getStrings().get(m.i); 47 | text = Api.strReplace(text, player); 48 | BossBarApi.showBoss(player, text, bossMessageBuilder, m.time); 49 | m.time--; 50 | } else { 51 | BossBarApi.removeBossBar(player); 52 | } 53 | } else { 54 | BossBarApi.removeBossBar(player); 55 | } 56 | } 57 | } 58 | 59 | private static class MessageType { 60 | public int i = 0; 61 | public int time = -2; 62 | } 63 | 64 | } 65 | -------------------------------------------------------------------------------- /src/main/java/tip/tasks/BroadCastPlayerTask.java: -------------------------------------------------------------------------------- 1 | package tip.tasks; 2 | 3 | import cn.nukkit.Player; 4 | import tip.messages.BaseMessage; 5 | import tip.messages.defaults.BroadcastMessage; 6 | import tip.utils.Api; 7 | 8 | import java.util.LinkedHashMap; 9 | 10 | /** 11 | * @author SmallasWater 12 | */ 13 | public class BroadCastPlayerTask { 14 | 15 | private final Player player; 16 | private final LinkedHashMap type = new LinkedHashMap<>(); 17 | 18 | 19 | public BroadCastPlayerTask(Player owner) { 20 | this.player = owner; 21 | } 22 | 23 | public void onRun() { 24 | if (player == null || !player.isOnline()) { 25 | return; 26 | } 27 | BroadcastMessage message = (BroadcastMessage) Api.getSendPlayerMessage(player.getName(), player.level.getFolderName(), BaseMessage.BaseTypes.BROADCAST); 28 | if (message != null && message.isOpen() && !message.getMessages().isEmpty()) { 29 | if (!type.containsKey(message)) { 30 | type.put(message, new MessageType()); 31 | } 32 | MessageType m = type.get(message); 33 | if (m.time == -1) { 34 | m.time = message.getTime(); 35 | m.key = true; 36 | } else if (m.time <= 0) { 37 | m.i++; 38 | m.time = message.getTime(); 39 | m.key = true; 40 | } 41 | if (m.i >= message.getMessages().size()) { 42 | m.i = 0; 43 | } 44 | if (m.key) { 45 | m.key = false; 46 | String text = message.getMessages().get(m.i); 47 | player.sendMessage(Api.strReplace(text, player)); 48 | } 49 | if (m.time > 0) { 50 | m.time--; 51 | } 52 | type.put(message, m); 53 | } 54 | } 55 | 56 | private static class MessageType { 57 | public int i = 0; 58 | 59 | public int time = -1; 60 | 61 | boolean key = false; 62 | 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /src/main/java/tip/tasks/BroadCastTask.java: -------------------------------------------------------------------------------- 1 | package tip.tasks; 2 | 3 | import cn.nukkit.Player; 4 | import cn.nukkit.Server; 5 | import cn.nukkit.scheduler.PluginTask; 6 | import tip.Main; 7 | 8 | import java.util.LinkedHashMap; 9 | 10 | 11 | /** 12 | * @author SmallasWater 13 | */ 14 | public class BroadCastTask { 15 | 16 | 17 | private Player player; 18 | private LinkedHashMap taskLinkedHashMap = new LinkedHashMap<>(); 19 | 20 | public BroadCastTask(Player player) { 21 | this.player = player; 22 | } 23 | 24 | public void onRun() { 25 | if(!taskLinkedHashMap.containsKey(player.getName())){ 26 | taskLinkedHashMap.put(player.getName(),new BroadCastPlayerTask(player)); 27 | } 28 | BroadCastPlayerTask task = taskLinkedHashMap.get(player.getName()); 29 | task.onRun(); 30 | 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /src/main/java/tip/tasks/MotdTask.java: -------------------------------------------------------------------------------- 1 | package tip.tasks; 2 | 3 | import cn.nukkit.Server; 4 | import cn.nukkit.utils.TextFormat; 5 | import com.smallaswater.serverinfo.ServerInfoMainClass; 6 | import com.smallaswater.serverinfo.servers.ServerInfo; 7 | import tip.Main; 8 | 9 | import java.util.concurrent.ThreadLocalRandom; 10 | 11 | 12 | /** 13 | * @author SmallasWater 14 | * Create on 2020/12/2 19:06 15 | * Package tip.tasks 16 | */ 17 | public class MotdTask extends BaseTipsRunnable { 18 | 19 | private boolean hasServerInfoPlugin = false; 20 | 21 | public MotdTask(Main owner) { 22 | super(owner); 23 | 24 | try { 25 | Class.forName("com.smallaswater.serverinfo.ServerInfoMainClass"); 26 | this.hasServerInfoPlugin = true; 27 | }catch (Exception ignored){ 28 | 29 | } 30 | } 31 | 32 | @Override 33 | public void run() { 34 | while (this.owner.isEnabled()) { 35 | String motd = this.owner.getMotd(); 36 | String[] strings = new String[]{"§c", "§6", "§e", "§a", "§b", "§9", "§d", "§7", "§5"}; 37 | motd = motd.replace("{online}", Server.getInstance().getOnlinePlayers().size() + ""); 38 | motd = motd.replace("{maxplayer}", Server.getInstance().getMaxPlayers() + ""); 39 | motd = motd.replace("{换行}", "\n"); 40 | motd = motd.replace("{color}", strings[ThreadLocalRandom.current().nextInt(strings.length)]); 41 | int maxOnline = 0; 42 | if (this.hasServerInfoPlugin) { 43 | for (ServerInfo info : ServerInfoMainClass.getInstance().getServerInfos()) { 44 | if (info.onLine()) { 45 | maxOnline += info.getPlayer(); 46 | motd = motd.replace("{ServerInfoPlayer@" + info.getCallback() + "}", String.valueOf(info.getPlayer())); 47 | motd = motd.replace("{ServerInfoMaxPlayer@" + info.getCallback() + "}", String.valueOf(info.getMaxPlayer())); 48 | } else { 49 | motd = motd.replace("{ServerInfoPlayer@" + info.getCallback() + "}", "服务器离线"); 50 | motd = motd.replace("{ServerInfoMaxPlayer@" + info.getCallback() + "}", "服务器离线"); 51 | } 52 | 53 | } 54 | motd = motd.replace("{ServerInfoPlayer}", maxOnline + ""); 55 | } 56 | 57 | owner.getServer().getNetwork().setName(TextFormat.colorize('&', motd)); 58 | try { 59 | Thread.sleep(getOwner().getConfig().getInt("自定义刷新刻度.motd", 20) * 50L); 60 | } catch (InterruptedException e) { 61 | e.printStackTrace(); 62 | return; 63 | } 64 | } 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /src/main/java/tip/tasks/NameTagTask.java: -------------------------------------------------------------------------------- 1 | package tip.tasks; 2 | 3 | import cn.nukkit.Player; 4 | import tip.messages.BaseMessage; 5 | import tip.messages.defaults.NameTagMessage; 6 | import tip.utils.Api; 7 | 8 | /** 9 | * @author SmallasWater 10 | */ 11 | public class NameTagTask { 12 | 13 | private Player player; 14 | 15 | public NameTagTask(Player player) { 16 | 17 | this.player = player; 18 | } 19 | 20 | public void onRun() { 21 | if (player == null || !player.isOnline()) { 22 | return; 23 | } 24 | NameTagMessage nameTagMessage = (NameTagMessage) Api.getSendPlayerMessage(player.getName(), player.level.getFolderName(), BaseMessage.BaseTypes.NAME_TAG); 25 | if (nameTagMessage != null) { 26 | if (nameTagMessage.isOpen()) { 27 | player.setNameTag(Api.strReplace(nameTagMessage.getMessage(), player)); 28 | } 29 | } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /src/main/java/tip/tasks/ScoreBoardTask.java: -------------------------------------------------------------------------------- 1 | package tip.tasks; 2 | 3 | import cn.lanink.gamecore.GameCore; 4 | import cn.lanink.gamecore.scoreboard.ScoreboardUtil; 5 | import cn.lanink.gamecore.scoreboard.base.IScoreboard; 6 | import cn.lanink.gamecore.scoreboard.ltname.SimpleScoreboard; 7 | import cn.nukkit.Player; 8 | import cn.nukkit.utils.TextFormat; 9 | import tip.Main; 10 | import tip.messages.BaseMessage; 11 | import tip.messages.defaults.ScoreBoardMessage; 12 | import tip.utils.Api; 13 | 14 | 15 | import java.util.ArrayList; 16 | import java.util.LinkedList; 17 | 18 | 19 | /** 20 | * @author 若水 21 | */ 22 | public class ScoreBoardTask { 23 | 24 | private final Player player; 25 | private final Main main; 26 | private IScoreboard scoreboard = null; 27 | 28 | public ScoreBoardTask(Player player,Main main) { 29 | this.player = player; 30 | this.main = main; 31 | 32 | try { 33 | Class.forName("cn.lanink.gamecore.scoreboard.ScoreboardUtil"); 34 | scoreboard = ScoreboardUtil.getScoreboard(); 35 | } catch (Exception ignored) { 36 | 37 | } 38 | } 39 | 40 | private Main getOwner() { 41 | return main; 42 | } 43 | 44 | public void onRun() { 45 | if (this.scoreboard == null) { 46 | return; 47 | } 48 | // for (Player player : Server.getInstance().getOnlinePlayers().values()) { 49 | if (player == null || !player.isOnline()) { 50 | return; 51 | } 52 | ScoreBoardMessage message = (ScoreBoardMessage) Api.getSendPlayerMessage(player.getName(), player.level.getFolderName(), BaseMessage.BaseTypes.SCORE_BOARD); 53 | if (message == null || !message.isOpen()) { 54 | if (getOwner().scoreboards.contains(player)) { 55 | this.scoreboard.closeScoreboard(player); 56 | getOwner().scoreboards.remove(player); 57 | } 58 | return; 59 | } 60 | 61 | if (player.isOnline()) { 62 | try { 63 | String title = Api.strReplace(message.getTitle(), player); 64 | ArrayList list = new ArrayList<>(); 65 | for (String ms : message.getMessages()) { 66 | list.add(Api.strReplace(ms, player)); 67 | } 68 | this.scoreboard.showScoreboard(player, title, list); 69 | Main.getInstance().scoreboards.add(player); 70 | } catch (Exception ignored) { 71 | } 72 | } 73 | // } 74 | } 75 | 76 | } 77 | -------------------------------------------------------------------------------- /src/main/java/tip/tasks/TipTask.java: -------------------------------------------------------------------------------- 1 | package tip.tasks; 2 | 3 | import cn.nukkit.Player; 4 | import cn.nukkit.Server; 5 | import com.google.common.cache.Cache; 6 | import com.google.common.cache.CacheBuilder; 7 | import tip.Main; 8 | import tip.utils.SendPlayerClass; 9 | 10 | import java.util.concurrent.TimeUnit; 11 | 12 | /** 13 | * @author 若水 14 | */ 15 | public class TipTask extends BaseTipsRunnable { 16 | 17 | private static final Cache sendPlayerClassCache = CacheBuilder.newBuilder() 18 | .expireAfterAccess(1, TimeUnit.MINUTES) 19 | .build(); 20 | 21 | private final int sleep; 22 | 23 | public TipTask(Main owner, int sleep) { 24 | super(owner); 25 | this.sleep = sleep * 50; 26 | } 27 | 28 | @Override 29 | public void run() { 30 | while (this.owner.isEnabled()) { 31 | for (Player player : Server.getInstance().getOnlinePlayers().values()) { 32 | try { 33 | SendPlayerClass sendPlayerClass; 34 | if ((sendPlayerClass = sendPlayerClassCache.getIfPresent(player)) == null) { 35 | sendPlayerClass = new SendPlayerClass(player, getOwner()); 36 | sendPlayerClassCache.put(player, sendPlayerClass); 37 | } 38 | sendPlayerClass.init(); 39 | } catch (Exception e) { 40 | e.printStackTrace(); 41 | } 42 | } 43 | try { 44 | Thread.sleep(sleep); 45 | } catch (InterruptedException e) { 46 | e.printStackTrace(); 47 | return; 48 | } 49 | } 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /src/main/java/tip/utils/Api.java: -------------------------------------------------------------------------------- 1 | package tip.utils; 2 | 3 | import cn.nukkit.IPlayer; 4 | import cn.nukkit.Player; 5 | import cn.nukkit.Server; 6 | import cn.nukkit.level.Level; 7 | import cn.nukkit.utils.TextFormat; 8 | import org.jetbrains.annotations.NotNull; 9 | import tip.Main; 10 | import tip.messages.BaseMessage; 11 | import tip.messages.defaults.MessageManager; 12 | import tip.utils.variables.BaseVariable; 13 | import tip.utils.variables.VariableManager; 14 | 15 | import java.lang.reflect.Constructor; 16 | import java.util.*; 17 | 18 | /** 19 | * @author 若水 20 | * Tips变量 21 | */ 22 | public final class Api { 23 | 24 | @Deprecated 25 | private final String string; 26 | @Deprecated 27 | private final IPlayer player; 28 | 29 | private static final LinkedHashMap> VARIABLE = new LinkedHashMap<>(); 30 | 31 | @Deprecated 32 | public Api(String string, IPlayer player) { 33 | this.string = string; 34 | this.player = player; 35 | } 36 | 37 | @Deprecated 38 | public String strReplace() { 39 | String m = string; 40 | m = Main.getInstance().getVarManager().toMessage((Player) player, m); 41 | 42 | return TextFormat.colorize('&', m); 43 | } 44 | 45 | public static void registerVariables(String name, Class variable) { 46 | if (VARIABLE.containsKey(name)) { 47 | return; 48 | } 49 | VARIABLE.put(name, variable); 50 | Main.getInstance().setVarManager(flush(variable)); 51 | } 52 | 53 | private static VariableManager flush(Class var) { 54 | VariableManager varManager = Main.getInstance().getVarManager(); 55 | if (Main.getInstance().getVarManager() == null) { 56 | varManager = new VariableManager(); 57 | } 58 | BaseVariable variable = Api.initVariable(var); 59 | if (variable != null) { 60 | varManager.addVariableClass(variable); 61 | } 62 | return varManager; 63 | } 64 | 65 | private static BaseVariable initVariable(Class var) { 66 | BaseVariable variable = null; 67 | for (Constructor constructor : var.getConstructors()) { 68 | try { 69 | if (constructor.getParameterCount() == 1) { 70 | variable = (BaseVariable) constructor.newInstance((Object) null); 71 | } else { 72 | variable = (BaseVariable) constructor.newInstance((Object) null, null); 73 | } 74 | } catch (Exception e) { 75 | e.printStackTrace(); 76 | return null; 77 | } 78 | } 79 | return variable; 80 | } 81 | 82 | public static String strReplace(@NotNull String string, Player player) { 83 | return TextFormat.colorize('&', Main.getInstance().getVarManager().toMessage(player, string)); 84 | } 85 | 86 | /** 87 | * 增加单个变量 88 | */ 89 | public static void addVariable(@NotNull String var, @NotNull String message) { 90 | Main.getInstance().getVarManager().addVariable(var, message); 91 | } 92 | 93 | public static BaseMessage getSendPlayerMessage(String playerName, String levelName, BaseMessage.BaseTypes baseTypes) { 94 | PlayerConfig config = Main.getInstance().getPlayerConfig(playerName); 95 | BaseMessage message = null; 96 | if (config != null) { 97 | message = config.getMessage(levelName, baseTypes.getType()); 98 | } 99 | if (message == null) { 100 | message = getLevelDefaultMessage(levelName, baseTypes); 101 | } 102 | 103 | return message; 104 | } 105 | 106 | public static BaseMessage getLevelDefaultMessage(String levelName, BaseMessage.BaseTypes baseTypes) { 107 | return Main.getInstance().getShowMessages().getMessageByTypeAndWorld(levelName, baseTypes.getType()); 108 | } 109 | 110 | public static void setLevelMessage(BaseMessage message) { 111 | Main.getInstance().getShowMessages().setMessage(message); 112 | } 113 | 114 | public static LinkedList getSettingLevels() { 115 | LinkedList linkedList = new LinkedList<>(); 116 | linkedList.add("default"); 117 | for (Level level : Server.getInstance().getLevels().values()) { 118 | if (!"default".equalsIgnoreCase(level.getFolderName())) { 119 | linkedList.add(level.getFolderName()); 120 | } 121 | } 122 | return linkedList; 123 | } 124 | 125 | public static void setPlayerShowMessage(String playerName, BaseMessage message) { 126 | PlayerConfig config = Main.getInstance().getPlayerConfigInit(playerName); 127 | config.setMessage(message); 128 | } 129 | 130 | public static void removePlayerShowMessage(String playerName, BaseMessage message) { 131 | PlayerConfig config = Main.getInstance().getPlayerConfig(playerName); 132 | if (config == null) { 133 | config = new PlayerConfig(playerName, new MessageManager(), Main.getInstance().getTheme()); 134 | } 135 | if (config.messages.contains(message)) { 136 | config.removeMessage(message); 137 | } 138 | if (config.messages.isEmpty()) { 139 | Main.getInstance().getPlayerConfigs().remove(config); 140 | } 141 | } 142 | } 143 | -------------------------------------------------------------------------------- /src/main/java/tip/utils/BossMessageBuilder.java: -------------------------------------------------------------------------------- 1 | package tip.utils; 2 | 3 | 4 | import cn.nukkit.utils.BossBarColor; 5 | 6 | import java.util.LinkedList; 7 | 8 | /** 9 | * @author 若水 10 | */ 11 | public class BossMessageBuilder { 12 | 13 | private int time; 14 | 15 | private LinkedList strings; 16 | 17 | private boolean health; 18 | 19 | private BossBarColor bossBarColor; 20 | 21 | public BossMessageBuilder(LinkedList strings,int time,boolean health){ 22 | this(strings, time, health, BossBarColor.GREEN); 23 | } 24 | 25 | public BossMessageBuilder(LinkedList strings, int time, boolean health, BossBarColor bossBarColor){ 26 | this.time = time; 27 | this.strings = strings; 28 | this.health = health; 29 | this.bossBarColor = bossBarColor; 30 | } 31 | 32 | public int getTime() { 33 | return time; 34 | } 35 | 36 | public LinkedList getStrings() { 37 | return strings; 38 | } 39 | 40 | public boolean isHealth() { 41 | return health; 42 | } 43 | 44 | public BossBarColor getBossBarColor() { 45 | return bossBarColor; 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /src/main/java/tip/utils/GameCoreDownload.java: -------------------------------------------------------------------------------- 1 | package tip.utils; 2 | 3 | import cn.lanink.gamecore.utils.VersionUtils; 4 | import cn.nukkit.Server; 5 | import cn.nukkit.math.NukkitMath; 6 | import cn.nukkit.plugin.Plugin; 7 | import com.google.common.util.concurrent.AtomicDouble; 8 | import tip.Main; 9 | 10 | import java.io.*; 11 | import java.net.HttpURLConnection; 12 | import java.net.URL; 13 | import java.net.URLClassLoader; 14 | import java.net.URLDecoder; 15 | import java.util.Arrays; 16 | import java.util.Collections; 17 | import java.util.List; 18 | import java.util.concurrent.ForkJoinPool; 19 | import java.util.concurrent.RecursiveAction; 20 | import java.util.concurrent.TimeUnit; 21 | import java.util.concurrent.atomic.AtomicLong; 22 | import java.util.function.BiConsumer; 23 | import java.util.function.Consumer; 24 | 25 | /** 26 | * 自动下载GameCore依赖工具类 27 | */ 28 | public class GameCoreDownload { 29 | 30 | private static final String USER_AGENT = "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/39.0.2171.71 Safari/537.36"; 31 | 32 | // 每个任务下载 128 kb数据 33 | private static final int THRESHOLD = 128 * 1024; 34 | 35 | public static final String MINIMUM_GAME_CORE_VERSION = "1.6.9"; 36 | private static String ACTUAL_MINIMUM_GAME_CORE_VERSION; 37 | 38 | private static final String MAVEN_URL_CENTRAL = "https://repo1.maven.org/maven2/"; 39 | private static final String MAVEN_URL_HUAWEI = "https://repo.huaweicloud.com/repository/maven/"; 40 | private static final String MAVEN_URL_LANINK = "https://repo.lanink.cn/repository/maven-public/"; 41 | 42 | private static final List GAME_CORE_URL_LIST; 43 | 44 | static { 45 | //为了防止编译依赖和实际环境区别,这里重新检查GameCore完整版本号 46 | ACTUAL_MINIMUM_GAME_CORE_VERSION = MINIMUM_GAME_CORE_VERSION.split("-")[0]; 47 | String codename = Server.getInstance().getCodename(); 48 | if ("PowerNukkitX".equalsIgnoreCase(codename)/* || "PowerNukkit".equalsIgnoreCase(codename)*/) { 49 | ACTUAL_MINIMUM_GAME_CORE_VERSION += "-PNX"; 50 | } else if ("PM1E".equalsIgnoreCase(codename)) { 51 | ACTUAL_MINIMUM_GAME_CORE_VERSION += "-PM1E"; 52 | } 53 | 54 | GAME_CORE_URL_LIST = Collections.unmodifiableList(Arrays.asList( 55 | getGameCoreUrl(MAVEN_URL_CENTRAL), 56 | getGameCoreUrl(MAVEN_URL_HUAWEI), 57 | getGameCoreUrl(MAVEN_URL_LANINK) 58 | )); 59 | } 60 | 61 | private static String getGameCoreUrl(String mavenUrl) { 62 | //插件完整下载地址 63 | return mavenUrl + "cn/lanink/MemoriesOfTime-GameCore/" + ACTUAL_MINIMUM_GAME_CORE_VERSION + "/MemoriesOfTime-GameCore-" + ACTUAL_MINIMUM_GAME_CORE_VERSION + ".jar"; 64 | } 65 | 66 | private GameCoreDownload() { 67 | throw new RuntimeException("error"); 68 | } 69 | 70 | /** 71 | * 检查并下载GameCore依赖 72 | * 73 | * @return 0 - GameCore已加载且是最新版本 1 - 无法下载GameCore 2 下载成功 74 | */ 75 | public static int checkAndDownload() { 76 | return checkAndDownload(0); 77 | } 78 | 79 | /** 80 | * 检查并下载GameCore依赖 81 | * 82 | * @param retry 重试次数(下载链接序号) 83 | * @return 0 - GameCore已加载且是最新版本 1 - 无法下载GameCore 2 下载成功 84 | */ 85 | private static int checkAndDownload(int retry) { 86 | if (retry >= GAME_CORE_URL_LIST.size()) { 87 | return 1; 88 | } 89 | String url = GAME_CORE_URL_LIST.get(retry); 90 | 91 | Plugin plugin = Server.getInstance().getPluginManager().getPlugin("MemoriesOfTime-GameCore"); 92 | 93 | if (plugin != null) { 94 | if (!VersionUtils.checkMinimumVersion(plugin, ACTUAL_MINIMUM_GAME_CORE_VERSION)) { 95 | Main.getInstance().getLogger().warning("MemoriesOfTime-GameCore依赖版本太低!正在尝试更新版本..."); 96 | File file = getPluginFile(plugin); 97 | if (file != null) { 98 | Server.getInstance().getPluginManager().disablePlugin(plugin); 99 | ClassLoader classLoader = plugin.getClass().getClassLoader(); 100 | try { 101 | if (classLoader instanceof URLClassLoader) { 102 | ((URLClassLoader) classLoader).close(); 103 | } 104 | } catch (IOException ignored) { 105 | 106 | } 107 | file.delete(); 108 | }else { 109 | Main.getInstance().getLogger().error("删除旧版本失败!请手动删除!"); 110 | } 111 | } 112 | } 113 | 114 | if (plugin == null || plugin.isDisabled()) { 115 | Main.getInstance().getLogger().info("尝试从 " + url + " 下载 MemoriesOfTime-GameCore 中..."); 116 | 117 | File file = new File(Server.getInstance().getFilePath() + "/plugins/MemoriesOfTime-GameCore-" + ACTUAL_MINIMUM_GAME_CORE_VERSION + ".jar"); 118 | 119 | try { 120 | AtomicDouble last = new AtomicDouble(-16); 121 | download(url, file, (len, fullLength) -> { 122 | double d = NukkitMath.round(len * 1.0 / fullLength * 100, 2); 123 | if (d - last.get() > 15) { // 每15%提示一次 124 | Main.getInstance().getLogger().info("已下载:" + d + "%"); 125 | last.set(d); 126 | } 127 | }); 128 | } catch (Exception e) { 129 | Main.getInstance().getLogger().error("MemoriesOfTime-GameCore依赖下载失败!"); 130 | return checkAndDownload(++retry); 131 | } 132 | 133 | Main.getInstance().getLogger().info("MemoriesOfTime-GameCore依赖下载成功!"); 134 | Server.getInstance().getPluginManager().loadPlugin(file); 135 | return 2; 136 | } 137 | return 0; 138 | } 139 | 140 | public static File getPluginFile(Plugin plugin) { 141 | File file = null; 142 | ClassLoader PluginClass = plugin.getClass().getClassLoader(); 143 | try { 144 | if (PluginClass instanceof URLClassLoader) { 145 | URLClassLoader pluginClass = (URLClassLoader) PluginClass; 146 | URL url = pluginClass.getURLs()[0]; 147 | file = new File(URLDecoder.decode(url.getFile(), "UTF-8")); 148 | } 149 | } catch (UnsupportedEncodingException ignored) { 150 | 151 | } 152 | return file; 153 | } 154 | 155 | /** 156 | * 下载 157 | * 158 | * @param strUrl 目标url 159 | * @param saveFile 保存到文件 160 | * @param callback 下载完的回调 161 | */ 162 | private static void download(String strUrl, File saveFile, BiConsumer callback) throws Exception { 163 | URL url = new URL(strUrl); 164 | HttpURLConnection connection = ((HttpURLConnection) url.openConnection()); 165 | connection.setRequestMethod("GET"); 166 | connection.setRequestProperty("Connection", "keep-alive"); 167 | connection.setRequestProperty("Accept", "*/*"); 168 | connection.setRequestProperty("User-Agent", USER_AGENT); 169 | connection.setReadTimeout(5000); 170 | 171 | 172 | long fullLength = connection.getContentLength(); 173 | if ("chunked".equals(connection.getHeaderField("Transfer-Encoding"))) { // chunked transfer 采用单线程下载 174 | RandomAccessFile out = new RandomAccessFile(saveFile, "rw"); 175 | out.seek(0); 176 | byte[] b = new byte[1024]; 177 | InputStream in = connection.getInputStream(); 178 | int read; 179 | long count = 0; 180 | while ((read = in.read(b)) >= 0) { 181 | out.write(b, 0, read); 182 | count += read; 183 | if (callback != null) { 184 | callback.accept(count, fullLength); 185 | } 186 | } 187 | in.close(); 188 | out.close(); 189 | return; 190 | } 191 | ForkJoinPool pool = new ForkJoinPool(); 192 | AtomicLong atomicLong = new AtomicLong(); 193 | pool.submit(new DownloadTask(strUrl,0, fullLength, saveFile, (l) -> { 194 | atomicLong.addAndGet(l); 195 | callback.accept(atomicLong.get(), fullLength); 196 | })); 197 | pool.shutdown(); 198 | // 同步 等待所有线程完成操作 199 | while (!pool.awaitTermination(1, TimeUnit.SECONDS)) { 200 | } 201 | if (fullLength < 1 || saveFile.length() < 1) { 202 | throw new Exception("下载失败"); 203 | } 204 | } 205 | 206 | private static class DownloadTask extends RecursiveAction { 207 | 208 | private final String strUrl; 209 | private final File file; 210 | private final long start; 211 | private final long end; 212 | 213 | private final Consumer callback; 214 | 215 | public DownloadTask(String strUrl, long start, long end, File file, Consumer callback) { 216 | this.strUrl = strUrl; 217 | this.start = start; 218 | this.end = end; 219 | this.file = file; 220 | this.callback = callback; 221 | } 222 | 223 | @Override 224 | protected void compute() { 225 | RandomAccessFile out = null; 226 | InputStream in = null; 227 | try { 228 | long l = end - start; 229 | if (l < THRESHOLD) { 230 | HttpURLConnection connection = getConnection(); 231 | connection.setRequestProperty("Range", "bytes=" + start + "-" + end); 232 | 233 | out = new RandomAccessFile(file, "rw"); 234 | out.seek(start); 235 | in = connection.getInputStream(); 236 | byte[] b = new byte[1024]; 237 | int len; 238 | while ((len = in.read(b)) >= 0) { 239 | out.write(b, 0, len); 240 | callback.accept(len); 241 | } 242 | in.close(); 243 | out.close(); 244 | } else { 245 | long mid = (start + end) / 2; 246 | new SubDownloadTask(strUrl, start, mid, file, callback).fork(); 247 | new SubDownloadTask(strUrl, mid, end, file, callback).fork(); 248 | } 249 | } catch (Exception e) { 250 | throw new RuntimeException(e); 251 | } finally { 252 | if (out != null) { 253 | try { 254 | out.close(); 255 | } catch (IOException e) { 256 | e.printStackTrace(); 257 | } 258 | } 259 | if (in != null) { 260 | try { 261 | in.close(); 262 | } catch (IOException e) { 263 | e.printStackTrace(); 264 | } 265 | } 266 | } 267 | } 268 | 269 | public HttpURLConnection getConnection() throws IOException { 270 | HttpURLConnection connection = (HttpURLConnection) new URL(strUrl).openConnection(); 271 | connection.setReadTimeout(5000); 272 | connection.setRequestMethod("GET"); 273 | connection.setRequestProperty("Connection", "keep-alive"); 274 | connection.setRequestProperty("Accept", "*/*"); 275 | connection.setRequestProperty("User-Agent", USER_AGENT); 276 | 277 | return connection; 278 | } 279 | } 280 | 281 | private static class SubDownloadTask extends DownloadTask { 282 | 283 | public SubDownloadTask(String strUrl, long start, long end, File file, Consumer callback) { 284 | super(strUrl, start, end, file, callback); 285 | } 286 | 287 | } 288 | 289 | } 290 | 291 | -------------------------------------------------------------------------------- /src/main/java/tip/utils/OnListener.java: -------------------------------------------------------------------------------- 1 | package tip.utils; 2 | 3 | import cn.nukkit.Player; 4 | import cn.nukkit.Server; 5 | import cn.nukkit.event.EventHandler; 6 | import cn.nukkit.event.EventPriority; 7 | import cn.nukkit.event.Listener; 8 | import cn.nukkit.event.player.PlayerChatEvent; 9 | import cn.nukkit.event.player.PlayerJoinEvent; 10 | import cn.nukkit.event.player.PlayerQuitEvent; 11 | import cn.nukkit.event.player.PlayerRespawnEvent; 12 | import tip.Main; 13 | import tip.bossbar.BossBarApi; 14 | import tip.messages.BaseMessage; 15 | import tip.messages.defaults.ChatMessage; 16 | 17 | import java.util.List; 18 | 19 | /** 20 | * @author 若水 21 | */ 22 | public class OnListener implements Listener { 23 | 24 | @EventHandler 25 | public void onJoin(PlayerJoinEvent event) { 26 | Main.getInstance().loadPlayerConfig(event.getPlayer()); 27 | 28 | } 29 | 30 | @EventHandler 31 | public void onQuit(PlayerQuitEvent event) { 32 | Player player = event.getPlayer(); 33 | PlayerConfig config = Main.getInstance().getPlayerConfig(player.getName()); 34 | if (config != null) { 35 | config.save(); 36 | Main.getInstance().getPlayerConfigs().remove(config); 37 | } 38 | 39 | BossBarApi.removeBossBar(player); 40 | Main.getInstance().apis.remove(player); 41 | } 42 | 43 | @EventHandler 44 | public void onPlayerRespawn(PlayerRespawnEvent event) { 45 | BossBarApi.removeBossBar(event.getPlayer()); 46 | } 47 | 48 | private String getBadWorld(String msg, List badWords) { 49 | for (Object badWord : badWords) { 50 | if (msg.contains((String) badWord)) { 51 | msg = msg.replace((String) badWord, "*"); 52 | } 53 | } 54 | return msg; 55 | } 56 | 57 | 58 | @EventHandler(priority = EventPriority.HIGH) 59 | public void onChat(PlayerChatEvent event) { 60 | if (event.isCancelled()) { 61 | return; 62 | } 63 | Player player = event.getPlayer(); 64 | String msg = event.getMessage(); 65 | 66 | ChatMessage message = (ChatMessage) Main.getInstance().getShowMessages().getMessageByTypeAndWorld(player.level.getFolderName() 67 | , BaseMessage.CHAT_MESSAGE_TYPE); 68 | PlayerConfig config = Main.getInstance().getPlayerConfig(player.getName()); 69 | if (config != null) { 70 | if (config.getMessage(player.getLevel().getFolderName(), BaseMessage.CHAT_MESSAGE_TYPE) != null) { 71 | message = (ChatMessage) config.getMessage(player.getLevel().getFolderName(), BaseMessage.CHAT_MESSAGE_TYPE); 72 | } 73 | } 74 | if (message != null) { 75 | String s = message.getMessage(); 76 | if (!message.isOpen()) { 77 | return; 78 | } 79 | if (!"".equals(s)) { 80 | String send = Api.strReplace(s, player).replace("{msg}", msg); 81 | if (message.isInWorld()) { 82 | for (Player player1 : player.getLevel().getPlayers().values()) { 83 | player1.sendMessage(send); 84 | } 85 | } else { 86 | Server.getInstance().broadcastMessage(send); 87 | } 88 | } 89 | event.setCancelled(); 90 | } 91 | 92 | } 93 | 94 | } 95 | -------------------------------------------------------------------------------- /src/main/java/tip/utils/PlayerConfig.java: -------------------------------------------------------------------------------- 1 | package tip.utils; 2 | 3 | import cn.nukkit.utils.Config; 4 | import tip.Main; 5 | import tip.messages.BaseMessage; 6 | import tip.messages.defaults.MessageManager; 7 | 8 | import java.util.LinkedHashMap; 9 | 10 | /** 11 | * @author SmallasWater 12 | */ 13 | public class PlayerConfig { 14 | 15 | public MessageManager messages; 16 | 17 | private String playerName; 18 | 19 | public PlayerConfig(String playerName,MessageManager baseMessages,String theme){ 20 | this.playerName = playerName; 21 | this.messages = baseMessages; 22 | this.theme = theme; 23 | } 24 | 25 | 26 | private String theme; 27 | 28 | 29 | 30 | public String getPlayerName() { 31 | return playerName; 32 | } 33 | 34 | public void addMessage(BaseMessage message){ 35 | messages.add(message); 36 | } 37 | 38 | 39 | public void setTheme(String theme) { 40 | this.theme = theme; 41 | } 42 | 43 | public void removeMessage(BaseMessage message){ 44 | messages.remove(message); 45 | } 46 | 47 | public void setMessage(BaseMessage message){ 48 | messages.setMessage(message); 49 | 50 | } 51 | 52 | public BaseMessage getMessageNewInstance(String levelName,int type,boolean create){ 53 | BaseMessage message = messages.getMessageByTypeAndWorld(levelName, type); 54 | if(message == null){ 55 | if(theme != null){ 56 | MessageManager message1 = Main.getInstance().getThemeManager().get(theme); 57 | if(message1 != null){ 58 | message = message1.getMessageByTypeAndWorld(levelName, type); 59 | } 60 | } 61 | } 62 | if(message == null && create){ 63 | message = Main.getInstance().getThemeManager() 64 | .getDefaultManager().getMessageByTypeAndWorld(levelName,type); 65 | if(message != null){ 66 | message = message.clone(); 67 | } 68 | } 69 | return message; 70 | } 71 | 72 | public BaseMessage getMessage(String levelName,int type){ 73 | return getMessageNewInstance(levelName,type,false); 74 | } 75 | 76 | 77 | public MessageManager getMessages() { 78 | return messages; 79 | } 80 | 81 | public void save(){ 82 | Config config = new Config(Main.getInstance().getDataFolder()+"/Players/"+playerName+".yml",2); 83 | LinkedHashMap map = new LinkedHashMap<>(); 84 | map.put("样式",theme); 85 | map.putAll(messages.saveConfig()); 86 | config.setAll(map); 87 | config.save(); 88 | } 89 | 90 | @Override 91 | public boolean equals(Object obj) { 92 | if(obj instanceof PlayerConfig){ 93 | return ((PlayerConfig) obj).playerName.equals(playerName); 94 | } 95 | return false; 96 | } 97 | } 98 | -------------------------------------------------------------------------------- /src/main/java/tip/utils/SendPlayerClass.java: -------------------------------------------------------------------------------- 1 | package tip.utils; 2 | 3 | import cn.nukkit.Player; 4 | import tip.Main; 5 | import tip.messages.BaseMessage; 6 | import tip.messages.defaults.TipMessage; 7 | import tip.tasks.BossBarAllPlayerTask; 8 | import tip.tasks.BroadCastTask; 9 | import tip.tasks.NameTagTask; 10 | import tip.tasks.ScoreBoardTask; 11 | 12 | /** 13 | * @author SmallasWater 14 | * Create on 2021/1/29 21:49 15 | * Package tip.utils 16 | */ 17 | public class SendPlayerClass { 18 | 19 | private BossBarAllPlayerTask bossTask; 20 | 21 | private BroadCastTask broadtask; 22 | 23 | private NameTagTask nametask; 24 | 25 | private ScoreBoardTask scoreTask; 26 | 27 | private Player player; 28 | private Main main; 29 | public SendPlayerClass(Player player,Main main){ 30 | this.player = player; 31 | this.main = main; 32 | 33 | } 34 | 35 | private Main getOwner() { 36 | return main; 37 | } 38 | 39 | public void init(){ 40 | if(player == null || !player.isOnline()){ 41 | return; 42 | } 43 | TipMessage tipMessage; 44 | tipMessage = (TipMessage) Api.getSendPlayerMessage(player.getName(),player.level.getFolderName(), 45 | BaseMessage.BaseTypes.TIP); 46 | if (tipMessage != null) { 47 | if (tipMessage.isOpen()) { 48 | sendTip(player, Api.strReplace(tipMessage.getMessage(), player), tipMessage.getShowType()); 49 | } 50 | } 51 | if(bossTask == null){ 52 | bossTask = new BossBarAllPlayerTask(player); 53 | } 54 | bossTask.onRun(); 55 | if(broadtask == null){ 56 | broadtask = new BroadCastTask(player); 57 | } 58 | broadtask.onRun(); 59 | if(nametask == null){ 60 | nametask = new NameTagTask(player); 61 | } 62 | nametask.onRun(); 63 | if(scoreTask == null){ 64 | scoreTask = new ScoreBoardTask(player,getOwner()); 65 | } 66 | scoreTask.onRun(); 67 | 68 | } 69 | 70 | private void sendTip(Player player,String tip,int type){ 71 | switch (type){ 72 | case TipMessage.POPUP: 73 | player.sendPopup(tip); 74 | break; 75 | case TipMessage.ACTION: 76 | player.sendActionBar(tip); 77 | break; 78 | default: 79 | player.sendTip(tip); 80 | break; 81 | } 82 | } 83 | } 84 | -------------------------------------------------------------------------------- /src/main/java/tip/utils/ThemeManager.java: -------------------------------------------------------------------------------- 1 | package tip.utils; 2 | 3 | import cn.nukkit.utils.Config; 4 | import tip.messages.defaults.MessageManager; 5 | 6 | import java.util.LinkedHashMap; 7 | import java.util.LinkedList; 8 | 9 | /** 10 | * @author SmallasWater 11 | */ 12 | public class ThemeManager extends LinkedHashMap { 13 | 14 | 15 | private LinkedHashMap configs = new LinkedHashMap<>(); 16 | 17 | public MessageManager put(String key, MessageManager value,Config config) { 18 | configs.put(key,config); 19 | return super.put(key, value); 20 | } 21 | 22 | public LinkedList getNames() { 23 | return new LinkedList<>(configs.keySet()); 24 | } 25 | 26 | 27 | public LinkedList getConfigs() { 28 | return new LinkedList<>(configs.values()); 29 | } 30 | 31 | public Config getConfig(String theme) { 32 | return configs.getOrDefault(theme,null); 33 | } 34 | 35 | public MessageManager getDefaultManager(){ 36 | return getOrDefault("default",null); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /src/main/java/tip/utils/variables/ASMTemplateCompiler.java: -------------------------------------------------------------------------------- 1 | package tip.utils.variables; 2 | 3 | import org.objectweb.asm.*; 4 | 5 | import java.util.Map; 6 | import java.util.concurrent.ConcurrentHashMap; 7 | import java.util.function.Function; 8 | import java.util.regex.Pattern; 9 | 10 | import static org.objectweb.asm.Opcodes.*; 11 | 12 | public final class ASMTemplateCompiler { 13 | 14 | private static final Pattern variablePattern = Pattern.compile("\\{([^}]+)}"); 15 | 16 | private static final Map, String>> templateCache = new ConcurrentHashMap<>(); 17 | 18 | private ASMTemplateCompiler() { 19 | 20 | } 21 | 22 | public static String strReplace(String template, Map variables) { 23 | // 调用模板函数,进行替换 24 | Function, String> templateFunc = templateCache.computeIfAbsent(template, ASMTemplateCompiler::createTemplateFunction); 25 | return templateFunc.apply(variables); 26 | } 27 | 28 | private static Function, String> createTemplateFunction(String template) { 29 | try { 30 | String className = "Tips_GeneratedTemplate_" + template.hashCode(); 31 | 32 | ClassWriter cw = new ClassWriter(ClassWriter.COMPUTE_FRAMES | ClassWriter.COMPUTE_MAXS); 33 | cw.visit(V1_8, ACC_PUBLIC, className, null, "java/lang/Object", new String[]{Function.class.getName().replace('.', '/')}); 34 | 35 | // 生成默认构造函数 36 | MethodVisitor mv = cw.visitMethod(ACC_PUBLIC, "", "()V", null, null); 37 | mv.visitCode(); 38 | mv.visitVarInsn(ALOAD, 0); 39 | mv.visitMethodInsn(INVOKESPECIAL, "java/lang/Object", "", "()V", false); 40 | mv.visitInsn(RETURN); 41 | mv.visitMaxs(0, 0); 42 | mv.visitEnd(); 43 | 44 | // 生成superReplace方法 45 | mv = cw.visitMethod(ACC_PUBLIC, "superReplace", "(Ljava/util/Map;)Ljava/lang/String;", null, null); 46 | mv.visitCode(); 47 | 48 | // 创建StringBuilder实例 49 | mv.visitTypeInsn(NEW, "java/lang/StringBuilder"); 50 | mv.visitInsn(DUP); 51 | mv.visitMethodInsn(INVOKESPECIAL, "java/lang/StringBuilder", "", "()V", false); 52 | 53 | int lastIndex = 0; 54 | java.util.regex.Matcher matcher = variablePattern.matcher(template); 55 | 56 | while (matcher.find()) { 57 | // 插入静态字符串片段 58 | if (matcher.start() > lastIndex) { 59 | mv.visitLdcInsn(template.substring(lastIndex, matcher.start())); 60 | mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/StringBuilder", "append", "(Ljava/lang/String;)Ljava/lang/StringBuilder;", false); 61 | } 62 | 63 | // 插入变量片段 64 | mv.visitVarInsn(ALOAD, 1); // 加载Map对象 65 | mv.visitLdcInsn("{" + matcher.group(1) + "}"); // 变量有大括号 66 | mv.visitMethodInsn(INVOKEINTERFACE, "java/util/Map", "get", "(Ljava/lang/Object;)Ljava/lang/Object;", true); 67 | 68 | // 判断是否为null,如果是null,使用原始变量字符串 69 | Label notNullLabel = new Label(); 70 | mv.visitInsn(DUP); // 复制Map.get的结果到栈顶 71 | mv.visitJumpInsn(IFNONNULL, notNullLabel); // 如果非null跳到notNullLabel 72 | mv.visitInsn(POP); // 弹出null值 73 | mv.visitLdcInsn("{" + matcher.group(1) + "}"); // 使用原始变量字符串 74 | mv.visitJumpInsn(GOTO, notNullLabel); 75 | 76 | mv.visitLabel(notNullLabel); // 标签位置 77 | mv.visitTypeInsn(CHECKCAST, "java/lang/String"); // 将结果转换为String 78 | mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/StringBuilder", "append", "(Ljava/lang/String;)Ljava/lang/StringBuilder;", false); 79 | 80 | lastIndex = matcher.end(); 81 | } 82 | 83 | 84 | // 插入最后的静态字符串片段 85 | if (lastIndex < template.length()) { 86 | mv.visitLdcInsn(template.substring(lastIndex)); 87 | mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/StringBuilder", "append", "(Ljava/lang/String;)Ljava/lang/StringBuilder;", false); 88 | } 89 | 90 | // 调用StringBuilder.toString() 91 | mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/StringBuilder", "toString", "()Ljava/lang/String;", false); 92 | mv.visitInsn(ARETURN); 93 | mv.visitMaxs(0, 0); // 自动计算 94 | mv.visitEnd(); 95 | 96 | // 将生成的字节码加载为Class 97 | byte[] bytecode = cw.toByteArray(); 98 | Class generatedClass = new DynamicClassLoader().defineClass(className, bytecode); 99 | 100 | // 使用lambda表达式包装生成的类,并调用superReplace方法 101 | return variables -> { 102 | try { 103 | Object instance = generatedClass.getDeclaredConstructor().newInstance(); 104 | return (String) generatedClass.getDeclaredMethod("superReplace", Map.class).invoke(instance, variables); 105 | } catch (Exception e) { 106 | throw new RuntimeException(e); 107 | } 108 | }; 109 | 110 | } catch (Exception e) { 111 | throw new RuntimeException("Failed to compile template", e); 112 | } 113 | } 114 | 115 | static class DynamicClassLoader extends ClassLoader { 116 | public Class defineClass(String name, byte[] b) { 117 | return defineClass(name, b, 0, b.length); 118 | } 119 | } 120 | } 121 | -------------------------------------------------------------------------------- /src/main/java/tip/utils/variables/BaseVariable.java: -------------------------------------------------------------------------------- 1 | package tip.utils.variables; 2 | 3 | 4 | import cn.nukkit.Player; 5 | import org.jetbrains.annotations.NotNull; 6 | 7 | import java.util.LinkedHashMap; 8 | 9 | 10 | /** 11 | * @author SmallasWater 12 | */ 13 | public abstract class BaseVariable { 14 | 15 | protected Player player; 16 | protected String string; 17 | 18 | private final LinkedHashMap var = new LinkedHashMap<>(); 19 | 20 | public BaseVariable(Player player) { 21 | this.player = player; 22 | } 23 | 24 | public boolean isResetMessage() { 25 | return false; 26 | } 27 | 28 | 29 | public String getString() { 30 | return string; 31 | } 32 | 33 | /** 34 | * 增加变量 35 | */ 36 | protected final void addStrReplaceString(@NotNull String key, @NotNull String value) { 37 | var.put(key, value); 38 | 39 | } 40 | 41 | public void setString(@NotNull String string) { 42 | this.string = string; 43 | } 44 | 45 | /** 46 | * 执行 变量转换..(在这个方法里执行添加变量..) 47 | */ 48 | public abstract void strReplace(); 49 | 50 | public LinkedHashMap getVar() { 51 | return var; 52 | } 53 | 54 | 55 | } 56 | -------------------------------------------------------------------------------- /src/main/java/tip/utils/variables/VariableManager.java: -------------------------------------------------------------------------------- 1 | package tip.utils.variables; 2 | 3 | import cn.nukkit.Player; 4 | import tip.Main; 5 | 6 | import java.util.LinkedHashMap; 7 | import java.util.LinkedList; 8 | import java.util.Map; 9 | 10 | /** 11 | * @author SmallasWater 12 | */ 13 | public final class VariableManager { 14 | 15 | public void addVariableClass(BaseVariable variable) { 16 | variablesClass.add(variable); 17 | } 18 | 19 | /** 20 | * 增加变量 21 | */ 22 | public void addVariable(String var, String message) { 23 | otherVariables.put(var, message); 24 | } 25 | 26 | private final LinkedList variablesClass = new LinkedList<>(); 27 | 28 | private final LinkedHashMap otherVariables = new LinkedHashMap<>(); 29 | 30 | private final LinkedHashMap variables = new LinkedHashMap<>(); 31 | 32 | public synchronized String toMessage(Player player, String msg) { 33 | if (msg == null) { 34 | return ""; 35 | } 36 | for (BaseVariable variable : variablesClass) { 37 | try { 38 | variable.player = player; 39 | variable.string = msg; 40 | variable.strReplace(); 41 | variables.putAll(variable.getVar()); 42 | } catch (Throwable e) { 43 | Main.getInstance().getLogger().error("VariablesClass: " + variable.getClass().getName() + " Error executing strReplace() method!", e); 44 | } 45 | } 46 | variables.putAll(otherVariables); 47 | 48 | try { 49 | return ASMTemplateCompiler.strReplace(msg, variables); 50 | } catch (Throwable e) { 51 | Main.getInstance().getLogger().error("Error executing ASMTemplateCompiler.strReplace() method!", e); 52 | String message = msg; 53 | for (Map.Entry entry : variables.entrySet()) { 54 | if (entry.getKey() == null || entry.getValue() == null) { 55 | continue; 56 | } 57 | message = message.replace(entry.getKey(), entry.getValue()); 58 | } 59 | return message; 60 | } 61 | } 62 | 63 | } 64 | -------------------------------------------------------------------------------- /src/main/java/tip/utils/variables/defaults/DefaultVariables.java: -------------------------------------------------------------------------------- 1 | package tip.utils.variables.defaults; 2 | 3 | 4 | import cn.nukkit.Achievement; 5 | import cn.nukkit.AdventureSettings; 6 | import cn.nukkit.Player; 7 | import cn.nukkit.Server; 8 | import cn.nukkit.item.Item; 9 | import me.onebone.economyapi.EconomyAPI; 10 | import tip.Main; 11 | import tip.utils.variables.BaseVariable; 12 | 13 | import java.lang.reflect.Method; 14 | import java.math.BigDecimal; 15 | import java.math.RoundingMode; 16 | import java.util.*; 17 | import java.util.concurrent.ThreadLocalRandom; 18 | 19 | /** 20 | * 默认变量 21 | * @author SmallasWater 22 | */ 23 | public class DefaultVariables extends BaseVariable { 24 | 25 | 26 | public DefaultVariables(Player player) { 27 | super(player); 28 | } 29 | 30 | @Override 31 | public void strReplace() { 32 | time(); 33 | if(player != null) { 34 | configString(); 35 | } 36 | defaultString(); 37 | } 38 | 39 | private void time() { 40 | Calendar now = Calendar.getInstance(); 41 | TimeZone timeZone = TimeZone.getTimeZone("GMT+8"); 42 | now.setTimeZone(timeZone); 43 | now.setTime(new Date()); 44 | addStrReplaceString("{年}", String.valueOf(now.get(Calendar.YEAR))); 45 | addStrReplaceString("{月}", String.valueOf(now.get(Calendar.MONTH) + 1)); 46 | addStrReplaceString("{日}", String.valueOf(now.get(Calendar.DAY_OF_MONTH))); 47 | addStrReplaceString("{时}", String.valueOf(now.get(Calendar.HOUR_OF_DAY))); 48 | addStrReplaceString("{分}", String.valueOf(now.get(Calendar.MINUTE))); 49 | addStrReplaceString("{秒}", String.valueOf(now.get(Calendar.SECOND))); 50 | addStrReplaceString("{星期}", String.valueOf(now.get(Calendar.WEEK_OF_MONTH))); 51 | if(player != null) { 52 | addStrReplaceString("{ms}",player.getPing()+"ms"); 53 | addStrReplaceString("{levelName}",player.getLevel().getFolderName()); 54 | addStrReplaceString("{x}", String.valueOf(Math.round(player.getX()))); 55 | addStrReplaceString("{y}", String.valueOf(Math.round(player.getY()))); 56 | addStrReplaceString("{z}", String.valueOf(Math.round(player.getZ()))); 57 | } 58 | 59 | addStrReplaceString("{tps}", String.valueOf(Server.getInstance().getTicksPerSecond())); 60 | 61 | } 62 | 63 | private void configString() { 64 | Map op = Main.getInstance().getConfig().get("变量显示.玩家权限", new LinkedHashMap() { 65 | { 66 | put("op", "§c[§e管理员§c]§f"); 67 | put("player", "§c[§b玩家§c]§f"); 68 | } 69 | }); 70 | String o = (String) op.get("player"); 71 | if (player.isOp()) { 72 | o = (String) op.get("op"); 73 | } 74 | addStrReplaceString("{op}", o); 75 | Map mode = Main.getInstance().getConfig().get("变量显示.游戏模式", new LinkedHashMap() { 76 | { 77 | put("0", "生存"); 78 | put("1", "创造"); 79 | put("2", "冒险"); 80 | put("3", "旁观"); 81 | } 82 | }); 83 | String m = (String) mode.get("0"); 84 | if (mode.containsKey(String.valueOf(player.getGamemode()))) { 85 | m = (String) mode.get(String.valueOf(player.getGamemode())); 86 | } 87 | addStrReplaceString("{gm}", m); 88 | Map fly = Main.getInstance().getConfig().get("变量显示.飞行", new LinkedHashMap() { 89 | { 90 | put("0", "飞行开启"); 91 | put("1", "飞行关闭"); 92 | } 93 | }); 94 | String f = (String) mode.get("1"); 95 | int i = 1; 96 | if (player.getAdventureSettings().get(AdventureSettings.Type.ALLOW_FLIGHT)) { 97 | i = 0; 98 | } 99 | if (fly.containsKey(String.valueOf(i))) { 100 | f = (String) fly.get(String.valueOf(i)); 101 | } 102 | addStrReplaceString("{fly}", f); 103 | } 104 | 105 | private void defaultString() { 106 | String[] strings = new String[]{"§c", "§6", "§e", "§a", "§b", "§9", "§d", "§7", "§5"}; 107 | addStrReplaceString("{online}", String.valueOf(Server.getInstance().getOnlinePlayers().size())); 108 | addStrReplaceString("{maxplayer}", String.valueOf(Server.getInstance().getMaxPlayers())); 109 | addStrReplaceString("{换行}", "\n"); 110 | addStrReplaceString("{color}", strings[ThreadLocalRandom.current().nextInt(strings.length)]); 111 | Optional playerOptional = Optional.ofNullable(player); 112 | if (!playerOptional.isPresent()) { 113 | return; 114 | } 115 | Player player = playerOptional.get(); 116 | if (!player.isOnline()) { 117 | return; 118 | } 119 | addStrReplaceString("{ach}", String.valueOf(player.achievements.size())); 120 | addStrReplaceString("{achCount}", String.valueOf(Achievement.achievements.size())); 121 | addStrReplaceString("{name}", player.getName()); 122 | addStrReplaceString("{h}", String.valueOf(BigDecimal.valueOf(player.getHealth()).setScale(2, RoundingMode.HALF_UP).doubleValue())); 123 | addStrReplaceString("{mh}", String.valueOf(player.getMaxHealth())); 124 | addStrReplaceString("{damage}", String.valueOf(player.getInventory().getItemInHand().getDamage())); 125 | int id = player.getInventory().getItemInHand().getId(); 126 | String displayId = String.valueOf(id); 127 | if (id == 255) {//兼容PN/PNX字符串ID 128 | //字符串ID 129 | Item item = player.getInventory().getItemInHand(); 130 | //保证能编译通过 131 | Class itemClass = item.getClass(); 132 | try { 133 | Method m = itemClass.getMethod("getNamespaceId"); 134 | displayId = (String) m.invoke(item); 135 | } catch (Exception ignore) { 136 | } 137 | } 138 | 139 | addStrReplaceString("{id}", displayId); 140 | addStrReplaceString("{food}", String.valueOf(player.getFoodData().getLevel())); 141 | addStrReplaceString("{mfood}", String.valueOf(player.getFoodData().getMaxLevel())); 142 | try { 143 | Class.forName("me.onebone.economyapi.EconomyAPI"); 144 | addStrReplaceString("{money}", String.format("%.2f", EconomyAPI.getInstance().myMoney(player))); 145 | } catch (Exception ignore) { 146 | } 147 | 148 | addStrReplaceString("{deviceOS}", this.mapDeviceOSToString(player.getLoginChainData().getDeviceOS())); 149 | addStrReplaceString("{playerVersion}", player.getLoginChainData().getGameVersion()); 150 | 151 | addStrReplaceString("{player_exp}", String.valueOf(player.getExperience())); 152 | addStrReplaceString("{player_exp_level}", String.valueOf(player.getExperienceLevel())); 153 | if (player.getExperienceLevel() >= 1) { 154 | addStrReplaceString("{player_exp_min}", String.valueOf(Player.calculateRequireExperience(player.getExperienceLevel() - 1))); 155 | } else { 156 | addStrReplaceString("{player_exp_min}", "0"); 157 | } 158 | addStrReplaceString("{player_exp_max}", String.valueOf(Player.calculateRequireExperience(player.getExperienceLevel()))); 159 | 160 | } 161 | 162 | private String mapDeviceOSToString(int os) { 163 | switch (os) { 164 | case 1: return "Android"; 165 | case 2: return "iOS"; 166 | case 3: return "macOS"; 167 | case 4: return "Fire OS"; 168 | case 5: return "Gear VR"; 169 | case 6: return "HoloLens"; 170 | case 7: return "Windows 10"; 171 | case 8: return "Windows"; 172 | case 9: return "Dedicated"; 173 | case 10: return "tvOS"; 174 | case 11: return "PlayStation"; 175 | case 12: return "Switch"; 176 | case 13: return "Xbox"; 177 | case 14: return "Windows Phone"; 178 | } 179 | return "Unknown"; 180 | } 181 | 182 | 183 | } 184 | -------------------------------------------------------------------------------- /src/main/java/tip/windows/CreateWindow.java: -------------------------------------------------------------------------------- 1 | package tip.windows; 2 | 3 | import cn.nukkit.Player; 4 | import cn.nukkit.Server; 5 | import cn.nukkit.form.element.*; 6 | import cn.nukkit.form.window.FormWindowCustom; 7 | import cn.nukkit.form.window.FormWindowSimple; 8 | import cn.nukkit.utils.Config; 9 | import tip.Main; 10 | import tip.messages.BaseMessage; 11 | import tip.utils.Api; 12 | 13 | import java.util.LinkedList; 14 | 15 | 16 | /** 17 | * @author SmallasWater 18 | */ 19 | public class CreateWindow { 20 | 21 | 22 | static int MENU = 0x123Ac01; 23 | static int SETTING = 0x123Ac02; 24 | static int CHOSE = 0x123Ac03; 25 | static int CHOSE_THEME = 0x123Ac04; 26 | 27 | public static void sendChoseTheme(Player player){ 28 | FormWindowCustom simple = new FormWindowCustom("样式选择"); 29 | LinkedList list = new LinkedList<>(); 30 | for(Config config: Main.getInstance().getThemeManager().getConfigs()){ 31 | list.add(config.getString("name", "未命名")); 32 | } 33 | list.add("关闭样式"); 34 | simple.addElement(new ElementDropdown("请选择你喜欢的样式",list)); 35 | player.showFormWindow(simple,CHOSE_THEME); 36 | 37 | } 38 | 39 | 40 | public static void sendSetting(Player player){ 41 | FormWindowSimple simple = new FormWindowSimple("玩家列表","请选择你要修改的玩家"); 42 | for(Player player1: Server.getInstance().getOnlinePlayers().values()){ 43 | simple.addButton(new ElementButton(player1.getName(), new ElementButtonImageData("path", "textures/ui/Friend2"))); 44 | } 45 | 46 | player.showFormWindow(simple,MENU); 47 | } 48 | 49 | public static void sendSettingType(Player player){ 50 | FormWindowSimple simple = new FormWindowSimple("显示类型","请选择你要修改显示类型"); 51 | for(BaseMessage.BaseTypes types: BaseMessage.BaseTypes.values()){ 52 | simple.addButton(new ElementButton(types.getConfigName(), new ElementButtonImageData("path", "textures/ui/message"))); 53 | } 54 | if(!ListenerWindow.CHOSE_TYPE.containsKey(player.getName()) || ListenerWindow.CHOSE_TYPE.get(player.getName()) == 0) { 55 | simple.addButton(getBackButton()); 56 | } 57 | player.showFormWindow(simple,SETTING); 58 | } 59 | 60 | private static ElementButton getBackButton(){ 61 | return new ElementButton("返回",new ElementButtonImageData("path","textures/ui/refresh_light")); 62 | } 63 | 64 | static void sendSettingShow(Player player, BaseMessage.BaseTypes type){ 65 | FormWindowCustom custom = new FormWindowCustom("显示设置"); 66 | custom.addElement(new ElementDropdown("请选择覆盖的地图 (default 为全地图覆盖)", Api.getSettingLevels())); 67 | custom.addElement(new ElementToggle("请选择是否开启显示",true)); 68 | switch (type){ 69 | case TIP: 70 | custom.setTitle(custom.getTitle()+"-- 底部显示"); 71 | custom.addElement(new ElementDropdown("请选择显示类型",new LinkedList(){{ 72 | add("tip"); 73 | add("popup"); 74 | add("action"); 75 | }})); 76 | custom.addElement(new ElementInput("请编辑显示内容","可空 变量参考变量文件")); 77 | break; 78 | case BOSS_BAR: 79 | custom.setTitle(custom.getTitle()+"-- Boss血条"); 80 | custom.addElement(new ElementInput("请编辑轮播时间(秒)","例如 5","5")); 81 | custom.addElement(new ElementToggle("请选择是否根据血量变化",true)); 82 | custom.addElement(new ElementInput("请编辑显示内容 轮播内容请用 & 隔开","可空 变量参考变量文件")); 83 | break; 84 | case NAME_TAG: 85 | custom.setTitle(custom.getTitle()+"-- 头部显示"); 86 | custom.addElement(new ElementInput("请编辑显示内容","可空 变量参考变量文件")); 87 | break; 88 | case SCORE_BOARD: 89 | custom.setTitle(custom.getTitle()+"-- 计分板"); 90 | custom.addElement(new ElementInput("请编辑计分板标题","可空 变量参考变量文件")); 91 | custom.addElement(new ElementInput("请编辑显示内容 个计分板内容请用 & 隔开","可空 变量参考变量文件")); 92 | break; 93 | case CHAT_MESSAGE: 94 | custom.setTitle(custom.getTitle()+"-- 聊天显示"); 95 | custom.addElement(new ElementToggle("请选择是否只在世界内聊天",false)); 96 | custom.addElement(new ElementInput("请编辑聊天内容","可空 变量参考变量文件")); 97 | break; 98 | case BROADCAST: 99 | custom.setTitle(custom.getTitle()+"-- 聊天栏公告"); 100 | custom.addElement(new ElementInput("请编辑轮播时间(秒)","例如 30","30")); 101 | custom.addElement(new ElementInput("请编辑显示内容 轮播内容请用 & 隔开","可空 变量参考变量文件")); 102 | break; 103 | default:break; 104 | } 105 | player.showFormWindow(custom,CHOSE); 106 | 107 | } 108 | 109 | 110 | } 111 | -------------------------------------------------------------------------------- /src/main/java/tip/windows/ListenerWindow.java: -------------------------------------------------------------------------------- 1 | package tip.windows; 2 | 3 | import cn.nukkit.Player; 4 | import cn.nukkit.event.EventHandler; 5 | import cn.nukkit.event.Listener; 6 | import cn.nukkit.event.player.PlayerFormRespondedEvent; 7 | import cn.nukkit.form.window.FormWindowCustom; 8 | import cn.nukkit.form.window.FormWindowSimple; 9 | import tip.Main; 10 | import tip.messages.*; 11 | import tip.messages.defaults.*; 12 | import tip.messages.defaults.BossBarMessage; 13 | import tip.messages.defaults.BroadcastMessage; 14 | import tip.messages.defaults.ChatMessage; 15 | import tip.messages.defaults.NameTagMessage; 16 | import tip.messages.defaults.ScoreBoardMessage; 17 | import tip.messages.defaults.TipMessage; 18 | import tip.utils.Api; 19 | import tip.utils.PlayerConfig; 20 | 21 | import java.util.Arrays; 22 | import java.util.LinkedHashMap; 23 | import java.util.LinkedList; 24 | 25 | /** 26 | * @author SmallasWater 27 | */ 28 | public class ListenerWindow implements Listener { 29 | 30 | 31 | private LinkedHashMap clickPlayer = new LinkedHashMap<>(); 32 | 33 | /** 0 为 改变选中玩家(展示玩家列表) 1 为default触发 (不展示玩家列表) 2为自身 (不展示玩家列表)*/ 34 | public static LinkedHashMap CHOSE_TYPE = new LinkedHashMap<>(); 35 | 36 | private LinkedHashMap clickType = new LinkedHashMap<>(); 37 | 38 | @EventHandler 39 | public void onWindow(PlayerFormRespondedEvent event){ 40 | 41 | if (event.getResponse() != null) { 42 | Player p = event.getPlayer(); 43 | int formId = event.getFormID(); 44 | if (formId == CreateWindow.MENU 45 | || formId == CreateWindow.SETTING 46 | || formId == CreateWindow.CHOSE 47 | || formId == CreateWindow.CHOSE_THEME){ 48 | if (event.getWindow() instanceof FormWindowSimple) { 49 | onListenerSimpleWindow(p, (FormWindowSimple) event.getWindow(), formId); 50 | } 51 | if (event.getWindow() instanceof FormWindowCustom) { 52 | onListenerCustomWindow(p, (FormWindowCustom) event.getWindow(), formId); 53 | } 54 | 55 | } 56 | } 57 | } 58 | 59 | private void onListenerSimpleWindow(Player player,FormWindowSimple window,int id){ 60 | if(id == CreateWindow.MENU){ 61 | clickPlayer.put(player.getName(),window.getResponse().getClickedButton().getText()); 62 | CreateWindow.sendSettingType(player); 63 | } 64 | if(id == CreateWindow.SETTING){ 65 | if(ListenerWindow.CHOSE_TYPE.containsKey(player.getName())){ 66 | BaseMessage.BaseTypes types = BaseMessage.getTypeByName(window.getResponse().getClickedButton().getText()); 67 | if (types != null) { 68 | clickType.put(player.getName(), types); 69 | CreateWindow.sendSettingShow(player, types); 70 | } 71 | }else { 72 | String playerName = clickPlayer.get(player.getName()); 73 | if (playerName != null) { 74 | BaseMessage.BaseTypes types = BaseMessage.getTypeByName(window.getResponse().getClickedButton().getText()); 75 | if (types == null) { 76 | CreateWindow.sendSetting(player); 77 | } else { 78 | clickType.put(player.getName(), types); 79 | CreateWindow.sendSettingShow(player, types); 80 | } 81 | } else { 82 | CreateWindow.sendSetting(player); 83 | } 84 | } 85 | } 86 | } 87 | 88 | private void onListenerCustomWindow(Player player,FormWindowCustom window,int id){ 89 | if(id == CreateWindow.CHOSE){ 90 | String playerName = clickPlayer.get(player.getName()); 91 | PlayerConfig config = Main.getInstance().getPlayerConfig(playerName); 92 | if(config == null){ 93 | config = new PlayerConfig(playerName,new MessageManager(),null); 94 | } 95 | BaseMessage defaultMessage; 96 | BaseMessage baseMessage; 97 | BaseMessage.BaseTypes types = clickType.get(player.getName()); 98 | String worldName = Api.getSettingLevels().get(window.getResponse() 99 | .getDropdownResponse(0).getElementID()); 100 | boolean open = window.getResponse().getToggleResponse(1); 101 | if(types != null){ 102 | defaultMessage = Main.getInstance().getShowMessages().getMessageByTypeAndWorld(worldName,types.getType()); 103 | if(defaultMessage == null){ 104 | return; 105 | } 106 | if(CHOSE_TYPE.get(player.getName()) == 0){ 107 | baseMessage = config.getMessage(worldName,types.getType()); 108 | }else if(CHOSE_TYPE.get(player.getName()) == 1){ 109 | baseMessage = Api.getLevelDefaultMessage(worldName,types); 110 | }else{ 111 | config = Main.getInstance().getPlayerConfig(player.getName()); 112 | if(config == null){ 113 | config = new PlayerConfig(player.getName(),new MessageManager(),Main.getInstance().getTheme()); 114 | } 115 | baseMessage = config.getMessage(worldName,types.getType()); 116 | } 117 | 118 | BaseMessage remove = baseMessage; 119 | switch (types){ 120 | case CHAT_MESSAGE: 121 | baseMessage = setChatBase(baseMessage,open,worldName,window,player,defaultMessage); 122 | break; 123 | case SCORE_BOARD: 124 | baseMessage = setScoreboard(baseMessage,open,worldName,window,player,defaultMessage); 125 | break; 126 | case NAME_TAG: 127 | baseMessage = setNameBase(baseMessage,open,worldName,window,player,defaultMessage); 128 | break; 129 | case TIP: 130 | baseMessage = setTipBase(baseMessage,open,worldName,window,player,defaultMessage); 131 | break; 132 | case BOSS_BAR: 133 | baseMessage = setBossBar(baseMessage,open,worldName,window,player,defaultMessage); 134 | break; 135 | case BROADCAST: 136 | baseMessage = setBroad(baseMessage,open,worldName,window,player,defaultMessage); 137 | break; 138 | default:break; 139 | } 140 | if(baseMessage != null){ 141 | if(CHOSE_TYPE.get(player.getName()) == 1){ 142 | Api.setLevelMessage(baseMessage); 143 | }else { 144 | config.setMessage(baseMessage); 145 | config.save(); 146 | } 147 | player.sendMessage("§7设置已保存.."); 148 | }else{ 149 | config.removeMessage(remove); 150 | } 151 | } 152 | } 153 | if(id == CreateWindow.CHOSE_THEME){ 154 | PlayerConfig config = Main.getInstance().getPlayerConfigInit(player.getName()); 155 | if("关闭样式".equalsIgnoreCase(window.getResponse() 156 | .getDropdownResponse(0).getElementContent())){ 157 | config.setTheme(null); 158 | player.sendMessage("§2你已关闭样式"); 159 | config.save(); 160 | return; 161 | } 162 | String name = Main.getInstance().getThemeManager().getNames().get(window.getResponse() 163 | .getDropdownResponse(0).getElementID()); 164 | config.setTheme(name); 165 | player.sendMessage("§2你已切换到 "+window.getResponse() 166 | .getDropdownResponse(0).getElementContent()+" §2样式"); 167 | config.save(); 168 | 169 | } 170 | } 171 | 172 | 173 | private BaseMessage setBroadCast(BaseMessage baseMessage, boolean open, String worldName, Player player, BroadcastMessage defaultMessage, String lines, int time){ 174 | if(lines != null && !"".equals(lines)){ 175 | LinkedList line = new LinkedList<>(Arrays.asList(lines.split("&"))); 176 | if(isEqualLine(line, defaultMessage.getMessages())){ 177 | if(open == baseMessage.isOpen() && worldName.equalsIgnoreCase(baseMessage.getWorldName())) { 178 | if(time == ((BroadcastMessage)baseMessage).getTime() ) { 179 | player.sendMessage("§c未更改"); 180 | CreateWindow.sendSettingType(player); 181 | return null; 182 | } 183 | } 184 | } 185 | if(baseMessage != null) { 186 | ((BroadcastMessage) baseMessage).setMessages(line); 187 | } 188 | 189 | }else{ 190 | ((BroadcastMessage) baseMessage).setMessages(defaultMessage.getMessages()); 191 | if(open == baseMessage.isOpen() && worldName.equalsIgnoreCase(baseMessage.getWorldName())) { 192 | if(time == ((BroadcastMessage)baseMessage).getTime()) { 193 | player.sendMessage("§7设置已初始化"); 194 | return null; 195 | } 196 | } 197 | } 198 | if(baseMessage != null) { 199 | ((BroadcastMessage) baseMessage).setTime(time); 200 | } 201 | return baseMessage; 202 | } 203 | 204 | private BaseMessage setChatBase(BaseMessage baseMessage,boolean open,String worldName,FormWindowCustom window,Player player,BaseMessage defaultMessage){ 205 | if(baseMessage == null){ 206 | baseMessage = new ChatMessage(defaultMessage.getWorldName(),defaultMessage.isOpen(),((ChatMessage)defaultMessage).getMessage(),((ChatMessage)defaultMessage).isInWorld()); 207 | } 208 | boolean inWorld = window.getResponse().getToggleResponse(2); 209 | String message = window.getResponse().getInputResponse(3); 210 | if(message != null && !"".equals(message)){ 211 | if(inWorld == ((ChatMessage)baseMessage).isInWorld() &&((ChatMessage)baseMessage).getMessage().equalsIgnoreCase(message)){ 212 | if(open == baseMessage.isOpen() && worldName.equalsIgnoreCase(baseMessage.getWorldName())) { 213 | player.sendMessage("§c未更改"); 214 | CreateWindow.sendSettingType(player); 215 | return null; 216 | } 217 | }else { 218 | ((ChatMessage) baseMessage).setInWorld(inWorld); 219 | ((ChatMessage) baseMessage).setMessage(message); 220 | } 221 | }else{ 222 | ((ChatMessage)baseMessage).setMessage( ((ChatMessage)defaultMessage).getMessage()); 223 | if(inWorld == ((ChatMessage)baseMessage).isInWorld()){ 224 | if(open == baseMessage.isOpen() && worldName.equalsIgnoreCase(baseMessage.getWorldName())) { 225 | player.sendMessage("§7设置已初始化"); 226 | return null; 227 | } 228 | }else{ 229 | ((ChatMessage) baseMessage).setInWorld(inWorld); 230 | } 231 | } 232 | return baseMessage; 233 | } 234 | 235 | private BaseMessage setNameBase(BaseMessage baseMessage,boolean open,String worldName,FormWindowCustom window,Player player,BaseMessage defaultMessage){ 236 | if(baseMessage == null){ 237 | baseMessage = new NameTagMessage(defaultMessage.getWorldName(),defaultMessage.isOpen(),((NameTagMessage)defaultMessage).getMessage()); 238 | } 239 | String message = window.getResponse().getInputResponse(2); 240 | if(message != null && !"".equals(message)){ 241 | if(((NameTagMessage)baseMessage).getMessage().equalsIgnoreCase(message)){ 242 | if(open == baseMessage.isOpen() && worldName.equalsIgnoreCase(baseMessage.getWorldName())) { 243 | player.sendMessage("§c未更改"); 244 | CreateWindow.sendSettingType(player); 245 | return null; 246 | } 247 | }else { 248 | ((NameTagMessage) baseMessage).setMessage(message); 249 | } 250 | }else{ 251 | ((NameTagMessage) baseMessage).setMessage( ((NameTagMessage) defaultMessage).getMessage()); 252 | if(open == baseMessage.isOpen() && worldName.equalsIgnoreCase(baseMessage.getWorldName())) { 253 | player.sendMessage("§7设置已初始化"); 254 | return null; 255 | } 256 | 257 | } 258 | 259 | baseMessage.setOpen(open); 260 | baseMessage.setWorldName(worldName); 261 | return baseMessage; 262 | } 263 | 264 | 265 | private BaseMessage setScoreboard(BaseMessage baseMessage,boolean open,String worldName,FormWindowCustom window,Player player,BaseMessage defaultMessage){ 266 | if(baseMessage == null){ 267 | baseMessage = new ScoreBoardMessage(defaultMessage.getWorldName(),defaultMessage.isOpen(),((ScoreBoardMessage)defaultMessage).getTitle(),((ScoreBoardMessage)defaultMessage).getMessages()); 268 | } 269 | String title = window.getResponse().getInputResponse(2); 270 | String lines = window.getResponse().getInputResponse(3); 271 | if(title != null && !"".equals(title)) { 272 | ((ScoreBoardMessage) baseMessage).setTitle(((ScoreBoardMessage)defaultMessage).getTitle()); 273 | baseMessage = setScoreBoardMessage(baseMessage, open, worldName, player, (ScoreBoardMessage) defaultMessage, lines,title); 274 | 275 | }else{ 276 | title = ((ScoreBoardMessage)defaultMessage).getTitle(); 277 | baseMessage = setScoreBoardMessage(baseMessage, open, worldName, player, (ScoreBoardMessage) defaultMessage, lines,title); 278 | } 279 | if(baseMessage != null){ 280 | baseMessage.setOpen(open); 281 | baseMessage.setWorldName(worldName); 282 | ((ScoreBoardMessage)baseMessage).setTitle(title); 283 | } 284 | 285 | return baseMessage; 286 | 287 | } 288 | 289 | private BaseMessage setBossBarMessage(BaseMessage baseMessage, boolean open, String worldName, Player player, BossBarMessage defaultMessage, String lines, int time, boolean size) { 290 | if(lines != null && !"".equals(lines)){ 291 | LinkedList line = new LinkedList<>(Arrays.asList(lines.split("&"))); 292 | if(isEqualLine(line, defaultMessage.getMessages())){ 293 | if(open == baseMessage.isOpen() && worldName.equalsIgnoreCase(baseMessage.getWorldName())) { 294 | if(time == ((BossBarMessage)baseMessage).getTime() && size == ((BossBarMessage)baseMessage).isSize()) { 295 | player.sendMessage("§c未更改"); 296 | CreateWindow.sendSettingType(player); 297 | return null; 298 | } 299 | } 300 | } 301 | if(baseMessage != null) { 302 | ((BossBarMessage) baseMessage).setMessages(line); 303 | } 304 | 305 | }else{ 306 | ((BossBarMessage) baseMessage).setMessages(defaultMessage.getMessages()); 307 | if(open == baseMessage.isOpen() && worldName.equalsIgnoreCase(baseMessage.getWorldName())) { 308 | if(time == ((BossBarMessage)baseMessage).getTime() && size == ((BossBarMessage)baseMessage).isSize()) { 309 | player.sendMessage("§7设置已初始化"); 310 | return null; 311 | } 312 | } 313 | } 314 | if(baseMessage != null) { 315 | ((BossBarMessage) baseMessage).setTime(time); 316 | ((BossBarMessage) baseMessage).setSize(size); 317 | } 318 | return baseMessage; 319 | } 320 | 321 | private boolean isEqualLine(LinkedList str1,LinkedList str2){ 322 | return str1.toString().equalsIgnoreCase(str2.toString()); 323 | } 324 | 325 | private BaseMessage setBroad(BaseMessage baseMessage,boolean open,String worldName,FormWindowCustom window,Player player,BaseMessage defaultMessage){ 326 | if(baseMessage == null){ 327 | baseMessage = new BroadcastMessage(defaultMessage.getWorldName(),defaultMessage.isOpen(),((BroadcastMessage)defaultMessage).getTime(),((BroadcastMessage)defaultMessage).getMessages()); 328 | } 329 | String timeString = window.getResponse().getInputResponse(2); 330 | String message = window.getResponse().getInputResponse(3); 331 | int time = ((BroadcastMessage) defaultMessage).getTime(); 332 | if(timeString != null && !"".equals(timeString)) { 333 | try{ 334 | time = Integer.parseInt(timeString); 335 | }catch (Exception ignore){} 336 | baseMessage = setBroadCast(baseMessage,open,worldName,player, (BroadcastMessage) defaultMessage,message,time); 337 | }else{ 338 | baseMessage = setBroadCast(baseMessage,open,worldName,player, (BroadcastMessage) defaultMessage,message,time); 339 | } 340 | 341 | if(baseMessage != null){ 342 | baseMessage.setOpen(open); 343 | baseMessage.setWorldName(worldName); 344 | } 345 | 346 | return baseMessage; 347 | 348 | } 349 | 350 | private BaseMessage setBossBar(BaseMessage baseMessage,boolean open,String worldName,FormWindowCustom window,Player player,BaseMessage defaultMessage){ 351 | if(baseMessage == null){ 352 | baseMessage = new BossBarMessage(defaultMessage.getWorldName(),defaultMessage.isOpen(),((BossBarMessage)defaultMessage).getTime(),((BossBarMessage)defaultMessage).isSize(),((BossBarMessage)defaultMessage).getMessages()); 353 | } 354 | String timeString = window.getResponse().getInputResponse(2); 355 | boolean size = window.getResponse().getToggleResponse(3); 356 | String message = window.getResponse().getInputResponse(4); 357 | int time = ((BossBarMessage) defaultMessage).getTime(); 358 | if(timeString != null && !"".equals(timeString)) { 359 | try{ 360 | time = Integer.parseInt(timeString); 361 | }catch (Exception ignore){} 362 | baseMessage = setBossBarMessage(baseMessage,open,worldName,player, (BossBarMessage) defaultMessage,message,time,size); 363 | }else{ 364 | baseMessage = setBossBarMessage(baseMessage,open,worldName,player, (BossBarMessage) defaultMessage,message,time,size); 365 | } 366 | 367 | if(baseMessage != null){ 368 | baseMessage.setOpen(open); 369 | baseMessage.setWorldName(worldName); 370 | } 371 | 372 | return baseMessage; 373 | 374 | } 375 | 376 | private BaseMessage setScoreBoardMessage(BaseMessage baseMessage, boolean open, String worldName, Player player, ScoreBoardMessage defaultMessage, String lines,String title) { 377 | if(lines != null && !"".equals(lines)){ 378 | LinkedList line = new LinkedList<>(Arrays.asList(lines.split("&"))); 379 | if(isEqualLine(line, defaultMessage.getMessages())){ 380 | if(open == baseMessage.isOpen() && worldName.equalsIgnoreCase(baseMessage.getWorldName())) { 381 | if(title.equalsIgnoreCase(((ScoreBoardMessage)baseMessage).getTitle())) { 382 | player.sendMessage("§c未更改"); 383 | CreateWindow.sendSettingType(player); 384 | return null; 385 | } 386 | } 387 | } 388 | ((ScoreBoardMessage)baseMessage).setMessages(line); 389 | }else{ 390 | ((ScoreBoardMessage) baseMessage).setMessages(defaultMessage.getMessages()); 391 | if(open == baseMessage.isOpen() && worldName.equalsIgnoreCase(baseMessage.getWorldName())) { 392 | if(title.equalsIgnoreCase(((ScoreBoardMessage)baseMessage).getTitle())) { 393 | player.sendMessage("§7设置已初始化"); 394 | return null; 395 | } 396 | } 397 | } 398 | return baseMessage; 399 | } 400 | 401 | private BaseMessage setTipBase(BaseMessage baseMessage,boolean open,String worldName,FormWindowCustom window,Player player,BaseMessage defaultMessage){ 402 | if(baseMessage == null){ 403 | baseMessage = new TipMessage(defaultMessage.getWorldName(),defaultMessage.isOpen(),((TipMessage)defaultMessage).getShowType(),((TipMessage)defaultMessage).getMessage()); 404 | } 405 | int showType = window.getResponse().getDropdownResponse(2).getElementID(); 406 | String message = window.getResponse().getInputResponse(3); 407 | if(message != null && !"".equals(message)){ 408 | if(((TipMessage)baseMessage).getMessage().equalsIgnoreCase(message)){ 409 | if(open == baseMessage.isOpen() && worldName.equalsIgnoreCase(baseMessage.getWorldName())) { 410 | if(showType == ((TipMessage)baseMessage).getShowType()) { 411 | player.sendMessage("§c未更改"); 412 | CreateWindow.sendSettingType(player); 413 | return null; 414 | } 415 | } 416 | } 417 | ((TipMessage) baseMessage).setMessage(message); 418 | ((TipMessage) baseMessage).setType(showType); 419 | }else{ 420 | ((TipMessage)baseMessage).setMessage(((TipMessage)defaultMessage).getMessage()); 421 | if(open == baseMessage.isOpen() && worldName.equalsIgnoreCase(baseMessage.getWorldName())) { 422 | if(showType == ((TipMessage)baseMessage).getShowType()) { 423 | player.sendMessage("§7设置已初始化"); 424 | return null; 425 | } 426 | } 427 | ((TipMessage) baseMessage).setType(showType); 428 | } 429 | baseMessage.setOpen(open); 430 | baseMessage.setWorldName(worldName); 431 | return baseMessage; 432 | } 433 | } 434 | -------------------------------------------------------------------------------- /src/main/resources/Tips变量.txt: -------------------------------------------------------------------------------- 1 | 版本: v2.2.1 2 | 3 | 变量 & 介绍: 4 | 基础变量: 5 | {name} : 玩家名称 6 | {h} : 玩家血量 7 | {mh} : 玩家血量上限 8 | {id} : 玩家手持物品ID 9 | {damage} : 玩家手持物品的特殊值 10 | {money} : 玩家金钱数量 (EconomyAPI) 11 | {ms} : 玩家的延迟 12 | {levelName}: 玩家当前地图名称 13 | {deviceOS} : 玩家设备系统 14 | {playerVersion}: 玩家客户端版本 15 | {view} : 玩家视角指南针 16 | {online} : 在线玩家数量 17 | {maxplayer}: 服务器最大人数上限 18 | {年}: 当前时间 年 19 | {月}: 当前时间 月 20 | {日}: 当前时间 日 21 | {时}: 当前时间 时 22 | {分}: 当前时间 分 23 | {秒}: 当前时间 秒 24 | {food} 玩家饥饿度 25 | {mfood} 玩家饥饿度上限 26 | {msg} 玩家聊天内容 27 | {x}{y}{z}:当前坐标 28 | {gm} :玩家游戏模式 29 | {fly} :玩家飞行状态 30 | {op} :玩家权限 31 | {ach} : 玩家完成的成就数量 32 | {achCount}: 玩家成就总数 33 | {color} : 随机字符颜色 34 | {player_exp} 玩家当前经验值 35 | {player_exp_level} 玩家当前经验等级 36 | {player_exp_min} 玩家当前等级的经验值下限 37 | {player_exp_max} 玩家当前等级的经验值上限 38 | 39 | 40 | 41 | 以下变量使用还需要配合Tips变量扩展插件! 42 | 以下变量使用还需要配合Tips变量扩展插件!! 43 | 以下变量使用还需要配合Tips变量扩展插件!!! 44 | 45 | 安装 LevelAwakenSystem (等级插件)可显示 变量 46 | {属性} : 玩家的RPG属性 47 | {天赋} : 玩家评分 48 | {换行} : 文本换行 49 | {level} : 玩家等级 50 | {exp} : 玩家当前经验 51 | {mexp} : 玩家当前经验最大值 52 | {dw} : 玩家物理攻击 53 | {df} : 玩家法术攻击 54 | {dlw} : 玩家物理防御 55 | {dlf} : 玩家法术防御 56 | {b} :玩家暴击 57 | {kb} : 玩家抗暴 58 | {kx} : 玩家抗性 59 | {c} :玩家穿透 60 | {饰品} : 玩家当前装备的饰品 61 | {pvp} : 玩家PVP 状态 (暂时不可用) 62 | 63 | 安装 HealthAPI 可显示 64 | {hb} : 玩家血量百分比 65 | 66 | 安装 Titles(称号) 插件 (购买SVIP赠送) 可显示 变量 67 | {ch} : 玩家称号 68 | 69 | 安装 SVIP 插件 可显示 变量(售卖插件 50RMB) 70 | {vip} : 玩家vip等级 71 | 72 | 安装 RsWeapon(自定义武器) 插件 可显示 变量 73 | {武器名称} : 玩家手持武器的名称 74 | {宝石个数} : 玩家手持武器的宝石个数 75 | {头盔} : 玩家装备的头盔 76 | {胸甲} : 玩家装备的胸甲 77 | {护腿} : 玩家装备的护腿 78 | {靴子} : 玩家装备的靴子 79 | {头盔宝石} : 玩家装备的头盔宝石个数 80 | {胸甲宝石} : 玩家装备的胸甲宝石个数 81 | {护腿宝石} : 玩家装备的护腿宝石个数 82 | {靴子宝石} : 玩家装备的靴子宝石个数 83 | 84 | 安装 RsWeapon 1.7.1版本 Tips 1.3.3版本 85 | 显示变量 86 | {we-damage}: 玩家武器攻击力 87 | {we-armor}: 玩家盔甲护甲值 88 | {we-health}: 玩家盔甲生命值 89 | {we-kick}: 玩家武器击退值 90 | {we-dkick}: 玩家盔甲抗击退值 91 | {we-todamage}: 玩家盔甲反伤百分比 92 | 93 | 安装好友 Friend 含 v1.1.7 以上版本 94 | {onlineFriend}: 获取在线好友数量 95 | {maxFriend} : 获取所有好友数量 96 | {mailFriend} : 获取好友邮件的数量 97 | 98 | 安装 RsTask (任务)可显示: 99 | {task-name} 正在进行中的任务 (显示第一个) 100 | {task-count} 玩家任务积分 101 | 102 | 安装 PlayerPoints (点券)插件 可显示 变量 103 | {point} : 显示玩家点券数量 104 | 105 | 106 | 安装OreArea (矿区)插件可显示 107 | {arealevel} 玩家矿区等级 108 | {nextarealevel} 玩家下一阶段矿区等级 109 | 110 | 111 | 安装OreArea (1.2.7以上版本) (矿区)插件可显示 112 | {oreareaTime}: 玩家在矿区的使用时间 113 | {oreareaReset}: 矿区刷新剩余时间 114 | {oreareaName}: 玩家所在矿区名称 115 | 116 | 安装 ServerInfo 插件可显示 117 | {ServerInfoPlayer@服务器名(这个在ServerInfo插件的配置内)}: 显示服务器的在线人数 118 | {ServerInfoMaxPlayer@服务器名(这个在ServerInfo插件的配置内)}: 显示服务器的最大在线人数 119 | 120 | 121 | ==================支持不是若水的插件=========== 122 | 123 | 安装 Money 插件 可显示 变量 124 | {money-coin}: Money 的第一个经济 125 | {money-point}: Money 的第二个经济 126 | 127 | 安装 KDR 插件可显示 128 | {kdrkills} 玩家击杀数 129 | {kdrdeath} 玩家死亡数 130 | {kdr} 玩家KDR 131 | 132 | 安装泥土公会可显示: 133 | {gh} 玩家公会名称 134 | {zw} 玩家公会职位 135 | 136 | 安装MarryN 插件可显示 137 | {marry} 结婚 138 | {sex} 性别 139 | 140 | 安装 ZSociety 可显示 141 | ${societyGrade} 公会等级 142 | ${societyName} 公会名字 143 | ${societyPost} 公会职位 144 | ${title} ZSociety称号 145 | ${zmarry} ZSociety 结婚 146 | 147 | 安装称号(Qwetitle 插件) 148 | {qt_ch} : 玩家称号 149 | 150 | 安装YRJob 插件变量 151 | {yr-job}: 职业 152 | 153 | 安装YRRPG 插件变量 154 | {yr-level}: 等级 155 | {yr-exp}: 经验 156 | {yr-maxExp} 最大值经验 157 | {yr-damage} 攻击 158 | {yr-defense} 防御 159 | {yr-suckblood} 吸血 160 | {yr-health} 血量 161 | {yr-defusedamage} 减伤 162 | {yr-counterattack} 反伤 163 | {yr-critprobability} 暴击率 164 | {yr-critrate} 暴击倍率 165 | {yr-title} 称号 166 | 167 | -------------------------------------------------------------------------------- /src/main/resources/config.yml: -------------------------------------------------------------------------------- 1 | 变量显示: 2 | 无称号显示: "§c无称号" 3 | 无VIP显示: "§c无VIP" 4 | 无公会显示: " c无公会" 5 | 无结婚显示: "§c单身" 6 | 玩家权限: 7 | op: "§c[§e管理员§c]§f" 8 | player: "§c[§a玩家§c]§f" 9 | 游戏模式: 10 | "0": "生存" 11 | "1": "创造" 12 | "2": "冒险" 13 | "3": "旁观" 14 | 飞行: 15 | "0": "飞行开启" 16 | "1": "飞行关闭" 17 | 18 | # 这里可以设置样式 19 | # 默认为 default 和 easy 20 | # 样式可以在 theme 文件夹添加 21 | 默认样式: default 22 | 23 | 自定义刷新刻度: 24 | 底部: 20 25 | Boss血条: 20 26 | 头部: 20 27 | 计分板: 20 28 | 聊天栏公告: 20 29 | motd: 20 30 | 31 | 自定义MOTD: 32 | 是否启用: false 33 | 内容: "&l{color}当前在线人数 {online}/{maxplayer}\n{version}" 34 | 自定义指令: 35 | name: tips 36 | aliases: 37 | - 底部 38 | description: 自定义玩家提示 39 | 40 | -------------------------------------------------------------------------------- /src/main/resources/levelMessage.yml: -------------------------------------------------------------------------------- 1 | # 均可使用RPG 里的变量 VIP 称号 2 | Boss血条: 3 | default: 4 | 是否开启: true 5 | 是否根据玩家血量变化: true 6 | 消息轮播: 7 | - "{color} 欢迎来到 本服务器 " 8 | - "{color} 您当前位于 §2{levelName} {color}世界" 9 | 间隔时间: 5 10 | 头部: 11 | default: 12 | 是否开启: true 13 | 显示: "{vip} §2✤§r {ch} §2✤§6 {name}§2 {ms}\n§2❤§b {h}/{mh}" 14 | 聊天: 15 | default: 16 | 是否开启: true 17 | 是否仅在世界内有效: false 18 | 显示: "§7[§a{levelName}§7]§4[§6▶§f{ch}§4]§2[§cVIP♥§f{vip}§2]{name} §b>>> {msg}" 19 | 底部: 20 | default: 21 | 是否开启: false 22 | # 0 : tip 1: popup 2:actionBar 23 | 显示类型: 0 24 | 显示: "§c✎手持>{id}:{damage} §9☣地图>{levelName} §d♨生命>{h}/{mh} §f۞在线>{online}/{maxplayer} §b❉延迟>{ms} \n §2✤称号>{ch} 25 | \ §e♈金币>{money} §7☼时间>{时}:{分}:{秒} §3❤坐标>x: {x} y: {y} z: {z}" 26 | 聊天栏公告: 27 | default: 28 | 是否开启: true 29 | 间隔时间: 30 30 | 消息轮播: 31 | - "§7[ 公告 ]§a 欢迎大家来到本服务器" 32 | - "§7[ 公告 ]§e 当前在线玩家 {online} / {maxplayer}" 33 | 34 | 计分板: 35 | default: 36 | 是否开启: true 37 | Title: "§7--§e◎{color} 服务器名 §e◎§7--" 38 | Line: 39 | - "" 40 | - "§6◎世界: §b {levelName}" 41 | - "§6◎位置: §2 {x},{y},{z}" 42 | - " " 43 | - "§6◎金币: §e {money}" 44 | - "§6◎手持: §e {id}:{damage}" 45 | - " " 46 | - "§6◎人数: §c {online} / {maxplayer}" 47 | - "§6◎延迟: §2 {ms}" 48 | - " " 49 | - "§7--§e◎§2==>> ~*..*~§2<<==§e◎§7--" 50 | -------------------------------------------------------------------------------- /src/main/resources/plugin.yml: -------------------------------------------------------------------------------- 1 | name: Tips 2 | main: tip.Main 3 | version: "2.2.2" 4 | api: ["1.0.8"] 5 | 6 | load: POSTWORLD 7 | 8 | 9 | permissions: 10 | tips.default: 11 | description: "修改默认显示" 12 | default: op 13 | tips.send: 14 | description: "发送提示" 15 | default: op 16 | tips.reload: 17 | description: "重载插件" 18 | default: op 19 | tips.theme: 20 | description: "设置自身的显示样式" 21 | default: true 22 | tips.achall: 23 | description: "打开成就GUI" 24 | default: true -------------------------------------------------------------------------------- /src/main/resources/theme/default.yml: -------------------------------------------------------------------------------- 1 | name: §d默认风格 2 | Boss血条: 3 | default: 4 | 是否开启: true 5 | 间隔时间: 5 6 | 是否根据玩家血量变化: false 7 | 显示颜色: RED 8 | 消息轮播: 9 | - '§e[系统] §a欢迎来到本服务器{换行}{换行}§e[系统]§7 游玩时请遵循服务器的规章制度 ' 10 | - '§e[系统] §a欢迎来到本服务器{换行}{换行}§e[系统]§7 未成年玩家请注意游戏时长 掌控好游玩时间' 11 | - '§e[系统] §a欢迎来到本服务器{换行}{换行}§e[系统]§7 拒绝盗版游戏 享受健康生活 ' 12 | 头部: 13 | default: 14 | 是否开启: true 15 | 显示: '{vip} §2✤§r {ch} §2✤§6 {name}§2 {ms}\n§2❤§b {h}/{mh}' 16 | 聊天: 17 | default: 18 | 是否开启: true 19 | 显示: "§7[§e{levelName}§7] §7[§a{ms}§7] §b{name} §7>> §r{msg}" 20 | 是否仅在世界内有效: false 21 | 底部: 22 | default: 23 | 是否开启: false 24 | 显示类型: 0 25 | 显示: "" 26 | 聊天栏公告: 27 | default: 28 | 是否开启: false 29 | 间隔时间: 30 30 | 消息轮播: 31 | - '§7[ 公告 ]§a 欢迎大家来到本服务器' 32 | - '§7[ 公告 ]§e 当前在线玩家 {online} / {maxplayer}' 33 | 计分板: 34 | default: 35 | 是否开启: true 36 | Title: '§7--§e◎{color} {name}信息栏 §e◎§7--' 37 | Line: 38 | - '' 39 | - '§e◎§f世界: §a {levelName}' 40 | - '§e◎§f位置: §e {x},{y},{z}' 41 | - ' ' 42 | - '§e◎§f金币: §a {money}' 43 | - '§e◎§f手持: §b {id}:{damage}' 44 | - ' ' 45 | - '§e◎§f人数: §7 {online} / {maxplayer}' 46 | - '§e◎§f延迟: §a {ms}' 47 | - ' ' 48 | - '§7--§e◎§2==>> ~*..*~§2<<==§e◎§7--' 49 | -------------------------------------------------------------------------------- /src/main/resources/theme/easy.yml: -------------------------------------------------------------------------------- 1 | # 均可使用RPG 里的变量 VIP 称号 2 | name: "§a简易风格" 3 | 头部: 4 | world: 5 | 是否开启: true 6 | 显示: "§e {name}§2 {ms}\n[§2❤§b {h}/{mh}]" 7 | default: 8 | 是否开启: true 9 | 显示: "§e {name}§2 {ms}\n[§2❤§b {h}/{mh}]" 10 | 聊天: 11 | default: 12 | 是否开启: true 13 | 是否仅在世界内有效: false 14 | 显示: "§7[§a{levelName}§7] §e{name} §7->§r {msg}" 15 | 底部: 16 | default: 17 | 是否开启: true 18 | # 0 : tip 1: popup 2:actionBar 19 | 显示类型: 0 20 | 显示: "§b{id}:{damage} §7||§r §a{levelName} §7||§r §l§o§e¥{money}§r §7||§r §a{online}§d/§c{maxplayer}" 21 | 22 | --------------------------------------------------------------------------------