getMelodyPlayer()

getMelodyPlayer Method in MelodyManager Class

The getMelodyPlayer method is used to retrieve the MelodyPlayer instance for a player in the MelodyMine plugin. This method uses the player's UUID to find the corresponding MelodyPlayer instance.

Method Signature

public MelodyPlayer getMelodyPlayer(String uuid)

Parameters

ParameterTypeDescription

uuid

String

The UUID of the player whose MelodyPlayer instance is to be retrieved.

Example

Here is an example of how to use the getMelodyPlayer method in another plugin:

import ir.taher7.melodymine.core.MelodyManager;
import ir.taher7.melodymine.models.MelodyPlayer;

public class ExamplePlugin {

    public void printPlayerName(String playerUUID) {
        MelodyPlayer player = MelodyManager.INSTANCE.getMelodyPlayer(playerUUID);

        if (player != null) {
            Bukkit.getLogger().info("Player name: " + player.getName());
        } else {
            Bukkit.getLogger().warning("Player not found.");
        }
    }
}

In this example, the printPlayerName method in the ExamplePlugin class retrieves the MelodyPlayer instance for the player using their UUID. It then prints the player's name to the console. If the player is not found, a warning is logged instead.

Last updated