mirror of
https://github.com/GeyserExtensionists/GeyserModelEngine.git
synced 2025-12-19 15:09:18 +00:00
Removed the weird schedulers on playerJoin and playerQuit
This commit is contained in:
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
File diff suppressed because one or more lines are too long
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -14,7 +14,6 @@ import re.imc.geysermodelengine.managers.ConfigManager;
|
||||
import re.imc.geysermodelengine.managers.commands.CommandManager;
|
||||
import re.imc.geysermodelengine.managers.model.EntityTaskManager;
|
||||
import re.imc.geysermodelengine.managers.model.ModelManager;
|
||||
import re.imc.geysermodelengine.managers.player.PlayerManager;
|
||||
import re.imc.geysermodelengine.managers.model.data.ModelEntityData;
|
||||
import re.imc.geysermodelengine.runnables.BedrockMountControlRunnable;
|
||||
import re.imc.geysermodelengine.runnables.UpdateTaskRunnable;
|
||||
@@ -31,8 +30,6 @@ public class GeyserModelEngine extends JavaPlugin {
|
||||
private ModelManager modelManager;
|
||||
private EntityTaskManager entityTaskManager;
|
||||
|
||||
private PlayerManager playerManager;
|
||||
|
||||
@Override
|
||||
public void onLoad() {
|
||||
PacketEvents.setAPI(SpigotPacketEventsBuilder.build(this));
|
||||
@@ -77,8 +74,6 @@ public class GeyserModelEngine extends JavaPlugin {
|
||||
|
||||
this.modelManager = new ModelManager(this);
|
||||
this.entityTaskManager = new EntityTaskManager(this);
|
||||
|
||||
this.playerManager = new PlayerManager();
|
||||
}
|
||||
|
||||
private void loadRunnables() {
|
||||
@@ -101,8 +96,4 @@ public class GeyserModelEngine extends JavaPlugin {
|
||||
public EntityTaskManager getEntityTaskManager() {
|
||||
return entityTaskManager;
|
||||
}
|
||||
|
||||
public PlayerManager getPlayerManager() {
|
||||
return playerManager;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -55,21 +55,20 @@ public class ModelListener implements Listener {
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onWorldLoad(WorldInitEvent event) {
|
||||
public void onWorldInit(WorldInitEvent event) {
|
||||
World world = event.getWorld();
|
||||
world.getEntities().forEach(entity -> plugin.getModelManager().processEntities(entity));
|
||||
}
|
||||
|
||||
//TODO Find out why we need this bc uh what?
|
||||
@EventHandler
|
||||
public void onPlayerLogin(PlayerJoinEvent event) {
|
||||
public void onPlayerJoin(PlayerJoinEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
Bukkit.getGlobalRegionScheduler().runDelayed(plugin, scheduledTask -> plugin.getPlayerManager().getPlayerJoinedCache().add(player.getUniqueId()), 10);
|
||||
plugin.getModelManager().getPlayerJoinedCache().add(player.getUniqueId());
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerQuit(PlayerQuitEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
Bukkit.getGlobalRegionScheduler().runDelayed(plugin, scheduledTask -> plugin.getPlayerManager().getPlayerJoinedCache().remove(player.getUniqueId()), 10);
|
||||
plugin.getModelManager().getPlayerJoinedCache().remove(player.getUniqueId());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -102,7 +102,7 @@ public class EntityTaskManager {
|
||||
|
||||
private void sendSpawnPacket(ModelEntityData model, Player onlinePlayer) {
|
||||
EntityTaskRunnable task = model.getEntityTask();
|
||||
boolean firstJoined = !plugin.getPlayerManager().getPlayerJoinedCache().contains(onlinePlayer.getUniqueId());
|
||||
boolean firstJoined = !plugin.getModelManager().getPlayerJoinedCache().contains(onlinePlayer.getUniqueId());
|
||||
|
||||
if (firstJoined) {
|
||||
task.sendEntityData(model, onlinePlayer, plugin.getConfigManager().getConfig().getInt("join-send-delay") / 50);
|
||||
@@ -113,7 +113,7 @@ public class EntityTaskManager {
|
||||
|
||||
public boolean canSee(Player player, PacketEntity entity) {
|
||||
if (!player.isOnline()) return false;
|
||||
if (!plugin.getPlayerManager().getPlayerJoinedCache().contains(player.getUniqueId())) return false;
|
||||
if (!plugin.getModelManager().getPlayerJoinedCache().contains(player.getUniqueId())) return false;
|
||||
|
||||
Location playerLocation = player.getLocation().clone();
|
||||
Location entityLocation = entity.getLocation().clone();
|
||||
|
||||
@@ -9,19 +9,18 @@ import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Player;
|
||||
import re.imc.geysermodelengine.GeyserModelEngine;
|
||||
import re.imc.geysermodelengine.managers.model.data.ModelEntityData;
|
||||
import re.imc.geysermodelengine.runnables.EntityTaskRunnable;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
public class ModelManager {
|
||||
|
||||
private final GeyserModelEngine plugin;
|
||||
|
||||
private final HashSet<UUID> playerJoinedCache = new HashSet<>();
|
||||
|
||||
private final ConcurrentHashMap<Integer, Map<ActiveModel, ModelEntityData>> entitiesCache = new ConcurrentHashMap<>();
|
||||
private final Map<Integer, ModelEntityData> modelEntitiesCache = new ConcurrentHashMap<>();
|
||||
private final ConcurrentHashMap<Integer, ModelEntityData> modelEntitiesCache = new ConcurrentHashMap<>();
|
||||
|
||||
private final ConcurrentHashMap<Player, Pair<ActiveModel, Mount>> driversCache = new ConcurrentHashMap<>();
|
||||
|
||||
@@ -54,6 +53,10 @@ public class ModelManager {
|
||||
model.ifPresent(m -> create(modeledEntity, m));
|
||||
}
|
||||
|
||||
public HashSet<UUID> getPlayerJoinedCache() {
|
||||
return playerJoinedCache;
|
||||
}
|
||||
|
||||
public ConcurrentHashMap<Integer, Map<ActiveModel, ModelEntityData>> getEntitiesCache() {
|
||||
return entitiesCache;
|
||||
}
|
||||
|
||||
@@ -1,13 +0,0 @@
|
||||
package re.imc.geysermodelengine.managers.player;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.UUID;
|
||||
|
||||
public class PlayerManager {
|
||||
|
||||
private final HashSet<UUID> playerJoinedCache = new HashSet<>();
|
||||
|
||||
public HashSet<UUID> getPlayerJoinedCache() {
|
||||
return playerJoinedCache;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user