Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e142d95abc | ||
|
|
6ac93a97df | ||
|
|
7db7e44bfc | ||
|
|
4792bda57b | ||
|
|
cd009e7080 | ||
|
|
bcc967d72d | ||
|
|
913cbf94f4 | ||
|
|
1941d2c34d | ||
|
|
36140fb42b | ||
|
|
91e2668998 | ||
|
|
b6f625b498 | ||
|
|
0c176aabd2 | ||
|
|
39ec5958e1 | ||
|
|
6467fece64 | ||
|
|
c6a8d5ad84 | ||
|
|
42b1f2b1a9 | ||
|
|
208823466c | ||
|
|
0c67bfb999 | ||
|
|
d64e92d84a | ||
|
|
29ec5f6638 | ||
|
|
9d10d5001d | ||
|
|
834b29f84a | ||
|
|
7787ce9f33 | ||
|
|
4775e9f815 | ||
|
|
7764939208 | ||
|
|
9c331ef630 | ||
|
|
3c3261bd96 | ||
|
|
f71530a4ee | ||
|
|
c9e4f627c8 | ||
|
|
75a5ec6022 | ||
|
|
366490d7fc | ||
|
|
9f22bebd3b | ||
|
|
35b0e6ccd8 | ||
|
|
3073342482 | ||
|
|
e83086fd21 | ||
|
|
9c886d8abb | ||
|
|
36b574edda | ||
|
|
90e490466e | ||
|
|
2743dafc40 | ||
|
|
7443f3f965 | ||
|
|
5e493a386c | ||
|
|
321b306a34 | ||
|
|
08996c3e17 | ||
|
|
39fc28def6 | ||
|
|
c2b0109820 | ||
|
|
86dbca109b | ||
|
|
904a9c458d | ||
|
|
36431251c0 |
No files matched your search
@@ -1,17 +1,20 @@
|
||||
# packetevents by purplex
|
||||
Listen to minecraft packets.
|
||||
|
||||
PacketEvents coded by purplex.
|
||||
PacketListener coded by purplex.
|
||||
|
||||
Dependencies? Nah...
|
||||
|
||||
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 version is 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
|
||||
|
||||
@@ -24,7 +27,7 @@ allprojects {
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation 'com.github.purplexdev:packetevents:1.1.5'
|
||||
implementation 'com.github.purplexdev:packetevents:1.1.9'
|
||||
}
|
||||
```
|
||||
|
||||
@@ -43,7 +46,7 @@ dependencies {
|
||||
<dependency>
|
||||
<groupId>com.github.purplexdev</groupId>
|
||||
<artifactId>packetevents</artifactId>
|
||||
<version>1.1.5</version>
|
||||
<version>1.1.9</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
```
|
||||
@@ -53,16 +56,15 @@ dependencies {
|
||||
```
|
||||
resolvers += "jitpack" at "https://jitpack.io"
|
||||
|
||||
libraryDependencies += "com.github.purplexdev" % "packetevents" % "1.1.5"
|
||||
libraryDependencies += "com.github.purplexdev" % "packetevents" % "1.1.9"
|
||||
```
|
||||
|
||||
# leiningen
|
||||
```
|
||||
:repositories [["jitpack" "https://jitpack.io"]]
|
||||
|
||||
:dependencies [[com.github.purplexdev/packetevents "1.1.5"]]
|
||||
:dependencies [[com.github.purplexdev/packetevents "1.1.9"]]
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
|
||||
<groupId>me.purplex</groupId>
|
||||
<artifactId>packetevents</artifactId>
|
||||
<version>1.1.5</version>
|
||||
<version>1.2.5</version>
|
||||
<packaging>jar</packaging>
|
||||
<name>packetevents</name>
|
||||
<properties>
|
||||
@@ -56,7 +56,6 @@
|
||||
<id>funkemunky-releases</id>
|
||||
<url>https://nexus.funkemunky.cc/content/repositories/releases/</url>
|
||||
</repository>
|
||||
|
||||
</repositories>
|
||||
|
||||
|
||||
@@ -181,13 +180,5 @@
|
||||
<version>1.14</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<!--Bukkit-->
|
||||
<dependency>
|
||||
<groupId>org.spigotmc</groupId>
|
||||
<artifactId>spigot-api</artifactId>
|
||||
<version>1.8-R0.1-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
@@ -1,64 +0,0 @@
|
||||
package me.purplex.packetevents;
|
||||
|
||||
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.event.*;
|
||||
import org.bukkit.event.player.PlayerJoinEvent;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
public class Main extends JavaPlugin implements Listener {
|
||||
|
||||
private static Main instance;
|
||||
private static PacketInjector packetInjector;
|
||||
|
||||
@Override
|
||||
public void onEnable() {
|
||||
instance = this;
|
||||
Bukkit.getPluginManager().registerEvents(this, this);
|
||||
packetInjector = new PacketInjector();
|
||||
PacketEvents.getPacketManager().registerListener(new TestExample());
|
||||
|
||||
Bukkit.getScheduler().scheduleAsyncRepeatingTask(this, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
long now = System.currentTimeMillis();
|
||||
PacketEvents.getPacketManager().callEvent(new ServerTickEvent(now));
|
||||
}
|
||||
}, 0L, 1L);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDisable() {
|
||||
/**
|
||||
* You don't need to unregister all events when the server shutsdown,
|
||||
* This is just an example
|
||||
*/
|
||||
|
||||
//PacketEvents.getPacketManager().unregisterListener(new TestExample());
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onJoin(PlayerJoinEvent e) {
|
||||
Bukkit.getScheduler().runTaskAsynchronously(this, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
packetInjector.injectPlayer(e.getPlayer());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onQuit(PlayerQuitEvent e) {
|
||||
packetInjector.uninjectPlayer(e.getPlayer());
|
||||
}
|
||||
|
||||
public static Main getInstance() {
|
||||
return instance;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -1,20 +1,113 @@
|
||||
package me.purplex.packetevents;
|
||||
|
||||
import me.purplex.packetevents.enums.ServerVersion;
|
||||
import me.purplex.packetevents.packetmanager.PacketManager;
|
||||
import me.purplex.packetevents.event.impl.ServerTickEvent;
|
||||
import me.purplex.packetevents.event.manager.EventManager;
|
||||
import me.purplex.packetevents.injector.PacketInjector; //public packet injector
|
||||
import me.purplex.packetevents.utils.TPSUtils; //tps utils
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.PlayerJoinEvent;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
import org.bukkit.scheduler.BukkitTask;
|
||||
|
||||
public class PacketEvents {
|
||||
private static PacketManager packetManager;
|
||||
import java.util.concurrent.*;
|
||||
|
||||
public class PacketEvents implements Listener {
|
||||
private static final ServerVersion version = ServerVersion.getVersion();
|
||||
private static PacketEvents instance;
|
||||
private static final PacketInjector packetInjector = new PacketInjector();
|
||||
public static ExecutorService executor = Executors.newCachedThreadPool();
|
||||
private static final EventManager eventManager = new EventManager();
|
||||
|
||||
private static int currentTick;
|
||||
|
||||
private static BukkitTask serverTickTask;
|
||||
|
||||
public static JavaPlugin plugin;
|
||||
|
||||
public static EventManager getEventManager() {
|
||||
return eventManager;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public static void setup(final JavaPlugin plugin, final boolean serverTickEventEnabled) {
|
||||
PacketEvents.plugin = plugin;
|
||||
Bukkit.getPluginManager().registerEvents(getInstance(), plugin);
|
||||
|
||||
if (serverTickEventEnabled) {
|
||||
final Runnable runnable = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
PacketEvents.getEventManager().callEvent(new ServerTickEvent(currentTick++, PacketEvents.currentTimeMS()));
|
||||
}
|
||||
};
|
||||
serverTickTask = Bukkit.getScheduler().runTaskTimerAsynchronously(plugin, runnable, 0L, 1L);
|
||||
}
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public static void cleanup() {
|
||||
if (serverTickTask != null) {
|
||||
serverTickTask.cancel();
|
||||
}
|
||||
getEventManager().unregisterAllListeners();
|
||||
}
|
||||
|
||||
|
||||
@EventHandler
|
||||
public void onJoin(PlayerJoinEvent e) {
|
||||
if (executor == null) {
|
||||
executor = Executors.newCachedThreadPool();
|
||||
packetInjector.injectPlayer(e.getPlayer());
|
||||
System.out.println("Failed to inject " + e.getPlayer().getName() + " asynchronously!");
|
||||
}
|
||||
|
||||
final Runnable runnable = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
packetInjector.injectPlayer(e.getPlayer());
|
||||
}
|
||||
};
|
||||
Future<?> future = executor.submit(runnable);
|
||||
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onQuit(PlayerQuitEvent e) {
|
||||
packetInjector.uninjectPlayer(e.getPlayer());
|
||||
}
|
||||
|
||||
public static ServerVersion getServerVersion() {
|
||||
return ServerVersion.getVersion();
|
||||
return version;
|
||||
}
|
||||
|
||||
public static PacketEvents getInstance() {
|
||||
return instance == null ? instance = new PacketEvents() : instance;
|
||||
}
|
||||
|
||||
public static PacketManager getPacketManager() {
|
||||
if (packetManager == null) {
|
||||
packetManager = new PacketManager();
|
||||
public static boolean isServerTickTaskEnabled() {
|
||||
return serverTickTask != null;
|
||||
}
|
||||
|
||||
public static double[] getRecentServerTPS() {
|
||||
final double[] tpsArray = TPSUtils.getRecentTPS();
|
||||
final int size = tpsArray.length;
|
||||
for (int i = 0; i < size; i++) {
|
||||
if (tpsArray[i] > 20.0) {
|
||||
tpsArray[i] = 20.0;
|
||||
}
|
||||
}
|
||||
return packetManager;
|
||||
return tpsArray;
|
||||
}
|
||||
|
||||
public static double getCurrentServerTPS() {
|
||||
return getRecentServerTPS()[0];
|
||||
}
|
||||
|
||||
public static long currentTimeMS() {
|
||||
return System.nanoTime() / 1000000;
|
||||
}
|
||||
}
|
||||
@@ -1,99 +0,0 @@
|
||||
package me.purplex.packetevents.customlistener.injector;
|
||||
|
||||
|
||||
import io.netty.channel.*;
|
||||
import me.purplex.packetevents.PacketEvents;
|
||||
import me.purplex.packetevents.enums.ServerVersion;
|
||||
import me.purplex.packetevents.events.packetevent.*;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
|
||||
public class PacketInjector {
|
||||
private final static ServerVersion version = ServerVersion.getVersion();
|
||||
|
||||
public void injectPlayer(Player player) {
|
||||
ChannelDuplexHandler channelDuplexHandler = new ChannelDuplexHandler() {
|
||||
@Override
|
||||
public void channelRead(ChannelHandlerContext ctx, Object packet) throws Exception {
|
||||
String packetName = packet.getClass().getSimpleName();
|
||||
PacketReceiveEvent e = new PacketReceiveEvent(player, packetName, packet);
|
||||
PacketEvents.getPacketManager().callEvent(e);
|
||||
if (e.isCancelled()) {
|
||||
return;
|
||||
}
|
||||
super.channelRead(ctx, packet);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(ChannelHandlerContext ctx, Object packet, ChannelPromise promise) throws Exception {
|
||||
String packetName = packet.getClass().getSimpleName();
|
||||
PacketSendEvent e = new PacketSendEvent(player, packetName, packet);
|
||||
PacketEvents.getPacketManager().callEvent(e);
|
||||
if (e.isCancelled()) {
|
||||
return;
|
||||
}
|
||||
super.write(ctx, packet, promise);
|
||||
}
|
||||
};
|
||||
Channel channel = getChannel(player);
|
||||
ChannelPipeline pipeline = channel.pipeline();
|
||||
pipeline.addBefore("packet_handler", player.getName(), channelDuplexHandler);
|
||||
}
|
||||
|
||||
public void uninjectPlayer(Player player) {
|
||||
Channel channel = getChannel(player);
|
||||
channel.eventLoop().submit(() -> {
|
||||
channel.pipeline().remove(player.getName());
|
||||
return null;
|
||||
});
|
||||
}
|
||||
|
||||
public Channel getChannel(Player player) {
|
||||
Channel channel = null;
|
||||
if (version == ServerVersion.v_1_8) {
|
||||
net.minecraft.server.v1_8_R1.NetworkManager networkManager = ((org.bukkit.craftbukkit.v1_8_R1.entity.CraftPlayer) player).getHandle().playerConnection.networkManager;
|
||||
try {
|
||||
channel = (Channel) networkManager.getClass().getField("i").get(networkManager);
|
||||
} catch (IllegalAccessException | NoSuchFieldException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
} else if (version == ServerVersion.v_1_8_3) {
|
||||
net.minecraft.server.v1_8_R2.NetworkManager networkManager = ((org.bukkit.craftbukkit.v1_8_R2.entity.CraftPlayer) player).getHandle().playerConnection.networkManager;
|
||||
channel = networkManager.k;
|
||||
} else if (version == ServerVersion.v_1_8_8) {
|
||||
net.minecraft.server.v1_8_R3.NetworkManager networkManager = ((org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer) player).getHandle().playerConnection.networkManager;
|
||||
channel = networkManager.channel;
|
||||
} else if (version == ServerVersion.v_1_9) {
|
||||
net.minecraft.server.v1_9_R1.NetworkManager networkManager = ((org.bukkit.craftbukkit.v1_9_R1.entity.CraftPlayer) player).getHandle().playerConnection.networkManager;
|
||||
channel = networkManager.channel;
|
||||
} else if (version == ServerVersion.v_1_9_4) {
|
||||
net.minecraft.server.v1_9_R2.NetworkManager networkManager = ((org.bukkit.craftbukkit.v1_9_R2.entity.CraftPlayer) player).getHandle().playerConnection.networkManager;
|
||||
channel = networkManager.channel;
|
||||
} else if (version == ServerVersion.v_1_10) {
|
||||
net.minecraft.server.v1_10_R1.NetworkManager networkManager = ((org.bukkit.craftbukkit.v1_10_R1.entity.CraftPlayer) player).getHandle().playerConnection.networkManager;
|
||||
channel = networkManager.channel;
|
||||
} else if (version == ServerVersion.v_1_11) {
|
||||
net.minecraft.server.v1_11_R1.NetworkManager networkManager = ((org.bukkit.craftbukkit.v1_11_R1.entity.CraftPlayer) player).getHandle().playerConnection.networkManager;
|
||||
channel = networkManager.channel;
|
||||
} else if (version == ServerVersion.v_1_12) {
|
||||
net.minecraft.server.v1_12_R1.NetworkManager networkManager = ((org.bukkit.craftbukkit.v1_12_R1.entity.CraftPlayer) player).getHandle().playerConnection.networkManager;
|
||||
channel = networkManager.channel;
|
||||
} else if (version == ServerVersion.v_1_13) {
|
||||
net.minecraft.server.v1_13_R1.NetworkManager networkManager = ((org.bukkit.craftbukkit.v1_13_R1.entity.CraftPlayer) player).getHandle().playerConnection.networkManager;
|
||||
channel = networkManager.channel;
|
||||
} else if (version == ServerVersion.v_1_13_2) {
|
||||
net.minecraft.server.v1_13_R2.NetworkManager networkManager = ((org.bukkit.craftbukkit.v1_13_R2.entity.CraftPlayer) player).getHandle().playerConnection.networkManager;
|
||||
channel = networkManager.channel;
|
||||
} else if (version == ServerVersion.v_1_14) {
|
||||
net.minecraft.server.v1_14_R1.NetworkManager networkManager = ((org.bukkit.craftbukkit.v1_14_R1.entity.CraftPlayer) player).getHandle().playerConnection.networkManager;
|
||||
channel = networkManager.channel;
|
||||
} else if (version == ServerVersion.v_1_15) {
|
||||
net.minecraft.server.v1_15_R1.NetworkManager networkManager = ((org.bukkit.craftbukkit.v1_15_R1.entity.CraftPlayer) player).getHandle().playerConnection.networkManager;
|
||||
channel = networkManager.channel;
|
||||
} else {
|
||||
System.err.println("Version unsupported, please contact purplex#0001 and tell him what version your server is running on! Make sure you are using paperspigot or spigot.");
|
||||
}
|
||||
return channel;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
package me.purplex.packetevents.enums;
|
||||
|
||||
public enum Direction {
|
||||
DOWN, UP, NORTH, SOUTH, WEST, EAST;
|
||||
|
||||
public static Direction get(final byte i) {
|
||||
return values()[i];
|
||||
}
|
||||
}
|
||||
@@ -2,4 +2,8 @@ package me.purplex.packetevents.enums;
|
||||
|
||||
public enum EntityUseAction {
|
||||
INTERACT, INTERACT_AT, ATTACK, INVALID;
|
||||
|
||||
public static EntityUseAction get(final byte i) {
|
||||
return values()[i];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
package me.purplex.packetevents.enums;
|
||||
|
||||
public enum Hand {
|
||||
MAIN_HAND,
|
||||
OFF_HAND;
|
||||
}
|
||||
@@ -18,4 +18,8 @@ public enum PlayerAction {
|
||||
OPEN_INVENTORY,
|
||||
|
||||
START_FALL_FLYING;
|
||||
|
||||
public static PlayerAction get(final byte i) {
|
||||
return values()[i];
|
||||
}
|
||||
}
|
||||
@@ -18,6 +18,7 @@ public enum PlayerDigType {
|
||||
|
||||
WRONG_PACKET;
|
||||
|
||||
|
||||
|
||||
public static PlayerDigType get(final byte i) {
|
||||
return values()[i];
|
||||
}
|
||||
}
|
||||
@@ -4,21 +4,68 @@ import org.apache.commons.lang.ArrayUtils;
|
||||
import org.bukkit.Bukkit;
|
||||
|
||||
|
||||
public enum ServerVersion
|
||||
{
|
||||
public enum ServerVersion {
|
||||
v_1_7_10, v_1_8, v_1_8_3, v_1_8_8, v_1_9, v_1_9_4, v_1_10, v_1_11, v_1_12, v_1_13, v_1_13_2, v_1_14, v_1_15,
|
||||
ERROR;
|
||||
|
||||
|
||||
public static ServerVersion getVersion() {
|
||||
ServerVersion[] vals = values();
|
||||
ArrayUtils.reverse(vals);
|
||||
for(ServerVersion val : vals) {
|
||||
for (ServerVersion val : vals) {
|
||||
String valName = val.name().substring(2).replace("_", ".");
|
||||
if(Bukkit.getBukkitVersion().contains(valName)) {
|
||||
if (Bukkit.getBukkitVersion().contains(valName)) {
|
||||
return val;
|
||||
}
|
||||
}
|
||||
return ERROR;
|
||||
}
|
||||
|
||||
private static final String nmsVersionSuffix = Bukkit.getServer().getClass().getPackage().getName().replace(".", ",").split(",")[3];
|
||||
|
||||
public static String getNmsSuffix() {
|
||||
return nmsVersionSuffix;
|
||||
}
|
||||
|
||||
public static String getNMSDirectory() {
|
||||
return "net.minecraft.server." + nmsVersionSuffix;
|
||||
}
|
||||
|
||||
public static String getOBCDirectory() {
|
||||
return "org.bukkit.craftbukkit." + getNmsSuffix();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns if the current version is more up to date than the argument passed version
|
||||
*
|
||||
* @param version
|
||||
* @return
|
||||
*/
|
||||
public boolean isHigherThan(final ServerVersion version) {
|
||||
if (this == version) return false;
|
||||
return !isLowerThan(version);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns if the current version is more outdated than the argument passed version
|
||||
*
|
||||
* @param version
|
||||
* @return
|
||||
*/
|
||||
public boolean isLowerThan(final ServerVersion version) {
|
||||
if(version == this) return false;
|
||||
byte len = (byte) values().length;
|
||||
for (byte i = 0; i < len; i++) {
|
||||
final ServerVersion v = values()[i];
|
||||
if(v == this) {
|
||||
return true;
|
||||
}
|
||||
else if(v == version) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
package me.purplex.packetevents.event;
|
||||
|
||||
|
||||
import me.purplex.packetevents.PacketEvents;
|
||||
import me.purplex.packetevents.enums.ServerVersion;
|
||||
|
||||
/**
|
||||
* Incoming and sent packets are called asynchronously,
|
||||
* recommended to avoid non thread safe bukkit operations
|
||||
*/
|
||||
public class PacketEvent {
|
||||
protected long timestamp = PacketEvents.currentTimeMS();
|
||||
protected static ServerVersion version = PacketEvents.getServerVersion();
|
||||
|
||||
/**
|
||||
* Timestamp of the packet
|
||||
* @return
|
||||
*/
|
||||
public long getTimestamp() {
|
||||
return timestamp;
|
||||
}
|
||||
}
|
||||
+5
-1
@@ -1,4 +1,4 @@
|
||||
package me.purplex.packetevents.events.handler;
|
||||
package me.purplex.packetevents.event.handler;
|
||||
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
@@ -7,6 +7,10 @@ import java.lang.annotation.Target;
|
||||
|
||||
@Target(ElementType.METHOD)
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
/**
|
||||
* Just like Bukkit's @EventHandler, but for packets.
|
||||
* Make sure your class implements the PacketListener interface, and is registered!
|
||||
*/
|
||||
public @interface PacketHandler {
|
||||
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
package me.purplex.packetevents.event.impl;
|
||||
|
||||
import me.purplex.packetevents.event.PacketEvent;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class PacketLoginEvent extends PacketEvent {
|
||||
private final Player player;
|
||||
private final String name;
|
||||
private final Object packet;
|
||||
public PacketLoginEvent(final Player player, final String packetName, final Object packet) {
|
||||
this.player = player;
|
||||
this.name = packetName;
|
||||
this.packet = packet;
|
||||
}
|
||||
|
||||
public Player getPlayer() {
|
||||
return player;
|
||||
}
|
||||
|
||||
public String getPacketName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public Object getPacket() {
|
||||
return packet;
|
||||
}
|
||||
}
|
||||
+3
-20
@@ -1,26 +1,18 @@
|
||||
package me.purplex.packetevents.events.packetevent;
|
||||
package me.purplex.packetevents.event.impl;
|
||||
|
||||
|
||||
import me.purplex.packetevents.PacketEvents;
|
||||
import me.purplex.packetevents.enums.ServerVersion;
|
||||
import me.purplex.packetevents.events.PacketEvent;
|
||||
import me.purplex.packetevents.event.PacketEvent;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
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();
|
||||
public PacketReceiveEvent(final Player player, final String packetName, final Object packet) {
|
||||
this.player = player;
|
||||
this.name = packetName;
|
||||
this.packet = packet;
|
||||
this.timestamp = (System.nanoTime() / 1000000);
|
||||
this.cancelled = false;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -50,15 +42,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
|
||||
*
|
||||
+3
-15
@@ -1,24 +1,18 @@
|
||||
package me.purplex.packetevents.events.packetevent;
|
||||
package me.purplex.packetevents.event.impl;
|
||||
|
||||
import me.purplex.packetevents.PacketEvents;
|
||||
import me.purplex.packetevents.enums.ServerVersion;
|
||||
import me.purplex.packetevents.events.PacketEvent;
|
||||
import me.purplex.packetevents.event.PacketEvent;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
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();
|
||||
public PacketSendEvent(final Player player, final String packetName, final Object packet) {
|
||||
this.player = player;
|
||||
this.name = packetName;
|
||||
this.packet = packet;
|
||||
this.timestamp = (System.nanoTime() / 1000000);
|
||||
this.cancelled = false;
|
||||
}
|
||||
|
||||
@@ -41,12 +35,6 @@ public class PacketSendEvent extends PacketEvent {
|
||||
}
|
||||
|
||||
|
||||
|
||||
public long getTimestamp() {
|
||||
return timestamp;
|
||||
}
|
||||
|
||||
|
||||
public void setCancelled(boolean cancelled) {
|
||||
this.cancelled = cancelled;
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package me.purplex.packetevents.event.impl;
|
||||
|
||||
import me.purplex.packetevents.event.PacketEvent;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class PlayerInjectEvent extends PacketEvent {
|
||||
private final Player player;
|
||||
public PlayerInjectEvent(final Player player) {
|
||||
this.player = player;
|
||||
}
|
||||
|
||||
public Player getPlayer() {
|
||||
return player;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package me.purplex.packetevents.event.impl;
|
||||
|
||||
import me.purplex.packetevents.event.PacketEvent;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class PlayerUninjectEvent extends PacketEvent {
|
||||
private final Player player;
|
||||
|
||||
public PlayerUninjectEvent(final Player player) {
|
||||
this.player = player;
|
||||
}
|
||||
|
||||
public Player getPlayer() {
|
||||
return player;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
package me.purplex.packetevents.event.impl;
|
||||
|
||||
//unfinished
|
||||
public class ServerReloadEvent {
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
package me.purplex.packetevents.event.impl;
|
||||
|
||||
import me.purplex.packetevents.PacketEvents;
|
||||
import me.purplex.packetevents.event.PacketEvent;
|
||||
|
||||
public class ServerTickEvent extends PacketEvent {
|
||||
private final int tick;
|
||||
private final double tps;
|
||||
public ServerTickEvent(final int tick, final long timestamp) {
|
||||
this.tick = tick;
|
||||
this.timestamp = timestamp;
|
||||
this.tps = PacketEvents.getCurrentServerTPS();
|
||||
}
|
||||
|
||||
public ServerTickEvent(final int tick) {
|
||||
this.tick = tick;
|
||||
this.tps = PacketEvents.getCurrentServerTPS();
|
||||
}
|
||||
|
||||
|
||||
public long getTimestamp() {
|
||||
return timestamp;
|
||||
}
|
||||
|
||||
public int getCurrentTick() {
|
||||
return tick;
|
||||
}
|
||||
|
||||
public double getCurrentServerTPS() {
|
||||
return tps;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
package me.purplex.packetevents.event.listener;
|
||||
|
||||
public interface PacketListener {
|
||||
}
|
||||
@@ -0,0 +1,68 @@
|
||||
package me.purplex.packetevents.event.manager;
|
||||
|
||||
import me.purplex.packetevents.event.PacketEvent;
|
||||
import me.purplex.packetevents.event.handler.PacketHandler;
|
||||
import me.purplex.packetevents.event.listener.PacketListener;
|
||||
|
||||
import java.lang.reflect.*;
|
||||
|
||||
public class EventManager implements PacketEventManager {
|
||||
|
||||
@Override
|
||||
public void callEvent(final PacketEvent e) {
|
||||
for (final PacketListener listener : this.packetListeners) {
|
||||
boolean calledOnPacket = false;
|
||||
//Annotated methods
|
||||
final Method[] methods = listener.getClass().getMethods();
|
||||
for (int i = 0; i < methods.length; i++) {
|
||||
final Method m = methods[i];
|
||||
if (m.isAnnotationPresent(PacketHandler.class)) {
|
||||
if (!calledOnPacket && m.getParameterTypes()[0].equals(PacketEvent.class)) {
|
||||
try {
|
||||
m.invoke(listener, e);
|
||||
} catch (IllegalAccessException ex) {
|
||||
ex.printStackTrace();
|
||||
} catch (InvocationTargetException ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
calledOnPacket = true;
|
||||
} else if (m.getParameterTypes()[0].getSimpleName().equals(e.getClass().getSimpleName())) {
|
||||
try {
|
||||
m.invoke(listener, e);
|
||||
} catch (IllegalAccessException ex) {
|
||||
ex.printStackTrace();
|
||||
} catch (InvocationTargetException ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void registerListener(final PacketListener e) {
|
||||
this.packetListeners.add(e);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean unregisterListener(final PacketListener e) {
|
||||
return this.packetListeners.remove(e);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean unregisterAllListeners() {
|
||||
if (this.packetListeners.size() != 0) {
|
||||
this.packetListeners.clear();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/*@Override
|
||||
public void sendPacket(Player player, WrappedPacket packet) {
|
||||
|
||||
}*/
|
||||
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
package me.purplex.packetevents.event.manager;
|
||||
|
||||
import me.purplex.packetevents.event.PacketEvent;
|
||||
import me.purplex.packetevents.event.listener.PacketListener;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedList;
|
||||
|
||||
public interface PacketEventManager {
|
||||
public ArrayList<PacketListener> packetListeners = new ArrayList<>();
|
||||
public void callEvent(PacketEvent e);
|
||||
|
||||
public void registerListener(PacketListener e);
|
||||
public boolean unregisterListener(PacketListener e);
|
||||
|
||||
public boolean unregisterAllListeners();
|
||||
|
||||
//public void sendPacket(Player player, WrappedPacket packet);
|
||||
|
||||
}
|
||||
@@ -1,22 +0,0 @@
|
||||
package me.purplex.packetevents.eventmanager;
|
||||
|
||||
import me.purplex.packetevents.events.PacketEvent;
|
||||
import me.purplex.packetevents.events.packetevent.ServerTickEvent;
|
||||
import me.purplex.packetevents.events.listener.PacketListener;
|
||||
import me.purplex.packetevents.events.packetevent.PacketReceiveEvent;
|
||||
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);
|
||||
|
||||
public void registerListener(PacketListener e);
|
||||
public void unregisterListener(PacketListener e);
|
||||
|
||||
public void unregisterAllListeners(PacketListener e);
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -1,6 +0,0 @@
|
||||
package me.purplex.packetevents.events;
|
||||
|
||||
|
||||
public class PacketEvent {
|
||||
|
||||
}
|
||||
@@ -1,4 +0,0 @@
|
||||
package me.purplex.packetevents.events.listener;
|
||||
|
||||
public interface PacketListener {
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
package me.purplex.packetevents.events.packetevent;
|
||||
|
||||
import me.purplex.packetevents.events.PacketEvent;
|
||||
|
||||
|
||||
public class ServerTickEvent extends PacketEvent {
|
||||
|
||||
private long timestamp;
|
||||
public ServerTickEvent(long timestamp) {
|
||||
this.timestamp = timestamp;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public long getTimestamp() {
|
||||
return timestamp;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
package me.purplex.packetevents.example;
|
||||
|
||||
import me.purplex.packetevents.PacketEvents;
|
||||
import me.purplex.packetevents.event.PacketEvent;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
/**
|
||||
* Example packetevent
|
||||
* Make sure to initiate the super timestamp variable,
|
||||
* if you want to use the getTimestamp() function
|
||||
*/
|
||||
public class CustomMoveEvent extends PacketEvent {
|
||||
private final Player player;
|
||||
private Location to, from;
|
||||
private boolean cancelled;
|
||||
|
||||
public CustomMoveEvent(final Player player, final Location to, final Location from) {
|
||||
this.player = player;
|
||||
this.to = to;
|
||||
this.from = from;
|
||||
this.cancelled = false;
|
||||
//Timestamp is initialized automatically, so you don't need to initiate it, but you may modify it
|
||||
//this.timestamp = PacketEvents.currentTimeMS();
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getTimestamp() {
|
||||
return super.getTimestamp();
|
||||
}
|
||||
|
||||
public void setCancelled(boolean cancelled) {
|
||||
this.cancelled = cancelled;
|
||||
}
|
||||
|
||||
public boolean isCancelled() {
|
||||
return this.cancelled;
|
||||
}
|
||||
|
||||
public Player getPlayer() {
|
||||
return player;
|
||||
}
|
||||
|
||||
public Location getTo() {
|
||||
return to;
|
||||
}
|
||||
|
||||
public Location getFrom() {
|
||||
return from;
|
||||
}
|
||||
|
||||
public void setTo(Location loc) {
|
||||
this.to = loc;
|
||||
}
|
||||
|
||||
public void setFrom(Location loc) {
|
||||
this.from = from;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
package me.purplex.packetevents.example;
|
||||
|
||||
import me.purplex.packetevents.PacketEvents;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
public class MainExample extends JavaPlugin {
|
||||
@Override
|
||||
public void onEnable() {
|
||||
|
||||
//Should the ServerTickEvent ever get called?
|
||||
final boolean serverTickEventEnabled = true;
|
||||
|
||||
/**
|
||||
* Starts the servertickevent repeating task (if enabled)
|
||||
* and registers onJoin and onQuit events to inject and uninject players.
|
||||
* The first argument is an instance to your Main Class,
|
||||
* The second argument is a boolean whether the servertickevent should ever get called
|
||||
*/
|
||||
PacketEvents.setup(this, serverTickEventEnabled);
|
||||
|
||||
|
||||
/**
|
||||
* Register TestExample's PacketListener
|
||||
*/
|
||||
PacketEvents.getEventManager().registerListener(new RegisteredListener());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDisable() {
|
||||
/**
|
||||
* Stops server tick event task if enabled and unregister all listeners
|
||||
*/
|
||||
PacketEvents.cleanup();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,182 @@
|
||||
package me.purplex.packetevents.example;
|
||||
import me.purplex.packetevents.PacketEvents;
|
||||
import me.purplex.packetevents.enums.Direction;
|
||||
import me.purplex.packetevents.enums.EntityUseAction;
|
||||
import me.purplex.packetevents.enums.Hand;
|
||||
import me.purplex.packetevents.enums.PlayerDigType;
|
||||
import me.purplex.packetevents.event.PacketEvent;
|
||||
import me.purplex.packetevents.event.impl.*;
|
||||
import me.purplex.packetevents.event.handler.PacketHandler;
|
||||
import me.purplex.packetevents.event.listener.PacketListener;
|
||||
import me.purplex.packetevents.packet.Packet;
|
||||
import me.purplex.packetevents.packetwrappers.in.abilities.WrappedPacketInAbilities;
|
||||
import me.purplex.packetevents.packetwrappers.in.blockdig.WrappedPacketInBlockDig;
|
||||
import me.purplex.packetevents.packetwrappers.in.chat.WrappedPacketInChat;
|
||||
import me.purplex.packetevents.packetwrappers.in.flying.WrappedPacketInFlying;
|
||||
import me.purplex.packetevents.packetwrappers.in.use_entity.WrappedPacketInUseEntity;
|
||||
import me.purplex.packetevents.packetwrappers.login.handshake.WrappedPacketLoginHandshake;
|
||||
import me.purplex.packetevents.utils.playerprotocolversion.PlayerVersionManager;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.PlayerMoveEvent;
|
||||
|
||||
/**
|
||||
* Implementing PacketListener to listen to packets and packetevents' custom events,
|
||||
* Implementing org.bukkit.event.Listener to listen to bukkit's events
|
||||
*/
|
||||
public class RegisteredListener implements PacketListener, Listener {
|
||||
|
||||
|
||||
/**
|
||||
* Listen to PacketReceiveEvent
|
||||
*
|
||||
* @param e PacketReceiveEvent
|
||||
*/
|
||||
@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:
|
||||
final WrappedPacketInUseEntity useEntity = new WrappedPacketInUseEntity(e.getPacket());
|
||||
final Entity entity = useEntity.getEntity();
|
||||
final double distance = entity.getLocation().distanceSquared(p.getLocation());
|
||||
final Hand hand = useEntity.getHand();
|
||||
final EntityUseAction action = useEntity.getAction();
|
||||
break;
|
||||
case Packet.Client.ABILITIES:
|
||||
final WrappedPacketInAbilities abilities = new WrappedPacketInAbilities(e.getPacket());
|
||||
final boolean isVulnerable = abilities.isVulnerable();
|
||||
final boolean isFlying = abilities.isFlying();
|
||||
final boolean canFly = abilities.canFly();
|
||||
final boolean canInstantlyBuild = abilities.canInstantlyBuild();
|
||||
final float flySpeed = abilities.getFlySpeed();
|
||||
final float walkSpeed = abilities.getWalkSpeed();
|
||||
// e.getPlayer().sendMessage("walkspeed: " + walkSpeed + ", flyspeed: " + flySpeed + ", canFly: " + canFly);
|
||||
break;
|
||||
case Packet.Client.BLOCK_DIG:
|
||||
//Custom PlayerDigType enum
|
||||
final WrappedPacketInBlockDig blockDig = new WrappedPacketInBlockDig(e.getPacket());
|
||||
final PlayerDigType type = blockDig.getDigType();
|
||||
final Direction direction = blockDig.getDirection();
|
||||
|
||||
break;
|
||||
case Packet.Client.FLYING:
|
||||
final WrappedPacketInFlying flying = new WrappedPacketInFlying(e.getPacket());
|
||||
final float pitch = flying.getPitch();
|
||||
final float yaw = flying.getYaw();
|
||||
break;
|
||||
case Packet.Client.POSITION:
|
||||
final WrappedPacketInFlying.WrappedPacketInPosition position =
|
||||
new WrappedPacketInFlying.WrappedPacketInPosition(e.getPacket());
|
||||
final boolean isPos = position.isPosition(); //true
|
||||
break;
|
||||
case Packet.Client.POSITION_LOOK:
|
||||
final WrappedPacketInFlying.WrappedPacketInPosition_Look position_look =
|
||||
new WrappedPacketInFlying.WrappedPacketInPosition_Look(e.getPacket());
|
||||
final boolean isLook = position_look.isLook(); //true
|
||||
break;
|
||||
case Packet.Client.CHAT:
|
||||
final WrappedPacketInChat chat = new WrappedPacketInChat(e.getPacket());
|
||||
final String message = chat.getMessage();
|
||||
//e.getPlayer().sendMessage(message);
|
||||
break;
|
||||
//System.out.println("YOU SAID: " + message);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@PacketHandler
|
||||
public void onPacketSend(PacketSendEvent e) {
|
||||
|
||||
}
|
||||
|
||||
@PacketHandler
|
||||
public void onCustomMove(CustomMoveEvent e) {
|
||||
double distance = e.getTo().distanceSquared(e.getFrom());
|
||||
}
|
||||
|
||||
@PacketHandler
|
||||
public void onInject(PlayerInjectEvent event) {
|
||||
//event.getPlayer().sendMessage("injected");
|
||||
|
||||
|
||||
//event.setCancelled(true) is possible
|
||||
}
|
||||
|
||||
@PacketHandler
|
||||
public void onUninject(PlayerUninjectEvent e) {
|
||||
//e.setCancelled(true); will
|
||||
}
|
||||
|
||||
/**
|
||||
* Another way to listen to packets
|
||||
*
|
||||
* @param e PacketEvent
|
||||
*/
|
||||
@PacketHandler
|
||||
public void onPacket(PacketEvent e) {
|
||||
if (e instanceof PacketSendEvent) {
|
||||
final PacketSendEvent p = (PacketSendEvent) e;
|
||||
final Player targetPlayer = p.getPlayer();
|
||||
final Object rawNMSPacket = p.getPacket();
|
||||
final long timestamp = p.getTimestamp();
|
||||
} else if (e instanceof CustomMoveEvent) {
|
||||
final CustomMoveEvent event = (CustomMoveEvent) e;
|
||||
final Player player = event.getPlayer();
|
||||
final Location to = event.getTo();
|
||||
final Location from = event.getFrom();
|
||||
} else if (e instanceof ServerTickEvent) {
|
||||
final ServerTickEvent event = (ServerTickEvent) e;
|
||||
final int currentTick = event.getCurrentTick();
|
||||
// System.out.println(PacketEvents.getCurrentServerTPS() + " is tps");
|
||||
} else if (e instanceof PacketLoginEvent) {
|
||||
//System.out.println("LLLOOOOOGIN");
|
||||
final PacketLoginEvent event = (PacketLoginEvent) e;
|
||||
if (event.getPacketName().equals(Packet.Login.HANDSHAKE)) {
|
||||
final WrappedPacketLoginHandshake handshake = new WrappedPacketLoginHandshake(event.getPacket());
|
||||
final String hostname = handshake.hostname;
|
||||
final int port = handshake.port;
|
||||
final int protocolVersion = handshake.protocolVersion;
|
||||
PlayerVersionManager.setPlayerProtocolVersion(event.getPlayer().getUniqueId(), protocolVersion);
|
||||
// System.out.println("PROTOCOL NUMBER: " + protocolVersion);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Call the CustomMoveEvent event
|
||||
*
|
||||
* @param e PlayerMoveEvent
|
||||
*/
|
||||
@EventHandler
|
||||
public void onMove(PlayerMoveEvent e) {
|
||||
CustomMoveEvent customMoveEvent = new CustomMoveEvent(e.getPlayer(), e.getTo(), e.getFrom());
|
||||
e.setCancelled(customMoveEvent.isCancelled());
|
||||
PacketEvents.getEventManager().callEvent(customMoveEvent);
|
||||
|
||||
if (e.getTo() != customMoveEvent.getTo()) {
|
||||
e.setTo(customMoveEvent.getTo());
|
||||
}
|
||||
if (e.getFrom() != customMoveEvent.getFrom()) {
|
||||
e.setFrom(customMoveEvent.getFrom());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Only listen to server tick (if enabled)
|
||||
*
|
||||
* @param e ServerTickEvent
|
||||
*/
|
||||
@PacketHandler
|
||||
public void onServerTick(ServerTickEvent e) {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,83 +0,0 @@
|
||||
package me.purplex.packetevents.example;
|
||||
|
||||
import me.purplex.packetevents.enums.EntityUseAction;
|
||||
import me.purplex.packetevents.enums.PlayerDigType;
|
||||
import me.purplex.packetevents.enums.ServerVersion;
|
||||
import me.purplex.packetevents.events.packetevent.ServerTickEvent;
|
||||
import me.purplex.packetevents.events.handler.PacketHandler;
|
||||
import me.purplex.packetevents.events.listener.PacketListener;
|
||||
import me.purplex.packetevents.events.packetevent.*;
|
||||
import me.purplex.packetevents.packetwrappers.in.*;
|
||||
import me.purplex.packetevents.packets.Packet;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class TestExample implements PacketListener {
|
||||
/**
|
||||
* How to register a packet listener?
|
||||
* <p>
|
||||
* PacketEvents.getPacketManager().registerPacketListener(new TestExample());
|
||||
*/
|
||||
|
||||
private int tick;
|
||||
|
||||
@PacketHandler
|
||||
public void onPacketReceive(PacketReceiveEvent e) {
|
||||
final Player p = e.getPlayer();
|
||||
//ONLY CLIENT PACKETS ALLOWED HERE!
|
||||
switch (e.getPacketName()) {
|
||||
case Packet.Client.USE_ENTITY:
|
||||
final WrappedPacketPlayInUseEntity useEntity = new WrappedPacketPlayInUseEntity(e.getPacket());
|
||||
final Entity entity = useEntity.getEntity();
|
||||
if (useEntity.getEntityUseAction() == EntityUseAction.ATTACK) {
|
||||
final double dist = entity.getLocation().distanceSquared(p.getLocation());
|
||||
p.sendMessage("dist: " + dist);
|
||||
}
|
||||
break;
|
||||
case Packet.Client.ABILITIES:
|
||||
final WrappedPacketPlayInAbilities abilities = new WrappedPacketPlayInAbilities(e.getPacket());
|
||||
final boolean a = abilities.a;
|
||||
final boolean b = abilities.b;
|
||||
final boolean c = abilities.c;
|
||||
final boolean d = abilities.d;
|
||||
final float eFloat = abilities.e;
|
||||
final float fFloat = abilities.f;
|
||||
//just like the 1.8 NMS classes.
|
||||
break;
|
||||
case Packet.Client.BLOCK_DIG:
|
||||
final WrappedPacketPlayInBlockDig blockDig = new WrappedPacketPlayInBlockDig(e.getPacket());
|
||||
final PlayerDigType type = blockDig.getPlayerDigType();
|
||||
break;
|
||||
case Packet.Client.FLYING:
|
||||
final WrappedPacketPlayInFlying flying = new WrappedPacketPlayInFlying(e.getPacket());
|
||||
final float pitch = flying.pitch;
|
||||
final float yaw = flying.yaw;
|
||||
final boolean hasPos = flying.hasPos;
|
||||
final boolean hasLook = flying.hasLook;
|
||||
break;
|
||||
case Packet.Client.POSITION:
|
||||
final WrappedPacketPlayInFlying.WrappedPacketPlayInPosition position =
|
||||
new WrappedPacketPlayInFlying.WrappedPacketPlayInPosition(e.getPacket());
|
||||
final boolean isPos = position.hasPos; //true
|
||||
break;
|
||||
case Packet.Client.POSITION_LOOK:
|
||||
final WrappedPacketPlayInFlying.WrappedPacketPlayInPosition_Look position_look =
|
||||
new WrappedPacketPlayInFlying.WrappedPacketPlayInPosition_Look(e.getPacket());
|
||||
final boolean isLook = position_look.hasLook; //true
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@PacketHandler
|
||||
public void onServerTick(ServerTickEvent e) {
|
||||
//CALLED EVERY TICK
|
||||
tick++;
|
||||
if (tick % 20 == 0) {
|
||||
/*for (Player p : Bukkit.getOnlinePlayers()) {
|
||||
p.sendMessage("One second has passed!");
|
||||
}*/
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,134 @@
|
||||
package me.purplex.packetevents.injector;
|
||||
|
||||
import me.purplex.packetevents.enums.ServerVersion;
|
||||
|
||||
import net.minecraft.server.v1_8_R3.NetworkManager;
|
||||
import net.minecraft.util.io.netty.channel.Channel;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.HashMap;
|
||||
import java.util.UUID;
|
||||
|
||||
public class ChannelManager {
|
||||
private static final ServerVersion version = ServerVersion.getVersion();
|
||||
private static final String nmsDir = ServerVersion.getNMSDirectory();
|
||||
private static final Class<?> networkManager;
|
||||
private static final Field channelField;
|
||||
|
||||
private static final Class<?> craftPlayer;
|
||||
private static final Method handleMethod;
|
||||
|
||||
private static final Class<?> entityPlayer;
|
||||
|
||||
private static final Class<?> playerConnection;
|
||||
private static final Field playerConnectionField;
|
||||
private static final Field networkManagerField;
|
||||
|
||||
|
||||
private static HashMap<UUID, Object> playerChannels = new HashMap<>();
|
||||
|
||||
static {
|
||||
try {
|
||||
networkManager = Class.forName(nmsDir + ".NetworkManager");
|
||||
craftPlayer = Class.forName("org.bukkit.craftbukkit." + ServerVersion.getNmsSuffix() + ".entity.CraftPlayer");
|
||||
entityPlayer = Class.forName(nmsDir + ".EntityPlayer");
|
||||
playerConnection = Class.forName(nmsDir + ".PlayerConnection");
|
||||
} catch (ClassNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
throw new IllegalStateException("Failed to find a NMS class! You are probably using an unsupported version of spigot.");
|
||||
}
|
||||
|
||||
//FIELDS & METHODS
|
||||
try {
|
||||
channelField = networkManager.getDeclaredField(getChannelFieldName());
|
||||
} catch (NoSuchFieldException e) {
|
||||
e.printStackTrace();
|
||||
throw new IllegalStateException("Failed to find the channel field in the NetworkManager! You are probably using an unsupported version of spigot.");
|
||||
}
|
||||
if (!channelField.isAccessible()) {
|
||||
channelField.setAccessible(true);
|
||||
}
|
||||
|
||||
try {
|
||||
handleMethod = craftPlayer.getDeclaredMethod("getHandle");
|
||||
} catch (NoSuchMethodException e) {
|
||||
e.printStackTrace();
|
||||
throw new IllegalStateException("Failed to find the getHandle function in the CraftPlayer class! You are probably using an unsupported version of spigot.");
|
||||
}
|
||||
if (!handleMethod.isAccessible()) {
|
||||
handleMethod.setAccessible(true);
|
||||
}
|
||||
|
||||
try {
|
||||
playerConnectionField = entityPlayer.getDeclaredField("playerConnection");
|
||||
} catch (NoSuchFieldException e) {
|
||||
e.printStackTrace();
|
||||
throw new IllegalStateException("Failed to find the playerConnection field in the EntityPlayer class! You are probably using an unsupported version of spigot.");
|
||||
}
|
||||
if (!playerConnectionField.isAccessible()) {
|
||||
playerConnectionField.setAccessible(true);
|
||||
}
|
||||
|
||||
try {
|
||||
networkManagerField = playerConnection.getDeclaredField("networkManager");
|
||||
} catch (NoSuchFieldException e) {
|
||||
e.printStackTrace();
|
||||
throw new IllegalStateException("Failed to find the networkManager field in the PlayerConnection class! You are probably using an unsupported version of spigot.");
|
||||
}
|
||||
|
||||
if (!networkManagerField.isAccessible()) {
|
||||
networkManagerField.setAccessible(true);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private static Object getChannelObject(final Player player) throws IllegalAccessException, InvocationTargetException {
|
||||
final Object craftPlayerObj = craftPlayer.cast(player);
|
||||
final Object entityPlayerObj = handleMethod.invoke(craftPlayerObj);
|
||||
final Object playerConnectionObj = playerConnectionField.get(entityPlayerObj);
|
||||
final Object networkManagerObj = networkManagerField.get(playerConnectionObj);
|
||||
return channelField.get(networkManagerObj);
|
||||
}
|
||||
|
||||
public static void removeChannel(final UUID uuid) {
|
||||
playerChannels.remove(uuid);
|
||||
}
|
||||
|
||||
public static Object getChannel(final Player player) {
|
||||
final UUID uuid = player.getUniqueId();
|
||||
if (playerChannels.containsKey(uuid)) {
|
||||
return playerChannels.get(uuid);
|
||||
}
|
||||
Object channel = null;
|
||||
try {
|
||||
channel = getChannelObject(player);
|
||||
} catch (IllegalAccessException e) {
|
||||
e.printStackTrace();
|
||||
} catch (InvocationTargetException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
if (channel != null) {
|
||||
playerChannels.put(uuid, channel);
|
||||
}
|
||||
else {
|
||||
System.out.println("ITS NULL");
|
||||
}
|
||||
return channel;
|
||||
}
|
||||
|
||||
private static String getChannelFieldName() {
|
||||
if (version == ServerVersion.v_1_7_10) {
|
||||
return "m";
|
||||
} else if (version == ServerVersion.v_1_8) {
|
||||
return "i";
|
||||
} else if (version == ServerVersion.v_1_8_3) {
|
||||
return "k";
|
||||
} else { //all 1.8.8 ->1.15
|
||||
return "channel";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
package me.purplex.packetevents.injector;
|
||||
|
||||
|
||||
import me.purplex.packetevents.PacketEvents;
|
||||
import me.purplex.packetevents.enums.ServerVersion;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
|
||||
public class PacketInjector {
|
||||
|
||||
private final static ServerVersion version = PacketEvents.getServerVersion();
|
||||
|
||||
public void injectPlayer(final Player player) {
|
||||
if(version == ServerVersion.v_1_7_10) {
|
||||
PlayerInject_1_7_10.injectPlayer(player);
|
||||
}
|
||||
else {
|
||||
PlayerInject_1_8.injectPlayer(player);
|
||||
// player.sendMessage("injected");
|
||||
}
|
||||
}
|
||||
|
||||
public void uninjectPlayer(final Player player) {
|
||||
if(version == ServerVersion.v_1_7_10) {
|
||||
PlayerInject_1_7_10.uninjectPlayer(player);
|
||||
}
|
||||
else {
|
||||
PlayerInject_1_8.uninjectPlayer(player);
|
||||
}
|
||||
ChannelManager.removeChannel(player.getUniqueId());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
package me.purplex.packetevents.injector;
|
||||
|
||||
import me.purplex.packetevents.PacketEvents;
|
||||
import me.purplex.packetevents.event.impl.PacketReceiveEvent;
|
||||
import me.purplex.packetevents.event.impl.PacketSendEvent;
|
||||
import me.purplex.packetevents.event.impl.PlayerInjectEvent;
|
||||
import me.purplex.packetevents.event.impl.PlayerUninjectEvent;
|
||||
import net.minecraft.util.io.netty.channel.Channel;
|
||||
import net.minecraft.util.io.netty.channel.ChannelDuplexHandler;
|
||||
import net.minecraft.util.io.netty.channel.ChannelHandlerContext;
|
||||
import net.minecraft.util.io.netty.channel.ChannelPromise;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
class PlayerInject_1_7_10 {
|
||||
public static void injectPlayer(final Player player) {
|
||||
final ChannelDuplexHandler channelDuplexHandler = new ChannelDuplexHandler() {
|
||||
@Override
|
||||
public void channelRead(final ChannelHandlerContext ctx, final Object packet) throws Exception {
|
||||
String packetName = packet.getClass().getSimpleName();
|
||||
PacketReceiveEvent e = new PacketReceiveEvent(player, packetName, packet);
|
||||
PacketEvents.getEventManager().callEvent(e);
|
||||
if (e.isCancelled()) {
|
||||
return;
|
||||
}
|
||||
super.channelRead(ctx, packet);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(final ChannelHandlerContext ctx, final Object packet, final ChannelPromise promise) throws Exception {
|
||||
String packetName = packet.getClass().getSimpleName();
|
||||
|
||||
PacketSendEvent e = new PacketSendEvent(player, packetName, packet);
|
||||
PacketEvents.getEventManager().callEvent(e);
|
||||
if (e.isCancelled()) {
|
||||
return;
|
||||
}
|
||||
|
||||
super.write(ctx, packet, promise);
|
||||
}
|
||||
};
|
||||
final PlayerInjectEvent injectEvent = new PlayerInjectEvent(player);
|
||||
PacketEvents.getEventManager().callEvent(injectEvent);
|
||||
getChannel(player).pipeline().addBefore("packet_handler", player.getName(), channelDuplexHandler);
|
||||
}
|
||||
|
||||
public static void uninjectPlayer(final Player player) {
|
||||
final Channel channel = getChannel(player);
|
||||
final Runnable runnable = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
channel.pipeline().remove(player.getName());
|
||||
}
|
||||
};
|
||||
final PlayerUninjectEvent uninjectEvent = new PlayerUninjectEvent(player);
|
||||
PacketEvents.getEventManager().callEvent(uninjectEvent);
|
||||
channel.eventLoop().submit(runnable);
|
||||
}
|
||||
public static Channel getChannel(final Player player) {
|
||||
return (Channel) ChannelManager.getChannel(player);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
package me.purplex.packetevents.injector;
|
||||
|
||||
|
||||
import io.netty.channel.Channel;
|
||||
import io.netty.channel.ChannelDuplexHandler;
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
import io.netty.channel.ChannelPromise;
|
||||
import me.purplex.packetevents.PacketEvents;
|
||||
import me.purplex.packetevents.event.impl.PacketReceiveEvent;
|
||||
import me.purplex.packetevents.event.impl.PacketSendEvent;
|
||||
import me.purplex.packetevents.event.impl.PlayerInjectEvent;
|
||||
import me.purplex.packetevents.event.impl.PlayerUninjectEvent;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
class PlayerInject_1_8 {
|
||||
public static void injectPlayer(final Player player) {
|
||||
final ChannelDuplexHandler channelDuplexHandler = new ChannelDuplexHandler() {
|
||||
@Override
|
||||
public void channelRead(final ChannelHandlerContext ctx, final Object packet) throws Exception {
|
||||
String packetName = packet.getClass().getSimpleName();
|
||||
PacketReceiveEvent e = new PacketReceiveEvent(player, packetName, packet);
|
||||
PacketEvents.getEventManager().callEvent(e);
|
||||
if (e.isCancelled()) {
|
||||
return;
|
||||
}
|
||||
super.channelRead(ctx, packet);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(final ChannelHandlerContext ctx, final Object packet, final ChannelPromise promise) throws Exception {
|
||||
String packetName = packet.getClass().getSimpleName();
|
||||
PacketSendEvent e = new PacketSendEvent(player, packetName, packet);
|
||||
PacketEvents.getEventManager().callEvent(e);
|
||||
if (e.isCancelled()) {
|
||||
return;
|
||||
}
|
||||
|
||||
super.write(ctx, packet, promise);
|
||||
}
|
||||
};
|
||||
final PlayerInjectEvent injectEvent = new PlayerInjectEvent(player);
|
||||
PacketEvents.getEventManager().callEvent(injectEvent);
|
||||
getChannel(player).pipeline().addBefore("packet_handler", player.getName(), channelDuplexHandler);
|
||||
}
|
||||
|
||||
public static void uninjectPlayer(final Player player) {
|
||||
final Channel channel = getChannel(player);
|
||||
final Runnable runnable = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
channel.pipeline().remove(player.getName());
|
||||
}
|
||||
};
|
||||
final PlayerUninjectEvent uninjectEvent = new PlayerUninjectEvent(player);
|
||||
PacketEvents.getEventManager().callEvent(uninjectEvent);
|
||||
channel.eventLoop().submit(runnable);
|
||||
}
|
||||
|
||||
public static Channel getChannel(final Player player) {
|
||||
return (Channel) ChannelManager.getChannel(player);
|
||||
}
|
||||
}
|
||||
+10
-1
@@ -1,4 +1,4 @@
|
||||
package me.purplex.packetevents.packets;
|
||||
package me.purplex.packetevents.packet;
|
||||
|
||||
public abstract class Packet {
|
||||
public static class Client {
|
||||
@@ -70,4 +70,13 @@ public abstract class Packet {
|
||||
public static final String START = "PacketStatusInStart";
|
||||
public static final String SUCCESS = "PacketLoginOutSuccess";
|
||||
}
|
||||
|
||||
public static boolean isInstanceOf(String fatherPacket, String childPacket) {
|
||||
if (fatherPacket.equals(Client.FLYING) && childPacket.equals(Client.POSITION) || childPacket.equals(Client.POSITION_LOOK)) {
|
||||
return true;
|
||||
}
|
||||
return fatherPacket.equals(childPacket);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -1,88 +0,0 @@
|
||||
package me.purplex.packetevents.packetmanager;
|
||||
|
||||
import me.purplex.packetevents.events.PacketEvent;
|
||||
import me.purplex.packetevents.events.packetevent.ServerTickEvent;
|
||||
import me.purplex.packetevents.eventmanager.PacketEventManager;
|
||||
import me.purplex.packetevents.events.handler.PacketHandler;
|
||||
import me.purplex.packetevents.events.listener.PacketListener;
|
||||
import me.purplex.packetevents.events.packetevent.PacketReceiveEvent;
|
||||
import me.purplex.packetevents.events.packetevent.PacketSendEvent;
|
||||
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
public class PacketManager implements PacketEventManager {
|
||||
@Override
|
||||
public void callEvent(PacketEvent e) {
|
||||
for (PacketListener listener : this.packetListeners) {
|
||||
Method[] methods = listener.getClass().getMethods();
|
||||
for (Method m : methods) {
|
||||
if (m.isAnnotationPresent(PacketHandler.class)) {
|
||||
if(e instanceof PacketReceiveEvent) {
|
||||
PacketReceiveEvent event = (PacketReceiveEvent)e;
|
||||
if(m.getParameterTypes()[0].getSimpleName().equals(event.getClass().getSimpleName())) {
|
||||
try {
|
||||
m.invoke(listener, event);
|
||||
} catch (IllegalAccessException ex) {
|
||||
ex.printStackTrace();
|
||||
} catch (InvocationTargetException ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
else if(e instanceof PacketSendEvent) {
|
||||
PacketSendEvent event = (PacketSendEvent)e;
|
||||
if(m.getParameterTypes()[0].getSimpleName().equals(event.getClass().getSimpleName())) {
|
||||
try {
|
||||
m.invoke(listener, event);
|
||||
} catch (IllegalAccessException ex) {
|
||||
ex.printStackTrace();
|
||||
} catch (InvocationTargetException ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
else if(e instanceof ServerTickEvent) {
|
||||
ServerTickEvent event = (ServerTickEvent)e;
|
||||
if(m.getParameterTypes()[0].getSimpleName().equals(event.getClass().getSimpleName())) {
|
||||
try {
|
||||
m.invoke(listener, event);
|
||||
} catch (IllegalAccessException ex) {
|
||||
ex.printStackTrace();
|
||||
} catch (InvocationTargetException ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
if(m.getParameterTypes()[0].getSimpleName().equals(e.getClass().getSimpleName())) {
|
||||
try {
|
||||
m.invoke(listener, e);
|
||||
} catch (IllegalAccessException ex) {
|
||||
ex.printStackTrace();
|
||||
} catch (InvocationTargetException ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerListener(PacketListener e) {
|
||||
this.packetListeners.add(e);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void unregisterListener(PacketListener e) {
|
||||
this.packetListeners.remove(e);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void unregisterAllListeners(PacketListener e) {
|
||||
this.packetListeners.clear();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -2,19 +2,28 @@ package me.purplex.packetevents.packetwrappers.api;
|
||||
|
||||
import me.purplex.packetevents.enums.ServerVersion;
|
||||
|
||||
/**
|
||||
* All the wrappers are still under development.
|
||||
* It is a lot of work, I must make 13 wrappers for each packet.
|
||||
*/
|
||||
public class WrappedPacket {
|
||||
protected Object packet;
|
||||
protected static final ServerVersion version = ServerVersion.getVersion();
|
||||
protected static ServerVersion version = ServerVersion.getVersion();
|
||||
private static final String err = "Your Version is unsupported, " +
|
||||
"please contact purplex(creator) " +
|
||||
"through his discord server (http://discord.gg/2uZY5A4) " +
|
||||
"and tell him what version your server is running on! " +
|
||||
"Make sure you are using spigot!";
|
||||
public WrappedPacket(Object packet) {
|
||||
this.packet = packet;
|
||||
setup();
|
||||
try {
|
||||
setup();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
protected void setup() {
|
||||
protected void setup() throws Exception {
|
||||
|
||||
}
|
||||
|
||||
protected void throwUnsupportedVersion() {
|
||||
throw new IllegalStateException(err);
|
||||
}
|
||||
|
||||
}
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
package me.purplex.packetevents.packetwrappers.api.sendable;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
/**
|
||||
* Unfinished
|
||||
*/
|
||||
public class WrappedServerPacket {
|
||||
public WrappedServerPacket(Player target) {
|
||||
|
||||
}
|
||||
}
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
package me.purplex.packetevents.packetwrappers.api.version;
|
||||
|
||||
import me.purplex.packetevents.PacketEvents;
|
||||
import me.purplex.packetevents.enums.ServerVersion;
|
||||
|
||||
public abstract class WrappedVersionPacket {
|
||||
protected final Object packet;
|
||||
protected static ServerVersion version = PacketEvents.getServerVersion();
|
||||
public WrappedVersionPacket(Object packet) {
|
||||
this.packet = packet;
|
||||
setup();
|
||||
}
|
||||
|
||||
protected abstract void setup();
|
||||
}
|
||||
-130
@@ -1,130 +0,0 @@
|
||||
package me.purplex.packetevents.packetwrappers.in;
|
||||
|
||||
|
||||
import me.purplex.packetevents.enums.ServerVersion;
|
||||
import me.purplex.packetevents.packetwrappers.api.WrappedPacket;
|
||||
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;
|
||||
import me.purplex.packetevents.packetwrappers.in._1_13.WrappedPacketPlayInAbilities_1_13;
|
||||
import me.purplex.packetevents.packetwrappers.in._1_13_2.WrappedPacketPlayInAbilities_1_13_2;
|
||||
import me.purplex.packetevents.packetwrappers.in._1_14.WrappedPacketPlayInAbilities_1_14;
|
||||
import me.purplex.packetevents.packetwrappers.in._1_15.WrappedPacketPlayInAbilities_1_15;
|
||||
import me.purplex.packetevents.packetwrappers.in._1_7_10.WrappedPacketPlayInAbilities_1_7_10;
|
||||
import me.purplex.packetevents.packetwrappers.in._1_8.WrappedPacketPlayInAbilities_1_8;
|
||||
import me.purplex.packetevents.packetwrappers.in._1_8_3.WrappedPacketPlayInAbilities_1_8_3;
|
||||
import me.purplex.packetevents.packetwrappers.in._1_8_8.WrappedPacketPlayInAbilities_1_8_8;
|
||||
import me.purplex.packetevents.packetwrappers.in._1_9.WrappedPacketPlayInAbilities_1_9;
|
||||
import me.purplex.packetevents.packetwrappers.in._1_9_4.WrappedPacketPlayInAbilities_1_9_4;
|
||||
|
||||
public class WrappedPacketPlayInAbilities extends WrappedPacket {
|
||||
|
||||
public boolean a;
|
||||
public boolean b;
|
||||
public boolean c;
|
||||
public boolean d;
|
||||
public float e;
|
||||
public float f;
|
||||
|
||||
public WrappedPacketPlayInAbilities(Object packet) {
|
||||
super(packet);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setup() {
|
||||
if(version == ServerVersion.v_1_7_10) {
|
||||
WrappedPacketPlayInAbilities_1_7_10 p = new WrappedPacketPlayInAbilities_1_7_10(packet);
|
||||
this.a = p.a;
|
||||
this.b = p.b;
|
||||
this.c = p.c;
|
||||
this.d = p.d;
|
||||
this.e = p.e;
|
||||
}
|
||||
else if (version == ServerVersion.v_1_8) {
|
||||
WrappedPacketPlayInAbilities_1_8 p = new WrappedPacketPlayInAbilities_1_8(packet);
|
||||
this.a = p.a;
|
||||
this.b = p.b;
|
||||
this.c = p.c;
|
||||
this.e = p.e;
|
||||
this.f = p.f;
|
||||
} else if (version == ServerVersion.v_1_8_3) {
|
||||
WrappedPacketPlayInAbilities_1_8_3 p = new WrappedPacketPlayInAbilities_1_8_3(packet);
|
||||
this.a = p.a;
|
||||
this.b = p.b;
|
||||
this.c = p.c;
|
||||
this.e = p.e;
|
||||
this.f = p.f;
|
||||
} else if (version == ServerVersion.v_1_8_8) {
|
||||
WrappedPacketPlayInAbilities_1_8_8 p = new WrappedPacketPlayInAbilities_1_8_8(packet);
|
||||
this.a = p.a;
|
||||
this.b = p.b;
|
||||
this.c = p.c;
|
||||
this.e = p.e;
|
||||
this.f = p.f;
|
||||
} else if (version == ServerVersion.v_1_9) {
|
||||
WrappedPacketPlayInAbilities_1_9 p = new WrappedPacketPlayInAbilities_1_9(packet);
|
||||
this.a = p.a;
|
||||
this.b = p.b;
|
||||
this.c = p.c;
|
||||
this.e = p.e;
|
||||
this.f = p.f;
|
||||
} else if (version == ServerVersion.v_1_9_4) {
|
||||
WrappedPacketPlayInAbilities_1_9_4 p = new WrappedPacketPlayInAbilities_1_9_4(packet);
|
||||
this.a = p.a;
|
||||
this.b = p.b;
|
||||
this.c = p.c;
|
||||
this.e = p.e;
|
||||
this.f = p.f;
|
||||
} else if (version == ServerVersion.v_1_10) {
|
||||
WrappedPacketPlayInAbilities_1_10 p = new WrappedPacketPlayInAbilities_1_10(packet);
|
||||
this.a = p.a;
|
||||
this.b = p.b;
|
||||
this.c = p.c;
|
||||
this.e = p.e;
|
||||
this.f = p.f;
|
||||
} else if (version == ServerVersion.v_1_11) {
|
||||
WrappedPacketPlayInAbilities_1_11 p = new WrappedPacketPlayInAbilities_1_11(packet);
|
||||
this.a = p.a;
|
||||
this.b = p.b;
|
||||
this.c = p.c;
|
||||
this.e = p.e;
|
||||
this.f = p.f;
|
||||
} else if (version == ServerVersion.v_1_12) {
|
||||
WrappedPacketPlayInAbilities_1_12 p = new WrappedPacketPlayInAbilities_1_12(packet);
|
||||
this.a = p.a;
|
||||
this.b = p.b;
|
||||
this.c = p.c;
|
||||
this.e = p.e;
|
||||
this.f = p.f;
|
||||
} else if (version == ServerVersion.v_1_13) {
|
||||
WrappedPacketPlayInAbilities_1_13 p = new WrappedPacketPlayInAbilities_1_13(packet);
|
||||
this.a = p.a;
|
||||
this.b = p.b;
|
||||
this.c = p.c;
|
||||
this.e = p.e;
|
||||
this.f = p.f;
|
||||
} else if (version == ServerVersion.v_1_13_2) {
|
||||
WrappedPacketPlayInAbilities_1_13_2 p = new WrappedPacketPlayInAbilities_1_13_2(packet);
|
||||
this.a = p.a;
|
||||
this.b = p.b;
|
||||
this.c = p.c;
|
||||
this.e = p.e;
|
||||
this.f = p.f;
|
||||
} else if (version == ServerVersion.v_1_14) {
|
||||
WrappedPacketPlayInAbilities_1_14 p = new WrappedPacketPlayInAbilities_1_14(packet);
|
||||
this.a = p.a;
|
||||
this.b = p.b;
|
||||
this.c = p.c;
|
||||
this.e = p.e;
|
||||
this.f = p.f;
|
||||
} else if (version == ServerVersion.v_1_15) {
|
||||
WrappedPacketPlayInAbilities_1_15 p = new WrappedPacketPlayInAbilities_1_15(packet);
|
||||
this.a = p.a;
|
||||
this.b = p.b;
|
||||
this.c = p.c;
|
||||
this.e = p.e;
|
||||
this.f = p.f;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
-76
@@ -1,76 +0,0 @@
|
||||
package me.purplex.packetevents.packetwrappers.in;
|
||||
|
||||
import me.purplex.packetevents.enums.PlayerDigType;
|
||||
import me.purplex.packetevents.enums.ServerVersion;
|
||||
import me.purplex.packetevents.packetwrappers.api.WrappedPacket;
|
||||
import me.purplex.packetevents.packetwrappers.in._1_10.WrappedPacketPlayInBlockDig_1_10;
|
||||
import me.purplex.packetevents.packetwrappers.in._1_11.WrappedPacketPlayInBlockDig_1_11;
|
||||
import me.purplex.packetevents.packetwrappers.in._1_12.WrappedPacketPlayInBlockDig_1_12;
|
||||
import me.purplex.packetevents.packetwrappers.in._1_13.WrappedPacketPlayInBlockDig_1_13;
|
||||
import me.purplex.packetevents.packetwrappers.in._1_13_2.WrappedPacketPlayInBlockDig_1_13_2;
|
||||
import me.purplex.packetevents.packetwrappers.in._1_14.WrappedPacketPlayInBlockDig_1_14;
|
||||
import me.purplex.packetevents.packetwrappers.in._1_15.WrappedPacketPlayInBlockDig_1_15;
|
||||
import me.purplex.packetevents.packetwrappers.in._1_7_10.WrappedPacketPlayInBlockDig_1_7_10;
|
||||
import me.purplex.packetevents.packetwrappers.in._1_8.WrappedPacketPlayInBlockDig_1_8;
|
||||
import me.purplex.packetevents.packetwrappers.in._1_8_3.WrappedPacketPlayInBlockDig_1_8_3;
|
||||
import me.purplex.packetevents.packetwrappers.in._1_8_8.WrappedPacketPlayInBlockDig_1_8_8;
|
||||
import me.purplex.packetevents.packetwrappers.in._1_9.WrappedPacketPlayInBlockDig_1_9;
|
||||
import me.purplex.packetevents.packetwrappers.in._1_9_4.WrappedPacketPlayInBlockDig_1_9_4;
|
||||
|
||||
public class WrappedPacketPlayInBlockDig extends WrappedPacket {
|
||||
|
||||
private PlayerDigType digType;
|
||||
|
||||
public WrappedPacketPlayInBlockDig(Object packet) {
|
||||
super(packet);
|
||||
}
|
||||
|
||||
public PlayerDigType getPlayerDigType() {
|
||||
return digType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setup() {
|
||||
if(version == ServerVersion.v_1_7_10) {
|
||||
WrappedPacketPlayInBlockDig_1_7_10 p = new WrappedPacketPlayInBlockDig_1_7_10(this.packet);
|
||||
this.digType = p.digType;
|
||||
}
|
||||
else if (version == ServerVersion.v_1_8) {
|
||||
WrappedPacketPlayInBlockDig_1_8 p = new WrappedPacketPlayInBlockDig_1_8(packet);
|
||||
this.digType = p.digType;
|
||||
} else if (version == ServerVersion.v_1_8_3) {
|
||||
WrappedPacketPlayInBlockDig_1_8_3 p = new WrappedPacketPlayInBlockDig_1_8_3(packet);
|
||||
this.digType = p.digType;
|
||||
} else if (version == ServerVersion.v_1_8_8) {
|
||||
WrappedPacketPlayInBlockDig_1_8_8 p = new WrappedPacketPlayInBlockDig_1_8_8(packet);
|
||||
this.digType = p.digType;
|
||||
} else if (version == ServerVersion.v_1_9) {
|
||||
WrappedPacketPlayInBlockDig_1_9 p = new WrappedPacketPlayInBlockDig_1_9(packet);
|
||||
this.digType = p.digType;
|
||||
} else if (version == ServerVersion.v_1_9_4) {
|
||||
WrappedPacketPlayInBlockDig_1_9_4 p = new WrappedPacketPlayInBlockDig_1_9_4(packet);
|
||||
this.digType = p.digType;
|
||||
} else if (version == ServerVersion.v_1_10) {
|
||||
WrappedPacketPlayInBlockDig_1_10 p = new WrappedPacketPlayInBlockDig_1_10(packet);
|
||||
this.digType = p.digType;
|
||||
} else if (version == ServerVersion.v_1_11) {
|
||||
WrappedPacketPlayInBlockDig_1_11 p = new WrappedPacketPlayInBlockDig_1_11(packet);
|
||||
this.digType = p.digType;
|
||||
} else if (version == ServerVersion.v_1_12) {
|
||||
WrappedPacketPlayInBlockDig_1_12 p = new WrappedPacketPlayInBlockDig_1_12(packet);
|
||||
this.digType = p.digType;
|
||||
} else if (version == ServerVersion.v_1_13) {
|
||||
WrappedPacketPlayInBlockDig_1_13 p = new WrappedPacketPlayInBlockDig_1_13(packet);
|
||||
this.digType = p.digType;
|
||||
} else if (version == ServerVersion.v_1_13_2) {
|
||||
WrappedPacketPlayInBlockDig_1_13_2 p = new WrappedPacketPlayInBlockDig_1_13_2(packet);
|
||||
this.digType = p.digType;
|
||||
} else if (version == ServerVersion.v_1_14) {
|
||||
WrappedPacketPlayInBlockDig_1_14 p = new WrappedPacketPlayInBlockDig_1_14(packet);
|
||||
this.digType = p.digType;
|
||||
} else if (version == ServerVersion.v_1_15) {
|
||||
WrappedPacketPlayInBlockDig_1_15 p = new WrappedPacketPlayInBlockDig_1_15(packet);
|
||||
this.digType = p.digType;
|
||||
}
|
||||
}
|
||||
}
|
||||
-439
@@ -1,439 +0,0 @@
|
||||
package me.purplex.packetevents.packetwrappers.in;
|
||||
|
||||
import me.purplex.packetevents.enums.ServerVersion;
|
||||
import me.purplex.packetevents.packetwrappers.api.WrappedPacket;
|
||||
import me.purplex.packetevents.packetwrappers.in._1_10.WrappedPacketPlayInFlying_1_10;
|
||||
import me.purplex.packetevents.packetwrappers.in._1_11.WrappedPacketPlayInFlying_1_11;
|
||||
import me.purplex.packetevents.packetwrappers.in._1_12.WrappedPacketPlayInFlying_1_12;
|
||||
import me.purplex.packetevents.packetwrappers.in._1_13.WrappedPacketPlayInFlying_1_13;
|
||||
import me.purplex.packetevents.packetwrappers.in._1_13_2.WrappedPacketPlayInFlying_1_13_2;
|
||||
import me.purplex.packetevents.packetwrappers.in._1_14.WrappedPacketPlayInFlying_1_14;
|
||||
import me.purplex.packetevents.packetwrappers.in._1_15.WrappedPacketPlayInFlying_1_15;
|
||||
import me.purplex.packetevents.packetwrappers.in._1_7_10.WrappedPacketPlayInFlying_1_7_10;
|
||||
import me.purplex.packetevents.packetwrappers.in._1_8.WrappedPacketPlayInFlying_1_8;
|
||||
import me.purplex.packetevents.packetwrappers.in._1_8_3.WrappedPacketPlayInFlying_1_8_3;
|
||||
import me.purplex.packetevents.packetwrappers.in._1_8_8.WrappedPacketPlayInFlying_1_8_8;
|
||||
import me.purplex.packetevents.packetwrappers.in._1_9.WrappedPacketPlayInFlying_1_9;
|
||||
import me.purplex.packetevents.packetwrappers.in._1_9_4.WrappedPacketPlayInFlying_1_9_4;
|
||||
|
||||
public class WrappedPacketPlayInFlying extends WrappedPacket {
|
||||
|
||||
public double x;
|
||||
public double y;
|
||||
public double z;
|
||||
public float yaw;
|
||||
public float pitch;
|
||||
public boolean f;
|
||||
public boolean hasPos;
|
||||
public boolean hasLook;
|
||||
|
||||
public WrappedPacketPlayInFlying(Object packet) {
|
||||
super(packet);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setup(){
|
||||
if(version == ServerVersion.v_1_7_10) {
|
||||
WrappedPacketPlayInFlying_1_7_10 p = new WrappedPacketPlayInFlying_1_7_10(packet);
|
||||
this.x = p.x;
|
||||
this.y = p.y;
|
||||
this.z = p.z;
|
||||
this.yaw = p.yaw;
|
||||
this.pitch = p.pitch;
|
||||
this.f = p.f;
|
||||
this.hasPos = p.hasPos;
|
||||
this.hasLook = p.hasLook;
|
||||
}
|
||||
else if(version == ServerVersion.v_1_8) {
|
||||
WrappedPacketPlayInFlying_1_8 p = new WrappedPacketPlayInFlying_1_8(packet);
|
||||
this.x = p.x;
|
||||
this.y = p.y;
|
||||
this.z = p.z;
|
||||
this.yaw = p.yaw;
|
||||
this.pitch = p.pitch;
|
||||
this.f = p.f;
|
||||
this.hasPos = p.hasPos;
|
||||
this.hasLook = p.hasLook;
|
||||
}
|
||||
else if(version == ServerVersion.v_1_8_3) {
|
||||
WrappedPacketPlayInFlying_1_8_3 p = new WrappedPacketPlayInFlying_1_8_3(packet);
|
||||
this.x = p.x;
|
||||
this.y = p.y;
|
||||
this.z = p.z;
|
||||
this.yaw = p.yaw;
|
||||
this.pitch = p.pitch;
|
||||
this.f = p.f;
|
||||
this.hasPos = p.hasPos;
|
||||
this.hasLook = p.hasLook;
|
||||
}
|
||||
else if(version == ServerVersion.v_1_8_8) {
|
||||
WrappedPacketPlayInFlying_1_8_8 p = new WrappedPacketPlayInFlying_1_8_8(packet);
|
||||
this.x = p.x;
|
||||
this.y = p.y;
|
||||
this.z = p.z;
|
||||
this.yaw = p.yaw;
|
||||
this.pitch = p.pitch;
|
||||
this.f = p.f;
|
||||
this.hasPos = p.hasPos;
|
||||
this.hasLook = p.hasLook;
|
||||
}
|
||||
else if(version == ServerVersion.v_1_9) {
|
||||
WrappedPacketPlayInFlying_1_9 p = new WrappedPacketPlayInFlying_1_9(packet);
|
||||
this.x = p.x;
|
||||
this.y = p.y;
|
||||
this.z = p.z;
|
||||
this.yaw = p.yaw;
|
||||
this.pitch = p.pitch;
|
||||
this.f = p.f;
|
||||
this.hasPos = p.hasPos;
|
||||
this.hasLook = p.hasLook;
|
||||
}
|
||||
else if(version == ServerVersion.v_1_9_4) {
|
||||
WrappedPacketPlayInFlying_1_9_4 p = new WrappedPacketPlayInFlying_1_9_4(packet);
|
||||
this.x = p.x;
|
||||
this.y = p.y;
|
||||
this.z = p.z;
|
||||
this.yaw = p.yaw;
|
||||
this.pitch = p.pitch;
|
||||
this.f = p.f;
|
||||
this.hasPos = p.hasPos;
|
||||
this.hasLook = p.hasLook;
|
||||
}
|
||||
else if(version == ServerVersion.v_1_10) {
|
||||
WrappedPacketPlayInFlying_1_10 p = new WrappedPacketPlayInFlying_1_10(packet);
|
||||
this.x = p.x;
|
||||
this.y = p.y;
|
||||
this.z = p.z;
|
||||
this.yaw = p.yaw;
|
||||
this.pitch = p.pitch;
|
||||
this.f = p.f;
|
||||
this.hasPos = p.hasPos;
|
||||
this.hasLook = p.hasLook;
|
||||
}
|
||||
else if(version== ServerVersion.v_1_11) {
|
||||
WrappedPacketPlayInFlying_1_11 p = new WrappedPacketPlayInFlying_1_11(packet);
|
||||
this.x = p.x;
|
||||
this.y = p.y;
|
||||
this.z = p.z;
|
||||
this.yaw = p.yaw;
|
||||
this.pitch = p.pitch;
|
||||
this.f = p.f;
|
||||
this.hasPos = p.hasPos;
|
||||
this.hasLook = p.hasLook;
|
||||
}
|
||||
else if(version == ServerVersion.v_1_12) {
|
||||
WrappedPacketPlayInFlying_1_12 p = new WrappedPacketPlayInFlying_1_12(packet);
|
||||
this.x = p.x;
|
||||
this.y = p.y;
|
||||
this.z = p.z;
|
||||
this.yaw = p.yaw;
|
||||
this.pitch = p.pitch;
|
||||
this.f = p.f;
|
||||
this.hasPos = p.hasPos;
|
||||
this.hasLook = p.hasLook;
|
||||
}
|
||||
else if(version== ServerVersion.v_1_13) {
|
||||
WrappedPacketPlayInFlying_1_13 p = new WrappedPacketPlayInFlying_1_13(packet);
|
||||
this.x = p.x;
|
||||
this.y = p.y;
|
||||
this.z = p.z;
|
||||
this.yaw = p.yaw;
|
||||
this.pitch = p.pitch;
|
||||
this.f = p.f;
|
||||
this.hasPos = p.hasPos;
|
||||
this.hasLook = p.hasLook;
|
||||
}
|
||||
else if(version == ServerVersion.v_1_13_2) {
|
||||
WrappedPacketPlayInFlying_1_13_2 p = new WrappedPacketPlayInFlying_1_13_2(packet);
|
||||
this.x = p.x;
|
||||
this.y = p.y;
|
||||
this.z = p.z;
|
||||
this.yaw = p.yaw;
|
||||
this.pitch = p.pitch;
|
||||
this.f = p.f;
|
||||
this.hasPos = p.hasPos;
|
||||
this.hasLook = p.hasLook;
|
||||
}
|
||||
else if(version == ServerVersion.v_1_14) {
|
||||
WrappedPacketPlayInFlying_1_14 p = new WrappedPacketPlayInFlying_1_14(packet);
|
||||
this.x = p.x;
|
||||
this.y = p.y;
|
||||
this.z = p.z;
|
||||
this.yaw = p.yaw;
|
||||
this.pitch = p.pitch;
|
||||
this.f = p.f;
|
||||
this.hasPos = p.hasPos;
|
||||
this.hasLook = p.hasLook;
|
||||
}
|
||||
else if(version == ServerVersion.v_1_15) {
|
||||
WrappedPacketPlayInFlying_1_15 p = new WrappedPacketPlayInFlying_1_15(packet);
|
||||
this.x = p.x;
|
||||
this.y = p.y;
|
||||
this.z = p.z;
|
||||
this.yaw = p.yaw;
|
||||
this.pitch = p.pitch;
|
||||
this.f = p.f;
|
||||
this.hasPos = p.hasPos;
|
||||
this.hasLook = p.hasLook;
|
||||
}
|
||||
}
|
||||
|
||||
public static class WrappedPacketPlayInPosition extends WrappedPacketPlayInFlying {
|
||||
|
||||
public WrappedPacketPlayInPosition(Object packet) {
|
||||
super(packet);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setup() {
|
||||
if(version == ServerVersion.v_1_7_10) {
|
||||
WrappedPacketPlayInFlying_1_7_10.WrappedPacketPlayInPosition_1_7_10 p
|
||||
= new WrappedPacketPlayInFlying_1_7_10.WrappedPacketPlayInPosition_1_7_10(packet);
|
||||
this.hasPos = p.hasPos;
|
||||
this.hasLook = p.hasLook;
|
||||
}
|
||||
else if(version == ServerVersion.v_1_8) {
|
||||
WrappedPacketPlayInFlying_1_8.WrappedPacketPlayInPosition_1_8 p
|
||||
= new WrappedPacketPlayInFlying_1_8.WrappedPacketPlayInPosition_1_8(packet);
|
||||
this.hasPos = p.hasPos;
|
||||
this.hasLook = p.hasLook;
|
||||
}
|
||||
else if(version == ServerVersion.v_1_8_3) {
|
||||
WrappedPacketPlayInFlying_1_8_3.WrappedPacketPlayInPosition_1_8_3 p
|
||||
= new WrappedPacketPlayInFlying_1_8_3.WrappedPacketPlayInPosition_1_8_3(packet);
|
||||
this.hasPos = p.hasPos;
|
||||
this.hasLook = p.hasLook;
|
||||
}
|
||||
else if(version == ServerVersion.v_1_8_8) {
|
||||
WrappedPacketPlayInFlying_1_8_8.WrappedPacketPlayInPosition_1_8_8 p
|
||||
= new WrappedPacketPlayInFlying_1_8_8.WrappedPacketPlayInPosition_1_8_8(packet);
|
||||
this.hasPos = p.hasPos;
|
||||
this.hasLook = p.hasLook;
|
||||
}
|
||||
else if(version == ServerVersion.v_1_9) {
|
||||
WrappedPacketPlayInFlying_1_9.WrappedPacketPlayInPosition_1_9 p
|
||||
= new WrappedPacketPlayInFlying_1_9.WrappedPacketPlayInPosition_1_9(packet);
|
||||
this.hasPos = p.hasPos;
|
||||
this.hasLook = p.hasLook;
|
||||
}
|
||||
else if(version == ServerVersion.v_1_9_4) {
|
||||
WrappedPacketPlayInFlying_1_9_4.WrappedPacketPlayInPosition_1_9_4 p
|
||||
= new WrappedPacketPlayInFlying_1_9_4.WrappedPacketPlayInPosition_1_9_4(packet);
|
||||
this.hasPos = p.hasPos;
|
||||
this.hasLook = p.hasLook;
|
||||
}
|
||||
else if(version == ServerVersion.v_1_10) {
|
||||
WrappedPacketPlayInFlying_1_10.WrappedPacketPlayInPosition_1_10 p
|
||||
= new WrappedPacketPlayInFlying_1_10.WrappedPacketPlayInPosition_1_10(packet);
|
||||
this.hasPos = p.hasPos;
|
||||
this.hasLook = p.hasLook;
|
||||
}
|
||||
else if(version== ServerVersion.v_1_11) {
|
||||
WrappedPacketPlayInFlying_1_11.WrappedPacketPlayInPosition_1_11 p
|
||||
= new WrappedPacketPlayInFlying_1_11.WrappedPacketPlayInPosition_1_11(packet);
|
||||
this.hasPos = p.hasPos;
|
||||
this.hasLook = p.hasLook;
|
||||
}
|
||||
else if(version == ServerVersion.v_1_12) {
|
||||
WrappedPacketPlayInFlying_1_12.WrappedPacketPlayInPosition_1_12 p
|
||||
= new WrappedPacketPlayInFlying_1_12.WrappedPacketPlayInPosition_1_12(packet);
|
||||
this.hasPos = p.hasPos;
|
||||
this.hasLook = p.hasLook;
|
||||
}
|
||||
else if(version== ServerVersion.v_1_13) {
|
||||
WrappedPacketPlayInFlying_1_13.WrappedPacketPlayInPosition_1_13 p
|
||||
= new WrappedPacketPlayInFlying_1_13.WrappedPacketPlayInPosition_1_13(packet);
|
||||
this.hasPos = p.hasPos;
|
||||
this.hasLook = p.hasLook;
|
||||
}
|
||||
else if(version == ServerVersion.v_1_13_2) {
|
||||
WrappedPacketPlayInFlying_1_13_2.WrappedPacketPlayInPosition_1_13_2 p
|
||||
= new WrappedPacketPlayInFlying_1_13_2.WrappedPacketPlayInPosition_1_13_2(packet);
|
||||
this.hasPos = p.hasPos;
|
||||
this.hasLook = p.hasLook;
|
||||
}
|
||||
else if(version == ServerVersion.v_1_14) {
|
||||
WrappedPacketPlayInFlying_1_14.WrappedPacketPlayInPosition_1_14 p
|
||||
= new WrappedPacketPlayInFlying_1_14.WrappedPacketPlayInPosition_1_14(packet);
|
||||
this.hasPos = p.hasPos;
|
||||
this.hasLook = p.hasLook;
|
||||
}
|
||||
else if(version == ServerVersion.v_1_15) {
|
||||
WrappedPacketPlayInFlying_1_15.WrappedPacketPlayInPosition_1_15 p
|
||||
= new WrappedPacketPlayInFlying_1_15.WrappedPacketPlayInPosition_1_15(packet);
|
||||
this.hasPos = p.hasPos;
|
||||
this.hasLook = p.hasLook;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
public static class WrappedPacketPlayInPosition_Look extends WrappedPacketPlayInFlying {
|
||||
|
||||
public WrappedPacketPlayInPosition_Look(Object packet) {
|
||||
super(packet);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setup() {
|
||||
if(version == ServerVersion.v_1_7_10) {
|
||||
WrappedPacketPlayInFlying_1_7_10.WrappedPacketPlayInPosition_Look_1_7_10 p
|
||||
= new WrappedPacketPlayInFlying_1_7_10.WrappedPacketPlayInPosition_Look_1_7_10(packet);
|
||||
this.x = p.x;
|
||||
this.y = p.y;
|
||||
this.z = p.z;
|
||||
this.yaw = p.yaw;
|
||||
this.pitch = p.pitch;
|
||||
this.f = p.f;
|
||||
this.hasPos = p.hasPos;
|
||||
this.hasLook = p.hasLook;
|
||||
}
|
||||
else if(version == ServerVersion.v_1_8) {
|
||||
WrappedPacketPlayInFlying_1_8.WrappedPacketPlayInPosition_Look_1_8 p
|
||||
= new WrappedPacketPlayInFlying_1_8.WrappedPacketPlayInPosition_Look_1_8(packet);
|
||||
this.x = p.x;
|
||||
this.y = p.y;
|
||||
this.z = p.z;
|
||||
this.yaw = p.yaw;
|
||||
this.pitch = p.pitch;
|
||||
this.f = p.f;
|
||||
this.hasPos = p.hasPos;
|
||||
this.hasLook = p.hasLook;
|
||||
}
|
||||
else if(version == ServerVersion.v_1_8_3) {
|
||||
WrappedPacketPlayInFlying_1_8_3.WrappedPacketPlayInPosition_Look_1_8_3 p
|
||||
= new WrappedPacketPlayInFlying_1_8_3.WrappedPacketPlayInPosition_Look_1_8_3(packet);
|
||||
this.x = p.x;
|
||||
this.y = p.y;
|
||||
this.z = p.z;
|
||||
this.yaw = p.yaw;
|
||||
this.pitch = p.pitch;
|
||||
this.f = p.f;
|
||||
this.hasPos = p.hasPos;
|
||||
this.hasLook = p.hasLook;
|
||||
}
|
||||
else if(version == ServerVersion.v_1_8_8) {
|
||||
WrappedPacketPlayInFlying_1_8_8.WrappedPacketPlayInPosition_Look_1_8_8 p
|
||||
= new WrappedPacketPlayInFlying_1_8_8.WrappedPacketPlayInPosition_Look_1_8_8(packet);
|
||||
this.x = p.x;
|
||||
this.y = p.y;
|
||||
this.z = p.z;
|
||||
this.yaw = p.yaw;
|
||||
this.pitch = p.pitch;
|
||||
this.f = p.f;
|
||||
this.hasPos = p.hasPos;
|
||||
this.hasLook = p.hasLook;
|
||||
}
|
||||
else if(version == ServerVersion.v_1_9) {
|
||||
WrappedPacketPlayInFlying_1_9.WrappedPacketPlayInPosition_Look_1_9 p
|
||||
= new WrappedPacketPlayInFlying_1_9.WrappedPacketPlayInPosition_Look_1_9(packet);
|
||||
this.x = p.x;
|
||||
this.y = p.y;
|
||||
this.z = p.z;
|
||||
this.yaw = p.yaw;
|
||||
this.pitch = p.pitch;
|
||||
this.f = p.f;
|
||||
this.hasPos = p.hasPos;
|
||||
this.hasLook = p.hasLook;
|
||||
}
|
||||
else if(version == ServerVersion.v_1_9_4) {
|
||||
WrappedPacketPlayInFlying_1_9_4.WrappedPacketPlayInPosition_Look_1_9_4 p
|
||||
= new WrappedPacketPlayInFlying_1_9_4.WrappedPacketPlayInPosition_Look_1_9_4(packet);
|
||||
this.x = p.x;
|
||||
this.y = p.y;
|
||||
this.z = p.z;
|
||||
this.yaw = p.yaw;
|
||||
this.pitch = p.pitch;
|
||||
this.f = p.f;
|
||||
this.hasPos = p.hasPos;
|
||||
this.hasLook = p.hasLook;
|
||||
}
|
||||
else if(version == ServerVersion.v_1_10) {
|
||||
WrappedPacketPlayInFlying_1_10.WrappedPacketPlayInPosition_Look_1_10 p
|
||||
= new WrappedPacketPlayInFlying_1_10.WrappedPacketPlayInPosition_Look_1_10(packet);
|
||||
this.x = p.x;
|
||||
this.y = p.y;
|
||||
this.z = p.z;
|
||||
this.yaw = p.yaw;
|
||||
this.pitch = p.pitch;
|
||||
this.f = p.f;
|
||||
this.hasPos = p.hasPos;
|
||||
this.hasLook = p.hasLook;
|
||||
}
|
||||
else if(version== ServerVersion.v_1_11) {
|
||||
WrappedPacketPlayInFlying_1_11.WrappedPacketPlayInPosition_Look_1_11 p
|
||||
= new WrappedPacketPlayInFlying_1_11.WrappedPacketPlayInPosition_Look_1_11(packet);
|
||||
this.x = p.x;
|
||||
this.y = p.y;
|
||||
this.z = p.z;
|
||||
this.yaw = p.yaw;
|
||||
this.pitch = p.pitch;
|
||||
this.f = p.f;
|
||||
this.hasPos = p.hasPos;
|
||||
this.hasLook = p.hasLook;
|
||||
}
|
||||
else if(version == ServerVersion.v_1_12) {
|
||||
WrappedPacketPlayInFlying_1_12.WrappedPacketPlayInPosition_Look_1_12 p
|
||||
= new WrappedPacketPlayInFlying_1_12.WrappedPacketPlayInPosition_Look_1_12(packet);
|
||||
this.x = p.x;
|
||||
this.y = p.y;
|
||||
this.z = p.z;
|
||||
this.yaw = p.yaw;
|
||||
this.pitch = p.pitch;
|
||||
this.f = p.f;
|
||||
this.hasPos = p.hasPos;
|
||||
this.hasLook = p.hasLook;
|
||||
}
|
||||
else if(version== ServerVersion.v_1_13) {
|
||||
WrappedPacketPlayInFlying_1_13.WrappedPacketPlayInPosition_Look_1_13 p
|
||||
= new WrappedPacketPlayInFlying_1_13.WrappedPacketPlayInPosition_Look_1_13(packet);
|
||||
this.x = p.x;
|
||||
this.y = p.y;
|
||||
this.z = p.z;
|
||||
this.yaw = p.yaw;
|
||||
this.pitch = p.pitch;
|
||||
this.f = p.f;
|
||||
this.hasPos = p.hasPos;
|
||||
this.hasLook = p.hasLook;
|
||||
}
|
||||
else if(version == ServerVersion.v_1_13_2) {
|
||||
WrappedPacketPlayInFlying_1_13_2.WrappedPacketPlayInPosition_Look_1_13_2 p
|
||||
= new WrappedPacketPlayInFlying_1_13_2.WrappedPacketPlayInPosition_Look_1_13_2(packet);
|
||||
this.x = p.x;
|
||||
this.y = p.y;
|
||||
this.z = p.z;
|
||||
this.yaw = p.yaw;
|
||||
this.pitch = p.pitch;
|
||||
this.f = p.f;
|
||||
this.hasPos = p.hasPos;
|
||||
this.hasLook = p.hasLook;
|
||||
}
|
||||
else if(version == ServerVersion.v_1_14) {
|
||||
WrappedPacketPlayInFlying_1_14.WrappedPacketPlayInPosition_Look_1_14 p
|
||||
= new WrappedPacketPlayInFlying_1_14.WrappedPacketPlayInPosition_Look_1_14(packet);
|
||||
this.x = p.x;
|
||||
this.y = p.y;
|
||||
this.z = p.z;
|
||||
this.yaw = p.yaw;
|
||||
this.pitch = p.pitch;
|
||||
this.f = p.f;
|
||||
this.hasPos = p.hasPos;
|
||||
this.hasLook = p.hasLook;
|
||||
}
|
||||
else if(version == ServerVersion.v_1_15) {
|
||||
WrappedPacketPlayInFlying_1_15.WrappedPacketPlayInPosition_Look_1_15 p
|
||||
= new WrappedPacketPlayInFlying_1_15.WrappedPacketPlayInPosition_Look_1_15(packet);
|
||||
this.x = p.x;
|
||||
this.y = p.y;
|
||||
this.z = p.z;
|
||||
this.yaw = p.yaw;
|
||||
this.pitch = p.pitch;
|
||||
this.f = p.f;
|
||||
this.hasPos = p.hasPos;
|
||||
this.hasLook = p.hasLook;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
-95
@@ -1,95 +0,0 @@
|
||||
package me.purplex.packetevents.packetwrappers.in;
|
||||
|
||||
import me.purplex.packetevents.enums.EntityUseAction;
|
||||
import me.purplex.packetevents.enums.ServerVersion;
|
||||
import me.purplex.packetevents.packetwrappers.api.WrappedPacket;
|
||||
import me.purplex.packetevents.packetwrappers.in._1_10.WrappedPacketPlayInUseEntity_1_10;
|
||||
import me.purplex.packetevents.packetwrappers.in._1_11.WrappedPacketPlayInUseEntity_1_11;
|
||||
import me.purplex.packetevents.packetwrappers.in._1_12.WrappedPacketPlayInUseEntity_1_12;
|
||||
import me.purplex.packetevents.packetwrappers.in._1_13.WrappedPacketPlayInUseEntity_1_13;
|
||||
import me.purplex.packetevents.packetwrappers.in._1_13_2.WrappedPacketPlayInUseEntity_1_13_2;
|
||||
import me.purplex.packetevents.packetwrappers.in._1_14.WrappedPacketPlayInUseEntity_1_14;
|
||||
import me.purplex.packetevents.packetwrappers.in._1_15.WrappedPacketPlayInUseEntity_1_15;
|
||||
import me.purplex.packetevents.packetwrappers.in._1_7_10.WrappedPacketPlayInUseEntity_1_7_10;
|
||||
import me.purplex.packetevents.packetwrappers.in._1_8.WrappedPacketPlayInUseEntity_1_8;
|
||||
import me.purplex.packetevents.packetwrappers.in._1_8_3.WrappedPacketPlayInUseEntity_1_8_3;
|
||||
import me.purplex.packetevents.packetwrappers.in._1_8_8.WrappedPacketPlayInUseEntity_1_8_8;
|
||||
import me.purplex.packetevents.packetwrappers.in._1_9.WrappedPacketPlayInUseEntity_1_9;
|
||||
import me.purplex.packetevents.packetwrappers.in._1_9_4.WrappedPacketPlayInUseEntity_1_9_4;
|
||||
import org.bukkit.entity.Entity;
|
||||
|
||||
public class WrappedPacketPlayInUseEntity extends WrappedPacket {
|
||||
|
||||
private Entity entity;
|
||||
private EntityUseAction action;
|
||||
|
||||
public WrappedPacketPlayInUseEntity(Object packet) {
|
||||
super(packet);
|
||||
}
|
||||
|
||||
public Entity getEntity() {
|
||||
return entity;
|
||||
}
|
||||
|
||||
public EntityUseAction getEntityUseAction() {
|
||||
return action;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setup() {
|
||||
if(version == ServerVersion.v_1_7_10) {
|
||||
WrappedPacketPlayInUseEntity_1_7_10 p = new WrappedPacketPlayInUseEntity_1_7_10(packet);
|
||||
this.entity = p.getEntity();
|
||||
this.action = p.getEntityUseAction();
|
||||
}
|
||||
else if (version == ServerVersion.v_1_8) {
|
||||
WrappedPacketPlayInUseEntity_1_8 p = new WrappedPacketPlayInUseEntity_1_8(packet);
|
||||
this.entity = p.getEntity();
|
||||
this.action = p.getEntityUseAction();
|
||||
} else if (version == ServerVersion.v_1_8_3) {
|
||||
WrappedPacketPlayInUseEntity_1_8_3 p = new WrappedPacketPlayInUseEntity_1_8_3(packet);
|
||||
this.entity = p.getEntity();
|
||||
this.action = p.getEntityUseAction();
|
||||
} else if (version == ServerVersion.v_1_8_8) {
|
||||
WrappedPacketPlayInUseEntity_1_8_8 p = new WrappedPacketPlayInUseEntity_1_8_8(packet);
|
||||
this.entity = p.getEntity();
|
||||
this.action = p.getEntityUseAction();
|
||||
} else if (version == ServerVersion.v_1_9) {
|
||||
WrappedPacketPlayInUseEntity_1_9 p = new WrappedPacketPlayInUseEntity_1_9(packet);
|
||||
this.entity = p.getEntity();
|
||||
this.action = p.getEntityUseAction();
|
||||
} else if (version == ServerVersion.v_1_9_4) {
|
||||
WrappedPacketPlayInUseEntity_1_9_4 p = new WrappedPacketPlayInUseEntity_1_9_4(packet);
|
||||
this.entity = p.getEntity();
|
||||
this.action = p.getEntityUseAction();
|
||||
} else if (version == ServerVersion.v_1_10) {
|
||||
WrappedPacketPlayInUseEntity_1_10 p = new WrappedPacketPlayInUseEntity_1_10(packet);
|
||||
this.entity = p.getEntity();
|
||||
this.action = p.getEntityUseAction();
|
||||
} else if (version == ServerVersion.v_1_11) {
|
||||
WrappedPacketPlayInUseEntity_1_11 p = new WrappedPacketPlayInUseEntity_1_11(packet);
|
||||
this.entity = p.getEntity();
|
||||
this.action = p.getEntityUseAction();
|
||||
} else if (version == ServerVersion.v_1_12) {
|
||||
WrappedPacketPlayInUseEntity_1_12 p = new WrappedPacketPlayInUseEntity_1_12(packet);
|
||||
this.entity = p.getEntity();
|
||||
this.action = p.getEntityUseAction();
|
||||
} else if (version == ServerVersion.v_1_13) {
|
||||
WrappedPacketPlayInUseEntity_1_13 p = new WrappedPacketPlayInUseEntity_1_13(packet);
|
||||
this.entity = p.getEntity();
|
||||
this.action = p.getEntityUseAction();
|
||||
} else if (version == ServerVersion.v_1_13_2) {
|
||||
WrappedPacketPlayInUseEntity_1_13_2 p = new WrappedPacketPlayInUseEntity_1_13_2(packet);
|
||||
this.entity = p.getEntity();
|
||||
this.action = p.getEntityUseAction();
|
||||
} else if (version == ServerVersion.v_1_14) {
|
||||
WrappedPacketPlayInUseEntity_1_14 p = new WrappedPacketPlayInUseEntity_1_14(packet);
|
||||
this.entity = p.getEntity();
|
||||
this.action = p.getEntityUseAction();
|
||||
} else if (version == ServerVersion.v_1_15) {
|
||||
WrappedPacketPlayInUseEntity_1_15 p = new WrappedPacketPlayInUseEntity_1_15(packet);
|
||||
this.entity = p.getEntity();
|
||||
this.action = p.getEntityUseAction();
|
||||
}
|
||||
}
|
||||
}
|
||||
-52
@@ -1,52 +0,0 @@
|
||||
package me.purplex.packetevents.packetwrappers.in._1_10;
|
||||
|
||||
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 boolean a;
|
||||
public boolean b;
|
||||
public boolean c;
|
||||
public boolean d;
|
||||
public float e;
|
||||
public float f;
|
||||
}
|
||||
-21
@@ -1,21 +0,0 @@
|
||||
package me.purplex.packetevents.packetwrappers.in._1_10;
|
||||
|
||||
import me.purplex.packetevents.enums.PlayerDigType;
|
||||
import net.minecraft.server.v1_10_R1.PacketPlayInBlockDig;
|
||||
|
||||
public class WrappedPacketPlayInBlockDig_1_10 {
|
||||
private final Object packet;
|
||||
public WrappedPacketPlayInBlockDig_1_10(Object packet) {
|
||||
this.packet = packet;
|
||||
setupDigType();
|
||||
}
|
||||
|
||||
private void setupDigType() {
|
||||
PacketPlayInBlockDig p = (PacketPlayInBlockDig)packet;
|
||||
String name = p.c().name();
|
||||
this.digType = PlayerDigType.valueOf(name);
|
||||
}
|
||||
|
||||
public PlayerDigType digType;
|
||||
|
||||
}
|
||||
-122
@@ -1,122 +0,0 @@
|
||||
package me.purplex.packetevents.packetwrappers.in._1_10;
|
||||
|
||||
import net.minecraft.server.v1_10_R1.PacketPlayInFlying;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
|
||||
public class WrappedPacketPlayInFlying_1_10 {
|
||||
private final Object packet;
|
||||
|
||||
public double x;
|
||||
public double y;
|
||||
public double z;
|
||||
public float yaw;
|
||||
public float pitch;
|
||||
public boolean f;
|
||||
public boolean hasPos;
|
||||
public boolean hasLook;
|
||||
public WrappedPacketPlayInFlying_1_10(Object packet) {
|
||||
this.packet = packet;
|
||||
try {
|
||||
setupFields();
|
||||
} 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);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
this.f = p.a();
|
||||
}
|
||||
|
||||
public static class WrappedPacketPlayInPosition_1_10 extends WrappedPacketPlayInFlying_1_10 {
|
||||
|
||||
public WrappedPacketPlayInPosition_1_10(Object packet) {
|
||||
super(packet);
|
||||
this.hasPos = true;
|
||||
}
|
||||
}
|
||||
|
||||
public static class WrappedPacketPlayInPosition_Look_1_10 extends WrappedPacketPlayInFlying_1_10 {
|
||||
|
||||
public WrappedPacketPlayInPosition_Look_1_10(Object packet) {
|
||||
super(packet);
|
||||
this.hasLook = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private static Field fieldHasPos;
|
||||
private static Field fieldHasLook;
|
||||
private static Field fieldX;
|
||||
private static Field fieldY;
|
||||
private static Field fieldZ;
|
||||
private static Field fieldYaw;
|
||||
private static Field fieldPitch;
|
||||
|
||||
static {
|
||||
try {
|
||||
fieldHasPos = PacketPlayInFlying.class.getDeclaredField("hasPos");
|
||||
} catch (NoSuchFieldException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
try {
|
||||
fieldHasLook = PacketPlayInFlying.class.getDeclaredField("hasLook");
|
||||
} catch (NoSuchFieldException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
try {
|
||||
fieldX = PacketPlayInFlying.class.getDeclaredField("x");
|
||||
} catch (NoSuchFieldException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
try {
|
||||
fieldY = PacketPlayInFlying.class.getDeclaredField("y");
|
||||
} catch (NoSuchFieldException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
try {
|
||||
fieldZ = PacketPlayInFlying.class.getDeclaredField("z");
|
||||
} catch (NoSuchFieldException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
try {
|
||||
fieldYaw = PacketPlayInFlying.class.getDeclaredField("yaw");
|
||||
} catch (NoSuchFieldException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
try {
|
||||
fieldPitch = PacketPlayInFlying.class.getDeclaredField("pitch");
|
||||
} catch (NoSuchFieldException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
-54
@@ -1,54 +0,0 @@
|
||||
package me.purplex.packetevents.packetwrappers.in._1_10;
|
||||
|
||||
import me.purplex.packetevents.enums.EntityUseAction;
|
||||
import me.purplex.packetevents.enums.ServerVersion;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.entity.Entity;
|
||||
|
||||
public class WrappedPacketPlayInUseEntity_1_10 {
|
||||
private final ServerVersion version;
|
||||
private Entity entity;
|
||||
private EntityUseAction action;
|
||||
private final Object packet;
|
||||
|
||||
public WrappedPacketPlayInUseEntity_1_10(Object packet) {
|
||||
this.version = ServerVersion.getVersion();
|
||||
this.packet = packet;
|
||||
setupEntity();
|
||||
setupAction();
|
||||
}
|
||||
|
||||
private Object getRawPacket() {
|
||||
return this.packet;
|
||||
}
|
||||
|
||||
public Entity getEntity() {
|
||||
return entity;
|
||||
}
|
||||
|
||||
public EntityUseAction getEntityUseAction() {
|
||||
return action;
|
||||
}
|
||||
|
||||
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;
|
||||
for (World bukkitWorld : Bukkit.getWorlds()) {
|
||||
org.bukkit.craftbukkit.v1_10_R1.CraftWorld craftWorld = (org.bukkit.craftbukkit.v1_10_R1.CraftWorld) bukkitWorld;
|
||||
worldServer = craftWorld.getHandle();
|
||||
if (packet.a(worldServer) != null) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
net.minecraft.server.v1_10_R1.Entity entity = packet.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();
|
||||
this.action = EntityUseAction.valueOf(name);
|
||||
}
|
||||
}
|
||||
-52
@@ -1,52 +0,0 @@
|
||||
package me.purplex.packetevents.packetwrappers.in._1_11;
|
||||
|
||||
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 boolean a;
|
||||
public boolean b;
|
||||
public boolean c;
|
||||
public boolean d;
|
||||
public float e;
|
||||
public float f;
|
||||
}
|
||||
-21
@@ -1,21 +0,0 @@
|
||||
package me.purplex.packetevents.packetwrappers.in._1_11;
|
||||
|
||||
import me.purplex.packetevents.enums.PlayerDigType;
|
||||
import net.minecraft.server.v1_11_R1.PacketPlayInBlockDig;
|
||||
|
||||
public class WrappedPacketPlayInBlockDig_1_11 {
|
||||
private final Object packet;
|
||||
public WrappedPacketPlayInBlockDig_1_11(Object packet) {
|
||||
this.packet = packet;
|
||||
setupDigType();
|
||||
}
|
||||
|
||||
private void setupDigType() {
|
||||
PacketPlayInBlockDig p = (PacketPlayInBlockDig)packet;
|
||||
String name = p.c().name();
|
||||
this.digType = PlayerDigType.valueOf(name);
|
||||
}
|
||||
|
||||
public PlayerDigType digType;
|
||||
|
||||
}
|
||||
-123
@@ -1,123 +0,0 @@
|
||||
package me.purplex.packetevents.packetwrappers.in._1_11;
|
||||
|
||||
import net.minecraft.server.v1_11_R1.PacketPlayInFlying;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
|
||||
public class WrappedPacketPlayInFlying_1_11 {
|
||||
private final Object packet;
|
||||
|
||||
public double x;
|
||||
public double y;
|
||||
public double z;
|
||||
public float yaw;
|
||||
public float pitch;
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
this.f = p.a();
|
||||
}
|
||||
|
||||
public static class WrappedPacketPlayInPosition_1_11 extends WrappedPacketPlayInFlying_1_11{
|
||||
|
||||
public WrappedPacketPlayInPosition_1_11(Object packet) {
|
||||
super(packet);
|
||||
this.hasPos = true;
|
||||
}
|
||||
}
|
||||
|
||||
public static class WrappedPacketPlayInPosition_Look_1_11 extends WrappedPacketPlayInFlying_1_11 {
|
||||
|
||||
public WrappedPacketPlayInPosition_Look_1_11(Object packet) {
|
||||
super(packet);
|
||||
this.hasLook = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private static Field fieldHasPos;
|
||||
private static Field fieldHasLook;
|
||||
private static Field fieldX;
|
||||
private static Field fieldY;
|
||||
private static Field fieldZ;
|
||||
private static Field fieldYaw;
|
||||
private static Field fieldPitch;
|
||||
|
||||
static {
|
||||
try {
|
||||
fieldHasPos = PacketPlayInFlying.class.getDeclaredField("hasPos");
|
||||
} catch (NoSuchFieldException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
try {
|
||||
fieldHasLook = PacketPlayInFlying.class.getDeclaredField("hasLook");
|
||||
} catch (NoSuchFieldException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
try {
|
||||
fieldX = PacketPlayInFlying.class.getDeclaredField("x");
|
||||
} catch (NoSuchFieldException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
try {
|
||||
fieldY = PacketPlayInFlying.class.getDeclaredField("y");
|
||||
} catch (NoSuchFieldException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
try {
|
||||
fieldZ = PacketPlayInFlying.class.getDeclaredField("z");
|
||||
} catch (NoSuchFieldException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
try {
|
||||
fieldYaw = PacketPlayInFlying.class.getDeclaredField("yaw");
|
||||
} catch (NoSuchFieldException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
try {
|
||||
fieldPitch = PacketPlayInFlying.class.getDeclaredField("pitch");
|
||||
} catch (NoSuchFieldException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
-54
@@ -1,54 +0,0 @@
|
||||
package me.purplex.packetevents.packetwrappers.in._1_11;
|
||||
|
||||
import me.purplex.packetevents.enums.EntityUseAction;
|
||||
import me.purplex.packetevents.enums.ServerVersion;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.entity.Entity;
|
||||
|
||||
public class WrappedPacketPlayInUseEntity_1_11 {
|
||||
private final ServerVersion version;
|
||||
private Entity entity;
|
||||
private EntityUseAction action;
|
||||
private final Object packet;
|
||||
|
||||
public WrappedPacketPlayInUseEntity_1_11(Object packet) {
|
||||
this.version = ServerVersion.getVersion();
|
||||
this.packet = packet;
|
||||
setupEntity();
|
||||
setupAction();
|
||||
}
|
||||
|
||||
private Object getRawPacket() {
|
||||
return this.packet;
|
||||
}
|
||||
|
||||
public Entity getEntity() {
|
||||
return entity;
|
||||
}
|
||||
|
||||
public EntityUseAction getEntityUseAction() {
|
||||
return action;
|
||||
}
|
||||
|
||||
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;
|
||||
for (World bukkitWorld : Bukkit.getWorlds()) {
|
||||
org.bukkit.craftbukkit.v1_11_R1.CraftWorld craftWorld = (org.bukkit.craftbukkit.v1_11_R1.CraftWorld) bukkitWorld;
|
||||
worldServer = craftWorld.getHandle();
|
||||
if (packet.a(worldServer) != null) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
net.minecraft.server.v1_11_R1.Entity entity = packet.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();
|
||||
this.action = EntityUseAction.valueOf(name);
|
||||
}
|
||||
}
|
||||
-52
@@ -1,52 +0,0 @@
|
||||
package me.purplex.packetevents.packetwrappers.in._1_12;
|
||||
|
||||
import net.minecraft.server.v1_12_R1.PacketPlayInAbilities;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
|
||||
public class WrappedPacketPlayInAbilities_1_12 {
|
||||
private final Object packet;
|
||||
|
||||
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();
|
||||
}
|
||||
|
||||
|
||||
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 boolean a;
|
||||
public boolean b;
|
||||
public boolean c;
|
||||
public boolean d;
|
||||
public float e;
|
||||
public float f;
|
||||
}
|
||||
-21
@@ -1,21 +0,0 @@
|
||||
package me.purplex.packetevents.packetwrappers.in._1_12;
|
||||
|
||||
import me.purplex.packetevents.enums.PlayerDigType;
|
||||
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 PlayerDigType digType;
|
||||
|
||||
}
|
||||
-122
@@ -1,122 +0,0 @@
|
||||
package me.purplex.packetevents.packetwrappers.in._1_12;
|
||||
|
||||
import net.minecraft.server.v1_12_R1.PacketPlayInFlying;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
|
||||
public class WrappedPacketPlayInFlying_1_12 {
|
||||
private final Object packet;
|
||||
|
||||
public double x;
|
||||
public double y;
|
||||
public double z;
|
||||
public float yaw;
|
||||
public float pitch;
|
||||
public boolean f;
|
||||
public boolean hasPos;
|
||||
public boolean hasLook;
|
||||
public WrappedPacketPlayInFlying_1_12(Object packet) {
|
||||
this.packet = packet;
|
||||
try {
|
||||
setupFields();
|
||||
} 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);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
this.f = p.a();
|
||||
}
|
||||
|
||||
public static class WrappedPacketPlayInPosition_1_12 extends WrappedPacketPlayInFlying_1_12 {
|
||||
|
||||
public WrappedPacketPlayInPosition_1_12(Object packet) {
|
||||
super(packet);
|
||||
this.hasPos = true;
|
||||
}
|
||||
}
|
||||
|
||||
public static class WrappedPacketPlayInPosition_Look_1_12 extends WrappedPacketPlayInFlying_1_12 {
|
||||
|
||||
public WrappedPacketPlayInPosition_Look_1_12(Object packet) {
|
||||
super(packet);
|
||||
this.hasLook = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private static Field fieldHasPos;
|
||||
private static Field fieldHasLook;
|
||||
private static Field fieldX;
|
||||
private static Field fieldY;
|
||||
private static Field fieldZ;
|
||||
private static Field fieldYaw;
|
||||
private static Field fieldPitch;
|
||||
|
||||
static {
|
||||
try {
|
||||
fieldHasPos = PacketPlayInFlying.class.getDeclaredField("hasPos");
|
||||
} catch (NoSuchFieldException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
try {
|
||||
fieldHasLook = PacketPlayInFlying.class.getDeclaredField("hasLook");
|
||||
} catch (NoSuchFieldException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
try {
|
||||
fieldX = PacketPlayInFlying.class.getDeclaredField("x");
|
||||
} catch (NoSuchFieldException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
try {
|
||||
fieldY = PacketPlayInFlying.class.getDeclaredField("y");
|
||||
} catch (NoSuchFieldException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
try {
|
||||
fieldZ = PacketPlayInFlying.class.getDeclaredField("z");
|
||||
} catch (NoSuchFieldException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
try {
|
||||
fieldYaw = PacketPlayInFlying.class.getDeclaredField("yaw");
|
||||
} catch (NoSuchFieldException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
try {
|
||||
fieldPitch = PacketPlayInFlying.class.getDeclaredField("pitch");
|
||||
} catch (NoSuchFieldException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
-54
@@ -1,54 +0,0 @@
|
||||
package me.purplex.packetevents.packetwrappers.in._1_12;
|
||||
|
||||
import me.purplex.packetevents.enums.EntityUseAction;
|
||||
import me.purplex.packetevents.enums.ServerVersion;
|
||||
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;
|
||||
private EntityUseAction action;
|
||||
private final Object packet;
|
||||
|
||||
public WrappedPacketPlayInUseEntity_1_12(Object packet) {
|
||||
this.version = ServerVersion.getVersion();
|
||||
this.packet = packet;
|
||||
setupEntity();
|
||||
setupAction();
|
||||
}
|
||||
|
||||
private Object getRawPacket() {
|
||||
return this.packet;
|
||||
}
|
||||
|
||||
public Entity getEntity() {
|
||||
return entity;
|
||||
}
|
||||
|
||||
public EntityUseAction getEntityUseAction() {
|
||||
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;
|
||||
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) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
net.minecraft.server.v1_12_R1.Entity entity = packet.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();
|
||||
this.action = EntityUseAction.valueOf(name);
|
||||
}
|
||||
}
|
||||
-52
@@ -1,52 +0,0 @@
|
||||
package me.purplex.packetevents.packetwrappers.in._1_13;
|
||||
|
||||
import net.minecraft.server.v1_13_R1.PacketPlayInAbilities;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
|
||||
public class WrappedPacketPlayInAbilities_1_13 {
|
||||
private final Object packet;
|
||||
|
||||
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();
|
||||
}
|
||||
|
||||
|
||||
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 boolean a;
|
||||
public boolean b;
|
||||
public boolean c;
|
||||
public boolean d;
|
||||
public float e;
|
||||
public float f;
|
||||
}
|
||||
-21
@@ -1,21 +0,0 @@
|
||||
package me.purplex.packetevents.packetwrappers.in._1_13;
|
||||
|
||||
import me.purplex.packetevents.enums.PlayerDigType;
|
||||
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();
|
||||
}
|
||||
|
||||
private void setupDigType() {
|
||||
PacketPlayInBlockDig p = (PacketPlayInBlockDig)packet;
|
||||
String name = p.d().name();
|
||||
this.digType = PlayerDigType.valueOf(name);
|
||||
}
|
||||
|
||||
public PlayerDigType digType;
|
||||
|
||||
}
|
||||
-122
@@ -1,122 +0,0 @@
|
||||
package me.purplex.packetevents.packetwrappers.in._1_13;
|
||||
|
||||
import net.minecraft.server.v1_13_R1.PacketPlayInFlying;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
|
||||
public class WrappedPacketPlayInFlying_1_13 {
|
||||
private final Object packet;
|
||||
|
||||
public double x;
|
||||
public double y;
|
||||
public double z;
|
||||
public float yaw;
|
||||
public float pitch;
|
||||
public boolean f;
|
||||
public boolean hasPos;
|
||||
public boolean hasLook;
|
||||
public WrappedPacketPlayInFlying_1_13(Object packet) {
|
||||
this.packet = packet;
|
||||
try {
|
||||
setupFields();
|
||||
} 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);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
this.f = p.a();
|
||||
}
|
||||
|
||||
public static class WrappedPacketPlayInPosition_1_13 extends WrappedPacketPlayInFlying_1_13{
|
||||
|
||||
public WrappedPacketPlayInPosition_1_13(Object packet) {
|
||||
super(packet);
|
||||
this.hasPos = true;
|
||||
}
|
||||
}
|
||||
|
||||
public static class WrappedPacketPlayInPosition_Look_1_13 extends WrappedPacketPlayInFlying_1_13 {
|
||||
|
||||
public WrappedPacketPlayInPosition_Look_1_13(Object packet) {
|
||||
super(packet);
|
||||
this.hasLook = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private static Field fieldHasPos;
|
||||
private static Field fieldHasLook;
|
||||
private static Field fieldX;
|
||||
private static Field fieldY;
|
||||
private static Field fieldZ;
|
||||
private static Field fieldYaw;
|
||||
private static Field fieldPitch;
|
||||
|
||||
static {
|
||||
try {
|
||||
fieldHasPos = PacketPlayInFlying.class.getDeclaredField("hasPos");
|
||||
} catch (NoSuchFieldException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
try {
|
||||
fieldHasLook = PacketPlayInFlying.class.getDeclaredField("hasLook");
|
||||
} catch (NoSuchFieldException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
try {
|
||||
fieldX = PacketPlayInFlying.class.getDeclaredField("x");
|
||||
} catch (NoSuchFieldException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
try {
|
||||
fieldY = PacketPlayInFlying.class.getDeclaredField("y");
|
||||
} catch (NoSuchFieldException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
try {
|
||||
fieldZ = PacketPlayInFlying.class.getDeclaredField("z");
|
||||
} catch (NoSuchFieldException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
try {
|
||||
fieldYaw = PacketPlayInFlying.class.getDeclaredField("yaw");
|
||||
} catch (NoSuchFieldException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
try {
|
||||
fieldPitch = PacketPlayInFlying.class.getDeclaredField("pitch");
|
||||
} catch (NoSuchFieldException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
-57
@@ -1,57 +0,0 @@
|
||||
package me.purplex.packetevents.packetwrappers.in._1_13;
|
||||
|
||||
import me.purplex.packetevents.enums.EntityUseAction;
|
||||
import me.purplex.packetevents.enums.ServerVersion;
|
||||
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;
|
||||
private EntityUseAction action;
|
||||
private final Object packet;
|
||||
|
||||
public WrappedPacketPlayInUseEntity_1_13(Object packet) {
|
||||
this.version = ServerVersion.getVersion();
|
||||
this.packet = packet;
|
||||
setupEntity();
|
||||
setupAction();
|
||||
}
|
||||
|
||||
private Object getRawPacket() {
|
||||
return this.packet;
|
||||
}
|
||||
|
||||
public Entity getEntity() {
|
||||
return entity;
|
||||
}
|
||||
|
||||
public EntityUseAction getEntityUseAction() {
|
||||
return action;
|
||||
}
|
||||
|
||||
private void setupEntity() {
|
||||
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;
|
||||
}
|
||||
}
|
||||
net.minecraft.server.v1_13_R1.Entity entity = packet.a(worldServer);
|
||||
this.entity = entity.getBukkitEntity();
|
||||
|
||||
}
|
||||
|
||||
private void setupAction() {
|
||||
PacketPlayInUseEntity packet = (PacketPlayInUseEntity) getRawPacket();
|
||||
String name = packet.b().name();
|
||||
this.action = EntityUseAction.valueOf(name);
|
||||
}
|
||||
}
|
||||
-52
@@ -1,52 +0,0 @@
|
||||
package me.purplex.packetevents.packetwrappers.in._1_13_2;
|
||||
|
||||
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 boolean a;
|
||||
public boolean b;
|
||||
public boolean c;
|
||||
public boolean d;
|
||||
public float e;
|
||||
public float f;
|
||||
}
|
||||
-21
@@ -1,21 +0,0 @@
|
||||
package me.purplex.packetevents.packetwrappers.in._1_13_2;
|
||||
|
||||
import me.purplex.packetevents.enums.PlayerDigType;
|
||||
import net.minecraft.server.v1_13_R2.PacketPlayInBlockDig;
|
||||
|
||||
public class WrappedPacketPlayInBlockDig_1_13_2 {
|
||||
private final Object packet;
|
||||
public WrappedPacketPlayInBlockDig_1_13_2(Object packet) {
|
||||
this.packet = packet;
|
||||
setupDigType();
|
||||
}
|
||||
|
||||
private void setupDigType() {
|
||||
PacketPlayInBlockDig p = (PacketPlayInBlockDig)packet;
|
||||
String name = p.d().name();
|
||||
this.digType = PlayerDigType.valueOf(name);
|
||||
}
|
||||
|
||||
public PlayerDigType digType;
|
||||
|
||||
}
|
||||
-122
@@ -1,122 +0,0 @@
|
||||
package me.purplex.packetevents.packetwrappers.in._1_13_2;
|
||||
|
||||
import net.minecraft.server.v1_13_R2.PacketPlayInFlying;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
|
||||
public class WrappedPacketPlayInFlying_1_13_2 {
|
||||
private final Object packet;
|
||||
|
||||
public double x;
|
||||
public double y;
|
||||
public double z;
|
||||
public float yaw;
|
||||
public float pitch;
|
||||
public boolean f;
|
||||
public boolean hasPos;
|
||||
public boolean hasLook;
|
||||
public WrappedPacketPlayInFlying_1_13_2(Object packet) {
|
||||
this.packet = packet;
|
||||
try {
|
||||
setupFields();
|
||||
} 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);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
this.f = p.a();
|
||||
}
|
||||
|
||||
public static class WrappedPacketPlayInPosition_1_13_2 extends WrappedPacketPlayInFlying_1_13_2 {
|
||||
|
||||
public WrappedPacketPlayInPosition_1_13_2(Object packet) {
|
||||
super(packet);
|
||||
this.hasPos = true;
|
||||
}
|
||||
}
|
||||
|
||||
public static class WrappedPacketPlayInPosition_Look_1_13_2 extends WrappedPacketPlayInFlying_1_13_2 {
|
||||
|
||||
public WrappedPacketPlayInPosition_Look_1_13_2(Object packet) {
|
||||
super(packet);
|
||||
this.hasLook = true;
|
||||
}
|
||||
}
|
||||
|
||||
private static Field fieldHasPos;
|
||||
private static Field fieldHasLook;
|
||||
private static Field fieldX;
|
||||
private static Field fieldY;
|
||||
private static Field fieldZ;
|
||||
private static Field fieldYaw;
|
||||
private static Field fieldPitch;
|
||||
|
||||
static {
|
||||
try {
|
||||
fieldHasPos = PacketPlayInFlying.class.getDeclaredField("hasPos");
|
||||
} catch (NoSuchFieldException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
try {
|
||||
fieldHasLook = PacketPlayInFlying.class.getDeclaredField("hasLook");
|
||||
} catch (NoSuchFieldException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
try {
|
||||
fieldX = PacketPlayInFlying.class.getDeclaredField("x");
|
||||
} catch (NoSuchFieldException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
try {
|
||||
fieldY = PacketPlayInFlying.class.getDeclaredField("y");
|
||||
} catch (NoSuchFieldException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
try {
|
||||
fieldZ = PacketPlayInFlying.class.getDeclaredField("z");
|
||||
} catch (NoSuchFieldException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
try {
|
||||
fieldYaw = PacketPlayInFlying.class.getDeclaredField("yaw");
|
||||
} catch (NoSuchFieldException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
try {
|
||||
fieldPitch = PacketPlayInFlying.class.getDeclaredField("pitch");
|
||||
} catch (NoSuchFieldException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
-56
@@ -1,56 +0,0 @@
|
||||
package me.purplex.packetevents.packetwrappers.in._1_13_2;
|
||||
|
||||
import me.purplex.packetevents.enums.EntityUseAction;
|
||||
import me.purplex.packetevents.enums.ServerVersion;
|
||||
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;
|
||||
private EntityUseAction action;
|
||||
private final Object packet;
|
||||
|
||||
public WrappedPacketPlayInUseEntity_1_13_2(Object packet) {
|
||||
this.version = ServerVersion.getVersion();
|
||||
this.packet = packet;
|
||||
setupEntity();
|
||||
setupAction();
|
||||
}
|
||||
|
||||
private Object getRawPacket() {
|
||||
return this.packet;
|
||||
}
|
||||
|
||||
public Entity getEntity() {
|
||||
return entity;
|
||||
}
|
||||
|
||||
public EntityUseAction getEntityUseAction() {
|
||||
return action;
|
||||
}
|
||||
|
||||
private void setupEntity() {
|
||||
PacketPlayInUseEntity packet = (net.minecraft.server.v1_13_R2.PacketPlayInUseEntity) getRawPacket();
|
||||
WorldServer worldServer = null;
|
||||
for (World bukkitWorld : Bukkit.getWorlds()) {
|
||||
CraftWorld craftWorld = (CraftWorld) bukkitWorld;
|
||||
worldServer = craftWorld.getHandle();
|
||||
if (packet.a(worldServer) != null) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
net.minecraft.server.v1_13_R2.Entity entity = packet.a(worldServer);
|
||||
this.entity = entity.getBukkitEntity();
|
||||
|
||||
}
|
||||
|
||||
private void setupAction() {
|
||||
PacketPlayInUseEntity packet = (PacketPlayInUseEntity) getRawPacket();
|
||||
String name = packet.b().name();
|
||||
this.action = EntityUseAction.valueOf(name);
|
||||
}
|
||||
}
|
||||
-52
@@ -1,52 +0,0 @@
|
||||
package me.purplex.packetevents.packetwrappers.in._1_14;
|
||||
|
||||
import net.minecraft.server.v1_14_R1.PacketPlayInAbilities;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
|
||||
public class WrappedPacketPlayInAbilities_1_14 {
|
||||
private final Object packet;
|
||||
|
||||
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();
|
||||
}
|
||||
|
||||
|
||||
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 boolean a;
|
||||
public boolean b;
|
||||
public boolean c;
|
||||
public boolean d;
|
||||
public float e;
|
||||
public float f;
|
||||
}
|
||||
-21
@@ -1,21 +0,0 @@
|
||||
package me.purplex.packetevents.packetwrappers.in._1_14;
|
||||
|
||||
import me.purplex.packetevents.enums.PlayerDigType;
|
||||
import net.minecraft.server.v1_14_R1.PacketPlayInBlockDig;
|
||||
|
||||
public class WrappedPacketPlayInBlockDig_1_14 {
|
||||
private final Object packet;
|
||||
public WrappedPacketPlayInBlockDig_1_14(Object packet) {
|
||||
this.packet = packet;
|
||||
setupDigType();
|
||||
}
|
||||
|
||||
private void setupDigType() {
|
||||
PacketPlayInBlockDig p = (PacketPlayInBlockDig)packet;
|
||||
String name = p.d().name();
|
||||
this.digType = PlayerDigType.valueOf(name);
|
||||
}
|
||||
|
||||
public PlayerDigType digType;
|
||||
|
||||
}
|
||||
-123
@@ -1,123 +0,0 @@
|
||||
package me.purplex.packetevents.packetwrappers.in._1_14;
|
||||
|
||||
import net.minecraft.server.v1_14_R1.PacketPlayInFlying;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
|
||||
public class WrappedPacketPlayInFlying_1_14 {
|
||||
private final Object packet;
|
||||
|
||||
public double x;
|
||||
public double y;
|
||||
public double z;
|
||||
public float yaw;
|
||||
public float pitch;
|
||||
public boolean f;
|
||||
public boolean hasPos;
|
||||
public boolean hasLook;
|
||||
public WrappedPacketPlayInFlying_1_14(Object packet) {
|
||||
this.packet = packet;
|
||||
try {
|
||||
setupFields();
|
||||
} 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);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
this.f = p.a();
|
||||
}
|
||||
|
||||
public static class WrappedPacketPlayInPosition_1_14 extends WrappedPacketPlayInFlying_1_14 {
|
||||
|
||||
public WrappedPacketPlayInPosition_1_14(Object packet) {
|
||||
super(packet);
|
||||
this.hasPos = true;
|
||||
}
|
||||
}
|
||||
|
||||
public static class WrappedPacketPlayInPosition_Look_1_14 extends WrappedPacketPlayInFlying_1_14 {
|
||||
|
||||
public WrappedPacketPlayInPosition_Look_1_14(Object packet) {
|
||||
super(packet);
|
||||
this.hasLook = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private static Field fieldHasPos;
|
||||
private static Field fieldHasLook;
|
||||
private static Field fieldX;
|
||||
private static Field fieldY;
|
||||
private static Field fieldZ;
|
||||
private static Field fieldYaw;
|
||||
private static Field fieldPitch;
|
||||
|
||||
static {
|
||||
try {
|
||||
fieldHasPos = PacketPlayInFlying.class.getDeclaredField("hasPos");
|
||||
} catch (NoSuchFieldException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
try {
|
||||
fieldHasLook = PacketPlayInFlying.class.getDeclaredField("hasLook");
|
||||
} catch (NoSuchFieldException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
try {
|
||||
fieldX = PacketPlayInFlying.class.getDeclaredField("x");
|
||||
} catch (NoSuchFieldException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
try {
|
||||
fieldY = PacketPlayInFlying.class.getDeclaredField("y");
|
||||
} catch (NoSuchFieldException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
try {
|
||||
fieldZ = PacketPlayInFlying.class.getDeclaredField("z");
|
||||
} catch (NoSuchFieldException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
try {
|
||||
fieldYaw = PacketPlayInFlying.class.getDeclaredField("yaw");
|
||||
} catch (NoSuchFieldException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
try {
|
||||
fieldPitch = PacketPlayInFlying.class.getDeclaredField("pitch");
|
||||
} catch (NoSuchFieldException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
-56
@@ -1,56 +0,0 @@
|
||||
package me.purplex.packetevents.packetwrappers.in._1_14;
|
||||
|
||||
import me.purplex.packetevents.enums.EntityUseAction;
|
||||
import me.purplex.packetevents.enums.ServerVersion;
|
||||
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;
|
||||
|
||||
public class WrappedPacketPlayInUseEntity_1_14 {
|
||||
private final ServerVersion version;
|
||||
private Entity entity;
|
||||
private EntityUseAction action;
|
||||
private final Object packet;
|
||||
|
||||
public WrappedPacketPlayInUseEntity_1_14(Object packet) {
|
||||
this.version = ServerVersion.getVersion();
|
||||
this.packet = packet;
|
||||
setupEntity();
|
||||
setupAction();
|
||||
}
|
||||
|
||||
private Object getRawPacket() {
|
||||
return this.packet;
|
||||
}
|
||||
|
||||
public Entity getEntity() {
|
||||
return entity;
|
||||
}
|
||||
|
||||
public EntityUseAction getEntityUseAction() {
|
||||
return action;
|
||||
}
|
||||
|
||||
private void setupEntity() {
|
||||
PacketPlayInUseEntity packet = (PacketPlayInUseEntity) getRawPacket();
|
||||
WorldServer worldServer = null;
|
||||
for (World bukkitWorld : Bukkit.getWorlds()) {
|
||||
org.bukkit.craftbukkit.v1_14_R1.CraftWorld craftWorld = (org.bukkit.craftbukkit.v1_14_R1.CraftWorld) bukkitWorld;
|
||||
worldServer = craftWorld.getHandle();
|
||||
if (packet.a(worldServer) != null) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
net.minecraft.server.v1_14_R1.Entity entity = packet.a(worldServer);
|
||||
this.entity = entity.getBukkitEntity();
|
||||
|
||||
}
|
||||
|
||||
private void setupAction() {
|
||||
PacketPlayInUseEntity packet = (PacketPlayInUseEntity) getRawPacket();
|
||||
String name = packet.b().name();
|
||||
this.action = EntityUseAction.valueOf(name);
|
||||
}
|
||||
}
|
||||
-52
@@ -1,52 +0,0 @@
|
||||
package me.purplex.packetevents.packetwrappers.in._1_15;
|
||||
|
||||
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 boolean a;
|
||||
public boolean b;
|
||||
public boolean c;
|
||||
public boolean d;
|
||||
public float e;
|
||||
public float f;
|
||||
}
|
||||
-21
@@ -1,21 +0,0 @@
|
||||
package me.purplex.packetevents.packetwrappers.in._1_15;
|
||||
|
||||
import me.purplex.packetevents.enums.PlayerDigType;
|
||||
import net.minecraft.server.v1_15_R1.PacketPlayInBlockDig;
|
||||
|
||||
public class WrappedPacketPlayInBlockDig_1_15 {
|
||||
private final Object packet;
|
||||
public WrappedPacketPlayInBlockDig_1_15(Object packet) {
|
||||
this.packet = packet;
|
||||
setupDigType();
|
||||
}
|
||||
|
||||
private void setupDigType() {
|
||||
PacketPlayInBlockDig p = (PacketPlayInBlockDig)packet;
|
||||
String name = p.d().name();
|
||||
this.digType = PlayerDigType.valueOf(name);
|
||||
}
|
||||
|
||||
public PlayerDigType digType;
|
||||
|
||||
}
|
||||
-122
@@ -1,122 +0,0 @@
|
||||
package me.purplex.packetevents.packetwrappers.in._1_15;
|
||||
|
||||
import net.minecraft.server.v1_15_R1.PacketPlayInFlying;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
|
||||
public class WrappedPacketPlayInFlying_1_15 {
|
||||
private final Object packet;
|
||||
|
||||
public double x;
|
||||
public double y;
|
||||
public double z;
|
||||
public float yaw;
|
||||
public float pitch;
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
this.f = p.a();
|
||||
}
|
||||
|
||||
public static class WrappedPacketPlayInPosition_1_15 extends WrappedPacketPlayInFlying_1_15 {
|
||||
|
||||
public WrappedPacketPlayInPosition_1_15(Object packet) {
|
||||
super(packet);
|
||||
this.hasPos = true;
|
||||
}
|
||||
}
|
||||
|
||||
public static class WrappedPacketPlayInPosition_Look_1_15 extends WrappedPacketPlayInFlying_1_15 {
|
||||
|
||||
public WrappedPacketPlayInPosition_Look_1_15(Object packet) {
|
||||
super(packet);
|
||||
this.hasLook = true;
|
||||
}
|
||||
}
|
||||
|
||||
private static Field fieldHasPos;
|
||||
private static Field fieldHasLook;
|
||||
private static Field fieldX;
|
||||
private static Field fieldY;
|
||||
private static Field fieldZ;
|
||||
private static Field fieldYaw;
|
||||
private static Field fieldPitch;
|
||||
|
||||
static {
|
||||
try {
|
||||
fieldHasPos = PacketPlayInFlying.class.getDeclaredField("hasPos");
|
||||
} catch (NoSuchFieldException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
try {
|
||||
fieldHasLook = PacketPlayInFlying.class.getDeclaredField("hasLook");
|
||||
} catch (NoSuchFieldException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
try {
|
||||
fieldX = PacketPlayInFlying.class.getDeclaredField("x");
|
||||
} catch (NoSuchFieldException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
try {
|
||||
fieldY = PacketPlayInFlying.class.getDeclaredField("y");
|
||||
} catch (NoSuchFieldException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
try {
|
||||
fieldZ = PacketPlayInFlying.class.getDeclaredField("z");
|
||||
} catch (NoSuchFieldException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
try {
|
||||
fieldYaw = PacketPlayInFlying.class.getDeclaredField("yaw");
|
||||
} catch (NoSuchFieldException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
try {
|
||||
fieldPitch = PacketPlayInFlying.class.getDeclaredField("pitch");
|
||||
} catch (NoSuchFieldException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
-57
@@ -1,57 +0,0 @@
|
||||
package me.purplex.packetevents.packetwrappers.in._1_15;
|
||||
|
||||
import me.purplex.packetevents.enums.EntityUseAction;
|
||||
import me.purplex.packetevents.enums.ServerVersion;
|
||||
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;
|
||||
private EntityUseAction action;
|
||||
private final Object packet;
|
||||
|
||||
public WrappedPacketPlayInUseEntity_1_15(Object packet) {
|
||||
this.version = ServerVersion.getVersion();
|
||||
this.packet = packet;
|
||||
setupEntity();
|
||||
setupAction();
|
||||
}
|
||||
|
||||
private Object getRawPacket() {
|
||||
return this.packet;
|
||||
}
|
||||
|
||||
public Entity getEntity() {
|
||||
return entity;
|
||||
}
|
||||
|
||||
public EntityUseAction getEntityUseAction() {
|
||||
return action;
|
||||
}
|
||||
|
||||
private void setupEntity() {
|
||||
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;
|
||||
}
|
||||
}
|
||||
net.minecraft.server.v1_15_R1.Entity entity = packet.a(worldServer);
|
||||
this.entity = entity.getBukkitEntity();
|
||||
|
||||
}
|
||||
|
||||
private void setupAction() {
|
||||
PacketPlayInUseEntity packet = (PacketPlayInUseEntity) getRawPacket();
|
||||
String name = packet.b().name();
|
||||
this.action = EntityUseAction.valueOf(name);
|
||||
}
|
||||
}
|
||||
-31
@@ -1,31 +0,0 @@
|
||||
package me.purplex.packetevents.packetwrappers.in._1_7_10;
|
||||
|
||||
import net.minecraft.server.v1_7_R4.PacketPlayInAbilities;
|
||||
|
||||
|
||||
public class WrappedPacketPlayInAbilities_1_7_10 {
|
||||
private final Object packet;
|
||||
|
||||
public WrappedPacketPlayInAbilities_1_7_10(Object packet) {
|
||||
this.packet = packet;
|
||||
setupFields();
|
||||
}
|
||||
|
||||
|
||||
private void setupFields() {
|
||||
PacketPlayInAbilities p = (PacketPlayInAbilities) packet;
|
||||
this.a = p.c();
|
||||
this.b = p.isFlying();
|
||||
this.c = p.e();
|
||||
this.d = p.f();
|
||||
this.e = p.g();
|
||||
this.f = p.h();
|
||||
}
|
||||
|
||||
public boolean a;
|
||||
public boolean b;
|
||||
public boolean c;
|
||||
public boolean d;
|
||||
public float e;
|
||||
public float f;
|
||||
}
|
||||
-21
@@ -1,21 +0,0 @@
|
||||
package me.purplex.packetevents.packetwrappers.in._1_7_10;
|
||||
|
||||
import me.purplex.packetevents.enums.PlayerDigType;
|
||||
import net.minecraft.server.v1_7_R4.PacketPlayInBlockDig;
|
||||
|
||||
public class WrappedPacketPlayInBlockDig_1_7_10 {
|
||||
private final Object packet;
|
||||
public WrappedPacketPlayInBlockDig_1_7_10(Object packet) {
|
||||
this.packet = packet;
|
||||
setupDigType();
|
||||
}
|
||||
|
||||
private void setupDigType() {
|
||||
PacketPlayInBlockDig p = (PacketPlayInBlockDig)packet;
|
||||
int status = p.e();
|
||||
this.digType = PlayerDigType.values()[status];
|
||||
}
|
||||
|
||||
public PlayerDigType digType;
|
||||
|
||||
}
|
||||
-49
@@ -1,49 +0,0 @@
|
||||
package me.purplex.packetevents.packetwrappers.in._1_7_10;
|
||||
|
||||
import net.minecraft.server.v1_7_R4.PacketPlayInFlying;
|
||||
|
||||
public class WrappedPacketPlayInFlying_1_7_10 {
|
||||
private final Object packet;
|
||||
public WrappedPacketPlayInFlying_1_7_10(Object packet) {
|
||||
this.packet = packet;
|
||||
setupFields();
|
||||
}
|
||||
|
||||
public double x;
|
||||
public double y;
|
||||
public double z;
|
||||
public float yaw;
|
||||
public float pitch;
|
||||
public boolean f;
|
||||
public boolean hasPos;
|
||||
public boolean hasLook;
|
||||
|
||||
|
||||
private void setupFields() {
|
||||
PacketPlayInFlying p = (PacketPlayInFlying)packet;
|
||||
this.x = p.c();
|
||||
this.y = p.d();
|
||||
this.z = p.e();
|
||||
this.yaw = p.g();
|
||||
this.pitch = p.h();
|
||||
this.f = p.i();
|
||||
}
|
||||
|
||||
public static class WrappedPacketPlayInPosition_1_7_10 extends WrappedPacketPlayInFlying_1_7_10 {
|
||||
|
||||
public WrappedPacketPlayInPosition_1_7_10(Object packet) {
|
||||
super(packet);
|
||||
this.hasPos = true;
|
||||
}
|
||||
}
|
||||
|
||||
public static class WrappedPacketPlayInPosition_Look_1_7_10 extends WrappedPacketPlayInFlying_1_7_10 {
|
||||
|
||||
public WrappedPacketPlayInPosition_Look_1_7_10(Object packet) {
|
||||
super(packet);
|
||||
this.hasLook = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
-58
@@ -1,58 +0,0 @@
|
||||
package me.purplex.packetevents.packetwrappers.in._1_7_10;
|
||||
|
||||
import me.purplex.packetevents.enums.EntityUseAction;
|
||||
import me.purplex.packetevents.enums.ServerVersion;
|
||||
import net.minecraft.server.v1_7_R4.Entity;
|
||||
import net.minecraft.server.v1_7_R4.PacketPlayInUseEntity;
|
||||
import net.minecraft.server.v1_7_R4.WorldServer;
|
||||
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;
|
||||
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();
|
||||
}
|
||||
|
||||
private Object getRawPacket() {
|
||||
return this.packet;
|
||||
}
|
||||
|
||||
public org.bukkit.entity.Entity getEntity() {
|
||||
return entity;
|
||||
}
|
||||
|
||||
public EntityUseAction getEntityUseAction() {
|
||||
return action;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
Entity entity = packet.a(worldServer);
|
||||
this.entity = entity.getBukkitEntity();
|
||||
}
|
||||
}
|
||||
|
||||
private void setupAction() {
|
||||
PacketPlayInUseEntity packet = (PacketPlayInUseEntity) getRawPacket();
|
||||
String name = packet.c().name();
|
||||
this.action = EntityUseAction.valueOf(name);
|
||||
}
|
||||
}
|
||||
-52
@@ -1,52 +0,0 @@
|
||||
package me.purplex.packetevents.packetwrappers.in._1_8;
|
||||
|
||||
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 boolean a;
|
||||
public boolean b;
|
||||
public boolean c;
|
||||
public boolean d;
|
||||
public float e;
|
||||
public float f;
|
||||
}
|
||||
-21
@@ -1,21 +0,0 @@
|
||||
package me.purplex.packetevents.packetwrappers.in._1_8;
|
||||
|
||||
import me.purplex.packetevents.enums.PlayerDigType;
|
||||
import net.minecraft.server.v1_8_R1.PacketPlayInBlockDig;
|
||||
|
||||
public class WrappedPacketPlayInBlockDig_1_8 {
|
||||
private final Object packet;
|
||||
public WrappedPacketPlayInBlockDig_1_8(Object packet) {
|
||||
this.packet = packet;
|
||||
setupDigType();
|
||||
}
|
||||
|
||||
private void setupDigType() {
|
||||
PacketPlayInBlockDig p = (PacketPlayInBlockDig)packet;
|
||||
String name = p.c().name();
|
||||
this.digType = PlayerDigType.valueOf(name);
|
||||
}
|
||||
|
||||
public PlayerDigType digType;
|
||||
|
||||
}
|
||||
-54
@@ -1,54 +0,0 @@
|
||||
package me.purplex.packetevents.packetwrappers.in._1_8;
|
||||
|
||||
|
||||
import net.minecraft.server.v1_8_R1.PacketPlayInFlying;
|
||||
|
||||
public class WrappedPacketPlayInFlying_1_8 {
|
||||
private final Object packet;
|
||||
|
||||
public WrappedPacketPlayInFlying_1_8(Object packet) {
|
||||
this.packet = packet;
|
||||
setupFields();
|
||||
}
|
||||
|
||||
public double x;
|
||||
public double y;
|
||||
public double z;
|
||||
public float yaw;
|
||||
public float pitch;
|
||||
public boolean f;
|
||||
public boolean hasPos;
|
||||
public boolean hasLook;
|
||||
|
||||
|
||||
private void setupFields() {
|
||||
PacketPlayInFlying p = (PacketPlayInFlying) packet;
|
||||
this.x = p.a();
|
||||
this.y = p.b();
|
||||
this.z = p.c();
|
||||
this.yaw = p.d();
|
||||
this.pitch = p.e();
|
||||
this.f = p.f();
|
||||
this.hasPos = p.g();
|
||||
this.hasLook = p.h();
|
||||
}
|
||||
|
||||
|
||||
public static class WrappedPacketPlayInPosition_1_8 extends WrappedPacketPlayInFlying_1_8 {
|
||||
|
||||
public WrappedPacketPlayInPosition_1_8(Object packet) {
|
||||
super(packet);
|
||||
this.hasPos = true;
|
||||
}
|
||||
}
|
||||
|
||||
public static class WrappedPacketPlayInPosition_Look_1_8 extends WrappedPacketPlayInFlying_1_8 {
|
||||
|
||||
public WrappedPacketPlayInPosition_Look_1_8(Object packet) {
|
||||
super(packet);
|
||||
this.hasLook = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
-57
@@ -1,57 +0,0 @@
|
||||
package me.purplex.packetevents.packetwrappers.in._1_8;
|
||||
|
||||
import me.purplex.packetevents.enums.EntityUseAction;
|
||||
import me.purplex.packetevents.enums.ServerVersion;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.entity.Entity;
|
||||
|
||||
public class WrappedPacketPlayInUseEntity_1_8 {
|
||||
private final ServerVersion version;
|
||||
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();
|
||||
}
|
||||
|
||||
private Object getRawPacket() {
|
||||
return this.packet;
|
||||
}
|
||||
|
||||
public Entity getEntity() {
|
||||
return entity;
|
||||
}
|
||||
|
||||
public EntityUseAction getEntityUseAction() {
|
||||
return action;
|
||||
}
|
||||
|
||||
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();
|
||||
net.minecraft.server.v1_8_R1.WorldServer worldServer = null;
|
||||
for (World bukkitWorld : Bukkit.getWorlds()) {
|
||||
org.bukkit.craftbukkit.v1_8_R1.CraftWorld craftWorld = (org.bukkit.craftbukkit.v1_8_R1.CraftWorld) bukkitWorld;
|
||||
worldServer = craftWorld.getHandle();
|
||||
if (packet.a(worldServer) != null) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
net.minecraft.server.v1_8_R1.Entity entity = packet.a(worldServer);
|
||||
this.entity = entity.getBukkitEntity();
|
||||
}
|
||||
}
|
||||
|
||||
private void setupAction() {
|
||||
net.minecraft.server.v1_8_R1.PacketPlayInUseEntity packet = (net.minecraft.server.v1_8_R1.PacketPlayInUseEntity) getRawPacket();
|
||||
String name = packet.a().name();
|
||||
this.action = EntityUseAction.valueOf(name);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
-65
@@ -1,65 +0,0 @@
|
||||
package me.purplex.packetevents.packetwrappers.in._1_8_3;
|
||||
|
||||
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 boolean a;
|
||||
public boolean b;
|
||||
public boolean c;
|
||||
public boolean d;
|
||||
public float e;
|
||||
public float f;
|
||||
}
|
||||
-21
@@ -1,21 +0,0 @@
|
||||
package me.purplex.packetevents.packetwrappers.in._1_8_3;
|
||||
|
||||
import me.purplex.packetevents.enums.PlayerDigType;
|
||||
import net.minecraft.server.v1_8_R2.PacketPlayInBlockDig;
|
||||
|
||||
public class WrappedPacketPlayInBlockDig_1_8_3 {
|
||||
private final Object packet;
|
||||
public WrappedPacketPlayInBlockDig_1_8_3(Object packet) {
|
||||
this.packet = packet;
|
||||
setupDigType();
|
||||
}
|
||||
|
||||
private void setupDigType() {
|
||||
PacketPlayInBlockDig p = (PacketPlayInBlockDig)packet;
|
||||
String name = p.c().name();
|
||||
this.digType = PlayerDigType.valueOf(name);
|
||||
}
|
||||
|
||||
public PlayerDigType digType;
|
||||
|
||||
}
|
||||
-50
@@ -1,50 +0,0 @@
|
||||
package me.purplex.packetevents.packetwrappers.in._1_8_3;
|
||||
|
||||
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 double x;
|
||||
public double y;
|
||||
public double z;
|
||||
public float yaw;
|
||||
public float pitch;
|
||||
public boolean f;
|
||||
public boolean hasPos;
|
||||
public boolean hasLook;
|
||||
|
||||
|
||||
private void setupFields() {
|
||||
PacketPlayInFlying p = (PacketPlayInFlying)packet;
|
||||
this.x = p.a();
|
||||
this.y = p.b();
|
||||
this.z = p.c();
|
||||
this.yaw = p.d();
|
||||
this.pitch = p.e();
|
||||
this.f = p.f();
|
||||
this.hasPos = p.g();
|
||||
this.hasLook = p.h();
|
||||
}
|
||||
public static class WrappedPacketPlayInPosition_1_8_3 extends WrappedPacketPlayInFlying_1_8_3 {
|
||||
|
||||
public WrappedPacketPlayInPosition_1_8_3(Object packet) {
|
||||
super(packet);
|
||||
this.hasPos = true;
|
||||
}
|
||||
}
|
||||
|
||||
public static class WrappedPacketPlayInPosition_Look_1_8_3 extends WrappedPacketPlayInFlying_1_8_3 {
|
||||
|
||||
public WrappedPacketPlayInPosition_Look_1_8_3(Object packet) {
|
||||
super(packet);
|
||||
this.hasLook = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
-56
@@ -1,56 +0,0 @@
|
||||
package me.purplex.packetevents.packetwrappers.in._1_8_3;
|
||||
|
||||
import me.purplex.packetevents.enums.EntityUseAction;
|
||||
import me.purplex.packetevents.enums.ServerVersion;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.entity.Entity;
|
||||
|
||||
public class WrappedPacketPlayInUseEntity_1_8_3 {
|
||||
private final ServerVersion version;
|
||||
private 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();
|
||||
}
|
||||
|
||||
private Object getRawPacket() {
|
||||
return this.packet;
|
||||
}
|
||||
|
||||
public Entity getEntity() {
|
||||
return entity;
|
||||
}
|
||||
|
||||
public EntityUseAction getEntityUseAction() {
|
||||
return action;
|
||||
}
|
||||
|
||||
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;
|
||||
for (World bukkitWorld : Bukkit.getWorlds()) {
|
||||
org.bukkit.craftbukkit.v1_8_R2.CraftWorld craftWorld = (org.bukkit.craftbukkit.v1_8_R2.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();
|
||||
|
||||
}
|
||||
|
||||
private void setupAction() {
|
||||
net.minecraft.server.v1_8_R2.PacketPlayInUseEntity packet = (net.minecraft.server.v1_8_R2.PacketPlayInUseEntity) getRawPacket();
|
||||
String name = packet.a().name();
|
||||
this.action = EntityUseAction.valueOf(name);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
-53
@@ -1,53 +0,0 @@
|
||||
package me.purplex.packetevents.packetwrappers.in._1_8_8;
|
||||
|
||||
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;
|
||||
|
||||
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();
|
||||
}
|
||||
|
||||
|
||||
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 boolean a;
|
||||
public boolean b;
|
||||
public boolean c;
|
||||
public boolean d;
|
||||
public float e;
|
||||
public float f;
|
||||
}
|
||||
-21
@@ -1,21 +0,0 @@
|
||||
package me.purplex.packetevents.packetwrappers.in._1_8_8;
|
||||
|
||||
import me.purplex.packetevents.enums.PlayerDigType;
|
||||
import net.minecraft.server.v1_8_R3.PacketPlayInBlockDig;
|
||||
|
||||
public class WrappedPacketPlayInBlockDig_1_8_8 {
|
||||
private final Object packet;
|
||||
public WrappedPacketPlayInBlockDig_1_8_8(Object packet) {
|
||||
this.packet = packet;
|
||||
setupDigType();
|
||||
}
|
||||
|
||||
private void setupDigType() {
|
||||
PacketPlayInBlockDig p = (PacketPlayInBlockDig)packet;
|
||||
String name = p.c().name();
|
||||
this.digType = PlayerDigType.valueOf(name);
|
||||
}
|
||||
|
||||
public PlayerDigType digType;
|
||||
|
||||
}
|
||||
-51
@@ -1,51 +0,0 @@
|
||||
package me.purplex.packetevents.packetwrappers.in._1_8_8;
|
||||
|
||||
import net.minecraft.server.v1_8_R3.PacketPlayInFlying;
|
||||
|
||||
public class WrappedPacketPlayInFlying_1_8_8 {
|
||||
private final Object packet;
|
||||
public WrappedPacketPlayInFlying_1_8_8(Object packet) {
|
||||
this.packet = packet;
|
||||
setupFields();
|
||||
}
|
||||
|
||||
public double x;
|
||||
public double y;
|
||||
public double z;
|
||||
public float yaw;
|
||||
public float pitch;
|
||||
public boolean f;
|
||||
public boolean hasPos;
|
||||
public boolean hasLook;
|
||||
|
||||
|
||||
private void setupFields() {
|
||||
PacketPlayInFlying p = (PacketPlayInFlying)packet;
|
||||
this.x = p.a();
|
||||
this.y = p.b();
|
||||
this.z = p.c();
|
||||
this.yaw = p.d();
|
||||
this.pitch = p.e();
|
||||
this.f = p.f();
|
||||
this.hasPos = p.g();
|
||||
this.hasLook = p.h();
|
||||
}
|
||||
|
||||
public static class WrappedPacketPlayInPosition_1_8_8 extends WrappedPacketPlayInFlying_1_8_8 {
|
||||
|
||||
public WrappedPacketPlayInPosition_1_8_8(Object packet) {
|
||||
super(packet);
|
||||
this.hasPos = true;
|
||||
}
|
||||
}
|
||||
|
||||
public static class WrappedPacketPlayInPosition_Look_1_8_8 extends WrappedPacketPlayInFlying_1_8_8 {
|
||||
|
||||
public WrappedPacketPlayInPosition_Look_1_8_8(Object packet) {
|
||||
super(packet);
|
||||
this.hasLook = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
-54
@@ -1,54 +0,0 @@
|
||||
package me.purplex.packetevents.packetwrappers.in._1_8_8;
|
||||
|
||||
import me.purplex.packetevents.enums.EntityUseAction;
|
||||
import me.purplex.packetevents.enums.ServerVersion;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.entity.Entity;
|
||||
|
||||
public class WrappedPacketPlayInUseEntity_1_8_8 {
|
||||
private final ServerVersion version;
|
||||
private 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();
|
||||
}
|
||||
|
||||
private Object getRawPacket() {
|
||||
return this.packet;
|
||||
}
|
||||
|
||||
public Entity getEntity() {
|
||||
return entity;
|
||||
}
|
||||
|
||||
public EntityUseAction getEntityUseAction() {
|
||||
return action;
|
||||
}
|
||||
|
||||
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;
|
||||
for (World bukkitWorld : Bukkit.getWorlds()) {
|
||||
org.bukkit.craftbukkit.v1_8_R3.CraftWorld craftWorld = (org.bukkit.craftbukkit.v1_8_R3.CraftWorld) bukkitWorld;
|
||||
worldServer = craftWorld.getHandle();
|
||||
if (packet.a(worldServer) != null) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
net.minecraft.server.v1_8_R3.Entity entity = packet.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();
|
||||
this.action = EntityUseAction.valueOf(name);
|
||||
}
|
||||
|
||||
}
|
||||
-52
@@ -1,52 +0,0 @@
|
||||
package me.purplex.packetevents.packetwrappers.in._1_9;
|
||||
|
||||
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 boolean a;
|
||||
public boolean b;
|
||||
public boolean c;
|
||||
public boolean d;
|
||||
public float e;
|
||||
public float f;
|
||||
}
|
||||
-21
@@ -1,21 +0,0 @@
|
||||
package me.purplex.packetevents.packetwrappers.in._1_9;
|
||||
|
||||
import me.purplex.packetevents.enums.PlayerDigType;
|
||||
import net.minecraft.server.v1_9_R1.PacketPlayInBlockDig;
|
||||
|
||||
public class WrappedPacketPlayInBlockDig_1_9 {
|
||||
private final Object packet;
|
||||
public WrappedPacketPlayInBlockDig_1_9(Object packet) {
|
||||
this.packet = packet;
|
||||
setupDigType();
|
||||
}
|
||||
|
||||
private void setupDigType() {
|
||||
PacketPlayInBlockDig p = (PacketPlayInBlockDig)packet;
|
||||
String name = p.c().name();
|
||||
this.digType = PlayerDigType.valueOf(name);
|
||||
}
|
||||
|
||||
public PlayerDigType digType;
|
||||
|
||||
}
|
||||
-122
@@ -1,122 +0,0 @@
|
||||
package me.purplex.packetevents.packetwrappers.in._1_9;
|
||||
|
||||
import net.minecraft.server.v1_9_R1.PacketPlayInFlying;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
|
||||
public class WrappedPacketPlayInFlying_1_9 {
|
||||
private final Object packet;
|
||||
|
||||
public double x;
|
||||
public double y;
|
||||
public double z;
|
||||
public float yaw;
|
||||
public float pitch;
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
this.f = p.a();
|
||||
}
|
||||
|
||||
public static class WrappedPacketPlayInPosition_1_9 extends WrappedPacketPlayInFlying_1_9 {
|
||||
|
||||
public WrappedPacketPlayInPosition_1_9(Object packet) {
|
||||
super(packet);
|
||||
this.hasPos = true;
|
||||
}
|
||||
}
|
||||
|
||||
public static class WrappedPacketPlayInPosition_Look_1_9 extends WrappedPacketPlayInFlying_1_9 {
|
||||
|
||||
public WrappedPacketPlayInPosition_Look_1_9(Object packet) {
|
||||
super(packet);
|
||||
this.hasLook = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private static Field fieldHasPos;
|
||||
private static Field fieldHasLook;
|
||||
private static Field fieldX;
|
||||
private static Field fieldY;
|
||||
private static Field fieldZ;
|
||||
private static Field fieldYaw;
|
||||
private static Field fieldPitch;
|
||||
|
||||
static {
|
||||
try {
|
||||
fieldHasPos = PacketPlayInFlying.class.getDeclaredField("hasPos");
|
||||
} catch (NoSuchFieldException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
try {
|
||||
fieldHasLook = PacketPlayInFlying.class.getDeclaredField("hasLook");
|
||||
} catch (NoSuchFieldException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
try {
|
||||
fieldX = PacketPlayInFlying.class.getDeclaredField("x");
|
||||
} catch (NoSuchFieldException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
try {
|
||||
fieldY = PacketPlayInFlying.class.getDeclaredField("y");
|
||||
} catch (NoSuchFieldException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
try {
|
||||
fieldZ = PacketPlayInFlying.class.getDeclaredField("z");
|
||||
} catch (NoSuchFieldException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
try {
|
||||
fieldYaw = PacketPlayInFlying.class.getDeclaredField("yaw");
|
||||
} catch (NoSuchFieldException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
try {
|
||||
fieldPitch = PacketPlayInFlying.class.getDeclaredField("pitch");
|
||||
} catch (NoSuchFieldException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
-56
@@ -1,56 +0,0 @@
|
||||
package me.purplex.packetevents.packetwrappers.in._1_9;
|
||||
|
||||
import me.purplex.packetevents.enums.EntityUseAction;
|
||||
import me.purplex.packetevents.enums.ServerVersion;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.entity.Entity;
|
||||
|
||||
public class WrappedPacketPlayInUseEntity_1_9 {
|
||||
private final ServerVersion version;
|
||||
private Entity entity;
|
||||
private EntityUseAction action;
|
||||
private final Object packet;
|
||||
|
||||
public WrappedPacketPlayInUseEntity_1_9(Object packet) {
|
||||
this.version = ServerVersion.getVersion();
|
||||
this.packet = packet;
|
||||
setupEntity();
|
||||
setupAction();
|
||||
}
|
||||
|
||||
private Object getRawPacket() {
|
||||
return this.packet;
|
||||
}
|
||||
|
||||
public Entity getEntity() {
|
||||
return entity;
|
||||
}
|
||||
|
||||
public EntityUseAction getEntityUseAction() {
|
||||
return action;
|
||||
}
|
||||
|
||||
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;
|
||||
for (World bukkitWorld : Bukkit.getWorlds()) {
|
||||
org.bukkit.craftbukkit.v1_9_R1.CraftWorld craftWorld = (org.bukkit.craftbukkit.v1_9_R1.CraftWorld) bukkitWorld;
|
||||
worldServer = craftWorld.getHandle();
|
||||
if (packet.a(worldServer) != null) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
net.minecraft.server.v1_9_R1.Entity entity = packet.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();
|
||||
this.action = EntityUseAction.valueOf(name);
|
||||
}
|
||||
}
|
||||
}
|
||||
-52
@@ -1,52 +0,0 @@
|
||||
package me.purplex.packetevents.packetwrappers.in._1_9_4;
|
||||
|
||||
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 boolean a;
|
||||
public boolean b;
|
||||
public boolean c;
|
||||
public boolean d;
|
||||
public float e;
|
||||
public float f;
|
||||
}
|
||||
-21
@@ -1,21 +0,0 @@
|
||||
package me.purplex.packetevents.packetwrappers.in._1_9_4;
|
||||
|
||||
import me.purplex.packetevents.enums.PlayerDigType;
|
||||
import net.minecraft.server.v1_9_R2.PacketPlayInBlockDig;
|
||||
|
||||
public class WrappedPacketPlayInBlockDig_1_9_4 {
|
||||
private final Object packet;
|
||||
public WrappedPacketPlayInBlockDig_1_9_4(Object packet) {
|
||||
this.packet = packet;
|
||||
setupDigType();
|
||||
}
|
||||
|
||||
private void setupDigType() {
|
||||
PacketPlayInBlockDig p = (PacketPlayInBlockDig)packet;
|
||||
String name = p.c().name();
|
||||
this.digType = PlayerDigType.valueOf(name);
|
||||
}
|
||||
|
||||
public PlayerDigType digType;
|
||||
|
||||
}
|
||||
-122
@@ -1,122 +0,0 @@
|
||||
package me.purplex.packetevents.packetwrappers.in._1_9_4;
|
||||
|
||||
import net.minecraft.server.v1_9_R2.PacketPlayInFlying;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
|
||||
public class WrappedPacketPlayInFlying_1_9_4 {
|
||||
private final Object packet;
|
||||
|
||||
public double x;
|
||||
public double y;
|
||||
public double z;
|
||||
public float yaw;
|
||||
public float pitch;
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
this.f = p.a();
|
||||
}
|
||||
|
||||
public static class WrappedPacketPlayInPosition_1_9_4 extends WrappedPacketPlayInFlying_1_9_4 {
|
||||
|
||||
public WrappedPacketPlayInPosition_1_9_4(Object packet) {
|
||||
super(packet);
|
||||
this.hasPos = true;
|
||||
}
|
||||
}
|
||||
|
||||
public static class WrappedPacketPlayInPosition_Look_1_9_4 extends WrappedPacketPlayInFlying_1_9_4 {
|
||||
|
||||
public WrappedPacketPlayInPosition_Look_1_9_4(Object packet) {
|
||||
super(packet);
|
||||
this.hasLook = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private static Field fieldHasPos;
|
||||
private static Field fieldHasLook;
|
||||
private static Field fieldX;
|
||||
private static Field fieldY;
|
||||
private static Field fieldZ;
|
||||
private static Field fieldYaw;
|
||||
private static Field fieldPitch;
|
||||
|
||||
static {
|
||||
try {
|
||||
fieldHasPos = PacketPlayInFlying.class.getDeclaredField("hasPos");
|
||||
} catch (NoSuchFieldException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
try {
|
||||
fieldHasLook = PacketPlayInFlying.class.getDeclaredField("hasLook");
|
||||
} catch (NoSuchFieldException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
try {
|
||||
fieldX = PacketPlayInFlying.class.getDeclaredField("x");
|
||||
} catch (NoSuchFieldException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
try {
|
||||
fieldY = PacketPlayInFlying.class.getDeclaredField("y");
|
||||
} catch (NoSuchFieldException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
try {
|
||||
fieldZ = PacketPlayInFlying.class.getDeclaredField("z");
|
||||
} catch (NoSuchFieldException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
try {
|
||||
fieldYaw = PacketPlayInFlying.class.getDeclaredField("yaw");
|
||||
} catch (NoSuchFieldException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
try {
|
||||
fieldPitch = PacketPlayInFlying.class.getDeclaredField("pitch");
|
||||
} catch (NoSuchFieldException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
-54
@@ -1,54 +0,0 @@
|
||||
package me.purplex.packetevents.packetwrappers.in._1_9_4;
|
||||
|
||||
import me.purplex.packetevents.enums.EntityUseAction;
|
||||
import me.purplex.packetevents.enums.ServerVersion;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.entity.Entity;
|
||||
|
||||
public class WrappedPacketPlayInUseEntity_1_9_4 {
|
||||
private final ServerVersion version;
|
||||
private 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();
|
||||
}
|
||||
|
||||
private Object getRawPacket() {
|
||||
return this.packet;
|
||||
}
|
||||
|
||||
public Entity getEntity() {
|
||||
return entity;
|
||||
}
|
||||
|
||||
public EntityUseAction getEntityUseAction() {
|
||||
return action;
|
||||
}
|
||||
|
||||
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;
|
||||
for (World bukkitWorld : Bukkit.getWorlds()) {
|
||||
org.bukkit.craftbukkit.v1_9_R2.CraftWorld craftWorld = (org.bukkit.craftbukkit.v1_9_R2.CraftWorld) bukkitWorld;
|
||||
worldServer = craftWorld.getHandle();
|
||||
if (packet.a(worldServer) != null) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
net.minecraft.server.v1_9_R2.Entity entity = packet.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();
|
||||
this.action = EntityUseAction.valueOf(name);
|
||||
}
|
||||
}
|
||||
+81
@@ -0,0 +1,81 @@
|
||||
package me.purplex.packetevents.packetwrappers.in.abilities;
|
||||
|
||||
import me.purplex.packetevents.packetwrappers.api.WrappedPacket;
|
||||
import me.purplex.packetevents.utils.NMSUtils;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
|
||||
public class WrappedPacketInAbilities extends WrappedPacket {
|
||||
private boolean isVulnerable;
|
||||
private boolean isFlying;
|
||||
private boolean allowFly;
|
||||
private boolean instantBuild;
|
||||
private float flySpeed;
|
||||
private float walkSpeed;
|
||||
|
||||
public WrappedPacketInAbilities(Object packet) {
|
||||
super(packet);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setup() throws IllegalAccessException {
|
||||
this.isVulnerable = fields[0].getBoolean(packet);
|
||||
this.isFlying = fields[1].getBoolean(packet);
|
||||
this.allowFly = fields[2].getBoolean(packet);
|
||||
this.instantBuild = fields[3].getBoolean(packet);
|
||||
this.flySpeed = fields[4].getFloat(packet);
|
||||
this.walkSpeed = fields[5].getFloat(packet);
|
||||
}
|
||||
|
||||
public boolean isVulnerable() {
|
||||
return isVulnerable;
|
||||
}
|
||||
|
||||
public boolean isFlying() {
|
||||
return isFlying;
|
||||
}
|
||||
|
||||
public boolean canFly() {
|
||||
return allowFly;
|
||||
}
|
||||
|
||||
public boolean canInstantlyBuild() {
|
||||
return instantBuild;
|
||||
}
|
||||
|
||||
public float getFlySpeed() {
|
||||
return flySpeed;
|
||||
}
|
||||
|
||||
public float getWalkSpeed() {
|
||||
return walkSpeed;
|
||||
}
|
||||
|
||||
private static Class<?> abilitiesClass;
|
||||
|
||||
private static Field[] fields = new Field[6];
|
||||
static {
|
||||
//CLASS
|
||||
try {
|
||||
abilitiesClass = NMSUtils.getNMSClass("PacketPlayInAbilities");
|
||||
} catch (ClassNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
//FIELDS
|
||||
try {
|
||||
fields[0] = abilitiesClass.getDeclaredField("a");
|
||||
fields[1] = abilitiesClass.getDeclaredField("b");
|
||||
fields[2] = abilitiesClass.getDeclaredField("c");
|
||||
fields[3] = abilitiesClass.getDeclaredField("d");
|
||||
fields[4] = abilitiesClass.getDeclaredField("e");
|
||||
fields[5] = abilitiesClass.getDeclaredField("f");
|
||||
} catch (NoSuchFieldException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
for(Field f : fields) {
|
||||
f.setAccessible(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
+139
@@ -0,0 +1,139 @@
|
||||
package me.purplex.packetevents.packetwrappers.in.blockdig;
|
||||
|
||||
|
||||
import me.purplex.packetevents.enums.Direction;
|
||||
import me.purplex.packetevents.enums.PlayerDigType;
|
||||
import me.purplex.packetevents.enums.ServerVersion;
|
||||
import me.purplex.packetevents.packetwrappers.api.WrappedPacket;
|
||||
import me.purplex.packetevents.utils.BaseBlockUtils;
|
||||
import me.purplex.packetevents.utils.NMSUtils;
|
||||
import me.purplex.packetevents.utils.math.*;
|
||||
import java.lang.reflect.Field;
|
||||
|
||||
public class WrappedPacketInBlockDig extends WrappedPacket {
|
||||
private Vector3i blockPosition;
|
||||
private Direction direction;
|
||||
private PlayerDigType digType;
|
||||
|
||||
public WrappedPacketInBlockDig(Object packet) {
|
||||
super(packet);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void setup() throws Exception {
|
||||
final Direction enumDirection;
|
||||
final PlayerDigType enumDigType;
|
||||
//1.7.10
|
||||
if (version == ServerVersion.v_1_7_10) {
|
||||
final int x = fields[0].getInt(packet);
|
||||
final int y = fields[1].getInt(packet);
|
||||
final int z = fields[2].getInt(packet);
|
||||
|
||||
this.blockPosition = new Vector3i(x, y, z);
|
||||
|
||||
enumDirection = Direction.get((byte) face.getInt(packet));
|
||||
enumDigType = PlayerDigType.get((byte)e.getInt(packet));
|
||||
} else {
|
||||
//1.8+
|
||||
final Object blockPosObj = fields[0].get(packet);
|
||||
final Object enumDirectionObj = fields[1].get(packet);
|
||||
final Object digTypeObj = fields[2].get(packet);
|
||||
|
||||
final int x = blockPosXYZ[0].getInt(blockPosObj);
|
||||
final int y = blockPosXYZ[1].getInt(blockPosObj);
|
||||
final int z = blockPosXYZ[2].getInt(blockPosObj);
|
||||
|
||||
this.blockPosition = new Vector3i(x, y, z);
|
||||
|
||||
enumDirection = Direction.valueOf(((Enum)enumDirectionObj).name());
|
||||
enumDigType = PlayerDigType.valueOf(((Enum)digTypeObj).name());
|
||||
}
|
||||
|
||||
this.direction = enumDirection;
|
||||
this.digType = enumDigType;
|
||||
}
|
||||
|
||||
public Vector3i getBlockPosition() {
|
||||
return blockPosition;
|
||||
}
|
||||
|
||||
public Direction getDirection() {
|
||||
return direction;
|
||||
}
|
||||
|
||||
public PlayerDigType getDigType() {
|
||||
return digType;
|
||||
}
|
||||
|
||||
//ALL
|
||||
private static Class<?> blockDigClass;
|
||||
|
||||
|
||||
//1.8
|
||||
private static Field[] fields = new Field[3];
|
||||
|
||||
private static Class<?> blockPositionClass;
|
||||
|
||||
private static Field[] blockPosXYZ = new Field[3];
|
||||
|
||||
//1.7
|
||||
private static Field face;
|
||||
|
||||
private static Field e;
|
||||
|
||||
static {
|
||||
//CLASSES
|
||||
try {
|
||||
blockDigClass = NMSUtils.getNMSClass("PacketPlayInBlockDig");
|
||||
if (version != ServerVersion.v_1_7_10) {
|
||||
blockPositionClass = NMSUtils.getNMSClass("BlockPosition");
|
||||
}
|
||||
} catch (ClassNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
//FIELDS
|
||||
try {
|
||||
//blockpos
|
||||
fields[0] = blockDigClass.getDeclaredField("a");
|
||||
//direction
|
||||
fields[1] = blockDigClass.getDeclaredField("b");
|
||||
//digtype
|
||||
fields[2] = blockDigClass.getDeclaredField("c");
|
||||
|
||||
if (version != ServerVersion.v_1_7_10) {
|
||||
blockPosXYZ[0] = blockPositionClass.getSuperclass().getDeclaredField(BaseBlockUtils.getPosXFieldName());
|
||||
blockPosXYZ[1] = blockPositionClass.getSuperclass().getDeclaredField(BaseBlockUtils.getPosXFieldName());
|
||||
blockPosXYZ[2] = blockPositionClass.getSuperclass().getDeclaredField(BaseBlockUtils.getPosZFieldName());
|
||||
} else {
|
||||
face = blockDigClass.getDeclaredField("face");
|
||||
e = blockDigClass.getDeclaredField("e");
|
||||
}
|
||||
} catch (NoSuchFieldException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
for(Field f : fields) {
|
||||
if(f != null) {
|
||||
f.setAccessible(true);
|
||||
}
|
||||
}
|
||||
|
||||
for(Field f : blockPosXYZ) {
|
||||
if(f != null) {
|
||||
f.setAccessible(true);
|
||||
}
|
||||
}
|
||||
|
||||
if(e != null) {
|
||||
e.setAccessible(true);
|
||||
}
|
||||
|
||||
if(face != null) {
|
||||
face.setAccessible(true);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
package me.purplex.packetevents.packetwrappers.in.chat;
|
||||
|
||||
import me.purplex.packetevents.enums.ServerVersion;
|
||||
import me.purplex.packetevents.packetwrappers.api.WrappedPacket;
|
||||
import me.purplex.packetevents.utils.NMSUtils;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
|
||||
public class WrappedPacketInChat extends WrappedPacket {
|
||||
private String message;
|
||||
|
||||
public WrappedPacketInChat(Object packet) {
|
||||
super(packet);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setup() throws IllegalAccessException {
|
||||
final Object obj = field.get(packet);
|
||||
this.message = obj.toString();
|
||||
}
|
||||
|
||||
public String getMessage() {
|
||||
return message;
|
||||
}
|
||||
|
||||
private static Class<?> chatPacketClass;
|
||||
|
||||
private static Field field;
|
||||
|
||||
static {
|
||||
//CLASSES
|
||||
try {
|
||||
chatPacketClass = NMSUtils.getNMSClass("PacketPlayInChat");
|
||||
} catch (ClassNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
try {
|
||||
field = chatPacketClass.getDeclaredField(getChatFieldName());
|
||||
} catch (NoSuchFieldException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
if (!field.isAccessible()) {
|
||||
field.setAccessible(true);
|
||||
}
|
||||
}
|
||||
|
||||
private static String getChatFieldName() {
|
||||
if (version == ServerVersion.v_1_7_10) {
|
||||
return "message";
|
||||
}
|
||||
return "a";
|
||||
}
|
||||
}
|
||||
+144
@@ -0,0 +1,144 @@
|
||||
package me.purplex.packetevents.packetwrappers.in.flying;
|
||||
|
||||
|
||||
import me.purplex.packetevents.enums.ServerVersion;
|
||||
import me.purplex.packetevents.packetwrappers.api.WrappedPacket;
|
||||
import me.purplex.packetevents.utils.NMSUtils;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
|
||||
public class WrappedPacketInFlying extends WrappedPacket {
|
||||
|
||||
private double x;
|
||||
private double y;
|
||||
private double z;
|
||||
private float yaw;
|
||||
private float pitch;
|
||||
private boolean onGround;
|
||||
private boolean isPosition;
|
||||
private boolean isLook;
|
||||
|
||||
public WrappedPacketInFlying(Object packet) {
|
||||
super(packet);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setup() throws IllegalAccessException {
|
||||
this.x = fields[0].getDouble(packet);
|
||||
this.y = fields[1].getDouble(packet);
|
||||
this.z = fields[2].getDouble(packet);
|
||||
|
||||
this.yaw = fields[3].getFloat(packet);
|
||||
this.pitch = fields[4].getFloat(packet);
|
||||
|
||||
this.onGround = fields[5].getBoolean(packet);
|
||||
|
||||
this.isPosition = fields[6].getBoolean(packet);
|
||||
this.isLook = fields[7].getBoolean(packet);
|
||||
}
|
||||
|
||||
public static class WrappedPacketInPosition extends WrappedPacketInFlying {
|
||||
public WrappedPacketInPosition(Object packet) {
|
||||
super(packet);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPosition() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isLook() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public static class WrappedPacketInPosition_Look extends WrappedPacketInFlying {
|
||||
public WrappedPacketInPosition_Look(Object packet) {
|
||||
super(packet);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isLook() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPosition() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public double getX() {
|
||||
return x;
|
||||
}
|
||||
|
||||
public double getY() {
|
||||
return y;
|
||||
}
|
||||
|
||||
public double getZ() {
|
||||
return z;
|
||||
}
|
||||
|
||||
public float getYaw() {
|
||||
return yaw;
|
||||
}
|
||||
|
||||
public float getPitch() {
|
||||
return pitch;
|
||||
}
|
||||
|
||||
public boolean isOnGround() {
|
||||
return onGround;
|
||||
}
|
||||
|
||||
public boolean isPosition() {
|
||||
return isPosition;
|
||||
}
|
||||
|
||||
public boolean isLook() {
|
||||
return isLook;
|
||||
}
|
||||
|
||||
private static Class<?> flyingClass;
|
||||
|
||||
private static Field[] fields = new Field[8]; //x, y, z, yaw pitch, onGround, isPositionPacket, isLookPacket
|
||||
|
||||
static {
|
||||
//CLASS
|
||||
try {
|
||||
flyingClass = NMSUtils.getNMSClass("PacketPlayInFlying");
|
||||
} catch (ClassNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
//FIELDS
|
||||
try {
|
||||
fields[0] = flyingClass.getDeclaredField("x");
|
||||
fields[1] = flyingClass.getDeclaredField("y");
|
||||
fields[2] = flyingClass.getDeclaredField("z");
|
||||
fields[3] = flyingClass.getDeclaredField("yaw");
|
||||
fields[4] = flyingClass.getDeclaredField("pitch");
|
||||
fields[5] = flyingClass.getDeclaredField(getOnGroundFieldName());
|
||||
fields[6] = flyingClass.getDeclaredField("hasPos");
|
||||
fields[7] = flyingClass.getDeclaredField("hasLook");
|
||||
} catch (NoSuchFieldException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
for (Field f : fields) {
|
||||
if (!f.isAccessible()) {
|
||||
f.setAccessible(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static String getOnGroundFieldName() {
|
||||
if (version == ServerVersion.v_1_7_10) {
|
||||
return "g";
|
||||
}
|
||||
return "f";
|
||||
}
|
||||
|
||||
}
|
||||
Loaded 100 of 126 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user