mirror of
https://github.com/dmulloy2/ProtocolLib.git
synced 2024-11-24 03:25:29 +01:00
parent
3ff2ccf1b3
commit
524fb1ba68
@ -19,6 +19,7 @@ package com.comphenix.protocol.injector;
|
|||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
@ -59,7 +60,7 @@ class EntityUtilities {
|
|||||||
private FieldAccessor trackedPlayersField;
|
private FieldAccessor trackedPlayersField;
|
||||||
private FieldAccessor trackerField;
|
private FieldAccessor trackerField;
|
||||||
|
|
||||||
private MethodAccessor scanPlayersMethod;
|
private Map<Class<?>, MethodAccessor> scanPlayersMethods = new HashMap<>();
|
||||||
|
|
||||||
public void updateEntity(Entity entity, List<Player> observers) {
|
public void updateEntity(Entity entity, List<Player> observers) {
|
||||||
if (entity == null || !entity.isValid()) {
|
if (entity == null || !entity.isValid()) {
|
||||||
@ -73,11 +74,8 @@ class EntityUtilities {
|
|||||||
|
|
||||||
Object trackerEntry = getEntityTrackerEntry(entity.getWorld(), entity.getEntityId());
|
Object trackerEntry = getEntityTrackerEntry(entity.getWorld(), entity.getEntityId());
|
||||||
|
|
||||||
if (scanPlayersMethod == null) {
|
// there can be multiple different entity tracker entry impls, see GH-732....
|
||||||
scanPlayersMethod = findScanPlayers(trackerEntry.getClass());
|
scanPlayersMethods.computeIfAbsent(trackerEntry.getClass(), this::findScanPlayers).invoke(trackerEntry, nmsPlayers);
|
||||||
}
|
|
||||||
|
|
||||||
scanPlayersMethod.invoke(trackerEntry, nmsPlayers);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private MethodAccessor findScanPlayers(Class<?> trackerClass) {
|
private MethodAccessor findScanPlayers(Class<?> trackerClass) {
|
||||||
|
Loading…
Reference in New Issue
Block a user