Updated a cache to use UUID instead of Player

This commit is contained in:
TheLividaProject
2025-07-04 17:17:25 +01:00
parent 3adb965697
commit f67ee6d9f8
32 changed files with 7 additions and 7 deletions

File diff suppressed because one or more lines are too long

View File

@@ -43,14 +43,14 @@ public class ModelListener implements Listener {
ModelEntityData model = map.get(event.getVehicle()); ModelEntityData model = map.get(event.getVehicle());
if (model != null && event.getPassenger() instanceof Player player) { if (model != null && event.getPassenger() instanceof Player player) {
plugin.getModelManager().getDriversCache().put(player, Pair.of(event.getVehicle(), event.getSeat())); plugin.getModelManager().getDriversCache().put(player.getUniqueId(), Pair.of(event.getVehicle(), event.getSeat()));
} }
} }
@EventHandler(priority = EventPriority.MONITOR) @EventHandler(priority = EventPriority.MONITOR)
public void onModelDismount(ModelDismountEvent event) { public void onModelDismount(ModelDismountEvent event) {
if (event.getPassenger() instanceof Player player) { if (event.getPassenger() instanceof Player player) {
plugin.getModelManager().getDriversCache().remove(player); plugin.getModelManager().getDriversCache().remove(player.getUniqueId());
} }
} }

View File

@@ -28,7 +28,7 @@ public class MountPacketListener implements PacketListener {
Player player = event.getPlayer(); Player player = event.getPlayer();
WrapperPlayClientEntityAction action = new WrapperPlayClientEntityAction(event); WrapperPlayClientEntityAction action = new WrapperPlayClientEntityAction(event);
Pair<ActiveModel, Mount> seat = plugin.getModelManager().getDriversCache().get(player); Pair<ActiveModel, Mount> seat = plugin.getModelManager().getDriversCache().get(player.getUniqueId());
if (seat == null) return; if (seat == null) return;
if (action.getAction() != WrapperPlayClientEntityAction.Action.START_SNEAKING) return; if (action.getAction() != WrapperPlayClientEntityAction.Action.START_SNEAKING) return;

View File

@@ -22,7 +22,7 @@ public class ModelManager {
private final ConcurrentHashMap<Integer, Map<ActiveModel, ModelEntityData>> entitiesCache = new ConcurrentHashMap<>(); private final ConcurrentHashMap<Integer, Map<ActiveModel, ModelEntityData>> entitiesCache = new ConcurrentHashMap<>();
private final ConcurrentHashMap<Integer, ModelEntityData> modelEntitiesCache = new ConcurrentHashMap<>(); private final ConcurrentHashMap<Integer, ModelEntityData> modelEntitiesCache = new ConcurrentHashMap<>();
private final ConcurrentHashMap<Player, Pair<ActiveModel, Mount>> driversCache = new ConcurrentHashMap<>(); private final ConcurrentHashMap<UUID, Pair<ActiveModel, Mount>> driversCache = new ConcurrentHashMap<>();
public ModelManager(GeyserModelEngine plugin) { public ModelManager(GeyserModelEngine plugin) {
this.plugin = plugin; this.plugin = plugin;
@@ -65,7 +65,7 @@ public class ModelManager {
return modelEntitiesCache; return modelEntitiesCache;
} }
public ConcurrentHashMap<Player, Pair<ActiveModel, Mount>> getDriversCache() { public ConcurrentHashMap<UUID, Pair<ActiveModel, Mount>> getDriversCache() {
return driversCache; return driversCache;
} }
} }

View File

@@ -28,7 +28,7 @@ public class BedrockMountControlRunnable implements Consumer<ScheduledTask> {
if (!FloodgateApi.getInstance().isFloodgatePlayer(player.getUniqueId())) continue; if (!FloodgateApi.getInstance().isFloodgatePlayer(player.getUniqueId())) continue;
float pitch = player.getLocation().getPitch(); float pitch = player.getLocation().getPitch();
Pair<ActiveModel, Mount> seat = plugin.getModelManager().getDriversCache().get(player); Pair<ActiveModel, Mount> seat = plugin.getModelManager().getDriversCache().get(player.getUniqueId());
if (seat == null) continue; if (seat == null) continue;