diff --git a/src/main/java/lol/vera/spigot/VeraSpigotAPI.java b/src/main/java/lol/vera/spigot/VeraSpigotAPI.java index 4bce533..2899d5a 100644 --- a/src/main/java/lol/vera/spigot/VeraSpigotAPI.java +++ b/src/main/java/lol/vera/spigot/VeraSpigotAPI.java @@ -1,6 +1,7 @@ package lol.vera.spigot; -import lol.vera.spigot.implementation.ApiImplementation; +import lol.vera.spigot.implementation.PacketHandlerImplementation; +import lol.vera.spigot.implementation.KnockbackImplementation; import lombok.Data; @@ -9,6 +10,10 @@ public class VeraSpigotAPI { public static VeraSpigotAPI INSTANCE = new VeraSpigotAPI(); - private ApiImplementation implementation = new ApiImplementation.DEFAULT(); + private KnockbackImplementation knockback + = new KnockbackImplementation.DEFAULT(); + + private PacketHandlerImplementation packetHandler + = new PacketHandlerImplementation.DEFAULT(); } \ No newline at end of file diff --git a/src/main/java/lol/vera/spigot/event/PreCreatureSpawnEvent.java b/src/main/java/lol/vera/spigot/event/PreCreatureSpawnEvent.java index 94c67cb..fdae551 100644 --- a/src/main/java/lol/vera/spigot/event/PreCreatureSpawnEvent.java +++ b/src/main/java/lol/vera/spigot/event/PreCreatureSpawnEvent.java @@ -8,16 +8,8 @@ import org.bukkit.event.Event; import org.bukkit.event.HandlerList; import org.bukkit.event.entity.CreatureSpawnEvent; -/** - * WARNING: This event only fires for a limited number of cases, and not for every case that CreatureSpawnEvent does. - * - * You should still listen to CreatureSpawnEvent as a backup, and only use this event as an "enhancement". - * The intent of this event is to improve server performance, so limited use cases. - * - * Currently: NATURAL and SPAWNER based reasons. Please submit a Pull Request for future additions. - * Also, Plugins that replace Entity Registrations with their own custom entities might not fire this event. - */ public class PreCreatureSpawnEvent extends Event implements Cancellable { + private final Location location; private final EntityType type; private final CreatureSpawnEvent.SpawnReason reason; @@ -95,4 +87,5 @@ public class PreCreatureSpawnEvent extends Event implements Cancellable { public void setCancelled(boolean cancel) { cancelled = cancel; } -} + +} \ No newline at end of file diff --git a/src/main/java/lol/vera/spigot/event/PrePlayerDeathEvent.java b/src/main/java/lol/vera/spigot/event/PrePlayerDeathEvent.java index 8371456..d3969f2 100644 --- a/src/main/java/lol/vera/spigot/event/PrePlayerDeathEvent.java +++ b/src/main/java/lol/vera/spigot/event/PrePlayerDeathEvent.java @@ -14,20 +14,27 @@ public class PrePlayerDeathEvent extends PlayerEvent implements Cancellable { super(who); } + /** + * @return If the death of this player is cancelled or not + */ public boolean isCancelled() { return this.cancelled; } + /** + * Set whether the event should be cancelled + * @param cancel true if you wish to cancel this event + */ public void setCancelled(boolean cancel) { this.cancelled = cancel; } - public HandlerList getHandlers() { - return handlers; - } - public static HandlerList getHandlerList() { return handlers; } + public HandlerList getHandlers() { + return handlers; + } + } \ No newline at end of file diff --git a/src/main/java/lol/vera/spigot/implementation/ApiImplementation.java b/src/main/java/lol/vera/spigot/implementation/KnockbackImplementation.java similarity index 56% rename from src/main/java/lol/vera/spigot/implementation/ApiImplementation.java rename to src/main/java/lol/vera/spigot/implementation/KnockbackImplementation.java index f624768..a3415e2 100644 --- a/src/main/java/lol/vera/spigot/implementation/ApiImplementation.java +++ b/src/main/java/lol/vera/spigot/implementation/KnockbackImplementation.java @@ -1,16 +1,9 @@ package lol.vera.spigot.implementation; -import lol.vera.spigot.handler.IMovementHandler; -import lol.vera.spigot.handler.IPacketHandler; import lol.vera.spigot.knockback.KnockbackProfile; import org.bukkit.entity.Player; -import org.bukkit.plugin.java.JavaPlugin; -public interface ApiImplementation { - - void registerMovementHandlers(JavaPlugin plugin, IMovementHandler... movementHandlers); - - void registerPacketHandlers(JavaPlugin plugin, IPacketHandler... packetHandlers); +public interface KnockbackImplementation { KnockbackProfile getActiveKnockbackProfile(); @@ -20,17 +13,7 @@ public interface ApiImplementation { void setActiveKnockbackProfile(Player player, KnockbackProfile knockbackProfile); - class DEFAULT implements ApiImplementation { - - @Override - public void registerMovementHandlers(JavaPlugin plugin, IMovementHandler... movementHandlers) { - - } - - @Override - public void registerPacketHandlers(JavaPlugin plugin, IPacketHandler... packetHandlers) { - - } + class DEFAULT implements KnockbackImplementation { @Override public KnockbackProfile getActiveKnockbackProfile() { diff --git a/src/main/java/lol/vera/spigot/implementation/PacketHandlerImplementation.java b/src/main/java/lol/vera/spigot/implementation/PacketHandlerImplementation.java new file mode 100644 index 0000000..77c2504 --- /dev/null +++ b/src/main/java/lol/vera/spigot/implementation/PacketHandlerImplementation.java @@ -0,0 +1,28 @@ +package lol.vera.spigot.implementation; + +import lol.vera.spigot.handler.IMovementHandler; +import lol.vera.spigot.handler.IPacketHandler; +import org.bukkit.plugin.java.JavaPlugin; + +public interface PacketHandlerImplementation { + + void registerMovementHandlers(JavaPlugin plugin, IMovementHandler... movementHandlers); + + void registerPacketHandlers(JavaPlugin plugin, IPacketHandler... packetHandlers); + + + class DEFAULT implements PacketHandlerImplementation { + + @Override + public void registerMovementHandlers(JavaPlugin plugin, IMovementHandler... movementHandlers) { + + } + + @Override + public void registerPacketHandlers(JavaPlugin plugin, IPacketHandler... packetHandlers) { + + } + + } + +} \ No newline at end of file