getMelodyPlayerFromSocketID()
getMelodyPlayerFromSocketID Method in MelodyManager Class
getMelodyPlayerFromSocketID Method in MelodyManager ClassMethod Signature
public MelodyPlayer getMelodyPlayerFromSocketID(String socketID)Parameters
Parameter
Type
Description
socketID
String
The socket ID of the player whose MelodyPlayer instance is to be retrieved.
Example
Here is an example of how to use the getMelodyPlayerFromSocketID method in another plugin:
import ir.taher7.melodymine.core.MelodyManager;
import ir.taher7.melodymine.models.MelodyPlayer;
public class ExamplePlugin {
public void printPlayerNameFromSocketID(String playerSocketID) {
MelodyPlayer player = MelodyManager.INSTANCE.getMelodyPlayerFromSocketID(playerSocketID);
if (player != null) {
Bukkit.getLogger().info("Player name: " + player.getName());
} else {
Bukkit.getLogger().warning("Player not found.");
}
}
}In this example, the printPlayerNameFromSocketID method in the ExamplePlugin class retrieves the MelodyPlayer instance for the player using their socket ID. It then prints the player's name to the console. If the player is not found, a warning is logged instead.
Last updated