Dieser Commit ist enthalten in:
Ursprung
c02d7c2c7d
Commit
c032f55d2e
@ -47,8 +47,17 @@ public class REntityServer implements Listener {
|
|||||||
private static final HashSet<Player> emptyPlayers = new HashSet<>(0);
|
private static final HashSet<Player> emptyPlayers = new HashSet<>(0);
|
||||||
|
|
||||||
private static final Class<?> useEntity = Reflection.getClass("{nms.network.protocol.game}.PacketPlayInUseEntity");
|
private static final Class<?> useEntity = Reflection.getClass("{nms.network.protocol.game}.PacketPlayInUseEntity");
|
||||||
|
private static final Class<?> useEntityEnumAction = Reflection.getClass("{nms.network.protocol.game}.PacketPlayInUseEntity$EnumEntityUseAction");
|
||||||
private static final Reflection.FieldAccessor<Integer> useEntityTarget = Reflection.getField(useEntity, int.class, 0);
|
private static final Reflection.FieldAccessor<Integer> useEntityTarget = Reflection.getField(useEntity, int.class, 0);
|
||||||
private static final Reflection.FieldAccessor<Integer> useEntityAction = Reflection.getField(useEntity, int.class, 1);
|
private static final Reflection.FieldAccessor<Object> useEntityAction = (Reflection.FieldAccessor<Object>) Reflection.getField(useEntity, useEntityEnumAction, 0);
|
||||||
|
private static final Reflection.MethodInvoker useEntityGetAction;
|
||||||
|
static {
|
||||||
|
if (useEntityEnumAction.isEnum()) {
|
||||||
|
useEntityGetAction = null;
|
||||||
|
} else {
|
||||||
|
useEntityGetAction = Reflection.getMethod(useEntity, "a");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private final ConcurrentHashMap<Integer, REntity> entityMap = new ConcurrentHashMap<>();
|
private final ConcurrentHashMap<Integer, REntity> entityMap = new ConcurrentHashMap<>();
|
||||||
private final HashMap<Long, HashSet<REntity>> entities = new HashMap<>();
|
private final HashMap<Long, HashSet<REntity>> entities = new HashMap<>();
|
||||||
@ -64,7 +73,15 @@ public class REntityServer implements Listener {
|
|||||||
REntity entity = entityMap.get(target);
|
REntity entity = entityMap.get(target);
|
||||||
if (entity == null) return packet;
|
if (entity == null) return packet;
|
||||||
|
|
||||||
EntityAction action = useEntityAction.get(packet) == 1 ? EntityAction.ATTACK : EntityAction.INTERACT;
|
Object entityAction = useEntityAction.get(packet);
|
||||||
|
int entityActionOrdinal;
|
||||||
|
if (useEntityEnumAction.isEnum()) {
|
||||||
|
entityActionOrdinal = ((Enum<?>) entityAction).ordinal();
|
||||||
|
} else {
|
||||||
|
entityActionOrdinal = ((Enum<?>) useEntityGetAction.invoke(entityAction)).ordinal();
|
||||||
|
}
|
||||||
|
|
||||||
|
EntityAction action = entityActionOrdinal == 1 ? EntityAction.ATTACK : EntityAction.INTERACT;
|
||||||
Bukkit.getScheduler().runTask(Core.getInstance(), () -> {
|
Bukkit.getScheduler().runTask(Core.getInstance(), () -> {
|
||||||
callback.onAction(player, entity, action);
|
callback.onAction(player, entity, action);
|
||||||
});
|
});
|
||||||
|
In neuem Issue referenzieren
Einen Benutzer sperren