👨MelodyPlayer

MelodyPlayer Class

The MelodyPlayer class is a data class in Kotlin that represents a player in the MelodyMine system. It contains various properties related to the player's state and actions in the system.

Properties

PropertyTypeDescription

player

Player?

The Bukkit player object.

id

Int

The unique identifier of the player in the system.

uuid

String

The UUID of the player.

name

String

The name of the player.

server

String

The server that the player is currently connected to.

socketID

String?

The ID of the socket connection for the player.

verifyCode

String?

The verification code for the player.

isActiveVoice

Boolean

Indicates whether the player's voice is active.

serverIsOnline

Boolean

Indicates whether the server is online.

webIsOnline

Boolean

Indicates whether the web interface is online.

adminMode

Boolean

Indicates whether the player is in admin mode.

isMute

Boolean

Indicates whether the player is muted.

isToggle

Boolean

Indicates whether the toggle state is on or off.

isSelfMute

Boolean

Indicates whether the player has muted themselves.

isDeafen

Boolean

Indicates whether the player is deafened.

isInCall

Boolean

Indicates whether the player is in a call.

callTarget

MelodyPlayer?

The player that the current player is in a call with.

isCallPending

Boolean

Indicates whether there is a pending call for the player.

callPendingTarget

MelodyPlayer?

The player that the current player has a pending call with.

callToggle

Boolean

Indicates whether the call toggle state is on or off.

isStartCall

Boolean

Indicates whether the player has started a call.

pendingTask

BukkitTask?

The pending task for the player.

isTalk

Boolean

Indicates whether the player is talking.

talkBossBar

TalkBossBar?

The boss bar for the player.

talkNameTag

TalkNameTag?

The name tag for the player.

isSendOffer

ArrayList<String>

The list of offers that the player has sent.

Example Usage

Here is an example of how to use the MelodyPlayer class in a Java plugin.

import ir.taher7.melodymine.models.MelodyPlayer;
import ir.taher7.melodymine.storage.Storage;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;

public class ExamplePlugin {

    public void printPlayerInfo(String uuid) {
        MelodyPlayer melodyPlayer = Storage.INSTANCE.onlinePlayers.get(uuid);
        if (melodyPlayer != null) {
            Player player = melodyPlayer.getPlayer();
            Bukkit.getLogger().info("Player ID: " + melodyPlayer.getId());
            Bukkit.getLogger().info("Player UUID: " + melodyPlayer.getUuid());
            Bukkit.getLogger().info("Player Name: " + melodyPlayer.getName());
            Bukkit.getLogger().info("Player Server: " + melodyPlayer.getServer());
            // Add more properties as needed
        } else {
            Bukkit.getLogger().info("Player not found");
        }
    }
}

In this example, the printPlayerInfo method retrieves a MelodyPlayer object from the Storage class using a UUID, and then prints various properties of the MelodyPlayer to the console.

Using MelodyManager to get MelodyPlayer

Here is an example of how to use the getMelodyPlayer and getMelodyPlayerFromSocketID methods from MelodyManager class in a Java plugin.

import ir.taher7.melodymine.models.MelodyPlayer;
import ir.taher7.melodymine.manager.MelodyManager;
import org.bukkit.Bukkit;

public class ExamplePlugin {

    public void printPlayerInfoFromManager(String uuid, String socketID) {
        MelodyPlayer melodyPlayerFromUUID = MelodyManager.INSTANCE.getMelodyPlayer(uuid);
        MelodyPlayer melodyPlayerFromSocketID = MelodyManager.INSTANCE.getMelodyPlayerFromSocketID(socketID);
        
        if (melodyPlayerFromUUID != null) {
            Bukkit.getLogger().info("Player ID from UUID: " + melodyPlayerFromUUID.getId());
        } else {
            Bukkit.getLogger().info("Player not found from UUID");
        }

        if (melodyPlayerFromSocketID != null) {
            Bukkit.getLogger().info("Player ID from SocketID: " + melodyPlayerFromSocketID.getId());
        } else {
            Bukkit.getLogger().info("Player not found from SocketID");
        }
    }
}

In this example, the printPlayerInfoFromManager method retrieves a MelodyPlayer object from the MelodyManager class using a UUID and a SocketID, and then prints the ID of the MelodyPlayer to the console.

Last updated