mirror of
https://github.com/songoda/UltimateStacker.git
synced 2025-01-15 20:11:21 +01:00
EntityTransformEvent isn't in 1.12-
This commit is contained in:
parent
ea19394b9d
commit
a62eda2666
@ -28,6 +28,8 @@ import com.songoda.ultimatestacker.database.migrations._3_BlockStacks;
|
|||||||
import com.songoda.ultimatestacker.hook.StackerHook;
|
import com.songoda.ultimatestacker.hook.StackerHook;
|
||||||
import com.songoda.ultimatestacker.hook.hooks.JobsHook;
|
import com.songoda.ultimatestacker.hook.hooks.JobsHook;
|
||||||
import com.songoda.ultimatestacker.listeners.*;
|
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.ItemCurrentListener;
|
||||||
import com.songoda.ultimatestacker.listeners.item.ItemLegacyListener;
|
import com.songoda.ultimatestacker.listeners.item.ItemLegacyListener;
|
||||||
import com.songoda.ultimatestacker.listeners.item.ItemListeners;
|
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 DeathListeners(this), this);
|
||||||
pluginManager.registerEvents(new ShearListeners(this), this);
|
pluginManager.registerEvents(new ShearListeners(this), this);
|
||||||
pluginManager.registerEvents(new InteractListeners(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 EntityListeners(this), this);
|
||||||
pluginManager.registerEvents(new ItemListeners(this), this);
|
pluginManager.registerEvents(new ItemListeners(this), this);
|
||||||
|
|
||||||
|
@ -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();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -1,4 +1,4 @@
|
|||||||
package com.songoda.ultimatestacker.listeners;
|
package com.songoda.ultimatestacker.listeners.entity;
|
||||||
|
|
||||||
import com.songoda.core.compatibility.CompatibleMaterial;
|
import com.songoda.core.compatibility.CompatibleMaterial;
|
||||||
import com.songoda.ultimatestacker.UltimateStacker;
|
import com.songoda.ultimatestacker.UltimateStacker;
|
||||||
@ -41,20 +41,6 @@ public class EntityListeners implements Listener {
|
|||||||
this.plugin = 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();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
|
||||||
public void onEgg(ItemSpawnEvent event) {
|
public void onEgg(ItemSpawnEvent event) {
|
||||||
Material material = event.getEntity().getItemStack().getType();
|
Material material = event.getEntity().getItemStack().getType();
|
Loading…
Reference in New Issue
Block a user