Added event callbacks to Instance, and organized events into packages

This commit is contained in:
jglrxavpok 2020-05-07 15:46:21 +02:00
parent f6803f9c24
commit 9d9c158af0
58 changed files with 253 additions and 98 deletions

View File

@ -8,7 +8,10 @@ import net.minestom.server.benchmark.BenchmarkManager;
import net.minestom.server.benchmark.ThreadResult; import net.minestom.server.benchmark.ThreadResult;
import net.minestom.server.entity.*; import net.minestom.server.entity.*;
import net.minestom.server.entity.damage.DamageType; 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.InstanceContainer;
import net.minestom.server.instance.block.Block; import net.minestom.server.instance.block.Block;
import net.minestom.server.inventory.Inventory; import net.minestom.server.inventory.Inventory;

View File

@ -4,7 +4,7 @@ import fr.themode.command.Command;
import fr.themode.command.CommandDispatcher; import fr.themode.command.CommandDispatcher;
import fr.themode.command.condition.CommandCondition; import fr.themode.command.condition.CommandCondition;
import net.minestom.server.entity.Player; 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.network.packet.server.play.DeclareCommandsPacket;
import net.minestom.server.utils.ArrayUtils; import net.minestom.server.utils.ArrayUtils;

View File

@ -7,7 +7,7 @@ import net.minestom.server.collision.CollisionUtils;
import net.minestom.server.data.Data; import net.minestom.server.data.Data;
import net.minestom.server.data.DataContainer; import net.minestom.server.data.DataContainer;
import net.minestom.server.event.CancellableEvent; 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.Event;
import net.minestom.server.event.EventCallback; import net.minestom.server.event.EventCallback;
import net.minestom.server.instance.Chunk; import net.minestom.server.instance.Chunk;

View File

@ -3,7 +3,7 @@ package net.minestom.server.entity;
import net.minestom.server.collision.CollisionUtils; import net.minestom.server.collision.CollisionUtils;
import net.minestom.server.entity.pathfinding.EntityPathFinder; import net.minestom.server.entity.pathfinding.EntityPathFinder;
import net.minestom.server.entity.property.Attribute; 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.item.ItemStack;
import net.minestom.server.network.packet.server.play.*; import net.minestom.server.network.packet.server.play.*;
import net.minestom.server.network.player.PlayerConnection; import net.minestom.server.network.player.PlayerConnection;

View File

@ -1,7 +1,7 @@
package net.minestom.server.entity; package net.minestom.server.entity;
import net.minestom.server.MinecraftServer; 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.Chunk;
import net.minestom.server.instance.Instance; import net.minestom.server.instance.Instance;
import net.minestom.server.instance.InstanceManager; import net.minestom.server.instance.InstanceManager;

View File

@ -3,10 +3,10 @@ package net.minestom.server.entity;
import net.minestom.server.collision.BoundingBox; import net.minestom.server.collision.BoundingBox;
import net.minestom.server.entity.damage.DamageType; import net.minestom.server.entity.damage.DamageType;
import net.minestom.server.entity.property.Attribute; import net.minestom.server.entity.property.Attribute;
import net.minestom.server.event.DeathEvent; import net.minestom.server.event.entity.DeathEvent;
import net.minestom.server.event.EntityDamageEvent; import net.minestom.server.event.entity.EntityDamageEvent;
import net.minestom.server.event.EntityFireEvent; import net.minestom.server.event.entity.EntityFireEvent;
import net.minestom.server.event.PickupItemEvent; import net.minestom.server.event.item.PickupItemEvent;
import net.minestom.server.instance.Chunk; import net.minestom.server.instance.Chunk;
import net.minestom.server.inventory.EquipmentHandler; import net.minestom.server.inventory.EquipmentHandler;
import net.minestom.server.item.ItemStack; import net.minestom.server.item.ItemStack;

View File

@ -10,7 +10,12 @@ import net.minestom.server.effects.Effects;
import net.minestom.server.entity.damage.DamageType; import net.minestom.server.entity.damage.DamageType;
import net.minestom.server.entity.property.Attribute; import net.minestom.server.entity.property.Attribute;
import net.minestom.server.entity.vehicle.PlayerVehicleInformation; 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.Chunk;
import net.minestom.server.instance.Instance; import net.minestom.server.instance.Instance;
import net.minestom.server.instance.block.CustomBlock; import net.minestom.server.instance.block.CustomBlock;

View File

