EntityTransformEvent isn't in 1.12-

This commit is contained in:
Brianna 2020-09-09 09:12:32 -05:00
parent ea19394b9d
commit a62eda2666
3 changed files with 38 additions and 15 deletions

View File

@ -28,6 +28,8 @@ import com.songoda.ultimatestacker.database.migrations._3_BlockStacks;
import com.songoda.ultimatestacker.hook.StackerHook;
import com.songoda.ultimatestacker.hook.hooks.JobsHook;
import com.songoda.ultimatestacker.listeners.*;
import com.songoda.ultimatestacker.listeners.entity.EntityCurrentListener;
import com.songoda.ultimatestacker.listeners.entity.EntityListeners;
import com.songoda.ultimatestacker.listeners.item.ItemCurrentListener;
import com.songoda.ultimatestacker.listeners.item.ItemLegacyListener;
import com.songoda.ultimatestacker.listeners.item.ItemListeners;
@ -168,6 +170,9 @@ public class UltimateStacker extends SongodaPlugin {
pluginManager.registerEvents(new DeathListeners(this), this);
pluginManager.registerEvents(new ShearListeners(this), this);
pluginManager.registerEvents(new InteractListeners(this), this);
if (ServerVersion.isServerVersionAtLeast(ServerVersion.V1_13))
pluginManager.registerEvents(new EntityCurrentListener(this), this);
pluginManager.registerEvents(new EntityListeners(this), this);
pluginManager.registerEvents(new ItemListeners(this), this);

View File

@ -0,0 +1,32 @@
package com.songoda.ultimatestacker.listeners.entity;
import com.songoda.ultimatestacker.UltimateStacker;
import com.songoda.ultimatestacker.stackable.entity.EntityStack;
import com.songoda.ultimatestacker.stackable.entity.EntityStackManager;
import org.bukkit.entity.LivingEntity;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.entity.EntityTransformEvent;
public class EntityCurrentListener implements Listener {
private final UltimateStacker plugin;
public EntityCurrentListener(UltimateStacker plugin) {
this.plugin = plugin;
}
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
public void onSpawn(EntityTransformEvent event) {
EntityStackManager stackManager = plugin.getEntityStackManager();
if (stackManager.isStackedAndLoaded(event.getEntity().getUniqueId())
&& event.getEntity() instanceof LivingEntity
&& event.getTransformedEntity() instanceof LivingEntity) {
EntityStack stack = stackManager.updateStack((LivingEntity) event.getEntity(),
(LivingEntity) event.getTransformedEntity());
stack.releaseHost();
stack.updateStack();
}
}
}

View File

@ -1,4 +1,4 @@
package com.songoda.ultimatestacker.listeners;
package com.songoda.ultimatestacker.listeners.entity;
import com.songoda.core.compatibility.CompatibleMaterial;
import com.songoda.ultimatestacker.UltimateStacker;
@ -41,20 +41,6 @@ public class EntityListeners implements Listener {
this.plugin = plugin;
}
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
public void onSpawn(EntityTransformEvent event) {
EntityStackManager stackManager = plugin.getEntityStackManager();
if (stackManager.isStackedAndLoaded(event.getEntity().getUniqueId())
&& event.getEntity() instanceof LivingEntity
&& event.getTransformedEntity() instanceof LivingEntity) {
EntityStack stack = stackManager.updateStack((LivingEntity) event.getEntity(),
(LivingEntity) event.getTransformedEntity());
stack.releaseHost();
stack.updateStack();
}
}
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
public void onEgg(ItemSpawnEvent event) {
Material material = event.getEntity().getItemStack().getType();