diff --git a/ItemDisguise/.classpath b/ItemDisguise/.classpath index b4cf4f7f..24f68324 100644 --- a/ItemDisguise/.classpath +++ b/ItemDisguise/.classpath @@ -3,6 +3,6 @@ - + diff --git a/License.txt b/License.txt new file mode 100644 index 00000000..d159169d --- /dev/null +++ b/License.txt @@ -0,0 +1,339 @@ + GNU GENERAL PUBLIC LICENSE + Version 2, June 1991 + + Copyright (C) 1989, 1991 Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +License is intended to guarantee your freedom to share and change free +software--to make sure the software is free for all its users. This +General Public License applies to most of the Free Software +Foundation's software and to any other program whose authors commit to +using it. (Some other Free Software Foundation software is covered by +the GNU Lesser General Public License instead.) You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +this service if you wish), that you receive source code or can get it +if you want it, that you can change the software or use pieces of it +in new free programs; and that you know you can do these things. + + To protect your rights, we need to make restrictions that forbid +anyone to deny you these rights or to ask you to surrender the rights. +These restrictions translate to certain responsibilities for you if you +distribute copies of the software, or if you modify it. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must give the recipients all the rights that +you have. You must make sure that they, too, receive or can get the +source code. And you must show them these terms so they know their +rights. + + We protect your rights with two steps: (1) copyright the software, and +(2) offer you this license which gives you legal permission to copy, +distribute and/or modify the software. + + Also, for each author's protection and ours, we want to make certain +that everyone understands that there is no warranty for this free +software. If the software is modified by someone else and passed on, we +want its recipients to know that what they have is not the original, so +that any problems introduced by others will not reflect on the original +authors' reputations. + + Finally, any free program is threatened constantly by software +patents. We wish to avoid the danger that redistributors of a free +program will individually obtain patent licenses, in effect making the +program proprietary. To prevent this, we have made it clear that any +patent must be licensed for everyone's free use or not licensed at all. + + The precise terms and conditions for copying, distribution and +modification follow. + + GNU GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License applies to any program or other work which contains +a notice placed by the copyright holder saying it may be distributed +under the terms of this General Public License. The "Program", below, +refers to any such program or work, and a "work based on the Program" +means either the Program or any derivative work under copyright law: +that is to say, a work containing the Program or a portion of it, +either verbatim or with modifications and/or translated into another +language. (Hereinafter, translation is included without limitation in +the term "modification".) Each licensee is addressed as "you". + +Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running the Program is not restricted, and the output from the Program +is covered only if its contents constitute a work based on the +Program (independent of having been made by running the Program). +Whether that is true depends on what the Program does. + + 1. You may copy and distribute verbatim copies of the Program's +source code as you receive it, in any medium, provided that you +conspicuously and appropriately publish on each copy an appropriate +copyright notice and disclaimer of warranty; keep intact all the +notices that refer to this License and to the absence of any warranty; +and give any other recipients of the Program a copy of this License +along with the Program. + +You may charge a fee for the physical act of transferring a copy, and +you may at your option offer warranty protection in exchange for a fee. + + 2. You may modify your copy or copies of the Program or any portion +of it, thus forming a work based on the Program, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) You must cause the modified files to carry prominent notices + stating that you changed the files and the date of any change. + + b) You must cause any work that you distribute or publish, that in + whole or in part contains or is derived from the Program or any + part thereof, to be licensed as a whole at no charge to all third + parties under the terms of this License. + + c) If the modified program normally reads commands interactively + when run, you must cause it, when started running for such + interactive use in the most ordinary way, to print or display an + announcement including an appropriate copyright notice and a + notice that there is no warranty (or else, saying that you provide + a warranty) and that users may redistribute the program under + these conditions, and telling the user how to view a copy of this + License. (Exception: if the Program itself is interactive but + does not normally print such an announcement, your work based on + the Program is not required to print an announcement.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Program, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Program, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Program. + +In addition, mere aggregation of another work not based on the Program +with the Program (or with a work based on the Program) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may copy and distribute the Program (or a work based on it, +under Section 2) in object code or executable form under the terms of +Sections 1 and 2 above provided that you also do one of the following: + + a) Accompany it with the complete corresponding machine-readable + source code, which must be distributed under the terms of Sections + 1 and 2 above on a medium customarily used for software interchange; or, + + b) Accompany it with a written offer, valid for at least three + years, to give any third party, for a charge no more than your + cost of physically performing source distribution, a complete + machine-readable copy of the corresponding source code, to be + distributed under the terms of Sections 1 and 2 above on a medium + customarily used for software interchange; or, + + c) Accompany it with the information you received as to the offer + to distribute corresponding source code. (This alternative is + allowed only for noncommercial distribution and only if you + received the program in object code or executable form with such + an offer, in accord with Subsection b above.) + +The source code for a work means the preferred form of the work for +making modifications to it. For an executable work, complete source +code means all the source code for all modules it contains, plus any +associated interface definition files, plus the scripts used to +control compilation and installation of the executable. However, as a +special exception, the source code distributed need not include +anything that is normally distributed (in either source or binary +form) with the major components (compiler, kernel, and so on) of the +operating system on which the executable runs, unless that component +itself accompanies the executable. + +If distribution of executable or object code is made by offering +access to copy from a designated place, then offering equivalent +access to copy the source code from the same place counts as +distribution of the source code, even though third parties are not +compelled to copy the source along with the object code. + + 4. You may not copy, modify, sublicense, or distribute the Program +except as expressly provided under this License. Any attempt +otherwise to copy, modify, sublicense or distribute the Program is +void, and will automatically terminate your rights under this License. +However, parties who have received copies, or rights, from you under +this License will not have their licenses terminated so long as such +parties remain in full compliance. + + 5. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Program or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Program (or any work based on the +Program), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Program or works based on it. + + 6. Each time you redistribute the Program (or any work based on the +Program), the recipient automatically receives a license from the +original licensor to copy, distribute or modify the Program subject to +these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties to +this License. + + 7. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Program at all. For example, if a patent +license would not permit royalty-free redistribution of the Program by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Program. + +If any portion of this section is held invalid or unenforceable under +any particular circumstance, the balance of the section is intended to +apply and the section as a whole is intended to apply in other +circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system, which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 8. If the distribution and/or use of the Program is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Program under this License +may add an explicit geographical distribution limitation excluding +those countries, so that distribution is permitted only in or among +countries not thus excluded. In such case, this License incorporates +the limitation as if written in the body of this License. + + 9. The Free Software Foundation may publish revised and/or new versions +of the General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + +Each version is given a distinguishing version number. If the Program +specifies a version number of this License which applies to it and "any +later version", you have the option of following the terms and conditions +either of that version or of any later version published by the Free +Software Foundation. If the Program does not specify a version number of +this License, you may choose any version ever published by the Free Software +Foundation. + + 10. If you wish to incorporate parts of the Program into other free +programs whose distribution conditions are different, write to the author +to ask for permission. For software which is copyrighted by the Free +Software Foundation, write to the Free Software Foundation; we sometimes +make exceptions for this. Our decision will be guided by the two goals +of preserving the free status of all derivatives of our free software and +of promoting the sharing and reuse of software generally. + + NO WARRANTY + + 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY +FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN +OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES +PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED +OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS +TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE +PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, +REPAIR OR CORRECTION. + + 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR +REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, +INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING +OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED +TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY +YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER +PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE +POSSIBILITY OF SUCH DAMAGES. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +convey the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + +Also add information on how to contact you by electronic and paper mail. + +If the program is interactive, make it output a short notice like this +when it starts in an interactive mode: + + Gnomovision version 69, Copyright (C) year name of author + Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, the commands you use may +be called something other than `show w' and `show c'; they could even be +mouse-clicks or menu items--whatever suits your program. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the program, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the program + `Gnomovision' (which makes passes at compilers) written by James Hacker. + + , 1 April 1989 + Ty Coon, President of Vice + +This General Public License does not permit incorporating your program into +proprietary programs. If your program is a subroutine library, you may +consider it more useful to permit linking proprietary applications with the +library. If this is what you want to do, use the GNU Lesser General +Public License instead of this License. diff --git a/ProtocolLib/.classpath b/ProtocolLib/.classpath index 0bc481ca..4134d657 100644 --- a/ProtocolLib/.classpath +++ b/ProtocolLib/.classpath @@ -1,14 +1,17 @@ - - - - + + + + - + - - - + + + + + + diff --git a/ProtocolLib/.gitignore b/ProtocolLib/.gitignore new file mode 100644 index 00000000..9f970225 --- /dev/null +++ b/ProtocolLib/.gitignore @@ -0,0 +1 @@ +target/ \ No newline at end of file diff --git a/ProtocolLib/.project b/ProtocolLib/.project index dd7e4061..43010533 100644 --- a/ProtocolLib/.project +++ b/ProtocolLib/.project @@ -10,8 +10,14 @@ + + org.eclipse.m2e.core.maven2Builder + + + + org.eclipse.m2e.core.maven2Nature org.eclipse.jdt.core.javanature diff --git a/ProtocolLib/.settings/org.eclipse.jdt.core.prefs b/ProtocolLib/.settings/org.eclipse.jdt.core.prefs index 54e493c0..6428c680 100644 --- a/ProtocolLib/.settings/org.eclipse.jdt.core.prefs +++ b/ProtocolLib/.settings/org.eclipse.jdt.core.prefs @@ -8,4 +8,5 @@ org.eclipse.jdt.core.compiler.debug.localVariable=generate org.eclipse.jdt.core.compiler.debug.sourceFile=generate org.eclipse.jdt.core.compiler.problem.assertIdentifier=error org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning org.eclipse.jdt.core.compiler.source=1.6 diff --git a/ProtocolLib/.settings/org.eclipse.m2e.core.prefs b/ProtocolLib/.settings/org.eclipse.m2e.core.prefs new file mode 100644 index 00000000..14b697b7 --- /dev/null +++ b/ProtocolLib/.settings/org.eclipse.m2e.core.prefs @@ -0,0 +1,4 @@ +activeProfiles= +eclipse.preferences.version=1 +resolveWorkspaceProjects=true +version=1 diff --git a/ProtocolLib/Java.xml b/ProtocolLib/Java.xml deleted file mode 100644 index 33c14105..00000000 --- a/ProtocolLib/Java.xml +++ /dev/null @@ -1,14 +0,0 @@ - - - - - - - - - - - - - - diff --git a/ProtocolLib/dependency-reduced-pom.xml b/ProtocolLib/dependency-reduced-pom.xml new file mode 100644 index 00000000..ae2475b5 --- /dev/null +++ b/ProtocolLib/dependency-reduced-pom.xml @@ -0,0 +1,153 @@ + + + + oss-parent + org.sonatype.oss + 7 + ../pom.xml/pom.xml + + 4.0.0 + com.comphenix.protocol + ProtocolLib + ProtocolLib + 1.3.1 + Provides read/write access to the Minecraft protocol. + http://dev.bukkit.org/server-mods/protocollib/ + + + aadnk + Kristian S. Stangeland + kr_stang@hotmail.com + http://comphenix.net/ + + developer + maintainer + + 1 + + + + + GNU GENERAL PUBLIC LICENSE - Version 2, June 1991 + http://www.gnu.org/licenses/gpl-2.0.txt + repo + + + + scm:git:git://github.com/aadnk/ProtocolLib.git + scm:git:git@github.com:aadnk/ProtocolLib.git + https://github.com/aadnk/ProtocolLib + + + src/main/java + src/test/java + + + src/main/java + + **/*.java + + + + + + maven-shade-plugin + 2.0 + + + package + + shade + + + + + org.bukkit:craftbukkit + junit:junit + + + + + + + + maven-compiler-plugin + 2.3.2 + + 1.6 + 1.6 + + + + + + + release-sign-artifacts + + + + maven-source-plugin + 2.2 + + + attach-sources + + jar + + + + + + maven-javadoc-plugin + 2.9 + + + attach-javadocs + + jar + + + + + + maven-gpg-plugin + 1.4 + + + sign-artifacts + verify + + sign + + + + + + + + + + + org.bukkit + craftbukkit + 1.3.2-R1.1-SNAPSHOT + compile + + + junit + junit + 4.10 + test + + + hamcrest-core + org.hamcrest + + + + + + UTF-8 + + + diff --git a/ProtocolLib/lib/cglib-nodep-2.2.3.jar b/ProtocolLib/lib/cglib-nodep-2.2.3.jar deleted file mode 100644 index 35d6d7c3..00000000 Binary files a/ProtocolLib/lib/cglib-nodep-2.2.3.jar and /dev/null differ diff --git a/ProtocolLib/pom.xml b/ProtocolLib/pom.xml new file mode 100644 index 00000000..70c59606 --- /dev/null +++ b/ProtocolLib/pom.xml @@ -0,0 +1,173 @@ + + 4.0.0 + com.comphenix.protocol + ProtocolLib + 1.3.1 + jar + Provides read/write access to the Minecraft protocol. + + + UTF-8 + + + + org.sonatype.oss + oss-parent + 7 + + + + src/main/java + src/test/java + + + src/main/java + + **/*.java + + + + + + + org.apache.maven.plugins + maven-shade-plugin + 2.0 + + + package + + shade + + + + + org.bukkit:craftbukkit + junit:junit + + + + + + + + + maven-compiler-plugin + 2.3.2 + + 1.6 + 1.6 + + + + + + + + release-sign-artifacts + + + performRelease + true + + + + + + org.apache.maven.plugins + maven-source-plugin + 2.2 + + + attach-sources + + jar + + + + + + + org.apache.maven.plugins + maven-javadoc-plugin + 2.9 + + + attach-javadocs + + jar + + + + + + + org.apache.maven.plugins + maven-gpg-plugin + 1.4 + + + sign-artifacts + verify + + sign + + + + + + + + + + + http://dev.bukkit.org/server-mods/protocollib/ + ProtocolLib + + + scm:git:git://github.com/aadnk/ProtocolLib.git + scm:git:git@github.com:aadnk/ProtocolLib.git + https://github.com/aadnk/ProtocolLib + + + + + GNU GENERAL PUBLIC LICENSE - Version 2, June 1991 + http://www.gnu.org/licenses/gpl-2.0.txt + repo + + + + + + aadnk + Kristian S. Stangeland + kr_stang@hotmail.com + http://comphenix.net/ + + developer + maintainer + + 1 + + + + + + cglib + cglib-nodep + 2.2.2 + + + org.bukkit + craftbukkit + 1.3.2-R1.1-SNAPSHOT + + + junit + junit + 4.10 + test + + + \ No newline at end of file diff --git a/ProtocolLib/src/com/comphenix/protocol/async/AsyncRunnable.java b/ProtocolLib/src/com/comphenix/protocol/async/AsyncRunnable.java deleted file mode 100644 index 2c0004d9..00000000 --- a/ProtocolLib/src/com/comphenix/protocol/async/AsyncRunnable.java +++ /dev/null @@ -1,35 +0,0 @@ -package com.comphenix.protocol.async; - -/** - * A runnable representing a asynchronous event listener. - * - * @author Kristian - */ -public interface AsyncRunnable extends Runnable { - - /** - * Retrieve a unique worker ID. - * @return Unique worker ID. - */ - public int getID(); - - /** - * Stop the given runnable. - *