@ -1,7 +0,0 @@
package net.minestom.server.event;
public class DeathEvent extends Event {
// TODO cause
}

View File

@ -1,4 +0,0 @@
package net.minestom.server.event;
public class PlayerDisconnectEvent extends Event {
}

View File

@ -1,4 +0,0 @@
package net.minestom.server.event;
public class PlayerTickEvent extends Event {
}

View File

@ -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.entity.Player;
import net.minestom.server.event.CancellableEvent;
public class AnimationEvent extends CancellableEvent { public class AnimationEvent extends CancellableEvent {

View File

@ -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 { public class ArmAnimationEvent extends CancellableEvent {

View File

@ -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;
}
}

View File

@ -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.entity.Entity;
import net.minestom.server.event.Event;
public class AttackEvent extends Event { public class AttackEvent extends Event {

View File

@ -0,0 +1,9 @@
package net.minestom.server.event.entity;
import net.minestom.server.event.Event;
public class DeathEvent extends Event {
// TODO cause
}

View File

@ -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.entity.damage.DamageType;
import net.minestom.server.event.CancellableEvent;
public class EntityDamageEvent extends CancellableEvent { public class EntityDamageEvent extends CancellableEvent {

View File

@ -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; import net.minestom.server.utils.time.TimeUnit;
public class EntityFireEvent extends CancellableEvent { public class EntityFireEvent extends CancellableEvent {

View File

@ -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; import net.minestom.server.instance.Instance;
public class EntitySpawnEvent extends Event { public class EntitySpawnEvent extends Event {

View File

@ -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;
}
}

View File

@ -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.Inventory;
import net.minestom.server.inventory.click.ClickType; import net.minestom.server.inventory.click.ClickType;
import net.minestom.server.item.ItemStack; import net.minestom.server.item.ItemStack;

View File

@ -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.Inventory;
public class InventoryCloseEvent extends Event { public class InventoryCloseEvent extends Event {

View File

@ -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.Inventory;
import net.minestom.server.inventory.click.ClickType; import net.minestom.server.inventory.click.ClickType;
import net.minestom.server.item.ItemStack; import net.minestom.server.item.ItemStack;

View File

@ -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.item.ItemStack;
import net.minestom.server.network.packet.server.play.EntityEquipmentPacket; import net.minestom.server.network.packet.server.play.EntityEquipmentPacket;

View File

@ -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; import net.minestom.server.item.ItemStack;
public class ItemDropEvent extends CancellableEvent { public class ItemDropEvent extends CancellableEvent {

View File

@ -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.item.ItemStack;
public class ItemUpdateStateEvent extends Event { public class ItemUpdateStateEvent extends Event {

View File

@ -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 { public class PickupExperienceEvent extends CancellableEvent {

View File

@ -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; import net.minestom.server.item.ItemStack;
public class PickupItemEvent extends CancellableEvent { public class PickupItemEvent extends CancellableEvent {

View File

@ -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; import net.minestom.server.utils.BlockPosition;
public class PlayerBlockBreakEvent extends CancellableEvent { public class PlayerBlockBreakEvent extends CancellableEvent {

View File

@ -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.entity.Player;
import net.minestom.server.event.CancellableEvent;
import net.minestom.server.utils.BlockPosition; import net.minestom.server.utils.BlockPosition;
public class PlayerBlockInteractEvent extends CancellableEvent { public class PlayerBlockInteractEvent extends CancellableEvent {

View File

@ -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.entity.Player;
import net.minestom.server.event.CancellableEvent;
import net.minestom.server.utils.BlockPosition; import net.minestom.server.utils.BlockPosition;
public class PlayerBlockPlaceEvent extends CancellableEvent { public class PlayerBlockPlaceEvent extends CancellableEvent {

View File

@ -1,7 +1,8 @@
package net.minestom.server.event; package net.minestom.server.event.player;
import net.kyori.text.TextComponent; import net.kyori.text.TextComponent;
import net.minestom.server.entity.Player; import net.minestom.server.entity.Player;
import net.minestom.server.event.CancellableEvent;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;

View File

@ -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.entity.Player;
import net.minestom.server.event.CancellableEvent;
public class PlayerCommandEvent extends CancellableEvent { public class PlayerCommandEvent extends CancellableEvent {

View File

@ -0,0 +1,6 @@
package net.minestom.server.event.player;
import net.minestom.server.event.Event;
public class PlayerDisconnectEvent extends Event {
}

View File

@ -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.Entity;
import net.minestom.server.entity.Player; import net.minestom.server.entity.Player;
import net.minestom.server.event.Event;
public class PlayerInteractEvent extends Event { public class PlayerInteractEvent extends Event {

View File

@ -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; import net.minestom.server.instance.Instance;
public class PlayerLoginEvent extends Event { public class PlayerLoginEvent extends Event {

View File

@ -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; import net.minestom.server.utils.Position;
public class PlayerMoveEvent extends CancellableEvent { public class PlayerMoveEvent extends CancellableEvent {

View File

@ -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 { public class PlayerPluginMessageEvent extends Event {

View File

@ -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; import net.minestom.server.utils.Position;
public class PlayerRespawnEvent extends Event { public class PlayerRespawnEvent extends Event {

View File

@ -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; import net.minestom.server.instance.Instance;
public class PlayerSpawnEvent extends EntitySpawnEvent { public class PlayerSpawnEvent extends EntitySpawnEvent {

View File

@ -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.instance.block.CustomBlock;
import net.minestom.server.utils.BlockPosition; import net.minestom.server.utils.BlockPosition;

View File

@ -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; import net.minestom.server.item.ItemStack;
public class PlayerSwapItemEvent extends CancellableEvent { public class PlayerSwapItemEvent extends CancellableEvent {

View File

@ -0,0 +1,6 @@
package net.minestom.server.event.player;
import net.minestom.server.event.Event;
public class PlayerTickEvent extends Event {
}

View File

@ -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.entity.Player;
import net.minestom.server.event.CancellableEvent;
import net.minestom.server.item.ItemStack; import net.minestom.server.item.ItemStack;
/** /**

View File

@ -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.entity.Player;
import net.minestom.server.event.Event;
import net.minestom.server.item.ItemStack; import net.minestom.server.item.ItemStack;
import net.minestom.server.utils.BlockPosition; import net.minestom.server.utils.BlockPosition;
import net.minestom.server.utils.Direction; import net.minestom.server.utils.Direction;

View File

@ -5,6 +5,11 @@ import net.minestom.server.MinecraftServer;
import net.minestom.server.data.Data; import net.minestom.server.data.Data;
import net.minestom.server.data.DataContainer; import net.minestom.server.data.DataContainer;
import net.minestom.server.entity.*; 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.BlockBatch;
import net.minestom.server.instance.batch.ChunkBatch; import net.minestom.server.instance.batch.ChunkBatch;
import net.minestom.server.instance.block.Block; import net.minestom.server.instance.block.Block;
@ -22,6 +27,7 @@ import net.minestom.server.world.Dimension;
import java.util.*; import java.util.*;
import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.CopyOnWriteArrayList;
import java.util.concurrent.CopyOnWriteArraySet; import java.util.concurrent.CopyOnWriteArraySet;
import java.util.function.Consumer; import java.util.function.Consumer;
@ -32,6 +38,8 @@ public abstract class Instance implements BlockModifier, DataContainer {
private Dimension dimension; private Dimension dimension;
private Map<Class<? extends Event>, List<EventCallback>> eventCallbacks = new ConcurrentHashMap<>();
// Entities present in this instance // Entities present in this instance
protected Set<Player> players = new CopyOnWriteArraySet<>(); protected Set<Player> players = new CopyOnWriteArraySet<>();
protected Set<EntityCreature> creatures = new CopyOnWriteArraySet<>(); protected Set<EntityCreature> creatures = new CopyOnWriteArraySet<>();
@ -266,6 +274,30 @@ public abstract class Instance implements BlockModifier, DataContainer {
this.data = data; 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) // UNSAFE METHODS (need most of time to be synchronized)
public void addEntity(Entity entity) { public void addEntity(Entity entity) {
@ -273,7 +305,8 @@ public abstract class Instance implements BlockModifier, DataContainer {
if (lastInstance != null && lastInstance != this) { if (lastInstance != null && lastInstance != this) {
lastInstance.removeEntity(entity); // If entity is in another instance, remove it from there and add it to 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); long[] visibleChunksEntity = ChunkUtils.getChunksInRange(entity.getPosition(), MinecraftServer.ENTITY_VIEW_DISTANCE);
boolean isPlayer = entity instanceof Player; boolean isPlayer = entity instanceof Player;
@ -296,6 +329,7 @@ public abstract class Instance implements BlockModifier, DataContainer {
Chunk chunk = getChunkAt(entity.getPosition()); Chunk chunk = getChunkAt(entity.getPosition());
addEntityToChunk(entity, chunk); addEntityToChunk(entity, chunk);
});
} }
public void removeEntity(Entity entity) { public void removeEntity(Entity entity) {
@ -303,10 +337,14 @@ public abstract class Instance implements BlockModifier, DataContainer {
if (entityInstance == null || entityInstance != this) if (entityInstance == null || entityInstance != this)
return; return;
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 entity.getViewers().forEach(p -> entity.removeViewer(p)); // Remove this entity from players viewable list and send delete entities packet
Chunk chunk = getChunkAt(entity.getPosition()); Chunk chunk = getChunkAt(entity.getPosition());
removeEntityFromChunk(entity, chunk); removeEntityFromChunk(entity, chunk);
});
} }
public void addEntityToChunk(Entity entity, Chunk chunk) { public void addEntityToChunk(Entity entity, Chunk chunk) {

View File

@ -4,7 +4,7 @@ import io.netty.buffer.ByteBuf;
import net.minestom.server.MinecraftServer; import net.minestom.server.MinecraftServer;
import net.minestom.server.data.Data; import net.minestom.server.data.Data;
import net.minestom.server.entity.Player; 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.BlockBatch;
import net.minestom.server.instance.batch.ChunkBatch; import net.minestom.server.instance.batch.ChunkBatch;
import net.minestom.server.instance.block.Block; import net.minestom.server.instance.block.Block;

View File

@ -1,7 +1,7 @@
package net.minestom.server.inventory; package net.minestom.server.inventory;
import net.minestom.server.entity.Player; 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.inventory.click.ClickType;
import net.minestom.server.item.ItemStack; import net.minestom.server.item.ItemStack;

View File

@ -1,7 +1,7 @@
package net.minestom.server.inventory; package net.minestom.server.inventory;
import net.minestom.server.entity.Player; 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.ClickType;
import net.minestom.server.inventory.click.InventoryClickLoopHandler; import net.minestom.server.inventory.click.InventoryClickLoopHandler;
import net.minestom.server.inventory.click.InventoryClickProcessor; import net.minestom.server.inventory.click.InventoryClickProcessor;

View File

@ -1,8 +1,8 @@
package net.minestom.server.inventory.click; package net.minestom.server.inventory.click;
import net.minestom.server.entity.Player; import net.minestom.server.entity.Player;
import net.minestom.server.event.InventoryClickEvent; import net.minestom.server.event.inventory.InventoryClickEvent;
import net.minestom.server.event.InventoryPreClickEvent; import net.minestom.server.event.inventory.InventoryPreClickEvent;
import net.minestom.server.inventory.Inventory; import net.minestom.server.inventory.Inventory;
import net.minestom.server.inventory.condition.InventoryCondition; import net.minestom.server.inventory.condition.InventoryCondition;
import net.minestom.server.inventory.condition.InventoryConditionResult; import net.minestom.server.inventory.condition.InventoryConditionResult;

View File

@ -1,7 +1,7 @@
package net.minestom.server.listener; package net.minestom.server.listener;
import net.minestom.server.entity.Player; 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.client.play.ClientAnimationPacket;
import net.minestom.server.network.packet.server.play.EntityAnimationPacket; import net.minestom.server.network.packet.server.play.EntityAnimationPacket;

View File

@ -5,9 +5,9 @@ import net.minestom.server.data.Data;
import net.minestom.server.entity.Entity; import net.minestom.server.entity.Entity;
import net.minestom.server.entity.GameMode; import net.minestom.server.entity.GameMode;
import net.minestom.server.entity.Player; import net.minestom.server.entity.Player;
import net.minestom.server.event.PlayerBlockInteractEvent; import net.minestom.server.event.player.PlayerBlockInteractEvent;
import net.minestom.server.event.PlayerBlockPlaceEvent; import net.minestom.server.event.player.PlayerBlockPlaceEvent;
import net.minestom.server.event.PlayerUseItemOnBlockEvent; import net.minestom.server.event.player.PlayerUseItemOnBlockEvent;
import net.minestom.server.instance.Chunk; import net.minestom.server.instance.Chunk;
import net.minestom.server.instance.Instance; import net.minestom.server.instance.Instance;
import net.minestom.server.instance.block.Block; import net.minestom.server.instance.block.Block;

View File

@ -9,8 +9,8 @@ import net.minestom.server.MinecraftServer;
import net.minestom.server.chat.Chat; import net.minestom.server.chat.Chat;
import net.minestom.server.command.CommandManager; import net.minestom.server.command.CommandManager;
import net.minestom.server.entity.Player; import net.minestom.server.entity.Player;
import net.minestom.server.event.PlayerChatEvent; import net.minestom.server.event.player.PlayerChatEvent;
import net.minestom.server.event.PlayerCommandEvent; import net.minestom.server.event.player.PlayerCommandEvent;
import net.minestom.server.network.packet.client.play.ClientChatMessagePacket; import net.minestom.server.network.packet.client.play.ClientChatMessagePacket;
import java.util.function.Function; import java.util.function.Function;

View File

@ -2,9 +2,9 @@ package net.minestom.server.listener;
import net.minestom.server.entity.GameMode; import net.minestom.server.entity.GameMode;
import net.minestom.server.entity.Player; import net.minestom.server.entity.Player;
import net.minestom.server.event.ItemUpdateStateEvent; import net.minestom.server.event.item.ItemUpdateStateEvent;
import net.minestom.server.event.PlayerStartDiggingEvent; import net.minestom.server.event.player.PlayerStartDiggingEvent;
import net.minestom.server.event.PlayerSwapItemEvent; import net.minestom.server.event.player.PlayerSwapItemEvent;
import net.minestom.server.instance.Instance; import net.minestom.server.instance.Instance;
import net.minestom.server.instance.block.Block; import net.minestom.server.instance.block.Block;
import net.minestom.server.instance.block.CustomBlock; import net.minestom.server.instance.block.CustomBlock;

View File

@ -1,7 +1,7 @@
package net.minestom.server.listener; package net.minestom.server.listener;
import net.minestom.server.entity.Player; 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.ClientPlayerLookPacket;
import net.minestom.server.network.packet.client.play.ClientPlayerPacket; import net.minestom.server.network.packet.client.play.ClientPlayerPacket;
import net.minestom.server.network.packet.client.play.ClientPlayerPositionAndLookPacket; import net.minestom.server.network.packet.client.play.ClientPlayerPositionAndLookPacket;

View File

@ -1,7 +1,7 @@
package net.minestom.server.listener; package net.minestom.server.listener;
import net.minestom.server.entity.Player; 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; import net.minestom.server.network.packet.client.play.ClientPluginMessagePacket;
public class PluginMessageListener { public class PluginMessageListener {

View File

@ -3,8 +3,8 @@ package net.minestom.server.listener;
import net.minestom.server.entity.Entity; import net.minestom.server.entity.Entity;
import net.minestom.server.entity.LivingEntity; import net.minestom.server.entity.LivingEntity;
import net.minestom.server.entity.Player; import net.minestom.server.entity.Player;
import net.minestom.server.event.AttackEvent; import net.minestom.server.event.entity.AttackEvent;
import net.minestom.server.event.PlayerInteractEvent; import net.minestom.server.event.player.PlayerInteractEvent;
import net.minestom.server.network.packet.client.play.ClientInteractEntityPacket; import net.minestom.server.network.packet.client.play.ClientInteractEntityPacket;
public class UseEntityListener { public class UseEntityListener {

View File

@ -1,9 +1,9 @@
package net.minestom.server.listener; package net.minestom.server.listener;
import net.minestom.server.entity.Player; import net.minestom.server.entity.Player;
import net.minestom.server.event.ArmAnimationEvent; import net.minestom.server.event.animation.ArmAnimationEvent;
import net.minestom.server.event.ArmorEquipEvent; import net.minestom.server.event.item.ArmorEquipEvent;
import net.minestom.server.event.PlayerUseItemEvent; import net.minestom.server.event.player.PlayerUseItemEvent;
import net.minestom.server.inventory.PlayerInventory; import net.minestom.server.inventory.PlayerInventory;
import net.minestom.server.item.ItemStack; import net.minestom.server.item.ItemStack;
import net.minestom.server.item.Material; import net.minestom.server.item.Material;

View File

@ -1,7 +1,7 @@
package net.minestom.server.listener; package net.minestom.server.listener;
import net.minestom.server.entity.Player; 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.Inventory;
import net.minestom.server.inventory.InventoryClickHandler; import net.minestom.server.inventory.InventoryClickHandler;
import net.minestom.server.inventory.PlayerInventory; import net.minestom.server.inventory.PlayerInventory;