├── .classpath ├── .gitignore ├── .idea ├── codeStyles │ ├── Project.xml │ └── codeStyleConfig.xml ├── compiler.xml ├── encodings.xml ├── jarRepositories.xml ├── misc.xml ├── vcs.xml └── workspace.xml ├── .project ├── .settings ├── org.eclipse.jdt.core.prefs ├── org.eclipse.ltk.core.refactoring.prefs └── org.eclipse.m2e.core.prefs ├── LICENSE.txt ├── License.txt ├── README.md ├── bin └── me │ └── zombie_striker │ └── pixelprinter │ ├── GithubDependDownloader$1$1.class │ ├── GithubDependDownloader$1.class │ ├── GithubDependDownloader.class │ ├── GithubUpdater$1.class │ ├── GithubUpdater.class │ ├── Metrics$1$1.class │ ├── Metrics$1.class │ ├── Metrics$2.class │ ├── Metrics$AdvancedBarChart.class │ ├── Metrics$AdvancedPie.class │ ├── Metrics$CustomChart.class │ ├── Metrics$DrilldownPie.class │ ├── Metrics$MultiLineChart.class │ ├── Metrics$SimpleBarChart.class │ ├── Metrics$SimplePie.class │ ├── Metrics$SingleLineChart.class │ ├── Metrics.class │ ├── PPListener.class │ ├── PixelPrinter$1.class │ ├── PixelPrinter$2.class │ ├── PixelPrinter$3.class │ ├── PixelPrinter$4.class │ ├── PixelPrinter$5.class │ ├── PixelPrinter$6.class │ ├── PixelPrinter$7$1.class │ ├── PixelPrinter$7.class │ ├── PixelPrinter.class │ ├── data │ ├── DataHolder$1.class │ ├── DataHolder.class │ ├── Direction.class │ ├── FileCreatorData.class │ ├── IntHolder.class │ └── MaterialData.class │ └── util │ ├── AsyncImageHolder$1$1$1.class │ ├── AsyncImageHolder$1$1.class │ ├── AsyncImageHolder$1$2.class │ ├── AsyncImageHolder$1.class │ ├── AsyncImageHolder.class │ ├── BlockTypeSnapshot.class │ ├── CustomImageRenderer.class │ ├── FileNameToMaterialUtil.class │ ├── GifHolder$1.class │ ├── GifHolder$2.class │ ├── GifHolder$3.class │ ├── GifHolder$4.class │ ├── GifHolder.class │ ├── Image.class │ ├── MapWallUtil$1.class │ ├── MapWallUtil.class │ ├── MojangAPI.class │ ├── RGBBlockColor$Pixel.class │ ├── RGBBlockColor.class │ ├── RGBBlockValue.class │ ├── RGBChatColor.class │ ├── RGBValue.class │ ├── ReflectionUtil.class │ ├── SimilarMapUtil.class │ ├── SkinCreator.class │ ├── UndoUtil.class │ └── Update13Handler.class ├── libs └── PluginConstructorAPI.jar ├── pom.xml ├── resources ├── changelog.txt └── plugin.yml └── src └── me └── zombie_striker ├── easygui ├── ClickData.java ├── EasyGUI.java ├── EasyGUICallable.java └── examples │ └── HelloWorldCallable.java └── pixelprinter ├── GithubDependDownloader.java ├── GithubUpdater.java ├── Metrics.java ├── PPListener.java ├── PixelPrinter.java ├── data ├── BoolHolder.java ├── CustomMapView.java ├── DataHolder.java ├── Direction.java ├── FileCreatorData.java ├── ImageRelativeBlockDirection.java ├── IntHolder.java └── MaterialData.java └── util ├── AsyncImageHolder.java ├── BlockTypeSnapshot.java ├── CustomImageRenderer.java ├── FileNameToMaterialUtil.java ├── GifHolder.java ├── Image.java ├── MapWallUtil.java ├── MojangAPI.java ├── RGBBlockColor.java ├── RGBChatColor.java ├── ReflectionUtil.java ├── SimilarMapUtil.java ├── SkinCreator.java ├── UndoUtil.java └── Update13Handler.java /.classpath: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | /target/ 2 | -------------------------------------------------------------------------------- /.idea/codeStyles/Project.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /.idea/codeStyles/codeStyleConfig.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | -------------------------------------------------------------------------------- /.idea/compiler.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /.idea/encodings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /.idea/jarRepositories.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 9 | 10 | 14 | 15 | 19 | 20 | 24 | 25 | -------------------------------------------------------------------------------- /.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /.idea/vcs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /.idea/workspace.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 23 | 24 | 26 | 27 | 29 | 30 | 35 | 36 | 37 | 39 | 40 | 47 | 48 | 49 | 51 | 52 | 53 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 1558936756013 112 | 116 | 117 | 118 | 119 | 128 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | 170 | 171 | 172 | 173 | 174 | 175 | 176 | 181 | 182 | 183 | 184 | 185 | 186 | 187 | 192 | 193 | 194 | 195 | 196 | 197 | PixelPrinter 198 | 199 | 205 | 206 | 207 | 208 | 209 | 210 | 10 211 | 212 | 217 | 218 | 219 | 220 | 221 | 222 | 223 | 228 | 229 | 230 | 231 | 232 | 233 | -------------------------------------------------------------------------------- /.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | PixelPrinter 4 | 5 | 6 | 7 | 8 | 9 | org.eclipse.jdt.core.javabuilder 10 | 11 | 12 | 13 | 14 | org.eclipse.m2e.core.maven2Builder 15 | 16 | 17 | 18 | 19 | 20 | org.eclipse.m2e.core.maven2Nature 21 | org.eclipse.jdt.core.javanature 22 | 23 | 24 | -------------------------------------------------------------------------------- /.settings/org.eclipse.jdt.core.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled 3 | org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7 4 | org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve 5 | org.eclipse.jdt.core.compiler.compliance=1.7 6 | org.eclipse.jdt.core.compiler.debug.lineNumber=generate 7 | org.eclipse.jdt.core.compiler.debug.localVariable=generate 8 | org.eclipse.jdt.core.compiler.debug.sourceFile=generate 9 | org.eclipse.jdt.core.compiler.problem.assertIdentifier=error 10 | org.eclipse.jdt.core.compiler.problem.enumIdentifier=error 11 | org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning 12 | org.eclipse.jdt.core.compiler.source=1.7 13 | -------------------------------------------------------------------------------- /.settings/org.eclipse.ltk.core.refactoring.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | org.eclipse.ltk.core.refactoring.enable.project.refactoring.history=false 3 | -------------------------------------------------------------------------------- /.settings/org.eclipse.m2e.core.prefs: -------------------------------------------------------------------------------- 1 | activeProfiles= 2 | eclipse.preferences.version=1 3 | resolveWorkspaceProjects=true 4 | version=1 5 | -------------------------------------------------------------------------------- /LICENSE.txt: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 2, June 1991 3 | 4 | Copyright (C) 1989, 1991 Free Software Foundation, Inc., 5 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 6 | Everyone is permitted to copy and distribute verbatim copies 7 | of this license document, but changing it is not allowed. 8 | 9 | Preamble 10 | 11 | The licenses for most software are designed to take away your 12 | freedom to share and change it. By contrast, the GNU General Public 13 | License is intended to guarantee your freedom to share and change free 14 | software--to make sure the software is free for all its users. This 15 | General Public License applies to most of the Free Software 16 | Foundation's software and to any other program whose authors commit to 17 | using it. (Some other Free Software Foundation software is covered by 18 | the GNU Lesser General Public License instead.) You can apply it to 19 | your programs, too. 20 | 21 | When we speak of free software, we are referring to freedom, not 22 | price. Our General Public Licenses are designed to make sure that you 23 | have the freedom to distribute copies of free software (and charge for 24 | this service if you wish), that you receive source code or can get it 25 | if you want it, that you can change the software or use pieces of it 26 | in new free programs; and that you know you can do these things. 27 | 28 | To protect your rights, we need to make restrictions that forbid 29 | anyone to deny you these rights or to ask you to surrender the rights. 30 | These restrictions translate to certain responsibilities for you if you 31 | distribute copies of the software, or if you modify it. 32 | 33 | For example, if you distribute copies of such a program, whether 34 | gratis or for a fee, you must give the recipients all the rights that 35 | you have. You must make sure that they, too, receive or can get the 36 | source code. And you must show them these terms so they know their 37 | rights. 38 | 39 | We protect your rights with two steps: (1) copyright the software, and 40 | (2) offer you this license which gives you legal permission to copy, 41 | distribute and/or modify the software. 42 | 43 | Also, for each author's protection and ours, we want to make certain 44 | that everyone understands that there is no warranty for this free 45 | software. If the software is modified by someone else and passed on, we 46 | want its recipients to know that what they have is not the original, so 47 | that any problems introduced by others will not reflect on the original 48 | authors' reputations. 49 | 50 | Finally, any free program is threatened constantly by software 51 | patents. We wish to avoid the danger that redistributors of a free 52 | program will individually obtain patent licenses, in effect making the 53 | program proprietary. To prevent this, we have made it clear that any 54 | patent must be licensed for everyone's free use or not licensed at all. 55 | 56 | The precise terms and conditions for copying, distribution and 57 | modification follow. 58 | 59 | GNU GENERAL PUBLIC LICENSE 60 | TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 61 | 62 | 0. This License applies to any program or other work which contains 63 | a notice placed by the copyright holder saying it may be distributed 64 | under the terms of this General Public License. The "Program", below, 65 | refers to any such program or work, and a "work based on the Program" 66 | means either the Program or any derivative work under copyright law: 67 | that is to say, a work containing the Program or a portion of it, 68 | either verbatim or with modifications and/or translated into another 69 | language. (Hereinafter, translation is included without limitation in 70 | the term "modification".) Each licensee is addressed as "you". 71 | 72 | Activities other than copying, distribution and modification are not 73 | covered by this License; they are outside its scope. The act of 74 | running the Program is not restricted, and the output from the Program 75 | is covered only if its contents constitute a work based on the 76 | Program (independent of having been made by running the Program). 77 | Whether that is true depends on what the Program does. 78 | 79 | 1. You may copy and distribute verbatim copies of the Program's 80 | source code as you receive it, in any medium, provided that you 81 | conspicuously and appropriately publish on each copy an appropriate 82 | copyright notice and disclaimer of warranty; keep intact all the 83 | notices that refer to this License and to the absence of any warranty; 84 | and give any other recipients of the Program a copy of this License 85 | along with the Program. 86 | 87 | You may charge a fee for the physical act of transferring a copy, and 88 | you may at your option offer warranty protection in exchange for a fee. 89 | 90 | 2. You may modify your copy or copies of the Program or any portion 91 | of it, thus forming a work based on the Program, and copy and 92 | distribute such modifications or work under the terms of Section 1 93 | above, provided that you also meet all of these conditions: 94 | 95 | a) You must cause the modified files to carry prominent notices 96 | stating that you changed the files and the date of any change. 97 | 98 | b) You must cause any work that you distribute or publish, that in 99 | whole or in part contains or is derived from the Program or any 100 | part thereof, to be licensed as a whole at no charge to all third 101 | parties under the terms of this License. 102 | 103 | c) If the modified program normally reads commands interactively 104 | when run, you must cause it, when started running for such 105 | interactive use in the most ordinary way, to print or display an 106 | announcement including an appropriate copyright notice and a 107 | notice that there is no warranty (or else, saying that you provide 108 | a warranty) and that users may redistribute the program under 109 | these conditions, and telling the user how to view a copy of this 110 | License. (Exception: if the Program itself is interactive but 111 | does not normally print such an announcement, your work based on 112 | the Program is not required to print an announcement.) 113 | 114 | These requirements apply to the modified work as a whole. If 115 | identifiable sections of that work are not derived from the Program, 116 | and can be reasonably considered independent and separate works in 117 | themselves, then this License, and its terms, do not apply to those 118 | sections when you distribute them as separate works. But when you 119 | distribute the same sections as part of a whole which is a work based 120 | on the Program, the distribution of the whole must be on the terms of 121 | this License, whose permissions for other licensees extend to the 122 | entire whole, and thus to each and every part regardless of who wrote it. 123 | 124 | Thus, it is not the intent of this section to claim rights or contest 125 | your rights to work written entirely by you; rather, the intent is to 126 | exercise the right to control the distribution of derivative or 127 | collective works based on the Program. 128 | 129 | In addition, mere aggregation of another work not based on the Program 130 | with the Program (or with a work based on the Program) on a volume of 131 | a storage or distribution medium does not bring the other work under 132 | the scope of this License. 133 | 134 | 3. You may copy and distribute the Program (or a work based on it, 135 | under Section 2) in object code or executable form under the terms of 136 | Sections 1 and 2 above provided that you also do one of the following: 137 | 138 | a) Accompany it with the complete corresponding machine-readable 139 | source code, which must be distributed under the terms of Sections 140 | 1 and 2 above on a medium customarily used for software interchange; or, 141 | 142 | b) Accompany it with a written offer, valid for at least three 143 | years, to give any third party, for a charge no more than your 144 | cost of physically performing source distribution, a complete 145 | machine-readable copy of the corresponding source code, to be 146 | distributed under the terms of Sections 1 and 2 above on a medium 147 | customarily used for software interchange; or, 148 | 149 | c) Accompany it with the information you received as to the offer 150 | to distribute corresponding source code. (This alternative is 151 | allowed only for noncommercial distribution and only if you 152 | received the program in object code or executable form with such 153 | an offer, in accord with Subsection b above.) 154 | 155 | The source code for a work means the preferred form of the work for 156 | making modifications to it. For an executable work, complete source 157 | code means all the source code for all modules it contains, plus any 158 | associated interface definition files, plus the scripts used to 159 | control compilation and installation of the executable. However, as a 160 | special exception, the source code distributed need not include 161 | anything that is normally distributed (in either source or binary 162 | form) with the major components (compiler, kernel, and so on) of the 163 | operating system on which the executable runs, unless that component 164 | itself accompanies the executable. 165 | 166 | If distribution of executable or object code is made by offering 167 | access to copy from a designated place, then offering equivalent 168 | access to copy the source code from the same place counts as 169 | distribution of the source code, even though third parties are not 170 | compelled to copy the source along with the object code. 171 | 172 | 4. You may not copy, modify, sublicense, or distribute the Program 173 | except as expressly provided under this License. Any attempt 174 | otherwise to copy, modify, sublicense or distribute the Program is 175 | void, and will automatically terminate your rights under this License. 176 | However, parties who have received copies, or rights, from you under 177 | this License will not have their licenses terminated so long as such 178 | parties remain in full compliance. 179 | 180 | 5. You are not required to accept this License, since you have not 181 | signed it. However, nothing else grants you permission to modify or 182 | distribute the Program or its derivative works. These actions are 183 | prohibited by law if you do not accept this License. Therefore, by 184 | modifying or distributing the Program (or any work based on the 185 | Program), you indicate your acceptance of this License to do so, and 186 | all its terms and conditions for copying, distributing or modifying 187 | the Program or works based on it. 188 | 189 | 6. Each time you redistribute the Program (or any work based on the 190 | Program), the recipient automatically receives a license from the 191 | original licensor to copy, distribute or modify the Program subject to 192 | these terms and conditions. You may not impose any further 193 | restrictions on the recipients' exercise of the rights granted herein. 194 | You are not responsible for enforcing compliance by third parties to 195 | this License. 196 | 197 | 7. If, as a consequence of a court judgment or allegation of patent 198 | infringement or for any other reason (not limited to patent issues), 199 | conditions are imposed on you (whether by court order, agreement or 200 | otherwise) that contradict the conditions of this License, they do not 201 | excuse you from the conditions of this License. If you cannot 202 | distribute so as to satisfy simultaneously your obligations under this 203 | License and any other pertinent obligations, then as a consequence you 204 | may not distribute the Program at all. For example, if a patent 205 | license would not permit royalty-free redistribution of the Program by 206 | all those who receive copies directly or indirectly through you, then 207 | the only way you could satisfy both it and this License would be to 208 | refrain entirely from distribution of the Program. 209 | 210 | If any portion of this section is held invalid or unenforceable under 211 | any particular circumstance, the balance of the section is intended to 212 | apply and the section as a whole is intended to apply in other 213 | circumstances. 214 | 215 | It is not the purpose of this section to induce you to infringe any 216 | patents or other property right claims or to contest validity of any 217 | such claims; this section has the sole purpose of protecting the 218 | integrity of the free software distribution system, which is 219 | implemented by public license practices. Many people have made 220 | generous contributions to the wide range of software distributed 221 | through that system in reliance on consistent application of that 222 | system; it is up to the author/donor to decide if he or she is willing 223 | to distribute software through any other system and a licensee cannot 224 | impose that choice. 225 | 226 | This section is intended to make thoroughly clear what is believed to 227 | be a consequence of the rest of this License. 228 | 229 | 8. If the distribution and/or use of the Program is restricted in 230 | certain countries either by patents or by copyrighted interfaces, the 231 | original copyright holder who places the Program under this License 232 | may add an explicit geographical distribution limitation excluding 233 | those countries, so that distribution is permitted only in or among 234 | countries not thus excluded. In such case, this License incorporates 235 | the limitation as if written in the body of this License. 236 | 237 | 9. The Free Software Foundation may publish revised and/or new versions 238 | of the General Public License from time to time. Such new versions will 239 | be similar in spirit to the present version, but may differ in detail to 240 | address new problems or concerns. 241 | 242 | Each version is given a distinguishing version number. If the Program 243 | specifies a version number of this License which applies to it and "any 244 | later version", you have the option of following the terms and conditions 245 | either of that version or of any later version published by the Free 246 | Software Foundation. If the Program does not specify a version number of 247 | this License, you may choose any version ever published by the Free Software 248 | Foundation. 249 | 250 | 10. If you wish to incorporate parts of the Program into other free 251 | programs whose distribution conditions are different, write to the author 252 | to ask for permission. For software which is copyrighted by the Free 253 | Software Foundation, write to the Free Software Foundation; we sometimes 254 | make exceptions for this. Our decision will be guided by the two goals 255 | of preserving the free status of all derivatives of our free software and 256 | of promoting the sharing and reuse of software generally. 257 | 258 | NO WARRANTY 259 | 260 | 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY 261 | FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN 262 | OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES 263 | PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED 264 | OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 265 | MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS 266 | TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE 267 | PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, 268 | REPAIR OR CORRECTION. 269 | 270 | 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 271 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR 272 | REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, 273 | INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING 274 | OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED 275 | TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY 276 | YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER 277 | PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE 278 | POSSIBILITY OF SUCH DAMAGES. 279 | 280 | END OF TERMS AND CONDITIONS 281 | 282 | How to Apply These Terms to Your New Programs 283 | 284 | If you develop a new program, and you want it to be of the greatest 285 | possible use to the public, the best way to achieve this is to make it 286 | free software which everyone can redistribute and change under these terms. 287 | 288 | To do so, attach the following notices to the program. It is safest 289 | to attach them to the start of each source file to most effectively 290 | convey the exclusion of warranty; and each file should have at least 291 | the "copyright" line and a pointer to where the full notice is found. 292 | 293 | 294 | Copyright (C) 295 | 296 | This program is free software; you can redistribute it and/or modify 297 | it under the terms of the GNU General Public License as published by 298 | the Free Software Foundation; either version 2 of the License, or 299 | (at your option) any later version. 300 | 301 | This program is distributed in the hope that it will be useful, 302 | but WITHOUT ANY WARRANTY; without even the implied warranty of 303 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 304 | GNU General Public License for more details. 305 | 306 | You should have received a copy of the GNU General Public License along 307 | with this program; if not, write to the Free Software Foundation, Inc., 308 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 309 | 310 | Also add information on how to contact you by electronic and paper mail. 311 | 312 | If the program is interactive, make it output a short notice like this 313 | when it starts in an interactive mode: 314 | 315 | Gnomovision version 69, Copyright (C) year name of author 316 | Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 317 | This is free software, and you are welcome to redistribute it 318 | under certain conditions; type `show c' for details. 319 | 320 | The hypothetical commands `show w' and `show c' should show the appropriate 321 | parts of the General Public License. Of course, the commands you use may 322 | be called something other than `show w' and `show c'; they could even be 323 | mouse-clicks or menu items--whatever suits your program. 324 | 325 | You should also get your employer (if you work as a programmer) or your 326 | school, if any, to sign a "copyright disclaimer" for the program, if 327 | necessary. Here is a sample; alter the names: 328 | 329 | Yoyodyne, Inc., hereby disclaims all copyright interest in the program 330 | `Gnomovision' (which makes passes at compilers) written by James Hacker. 331 | 332 | , 1 April 1989 333 | Ty Coon, President of Vice 334 | 335 | This General Public License does not permit incorporating your program into 336 | proprietary programs. If your program is a subroutine library, you may 337 | consider it more useful to permit linking proprietary applications with the 338 | library. If this is what you want to do, use the GNU Lesser General 339 | Public License instead of this License. -------------------------------------------------------------------------------- /License.txt: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 2, June 1991 3 | 4 | Copyright (C) 1989, 1991 Free Software Foundation, Inc., 5 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 6 | Everyone is permitted to copy and distribute verbatim copies 7 | of this license document, but changing it is not allowed. 8 | 9 | Preamble 10 | 11 | The licenses for most software are designed to take away your 12 | freedom to share and change it. By contrast, the GNU General Public 13 | License is intended to guarantee your freedom to share and change free 14 | software--to make sure the software is free for all its users. This 15 | General Public License applies to most of the Free Software 16 | Foundation's software and to any other program whose authors commit to 17 | using it. (Some other Free Software Foundation software is covered by 18 | the GNU Lesser General Public License instead.) You can apply it to 19 | your programs, too. 20 | 21 | When we speak of free software, we are referring to freedom, not 22 | price. Our General Public Licenses are designed to make sure that you 23 | have the freedom to distribute copies of free software (and charge for 24 | this service if you wish), that you receive source code or can get it 25 | if you want it, that you can change the software or use pieces of it 26 | in new free programs; and that you know you can do these things. 27 | 28 | To protect your rights, we need to make restrictions that forbid 29 | anyone to deny you these rights or to ask you to surrender the rights. 30 | These restrictions translate to certain responsibilities for you if you 31 | distribute copies of the software, or if you modify it. 32 | 33 | For example, if you distribute copies of such a program, whether 34 | gratis or for a fee, you must give the recipients all the rights that 35 | you have. You must make sure that they, too, receive or can get the 36 | source code. And you must show them these terms so they know their 37 | rights. 38 | 39 | We protect your rights with two steps: (1) copyright the software, and 40 | (2) offer you this license which gives you legal permission to copy, 41 | distribute and/or modify the software. 42 | 43 | Also, for each author's protection and ours, we want to make certain 44 | that everyone understands that there is no warranty for this free 45 | software. If the software is modified by someone else and passed on, we 46 | want its recipients to know that what they have is not the original, so 47 | that any problems introduced by others will not reflect on the original 48 | authors' reputations. 49 | 50 | Finally, any free program is threatened constantly by software 51 | patents. We wish to avoid the danger that redistributors of a free 52 | program will individually obtain patent licenses, in effect making the 53 | program proprietary. To prevent this, we have made it clear that any 54 | patent must be licensed for everyone's free use or not licensed at all. 55 | 56 | The precise terms and conditions for copying, distribution and 57 | modification follow. 58 | 59 | GNU GENERAL PUBLIC LICENSE 60 | TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 61 | 62 | 0. This License applies to any program or other work which contains 63 | a notice placed by the copyright holder saying it may be distributed 64 | under the terms of this General Public License. The "Program", below, 65 | refers to any such program or work, and a "work based on the Program" 66 | means either the Program or any derivative work under copyright law: 67 | that is to say, a work containing the Program or a portion of it, 68 | either verbatim or with modifications and/or translated into another 69 | language. (Hereinafter, translation is included without limitation in 70 | the term "modification".) Each licensee is addressed as "you". 71 | 72 | Activities other than copying, distribution and modification are not 73 | covered by this License; they are outside its scope. The act of 74 | running the Program is not restricted, and the output from the Program 75 | is covered only if its contents constitute a work based on the 76 | Program (independent of having been made by running the Program). 77 | Whether that is true depends on what the Program does. 78 | 79 | 1. You may copy and distribute verbatim copies of the Program's 80 | source code as you receive it, in any medium, provided that you 81 | conspicuously and appropriately publish on each copy an appropriate 82 | copyright notice and disclaimer of warranty; keep intact all the 83 | notices that refer to this License and to the absence of any warranty; 84 | and give any other recipients of the Program a copy of this License 85 | along with the Program. 86 | 87 | You may charge a fee for the physical act of transferring a copy, and 88 | you may at your option offer warranty protection in exchange for a fee. 89 | 90 | 2. You may modify your copy or copies of the Program or any portion 91 | of it, thus forming a work based on the Program, and copy and 92 | distribute such modifications or work under the terms of Section 1 93 | above, provided that you also meet all of these conditions: 94 | 95 | a) You must cause the modified files to carry prominent notices 96 | stating that you changed the files and the date of any change. 97 | 98 | b) You must cause any work that you distribute or publish, that in 99 | whole or in part contains or is derived from the Program or any 100 | part thereof, to be licensed as a whole at no charge to all third 101 | parties under the terms of this License. 102 | 103 | c) If the modified program normally reads commands interactively 104 | when run, you must cause it, when started running for such 105 | interactive use in the most ordinary way, to print or display an 106 | announcement including an appropriate copyright notice and a 107 | notice that there is no warranty (or else, saying that you provide 108 | a warranty) and that users may redistribute the program under 109 | these conditions, and telling the user how to view a copy of this 110 | License. (Exception: if the Program itself is interactive but 111 | does not normally print such an announcement, your work based on 112 | the Program is not required to print an announcement.) 113 | 114 | These requirements apply to the modified work as a whole. If 115 | identifiable sections of that work are not derived from the Program, 116 | and can be reasonably considered independent and separate works in 117 | themselves, then this License, and its terms, do not apply to those 118 | sections when you distribute them as separate works. But when you 119 | distribute the same sections as part of a whole which is a work based 120 | on the Program, the distribution of the whole must be on the terms of 121 | this License, whose permissions for other licensees extend to the 122 | entire whole, and thus to each and every part regardless of who wrote it. 123 | 124 | Thus, it is not the intent of this section to claim rights or contest 125 | your rights to work written entirely by you; rather, the intent is to 126 | exercise the right to control the distribution of derivative or 127 | collective works based on the Program. 128 | 129 | In addition, mere aggregation of another work not based on the Program 130 | with the Program (or with a work based on the Program) on a volume of 131 | a storage or distribution medium does not bring the other work under 132 | the scope of this License. 133 | 134 | 3. You may copy and distribute the Program (or a work based on it, 135 | under Section 2) in object code or executable form under the terms of 136 | Sections 1 and 2 above provided that you also do one of the following: 137 | 138 | a) Accompany it with the complete corresponding machine-readable 139 | source code, which must be distributed under the terms of Sections 140 | 1 and 2 above on a medium customarily used for software interchange; or, 141 | 142 | b) Accompany it with a written offer, valid for at least three 143 | years, to give any third party, for a charge no more than your 144 | cost of physically performing source distribution, a complete 145 | machine-readable copy of the corresponding source code, to be 146 | distributed under the terms of Sections 1 and 2 above on a medium 147 | customarily used for software interchange; or, 148 | 149 | c) Accompany it with the information you received as to the offer 150 | to distribute corresponding source code. (This alternative is 151 | allowed only for noncommercial distribution and only if you 152 | received the program in object code or executable form with such 153 | an offer, in accord with Subsection b above.) 154 | 155 | The source code for a work means the preferred form of the work for 156 | making modifications to it. For an executable work, complete source 157 | code means all the source code for all modules it contains, plus any 158 | associated interface definition files, plus the scripts used to 159 | control compilation and installation of the executable. However, as a 160 | special exception, the source code distributed need not include 161 | anything that is normally distributed (in either source or binary 162 | form) with the major components (compiler, kernel, and so on) of the 163 | operating system on which the executable runs, unless that component 164 | itself accompanies the executable. 165 | 166 | If distribution of executable or object code is made by offering 167 | access to copy from a designated place, then offering equivalent 168 | access to copy the source code from the same place counts as 169 | distribution of the source code, even though third parties are not 170 | compelled to copy the source along with the object code. 171 | 172 | 4. You may not copy, modify, sublicense, or distribute the Program 173 | except as expressly provided under this License. Any attempt 174 | otherwise to copy, modify, sublicense or distribute the Program is 175 | void, and will automatically terminate your rights under this License. 176 | However, parties who have received copies, or rights, from you under 177 | this License will not have their licenses terminated so long as such 178 | parties remain in full compliance. 179 | 180 | 5. You are not required to accept this License, since you have not 181 | signed it. However, nothing else grants you permission to modify or 182 | distribute the Program or its derivative works. These actions are 183 | prohibited by law if you do not accept this License. Therefore, by 184 | modifying or distributing the Program (or any work based on the 185 | Program), you indicate your acceptance of this License to do so, and 186 | all its terms and conditions for copying, distributing or modifying 187 | the Program or works based on it. 188 | 189 | 6. Each time you redistribute the Program (or any work based on the 190 | Program), the recipient automatically receives a license from the 191 | original licensor to copy, distribute or modify the Program subject to 192 | these terms and conditions. You may not impose any further 193 | restrictions on the recipients' exercise of the rights granted herein. 194 | You are not responsible for enforcing compliance by third parties to 195 | this License. 196 | 197 | 7. If, as a consequence of a court judgment or allegation of patent 198 | infringement or for any other reason (not limited to patent issues), 199 | conditions are imposed on you (whether by court order, agreement or 200 | otherwise) that contradict the conditions of this License, they do not 201 | excuse you from the conditions of this License. If you cannot 202 | distribute so as to satisfy simultaneously your obligations under this 203 | License and any other pertinent obligations, then as a consequence you 204 | may not distribute the Program at all. For example, if a patent 205 | license would not permit royalty-free redistribution of the Program by 206 | all those who receive copies directly or indirectly through you, then 207 | the only way you could satisfy both it and this License would be to 208 | refrain entirely from distribution of the Program. 209 | 210 | If any portion of this section is held invalid or unenforceable under 211 | any particular circumstance, the balance of the section is intended to 212 | apply and the section as a whole is intended to apply in other 213 | circumstances. 214 | 215 | It is not the purpose of this section to induce you to infringe any 216 | patents or other property right claims or to contest validity of any 217 | such claims; this section has the sole purpose of protecting the 218 | integrity of the free software distribution system, which is 219 | implemented by public license practices. Many people have made 220 | generous contributions to the wide range of software distributed 221 | through that system in reliance on consistent application of that 222 | system; it is up to the author/donor to decide if he or she is willing 223 | to distribute software through any other system and a licensee cannot 224 | impose that choice. 225 | 226 | This section is intended to make thoroughly clear what is believed to 227 | be a consequence of the rest of this License. 228 | 229 | 8. If the distribution and/or use of the Program is restricted in 230 | certain countries either by patents or by copyrighted interfaces, the 231 | original copyright holder who places the Program under this License 232 | may add an explicit geographical distribution limitation excluding 233 | those countries, so that distribution is permitted only in or among 234 | countries not thus excluded. In such case, this License incorporates 235 | the limitation as if written in the body of this License. 236 | 237 | 9. The Free Software Foundation may publish revised and/or new versions 238 | of the General Public License from time to time. Such new versions will 239 | be similar in spirit to the present version, but may differ in detail to 240 | address new problems or concerns. 241 | 242 | Each version is given a distinguishing version number. If the Program 243 | specifies a version number of this License which applies to it and "any 244 | later version", you have the option of following the terms and conditions 245 | either of that version or of any later version published by the Free 246 | Software Foundation. If the Program does not specify a version number of 247 | this License, you may choose any version ever published by the Free Software 248 | Foundation. 249 | 250 | 10. If you wish to incorporate parts of the Program into other free 251 | programs whose distribution conditions are different, write to the author 252 | to ask for permission. For software which is copyrighted by the Free 253 | Software Foundation, write to the Free Software Foundation; we sometimes 254 | make exceptions for this. Our decision will be guided by the two goals 255 | of preserving the free status of all derivatives of our free software and 256 | of promoting the sharing and reuse of software generally. 257 | 258 | NO WARRANTY 259 | 260 | 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY 261 | FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN 262 | OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES 263 | PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED 264 | OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 265 | MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS 266 | TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE 267 | PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, 268 | REPAIR OR CORRECTION. 269 | 270 | 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 271 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR 272 | REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, 273 | INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING 274 | OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED 275 | TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY 276 | YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER 277 | PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE 278 | POSSIBILITY OF SUCH DAMAGES. 279 | 280 | END OF TERMS AND CONDITIONS 281 | 282 | How to Apply These Terms to Your New Programs 283 | 284 | If you develop a new program, and you want it to be of the greatest 285 | possible use to the public, the best way to achieve this is to make it 286 | free software which everyone can redistribute and change under these terms. 287 | 288 | To do so, attach the following notices to the program. It is safest 289 | to attach them to the start of each source file to most effectively 290 | convey the exclusion of warranty; and each file should have at least 291 | the "copyright" line and a pointer to where the full notice is found. 292 | 293 | 294 | Copyright (C) 295 | 296 | This program is free software; you can redistribute it and/or modify 297 | it under the terms of the GNU General Public License as published by 298 | the Free Software Foundation; either version 2 of the License, or 299 | (at your option) any later version. 300 | 301 | This program is distributed in the hope that it will be useful, 302 | but WITHOUT ANY WARRANTY; without even the implied warranty of 303 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 304 | GNU General Public License for more details. 305 | 306 | You should have received a copy of the GNU General Public License along 307 | with this program; if not, write to the Free Software Foundation, Inc., 308 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 309 | 310 | Also add information on how to contact you by electronic and paper mail. 311 | 312 | If the program is interactive, make it output a short notice like this 313 | when it starts in an interactive mode: 314 | 315 | Gnomovision version 69, Copyright (C) year name of author 316 | Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 317 | This is free software, and you are welcome to redistribute it 318 | under certain conditions; type `show c' for details. 319 | 320 | The hypothetical commands `show w' and `show c' should show the appropriate 321 | parts of the General Public License. Of course, the commands you use may 322 | be called something other than `show w' and `show c'; they could even be 323 | mouse-clicks or menu items--whatever suits your program. 324 | 325 | You should also get your employer (if you work as a programmer) or your 326 | school, if any, to sign a "copyright disclaimer" for the program, if 327 | necessary. Here is a sample; alter the names: 328 | 329 | Yoyodyne, Inc., hereby disclaims all copyright interest in the program 330 | `Gnomovision' (which makes passes at compilers) written by James Hacker. 331 | 332 | , 1 April 1989 333 | Ty Coon, President of Vice 334 | 335 | This General Public License does not permit incorporating your program into 336 | proprietary programs. If your program is a subroutine library, you may 337 | consider it more useful to permit linking proprietary applications with the 338 | library. If this is what you want to do, use the GNU Lesser General 339 | Public License instead of this License. -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | PixelPrinter is a plugin that was created to test out the Library found at the following link below. PixelPrinter allows server administrators to create images using blocks on their server (I.E create Pixel art). Using this plugin, you can download,create,resize, and even rotate images. PixelPrinter also features the ability to play .gif files. 2 | 3 | 4 | If you wish, you can check out the resource used in this plugin to color code each block with the following link: 5 | https://bukkit.org/threads/raw-color-values-to-material-types.413391 -------------------------------------------------------------------------------- /bin/me/zombie_striker/pixelprinter/GithubDependDownloader$1$1.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZombieStriker/PixelPrinter/56c9496b3081125a9a62e01a1f7f6f2f7d8b431f/bin/me/zombie_striker/pixelprinter/GithubDependDownloader$1$1.class -------------------------------------------------------------------------------- /bin/me/zombie_striker/pixelprinter/GithubDependDownloader$1.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZombieStriker/PixelPrinter/56c9496b3081125a9a62e01a1f7f6f2f7d8b431f/bin/me/zombie_striker/pixelprinter/GithubDependDownloader$1.class -------------------------------------------------------------------------------- /bin/me/zombie_striker/pixelprinter/GithubDependDownloader.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZombieStriker/PixelPrinter/56c9496b3081125a9a62e01a1f7f6f2f7d8b431f/bin/me/zombie_striker/pixelprinter/GithubDependDownloader.class -------------------------------------------------------------------------------- /bin/me/zombie_striker/pixelprinter/GithubUpdater$1.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZombieStriker/PixelPrinter/56c9496b3081125a9a62e01a1f7f6f2f7d8b431f/bin/me/zombie_striker/pixelprinter/GithubUpdater$1.class -------------------------------------------------------------------------------- /bin/me/zombie_striker/pixelprinter/GithubUpdater.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZombieStriker/PixelPrinter/56c9496b3081125a9a62e01a1f7f6f2f7d8b431f/bin/me/zombie_striker/pixelprinter/GithubUpdater.class -------------------------------------------------------------------------------- /bin/me/zombie_striker/pixelprinter/Metrics$1$1.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZombieStriker/PixelPrinter/56c9496b3081125a9a62e01a1f7f6f2f7d8b431f/bin/me/zombie_striker/pixelprinter/Metrics$1$1.class -------------------------------------------------------------------------------- /bin/me/zombie_striker/pixelprinter/Metrics$1.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZombieStriker/PixelPrinter/56c9496b3081125a9a62e01a1f7f6f2f7d8b431f/bin/me/zombie_striker/pixelprinter/Metrics$1.class -------------------------------------------------------------------------------- /bin/me/zombie_striker/pixelprinter/Metrics$2.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZombieStriker/PixelPrinter/56c9496b3081125a9a62e01a1f7f6f2f7d8b431f/bin/me/zombie_striker/pixelprinter/Metrics$2.class -------------------------------------------------------------------------------- /bin/me/zombie_striker/pixelprinter/Metrics$AdvancedBarChart.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZombieStriker/PixelPrinter/56c9496b3081125a9a62e01a1f7f6f2f7d8b431f/bin/me/zombie_striker/pixelprinter/Metrics$AdvancedBarChart.class -------------------------------------------------------------------------------- /bin/me/zombie_striker/pixelprinter/Metrics$AdvancedPie.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZombieStriker/PixelPrinter/56c9496b3081125a9a62e01a1f7f6f2f7d8b431f/bin/me/zombie_striker/pixelprinter/Metrics$AdvancedPie.class -------------------------------------------------------------------------------- /bin/me/zombie_striker/pixelprinter/Metrics$CustomChart.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZombieStriker/PixelPrinter/56c9496b3081125a9a62e01a1f7f6f2f7d8b431f/bin/me/zombie_striker/pixelprinter/Metrics$CustomChart.class -------------------------------------------------------------------------------- /bin/me/zombie_striker/pixelprinter/Metrics$DrilldownPie.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZombieStriker/PixelPrinter/56c9496b3081125a9a62e01a1f7f6f2f7d8b431f/bin/me/zombie_striker/pixelprinter/Metrics$DrilldownPie.class -------------------------------------------------------------------------------- /bin/me/zombie_striker/pixelprinter/Metrics$MultiLineChart.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZombieStriker/PixelPrinter/56c9496b3081125a9a62e01a1f7f6f2f7d8b431f/bin/me/zombie_striker/pixelprinter/Metrics$MultiLineChart.class -------------------------------------------------------------------------------- /bin/me/zombie_striker/pixelprinter/Metrics$SimpleBarChart.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZombieStriker/PixelPrinter/56c9496b3081125a9a62e01a1f7f6f2f7d8b431f/bin/me/zombie_striker/pixelprinter/Metrics$SimpleBarChart.class -------------------------------------------------------------------------------- /bin/me/zombie_striker/pixelprinter/Metrics$SimplePie.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZombieStriker/PixelPrinter/56c9496b3081125a9a62e01a1f7f6f2f7d8b431f/bin/me/zombie_striker/pixelprinter/Metrics$SimplePie.class -------------------------------------------------------------------------------- /bin/me/zombie_striker/pixelprinter/Metrics$SingleLineChart.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZombieStriker/PixelPrinter/56c9496b3081125a9a62e01a1f7f6f2f7d8b431f/bin/me/zombie_striker/pixelprinter/Metrics$SingleLineChart.class -------------------------------------------------------------------------------- /bin/me/zombie_striker/pixelprinter/Metrics.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZombieStriker/PixelPrinter/56c9496b3081125a9a62e01a1f7f6f2f7d8b431f/bin/me/zombie_striker/pixelprinter/Metrics.class -------------------------------------------------------------------------------- /bin/me/zombie_striker/pixelprinter/PPListener.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZombieStriker/PixelPrinter/56c9496b3081125a9a62e01a1f7f6f2f7d8b431f/bin/me/zombie_striker/pixelprinter/PPListener.class -------------------------------------------------------------------------------- /bin/me/zombie_striker/pixelprinter/PixelPrinter$1.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZombieStriker/PixelPrinter/56c9496b3081125a9a62e01a1f7f6f2f7d8b431f/bin/me/zombie_striker/pixelprinter/PixelPrinter$1.class -------------------------------------------------------------------------------- /bin/me/zombie_striker/pixelprinter/PixelPrinter$2.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZombieStriker/PixelPrinter/56c9496b3081125a9a62e01a1f7f6f2f7d8b431f/bin/me/zombie_striker/pixelprinter/PixelPrinter$2.class -------------------------------------------------------------------------------- /bin/me/zombie_striker/pixelprinter/PixelPrinter$3.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZombieStriker/PixelPrinter/56c9496b3081125a9a62e01a1f7f6f2f7d8b431f/bin/me/zombie_striker/pixelprinter/PixelPrinter$3.class -------------------------------------------------------------------------------- /bin/me/zombie_striker/pixelprinter/PixelPrinter$4.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZombieStriker/PixelPrinter/56c9496b3081125a9a62e01a1f7f6f2f7d8b431f/bin/me/zombie_striker/pixelprinter/PixelPrinter$4.class -------------------------------------------------------------------------------- /bin/me/zombie_striker/pixelprinter/PixelPrinter$5.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZombieStriker/PixelPrinter/56c9496b3081125a9a62e01a1f7f6f2f7d8b431f/bin/me/zombie_striker/pixelprinter/PixelPrinter$5.class -------------------------------------------------------------------------------- /bin/me/zombie_striker/pixelprinter/PixelPrinter$6.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZombieStriker/PixelPrinter/56c9496b3081125a9a62e01a1f7f6f2f7d8b431f/bin/me/zombie_striker/pixelprinter/PixelPrinter$6.class -------------------------------------------------------------------------------- /bin/me/zombie_striker/pixelprinter/PixelPrinter$7$1.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZombieStriker/PixelPrinter/56c9496b3081125a9a62e01a1f7f6f2f7d8b431f/bin/me/zombie_striker/pixelprinter/PixelPrinter$7$1.class -------------------------------------------------------------------------------- /bin/me/zombie_striker/pixelprinter/PixelPrinter$7.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZombieStriker/PixelPrinter/56c9496b3081125a9a62e01a1f7f6f2f7d8b431f/bin/me/zombie_striker/pixelprinter/PixelPrinter$7.class -------------------------------------------------------------------------------- /bin/me/zombie_striker/pixelprinter/PixelPrinter.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZombieStriker/PixelPrinter/56c9496b3081125a9a62e01a1f7f6f2f7d8b431f/bin/me/zombie_striker/pixelprinter/PixelPrinter.class -------------------------------------------------------------------------------- /bin/me/zombie_striker/pixelprinter/data/DataHolder$1.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZombieStriker/PixelPrinter/56c9496b3081125a9a62e01a1f7f6f2f7d8b431f/bin/me/zombie_striker/pixelprinter/data/DataHolder$1.class -------------------------------------------------------------------------------- /bin/me/zombie_striker/pixelprinter/data/DataHolder.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZombieStriker/PixelPrinter/56c9496b3081125a9a62e01a1f7f6f2f7d8b431f/bin/me/zombie_striker/pixelprinter/data/DataHolder.class -------------------------------------------------------------------------------- /bin/me/zombie_striker/pixelprinter/data/Direction.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZombieStriker/PixelPrinter/56c9496b3081125a9a62e01a1f7f6f2f7d8b431f/bin/me/zombie_striker/pixelprinter/data/Direction.class -------------------------------------------------------------------------------- /bin/me/zombie_striker/pixelprinter/data/FileCreatorData.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZombieStriker/PixelPrinter/56c9496b3081125a9a62e01a1f7f6f2f7d8b431f/bin/me/zombie_striker/pixelprinter/data/FileCreatorData.class -------------------------------------------------------------------------------- /bin/me/zombie_striker/pixelprinter/data/IntHolder.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZombieStriker/PixelPrinter/56c9496b3081125a9a62e01a1f7f6f2f7d8b431f/bin/me/zombie_striker/pixelprinter/data/IntHolder.class -------------------------------------------------------------------------------- /bin/me/zombie_striker/pixelprinter/data/MaterialData.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZombieStriker/PixelPrinter/56c9496b3081125a9a62e01a1f7f6f2f7d8b431f/bin/me/zombie_striker/pixelprinter/data/MaterialData.class -------------------------------------------------------------------------------- /bin/me/zombie_striker/pixelprinter/util/AsyncImageHolder$1$1$1.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZombieStriker/PixelPrinter/56c9496b3081125a9a62e01a1f7f6f2f7d8b431f/bin/me/zombie_striker/pixelprinter/util/AsyncImageHolder$1$1$1.class -------------------------------------------------------------------------------- /bin/me/zombie_striker/pixelprinter/util/AsyncImageHolder$1$1.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZombieStriker/PixelPrinter/56c9496b3081125a9a62e01a1f7f6f2f7d8b431f/bin/me/zombie_striker/pixelprinter/util/AsyncImageHolder$1$1.class -------------------------------------------------------------------------------- /bin/me/zombie_striker/pixelprinter/util/AsyncImageHolder$1$2.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZombieStriker/PixelPrinter/56c9496b3081125a9a62e01a1f7f6f2f7d8b431f/bin/me/zombie_striker/pixelprinter/util/AsyncImageHolder$1$2.class -------------------------------------------------------------------------------- /bin/me/zombie_striker/pixelprinter/util/AsyncImageHolder$1.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZombieStriker/PixelPrinter/56c9496b3081125a9a62e01a1f7f6f2f7d8b431f/bin/me/zombie_striker/pixelprinter/util/AsyncImageHolder$1.class -------------------------------------------------------------------------------- /bin/me/zombie_striker/pixelprinter/util/AsyncImageHolder.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZombieStriker/PixelPrinter/56c9496b3081125a9a62e01a1f7f6f2f7d8b431f/bin/me/zombie_striker/pixelprinter/util/AsyncImageHolder.class -------------------------------------------------------------------------------- /bin/me/zombie_striker/pixelprinter/util/BlockTypeSnapshot.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZombieStriker/PixelPrinter/56c9496b3081125a9a62e01a1f7f6f2f7d8b431f/bin/me/zombie_striker/pixelprinter/util/BlockTypeSnapshot.class -------------------------------------------------------------------------------- /bin/me/zombie_striker/pixelprinter/util/CustomImageRenderer.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZombieStriker/PixelPrinter/56c9496b3081125a9a62e01a1f7f6f2f7d8b431f/bin/me/zombie_striker/pixelprinter/util/CustomImageRenderer.class -------------------------------------------------------------------------------- /bin/me/zombie_striker/pixelprinter/util/FileNameToMaterialUtil.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZombieStriker/PixelPrinter/56c9496b3081125a9a62e01a1f7f6f2f7d8b431f/bin/me/zombie_striker/pixelprinter/util/FileNameToMaterialUtil.class -------------------------------------------------------------------------------- /bin/me/zombie_striker/pixelprinter/util/GifHolder$1.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZombieStriker/PixelPrinter/56c9496b3081125a9a62e01a1f7f6f2f7d8b431f/bin/me/zombie_striker/pixelprinter/util/GifHolder$1.class -------------------------------------------------------------------------------- /bin/me/zombie_striker/pixelprinter/util/GifHolder$2.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZombieStriker/PixelPrinter/56c9496b3081125a9a62e01a1f7f6f2f7d8b431f/bin/me/zombie_striker/pixelprinter/util/GifHolder$2.class -------------------------------------------------------------------------------- /bin/me/zombie_striker/pixelprinter/util/GifHolder$3.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZombieStriker/PixelPrinter/56c9496b3081125a9a62e01a1f7f6f2f7d8b431f/bin/me/zombie_striker/pixelprinter/util/GifHolder$3.class -------------------------------------------------------------------------------- /bin/me/zombie_striker/pixelprinter/util/GifHolder$4.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZombieStriker/PixelPrinter/56c9496b3081125a9a62e01a1f7f6f2f7d8b431f/bin/me/zombie_striker/pixelprinter/util/GifHolder$4.class -------------------------------------------------------------------------------- /bin/me/zombie_striker/pixelprinter/util/GifHolder.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZombieStriker/PixelPrinter/56c9496b3081125a9a62e01a1f7f6f2f7d8b431f/bin/me/zombie_striker/pixelprinter/util/GifHolder.class -------------------------------------------------------------------------------- /bin/me/zombie_striker/pixelprinter/util/Image.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZombieStriker/PixelPrinter/56c9496b3081125a9a62e01a1f7f6f2f7d8b431f/bin/me/zombie_striker/pixelprinter/util/Image.class -------------------------------------------------------------------------------- /bin/me/zombie_striker/pixelprinter/util/MapWallUtil$1.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZombieStriker/PixelPrinter/56c9496b3081125a9a62e01a1f7f6f2f7d8b431f/bin/me/zombie_striker/pixelprinter/util/MapWallUtil$1.class -------------------------------------------------------------------------------- /bin/me/zombie_striker/pixelprinter/util/MapWallUtil.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZombieStriker/PixelPrinter/56c9496b3081125a9a62e01a1f7f6f2f7d8b431f/bin/me/zombie_striker/pixelprinter/util/MapWallUtil.class -------------------------------------------------------------------------------- /bin/me/zombie_striker/pixelprinter/util/MojangAPI.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZombieStriker/PixelPrinter/56c9496b3081125a9a62e01a1f7f6f2f7d8b431f/bin/me/zombie_striker/pixelprinter/util/MojangAPI.class -------------------------------------------------------------------------------- /bin/me/zombie_striker/pixelprinter/util/RGBBlockColor$Pixel.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZombieStriker/PixelPrinter/56c9496b3081125a9a62e01a1f7f6f2f7d8b431f/bin/me/zombie_striker/pixelprinter/util/RGBBlockColor$Pixel.class -------------------------------------------------------------------------------- /bin/me/zombie_striker/pixelprinter/util/RGBBlockColor.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZombieStriker/PixelPrinter/56c9496b3081125a9a62e01a1f7f6f2f7d8b431f/bin/me/zombie_striker/pixelprinter/util/RGBBlockColor.class -------------------------------------------------------------------------------- /bin/me/zombie_striker/pixelprinter/util/RGBBlockValue.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZombieStriker/PixelPrinter/56c9496b3081125a9a62e01a1f7f6f2f7d8b431f/bin/me/zombie_striker/pixelprinter/util/RGBBlockValue.class -------------------------------------------------------------------------------- /bin/me/zombie_striker/pixelprinter/util/RGBChatColor.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZombieStriker/PixelPrinter/56c9496b3081125a9a62e01a1f7f6f2f7d8b431f/bin/me/zombie_striker/pixelprinter/util/RGBChatColor.class -------------------------------------------------------------------------------- /bin/me/zombie_striker/pixelprinter/util/RGBValue.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZombieStriker/PixelPrinter/56c9496b3081125a9a62e01a1f7f6f2f7d8b431f/bin/me/zombie_striker/pixelprinter/util/RGBValue.class -------------------------------------------------------------------------------- /bin/me/zombie_striker/pixelprinter/util/ReflectionUtil.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZombieStriker/PixelPrinter/56c9496b3081125a9a62e01a1f7f6f2f7d8b431f/bin/me/zombie_striker/pixelprinter/util/ReflectionUtil.class -------------------------------------------------------------------------------- /bin/me/zombie_striker/pixelprinter/util/SimilarMapUtil.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZombieStriker/PixelPrinter/56c9496b3081125a9a62e01a1f7f6f2f7d8b431f/bin/me/zombie_striker/pixelprinter/util/SimilarMapUtil.class -------------------------------------------------------------------------------- /bin/me/zombie_striker/pixelprinter/util/SkinCreator.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZombieStriker/PixelPrinter/56c9496b3081125a9a62e01a1f7f6f2f7d8b431f/bin/me/zombie_striker/pixelprinter/util/SkinCreator.class -------------------------------------------------------------------------------- /bin/me/zombie_striker/pixelprinter/util/UndoUtil.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZombieStriker/PixelPrinter/56c9496b3081125a9a62e01a1f7f6f2f7d8b431f/bin/me/zombie_striker/pixelprinter/util/UndoUtil.class -------------------------------------------------------------------------------- /bin/me/zombie_striker/pixelprinter/util/Update13Handler.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZombieStriker/PixelPrinter/56c9496b3081125a9a62e01a1f7f6f2f7d8b431f/bin/me/zombie_striker/pixelprinter/util/Update13Handler.class -------------------------------------------------------------------------------- /libs/PluginConstructorAPI.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZombieStriker/PixelPrinter/56c9496b3081125a9a62e01a1f7f6f2f7d8b431f/libs/PluginConstructorAPI.jar -------------------------------------------------------------------------------- /pom.xml: -------------------------------------------------------------------------------- 1 | 3 | 4.0.0 4 | me.zombie_striker 5 | PixelPrinter 6 | 1.0.48 7 | 8 | 9 | spigot-repo 10 | https://hub.spigotmc.org/nexus/content/repositories/snapshots/ 11 | 12 | 13 | 14 | ${project.name} 15 | install 16 | 17 | 18 | 19 | ${basedir}/resources 20 | true 21 | 22 | plugin.yml 23 | changelog.txt 24 | config.yml 25 | 26 | 27 | 28 | src 29 | src 30 | 31 | **/*.java 32 | **/*.gwt.xml 33 | 34 | 35 | 36 | src 37 | 38 | 39 | maven-compiler-plugin 40 | 3.7.0 41 | 42 | 1.7 43 | 1.7 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | me.zombie_striker 52 | pluginconstructor 53 | 1.0.50 54 | system 55 | ${project.basedir}/libs/PluginConstructorAPI.jar 56 | 57 | 58 | 59 | 60 | 61 | 62 | org.spigotmc 63 | spigot 64 | 1.16.1-R0.1-SNAPSHOT 65 | provided 66 | 67 | 68 | -------------------------------------------------------------------------------- /resources/changelog.txt: -------------------------------------------------------------------------------- 1 | 1.0.48 2 | - Possible fix for 1.12 3 | 4 | 1.0.47 5 | Fixed skin creator 6 | 7 | 1.0.46 8 | Added 1.16 pre-support. 9 | Added 1.15 blocks to RGB color system. 10 | Fixed updated block count to correctly display right amount. 11 | Changed internal direction system to new ImageRelativeBlockDirection enum instead of BlockFace. 12 | Implemented new system that makes loading new blocks easier. 13 | 14 | 1.0.45 15 | Fixed 1.14 support. 16 | Fixed large image loading for 1.14+ 17 | Fixed long wait times/crashes for multiple images 18 | Fixed /pp undo 19 | Fixed issue where directions for rotated blocks are not correct 20 | 21 | 1.0.44 22 | Added 1.14 support 23 | Added /pp undo to undo images. Does not affect blocks that are air 24 | Moved all PluginConstructorAPI classes into PixelPrinter. It should no longer be needed as a dependency. 25 | FIXED MAP UNRENDERING BUG FOR 1.14 26 | Optimized maps so map with the same image are reused 27 | Updated to Maven 28 | 29 | 1.0.43 30 | Fixed gif maps. 31 | Fixed maps for 1.13. 32 | 33 | 1.0.42 34 | Fixed issue where directions were getting mixed up. 35 | Fixed VOID AIR error appearing if image is cut off 36 | Fixed issue for 1.13 where the materialIDs are stilled checked, even though all items should no longer have them 37 | 1.0.41 38 | Fixed error message if the player uses pp di in console. 39 | Changed downloader so it saves as PNG 40 | 41 | 1.0.40 42 | Move all 1.13 code to its own class. Should fix error finding the class 43 | 44 | 1.0.39 45 | Removed exception thrower 46 | 47 | 1.0.38 48 | Added back support for lower versions. 49 | 50 | 1.0.37 51 | Added full 1.13 support 52 | 53 | 1.0.36 54 | Added support for transparent images. You can now load item icons without having to break the blocks for the transparent pixels 55 | Fixed blocks for custom resourcepacks 56 | Fixed RGB for some blocks 57 | Made sure most blocks for 1.13 can be loaded 58 | Added more non-solid blocks to blacklist 59 | 60 | 1.0.35 61 | Added more blocks faces. Added Pistons, pumpkins, dispensers, and observers. 62 | 63 | 1.0.34 64 | More skin support. 65 | 66 | 1.0.33 67 | Added more skin support 68 | 69 | 1.0.32 70 | Fixed legacy skin issue 71 | 72 | 1.0.31 73 | Added more linecodes. 74 | 75 | 1.0.30 76 | Fixed imports 77 | 78 | 1.0.29 79 | Fixed Java9 JavaX import 80 | 81 | 1.0.28 82 | Fixed updater time-out error. 83 | 84 | 1.0.27 85 | Fixed Github updater 86 | 87 | 1.0.26 88 | Added semi-support for slim skins. 89 | 90 | 1.0.25 91 | Added doors to images 92 | 93 | 1.0.24 94 | Added whitelistedMaterials to config. Now you can specify which blocks should be allowed on your server when creating an image 95 | 96 | 1.0.23 97 | Fixed updater 98 | 99 | 1.0.22 100 | Fixed black blocks not loaded 101 | Added enableTrans to /pp create. This will allow you to control if the image should render transparent pixels, or turn them black. 102 | Improved code for loading chunks. 103 | Improved messages to not create chatspam when loading image. 104 | 105 | 1.0.21 106 | Code Cleanup 107 | Added hat support! 108 | Fixed transparent images for PP. No longer do you have to worry about breaking all the black blocks for icons images created. 109 | 110 | 1.0.20 111 | Code cleanup 112 | Added more checks around onEnable. The plugin should still operate even if something fails 113 | Added reload on dependancy download, since we need PCAPI for this plugin to work. 114 | Fixed permissions for /pp d 115 | Fixed chuck alignment for image loading. Should now have less lag for low end systems. 116 | 117 | 118 | 1.0.19 119 | Replace Schedulers with BukkitRunnables 120 | Added support for PPAPI in 1.0.4: Better color detection 121 | 122 | 1.0.18 123 | Fixed dependancy 124 | 125 | 1.0.17 126 | Added PluginConstructorAPI dependancy 127 | Added Capes to player skins 128 | 129 | 1.0.16 130 | Added support for offline servers. 131 | Fixed issue with capes. 132 | 133 | 1.0.15 134 | Fixing incorrect data values for blocks. 135 | Fixed gifs being half as tall as they should be. 136 | Fixed issue loading large gifs- Image conversion is done asynchronously. 137 | 138 | 1.0.14 139 | Added /pp createSkin. This will generate a 1-1 pixel version of a player's skin. 140 | Added 1.12 support. 141 | Fixed color code values: Block colors should be accurate. 142 | Fixed invalid link error. 143 | Added custom resourcepack support 144 | Fixed gifs stopping when reloading 145 | Slowed down gif framerate so low-end clients can render them better. 146 | 147 | 1.0.13 148 | Added more chars to ASCII printer 149 | Updated updater 150 | 151 | 1.0.12 152 | Changed location of updater. There should be no longer any conflicts with my other plugins. 153 | Fixed gif inputstream error. 154 | Allowed users to input the URL in the command. 155 | 156 | 1.0.11 157 | Added support for ALL versions of bukkit/spigot 158 | Fixed chat color codes. Now chat images from /pp specs XXX will look better/ more accurate 159 | Minor bug fixes 160 | 161 | 1.0.10 162 | 163 | Added image-viewer. You are now able to see the image you are selecting using the chat. Using /pp specs will now print out the image in the chat 164 | (Note: Because MC only has 16 colors, images will be almost unrecognizable at this current time. Once I can set up multiple chars and once MC gets more colors, then 165 | Image should become clearer.) 166 | Updated code for the new BukkitDev site 167 | Added changelog 168 | 169 | 170 | 1.0.9 171 | 172 | Changed image loading from the bottom-up, to left-to-right. This will add a great performance boost for both the server and the players (To the point where some players 173 | may no longer receive any lag when loading large images). 174 | Fixed issue where images may become max size instead of scaling to the player's input. 175 | 176 | 1.0.8 177 | 178 | Added bStats 179 | Added new directions: FlatSouthEast, FlatSouthWest, FlatNorthEast, and FlatNorthWest 180 | Added more correct values. 181 | Added color values for tops of blocks, and sides of blocks 182 | Fixed logs spawning with a "top face". The bark will always be shown now. 183 | Fixed some commands. 184 | Added ability to change the amount of blocks will load every second. If you want one block to spawn every second, use /pp setLoadCount 1. 185 | URLS now have to be typed on a second line when downloading images/image locations. This adds the ability to use large URLs. 186 | Other bug fixes. 187 | 188 | 1.0.7 189 | 190 | Fixed color finding algorithm 191 | Added more blocks 192 | Minor bug fixes 193 | 194 | 1.0.6 195 | 196 | Fixed image values 197 | Made color searching algorithm more accurate. 198 | Added some new shortcuts. 199 | General bug fixes 200 | 201 | 1.0.5 202 | 203 | Added License 204 | Fixed some minor issues. 205 | 206 | -------------------------------------------------------------------------------- /resources/plugin.yml: -------------------------------------------------------------------------------- 1 | main: me.zombie_striker.pixelprinter.PixelPrinter 2 | version: ${project.version} 3 | name: PixelPrinter 4 | api-version: 1.13 5 | commands: 6 | PixelPrinter: 7 | description: Create images using blocks 8 | aliases: [pp] 9 | permissions: 10 | pixelprinter.*: 11 | description: Gives access to all PixelPrinter commands 12 | children: 13 | pixelprinter.create: true 14 | pixelprinter.download: true 15 | pixelprinter.delete: true 16 | pixelprinter.stop: true 17 | pixelprinter.create: 18 | description: Allows you create PixelPrinter images 19 | pixelprinter.download: 20 | description: Allows you to download images for the server to use 21 | pixelprinter.stop: 22 | description: Allows you to stop gifs on the server 23 | pixelprinter.delete: 24 | description: Allows you to delete images inside the /Pixelprinter/images/ directory 25 | author: 26 | Zombie_Striker -------------------------------------------------------------------------------- /src/me/zombie_striker/easygui/ClickData.java: -------------------------------------------------------------------------------- 1 | package me.zombie_striker.easygui; 2 | 3 | import org.bukkit.entity.Player; 4 | import org.bukkit.event.inventory.InventoryClickEvent; 5 | import org.bukkit.inventory.Inventory; 6 | import org.bukkit.inventory.ItemStack; 7 | 8 | public class ClickData { 9 | 10 | private InventoryClickEvent raw; 11 | private Inventory inv; 12 | private Player clicker; 13 | private ItemStack clickedItem; 14 | private int slot; 15 | private EasyGUI gui; 16 | 17 | public ClickData(InventoryClickEvent raw, EasyGUI gui){ 18 | this.raw = raw; 19 | this.clickedItem = raw.getCurrentItem(); 20 | this.clicker = (Player) raw.getWhoClicked(); 21 | this.slot = raw.getSlot(); 22 | this.inv = raw.getClickedInventory(); 23 | this.gui = gui; 24 | } 25 | public int getSlot(){ 26 | return slot; 27 | } 28 | public ItemStack getClickedItem(){ 29 | return clickedItem; 30 | } 31 | public Player getClicker(){ 32 | return clicker; 33 | } 34 | public InventoryClickEvent getRaw(){ 35 | return raw; 36 | } 37 | public Inventory getInventory(){ 38 | return inv; 39 | } 40 | public void cancelPickup(boolean b){ 41 | raw.setCancelled(b); 42 | } 43 | public boolean isCanceled(){ 44 | return raw.isCancelled(); 45 | } 46 | public EasyGUI getClickedGUI(){ 47 | return gui; 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /src/me/zombie_striker/easygui/EasyGUI.java: -------------------------------------------------------------------------------- 1 | package me.zombie_striker.easygui; 2 | 3 | import me.zombie_striker.pixelprinter.PixelPrinter; 4 | import org.bukkit.Bukkit; 5 | import org.bukkit.ChatColor; 6 | import org.bukkit.Material; 7 | import org.bukkit.event.EventHandler; 8 | import org.bukkit.event.Listener; 9 | import org.bukkit.event.inventory.InventoryClickEvent; 10 | import org.bukkit.inventory.Inventory; 11 | import org.bukkit.inventory.ItemStack; 12 | import org.bukkit.inventory.meta.ItemMeta; 13 | import org.bukkit.plugin.java.JavaPlugin; 14 | import org.bukkit.scheduler.BukkitRunnable; 15 | 16 | import java.util.HashMap; 17 | 18 | public class EasyGUI { 19 | 20 | private static HashMap lists = new HashMap<>(); 21 | 22 | private ItemStack[] items; 23 | private String title; 24 | private String displayname; 25 | 26 | private EasyGUICallable[] buttons; 27 | 28 | private Inventory[] loadedInventories; 29 | 30 | private static ItemStack BOTTOM; 31 | private static ItemStack BACK; 32 | private static ItemStack FORWARD; 33 | 34 | private static final String BACK_NAME = ChatColor.RED + "[Previous Page]"; 35 | private static final String FORWARD_NAME = ChatColor.GREEN + "[Next Page]"; 36 | private static final String BOTTOM_NAME = ""; 37 | 38 | static { 39 | try { 40 | BOTTOM = new ItemStack(Material.WHITE_STAINED_GLASS_PANE); 41 | BACK = new ItemStack(Material.RED_STAINED_GLASS_PANE); 42 | FORWARD = new ItemStack(Material.GREEN_STAINED_GLASS_PANE); 43 | } catch (Error | Exception e4) { 44 | BOTTOM = new ItemStack(Material.valueOf("STAINED_GLASS_PANE"), 1, (short) 0); 45 | BACK = new ItemStack(Material.valueOf("STAINED_GLASS_PANE"), 1, (short) 12); 46 | FORWARD = new ItemStack(Material.valueOf("STAINED_GLASS_PANE"), 1, (short) 6); 47 | } 48 | ItemMeta temp; 49 | 50 | temp = BOTTOM.getItemMeta(); 51 | temp.setDisplayName(BOTTOM_NAME); 52 | BOTTOM.setItemMeta(temp); 53 | 54 | temp = BACK.getItemMeta(); 55 | temp.setDisplayName(BACK_NAME); 56 | BACK.setItemMeta(temp); 57 | 58 | temp = FORWARD.getItemMeta(); 59 | temp.setDisplayName(FORWARD_NAME); 60 | FORWARD.setItemMeta(temp); 61 | } 62 | 63 | private static boolean beenEnabled = false; 64 | 65 | public static void INIT(JavaPlugin plugin) { 66 | if (!beenEnabled) 67 | Bukkit.getPluginManager().registerEvents(new InventoryListener(), plugin); 68 | beenEnabled = true; 69 | } 70 | 71 | public static EasyGUI generateGUIIfNoneExist(ItemStack[] items, String title, boolean removeEmptySlots) { 72 | return generateGUIIfNoneExist(items, title,title,!removeEmptySlots); 73 | } 74 | public static EasyGUI generateGUIIfNoneExist(ItemStack[] items, String title, String displayname, boolean removeEmptySlots) { 75 | if(lists.containsKey(title)) 76 | return lists.get(title); 77 | return new EasyGUI(items,title,displayname,! removeEmptySlots); 78 | } 79 | public static EasyGUI generateGUIIfNoneExist(int maxAmountAllowedItems, String title, boolean removeEmptySlots) { 80 | return generateGUIIfNoneExist(maxAmountAllowedItems,title,title,!removeEmptySlots); 81 | } 82 | public static EasyGUI generateGUIIfNoneExist(int maxAmountAllowedItems, String title, String displayname, boolean removeEmptySlots) { 83 | return generateGUIIfNoneExist(maxAmountAllowedItems,title,displayname,removeEmptySlots,false); 84 | } 85 | public static EasyGUI generateGUIIfNoneExist(int maxAmountAllowedItems, String title, String displayname, boolean removeEmptySlots, boolean forceCreateNew) { 86 | if(lists.containsKey(title) && !forceCreateNew) 87 | return lists.get(title); 88 | if(maxAmountAllowedItems%9!=0) 89 | maxAmountAllowedItems = (((maxAmountAllowedItems/9)+1)*9); 90 | if(maxAmountAllowedItems==0) 91 | maxAmountAllowedItems=9; 92 | 93 | return new EasyGUI(new ItemStack[maxAmountAllowedItems],title, displayname, !removeEmptySlots); 94 | } 95 | 96 | private EasyGUI(ItemStack[] items, String title, boolean maximizeInventory) { 97 | this(items,title,title,maximizeInventory); 98 | } 99 | private EasyGUI(ItemStack[] items, String title, String displayname, boolean maximizeInventory) { 100 | 101 | this.items = items; 102 | buttons = new EasyGUICallable[items.length]; 103 | 104 | this.title = title; 105 | this.displayname = displayname; 106 | lists.put(title, this); 107 | 108 | loadedInventories = new Inventory[((items.length / (9 * 5)+1))]; 109 | for (int page = 0; page < (items.length / (45))+1; page++) { 110 | int id = page * 45; 111 | int size = maximizeInventory ? 54: (Math.min(45, (((items.length-id-1)/9)*9)+9)+9); 112 | Inventory pageI = Bukkit.createInventory(null, size, displayname); 113 | for (int i = 0; i < Math.min(45, items.length - id); i++) { 114 | if(i < pageI.getSize()) 115 | pageI.setItem(i, items[id + i]); 116 | } 117 | if(items.length >= 45) { 118 | for (int i = 0; i < 7; i++) { 119 | pageI.setItem(45 + i, BOTTOM); 120 | } 121 | if (page == 0) { 122 | pageI.setItem(52, BOTTOM); 123 | } else { 124 | pageI.setItem(52, BACK); 125 | } 126 | if (page == (items.length / (45)) - 1) { 127 | pageI.setItem(53, BOTTOM); 128 | } else { 129 | pageI.setItem(53, FORWARD); 130 | } 131 | } 132 | loadedInventories[page] = pageI; 133 | } 134 | } 135 | 136 | public void updateButton(int slot, ItemStack newItem) { 137 | updateButton(slot, newItem, buttons[slot]); 138 | } 139 | 140 | public void updateButton(int slot, final ItemStack newItem, EasyGUICallable newCallable) { 141 | final int page = slot / 45; 142 | final int i = slot - (page * 45); 143 | 144 | if(page >= loadedInventories.length){ 145 | Inventory[] tempItem = new Inventory[page]; 146 | EasyGUICallable[] buttons = new EasyGUICallable[items.length]; 147 | for(int l = 0; l < loadedInventories.length;l++){ 148 | tempItem[l] = loadedInventories[l]; 149 | } 150 | loadedInventories=tempItem; 151 | this.buttons=buttons; 152 | } 153 | 154 | if(page >= 1){ 155 | new BukkitRunnable(){ 156 | @Override 157 | public void run() { 158 | loadedInventories[page].setItem(i, newItem); 159 | } 160 | }.runTaskLater(PixelPrinter.getInstance(),page*4); 161 | }else { 162 | loadedInventories[page].setItem(i, newItem); 163 | } 164 | items[slot]=newItem; 165 | buttons[slot] = newCallable; 166 | } 167 | public void updateAllCallables(EasyGUICallable... callables){ 168 | int i = 0; 169 | for(EasyGUICallable c : callables){ 170 | buttons[i] = c; 171 | i++; 172 | } 173 | } 174 | 175 | public static EasyGUI getEasyGUIByName(String title) { 176 | return lists.get(title); 177 | } 178 | 179 | public static EasyGUI getEasyGUIByInventory(Inventory inventory) { 180 | for (EasyGUI gui : lists.values()) { 181 | for (Inventory i : gui.loadedInventories) 182 | if (i!=null && i.equals(inventory)) 183 | return gui; 184 | } 185 | return null; 186 | } 187 | 188 | public int getPageIDFromInventory(Inventory inventory) { 189 | for (int i = 0; i < loadedInventories.length; i++) 190 | if (loadedInventories[i].equals(inventory)) 191 | return i; 192 | return -1; 193 | } 194 | 195 | public void registerButton(EasyGUICallable code, int itemSlot) { 196 | buttons[itemSlot] = code; 197 | } 198 | 199 | public Inventory getPageByID(int id) { 200 | return loadedInventories[id]; 201 | } 202 | 203 | static class InventoryListener implements Listener { 204 | 205 | @EventHandler 206 | public void onClick(InventoryClickEvent e) { 207 | EasyGUI gui = null; 208 | if ((gui = EasyGUI.getEasyGUIByInventory(e.getClickedInventory())) != null) { 209 | e.setCancelled(true); 210 | if (e.getClick().isShiftClick()) { 211 | e.setCancelled(true); 212 | } 213 | if (e.getCurrentItem() != null) { 214 | if (e.getSlot() >= 45) { 215 | e.setCancelled(true); 216 | if (e.getCurrentItem().isSimilar(BOTTOM)) 217 | return; 218 | if (e.getSlot() == 52) { 219 | //back 220 | int page = gui.getPageIDFromInventory(e.getClickedInventory()); 221 | if (page > 0) { 222 | e.getWhoClicked().closeInventory(); 223 | e.getWhoClicked().openInventory(gui.getPageByID(page - 1)); 224 | } 225 | } else if (e.getSlot() == 53) { 226 | //back 227 | int page = gui.getPageIDFromInventory(e.getClickedInventory()); 228 | if (page < gui.loadedInventories.length - 1) { 229 | e.getWhoClicked().closeInventory(); 230 | e.getWhoClicked().openInventory(gui.getPageByID(page + 1)); 231 | } 232 | } 233 | return; 234 | } 235 | ClickData data = new ClickData(e, gui); 236 | if(gui.buttons.length > e.getSlot()) 237 | if (gui.buttons[e.getSlot()] != null) 238 | gui.buttons[e.getSlot()].call(data); 239 | } 240 | } 241 | } 242 | } 243 | } 244 | -------------------------------------------------------------------------------- /src/me/zombie_striker/easygui/EasyGUICallable.java: -------------------------------------------------------------------------------- 1 | package me.zombie_striker.easygui; 2 | 3 | public abstract class EasyGUICallable { 4 | 5 | public abstract void call(ClickData data); 6 | 7 | } 8 | -------------------------------------------------------------------------------- /src/me/zombie_striker/easygui/examples/HelloWorldCallable.java: -------------------------------------------------------------------------------- 1 | package me.zombie_striker.easygui.examples; 2 | 3 | import me.zombie_striker.easygui.ClickData; 4 | import me.zombie_striker.easygui.EasyGUICallable; 5 | 6 | public class HelloWorldCallable extends EasyGUICallable { 7 | 8 | @Override 9 | public void call(ClickData data) { 10 | data.getClicker().sendMessage("Hello World!"); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /src/me/zombie_striker/pixelprinter/GithubDependDownloader.java: -------------------------------------------------------------------------------- 1 | package me.zombie_striker.pixelprinter; 2 | 3 | import com.google.gson.JsonObject; 4 | import com.google.gson.JsonParser; 5 | import org.bukkit.Bukkit; 6 | import org.bukkit.ChatColor; 7 | import org.bukkit.plugin.Plugin; 8 | import org.bukkit.scheduler.BukkitRunnable; 9 | 10 | import java.io.*; 11 | import java.net.URL; 12 | import java.net.URLConnection; 13 | 14 | public class GithubDependDownloader { 15 | 16 | 17 | public static boolean autoUpdate(final Plugin main, final File output, String author, String githubProject, 18 | String jarname) { 19 | try { 20 | 21 | String tagname = null; 22 | URL api = new URL("https://api.github.com/repos/" + author + "/" + githubProject + "/releases/latest"); 23 | URLConnection con = api.openConnection(); 24 | con.setConnectTimeout(15000); 25 | con.setReadTimeout(15000); 26 | 27 | JsonObject json = new JsonParser().parse(new InputStreamReader(con.getInputStream())).getAsJsonObject(); 28 | tagname = json.get("tag_name").getAsString(); 29 | 30 | final URL download = new URL("https://github.com/" + author + "/" + githubProject + "/releases/download/" 31 | + tagname + "/" + jarname); 32 | 33 | Bukkit.getConsoleSender().sendMessage(ChatColor.GREEN + "Found a new version " + ChatColor.WHITE + tagname 34 | + ChatColor.LIGHT_PURPLE + " downloading now!!"); 35 | 36 | new BukkitRunnable() { 37 | 38 | @Override 39 | public void run() { 40 | try { 41 | 42 | InputStream in = download.openStream(); 43 | 44 | File pluginFile = output; 45 | 46 | // File temp = new File("plugins/update"); 47 | // if (!temp.exists()) { 48 | // temp.mkdir(); 49 | // } 50 | 51 | // Path path = new File("plugins/update" + File.separator + "COD.jar").toPath(); 52 | pluginFile.setWritable(true, false); 53 | pluginFile.delete(); 54 | // Files.copy(in, pluginFile.toPath(), StandardCopyOption.REPLACE_EXISTING); 55 | copy(in, new FileOutputStream(pluginFile)); 56 | 57 | new BukkitRunnable() { 58 | public void run() { 59 | Bukkit.reload(); 60 | } 61 | }.runTaskLater(main, 4); 62 | } catch (IOException e) { 63 | e.printStackTrace(); 64 | } 65 | } 66 | }.runTaskLaterAsynchronously(main, 0); 67 | return true; 68 | } catch (IOException e) { 69 | e.printStackTrace(); 70 | } 71 | return false; 72 | } 73 | 74 | private static long copy(InputStream in, OutputStream out) throws IOException { 75 | long bytes = 0; 76 | byte[] buf = new byte[0x1000]; 77 | while (true) { 78 | int r = in.read(buf); 79 | if (r == -1) 80 | break; 81 | out.write(buf, 0, r); 82 | bytes += r; 83 | // debug("Another 4K, current: " + r); 84 | } 85 | out.flush(); 86 | out.close(); 87 | in.close(); 88 | return bytes; 89 | } 90 | 91 | } 92 | -------------------------------------------------------------------------------- /src/me/zombie_striker/pixelprinter/GithubUpdater.java: -------------------------------------------------------------------------------- 1 | package me.zombie_striker.pixelprinter; 2 | 3 | import com.google.gson.JsonObject; 4 | import com.google.gson.JsonParser; 5 | import org.bukkit.Bukkit; 6 | import org.bukkit.ChatColor; 7 | import org.bukkit.plugin.Plugin; 8 | import org.bukkit.scheduler.BukkitRunnable; 9 | 10 | import java.io.*; 11 | import java.net.URL; 12 | import java.net.URLConnection; 13 | import java.net.URLDecoder; 14 | import java.nio.charset.StandardCharsets; 15 | 16 | public class GithubUpdater { 17 | 18 | public static boolean autoUpdate(final Plugin main, String author, String githubProject, String jarname) { 19 | try { 20 | String version = main.getDescription().getVersion(); 21 | String parseVersion = version.replace(".", ""); 22 | 23 | String tagname = null; 24 | URL api = new URL("https://api.github.com/repos/" + author + "/" + githubProject + "/releases/latest"); 25 | URLConnection con = api.openConnection(); 26 | con.setConnectTimeout(15000); 27 | con.setReadTimeout(15000); 28 | 29 | JsonObject json = new JsonParser().parse(new InputStreamReader(con.getInputStream())).getAsJsonObject(); 30 | tagname = json.get("tag_name").getAsString(); 31 | 32 | String parsedTagName = tagname.replace(".", ""); 33 | 34 | int latestVersion = Integer.valueOf(parsedTagName.substring(1)); 35 | 36 | final URL download = new URL("https://github.com/" + author + "/" + githubProject + "/releases/download/" 37 | + tagname + "/" + jarname); 38 | 39 | if (latestVersion > Integer.parseInt(parseVersion)) { 40 | Bukkit.getConsoleSender().sendMessage(ChatColor.GREEN + "Found a new version of " + ChatColor.GOLD + main.getDescription().getName() + ": " + ChatColor.WHITE 41 | + tagname + ChatColor.LIGHT_PURPLE + " downloading now!!"); 42 | 43 | new BukkitRunnable() { 44 | 45 | @Override 46 | public void run() { 47 | try { 48 | 49 | InputStream in = download.openStream(); 50 | 51 | 52 | File pluginFile = null; 53 | 54 | pluginFile = new File(URLDecoder.decode( 55 | this.getClass().getProtectionDomain().getCodeSource().getLocation().getPath(), 56 | StandardCharsets.UTF_8)); 57 | 58 | // File temp = new File("plugins/update"); 59 | // if (!temp.exists()) { 60 | // temp.mkdir(); 61 | // } 62 | 63 | File tempInCaseSomethingGoesWrong = new File(main.getName() + "-backup.jar"); 64 | copy(new FileInputStream(pluginFile), new FileOutputStream(tempInCaseSomethingGoesWrong)); 65 | 66 | // Path path = new File("plugins/update" + File.separator + "COD.jar").toPath(); 67 | pluginFile.setWritable(true, false); 68 | pluginFile.delete(); 69 | //Files.copy(in, pluginFile.toPath(), StandardCopyOption.REPLACE_EXISTING); 70 | copy(in, new FileOutputStream(pluginFile)); 71 | 72 | if (pluginFile.length() < 1000) { 73 | //Plugin is too small. Keep old version in case new one is incomplete/nonexistant 74 | copy(new FileInputStream(tempInCaseSomethingGoesWrong), new FileOutputStream(pluginFile)); 75 | } else { 76 | //Plugin is valid, and we can delete the temp 77 | tempInCaseSomethingGoesWrong.delete(); 78 | } 79 | 80 | } catch (IOException e) { 81 | } 82 | } 83 | }.runTaskLaterAsynchronously(main, 0); 84 | return true; 85 | } 86 | } catch (IOException e) { 87 | } 88 | return false; 89 | } 90 | 91 | private static long copy(InputStream in, OutputStream out) throws IOException { 92 | long bytes = 0; 93 | byte[] buf = new byte[0x1000]; 94 | while (true) { 95 | int r = in.read(buf); 96 | if (r == -1) 97 | break; 98 | out.write(buf, 0, r); 99 | bytes += r; 100 | // debug("Another 4K, current: " + r); 101 | } 102 | out.flush(); 103 | out.close(); 104 | in.close(); 105 | return bytes; 106 | } 107 | 108 | } 109 | -------------------------------------------------------------------------------- /src/me/zombie_striker/pixelprinter/PPListener.java: -------------------------------------------------------------------------------- 1 | package me.zombie_striker.pixelprinter; 2 | 3 | import org.bukkit.event.EventHandler; 4 | import org.bukkit.event.Listener; 5 | import org.bukkit.event.player.AsyncPlayerChatEvent; 6 | 7 | import javax.imageio.ImageIO; 8 | import java.awt.image.BufferedImage; 9 | import java.io.BufferedWriter; 10 | import java.io.File; 11 | import java.io.FileWriter; 12 | import java.io.IOException; 13 | import java.net.URL; 14 | 15 | public class PPListener implements Listener { 16 | 17 | private PixelPrinter inst; 18 | 19 | public PPListener(PixelPrinter p) { 20 | this.inst = p; 21 | } 22 | 23 | @EventHandler 24 | public void onChat(AsyncPlayerChatEvent e) { 25 | 26 | if (inst.downloadFile.containsKey(e.getPlayer().getUniqueId())) { 27 | e.setCancelled(true); 28 | if (!e.getMessage().contains(".")) { 29 | inst.downloadFile.remove(e.getPlayer().getUniqueId()); 30 | e.getPlayer().sendMessage("The link sent is not valid. Resend the command and provide a valid link."); 31 | return; 32 | } 33 | File outputfile = new File( 34 | inst.images + File.separator + inst.downloadFile.get(e.getPlayer().getUniqueId()).getName() 35 | // + inst.downloadFile.get(e.getPlayer().getUniqueId()) 36 | // .getType() 37 | + (inst.downloadFile.get(e.getPlayer().getUniqueId()).getType().equalsIgnoreCase(".txt") 38 | ? ".txt" 39 | : (e.getMessage().endsWith("gif") ? ".gif" : ".jpg"))); 40 | if (outputfile.exists()) { 41 | e.getPlayer().sendMessage(inst.getPrefix() 42 | + " A file already exists with this name. Either choose a new name or contact the server admin to delete this image."); 43 | return; 44 | } 45 | if (inst.downloadFile.get(e.getPlayer().getUniqueId()).getType().equalsIgnoreCase(".txt")) { 46 | try { 47 | BufferedWriter br = new BufferedWriter(new FileWriter(outputfile)); 48 | br.write(e.getMessage()); 49 | br.flush(); 50 | br.close(); 51 | e.getPlayer().sendMessage(inst.getPrefix() + " Completed downloading image path. File \"" 52 | + outputfile.getName() + "\" created."); 53 | } catch (IOException e2) { 54 | e.getPlayer().sendMessage(inst.getPrefix() 55 | + " Something failed when downloading the image. Check console for details."); 56 | e2.printStackTrace(); 57 | } 58 | } else { 59 | try { 60 | if (e.getMessage().toLowerCase().endsWith(".gif")) { 61 | // byte[] bytes = IOUtils.toByteArray(new URL(e 62 | // .getMessage()).openStream()); 63 | // FileUtils.writeByteArrayToFile(outputfile, bytes); 64 | PixelPrinter.saveImage(new URL(e.getMessage()), outputfile); 65 | e.getPlayer().sendMessage(inst.getPrefix() + " Completed downloading image. File \"" 66 | + outputfile.getName() + "\" created."); 67 | } else { 68 | BufferedImage bi = ImageIO.read(new URL(e.getMessage())); 69 | ImageIO.write(bi, "jpg", outputfile); 70 | e.getPlayer().sendMessage(inst.getPrefix() + " Completed downloading image. File \"" 71 | + outputfile.getName() + "\" created."); 72 | bi.flush(); 73 | } 74 | } catch (Exception er) { 75 | e.getPlayer().sendMessage(inst.getPrefix() 76 | + " Something failed when downloading the image. Check console for details."); 77 | er.printStackTrace(); 78 | 79 | } 80 | } 81 | inst.downloadFile.remove(e.getPlayer().getUniqueId()); 82 | } 83 | } 84 | } 85 | -------------------------------------------------------------------------------- /src/me/zombie_striker/pixelprinter/data/BoolHolder.java: -------------------------------------------------------------------------------- 1 | package me.zombie_striker.pixelprinter.data; 2 | 3 | public class BoolHolder { 4 | boolean i; 5 | 6 | public boolean getB() { 7 | return i; 8 | } 9 | 10 | public void setB(boolean i) { 11 | this.i = i; 12 | } 13 | } -------------------------------------------------------------------------------- /src/me/zombie_striker/pixelprinter/data/CustomMapView.java: -------------------------------------------------------------------------------- 1 | package me.zombie_striker.pixelprinter.data; 2 | 3 | import org.bukkit.Bukkit; 4 | import org.bukkit.World; 5 | import org.bukkit.map.MapRenderer; 6 | import org.bukkit.map.MapView; 7 | 8 | import java.util.ArrayList; 9 | import java.util.List; 10 | 11 | public class CustomMapView implements MapView { 12 | 13 | List renderers = new ArrayList<>(); 14 | private int mapID = 0; 15 | 16 | public CustomMapView(int id) { 17 | this.mapID = id; 18 | } 19 | 20 | @Override 21 | public void addRenderer(MapRenderer arg0) { 22 | renderers.add(arg0); 23 | } 24 | 25 | @Override 26 | public int getCenterX() { 27 | return 0; 28 | } 29 | 30 | @Override 31 | public void setCenterX(int arg0) { 32 | } 33 | 34 | @Override 35 | public int getCenterZ() { 36 | return 0; 37 | } 38 | 39 | @Override 40 | public void setCenterZ(int arg0) { 41 | } 42 | 43 | @Override 44 | public int getId() { 45 | return mapID; 46 | } 47 | 48 | @Override 49 | public List getRenderers() { 50 | return renderers; 51 | } 52 | 53 | @Override 54 | public Scale getScale() { 55 | return Scale.NORMAL; 56 | } 57 | 58 | @Override 59 | public void setScale(Scale arg0) { 60 | } 61 | 62 | @Override 63 | public World getWorld() { 64 | return Bukkit.getWorlds().get(0); 65 | } 66 | 67 | @Override 68 | public void setWorld(World arg0) { 69 | } 70 | 71 | @Override 72 | public boolean isUnlimitedTracking() { 73 | return true; 74 | } 75 | 76 | @Override 77 | public void setUnlimitedTracking(boolean arg0) { 78 | } 79 | 80 | @Override 81 | public boolean isVirtual() { 82 | return true; 83 | } 84 | 85 | @Override 86 | public boolean removeRenderer(MapRenderer arg0) { 87 | return renderers.remove(arg0); 88 | } 89 | 90 | @Override 91 | public boolean isTrackingPosition() { 92 | return false; 93 | } 94 | 95 | @Override 96 | public void setTrackingPosition(boolean b) { 97 | 98 | } 99 | 100 | @Override 101 | public boolean isLocked() { 102 | // TODO Auto-generated method stub 103 | return false; 104 | } 105 | 106 | @Override 107 | public void setLocked(boolean arg0) { 108 | // TODO Auto-generated method stub 109 | 110 | } 111 | 112 | 113 | } 114 | -------------------------------------------------------------------------------- /src/me/zombie_striker/pixelprinter/data/DataHolder.java: -------------------------------------------------------------------------------- 1 | package me.zombie_striker.pixelprinter.data; 2 | 3 | import me.zombie_striker.pixelprinter.PixelPrinter; 4 | import org.bukkit.Bukkit; 5 | import org.bukkit.Location; 6 | import org.bukkit.configuration.serialization.ConfigurationSerializable; 7 | import org.bukkit.scheduler.BukkitRunnable; 8 | 9 | import java.util.HashMap; 10 | import java.util.Map; 11 | 12 | public class DataHolder implements ConfigurationSerializable { 13 | public MaterialData md; 14 | public Location b; 15 | boolean hasFaces = false; 16 | 17 | public DataHolder(Location b2, MaterialData md) { 18 | this.b = b2; 19 | this.md = md; 20 | } 21 | 22 | public DataHolder(Location b, MaterialData md, boolean hasFaces) { 23 | this.b = b; 24 | this.md = md; 25 | this.hasFaces = hasFaces; 26 | } 27 | 28 | public DataHolder(Map data) { 29 | final Map tempData = data; 30 | new BukkitRunnable() { 31 | 32 | @Override 33 | public void run() { 34 | if (Bukkit.getWorld((String) tempData.get("b.w")) != null) { 35 | b = new Location(Bukkit.getWorld((String) tempData.get("b.w")), (int) tempData.get("b.x"), 36 | (int) tempData.get("b.y"), (int) tempData.get("b.z")); 37 | cancel(); 38 | } 39 | } 40 | }.runTaskTimer(PixelPrinter.getInstance(), 0, 20); 41 | this.md = (MaterialData) data.get("md"); 42 | } 43 | 44 | @Override 45 | public Map serialize() { 46 | Map data = new HashMap(); 47 | data.put("b.x", this.b.getBlockX()); 48 | data.put("b.y", this.b.getBlockY()); 49 | data.put("b.z", this.b.getBlockZ()); 50 | data.put("b.w", this.b.getWorld().getName()); 51 | data.put("md", this.md); 52 | return data; 53 | } 54 | 55 | public boolean hasFaces() { 56 | return hasFaces; 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /src/me/zombie_striker/pixelprinter/data/Direction.java: -------------------------------------------------------------------------------- 1 | package me.zombie_striker.pixelprinter.data; 2 | 3 | public enum Direction { 4 | UP_SOUTH("South"), 5 | UP_NORTH("North"), 6 | UP_EAST("East"), 7 | UP_WEST("West"), 8 | FLAT_NORTHEAST("FlatNorthEast"), 9 | FLAT_SOUTHEAST("FlatSouthEast"), 10 | FLAT_NORTHWEST("FlatNorthWest"), 11 | FLAT_SOUTHWEST("FlatSouthWest"); 12 | 13 | String dir; 14 | 15 | Direction(String dir) { 16 | this.dir = dir; 17 | } 18 | 19 | public static Direction getDir(String s) { 20 | for (Direction dir : Direction.values()) { 21 | if (dir.getName().equalsIgnoreCase(s)) 22 | return dir; 23 | } 24 | return null; 25 | } 26 | 27 | public String getName() { 28 | return dir; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/me/zombie_striker/pixelprinter/data/FileCreatorData.java: -------------------------------------------------------------------------------- 1 | package me.zombie_striker.pixelprinter.data; 2 | 3 | public class FileCreatorData { 4 | 5 | String fileType; 6 | String fileName; 7 | 8 | public FileCreatorData(String t, String n) { 9 | this.fileName = n; 10 | this.fileType = t; 11 | } 12 | 13 | public String getName() { 14 | return this.fileName; 15 | } 16 | 17 | public String getType() { 18 | return this.fileType; 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/me/zombie_striker/pixelprinter/data/ImageRelativeBlockDirection.java: -------------------------------------------------------------------------------- 1 | package me.zombie_striker.pixelprinter.data; 2 | 3 | import org.bukkit.block.BlockFace; 4 | 5 | public enum ImageRelativeBlockDirection { 6 | FRONT,SIDE,BACK,TOP,BOTTOM; 7 | 8 | public BlockFace convertToBlockFace(){ 9 | if(this == FRONT) 10 | return BlockFace.EAST; 11 | if(this == BACK) 12 | return BlockFace.WEST; 13 | if(this == SIDE) 14 | return BlockFace.NORTH; 15 | if(this == TOP) 16 | return BlockFace.UP; 17 | if(this == BOTTOM) 18 | return BlockFace.DOWN; 19 | return null; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/me/zombie_striker/pixelprinter/data/IntHolder.java: -------------------------------------------------------------------------------- 1 | package me.zombie_striker.pixelprinter.data; 2 | 3 | public class IntHolder { 4 | int i; 5 | 6 | public int getI() { 7 | return i; 8 | } 9 | 10 | public void setI(int i) { 11 | this.i = i; 12 | } 13 | } -------------------------------------------------------------------------------- /src/me/zombie_striker/pixelprinter/data/MaterialData.java: -------------------------------------------------------------------------------- 1 | package me.zombie_striker.pixelprinter.data; 2 | 3 | import me.zombie_striker.pixelprinter.util.RGBBlockColor; 4 | import org.bukkit.Material; 5 | import org.bukkit.block.BlockFace; 6 | import org.bukkit.configuration.serialization.ConfigurationSerializable; 7 | import org.bukkit.configuration.serialization.ConfigurationSerialization; 8 | 9 | import java.util.HashMap; 10 | import java.util.Map; 11 | 12 | public class MaterialData implements ConfigurationSerializable, Comparable { 13 | 14 | private Material m; 15 | private byte data; 16 | private ImageRelativeBlockDirection direction = null; 17 | private boolean onlyTop = false; 18 | 19 | public MaterialData(Material m, byte data, ImageRelativeBlockDirection direction) { 20 | this(m,data,direction,false); 21 | } 22 | public MaterialData(Material m, byte data, ImageRelativeBlockDirection direction, boolean onlyTop) { 23 | ConfigurationSerialization.registerClass(MaterialData.class); 24 | this.setMaterial(m); 25 | this.data = data; 26 | this.direction = direction; 27 | this.onlyTop = onlyTop; 28 | } 29 | 30 | public MaterialData(Material m, byte data) { 31 | this(m, data, null); 32 | } 33 | 34 | public MaterialData(Material m) { 35 | this(m, ((byte) 0), null); 36 | } 37 | 38 | public MaterialData(Map data) { 39 | this.setMaterial(Material.valueOf((String) data.get("m"))); 40 | this.data = Byte.parseByte((String) data.get("data")); 41 | } 42 | 43 | public static MaterialData getMatDataByTypes(Material mat, byte data) { 44 | return getMatDataByTypes(mat, data, null); 45 | } 46 | 47 | public static MaterialData getMatDataByTypes(Material mat, byte data, ImageRelativeBlockDirection direction) { 48 | for (MaterialData key : RGBBlockColor.materialValue.keySet()) 49 | if (key.getData() == data && key.getMaterial() == mat && ((direction == null && !key.hasDirection()) || direction == key.getDirection())) 50 | return key; 51 | return null; 52 | } 53 | 54 | public boolean hasDirection() { 55 | return direction != null; 56 | } 57 | public boolean isOnlyTop(){ 58 | return onlyTop; 59 | } 60 | 61 | public ImageRelativeBlockDirection getDirection() { 62 | return direction; 63 | } 64 | public BlockFace getBlockFace() { 65 | return direction.convertToBlockFace(); 66 | } 67 | 68 | public byte getData() { 69 | return data; 70 | } 71 | 72 | public Material getMaterial() { 73 | return m; 74 | } 75 | 76 | public void setMaterial(Material m) { 77 | this.m = m; 78 | } 79 | 80 | @Override 81 | public Map serialize() { 82 | Map data = new HashMap(); 83 | data.put("m", this.getMaterial().toString()); 84 | data.put("data", this.data + ""); 85 | return data; 86 | } 87 | 88 | @Override 89 | public int compareTo(MaterialData o) { 90 | if(this.m==o.m){ 91 | String dir1 = this.direction==null?"":this.direction.name(); 92 | String dir2 = o.direction==null?"":o.direction.name(); 93 | return dir1.compareTo(dir2); 94 | } 95 | return this.m.name().compareTo(o.m.name()); 96 | } 97 | } 98 | -------------------------------------------------------------------------------- /src/me/zombie_striker/pixelprinter/util/AsyncImageHolder.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2017 Zombie_Striker 3 | * 4 | * This program is free software; you can redistribute it and/or modify it under the terms of the 5 | * GNU General Public License as published by the Free Software Foundation; either version 2 of 6 | * the License, or (at your option) any later version. 7 | * 8 | * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 9 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 10 | * See the GNU General Public License for more details. 11 | * 12 | * You should have received a copy of the GNU General Public License along with this program; 13 | * if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 14 | * 02111-1307 USA 15 | */ 16 | 17 | package me.zombie_striker.pixelprinter.util; 18 | 19 | import me.zombie_striker.pixelprinter.PixelPrinter; 20 | import me.zombie_striker.pixelprinter.data.*; 21 | import me.zombie_striker.pixelprinter.util.RGBBlockColor.Pixel; 22 | import org.bukkit.Location; 23 | import org.bukkit.Material; 24 | import org.bukkit.block.Block; 25 | import org.bukkit.block.BlockFace; 26 | import org.bukkit.block.BlockState; 27 | import org.bukkit.entity.Player; 28 | import org.bukkit.scheduler.BukkitRunnable; 29 | 30 | import java.awt.*; 31 | import java.awt.image.BufferedImage; 32 | import java.util.ArrayList; 33 | import java.util.HashMap; 34 | import java.util.List; 35 | import java.util.Map.Entry; 36 | 37 | public class AsyncImageHolder extends Image { 38 | 39 | private final Pixel[][] result; 40 | private final BufferedImage bi; 41 | private String name = null; 42 | 43 | public AsyncImageHolder(Pixel[][] result1, Player p1, Location loc1, Direction dir1, BufferedImage bi1, 44 | boolean enableTrans) { 45 | this(null, result1, p1, loc1, dir1, bi1, enableTrans); 46 | } 47 | 48 | public AsyncImageHolder(String name, Pixel[][] result1, Player p1, Location loc1, Direction dir1, BufferedImage bi1, 49 | boolean enableTrans) { 50 | p = (p1 == null ? "Plugin" : p1.getName()); 51 | result = result1; 52 | dir = dir1; 53 | bi = bi1; 54 | minCorner = loc1; 55 | neg = isMinUpNeg(dir); 56 | moving = isMovingX(dir); 57 | this.enableTransparent = enableTrans; 58 | 59 | } 60 | 61 | public static BlockFace getBlockFace(DataHolder dh, Direction dir) { 62 | 63 | try { 64 | if (dh.md.getMaterial() == Material.FURNACE || dh.md.getMaterial().name().equals("BURNING_FURNACE")) { 65 | // Go eat, then we need south. 66 | // Go south, then face west, ect. 67 | if (dir == Direction.UP_EAST) 68 | return BlockFace.SOUTH; 69 | if (dir == Direction.UP_SOUTH) 70 | return BlockFace.WEST; 71 | if (dir == Direction.UP_WEST) 72 | return BlockFace.NORTH; 73 | if (dir == Direction.UP_NORTH) 74 | return BlockFace.EAST; 75 | } 76 | if (dh.md.getMaterial() == Material.DISPENSER) { 77 | // Go eat, then we need south. 78 | // Go south, then face west, ect. 79 | if (dir == Direction.UP_EAST) 80 | return BlockFace.SOUTH; 81 | if (dir == Direction.UP_SOUTH) 82 | return BlockFace.WEST; 83 | if (dir == Direction.UP_WEST) 84 | return BlockFace.NORTH; 85 | if (dir == Direction.UP_NORTH) 86 | return BlockFace.EAST; 87 | 88 | } 89 | 90 | if (dh.md.getMaterial() == Material.OBSERVER) { 91 | if (dh.md.getDirection() == ImageRelativeBlockDirection.FRONT) { 92 | if (dir == Direction.UP_EAST) 93 | return BlockFace.SOUTH; 94 | if (dir == Direction.UP_SOUTH) 95 | return BlockFace.WEST; 96 | if (dir == Direction.UP_WEST) 97 | return BlockFace.NORTH; 98 | if (dir == Direction.UP_NORTH) 99 | return BlockFace.EAST; 100 | } 101 | 102 | if (dh.md.getDirection() == ImageRelativeBlockDirection.BACK) { 103 | // Go eat, then we need south. 104 | // Go south, then face west, ect. 105 | if (dir == Direction.UP_EAST) 106 | return BlockFace.NORTH; 107 | if (dir == Direction.UP_SOUTH) 108 | return BlockFace.EAST; 109 | if (dir == Direction.UP_WEST) 110 | return BlockFace.SOUTH; 111 | if (dir == Direction.UP_NORTH) 112 | return BlockFace.WEST; 113 | } 114 | 115 | if (dh.md.getDirection() == ImageRelativeBlockDirection.SIDE) { 116 | // Go eat, then we need south. 117 | // Go south, then face west, ect. 118 | if (dir == Direction.UP_EAST) 119 | return BlockFace.EAST; 120 | if (dir == Direction.UP_SOUTH) 121 | return BlockFace.SOUTH; 122 | if (dir == Direction.UP_WEST) 123 | return BlockFace.WEST; 124 | if (dir == Direction.UP_NORTH) 125 | return BlockFace.NORTH; 126 | } 127 | } 128 | } catch (Error | Exception e54) { 129 | } 130 | return null; 131 | } 132 | 133 | public static byte getBlockData(DataHolder dh, Direction dir) { 134 | 135 | try { 136 | if (dh.md.getMaterial().name().endsWith("_DOOR") && !dh.md.getMaterial().name().contains("TRAP")) { 137 | // org.bukkit.material.Door door = (org.bukkit.material.Door) 138 | // bs.getData(); 139 | if (dir == Direction.UP_NORTH) 140 | return ((byte) 2); 141 | if (dir == Direction.UP_EAST) 142 | return ((byte) 3); 143 | if (dir == Direction.UP_SOUTH) 144 | return ((byte) 0); 145 | if (dir == Direction.UP_WEST) 146 | return ((byte) 1); 147 | } 148 | if (dh.md.getMaterial() == Material.FURNACE || dh.md.getMaterial().name().equals("BURNING_FURNACE")) { 149 | // Go eat, then we need south. 150 | // Go south, then face west, ect. 151 | if (dir == Direction.UP_NORTH) 152 | return ((byte) 5); 153 | if (dir == Direction.UP_EAST) 154 | return ((byte) 3); 155 | if (dir == Direction.UP_SOUTH) 156 | return ((byte) 4); 157 | if (dir == Direction.UP_WEST) 158 | return ((byte) 2); 159 | } 160 | 161 | if (dh.md.getMaterial() == Material.DISPENSER) { 162 | // Go eat, then we need south. 163 | // Go south, then face west, ect. 164 | if (dir == Direction.UP_NORTH) 165 | return ((byte) 5); 166 | if (dir == Direction.UP_EAST) 167 | return ((byte) 3); 168 | if (dir == Direction.UP_SOUTH) 169 | return ((byte) 4); 170 | if (dir == Direction.UP_WEST) 171 | return ((byte) 2); 172 | 173 | } 174 | if (dh.md.getMaterial().name().equals("PISTON_BASE") 175 | || dh.md.getMaterial().name().equals("PISTON_STICKY_BASE")) { 176 | if (dh.md.getDirection() == ImageRelativeBlockDirection.TOP) { 177 | if (dir == Direction.UP_NORTH) 178 | return ((byte) 5); 179 | if (dir == Direction.UP_EAST) 180 | return ((byte) 3); 181 | if (dir == Direction.UP_SOUTH) 182 | return ((byte) 4); 183 | if (dir == Direction.UP_WEST) 184 | return ((byte) 2); 185 | } 186 | if (dh.md.getDirection() == ImageRelativeBlockDirection.BACK) { 187 | if (dir == Direction.UP_NORTH) 188 | return ((byte) 4); 189 | if (dir == Direction.UP_EAST) 190 | return ((byte) 2); 191 | if (dir == Direction.UP_SOUTH) 192 | return ((byte) 5); 193 | if (dir == Direction.UP_WEST) 194 | return ((byte) 3); 195 | } 196 | } 197 | if (dh.md.getMaterial() == Material.PUMPKIN || dh.md.getMaterial() == Material.JACK_O_LANTERN) { 198 | if (dh.md.getDirection() == ImageRelativeBlockDirection.FRONT) { 199 | // Go eat, then we need south. 200 | // Go south, then face west, ect. 201 | if (dir == Direction.UP_NORTH) 202 | return ((byte) 3); 203 | if (dir == Direction.UP_EAST) 204 | return ((byte) 0); 205 | if (dir == Direction.UP_SOUTH) 206 | return ((byte) 1); 207 | if (dir == Direction.UP_WEST) 208 | return ((byte) 2); 209 | } 210 | 211 | if (dh.md.getDirection() == ImageRelativeBlockDirection.BACK) { 212 | if (dir == Direction.UP_NORTH) 213 | return ((byte) 0); 214 | if (dir == Direction.UP_EAST) 215 | return ((byte) 3); 216 | if (dir == Direction.UP_SOUTH) 217 | return ((byte) 2); 218 | if (dir == Direction.UP_WEST) 219 | return ((byte) 1); 220 | } 221 | 222 | } 223 | 224 | if (dh.md.getMaterial() == Material.OBSERVER) { 225 | if (dh.md.getDirection() == ImageRelativeBlockDirection.FRONT) { 226 | // Go eat, then we need south. 227 | // Go south, then face west, ect. 228 | if (dir == Direction.UP_NORTH) 229 | return ((byte) 4); 230 | if (dir == Direction.UP_EAST) 231 | return ((byte) 2); 232 | if (dir == Direction.UP_SOUTH) 233 | return ((byte) 5); 234 | if (dir == Direction.UP_WEST) 235 | return ((byte) 3); 236 | 237 | } 238 | 239 | if (dh.md.getDirection() == ImageRelativeBlockDirection.BACK) { 240 | // Go eat, then we need south. 241 | // Go south, then face west, ect. 242 | if (dir == Direction.UP_NORTH) 243 | return ((byte) 5); 244 | if (dir == Direction.UP_EAST) 245 | return ((byte) 3); 246 | if (dir == Direction.UP_SOUTH) 247 | return ((byte) 4); 248 | if (dir == Direction.UP_WEST) 249 | return ((byte) 2); 250 | } 251 | 252 | if (dh.md.getDirection() == ImageRelativeBlockDirection.SIDE) { 253 | // Go eat, then we need south. 254 | // Go south, then face west, ect. 255 | if (dir == Direction.UP_NORTH) 256 | return ((byte) 3); 257 | if (dir == Direction.UP_EAST) 258 | return ((byte) 5); 259 | if (dir == Direction.UP_SOUTH) 260 | return ((byte) 2); 261 | if (dir == Direction.UP_WEST) 262 | return ((byte) 4); 263 | } 264 | 265 | } 266 | } catch (Error | Exception e54) { 267 | } 268 | return dh.md.getData(); 269 | } 270 | 271 | @SuppressWarnings("deprecation") 272 | public void loadImage(boolean allowUndo) { 273 | final IntHolder isDone = new IntHolder(); 274 | isDone.setI(0); 275 | for (Player p2 : minCorner.getWorld().getPlayers()) 276 | p2.sendMessage(PixelPrinter.getInstance().getPrefix() + " Loading image requested by " + p); 277 | Location start = getBlockAt(0, bi.getHeight(), bi.getHeight()); 278 | Location end = getBlockAt(0, 0, bi.getHeight()); 279 | UndoUtil.addNewSnapshot(name, start, end); 280 | 281 | new BukkitRunnable() { 282 | public void run() { 283 | final HashMap> chunksorter = new HashMap>(); 284 | 285 | for (int width = 0; width < (bi.getWidth()); width += 2) { 286 | for (int height = (bi.getHeight() - 1); height >= 0; height -= 2) { 287 | Location b = getBlockAt(height, width, bi.getHeight()); 288 | if (b == null || b.getBlockY() > 255) { 289 | continue; 290 | } 291 | Color[] color = new Color[4]; 292 | for (int i = 0; i < 4; i++) { 293 | int y = (height + 1 < result.length) ? height + (i % 2) : height; 294 | int x = (width + 1 < result[y].length) ? width + (i % 2) : width; 295 | color[i] = new Color(result[y][x].r, result[y][x].g, result[y][x].b, result[y][x].a); 296 | } 297 | MaterialData m = RGBBlockColor.getClosestBlockValue(color, 298 | (dir == Direction.FLAT_NORTHEAST || dir == Direction.FLAT_NORTHWEST 299 | || dir == Direction.FLAT_SOUTHEAST || dir == Direction.FLAT_SOUTHWEST), 300 | enableTransparent, PixelPrinter.getInstance().supportedMaterials); 301 | String tempkey = (b.getBlockX() / 16) + "," + (b.getBlockZ() / 16); 302 | if (chunksorter.containsKey(tempkey)) { 303 | List temp = chunksorter.get(tempkey); 304 | if (temp == null) 305 | temp = new ArrayList(); 306 | temp.add(new DataHolder(b, m, m.hasDirection())); 307 | chunksorter.put(tempkey, temp); 308 | } else { 309 | List temp = new ArrayList(); 310 | temp.add(new DataHolder(b, m)); 311 | chunksorter.put(tempkey, temp); 312 | } 313 | } 314 | } 315 | int delayLoadingMessage = 0; 316 | final int maxDelay = 7; 317 | int timesTicked = 0; 318 | 319 | final IntHolder blocksUpdated = new IntHolder(); 320 | final BoolHolder hadToReplace = new BoolHolder(); 321 | 322 | for (Entry> ent : chunksorter.entrySet()) { 323 | final List gg = ent.getValue(); 324 | timesTicked++; 325 | final int tempDel = delayLoadingMessage++; 326 | delayLoadingMessage %= maxDelay; 327 | final int currTick = timesTicked; 328 | 329 | new BukkitRunnable() { 330 | @Override 331 | public void run() { 332 | for (final DataHolder dh : gg) { 333 | final BlockState bs = dh.b.getBlock().getState(); 334 | 335 | if (dh.md.getMaterial() != Material.AIR) { 336 | 337 | byte rd = dh.md.getData(); 338 | BlockFace bf = null; 339 | 340 | if (dh.hasFaces()) { 341 | bf = getBlockFace(dh, dir); 342 | rd = getBlockData(dh, dir); 343 | } 344 | 345 | if (dh.md.getMaterial() != bs.getType() 346 | || (!PixelPrinter.isAbove113 && ((int) bs.getRawData()) != ((int) rd)) || (PixelPrinter.isAbove113 && bf != Update13Handler.getFacing(bs))){ 347 | hadToReplace.setB(true); 348 | blocksUpdated.setI(blocksUpdated.getI() + 1); 349 | 350 | if (PixelPrinter.isAbove113) { 351 | bs.getBlock().setType(dh.md.getMaterial()); 352 | bs.setType(dh.md.getMaterial()); 353 | if (bf != null) { 354 | Update13Handler.setFacing(bs, bf); 355 | } 356 | } else { 357 | bs.setType(dh.md.getMaterial()); 358 | if (bs.getRawData() != rd) 359 | bs.setRawData(rd); 360 | bs.update(true, false); 361 | } 362 | if (dh.md.getMaterial().hasGravity()) { 363 | Block below = bs.getBlock().getLocation().subtract(0, 1, 0).getBlock(); 364 | if (below.getType() == Material.AIR) 365 | below.setType(Material.STONE); 366 | } 367 | final BlockFace bf2 = bf; 368 | new BukkitRunnable() { 369 | 370 | @Override 371 | public void run() { 372 | boolean tryBoolean = Update13Handler.isFacing(bs, bf2); 373 | 374 | if (bs.getBlock().getType() != dh.md.getMaterial() 375 | || ((bf2 != null) ? (!tryBoolean) 376 | : (!PixelPrinter.isAbove113 && bs.getBlock().getData() != dh.md.getData())) 377 | || bs.getBlock().getType() == Material.AIR) { 378 | if (bs.getBlock().getType().name().equals("VOID_AIR")) 379 | return; 380 | BlockFace test = null; 381 | if (Update13Handler.isDirectional(bs.getBlock().getState())) { 382 | test = Update13Handler.getFacing(bs.getBlock().getState()); 383 | } 384 | for (Player p2 : minCorner.getWorld().getPlayers()) { 385 | p2.sendMessage(PixelPrinter.getInstance().getPrefix() 386 | + "Incorrect value: " + dh.md.getMaterial().name() + ":" 387 | + ((bf2 != null) ? bf2.name() : dh.md.getData()) 388 | + " is " + bs.getBlock().getType() + ":" 389 | + (test != null ? test.name() : bs.getBlock().getData()) 390 | + " at " + bs.getBlock().getLocation().getBlockX() + "," 391 | + bs.getBlock().getLocation().getBlockY() + "," 392 | + bs.getBlock().getLocation().getBlockZ()); 393 | } 394 | } 395 | cancel(); 396 | } 397 | }.runTaskLater(PixelPrinter.getInstance(), 20); 398 | } 399 | } 400 | } 401 | if (tempDel == 0) 402 | for (Player p2 : minCorner.getWorld().getPlayers()) 403 | p2.sendMessage(PixelPrinter.getInstance().getPrefix() + " Loading: " 404 | + ((int) (((double) currTick) / chunksorter.size() * 100)) + "%"); 405 | 406 | cancel(); 407 | } 408 | }.runTaskLater(PixelPrinter.getInstance(), 3 * timesTicked); 409 | 410 | } 411 | 412 | new BukkitRunnable() { 413 | @Override 414 | public void run() { 415 | for (Player p2 : minCorner.getWorld().getPlayers()) { 416 | p2.sendMessage(PixelPrinter.getInstance().getPrefix() + " Done!" 417 | + (hadToReplace.getB() ? " Updated " + blocksUpdated.getI() + " blocks." 418 | : "")); 419 | } 420 | cancel(); 421 | } 422 | }.runTaskLater(PixelPrinter.getInstance(), 3 * timesTicked); 423 | cancel(); 424 | } 425 | }.runTaskAsynchronously(PixelPrinter.getInstance()); 426 | } 427 | } 428 | -------------------------------------------------------------------------------- /src/me/zombie_striker/pixelprinter/util/BlockTypeSnapshot.java: -------------------------------------------------------------------------------- 1 | package me.zombie_striker.pixelprinter.util; 2 | 3 | import org.bukkit.Location; 4 | import org.bukkit.World; 5 | import org.bukkit.block.Block; 6 | import org.bukkit.block.BlockState; 7 | 8 | import java.util.HashMap; 9 | import java.util.Map.Entry; 10 | 11 | public class BlockTypeSnapshot { 12 | 13 | public HashMap originalBlockState = new HashMap<>(); 14 | 15 | public BlockTypeSnapshot(Location start, Location stop) { 16 | World world = start.getWorld(); 17 | for (int x = Math.min(start.getBlockX(), stop.getBlockX()); x < Math.max(start.getBlockX(), stop.getBlockX()) 18 | + 1; x++) { 19 | for (int y = Math.min(start.getBlockY(), stop.getBlockY()); y < Math.min(256, 20 | Math.max(start.getBlockY(), stop.getBlockY())) + 1; y++) { 21 | for (int z = Math.min(start.getBlockZ(), stop.getBlockZ()); z < Math.max(start.getBlockZ(), 22 | stop.getBlockZ()) + 1; z++) { 23 | Block b = world.getBlockAt(x, y, z); 24 | originalBlockState.put(b.getLocation(), b.getState().getRawData()); 25 | } 26 | } 27 | } 28 | } 29 | 30 | public void undo() { 31 | HashMap newOnes = new HashMap<>(); 32 | for (Entry e : originalBlockState.entrySet()) { 33 | if (!e.getKey().getBlock().getState().equals(e.getValue())) { 34 | newOnes.put(e.getKey(), e.getKey().getBlock().getState().getRawData()); 35 | BlockState state = e.getKey().getBlock().getState(); 36 | state.setRawData(e.getValue()); 37 | state.update(true,false); 38 | // e.getValue().update(true, false); 39 | } 40 | } 41 | this.originalBlockState = newOnes; 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /src/me/zombie_striker/pixelprinter/util/CustomImageRenderer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2016 Zombie_Striker 3 | * 4 | * This program is free software; you can redistribute it and/or modify it under the terms of the 5 | * GNU General Public License as published by the Free Software Foundation; either version 2 of 6 | * the License, or (at your option) any later version. 7 | * 8 | * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 9 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 10 | * See the GNU General Public License for more details. 11 | * 12 | * You should have received a copy of the GNU General Public License along with this program; 13 | * if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 14 | * 02111-1307 USA 15 | */ 16 | package me.zombie_striker.pixelprinter.util; 17 | 18 | import org.bukkit.entity.Player; 19 | import org.bukkit.map.MapCanvas; 20 | import org.bukkit.map.MapRenderer; 21 | import org.bukkit.map.MapView; 22 | 23 | import java.awt.image.BufferedImage; 24 | 25 | public class CustomImageRenderer extends MapRenderer { 26 | 27 | public static int TICK_FOR_STILLS = 500; 28 | private BufferedImage[] image; 29 | private int frameCount = 0; 30 | 31 | public CustomImageRenderer(BufferedImage[] bi, int ticks) { 32 | super(true); 33 | this.image = bi; 34 | } 35 | 36 | public CustomImageRenderer(BufferedImage bi, int ticks) { 37 | super(true); 38 | this.image = new BufferedImage[1]; 39 | image[0] = bi; 40 | } 41 | 42 | // maps update multiple times per second. 43 | // for still images, set ticks to 100; 44 | @Override 45 | public void render(MapView view, MapCanvas canvas, Player player) { 46 | if (image != null && image[frameCount] != null) 47 | canvas.drawImage(0, 0, image[frameCount]); 48 | frameCount = (frameCount + 1);// % image.length; 49 | if (frameCount >= image.length) 50 | frameCount = 0; 51 | } 52 | 53 | } 54 | -------------------------------------------------------------------------------- /src/me/zombie_striker/pixelprinter/util/FileNameToMaterialUtil.java: -------------------------------------------------------------------------------- 1 | package me.zombie_striker.pixelprinter.util; 2 | 3 | import me.zombie_striker.pixelprinter.data.ImageRelativeBlockDirection; 4 | import me.zombie_striker.pixelprinter.data.MaterialData; 5 | import org.bukkit.Bukkit; 6 | import org.bukkit.DyeColor; 7 | import org.bukkit.Material; 8 | import org.bukkit.block.BlockFace; 9 | 10 | public class FileNameToMaterialUtil { 11 | 12 | @SuppressWarnings("deprecation") 13 | public static MaterialData getMaterialData(String filename) { 14 | byte b = 0; 15 | String m = filename; 16 | boolean isOnlyTop = false; 17 | 18 | ImageRelativeBlockDirection facing = null; 19 | 20 | if (filename.equalsIgnoreCase("end_rod") || filename.equalsIgnoreCase("ice") 21 | || filename.equalsIgnoreCase("vine") || filename.equalsIgnoreCase("web") 22 | || filename.equalsIgnoreCase("CHORUS_PLANT") || filename.equalsIgnoreCase("flower_pot") 23 | || filename.equalsIgnoreCase("glass") || filename.equalsIgnoreCase("ladder") 24 | || filename.equalsIgnoreCase("iron_trapdoor") || filename.equalsIgnoreCase("TRAP_DOOR") 25 | || filename.equalsIgnoreCase("MOB_SPAWNER") || filename.equalsIgnoreCase("WATER") 26 | || filename.equalsIgnoreCase("ENDER_PORTAL") || filename.equalsIgnoreCase("ANVIL") 27 | || filename.equalsIgnoreCase("LAVA") || filename.equalsIgnoreCase("WATER_LILY") 28 | || filename.contains("_door") || filename.equalsIgnoreCase("BEETROOT") 29 | || filename.equalsIgnoreCase("BREWING_STAND") || filename.equalsIgnoreCase("carrot") 30 | || filename.equalsIgnoreCase("deadbush") || filename.equalsIgnoreCase("DRAGON_EGG") 31 | || filename.equalsIgnoreCase("fern") || filename.equalsIgnoreCase("iron_bars") 32 | || filename.equalsIgnoreCase("potatoes") || filename.equals("rail") || filename.contains("_rail") 33 | || filename.equalsIgnoreCase("reeds") || filename.equalsIgnoreCase("redstone_torch") 34 | || filename.equalsIgnoreCase("redstone") || filename.equalsIgnoreCase("trip_wire") 35 | || filename.equalsIgnoreCase("MONSTER_EGG") || filename.equalsIgnoreCase("LEVER") 36 | || filename.equalsIgnoreCase("BROWN_MUSHROOM") || filename.equalsIgnoreCase("RED_MUSHROOM") 37 | || filename.equalsIgnoreCase("TORCH") || filename.equalsIgnoreCase("SUGAR_CANE") 38 | || filename.equalsIgnoreCase("PUMPKIN_STEM") || filename.equalsIgnoreCase("PORTAL") 39 | || filename.equalsIgnoreCase("MELON_STEM") || filename.equalsIgnoreCase("CHORUS_FLOWER") 40 | || filename.equalsIgnoreCase("DEAD_BUSH") || filename.equalsIgnoreCase("SUGAR_CANE") 41 | || filename.contains("shulker") || filename.endsWith("sapling") || filename.equals("tripwire") || filename.equals("lecturn") 42 | 43 | 44 | || filename.startsWith("bell") || filename.startsWith("anvil") || filename.startsWith("cactus") 45 | 46 | || filename.equalsIgnoreCase("crimson_fungi") || filename.equalsIgnoreCase("crimson_roots") || 47 | filename.equalsIgnoreCase("crimson_stem") || filename.equalsIgnoreCase("nether_sprouts") || 48 | filename.equalsIgnoreCase("soul_fire_lantern") || filename.equalsIgnoreCase("soul_fire_torch") || 49 | filename.equalsIgnoreCase("warped_fungi") || filename.equalsIgnoreCase("warped_roots") || 50 | filename.equalsIgnoreCase("weeping_vines")||filename.equals("soul_lantern")||filename.equals("soul_torch") 51 | 52 | || filename.equals("tripwire_hook") || filename.equals("tripwire_hook") || filename.equals("iron_block") 53 | || filename.equals("snow") || filename.equals("beacon") || filename.equals("cobweb") 54 | || filename.equals("dandelion") || filename.equals("wither_rose") || filename.equals("cornflower") || filename.equals("lily_of_the_valley") || filename.equals("comparator") || filename.equals("conduit") 55 | || filename.equals("repeater") || filename.equals("poppy") || filename.equals("white_tulip") 56 | || filename.equals("pink_tulip") || filename.equals("red_tulip") || filename.equals("orange_tulip") 57 | || filename.equals("allium") || filename.equals("azure_bluet") || filename.equals("blue_orchid") 58 | || filename.endsWith("_leaves") || filename.equals("lily_pad") 59 | || filename.equals("attached_pumpkin_stem") || filename.equals("attached_melon_stem") 60 | || filename.equals("kelp_plant") || filename.equals("kelp") 61 | || filename.equals("warped_fungus") || filename.equals("twisted_vines") || filename.equals("twisted_vines_plant") || filename.equals("crimson_roots") || filename.equals("crimson_fungus") || filename.equals("weeping_vines") || filename.equals("warped_roots")|| filename.equals("weeping_vines_plant") 62 | || filename.equals("chain") || filename.equals("tnt_bottom")||filename.equals("tnt_top")||filename.equals("tnt_side") 63 | 64 | || filename.equals("turtle_egg") || filename.contains("coral_fan") || filename.equals("sea_pickle") 65 | || filename.equals("seagrass") || filename.equals("farmland") || filename.equals("oxeye_daisy") 66 | || filename.endsWith("_coral") || filename.startsWith("stonecutter") || filename.startsWith("grindstone") 67 | 68 | || filename.equalsIgnoreCase("lantern") ||filename.equals("grass_block_side") ||filename.equals("mycelium_side")||filename.startsWith("sunflower_") 69 | 70 | ||filename.equals("scaffolding_side") || filename.startsWith("grass_path_")|| filename.equals("cake_side") || m.equals("daylight_detector_side") || filename.equals("enchanting_table_side")||filename.equals("end_portal_frame_side") 71 | 72 | ||filename.equals("jigsaw_side") ||filename.equals("structure_block")) { 73 | return null; 74 | } 75 | 76 | if(filename.equals("smooth_stone_slab_side")){ 77 | return null; 78 | } 79 | 80 | if (m.endsWith("_front")) { 81 | m = m.split("_front")[0]; 82 | facing = ImageRelativeBlockDirection.FRONT; 83 | }else if (m.endsWith("_top")) { 84 | m = m.split("_top")[0]; 85 | facing = ImageRelativeBlockDirection.TOP; 86 | }else if (m.endsWith("_side")) { 87 | m = m.split("_side")[0]; 88 | facing = ImageRelativeBlockDirection.SIDE; 89 | }else if (m.endsWith("_back")) { 90 | m = m.split("_back")[0]; 91 | facing = ImageRelativeBlockDirection.BACK; 92 | }else if(m.endsWith("_bottom")){ 93 | m=m.split("_bottom")[0]; 94 | facing = ImageRelativeBlockDirection.BOTTOM; 95 | } 96 | 97 | if(m.equals("bell") ) 98 | return null; 99 | 100 | if (Material.matchMaterial(m) != null) { 101 | if (ReflectionUtil.isVersionHigherThan(1, 16)) { 102 | if(m.endsWith("_log")) 103 | m=m.split("_log")[0].toUpperCase()+"_WOOD"; 104 | if(filename.equals("crimson_stem")) 105 | m="CRIMSON_HYPHAE"; 106 | if(filename.equals("warped_stem")) 107 | m="WARPED_HYPHAE"; 108 | if(filename.equals("crimson_stem_top")) { 109 | m = "CRIMSON_STEM"; 110 | facing = ImageRelativeBlockDirection.TOP; 111 | } 112 | if(filename.equals("warped_stem_top")) { 113 | m = "WARPED_STEM"; 114 | facing = ImageRelativeBlockDirection.TOP; 115 | } 116 | if(filename.equals("crimson_nylium")) { 117 | m = "crimson_nylium"; 118 | facing = ImageRelativeBlockDirection.TOP; 119 | isOnlyTop = true; 120 | } 121 | if(filename.equals("crimson_nylium_side")) { 122 | return null; 123 | } 124 | if(filename.equals("warped_nylium")) { 125 | m = "warped_nylium"; 126 | facing = ImageRelativeBlockDirection.TOP; 127 | isOnlyTop = true; 128 | } 129 | if(filename.equals("warped_nylium_side")) { 130 | return null; 131 | } 132 | } 133 | if(filename.equals("dried_kelp")){ 134 | m = "DRIED_KELP_BLOCK"; 135 | } 136 | if(filename.equals("dried_kelp_top")){ 137 | m = "DRIED_KELP_BLOCK"; 138 | facing = ImageRelativeBlockDirection.TOP; 139 | } 140 | if (filename.equalsIgnoreCase("snow")) { 141 | m = "SNOW_BLOCK"; 142 | } 143 | if (ReflectionUtil.isVersionHigherThan(1, 13)) { 144 | 145 | if (filename.endsWith("coral_block") && !filename.startsWith("dead")) 146 | return null; 147 | // TODO: Figure out ways to keep coral alive without water. 148 | 149 | if (filename.equalsIgnoreCase("mycelium")) 150 | return null; 151 | if (filename.equals("redstone_torch_off")) 152 | return null; 153 | if (filename.equals("redstone_lamp_off")) 154 | return null; 155 | if (filename.equals("redstone_lamp_on")) 156 | return null; 157 | if (filename.equals("grass")) 158 | return null; 159 | if (filename.contains("_trapdoor")) 160 | return null; 161 | if (filename.contains("_stained_glass")) 162 | return null; 163 | if (filename.equals("spawner")) 164 | return null; 165 | } 166 | if (!Material.matchMaterial(m).isBlock()) 167 | return null; 168 | }else { 169 | if (ReflectionUtil.isVersionHigherThan(1, 14)) { 170 | 171 | if (filename.equalsIgnoreCase("smithing_table_side")) { 172 | m = "SMITHING_TABLE"; 173 | } else if (filename.equalsIgnoreCase("blast_furnace_front")) { 174 | m = "BLAST_FURNACE"; 175 | facing = ImageRelativeBlockDirection.FRONT; 176 | } else if (filename.equalsIgnoreCase("blast_furnace_side")) { 177 | m = "BLAST_FURNACE"; 178 | facing = ImageRelativeBlockDirection.SIDE; 179 | } else if (filename.equalsIgnoreCase("smoker_front")) { 180 | m = "SMOKER"; 181 | facing = ImageRelativeBlockDirection.FRONT; 182 | } else if (filename.equalsIgnoreCase("smoker_side")) { 183 | m = "SMOKER"; 184 | facing = ImageRelativeBlockDirection.SIDE; 185 | } else if (filename.equals("composter_side")) { 186 | m = "COMPOSTER"; 187 | } 188 | } 189 | 190 | // 1.13 code. 191 | if (ReflectionUtil.isVersionHigherThan(1, 13)) { 192 | if (filename.equalsIgnoreCase("barrel_side")) { 193 | m = "BARREL"; 194 | } else if (filename.equalsIgnoreCase("acacia_planks")) { 195 | m = "ACACIA_WOOD"; 196 | } else if (filename.equalsIgnoreCase("birtch_planks")) { 197 | m = "BIRTCH_WOOD"; 198 | } else if (filename.equalsIgnoreCase("oak_planks")) { 199 | m = "OAK_WOOD"; 200 | } else if (filename.equalsIgnoreCase("dark_oak_planks")) { 201 | m = "DARK_OAK_WOOD"; 202 | } else if (filename.equalsIgnoreCase("spruce_planks")) { 203 | m = "SPRUCE_WOOD"; 204 | } else if (filename.equalsIgnoreCase("jungle_planks")) { 205 | m = "JUNGLE_WOOD"; 206 | } else if (filename.equalsIgnoreCase("chain_command_block_front")) { 207 | m = "CHAIN_COMMAND_BLOCK"; 208 | } else if (filename.equalsIgnoreCase("command_block_front")) { 209 | m = "COMMAND_BLOCK"; 210 | } else if (filename.equalsIgnoreCase("crafting_table_side")) { 211 | m = "CRAFTING_TABLE"; 212 | } else if (filename.equalsIgnoreCase("dispenser_front")) { 213 | m = "DISPENCER"; 214 | facing = ImageRelativeBlockDirection.FRONT; 215 | } else if (filename.equalsIgnoreCase("dried_kelp_side")) { 216 | m = "DRIED_KELP_BLOCK"; 217 | } else if (filename.equalsIgnoreCase("frosted_ice_0")) { 218 | m = "FROSTED_ICE"; 219 | } else if (filename.equalsIgnoreCase("iron_block")) { 220 | m = "IRON_BLOCK"; 221 | } else if (filename.equalsIgnoreCase("magma")) { 222 | m = "MAGMA_BLOCK"; 223 | } else if (filename.equalsIgnoreCase("melon_side")) { 224 | m = "MELON"; 225 | } else if (filename.equalsIgnoreCase("repeating_command_block_front")) { 226 | m = "REPEATING_COMMAND_BLOCK"; 227 | } else if (filename.equalsIgnoreCase("sandstone_top")) { 228 | m = "SMOOTH_SANDSTONE"; 229 | } else if (filename.equalsIgnoreCase("red_sandstone_top")) { 230 | m = "SMOOTH_RED_SANDSTONE"; 231 | } else if (filename.equalsIgnoreCase("stone_slab_top")) { 232 | m = "SMOOTH_STONE"; 233 | } 234 | } 235 | if (filename.equalsIgnoreCase("bone_block_side")) { 236 | m = "BONE_BLOCK"; 237 | } else if (filename.equalsIgnoreCase("pumpkin_face_on")) { 238 | m = "JACK_O_LANTERN"; 239 | facing =ImageRelativeBlockDirection.FRONT; 240 | } else if (filename.equalsIgnoreCase("pumpkin_face")) { 241 | m = "PUMPKIN"; 242 | facing = ImageRelativeBlockDirection.FRONT; 243 | } else if (filename.equalsIgnoreCase("cobblestone_mossy")) { 244 | m = "MOSSY_COBBLESTONE"; 245 | } else if (filename.equalsIgnoreCase("pumpkin_side")) { 246 | m = "PUMPKIN"; 247 | facing = ImageRelativeBlockDirection.BACK; 248 | } else if (filename.equalsIgnoreCase("dispenser_front")) { 249 | m = "DISPENCER"; 250 | facing = ImageRelativeBlockDirection.FRONT; 251 | } else if (filename.equalsIgnoreCase("furnace_front")) { 252 | m = "FURNACE"; 253 | facing = ImageRelativeBlockDirection.FRONT; 254 | } else if (filename.equalsIgnoreCase("furnace_front_on")) { 255 | if (ReflectionUtil.isVersionHigherThan(1, 13)) 256 | return null; 257 | m = "BURNING_FURNACE"; 258 | facing =ImageRelativeBlockDirection.FRONT; 259 | } else if (filename.equalsIgnoreCase("observer_back")) { 260 | m = "OBSERVER"; 261 | facing = ImageRelativeBlockDirection.BACK; 262 | } else if (filename.equalsIgnoreCase("observer_back_on")) { 263 | return null; 264 | } else if (filename.equalsIgnoreCase("observer_top")) { 265 | m = "OBSERVER"; 266 | facing = ImageRelativeBlockDirection.TOP; 267 | } else if (filename.equalsIgnoreCase("observer_side")) { 268 | m = "OBSERVER"; 269 | facing = ImageRelativeBlockDirection.SIDE; 270 | } else if (filename.equalsIgnoreCase("observer_front")) { 271 | m = "OBSERVER"; 272 | facing = ImageRelativeBlockDirection.FRONT; 273 | } else if (filename.equalsIgnoreCase("piston_top")) { 274 | m = "PISTON_BASE"; 275 | facing = ImageRelativeBlockDirection.FRONT; 276 | } else if (filename.equalsIgnoreCase("piston_top_sticky")) { 277 | m = "PISTON_STICKY_BASE"; 278 | facing = ImageRelativeBlockDirection.FRONT; 279 | } else if (filename.equalsIgnoreCase("piston_bottom")) { 280 | m = "PISTON_BASE"; 281 | facing = ImageRelativeBlockDirection.BACK; 282 | 283 | } else if (filename.equalsIgnoreCase("repeating_command_block_front")) { 284 | m = "COMMAND_REPEATING"; 285 | } else if (filename.equalsIgnoreCase("command_block_front")) { 286 | m = "COMMAND"; 287 | } else if (filename.equalsIgnoreCase("chain_command_block_front")) { 288 | m = "COMMAND_CHAIN"; 289 | } else if (filename.equalsIgnoreCase("crafting_table_front")) { 290 | m = "WORKBENCH"; 291 | } else if (filename.contains("concrete_") && (!filename.contains("powd"))) { 292 | m = "CONCRETE"; 293 | b = DyeColor.valueOf(filename.split("concrete_")[1].toUpperCase()).getWoolData(); 294 | 295 | } else if (filename.equalsIgnoreCase("end_stone")) { 296 | m = "ENDER_STONE"; 297 | 298 | } else if (filename.equalsIgnoreCase("frosted_ice_0")) { 299 | m = "PACKED_ICE"; 300 | } else if (filename.equalsIgnoreCase("furnace_side")) { 301 | m = "FURNACE"; 302 | } else if (filename.contains("glazed_terracotta")) { 303 | try { 304 | m = filename.split("glazed_terracotta_")[1] + "_glazed_terracotta"; 305 | } catch (Error | Exception e3) { 306 | try { 307 | m = Material.matchMaterial(filename).name(); 308 | m.length(); 309 | } catch (Error | Exception er532) { 310 | m = Material.WHITE_GLAZED_TERRACOTTA.name(); 311 | Bukkit.broadcastMessage("THIS VALUE NEEDS TO BE CORRECTED. == " + filename); 312 | } 313 | } 314 | } else if (filename.contains("hardened_clay_stained")) { 315 | m = "STAINED_CLAY"; 316 | b = DyeColor.valueOf(filename.split("hardened_clay_stained_")[1].toUpperCase()).getWoolData(); 317 | } else if (filename.equalsIgnoreCase("hardened_clay")) { 318 | m = "HARD_CLAY"; 319 | } else if (filename.equalsIgnoreCase("hay_block_side")) { 320 | m = "HAY_BLOCK"; 321 | } else if (filename.contains("log_")) { 322 | if (filename.contains("stripped")) { 323 | 324 | } else { 325 | if (filename.contains("big_oak") || filename.contains("acacia")) { 326 | m = "LOG_2"; 327 | if (filename.contains("acacia")) { 328 | b = 12; 329 | } else { 330 | b = 13; 331 | } 332 | } else { 333 | m = "LOG"; 334 | if (filename.contains("oak")) { 335 | b = 12; 336 | } else if (filename.contains("spru")) { 337 | b = 13; 338 | } else if (filename.contains("bir")) { 339 | b = 14; 340 | } else { 341 | b = 15; 342 | } 343 | 344 | } 345 | } 346 | 347 | } else if (filename.equalsIgnoreCase("melon_side")) { 348 | m = "MELON_BLOCK"; 349 | } else if (filename.contains("mushroom_block")) { 350 | m = "HUGE_MUSHROOM_" + (filename.contains("red") ? 1 : 2); 351 | if (filename.contains("outside")) 352 | b = 1; 353 | if ((b != 1 || m.contains("1")) && RGBBlockColor.isVersionHigherThan(1, 12)) 354 | m = "Fail"; 355 | } else if (filename.equalsIgnoreCase("mycelium_side")) { 356 | if (ReflectionUtil.isVersionHigherThan(1, 13)) 357 | return null; 358 | // m = "MYCELIUM"; 359 | else 360 | m = "MYCEL"; 361 | } else if (filename.equalsIgnoreCase("noteblock")) { 362 | m = "NOTE_BLOCK"; 363 | } else if (filename.equalsIgnoreCase("piston_side")) { 364 | m = "PISTON_BASE"; 365 | } else if (filename.contains("planks_")) { 366 | m = "WOOD"; 367 | if (filename.contains("big_oak")) { 368 | b = 5; 369 | } else if (filename.contains("acacia")) { 370 | b = 4; 371 | } else if (filename.contains("jungle")) { 372 | b = 3; 373 | } else if (filename.contains("birch")) { 374 | b = 2; 375 | } else if (filename.contains("spruce")) { 376 | b = 1; 377 | } 378 | } else if (filename.contains("prismarine_")) { 379 | m = "PRISMARINE"; 380 | if (filename.contains("bricks")) { 381 | b = 1; 382 | } else if (filename.contains("dark")) { 383 | b = 2; 384 | } 385 | } else if (filename.equalsIgnoreCase("pumpkin_side")) { 386 | m = "PUMKIN"; 387 | } else if (filename.equalsIgnoreCase("quartz_block_side")) { 388 | m = "QUARTZ_BLOCK"; 389 | } else if (filename.equalsIgnoreCase("quartz_block_chiseled")) { 390 | m = "QUARTZ_BLOCK"; 391 | b = 1; 392 | } else if (filename.equalsIgnoreCase("quartz_block_lines")) { 393 | m = "QUARTZ_BLOCK"; 394 | b = 2; 395 | } else if (filename.equalsIgnoreCase("sandstone_normal")) { 396 | m = "SANDSTONE"; 397 | } else if (filename.equalsIgnoreCase("red_sandstone_normal")) { 398 | m = "RED_SANDSTONE"; 399 | } else if (filename.equalsIgnoreCase("redstone_block")) { 400 | m = "REDstone_block"; 401 | } else if (filename.equalsIgnoreCase("slime")) { 402 | m = "SLIME_BLOCK"; 403 | } else if (filename.equalsIgnoreCase("snow")) { 404 | m = "SNOW_BLOCK"; 405 | } else if (filename.equalsIgnoreCase("sponge_wet")) { 406 | m = "SPONGE"; 407 | b = 1; 408 | } else if (filename.equalsIgnoreCase("stone_slab_top")) { 409 | if (ReflectionUtil.isVersionHigherThan(1, 13)) 410 | return null; 411 | m = "DOUBLE_STEP"; 412 | b = 8; 413 | } else if (filename.equals("cobblestone")) { 414 | m = "COBBLESTONE"; 415 | } else if (filename.contains("stonebrick")) { 416 | m = "SMOOTH_BRICK"; 417 | if (filename.contains("mossy")) 418 | b = 1; 419 | if (filename.contains("cracked")) 420 | b = 2; 421 | if (filename.contains("carve")) 422 | b = 3; 423 | } else if ((!filename.contains("redstone")) && filename.contains("stone") && (!filename.contains("glow")) 424 | && (!filename.contains("sandstone")) && (!filename.contains("brick"))) { 425 | m = "stone"; 426 | if (filename.contains("granite")) { 427 | b = 1; 428 | } else if (filename.contains("diorite")) { 429 | b = 3; 430 | } else if (filename.contains("andes")) { 431 | b = 5; 432 | } 433 | 434 | if (filename.contains("smooth")) 435 | b += 1; 436 | } else if (filename.equals("granite")) { 437 | m = "stone"; 438 | b = 1; 439 | } else if (filename.equals("andesite")) { 440 | m = "stone"; 441 | b = 5; 442 | } else if (filename.equals("diorite")) { 443 | m = "stone"; 444 | b = 3; 445 | } else if (filename.contains("polished_")) { 446 | if (filename.contains("granite")) { 447 | b = 2; 448 | } else if (filename.contains("diorite")) { 449 | b = 4; 450 | } else if (filename.contains("andes")) { 451 | b = 6; 452 | } 453 | } else if (filename.contains("wool")) { 454 | m = "WOOL"; 455 | try { 456 | b = DyeColor.valueOf(filename.split("wool_colored_")[1].toUpperCase()).getWoolData(); 457 | } catch (Error | Exception e54t3r25) { 458 | try { 459 | b = DyeColor.valueOf(filename.split("_wool")[0].toUpperCase()).getWoolData(); 460 | } catch (Error | Exception e43) { 461 | Bukkit.broadcastMessage("THIS VALUE NEEDS TO BE CORRECTED. == " + filename); 462 | b = 4; 463 | } 464 | } 465 | } 466 | } 467 | if (Material.matchMaterial(m) == null || Material.matchMaterial(m) == Material.AIR) { 468 | return null; 469 | } 470 | return new MaterialData(Material.getMaterial(m.toUpperCase()), b, facing, isOnlyTop); 471 | } 472 | } 473 | -------------------------------------------------------------------------------- /src/me/zombie_striker/pixelprinter/util/GifHolder.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2017 Zombie_Striker 3 | * 4 | * This program is free software; you can redistribute it and/or modify it under the terms of the 5 | * GNU General Public License as published by the Free Software Foundation; either version 2 of 6 | * the License, or (at your option) any later version. 7 | * 8 | * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 9 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 10 | * See the GNU General Public License for more details. 11 | * 12 | * You should have received a copy of the GNU General Public License along with this program; 13 | * if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 14 | * 02111-1307 USA 15 | */ 16 | package me.zombie_striker.pixelprinter.util; 17 | 18 | import me.zombie_striker.pixelprinter.PixelPrinter; 19 | import me.zombie_striker.pixelprinter.data.DataHolder; 20 | import me.zombie_striker.pixelprinter.data.Direction; 21 | import me.zombie_striker.pixelprinter.data.IntHolder; 22 | import me.zombie_striker.pixelprinter.data.MaterialData; 23 | import me.zombie_striker.pixelprinter.util.RGBBlockColor.Pixel; 24 | import org.bukkit.Bukkit; 25 | import org.bukkit.Location; 26 | import org.bukkit.block.Block; 27 | import org.bukkit.block.BlockFace; 28 | import org.bukkit.block.BlockState; 29 | import org.bukkit.configuration.serialization.ConfigurationSerializable; 30 | import org.bukkit.configuration.serialization.ConfigurationSerialization; 31 | import org.bukkit.scheduler.BukkitRunnable; 32 | 33 | import javax.imageio.IIOImage; 34 | import javax.imageio.ImageIO; 35 | import javax.imageio.ImageReader; 36 | import javax.imageio.stream.ImageInputStream; 37 | import java.awt.*; 38 | import java.awt.image.BufferedImage; 39 | import java.io.File; 40 | import java.io.IOException; 41 | import java.net.URL; 42 | import java.util.List; 43 | import java.util.*; 44 | 45 | public class GifHolder extends Image implements ConfigurationSerializable { 46 | 47 | public static List freeID = new ArrayList(); 48 | private BufferedImage[] frames; 49 | private int currentFrame = 0; 50 | private boolean isFulluLoaded = false; 51 | private DataHolder[][][] materials; 52 | private boolean[][][] isTrans; 53 | private int gifID; 54 | private UUID owner; 55 | private String fileName; 56 | private int height; 57 | 58 | public GifHolder(String filename, Location minLocation, int height, String dir, UUID owner) { 59 | this.dir = Direction.getDir(dir); 60 | this.p = Bukkit.getPlayer(owner) == null ? "null" : Bukkit.getPlayer(owner).getName(); 61 | this.minCorner = minLocation; 62 | this.height = height * 2; 63 | this.fileName = filename; 64 | this.owner = owner; 65 | while (true) { 66 | gifID++; 67 | if (!freeID.contains(gifID)) { 68 | freeID.add(gifID); 69 | break; 70 | } 71 | } 72 | createFrames(new File(PixelPrinter.getInstance().getImageFile() + File.separator + this.fileName), this.height, 73 | owner); 74 | } 75 | 76 | public GifHolder(Map data) { 77 | final Map tempData = data; 78 | this.currentFrame = (int) data.get("currentframe"); 79 | this.fileName = (String) data.get("fileName"); 80 | this.gifID = (int) data.get("gifID"); 81 | this.dir = Direction.getDir((String) data.get("dir")); 82 | freeID.add(gifID); 83 | this.height = (int) data.get("height"); 84 | this.moving = (boolean) data.get("moving"); 85 | this.neg = (boolean) data.get("neg"); 86 | this.owner = UUID.fromString((String) data.get("owner")); 87 | createFrames(new File(PixelPrinter.getInstance().getImageFile() + File.separator + this.fileName), this.height, 88 | owner); 89 | final IntHolder temp = new IntHolder(); 90 | temp.setI(Bukkit.getScheduler().scheduleSyncRepeatingTask(PixelPrinter.getInstance(), new Runnable() { 91 | public void run() { 92 | if (Bukkit.getWorld((String) tempData.get("minCorner.w")) != null) { 93 | minCorner = Bukkit.getWorld((String) tempData.get("minCorner.w")) 94 | .getBlockAt((int) tempData.get("minCorner.x"), (int) tempData.get("minCorner.y"), 95 | (int) tempData.get("minCorner.z")) 96 | .getLocation(); 97 | Bukkit.getScheduler().cancelTask(temp.getI()); 98 | } 99 | } 100 | }, 0, 20)); 101 | final IntHolder temp2 = new IntHolder(); 102 | temp2.setI(Bukkit.getScheduler().scheduleSyncRepeatingTask(PixelPrinter.getInstance(), new Runnable() { 103 | public void run() { 104 | if (minCorner != null && getFrames() != null && getFrames().length > 1) { 105 | init(); 106 | Bukkit.getScheduler().cancelTask(temp2.getI()); 107 | } 108 | } 109 | }, 0, 20)); 110 | } 111 | 112 | public static void registerClass() { 113 | ConfigurationSerialization.registerClass(GifHolder.class); 114 | ConfigurationSerialization.registerClass(DataHolder.class); 115 | } 116 | 117 | public static BufferedImage[] getFrames(File gif, int height) { 118 | ImageInputStream iis = null; 119 | try { 120 | iis = ImageIO.createImageInputStream(gif); 121 | } catch (IOException e) { 122 | e.printStackTrace(); 123 | } 124 | return getFrames(iis, height); 125 | } 126 | 127 | public static BufferedImage[] getFrames(URL gif, int height) { 128 | try { 129 | return getFrames((ImageInputStream) gif.openStream(), height); 130 | } catch (IOException e) { 131 | e.printStackTrace(); 132 | } 133 | return null; 134 | } 135 | 136 | private static BufferedImage[] getFrames(ImageInputStream gif, int height) { 137 | try { 138 | ImageReader reader = ImageIO.getImageReadersByFormatName("gif").next(); 139 | reader.setInput(gif, true); 140 | Iterator iter = reader.readAll(null); 141 | List bii = new ArrayList<>(); 142 | while (iter.hasNext()) { 143 | IIOImage img = iter.next(); 144 | BufferedImage frame = (BufferedImage) img.getRenderedImage(); 145 | frame = RGBBlockColor.resize(frame, (int) (frame.getWidth() * ((double) height) / frame.getHeight()), 146 | height);// .createResizedCopy(frame, 147 | // height, false); 148 | bii.add(frame); 149 | } 150 | gif.flush(); 151 | gif.close(); 152 | Object[] array1 = bii.toArray(); 153 | BufferedImage[] array = new BufferedImage[array1.length]; 154 | for (int i = 0; i < array1.length; i++) { 155 | if (array1[i] instanceof BufferedImage) { 156 | array[i] = (BufferedImage) array1[i]; 157 | } else { 158 | System.out.println("ERROR: Image is not an image."); 159 | } 160 | } 161 | return array; 162 | } catch (Exception e) { 163 | e.printStackTrace(); 164 | } 165 | return null; 166 | } 167 | 168 | public boolean isLoaded() { 169 | return isFulluLoaded; 170 | } 171 | 172 | public void init() { 173 | new BukkitRunnable() { 174 | 175 | @Override 176 | public void run() { 177 | final List holders = new ArrayList<>(); 178 | int fWidth = 0; 179 | int fHeight = 0; 180 | for (int frames = 0; frames < getFrames().length; frames++) { 181 | if (fWidth < getFrame(frames).getWidth() / 2) 182 | fWidth = getFrame(frames).getWidth() / 2; 183 | if (fHeight < getFrame(frames).getHeight() / 2) 184 | fHeight = getFrame(frames).getHeight() / 2; 185 | } 186 | materials = new DataHolder[getFrames().length][fWidth][fHeight]; 187 | isTrans = new boolean[getFrames().length][fWidth][fHeight]; 188 | 189 | for (int frame = 0; frame < getFrames().length; frame++) { 190 | holders.clear(); 191 | 192 | final BufferedImage bi = getFrames()[frame]; 193 | final Pixel[][] result = RGBBlockColor.convertTo2DWithoutUsingGetRGB(bi); 194 | 195 | for (int width = 0; width < bi.getWidth(); width += 2) { 196 | for (int height = (bi.getHeight() - 1); height >= 0; height -= 2) { 197 | if (width / 2 >= fWidth || height / 2 >= fHeight) 198 | continue; 199 | 200 | Location b = getBlockAt(height, width, bi.getHeight()); 201 | Color[] color = new Color[4]; 202 | boolean allTrans = true; 203 | 204 | int defaultR = 0; 205 | int defaultG = 0; 206 | int defaultB = 0; 207 | 208 | for (int iT = 0; iT < 4; iT++) { 209 | int yT = (1 + height < result.length) ? height + (iT % 2) : height; 210 | int xT = (width + 1 < result[height].length) ? width + (iT / 2) : width; 211 | Pixel rgb = result[yT][xT]; 212 | if (rgb.r != 0 || rgb.g != 0 || rgb.b != 0) { 213 | allTrans = false; 214 | defaultR = rgb.r; 215 | defaultG = rgb.g; 216 | defaultB = rgb.b; 217 | break; 218 | } 219 | } 220 | if (allTrans) { 221 | isTrans[frame][width / 2][height / 2] = true; 222 | } else { 223 | for (int i = 0; i < 4; i++) { 224 | int y = (1 + height < result.length) ? height + (i % 2) : height; 225 | int x = (width + 1 < result[height].length) ? width + (i / 2) : width; 226 | Pixel rgb = result[y][x]; 227 | if (rgb.r != 0 || rgb.g != 0 || rgb.b != 0) { 228 | color[i] = new Color(rgb.r, rgb.g, rgb.b); 229 | } else { 230 | color[i] = new Color(defaultR, defaultG, defaultB); 231 | } 232 | } 233 | MaterialData m = RGBBlockColor.getClosestBlockValue(color, 234 | (dir == Direction.FLAT_NORTHEAST || dir == Direction.FLAT_NORTHWEST 235 | || dir == Direction.FLAT_SOUTHEAST || dir == Direction.FLAT_SOUTHWEST)); 236 | DataHolder dh = new DataHolder(b, m); 237 | holders.add(dh); 238 | materials[frame][width / 2][height / 2] = dh; 239 | } 240 | } 241 | } 242 | } 243 | isFulluLoaded = true; 244 | } 245 | }.runTaskLaterAsynchronously(PixelPrinter.getInstance(), 0); 246 | } 247 | 248 | public int getCurrentFrame() { 249 | return currentFrame; 250 | } 251 | 252 | public BufferedImage getFrame(int i) { 253 | return getFrames()[i]; 254 | } 255 | 256 | public void setNegDir(boolean b) { 257 | neg = b; 258 | } 259 | 260 | public void setEastOrWest(boolean b) { 261 | moving = b; 262 | } 263 | 264 | @SuppressWarnings("deprecation") 265 | public void loadFrame() { 266 | if (getFrames() == null || getFrames().length < 1) 267 | return; 268 | 269 | for (int x = 0; x < materials[currentFrame].length; x++) { 270 | for (int y = materials[currentFrame][x].length - 1; y >= 0; y--) { 271 | if (!isTrans[currentFrame][x][y]) { 272 | DataHolder dh = materials[currentFrame][x][y]; 273 | if (dh == null) 274 | continue; 275 | Block b = dh.b.getBlock(); 276 | if (b.getType() != dh.md.getMaterial()) { 277 | BlockState state = b.getState(); 278 | BlockFace bf = null; 279 | byte rd = dh.md.getData(); 280 | if (dh.hasFaces()) { 281 | bf = AsyncImageHolder.getBlockFace(dh, dir); 282 | rd = AsyncImageHolder.getBlockData(dh, dir); 283 | } 284 | if (PixelPrinter.isAbove113) { 285 | b.setType(dh.md.getMaterial()); 286 | try { 287 | if (bf != null) { 288 | Update13Handler.setFacing(b.getState(), bf); 289 | } 290 | } catch (Error | Exception e45) { 291 | } 292 | } else { 293 | state.setType(dh.md.getMaterial()); 294 | //b.setType(dh.md.getMaterial()); 295 | try { 296 | if (dh.md.getData() != 0 && b.getData() != rd) 297 | state.setRawData(rd); 298 | //b.setData(dh.md.getData()); 299 | } catch (Exception e) { 300 | e.printStackTrace(); 301 | } 302 | state.update(true, false); 303 | } 304 | } 305 | } 306 | } 307 | } 308 | this.currentFrame++; 309 | if (this.currentFrame >= getFrames().length) 310 | currentFrame = 0; 311 | } 312 | 313 | public int getSize() { 314 | return getFrames().length; 315 | } 316 | 317 | public UUID getOwner() { 318 | return owner; 319 | } 320 | 321 | public int getID() { 322 | return gifID; 323 | } 324 | 325 | public Location getMinCorner() { 326 | return minCorner; 327 | } 328 | 329 | public BufferedImage[] getFrames() { 330 | return frames; 331 | } 332 | 333 | public void setFrames(BufferedImage[] frames) { 334 | this.frames = frames; 335 | } 336 | 337 | public String getFileName() { 338 | return this.fileName; 339 | } 340 | 341 | @Override 342 | public Map serialize() { 343 | Map data = new HashMap(); 344 | data.put("currentframe", this.currentFrame); 345 | data.put("fileName", this.fileName); 346 | data.put("gifID", this.gifID); 347 | data.put("height", this.height); 348 | data.put("minCorner.x", this.minCorner.getBlockX()); 349 | data.put("minCorner.y", this.minCorner.getBlockY()); 350 | data.put("minCorner.z", this.minCorner.getBlockZ()); 351 | data.put("minCorner.w", this.minCorner.getWorld().getName()); 352 | data.put("moving", this.moving); 353 | data.put("neg", this.neg); 354 | data.put("owner", this.owner.toString()); 355 | 356 | data.put("dir", this.dir.getName()); 357 | return data; 358 | } 359 | 360 | @SuppressWarnings("deprecation") 361 | public void createFrames(final File gif, final int height, UUID owner) { 362 | Bukkit.getScheduler().scheduleAsyncDelayedTask(PixelPrinter.getInstance(), new Runnable() { 363 | public void run() { 364 | setFrames(getFrames(gif, height)); 365 | } 366 | }, 0); 367 | 368 | } 369 | } 370 | 371 | -------------------------------------------------------------------------------- /src/me/zombie_striker/pixelprinter/util/Image.java: -------------------------------------------------------------------------------- 1 | package me.zombie_striker.pixelprinter.util; 2 | 3 | import me.zombie_striker.pixelprinter.data.Direction; 4 | import me.zombie_striker.pixelprinter.data.IntHolder; 5 | import org.bukkit.Location; 6 | 7 | public class Image { 8 | 9 | protected final IntHolder done = new IntHolder(); 10 | protected final IntHolder total = new IntHolder(); 11 | protected Direction dir; 12 | protected Location minCorner; 13 | protected boolean neg; 14 | protected boolean moving; 15 | protected String p; 16 | protected boolean enableTransparent = false; 17 | 18 | public boolean isMovingX(Direction dir) { 19 | return dir == Direction.UP_EAST || dir == Direction.UP_WEST; 20 | } 21 | 22 | public boolean isMinUpNeg(Direction dir2) { 23 | return dir == Direction.UP_NORTH || dir2 == Direction.UP_WEST; 24 | } 25 | 26 | public Location getBlockAt(int height, int width, int imageHeight) { 27 | switch (dir) { 28 | case UP_EAST: 29 | return minCorner.clone() 30 | .add(width / 2, (imageHeight - height - 1) / 2, 0); 31 | case UP_WEST: 32 | return minCorner.clone() 33 | .add(-width / 2, (imageHeight - height - 1) / 2, 0); 34 | case UP_NORTH: 35 | return minCorner.clone() 36 | .add(0, (imageHeight - height - 1) / 2, -width / 2); 37 | case UP_SOUTH: 38 | return minCorner.clone() 39 | .add(0, (imageHeight - height - 1) / 2, width / 2); 40 | case FLAT_NORTHEAST: 41 | return minCorner.clone() 42 | .add(width / 2, 0, -(imageHeight - height - 1) / 2); 43 | case FLAT_NORTHWEST: 44 | return minCorner.clone() 45 | .add(-width / 2, 0, -(imageHeight - height - 1) / 2); 46 | case FLAT_SOUTHEAST: 47 | return minCorner.clone() 48 | .add((imageHeight - height - 1) / 2, 0, width / 2); 49 | case FLAT_SOUTHWEST: 50 | return minCorner.clone() 51 | .add(-(imageHeight - height - 1) / 2, 0, width / 2); 52 | default: 53 | return null; 54 | } 55 | } 56 | 57 | } 58 | -------------------------------------------------------------------------------- /src/me/zombie_striker/pixelprinter/util/MapWallUtil.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2017 Zombie_Striker 3 | * 4 | * This program is free software; you can redistribute it and/or modify it under the terms of the 5 | * GNU General Public License as published by the Free Software Foundation; either version 2 of 6 | * the License, or (at your option) any later version. 7 | * 8 | * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 9 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 10 | * See the GNU General Public License for more details. 11 | * 12 | * You should have received a copy of the GNU General Public License along with this program; 13 | * if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 14 | * 02111-1307 USA 15 | */ 16 | package me.zombie_striker.pixelprinter.util; 17 | 18 | import me.zombie_striker.pixelprinter.PixelPrinter; 19 | import me.zombie_striker.pixelprinter.data.Direction; 20 | import org.bukkit.Bukkit; 21 | import org.bukkit.Location; 22 | import org.bukkit.Material; 23 | import org.bukkit.block.BlockFace; 24 | import org.bukkit.entity.EntityType; 25 | import org.bukkit.entity.ItemFrame; 26 | import org.bukkit.entity.Player; 27 | import org.bukkit.inventory.ItemStack; 28 | import org.bukkit.inventory.meta.MapMeta; 29 | import org.bukkit.map.MapRenderer; 30 | 31 | import java.awt.image.BufferedImage; 32 | 33 | public class MapWallUtil { 34 | 35 | @SuppressWarnings("deprecation") 36 | public static ItemStack getMap(BufferedImage BUFFEREDIMAGE) { 37 | Material map = Material.MAP; 38 | ItemStack is; 39 | if (ReflectionUtil.isVersionHigherThan(1, 13)) { 40 | map = Material.FILLED_MAP; 41 | is = new ItemStack(map, 1); 42 | org.bukkit.inventory.meta.MapMeta mapmeta = (org.bukkit.inventory.meta.MapMeta) is.getItemMeta(); 43 | mapmeta.setMapId((short) SimilarMapUtil.findSimilarImage(BUFFEREDIMAGE)); 44 | is.setItemMeta(mapmeta); 45 | } else { 46 | is = new ItemStack(map, 1, (short) SimilarMapUtil.findSimilarImage(BUFFEREDIMAGE)); 47 | } 48 | return is; 49 | } 50 | 51 | /** 52 | * Remember: The image has to be a multiple of 128 53 | * 54 | * @param whole 55 | * @return 56 | */ 57 | public static ItemStack[][] getMaps(BufferedImage[] whole) { 58 | int frames = whole.length; 59 | int width = 0; 60 | int height = 0; 61 | for (int i = 0; i < whole.length; i++) { 62 | if (width < whole[i].getWidth()) 63 | width = whole[i].getWidth(); 64 | if (height < whole[i].getHeight()) 65 | height = whole[i].getHeight(); 66 | } 67 | int wd1 = (int) (0.999999999 + (((double) width) / 128)); 68 | int hd1 = (int) (0.999999999 + (((double) height) / 128)); 69 | ItemStack[][] stacks = new ItemStack[wd1][hd1]; 70 | if (wd1 == 0 || hd1 == 0) { 71 | Bukkit.broadcast("Image is invalid. Width=" + wd1 + " Height=" + hd1 + ".", 72 | "pluginconstructorapi.detectImage"); 73 | } 74 | for (int x = 0; x < wd1; x++) { 75 | for (int y = 0; y < hd1; y++) { 76 | ItemStack is; 77 | if (frames > 1) { 78 | /* 79 | * mv = Bukkit.createMap(Bukkit.getWorlds().get(0)); if 80 | * (ReflectionUtil.isVersionHigherThan(1, 13)) { map = Material.FILLED_MAP; is = 81 | * new ItemStack(map, 1); org.bukkit.inventory.meta.MapMeta mapmeta = 82 | * (org.bukkit.inventory.meta.MapMeta) is .getItemMeta(); 83 | * mapmeta.setMapId(mv.getId()); is.setItemMeta(mapmeta); } else { map = 84 | * Material.MAP; is = new ItemStack(map, 1, (short) mv.getId()); } 85 | */ 86 | BufferedImage[] bip = new BufferedImage[frames]; 87 | for (int frame = 0; frame < frames; frame++) { 88 | if (x * 128 >= whole[frame].getWidth()) { 89 | continue; 90 | } 91 | int cW = 128; 92 | int cH = 128; 93 | // if ((x * 128) + cW == whole[frame].getWidth()) 94 | // continue; 95 | if ((x * 128) + cW > whole[frame].getWidth()) 96 | cW = whole[frame].getWidth() - ((x * 128)); 97 | if ((y * 128) + cH > whole[frame].getHeight()) 98 | cH = whole[frame].getHeight() - ((y * 128)); 99 | if (cH <= 0 || cW <= 0) 100 | continue; 101 | bip[frame] = whole[frame].getSubimage(x * 128, y * 128, cW, cH); 102 | } 103 | is = getMap(bip[0]); 104 | CustomImageRenderer cir = new CustomImageRenderer(bip, 105 | ((frames > 1) ? 0 : CustomImageRenderer.TICK_FOR_STILLS)); 106 | for (MapRenderer mr : ((MapMeta) is).getMapView().getRenderers()) { 107 | ((MapMeta) is).getMapView().removeRenderer(mr); 108 | } 109 | ((MapMeta) is).getMapView().addRenderer(cir); 110 | stacks[x][y] = is; 111 | } else { 112 | BufferedImage[] bip = new BufferedImage[frames]; 113 | for (int frame = 0; frame < frames; frame++) { 114 | if (x * 128 >= whole[frame].getWidth()) { 115 | continue; 116 | } 117 | int cW = 128; 118 | int cH = 128; 119 | // if ((x * 128) + cW == whole[frame].getWidth()) 120 | // continue; 121 | if ((x * 128) + cW > whole[frame].getWidth()) 122 | cW = whole[frame].getWidth() - ((x * 128)); 123 | if ((y * 128) + cH > whole[frame].getHeight()) 124 | cH = whole[frame].getHeight() - ((y * 128)); 125 | if (cH <= 0 || cW <= 0) 126 | continue; 127 | bip[frame] = whole[frame].getSubimage(x * 128, y * 128, cW, cH); 128 | } 129 | stacks[x][y] = getMap(bip[0]); 130 | } 131 | } 132 | } 133 | return stacks; 134 | } 135 | 136 | public static void setBlockAt(Direction dir, final Player p, int height, int width, final ItemStack is) { 137 | Location loc = new Location(p.getWorld(), p.getLocation().getBlockX(), p.getLocation().getBlockY(), 138 | p.getLocation().getBlockZ()); 139 | final Location frame_loc; 140 | final BlockFace bf; 141 | final Material type = Material.GLASS; 142 | switch (dir) { 143 | case UP_EAST: 144 | loc.add(width, height, 0); 145 | loc.getBlock().setType(type); 146 | frame_loc = loc.clone(); 147 | frame_loc.setZ(loc.getZ() + 1); 148 | bf = BlockFace.EAST; 149 | break; 150 | case UP_WEST: 151 | loc.add(-width, height, 0); 152 | loc.getBlock().setType(type); 153 | frame_loc = loc.clone(); 154 | frame_loc.setZ(loc.getZ() - 1); 155 | bf = BlockFace.WEST; 156 | break; 157 | case UP_NORTH: 158 | loc.add(0, height, -width); 159 | loc.getBlock().setType(type); 160 | frame_loc = loc.clone(); 161 | frame_loc.setX(loc.getX() + 1); 162 | bf = BlockFace.NORTH; 163 | break; 164 | default: 165 | loc.add(0, height, width); 166 | loc.getBlock().setType(type); 167 | frame_loc = loc.clone(); 168 | frame_loc.setX(loc.getX() - 1); 169 | bf = BlockFace.SOUTH; 170 | break; 171 | } 172 | if (frame_loc.getBlock().getType() != Material.AIR) 173 | frame_loc.getBlock().setType(Material.AIR); 174 | if (is != null) 175 | Bukkit.getScheduler().scheduleSyncDelayedTask(PixelPrinter.getInstance(), new Runnable() { 176 | public void run() { 177 | ItemFrame i = (ItemFrame) p.getWorld().spawnEntity(frame_loc, EntityType.ITEM_FRAME);// .spawn(frame_loc, 178 | // ItemFrame.class); 179 | i.setFacingDirection(bf); 180 | i.setItem(is); 181 | } 182 | }, 20); 183 | } 184 | } 185 | -------------------------------------------------------------------------------- /src/me/zombie_striker/pixelprinter/util/MojangAPI.java: -------------------------------------------------------------------------------- 1 | package me.zombie_striker.pixelprinter.util; 2 | 3 | import java.io.BufferedReader; 4 | import java.io.IOException; 5 | import java.io.InputStreamReader; 6 | import java.net.URL; 7 | import java.util.ArrayList; 8 | import java.util.List; 9 | 10 | public class MojangAPI { 11 | 12 | private static final String NAME_URL = "https://api.mojang.com/users/profiles/minecraft/"; 13 | 14 | public static String getUUIDFromName(String name) { 15 | try { 16 | URL url = new URL(NAME_URL + name); 17 | BufferedReader br = new BufferedReader(new InputStreamReader( 18 | url.openStream())); 19 | List list = new ArrayList<>(); 20 | String input = null; 21 | while ((input = br.readLine()) != null) { 22 | list.add(input); 23 | } 24 | br.close(); 25 | 26 | for (String s : list) { 27 | System.out.println(s); 28 | return s.split(",")[0].split("id\":")[1].replaceAll("\"", "") 29 | .trim(); 30 | 31 | } 32 | } catch (IOException e) { 33 | // TODO Auto-generated catch block 34 | e.printStackTrace(); 35 | } 36 | return null; 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /src/me/zombie_striker/pixelprinter/util/RGBChatColor.java: -------------------------------------------------------------------------------- 1 | package me.zombie_striker.pixelprinter.util; 2 | 3 | import org.bukkit.ChatColor; 4 | 5 | import java.awt.*; 6 | import java.util.HashMap; 7 | import java.util.Map; 8 | import java.util.Map.Entry; 9 | 10 | public class RGBChatColor { 11 | 12 | public static Map chatValue = new HashMap<>(); 13 | 14 | public static String BLACK_BAR = Character.toString((char) 0x2588); 15 | private static String bol = (ChatColor.BOLD + ""); 16 | 17 | static { 18 | 19 | chatValue.put(ChatColor.BLACK + bol + "#", new RGBValue(new Color(0, 0, 20 | 0))); 21 | addColor("C", new double[]{155, 53, 128, 56}, new double[]{155, 22 | 53, 128, 56}, new double[]{155, 53, 128, 56}); 23 | addColor("$", new double[]{108, 94, 121, 94}, new double[]{108, 24 | 94, 121, 94}, new double[]{108, 94, 121, 94}); 25 | addColor("X", new double[]{105, 86, 93, 76}, new double[]{105, 86, 26 | 93, 76}, new double[]{105, 86, 93, 76}); 27 | addColor("M", new double[]{151, 125, 93, 80}, new double[]{151, 28 | 125, 93, 80}, new double[]{151, 125, 93, 80}); 29 | addColor("O", new double[]{138, 107, 104, 93}, new double[]{138, 30 | 107, 104, 93}, new double[]{138, 107, 104, 93}); 31 | addColor("0", new double[]{159, 131, 127, 102}, new double[]{159, 32 | 131, 127, 102}, new double[]{159, 131, 127, 102}); 33 | addColor("/", new double[]{36, 84, 82, 10}, new double[]{36, 84, 34 | 82, 10}, new double[]{36, 84, 82, 10}); 35 | addColor("\\", new double[]{84, 36, 10, 82}, new double[]{84, 36, 36 | 10, 82}, new double[]{84, 36, 10, 82}); 37 | addColor("_", new double[]{0, 0, 63, 51}, new double[]{0, 0, 63, 38 | 51}, new double[]{0, 0, 63, 51}); 39 | addColor("P", new double[]{201, 84, 94, 0}, new double[]{201, 84, 40 | 94, 0}, new double[]{201, 84, 94, 0}); 41 | addColor("a", new double[]{63, 63, 110, 150}, new double[]{63, 63, 42 | 110, 150}, new double[]{63, 63, 110, 150}); 43 | addColor("=", new double[]{80, 65, 80, 75}, new double[]{80, 65, 44 | 80, 75}, new double[]{80, 65, 80, 75}); 45 | addColor("-", new double[]{44, 33, 48, 43}, new double[]{44, 33, 46 | 48, 43}, new double[]{44, 33, 48, 43}); 47 | addColor("J", new double[]{0, 90, 63, 90}, new double[]{0, 90, 63, 48 | 90}, new double[]{0, 90, 63, 90}); 49 | addColor("U", new double[]{110, 90, 100, 90}, new double[]{110, 50 | 90, 100, 90}, new double[]{110, 90, 100, 90}); 51 | addColor("T", new double[]{115, 95, 40, 30}, new double[]{115, 95, 52 | 40, 30}, new double[]{115, 95, 40, 30}); 53 | addColor("E", new double[]{191, 60, 130, 35}, new double[]{191, 54 | 60, 130, 35}, new double[]{191, 60, 130, 35}); 55 | addColor("8", new double[]{144, 111, 105, 90}, new double[]{144, 56 | 111, 105, 90}, new double[]{144, 111, 105, 90}); 57 | addColor("4", new double[]{90, 147, 70, 105}, new double[]{90, 58 | 147, 70, 105}, new double[]{90, 147, 70, 105}); 59 | addColor("2", new double[]{98, 104, 118, 105}, new double[]{98, 60 | 104, 118, 105}, new double[]{98, 104, 118, 105}); 61 | addColor("6", new double[]{135, 65, 126, 91}, new double[]{135, 62 | 65, 126, 91}, new double[]{135, 65, 126, 91}); 63 | addColor("u", new double[]{66, 48, 111, 124}, new double[]{66, 48, 64 | 111, 124}, new double[]{66, 48, 111, 124}); 65 | addColor("Y", new double[]{80, 70, 44, 35}, new double[]{80, 70, 66 | 44, 35}, new double[]{80, 70, 44, 35}); 67 | addColor("I!", new double[]{136, 123, 113, 78}, new double[]{136, 68 | 123, 113, 78}, new double[]{136, 123, 113, 78}); 69 | addColor("!I", new double[]{156, 116, 102, 104}, new double[]{156, 70 | 116, 102, 104}, new double[]{156, 116, 102, 104}); 71 | addColor("h", new double[]{150, 50, 108, 88}, new double[]{150, 72 | 50, 108, 88}, new double[]{150, 50, 108, 88}); 73 | addColor("H", new double[]{155, 125, 100, 85}, new double[]{155, 74 | 125, 100, 85}, new double[]{155, 125, 100, 85}); 75 | addColor("x", new double[]{50, 50, 90, 71}, new double[]{50, 50, 76 | 90, 71}, new double[]{50, 50, 90, 71}); 77 | addColor("q", new double[]{80, 80, 70, 135}, new double[]{80, 80, 78 | 70, 135}, new double[]{80, 80, 70, 135}); 79 | addColor("![", new double[]{175, 81, 117, 77}, new double[]{175, 80 | 81, 117, 77}, new double[]{175, 81, 117, 77}); 81 | addColor("]!", new double[]{105, 146, 90, 191}, new double[]{105, 82 | 146, 90, 191}, new double[]{105, 146, 90, 191}); 83 | addColor("S", new double[]{117, 125, 68, 94}, new double[]{117, 84 | 125, 68, 94}, new double[]{117, 125, 68, 94}); 85 | addColor("N", new double[]{146, 116, 100, 90}, new double[]{146, 86 | 116, 100, 90}, new double[]{146, 116, 100, 90}); 87 | addColor("n", new double[]{106, 58, 107, 86}, new double[]{106, 88 | 58, 107, 86}, new double[]{106, 58, 107, 86}); 89 | addColor("b", new double[]{146, 50, 148, 99}, new double[]{146, 90 | 50, 148, 99}, new double[]{146, 50, 148, 99}); 91 | addColor("B", new double[]{197, 109, 133, 91}, new double[]{197, 92 | 109, 133, 91}, new double[]{197, 109, 133, 91}); 93 | addColor("w", new double[]{67, 52, 133, 141}, new double[]{67, 52, 94 | 133, 141}, new double[]{67, 52, 133, 141}); 95 | addColor("W", new double[]{121, 100, 133, 105}, new double[]{121, 96 | 100, 133, 105}, new double[]{121, 100, 133, 105}); 97 | addColor("#", new double[]{178, 136, 132, 116}, new double[]{178, 98 | 136, 132, 116}, new double[]{178, 136, 132, 116}); 99 | addColor("f", new double[]{129, 114, 82, 33}, new double[]{129, 100 | 114, 82, 33}, new double[]{129, 114, 82, 33}); 101 | addColor("F", new double[]{194, 68, 92, 0}, new double[]{194, 68, 102 | 92, 0}, new double[]{194, 68, 92, 0}); 103 | addColor("d", new double[]{80, 122, 112, 124}, new double[]{80, 104 | 122, 112, 124}, new double[]{80, 122, 112, 124}); 105 | addColor("D", new double[]{153, 101, 120, 84}, new double[]{153, 106 | 101, 120, 84}, new double[]{153, 101, 120, 84}); 107 | addColor("A", new double[]{174, 137, 94, 80}, new double[]{174, 108 | 137, 94, 80}, new double[]{174, 137, 94, 80}); 109 | addColor("k", new double[]{162, 32, 146, 55}, new double[]{162, 110 | 32, 146, 55}, new double[]{162, 32, 146, 55}); 111 | addColor("K", new double[]{157, 75, 100, 70}, new double[]{157, 112 | 75, 100, 70}, new double[]{157, 75, 100, 70}); 113 | addColor("v", new double[]{62, 50, 80, 71}, new double[]{62, 50, 114 | 80, 71}, new double[]{62, 50, 80, 71}); 115 | addColor("V", new double[]{119, 98, 79, 70}, new double[]{119, 98, 116 | 79, 70}, new double[]{119, 98, 79, 70}); 117 | addColor("L", new double[]{113, 0, 133, 54}, new double[]{113, 0, 118 | 133, 54}, new double[]{113, 0, 133, 54}); 119 | addColor("ll", new double[]{144, 82, 101, 75}, new double[]{144, 120 | 82, 101, 75}, new double[]{144, 82, 101, 75}); 121 | addColor("1", new double[]{73, 42, 99, 83}, new double[]{73, 42, 122 | 99, 83}, new double[]{73, 42, 99, 83}); 123 | } 124 | 125 | private static void addColor(String ch, double[] r, double[] g, double[] b) { 126 | double[] c = new double[4 * 3]; 127 | for (int k = 0; k < 4; k++) { 128 | c[(k * 3) + 0] = r[k] / 255; 129 | c[(k * 3) + 1] = g[k] / 255; 130 | c[(k * 3) + 2] = b[k] / 255; 131 | } 132 | 133 | int[][] mods = {{0, 0, 0}, // black 0 134 | {0, 0, 170},// darkblue 1 135 | {0, 170, 0}, // dark green 2 136 | {0, 170, 170}, // cyan 3 137 | {170, 0, 0}, // dark red 4 138 | {170, 0, 170}, // purple 5 139 | {255, 170, 0}, // gold 6 140 | {170, 170, 170}, // light gray 7 141 | {85, 85, 85}, // dark gray 8 142 | {85, 85, 255}, // blue 9 143 | {85, 255, 85},// green a 144 | {85, 255, 255}, // light blue b 145 | {255, 85, 85}, // red c 146 | {255, 85, 255}, // light pink d 147 | {255, 255, 85}, // yellow e 148 | {300, 300, 300} // White +45 F //{ 255, 255, 255 } // white f 149 | }; 150 | 151 | int cm = 0; 152 | for (ChatColor cc : ChatColor.values()) { 153 | if (cc == ChatColor.BOLD || cc == ChatColor.STRIKETHROUGH 154 | || cc == ChatColor.RESET || cc == ChatColor.ITALIC 155 | || cc == ChatColor.MAGIC || cc == ChatColor.UNDERLINE) 156 | continue; 157 | int x = 0; 158 | chatValue.put(cc + bol + ch, new RGBValue(new Color((c[x] 159 | * mods[cm][x % 3] > 255) ? 255 160 | : (int) (c[x] * mods[cm][x++ % 3]), 161 | (c[x] * mods[cm][x % 3] > 255) ? 255 162 | : (int) (c[x] * mods[cm][x++ % 3]), (c[x] 163 | * mods[cm][x % 3] > 255) ? 255 164 | : (int) (c[x] * mods[cm][x++ % 3])), new Color( 165 | (c[x] * mods[cm][x % 3] > 255) ? 255 166 | : (int) (c[x] * mods[cm][x++ % 3]), (c[x] 167 | * mods[cm][x % 3] > 255) ? 255 168 | : (int) (c[x] * mods[cm][x++ % 3]), (c[x] 169 | * mods[cm][x % 3] > 255) ? 255 170 | : (int) (c[x] * mods[cm][x++ % 3])), new Color( 171 | (c[x] * mods[cm][x % 3] > 255) ? 255 172 | : (int) (c[x] * mods[cm][x++ % 3]), (c[x] 173 | * mods[cm][x % 3] > 255) ? 255 174 | : (int) (c[x] * mods[cm][x++ % 3]), (c[x] 175 | * mods[cm][x % 3] > 255) ? 255 176 | : (int) (c[x] * mods[cm][x++ % 3])), new Color( 177 | (c[x] * mods[cm][x % 3] > 255) ? 255 178 | : (int) (c[x] * mods[cm][x++ % 3]), (c[x] 179 | * mods[cm][x % 3] > 255) ? 255 180 | : (int) (c[x] * mods[cm][x++ % 3]), (c[x] 181 | * mods[cm][x % 3] > 255) ? 255 182 | : (int) (c[x] * mods[cm][x++ % 3])))); 183 | cm++; 184 | } 185 | } 186 | 187 | /** 188 | * The color value of the four closest colors. Use this if you want to 189 | * preserve hard edges in images. For the array, you need four color values. 190 | * Use the following chart to understand which pixel should be at which 191 | * index: 192 | *

