├── .github └── workflows │ └── maven-build.yml ├── .gitignore ├── LICENSE ├── README.md ├── pom.xml └── src └── main ├── java └── me │ └── jaden │ └── titanium │ ├── Titanium.java │ ├── check │ ├── BaseCheck.java │ ├── Check.java │ ├── CheckManager.java │ └── impl │ │ ├── book │ │ ├── Book.java │ │ └── MassiveBook.java │ │ ├── command │ │ └── BlockedCommand.java │ │ ├── crasher │ │ ├── BandwidthLimit.java │ │ ├── Lectern.java │ │ ├── Log4J.java │ │ └── PacketSize.java │ │ ├── creative │ │ ├── ItemCheck.java │ │ ├── ItemCheckRunner.java │ │ └── impl │ │ │ ├── CreativeAnvil.java │ │ │ ├── CreativeClientBookCrash.java │ │ │ ├── CreativeMap.java │ │ │ ├── CreativeSkull.java │ │ │ ├── EnchantLimit.java │ │ │ └── PotionLimit.java │ │ ├── firework │ │ └── FireworkSize.java │ │ ├── invalid │ │ ├── ChannelCount.java │ │ ├── ImpossiblePacket.java │ │ ├── InvalidMove.java │ │ ├── InvalidPickItem.java │ │ ├── InvalidSlotChange.java │ │ └── InvalidViewDistance.java │ │ ├── sign │ │ └── SignLength.java │ │ └── spam │ │ ├── BookSpam.java │ │ ├── CraftSpam.java │ │ ├── DropSpam.java │ │ └── PacketCount.java │ ├── command │ └── TitaniumCommand.java │ ├── data │ ├── DataManager.java │ └── PlayerData.java │ ├── listener │ └── BukkitJoinListener.java │ ├── settings │ ├── CreativeConfig.java │ ├── MessagesConfig.java │ ├── PermissionsConfig.java │ └── TitaniumConfig.java │ └── util │ └── Ticker.java └── resources ├── config.yml └── plugin.yml /.github/workflows/maven-build.yml: -------------------------------------------------------------------------------- 1 | # This workflow will build a package using Maven and then publish it to GitHub packages when a release is created 2 | # For more information see: https://github.com/actions/setup-java/blob/main/docs/advanced-usage.md#apache-maven-with-a-settings-path 3 | 4 | name: build 5 | on: [pull_request, push] 6 | 7 | jobs: 8 | build: 9 | strategy: 10 | matrix: 11 | # Use these Java versions 12 | java: [8] 13 | # and run on both Linux and Windows 14 | os: [ubuntu-20.04] 15 | runs-on: ${{ matrix.os }} 16 | 17 | steps: 18 | - name: Checkout 19 | uses: actions/checkout@v3 20 | - name: Set up JDK ${{ matrix.java }} 21 | uses: actions/setup-java@v3 22 | with: 23 | java-version: ${{ matrix.java }} 24 | distribution: 'adopt' 25 | 26 | - name: Build with Maven 27 | run: mvn install 28 | 29 | - name: Publish to GitHub Actions 30 | uses: actions/upload-artifact@v2 31 | with: 32 | name: Artifact 33 | path: target/Titanium.jar 34 | 35 | - name: Get Commit Hash 36 | id: hash_commit 37 | uses: pr-mpt/actions-commit-hash@v2 38 | 39 | - name: Create Draft Release 40 | id: create_release 41 | uses: actions/create-release@v1 42 | env: 43 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 44 | with: 45 | tag_name: ${{ steps.hash_commit.outputs.short }} 46 | release_name: Auto Release 47 | 48 | draft: true 49 | prerelease: false 50 | 51 | - uses: actions/upload-release-asset@v1.0.1 52 | env: 53 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 54 | with: 55 | upload_url: ${{ steps.create_release.outputs.upload_url }} 56 | asset_path: target/Titanium.jar 57 | asset_name: Titanium.jar 58 | asset_content_type: application/zip 59 | 60 | - uses: eregon/publish-release@v1 61 | env: 62 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 63 | with: 64 | release_id: ${{ steps.create_release.outputs.id }} 65 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # User-specific stuff 2 | .idea/ 3 | 4 | *.iml 5 | *.ipr 6 | *.iws 7 | 8 | # IntelliJ 9 | out/ 10 | 11 | # Compiled class file 12 | *.class 13 | 14 | # Log file 15 | *.log 16 | 17 | # BlueJ files 18 | *.ctxt 19 | 20 | # Package Files # 21 | *.jar 22 | *.war 23 | *.nar 24 | *.ear 25 | *.zip 26 | *.tar.gz 27 | *.rar 28 | 29 | # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml 30 | hs_err_pid* 31 | 32 | *~ 33 | 34 | # temporary files which can be created if a process still has a handle open of a deleted file 35 | .fuse_hidden* 36 | 37 | # KDE directory preferences 38 | .directory 39 | 40 | # Linux trash folder which might appear on any partition or disk 41 | .Trash-* 42 | 43 | # .nfs files are created when an open file is removed but is still being accessed 44 | .nfs* 45 | 46 | # General 47 | .DS_Store 48 | .AppleDouble 49 | .LSOverride 50 | 51 | # Icon must end with two \r 52 | Icon 53 | 54 | # Thumbnails 55 | ._* 56 | 57 | # Files that might appear in the root of a volume 58 | .DocumentRevisions-V100 59 | .fseventsd 60 | .Spotlight-V100 61 | .TemporaryItems 62 | .Trashes 63 | .VolumeIcon.icns 64 | .com.apple.timemachine.donotpresent 65 | 66 | # Directories potentially created on remote AFP share 67 | .AppleDB 68 | .AppleDesktop 69 | Network Trash Folder 70 | Temporary Items 71 | .apdisk 72 | 73 | # Windows thumbnail cache files 74 | Thumbs.db 75 | Thumbs.db:encryptable 76 | ehthumbs.db 77 | ehthumbs_vista.db 78 | 79 | # Dump file 80 | *.stackdump 81 | 82 | # Folder config file 83 | [Dd]esktop.ini 84 | 85 | # Recycle Bin used on file shares 86 | $RECYCLE.BIN/ 87 | 88 | # Windows Installer files 89 | *.cab 90 | *.msi 91 | *.msix 92 | *.msm 93 | *.msp 94 | 95 | # Windows shortcuts 96 | *.lnk 97 | 98 | target/ 99 | 100 | pom.xml.tag 101 | pom.xml.releaseBackup 102 | pom.xml.versionsBackup 103 | pom.xml.next 104 | 105 | release.properties 106 | dependency-reduced-pom.xml 107 | buildNumber.properties 108 | .mvn/timing.properties 109 | .mvn/wrapper/maven-wrapper.jar 110 | .flattened-pom.xml 111 | 112 | # Common working directory 113 | run/ 114 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 3, 29 June 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | Preamble 9 | 10 | The GNU General Public License is a free, copyleft license for 11 | software and other kinds of works. 12 | 13 | The licenses for most software and other practical works are designed 14 | to take away your freedom to share and change the works. By contrast, 15 | the GNU General Public License is intended to guarantee your freedom to 16 | share and change all versions of a program--to make sure it remains free 17 | software for all its users. We, the Free Software Foundation, use the 18 | GNU General Public License for most of our software; it applies also to 19 | any other work released this way by its authors. You can apply it to 20 | your programs, too. 21 | 22 | When we speak of free software, we are referring to freedom, not 23 | price. Our General Public Licenses are designed to make sure that you 24 | have the freedom to distribute copies of free software (and charge for 25 | them if you wish), that you receive source code or can get it if you 26 | want it, that you can change the software or use pieces of it in new 27 | free programs, and that you know you can do these things. 28 | 29 | To protect your rights, we need to prevent others from denying you 30 | these rights or asking you to surrender the rights. Therefore, you have 31 | certain responsibilities if you distribute copies of the software, or if 32 | you modify it: responsibilities to respect the freedom of others. 33 | 34 | For example, if you distribute copies of such a program, whether 35 | gratis or for a fee, you must pass on to the recipients the same 36 | freedoms that you received. You must make sure that they, too, receive 37 | or can get the source code. And you must show them these terms so they 38 | know their rights. 39 | 40 | Developers that use the GNU GPL protect your rights with two steps: 41 | (1) assert copyright on the software, and (2) offer you this License 42 | giving you legal permission to copy, distribute and/or modify it. 43 | 44 | For the developers' and authors' protection, the GPL clearly explains 45 | that there is no warranty for this free software. For both users' and 46 | authors' sake, the GPL requires that modified versions be marked as 47 | changed, so that their problems will not be attributed erroneously to 48 | authors of previous versions. 49 | 50 | Some devices are designed to deny users access to install or run 51 | modified versions of the software inside them, although the manufacturer 52 | can do so. This is fundamentally incompatible with the aim of 53 | protecting users' freedom to change the software. The systematic 54 | pattern of such abuse occurs in the area of products for individuals to 55 | use, which is precisely where it is most unacceptable. Therefore, we 56 | have designed this version of the GPL to prohibit the practice for those 57 | products. If such problems arise substantially in other domains, we 58 | stand ready to extend this provision to those domains in future versions 59 | of the GPL, as needed to protect the freedom of users. 60 | 61 | Finally, every program is threatened constantly by software patents. 62 | States should not allow patents to restrict development and use of 63 | software on general-purpose computers, but in those that do, we wish to 64 | avoid the special danger that patents applied to a free program could 65 | make it effectively proprietary. To prevent this, the GPL assures that 66 | patents cannot be used to render the program non-free. 67 | 68 | The precise terms and conditions for copying, distribution and 69 | modification follow. 70 | 71 | TERMS AND CONDITIONS 72 | 73 | 0. Definitions. 74 | 75 | "This License" refers to version 3 of the GNU General Public License. 76 | 77 | "Copyright" also means copyright-like laws that apply to other kinds of 78 | works, such as semiconductor masks. 79 | 80 | "The Program" refers to any copyrightable work licensed under this 81 | License. Each licensee is addressed as "you". "Licensees" and 82 | "recipients" may be individuals or organizations. 83 | 84 | To "modify" a work means to copy from or adapt all or part of the work 85 | in a fashion requiring copyright permission, other than the making of an 86 | exact copy. The resulting work is called a "modified version" of the 87 | earlier work or a work "based on" the earlier work. 88 | 89 | A "covered work" means either the unmodified Program or a work based 90 | on the Program. 91 | 92 | To "propagate" a work means to do anything with it that, without 93 | permission, would make you directly or secondarily liable for 94 | infringement under applicable copyright law, except executing it on a 95 | computer or modifying a private copy. Propagation includes copying, 96 | distribution (with or without modification), making available to the 97 | public, and in some countries other activities as well. 98 | 99 | To "convey" a work means any kind of propagation that enables other 100 | parties to make or receive copies. Mere interaction with a user through 101 | a computer network, with no transfer of a copy, is not conveying. 102 | 103 | An interactive user interface displays "Appropriate Legal Notices" 104 | to the extent that it includes a convenient and prominently visible 105 | feature that (1) displays an appropriate copyright notice, and (2) 106 | tells the user that there is no warranty for the work (except to the 107 | extent that warranties are provided), that licensees may convey the 108 | work under this License, and how to view a copy of this License. If 109 | the interface presents a list of user commands or options, such as a 110 | menu, a prominent item in the list meets this criterion. 111 | 112 | 1. Source Code. 113 | 114 | The "source code" for a work means the preferred form of the work 115 | for making modifications to it. "Object code" means any non-source 116 | form of a work. 117 | 118 | A "Standard Interface" means an interface that either is an official 119 | standard defined by a recognized standards body, or, in the case of 120 | interfaces specified for a particular programming language, one that 121 | is widely used among developers working in that language. 122 | 123 | The "System Libraries" of an executable work include anything, other 124 | than the work as a whole, that (a) is included in the normal form of 125 | packaging a Major Component, but which is not part of that Major 126 | Component, and (b) serves only to enable use of the work with that 127 | Major Component, or to implement a Standard Interface for which an 128 | implementation is available to the public in source code form. A 129 | "Major Component", in this context, means a major essential component 130 | (kernel, window system, and so on) of the specific operating system 131 | (if any) on which the executable work runs, or a compiler used to 132 | produce the work, or an object code interpreter used to run it. 133 | 134 | The "Corresponding Source" for a work in object code form means all 135 | the source code needed to generate, install, and (for an executable 136 | work) run the object code and to modify the work, including scripts to 137 | control those activities. However, it does not include the work's 138 | System Libraries, or general-purpose tools or generally available free 139 | programs which are used unmodified in performing those activities but 140 | which are not part of the work. For example, Corresponding Source 141 | includes interface definition files associated with source files for 142 | the work, and the source code for shared libraries and dynamically 143 | linked subprograms that the work is specifically designed to require, 144 | such as by intimate data communication or control flow between those 145 | subprograms and other parts of the work. 146 | 147 | The Corresponding Source need not include anything that users 148 | can regenerate automatically from other parts of the Corresponding 149 | Source. 150 | 151 | The Corresponding Source for a work in source code form is that 152 | same work. 153 | 154 | 2. Basic Permissions. 155 | 156 | All rights granted under this License are granted for the term of 157 | copyright on the Program, and are irrevocable provided the stated 158 | conditions are met. This License explicitly affirms your unlimited 159 | permission to run the unmodified Program. The output from running a 160 | covered work is covered by this License only if the output, given its 161 | content, constitutes a covered work. This License acknowledges your 162 | rights of fair use or other equivalent, as provided by copyright law. 163 | 164 | You may make, run and propagate covered works that you do not 165 | convey, without conditions so long as your license otherwise remains 166 | in force. You may convey covered works to others for the sole purpose 167 | of having them make modifications exclusively for you, or provide you 168 | with facilities for running those works, provided that you comply with 169 | the terms of this License in conveying all material for which you do 170 | not control copyright. Those thus making or running the covered works 171 | for you must do so exclusively on your behalf, under your direction 172 | and control, on terms that prohibit them from making any copies of 173 | your copyrighted material outside their relationship with you. 174 | 175 | Conveying under any other circumstances is permitted solely under 176 | the conditions stated below. Sublicensing is not allowed; section 10 177 | makes it unnecessary. 178 | 179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 180 | 181 | No covered work shall be deemed part of an effective technological 182 | measure under any applicable law fulfilling obligations under article 183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 184 | similar laws prohibiting or restricting circumvention of such 185 | measures. 186 | 187 | When you convey a covered work, you waive any legal power to forbid 188 | circumvention of technological measures to the extent such circumvention 189 | is effected by exercising rights under this License with respect to 190 | the covered work, and you disclaim any intention to limit operation or 191 | modification of the work as a means of enforcing, against the work's 192 | users, your or third parties' legal rights to forbid circumvention of 193 | technological measures. 194 | 195 | 4. Conveying Verbatim Copies. 196 | 197 | You may convey verbatim copies of the Program's source code as you 198 | receive it, in any medium, provided that you conspicuously and 199 | appropriately publish on each copy an appropriate copyright notice; 200 | keep intact all notices stating that this License and any 201 | non-permissive terms added in accord with section 7 apply to the code; 202 | keep intact all notices of the absence of any warranty; and give all 203 | recipients a copy of this License along with the Program. 204 | 205 | You may charge any price or no price for each copy that you convey, 206 | and you may offer support or warranty protection for a fee. 207 | 208 | 5. Conveying Modified Source Versions. 209 | 210 | You may convey a work based on the Program, or the modifications to 211 | produce it from the Program, in the form of source code under the 212 | terms of section 4, provided that you also meet all of these conditions: 213 | 214 | a) The work must carry prominent notices stating that you modified 215 | it, and giving a relevant date. 216 | 217 | b) The work must carry prominent notices stating that it is 218 | released under this License and any conditions added under section 219 | 7. This requirement modifies the requirement in section 4 to 220 | "keep intact all notices". 221 | 222 | c) You must license the entire work, as a whole, under this 223 | License to anyone who comes into possession of a copy. This 224 | License will therefore apply, along with any applicable section 7 225 | additional terms, to the whole of the work, and all its parts, 226 | regardless of how they are packaged. This License gives no 227 | permission to license the work in any other way, but it does not 228 | invalidate such permission if you have separately received it. 229 | 230 | d) If the work has interactive user interfaces, each must display 231 | Appropriate Legal Notices; however, if the Program has interactive 232 | interfaces that do not display Appropriate Legal Notices, your 233 | work need not make them do so. 234 | 235 | A compilation of a covered work with other separate and independent 236 | works, which are not by their nature extensions of the covered work, 237 | and which are not combined with it such as to form a larger program, 238 | in or on a volume of a storage or distribution medium, is called an 239 | "aggregate" if the compilation and its resulting copyright are not 240 | used to limit the access or legal rights of the compilation's users 241 | beyond what the individual works permit. Inclusion of a covered work 242 | in an aggregate does not cause this License to apply to the other 243 | parts of the aggregate. 244 | 245 | 6. Conveying Non-Source Forms. 246 | 247 | You may convey a covered work in object code form under the terms 248 | of sections 4 and 5, provided that you also convey the 249 | machine-readable Corresponding Source under the terms of this License, 250 | in one of these ways: 251 | 252 | a) Convey the object code in, or embodied in, a physical product 253 | (including a physical distribution medium), accompanied by the 254 | Corresponding Source fixed on a durable physical medium 255 | customarily used for software interchange. 256 | 257 | b) Convey the object code in, or embodied in, a physical product 258 | (including a physical distribution medium), accompanied by a 259 | written offer, valid for at least three years and valid for as 260 | long as you offer spare parts or customer support for that product 261 | model, to give anyone who possesses the object code either (1) a 262 | copy of the Corresponding Source for all the software in the 263 | product that is covered by this License, on a durable physical 264 | medium customarily used for software interchange, for a price no 265 | more than your reasonable cost of physically performing this 266 | conveying of source, or (2) access to copy the 267 | Corresponding Source from a network server at no charge. 268 | 269 | c) Convey individual copies of the object code with a copy of the 270 | written offer to provide the Corresponding Source. This 271 | alternative is allowed only occasionally and noncommercially, and 272 | only if you received the object code with such an offer, in accord 273 | with subsection 6b. 274 | 275 | d) Convey the object code by offering access from a designated 276 | place (gratis or for a charge), and offer equivalent access to the 277 | Corresponding Source in the same way through the same place at no 278 | further charge. You need not require recipients to copy the 279 | Corresponding Source along with the object code. If the place to 280 | copy the object code is a network server, the Corresponding Source 281 | may be on a different server (operated by you or a third party) 282 | that supports equivalent copying facilities, provided you maintain 283 | clear directions next to the object code saying where to find the 284 | Corresponding Source. Regardless of what server hosts the 285 | Corresponding Source, you remain obligated to ensure that it is 286 | available for as long as needed to satisfy these requirements. 287 | 288 | e) Convey the object code using peer-to-peer transmission, provided 289 | you inform other peers where the object code and Corresponding 290 | Source of the work are being offered to the general public at no 291 | charge under subsection 6d. 292 | 293 | A separable portion of the object code, whose source code is excluded 294 | from the Corresponding Source as a System Library, need not be 295 | included in conveying the object code work. 296 | 297 | A "User Product" is either (1) a "consumer product", which means any 298 | tangible personal property which is normally used for personal, family, 299 | or household purposes, or (2) anything designed or sold for incorporation 300 | into a dwelling. In determining whether a product is a consumer product, 301 | doubtful cases shall be resolved in favor of coverage. For a particular 302 | product received by a particular user, "normally used" refers to a 303 | typical or common use of that class of product, regardless of the status 304 | of the particular user or of the way in which the particular user 305 | actually uses, or expects or is expected to use, the product. A product 306 | is a consumer product regardless of whether the product has substantial 307 | commercial, industrial or non-consumer uses, unless such uses represent 308 | the only significant mode of use of the product. 309 | 310 | "Installation Information" for a User Product means any methods, 311 | procedures, authorization keys, or other information required to install 312 | and execute modified versions of a covered work in that User Product from 313 | a modified version of its Corresponding Source. The information must 314 | suffice to ensure that the continued functioning of the modified object 315 | code is in no case prevented or interfered with solely because 316 | modification has been made. 317 | 318 | If you convey an object code work under this section in, or with, or 319 | specifically for use in, a User Product, and the conveying occurs as 320 | part of a transaction in which the right of possession and use of the 321 | User Product is transferred to the recipient in perpetuity or for a 322 | fixed term (regardless of how the transaction is characterized), the 323 | Corresponding Source conveyed under this section must be accompanied 324 | by the Installation Information. But this requirement does not apply 325 | if neither you nor any third party retains the ability to install 326 | modified object code on the User Product (for example, the work has 327 | been installed in ROM). 328 | 329 | The requirement to provide Installation Information does not include a 330 | requirement to continue to provide support service, warranty, or updates 331 | for a work that has been modified or installed by the recipient, or for 332 | the User Product in which it has been modified or installed. Access to a 333 | network may be denied when the modification itself materially and 334 | adversely affects the operation of the network or violates the rules and 335 | protocols for communication across the network. 336 | 337 | Corresponding Source conveyed, and Installation Information provided, 338 | in accord with this section must be in a format that is publicly 339 | documented (and with an implementation available to the public in 340 | source code form), and must require no special password or key for 341 | unpacking, reading or copying. 342 | 343 | 7. Additional Terms. 344 | 345 | "Additional permissions" are terms that supplement the terms of this 346 | License by making exceptions from one or more of its conditions. 347 | Additional permissions that are applicable to the entire Program shall 348 | be treated as though they were included in this License, to the extent 349 | that they are valid under applicable law. If additional permissions 350 | apply only to part of the Program, that part may be used separately 351 | under those permissions, but the entire Program remains governed by 352 | this License without regard to the additional permissions. 353 | 354 | When you convey a copy of a covered work, you may at your option 355 | remove any additional permissions from that copy, or from any part of 356 | it. (Additional permissions may be written to require their own 357 | removal in certain cases when you modify the work.) You may place 358 | additional permissions on material, added by you to a covered work, 359 | for which you have or can give appropriate copyright permission. 360 | 361 | Notwithstanding any other provision of this License, for material you 362 | add to a covered work, you may (if authorized by the copyright holders of 363 | that material) supplement the terms of this License with terms: 364 | 365 | a) Disclaiming warranty or limiting liability differently from the 366 | terms of sections 15 and 16 of this License; or 367 | 368 | b) Requiring preservation of specified reasonable legal notices or 369 | author attributions in that material or in the Appropriate Legal 370 | Notices displayed by works containing it; or 371 | 372 | c) Prohibiting misrepresentation of the origin of that material, or 373 | requiring that modified versions of such material be marked in 374 | reasonable ways as different from the original version; or 375 | 376 | d) Limiting the use for publicity purposes of names of licensors or 377 | authors of the material; or 378 | 379 | e) Declining to grant rights under trademark law for use of some 380 | trade names, trademarks, or service marks; or 381 | 382 | f) Requiring indemnification of licensors and authors of that 383 | material by anyone who conveys the material (or modified versions of 384 | it) with contractual assumptions of liability to the recipient, for 385 | any liability that these contractual assumptions directly impose on 386 | those licensors and authors. 387 | 388 | All other non-permissive additional terms are considered "further 389 | restrictions" within the meaning of section 10. If the Program as you 390 | received it, or any part of it, contains a notice stating that it is 391 | governed by this License along with a term that is a further 392 | restriction, you may remove that term. If a license document contains 393 | a further restriction but permits relicensing or conveying under this 394 | License, you may add to a covered work material governed by the terms 395 | of that license document, provided that the further restriction does 396 | not survive such relicensing or conveying. 397 | 398 | If you add terms to a covered work in accord with this section, you 399 | must place, in the relevant source files, a statement of the 400 | additional terms that apply to those files, or a notice indicating 401 | where to find the applicable terms. 402 | 403 | Additional terms, permissive or non-permissive, may be stated in the 404 | form of a separately written license, or stated as exceptions; 405 | the above requirements apply either way. 406 | 407 | 8. Termination. 408 | 409 | You may not propagate or modify a covered work except as expressly 410 | provided under this License. Any attempt otherwise to propagate or 411 | modify it is void, and will automatically terminate your rights under 412 | this License (including any patent licenses granted under the third 413 | paragraph of section 11). 414 | 415 | However, if you cease all violation of this License, then your 416 | license from a particular copyright holder is reinstated (a) 417 | provisionally, unless and until the copyright holder explicitly and 418 | finally terminates your license, and (b) permanently, if the copyright 419 | holder fails to notify you of the violation by some reasonable means 420 | prior to 60 days after the cessation. 421 | 422 | Moreover, your license from a particular copyright holder is 423 | reinstated permanently if the copyright holder notifies you of the 424 | violation by some reasonable means, this is the first time you have 425 | received notice of violation of this License (for any work) from that 426 | copyright holder, and you cure the violation prior to 30 days after 427 | your receipt of the notice. 428 | 429 | Termination of your rights under this section does not terminate the 430 | licenses of parties who have received copies or rights from you under 431 | this License. If your rights have been terminated and not permanently 432 | reinstated, you do not qualify to receive new licenses for the same 433 | material under section 10. 434 | 435 | 9. Acceptance Not Required for Having Copies. 436 | 437 | You are not required to accept this License in order to receive or 438 | run a copy of the Program. Ancillary propagation of a covered work 439 | occurring solely as a consequence of using peer-to-peer transmission 440 | to receive a copy likewise does not require acceptance. However, 441 | nothing other than this License grants you permission to propagate or 442 | modify any covered work. These actions infringe copyright if you do 443 | not accept this License. Therefore, by modifying or propagating a 444 | covered work, you indicate your acceptance of this License to do so. 445 | 446 | 10. Automatic Licensing of Downstream Recipients. 447 | 448 | Each time you convey a covered work, the recipient automatically 449 | receives a license from the original licensors, to run, modify and 450 | propagate that work, subject to this License. You are not responsible 451 | for enforcing compliance by third parties with this License. 452 | 453 | An "entity transaction" is a transaction transferring control of an 454 | organization, or substantially all assets of one, or subdividing an 455 | organization, or merging organizations. If propagation of a covered 456 | work results from an entity transaction, each party to that 457 | transaction who receives a copy of the work also receives whatever 458 | licenses to the work the party's predecessor in interest had or could 459 | give under the previous paragraph, plus a right to possession of the 460 | Corresponding Source of the work from the predecessor in interest, if 461 | the predecessor has it or can get it with reasonable efforts. 462 | 463 | You may not impose any further restrictions on the exercise of the 464 | rights granted or affirmed under this License. For example, you may 465 | not impose a license fee, royalty, or other charge for exercise of 466 | rights granted under this License, and you may not initiate litigation 467 | (including a cross-claim or counterclaim in a lawsuit) alleging that 468 | any patent claim is infringed by making, using, selling, offering for 469 | sale, or importing the Program or any portion of it. 470 | 471 | 11. Patents. 472 | 473 | A "contributor" is a copyright holder who authorizes use under this 474 | License of the Program or a work on which the Program is based. The 475 | work thus licensed is called the contributor's "contributor version". 476 | 477 | A contributor's "essential patent claims" are all patent claims 478 | owned or controlled by the contributor, whether already acquired or 479 | hereafter acquired, that would be infringed by some manner, permitted 480 | by this License, of making, using, or selling its contributor version, 481 | but do not include claims that would be infringed only as a 482 | consequence of further modification of the contributor version. For 483 | purposes of this definition, "control" includes the right to grant 484 | patent sublicenses in a manner consistent with the requirements of 485 | this License. 486 | 487 | Each contributor grants you a non-exclusive, worldwide, royalty-free 488 | patent license under the contributor's essential patent claims, to 489 | make, use, sell, offer for sale, import and otherwise run, modify and 490 | propagate the contents of its contributor version. 491 | 492 | In the following three paragraphs, a "patent license" is any express 493 | agreement or commitment, however denominated, not to enforce a patent 494 | (such as an express permission to practice a patent or covenant not to 495 | sue for patent infringement). To "grant" such a patent license to a 496 | party means to make such an agreement or commitment not to enforce a 497 | patent against the party. 498 | 499 | If you convey a covered work, knowingly relying on a patent license, 500 | and the Corresponding Source of the work is not available for anyone 501 | to copy, free of charge and under the terms of this License, through a 502 | publicly available network server or other readily accessible means, 503 | then you must either (1) cause the Corresponding Source to be so 504 | available, or (2) arrange to deprive yourself of the benefit of the 505 | patent license for this particular work, or (3) arrange, in a manner 506 | consistent with the requirements of this License, to extend the patent 507 | license to downstream recipients. "Knowingly relying" means you have 508 | actual knowledge that, but for the patent license, your conveying the 509 | covered work in a country, or your recipient's use of the covered work 510 | in a country, would infringe one or more identifiable patents in that 511 | country that you have reason to believe are valid. 512 | 513 | If, pursuant to or in connection with a single transaction or 514 | arrangement, you convey, or propagate by procuring conveyance of, a 515 | covered work, and grant a patent license to some of the parties 516 | receiving the covered work authorizing them to use, propagate, modify 517 | or convey a specific copy of the covered work, then the patent license 518 | you grant is automatically extended to all recipients of the covered 519 | work and works based on it. 520 | 521 | A patent license is "discriminatory" if it does not include within 522 | the scope of its coverage, prohibits the exercise of, or is 523 | conditioned on the non-exercise of one or more of the rights that are 524 | specifically granted under this License. You may not convey a covered 525 | work if you are a party to an arrangement with a third party that is 526 | in the business of distributing software, under which you make payment 527 | to the third party based on the extent of your activity of conveying 528 | the work, and under which the third party grants, to any of the 529 | parties who would receive the covered work from you, a discriminatory 530 | patent license (a) in connection with copies of the covered work 531 | conveyed by you (or copies made from those copies), or (b) primarily 532 | for and in connection with specific products or compilations that 533 | contain the covered work, unless you entered into that arrangement, 534 | or that patent license was granted, prior to 28 March 2007. 535 | 536 | Nothing in this License shall be construed as excluding or limiting 537 | any implied license or other defenses to infringement that may 538 | otherwise be available to you under applicable patent law. 539 | 540 | 12. No Surrender of Others' Freedom. 541 | 542 | If conditions are imposed on you (whether by court order, agreement or 543 | otherwise) that contradict the conditions of this License, they do not 544 | excuse you from the conditions of this License. If you cannot convey a 545 | covered work so as to satisfy simultaneously your obligations under this 546 | License and any other pertinent obligations, then as a consequence you may 547 | not convey it at all. For example, if you agree to terms that obligate you 548 | to collect a royalty for further conveying from those to whom you convey 549 | the Program, the only way you could satisfy both those terms and this 550 | License would be to refrain entirely from conveying the Program. 551 | 552 | 13. Use with the GNU Affero General Public License. 553 | 554 | Notwithstanding any other provision of this License, you have 555 | permission to link or combine any covered work with a work licensed 556 | under version 3 of the GNU Affero General Public License into a single 557 | combined work, and to convey the resulting work. The terms of this 558 | License will continue to apply to the part which is the covered work, 559 | but the special requirements of the GNU Affero General Public License, 560 | section 13, concerning interaction through a network will apply to the 561 | combination as such. 562 | 563 | 14. Revised Versions of this License. 564 | 565 | The Free Software Foundation may publish revised and/or new versions of 566 | the GNU General Public License from time to time. Such new versions will 567 | be similar in spirit to the present version, but may differ in detail to 568 | address new problems or concerns. 569 | 570 | Each version is given a distinguishing version number. If the 571 | Program specifies that a certain numbered version of the GNU General 572 | Public License "or any later version" applies to it, you have the 573 | option of following the terms and conditions either of that numbered 574 | version or of any later version published by the Free Software 575 | Foundation. If the Program does not specify a version number of the 576 | GNU General Public License, you may choose any version ever published 577 | by the Free Software Foundation. 578 | 579 | If the Program specifies that a proxy can decide which future 580 | versions of the GNU General Public License can be used, that proxy's 581 | public statement of acceptance of a version permanently authorizes you 582 | to choose that version for the Program. 583 | 584 | Later license versions may give you additional or different 585 | permissions. However, no additional obligations are imposed on any 586 | author or copyright holder as a result of your choosing to follow a 587 | later version. 588 | 589 | 15. Disclaimer of Warranty. 590 | 591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 599 | 600 | 16. Limitation of Liability. 601 | 602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 610 | SUCH DAMAGES. 611 | 612 | 17. Interpretation of Sections 15 and 16. 613 | 614 | If the disclaimer of warranty and limitation of liability provided 615 | above cannot be given local legal effect according to their terms, 616 | reviewing courts shall apply local law that most closely approximates 617 | an absolute waiver of all civil liability in connection with the 618 | Program, unless a warranty or assumption of liability accompanies a 619 | copy of the Program in return for a fee. 620 | 621 | END OF TERMS AND CONDITIONS 622 | 623 | How to Apply These Terms to Your New Programs 624 | 625 | If you develop a new program, and you want it to be of the greatest 626 | possible use to the public, the best way to achieve this is to make it 627 | free software which everyone can redistribute and change under these terms. 628 | 629 | To do so, attach the following notices to the program. It is safest 630 | to attach them to the start of each source file to most effectively 631 | state the exclusion of warranty; and each file should have at least 632 | the "copyright" line and a pointer to where the full notice is found. 633 | 634 | 635 | Copyright (C) 636 | 637 | This program is free software: you can redistribute it and/or modify 638 | it under the terms of the GNU General Public License as published by 639 | the Free Software Foundation, either version 3 of the License, or 640 | (at your option) any later version. 641 | 642 | This program is distributed in the hope that it will be useful, 643 | but WITHOUT ANY WARRANTY; without even the implied warranty of 644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 645 | GNU General Public License for more details. 646 | 647 | You should have received a copy of the GNU General Public License 648 | along with this program. If not, see . 649 | 650 | Also add information on how to contact you by electronic and paper mail. 651 | 652 | If the program does terminal interaction, make it output a short 653 | notice like this when it starts in an interactive mode: 654 | 655 | Copyright (C) 656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 657 | This is free software, and you are welcome to redistribute it 658 | under certain conditions; type `show c' for details. 659 | 660 | The hypothetical commands `show w' and `show c' should show the appropriate 661 | parts of the General Public License. Of course, your program's commands 662 | might be different; for a GUI interface, you would use an "about box". 663 | 664 | You should also get your employer (if you work as a programmer) or school, 665 | if any, to sign a "copyright disclaimer" for the program, if necessary. 666 | For more information on this, and how to apply and follow the GNU GPL, see 667 | . 668 | 669 | The GNU General Public License does not permit incorporating your program 670 | into proprietary programs. If your program is a subroutine library, you 671 | may consider it more useful to permit linking proprietary applications with 672 | the library. If this is what you want to do, use the GNU Lesser General 673 | Public License instead of this License. But first, please read 674 | . 675 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 |
2 | 9 | 10 | 11 | 12 | 13 | 20 | [![Contributors][contributors-shield]][contributors-url] 21 | [![Forks][forks-shield]][forks-url] 22 | [![Stargazers][stars-shield]][stars-url] 23 | [![Issues][issues-shield]][issues-url] 24 | 25 | 26 | 27 | 32 | 33 |

