Skip to content

Commit

Permalink
* 1.3.8 Release, all stable! PacketTypeClasses also added, client sid…
Browse files Browse the repository at this point in the history
…e only for now though
  • Loading branch information
purplexdev committed Jun 29, 2020
1 parent b1d1201 commit ee959b6
Show file tree
Hide file tree
Showing 6 changed files with 77 additions and 3 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>io.github.retrooper</groupId>
<artifactId>packetevents</artifactId>
<version>1.3.7.2</version>
<version>1.3.8</version>
<packaging>jar</packaging>
<name>packetevents</name>
<properties>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,22 @@ public String getPacketName() {
}

/**
* Get the raw NMS packet object
* Get the NMS packet object
*
* @return packet object
*/
public Object getNMSPacket() {
return this.packet;
}

/**
* Get the class of the NMS packet object
* @return packet object class
*/
public Class<?> getNMSPacketClass() {
return getNMSPacket().getClass();
}

/**
* Returns if the packet has been cancelled
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,22 @@ public String getPacketName() {


/**
* Get the raw NMS packet object
* Get the NMS packet object
*
* @return packet object
*/
public Object getNMSPacket() {
return this.packet;
}

/**
* Get the class of the NMS packet object
* @return packet object class
*/
public Class<?> getNMSPacketClass() {
return getNMSPacket().getClass();
}

public boolean isCancelled() {
return cancelled;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ public class MainExample extends JavaPlugin {
public void onEnable() {
PacketEvents.start(this);


getAPI().getServerTickTask().cancel();
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
package io.github.retrooper.packetevents.packet;

import io.github.retrooper.packetevents.annotations.Nullable;
import io.github.retrooper.packetevents.utils.NMSUtils;

public class PacketTypeClasses {
public static class Client {
private static String c = "PacketPlayIn";

@Nullable
public static final Class<?> FLYING = NMSUtils.getNMSClassWithoutException(c + "Flying");

public static Class<?> POSITION, POSITION_LOOK, LOOK, CLIENT_COMMAND,
TRANSACTION, BLOCK_DIG, ENTITY_ACTION, USE_ENTITY,
WINDOW_CLICK, STEER_VEHICLE, CUSTOM_PAYLOAD, ARM_ANIMATION,
BLOCK_PLACE, ABILITIES, HELD_ITEM_SLOT, CLOSE_WINDOW,
TAB_COMPLETE, CHAT, SET_CREATIVE_SLOT, KEEP_ALIVE;

static {
try {
POSITION = NMSUtils.getNMSClass(c + "Position");
POSITION_LOOK = NMSUtils.getNMSClass(c + "PositionLook");
LOOK = NMSUtils.getNMSClass(c + "Look");

CLIENT_COMMAND = NMSUtils.getNMSClass(c + "ClientCommand");
TRANSACTION = NMSUtils.getNMSClass(c + "Transaction");
BLOCK_DIG = NMSUtils.getNMSClass(c + "BlockDig");
ENTITY_ACTION = NMSUtils.getNMSClass(c + "EntityAction");
USE_ENTITY = NMSUtils.getNMSClass(c + "UseEntity");
WINDOW_CLICK = NMSUtils.getNMSClass(c + "WindowClick");
STEER_VEHICLE = NMSUtils.getNMSClass(c + "SteerVehicle");
CUSTOM_PAYLOAD = NMSUtils.getNMSClass(c + "CustomPayload");
ARM_ANIMATION = NMSUtils.getNMSClass(c + "ArmAnimation");
ABILITIES = NMSUtils.getNMSClass(c + "Abilities");
HELD_ITEM_SLOT = NMSUtils.getNMSClass(c + "HeldItemSlot");
CLOSE_WINDOW = NMSUtils.getNMSClass(c + "CloseWindow");
TAB_COMPLETE = NMSUtils.getNMSClass(c + "TabComplete");
CHAT = NMSUtils.getNMSClass(c + "Chat");
SET_CREATIVE_SLOT = NMSUtils.getNMSClass(c + "SetCreativeSlot");
KEEP_ALIVE = NMSUtils.getNMSClass(c + "KeepAlive");
} catch (ClassNotFoundException e) {
e.printStackTrace();
}
//Block place
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,15 @@ public static Class<?> getNMSClass(String name) throws ClassNotFoundException {
return Class.forName(nmsDir + "." + name);
}

public static Class<?> getNMSClassWithoutException(String name) {
try {
return getNMSClass(name);
} catch (ClassNotFoundException e) {
return null;
}

}

public static Class<?> getOBCClass(String name) throws ClassNotFoundException {
return Class.forName(obcDir + "." + name);
}
Expand Down

0 comments on commit ee959b6

Please sign in to comment.