Skip to content

Commit

Permalink
Format project, update headers, add collision rule
Browse files Browse the repository at this point in the history
Fixes #26
  • Loading branch information
dmulloy2 committed May 8, 2016
1 parent 84b7cd8 commit c7d944a
Show file tree
Hide file tree
Showing 121 changed files with 10,082 additions and 9,310 deletions.
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
/**
* This file is part of PacketWrapper.
* Copyright (C) 2012-2015 Kristian S. Strangeland
* Copyright (C) 2015 dmulloy2
* PacketWrapper - ProtocolLib wrappers for Minecraft packets
* Copyright (C) dmulloy2 <http://dmulloy2.net>
* Copyright (C) Kristian S. Strangeland
*
* PacketWrapper is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* 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 3 of the License, or
* (at your option) any later version.
*
* PacketWrapper is distributed in the hope that it will be useful,
* 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 Lesser General Public License
* along with PacketWrapper. If not, see <http://www.gnu.org/licenses/>.
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.comphenix.packetwrapper;

Expand All @@ -33,6 +33,7 @@ public abstract class AbstractPacket {

/**
* Constructs a new strongly typed wrapper for the given packet.
*
* @param handle - handle to the raw packet data.
* @param type - the packet type.
*/
Expand All @@ -41,13 +42,15 @@ protected AbstractPacket(PacketContainer handle, PacketType type) {
if (handle == null)
throw new IllegalArgumentException("Packet handle cannot be NULL.");
if (!Objects.equal(handle.getType(), type))
throw new IllegalArgumentException(handle.getHandle() + " is not a packet of type " + type);
throw new IllegalArgumentException(handle.getHandle()
+ " is not a packet of type " + type);

this.handle = handle;
}

/**
* Retrieve a handle to the raw packet data.
*
* @return Raw packet data.
*/
public PacketContainer getHandle() {
Expand All @@ -56,19 +59,22 @@ public PacketContainer getHandle() {

/**
* Send the current packet to the given receiver.
*
* @param receiver - the receiver.
* @throws RuntimeException If the packet cannot be sent.
*/
public void sendPacket(Player receiver) {
try {
ProtocolLibrary.getProtocolManager().sendServerPacket(receiver, getHandle());
ProtocolLibrary.getProtocolManager().sendServerPacket(receiver,
getHandle());
} catch (InvocationTargetException e) {
throw new RuntimeException("Cannot send packet.", e);
}
}

/**
* Simulate receiving the current packet from the given sender.
*
* @param sender - the sender.
* @throws RuntimeException If the packet cannot be received.
* @deprecated Misspelled. recieve -> receive
Expand All @@ -77,20 +83,23 @@ public void sendPacket(Player receiver) {
@Deprecated
public void recievePacket(Player sender) {
try {
ProtocolLibrary.getProtocolManager().recieveClientPacket(sender, getHandle());
ProtocolLibrary.getProtocolManager().recieveClientPacket(sender,
getHandle());
} catch (Exception e) {
throw new RuntimeException("Cannot recieve packet.", e);
}
}

/**
* Simulate receiving the current packet from the given sender.
*
* @param sender - the sender.
* @throws RuntimeException if the packet cannot be received.
*/
public void receivePacket(Player sender) {
try {
ProtocolLibrary.getProtocolManager().recieveClientPacket(sender, getHandle());
ProtocolLibrary.getProtocolManager().recieveClientPacket(sender,
getHandle());
} catch (Exception e) {
throw new RuntimeException("Cannot recieve packet.", e);
}
Expand Down
Loading

0 comments on commit c7d944a

Please sign in to comment.