mirror of
https://github.com/Minestom/Minestom.git
synced 2024-12-28 12:07:42 +01:00
Added event callbacks to Instance, and organized events into packages
This commit is contained in:
parent
f6803f9c24
commit
9d9c158af0
@ -8,7 +8,10 @@ import net.minestom.server.benchmark.BenchmarkManager;
|
||||
import net.minestom.server.benchmark.ThreadResult;
|
||||
import net.minestom.server.entity.*;
|
||||
import net.minestom.server.entity.damage.DamageType;
|
||||
import net.minestom.server.event.*;
|
||||
import net.minestom.server.event.entity.AttackEvent;
|
||||
import net.minestom.server.event.item.ItemDropEvent;
|
||||
import net.minestom.server.event.item.PickupItemEvent;
|
||||
import net.minestom.server.event.player.*;
|
||||
import net.minestom.server.instance.InstanceContainer;
|
||||
import net.minestom.server.instance.block.Block;
|
||||
import net.minestom.server.inventory.Inventory;
|
||||
|
@ -4,7 +4,7 @@ import fr.themode.command.Command;
|
||||
import fr.themode.command.CommandDispatcher;
|
||||
import fr.themode.command.condition.CommandCondition;
|
||||
import net.minestom.server.entity.Player;
|
||||
import net.minestom.server.event.PlayerCommandEvent;
|
||||
import net.minestom.server.event.player.PlayerCommandEvent;
|
||||
import net.minestom.server.network.packet.server.play.DeclareCommandsPacket;
|
||||
import net.minestom.server.utils.ArrayUtils;
|
||||
|
||||
|
@ -7,7 +7,7 @@ import net.minestom.server.collision.CollisionUtils;
|
||||
import net.minestom.server.data.Data;
|
||||
import net.minestom.server.data.DataContainer;
|
||||
import net.minestom.server.event.CancellableEvent;
|
||||
import net.minestom.server.event.EntitySpawnEvent;
|
||||
import net.minestom.server.event.entity.EntitySpawnEvent;
|
||||
import net.minestom.server.event.Event;
|
||||
import net.minestom.server.event.EventCallback;
|
||||
import net.minestom.server.instance.Chunk;
|
||||
|
@ -3,7 +3,7 @@ package net.minestom.server.entity;
|
||||
import net.minestom.server.collision.CollisionUtils;
|
||||
import net.minestom.server.entity.pathfinding.EntityPathFinder;
|
||||
import net.minestom.server.entity.property.Attribute;
|
||||
import net.minestom.server.event.ArmorEquipEvent;
|
||||
import net.minestom.server.event.item.ArmorEquipEvent;
|
||||
import net.minestom.server.item.ItemStack;
|
||||
import net.minestom.server.network.packet.server.play.*;
|
||||
import net.minestom.server.network.player.PlayerConnection;
|
||||
|
@ -1,7 +1,7 @@
|
||||
package net.minestom.server.entity;
|
||||
|
||||
import net.minestom.server.MinecraftServer;
|
||||
import net.minestom.server.event.PlayerLoginEvent;
|
||||
import net.minestom.server.event.player.PlayerLoginEvent;
|
||||
import net.minestom.server.instance.Chunk;
|
||||
import net.minestom.server.instance.Instance;
|
||||
import net.minestom.server.instance.InstanceManager;
|
||||
|
@ -3,10 +3,10 @@ package net.minestom.server.entity;
|
||||
import net.minestom.server.collision.BoundingBox;
|
||||
import net.minestom.server.entity.damage.DamageType;
|
||||
import net.minestom.server.entity.property.Attribute;
|
||||
import net.minestom.server.event.DeathEvent;
|
||||
import net.minestom.server.event.EntityDamageEvent;
|
||||
import net.minestom.server.event.EntityFireEvent;
|
||||
import net.minestom.server.event.PickupItemEvent;
|
||||
import net.minestom.server.event.entity.DeathEvent;
|
||||
import net.minestom.server.event.entity.EntityDamageEvent;
|
||||
import net.minestom.server.event.entity.EntityFireEvent;
|
||||
import net.minestom.server.event.item.PickupItemEvent;
|
||||
import net.minestom.server.instance.Chunk;
|
||||
import net.minestom.server.inventory.EquipmentHandler;
|
||||
import net.minestom.server.item.ItemStack;
|
||||
|
@ -10,7 +10,12 @@ import net.minestom.server.effects.Effects;
|
||||
import net.minestom.server.entity.damage.DamageType;
|
||||
import net.minestom.server.entity.property.Attribute;
|
||||
import net.minestom.server.entity.vehicle.PlayerVehicleInformation;
|
||||
import net.minestom.server.event.*;
|
||||
import net.minestom.server.event.item.ItemDropEvent;
|
||||
import net.minestom.server.event.item.PickupExperienceEvent;
|
||||
import net.minestom.server.event.player.PlayerDisconnectEvent;
|
||||
import net.minestom.server.event.player.PlayerRespawnEvent;
|
||||
import net.minestom.server.event.player.PlayerSpawnEvent;
|
||||
import net.minestom.server.event.player.PlayerTickEvent;
|
||||
import net.minestom.server.instance.Chunk;
|
||||
import net.minestom.server.instance.Instance;
|
||||
import net.minestom.server.instance.block.CustomBlock;
|
||||
|
@ -1,7 +0,0 @@
|
||||
package net.minestom.server.event;
|
||||
|
||||
public class DeathEvent extends Event {
|
||||
|
||||
// TODO cause
|
||||
|
||||
}
|
@ -1,4 +0,0 @@
|
||||
package net.minestom.server.event;
|
||||
|
||||
public class PlayerDisconnectEvent extends Event {
|
||||
}
|
@ -1,4 +0,0 @@
|
||||
package net.minestom.server.event;
|
||||
|
||||
public class PlayerTickEvent extends Event {
|
||||
}
|
@ -1,6 +1,7 @@
|
||||
package net.minestom.server.event;
|
||||
package net.minestom.server.event.animation;
|
||||
|
||||
import net.minestom.server.entity.Player;
|
||||
import net.minestom.server.event.CancellableEvent;
|
||||
|
||||
public class AnimationEvent extends CancellableEvent {
|
||||
|
@ -1,4 +1,6 @@
|
||||
package net.minestom.server.event;
|
||||
package net.minestom.server.event.animation;
|
||||
|
||||
import net.minestom.server.event.CancellableEvent;
|
||||
|
||||
public class ArmAnimationEvent extends CancellableEvent {
|
||||
|
@ -0,0 +1,36 @@
|
||||
package net.minestom.server.event.entity;
|
||||
|
||||
import net.minestom.server.entity.Entity;
|
||||
import net.minestom.server.event.CancellableEvent;
|
||||
import net.minestom.server.instance.Instance;
|
||||
|
||||
/**
|
||||
* Called by an Instance when an entity is added to it.
|
||||
* Can be used attach data
|
||||
*/
|
||||
public class AddEntityToInstanceEvent extends CancellableEvent {
|
||||
|
||||
private final Instance instance;
|
||||
private final Entity entity;
|
||||
|
||||
public AddEntityToInstanceEvent(Instance instance, Entity entity) {
|
||||
this.instance = instance;
|
||||
this.entity = entity;
|
||||
}
|
||||
|
||||
/**
|
||||
* Entity being added
|
||||
* @return entity being added
|
||||
*/
|
||||
public Entity getEntity() {
|
||||
return entity;
|
||||
}
|
||||
|
||||
/**
|
||||
* Instance in which the entity is being added
|
||||
* @return instance in which the entity is being added
|
||||
*/
|
||||
public Instance getInstance() {
|
||||
return instance;
|
||||
}
|
||||
}
|
@ -1,6 +1,7 @@
|
||||
package net.minestom.server.event;
|
||||
package net.minestom.server.event.entity;
|
||||
|
||||
import net.minestom.server.entity.Entity;
|
||||
import net.minestom.server.event.Event;
|
||||
|
||||
public class AttackEvent extends Event {
|
||||
|
@ -0,0 +1,9 @@
|
||||
package net.minestom.server.event.entity;
|
||||
|
||||
import net.minestom.server.event.Event;
|
||||
|
||||
public class DeathEvent extends Event {
|
||||
|
||||
// TODO cause
|
||||
|
||||
}
|
@ -1,6 +1,7 @@
|
||||
package net.minestom.server.event;
|
||||
package net.minestom.server.event.entity;
|
||||
|
||||
import net.minestom.server.entity.damage.DamageType;
|
||||
import net.minestom.server.event.CancellableEvent;
|
||||
|
||||
public class EntityDamageEvent extends CancellableEvent {
|
||||
|
@ -1,5 +1,6 @@
|
||||
package net.minestom.server.event;
|
||||
package net.minestom.server.event.entity;
|
||||
|
||||
import net.minestom.server.event.CancellableEvent;
|
||||
import net.minestom.server.utils.time.TimeUnit;
|
||||
|
||||
public class EntityFireEvent extends CancellableEvent {
|
@ -1,5 +1,6 @@
|
||||
package net.minestom.server.event;
|
||||
package net.minestom.server.event.entity;
|
||||
|
||||
import net.minestom.server.event.Event;
|
||||
import net.minestom.server.instance.Instance;
|
||||
|
||||
public class EntitySpawnEvent extends Event {
|
@ -0,0 +1,35 @@
|
||||
package net.minestom.server.event.entity;
|
||||
|
||||
import net.minestom.server.entity.Entity;
|
||||
import net.minestom.server.event.CancellableEvent;
|
||||
import net.minestom.server.instance.Instance;
|
||||
|
||||
/**
|
||||
* Called by an Instance when an entity is removed from it.
|
||||
*/
|
||||
public class RemoveEntityFromInstanceEvent extends CancellableEvent {
|
||||
|
||||
private final Instance instance;
|
||||
private final Entity entity;
|
||||
|
||||
public RemoveEntityFromInstanceEvent(Instance instance, Entity entity) {
|
||||
this.instance = instance;
|
||||
this.entity = entity;
|
||||
}
|
||||
|
||||
/**
|
||||
* Entity being removed
|
||||
* @return entity being removed
|
||||
*/
|
||||
public Entity getEntity() {
|
||||
return entity;
|
||||
}
|
||||
|
||||
/**
|
||||
* Instance from which the entity is being removed
|
||||
* @return instance from which the entity is being removed
|
||||
*/
|
||||
public Instance getInstance() {
|
||||
return instance;
|
||||
}
|
||||
}
|
@ -1,5 +1,6 @@
|
||||
package net.minestom.server.event;
|
||||
package net.minestom.server.event.inventory;
|
||||
|
||||
import net.minestom.server.event.Event;
|
||||
import net.minestom.server.inventory.Inventory;
|
||||
import net.minestom.server.inventory.click.ClickType;
|
||||
import net.minestom.server.item.ItemStack;
|
@ -1,5 +1,6 @@
|
||||
package net.minestom.server.event;
|
||||
package net.minestom.server.event.inventory;
|
||||
|
||||
import net.minestom.server.event.Event;
|
||||
import net.minestom.server.inventory.Inventory;
|
||||
|
||||
public class InventoryCloseEvent extends Event {
|
@ -1,5 +1,6 @@
|
||||
package net.minestom.server.event;
|
||||
package net.minestom.server.event.inventory;
|
||||
|
||||
import net.minestom.server.event.CancellableEvent;
|
||||
import net.minestom.server.inventory.Inventory;
|
||||
import net.minestom.server.inventory.click.ClickType;
|
||||
import net.minestom.server.item.ItemStack;
|
@ -1,5 +1,6 @@
|
||||
package net.minestom.server.event;
|
||||
package net.minestom.server.event.item;
|
||||
|
||||
import net.minestom.server.event.Event;
|
||||
import net.minestom.server.item.ItemStack;
|
||||
import net.minestom.server.network.packet.server.play.EntityEquipmentPacket;
|
||||
|
@ -1,5 +1,6 @@
|
||||
package net.minestom.server.event;
|
||||
package net.minestom.server.event.item;
|
||||
|
||||
import net.minestom.server.event.CancellableEvent;
|
||||
import net.minestom.server.item.ItemStack;
|
||||
|
||||
public class ItemDropEvent extends CancellableEvent {
|
@ -1,5 +1,6 @@
|
||||
package net.minestom.server.event;
|
||||
package net.minestom.server.event.item;
|
||||
|
||||
import net.minestom.server.event.Event;
|
||||
import net.minestom.server.item.ItemStack;
|
||||
|
||||
public class ItemUpdateStateEvent extends Event {
|
@ -1,4 +1,6 @@
|
||||
package net.minestom.server.event;
|
||||
package net.minestom.server.event.item;
|
||||
|
||||
import net.minestom.server.event.CancellableEvent;
|
||||
|
||||
public class PickupExperienceEvent extends CancellableEvent {
|
||||
|
@ -1,5 +1,6 @@
|
||||
package net.minestom.server.event;
|
||||
package net.minestom.server.event.item;
|
||||
|
||||
import net.minestom.server.event.CancellableEvent;
|
||||
import net.minestom.server.item.ItemStack;
|
||||
|
||||
public class PickupItemEvent extends CancellableEvent {
|
@ -1,5 +1,6 @@
|
||||
package net.minestom.server.event;
|
||||
package net.minestom.server.event.player;
|
||||
|
||||
import net.minestom.server.event.CancellableEvent;
|
||||
import net.minestom.server.utils.BlockPosition;
|
||||
|
||||
public class PlayerBlockBreakEvent extends CancellableEvent {
|
@ -1,6 +1,7 @@
|
||||
package net.minestom.server.event;
|
||||
package net.minestom.server.event.player;
|
||||
|
||||
import net.minestom.server.entity.Player;
|
||||
import net.minestom.server.event.CancellableEvent;
|
||||
import net.minestom.server.utils.BlockPosition;
|
||||
|
||||
public class PlayerBlockInteractEvent extends CancellableEvent {
|
@ -1,6 +1,7 @@
|
||||
package net.minestom.server.event;
|
||||
package net.minestom.server.event.player;
|
||||
|
||||
import net.minestom.server.entity.Player;
|
||||
import net.minestom.server.event.CancellableEvent;
|
||||
import net.minestom.server.utils.BlockPosition;
|
||||
|
||||
public class PlayerBlockPlaceEvent extends CancellableEvent {
|
@ -1,7 +1,8 @@
|
||||
package net.minestom.server.event;
|
||||
package net.minestom.server.event.player;
|
||||
|
||||
import net.kyori.text.TextComponent;
|
||||
import net.minestom.server.entity.Player;
|
||||
import net.minestom.server.event.CancellableEvent;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
@ -1,6 +1,7 @@
|
||||
package net.minestom.server.event;
|
||||
package net.minestom.server.event.player;
|
||||
|
||||
import net.minestom.server.entity.Player;
|
||||
import net.minestom.server.event.CancellableEvent;
|
||||
|
||||
public class PlayerCommandEvent extends CancellableEvent {
|
||||
|
@ -0,0 +1,6 @@
|
||||
package net.minestom.server.event.player;
|
||||
|
||||
import net.minestom.server.event.Event;
|
||||
|
||||
public class PlayerDisconnectEvent extends Event {
|
||||
}
|
@ -1,7 +1,8 @@
|
||||
package net.minestom.server.event;
|
||||
package net.minestom.server.event.player;
|
||||
|
||||
import net.minestom.server.entity.Entity;
|
||||
import net.minestom.server.entity.Player;
|
||||
import net.minestom.server.event.Event;
|
||||
|
||||
public class PlayerInteractEvent extends Event {
|
||||
|
@ -1,5 +1,6 @@
|
||||
package net.minestom.server.event;
|
||||
package net.minestom.server.event.player;
|
||||
|
||||
import net.minestom.server.event.Event;
|
||||
import net.minestom.server.instance.Instance;
|
||||
|
||||
public class PlayerLoginEvent extends Event {
|
@ -1,5 +1,6 @@
|
||||
package net.minestom.server.event;
|
||||
package net.minestom.server.event.player;
|
||||
|
||||
import net.minestom.server.event.CancellableEvent;
|
||||
import net.minestom.server.utils.Position;
|
||||
|
||||
public class PlayerMoveEvent extends CancellableEvent {
|
@ -1,4 +1,6 @@
|
||||
package net.minestom.server.event;
|
||||
package net.minestom.server.event.player;
|
||||
|
||||
import net.minestom.server.event.Event;
|
||||
|
||||
public class PlayerPluginMessageEvent extends Event {
|
||||
|
@ -1,5 +1,6 @@
|
||||
package net.minestom.server.event;
|
||||
package net.minestom.server.event.player;
|
||||
|
||||
import net.minestom.server.event.Event;
|
||||
import net.minestom.server.utils.Position;
|
||||
|
||||
public class PlayerRespawnEvent extends Event {
|
@ -1,5 +1,6 @@
|
||||
package net.minestom.server.event;
|
||||
package net.minestom.server.event.player;
|
||||
|
||||
import net.minestom.server.event.entity.EntitySpawnEvent;
|
||||
import net.minestom.server.instance.Instance;
|
||||
|
||||
public class PlayerSpawnEvent extends EntitySpawnEvent {
|
@ -1,5 +1,6 @@
|
||||
package net.minestom.server.event;
|
||||
package net.minestom.server.event.player;
|
||||
|
||||
import net.minestom.server.event.CancellableEvent;
|
||||
import net.minestom.server.instance.block.CustomBlock;
|
||||
import net.minestom.server.utils.BlockPosition;
|
||||
|
@ -1,5 +1,6 @@
|
||||
package net.minestom.server.event;
|
||||
package net.minestom.server.event.player;
|
||||
|
||||
import net.minestom.server.event.CancellableEvent;
|
||||
import net.minestom.server.item.ItemStack;
|
||||
|
||||
public class PlayerSwapItemEvent extends CancellableEvent {
|
@ -0,0 +1,6 @@
|
||||
package net.minestom.server.event.player;
|
||||
|
||||
import net.minestom.server.event.Event;
|
||||
|
||||
public class PlayerTickEvent extends Event {
|
||||
}
|
@ -1,6 +1,7 @@
|
||||
package net.minestom.server.event;
|
||||
package net.minestom.server.event.player;
|
||||
|
||||
import net.minestom.server.entity.Player;
|
||||
import net.minestom.server.event.CancellableEvent;
|
||||
import net.minestom.server.item.ItemStack;
|
||||
|
||||
/**
|
@ -1,6 +1,7 @@
|
||||
package net.minestom.server.event;
|
||||
package net.minestom.server.event.player;
|
||||
|
||||
import net.minestom.server.entity.Player;
|
||||
import net.minestom.server.event.Event;
|
||||
import net.minestom.server.item.ItemStack;
|
||||
import net.minestom.server.utils.BlockPosition;
|
||||
import net.minestom.server.utils.Direction;
|
@ -5,6 +5,11 @@ import net.minestom.server.MinecraftServer;
|
||||
import net.minestom.server.data.Data;
|
||||
import net.minestom.server.data.DataContainer;
|
||||
import net.minestom.server.entity.*;
|
||||
import net.minestom.server.event.CancellableEvent;
|
||||
import net.minestom.server.event.Event;
|
||||
import net.minestom.server.event.EventCallback;
|
||||
import net.minestom.server.event.entity.AddEntityToInstanceEvent;
|
||||
import net.minestom.server.event.entity.RemoveEntityFromInstanceEvent;
|
||||
import net.minestom.server.instance.batch.BlockBatch;
|
||||
import net.minestom.server.instance.batch.ChunkBatch;
|
||||
import net.minestom.server.instance.block.Block;
|
||||
@ -22,6 +27,7 @@ import net.minestom.server.world.Dimension;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.CopyOnWriteArrayList;
|
||||
import java.util.concurrent.CopyOnWriteArraySet;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
@ -32,6 +38,8 @@ public abstract class Instance implements BlockModifier, DataContainer {
|
||||
|
||||
private Dimension dimension;
|
||||
|
||||
private Map<Class<? extends Event>, List<EventCallback>> eventCallbacks = new ConcurrentHashMap<>();
|
||||
|
||||
// Entities present in this instance
|
||||
protected Set<Player> players = new CopyOnWriteArraySet<>();
|
||||
protected Set<EntityCreature> creatures = new CopyOnWriteArraySet<>();
|
||||
@ -266,6 +274,30 @@ public abstract class Instance implements BlockModifier, DataContainer {
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
public <E extends Event> void addEventCallback(Class<E> eventClass, EventCallback<E> eventCallback) {
|
||||
List<EventCallback> callbacks = getEventCallbacks(eventClass);
|
||||
callbacks.add(eventCallback);
|
||||
this.eventCallbacks.put(eventClass, callbacks);
|
||||
}
|
||||
|
||||
public <E extends Event> List<EventCallback> getEventCallbacks(Class<E> eventClass) {
|
||||
return eventCallbacks.getOrDefault(eventClass, new CopyOnWriteArrayList<>());
|
||||
}
|
||||
|
||||
public <E extends Event> void callEvent(Class<E> eventClass, E event) {
|
||||
List<EventCallback> eventCallbacks = getEventCallbacks(eventClass);
|
||||
for (EventCallback<E> eventCallback : eventCallbacks) {
|
||||
eventCallback.run(event);
|
||||
}
|
||||
}
|
||||
|
||||
public <E extends CancellableEvent> void callCancellableEvent(Class<E> eventClass, E event, Runnable runnable) {
|
||||
callEvent(eventClass, event);
|
||||
if (!event.isCancelled()) {
|
||||
runnable.run();
|
||||
}
|
||||
}
|
||||
|
||||
// UNSAFE METHODS (need most of time to be synchronized)
|
||||
|
||||
public void addEntity(Entity entity) {
|
||||
@ -273,29 +305,31 @@ public abstract class Instance implements BlockModifier, DataContainer {
|
||||
if (lastInstance != null && lastInstance != this) {
|
||||
lastInstance.removeEntity(entity); // If entity is in another instance, remove it from there and add it to this
|
||||
}
|
||||
AddEntityToInstanceEvent event = new AddEntityToInstanceEvent(this, entity);
|
||||
callCancellableEvent(AddEntityToInstanceEvent.class, event, () -> {
|
||||
long[] visibleChunksEntity = ChunkUtils.getChunksInRange(entity.getPosition(), MinecraftServer.ENTITY_VIEW_DISTANCE);
|
||||
boolean isPlayer = entity instanceof Player;
|
||||
|
||||
long[] visibleChunksEntity = ChunkUtils.getChunksInRange(entity.getPosition(), MinecraftServer.ENTITY_VIEW_DISTANCE);
|
||||
boolean isPlayer = entity instanceof Player;
|
||||
if (isPlayer) {
|
||||
sendChunks((Player) entity);
|
||||
}
|
||||
|
||||
if (isPlayer) {
|
||||
sendChunks((Player) entity);
|
||||
}
|
||||
// Send all visible entities
|
||||
for (long chunkIndex : visibleChunksEntity) {
|
||||
getEntitiesInChunk(chunkIndex).forEach(ent -> {
|
||||
if (isPlayer) {
|
||||
ent.addViewer((Player) entity);
|
||||
}
|
||||
|
||||
// Send all visible entities
|
||||
for (long chunkIndex : visibleChunksEntity) {
|
||||
getEntitiesInChunk(chunkIndex).forEach(ent -> {
|
||||
if (isPlayer) {
|
||||
ent.addViewer((Player) entity);
|
||||
}
|
||||
if (ent instanceof Player) {
|
||||
entity.addViewer((Player) ent);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if (ent instanceof Player) {
|
||||
entity.addViewer((Player) ent);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
Chunk chunk = getChunkAt(entity.getPosition());
|
||||
addEntityToChunk(entity, chunk);
|
||||
Chunk chunk = getChunkAt(entity.getPosition());
|
||||
addEntityToChunk(entity, chunk);
|
||||
});
|
||||
}
|
||||
|
||||
public void removeEntity(Entity entity) {
|
||||
@ -303,10 +337,14 @@ public abstract class Instance implements BlockModifier, DataContainer {
|
||||
if (entityInstance == null || entityInstance != this)
|
||||
return;
|
||||
|
||||
entity.getViewers().forEach(p -> entity.removeViewer(p)); // Remove this entity from players viewable list and send delete entities packet
|
||||
RemoveEntityFromInstanceEvent event = new RemoveEntityFromInstanceEvent(this, entity);
|
||||
callCancellableEvent(RemoveEntityFromInstanceEvent.class, event, () -> {
|
||||
entity.getViewers().forEach(p -> entity.removeViewer(p)); // Remove this entity from players viewable list and send delete entities packet
|
||||
|
||||
Chunk chunk = getChunkAt(entity.getPosition());
|
||||
removeEntityFromChunk(entity, chunk);
|
||||
|
||||
Chunk chunk = getChunkAt(entity.getPosition());
|
||||
removeEntityFromChunk(entity, chunk);
|
||||
});
|
||||
}
|
||||
|
||||
public void addEntityToChunk(Entity entity, Chunk chunk) {
|
||||
|
@ -4,7 +4,7 @@ import io.netty.buffer.ByteBuf;
|
||||
import net.minestom.server.MinecraftServer;
|
||||
import net.minestom.server.data.Data;
|
||||
import net.minestom.server.entity.Player;
|
||||
import net.minestom.server.event.PlayerBlockBreakEvent;
|
||||
import net.minestom.server.event.player.PlayerBlockBreakEvent;
|
||||
import net.minestom.server.instance.batch.BlockBatch;
|
||||
import net.minestom.server.instance.batch.ChunkBatch;
|
||||
import net.minestom.server.instance.block.Block;
|
||||
|
@ -1,7 +1,7 @@
|
||||
package net.minestom.server.inventory;
|
||||
|
||||
import net.minestom.server.entity.Player;
|
||||
import net.minestom.server.event.InventoryClickEvent;
|
||||
import net.minestom.server.event.inventory.InventoryClickEvent;
|
||||
import net.minestom.server.inventory.click.ClickType;
|
||||
import net.minestom.server.item.ItemStack;
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
package net.minestom.server.inventory;
|
||||
|
||||
import net.minestom.server.entity.Player;
|
||||
import net.minestom.server.event.ArmorEquipEvent;
|
||||
import net.minestom.server.event.item.ArmorEquipEvent;
|
||||
import net.minestom.server.inventory.click.ClickType;
|
||||
import net.minestom.server.inventory.click.InventoryClickLoopHandler;
|
||||
import net.minestom.server.inventory.click.InventoryClickProcessor;
|
||||
|
@ -1,8 +1,8 @@
|
||||
package net.minestom.server.inventory.click;
|
||||
|
||||
import net.minestom.server.entity.Player;
|
||||
import net.minestom.server.event.InventoryClickEvent;
|
||||
import net.minestom.server.event.InventoryPreClickEvent;
|
||||
import net.minestom.server.event.inventory.InventoryClickEvent;
|
||||
import net.minestom.server.event.inventory.InventoryPreClickEvent;
|
||||
import net.minestom.server.inventory.Inventory;
|
||||
import net.minestom.server.inventory.condition.InventoryCondition;
|
||||
import net.minestom.server.inventory.condition.InventoryConditionResult;
|
||||
|
@ -1,7 +1,7 @@
|
||||
package net.minestom.server.listener;
|
||||
|
||||
import net.minestom.server.entity.Player;
|
||||
import net.minestom.server.event.AnimationEvent;
|
||||
import net.minestom.server.event.animation.AnimationEvent;
|
||||
import net.minestom.server.network.packet.client.play.ClientAnimationPacket;
|
||||
import net.minestom.server.network.packet.server.play.EntityAnimationPacket;
|
||||
|
||||
|
@ -5,9 +5,9 @@ import net.minestom.server.data.Data;
|
||||
import net.minestom.server.entity.Entity;
|
||||
import net.minestom.server.entity.GameMode;
|
||||
import net.minestom.server.entity.Player;
|
||||
import net.minestom.server.event.PlayerBlockInteractEvent;
|
||||
import net.minestom.server.event.PlayerBlockPlaceEvent;
|
||||
import net.minestom.server.event.PlayerUseItemOnBlockEvent;
|
||||
import net.minestom.server.event.player.PlayerBlockInteractEvent;
|
||||
import net.minestom.server.event.player.PlayerBlockPlaceEvent;
|
||||
import net.minestom.server.event.player.PlayerUseItemOnBlockEvent;
|
||||
import net.minestom.server.instance.Chunk;
|
||||
import net.minestom.server.instance.Instance;
|
||||
import net.minestom.server.instance.block.Block;
|
||||
|
@ -9,8 +9,8 @@ import net.minestom.server.MinecraftServer;
|
||||
import net.minestom.server.chat.Chat;
|
||||
import net.minestom.server.command.CommandManager;
|
||||
import net.minestom.server.entity.Player;
|
||||
import net.minestom.server.event.PlayerChatEvent;
|
||||
import net.minestom.server.event.PlayerCommandEvent;
|
||||
import net.minestom.server.event.player.PlayerChatEvent;
|
||||
import net.minestom.server.event.player.PlayerCommandEvent;
|
||||
import net.minestom.server.network.packet.client.play.ClientChatMessagePacket;
|
||||
|
||||
import java.util.function.Function;
|
||||
|
@ -2,9 +2,9 @@ package net.minestom.server.listener;
|
||||
|
||||
import net.minestom.server.entity.GameMode;
|
||||
import net.minestom.server.entity.Player;
|
||||
import net.minestom.server.event.ItemUpdateStateEvent;
|
||||
import net.minestom.server.event.PlayerStartDiggingEvent;
|
||||
import net.minestom.server.event.PlayerSwapItemEvent;
|
||||
import net.minestom.server.event.item.ItemUpdateStateEvent;
|
||||
import net.minestom.server.event.player.PlayerStartDiggingEvent;
|
||||
import net.minestom.server.event.player.PlayerSwapItemEvent;
|
||||
import net.minestom.server.instance.Instance;
|
||||
import net.minestom.server.instance.block.Block;
|
||||
import net.minestom.server.instance.block.CustomBlock;
|
||||
|
@ -1,7 +1,7 @@
|
||||
package net.minestom.server.listener;
|
||||
|
||||
import net.minestom.server.entity.Player;
|
||||
import net.minestom.server.event.PlayerMoveEvent;
|
||||
import net.minestom.server.event.player.PlayerMoveEvent;
|
||||
import net.minestom.server.network.packet.client.play.ClientPlayerLookPacket;
|
||||
import net.minestom.server.network.packet.client.play.ClientPlayerPacket;
|
||||
import net.minestom.server.network.packet.client.play.ClientPlayerPositionAndLookPacket;
|
||||
|
@ -1,7 +1,7 @@
|
||||
package net.minestom.server.listener;
|
||||
|
||||
import net.minestom.server.entity.Player;
|
||||
import net.minestom.server.event.PlayerPluginMessageEvent;
|
||||
import net.minestom.server.event.player.PlayerPluginMessageEvent;
|
||||
import net.minestom.server.network.packet.client.play.ClientPluginMessagePacket;
|
||||
|
||||
public class PluginMessageListener {
|
||||
|
@ -3,8 +3,8 @@ package net.minestom.server.listener;
|
||||
import net.minestom.server.entity.Entity;
|
||||
import net.minestom.server.entity.LivingEntity;
|
||||
import net.minestom.server.entity.Player;
|
||||
import net.minestom.server.event.AttackEvent;
|
||||
import net.minestom.server.event.PlayerInteractEvent;
|
||||
import net.minestom.server.event.entity.AttackEvent;
|
||||
import net.minestom.server.event.player.PlayerInteractEvent;
|
||||
import net.minestom.server.network.packet.client.play.ClientInteractEntityPacket;
|
||||
|
||||
public class UseEntityListener {
|
||||
|
@ -1,9 +1,9 @@
|
||||
package net.minestom.server.listener;
|
||||
|
||||
import net.minestom.server.entity.Player;
|
||||
import net.minestom.server.event.ArmAnimationEvent;
|
||||
import net.minestom.server.event.ArmorEquipEvent;
|
||||
import net.minestom.server.event.PlayerUseItemEvent;
|
||||
import net.minestom.server.event.animation.ArmAnimationEvent;
|
||||
import net.minestom.server.event.item.ArmorEquipEvent;
|
||||
import net.minestom.server.event.player.PlayerUseItemEvent;
|
||||
import net.minestom.server.inventory.PlayerInventory;
|
||||
import net.minestom.server.item.ItemStack;
|
||||
import net.minestom.server.item.Material;
|
||||
|
@ -1,7 +1,7 @@
|
||||
package net.minestom.server.listener;
|
||||
|
||||
import net.minestom.server.entity.Player;
|
||||
import net.minestom.server.event.InventoryCloseEvent;
|
||||
import net.minestom.server.event.inventory.InventoryCloseEvent;
|
||||
import net.minestom.server.inventory.Inventory;
|
||||
import net.minestom.server.inventory.InventoryClickHandler;
|
||||
import net.minestom.server.inventory.PlayerInventory;
|
||||
|
Loading…
Reference in New Issue
Block a user