├── .gitignore ├── CREDITS-fml.txt ├── LICENSE-fml.txt ├── MinecraftForge-Credits.txt ├── MinecraftForge-License.txt ├── Paulscode IBXM Library License.txt ├── Paulscode SoundSystem CodecIBXM License.txt ├── README.md ├── build.gradle ├── forge-1.8.9-11.15.1.2318-1.8.9-changelog.txt ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat └── src └── main ├── java └── com │ └── yuluo │ └── dglab │ ├── CommandDglab.java │ ├── CommandDglabConnect.java │ ├── CommandDglabPunish.java │ ├── CommandDglabStrength.java │ └── DGLabController.java └── resources └── mcmod.info /.gitignore: -------------------------------------------------------------------------------- 1 | # eclipse 2 | bin 3 | *.launch 4 | .settings 5 | .metadata 6 | .classpath 7 | .project 8 | 9 | # idea 10 | out 11 | *.ipr 12 | *.iws 13 | *.iml 14 | .idea 15 | 16 | # gradle 17 | build 18 | .gradle 19 | 20 | # other 21 | eclipse 22 | run 23 | -------------------------------------------------------------------------------- /CREDITS-fml.txt: -------------------------------------------------------------------------------- 1 | This is Forge Mod Loader. 2 | 3 | You can find the source code at all times at https://github.com/MinecraftForge/FML 4 | 5 | This minecraft mod is a clean open source implementation of a mod loader for minecraft servers 6 | and minecraft clients. 7 | 8 | The code is authored by cpw. 9 | 10 | It began by partially implementing an API defined by the client side ModLoader, authored by Risugami. 11 | http://www.minecraftforum.net/topic/75440- 12 | This support has been dropped as of Minecraft release 1.7, as Risugami no longer maintains ModLoader. 13 | 14 | It also contains suggestions and hints and generous helpings of code from LexManos, author of MinecraftForge. 15 | http://www.minecraftforge.net/ 16 | 17 | Additionally, it contains an implementation of topological sort based on that 18 | published at http://keithschwarz.com/interesting/code/?dir=topological-sort 19 | 20 | It also contains code from the Maven project for performing versioned dependency 21 | resolution. http://maven.apache.org/ 22 | 23 | It also contains a partial repackaging of the javaxdelta library from http://sourceforge.net/projects/javaxdelta/ 24 | with credit to it's authors. 25 | 26 | Forge Mod Loader downloads components from the Minecraft Coder Pack 27 | (http://mcp.ocean-labs.de/index.php/Main_Page) with kind permission from the MCP team. 28 | 29 | -------------------------------------------------------------------------------- /LICENSE-fml.txt: -------------------------------------------------------------------------------- 1 | This minecraft mod, Forge Mod Loader, including all parts herein except as noted below, 2 | is licensed under the GNU LGPL v2.1 or later. 3 | 4 | Homepage: https://github.com/MinecraftForge/FML 5 | 6 | This software includes portions from the Apache Maven project at 7 | http://maven.apache.org/ specifically the ComparableVersion.java code. It is 8 | included based on guidelines at 9 | http://www.softwarefreedom.org/resources/2007/gpl-non-gpl-collaboration.html 10 | with notices intact. The only change is a non-functional change of package name. 11 | 12 | This software contains a partial repackaging of javaxdelta, a BSD licensed program for generating 13 | binary differences and applying them, sourced from the subversion at http://sourceforge.net/projects/javaxdelta/ 14 | authored by genman, heikok, pivot. 15 | The only changes are to replace some Trove collection types with standard Java collections, and repackaged. 16 | 17 | 18 | === MCP Data === 19 | This software includes data from the Minecraft Coder Pack (MCP), with kind permission 20 | from them. The license to MCP data is not transitive - distribution of this data by 21 | third parties requires independent licensing from the MCP team. This data is not 22 | redistributable without permission from the MCP team. 23 | 24 | === Sharing === 25 | I grant permission for some parts of FML to be redistributed outside the terms of the LGPL, for the benefit of 26 | the minecraft modding community. All contributions to these parts should be licensed under the same additional grant. 27 | 28 | -- Runtime patcher -- 29 | License is granted to redistribute the runtime patcher code (common/cpw/mods/fml/patcher and subdirectories) under 30 | any alternative open source license as classified by the OSI (http://opensource.org/licenses) 31 | 32 | -- ASM transformers -- 33 | License is granted to redistribute the ASM transformer code (common/cpw/mods/fml/common/asm/ and subdirectories) 34 | under any alternative open source license as classified by the OSI (http://opensource.org/licenses) 35 | 36 | ======== 37 | 38 | GNU LESSER GENERAL PUBLIC LICENSE 39 | Version 2.1, February 1999 40 | 41 | Copyright (C) 1991, 1999 Free Software Foundation, Inc. 42 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 43 | Everyone is permitted to copy and distribute verbatim copies 44 | of this license document, but changing it is not allowed. 45 | 46 | Preamble 47 | 48 | The licenses for most software are designed to take away your 49 | freedom to share and change it. By contrast, the GNU General Public 50 | Licenses are intended to guarantee your freedom to share and change 51 | free software--to make sure the software is free for all its users. 52 | 53 | This license, the Lesser General Public License, applies to some 54 | specially designated software packages--typically libraries--of the 55 | Free Software Foundation and other authors who decide to use it. You 56 | can use it too, but we suggest you first think carefully about whether 57 | this license or the ordinary General Public License is the better 58 | strategy to use in any particular case, based on the explanations below. 59 | 60 | When we speak of free software, we are referring to freedom of use, 61 | not price. Our General Public Licenses are designed to make sure that 62 | you have the freedom to distribute copies of free software (and charge 63 | for this service if you wish); that you receive source code or can get 64 | it if you want it; that you can change the software and use pieces of 65 | it in new free programs; and that you are informed that you can do 66 | these things. 67 | 68 | To protect your rights, we need to make restrictions that forbid 69 | distributors to deny you these rights or to ask you to surrender these 70 | rights. These restrictions translate to certain responsibilities for 71 | you if you distribute copies of the library or if you modify it. 72 | 73 | For example, if you distribute copies of the library, whether gratis 74 | or for a fee, you must give the recipients all the rights that we gave 75 | you. You must make sure that they, too, receive or can get the source 76 | code. If you link other code with the library, you must provide 77 | complete object files to the recipients, so that they can relink them 78 | with the library after making changes to the library and recompiling 79 | it. And you must show them these terms so they know their rights. 80 | 81 | We protect your rights with a two-step method: (1) we copyright the 82 | library, and (2) we offer you this license, which gives you legal 83 | permission to copy, distribute and/or modify the library. 84 | 85 | To protect each distributor, we want to make it very clear that 86 | there is no warranty for the free library. Also, if the library is 87 | modified by someone else and passed on, the recipients should know 88 | that what they have is not the original version, so that the original 89 | author's reputation will not be affected by problems that might be 90 | introduced by others. 91 | 92 | Finally, software patents pose a constant threat to the existence of 93 | any free program. We wish to make sure that a company cannot 94 | effectively restrict the users of a free program by obtaining a 95 | restrictive license from a patent holder. Therefore, we insist that 96 | any patent license obtained for a version of the library must be 97 | consistent with the full freedom of use specified in this license. 98 | 99 | Most GNU software, including some libraries, is covered by the 100 | ordinary GNU General Public License. This license, the GNU Lesser 101 | General Public License, applies to certain designated libraries, and 102 | is quite different from the ordinary General Public License. We use 103 | this license for certain libraries in order to permit linking those 104 | libraries into non-free programs. 105 | 106 | When a program is linked with a library, whether statically or using 107 | a shared library, the combination of the two is legally speaking a 108 | combined work, a derivative of the original library. The ordinary 109 | General Public License therefore permits such linking only if the 110 | entire combination fits its criteria of freedom. The Lesser General 111 | Public License permits more lax criteria for linking other code with 112 | the library. 113 | 114 | We call this license the "Lesser" General Public License because it 115 | does Less to protect the user's freedom than the ordinary General 116 | Public License. It also provides other free software developers Less 117 | of an advantage over competing non-free programs. These disadvantages 118 | are the reason we use the ordinary General Public License for many 119 | libraries. However, the Lesser license provides advantages in certain 120 | special circumstances. 121 | 122 | For example, on rare occasions, there may be a special need to 123 | encourage the widest possible use of a certain library, so that it becomes 124 | a de-facto standard. To achieve this, non-free programs must be 125 | allowed to use the library. A more frequent case is that a free 126 | library does the same job as widely used non-free libraries. In this 127 | case, there is little to gain by limiting the free library to free 128 | software only, so we use the Lesser General Public License. 129 | 130 | In other cases, permission to use a particular library in non-free 131 | programs enables a greater number of people to use a large body of 132 | free software. For example, permission to use the GNU C Library in 133 | non-free programs enables many more people to use the whole GNU 134 | operating system, as well as its variant, the GNU/Linux operating 135 | system. 136 | 137 | Although the Lesser General Public License is Less protective of the 138 | users' freedom, it does ensure that the user of a program that is 139 | linked with the Library has the freedom and the wherewithal to run 140 | that program using a modified version of the Library. 141 | 142 | The precise terms and conditions for copying, distribution and 143 | modification follow. Pay close attention to the difference between a 144 | "work based on the library" and a "work that uses the library". The 145 | former contains code derived from the library, whereas the latter must 146 | be combined with the library in order to run. 147 | 148 | GNU LESSER GENERAL PUBLIC LICENSE 149 | TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 150 | 151 | 0. This License Agreement applies to any software library or other 152 | program which contains a notice placed by the copyright holder or 153 | other authorized party saying it may be distributed under the terms of 154 | this Lesser General Public License (also called "this License"). 155 | Each licensee is addressed as "you". 156 | 157 | A "library" means a collection of software functions and/or data 158 | prepared so as to be conveniently linked with application programs 159 | (which use some of those functions and data) to form executables. 160 | 161 | The "Library", below, refers to any such software library or work 162 | which has been distributed under these terms. A "work based on the 163 | Library" means either the Library or any derivative work under 164 | copyright law: that is to say, a work containing the Library or a 165 | portion of it, either verbatim or with modifications and/or translated 166 | straightforwardly into another language. (Hereinafter, translation is 167 | included without limitation in the term "modification".) 168 | 169 | "Source code" for a work means the preferred form of the work for 170 | making modifications to it. For a library, complete source code means 171 | all the source code for all modules it contains, plus any associated 172 | interface definition files, plus the scripts used to control compilation 173 | and installation of the library. 174 | 175 | Activities other than copying, distribution and modification are not 176 | covered by this License; they are outside its scope. The act of 177 | running a program using the Library is not restricted, and output from 178 | such a program is covered only if its contents constitute a work based 179 | on the Library (independent of the use of the Library in a tool for 180 | writing it). Whether that is true depends on what the Library does 181 | and what the program that uses the Library does. 182 | 183 | 1. You may copy and distribute verbatim copies of the Library's 184 | complete source code as you receive it, in any medium, provided that 185 | you conspicuously and appropriately publish on each copy an 186 | appropriate copyright notice and disclaimer of warranty; keep intact 187 | all the notices that refer to this License and to the absence of any 188 | warranty; and distribute a copy of this License along with the 189 | Library. 190 | 191 | You may charge a fee for the physical act of transferring a copy, 192 | and you may at your option offer warranty protection in exchange for a 193 | fee. 194 | 195 | 2. You may modify your copy or copies of the Library or any portion 196 | of it, thus forming a work based on the Library, and copy and 197 | distribute such modifications or work under the terms of Section 1 198 | above, provided that you also meet all of these conditions: 199 | 200 | a) The modified work must itself be a software library. 201 | 202 | b) You must cause the files modified to carry prominent notices 203 | stating that you changed the files and the date of any change. 204 | 205 | c) You must cause the whole of the work to be licensed at no 206 | charge to all third parties under the terms of this License. 207 | 208 | d) If a facility in the modified Library refers to a function or a 209 | table of data to be supplied by an application program that uses 210 | the facility, other than as an argument passed when the facility 211 | is invoked, then you must make a good faith effort to ensure that, 212 | in the event an application does not supply such function or 213 | table, the facility still operates, and performs whatever part of 214 | its purpose remains meaningful. 215 | 216 | (For example, a function in a library to compute square roots has 217 | a purpose that is entirely well-defined independent of the 218 | application. Therefore, Subsection 2d requires that any 219 | application-supplied function or table used by this function must 220 | be optional: if the application does not supply it, the square 221 | root function must still compute square roots.) 222 | 223 | These requirements apply to the modified work as a whole. If 224 | identifiable sections of that work are not derived from the Library, 225 | and can be reasonably considered independent and separate works in 226 | themselves, then this License, and its terms, do not apply to those 227 | sections when you distribute them as separate works. But when you 228 | distribute the same sections as part of a whole which is a work based 229 | on the Library, the distribution of the whole must be on the terms of 230 | this License, whose permissions for other licensees extend to the 231 | entire whole, and thus to each and every part regardless of who wrote 232 | it. 233 | 234 | Thus, it is not the intent of this section to claim rights or contest 235 | your rights to work written entirely by you; rather, the intent is to 236 | exercise the right to control the distribution of derivative or 237 | collective works based on the Library. 238 | 239 | In addition, mere aggregation of another work not based on the Library 240 | with the Library (or with a work based on the Library) on a volume of 241 | a storage or distribution medium does not bring the other work under 242 | the scope of this License. 243 | 244 | 3. You may opt to apply the terms of the ordinary GNU General Public 245 | License instead of this License to a given copy of the Library. To do 246 | this, you must alter all the notices that refer to this License, so 247 | that they refer to the ordinary GNU General Public License, version 2, 248 | instead of to this License. (If a newer version than version 2 of the 249 | ordinary GNU General Public License has appeared, then you can specify 250 | that version instead if you wish.) Do not make any other change in 251 | these notices. 252 | 253 | Once this change is made in a given copy, it is irreversible for 254 | that copy, so the ordinary GNU General Public License applies to all 255 | subsequent copies and derivative works made from that copy. 256 | 257 | This option is useful when you wish to copy part of the code of 258 | the Library into a program that is not a library. 259 | 260 | 4. You may copy and distribute the Library (or a portion or 261 | derivative of it, under Section 2) in object code or executable form 262 | under the terms of Sections 1 and 2 above provided that you accompany 263 | it with the complete corresponding machine-readable source code, which 264 | must be distributed under the terms of Sections 1 and 2 above on a 265 | medium customarily used for software interchange. 266 | 267 | If distribution of object code is made by offering access to copy 268 | from a designated place, then offering equivalent access to copy the 269 | source code from the same place satisfies the requirement to 270 | distribute the source code, even though third parties are not 271 | compelled to copy the source along with the object code. 272 | 273 | 5. A program that contains no derivative of any portion of the 274 | Library, but is designed to work with the Library by being compiled or 275 | linked with it, is called a "work that uses the Library". Such a 276 | work, in isolation, is not a derivative work of the Library, and 277 | therefore falls outside the scope of this License. 278 | 279 | However, linking a "work that uses the Library" with the Library 280 | creates an executable that is a derivative of the Library (because it 281 | contains portions of the Library), rather than a "work that uses the 282 | library". The executable is therefore covered by this License. 283 | Section 6 states terms for distribution of such executables. 284 | 285 | When a "work that uses the Library" uses material from a header file 286 | that is part of the Library, the object code for the work may be a 287 | derivative work of the Library even though the source code is not. 288 | Whether this is true is especially significant if the work can be 289 | linked without the Library, or if the work is itself a library. The 290 | threshold for this to be true is not precisely defined by law. 291 | 292 | If such an object file uses only numerical parameters, data 293 | structure layouts and accessors, and small macros and small inline 294 | functions (ten lines or less in length), then the use of the object 295 | file is unrestricted, regardless of whether it is legally a derivative 296 | work. (Executables containing this object code plus portions of the 297 | Library will still fall under Section 6.) 298 | 299 | Otherwise, if the work is a derivative of the Library, you may 300 | distribute the object code for the work under the terms of Section 6. 301 | Any executables containing that work also fall under Section 6, 302 | whether or not they are linked directly with the Library itself. 303 | 304 | 6. As an exception to the Sections above, you may also combine or 305 | link a "work that uses the Library" with the Library to produce a 306 | work containing portions of the Library, and distribute that work 307 | under terms of your choice, provided that the terms permit 308 | modification of the work for the customer's own use and reverse 309 | engineering for debugging such modifications. 310 | 311 | You must give prominent notice with each copy of the work that the 312 | Library is used in it and that the Library and its use are covered by 313 | this License. You must supply a copy of this License. If the work 314 | during execution displays copyright notices, you must include the 315 | copyright notice for the Library among them, as well as a reference 316 | directing the user to the copy of this License. Also, you must do one 317 | of these things: 318 | 319 | a) Accompany the work with the complete corresponding 320 | machine-readable source code for the Library including whatever 321 | changes were used in the work (which must be distributed under 322 | Sections 1 and 2 above); and, if the work is an executable linked 323 | with the Library, with the complete machine-readable "work that 324 | uses the Library", as object code and/or source code, so that the 325 | user can modify the Library and then relink to produce a modified 326 | executable containing the modified Library. (It is understood 327 | that the user who changes the contents of definitions files in the 328 | Library will not necessarily be able to recompile the application 329 | to use the modified definitions.) 330 | 331 | b) Use a suitable shared library mechanism for linking with the 332 | Library. A suitable mechanism is one that (1) uses at run time a 333 | copy of the library already present on the user's computer system, 334 | rather than copying library functions into the executable, and (2) 335 | will operate properly with a modified version of the library, if 336 | the user installs one, as long as the modified version is 337 | interface-compatible with the version that the work was made with. 338 | 339 | c) Accompany the work with a written offer, valid for at 340 | least three years, to give the same user the materials 341 | specified in Subsection 6a, above, for a charge no more 342 | than the cost of performing this distribution. 343 | 344 | d) If distribution of the work is made by offering access to copy 345 | from a designated place, offer equivalent access to copy the above 346 | specified materials from the same place. 347 | 348 | e) Verify that the user has already received a copy of these 349 | materials or that you have already sent this user a copy. 350 | 351 | For an executable, the required form of the "work that uses the 352 | Library" must include any data and utility programs needed for 353 | reproducing the executable from it. However, as a special exception, 354 | the materials to be distributed need not include anything that is 355 | normally distributed (in either source or binary form) with the major 356 | components (compiler, kernel, and so on) of the operating system on 357 | which the executable runs, unless that component itself accompanies 358 | the executable. 359 | 360 | It may happen that this requirement contradicts the license 361 | restrictions of other proprietary libraries that do not normally 362 | accompany the operating system. Such a contradiction means you cannot 363 | use both them and the Library together in an executable that you 364 | distribute. 365 | 366 | 7. You may place library facilities that are a work based on the 367 | Library side-by-side in a single library together with other library 368 | facilities not covered by this License, and distribute such a combined 369 | library, provided that the separate distribution of the work based on 370 | the Library and of the other library facilities is otherwise 371 | permitted, and provided that you do these two things: 372 | 373 | a) Accompany the combined library with a copy of the same work 374 | based on the Library, uncombined with any other library 375 | facilities. This must be distributed under the terms of the 376 | Sections above. 377 | 378 | b) Give prominent notice with the combined library of the fact 379 | that part of it is a work based on the Library, and explaining 380 | where to find the accompanying uncombined form of the same work. 381 | 382 | 8. You may not copy, modify, sublicense, link with, or distribute 383 | the Library except as expressly provided under this License. Any 384 | attempt otherwise to copy, modify, sublicense, link with, or 385 | distribute the Library is void, and will automatically terminate your 386 | rights under this License. However, parties who have received copies, 387 | or rights, from you under this License will not have their licenses 388 | terminated so long as such parties remain in full compliance. 389 | 390 | 9. You are not required to accept this License, since you have not 391 | signed it. However, nothing else grants you permission to modify or 392 | distribute the Library or its derivative works. These actions are 393 | prohibited by law if you do not accept this License. Therefore, by 394 | modifying or distributing the Library (or any work based on the 395 | Library), you indicate your acceptance of this License to do so, and 396 | all its terms and conditions for copying, distributing or modifying 397 | the Library or works based on it. 398 | 399 | 10. Each time you redistribute the Library (or any work based on the 400 | Library), the recipient automatically receives a license from the 401 | original licensor to copy, distribute, link with or modify the Library 402 | subject to these terms and conditions. You may not impose any further 403 | restrictions on the recipients' exercise of the rights granted herein. 404 | You are not responsible for enforcing compliance by third parties with 405 | this License. 406 | 407 | 11. If, as a consequence of a court judgment or allegation of patent 408 | infringement or for any other reason (not limited to patent issues), 409 | conditions are imposed on you (whether by court order, agreement or 410 | otherwise) that contradict the conditions of this License, they do not 411 | excuse you from the conditions of this License. If you cannot 412 | distribute so as to satisfy simultaneously your obligations under this 413 | License and any other pertinent obligations, then as a consequence you 414 | may not distribute the Library at all. For example, if a patent 415 | license would not permit royalty-free redistribution of the Library by 416 | all those who receive copies directly or indirectly through you, then 417 | the only way you could satisfy both it and this License would be to 418 | refrain entirely from distribution of the Library. 419 | 420 | If any portion of this section is held invalid or unenforceable under any 421 | particular circumstance, the balance of the section is intended to apply, 422 | and the section as a whole is intended to apply in other circumstances. 423 | 424 | It is not the purpose of this section to induce you to infringe any 425 | patents or other property right claims or to contest validity of any 426 | such claims; this section has the sole purpose of protecting the 427 | integrity of the free software distribution system which is 428 | implemented by public license practices. Many people have made 429 | generous contributions to the wide range of software distributed 430 | through that system in reliance on consistent application of that 431 | system; it is up to the author/donor to decide if he or she is willing 432 | to distribute software through any other system and a licensee cannot 433 | impose that choice. 434 | 435 | This section is intended to make thoroughly clear what is believed to 436 | be a consequence of the rest of this License. 437 | 438 | 12. If the distribution and/or use of the Library is restricted in 439 | certain countries either by patents or by copyrighted interfaces, the 440 | original copyright holder who places the Library under this License may add 441 | an explicit geographical distribution limitation excluding those countries, 442 | so that distribution is permitted only in or among countries not thus 443 | excluded. In such case, this License incorporates the limitation as if 444 | written in the body of this License. 445 | 446 | 13. The Free Software Foundation may publish revised and/or new 447 | versions of the Lesser General Public License from time to time. 448 | Such new versions will be similar in spirit to the present version, 449 | but may differ in detail to address new problems or concerns. 450 | 451 | Each version is given a distinguishing version number. If the Library 452 | specifies a version number of this License which applies to it and 453 | "any later version", you have the option of following the terms and 454 | conditions either of that version or of any later version published by 455 | the Free Software Foundation. If the Library does not specify a 456 | license version number, you may choose any version ever published by 457 | the Free Software Foundation. 458 | 459 | 14. If you wish to incorporate parts of the Library into other free 460 | programs whose distribution conditions are incompatible with these, 461 | write to the author to ask for permission. For software which is 462 | copyrighted by the Free Software Foundation, write to the Free 463 | Software Foundation; we sometimes make exceptions for this. Our 464 | decision will be guided by the two goals of preserving the free status 465 | of all derivatives of our free software and of promoting the sharing 466 | and reuse of software generally. 467 | 468 | NO WARRANTY 469 | 470 | 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO 471 | WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. 472 | EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR 473 | OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY 474 | KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE 475 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 476 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE 477 | LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME 478 | THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 479 | 480 | 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN 481 | WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY 482 | AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU 483 | FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR 484 | CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE 485 | LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING 486 | RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A 487 | FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF 488 | SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH 489 | DAMAGES. 490 | 491 | END OF TERMS AND CONDITIONS 492 | -------------------------------------------------------------------------------- /MinecraftForge-Credits.txt: -------------------------------------------------------------------------------- 1 | * Eloraam * 2 | 3 | * FlowerChild * 4 | 5 | * Hawkye * 6 | 7 | * MALfunction84 * 8 | 9 | Submitted the sleep handler code for his mod (Somnia) and others to use. 10 | 11 | * Scokeev9 * 12 | 13 | Gave permission for ScotTools API to be integrated into MCF, and also supported the Forge by converting his mods to use it. 14 | 15 | ScotTools Background: ScotTools was an API that enabled modders to add blocks to harvesting levels (and many other ease-of-use features to create new tools), and the first tool API that used block material for block breaking efficiency which allowed blocks from mods that didn't use ScotTools API to break with the correct speed. 16 | 17 | * SpaceToad * 18 | 19 | * LexManos * 20 | 21 | * cpw * 22 | 23 | * Minecraft Coder Pack (MCP) * 24 | Forge Mod Loader and Minecraft Forge have permission to distribute and automatically download components of MCP and distribute MCP data files. 25 | This permission is not transitive and others wishing to redistribute the Minecraft Forge source independently should seek permission of MCP or 26 | remove the MCP data files and request their users to download MCP separately. 27 | -------------------------------------------------------------------------------- /MinecraftForge-License.txt: -------------------------------------------------------------------------------- 1 | Minecraft Forge Public Licence 2 | ============================== 3 | 4 | Version 1.0 5 | 6 | 0. Definitions 7 | -------------- 8 | 9 | Minecraft: Denotes a copy of the Minecraft game licensed by Mojang AB 10 | 11 | User: Anybody that interract with the software in one of the following ways: 12 | - play 13 | - decompile 14 | - recompile or compile 15 | - modify 16 | 17 | Minecraft Forge: The Minecraft Forge code, in source form, class file form, as 18 | obtained in a standalone fashion or as part of a wider distribution. 19 | 20 | Dependency: Code required to have Minecraft Forge working properly. That can 21 | include dependencies required to compile the code as well as modifications in 22 | the Minecraft sources that are required to have Minecraft Forge working. 23 | 24 | 1. Scope 25 | -------- 26 | 27 | The present license is granted to any user of Minecraft Forge, for all files included 28 | unless stated otherwise in the file itself. As a prerequisite, a user of Minecraft 29 | Forge must own a legally aquired copy of Minecraft. 30 | 31 | 2. Play rights 32 | -------------- 33 | 34 | The user of Minecraft Forge is allowed to install the software on a client or 35 | a server and to play it without restriction. 36 | 37 | 3. Modification rights 38 | ---------------------- 39 | 40 | The user has the right to decompile the source code, look at either the 41 | decompiled version or the original source code, and to modify it. 42 | 43 | 4. Derivation rights 44 | -------------------- 45 | 46 | The user has the rights to derive code from Minecraft Forge, that is to say to 47 | write code that either extends Minecraft Forge class and interfaces, 48 | instantiate the objects declared or calls the functions. This code is known as 49 | "derived" code, and can be licensed with conditions different from Minecraft 50 | Forge. 51 | 52 | 53 | 5. Distribution rights 54 | ---------------------- 55 | 56 | The user of Minecraft Forge is allowed to redistribute Minecraft Forge in 57 | partially, in totallity, or included in a distribution. When distributing 58 | binaries or class files, the user must provide means to obtain the sources of 59 | the distributed version of Minecraft Forge at no costs. This includes the 60 | files as well as any dependency that the code may rely on, including patches to 61 | minecraft original sources. 62 | 63 | Modification of Minecraft Forge as well as dependencies, including patches to 64 | minecraft original sources, has to remain under the terms of the present 65 | license. 66 | 67 | The right to distribute Minecraft Forge does not extend to the right to distribute 68 | MCP data files included within Minecraft Forge. These are the property of the MCP 69 | project and should be removed from any customized distribution of Minecraft Forge 70 | or permission sought separately from the MCP team. 71 | -------------------------------------------------------------------------------- /Paulscode IBXM Library License.txt: -------------------------------------------------------------------------------- 1 | IBXM is copyright (c) 2007, Martin Cameron, and is licensed under the BSD License. 2 | All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 5 | 6 | Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 7 | Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 8 | Neither the name of mumart nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. 9 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 10 | 11 | -------------------------------------------------------------------------------- /Paulscode SoundSystem CodecIBXM License.txt: -------------------------------------------------------------------------------- 1 | SoundSystem CodecIBXM Class License: 2 | 3 | You are free to use this class for any purpose, commercial or otherwise. 4 | You may modify this class or source code, and distribute it any way you 5 | like, provided the following conditions are met: 6 | 7 | 1) You may not falsely claim to be the author of this class or any 8 | unmodified portion of it. 9 | 2) You may not copyright this class or a modified version of it and then 10 | sue me for copyright infringement. 11 | 3) If you modify the source code, you must clearly document the changes 12 | made before redistributing the modified source code, so other users know 13 | it is not the original code. 14 | 4) You are not required to give me credit for this class in any derived 15 | work, but if you do, you must also mention my website: 16 | http://www.paulscode.com 17 | 5) I the author will not be responsible for any damages (physical, 18 | financial, or otherwise) caused by the use if this class or any 19 | portion of it. 20 | 6) I the author do not guarantee, warrant, or make any representations, 21 | either expressed or implied, regarding the use of this class or any 22 | portion of it. 23 | 24 | Author: Paul Lamb 25 | http://www.paulscode.com 26 | 27 | 28 | This software is based on or using the IBXM library available from 29 | http://www.geocities.com/sunet2000/ 30 | 31 | 32 | IBXM is copyright (c) 2007, Martin Cameron, and is licensed under the BSD License. 33 | All rights reserved. 34 | 35 | Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 36 | 37 | Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 38 | Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 39 | Neither the name of mumart nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. 40 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 41 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # DG-Lab-Mod 2 | 一个可以连接到DG-Lab设备并进行操作的Minecraft mod 3 | 可以根据扣血事件来调整强度 4 | # 连接 5 | 连接部分使用https://github.com/SakuraKoi/DgLabUnlocker 模块的“对外开放Websocket RPC服务端口”功能,所以需要先下载DG-Lab 1.3.2版本:https://dungeon-lab.cn/appDownload/dlab1.3.2.apk ,并安装好DgLabUnlocker模块,在右上角模块设置-功能设置中打开“开放RPC服务端口”,并确保该手机与电脑处于同一网络下。 6 | ~其实是不想在Java里折腾蓝牙协议了~ 7 | 进入游戏,输入/dglab connect [ip] 来连接到设备,ip可以从手机上的wifi-设置-高级-IP地址中看到。 8 | 如成功连接,应该会看到提示“Connected to [ip]" 9 | # 使用 10 | 以下是指令列表以及说明: 11 | `/dglab connect `    连接到对应ip的设备 12 | `/dglab disconnect`    从设备断开连接 13 | `/dglab getStrength`    获取当前A、B通道强度 14 | `/dglab setMaxStrength [20~276] [20~276]`    设置A、B通道最大强度,mod对强度的调整不会超过此强度限制,默认为100 15 | `/dglab getMaxStrength`    获取当前最大强度设置 16 | `/dglab addStrength [value]`   对A/B通道增加 value 强度 17 | `/dglab setBaseStrength [value] [value]`    设置基础强度,punish 模式下当 punishTime 结束后会回到此强度,默认为20 18 | `/dglab getBaseStrength`    获取当前基础强度设置 19 | `/dglab setPunishTime [seconds]`    设置当前惩罚持续时间,单位为秒,默认为3 20 | `/dglab setPunishRate [value]`    设置当前惩罚倍数,默认为5 21 | `/dglab punish/ultraPunish `    开始或停止 punish/ultraPunish 模式 22 | # Punish 模式 23 | 当 punish 启动后,mod将会开始监听受伤事件 24 | 当玩家受到 damage 点hp的伤害时(1颗心=2hp),将会将强度提升 (damage*punishRate),持续 punishTime 秒 25 | 在 punishTime 持续期间,受到的其他伤害会被忽略,时间结束后强度会被恢复为基础强度 26 | # UltraPunish模式 27 | 一个特殊的惩罚模式,当 ultraPunish 启动后,mod将会开始监听受伤事件 28 | 当玩家受到 damage 点hp的伤害时(1颗心=2hp),将会将强度提升 (damage*punishRate),持续 punishTime 秒 29 | 在 punishTime 持续期间,受到的其他伤害会被叠加,并重新计算 punishTime ,时间结束后强度会被恢复为基础强度 30 | 31 | 注意:punish 模式不能和 ultraPunish 模式同时开启,如已经启动了一个模式,在启动另一个模式时将会自动关闭此模式 32 | -------------------------------------------------------------------------------- /build.gradle: -------------------------------------------------------------------------------- 1 | // For those who want the bleeding edge 2 | buildscript { 3 | repositories { 4 | maven { 5 | name = "forge" 6 | url = "http://files.minecraftforge.net/maven" 7 | } 8 | mavenCentral() 9 | } 10 | dependencies { 11 | classpath 'net.minecraftforge.gradle:ForgeGradle:2.1-SNAPSHOT' 12 | } 13 | } 14 | 15 | plugins { 16 | id 'java' 17 | id 'com.github.johnrengelman.shadow' version '1.2.4' 18 | // ... 19 | } 20 | 21 | apply plugin: 'net.minecraftforge.gradle.forge' 22 | 23 | /* 24 | // for people who want stable - not yet functional for MC 1.8.8 - we require the forgegradle 2.1 snapshot 25 | plugins { 26 | id "net.minecraftforge.gradle.forge" version "2.0.2" 27 | } 28 | */ 29 | version = "1.0.0" 30 | group = "com.yuluo.dglab_controller" // http://maven.apache.org/guides/mini/guide-naming-conventions.html 31 | archivesBaseName = "DG-LabController" 32 | 33 | minecraft { 34 | version = "1.8.9-11.15.1.2318-1.8.9" 35 | runDir = "run" 36 | 37 | // the mappings can be changed at any time, and must be in the following format. 38 | // snapshot_YYYYMMDD snapshot are built nightly. 39 | // stable_# stables are built at the discretion of the MCP team. 40 | // Use non-default mappings at your own risk. they may not allways work. 41 | // simply re-run your setup task after changing the mappings to update your workspace. 42 | mappings = "stable_20" 43 | // makeObfSourceJar = false // an Srg named sources jar is made by default. uncomment this to disable. 44 | } 45 | 46 | sourceCompatibility = JavaVersion.VERSION_1_8 47 | targetCompatibility = JavaVersion.VERSION_1_8 48 | 49 | dependencies { 50 | compile 'org.java-websocket:Java-WebSocket:1.5.2' 51 | compile 'com.neovisionaries:nv-websocket-client:2.14' 52 | 53 | 54 | shadow 'org.java-websocket:Java-WebSocket:1.5.2' 55 | shadow 'com.neovisionaries:nv-websocket-client:2.14' 56 | // you may put jars on which you depend on in ./libs 57 | // or you may define them like so.. 58 | //compile "some.group:artifact:version:classifier" 59 | //compile "some.group:artifact:version" 60 | 61 | // real examples 62 | //compile 'com.mod-buildcraft:buildcraft:6.0.8:dev' // adds buildcraft to the dev env 63 | //compile 'com.googlecode.efficient-java-matrix-library:ejml:0.24' // adds ejml to the dev env 64 | 65 | // the 'provided' configuration is for optional dependencies that exist at compile-time but might not at runtime. 66 | //provided 'com.mod-buildcraft:buildcraft:6.0.8:dev' 67 | 68 | // the deobf configurations: 'deobfCompile' and 'deobfProvided' are the same as the normal compile and provided, 69 | // except that these dependencies get remapped to your current MCP mappings 70 | //deobfCompile 'com.mod-buildcraft:buildcraft:6.0.8:dev' 71 | //deobfProvided 'com.mod-buildcraft:buildcraft:6.0.8:dev' 72 | 73 | // for more info... 74 | // http://www.gradle.org/docs/current/userguide/artifact_dependencies_tutorial.html 75 | // http://www.gradle.org/docs/current/userguide/dependency_management.html 76 | 77 | } 78 | 79 | processResources { 80 | // this will ensure that this task is redone when the versions change. 81 | inputs.property "version", project.version 82 | inputs.property "mcversion", project.minecraft.version 83 | 84 | // replace stuff in mcmod.info, nothing else 85 | from(sourceSets.main.resources.srcDirs) { 86 | include 'mcmod.info' 87 | 88 | // replace version and mcversion 89 | expand 'version': project.version, 'mcversion': project.minecraft.version 90 | } 91 | 92 | // copy everything else, thats not the mcmod.info 93 | from(sourceSets.main.resources.srcDirs) { 94 | exclude 'mcmod.info' 95 | } 96 | } 97 | 98 | tasks.withType(JavaCompile) { 99 | options.encoding = "UTF-8" 100 | } 101 | 102 | shadowJar { 103 | classifier = "" 104 | configurations = [project.configurations.shadow] 105 | mergeServiceFiles() 106 | relocate 'org.java_websocket', 'com.yuluo.dglab.shadow.org.java_websocket' 107 | } 108 | 109 | jar { 110 | manifest { 111 | attributes 'Implementation-Title': 'DG-Lab Controller', 112 | 'Implementation-Version': version, 113 | 'Implementation-Vendor': 'yuluo', 114 | 'FMLCorePluginContainsFMLMod': 'true' 115 | } 116 | } 117 | 118 | reobfJar { 119 | dependsOn(shadowJar) 120 | } 121 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/YuuLuo/DG-Lab-Mod/f629304be3e4d4957d292434ee83f3571e6ddeee/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Mon Sep 14 12:28:28 PDT 2015 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | distributionUrl=https\://services.gradle.org/distributions/gradle-3.5.1-bin.zip 7 | -------------------------------------------------------------------------------- /gradlew: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | ############################################################################## 4 | ## 5 | ## Gradle start up script for UN*X 6 | ## 7 | ############################################################################## 8 | 9 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 10 | DEFAULT_JVM_OPTS="" 11 | 12 | APP_NAME="Gradle" 13 | APP_BASE_NAME=`basename "$0"` 14 | 15 | # Use the maximum available, or set MAX_FD != -1 to use that value. 16 | MAX_FD="maximum" 17 | 18 | warn ( ) { 19 | echo "$*" 20 | } 21 | 22 | die ( ) { 23 | echo 24 | echo "$*" 25 | echo 26 | exit 1 27 | } 28 | 29 | # OS specific support (must be 'true' or 'false'). 30 | cygwin=false 31 | msys=false 32 | darwin=false 33 | case "`uname`" in 34 | CYGWIN* ) 35 | cygwin=true 36 | ;; 37 | Darwin* ) 38 | darwin=true 39 | ;; 40 | MINGW* ) 41 | msys=true 42 | ;; 43 | esac 44 | 45 | # For Cygwin, ensure paths are in UNIX format before anything is touched. 46 | if $cygwin ; then 47 | [ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"` 48 | fi 49 | 50 | # Attempt to set APP_HOME 51 | # Resolve links: $0 may be a link 52 | PRG="$0" 53 | # Need this for relative symlinks. 54 | while [ -h "$PRG" ] ; do 55 | ls=`ls -ld "$PRG"` 56 | link=`expr "$ls" : '.*-> \(.*\)$'` 57 | if expr "$link" : '/.*' > /dev/null; then 58 | PRG="$link" 59 | else 60 | PRG=`dirname "$PRG"`"/$link" 61 | fi 62 | done 63 | SAVED="`pwd`" 64 | cd "`dirname \"$PRG\"`/" >&- 65 | APP_HOME="`pwd -P`" 66 | cd "$SAVED" >&- 67 | 68 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 69 | 70 | # Determine the Java command to use to start the JVM. 71 | if [ -n "$JAVA_HOME" ] ; then 72 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 73 | # IBM's JDK on AIX uses strange locations for the executables 74 | JAVACMD="$JAVA_HOME/jre/sh/java" 75 | else 76 | JAVACMD="$JAVA_HOME/bin/java" 77 | fi 78 | if [ ! -x "$JAVACMD" ] ; then 79 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 80 | 81 | Please set the JAVA_HOME variable in your environment to match the 82 | location of your Java installation." 83 | fi 84 | else 85 | JAVACMD="java" 86 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 87 | 88 | Please set the JAVA_HOME variable in your environment to match the 89 | location of your Java installation." 90 | fi 91 | 92 | # Increase the maximum file descriptors if we can. 93 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then 94 | MAX_FD_LIMIT=`ulimit -H -n` 95 | if [ $? -eq 0 ] ; then 96 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then 97 | MAX_FD="$MAX_FD_LIMIT" 98 | fi 99 | ulimit -n $MAX_FD 100 | if [ $? -ne 0 ] ; then 101 | warn "Could not set maximum file descriptor limit: $MAX_FD" 102 | fi 103 | else 104 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" 105 | fi 106 | fi 107 | 108 | # For Darwin, add options to specify how the application appears in the dock 109 | if $darwin; then 110 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" 111 | fi 112 | 113 | # For Cygwin, switch paths to Windows format before running java 114 | if $cygwin ; then 115 | APP_HOME=`cygpath --path --mixed "$APP_HOME"` 116 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` 117 | 118 | # We build the pattern for arguments to be converted via cygpath 119 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` 120 | SEP="" 121 | for dir in $ROOTDIRSRAW ; do 122 | ROOTDIRS="$ROOTDIRS$SEP$dir" 123 | SEP="|" 124 | done 125 | OURCYGPATTERN="(^($ROOTDIRS))" 126 | # Add a user-defined pattern to the cygpath arguments 127 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then 128 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" 129 | fi 130 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 131 | i=0 132 | for arg in "$@" ; do 133 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` 134 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option 135 | 136 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition 137 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` 138 | else 139 | eval `echo args$i`="\"$arg\"" 140 | fi 141 | i=$((i+1)) 142 | done 143 | case $i in 144 | (0) set -- ;; 145 | (1) set -- "$args0" ;; 146 | (2) set -- "$args0" "$args1" ;; 147 | (3) set -- "$args0" "$args1" "$args2" ;; 148 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;; 149 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; 150 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; 151 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; 152 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; 153 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; 154 | esac 155 | fi 156 | 157 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules 158 | function splitJvmOpts() { 159 | JVM_OPTS=("$@") 160 | } 161 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS 162 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME" 163 | 164 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@" 165 | -------------------------------------------------------------------------------- /gradlew.bat: -------------------------------------------------------------------------------- 1 | @if "%DEBUG%" == "" @echo off 2 | @rem ########################################################################## 3 | @rem 4 | @rem Gradle startup script for Windows 5 | @rem 6 | @rem ########################################################################## 7 | 8 | @rem Set local scope for the variables with windows NT shell 9 | if "%OS%"=="Windows_NT" setlocal 10 | 11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 12 | set DEFAULT_JVM_OPTS= 13 | 14 | set DIRNAME=%~dp0 15 | if "%DIRNAME%" == "" set DIRNAME=. 16 | set APP_BASE_NAME=%~n0 17 | set APP_HOME=%DIRNAME% 18 | 19 | @rem Find java.exe 20 | if defined JAVA_HOME goto findJavaFromJavaHome 21 | 22 | set JAVA_EXE=java.exe 23 | %JAVA_EXE% -version >NUL 2>&1 24 | if "%ERRORLEVEL%" == "0" goto init 25 | 26 | echo. 27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 28 | echo. 29 | echo Please set the JAVA_HOME variable in your environment to match the 30 | echo location of your Java installation. 31 | 32 | goto fail 33 | 34 | :findJavaFromJavaHome 35 | set JAVA_HOME=%JAVA_HOME:"=% 36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 37 | 38 | if exist "%JAVA_EXE%" goto init 39 | 40 | echo. 41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 42 | echo. 43 | echo Please set the JAVA_HOME variable in your environment to match the 44 | echo location of your Java installation. 45 | 46 | goto fail 47 | 48 | :init 49 | @rem Get command-line arguments, handling Windowz variants 50 | 51 | if not "%OS%" == "Windows_NT" goto win9xME_args 52 | if "%@eval[2+2]" == "4" goto 4NT_args 53 | 54 | :win9xME_args 55 | @rem Slurp the command line arguments. 56 | set CMD_LINE_ARGS= 57 | set _SKIP=2 58 | 59 | :win9xME_args_slurp 60 | if "x%~1" == "x" goto execute 61 | 62 | set CMD_LINE_ARGS=%* 63 | goto execute 64 | 65 | :4NT_args 66 | @rem Get arguments from the 4NT Shell from JP Software 67 | set CMD_LINE_ARGS=%$ 68 | 69 | :execute 70 | @rem Setup the command line 71 | 72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 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 %CMD_LINE_ARGS% 76 | 77 | :end 78 | @rem End local scope for the variables with windows NT shell 79 | if "%ERRORLEVEL%"=="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 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 85 | exit /b 1 86 | 87 | :mainEnd 88 | if "%OS%"=="Windows_NT" endlocal 89 | 90 | :omega 91 | -------------------------------------------------------------------------------- /src/main/java/com/yuluo/dglab/CommandDglab.java: -------------------------------------------------------------------------------- 1 | package com.yuluo.dglab; 2 | 3 | import net.minecraft.command.CommandBase; 4 | import net.minecraft.command.ICommandSender; 5 | import net.minecraft.command.WrongUsageException; 6 | import net.minecraft.util.ChatComponentText; 7 | 8 | import java.util.Arrays; 9 | 10 | public class CommandDglab extends CommandBase { 11 | private final CommandDglabConnect connectHandler; 12 | private final CommandDglabStrength strengthHandler; 13 | private final CommandDglabPunish punishHandler; 14 | 15 | public CommandDglab() { 16 | connectHandler = new CommandDglabConnect(); 17 | strengthHandler = new CommandDglabStrength(); 18 | punishHandler = new CommandDglabPunish(); 19 | } 20 | 21 | @Override 22 | public String getCommandName() { 23 | return "dglab"; 24 | } 25 | 26 | @Override 27 | public String getCommandUsage(ICommandSender sender) { 28 | return "/dglab \n" + 29 | "/dglab connect \n" + 30 | "/dglab disconnect\n" + 31 | "/dglab setStrength [0~maxStrengthA] [0~maxStrengthB]\n" + 32 | "/dglab getStrength\n" + 33 | "/dglab setMaxStrength [20~276] [20~276]\n" + 34 | "/dglab getMaxStrength\n" + 35 | "/dglab addStrength [value]\n" + 36 | "/dglab setBaseStrength [value]\n" + 37 | "/dglab getBaseStrength\n" + 38 | "/dglab setPunishTime [seconds]\n" + 39 | "/dglab setPunishRate [value]\n" + 40 | "/dglab getPunishSetting\n"; 41 | } 42 | 43 | @Override 44 | public void processCommand(ICommandSender sender, String[] args) throws WrongUsageException { 45 | if (args.length == 0 || args[0].equalsIgnoreCase("help")) { 46 | displayHelp(sender); 47 | return; 48 | } 49 | 50 | String subCommand = args[0].toLowerCase(); 51 | 52 | switch (subCommand) { 53 | case "connect": 54 | if (args.length < 2) { 55 | throw new WrongUsageException(connectHandler.getCommandUsage(sender)); 56 | } 57 | connectHandler.processCommand(sender, Arrays.copyOfRange(args, 1, args.length)); 58 | break; 59 | 60 | case "disconnect": 61 | connectHandler.processCommand(sender, args); 62 | break; 63 | 64 | case "getstrength": 65 | case "getbasestrength": 66 | case "getmaxstrength": 67 | strengthHandler.processCommand(sender, args); 68 | break; 69 | 70 | case "setmaxstrength": 71 | case "setbasestrength": 72 | case "addstrength": 73 | case "setstrength": 74 | if (args.length < 3) { 75 | throw new WrongUsageException(strengthHandler.getCommandUsage(sender)); 76 | } 77 | strengthHandler.processCommand(sender, args); 78 | break; 79 | 80 | case "setpunishtime": 81 | case "setpunishrate": 82 | if (args.length < 2) { 83 | throw new WrongUsageException(punishHandler.getCommandUsage(sender)); 84 | } 85 | punishHandler.processCommand(sender, args); 86 | break; 87 | 88 | case "getpunishsetting": 89 | case "punish": 90 | case "ultrapunish": 91 | punishHandler.processCommand(sender, args); 92 | break; 93 | 94 | default: 95 | System.out.println("2"); 96 | throw new WrongUsageException(getCommandUsage(sender)); 97 | } 98 | } 99 | 100 | private void displayHelp(ICommandSender sender) { 101 | sender.addChatMessage(new ChatComponentText(getCommandUsage(sender))); 102 | } 103 | } 104 | -------------------------------------------------------------------------------- /src/main/java/com/yuluo/dglab/CommandDglabConnect.java: -------------------------------------------------------------------------------- 1 | package com.yuluo.dglab; 2 | 3 | import com.neovisionaries.ws.client.WebSocket; 4 | import com.neovisionaries.ws.client.WebSocketAdapter; 5 | import com.neovisionaries.ws.client.WebSocketException; 6 | import com.neovisionaries.ws.client.WebSocketFactory; 7 | import com.neovisionaries.ws.client.WebSocketFrame; 8 | import net.minecraft.command.CommandBase; 9 | import net.minecraft.command.ICommandSender; 10 | import net.minecraft.command.WrongUsageException; 11 | import net.minecraft.util.ChatComponentText; 12 | 13 | import java.io.IOException; 14 | import java.net.URI; 15 | import java.net.URISyntaxException; 16 | import java.util.List; 17 | import java.util.Map; 18 | 19 | public class CommandDglabConnect extends CommandBase { 20 | private static WebSocket ws; 21 | private static CommandDglabConnect instance; 22 | 23 | public CommandDglabConnect() { 24 | instance = this; 25 | } 26 | 27 | public static WebSocket getClientInstance() { 28 | if (instance != null && ws != null) { 29 | System.out.println("Returning WebSocket client instance: " + ws); 30 | } else { 31 | System.out.println("No WebSocket client instance found."); 32 | } 33 | return ws; 34 | } 35 | 36 | public interface WebSocketMessageCallback { 37 | void onWebSocketMessage(ICommandSender sender, String message); 38 | } 39 | 40 | private static WebSocketMessageCallback messageCallback; 41 | 42 | public static void setWebSocketMessageCallback(WebSocketMessageCallback callback) { 43 | messageCallback = callback; 44 | } 45 | 46 | @Override 47 | public void processCommand(final ICommandSender sender, String[] args) throws WrongUsageException { 48 | if (args.length < 1) { 49 | throw new WrongUsageException(getCommandUsage(sender)); 50 | } 51 | String subCommand = args[0].toLowerCase(); 52 | if (!subCommand.equals("disconnect")) { 53 | final String deviceAddress = args[0]; 54 | int wsPort = 23301; 55 | 56 | try { 57 | URI deviceUri = new URI("ws://" + deviceAddress + ":" + wsPort); 58 | 59 | WebSocketFactory factory = new WebSocketFactory(); 60 | ws = factory.createSocket(deviceUri); 61 | 62 | ws.addListener(new WebSocketAdapter() { 63 | @Override 64 | public void onTextMessage(WebSocket websocket, String message) { 65 | if (messageCallback != null) { 66 | messageCallback.onWebSocketMessage(sender, message); 67 | } 68 | } 69 | 70 | @Override 71 | public void onConnected(WebSocket websocket, Map> headers) { 72 | sender.addChatMessage(new ChatComponentText("Connected to " + deviceAddress)); 73 | } 74 | 75 | @Override 76 | public void onDisconnected(WebSocket websocket, WebSocketFrame serverCloseFrame, WebSocketFrame clientCloseFrame, boolean closedByServer) { 77 | sender.addChatMessage(new ChatComponentText("Disconnected from " + deviceAddress)); 78 | } 79 | 80 | @Override 81 | public void onError(WebSocket websocket, WebSocketException cause) { 82 | sender.addChatMessage(new ChatComponentText("Error: " + cause.getMessage())); 83 | } 84 | }); 85 | 86 | ws.connect(); 87 | 88 | } catch (URISyntaxException e) { 89 | sender.addChatMessage(new ChatComponentText("Error: " + e.getMessage())); 90 | e.printStackTrace(); 91 | } catch (IOException | WebSocketException e) { 92 | e.printStackTrace(); 93 | } 94 | } else { 95 | ws.disconnect(); 96 | sender.addChatMessage(new ChatComponentText("Connection closed by player.")); 97 | } 98 | } 99 | 100 | @Override 101 | public String getCommandName() { 102 | return null; 103 | } 104 | 105 | @Override 106 | public String getCommandUsage(ICommandSender sender) { 107 | return "/dglab connect [your device address]"; 108 | } 109 | } 110 | -------------------------------------------------------------------------------- /src/main/java/com/yuluo/dglab/CommandDglabPunish.java: -------------------------------------------------------------------------------- 1 | package com.yuluo.dglab; 2 | 3 | import net.minecraft.command.CommandBase; 4 | import net.minecraft.command.ICommandSender; 5 | import net.minecraft.entity.player.EntityPlayer; 6 | import net.minecraft.util.ChatComponentText; 7 | import net.minecraft.util.EnumChatFormatting; 8 | import net.minecraftforge.event.entity.living.LivingHurtEvent; 9 | import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; 10 | 11 | import java.util.Timer; 12 | import java.util.TimerTask; 13 | 14 | public class CommandDglabPunish extends CommandBase { 15 | 16 | private static boolean punishActive = false; 17 | private static boolean ultraPunishActive = false; 18 | private static int punishTime = 3; // 设置惩罚持续时间,单位为秒 19 | private static int punishRate = 5; // 设置惩罚比例 20 | private EntityPlayer playerToPunish; 21 | private long punishEndTime = 0; 22 | 23 | 24 | private Timer ultraPunishTimer; 25 | 26 | 27 | @SubscribeEvent 28 | public void onLivingHurt(LivingHurtEvent event) { 29 | if (event.entityLiving instanceof EntityPlayer) { 30 | EntityPlayer player = (EntityPlayer) event.entityLiving; 31 | 32 | if (punishActive && System.currentTimeMillis() > punishEndTime) { 33 | float damage = event.ammount; 34 | System.out.println("received punish damage: " + damage); 35 | startPunish(player, damage); 36 | } else if (ultraPunishActive) { 37 | float damage = event.ammount; 38 | startUltraPunish(player, damage); 39 | } 40 | System.out.println(punishActive + " " + (System.currentTimeMillis() > punishEndTime) + " " + System.currentTimeMillis() + " " + punishEndTime); 41 | float damage = event.ammount; 42 | System.out.println("received damage: " + damage); 43 | } 44 | } 45 | 46 | 47 | private void startPunish(final ICommandSender sender, float damage) { 48 | // 获取当前强度值 49 | CommandDglabStrength.queryStrength(sender, true); 50 | 51 | // 计算惩罚强度值 52 | int punishStrengthA = CommandDglabStrength.getCurrentStrengthA() + (int) (damage * punishRate); 53 | int punishStrengthB = CommandDglabStrength.getCurrentStrengthB() + (int) (damage * punishRate); 54 | 55 | 56 | // 设置新的强度值 57 | CommandDglabStrength.instance.setStrength(null, punishStrengthA, punishStrengthB); 58 | 59 | ChatComponentText message = new ChatComponentText("Received damage: "); 60 | message.getChatStyle().setColor(EnumChatFormatting.WHITE); 61 | 62 | ChatComponentText damageComponent = new ChatComponentText(String.valueOf(damage)); 63 | damageComponent.getChatStyle().setColor(EnumChatFormatting.AQUA); 64 | 65 | ChatComponentText part2 = new ChatComponentText(" HP, setting strength to: "); 66 | part2.getChatStyle().setColor(EnumChatFormatting.WHITE); 67 | 68 | ChatComponentText strengthComponent = new ChatComponentText(String.valueOf(punishStrengthA)); 69 | strengthComponent.getChatStyle().setColor(EnumChatFormatting.LIGHT_PURPLE); 70 | 71 | ChatComponentText part3 = new ChatComponentText(", "); 72 | part3.getChatStyle().setColor(EnumChatFormatting.WHITE); 73 | 74 | ChatComponentText strengthComponent2 = new ChatComponentText(String.valueOf(punishStrengthB)); 75 | strengthComponent2.getChatStyle().setColor(EnumChatFormatting.LIGHT_PURPLE); 76 | 77 | message.appendSibling(damageComponent); 78 | message.appendSibling(part2); 79 | message.appendSibling(strengthComponent); 80 | message.appendSibling(part3); 81 | message.appendSibling(strengthComponent2); 82 | 83 | sender.addChatMessage(message); 84 | // 在惩罚结束时恢复基础强度值 85 | punishEndTime = System.currentTimeMillis() + (punishTime * 1000L); 86 | new Timer().schedule( 87 | new TimerTask() { 88 | @Override 89 | public void run() { 90 | CommandDglabStrength.instance.setStrength(sender, CommandDglabStrength.getBaseStrengthA(), CommandDglabStrength.getBaseStrengthB()); 91 | } 92 | }, 93 | punishTime * 1000L 94 | ); 95 | } 96 | 97 | private void startUltraPunish(final ICommandSender sender, float damage) { 98 | System.out.println(CommandDglabStrength.getCurrentStrengthA() + " " + CommandDglabStrength.getCurrentStrengthB()); 99 | // 获取当前强度值 100 | CommandDglabStrength.queryStrength(sender, true); 101 | // 计算惩罚强度值 102 | int punishStrengthA = (int) (damage * punishRate); 103 | int punishStrengthB = (int) (damage * punishRate); 104 | 105 | 106 | if (punishStrengthA + CommandDglabStrength.getCurrentStrengthA() > CommandDglabStrength.getMaxStrengthA()) { 107 | sender.addChatMessage(new ChatComponentText("Strength A exceeds the maximum limit (" + CommandDglabStrength.getMaxStrengthA() + "). Setting to max limit.")); 108 | punishStrengthA = CommandDglabStrength.getMaxStrengthA() - CommandDglabStrength.getCurrentStrengthA(); 109 | } 110 | if (punishStrengthB + CommandDglabStrength.getCurrentStrengthB() > CommandDglabStrength.getMaxStrengthB()) { 111 | sender.addChatMessage(new ChatComponentText("Strength B exceeds the maximum limit (" + CommandDglabStrength.getMaxStrengthB() + "). Setting to max limit.")); 112 | punishStrengthB = CommandDglabStrength.getMaxStrengthB() - CommandDglabStrength.getCurrentStrengthB(); 113 | } 114 | 115 | // 设置新的强度值 116 | int resultStrengthA = CommandDglabStrength.getCurrentStrengthA() + punishStrengthA; 117 | int resultStrengthB = CommandDglabStrength.getCurrentStrengthB() + punishStrengthB; 118 | CommandDglabStrength.instance.addStrength(sender, "a", punishStrengthA); 119 | CommandDglabStrength.instance.addStrength(sender, "b", punishStrengthB); 120 | 121 | 122 | //设置字体颜色 123 | ChatComponentText ultraMode = new ChatComponentText("[Ultra mode]"); 124 | ultraMode.getChatStyle().setColor(EnumChatFormatting.RED); 125 | 126 | ChatComponentText message = new ChatComponentText("Received damage: "); 127 | message.getChatStyle().setColor(EnumChatFormatting.WHITE); 128 | 129 | ChatComponentText damageComponent = new ChatComponentText(String.valueOf(damage)); 130 | damageComponent.getChatStyle().setColor(EnumChatFormatting.BLUE); 131 | 132 | ChatComponentText part2 = new ChatComponentText(" HP, increasing strength to: "); 133 | part2.getChatStyle().setColor(EnumChatFormatting.WHITE); 134 | 135 | ChatComponentText strengthComponent = new ChatComponentText(String.valueOf(resultStrengthA)); 136 | strengthComponent.getChatStyle().setColor(EnumChatFormatting.LIGHT_PURPLE); 137 | 138 | ChatComponentText part3 = new ChatComponentText(", "); 139 | part3.getChatStyle().setColor(EnumChatFormatting.WHITE); 140 | 141 | ChatComponentText strengthComponent2 = new ChatComponentText(String.valueOf(resultStrengthB)); 142 | strengthComponent2.getChatStyle().setColor(EnumChatFormatting.LIGHT_PURPLE); 143 | 144 | ultraMode.appendSibling(message); 145 | ultraMode.appendSibling(damageComponent); 146 | ultraMode.appendSibling(part2); 147 | ultraMode.appendSibling(strengthComponent); 148 | ultraMode.appendSibling(part3); 149 | ultraMode.appendSibling(strengthComponent2); 150 | 151 | sender.addChatMessage(ultraMode); 152 | 153 | 154 | // 在惩罚结束时恢复基础强度值 155 | punishEndTime = System.currentTimeMillis() + (punishTime * 1000L); 156 | if (ultraPunishTimer != null) { 157 | ultraPunishTimer.cancel(); // 取消上一个 Timer 158 | } 159 | ultraPunishTimer = new Timer(); 160 | ultraPunishTimer.schedule( 161 | new TimerTask() { 162 | @Override 163 | public void run() { 164 | CommandDglabStrength.instance.setStrength(sender, CommandDglabStrength.getBaseStrengthA(), CommandDglabStrength.getBaseStrengthB()); 165 | } 166 | }, 167 | punishTime * 1000L 168 | ); 169 | } 170 | 171 | 172 | @Override 173 | public void processCommand(ICommandSender sender, String[] args) { 174 | /*if (args.length < 1) { 175 | sender.addChatMessage(new ChatComponentText("Usage: " + getCommandUsage(sender))); 176 | return; 177 | }*/ 178 | 179 | String subCommand = args[0].toLowerCase(); 180 | 181 | switch (subCommand) { 182 | case "punish": { 183 | if (sender instanceof EntityPlayer) { 184 | playerToPunish = (EntityPlayer) sender; 185 | } else { 186 | sender.addChatMessage(new ChatComponentText("This command can only be used by a player.")); 187 | return; 188 | } 189 | 190 | String option = args[1].toLowerCase(); 191 | 192 | if (option.equals("start")) { 193 | if (punishActive) { 194 | sender.addChatMessage(new ChatComponentText("Punish already started!")); 195 | } else { 196 | if (ultraPunishActive) { 197 | sender.addChatMessage(new ChatComponentText( 198 | "UltraPunish task is running, stopping ultraPunish task.")); 199 | ultraPunishActive = false; 200 | } 201 | punishActive = true; 202 | sender.addChatMessage(new ChatComponentText("Punish started for player: " + playerToPunish.getName())); 203 | } 204 | } else if (option.equals("stop")) { 205 | if (!punishActive) { 206 | sender.addChatMessage(new ChatComponentText("There's no punish task to stop!")); 207 | } else { 208 | punishActive = false; 209 | sender.addChatMessage(new ChatComponentText("Punish stopped for player: " + playerToPunish.getName())); 210 | playerToPunish = null; 211 | } 212 | } else { 213 | sender.addChatMessage(new ChatComponentText("Usage: " + getCommandUsage(sender))); 214 | } 215 | break; 216 | } 217 | case "ultrapunish": { 218 | if (sender instanceof EntityPlayer) { 219 | playerToPunish = (EntityPlayer) sender; 220 | } else { 221 | sender.addChatMessage(new ChatComponentText("This command can only be used by a player.")); 222 | return; 223 | } 224 | 225 | String option = args[1].toLowerCase(); 226 | 227 | if (option.equals("start")) { 228 | if (ultraPunishActive) { 229 | sender.addChatMessage(new ChatComponentText("UltraPunish already started!")); 230 | } else { 231 | if (punishActive) { 232 | sender.addChatMessage(new ChatComponentText("Punish task is running, stopping punish task.")); 233 | punishActive = false; 234 | } 235 | ultraPunishActive = true; 236 | sender.addChatMessage(new ChatComponentText("UltraPunish started for player: " + playerToPunish.getName())); 237 | } 238 | } else if (option.equals("stop")) { 239 | if (!ultraPunishActive) { 240 | sender.addChatMessage(new ChatComponentText("There's no ultraPunish task to stop!")); 241 | } else { 242 | sender.addChatMessage(new ChatComponentText("UltraPunish stopped for player: " + playerToPunish.getName())); 243 | playerToPunish = null; 244 | ultraPunishActive = false; 245 | } 246 | } 247 | break; 248 | } 249 | case "setpunishtime": 250 | punishTime = Integer.parseInt(args[1]); 251 | sender.addChatMessage(new ChatComponentText("Successfully set punishTime to: " + punishTime)); 252 | break; 253 | case "setpunishrate": 254 | punishRate = Integer.parseInt(args[1]); 255 | sender.addChatMessage(new ChatComponentText("Successfully set punishRate to: " + punishRate)); 256 | break; 257 | case "getpunishsetting": 258 | sender.addChatMessage(new ChatComponentText("Punish time: " + punishTime)); 259 | sender.addChatMessage(new ChatComponentText("Punish rate: " + punishRate)); 260 | break; 261 | default: 262 | sender.addChatMessage(new ChatComponentText("Usage: " + getCommandUsage(sender))); 263 | break; 264 | } 265 | } 266 | 267 | 268 | @Override 269 | public String getCommandName() { 270 | return null; 271 | } 272 | 273 | @Override 274 | public String getCommandUsage(ICommandSender iCommandSender) { 275 | return "/dglab punish/ultraPunish \n" + 276 | "/dglab setPunishTime [seconds]\n" + 277 | "/dglab setPunishRate [value]\n" + 278 | "/dglab getPunishSetting"; 279 | } 280 | 281 | } 282 | -------------------------------------------------------------------------------- /src/main/java/com/yuluo/dglab/CommandDglabStrength.java: -------------------------------------------------------------------------------- 1 | package com.yuluo.dglab; 2 | 3 | import com.google.gson.JsonObject; 4 | import com.google.gson.JsonParser; 5 | import com.neovisionaries.ws.client.WebSocket; 6 | import net.minecraft.command.CommandBase; 7 | import net.minecraft.command.ICommandSender; 8 | import net.minecraft.util.ChatComponentText; 9 | 10 | public class CommandDglabStrength extends CommandBase implements CommandDglabConnect.WebSocketMessageCallback { 11 | public static int maxStrengthA = 100; 12 | public static int maxStrengthB = 100; 13 | public static int currentStrengthA = 20; 14 | public static int currentStrengthB = 20; 15 | 16 | public static int getMaxStrengthA() { 17 | return maxStrengthA; 18 | } 19 | 20 | public static int getMaxStrengthB() { 21 | return maxStrengthB; 22 | } 23 | 24 | public static int getCurrentStrengthA() { 25 | return currentStrengthA; 26 | } 27 | 28 | public static int getCurrentStrengthB() { 29 | return currentStrengthB; 30 | } 31 | 32 | public static int getBaseStrengthA() { 33 | return baseStrengthA; 34 | } 35 | 36 | public static int getBaseStrengthB() { 37 | return baseStrengthB; 38 | } 39 | 40 | public static int baseStrengthA = 20; 41 | public static int baseStrengthB = 20; 42 | public static CommandDglabStrength instance = new CommandDglabStrength(); 43 | 44 | 45 | @Override 46 | public String getCommandName() { 47 | return null; 48 | } 49 | 50 | @Override 51 | public String getCommandUsage(ICommandSender iCommandSender) { 52 | return null; 53 | } 54 | 55 | @Override 56 | public void processCommand(ICommandSender sender, String[] args) { 57 | String subCommand = args[0].toLowerCase(); 58 | WebSocket client = CommandDglabConnect.getClientInstance(); 59 | 60 | if (client == null || !client.isOpen()) { 61 | sender.addChatMessage(new ChatComponentText("WebSocket connection is not established.")); 62 | return; 63 | } 64 | // Set the callback for the WebSocket messages 65 | CommandDglabConnect.setWebSocketMessageCallback(this); 66 | 67 | switch (subCommand) { 68 | case "getstrength": 69 | queryStrength(sender, false); 70 | break; 71 | case "setstrength": 72 | int strengthA = Integer.parseInt(args[1]); 73 | int strengthB = Integer.parseInt(args[2]); 74 | setStrength(sender, strengthA, strengthB); 75 | break; 76 | case "addstrength": 77 | if (args.length < 3) { 78 | sender.addChatMessage(new ChatComponentText("Usage: /dglab addstrength [strength]")); 79 | return; 80 | } 81 | String channel = args[1].toLowerCase(); 82 | int strength = Integer.parseInt(args[2]); 83 | addStrength(sender, channel, strength); 84 | break; 85 | case "setbasestrength": 86 | baseStrengthA = Integer.parseInt(args[1]); 87 | baseStrengthB = Integer.parseInt(args[2]); 88 | sender.addChatMessage(new ChatComponentText("Successfully set baseStrengthA to: " + baseStrengthA)); 89 | sender.addChatMessage(new ChatComponentText("Successfully set baseStrengthB to: " + baseStrengthB)); 90 | break; 91 | case "getbasestrength": 92 | sender.addChatMessage(new ChatComponentText("BaseStrengthA: " + baseStrengthA)); 93 | sender.addChatMessage(new ChatComponentText("BaseStrengthB: " + baseStrengthB)); 94 | break; 95 | case "setmaxstrength": 96 | maxStrengthA = Integer.parseInt(args[1]); 97 | maxStrengthB = Integer.parseInt(args[2]); 98 | sender.addChatMessage(new ChatComponentText("Successfully set maxStrengthA to: " + maxStrengthA)); 99 | sender.addChatMessage(new ChatComponentText("Successfully set maxStrengthB to: " + maxStrengthB)); 100 | break; 101 | case "getmaxstrength": 102 | sender.addChatMessage(new ChatComponentText("MaxStrengthA: " + maxStrengthA)); 103 | sender.addChatMessage(new ChatComponentText("MaxStrengthB: " + maxStrengthB)); 104 | break; 105 | } 106 | } 107 | 108 | @Override 109 | public void onWebSocketMessage(ICommandSender sender, String message) { 110 | JsonParser jsonParser = new JsonParser(); 111 | JsonObject response = jsonParser.parse(message).getAsJsonObject(); 112 | 113 | System.out.println(message); 114 | int responseId = response.get("id").getAsInt(); 115 | 116 | switch (responseId) { 117 | case 100001: { // queryStrength response 118 | // Process the response 119 | JsonObject responseData = response.get("data").getAsJsonObject(); 120 | int totalStrengthA = responseData.get("totalStrengthA").getAsInt(); 121 | totalStrengthA = totalStrengthA == 0 ? 0 : totalStrengthA - 9; 122 | int totalStrengthB = responseData.get("totalStrengthB").getAsInt(); 123 | totalStrengthB = totalStrengthB == 0 ? 0 : totalStrengthB - 9; 124 | 125 | // Send the message to the player 126 | sender.addChatMessage(new ChatComponentText("Strength values:")); 127 | sender.addChatMessage(new ChatComponentText("Total Strength A: " + totalStrengthA)); 128 | sender.addChatMessage(new ChatComponentText("Total Strength B: " + totalStrengthB)); 129 | break; 130 | } 131 | case 100002: {// setStrength response 132 | if (response.get("code").getAsInt() == 0) { 133 | System.out.println("Strength values set successfully."); 134 | //sender.addChatMessage(new ChatComponentText("Strength values set successfully.")); 135 | } else { 136 | System.out.println("Failed to set strength values. "); 137 | sender.addChatMessage(new ChatComponentText("Failed to set strength values. Error: " + response.get("result").getAsString())); 138 | } 139 | break; 140 | } 141 | case 100003: { //addStrength response 142 | if (response.get("code").getAsInt() == 0) { 143 | System.out.println("Strength values added successfully."); 144 | } else { 145 | System.out.println("Failed to add strength values. "); 146 | sender.addChatMessage(new ChatComponentText("Failed to add strength values. Error: " + response.get("result").getAsString())); 147 | } 148 | break; 149 | } 150 | case 100000: { // queryStrength(Hide) response 151 | // Process the response 152 | JsonObject responseData = response.get("data").getAsJsonObject(); 153 | int totalStrengthA = responseData.get("totalStrengthA").getAsInt(); 154 | totalStrengthA = totalStrengthA == 0 ? 0 : totalStrengthA - 9; 155 | int totalStrengthB = responseData.get("totalStrengthB").getAsInt(); 156 | totalStrengthB = totalStrengthB == 0 ? 0 : totalStrengthB - 9; 157 | break; 158 | } 159 | } 160 | } 161 | 162 | public void setStrength(ICommandSender sender, int strengthA, int strengthB) { 163 | if (strengthA > maxStrengthA) { 164 | sender.addChatMessage(new ChatComponentText("Strength A exceeds the maximum limit (" + maxStrengthA + "). Setting to max limit.")); 165 | strengthA = maxStrengthA; 166 | } 167 | if (strengthB > maxStrengthB) { 168 | sender.addChatMessage(new ChatComponentText("Strength B exceeds the maximum limit (" + maxStrengthB + "). Setting to max limit.")); 169 | strengthB = maxStrengthB; 170 | } 171 | 172 | // 获取已建立连接的 WebSocketClient 173 | WebSocket client = CommandDglabConnect.getClientInstance(); 174 | 175 | if (client == null || !client.isOpen()) { 176 | sender.addChatMessage(new ChatComponentText("WebSocket connection is not established.")); 177 | return; 178 | } 179 | currentStrengthA = strengthA; 180 | currentStrengthB = strengthB; 181 | strengthA = strengthA == 0 ? 0 : strengthA + 9; 182 | strengthB = strengthB == 0 ? 0 : strengthB + 9; 183 | 184 | 185 | // 创建 JSON 请求 186 | JsonObject requestData = new JsonObject(); 187 | requestData.addProperty("strengthA", strengthA); 188 | requestData.addProperty("strengthB", strengthB); 189 | 190 | JsonObject request = new JsonObject(); 191 | request.addProperty("id", 100002); 192 | request.addProperty("method", "setStrength"); 193 | request.add("data", requestData); 194 | 195 | // 发送 JSON 请求 196 | client.sendText(request.toString()); 197 | } 198 | 199 | public void addStrength(ICommandSender sender, String channel, int addedStrength) { 200 | queryStrength(sender, true); 201 | boolean channelA; 202 | if (channel.equals("a")) { 203 | channelA = true; 204 | if (currentStrengthA + addedStrength > maxStrengthA) { 205 | addedStrength = maxStrengthA - currentStrengthA; 206 | sender.addChatMessage(new ChatComponentText("Strength A exceeds the maximum limit (" + maxStrengthA + "). Setting to max limit.")); 207 | } 208 | // 更新 currentStrengthA 209 | currentStrengthA = currentStrengthA + addedStrength; 210 | } else if (channel.equals("b")) { 211 | channelA = false; 212 | if (currentStrengthB + addedStrength > maxStrengthB) { 213 | addedStrength = maxStrengthB - currentStrengthB; 214 | sender.addChatMessage(new ChatComponentText("Strength B exceeds the maximum limit (" + maxStrengthB + "). Setting to max limit.")); 215 | } 216 | // 更新 currentStrengthB 217 | currentStrengthB = currentStrengthB + addedStrength; 218 | } else { 219 | sender.addChatMessage(new ChatComponentText("Invalid channel. Please use 'a' or 'b'.")); 220 | return; 221 | } 222 | 223 | // 获取已建立连接的 WebSocketClient 224 | WebSocket client = CommandDglabConnect.getClientInstance(); 225 | 226 | if (client == null || !client.isOpen()) { 227 | sender.addChatMessage(new ChatComponentText("WebSocket connection is not established.")); 228 | return; 229 | } 230 | 231 | // 创建 JSON 请求 232 | JsonObject requestData = new JsonObject(); 233 | requestData.addProperty("channel", channelA); 234 | requestData.addProperty("strength", addedStrength); 235 | 236 | JsonObject request = new JsonObject(); 237 | request.addProperty("id", 100003); // 使用唯一ID 238 | request.addProperty("method", "addStrength"); 239 | request.add("data", requestData); 240 | 241 | // 发送 JSON 请求 242 | client.sendText(request.toString()); 243 | System.out.println(request); 244 | } 245 | 246 | public static void queryStrength(ICommandSender sender, boolean silent) { 247 | // 获取已建立连接的 WebSocketClient 248 | WebSocket client = CommandDglabConnect.getClientInstance(); 249 | 250 | if (client == null || !client.isOpen()) { 251 | if (!silent) { 252 | sender.addChatMessage(new ChatComponentText("WebSocket connection is not established.")); 253 | } 254 | return; 255 | } 256 | 257 | // 创建 JSON 请求 258 | JsonObject request = new JsonObject(); 259 | if (!silent) { 260 | request.addProperty("id", 100001); 261 | } else { 262 | request.addProperty("id", 100000); 263 | } 264 | 265 | request.addProperty("method", "queryStrength"); 266 | 267 | // 发送 JSON 请求 268 | client.sendText(request.toString()); 269 | } 270 | } 271 | -------------------------------------------------------------------------------- /src/main/java/com/yuluo/dglab/DGLabController.java: -------------------------------------------------------------------------------- 1 | package com.yuluo.dglab; 2 | 3 | import net.minecraftforge.common.MinecraftForge; 4 | import net.minecraftforge.fml.common.Mod; 5 | import net.minecraftforge.fml.common.Mod.EventHandler; 6 | import net.minecraftforge.fml.common.event.FMLInitializationEvent; 7 | import net.minecraftforge.fml.common.event.FMLServerStartingEvent; 8 | 9 | @Mod(modid = "dglab-controller", name = "DGLab Controller", version = "1.0.0", acceptedMinecraftVersions = "[1.8.9]") 10 | public class DGLabController { 11 | @EventHandler 12 | public void init(FMLInitializationEvent event) { 13 | MinecraftForge.EVENT_BUS.register(new CommandDglabPunish()); 14 | System.out.println("punish registered!"); 15 | } 16 | 17 | @EventHandler 18 | public void serverStarting(FMLServerStartingEvent event) { 19 | try { 20 | event.registerServerCommand(new CommandDglab()); 21 | } catch (Exception e) { 22 | e.printStackTrace(); 23 | } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/main/resources/mcmod.info: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "modid": "dglab", 4 | "name": "DG-Lab Controller", 5 | "description": "A mod used to control a DG-Lab device in minecraft.", 6 | "version": "${version}", 7 | "mcversion": "${mcversion}", 8 | "url": "https://twitter.com/yuluoqwq", 9 | "updateUrl": "", 10 | "authorList": ["yuluo"], 11 | "credits": "", 12 | "logoFile": "", 13 | "screenshots": [], 14 | "dependencies": [] 15 | } 16 | ] 17 | --------------------------------------------------------------------------------