Compare commits

...
5 Commits
Author SHA1 Message Date
retrooper a88e95e116 Merge pull request #62 from retrooper/dev
1.7.5 release
2020-11-09 07:21:41 +01:00
retrooper 7c583bf8ec 1.7.5 release 2020-11-09 07:21:06 +01:00
retrooper c3911483a5 Fix of WrappedPacketInBlockPlace returning -1 on 1.8 servers (By @LIWKK) 2020-11-08 22:12:03 +01:00
Johannes f37d7f4040 Fixxxxx 2020-11-08 23:10:14 +02:00
retrooper c39c9691a8 * Attempt to fix a bug to do with block place on 1.9+ 2020-11-08 17:39:11 +01:00
5 changed files with 19 additions and 22 deletions

No files matched your search

+1 -1
View File
@@ -6,7 +6,7 @@
<groupId>io.github.retrooper</groupId>
<artifactId>packetevents</artifactId>
<version>1.7.4</version>
<version>1.7.5</version>
<!-- You can build the project with this: "mvn clean compile assembly:single" -->
<build>
@@ -57,7 +57,7 @@ public final class PacketEvents implements Listener {
private static final PacketEvents instance = new PacketEvents();
private static final ArrayList<Plugin> plugins = new ArrayList<>(1);
private static boolean loaded, initialized;
private static final PEVersion version = new PEVersion(1, 7, 4);
private static final PEVersion version = new PEVersion(1, 7, 5);
private static PacketEventsSettings settings = new PacketEventsSettings();
/** General executor service, basically for anything that the packet executor service doesn't do.
@@ -491,7 +491,8 @@ public class WrappedPacket implements WrapperPacketReader, WrapperPacketWriter {
public Object readObject(int index, Class<?> type) {
Map<Class<?>, Field[]> cached = fieldCache.get(packetClass);
if (cached != null) {
if (!cached.containsKey(type)) {
Field[] cachedFields = cached.get(type);
if (cachedFields == null) {
List<Field> typeFields = new ArrayList<>();
for (Field f : packetClass.getDeclaredFields()) {
f.setAccessible(true);
@@ -501,10 +502,14 @@ public class WrappedPacket implements WrapperPacketReader, WrapperPacketWriter {
}
if (!typeFields.isEmpty()) {
cached.put(type, typeFields.toArray(new Field[0]));
cachedFields = cached.get(type);
}
else {
throw new WrapperFieldNotFoundException("The class you are trying to read fields from does not contain any fields!");
}
}
try {
return cached.get(type)[index].get(packet);
return cachedFields[index].get(packet);
} catch (IllegalAccessException e) {
e.printStackTrace();
}
@@ -601,12 +606,9 @@ public class WrappedPacket implements WrapperPacketReader, WrapperPacketWriter {
}
private List<Field> getFields(Class<?> type, Field[] fields) {
List<Field> ret = null;
List<Field> ret = new ArrayList<>();
for (Field field : fields) {
if (field.getType() == type) {
if (ret == null) {
ret = new ArrayList<>();
}
ret.add(field);
}
}
@@ -27,8 +27,6 @@ package io.github.retrooper.packetevents.packetwrappers.in.blockplace;
import io.github.retrooper.packetevents.enums.Direction;
import io.github.retrooper.packetevents.packetwrappers.WrappedPacket;
import io.github.retrooper.packetevents.utils.server.ServerVersion;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
public final class WrappedPacketInBlockPlace extends WrappedPacket {
@@ -41,21 +39,17 @@ public final class WrappedPacketInBlockPlace extends WrappedPacket {
public static void load() {
isHigherThan_v_1_8_8 = version.isHigherThan(ServerVersion.v_1_8_8);
isHigherThan_v_1_7_10 = version.isHigherThan(ServerVersion.v_1_7_10);
if (isHigherThan_v_1_8_8) {
WrappedPacketInBlockPlace_1_9.load();
}
WrappedPacketInBlockPlace_1_9.load();
}
public Direction getDirection() {
if(isHigherThan_v_1_8_8) {
if (isHigherThan_v_1_8_8) {
WrappedPacketInBlockPlace_1_9 blockPlace_1_9 = new WrappedPacketInBlockPlace_1_9(packet);
return Direction.valueOf(((Enum)blockPlace_1_9.getEnumDirectionObject()).name());
}
else if(isHigherThan_v_1_7_10) {
return Direction.valueOf(((Enum) blockPlace_1_9.getEnumDirectionObject()).name());
} else if (isHigherThan_v_1_7_10) {
WrappedPacketInBlockPlace_1_8 blockPlace_1_8 = new WrappedPacketInBlockPlace_1_8(packet);
return Direction.values()[blockPlace_1_8.getFace()];
}
else {
} else {
WrappedPacketInBlockPlace_1_7_10 blockPlace_1_7_10 = new WrappedPacketInBlockPlace_1_7_10(packet);
return Direction.values()[blockPlace_1_7_10.face];
}
@@ -40,7 +40,7 @@ final class WrappedPacketInBlockPlace_1_8 extends WrappedPacket {
public int getX() {
if(blockPosObj == null) {
blockPosObj = readObject(0, NMSUtils.blockPosClass);
blockPosObj = readObject(1, NMSUtils.blockPosClass);
}
try {
return (int) Reflection.getMethod(blockPosObj.getClass().getSuperclass(), "getX", 0).invoke(blockPosObj);
@@ -49,10 +49,11 @@ final class WrappedPacketInBlockPlace_1_8 extends WrappedPacket {
}
return -1;
}
public int getY() {
if(blockPosObj == null) {
blockPosObj = readObject(0, NMSUtils.blockPosClass);
blockPosObj = readObject(1, NMSUtils.blockPosClass);
}
try {
return (int) Reflection.getMethod(blockPosObj.getClass().getSuperclass(), "getY", 0).invoke(blockPosObj);
@@ -64,7 +65,7 @@ final class WrappedPacketInBlockPlace_1_8 extends WrappedPacket {
public int getZ() {
if(blockPosObj == null) {
blockPosObj = readObject(0, NMSUtils.blockPosClass);
blockPosObj = readObject(1, NMSUtils.blockPosClass);
}
try {
return (int) Reflection.getMethod(blockPosObj.getClass().getSuperclass(), "getZ", 0).invoke(blockPosObj);