diff --git a/api/src/main/java/de/oliver/fancysitula/api/packets/FS_ClientboundAddEntityPacket.java b/api/src/main/java/de/oliver/fancysitula/api/packets/FS_ClientboundAddEntityPacket.java index 44f90fe..ef9ac54 100644 --- a/api/src/main/java/de/oliver/fancysitula/api/packets/FS_ClientboundAddEntityPacket.java +++ b/api/src/main/java/de/oliver/fancysitula/api/packets/FS_ClientboundAddEntityPacket.java @@ -7,7 +7,7 @@ /** * Used to add an entity to the client's world. */ -public abstract class FS_ClientboundAddEntityPacket implements FS_ClientboundPacket { +public abstract class FS_ClientboundAddEntityPacket extends FS_ClientboundPacket { protected int entityId; protected UUID entityUUID; diff --git a/api/src/main/java/de/oliver/fancysitula/api/packets/FS_ClientboundPacket.java b/api/src/main/java/de/oliver/fancysitula/api/packets/FS_ClientboundPacket.java index 7086675..0f527a2 100644 --- a/api/src/main/java/de/oliver/fancysitula/api/packets/FS_ClientboundPacket.java +++ b/api/src/main/java/de/oliver/fancysitula/api/packets/FS_ClientboundPacket.java @@ -3,19 +3,39 @@ import de.oliver.fancysitula.api.entities.FS_RealPlayer; import org.jetbrains.annotations.ApiStatus; -public interface FS_ClientboundPacket { +public abstract class FS_ClientboundPacket { + + protected static boolean enableDebugLogs = false; + + /** + * Enables debug logs for all packets. + */ + public static void enableDebugLogs() { + enableDebugLogs = true; + } /** * Creates the packet object. * For internal use only. */ @ApiStatus.Internal - Object createPacket(); + public abstract Object createPacket(); /** * Sends the packet to the player. - * - * @param player the player to send the packet to + * For internal use only. */ - void send(FS_RealPlayer player); + @ApiStatus.Internal + protected abstract void sendPacketTo(FS_RealPlayer player); + + /** + * Sends the packet to the player. + */ + public final void send(FS_RealPlayer player) { + if (enableDebugLogs) { + System.out.println("Sending packet '" + this.getClass().getSimpleName() + "' to " + player.getBukkitPlayer().getName()); + } + + sendPacketTo(player); + } } diff --git a/api/src/main/java/de/oliver/fancysitula/api/packets/FS_ClientboundPlayerInfoRemovePacket.java b/api/src/main/java/de/oliver/fancysitula/api/packets/FS_ClientboundPlayerInfoRemovePacket.java index 7ff2d75..359c0db 100644 --- a/api/src/main/java/de/oliver/fancysitula/api/packets/FS_ClientboundPlayerInfoRemovePacket.java +++ b/api/src/main/java/de/oliver/fancysitula/api/packets/FS_ClientboundPlayerInfoRemovePacket.java @@ -6,7 +6,7 @@ /** * Used to remove players from the client's player list. */ -public abstract class FS_ClientboundPlayerInfoRemovePacket implements FS_ClientboundPacket { +public abstract class FS_ClientboundPlayerInfoRemovePacket extends FS_ClientboundPacket { protected List uuids; diff --git a/api/src/main/java/de/oliver/fancysitula/api/packets/FS_ClientboundPlayerInfoUpdatePacket.java b/api/src/main/java/de/oliver/fancysitula/api/packets/FS_ClientboundPlayerInfoUpdatePacket.java index 3c27697..4e15b7e 100644 --- a/api/src/main/java/de/oliver/fancysitula/api/packets/FS_ClientboundPlayerInfoUpdatePacket.java +++ b/api/src/main/java/de/oliver/fancysitula/api/packets/FS_ClientboundPlayerInfoUpdatePacket.java @@ -12,7 +12,7 @@ /** * Used to update the player list of the client. */ -public abstract class FS_ClientboundPlayerInfoUpdatePacket implements FS_ClientboundPacket { +public abstract class FS_ClientboundPlayerInfoUpdatePacket extends FS_ClientboundPacket { protected EnumSet actions; protected List entries; diff --git a/api/src/main/java/de/oliver/fancysitula/api/packets/FS_ClientboundRemoveEntitiesPacket.java b/api/src/main/java/de/oliver/fancysitula/api/packets/FS_ClientboundRemoveEntitiesPacket.java index d823f82..b307c10 100644 --- a/api/src/main/java/de/oliver/fancysitula/api/packets/FS_ClientboundRemoveEntitiesPacket.java +++ b/api/src/main/java/de/oliver/fancysitula/api/packets/FS_ClientboundRemoveEntitiesPacket.java @@ -5,7 +5,7 @@ /** * Used to remove entities from the client's world. */ -public abstract class FS_ClientboundRemoveEntitiesPacket implements FS_ClientboundPacket { +public abstract class FS_ClientboundRemoveEntitiesPacket extends FS_ClientboundPacket { protected List entityIds; diff --git a/api/src/main/java/de/oliver/fancysitula/api/packets/FS_ClientboundRotateHeadPacket.java b/api/src/main/java/de/oliver/fancysitula/api/packets/FS_ClientboundRotateHeadPacket.java index 69902ee..9563482 100644 --- a/api/src/main/java/de/oliver/fancysitula/api/packets/FS_ClientboundRotateHeadPacket.java +++ b/api/src/main/java/de/oliver/fancysitula/api/packets/FS_ClientboundRotateHeadPacket.java @@ -1,6 +1,6 @@ package de.oliver.fancysitula.api.packets; -public abstract class FS_ClientboundRotateHeadPacket implements FS_ClientboundPacket { +public abstract class FS_ClientboundRotateHeadPacket extends FS_ClientboundPacket { protected int entityId; protected float headYaw; diff --git a/api/src/main/java/de/oliver/fancysitula/api/packets/FS_ClientboundSetEntityDataPacket.java b/api/src/main/java/de/oliver/fancysitula/api/packets/FS_ClientboundSetEntityDataPacket.java index 51f8c3e..a433475 100644 --- a/api/src/main/java/de/oliver/fancysitula/api/packets/FS_ClientboundSetEntityDataPacket.java +++ b/api/src/main/java/de/oliver/fancysitula/api/packets/FS_ClientboundSetEntityDataPacket.java @@ -2,7 +2,7 @@ import java.util.List; -public abstract class FS_ClientboundSetEntityDataPacket implements FS_ClientboundPacket { +public abstract class FS_ClientboundSetEntityDataPacket extends FS_ClientboundPacket { protected int entityId; protected List entityData; diff --git a/api/src/main/java/de/oliver/fancysitula/api/packets/FS_ClientboundSetEquipmentPacket.java b/api/src/main/java/de/oliver/fancysitula/api/packets/FS_ClientboundSetEquipmentPacket.java index a764301..8cad16c 100644 --- a/api/src/main/java/de/oliver/fancysitula/api/packets/FS_ClientboundSetEquipmentPacket.java +++ b/api/src/main/java/de/oliver/fancysitula/api/packets/FS_ClientboundSetEquipmentPacket.java @@ -5,7 +5,7 @@ import java.util.Map; -public abstract class FS_ClientboundSetEquipmentPacket implements FS_ClientboundPacket { +public abstract class FS_ClientboundSetEquipmentPacket extends FS_ClientboundPacket { protected int entityId; protected Map equipment; diff --git a/api/src/main/java/de/oliver/fancysitula/api/packets/FS_ClientboundSetPassengersPacket.java b/api/src/main/java/de/oliver/fancysitula/api/packets/FS_ClientboundSetPassengersPacket.java index 8bf4ef5..34d6197 100644 --- a/api/src/main/java/de/oliver/fancysitula/api/packets/FS_ClientboundSetPassengersPacket.java +++ b/api/src/main/java/de/oliver/fancysitula/api/packets/FS_ClientboundSetPassengersPacket.java @@ -2,7 +2,7 @@ import java.util.List; -public abstract class FS_ClientboundSetPassengersPacket implements FS_ClientboundPacket { +public abstract class FS_ClientboundSetPassengersPacket extends FS_ClientboundPacket { protected int entityId; protected List passengers; diff --git a/api/src/main/java/de/oliver/fancysitula/api/packets/FS_ClientboundTeleportEntityPacket.java b/api/src/main/java/de/oliver/fancysitula/api/packets/FS_ClientboundTeleportEntityPacket.java index c6daede..d9495ae 100644 --- a/api/src/main/java/de/oliver/fancysitula/api/packets/FS_ClientboundTeleportEntityPacket.java +++ b/api/src/main/java/de/oliver/fancysitula/api/packets/FS_ClientboundTeleportEntityPacket.java @@ -1,6 +1,6 @@ package de.oliver.fancysitula.api.packets; -public abstract class FS_ClientboundTeleportEntityPacket implements FS_ClientboundPacket { +public abstract class FS_ClientboundTeleportEntityPacket extends FS_ClientboundPacket { protected int entityId; protected double x; diff --git a/implementations/1_20_6/src/main/java/de/oliver/fancysitula/versions/v1_20_6/packets/ClientboundAddEntityPacketImpl.java b/implementations/1_20_6/src/main/java/de/oliver/fancysitula/versions/v1_20_6/packets/ClientboundAddEntityPacketImpl.java index 721b002..c73996c 100644 --- a/implementations/1_20_6/src/main/java/de/oliver/fancysitula/versions/v1_20_6/packets/ClientboundAddEntityPacketImpl.java +++ b/implementations/1_20_6/src/main/java/de/oliver/fancysitula/versions/v1_20_6/packets/ClientboundAddEntityPacketImpl.java @@ -39,7 +39,7 @@ public Object createPacket() { } @Override - public void send(FS_RealPlayer player) { + public void sendPacketTo(FS_RealPlayer player) { ClientboundAddEntityPacket packet = (ClientboundAddEntityPacket) createPacket(); ServerPlayer vanillaPlayer = VanillaPlayerAdapter.asVanilla(player.getBukkitPlayer()); diff --git a/implementations/1_20_6/src/main/java/de/oliver/fancysitula/versions/v1_20_6/packets/ClientboundPlayerInfoRemovePacketImpl.java b/implementations/1_20_6/src/main/java/de/oliver/fancysitula/versions/v1_20_6/packets/ClientboundPlayerInfoRemovePacketImpl.java index a774cf0..8a4626f 100644 --- a/implementations/1_20_6/src/main/java/de/oliver/fancysitula/versions/v1_20_6/packets/ClientboundPlayerInfoRemovePacketImpl.java +++ b/implementations/1_20_6/src/main/java/de/oliver/fancysitula/versions/v1_20_6/packets/ClientboundPlayerInfoRemovePacketImpl.java @@ -21,7 +21,7 @@ public Object createPacket() { } @Override - public void send(FS_RealPlayer player) { + public void sendPacketTo(FS_RealPlayer player) { ClientboundPlayerInfoRemovePacket packet = (ClientboundPlayerInfoRemovePacket) createPacket(); ServerPlayer vanillaPlayer = VanillaPlayerAdapter.asVanilla(player.getBukkitPlayer()); diff --git a/implementations/1_20_6/src/main/java/de/oliver/fancysitula/versions/v1_20_6/packets/ClientboundPlayerInfoUpdatePacketImpl.java b/implementations/1_20_6/src/main/java/de/oliver/fancysitula/versions/v1_20_6/packets/ClientboundPlayerInfoUpdatePacketImpl.java index b94934d..b49c985 100644 --- a/implementations/1_20_6/src/main/java/de/oliver/fancysitula/versions/v1_20_6/packets/ClientboundPlayerInfoUpdatePacketImpl.java +++ b/implementations/1_20_6/src/main/java/de/oliver/fancysitula/versions/v1_20_6/packets/ClientboundPlayerInfoUpdatePacketImpl.java @@ -43,7 +43,7 @@ public Object createPacket() { } @Override - public void send(FS_RealPlayer player) { + public void sendPacketTo(FS_RealPlayer player) { ClientboundPlayerInfoUpdatePacket packet = (ClientboundPlayerInfoUpdatePacket) createPacket(); ServerPlayer vanillaPlayer = VanillaPlayerAdapter.asVanilla(player.getBukkitPlayer()); diff --git a/implementations/1_20_6/src/main/java/de/oliver/fancysitula/versions/v1_20_6/packets/ClientboundRemoveEntitiesPacketImpl.java b/implementations/1_20_6/src/main/java/de/oliver/fancysitula/versions/v1_20_6/packets/ClientboundRemoveEntitiesPacketImpl.java index feaf708..7b3c35a 100644 --- a/implementations/1_20_6/src/main/java/de/oliver/fancysitula/versions/v1_20_6/packets/ClientboundRemoveEntitiesPacketImpl.java +++ b/implementations/1_20_6/src/main/java/de/oliver/fancysitula/versions/v1_20_6/packets/ClientboundRemoveEntitiesPacketImpl.java @@ -28,7 +28,7 @@ public Object createPacket() { } @Override - public void send(FS_RealPlayer player) { + public void sendPacketTo(FS_RealPlayer player) { ClientboundRemoveEntitiesPacket packet = (ClientboundRemoveEntitiesPacket) createPacket(); ServerPlayer vanillaPlayer = VanillaPlayerAdapter.asVanilla(player.getBukkitPlayer()); diff --git a/implementations/1_20_6/src/main/java/de/oliver/fancysitula/versions/v1_20_6/packets/ClientboundRotateHeadPacketImpl.java b/implementations/1_20_6/src/main/java/de/oliver/fancysitula/versions/v1_20_6/packets/ClientboundRotateHeadPacketImpl.java index 95e8ce4..8d1a8c0 100644 --- a/implementations/1_20_6/src/main/java/de/oliver/fancysitula/versions/v1_20_6/packets/ClientboundRotateHeadPacketImpl.java +++ b/implementations/1_20_6/src/main/java/de/oliver/fancysitula/versions/v1_20_6/packets/ClientboundRotateHeadPacketImpl.java @@ -29,7 +29,7 @@ public Object createPacket() { } @Override - public void send(FS_RealPlayer player) { + public void sendPacketTo(FS_RealPlayer player) { ClientboundRotateHeadPacket packet = (ClientboundRotateHeadPacket) createPacket(); ServerPlayer vanillaPlayer = VanillaPlayerAdapter.asVanilla(player.getBukkitPlayer()); diff --git a/implementations/1_20_6/src/main/java/de/oliver/fancysitula/versions/v1_20_6/packets/ClientboundSetEntityDataPacketImpl.java b/implementations/1_20_6/src/main/java/de/oliver/fancysitula/versions/v1_20_6/packets/ClientboundSetEntityDataPacketImpl.java index f9c6d0e..573d7e8 100644 --- a/implementations/1_20_6/src/main/java/de/oliver/fancysitula/versions/v1_20_6/packets/ClientboundSetEntityDataPacketImpl.java +++ b/implementations/1_20_6/src/main/java/de/oliver/fancysitula/versions/v1_20_6/packets/ClientboundSetEntityDataPacketImpl.java @@ -58,7 +58,7 @@ public Object createPacket() { } @Override - public void send(FS_RealPlayer player) { + public void sendPacketTo(FS_RealPlayer player) { ClientboundSetEntityDataPacket packet = (ClientboundSetEntityDataPacket) createPacket(); ServerPlayer vanillaPlayer = VanillaPlayerAdapter.asVanilla(player.getBukkitPlayer()); diff --git a/implementations/1_20_6/src/main/java/de/oliver/fancysitula/versions/v1_20_6/packets/ClientboundSetEquipmentPacketImpl.java b/implementations/1_20_6/src/main/java/de/oliver/fancysitula/versions/v1_20_6/packets/ClientboundSetEquipmentPacketImpl.java index c36238e..e25b481 100644 --- a/implementations/1_20_6/src/main/java/de/oliver/fancysitula/versions/v1_20_6/packets/ClientboundSetEquipmentPacketImpl.java +++ b/implementations/1_20_6/src/main/java/de/oliver/fancysitula/versions/v1_20_6/packets/ClientboundSetEquipmentPacketImpl.java @@ -36,7 +36,7 @@ public Object createPacket() { } @Override - public void send(FS_RealPlayer player) { + public void sendPacketTo(FS_RealPlayer player) { ClientboundSetEquipmentPacket packet = (ClientboundSetEquipmentPacket) createPacket(); ServerPlayer vanillaPlayer = VanillaPlayerAdapter.asVanilla(player.getBukkitPlayer()); diff --git a/implementations/1_20_6/src/main/java/de/oliver/fancysitula/versions/v1_20_6/packets/ClientboundSetPassengersPacketImpl.java b/implementations/1_20_6/src/main/java/de/oliver/fancysitula/versions/v1_20_6/packets/ClientboundSetPassengersPacketImpl.java index ded6fec..1b20181 100644 --- a/implementations/1_20_6/src/main/java/de/oliver/fancysitula/versions/v1_20_6/packets/ClientboundSetPassengersPacketImpl.java +++ b/implementations/1_20_6/src/main/java/de/oliver/fancysitula/versions/v1_20_6/packets/ClientboundSetPassengersPacketImpl.java @@ -36,7 +36,7 @@ public Object createPacket() { } @Override - public void send(FS_RealPlayer player) { + public void sendPacketTo(FS_RealPlayer player) { ClientboundSetPassengersPacket packet = (ClientboundSetPassengersPacket) createPacket(); ServerPlayer vanillaPlayer = VanillaPlayerAdapter.asVanilla(player.getBukkitPlayer()); diff --git a/implementations/1_20_6/src/main/java/de/oliver/fancysitula/versions/v1_20_6/packets/ClientboundTeleportEntityPacketImpl.java b/implementations/1_20_6/src/main/java/de/oliver/fancysitula/versions/v1_20_6/packets/ClientboundTeleportEntityPacketImpl.java index 587fe9a..9221e15 100644 --- a/implementations/1_20_6/src/main/java/de/oliver/fancysitula/versions/v1_20_6/packets/ClientboundTeleportEntityPacketImpl.java +++ b/implementations/1_20_6/src/main/java/de/oliver/fancysitula/versions/v1_20_6/packets/ClientboundTeleportEntityPacketImpl.java @@ -34,7 +34,7 @@ public Object createPacket() { } @Override - public void send(FS_RealPlayer player) { + public void sendPacketTo(FS_RealPlayer player) { ClientboundTeleportEntityPacket packet = (ClientboundTeleportEntityPacket) createPacket(); ServerPlayer vanillaPlayer = VanillaPlayerAdapter.asVanilla(player.getBukkitPlayer()); diff --git a/test_plugin/src/main/java/de/oliver/fancysitula/FancySitulaPlugin.java b/test_plugin/src/main/java/de/oliver/fancysitula/FancySitulaPlugin.java index c99ff96..de6be7e 100644 --- a/test_plugin/src/main/java/de/oliver/fancysitula/FancySitulaPlugin.java +++ b/test_plugin/src/main/java/de/oliver/fancysitula/FancySitulaPlugin.java @@ -1,5 +1,6 @@ package de.oliver.fancysitula; +import de.oliver.fancysitula.api.packets.FS_ClientboundPacket; import de.oliver.fancysitula.commands.FancySitulaCMD; import org.bukkit.plugin.java.JavaPlugin; @@ -7,6 +8,8 @@ public class FancySitulaPlugin extends JavaPlugin { @Override public void onEnable() { + FS_ClientboundPacket.enableDebugLogs(); + getServer().getCommandMap().register("fancysitula", new FancySitulaCMD()); } }