- * This may not occur right away. - * @return TRUE if the thread was stopped, FALSE if it was already stopped. - */ - public boolean stop() throws InterruptedException; - - /** - * Determine if we're running or not. - * @return TRUE if we're running, FALSE otherwise. - */ - public boolean isRunning(); - - /** - * Determine if this runnable has already run its course. - * @return TRUE if it has been stopped, FALSE otherwise. - */ - boolean isFinished(); -} diff --git a/ProtocolLib/src/com/comphenix/protocol/async/PacketEventHolder.java b/ProtocolLib/src/com/comphenix/protocol/async/PacketEventHolder.java deleted file mode 100644 index 429d5caf..00000000 --- a/ProtocolLib/src/com/comphenix/protocol/async/PacketEventHolder.java +++ /dev/null @@ -1,40 +0,0 @@ -package com.comphenix.protocol.async; - -import com.comphenix.protocol.events.PacketEvent; -import com.google.common.base.Preconditions; -import com.google.common.collect.ComparisonChain; - -/** - * Provides a comparable to a packet event. - * - * @author Kristian - */ -class PacketEventHolder implements Comparable { - - private PacketEvent event; - - /** - * A wrapper that ensures the packet event is ordered by sending index. - * @param event - packet event to wrap. - */ - public PacketEventHolder(PacketEvent event) { - this.event = Preconditions.checkNotNull(event, "Event must be non-null"); - } - - /** - * Retrieve the stored event. - * @return The stored event. - */ - public PacketEvent getEvent() { - return event; - } - - @Override - public int compareTo(PacketEventHolder other) { - AsyncMarker marker = other != null ? other.getEvent().getAsyncMarker() : null; - - return ComparisonChain.start(). - compare(event.getAsyncMarker(), marker). - result(); - } -} diff --git a/ProtocolLib/src/com/comphenix/protocol/injector/ListenerInvoker.java b/ProtocolLib/src/com/comphenix/protocol/injector/ListenerInvoker.java deleted file mode 100644 index e5bc0e4b..00000000 --- a/ProtocolLib/src/com/comphenix/protocol/injector/ListenerInvoker.java +++ /dev/null @@ -1,27 +0,0 @@ -package com.comphenix.protocol.injector; - -import net.minecraft.server.Packet; - -import com.comphenix.protocol.events.PacketEvent; - -public interface ListenerInvoker { - - /** - * Invokes the given packet event for every registered listener. - * @param event - the packet event to invoke. - */ - public abstract void invokePacketRecieving(PacketEvent event); - - /** - * Invokes the given packet event for every registered listener. - * @param event - the packet event to invoke. - */ - public abstract void invokePacketSending(PacketEvent event); - - /** - * Retrieve the associated ID of a packet. - * @param packet - the packet. - * @return The packet ID. - */ - public abstract int getPacketID(Packet packet); -} \ No newline at end of file diff --git a/ProtocolLib/src/com/comphenix/protocol/reflect/compiler/CompileListener.java b/ProtocolLib/src/com/comphenix/protocol/reflect/compiler/CompileListener.java deleted file mode 100644 index 5ab92978..00000000 --- a/ProtocolLib/src/com/comphenix/protocol/reflect/compiler/CompileListener.java +++ /dev/null @@ -1,17 +0,0 @@ -package com.comphenix.protocol.reflect.compiler; - -import com.comphenix.protocol.reflect.StructureModifier; - -/** - * Used to save the result of an compilation. - * - * @author Kristian - * @param - type of the structure modifier field. - */ -public interface CompileListener { - /** - * Invoked when a structure modifier has been successfully compiled. - * @param compiledModifier - the compiled structure modifier. - */ - public void onCompiled(StructureModifier compiledModifier); -} diff --git a/ProtocolLib/src/com/comphenix/protocol/reflect/instances/InstanceProvider.java b/ProtocolLib/src/com/comphenix/protocol/reflect/instances/InstanceProvider.java deleted file mode 100644 index 98775af7..00000000 --- a/ProtocolLib/src/com/comphenix/protocol/reflect/instances/InstanceProvider.java +++ /dev/null @@ -1,18 +0,0 @@ -package com.comphenix.protocol.reflect.instances; - -import javax.annotation.Nullable; - -/** - * Represents a type generator for specific types. - * - * @author Kristian - */ -public interface InstanceProvider { - - /** - * Create an instance given a type, if possible. - * @param type - type to create. - * @return The instance, or NULL if the type cannot be created. - */ - public abstract Object create(@Nullable Class type); -} \ No newline at end of file diff --git a/ProtocolLib/src/com/comphenix/protocol/Application.java b/ProtocolLib/src/main/java/com/comphenix/protocol/Application.java similarity index 93% rename from ProtocolLib/src/com/comphenix/protocol/Application.java rename to ProtocolLib/src/main/java/com/comphenix/protocol/Application.java index 1ba08ce7..a4ef1376 100644 --- a/ProtocolLib/src/com/comphenix/protocol/Application.java +++ b/ProtocolLib/src/main/java/com/comphenix/protocol/Application.java @@ -17,6 +17,11 @@ package com.comphenix.protocol; +/** + * Ignore this class. + * + * @author Kristian + */ public class Application { public static void main(String[] args) { // For now, though we might consider making a proper application diff --git a/ProtocolLib/src/com/comphenix/protocol/AsynchronousManager.java b/ProtocolLib/src/main/java/com/comphenix/protocol/AsynchronousManager.java similarity index 62% rename from ProtocolLib/src/com/comphenix/protocol/AsynchronousManager.java rename to ProtocolLib/src/main/java/com/comphenix/protocol/AsynchronousManager.java index 55d75f99..bd8ac97d 100644 --- a/ProtocolLib/src/com/comphenix/protocol/AsynchronousManager.java +++ b/ProtocolLib/src/main/java/com/comphenix/protocol/AsynchronousManager.java @@ -1,3 +1,20 @@ +/* + * ProtocolLib - Bukkit server library that allows access to the Minecraft protocol. + * Copyright (C) 2012 Kristian S. Stangeland + * + * This program is free software; you can redistribute it and/or modify it under the terms of the + * GNU General Public License as published by the Free Software Foundation; either version 2 of + * the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along with this program; + * if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + * 02111-1307 USA + */ + package com.comphenix.protocol; import java.util.Set; @@ -15,7 +32,6 @@ import com.comphenix.protocol.events.PacketListener; * @author Kristian */ public interface AsynchronousManager { - /** * Registers an asynchronous packet handler. *

@@ -74,4 +90,13 @@ public interface AsynchronousManager { * Remove listeners, close threads and transmit every delayed packet. */ public abstract void cleanupAll(); + + /** + * Signal that a packet is ready to be transmitted. + *

+ * This should only be called if {@link com.comphenix.protocol.async.AsyncMarker#incrementProcessingDelay() AsyncMarker.incrementProcessingDelay()} + * has been called previously. + * @param packet - packet to signal. + */ + public abstract void signalPacketTransmission(PacketEvent packet); } \ No newline at end of file diff --git a/ProtocolLib/src/com/comphenix/protocol/PacketStream.java b/ProtocolLib/src/main/java/com/comphenix/protocol/PacketStream.java similarity index 67% rename from ProtocolLib/src/com/comphenix/protocol/PacketStream.java rename to ProtocolLib/src/main/java/com/comphenix/protocol/PacketStream.java index 464f6f5c..fbffae75 100644 --- a/ProtocolLib/src/com/comphenix/protocol/PacketStream.java +++ b/ProtocolLib/src/main/java/com/comphenix/protocol/PacketStream.java @@ -1,3 +1,20 @@ +/* + * ProtocolLib - Bukkit server library that allows access to the Minecraft protocol. + * Copyright (C) 2012 Kristian S. Stangeland + * + * This program is free software; you can redistribute it and/or modify it under the terms of the + * GNU General Public License as published by the Free Software Foundation; either version 2 of + * the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along with this program; + * if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + * 02111-1307 USA + */ + package com.comphenix.protocol; import java.lang.reflect.InvocationTargetException; diff --git a/ProtocolLib/src/com/comphenix/protocol/Packets.java b/ProtocolLib/src/main/java/com/comphenix/protocol/Packets.java similarity index 69% rename from ProtocolLib/src/com/comphenix/protocol/Packets.java rename to ProtocolLib/src/main/java/com/comphenix/protocol/Packets.java index 587d0fdd..3b2fa253 100644 --- a/ProtocolLib/src/com/comphenix/protocol/Packets.java +++ b/ProtocolLib/src/main/java/com/comphenix/protocol/Packets.java @@ -1,5 +1,26 @@ +/* + * ProtocolLib - Bukkit server library that allows access to the Minecraft protocol. + * Copyright (C) 2012 Kristian S. Stangeland + * + * This program is free software; you can redistribute it and/or modify it under the terms of the + * GNU General Public License as published by the Free Software Foundation; either version 2 of + * the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along with this program; + * if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + * 02111-1307 USA + */ + package com.comphenix.protocol; +import java.util.Set; + +import com.comphenix.protocol.injector.PacketFilterManager; +import com.comphenix.protocol.reflect.FieldAccessException; import com.comphenix.protocol.reflect.IntEnum; /** @@ -92,6 +113,25 @@ public final class Packets { return INSTANCE; } + /** + * Determine if the given packet is a valid server packet in the current version of Minecraft. + * @param packetID - the packet to test. + * @return TRUE if this packet is supported, FALSE otherwise. + * @throws FieldAccessException If we're unable to retrieve the server packet data from Minecraft. + */ + public static boolean isSupported(int packetID) throws FieldAccessException { + return PacketFilterManager.getServerPackets().contains(packetID); + } + + /** + * Retrieve every client packet the current version of Minecraft is aware of. + * @return Every supported server packet. + * @throws FieldAccessException If we're unable to retrieve the server packet data from Minecraft. + */ + public static Set getSupported() throws FieldAccessException { + return PacketFilterManager.getServerPackets(); + } + // We only allow a single instance of this class private Server() { super(); @@ -146,6 +186,25 @@ public final class Packets { return INSTANCE; } + /** + * Determine if the given packet is a valid client packet in the current version of Minecraft. + * @param packetID - the packet to test. + * @return TRUE if this packet is supported, FALSE otherwise. + * @throws FieldAccessException If we're unable to retrieve the client packet data from Minecraft. + */ + public static boolean isSupported(int packetID) throws FieldAccessException { + return PacketFilterManager.getClientPackets().contains(packetID); + } + + /** + * Retrieve every client packet the current version of Minecraft is aware of. + * @return Every supported client packet. + * @throws FieldAccessException If we're unable to retrieve the client packet data from Minecraft. + */ + public static Set getSupported() throws FieldAccessException { + return PacketFilterManager.getClientPackets(); + } + // Like above private Client() { super(); diff --git a/ProtocolLib/src/com/comphenix/protocol/ProtocolLibrary.java b/ProtocolLib/src/main/java/com/comphenix/protocol/ProtocolLibrary.java similarity index 95% rename from ProtocolLib/src/com/comphenix/protocol/ProtocolLibrary.java rename to ProtocolLib/src/main/java/com/comphenix/protocol/ProtocolLibrary.java index 1b8a7132..ad2dab81 100644 --- a/ProtocolLib/src/com/comphenix/protocol/ProtocolLibrary.java +++ b/ProtocolLib/src/main/java/com/comphenix/protocol/ProtocolLibrary.java @@ -30,6 +30,11 @@ import com.comphenix.protocol.injector.PacketFilterManager; import com.comphenix.protocol.metrics.Statistics; import com.comphenix.protocol.reflect.compiler.BackgroundCompiler; +/** + * The main entry point for ProtocolLib. + * + * @author Kristian + */ public class ProtocolLibrary extends JavaPlugin { // There should only be one protocol manager, so we'll make it static diff --git a/ProtocolLib/src/com/comphenix/protocol/ProtocolManager.java b/ProtocolLib/src/main/java/com/comphenix/protocol/ProtocolManager.java similarity index 100% rename from ProtocolLib/src/com/comphenix/protocol/ProtocolManager.java rename to ProtocolLib/src/main/java/com/comphenix/protocol/ProtocolManager.java diff --git a/ProtocolLib/src/com/comphenix/protocol/async/AsyncFilterManager.java b/ProtocolLib/src/main/java/com/comphenix/protocol/async/AsyncFilterManager.java similarity index 80% rename from ProtocolLib/src/com/comphenix/protocol/async/AsyncFilterManager.java rename to ProtocolLib/src/main/java/com/comphenix/protocol/async/AsyncFilterManager.java index ecc841d0..959700a1 100644 --- a/ProtocolLib/src/com/comphenix/protocol/async/AsyncFilterManager.java +++ b/ProtocolLib/src/main/java/com/comphenix/protocol/async/AsyncFilterManager.java @@ -1,3 +1,20 @@ +/* + * ProtocolLib - Bukkit server library that allows access to the Minecraft protocol. + * Copyright (C) 2012 Kristian S. Stangeland + * + * This program is free software; you can redistribute it and/or modify it under the terms of the + * GNU General Public License as published by the Free Software Foundation; either version 2 of + * the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along with this program; + * if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + * 02111-1307 USA + */ + package com.comphenix.protocol.async; import java.util.Collection; @@ -180,9 +197,14 @@ public class AsyncFilterManager implements AsynchronousManager { * @param syncPacket - synchronous packet event. * @param asyncMarker - the asynchronous marker to use. */ - public void enqueueSyncPacket(PacketEvent syncPacket, AsyncMarker asyncMarker) { + public synchronized void enqueueSyncPacket(PacketEvent syncPacket, AsyncMarker asyncMarker) { PacketEvent newEvent = PacketEvent.fromSynchronous(syncPacket, asyncMarker); + if (asyncMarker.isQueued() || asyncMarker.isTransmitted()) + throw new IllegalArgumentException("Cannot queue a packet that has already been queued."); + + asyncMarker.setQueuedSendingIndex(asyncMarker.getNewSendingIndex()); + // Start the process getSendingQueue(syncPacket).enqueue(newEvent); @@ -256,14 +278,31 @@ public class AsyncFilterManager implements AsynchronousManager { serverQueue.cleanupAll(); } + @Override + public void signalPacketTransmission(PacketEvent packet) { + signalPacketTransmission(packet, onMainThread()); + } + /** * Signal that a packet is ready to be transmitted. * @param packet - packet to signal. + * @param onMainThread - whether or not this method was run by the main thread. */ - public void signalPacketUpdate(PacketEvent packet) { - getSendingQueue(packet).signalPacketUpdate(packet, onMainThread()); + private void signalPacketTransmission(PacketEvent packet, boolean onMainThread) { + AsyncMarker marker = packet.getAsyncMarker(); + if (marker == null) + throw new IllegalArgumentException( + "A sync packet cannot be transmitted by the asynchronous manager."); + if (!marker.isQueued()) + throw new IllegalArgumentException( + "A packet must have been queued before it can be transmitted."); + + // Only send if the packet is ready + if (marker.decrementProcessingDelay() == 0) { + getSendingQueue(packet).signalPacketUpdate(packet, onMainThread); + } } - + /** * Retrieve the sending queue this packet belongs to. * @param packet - the packet. @@ -277,7 +316,7 @@ public class AsyncFilterManager implements AsynchronousManager { * Signal that a packet has finished processing. * @param packet - packet to signal. */ - public void signalProcessingDone(PacketEvent packet) { + public void signalFreeProcessingSlot(PacketEvent packet) { getProcessingQueue(packet).signalProcessingDone(); } diff --git a/ProtocolLib/src/com/comphenix/protocol/async/AsyncListenerHandler.java b/ProtocolLib/src/main/java/com/comphenix/protocol/async/AsyncListenerHandler.java similarity index 67% rename from ProtocolLib/src/com/comphenix/protocol/async/AsyncListenerHandler.java rename to ProtocolLib/src/main/java/com/comphenix/protocol/async/AsyncListenerHandler.java index 87c09e26..4f601ece 100644 --- a/ProtocolLib/src/com/comphenix/protocol/async/AsyncListenerHandler.java +++ b/ProtocolLib/src/main/java/com/comphenix/protocol/async/AsyncListenerHandler.java @@ -1,3 +1,20 @@ +/* + * ProtocolLib - Bukkit server library that allows access to the Minecraft protocol. + * Copyright (C) 2012 Kristian S. Stangeland + * + * This program is free software; you can redistribute it and/or modify it under the terms of the + * GNU General Public License as published by the Free Software Foundation; either version 2 of + * the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along with this program; + * if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + * 02111-1307 USA + */ + package com.comphenix.protocol.async; import java.util.HashSet; @@ -9,9 +26,12 @@ import java.util.logging.Level; import org.bukkit.plugin.Plugin; +import com.comphenix.protocol.events.ListeningWhitelist; import com.comphenix.protocol.events.PacketAdapter; import com.comphenix.protocol.events.PacketEvent; import com.comphenix.protocol.events.PacketListener; +import com.google.common.base.Function; +import com.google.common.base.Joiner; /** * Represents a handler for an asynchronous event. @@ -51,7 +71,7 @@ public class AsyncListenerHandler { // List of queued packets private ArrayBlockingQueue queuedPackets = new ArrayBlockingQueue(DEFAULT_CAPACITY); - + // List of cancelled tasks private final Set stoppedTasks = new HashSet(); private final Object stopLock = new Object(); @@ -198,7 +218,7 @@ public class AsyncListenerHandler { } /** - * Start a singler worker thread handling the asynchronous. + * Start a singler worker thread handling the asynchronous listener. */ public synchronized void start() { if (listener.getPlugin() == null) @@ -206,7 +226,91 @@ public class AsyncListenerHandler { if (cancelled) throw new IllegalStateException("Cannot start a worker when the listener is closing."); - filterManager.scheduleAsyncTask(listener.getPlugin(), getListenerLoop()); + final AsyncRunnable listenerLoop = getListenerLoop(); + + filterManager.scheduleAsyncTask(listener.getPlugin(), new Runnable() { + @Override + public void run() { + Thread thread = Thread.currentThread(); + + String previousName = thread.getName(); + String workerName = getFriendlyWorkerName(listenerLoop.getID()); + + // Add the friendly worker name + thread.setName(workerName); + listenerLoop.run(); + thread.setName(previousName); + } + }); + } + + /** + * Start a singler worker thread handling the asynchronous listener. + *

+ * This method is intended to allow callers to customize the thread priority + * before the worker loop is actually called. This is simpler than to + * schedule the worker threads manually. + *


+	 * listenerHandler.start(new Function<AsyncRunnable, Void>() {
+	 *     @Override
+	 *     public Void apply(@Nullable AsyncRunnable workerLoop) {
+	 *         Thread thread = Thread.currentThread();
+	 *         int prevPriority = thread.getPriority();
+	 *	       
+	 *         thread.setPriority(Thread.MIN_PRIORITY);
+	 *         workerLoop.run();
+	 *         thread.setPriority(prevPriority);
+	 *         return null;
+	 *     }
+	 *   });
+	 * }
+	 * 
+ * @param executor - a method that will execute the given listener loop. + */ + public synchronized void start(Function executor) { + if (listener.getPlugin() == null) + throw new IllegalArgumentException("Cannot start task without a valid plugin."); + if (cancelled) + throw new IllegalStateException("Cannot start a worker when the listener is closing."); + + final AsyncRunnable listenerLoop = getListenerLoop(); + final Function delegateCopy = executor; + + filterManager.scheduleAsyncTask(listener.getPlugin(), new Runnable() { + @Override + public void run() { + delegateCopy.apply(listenerLoop); + } + }); + } + + /** + * Create a friendly thread name using the following convention: + *

+ *     Protocol Worker {id} - {plugin} - [recv: {packets}, send: {packets}] + *

+ * @param id - the worker ID. + * @return A friendly thread name. + */ + public String getFriendlyWorkerName(int id) { + return String.format("Protocol Worker #%s - %s - [recv: %s, send: %s]", + id, + PacketAdapter.getPluginName(listener), + fromWhitelist(listener.getReceivingWhitelist()), + fromWhitelist(listener.getSendingWhitelist()) + ); + } + + /** + * Convert the given whitelist to a comma-separated list of packet IDs. + * @param whitelist - the whitelist. + * @return A comma separated list of packet IDs in the whitelist, or the emtpy string. + */ + private String fromWhitelist(ListeningWhitelist whitelist) { + if (whitelist == null) + return ""; + else + return Joiner.on(", ").join(whitelist.getWhitelist()); } /** @@ -258,7 +362,7 @@ public class AsyncListenerHandler { stop(); // May happen if another thread is doing something similar to "setWorkers" - if ((System.currentTimeMillis() - time) > 1000) + if ((System.currentTimeMillis() - time) > 50) throw new RuntimeException("Failed to set worker count."); } } @@ -329,10 +433,12 @@ public class AsyncListenerHandler { marker.setListenerHandler(this); marker.setWorkerID(workerID); - if (packet.isServerPacket()) - listener.onPacketSending(packet); - else - listener.onPacketReceiving(packet); + synchronized (marker.getProcessingLock()) { + if (packet.isServerPacket()) + listener.onPacketSending(packet); + else + listener.onPacketReceiving(packet); + } } catch (Throwable e) { // Minecraft doesn't want your Exception. @@ -351,8 +457,10 @@ public class AsyncListenerHandler { } // There are no more listeners - queue the packet for transmission - filterManager.signalPacketUpdate(packet); - filterManager.signalProcessingDone(packet); + filterManager.signalFreeProcessingSlot(packet); + + // Note that listeners can opt to delay the packet transmission + filterManager.signalPacketTransmission(packet); } } catch (InterruptedException e) { diff --git a/ProtocolLib/src/com/comphenix/protocol/async/AsyncMarker.java b/ProtocolLib/src/main/java/com/comphenix/protocol/async/AsyncMarker.java similarity index 68% rename from ProtocolLib/src/com/comphenix/protocol/async/AsyncMarker.java rename to ProtocolLib/src/main/java/com/comphenix/protocol/async/AsyncMarker.java index a5e15f0e..ec3aa894 100644 --- a/ProtocolLib/src/com/comphenix/protocol/async/AsyncMarker.java +++ b/ProtocolLib/src/main/java/com/comphenix/protocol/async/AsyncMarker.java @@ -1,3 +1,20 @@ +/* + * ProtocolLib - Bukkit server library that allows access to the Minecraft protocol. + * Copyright (C) 2012 Kristian S. Stangeland + * + * This program is free software; you can redistribute it and/or modify it under the terms of the + * GNU General Public License as published by the Free Software Foundation; either version 2 of + * the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along with this program; + * if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + * 02111-1307 USA + */ + package com.comphenix.protocol.async; import java.io.IOException; @@ -6,6 +23,7 @@ import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.util.Iterator; import java.util.List; +import java.util.concurrent.atomic.AtomicInteger; import net.minecraft.server.Packet; @@ -58,6 +76,9 @@ public class AsyncMarker implements Serializable, Comparable { private long originalSendingIndex; private long newSendingIndex; + // Used to determine if a packet must be reordered in the sending queue + private Long queuedSendingIndex; + // Whether or not the packet has been processed by the listeners private volatile boolean processed; @@ -67,6 +88,12 @@ public class AsyncMarker implements Serializable, Comparable { // Whether or not the asynchronous processing itself should be cancelled private volatile boolean asyncCancelled; + // Whether or not to delay processing + private AtomicInteger processingDelay = new AtomicInteger(); + + // Used to synchronize processing on the shared PacketEvent + private Object processingLock = new Object(); + // Used to identify the asynchronous worker private AsyncListenerHandler listenerHandler; private int workerID; @@ -178,6 +205,80 @@ public class AsyncMarker implements Serializable, Comparable { this.processed = processed; } + /** + * Increment the number of times this packet must be signalled as done before its transmitted. + *

+ * This is useful if an asynchronous listener is waiting for further information before the + * packet can be sent to the user. A packet listener MUST eventually call + * {@link AsyncFilterManager#signalPacketTransmission(PacketEvent)}, + * even if the packet is cancelled, after this method is called. + *

+ * It is recommended that processing outside a packet listener is wrapped in a synchronized block + * using the {@link #getProcessingLock()} method. + *

+ * To decrement the processing delay, call signalPacketUpdate. A thread that calls this method + * multiple times must call signalPacketUpdate at least that many times. + * @return The new processing delay. + */ + public int incrementProcessingDelay() { + return processingDelay.incrementAndGet(); + } + + /** + * Decrement the number of times this packet must be signalled as done before it's transmitted. + * @return The new processing delay. If zero, the packet should be sent. + */ + int decrementProcessingDelay() { + return processingDelay.decrementAndGet(); + } + + /** + * Retrieve the number of times a packet must be signalled to be done before it's sent. + * @return Number of processing delays. + */ + public int getProcessingDelay() { + return processingDelay.get(); + } + + /** + * Whether or not this packet is or has been queued for processing. + * @return TRUE if it has, FALSE otherwise. + */ + public boolean isQueued() { + return queuedSendingIndex != null; + } + + /** + * Retrieve the sending index when the packet was queued. + * @return Queued sending index. + */ + public long getQueuedSendingIndex() { + return queuedSendingIndex != null ? queuedSendingIndex : 0; + } + + /** + * Set the sending index when the packet was queued. + * @param queuedSendingIndex - sending index. + */ + void setQueuedSendingIndex(Long queuedSendingIndex) { + this.queuedSendingIndex = queuedSendingIndex; + } + + /** + * Processing lock used to synchronize access to the parent PacketEvent and PacketContainer. + *

+ * This lock is automatically acquired for every asynchronous packet listener. It should only be + * used to synchronize access to a PacketEvent if it's processing has been delayed. + * @return A processing lock. + */ + public Object getProcessingLock() { + return processingLock; + } + + public void setProcessingLock(Object processingLock) { + this.processingLock = processingLock; + } + /** * Retrieve whether or not this packet has already been sent. * @return TRUE if it has been sent before, FALSE otherwise. @@ -213,6 +314,10 @@ public class AsyncMarker implements Serializable, Comparable { /** * Set whether or not the asynchronous handling should be cancelled. + *

+ * This is only relevant during the synchronous processing. Asynchronous + * listeners should use the normal cancel-field to cancel a PacketEvent. + * * @param asyncCancelled - TRUE to cancel it, FALSE otherwise. */ public void setAsyncCancelled(boolean asyncCancelled) { @@ -276,7 +381,7 @@ public class AsyncMarker implements Serializable, Comparable { * @param event - the packet to send. * @throws IOException If the packet couldn't be sent. */ - public void sendPacket(PacketEvent event) throws IOException { + void sendPacket(PacketEvent event) throws IOException { try { if (event.isServerPacket()) { packetStream.sendServerPacket(event.getPlayer(), event.getPacket(), false); diff --git a/ProtocolLib/src/main/java/com/comphenix/protocol/async/AsyncRunnable.java b/ProtocolLib/src/main/java/com/comphenix/protocol/async/AsyncRunnable.java new file mode 100644 index 00000000..aeb2c0be --- /dev/null +++ b/ProtocolLib/src/main/java/com/comphenix/protocol/async/AsyncRunnable.java @@ -0,0 +1,52 @@ +/* + * ProtocolLib - Bukkit server library that allows access to the Minecraft protocol. + * Copyright (C) 2012 Kristian S. Stangeland + * + * This program is free software; you can redistribute it and/or modify it under the terms of the + * GNU General Public License as published by the Free Software Foundation; either version 2 of + * the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along with this program; + * if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + * 02111-1307 USA + */ + +package com.comphenix.protocol.async; + +/** + * A runnable representing a asynchronous event listener. + * + * @author Kristian + */ +public interface AsyncRunnable extends Runnable { + + /** + * Retrieve a unique worker ID. + * @return Unique worker ID. + */ + public int getID(); + + /** + * Stop the given runnable. + *

+ * This may not occur right away. + * @return TRUE if the thread was stopped, FALSE if it was already stopped. + */ + public boolean stop() throws InterruptedException; + + /** + * Determine if we're running or not. + * @return TRUE if we're running, FALSE otherwise. + */ + public boolean isRunning(); + + /** + * Determine if this runnable has already run its course. + * @return TRUE if it has been stopped, FALSE otherwise. + */ + boolean isFinished(); +} diff --git a/ProtocolLib/src/com/comphenix/protocol/async/NullPacketListener.java b/ProtocolLib/src/main/java/com/comphenix/protocol/async/NullPacketListener.java similarity index 63% rename from ProtocolLib/src/com/comphenix/protocol/async/NullPacketListener.java rename to ProtocolLib/src/main/java/com/comphenix/protocol/async/NullPacketListener.java index d02559d3..8a358fad 100644 --- a/ProtocolLib/src/com/comphenix/protocol/async/NullPacketListener.java +++ b/ProtocolLib/src/main/java/com/comphenix/protocol/async/NullPacketListener.java @@ -1,3 +1,20 @@ +/* + * ProtocolLib - Bukkit server library that allows access to the Minecraft protocol. + * Copyright (C) 2012 Kristian S. Stangeland + * + * This program is free software; you can redistribute it and/or modify it under the terms of the + * GNU General Public License as published by the Free Software Foundation; either version 2 of + * the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along with this program; + * if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + * 02111-1307 USA + */ + package com.comphenix.protocol.async; import org.bukkit.plugin.Plugin; diff --git a/ProtocolLib/src/main/java/com/comphenix/protocol/async/PacketEventHolder.java b/ProtocolLib/src/main/java/com/comphenix/protocol/async/PacketEventHolder.java new file mode 100644 index 00000000..8504157f --- /dev/null +++ b/ProtocolLib/src/main/java/com/comphenix/protocol/async/PacketEventHolder.java @@ -0,0 +1,59 @@ +/* + * ProtocolLib - Bukkit server library that allows access to the Minecraft protocol. + * Copyright (C) 2012 Kristian S. Stangeland + * + * This program is free software; you can redistribute it and/or modify it under the terms of the + * GNU General Public License as published by the Free Software Foundation; either version 2 of + * the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along with this program; + * if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + * 02111-1307 USA + */ + +package com.comphenix.protocol.async; + +import com.comphenix.protocol.events.PacketEvent; +import com.google.common.base.Preconditions; +import com.google.common.collect.ComparisonChain; + +/** + * Provides a comparable to a packet event. + * + * @author Kristian + */ +class PacketEventHolder implements Comparable { + + private PacketEvent event; + private long sendingIndex = 0; + + /** + * A wrapper that ensures the packet event is ordered by sending index. + * @param event - packet event to wrap. + */ + public PacketEventHolder(PacketEvent event) { + this.event = Preconditions.checkNotNull(event, "Event must be non-null"); + + if (event.getAsyncMarker() != null) + this.sendingIndex = event.getAsyncMarker().getNewSendingIndex(); + } + + /** + * Retrieve the stored event. + * @return The stored event. + */ + public PacketEvent getEvent() { + return event; + } + + @Override + public int compareTo(PacketEventHolder other) { + return ComparisonChain.start(). + compare(sendingIndex, other.sendingIndex). + result(); + } +} diff --git a/ProtocolLib/src/com/comphenix/protocol/async/PacketProcessingQueue.java b/ProtocolLib/src/main/java/com/comphenix/protocol/async/PacketProcessingQueue.java similarity index 78% rename from ProtocolLib/src/com/comphenix/protocol/async/PacketProcessingQueue.java rename to ProtocolLib/src/main/java/com/comphenix/protocol/async/PacketProcessingQueue.java index 08ab06ad..1f49df99 100644 --- a/ProtocolLib/src/com/comphenix/protocol/async/PacketProcessingQueue.java +++ b/ProtocolLib/src/main/java/com/comphenix/protocol/async/PacketProcessingQueue.java @@ -1,3 +1,20 @@ +/* + * ProtocolLib - Bukkit server library that allows access to the Minecraft protocol. + * Copyright (C) 2012 Kristian S. Stangeland + * + * This program is free software; you can redistribute it and/or modify it under the terms of the + * GNU General Public License as published by the Free Software Foundation; either version 2 of + * the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along with this program; + * if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + * 02111-1307 USA + */ + package com.comphenix.protocol.async; import java.util.Collection; @@ -100,6 +117,8 @@ class PacketProcessingQueue extends AbstractConcurrentListenerMultimap> list = getListener(packet.getPacketID()); + marker.incrementProcessingDelay(); + // Yes, removing the marker will cause the chain to stop if (list != null) { Iterator> iterator = list.iterator(); @@ -112,7 +131,8 @@ class PacketProcessingQueue extends AbstractConcurrentListenerMultimapwithType(net.minecraft.server.ItemStack.class, new EquivalentConverter() { public Object getGeneric(ItemStack specific) { - return ((CraftItemStack) specific).getHandle(); + return toStackNMS(specific); } @Override @@ -175,7 +175,7 @@ public class PacketContainer implements Serializable { // Unwrap every item for (int i = 0; i < result.length; i++) { - result[i] = ((CraftItemStack) specific[i]).getHandle(); + result[i] = toStackNMS(specific[i]); } return result; } @@ -199,6 +199,20 @@ public class PacketContainer implements Serializable { }); } + /** + * Convert an item stack to the NMS equivalent. + * @param stack - Bukkit stack to convert. + * @return A bukkit stack. + */ + private net.minecraft.server.ItemStack toStackNMS(ItemStack stack) { + // We must be prepared for an object that simply implements ItemStcak + if (stack instanceof CraftItemStack) { + return ((CraftItemStack) stack).getHandle(); + } else { + return (new CraftItemStack(stack)).getHandle(); + } + } + /** * Retrieves a read/write structure for the world type enum. *

diff --git a/ProtocolLib/src/com/comphenix/protocol/events/PacketEvent.java b/ProtocolLib/src/main/java/com/comphenix/protocol/events/PacketEvent.java similarity index 100% rename from ProtocolLib/src/com/comphenix/protocol/events/PacketEvent.java rename to ProtocolLib/src/main/java/com/comphenix/protocol/events/PacketEvent.java diff --git a/ProtocolLib/src/com/comphenix/protocol/events/PacketListener.java b/ProtocolLib/src/main/java/com/comphenix/protocol/events/PacketListener.java similarity index 100% rename from ProtocolLib/src/com/comphenix/protocol/events/PacketListener.java rename to ProtocolLib/src/main/java/com/comphenix/protocol/events/PacketListener.java diff --git a/ProtocolLib/src/com/comphenix/protocol/events/SerializedOfflinePlayer.java b/ProtocolLib/src/main/java/com/comphenix/protocol/events/SerializedOfflinePlayer.java similarity index 82% rename from ProtocolLib/src/com/comphenix/protocol/events/SerializedOfflinePlayer.java rename to ProtocolLib/src/main/java/com/comphenix/protocol/events/SerializedOfflinePlayer.java index 4e222e57..9d593835 100644 --- a/ProtocolLib/src/com/comphenix/protocol/events/SerializedOfflinePlayer.java +++ b/ProtocolLib/src/main/java/com/comphenix/protocol/events/SerializedOfflinePlayer.java @@ -1,3 +1,20 @@ +/* + * ProtocolLib - Bukkit server library that allows access to the Minecraft protocol. + * Copyright (C) 2012 Kristian S. Stangeland + * + * This program is free software; you can redistribute it and/or modify it under the terms of the + * GNU General Public License as published by the Free Software Foundation; either version 2 of + * the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along with this program; + * if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + * 02111-1307 USA + */ + package com.comphenix.protocol.events; import java.io.IOException; diff --git a/ProtocolLib/src/main/java/com/comphenix/protocol/injector/BukkitUnwrapper.java b/ProtocolLib/src/main/java/com/comphenix/protocol/injector/BukkitUnwrapper.java new file mode 100644 index 00000000..6ca4d332 --- /dev/null +++ b/ProtocolLib/src/main/java/com/comphenix/protocol/injector/BukkitUnwrapper.java @@ -0,0 +1,113 @@ +/* + * ProtocolLib - Bukkit server library that allows access to the Minecraft protocol. + * Copyright (C) 2012 Kristian S. Stangeland + * + * This program is free software; you can redistribute it and/or modify it under the terms of the + * GNU General Public License as published by the Free Software Foundation; either version 2 of + * the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along with this program; + * if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + * 02111-1307 USA + */ + +package com.comphenix.protocol.injector; + +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; +import java.util.Collection; +import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; + +import com.comphenix.protocol.injector.PacketConstructor.Unwrapper; +import com.comphenix.protocol.reflect.instances.DefaultInstances; + +/** + * Represents an object capable of converting wrapped Bukkit objects into NMS objects. + *

+ * Typical conversions include: + *

    + *
  • org.bukkit.entity.Player -> net.minecraft.server.EntityPlayer
  • + *
  • org.bukkit.World -> net.minecraft.server.WorldServer
  • + *
+ * + * @author Kristian + */ +public class BukkitUnwrapper implements Unwrapper { + + private static Map, Method> cache = new ConcurrentHashMap, Method>(); + + @SuppressWarnings("unchecked") + @Override + public Object unwrapItem(Object wrappedObject) { + + // Special case + if (wrappedObject instanceof Collection) { + return handleCollection((Collection) wrappedObject); + } + + Class currentClass = wrappedObject.getClass(); + Method cachedMethod = initializeCache(currentClass); + + try { + // Retrieve the handle + if (cachedMethod != null) + return cachedMethod.invoke(wrappedObject); + else + return null; + + } catch (IllegalArgumentException e) { + // Impossible + return null; + } catch (IllegalAccessException e) { + return null; + } catch (InvocationTargetException e) { + // This is REALLY bad + throw new RuntimeException("Minecraft error.", e); + } + } + + private Object handleCollection(Collection wrappedObject) { + + @SuppressWarnings("unchecked") + Collection copy = DefaultInstances.DEFAULT.getDefault(wrappedObject.getClass()); + + if (copy != null) { + // Unwrap every element + for (Object element : wrappedObject) { + copy.add(unwrapItem(element)); + } + return copy; + + } else { + // Impossible + return null; + } + } + + private Method initializeCache(Class type) { + + // See if we're already determined this + if (cache.containsKey(type)) { + // We will never remove from the cache, so this ought to be thread safe + return cache.get(type); + } + + try { + Method find = type.getMethod("getHandle"); + + // It's thread safe, as getMethod should return the same handle + cache.put(type, find); + return find; + + } catch (SecurityException e) { + return null; + } catch (NoSuchMethodException e) { + return null; + } + } +} diff --git a/ProtocolLib/src/com/comphenix/protocol/injector/EntityUtilities.java b/ProtocolLib/src/main/java/com/comphenix/protocol/injector/EntityUtilities.java similarity index 85% rename from ProtocolLib/src/com/comphenix/protocol/injector/EntityUtilities.java rename to ProtocolLib/src/main/java/com/comphenix/protocol/injector/EntityUtilities.java index e3c4a2c9..7eb4041b 100644 --- a/ProtocolLib/src/com/comphenix/protocol/injector/EntityUtilities.java +++ b/ProtocolLib/src/main/java/com/comphenix/protocol/injector/EntityUtilities.java @@ -1,3 +1,20 @@ +/* + * ProtocolLib - Bukkit server library that allows access to the Minecraft protocol. + * Copyright (C) 2012 Kristian S. Stangeland + * + * This program is free software; you can redistribute it and/or modify it under the terms of the + * GNU General Public License as published by the Free Software Foundation; either version 2 of + * the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along with this program; + * if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + * 02111-1307 USA + */ + package com.comphenix.protocol.injector; import java.lang.reflect.Constructor; @@ -15,7 +32,6 @@ import org.bukkit.craftbukkit.CraftWorld; import org.bukkit.entity.Entity; import org.bukkit.entity.Player; -import com.comphenix.protocol.injector.PacketConstructor.BukkitUnwrapper; import com.comphenix.protocol.reflect.FieldAccessException; import com.comphenix.protocol.reflect.FieldUtils; import com.comphenix.protocol.reflect.FuzzyReflection; diff --git a/ProtocolLib/src/main/java/com/comphenix/protocol/injector/ListenerInvoker.java b/ProtocolLib/src/main/java/com/comphenix/protocol/injector/ListenerInvoker.java new file mode 100644 index 00000000..e38edcf2 --- /dev/null +++ b/ProtocolLib/src/main/java/com/comphenix/protocol/injector/ListenerInvoker.java @@ -0,0 +1,49 @@ +/* + * ProtocolLib - Bukkit server library that allows access to the Minecraft protocol. + * Copyright (C) 2012 Kristian S. Stangeland + * + * This program is free software; you can redistribute it and/or modify it under the terms of the + * GNU General Public License as published by the Free Software Foundation; either version 2 of + * the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along with this program; + * if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + * 02111-1307 USA + */ + +package com.comphenix.protocol.injector; + +import net.minecraft.server.Packet; + +import com.comphenix.protocol.events.PacketEvent; + +/** + * Represents an object that initiate the packet listeners. + * + * @author Kristian + */ +public interface ListenerInvoker { + + /** + * Invokes the given packet event for every registered listener. + * @param event - the packet event to invoke. + */ + public abstract void invokePacketRecieving(PacketEvent event); + + /** + * Invokes the given packet event for every registered listener. + * @param event - the packet event to invoke. + */ + public abstract void invokePacketSending(PacketEvent event); + + /** + * Retrieve the associated ID of a packet. + * @param packet - the packet. + * @return The packet ID. + */ + public abstract int getPacketID(Packet packet); +} \ No newline at end of file diff --git a/ProtocolLib/src/com/comphenix/protocol/injector/MinecraftRegistry.java b/ProtocolLib/src/main/java/com/comphenix/protocol/injector/MinecraftRegistry.java similarity index 53% rename from ProtocolLib/src/com/comphenix/protocol/injector/MinecraftRegistry.java rename to ProtocolLib/src/main/java/com/comphenix/protocol/injector/MinecraftRegistry.java index 2e372e1e..34930aee 100644 --- a/ProtocolLib/src/com/comphenix/protocol/injector/MinecraftRegistry.java +++ b/ProtocolLib/src/main/java/com/comphenix/protocol/injector/MinecraftRegistry.java @@ -19,13 +19,17 @@ package com.comphenix.protocol.injector; import java.lang.reflect.Field; import java.util.HashMap; +import java.util.List; import java.util.Map; +import java.util.Set; import net.minecraft.server.Packet; +import com.comphenix.protocol.reflect.FieldAccessException; import com.comphenix.protocol.reflect.FieldUtils; import com.comphenix.protocol.reflect.FuzzyReflection; import com.google.common.base.Objects; +import com.google.common.collect.ImmutableSet; /** * Static registries in Minecraft. @@ -35,9 +39,16 @@ import com.google.common.base.Objects; @SuppressWarnings("rawtypes") class MinecraftRegistry { + // Fuzzy reflection + private static FuzzyReflection packetRegistry; + // The packet class to packet ID translator private static Map packetToID; + // Whether or not certain packets are sent by the client or the server + private static Set serverPackets; + private static Set clientPackets; + // New proxy values private static Map overwrittenPackets = new HashMap(); @@ -49,7 +60,7 @@ class MinecraftRegistry { // Initialize it, if we haven't already if (packetToID == null) { try { - Field packetsField = FuzzyReflection.fromClass(Packet.class, true).getFieldByType("packetsField", Map.class); + Field packetsField = getPacketRegistry().getFieldByType("packetsField", Map.class); packetToID = (Map) FieldUtils.readStaticField(packetsField, true); } catch (IllegalAccessException e) { @@ -60,14 +71,80 @@ class MinecraftRegistry { return packetToID; } + /** + * Retrieve the cached fuzzy reflection instance allowing access to the packet registry. + * @return Reflected packet registry. + */ + private static FuzzyReflection getPacketRegistry() { + if (packetRegistry == null) + packetRegistry = FuzzyReflection.fromClass(Packet.class, true); + return packetRegistry; + } + + /** + * Retrieve the injected proxy classes handlig each packet ID. + * @return Injected classes. + */ public static Map getOverwrittenPackets() { return overwrittenPackets; } + /** + * Retrieve the vanilla classes handling each packet ID. + * @return Vanilla classes. + */ public static Map getPreviousPackets() { return previousValues; } + /** + * Retrieve every known and supported server packet. + * @return An immutable set of every known server packet. + * @throws FieldAccessException If we're unable to retrieve the server packet data from Minecraft. + */ + public static Set getServerPackets() throws FieldAccessException { + initializeSets(); + return serverPackets; + } + + /** + * Retrieve every known and supported client packet. + * @return An immutable set of every known client packet. + * @throws FieldAccessException If we're unable to retrieve the client packet data from Minecraft. + */ + public static Set getClientPackets() throws FieldAccessException { + initializeSets(); + return clientPackets; + } + + @SuppressWarnings("unchecked") + private static void initializeSets() throws FieldAccessException { + if (serverPackets == null || clientPackets == null) { + List sets = getPacketRegistry().getFieldListByType(Set.class); + + try { + if (sets.size() > 1) { + serverPackets = (Set) FieldUtils.readStaticField(sets.get(0), true); + clientPackets = (Set) FieldUtils.readStaticField(sets.get(1), true); + + // Impossible + if (serverPackets == null || clientPackets == null) + throw new FieldAccessException("Packet sets are in an illegal state."); + + // NEVER allow callers to modify the underlying sets + serverPackets = ImmutableSet.copyOf(serverPackets); + clientPackets = ImmutableSet.copyOf(clientPackets); + + } else { + throw new FieldAccessException("Cannot retrieve packet client/server sets."); + } + + } catch (IllegalAccessException e) { + throw new FieldAccessException("Cannot access field.", e); + } + } + } + /** * Retrieves the correct packet class from a given packet ID. * @param packetID - the packet ID. diff --git a/ProtocolLib/src/com/comphenix/protocol/injector/PacketConstructor.java b/ProtocolLib/src/main/java/com/comphenix/protocol/injector/PacketConstructor.java similarity index 76% rename from ProtocolLib/src/com/comphenix/protocol/injector/PacketConstructor.java rename to ProtocolLib/src/main/java/com/comphenix/protocol/injector/PacketConstructor.java index 135e7eb2..da7a1c0b 100644 --- a/ProtocolLib/src/com/comphenix/protocol/injector/PacketConstructor.java +++ b/ProtocolLib/src/main/java/com/comphenix/protocol/injector/PacketConstructor.java @@ -1,11 +1,25 @@ +/* + * ProtocolLib - Bukkit server library that allows access to the Minecraft protocol. + * Copyright (C) 2012 Kristian S. Stangeland + * + * This program is free software; you can redistribute it and/or modify it under the terms of the + * GNU General Public License as published by the Free Software Foundation; either version 2 of + * the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along with this program; + * if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + * 02111-1307 USA + */ + package com.comphenix.protocol.injector; import java.lang.reflect.Constructor; import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Method; import java.util.List; -import java.util.Map; -import java.util.concurrent.ConcurrentHashMap; import net.minecraft.server.Packet; @@ -174,58 +188,17 @@ public class PacketConstructor { return false; } - public static class BukkitUnwrapper implements Unwrapper { - - private static Map, Method> cache = new ConcurrentHashMap, Method>(); - - @Override - public Object unwrapItem(Object wrappedObject) { - - Class currentClass = wrappedObject.getClass(); - Method cachedMethod = initializeCache(currentClass); - - try { - // Retrieve the handle - if (cachedMethod != null) - return cachedMethod.invoke(wrappedObject); - else - return null; - - } catch (IllegalArgumentException e) { - // Impossible - return null; - } catch (IllegalAccessException e) { - return null; - } catch (InvocationTargetException e) { - // This is REALLY bad - throw new RuntimeException("Minecraft error.", e); - } - } - - private Method initializeCache(Class type) { - - // See if we're already determined this - if (cache.containsKey(type)) { - // We will never remove from the cache, so this ought to be thread safe - return cache.get(type); - } - - try { - Method find = type.getMethod("getHandle"); - - // It's thread safe, as getMethod should return the same handle - cache.put(type, find); - return find; - - } catch (SecurityException e) { - return null; - } catch (NoSuchMethodException e) { - return null; - } - } - } - + /** + * Represents a unwrapper for a constructor parameter. + * + * @author Kristian + */ public static interface Unwrapper { + /** + * Convert the given wrapped object to the equivalent net.minecraft.server object. + * @param wrappedObject - wrapped object. + * @return The net.minecraft.server object. + */ public Object unwrapItem(Object wrappedObject); } } diff --git a/ProtocolLib/src/com/comphenix/protocol/injector/PacketFilterManager.java b/ProtocolLib/src/main/java/com/comphenix/protocol/injector/PacketFilterManager.java similarity index 84% rename from ProtocolLib/src/com/comphenix/protocol/injector/PacketFilterManager.java rename to ProtocolLib/src/main/java/com/comphenix/protocol/injector/PacketFilterManager.java index 7a1c612d..14e2d620 100644 --- a/ProtocolLib/src/com/comphenix/protocol/injector/PacketFilterManager.java +++ b/ProtocolLib/src/main/java/com/comphenix/protocol/injector/PacketFilterManager.java @@ -61,13 +61,6 @@ public final class PacketFilterManager implements ProtocolManager, ListenerInvok * @author Kristian */ public enum PlayerInjectHooks { - /** - * Override the packet queue lists in NetworkHandler. - *

- * Cannot intercept MapChunk packets. - */ - NETWORK_HANDLER_FIELDS, - /** * Override the network handler object itself. Only works in 1.3. *

@@ -75,6 +68,13 @@ public final class PacketFilterManager implements ProtocolManager, ListenerInvok */ NETWORK_MANAGER_OBJECT, + /** + * Override the packet queue lists in NetworkHandler. + *

+ * Cannot intercept MapChunk packets. + */ + NETWORK_HANDLER_FIELDS, + /** * Override the server handler object. Versatile, but a tad slower. */ @@ -107,6 +107,11 @@ public final class PacketFilterManager implements ProtocolManager, ListenerInvok // The async packet handler private AsyncFilterManager asyncFilterManager; + // Valid server and client packets + private Set serverPackets; + private Set clientPackets; + + /** * Only create instances of this class if protocol lib is disabled. */ @@ -123,6 +128,15 @@ public final class PacketFilterManager implements ProtocolManager, ListenerInvok this.playerInjection = new PlayerInjectionHandler(classLoader, logger, this, server); this.packetInjector = new PacketInjector(classLoader, this, playerInjection); this.asyncFilterManager = new AsyncFilterManager(logger, server.getScheduler(), this); + + // Attempt to load the list of server and client packets + try { + this.serverPackets = MinecraftRegistry.getServerPackets(); + this.clientPackets = MinecraftRegistry.getClientPackets(); + } catch (FieldAccessException e) { + logger.log(Level.WARNING, "Cannot load server and client packet list.", e); + } + } catch (IllegalAccessException e) { logger.log(Level.SEVERE, "Unable to initialize packet injector.", e); } @@ -180,7 +194,7 @@ public final class PacketFilterManager implements ProtocolManager, ListenerInvok if (hasSending) { verifyWhitelist(listener, sending); sendingListeners.addListener(listener, sending); - enablePacketFilters(ConnectionSide.SERVER_SIDE, sending.getWhitelist()); + enablePacketFilters(listener, ConnectionSide.SERVER_SIDE, sending.getWhitelist()); // Make sure this is possible playerInjection.checkListener(listener); @@ -188,7 +202,7 @@ public final class PacketFilterManager implements ProtocolManager, ListenerInvok if (hasReceiving) { verifyWhitelist(listener, receiving); recievedListeners.addListener(listener, receiving); - enablePacketFilters(ConnectionSide.CLIENT_SIDE, receiving.getWhitelist()); + enablePacketFilters(listener, ConnectionSide.CLIENT_SIDE, receiving.getWhitelist()); } // Inform our injected hooks @@ -304,18 +318,39 @@ public final class PacketFilterManager implements ProtocolManager, ListenerInvok *

* Note that all packets are disabled by default. * + * @param listener - the listener that requested to enable these filters. * @param side - which side the event will arrive from. * @param packets - the packet id(s). */ - private void enablePacketFilters(ConnectionSide side, Iterable packets) { + private void enablePacketFilters(PacketListener listener, ConnectionSide side, Iterable packets) { if (side == null) throw new IllegalArgumentException("side cannot be NULL."); + + // Note the difference between unsupported and valid. + // Every packet ID between and including 0 - 255 is valid, but only a subset is supported. for (int packetID : packets) { - if (side.isForServer()) - playerInjection.addPacketHandler(packetID); - if (side.isForClient() && packetInjector != null) - packetInjector.addPacketHandler(packetID); + // Only register server packets that are actually supported by Minecraft + if (side.isForServer()) { + if (serverPackets != null && serverPackets.contains(packetID)) + playerInjection.addPacketHandler(packetID); + else + logger.warning(String.format( + "[%s] Unsupported server packet ID in current Minecraft version: %s", + PacketAdapter.getPluginName(listener), packetID + )); + } + + // As above, only for client packets + if (side.isForClient() && packetInjector != null) { + if (clientPackets != null && clientPackets.contains(packetID)) + packetInjector.addPacketHandler(packetID); + else + logger.warning(String.format( + "[%s] Unsupported client packet ID in current Minecraft version: %s", + PacketAdapter.getPluginName(listener), packetID + )); + } } } @@ -440,18 +475,17 @@ public final class PacketFilterManager implements ProtocolManager, ListenerInvok try { manager.registerEvents(new Listener() { - - @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) + @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) public void onPlayerJoin(PlayerJoinEvent event) { playerInjection.injectPlayer(event.getPlayer()); } - @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) + @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) public void onPlayerQuit(PlayerQuitEvent event) { playerInjection.uninjectPlayer(event.getPlayer()); } - @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) + @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) public void onPluginDisabled(PluginDisableEvent event) { // Clean up in case the plugin forgets if (event.getPlugin() != plugin) { @@ -487,7 +521,7 @@ public final class PacketFilterManager implements ProtocolManager, ListenerInvok Class eventPriority = loader.loadClass("org.bukkit.event.Event$Priority"); // Get the priority - Object priorityNormal = Enum.valueOf(eventPriority, "Highest"); + Object priorityNormal = Enum.valueOf(eventPriority, "Monitor"); // Get event types Object playerJoinType = Enum.valueOf(eventTypes, "PLAYER_JOIN"); @@ -560,7 +594,25 @@ public final class PacketFilterManager implements ProtocolManager, ListenerInvok e.printStackTrace(); } } - + + /** + * Retrieve every known and supported server packet. + * @return An immutable set of every known server packet. + * @throws FieldAccessException If we're unable to retrieve the server packet data from Minecraft. + */ + public static Set getServerPackets() throws FieldAccessException { + return MinecraftRegistry.getServerPackets(); + } + + /** + * Retrieve every known and supported client packet. + * @return An immutable set of every known client packet. + * @throws FieldAccessException If we're unable to retrieve the client packet data from Minecraft. + */ + public static Set getClientPackets() throws FieldAccessException { + return MinecraftRegistry.getClientPackets(); + } + /** * Retrieves the current plugin class loader. * @return Class loader. @@ -574,6 +626,9 @@ public final class PacketFilterManager implements ProtocolManager, ListenerInvok return hasClosed; } + /** + * Called when ProtocolLib is closing. + */ public void close() { // Guard if (hasClosed) diff --git a/ProtocolLib/src/com/comphenix/protocol/injector/PacketInjector.java b/ProtocolLib/src/main/java/com/comphenix/protocol/injector/PacketInjector.java similarity index 95% rename from ProtocolLib/src/com/comphenix/protocol/injector/PacketInjector.java rename to ProtocolLib/src/main/java/com/comphenix/protocol/injector/PacketInjector.java index 9e042885..ee1e98de 100644 --- a/ProtocolLib/src/com/comphenix/protocol/injector/PacketInjector.java +++ b/ProtocolLib/src/main/java/com/comphenix/protocol/injector/PacketInjector.java @@ -117,6 +117,10 @@ class PacketInjector { Map registry = MinecraftRegistry.getPacketToID(); Class old = MinecraftRegistry.getPacketClassFromID(packetID); + // If this packet is not known + if (old == null) { + throw new IllegalStateException("Packet ID " + packetID + " is not a valid packet ID in this version."); + } // Check for previous injections if (!old.getName().startsWith("net.minecraft.")) { throw new IllegalStateException("Packet " + packetID + " has already been injected."); diff --git a/ProtocolLib/src/com/comphenix/protocol/injector/PlayerLoggedOutException.java b/ProtocolLib/src/main/java/com/comphenix/protocol/injector/PlayerLoggedOutException.java similarity index 52% rename from ProtocolLib/src/com/comphenix/protocol/injector/PlayerLoggedOutException.java rename to ProtocolLib/src/main/java/com/comphenix/protocol/injector/PlayerLoggedOutException.java index 5cdd569a..db5ccfe5 100644 --- a/ProtocolLib/src/com/comphenix/protocol/injector/PlayerLoggedOutException.java +++ b/ProtocolLib/src/main/java/com/comphenix/protocol/injector/PlayerLoggedOutException.java @@ -1,3 +1,20 @@ +/* + * ProtocolLib - Bukkit server library that allows access to the Minecraft protocol. + * Copyright (C) 2012 Kristian S. Stangeland + * + * This program is free software; you can redistribute it and/or modify it under the terms of the + * GNU General Public License as published by the Free Software Foundation; either version 2 of + * the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along with this program; + * if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + * 02111-1307 USA + */ + package com.comphenix.protocol.injector; /** diff --git a/ProtocolLib/src/com/comphenix/protocol/injector/PrioritizedListener.java b/ProtocolLib/src/main/java/com/comphenix/protocol/injector/PrioritizedListener.java similarity index 64% rename from ProtocolLib/src/com/comphenix/protocol/injector/PrioritizedListener.java rename to ProtocolLib/src/main/java/com/comphenix/protocol/injector/PrioritizedListener.java index 2d971206..844c34e5 100644 --- a/ProtocolLib/src/com/comphenix/protocol/injector/PrioritizedListener.java +++ b/ProtocolLib/src/main/java/com/comphenix/protocol/injector/PrioritizedListener.java @@ -1,3 +1,20 @@ +/* + * ProtocolLib - Bukkit server library that allows access to the Minecraft protocol. + * Copyright (C) 2012 Kristian S. Stangeland + * + * This program is free software; you can redistribute it and/or modify it under the terms of the + * GNU General Public License as published by the Free Software Foundation; either version 2 of + * the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along with this program; + * if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + * 02111-1307 USA + */ + package com.comphenix.protocol.injector; import com.comphenix.protocol.events.ListenerPriority; diff --git a/ProtocolLib/src/com/comphenix/protocol/injector/ReadPacketModifier.java b/ProtocolLib/src/main/java/com/comphenix/protocol/injector/ReadPacketModifier.java similarity index 100% rename from ProtocolLib/src/com/comphenix/protocol/injector/ReadPacketModifier.java rename to ProtocolLib/src/main/java/com/comphenix/protocol/injector/ReadPacketModifier.java diff --git a/ProtocolLib/src/com/comphenix/protocol/injector/SortedPacketListenerList.java b/ProtocolLib/src/main/java/com/comphenix/protocol/injector/SortedPacketListenerList.java similarity index 69% rename from ProtocolLib/src/com/comphenix/protocol/injector/SortedPacketListenerList.java rename to ProtocolLib/src/main/java/com/comphenix/protocol/injector/SortedPacketListenerList.java index 7ff8cddd..2440147e 100644 --- a/ProtocolLib/src/com/comphenix/protocol/injector/SortedPacketListenerList.java +++ b/ProtocolLib/src/main/java/com/comphenix/protocol/injector/SortedPacketListenerList.java @@ -1,3 +1,20 @@ +/* + * ProtocolLib - Bukkit server library that allows access to the Minecraft protocol. + * Copyright (C) 2012 Kristian S. Stangeland + * + * This program is free software; you can redistribute it and/or modify it under the terms of the + * GNU General Public License as published by the Free Software Foundation; either version 2 of + * the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along with this program; + * if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + * 02111-1307 USA + */ + package com.comphenix.protocol.injector; import java.util.Collection; diff --git a/ProtocolLib/src/com/comphenix/protocol/injector/StructureCache.java b/ProtocolLib/src/main/java/com/comphenix/protocol/injector/StructureCache.java similarity index 100% rename from ProtocolLib/src/com/comphenix/protocol/injector/StructureCache.java rename to ProtocolLib/src/main/java/com/comphenix/protocol/injector/StructureCache.java diff --git a/ProtocolLib/src/com/comphenix/protocol/injector/player/InjectedArrayList.java b/ProtocolLib/src/main/java/com/comphenix/protocol/injector/player/InjectedArrayList.java similarity index 77% rename from ProtocolLib/src/com/comphenix/protocol/injector/player/InjectedArrayList.java rename to ProtocolLib/src/main/java/com/comphenix/protocol/injector/player/InjectedArrayList.java index 4562d2c5..69496fcd 100644 --- a/ProtocolLib/src/com/comphenix/protocol/injector/player/InjectedArrayList.java +++ b/ProtocolLib/src/main/java/com/comphenix/protocol/injector/player/InjectedArrayList.java @@ -1,3 +1,20 @@ +/* + * ProtocolLib - Bukkit server library that allows access to the Minecraft protocol. + * Copyright (C) 2012 Kristian S. Stangeland + * + * This program is free software; you can redistribute it and/or modify it under the terms of the + * GNU General Public License as published by the Free Software Foundation; either version 2 of + * the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along with this program; + * if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + * 02111-1307 USA + */ + package com.comphenix.protocol.injector.player; import java.lang.reflect.InvocationTargetException; diff --git a/ProtocolLib/src/com/comphenix/protocol/injector/player/InjectedServerConnection.java b/ProtocolLib/src/main/java/com/comphenix/protocol/injector/player/InjectedServerConnection.java similarity index 84% rename from ProtocolLib/src/com/comphenix/protocol/injector/player/InjectedServerConnection.java rename to ProtocolLib/src/main/java/com/comphenix/protocol/injector/player/InjectedServerConnection.java index 4ed76815..7f6878ce 100644 --- a/ProtocolLib/src/com/comphenix/protocol/injector/player/InjectedServerConnection.java +++ b/ProtocolLib/src/main/java/com/comphenix/protocol/injector/player/InjectedServerConnection.java @@ -1,3 +1,20 @@ +/* + * ProtocolLib - Bukkit server library that allows access to the Minecraft protocol. + * Copyright (C) 2012 Kristian S. Stangeland + * + * This program is free software; you can redistribute it and/or modify it under the terms of the + * GNU General Public License as published by the Free Software Foundation; either version 2 of + * the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along with this program; + * if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + * 02111-1307 USA + */ + package com.comphenix.protocol.injector.player; import java.lang.reflect.Field; diff --git a/ProtocolLib/src/com/comphenix/protocol/injector/player/NetworkFieldInjector.java b/ProtocolLib/src/main/java/com/comphenix/protocol/injector/player/NetworkFieldInjector.java similarity index 82% rename from ProtocolLib/src/com/comphenix/protocol/injector/player/NetworkFieldInjector.java rename to ProtocolLib/src/main/java/com/comphenix/protocol/injector/player/NetworkFieldInjector.java index 35395725..7ab5d1d6 100644 --- a/ProtocolLib/src/com/comphenix/protocol/injector/player/NetworkFieldInjector.java +++ b/ProtocolLib/src/main/java/com/comphenix/protocol/injector/player/NetworkFieldInjector.java @@ -1,3 +1,20 @@ +/* + * ProtocolLib - Bukkit server library that allows access to the Minecraft protocol. + * Copyright (C) 2012 Kristian S. Stangeland + * + * This program is free software; you can redistribute it and/or modify it under the terms of the + * GNU General Public License as published by the Free Software Foundation; either version 2 of + * the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along with this program; + * if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + * 02111-1307 USA + */ + package com.comphenix.protocol.injector.player; import java.lang.reflect.Field; diff --git a/ProtocolLib/src/com/comphenix/protocol/injector/player/NetworkObjectInjector.java b/ProtocolLib/src/main/java/com/comphenix/protocol/injector/player/NetworkObjectInjector.java similarity index 78% rename from ProtocolLib/src/com/comphenix/protocol/injector/player/NetworkObjectInjector.java rename to ProtocolLib/src/main/java/com/comphenix/protocol/injector/player/NetworkObjectInjector.java index 6d6bba12..bbd6bd74 100644 --- a/ProtocolLib/src/com/comphenix/protocol/injector/player/NetworkObjectInjector.java +++ b/ProtocolLib/src/main/java/com/comphenix/protocol/injector/player/NetworkObjectInjector.java @@ -1,3 +1,20 @@ +/* + * ProtocolLib - Bukkit server library that allows access to the Minecraft protocol. + * Copyright (C) 2012 Kristian S. Stangeland + * + * This program is free software; you can redistribute it and/or modify it under the terms of the + * GNU General Public License as published by the Free Software Foundation; either version 2 of + * the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along with this program; + * if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + * 02111-1307 USA + */ + package com.comphenix.protocol.injector.player; import java.lang.reflect.InvocationTargetException; diff --git a/ProtocolLib/src/com/comphenix/protocol/injector/player/NetworkServerInjector.java b/ProtocolLib/src/main/java/com/comphenix/protocol/injector/player/NetworkServerInjector.java similarity index 86% rename from ProtocolLib/src/com/comphenix/protocol/injector/player/NetworkServerInjector.java rename to ProtocolLib/src/main/java/com/comphenix/protocol/injector/player/NetworkServerInjector.java index 72de1223..0daa0786 100644 --- a/ProtocolLib/src/com/comphenix/protocol/injector/player/NetworkServerInjector.java +++ b/ProtocolLib/src/main/java/com/comphenix/protocol/injector/player/NetworkServerInjector.java @@ -1,3 +1,20 @@ +/* + * ProtocolLib - Bukkit server library that allows access to the Minecraft protocol. + * Copyright (C) 2012 Kristian S. Stangeland + * + * This program is free software; you can redistribute it and/or modify it under the terms of the + * GNU General Public License as published by the Free Software Foundation; either version 2 of + * the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along with this program; + * if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + * 02111-1307 USA + */ + package com.comphenix.protocol.injector.player; import java.lang.reflect.InvocationTargetException; diff --git a/ProtocolLib/src/com/comphenix/protocol/injector/player/PlayerInjectionHandler.java b/ProtocolLib/src/main/java/com/comphenix/protocol/injector/player/PlayerInjectionHandler.java similarity index 88% rename from ProtocolLib/src/com/comphenix/protocol/injector/player/PlayerInjectionHandler.java rename to ProtocolLib/src/main/java/com/comphenix/protocol/injector/player/PlayerInjectionHandler.java index da50fdee..6bb66dc0 100644 --- a/ProtocolLib/src/com/comphenix/protocol/injector/player/PlayerInjectionHandler.java +++ b/ProtocolLib/src/main/java/com/comphenix/protocol/injector/player/PlayerInjectionHandler.java @@ -1,3 +1,20 @@ +/* + * ProtocolLib - Bukkit server library that allows access to the Minecraft protocol. + * Copyright (C) 2012 Kristian S. Stangeland + * + * This program is free software; you can redistribute it and/or modify it under the terms of the + * GNU General Public License as published by the Free Software Foundation; either version 2 of + * the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along with this program; + * if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + * 02111-1307 USA + */ + package com.comphenix.protocol.injector.player; import java.io.DataInputStream; diff --git a/ProtocolLib/src/com/comphenix/protocol/injector/player/PlayerInjector.java b/ProtocolLib/src/main/java/com/comphenix/protocol/injector/player/PlayerInjector.java similarity index 100% rename from ProtocolLib/src/com/comphenix/protocol/injector/player/PlayerInjector.java rename to ProtocolLib/src/main/java/com/comphenix/protocol/injector/player/PlayerInjector.java diff --git a/ProtocolLib/src/com/comphenix/protocol/injector/player/ReplacedArrayList.java b/ProtocolLib/src/main/java/com/comphenix/protocol/injector/player/ReplacedArrayList.java similarity index 78% rename from ProtocolLib/src/com/comphenix/protocol/injector/player/ReplacedArrayList.java rename to ProtocolLib/src/main/java/com/comphenix/protocol/injector/player/ReplacedArrayList.java index ed239f3c..ec076e29 100644 --- a/ProtocolLib/src/com/comphenix/protocol/injector/player/ReplacedArrayList.java +++ b/ProtocolLib/src/main/java/com/comphenix/protocol/injector/player/ReplacedArrayList.java @@ -1,3 +1,20 @@ +/* + * ProtocolLib - Bukkit server library that allows access to the Minecraft protocol. + * Copyright (C) 2012 Kristian S. Stangeland + * + * This program is free software; you can redistribute it and/or modify it under the terms of the + * GNU General Public License as published by the Free Software Foundation; either version 2 of + * the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along with this program; + * if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + * 02111-1307 USA + */ + package com.comphenix.protocol.injector.player; import java.util.Collection; diff --git a/ProtocolLib/src/com/comphenix/protocol/metrics/Metrics.java b/ProtocolLib/src/main/java/com/comphenix/protocol/metrics/Metrics.java similarity index 100% rename from ProtocolLib/src/com/comphenix/protocol/metrics/Metrics.java rename to ProtocolLib/src/main/java/com/comphenix/protocol/metrics/Metrics.java diff --git a/ProtocolLib/src/com/comphenix/protocol/metrics/Statistics.java b/ProtocolLib/src/main/java/com/comphenix/protocol/metrics/Statistics.java similarity index 100% rename from ProtocolLib/src/com/comphenix/protocol/metrics/Statistics.java rename to ProtocolLib/src/main/java/com/comphenix/protocol/metrics/Statistics.java diff --git a/ProtocolLib/src/com/comphenix/protocol/reflect/EquivalentConverter.java b/ProtocolLib/src/main/java/com/comphenix/protocol/reflect/EquivalentConverter.java similarity index 100% rename from ProtocolLib/src/com/comphenix/protocol/reflect/EquivalentConverter.java rename to ProtocolLib/src/main/java/com/comphenix/protocol/reflect/EquivalentConverter.java diff --git a/ProtocolLib/src/com/comphenix/protocol/reflect/FieldAccessException.java b/ProtocolLib/src/main/java/com/comphenix/protocol/reflect/FieldAccessException.java similarity index 100% rename from ProtocolLib/src/com/comphenix/protocol/reflect/FieldAccessException.java rename to ProtocolLib/src/main/java/com/comphenix/protocol/reflect/FieldAccessException.java diff --git a/ProtocolLib/src/com/comphenix/protocol/reflect/FieldUtils.java b/ProtocolLib/src/main/java/com/comphenix/protocol/reflect/FieldUtils.java similarity index 100% rename from ProtocolLib/src/com/comphenix/protocol/reflect/FieldUtils.java rename to ProtocolLib/src/main/java/com/comphenix/protocol/reflect/FieldUtils.java diff --git a/ProtocolLib/src/com/comphenix/protocol/reflect/FuzzyReflection.java b/ProtocolLib/src/main/java/com/comphenix/protocol/reflect/FuzzyReflection.java similarity index 100% rename from ProtocolLib/src/com/comphenix/protocol/reflect/FuzzyReflection.java rename to ProtocolLib/src/main/java/com/comphenix/protocol/reflect/FuzzyReflection.java diff --git a/ProtocolLib/src/com/comphenix/protocol/reflect/IntEnum.java b/ProtocolLib/src/main/java/com/comphenix/protocol/reflect/IntEnum.java similarity index 61% rename from ProtocolLib/src/com/comphenix/protocol/reflect/IntEnum.java rename to ProtocolLib/src/main/java/com/comphenix/protocol/reflect/IntEnum.java index a367dc9a..3e3baa5d 100644 --- a/ProtocolLib/src/com/comphenix/protocol/reflect/IntEnum.java +++ b/ProtocolLib/src/main/java/com/comphenix/protocol/reflect/IntEnum.java @@ -1,6 +1,24 @@ +/* + * ProtocolLib - Bukkit server library that allows access to the Minecraft protocol. + * Copyright (C) 2012 Kristian S. Stangeland + * + * This program is free software; you can redistribute it and/or modify it under the terms of the + * GNU General Public License as published by the Free Software Foundation; either version 2 of + * the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along with this program; + * if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + * 02111-1307 USA + */ + package com.comphenix.protocol.reflect; import java.lang.reflect.Field; +import java.util.Set; import com.google.common.collect.BiMap; import com.google.common.collect.HashBiMap; @@ -76,4 +94,12 @@ public class IntEnum { public String getDeclaredName(Integer id) { return members.get(id); } + + /** + * Retrieve the ID of every registered member. + * @return Enumeration of every value. + */ + public Set values() { + return members.keySet(); + } } diff --git a/ProtocolLib/src/com/comphenix/protocol/reflect/MethodUtils.java b/ProtocolLib/src/main/java/com/comphenix/protocol/reflect/MethodUtils.java similarity index 100% rename from ProtocolLib/src/com/comphenix/protocol/reflect/MethodUtils.java rename to ProtocolLib/src/main/java/com/comphenix/protocol/reflect/MethodUtils.java diff --git a/ProtocolLib/src/com/comphenix/protocol/reflect/ObjectCloner.java b/ProtocolLib/src/main/java/com/comphenix/protocol/reflect/ObjectCloner.java similarity index 69% rename from ProtocolLib/src/com/comphenix/protocol/reflect/ObjectCloner.java rename to ProtocolLib/src/main/java/com/comphenix/protocol/reflect/ObjectCloner.java index e64c32a8..9ed86545 100644 --- a/ProtocolLib/src/com/comphenix/protocol/reflect/ObjectCloner.java +++ b/ProtocolLib/src/main/java/com/comphenix/protocol/reflect/ObjectCloner.java @@ -1,3 +1,20 @@ +/* + * ProtocolLib - Bukkit server library that allows access to the Minecraft protocol. + * Copyright (C) 2012 Kristian S. Stangeland + * + * This program is free software; you can redistribute it and/or modify it under the terms of the + * GNU General Public License as published by the Free Software Foundation; either version 2 of + * the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along with this program; + * if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + * 02111-1307 USA + */ + package com.comphenix.protocol.reflect; import java.util.concurrent.ConcurrentHashMap; diff --git a/ProtocolLib/src/com/comphenix/protocol/reflect/PrimitiveUtils.java b/ProtocolLib/src/main/java/com/comphenix/protocol/reflect/PrimitiveUtils.java similarity index 100% rename from ProtocolLib/src/com/comphenix/protocol/reflect/PrimitiveUtils.java rename to ProtocolLib/src/main/java/com/comphenix/protocol/reflect/PrimitiveUtils.java diff --git a/ProtocolLib/src/com/comphenix/protocol/reflect/StructureModifier.java b/ProtocolLib/src/main/java/com/comphenix/protocol/reflect/StructureModifier.java similarity index 100% rename from ProtocolLib/src/com/comphenix/protocol/reflect/StructureModifier.java rename to ProtocolLib/src/main/java/com/comphenix/protocol/reflect/StructureModifier.java diff --git a/ProtocolLib/src/com/comphenix/protocol/reflect/VolatileField.java b/ProtocolLib/src/main/java/com/comphenix/protocol/reflect/VolatileField.java similarity index 100% rename from ProtocolLib/src/com/comphenix/protocol/reflect/VolatileField.java rename to ProtocolLib/src/main/java/com/comphenix/protocol/reflect/VolatileField.java diff --git a/ProtocolLib/src/com/comphenix/protocol/reflect/compiler/BackgroundCompiler.java b/ProtocolLib/src/main/java/com/comphenix/protocol/reflect/compiler/BackgroundCompiler.java similarity index 83% rename from ProtocolLib/src/com/comphenix/protocol/reflect/compiler/BackgroundCompiler.java rename to ProtocolLib/src/main/java/com/comphenix/protocol/reflect/compiler/BackgroundCompiler.java index 61a42d48..dfc0eb2a 100644 --- a/ProtocolLib/src/com/comphenix/protocol/reflect/compiler/BackgroundCompiler.java +++ b/ProtocolLib/src/main/java/com/comphenix/protocol/reflect/compiler/BackgroundCompiler.java @@ -1,3 +1,20 @@ +/* + * ProtocolLib - Bukkit server library that allows access to the Minecraft protocol. + * Copyright (C) 2012 Kristian S. Stangeland + * + * This program is free software; you can redistribute it and/or modify it under the terms of the + * GNU General Public License as published by the Free Software Foundation; either version 2 of + * the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along with this program; + * if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + * 02111-1307 USA + */ + package com.comphenix.protocol.reflect.compiler; import java.util.Map; diff --git a/ProtocolLib/src/com/comphenix/protocol/reflect/compiler/BoxingHelper.java b/ProtocolLib/src/main/java/com/comphenix/protocol/reflect/compiler/BoxingHelper.java similarity index 86% rename from ProtocolLib/src/com/comphenix/protocol/reflect/compiler/BoxingHelper.java rename to ProtocolLib/src/main/java/com/comphenix/protocol/reflect/compiler/BoxingHelper.java index 06d043a1..401516d8 100644 --- a/ProtocolLib/src/com/comphenix/protocol/reflect/compiler/BoxingHelper.java +++ b/ProtocolLib/src/main/java/com/comphenix/protocol/reflect/compiler/BoxingHelper.java @@ -1,3 +1,20 @@ +/* + * ProtocolLib - Bukkit server library that allows access to the Minecraft protocol. + * Copyright (C) 2012 Kristian S. Stangeland + * + * This program is free software; you can redistribute it and/or modify it under the terms of the + * GNU General Public License as published by the Free Software Foundation; either version 2 of + * the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along with this program; + * if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + * 02111-1307 USA + */ + package com.comphenix.protocol.reflect.compiler; import net.sf.cglib.asm.*; diff --git a/ProtocolLib/src/main/java/com/comphenix/protocol/reflect/compiler/CompileListener.java b/ProtocolLib/src/main/java/com/comphenix/protocol/reflect/compiler/CompileListener.java new file mode 100644 index 00000000..c8d5f806 --- /dev/null +++ b/ProtocolLib/src/main/java/com/comphenix/protocol/reflect/compiler/CompileListener.java @@ -0,0 +1,34 @@ +/* + * ProtocolLib - Bukkit server library that allows access to the Minecraft protocol. + * Copyright (C) 2012 Kristian S. Stangeland + * + * This program is free software; you can redistribute it and/or modify it under the terms of the + * GNU General Public License as published by the Free Software Foundation; either version 2 of + * the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along with this program; + * if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + * 02111-1307 USA + */ + +package com.comphenix.protocol.reflect.compiler; + +import com.comphenix.protocol.reflect.StructureModifier; + +/** + * Used to save the result of an compilation. + * + * @author Kristian + * @param - type of the structure modifier field. + */ +public interface CompileListener { + /** + * Invoked when a structure modifier has been successfully compiled. + * @param compiledModifier - the compiled structure modifier. + */ + public void onCompiled(StructureModifier compiledModifier); +} diff --git a/ProtocolLib/src/com/comphenix/protocol/reflect/compiler/CompiledStructureModifier.java b/ProtocolLib/src/main/java/com/comphenix/protocol/reflect/compiler/CompiledStructureModifier.java similarity index 68% rename from ProtocolLib/src/com/comphenix/protocol/reflect/compiler/CompiledStructureModifier.java rename to ProtocolLib/src/main/java/com/comphenix/protocol/reflect/compiler/CompiledStructureModifier.java index d96236f7..510f26ba 100644 --- a/ProtocolLib/src/com/comphenix/protocol/reflect/compiler/CompiledStructureModifier.java +++ b/ProtocolLib/src/main/java/com/comphenix/protocol/reflect/compiler/CompiledStructureModifier.java @@ -1,3 +1,20 @@ +/* + * ProtocolLib - Bukkit server library that allows access to the Minecraft protocol. + * Copyright (C) 2012 Kristian S. Stangeland + * + * This program is free software; you can redistribute it and/or modify it under the terms of the + * GNU General Public License as published by the Free Software Foundation; either version 2 of + * the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along with this program; + * if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + * 02111-1307 USA + */ + package com.comphenix.protocol.reflect.compiler; import java.lang.reflect.Field; diff --git a/ProtocolLib/src/com/comphenix/protocol/reflect/compiler/MethodDescriptor.java b/ProtocolLib/src/main/java/com/comphenix/protocol/reflect/compiler/MethodDescriptor.java similarity index 86% rename from ProtocolLib/src/com/comphenix/protocol/reflect/compiler/MethodDescriptor.java rename to ProtocolLib/src/main/java/com/comphenix/protocol/reflect/compiler/MethodDescriptor.java index b1aa1260..7aad74a5 100644 --- a/ProtocolLib/src/com/comphenix/protocol/reflect/compiler/MethodDescriptor.java +++ b/ProtocolLib/src/main/java/com/comphenix/protocol/reflect/compiler/MethodDescriptor.java @@ -1,3 +1,20 @@ +/* + * ProtocolLib - Bukkit server library that allows access to the Minecraft protocol. + * Copyright (C) 2012 Kristian S. Stangeland + * + * This program is free software; you can redistribute it and/or modify it under the terms of the + * GNU General Public License as published by the Free Software Foundation; either version 2 of + * the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along with this program; + * if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + * 02111-1307 USA + */ + package com.comphenix.protocol.reflect.compiler; import java.util.HashMap; diff --git a/ProtocolLib/src/com/comphenix/protocol/reflect/compiler/StructureCompiler.java b/ProtocolLib/src/main/java/com/comphenix/protocol/reflect/compiler/StructureCompiler.java similarity index 92% rename from ProtocolLib/src/com/comphenix/protocol/reflect/compiler/StructureCompiler.java rename to ProtocolLib/src/main/java/com/comphenix/protocol/reflect/compiler/StructureCompiler.java index 24477dff..9c7ce883 100644 --- a/ProtocolLib/src/com/comphenix/protocol/reflect/compiler/StructureCompiler.java +++ b/ProtocolLib/src/main/java/com/comphenix/protocol/reflect/compiler/StructureCompiler.java @@ -1,3 +1,20 @@ +/* + * ProtocolLib - Bukkit server library that allows access to the Minecraft protocol. + * Copyright (C) 2012 Kristian S. Stangeland + * + * This program is free software; you can redistribute it and/or modify it under the terms of the + * GNU General Public License as published by the Free Software Foundation; either version 2 of + * the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along with this program; + * if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + * 02111-1307 USA + */ + package com.comphenix.protocol.reflect.compiler; import java.lang.reflect.Field; diff --git a/ProtocolLib/src/com/comphenix/protocol/reflect/instances/CollectionGenerator.java b/ProtocolLib/src/main/java/com/comphenix/protocol/reflect/instances/CollectionGenerator.java similarity index 59% rename from ProtocolLib/src/com/comphenix/protocol/reflect/instances/CollectionGenerator.java rename to ProtocolLib/src/main/java/com/comphenix/protocol/reflect/instances/CollectionGenerator.java index c7fe4de7..3efc0ae5 100644 --- a/ProtocolLib/src/com/comphenix/protocol/reflect/instances/CollectionGenerator.java +++ b/ProtocolLib/src/main/java/com/comphenix/protocol/reflect/instances/CollectionGenerator.java @@ -1,3 +1,20 @@ +/* + * ProtocolLib - Bukkit server library that allows access to the Minecraft protocol. + * Copyright (C) 2012 Kristian S. Stangeland + * + * This program is free software; you can redistribute it and/or modify it under the terms of the + * GNU General Public License as published by the Free Software Foundation; either version 2 of + * the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along with this program; + * if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + * 02111-1307 USA + */ + package com.comphenix.protocol.reflect.instances; import java.util.ArrayList; diff --git a/ProtocolLib/src/com/comphenix/protocol/reflect/instances/DefaultInstances.java b/ProtocolLib/src/main/java/com/comphenix/protocol/reflect/instances/DefaultInstances.java similarity index 100% rename from ProtocolLib/src/com/comphenix/protocol/reflect/instances/DefaultInstances.java rename to ProtocolLib/src/main/java/com/comphenix/protocol/reflect/instances/DefaultInstances.java diff --git a/ProtocolLib/src/com/comphenix/protocol/reflect/instances/ExistingGenerator.java b/ProtocolLib/src/main/java/com/comphenix/protocol/reflect/instances/ExistingGenerator.java similarity index 76% rename from ProtocolLib/src/com/comphenix/protocol/reflect/instances/ExistingGenerator.java rename to ProtocolLib/src/main/java/com/comphenix/protocol/reflect/instances/ExistingGenerator.java index d183ad95..d5e13a10 100644 --- a/ProtocolLib/src/com/comphenix/protocol/reflect/instances/ExistingGenerator.java +++ b/ProtocolLib/src/main/java/com/comphenix/protocol/reflect/instances/ExistingGenerator.java @@ -1,3 +1,20 @@ +/* + * ProtocolLib - Bukkit server library that allows access to the Minecraft protocol. + * Copyright (C) 2012 Kristian S. Stangeland + * + * This program is free software; you can redistribute it and/or modify it under the terms of the + * GNU General Public License as published by the Free Software Foundation; either version 2 of + * the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along with this program; + * if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + * 02111-1307 USA + */ + package com.comphenix.protocol.reflect.instances; import java.lang.reflect.Field; diff --git a/ProtocolLib/src/main/java/com/comphenix/protocol/reflect/instances/InstanceProvider.java b/ProtocolLib/src/main/java/com/comphenix/protocol/reflect/instances/InstanceProvider.java new file mode 100644 index 00000000..09c42db3 --- /dev/null +++ b/ProtocolLib/src/main/java/com/comphenix/protocol/reflect/instances/InstanceProvider.java @@ -0,0 +1,35 @@ +/* + * ProtocolLib - Bukkit server library that allows access to the Minecraft protocol. + * Copyright (C) 2012 Kristian S. Stangeland + * + * This program is free software; you can redistribute it and/or modify it under the terms of the + * GNU General Public License as published by the Free Software Foundation; either version 2 of + * the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along with this program; + * if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + * 02111-1307 USA + */ + +package com.comphenix.protocol.reflect.instances; + +import javax.annotation.Nullable; + +/** + * Represents a type generator for specific types. + * + * @author Kristian + */ +public interface InstanceProvider { + + /** + * Create an instance given a type, if possible. + * @param type - type to create. + * @return The instance, or NULL if the type cannot be created. + */ + public abstract Object create(@Nullable Class type); +} \ No newline at end of file diff --git a/ProtocolLib/src/com/comphenix/protocol/reflect/instances/PrimitiveGenerator.java b/ProtocolLib/src/main/java/com/comphenix/protocol/reflect/instances/PrimitiveGenerator.java similarity index 62% rename from ProtocolLib/src/com/comphenix/protocol/reflect/instances/PrimitiveGenerator.java rename to ProtocolLib/src/main/java/com/comphenix/protocol/reflect/instances/PrimitiveGenerator.java index c569ad16..5ff4529a 100644 --- a/ProtocolLib/src/com/comphenix/protocol/reflect/instances/PrimitiveGenerator.java +++ b/ProtocolLib/src/main/java/com/comphenix/protocol/reflect/instances/PrimitiveGenerator.java @@ -1,3 +1,20 @@ +/* + * ProtocolLib - Bukkit server library that allows access to the Minecraft protocol. + * Copyright (C) 2012 Kristian S. Stangeland + * + * This program is free software; you can redistribute it and/or modify it under the terms of the + * GNU General Public License as published by the Free Software Foundation; either version 2 of + * the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along with this program; + * if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + * 02111-1307 USA + */ + package com.comphenix.protocol.reflect.instances; import java.lang.reflect.Array; diff --git a/ProtocolLib/src/plugin.yml b/ProtocolLib/src/main/java/plugin.yml similarity index 86% rename from ProtocolLib/src/plugin.yml rename to ProtocolLib/src/main/java/plugin.yml index 3901dcf0..4386cbc8 100644 --- a/ProtocolLib/src/plugin.yml +++ b/ProtocolLib/src/main/java/plugin.yml @@ -1,5 +1,5 @@ name: ProtocolLib -version: 1.3.0 +version: 1.3.1 description: Provides read/write access to the Minecraft protocol. author: Comphenix website: http://www.comphenix.net/ProtocolLib diff --git a/ProtocolLib/test/com/comphenix/protocol/injector/SortedCopyOnWriteArrayTest.java b/ProtocolLib/src/test/java/com/comphenix/protocol/injector/SortedCopyOnWriteArrayTest.java similarity index 100% rename from ProtocolLib/test/com/comphenix/protocol/injector/SortedCopyOnWriteArrayTest.java rename to ProtocolLib/src/test/java/com/comphenix/protocol/injector/SortedCopyOnWriteArrayTest.java diff --git a/ProtocolLib/test/com/comphenix/protocol/reflect/StructureModifierTest.java b/ProtocolLib/src/test/java/com/comphenix/protocol/reflect/StructureModifierTest.java similarity index 100% rename from ProtocolLib/test/com/comphenix/protocol/reflect/StructureModifierTest.java rename to ProtocolLib/src/test/java/com/comphenix/protocol/reflect/StructureModifierTest.java