9 Commits
1.0.0 ... 1.0.1

Author SHA1 Message Date
TheLividaProject
63c20d3f74 updated to PE 2.9.0 SNAPSHOT 2025-07-02 13:41:42 +01:00
TheLividaProject
c83fc4dd0a updated most dependencies 2025-07-02 12:50:47 +01:00
TheLividaProject
c0ed740b47 updated dependencies 2025-06-24 16:58:43 +01:00
TheLividaProject
ed61baebf2 updated gradle.build.kts 2025-05-28 12:16:43 +01:00
TheLividaProject
e22170d219 Removed the weird schedulers on playerJoin and playerQuit 2025-05-28 11:46:48 +01:00
TheLividaProject
6e4947d827 Updated playerJoinedCache to use UUID instead of player object 2025-05-28 11:37:32 +01:00
TheLividaProject
0a1151be75 merged BedrockMountControlManager to ModelManager 2025-05-28 11:12:21 +01:00
TheLividaProject
16fa85f52e Removed the weird check for worlds 2025-05-28 02:49:55 +01:00
TheLividaProject
ff1133a4d5 added auto file create (may of forgotten to add it)
TODO
-Need to move the other schedule to a better system
2025-05-28 01:14:30 +01:00
68 changed files with 191 additions and 173 deletions

Binary file not shown.

14
.idea/compiler.xml generated
View File

@@ -1,18 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<project version="4"> <project version="4">
<component name="CompilerConfiguration"> <component name="CompilerConfiguration">
<annotationProcessing> <bytecodeTargetLevel target="21" />
<profile name="Maven default annotation processors profile" enabled="true">
<sourceOutputDir name="target/generated-sources/annotations" />
<sourceTestOutputDir name="target/generated-test-sources/test-annotations" />
<outputRelativeToContentRoot value="true" />
<module name="GeyserModelEngine" />
</profile>
</annotationProcessing>
</component>
<component name="JavacSettings">
<option name="ADDITIONAL_OPTIONS_OVERRIDE">
<module name="GeyserModelEngine" options="" />
</option>
</component> </component>
</project> </project>

16
.idea/gradle.xml generated Normal file
View File

@@ -0,0 +1,16 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="GradleMigrationSettings" migrationVersion="1" />
<component name="GradleSettings">
<option name="linkedExternalProjectsSettings">
<GradleProjectSettings>
<option name="externalProjectPath" value="$PROJECT_DIR$" />
<option name="modules">
<set>
<option value="$PROJECT_DIR$" />
</set>
</option>
</GradleProjectSettings>
</option>
</component>
</project>

7
.idea/misc.xml generated
View File

@@ -1,12 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<project version="4"> <project version="4">
<component name="ExternalStorageConfigurationManager" enabled="true" /> <component name="ExternalStorageConfigurationManager" enabled="true" />
<component name="MavenProjectsManager">
<option name="originalFiles">
<list>
<option value="$PROJECT_DIR$/pom.xml" />
</list>
</option>
</component>
<component name="ProjectRootManager" version="2" languageLevel="JDK_21" default="true" project-jdk-name="21" project-jdk-type="JavaSDK" /> <component name="ProjectRootManager" version="2" languageLevel="JDK_21" default="true" project-jdk-name="21" project-jdk-type="JavaSDK" />
</project> </project>

118
.idea/workspace.xml generated
View File

