Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
90e490466e | ||
|
|
2743dafc40 | ||
|
|
7443f3f965 | ||
|
|
5e493a386c | ||
|
|
321b306a34 | ||
|
|
08996c3e17 | ||
|
|
39fc28def6 | ||
|
|
c2b0109820 | ||
|
|
86dbca109b | ||
|
|
904a9c458d | ||
|
|
36431251c0 |
No files matched your search
@@ -1,17 +1,18 @@
|
||||
# packetevents by purplex
|
||||
Listen to minecraft packets.
|
||||
|
||||
PacketEvents coded by purplex.
|
||||
PacketListener coded by purplex.
|
||||
|
||||
Licensed with the GPL3 license.
|
||||
|
||||
[](https://www.gnu.org/licenses/gpl-3.0)
|
||||
|
||||
Coding help discord server: https://discord.gg/ZWTkg4v
|
||||
|
||||
Examples can be found in this class->
|
||||
me/purplex/packetevents/example/TestExample.java
|
||||
How to use with **Gradle, Maven, sbt and leiningen**.
|
||||
|
||||
The lastest stable tested versions are displayed below.
|
||||
|
||||
How to use with gradle, maven, sbt and leiningen.
|
||||
The last stable tested versions are displayed below.
|
||||
Updated daily.
|
||||
[](https://jitpack.io/#purplexdev/packetevents)
|
||||
|
||||
# Gradle
|
||||
|
||||
@@ -65,4 +66,3 @@ libraryDependencies += "com.github.purplexdev" % "packetevents" % "1.1.5"
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
|
||||
<groupId>me.purplex</groupId>
|
||||
<artifactId>packetevents</artifactId>
|
||||
<version>1.1.5</version>
|
||||
<version>1.1.7</version>
|
||||
<packaging>jar</packaging>
|
||||
<name>packetevents</name>
|
||||
<properties>
|
||||
|
||||
@@ -4,6 +4,7 @@ import me.purplex.packetevents.customlistener.injector.PacketInjector;
|
||||
import me.purplex.packetevents.events.packetevent.ServerTickEvent;
|
||||
import me.purplex.packetevents.example.TestExample;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.*;
|
||||
import org.bukkit.event.player.PlayerJoinEvent;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
@@ -38,7 +39,7 @@ public class Main extends JavaPlugin implements Listener {
|
||||
* This is just an example
|
||||
*/
|
||||
|
||||
//PacketEvents.getPacketManager().unregisterListener(new TestExample());
|
||||
PacketEvents.getPacketManager().unregisterListener(new TestExample());
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
@@ -60,5 +61,4 @@ public class Main extends JavaPlugin implements Listener {
|
||||
return instance;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
package me.purplex.packetevents.enums;
|
||||
|
||||
public enum EntityUseAction {
|
||||
INTERACT, INTERACT_AT, ATTACK, INVALID;
|
||||
INTERACT, INTERACT_AT, ATTACK, INVALID
|
||||
}
|
||||
@@ -17,5 +17,5 @@ public enum PlayerAction {
|
||||
|
||||
OPEN_INVENTORY,
|
||||
|
||||
START_FALL_FLYING;
|
||||
START_FALL_FLYING
|
||||
}
|
||||
@@ -16,8 +16,7 @@ public enum PlayerDigType {
|
||||
|
||||
SWAP_HELD_ITEMS,
|
||||
|
||||
WRONG_PACKET;
|
||||
|
||||
WRONG_PACKET
|
||||
|
||||
|
||||
}
|
||||
@@ -9,13 +9,13 @@ import me.purplex.packetevents.events.packetevent.PacketSendEvent;
|
||||
import java.util.LinkedList;
|
||||
|
||||
public interface PacketEventManager {
|
||||
public LinkedList<PacketListener> packetListeners = new LinkedList<>();
|
||||
public void callEvent(PacketEvent e);
|
||||
LinkedList<PacketListener> packetListeners = new LinkedList<>();
|
||||
void callEvent(PacketEvent e);
|
||||
|
||||
public void registerListener(PacketListener e);
|
||||
public void unregisterListener(PacketListener e);
|
||||
void registerListener(PacketListener e);
|
||||
void unregisterListener(PacketListener e);
|
||||
|
||||
public void unregisterAllListeners(PacketListener e);
|
||||
void unregisterAllListeners(PacketListener e);
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,6 +1,20 @@
|
||||
package me.purplex.packetevents.events;
|
||||
|
||||
|
||||
public class PacketEvent {
|
||||
import me.purplex.packetevents.enums.ServerVersion;
|
||||
|
||||
public class PacketEvent {
|
||||
protected long timestamp;
|
||||
protected static ServerVersion version;
|
||||
static {
|
||||
version = ServerVersion.getVersion();
|
||||
}
|
||||
|
||||
/**
|
||||
* Timestamp of the packet
|
||||
* @return
|
||||
*/
|
||||
public long getTimestamp() {
|
||||
return timestamp;
|
||||
}
|
||||
}
|
||||
@@ -10,12 +10,9 @@ public class PacketReceiveEvent extends PacketEvent {
|
||||
private final Player player;
|
||||
private final String name;
|
||||
private final Object packet;
|
||||
private final long timestamp;
|
||||
private boolean cancelled;
|
||||
public final ServerVersion version;
|
||||
|
||||
public PacketReceiveEvent(Player player, String packetName, Object packet) {
|
||||
this.version = PacketEvents.getServerVersion();
|
||||
this.player = player;
|
||||
this.name = packetName;
|
||||
this.packet = packet;
|
||||
@@ -50,15 +47,6 @@ public class PacketReceiveEvent extends PacketEvent {
|
||||
return this.packet;
|
||||
}
|
||||
|
||||
/**
|
||||
* The time the packet was received(ms)
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public long getTimestamp() {
|
||||
return timestamp;
|
||||
}
|
||||
|
||||
/**
|
||||
* Cancel the packet
|
||||
*
|
||||
|
||||
@@ -9,12 +9,9 @@ public class PacketSendEvent extends PacketEvent {
|
||||
private final Player player;
|
||||
private final String name;
|
||||
private final Object packet;
|
||||
private final long timestamp;
|
||||
private boolean cancelled;
|
||||
public final ServerVersion version;
|
||||
|
||||
public PacketSendEvent(Player player, String packetName, Object packet) {
|
||||
this.version = PacketEvents.getServerVersion();
|
||||
this.player = player;
|
||||
this.name = packetName;
|
||||
this.packet = packet;
|
||||
@@ -41,12 +38,6 @@ public class PacketSendEvent extends PacketEvent {
|
||||
}
|
||||
|
||||
|
||||
|
||||
public long getTimestamp() {
|
||||
return timestamp;
|
||||
}
|
||||
|
||||
|
||||
public void setCancelled(boolean cancelled) {
|
||||
this.cancelled = cancelled;
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@ import me.purplex.packetevents.events.PacketEvent;
|
||||
|
||||
public class ServerTickEvent extends PacketEvent {
|
||||
|
||||
private long timestamp;
|
||||
private final long timestamp;
|
||||
public ServerTickEvent(long timestamp) {
|
||||
this.timestamp = timestamp;
|
||||
}
|
||||
|
||||
@@ -24,6 +24,7 @@ public class TestExample implements PacketListener {
|
||||
@PacketHandler
|
||||
public void onPacketReceive(PacketReceiveEvent e) {
|
||||
final Player p = e.getPlayer();
|
||||
final long timestamp = e.getTimestamp();
|
||||
//ONLY CLIENT PACKETS ALLOWED HERE!
|
||||
switch (e.getPacketName()) {
|
||||
case Packet.Client.USE_ENTITY:
|
||||
@@ -31,7 +32,7 @@ public class TestExample implements PacketListener {
|
||||
final Entity entity = useEntity.getEntity();
|
||||
if (useEntity.getEntityUseAction() == EntityUseAction.ATTACK) {
|
||||
final double dist = entity.getLocation().distanceSquared(p.getLocation());
|
||||
p.sendMessage("dist: " + dist);
|
||||
//p.sendMessage("dist: " + dist);
|
||||
}
|
||||
break;
|
||||
case Packet.Client.ABILITIES:
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
package me.purplex.packetevents.packetwrappers.api;
|
||||
|
||||
import me.purplex.packetevents.enums.ServerVersion;
|
||||
|
||||
public abstract class WrappedVersionPacket {
|
||||
protected final Object packet;
|
||||
protected static ServerVersion version;
|
||||
static {
|
||||
version = ServerVersion.getVersion();
|
||||
}
|
||||
public WrappedVersionPacket(Object packet) {
|
||||
this.packet = packet;
|
||||
setup();
|
||||
}
|
||||
|
||||
protected abstract void setup();
|
||||
}
|
||||
+1
@@ -3,6 +3,7 @@ package me.purplex.packetevents.packetwrappers.in;
|
||||
|
||||
import me.purplex.packetevents.enums.ServerVersion;
|
||||
import me.purplex.packetevents.packetwrappers.api.WrappedPacket;
|
||||
import me.purplex.packetevents.packetwrappers.api.WrappedVersionPacket;
|
||||
import me.purplex.packetevents.packetwrappers.in._1_10.WrappedPacketPlayInAbilities_1_10;
|
||||
import me.purplex.packetevents.packetwrappers.in._1_11.WrappedPacketPlayInAbilities_1_11;
|
||||
import me.purplex.packetevents.packetwrappers.in._1_12.WrappedPacketPlayInAbilities_1_12;
|
||||
|
||||
+35
-38
@@ -1,47 +1,11 @@
|
||||
package me.purplex.packetevents.packetwrappers.in._1_10;
|
||||
|
||||
import me.purplex.packetevents.packetwrappers.api.WrappedVersionPacket;
|
||||
import net.minecraft.server.v1_10_R1.PacketPlayInAbilities;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
|
||||
public class WrappedPacketPlayInAbilities_1_10 {
|
||||
private final Object packet;
|
||||
|
||||
private Field fieldE;
|
||||
private Field fieldF;
|
||||
public WrappedPacketPlayInAbilities_1_10(Object packet) {
|
||||
this.packet = packet;
|
||||
try {
|
||||
this.fieldE = PacketPlayInAbilities.class.getDeclaredField("e");
|
||||
} catch (NoSuchFieldException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
try {
|
||||
this.fieldF = PacketPlayInAbilities.class.getDeclaredField("f");
|
||||
} catch (NoSuchFieldException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
setupFields();
|
||||
}
|
||||
|
||||
|
||||
private void setupFields() {
|
||||
PacketPlayInAbilities p = (PacketPlayInAbilities) packet;
|
||||
this.a = p.a();
|
||||
this.b = p.isFlying();
|
||||
this.c = p.c();
|
||||
this.d = p.d();
|
||||
try {
|
||||
this.e = fieldE.getFloat(p);
|
||||
} catch (IllegalAccessException illegalAccessException) {
|
||||
illegalAccessException.printStackTrace();
|
||||
}
|
||||
try {
|
||||
this.f = fieldF.getFloat(p);
|
||||
} catch (IllegalAccessException illegalAccessException) {
|
||||
illegalAccessException.printStackTrace();
|
||||
}
|
||||
}
|
||||
public class WrappedPacketPlayInAbilities_1_10 extends WrappedVersionPacket {
|
||||
|
||||
public boolean a;
|
||||
public boolean b;
|
||||
@@ -49,4 +13,37 @@ public class WrappedPacketPlayInAbilities_1_10 {
|
||||
public boolean d;
|
||||
public float e;
|
||||
public float f;
|
||||
|
||||
public WrappedPacketPlayInAbilities_1_10(Object packet) {
|
||||
super(packet);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setup() {
|
||||
PacketPlayInAbilities p = (PacketPlayInAbilities) packet;
|
||||
this.a = p.a();
|
||||
this.b = p.isFlying();
|
||||
this.c = p.c();
|
||||
this.d = p.d();
|
||||
try {
|
||||
this.e = fieldE.getFloat(p);
|
||||
this.f = fieldF.getFloat(p);
|
||||
} catch (IllegalAccessException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
private static Field fieldE;
|
||||
private static Field fieldF;
|
||||
|
||||
static {
|
||||
try {
|
||||
fieldE = PacketPlayInAbilities.class.getDeclaredField("e");
|
||||
fieldE.setAccessible(true);
|
||||
fieldF = PacketPlayInAbilities.class.getDeclaredField("f");
|
||||
fieldF.setAccessible(true);
|
||||
} catch (NoSuchFieldException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
+8
-8
@@ -1,21 +1,21 @@
|
||||
package me.purplex.packetevents.packetwrappers.in._1_10;
|
||||
|
||||
import me.purplex.packetevents.enums.PlayerDigType;
|
||||
import me.purplex.packetevents.packetwrappers.api.WrappedVersionPacket;
|
||||
import net.minecraft.server.v1_10_R1.PacketPlayInBlockDig;
|
||||
|
||||
public class WrappedPacketPlayInBlockDig_1_10 {
|
||||
private final Object packet;
|
||||
public class WrappedPacketPlayInBlockDig_1_10 extends WrappedVersionPacket {
|
||||
|
||||
public PlayerDigType digType;
|
||||
|
||||
public WrappedPacketPlayInBlockDig_1_10(Object packet) {
|
||||
this.packet = packet;
|
||||
setupDigType();
|
||||
super(packet);
|
||||
}
|
||||
|
||||
private void setupDigType() {
|
||||
@Override
|
||||
protected void setup() {
|
||||
PacketPlayInBlockDig p = (PacketPlayInBlockDig)packet;
|
||||
String name = p.c().name();
|
||||
this.digType = PlayerDigType.valueOf(name);
|
||||
}
|
||||
|
||||
public PlayerDigType digType;
|
||||
|
||||
}
|
||||
+32
-47
@@ -1,11 +1,11 @@
|
||||
package me.purplex.packetevents.packetwrappers.in._1_10;
|
||||
|
||||
import me.purplex.packetevents.packetwrappers.api.WrappedVersionPacket;
|
||||
import net.minecraft.server.v1_10_R1.PacketPlayInFlying;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
|
||||
public class WrappedPacketPlayInFlying_1_10 {
|
||||
private final Object packet;
|
||||
public class WrappedPacketPlayInFlying_1_10 extends WrappedVersionPacket {
|
||||
|
||||
public double x;
|
||||
public double y;
|
||||
@@ -15,38 +15,44 @@ public class WrappedPacketPlayInFlying_1_10 {
|
||||
public boolean f;
|
||||
public boolean hasPos;
|
||||
public boolean hasLook;
|
||||
|
||||
public WrappedPacketPlayInFlying_1_10(Object packet) {
|
||||
this.packet = packet;
|
||||
super(packet);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setup() {
|
||||
PacketPlayInFlying p = (PacketPlayInFlying) packet;
|
||||
try {
|
||||
setupFields();
|
||||
this.hasPos = fieldHasPos.getBoolean(p);
|
||||
this.hasLook = fieldHasLook.getBoolean(p);
|
||||
} catch (IllegalAccessException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
private void setupFields() throws IllegalAccessException {
|
||||
PacketPlayInFlying p = (PacketPlayInFlying) packet;
|
||||
this.hasPos = fieldHasPos.getBoolean(p);
|
||||
this.hasLook = fieldHasLook.getBoolean(p);
|
||||
if (hasPos) {
|
||||
this.x = p.a(0.0D);
|
||||
this.y = p.b(0.0D);
|
||||
this.z = p.c(0.0D);
|
||||
} else {
|
||||
this.x = fieldX.getDouble(p);
|
||||
this.y = fieldY.getDouble(p);
|
||||
this.z = fieldZ.getDouble(p);
|
||||
try {
|
||||
this.x = fieldX.getDouble(p);
|
||||
this.y = fieldY.getDouble(p);
|
||||
this.z = fieldZ.getDouble(p);
|
||||
} catch (IllegalAccessException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
if (hasLook) {
|
||||
this.yaw = p.a(0.0F);
|
||||
this.pitch = p.b(0.0F);
|
||||
}
|
||||
else {
|
||||
this.yaw = fieldYaw.getFloat(p);
|
||||
this.pitch = fieldPitch.getFloat(p);
|
||||
} else {
|
||||
try {
|
||||
this.yaw = fieldYaw.getFloat(p);
|
||||
this.pitch = fieldPitch.getFloat(p);
|
||||
} catch (IllegalAccessException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
this.f = p.a();
|
||||
}
|
||||
@@ -79,40 +85,19 @@ public class WrappedPacketPlayInFlying_1_10 {
|
||||
static {
|
||||
try {
|
||||
fieldHasPos = PacketPlayInFlying.class.getDeclaredField("hasPos");
|
||||
} catch (NoSuchFieldException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
try {
|
||||
fieldHasPos.setAccessible(true);
|
||||
fieldHasLook = PacketPlayInFlying.class.getDeclaredField("hasLook");
|
||||
} catch (NoSuchFieldException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
try {
|
||||
fieldHasLook.setAccessible(true);
|
||||
fieldX = PacketPlayInFlying.class.getDeclaredField("x");
|
||||
} catch (NoSuchFieldException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
try {
|
||||
fieldX.setAccessible(true);
|
||||
fieldY = PacketPlayInFlying.class.getDeclaredField("y");
|
||||
} catch (NoSuchFieldException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
try {
|
||||
fieldY.setAccessible(true);
|
||||
fieldZ = PacketPlayInFlying.class.getDeclaredField("z");
|
||||
} catch (NoSuchFieldException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
try {
|
||||
fieldZ.setAccessible(true);
|
||||
fieldYaw = PacketPlayInFlying.class.getDeclaredField("yaw");
|
||||
} catch (NoSuchFieldException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
try {
|
||||
fieldYaw.setAccessible(true);
|
||||
fieldPitch = PacketPlayInFlying.class.getDeclaredField("pitch");
|
||||
fieldPitch.setAccessible(true);
|
||||
} catch (NoSuchFieldException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
+22
-22
@@ -1,29 +1,23 @@
|
||||
package me.purplex.packetevents.packetwrappers.in._1_10;
|
||||
|
||||
import me.purplex.packetevents.enums.EntityUseAction;
|
||||
import me.purplex.packetevents.enums.ServerVersion;
|
||||
import me.purplex.packetevents.packetwrappers.api.WrappedVersionPacket;
|
||||
import net.minecraft.server.v1_10_R1.Entity;
|
||||
import net.minecraft.server.v1_10_R1.PacketPlayInUseEntity;
|
||||
import net.minecraft.server.v1_10_R1.WorldServer;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.craftbukkit.v1_10_R1.CraftWorld;
|
||||
|
||||
public class WrappedPacketPlayInUseEntity_1_10 {
|
||||
private final ServerVersion version;
|
||||
private Entity entity;
|
||||
public class WrappedPacketPlayInUseEntity_1_10 extends WrappedVersionPacket {
|
||||
private org.bukkit.entity.Entity entity;
|
||||
private EntityUseAction action;
|
||||
private final Object packet;
|
||||
|
||||
public WrappedPacketPlayInUseEntity_1_10(Object packet) {
|
||||
this.version = ServerVersion.getVersion();
|
||||
this.packet = packet;
|
||||
setupEntity();
|
||||
setupAction();
|
||||
super(packet);
|
||||
}
|
||||
|
||||
private Object getRawPacket() {
|
||||
return this.packet;
|
||||
}
|
||||
|
||||
public Entity getEntity() {
|
||||
public org.bukkit.entity.Entity getEntity() {
|
||||
return entity;
|
||||
}
|
||||
|
||||
@@ -31,24 +25,30 @@ public class WrappedPacketPlayInUseEntity_1_10 {
|
||||
return action;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setup() {
|
||||
setupEntity();
|
||||
setupAction();
|
||||
}
|
||||
|
||||
private void setupEntity() {
|
||||
net.minecraft.server.v1_10_R1.PacketPlayInUseEntity packet = (net.minecraft.server.v1_10_R1.PacketPlayInUseEntity) getRawPacket();
|
||||
net.minecraft.server.v1_10_R1.WorldServer worldServer = null;
|
||||
PacketPlayInUseEntity p = (PacketPlayInUseEntity) packet;
|
||||
WorldServer worldServer = null;
|
||||
for (World bukkitWorld : Bukkit.getWorlds()) {
|
||||
org.bukkit.craftbukkit.v1_10_R1.CraftWorld craftWorld = (org.bukkit.craftbukkit.v1_10_R1.CraftWorld) bukkitWorld;
|
||||
CraftWorld craftWorld = (CraftWorld) bukkitWorld;
|
||||
worldServer = craftWorld.getHandle();
|
||||
if (packet.a(worldServer) != null) {
|
||||
if (p.a(worldServer) != null) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
net.minecraft.server.v1_10_R1.Entity entity = packet.a(worldServer);
|
||||
Entity entity = p.a(worldServer);
|
||||
this.entity = entity.getBukkitEntity();
|
||||
|
||||
}
|
||||
|
||||
private void setupAction() {
|
||||
net.minecraft.server.v1_10_R1.PacketPlayInUseEntity packet = (net.minecraft.server.v1_10_R1.PacketPlayInUseEntity) getRawPacket();
|
||||
String name = packet.a().name();
|
||||
PacketPlayInUseEntity p = (PacketPlayInUseEntity) packet;
|
||||
String name = p.a().name();
|
||||
this.action = EntityUseAction.valueOf(name);
|
||||
}
|
||||
}
|
||||
+35
-38
@@ -1,47 +1,11 @@
|
||||
package me.purplex.packetevents.packetwrappers.in._1_11;
|
||||
|
||||
import me.purplex.packetevents.packetwrappers.api.WrappedVersionPacket;
|
||||
import net.minecraft.server.v1_11_R1.PacketPlayInAbilities;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
|
||||
public class WrappedPacketPlayInAbilities_1_11 {
|
||||
private final Object packet;
|
||||
|
||||
private Field fieldE;
|
||||
private Field fieldF;
|
||||
public WrappedPacketPlayInAbilities_1_11(Object packet) {
|
||||
this.packet = packet;
|
||||
try {
|
||||
this.fieldE = PacketPlayInAbilities.class.getDeclaredField("e");
|
||||
} catch (NoSuchFieldException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
try {
|
||||
this.fieldF = PacketPlayInAbilities.class.getDeclaredField("f");
|
||||
} catch (NoSuchFieldException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
setupFields();
|
||||
}
|
||||
|
||||
|
||||
private void setupFields() {
|
||||
PacketPlayInAbilities p = (PacketPlayInAbilities) packet;
|
||||
this.a = p.a();
|
||||
this.b = p.isFlying();
|
||||
this.c = p.c();
|
||||
this.d = p.d();
|
||||
try {
|
||||
this.e = fieldE.getFloat(p);
|
||||
} catch (IllegalAccessException illegalAccessException) {
|
||||
illegalAccessException.printStackTrace();
|
||||
}
|
||||
try {
|
||||
this.f = fieldF.getFloat(p);
|
||||
} catch (IllegalAccessException illegalAccessException) {
|
||||
illegalAccessException.printStackTrace();
|
||||
}
|
||||
}
|
||||
public class WrappedPacketPlayInAbilities_1_11 extends WrappedVersionPacket {
|
||||
|
||||
public boolean a;
|
||||
public boolean b;
|
||||
@@ -49,4 +13,37 @@ public class WrappedPacketPlayInAbilities_1_11 {
|
||||
public boolean d;
|
||||
public float e;
|
||||
public float f;
|
||||
|
||||
public WrappedPacketPlayInAbilities_1_11(Object packet) {
|
||||
super(packet);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setup() {
|
||||
PacketPlayInAbilities p = (PacketPlayInAbilities) packet;
|
||||
this.a = p.a();
|
||||
this.b = p.isFlying();
|
||||
this.c = p.c();
|
||||
this.d = p.d();
|
||||
try {
|
||||
this.e = fieldE.getFloat(p);
|
||||
this.f = fieldF.getFloat(p);
|
||||
} catch (IllegalAccessException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
private static Field fieldE;
|
||||
private static Field fieldF;
|
||||
|
||||
static {
|
||||
try {
|
||||
fieldE = PacketPlayInAbilities.class.getDeclaredField("e");
|
||||
fieldE.setAccessible(true);
|
||||
fieldF = PacketPlayInAbilities.class.getDeclaredField("f");
|
||||
fieldF.setAccessible(true);
|
||||
} catch (NoSuchFieldException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
+8
-7
@@ -1,21 +1,22 @@
|
||||
package me.purplex.packetevents.packetwrappers.in._1_11;
|
||||
|
||||
import me.purplex.packetevents.enums.PlayerDigType;
|
||||
import me.purplex.packetevents.packetwrappers.api.WrappedVersionPacket;
|
||||
import net.minecraft.server.v1_11_R1.PacketPlayInBlockDig;
|
||||
|
||||
public class WrappedPacketPlayInBlockDig_1_11 {
|
||||
private final Object packet;
|
||||
public class WrappedPacketPlayInBlockDig_1_11 extends WrappedVersionPacket {
|
||||
|
||||
public PlayerDigType digType;
|
||||
|
||||
public WrappedPacketPlayInBlockDig_1_11(Object packet) {
|
||||
this.packet = packet;
|
||||
setupDigType();
|
||||
super(packet);
|
||||
}
|
||||
|
||||
private void setupDigType() {
|
||||
@Override
|
||||
protected void setup() {
|
||||
PacketPlayInBlockDig p = (PacketPlayInBlockDig)packet;
|
||||
String name = p.c().name();
|
||||
this.digType = PlayerDigType.valueOf(name);
|
||||
}
|
||||
|
||||
public PlayerDigType digType;
|
||||
|
||||
}
|
||||
+34
-50
@@ -1,11 +1,11 @@
|
||||
package me.purplex.packetevents.packetwrappers.in._1_11;
|
||||
|
||||
import me.purplex.packetevents.packetwrappers.api.WrappedVersionPacket;
|
||||
import net.minecraft.server.v1_11_R1.PacketPlayInFlying;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
|
||||
public class WrappedPacketPlayInFlying_1_11 {
|
||||
private final Object packet;
|
||||
public class WrappedPacketPlayInFlying_1_11 extends WrappedVersionPacket {
|
||||
|
||||
public double x;
|
||||
public double y;
|
||||
@@ -15,43 +15,50 @@ public class WrappedPacketPlayInFlying_1_11 {
|
||||
public boolean f;
|
||||
public boolean hasPos;
|
||||
public boolean hasLook;
|
||||
|
||||
public WrappedPacketPlayInFlying_1_11(Object packet) {
|
||||
this.packet = packet;
|
||||
try {
|
||||
setupFields();
|
||||
} catch (IllegalAccessException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
super(packet);
|
||||
}
|
||||
|
||||
|
||||
|
||||
private void setupFields() throws IllegalAccessException {
|
||||
@Override
|
||||
protected void setup() {
|
||||
PacketPlayInFlying p = (PacketPlayInFlying) packet;
|
||||
this.hasPos = fieldHasPos.getBoolean(p);
|
||||
this.hasLook = fieldHasLook.getBoolean(p);
|
||||
try {
|
||||
this.hasPos = fieldHasPos.getBoolean(p);
|
||||
this.hasLook = fieldHasLook.getBoolean(p);
|
||||
} catch (IllegalAccessException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
if (hasPos) {
|
||||
this.x = p.a(0.0D);
|
||||
this.y = p.b(0.0D);
|
||||
this.z = p.c(0.0D);
|
||||
} else {
|
||||
this.x = fieldX.getDouble(p);
|
||||
this.y = fieldY.getDouble(p);
|
||||
this.z = fieldZ.getDouble(p);
|
||||
try {
|
||||
this.x = fieldX.getDouble(p);
|
||||
this.y = fieldY.getDouble(p);
|
||||
this.z = fieldZ.getDouble(p);
|
||||
} catch (IllegalAccessException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
if (hasLook) {
|
||||
this.yaw = p.a(0.0F);
|
||||
this.pitch = p.b(0.0F);
|
||||
}
|
||||
else {
|
||||
this.yaw = fieldYaw.getFloat(p);
|
||||
this.pitch = fieldPitch.getFloat(p);
|
||||
} else {
|
||||
try {
|
||||
this.yaw = fieldYaw.getFloat(p);
|
||||
this.pitch = fieldPitch.getFloat(p);
|
||||
} catch (IllegalAccessException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
this.f = p.a();
|
||||
}
|
||||
|
||||
public static class WrappedPacketPlayInPosition_1_11 extends WrappedPacketPlayInFlying_1_11{
|
||||
public static class WrappedPacketPlayInPosition_1_11 extends WrappedPacketPlayInFlying_1_11 {
|
||||
|
||||
public WrappedPacketPlayInPosition_1_11(Object packet) {
|
||||
super(packet);
|
||||
@@ -79,45 +86,22 @@ public class WrappedPacketPlayInFlying_1_11 {
|
||||
static {
|
||||
try {
|
||||
fieldHasPos = PacketPlayInFlying.class.getDeclaredField("hasPos");
|
||||
} catch (NoSuchFieldException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
try {
|
||||
fieldHasPos.setAccessible(true);
|
||||
fieldHasLook = PacketPlayInFlying.class.getDeclaredField("hasLook");
|
||||
} catch (NoSuchFieldException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
try {
|
||||
fieldHasLook.setAccessible(true);
|
||||
fieldX = PacketPlayInFlying.class.getDeclaredField("x");
|
||||
} catch (NoSuchFieldException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
try {
|
||||
fieldX.setAccessible(true);
|
||||
fieldY = PacketPlayInFlying.class.getDeclaredField("y");
|
||||
} catch (NoSuchFieldException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
try {
|
||||
fieldY.setAccessible(true);
|
||||
fieldZ = PacketPlayInFlying.class.getDeclaredField("z");
|
||||
} catch (NoSuchFieldException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
try {
|
||||
fieldZ.setAccessible(true);
|
||||
fieldYaw = PacketPlayInFlying.class.getDeclaredField("yaw");
|
||||
} catch (NoSuchFieldException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
try {
|
||||
fieldYaw.setAccessible(true);
|
||||
fieldPitch = PacketPlayInFlying.class.getDeclaredField("pitch");
|
||||
fieldPitch.setAccessible(true);
|
||||
} catch (NoSuchFieldException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
+22
-22
@@ -1,29 +1,23 @@
|
||||
package me.purplex.packetevents.packetwrappers.in._1_11;
|
||||
|
||||
import me.purplex.packetevents.enums.EntityUseAction;
|
||||
import me.purplex.packetevents.enums.ServerVersion;
|
||||
import me.purplex.packetevents.packetwrappers.api.WrappedVersionPacket;
|
||||
import net.minecraft.server.v1_11_R1.Entity;
|
||||
import net.minecraft.server.v1_11_R1.PacketPlayInUseEntity;
|
||||
import net.minecraft.server.v1_11_R1.WorldServer;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.craftbukkit.v1_11_R1.CraftWorld;
|
||||
|
||||
public class WrappedPacketPlayInUseEntity_1_11 {
|
||||
private final ServerVersion version;
|
||||
private Entity entity;
|
||||
public class WrappedPacketPlayInUseEntity_1_11 extends WrappedVersionPacket {
|
||||
private org.bukkit.entity.Entity entity;
|
||||
private EntityUseAction action;
|
||||
private final Object packet;
|
||||
|
||||
public WrappedPacketPlayInUseEntity_1_11(Object packet) {
|
||||
this.version = ServerVersion.getVersion();
|
||||
this.packet = packet;
|
||||
setupEntity();
|
||||
setupAction();
|
||||
super(packet);
|
||||
}
|
||||
|
||||
private Object getRawPacket() {
|
||||
return this.packet;
|
||||
}
|
||||
|
||||
public Entity getEntity() {
|
||||
public org.bukkit.entity.Entity getEntity() {
|
||||
return entity;
|
||||
}
|
||||
|
||||
@@ -31,24 +25,30 @@ public class WrappedPacketPlayInUseEntity_1_11 {
|
||||
return action;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setup() {
|
||||
setupEntity();
|
||||
setupAction();
|
||||
}
|
||||
|
||||
private void setupEntity() {
|
||||
net.minecraft.server.v1_11_R1.PacketPlayInUseEntity packet = (net.minecraft.server.v1_11_R1.PacketPlayInUseEntity) getRawPacket();
|
||||
net.minecraft.server.v1_11_R1.WorldServer worldServer = null;
|
||||
PacketPlayInUseEntity p = (PacketPlayInUseEntity) packet;
|
||||
WorldServer worldServer = null;
|
||||
for (World bukkitWorld : Bukkit.getWorlds()) {
|
||||
org.bukkit.craftbukkit.v1_11_R1.CraftWorld craftWorld = (org.bukkit.craftbukkit.v1_11_R1.CraftWorld) bukkitWorld;
|
||||
CraftWorld craftWorld = (CraftWorld) bukkitWorld;
|
||||
worldServer = craftWorld.getHandle();
|
||||
if (packet.a(worldServer) != null) {
|
||||
if (p.a(worldServer) != null) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
net.minecraft.server.v1_11_R1.Entity entity = packet.a(worldServer);
|
||||
Entity entity = p.a(worldServer);
|
||||
this.entity = entity.getBukkitEntity();
|
||||
|
||||
}
|
||||
|
||||
private void setupAction() {
|
||||
net.minecraft.server.v1_11_R1.PacketPlayInUseEntity packet = (net.minecraft.server.v1_11_R1.PacketPlayInUseEntity) getRawPacket();
|
||||
String name = packet.a().name();
|
||||
PacketPlayInUseEntity p = (PacketPlayInUseEntity) packet;
|
||||
String name = p.a().name();
|
||||
this.action = EntityUseAction.valueOf(name);
|
||||
}
|
||||
}
|
||||
+27
-24
@@ -1,31 +1,25 @@
|
||||
package me.purplex.packetevents.packetwrappers.in._1_12;
|
||||
|
||||
import me.purplex.packetevents.packetwrappers.api.WrappedVersionPacket;
|
||||
import net.minecraft.server.v1_12_R1.PacketPlayInAbilities;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
|
||||
public class WrappedPacketPlayInAbilities_1_12 {
|
||||
private final Object packet;
|
||||
public class WrappedPacketPlayInAbilities_1_12 extends WrappedVersionPacket {
|
||||
|
||||
public boolean a;
|
||||
public boolean b;
|
||||
public boolean c;
|
||||
public boolean d;
|
||||
public float e;
|
||||
public float f;
|
||||
|
||||
private Field fieldE;
|
||||
private Field fieldF;
|
||||
public WrappedPacketPlayInAbilities_1_12(Object packet) {
|
||||
this.packet = packet;
|
||||
try {
|
||||
this.fieldE = PacketPlayInAbilities.class.getDeclaredField("e");
|
||||
} catch (NoSuchFieldException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
try {
|
||||
this.fieldF = PacketPlayInAbilities.class.getDeclaredField("f");
|
||||
} catch (NoSuchFieldException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
setupFields();
|
||||
super(packet);
|
||||
}
|
||||
|
||||
|
||||
private void setupFields() {
|
||||
@Override
|
||||
protected void setup() {
|
||||
PacketPlayInAbilities p = (PacketPlayInAbilities) packet;
|
||||
this.a = p.a();
|
||||
this.b = p.isFlying();
|
||||
@@ -43,10 +37,19 @@ public class WrappedPacketPlayInAbilities_1_12 {
|
||||
}
|
||||
}
|
||||
|
||||
public boolean a;
|
||||
public boolean b;
|
||||
public boolean c;
|
||||
public boolean d;
|
||||
public float e;
|
||||
public float f;
|
||||
private static Field fieldE;
|
||||
private static Field fieldF;
|
||||
|
||||
static {
|
||||
try {
|
||||
fieldE = PacketPlayInAbilities.class.getDeclaredField("e");
|
||||
fieldE.setAccessible(true);
|
||||
fieldF = PacketPlayInAbilities.class.getDeclaredField("f");
|
||||
fieldF.setAccessible(true);
|
||||
} catch (NoSuchFieldException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
+12
-12
@@ -1,21 +1,21 @@
|
||||
package me.purplex.packetevents.packetwrappers.in._1_12;
|
||||
|
||||
import me.purplex.packetevents.enums.PlayerDigType;
|
||||
import me.purplex.packetevents.packetwrappers.api.WrappedVersionPacket;
|
||||
import net.minecraft.server.v1_12_R1.PacketPlayInBlockDig;
|
||||
|
||||
public class WrappedPacketPlayInBlockDig_1_12 {
|
||||
private final Object packet;
|
||||
public WrappedPacketPlayInBlockDig_1_12(Object packet) {
|
||||
this.packet = packet;
|
||||
setupDigType();
|
||||
}
|
||||
|
||||
private void setupDigType() {
|
||||
PacketPlayInBlockDig p = (PacketPlayInBlockDig)packet;
|
||||
String name = p.c().name();
|
||||
this.digType = PlayerDigType.valueOf(name);
|
||||
}
|
||||
public class WrappedPacketPlayInBlockDig_1_12 extends WrappedVersionPacket {
|
||||
|
||||
public PlayerDigType digType;
|
||||
|
||||
public WrappedPacketPlayInBlockDig_1_12(Object packet) {
|
||||
super(packet);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setup() {
|
||||
PacketPlayInBlockDig p = (PacketPlayInBlockDig) packet;
|
||||
String name = p.c().name();
|
||||
this.digType = PlayerDigType.valueOf(name);
|
||||
}
|
||||
}
|
||||
+32
-48
@@ -1,12 +1,11 @@
|
||||
package me.purplex.packetevents.packetwrappers.in._1_12;
|
||||
|
||||
import me.purplex.packetevents.packetwrappers.api.WrappedVersionPacket;
|
||||
import net.minecraft.server.v1_12_R1.PacketPlayInFlying;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
|
||||
public class WrappedPacketPlayInFlying_1_12 {
|
||||
private final Object packet;
|
||||
|
||||
public class WrappedPacketPlayInFlying_1_12 extends WrappedVersionPacket {
|
||||
public double x;
|
||||
public double y;
|
||||
public double z;
|
||||
@@ -15,38 +14,44 @@ public class WrappedPacketPlayInFlying_1_12 {
|
||||
public boolean f;
|
||||
public boolean hasPos;
|
||||
public boolean hasLook;
|
||||
|
||||
public WrappedPacketPlayInFlying_1_12(Object packet) {
|
||||
this.packet = packet;
|
||||
super(packet);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setup() {
|
||||
PacketPlayInFlying p = (PacketPlayInFlying) packet;
|
||||
try {
|
||||
setupFields();
|
||||
this.hasPos = fieldHasPos.getBoolean(p);
|
||||
this.hasLook = fieldHasLook.getBoolean(p);
|
||||
} catch (IllegalAccessException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
private void setupFields() throws IllegalAccessException {
|
||||
PacketPlayInFlying p = (PacketPlayInFlying) packet;
|
||||
this.hasPos = fieldHasPos.getBoolean(p);
|
||||
this.hasLook = fieldHasLook.getBoolean(p);
|
||||
if (hasPos) {
|
||||
this.x = p.a(0.0D);
|
||||
this.y = p.b(0.0D);
|
||||
this.z = p.c(0.0D);
|
||||
} else {
|
||||
this.x = fieldX.getDouble(p);
|
||||
this.y = fieldY.getDouble(p);
|
||||
this.z = fieldZ.getDouble(p);
|
||||
try {
|
||||
this.x = fieldX.getDouble(p);
|
||||
this.y = fieldY.getDouble(p);
|
||||
this.z = fieldZ.getDouble(p);
|
||||
} catch (IllegalAccessException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
if (hasLook) {
|
||||
this.yaw = p.a(0.0F);
|
||||
this.pitch = p.b(0.0F);
|
||||
}
|
||||
else {
|
||||
this.yaw = fieldYaw.getFloat(p);
|
||||
this.pitch = fieldPitch.getFloat(p);
|
||||
} else {
|
||||
try {
|
||||
this.yaw = fieldYaw.getFloat(p);
|
||||
this.pitch = fieldPitch.getFloat(p);
|
||||
} catch (IllegalAccessException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
this.f = p.a();
|
||||
}
|
||||
@@ -79,40 +84,19 @@ public class WrappedPacketPlayInFlying_1_12 {
|
||||
static {
|
||||
try {
|
||||
fieldHasPos = PacketPlayInFlying.class.getDeclaredField("hasPos");
|
||||
} catch (NoSuchFieldException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
try {
|
||||
fieldHasPos.setAccessible(true);
|
||||
fieldHasLook = PacketPlayInFlying.class.getDeclaredField("hasLook");
|
||||
} catch (NoSuchFieldException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
try {
|
||||
fieldHasLook.setAccessible(true);
|
||||
fieldX = PacketPlayInFlying.class.getDeclaredField("x");
|
||||
} catch (NoSuchFieldException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
try {
|
||||
fieldX.setAccessible(true);
|
||||
fieldY = PacketPlayInFlying.class.getDeclaredField("y");
|
||||
} catch (NoSuchFieldException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
try {
|
||||
fieldY.setAccessible(true);
|
||||
fieldZ = PacketPlayInFlying.class.getDeclaredField("z");
|
||||
} catch (NoSuchFieldException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
try {
|
||||
fieldZ.setAccessible(true);
|
||||
fieldYaw = PacketPlayInFlying.class.getDeclaredField("yaw");
|
||||
} catch (NoSuchFieldException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
try {
|
||||
fieldYaw.setAccessible(true);
|
||||
fieldPitch = PacketPlayInFlying.class.getDeclaredField("pitch");
|
||||
fieldPitch.setAccessible(true);
|
||||
} catch (NoSuchFieldException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
+16
-22
@@ -1,29 +1,22 @@
|
||||
package me.purplex.packetevents.packetwrappers.in._1_12;
|
||||
|
||||
import me.purplex.packetevents.enums.EntityUseAction;
|
||||
import me.purplex.packetevents.enums.ServerVersion;
|
||||
import me.purplex.packetevents.packetwrappers.api.WrappedVersionPacket;
|
||||
import net.minecraft.server.v1_12_R1.Entity;
|
||||
import net.minecraft.server.v1_12_R1.PacketPlayInUseEntity;
|
||||
import net.minecraft.server.v1_12_R1.WorldServer;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.entity.Entity;
|
||||
|
||||
public class WrappedPacketPlayInUseEntity_1_12 {
|
||||
private final ServerVersion version;
|
||||
private Entity entity;
|
||||
public class WrappedPacketPlayInUseEntity_1_12 extends WrappedVersionPacket {
|
||||
private org.bukkit.entity.Entity entity;
|
||||
private EntityUseAction action;
|
||||
private final Object packet;
|
||||
|
||||
public WrappedPacketPlayInUseEntity_1_12(Object packet) {
|
||||
this.version = ServerVersion.getVersion();
|
||||
this.packet = packet;
|
||||
setupEntity();
|
||||
setupAction();
|
||||
super(packet);
|
||||
}
|
||||
|
||||
private Object getRawPacket() {
|
||||
return this.packet;
|
||||
}
|
||||
|
||||
public Entity getEntity() {
|
||||
public org.bukkit.entity.Entity getEntity() {
|
||||
return entity;
|
||||
}
|
||||
|
||||
@@ -31,24 +24,25 @@ public class WrappedPacketPlayInUseEntity_1_12 {
|
||||
return action;
|
||||
}
|
||||
|
||||
private void setupEntity() {
|
||||
net.minecraft.server.v1_12_R1.PacketPlayInUseEntity packet = (net.minecraft.server.v1_12_R1.PacketPlayInUseEntity) getRawPacket();
|
||||
net.minecraft.server.v1_12_R1.WorldServer worldServer = null;
|
||||
@Override
|
||||
protected void setup() {
|
||||
PacketPlayInUseEntity p = (net.minecraft.server.v1_12_R1.PacketPlayInUseEntity) packet;
|
||||
WorldServer worldServer = null;
|
||||
for (World bukkitWorld : Bukkit.getWorlds()) {
|
||||
org.bukkit.craftbukkit.v1_12_R1.CraftWorld craftWorld = (org.bukkit.craftbukkit.v1_12_R1.CraftWorld) bukkitWorld;
|
||||
worldServer = craftWorld.getHandle();
|
||||
if (packet.a(worldServer) != null) {
|
||||
if (p.a(worldServer) != null) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
net.minecraft.server.v1_12_R1.Entity entity = packet.a(worldServer);
|
||||
Entity entity = p.a(worldServer);
|
||||
this.entity = entity.getBukkitEntity();
|
||||
|
||||
}
|
||||
|
||||
private void setupAction() {
|
||||
net.minecraft.server.v1_12_R1.PacketPlayInUseEntity packet = (net.minecraft.server.v1_12_R1.PacketPlayInUseEntity) getRawPacket();
|
||||
String name = packet.a().name();
|
||||
PacketPlayInUseEntity p = (PacketPlayInUseEntity) packet;
|
||||
String name = p.a().name();
|
||||
this.action = EntityUseAction.valueOf(name);
|
||||
}
|
||||
}
|
||||
+26
-24
@@ -1,31 +1,25 @@
|
||||
package me.purplex.packetevents.packetwrappers.in._1_13;
|
||||
|
||||
import me.purplex.packetevents.packetwrappers.api.WrappedVersionPacket;
|
||||
import net.minecraft.server.v1_13_R1.PacketPlayInAbilities;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
|
||||
public class WrappedPacketPlayInAbilities_1_13 {
|
||||
private final Object packet;
|
||||
public class WrappedPacketPlayInAbilities_1_13 extends WrappedVersionPacket {
|
||||
|
||||
public boolean a;
|
||||
public boolean b;
|
||||
public boolean c;
|
||||
public boolean d;
|
||||
public float e;
|
||||
public float f;
|
||||
|
||||
private Field fieldE;
|
||||
private Field fieldF;
|
||||
public WrappedPacketPlayInAbilities_1_13(Object packet) {
|
||||
this.packet = packet;
|
||||
try {
|
||||
this.fieldE = PacketPlayInAbilities.class.getDeclaredField("e");
|
||||
} catch (NoSuchFieldException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
try {
|
||||
this.fieldF = PacketPlayInAbilities.class.getDeclaredField("f");
|
||||
} catch (NoSuchFieldException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
setupFields();
|
||||
super(packet);
|
||||
}
|
||||
|
||||
|
||||
private void setupFields() {
|
||||
@Override
|
||||
protected void setup() {
|
||||
PacketPlayInAbilities p = (PacketPlayInAbilities) packet;
|
||||
this.a = p.b();
|
||||
this.b = p.isFlying();
|
||||
@@ -43,10 +37,18 @@ public class WrappedPacketPlayInAbilities_1_13 {
|
||||
}
|
||||
}
|
||||
|
||||
public boolean a;
|
||||
public boolean b;
|
||||
public boolean c;
|
||||
public boolean d;
|
||||
public float e;
|
||||
public float f;
|
||||
private static Field fieldE;
|
||||
private static Field fieldF;
|
||||
|
||||
static {
|
||||
try {
|
||||
fieldE = PacketPlayInAbilities.class.getDeclaredField("e");
|
||||
fieldE.setAccessible(true);
|
||||
fieldF = PacketPlayInAbilities.class.getDeclaredField("f");
|
||||
fieldF.setAccessible(true);
|
||||
} catch (NoSuchFieldException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
+9
-10
@@ -1,21 +1,20 @@
|
||||
package me.purplex.packetevents.packetwrappers.in._1_13;
|
||||
|
||||
import me.purplex.packetevents.enums.PlayerDigType;
|
||||
import me.purplex.packetevents.packetwrappers.api.WrappedVersionPacket;
|
||||
import net.minecraft.server.v1_13_R1.PacketPlayInBlockDig;
|
||||
|
||||
public class WrappedPacketPlayInBlockDig_1_13 {
|
||||
private final Object packet;
|
||||
public WrappedPacketPlayInBlockDig_1_13(Object packet) {
|
||||
this.packet = packet;
|
||||
setupDigType();
|
||||
}
|
||||
public class WrappedPacketPlayInBlockDig_1_13 extends WrappedVersionPacket {
|
||||
public PlayerDigType digType;
|
||||
|
||||
private void setupDigType() {
|
||||
PacketPlayInBlockDig p = (PacketPlayInBlockDig)packet;
|
||||
public WrappedPacketPlayInBlockDig_1_13(Object packet) {
|
||||
super(packet);
|
||||
}
|
||||
@Override
|
||||
protected void setup() {
|
||||
PacketPlayInBlockDig p = (PacketPlayInBlockDig) packet;
|
||||
String name = p.d().name();
|
||||
this.digType = PlayerDigType.valueOf(name);
|
||||
}
|
||||
|
||||
public PlayerDigType digType;
|
||||
|
||||
}
|
||||
+34
-49
@@ -1,12 +1,11 @@
|
||||
package me.purplex.packetevents.packetwrappers.in._1_13;
|
||||
|
||||
import me.purplex.packetevents.packetwrappers.api.WrappedVersionPacket;
|
||||
import net.minecraft.server.v1_13_R1.PacketPlayInFlying;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
|
||||
public class WrappedPacketPlayInFlying_1_13 {
|
||||
private final Object packet;
|
||||
|
||||
public class WrappedPacketPlayInFlying_1_13 extends WrappedVersionPacket {
|
||||
public double x;
|
||||
public double y;
|
||||
public double z;
|
||||
@@ -15,43 +14,49 @@ public class WrappedPacketPlayInFlying_1_13 {
|
||||
public boolean f;
|
||||
public boolean hasPos;
|
||||
public boolean hasLook;
|
||||
|
||||
public WrappedPacketPlayInFlying_1_13(Object packet) {
|
||||
this.packet = packet;
|
||||
super(packet);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setup() {
|
||||
PacketPlayInFlying p = (PacketPlayInFlying) packet;
|
||||
try {
|
||||
setupFields();
|
||||
this.hasPos = fieldHasPos.getBoolean(p);
|
||||
this.hasLook = fieldHasLook.getBoolean(p);
|
||||
} catch (IllegalAccessException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
private void setupFields() throws IllegalAccessException {
|
||||
PacketPlayInFlying p = (PacketPlayInFlying) packet;
|
||||
this.hasPos = fieldHasPos.getBoolean(p);
|
||||
this.hasLook = fieldHasLook.getBoolean(p);
|
||||
if (hasPos) {
|
||||
this.x = p.a(0.0D);
|
||||
this.y = p.b(0.0D);
|
||||
this.z = p.c(0.0D);
|
||||
} else {
|
||||
this.x = fieldX.getDouble(p);
|
||||
this.y = fieldY.getDouble(p);
|
||||
this.z = fieldZ.getDouble(p);
|
||||
try {
|
||||
this.x = fieldX.getDouble(p);
|
||||
this.y = fieldY.getDouble(p);
|
||||
this.z = fieldZ.getDouble(p);
|
||||
} catch (IllegalAccessException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
if (hasLook) {
|
||||
this.yaw = p.a(0.0F);
|
||||
this.pitch = p.b(0.0F);
|
||||
}
|
||||
else {
|
||||
this.yaw = fieldYaw.getFloat(p);
|
||||
this.pitch = fieldPitch.getFloat(p);
|
||||
} else {
|
||||
try {
|
||||
this.yaw = fieldYaw.getFloat(p);
|
||||
this.pitch = fieldPitch.getFloat(p);
|
||||
} catch (IllegalAccessException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
this.f = p.a();
|
||||
}
|
||||
|
||||
public static class WrappedPacketPlayInPosition_1_13 extends WrappedPacketPlayInFlying_1_13{
|
||||
public static class WrappedPacketPlayInPosition_1_13 extends WrappedPacketPlayInFlying_1_13 {
|
||||
|
||||
public WrappedPacketPlayInPosition_1_13(Object packet) {
|
||||
super(packet);
|
||||
@@ -79,40 +84,20 @@ public class WrappedPacketPlayInFlying_1_13 {
|
||||
static {
|
||||
try {
|
||||
fieldHasPos = PacketPlayInFlying.class.getDeclaredField("hasPos");
|
||||
} catch (NoSuchFieldException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
try {
|
||||
fieldHasPos.setAccessible(true);
|
||||
fieldHasLook = PacketPlayInFlying.class.getDeclaredField("hasLook");
|
||||
} catch (NoSuchFieldException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
try {
|
||||
fieldHasLook.setAccessible(true);
|
||||
fieldX = PacketPlayInFlying.class.getDeclaredField("x");
|
||||
} catch (NoSuchFieldException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
try {
|
||||
fieldX.setAccessible(true);
|
||||
fieldY = PacketPlayInFlying.class.getDeclaredField("y");
|
||||
} catch (NoSuchFieldException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
try {
|
||||
fieldY.setAccessible(true);
|
||||
fieldZ = PacketPlayInFlying.class.getDeclaredField("z");
|
||||
} catch (NoSuchFieldException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
try {
|
||||
fieldZ.setAccessible(true);
|
||||
fieldYaw = PacketPlayInFlying.class.getDeclaredField("yaw");
|
||||
} catch (NoSuchFieldException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
try {
|
||||
fieldYaw.setAccessible(true);
|
||||
fieldPitch = PacketPlayInFlying.class.getDeclaredField("pitch");
|
||||
fieldPitch.setAccessible(true);
|
||||
|
||||
} catch (NoSuchFieldException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
+17
-21
@@ -1,32 +1,22 @@
|
||||
package me.purplex.packetevents.packetwrappers.in._1_13;
|
||||
|
||||
import me.purplex.packetevents.enums.EntityUseAction;
|
||||
import me.purplex.packetevents.enums.ServerVersion;
|
||||
import me.purplex.packetevents.packetwrappers.api.WrappedVersionPacket;
|
||||
import net.minecraft.server.v1_13_R1.Entity;
|
||||
import net.minecraft.server.v1_13_R1.PacketPlayInUseEntity;
|
||||
import net.minecraft.server.v1_13_R1.WorldServer;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.craftbukkit.v1_13_R1.CraftWorld;
|
||||
import org.bukkit.entity.Entity;
|
||||
|
||||
public class WrappedPacketPlayInUseEntity_1_13 {
|
||||
private final ServerVersion version;
|
||||
private Entity entity;
|
||||
public class WrappedPacketPlayInUseEntity_1_13 extends WrappedVersionPacket {
|
||||
private org.bukkit.entity.Entity entity;
|
||||
private EntityUseAction action;
|
||||
private final Object packet;
|
||||
|
||||
public WrappedPacketPlayInUseEntity_1_13(Object packet) {
|
||||
this.version = ServerVersion.getVersion();
|
||||
this.packet = packet;
|
||||
setupEntity();
|
||||
setupAction();
|
||||
super(packet);
|
||||
}
|
||||
|
||||
private Object getRawPacket() {
|
||||
return this.packet;
|
||||
}
|
||||
|
||||
public Entity getEntity() {
|
||||
public org.bukkit.entity.Entity getEntity() {
|
||||
return entity;
|
||||
}
|
||||
|
||||
@@ -34,24 +24,30 @@ public class WrappedPacketPlayInUseEntity_1_13 {
|
||||
return action;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setup() {
|
||||
setupEntity();
|
||||
setupAction();
|
||||
}
|
||||
|
||||
private void setupEntity() {
|
||||
PacketPlayInUseEntity packet = (PacketPlayInUseEntity) getRawPacket();
|
||||
PacketPlayInUseEntity p = (PacketPlayInUseEntity) packet;
|
||||
WorldServer worldServer = null;
|
||||
for (World bukkitWorld : Bukkit.getWorlds()) {
|
||||
CraftWorld craftWorld = (CraftWorld) bukkitWorld;
|
||||
worldServer = craftWorld.getHandle();
|
||||
if (packet.a(worldServer) != null) {
|
||||
if (p.a(worldServer) != null) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
net.minecraft.server.v1_13_R1.Entity entity = packet.a(worldServer);
|
||||
Entity entity = p.a(worldServer);
|
||||
this.entity = entity.getBukkitEntity();
|
||||
|
||||
}
|
||||
|
||||
private void setupAction() {
|
||||
PacketPlayInUseEntity packet = (PacketPlayInUseEntity) getRawPacket();
|
||||
String name = packet.b().name();
|
||||
PacketPlayInUseEntity p = (PacketPlayInUseEntity) packet;
|
||||
String name = p.b().name();
|
||||
this.action = EntityUseAction.valueOf(name);
|
||||
}
|
||||
}
|
||||
+39
-38
@@ -1,47 +1,11 @@
|
||||
package me.purplex.packetevents.packetwrappers.in._1_13_2;
|
||||
|
||||
import me.purplex.packetevents.packetwrappers.api.WrappedVersionPacket;
|
||||
import net.minecraft.server.v1_13_R2.PacketPlayInAbilities;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
|
||||
public class WrappedPacketPlayInAbilities_1_13_2 {
|
||||
private final Object packet;
|
||||
|
||||
private Field fieldE;
|
||||
private Field fieldF;
|
||||
public WrappedPacketPlayInAbilities_1_13_2(Object packet) {
|
||||
this.packet = packet;
|
||||
try {
|
||||
this.fieldE = PacketPlayInAbilities.class.getDeclaredField("e");
|
||||
} catch (NoSuchFieldException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
try {
|
||||
this.fieldF = PacketPlayInAbilities.class.getDeclaredField("f");
|
||||
} catch (NoSuchFieldException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
setupFields();
|
||||
}
|
||||
|
||||
|
||||
private void setupFields() {
|
||||
PacketPlayInAbilities p = (PacketPlayInAbilities) packet;
|
||||
this.a = p.b();
|
||||
this.b = p.isFlying();
|
||||
this.c = p.d();
|
||||
this.d = p.e();
|
||||
try {
|
||||
this.e = fieldE.getFloat(p);
|
||||
} catch (IllegalAccessException illegalAccessException) {
|
||||
illegalAccessException.printStackTrace();
|
||||
}
|
||||
try {
|
||||
this.f = fieldF.getFloat(p);
|
||||
} catch (IllegalAccessException illegalAccessException) {
|
||||
illegalAccessException.printStackTrace();
|
||||
}
|
||||
}
|
||||
public class WrappedPacketPlayInAbilities_1_13_2 extends WrappedVersionPacket {
|
||||
|
||||
public boolean a;
|
||||
public boolean b;
|
||||
@@ -49,4 +13,41 @@ public class WrappedPacketPlayInAbilities_1_13_2 {
|
||||
public boolean d;
|
||||
public float e;
|
||||
public float f;
|
||||
|
||||
public WrappedPacketPlayInAbilities_1_13_2(Object packet) {
|
||||
super(packet);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setup() {
|
||||
PacketPlayInAbilities p = (PacketPlayInAbilities) packet;
|
||||
this.a = p.b();
|
||||
this.b = p.isFlying();
|
||||
this.c = p.d();
|
||||
this.d = p.e();
|
||||
try {
|
||||
this.e = fieldE.getFloat(p);
|
||||
} catch (IllegalAccessException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
try {
|
||||
this.f = fieldF.getFloat(p);
|
||||
} catch (IllegalAccessException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
private static Field fieldE;
|
||||
private static Field fieldF;
|
||||
|
||||
static {
|
||||
try {
|
||||
fieldE = PacketPlayInAbilities.class.getDeclaredField("e");
|
||||
fieldE.setAccessible(true);
|
||||
fieldF = PacketPlayInAbilities.class.getDeclaredField("f");
|
||||
fieldF.setAccessible(true);
|
||||
} catch (NoSuchFieldException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
+8
-8
@@ -1,21 +1,21 @@
|
||||
package me.purplex.packetevents.packetwrappers.in._1_13_2;
|
||||
|
||||
import me.purplex.packetevents.enums.PlayerDigType;
|
||||
import me.purplex.packetevents.packetwrappers.api.WrappedVersionPacket;
|
||||
import net.minecraft.server.v1_13_R2.PacketPlayInBlockDig;
|
||||
|
||||
public class WrappedPacketPlayInBlockDig_1_13_2 {
|
||||
private final Object packet;
|
||||
public class WrappedPacketPlayInBlockDig_1_13_2 extends WrappedVersionPacket {
|
||||
public PlayerDigType digType;
|
||||
|
||||
public WrappedPacketPlayInBlockDig_1_13_2(Object packet) {
|
||||
this.packet = packet;
|
||||
setupDigType();
|
||||
super(packet);
|
||||
}
|
||||
|
||||
private void setupDigType() {
|
||||
PacketPlayInBlockDig p = (PacketPlayInBlockDig)packet;
|
||||
@Override
|
||||
protected void setup() {
|
||||
PacketPlayInBlockDig p = (PacketPlayInBlockDig) packet;
|
||||
String name = p.d().name();
|
||||
this.digType = PlayerDigType.valueOf(name);
|
||||
}
|
||||
|
||||
public PlayerDigType digType;
|
||||
|
||||
}
|
||||
+34
-50
@@ -1,12 +1,11 @@
|
||||
package me.purplex.packetevents.packetwrappers.in._1_13_2;
|
||||
|
||||
import me.purplex.packetevents.packetwrappers.api.WrappedVersionPacket;
|
||||
import net.minecraft.server.v1_13_R2.PacketPlayInFlying;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
|
||||
public class WrappedPacketPlayInFlying_1_13_2 {
|
||||
private final Object packet;
|
||||
|
||||
public class WrappedPacketPlayInFlying_1_13_2 extends WrappedVersionPacket {
|
||||
public double x;
|
||||
public double y;
|
||||
public double z;
|
||||
@@ -15,38 +14,44 @@ public class WrappedPacketPlayInFlying_1_13_2 {
|
||||
public boolean f;
|
||||
public boolean hasPos;
|
||||
public boolean hasLook;
|
||||
|
||||
public WrappedPacketPlayInFlying_1_13_2(Object packet) {
|
||||
this.packet = packet;
|
||||
super(packet);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setup() {
|
||||
PacketPlayInFlying p = (PacketPlayInFlying) packet;
|
||||
try {
|
||||
setupFields();
|
||||
this.hasPos = fieldHasPos.getBoolean(p);
|
||||
this.hasLook = fieldHasLook.getBoolean(p);
|
||||
} catch (IllegalAccessException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
private void setupFields() throws IllegalAccessException {
|
||||
PacketPlayInFlying p = (PacketPlayInFlying) packet;
|
||||
this.hasPos = fieldHasPos.getBoolean(p);
|
||||
this.hasLook = fieldHasLook.getBoolean(p);
|
||||
if (hasPos) {
|
||||
this.x = p.a(0.0D);
|
||||
this.y = p.b(0.0D);
|
||||
this.z = p.c(0.0D);
|
||||
} else {
|
||||
this.x = fieldX.getDouble(p);
|
||||
this.y = fieldY.getDouble(p);
|
||||
this.z = fieldZ.getDouble(p);
|
||||
try {
|
||||
this.x = fieldX.getDouble(p);
|
||||
this.y = fieldY.getDouble(p);
|
||||
this.z = fieldZ.getDouble(p);
|
||||
} catch (IllegalAccessException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
if (hasLook) {
|
||||
this.yaw = p.a(0.0F);
|
||||
this.pitch = p.b(0.0F);
|
||||
}
|
||||
else {
|
||||
this.yaw = fieldYaw.getFloat(p);
|
||||
this.pitch = fieldPitch.getFloat(p);
|
||||
} else {
|
||||
try {
|
||||
this.yaw = fieldYaw.getFloat(p);
|
||||
this.pitch = fieldPitch.getFloat(p);
|
||||
} catch (IllegalAccessException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
this.f = p.a();
|
||||
}
|
||||
@@ -78,40 +83,19 @@ public class WrappedPacketPlayInFlying_1_13_2 {
|
||||
static {
|
||||
try {
|
||||
fieldHasPos = PacketPlayInFlying.class.getDeclaredField("hasPos");
|
||||
} catch (NoSuchFieldException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
try {
|
||||
fieldHasPos.setAccessible(true);
|
||||
fieldHasLook = PacketPlayInFlying.class.getDeclaredField("hasLook");
|
||||
} catch (NoSuchFieldException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
try {
|
||||
fieldX = PacketPlayInFlying.class.getDeclaredField("x");
|
||||
} catch (NoSuchFieldException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
try {
|
||||
fieldHasLook.setAccessible(true);
|
||||
fieldY = PacketPlayInFlying.class.getDeclaredField("y");
|
||||
} catch (NoSuchFieldException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
try {
|
||||
fieldY.setAccessible(true);
|
||||
fieldX = PacketPlayInFlying.class.getDeclaredField("x");
|
||||
fieldX.setAccessible(true);
|
||||
fieldZ = PacketPlayInFlying.class.getDeclaredField("z");
|
||||
} catch (NoSuchFieldException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
try {
|
||||
fieldYaw = PacketPlayInFlying.class.getDeclaredField("yaw");
|
||||
} catch (NoSuchFieldException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
try {
|
||||
fieldZ.setAccessible(true);
|
||||
fieldPitch = PacketPlayInFlying.class.getDeclaredField("pitch");
|
||||
fieldPitch.setAccessible(true);
|
||||
fieldYaw = PacketPlayInFlying.class.getDeclaredField("yaw");
|
||||
fieldYaw.setAccessible(true);
|
||||
} catch (NoSuchFieldException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
+18
-20
@@ -1,31 +1,23 @@
|
||||
package me.purplex.packetevents.packetwrappers.in._1_13_2;
|
||||
|
||||
import me.purplex.packetevents.enums.EntityUseAction;
|
||||
import me.purplex.packetevents.enums.ServerVersion;
|
||||
import me.purplex.packetevents.packetwrappers.api.WrappedVersionPacket;
|
||||
import net.minecraft.server.v1_13_R2.Entity;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.craftbukkit.v1_13_R2.CraftWorld;
|
||||
import org.bukkit.entity.Entity;
|
||||
import net.minecraft.server.v1_13_R2.PacketPlayInUseEntity;
|
||||
import net.minecraft.server.v1_13_R2.WorldServer;
|
||||
public class WrappedPacketPlayInUseEntity_1_13_2 {
|
||||
private final ServerVersion version;
|
||||
private Entity entity;
|
||||
public class WrappedPacketPlayInUseEntity_1_13_2 extends WrappedVersionPacket {
|
||||
|
||||
private org.bukkit.entity.Entity entity;
|
||||
private EntityUseAction action;
|
||||
private final Object packet;
|
||||
|
||||
public WrappedPacketPlayInUseEntity_1_13_2(Object packet) {
|
||||
this.version = ServerVersion.getVersion();
|
||||
this.packet = packet;
|
||||
setupEntity();
|
||||
setupAction();
|
||||
super(packet);
|
||||
}
|
||||
|
||||
private Object getRawPacket() {
|
||||
return this.packet;
|
||||
}
|
||||
|
||||
public Entity getEntity() {
|
||||
public org.bukkit.entity.Entity getEntity() {
|
||||
return entity;
|
||||
}
|
||||
|
||||
@@ -33,24 +25,30 @@ public class WrappedPacketPlayInUseEntity_1_13_2 {
|
||||
return action;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setup() {
|
||||
setupEntity();
|
||||
setupAction();
|
||||
}
|
||||
|
||||
private void setupEntity() {
|
||||
PacketPlayInUseEntity packet = (net.minecraft.server.v1_13_R2.PacketPlayInUseEntity) getRawPacket();
|
||||
PacketPlayInUseEntity p = (PacketPlayInUseEntity) packet;
|
||||
WorldServer worldServer = null;
|
||||
for (World bukkitWorld : Bukkit.getWorlds()) {
|
||||
CraftWorld craftWorld = (CraftWorld) bukkitWorld;
|
||||
worldServer = craftWorld.getHandle();
|
||||
if (packet.a(worldServer) != null) {
|
||||
if (p.a(worldServer) != null) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
net.minecraft.server.v1_13_R2.Entity entity = packet.a(worldServer);
|
||||
Entity entity = p.a(worldServer);
|
||||
this.entity = entity.getBukkitEntity();
|
||||
|
||||
}
|
||||
|
||||
private void setupAction() {
|
||||
PacketPlayInUseEntity packet = (PacketPlayInUseEntity) getRawPacket();
|
||||
String name = packet.b().name();
|
||||
PacketPlayInUseEntity p = (PacketPlayInUseEntity) packet;
|
||||
String name = p.b().name();
|
||||
this.action = EntityUseAction.valueOf(name);
|
||||
}
|
||||
}
|
||||
+25
-24
@@ -1,31 +1,25 @@
|
||||
package me.purplex.packetevents.packetwrappers.in._1_14;
|
||||
|
||||
import me.purplex.packetevents.packetwrappers.api.WrappedVersionPacket;
|
||||
import net.minecraft.server.v1_14_R1.PacketPlayInAbilities;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
|
||||
public class WrappedPacketPlayInAbilities_1_14 {
|
||||
private final Object packet;
|
||||
public class WrappedPacketPlayInAbilities_1_14 extends WrappedVersionPacket {
|
||||
|
||||
public boolean a;
|
||||
public boolean b;
|
||||
public boolean c;
|
||||
public boolean d;
|
||||
public float e;
|
||||
public float f;
|
||||
|
||||
private Field fieldE;
|
||||
private Field fieldF;
|
||||
public WrappedPacketPlayInAbilities_1_14(Object packet) {
|
||||
this.packet = packet;
|
||||
try {
|
||||
this.fieldE = PacketPlayInAbilities.class.getDeclaredField("e");
|
||||
} catch (NoSuchFieldException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
try {
|
||||
this.fieldF = PacketPlayInAbilities.class.getDeclaredField("f");
|
||||
} catch (NoSuchFieldException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
setupFields();
|
||||
super(packet);
|
||||
}
|
||||
|
||||
|
||||
private void setupFields() {
|
||||
@Override
|
||||
protected void setup() {
|
||||
PacketPlayInAbilities p = (PacketPlayInAbilities) packet;
|
||||
this.a = p.b();
|
||||
this.b = p.isFlying();
|
||||
@@ -43,10 +37,17 @@ public class WrappedPacketPlayInAbilities_1_14 {
|
||||
}
|
||||
}
|
||||
|
||||
public boolean a;
|
||||
public boolean b;
|
||||
public boolean c;
|
||||
public boolean d;
|
||||
public float e;
|
||||
public float f;
|
||||
private static Field fieldE;
|
||||
private static Field fieldF;
|
||||
|
||||
static {
|
||||
try {
|
||||
fieldE = PacketPlayInAbilities.class.getDeclaredField("e");
|
||||
fieldE.setAccessible(true);
|
||||
fieldF = PacketPlayInAbilities.class.getDeclaredField("f");
|
||||
fieldF.setAccessible(true);
|
||||
} catch (NoSuchFieldException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
+8
-9
@@ -1,21 +1,20 @@
|
||||
package me.purplex.packetevents.packetwrappers.in._1_14;
|
||||
|
||||
import me.purplex.packetevents.enums.PlayerDigType;
|
||||
import me.purplex.packetevents.packetwrappers.api.WrappedVersionPacket;
|
||||
import net.minecraft.server.v1_14_R1.PacketPlayInBlockDig;
|
||||
|
||||
public class WrappedPacketPlayInBlockDig_1_14 {
|
||||
private final Object packet;
|
||||
public class WrappedPacketPlayInBlockDig_1_14 extends WrappedVersionPacket {
|
||||
public PlayerDigType digType;
|
||||
|
||||
public WrappedPacketPlayInBlockDig_1_14(Object packet) {
|
||||
this.packet = packet;
|
||||
setupDigType();
|
||||
super(packet);
|
||||
}
|
||||
|
||||
private void setupDigType() {
|
||||
PacketPlayInBlockDig p = (PacketPlayInBlockDig)packet;
|
||||
@Override
|
||||
protected void setup() {
|
||||
PacketPlayInBlockDig p = (PacketPlayInBlockDig) packet;
|
||||
String name = p.d().name();
|
||||
this.digType = PlayerDigType.valueOf(name);
|
||||
}
|
||||
|
||||
public PlayerDigType digType;
|
||||
|
||||
}
|
||||
+32
-48
@@ -1,12 +1,11 @@
|
||||
package me.purplex.packetevents.packetwrappers.in._1_14;
|
||||
|
||||
import me.purplex.packetevents.packetwrappers.api.WrappedVersionPacket;
|
||||
import net.minecraft.server.v1_14_R1.PacketPlayInFlying;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
|
||||
public class WrappedPacketPlayInFlying_1_14 {
|
||||
private final Object packet;
|
||||
|
||||
public class WrappedPacketPlayInFlying_1_14 extends WrappedVersionPacket {
|
||||
public double x;
|
||||
public double y;
|
||||
public double z;
|
||||
@@ -15,38 +14,44 @@ public class WrappedPacketPlayInFlying_1_14 {
|
||||
public boolean f;
|
||||
public boolean hasPos;
|
||||
public boolean hasLook;
|
||||
|
||||
public WrappedPacketPlayInFlying_1_14(Object packet) {
|
||||
this.packet = packet;
|
||||
super(packet);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setup() {
|
||||
PacketPlayInFlying p = (PacketPlayInFlying) packet;
|
||||
try {
|
||||
setupFields();
|
||||
this.hasPos = fieldHasPos.getBoolean(p);
|
||||
this.hasLook = fieldHasLook.getBoolean(p);
|
||||
} catch (IllegalAccessException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
private void setupFields() throws IllegalAccessException {
|
||||
PacketPlayInFlying p = (PacketPlayInFlying) packet;
|
||||
this.hasPos = fieldHasPos.getBoolean(p);
|
||||
this.hasLook = fieldHasLook.getBoolean(p);
|
||||
if (hasPos) {
|
||||
this.x = p.a(0.0D);
|
||||
this.y = p.b(0.0D);
|
||||
this.z = p.c(0.0D);
|
||||
} else {
|
||||
this.x = fieldX.getDouble(p);
|
||||
this.y = fieldY.getDouble(p);
|
||||
this.z = fieldZ.getDouble(p);
|
||||
try {
|
||||
this.x = fieldX.getDouble(p);
|
||||
this.y = fieldY.getDouble(p);
|
||||
this.z = fieldZ.getDouble(p);
|
||||
} catch (IllegalAccessException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
if (hasLook) {
|
||||
this.yaw = p.a(0.0F);
|
||||
this.pitch = p.b(0.0F);
|
||||
}
|
||||
else {
|
||||
this.yaw = fieldYaw.getFloat(p);
|
||||
this.pitch = fieldPitch.getFloat(p);
|
||||
} else {
|
||||
try {
|
||||
this.yaw = fieldYaw.getFloat(p);
|
||||
this.pitch = fieldPitch.getFloat(p);
|
||||
} catch (IllegalAccessException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
this.f = p.a();
|
||||
}
|
||||
@@ -79,40 +84,19 @@ public class WrappedPacketPlayInFlying_1_14 {
|
||||
static {
|
||||
try {
|
||||
fieldHasPos = PacketPlayInFlying.class.getDeclaredField("hasPos");
|
||||
} catch (NoSuchFieldException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
try {
|
||||
fieldHasPos.setAccessible(true);
|
||||
fieldHasLook = PacketPlayInFlying.class.getDeclaredField("hasLook");
|
||||
} catch (NoSuchFieldException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
try {
|
||||
fieldHasLook.setAccessible(true);
|
||||
fieldX = PacketPlayInFlying.class.getDeclaredField("x");
|
||||
} catch (NoSuchFieldException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
try {
|
||||
fieldX.setAccessible(true);
|
||||
fieldY = PacketPlayInFlying.class.getDeclaredField("y");
|
||||
} catch (NoSuchFieldException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
try {
|
||||
fieldY.setAccessible(true);
|
||||
fieldZ = PacketPlayInFlying.class.getDeclaredField("z");
|
||||
} catch (NoSuchFieldException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
try {
|
||||
fieldZ.setAccessible(true);
|
||||
fieldYaw = PacketPlayInFlying.class.getDeclaredField("yaw");
|
||||
} catch (NoSuchFieldException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
try {
|
||||
fieldYaw.setAccessible(true);
|
||||
fieldPitch = PacketPlayInFlying.class.getDeclaredField("pitch");
|
||||
fieldPitch.setAccessible(true);
|
||||
} catch (NoSuchFieldException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
+19
-21
@@ -1,31 +1,23 @@
|
||||
package me.purplex.packetevents.packetwrappers.in._1_14;
|
||||
|
||||
import me.purplex.packetevents.enums.EntityUseAction;
|
||||
import me.purplex.packetevents.enums.ServerVersion;
|
||||
import me.purplex.packetevents.packetwrappers.api.WrappedVersionPacket;
|
||||
import net.minecraft.server.v1_14_R1.Entity;
|
||||
import net.minecraft.server.v1_14_R1.PacketPlayInUseEntity;
|
||||
import net.minecraft.server.v1_14_R1.WorldServer;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.craftbukkit.v1_14_R1.CraftWorld;
|
||||
|
||||
public class WrappedPacketPlayInUseEntity_1_14 {
|
||||
private final ServerVersion version;
|
||||
private Entity entity;
|
||||
public class WrappedPacketPlayInUseEntity_1_14 extends WrappedVersionPacket {
|
||||
private org.bukkit.entity.Entity entity;
|
||||
private EntityUseAction action;
|
||||
private final Object packet;
|
||||
|
||||
public WrappedPacketPlayInUseEntity_1_14(Object packet) {
|
||||
this.version = ServerVersion.getVersion();
|
||||
this.packet = packet;
|
||||
setupEntity();
|
||||
setupAction();
|
||||
super(packet);
|
||||
}
|
||||
|
||||
private Object getRawPacket() {
|
||||
return this.packet;
|
||||
}
|
||||
|
||||
public Entity getEntity() {
|
||||
public org.bukkit.entity.Entity getEntity() {
|
||||
return entity;
|
||||
}
|
||||
|
||||
@@ -33,24 +25,30 @@ public class WrappedPacketPlayInUseEntity_1_14 {
|
||||
return action;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setup() {
|
||||
setupEntity();
|
||||
setupAction();
|
||||
}
|
||||
|
||||
private void setupEntity() {
|
||||
PacketPlayInUseEntity packet = (PacketPlayInUseEntity) getRawPacket();
|
||||
PacketPlayInUseEntity p = (PacketPlayInUseEntity) packet;
|
||||
WorldServer worldServer = null;
|
||||
for (World bukkitWorld : Bukkit.getWorlds()) {
|
||||
org.bukkit.craftbukkit.v1_14_R1.CraftWorld craftWorld = (org.bukkit.craftbukkit.v1_14_R1.CraftWorld) bukkitWorld;
|
||||
CraftWorld craftWorld = (CraftWorld) bukkitWorld;
|
||||
worldServer = craftWorld.getHandle();
|
||||
if (packet.a(worldServer) != null) {
|
||||
if (p.a(worldServer) != null) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
net.minecraft.server.v1_14_R1.Entity entity = packet.a(worldServer);
|
||||
Entity entity = p.a(worldServer);
|
||||
this.entity = entity.getBukkitEntity();
|
||||
|
||||
}
|
||||
|
||||
private void setupAction() {
|
||||
PacketPlayInUseEntity packet = (PacketPlayInUseEntity) getRawPacket();
|
||||
String name = packet.b().name();
|
||||
PacketPlayInUseEntity p = (PacketPlayInUseEntity) packet;
|
||||
String name = p.b().name();
|
||||
this.action = EntityUseAction.valueOf(name);
|
||||
}
|
||||
}
|
||||
+40
-38
@@ -1,47 +1,11 @@
|
||||
package me.purplex.packetevents.packetwrappers.in._1_15;
|
||||
|
||||
import me.purplex.packetevents.packetwrappers.api.WrappedVersionPacket;
|
||||
import net.minecraft.server.v1_15_R1.PacketPlayInAbilities;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
|
||||
public class WrappedPacketPlayInAbilities_1_15 {
|
||||
private final Object packet;
|
||||
|
||||
private Field fieldE;
|
||||
private Field fieldF;
|
||||
public WrappedPacketPlayInAbilities_1_15(Object packet) {
|
||||
this.packet = packet;
|
||||
try {
|
||||
this.fieldE = PacketPlayInAbilities.class.getDeclaredField("e");
|
||||
} catch (NoSuchFieldException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
try {
|
||||
this.fieldF = PacketPlayInAbilities.class.getDeclaredField("f");
|
||||
} catch (NoSuchFieldException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
setupFields();
|
||||
}
|
||||
|
||||
|
||||
private void setupFields() {
|
||||
PacketPlayInAbilities p = (PacketPlayInAbilities) packet;
|
||||
this.a = p.b();
|
||||
this.b = p.isFlying();
|
||||
this.c = p.d();
|
||||
this.d = p.e();
|
||||
try {
|
||||
this.e = fieldE.getFloat(p);
|
||||
} catch (IllegalAccessException illegalAccessException) {
|
||||
illegalAccessException.printStackTrace();
|
||||
}
|
||||
try {
|
||||
this.f = fieldF.getFloat(p);
|
||||
} catch (IllegalAccessException illegalAccessException) {
|
||||
illegalAccessException.printStackTrace();
|
||||
}
|
||||
}
|
||||
public class WrappedPacketPlayInAbilities_1_15 extends WrappedVersionPacket {
|
||||
|
||||
public boolean a;
|
||||
public boolean b;
|
||||
@@ -49,4 +13,42 @@ public class WrappedPacketPlayInAbilities_1_15 {
|
||||
public boolean d;
|
||||
public float e;
|
||||
public float f;
|
||||
|
||||
public WrappedPacketPlayInAbilities_1_15(Object packet) {
|
||||
super(packet);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setup() {
|
||||
PacketPlayInAbilities p = (PacketPlayInAbilities) packet;
|
||||
this.a = p.b();
|
||||
this.b = p.isFlying();
|
||||
this.c = p.d();
|
||||
this.d = p.e();
|
||||
try {
|
||||
this.e = fieldE.getFloat(p);
|
||||
} catch (IllegalAccessException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
try {
|
||||
this.f = fieldF.getFloat(p);
|
||||
} catch (IllegalAccessException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private static Field fieldE;
|
||||
private static Field fieldF;
|
||||
|
||||
static {
|
||||
try {
|
||||
fieldE = PacketPlayInAbilities.class.getDeclaredField("e");
|
||||
fieldE.setAccessible(true);
|
||||
fieldF = PacketPlayInAbilities.class.getDeclaredField("f");
|
||||
fieldF.setAccessible(true);
|
||||
} catch (NoSuchFieldException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
+8
-9
@@ -1,21 +1,20 @@
|
||||
package me.purplex.packetevents.packetwrappers.in._1_15;
|
||||
|
||||
import me.purplex.packetevents.enums.PlayerDigType;
|
||||
import me.purplex.packetevents.packetwrappers.api.WrappedVersionPacket;
|
||||
import net.minecraft.server.v1_15_R1.PacketPlayInBlockDig;
|
||||
|
||||
public class WrappedPacketPlayInBlockDig_1_15 {
|
||||
private final Object packet;
|
||||
public class WrappedPacketPlayInBlockDig_1_15 extends WrappedVersionPacket {
|
||||
public PlayerDigType digType;
|
||||
|
||||
public WrappedPacketPlayInBlockDig_1_15(Object packet) {
|
||||
this.packet = packet;
|
||||
setupDigType();
|
||||
super(packet);
|
||||
}
|
||||
|
||||
private void setupDigType() {
|
||||
PacketPlayInBlockDig p = (PacketPlayInBlockDig)packet;
|
||||
@Override
|
||||
protected void setup() {
|
||||
PacketPlayInBlockDig p = (PacketPlayInBlockDig) packet;
|
||||
String name = p.d().name();
|
||||
this.digType = PlayerDigType.valueOf(name);
|
||||
}
|
||||
|
||||
public PlayerDigType digType;
|
||||
|
||||
}
|
||||
+33
-48
@@ -1,12 +1,11 @@
|
||||
package me.purplex.packetevents.packetwrappers.in._1_15;
|
||||
|
||||
import me.purplex.packetevents.packetwrappers.api.WrappedVersionPacket;
|
||||
import net.minecraft.server.v1_15_R1.PacketPlayInFlying;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
|
||||
public class WrappedPacketPlayInFlying_1_15 {
|
||||
private final Object packet;
|
||||
|
||||
public class WrappedPacketPlayInFlying_1_15 extends WrappedVersionPacket {
|
||||
public double x;
|
||||
public double y;
|
||||
public double z;
|
||||
@@ -15,38 +14,45 @@ public class WrappedPacketPlayInFlying_1_15 {
|
||||
public boolean f;
|
||||
public boolean hasPos;
|
||||
public boolean hasLook;
|
||||
|
||||
public WrappedPacketPlayInFlying_1_15(Object packet) {
|
||||
this.packet = packet;
|
||||
try {
|
||||
setupFields();
|
||||
} catch (IllegalAccessException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
super(packet);
|
||||
}
|
||||
|
||||
|
||||
|
||||
private void setupFields() throws IllegalAccessException {
|
||||
@Override
|
||||
protected void setup() {
|
||||
PacketPlayInFlying p = (PacketPlayInFlying) packet;
|
||||
this.hasPos = fieldHasPos.getBoolean(p);
|
||||
this.hasLook = fieldHasLook.getBoolean(p);
|
||||
try {
|
||||
this.hasPos = fieldHasPos.getBoolean(p);
|
||||
this.hasLook = fieldHasLook.getBoolean(p);
|
||||
} catch (IllegalAccessException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
if (hasPos) {
|
||||
this.x = p.a(0.0D);
|
||||
this.y = p.b(0.0D);
|
||||
this.z = p.c(0.0D);
|
||||
} else {
|
||||
this.x = fieldX.getDouble(p);
|
||||
this.y = fieldY.getDouble(p);
|
||||
this.z = fieldZ.getDouble(p);
|
||||
try {
|
||||
this.x = fieldX.getDouble(p);
|
||||
this.y = fieldY.getDouble(p);
|
||||
this.z = fieldZ.getDouble(p);
|
||||
} catch (IllegalAccessException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
if (hasLook) {
|
||||
this.yaw = p.a(0.0F);
|
||||
this.pitch = p.b(0.0F);
|
||||
}
|
||||
else {
|
||||
this.yaw = fieldYaw.getFloat(p);
|
||||
this.pitch = fieldPitch.getFloat(p);
|
||||
} else {
|
||||
try {
|
||||
this.yaw = fieldYaw.getFloat(p);
|
||||
this.pitch = fieldPitch.getFloat(p);
|
||||
} catch (IllegalAccessException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
this.f = p.a();
|
||||
}
|
||||
@@ -78,40 +84,19 @@ public class WrappedPacketPlayInFlying_1_15 {
|
||||
static {
|
||||
try {
|
||||
fieldHasPos = PacketPlayInFlying.class.getDeclaredField("hasPos");
|
||||
} catch (NoSuchFieldException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
try {
|
||||
fieldHasPos.setAccessible(true);
|
||||
fieldHasLook = PacketPlayInFlying.class.getDeclaredField("hasLook");
|
||||
} catch (NoSuchFieldException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
try {
|
||||
fieldHasLook.setAccessible(true);
|
||||
fieldX = PacketPlayInFlying.class.getDeclaredField("x");
|
||||
} catch (NoSuchFieldException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
try {
|
||||
fieldX.setAccessible(true);
|
||||
fieldY = PacketPlayInFlying.class.getDeclaredField("y");
|
||||
} catch (NoSuchFieldException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
try {
|
||||
fieldY.setAccessible(true);
|
||||
fieldZ = PacketPlayInFlying.class.getDeclaredField("z");
|
||||
} catch (NoSuchFieldException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
try {
|
||||
fieldZ.setAccessible(true);
|
||||
fieldYaw = PacketPlayInFlying.class.getDeclaredField("yaw");
|
||||
} catch (NoSuchFieldException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
try {
|
||||
fieldYaw.setAccessible(true);
|
||||
fieldPitch = PacketPlayInFlying.class.getDeclaredField("pitch");
|
||||
fieldPitch.setAccessible(true);
|
||||
} catch (NoSuchFieldException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
+17
-20
@@ -1,32 +1,24 @@
|
||||
package me.purplex.packetevents.packetwrappers.in._1_15;
|
||||
|
||||
import me.purplex.packetevents.enums.EntityUseAction;
|
||||
import me.purplex.packetevents.enums.ServerVersion;
|
||||
import me.purplex.packetevents.packetwrappers.api.WrappedVersionPacket;
|
||||
import net.minecraft.server.v1_15_R1.Entity;
|
||||
import net.minecraft.server.v1_15_R1.PacketPlayInUseEntity;
|
||||
import net.minecraft.server.v1_15_R1.WorldServer;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.craftbukkit.v1_15_R1.CraftWorld;
|
||||
import org.bukkit.entity.Entity;
|
||||
|
||||
public class WrappedPacketPlayInUseEntity_1_15 {
|
||||
private final ServerVersion version;
|
||||
private Entity entity;
|
||||
public class WrappedPacketPlayInUseEntity_1_15 extends WrappedVersionPacket {
|
||||
private org.bukkit.entity.Entity entity;
|
||||
private EntityUseAction action;
|
||||
private final Object packet;
|
||||
|
||||
public WrappedPacketPlayInUseEntity_1_15(Object packet) {
|
||||
this.version = ServerVersion.getVersion();
|
||||
this.packet = packet;
|
||||
setupEntity();
|
||||
setupAction();
|
||||
super(packet);
|
||||
}
|
||||
|
||||
private Object getRawPacket() {
|
||||
return this.packet;
|
||||
}
|
||||
|
||||
public Entity getEntity() {
|
||||
public org.bukkit.entity.Entity getEntity() {
|
||||
return entity;
|
||||
}
|
||||
|
||||
@@ -34,24 +26,29 @@ public class WrappedPacketPlayInUseEntity_1_15 {
|
||||
return action;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setup() {
|
||||
setupEntity();
|
||||
setupAction();
|
||||
}
|
||||
|
||||
private void setupEntity() {
|
||||
PacketPlayInUseEntity packet = (PacketPlayInUseEntity) getRawPacket();
|
||||
PacketPlayInUseEntity p = (PacketPlayInUseEntity) packet;
|
||||
WorldServer worldServer = null;
|
||||
for (World bukkitWorld : Bukkit.getWorlds()) {
|
||||
CraftWorld craftWorld = (CraftWorld) bukkitWorld;
|
||||
worldServer = craftWorld.getHandle();
|
||||
if (packet.a(worldServer) != null) {
|
||||
if (p.a(worldServer) != null) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
net.minecraft.server.v1_15_R1.Entity entity = packet.a(worldServer);
|
||||
Entity entity = p.a(worldServer);
|
||||
this.entity = entity.getBukkitEntity();
|
||||
|
||||
}
|
||||
|
||||
private void setupAction() {
|
||||
PacketPlayInUseEntity packet = (PacketPlayInUseEntity) getRawPacket();
|
||||
String name = packet.b().name();
|
||||
PacketPlayInUseEntity p = (PacketPlayInUseEntity) packet;
|
||||
String name = p.b().name();
|
||||
this.action = EntityUseAction.valueOf(name);
|
||||
}
|
||||
}
|
||||
+5
-6
@@ -1,18 +1,17 @@
|
||||
package me.purplex.packetevents.packetwrappers.in._1_7_10;
|
||||
|
||||
import me.purplex.packetevents.packetwrappers.api.WrappedVersionPacket;
|
||||
import net.minecraft.server.v1_7_R4.PacketPlayInAbilities;
|
||||
|
||||
|
||||
public class WrappedPacketPlayInAbilities_1_7_10 {
|
||||
private final Object packet;
|
||||
|
||||
public class WrappedPacketPlayInAbilities_1_7_10 extends WrappedVersionPacket {
|
||||
public WrappedPacketPlayInAbilities_1_7_10(Object packet) {
|
||||
this.packet = packet;
|
||||
setupFields();
|
||||
super(packet);
|
||||
}
|
||||
|
||||
|
||||
private void setupFields() {
|
||||
@Override
|
||||
protected void setup() {
|
||||
PacketPlayInAbilities p = (PacketPlayInAbilities) packet;
|
||||
this.a = p.c();
|
||||
this.b = p.isFlying();
|
||||
|
||||
+5
-5
@@ -1,16 +1,16 @@
|
||||
package me.purplex.packetevents.packetwrappers.in._1_7_10;
|
||||
|
||||
import me.purplex.packetevents.enums.PlayerDigType;
|
||||
import me.purplex.packetevents.packetwrappers.api.WrappedVersionPacket;
|
||||
import net.minecraft.server.v1_7_R4.PacketPlayInBlockDig;
|
||||
|
||||
public class WrappedPacketPlayInBlockDig_1_7_10 {
|
||||
private final Object packet;
|
||||
public class WrappedPacketPlayInBlockDig_1_7_10 extends WrappedVersionPacket {
|
||||
public WrappedPacketPlayInBlockDig_1_7_10(Object packet) {
|
||||
this.packet = packet;
|
||||
setupDigType();
|
||||
super(packet);
|
||||
}
|
||||
|
||||
private void setupDigType() {
|
||||
@Override
|
||||
protected void setup() {
|
||||
PacketPlayInBlockDig p = (PacketPlayInBlockDig)packet;
|
||||
int status = p.e();
|
||||
this.digType = PlayerDigType.values()[status];
|
||||
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
package me.purplex.packetevents.packetwrappers.in._1_7_10;
|
||||
|
||||
|
||||
public class WrappedPacketPlayInBlockPlace_1_7_10 {
|
||||
|
||||
}
|
||||
+5
-5
@@ -1,12 +1,11 @@
|
||||
package me.purplex.packetevents.packetwrappers.in._1_7_10;
|
||||
|
||||
import me.purplex.packetevents.packetwrappers.api.WrappedVersionPacket;
|
||||
import net.minecraft.server.v1_7_R4.PacketPlayInFlying;
|
||||
|
||||
public class WrappedPacketPlayInFlying_1_7_10 {
|
||||
private final Object packet;
|
||||
public class WrappedPacketPlayInFlying_1_7_10 extends WrappedVersionPacket {
|
||||
public WrappedPacketPlayInFlying_1_7_10(Object packet) {
|
||||
this.packet = packet;
|
||||
setupFields();
|
||||
super(packet);
|
||||
}
|
||||
|
||||
public double x;
|
||||
@@ -19,7 +18,8 @@ public class WrappedPacketPlayInFlying_1_7_10 {
|
||||
public boolean hasLook;
|
||||
|
||||
|
||||
private void setupFields() {
|
||||
@Override
|
||||
protected void setup() {
|
||||
PacketPlayInFlying p = (PacketPlayInFlying)packet;
|
||||
this.x = p.c();
|
||||
this.y = p.d();
|
||||
|
||||
+19
-18
@@ -2,6 +2,7 @@ package me.purplex.packetevents.packetwrappers.in._1_7_10;
|
||||
|
||||
import me.purplex.packetevents.enums.EntityUseAction;
|
||||
import me.purplex.packetevents.enums.ServerVersion;
|
||||
import me.purplex.packetevents.packetwrappers.api.WrappedVersionPacket;
|
||||
import net.minecraft.server.v1_7_R4.Entity;
|
||||
import net.minecraft.server.v1_7_R4.PacketPlayInUseEntity;
|
||||
import net.minecraft.server.v1_7_R4.WorldServer;
|
||||
@@ -9,17 +10,13 @@ import org.bukkit.Bukkit;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.craftbukkit.v1_7_R4.CraftWorld;
|
||||
|
||||
public class WrappedPacketPlayInUseEntity_1_7_10 {
|
||||
private final ServerVersion version;
|
||||
public class WrappedPacketPlayInUseEntity_1_7_10 extends WrappedVersionPacket {
|
||||
private org.bukkit.entity.Entity entity;
|
||||
private EntityUseAction action;
|
||||
private final Object packet;
|
||||
|
||||
public WrappedPacketPlayInUseEntity_1_7_10(Object packet) {
|
||||
this.version = ServerVersion.getVersion();
|
||||
this.packet = packet;
|
||||
setupEntity();
|
||||
setupAction();
|
||||
super(packet);
|
||||
version = ServerVersion.getVersion();
|
||||
}
|
||||
|
||||
private Object getRawPacket() {
|
||||
@@ -34,20 +31,24 @@ public class WrappedPacketPlayInUseEntity_1_7_10 {
|
||||
return action;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setup() {
|
||||
setupEntity();
|
||||
setupAction();
|
||||
}
|
||||
|
||||
private void setupEntity() {
|
||||
if (version == ServerVersion.v_1_8) {
|
||||
PacketPlayInUseEntity packet = (PacketPlayInUseEntity) getRawPacket();
|
||||
WorldServer worldServer = null;
|
||||
for (World bukkitWorld : Bukkit.getWorlds()) {
|
||||
CraftWorld craftWorld = (CraftWorld) bukkitWorld;
|
||||
worldServer = craftWorld.getHandle();
|
||||
if (packet.a(worldServer) != null) {
|
||||
break;
|
||||
}
|
||||
PacketPlayInUseEntity packet = (PacketPlayInUseEntity) getRawPacket();
|
||||
WorldServer worldServer = null;
|
||||
for (World bukkitWorld : Bukkit.getWorlds()) {
|
||||
CraftWorld craftWorld = (CraftWorld) bukkitWorld;
|
||||
worldServer = craftWorld.getHandle();
|
||||
if (packet.a(worldServer) != null) {
|
||||
break;
|
||||
}
|
||||
Entity entity = packet.a(worldServer);
|
||||
this.entity = entity.getBukkitEntity();
|
||||
}
|
||||
Entity entity = packet.a(worldServer);
|
||||
this.entity = entity.getBukkitEntity();
|
||||
}
|
||||
|
||||
private void setupAction() {
|
||||
|
||||
+40
-38
@@ -1,47 +1,11 @@
|
||||
package me.purplex.packetevents.packetwrappers.in._1_8;
|
||||
|
||||
import me.purplex.packetevents.packetwrappers.api.WrappedVersionPacket;
|
||||
import net.minecraft.server.v1_8_R1.PacketPlayInAbilities;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
|
||||
public class WrappedPacketPlayInAbilities_1_8 {
|
||||
private final Object packet;
|
||||
|
||||
private Field fieldE;
|
||||
private Field fieldF;
|
||||
public WrappedPacketPlayInAbilities_1_8(Object packet) {
|
||||
this.packet = packet;
|
||||
try {
|
||||
this.fieldE = PacketPlayInAbilities.class.getDeclaredField("e");
|
||||
} catch (NoSuchFieldException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
try {
|
||||
this.fieldF = PacketPlayInAbilities.class.getDeclaredField("f");
|
||||
} catch (NoSuchFieldException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
setupFields();
|
||||
}
|
||||
|
||||
|
||||
private void setupFields() {
|
||||
PacketPlayInAbilities p = (PacketPlayInAbilities) packet;
|
||||
this.a = p.a();
|
||||
this.b = p.isFlying();
|
||||
this.c = p.c();
|
||||
this.d = p.d();
|
||||
try {
|
||||
this.e = fieldE.getFloat(p);
|
||||
} catch (IllegalAccessException illegalAccessException) {
|
||||
illegalAccessException.printStackTrace();
|
||||
}
|
||||
try {
|
||||
this.f = fieldF.getFloat(p);
|
||||
} catch (IllegalAccessException illegalAccessException) {
|
||||
illegalAccessException.printStackTrace();
|
||||
}
|
||||
}
|
||||
public class WrappedPacketPlayInAbilities_1_8 extends WrappedVersionPacket {
|
||||
|
||||
public boolean a;
|
||||
public boolean b;
|
||||
@@ -49,4 +13,42 @@ public class WrappedPacketPlayInAbilities_1_8 {
|
||||
public boolean d;
|
||||
public float e;
|
||||
public float f;
|
||||
|
||||
|
||||
public WrappedPacketPlayInAbilities_1_8(Object packet) {
|
||||
super(packet);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setup() {
|
||||
PacketPlayInAbilities p = (PacketPlayInAbilities) packet;
|
||||
this.a = p.a();
|
||||
this.b = p.isFlying();
|
||||
this.c = p.c();
|
||||
this.d = p.d();
|
||||
try {
|
||||
this.e = fieldE.getFloat(p);
|
||||
} catch (IllegalAccessException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
try {
|
||||
this.f = fieldF.getFloat(p);
|
||||
} catch (IllegalAccessException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
private static Field fieldE;
|
||||
private static Field fieldF;
|
||||
|
||||
static {
|
||||
try {
|
||||
fieldE = PacketPlayInAbilities.class.getDeclaredField("e");
|
||||
fieldE.setAccessible(true);
|
||||
fieldF = PacketPlayInAbilities.class.getDeclaredField("f");
|
||||
fieldF.setAccessible(true);
|
||||
} catch (NoSuchFieldException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
+5
-6
@@ -1,21 +1,20 @@
|
||||
package me.purplex.packetevents.packetwrappers.in._1_8;
|
||||
|
||||
import me.purplex.packetevents.enums.PlayerDigType;
|
||||
import me.purplex.packetevents.packetwrappers.api.WrappedVersionPacket;
|
||||
import net.minecraft.server.v1_8_R1.PacketPlayInBlockDig;
|
||||
|
||||
public class WrappedPacketPlayInBlockDig_1_8 {
|
||||
private final Object packet;
|
||||
public class WrappedPacketPlayInBlockDig_1_8 extends WrappedVersionPacket {
|
||||
public WrappedPacketPlayInBlockDig_1_8(Object packet) {
|
||||
this.packet = packet;
|
||||
setupDigType();
|
||||
super(packet);
|
||||
}
|
||||
|
||||
private void setupDigType() {
|
||||
@Override
|
||||
protected void setup() {
|
||||
PacketPlayInBlockDig p = (PacketPlayInBlockDig)packet;
|
||||
String name = p.c().name();
|
||||
this.digType = PlayerDigType.valueOf(name);
|
||||
}
|
||||
|
||||
public PlayerDigType digType;
|
||||
|
||||
}
|
||||
+5
-6
@@ -1,14 +1,12 @@
|
||||
package me.purplex.packetevents.packetwrappers.in._1_8;
|
||||
|
||||
|
||||
import me.purplex.packetevents.packetwrappers.api.WrappedVersionPacket;
|
||||
import net.minecraft.server.v1_8_R1.PacketPlayInFlying;
|
||||
|
||||
public class WrappedPacketPlayInFlying_1_8 {
|
||||
private final Object packet;
|
||||
|
||||
public class WrappedPacketPlayInFlying_1_8 extends WrappedVersionPacket {
|
||||
public WrappedPacketPlayInFlying_1_8(Object packet) {
|
||||
this.packet = packet;
|
||||
setupFields();
|
||||
super(packet);
|
||||
}
|
||||
|
||||
public double x;
|
||||
@@ -21,7 +19,8 @@ public class WrappedPacketPlayInFlying_1_8 {
|
||||
public boolean hasLook;
|
||||
|
||||
|
||||
private void setupFields() {
|
||||
@Override
|
||||
protected void setup() {
|
||||
PacketPlayInFlying p = (PacketPlayInFlying) packet;
|
||||
this.x = p.a();
|
||||
this.y = p.b();
|
||||
|
||||
+10
-7
@@ -2,21 +2,18 @@ package me.purplex.packetevents.packetwrappers.in._1_8;
|
||||
|
||||
import me.purplex.packetevents.enums.EntityUseAction;
|
||||
import me.purplex.packetevents.enums.ServerVersion;
|
||||
import me.purplex.packetevents.packetwrappers.api.WrappedVersionPacket;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.entity.Entity;
|
||||
|
||||
public class WrappedPacketPlayInUseEntity_1_8 {
|
||||
private final ServerVersion version;
|
||||
public class WrappedPacketPlayInUseEntity_1_8 extends WrappedVersionPacket {
|
||||
private Entity entity;
|
||||
private EntityUseAction action;
|
||||
private final Object packet;
|
||||
|
||||
public WrappedPacketPlayInUseEntity_1_8(Object packet) {
|
||||
this.version = ServerVersion.getVersion();
|
||||
this.packet = packet;
|
||||
setupEntity();
|
||||
setupAction();
|
||||
super(packet);
|
||||
|
||||
}
|
||||
|
||||
private Object getRawPacket() {
|
||||
@@ -31,6 +28,12 @@ public class WrappedPacketPlayInUseEntity_1_8 {
|
||||
return action;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setup() {
|
||||
setupEntity();
|
||||
setupAction();
|
||||
}
|
||||
|
||||
private void setupEntity() {
|
||||
if (version == ServerVersion.v_1_8) {
|
||||
net.minecraft.server.v1_8_R1.PacketPlayInUseEntity packet = (net.minecraft.server.v1_8_R1.PacketPlayInUseEntity) getRawPacket();
|
||||
|
||||
+29
-51
@@ -1,60 +1,11 @@
|
||||
package me.purplex.packetevents.packetwrappers.in._1_8_3;
|
||||
|
||||
import me.purplex.packetevents.packetwrappers.api.WrappedVersionPacket;
|
||||
import net.minecraft.server.v1_8_R2.PacketPlayInAbilities;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
|
||||
public class WrappedPacketPlayInAbilities_1_8_3 {
|
||||
private final Object packet;
|
||||
|
||||
private static Field fieldE;
|
||||
private static Field fieldF;
|
||||
|
||||
static {
|
||||
try {
|
||||
fieldF = PacketPlayInAbilities.class.getDeclaredField("e");
|
||||
} catch (NoSuchFieldException noSuchFieldException) {
|
||||
noSuchFieldException.printStackTrace();
|
||||
} try {
|
||||
fieldE = PacketPlayInAbilities.class.getDeclaredField("e");
|
||||
} catch (NoSuchFieldException noSuchFieldException) {
|
||||
noSuchFieldException.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public WrappedPacketPlayInAbilities_1_8_3(Object packet) {
|
||||
this.packet = packet;
|
||||
try {
|
||||
this.fieldE = PacketPlayInAbilities.class.getDeclaredField("e");
|
||||
} catch (NoSuchFieldException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
try {
|
||||
this.fieldF = PacketPlayInAbilities.class.getDeclaredField("f");
|
||||
} catch (NoSuchFieldException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
setupFields();
|
||||
}
|
||||
|
||||
|
||||
private void setupFields() {
|
||||
PacketPlayInAbilities p = (PacketPlayInAbilities) packet;
|
||||
this.a = p.a();
|
||||
this.b = p.isFlying();
|
||||
this.c = p.c();
|
||||
this.d = p.d();
|
||||
try {
|
||||
this.e = fieldE.getFloat(p);
|
||||
} catch (IllegalAccessException illegalAccessException) {
|
||||
illegalAccessException.printStackTrace();
|
||||
}
|
||||
try {
|
||||
this.f = fieldF.getFloat(p);
|
||||
} catch (IllegalAccessException illegalAccessException) {
|
||||
illegalAccessException.printStackTrace();
|
||||
}
|
||||
}
|
||||
public class WrappedPacketPlayInAbilities_1_8_3 extends WrappedVersionPacket {
|
||||
|
||||
public boolean a;
|
||||
public boolean b;
|
||||
@@ -62,4 +13,31 @@ public class WrappedPacketPlayInAbilities_1_8_3 {
|
||||
public boolean d;
|
||||
public float e;
|
||||
public float f;
|
||||
|
||||
public WrappedPacketPlayInAbilities_1_8_3(Object packet) {
|
||||
super(packet);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setup() {
|
||||
PacketPlayInAbilities p = (PacketPlayInAbilities) packet;
|
||||
this.a = p.a();
|
||||
this.b = p.isFlying();
|
||||
this.c = p.c();
|
||||
this.d = p.d();
|
||||
}
|
||||
|
||||
private static Field fieldE;
|
||||
private static Field fieldF;
|
||||
|
||||
static {
|
||||
try {
|
||||
fieldE = PacketPlayInAbilities.class.getDeclaredField("e");
|
||||
fieldE.setAccessible(true);
|
||||
fieldF = PacketPlayInAbilities.class.getDeclaredField("f");
|
||||
fieldF.setAccessible(true);
|
||||
} catch (NoSuchFieldException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
+8
-7
@@ -1,21 +1,22 @@
|
||||
package me.purplex.packetevents.packetwrappers.in._1_8_3;
|
||||
|
||||
import me.purplex.packetevents.enums.PlayerDigType;
|
||||
import me.purplex.packetevents.packetwrappers.api.WrappedVersionPacket;
|
||||
import net.minecraft.server.v1_8_R2.PacketPlayInBlockDig;
|
||||
|
||||
public class WrappedPacketPlayInBlockDig_1_8_3 {
|
||||
private final Object packet;
|
||||
public class WrappedPacketPlayInBlockDig_1_8_3 extends WrappedVersionPacket {
|
||||
public PlayerDigType digType;
|
||||
|
||||
public WrappedPacketPlayInBlockDig_1_8_3(Object packet) {
|
||||
this.packet = packet;
|
||||
setupDigType();
|
||||
super(packet);
|
||||
}
|
||||
|
||||
private void setupDigType() {
|
||||
PacketPlayInBlockDig p = (PacketPlayInBlockDig)packet;
|
||||
@Override
|
||||
protected void setup() {
|
||||
PacketPlayInBlockDig p = (PacketPlayInBlockDig) packet;
|
||||
String name = p.c().name();
|
||||
this.digType = PlayerDigType.valueOf(name);
|
||||
}
|
||||
|
||||
public PlayerDigType digType;
|
||||
|
||||
}
|
||||
+7
-8
@@ -1,14 +1,9 @@
|
||||
package me.purplex.packetevents.packetwrappers.in._1_8_3;
|
||||
|
||||
import me.purplex.packetevents.packetwrappers.api.WrappedVersionPacket;
|
||||
import net.minecraft.server.v1_8_R2.PacketPlayInFlying;
|
||||
|
||||
public class WrappedPacketPlayInFlying_1_8_3 {
|
||||
private final Object packet;
|
||||
public WrappedPacketPlayInFlying_1_8_3(Object packet) {
|
||||
this.packet = packet;
|
||||
setupFields();
|
||||
}
|
||||
|
||||
public class WrappedPacketPlayInFlying_1_8_3 extends WrappedVersionPacket {
|
||||
public double x;
|
||||
public double y;
|
||||
public double z;
|
||||
@@ -17,9 +12,13 @@ public class WrappedPacketPlayInFlying_1_8_3 {
|
||||
public boolean f;
|
||||
public boolean hasPos;
|
||||
public boolean hasLook;
|
||||
public WrappedPacketPlayInFlying_1_8_3(Object packet) {
|
||||
super(packet);
|
||||
}
|
||||
|
||||
|
||||
private void setupFields() {
|
||||
@Override
|
||||
protected void setup() {
|
||||
PacketPlayInFlying p = (PacketPlayInFlying)packet;
|
||||
this.x = p.a();
|
||||
this.y = p.b();
|
||||
|
||||
+22
-16
@@ -1,29 +1,27 @@
|
||||
package me.purplex.packetevents.packetwrappers.in._1_8_3;
|
||||
|
||||
import me.purplex.packetevents.enums.EntityUseAction;
|
||||
import me.purplex.packetevents.enums.ServerVersion;
|
||||
import me.purplex.packetevents.packetwrappers.api.WrappedVersionPacket;
|
||||
import net.minecraft.server.v1_8_R2.Entity;
|
||||
import net.minecraft.server.v1_8_R2.PacketPlayInUseEntity;
|
||||
import net.minecraft.server.v1_8_R2.WorldServer;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.craftbukkit.v1_8_R2.CraftWorld;
|
||||
|
||||
public class WrappedPacketPlayInUseEntity_1_8_3 {
|
||||
private final ServerVersion version;
|
||||
private Entity entity;
|
||||
public class WrappedPacketPlayInUseEntity_1_8_3 extends WrappedVersionPacket {
|
||||
private org.bukkit.entity.Entity entity;
|
||||
private EntityUseAction action;
|
||||
private final Object packet;
|
||||
|
||||
public WrappedPacketPlayInUseEntity_1_8_3(Object packet) {
|
||||
this.version = ServerVersion.getVersion();
|
||||
this.packet = packet;
|
||||
setupEntity();
|
||||
setupAction();
|
||||
super(packet);
|
||||
}
|
||||
|
||||
private Object getRawPacket() {
|
||||
return this.packet;
|
||||
}
|
||||
|
||||
public Entity getEntity() {
|
||||
public org.bukkit.entity.Entity getEntity() {
|
||||
return entity;
|
||||
}
|
||||
|
||||
@@ -31,19 +29,27 @@ public class WrappedPacketPlayInUseEntity_1_8_3 {
|
||||
return action;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setup() {
|
||||
setupEntity();
|
||||
setupAction();
|
||||
}
|
||||
|
||||
private void setupEntity() {
|
||||
net.minecraft.server.v1_8_R2.PacketPlayInUseEntity packet = (net.minecraft.server.v1_8_R2.PacketPlayInUseEntity) getRawPacket();
|
||||
net.minecraft.server.v1_8_R2.WorldServer worldServer = null;
|
||||
PacketPlayInUseEntity packet = (PacketPlayInUseEntity) getRawPacket();
|
||||
WorldServer worldServer = null;
|
||||
for (World bukkitWorld : Bukkit.getWorlds()) {
|
||||
org.bukkit.craftbukkit.v1_8_R2.CraftWorld craftWorld = (org.bukkit.craftbukkit.v1_8_R2.CraftWorld) bukkitWorld;
|
||||
CraftWorld craftWorld = (CraftWorld) bukkitWorld;
|
||||
worldServer = craftWorld.getHandle();
|
||||
if (packet.a(worldServer) != null) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
net.minecraft.server.v1_8_R2.Entity entity = packet.a(worldServer);
|
||||
this.entity = entity.getBukkitEntity();
|
||||
//nms entity
|
||||
Entity entity = packet.a(worldServer);
|
||||
|
||||
//bukkit entity
|
||||
this.entity = entity.getBukkitEntity();
|
||||
}
|
||||
|
||||
private void setupAction() {
|
||||
|
||||
+25
-23
@@ -1,32 +1,27 @@
|
||||
package me.purplex.packetevents.packetwrappers.in._1_8_8;
|
||||
|
||||
import me.purplex.packetevents.packetwrappers.api.WrappedVersionPacket;
|
||||
import net.minecraft.server.v1_8_R3.PacketPlayInAbilities;
|
||||
|
||||
import java.lang.Object;
|
||||
import java.lang.reflect.Field;
|
||||
|
||||
public class WrappedPacketPlayInAbilities_1_8_8 {
|
||||
private final Object packet;
|
||||
public class WrappedPacketPlayInAbilities_1_8_8 extends WrappedVersionPacket {
|
||||
|
||||
public boolean a;
|
||||
public boolean b;
|
||||
public boolean c;
|
||||
public boolean d;
|
||||
public float e;
|
||||
public float f;
|
||||
|
||||
private Field fieldE;
|
||||
private Field fieldF;
|
||||
public WrappedPacketPlayInAbilities_1_8_8(Object packet) {
|
||||
this.packet = packet;
|
||||
try {
|
||||
this.fieldE = PacketPlayInAbilities.class.getDeclaredField("e");
|
||||
} catch (NoSuchFieldException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
try {
|
||||
this.fieldF = PacketPlayInAbilities.class.getDeclaredField("f");
|
||||
} catch (NoSuchFieldException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
setupFields();
|
||||
super(packet);
|
||||
}
|
||||
|
||||
|
||||
private void setupFields() {
|
||||
@Override
|
||||
protected void setup() {
|
||||
PacketPlayInAbilities p = (PacketPlayInAbilities) packet;
|
||||
this.a = p.a();
|
||||
this.b = p.isFlying();
|
||||
@@ -44,10 +39,17 @@ public class WrappedPacketPlayInAbilities_1_8_8 {
|
||||
}
|
||||
}
|
||||
|
||||
public boolean a;
|
||||
public boolean b;
|
||||
public boolean c;
|
||||
public boolean d;
|
||||
public float e;
|
||||
public float f;
|
||||
private static Field fieldE;
|
||||
private static Field fieldF;
|
||||
|
||||
static {
|
||||
try {
|
||||
fieldE = PacketPlayInAbilities.class.getDeclaredField("e");
|
||||
fieldE.setAccessible(true);
|
||||
fieldF = PacketPlayInAbilities.class.getDeclaredField("f");
|
||||
fieldF.setAccessible(true);
|
||||
} catch (NoSuchFieldException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
+5
-5
@@ -1,16 +1,16 @@
|
||||
package me.purplex.packetevents.packetwrappers.in._1_8_8;
|
||||
|
||||
import me.purplex.packetevents.enums.PlayerDigType;
|
||||
import me.purplex.packetevents.packetwrappers.api.WrappedVersionPacket;
|
||||
import net.minecraft.server.v1_8_R3.PacketPlayInBlockDig;
|
||||
|
||||
public class WrappedPacketPlayInBlockDig_1_8_8 {
|
||||
private final Object packet;
|
||||
public class WrappedPacketPlayInBlockDig_1_8_8 extends WrappedVersionPacket {
|
||||
public WrappedPacketPlayInBlockDig_1_8_8(Object packet) {
|
||||
this.packet = packet;
|
||||
setupDigType();
|
||||
super(packet);
|
||||
}
|
||||
|
||||
private void setupDigType() {
|
||||
@Override
|
||||
protected void setup() {
|
||||
PacketPlayInBlockDig p = (PacketPlayInBlockDig)packet;
|
||||
String name = p.c().name();
|
||||
this.digType = PlayerDigType.valueOf(name);
|
||||
|
||||
+5
-5
@@ -1,12 +1,11 @@
|
||||
package me.purplex.packetevents.packetwrappers.in._1_8_8;
|
||||
|
||||
import me.purplex.packetevents.packetwrappers.api.WrappedVersionPacket;
|
||||
import net.minecraft.server.v1_8_R3.PacketPlayInFlying;
|
||||
|
||||
public class WrappedPacketPlayInFlying_1_8_8 {
|
||||
private final Object packet;
|
||||
public class WrappedPacketPlayInFlying_1_8_8 extends WrappedVersionPacket {
|
||||
public WrappedPacketPlayInFlying_1_8_8(Object packet) {
|
||||
this.packet = packet;
|
||||
setupFields();
|
||||
super(packet);
|
||||
}
|
||||
|
||||
public double x;
|
||||
@@ -19,7 +18,8 @@ public class WrappedPacketPlayInFlying_1_8_8 {
|
||||
public boolean hasLook;
|
||||
|
||||
|
||||
private void setupFields() {
|
||||
@Override
|
||||
protected void setup() {
|
||||
PacketPlayInFlying p = (PacketPlayInFlying)packet;
|
||||
this.x = p.a();
|
||||
this.y = p.b();
|
||||
|
||||
+22
-23
@@ -1,29 +1,22 @@
|
||||
package me.purplex.packetevents.packetwrappers.in._1_8_8;
|
||||
|
||||
import me.purplex.packetevents.enums.EntityUseAction;
|
||||
import me.purplex.packetevents.enums.ServerVersion;
|
||||
import me.purplex.packetevents.packetwrappers.api.WrappedVersionPacket;
|
||||
import net.minecraft.server.v1_8_R3.Entity;
|
||||
import net.minecraft.server.v1_8_R3.PacketPlayInUseEntity;
|
||||
import net.minecraft.server.v1_8_R3.WorldServer;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.craftbukkit.v1_8_R3.CraftWorld;
|
||||
|
||||
public class WrappedPacketPlayInUseEntity_1_8_8 {
|
||||
private final ServerVersion version;
|
||||
private Entity entity;
|
||||
public class WrappedPacketPlayInUseEntity_1_8_8 extends WrappedVersionPacket {
|
||||
private org.bukkit.entity.Entity entity;
|
||||
private EntityUseAction action;
|
||||
private final Object packet;
|
||||
|
||||
public WrappedPacketPlayInUseEntity_1_8_8(Object packet) {
|
||||
this.version = ServerVersion.getVersion();
|
||||
this.packet = packet;
|
||||
setupEntity();
|
||||
setupAction();
|
||||
super(packet);
|
||||
}
|
||||
|
||||
private Object getRawPacket() {
|
||||
return this.packet;
|
||||
}
|
||||
|
||||
public Entity getEntity() {
|
||||
public org.bukkit.entity.Entity getEntity() {
|
||||
return entity;
|
||||
}
|
||||
|
||||
@@ -31,23 +24,29 @@ public class WrappedPacketPlayInUseEntity_1_8_8 {
|
||||
return action;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setup() {
|
||||
setupEntity();
|
||||
setupAction();
|
||||
}
|
||||
|
||||
private void setupEntity() {
|
||||
net.minecraft.server.v1_8_R3.PacketPlayInUseEntity packet = (net.minecraft.server.v1_8_R3.PacketPlayInUseEntity) getRawPacket();
|
||||
net.minecraft.server.v1_8_R3.WorldServer worldServer = null;
|
||||
PacketPlayInUseEntity p = (PacketPlayInUseEntity) packet;
|
||||
WorldServer worldServer = null;
|
||||
for (World bukkitWorld : Bukkit.getWorlds()) {
|
||||
org.bukkit.craftbukkit.v1_8_R3.CraftWorld craftWorld = (org.bukkit.craftbukkit.v1_8_R3.CraftWorld) bukkitWorld;
|
||||
CraftWorld craftWorld = (CraftWorld) bukkitWorld;
|
||||
worldServer = craftWorld.getHandle();
|
||||
if (packet.a(worldServer) != null) {
|
||||
if (p.a(worldServer) != null) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
net.minecraft.server.v1_8_R3.Entity entity = packet.a(worldServer);
|
||||
Entity entity = p.a(worldServer);
|
||||
this.entity = entity.getBukkitEntity();
|
||||
}
|
||||
|
||||
private void setupAction() {
|
||||
net.minecraft.server.v1_8_R3.PacketPlayInUseEntity packet = (net.minecraft.server.v1_8_R3.PacketPlayInUseEntity) getRawPacket();
|
||||
String name = packet.a().name();
|
||||
PacketPlayInUseEntity p = (PacketPlayInUseEntity) packet;
|
||||
String name = p.a().name();
|
||||
this.action = EntityUseAction.valueOf(name);
|
||||
}
|
||||
|
||||
|
||||
+40
-38
@@ -1,47 +1,11 @@
|
||||
package me.purplex.packetevents.packetwrappers.in._1_9;
|
||||
|
||||
import me.purplex.packetevents.packetwrappers.api.WrappedVersionPacket;
|
||||
import net.minecraft.server.v1_9_R1.PacketPlayInAbilities;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
|
||||
public class WrappedPacketPlayInAbilities_1_9 {
|
||||
private final Object packet;
|
||||
|
||||
private Field fieldE;
|
||||
private Field fieldF;
|
||||
public WrappedPacketPlayInAbilities_1_9(Object packet) {
|
||||
this.packet = packet;
|
||||
try {
|
||||
this.fieldE = PacketPlayInAbilities.class.getDeclaredField("e");
|
||||
} catch (NoSuchFieldException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
try {
|
||||
this.fieldF = PacketPlayInAbilities.class.getDeclaredField("f");
|
||||
} catch (NoSuchFieldException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
setupFields();
|
||||
}
|
||||
|
||||
|
||||
private void setupFields() {
|
||||
PacketPlayInAbilities p = (PacketPlayInAbilities) packet;
|
||||
this.a = p.a();
|
||||
this.b = p.isFlying();
|
||||
this.c = p.c();
|
||||
this.d = p.d();
|
||||
try {
|
||||
this.e = fieldE.getFloat(p);
|
||||
} catch (IllegalAccessException illegalAccessException) {
|
||||
illegalAccessException.printStackTrace();
|
||||
}
|
||||
try {
|
||||
this.f = fieldF.getFloat(p);
|
||||
} catch (IllegalAccessException illegalAccessException) {
|
||||
illegalAccessException.printStackTrace();
|
||||
}
|
||||
}
|
||||
public class WrappedPacketPlayInAbilities_1_9 extends WrappedVersionPacket {
|
||||
|
||||
public boolean a;
|
||||
public boolean b;
|
||||
@@ -49,4 +13,42 @@ public class WrappedPacketPlayInAbilities_1_9 {
|
||||
public boolean d;
|
||||
public float e;
|
||||
public float f;
|
||||
|
||||
public WrappedPacketPlayInAbilities_1_9(Object packet) {
|
||||
super(packet);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setup() {
|
||||
PacketPlayInAbilities p = (PacketPlayInAbilities) packet;
|
||||
this.a = p.a();
|
||||
this.b = p.isFlying();
|
||||
this.c = p.c();
|
||||
this.d = p.d();
|
||||
try {
|
||||
this.e = fieldE.getFloat(p);
|
||||
} catch (IllegalAccessException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
try {
|
||||
this.f = fieldF.getFloat(p);
|
||||
} catch (IllegalAccessException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
private static Field fieldE;
|
||||
private static Field fieldF;
|
||||
|
||||
static {
|
||||
try {
|
||||
fieldE = PacketPlayInAbilities.class.getDeclaredField("e");
|
||||
fieldE.setAccessible(true);
|
||||
fieldF = PacketPlayInAbilities.class.getDeclaredField("f");
|
||||
fieldF.setAccessible(true);
|
||||
} catch (NoSuchFieldException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
+8
-7
@@ -1,21 +1,22 @@
|
||||
package me.purplex.packetevents.packetwrappers.in._1_9;
|
||||
|
||||
import me.purplex.packetevents.enums.PlayerDigType;
|
||||
import me.purplex.packetevents.packetwrappers.api.WrappedVersionPacket;
|
||||
import net.minecraft.server.v1_9_R1.PacketPlayInBlockDig;
|
||||
|
||||
public class WrappedPacketPlayInBlockDig_1_9 {
|
||||
private final Object packet;
|
||||
public class WrappedPacketPlayInBlockDig_1_9 extends WrappedVersionPacket {
|
||||
|
||||
public PlayerDigType digType;
|
||||
|
||||
public WrappedPacketPlayInBlockDig_1_9(Object packet) {
|
||||
this.packet = packet;
|
||||
setupDigType();
|
||||
super(packet);
|
||||
}
|
||||
|
||||
private void setupDigType() {
|
||||
@Override
|
||||
protected void setup() {
|
||||
PacketPlayInBlockDig p = (PacketPlayInBlockDig)packet;
|
||||
String name = p.c().name();
|
||||
this.digType = PlayerDigType.valueOf(name);
|
||||
}
|
||||
|
||||
public PlayerDigType digType;
|
||||
|
||||
}
|
||||
+33
-48
@@ -1,12 +1,11 @@
|
||||
package me.purplex.packetevents.packetwrappers.in._1_9;
|
||||
|
||||
import me.purplex.packetevents.packetwrappers.api.WrappedVersionPacket;
|
||||
import net.minecraft.server.v1_9_R1.PacketPlayInFlying;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
|
||||
public class WrappedPacketPlayInFlying_1_9 {
|
||||
private final Object packet;
|
||||
|
||||
public class WrappedPacketPlayInFlying_1_9 extends WrappedVersionPacket {
|
||||
public double x;
|
||||
public double y;
|
||||
public double z;
|
||||
@@ -15,38 +14,45 @@ public class WrappedPacketPlayInFlying_1_9 {
|
||||
public boolean f;
|
||||
public boolean hasPos;
|
||||
public boolean hasLook;
|
||||
|
||||
public WrappedPacketPlayInFlying_1_9(Object packet) {
|
||||
this.packet = packet;
|
||||
try {
|
||||
setupFields();
|
||||
} catch (IllegalAccessException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
super(packet);
|
||||
}
|
||||
|
||||
|
||||
|
||||
private void setupFields() throws IllegalAccessException {
|
||||
@Override
|
||||
protected void setup() {
|
||||
PacketPlayInFlying p = (PacketPlayInFlying) packet;
|
||||
this.hasPos = fieldHasPos.getBoolean(p);
|
||||
this.hasLook = fieldHasLook.getBoolean(p);
|
||||
try {
|
||||
this.hasPos = fieldHasPos.getBoolean(p);
|
||||
this.hasLook = fieldHasLook.getBoolean(p);
|
||||
} catch (IllegalAccessException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
if (hasPos) {
|
||||
this.x = p.a(0.0D);
|
||||
this.y = p.b(0.0D);
|
||||
this.z = p.c(0.0D);
|
||||
} else {
|
||||
this.x = fieldX.getDouble(p);
|
||||
this.y = fieldY.getDouble(p);
|
||||
this.z = fieldZ.getDouble(p);
|
||||
try {
|
||||
this.x = fieldX.getDouble(p);
|
||||
this.y = fieldY.getDouble(p);
|
||||
this.z = fieldZ.getDouble(p);
|
||||
} catch (IllegalAccessException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
if (hasLook) {
|
||||
this.yaw = p.a(0.0F);
|
||||
this.pitch = p.b(0.0F);
|
||||
}
|
||||
else {
|
||||
this.yaw = fieldYaw.getFloat(p);
|
||||
this.pitch = fieldPitch.getFloat(p);
|
||||
} else {
|
||||
try {
|
||||
this.yaw = fieldYaw.getFloat(p);
|
||||
this.pitch = fieldPitch.getFloat(p);
|
||||
} catch (IllegalAccessException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
this.f = p.a();
|
||||
}
|
||||
@@ -79,40 +85,19 @@ public class WrappedPacketPlayInFlying_1_9 {
|
||||
static {
|
||||
try {
|
||||
fieldHasPos = PacketPlayInFlying.class.getDeclaredField("hasPos");
|
||||
} catch (NoSuchFieldException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
try {
|
||||
fieldHasPos.setAccessible(true);
|
||||
fieldHasLook = PacketPlayInFlying.class.getDeclaredField("hasLook");
|
||||
} catch (NoSuchFieldException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
try {
|
||||
fieldHasLook.setAccessible(true);
|
||||
fieldX = PacketPlayInFlying.class.getDeclaredField("x");
|
||||
} catch (NoSuchFieldException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
try {
|
||||
fieldX.setAccessible(true);
|
||||
fieldY = PacketPlayInFlying.class.getDeclaredField("y");
|
||||
} catch (NoSuchFieldException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
try {
|
||||
fieldY.setAccessible(true);
|
||||
fieldZ = PacketPlayInFlying.class.getDeclaredField("z");
|
||||
} catch (NoSuchFieldException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
try {
|
||||
fieldZ.setAccessible(true);
|
||||
fieldYaw = PacketPlayInFlying.class.getDeclaredField("yaw");
|
||||
} catch (NoSuchFieldException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
try {
|
||||
fieldYaw.setAccessible(true);
|
||||
fieldPitch = PacketPlayInFlying.class.getDeclaredField("pitch");
|
||||
fieldPitch.setAccessible(true);
|
||||
} catch (NoSuchFieldException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
+22
-22
@@ -2,28 +2,22 @@ package me.purplex.packetevents.packetwrappers.in._1_9;
|
||||
|
||||
import me.purplex.packetevents.enums.EntityUseAction;
|
||||
import me.purplex.packetevents.enums.ServerVersion;
|
||||
import me.purplex.packetevents.packetwrappers.api.WrappedVersionPacket;
|
||||
import net.minecraft.server.v1_9_R1.Entity;
|
||||
import net.minecraft.server.v1_9_R1.PacketPlayInUseEntity;
|
||||
import net.minecraft.server.v1_9_R1.WorldServer;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.craftbukkit.v1_9_R1.CraftWorld;
|
||||
|
||||
public class WrappedPacketPlayInUseEntity_1_9 {
|
||||
private final ServerVersion version;
|
||||
private Entity entity;
|
||||
public class WrappedPacketPlayInUseEntity_1_9 extends WrappedVersionPacket {
|
||||
private org.bukkit.entity.Entity entity;
|
||||
private EntityUseAction action;
|
||||
private final Object packet;
|
||||
|
||||
public WrappedPacketPlayInUseEntity_1_9(Object packet) {
|
||||
this.version = ServerVersion.getVersion();
|
||||
this.packet = packet;
|
||||
setupEntity();
|
||||
setupAction();
|
||||
super(packet);
|
||||
}
|
||||
|
||||
private Object getRawPacket() {
|
||||
return this.packet;
|
||||
}
|
||||
|
||||
public Entity getEntity() {
|
||||
public org.bukkit.entity.Entity getEntity() {
|
||||
return entity;
|
||||
}
|
||||
|
||||
@@ -31,25 +25,31 @@ public class WrappedPacketPlayInUseEntity_1_9 {
|
||||
return action;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setup() {
|
||||
setupEntity();
|
||||
setupAction();
|
||||
}
|
||||
|
||||
private void setupEntity() {
|
||||
net.minecraft.server.v1_9_R1.PacketPlayInUseEntity packet = (net.minecraft.server.v1_9_R1.PacketPlayInUseEntity) getRawPacket();
|
||||
net.minecraft.server.v1_9_R1.WorldServer worldServer = null;
|
||||
PacketPlayInUseEntity p = (PacketPlayInUseEntity) packet;
|
||||
WorldServer worldServer = null;
|
||||
for (World bukkitWorld : Bukkit.getWorlds()) {
|
||||
org.bukkit.craftbukkit.v1_9_R1.CraftWorld craftWorld = (org.bukkit.craftbukkit.v1_9_R1.CraftWorld) bukkitWorld;
|
||||
CraftWorld craftWorld = (CraftWorld) bukkitWorld;
|
||||
worldServer = craftWorld.getHandle();
|
||||
if (packet.a(worldServer) != null) {
|
||||
if (p.a(worldServer) != null) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
net.minecraft.server.v1_9_R1.Entity entity = packet.a(worldServer);
|
||||
Entity entity = p.a(worldServer);
|
||||
this.entity = entity.getBukkitEntity();
|
||||
|
||||
}
|
||||
|
||||
private void setupAction() {
|
||||
if (version == ServerVersion.v_1_8) {
|
||||
net.minecraft.server.v1_9_R1.PacketPlayInUseEntity packet = (net.minecraft.server.v1_9_R1.PacketPlayInUseEntity) getRawPacket();
|
||||
String name = packet.a().name();
|
||||
PacketPlayInUseEntity p = (net.minecraft.server.v1_9_R1.PacketPlayInUseEntity) packet;
|
||||
String name = p.a().name();
|
||||
this.action = EntityUseAction.valueOf(name);
|
||||
}
|
||||
}
|
||||
|
||||
+34
-39
@@ -1,47 +1,10 @@
|
||||
package me.purplex.packetevents.packetwrappers.in._1_9_4;
|
||||
|
||||
import me.purplex.packetevents.packetwrappers.api.WrappedVersionPacket;
|
||||
import net.minecraft.server.v1_9_R2.PacketPlayInAbilities;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
|
||||
public class WrappedPacketPlayInAbilities_1_9_4 {
|
||||
private final Object packet;
|
||||
|
||||
private Field fieldE;
|
||||
private Field fieldF;
|
||||
public WrappedPacketPlayInAbilities_1_9_4(Object packet) {
|
||||
this.packet = packet;
|
||||
try {
|
||||
this.fieldE = PacketPlayInAbilities.class.getDeclaredField("e");
|
||||
} catch (NoSuchFieldException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
try {
|
||||
this.fieldF = PacketPlayInAbilities.class.getDeclaredField("f");
|
||||
} catch (NoSuchFieldException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
setupFields();
|
||||
}
|
||||
|
||||
|
||||
private void setupFields() {
|
||||
PacketPlayInAbilities p = (PacketPlayInAbilities) packet;
|
||||
this.a = p.a();
|
||||
this.b = p.isFlying();
|
||||
this.c = p.c();
|
||||
this.d = p.d();
|
||||
try {
|
||||
this.e = fieldE.getFloat(p);
|
||||
} catch (IllegalAccessException illegalAccessException) {
|
||||
illegalAccessException.printStackTrace();
|
||||
}
|
||||
try {
|
||||
this.f = fieldF.getFloat(p);
|
||||
} catch (IllegalAccessException illegalAccessException) {
|
||||
illegalAccessException.printStackTrace();
|
||||
}
|
||||
}
|
||||
public class WrappedPacketPlayInAbilities_1_9_4 extends WrappedVersionPacket {
|
||||
|
||||
public boolean a;
|
||||
public boolean b;
|
||||
@@ -49,4 +12,36 @@ public class WrappedPacketPlayInAbilities_1_9_4 {
|
||||
public boolean d;
|
||||
public float e;
|
||||
public float f;
|
||||
|
||||
public WrappedPacketPlayInAbilities_1_9_4(Object packet) {
|
||||
super(packet);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void setup() {
|
||||
PacketPlayInAbilities p = (PacketPlayInAbilities) packet;
|
||||
this.a = p.a();
|
||||
this.b = p.isFlying();
|
||||
this.c = p.c();
|
||||
this.d = p.d();
|
||||
try {
|
||||
e = fieldE.getFloat(p);
|
||||
this.f = fieldF.getFloat(p);
|
||||
} catch (IllegalAccessException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
private static Field fieldE;
|
||||
private static Field fieldF;
|
||||
|
||||
static {
|
||||
try {
|
||||
fieldE = PacketPlayInAbilities.class.getDeclaredField("e");fieldE.setAccessible(true);
|
||||
fieldF = PacketPlayInAbilities.class.getDeclaredField("f");fieldF.setAccessible(true);
|
||||
} catch (NoSuchFieldException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
+8
-7
@@ -1,21 +1,22 @@
|
||||
package me.purplex.packetevents.packetwrappers.in._1_9_4;
|
||||
|
||||
import me.purplex.packetevents.enums.PlayerDigType;
|
||||
import me.purplex.packetevents.packetwrappers.api.WrappedVersionPacket;
|
||||
import net.minecraft.server.v1_9_R2.PacketPlayInBlockDig;
|
||||
|
||||
public class WrappedPacketPlayInBlockDig_1_9_4 {
|
||||
private final Object packet;
|
||||
public class WrappedPacketPlayInBlockDig_1_9_4 extends WrappedVersionPacket {
|
||||
|
||||
public PlayerDigType digType;
|
||||
|
||||
public WrappedPacketPlayInBlockDig_1_9_4(Object packet) {
|
||||
this.packet = packet;
|
||||
setupDigType();
|
||||
super(packet);
|
||||
}
|
||||
|
||||
private void setupDigType() {
|
||||
@Override
|
||||
protected void setup() {
|
||||
PacketPlayInBlockDig p = (PacketPlayInBlockDig)packet;
|
||||
String name = p.c().name();
|
||||
this.digType = PlayerDigType.valueOf(name);
|
||||
}
|
||||
|
||||
public PlayerDigType digType;
|
||||
|
||||
}
|
||||
+33
-48
@@ -1,12 +1,11 @@
|
||||
package me.purplex.packetevents.packetwrappers.in._1_9_4;
|
||||
|
||||
import me.purplex.packetevents.packetwrappers.api.WrappedVersionPacket;
|
||||
import net.minecraft.server.v1_9_R2.PacketPlayInFlying;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
|
||||
public class WrappedPacketPlayInFlying_1_9_4 {
|
||||
private final Object packet;
|
||||
|
||||
public class WrappedPacketPlayInFlying_1_9_4 extends WrappedVersionPacket {
|
||||
public double x;
|
||||
public double y;
|
||||
public double z;
|
||||
@@ -15,38 +14,45 @@ public class WrappedPacketPlayInFlying_1_9_4 {
|
||||
public boolean f;
|
||||
public boolean hasPos;
|
||||
public boolean hasLook;
|
||||
|
||||
public WrappedPacketPlayInFlying_1_9_4(Object packet) {
|
||||
this.packet = packet;
|
||||
try {
|
||||
setupFields();
|
||||
} catch (IllegalAccessException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
super(packet);
|
||||
}
|
||||
|
||||
|
||||
|
||||
private void setupFields() throws IllegalAccessException {
|
||||
@Override
|
||||
protected void setup() {
|
||||
PacketPlayInFlying p = (PacketPlayInFlying) packet;
|
||||
this.hasPos = fieldHasPos.getBoolean(p);
|
||||
this.hasLook = fieldHasLook.getBoolean(p);
|
||||
try {
|
||||
this.hasPos = fieldHasPos.getBoolean(p);
|
||||
this.hasLook = fieldHasLook.getBoolean(p);
|
||||
} catch (IllegalAccessException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
if (hasPos) {
|
||||
this.x = p.a(0.0D);
|
||||
this.y = p.b(0.0D);
|
||||
this.z = p.c(0.0D);
|
||||
} else {
|
||||
this.x = fieldX.getDouble(p);
|
||||
this.y = fieldY.getDouble(p);
|
||||
this.z = fieldZ.getDouble(p);
|
||||
try {
|
||||
this.x = fieldX.getDouble(p);
|
||||
this.y = fieldY.getDouble(p);
|
||||
this.z = fieldZ.getDouble(p);
|
||||
} catch (IllegalAccessException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
if (hasLook) {
|
||||
this.yaw = p.a(0.0F);
|
||||
this.pitch = p.b(0.0F);
|
||||
}
|
||||
else {
|
||||
this.yaw = fieldYaw.getFloat(p);
|
||||
this.pitch = fieldPitch.getFloat(p);
|
||||
} else {
|
||||
try {
|
||||
this.yaw = fieldYaw.getFloat(p);
|
||||
this.pitch = fieldPitch.getFloat(p);
|
||||
} catch (IllegalAccessException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
this.f = p.a();
|
||||
}
|
||||
@@ -79,40 +85,19 @@ public class WrappedPacketPlayInFlying_1_9_4 {
|
||||
static {
|
||||
try {
|
||||
fieldHasPos = PacketPlayInFlying.class.getDeclaredField("hasPos");
|
||||
} catch (NoSuchFieldException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
try {
|
||||
fieldHasPos.setAccessible(true);
|
||||
fieldHasLook = PacketPlayInFlying.class.getDeclaredField("hasLook");
|
||||
} catch (NoSuchFieldException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
try {
|
||||
fieldHasLook.setAccessible(true);
|
||||
fieldX = PacketPlayInFlying.class.getDeclaredField("x");
|
||||
} catch (NoSuchFieldException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
try {
|
||||
fieldX.setAccessible(true);
|
||||
fieldY = PacketPlayInFlying.class.getDeclaredField("y");
|
||||
} catch (NoSuchFieldException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
try {
|
||||
fieldY.setAccessible(true);
|
||||
fieldZ = PacketPlayInFlying.class.getDeclaredField("z");
|
||||
} catch (NoSuchFieldException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
try {
|
||||
fieldZ.setAccessible(true);
|
||||
fieldYaw = PacketPlayInFlying.class.getDeclaredField("yaw");
|
||||
} catch (NoSuchFieldException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
try {
|
||||
fieldYaw.setAccessible(true);
|
||||
fieldPitch = PacketPlayInFlying.class.getDeclaredField("pitch");
|
||||
fieldPitch.setAccessible(true);
|
||||
} catch (NoSuchFieldException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
+22
-23
@@ -1,29 +1,22 @@
|
||||
package me.purplex.packetevents.packetwrappers.in._1_9_4;
|
||||
|
||||
import me.purplex.packetevents.enums.EntityUseAction;
|
||||
import me.purplex.packetevents.enums.ServerVersion;
|
||||
import me.purplex.packetevents.packetwrappers.api.WrappedVersionPacket;
|
||||
import net.minecraft.server.v1_9_R2.Entity;
|
||||
import net.minecraft.server.v1_9_R2.PacketPlayInUseEntity;
|
||||
import net.minecraft.server.v1_9_R2.WorldServer;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.craftbukkit.v1_9_R2.CraftWorld;
|
||||
|
||||
public class WrappedPacketPlayInUseEntity_1_9_4 {
|
||||
private final ServerVersion version;
|
||||
private Entity entity;
|
||||
public class WrappedPacketPlayInUseEntity_1_9_4 extends WrappedVersionPacket {
|
||||
private org.bukkit.entity.Entity entity;
|
||||
private EntityUseAction action;
|
||||
private final Object packet;
|
||||
|
||||
public WrappedPacketPlayInUseEntity_1_9_4(Object packet) {
|
||||
this.version = ServerVersion.getVersion();
|
||||
this.packet = packet;
|
||||
setupEntity();
|
||||
setupAction();
|
||||
super(packet);
|
||||
}
|
||||
|
||||
private Object getRawPacket() {
|
||||
return this.packet;
|
||||
}
|
||||
|
||||
public Entity getEntity() {
|
||||
public org.bukkit.entity.Entity getEntity() {
|
||||
return entity;
|
||||
}
|
||||
|
||||
@@ -31,24 +24,30 @@ public class WrappedPacketPlayInUseEntity_1_9_4 {
|
||||
return action;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setup() {
|
||||
setupEntity();
|
||||
setupAction();
|
||||
}
|
||||
|
||||
private void setupEntity() {
|
||||
net.minecraft.server.v1_9_R2.PacketPlayInUseEntity packet = (net.minecraft.server.v1_9_R2.PacketPlayInUseEntity) getRawPacket();
|
||||
net.minecraft.server.v1_9_R2.WorldServer worldServer = null;
|
||||
PacketPlayInUseEntity p = (PacketPlayInUseEntity) packet;
|
||||
WorldServer worldServer = null;
|
||||
for (World bukkitWorld : Bukkit.getWorlds()) {
|
||||
org.bukkit.craftbukkit.v1_9_R2.CraftWorld craftWorld = (org.bukkit.craftbukkit.v1_9_R2.CraftWorld) bukkitWorld;
|
||||
CraftWorld craftWorld = (CraftWorld) bukkitWorld;
|
||||
worldServer = craftWorld.getHandle();
|
||||
if (packet.a(worldServer) != null) {
|
||||
if (p.a(worldServer) != null) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
net.minecraft.server.v1_9_R2.Entity entity = packet.a(worldServer);
|
||||
Entity entity = p.a(worldServer);
|
||||
this.entity = entity.getBukkitEntity();
|
||||
|
||||
}
|
||||
|
||||
private void setupAction() {
|
||||
net.minecraft.server.v1_9_R2.PacketPlayInUseEntity packet = (net.minecraft.server.v1_9_R2.PacketPlayInUseEntity) getRawPacket();
|
||||
String name = packet.a().name();
|
||||
net.minecraft.server.v1_9_R2.PacketPlayInUseEntity p = (net.minecraft.server.v1_9_R2.PacketPlayInUseEntity) packet;
|
||||
String name = p.a().name();
|
||||
this.action = EntityUseAction.valueOf(name);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user