├── .github ├── ISSUE_TEMPLATE │ └── bug_report.md ├── dependabot.yml └── workflows │ ├── autobuild.yml │ └── create-release.yml ├── .gitignore ├── CODE_OF_CONDUCT.md ├── CONTRIBUTING.md ├── LICENSE ├── README.md ├── ensure-java-16 ├── jitpack.yml ├── licenseheader.txt ├── logo-square.png ├── logo.png ├── pom.xml └── src └── main ├── java └── de │ └── jeter │ └── chatex │ ├── ChannelHandler.java │ ├── ChatEx.java │ ├── ChatListener.java │ ├── CommandHandler.java │ ├── EssentialsAFKListener.java │ ├── PlayerListener.java │ ├── PurpurAFKListener.java │ ├── api │ ├── ChatExAPI.java │ └── events │ │ ├── MessageBlockedByAdManagerEvent.java │ │ ├── MessageBlockedBySpamManagerEvent.java │ │ ├── MessageContainsBlockedWordEvent.java │ │ ├── PlayerUsesGlobalChatEvent.java │ │ └── PlayerUsesRangeModeEvent.java │ ├── plugins │ ├── LuckPerms.java │ ├── Nothing.java │ ├── PermissionsPlugin.java │ ├── PluginManager.java │ └── Vault.java │ └── utils │ ├── AntiSpamManager.java │ ├── ChatLogger.java │ ├── Config.java │ ├── CustomCharts.java │ ├── DomainDictionary.java │ ├── HookManager.java │ ├── Locales.java │ ├── LogHelper.java │ ├── RGBColors.java │ ├── Utils.java │ └── adManager │ ├── AdManager.java │ ├── SimpleAdManager.java │ └── SmartAdManager.java └── resources ├── locales ├── de-DE.yml ├── es-ES.yml ├── fr-FR.yml ├── ja-JP.yml ├── pt-BR.yml ├── ru-RU.yml ├── tr-TR.yml └── zh-CN.yml └── plugin.yml /.github/ISSUE_TEMPLATE/bug_report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug report 3 | about: Create a report to help us improve 4 | title: "[BUG]" 5 | labels: '' 6 | assignees: '' 7 | 8 | --- 9 | 10 | **Describe the bug** 11 | A clear and concise description of what the bug is. 12 | 13 | **To Reproduce** 14 | Steps to reproduce the behavior: 15 | 16 | 1. Go to '...' 17 | 2. Click on '....' 18 | 3. Scroll down to '....' 19 | 4. See error 20 | 21 | **Expected behavior** 22 | A clear and concise description of what you expected to happen. 23 | 24 | **Screenshots** 25 | If applicable, add screenshots to help explain your problem. 26 | 27 | **Please complete the following information:** 28 | 29 | - OS: [e.g. Ubuntu, Debian] 30 | - Java Version [e.g. 1.8, 1.7] 31 | - Minecraft Version [e.g. 1.16] 32 | - ChatEx Version [e.g. 2.6.0] 33 | 34 | **Files (please complete the following information):** 35 | 36 | - Link to Server Startup Log file: 37 | - Link to ChatEx Configuration file: 38 | 39 | **Additional context** 40 | Add any other context about the problem here. 41 | -------------------------------------------------------------------------------- /.github/dependabot.yml: -------------------------------------------------------------------------------- 1 | # To get started with Dependabot version updates, you'll need to specify which 2 | # package ecosystems to update and where the package manifests are located. 3 | # Please see the documentation for all configuration options: 4 | # https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates 5 | 6 | version: 2 7 | updates: 8 | - package-ecosystem: "maven" # See documentation for possible values 9 | directory: "/" # Location of package manifests 10 | schedule: 11 | interval: "daily" 12 | commit-message: 13 | # Prefix all commit messages with "npm: " 14 | prefix: "maven" 15 | - package-ecosystem: "github-actions" 16 | # Workflow files stored in the 17 | # default location of `.github/workflows` 18 | directory: "/" 19 | schedule: 20 | interval: "daily" 21 | commit-message: 22 | # Prefix all commit messages with "npm: " 23 | prefix: "gh-actions" 24 | -------------------------------------------------------------------------------- /.github/workflows/autobuild.yml: -------------------------------------------------------------------------------- 1 | name: Create DevBuild 2 | 3 | on: 4 | pull_request: 5 | branches: 6 | - master 7 | 8 | jobs: 9 | create-prerelease: 10 | name: Create Dev Build 11 | runs-on: ubuntu-latest 12 | 13 | steps: 14 | - name: Checkout code 15 | uses: actions/checkout@v4.1.7 16 | 17 | - name: Set up JDK 17 18 | uses: actions/setup-java@v4.2.1 19 | with: 20 | distribution: 'zulu' 21 | java-version: '17' 22 | java-package: jdk # optional (jdk or jre) - defaults to jdk 23 | cache: 'maven' 24 | - name: Build with Maven 25 | run: mvn clean install 26 | -------------------------------------------------------------------------------- /.github/workflows/create-release.yml: -------------------------------------------------------------------------------- 1 | name: Create Release 2 | 3 | on: 4 | push: 5 | branches: 6 | - master 7 | 8 | jobs: 9 | create-release: 10 | if: "startsWith(github.event.head_commit.message, 'v')" 11 | name: Create Release 12 | runs-on: ubuntu-latest 13 | steps: 14 | - name: Checkout code 15 | uses: actions/checkout@v4.1.7 16 | with: 17 | fetch-depth: 0 18 | - name: Set up JDK 19 | uses: actions/setup-java@v4.2.1 20 | with: 21 | distribution: 'zulu' 22 | java-version: '17' 23 | java-package: jdk # optional (jdk or jre) - defaults to jdk 24 | cache: 'maven' 25 | - name: Build with Maven 26 | run: mvn clean install 27 | - name: Create Prerelease 28 | if: ${{contains(github.event.head_commit.message, '-SNAPSHOT')}} 29 | id: create_prerelease 30 | uses: softprops/action-gh-release@v2.0.8 31 | env: 32 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 33 | with: 34 | name: ChatEx ${{ github.event.head_commit.message }} 35 | tag_name: ${{ github.event.head_commit.message }} 36 | files: target/ChatEx.jar 37 | generate_release_notes: true 38 | prerelease: true 39 | - name: Create Release 40 | if: ${{!contains(github.event.head_commit.message, '-SNAPSHOT')}} 41 | id: create_release 42 | uses: softprops/action-gh-release@v2.0.8 43 | env: 44 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 45 | with: 46 | name: ChatEx ${{ github.event.head_commit.message }} 47 | tag_name: ${{ github.event.head_commit.message }} 48 | files: target/ChatEx.jar 49 | generate_release_notes: true 50 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | /target/ 2 | /.idea/ 3 | dependency-reduced-pom.xml 4 | nb-configuration.xml -------------------------------------------------------------------------------- /CODE_OF_CONDUCT.md: -------------------------------------------------------------------------------- 1 | # Contributor Covenant Code of Conduct 2 | 3 | ## Our Pledge 4 | 5 | In the interest of fostering an open and welcoming environment, we as 6 | contributors and maintainers pledge to making participation in our project and 7 | our community a harassment-free experience for everyone, regardless of age, body 8 | size, disability, ethnicity, sex characteristics, gender identity and expression, 9 | level of experience, education, socio-economic status, nationality, personal 10 | appearance, race, religion, or sexual identity and orientation. 11 | 12 | ## Our Standards 13 | 14 | Examples of behavior that contributes to creating a positive environment 15 | include: 16 | 17 | * Using welcoming and inclusive language 18 | * Being respectful of differing viewpoints and experiences 19 | * Gracefully accepting constructive criticism 20 | * Focusing on what is best for the community 21 | * Showing empathy towards other community members 22 | 23 | Examples of unacceptable behavior by participants include: 24 | 25 | * The use of sexualized language or imagery and unwelcome sexual attention or 26 | advances 27 | * Trolling, insulting/derogatory comments, and personal or political attacks 28 | * Public or private harassment 29 | * Publishing others' private information, such as a physical or electronic 30 | address, without explicit permission 31 | * Other conduct which could reasonably be considered inappropriate in a 32 | professional setting 33 | 34 | ## Our Responsibilities 35 | 36 | Project maintainers are responsible for clarifying the standards of acceptable 37 | behavior and are expected to take appropriate and fair corrective action in 38 | response to any instances of unacceptable behavior. 39 | 40 | Project maintainers have the right and responsibility to remove, edit, or 41 | reject comments, commits, code, wiki edits, issues, and other contributions 42 | that are not aligned to this Code of Conduct, or to ban temporarily or 43 | permanently any contributor for other behaviors that they deem inappropriate, 44 | threatening, offensive, or harmful. 45 | 46 | ## Scope 47 | 48 | This Code of Conduct applies both within project spaces and in public spaces 49 | when an individual is representing the project or its community. Examples of 50 | representing a project or community include using an official project e-mail 51 | address, posting via an official social media account, or acting as an appointed 52 | representative at an online or offline event. Representation of a project may be 53 | further defined and clarified by project maintainers. 54 | 55 | ## Enforcement 56 | 57 | Instances of abusive, harassing, or otherwise unacceptable behavior may be 58 | reported by contacting the project team at joey.peter1998@gmail.com. All 59 | complaints will be reviewed and investigated and will result in a response that 60 | is deemed necessary and appropriate to the circumstances. The project team is 61 | obligated to maintain confidentiality with regard to the reporter of an incident. 62 | Further details of specific enforcement policies may be posted separately. 63 | 64 | Project maintainers who do not follow or enforce the Code of Conduct in good 65 | faith may face temporary or permanent repercussions as determined by other 66 | members of the project's leadership. 67 | 68 | ## Attribution 69 | 70 | This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, 71 | available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html 72 | 73 | [homepage]: https://www.contributor-covenant.org 74 | 75 | For answers to common questions about this code of conduct, see 76 | https://www.contributor-covenant.org/faq 77 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | [![ChatEx Logo](https://github.com/TheJeterLP/ChatEx/blob/master/logo.png?raw=true)](https://www.spigotmc.org/resources/chatex-continued.71041/) 2 | [![Create DevBuild](https://github.com/TheJeterLP/ChatEx/actions/workflows/autobuild.yml/badge.svg)](https://github.com/TheJeterLP/ChatEx/actions/workflows/autobuild.yml) 3 | [![JitPack](https://jitpack.io/v/TheJeterLP/ChatEx.svg)](https://jitpack.io/#TheJeterLP/ChatEx) 4 | 5 | Developer requirements 6 | ------------ 7 | 8 | * The Java 8 or newer JDK 9 | * Maven 10 | * Git 11 | 12 | Developer Informations 13 | ------------ 14 | If you want to contribute, feel free to fork the project and create pull requests. Your help is really appreciated! 15 | Every developer of the ChatEx team is able to create branches and merge it into master. Once the development of a 16 | feature has started, the developer creates a new branch named after the feature. Once a feature is finished, the branch 17 | becomes merged to the master branch to prevent commit conflicts. 18 | Everybody who is not from the developer team, can make pull requests to the main branch and we will review them and 19 | maybe merge them. 20 | 21 | To clone: 22 | 23 | ``` 24 | git clone https://github.com/TheJeterLP/ChatEx.git 25 | ``` 26 | 27 | To create a new branch, go to [Github](https://github.com/TheJeterLP/ChatEx), click on branch master and create a new 28 | branch. 29 | Otherwise use: 30 | 31 | ``` 32 | git branch [username] 33 | git checkout [username] 34 | git branch -u origin/[username] 35 | ``` 36 | 37 | To switch to a branch 38 | 39 | ```` 40 | git pull origin BRANCHNAME 41 | git checkout BRANCHNAME 42 | ```` 43 | 44 | To merge the master branch to a branch: 45 | 46 | ``` 47 | git pull origin master 48 | git checkout BRANCHNAME 49 | git merge master 50 | ``` 51 | 52 | To merge a branch to the master branch: 53 | 54 | ``` 55 | git pull origin master 56 | git checkout master 57 | git merge BRANCHNAME 58 | ``` 59 | 60 | Commit Structure 61 | ------------ 62 | If you make a commit, use the tags below in your commit. For example: 63 | 64 | ``` 65 | [MOD] Change the way how players get stored in the database 66 | ``` 67 | 68 | So always prefix your commit message with one of these tags: 69 | 70 | * [MOD] : You have modified something in the existing code 71 | * [ADD] : You've added something new to the code 72 | * [FIX] : Fixed a problem/bug 73 | * [OPTIMIZATION] or [OPT] : Some optimization done in the code 74 | * [DEV] : Something only related to development 75 | * [DEBUG] or [DEB] : Related to help the debugging. 76 | * [IGNORE] or [IGN] : Related to the .gitignore file 77 | * [REMOVE] or [REM] : Related to removing files/code. 78 | * [MPR] : Merge Pull Requests 79 | 80 | If you have already commited something, but want to add another commit, 81 | just type ```git commit -amend``` 82 | BUT: Only use this if you did not push already. If you pushed already, you need to make a new commit. 83 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 2, June 1991 3 | 4 | Copyright (C) 1989, 1991 Free Software Foundation, Inc., 5 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 6 | Everyone is permitted to copy and distribute verbatim copies 7 | of this license document, but changing it is not allowed. 8 | 9 | Preamble 10 | 11 | The licenses for most software are designed to take away your 12 | freedom to share and change it. By contrast, the GNU General Public 13 | License is intended to guarantee your freedom to share and change free 14 | software--to make sure the software is free for all its users. This 15 | General Public License applies to most of the Free Software 16 | Foundation's software and to any other program whose authors commit to 17 | using it. (Some other Free Software Foundation software is covered by 18 | the GNU Lesser General Public License instead.) You can apply it to 19 | your programs, too. 20 | 21 | When we speak of free software, we are referring to freedom, not 22 | price. Our General Public Licenses are designed to make sure that you 23 | have the freedom to distribute copies of free software (and charge for 24 | this service if you wish), that you receive source code or can get it 25 | if you want it, that you can change the software or use pieces of it 26 | in new free programs; and that you know you can do these things. 27 | 28 | To protect your rights, we need to make restrictions that forbid 29 | anyone to deny you these rights or to ask you to surrender the rights. 30 | These restrictions translate to certain responsibilities for you if you 31 | distribute copies of the software, or if you modify it. 32 | 33 | For example, if you distribute copies of such a program, whether 34 | gratis or for a fee, you must give the recipients all the rights that 35 | you have. You must make sure that they, too, receive or can get the 36 | source code. And you must show them these terms so they know their 37 | rights. 38 | 39 | We protect your rights with two steps: (1) copyright the software, and 40 | (2) offer you this license which gives you legal permission to copy, 41 | distribute and/or modify the software. 42 | 43 | Also, for each author's protection and ours, we want to make certain 44 | that everyone understands that there is no warranty for this free 45 | software. If the software is modified by someone else and passed on, we 46 | want its recipients to know that what they have is not the original, so 47 | that any problems introduced by others will not reflect on the original 48 | authors' reputations. 49 | 50 | Finally, any free program is threatened constantly by software 51 | patents. We wish to avoid the danger that redistributors of a free 52 | program will individually obtain patent licenses, in effect making the 53 | program proprietary. To prevent this, we have made it clear that any 54 | patent must be licensed for everyone's free use or not licensed at all. 55 | 56 | The precise terms and conditions for copying, distribution and 57 | modification follow. 58 | 59 | GNU GENERAL PUBLIC LICENSE 60 | TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 61 | 62 | 0. This License applies to any program or other work which contains 63 | a notice placed by the copyright holder saying it may be distributed 64 | under the terms of this General Public License. The "Program", below, 65 | refers to any such program or work, and a "work based on the Program" 66 | means either the Program or any derivative work under copyright law: 67 | that is to say, a work containing the Program or a portion of it, 68 | either verbatim or with modifications and/or translated into another 69 | language. (Hereinafter, translation is included without limitation in 70 | the term "modification".) Each licensee is addressed as "you". 71 | 72 | Activities other than copying, distribution and modification are not 73 | covered by this License; they are outside its scope. The act of 74 | running the Program is not restricted, and the output from the Program 75 | is covered only if its contents constitute a work based on the 76 | Program (independent of having been made by running the Program). 77 | Whether that is true depends on what the Program does. 78 | 79 | 1. You may copy and distribute verbatim copies of the Program's 80 | source code as you receive it, in any medium, provided that you 81 | conspicuously and appropriately publish on each copy an appropriate 82 | copyright notice and disclaimer of warranty; keep intact all the 83 | notices that refer to this License and to the absence of any warranty; 84 | and give any other recipients of the Program a copy of this License 85 | along with the Program. 86 | 87 | You may charge a fee for the physical act of transferring a copy, and 88 | you may at your option offer warranty protection in exchange for a fee. 89 | 90 | 2. You may modify your copy or copies of the Program or any portion 91 | of it, thus forming a work based on the Program, and copy and 92 | distribute such modifications or work under the terms of Section 1 93 | above, provided that you also meet all of these conditions: 94 | 95 | a) You must cause the modified files to carry prominent notices 96 | stating that you changed the files and the date of any change. 97 | 98 | b) You must cause any work that you distribute or publish, that in 99 | whole or in part contains or is derived from the Program or any 100 | part thereof, to be licensed as a whole at no charge to all third 101 | parties under the terms of this License. 102 | 103 | c) If the modified program normally reads commands interactively 104 | when run, you must cause it, when started running for such 105 | interactive use in the most ordinary way, to print or display an 106 | announcement including an appropriate copyright notice and a 107 | notice that there is no warranty (or else, saying that you provide 108 | a warranty) and that users may redistribute the program under 109 | these conditions, and telling the user how to view a copy of this 110 | License. (Exception: if the Program itself is interactive but 111 | does not normally print such an announcement, your work based on 112 | the Program is not required to print an announcement.) 113 | 114 | These requirements apply to the modified work as a whole. If 115 | identifiable sections of that work are not derived from the Program, 116 | and can be reasonably considered independent and separate works in 117 | themselves, then this License, and its terms, do not apply to those 118 | sections when you distribute them as separate works. But when you 119 | distribute the same sections as part of a whole which is a work based 120 | on the Program, the distribution of the whole must be on the terms of 121 | this License, whose permissions for other licensees extend to the 122 | entire whole, and thus to each and every part regardless of who wrote it. 123 | 124 | Thus, it is not the intent of this section to claim rights or contest 125 | your rights to work written entirely by you; rather, the intent is to 126 | exercise the right to control the distribution of derivative or 127 | collective works based on the Program. 128 | 129 | In addition, mere aggregation of another work not based on the Program 130 | with the Program (or with a work based on the Program) on a volume of 131 | a storage or distribution medium does not bring the other work under 132 | the scope of this License. 133 | 134 | 3. You may copy and distribute the Program (or a work based on it, 135 | under Section 2) in object code or executable form under the terms of 136 | Sections 1 and 2 above provided that you also do one of the following: 137 | 138 | a) Accompany it with the complete corresponding machine-readable 139 | source code, which must be distributed under the terms of Sections 140 | 1 and 2 above on a medium customarily used for software interchange; or, 141 | 142 | b) Accompany it with a written offer, valid for at least three 143 | years, to give any third party, for a charge no more than your 144 | cost of physically performing source distribution, a complete 145 | machine-readable copy of the corresponding source code, to be 146 | distributed under the terms of Sections 1 and 2 above on a medium 147 | customarily used for software interchange; or, 148 | 149 | c) Accompany it with the information you received as to the offer 150 | to distribute corresponding source code. (This alternative is 151 | allowed only for noncommercial distribution and only if you 152 | received the program in object code or executable form with such 153 | an offer, in accord with Subsection b above.) 154 | 155 | The source code for a work means the preferred form of the work for 156 | making modifications to it. For an executable work, complete source 157 | code means all the source code for all modules it contains, plus any 158 | associated interface definition files, plus the scripts used to 159 | control compilation and installation of the executable. However, as a 160 | special exception, the source code distributed need not include 161 | anything that is normally distributed (in either source or binary 162 | form) with the major components (compiler, kernel, and so on) of the 163 | operating system on which the executable runs, unless that component 164 | itself accompanies the executable. 165 | 166 | If distribution of executable or object code is made by offering 167 | access to copy from a designated place, then offering equivalent 168 | access to copy the source code from the same place counts as 169 | distribution of the source code, even though third parties are not 170 | compelled to copy the source along with the object code. 171 | 172 | 4. You may not copy, modify, sublicense, or distribute the Program 173 | except as expressly provided under this License. Any attempt 174 | otherwise to copy, modify, sublicense or distribute the Program is 175 | void, and will automatically terminate your rights under this License. 176 | However, parties who have received copies, or rights, from you under 177 | this License will not have their licenses terminated so long as such 178 | parties remain in full compliance. 179 | 180 | 5. You are not required to accept this License, since you have not 181 | signed it. However, nothing else grants you permission to modify or 182 | distribute the Program or its derivative works. These actions are 183 | prohibited by law if you do not accept this License. Therefore, by 184 | modifying or distributing the Program (or any work based on the 185 | Program), you indicate your acceptance of this License to do so, and 186 | all its terms and conditions for copying, distributing or modifying 187 | the Program or works based on it. 188 | 189 | 6. Each time you redistribute the Program (or any work based on the 190 | Program), the recipient automatically receives a license from the 191 | original licensor to copy, distribute or modify the Program subject to 192 | these terms and conditions. You may not impose any further 193 | restrictions on the recipients' exercise of the rights granted herein. 194 | You are not responsible for enforcing compliance by third parties to 195 | this License. 196 | 197 | 7. If, as a consequence of a court judgment or allegation of patent 198 | infringement or for any other reason (not limited to patent issues), 199 | conditions are imposed on you (whether by court order, agreement or 200 | otherwise) that contradict the conditions of this License, they do not 201 | excuse you from the conditions of this License. If you cannot 202 | distribute so as to satisfy simultaneously your obligations under this 203 | License and any other pertinent obligations, then as a consequence you 204 | may not distribute the Program at all. For example, if a patent 205 | license would not permit royalty-free redistribution of the Program by 206 | all those who receive copies directly or indirectly through you, then 207 | the only way you could satisfy both it and this License would be to 208 | refrain entirely from distribution of the Program. 209 | 210 | If any portion of this section is held invalid or unenforceable under 211 | any particular circumstance, the balance of the section is intended to 212 | apply and the section as a whole is intended to apply in other 213 | circumstances. 214 | 215 | It is not the purpose of this section to induce you to infringe any 216 | patents or other property right claims or to contest validity of any 217 | such claims; this section has the sole purpose of protecting the 218 | integrity of the free software distribution system, which is 219 | implemented by public license practices. Many people have made 220 | generous contributions to the wide range of software distributed 221 | through that system in reliance on consistent application of that 222 | system; it is up to the author/donor to decide if he or she is willing 223 | to distribute software through any other system and a licensee cannot 224 | impose that choice. 225 | 226 | This section is intended to make thoroughly clear what is believed to 227 | be a consequence of the rest of this License. 228 | 229 | 8. If the distribution and/or use of the Program is restricted in 230 | certain countries either by patents or by copyrighted interfaces, the 231 | original copyright holder who places the Program under this License 232 | may add an explicit geographical distribution limitation excluding 233 | those countries, so that distribution is permitted only in or among 234 | countries not thus excluded. In such case, this License incorporates 235 | the limitation as if written in the body of this License. 236 | 237 | 9. The Free Software Foundation may publish revised and/or new versions 238 | of the General Public License from time to time. Such new versions will 239 | be similar in spirit to the present version, but may differ in detail to 240 | address new problems or concerns. 241 | 242 | Each version is given a distinguishing version number. If the Program 243 | specifies a version number of this License which applies to it and "any 244 | later version", you have the option of following the terms and conditions 245 | either of that version or of any later version published by the Free 246 | Software Foundation. If the Program does not specify a version number of 247 | this License, you may choose any version ever published by the Free Software 248 | Foundation. 249 | 250 | 10. If you wish to incorporate parts of the Program into other free 251 | programs whose distribution conditions are different, write to the author 252 | to ask for permission. For software which is copyrighted by the Free 253 | Software Foundation, write to the Free Software Foundation; we sometimes 254 | make exceptions for this. Our decision will be guided by the two goals 255 | of preserving the free status of all derivatives of our free software and 256 | of promoting the sharing and reuse of software generally. 257 | 258 | NO WARRANTY 259 | 260 | 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY 261 | FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN 262 | OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES 263 | PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED 264 | OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 265 | MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS 266 | TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE 267 | PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, 268 | REPAIR OR CORRECTION. 269 | 270 | 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 271 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR 272 | REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, 273 | INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING 274 | OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED 275 | TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY 276 | YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER 277 | PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE 278 | POSSIBILITY OF SUCH DAMAGES. 279 | 280 | END OF TERMS AND CONDITIONS 281 | 282 | How to Apply These Terms to Your New Programs 283 | 284 | If you develop a new program, and you want it to be of the greatest 285 | possible use to the public, the best way to achieve this is to make it 286 | free software which everyone can redistribute and change under these terms. 287 | 288 | To do so, attach the following notices to the program. It is safest 289 | to attach them to the start of each source file to most effectively 290 | convey the exclusion of warranty; and each file should have at least 291 | the "copyright" line and a pointer to where the full notice is found. 292 | 293 | {description} 294 | Copyright (C) {year} {fullname} 295 | 296 | This program is free software; you can redistribute it and/or modify 297 | it under the terms of the GNU General Public License as published by 298 | the Free Software Foundation; either version 2 of the License, or 299 | (at your option) any later version. 300 | 301 | This program is distributed in the hope that it will be useful, 302 | but WITHOUT ANY WARRANTY; without even the implied warranty of 303 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 304 | GNU General Public License for more details. 305 | 306 | You should have received a copy of the GNU General Public License along 307 | with this program; if not, write to the Free Software Foundation, Inc., 308 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 309 | 310 | Also add information on how to contact you by electronic and paper mail. 311 | 312 | If the program is interactive, make it output a short notice like this 313 | when it starts in an interactive mode: 314 | 315 | Gnomovision version 69, Copyright (C) year name of author 316 | Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 317 | This is free software, and you are welcome to redistribute it 318 | under certain conditions; type `show c' for details. 319 | 320 | The hypothetical commands `show w' and `show c' should show the appropriate 321 | parts of the General Public License. Of course, the commands you use may 322 | be called something other than `show w' and `show c'; they could even be 323 | mouse-clicks or menu items--whatever suits your program. 324 | 325 | You should also get your employer (if you work as a programmer) or your 326 | school, if any, to sign a "copyright disclaimer" for the program, if 327 | necessary. Here is a sample; alter the names: 328 | 329 | Yoyodyne, Inc., hereby disclaims all copyright interest in the program 330 | `Gnomovision' (which makes passes at compilers) written by James Hacker. 331 | 332 | {signature of Ty Coon}, 1 April 1989 333 | Ty Coon, President of Vice 334 | 335 | This General Public License does not permit incorporating your program into 336 | proprietary programs. If your program is a subroutine library, you may 337 | consider it more useful to permit linking proprietary applications with the 338 | library. If this is what you want to do, use the GNU Lesser General 339 | Public License instead of this License. 340 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | [![ChatEx Logo](https://github.com/TheJeterLP/ChatEx/blob/master/logo.png?raw=true)](https://www.spigotmc.org/resources/chatex-continued.71041/) 2 | [![Create DevBuild](https://github.com/TheJeterLP/ChatEx/actions/workflows/autobuild.yml/badge.svg)](https://github.com/TheJeterLP/ChatEx/actions/workflows/autobuild.yml) 3 | [![JitPack](https://jitpack.io/v/TheJeterLP/ChatEx.svg)](https://jitpack.io/#TheJeterLP/ChatEx) 4 | ================================ 5 | Recode of the original ChatManager from PermissionsEx, which is no longer supported. 6 | This is the only official version. 7 | 8 | If you need to report a bug or want to suggest a new feature, please use GitHubs Issue trackl. 9 | 10 | If you want to use ChatEx as a Maven dependency, just click on the Jitpack image above 11 | or [Here](https://jitpack.io/#TheJeterLP/ChatEx) to read more about how to add it as a dependency. You can use the 12 | versions from github releases 13 | 14 | [![BStats](https://bstats.org/signatures/bukkit/ChatEx.svg)](https://bstats.org/plugin/bukkit/ChatEx/7744) 15 | -------------------------------------------------------------------------------- /ensure-java-16: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | JV=`java -version 2>&1 >/dev/null | head -1` 4 | echo $JV | sed -E 's/^.*version "([^".]*)\.[^"]*".*$/\1/' 5 | 6 | if [ "$JV" != 16 ]; then 7 | case "$1" in 8 | install) 9 | echo "Installing SDKMAN..." 10 | curl -s "https://get.sdkman.io" | bash 11 | source ~/.sdkman/bin/sdkman-init.sh 12 | sdk version 13 | sdk install java 16.0.2-open 14 | ;; 15 | use) 16 | echo "must source ~/.sdkman/bin/sdkman-init.sh" 17 | exit 1 18 | ;; 19 | esac 20 | fi -------------------------------------------------------------------------------- /jitpack.yml: -------------------------------------------------------------------------------- 1 | jdk: 2 | - openjdk16 3 | before_install: 4 | - echo "Before Install" 5 | - bash ensure-java-16 install 6 | install: 7 | - echo "Install" 8 | - if ! bash ensure-java-16 use; then source ~/.sdkman/bin/sdkman-init.sh; fi 9 | - java -version 10 | - mvn install -------------------------------------------------------------------------------- /licenseheader.txt: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of ChatEx 3 | * Copyright (C) 2020 ChatEx Team 4 | * 5 | * This program is free software; you can redistribute it and/or 6 | * modify it under the terms of the GNU General Public License 7 | * as published by the Free Software Foundation; either version 2 8 | * of the License, or (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program; if not, write to the Free Software 17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 18 | */ -------------------------------------------------------------------------------- /logo-square.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheJeterLP/ChatEx/81b439c2c24b37c005abee91b43ca246e4f70e40/logo-square.png -------------------------------------------------------------------------------- /logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TheJeterLP/ChatEx/81b439c2c24b37c005abee91b43ca246e4f70e40/logo.png -------------------------------------------------------------------------------- /pom.xml: -------------------------------------------------------------------------------- 1 | 3 | 4.0.0 4 | de.jeter 5 | ChatEx 6 | ChatEx 7 | 2024 8 | 9 | 3.2.2 10 | ChatManagement plugin for Bukkit 11 | https://www.spigotmc.org/resources/chatex-continued.71041/ 12 | 13 | 14 | scm:git:git@github.com:TheJeterLP/ChatEx.git 15 | scm:git:git@github.com:TheJeterLP/ChatEx.git 16 | scm:git:git@github.com:TheJeterLP/ChatEx.git 17 | 18 | 19 | 20 | clean install 21 | ${project.name} 22 | ${basedir}/src/main/java/ 23 | 24 | 25 | . 26 | true 27 | ${basedir}/src/main/resources/ 28 | 29 | **/* 30 | 31 | 32 | 33 | 34 | 35 | 36 | org.apache.maven.plugins 37 | maven-shade-plugin 38 | 3.6.0 39 | 40 | 41 | 42 | org.bstats 43 | de.jeter.chatex.bstats 44 | 45 | 46 | de.jeter.updatechecker 47 | de.jeter.chatex.updatechecker 48 | 49 | 50 | 51 | 52 | 53 | package 54 | 55 | shade 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | spigot-repo 66 | https://hub.spigotmc.org/nexus/content/repositories/snapshots/ 67 | 68 | 69 | jitpack.io 70 | https://jitpack.io 71 | 72 | 73 | placeholderapi 74 | https://repo.extendedclip.com/content/repositories/placeholderapi/ 75 | 76 | 77 | CodeMC 78 | https://repo.codemc.org/repository/maven-public/ 79 | 80 | 81 | essentials-repo 82 | https://repo.essentialsx.net/releases/ 83 | 84 | 85 | purpur 86 | https://repo.purpurmc.org/snapshots 87 | 88 | 89 | 90 | 91 | 92 | org.spigotmc 93 | spigot-api 94 | 1.20.1-R0.1-SNAPSHOT 95 | provided 96 | 97 | 98 | com.github.MilkBowl 99 | VaultAPI 100 | 1.7.1 101 | provided 102 | 103 | 104 | me.clip 105 | placeholderapi 106 | 2.11.6 107 | provided 108 | 109 | 110 | net.luckperms 111 | api 112 | 5.4 113 | provided 114 | 115 | 116 | net.ess3 117 | EssentialsX 118 | 2.18.2 119 | provided 120 | 121 | 122 | org.purpurmc.purpur 123 | purpur-api 124 | 1.20.1-R0.1-SNAPSHOT 125 | provided 126 | 127 | 128 | org.bstats 129 | bstats-bukkit 130 | 3.0.2 131 | compile 132 | 133 | 134 | com.github.TheJeterLP 135 | Spigot-Updatechecker 136 | 2.0.6 137 | compile 138 | 139 | 140 | 141 | 142 | 16 143 | 16 144 | 16 145 | UTF-8 146 | 147 | 148 | 149 | -------------------------------------------------------------------------------- /src/main/java/de/jeter/chatex/ChannelHandler.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of ChatEx 3 | * Copyright (C) 2022 ChatEx Team 4 | * 5 | * This program is free software; you can redistribute it and/or 6 | * modify it under the terms of the GNU General Public License 7 | * as published by the Free Software Foundation; either version 2 8 | * of the License, or (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program; if not, write to the Free Software 17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 18 | */ 19 | package de.jeter.chatex; 20 | 21 | import com.google.common.io.ByteArrayDataInput; 22 | import com.google.common.io.ByteArrayDataOutput; 23 | import com.google.common.io.ByteStreams; 24 | import de.jeter.chatex.utils.Config; 25 | import org.bukkit.entity.Player; 26 | import org.bukkit.plugin.messaging.PluginMessageListener; 27 | 28 | import java.io.*; 29 | import java.util.concurrent.TimeUnit; 30 | 31 | public class ChannelHandler implements PluginMessageListener { 32 | 33 | private static ChannelHandler INSTANCE; 34 | 35 | public static ChannelHandler getInstance() { 36 | return INSTANCE; 37 | } 38 | 39 | public static void load() { 40 | if (Config.BUNGEECORD.getBoolean()) { 41 | INSTANCE = new ChannelHandler(); 42 | ChatEx.getInstance().getServer().getMessenger().registerOutgoingPluginChannel(ChatEx.getInstance(), "BungeeCord"); 43 | ChatEx.getInstance().getServer().getMessenger().registerIncomingPluginChannel(ChatEx.getInstance(), "BungeeCord", INSTANCE); 44 | } 45 | } 46 | 47 | @Override 48 | public void onPluginMessageReceived(String channel, Player player, byte[] message) { 49 | if (!channel.equals("BungeeCord")) { 50 | return; 51 | } 52 | 53 | ByteArrayDataInput in = ByteStreams.newDataInput(message); 54 | String subChannel = in.readUTF(); 55 | if (subChannel.equals("ChatEx")) { 56 | //String serverName = in.readUTF(); 57 | 58 | short len = in.readShort(); 59 | byte[] msgbytes = new byte[len]; 60 | in.readFully(msgbytes); 61 | 62 | DataInputStream msgin = new DataInputStream(new ByteArrayInputStream(msgbytes)); 63 | String msg; 64 | long millis = 0; 65 | try { 66 | millis = msgin.readLong(); 67 | msg = msgin.readUTF(); 68 | } catch (IOException ex) { 69 | ex.printStackTrace(); 70 | msg = "null"; 71 | } 72 | 73 | if ((System.currentTimeMillis() - millis) < TimeUnit.SECONDS.toMillis(Config.CROSS_SERVER_TIMEOUT.getInt())) { 74 | ChatEx.getInstance().getServer().broadcastMessage(msg); 75 | } 76 | } 77 | } 78 | 79 | public void sendMessage(Player p, String message) { 80 | if (Config.BUNGEECORD.getBoolean()) { 81 | ByteArrayDataOutput out = ByteStreams.newDataOutput(); 82 | out.writeUTF("Forward"); // So BungeeCord knows to forward it 83 | out.writeUTF("ALL"); 84 | out.writeUTF("ChatEx"); // The channel name to check if this your data 85 | //out.writeUTF("GetServer"); 86 | 87 | ByteArrayOutputStream msgbytes = new ByteArrayOutputStream(); 88 | DataOutputStream msgout = new DataOutputStream(msgbytes); 89 | try { 90 | msgout.writeLong(System.currentTimeMillis()); 91 | msgout.writeUTF(message); 92 | } catch (IOException exception) { 93 | exception.printStackTrace(); 94 | } 95 | 96 | out.writeShort(msgbytes.toByteArray().length); 97 | out.write(msgbytes.toByteArray()); 98 | p.sendPluginMessage(ChatEx.getInstance(), "BungeeCord", out.toByteArray()); 99 | } 100 | } 101 | 102 | } 103 | -------------------------------------------------------------------------------- /src/main/java/de/jeter/chatex/ChatEx.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of ChatEx 3 | * Copyright (C) 2022 ChatEx Team 4 | * 5 | * This program is free software; you can redistribute it and/or 6 | * modify it under the terms of the GNU General Public License 7 | * as published by the Free Software Foundation; either version 2 8 | * of the License, or (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program; if not, write to the Free Software 17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 18 | */ 19 | package de.jeter.chatex; 20 | 21 | import de.jeter.chatex.plugins.PluginManager; 22 | import de.jeter.chatex.utils.*; 23 | import de.jeter.updatechecker.SpigotUpdateChecker; 24 | import de.jeter.updatechecker.UpdateChecker; 25 | import org.bstats.bukkit.Metrics; 26 | import org.bukkit.plugin.java.JavaPlugin; 27 | 28 | public class ChatEx extends JavaPlugin { 29 | 30 | private static ChatEx INSTANCE; 31 | private UpdateChecker updatechecker = null; 32 | 33 | public static ChatEx getInstance() { 34 | return INSTANCE; 35 | } 36 | 37 | @Override 38 | public void onEnable() { 39 | INSTANCE = this; 40 | 41 | Config.load(); 42 | Locales.load(); 43 | PluginManager.load(); 44 | ChatLogger.load(); 45 | RGBColors.load(); 46 | 47 | getServer().getPluginManager().registerEvents(new ChatListener(), this); 48 | getServer().getPluginManager().registerEvents(new PlayerListener(), this); 49 | getCommand("chatex").setExecutor(new CommandHandler()); 50 | 51 | if (Config.CHECK_UPDATE.getBoolean()) { 52 | updatechecker = new SpigotUpdateChecker(this, 71041); 53 | } 54 | 55 | ChannelHandler.load(); 56 | 57 | if (Config.B_STATS.getBoolean()) { 58 | Metrics metrics = new Metrics(this, 7744); 59 | CustomCharts.addPermissionsPluginChart(metrics); 60 | CustomCharts.addUpdateCheckerChart(metrics); 61 | getLogger().info("Thanks for using bstats, it was enabled!"); 62 | } 63 | 64 | getLogger().info("Is now enabled!"); 65 | } 66 | 67 | @Override 68 | public void onDisable() { 69 | AntiSpamManager.getInstance().clear(); 70 | ChatLogger.close(); 71 | getServer().getScheduler().cancelTasks(this); 72 | getLogger().info("Is now disabled!"); 73 | } 74 | 75 | public UpdateChecker getUpdateChecker() { 76 | return this.updatechecker; 77 | } 78 | } 79 | -------------------------------------------------------------------------------- /src/main/java/de/jeter/chatex/ChatListener.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of ChatEx 3 | * Copyright (C) 2022 ChatEx Team 4 | * 5 | * This program is free software; you can redistribute it and/or 6 | * modify it under the terms of the GNU General Public License 7 | * as published by the Free Software Foundation; either version 2 8 | * of the License, or (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program; if not, write to the Free Software 17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 18 | */ 19 | package de.jeter.chatex; 20 | 21 | import de.jeter.chatex.api.events.*; 22 | import de.jeter.chatex.plugins.PluginManager; 23 | import de.jeter.chatex.utils.*; 24 | import de.jeter.chatex.utils.adManager.AdManager; 25 | import de.jeter.chatex.utils.adManager.SimpleAdManager; 26 | import de.jeter.chatex.utils.adManager.SmartAdManager; 27 | import org.bukkit.Bukkit; 28 | import org.bukkit.entity.Player; 29 | import org.bukkit.event.EventHandler; 30 | import org.bukkit.event.EventPriority; 31 | import org.bukkit.event.Listener; 32 | import org.bukkit.event.player.AsyncPlayerChatEvent; 33 | 34 | import java.util.UnknownFormatConversionException; 35 | import java.util.regex.Matcher; 36 | import java.util.regex.Pattern; 37 | 38 | public class ChatListener implements Listener { 39 | 40 | private final AdManager adManager = Config.ADS_SMART_MANAGER.getBoolean() ? new SmartAdManager() : new SimpleAdManager(); 41 | 42 | @EventHandler(priority = EventPriority.LOWEST) 43 | public void onLowest(final AsyncPlayerChatEvent event) { 44 | if (Config.PRIORITY.getString().equalsIgnoreCase("LOWEST")) { 45 | executeChatEvent(event); 46 | } 47 | } 48 | 49 | @EventHandler(priority = EventPriority.LOW) 50 | public void onLow(final AsyncPlayerChatEvent event) { 51 | if (Config.PRIORITY.getString().equalsIgnoreCase("LOW")) { 52 | executeChatEvent(event); 53 | } 54 | } 55 | 56 | @EventHandler(priority = EventPriority.NORMAL) 57 | public void onNormal(final AsyncPlayerChatEvent event) { 58 | if (Config.PRIORITY.getString().equalsIgnoreCase("NORMAL")) { 59 | executeChatEvent(event); 60 | } 61 | } 62 | 63 | @EventHandler(priority = EventPriority.HIGH) 64 | public void onHigh(final AsyncPlayerChatEvent event) { 65 | if (Config.PRIORITY.getString().equalsIgnoreCase("HIGH")) { 66 | executeChatEvent(event); 67 | } 68 | } 69 | 70 | @EventHandler(priority = EventPriority.HIGHEST) 71 | public void onHighest(final AsyncPlayerChatEvent event) { 72 | if (Config.PRIORITY.getString().equalsIgnoreCase("HIGHEST")) { 73 | executeChatEvent(event); 74 | } 75 | } 76 | 77 | @EventHandler(priority = EventPriority.MONITOR) 78 | public void onMonitor(final AsyncPlayerChatEvent event) { 79 | if (Config.PRIORITY.getString().equalsIgnoreCase("MONITOR")) { 80 | executeChatEvent(event); 81 | } 82 | } 83 | 84 | private void executeChatEvent(AsyncPlayerChatEvent event) { 85 | LogHelper.debug("ChatEvent fired with priority: " + Config.PRIORITY.getString().toUpperCase() + ", ChatEx reacting to it..."); 86 | Player player = event.getPlayer(); 87 | 88 | if (!player.hasPermission("chatex.allowchat")) { 89 | String msg = Locales.COMMAND_RESULT_NO_PERM.getString(player).replaceAll("%perm", "chatex.allowchat"); 90 | player.sendMessage(msg); 91 | event.setCancelled(true); 92 | return; 93 | } 94 | 95 | String format = PluginManager.getInstance().getMessageFormat(event.getPlayer()); 96 | LogHelper.debug("Format: " + format); 97 | LogHelper.debug("Prefix: " + PluginManager.getInstance().getPrefix(event.getPlayer())); 98 | LogHelper.debug("Suffix: " + PluginManager.getInstance().getSuffix(event.getPlayer())); 99 | 100 | String chatMessage = event.getMessage(); 101 | 102 | if (!AntiSpamManager.getInstance().isAllowed(event.getPlayer())) { 103 | long remainingTime = AntiSpamManager.getInstance().getRemainingSeconds(event.getPlayer()); 104 | String message = Locales.ANTI_SPAM_DENIED.getString(event.getPlayer()).replaceAll("%time%", remainingTime + ""); 105 | MessageBlockedBySpamManagerEvent messageBlockedBySpamManagerEvent = new MessageBlockedBySpamManagerEvent(event.getPlayer(), chatMessage, message, remainingTime); 106 | Bukkit.getPluginManager().callEvent(messageBlockedBySpamManagerEvent); 107 | event.setCancelled(!messageBlockedBySpamManagerEvent.isCancelled()); 108 | if (!messageBlockedBySpamManagerEvent.isCancelled()) { 109 | event.getPlayer().sendMessage(messageBlockedBySpamManagerEvent.getPluginMessage()); 110 | return; 111 | } 112 | chatMessage = messageBlockedBySpamManagerEvent.getMessage(); 113 | } 114 | AntiSpamManager.getInstance().put(player); 115 | 116 | LogHelper.debug("Player did not activate the AntiSpam. Continuing..."); 117 | 118 | if (adManager.checkForAds(chatMessage, player)) { 119 | String message = Locales.MESSAGES_AD.getString(null).replaceAll("%perm", "chatex.bypassads"); 120 | MessageBlockedByAdManagerEvent messageBlockedByAdManagerEvent = new MessageBlockedByAdManagerEvent(player, chatMessage, message); 121 | Bukkit.getPluginManager().callEvent(messageBlockedByAdManagerEvent); 122 | chatMessage = messageBlockedByAdManagerEvent.getMessage(); 123 | event.setCancelled(!messageBlockedByAdManagerEvent.isCancelled()); 124 | if (!messageBlockedByAdManagerEvent.isCancelled()) { 125 | event.getPlayer().sendMessage(messageBlockedByAdManagerEvent.getPluginMessage()); 126 | return; 127 | } 128 | } 129 | 130 | LogHelper.debug("Player did not activate the AdBlocker. Continuing..."); 131 | 132 | for(String block : Config.BLOCKED_WORDS.getStringList()) { 133 | if(chatMessage.toLowerCase().contains(block.toLowerCase())) { 134 | LogHelper.debug("Player activated wordblocker! ChatMessage: " + chatMessage + " contains blockedWord: " + block); 135 | String message = Locales.MESSAGES_BLOCKED.getString(null); 136 | MessageContainsBlockedWordEvent messageContainsBlockedWordEvent = new MessageContainsBlockedWordEvent(player, chatMessage, message); 137 | Bukkit.getPluginManager().callEvent(messageContainsBlockedWordEvent); 138 | event.setCancelled(!messageContainsBlockedWordEvent.isCancelled()); 139 | chatMessage = messageContainsBlockedWordEvent.getMessage(); 140 | if (!messageContainsBlockedWordEvent.isCancelled()) { 141 | event.getPlayer().sendMessage(messageContainsBlockedWordEvent.getPluginMessage()); 142 | return; 143 | } 144 | } 145 | } 146 | 147 | LogHelper.debug("Player did not use a blocked word. Continuing..."); 148 | LogHelper.debug("ChatMessage: " + chatMessage); 149 | boolean global = false; 150 | 151 | if (Config.RANGEMODE.getBoolean() || Config.BUNGEECORD.getBoolean()) { 152 | LogHelper.debug("Message starts with prefix (" + Config.RANGEPREFIX.getString() + "): " + chatMessage.startsWith(Config.RANGEPREFIX.getString())); 153 | if ((Config.RANGEMODE.getBoolean() && chatMessage.startsWith(Config.RANGEPREFIX.getString())) || Config.BUNGEECORD.getBoolean()) { 154 | LogHelper.debug("Global mode enabled!"); 155 | if (player.hasPermission("chatex.chat.global")) { 156 | chatMessage = chatMessage.replaceFirst(Pattern.quote(Config.RANGEPREFIX.getString()), ""); 157 | format = PluginManager.getInstance().getGlobalMessageFormat(player); 158 | global = true; 159 | 160 | PlayerUsesGlobalChatEvent playerUsesGlobalChatEvent = new PlayerUsesGlobalChatEvent(player, chatMessage); 161 | Bukkit.getPluginManager().callEvent(playerUsesGlobalChatEvent); 162 | chatMessage = playerUsesGlobalChatEvent.getMessage(); 163 | if (playerUsesGlobalChatEvent.isCancelled()) { 164 | event.setCancelled(true); 165 | return; 166 | } 167 | } else { 168 | player.sendMessage(Locales.COMMAND_RESULT_NO_PERM.getString(player).replaceAll("%perm", "chatex.chat.global")); 169 | event.setCancelled(true); 170 | return; 171 | } 172 | } else { 173 | if (Config.RANGEMODE.getBoolean()) { 174 | LogHelper.debug("Range mode enabled!"); 175 | event.getRecipients().clear(); 176 | if (Utils.getLocalRecipients(player).size() == 1 && Config.SHOW_NO_RECEIVER_MSG.getBoolean()) { 177 | player.sendMessage(Locales.NO_LISTENING_PLAYERS.getString(player)); 178 | event.setCancelled(true); 179 | return; 180 | } else { 181 | event.getRecipients().addAll(Utils.getLocalRecipients(player)); 182 | 183 | PlayerUsesRangeModeEvent playerUsesRangeModeEvent = new PlayerUsesRangeModeEvent(player, chatMessage); 184 | Bukkit.getPluginManager().callEvent(playerUsesRangeModeEvent); 185 | chatMessage = playerUsesRangeModeEvent.getMessage(); 186 | if (playerUsesRangeModeEvent.isCancelled()) { 187 | event.setCancelled(true); 188 | return; 189 | } 190 | } 191 | } 192 | } 193 | } 194 | 195 | if (global && Config.BUNGEECORD.getBoolean()) { 196 | LogHelper.debug("Local mode & Bungeecord mode enabled! Spreading Cross server message..."); 197 | String msgToSend = Utils.replacePlayerPlaceholders(player, format.replaceAll("%message", Matcher.quoteReplacement(chatMessage))); 198 | ChannelHandler.getInstance().sendMessage(player, msgToSend); 199 | } 200 | 201 | LogHelper.debug("Replacing Placeholder in format..."); 202 | format = Utils.replacePlayerPlaceholders(player, format); 203 | format = Utils.escape(format); 204 | format = format.replace("%%message", "%2$s"); 205 | LogHelper.debug("Format after replacing: " + format); 206 | 207 | 208 | try { 209 | event.setFormat(format); 210 | } catch (UnknownFormatConversionException ex) { 211 | System.out.println(format); 212 | ChatEx.getInstance().getLogger().severe("Placeholder in format is not allowed!"); 213 | format = format.replaceAll("%\\\\?.*?%", ""); 214 | event.setFormat(format); 215 | } 216 | 217 | event.setMessage(Utils.translateColorCodes(chatMessage, player)); 218 | ChatLogger.writeToFile(player, chatMessage); 219 | LogHelper.debug("Everything done! Method end."); 220 | } 221 | 222 | } 223 | -------------------------------------------------------------------------------- /src/main/java/de/jeter/chatex/CommandHandler.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of ChatEx 3 | * Copyright (C) 2022 ChatEx Team 4 | * 5 | * This program is free software; you can redistribute it and/or 6 | * modify it under the terms of the GNU General Public License 7 | * as published by the Free Software Foundation; either version 2 8 | * of the License, or (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program; if not, write to the Free Software 17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 18 | */ 19 | package de.jeter.chatex; 20 | 21 | import de.jeter.chatex.utils.Config; 22 | import de.jeter.chatex.utils.Locales; 23 | import de.jeter.chatex.utils.Utils; 24 | import org.bukkit.Bukkit; 25 | import org.bukkit.command.*; 26 | import org.bukkit.entity.Player; 27 | 28 | import java.util.ArrayList; 29 | import java.util.List; 30 | 31 | public class CommandHandler implements CommandExecutor, TabCompleter { 32 | 33 | @Override 34 | public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { 35 | if (args.length == 0) { 36 | sender.sendMessage("§aChatEx plugin by " + ChatEx.getInstance().getDescription().getAuthors() + " (" + ChatEx.getInstance().getDescription().getVersion() + ")"); 37 | return true; 38 | } else if (args.length > 1) { 39 | sender.sendMessage(Locales.COMMAND_RESULT_WRONG_USAGE.getString(null).replaceAll("%cmd", command.getName())); 40 | return true; 41 | } else { 42 | if (args[0].equalsIgnoreCase("reload")) { 43 | if (sender.hasPermission("chatex.reload")) { 44 | Config.reload(true); 45 | sender.sendMessage(Locales.MESSAGES_RELOAD.getString(null)); 46 | 47 | if (Config.CHANGE_TABLIST_NAME.getBoolean()) { 48 | for (Player p : Bukkit.getOnlinePlayers()) { 49 | String name = Config.TABLIST_FORMAT.getString(); 50 | name = Utils.replacePlayerPlaceholders(p, name); 51 | p.setPlayerListName(name); 52 | } 53 | } 54 | } else { 55 | sender.sendMessage(Locales.COMMAND_RESULT_NO_PERM.getString(null).replaceAll("%perm", "chatex.reload")); 56 | } 57 | return true; 58 | } else if (args[0].equalsIgnoreCase("clear")) { 59 | if (sender.hasPermission("chatex.clear")) { 60 | for (int i = 0; i < 50; i++) { 61 | Bukkit.broadcastMessage("\n"); 62 | } 63 | 64 | Player clearer = null; 65 | 66 | String who = Locales.COMMAND_CLEAR_UNKNOWN.getString(null); 67 | if ((sender instanceof ConsoleCommandSender) || (sender instanceof BlockCommandSender)) { 68 | who = Locales.COMMAND_CLEAR_CONSOLE.getString(null); 69 | } else if (sender instanceof Player) { 70 | who = sender.getName(); 71 | clearer = (Player) sender; 72 | } 73 | Bukkit.broadcastMessage(Locales.MESSAGES_CLEAR.getString(clearer) + who); 74 | } else { 75 | sender.sendMessage(Locales.COMMAND_RESULT_NO_PERM.getString(null).replaceAll("%perm", "chatex.clear")); 76 | } 77 | return true; 78 | } else if (args[0].equalsIgnoreCase("help") || args[0].equalsIgnoreCase("?")) { 79 | sender.sendMessage("§a/" + command.getName() + " reload - " + Locales.COMMAND_RELOAD_DESCRIPTION.getString(null)); 80 | sender.sendMessage("§a/" + command.getName() + " clear - " + Locales.COMMAND_CLEAR_DESCRIPTION.getString(null)); 81 | return true; 82 | } else { 83 | sender.sendMessage(Locales.COMMAND_RESULT_WRONG_USAGE.getString(null).replaceAll("%cmd", "/chatex")); 84 | return true; 85 | } 86 | } 87 | 88 | } 89 | 90 | @Override 91 | public List onTabComplete(CommandSender commandSender, Command command, String s, String[] strings) { 92 | List possibleTabs = new ArrayList<>(); 93 | if (commandSender.hasPermission("chatex.clear")) { 94 | possibleTabs.add("clear"); 95 | } 96 | if (commandSender.hasPermission("chatex.reload")) { 97 | possibleTabs.add("reload"); 98 | } 99 | return possibleTabs; 100 | } 101 | } 102 | -------------------------------------------------------------------------------- /src/main/java/de/jeter/chatex/EssentialsAFKListener.java: -------------------------------------------------------------------------------- 1 | package de.jeter.chatex; 2 | 3 | import de.jeter.chatex.utils.Config; 4 | import de.jeter.chatex.utils.Utils; 5 | import net.ess3.api.events.AfkStatusChangeEvent; 6 | import org.bukkit.entity.Player; 7 | import org.bukkit.event.EventHandler; 8 | import org.bukkit.event.Listener; 9 | 10 | public class EssentialsAFKListener implements Listener { 11 | 12 | @EventHandler(ignoreCancelled = true) 13 | public void onAFKChangeEvent(AfkStatusChangeEvent event) { 14 | Player player = event.getAffected().getBase(); 15 | if (event.getValue()) { 16 | String format = Config.TABLIST_FORMAT.getString().replace("%afk", Config.AFK_FORMAT.getString()); 17 | player.setPlayerListName(Utils.replacePlayerPlaceholders(player, format)); 18 | return; 19 | } 20 | player.setPlayerListName(Utils.replacePlayerPlaceholders(player, Config.TABLIST_FORMAT.getString())); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/main/java/de/jeter/chatex/PlayerListener.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of ChatEx 3 | * Copyright (C) 2022 ChatEx Team 4 | * 5 | * This program is free software; you can redistribute it and/or 6 | * modify it under the terms of the GNU General Public License 7 | * as published by the Free Software Foundation; either version 2 8 | * of the License, or (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program; if not, write to the Free Software 17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 18 | */ 19 | package de.jeter.chatex; 20 | 21 | import de.jeter.chatex.utils.Config; 22 | import de.jeter.chatex.utils.Locales; 23 | import de.jeter.chatex.utils.Utils; 24 | import de.jeter.updatechecker.Result; 25 | import de.jeter.updatechecker.UpdateChecker; 26 | import net.md_5.bungee.api.chat.ClickEvent; 27 | import net.md_5.bungee.api.chat.HoverEvent; 28 | import net.md_5.bungee.api.chat.TextComponent; 29 | import net.md_5.bungee.api.chat.hover.content.Text; 30 | import org.bukkit.event.EventHandler; 31 | import org.bukkit.event.EventPriority; 32 | import org.bukkit.event.Listener; 33 | import org.bukkit.event.player.PlayerJoinEvent; 34 | import org.bukkit.event.player.PlayerKickEvent; 35 | import org.bukkit.event.player.PlayerQuitEvent; 36 | 37 | public class PlayerListener implements Listener { 38 | 39 | @EventHandler(priority = EventPriority.LOWEST) 40 | public void onJoin(PlayerJoinEvent e) { 41 | if (Config.CHANGE_JOIN_AND_QUIT.getBoolean()) { 42 | String msg; 43 | if(e.getPlayer().hasPlayedBefore()) { 44 | msg = Locales.PLAYER_JOIN.getString(e.getPlayer()); 45 | } else { 46 | msg = Locales.PLAYER_JOIN_FIRST_TIME.getString(e.getPlayer()); 47 | } 48 | 49 | e.setJoinMessage(Utils.replacePlayerPlaceholders(e.getPlayer(), msg)); 50 | } 51 | 52 | if (Config.CHANGE_TABLIST_NAME.getBoolean()) { 53 | String name = Config.TABLIST_FORMAT.getString(); 54 | name = Utils.replacePlayerPlaceholders(e.getPlayer(), name); 55 | e.getPlayer().setPlayerListName(name); 56 | } 57 | 58 | UpdateChecker checker = ChatEx.getInstance().getUpdateChecker(); 59 | 60 | if (Config.CHECK_UPDATE.getBoolean() && e.getPlayer().hasPermission("chatex.notifyupdate") && checker != null) { 61 | if (checker.getResult() == Result.UPDATE_FOUND) { 62 | try { 63 | TextComponent msg = new TextComponent(Locales.UPDATE_FOUND.getString(null).replaceAll("%oldversion", ChatEx.getInstance().getDescription().getVersion()).replaceAll("%newversion", ChatEx.getInstance().getUpdateChecker().getLatestRemoteVersion())); 64 | msg.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new Text("§aClick to download"))); 65 | msg.setClickEvent(new ClickEvent(ClickEvent.Action.OPEN_URL, checker.getDownloadLink())); 66 | e.getPlayer().spigot().sendMessage(msg); 67 | } catch (NoClassDefFoundError ex) { 68 | e.getPlayer().sendMessage(Locales.UPDATE_FOUND.getString(null).replaceAll("%oldversion", ChatEx.getInstance().getDescription().getVersion()).replaceAll("%newversion", ChatEx.getInstance().getUpdateChecker().getLatestRemoteVersion())); 69 | } catch (Exception ex) { 70 | e.getPlayer().sendMessage(Locales.UPDATE_FOUND.getString(null).replaceAll("%oldversion", ChatEx.getInstance().getDescription().getVersion()).replaceAll("%newversion", ChatEx.getInstance().getUpdateChecker().getLatestRemoteVersion())); 71 | } 72 | } 73 | } 74 | } 75 | 76 | @EventHandler(priority = EventPriority.LOWEST) 77 | public void onQuit(final PlayerQuitEvent e) { 78 | if (!Config.CHANGE_JOIN_AND_QUIT.getBoolean()) { 79 | return; 80 | } 81 | String msg = Locales.PLAYER_QUIT.getString(e.getPlayer()); 82 | e.setQuitMessage(Utils.replacePlayerPlaceholders(e.getPlayer(), msg)); 83 | } 84 | 85 | @EventHandler(priority = EventPriority.LOWEST) 86 | public void onKick(final PlayerKickEvent e) { 87 | if (!Config.CHANGE_JOIN_AND_QUIT.getBoolean()) { 88 | return; 89 | } 90 | String msg = Locales.PLAYER_KICK.getString(e.getPlayer()); 91 | e.setLeaveMessage(Utils.replacePlayerPlaceholders(e.getPlayer(), msg)); 92 | } 93 | 94 | } 95 | -------------------------------------------------------------------------------- /src/main/java/de/jeter/chatex/PurpurAFKListener.java: -------------------------------------------------------------------------------- 1 | package de.jeter.chatex; 2 | 3 | import de.jeter.chatex.utils.Config; 4 | import de.jeter.chatex.utils.Utils; 5 | import org.bukkit.entity.Player; 6 | import org.bukkit.event.EventHandler; 7 | import org.bukkit.event.Listener; 8 | import org.purpurmc.purpur.event.PlayerAFKEvent; 9 | 10 | public class PurpurAFKListener implements Listener { 11 | 12 | @EventHandler(ignoreCancelled = true) 13 | public void onAFKChangeEvent(PlayerAFKEvent event) { 14 | Player player = event.getPlayer(); 15 | if (event.isGoingAfk()) { 16 | String format = Config.TABLIST_FORMAT.getString().replace("%afk", Config.AFK_FORMAT.getString()); 17 | player.setPlayerListName(Utils.replacePlayerPlaceholders(player, format)); 18 | return; 19 | } 20 | player.setPlayerListName(Utils.replacePlayerPlaceholders(player, Config.TABLIST_FORMAT.getString())); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/main/java/de/jeter/chatex/api/ChatExAPI.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of ChatEx 3 | * Copyright (C) 2022 ChatEx Team 4 | * 5 | * This program is free software; you can redistribute it and/or 6 | * modify it under the terms of the GNU General Public License 7 | * as published by the Free Software Foundation; either version 2 8 | * of the License, or (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program; if not, write to the Free Software 17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 18 | */ 19 | package de.jeter.chatex.api; 20 | 21 | import de.jeter.chatex.plugins.PluginManager; 22 | import de.jeter.chatex.utils.AntiSpamManager; 23 | import org.bukkit.entity.Player; 24 | 25 | public class ChatExAPI { 26 | 27 | public String getPermissionHandlerName() { 28 | return PluginManager.getInstance().getName(); 29 | } 30 | 31 | public AntiSpamManager getAntiSpamManager() { 32 | return AntiSpamManager.getInstance(); 33 | } 34 | 35 | public String getPrefix(Player p) { 36 | return PluginManager.getInstance().getPrefix(p); 37 | } 38 | 39 | public String getSuffix(Player p) { 40 | return PluginManager.getInstance().getSuffix(p); 41 | } 42 | 43 | public String[] getGroupNames(Player p) { 44 | return PluginManager.getInstance().getGroupNames(p); 45 | } 46 | 47 | public String getMessageFormat(Player p) { 48 | return PluginManager.getInstance().getMessageFormat(p); 49 | } 50 | 51 | public String getGlobalMessageFormat(Player p) { 52 | return PluginManager.getInstance().getGlobalMessageFormat(p); 53 | } 54 | } -------------------------------------------------------------------------------- /src/main/java/de/jeter/chatex/api/events/MessageBlockedByAdManagerEvent.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of ChatEx 3 | * Copyright (C) 2022 ChatEx Team 4 | * 5 | * This program is free software; you can redistribute it and/or 6 | * modify it under the terms of the GNU General Public License 7 | * as published by the Free Software Foundation; either version 2 8 | * of the License, or (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program; if not, write to the Free Software 17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 18 | */ 19 | package de.jeter.chatex.api.events; 20 | 21 | import org.bukkit.entity.Player; 22 | import org.bukkit.event.Cancellable; 23 | import org.bukkit.event.Event; 24 | import org.bukkit.event.HandlerList; 25 | 26 | public class MessageBlockedByAdManagerEvent extends Event implements Cancellable { 27 | 28 | private static final HandlerList handlers = new HandlerList(); 29 | private final Player player; 30 | private boolean canceled = false; 31 | private String message; 32 | private String pluginMessage; 33 | 34 | /** 35 | * @param player the player which fired the event 36 | * @param message the message of the player 37 | * @param pluginMessage the message which the plugin sends to the player. 38 | */ 39 | public MessageBlockedByAdManagerEvent(Player player, String message, String pluginMessage) { 40 | super(true); 41 | this.player = player; 42 | this.message = message; 43 | this.pluginMessage = pluginMessage; 44 | } 45 | 46 | public static HandlerList getHandlerList() { 47 | return handlers; 48 | } 49 | 50 | /** 51 | * @return the player which fired this event 52 | */ 53 | public Player getPlayer() { 54 | return player; 55 | } 56 | 57 | /** 58 | * @return the message which the player would have written. 59 | */ 60 | public String getMessage() { 61 | return message; 62 | } 63 | 64 | /** 65 | * @param message set the message which the player writes. 66 | */ 67 | public void setMessage(String message) { 68 | this.message = message; 69 | } 70 | 71 | /** 72 | * @return Return the message which the player will receive. 73 | */ 74 | public String getPluginMessage() { 75 | return pluginMessage; 76 | } 77 | 78 | /** 79 | * @param pluginMessage the message the player will receive 80 | */ 81 | public void setPluginMessage(String pluginMessage) { 82 | this.pluginMessage = pluginMessage; 83 | } 84 | 85 | @Override 86 | public boolean isCancelled() { 87 | return canceled; 88 | } 89 | 90 | @Override 91 | public void setCancelled(boolean b) { 92 | canceled = b; 93 | } 94 | 95 | @Override 96 | public HandlerList getHandlers() { 97 | return handlers; 98 | } 99 | } 100 | -------------------------------------------------------------------------------- /src/main/java/de/jeter/chatex/api/events/MessageBlockedBySpamManagerEvent.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of ChatEx 3 | * Copyright (C) 2022 ChatEx Team 4 | * 5 | * This program is free software; you can redistribute it and/or 6 | * modify it under the terms of the GNU General Public License 7 | * as published by the Free Software Foundation; either version 2 8 | * of the License, or (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program; if not, write to the Free Software 17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 18 | */ 19 | package de.jeter.chatex.api.events; 20 | 21 | import org.bukkit.entity.Player; 22 | import org.bukkit.event.Cancellable; 23 | import org.bukkit.event.Event; 24 | import org.bukkit.event.HandlerList; 25 | 26 | public class MessageBlockedBySpamManagerEvent extends Event implements Cancellable { 27 | 28 | private static final HandlerList handlers = new HandlerList(); 29 | private final Player player; 30 | private final long remainingTime; 31 | private String message; 32 | private String pluginMessage; 33 | private boolean canceled = false; 34 | 35 | /** 36 | * @param player the player which fired the event 37 | * @param message the message of the player 38 | * @param pluginMessage the message which the plugin sends to the player. 39 | * @param remaining the remaining time in seconds. 40 | */ 41 | public MessageBlockedBySpamManagerEvent(Player player, String message, String pluginMessage, long remaining) { 42 | super(true); 43 | this.player = player; 44 | this.message = message; 45 | this.pluginMessage = pluginMessage; 46 | this.remainingTime = remaining; 47 | } 48 | 49 | public static HandlerList getHandlerList() { 50 | return handlers; 51 | } 52 | 53 | /** 54 | * @return the player which fired this event 55 | */ 56 | public Player getPlayer() { 57 | return player; 58 | } 59 | 60 | /** 61 | * @return the message which the player would have written. 62 | */ 63 | public String getMessage() { 64 | return message; 65 | } 66 | 67 | /** 68 | * @param message set the message which the player writes. 69 | */ 70 | public void setMessage(String message) { 71 | this.message = message; 72 | } 73 | 74 | /** 75 | * @return Return the message which the player will receive. 76 | */ 77 | public String getPluginMessage() { 78 | return pluginMessage; 79 | } 80 | 81 | /** 82 | * @param pluginMessage the message the player will receive 83 | */ 84 | public void setPluginMessage(String pluginMessage) { 85 | this.pluginMessage = pluginMessage; 86 | } 87 | 88 | /** 89 | * @return the remaining time a player is muted 90 | */ 91 | public long getRemainingTime() { 92 | return remainingTime; 93 | } 94 | 95 | @Override 96 | public boolean isCancelled() { 97 | return canceled; 98 | } 99 | 100 | @Override 101 | public void setCancelled(boolean b) { 102 | canceled = b; 103 | } 104 | 105 | @Override 106 | public HandlerList getHandlers() { 107 | return handlers; 108 | } 109 | 110 | } 111 | -------------------------------------------------------------------------------- /src/main/java/de/jeter/chatex/api/events/MessageContainsBlockedWordEvent.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of ChatEx 3 | * Copyright (C) 2022 ChatEx Team 4 | * 5 | * This program is free software; you can redistribute it and/or 6 | * modify it under the terms of the GNU General Public License 7 | * as published by the Free Software Foundation; either version 2 8 | * of the License, or (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program; if not, write to the Free Software 17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 18 | */ 19 | package de.jeter.chatex.api.events; 20 | 21 | import org.bukkit.entity.Player; 22 | import org.bukkit.event.Cancellable; 23 | import org.bukkit.event.Event; 24 | import org.bukkit.event.HandlerList; 25 | 26 | public class MessageContainsBlockedWordEvent extends Event implements Cancellable { 27 | 28 | private static final HandlerList handlers = new HandlerList(); 29 | private final Player player; 30 | private String message; 31 | private String pluginMessage; 32 | private boolean canceled = false; 33 | 34 | /** 35 | * @param player the player which fired the event 36 | * @param message the message of the player 37 | * @param pluginMessage the message which the plugin sends to the player. 38 | */ 39 | public MessageContainsBlockedWordEvent(Player player, String message, String pluginMessage) { 40 | super(true); 41 | this.player = player; 42 | this.message = message; 43 | this.pluginMessage = pluginMessage; 44 | } 45 | 46 | public static HandlerList getHandlerList() { 47 | return handlers; 48 | } 49 | 50 | /** 51 | * @return the player which fired this event 52 | */ 53 | public Player getPlayer() { 54 | return player; 55 | } 56 | 57 | /** 58 | * @return the message which the player would have written. 59 | */ 60 | public String getMessage() { 61 | return message; 62 | } 63 | 64 | /** 65 | * @param message set the message which the player writes. 66 | */ 67 | public void setMessage(String message) { 68 | this.message = message; 69 | } 70 | 71 | /** 72 | * @return Return the message which the player will receive. 73 | */ 74 | public String getPluginMessage() { 75 | return pluginMessage; 76 | } 77 | 78 | /** 79 | * @param pluginMessage the message the player will receive 80 | */ 81 | public void setPluginMessage(String pluginMessage) { 82 | this.pluginMessage = pluginMessage; 83 | } 84 | 85 | @Override 86 | public boolean isCancelled() { 87 | return this.canceled; 88 | } 89 | 90 | @Override 91 | public void setCancelled(boolean b) { 92 | this.canceled = b; 93 | } 94 | 95 | @Override 96 | public HandlerList getHandlers() { 97 | return handlers; 98 | } 99 | 100 | } 101 | -------------------------------------------------------------------------------- /src/main/java/de/jeter/chatex/api/events/PlayerUsesGlobalChatEvent.java: -------------------------------------------------------------------------------- 1 | package de.jeter.chatex.api.events; 2 | 3 | import org.bukkit.entity.Player; 4 | import org.bukkit.event.Cancellable; 5 | import org.bukkit.event.Event; 6 | import org.bukkit.event.HandlerList; 7 | 8 | public class PlayerUsesGlobalChatEvent extends Event implements Cancellable { 9 | 10 | private static final HandlerList handlers = new HandlerList(); 11 | private final Player player; 12 | private String message; 13 | private boolean canceled = false; 14 | 15 | public PlayerUsesGlobalChatEvent(Player player, String message) { 16 | super(true); 17 | this.player = player; 18 | this.message = message; 19 | } 20 | 21 | public static HandlerList getHandlerList() { 22 | return handlers; 23 | } 24 | 25 | /** 26 | * @return the player which fired this event 27 | */ 28 | public Player getPlayer() { 29 | return player; 30 | } 31 | 32 | /** 33 | * @return the message which the player would have written. 34 | */ 35 | public String getMessage() { 36 | return message; 37 | } 38 | 39 | /** 40 | * @param message set the message which the player writes. 41 | */ 42 | public void setMessage(String message) { 43 | this.message = message; 44 | } 45 | 46 | @Override 47 | public HandlerList getHandlers() { 48 | return handlers; 49 | } 50 | 51 | @Override 52 | public boolean isCancelled() { 53 | return canceled; 54 | } 55 | 56 | @Override 57 | public void setCancelled(boolean b) { 58 | canceled = b; 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /src/main/java/de/jeter/chatex/api/events/PlayerUsesRangeModeEvent.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of ChatEx 3 | * Copyright (C) 2022 ChatEx Team 4 | * 5 | * This program is free software; you can redistribute it and/or 6 | * modify it under the terms of the GNU General Public License 7 | * as published by the Free Software Foundation; either version 2 8 | * of the License, or (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program; if not, write to the Free Software 17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 18 | */ 19 | package de.jeter.chatex.api.events; 20 | 21 | import org.bukkit.entity.Player; 22 | import org.bukkit.event.Cancellable; 23 | import org.bukkit.event.Event; 24 | import org.bukkit.event.HandlerList; 25 | 26 | public class PlayerUsesRangeModeEvent extends Event implements Cancellable { 27 | 28 | private static final HandlerList handlers = new HandlerList(); 29 | private final Player player; 30 | private String message; 31 | private boolean canceled = false; 32 | 33 | public PlayerUsesRangeModeEvent(Player player, String message) { 34 | super(true); 35 | this.player = player; 36 | this.message = message; 37 | } 38 | 39 | public static HandlerList getHandlerList() { 40 | return handlers; 41 | } 42 | 43 | /** 44 | * @return the player which fired this event 45 | */ 46 | public Player getPlayer() { 47 | return player; 48 | } 49 | 50 | /** 51 | * @return the message which the player would have written. 52 | */ 53 | public String getMessage() { 54 | return message; 55 | } 56 | 57 | /** 58 | * @param message set the message which the player writes. 59 | */ 60 | public void setMessage(String message) { 61 | this.message = message; 62 | } 63 | 64 | @Override 65 | public HandlerList getHandlers() { 66 | return handlers; 67 | } 68 | 69 | @Override 70 | public boolean isCancelled() { 71 | return canceled; 72 | } 73 | 74 | @Override 75 | public void setCancelled(boolean b) { 76 | canceled = b; 77 | } 78 | } 79 | -------------------------------------------------------------------------------- /src/main/java/de/jeter/chatex/plugins/LuckPerms.java: -------------------------------------------------------------------------------- 1 | package de.jeter.chatex.plugins; 2 | 3 | import de.jeter.chatex.utils.Config; 4 | import de.jeter.chatex.utils.LogHelper; 5 | import net.luckperms.api.LuckPermsProvider; 6 | import net.luckperms.api.model.group.Group; 7 | import net.luckperms.api.model.user.User; 8 | import net.luckperms.api.platform.PlayerAdapter; 9 | import org.bukkit.entity.Player; 10 | 11 | import java.util.ArrayList; 12 | import java.util.Collection; 13 | import java.util.List; 14 | 15 | public class LuckPerms implements PermissionsPlugin { 16 | 17 | private net.luckperms.api.LuckPerms getAPI() { 18 | return LuckPermsProvider.get(); 19 | } 20 | 21 | private Collection getGroups(Player p) { 22 | PlayerAdapter playerAdapter = getAPI().getPlayerAdapter(Player.class); 23 | User user = playerAdapter.getUser(p); 24 | Collection groups = user.getInheritedGroups(playerAdapter.getQueryOptions(p)); 25 | return groups; 26 | } 27 | 28 | @Override 29 | public String getName() { 30 | return "LuckPerms"; 31 | } 32 | 33 | @Override 34 | public String getPrefix(Player p) { 35 | if (Config.MULTIPREFIXES.getBoolean()) { 36 | LogHelper.debug("Getting multiprefixes from " + p.getName()); 37 | String retprefix = ""; 38 | 39 | for (String prefix : getAPI().getPlayerAdapter(Player.class).getMetaData(p).getPrefixes().values()) { 40 | LogHelper.debug(prefix); 41 | if (prefix.length() == 2 && prefix.startsWith("&")) { 42 | retprefix += prefix; 43 | } else { 44 | retprefix += (prefix + " "); 45 | } 46 | } 47 | 48 | return retprefix; 49 | } else { 50 | String prefix = getAPI().getPlayerAdapter(Player.class).getMetaData(p).getPrefix(); 51 | return prefix != null ? prefix : ""; 52 | } 53 | } 54 | 55 | @Override 56 | public String getSuffix(Player p) { 57 | if (Config.MULTISUFFIXES.getBoolean()) { 58 | LogHelper.debug("Getting multisuffixes from " + p.getName()); 59 | String retsuffix = ""; 60 | 61 | for (String suffix : getAPI().getPlayerAdapter(Player.class).getMetaData(p).getSuffixes().values()) { 62 | LogHelper.debug(suffix); 63 | if (suffix.length() == 2 && suffix.startsWith("&")) { 64 | retsuffix += suffix; 65 | } else { 66 | retsuffix += (suffix + " "); 67 | } 68 | } 69 | 70 | return retsuffix; 71 | } else { 72 | String suffix = getAPI().getPlayerAdapter(Player.class).getMetaData(p).getSuffix(); 73 | return suffix != null ? suffix : ""; 74 | } 75 | 76 | } 77 | 78 | @Override 79 | public String[] getGroupNames(Player p) { 80 | Collection groups = getGroups(p); 81 | List list = new ArrayList<>(); 82 | for (Group group : groups) { 83 | String name = group.getDisplayName() == null ? group.getName() : group.getDisplayName(); 84 | list.add(name); 85 | } 86 | return list.toArray(String[]::new); 87 | } 88 | 89 | @Override 90 | public String getMessageFormat(Player p) { 91 | return Config.FORMAT.getString(); 92 | } 93 | 94 | @Override 95 | public String getGlobalMessageFormat(Player p) { 96 | return Config.GLOBALFORMAT.getString(); 97 | } 98 | } 99 | -------------------------------------------------------------------------------- /src/main/java/de/jeter/chatex/plugins/Nothing.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of ChatEx 3 | * Copyright (C) 2022 ChatEx Team 4 | * 5 | * This program is free software; you can redistribute it and/or 6 | * modify it under the terms of the GNU General Public License 7 | * as published by the Free Software Foundation; either version 2 8 | * of the License, or (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program; if not, write to the Free Software 17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 18 | */ 19 | package de.jeter.chatex.plugins; 20 | 21 | import de.jeter.chatex.utils.Config; 22 | import org.bukkit.entity.Player; 23 | 24 | public class Nothing implements PermissionsPlugin { 25 | 26 | @Override 27 | public String getPrefix(Player p) { 28 | return ""; 29 | } 30 | 31 | @Override 32 | public String getSuffix(Player p) { 33 | return ""; 34 | } 35 | 36 | @Override 37 | public String[] getGroupNames(Player p) { 38 | String[] data = {""}; 39 | return data; 40 | } 41 | 42 | @Override 43 | public String getName() { 44 | return "Nothing was found!"; 45 | } 46 | 47 | @Override 48 | public String getMessageFormat(Player p) { 49 | return Config.FORMAT.getString(); 50 | } 51 | 52 | @Override 53 | public String getGlobalMessageFormat(Player p) { 54 | return Config.GLOBALFORMAT.getString(); 55 | } 56 | 57 | } 58 | -------------------------------------------------------------------------------- /src/main/java/de/jeter/chatex/plugins/PermissionsPlugin.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of ChatEx 3 | * Copyright (C) 2022 ChatEx Team 4 | * 5 | * This program is free software; you can redistribute it and/or 6 | * modify it under the terms of the GNU General Public License 7 | * as published by the Free Software Foundation; either version 2 8 | * of the License, or (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program; if not, write to the Free Software 17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 18 | */ 19 | package de.jeter.chatex.plugins; 20 | 21 | import org.bukkit.entity.Player; 22 | 23 | public interface PermissionsPlugin { 24 | 25 | String getName(); 26 | 27 | String getPrefix(Player p); 28 | 29 | String getSuffix(Player p); 30 | 31 | String[] getGroupNames(Player p); 32 | 33 | String getMessageFormat(Player p); 34 | 35 | String getGlobalMessageFormat(Player p); 36 | } 37 | -------------------------------------------------------------------------------- /src/main/java/de/jeter/chatex/plugins/PluginManager.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of ChatEx 3 | * Copyright (C) 2022 ChatEx Team 4 | * This program is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU General Public License 6 | * as published by the Free Software Foundation; either version 2 7 | * of the License, or (at your option) any later version. 8 | * This program is distributed in the hope that it will be useful, 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | * GNU General Public License for more details. 12 | * You should have received a copy of the GNU General Public License 13 | * along with this program; if not, write to the Free Software 14 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 15 | */ 16 | package de.jeter.chatex.plugins; 17 | 18 | import de.jeter.chatex.ChatEx; 19 | import de.jeter.chatex.EssentialsAFKListener; 20 | import de.jeter.chatex.PurpurAFKListener; 21 | import de.jeter.chatex.utils.Config; 22 | import de.jeter.chatex.utils.HookManager; 23 | import de.jeter.chatex.utils.Utils; 24 | import org.bukkit.entity.Player; 25 | 26 | public class PluginManager implements PermissionsPlugin { 27 | 28 | private static PermissionsPlugin handler; 29 | private static PluginManager INSTANCE; 30 | 31 | public static PermissionsPlugin getInstance() { 32 | return INSTANCE; 33 | } 34 | 35 | public static void load() { 36 | INSTANCE = new PluginManager(); 37 | if (HookManager.checkLuckperms()) { 38 | handler = new LuckPerms(); 39 | } else if (HookManager.checkVault() && Vault.setupChat()) { 40 | handler = new Vault(); 41 | } else { 42 | handler = new Nothing(); 43 | } 44 | ChatEx.getInstance().getLogger().info("Successfully hooked into: " + handler.getName()); 45 | 46 | if (HookManager.checkPlaceholderAPI()) { 47 | ChatEx.getInstance().getLogger().info("Hooked into PlaceholderAPI"); 48 | } 49 | 50 | if (Config.AFK_PLACEHOLDER.getBoolean()) { 51 | if (HookManager.checkEssentials()) { 52 | ChatEx.getInstance().getLogger().info("Hooked into Essentials"); 53 | ChatEx.getInstance().getServer().getPluginManager().registerEvents(new EssentialsAFKListener(), ChatEx.getInstance()); 54 | } else if (HookManager.checkPurpur()) { 55 | ChatEx.getInstance().getLogger().info("Hooked into Purpur"); 56 | ChatEx.getInstance().getServer().getPluginManager().registerEvents(new PurpurAFKListener(), ChatEx.getInstance()); 57 | } else { 58 | ChatEx.getInstance().getLogger().warning("Error while enabling AFK placeholder, neither essentials nor purpur were found!"); 59 | } 60 | } 61 | } 62 | 63 | @Override 64 | public String getName() { 65 | return handler.getName(); 66 | } 67 | 68 | @Override 69 | public String getPrefix(Player p) { 70 | return handler.getPrefix(p); 71 | } 72 | 73 | @Override 74 | public String getSuffix(Player p) { 75 | return handler.getSuffix(p); 76 | } 77 | 78 | @Override 79 | public String[] getGroupNames(Player p) { 80 | return handler.getGroupNames(p); 81 | } 82 | 83 | @Override 84 | public String getMessageFormat(Player p) { 85 | return Utils.replaceColors(handler.getMessageFormat(p)); 86 | } 87 | 88 | @Override 89 | public String getGlobalMessageFormat(Player p) { 90 | return Utils.replaceColors(handler.getGlobalMessageFormat(p)); 91 | } 92 | } -------------------------------------------------------------------------------- /src/main/java/de/jeter/chatex/plugins/Vault.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of ChatEx 3 | * Copyright (C) 2022 ChatEx Team 4 | * 5 | * This program is free software; you can redistribute it and/or 6 | * modify it under the terms of the GNU General Public License 7 | * as published by the Free Software Foundation; either version 2 8 | * of the License, or (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program; if not, write to the Free Software 17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 18 | */ 19 | package de.jeter.chatex.plugins; 20 | 21 | import de.jeter.chatex.utils.Config; 22 | import net.milkbowl.vault.chat.Chat; 23 | import org.bukkit.Bukkit; 24 | import org.bukkit.entity.Player; 25 | import org.bukkit.plugin.RegisteredServiceProvider; 26 | 27 | public class Vault implements PermissionsPlugin { 28 | 29 | private static Chat chat = null; 30 | 31 | protected static boolean setupChat() { 32 | RegisteredServiceProvider chatProvider = Bukkit.getServer().getServicesManager().getRegistration(net.milkbowl.vault.chat.Chat.class); 33 | if (chatProvider != null) { 34 | chatProvider.getProvider(); 35 | chat = chatProvider.getProvider(); 36 | return chat.isEnabled(); 37 | } 38 | return false; 39 | } 40 | 41 | @Override 42 | public String getPrefix(Player p) { 43 | if (!Config.MULTIPREFIXES.getBoolean()) { 44 | return chat.getPlayerPrefix(p.getWorld().getName(), p); 45 | } 46 | StringBuilder finalPrefix = new StringBuilder(); 47 | int i = 0; 48 | for (String group : chat.getPlayerGroups(p)) { 49 | String groupPrefix = chat.getGroupPrefix(p.getWorld(), group); 50 | if (groupPrefix != null && !groupPrefix.isEmpty()) { 51 | if (i > 1) { 52 | finalPrefix.append(" "); 53 | } 54 | finalPrefix.append(groupPrefix); 55 | i++; 56 | } 57 | } 58 | return finalPrefix.toString(); 59 | } 60 | 61 | @Override 62 | public String getSuffix(Player p) { 63 | if (!Config.MULTIPREFIXES.getBoolean()) { 64 | return chat.getPlayerSuffix(p.getWorld().getName(), p); 65 | } 66 | StringBuilder finalSuffix = new StringBuilder(); 67 | int i = 0; 68 | for (String group : chat.getPlayerGroups(p)) { 69 | String groupSuffix = chat.getGroupSuffix(p.getWorld(), group); 70 | if (groupSuffix != null && !groupSuffix.isEmpty()) { 71 | if (i > 1) { 72 | finalSuffix.append(" "); 73 | } 74 | i++; 75 | finalSuffix.append(groupSuffix); 76 | } 77 | } 78 | return finalSuffix.toString(); 79 | } 80 | 81 | @Override 82 | public String[] getGroupNames(Player p) { 83 | return chat.getPlayerGroups(p); 84 | } 85 | 86 | @Override 87 | public String getName() { 88 | return "Vault:" + chat.getName(); 89 | } 90 | 91 | @Override 92 | public String getMessageFormat(Player p) { 93 | return Config.FORMAT.getString(); 94 | } 95 | 96 | @Override 97 | public String getGlobalMessageFormat(Player p) { 98 | return Config.GLOBALFORMAT.getString(); 99 | } 100 | } 101 | -------------------------------------------------------------------------------- /src/main/java/de/jeter/chatex/utils/AntiSpamManager.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of ChatEx 3 | * Copyright (C) 2022 ChatEx Team 4 | * 5 | * This program is free software; you can redistribute it and/or 6 | * modify it under the terms of the GNU General Public License 7 | * as published by the Free Software Foundation; either version 2 8 | * of the License, or (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program; if not, write to the Free Software 17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 18 | */ 19 | package de.jeter.chatex.utils; 20 | 21 | import org.bukkit.entity.Player; 22 | 23 | import java.util.HashMap; 24 | import java.util.Map; 25 | import java.util.concurrent.TimeUnit; 26 | 27 | public class AntiSpamManager { 28 | 29 | private static final AntiSpamManager instance = new AntiSpamManager(); 30 | private final Map map = new HashMap<>(); 31 | 32 | private AntiSpamManager() { 33 | 34 | } 35 | 36 | public static AntiSpamManager getInstance() { 37 | return instance; 38 | } 39 | 40 | public void put(Player chatter) { 41 | map.put(chatter, System.currentTimeMillis()); 42 | } 43 | 44 | public boolean isAllowed(Player chatter) { 45 | if (!map.containsKey(chatter) || !Config.ANTISPAM_ENABLED.getBoolean() || chatter.hasPermission("chatex.antispam.bypass")) { 46 | return true; 47 | } 48 | 49 | long lastChat = map.get(chatter) + (Config.ANTISPAM_SECONDS.getInt() * 1000L); 50 | long current = System.currentTimeMillis(); 51 | 52 | return current > lastChat; 53 | } 54 | 55 | public long getRemainingSeconds(Player chatter) { 56 | if (isAllowed(chatter)) { 57 | return 0; 58 | } 59 | 60 | long lastChat = map.get(chatter) + (Config.ANTISPAM_SECONDS.getInt() * 1000L); 61 | long current = System.currentTimeMillis(); 62 | 63 | long diff = lastChat - current; 64 | return TimeUnit.MILLISECONDS.toSeconds(diff); 65 | } 66 | 67 | public void clear() { 68 | map.clear(); 69 | } 70 | 71 | } 72 | -------------------------------------------------------------------------------- /src/main/java/de/jeter/chatex/utils/ChatLogger.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of ChatEx 3 | * Copyright (C) 2022 ChatEx Team 4 | * 5 | * This program is free software; you can redistribute it and/or 6 | * modify it under the terms of the GNU General Public License 7 | * as published by the Free Software Foundation; either version 2 8 | * of the License, or (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program; if not, write to the Free Software 17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 18 | */ 19 | package de.jeter.chatex.utils; 20 | 21 | import de.jeter.chatex.ChatEx; 22 | import org.bukkit.entity.Player; 23 | 24 | import java.io.BufferedWriter; 25 | import java.io.File; 26 | import java.io.FileWriter; 27 | import java.io.IOException; 28 | import java.text.DateFormat; 29 | import java.text.SimpleDateFormat; 30 | import java.util.Calendar; 31 | 32 | public class ChatLogger { 33 | 34 | private static BufferedWriter chatWriter = null; 35 | private static BufferedWriter adWriter = null; 36 | 37 | public static void load() { 38 | try { 39 | File logFolder = new File(ChatEx.getInstance().getDataFolder(), "logs"); 40 | if (Config.LOGCHAT.getBoolean() || Config.ADS_LOG.getBoolean()) { 41 | logFolder.mkdirs(); 42 | } 43 | if (Config.LOGCHAT.getBoolean()) { 44 | File chatLog = new File(logFolder, fileName()); 45 | chatLog.createNewFile(); 46 | chatWriter = new BufferedWriter(new FileWriter(chatLog, true)); 47 | } 48 | if (Config.ADS_LOG.getBoolean()) { 49 | File adLog = new File(logFolder, "ads.log"); 50 | adLog.createNewFile(); 51 | adWriter = new BufferedWriter(new FileWriter(adLog, true)); 52 | } 53 | } catch (IOException ex) { 54 | ex.printStackTrace(); 55 | } 56 | } 57 | 58 | public static void close() { 59 | try { 60 | if (chatWriter != null) { 61 | chatWriter.close(); 62 | } 63 | if (adWriter != null) { 64 | adWriter.close(); 65 | } 66 | } catch (IOException ex) { 67 | ex.printStackTrace(); 68 | } 69 | } 70 | 71 | public static void writeToFile(Player player, String message) { 72 | if (!Config.LOGCHAT.getBoolean() || chatWriter == null) { 73 | return; 74 | } 75 | 76 | try { 77 | chatWriter.write(prefix(false) + player.getName() + " (uuid: " + player.getUniqueId() + "): " + message); 78 | chatWriter.newLine(); 79 | chatWriter.flush(); 80 | } catch (IOException ex) { 81 | ex.printStackTrace(); 82 | } 83 | } 84 | 85 | public static void writeToAdFile(Player player, String message) { 86 | if (!Config.ADS_LOG.getBoolean() || adWriter == null) { 87 | return; 88 | } 89 | try { 90 | adWriter.write(prefix(true) + player.getName() + " (uuid: " + player.getUniqueId() + "): " + message); 91 | adWriter.newLine(); 92 | adWriter.flush(); 93 | } catch (IOException ex) { 94 | ex.printStackTrace(); 95 | } 96 | } 97 | 98 | private static String fileName() { 99 | DateFormat date = new SimpleDateFormat("yyyy-MM-dd"); 100 | Calendar cal = Calendar.getInstance(); 101 | return date.format(cal.getTime()) + ".log"; 102 | } 103 | 104 | private static String prefix(boolean day) { 105 | DateFormat date = day ? new SimpleDateFormat("[yyyy-MM-dd HH:mm:ss] ") : new SimpleDateFormat("[HH:mm:ss] "); 106 | Calendar cal = Calendar.getInstance(); 107 | return date.format(cal.getTime()); 108 | } 109 | 110 | } -------------------------------------------------------------------------------- /src/main/java/de/jeter/chatex/utils/Config.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of ChatEx 3 | * Copyright (C) 2022 ChatEx Team 4 | * 5 | * This program is free software; you can redistribute it and/or 6 | * modify it under the terms of the GNU General Public License 7 | * as published by the Free Software Foundation; either version 2 8 | * of the License, or (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program; if not, write to the Free Software 17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 18 | */ 19 | package de.jeter.chatex.utils; 20 | 21 | import de.jeter.chatex.ChatEx; 22 | import org.bukkit.configuration.ConfigurationSection; 23 | import org.bukkit.configuration.file.YamlConfiguration; 24 | import org.bukkit.event.EventPriority; 25 | 26 | import java.io.File; 27 | import java.io.IOException; 28 | import java.util.ArrayList; 29 | import java.util.Arrays; 30 | import java.util.List; 31 | 32 | public enum Config { 33 | 34 | CHECK_UPDATE("check-for-updates", true, "Should the plugin check for updates by itself?"), 35 | B_STATS("enable-bstats", true, "Do you want to use bstats?"), 36 | BUNGEECORD("bungeecord", false, "If you use bungeecord, players can chat cross-server wide with the range mode (! in front of the message)."), 37 | CROSS_SERVER_TIMEOUT("cross_server_timeout", 3, "If this timeout (In seconds) is exceeded the cross-server-message will not be send."), 38 | FORMAT("message-format", "%prefix%displayname%suffix: %message", "The standard message-format."), 39 | GLOBALFORMAT("global-message-format", "&9[%world] %prefix%displayname%suffix: &e%message", "The message-format if ranged-mode is enabled."), 40 | MULTIPREFIXES("multi-prefixes", false, "Should the multi-prefixes be enabled?"), 41 | MULTISUFFIXES("multi-suffixes", false, "Should the multi-suffixes be enabled?"), 42 | RANGEMODE("ranged-mode", false, "Should the ranged-mode be enabled?"), 43 | RANGEPREFIX("ranged-prefix", "!", "The Prefix to use for Range Mode"), 44 | SHOW_NO_RECEIVER_MSG("show-no-players-near", true, "Should we check if any player would receiver your chat message?"), 45 | RANGE("chat-range", 100, "The range to talk to other players. Set to -1 to enable world-wide-chat"), 46 | LOGCHAT("logChat", false, "Should the chat be logged?"), 47 | DEBUG("debug", false, "Should the debug log be enabled?"), 48 | PRIORITY("EventPriority", EventPriority.LOWEST.name(), "Choose the Eventpriority here of ChatEx. Listeners are called in following order: LOWEST -> LOW -> NORMAL -> HIGH -> HIGHEST -> MONITOR"), 49 | LOCALE("Locale", "en-EN", "Which language do you want? (You can choose betwenn de-DE, fr-FR, pt-BR, zh-CN and en-EN by default.)"), 50 | ADS_ENABLED("Ads.Enabled", true, "Should we check for ads?"), 51 | ADS_BYPASS("Ads.Bypass", Arrays.asList("127.0.0.1", "my-domain.com"), "A list with allowed ips or domains."), 52 | ADS_LOG("Ads.Log", true, "Should the ads be logged in a file?"), 53 | ADS_SMART_MANAGER("Ads.SmartManager", true, "Should the \"Smart Manager\" be used? (For more information read: https://github.com/TheJeterLP/ChatEx/wiki/Ad-Manager)"), 54 | ADS_SMART_DOMAIN_ENDINGS("Ads.SmartConfig.DomainEndings", Arrays.asList( 55 | "com", "net", "org", "de", "icu", "uk", "ru", "me", "info", "top", "xyz", "tk", "cn", "ga", "cf", "nl", "eu" 56 | ), "The endings the SmartManager applies the multiplier to."), 57 | ADS_REPLACE_COMMAS("Ads.ReplaceCommas", false, "Should commas be replaced with \".\" for the add test?"), 58 | ADS_SMART_MULTIPLIER("Ads.SmartConfig.Multiplier", 4, "If a domain pattern contains an ending from Ads.SmartConfig.DomainEndings the score get multiplied by this number."), 59 | ADS_SMART_UN_MULTIPLIER("Ads.SmartConfig.UnMultiplier", 1, "If a domain pattern contains NOT an ending from Ads.SmartConfig.DomainEndings the score get multiplied by this number."), 60 | ADS_THRESHOLD("Ads.Threshold.Block", 0.3, "The threshold required to cancel a message."), 61 | ADS_REDUCE_THRESHOLD("Ads.Threshold.ReduceThreshold", 0.1, "How much threshold is removed per message"), 62 | ADS_MAX_LENGTH("Ads.Threshold.MaxLinkLength", 10, "What the max detected link length is (For more information read: https://github.com/TheJeterLP/ChatEx/wiki/Ad-Manager)"), 63 | ANTISPAM_SECONDS("AntiSpam.Seconds", 5, "The delay between player messages to prevent spam"), 64 | ANTISPAM_ENABLED("AntiSpam.Enable", true, "Should antispam be enabled?"), 65 | BLOCKED_WORDS("BlockedWords", Arrays.asList("shit", "@everyone"), "A list of words that should be blocked."), 66 | CHANGE_TABLIST_NAME("Tablist.Change", true, "Do you want to have the prefixes and suffixes in the tablist?"), 67 | TABLIST_FORMAT("Tablist.format", "%prefix%player%suffix", "The format of the tablist name"), 68 | CHANGE_JOIN_AND_QUIT("Messages.JoinAndQuit.Enabled", false, "Do you want to change the join and the quit messages?"), 69 | RGB_COLORS("colors", null, "Requires 1.16+, Colors you want to use."), 70 | RGB_COLORS_EXAMPLE("colors.$g", "#00ff00", "Default color code. &g in chat will be used with the #00ff00."), 71 | AFK_PLACEHOLDER("AfkPlaceholder.Enabled", false, "Enable the %afk placeholder. You can use it to display AFK players on tablist. (Requires Essentials or Purpur)."), 72 | AFK_FORMAT("AfkPlaceholder.format", "&r[&7AFK&r] ", "The format of the afk placeholder."); 73 | 74 | private static final File f = new File(ChatEx.getInstance().getDataFolder(), "config.yml"); 75 | private static YamlConfiguration cfg; 76 | private final Object value; 77 | private final String path; 78 | private final String description; 79 | 80 | Config(String path, Object val, String description) { 81 | this.path = path; 82 | this.value = val; 83 | this.description = description; 84 | } 85 | 86 | public static void load() { 87 | ChatEx.getInstance().getDataFolder().mkdirs(); 88 | reload(false); 89 | List header = new ArrayList<>(); 90 | header.add("Thanks for installing " + ChatEx.getInstance().getName()); 91 | header.add("Please report any bugs you may encounter at my discord under:"); 92 | header.add("https://www.thejeterlp.de/discord"); 93 | header.add("-------------------------------Descriptions--------------------------------------"); 94 | header.add(""); 95 | for (Config c : values()) { 96 | header.add(c.getPath() + ": " + c.getDescription()); 97 | if (!cfg.contains(c.getPath())) { 98 | c.set(c.getDefaultValue(), false); 99 | } 100 | } 101 | try { 102 | cfg.options().setHeader(header); 103 | } catch (NoSuchMethodError e) { 104 | String headerString = ""; 105 | for (String s : header) { 106 | headerString += s + System.lineSeparator(); 107 | } 108 | cfg.options().header(headerString); 109 | } 110 | try { 111 | cfg.save(f); 112 | } catch (IOException ex) { 113 | ex.printStackTrace(); 114 | } 115 | } 116 | 117 | public static void reload(boolean complete) { 118 | if (!complete) { 119 | cfg = YamlConfiguration.loadConfiguration(f); 120 | return; 121 | } 122 | load(); 123 | } 124 | 125 | public String getPath() { 126 | return path; 127 | } 128 | 129 | public String getDescription() { 130 | return description; 131 | } 132 | 133 | public Object getDefaultValue() { 134 | return value; 135 | } 136 | 137 | public boolean getBoolean() { 138 | return cfg.getBoolean(path); 139 | } 140 | 141 | public double getDouble() { 142 | return cfg.getDouble(path); 143 | } 144 | 145 | public int getInt() { 146 | return cfg.getInt(path); 147 | } 148 | 149 | public String getString() { 150 | return Utils.replaceColors(cfg.getString(path)); 151 | } 152 | 153 | public List getStringList() { 154 | return cfg.getStringList(path); 155 | } 156 | 157 | public ConfigurationSection getConfigurationSection() { 158 | return cfg.getConfigurationSection(path); 159 | } 160 | 161 | public void set(Object value, boolean save) { 162 | cfg.set(path, value); 163 | if (save) { 164 | try { 165 | cfg.save(f); 166 | } catch (IOException ex) { 167 | ex.printStackTrace(); 168 | } 169 | reload(false); 170 | } 171 | } 172 | } 173 | -------------------------------------------------------------------------------- /src/main/java/de/jeter/chatex/utils/CustomCharts.java: -------------------------------------------------------------------------------- 1 | package de.jeter.chatex.utils; 2 | 3 | import de.jeter.chatex.plugins.PluginManager; 4 | import org.bstats.bukkit.Metrics; 5 | import org.bstats.charts.SimplePie; 6 | 7 | public class CustomCharts { 8 | 9 | public static void addUpdateCheckerChart(Metrics metrics) { 10 | metrics.addCustomChart(new SimplePie("updatechecker_enabled", () -> String.valueOf(Config.CHECK_UPDATE.getBoolean()))); 11 | } 12 | 13 | public static void addPermissionsPluginChart(Metrics metrics) { 14 | metrics.addCustomChart(new SimplePie("used_permissions_plugin", () -> PluginManager.getInstance().getName())); 15 | } 16 | 17 | } 18 | -------------------------------------------------------------------------------- /src/main/java/de/jeter/chatex/utils/DomainDictionary.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of ChatEx 3 | * Copyright (C) 2022 ChatEx Team 4 | * 5 | * This program is free software; you can redistribute it and/or 6 | * modify it under the terms of the GNU General Public License 7 | * as published by the Free Software Foundation; either version 2 8 | * of the License, or (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program; if not, write to the Free Software 17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 18 | */ 19 | package de.jeter.chatex.utils; 20 | 21 | import java.util.HashSet; 22 | 23 | public class DomainDictionary { 24 | 25 | private static final HashSet endingSet = new HashSet<>(Config.ADS_SMART_DOMAIN_ENDINGS.getStringList()); 26 | 27 | public static boolean containsTopLevelEnding(String checkString) { 28 | String[] parts = checkString.split("\\."); 29 | String ending = parts[parts.length - 1]; 30 | StringBuilder stringBuilder = new StringBuilder(); 31 | for (char Character : ending.toCharArray()) { 32 | stringBuilder.append(Character); 33 | if (endingSet.contains(stringBuilder.toString())) { 34 | return true; 35 | } 36 | } 37 | return false; 38 | } 39 | 40 | } 41 | -------------------------------------------------------------------------------- /src/main/java/de/jeter/chatex/utils/HookManager.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of ChatEx 3 | * Copyright (C) 2022 ChatEx Team 4 | * 5 | * This program is free software; you can redistribute it and/or 6 | * modify it under the terms of the GNU General Public License 7 | * as published by the Free Software Foundation; either version 2 8 | * of the License, or (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program; if not, write to the Free Software 17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 18 | */ 19 | package de.jeter.chatex.utils; 20 | 21 | import org.bukkit.Bukkit; 22 | import org.bukkit.plugin.Plugin; 23 | 24 | public class HookManager { 25 | 26 | public static boolean checkVault() { 27 | Plugin plugin = Bukkit.getServer().getPluginManager().getPlugin("Vault"); 28 | return plugin != null && plugin.isEnabled(); 29 | } 30 | 31 | public static boolean checkLuckperms() { 32 | Plugin plugin = Bukkit.getServer().getPluginManager().getPlugin("LuckPerms"); 33 | return plugin != null && plugin.isEnabled(); 34 | } 35 | 36 | public static boolean checkPlaceholderAPI() { 37 | Plugin plugin = Bukkit.getServer().getPluginManager().getPlugin("PlaceholderAPI"); 38 | return plugin != null && plugin.isEnabled(); 39 | } 40 | 41 | public static boolean checkEssentials() { 42 | Plugin plugin = Bukkit.getServer().getPluginManager().getPlugin("Essentials"); 43 | return plugin != null && plugin.isEnabled(); 44 | } 45 | 46 | public static boolean checkPurpur() { 47 | try { 48 | Class.forName("org.purpurmc.purpur.event.PlayerAFKEvent"); 49 | return true; 50 | } catch (ClassNotFoundException e) { 51 | return false; 52 | } 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /src/main/java/de/jeter/chatex/utils/Locales.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of ChatEx 3 | * Copyright (C) 2022 ChatEx Team 4 | * 5 | * This program is free software; you can redistribute it and/or 6 | * modify it under the terms of the GNU General Public License 7 | * as published by the Free Software Foundation; either version 2 8 | * of the License, or (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program; if not, write to the Free Software 17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 18 | */ 19 | package de.jeter.chatex.utils; 20 | 21 | import de.jeter.chatex.ChatEx; 22 | import org.bukkit.configuration.file.YamlConfiguration; 23 | import org.bukkit.entity.Player; 24 | 25 | import java.io.File; 26 | import java.io.IOException; 27 | 28 | public enum Locales { 29 | 30 | COMMAND_RELOAD_DESCRIPTION("Commands.Reload.Description", "Reloads the plugin and its configuration."), 31 | COMMAND_CLEAR_DESCRIPTION("Commands.Clear.Description", "Clears the chat."), 32 | COMMAND_CLEAR_CONSOLE("Commands.Clear.Console", "CONSOLE"), 33 | COMMAND_CLEAR_UNKNOWN("Commands.Clear.Unknown", "UNKNOWN"), 34 | MESSAGES_RELOAD("Messages.Commands.Reload.Success", "&aConfig was reloaded."), 35 | MESSAGES_CLEAR("Messages.Commands.Clear.Success", "&aThe chat has been cleared by "), 36 | MESSAGES_AD("Messages.Chat.AdDetected", "&4[ERROR] &7Advertising is not allowed! &c(%perm)"), 37 | MESSAGES_BLOCKED("Messages.Chat.BlockedWord", "&4[ERROR] &7You tried to write a word that is blocked!"), 38 | MESSAGES_AD_NOTIFY("Messages.Chat.AdNotify", "&c%player tried to write an ad in chat. He wrote: \n&a %message"), 39 | COMMAND_RESULT_NO_PERM("Messages.CommandResult.NoPermission", "&4[ERROR] &7You don't have permission for this! &c(%perm)"), 40 | COMMAND_RESULT_WRONG_USAGE("Messages.CommandResult.WrongUsage", "&c[ERROR] &7Wrong usage! Please type &6%cmd help&7!"), 41 | ANTI_SPAM_DENIED("Messages.AntiSpam.Denied", "&e[AntiSpam] &7You are not allowed to spam! Please wait another &e%time% &7seconds!"), 42 | PLAYER_JOIN("Messages.Player.Join", "%prefix%displayname%suffix &ejoined the game!"), 43 | PLAYER_JOIN_FIRST_TIME("Messages.Player.JoinFirstTime", "%prefix%displayname%suffix &ejoined the server for the first time!"), 44 | PLAYER_KICK("Messages.Player.Kick", "%prefix%displayname%suffix &ewas kicked from the game!"), 45 | PLAYER_QUIT("Messages.Player.Quit", "%prefix%displayname%suffix &eleft the game!"), 46 | NO_LISTENING_PLAYERS("Messages.Chat.NoOneListens", "&cNo players are near you to hear you talking! Try to use the global mode to chat globally."), 47 | UPDATE_FOUND("Messages.UpdateFound", "&a[ChatEx]&7 A new update has been found on SpigotMC. Current version: %oldversion New version: %newversion. Click this message to download it!"), 48 | ; 49 | 50 | private static final File localeFolder = new File(ChatEx.getInstance().getDataFolder(), "locales"); 51 | private static YamlConfiguration cfg; 52 | private static File f; 53 | private final String value; 54 | private final String path; 55 | 56 | Locales(String path, String val) { 57 | this.path = path; 58 | this.value = val; 59 | } 60 | 61 | public static void load() { 62 | localeFolder.mkdirs(); 63 | f = new File(localeFolder, Config.LOCALE.getString() + ".yml"); 64 | if (!f.exists()) { 65 | try { 66 | ChatEx.getInstance().saveResource("locales" + File.separator + Config.LOCALE.getString() + ".yml", true); 67 | File locale = new File(ChatEx.getInstance().getDataFolder(), Config.LOCALE.getString() + ".yml"); 68 | if (locale.exists()) { 69 | locale.delete(); 70 | } 71 | reload(false); 72 | } catch (IllegalArgumentException ex) { 73 | reload(false); 74 | try { 75 | for (Locales c : values()) { 76 | if (!cfg.contains(c.getPath())) { 77 | c.set(c.getDefaultValue(), false); 78 | } 79 | } 80 | cfg.save(f); 81 | } catch (IOException ioex) { 82 | ioex.printStackTrace(); 83 | } 84 | } 85 | } else { 86 | reload(false); 87 | try { 88 | for (Locales c : values()) { 89 | if (!cfg.contains(c.getPath())) { 90 | c.set(c.getDefaultValue(), false); 91 | } 92 | } 93 | cfg.save(f); 94 | } catch (IOException ex) { 95 | ex.printStackTrace(); 96 | } 97 | } 98 | } 99 | 100 | public static void reload(boolean complete) { 101 | if (!complete) { 102 | cfg = YamlConfiguration.loadConfiguration(f); 103 | return; 104 | } 105 | load(); 106 | } 107 | 108 | public String getPath() { 109 | return path; 110 | } 111 | 112 | public String getDefaultValue() { 113 | return value; 114 | } 115 | 116 | public String getString(Player p) { 117 | String ret = Utils.replaceColors(cfg.getString(path)); 118 | ret = Utils.replacePlayerPlaceholders(p, ret); 119 | return ret; 120 | } 121 | 122 | public void set(Object value, boolean save) { 123 | cfg.set(path, value); 124 | if (save) { 125 | try { 126 | cfg.save(f); 127 | } catch (IOException ex) { 128 | ex.printStackTrace(); 129 | } 130 | reload(false); 131 | } 132 | } 133 | } 134 | -------------------------------------------------------------------------------- /src/main/java/de/jeter/chatex/utils/LogHelper.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of ChatEx 3 | * Copyright (C) 2022 ChatEx Team 4 | * 5 | * This program is free software; you can redistribute it and/or 6 | * modify it under the terms of the GNU General Public License 7 | * as published by the Free Software Foundation; either version 2 8 | * of the License, or (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program; if not, write to the Free Software 17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 18 | */ 19 | package de.jeter.chatex.utils; 20 | 21 | import de.jeter.chatex.ChatEx; 22 | 23 | public class LogHelper { 24 | 25 | public static void debug(String text) { 26 | if (!Config.DEBUG.getBoolean()) { 27 | return; 28 | } 29 | ChatEx.getInstance().getLogger().info("[DEBUG] " + text); 30 | } 31 | 32 | } 33 | -------------------------------------------------------------------------------- /src/main/java/de/jeter/chatex/utils/RGBColors.java: -------------------------------------------------------------------------------- 1 | package de.jeter.chatex.utils; 2 | 3 | import de.jeter.chatex.ChatEx; 4 | import org.bukkit.Bukkit; 5 | import org.bukkit.ChatColor; 6 | import org.bukkit.configuration.ConfigurationSection; 7 | 8 | import java.util.HashMap; 9 | import java.util.Map; 10 | import java.util.regex.Matcher; 11 | import java.util.regex.Pattern; 12 | 13 | public class RGBColors { 14 | 15 | private static final HashMap placeHolderColorMap = new HashMap<>(); 16 | 17 | private static Boolean supported = null; 18 | 19 | public static void load() { 20 | ChatEx.getInstance().getLogger().info("Server version:" + Bukkit.getVersion()); 21 | if (isNotSupported()) { 22 | ChatEx.getInstance().getLogger().info("This server version doesn't support custom color codes!"); 23 | return; 24 | } 25 | ChatEx.getInstance().getLogger().info("Version is later than 1.16. Loading RGB ColorCodes!"); 26 | ConfigurationSection configurationSection = Config.RGB_COLORS.getConfigurationSection(); 27 | 28 | if (configurationSection == null) { 29 | ChatEx.getInstance().getLogger().info("No ColorCodes Specified!"); 30 | return; 31 | } 32 | 33 | for (Map.Entry stringObjectEntry : configurationSection.getValues(false).entrySet()) { 34 | String key = stringObjectEntry.getKey(); 35 | String value = (String) stringObjectEntry.getValue(); 36 | LogHelper.debug(("Loading custom color code " + key + " with value " + value + " from config!")); 37 | String clearedValue = value.replaceFirst("#", ""); 38 | char[] valueChars = clearedValue.toCharArray(); 39 | StringBuilder rgbColor = new StringBuilder(); 40 | rgbColor.append("§x"); 41 | for (int i = 0; i < clearedValue.length(); i++) { 42 | rgbColor.append("§").append(valueChars[i]); 43 | } 44 | LogHelper.debug("Putting KEY: " + key + " value: " + rgbColor); 45 | placeHolderColorMap.put(key, rgbColor.toString()); 46 | } 47 | } 48 | 49 | public static String translateCustomColorCodes(String s) { 50 | if (isNotSupported()) { 51 | return s; 52 | } 53 | s = translateSingleMessageColorCodes(s); 54 | for (Map.Entry stringColorEntry : placeHolderColorMap.entrySet()) { 55 | s = s.replace(stringColorEntry.getKey(), stringColorEntry.getValue()); 56 | } 57 | return s; 58 | } 59 | 60 | public static String translateSingleMessageColorCodes(String s) { 61 | for (int i = 0; i < s.length(); i++) { 62 | if (s.length() - i > 8) { 63 | String tempString = s.substring(i, i + 8); 64 | if (tempString.startsWith("&#")) { 65 | char[] tempChars = tempString.replaceFirst("&#", "").toCharArray(); 66 | StringBuilder rgbColor = new StringBuilder(); 67 | rgbColor.append("§x"); 68 | for (char tempChar : tempChars) { 69 | rgbColor.append("§").append(tempChar); 70 | } 71 | s = s.replaceAll(tempString, rgbColor.toString()); 72 | } 73 | } 74 | } 75 | return s; 76 | } 77 | 78 | private static boolean isNotSupported() { 79 | if (supported == null) { 80 | try { 81 | final String version = Bukkit.getVersion(); 82 | String ver = version.split("\\(MC: ")[1]; 83 | String[] numbers = ver.replaceAll("\\)", "").split("\\."); 84 | ver = numbers[0] + numbers[1]; 85 | int toCheck = Integer.valueOf(ver); 86 | LogHelper.debug(ver + " INT: " + toCheck); 87 | supported = toCheck >= 116; 88 | } catch (Exception ex) { 89 | ex.printStackTrace(); 90 | } 91 | } 92 | return !supported; 93 | } 94 | 95 | public static String translateGradientCodes(String message) { 96 | final Pattern hexPattern = Pattern.compile("#([A-Fa-f0-9]{6})"); 97 | Matcher matcher = hexPattern.matcher(message); 98 | StringBuffer buffer = new StringBuffer(message.length() + 4 * 8); 99 | while (matcher.find()) 100 | { 101 | String group = matcher.group(1); 102 | matcher.appendReplacement(buffer, ChatColor.COLOR_CHAR + "x" 103 | + ChatColor.COLOR_CHAR + group.charAt(0) + ChatColor.COLOR_CHAR + group.charAt(1) 104 | + ChatColor.COLOR_CHAR + group.charAt(2) + ChatColor.COLOR_CHAR + group.charAt(3) 105 | + ChatColor.COLOR_CHAR + group.charAt(4) + ChatColor.COLOR_CHAR + group.charAt(5) 106 | ); 107 | } 108 | return matcher.appendTail(buffer).toString(); 109 | } 110 | 111 | } 112 | -------------------------------------------------------------------------------- /src/main/java/de/jeter/chatex/utils/Utils.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of ChatEx 3 | * Copyright (C) 2022 ChatEx Team 4 | * 5 | * This program is free software; you can redistribute it and/or 6 | * modify it under the terms of the GNU General Public License 7 | * as published by the Free Software Foundation; either version 2 8 | * of the License, or (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program; if not, write to the Free Software 17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 18 | */ 19 | package de.jeter.chatex.utils; 20 | 21 | import de.jeter.chatex.ChatEx; 22 | import de.jeter.chatex.plugins.PluginManager; 23 | import me.clip.placeholderapi.PlaceholderAPI; 24 | import org.bukkit.ChatColor; 25 | import org.bukkit.Location; 26 | import org.bukkit.entity.Player; 27 | 28 | import java.util.ArrayList; 29 | import java.util.List; 30 | 31 | public class Utils { 32 | 33 | public static String translateColorCodes(String string, Player p) { 34 | return p.hasPermission("chatex.chat.color") ? replaceColors(string) : string; 35 | } 36 | 37 | public static String replaceColors(String message) { 38 | message = RGBColors.translateGradientCodes(message); 39 | message = RGBColors.translateCustomColorCodes(message); 40 | return ChatColor.translateAlternateColorCodes('&', message); 41 | } 42 | 43 | public static List getLocalRecipients(Player sender) { 44 | Location playerLocation = sender.getLocation(); 45 | List recipients = new ArrayList<>(); 46 | 47 | double squaredDistance = Math.pow(Config.RANGE.getInt(), 2); 48 | for (Player recipient : sender.getWorld().getPlayers()) { 49 | if (Config.RANGE.getInt() > 0 && (playerLocation.distanceSquared(recipient.getLocation()) > squaredDistance)) { 50 | continue; 51 | } 52 | recipients.add(recipient); 53 | } 54 | 55 | return recipients; 56 | } 57 | 58 | public static String replacePlayerPlaceholders(Player player, String format) { 59 | if (player == null) { 60 | return format; 61 | } 62 | String result = format; 63 | 64 | result = result.replace("%displayname", player.getDisplayName()); 65 | result = result.replace("%prefix", PluginManager.getInstance().getPrefix(player)); 66 | result = result.replace("%suffix", PluginManager.getInstance().getSuffix(player)); 67 | result = result.replace("%player", player.getName()); 68 | result = result.replace("%world", player.getWorld().getName()); 69 | result = result.replace("%group", PluginManager.getInstance().getGroupNames(player).length > 0 ? PluginManager.getInstance().getGroupNames(player)[0] : "none"); 70 | 71 | if (HookManager.checkPlaceholderAPI()) { 72 | LogHelper.debug("PlaceholderAPI is installed! Replacing..."); 73 | result = PlaceholderAPI.setPlaceholders(player, result); 74 | LogHelper.debug("Result: " + result); 75 | } 76 | 77 | if ((HookManager.checkEssentials() || HookManager.checkPurpur()) && Config.AFK_PLACEHOLDER.getBoolean()) { 78 | result = result.replace("%afk", ""); 79 | } 80 | 81 | result = replaceColors(result); 82 | 83 | return result; 84 | } 85 | 86 | public static String escape(String string) { 87 | return string.replace("%", "%%"); 88 | } 89 | 90 | public static boolean checkForBypassString(String message) { 91 | for (String block : Config.ADS_BYPASS.getStringList()) { 92 | if (message.toLowerCase().contains(block.toLowerCase())) { 93 | return true; 94 | } 95 | } 96 | return false; 97 | } 98 | 99 | public static void notifyOps(String msg) { 100 | for (Player op : ChatEx.getInstance().getServer().getOnlinePlayers()) { 101 | if (!op.hasPermission("chatex.notifyad")) { 102 | continue; 103 | } 104 | op.sendMessage(msg); 105 | } 106 | } 107 | 108 | } 109 | -------------------------------------------------------------------------------- /src/main/java/de/jeter/chatex/utils/adManager/AdManager.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of ChatEx 3 | * Copyright (C) 2022 ChatEx Team 4 | * 5 | * This program is free software; you can redistribute it and/or 6 | * modify it under the terms of the GNU General Public License 7 | * as published by the Free Software Foundation; either version 2 8 | * of the License, or (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program; if not, write to the Free Software 17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 18 | */ 19 | package de.jeter.chatex.utils.adManager; 20 | 21 | import org.bukkit.entity.Player; 22 | 23 | public interface AdManager { 24 | boolean checkForAds(String message, Player p); 25 | } 26 | -------------------------------------------------------------------------------- /src/main/java/de/jeter/chatex/utils/adManager/SimpleAdManager.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of ChatEx 3 | * Copyright (C) 2022 ChatEx Team 4 | * 5 | * This program is free software; you can redistribute it and/or 6 | * modify it under the terms of the GNU General Public License 7 | * as published by the Free Software Foundation; either version 2 8 | * of the License, or (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program; if not, write to the Free Software 17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 18 | */ 19 | package de.jeter.chatex.utils.adManager; 20 | 21 | import de.jeter.chatex.utils.ChatLogger; 22 | import de.jeter.chatex.utils.Config; 23 | import de.jeter.chatex.utils.Locales; 24 | import de.jeter.chatex.utils.Utils; 25 | import org.bukkit.entity.Player; 26 | 27 | import java.util.regex.Matcher; 28 | import java.util.regex.Pattern; 29 | 30 | public class SimpleAdManager implements AdManager { 31 | private static final Pattern ipPattern = Pattern.compile("((? 4) { 42 | String[] domains = text.split("\\."); 43 | String one = domains[domains.length - 1]; 44 | String two = domains[domains.length - 2]; 45 | String three = domains[domains.length - 3]; 46 | String four = domains[domains.length - 4]; 47 | text = one + "." + two + "." + three + "." + four; 48 | } 49 | 50 | if (ipPattern.matcher(text).find()) { 51 | if (!Utils.checkForBypassString(regexMatcher.group().trim())) { 52 | return true; 53 | } 54 | } 55 | } 56 | } 57 | return false; 58 | } 59 | 60 | private static boolean checkForWebPattern(String message) { 61 | message = Config.ADS_REPLACE_COMMAS.getBoolean() ? message.replaceAll(",", ".") : message; 62 | message = message.replaceAll(" ", ""); 63 | Matcher regexMatcher = webpattern.matcher(message); 64 | while (regexMatcher.find()) { 65 | if (regexMatcher.group().length() != 0) { 66 | String text = regexMatcher.group().trim().replaceAll("http://", "").replaceAll("https://", "").split("/")[0]; 67 | 68 | if (text.split("\\.").length > 2) { 69 | String[] domains = text.split("\\."); 70 | String toplevel = domains[domains.length - 1]; 71 | String second = domains[domains.length - 2]; 72 | text = second + "." + toplevel; 73 | } 74 | 75 | if (webpattern.matcher(text).find()) { 76 | if (!Utils.checkForBypassString(message)) { 77 | return true; 78 | } 79 | } 80 | } 81 | } 82 | return false; 83 | } 84 | 85 | @Override 86 | public boolean checkForAds(String msg, Player p) { 87 | if (p.hasPermission("chatex.bypassads")) { 88 | return false; 89 | } 90 | if (!Config.ADS_ENABLED.getBoolean()) { 91 | return false; 92 | } 93 | boolean found = checkForIPPattern(msg) || checkForWebPattern(msg); 94 | if (found) { 95 | String message = Locales.MESSAGES_AD_NOTIFY.getString(p) 96 | .replaceAll("%player", Matcher.quoteReplacement(p.getName())) 97 | .replaceAll("%message", Matcher.quoteReplacement(msg)); 98 | Utils.notifyOps(message); 99 | ChatLogger.writeToAdFile(p, msg); 100 | } 101 | return found; 102 | } 103 | } 104 | -------------------------------------------------------------------------------- /src/main/java/de/jeter/chatex/utils/adManager/SmartAdManager.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of ChatEx 3 | * Copyright (C) 2022 ChatEx Team 4 | * 5 | * This program is free software; you can redistribute it and/or 6 | * modify it under the terms of the GNU General Public License 7 | * as published by the Free Software Foundation; either version 2 8 | * of the License, or (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program; if not, write to the Free Software 17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 18 | */ 19 | package de.jeter.chatex.utils.adManager; 20 | 21 | import de.jeter.chatex.utils.*; 22 | import org.bukkit.entity.Player; 23 | 24 | import java.util.HashMap; 25 | import java.util.Map; 26 | import java.util.UUID; 27 | import java.util.regex.Matcher; 28 | import java.util.regex.Pattern; 29 | 30 | public class SmartAdManager implements AdManager { 31 | private static final Map uuidErrorMap = new HashMap<>(); 32 | private static final Pattern ipPattern = Pattern.compile("((? 0 ? error / messageLength : 0; 79 | } 80 | return error; 81 | } 82 | 83 | @Override 84 | public boolean checkForAds(String msg, Player p) { 85 | if (p.hasPermission("chatex.bypassads")) { 86 | return false; 87 | } 88 | if (!Config.ADS_ENABLED.getBoolean()) { 89 | return false; 90 | } 91 | if (!uuidErrorMap.containsKey(p.getUniqueId()) || uuidErrorMap.get(p.getUniqueId()) < 0) { 92 | uuidErrorMap.put(p.getUniqueId(), 0d); 93 | } 94 | double error = checkForWebPattern(msg); 95 | uuidErrorMap.put(p.getUniqueId(), uuidErrorMap.get(p.getUniqueId()) + error); 96 | boolean canceled = uuidErrorMap.get(p.getUniqueId()) > Config.ADS_THRESHOLD.getDouble() || checkForIPPattern(msg); 97 | if (canceled) { 98 | uuidErrorMap.put(p.getUniqueId(), Config.ADS_THRESHOLD.getDouble()); 99 | String message = Locales.MESSAGES_AD_NOTIFY.getString(p) 100 | .replaceAll("%player", Matcher.quoteReplacement(p.getName())) 101 | .replaceAll("%message", Matcher.quoteReplacement(msg)); 102 | Utils.notifyOps(message); 103 | ChatLogger.writeToAdFile(p, msg); 104 | } else { 105 | uuidErrorMap.put(p.getUniqueId(), uuidErrorMap.get(p.getUniqueId()) - Config.ADS_REDUCE_THRESHOLD.getDouble()); 106 | } 107 | return canceled; 108 | } 109 | } -------------------------------------------------------------------------------- /src/main/resources/locales/de-DE.yml: -------------------------------------------------------------------------------- 1 | Commands: 2 | Reload: 3 | Description: 'Lädt das Plugin und seine Konfiguration neu.' 4 | Clear: 5 | Description: 'Leert den Chat.' 6 | Console: 'KONSOLE' 7 | Unknown: 'UNBEKANNT' 8 | Messages: 9 | Chat: 10 | AdDetected: '&4[FEHLER] &7Werbung ist nicht erlaubt! &c(%perm)' 11 | AdNotify: "&c%player Hat versucht Werbung zu schreiben: \n&a %message" 12 | BlockedWord: '&4[FEHLER] &7Du hast versucht ein verbotenes Wort zu schreiben!' 13 | NoOneListens: '&cDich kann niemand hören! Benutze den ranged mode um zu chatten.' 14 | Commands: 15 | Reload: 16 | Success: '&aChatEx wurde neugeladen.' 17 | Clear: 18 | Success: '&aDer Chat wurde geleert von ' 19 | CommandResult: 20 | NoPermission: '&4[FEHLER] &7Dafür hast du nicht die nötigen Rechte! &c(%perm)' 21 | WrongUsage: '&c[FEHLER] &7Falsche Benutzung! Benutze &6%cmd help&7!' 22 | Player: 23 | Join: '%prefix%displayname%suffix &ehat den Server betreten!' 24 | Quit: '%prefix%displayname%suffix &ehat den Server verlassen!' 25 | Kick: '%prefix%displayname%suffix &ewurde vom Server gekickt!' 26 | UpdateFound: '&a[ChatEx]&7 Ein neues Update wurde veröffentlicht. Aktuelle Version: %oldversion Neue version: %newversion' 27 | UpdateDownloaded: '&a[ChatEx]&7 Ein neues Update wurde installiert. Es wird beim nächsten Neustart aktiv.' 28 | 29 | -------------------------------------------------------------------------------- /src/main/resources/locales/es-ES.yml: -------------------------------------------------------------------------------- 1 | Commands: 2 | Reload: 3 | Description: Recarga el plugin y su configuración. 4 | Clear: 5 | Description: Borra el chat. 6 | Console: CONSOLE 7 | Unknown: UNKNOWN 8 | Messages: 9 | Commands: 10 | Reload: 11 | Success: '&aLa configuración ha sido recargada.' 12 | Clear: 13 | Success: '&aEl chat ha sido borrado ' 14 | Chat: 15 | AdDetected: '&4[ERROR] &7La publicidad no está permitida! &c(%perm)' 16 | BlockedWord: '&4[ERROR] &7Trataste de usar una palabra que no está permitida!' 17 | AdNotify: "&c%player intentó hacer publicidad. Su mensaje fue: \n&a %message" 18 | NoOneListens: '&cNo hay jugadores lo suficientemente cerca de ti como para verte 19 | hablar. Usa el modo a distancia para charlar.' 20 | CommandResult: 21 | NoPermission: '&4[ERROR] &7No tienes permiso para hacer esto! &c(%perm)' 22 | WrongUsage: '&c[ERROR] &7Sintaxis incorrecta, por favor, usa &6%cmd help&7! para 23 | obtener ayuda' 24 | AntiSpam: 25 | Denied: '&e[AntiSpam] &7Por favor, espera &e%time% &7segundos antes de enviar 26 | otro mensaje!' 27 | Player: 28 | Join: '%prefix%displayname%suffix &ese unió al juego!' 29 | Kick: '%prefix%displayname%suffix &efue expulsado del juego!' 30 | Quit: '%prefix%displayname%suffix &ese fue del juego!' 31 | UpdateFound: '&a[ChatEx]&7 Una nueva actualización fue encontrada en SpigotMC. Versión 32 | actual: %oldversion Nueva versión: %newversion' 33 | -------------------------------------------------------------------------------- /src/main/resources/locales/fr-FR.yml: -------------------------------------------------------------------------------- 1 | Commands: 2 | Reload: 3 | Description: 'Relance le plugin et sa configuration.' 4 | Clear: 5 | Description: 'Efface le chat.' 6 | Console: 'CONSOLE' 7 | Unknown: 'INCONNU' 8 | Messages: 9 | Chat: 10 | AdDetected: '&4Les publicités ne sont pas autorisées ! (%perm)' 11 | Commands: 12 | Reload: 13 | Success: '&aConfiguration rechargée.' 14 | Clear: 15 | Success: '&aLe chat a été effacé par ' 16 | CommandResult: 17 | NoPermission: "&4[ERREUR] &7Vous n'avez pas la permission ! &c(%perm%)" 18 | WrongUsage: '&c[ERREUR] &7Mauvaise utilisation ! Tapez &6%cmd help&7!' 19 | Player: 20 | Join: '%faction %prefix%displayname%suffix &ea rejoint la partie !' 21 | FirstJoin: '%faction %prefix%displayname%suffix &ea rejoint la partie &6pour la première fois !' 22 | Quit: '%faction %prefix%displayname%suffix &ea quitté la partie !' 23 | Kick: '%faction %prefix%displayname%suffix &ea été expulsé de la partie !' 24 | -------------------------------------------------------------------------------- /src/main/resources/locales/ja-JP.yml: -------------------------------------------------------------------------------- 1 | Commands: 2 | Reload: 3 | Description: Pluginと設定を再読み込みします。 4 | Clear: 5 | Description: チャットを削除します。 6 | Console: CONSOLE 7 | Unknown: UNKNOWN 8 | Messages: 9 | Commands: 10 | Reload: 11 | Success: '&a設定が再読み込みされました。' 12 | Clear: 13 | Success: '&aチャットは削除されました。 ' 14 | Chat: 15 | AdDetected: '&4[エラー] &7広告は許可されていません! &c(%perm)' 16 | BlockedWord: '&4[エラー] &7禁止されている単語を使用しようとしました!' 17 | AdNotify: "&c%playerが宣伝しようとしました。宣伝内容:\n&a %message" 18 | NoOneListens: '&c周辺にあなたのチャットが見えるプレイヤーが近くにいません。 19 | 遠隔モードを使用してチャットしてください。' 20 | CommandResult: 21 | NoPermission: '&4[エラー] &7これを実行する許可がありません! &c(%perm)' 22 | WrongUsage: '&c[エラー] &7構文が正しくありません。ヘルプは、&6%cmd help&7 を使用してください!' 23 | AntiSpam: 24 | Denied: '&e[AntiSpam] &7別のメッセージを送信する前に、&e%time%&7 秒待ってください' 25 | Player: 26 | Join: '%prefix%displayname%suffix &eゲームに参加しました!' 27 | Kick: '%prefix%displayname%suffix &eゲームから除外されました!' 28 | Quit: '%prefix%displayname%suffix &eゲームから退出しました!' 29 | UpdateFound: '&a[ChatEx]&7 SpigotMC で新しいアップデートが見つかりました。 30 | 現在のバージョン: %oldversion 最新のバージョン: %newversion' 31 | -------------------------------------------------------------------------------- /src/main/resources/locales/pt-BR.yml: -------------------------------------------------------------------------------- 1 | Commands: 2 | Reload: 3 | Description: Recarrega o plugin e sua configuracao. 4 | Clear: 5 | Description: Limpa o chat. 6 | Console: CONSOLE 7 | Unknown: DESCONHECIDO 8 | Messages: 9 | Commands: 10 | Reload: 11 | Success: '&aConfig foi recarregada.' 12 | Clear: 13 | Success: '&aO chat foi limpo por ' 14 | Chat: 15 | AdDetected: '&4[ERRO] &7Propaganda nao e permitida! &c(%perm)' 16 | AdNotify: "&c%jogador tentou escrever propaganda no chat. Ele/ela escreveu: \n\ 17 | &a %message" 18 | CommandResult: 19 | NoPermission: '&4[ERRO] &7Voce nao tem permissao para isso! &c(%perm)' 20 | WrongUsage: '&c[ERROR] &7Modo errado de usar! Por favor digite &6%cmd help&7!' 21 | Player: 22 | Join: '%prefix%displayname%suffix &eentrou no servidor!' 23 | FirstJoin: '%prefix%displayname%suffix &eentrou no servidor &6pela primeira vez!' 24 | Kick: '%faction %prefix%displayname%suffix &efoi kickado do servidor!' 25 | Quit: '%faction %prefix%displayname%suffix &esaiu do servidor!' 26 | -------------------------------------------------------------------------------- /src/main/resources/locales/ru-RU.yml: -------------------------------------------------------------------------------- 1 | Commands: 2 | Reload: 3 | Description: 'Перезагружает плагин и его конфигурацию.' 4 | Clear: 5 | Description: 'Очищает чат.' 6 | Console: 'Консоль' 7 | Unknown: 'Неизвестно' 8 | Messages: 9 | Chat: 10 | AdDetected: '&f[&4Внимание&f] &7Реклама в чате запрещена! &7(&e%perm&7)' 11 | AdNotify: '&f[&4Внимание&f] &e%player &7пытался рекламировать в чате: &e%message' 12 | BlockedWord: '&f[&4Внимание&f] &7Вам нельзя писать запрещенные слова!' 13 | NoOneListens: '&f[&4Внимание&f] &7Сейчас в локальном чате никого рядом нет! Используй &e! &7знак в начале сообщения для использования глобального чата!' 14 | Commands: 15 | Reload: 16 | Success: '&f[&4Внимание&f] &7ChatEx был перезагружен!' 17 | Clear: 18 | Success: '&f[&4Внимание&f] &7Чат был очищен! ' 19 | CommandResult: 20 | NoPermission: '&f[&4Внимание&f] &7У вас нет прав на это! &7(&e%perm&7)' 21 | WrongUsage: '&f[&4Внимание&f] &7неизвестная команда, используйте: &e%cmd help&7!' 22 | Player: 23 | Join: '%prefix %displayname %suffix &7вошел на сервер!' 24 | Quit: '%prefix %displayname %suffix &7покинул сервер!' 25 | Kick: '%prefix %displayname %suffix &7был кикнут с сервера!' 26 | UpdateFound: '&f[&4Внимание&f] &7Новая версия ChatEx (&e%newversion&7) доступна! У вас установлена: &e%oldversion' 27 | UpdateDownloaded: '&f[&4Внимание&f] &7Обновление ChatEx успешно установлено и будет активно после перезапуска!' 28 | AntiSpam: 29 | Denied: '&f[&4Внимание&f] &eАнтиспам &7заметил массовую рассылку! Перед отправкой следующего сообщения подождите &e%time% &7секунд(ы)!' -------------------------------------------------------------------------------- /src/main/resources/locales/tr-TR.yml: -------------------------------------------------------------------------------- 1 | Commands: 2 | Reload: 3 | Description: 'Eklentiyi ve yapılandırmasını yeniden yükler.' 4 | Clear: 5 | Description: 'Sohbeti boşaltır.' 6 | Console: 'KONSOL' 7 | Unknown: 'BİLİNMEYEN' 8 | Messages: 9 | Chat: 10 | AdDetected: '&4[HATA] &7Reklama izin verilmiyor! &c(%perm)' 11 | AdNotify: "&c%player Bir reklam yazmaya çalıştın: \n&a %message" 12 | BlockedWord: '&4[HATA] &7Yasak bir kelime yazmaya çalıştınız!' 13 | NoOneListens: '&cKimse seni duyamaz! Sohbet etmek için menzilli modu kullanın.' 14 | Commands: 15 | Reload: 16 | Success: '&aChatEx yeniden yüklendi.' 17 | Clear: 18 | Success: '&aSohbet şu kişi tarafından boşaltıldı: ' 19 | CommandResult: 20 | NoPermission: '&4[HATA] &7Bunun için gerekli izinlere sahip değilsiniz! &c(%perm)' 21 | WrongUsage: '&c[HATA] &7 Yanlış kullanım! &6%cmd help&7'i kullan!' 22 | Player: 23 | Join: '%prefix%displayname%suffix &esunucuya girdi!' 24 | Quit: '%prefix%displayname%suffix &esunucudan ayrıldı!' 25 | Kick: '%prefix%displayname%suffix &esunucu tarafından atıldı!' 26 | UpdateFound: '&a[ChatEx]&7 Yeni bir güncelleme yayınlandı. Şimdiki versiyonu: %oldversion Yeni versiyon: %newversion' 27 | UpdateDownloaded: '&a[ChatEx]&7 Yeni bir güncelleme yüklendi. Bir sonraki yeniden başlatmada aktif hale gelecektir.' 28 | 29 | -------------------------------------------------------------------------------- /src/main/resources/locales/zh-CN.yml: -------------------------------------------------------------------------------- 1 | Commands: 2 | Reload: 3 | Description: 重新加载插件和配置文件 4 | Clear: 5 | Description: 清空聊天栏 6 | Console: 控制台 7 | Unknown: 未知 8 | Messages: 9 | Commands: 10 | Reload: 11 | Success: '&a配置文件已重新加载' 12 | Clear: 13 | Success: '&a聊天已被清除,操作者:' 14 | Chat: 15 | AdDetected: '&4[错误] &7禁止发送广告! &c(%perm)' 16 | BlockedWord: '&4[错误] &7你正尝试发送被禁止的文字!' 17 | AdNotify: "&c%player 尝试发送广告信息: \n&a %message" 18 | NoOneListens: '&c附件没有玩家能听到你说话!请使用远程模式聊天。' 19 | CommandResult: 20 | NoPermission: '&4[错误] &7你没有足够的权限执行此操作! &c(%perm)' 21 | WrongUsage: '&c[错误] &7无效的用法,请尝试 &6%cmd help&7!' 22 | AntiSpam: 23 | Denied: '&e[反垃圾信息] &7请不要频繁发送聊天信息,请等待 &e%time% &7秒!' 24 | Player: 25 | Join: '%prefix%displayname%suffix &e加入服务器!' 26 | Kick: '%prefix%displayname%suffix &e被踢出服务器!' 27 | Quit: '%prefix%displayname%suffix &e离开服务器!' 28 | UpdateFound: '&a[ChatEx]&7 在 SpigotMC 发现可用的插件更新。当前版本:%oldversion 新版本:%newversion' 29 | -------------------------------------------------------------------------------- /src/main/resources/plugin.yml: -------------------------------------------------------------------------------- 1 | name: ${project.name} 2 | main: de.jeter.chatex.ChatEx 3 | version: ${project.version} 4 | authors: [ Jeter, Wizard_x ] 5 | description: Chat management plugin 6 | softdepend: [ LuckPerms, Vault, PlaceholderAPI, Essentials ] 7 | api-version: 1.13 8 | 9 | commands: 10 | chatex: 11 | description: ChatEx Plugin commands 12 | 13 | permissions: 14 | chatex.allowchat: 15 | description: Allows chatting 16 | default: true 17 | chatex.chat.global: 18 | description: Is needed to use the global chat (if ranged mode is enabled) or Cross server chat 19 | default: false 20 | chatex.chat.color: 21 | description: Is needed to use color codes with & in chat 22 | default: false 23 | chatex.antispam.bypass: 24 | description: Is needed to bypass the antispam system 25 | default: false 26 | chatex.bypassads: 27 | description: Is needed to bypass the AdBlocker 28 | default: false 29 | chatex.notifyad: 30 | description: Is needed to be messaged when a player tries to advertise. 31 | default: false 32 | chatex.notifyupdate: 33 | description: Is needed to get notiefied about new updates when you join 34 | default: false 35 | chatex.clear: 36 | description: Is needed to use /chatex clear to clear the chat 37 | default: op 38 | chatex.reload: 39 | description: Is needed to use /chatex reload to reload the config and messages of chatex. 40 | default: op 41 | --------------------------------------------------------------------------------