@@ -4,38 +4,126 @@
<option name="autoReloadType" value="SELECTIVE" /> <option name="autoReloadType" value="SELECTIVE" />
</component> </component>
<component name="ChangeListManager"> <component name="ChangeListManager">
<list default="true" id="ff2e9770-ec88-4715-adeb-b9dbda130e1a" name="Changes" comment="" /> <list default="true" id="ff2e9770-ec88-4715-adeb-b9dbda130e1a" name="Changes" comment="">
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/main/java/re/imc/geysermodelengine/commands/geysermodelenginecommands/GeyserModelEngineReloadCommand.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/re/imc/geysermodelengine/commands/geysermodelenginecommands/GeyserModelEngineReloadCommand.java" afterDir="false" />
</list>
<option name="SHOW_DIALOG" value="false" /> <option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" /> <option name="HIGHLIGHT_CONFLICTS" value="true" />
<option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" /> <option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
<option name="LAST_RESOLUTION" value="IGNORE" /> <option name="LAST_RESOLUTION" value="IGNORE" />
</component> </component>
<component name="ExternalProjectsData">
<projectState path="$PROJECT_DIR$">
<ProjectState />
</projectState>
</component>
<component name="ExternalProjectsManager">
<system id="GRADLE">
<state>
<task path="$PROJECT_DIR$">
<activation />
</task>
<projects_view>
<tree_state>
<expand>
<path>
<item name="" type="6a2764b6:ExternalProjectsStructure$RootNode" />
<item name="GeyserModelEngine" type="f1a62948:ProjectNode" />
</path>
<path>
<item name="" type="6a2764b6:ExternalProjectsStructure$RootNode" />
<item name="GeyserModelEngine" type="f1a62948:ProjectNode" />
<item name="Tasks" type="e4a08cd1:TasksNode" />
</path>
<path>
<item name="" type="6a2764b6:ExternalProjectsStructure$RootNode" />
<item name="GeyserModelEngine" type="f1a62948:ProjectNode" />
<item name="Tasks" type="e4a08cd1:TasksNode" />
<item name="build" type="c8890929:TasksNode$1" />
</path>
</expand>
<select />
</tree_state>
</projects_view>
</state>
</system>
</component>
<component name="FileTemplateManagerImpl">
<option name="RECENT_TEMPLATES">
<list>
<option value="Interface" />
<option value="Class" />
</list>
</option>
</component>
<component name="Git.Settings"> <component name="Git.Settings">
<option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" /> <option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" />
</component> </component>
<component name="MavenRunner"> <component name="MavenRunner">
<option name="delegateBuildToMaven" value="true" /> <option name="delegateBuildToMaven" value="true" />
</component> </component>
<component name="ProjectColorInfo"><![CDATA[{ <component name="ProjectColorInfo">{
"associatedIndex": 8 &quot;associatedIndex&quot;: 8
}]]></component> }</component>
<component name="ProjectId" id="2xedme8VKz03tyMoE1OuGEibnGo" /> <component name="ProjectId" id="2xedme8VKz03tyMoE1OuGEibnGo" />
<component name="ProjectLevelVcsManager">
<ConfirmationsSetting value="2" id="Add" />
</component>
<component name="ProjectViewState"> <component name="ProjectViewState">
<option name="hideEmptyMiddlePackages" value="true" /> <option name="hideEmptyMiddlePackages" value="true" />
<option name="showLibraryContents" value="true" /> <option name="showLibraryContents" value="true" />
</component> </component>
<component name="PropertiesComponent"><![CDATA[{ <component name="PropertiesComponent">{
"keyToString": { &quot;keyToString&quot;: {
"Maven.GeyserModelEngine [install...].executor": "Run", &quot;Gradle.GeyserModelEngine [jar].executor&quot;: &quot;Run&quot;,
"Maven.GeyserModelEngine [install].executor": "Run", &quot;Maven.GeyserModelEngine [install...].executor&quot;: &quot;Run&quot;,
"ModuleVcsDetector.initialDetectionPerformed": "true", &quot;Maven.GeyserModelEngine [install].executor&quot;: &quot;Run&quot;,
"RunOnceActivity.ShowReadmeOnStart": "true", &quot;ModuleVcsDetector.initialDetectionPerformed&quot;: &quot;true&quot;,
"RunOnceActivity.git.unshallow": "true", &quot;RunOnceActivity.ShowReadmeOnStart&quot;: &quot;true&quot;,
"git-widget-placeholder": "main", &quot;RunOnceActivity.git.unshallow&quot;: &quot;true&quot;,
"last_opened_file_path": "D:/Coding/Forks/Minecraft/GeyserModelEngine", &quot;git-widget-placeholder&quot;: &quot;main&quot;,
"settings.editor.selected.configurable": "reference.settings.project.maven.runner" &quot;last_opened_file_path&quot;: &quot;D:/Coding/Forks/Minecraft/GeyserModelEngine&quot;,
&quot;project.structure.last.edited&quot;: &quot;Project&quot;,
&quot;project.structure.proportion&quot;: &quot;0.0&quot;,
&quot;project.structure.side.proportion&quot;: &quot;0.2&quot;,
&quot;settings.editor.selected.configurable&quot;: &quot;reference.settings.project.maven.runner&quot;
} }
}]]></component> }</component>
<component name="RecentsManager">
<key name="CopyFile.RECENT_KEYS">
<recent name="D:\Coding\Forks\Minecraft\GeyserModelEngine" />
</key>
</component>
<component name="RunManager">
<configuration name="GeyserModelEngine [jar]" type="GradleRunConfiguration" factoryName="Gradle" temporary="true">
<ExternalSystemSettings>
<option name="executionName" />
<option name="externalProjectPath" value="$PROJECT_DIR$" />
<option name="externalSystemIdString" value="GRADLE" />
<option name="scriptParameters" />
<option name="taskDescriptions">
<list />
</option>
<option name="taskNames">
<list>
<option value="jar" />
</list>
</option>
<option name="vmOptions" />
</ExternalSystemSettings>
<ExternalSystemDebugServerProcess>true</ExternalSystemDebugServerProcess>
<ExternalSystemReattachDebugProcess>true</ExternalSystemReattachDebugProcess>
<DebugAllEnabled>false</DebugAllEnabled>
<RunAsTest>false</RunAsTest>
<method v="2" />
</configuration>
<recent_temporary>
<list>
<item itemvalue="Gradle.GeyserModelEngine [jar]" />
</list>
</recent_temporary>
</component>
<component name="TaskManager"> <component name="TaskManager">
<task active="true" id="Default" summary="Default task"> <task active="true" id="Default" summary="Default task">
<changelist id="ff2e9770-ec88-4715-adeb-b9dbda130e1a" name="Changes" comment="" /> <changelist id="ff2e9770-ec88-4715-adeb-b9dbda130e1a" name="Changes" comment="" />

