From 85c33ba2f164f37fa5e2b937022f1b2b294630f2 Mon Sep 17 00:00:00 2001 From: Freddie Date: Sun, 30 Apr 2023 21:44:36 +0100 Subject: [PATCH] movement and packet handler --- pom.xml | 6 ++++++ .../java/lol/vera/spigot/VeraSpigotAPI.java | 1 + .../vera/spigot/handler/IMovementHandler.java | 17 ++++++++++++++++ .../vera/spigot/handler/IPacketHandler.java | 20 +++++++++++++++++++ .../ApiImplementation.java | 19 +++++++++++++++++- 5 files changed, 62 insertions(+), 1 deletion(-) create mode 100644 src/main/java/lol/vera/spigot/handler/IMovementHandler.java create mode 100644 src/main/java/lol/vera/spigot/handler/IPacketHandler.java rename src/main/java/lol/vera/spigot/{ => implementation}/ApiImplementation.java (59%) diff --git a/pom.xml b/pom.xml index 3adeaa5..7a67ec1 100644 --- a/pom.xml +++ b/pom.xml @@ -28,6 +28,12 @@ 1.8.8-R0.1-SNAPSHOT provided + + org.spigotmc + minecraft-server + 1.8.8-SNAPSHOT + provided + org.projectlombok lombok diff --git a/src/main/java/lol/vera/spigot/VeraSpigotAPI.java b/src/main/java/lol/vera/spigot/VeraSpigotAPI.java index a9b9c8c..4bce533 100644 --- a/src/main/java/lol/vera/spigot/VeraSpigotAPI.java +++ b/src/main/java/lol/vera/spigot/VeraSpigotAPI.java @@ -1,5 +1,6 @@ package lol.vera.spigot; +import lol.vera.spigot.implementation.ApiImplementation; import lombok.Data; diff --git a/src/main/java/lol/vera/spigot/handler/IMovementHandler.java b/src/main/java/lol/vera/spigot/handler/IMovementHandler.java new file mode 100644 index 0000000..af83541 --- /dev/null +++ b/src/main/java/lol/vera/spigot/handler/IMovementHandler.java @@ -0,0 +1,17 @@ +package lol.vera.spigot.handler; + +import net.minecraft.server.PacketPlayInFlying; +import org.bukkit.Location; +import org.bukkit.entity.Player; + +public interface IMovementHandler { + + /** + * @param player The {@link Player} who has moved + * @param to The {@link Location} the player came from + * @param from The {@link Location} the player is going to + * @param packet The {@link PacketPlayInFlying} flying packet + */ + void handleMove(Player player, Location to, Location from, PacketPlayInFlying packet); + +} \ No newline at end of file diff --git a/src/main/java/lol/vera/spigot/handler/IPacketHandler.java b/src/main/java/lol/vera/spigot/handler/IPacketHandler.java new file mode 100644 index 0000000..024e9e8 --- /dev/null +++ b/src/main/java/lol/vera/spigot/handler/IPacketHandler.java @@ -0,0 +1,20 @@ +package lol.vera.spigot.handler; + +import net.minecraft.server.Packet; +import net.minecraft.server.PlayerConnection; + +public interface IPacketHandler { + + /** + * @param connection The player who we are sending the packet to + * @param packet The {@link Packet} which has been sent + */ + void handleSent(PlayerConnection connection, Packet packet); + + /** + * @param connection The player who receives the packet + * @param packet The {@link Packet} which has been received + */ + void handleReceived(PlayerConnection connection, Packet packet); + +} \ No newline at end of file diff --git a/src/main/java/lol/vera/spigot/ApiImplementation.java b/src/main/java/lol/vera/spigot/implementation/ApiImplementation.java similarity index 59% rename from src/main/java/lol/vera/spigot/ApiImplementation.java rename to src/main/java/lol/vera/spigot/implementation/ApiImplementation.java index 7508757..f624768 100644 --- a/src/main/java/lol/vera/spigot/ApiImplementation.java +++ b/src/main/java/lol/vera/spigot/implementation/ApiImplementation.java @@ -1,10 +1,17 @@ -package lol.vera.spigot; +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); + KnockbackProfile getActiveKnockbackProfile(); KnockbackProfile getKnockbackProfile(String name); @@ -15,6 +22,16 @@ public interface ApiImplementation { class DEFAULT implements ApiImplementation { + @Override + public void registerMovementHandlers(JavaPlugin plugin, IMovementHandler... movementHandlers) { + + } + + @Override + public void registerPacketHandlers(JavaPlugin plugin, IPacketHandler... packetHandlers) { + + } + @Override public KnockbackProfile getActiveKnockbackProfile() { return null;