mirror of
https://github.com/GeyserExtensionists/GeyserModelEngine.git
synced 2025-12-19 15:09:18 +00:00
Removed the weird check for worlds
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.
@@ -8,6 +8,8 @@ authors:
|
||||
- willem.dev
|
||||
- TheLividaProject
|
||||
|
||||
load: STARTUP
|
||||
|
||||
dependencies:
|
||||
server:
|
||||
GeyserUtils:
|
||||
|
||||
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.
@@ -20,7 +20,6 @@ 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.server.ServerManager;
|
||||
import re.imc.geysermodelengine.managers.model.data.ModelEntityData;
|
||||
import re.imc.geysermodelengine.runnables.BedrockMountControlRunnable;
|
||||
import re.imc.geysermodelengine.runnables.UpdateTaskRunnable;
|
||||
@@ -31,7 +30,6 @@ import java.util.concurrent.*;
|
||||
public class GeyserModelEngine extends JavaPlugin {
|
||||
|
||||
private ConfigManager configManager;
|
||||
private ServerManager serverManager;
|
||||
|
||||
private CommandManager commandManager;
|
||||
|
||||
@@ -58,24 +56,6 @@ public class GeyserModelEngine extends JavaPlugin {
|
||||
PacketEvents.getAPI().getEventManager().registerListener(new MountPacketListener(this), PacketListenerPriority.NORMAL);
|
||||
|
||||
Bukkit.getPluginManager().registerEvents(new ModelListener(this), this);
|
||||
|
||||
Bukkit.getScheduler().runTaskLater(this, () -> {
|
||||
for (World world : Bukkit.getWorlds()) {
|
||||
|
||||
for (Entity entity : world.getEntities()) {
|
||||
|
||||
if (!modelManager.getEntitiesCache().containsKey(entity.getEntityId())) {
|
||||
|
||||
ModeledEntity modeledEntity = ModelEngineAPI.getModeledEntity(entity);
|
||||
|
||||
if (modeledEntity != null) {
|
||||
Optional<ActiveModel> model = modeledEntity.getModels().values().stream().findFirst();
|
||||
model.ifPresent(m -> modelManager.create(modeledEntity, m));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}, 100);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -98,7 +78,6 @@ public class GeyserModelEngine extends JavaPlugin {
|
||||
|
||||
private void loadManagers() {
|
||||
this.configManager = new ConfigManager(this);
|
||||
this.serverManager = new ServerManager();
|
||||
|
||||
this.commandManager = new CommandManager(this);
|
||||
|
||||
@@ -118,10 +97,6 @@ public class GeyserModelEngine extends JavaPlugin {
|
||||
return configManager;
|
||||
}
|
||||
|
||||
public ServerManager getServerManager() {
|
||||
return serverManager;
|
||||
}
|
||||
|
||||
public CommandManager getCommandManager() {
|
||||
return commandManager;
|
||||
}
|
||||
|
||||
@@ -6,12 +6,15 @@ import com.ticxo.modelengine.api.events.ModelMountEvent;
|
||||
import com.ticxo.modelengine.api.model.ActiveModel;
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.PlayerJoinEvent;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
import org.bukkit.event.world.WorldInitEvent;
|
||||
import org.bukkit.event.world.WorldLoadEvent;
|
||||
import re.imc.geysermodelengine.GeyserModelEngine;
|
||||
import re.imc.geysermodelengine.managers.model.data.ModelEntityData;
|
||||
|
||||
@@ -51,6 +54,12 @@ public class ModelListener implements Listener {
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onWorldLoad(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) {
|
||||
|
||||
@@ -1,13 +1,16 @@
|
||||
package re.imc.geysermodelengine.managers.model;
|
||||
|
||||
import com.ticxo.modelengine.api.ModelEngineAPI;
|
||||
import com.ticxo.modelengine.api.model.ActiveModel;
|
||||
import com.ticxo.modelengine.api.model.ModeledEntity;
|
||||
import org.bukkit.entity.Entity;
|
||||
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.concurrent.ConcurrentHashMap;
|
||||
|
||||
public class ModelManager {
|
||||
@@ -36,6 +39,16 @@ public class ModelManager {
|
||||
map.put(model, modelEntity);
|
||||
}
|
||||
|
||||
public void processEntities(Entity entity) {
|
||||
if (entitiesCache.containsKey(entity.getEntityId())) return;
|
||||
|
||||
ModeledEntity modeledEntity = ModelEngineAPI.getModeledEntity(entity);
|
||||
if (modeledEntity == null) return;
|
||||
|
||||
Optional<ActiveModel> model = modeledEntity.getModels().values().stream().findFirst();
|
||||
model.ifPresent(m -> create(modeledEntity, m));
|
||||
}
|
||||
|
||||
public ConcurrentHashMap<Integer, Map<ActiveModel, ModelEntityData>> getEntitiesCache() {
|
||||
return entitiesCache;
|
||||
}
|
||||
|
||||
@@ -1,14 +0,0 @@
|
||||
package re.imc.geysermodelengine.managers.server;
|
||||
|
||||
import io.papermc.paper.threadedregions.scheduler.ScheduledTask;
|
||||
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
public class ServerData {
|
||||
|
||||
private final ConcurrentHashMap<String, ScheduledTask> activeRunnablesCache = new ConcurrentHashMap<>();
|
||||
|
||||
public ConcurrentHashMap<String, ScheduledTask> getActiveRunnablesCache() {
|
||||
return activeRunnablesCache;
|
||||
}
|
||||
}
|
||||
@@ -1,14 +0,0 @@
|
||||
package re.imc.geysermodelengine.managers.server;
|
||||
|
||||
public class ServerManager {
|
||||
|
||||
private final ServerData serverData;
|
||||
|
||||
public ServerManager() {
|
||||
this.serverData = new ServerData();
|
||||
}
|
||||
|
||||
public ServerData getServerData() {
|
||||
return serverData;
|
||||
}
|
||||
}
|
||||
@@ -8,6 +8,8 @@ authors:
|
||||
- willem.dev
|
||||
- TheLividaProject
|
||||
|
||||
load: STARTUP
|
||||
|
||||
dependencies:
|
||||
server:
|
||||
GeyserUtils:
|
||||
|
||||
Reference in New Issue
Block a user