View File

@@ -9,32 +9,28 @@ version = "1.0.0"
repositories { repositories {
mavenCentral() mavenCentral()
maven("https://repo.papermc.io/repository/maven-public/") maven("https://repo.papermc.io/repository/maven-public/")
maven("https://s01.oss.sonatype.org/content/repositories/snapshots/") maven("https://central.sonatype.com/repository/maven-snapshots/")
maven("https://mvn.lumine.io/repository/maven-public/") maven("https://mvn.lumine.io/repository/maven-public/")
maven("https://repo.opencollab.dev/maven-releases/") { maven("https://repo.opencollab.dev/maven-releases/")
isAllowInsecureProtocol = true maven("https://repo.opencollab.dev/maven-snapshots/")
}
maven("https://repo.opencollab.dev/maven-snapshots/") {
isAllowInsecureProtocol = true
}
maven("https://repo.codemc.io/repository/maven-public/") maven("https://repo.codemc.io/repository/maven-public/")
maven("https://repo.codemc.io/repository/maven-releases/") maven("https://repo.codemc.io/repository/maven-releases/")
} }
dependencies { dependencies {
compileOnly("io.papermc.paper:paper-api:1.21.5-R0.1-SNAPSHOT") compileOnly("io.papermc.paper:paper-api:1.21.7-R0.1-SNAPSHOT")
implementation("dev.jorel:commandapi-bukkit-shade-mojang-mapped:10.0.1") implementation("dev.jorel:commandapi-bukkit-shade-mojang-mapped:10.1.1")
compileOnly("com.ticxo.modelengine:ModelEngine:R4.0.4") compileOnly("com.ticxo.modelengine:ModelEngine:R4.0.4")
compileOnly(files("libs/geyserutils-spigot-1.0-SNAPSHOT.jar")) compileOnly(files("libs/geyserutils-spigot-1.0-SNAPSHOT.jar"))
compileOnly("org.geysermc.floodgate:api:2.2.2-SNAPSHOT") compileOnly("org.geysermc.floodgate:api:2.2.4-SNAPSHOT")
implementation("com.github.retrooper:packetevents-spigot:2.8.0") implementation("com.github.retrooper:packetevents-spigot:2.9.0-SNAPSHOT")
implementation("org.reflections:reflections:0.10.2") implementation("org.reflections:reflections:0.10.2")
} }

