Minecraft Server-to-Client Direct Communication Library
"Client-side only" is a term widely used when advancing in plugin development, where you're limited in interacting with player's own client. The goal of this library is to solve this issue: create a mod that can communicate with your plugin. That is exactly what SocketMC does! Send your own instructions to clients using our simple and efficient API.
All players on your server must have the SocketMC mod installed. You can download them from the following locations:
Java
import xyz.gmitch215.socketmc.spigot.SocketPlayer;
import xyz.gmitch215.socketmc.instruction.Instruction;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import java.time.Duration;
public class MyPlugin extends JavaPlugin {
@Override
public void onEnable() {
sendInstructions();
}
public void sendInstructions() {
Player player = Bukkit.getPlayer("gmitch215");
SocketPlayer sp = new SocketPlayer(player);
// Specify X and Y, Text, and Duration
// Pass the plugin instance to the sendInstruction method
sp.sendInstruction(Instruction.drawText(100, 100, "Hello World", Duration.ofSeconds(5)), this);
}
}
Kotlin
import xyz.gmitch215.socketmc.spigot.SocketPlayer
import xyz.gmitch215.socketmc.instruction.Instruction
import org.bukkit.Bukkit
import org.bukkit.entity.Player
import java.time.Duration
class MyPlugin : JavaPlugin() {
override fun onEnable() {
sendInstructions()
}
fun sendInstructions() {
val player: Player = Bukkit.getPlayer("gmitch215")
val sp = SocketPlayer(player)
// Specify X and Y, Text, and Duration
// Pass the plugin instance to the sendInstruction method
sp.sendInstruction(Instruction.drawText(100, 100, "Hello World", Duration.ofSeconds(5)), this)
}
}
Output: