updated BetterModel Support

This commit is contained in:
xSquishyLiam
2025-11-25 03:25:17 +00:00
parent 76b857e8a4
commit be7b067889
9 changed files with 59 additions and 64 deletions

52
.idea/workspace.xml generated
View File

@@ -11,7 +11,7 @@
<option name="LAST_RESOLUTION" value="IGNORE" />
</component>
<component name="DarkyenusTimeTracker">
<option name="totalTimeSeconds" value="20478" />
<option name="totalTimeSeconds" value="21532" />
</component>
<component name="ExternalProjectsData">
<projectState path="$PROJECT_DIR$">
@@ -78,31 +78,31 @@
<option name="hideEmptyMiddlePackages" value="true" />
<option name="showLibraryContents" value="true" />
</component>
<component name="PropertiesComponent"><![CDATA[{
"keyToString": {
"Gradle.Build GeyserModelEngine.executor": "Run",
"Gradle.Download Sources.executor": "Run",
"Gradle.GeyserModelEngine [buildDependents].executor": "Run",
"Gradle.GeyserModelEngine [buildNeeded].executor": "Run",
"Gradle.GeyserModelEngine [build].executor": "Run",
"Gradle.GeyserModelEngine [clean].executor": "Run",
"Gradle.GeyserModelEngine [jar].executor": "Run",
"Maven.GeyserModelEngine [install...].executor": "Run",
"Maven.GeyserModelEngine [install].executor": "Run",
"ModuleVcsDetector.initialDetectionPerformed": "true",
"RunOnceActivity.ShowReadmeOnStart": "true",
"RunOnceActivity.TerminalTabsStorage.copyFrom.TerminalArrangementManager.252": "true",
"RunOnceActivity.git.unshallow": "true",
"git-widget-placeholder": "main",
"ignore.virus.scanning.warn.message": "true",
"kotlin-language-version-configured": "true",
"last_opened_file_path": "D:/Coding/Forks/Minecraft/GeyserModelEngine/geyser",
"project.structure.last.edited": "Project",
"project.structure.proportion": "0.0",
"project.structure.side.proportion": "0.2",
"settings.editor.selected.configurable": "reference.settingsdialog.project.gradle"
<component name="PropertiesComponent">{
&quot;keyToString&quot;: {
&quot;Gradle.Build GeyserModelEngine.executor&quot;: &quot;Run&quot;,
&quot;Gradle.Download Sources.executor&quot;: &quot;Run&quot;,
&quot;Gradle.GeyserModelEngine [buildDependents].executor&quot;: &quot;Run&quot;,
&quot;Gradle.GeyserModelEngine [buildNeeded].executor&quot;: &quot;Run&quot;,
&quot;Gradle.GeyserModelEngine [build].executor&quot;: &quot;Run&quot;,
&quot;Gradle.GeyserModelEngine [clean].executor&quot;: &quot;Run&quot;,
&quot;Gradle.GeyserModelEngine [jar].executor&quot;: &quot;Run&quot;,
&quot;Maven.GeyserModelEngine [install...].executor&quot;: &quot;Run&quot;,
&quot;Maven.GeyserModelEngine [install].executor&quot;: &quot;Run&quot;,
&quot;ModuleVcsDetector.initialDetectionPerformed&quot;: &quot;true&quot;,
&quot;RunOnceActivity.ShowReadmeOnStart&quot;: &quot;true&quot;,
&quot;RunOnceActivity.TerminalTabsStorage.copyFrom.TerminalArrangementManager.252&quot;: &quot;true&quot;,
&quot;RunOnceActivity.git.unshallow&quot;: &quot;true&quot;,
&quot;git-widget-placeholder&quot;: &quot;main&quot;,
&quot;ignore.virus.scanning.warn.message&quot;: &quot;true&quot;,
&quot;kotlin-language-version-configured&quot;: &quot;true&quot;,
&quot;last_opened_file_path&quot;: &quot;D:/Coding/Forks/Minecraft/GeyserModelEngine/geyser&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.settingsdialog.project.gradle&quot;
}
}]]></component>
}</component>
<component name="RecentsManager">
<key name="CopyFile.RECENT_KEYS">
<recent name="D:\Coding\Forks\Minecraft\GeyserModelEngine\geyser" />
@@ -231,8 +231,8 @@
<item itemvalue="Gradle.GeyserModelEngine [build]" />
<item itemvalue="Gradle.GeyserModelEngine [jar]" />
<item itemvalue="Gradle.GeyserModelEngine [clean]" />
<item itemvalue="Gradle.GeyserModelEngine [buildDependents]" />
<item itemvalue="Gradle.GeyserModelEngine [buildNeeded]" />
<item itemvalue="Gradle.GeyserModelEngine [buildDependents]" />
</list>
</recent_temporary>
</component>

View File

@@ -21,7 +21,7 @@ repositories {
dependencies {
compileOnly("io.papermc.paper:paper-api:1.21.10-R0.1-SNAPSHOT")
implementation("dev.jorel:commandapi-paper-shade:11.0.0")
// implementation("dev.jorel:commandapi-paper-shade:11.0.0")
compileOnly("com.ticxo.modelengine:ModelEngine:R4.0.9")
compileOnly("io.github.toxicity188:bettermodel:1.14.0")

View File

@@ -2,8 +2,6 @@ package re.imc.geysermodelengine;
import com.github.retrooper.packetevents.PacketEvents;
import com.github.retrooper.packetevents.event.PacketListenerPriority;
import dev.jorel.commandapi.CommandAPI;
import dev.jorel.commandapi.CommandAPIPaperConfig;
import io.github.retrooper.packetevents.factory.spigot.SpigotPacketEventsBuilder;
import org.bstats.bukkit.Metrics;
import org.bukkit.Bukkit;
@@ -35,7 +33,7 @@ public class GeyserModelEngine extends JavaPlugin {
PacketEvents.setAPI(SpigotPacketEventsBuilder.build(this));
PacketEvents.getAPI().load();
CommandAPI.onLoad(new CommandAPIPaperConfig(this));
// CommandAPI.onLoad(new CommandAPIPaperConfig(this));
}
@Override
@@ -56,12 +54,12 @@ public class GeyserModelEngine extends JavaPlugin {
this.modelManager.removeEntities();
PacketEvents.getAPI().terminate();
CommandAPI.onDisable();
// CommandAPI.onDisable();
}
private void loadHooks() {
PacketEvents.getAPI().init();
CommandAPI.onEnable();
// CommandAPI.onEnable();
}
private void loadBStats() {

View File

@@ -1,7 +1,5 @@
package re.imc.geysermodelengine.commands.geysermodelenginecommands;
import dev.jorel.commandapi.CommandAPICommand;
import org.bukkit.Bukkit;
import re.imc.geysermodelengine.GeyserModelEngine;
import re.imc.geysermodelengine.managers.commands.subcommands.SubCommands;
import re.imc.geysermodelengine.util.ColourUtils;
@@ -16,13 +14,13 @@ public class GeyserModelEngineReloadCommand implements SubCommands {
this.plugin = plugin;
}
@Override
public CommandAPICommand onCommand() {
return new CommandAPICommand("reload")
.withPermission("geysermodelengine.commands.reload")
.executes((sender, args) -> {
Bukkit.getAsyncScheduler().runNow(plugin, scheduledTask -> plugin.getConfigManager().load());
sender.sendMessage(colourUtils.miniFormat(plugin.getConfigManager().getLang().getString("commands.reload.successfully-reloaded")));
});
}
// @Override
// public CommandAPICommand onCommand() {
// return new CommandAPICommand("reload")
// .withPermission("geysermodelengine.commands.reload")
// .executes((sender, args) -> {
// Bukkit.getAsyncScheduler().runNow(plugin, scheduledTask -> plugin.getConfigManager().load());
// sender.sendMessage(colourUtils.miniFormat(plugin.getConfigManager().getLang().getString("commands.reload.successfully-reloaded")));
// });
// }
}

View File

@@ -1,6 +1,5 @@
package re.imc.geysermodelengine.managers.commands.managers.geysermodelengine;
import dev.jorel.commandapi.CommandAPICommand;
import re.imc.geysermodelengine.GeyserModelEngine;
import re.imc.geysermodelengine.commands.geysermodelenginecommands.GeyserModelEngineReloadCommand;
import re.imc.geysermodelengine.managers.commands.CommandManagers;
@@ -19,11 +18,11 @@ public class GeyserModelEngineCommandManager implements CommandManagers {
}
private void registerCommand() {
CommandAPICommand geyserModelEngineCommand = new CommandAPICommand(getName());
commands.forEach(subCommands -> geyserModelEngineCommand.withSubcommand(subCommands.onCommand()));
geyserModelEngineCommand.register();
// CommandAPICommand geyserModelEngineCommand = new CommandAPICommand(getName());
//
// commands.forEach(subCommands -> geyserModelEngineCommand.withSubcommand(subCommands.onCommand()));
//
// geyserModelEngineCommand.register();
}
@Override

View File

@@ -1,11 +1,9 @@
package re.imc.geysermodelengine.managers.commands.subcommands;
import dev.jorel.commandapi.CommandAPICommand;
public interface SubCommands {
/**
* Subcommand setup
*/
CommandAPICommand onCommand();
// CommandAPICommand onCommand();
}

View File

@@ -2,10 +2,10 @@ package re.imc.geysermodelengine.managers.model.entity;
import com.github.retrooper.packetevents.protocol.entity.type.EntityTypes;
import com.google.common.collect.Sets;
import kr.toxicity.model.api.entity.BaseEntity;
import kr.toxicity.model.api.tracker.EntityTracker;
import kr.toxicity.model.api.tracker.Tracker;
import org.bukkit.Location;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
import re.imc.geysermodelengine.GeyserModelEngine;
import re.imc.geysermodelengine.managers.model.taskshandler.BetterModelTaskHandler;
@@ -20,7 +20,7 @@ public class BetterModelEntityData implements EntityData {
private final PacketEntity entity;
private final Set<Player> viewers = Sets.newConcurrentHashSet();
private final Entity entitySource;
private final BaseEntity entitySource;
private final Tracker tracker;
private final EntityTracker entityTracker;
@@ -28,20 +28,20 @@ public class BetterModelEntityData implements EntityData {
private boolean hurt;
public BetterModelEntityData(GeyserModelEngine plugin, Entity entitySource, Tracker tracker, EntityTracker entityTracker) {
public BetterModelEntityData(GeyserModelEngine plugin, BaseEntity entitySource, Tracker tracker, EntityTracker entityTracker) {
this.plugin = plugin;
this.entitySource = entitySource;
this.tracker = tracker;
this.entityTracker = entityTracker;
this.entity = new PacketEntity(EntityTypes.PIG, viewers, entitySource.getLocation());
this.entity = new PacketEntity(EntityTypes.PIG, viewers, entitySource.location());
runEntityTask();
}
@Override
public void teleportToModel() {
Location location = entitySource.getLocation();
Location location = entitySource.location();
entity.teleport(location);
}
@@ -68,7 +68,7 @@ public class BetterModelEntityData implements EntityData {
this.hurt = hurt;
}
public Entity getEntitySource() {
public BaseEntity getEntitySource() {
return entitySource;
}

View File

@@ -1,5 +1,6 @@
package re.imc.geysermodelengine.managers.model.modelhandler;
import kr.toxicity.model.api.entity.BaseEntity;
import kr.toxicity.model.api.tracker.EntityTracker;
import kr.toxicity.model.api.tracker.Tracker;
import org.bukkit.Bukkit;
@@ -26,11 +27,11 @@ public class BetterModelHandler implements ModelHandler {
//TODO fix dupe issue - dupe happens when server restart
@Override
public void createModel(Object... objects) {
Entity entitySource = (Entity) objects[0];
BaseEntity entitySource = (BaseEntity) objects[0];
Tracker tracker = (Tracker) objects[1];
EntityTracker entityTracker = (EntityTracker) objects[2];
int entityID = entitySource.getEntityId();
int entityID = entitySource.id();
PropertyHandler propertyHandler = plugin.getEntityTaskManager().getPropertyHandler();
EntityData entityData = new BetterModelEntityData(plugin, entitySource, tracker, entityTracker);

View File

@@ -2,6 +2,7 @@ package re.imc.geysermodelengine.managers.model.taskshandler;
import com.google.common.cache.Cache;
import com.google.common.cache.CacheBuilder;
import kr.toxicity.model.api.entity.BaseEntity;
import kr.toxicity.model.api.tracker.Tracker;
import me.zimzaza4.geyserutils.spigot.api.EntityUtils;
import org.bukkit.entity.Entity;
@@ -53,17 +54,17 @@ public class BetterModelTaskHandler implements TaskHandler {
if (entity.isDead()) return;
Set<Player> viewers = entityData.getViewers();
Entity entitySource = entityData.getEntitySource();
BaseEntity entitySource = entityData.getEntitySource();
Tracker tracker = entityData.getTracker();
entityData.teleportToModel();
if (entitySource.isDead() || tracker.forRemoval()) {
if (entitySource.dead() || tracker.forRemoval()) {
removed = true;
entity.remove();
plugin.getModelManager().getEntitiesCache().remove(entitySource.getEntityId());
plugin.getModelManager().getModelEntitiesCache().remove(entitySource.getEntityId());
plugin.getModelManager().getEntitiesCache().remove(entitySource.id());
plugin.getModelManager().getModelEntitiesCache().remove(entitySource.id());
cancel();
return;