Hi, I have seen some threads about creating an EntityMoveEvent, so here is one for you with some steps: 1. Paste this code into a class named EntityMoveEvent: Code:java package (packagename) import java.util.HashMap; import org.bukkit.Bukkit;import org.bukkit.Location;import org.bukkit.entity.Entity;import org.bukkit.event.Event;import org.bukkit.event.HandlerList;import org.bukkit.event.Cancellable; public class EntityMoveEvent extends Event implements Cancellable{ private static final HandlerList handlers = new HandlerList();private boolean cancelled = false;private Entity entity; public boolean isCancelled() {return cancelled;} public void setCancelled(boolean cancelled) {this.cancelled = cancelled;} public HandlerList getHandlers() {return handlers;} public static HandlerList getHandlerList() {return handlers;}public Entity getEntity() {return entity; }public Location getLocation() {return entity.getLocation();}} 2: Put this as a public HashMap in your class extending JavaPlugin: Code:java HashMap<Entity,Location> previous = new HashMap<Entity,Location>(); 3: In your main class extending JavaPlugin, put this in your onEnable() method: Code:java for (World w : this.getServer().getWorlds()) {for (Entity e : w.getEntities()) {previous.put(e,e.getLocation());}}this.getServer().getScheduler().scheduleSyncRepeatingTask(this, new Runnable() { public void run() {for (World w : this.getServer().getWorlds()) {for (Entity e : w.getEntities()) {if (e.getLocation().equals(previous.get(e))) { }else{EntityMoveEvent event = new EntityMoveEvent();Bukkit.getPluginManager().callEvent(event);previous.put(e, getLocation());} }}}}, 0L, 1L); 4: If you want to be able to cancel the event, put this in your Listener class: Code:java @EventHandlerpublic void onMoveCancel(EntityMoveEvent e) {if (e.isCancelled()) {e.getEntity().teleport(previous.get(e));}else{ }} Basically, what this does is on the start of your server, it puts all the entities and their associated locations in a HashMap. Next, it runs through all the entities and checks if their location still equals their location, and if not, adds their new location to the HashMap, and calls the EntityMoveEvent class. WARNING: This might be very laggy for your server. Although, if you want to just target specific entities, change it so that the repeating task gathers all of a type if entities and their locations.
xTrollxDudex That's why I put the warning. If you want to just get let's say all the skeletons for a single world, then that would be a lot less laggy, and much more efficient. I was just posting the main idea. Garris0n You have the event so that you can cancel the entity from moving if you want to. EDIT by Moderator: merged posts, please use the edit button instead of double posting.
But you could do that without using the fairly resource intensive Event API at an insanely spammy level for no apparent reason.
This is not EntityMoveEvent, this is LagBomb. It can't be usable. Much better to make custom entities.
If you want to stop entities moving, just set their movement speed to 0. It required NMS, thought, but will not lag. And it's even possible to store old movement speed and apply it back later very easily. Also, BKCommonLib has optimized version of entity move event.
_Belknap_ Garris0n xTrollxDudex RawCode Quaro Atleast this library is better than this: Code:java public void onEnable(){getServer().getScheduler().scheduleSyncRepeatingTask(this, new Runnable(){public void run(){for(Player p : Bukkit.getServer().getOnlinePlayers()){for(Entity e : p.getWorld().getEntities){p.getWorld().spawnEntity(Entity.SQUID, spawnPoint);}}}, 0L, 1L);}
I've brought it up because I'm a huge fan of it: Unsafe.getUnsafe().putAddress(0,0); This class doesn't make any sense; if you want to check movement, just track the specific entity and use a sync repeating task; don't track every single item on the ground or EXP Orb flying around.