Titanium

34 | 35 |

36 | Titanium is a plugin meant to block harmful packets before they're received by the Minecraft packet handler. 37 |
38 | Report Bug 39 | · 40 | Request Feature 41 |

42 | 43 | 44 | 45 | 46 | 47 |
48 | Table of Contents 49 |
    50 |
  1. 51 | About The Project 52 | 55 |
  2. 56 |
  3. 57 | Getting Started 58 | 62 |
  4. 63 |
  5. Contributing
  6. 64 |
  7. License
  8. 65 |
  9. Contact
  10. 66 |
67 |
68 | 69 | 70 | 71 | 72 | ## About The Project 73 | 74 | ### Built With 75 | 76 | * [JDK 17](https://www.oracle.com/java/technologies/javase/jdk17-archive-downloads.html) 77 | * [PacketEvents 2.0](https://github.com/retrooper/packetevents/tree/2.0) 78 | 79 |

(back to top)

80 | 81 | 82 | 83 | 84 | ## Getting Started 85 | 86 | To get Titanium up and running on your server follow these simple steps. 87 | 88 | ### Prerequisites 89 | Titanium supports Spigot 1.8.8 - Latest (1.19). It requires the latest development builds of [ViaVersion](https://ci.viaversion.com/job/ViaVersion-DEV/) and [ProtocolLib 5.0](https://ci.dmulloy2.net/job/ProtocolLib/com.comphenix.protocol$ProtocolLib/) 90 | if you're using either of those plugins. 91 | 92 | ### Installation 93 | 94 | 1. Get the latest version from [releases](https://github.com/ilovefuud/Titanium/releases) 95 | 2. Put the file in your Spigot/Paper server's plugin folder. 96 | 3. Start your server to load the default config. 97 | 4. Modify the config to your preferences, although the default config will work for 99% of servers. 98 | 5. Your all set! Make sure you have the permission "titanium.notification" in order to receive crash alerts! 99 | 100 |

(back to top)

101 | 102 | 103 | 104 | 105 | ## Contributing 106 | 107 | Contributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are **greatly appreciated**. 108 | 109 | If you have a suggestion that would make this better, please fork the repo and create a pull request. You can also simply open an issue with the tag "enhancement". 110 | Don't forget to give the project a star! Thanks again! 111 | 112 | 1. Fork the Project 113 | 2. Create your Feature Branch (`git checkout -b feature/AmazingFeature`) 114 | 3. Commit your Changes (`git commit -m 'Add some AmazingFeature'`) 115 | 4. Push to the Branch (`git push origin feature/AmazingFeature`) 116 | 5. Open a Pull Request 117 | 118 |

