Compare commits

...
4 Commits
Author SHA1 Message Date
Retrooper d5454b918a 1.6.2 release
* Issues with WrappedPacketInEntityAction on 1.7.10
2020-08-30 16:15:28 +08:00
Retrooper 427a0fff4a * NPE fix for WrappedPacketInEntityAction in 1.8+ 2020-08-30 15:38:17 +08:00
retrooper 7fc446321d Merge pull request #32 from SamJakob/patch-3
Only update JavaDoc on published release
2020-08-29 21:55:13 +02:00
SamJakob 5ed9038f7b Only update JavaDoc on published release 2020-08-28 12:22:33 +01:00
4 changed files with 16 additions and 13 deletions

No files matched your search

+2 -4
View File
@@ -1,10 +1,8 @@
name: Generate and deploy JavaDocs
on:
push:
branches: [ master ]
pull_request:
branches: [ master ]
release:
types: [published]
jobs:
build:
+1 -1
View File
@@ -6,7 +6,7 @@
<groupId>io.github.retrooper</groupId>
<artifactId>packetevents</artifactId>
<version>1.6.1</version>
<version>1.6.2</version>
<!-- You can build the project with this: "mvn clean compile assembly:single" -->
<build>
@@ -13,7 +13,6 @@ import io.github.retrooper.packetevents.packet.PacketType;
import io.github.retrooper.packetevents.packetwrappers.in.useentity.WrappedPacketInUseEntity;
import io.github.retrooper.packetevents.packetwrappers.out.chat.WrappedPacketOutChat;
import org.bukkit.plugin.java.JavaPlugin;
public class MainExample extends JavaPlugin implements PacketListener {
@Override
@@ -15,6 +15,7 @@ import java.util.HashMap;
public final class WrappedPacketInEntityAction extends WrappedPacket {
private static final HashMap<String, PlayerAction> cachedPlayerActionNames = new HashMap<String, PlayerAction>();
private static final HashMap<Integer, PlayerAction> cachedPlayerActionIDs = new HashMap<Integer, PlayerAction>();
private static Class<?> entityActionClass;
@Nullable
private static Class<?> enumPlayerActionClass;
@@ -41,6 +42,15 @@ public final class WrappedPacketInEntityAction extends WrappedPacket {
cachedPlayerActionNames.put("PRESS_SHIFT_KEY", PlayerAction.START_SNEAKING);
cachedPlayerActionNames.put("RELEASE_SHIFT_KEY", PlayerAction.STOP_SNEAKING);
cachedPlayerActionNames.put("RIDING_JUMP", PlayerAction.START_RIDING_JUMP);
cachedPlayerActionIDs.put(1, PlayerAction.START_SNEAKING);
cachedPlayerActionIDs.put(2, PlayerAction.STOP_SNEAKING);
cachedPlayerActionIDs.put(3, PlayerAction.STOP_SLEEPING);
cachedPlayerActionIDs.put(4, PlayerAction.START_SPRINTING);
cachedPlayerActionIDs.put(5, PlayerAction.STOP_SPRINTING);
cachedPlayerActionIDs.put(6, PlayerAction.START_RIDING_JUMP); //riding jump
cachedPlayerActionIDs.put(7, PlayerAction.OPEN_INVENTORY); //horse interaction
}
@Override
@@ -54,23 +64,19 @@ public final class WrappedPacketInEntityAction extends WrappedPacket {
jumpBoost = Reflection.getField(entityActionClass, int.class, 1).getInt(packet);
}
int animationIndex = -1;
//1.7.10
if (isLowerThan_v_1_8) {
animationIndex = Reflection.getField(entityActionClass, int.class, 1).getInt(packet); // TODO: += if packetdataserializer.version < 16
int animationIndex = Reflection.getField(entityActionClass, int.class, 1).getInt(packet); // TODO: += if packetdataserializer.version < 16
this.action = cachedPlayerActionIDs.get(animationIndex);
} else {
final Object enumObj = Reflection.getField(entityActionClass, enumPlayerActionClass, 0).get(packet);
final String enumName = enumObj.toString();
this.action = cachedPlayerActionNames.get(enumName);
}
this.entityId = entityId;
this.jumpBoost = jumpBoost;
if (animationIndex != -1) {
this.action = PlayerAction.values()[animationIndex];
}
} catch (IllegalAccessException e) {
e.printStackTrace();
}