movement and packet handler

This commit is contained in:
Freddie 2023-04-30 21:44:36 +01:00
parent f26908ecf2
commit 85c33ba2f1
5 changed files with 62 additions and 1 deletions

View File

@ -28,6 +28,12 @@
<version>1.8.8-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>minecraft-server</artifactId>
<version>1.8.8-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>

View File

@ -1,5 +1,6 @@
package lol.vera.spigot;
import lol.vera.spigot.implementation.ApiImplementation;
import lombok.Data;

View File

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

View File

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

View File

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