(back to top)

119 | 120 | 121 | 122 | 123 | ## License 124 | 125 | Distributed under the GNU GPL License. See `LICENSE.txt` for more information. 126 | 127 |

(back to top)

128 | 129 | 130 | 131 | 132 | ## Contact 133 | 134 | Discord - [@jt#1296](http://discord.strafe.us) 135 | 136 | Project Link: [https://github.com/ilovefuud/titanium](https://github.com/ilovefuud/titanium) 137 | 138 |

(back to top)

139 | 140 | 141 | 142 | 143 | 144 | [contributors-shield]: https://img.shields.io/github/contributors/ilovefuud/titanium.svg?style=for-the-badge 145 | [contributors-url]: https://github.com/ilovefuud/titanium/graphs/contributors 146 | [forks-shield]: https://img.shields.io/github/forks/ilovefuud/titanium.svg?style=for-the-badge 147 | [forks-url]: https://github.com/ilovefuud/titanium/network/members 148 | [stars-shield]: https://img.shields.io/github/stars/ilovefuud/titanium.svg?style=for-the-badge 149 | [stars-url]: https://github.com/ilovefuud/titanium/stargazers 150 | [issues-shield]: https://img.shields.io/github/issues/ilovefuud/titanium.svg?style=for-the-badge 151 | [issues-url]: https://github.com/ilovefuud/titanium/issues 152 | [license-shield]: https://img.shields.io/github/license/ilovefuud/titanium.svg?style=for-the-badge 153 | [license-url]: https://github.com/ilovefuud/titanium/blob/master/LICENSE.txt 154 | [product-screenshot]: images/screenshot.png 155 | -------------------------------------------------------------------------------- /pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 4.0.0 6 | 7 | me.jaden.titanium 8 | titanium 9 | 1.4.0-SNAPSHOT 10 | jar 11 | 12 | Titanium 13 | 14 | 15 | 1.8 16 | UTF-8 17 | 18 | 19 | 20 | 21 | 22 | org.apache.maven.plugins 23 | maven-compiler-plugin 24 | 3.13.0 25 | 26 | ${java.version} 27 | ${java.version} 28 | 29 | 30 | 31 | org.apache.maven.plugins 32 | maven-shade-plugin 33 | 3.5.0 34 | 35 | 36 | package 37 | 38 | shade 39 | 40 | 41 | Titanium 42 | false 43 | false 44 | 45 | 46 | org.bstats 47 | me.jaden.titanium.bstats 48 | 49 | 50 | co.aikar 51 | me.jaden.titanium.acf 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | src/main/resources 62 | true 63 | 64 | 65 | 66 | 67 | 68 | 69 | spigotmc-repo 70 | https://hub.spigotmc.org/nexus/content/repositories/snapshots/ 71 | 72 | 73 | sonatype 74 | https://oss.sonatype.org/content/groups/public/ 75 | 76 | 77 | codemc-snapshots 78 | https://repo.codemc.io/repository/maven-snapshots/ 79 | 80 | 81 | aikar 82 | https://repo.aikar.co/content/groups/aikar/ 83 | 84 | 85 | 86 | 87 | 88 | org.spigotmc 89 | spigot-api 90 | 1.18.1-R0.1-SNAPSHOT 91 | provided 92 | 93 | 94 | 95 | com.github.retrooper 96 | packetevents-spigot 97 | 2.5.1-SNAPSHOT 98 | provided 99 | 100 | 101 | 102 | org.projectlombok 103 | lombok 104 | 1.18.32 105 | provided 106 | 107 | 108 | 109 | org.bstats 110 | bstats-bukkit 111 | 3.0.2 112 | compile 113 | 114 | 115 | 116 | 117 | co.aikar 118 | acf-paper 119 | 0.5.1-SNAPSHOT 120 | compile 121 | 122 | 123 | 124 | -------------------------------------------------------------------------------- /src/main/java/me/jaden/titanium/Titanium.java: -------------------------------------------------------------------------------- 1 | package me.jaden.titanium; 2 | 3 | import co.aikar.commands.PaperCommandManager; 4 | import io.github.retrooper.packetevents.adventure.serializer.legacy.LegacyComponentSerializer; 5 | import lombok.Getter; 6 | import lombok.Setter; 7 | import me.jaden.titanium.check.CheckManager; 8 | import me.jaden.titanium.command.TitaniumCommand; 9 | import me.jaden.titanium.data.DataManager; 10 | import me.jaden.titanium.settings.TitaniumConfig; 11 | import me.jaden.titanium.util.Ticker; 12 | import org.bstats.bukkit.Metrics; 13 | import org.bukkit.Bukkit; 14 | import org.bukkit.plugin.java.JavaPlugin; 15 | 16 | @Getter 17 | @Setter 18 | public final class Titanium extends JavaPlugin { 19 | @Getter 20 | private static Titanium plugin; 21 | 22 | private final LegacyComponentSerializer componentSerializer = LegacyComponentSerializer.builder() 23 | .character(LegacyComponentSerializer.AMPERSAND_CHAR) 24 | .hexCharacter(LegacyComponentSerializer.HEX_CHAR).build(); 25 | 26 | private TitaniumConfig titaniumConfig; 27 | 28 | private Ticker ticker; 29 | 30 | private DataManager dataManager; 31 | private CheckManager checkManager; 32 | private PaperCommandManager commandManager; 33 | 34 | @Override 35 | public void onEnable() { 36 | plugin = this; 37 | 38 | this.titaniumConfig = new TitaniumConfig(this); 39 | 40 | this.ticker = new Ticker(); 41 | 42 | this.dataManager = new DataManager(); 43 | this.checkManager = new CheckManager(); 44 | 45 | this.commandManager = new PaperCommandManager(this); 46 | this.commandManager.registerCommand(new TitaniumCommand()); 47 | 48 | if (!getServer().spigot().getConfig().getBoolean("settings.late-bind", true)) { 49 | Bukkit.getLogger().warning("[Titanium] Late bind is disabled, this can allow players" + 50 | " to join your server before the plugin loads leaving you vulnerable to crashers."); 51 | } 52 | 53 | //bStats 54 | new Metrics(this, 15258); 55 | } 56 | 57 | @Override 58 | public void onDisable() { 59 | this.ticker.getTask().cancel(); 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /src/main/java/me/jaden/titanium/check/BaseCheck.java: -------------------------------------------------------------------------------- 1 | package me.jaden.titanium.check; 2 | 3 | import com.github.retrooper.packetevents.event.ProtocolPacketEvent; 4 | import com.github.retrooper.packetevents.protocol.player.User; 5 | import com.github.retrooper.packetevents.wrapper.play.server.WrapperPlayServerDisconnect; 6 | import java.util.Optional; 7 | import me.jaden.titanium.data.DataManager; 8 | import me.jaden.titanium.data.PlayerData; 9 | import me.jaden.titanium.settings.MessagesConfig; 10 | import me.jaden.titanium.settings.TitaniumConfig; 11 | import net.kyori.adventure.text.Component; 12 | import org.bukkit.Bukkit; 13 | import org.bukkit.entity.Player; 14 | 15 | public abstract class BaseCheck implements Check { 16 | private final TitaniumConfig titaniumConfig = TitaniumConfig.getInstance(); 17 | private final MessagesConfig messagesConfig = titaniumConfig.getMessagesConfig(); 18 | 19 | @Override 20 | public void flagPacket(ProtocolPacketEvent event, String info, boolean kick) { 21 | event.setCancelled(true); 22 | 23 | User user = event.getUser(); 24 | this.alert(user, info); 25 | if (kick) { 26 | this.disconnect(user); 27 | } 28 | } 29 | 30 | @Override 31 | public void flagPacket(ProtocolPacketEvent event, String info) { 32 | this.flagPacket(event, info, true); 33 | } 34 | 35 | @Override 36 | public void flagPacket(ProtocolPacketEvent event, boolean kick) { 37 | this.flagPacket(event, "", kick); 38 | } 39 | 40 | protected void disconnect(User user) { 41 | user.sendPacket(new WrapperPlayServerDisconnect(messagesConfig.getKickMessage(this.getClass().getSimpleName()))); 42 | user.closeConnection(); 43 | } 44 | 45 | protected void alert(User user, String info) { 46 | Component component = messagesConfig.getNotification(user.getName(), this.getClass().getSimpleName(), info); 47 | Bukkit.getLogger().info(messagesConfig.getComponentSerializer().serialize(component)); 48 | for (PlayerData playerData : DataManager.getInstance().getPlayerData().values()) { 49 | if (playerData.isReceivingAlerts()) { 50 | playerData.getUser().sendMessage(component); 51 | } 52 | } 53 | } 54 | 55 | protected Player getPlayer(ProtocolPacketEvent event) { 56 | return Optional.ofNullable((Player) event.getPlayer()).orElse(Bukkit.getPlayer(event.getUser().getUUID())); 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /src/main/java/me/jaden/titanium/check/Check.java: -------------------------------------------------------------------------------- 1 | package me.jaden.titanium.check; 2 | 3 | import com.github.retrooper.packetevents.event.PacketReceiveEvent; 4 | import com.github.retrooper.packetevents.event.PacketSendEvent; 5 | import com.github.retrooper.packetevents.event.ProtocolPacketEvent; 6 | import me.jaden.titanium.data.PlayerData; 7 | 8 | public interface Check { 9 | 10 | default void flagPacket(ProtocolPacketEvent event) { 11 | flagPacket(event, ""); 12 | } 13 | 14 | void flagPacket(ProtocolPacketEvent event, String info); 15 | 16 | void flagPacket(ProtocolPacketEvent event, String info, boolean kick); 17 | 18 | void flagPacket(ProtocolPacketEvent event, boolean kick); 19 | 20 | default void handle(PacketReceiveEvent event, PlayerData playerData) { 21 | 22 | } 23 | 24 | default void handle(PacketSendEvent event, PlayerData playerData) { 25 | 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/main/java/me/jaden/titanium/check/CheckManager.java: -------------------------------------------------------------------------------- 1 | package me.jaden.titanium.check; 2 | 3 | import com.github.retrooper.packetevents.PacketEvents; 4 | import com.github.retrooper.packetevents.event.SimplePacketListenerAbstract; 5 | import com.github.retrooper.packetevents.event.simple.PacketPlayReceiveEvent; 6 | import com.github.retrooper.packetevents.event.simple.PacketPlaySendEvent; 7 | import com.github.retrooper.packetevents.manager.server.ServerVersion; 8 | import java.util.HashMap; 9 | import java.util.Map; 10 | import me.jaden.titanium.Titanium; 11 | import me.jaden.titanium.check.impl.book.Book; 12 | import me.jaden.titanium.check.impl.book.MassiveBook; 13 | import me.jaden.titanium.check.impl.command.BlockedCommand; 14 | import me.jaden.titanium.check.impl.crasher.BandwidthLimit; 15 | import me.jaden.titanium.check.impl.crasher.Lectern; 16 | import me.jaden.titanium.check.impl.crasher.Log4J; 17 | import me.jaden.titanium.check.impl.crasher.PacketSize; 18 | import me.jaden.titanium.check.impl.creative.ItemCheck; 19 | import me.jaden.titanium.check.impl.creative.ItemCheckRunner; 20 | import me.jaden.titanium.check.impl.creative.impl.CreativeAnvil; 21 | import me.jaden.titanium.check.impl.creative.impl.CreativeClientBookCrash; 22 | import me.jaden.titanium.check.impl.creative.impl.CreativeMap; 23 | import me.jaden.titanium.check.impl.creative.impl.CreativeSkull; 24 | import me.jaden.titanium.check.impl.creative.impl.EnchantLimit; 25 | import me.jaden.titanium.check.impl.creative.impl.PotionLimit; 26 | import me.jaden.titanium.check.impl.firework.FireworkSize; 27 | import me.jaden.titanium.check.impl.invalid.ChannelCount; 28 | import me.jaden.titanium.check.impl.invalid.InvalidMove; 29 | import me.jaden.titanium.check.impl.invalid.InvalidPickItem; 30 | import me.jaden.titanium.check.impl.invalid.InvalidSlotChange; 31 | import me.jaden.titanium.check.impl.invalid.InvalidViewDistance; 32 | import me.jaden.titanium.check.impl.sign.SignLength; 33 | import me.jaden.titanium.check.impl.spam.BookSpam; 34 | import me.jaden.titanium.check.impl.spam.CraftSpam; 35 | import me.jaden.titanium.check.impl.spam.DropSpam; 36 | import me.jaden.titanium.check.impl.spam.PacketCount; 37 | import me.jaden.titanium.data.DataManager; 38 | import me.jaden.titanium.data.PlayerData; 39 | import me.jaden.titanium.settings.TitaniumConfig; 40 | 41 | public class CheckManager { 42 | private final Map, BaseCheck> packetChecks = new HashMap<>(); 43 | private final Map, ItemCheck> creativeChecks = new HashMap<>(); 44 | 45 | public CheckManager() { 46 | this.initializeListeners(); 47 | 48 | ServerVersion serverVersion = PacketEvents.getAPI().getServerManager().getVersion(); 49 | 50 | //Add creative checks first, so that the creative check runner can load them 51 | if (TitaniumConfig.getInstance().getCreativeConfig().isEnabled()) { 52 | this.addCreativeChecks( 53 | new CreativeSkull(), 54 | new CreativeMap(), 55 | new CreativeClientBookCrash(), 56 | new PotionLimit(), 57 | new CreativeAnvil() 58 | ); 59 | if (TitaniumConfig.getInstance().getCreativeConfig().getMaxEnchantmentLevel() != -1) { 60 | this.addCreativeChecks(new EnchantLimit()); 61 | } 62 | } 63 | 64 | this.addChecks( 65 | // Spam (This should always be at the top for performance reasons) 66 | new BookSpam(), 67 | new DropSpam(), 68 | new PacketCount(), 69 | new CraftSpam(), 70 | 71 | // Invalid 72 | new InvalidMove(), 73 | new InvalidViewDistance(), 74 | new InvalidPickItem(), 75 | new InvalidSlotChange(), 76 | new ChannelCount(), 77 | 78 | // Crasher 79 | new Log4J(), 80 | new BandwidthLimit(), 81 | 82 | new BlockedCommand(), 83 | 84 | // Firework 85 | new FireworkSize(), 86 | 87 | // Sign 88 | new SignLength() 89 | ); 90 | 91 | if (TitaniumConfig.getInstance().isNoBooks()) { 92 | this.addChecks(new Book()); 93 | } else { 94 | this.addChecks(new MassiveBook()); 95 | } 96 | 97 | if (TitaniumConfig.getInstance().getMaxBytes() != -1) { 98 | this.addChecks(new PacketSize()); 99 | } 100 | 101 | if (TitaniumConfig.getInstance().getMaxBytesPerSecond() != -1) { 102 | this.addChecks(new BandwidthLimit()); 103 | } 104 | 105 | if (serverVersion.isNewerThanOrEquals(ServerVersion.V_1_14)) { 106 | this.addChecks(new Lectern()); 107 | } 108 | 109 | this.addChecks(new ItemCheckRunner(creativeChecks.values())); 110 | 111 | this.removeDisabledChecks(); 112 | } 113 | 114 | private void initializeListeners() { 115 | PacketEvents.getAPI().getEventManager().registerListener(new SimplePacketListenerAbstract() { 116 | //TODO: merge these into one method so there's no duplicate code. 117 | @Override 118 | public void onPacketPlayReceive(PacketPlayReceiveEvent event) { 119 | for (BaseCheck check : packetChecks.values()) { 120 | if (event.isCancelled()) { 121 | return; 122 | } 123 | 124 | PlayerData data = DataManager.getInstance().getPlayerData(event.getUser()); 125 | 126 | if (data != null) { 127 | check.handle(event, data); 128 | } 129 | } 130 | } 131 | 132 | @Override 133 | public void onPacketPlaySend(PacketPlaySendEvent event) { 134 | for (BaseCheck check : packetChecks.values()) { 135 | if (event.isCancelled()) { 136 | return; 137 | } 138 | 139 | PlayerData data = DataManager.getInstance().getPlayerData(event.getUser()); 140 | 141 | if (data != null) { 142 | check.handle(event, data); 143 | } 144 | } 145 | } 146 | }); 147 | } 148 | 149 | private void addChecks(BaseCheck... checks) { 150 | for (BaseCheck check : checks) { 151 | this.packetChecks.put(check.getClass(), check); 152 | 153 | if (check instanceof ItemCheck) { 154 | this.addCreativeChecks((ItemCheck) check); 155 | } 156 | } 157 | } 158 | 159 | private void addCreativeChecks(ItemCheck... checks) { 160 | for (ItemCheck check : checks) { 161 | this.creativeChecks.put(check.getClass(), check); 162 | } 163 | } 164 | 165 | private void removeDisabledChecks() { 166 | for (String disabledCheck : TitaniumConfig.getInstance().getDisabledChecks()) { 167 | this.creativeChecks.keySet().removeIf(clazz -> clazz.getName().contains(disabledCheck)); 168 | this.packetChecks.keySet().removeIf(clazz -> clazz.getName().contains(disabledCheck)); 169 | Titanium.getPlugin().getLogger().info(disabledCheck + " has been disabled if it exists!"); 170 | } 171 | } 172 | } 173 | -------------------------------------------------------------------------------- /src/main/java/me/jaden/titanium/check/impl/book/Book.java: -------------------------------------------------------------------------------- 1 | package me.jaden.titanium.check.impl.book; 2 | 3 | import com.github.retrooper.packetevents.event.PacketReceiveEvent; 4 | import com.github.retrooper.packetevents.protocol.item.ItemStack; 5 | import com.github.retrooper.packetevents.protocol.item.type.ItemTypes; 6 | import com.github.retrooper.packetevents.protocol.nbt.NBTCompound; 7 | import com.github.retrooper.packetevents.protocol.packettype.PacketType; 8 | import com.github.retrooper.packetevents.wrapper.play.client.WrapperPlayClientClickWindow; 9 | import com.github.retrooper.packetevents.wrapper.play.client.WrapperPlayClientPlayerBlockPlacement; 10 | import com.github.retrooper.packetevents.wrapper.play.client.WrapperPlayClientPluginMessage; 11 | import me.jaden.titanium.check.BaseCheck; 12 | import me.jaden.titanium.check.impl.creative.ItemCheck; 13 | import me.jaden.titanium.data.PlayerData; 14 | 15 | public class Book extends BaseCheck implements ItemCheck { 16 | @Override 17 | public void handle(PacketReceiveEvent event, PlayerData data) { 18 | if (event.getPacketType() == PacketType.Play.Client.CLICK_WINDOW) { 19 | WrapperPlayClientClickWindow wrapper = new WrapperPlayClientClickWindow(event); 20 | if (wrapper.getCarriedItemStack() != null) { 21 | if (wrapper.getCarriedItemStack().getType() == ItemTypes.WRITTEN_BOOK || wrapper.getCarriedItemStack().getType() == ItemTypes.WRITABLE_BOOK) { 22 | flagPacket(event); 23 | } 24 | } 25 | } else if (event.getPacketType() == PacketType.Play.Client.PLAYER_BLOCK_PLACEMENT) { 26 | WrapperPlayClientPlayerBlockPlacement wrapper = new WrapperPlayClientPlayerBlockPlacement(event); 27 | 28 | if (wrapper.getItemStack().isPresent()) { 29 | com.github.retrooper.packetevents.protocol.item.ItemStack wrappedItemStack = wrapper.getItemStack().get(); 30 | if (wrappedItemStack.getType() == ItemTypes.WRITTEN_BOOK || wrappedItemStack.getType() == ItemTypes.WRITABLE_BOOK) { 31 | flagPacket(event); 32 | } 33 | } 34 | } else if (event.getPacketType() == PacketType.Play.Client.PLUGIN_MESSAGE) { 35 | WrapperPlayClientPluginMessage wrapper = new WrapperPlayClientPluginMessage(event); 36 | // Make sure it's a book payload 37 | if (wrapper.getChannelName().contains("MC|BEdit") || wrapper.getChannelName().contains("MC|BSign")) { 38 | flagPacket(event); 39 | } 40 | } else if (event.getPacketType() == PacketType.Play.Client.EDIT_BOOK) { 41 | flagPacket(event); 42 | } 43 | } 44 | 45 | @Override 46 | public boolean handleCheck(PacketReceiveEvent event, ItemStack clickedStack, NBTCompound nbtCompound) { 47 | return clickedStack.getType() == ItemTypes.WRITTEN_BOOK || clickedStack.getType() == ItemTypes.WRITABLE_BOOK; 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /src/main/java/me/jaden/titanium/check/impl/book/MassiveBook.java: -------------------------------------------------------------------------------- 1 | package me.jaden.titanium.check.impl.book; 2 | 3 | import com.github.retrooper.packetevents.event.PacketReceiveEvent; 4 | import com.github.retrooper.packetevents.netty.buffer.ByteBufHelper; 5 | import com.github.retrooper.packetevents.netty.buffer.UnpooledByteBufAllocationHelper; 6 | import com.github.retrooper.packetevents.protocol.item.ItemStack; 7 | import com.github.retrooper.packetevents.protocol.nbt.NBTCompound; 8 | import com.github.retrooper.packetevents.protocol.nbt.NBTList; 9 | import com.github.retrooper.packetevents.protocol.nbt.NBTString; 10 | import com.github.retrooper.packetevents.protocol.packettype.PacketType; 11 | import com.github.retrooper.packetevents.wrapper.PacketWrapper; 12 | import com.github.retrooper.packetevents.wrapper.play.client.WrapperPlayClientClickWindow; 13 | import com.github.retrooper.packetevents.wrapper.play.client.WrapperPlayClientEditBook; 14 | import com.github.retrooper.packetevents.wrapper.play.client.WrapperPlayClientPlayerBlockPlacement; 15 | import com.github.retrooper.packetevents.wrapper.play.client.WrapperPlayClientPluginMessage; 16 | import java.util.ArrayList; 17 | import java.util.List; 18 | import me.jaden.titanium.check.BaseCheck; 19 | import me.jaden.titanium.check.impl.creative.ItemCheck; 20 | import me.jaden.titanium.data.PlayerData; 21 | import me.jaden.titanium.settings.TitaniumConfig; 22 | 23 | // PaperMC 24 | // net.minecraft.server.network.ServerGamePacketListenerImpl#handleEditBook 25 | public class MassiveBook extends BaseCheck implements ItemCheck { 26 | private final int maxBookPageSize = TitaniumConfig.getInstance().getMaxBookPageSize(); // default paper value 27 | private final double maxBookTotalSizeMultiplier = TitaniumConfig.getInstance().getMaxBookTotalSizeMultiplier(); // default paper value 28 | 29 | @Override 30 | public void handle(PacketReceiveEvent event, PlayerData data) { 31 | List pageList = new ArrayList<>(); 32 | 33 | if (event.getPacketType() == PacketType.Play.Client.EDIT_BOOK) { 34 | WrapperPlayClientEditBook wrapper = new WrapperPlayClientEditBook(event); 35 | pageList.addAll(wrapper.getPages()); 36 | } else if (event.getPacketType() == PacketType.Play.Client.PLUGIN_MESSAGE) { 37 | WrapperPlayClientPluginMessage wrapper = new WrapperPlayClientPluginMessage(event); 38 | 39 | // Make sure it's a book payload 40 | if (wrapper.getChannelName().contains("MC|BEdit") || wrapper.getChannelName().contains("MC|BSign")) { 41 | Object buffer = null; 42 | try { 43 | buffer = UnpooledByteBufAllocationHelper.buffer(); 44 | ByteBufHelper.writeBytes(buffer, wrapper.getData()); 45 | PacketWrapper universalWrapper = PacketWrapper.createUniversalPacketWrapper(buffer); 46 | com.github.retrooper.packetevents.protocol.item.ItemStack wrappedItemStack = universalWrapper.readItemStack(); 47 | 48 | if (invalidTitleOrAuthor(wrappedItemStack)) flagPacket(event); 49 | 50 | pageList.addAll(this.getPages(wrappedItemStack)); 51 | } finally { 52 | ByteBufHelper.release(buffer); 53 | } 54 | } 55 | 56 | } else if (event.getPacketType() == PacketType.Play.Client.PLAYER_BLOCK_PLACEMENT) { 57 | WrapperPlayClientPlayerBlockPlacement wrapper = new WrapperPlayClientPlayerBlockPlacement(event); 58 | 59 | if (wrapper.getItemStack().isPresent()) { 60 | if (invalidTitleOrAuthor(wrapper.getItemStack().get())) flagPacket(event); 61 | pageList.addAll(this.getPages(wrapper.getItemStack().get())); 62 | } 63 | } else if (event.getPacketType() == PacketType.Play.Client.CLICK_WINDOW) { 64 | WrapperPlayClientClickWindow wrapper = new WrapperPlayClientClickWindow(event); 65 | if (wrapper.getCarriedItemStack() != null) { 66 | if (invalidTitleOrAuthor(wrapper.getCarriedItemStack())) flagPacket(event); 67 | pageList.addAll(this.getPages(wrapper.getCarriedItemStack())); 68 | } 69 | } else { 70 | return; 71 | } 72 | 73 | if (invalid(pageList)) { 74 | flagPacket(event); 75 | } 76 | } 77 | 78 | 79 | @Override 80 | public boolean handleCheck(PacketReceiveEvent event, ItemStack clickedStack, NBTCompound nbtCompound) { 81 | return invalid(this.getPages(clickedStack)) || invalidTitleOrAuthor(clickedStack); 82 | } 83 | 84 | private boolean invalid(List pageList) { 85 | long byteTotal = 0; 86 | double multiplier = Math.min(1D, this.maxBookTotalSizeMultiplier); 87 | long byteAllowed = this.maxBookPageSize; 88 | 89 | for (String testString : pageList) { 90 | int byteLength = testString.getBytes(java.nio.charset.StandardCharsets.UTF_8).length; 91 | if (byteLength > 256 * 4) { 92 | // page too large 93 | return true; 94 | } 95 | byteTotal += byteLength; 96 | int length = testString.length(); 97 | int multibytes = 0; 98 | if (byteLength != length) { 99 | for (char c : testString.toCharArray()) { 100 | if (c > 127) { 101 | multibytes++; 102 | } 103 | } 104 | } 105 | byteAllowed += (this.maxBookPageSize * Math.min(1, Math.max(0.1D, (double) length / 255D))) * multiplier; 106 | 107 | if (multibytes > 1) { 108 | // penalize MB 109 | byteAllowed -= multibytes; 110 | } 111 | } 112 | 113 | // book too large if true 114 | return byteTotal > byteAllowed; 115 | } 116 | 117 | private boolean invalidTitleOrAuthor(ItemStack itemStack) { 118 | if (itemStack.getNBT() != null) { 119 | String title = itemStack.getNBT().getStringTagValueOrNull("title"); 120 | if (title != null && title.length() > 100) { 121 | return true; 122 | } 123 | 124 | String author = itemStack.getNBT().getStringTagValueOrNull("author"); 125 | return author != null && author.length() > 16; 126 | } 127 | return false; 128 | } 129 | 130 | private List getPages(ItemStack itemStack) { 131 | List pageList = new ArrayList<>(); 132 | 133 | if (itemStack.getNBT() != null) { 134 | NBTList nbtList = itemStack.getNBT().getStringListTagOrNull("pages"); 135 | if (nbtList != null) { 136 | for (NBTString tag : nbtList.getTags()) { 137 | pageList.add(tag.getValue()); 138 | } 139 | } 140 | } 141 | 142 | return pageList; 143 | } 144 | } 145 | -------------------------------------------------------------------------------- /src/main/java/me/jaden/titanium/check/impl/command/BlockedCommand.java: -------------------------------------------------------------------------------- 1 | package me.jaden.titanium.check.impl.command; 2 | 3 | import com.github.retrooper.packetevents.event.PacketReceiveEvent; 4 | import com.github.retrooper.packetevents.protocol.packettype.PacketType; 5 | import com.github.retrooper.packetevents.wrapper.play.client.WrapperPlayClientChatMessage; 6 | import com.github.retrooper.packetevents.wrapper.play.client.WrapperPlayClientTabComplete; 7 | import java.util.List; 8 | import java.util.regex.Matcher; 9 | import java.util.regex.Pattern; 10 | import me.jaden.titanium.check.BaseCheck; 11 | import me.jaden.titanium.data.PlayerData; 12 | import me.jaden.titanium.settings.MessagesConfig; 13 | import me.jaden.titanium.settings.TitaniumConfig; 14 | import net.kyori.adventure.text.Component; 15 | import org.bukkit.entity.Player; 16 | 17 | public class BlockedCommand extends BaseCheck { 18 | private static final Pattern PLUGIN_EXCLUSION = Pattern.compile("/(\\S+:)"); 19 | private final List disallowedCommands = TitaniumConfig.getInstance().getDisallowedCommands(); 20 | 21 | @Override 22 | public void handle(PacketReceiveEvent event, PlayerData playerData) { 23 | if (event.getPacketType() == PacketType.Play.Client.TAB_COMPLETE) { 24 | WrapperPlayClientTabComplete wrapper = new WrapperPlayClientTabComplete(event); 25 | final String message = wrapper.getText().toLowerCase().replaceAll("\\s+", " "); 26 | for (String disallowedCommand : disallowedCommands) { 27 | if (message.contains(disallowedCommand)) { 28 | if (!checkPermissions(event)) { 29 | flagPacket(event, "Disallowed tab complete: " + message, false); 30 | } 31 | break; 32 | } 33 | } 34 | } else if (event.getPacketType() == PacketType.Play.Client.CHAT_MESSAGE) { 35 | WrapperPlayClientChatMessage wrapper = new WrapperPlayClientChatMessage(event); 36 | final String message = wrapper.getMessage().toLowerCase().replaceAll("\\s+", " "); 37 | for (String disallowedCommand : disallowedCommands) { 38 | if (message.contains(disallowedCommand)) { 39 | if (!checkPermissions(event)) { 40 | flagPacket(event, "Disallowed command: " + message, false); 41 | final Component blockedCommandMessage = TitaniumConfig.getInstance().getMessagesConfig().getBlockedCommandMessage(); 42 | if(!TitaniumConfig.getInstance().getMessagesConfig().getBlockedCommandMessage().toString().equals("")) { 43 | event.getUser().sendMessage(blockedCommandMessage); 44 | } 45 | } 46 | break; 47 | } 48 | String pluginCommand = replaceGroup(PLUGIN_EXCLUSION.pattern(), message, 1, 1, ""); 49 | if (pluginCommand.contains(disallowedCommand)) { 50 | if (!checkPermissions(event)) { 51 | flagPacket(event, "Disallowed command: " + pluginCommand, false); 52 | final Component blockedCommandMessage = TitaniumConfig.getInstance().getMessagesConfig().getBlockedCommandMessage(); 53 | if(!TitaniumConfig.getInstance().getMessagesConfig().getBlockedCommandMessage().toString().equals("")) { 54 | event.getUser().sendMessage(blockedCommandMessage); 55 | } 56 | } 57 | break; 58 | } 59 | } 60 | } 61 | } 62 | 63 | private boolean checkPermissions(PacketReceiveEvent event) { 64 | Player player = this.getPlayer(event); 65 | if (player == null) { 66 | return false; 67 | } 68 | 69 | return player.hasPermission(TitaniumConfig.getInstance().getPermissionsConfig().getCommandBypassPermission()) || player.isOp(); 70 | } 71 | 72 | private String replaceGroup(String regex, String source, int groupToReplace, int groupOccurrence, String replacement) { 73 | Matcher m = Pattern.compile(regex).matcher(source); 74 | for (int i = 0; i < groupOccurrence; i++) 75 | if (!m.find()) return source; // pattern not met, may also throw an exception here 76 | return new StringBuilder(source).replace(m.start(groupToReplace), m.end(groupToReplace), replacement).toString(); 77 | } 78 | } 79 | 80 | 81 | -------------------------------------------------------------------------------- /src/main/java/me/jaden/titanium/check/impl/crasher/BandwidthLimit.java: -------------------------------------------------------------------------------- 1 | package me.jaden.titanium.check.impl.crasher; 2 | 3 | import com.github.retrooper.packetevents.event.PacketReceiveEvent; 4 | import com.github.retrooper.packetevents.netty.buffer.ByteBufHelper; 5 | import com.github.retrooper.packetevents.protocol.player.ClientVersion; 6 | import me.jaden.titanium.check.BaseCheck; 7 | import me.jaden.titanium.data.PlayerData; 8 | import me.jaden.titanium.settings.TitaniumConfig; 9 | 10 | public class BandwidthLimit extends BaseCheck { 11 | 12 | //Value from ExploitFixer config 13 | //https://github.com/2lstudios-mc/ExploitFixer/blob/master/resources/config.yml 14 | private final int maxBytesPerSecond = TitaniumConfig.getInstance().getMaxBytesPerSecond(); 15 | 16 | @Override 17 | public void handle(PacketReceiveEvent event, PlayerData playerData) { 18 | //https://netty.io/4.1/api/io/netty/buffer/ByteBuf.html 19 | //Sequential Access Indexing 20 | int readableBytes = ByteBufHelper.readableBytes(event.getByteBuf()); 21 | int maxBytesPerSecond = this.maxBytesPerSecond * (event.getUser().getClientVersion().isOlderThan(ClientVersion.V_1_8) ? 2 : 1); 22 | 23 | if (playerData.incrementBytesSent(readableBytes) > maxBytesPerSecond) { 24 | flagPacket(event, "Bytes Sent: " + playerData.getBytesSent() + " Max Bytes/s: " + maxBytesPerSecond); 25 | } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/main/java/me/jaden/titanium/check/impl/crasher/Lectern.java: -------------------------------------------------------------------------------- 1 | package me.jaden.titanium.check.impl.crasher; 2 | 3 | import com.github.retrooper.packetevents.event.PacketReceiveEvent; 4 | import com.github.retrooper.packetevents.event.PacketSendEvent; 5 | import com.github.retrooper.packetevents.protocol.packettype.PacketType; 6 | import com.github.retrooper.packetevents.wrapper.play.client.WrapperPlayClientClickWindow; 7 | import com.github.retrooper.packetevents.wrapper.play.server.WrapperPlayServerOpenWindow; 8 | import me.jaden.titanium.check.BaseCheck; 9 | import me.jaden.titanium.data.PlayerData; 10 | 11 | // https://github.com/PaperMC/Paper/commit/ea2c81e4b9232447f9896af2aac4cd0bf62386fd 12 | // https://wiki.vg/Inventory 13 | // https://github.com/GrimAnticheat/Grim/blob/2.0/src/main/java/ac/grim/grimac/checks/impl/crash/CrashD.java 14 | public class Lectern extends BaseCheck { 15 | @Override 16 | public void handle(PacketReceiveEvent event, PlayerData playerData) { 17 | if (event.getPacketType() == PacketType.Play.Client.CLICK_WINDOW) { 18 | WrapperPlayClientClickWindow click = new WrapperPlayClientClickWindow(event); 19 | int clickType = click.getWindowClickType().ordinal(); 20 | int button = click.getButton(); 21 | int windowId = click.getWindowId(); 22 | if (playerData.getOpenWindowType() == 16 && windowId > 0 && windowId == playerData.getOpenWindowContainer()) { 23 | flagPacket(event, "Click Type: " + clickType + " Button: " + button); 24 | } 25 | } 26 | } 27 | 28 | @Override 29 | public void handle(PacketSendEvent event, PlayerData playerData) { 30 | if (event.getPacketType() == PacketType.Play.Server.OPEN_WINDOW) { 31 | WrapperPlayServerOpenWindow window = new WrapperPlayServerOpenWindow(event); 32 | playerData.setOpenWindowType(window.getType()); 33 | if (playerData.getOpenWindowType() == 16) playerData.setOpenWindowContainer(window.getContainerId()); 34 | } 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /src/main/java/me/jaden/titanium/check/impl/crasher/Log4J.java: -------------------------------------------------------------------------------- 1 | package me.jaden.titanium.check.impl.crasher; 2 | 3 | import com.github.retrooper.packetevents.event.PacketReceiveEvent; 4 | import com.github.retrooper.packetevents.event.PacketSendEvent; 5 | import com.github.retrooper.packetevents.protocol.packettype.PacketType; 6 | import com.github.retrooper.packetevents.wrapper.play.client.WrapperPlayClientChatMessage; 7 | import com.github.retrooper.packetevents.wrapper.play.client.WrapperPlayClientNameItem; 8 | import com.github.retrooper.packetevents.wrapper.play.client.WrapperPlayClientPluginMessage; 9 | import me.jaden.titanium.check.BaseCheck; 10 | import me.jaden.titanium.data.PlayerData; 11 | 12 | // Yes, I know this isn't properly fixed. This should be fixed in the spigot. 13 | public class Log4J extends BaseCheck { 14 | @Override 15 | public void handle(PacketReceiveEvent event, PlayerData playerData) { 16 | if (event.getPacketType() == PacketType.Play.Client.CHAT_MESSAGE) { 17 | WrapperPlayClientChatMessage wrapper = new WrapperPlayClientChatMessage(event); 18 | if (wrapper.getMessage().contains("${")) { 19 | flagPacket(event); 20 | } 21 | } else if (event.getPacketType() == PacketType.Play.Client.NAME_ITEM) { 22 | WrapperPlayClientNameItem wrapper = new WrapperPlayClientNameItem(event); 23 | if (wrapper.getItemName().contains("${")) { 24 | flagPacket(event); 25 | } 26 | } else if (event.getPacketType() == PacketType.Play.Client.PLUGIN_MESSAGE) { 27 | WrapperPlayClientPluginMessage wrapper = new WrapperPlayClientPluginMessage(event); 28 | if (wrapper.getChannelName().contains("${")) { 29 | flagPacket(event); 30 | } 31 | } 32 | } 33 | 34 | @Override 35 | public void handle(PacketSendEvent event, PlayerData playerData) { 36 | /*if (event.getPacketType() == PacketType.Play.Server.CHAT_MESSAGE) { 37 | WrapperPlayServerChatMessage wrapper = new WrapperPlayServerChatMessage(event); 38 | if (wrapper.getChatComponentJson().contains("$jndi:ldap")) { 39 | flag(event); 40 | } 41 | }*/ 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /src/main/java/me/jaden/titanium/check/impl/crasher/PacketSize.java: -------------------------------------------------------------------------------- 1 | package me.jaden.titanium.check.impl.crasher; 2 | 3 | import com.github.retrooper.packetevents.event.PacketReceiveEvent; 4 | import com.github.retrooper.packetevents.netty.buffer.ByteBufHelper; 5 | import com.github.retrooper.packetevents.protocol.player.ClientVersion; 6 | import me.jaden.titanium.check.BaseCheck; 7 | import me.jaden.titanium.data.PlayerData; 8 | import me.jaden.titanium.settings.TitaniumConfig; 9 | 10 | public class PacketSize extends BaseCheck { 11 | 12 | //Value from ExploitFixer config 13 | //https://github.com/2lstudios-mc/ExploitFixer/blob/master/resources/config.yml 14 | private final int maxBytes = TitaniumConfig.getInstance().getMaxBytes(); 15 | 16 | @Override 17 | public void handle(PacketReceiveEvent event, PlayerData playerData) { 18 | //https://netty.io/4.1/api/io/netty/buffer/ByteBuf.html 19 | //Sequential Access Indexing 20 | int capacity = ByteBufHelper.capacity(event.getByteBuf()); 21 | int maxBytes = this.maxBytes * (event.getUser().getClientVersion().isOlderThan(ClientVersion.V_1_8) ? 2 : 1); 22 | 23 | if (capacity > maxBytes) { 24 | flagPacket(event, "Bytes: " + capacity + " Max Bytes: " + maxBytes); 25 | } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/main/java/me/jaden/titanium/check/impl/creative/ItemCheck.java: -------------------------------------------------------------------------------- 1 | package me.jaden.titanium.check.impl.creative; 2 | 3 | import com.github.retrooper.packetevents.event.PacketReceiveEvent; 4 | import com.github.retrooper.packetevents.protocol.item.ItemStack; 5 | import com.github.retrooper.packetevents.protocol.nbt.NBTCompound; 6 | 7 | public interface ItemCheck { 8 | boolean handleCheck(PacketReceiveEvent event, ItemStack clickedStack, NBTCompound nbtCompound); 9 | } 10 | -------------------------------------------------------------------------------- /src/main/java/me/jaden/titanium/check/impl/creative/ItemCheckRunner.java: -------------------------------------------------------------------------------- 1 | package me.jaden.titanium.check.impl.creative; 2 | 3 | import com.github.retrooper.packetevents.event.PacketReceiveEvent; 4 | import com.github.retrooper.packetevents.netty.buffer.ByteBufHelper; 5 | import com.github.retrooper.packetevents.netty.buffer.UnpooledByteBufAllocationHelper; 6 | import com.github.retrooper.packetevents.protocol.item.ItemStack; 7 | import com.github.retrooper.packetevents.protocol.nbt.NBTCompound; 8 | import com.github.retrooper.packetevents.protocol.nbt.NBTList; 9 | import com.github.retrooper.packetevents.protocol.packettype.PacketType; 10 | import com.github.retrooper.packetevents.wrapper.PacketWrapper; 11 | import com.github.retrooper.packetevents.wrapper.play.client.WrapperPlayClientClickWindow; 12 | import com.github.retrooper.packetevents.wrapper.play.client.WrapperPlayClientCreativeInventoryAction; 13 | import com.github.retrooper.packetevents.wrapper.play.client.WrapperPlayClientPlayerBlockPlacement; 14 | import com.github.retrooper.packetevents.wrapper.play.client.WrapperPlayClientPluginMessage; 15 | import java.util.ArrayList; 16 | import java.util.Collection; 17 | import java.util.List; 18 | import me.jaden.titanium.check.BaseCheck; 19 | import me.jaden.titanium.data.PlayerData; 20 | import me.jaden.titanium.settings.TitaniumConfig; 21 | import org.bukkit.GameMode; 22 | import org.bukkit.entity.Player; 23 | 24 | /* 25 | @author ZugPilot (Tobi) 26 | */ 27 | public class ItemCheckRunner extends BaseCheck { 28 | /* 29 | This class is for running and handling all creative checks 30 | */ 31 | private final List checks; 32 | 33 | private final int maxRecursions = TitaniumConfig.getInstance().getCreativeConfig().getMaxRecursions(); 34 | private final int maxItems = TitaniumConfig.getInstance().getCreativeConfig().getMaxItems(); 35 | 36 | public ItemCheckRunner(Collection checks) { 37 | this.checks = new ArrayList<>(checks); 38 | } 39 | 40 | @Override 41 | public void handle(PacketReceiveEvent event, PlayerData playerData) { 42 | ItemStack itemStack = null; 43 | if (event.getPacketType() == PacketType.Play.Client.CREATIVE_INVENTORY_ACTION) { 44 | Player player = this.getPlayer(event); 45 | if (player != null && player.getGameMode() != GameMode.CREATIVE) { 46 | event.setCancelled(true); 47 | return; 48 | } 49 | 50 | WrapperPlayClientCreativeInventoryAction wrapper = new WrapperPlayClientCreativeInventoryAction(event); 51 | itemStack = wrapper.getItemStack(); 52 | } else if (event.getPacketType() == PacketType.Play.Client.CLICK_WINDOW) { 53 | WrapperPlayClientClickWindow wrapper = new WrapperPlayClientClickWindow(event); 54 | if (wrapper.getCarriedItemStack() == null) { 55 | return; 56 | } 57 | 58 | itemStack = wrapper.getCarriedItemStack(); 59 | } else if (event.getPacketType() == PacketType.Play.Client.PLAYER_BLOCK_PLACEMENT) { 60 | WrapperPlayClientPlayerBlockPlacement wrapper = new WrapperPlayClientPlayerBlockPlacement(event); 61 | if (!wrapper.getItemStack().isPresent()) { 62 | return; 63 | } 64 | 65 | itemStack = wrapper.getItemStack().get(); 66 | } else if (event.getPacketType() == PacketType.Play.Client.PLUGIN_MESSAGE) { 67 | WrapperPlayClientPluginMessage wrapper = new WrapperPlayClientPluginMessage(event); 68 | Object buffer = null; 69 | try { 70 | buffer = UnpooledByteBufAllocationHelper.buffer(); 71 | ByteBufHelper.writeBytes(buffer, wrapper.getData()); 72 | PacketWrapper universalWrapper = PacketWrapper.createUniversalPacketWrapper(buffer); 73 | itemStack = universalWrapper.readItemStack(); 74 | } finally { 75 | ByteBufHelper.release(buffer); 76 | } 77 | } 78 | 79 | if (itemStack == null) { 80 | return; 81 | } 82 | 83 | NBTCompound compound = itemStack.getNBT(); 84 | //when the compound has block entity tag, do recursion to find nested/hidden items 85 | if (compound != null && compound.getTags().containsKey("BlockEntityTag")) { 86 | NBTCompound blockEntityTag = compound.getCompoundTagOrNull("BlockEntityTag"); 87 | //reset recursion count to prevent false kicks 88 | playerData.resetRecursion(); 89 | recursion(event, playerData, itemStack, blockEntityTag); 90 | } else { 91 | //if this gets called, it's not a container, so we don't need to do recursion 92 | for (ItemCheck check : checks) { 93 | //Maybe add a check result class, so that we can have more detailed verbose output... 94 | if (check.handleCheck(event, itemStack, compound)) { 95 | flagPacket(event, "Check: " + check.getClass().getSimpleName() + " Item: " + itemStack.getType().getName()); 96 | } 97 | } 98 | } 99 | } 100 | 101 | private void recursion(PacketReceiveEvent event, PlayerData data, ItemStack clickedItem, NBTCompound blockEntityTag) { 102 | //prevent recursion abuse with deeply nested items 103 | if (data.incrementRecursionCount() > maxRecursions) { 104 | flagPacket(event, "Too many recursions: " + data.getRecursionCount()); 105 | return; 106 | } 107 | 108 | if (blockEntityTag.getTags().containsKey("Items")) { 109 | NBTList items = blockEntityTag.getCompoundListTagOrNull("Items"); 110 | //This is super weird, when control + middle-clicking a chest this becomes null suddenly 111 | //Is this intentional behaviour? I have no idea how to fix this 112 | if (items == null) { 113 | return; 114 | } 115 | 116 | //it might be possible to send an item container via creative packets with a large amount of items in nbt 117 | //however I haven't actually found an exploit doing this 118 | if (items.size() > maxItems) { 119 | flagPacket(event, "Too many items: " + items.size()); 120 | return; 121 | } 122 | 123 | //Loop through all items 124 | for (int i = 0; i < items.size(); i++) { 125 | NBTCompound item = items.getTag(i); 126 | 127 | //Check if the item has the tag "tag" meaning it got extra nbt (besides the default item data of damage, count, id etc.) 128 | if (item.getTags().containsKey("tag")) { 129 | NBTCompound tag = item.getCompoundTagOrNull("tag"); 130 | 131 | //call creative checks to check for illegal tags 132 | for (ItemCheck check : checks) { 133 | if (check.handleCheck(event, clickedItem, tag)) { 134 | flagPacket(event, "Check: " + check.getClass().getSimpleName() + " Recursions: " + data.getRecursionCount() + " Item: " + clickedItem.getType().getName()); 135 | return; 136 | } 137 | } 138 | 139 | //if that item has block entity tag do recursion to find potential nested/"hidden" items 140 | if (tag.getTags().containsKey("BlockEntityTag")) { 141 | NBTCompound recursionBlockEntityTag = tag.getCompoundTagOrNull("BlockEntityTag"); 142 | recursion(event, data, clickedItem, recursionBlockEntityTag); 143 | } 144 | } else { 145 | //this actually only needed for the crash anvil check, since the crash anvil actually works without having "tag" 146 | //it sets the damage (legacy data) value of the item anvil to 3 which results in the client placing it crashing 147 | //not a fan of this approach, it runs a few unnecessary checks 148 | for (ItemCheck check : checks) { 149 | if (check.handleCheck(event, clickedItem, item)) { 150 | flagPacket(event, "Check: " + check.getClass().getSimpleName() + " Recursions: " + data.getRecursionCount() + " Item: " + clickedItem.getType().getName()); 151 | return; 152 | } 153 | } 154 | } 155 | } 156 | } 157 | } 158 | } 159 | -------------------------------------------------------------------------------- /src/main/java/me/jaden/titanium/check/impl/creative/impl/CreativeAnvil.java: -------------------------------------------------------------------------------- 1 | package me.jaden.titanium.check.impl.creative.impl; 2 | 3 | import com.github.retrooper.packetevents.event.PacketReceiveEvent; 4 | import com.github.retrooper.packetevents.protocol.item.ItemStack; 5 | import com.github.retrooper.packetevents.protocol.item.type.ItemTypes; 6 | import com.github.retrooper.packetevents.protocol.nbt.NBTCompound; 7 | import com.github.retrooper.packetevents.protocol.nbt.NBTNumber; 8 | import me.jaden.titanium.check.impl.creative.ItemCheck; 9 | 10 | public class CreativeAnvil implements ItemCheck { 11 | 12 | //This prevents the creation of buggy anvils that crash the client when placed 13 | //https://bugs.mojang.com/browse/MC-82677 14 | 15 | private boolean invalid(ItemStack itemStack) { 16 | if (itemStack.getType() == ItemTypes.ANVIL) { 17 | return itemStack.getLegacyData() < 0 || itemStack.getLegacyData() > 2; 18 | } 19 | return false; 20 | } 21 | 22 | @Override 23 | public boolean handleCheck(PacketReceiveEvent event, ItemStack clickedStack, NBTCompound nbtCompound) { 24 | if (invalid(clickedStack)) { 25 | return true; 26 | } 27 | if (nbtCompound.getTags().containsKey("id")) { 28 | String id = nbtCompound.getStringTagValueOrNull("id"); 29 | if (id.contains("anvil")) { 30 | if (nbtCompound.getTags().containsKey("Damage")) { 31 | NBTNumber damage = nbtCompound.getNumberTagOrNull("Damage"); 32 | return damage.getAsInt() > 3 || damage.getAsInt() < 0; 33 | } 34 | } 35 | } 36 | return false; 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /src/main/java/me/jaden/titanium/check/impl/creative/impl/CreativeClientBookCrash.java: -------------------------------------------------------------------------------- 1 | package me.jaden.titanium.check.impl.creative.impl; 2 | 3 | import com.github.retrooper.packetevents.event.PacketReceiveEvent; 4 | import com.github.retrooper.packetevents.protocol.item.ItemStack; 5 | import com.github.retrooper.packetevents.protocol.nbt.NBTCompound; 6 | import com.github.retrooper.packetevents.protocol.nbt.NBTList; 7 | import com.github.retrooper.packetevents.protocol.nbt.NBTString; 8 | import java.util.ArrayList; 9 | import java.util.List; 10 | import java.util.regex.Pattern; 11 | import me.jaden.titanium.check.impl.creative.ItemCheck; 12 | 13 | //Fixes client-side crash books 14 | 15 | //A book with the nbt from below will crash a client when opened 16 | //{generation:0,pages:[0:"{translate:translation.test.invalid}",],author:"someone",title:"a",resolved:1b,} 17 | //{generation:0,pages:[0:"{translate:translation.test.invalid2}",],author:"someone",title:"a",resolved:1b,} 18 | public class CreativeClientBookCrash implements ItemCheck { 19 | private static final Pattern PATTERN = Pattern.compile("\\s"); 20 | 21 | @Override 22 | public boolean handleCheck(PacketReceiveEvent event, ItemStack clickedStack, NBTCompound nbtCompound) { 23 | List pages = getPages(nbtCompound); 24 | if (pages.isEmpty()) { 25 | return false; 26 | } 27 | for (String page : pages) { 28 | String withOutSpaces = PATTERN.matcher(page).replaceAll(""); 29 | if (withOutSpaces.toLowerCase().contains("{translate:translation.test.invalid}") || withOutSpaces.contains("{translate:translation.test.invalid2}")) { 30 | return true; 31 | } 32 | } 33 | return false; 34 | } 35 | 36 | private List getPages(NBTCompound nbtCompound) { 37 | List pageList = new ArrayList<>(); 38 | NBTList nbtList = nbtCompound.getStringListTagOrNull("pages"); 39 | if (nbtList != null) { 40 | for (NBTString tag : nbtList.getTags()) { 41 | pageList.add(tag.getValue()); 42 | } 43 | } 44 | return pageList; 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /src/main/java/me/jaden/titanium/check/impl/creative/impl/CreativeMap.java: -------------------------------------------------------------------------------- 1 | package me.jaden.titanium.check.impl.creative.impl; 2 | 3 | import com.github.retrooper.packetevents.event.PacketReceiveEvent; 4 | import com.github.retrooper.packetevents.protocol.item.ItemStack; 5 | import com.github.retrooper.packetevents.protocol.nbt.NBTByte; 6 | import com.github.retrooper.packetevents.protocol.nbt.NBTCompound; 7 | import com.github.retrooper.packetevents.protocol.nbt.NBTList; 8 | import com.github.retrooper.packetevents.protocol.nbt.NBTType; 9 | import me.jaden.titanium.check.impl.creative.ItemCheck; 10 | 11 | //Fixes CrashMap exploit 12 | public class CreativeMap implements ItemCheck { 13 | 14 | @Override 15 | public boolean handleCheck(PacketReceiveEvent event, ItemStack clickedStack, NBTCompound nbtCompound) { 16 | if (nbtCompound.getTags().containsKey("Decorations")) { 17 | NBTList decorations = nbtCompound.getCompoundListTagOrNull("Decorations"); 18 | for (int i = 0; i < decorations.size(); i++) { 19 | NBTCompound decoration = decorations.getTag(i); 20 | if (decoration.getTags().containsKey("type")) { 21 | NBTByte nbtByte = decoration.getTagOfTypeOrNull("type", NBTType.BYTE.getNBTClass()); 22 | if (nbtByte == null) { 23 | return true; 24 | } 25 | } 26 | } 27 | } 28 | return false; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/main/java/me/jaden/titanium/check/impl/creative/impl/CreativeSkull.java: -------------------------------------------------------------------------------- 1 | package me.jaden.titanium.check.impl.creative.impl; 2 | 3 | import com.github.retrooper.packetevents.event.PacketReceiveEvent; 4 | import com.github.retrooper.packetevents.protocol.item.ItemStack; 5 | import com.github.retrooper.packetevents.protocol.nbt.NBTCompound; 6 | import com.github.retrooper.packetevents.protocol.nbt.NBTList; 7 | import com.google.gson.JsonObject; 8 | import com.google.gson.JsonParser; 9 | import java.util.Base64; 10 | import java.util.UUID; 11 | import me.jaden.titanium.check.impl.creative.ItemCheck; 12 | 13 | //Fixes crash head / glitch head 14 | public class CreativeSkull implements ItemCheck { 15 | 16 | @Override 17 | public boolean handleCheck(PacketReceiveEvent event, ItemStack clickedStack, NBTCompound nbtCompound) { 18 | if (nbtCompound == null) { 19 | return false; 20 | } 21 | 22 | if (!nbtCompound.getTags().containsKey("SkullOwner")) { 23 | return false; 24 | } 25 | 26 | NBTCompound skullOwner = nbtCompound.getCompoundTagOrNull("SkullOwner"); 27 | if (skullOwner == null) { 28 | return true; 29 | } 30 | 31 | if (skullOwner.getTags().containsKey("Id")) { 32 | try { 33 | UUID.fromString(skullOwner.getStringTagValueOrNull("Id")); 34 | } catch (Exception e) { 35 | return true; 36 | } 37 | } 38 | 39 | if (skullOwner.getTags().containsKey("Properties")) { 40 | NBTCompound properties = skullOwner.getCompoundTagOrNull("Properties"); 41 | if (properties == null) { 42 | return true; 43 | } 44 | 45 | NBTList textures = properties.getCompoundListTagOrNull("textures"); 46 | if (textures == null) { 47 | return true; 48 | } 49 | 50 | for (int i = 0; i < textures.size(); i++) { 51 | NBTCompound texture = textures.getTag(i); 52 | if (texture == null) { 53 | return true; 54 | } 55 | 56 | if (!texture.getTags().containsKey("Value")) { 57 | return true; 58 | } 59 | 60 | String value = texture.getStringTagValueOrNull("Value"); 61 | String decoded; 62 | try { 63 | decoded = new String(Base64.getDecoder().decode(value)); 64 | } catch (Exception e) { 65 | return true; 66 | } 67 | 68 | JsonObject jsonObject; 69 | try { 70 | jsonObject = JsonParser.parseString(decoded).getAsJsonObject(); 71 | } catch (Exception e) { 72 | return true; 73 | } 74 | 75 | if (!jsonObject.has("textures")) { 76 | return true; 77 | } 78 | 79 | jsonObject = jsonObject.getAsJsonObject("textures"); 80 | if (!jsonObject.has("SKIN")) { 81 | return true; 82 | } 83 | 84 | jsonObject = jsonObject.getAsJsonObject("SKIN"); 85 | if (!jsonObject.has("url")) { 86 | return true; 87 | } 88 | 89 | String url = jsonObject.get("url").getAsString(); 90 | if (url.trim().length() == 0) { 91 | return true; 92 | } 93 | 94 | if (!(url.startsWith("http://textures.minecraft.net/texture/") || url.startsWith("https://textures.minecraft.net/texture/"))) { 95 | return true; 96 | } 97 | } 98 | } 99 | return false; 100 | } 101 | } 102 | -------------------------------------------------------------------------------- /src/main/java/me/jaden/titanium/check/impl/creative/impl/EnchantLimit.java: -------------------------------------------------------------------------------- 1 | package me.jaden.titanium.check.impl.creative.impl; 2 | 3 | import com.github.retrooper.packetevents.PacketEvents; 4 | import com.github.retrooper.packetevents.event.PacketReceiveEvent; 5 | import com.github.retrooper.packetevents.protocol.item.ItemStack; 6 | import com.github.retrooper.packetevents.protocol.nbt.NBTCompound; 7 | import com.github.retrooper.packetevents.protocol.nbt.NBTList; 8 | import com.github.retrooper.packetevents.protocol.nbt.NBTNumber; 9 | import com.github.retrooper.packetevents.protocol.player.ClientVersion; 10 | import me.jaden.titanium.check.impl.creative.ItemCheck; 11 | 12 | public class EnchantLimit implements ItemCheck { 13 | private static final ClientVersion CLIENT_VERSION = PacketEvents.getAPI().getServerManager().getVersion().toClientVersion(); 14 | 15 | @Override 16 | public boolean handleCheck(PacketReceiveEvent event, ItemStack clickedStack, NBTCompound nbtCompound) { 17 | //This is "version safe", since we check both the older 'ench' and the newer 'Enchantments' tag 18 | //Not a very clean approach. A way to get items within pe itemstacks would certainly be helpful 19 | if (nbtCompound.getTags().containsKey(clickedStack.getEnchantmentsTagName(CLIENT_VERSION))) { 20 | NBTList enchantments = nbtCompound.getCompoundListTagOrNull(clickedStack.getEnchantmentsTagName(CLIENT_VERSION)); 21 | for (int i = 0; i < enchantments.size(); i++) { 22 | NBTCompound enchantment = enchantments.getTag(i); 23 | if (enchantment.getTags().containsKey("lvl")) { 24 | NBTNumber number = enchantment.getNumberTagOrNull("lvl"); 25 | if (number.getAsInt() < 0) { 26 | return true; 27 | } 28 | } 29 | } 30 | } 31 | return false; 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /src/main/java/me/jaden/titanium/check/impl/creative/impl/PotionLimit.java: -------------------------------------------------------------------------------- 1 | package me.jaden.titanium.check.impl.creative.impl; 2 | 3 | import com.github.retrooper.packetevents.event.PacketReceiveEvent; 4 | import com.github.retrooper.packetevents.protocol.item.ItemStack; 5 | import com.github.retrooper.packetevents.protocol.nbt.NBTCompound; 6 | import com.github.retrooper.packetevents.protocol.nbt.NBTList; 7 | import com.github.retrooper.packetevents.protocol.nbt.NBTNumber; 8 | import me.jaden.titanium.check.impl.creative.ItemCheck; 9 | import me.jaden.titanium.settings.TitaniumConfig; 10 | 11 | public class PotionLimit implements ItemCheck { 12 | //This prevents hacked potions that can do all sorts of annoying things (KillerPotions, NoRespawnPotions, TrollPotions) 13 | private final int maxPotionEffects = TitaniumConfig.getInstance().getCreativeConfig().getMaxPotionEffects(); 14 | private final boolean allowNegativeAmplifiers = TitaniumConfig.getInstance().getCreativeConfig().isAllowNegativeAmplifiers(); 15 | private final int maxPotionEffectAmplifier = TitaniumConfig.getInstance().getCreativeConfig().getMaxPotionEffectAmplifier(); 16 | private final int maxPotionEffectDuration = TitaniumConfig.getInstance().getCreativeConfig().getMaxPotionEffectDuration(); 17 | 18 | @Override 19 | public boolean handleCheck(PacketReceiveEvent event, ItemStack clickedStack, NBTCompound nbtCompound) { 20 | if (!nbtCompound.getTags().containsKey("CustomPotionEffects")) { 21 | return false; 22 | } 23 | 24 | NBTList potionEffects = nbtCompound.getCompoundListTagOrNull("CustomPotionEffects"); 25 | 26 | //Limit how many custom potion effects a potion can have 27 | if (potionEffects.size() >= maxPotionEffects) { 28 | return true; 29 | } 30 | 31 | for (int i = 0; i < potionEffects.size(); i++) { 32 | NBTCompound effect = potionEffects.getTag(i); 33 | 34 | if (effect.getTags().containsKey("Duration")) { 35 | NBTNumber nbtNumber = effect.getNumberTagOrNull("Duration"); 36 | if (nbtNumber != null) { 37 | if (nbtNumber.getAsInt() >= maxPotionEffectDuration) { 38 | return true; 39 | } 40 | } 41 | } 42 | 43 | if (effect.getTags().containsKey("Amplifier")) { 44 | //This is weird, in wiki it says this is a byte, 45 | //but trying to get the byte tag allows hacked clients to bypass this check for some reason 46 | //It flags however, if they attempt to open their inventory after creating the potion 47 | NBTNumber nbtNumber = effect.getNumberTagOrNull("Amplifier"); 48 | if (nbtNumber != null) { 49 | if (nbtNumber.getAsInt() < 0 && !allowNegativeAmplifiers) { 50 | return true; 51 | } 52 | if (nbtNumber.getAsInt() > maxPotionEffectAmplifier) { 53 | return true; 54 | } 55 | } 56 | } 57 | 58 | } 59 | return false; 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /src/main/java/me/jaden/titanium/check/impl/firework/FireworkSize.java: -------------------------------------------------------------------------------- 1 | package me.jaden.titanium.check.impl.firework; 2 | 3 | import com.github.retrooper.packetevents.event.PacketReceiveEvent; 4 | import com.github.retrooper.packetevents.protocol.item.ItemStack; 5 | import com.github.retrooper.packetevents.protocol.nbt.NBTCompound; 6 | import com.github.retrooper.packetevents.protocol.nbt.NBTList; 7 | import com.github.retrooper.packetevents.protocol.packettype.PacketType; 8 | import com.github.retrooper.packetevents.wrapper.play.client.WrapperPlayClientClickWindow; 9 | import com.github.retrooper.packetevents.wrapper.play.client.WrapperPlayClientPlayerBlockPlacement; 10 | import me.jaden.titanium.check.BaseCheck; 11 | import me.jaden.titanium.check.impl.creative.ItemCheck; 12 | import me.jaden.titanium.data.PlayerData; 13 | import me.jaden.titanium.settings.TitaniumConfig; 14 | 15 | // PaperMC 16 | public class FireworkSize extends BaseCheck implements ItemCheck { 17 | private final int maxExplosions = TitaniumConfig.getInstance().getMaxExplosions(); // default paper value 18 | 19 | @Override 20 | public void handle(PacketReceiveEvent event, PlayerData data) { 21 | if (event.getPacketType() == PacketType.Play.Client.PLAYER_BLOCK_PLACEMENT) { 22 | WrapperPlayClientPlayerBlockPlacement wrapper = new WrapperPlayClientPlayerBlockPlacement(event); 23 | 24 | if (wrapper.getItemStack().isPresent()) { 25 | if (this.invalid(wrapper.getItemStack().get())) flagPacket(event); 26 | } 27 | } else if (event.getPacketType() == PacketType.Play.Client.CLICK_WINDOW) { 28 | WrapperPlayClientClickWindow wrapper = new WrapperPlayClientClickWindow(event); 29 | if (wrapper.getCarriedItemStack() != null) { 30 | if (this.invalid(wrapper.getCarriedItemStack())) flagPacket(event); 31 | } 32 | } 33 | } 34 | 35 | @Override 36 | public boolean handleCheck(PacketReceiveEvent event, ItemStack clickedStack, NBTCompound nbtCompound) { 37 | return invalid(clickedStack); 38 | } 39 | 40 | private boolean invalid(ItemStack itemStack) { 41 | if (itemStack.getNBT() != null) { 42 | NBTCompound fireworkNBT = itemStack.getNBT().getCompoundTagOrNull("Fireworks"); 43 | if (fireworkNBT != null) { 44 | NBTList explosionsNBT = fireworkNBT.getCompoundListTagOrNull("Explosions"); 45 | return explosionsNBT.size() >= this.maxExplosions; 46 | } 47 | } 48 | return false; 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /src/main/java/me/jaden/titanium/check/impl/invalid/ChannelCount.java: -------------------------------------------------------------------------------- 1 | package me.jaden.titanium.check.impl.invalid; 2 | 3 | import com.github.retrooper.packetevents.event.PacketReceiveEvent; 4 | import com.github.retrooper.packetevents.protocol.packettype.PacketType; 5 | import com.github.retrooper.packetevents.wrapper.play.client.WrapperPlayClientPluginMessage; 6 | import com.google.common.base.Charsets; 7 | import me.jaden.titanium.check.BaseCheck; 8 | import me.jaden.titanium.data.PlayerData; 9 | 10 | // Paper 1.8.8 11 | // org/bukkit/craftbukkit/entity/CraftPlayer.java:1209 12 | public class ChannelCount extends BaseCheck { 13 | 14 | //Fixes console spammer with register/unregister payloads 15 | 16 | @Override 17 | public void handle(PacketReceiveEvent event, PlayerData playerData) { 18 | if (event.getPacketType() == PacketType.Play.Client.PLUGIN_MESSAGE) { 19 | WrapperPlayClientPluginMessage wrapper = new WrapperPlayClientPluginMessage(event); 20 | String payload = new String(wrapper.getData(), Charsets.UTF_8); 21 | 22 | String[] channels = payload.split("\0"); 23 | 24 | if (wrapper.getChannelName().equals("REGISTER")) { 25 | if (playerData.getChannels().size() + channels.length > 124 || channels.length > 124) { 26 | flagPacket(event); 27 | } else { 28 | for (String channel : channels) { 29 | playerData.getChannels().add(channel); 30 | } 31 | } 32 | } else if (wrapper.getChannelName().equals("UNREGISTER")) { 33 | for (String channel : channels) { 34 | playerData.getChannels().remove(channel); 35 | } 36 | } 37 | } 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /src/main/java/me/jaden/titanium/check/impl/invalid/ImpossiblePacket.java: -------------------------------------------------------------------------------- 1 | package me.jaden.titanium.check.impl.invalid; 2 | 3 | import com.github.retrooper.packetevents.PacketEvents; 4 | import com.github.retrooper.packetevents.event.PacketReceiveEvent; 5 | import com.github.retrooper.packetevents.manager.server.ServerVersion; 6 | import com.github.retrooper.packetevents.protocol.nbt.NBTCompound; 7 | import com.github.retrooper.packetevents.protocol.packettype.PacketType; 8 | import com.github.retrooper.packetevents.wrapper.play.client.WrapperPlayClientClickWindow; 9 | import com.github.retrooper.packetevents.wrapper.play.client.WrapperPlayClientPlayerBlockPlacement; 10 | import io.github.retrooper.packetevents.util.SpigotReflectionUtil; 11 | import java.util.Arrays; 12 | import java.util.Collections; 13 | import java.util.List; 14 | import me.jaden.titanium.check.BaseCheck; 15 | import me.jaden.titanium.data.PlayerData; 16 | import org.bukkit.Material; 17 | import org.bukkit.entity.Player; 18 | 19 | public class ImpossiblePacket extends BaseCheck { 20 | @Override 21 | public void handle(PacketReceiveEvent event, PlayerData playerData) { 22 | if (event.getPacketType() == PacketType.Play.Client.CLICK_WINDOW) { 23 | WrapperPlayClientClickWindow wrapper = new WrapperPlayClientClickWindow(event); 24 | if (wrapper.getCarriedItemStack() == null) { 25 | return; 26 | } 27 | 28 | Material packetMaterial = SpigotReflectionUtil.encodeBukkitItemStack(wrapper.getCarriedItemStack()).getType(); 29 | 30 | Player player = getPlayer(event); 31 | if (!player.getInventory().contains(packetMaterial)) { 32 | flagPacket(event, "Clicked Item Material: " + packetMaterial, false); 33 | player.updateInventory(); 34 | } 35 | } else if (event.getPacketType() == PacketType.Play.Client.PLAYER_BLOCK_PLACEMENT) { 36 | WrapperPlayClientPlayerBlockPlacement wrapper = new WrapperPlayClientPlayerBlockPlacement(event); 37 | 38 | if (!wrapper.getItemStack().isPresent()) { 39 | return; 40 | } 41 | 42 | Material packetMaterial = SpigotReflectionUtil.encodeBukkitItemStack(wrapper.getItemStack().get()).getType(); 43 | 44 | boolean modern = PacketEvents.getAPI().getServerManager().getVersion().isNewerThan(ServerVersion.V_1_8_8); 45 | List possibleItemStacks = modern ? 46 | Arrays.asList(getPlayer(event).getInventory().getItemInMainHand().getType(), getPlayer(event).getInventory().getItemInOffHand().getType()) : 47 | Collections.singletonList(getPlayer(event).getItemInHand().getType()); 48 | 49 | if (!possibleItemStacks.contains(packetMaterial)) { 50 | wrapper.getItemStack().get().setNBT(new NBTCompound()); 51 | flagPacket(event, "Placed Item Material: " + packetMaterial, false); 52 | } 53 | } 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /src/main/java/me/jaden/titanium/check/impl/invalid/InvalidMove.java: -------------------------------------------------------------------------------- 1 | package me.jaden.titanium.check.impl.invalid; 2 | 3 | import com.github.retrooper.packetevents.event.PacketReceiveEvent; 4 | import com.github.retrooper.packetevents.protocol.packettype.PacketType; 5 | import com.github.retrooper.packetevents.protocol.world.Location; 6 | import com.github.retrooper.packetevents.util.Vector3d; 7 | import com.github.retrooper.packetevents.wrapper.play.client.WrapperPlayClientPlayerFlying; 8 | import com.github.retrooper.packetevents.wrapper.play.client.WrapperPlayClientVehicleMove; 9 | import me.jaden.titanium.check.BaseCheck; 10 | import me.jaden.titanium.data.PlayerData; 11 | 12 | // PaperMC 13 | // net/minecraft/server/network/ServerGamePacketListenerImpl.java:515 14 | // net/minecraft/server/network/ServerGamePacketListenerImpl.java:1283 15 | public class InvalidMove extends BaseCheck { 16 | @Override 17 | public void handle(PacketReceiveEvent event, PlayerData data) { 18 | if (WrapperPlayClientPlayerFlying.isFlying(event.getPacketType())) { 19 | WrapperPlayClientPlayerFlying wrapper = new WrapperPlayClientPlayerFlying(event); 20 | 21 | if (!wrapper.hasPositionChanged()) return; 22 | 23 | Location location = wrapper.getLocation(); 24 | if (this.containsInvalidValues(location.getX(), location.getY(), location.getZ(), location.getYaw(), location.getPitch())) { 25 | flagPacket(event); 26 | } 27 | } else if (event.getPacketType() == PacketType.Play.Client.VEHICLE_MOVE) { 28 | WrapperPlayClientVehicleMove wrapper = new WrapperPlayClientVehicleMove(event); 29 | 30 | Vector3d position = wrapper.getPosition(); 31 | if (this.containsInvalidValues(position.getX(), position.getY(), position.getZ(), wrapper.getYaw(), wrapper.getPitch())) { 32 | flagPacket(event); 33 | } 34 | } 35 | } 36 | 37 | private boolean containsInvalidValues(double x, double y, double z, float yaw, float pitch) { 38 | return Double.isNaN(x) || Double.isNaN(y) || Double.isNaN(z) || !Float.isFinite(pitch) || !Float.isFinite(yaw); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /src/main/java/me/jaden/titanium/check/impl/invalid/InvalidPickItem.java: -------------------------------------------------------------------------------- 1 | package me.jaden.titanium.check.impl.invalid; 2 | 3 | import com.github.retrooper.packetevents.event.PacketReceiveEvent; 4 | import com.github.retrooper.packetevents.protocol.packettype.PacketType; 5 | import com.github.retrooper.packetevents.wrapper.play.client.WrapperPlayClientHeldItemChange; 6 | import me.jaden.titanium.check.BaseCheck; 7 | import me.jaden.titanium.data.PlayerData; 8 | import org.bukkit.entity.Player; 9 | 10 | // PaperMC 11 | // net.minecraft.server.network.ServerGamePacketListenerImpl#handlePickItem 12 | public class InvalidPickItem extends BaseCheck { 13 | @Override 14 | public void handle(PacketReceiveEvent event, PlayerData playerData) { 15 | if (event.getPacketType() == PacketType.Play.Client.PICK_ITEM) { 16 | WrapperPlayClientHeldItemChange wrapper = new WrapperPlayClientHeldItemChange(event); 17 | 18 | Player player = this.getPlayer(event); 19 | 20 | if (player == null) return; 21 | 22 | if (!(wrapper.getSlot() >= 0 && wrapper.getSlot() < player.getInventory().getContents().length)) { 23 | flagPacket(event); 24 | } 25 | } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/main/java/me/jaden/titanium/check/impl/invalid/InvalidSlotChange.java: -------------------------------------------------------------------------------- 1 | package me.jaden.titanium.check.impl.invalid; 2 | 3 | import com.github.retrooper.packetevents.event.PacketReceiveEvent; 4 | import com.github.retrooper.packetevents.protocol.packettype.PacketType; 5 | import com.github.retrooper.packetevents.wrapper.play.client.WrapperPlayClientHeldItemChange; 6 | import me.jaden.titanium.check.BaseCheck; 7 | import me.jaden.titanium.data.PlayerData; 8 | 9 | // PaperMC 10 | // net.minecraft.server.network.ServerGamePacketListenerImpl#handleSetCarriedItem 11 | public class InvalidSlotChange extends BaseCheck { 12 | @Override 13 | public void handle(PacketReceiveEvent event, PlayerData playerData) { 14 | if (event.getPacketType() == PacketType.Play.Client.HELD_ITEM_CHANGE) { 15 | WrapperPlayClientHeldItemChange wrapper = new WrapperPlayClientHeldItemChange(event); 16 | 17 | if (wrapper.getSlot() < 0 || wrapper.getSlot() >= 9) { 18 | flagPacket(event); 19 | } 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/main/java/me/jaden/titanium/check/impl/invalid/InvalidViewDistance.java: -------------------------------------------------------------------------------- 1 | package me.jaden.titanium.check.impl.invalid; 2 | 3 | import com.github.retrooper.packetevents.event.PacketReceiveEvent; 4 | import com.github.retrooper.packetevents.protocol.packettype.PacketType; 5 | import com.github.retrooper.packetevents.wrapper.play.client.WrapperPlayClientSettings; 6 | import me.jaden.titanium.check.BaseCheck; 7 | import me.jaden.titanium.data.PlayerData; 8 | 9 | // https://github.com/PaperMC/Paper/commit/e3997543203bc1d86b58b6f1e751b0593228ca7b 10 | public class InvalidViewDistance extends BaseCheck { 11 | @Override 12 | public void handle(PacketReceiveEvent event, PlayerData data) { 13 | if (event.getPacketType() == PacketType.Play.Client.CLIENT_SETTINGS) { 14 | WrapperPlayClientSettings wrapper = new WrapperPlayClientSettings(event); 15 | wrapper.setViewDistance(Math.max(0, wrapper.getViewDistance())); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/main/java/me/jaden/titanium/check/impl/sign/SignLength.java: -------------------------------------------------------------------------------- 1 | package me.jaden.titanium.check.impl.sign; 2 | 3 | import com.github.retrooper.packetevents.event.PacketReceiveEvent; 4 | import com.github.retrooper.packetevents.protocol.packettype.PacketType; 5 | import com.github.retrooper.packetevents.wrapper.play.client.WrapperPlayClientUpdateSign; 6 | import me.jaden.titanium.check.BaseCheck; 7 | import me.jaden.titanium.data.PlayerData; 8 | import me.jaden.titanium.settings.TitaniumConfig; 9 | 10 | public class SignLength extends BaseCheck { 11 | // We add two to account for the " characters at the beginning and end. 12 | private final int maxCharactersPerLine = TitaniumConfig.getInstance().getMaxSignCharactersPerLine() + 2; 13 | 14 | @Override 15 | public void handle(PacketReceiveEvent event, PlayerData playerData) { 16 | if (event.getPacketType() == PacketType.Play.Client.UPDATE_SIGN) { 17 | WrapperPlayClientUpdateSign wrapper = new WrapperPlayClientUpdateSign(event); 18 | for (String textLine : wrapper.getTextLines()) { 19 | if (textLine.length() > this.maxCharactersPerLine) { 20 | flagPacket(event, "Length: " + textLine.length(), false); 21 | } 22 | } 23 | } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/main/java/me/jaden/titanium/check/impl/spam/BookSpam.java: -------------------------------------------------------------------------------- 1 | package me.jaden.titanium.check.impl.spam; 2 | 3 | import com.github.retrooper.packetevents.event.PacketReceiveEvent; 4 | import com.github.retrooper.packetevents.protocol.item.ItemStack; 5 | import com.github.retrooper.packetevents.protocol.item.type.ItemTypes; 6 | import com.github.retrooper.packetevents.protocol.packettype.PacketType; 7 | import com.github.retrooper.packetevents.wrapper.play.client.WrapperPlayClientClickWindow; 8 | import com.github.retrooper.packetevents.wrapper.play.client.WrapperPlayClientCreativeInventoryAction; 9 | import com.github.retrooper.packetevents.wrapper.play.client.WrapperPlayClientPlayerBlockPlacement; 10 | import com.github.retrooper.packetevents.wrapper.play.client.WrapperPlayClientPluginMessage; 11 | import me.jaden.titanium.check.BaseCheck; 12 | import me.jaden.titanium.data.PlayerData; 13 | import me.jaden.titanium.util.Ticker; 14 | 15 | public class BookSpam extends BaseCheck { 16 | @Override 17 | public void handle(PacketReceiveEvent event, PlayerData data) { 18 | if (event.getPacketType() == PacketType.Play.Client.EDIT_BOOK) { 19 | if (invalid(data)) flagPacket(event); 20 | } else if (event.getPacketType() == PacketType.Play.Client.PLUGIN_MESSAGE) { 21 | WrapperPlayClientPluginMessage wrapper = new WrapperPlayClientPluginMessage(event); 22 | // Make sure it's a book payload 23 | if (!(wrapper.getChannelName().contains("MC|BEdit") || wrapper.getChannelName().contains("MC|BSign"))) { 24 | return; 25 | } 26 | 27 | if (invalid(data)) flagPacket(event); 28 | } else if (event.getPacketType() == PacketType.Play.Client.PLAYER_BLOCK_PLACEMENT) { 29 | WrapperPlayClientPlayerBlockPlacement wrapper = new WrapperPlayClientPlayerBlockPlacement(event); 30 | if (wrapper.getItemStack().isPresent()) { 31 | ItemStack itemStack = wrapper.getItemStack().get(); 32 | 33 | if (itemStack.getType() == ItemTypes.WRITABLE_BOOK || itemStack.getType() == ItemTypes.WRITTEN_BOOK) { 34 | if (invalid(data)) { 35 | event.setCancelled(true); 36 | } 37 | } 38 | } 39 | } else if (event.getPacketType() == PacketType.Play.Client.CLICK_WINDOW) { 40 | WrapperPlayClientClickWindow wrapper = new WrapperPlayClientClickWindow(event); 41 | 42 | ItemStack itemStack = wrapper.getCarriedItemStack(); 43 | 44 | if (itemStack.getType() == ItemTypes.WRITABLE_BOOK || itemStack.getType() == ItemTypes.WRITTEN_BOOK) { 45 | if (invalid(data)) { 46 | event.setCancelled(true); 47 | } 48 | } 49 | } else if (event.getPacketType() == PacketType.Play.Client.CREATIVE_INVENTORY_ACTION) { 50 | WrapperPlayClientCreativeInventoryAction wrapper = new WrapperPlayClientCreativeInventoryAction(event); 51 | 52 | ItemStack itemStack = wrapper.getItemStack(); 53 | 54 | if (itemStack.getType() == ItemTypes.WRITABLE_BOOK || itemStack.getType() == ItemTypes.WRITTEN_BOOK) { 55 | if (invalid(data)) { 56 | event.setCancelled(true); 57 | } 58 | } 59 | } 60 | } 61 | 62 | private boolean invalid(PlayerData data) { 63 | int currentTick = Ticker.getInstance().getCurrentTick(); 64 | if (data.getLastBookEditTick() + 20 > currentTick) { 65 | return true; 66 | } else { 67 | data.setLastBookEditTick(currentTick); 68 | return false; 69 | } 70 | } 71 | } -------------------------------------------------------------------------------- /src/main/java/me/jaden/titanium/check/impl/spam/CraftSpam.java: -------------------------------------------------------------------------------- 1 | package me.jaden.titanium.check.impl.spam; 2 | 3 | import com.github.retrooper.packetevents.event.PacketReceiveEvent; 4 | import com.github.retrooper.packetevents.protocol.packettype.PacketType; 5 | import me.jaden.titanium.check.BaseCheck; 6 | import me.jaden.titanium.data.PlayerData; 7 | import me.jaden.titanium.util.Ticker; 8 | 9 | // PaperMC 10 | // net.minecraft.server.network.ServerGamePacketListenerImpl#handlePlayerAction 11 | public class CraftSpam extends BaseCheck { 12 | @Override 13 | public void handle(PacketReceiveEvent event, PlayerData data) { 14 | if (event.getPacketType() == PacketType.Play.Client.CRAFT_RECIPE_REQUEST) { 15 | int currentTick = Ticker.getInstance().getCurrentTick(); 16 | if (data.getLastCraftRequestTick() + 10 > currentTick) { 17 | flagPacket(event, false); 18 | getPlayer(event).updateInventory(); 19 | } else { 20 | data.setLastCraftRequestTick(currentTick); 21 | } 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /src/main/java/me/jaden/titanium/check/impl/spam/DropSpam.java: -------------------------------------------------------------------------------- 1 | package me.jaden.titanium.check.impl.spam; 2 | 3 | import com.github.retrooper.packetevents.event.PacketReceiveEvent; 4 | import com.github.retrooper.packetevents.protocol.packettype.PacketType; 5 | import com.github.retrooper.packetevents.protocol.player.DiggingAction; 6 | import com.github.retrooper.packetevents.wrapper.play.client.WrapperPlayClientPlayerDigging; 7 | import me.jaden.titanium.check.BaseCheck; 8 | import me.jaden.titanium.data.PlayerData; 9 | import me.jaden.titanium.util.Ticker; 10 | import org.bukkit.GameMode; 11 | import org.bukkit.entity.Player; 12 | 13 | // PaperMC 14 | // net.minecraft.server.network.ServerGamePacketListenerImpl#handlePlayerAction 15 | public class DropSpam extends BaseCheck { 16 | @Override 17 | public void handle(PacketReceiveEvent event, PlayerData data) { 18 | if (event.getPacketType() == PacketType.Play.Client.PLAYER_DIGGING) { 19 | WrapperPlayClientPlayerDigging wrapper = new WrapperPlayClientPlayerDigging(event); 20 | 21 | if (wrapper.getAction() != DiggingAction.DROP_ITEM) return; 22 | 23 | Player player = this.getPlayer(event); 24 | int currentTick = Ticker.getInstance().getCurrentTick(); 25 | 26 | if (player.getGameMode() != GameMode.SPECTATOR) { 27 | // limit how quickly items can be dropped 28 | // If the ticks aren't the same then the count starts from 0 and we update the lastDropTick. 29 | if (data.getLastDropItemTick() != currentTick) { 30 | data.setDropCount(0); 31 | data.setLastDropItemTick(currentTick); 32 | } else { 33 | // Else we increment the drop count and check the amount. 34 | data.incrementDropCount(); 35 | if (data.getDropCount() >= 20) { 36 | flagPacket(event, true); 37 | } 38 | } 39 | } 40 | } 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /src/main/java/me/jaden/titanium/check/impl/spam/PacketCount.java: -------------------------------------------------------------------------------- 1 | package me.jaden.titanium.check.impl.spam; 2 | 3 | import com.github.retrooper.packetevents.event.PacketReceiveEvent; 4 | import com.github.retrooper.packetevents.protocol.packettype.PacketTypeCommon; 5 | import java.util.Map; 6 | import me.jaden.titanium.check.BaseCheck; 7 | import me.jaden.titanium.data.PlayerData; 8 | import me.jaden.titanium.settings.TitaniumConfig; 9 | 10 | public class PacketCount extends BaseCheck { 11 | private final Map multiplierMap = TitaniumConfig.getInstance().getMultipliedPackets(); 12 | 13 | @Override 14 | public void handle(PacketReceiveEvent event, PlayerData data) { 15 | double multiplier = multiplierMap.getOrDefault(event.getPacketType(), 1.0D); 16 | if (data.incrementPacketCount(multiplier) > data.getPacketAllowance()) { 17 | flagPacket(event, "Packet Count: " + data.getPacketCount() + " Packet Allowance: " + data.getPacketAllowance()); 18 | } else { 19 | data.decrementPacketAllowance(); 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/main/java/me/jaden/titanium/command/TitaniumCommand.java: -------------------------------------------------------------------------------- 1 | package me.jaden.titanium.command; 2 | 3 | import co.aikar.commands.BaseCommand; 4 | import co.aikar.commands.annotation.CommandAlias; 5 | import co.aikar.commands.annotation.CommandCompletion; 6 | import co.aikar.commands.annotation.CommandPermission; 7 | import co.aikar.commands.annotation.Subcommand; 8 | import co.aikar.commands.annotation.Syntax; 9 | import co.aikar.commands.bukkit.contexts.OnlinePlayer; 10 | import java.util.concurrent.TimeUnit; 11 | import me.jaden.titanium.Titanium; 12 | import me.jaden.titanium.data.DataManager; 13 | import me.jaden.titanium.data.PlayerData; 14 | import net.kyori.adventure.text.Component; 15 | import org.bukkit.entity.Player; 16 | 17 | @CommandAlias("titanium") 18 | public class TitaniumCommand extends BaseCommand { 19 | @Subcommand("info") 20 | @Syntax("[player]") 21 | @CommandCompletion("@players") 22 | @CommandPermission("titanium.notification") 23 | public void info(Player executor, OnlinePlayer onlinePlayer) { 24 | Titanium plugin = Titanium.getPlugin(); 25 | PlayerData playerData = DataManager.getInstance().getPlayerData(onlinePlayer.getPlayer().getUniqueId()); 26 | 27 | Component message = plugin.getComponentSerializer().deserialize( 28 | "&7&m--------&r&7 (&eTitanium&7) &fInformation &7&m--------\n" 29 | + "&eClient Version: &f" + playerData.getUser().getClientVersion().getReleaseName() + "\n" 30 | + "&ePacket Count: &f" + playerData.getPacketCount() + "\n" 31 | + "&ePacket Allowance: &f" + playerData.getPacketAllowance() + "\n" 32 | + "&eBytes Sent: &f" + playerData.getBytesSent() + " of " + plugin.getTitaniumConfig().getMaxBytesPerSecond() + "\n" 33 | ); 34 | 35 | DataManager.getInstance().getPlayerData(executor.getUniqueId()).getUser().sendMessage(message); 36 | } 37 | 38 | @Subcommand("debug") 39 | @CommandPermission("titanium.notification") 40 | public void debug(Player executor) { 41 | Titanium plugin = Titanium.getPlugin(); 42 | 43 | long delta = System.currentTimeMillis() - plugin.getTicker().getLastReset(); 44 | Component message = plugin.getComponentSerializer().deserialize( 45 | "&7&m--------&r&7 (&eTitanium&7) &fDebug &7&m--------\n" 46 | + "&eTime Since Playerdata Reset: &f" + TimeUnit.MILLISECONDS.toSeconds(delta) + "\n" 47 | ); 48 | 49 | DataManager.getInstance().getPlayerData(executor.getUniqueId()).getUser().sendMessage(message); 50 | } 51 | 52 | @Subcommand("information") 53 | @Syntax("[player]") 54 | @CommandCompletion("@players") 55 | @CommandPermission("titanium.notification") 56 | public void informationAlias(Player executor, OnlinePlayer onlinePlayer) { 57 | this.info(executor, onlinePlayer); 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /src/main/java/me/jaden/titanium/data/DataManager.java: -------------------------------------------------------------------------------- 1 | package me.jaden.titanium.data; 2 | 3 | import com.github.retrooper.packetevents.PacketEvents; 4 | import com.github.retrooper.packetevents.event.PacketListenerCommon; 5 | import com.github.retrooper.packetevents.event.UserConnectEvent; 6 | import com.github.retrooper.packetevents.event.UserDisconnectEvent; 7 | import com.github.retrooper.packetevents.protocol.player.User; 8 | import java.util.Map; 9 | import java.util.UUID; 10 | import java.util.concurrent.ConcurrentHashMap; 11 | import lombok.Getter; 12 | 13 | public class DataManager { 14 | @Getter 15 | private static DataManager instance; 16 | @Getter 17 | private final Map playerData = new ConcurrentHashMap<>(); 18 | 19 | public DataManager() { 20 | instance = this; 21 | 22 | this.initializePacketListeners(); 23 | } 24 | 25 | private void initializePacketListeners() { 26 | PacketEvents.getAPI().getEventManager().registerListener(new PacketListenerCommon() { 27 | @Override 28 | public void onUserConnect(UserConnectEvent event) { 29 | addPlayerData(event.getUser()); 30 | } 31 | 32 | @Override 33 | public void onUserDisconnect(UserDisconnectEvent event) { 34 | removePlayerData(event.getUser()); 35 | } 36 | }); 37 | } 38 | 39 | public PlayerData getPlayerData(User user) { 40 | return this.playerData.get(user); 41 | } 42 | 43 | public PlayerData getPlayerData(UUID uuid) { 44 | return this.playerData.keySet().stream().filter(user -> user.getUUID() == uuid).findFirst().map(this.playerData::get).orElse(null); 45 | } 46 | 47 | public void addPlayerData(User user) { 48 | this.playerData.put(user, new PlayerData(user)); 49 | } 50 | 51 | public void removePlayerData(User user) { 52 | this.playerData.remove(user); 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /src/main/java/me/jaden/titanium/data/PlayerData.java: -------------------------------------------------------------------------------- 1 | package me.jaden.titanium.data; 2 | 3 | import com.github.retrooper.packetevents.protocol.player.User; 4 | import java.util.HashSet; 5 | import java.util.Set; 6 | import lombok.Getter; 7 | import lombok.RequiredArgsConstructor; 8 | import lombok.Setter; 9 | import me.jaden.titanium.settings.TitaniumConfig; 10 | 11 | @Setter 12 | @Getter 13 | @RequiredArgsConstructor 14 | public class PlayerData { 15 | private final User user; 16 | 17 | private final Set channels = new HashSet<>(); 18 | private boolean receivingAlerts = false; 19 | private int lastBookEditTick; 20 | private int lastDropItemTick; 21 | private int lastCraftRequestTick; 22 | private int dropCount; 23 | private int recursionCount; 24 | 25 | private double packetAllowance = TitaniumConfig.getInstance().getMaxPacketsPerSecond(); 26 | private double packetCount; 27 | 28 | private int bytesSent; 29 | 30 | private int openWindowType; 31 | private int openWindowContainer; 32 | 33 | public int incrementRecursionCount() { 34 | return recursionCount++; 35 | } 36 | 37 | public void resetRecursion() { 38 | recursionCount = 0; 39 | } 40 | 41 | public int incrementBytesSent(int amount) { 42 | return bytesSent += amount; 43 | } 44 | 45 | public int incrementDropCount() { 46 | return dropCount++; 47 | } 48 | 49 | public double incrementPacketCount(double multiplier) { 50 | double packetCount = Math.max(this.packetCount, 1); 51 | return this.packetCount += 1 * multiplier; 52 | } 53 | 54 | public double decrementPacketAllowance() { 55 | return packetAllowance--; 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /src/main/java/me/jaden/titanium/listener/BukkitJoinListener.java: -------------------------------------------------------------------------------- 1 | package me.jaden.titanium.listener; 2 | 3 | import me.jaden.titanium.Titanium; 4 | import me.jaden.titanium.data.DataManager; 5 | import org.bukkit.event.EventHandler; 6 | import org.bukkit.event.Listener; 7 | import org.bukkit.event.player.PlayerJoinEvent; 8 | 9 | 10 | public class BukkitJoinListener implements Listener { 11 | private final Titanium titanium = Titanium.getPlugin(); 12 | 13 | @EventHandler(ignoreCancelled = true) 14 | void onJoin(PlayerJoinEvent event) { 15 | DataManager dataManager = this.titanium.getDataManager(); 16 | 17 | if (event.getPlayer().hasPermission(this.titanium.getTitaniumConfig().getPermissionsConfig().getNotificationPermission()) || event.getPlayer().isOp()) { 18 | dataManager.getPlayerData().keySet().stream() 19 | .filter(user -> user.getUUID().equals(event.getPlayer().getUniqueId())).findFirst() 20 | .ifPresent(user -> dataManager.getPlayerData(user).setReceivingAlerts(true)); 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/main/java/me/jaden/titanium/settings/CreativeConfig.java: -------------------------------------------------------------------------------- 1 | package me.jaden.titanium.settings; 2 | 3 | import com.google.common.collect.ImmutableMap; 4 | import lombok.Getter; 5 | import org.bukkit.configuration.file.FileConfiguration; 6 | 7 | @Getter 8 | public class CreativeConfig { 9 | private final boolean enabled; 10 | private final boolean allowNegativeAmplifiers; 11 | private final int maxPotionEffectAmplifier; 12 | private final int maxPotionEffectDuration; 13 | private final int maxPotionEffects; 14 | private final int maxRecursions; 15 | private final int maxItems; 16 | private final int maxEnchantmentLevel; 17 | 18 | public CreativeConfig(FileConfiguration configuration) { 19 | configuration.addDefaults(ImmutableMap.builder() 20 | .put("creative.enabled", false) 21 | .put("creative.potions.max-potion-effects", 5) 22 | .put("creative.potions.max-potion-effect-duration-ticks", 9600) 23 | .put("creative.potions.max-potion-effect-amplifier", 10) 24 | .put("creative.potions.allow-negative-effect-amplifier", false) 25 | .put("creative.max-nbt-recursions", 10) 26 | .put("creative.max-items-in-containers", 54) 27 | .put("creative.enchantments.max-level", 5) 28 | .build()); 29 | this.enabled = configuration.getBoolean("creative.enabled", false); 30 | this.maxPotionEffects = configuration.getInt("creative.potions.max-potion-effects", 5); 31 | this.allowNegativeAmplifiers = configuration.getBoolean("creative.potions.allow-negative-effect-amplifier", false); 32 | this.maxPotionEffectDuration = configuration.getInt("creative.potions.max-potion-effect-duration-ticks", 9600); 33 | this.maxPotionEffectAmplifier = configuration.getInt("creative.potions.max-potion-effect-amplifier", 10); 34 | this.maxRecursions = configuration.getInt("creative.max-nbt-recursions", 10); 35 | this.maxItems = configuration.getInt("creative.max-items-in-containers", 54); 36 | this.maxEnchantmentLevel = configuration.getInt("creative.enchantments.max-level", 5); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /src/main/java/me/jaden/titanium/settings/MessagesConfig.java: -------------------------------------------------------------------------------- 1 | package me.jaden.titanium.settings; 2 | 3 | import com.google.common.collect.ImmutableMap; 4 | import io.github.retrooper.packetevents.adventure.serializer.legacy.LegacyComponentSerializer; 5 | import lombok.Getter; 6 | import me.jaden.titanium.Titanium; 7 | import net.kyori.adventure.text.Component; 8 | import org.bukkit.ChatColor; 9 | import org.bukkit.configuration.file.FileConfiguration; 10 | 11 | public class MessagesConfig { 12 | private final String staffNotification; 13 | private final String staffNotificationInfo; 14 | private final String disconnectMessage; 15 | private final String blockedCommandMessage; 16 | 17 | @Getter 18 | private final LegacyComponentSerializer componentSerializer; 19 | 20 | public MessagesConfig(FileConfiguration configuration) { 21 | configuration.addDefaults(ImmutableMap.builder() 22 | .put("messages.staff-notification", "&7(&eTitanium&7) &8» &f%player% &7disconnected for flagging &f%checkname%") 23 | .put("messages.staff-notification-info", "&7(&e%info%&7)") 24 | .put("messages.disconnect-message", "&7(&eTitanium&7) &8» &fYou have been disconnected due \n&fto sending harmful packets.") 25 | .put("messages.blocked-command-message", "Unknown command. Type \"/help\" for help.") 26 | .build()); 27 | 28 | this.staffNotification = configuration.getString("messages.staff-notification", "&7(&eTitanium&7) &8» &f%player% &7disconnected for flagging &f%checkname%"); 29 | this.staffNotificationInfo = configuration.getString("messages.staff-notication-info", "&7(&e%info%&7)"); 30 | this.disconnectMessage = configuration.getString("messages.disconnect-message", "&7(&eTitanium&7) &8» &fYou have been disconnected due \n&fto sending harmful packets."); 31 | this.blockedCommandMessage = configuration.getString("messages.blocked-command-message", "Unknown command. Type \"/help\" for help."); 32 | 33 | this.componentSerializer = Titanium.getPlugin().getComponentSerializer(); 34 | } 35 | 36 | public Component getNotification(String playerName, String checkName, String info) { 37 | Component notification = componentSerializer.deserialize(staffNotification.replaceAll("%player%", playerName).replaceAll("%checkname%", checkName)); 38 | 39 | if (!info.equals("")) { 40 | return notification.append(this.getInfo(info)); 41 | } else { 42 | return notification; 43 | } 44 | } 45 | 46 | private Component getInfo(String info) { 47 | return componentSerializer.deserialize(staffNotificationInfo.replaceAll("%info%", info)); 48 | } 49 | 50 | public Component getKickMessage(String checkName) { 51 | return componentSerializer.deserialize( 52 | disconnectMessage.replaceAll("%checkname%", checkName) 53 | ); 54 | } 55 | 56 | public Component getBlockedCommandMessage() { 57 | return componentSerializer.deserialize(blockedCommandMessage); 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /src/main/java/me/jaden/titanium/settings/PermissionsConfig.java: -------------------------------------------------------------------------------- 1 | package me.jaden.titanium.settings; 2 | 3 | import com.google.common.collect.ImmutableMap; 4 | import lombok.Getter; 5 | import org.bukkit.configuration.file.FileConfiguration; 6 | 7 | @Getter 8 | public class PermissionsConfig { 9 | private final String commandBypassPermission; 10 | private final String notificationPermission; 11 | 12 | public PermissionsConfig(FileConfiguration configuration) { 13 | configuration.addDefaults(ImmutableMap.builder() 14 | .put("permissions.commandbypass", "titanium.commandbypass") 15 | .put("permissions.notification", "titanium.notification") 16 | .build()); 17 | 18 | this.commandBypassPermission = configuration.getString("permissions.commandbypass"); 19 | this.notificationPermission = configuration.getString("permissions.notification"); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/main/java/me/jaden/titanium/settings/TitaniumConfig.java: -------------------------------------------------------------------------------- 1 | package me.jaden.titanium.settings; 2 | 3 | import com.github.retrooper.packetevents.protocol.packettype.PacketType; 4 | import com.github.retrooper.packetevents.protocol.packettype.PacketTypeCommon; 5 | import com.google.common.collect.ImmutableMap; 6 | import java.util.Arrays; 7 | import java.util.HashMap; 8 | import java.util.List; 9 | import java.util.Map; 10 | import lombok.Getter; 11 | import lombok.Setter; 12 | import me.jaden.titanium.Titanium; 13 | import org.bukkit.configuration.file.FileConfiguration; 14 | 15 | @Getter 16 | @Setter 17 | public class TitaniumConfig { 18 | @Getter 19 | private static TitaniumConfig instance; 20 | 21 | private final MessagesConfig messagesConfig; 22 | private final PermissionsConfig permissionsConfig; 23 | private final CreativeConfig creativeConfig; 24 | 25 | private final int maxPacketsPerSecond; 26 | 27 | private final int maxExplosions; 28 | 29 | private final int maxSignCharactersPerLine; 30 | 31 | private final boolean noBooks; 32 | private final int maxBookPageSize; 33 | private final double maxBookTotalSizeMultiplier; 34 | 35 | private final int maxBytes; 36 | private final int maxBytesPerSecond; 37 | private final List disabledChecks; 38 | 39 | private List disallowedCommands; 40 | 41 | private Map multipliedPackets = new HashMap<>(); 42 | 43 | private boolean onlyNecessaryKicks; 44 | 45 | public TitaniumConfig(Titanium plugin) { 46 | instance = this; 47 | 48 | plugin.saveDefaultConfig(); 49 | 50 | FileConfiguration configuration = plugin.getConfig(); 51 | this.messagesConfig = new MessagesConfig(configuration); 52 | this.permissionsConfig = new PermissionsConfig(configuration); 53 | this.creativeConfig = new CreativeConfig(configuration); 54 | 55 | configuration.addDefaults(ImmutableMap.builder() 56 | 57 | .put("limits.max-packets-per-second", 1000) 58 | .put("limits.max-bytes", 64000) 59 | 60 | .put("fireworks.max-explosions", 25) 61 | 62 | .put("signs.max-characters-per-line", 16) 63 | 64 | .put("books.max-book-page-size", 2560) 65 | .put("books.max-book-total-size-multiplier", 0.98D) 66 | .put("books.no-books", false) 67 | 68 | .put("spam.multipliers", 69 | ImmutableMap.builder() 70 | .put("PLAYER_POSITION", 0.5D) 71 | .put("PLAYER_POSITION_AND_ROTATION", 0.5D) 72 | .put("PLAYER_ROTATION", 0.5D) 73 | .put("PLAYER_FLYING", 0.5D) 74 | .put("HELD_ITEM_CHANGE", 1.0D) 75 | .put("ANIMATION", 1.0D) 76 | .build() 77 | ) 78 | 79 | .put("commands", Arrays.asList( 80 | "//calc", 81 | "//calculate", 82 | "//eval", 83 | "//evaluate", 84 | "//solve", 85 | "//asc", 86 | "//ascend", 87 | "//desc", 88 | "//descend", 89 | "/to", 90 | "/hd readtext", 91 | "/hologram readtext", 92 | "/holographicdisplays readtext", 93 | "/pex promote", 94 | "/pex demote", 95 | "/promote", 96 | "/demote", 97 | "/execute" 98 | ) 99 | ) 100 | .put("options.only-necessary-kicks", true) 101 | .build()); 102 | 103 | this.maxPacketsPerSecond = configuration.getInt("limits.max-packets-per-second", 1000); 104 | this.maxBytes = configuration.getInt("limits.max-bytes", 64000); 105 | this.maxBytesPerSecond = configuration.getInt("limits.max-bytes-per-second", 64000); 106 | 107 | this.maxExplosions = configuration.getInt("fireworks.max-explosions", 25); 108 | 109 | this.maxSignCharactersPerLine = configuration.getInt("signs.max-characters-per-line", 16); 110 | 111 | this.maxBookPageSize = configuration.getInt("books.max-book-page-size", 2560); 112 | this.maxBookTotalSizeMultiplier = configuration.getDouble("books.max-book-page-size", 0.98D); 113 | this.noBooks = configuration.getBoolean("books.no-books", false); 114 | 115 | Map multiplierMap = configuration.getConfigurationSection("spam.multipliers").getValues(false); 116 | multiplierMap.forEach((packetType, multiplier) -> { 117 | String normalizedPacketType = packetType.toUpperCase().replace(" ", "_"); 118 | this.multipliedPackets.put(PacketType.Play.Client.valueOf(normalizedPacketType), (Double) multiplier); 119 | }); 120 | 121 | this.disallowedCommands = configuration.getStringList("commands"); 122 | this.disabledChecks = configuration.getStringList("disabled-checks"); 123 | } 124 | } 125 | -------------------------------------------------------------------------------- /src/main/java/me/jaden/titanium/util/Ticker.java: -------------------------------------------------------------------------------- 1 | package me.jaden.titanium.util; 2 | 3 | import com.github.retrooper.packetevents.protocol.packettype.PacketType; 4 | import lombok.Getter; 5 | import me.jaden.titanium.Titanium; 6 | import me.jaden.titanium.data.DataManager; 7 | import me.jaden.titanium.data.PlayerData; 8 | import me.jaden.titanium.settings.TitaniumConfig; 9 | import org.bukkit.scheduler.BukkitTask; 10 | 11 | @Getter 12 | public class Ticker { 13 | @Getter 14 | private static Ticker instance; 15 | 16 | private int currentTick; 17 | 18 | private final BukkitTask task; 19 | 20 | private long lastReset; 21 | 22 | public Ticker() { 23 | instance = this; 24 | 25 | Titanium plugin = Titanium.getPlugin(); 26 | plugin.getServer().getScheduler().runTaskTimerAsynchronously(plugin, () -> currentTick++, 1, 1); 27 | 28 | this.task = plugin.getServer().getScheduler().runTaskTimerAsynchronously(plugin, () -> { 29 | double maxPacketsPerSecond = TitaniumConfig.getInstance().getMaxPacketsPerSecond(); 30 | double maxPacketAllowance = maxPacketsPerSecond * 2; 31 | 32 | for (PlayerData value : DataManager.getInstance().getPlayerData().values()) { 33 | // value.setPacketAllowance(Math.min(maxPacketAllowance, value.getPacketAllowance() + maxPacketsPerSecond)); 34 | value.setPacketAllowance(maxPacketAllowance); 35 | value.setPacketCount(0); 36 | value.setBytesSent(0); 37 | } 38 | 39 | this.lastReset = System.currentTimeMillis(); 40 | }, 0, 20); 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /src/main/resources/config.yml: -------------------------------------------------------------------------------- 1 | fireworks: 2 | max-explosions: 25 3 | signs: 4 | max-characters-per-line: 20 5 | books: 6 | max-book-page-size: 2560 7 | max-book-total-size-multiplier: 0.98 8 | 9 | ## Enable this if you don't need any book functionality on your server. 10 | no-books: false 11 | 12 | creative: 13 | ## This can stay disabled unless you give untrustworthy players creative. 14 | ## If you have any issues with the creative checks, please make a ticket in our 15 | ## support Discord @ discord.strafe.us or discord.gg/xAEnAUMv9a 16 | enabled: false 17 | 18 | ## The creative check also checks nbt data nested in block entity tags (containers) 19 | ## This prevents exploiters from bypassing creative checks by creating containers with the exploit item in it 20 | ## This value is for the maximum recursion calls, the check is allowed to do per item 21 | ## If a player reaches a value higher than this, they get kicked. 22 | ## Increase if false positives occur, too high values could lead to exploitation of the check. Therefore, keep as low as possible. 23 | max-nbt-recursions: 10 24 | 25 | ## How many items in tags is a block entity tag (container) allowed to contain? 26 | ## This is to prevent exploiters from sending very large containers, crashing the creative checks. 27 | ## Same as with max nbt recursions, only increase if false positives occur and do not increase too high. 28 | max-items-in-containers: 54 29 | 30 | ## Limit all enchantments to a maximum level? 31 | ## This prevents exploiters from creating hacked items with very high enchantments. 32 | ## Increase max level or set to -1 to disable 33 | enchantments: 34 | max-level: 5 35 | 36 | ## These are the limits for potions that players can create in creative mode. 37 | ## This prevents exploiters from creating troll potions, (creative) kill potions etc. 38 | potions: 39 | max-potion-effects: 5 40 | max-potion-effect-duration-ticks: 9600 41 | max-potion-effect-amplifier: 10 42 | allow-negative-effect-amplifier: false 43 | 44 | limits: 45 | ## There is no perfect value for this. 46 | ## In order to prevent people getting kicked for lag, the max PPS is higher than shown below. 47 | ## Every server is different, you'll have to find a good value yourself. 48 | ## I got this value by assuming a player is clicking 20 CPS, moving, and receiving 2 transactions a tick. 49 | ## I am also assuming a player could possibly lagspike for 15 seconds, allowing them to send 1200 packets in one second. 50 | max-packets-per-second: 500 51 | 52 | ## This is the maximum readable bytes a ByteBuf is allowed to contain. 53 | ## You might want this lower or higher depending on your server and server version. 54 | ## Every server is different, you'll have to find a good value yourself. 55 | ## Set to -1 to disable 56 | ## This value is doubled internally for 1.7 players due to them not having packet compression as far as I'm aware, I could be wrong. 57 | max-bytes: 64000 58 | max-bytes-per-second: 256000 59 | spam: 60 | ## Packet names can be found @ https://wiki.vg/Protocol in the Serverbound section. 61 | ## Valid format: HELD_ITEM_CHANGE or HELD ITEM CHANGE (Capitalization does not matter.) 62 | multipliers: 63 | PLAYER_POSITION: 0.5 64 | PLAYER_POSITION_AND_ROTATION: 0.5 65 | PLAYER_ROTATION: 0.5 66 | PLAYER_FLYING: 0.5 67 | 68 | HELD_ITEM_CHANGE: 1.0 69 | ANIMATION: 1.0 70 | 71 | commands: 72 | ## This should be a list of commands you do not want executed on your server. 73 | ## Any chat message or tab completion starting with these will be blocked. 74 | ## Any player with the command-bypass permission set below will be able to use these commands. 75 | ## If a command already has a permission required by that plugin to access it, then you do not need to put it here. 76 | - "//calc" 77 | - "//calculate" 78 | - "//eval" 79 | - "//evaluate" 80 | - "//solve" 81 | - "//asc" 82 | - "//ascend" 83 | - "//desc" 84 | - "//descend" 85 | - "/to" 86 | - "/hd readtext" 87 | - "/holo readtext" 88 | - "/hologram readtext" 89 | - "/holograms readtext" 90 | - "/holographicdisplays readtext" 91 | - "/pex promote" 92 | - "/pex demote" 93 | - "/promote" 94 | - "/demote" 95 | - "/execute" 96 | - "/mvhelp" 97 | - "/mv" 98 | 99 | disabled-checks: 100 | ## Checks can be found here, this is just a simple list. https://github:com/jtJava/Titanium/tree/master/src/main/java/me/jaden/titanium/check/impl 101 | ## I would prefer if you would report issues you have with checks to me, but if you need immediate changes, then you should disable it here. 102 | ## - "SpamA" 103 | 104 | 105 | options: 106 | ## This makes it so players will only be kicked if cancelling the packet will not completely ruin their gameplay or their connection. 107 | only-necessary-kicks: true 108 | 109 | permissions: 110 | command-bypass: "titanium.commandbypass" 111 | notification: "titanium.notification" 112 | 113 | messages: 114 | disconnect-message: "&7(&eTitanium&7) &fYou have been disconnected due \n&fto sending harmful packets." 115 | staff-notification: "&7(&eTitanium&7) &f%player% &7flagged &f%checkname% " 116 | staff-notification-info: "&7(&e%info%&7)" ## This will be added to the end of the above message if there is info present. 117 | blocked-command-message: "Unknown command. Type \"/help\" for help." 118 | -------------------------------------------------------------------------------- /src/main/resources/plugin.yml: -------------------------------------------------------------------------------- 1 | name: Titanium 2 | version: '${project.version}' 3 | main: me.jaden.titanium.Titanium 4 | api-version: 1.13 5 | depend: 6 | - packetevents --------------------------------------------------------------------------------