193 | * | 0 | 1 | 194 | *

195 | * |---|---| 196 | *

197 | * | 2 | 3 | 198 | * 199 | * @param c - The color value 200 | * @return The closest material and durability. 201 | */ 202 | public static String getClosestBlockValue(Color[] c) { 203 | 204 | int[] r = new int[4]; 205 | int[] b = new int[4]; 206 | int[] g = new int[4]; 207 | for (int i = 0; i < c.length; i++) { 208 | r[i] = c[i].getRed(); 209 | b[i] = c[i].getBlue(); 210 | g[i] = c[i].getGreen(); 211 | } 212 | 213 | double cR = Integer.MAX_VALUE; 214 | double cG = Integer.MAX_VALUE; 215 | double cB = Integer.MAX_VALUE; 216 | 217 | String closest = null; 218 | 219 | double[] tR = new double[4]; 220 | double[] tG = new double[4]; 221 | double[] tB = new double[4]; 222 | for (Entry entry : chatValue.entrySet()) { 223 | for (int i = 0; i < 4; i++) { 224 | tR[i] = entry.getValue().r[i] - r[i]; 225 | tG[i] = entry.getValue().g[i] - g[i]; 226 | tB[i] = entry.getValue().b[i] - b[i]; 227 | if (tR[i] < 0) 228 | tR[i] = -tR[i]; 229 | if (tG[i] < 0) 230 | tG[i] = -tG[i]; 231 | if (tB[i] < 0) 232 | tB[i] = -tB[i]; 233 | } 234 | if ((tR[0] * tR[0]) + (tG[0] * tG[0]) + (tB[0] * tB[0]) 235 | + (tR[1] * tR[1]) + (tG[1] * tG[1]) + (tB[1] * tB[1]) 236 | + (tR[2] * tR[2]) + (tG[2] * tG[2]) + (tB[2] * tB[2]) 237 | + (tR[3] * tR[3]) + (tG[3] * tG[3]) + (tB[3] * tB[3]) < (cR 238 | + cG + cB)) { 239 | cR = 0; 240 | cB = 0; 241 | cG = 0; 242 | for (int i = 0; i < 4; i++) { 243 | cR += (tR[i] * tR[i]); 244 | cG += (tG[i] * tG[i]); 245 | cB += (tB[i] * tB[i]); 246 | } 247 | closest = entry.getKey(); 248 | } 249 | } 250 | return closest; 251 | } 252 | } 253 | -------------------------------------------------------------------------------- /src/me/zombie_striker/pixelprinter/util/ReflectionUtil.java: -------------------------------------------------------------------------------- 1 | package me.zombie_striker.pixelprinter.util; 2 | 3 | import org.bukkit.Bukkit; 4 | 5 | import java.lang.reflect.Constructor; 6 | import java.lang.reflect.Field; 7 | import java.lang.reflect.InvocationTargetException; 8 | import java.lang.reflect.Method; 9 | import java.util.Optional; 10 | 11 | /** 12 | * A small help with reflection 13 | */ 14 | public class ReflectionUtil { 15 | private static final String SERVER_VERSION; 16 | 17 | 18 | static { 19 | String name = Bukkit.getServer().getClass().getName(); 20 | name = name.substring(name.indexOf("craftbukkit.") 21 | + "craftbukkit.".length()); 22 | name = name.substring(0, name.indexOf(".")); 23 | SERVER_VERSION = name; 24 | } 25 | 26 | public static boolean isVersionHigherThan(int mainVersion, 27 | int secondVersion) { 28 | String firstChar = SERVER_VERSION.substring(1, 2); 29 | int fInt = Integer.parseInt(firstChar); 30 | if (fInt < mainVersion) 31 | return false; 32 | StringBuilder secondChar = new StringBuilder(); 33 | for (int i = 3; i < 10; i++) { 34 | if (SERVER_VERSION.charAt(i) == '_' 35 | || SERVER_VERSION.charAt(i) == '.') 36 | break; 37 | secondChar.append(SERVER_VERSION.charAt(i)); 38 | } 39 | int sInt = Integer.parseInt(secondChar.toString()); 40 | return sInt >= secondVersion; 41 | } 42 | 43 | /** 44 | * Returns the NMS class. 45 | * 46 | * @param name The name of the class 47 | * @return The NMS class or null if an error occurred 48 | */ 49 | public static Class getNMSClass(String name) { 50 | try { 51 | return Class.forName("net.minecraft.server." + SERVER_VERSION 52 | + "." + name); 53 | } catch (ClassNotFoundException e) { 54 | e.printStackTrace(); 55 | return null; 56 | } 57 | } 58 | 59 | /** 60 | * Returns the CraftBukkit class. 61 | * 62 | * @param name The name of the class 63 | * @return The CraftBukkit class or null if an error occurred 64 | */ 65 | 66 | public static Class getCraftbukkitClass(String name, 67 | String packageName) { 68 | try { 69 | return Class.forName("org.bukkit.craftbukkit." + SERVER_VERSION 70 | + "." + packageName + "." + name); 71 | } catch (ClassNotFoundException e) { 72 | e.printStackTrace(); 73 | return null; 74 | } 75 | } 76 | 77 | /** 78 | * Returns the CraftBukkit class. 79 | * 80 | * @param name The name of the class 81 | * @return The CraftBukkit class or null if an error occurred 82 | */ 83 | 84 | public static Class getCraftbukkitClass(String name) { 85 | try { 86 | return Class.forName("org.bukkit.craftbukkit." + SERVER_VERSION 87 | + "." + name); 88 | } catch (ClassNotFoundException e) { 89 | e.printStackTrace(); 90 | return null; 91 | } 92 | } 93 | 94 | /** 95 | * Returns the mojang.authlib class. 96 | * 97 | * @param name The name of the class 98 | * @return The mojang.authlib class or null if an error occurred 99 | */ 100 | 101 | public static Class getMojangAuthClass(String name) { 102 | try { 103 | return Class.forName("com.mojang.authlib." + name); 104 | } catch (ClassNotFoundException e) { 105 | e.printStackTrace(); 106 | return null; 107 | } 108 | } 109 | 110 | /** 111 | * Invokes the method 112 | * 113 | * @param handle The handle to invoke it on 114 | * @param methodName The name of the method 115 | * @param parameterClasses The parameter types 116 | * @param args The arguments 117 | * @return The resulting object or null if an error occurred / the 118 | * method didn't return a thing 119 | */ 120 | @SuppressWarnings("rawtypes") 121 | public static Object invokeMethod(Object handle, String methodName, 122 | Class[] parameterClasses, Object... args) { 123 | return invokeMethod(handle.getClass(), handle, methodName, 124 | parameterClasses, args); 125 | } 126 | 127 | /** 128 | * Invokes the method 129 | * 130 | * @param clazz The class to invoke it from 131 | * @param handle The handle to invoke it on 132 | * @param methodName The name of the method 133 | * @param parameterClasses The parameter types 134 | * @param args The arguments 135 | * @return The resulting object or null if an error occurred / the 136 | * method didn't return a thing 137 | */ 138 | @SuppressWarnings("rawtypes") 139 | public static Object invokeMethod(Class clazz, Object handle, 140 | String methodName, Class[] parameterClasses, Object... args) { 141 | Optional methodOptional = getMethod(clazz, methodName, 142 | parameterClasses); 143 | 144 | if (!methodOptional.isPresent()) { 145 | return null; 146 | } 147 | 148 | Method method = methodOptional.get(); 149 | 150 | try { 151 | return method.invoke(handle, args); 152 | } catch (IllegalAccessException | InvocationTargetException e) { 153 | e.printStackTrace(); 154 | } 155 | return null; 156 | } 157 | 158 | /** 159 | * Sets the value of an instance field 160 | * 161 | * @param handle The handle to invoke it on 162 | * @param name The name of the field 163 | * @param value The new value of the field 164 | */ 165 | @SuppressWarnings("deprecation") 166 | public static void setInstanceField(Object handle, String name, 167 | Object value) { 168 | Class clazz = handle.getClass(); 169 | Optional fieldOptional = getField(clazz, name); 170 | if (!fieldOptional.isPresent()) { 171 | return; 172 | } 173 | 174 | Field field = fieldOptional.get(); 175 | if (!field.isAccessible()) { 176 | field.setAccessible(true); 177 | } 178 | try { 179 | field.set(handle, value); 180 | } catch (IllegalAccessException e) { 181 | e.printStackTrace(); 182 | } 183 | } 184 | 185 | /** 186 | * Sets the value of an instance field 187 | * 188 | * @param handle The handle to invoke it on 189 | * @param name The name of the field 190 | * @return The result 191 | */ 192 | @SuppressWarnings("deprecation") 193 | public static Object getInstanceField(Object handle, String name) { 194 | Class clazz = handle.getClass(); 195 | Optional fieldOptional = getField(clazz, name); 196 | if (!fieldOptional.isPresent()) { 197 | return handle; 198 | } 199 | Field field = fieldOptional.get(); 200 | if (!field.isAccessible()) { 201 | field.setAccessible(true); 202 | } 203 | try { 204 | return field.get(handle); 205 | } catch (IllegalAccessException e) { 206 | e.printStackTrace(); 207 | } 208 | return null; 209 | } 210 | 211 | /** 212 | * Returns an enum constant 213 | * 214 | * @param enumClass The class of the enum 215 | * @param name The name of the enum constant 216 | * @return The enum entry or null 217 | */ 218 | public static Object getEnumConstant(Class enumClass, String name) { 219 | if (!enumClass.isEnum()) { 220 | return null; 221 | } 222 | for (Object o : enumClass.getEnumConstants()) { 223 | if (name.equals(invokeMethod(o, "name", new Class[0]))) { 224 | return o; 225 | } 226 | } 227 | return null; 228 | } 229 | 230 | /** 231 | * Returns the constructor 232 | * 233 | * @param clazz The class 234 | * @param params The Constructor parameters 235 | * @return The Constructor or an empty Optional if there is none with 236 | * these parameters 237 | */ 238 | public static Optional getConstructor(Class clazz, 239 | Class... params) { 240 | try { 241 | return Optional.of(clazz.getConstructor(params)); 242 | } catch (NoSuchMethodException e) { 243 | try { 244 | return Optional.of(clazz.getDeclaredConstructor(params)); 245 | } catch (NoSuchMethodException e2) { 246 | e2.printStackTrace(); 247 | } 248 | } 249 | return Optional.empty(); 250 | } 251 | 252 | /** 253 | * Instantiates the class. Will print the errors it gets 254 | * 255 | * @param constructor The constructor 256 | * @param arguments The initial arguments 257 | * @return The resulting object, or null if an error occurred. 258 | */ 259 | public static Object instantiate(Constructor constructor, 260 | Object... arguments) { 261 | try { 262 | return constructor.newInstance(arguments); 263 | } catch (InstantiationException | IllegalAccessException 264 | | InvocationTargetException e) { 265 | e.printStackTrace(); 266 | } 267 | return null; 268 | } 269 | 270 | public static Optional getMethod(Class clazz, String name, 271 | Class... params) { 272 | try { 273 | return Optional.of(clazz.getMethod(name, params)); 274 | } catch (NoSuchMethodException e) { 275 | e.printStackTrace(); 276 | } 277 | try { 278 | return Optional.of(clazz.getDeclaredMethod(name, params)); 279 | } catch (NoSuchMethodException e) { 280 | e.printStackTrace(); 281 | } 282 | return Optional.empty(); 283 | } 284 | 285 | public static Optional getField(Class clazz, String name) { 286 | try { 287 | return Optional.of(clazz.getField(name)); 288 | } catch (NoSuchFieldException e) { 289 | } 290 | 291 | try { 292 | return Optional.of(clazz.getDeclaredField(name)); 293 | } catch (NoSuchFieldException e) { 294 | } 295 | return Optional.empty(); 296 | } 297 | } -------------------------------------------------------------------------------- /src/me/zombie_striker/pixelprinter/util/SimilarMapUtil.java: -------------------------------------------------------------------------------- 1 | package me.zombie_striker.pixelprinter.util; 2 | 3 | import me.zombie_striker.pixelprinter.data.CustomMapView; 4 | import org.bukkit.Bukkit; 5 | import org.bukkit.Material; 6 | import org.bukkit.inventory.ItemStack; 7 | import org.bukkit.inventory.meta.MapMeta; 8 | import org.bukkit.map.MapRenderer; 9 | import org.bukkit.map.MapView; 10 | 11 | import javax.imageio.ImageIO; 12 | import java.awt.image.BufferedImage; 13 | import java.io.File; 14 | import java.io.IOException; 15 | 16 | public class SimilarMapUtil { 17 | 18 | private static File mapFolder; 19 | 20 | public static void registerAllMaps(File folder) { 21 | mapFolder = folder; 22 | for (File f : mapFolder.listFiles()) { 23 | int id = Integer.parseInt(f.getName().split(".png")[0]); 24 | try { 25 | renderMap(id, ImageIO.read(f)); 26 | } catch (IOException e) { 27 | e.printStackTrace(); 28 | } 29 | } 30 | } 31 | 32 | public static void renderMap(int mapIds, BufferedImage image) { 33 | try { 34 | Material map = Material.MAP; 35 | if (ReflectionUtil.isVersionHigherThan(1, 13)) 36 | map = Material.FILLED_MAP; 37 | @SuppressWarnings("deprecation") 38 | ItemStack is = new ItemStack(map, 1, (short) mapIds); 39 | 40 | MapMeta meta = (MapMeta) is.getItemMeta(); 41 | meta.setMapView(new CustomMapView(mapIds)); 42 | if (!meta.hasMapView()) { 43 | Bukkit.getMap(mapIds); 44 | } 45 | MapView mv = meta.getMapView(); 46 | for (MapRenderer mr : mv.getRenderers()) { 47 | mv.removeRenderer(mr); 48 | } 49 | mv.addRenderer(new CustomImageRenderer(image, CustomImageRenderer.TICK_FOR_STILLS)); 50 | } catch (Error | Exception e4) { 51 | e4.printStackTrace(); 52 | } 53 | } 54 | 55 | public static int findSimilarImage(BufferedImage image) { 56 | for (File f : mapFolder.listFiles()) { 57 | String filename = f.getName(); 58 | if (filename.contains(".")) 59 | filename = filename.split("\\.")[0]; 60 | int id = Integer.parseInt(filename); 61 | try { 62 | if (compareImages(image, ImageIO.read(f))) { 63 | return id; 64 | } 65 | } catch (IOException e) { 66 | e.printStackTrace(); 67 | } 68 | } 69 | MapView mv = Bukkit.createMap(Bukkit.getWorlds().get(0)); 70 | for (MapRenderer mr : mv.getRenderers()) { 71 | mv.removeRenderer(mr); 72 | } 73 | mv.addRenderer(new CustomImageRenderer(image, CustomImageRenderer.TICK_FOR_STILLS)); 74 | 75 | try { 76 | ImageIO.write(image, "png", new File(mapFolder, mv.getId() + ".png")); 77 | } catch (IOException e) { 78 | e.printStackTrace(); 79 | } 80 | image.flush(); 81 | 82 | return mv.getId(); 83 | } 84 | 85 | /** 86 | * Compares two images pixel by pixel. 87 | * 88 | * @param imgA the first image. 89 | * @param imgB the second image. 90 | * @return whether the images are both the same or not. 91 | */ 92 | public static boolean compareImages(BufferedImage imgA, BufferedImage imgB) { 93 | // The images must be the same size. 94 | if (imgA.getWidth() != imgB.getWidth() || imgA.getHeight() != imgB.getHeight()) { 95 | return false; 96 | } 97 | 98 | int width = imgA.getWidth(); 99 | int height = imgA.getHeight(); 100 | 101 | // Loop over every pixel. 102 | for (int y = 0; y < height; y++) { 103 | for (int x = 0; x < width; x++) { 104 | // Compare the pixels for equality. 105 | if (imgA.getRGB(x, y) != imgB.getRGB(x, y)) { 106 | return false; 107 | } 108 | } 109 | } 110 | 111 | return true; 112 | } 113 | } 114 | -------------------------------------------------------------------------------- /src/me/zombie_striker/pixelprinter/util/SkinCreator.java: -------------------------------------------------------------------------------- 1 | package me.zombie_striker.pixelprinter.util; 2 | 3 | import com.sun.org.apache.xerces.internal.impl.dv.util.Base64; 4 | import me.zombie_striker.pixelprinter.data.Direction; 5 | import me.zombie_striker.pixelprinter.util.RGBBlockColor.Pixel; 6 | import org.bukkit.Location; 7 | 8 | import javax.imageio.ImageIO; 9 | import java.awt.image.BufferedImage; 10 | import java.io.IOException; 11 | import java.io.InputStreamReader; 12 | import java.lang.reflect.Method; 13 | import java.net.URL; 14 | 15 | public class SkinCreator { 16 | 17 | public static BufferedImage[] getSkin(String uuid) 18 | throws NullPointerException, IOException { 19 | int linecode = 21; 20 | try { 21 | StringBuilder code = new StringBuilder(); 22 | InputStreamReader is = new InputStreamReader(new URL( 23 | "https://sessionserver.mojang.com/session/minecraft/profile/" 24 | + uuid.replace("-", "")).openStream()); 25 | int charI = 0; 26 | while ((charI = is.read()) != -1) { 27 | code.append(((char) charI)); 28 | } 29 | linecode = 31; 30 | String[] aaaa = code.toString().split("\"value\" : \""); 31 | if (aaaa.length == 1) { 32 | System.out.println("The user does not exist- AAAA does not contain value. Response:"); 33 | System.out.println(code.toString()); 34 | throw new NullPointerException(); 35 | } 36 | String decode; 37 | try { 38 | linecode = 39; 39 | Method m = Class.forName("javax.xml.bind.DatatypeConverter").getMethod("parseBase64Binary", String.class); 40 | /* 41 | javax.xml.bind.DatatypeConverter.parseBase64Binary(*/ 42 | decode = (String) m.invoke(null, aaaa[1] 43 | .split("\"}],\"legacy\"")[0].split("\"}}}")[0].split("\"")[0]); 44 | } catch (Error | Exception e4) { 45 | linecode = 45; 46 | decode = new String(Base64.decode(aaaa[1] 47 | .split("\"}],\"legacy\"")[0].split("\"}}}")[0].split("\"")[0])); 48 | } 49 | linecode = 49; 50 | System.out.println(decode); 51 | String url = decode.split("url\" : \"")[1].split("\"}")[0].split("\",")[0]; 52 | linecode = 52; 53 | System.out.println(url); 54 | BufferedImage[] images = new BufferedImage[2]; 55 | images[0] = ImageIO.read(new URL(url)); 56 | linecode = 56; 57 | if (decode.contains("CAPE")) { 58 | String urlcape = decode.split("url\" : \"")[2].split("\"}")[0]; 59 | linecode = 59; 60 | images[1] = ImageIO.read(new URL(urlcape)); 61 | } 62 | return images; 63 | } catch (NullPointerException e) { 64 | System.out 65 | .println("The Mojang servers denied the request. Wait a minute or so until you are allowed to get the texture again." + linecode); 66 | throw new NullPointerException(); 67 | } catch (IOException e2) { 68 | System.out.println("The user does not exist- ErrorLineCode=" + linecode + "."); 69 | throw new IOException(); 70 | } 71 | } 72 | 73 | @SuppressWarnings("deprecation") 74 | public static void createStatue(BufferedImage[] images, Location center, 75 | Direction dir) { 76 | BufferedImage skin = images[0]; 77 | BufferedImage cape = images[1]; 78 | 79 | Direction front = dir; 80 | Direction back = null; 81 | Direction left = null; 82 | Direction right = null; 83 | Direction flat = null; 84 | 85 | switch (front) { 86 | case UP_EAST: 87 | back = Direction.UP_WEST; 88 | right = Direction.UP_NORTH; 89 | left = Direction.UP_SOUTH; 90 | flat = Direction.FLAT_SOUTHEAST; 91 | break; 92 | case UP_WEST: 93 | back = Direction.UP_EAST; 94 | right = Direction.UP_SOUTH; 95 | left = Direction.UP_NORTH; 96 | flat = Direction.FLAT_NORTHWEST; 97 | break; 98 | case UP_NORTH: 99 | back = Direction.UP_SOUTH; 100 | right = Direction.UP_EAST; 101 | left = Direction.UP_WEST; 102 | flat = Direction.FLAT_SOUTHEAST; 103 | break; 104 | case UP_SOUTH: 105 | back = Direction.UP_NORTH; 106 | right = Direction.UP_WEST; 107 | left = Direction.UP_EAST; 108 | flat = Direction.FLAT_NORTHWEST; 109 | break; 110 | default: 111 | break; 112 | } 113 | /** 114 | * 115 | * This code would be right, If the direction the block is facing is the 116 | * same as the direction of the wall. 117 | * 118 | * switch (front) { 119 | * 120 | * case UP_SOUTH: back = Direction.UP_NORTH; right = Direction.UP_WEST; 121 | * left = Direction.UP_EAST; flat = Direction.FLAT_SOUTHWEST; break; 122 | * case UP_NORTH: back = Direction.UP_SOUTH; right = Direction.UP_EAST; 123 | * left = Direction.UP_WEST; flat = Direction.FLAT_NORTHEAST; 124 | * 125 | * break; case UP_EAST: back = Direction.UP_WEST; right = 126 | * Direction.UP_SOUTH; left = Direction.UP_NORTH; flat = 127 | * Direction.FLAT_SOUTHEAST; break; case UP_WEST: back = 128 | * Direction.UP_EAST; right = Direction.UP_NORTH; left = 129 | * Direction.UP_SOUTH; flat = Direction.FLAT_NORTHWEST; break; default: 130 | * break; } 131 | */ 132 | final Location loc = center.clone(); 133 | // legs (left) 134 | { 135 | a(2, 136 | 0, 137 | -3, 138 | loc, 139 | left, 140 | front, 141 | RGBBlockColor.createResizedCopy( 142 | skin.getSubimage(0, 32 - 12, 4, 12), 24, false)); 143 | a(-1, 144 | 0, 145 | 0, 146 | loc, 147 | right, 148 | front, 149 | RGBBlockColor.createResizedCopy( 150 | skin.getSubimage(0 + 8, 32 - 12, 4, 12), 24, false)); 151 | a(2, 152 | 0, 153 | -3, 154 | loc, 155 | front, 156 | front, 157 | RGBBlockColor.createResizedCopy( 158 | skin.getSubimage(0 + 4, 32 - 12, 4, 12), 24, false)); 159 | a(-1, 0, 0, loc, back, front, RGBBlockColor.createResizedCopy( 160 | skin.getSubimage(0 + 12, 32 - 12, 4, 12), 24, false)); 161 | } 162 | 163 | // Legs (right) 164 | { 165 | int x = 16; 166 | int y = 64; 167 | if (skin.getHeight() == 32) { 168 | x = 0; 169 | y = 32; 170 | } 171 | a(2, 172 | 0, 173 | 1, 174 | loc, 175 | left, 176 | front, 177 | RGBBlockColor.createResizedCopy( 178 | skin.getSubimage(x, y - 12, 4, 12), 24, false)); 179 | a(-1, 180 | 0, 181 | 4, 182 | loc, 183 | right, 184 | front, 185 | RGBBlockColor.createResizedCopy( 186 | skin.getSubimage(x + 8, y - 12, 4, 12), 24, false)); 187 | a(2, 188 | 0, 189 | 1, 190 | loc, 191 | front, 192 | front, 193 | RGBBlockColor.createResizedCopy( 194 | skin.getSubimage(x + 4, y - 12, 4, 12), 24, false)); 195 | a(-1, 196 | 0, 197 | 4, 198 | loc, 199 | back, 200 | front, 201 | RGBBlockColor.createResizedCopy( 202 | skin.getSubimage(x + 12, y - 12, 4, 12), 24, false)); 203 | } 204 | 205 | // arm (left) 206 | { 207 | a(-1, 208 | 23, 209 | -3 + 8, 210 | loc, 211 | flat, 212 | front, 213 | RGBBlockColor.createResizedCopy( 214 | skin.getSubimage(40 + 4, 16, 4, 4), 8, false)); 215 | a(-1, 216 | 12, 217 | -3 + 8, 218 | loc, 219 | flat, 220 | front, 221 | RGBBlockColor.createResizedCopy( 222 | skin.getSubimage(40 + 4 + 4, 16, 4, 4), 8, false)); 223 | 224 | a(2, 225 | 12, 226 | -3 + 8, 227 | loc, 228 | left, 229 | front, 230 | RGBBlockColor.createResizedCopy( 231 | skin.getSubimage(40, 20, 4, 12), 24, false)); 232 | a(-1, 233 | 12, 234 | 8, 235 | loc, 236 | right, 237 | front, 238 | RGBBlockColor.createResizedCopy( 239 | skin.getSubimage(40 + 8, 20, 4, 12), 24, false)); 240 | a(2, 241 | 12, 242 | -3 + 8, 243 | loc, 244 | front, 245 | front, 246 | RGBBlockColor.createResizedCopy( 247 | skin.getSubimage(40 + 4, 20, 4, 12), 24, false)); 248 | a(-1, 249 | 12, 250 | 8, 251 | loc, 252 | back, 253 | front, 254 | RGBBlockColor.createResizedCopy( 255 | skin.getSubimage(40 + 12, 20, 4, 12), 24, false)); 256 | } 257 | // arm (right) 258 | { 259 | int x = 32; 260 | int y = 20; 261 | if (skin.getHeight() == 32) { 262 | x = 32; 263 | y = 20; 264 | } 265 | 266 | // Tops and bottoms 267 | 268 | a(2, 269 | 12, 270 | -3 - 4, 271 | loc, 272 | left, 273 | front, 274 | RGBBlockColor.createResizedCopy( 275 | skin.getSubimage(x, y, 4, 12), 24, false)); 276 | a(-1, 277 | 12, 278 | -4, 279 | loc, 280 | right, 281 | front, 282 | RGBBlockColor.createResizedCopy( 283 | skin.getSubimage(x + 8, y, 4, 12), 24, false)); 284 | a(-1, 285 | 12, 286 | -3 - 4, 287 | loc, 288 | front, 289 | front, 290 | RGBBlockColor.createResizedCopy( 291 | skin.getSubimage(x + 4, y, 4, 12), 24, false)); 292 | a(2, 293 | 12, 294 | -4, 295 | loc, 296 | back, 297 | front, 298 | RGBBlockColor.createResizedCopy( 299 | skin.getSubimage(x + 12, y, 4, 12), 24, false)); 300 | 301 | a(-1, 302 | 23, 303 | -3 - 4, 304 | loc, 305 | flat, 306 | front, 307 | RGBBlockColor.createResizedCopy( 308 | skin.getSubimage(x + 4, y - 4, 4, 4), 8, false)); 309 | a(-1, 310 | 12, 311 | -3 - 4, 312 | loc, 313 | flat, 314 | front, 315 | RGBBlockColor.createResizedCopy( 316 | skin.getSubimage(x + 4 + 4, y - 4, 4, 4), 8, false)); 317 | } 318 | // chest 319 | { 320 | a(2, 321 | 12, 322 | -3, 323 | loc, 324 | left, 325 | front, 326 | RGBBlockColor.createResizedCopy( 327 | skin.getSubimage(16, 20, 4, 12), 24, false)); 328 | a(-1, 329 | 12, 330 | 4, 331 | loc, 332 | right, 333 | front, 334 | RGBBlockColor.createResizedCopy( 335 | skin.getSubimage(16 + 12, 20, 4, 12), 24, false)); 336 | a(2, 337 | 12, 338 | -3, 339 | loc, 340 | front, 341 | front, 342 | RGBBlockColor.createResizedCopy( 343 | skin.getSubimage(16 + 4, 20, 8, 12), 24, false)); 344 | a(-1, 345 | 12, 346 | 4, 347 | loc, 348 | back, 349 | front, 350 | RGBBlockColor.createResizedCopy( 351 | skin.getSubimage(16 + 16, 20, 8, 12), 24, false)); 352 | } 353 | //Helmet bottom 354 | { 355 | a(-3, 356 | 23, 357 | -3, 358 | loc, 359 | flat, 360 | front, 361 | RGBBlockColor.createResizedCopy( 362 | skin.getSubimage(32 + 16, 0, 8, 8), 16, true), true); 363 | a(-3, 364 | 32, 365 | -3, 366 | loc, 367 | flat, 368 | front, 369 | RGBBlockColor.createResizedCopy( 370 | skin.getSubimage(32 + 8, 0, 8, 8), 16, true), true); 371 | } 372 | 373 | // head 374 | { 375 | a(-3, 376 | 24, 377 | -3, 378 | loc, 379 | flat, 380 | front, 381 | RGBBlockColor.createResizedCopy( 382 | skin.getSubimage(16, 0, 8, 8), 16, false)); 383 | a(-3, 384 | 31, 385 | -3, 386 | loc, 387 | flat, 388 | front, 389 | RGBBlockColor.createResizedCopy( 390 | skin.getSubimage(8, 0, 8, 8), 16, false)); 391 | 392 | a(-3, 393 | 24, 394 | -3, 395 | loc, 396 | right, 397 | front, 398 | RGBBlockColor.createResizedCopy( 399 | skin.getSubimage(0, 8, 8, 8), 16, false)); 400 | a(4, 401 | 24, 402 | 4, 403 | loc, 404 | left, 405 | front, 406 | RGBBlockColor.createResizedCopy( 407 | skin.getSubimage(16, 8, 8, 8), 16, false)); 408 | a(-3, 409 | 24, 410 | 4, 411 | loc, 412 | back, 413 | front, 414 | RGBBlockColor.createResizedCopy( 415 | skin.getSubimage(24, 8, 8, 8), 16, false)); 416 | a(4, 417 | 24, 418 | -3, 419 | loc, 420 | front, 421 | front, 422 | RGBBlockColor.createResizedCopy( 423 | skin.getSubimage(8, 8, 8, 8), 16, false)); 424 | } 425 | // helmet 426 | { 427 | 428 | a(-3, 429 | 24, 430 | -4,//-3 431 | loc, 432 | right, 433 | front, 434 | RGBBlockColor.createResizedCopy( 435 | skin.getSubimage(32 + 0, 8, 8, 8), 16, true), true); 436 | a(4, 437 | 24, 438 | 5,//4, 439 | loc, 440 | left, 441 | front, 442 | RGBBlockColor.createResizedCopy( 443 | skin.getSubimage(32 + 16, 8, 8, 8), 16, true), true); 444 | a(-4,//-3, 445 | 24, 446 | 4, 447 | loc, 448 | back, 449 | front, 450 | RGBBlockColor.createResizedCopy( 451 | skin.getSubimage(32 + 24, 8, 8, 8), 16, true), true); 452 | a(5,//4, 453 | 24, 454 | -3, 455 | loc, 456 | front, 457 | front, 458 | RGBBlockColor.createResizedCopy( 459 | skin.getSubimage(32 + 8, 8, 8, 8), 16, true), true); 460 | } 461 | 462 | if (cape != null) { 463 | a(-6 + 4, 464 | 6, 465 | -9 + 4, 466 | loc, 467 | front, 468 | front, 469 | RGBBlockColor.createResizedCopy( 470 | cape.getSubimage(0, 0, 12, 18), 18 * 2, true), true); 471 | } 472 | 473 | } 474 | 475 | private static void a(int x, int y, int z, Location loc, Direction d, 476 | Direction f, BufferedImage skin2) { 477 | a(x, y, z, loc, d, f, skin2, false); 478 | } 479 | 480 | private static void a(int x, int y, int z, Location loc, Direction d, 481 | Direction f, BufferedImage skin2, boolean enableTrans) { 482 | 483 | if (d == Direction.UP_EAST) { 484 | d = Direction.UP_SOUTH; 485 | } else if (d == Direction.UP_WEST) { 486 | d = Direction.UP_NORTH; 487 | } else if (d == Direction.UP_NORTH) { 488 | d = Direction.UP_EAST; 489 | /* 490 | * if (f == Direction.UP_EAST || f == Direction.UP_WEST) { d = 491 | * Direction.UP_EAST; } else { d = Direction.UP_WEST; } 492 | */ 493 | } else if (d == Direction.UP_SOUTH) { 494 | d = Direction.UP_WEST; 495 | /* 496 | * if (f == Direction.UP_EAST || f == Direction.UP_WEST) { d = 497 | * Direction.UP_WEST; } else { d = Direction.UP_EAST; } 498 | */ 499 | } 500 | BufferedImage temp = skin2; 501 | Pixel[][] result = RGBBlockColor.convertTo2DWithoutUsingGetRGB(temp); 502 | new AsyncImageHolder(result, null, getOffset(loc, f, x, y, z), d, temp, 503 | enableTrans).loadImage(false); 504 | } 505 | 506 | public static Location getOffset(Location start, Direction d, double xoff, 507 | int yoff, double zoff) { 508 | if (d == Direction.UP_SOUTH) { 509 | return start.clone().add(-zoff, yoff, -xoff); 510 | } 511 | if (d == Direction.UP_NORTH) { 512 | return start.clone().add(zoff, yoff, xoff); 513 | } 514 | if (d == Direction.UP_EAST) { 515 | return start.clone().add(xoff, yoff, zoff); 516 | } 517 | if (d == Direction.UP_WEST) { 518 | return start.clone().add(-xoff, yoff, -zoff); 519 | } 520 | return start.clone().add(xoff, yoff, zoff); 521 | } 522 | 523 | } 524 | -------------------------------------------------------------------------------- /src/me/zombie_striker/pixelprinter/util/UndoUtil.java: -------------------------------------------------------------------------------- 1 | package me.zombie_striker.pixelprinter.util; 2 | 3 | import org.bukkit.Location; 4 | 5 | import java.util.HashMap; 6 | import java.util.Set; 7 | 8 | public class UndoUtil { 9 | 10 | static HashMap savedLocs = new HashMap<>(); 11 | 12 | public static String verifyNewName(String start) { 13 | String test = start; 14 | int id = 0; 15 | while (savedLocs.containsKey(test)) { 16 | id++; 17 | test = test + "(" + id + ")"; 18 | } 19 | return test; 20 | } 21 | 22 | public static void addNewSnapshot(String name, Location start, Location end) { 23 | savedLocs.put(verifyNewName(name), new BlockTypeSnapshot(start, end)); 24 | } 25 | 26 | public static void undo(String name) { 27 | BlockTypeSnapshot bts = savedLocs.get(name); 28 | if (bts != null) 29 | bts.undo(); 30 | } 31 | 32 | public static void remove(String name) { 33 | savedLocs.remove(name); 34 | } 35 | 36 | public static Set getSnapshots() { 37 | return savedLocs.keySet(); 38 | } 39 | 40 | public static boolean snapshotExists(String name) { 41 | for (String s : savedLocs.keySet()) { 42 | if (s.equals(name)) 43 | return true; 44 | } 45 | return false; 46 | } 47 | 48 | } 49 | -------------------------------------------------------------------------------- /src/me/zombie_striker/pixelprinter/util/Update13Handler.java: -------------------------------------------------------------------------------- 1 | package me.zombie_striker.pixelprinter.util; 2 | 3 | import org.bukkit.Bukkit; 4 | import org.bukkit.block.BlockFace; 5 | import org.bukkit.block.BlockState; 6 | 7 | public class Update13Handler { 8 | 9 | public static boolean isFacing(BlockState bs, BlockFace bf2) { 10 | try { 11 | return (((org.bukkit.block.data.Directional) bs.getBlock().getBlockData()).getFacing() == bf2); 12 | } catch (Error | Exception e45) { 13 | } 14 | return false; 15 | } 16 | 17 | public static BlockFace getFacing(BlockState bs) { 18 | try { 19 | return (((org.bukkit.block.data.Directional) bs.getBlock().getBlockData()).getFacing()); 20 | } catch (Error | Exception e45) { 21 | } 22 | return null; 23 | } 24 | 25 | public static boolean isDirectional(BlockState bs) { 26 | try { 27 | return (bs.getBlock().getBlockData() instanceof org.bukkit.block.data.Directional); 28 | } catch (Error | Exception e45) { 29 | } 30 | return false; 31 | } 32 | 33 | public static void setFacing(BlockState bs, BlockFace bf) { 34 | try { 35 | org.bukkit.block.data.Directional d = ((org.bukkit.block.data.Directional) bs.getBlockData()); 36 | d.setFacing(bf); 37 | bs.setBlockData(d); 38 | bs.update(true, false); 39 | } catch (Error | Exception e45) { 40 | 41 | } 42 | } 43 | 44 | } 45 | --------------------------------------------------------------------------------