Packet refactor
This commit is contained in:
@@ -26,6 +26,7 @@ import com.willfp.eco.core.gui.slot.SlotBuilder;
|
||||
import com.willfp.eco.core.gui.slot.functional.SlotProvider;
|
||||
import com.willfp.eco.core.items.TestableItem;
|
||||
import com.willfp.eco.core.math.MathContext;
|
||||
import com.willfp.eco.core.packet.Packet;
|
||||
import com.willfp.eco.core.proxy.ProxyFactory;
|
||||
import com.willfp.eco.core.scheduling.Scheduler;
|
||||
import net.kyori.adventure.platform.bukkit.BukkitAudiences;
|
||||
@@ -551,7 +552,16 @@ public interface Eco {
|
||||
*
|
||||
* @param command The command.
|
||||
*/
|
||||
void unregisterCommand(@NotNull final PluginCommandBase command);
|
||||
void unregisterCommand(@NotNull PluginCommandBase command);
|
||||
|
||||
/**
|
||||
* Send a packet.
|
||||
*
|
||||
* @param player The player.
|
||||
* @param packet The packet.
|
||||
*/
|
||||
void sendPacket(@NotNull Player player,
|
||||
@NotNull Packet packet);
|
||||
|
||||
/**
|
||||
* Get the instance of eco; the bridge between the api frontend and the implementation backend.
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package com.willfp.eco.core.packet;
|
||||
|
||||
import com.willfp.eco.core.Eco;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
@@ -8,5 +10,12 @@ import org.jetbrains.annotations.NotNull;
|
||||
* @param handle The NMS handle.
|
||||
*/
|
||||
public record Packet(@NotNull Object handle) {
|
||||
|
||||
/**
|
||||
* Send to a player.
|
||||
*
|
||||
* @param player The player.
|
||||
*/
|
||||
void send(@NotNull final Player player) {
|
||||
Eco.get().sendPacket(player, this);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
@file:JvmName("PacketExtensions")
|
||||
|
||||
package com.willfp.eco.core.packet
|
||||
|
||||
import org.bukkit.entity.Player
|
||||
|
||||
/** @see Packet.send */
|
||||
fun Player.sendPacket(packet: Packet) =
|
||||
packet.send(this)
|
||||
Reference in New Issue
Block a user