├── .config └── checkstyle │ ├── checkstyle.xml │ └── suppressions.xml ├── .gitattributes ├── .github └── workflows │ ├── build.yml │ └── release.yml ├── .gitignore ├── HEADER.txt ├── LICENSE ├── README.md ├── VERSION ├── build.gradle ├── gradle.properties ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── settings.gradle └── src └── main └── java └── net └── elytrium └── velocitytools ├── Settings.java ├── VelocityTools.java ├── commands ├── AlertCommand.java ├── FindCommand.java ├── HubCommand.java ├── RatelimitedCommand.java ├── SendCommand.java └── VelocityToolsCommand.java ├── handlers └── HostnamesManagerHandler.java ├── hooks ├── ChannelInitializerHook.java ├── HandshakeHook.java ├── HooksInitializer.java ├── PacketHook.java └── PluginMessageHook.java ├── listeners ├── BrandChangerPingListener.java ├── ProtocolBlockerJoinListener.java └── ProtocolBlockerPingListener.java └── utils ├── ProtocolUtil.java └── WhitelistUtil.java /.config/checkstyle/checkstyle.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 64 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 81 | 82 | 83 | 85 | 86 | 87 | 93 | 94 | 95 | 96 | 99 | 100 | 101 | 102 | 103 | 107 | 108 | 109 | 110 | 111 | 113 | 114 | 115 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 136 | 138 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | 167 | 168 | 169 | 170 | 171 | 172 | 173 | 174 | 175 | 176 | 177 | 178 | 179 | 180 | 181 | 182 | 183 | 184 | 186 | 187 | 188 | 190 | 192 | 193 | 194 | 195 | 197 | 198 | 199 | 200 | 202 | 203 | 204 | 205 | 207 | 208 | 209 | 210 | 212 | 213 | 214 | 215 | 217 | 218 | 219 | 220 | 222 | 223 | 224 | 225 | 227 | 228 | 229 | 230 | 232 | 233 | 234 | 235 | 237 | 238 | 239 | 240 | 242 | 243 | 244 | 245 | 247 | 248 | 249 | 250 | 252 | 254 | 256 | 258 | 259 | 260 | 261 | 262 | 263 | 264 | 265 | 266 | 267 | 268 | 269 | 270 | 274 | 275 | 276 | 277 | 278 | 279 | 280 | 281 | 282 | 283 | 284 | 285 | 288 | 289 | 290 | 293 | 294 | 295 | 296 | 302 | 303 | 304 | 305 | 309 | 310 | 311 | 312 | 315 | 316 | 317 | 318 | 319 | 320 | 321 | 322 | 323 | 324 | 325 | 327 | 328 | 329 | 330 | 331 | 332 | 334 | 335 | 336 | 337 | 338 | 339 | 340 | 341 | 342 | 343 | 344 | 345 | 346 | 348 | 349 | 350 | 351 | 354 | 355 | 356 | 357 | 358 | 360 | 361 | 362 | 363 | 364 | 365 | 366 | 367 | 368 | 369 | 370 | 372 | 373 | 374 | 375 | 376 | 377 | 378 | 379 | 380 | 381 | 382 | 383 | 384 | 385 | 386 | 387 | 388 | 389 | -------------------------------------------------------------------------------- /.config/checkstyle/suppressions.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | # 2 | # https://help.github.com/articles/dealing-with-line-endings/ 3 | # 4 | # Linux start script should use lf 5 | /gradlew text eol=lf 6 | 7 | # These are Windows script files and should use crlf 8 | *.bat text eol=crlf 9 | 10 | -------------------------------------------------------------------------------- /.github/workflows/build.yml: -------------------------------------------------------------------------------- 1 | name: Java CI with Gradle 2 | 3 | on: 4 | push: 5 | branches: 6 | - master 7 | pull_request: 8 | branches: 9 | - master 10 | 11 | jobs: 12 | build: 13 | runs-on: ubuntu-latest 14 | steps: 15 | - name: Checkout 16 | uses: actions/checkout@v4.2.2 17 | - name: Set up JDK 18 | uses: actions/setup-java@v4.7.0 19 | with: 20 | distribution: adopt 21 | java-version: 17 22 | - name: Build VelocityTools 23 | run: ./gradlew build 24 | - name: Upload VelocityTools 25 | uses: actions/upload-artifact@v4.6.2 26 | with: 27 | name: VelocityTools 28 | path: "build/libs/*.jar" 29 | - uses: dev-drprasad/delete-tag-and-release@v0.2.1 30 | if: ${{ github.event_name == 'push' }} 31 | with: 32 | delete_release: true 33 | tag_name: dev-build 34 | env: 35 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 36 | - name: Find git version 37 | id: git-version 38 | run: echo "id=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT 39 | - name: Find correct JAR 40 | if: ${{ github.event_name == 'push' }} 41 | id: find-jar 42 | run: | 43 | output="$(find build/libs/ ! -name "*-javadoc.jar" ! -name "*-sources.jar" -type f -printf "%f\n")" 44 | echo "::set-output name=jarname::$output" 45 | - name: Release the build 46 | if: ${{ github.event_name == 'push' }} 47 | uses: ncipollo/release-action@v1 48 | with: 49 | artifacts: build/libs/${{ steps.find-jar.outputs.jarname }} 50 | body: ${{ join(github.event.commits.*.message, '\n') }} 51 | prerelease: true 52 | name: Dev-build ${{ steps.git-version.outputs.id }} 53 | tag: dev-build 54 | - name: Upload to Modrinth 55 | if: ${{ github.event_name == 'push' }} 56 | uses: RubixDev/modrinth-upload@v1.0.0 57 | with: 58 | token: ${{ secrets.MODRINTH_TOKEN }} 59 | file_path: build/libs/${{ steps.find-jar.outputs.jarname }} 60 | name: Dev-build ${{ steps.git-version.outputs.id }} 61 | version: ${{ steps.git-version.outputs.id }} 62 | changelog: ${{ join(github.event.commits.*.message, '\n') }} 63 | game_versions: 1.7.2 64 | release_type: beta 65 | loaders: velocity 66 | featured: false 67 | project_id: 4mehh1CR 68 | -------------------------------------------------------------------------------- /.github/workflows/release.yml: -------------------------------------------------------------------------------- 1 | name: Java CI with Gradle 2 | 3 | on: 4 | release: 5 | types: [published] 6 | 7 | jobs: 8 | build: 9 | runs-on: ubuntu-latest 10 | steps: 11 | - name: Checkout 12 | uses: actions/checkout@v4.2.2 13 | - name: Set up JDK 14 | uses: actions/setup-java@v4.7.0 15 | with: 16 | distribution: adopt 17 | java-version: 17 18 | - name: Build VelocityTools 19 | run: ./gradlew build 20 | - name: Upload VelocityTools 21 | uses: actions/upload-artifact@v4.6.2 22 | with: 23 | name: VelocityTools 24 | path: "build/libs/*.jar" 25 | - name: Find correct JAR 26 | id: find-jar 27 | run: | 28 | output="$(find build/libs/ ! -name "*-javadoc.jar" ! -name "*-sources.jar" -type f -printf "%f\n")" 29 | echo "::set-output name=jarname::$output" 30 | - name: Upload to the GitHub release 31 | uses: actions/upload-release-asset@v1 32 | env: 33 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 34 | with: 35 | upload_url: ${{ github.event.release.upload_url }} 36 | asset_path: build/libs/${{ steps.find-jar.outputs.jarname }} 37 | asset_name: ${{ steps.find-jar.outputs.jarname }} 38 | asset_content_type: application/java-archive 39 | - name: Upload to Modrinth 40 | uses: RubixDev/modrinth-upload@v1.0.0 41 | with: 42 | token: ${{ secrets.MODRINTH_TOKEN }} 43 | file_path: build/libs/${{ steps.find-jar.outputs.jarname }} 44 | name: Release ${{ github.event.release.tag_name }} 45 | version: ${{ github.event.release.tag_name }} 46 | changelog: ${{ github.event.release.body }} 47 | game_versions: 1.7.2 48 | release_type: release 49 | loaders: velocity 50 | featured: true 51 | project_id: 4mehh1CR 52 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # IntelliJ user-specific stuff 2 | .idea/ 3 | *.iml 4 | 5 | # Compiled class file 6 | *.class 7 | 8 | # Log file 9 | *.log 10 | 11 | # Package Files 12 | *.jar 13 | *.zip 14 | *.tar.gz 15 | *.rar 16 | 17 | # Virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml 18 | hs_err_pid* 19 | 20 | *~ 21 | 22 | # Temporary files which can be created if a process still has a handle open of a deleted file 23 | .fuse_hidden* 24 | 25 | # KDE directory preferences 26 | .directory 27 | 28 | # Linux trash folder which might appear on any partition or disk 29 | .Trash-* 30 | 31 | # .nfs files are created when an open file is removed but is still being accessed 32 | .nfs* 33 | 34 | # General 35 | .DS_Store 36 | .AppleDouble 37 | .LSOverride 38 | 39 | # Icon must end with two \r 40 | Icon 41 | 42 | # Thumbnails 43 | ._* 44 | 45 | # Files that might appear in the root of a volume 46 | .DocumentRevisions-V100 47 | .fseventsd 48 | .Spotlight-V100 49 | .TemporaryItems 50 | .Trashes 51 | .VolumeIcon.icns 52 | .com.apple.timemachine.donotpresent 53 | 54 | # Directories potentially created on remote AFP share 55 | .AppleDB 56 | .AppleDesktop 57 | Network Trash Folder 58 | Temporary Items 59 | .apdisk 60 | 61 | # Windows thumbnail cache files 62 | Thumbs.db 63 | Thumbs.db:encryptable 64 | ehthumbs.db 65 | ehthumbs_vista.db 66 | 67 | # Dump file 68 | *.stackdump 69 | 70 | # Folder config file 71 | [Dd]esktop.ini 72 | 73 | # Recycle Bin used on file shares 74 | $RECYCLE.BIN/ 75 | 76 | # Windows Installer files 77 | *.cab 78 | *.msi 79 | *.msix 80 | *.msm 81 | *.msp 82 | 83 | # Windows shortcuts 84 | *.lnk 85 | 86 | # Gradle 87 | .gradle 88 | build/ 89 | 90 | # Gradle Patch 91 | **/build/ 92 | 93 | # Common working directory 94 | run/ 95 | 96 | # Avoid ignoring Gradle wrapper jar file (.jar files are usually ignored) 97 | !gradle-wrapper.jar 98 | -------------------------------------------------------------------------------- /HEADER.txt: -------------------------------------------------------------------------------- 1 | Copyright (C) 2021 - 2025 Elytrium 2 | 3 | This program is free software: you can redistribute it and/or modify 4 | it under the terms of the GNU Affero General Public License as published by 5 | the Free Software Foundation, either version 3 of the License, or 6 | (at your option) any later version. 7 | 8 | This program is distributed in the hope that it will be useful, 9 | but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | GNU Affero General Public License for more details. 12 | 13 | You should have received a copy of the GNU Affero General Public License 14 | along with this program. If not, see . -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | GNU AFFERO GENERAL PUBLIC LICENSE 2 | Version 3, 19 November 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 Affero General Public License is a free, copyleft license for 11 | software and other kinds of works, specifically designed to ensure 12 | cooperation with the community in the case of network server software. 13 | 14 | The licenses for most software and other practical works are designed 15 | to take away your freedom to share and change the works. By contrast, 16 | our General Public Licenses are intended to guarantee your freedom to 17 | share and change all versions of a program--to make sure it remains free 18 | software for all its users. 19 | 20 | When we speak of free software, we are referring to freedom, not 21 | price. Our General Public Licenses are designed to make sure that you 22 | have the freedom to distribute copies of free software (and charge for 23 | them if you wish), that you receive source code or can get it if you 24 | want it, that you can change the software or use pieces of it in new 25 | free programs, and that you know you can do these things. 26 | 27 | Developers that use our General Public Licenses protect your rights 28 | with two steps: (1) assert copyright on the software, and (2) offer 29 | you this License which gives you legal permission to copy, distribute 30 | and/or modify the software. 31 | 32 | A secondary benefit of defending all users' freedom is that 33 | improvements made in alternate versions of the program, if they 34 | receive widespread use, become available for other developers to 35 | incorporate. Many developers of free software are heartened and 36 | encouraged by the resulting cooperation. However, in the case of 37 | software used on network servers, this result may fail to come about. 38 | The GNU General Public License permits making a modified version and 39 | letting the public access it on a server without ever releasing its 40 | source code to the public. 41 | 42 | The GNU Affero General Public License is designed specifically to 43 | ensure that, in such cases, the modified source code becomes available 44 | to the community. It requires the operator of a network server to 45 | provide the source code of the modified version running there to the 46 | users of that server. Therefore, public use of a modified version, on 47 | a publicly accessible server, gives the public access to the source 48 | code of the modified version. 49 | 50 | An older license, called the Affero General Public License and 51 | published by Affero, was designed to accomplish similar goals. This is 52 | a different license, not a version of the Affero GPL, but Affero has 53 | released a new version of the Affero GPL which permits relicensing under 54 | this license. 55 | 56 | The precise terms and conditions for copying, distribution and 57 | modification follow. 58 | 59 | TERMS AND CONDITIONS 60 | 61 | 0. Definitions. 62 | 63 | "This License" refers to version 3 of the GNU Affero General Public License. 64 | 65 | "Copyright" also means copyright-like laws that apply to other kinds of 66 | works, such as semiconductor masks. 67 | 68 | "The Program" refers to any copyrightable work licensed under this 69 | License. Each licensee is addressed as "you". "Licensees" and 70 | "recipients" may be individuals or organizations. 71 | 72 | To "modify" a work means to copy from or adapt all or part of the work 73 | in a fashion requiring copyright permission, other than the making of an 74 | exact copy. The resulting work is called a "modified version" of the 75 | earlier work or a work "based on" the earlier work. 76 | 77 | A "covered work" means either the unmodified Program or a work based 78 | on the Program. 79 | 80 | To "propagate" a work means to do anything with it that, without 81 | permission, would make you directly or secondarily liable for 82 | infringement under applicable copyright law, except executing it on a 83 | computer or modifying a private copy. Propagation includes copying, 84 | distribution (with or without modification), making available to the 85 | public, and in some countries other activities as well. 86 | 87 | To "convey" a work means any kind of propagation that enables other 88 | parties to make or receive copies. Mere interaction with a user through 89 | a computer network, with no transfer of a copy, is not conveying. 90 | 91 | An interactive user interface displays "Appropriate Legal Notices" 92 | to the extent that it includes a convenient and prominently visible 93 | feature that (1) displays an appropriate copyright notice, and (2) 94 | tells the user that there is no warranty for the work (except to the 95 | extent that warranties are provided), that licensees may convey the 96 | work under this License, and how to view a copy of this License. If 97 | the interface presents a list of user commands or options, such as a 98 | menu, a prominent item in the list meets this criterion. 99 | 100 | 1. Source Code. 101 | 102 | The "source code" for a work means the preferred form of the work 103 | for making modifications to it. "Object code" means any non-source 104 | form of a work. 105 | 106 | A "Standard Interface" means an interface that either is an official 107 | standard defined by a recognized standards body, or, in the case of 108 | interfaces specified for a particular programming language, one that 109 | is widely used among developers working in that language. 110 | 111 | The "System Libraries" of an executable work include anything, other 112 | than the work as a whole, that (a) is included in the normal form of 113 | packaging a Major Component, but which is not part of that Major 114 | Component, and (b) serves only to enable use of the work with that 115 | Major Component, or to implement a Standard Interface for which an 116 | implementation is available to the public in source code form. A 117 | "Major Component", in this context, means a major essential component 118 | (kernel, window system, and so on) of the specific operating system 119 | (if any) on which the executable work runs, or a compiler used to 120 | produce the work, or an object code interpreter used to run it. 121 | 122 | The "Corresponding Source" for a work in object code form means all 123 | the source code needed to generate, install, and (for an executable 124 | work) run the object code and to modify the work, including scripts to 125 | control those activities. However, it does not include the work's 126 | System Libraries, or general-purpose tools or generally available free 127 | programs which are used unmodified in performing those activities but 128 | which are not part of the work. For example, Corresponding Source 129 | includes interface definition files associated with source files for 130 | the work, and the source code for shared libraries and dynamically 131 | linked subprograms that the work is specifically designed to require, 132 | such as by intimate data communication or control flow between those 133 | subprograms and other parts of the work. 134 | 135 | The Corresponding Source need not include anything that users 136 | can regenerate automatically from other parts of the Corresponding 137 | Source. 138 | 139 | The Corresponding Source for a work in source code form is that 140 | same work. 141 | 142 | 2. Basic Permissions. 143 | 144 | All rights granted under this License are granted for the term of 145 | copyright on the Program, and are irrevocable provided the stated 146 | conditions are met. This License explicitly affirms your unlimited 147 | permission to run the unmodified Program. The output from running a 148 | covered work is covered by this License only if the output, given its 149 | content, constitutes a covered work. This License acknowledges your 150 | rights of fair use or other equivalent, as provided by copyright law. 151 | 152 | You may make, run and propagate covered works that you do not 153 | convey, without conditions so long as your license otherwise remains 154 | in force. You may convey covered works to others for the sole purpose 155 | of having them make modifications exclusively for you, or provide you 156 | with facilities for running those works, provided that you comply with 157 | the terms of this License in conveying all material for which you do 158 | not control copyright. Those thus making or running the covered works 159 | for you must do so exclusively on your behalf, under your direction 160 | and control, on terms that prohibit them from making any copies of 161 | your copyrighted material outside their relationship with you. 162 | 163 | Conveying under any other circumstances is permitted solely under 164 | the conditions stated below. Sublicensing is not allowed; section 10 165 | makes it unnecessary. 166 | 167 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 168 | 169 | No covered work shall be deemed part of an effective technological 170 | measure under any applicable law fulfilling obligations under article 171 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 172 | similar laws prohibiting or restricting circumvention of such 173 | measures. 174 | 175 | When you convey a covered work, you waive any legal power to forbid 176 | circumvention of technological measures to the extent such circumvention 177 | is effected by exercising rights under this License with respect to 178 | the covered work, and you disclaim any intention to limit operation or 179 | modification of the work as a means of enforcing, against the work's 180 | users, your or third parties' legal rights to forbid circumvention of 181 | technological measures. 182 | 183 | 4. Conveying Verbatim Copies. 184 | 185 | You may convey verbatim copies of the Program's source code as you 186 | receive it, in any medium, provided that you conspicuously and 187 | appropriately publish on each copy an appropriate copyright notice; 188 | keep intact all notices stating that this License and any 189 | non-permissive terms added in accord with section 7 apply to the code; 190 | keep intact all notices of the absence of any warranty; and give all 191 | recipients a copy of this License along with the Program. 192 | 193 | You may charge any price or no price for each copy that you convey, 194 | and you may offer support or warranty protection for a fee. 195 | 196 | 5. Conveying Modified Source Versions. 197 | 198 | You may convey a work based on the Program, or the modifications to 199 | produce it from the Program, in the form of source code under the 200 | terms of section 4, provided that you also meet all of these conditions: 201 | 202 | a) The work must carry prominent notices stating that you modified 203 | it, and giving a relevant date. 204 | 205 | b) The work must carry prominent notices stating that it is 206 | released under this License and any conditions added under section 207 | 7. This requirement modifies the requirement in section 4 to 208 | "keep intact all notices". 209 | 210 | c) You must license the entire work, as a whole, under this 211 | License to anyone who comes into possession of a copy. This 212 | License will therefore apply, along with any applicable section 7 213 | additional terms, to the whole of the work, and all its parts, 214 | regardless of how they are packaged. This License gives no 215 | permission to license the work in any other way, but it does not 216 | invalidate such permission if you have separately received it. 217 | 218 | d) If the work has interactive user interfaces, each must display 219 | Appropriate Legal Notices; however, if the Program has interactive 220 | interfaces that do not display Appropriate Legal Notices, your 221 | work need not make them do so. 222 | 223 | A compilation of a covered work with other separate and independent 224 | works, which are not by their nature extensions of the covered work, 225 | and which are not combined with it such as to form a larger program, 226 | in or on a volume of a storage or distribution medium, is called an 227 | "aggregate" if the compilation and its resulting copyright are not 228 | used to limit the access or legal rights of the compilation's users 229 | beyond what the individual works permit. Inclusion of a covered work 230 | in an aggregate does not cause this License to apply to the other 231 | parts of the aggregate. 232 | 233 | 6. Conveying Non-Source Forms. 234 | 235 | You may convey a covered work in object code form under the terms 236 | of sections 4 and 5, provided that you also convey the 237 | machine-readable Corresponding Source under the terms of this License, 238 | in one of these ways: 239 | 240 | a) Convey the object code in, or embodied in, a physical product 241 | (including a physical distribution medium), accompanied by the 242 | Corresponding Source fixed on a durable physical medium 243 | customarily used for software interchange. 244 | 245 | b) Convey the object code in, or embodied in, a physical product 246 | (including a physical distribution medium), accompanied by a 247 | written offer, valid for at least three years and valid for as 248 | long as you offer spare parts or customer support for that product 249 | model, to give anyone who possesses the object code either (1) a 250 | copy of the Corresponding Source for all the software in the 251 | product that is covered by this License, on a durable physical 252 | medium customarily used for software interchange, for a price no 253 | more than your reasonable cost of physically performing this 254 | conveying of source, or (2) access to copy the 255 | Corresponding Source from a network server at no charge. 256 | 257 | c) Convey individual copies of the object code with a copy of the 258 | written offer to provide the Corresponding Source. This 259 | alternative is allowed only occasionally and noncommercially, and 260 | only if you received the object code with such an offer, in accord 261 | with subsection 6b. 262 | 263 | d) Convey the object code by offering access from a designated 264 | place (gratis or for a charge), and offer equivalent access to the 265 | Corresponding Source in the same way through the same place at no 266 | further charge. You need not require recipients to copy the 267 | Corresponding Source along with the object code. If the place to 268 | copy the object code is a network server, the Corresponding Source 269 | may be on a different server (operated by you or a third party) 270 | that supports equivalent copying facilities, provided you maintain 271 | clear directions next to the object code saying where to find the 272 | Corresponding Source. Regardless of what server hosts the 273 | Corresponding Source, you remain obligated to ensure that it is 274 | available for as long as needed to satisfy these requirements. 275 | 276 | e) Convey the object code using peer-to-peer transmission, provided 277 | you inform other peers where the object code and Corresponding 278 | Source of the work are being offered to the general public at no 279 | charge under subsection 6d. 280 | 281 | A separable portion of the object code, whose source code is excluded 282 | from the Corresponding Source as a System Library, need not be 283 | included in conveying the object code work. 284 | 285 | A "User Product" is either (1) a "consumer product", which means any 286 | tangible personal property which is normally used for personal, family, 287 | or household purposes, or (2) anything designed or sold for incorporation 288 | into a dwelling. In determining whether a product is a consumer product, 289 | doubtful cases shall be resolved in favor of coverage. For a particular 290 | product received by a particular user, "normally used" refers to a 291 | typical or common use of that class of product, regardless of the status 292 | of the particular user or of the way in which the particular user 293 | actually uses, or expects or is expected to use, the product. A product 294 | is a consumer product regardless of whether the product has substantial 295 | commercial, industrial or non-consumer uses, unless such uses represent 296 | the only significant mode of use of the product. 297 | 298 | "Installation Information" for a User Product means any methods, 299 | procedures, authorization keys, or other information required to install 300 | and execute modified versions of a covered work in that User Product from 301 | a modified version of its Corresponding Source. The information must 302 | suffice to ensure that the continued functioning of the modified object 303 | code is in no case prevented or interfered with solely because 304 | modification has been made. 305 | 306 | If you convey an object code work under this section in, or with, or 307 | specifically for use in, a User Product, and the conveying occurs as 308 | part of a transaction in which the right of possession and use of the 309 | User Product is transferred to the recipient in perpetuity or for a 310 | fixed term (regardless of how the transaction is characterized), the 311 | Corresponding Source conveyed under this section must be accompanied 312 | by the Installation Information. But this requirement does not apply 313 | if neither you nor any third party retains the ability to install 314 | modified object code on the User Product (for example, the work has 315 | been installed in ROM). 316 | 317 | The requirement to provide Installation Information does not include a 318 | requirement to continue to provide support service, warranty, or updates 319 | for a work that has been modified or installed by the recipient, or for 320 | the User Product in which it has been modified or installed. Access to a 321 | network may be denied when the modification itself materially and 322 | adversely affects the operation of the network or violates the rules and 323 | protocols for communication across the network. 324 | 325 | Corresponding Source conveyed, and Installation Information provided, 326 | in accord with this section must be in a format that is publicly 327 | documented (and with an implementation available to the public in 328 | source code form), and must require no special password or key for 329 | unpacking, reading or copying. 330 | 331 | 7. Additional Terms. 332 | 333 | "Additional permissions" are terms that supplement the terms of this 334 | License by making exceptions from one or more of its conditions. 335 | Additional permissions that are applicable to the entire Program shall 336 | be treated as though they were included in this License, to the extent 337 | that they are valid under applicable law. If additional permissions 338 | apply only to part of the Program, that part may be used separately 339 | under those permissions, but the entire Program remains governed by 340 | this License without regard to the additional permissions. 341 | 342 | When you convey a copy of a covered work, you may at your option 343 | remove any additional permissions from that copy, or from any part of 344 | it. (Additional permissions may be written to require their own 345 | removal in certain cases when you modify the work.) You may place 346 | additional permissions on material, added by you to a covered work, 347 | for which you have or can give appropriate copyright permission. 348 | 349 | Notwithstanding any other provision of this License, for material you 350 | add to a covered work, you may (if authorized by the copyright holders of 351 | that material) supplement the terms of this License with terms: 352 | 353 | a) Disclaiming warranty or limiting liability differently from the 354 | terms of sections 15 and 16 of this License; or 355 | 356 | b) Requiring preservation of specified reasonable legal notices or 357 | author attributions in that material or in the Appropriate Legal 358 | Notices displayed by works containing it; or 359 | 360 | c) Prohibiting misrepresentation of the origin of that material, or 361 | requiring that modified versions of such material be marked in 362 | reasonable ways as different from the original version; or 363 | 364 | d) Limiting the use for publicity purposes of names of licensors or 365 | authors of the material; or 366 | 367 | e) Declining to grant rights under trademark law for use of some 368 | trade names, trademarks, or service marks; or 369 | 370 | f) Requiring indemnification of licensors and authors of that 371 | material by anyone who conveys the material (or modified versions of 372 | it) with contractual assumptions of liability to the recipient, for 373 | any liability that these contractual assumptions directly impose on 374 | those licensors and authors. 375 | 376 | All other non-permissive additional terms are considered "further 377 | restrictions" within the meaning of section 10. If the Program as you 378 | received it, or any part of it, contains a notice stating that it is 379 | governed by this License along with a term that is a further 380 | restriction, you may remove that term. If a license document contains 381 | a further restriction but permits relicensing or conveying under this 382 | License, you may add to a covered work material governed by the terms 383 | of that license document, provided that the further restriction does 384 | not survive such relicensing or conveying. 385 | 386 | If you add terms to a covered work in accord with this section, you 387 | must place, in the relevant source files, a statement of the 388 | additional terms that apply to those files, or a notice indicating 389 | where to find the applicable terms. 390 | 391 | Additional terms, permissive or non-permissive, may be stated in the 392 | form of a separately written license, or stated as exceptions; 393 | the above requirements apply either way. 394 | 395 | 8. Termination. 396 | 397 | You may not propagate or modify a covered work except as expressly 398 | provided under this License. Any attempt otherwise to propagate or 399 | modify it is void, and will automatically terminate your rights under 400 | this License (including any patent licenses granted under the third 401 | paragraph of section 11). 402 | 403 | However, if you cease all violation of this License, then your 404 | license from a particular copyright holder is reinstated (a) 405 | provisionally, unless and until the copyright holder explicitly and 406 | finally terminates your license, and (b) permanently, if the copyright 407 | holder fails to notify you of the violation by some reasonable means 408 | prior to 60 days after the cessation. 409 | 410 | Moreover, your license from a particular copyright holder is 411 | reinstated permanently if the copyright holder notifies you of the 412 | violation by some reasonable means, this is the first time you have 413 | received notice of violation of this License (for any work) from that 414 | copyright holder, and you cure the violation prior to 30 days after 415 | your receipt of the notice. 416 | 417 | Termination of your rights under this section does not terminate the 418 | licenses of parties who have received copies or rights from you under 419 | this License. If your rights have been terminated and not permanently 420 | reinstated, you do not qualify to receive new licenses for the same 421 | material under section 10. 422 | 423 | 9. Acceptance Not Required for Having Copies. 424 | 425 | You are not required to accept this License in order to receive or 426 | run a copy of the Program. Ancillary propagation of a covered work 427 | occurring solely as a consequence of using peer-to-peer transmission 428 | to receive a copy likewise does not require acceptance. However, 429 | nothing other than this License grants you permission to propagate or 430 | modify any covered work. These actions infringe copyright if you do 431 | not accept this License. Therefore, by modifying or propagating a 432 | covered work, you indicate your acceptance of this License to do so. 433 | 434 | 10. Automatic Licensing of Downstream Recipients. 435 | 436 | Each time you convey a covered work, the recipient automatically 437 | receives a license from the original licensors, to run, modify and 438 | propagate that work, subject to this License. You are not responsible 439 | for enforcing compliance by third parties with this License. 440 | 441 | An "entity transaction" is a transaction transferring control of an 442 | organization, or substantially all assets of one, or subdividing an 443 | organization, or merging organizations. If propagation of a covered 444 | work results from an entity transaction, each party to that 445 | transaction who receives a copy of the work also receives whatever 446 | licenses to the work the party's predecessor in interest had or could 447 | give under the previous paragraph, plus a right to possession of the 448 | Corresponding Source of the work from the predecessor in interest, if 449 | the predecessor has it or can get it with reasonable efforts. 450 | 451 | You may not impose any further restrictions on the exercise of the 452 | rights granted or affirmed under this License. For example, you may 453 | not impose a license fee, royalty, or other charge for exercise of 454 | rights granted under this License, and you may not initiate litigation 455 | (including a cross-claim or counterclaim in a lawsuit) alleging that 456 | any patent claim is infringed by making, using, selling, offering for 457 | sale, or importing the Program or any portion of it. 458 | 459 | 11. Patents. 460 | 461 | A "contributor" is a copyright holder who authorizes use under this 462 | License of the Program or a work on which the Program is based. The 463 | work thus licensed is called the contributor's "contributor version". 464 | 465 | A contributor's "essential patent claims" are all patent claims 466 | owned or controlled by the contributor, whether already acquired or 467 | hereafter acquired, that would be infringed by some manner, permitted 468 | by this License, of making, using, or selling its contributor version, 469 | but do not include claims that would be infringed only as a 470 | consequence of further modification of the contributor version. For 471 | purposes of this definition, "control" includes the right to grant 472 | patent sublicenses in a manner consistent with the requirements of 473 | this License. 474 | 475 | Each contributor grants you a non-exclusive, worldwide, royalty-free 476 | patent license under the contributor's essential patent claims, to 477 | make, use, sell, offer for sale, import and otherwise run, modify and 478 | propagate the contents of its contributor version. 479 | 480 | In the following three paragraphs, a "patent license" is any express 481 | agreement or commitment, however denominated, not to enforce a patent 482 | (such as an express permission to practice a patent or covenant not to 483 | sue for patent infringement). To "grant" such a patent license to a 484 | party means to make such an agreement or commitment not to enforce a 485 | patent against the party. 486 | 487 | If you convey a covered work, knowingly relying on a patent license, 488 | and the Corresponding Source of the work is not available for anyone 489 | to copy, free of charge and under the terms of this License, through a 490 | publicly available network server or other readily accessible means, 491 | then you must either (1) cause the Corresponding Source to be so 492 | available, or (2) arrange to deprive yourself of the benefit of the 493 | patent license for this particular work, or (3) arrange, in a manner 494 | consistent with the requirements of this License, to extend the patent 495 | license to downstream recipients. "Knowingly relying" means you have 496 | actual knowledge that, but for the patent license, your conveying the 497 | covered work in a country, or your recipient's use of the covered work 498 | in a country, would infringe one or more identifiable patents in that 499 | country that you have reason to believe are valid. 500 | 501 | If, pursuant to or in connection with a single transaction or 502 | arrangement, you convey, or propagate by procuring conveyance of, a 503 | covered work, and grant a patent license to some of the parties 504 | receiving the covered work authorizing them to use, propagate, modify 505 | or convey a specific copy of the covered work, then the patent license 506 | you grant is automatically extended to all recipients of the covered 507 | work and works based on it. 508 | 509 | A patent license is "discriminatory" if it does not include within 510 | the scope of its coverage, prohibits the exercise of, or is 511 | conditioned on the non-exercise of one or more of the rights that are 512 | specifically granted under this License. You may not convey a covered 513 | work if you are a party to an arrangement with a third party that is 514 | in the business of distributing software, under which you make payment 515 | to the third party based on the extent of your activity of conveying 516 | the work, and under which the third party grants, to any of the 517 | parties who would receive the covered work from you, a discriminatory 518 | patent license (a) in connection with copies of the covered work 519 | conveyed by you (or copies made from those copies), or (b) primarily 520 | for and in connection with specific products or compilations that 521 | contain the covered work, unless you entered into that arrangement, 522 | or that patent license was granted, prior to 28 March 2007. 523 | 524 | Nothing in this License shall be construed as excluding or limiting 525 | any implied license or other defenses to infringement that may 526 | otherwise be available to you under applicable patent law. 527 | 528 | 12. No Surrender of Others' Freedom. 529 | 530 | If conditions are imposed on you (whether by court order, agreement or 531 | otherwise) that contradict the conditions of this License, they do not 532 | excuse you from the conditions of this License. If you cannot convey a 533 | covered work so as to satisfy simultaneously your obligations under this 534 | License and any other pertinent obligations, then as a consequence you may 535 | not convey it at all. For example, if you agree to terms that obligate you 536 | to collect a royalty for further conveying from those to whom you convey 537 | the Program, the only way you could satisfy both those terms and this 538 | License would be to refrain entirely from conveying the Program. 539 | 540 | 13. Remote Network Interaction; Use with the GNU General Public License. 541 | 542 | Notwithstanding any other provision of this License, if you modify the 543 | Program, your modified version must prominently offer all users 544 | interacting with it remotely through a computer network (if your version 545 | supports such interaction) an opportunity to receive the Corresponding 546 | Source of your version by providing access to the Corresponding Source 547 | from a network server at no charge, through some standard or customary 548 | means of facilitating copying of software. This Corresponding Source 549 | shall include the Corresponding Source for any work covered by version 3 550 | of the GNU General Public License that is incorporated pursuant to the 551 | following paragraph. 552 | 553 | Notwithstanding any other provision of this License, you have 554 | permission to link or combine any covered work with a work licensed 555 | under version 3 of the GNU General Public License into a single 556 | combined work, and to convey the resulting work. The terms of this 557 | License will continue to apply to the part which is the covered work, 558 | but the work with which it is combined will remain governed by version 559 | 3 of the GNU General Public License. 560 | 561 | 14. Revised Versions of this License. 562 | 563 | The Free Software Foundation may publish revised and/or new versions of 564 | the GNU Affero General Public License from time to time. Such new versions 565 | will be similar in spirit to the present version, but may differ in detail to 566 | address new problems or concerns. 567 | 568 | Each version is given a distinguishing version number. If the 569 | Program specifies that a certain numbered version of the GNU Affero General 570 | Public License "or any later version" applies to it, you have the 571 | option of following the terms and conditions either of that numbered 572 | version or of any later version published by the Free Software 573 | Foundation. If the Program does not specify a version number of the 574 | GNU Affero General Public License, you may choose any version ever published 575 | by the Free Software Foundation. 576 | 577 | If the Program specifies that a proxy can decide which future 578 | versions of the GNU Affero General Public License can be used, that proxy's 579 | public statement of acceptance of a version permanently authorizes you 580 | to choose that version for the Program. 581 | 582 | Later license versions may give you additional or different 583 | permissions. However, no additional obligations are imposed on any 584 | author or copyright holder as a result of your choosing to follow a 585 | later version. 586 | 587 | 15. Disclaimer of Warranty. 588 | 589 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 590 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 591 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 592 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 593 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 594 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 595 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 596 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 597 | 598 | 16. Limitation of Liability. 599 | 600 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 601 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 602 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 603 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 604 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 605 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 606 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 607 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 608 | SUCH DAMAGES. 609 | 610 | 17. Interpretation of Sections 15 and 16. 611 | 612 | If the disclaimer of warranty and limitation of liability provided 613 | above cannot be given local legal effect according to their terms, 614 | reviewing courts shall apply local law that most closely approximates 615 | an absolute waiver of all civil liability in connection with the 616 | Program, unless a warranty or assumption of liability accompanies a 617 | copy of the Program in return for a fee. 618 | 619 | END OF TERMS AND CONDITIONS 620 | 621 | How to Apply These Terms to Your New Programs 622 | 623 | If you develop a new program, and you want it to be of the greatest 624 | possible use to the public, the best way to achieve this is to make it 625 | free software which everyone can redistribute and change under these terms. 626 | 627 | To do so, attach the following notices to the program. It is safest 628 | to attach them to the start of each source file to most effectively 629 | state the exclusion of warranty; and each file should have at least 630 | the "copyright" line and a pointer to where the full notice is found. 631 | 632 | 633 | Copyright (C) 634 | 635 | This program is free software: you can redistribute it and/or modify 636 | it under the terms of the GNU Affero General Public License as published 637 | by the Free Software Foundation, either version 3 of the License, or 638 | (at your option) any later version. 639 | 640 | This program is distributed in the hope that it will be useful, 641 | but WITHOUT ANY WARRANTY; without even the implied warranty of 642 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 643 | GNU Affero General Public License for more details. 644 | 645 | You should have received a copy of the GNU Affero General Public License 646 | along with this program. If not, see . 647 | 648 | Also add information on how to contact you by electronic and paper mail. 649 | 650 | If your software can interact with users remotely through a computer 651 | network, you should also make sure that it provides a way for users to 652 | get its source. For example, if your program is a web application, its 653 | interface could display a "Source" link that leads users to an archive 654 | of the code. There are many ways you could offer source, and different 655 | solutions will be better for different programs; see section 13 for the 656 | specific requirements. 657 | 658 | You should also get your employer (if you work as a programmer) or school, 659 | if any, to sign a "copyright disclaimer" for the program, if necessary. 660 | For more information on this, and how to apply and follow the GNU AGPL, see 661 | . 662 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | Elytrium 2 | 3 | # VelocityTools 4 | 5 | [![Join our Discord](https://img.shields.io/discord/775778822334709780.svg?logo=discord&label=Discord)](https://ely.su/discord) 6 | ![Modrinth Game Versions](https://img.shields.io/modrinth/game-versions/4mehh1CR?logo=data%3Aimage%2Fpng%3Bbase64%2CiVBORw0KGgoAAAANSUhEUgAAAIkAAAA8CAMAAABl%2FWk9AAABAlBMVEUAAAAApcwAqM4Apc4Ap88Apc4Apc4AqM0Aps0Ap84Apc0ApswApc4Aps0Ap80Aps4Ap80Aps0Ap84Aps0Aps4Aps0EqdAHrNMKrtQNsdcRtNoVttwWtt0buuAbuuAbuuAauuAbuuEauuAbu%2BAbuuAbuuEbu%2BAbuuEau%2BAbuuAbuuEau%2BEauuAbuuAbueAbuuAau%2BEbuuAauuAauuAbuuEauuEau%2BAbuuAau%2BEbu%2BAWtt0bvOAau%2BEZuOEYt94cvOEUtt8YudsVsdYAn90A%2F%2F8CqM8Ap84Bp84Aps0Ap80Aps0Aps0Aps0auuAauuAbuuAbuuAauuAauuAbuuAAps0buuCTPBtaAAAAVHRSTlMAIhwzOj5ESk1aZnB3f4iTnKWqrrW7xMDCxdDa3%2BDc2tbMxcC8uLOvp6KflpCHgXl1b15ZVE5EQDovKSQhHRcRDAgFAgHL1Nne5e30%2FPj08e3q5vwu6%2BLEAAADTUlEQVR42sXXhXLDPAzAcY2ZGcrMzAzjYhK9%2F6N8YA8zW62Xwu9gvOp6yt8JTKmSjXnHA18Jlqn63xAj5IbLGqWWi%2FvH%2BJ2jufwh3oUXPYSGMmlYjFLcN0aRkc%2BJzKACi5DUUSzQBMj22aeuNsxfUTaIjS1qBJkozF3XRS9HBrkczFsGJVwd9vMEcqMazFfLhhIF9vO2Hd%2B5T05n4GAVJJIoEQAmhZ%2BujFl4lYxSH6KYXmY%2Fb4y%2BfevBmIVDEIqiRFTw8%2FGrMQMnIFLuo9iwzg%2FCnz%2B%2F7RnW7YFIACWSwASRm%2BGqXLZAoIASthaPHprojwbh7Xh%2Fkr3NtlrUMsC40UwjVuW1DH%2BVlkaty36exd9uDKn9OUStyKPmQBN6VbbgrxIToybSf5rle0JHrV%2F5iJrQ%2FZtsT1bgbyJTRU1lVd6OdoV23kdc2dnoqkRNa3xETebSUNRjNdvrGcaFoCZ%2BFBsVP6ImNXhRHmUVYKVnWiYyarozVgemioRrQ9U2wA775BxMOr%2Bj5gimCk34kELCnaFqDWCdfXJER80eTLIhvokh4dZQwt%2BJ7jm%2FvoRR40PkG3R%2F6ZXtPV5McrbXZqXcOz1aEUdtGONDiNQHKHXPdo97WQPOStSGJeUCcw%2BzSPz3aEXgt2atBVzHO82W9NpgCX8ATpiGKKaCDh37%2FjIwdQ2F9B8HTx0s4Tvg%2Bz5EyKnjuyFvWzevTxH7Q7DEh0yyYx6C0%2BrAxKYJ7PHGyh%2B1AKDUR8bm5UOYefnjX9tN3J9Y1ztpAiSRlgCmNkKz8ZsxO0cAXT%2BS9CIwOSpq1r3wC4NkawATIaJm3TM7i3Uk%2Bbt8VVzyqFl38H5h0FLAVIaSqFn3fNDmDfUgqV8CJiOJGu14pQNTq42QZG8CE5JEjXIKXVCQQ1oQmKZN%2Fa5xU%2FkgpKWBSapHbQPUtF1IGpT5pqhH7QgUVYZIcrZ4U5Sj1ttvgZo00vxN6KZ1ZO6UotZ7NnvYbwMhjLSBxza7qJ0AoelEwqyjVgdCaYAEMmrqykBJ4VRuZpH3DpACOIXB6wwGWQNaw4YT9dOblq21YJJiH0maP1GDxUigzMgdy9VhcTo%2B%2FG3ojqbLsGh1jRhisQp95Ma%2BWK4Gy1T0DLQlDPEv1X2Xr4VYWO8AAAAASUVORK5CYII%3D) 7 | ![Modrinth Downloads](https://img.shields.io/modrinth/dt/4mehh1CR?logo=data%3Aimage%2Fsvg%2Bxml%3Bbase64%2CPHN2ZyB3aWR0aD0iNTEyIiBoZWlnaHQ9IjUxNCIgdmlld0JveD0iMCAwIDUxMiA1MTQiIGZpbGw9Im5vbmUiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI%2BCiAgPHBhdGggZmlsbC1ydWxlPSJldmVub2RkIiBjbGlwLXJ1bGU9ImV2ZW5vZGQiIGQ9Ik01MDMuMTYgMzIzLjU2QzUxNC41NSAyODEuNDcgNTE1LjMyIDIzNS45MSA1MDMuMiAxOTAuNzZDNDY2LjU3IDU0LjIyOTkgMzI2LjA0IC0yNi44MDAxIDE4OS4zMyA5Ljc3OTkxQzgzLjgxMDEgMzguMDE5OSAxMS4zODk5IDEyOC4wNyAwLjY4OTk0MSAyMzAuNDdINDMuOTlDNTQuMjkgMTQ3LjMzIDExMy43NCA3NC43Mjk4IDE5OS43NSA1MS43MDk4QzMwNi4wNSAyMy4yNTk4IDQxNS4xMyA4MC42Njk5IDQ1My4xNyAxODEuMzhMNDExLjAzIDE5Mi42NUMzOTEuNjQgMTQ1LjggMzUyLjU3IDExMS40NSAzMDYuMyA5Ni44MTk4TDI5OC41NiAxNDAuNjZDMzM1LjA5IDE1NC4xMyAzNjQuNzIgMTg0LjUgMzc1LjU2IDIyNC45MUMzOTEuMzYgMjgzLjggMzYxLjk0IDM0NC4xNCAzMDguNTYgMzY5LjE3TDMyMC4wOSA0MTIuMTZDMzkwLjI1IDM4My4yMSA0MzIuNCAzMTAuMyA0MjIuNDMgMjM1LjE0TDQ2NC40MSAyMjMuOTFDNDY4LjkxIDI1Mi42MiA0NjcuMzUgMjgxLjE2IDQ2MC41NSAzMDguMDdMNTAzLjE2IDMyMy41NloiIGZpbGw9IiMxYmQ5NmEiLz4KICA8cGF0aCBkPSJNMzIxLjk5IDUwNC4yMkMxODUuMjcgNTQwLjggNDQuNzUwMSA0NTkuNzcgOC4xMTAxMSAzMjMuMjRDMy44NDAxMSAzMDcuMzEgMS4xNyAyOTEuMzMgMCAyNzUuNDZINDMuMjdDNDQuMzYgMjg3LjM3IDQ2LjQ2OTkgMjk5LjM1IDQ5LjY3OTkgMzExLjI5QzUzLjAzOTkgMzIzLjggNTcuNDUgMzM1Ljc1IDYyLjc5IDM0Ny4wN0wxMDEuMzggMzIzLjkyQzk4LjEyOTkgMzE2LjQyIDk1LjM5IDMwOC42IDkzLjIxIDMwMC40N0M2OS4xNyAyMTAuODcgMTIyLjQxIDExOC43NyAyMTIuMTMgOTQuNzYwMUMyMjkuMTMgOTAuMjEwMSAyNDYuMjMgODguNDQwMSAyNjIuOTMgODkuMTUwMUwyNTUuMTkgMTMzQzI0NC43MyAxMzMuMDUgMjM0LjExIDEzNC40MiAyMjMuNTMgMTM3LjI1QzE1Ny4zMSAxNTQuOTggMTE4LjAxIDIyMi45NSAxMzUuNzUgMjg5LjA5QzEzNi44NSAyOTMuMTYgMTM4LjEzIDI5Ny4xMyAxMzkuNTkgMzAwLjk5TDE4OC45NCAyNzEuMzhMMTc0LjA3IDIzMS45NUwyMjAuNjcgMTg0LjA4TDI3OS41NyAxNzEuMzlMMjk2LjYyIDE5Mi4zOEwyNjkuNDcgMjE5Ljg4TDI0NS43OSAyMjcuMzNMMjI4Ljg3IDI0NC43MkwyMzcuMTYgMjY3Ljc5QzIzNy4xNiAyNjcuNzkgMjUzLjk1IDI4NS42MyAyNTMuOTggMjg1LjY0TDI3Ny43IDI3OS4zM0wyOTQuNTggMjYwLjc5TDMzMS40NCAyNDkuMTJMMzQyLjQyIDI3My44MkwzMDQuMzkgMzIwLjQ1TDI0MC42NiAzNDAuNjNMMjEyLjA4IDMwOC44MUwxNjIuMjYgMzM4LjdDMTg3LjggMzY3Ljc4IDIyNi4yIDM4My45MyAyNjYuMDEgMzgwLjU2TDI3Ny41NCA0MjMuNTVDMjE4LjEzIDQzMS40MSAxNjAuMSA0MDYuODIgMTI0LjA1IDM2MS42NEw4NS42Mzk5IDM4NC42OEMxMzYuMjUgNDUxLjE3IDIyMy44NCA0ODQuMTEgMzA5LjYxIDQ2MS4xNkMzNzEuMzUgNDQ0LjY0IDQxOS40IDQwMi41NiA0NDUuNDIgMzQ5LjM4TDQ4OC4wNiAzNjQuODhDNDU3LjE3IDQzMS4xNiAzOTguMjIgNDgzLjgyIDMyMS45OSA1MDQuMjJaIiBmaWxsPSIjMWJkOTZhIi8%2BCjwvc3ZnPg%3D%3D) 8 | [![Proxy Stats](https://img.shields.io/bstats/servers/12708?logo=minecraft&label=Servers)](https://bstats.org/plugin/velocity/VelocityTools/12708) 9 | [![Proxy Stats](https://img.shields.io/bstats/players/12708?logo=minecraft&label=Players)](https://bstats.org/plugin/velocity/VelocityTools/12708) 10 | 11 | Some useful tools for Velocity. \ 12 | [Modrinth](https://modrinth.com/plugin/velocitytools) 13 | 14 | ## Features of VelocityTools 15 | 16 | - [Protocol](https://wiki.vg/Protocol_History) Blocker (prohibits connection from certain versions) 17 | - [Hostnames](https://en.wikipedia.org/wiki/Domain_name) Manager (denies connection from a specific hostname, see details below) 18 | - Brand Changer aka Brand Rewriter (changes brand in game and in ping requests) 19 | 20 | ## Commands and permissions 21 | 22 | - ***velocitytools.admin.reload* | /velocitytools reload** - Reload Plugin Command 23 | - ***velocitytools.command.alert* | /alert** - Send Proxy-Wide Alert Command 24 | - ***velocitytools.command.find* | /find** - Find Player Server Command 25 | - ***velocitytools.command.send* | /send** - Send Player to Server Command 26 | - ***velocitytools.command.hub* | /hub** - Hub Command 27 | - ***velocitytools.command.hub.bypass.*** - Disabled-Servers Bypass Permission 28 | 29 | ## Donation 30 | 31 | Your donations are really appreciated. Donations wallets/links/cards: 32 | 33 | - MasterCard Debit Card (Tinkoff Bank): ``5536 9140 0599 1975`` 34 | - Qiwi Wallet: ``PFORG`` or [this link](https://my.qiwi.com/form/Petr-YSpyiLt9c6) 35 | - YooMoney Wallet: ``4100 1721 8467 044`` or [this link](https://yoomoney.ru/quickpay/shop-widget?writer=seller&targets=Donation&targets-hint=&default-sum=&button-text=11&payment-type-choice=on&mobile-payment-type-choice=on&hint=&successURL=&quickpay=shop&account=410017218467044) 36 | - Monero (XMR): 86VQyCz68ApebfFgrzRFAuYLdvd3qG8iT9RHcru9moQkJR9W2Q89Gt3ecFQcFu6wncGwGJsMS9E8Bfr9brztBNbX7Q2rfYS 37 | -------------------------------------------------------------------------------- /VERSION: -------------------------------------------------------------------------------- 1 | 1.2.4 2 | -------------------------------------------------------------------------------- /build.gradle: -------------------------------------------------------------------------------- 1 | plugins() { 2 | id("java") 3 | 4 | id("com.gradleup.shadow").version("8.3.6") 5 | 6 | id("checkstyle") 7 | id("com.github.spotbugs").version("6.1.7") 8 | id("org.cadixdev.licenser").version("0.6.1") 9 | 10 | id("com.github.gmazzo.buildconfig").version("4.1.2") // Kotlin :skull: 11 | } 12 | 13 | this.group = "net.elytrium" 14 | this.version = "1.2.4" 15 | 16 | compileJava() { 17 | sourceCompatibility = 17 18 | targetCompatibility = 17 19 | options.getRelease().set(17) 20 | 21 | options.setEncoding("UTF-8") 22 | } 23 | 24 | repositories() { 25 | mavenCentral() 26 | 27 | maven { 28 | name = "papermc-repo" 29 | url = "https://repo.papermc.io/repository/maven-public/" 30 | } 31 | maven { 32 | name = "elytrium-repo" 33 | url = "https://maven.elytrium.net/repo/" 34 | } 35 | } 36 | 37 | dependencies() { 38 | annotationProcessor("net.java.dev.jna:jna-platform:5.13.0") 39 | 40 | compileOnly("com.github.spotbugs:spotbugs-annotations:4.9.3") 41 | 42 | compileOnly("com.velocitypowered:velocity-api:3.4.0-SNAPSHOT") 43 | annotationProcessor("com.velocitypowered:velocity-api:3.4.0-SNAPSHOT") 44 | compileOnly("com.velocitypowered:velocity-proxy:3.4.0-SNAPSHOT") // From Elytrium Repo. 45 | 46 | // Needs for some velocity methods. 47 | compileOnly("io.netty:netty-transport:4.1.101.Final") 48 | compileOnly("it.unimi.dsi:fastutil-core:8.5.12") 49 | 50 | // To suppress VulnerableLibrariesLocal of velocity-api dependency. 51 | compileOnly("org.yaml:snakeyaml:2.2") 52 | 53 | implementation("net.elytrium.commons:kyori:1.3.0") 54 | implementation("net.elytrium.commons:velocity:1.3.0") 55 | implementation("net.elytrium.commons:utils:1.3.0") 56 | implementation("net.elytrium:serializer:1.1.1") 57 | implementation("net.elytrium:fastprepare:1.0.11") 58 | 59 | implementation("org.bstats:bstats-velocity:3.0.2") 60 | } 61 | 62 | shadowJar() { 63 | archiveClassifier = null 64 | 65 | minimize() 66 | enableRelocation = true 67 | relocationPrefix = "net.elytrium.velocitytools.3rdparty" 68 | } 69 | 70 | checkstyle() { 71 | toolVersion = "10.12.1" 72 | 73 | configFile = file(".config/checkstyle/checkstyle.xml") 74 | configProperties = ["configDirectory": "$rootDir/.config/checkstyle"] 75 | maxErrors = 0 76 | maxWarnings = 0 77 | } 78 | 79 | spotbugsMain() { 80 | reports.register("html") { 81 | required = true 82 | outputLocation.fileValue(file("${project.layout.buildDirectory.get()}/reports/spotbugs/main/spotbugs.html")) 83 | stylesheet = "fancy-hist.xsl" 84 | } 85 | } 86 | 87 | license() { 88 | header = file("HEADER.txt") 89 | 90 | exclude("**/BuildConfig.java") 91 | } 92 | 93 | buildConfig() { 94 | packageName("net.elytrium.velocitytools") 95 | buildConfigField("String", "VERSION", "\"$version\"") 96 | } 97 | 98 | assemble.dependsOn(shadowJar) 99 | -------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- 1 | org.gradle.parallel=true 2 | org.gradle.caching=true 3 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Elytrium/VelocityTools/ebf1cc5ca2d9302a90c63e5b72ad1e4d92ccb5be/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | distributionUrl=https\://services.gradle.org/distributions/gradle-8.13-bin.zip 4 | networkTimeout=10000 5 | validateDistributionUrl=true 6 | zipStoreBase=GRADLE_USER_HOME 7 | zipStorePath=wrapper/dists 8 | -------------------------------------------------------------------------------- /gradlew: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # 4 | # Copyright © 2015-2021 the original authors. 5 | # 6 | # Licensed under the Apache License, Version 2.0 (the "License"); 7 | # you may not use this file except in compliance with the License. 8 | # You may obtain a copy of the License at 9 | # 10 | # https://www.apache.org/licenses/LICENSE-2.0 11 | # 12 | # Unless required by applicable law or agreed to in writing, software 13 | # distributed under the License is distributed on an "AS IS" BASIS, 14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | # See the License for the specific language governing permissions and 16 | # limitations under the License. 17 | # 18 | 19 | ############################################################################## 20 | # 21 | # Gradle start up script for POSIX generated by Gradle. 22 | # 23 | # Important for running: 24 | # 25 | # (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is 26 | # noncompliant, but you have some other compliant shell such as ksh or 27 | # bash, then to run this script, type that shell name before the whole 28 | # command line, like: 29 | # 30 | # ksh Gradle 31 | # 32 | # Busybox and similar reduced shells will NOT work, because this script 33 | # requires all of these POSIX shell features: 34 | # * functions; 35 | # * expansions «$var», «${var}», «${var:-default}», «${var+SET}», 36 | # «${var#prefix}», «${var%suffix}», and «$( cmd )»; 37 | # * compound commands having a testable exit status, especially «case»; 38 | # * various built-in commands including «command», «set», and «ulimit». 39 | # 40 | # Important for patching: 41 | # 42 | # (2) This script targets any POSIX shell, so it avoids extensions provided 43 | # by Bash, Ksh, etc; in particular arrays are avoided. 44 | # 45 | # The "traditional" practice of packing multiple parameters into a 46 | # space-separated string is a well documented source of bugs and security 47 | # problems, so this is (mostly) avoided, by progressively accumulating 48 | # options in "$@", and eventually passing that to Java. 49 | # 50 | # Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS, 51 | # and GRADLE_OPTS) rely on word-splitting, this is performed explicitly; 52 | # see the in-line comments for details. 53 | # 54 | # There are tweaks for specific operating systems such as AIX, CygWin, 55 | # Darwin, MinGW, and NonStop. 56 | # 57 | # (3) This script is generated from the Groovy template 58 | # https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt 59 | # within the Gradle project. 60 | # 61 | # You can find Gradle at https://github.com/gradle/gradle/. 62 | # 63 | ############################################################################## 64 | 65 | # Attempt to set APP_HOME 66 | 67 | # Resolve links: $0 may be a link 68 | app_path=$0 69 | 70 | # Need this for daisy-chained symlinks. 71 | while 72 | APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path 73 | [ -h "$app_path" ] 74 | do 75 | ls=$( ls -ld "$app_path" ) 76 | link=${ls#*' -> '} 77 | case $link in #( 78 | /*) app_path=$link ;; #( 79 | *) app_path=$APP_HOME$link ;; 80 | esac 81 | done 82 | 83 | # This is normally unused 84 | # shellcheck disable=SC2034 85 | APP_BASE_NAME=${0##*/} 86 | # Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) 87 | APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit 88 | 89 | # Use the maximum available, or set MAX_FD != -1 to use that value. 90 | MAX_FD=maximum 91 | 92 | warn () { 93 | echo "$*" 94 | } >&2 95 | 96 | die () { 97 | echo 98 | echo "$*" 99 | echo 100 | exit 1 101 | } >&2 102 | 103 | # OS specific support (must be 'true' or 'false'). 104 | cygwin=false 105 | msys=false 106 | darwin=false 107 | nonstop=false 108 | case "$( uname )" in #( 109 | CYGWIN* ) cygwin=true ;; #( 110 | Darwin* ) darwin=true ;; #( 111 | MSYS* | MINGW* ) msys=true ;; #( 112 | NONSTOP* ) nonstop=true ;; 113 | esac 114 | 115 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 116 | 117 | 118 | # Determine the Java command to use to start the JVM. 119 | if [ -n "$JAVA_HOME" ] ; then 120 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 121 | # IBM's JDK on AIX uses strange locations for the executables 122 | JAVACMD=$JAVA_HOME/jre/sh/java 123 | else 124 | JAVACMD=$JAVA_HOME/bin/java 125 | fi 126 | if [ ! -x "$JAVACMD" ] ; then 127 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 128 | 129 | Please set the JAVA_HOME variable in your environment to match the 130 | location of your Java installation." 131 | fi 132 | else 133 | JAVACMD=java 134 | if ! command -v java >/dev/null 2>&1 135 | then 136 | die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 137 | 138 | Please set the JAVA_HOME variable in your environment to match the 139 | location of your Java installation." 140 | fi 141 | fi 142 | 143 | # Increase the maximum file descriptors if we can. 144 | if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then 145 | case $MAX_FD in #( 146 | max*) 147 | # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked. 148 | # shellcheck disable=SC2039,SC3045 149 | MAX_FD=$( ulimit -H -n ) || 150 | warn "Could not query maximum file descriptor limit" 151 | esac 152 | case $MAX_FD in #( 153 | '' | soft) :;; #( 154 | *) 155 | # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked. 156 | # shellcheck disable=SC2039,SC3045 157 | ulimit -n "$MAX_FD" || 158 | warn "Could not set maximum file descriptor limit to $MAX_FD" 159 | esac 160 | fi 161 | 162 | # Collect all arguments for the java command, stacking in reverse order: 163 | # * args from the command line 164 | # * the main class name 165 | # * -classpath 166 | # * -D...appname settings 167 | # * --module-path (only if needed) 168 | # * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables. 169 | 170 | # For Cygwin or MSYS, switch paths to Windows format before running java 171 | if "$cygwin" || "$msys" ; then 172 | APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) 173 | CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) 174 | 175 | JAVACMD=$( cygpath --unix "$JAVACMD" ) 176 | 177 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 178 | for arg do 179 | if 180 | case $arg in #( 181 | -*) false ;; # don't mess with options #( 182 | /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath 183 | [ -e "$t" ] ;; #( 184 | *) false ;; 185 | esac 186 | then 187 | arg=$( cygpath --path --ignore --mixed "$arg" ) 188 | fi 189 | # Roll the args list around exactly as many times as the number of 190 | # args, so each arg winds up back in the position where it started, but 191 | # possibly modified. 192 | # 193 | # NB: a `for` loop captures its iteration list before it begins, so 194 | # changing the positional parameters here affects neither the number of 195 | # iterations, nor the values presented in `arg`. 196 | shift # remove old arg 197 | set -- "$@" "$arg" # push replacement arg 198 | done 199 | fi 200 | 201 | 202 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 203 | DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' 204 | 205 | # Collect all arguments for the java command: 206 | # * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, 207 | # and any embedded shellness will be escaped. 208 | # * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be 209 | # treated as '${Hostname}' itself on the command line. 210 | 211 | set -- \ 212 | "-Dorg.gradle.appname=$APP_BASE_NAME" \ 213 | -classpath "$CLASSPATH" \ 214 | org.gradle.wrapper.GradleWrapperMain \ 215 | "$@" 216 | 217 | # Stop when "xargs" is not available. 218 | if ! command -v xargs >/dev/null 2>&1 219 | then 220 | die "xargs is not available" 221 | fi 222 | 223 | # Use "xargs" to parse quoted args. 224 | # 225 | # With -n1 it outputs one arg per line, with the quotes and backslashes removed. 226 | # 227 | # In Bash we could simply go: 228 | # 229 | # readarray ARGS < <( xargs -n1 <<<"$var" ) && 230 | # set -- "${ARGS[@]}" "$@" 231 | # 232 | # but POSIX shell has neither arrays nor command substitution, so instead we 233 | # post-process each arg (as a line of input to sed) to backslash-escape any 234 | # character that might be a shell metacharacter, then use eval to reverse 235 | # that process (while maintaining the separation between arguments), and wrap 236 | # the whole thing up as a single "set" statement. 237 | # 238 | # This will of course break if any of these variables contains a newline or 239 | # an unmatched quote. 240 | # 241 | 242 | eval "set -- $( 243 | printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" | 244 | xargs -n1 | 245 | sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' | 246 | tr '\n' ' ' 247 | )" '"$@"' 248 | 249 | exec "$JAVACMD" "$@" 250 | -------------------------------------------------------------------------------- /gradlew.bat: -------------------------------------------------------------------------------- 1 | @rem 2 | @rem Copyright 2015 the original author or authors. 3 | @rem 4 | @rem Licensed under the Apache License, Version 2.0 (the "License"); 5 | @rem you may not use this file except in compliance with the License. 6 | @rem You may obtain a copy of the License at 7 | @rem 8 | @rem https://www.apache.org/licenses/LICENSE-2.0 9 | @rem 10 | @rem Unless required by applicable law or agreed to in writing, software 11 | @rem distributed under the License is distributed on an "AS IS" BASIS, 12 | @rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | @rem See the License for the specific language governing permissions and 14 | @rem limitations under the License. 15 | @rem 16 | 17 | @if "%DEBUG%"=="" @echo off 18 | @rem ########################################################################## 19 | @rem 20 | @rem Gradle startup script for Windows 21 | @rem 22 | @rem ########################################################################## 23 | 24 | @rem Set local scope for the variables with windows NT shell 25 | if "%OS%"=="Windows_NT" setlocal 26 | 27 | set DIRNAME=%~dp0 28 | if "%DIRNAME%"=="" set DIRNAME=. 29 | @rem This is normally unused 30 | set APP_BASE_NAME=%~n0 31 | set APP_HOME=%DIRNAME% 32 | 33 | @rem Resolve any "." and ".." in APP_HOME to make it shorter. 34 | for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi 35 | 36 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 37 | set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" 38 | 39 | @rem Find java.exe 40 | if defined JAVA_HOME goto findJavaFromJavaHome 41 | 42 | set JAVA_EXE=java.exe 43 | %JAVA_EXE% -version >NUL 2>&1 44 | if %ERRORLEVEL% equ 0 goto execute 45 | 46 | echo. 47 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 48 | echo. 49 | echo Please set the JAVA_HOME variable in your environment to match the 50 | echo location of your Java installation. 51 | 52 | goto fail 53 | 54 | :findJavaFromJavaHome 55 | set JAVA_HOME=%JAVA_HOME:"=% 56 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 57 | 58 | if exist "%JAVA_EXE%" goto execute 59 | 60 | echo. 61 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 62 | echo. 63 | echo Please set the JAVA_HOME variable in your environment to match the 64 | echo location of your Java installation. 65 | 66 | goto fail 67 | 68 | :execute 69 | @rem Setup the command line 70 | 71 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 72 | 73 | 74 | @rem Execute Gradle 75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* 76 | 77 | :end 78 | @rem End local scope for the variables with windows NT shell 79 | if %ERRORLEVEL% equ 0 goto mainEnd 80 | 81 | :fail 82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 83 | rem the _cmd.exe /c_ return code! 84 | set EXIT_CODE=%ERRORLEVEL% 85 | if %EXIT_CODE% equ 0 set EXIT_CODE=1 86 | if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% 87 | exit /b %EXIT_CODE% 88 | 89 | :mainEnd 90 | if "%OS%"=="Windows_NT" endlocal 91 | 92 | :omega 93 | -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | this.rootProject.setName("velocity-tools") 2 | -------------------------------------------------------------------------------- /src/main/java/net/elytrium/velocitytools/Settings.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2021 - 2025 Elytrium 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Affero General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Affero General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Affero General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | package net.elytrium.velocitytools; 19 | 20 | import java.util.List; 21 | import net.elytrium.commons.kyori.serialization.Serializers; 22 | import net.elytrium.serializer.annotations.Comment; 23 | import net.elytrium.serializer.annotations.CommentValue; 24 | import net.elytrium.serializer.annotations.Final; 25 | import net.elytrium.serializer.language.object.YamlSerializable; 26 | 27 | public class Settings extends YamlSerializable { 28 | 29 | public static final Settings IMP = new Settings(); 30 | 31 | @Final 32 | public String VERSION = BuildConfig.VERSION; 33 | 34 | @Comment({ 35 | @CommentValue("Available serializers:"), 36 | @CommentValue("LEGACY_AMPERSAND - \"&c&lExample &c&9Text\"."), 37 | @CommentValue("LEGACY_SECTION - \"§c§lExample §c§9Text\"."), 38 | @CommentValue("MINIMESSAGE - \"Example Text\". (https://webui.adventure.kyori.net/)"), 39 | @CommentValue("GSON - \"[{\"text\":\"Example\",\"bold\":true,\"color\":\"red\"},{\"text\":\" \",\"bold\":true},{\"text\":\"Text\",\"bold\":true,\"color\":\"blue\"}]\". (https://minecraft.tools/en/json_text.php/)"), 40 | @CommentValue("GSON_COLOR_DOWNSAMPLING - Same as GSON, but uses downsampling.") 41 | }) 42 | public Serializers SERIALIZER = Serializers.LEGACY_AMPERSAND; 43 | 44 | public MAIN MAIN = new MAIN(); 45 | public COMMANDS COMMANDS = new COMMANDS(); 46 | public TOOLS TOOLS = new TOOLS(); 47 | 48 | public static class MAIN { 49 | 50 | @Comment(@CommentValue("Should this plugin check for new updates?")) 51 | public boolean CHECK_FOR_UPDATES = true; 52 | 53 | @Comment({ 54 | @CommentValue("VelocityTools will consume more RAM if this option is enabled, but compatibility with other plugins will be better"), 55 | @CommentValue("Enable it if you have a plugin installed that bypasses compression (e.g. Geyser)") 56 | }) 57 | public boolean SAVE_UNCOMPRESSED_PACKETS = true; 58 | } 59 | 60 | @Comment({ 61 | @CommentValue("Don't use {NL}, use \\n for new line. Ampersand (&) color codes are supported too.\n"), 62 | @CommentValue(), 63 | @CommentValue("Permissions:"), 64 | @CommentValue(" │"), 65 | @CommentValue(" └── Commands:"), 66 | @CommentValue(" │"), 67 | @CommentValue(" ├── /velocitytools reload"), 68 | @CommentValue(" │ └── velocitytools.admin.reload"), 69 | @CommentValue(" ├── /alert"), 70 | @CommentValue(" │ └── velocitytools.command.alert"), 71 | @CommentValue(" ├── /find"), 72 | @CommentValue(" │ └── velocitytools.command.find"), 73 | @CommentValue(" ├── /send"), 74 | @CommentValue(" │ └── velocitytools.command.send"), 75 | @CommentValue(" └── /hub"), 76 | @CommentValue(" ├── velocitytools.command.hub"), 77 | @CommentValue(" └── velocitytools.command.hub.bypass. (disabled-servers bypass permission)"), 78 | @CommentValue() 79 | }) 80 | public static class COMMANDS { 81 | 82 | public ALERT ALERT = new ALERT(); 83 | public FIND FIND = new FIND(); 84 | public SEND SEND = new SEND(); 85 | public HUB HUB = new HUB(); 86 | 87 | public String RATELIMITED = "&cPlease wait before next usage!"; 88 | 89 | @Comment(@CommentValue("Ratelimit delay in milliseconds")) 90 | public int RATELIMIT_DELAY = 1000; 91 | 92 | public static class ALERT { 93 | 94 | public boolean ENABLED = true; 95 | public String PREFIX = "&8[&4Alert&8] &r{0}"; 96 | public String MESSAGE_NEEDED = "&cYou must supply the message."; 97 | public String EMPTY_PROXY = "&cNo one is connected to this proxy!"; 98 | } 99 | 100 | public static class FIND { 101 | 102 | public boolean ENABLED = true; 103 | public String USERNAME_NEEDED = "&cYou must supply the username."; 104 | public String PLAYER_ONLINE_AT = "&6{0} &fis online at &6{1}"; 105 | public String PLAYER_NOT_ONLINE = "&6{0} &fis not online."; 106 | } 107 | 108 | public static class SEND { 109 | 110 | @Comment(@CommentValue("Velocity already has /send command, so this one is disabled by default to not replace it.")) 111 | public boolean ENABLED = false; 112 | public String CONSOLE = "CONSOLE"; 113 | public String NOT_ENOUGH_ARGUMENTS = "&fNot enough arguments. Usage: &6/send "; 114 | @Comment(@CommentValue("Set to \"\" to disable.")) 115 | public String YOU_GOT_SUMMONED = "&fSummoned to &6{0} &fby &6{1}"; 116 | public String PLAYER_NOT_ONLINE = "&6{0} &fis not online."; 117 | public String CALLBACK = "&aAttempting to send {0} players to {1}"; 118 | public String NOT_ON_SERVER = "&cError: You are not on server."; 119 | } 120 | 121 | public static class HUB { 122 | 123 | public boolean ENABLED = true; 124 | public List SERVERS = List.of("hub-1", "hub-2"); 125 | @Comment(@CommentValue("Set to \"\" to disable.")) 126 | public String YOU_GOT_MOVED = "&aYou have been moved to a hub!"; 127 | public String DISABLED_SERVER = "&cYou cannot use this command here."; 128 | public List DISABLED_SERVERS = List.of("foo", "bar"); 129 | public List ALIASES = List.of("hub", "lobby"); 130 | } 131 | } 132 | 133 | public static class TOOLS { 134 | 135 | @Comment(@CommentValue("Hides the Legacy Ping message.")) 136 | public boolean DISABLE_LEGACY_PING = true; 137 | @Comment(@CommentValue("Hides the \"... provided invalid protocol ...\" message. Helps with some types of attacks. (https://media.discordapp.net/attachments/868930650537857024/921383075454259300/unknown.png)")) 138 | public boolean DISABLE_INVALID_PROTOCOL = true; 139 | 140 | public PROTOCOL_BLOCKER PROTOCOL_BLOCKER = new PROTOCOL_BLOCKER(); 141 | public BRAND_CHANGER BRAND_CHANGER = new BRAND_CHANGER(); 142 | public HOSTNAMES_MANAGER HOSTNAMES_MANAGER = new HOSTNAMES_MANAGER(); 143 | 144 | public static class PROTOCOL_BLOCKER { 145 | 146 | public boolean BLOCK_JOIN = true; 147 | public boolean BLOCK_PING = false; 148 | @Comment(@CommentValue("If true, all protocols except those listed below will be blocked.")) 149 | public boolean WHITELIST = false; 150 | @Comment({ 151 | @CommentValue("You can set either a protocol number here (e.g. '340' for 1.12.2) or a Minecraft version below (e.g. '1.12.2')"), 152 | @CommentValue("You can find a list of protocols here: https://wiki.vg/Protocol_version_numbers"), 153 | }) 154 | public List PROTOCOLS = List.of(9999, 9998); 155 | @Comment({ 156 | @CommentValue("List of versions:"), 157 | @CommentValue("1.7.2, 1.7.6, 1.8, 1.9, 1.9.1, 1.9.2, 1.9.4, 1.10, 1.11, 1.11.1, 1.12, 1.12.1, 1.12.2,"), 158 | @CommentValue("1.13, 1.13.1, 1.13.2, 1.14, 1.14.1, 1.14.2, 1.14.3, 1.14.4, 1.15, 1.15.1, 1.15.2,"), 159 | @CommentValue("1.16, 1.16.1, 1.16.2, 1.16.3, 1.16.4, 1.17, 1.17.1, 1.18, 1.18.2, 1.19, 1.19.1, 1.19.3, 1.19.4,"), 160 | @CommentValue("1.20, 1.20.2, 1.20.3, 1.20.5, 1.21, 1.21.2, 1.21.4, 1.21.5, LATEST"), 161 | }) 162 | public List VERSIONS = List.of("1.7.2"); 163 | public String MINIMUM_VERSION = "1.7.2"; 164 | public String MAXIMUM_VERSION = "LATEST"; 165 | @Comment(@CommentValue("For \"block-ping\" option.")) 166 | public String BRAND = "Version is not supported!"; 167 | @Comment(@CommentValue("For \"block-ping\", set to \"\" to disable.")) 168 | public String MOTD = "&cVersion is not supported!\n&ePlease, join with Minecraft 1.12.2 or newer."; 169 | @Comment(@CommentValue("For \"block-joining\" option.")) 170 | public String KICK_REASON = "&cYour version is unsupported!"; 171 | } 172 | 173 | public static class BRAND_CHANGER { 174 | 175 | public boolean REWRITE_IN_PING = true; 176 | public boolean REWRITE_IN_GAME = true; 177 | public String PING_BRAND = "YourServer 1.12.2-1.21.5"; 178 | @Comment(@CommentValue("For ping.")) 179 | public boolean SHOW_ALWAYS = false; 180 | @Comment(@CommentValue("{0} - Original server brand (e.g. Paper).")) 181 | public String IN_GAME_BRAND = "YourServer ({0})"; 182 | } 183 | 184 | @Comment(@CommentValue("Doesn't work with srv records.")) 185 | public static class HOSTNAMES_MANAGER { 186 | 187 | public boolean BLOCK_JOIN = false; 188 | public boolean BLOCK_PING = false; 189 | @Comment(@CommentValue("Connections IP logging.")) 190 | public boolean DEBUG = false; 191 | @Comment(@CommentValue("For \"debug\" option.")) 192 | public boolean SHOW_BLOCKED_ONLY = false; 193 | @Comment(@CommentValue("For \"block-joining\" option, set to \"\" to show the default reason.")) 194 | public String KICK_REASON = "&cPlease, don't connect to the direct ip!\nUse example.com"; 195 | public boolean WHITELIST = true; 196 | @Comment(@CommentValue("IP Addresses starting with \"127.\" or equal to \"localhost\" will be blocked.")) 197 | public boolean BLOCK_LOCAL_ADDRESSES = false; 198 | @Comment(@CommentValue("DoMaIn.net will be similar to domain.net.")) 199 | public boolean IGNORE_CASE = true; 200 | public List HOSTNAMES = List.of("your-domain.net", "your-domain.com"); 201 | @Comment(@CommentValue("List of IP addresses that will bypass this check.")) 202 | public List IGNORED_IPS = List.of("79.555.*", "228.1337.*"); 203 | } 204 | } 205 | } 206 | -------------------------------------------------------------------------------- /src/main/java/net/elytrium/velocitytools/VelocityTools.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2021 - 2025 Elytrium 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Affero General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Affero General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Affero General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | package net.elytrium.velocitytools; 19 | 20 | import com.google.inject.Inject; 21 | import com.velocitypowered.api.command.Command; 22 | import com.velocitypowered.api.command.CommandMeta; 23 | import com.velocitypowered.api.event.Subscribe; 24 | import com.velocitypowered.api.event.proxy.ProxyInitializeEvent; 25 | import com.velocitypowered.api.plugin.Plugin; 26 | import com.velocitypowered.api.plugin.PluginContainer; 27 | import com.velocitypowered.api.plugin.annotation.DataDirectory; 28 | import com.velocitypowered.api.proxy.ProxyServer; 29 | import com.velocitypowered.proxy.plugin.virtual.VelocityVirtualPlugin; 30 | import com.velocitypowered.proxy.protocol.StateRegistry; 31 | import com.velocitypowered.proxy.util.ratelimit.Ratelimiter; 32 | import com.velocitypowered.proxy.util.ratelimit.Ratelimiters; 33 | import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; 34 | import java.io.IOException; 35 | import java.net.InetAddress; 36 | import java.nio.file.Files; 37 | import java.nio.file.Path; 38 | import java.util.ArrayList; 39 | import java.util.List; 40 | import java.util.Objects; 41 | import java.util.stream.Collectors; 42 | import net.elytrium.commons.kyori.serialization.Serializer; 43 | import net.elytrium.commons.kyori.serialization.Serializers; 44 | import net.elytrium.commons.utils.updates.UpdatesChecker; 45 | import net.elytrium.fastprepare.PreparedPacket; 46 | import net.elytrium.fastprepare.PreparedPacketFactory; 47 | import net.elytrium.velocitytools.commands.AlertCommand; 48 | import net.elytrium.velocitytools.commands.FindCommand; 49 | import net.elytrium.velocitytools.commands.HubCommand; 50 | import net.elytrium.velocitytools.commands.SendCommand; 51 | import net.elytrium.velocitytools.commands.VelocityToolsCommand; 52 | import net.elytrium.velocitytools.hooks.HandshakeHook; 53 | import net.elytrium.velocitytools.hooks.HooksInitializer; 54 | import net.elytrium.velocitytools.listeners.BrandChangerPingListener; 55 | import net.elytrium.velocitytools.listeners.ProtocolBlockerJoinListener; 56 | import net.elytrium.velocitytools.listeners.ProtocolBlockerPingListener; 57 | import net.kyori.adventure.text.Component; 58 | import net.kyori.adventure.text.serializer.ComponentSerializer; 59 | import org.bstats.velocity.Metrics; 60 | import org.checkerframework.checker.nullness.qual.MonotonicNonNull; 61 | import org.slf4j.Logger; 62 | 63 | @Plugin( 64 | id = "velocity-tools", 65 | name = "VelocityTools", 66 | version = BuildConfig.VERSION, 67 | url = "https://elytrium.net/", 68 | authors = { 69 | "Elytrium (https://elytrium.net/)", 70 | } 71 | ) 72 | public class VelocityTools { 73 | 74 | @MonotonicNonNull 75 | private static Logger LOGGER; 76 | @MonotonicNonNull 77 | private static Serializer SERIALIZER; 78 | @MonotonicNonNull 79 | private static Ratelimiter RATELIMITER; 80 | 81 | private final ProxyServer server; 82 | private final Path dataDirectory; 83 | private final Metrics.Factory metricsFactory; 84 | private final PreparedPacketFactory packetFactory; 85 | 86 | @Inject 87 | @SuppressFBWarnings("NP_NULL_ON_SOME_PATH_FROM_RETURN_VALUE") 88 | public VelocityTools(ProxyServer server, @DataDirectory Path dataDirectory, Logger logger, Metrics.Factory metricsFactory) { 89 | setLogger(logger); 90 | 91 | this.server = server; 92 | this.dataDirectory = dataDirectory; 93 | this.metricsFactory = metricsFactory; 94 | 95 | // Pre 1.2.0 migration. 96 | Path oldDataDirectory; 97 | if (Files.notExists(dataDirectory) && Files.exists(oldDataDirectory = dataDirectory.getParent().resolve("velocity_tools"))) { 98 | try { 99 | Files.move(oldDataDirectory, dataDirectory); 100 | } catch (IOException e) { 101 | logger.error("Failed to migrate data from pre-1.2.0", e); 102 | } 103 | } 104 | 105 | Settings.IMP.reload(this.dataDirectory.resolve("config.yml")); 106 | this.packetFactory = new PreparedPacketFactory( 107 | PreparedPacket::new, 108 | StateRegistry.LOGIN, 109 | false, 110 | 1, 111 | 1, 112 | Settings.IMP.MAIN.SAVE_UNCOMPRESSED_PACKETS, 113 | true 114 | ); 115 | 116 | try { 117 | Class.forName("com.velocitypowered.proxy.connection.client.LoginInboundConnection"); 118 | } catch (ClassNotFoundException e) { 119 | LOGGER.error("Please update your Velocity binary to 3.1.0+ version", e); 120 | this.server.shutdown(); 121 | } 122 | } 123 | 124 | @Subscribe 125 | public void onProxyInitialization(ProxyInitializeEvent event) { 126 | this.reload(); 127 | 128 | HooksInitializer.init(this.server); 129 | 130 | if (Settings.IMP.MAIN.CHECK_FOR_UPDATES) { 131 | this.server.getScheduler().buildTask(this, () -> { 132 | if (!UpdatesChecker.checkVersionByURL("https://raw.githubusercontent.com/Elytrium/VelocityTools/master/VERSION", Settings.IMP.VERSION)) { 133 | LOGGER.error("****************************************"); 134 | LOGGER.warn("The new VelocityTools update was found, please update."); 135 | LOGGER.error("https://github.com/Elytrium/VelocityTools/releases/"); 136 | LOGGER.error("****************************************"); 137 | } 138 | }).schedule(); 139 | } 140 | this.metricsFactory.make(this, 12708); 141 | } 142 | 143 | @SuppressFBWarnings(value = "NP_NULL_ON_SOME_PATH", justification = "LEGACY_AMPERSAND can't be null in velocity.") 144 | public void reload() { 145 | // Unregister previously registered commands. 146 | this.unregisterCommands(); 147 | 148 | Settings.IMP.reload(this.dataDirectory.resolve("config.yml")); 149 | 150 | ComponentSerializer serializer = Settings.IMP.SERIALIZER.getSerializer(); 151 | if (serializer == null) { 152 | LOGGER.warn("The specified serializer could not be founded, using default. (LEGACY_AMPERSAND)"); 153 | setSerializer(new Serializer(Objects.requireNonNull(Serializers.LEGACY_AMPERSAND.getSerializer()))); 154 | } else { 155 | setSerializer(new Serializer(serializer)); 156 | } 157 | 158 | setRatelimiter(Ratelimiters.createWithMilliseconds(Settings.IMP.COMMANDS.RATELIMIT_DELAY)); 159 | this.unregisterCommands(); 160 | 161 | List aliases = Settings.IMP.COMMANDS.HUB.ALIASES; 162 | if (Settings.IMP.COMMANDS.HUB.ENABLED && !aliases.isEmpty()) { 163 | this.registerCommand(aliases.get(0), new HubCommand(this.server), aliases.toArray(new String[0])); 164 | } 165 | 166 | if (Settings.IMP.COMMANDS.ALERT.ENABLED) { 167 | this.registerCommand("alert", new AlertCommand(this.server)); 168 | } 169 | 170 | if (Settings.IMP.COMMANDS.FIND.ENABLED) { 171 | this.registerCommand("find", new FindCommand(this.server)); 172 | } 173 | 174 | if (Settings.IMP.COMMANDS.SEND.ENABLED) { 175 | this.registerCommand("send", new SendCommand(this.server)); 176 | } 177 | 178 | this.registerCommand("velocitytools", new VelocityToolsCommand(this), "vtools"); 179 | 180 | this.server.getEventManager().unregisterListeners(this); 181 | 182 | if (Settings.IMP.TOOLS.BRAND_CHANGER.REWRITE_IN_PING) { 183 | this.server.getEventManager().register(this, new BrandChangerPingListener()); 184 | } 185 | 186 | if (Settings.IMP.TOOLS.PROTOCOL_BLOCKER.BLOCK_PING) { 187 | this.server.getEventManager().register(this, new ProtocolBlockerPingListener()); 188 | } 189 | 190 | if (Settings.IMP.TOOLS.PROTOCOL_BLOCKER.BLOCK_JOIN) { 191 | this.server.getEventManager().register(this, new ProtocolBlockerJoinListener()); 192 | } 193 | 194 | HandshakeHook.reload(this.packetFactory); 195 | } 196 | 197 | private void registerCommand(String alias, Command command, String... otherAliases) { 198 | List unregisteredCommands = new ArrayList<>(); 199 | 200 | CommandMeta meta = this.server.getCommandManager().getCommandMeta(alias); 201 | if (meta != null) { 202 | unregisteredCommands.add(meta); 203 | this.server.getCommandManager().unregister(alias); 204 | } 205 | 206 | for (String otherAlias : otherAliases) { 207 | meta = this.server.getCommandManager().getCommandMeta(otherAlias); 208 | if (meta != null) { 209 | unregisteredCommands.add(meta); 210 | this.server.getCommandManager().unregister(otherAlias); 211 | } 212 | } 213 | 214 | if (!unregisteredCommands.isEmpty()) { 215 | getLogger().warn("Unregistered command(s) from other plugin(s): {}", unregisteredCommands.stream().map(commandMeta -> { 216 | String pluginName = "unknown"; 217 | Object plugin = commandMeta.getPlugin(); 218 | if (plugin instanceof VelocityVirtualPlugin) { 219 | pluginName = "Velocity"; 220 | } else if (plugin != null) { 221 | PluginContainer container = this.server.getPluginManager().fromInstance(plugin).orElse(null); 222 | if (container != null && container.getDescription() != null) { 223 | pluginName = container.getDescription().getName().orElse(plugin.toString()); 224 | } 225 | } 226 | 227 | return String.join(", ", commandMeta.getAliases()) + " from " + pluginName; 228 | }).collect(Collectors.joining(", "))); 229 | } 230 | 231 | this.server.getCommandManager().register(this.server.getCommandManager().metaBuilder(alias).plugin(this).aliases(otherAliases).build(), command); 232 | } 233 | 234 | private void unregisterCommands() { 235 | List aliases = Settings.IMP.COMMANDS.HUB.ALIASES; 236 | if (aliases != null) { 237 | aliases.forEach(this::unregisterCommand); 238 | } 239 | this.unregisterCommand("alert"); 240 | this.unregisterCommand("find"); 241 | this.unregisterCommand("send"); 242 | this.unregisterCommand("velocitytools"); 243 | } 244 | 245 | private void unregisterCommand(String command) { 246 | CommandMeta meta = this.server.getCommandManager().getCommandMeta(command); 247 | if (meta != null && meta.getPlugin() == this) { 248 | this.server.getCommandManager().unregister(meta); 249 | } 250 | } 251 | 252 | private static void setLogger(Logger logger) { 253 | LOGGER = logger; 254 | } 255 | 256 | private static void setSerializer(Serializer serializer) { 257 | SERIALIZER = serializer; 258 | } 259 | 260 | private static void setRatelimiter(Ratelimiter ratelimiter) { 261 | RATELIMITER = ratelimiter; 262 | } 263 | 264 | public static Logger getLogger() { 265 | return LOGGER; 266 | } 267 | 268 | public static Serializer getSerializer() { 269 | return SERIALIZER; 270 | } 271 | 272 | public static Ratelimiter getRatelimiter() { 273 | return RATELIMITER; 274 | } 275 | } 276 | -------------------------------------------------------------------------------- /src/main/java/net/elytrium/velocitytools/commands/AlertCommand.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2021 - 2025 Elytrium 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Affero General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Affero General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Affero General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | package net.elytrium.velocitytools.commands; 19 | 20 | import com.velocitypowered.api.command.CommandSource; 21 | import com.velocitypowered.api.command.SimpleCommand; 22 | import com.velocitypowered.api.proxy.Player; 23 | import com.velocitypowered.api.proxy.ProxyServer; 24 | import java.text.MessageFormat; 25 | import net.elytrium.velocitytools.Settings; 26 | import net.elytrium.velocitytools.VelocityTools; 27 | import net.kyori.adventure.text.Component; 28 | 29 | public class AlertCommand implements SimpleCommand { 30 | 31 | private final ProxyServer server; 32 | private final Component messageNeeded; 33 | private final String prefix; 34 | private final Component emptyProxy; 35 | 36 | public AlertCommand(ProxyServer server) { 37 | this.server = server; 38 | this.messageNeeded = VelocityTools.getSerializer().deserialize(Settings.IMP.COMMANDS.ALERT.MESSAGE_NEEDED); 39 | this.prefix = Settings.IMP.COMMANDS.ALERT.PREFIX; 40 | this.emptyProxy = VelocityTools.getSerializer().deserialize(Settings.IMP.COMMANDS.ALERT.EMPTY_PROXY); 41 | } 42 | 43 | @Override 44 | public void execute(SimpleCommand.Invocation invocation) { 45 | CommandSource source = invocation.source(); 46 | String[] args = invocation.arguments(); 47 | 48 | if (args.length == 0) { 49 | source.sendMessage(this.messageNeeded); 50 | } else { 51 | Component component = VelocityTools.getSerializer().deserialize(MessageFormat.format(this.prefix, String.join(" ", args))); 52 | if (this.server.getAllPlayers().size() < 1) { 53 | source.sendMessage(this.emptyProxy); 54 | } else { 55 | if (!(source instanceof Player)) { 56 | source.sendMessage(component); 57 | } 58 | 59 | this.server.getAllPlayers().forEach(player -> player.sendMessage(component)); 60 | } 61 | } 62 | } 63 | 64 | @Override 65 | public boolean hasPermission(SimpleCommand.Invocation invocation) { 66 | return invocation.source().hasPermission("velocitytools.command.alert"); 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /src/main/java/net/elytrium/velocitytools/commands/FindCommand.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2021 - 2025 Elytrium 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Affero General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Affero General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Affero General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | package net.elytrium.velocitytools.commands; 19 | 20 | import com.google.common.collect.ImmutableList; 21 | import com.velocitypowered.api.command.CommandSource; 22 | import com.velocitypowered.api.command.SimpleCommand; 23 | import com.velocitypowered.api.proxy.Player; 24 | import com.velocitypowered.api.proxy.ProxyServer; 25 | import com.velocitypowered.api.proxy.ServerConnection; 26 | import java.text.MessageFormat; 27 | import java.util.List; 28 | import java.util.Optional; 29 | import java.util.stream.Collectors; 30 | import net.elytrium.velocitytools.Settings; 31 | import net.elytrium.velocitytools.VelocityTools; 32 | import net.kyori.adventure.text.Component; 33 | 34 | public class FindCommand implements SimpleCommand { 35 | 36 | private final ProxyServer server; 37 | private final Component usernameNeeded; 38 | private final String playerOnlineAt; 39 | 40 | public FindCommand(ProxyServer server) { 41 | this.server = server; 42 | this.usernameNeeded = VelocityTools.getSerializer().deserialize(Settings.IMP.COMMANDS.FIND.USERNAME_NEEDED); 43 | this.playerOnlineAt = Settings.IMP.COMMANDS.FIND.PLAYER_ONLINE_AT; 44 | } 45 | 46 | @Override 47 | public List suggest(SimpleCommand.Invocation invocation) { 48 | String[] args = invocation.arguments(); 49 | 50 | if (args.length == 0) { 51 | return this.server.getAllPlayers().stream() 52 | .map(Player::getUsername) 53 | .collect(Collectors.toList()); 54 | } else if (args.length == 1) { 55 | return this.server.getAllPlayers().stream() 56 | .map(Player::getUsername) 57 | .filter(name -> name.regionMatches(true, 0, args[0], 0, args[0].length())) 58 | .collect(Collectors.toList()); 59 | } else { 60 | return ImmutableList.of(); 61 | } 62 | } 63 | 64 | @Override 65 | public void execute(SimpleCommand.Invocation invocation) { 66 | CommandSource source = invocation.source(); 67 | String[] args = invocation.arguments(); 68 | 69 | if (args.length == 0) { 70 | source.sendMessage(this.usernameNeeded); 71 | } else { 72 | Optional player = this.server.getPlayer(args[0]); 73 | if (player.isPresent()) { 74 | Player player0 = player.get(); 75 | Optional server = player0.getCurrentServer(); 76 | server.ifPresent(srv -> 77 | source.sendMessage( 78 | VelocityTools.getSerializer().deserialize( 79 | MessageFormat.format(this.playerOnlineAt, player0.getUsername(), srv.getServerInfo().getName()) 80 | ) 81 | ) 82 | ); 83 | } else { 84 | source.sendMessage( 85 | VelocityTools.getSerializer().deserialize(MessageFormat.format(Settings.IMP.COMMANDS.FIND.PLAYER_NOT_ONLINE, args[0])) 86 | ); 87 | } 88 | } 89 | } 90 | 91 | @Override 92 | public boolean hasPermission(SimpleCommand.Invocation invocation) { 93 | return invocation.source().hasPermission("velocitytools.command.find"); 94 | } 95 | } 96 | -------------------------------------------------------------------------------- /src/main/java/net/elytrium/velocitytools/commands/HubCommand.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2021 - 2025 Elytrium 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Affero General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Affero General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Affero General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | package net.elytrium.velocitytools.commands; 19 | 20 | import com.velocitypowered.api.command.CommandSource; 21 | import com.velocitypowered.api.command.SimpleCommand; 22 | import com.velocitypowered.api.proxy.Player; 23 | import com.velocitypowered.api.proxy.ProxyServer; 24 | import com.velocitypowered.api.proxy.server.RegisteredServer; 25 | import com.velocitypowered.proxy.command.builtin.CommandMessages; 26 | import java.util.List; 27 | import net.elytrium.velocitytools.Settings; 28 | import net.elytrium.velocitytools.VelocityTools; 29 | import net.kyori.adventure.text.Component; 30 | 31 | public class HubCommand extends RatelimitedCommand { 32 | 33 | private final ProxyServer server; 34 | private final List servers; 35 | private int serversCounter; 36 | private final Component disabledServer; 37 | private final List disabledServers; 38 | private final String youGotMoved; 39 | private final Component youGotMovedComponent; 40 | 41 | public HubCommand(ProxyServer server) { 42 | this.server = server; 43 | this.servers = Settings.IMP.COMMANDS.HUB.SERVERS; 44 | this.serversCounter = this.servers.size(); 45 | this.disabledServers = Settings.IMP.COMMANDS.HUB.DISABLED_SERVERS; 46 | this.disabledServer = VelocityTools.getSerializer().deserialize(Settings.IMP.COMMANDS.HUB.DISABLED_SERVER); 47 | this.youGotMoved = Settings.IMP.COMMANDS.HUB.YOU_GOT_MOVED; 48 | this.youGotMovedComponent = VelocityTools.getSerializer().deserialize(this.youGotMoved); 49 | } 50 | 51 | @Override 52 | protected void execute(CommandSource source, String[] args) { 53 | if (!(source instanceof Player player)) { 54 | source.sendMessage(CommandMessages.PLAYERS_ONLY); 55 | return; 56 | } 57 | 58 | String serverName; 59 | int serversSize = this.servers.size(); 60 | if (serversSize > 1) { 61 | if (++this.serversCounter >= serversSize) { 62 | this.serversCounter = 0; 63 | } 64 | 65 | serverName = this.servers.get(this.serversCounter); 66 | } else { 67 | serverName = this.servers.get(0); 68 | } 69 | RegisteredServer toConnect = this.server.getServer(serverName).orElse(null); 70 | if (toConnect == null) { 71 | source.sendMessage(CommandMessages.SERVER_DOES_NOT_EXIST.args(Component.text(serverName))); 72 | return; 73 | } 74 | 75 | player.getCurrentServer().ifPresent(serverConnection -> { 76 | String servername = serverConnection.getServer().getServerInfo().getName(); 77 | 78 | if (this.disabledServers.stream().anyMatch(servername::equals) && !player.hasPermission("velocitytools.command.hub.bypass." + servername)) { 79 | player.sendMessage(this.disabledServer); 80 | } else { 81 | player.createConnectionRequest(toConnect).connectWithIndication() 82 | .thenAccept(isSuccessful -> { 83 | if (isSuccessful && !this.youGotMoved.isEmpty()) { 84 | player.sendMessage(this.youGotMovedComponent); 85 | } 86 | }); 87 | } 88 | }); 89 | } 90 | 91 | @Override 92 | public boolean hasPermission(SimpleCommand.Invocation invocation) { 93 | return invocation.source().hasPermission("velocitytools.command.hub"); 94 | } 95 | } 96 | -------------------------------------------------------------------------------- /src/main/java/net/elytrium/velocitytools/commands/RatelimitedCommand.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2021 - 2025 Elytrium 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Affero General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Affero General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Affero General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | package net.elytrium.velocitytools.commands; 19 | 20 | import com.velocitypowered.api.command.CommandSource; 21 | import com.velocitypowered.api.command.SimpleCommand; 22 | import com.velocitypowered.api.proxy.Player; 23 | import net.elytrium.velocitytools.Settings; 24 | import net.elytrium.velocitytools.VelocityTools; 25 | import net.kyori.adventure.text.Component; 26 | 27 | public abstract class RatelimitedCommand implements SimpleCommand { 28 | 29 | private final Component ratelimited; 30 | 31 | public RatelimitedCommand() { 32 | this.ratelimited = VelocityTools.getSerializer().deserialize(Settings.IMP.COMMANDS.RATELIMITED); 33 | } 34 | 35 | @Override 36 | public final void execute(SimpleCommand.Invocation invocation) { 37 | CommandSource source = invocation.source(); 38 | if (source instanceof Player player && !VelocityTools.getRatelimiter().attempt(player.getRemoteAddress().getAddress())) { 39 | source.sendMessage(this.ratelimited); 40 | return; 41 | } 42 | 43 | this.execute(source, invocation.arguments()); 44 | } 45 | 46 | protected abstract void execute(CommandSource source, String[] args); 47 | } 48 | -------------------------------------------------------------------------------- /src/main/java/net/elytrium/velocitytools/commands/SendCommand.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2021 - 2025 Elytrium 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Affero General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Affero General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Affero General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | package net.elytrium.velocitytools.commands; 19 | 20 | import com.google.common.collect.ImmutableList; 21 | import com.velocitypowered.api.command.CommandSource; 22 | import com.velocitypowered.api.command.SimpleCommand; 23 | import com.velocitypowered.api.proxy.Player; 24 | import com.velocitypowered.api.proxy.ProxyServer; 25 | import com.velocitypowered.api.proxy.ServerConnection; 26 | import com.velocitypowered.api.proxy.server.RegisteredServer; 27 | import com.velocitypowered.api.proxy.server.ServerInfo; 28 | import com.velocitypowered.proxy.command.builtin.CommandMessages; 29 | import java.text.MessageFormat; 30 | import java.util.Collection; 31 | import java.util.List; 32 | import java.util.Locale; 33 | import java.util.Optional; 34 | import java.util.stream.Collectors; 35 | import net.elytrium.velocitytools.Settings; 36 | import net.elytrium.velocitytools.VelocityTools; 37 | import net.kyori.adventure.text.Component; 38 | 39 | public class SendCommand implements SimpleCommand { 40 | 41 | private final ProxyServer server; 42 | private final Component notEnoughArguments; 43 | private final String youGotSummoned; 44 | private final String console; 45 | private final String playerNotOnline; 46 | private final String callback; 47 | private final Component notOnServer; 48 | 49 | public SendCommand(ProxyServer server) { 50 | this.server = server; 51 | this.notEnoughArguments = VelocityTools.getSerializer().deserialize(Settings.IMP.COMMANDS.SEND.NOT_ENOUGH_ARGUMENTS); 52 | this.youGotSummoned = Settings.IMP.COMMANDS.SEND.YOU_GOT_SUMMONED; 53 | this.console = Settings.IMP.COMMANDS.SEND.CONSOLE; 54 | this.playerNotOnline = Settings.IMP.COMMANDS.SEND.PLAYER_NOT_ONLINE; 55 | this.callback = Settings.IMP.COMMANDS.SEND.CALLBACK; 56 | this.notOnServer = VelocityTools.getSerializer().deserialize(Settings.IMP.COMMANDS.SEND.NOT_ON_SERVER); 57 | } 58 | 59 | @Override 60 | public List suggest(SimpleCommand.Invocation invocation) { 61 | String[] args = invocation.arguments(); 62 | 63 | if (args.length < 2) { 64 | List players = this.server.getAllPlayers().stream() 65 | .map(Player::getUsername) 66 | .collect(Collectors.toList()); 67 | 68 | List serversNames = this.server.getAllServers().stream() 69 | .map(RegisteredServer::getServerInfo) 70 | .map(ServerInfo::getName) 71 | .collect(Collectors.toList()); 72 | serversNames.add("ALL"); 73 | serversNames.add("CURRENT"); 74 | 75 | players.addAll(serversNames); 76 | 77 | if (args.length == 0) { 78 | return players; 79 | } else { 80 | return players.stream() 81 | .filter(name -> name.regionMatches(true, 0, args[0], 0, args[0].length())) 82 | .collect(Collectors.toList()); 83 | } 84 | } else if (args.length == 2) { 85 | return this.server.getAllServers().stream() 86 | .map(RegisteredServer::getServerInfo) 87 | .map(ServerInfo::getName) 88 | .filter(name -> name.regionMatches(true, 0, args[1], 0, args[1].length())) 89 | .collect(Collectors.toList()); 90 | } else { 91 | return ImmutableList.of(); 92 | } 93 | } 94 | 95 | @Override 96 | public void execute(SimpleCommand.Invocation invocation) { 97 | CommandSource source = invocation.source(); 98 | String[] args = invocation.arguments(); 99 | 100 | if (args.length != 2) { 101 | source.sendMessage(this.notEnoughArguments); 102 | return; 103 | } 104 | 105 | RegisteredServer target = this.server.getServer(args[1]).orElse(null); 106 | if (target == null) { 107 | source.sendMessage(CommandMessages.SERVER_DOES_NOT_EXIST.args(Component.text(args[1]))); 108 | return; 109 | } 110 | 111 | Component summoned = VelocityTools.getSerializer().deserialize(MessageFormat.format( 112 | this.youGotSummoned, 113 | target.getServerInfo().getName(), 114 | ((source instanceof Player) ? ((Player) source).getUsername() : this.console) 115 | )); 116 | 117 | int playersToProccess; 118 | switch (args[0].toLowerCase(Locale.ROOT)) { 119 | case "all" -> { 120 | Collection players = this.server.getAllPlayers(); 121 | playersToProccess = players.size(); 122 | players.forEach(player -> player.createConnectionRequest(target).connectWithIndication().thenAccept(isSuccessful -> { 123 | if (isSuccessful && !this.youGotSummoned.isEmpty()) { 124 | player.sendMessage(summoned); 125 | } 126 | })); 127 | } 128 | case "current" -> { 129 | if (source instanceof Player player) { 130 | Optional currentServer = player.getCurrentServer(); 131 | if (currentServer.isPresent()) { 132 | Collection players = currentServer.get().getServer().getPlayersConnected(); 133 | playersToProccess = players.size(); 134 | players.forEach(next -> next.createConnectionRequest(target).connectWithIndication().thenAccept(isSuccessful -> { 135 | if (isSuccessful && !this.youGotSummoned.isEmpty()) { 136 | next.sendMessage(summoned); 137 | } 138 | })); 139 | } else { 140 | source.sendMessage(this.notOnServer); 141 | return; 142 | } 143 | } else { 144 | source.sendMessage(CommandMessages.PLAYERS_ONLY); 145 | return; 146 | } 147 | } 148 | default -> { 149 | RegisteredServer server = this.server.getServer(args[0]).orElse(null); 150 | if (server == null) { 151 | Player player = this.server.getPlayer(args[0]).orElse(null); 152 | if (player == null) { 153 | source.sendMessage(VelocityTools.getSerializer().deserialize(MessageFormat.format(this.playerNotOnline, args[0]))); 154 | return; 155 | } else { 156 | playersToProccess = 1; 157 | player.createConnectionRequest(target).connectWithIndication().thenAccept(isSuccessful -> { 158 | if (isSuccessful && !this.youGotSummoned.isEmpty()) { 159 | player.sendMessage(summoned); 160 | } 161 | }); 162 | } 163 | } else { 164 | Collection players = server.getPlayersConnected(); 165 | playersToProccess = players.size(); 166 | players.forEach(player -> player.createConnectionRequest(target).connectWithIndication().thenAccept(isSuccessful -> { 167 | if (isSuccessful && !this.youGotSummoned.isEmpty()) { 168 | player.sendMessage(summoned); 169 | } 170 | })); 171 | } 172 | } 173 | } 174 | 175 | source.sendMessage(VelocityTools.getSerializer().deserialize(MessageFormat.format( 176 | this.callback, 177 | playersToProccess, 178 | target.getServerInfo().getName() 179 | ))); 180 | } 181 | 182 | @Override 183 | public boolean hasPermission(SimpleCommand.Invocation invocation) { 184 | return invocation.source().hasPermission("velocitytools.command.send"); 185 | } 186 | } 187 | -------------------------------------------------------------------------------- /src/main/java/net/elytrium/velocitytools/commands/VelocityToolsCommand.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2021 - 2025 Elytrium 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Affero General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Affero General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Affero General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | package net.elytrium.velocitytools.commands; 19 | 20 | import com.google.common.collect.ImmutableList; 21 | import com.velocitypowered.api.command.CommandSource; 22 | import com.velocitypowered.api.command.SimpleCommand; 23 | import java.util.Arrays; 24 | import java.util.List; 25 | import java.util.Locale; 26 | import java.util.stream.Collectors; 27 | import net.elytrium.velocitytools.VelocityTools; 28 | import net.kyori.adventure.text.Component; 29 | import net.kyori.adventure.text.format.NamedTextColor; 30 | 31 | public class VelocityToolsCommand implements SimpleCommand { 32 | 33 | private static final List HELP_MESSAGE = List.of( 34 | Component.text("This server is using VelocityTools.", NamedTextColor.YELLOW), 35 | Component.text("(C) 2021 - 2025 Elytrium", NamedTextColor.YELLOW), 36 | Component.text("https://elytrium.net/github/", NamedTextColor.GREEN), 37 | Component.empty() 38 | ); 39 | 40 | private static final Component AVAILABLE_SUBCOMMANDS_MESSAGE = Component.text("Available subcommands:", NamedTextColor.WHITE); 41 | private static final Component NO_AVAILABLE_SUBCOMMANDS_MESSAGE = Component.text("There is no available subcommands for you.", NamedTextColor.WHITE); 42 | 43 | 44 | public final VelocityTools plugin; 45 | 46 | public VelocityToolsCommand(VelocityTools plugin) { 47 | this.plugin = plugin; 48 | } 49 | 50 | @Override 51 | public List suggest(SimpleCommand.Invocation invocation) { 52 | CommandSource source = invocation.source(); 53 | String[] args = invocation.arguments(); 54 | 55 | if (args.length == 0) { 56 | return Arrays.stream(Subcommand.values()) 57 | .filter(command -> command.hasPermission(source)) 58 | .map(Subcommand::getCommand) 59 | .collect(Collectors.toList()); 60 | } else if (args.length == 1) { 61 | String argument = args[0]; 62 | return Arrays.stream(Subcommand.values()) 63 | .filter(command -> command.hasPermission(source)) 64 | .map(Subcommand::getCommand) 65 | .filter(str -> str.regionMatches(true, 0, argument, 0, argument.length())) 66 | .collect(Collectors.toList()); 67 | } else { 68 | return ImmutableList.of(); 69 | } 70 | } 71 | 72 | @Override 73 | public void execute(SimpleCommand.Invocation invocation) { 74 | CommandSource source = invocation.source(); 75 | String[] args = invocation.arguments(); 76 | 77 | int argsAmount = args.length; 78 | if (argsAmount > 0) { 79 | try { 80 | Subcommand subcommand = Subcommand.valueOf(args[0].toUpperCase(Locale.ROOT)); 81 | if (!subcommand.hasPermission(source)) { 82 | this.showHelp(source); 83 | return; 84 | } 85 | 86 | subcommand.executor.execute(this, source, args); 87 | } catch (IllegalArgumentException e) { 88 | this.showHelp(source); 89 | } 90 | } else { 91 | this.showHelp(source); 92 | } 93 | } 94 | 95 | private void showHelp(CommandSource source) { 96 | HELP_MESSAGE.forEach(source::sendMessage); 97 | 98 | List availableSubcommands = Arrays.stream(Subcommand.values()) 99 | .filter(command -> command.hasPermission(source)) 100 | .collect(Collectors.toList()); 101 | 102 | if (availableSubcommands.size() > 0) { 103 | source.sendMessage(AVAILABLE_SUBCOMMANDS_MESSAGE); 104 | availableSubcommands.forEach(command -> source.sendMessage(command.getMessageLine())); 105 | } else { 106 | source.sendMessage(NO_AVAILABLE_SUBCOMMANDS_MESSAGE); 107 | } 108 | } 109 | 110 | private enum Subcommand { 111 | RELOAD("Reload config.", (VelocityToolsCommand parent, CommandSource source, String[] args) -> { 112 | parent.plugin.reload(); 113 | source.sendMessage(Component.text("§aСonfig reloaded successfully!")); 114 | }); 115 | 116 | private final String command; 117 | private final String description; 118 | private final SubcommandExecutor executor; 119 | 120 | Subcommand(String description, SubcommandExecutor executor) { 121 | this.command = this.name().toLowerCase(Locale.ROOT); 122 | this.description = description; 123 | this.executor = executor; 124 | } 125 | 126 | public boolean hasPermission(CommandSource source) { 127 | return source.hasPermission("velocitytools.admin." + this.command); 128 | } 129 | 130 | public Component getMessageLine() { 131 | return Component.textOfChildren( 132 | Component.text(" /velocitytools " + this.command, NamedTextColor.GREEN), 133 | Component.text(" - ", NamedTextColor.DARK_GRAY), 134 | Component.text(this.description, NamedTextColor.YELLOW) 135 | ); 136 | } 137 | 138 | public String getCommand() { 139 | return this.command; 140 | } 141 | } 142 | 143 | private interface SubcommandExecutor { 144 | void execute(VelocityToolsCommand parent, CommandSource source, String[] args); 145 | } 146 | } 147 | -------------------------------------------------------------------------------- /src/main/java/net/elytrium/velocitytools/handlers/HostnamesManagerHandler.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2021 - 2025 Elytrium 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Affero General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Affero General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Affero General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | package net.elytrium.velocitytools.handlers; 19 | 20 | import com.velocitypowered.proxy.connection.MinecraftConnection; 21 | import com.velocitypowered.proxy.connection.MinecraftSessionHandler; 22 | import com.velocitypowered.proxy.connection.client.HandshakeSessionHandler; 23 | import com.velocitypowered.proxy.protocol.StateRegistry; 24 | import java.lang.reflect.InvocationTargetException; 25 | import java.lang.reflect.Method; 26 | import java.net.InetSocketAddress; 27 | import java.util.List; 28 | import java.util.Locale; 29 | import java.util.regex.Pattern; 30 | import java.util.stream.Collectors; 31 | import net.elytrium.commons.utils.reflection.ReflectionException; 32 | import net.elytrium.velocitytools.Settings; 33 | import net.elytrium.velocitytools.VelocityTools; 34 | import net.elytrium.velocitytools.utils.WhitelistUtil; 35 | 36 | public class HostnamesManagerHandler { 37 | 38 | 39 | private static Method cleanVhost; 40 | private final boolean ignoreCase; 41 | private final boolean blockPing; 42 | private final boolean blockJoin; 43 | private final boolean blockLocal; 44 | private final boolean whitelist; 45 | private final List hostnames; 46 | private final List whitelistedIps; 47 | private final boolean debug; 48 | private final boolean showBlockedOnly; 49 | 50 | public HostnamesManagerHandler() { 51 | this.ignoreCase = Settings.IMP.TOOLS.HOSTNAMES_MANAGER.IGNORE_CASE; 52 | this.blockPing = Settings.IMP.TOOLS.HOSTNAMES_MANAGER.BLOCK_PING; 53 | this.blockJoin = Settings.IMP.TOOLS.HOSTNAMES_MANAGER.BLOCK_JOIN; 54 | this.blockLocal = Settings.IMP.TOOLS.HOSTNAMES_MANAGER.BLOCK_LOCAL_ADDRESSES; 55 | this.whitelist = Settings.IMP.TOOLS.HOSTNAMES_MANAGER.WHITELIST; 56 | this.hostnames = Settings.IMP.TOOLS.HOSTNAMES_MANAGER.HOSTNAMES 57 | .stream() 58 | .map(object -> Pattern.compile("^" + object.replace(".", "\\.").replace("*", ".*") + "$")) 59 | .collect(Collectors.toList()); 60 | this.whitelistedIps = Settings.IMP.TOOLS.HOSTNAMES_MANAGER.IGNORED_IPS 61 | .stream() 62 | .map(object -> Pattern.compile("^" + object.replace(".", "\\.").replace("*", ".*") + "$")) 63 | .collect(Collectors.toList()); 64 | this.debug = Settings.IMP.TOOLS.HOSTNAMES_MANAGER.DEBUG; 65 | this.showBlockedOnly = Settings.IMP.TOOLS.HOSTNAMES_MANAGER.SHOW_BLOCKED_ONLY; 66 | } 67 | 68 | public boolean checkAddress(StateRegistry type, MinecraftConnection connection, MinecraftSessionHandler handler, 69 | String initialServerAddress) throws IllegalAccessException, InvocationTargetException { 70 | String log; 71 | 72 | switch (type) { 73 | case STATUS: { 74 | if (this.blockPing) { 75 | log = "{} is pinging the server using: {}"; 76 | } else { 77 | return false; 78 | } 79 | break; 80 | } 81 | case LOGIN: { 82 | if (this.blockJoin) { 83 | log = "{} is joining the server using: {}"; 84 | } else { 85 | return false; 86 | } 87 | break; 88 | } 89 | default: { 90 | throw new IllegalStateException("Unexpected value: " + type); 91 | } 92 | } 93 | 94 | InetSocketAddress remoteAddress = (InetSocketAddress) connection.getRemoteAddress(); 95 | 96 | String originalServerAddress = (String) cleanVhost.invoke(handler, initialServerAddress); 97 | String serverAddress; 98 | if (this.ignoreCase) { 99 | serverAddress = originalServerAddress.toLowerCase(Locale.ROOT); 100 | } else { 101 | serverAddress = originalServerAddress; 102 | } 103 | 104 | if ((this.blockLocal && (originalServerAddress.startsWith("127.") || originalServerAddress.equalsIgnoreCase("localhost"))) 105 | || (WhitelistUtil.checkForWhitelist(this.whitelist, this.hostnames.stream().anyMatch(pattern -> pattern.matcher(serverAddress).matches())) 106 | && this.whitelistedIps.stream().noneMatch(pattern -> pattern.matcher(remoteAddress.getAddress().getHostAddress()).matches()))) { 107 | this.debugInfo(log + " §c(blocked)", remoteAddress, originalServerAddress, true); 108 | return true; 109 | } else { 110 | this.debugInfo(log, remoteAddress, originalServerAddress, false); 111 | return false; 112 | } 113 | } 114 | 115 | private void debugInfo(String msg, InetSocketAddress remoteAddress, String hostname, boolean blocked) { 116 | if (this.debug) { 117 | if (this.showBlockedOnly && !blocked) { 118 | return; 119 | } 120 | 121 | VelocityTools.getLogger().info(msg, remoteAddress, hostname); 122 | } 123 | } 124 | 125 | private static void init() { 126 | try { 127 | cleanVhost = HandshakeSessionHandler.class.getDeclaredMethod("cleanVhost", String.class); 128 | cleanVhost.setAccessible(true); 129 | } catch (NoSuchMethodException e) { 130 | throw new ReflectionException(e); 131 | } 132 | } 133 | 134 | static { 135 | init(); 136 | } 137 | } 138 | -------------------------------------------------------------------------------- /src/main/java/net/elytrium/velocitytools/hooks/ChannelInitializerHook.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2021 - 2025 Elytrium 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Affero General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Affero General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Affero General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | package net.elytrium.velocitytools.hooks; 19 | 20 | import com.velocitypowered.proxy.network.Connections; 21 | import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; 22 | import io.netty.channel.Channel; 23 | import io.netty.channel.ChannelInitializer; 24 | import io.netty.channel.ChannelPipeline; 25 | import java.lang.invoke.MethodHandle; 26 | import java.lang.invoke.MethodHandles; 27 | import java.lang.invoke.MethodType; 28 | import net.elytrium.velocitytools.Settings; 29 | import org.jetbrains.annotations.NotNull; 30 | 31 | public class ChannelInitializerHook extends ChannelInitializer { 32 | 33 | private static final MethodHandle MH_initChannel; 34 | 35 | private final ChannelInitializer originalInitializer; 36 | 37 | @SuppressFBWarnings("EI_EXPOSE_REP2") 38 | public ChannelInitializerHook(ChannelInitializer originalInitializer) { 39 | this.originalInitializer = originalInitializer; 40 | } 41 | 42 | @Override 43 | protected void initChannel(@NotNull Channel channel) throws Exception { 44 | try { 45 | MH_initChannel.invokeExact(this.originalInitializer, channel); 46 | } catch (Throwable e) { 47 | throw new Exception("failed to initialize channel", e); 48 | } 49 | ChannelPipeline pipeline = channel.pipeline(); 50 | if (Settings.IMP.TOOLS.DISABLE_LEGACY_PING && pipeline.names().contains(Connections.LEGACY_PING_DECODER)) { 51 | pipeline.remove(Connections.LEGACY_PING_DECODER); 52 | } 53 | } 54 | 55 | static { 56 | try { 57 | MH_initChannel = MethodHandles.privateLookupIn(ChannelInitializer.class, MethodHandles.lookup()) 58 | .findVirtual(ChannelInitializer.class, "initChannel", MethodType.methodType(void.class, Channel.class)); 59 | } catch (Throwable e) { 60 | throw new ExceptionInInitializerError(e); 61 | } 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /src/main/java/net/elytrium/velocitytools/hooks/HandshakeHook.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2021 - 2025 Elytrium 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Affero General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Affero General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Affero General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | package net.elytrium.velocitytools.hooks; 19 | 20 | import com.velocitypowered.api.network.ProtocolVersion; 21 | import com.velocitypowered.proxy.connection.MinecraftConnection; 22 | import com.velocitypowered.proxy.connection.MinecraftSessionHandler; 23 | import com.velocitypowered.proxy.connection.client.HandshakeSessionHandler; 24 | import com.velocitypowered.proxy.network.Connections; 25 | import com.velocitypowered.proxy.protocol.MinecraftPacket; 26 | import com.velocitypowered.proxy.protocol.StateRegistry; 27 | import com.velocitypowered.proxy.protocol.packet.DisconnectPacket; 28 | import com.velocitypowered.proxy.protocol.packet.HandshakePacket; 29 | import java.lang.reflect.Field; 30 | import java.lang.reflect.InvocationTargetException; 31 | import java.lang.reflect.Method; 32 | import java.util.function.Supplier; 33 | import net.elytrium.commons.utils.reflection.ReflectionException; 34 | import net.elytrium.fastprepare.PreparedPacket; 35 | import net.elytrium.fastprepare.PreparedPacketFactory; 36 | import net.elytrium.velocitytools.Settings; 37 | import net.elytrium.velocitytools.VelocityTools; 38 | import net.elytrium.velocitytools.handlers.HostnamesManagerHandler; 39 | import net.kyori.adventure.text.Component; 40 | 41 | public class HandshakeHook extends HandshakePacket implements PacketHook { 42 | 43 | private static Method GET_STATE_FOR_PROTOCOL; 44 | private static Field CONNECTION_FIELD; 45 | private static HostnamesManagerHandler HOSTNAMES_HANDLER; 46 | private static PreparedPacket DISCONNECT_PACKET; 47 | private static boolean DISABLE_INVALID_PROTOCOL; 48 | 49 | @Override 50 | public boolean handle(MinecraftSessionHandler handler) { 51 | try { 52 | int nextStatus = this.getNextStatus(); 53 | if (DISABLE_INVALID_PROTOCOL && GET_STATE_FOR_PROTOCOL.invoke(handler, nextStatus) == null) { 54 | return true; 55 | } 56 | 57 | MinecraftConnection connection = (MinecraftConnection) CONNECTION_FIELD.get(handler); 58 | if (nextStatus == StateRegistry.STATUS_ID) { 59 | if (HOSTNAMES_HANDLER.checkAddress(StateRegistry.STATUS, connection, handler, this.getServerAddress())) { 60 | connection.close(); 61 | return true; 62 | } 63 | } else if (nextStatus == StateRegistry.LOGIN_ID) { 64 | StateRegistry login = StateRegistry.LOGIN; 65 | if (HOSTNAMES_HANDLER.checkAddress(login, connection, handler, this.getServerAddress())) { 66 | connection.getChannel().pipeline().remove(Connections.FRAME_ENCODER); 67 | connection.closeWith(DISCONNECT_PACKET.getPackets(this.getProtocolVersion())); 68 | return true; 69 | } 70 | } 71 | } catch (IllegalAccessException | InvocationTargetException e) { 72 | throw new ReflectionException(e); 73 | } 74 | 75 | return super.handle(handler); 76 | } 77 | 78 | @Override 79 | public Supplier getHook() { 80 | return HandshakeHook::new; 81 | } 82 | 83 | @Override 84 | public Class getType() { 85 | return HandshakePacket.class; 86 | } 87 | 88 | @Override 89 | public Class getHookClass() { 90 | return this.getClass(); 91 | } 92 | 93 | public static void reload(PreparedPacketFactory factory) { 94 | try { 95 | GET_STATE_FOR_PROTOCOL = HandshakeSessionHandler.class.getDeclaredMethod("getStateForProtocol", int.class); 96 | GET_STATE_FOR_PROTOCOL.setAccessible(true); 97 | 98 | CONNECTION_FIELD = HandshakeSessionHandler.class.getDeclaredField("connection"); 99 | CONNECTION_FIELD.setAccessible(true); 100 | 101 | HOSTNAMES_HANDLER = new HostnamesManagerHandler(); 102 | 103 | String kickReason = Settings.IMP.TOOLS.HOSTNAMES_MANAGER.KICK_REASON; 104 | Component kickReasonComponent; 105 | if (kickReason.isEmpty()) { 106 | kickReasonComponent = Component.empty(); 107 | } else { 108 | kickReasonComponent = VelocityTools.getSerializer().deserialize(kickReason); 109 | } 110 | 111 | DISCONNECT_PACKET = factory 112 | .createPreparedPacket(ProtocolVersion.MINIMUM_VERSION, ProtocolVersion.MAXIMUM_VERSION) 113 | .prepare(version -> DisconnectPacket.create(kickReasonComponent, version, StateRegistry.PLAY)); 114 | 115 | DISABLE_INVALID_PROTOCOL = Settings.IMP.TOOLS.DISABLE_INVALID_PROTOCOL; 116 | } catch (NoSuchMethodException | NoSuchFieldException e) { 117 | throw new ReflectionException(e); 118 | } 119 | } 120 | } 121 | -------------------------------------------------------------------------------- /src/main/java/net/elytrium/velocitytools/hooks/HooksInitializer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2021 - 2025 Elytrium 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Affero General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Affero General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Affero General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | package net.elytrium.velocitytools.hooks; 19 | 20 | import com.velocitypowered.api.network.ProtocolVersion; 21 | import com.velocitypowered.api.proxy.ProxyServer; 22 | import com.velocitypowered.proxy.connection.backend.BackendPlaySessionHandler; 23 | import com.velocitypowered.proxy.connection.backend.ConfigSessionHandler; 24 | import com.velocitypowered.proxy.connection.backend.VelocityServerConnection; 25 | import com.velocitypowered.proxy.network.ConnectionManager; 26 | import com.velocitypowered.proxy.network.ServerChannelInitializerHolder; 27 | import com.velocitypowered.proxy.protocol.MinecraftPacket; 28 | import com.velocitypowered.proxy.protocol.StateRegistry; 29 | import io.netty.channel.Channel; 30 | import io.netty.channel.ChannelInitializer; 31 | import io.netty.util.collection.IntObjectMap; 32 | import it.unimi.dsi.fastutil.objects.Object2IntMap; 33 | import java.lang.invoke.MethodHandle; 34 | import java.lang.invoke.MethodHandles; 35 | import java.lang.reflect.Field; 36 | import java.util.ArrayList; 37 | import java.util.List; 38 | import java.util.Map; 39 | import java.util.function.BiConsumer; 40 | import java.util.function.Supplier; 41 | import net.elytrium.commons.utils.reflection.ReflectionException; 42 | 43 | /** 44 | * @author hevav 45 | */ 46 | public class HooksInitializer { 47 | 48 | @SuppressWarnings("unchecked") 49 | public static void init(ProxyServer server) { 50 | try { 51 | MethodHandle cm = MethodHandles.privateLookupIn(server.getClass(), MethodHandles.lookup()) 52 | .findGetter(server.getClass(), "cm", ConnectionManager.class); 53 | 54 | ServerChannelInitializerHolder serverChannelInitializer = ((ConnectionManager) cm.invoke(server)).getServerChannelInitializer(); 55 | Field initializerField = serverChannelInitializer.getClass().getDeclaredField("initializer"); 56 | initializerField.setAccessible(true); 57 | ChannelInitializer initializer = (ChannelInitializer) initializerField.get(serverChannelInitializer); 58 | initializerField.set(serverChannelInitializer, new ChannelInitializerHook(initializer)); 59 | 60 | PluginMessageHook.SERVER_CONNECTION_BACKEND_PLAY_FIELD = MethodHandles 61 | .privateLookupIn(BackendPlaySessionHandler.class, MethodHandles.lookup()) 62 | .findGetter(BackendPlaySessionHandler.class, "serverConn", VelocityServerConnection.class); 63 | 64 | PluginMessageHook.SERVER_CONNECTION_CONFIG_FIELD = MethodHandles 65 | .privateLookupIn(ConfigSessionHandler.class, MethodHandles.lookup()) 66 | .findGetter(ConfigSessionHandler.class, "serverConn", VelocityServerConnection.class); 67 | 68 | MethodHandle versionsField = MethodHandles.privateLookupIn(StateRegistry.PacketRegistry.class, MethodHandles.lookup()) 69 | .findGetter(StateRegistry.PacketRegistry.class, "versions", Map.class); 70 | 71 | MethodHandle packetIdToSupplierField = MethodHandles 72 | .privateLookupIn(StateRegistry.PacketRegistry.ProtocolRegistry.class, MethodHandles.lookup()) 73 | .findGetter(StateRegistry.PacketRegistry.ProtocolRegistry.class, "packetIdToSupplier", IntObjectMap.class); 74 | 75 | MethodHandle packetClassToIdField = MethodHandles 76 | .privateLookupIn(StateRegistry.PacketRegistry.ProtocolRegistry.class, MethodHandles.lookup()) 77 | .findGetter(StateRegistry.PacketRegistry.ProtocolRegistry.class, "packetClassToId", Object2IntMap.class); 78 | 79 | List hooks = new ArrayList<>(); 80 | hooks.add(new PluginMessageHook()); 81 | hooks.add(new HandshakeHook()); 82 | 83 | BiConsumer consumer = (version, registry) -> { 84 | try { 85 | IntObjectMap> packetIdToSupplier 86 | = (IntObjectMap>) packetIdToSupplierField.invoke(registry); 87 | 88 | Object2IntMap> packetClassToId 89 | = (Object2IntMap>) packetClassToIdField.invoke(registry); 90 | 91 | hooks.forEach(hook -> { 92 | int packetId = packetClassToId.getInt(hook.getType()); 93 | packetClassToId.put(hook.getHookClass(), packetId); 94 | packetIdToSupplier.remove(packetId); 95 | packetIdToSupplier.put(packetId, hook.getHook()); 96 | }); 97 | } catch (Throwable e) { 98 | throw new ReflectionException(e); 99 | } 100 | }; 101 | 102 | MethodHandle clientboundGetter = MethodHandles.privateLookupIn(StateRegistry.class, MethodHandles.lookup()) 103 | .findGetter(StateRegistry.class, "clientbound", StateRegistry.PacketRegistry.class); 104 | 105 | MethodHandle serverboundGetter = MethodHandles.privateLookupIn(StateRegistry.class, MethodHandles.lookup()) 106 | .findGetter(StateRegistry.class, "serverbound", StateRegistry.PacketRegistry.class); 107 | 108 | StateRegistry.PacketRegistry playClientbound = (StateRegistry.PacketRegistry) clientboundGetter.invokeExact(StateRegistry.PLAY); 109 | StateRegistry.PacketRegistry configClientbound = (StateRegistry.PacketRegistry) clientboundGetter.invokeExact(StateRegistry.CONFIG); 110 | StateRegistry.PacketRegistry handshakeServerbound = (StateRegistry.PacketRegistry) serverboundGetter.invokeExact(StateRegistry.HANDSHAKE); 111 | 112 | ((Map) versionsField.invokeExact(playClientbound)).forEach(consumer); 113 | ((Map) versionsField.invokeExact(configClientbound)).forEach(consumer); 114 | ((Map) versionsField.invokeExact(handshakeServerbound)).forEach(consumer); 115 | } catch (Throwable e) { 116 | throw new ReflectionException(e); 117 | } 118 | } 119 | } 120 | -------------------------------------------------------------------------------- /src/main/java/net/elytrium/velocitytools/hooks/PacketHook.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2021 - 2025 Elytrium 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Affero General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Affero General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Affero General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | package net.elytrium.velocitytools.hooks; 19 | 20 | import com.velocitypowered.proxy.protocol.MinecraftPacket; 21 | import java.util.function.Supplier; 22 | 23 | public interface PacketHook { 24 | 25 | Supplier getHook(); 26 | 27 | Class getType(); 28 | 29 | Class getHookClass(); 30 | } 31 | -------------------------------------------------------------------------------- /src/main/java/net/elytrium/velocitytools/hooks/PluginMessageHook.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2021 - 2025 Elytrium 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Affero General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Affero General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Affero General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | package net.elytrium.velocitytools.hooks; 19 | 20 | import com.velocitypowered.api.network.ProtocolVersion; 21 | import com.velocitypowered.proxy.connection.MinecraftSessionHandler; 22 | import com.velocitypowered.proxy.connection.backend.BackendPlaySessionHandler; 23 | import com.velocitypowered.proxy.connection.backend.ConfigSessionHandler; 24 | import com.velocitypowered.proxy.connection.backend.VelocityServerConnection; 25 | import com.velocitypowered.proxy.connection.client.ConnectedPlayer; 26 | import com.velocitypowered.proxy.protocol.MinecraftPacket; 27 | import com.velocitypowered.proxy.protocol.ProtocolUtils; 28 | import com.velocitypowered.proxy.protocol.packet.PluginMessagePacket; 29 | import com.velocitypowered.proxy.protocol.util.PluginMessageUtil; 30 | import io.netty.buffer.ByteBuf; 31 | import io.netty.buffer.Unpooled; 32 | import java.lang.invoke.MethodHandle; 33 | import java.nio.charset.StandardCharsets; 34 | import java.text.MessageFormat; 35 | import java.util.function.Supplier; 36 | import net.elytrium.commons.utils.reflection.ReflectionException; 37 | import net.elytrium.velocitytools.Settings; 38 | 39 | class PluginMessageHook extends PluginMessagePacket implements PacketHook { 40 | 41 | protected static MethodHandle SERVER_CONNECTION_BACKEND_PLAY_FIELD; 42 | protected static MethodHandle SERVER_CONNECTION_CONFIG_FIELD; 43 | 44 | private final boolean enabled = Settings.IMP.TOOLS.BRAND_CHANGER.REWRITE_IN_GAME; 45 | private final String inGameBrand = Settings.IMP.TOOLS.BRAND_CHANGER.IN_GAME_BRAND; 46 | 47 | @Override 48 | public boolean handle(MinecraftSessionHandler handler) { 49 | if (this.enabled && PluginMessageUtil.isMcBrand(this)) { 50 | try { 51 | if (handler instanceof BackendPlaySessionHandler) { 52 | ConnectedPlayer player = ((VelocityServerConnection) SERVER_CONNECTION_BACKEND_PLAY_FIELD.invoke(handler)).getPlayer(); 53 | player.getConnection().write(this.rewriteMinecraftBrand(this, player.getProtocolVersion())); 54 | return true; 55 | } else if (handler instanceof ConfigSessionHandler) { 56 | ConnectedPlayer player = ((VelocityServerConnection) SERVER_CONNECTION_CONFIG_FIELD.invoke(handler)).getPlayer(); 57 | player.getConnection().write(this.rewriteMinecraftBrand(this, player.getProtocolVersion())); 58 | return true; 59 | } 60 | } catch (Throwable e) { 61 | throw new ReflectionException(e); 62 | } 63 | } 64 | 65 | return super.handle(handler); 66 | } 67 | 68 | private PluginMessagePacket rewriteMinecraftBrand(PluginMessagePacket message, ProtocolVersion protocolVersion) { 69 | String currentBrand = PluginMessageUtil.readBrandMessage(message.content()); 70 | String rewrittenBrand = MessageFormat.format(this.inGameBrand, currentBrand); 71 | ByteBuf rewrittenBuf = Unpooled.buffer(); 72 | if (protocolVersion.compareTo(ProtocolVersion.MINECRAFT_1_8) >= 0) { 73 | ProtocolUtils.writeString(rewrittenBuf, rewrittenBrand); 74 | } else { 75 | rewrittenBuf.writeCharSequence(rewrittenBrand, StandardCharsets.UTF_8); 76 | } 77 | 78 | return new PluginMessagePacket(message.getChannel(), rewrittenBuf); 79 | } 80 | 81 | @Override 82 | public Supplier getHook() { 83 | return PluginMessageHook::new; 84 | } 85 | 86 | @Override 87 | public Class getType() { 88 | return PluginMessagePacket.class; 89 | } 90 | 91 | @Override 92 | public Class getHookClass() { 93 | return this.getClass(); 94 | } 95 | } 96 | -------------------------------------------------------------------------------- /src/main/java/net/elytrium/velocitytools/listeners/BrandChangerPingListener.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2021 - 2025 Elytrium 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Affero General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Affero General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Affero General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | package net.elytrium.velocitytools.listeners; 19 | 20 | import com.velocitypowered.api.event.Subscribe; 21 | import com.velocitypowered.api.event.proxy.ProxyPingEvent; 22 | import com.velocitypowered.api.proxy.server.ServerPing; 23 | import net.elytrium.velocitytools.Settings; 24 | 25 | public class BrandChangerPingListener { 26 | 27 | private final boolean showAlways; 28 | private final String pingBrand; 29 | 30 | public BrandChangerPingListener() { 31 | this.showAlways = Settings.IMP.TOOLS.BRAND_CHANGER.SHOW_ALWAYS; 32 | this.pingBrand = Settings.IMP.TOOLS.BRAND_CHANGER.PING_BRAND; 33 | } 34 | 35 | @Subscribe 36 | public void onPing(ProxyPingEvent event) { 37 | ServerPing.Builder builder = event.getPing().asBuilder(); 38 | 39 | builder.version(new ServerPing.Version(this.showAlways ? -1 : event.getPing().getVersion().getProtocol(), this.pingBrand)); 40 | 41 | event.setPing(builder.build()); 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /src/main/java/net/elytrium/velocitytools/listeners/ProtocolBlockerJoinListener.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2021 - 2025 Elytrium 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Affero General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Affero General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Affero General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | package net.elytrium.velocitytools.listeners; 19 | 20 | import com.velocitypowered.api.event.Subscribe; 21 | import com.velocitypowered.api.event.connection.PreLoginEvent; 22 | import com.velocitypowered.api.network.ProtocolVersion; 23 | import com.velocitypowered.proxy.connection.client.InitialInboundConnection; 24 | import com.velocitypowered.proxy.connection.client.LoginInboundConnection; 25 | import java.lang.invoke.MethodHandle; 26 | import java.lang.invoke.MethodHandles; 27 | import java.util.List; 28 | import java.util.stream.Collectors; 29 | import net.elytrium.commons.utils.reflection.ReflectionException; 30 | import net.elytrium.velocitytools.Settings; 31 | import net.elytrium.velocitytools.VelocityTools; 32 | import net.elytrium.velocitytools.utils.ProtocolUtil; 33 | import net.elytrium.velocitytools.utils.WhitelistUtil; 34 | import net.kyori.adventure.text.Component; 35 | 36 | public class ProtocolBlockerJoinListener { 37 | 38 | private static final MethodHandle MH_delegate; 39 | 40 | private final boolean whitelist; 41 | private final List protocolNumbers; 42 | private final List protocolVersions; 43 | private final ProtocolVersion minimumProtocolVersion; 44 | private final ProtocolVersion maximumProtocolVersion; 45 | private final Component kickReason; 46 | 47 | public ProtocolBlockerJoinListener() { 48 | this.whitelist = Settings.IMP.TOOLS.PROTOCOL_BLOCKER.WHITELIST; 49 | this.protocolNumbers = Settings.IMP.TOOLS.PROTOCOL_BLOCKER.PROTOCOLS; 50 | this.protocolVersions = Settings.IMP.TOOLS.PROTOCOL_BLOCKER.VERSIONS.stream() 51 | .map(ProtocolUtil::protocolVersionFromString) 52 | .collect(Collectors.toList()); 53 | this.minimumProtocolVersion = ProtocolUtil.protocolVersionFromString(Settings.IMP.TOOLS.PROTOCOL_BLOCKER.MINIMUM_VERSION); 54 | this.maximumProtocolVersion = ProtocolUtil.protocolVersionFromString(Settings.IMP.TOOLS.PROTOCOL_BLOCKER.MAXIMUM_VERSION); 55 | this.kickReason = VelocityTools.getSerializer().deserialize(Settings.IMP.TOOLS.PROTOCOL_BLOCKER.KICK_REASON); 56 | } 57 | 58 | @Subscribe 59 | public void onJoin(PreLoginEvent event) { 60 | try { 61 | InitialInboundConnection inbound = (InitialInboundConnection) MH_delegate.invoke(event.getConnection()); 62 | 63 | inbound.getConnection().eventLoop().execute(() -> { 64 | ProtocolVersion playerProtocol = event.getConnection().getProtocolVersion(); 65 | if (this.minimumProtocolVersion.compareTo(playerProtocol) > 0 || this.maximumProtocolVersion.compareTo(playerProtocol) < 0 66 | || WhitelistUtil.checkForWhitelist(this.whitelist, 67 | this.protocolNumbers.contains(playerProtocol.getProtocol()) 68 | || this.protocolVersions.contains(playerProtocol))) { 69 | event.getConnection().getVirtualHost().ifPresent(conn -> inbound.disconnect(this.kickReason)); 70 | } 71 | }); 72 | } catch (Throwable e) { 73 | throw new ReflectionException(e); 74 | } 75 | } 76 | 77 | static { 78 | try { 79 | MH_delegate = MethodHandles.privateLookupIn(LoginInboundConnection.class, MethodHandles.lookup()) 80 | .findGetter(LoginInboundConnection.class, "delegate", InitialInboundConnection.class); 81 | } catch (NoSuchFieldException | IllegalAccessException e) { 82 | throw new RuntimeException(e); 83 | } 84 | } 85 | } 86 | -------------------------------------------------------------------------------- /src/main/java/net/elytrium/velocitytools/listeners/ProtocolBlockerPingListener.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2021 - 2025 Elytrium 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Affero General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Affero General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Affero General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | package net.elytrium.velocitytools.listeners; 19 | 20 | import com.velocitypowered.api.event.PostOrder; 21 | import com.velocitypowered.api.event.Subscribe; 22 | import com.velocitypowered.api.event.proxy.ProxyPingEvent; 23 | import com.velocitypowered.api.network.ProtocolVersion; 24 | import com.velocitypowered.api.proxy.server.ServerPing; 25 | import java.util.List; 26 | import java.util.stream.Collectors; 27 | import net.elytrium.velocitytools.Settings; 28 | import net.elytrium.velocitytools.VelocityTools; 29 | import net.elytrium.velocitytools.utils.ProtocolUtil; 30 | import net.elytrium.velocitytools.utils.WhitelistUtil; 31 | import net.kyori.adventure.text.Component; 32 | 33 | public class ProtocolBlockerPingListener { 34 | 35 | private final boolean whitelist; 36 | private final List protocolNumbers; 37 | private final List protocolVersions; 38 | private final ProtocolVersion minimumProtocolVersion; 39 | private final ProtocolVersion maximumProtocolVersion; 40 | private final String brand; 41 | private final String motd; 42 | private final Component motdComponent; 43 | 44 | public ProtocolBlockerPingListener() { 45 | this.whitelist = Settings.IMP.TOOLS.PROTOCOL_BLOCKER.WHITELIST; 46 | this.protocolNumbers = Settings.IMP.TOOLS.PROTOCOL_BLOCKER.PROTOCOLS; 47 | this.protocolVersions = Settings.IMP.TOOLS.PROTOCOL_BLOCKER.VERSIONS.stream() 48 | .map(ProtocolUtil::protocolVersionFromString) 49 | .collect(Collectors.toList()); 50 | this.minimumProtocolVersion = ProtocolUtil.protocolVersionFromString(Settings.IMP.TOOLS.PROTOCOL_BLOCKER.MINIMUM_VERSION); 51 | this.maximumProtocolVersion = ProtocolUtil.protocolVersionFromString(Settings.IMP.TOOLS.PROTOCOL_BLOCKER.MAXIMUM_VERSION); 52 | this.brand = Settings.IMP.TOOLS.PROTOCOL_BLOCKER.BRAND; 53 | this.motd = Settings.IMP.TOOLS.PROTOCOL_BLOCKER.MOTD; 54 | this.motdComponent = VelocityTools.getSerializer().deserialize(this.motd); 55 | } 56 | 57 | @Subscribe(order = PostOrder.LAST) 58 | public void onPing(ProxyPingEvent event) { 59 | ServerPing.Builder builder = event.getPing().asBuilder(); 60 | 61 | ProtocolVersion playerProtocol = event.getConnection().getProtocolVersion(); 62 | int playerProtocolNumber = event.getConnection().getProtocolVersion().getProtocol(); 63 | if (this.minimumProtocolVersion.compareTo(playerProtocol) > 0 || this.maximumProtocolVersion.compareTo(playerProtocol) < 0 64 | || WhitelistUtil.checkForWhitelist(this.whitelist, 65 | this.protocolNumbers.contains(playerProtocolNumber) 66 | || this.protocolVersions.contains(playerProtocol))) { 67 | builder.version(new ServerPing.Version(playerProtocolNumber + 1, this.brand)); 68 | if (!this.motd.isEmpty()) { 69 | builder.description(this.motdComponent); 70 | } 71 | } 72 | 73 | event.setPing(builder.build()); 74 | } 75 | } 76 | -------------------------------------------------------------------------------- /src/main/java/net/elytrium/velocitytools/utils/ProtocolUtil.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2021 - 2025 Elytrium 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Affero General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Affero General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Affero General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | package net.elytrium.velocitytools.utils; 19 | 20 | import com.velocitypowered.api.network.ProtocolVersion; 21 | 22 | public class ProtocolUtil { 23 | 24 | public static ProtocolVersion protocolVersionFromString(String string) { 25 | if (string.equalsIgnoreCase("LATEST")) { 26 | return ProtocolVersion.MAXIMUM_VERSION; 27 | } 28 | 29 | return ProtocolVersion.valueOf("MINECRAFT_" + string.replace(".", "_")); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /src/main/java/net/elytrium/velocitytools/utils/WhitelistUtil.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2021 - 2025 Elytrium 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU Affero General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU Affero General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Affero General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | package net.elytrium.velocitytools.utils; 19 | 20 | public class WhitelistUtil { 21 | 22 | public static boolean checkForWhitelist(boolean whitelist, boolean toCheck) { 23 | if (whitelist) { 24 | return !toCheck; 25 | } else { 26 | return toCheck; 27 | } 28 | } 29 | } 30 | --------------------------------------------------------------------------------