File diff suppressed because one or more lines are too long

View File

@@ -8,6 +8,8 @@ authors:
- willem.dev - willem.dev
- TheLividaProject - TheLividaProject
load: STARTUP
dependencies: dependencies:
server: server:
GeyserUtils: GeyserUtils:

View File

@@ -2,25 +2,18 @@ package re.imc.geysermodelengine;
import com.github.retrooper.packetevents.PacketEvents; import com.github.retrooper.packetevents.PacketEvents;
import com.github.retrooper.packetevents.event.PacketListenerPriority; import com.github.retrooper.packetevents.event.PacketListenerPriority;
import com.ticxo.modelengine.api.ModelEngineAPI;
import com.ticxo.modelengine.api.model.ActiveModel; import com.ticxo.modelengine.api.model.ActiveModel;
import com.ticxo.modelengine.api.model.ModeledEntity;
import dev.jorel.commandapi.CommandAPI; import dev.jorel.commandapi.CommandAPI;
import dev.jorel.commandapi.CommandAPIBukkitConfig; import dev.jorel.commandapi.CommandAPIBukkitConfig;
import io.github.retrooper.packetevents.factory.spigot.SpigotPacketEventsBuilder; import io.github.retrooper.packetevents.factory.spigot.SpigotPacketEventsBuilder;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.World;
import org.bukkit.entity.Entity;
import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.plugin.java.JavaPlugin;
import re.imc.geysermodelengine.listener.ModelListener; import re.imc.geysermodelengine.listener.ModelListener;
import re.imc.geysermodelengine.listener.MountPacketListener; import re.imc.geysermodelengine.listener.MountPacketListener;
import re.imc.geysermodelengine.managers.ConfigManager; import re.imc.geysermodelengine.managers.ConfigManager;
import re.imc.geysermodelengine.managers.bedrock.BedrockMountControlManager;
import re.imc.geysermodelengine.managers.commands.CommandManager; import re.imc.geysermodelengine.managers.commands.CommandManager;
import re.imc.geysermodelengine.managers.model.EntityTaskManager; import re.imc.geysermodelengine.managers.model.EntityTaskManager;
import re.imc.geysermodelengine.managers.model.ModelManager; 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.managers.model.data.ModelEntityData;
import re.imc.geysermodelengine.runnables.BedrockMountControlRunnable; import re.imc.geysermodelengine.runnables.BedrockMountControlRunnable;
import re.imc.geysermodelengine.runnables.UpdateTaskRunnable; import re.imc.geysermodelengine.runnables.UpdateTaskRunnable;
@@ -31,15 +24,11 @@ import java.util.concurrent.*;
public class GeyserModelEngine extends JavaPlugin { public class GeyserModelEngine extends JavaPlugin {
private ConfigManager configManager; private ConfigManager configManager;
private ServerManager serverManager;
private CommandManager commandManager; private CommandManager commandManager;
private ModelManager modelManager; private ModelManager modelManager;
private EntityTaskManager entityTaskManager; private EntityTaskManager entityTaskManager;
private BedrockMountControlManager bedrockMountControlManager;
private PlayerManager playerManager;
@Override @Override
public void onLoad() { public void onLoad() {
@@ -58,24 +47,6 @@ public class GeyserModelEngine extends JavaPlugin {
PacketEvents.getAPI().getEventManager().registerListener(new MountPacketListener(this), PacketListenerPriority.NORMAL); PacketEvents.getAPI().getEventManager().registerListener(new MountPacketListener(this), PacketListenerPriority.NORMAL);
Bukkit.getPluginManager().registerEvents(new ModelListener(this), this); 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 @Override
@@ -98,19 +69,15 @@ public class GeyserModelEngine extends JavaPlugin {
private void loadManagers() { private void loadManagers() {
this.configManager = new ConfigManager(this); this.configManager = new ConfigManager(this);
this.serverManager = new ServerManager();
this.commandManager = new CommandManager(this); this.commandManager = new CommandManager(this);
this.modelManager = new ModelManager(this); this.modelManager = new ModelManager(this);
this.entityTaskManager = new EntityTaskManager(this); this.entityTaskManager = new EntityTaskManager(this);
this.bedrockMountControlManager = new BedrockMountControlManager();
this.playerManager = new PlayerManager();
} }
private void loadRunnables() { private void loadRunnables() {
Bukkit.getAsyncScheduler().runAtFixedRate(this, new UpdateTaskRunnable(this), 10, configManager.getConfig().getLong("entity-position-update-period"), TimeUnit.MILLISECONDS); Bukkit.getAsyncScheduler().runAtFixedRate(this, new UpdateTaskRunnable(this), 10, configManager.getConfig().getLong("entity-position-update-period", 35), TimeUnit.MILLISECONDS);
Bukkit.getAsyncScheduler().runAtFixedRate(this, new BedrockMountControlRunnable(this), 1, 1, TimeUnit.MILLISECONDS); Bukkit.getAsyncScheduler().runAtFixedRate(this, new BedrockMountControlRunnable(this), 1, 1, TimeUnit.MILLISECONDS);
} }
@@ -118,10 +85,6 @@ public class GeyserModelEngine extends JavaPlugin {
return configManager; return configManager;
} }
public ServerManager getServerManager() {
return serverManager;
}
public CommandManager getCommandManager() { public CommandManager getCommandManager() {
return commandManager; return commandManager;
} }
@@ -133,12 +96,4 @@ public class GeyserModelEngine extends JavaPlugin {
public EntityTaskManager getEntityTaskManager() { public EntityTaskManager getEntityTaskManager() {
return entityTaskManager; return entityTaskManager;
} }
public BedrockMountControlManager getBedrockMountControlManager() {
return bedrockMountControlManager;
}
public PlayerManager getPlayerManager() {
return playerManager;
}
} }

View File

@@ -21,10 +21,7 @@ public class GeyserModelEngineReloadCommand implements SubCommands {
return new CommandAPICommand("reload") return new CommandAPICommand("reload")
.withPermission("geysermodelengine.commands.reload") .withPermission("geysermodelengine.commands.reload")
.executes((sender, args) -> { .executes((sender, args) -> {
Bukkit.getAsyncScheduler().runNow(plugin, scheduledTask -> { Bukkit.getAsyncScheduler().runNow(plugin, scheduledTask -> plugin.getConfigManager().load());
plugin.getConfigManager().load();
});
sender.sendMessage(colourUtils.miniFormat(plugin.getConfigManager().getLang().getString("commands.reload.successfully-reloaded"))); sender.sendMessage(colourUtils.miniFormat(plugin.getConfigManager().getLang().getString("commands.reload.successfully-reloaded")));
}); });
} }

View File

@@ -6,12 +6,15 @@ import com.ticxo.modelengine.api.events.ModelMountEvent;
import com.ticxo.modelengine.api.model.ActiveModel; import com.ticxo.modelengine.api.model.ActiveModel;
import org.apache.commons.lang3.tuple.Pair; import org.apache.commons.lang3.tuple.Pair;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.World;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority; import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener; import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerJoinEvent; import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerQuitEvent; 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.GeyserModelEngine;
import re.imc.geysermodelengine.managers.model.data.ModelEntityData; import re.imc.geysermodelengine.managers.model.data.ModelEntityData;
@@ -40,25 +43,32 @@ 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.getBedrockMountControlManager().getDriversCache().put(player, Pair.of(event.getVehicle(), event.getSeat())); plugin.getModelManager().getDriversCache().put(player, 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.getBedrockMountControlManager().getDriversCache().remove(player); plugin.getModelManager().getDriversCache().remove(player);
} }
} }
//TODO Find out why we need this bc uh what?
@EventHandler @EventHandler
public void onPlayerLogin(PlayerJoinEvent event) { public void onWorldInit(WorldInitEvent event) {
Bukkit.getGlobalRegionScheduler().runDelayed(plugin, scheduledTask -> plugin.getPlayerManager().getPlayerJoinedCache().add(event.getPlayer()), 10); World world = event.getWorld();
world.getEntities().forEach(entity -> plugin.getModelManager().processEntities(entity));
}
@EventHandler
public void onPlayerJoin(PlayerJoinEvent event) {
Player player = event.getPlayer();
plugin.getModelManager().getPlayerJoinedCache().add(player.getUniqueId());
} }
@EventHandler @EventHandler
public void onPlayerQuit(PlayerQuitEvent event) { public void onPlayerQuit(PlayerQuitEvent event) {
Bukkit.getGlobalRegionScheduler().runDelayed(plugin, scheduledTask -> plugin.getPlayerManager().getPlayerJoinedCache().remove(event.getPlayer()), 10); Player player = event.getPlayer();
plugin.getModelManager().getPlayerJoinedCache().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.getBedrockMountControlManager().getDriversCache().get(player); Pair<ActiveModel, Mount> seat = plugin.getModelManager().getDriversCache().get(player);
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

@@ -18,6 +18,12 @@ public class ConfigManager {
} }
public void load() { public void load() {
if (!plugin.getDataFolder().exists()) {
plugin.getDataFolder().mkdir();
plugin.saveResource("config.yml", false);
plugin.saveResource("Lang/messages.yml", false);
}
this.config = YamlConfiguration.loadConfiguration(new File(plugin.getDataFolder(), "config.yml")); this.config = YamlConfiguration.loadConfiguration(new File(plugin.getDataFolder(), "config.yml"));
this.lang = YamlConfiguration.loadConfiguration(new File(plugin.getDataFolder(), "Lang/messages.yml")); this.lang = YamlConfiguration.loadConfiguration(new File(plugin.getDataFolder(), "Lang/messages.yml"));
} }

View File

@@ -1,17 +0,0 @@
package re.imc.geysermodelengine.managers.bedrock;
import com.ticxo.modelengine.api.model.ActiveModel;
import com.ticxo.modelengine.api.model.bone.type.Mount;
import org.apache.commons.lang3.tuple.Pair;
import org.bukkit.entity.Player;
import java.util.concurrent.ConcurrentHashMap;
public class BedrockMountControlManager {
private final ConcurrentHashMap<Player, Pair<ActiveModel, Mount>> driversCache = new ConcurrentHashMap<>();
public ConcurrentHashMap<Player, Pair<ActiveModel, Mount>> getDriversCache() {
return driversCache;
}
}

View File

@@ -102,7 +102,7 @@ public class EntityTaskManager {
private void sendSpawnPacket(ModelEntityData model, Player onlinePlayer) { private void sendSpawnPacket(ModelEntityData model, Player onlinePlayer) {
EntityTaskRunnable task = model.getEntityTask(); EntityTaskRunnable task = model.getEntityTask();
boolean firstJoined = !plugin.getPlayerManager().getPlayerJoinedCache().contains(onlinePlayer); boolean firstJoined = !plugin.getModelManager().getPlayerJoinedCache().contains(onlinePlayer.getUniqueId());
if (firstJoined) { if (firstJoined) {
task.sendEntityData(model, onlinePlayer, plugin.getConfigManager().getConfig().getInt("join-send-delay") / 50); 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) { public boolean canSee(Player player, PacketEntity entity) {
if (!player.isOnline()) return false; if (!player.isOnline()) return false;
if (!plugin.getPlayerManager().getPlayerJoinedCache().contains(player)) return false; if (!plugin.getModelManager().getPlayerJoinedCache().contains(player.getUniqueId())) return false;
Location playerLocation = player.getLocation().clone(); Location playerLocation = player.getLocation().clone();
Location entityLocation = entity.getLocation().clone(); Location entityLocation = entity.getLocation().clone();

View File

@@ -1,21 +1,28 @@
package re.imc.geysermodelengine.managers.model; 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.ActiveModel;
import com.ticxo.modelengine.api.model.ModeledEntity; import com.ticxo.modelengine.api.model.ModeledEntity;
import com.ticxo.modelengine.api.model.bone.type.Mount;
import org.apache.commons.lang3.tuple.Pair;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
import re.imc.geysermodelengine.GeyserModelEngine; import re.imc.geysermodelengine.GeyserModelEngine;
import re.imc.geysermodelengine.managers.model.data.ModelEntityData; import re.imc.geysermodelengine.managers.model.data.ModelEntityData;
import re.imc.geysermodelengine.runnables.EntityTaskRunnable;
import java.util.HashMap; import java.util.*;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentHashMap;
public class ModelManager { public class ModelManager {
private final GeyserModelEngine plugin; private final GeyserModelEngine plugin;
private final HashSet<UUID> playerJoinedCache = new HashSet<>();
private final ConcurrentHashMap<Integer, Map<ActiveModel, ModelEntityData>> entitiesCache = new ConcurrentHashMap<>(); 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<>();
public ModelManager(GeyserModelEngine plugin) { public ModelManager(GeyserModelEngine plugin) {
this.plugin = plugin; this.plugin = plugin;
@@ -36,11 +43,29 @@ public class ModelManager {
map.put(model, modelEntity); 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 HashSet<UUID> getPlayerJoinedCache() {
return playerJoinedCache;
}
public ConcurrentHashMap<Integer, Map<ActiveModel, ModelEntityData>> getEntitiesCache() { public ConcurrentHashMap<Integer, Map<ActiveModel, ModelEntityData>> getEntitiesCache() {
return entitiesCache; return entitiesCache;
} }
public Map<Integer, ModelEntityData> getModelEntitiesCache() { public ConcurrentHashMap<Integer, ModelEntityData> getModelEntitiesCache() {
return modelEntitiesCache; return modelEntitiesCache;
} }
public ConcurrentHashMap<Player, Pair<ActiveModel, Mount>> getDriversCache() {
return driversCache;
}
} }

View File

@@ -1,14 +0,0 @@
package re.imc.geysermodelengine.managers.player;
import org.bukkit.entity.Player;
import java.util.HashSet;
public class PlayerManager {
private final HashSet<Player> playerJoinedCache = new HashSet<>();
public HashSet<Player> getPlayerJoinedCache() {
return playerJoinedCache;
}
}

View File

@@ -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;
}
}

View File

@@ -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;
}
}

View File

@@ -28,13 +28,12 @@ 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.getBedrockMountControlManager().getDriversCache().get(player); Pair<ActiveModel, Mount> seat = plugin.getModelManager().getDriversCache().get(player);
if (seat == null) continue; if (seat == null) continue;
if (pitch < -30) { if (pitch < -30) {
MountController controller = ModelEngineAPI.getMountPairManager() MountController controller = ModelEngineAPI.getMountPairManager().getController(player.getUniqueId());
.getController(player.getUniqueId());
if (controller != null) { if (controller != null) {
MountController.MountInput input = controller.getInput(); MountController.MountInput input = controller.getInput();
if (input != null) { if (input != null) {

View File

@@ -8,6 +8,8 @@ authors:
- willem.dev - willem.dev
- TheLividaProject - TheLividaProject
load: STARTUP
dependencies: dependencies:
server: server:
GeyserUtils: GeyserUtils: