mirror of
https://github.com/xSquishyLiam/mc-GeyserModelEngine-plugin.git
synced 2025-12-19 14:59:19 +00:00
updated BetterModel Support
This commit is contained in:
@@ -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")
|
||||
|
||||
@@ -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() {
|
||||
|
||||
@@ -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")));
|
||||
// });
|
||||
// }
|
||||
}
|
||||
@@ -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
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user